Skip to content

Commit 6bf3a87

Browse files
committed
feat-docs-wasm-attempt
1 parent 8511de6 commit 6bf3a87

7 files changed

Lines changed: 261 additions & 374 deletions

File tree

PLAN_MICRO.md

Lines changed: 0 additions & 201 deletions
This file was deleted.

PLAN_WASM.md

Lines changed: 0 additions & 110 deletions
This file was deleted.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"test:unit": "vitest --project unit"
2727
},
2828
"dependencies": {
29+
"@deno/doc": "jsr:^0.189.1",
2930
"@iconify-json/simple-icons": "^1.2.67",
3031
"@iconify-json/vscode-icons": "^1.2.40",
3132
"@nuxt/a11y": "1.0.0-alpha.1",
@@ -93,6 +94,9 @@
9394
"estree-walker": "^3.0.3"
9495
}
9596
}
97+
},
98+
"patchedDependencies": {
99+
"@jsr/deno__doc@0.189.1": "patches/@jsr__deno__doc@0.189.1.patch"
96100
}
97101
},
98102
"simple-git-hooks": {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
diff --git a/deno_doc_wasm.generated.js b/deno_doc_wasm.generated.js
2+
index 12add85709ae8a235058c751c397893693f52a6a..da235f2e0ce35b9fc012a51495a15c84d024e434 100755
3+
--- a/deno_doc_wasm.generated.js
4+
+++ b/deno_doc_wasm.generated.js
5+
@@ -1012,13 +1012,18 @@ class WasmBuildLoader {
6+
7+
// make file urls work in Node via dnt
8+
const isNode = globalThis.process?.versions?.node != null;
9+
- if (isFile && typeof Deno !== "object") {
10+
- throw new Error(
11+
- "Loading local files are not supported in this environment",
12+
+ if (isNode && isFile) {
13+
+ // Use Node.js fs module to read the file (patched for Node.js support)
14+
+ const { readFileSync } = await import("node:fs");
15+
+ const { fileURLToPath } = await import("node:url");
16+
+ const wasmCode = readFileSync(fileURLToPath(url));
17+
+ return WebAssembly.instantiate(
18+
+ decompress ? decompress(wasmCode) : wasmCode,
19+
+ imports,
20+
);
21+
}
22+
- if (isNode && isFile) {
23+
- // the deno global will be shimmed by dnt
24+
+ if (isFile && typeof Deno === "object") {
25+
+ // Deno environment
26+
const wasmCode = await Deno.readFile(url);
27+
return WebAssembly.instantiate(
28+
decompress ? decompress(wasmCode) : wasmCode,
29+
diff --git a/mod.js b/mod.js
30+
index f9d9de1349c2bb575b29138a5fc54654e92c4a47..025ecdb580b52160f709b32bb5db9ecf481e70ce 100755
31+
--- a/mod.js
32+
+++ b/mod.js
33+
@@ -1,8 +1,8 @@
34+
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
35+
import { instantiate } from "./deno_doc_wasm.generated.js";
36+
import { createCache } from "@jsr/deno__cache-dir";
37+
-export * from "./types.d.ts";
38+
-export * from "./html_types.d.ts";
39+
+// Removed: export * from "./types.d.ts"; (incompatible with Node.js/Rollup)
40+
+// Removed: export * from "./html_types.d.ts"; (incompatible with Node.js/Rollup)
41+
const encoder = new TextEncoder();
42+
/**
43+
* Generate asynchronously an array of documentation nodes for the supplied

0 commit comments

Comments
 (0)