@taciturnaxolotl/traverse 0.1.4 → 0.1.6
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/package.json +1 -1
- package/src/og.ts +34 -1
package/package.json
CHANGED
package/src/og.ts
CHANGED
|
@@ -10,7 +10,40 @@ const [interRegular, interBold] = await Promise.all([
|
|
|
10
10
|
]);
|
|
11
11
|
|
|
12
12
|
// Initialize resvg-wasm
|
|
13
|
-
|
|
13
|
+
// Use import.meta.resolve to find the package, then locate the WASM file
|
|
14
|
+
let wasmPath: string;
|
|
15
|
+
try {
|
|
16
|
+
// Try to resolve the @resvg/resvg-wasm package
|
|
17
|
+
const resvgPath = import.meta.resolve("@resvg/resvg-wasm");
|
|
18
|
+
// The resolved path will be something like file:///path/to/node_modules/@resvg/resvg-wasm/index.js
|
|
19
|
+
// Extract the directory and append the WASM file
|
|
20
|
+
const resvgDir = new URL(".", resvgPath).pathname;
|
|
21
|
+
wasmPath = join(resvgDir, "index_bg.wasm");
|
|
22
|
+
} catch {
|
|
23
|
+
// Fallback to manual path resolution if import.meta.resolve fails
|
|
24
|
+
const possiblePaths = [
|
|
25
|
+
join(import.meta.dir, "../node_modules/@resvg/resvg-wasm/index_bg.wasm"),
|
|
26
|
+
join(import.meta.dir, "../../@resvg/resvg-wasm/index_bg.wasm"),
|
|
27
|
+
join(import.meta.dir, "../../../@resvg/resvg-wasm/index_bg.wasm"),
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
for (const path of possiblePaths) {
|
|
31
|
+
if (await Bun.file(path).exists()) {
|
|
32
|
+
wasmPath = path;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (!wasmPath!) {
|
|
38
|
+
console.error("Failed to find @resvg/resvg-wasm WASM file. Tried:");
|
|
39
|
+
for (const path of possiblePaths) {
|
|
40
|
+
console.error(` - ${path}`);
|
|
41
|
+
}
|
|
42
|
+
console.error(`\nCurrent directory: ${import.meta.dir}`);
|
|
43
|
+
throw new Error("Could not find @resvg/resvg-wasm WASM file");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
14
47
|
await initWasm(Bun.file(wasmPath).arrayBuffer());
|
|
15
48
|
|
|
16
49
|
// Cache generated images by diagram ID
|