about summary refs log tree commit diff stats
path: root/src/bindings
Commit message (Collapse)AuthorAgeFilesLines
* Move JS wrapper into Monouchabptato2024-06-034-653/+0
| | | | Operation "modularize Chawan somewhat" part 3
* js: fix runtime cleanupbptato2024-06-031-0/+4
| | | | | | | | | | | | | | This is a minefield. Intuitively, you would think that just clearing the opaque and manually freeing registered object should be enough. Unfortunately, this is not true; we do not store whether we are actually holding a reference to registered JS objects, so this approach leads to double frees. Instead, we add a QJS callback that is called right after the final GC cleanup, but before the list_free assertion. This way, we can be sure that any object still in our registry is referenced by us, and can therefore unreference them safely.
* Fix GCC 14 compilationbptato2024-05-301-2/+4
| | | | | | | | 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
* luwrap: use separate context (+ various cleanups)bptato2024-05-101-1/+1
| | | | | | Use a LUContext to only load required CharRanges once per pager. Also, add kana & hangul vi word break categories for convenience.
* luwrap: replace Nim unicode maps with libunicodebptato2024-05-091-4/+19
| | | | | | | | | | | | | | | | | Instead of using the built-in (and outdated, and buggy) tables, we now use libunicode from QJS. This shaves some bytes off the executable, though far less than I had imagined it would. Also, a surprising effect of this change: because libunicode's tables aren't glitched out, kanji properly gets classified as alpha. I found this greatly annoying because `w' in Japanese text would now jump through whole sentences. As a band-aid solution I added an extra Han category, but I wish we had a more robust solution that could differentiate between *all* scripts. TODO: I suspect that separately loading the tables for every rune in breaksViWordCat is rather inefficient. Using some context object (at least per operation) would probably be beneficial.
* client: make quit() actually quit, misc fixesbptato2024-05-041-0/+2
| | | | | | | * 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-12/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* adapter: update code stylebptato2024-04-261-2/+1
|
* sandbox: seccomp support on Linuxbptato2024-04-181-0/+49
| | | | | | | | | | | | | | | | | We use libseccomp, which is now a semi-mandatory dependency on Linux. (You can still build without it, but only if you pass a scary long flag to make.) For this to work I had to disable getTimezoneOffset, which would otherwise call localtime_r which in turn reads in some files from /usr/share/zoneinfo. To allow this we would have to give unrestricted openat(2) access to buffer processes, which is unacceptable. (Giving websites access to the local timezone is a fingerprinting vector so if this ever gets fixed then it should be an opt-in config setting.) This patch also includes misc fixes to buffer cloning, and fixes the LIBEXECDIR override in the makefile so that it is actually useful.
* Update code stylebptato2024-04-176-185/+224
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* sandbox: add OpenBSD pledge/unveil supportbptato2024-04-031-0/+6
| | | | | | | | | | | | pledge is a bit more fine-grained than Capsicum's capability mode, so the buffer & http ("network") sandboxes are now split up into two parts. I applied the same hack as in FreeBSD for overriding the buffer selector kqueue, because a) I didn't want to request sysctl promise b) I'm not sure if it would even work and c) if it breaks on OpenBSD, then it's broken on FreeBSD too, so there's a greater chance of discovering the bug.
* Add capsicum supportbptato2024-03-281-0/+6
| | | | | | | | | | | | | It's the sandboxing system of FreeBSD. Quite pleasant to work with. (Just trying to figure out the basics with this one before tackling the abomination that is seccomp.) Indeed, the only non-trivial part was getting newSelector to work with Capsicum. Long story short it doesn't, so we use an ugly pointer cast + assignment. But even that is stdlib's "fault", not Capsicum's. This also gets rid of that ugly SocketPath global.
* libregexp: update LRE_FLAG_UTF16 namebptato2024-03-211-1/+1
| | | | upstream now calls it unicode
* quickjs: reduce diff with upstreambptato2024-03-021-10/+4
| | | | | | * the uint8array thing is probably from txiki.js, but we never used it * upstream now has JS_GetClassID, importing that instead... (so this commit won't build :/)
* libregexp: cast flags to the right sizebptato2024-02-181-1/+1
| | | | We have less than 8 flags, so the set's size is 1.
* regex: re-work compileSearchRegexbptato2024-02-171-7/+16
| | | | | | | 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/+1
|
* js: small improvementsbptato2024-01-171-1/+1
| | | | | * turn JSFuncGenerator into a ref object (it's faster this way) * remove strformat dependency
* js: use Nim allocatorbptato2024-01-081-16/+30
|
* Use std/* imports everywherebptato2024-01-071-1/+1
|
* Fix some casing issuesbptato2024-01-061-1/+1
|
* Compile with styleCheck:usagesbptato2023-12-284-9/+9
| | | | much better
* dom: use JS_EvalFunction; add module fetching stubsbptato2023-12-251-0/+1
| | | | (still no module support in buffer...)
* bindings/quickjs: cint -> csize_tbptato2023-12-231-1/+2
| | | | | | cint was incorrect :/ Makes me wonder if maybe we should just use futhark after all...
* ftp: fix unnecessary slashes being added to path; move bindings/curlbptato2023-12-151-425/+0
| | | | also in ftp: clean up resources before exit
* http: use CURLU for URLsbptato2023-12-131-0/+78
|
* Move http out of main binarybptato2023-12-131-0/+3
| | | | | | | | | | | | Now it is (technically) no longer mandatory to link to libcurl. Also, Chawan is at last completely protocol and network backend agnostic :) * Implement multipart requests in local CGI * Implement simultaneous download of CGI data * Add REQUEST_HEADERS env var with all headers * cssparser: add a missing check in consumeEscape
* pager, container: add text selection/copyingbptato2023-12-031-0/+2
| | | | | | | | | | * Add select & copy selection functionality to container * Fix bug in generateSwapOutput where output could be misplaced because of zero-width cells * Add fromJSPromise, call runJSJobs in every iteration of the headed event loop * "await" pager actions that output a promise * Change default view source keybinding to `\'
* Get rid of clang 16 workaroundbptato2023-12-022-5/+20
| | | | | * bindings/quickjs: importc and use correct pointer types * add constcharp module for when it is unavoidable
* js: get rid of getJSValuebptato2023-12-021-1/+2
| | | | just use an UncheckedArray in the binding
* js: simplify toJSP0bptato2023-11-301-2/+6
| | | | | | | * 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)
* bindings: find termcap on FreeBSDbptato2023-11-211-2/+13
| | | | | pkg-config does not find termcap (or really, ncurses) here, so we have to find it ourselves.
* http: use Accept-Encodingbptato2023-11-171-0/+1
| | | | just ask libcurl to decode
* Add jspropnames, CSSStyleDeclaration stubbptato2023-10-251-1/+5
|
* Remove trailing spacesbptato2023-10-232-85/+85
|
* base64: reduce pointless re-coding using JSStringbptato2023-10-211-0/+11
| | | | | 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
|
* ftp, file: better dirlist, fix FTP path issuebptato2023-09-191-1/+1
| | | | | | | | | * Dirlist is now unified across ftp and file loaders. It's basically a copycat of w3m's FTP dirlist, because I like how it looks. * We now hack around the cURL FTP path problem by always prepending a slash to the path. This is probably closer aligned with expectations than the default behavior.
* dom: add document.all, misc fixesbptato2023-09-191-0/+1
| | | | | | | | * 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.
* loader: add FTP supportbptato2023-09-191-0/+8
| | | | | | | | | | | | works, sort of still needs some work: * better dirlist, ideally make it look like file dirlist (or make file look like ftp dirlist. well, anyway, they should look the same) * absolute paths? (for now you have to append an extra slash to the path beginning) * ssh keys for sftp? (actually I haven't even tested sftp yet...)
* bindings: fix JSInterruptHandler signaturebptato2023-09-151-1/+1
|
* Allow overriding libcurl namebptato2023-08-261-3/+9
| | | | for better compatibility with curl-impersonate
* javascript: misc. refactoringsbptato2023-08-241-1/+3
| | | | | | | | | | | | * Remove some unused properties from objects * Un-extern JSFunctionList * Remove js/javascript dependency from regex (the wrapper functions were rather pointless) * Remove setProperty (only toJS(Table) used it, but there we have to use defineProperty instead.) * Accordingly, use definePropertyCWE in toJS(Table) * Simplify fromJSTable (replace pointer arithmetic with UncheckedArray) * Reduce implicit `result' usage
* javascript: finish LegacyUnforgeable + misc fixesbptato2023-08-201-0/+11
| | | | | | | | Add jsuffget, jsuffunc for setting LegacyUnforgeable on functions. Misc fixes: * define LegacyUnforgeable properties for native object shims * replace some macros with templates
* javascript: update Events, misc fixes & additionsbptato2023-08-201-3/+15
| | | | | | | | | | | | | | Events: just implement the interfaces, no events are triggered yet. JS changes: * add LegacyUnforgeable * make consts enumerable * fix crash in isInstanceOf * fix destructor warnings * refactor registerType As a result, peakmem is now 1G+ on 1.6.14. It stays ~750M on 2.0.0. Hmm. Well, better upgrade to 2.0.0 I guess.
* Fixes & workarounds to compile on Nim 2.0.0bptato2023-08-012-1/+4
| | | | | | | | | | | | | | * Import punycode, as it has been removed from stdlib. * Fix some syntax errors * Apparently you can no longer compare distinct pointers with nil. Add explicit comparisons with typeof(nil) instead. * htmlparser: rename _ to other, as semantics of _ have changed. (Quite a shame, it looked better with _. Oh well.) * Explicitly specify mm:refc, as the browser OOMs with orc for some reason. Confirmed to compile & run on 2.0.0, 1.6.14, 1.6.12, 1.6.10 and 1.6.8. (<1.6.8 it's broken & wontfix.)
* Include libunicode header in bindingbptato2023-07-151-0/+5
|
* Add libregexp header to libregexp bindingbptato2023-07-042-15/+12
|
* Fix CastSize warningsbptato2023-07-031-2/+2
| | | | Introduced by 1.6.14. Warns of undefined behavior.
* Remove getClassID hackbptato2023-06-271-0/+1
| | | | Add a JS_GetClassID function to QJS instead.