about summary refs log tree commit diff stats
path: root/src/js/tojs.nim
Commit message (Collapse)AuthorAgeFilesLines
* Move JS wrapper into Monouchabptato2024-06-031-399/+0
| | | | Operation "modularize Chawan somewhat" part 3
* Fix GCC 14 compilationbptato2024-05-301-15/+22
| | | | | | | | TODO: find the exact flags we need instead of -fpermissive. See also: https://todo.sr.ht/~bptato/chawan/12 https://forum.nim-lang.org/t/11587
* js: refactorbptato2024-05-081-64/+21
| | | | | | | * prefix to-be-separated modules with js * remove dynstreams dependency * untangle from EmptyPromise * move typeptr into tojs
* js: fix compilation on 1.6.14bptato2024-05-061-2/+1
| | | | | | | | | * 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-1/+1
| | | | no point in having identical overloads
* js: move fromJS_or_return nil check to JSError toJSbptato2024-05-041-3/+4
|
* client: make quit() actually quit, misc fixesbptato2024-05-041-1/+1
| | | | | | | * 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-17/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | 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: fix some incorrect defineProperty usagebptato2024-04-211-0/+1
| | | | It consumes a value, so we must dup those that we pass.
* Update code stylebptato2024-04-171-78/+78
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* js: proper distinction between Opt/Optionbptato2024-03-241-2/+1
| | | | | | | | | | | | | | | | until now, this had very strange (and inconsistent) semantics: * err() was used for exception propagation, but also as a null value * Option accepted undefined as a none value, but not null * Opt and Option were used interchangeably (and mostly randomly) Now, Result is always used for error reporting, and err(nil) means JS_EXCEPTION. (Opt is a special case of Result where we don't care about the error type, and is not used in JS.) Option on the other hand means "nullable variation of normally non-nullable type", and translates to JS_NULL. In JS we mainly use it for turning strings nullable.
* dom: add onload content attribute to bodybptato2024-02-241-1/+19
|
* regex: re-work compileSearchRegexbptato2024-02-171-0/+11
| | | | | | | 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: define toStringTag properlybptato2024-01-241-0/+9
|
* js: merge some type modules into jstypesbptato2024-01-111-7/+5
| | | | They only had type definitions, no need to put them in separate modules.
* tojs: document + remove unused JSCFunction converterbptato2024-01-071-7/+41
|
* pager: add marksbptato2023-12-091-0/+15
| | | | | Default is vi-style, but w3m-style marks work as well; see bonus/w3m.toml.
* js: simplify toJSP0bptato2023-11-301-28/+10
| | | | | | | * 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-4/+48
|
* intl: stub out Intl.PluralRulesbptato2023-11-301-0/+9
|
* js: define global properties as CONFIGURABLE | WRITABLEbptato2023-10-251-0/+5
|
* base64: reduce pointless re-coding using JSStringbptato2023-10-211-0/+7
| | | | | We now expose some functions from QuickJS to interact with JavaScript strings without re-encoding them into UTF-8.
* javascript: add TextEncoder, TextDecoderbptato2023-10-211-0/+11
|
* dom: add document.all, misc fixesbptato2023-09-191-1/+4
| | | | | | | | * 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.
* 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/
* tojs: remove JSDictbptato2023-09-091-12/+0
| | | | it's broken anyway, and unused currently
* javascript: add JSDict typebptato2023-09-091-0/+14
| | | | And use that in extern().
* tojs: fix memory leakbptato2023-09-041-5/+12
| | | | | | Welp. GC_ref should only be called if a new reference is being created. This is what we did until 48f1306f, where this regression slipped in.
* buffer: basic click event supportbptato2023-08-311-1/+3
| | | | | | | 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: refactorbptato2023-08-281-0/+273
Split out parts of the JS module, because it was starting to confuse the compiler a little. (Peakmem is back at 750M. Interesting.)