diff options
author | bptato <nincsnevem662@gmail.com> | 2024-06-03 20:42:16 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-06-03 21:15:44 +0200 |
commit | 3aa8f1e0694d1606c3f3795f8b83e8a82caacd3e (patch) | |
tree | 9708d4599360116a96e4aa7f983eea387e8437c6 /src/html | |
parent | 3e12a95ab34e120fb958ba0eeebaada5def7cd11 (diff) | |
download | chawan-3aa8f1e0694d1606c3f3795f8b83e8a82caacd3e.tar.gz |
Move JS wrapper into Monoucha
Operation "modularize Chawan somewhat" part 3
Diffstat (limited to 'src/html')
-rw-r--r-- | src/html/chadombuilder.nim | 19 | ||||
-rw-r--r-- | src/html/dom.nim | 22 | ||||
-rw-r--r-- | src/html/env.nim | 11 | ||||
-rw-r--r-- | src/html/event.nim | 14 | ||||
-rw-r--r-- | src/html/formdata.nim | 8 | ||||
-rw-r--r-- | src/html/script.nim | 2 | ||||
-rw-r--r-- | src/html/xmlhttprequest.nim | 7 |
7 files changed, 46 insertions, 37 deletions
diff --git a/src/html/chadombuilder.nim b/src/html/chadombuilder.nim index 3c5b2c12..708b127c 100644 --- a/src/html/chadombuilder.nim +++ b/src/html/chadombuilder.nim @@ -1,19 +1,19 @@ import std/deques import std/options +import std/tables +import chagashi/charset +import chame/htmlparser +import chame/tags import html/catom import html/dom import html/enums -import js/jserror -import js/fromjs -import js/javascript +import monoucha/fromjs +import monoucha/javascript +import monoucha/jserror +import types/opt import types/url -import chagashi/charset - -import chame/htmlparser -import chame/tags - export htmlparser.ParseResult # DOMBuilder implementation for Chawan. @@ -260,6 +260,9 @@ proc parseHTMLFragment*(element: Element; s: string): seq[Node] = builder.finish() return root.childList +# Forward declaration hack +domParseHTMLFragment = parseHTMLFragment + proc newHTML5ParserWrapper*(window: Window; url: URL; factory: CAtomFactory; confidence: CharsetConfidence; charset: Charset): HTML5ParserWrapper = let opts = HTML5ParserOpts[Node, CAtom](scripting: window.settings.scripting) diff --git a/src/html/dom.nim b/src/html/dom.nim index af839cea..6eb1079f 100644 --- a/src/html/dom.nim +++ b/src/html/dom.nim @@ -22,19 +22,20 @@ import io/dynstream import io/promise import js/console import js/domexception -import js/fromjs -import js/javascript -import js/jserror -import js/jsopaque -import js/jspropenumlist -import js/jsutils import js/timeout -import js/tojs import loader/loader import loader/request +import monoucha/fromjs +import monoucha/javascript +import monoucha/jserror +import monoucha/jsopaque +import monoucha/jspropenumlist +import monoucha/jsutils +import monoucha/tojs import types/blob import types/color import types/matrix +import types/opt import types/referrer import types/url import types/vector @@ -4189,11 +4190,14 @@ proc toBlob(ctx: JSContext; this: HTMLCanvasElement; callback: JSValue; JS_FreeValue(ctx, res) return JS_UNDEFINED -import html/chadombuilder +# Forward declaration hack +var domParseHTMLFragment*: proc(element: Element; s: string): seq[Node] + {.nimcall.} + # https://w3c.github.io/DOM-Parsing/#dfn-fragment-parsing-algorithm proc fragmentParsingAlgorithm*(element: Element; s: string): DocumentFragment = #TODO xml - let newChildren = parseHTMLFragment(element, s) + let newChildren = domParseHTMLFragment(element, s) let fragment = element.document.newDocumentFragment() for child in newChildren: fragment.append(child) diff --git a/src/html/env.nim b/src/html/env.nim index 76aa2007..fadcd52c 100644 --- a/src/html/env.nim +++ b/src/html/env.nim @@ -1,6 +1,5 @@ import std/selectors -import bindings/quickjs import html/catom import html/chadombuilder import html/dom @@ -14,17 +13,19 @@ import js/base64 import js/console import js/domexception import js/encoding -import js/jserror import js/intl -import js/javascript -import js/jstypes import js/timeout -import js/tojs import loader/headers import loader/loader import loader/request import loader/response +import monoucha/javascript +import monoucha/jserror +import monoucha/jstypes +import monoucha/quickjs +import monoucha/tojs import types/blob +import types/opt import types/url import types/winattrs diff --git a/src/html/event.nim b/src/html/event.nim index 7ae024db..fd818048 100644 --- a/src/html/event.nim +++ b/src/html/event.nim @@ -2,13 +2,13 @@ import std/math import std/options import std/times -import bindings/quickjs -import js/jserror -import js/fromjs -import js/javascript -import js/jstypes -import js/jsutils -import js/tojs +import monoucha/quickjs +import monoucha/jserror +import monoucha/fromjs +import monoucha/javascript +import monoucha/jstypes +import monoucha/jsutils +import monoucha/tojs import types/opt type diff --git a/src/html/formdata.nim b/src/html/formdata.nim index 7f099acd..df839d3f 100644 --- a/src/html/formdata.nim +++ b/src/html/formdata.nim @@ -1,3 +1,4 @@ +import chame/tags import html/catom import html/dom import html/enums @@ -5,14 +6,13 @@ import io/dynstream import io/posixstream import js/base64 import js/domexception -import js/javascript -import js/tojs +import monoucha/javascript +import monoucha/tojs import types/blob import types/formdata +import types/opt import utils/twtstr -import chame/tags - proc constructEntryList*(form: HTMLFormElement; submitter: Element = nil; encoding = "UTF-8"): seq[FormDataEntry] diff --git a/src/html/script.nim b/src/html/script.nim index c0962b13..59ada2f0 100644 --- a/src/html/script.nim +++ b/src/html/script.nim @@ -1,4 +1,4 @@ -import js/javascript +import monoucha/javascript import types/referrer import types/url diff --git a/src/html/xmlhttprequest.nim b/src/html/xmlhttprequest.nim index 33f1e61c..92065ab4 100644 --- a/src/html/xmlhttprequest.nim +++ b/src/html/xmlhttprequest.nim @@ -1,15 +1,16 @@ import std/options import std/strutils -import bindings/quickjs import html/dom import html/event import js/domexception -import js/fromjs -import js/javascript import loader/headers import loader/request import loader/response +import monoucha/fromjs +import monoucha/javascript +import monoucha/quickjs +import types/opt import types/url type |