Skip to content

Commit

Permalink
chore: add entrypoint module documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
b-fuze committed May 30, 2024
1 parent 2c2638d commit 957ff92
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
34 changes: 34 additions & 0 deletions deno-dom-native.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
/**
* @module
*
* This module exposes the Deno DOM API with the native binary backend.
* Unlike the WASM backend the native backend requires more permissions
* due to the nature of how native bindings work. They include:
*
* - `--unstable-ffi`
* - `--allow-ffi`
* - `--allow-env`
* - `--allow-read`
* - `--allow-net=deno.land`
*
* @example
* ```ts
* import { DOMParser, initParser } from "jsr:@b-fuze/deno-dom/native";
*
* // ...and when you need Deno DOM make sure you initialize the parser...
* await initParser();
*
* // Then you can use Deno DOM as you would normally
* const doc = new DOMParser().parseFromString(
* `
* <h1>Hello World!</h1>
* <p>Hello from <a href="https://deno.land/">Deno!</a></p>
* `,
* "text/html",
* );
*
* const p = doc.querySelector("p")!;
* console.log(p.textContent); // "Hello from Deno!"
* ```
*/

import { dlopen } from "jsr:@denosaurs/plug@1.0.3";
import { register } from "./src/parser.ts";

Expand Down
30 changes: 30 additions & 0 deletions deno-dom-wasm-noinit.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
/**
* @module
*
* This module exposes the Deno DOM API with the WASM (Web Assembly) backend.
* This module is different from the primary WASM module because it allows
* you to control when the WASM HTML parsing engine loads (which is a
* relatively slow process). You can't use any of the parsing functions
* of Deno DOM until you invoke the async `initParser()` export.
*
* @example
* ```ts
* import { DOMParser, initParser } from "jsr:@b-fuze/deno-dom/wasm-noinit";
*
* // ...and when you need Deno DOM's parser make sure you initialize it...
* await initParser();
*
* // Then you can use Deno DOM as you would normally
* const doc = new DOMParser().parseFromString(
* `
* <h1>Hello World!</h1>
* <p>Hello from <a href="https://deno.land/">Deno!</a></p>
* `,
* "text/html",
* );
*
* const p = doc.querySelector("p")!;
* console.log(p.textContent); // "Hello from Deno!"
* ```
*/

import initWasm, {
parse,
parse_frag as parseFrag,
Expand Down
22 changes: 22 additions & 0 deletions deno-dom-wasm.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/**
* @module
*
* This module exposes the Deno DOM API with the WASM (Web Assembly) backend
*
* @example
* ```typescript
* import { DOMParser, Element } from "jsr:@b-fuze/deno-dom";
*
* const doc = new DOMParser().parseFromString(
* `
* <h1>Hello World!</h1>
* <p>Hello from <a href="https://deno.land/">Deno!</a></p>
* `,
* "text/html",
* );
*
* const p = doc.querySelector("p")!;
* console.log(p.textContent); // "Hello from Deno!"
* ```
*/

import init, { parse, parse_frag } from "./build/deno-wasm/deno-wasm.js";
import { register } from "./src/parser.ts";

Expand Down

0 comments on commit 957ff92

Please sign in to comment.