ducsvg 3.4.5 → 3.5.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/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from "./ducToSvg";
2
+ export { getSvgWasmBinary, initSvgWasmFromBinary } from "./pdf2svg";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { convertDucToPdf as i } from "ducpdf";
2
- let o = null, n = null;
1
+ import { convertDucToPdf as s } from "ducpdf";
2
+ let o = null, r = null;
3
3
  async function a() {
4
- return o || n || (n = (async () => {
4
+ return o || r || (r = (async () => {
5
5
  try {
6
6
  const t = await import("./wasm-CsOBw0hB.js");
7
7
  if (typeof t.default == "function")
@@ -12,18 +12,38 @@ async function a() {
12
12
  throw new Error("Required WASM function 'convert_pdf_to_svg_rs' not found");
13
13
  return o = t, o;
14
14
  } catch (t) {
15
- throw console.error("Failed to initialize pdf2svg WASM module:", t), n = null, t;
15
+ throw console.error("Failed to initialize pdf2svg WASM module:", t), r = null, t;
16
16
  }
17
- })(), n);
17
+ })(), r);
18
18
  }
19
- async function u(t) {
20
- const r = (await a()).convert_pdf_to_svg_rs(t);
21
- return JSON.parse(r);
19
+ async function f(t) {
20
+ const e = (await a()).convert_pdf_to_svg_rs(t);
21
+ return JSON.parse(e);
22
22
  }
23
- const f = async (t, e) => {
24
- const { data: r } = await i(t, e);
25
- return await u(r);
23
+ async function c() {
24
+ const t = new URL("../dist/pdf2svg_bg.wasm", import.meta.url), n = await fetch(t);
25
+ if (!n.ok) throw new Error(`Failed to fetch pdf2svg WASM: ${n.status} ${n.statusText}`);
26
+ return n.arrayBuffer();
27
+ }
28
+ async function d(t) {
29
+ if (o) return;
30
+ const n = await import("./wasm-CsOBw0hB.js");
31
+ if (typeof n.initSync == "function")
32
+ n.initSync({ module: t });
33
+ else if (typeof n.default == "function")
34
+ await n.default(t);
35
+ else
36
+ throw new Error("pdf2svg WASM module has no init function");
37
+ if (typeof n.convert_pdf_to_svg_rs != "function")
38
+ throw new Error("Required WASM function 'convert_pdf_to_svg_rs' not found after binary init");
39
+ o = n;
40
+ }
41
+ const l = async (t, n) => {
42
+ const { data: e } = await s(t, n);
43
+ return await f(e);
26
44
  };
27
45
  export {
28
- f as ducToSvg
46
+ l as ducToSvg,
47
+ c as getSvgWasmBinary,
48
+ d as initSvgWasmFromBinary
29
49
  };
@@ -0,0 +1,3 @@
1
+ C@��f�~��3���+c֝x�aM ?��9ՍQJ��ʀ��y@4=+f�tX�f���Th�$��ڇ?�#J���?�h
2
  ˙���{K��8>g Y8&��Z"���` ��`��Lԕ�_<+y7��q�2k����\��Ͽ_�Ki (?f�kW8:�FzAJ��g%>�R�:�p����c���_�{��'��N�}rƠ.L��o�$���ău2F�wҵx�u���R�kˀuA�.�.h� h/d�sG) �A,�
3
+ а(���Gt#_2�)�z�&R����p��7�ke�9`]Y[���
4
+ �e���!�5W��� b4s���FBNpzG>���'��r�B����v��Мƴ��+W/�ET��$�ƚr�� =
@@ -10,3 +10,13 @@ export interface SvgDocument {
10
10
  export declare function convertPdfToSvg(pdfData: Uint8Array): Promise<SvgDocument>;
11
11
  export declare function isWasmInitialized(): boolean;
12
12
  export declare function resetWasmModule(): void;
13
+ /**
14
+ * Fetch the raw pdf2svg WASM binary as an ArrayBuffer.
15
+ * Must be called from the main thread where `import.meta.url` resolves correctly.
16
+ */
17
+ export declare function getSvgWasmBinary(): Promise<ArrayBuffer>;
18
+ /**
19
+ * Initialize the pdf2svg WASM module from a pre-fetched binary (ArrayBuffer).
20
+ * Used inside Web Workers where `import.meta.url` cannot resolve the .wasm file.
21
+ */
22
+ export declare function initSvgWasmFromBinary(wasmBinary: BufferSource): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ducsvg",
3
- "version": "3.4.5",
3
+ "version": "3.5.0",
4
4
  "description": "Adapter for converting duc CAD documents to SVG. Built on top of ducjs.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -33,8 +33,8 @@
33
33
  "author": "Ducflair",
34
34
  "license": "MIT",
35
35
  "dependencies": {
36
- "ducjs": "^3.0.5",
37
- "ducpdf": "^3.5.5"
36
+ "ducjs": "^3.1.0",
37
+ "ducpdf": "^3.6.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@xmldom/xmldom": "^0.8.11",