about summary refs log tree commit diff stats
path: root/src/local/client.nim
Commit message (Collapse)AuthorAgeFilesLines
* dom: remove generic JS bindingsbptato2024-08-111-1/+1
| | | | Dispatch manually with fromJS instead.
* Update monouchabptato2024-08-091-6/+6
|
* console, client: optimize console.log (etc.)bptato2024-07-301-2/+2
| | | | use JSValue varargs instead
* Fixes for Nim 2.2bptato2024-07-291-4/+0
| | | | | | | | | * xmlhttprequest: fix missing import * painter: generic tuple workaround * dynstream: merge module with implementations (so it will work with vtables) Not enabling vtables yet since it doesn't work with refc.
* buffer, pager, config: add meta-refresh + misc fixesbptato2024-07-281-0/+1
| | | | | | | | | * buffer, pager, config: add meta-refresh value, which makes it possible to follow http-equiv=refresh META tags. * config: clean up redundant format mode parser * timeout: accept varargs for params to pass on to functions * pager: add "options" dict to JS gotoURL * twtstr: remove redundant startsWithNoCase
* client, sandbox: fix termux buildbptato2024-07-241-5/+8
| | | | | Still not perfect, because it crashes on missing /tmp dir so you have to manually set it...
* loader: copy cached items on buffer cloningbptato2024-07-201-1/+2
| | | | | This fixes a bug where cloning buffers with images would crash the browser.
* client: remove redundant global functionsbptato2024-07-161-22/+0
| | | | these are already defined on Window
* timeout: simplify, misc fixesbptato2024-07-161-7/+7
| | | | | | Merge timeout & interval code paths. This fixes clearTimeout not clearing intervals.
* 32-bit compilation fixesbptato2024-07-131-1/+1
| | | | | | | | It seems registerHandle/unregister doesn't accept cint as handles. Not sure why it even works on 64-bit targets... (maybe some converter weirdness?) Seems best to explicitly cast it away.
* timeout: fix jsvalue leakbptato2024-07-101-0/+1
|
* main, forkserver: optimize startupbptato2024-07-061-9/+2
| | | | | Merge "load config" with "fork loader", so that the loader process gets forked one packet earlier.
* config: fix JS command definitionsbptato2024-06-231-2/+3
|
* misc cleanupsbptato2024-06-221-1/+1
|
* pager: refactor drawing codebptato2024-06-221-16/+10
| | | | | | | * merge select into container * avoid unnecessary redraws in draw() for parts of the screen that haven't been updated * various image redraw fixes
* client, pager: fix cached item refcounting bugsbptato2024-06-211-5/+13
|
* img, loader: separate out png codec into cgi, misc improvementsbptato2024-06-201-2/+2
| | | | | | | | | | | | | | | * multi-processed and sandboxed PNG decoding & encoding (through local CGI) * improved request body passing (including support for output id as response body) * simplified & faster blob()/text() - now every request starts suspended, and OngoingData.buf has been replaced with loader's buffering capability * image caching: we no longer pull bitmaps from the container after every single getLines call Next steps: replace our bespoke PNG decoder with something more usable, add other decoders, and make them stream.
* dom: simplify window.loaderbptato2024-06-091-4/+1
| | | | the Option setup hasn't made much sense for a long time now
* Move JS wrapper into Monouchabptato2024-06-031-9/+9
| | | | Operation "modularize Chawan somewhat" part 3
* client: fix double click on double width charsbptato2024-05-231-7/+7
| | | | | This is not a perfect solution, but it's still better than not being able to double click on CJK links correctly.
* html: improve Request, derive Client from Windowbptato2024-05-201-20/+17
| | | | | | | * make Client an instance of Window (for less special casing) * misc work on Request & fetch * improve origin comparison (opaque origins of same URLs are now considered the same)
* config: separate tmp dir for sockets, usersbptato2024-05-161-4/+5
| | | | | | | * add $LOGNAME to the tmp directory name, so that tmpdirs of separate users don't conflict * use separate directory for sockets, so that we do not have to give buffers access to all cached pages
* client, pager: remove unnecessary std/streamsbptato2024-05-111-3/+1
|
* buffer: fix multipart formsbptato2024-05-111-5/+6
| | | | | | | | | * fix enctype not getting picked up * fix form data constructor requiring open() syscall (which gets blocked by our seccomp filter) * add closing boundary to multipart end * pass fds instead of path names through WebFile/Blob and send those through bufwriter/bufreader
* js: refactorbptato2024-05-081-6/+11
| | | | | | | * 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-1/+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
* client: make quit() actually quit, misc fixesbptato2024-05-041-33/+42
| | | | | | | * 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-32/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* sandbox: seccomp support on Linuxbptato2024-04-181-0/+4
| | | | | | | | | | | | | | | | | 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-171-28/+26
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* Add capsicum supportbptato2024-03-281-2/+5
| | | | | | | | | | | | | 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.
* config: improve input systembptato2024-03-261-8/+10
| | | | as described in <https://todo.sr.ht/~bptato/chawan/6>
* client, forkserver: remove useless codebptato2024-03-241-1/+0
|
* buffer: fix clonebptato2024-03-241-3/+3
|
* io: derive DynStream from RootObj (not Stream)bptato2024-03-241-26/+29
| | | | | | | | 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.)
* io: add bufreaderbptato2024-03-211-1/+1
| | | | analogous to bufwriter
* buffer: also buffer input readsbptato2024-03-211-1/+5
| | | | this is buffer reading from pager
* client: fix dump detectionbptato2024-03-201-7/+7
| | | | it wouldn't start dump mode if stdout was not a tty but stdin was.
* pager: add "save link", "save source"; change & document some keybindingsbptato2024-03-201-2/+2
| | | | | | | | | * `s{Enter}' now saves link, and `sS' saves source. * Changed ;, +, @ to g0, g$, gc so that it's somewhat consistent with vim (and won't conflict with ; for "repeat jump to char") * Changed (, ) to -, + so that it doesn't conflict with vi's "previous/next sentence" (once we have it...) * Add previously missing keybindings to about:chawan
* client: refactor inputbptato2024-03-181-114/+26
| | | | | * move mouse handling to term * do not use File for input just to disable buffering anyway
* config: parse mime.types/mailcap/urimethodmap inside parseConfigbptato2024-03-181-1/+1
| | | | | | Better (and simpler) than storing them all over the place. extra: change lmDownload text to match w3m
* pager: remove useless codebptato2024-03-181-1/+1
|
* config: clean up/simplifybptato2024-03-171-6/+8
| | | | | | | | | * Parse the default config at runtime. There's no significant performance difference, but this makes it much less painful to write config code. * Add better error reporting * Make fromJS2 easier to use * Unquote ChaPaths while parsing config
* client: fix "Hit any key" bug on load failurebptato2024-03-171-5/+16
| | | | it's an unintended side effect that we do not want
* io: add BuferedWriterbptato2024-03-161-2/+3
| | | | | | | | | | Unsurprisingly enough, calling `write` a million times is never going to be very fast. BufferedWriter basically does the same thing as serialize.swrite did, but queues up writes in batches before sending them. TODO: give sread a similar treatment
* client, pager: various file saving fixesbptato2024-03-161-1/+3
| | | | | | * do not immediately quit when all containers are gone * fix double saving bug * fix wrong "save to" string
* config: add start.console-buffer optionbptato2024-03-161-2/+3
| | | | useful for debugging
* Clean up BufferConfigbptato2024-03-151-2/+1
| | | | | | | | It was defined in the wrong module, and unnecessarily included LoaderClientConfig. Also, referrerPolicy was not being propagated to loader clients because it was (incorrectly) in BufferConfig instead of LoaderClientConfig.
* client: check if container was found before deleting itbptato2024-03-141-2/+2
| | | | | | Containers may also be deleted without a connection. More specifically: by mailcap, when it launches an external process without opening the output in a buffer.