about summary refs log tree commit diff stats
path: root/src/local/client.nim
Commit message (Collapse)AuthorAgeFilesLines
* jserror: simplify custom error creationbptato2025-03-291-2/+1
| | | | | | | The old API was needlessly complex and suggested that it could only be used for DOMException (which is not the case). (Also optimized out code lookup from the DOMException constructor.)
* env, client: fix fetch on Clientbptato2025-03-231-0/+3
|
* forkserver: simplify & improve process cleanupbptato2025-03-131-2/+2
| | | | | | | | | | Instead of trying to track child pids (which is wrong - a child may die at any time for whatever reason, so we could have ended up murdering some random process that took its place...), just setsid on forkserver start and send SIGTERM to the entire process group on termination. Also removed the loader pid from the FileLoader object, as it is no longer useful.
* Re-add JSValueConstbptato2025-03-121-4/+4
| | | | | | | | | This time, I've also ported over the consistency check to prevent some ownership bugs. Unfortunately, the check is very limited, and it is still possible to double-free or leak JSValues. I think it would be possible to make coverage 100%, but only with ARC...
* Update QuickJS-NG to 0.9.0bptato2025-03-111-1/+1
|
* tojs: misc cleanupbptato2025-03-071-2/+2
| | | | | | | * optimize toJS set * change defineProperty wrappers to return an enum If we're going to wrap defineProperty, then let's do it properly.
* fromjs, javascript: optimize out class name registrybptato2025-02-191-6/+6
| | | | | | | | Instead of hashing the class name for isInstanceOf, we now just reuse the Nim type pointer -> JSClassID map, which should be more efficient. This removes getClass and hasClass; these can be replaced by just reusing the class ID returned from registerType.
* client: remove client getterbptato2025-02-151-3/+0
| | | | Undocumented, plus and globalThis/window are enough.
* catom: make factory globalbptato2025-02-131-1/+1
| | | | | This isn't great, but neither was passing around a pointer that pointed to a single object.
* javascript: add .jsrget, .jsrfgetbptato2025-01-221-1/+1
| | | | Implements the [Replaceable] WebIDL property.
* pager: merge ask with askChar, remove urandombptato2025-01-171-1/+1
|
* env, dom: add crypto.getRandomValues, HTMLInputElement.filesbptato2025-01-161-1/+1
|
* buffer: remove server socketbptato2025-01-091-3/+1
| | | | | | | | | | | Now we just pass through a socket created in pager. This removes the need for a socket directory, and strengthens the buffer sandbox slightly. I've kept the ServerSocket code, because I want to add some form of RPC and communication between separate instances in the future. However, I don't expect this to be handled outside the main process, so I've removed the Capsicum-specific connectat/bindat code.
* loader: use per-process control socketsbptato2025-01-081-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | Previously, each message (load, resume, passFd, etc.) would open a new connection to loader's UNIX socket, and assumed the loader was dead when the loader did not respond (ECONNREFUSED). As it turns out, this model was hopelessly broken: POSIX does not specify when a UNIX socket can refuse connections, so while it happened to work on Linux (which just blocks if it can't accept right now), FreeBSD would randomly refuse connections whenever its listen queue was full. Instead, we now take a socketpair() from the loader in addClient, and pass on one half to the client (the other half stays in loader); this is the control stream, and all messages from the specific client are sent through it. If a message includes a new stream (e.g. lcLoad), then it sends a new socketpair through the control stream. Aside from not being completely broken (and being marginally more efficient), this arrangement has several other benefits: it removes the need for authentication, almost removes the need for sockdir (now only buffers use it), and will make it easier to add async message processing in the future.
* env: do not copy attrs, fix screen on clientbptato2024-12-281-1/+4
| | | | Now screen.width etc. works in the pager too.
* client: document readFile, writeFile; add getenv, setenvbptato2024-12-141-7/+32
| | | | | | | | Both are quite useful. readFile and writeFile got a small makeover in error handling; in particular, readFile now returns null instead of the empty string when the file is missing and writeFile throws a TypeError on I/O errors.
* cookie: remove JS modulebptato2024-12-131-2/+0
| | | | I no longer need it
* client: mostly merge into pagerbptato2024-12-091-751/+11
| | | | | | | | not completely, because that would break the existing API :/ this also fixes the broken interruptHandler - it no longer crashes, but it's still inefficient... probably it should "just" handle SIGINT instead
* client: exit if quit was called inside a jobbptato2024-11-251-10/+11
| | | | ref. https://todo.sr.ht/~bptato/chawan/27
* pager, select: add more items, misc fixesbptato2024-11-251-3/+5
| | | | | | eh probably have to move the event loop to pager...
* loader/* -> serverbptato2024-11-241-4/+4
| | | | one less mystery
* pager, select: add right click menu, fix some bugsbptato2024-11-231-56/+126
| | | | | | | | | | | | | | | | | | It's *not* a context menu: items are fixed, and currently not even customizable. Former is a feature, latter is a bug. Also, select now has improved mouse support; its behavior is a combination of the w3m menu (for btn1) and GTK Firefox context menu (for btn3). Also, fix some bugs in select: * lines with double width chars are handled better (not perfectly, but at least the grid isn't completely mangled anymore) * non-multiple select now highlights the currently selected option * small selects at the bottom of the screen are handled correctly * selects at the right edge of the screen are handled correctly * select multiple no longer discards selected items on cursorLeft
* formdata: eliminate a global varbptato2024-11-151-3/+4
|
* js: reorganize modules, update docsbptato2024-11-151-6/+28
| | | | | | | most of it has already been moved to monoucha, and the rest fits better in other directories. also, move urimethodmap to config
* client: do not reopen istream if stdin is a ttybptato2024-11-121-6/+5
|
* url: reduce URL object size, simplifybptato2024-11-111-1/+1
| | | | | | | * query, fragment are now strings, not options * get rid of Host, Path types, now hostname/pathname are strings * fix ipv4 parsing error case * in file protocol, fix URL for dirlist without slash with a redirection
* client: run actions for mouse clicksbptato2024-11-101-12/+16
| | | | | stopgap measure until I think of a more flexible mouse configuration method
* dynstream: refactorbptato2024-10-201-1/+1
| | | | | | | | | | * consistently use cint instead of FileHandle - this was another remnant of winapi support; on posix, they are the same. * move "blocking" field to PosixStream * recvFileHandle -> recvFd, sendFileHandle -> sendFd * merge serversocket into dynstream * merge auxiliary C functions into dynstream_aux
* dynstream, serversocket: use posix instead of nativesocketsbptato2024-10-201-3/+0
| | | | | | | | | | | nativesockets is a wrapper over posix and winapi, but we don't support winapi, so we can just fall back to PosixStream instead. SocketStream remains as a constraint over PosixStream to allow sendFileHandle/recvFileHandle. As a nice side effect, we can drop some allowed syscalls from the seccomp filter.
* pager: refactor mailcap, console; misc fixesbptato2024-10-141-93/+36
| | | | | | | | | * use more PosixStream (because it has double-close checking) * factor out some common mailcap operations * move console from client to pager * fix case-insensitive mime type matching * replace convoluted fdin/fdout comparison logic (that only accidentally worked) with a boolean flag
* client: fix redirected buffers jumping back to parent on reloadbptato2024-10-071-0/+5
| | | | | replaceBackup was not being cleared, so the next gotoURL with a replace pointing to such buffers wouldn't work.
* timeout: accept err stream as parambptato2024-09-301-6/+3
| | | | | gets rid of a todo. (not sure why I thought this was important, but it sure looks nicer)
* select: use a separate module (again)bptato2024-09-241-0/+2
| | | | | | | | | Now we dispatch to select objects from the pager object too, just to make things even more confusing. Well, it works better than the previous arrangement, in that trying to use unimplemented movements now just throws instead of moving around the container. Yay for OOP (?)
* Replace std/selectors with pollbptato2024-09-231-57/+73
| | | | | | | | | | | | std/selectors uses OS-specific selector APIs, which sounds good in theory (faster than poll!), but sucks for portability in practice. Sure, you can fix portability bugs, but who knows how many there are on untested platforms... poll is standard, so if it works on one computer it should work on all other ones. (I hope.) As a bonus, I rewrote the timeout API for poll, which incidentally fixes setTimeout across forks. Also, SIGWINCH should now work on all platforms (as we self-pipe instead of signalfd/kqueue magic).
* client, forkserver, dynstream: misc refactorings, fixesbptato2024-09-231-59/+66
| | | | | | * fix broken int conversion in dynstream * fix EPIPE handling in forkserver * merge fdmap and connectingContainers into loader map
* loader: mmap intermediate image files, misc refactoringbptato2024-09-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | * refactor parseHeader * optimize response blob() * add direct "to cache" mode for loader requests which sets stdout to a file, and use it for image processing * move image resizing into a separate process * mmap cache files in between processing steps when possible At last, resize is no longer a part of image decoding. Also, it feels much nicer to keep encoded image data in the same cache as everything else. The mmap operations *should* be more efficient than copying the whole RGBA data through a pipe. In practice, it only makes a difference for loading (well, now just mmapping) the encoded image into the pager, where it singlehandedly speeds up image display by 10x on my test image. For the other steps, the unfortunate fact that "tocache" must delay the next fork/exec in the pipeline until the entire image is processed seems to equal out any wins we might have gotten from skipping a single raw RGBA copy. I have tried moving the delay before the exec (it's possible with yet another pipe), but it didn't help much and made the code much uglier. (Not that tocache didn't, but I can live with this...)
* client: seqify fdmapbptato2024-09-221-4/+6
|
* loader: refactor/move around some procsbptato2024-09-151-1/+2
| | | | | | | | | | | | | | Module boundaries didn't make much sense here either. Specifically: * loader/cgi was originally just one of the many "real" protocols supported by loader, so it was in a separate module (like the other ones). Now it's mostly an "internal" protocol, and it was getting cumbersome to pass all required loader state to loadCGI. * The loader interface has grown quite large, but there is no need for (or advantage in) putting it in the same module as the implementation. Now CGI is handled by loader, and the interface is in the new module "loaderiface".
* loader: improve map interfacebptato2024-09-141-1/+1
| | | | directly accessing map was a bit too error prone
* loader: refactor, misc optimizations & fixesbptato2024-09-141-11/+6
| | | | | | | | * factor out input/output handle tables; use a seq instead * add possibility to directly open cached items onto stdin (mainly an optimization for reading images, which are always cached) * close used handles on local CGI execution * make clone during load work again
* loader, client, buffer: use selectInto (not select)bptato2024-09-031-4/+6
| | | | select allocates. (makes sense, but I never realized...)
* 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.