diff options
author | bptato <nincsnevem662@gmail.com> | 2024-03-24 14:12:27 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-03-24 14:21:01 +0100 |
commit | fb21b1e4f0ee0e55e9556bf1f399d00d5eae26e4 (patch) | |
tree | c532aa98ee6bedf19b840f4ea0c7360a42407fbf /src/html | |
parent | b27deb7672c53e3ee59f91b7091e83ab28a8318d (diff) | |
download | chawan-fb21b1e4f0ee0e55e9556bf1f399d00d5eae26e4.tar.gz |
io: derive DynStream from RootObj (not Stream)
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.)
Diffstat (limited to 'src/html')
-rw-r--r-- | src/html/dom.nim | 3 | ||||
-rw-r--r-- | src/html/env.nim | 17 |
2 files changed, 11 insertions, 9 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim index 41869a95..f0cc05c9 100644 --- a/src/html/dom.nim +++ b/src/html/dom.nim @@ -18,6 +18,7 @@ import img/bitmap import img/painter import img/path import img/png +import io/dynstream import io/promise import js/console import js/domexception @@ -3515,7 +3516,7 @@ proc fetchClassicScript(element: HTMLScriptElement, url: URL, element.onComplete(ScriptResult(t: RESULT_NULL)) return #TODO make this non-blocking somehow - let s = response.body.readAll() + let s = response.body.recvAll() let source = if cs in {CHARSET_UNKNOWN, CHARSET_UTF_8}: s.toValidUTF8() else: diff --git a/src/html/env.nim b/src/html/env.nim index 3ffff116..ebd9e83e 100644 --- a/src/html/env.nim +++ b/src/html/env.nim @@ -1,5 +1,4 @@ import std/selectors -import std/streams import bindings/quickjs import html/catom @@ -9,6 +8,7 @@ import html/event import html/formdata import html/script import html/xmlhttprequest +import io/filestream import io/promise import js/base64 import js/console @@ -34,7 +34,9 @@ proc appVersion(navigator: ptr Navigator): string {.jsfget.} = "5.0 (Windows)" proc platform(navigator: ptr Navigator): string {.jsfget.} = "Win32" proc product(navigator: ptr Navigator): string {.jsfget.} = "Gecko" proc productSub(navigator: ptr Navigator): string {.jsfget.} = "20100101" -proc userAgent(navigator: ptr Navigator): string {.jsfget.} = "chawan" #TODO TODO TODO this should be configurable +proc userAgent(navigator: ptr Navigator): string {.jsfget.} = + #TODO TODO TODO this should be configurable + "chawan" proc vendor(navigator: ptr Navigator): string {.jsfget.} = "" proc vendorSub(navigator: ptr Navigator): string {.jsfget.} = "" proc taintEnabled(navigator: ptr Navigator): bool {.jsfget.} = false @@ -153,7 +155,7 @@ proc getComputedStyle(window: Window, element: Element, #TODO implement this properly return ok(element.style) -proc addScripting*(window: Window, selector: Selector[int]) = +proc addScripting*(window: Window; selector: Selector[int]) = let rt = newJSRuntime() let ctx = rt.newJSContext() window.jsrt = rt @@ -166,11 +168,10 @@ proc addScripting*(window: Window, selector: Selector[int]) = evalJSFree = (proc(src, file: string) = let ret = window.jsctx.eval(src, file, JS_EVAL_TYPE_GLOBAL) if JS_IsException(ret): - let ss = newStringStream() - window.jsctx.writeException(ss) - ss.setPosition(0) window.console.log("Exception in document", $window.document.url, - ss.readAll()) + window.jsctx.getExceptionStr()) + else: + JS_FreeValue(ctx, ret) ) ) var global = JS_GetGlobalObject(ctx) @@ -200,7 +201,7 @@ proc runJSJobs*(window: Window) = proc newWindow*(scripting, images: bool, selector: Selector[int], attrs: WindowAttributes, factory: CAtomFactory, navigate: proc(url: URL) = nil, loader = none(FileLoader)): Window = - let err = newFileStream(stderr) + let err = newDynFileStream(stderr) let window = Window( attrs: attrs, console: newConsole(err), |