about summary refs log tree commit diff stats
path: root/src/js/javascript.nim
Commit message (Collapse)AuthorAgeFilesLines
* js: fix compilation on 1.6.14bptato2024-05-061-2/+2
| | | | | | | | | * resolve empty promises without params, not a single undefined param (we can't just unsafeAddr constants on 1.6.14, and I don't see why we need to pass undefined?) * same in client with InternalError * explicitly convert static `asglobal' to bool (1.6.14 turns unquoted enums into ints...)
* Use isSome instead of isOkbptato2024-05-051-21/+16
| | | | no point in having identical overloads
* js: move fromJS_or_return nil check to JSError toJSbptato2024-05-041-4/+0
|
* client: make quit() actually quit, misc fixesbptato2024-05-041-0/+9
| | | | | | | * unwind the QJS stack with an uncatchable exception when quit is called * clean up JS references in JSRuntime free even when the Nim counterparts are still alive * simplify some tests
* js: fix various leaks etc.bptato2024-05-031-43/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously we didn't actually free the main JS runtime, probably because you can't do this without first waiting for JS to unwind the stack. (This has the unfortunate effect that code now *can* run after quit(). TODO: find a fix for this.) This isn't a huge problem per se, we only have one of these and the OS can clean it up. However, it also disabled the JS_FreeRuntime leak check, which resulted in sieve-like behavior (manual refcounting is a pain). So now we choose the other tradeoff: quit no longer runs exitnow, but it waits for the event loop to run to the end and only then exits the browser. Then, before exit we free the JS context & runtime, and also all JS values allocated by config. Fixes: * fix `ad' flag not being set for just one siteconf/omnirule * fix various leaks (since leak check is enabled now) * use ptr UncheckedArray[JSValue] for QJS bindings that take an array * allow JSAtom in jsgetprop etc., also disallow int types other than uint32 * do not set a destructor for globals
* js: override default toString tag of globalbptato2024-04-211-1/+5
| | | | Some JS modules use this to check if they are running in a browser.
* Update code stylebptato2024-04-171-116/+130
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* js: remove automatic function -> closure conversionbptato2024-04-151-10/+16
| | | | | | | | | | | | | | | It's a bad idea for several reasons: * it's inefficient; must allocate an environment for a closure in Nim, even though we already have one in JS * writing macros for automatically creating functions with variadic arguments is suprisingly difficult (see the entire `js/javascript' module) * it never really worked properly, because we never freed the associated function pointer. We hardly used it anyway, so the easiest fix is to get rid of it completely.
* remove dead code, fix openArray casingbptato2024-04-081-2/+2
|
* io: derive DynStream from RootObj (not Stream)bptato2024-03-241-4/+4
| | | | | | | | This way they are no longer compatible, but we no longer need them to be compatible anyway. (This also forces us to throw out the old serialize module, and use packet writers everywhere.)
* dom: add onload content attribute to bodybptato2024-02-241-0/+1
|
* dom: print parse errors to consolebptato2024-02-241-6/+8
| | | | instead of trying to evaluate exceptions...
* regex: re-work compileSearchRegexbptato2024-02-171-0/+1
| | | | | | | I've gotten tired of not being able to search for forward slashes. Now it works like in vim, and you can also set default ignore case in the config.
* js: always use var destructorbptato2024-01-291-8/+2
| | | | See https://forum.nim-lang.org/t/10807
* js: update pragma docsbptato2024-01-241-3/+9
|
* js: define toStringTag properlybptato2024-01-241-3/+3
|
* js: allow specifying static function name, small refactoringbptato2024-01-241-58/+60
| | | | | | | | * static function names can now be defined using the syntax `Class:functionName' (or just use `Class' to take the default name * fix URL.canParse with 1 argument only * do not store JSFuncGenerator for constructors; just put the function node in BoundFunctions
* js: small improvementsbptato2024-01-171-20/+50
| | | | | * turn JSFuncGenerator into a ref object (it's faster this way) * remove strformat dependency
* js: use Nim allocatorbptato2024-01-081-1/+19
|
* Use std/* imports everywherebptato2024-01-071-8/+8
|
* Fix some casing issuesbptato2024-01-061-4/+4
|
* Compile with styleCheck:usagesbptato2023-12-281-1/+1
| | | | much better
* dom: use JS_EvalFunction; add module fetching stubsbptato2023-12-251-0/+7
| | | | (still no module support in buffer...)
* bindings/quickjs: cint -> csize_tbptato2023-12-231-2/+3
| | | | | | cint was incorrect :/ Makes me wonder if maybe we should just use futhark after all...
* js: fix nil deref in jsgetpropbptato2023-12-201-4/+9
| | | | Turns out desc can in fact be nil.
* event: remove ctx from CustomEventbptato2023-12-031-22/+35
| | | | | Instead, make finalizers optionally pass their runtime for resource deallocation.
* js: get rid of emitbptato2023-12-021-22/+15
| | | | now I know how to :P
* js: get rid of getJSValuebptato2023-12-021-10/+9
| | | | just use an UncheckedArray in the binding
* html: add HTMLElement.dataset (+ some twtstr cleanup)bptato2023-12-011-6/+14
|
* js: simplify toJSP0bptato2023-11-301-3/+1
| | | | | | | * Expose js_create_from_ctor from QuickJS and directly use that (instead of badly recreating it) * Do not call defineUnforgeable twice (it is inevitably called in toJSP0, so jsctor does not need it)
* js: allow subclassing platform objects in JSbptato2023-11-301-1/+1
|
* js: remove nonsensical comment linebptato2023-11-261-1/+0
|
* js: refine isInstanceOf check in functionsbptato2023-10-251-9/+4
| | | | Special case the global object, check for inheritance, etc.
* js: define global properties as CONFIGURABLE | WRITABLEbptato2023-10-251-2/+2
|
* reduce new() usagebptato2023-10-251-1/+1
|
* Add jspropnames, CSSStyleDeclaration stubbptato2023-10-251-3/+50
|
* javascript: add TextEncoder, TextDecoderbptato2023-10-211-0/+1
|
* XHR progressbptato2023-10-141-3/+4
| | | | still non-functional
* js: improve optional argument handlingbptato2023-09-261-1/+4
| | | | | | | If a fallback argument has been specified, treat undefined as if no argument had been given. This removes the need for the ?? 1 checks in the config.
* dom: add document.all, misc fixesbptato2023-09-191-3/+7
| | | | | | | | * Fix an issue with Collection cache invalidation (we must invalidate collections of the parent node on insertion, so that it triggers a refresh). * Remove circular reference of document.document, now we use a function instead.
* javascript: static methods, URL.canParsebptato2023-09-171-23/+46
|
* move around more modulesbptato2023-09-141-1/+1
| | | | | | | | | | * ips -> io/ * loader related stuff -> loader/ * tempfile -> extern/ * buffer, forkserver -> server/ * lineedit, window -> display/ * cell -> types/ * opt -> types/
* javascript: fix a GC bugbptato2023-09-091-5/+22
| | | | | | | GC_unref may indirectly call nim_finalize_for_js, which could mess up execution of checkDestroy. I haven't encountered it in refc, but it's definitely present in orc.
* javascript: reference unforgeables in tablebptato2023-09-041-1/+1
| | | | | Conceptually, seqs are by-value. In practice I they are by-ref, but let's not depend on this.
* buffer: basic click event supportbptato2023-08-311-1/+1
| | | | | | | Mostly a proof of concept. Just bubble it unconditionally for now and never prevent default. Also, fix fromJSFunction by Dup'ing its closure JSValue.
* javascript: fix fromJSFunction, simplify setOpaquebptato2023-08-301-1/+1
| | | | | | * fromJSFunction: dup the value, so that it cannot go out of context. * setOpaque no longer calls GC_ref, so no need for it to be generic instead of just taking a pointer.
* javascript: factor out fromJSbptato2023-08-291-489/+4
|
* javascript: move error ctors to js/errorbptato2023-08-291-48/+0
|
* js: fix typobptato2023-08-291-1/+1
|
* Add jsdelprop, allow deletion of ActionMap propsbptato2023-08-291-2/+41
| | | | mostly for symmetry with real objects