wasm-quickjs-dom 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Run a web page's JavaScript **without a browser and without `eval`** — and read the resulting DOM.
4
4
 
5
- It is a small JSDOM for places where JSDOM cannot go: Cloudflare Workers, Vercel / Next.js Edge, Deno, Bun, browsers, and plain Node.js. The page's scripts run in [QuickJS-ng](https://github.com/quickjs-ng/quickjs) compiled to WebAssembly, on a [linkedom](https://github.com/WebReflection/linkedom) DOM, so nothing needs `eval`, native modules or a headless browser.
5
+ It is a small JSDOM for places where JSDOM cannot go: Cloudflare Workers, Vercel / Next.js Edge, Deno, Bun, browsers, and plain Node.js. The page's scripts run in [QuickJS-ng](https://github.com/quickjs-ng/quickjs) compiled to WebAssembly, on a DOM written in C inside the same WebAssembly module, so nothing needs `eval`, native modules or a headless browser.
6
6
 
7
7
  ```ts
8
8
  import { createDOM } from "wasm-quickjs-dom";
@@ -207,9 +207,9 @@ Exit code `0` is done, `1` the page could not be loaded (or `-e` threw), `2` wro
207
207
 
208
208
  ## How it works
209
209
 
210
- Each page gets its own WebAssembly instance of QuickJS-ng. The browser APIs a bare QuickJS lacks, and linkedom, are compiled to QuickJS bytecode when the package is built; the first page of a process starts that program, and every later page is a copy of that started instance, which is why a page starts in about 3 ms. Nothing is shared between pages. Each gets its own clock origin and `Math.random` seed.
210
+ Each page gets its own WebAssembly instance of QuickJS-ng. The browser APIs a bare QuickJS lacks, and the JavaScript half of the DOM (events, `MutationObserver`, custom elements, ...), are compiled to QuickJS bytecode when the package is built; the first page of a process starts that program, and every later page is a copy of that started instance, which is why a page starts in about 3 ms. Nothing is shared between pages. Each gets its own clock origin and `Math.random` seed.
211
211
 
212
- HTML (the page itself, and every `innerHTML` the page sets) is tokenized by a C port of htmlparser2 inside the WebAssembly module, which hands linkedom the same calls htmlparser2 would; that is about 2.5 times faster than parsing in the interpreter. Input the port does not reproduce exactly (for example non-ASCII tag names) falls back to htmlparser2 by itself.
212
+ The native DOM (`csrc/nativedom*.h`) keeps nodes as C structures: tree operations, a CSS selector engine (combinators, `:not` / `:is` / `:has`, `:nth-*`, attribute operators), serialization and a C port of htmlparser2 for parsing, with events, `MutationObserver`, custom elements, shadow roots, `style`, form controls and live collections layered on top in JavaScript. It is tested against jsdom operation by operation (random programs of tree edits, with every node and selector compared after each step). SVG is recognised by its root (`namespaceURI`, `createElementNS`), not modelled as a separate set of classes. Parsing is about 2.5 times faster than htmlparser2 in the interpreter was. Input the port does not reproduce exactly (for example non-ASCII tag names) falls back to htmlparser2 by itself.
213
213
 
214
214
  ## For contributors
215
215
 
@@ -222,4 +222,4 @@ pnpm --filter wasm-quickjs-dom test
222
222
 
223
223
  ## License
224
224
 
225
- MIT. QuickJS-ng, linkedom and web-streams-polyfill are included under their own licenses: see `THIRD-PARTY-NOTICES.md`.
225
+ MIT. QuickJS-ng and web-streams-polyfill are included under their own licenses: see `THIRD-PARTY-NOTICES.md`.
@@ -29,9 +29,9 @@
29
29
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
30
  THE SOFTWARE.
31
31
 
32
- - **linkedom** (<https://github.com/WebReflection/linkedom>), ISC, and **web-streams-polyfill** (<https://github.com/MattiasBuelens/web-streams-polyfill>), MIT, are bundled into the guest program `dist/edge-js-payload.js`.
32
+ - **web-streams-polyfill** (<https://github.com/MattiasBuelens/web-streams-polyfill>), MIT, is bundled into the guest program `dist/edge-js-payload.js`. (jsdom, MIT, is a devDependency the tests compare the DOM with; it is not shipped.)
33
33
 
34
- - **htmlparser2** (<https://github.com/fb55/htmlparser2>, MIT, copyright Felix Böhm and Chris Winberry) and **entities** (<https://github.com/fb55/entities>, BSD-2-Clause, copyright Felix Böhm). `dist/quickjs.wasm` contains a C port of htmlparser2's HTML tokenizer and parser (`csrc/htmlparse.h`) and the HTML named-entity table of `entities` (`csrc/entity_tree.h`); linkedom's own copy of htmlparser2 is also inside the guest program. The entity table is under:
34
+ - **htmlparser2** (<https://github.com/fb55/htmlparser2>, MIT, copyright Felix Böhm and Chris Winberry) and **entities** (<https://github.com/fb55/entities>, BSD-2-Clause, copyright Felix Böhm). `dist/quickjs.wasm` contains a C port of htmlparser2's HTML tokenizer and parser (`csrc/htmlparse.h`) and the HTML named-entity table of `entities` (`csrc/entity_tree.h`). The entity table is under:
35
35
 
36
36
  Copyright (c) Felix Böhm
37
37
  All rights reserved.