@qrcommunication/gigapdf-lib 0.52.5 → 0.53.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.
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/node-fs.browser.ts
21
+ var node_fs_browser_exports = {};
22
+ __export(node_fs_browser_exports, {
23
+ loadDefaultWasmBytes: () => loadDefaultWasmBytes,
24
+ readModelFile: () => readModelFile,
25
+ readModelsDir: () => readModelsDir
26
+ });
27
+ module.exports = __toCommonJS(node_fs_browser_exports);
28
+ var NODE_ONLY = "gigapdf-lib: this loader is Node-only \u2014 in the browser, pass bytes or a URL to load()/loadOcrModel() instead";
29
+ async function loadDefaultWasmBytes() {
30
+ throw new Error(NODE_ONLY);
31
+ }
32
+ async function readModelFile(_fileName) {
33
+ throw new Error(NODE_ONLY);
34
+ }
35
+ async function readModelsDir() {
36
+ throw new Error(NODE_ONLY);
37
+ }
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ loadDefaultWasmBytes,
41
+ readModelFile,
42
+ readModelsDir
43
+ });
44
+ //# sourceMappingURL=node-fs.browser.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/node-fs.browser.ts"],"sourcesContent":["/**\n * Browser stub for the Node-only filesystem loaders.\n *\n * This file is substituted for `node-fs.ts` in browser bundles via the\n * package.json `\"browser\"` field. It contains NO reference to `node:fs`/\n * `node:url`, so browser bundlers (Turbopack, webpack, Vite) have nothing to\n * resolve. Each loader throws — in the browser you must pass bytes or a URL to\n * `GigaPdfEngine.load()` / `loadOcrModel()` instead.\n */\n\nconst NODE_ONLY =\n \"gigapdf-lib: this loader is Node-only — in the browser, pass bytes or a URL to load()/loadOcrModel() instead\";\n\n/** Browser stub — throws; pass bytes/URL to `GigaPdfEngine.load()` instead. */\nexport async function loadDefaultWasmBytes(): Promise<Uint8Array> {\n throw new Error(NODE_ONLY);\n}\n\n/** Browser stub — throws; pass model bytes to `loadOcrModel()` instead. */\nexport async function readModelFile(_fileName: string): Promise<Uint8Array> {\n throw new Error(NODE_ONLY);\n}\n\n/** Browser stub — throws; load OCR models from bytes instead. */\nexport async function readModelsDir(): Promise<{ name: string; bytes: Uint8Array }[]> {\n throw new Error(NODE_ONLY);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,IAAM,YACJ;AAGF,eAAsB,uBAA4C;AAChE,QAAM,IAAI,MAAM,SAAS;AAC3B;AAGA,eAAsB,cAAc,WAAwC;AAC1E,QAAM,IAAI,MAAM,SAAS;AAC3B;AAGA,eAAsB,gBAAgE;AACpF,QAAM,IAAI,MAAM,SAAS;AAC3B;","names":[]}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Browser stub for the Node-only filesystem loaders.
3
+ *
4
+ * This file is substituted for `node-fs.ts` in browser bundles via the
5
+ * package.json `"browser"` field. It contains NO reference to `node:fs`/
6
+ * `node:url`, so browser bundlers (Turbopack, webpack, Vite) have nothing to
7
+ * resolve. Each loader throws — in the browser you must pass bytes or a URL to
8
+ * `GigaPdfEngine.load()` / `loadOcrModel()` instead.
9
+ */
10
+ /** Browser stub — throws; pass bytes/URL to `GigaPdfEngine.load()` instead. */
11
+ declare function loadDefaultWasmBytes(): Promise<Uint8Array>;
12
+ /** Browser stub — throws; pass model bytes to `loadOcrModel()` instead. */
13
+ declare function readModelFile(_fileName: string): Promise<Uint8Array>;
14
+ /** Browser stub — throws; load OCR models from bytes instead. */
15
+ declare function readModelsDir(): Promise<{
16
+ name: string;
17
+ bytes: Uint8Array;
18
+ }[]>;
19
+
20
+ export { loadDefaultWasmBytes, readModelFile, readModelsDir };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Browser stub for the Node-only filesystem loaders.
3
+ *
4
+ * This file is substituted for `node-fs.ts` in browser bundles via the
5
+ * package.json `"browser"` field. It contains NO reference to `node:fs`/
6
+ * `node:url`, so browser bundlers (Turbopack, webpack, Vite) have nothing to
7
+ * resolve. Each loader throws — in the browser you must pass bytes or a URL to
8
+ * `GigaPdfEngine.load()` / `loadOcrModel()` instead.
9
+ */
10
+ /** Browser stub — throws; pass bytes/URL to `GigaPdfEngine.load()` instead. */
11
+ declare function loadDefaultWasmBytes(): Promise<Uint8Array>;
12
+ /** Browser stub — throws; pass model bytes to `loadOcrModel()` instead. */
13
+ declare function readModelFile(_fileName: string): Promise<Uint8Array>;
14
+ /** Browser stub — throws; load OCR models from bytes instead. */
15
+ declare function readModelsDir(): Promise<{
16
+ name: string;
17
+ bytes: Uint8Array;
18
+ }[]>;
19
+
20
+ export { loadDefaultWasmBytes, readModelFile, readModelsDir };
@@ -0,0 +1,17 @@
1
+ // src/node-fs.browser.ts
2
+ var NODE_ONLY = "gigapdf-lib: this loader is Node-only \u2014 in the browser, pass bytes or a URL to load()/loadOcrModel() instead";
3
+ async function loadDefaultWasmBytes() {
4
+ throw new Error(NODE_ONLY);
5
+ }
6
+ async function readModelFile(_fileName) {
7
+ throw new Error(NODE_ONLY);
8
+ }
9
+ async function readModelsDir() {
10
+ throw new Error(NODE_ONLY);
11
+ }
12
+ export {
13
+ loadDefaultWasmBytes,
14
+ readModelFile,
15
+ readModelsDir
16
+ };
17
+ //# sourceMappingURL=node-fs.browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/node-fs.browser.ts"],"sourcesContent":["/**\n * Browser stub for the Node-only filesystem loaders.\n *\n * This file is substituted for `node-fs.ts` in browser bundles via the\n * package.json `\"browser\"` field. It contains NO reference to `node:fs`/\n * `node:url`, so browser bundlers (Turbopack, webpack, Vite) have nothing to\n * resolve. Each loader throws — in the browser you must pass bytes or a URL to\n * `GigaPdfEngine.load()` / `loadOcrModel()` instead.\n */\n\nconst NODE_ONLY =\n \"gigapdf-lib: this loader is Node-only — in the browser, pass bytes or a URL to load()/loadOcrModel() instead\";\n\n/** Browser stub — throws; pass bytes/URL to `GigaPdfEngine.load()` instead. */\nexport async function loadDefaultWasmBytes(): Promise<Uint8Array> {\n throw new Error(NODE_ONLY);\n}\n\n/** Browser stub — throws; pass model bytes to `loadOcrModel()` instead. */\nexport async function readModelFile(_fileName: string): Promise<Uint8Array> {\n throw new Error(NODE_ONLY);\n}\n\n/** Browser stub — throws; load OCR models from bytes instead. */\nexport async function readModelsDir(): Promise<{ name: string; bytes: Uint8Array }[]> {\n throw new Error(NODE_ONLY);\n}\n"],"mappings":";AAUA,IAAM,YACJ;AAGF,eAAsB,uBAA4C;AAChE,QAAM,IAAI,MAAM,SAAS;AAC3B;AAGA,eAAsB,cAAc,WAAwC;AAC1E,QAAM,IAAI,MAAM,SAAS;AAC3B;AAGA,eAAsB,gBAAgE;AACpF,QAAM,IAAI,MAAM,SAAS;AAC3B;","names":[]}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/node-fs.ts
21
+ var node_fs_exports = {};
22
+ __export(node_fs_exports, {
23
+ loadDefaultWasmBytes: () => loadDefaultWasmBytes,
24
+ readModelFile: () => readModelFile,
25
+ readModelsDir: () => readModelsDir
26
+ });
27
+ module.exports = __toCommonJS(node_fs_exports);
28
+
29
+ // node_modules/.pnpm/tsup@8.5.1_postcss@8.5.15_typescript@6.0.3/node_modules/tsup/assets/cjs_shims.js
30
+ var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
31
+ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
32
+
33
+ // src/node-fs.ts
34
+ var nodeImport = (m) => import(
35
+ /* webpackIgnore: true */
36
+ /* @vite-ignore */
37
+ m
38
+ );
39
+ async function fsReadFile() {
40
+ const { readFile } = await nodeImport("node:fs/promises");
41
+ return readFile;
42
+ }
43
+ async function fsReaddir() {
44
+ const { readdir } = await nodeImport("node:fs/promises");
45
+ return readdir;
46
+ }
47
+ async function urlToPath() {
48
+ const { fileURLToPath } = await nodeImport("node:url");
49
+ return fileURLToPath;
50
+ }
51
+ async function loadDefaultWasmBytes() {
52
+ const [readFile, fileURLToPath] = await Promise.all([fsReadFile(), urlToPath()]);
53
+ const wasmPath = fileURLToPath(new URL("../gigapdf.wasm", importMetaUrl));
54
+ return readFile(wasmPath);
55
+ }
56
+ async function readModelFile(fileName) {
57
+ const [readFile, fileURLToPath] = await Promise.all([fsReadFile(), urlToPath()]);
58
+ const path = fileURLToPath(new URL(`../models/${fileName}`, importMetaUrl));
59
+ return readFile(path);
60
+ }
61
+ async function readModelsDir() {
62
+ const [readFile, readdir, fileURLToPath] = await Promise.all([
63
+ fsReadFile(),
64
+ fsReaddir(),
65
+ urlToPath()
66
+ ]);
67
+ let entries;
68
+ try {
69
+ entries = await readdir(fileURLToPath(new URL("../models/", importMetaUrl)));
70
+ } catch {
71
+ return [];
72
+ }
73
+ const out = [];
74
+ for (const name of entries) {
75
+ if (!name.endsWith(".gpocr")) continue;
76
+ const bytes = await readFile(
77
+ fileURLToPath(new URL(`../models/${name}`, importMetaUrl))
78
+ );
79
+ out.push({ name, bytes });
80
+ }
81
+ return out;
82
+ }
83
+ // Annotate the CommonJS export names for ESM import in node:
84
+ 0 && (module.exports = {
85
+ loadDefaultWasmBytes,
86
+ readModelFile,
87
+ readModelsDir
88
+ });
89
+ //# sourceMappingURL=node-fs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/node-fs.ts","../node_modules/.pnpm/tsup@8.5.1_postcss@8.5.15_typescript@6.0.3/node_modules/tsup/assets/cjs_shims.js"],"sourcesContent":["/**\n * Node-only filesystem loaders for gigapdf-lib.\n *\n * This module is the ONLY place that touches Node's `fs`/`url` modules. It is\n * swapped out for `node-fs.browser.ts` via the package.json `\"browser\"` field\n * so that browser bundlers (Turbopack, webpack, Vite) never see a reference to\n * `node:fs/promises` / `node:url` and never try to resolve them.\n *\n * The relative paths below are resolved from the built module (`dist/node-fs.js`)\n * to the package root via the `import.meta.url` shim injected by tsup (`shims`),\n * exactly like the previous in-`index.ts` resolution did from `dist/index.js`.\n */\n\n/**\n * Indirect the specifier through a variable so any bundler that still evaluates\n * this module (it shouldn't in the browser, thanks to the `\"browser\"` mapping)\n * doesn't statically resolve these Node-only modules.\n */\nconst nodeImport = (m: string): Promise<Record<string, unknown>> =>\n import(/* webpackIgnore: true */ /* @vite-ignore */ m);\n\nasync function fsReadFile(): Promise<(p: string) => Promise<Uint8Array>> {\n const { readFile } = (await nodeImport(\"node:fs/promises\")) as {\n readFile: (p: string) => Promise<Uint8Array>;\n };\n return readFile;\n}\n\nasync function fsReaddir(): Promise<(p: string) => Promise<string[]>> {\n const { readdir } = (await nodeImport(\"node:fs/promises\")) as {\n readdir: (p: string) => Promise<string[]>;\n };\n return readdir;\n}\n\nasync function urlToPath(): Promise<(u: URL) => string> {\n const { fileURLToPath } = (await nodeImport(\"node:url\")) as {\n fileURLToPath: (u: URL) => string;\n };\n return fileURLToPath;\n}\n\n/** Read the bundled `gigapdf.wasm` shipped inside this package. */\nexport async function loadDefaultWasmBytes(): Promise<Uint8Array> {\n const [readFile, fileURLToPath] = await Promise.all([fsReadFile(), urlToPath()]);\n const wasmPath = fileURLToPath(new URL(\"../gigapdf.wasm\", import.meta.url));\n return readFile(wasmPath);\n}\n\n/** Read a single bundled `.gpocr` model by its filename (under `models/`). */\nexport async function readModelFile(fileName: string): Promise<Uint8Array> {\n const [readFile, fileURLToPath] = await Promise.all([fsReadFile(), urlToPath()]);\n const path = fileURLToPath(new URL(`../models/${fileName}`, import.meta.url));\n return readFile(path);\n}\n\n/**\n * Discover every bundled `.gpocr` model and return its name + bytes.\n * Returns an empty list if the `models/` directory is absent (slimmed install).\n */\nexport async function readModelsDir(): Promise<{ name: string; bytes: Uint8Array }[]> {\n const [readFile, readdir, fileURLToPath] = await Promise.all([\n fsReadFile(),\n fsReaddir(),\n urlToPath(),\n ]);\n let entries: string[];\n try {\n entries = await readdir(fileURLToPath(new URL(\"../models/\", import.meta.url)));\n } catch {\n return []; // models/ absent (slimmed install) → caller falls back\n }\n const out: { name: string; bytes: Uint8Array }[] = [];\n for (const name of entries) {\n if (!name.endsWith(\".gpocr\")) continue;\n const bytes = await readFile(\n fileURLToPath(new URL(`../models/${name}`, import.meta.url)),\n );\n out.push({ name, bytes });\n }\n return out;\n}\n","// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n typeof document === \"undefined\" \n ? new URL(`file:${__filename}`).href \n : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n ? document.currentScript.src \n : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,OAC7B,SAAS,iBAAiB,SAAS,cAAc,QAAQ,YAAY,MAAM,WAC1E,SAAS,cAAc,MACvB,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;AAEtC,IAAM,gBAAgC,iCAAiB;;;ADM9D,IAAM,aAAa,CAAC,MAClB;AAAA;AAAA;AAAA,EAAoD;AAAA;AAEtD,eAAe,aAA0D;AACvE,QAAM,EAAE,SAAS,IAAK,MAAM,WAAW,kBAAkB;AAGzD,SAAO;AACT;AAEA,eAAe,YAAuD;AACpE,QAAM,EAAE,QAAQ,IAAK,MAAM,WAAW,kBAAkB;AAGxD,SAAO;AACT;AAEA,eAAe,YAAyC;AACtD,QAAM,EAAE,cAAc,IAAK,MAAM,WAAW,UAAU;AAGtD,SAAO;AACT;AAGA,eAAsB,uBAA4C;AAChE,QAAM,CAAC,UAAU,aAAa,IAAI,MAAM,QAAQ,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,CAAC;AAC/E,QAAM,WAAW,cAAc,IAAI,IAAI,mBAAmB,aAAe,CAAC;AAC1E,SAAO,SAAS,QAAQ;AAC1B;AAGA,eAAsB,cAAc,UAAuC;AACzE,QAAM,CAAC,UAAU,aAAa,IAAI,MAAM,QAAQ,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,CAAC;AAC/E,QAAM,OAAO,cAAc,IAAI,IAAI,aAAa,QAAQ,IAAI,aAAe,CAAC;AAC5E,SAAO,SAAS,IAAI;AACtB;AAMA,eAAsB,gBAAgE;AACpF,QAAM,CAAC,UAAU,SAAS,aAAa,IAAI,MAAM,QAAQ,IAAI;AAAA,IAC3D,WAAW;AAAA,IACX,UAAU;AAAA,IACV,UAAU;AAAA,EACZ,CAAC;AACD,MAAI;AACJ,MAAI;AACF,cAAU,MAAM,QAAQ,cAAc,IAAI,IAAI,cAAc,aAAe,CAAC,CAAC;AAAA,EAC/E,QAAQ;AACN,WAAO,CAAC;AAAA,EACV;AACA,QAAM,MAA6C,CAAC;AACpD,aAAW,QAAQ,SAAS;AAC1B,QAAI,CAAC,KAAK,SAAS,QAAQ,EAAG;AAC9B,UAAM,QAAQ,MAAM;AAAA,MAClB,cAAc,IAAI,IAAI,aAAa,IAAI,IAAI,aAAe,CAAC;AAAA,IAC7D;AACA,QAAI,KAAK,EAAE,MAAM,MAAM,CAAC;AAAA,EAC1B;AACA,SAAO;AACT;","names":[]}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Node-only filesystem loaders for gigapdf-lib.
3
+ *
4
+ * This module is the ONLY place that touches Node's `fs`/`url` modules. It is
5
+ * swapped out for `node-fs.browser.ts` via the package.json `"browser"` field
6
+ * so that browser bundlers (Turbopack, webpack, Vite) never see a reference to
7
+ * `node:fs/promises` / `node:url` and never try to resolve them.
8
+ *
9
+ * The relative paths below are resolved from the built module (`dist/node-fs.js`)
10
+ * to the package root via the `import.meta.url` shim injected by tsup (`shims`),
11
+ * exactly like the previous in-`index.ts` resolution did from `dist/index.js`.
12
+ */
13
+ /** Read the bundled `gigapdf.wasm` shipped inside this package. */
14
+ declare function loadDefaultWasmBytes(): Promise<Uint8Array>;
15
+ /** Read a single bundled `.gpocr` model by its filename (under `models/`). */
16
+ declare function readModelFile(fileName: string): Promise<Uint8Array>;
17
+ /**
18
+ * Discover every bundled `.gpocr` model and return its name + bytes.
19
+ * Returns an empty list if the `models/` directory is absent (slimmed install).
20
+ */
21
+ declare function readModelsDir(): Promise<{
22
+ name: string;
23
+ bytes: Uint8Array;
24
+ }[]>;
25
+
26
+ export { loadDefaultWasmBytes, readModelFile, readModelsDir };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Node-only filesystem loaders for gigapdf-lib.
3
+ *
4
+ * This module is the ONLY place that touches Node's `fs`/`url` modules. It is
5
+ * swapped out for `node-fs.browser.ts` via the package.json `"browser"` field
6
+ * so that browser bundlers (Turbopack, webpack, Vite) never see a reference to
7
+ * `node:fs/promises` / `node:url` and never try to resolve them.
8
+ *
9
+ * The relative paths below are resolved from the built module (`dist/node-fs.js`)
10
+ * to the package root via the `import.meta.url` shim injected by tsup (`shims`),
11
+ * exactly like the previous in-`index.ts` resolution did from `dist/index.js`.
12
+ */
13
+ /** Read the bundled `gigapdf.wasm` shipped inside this package. */
14
+ declare function loadDefaultWasmBytes(): Promise<Uint8Array>;
15
+ /** Read a single bundled `.gpocr` model by its filename (under `models/`). */
16
+ declare function readModelFile(fileName: string): Promise<Uint8Array>;
17
+ /**
18
+ * Discover every bundled `.gpocr` model and return its name + bytes.
19
+ * Returns an empty list if the `models/` directory is absent (slimmed install).
20
+ */
21
+ declare function readModelsDir(): Promise<{
22
+ name: string;
23
+ bytes: Uint8Array;
24
+ }[]>;
25
+
26
+ export { loadDefaultWasmBytes, readModelFile, readModelsDir };
@@ -0,0 +1,56 @@
1
+ // src/node-fs.ts
2
+ var nodeImport = (m) => import(
3
+ /* webpackIgnore: true */
4
+ /* @vite-ignore */
5
+ m
6
+ );
7
+ async function fsReadFile() {
8
+ const { readFile } = await nodeImport("node:fs/promises");
9
+ return readFile;
10
+ }
11
+ async function fsReaddir() {
12
+ const { readdir } = await nodeImport("node:fs/promises");
13
+ return readdir;
14
+ }
15
+ async function urlToPath() {
16
+ const { fileURLToPath } = await nodeImport("node:url");
17
+ return fileURLToPath;
18
+ }
19
+ async function loadDefaultWasmBytes() {
20
+ const [readFile, fileURLToPath] = await Promise.all([fsReadFile(), urlToPath()]);
21
+ const wasmPath = fileURLToPath(new URL("../gigapdf.wasm", import.meta.url));
22
+ return readFile(wasmPath);
23
+ }
24
+ async function readModelFile(fileName) {
25
+ const [readFile, fileURLToPath] = await Promise.all([fsReadFile(), urlToPath()]);
26
+ const path = fileURLToPath(new URL(`../models/${fileName}`, import.meta.url));
27
+ return readFile(path);
28
+ }
29
+ async function readModelsDir() {
30
+ const [readFile, readdir, fileURLToPath] = await Promise.all([
31
+ fsReadFile(),
32
+ fsReaddir(),
33
+ urlToPath()
34
+ ]);
35
+ let entries;
36
+ try {
37
+ entries = await readdir(fileURLToPath(new URL("../models/", import.meta.url)));
38
+ } catch {
39
+ return [];
40
+ }
41
+ const out = [];
42
+ for (const name of entries) {
43
+ if (!name.endsWith(".gpocr")) continue;
44
+ const bytes = await readFile(
45
+ fileURLToPath(new URL(`../models/${name}`, import.meta.url))
46
+ );
47
+ out.push({ name, bytes });
48
+ }
49
+ return out;
50
+ }
51
+ export {
52
+ loadDefaultWasmBytes,
53
+ readModelFile,
54
+ readModelsDir
55
+ };
56
+ //# sourceMappingURL=node-fs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/node-fs.ts"],"sourcesContent":["/**\n * Node-only filesystem loaders for gigapdf-lib.\n *\n * This module is the ONLY place that touches Node's `fs`/`url` modules. It is\n * swapped out for `node-fs.browser.ts` via the package.json `\"browser\"` field\n * so that browser bundlers (Turbopack, webpack, Vite) never see a reference to\n * `node:fs/promises` / `node:url` and never try to resolve them.\n *\n * The relative paths below are resolved from the built module (`dist/node-fs.js`)\n * to the package root via the `import.meta.url` shim injected by tsup (`shims`),\n * exactly like the previous in-`index.ts` resolution did from `dist/index.js`.\n */\n\n/**\n * Indirect the specifier through a variable so any bundler that still evaluates\n * this module (it shouldn't in the browser, thanks to the `\"browser\"` mapping)\n * doesn't statically resolve these Node-only modules.\n */\nconst nodeImport = (m: string): Promise<Record<string, unknown>> =>\n import(/* webpackIgnore: true */ /* @vite-ignore */ m);\n\nasync function fsReadFile(): Promise<(p: string) => Promise<Uint8Array>> {\n const { readFile } = (await nodeImport(\"node:fs/promises\")) as {\n readFile: (p: string) => Promise<Uint8Array>;\n };\n return readFile;\n}\n\nasync function fsReaddir(): Promise<(p: string) => Promise<string[]>> {\n const { readdir } = (await nodeImport(\"node:fs/promises\")) as {\n readdir: (p: string) => Promise<string[]>;\n };\n return readdir;\n}\n\nasync function urlToPath(): Promise<(u: URL) => string> {\n const { fileURLToPath } = (await nodeImport(\"node:url\")) as {\n fileURLToPath: (u: URL) => string;\n };\n return fileURLToPath;\n}\n\n/** Read the bundled `gigapdf.wasm` shipped inside this package. */\nexport async function loadDefaultWasmBytes(): Promise<Uint8Array> {\n const [readFile, fileURLToPath] = await Promise.all([fsReadFile(), urlToPath()]);\n const wasmPath = fileURLToPath(new URL(\"../gigapdf.wasm\", import.meta.url));\n return readFile(wasmPath);\n}\n\n/** Read a single bundled `.gpocr` model by its filename (under `models/`). */\nexport async function readModelFile(fileName: string): Promise<Uint8Array> {\n const [readFile, fileURLToPath] = await Promise.all([fsReadFile(), urlToPath()]);\n const path = fileURLToPath(new URL(`../models/${fileName}`, import.meta.url));\n return readFile(path);\n}\n\n/**\n * Discover every bundled `.gpocr` model and return its name + bytes.\n * Returns an empty list if the `models/` directory is absent (slimmed install).\n */\nexport async function readModelsDir(): Promise<{ name: string; bytes: Uint8Array }[]> {\n const [readFile, readdir, fileURLToPath] = await Promise.all([\n fsReadFile(),\n fsReaddir(),\n urlToPath(),\n ]);\n let entries: string[];\n try {\n entries = await readdir(fileURLToPath(new URL(\"../models/\", import.meta.url)));\n } catch {\n return []; // models/ absent (slimmed install) → caller falls back\n }\n const out: { name: string; bytes: Uint8Array }[] = [];\n for (const name of entries) {\n if (!name.endsWith(\".gpocr\")) continue;\n const bytes = await readFile(\n fileURLToPath(new URL(`../models/${name}`, import.meta.url)),\n );\n out.push({ name, bytes });\n }\n return out;\n}\n"],"mappings":";AAkBA,IAAM,aAAa,CAAC,MAClB;AAAA;AAAA;AAAA,EAAoD;AAAA;AAEtD,eAAe,aAA0D;AACvE,QAAM,EAAE,SAAS,IAAK,MAAM,WAAW,kBAAkB;AAGzD,SAAO;AACT;AAEA,eAAe,YAAuD;AACpE,QAAM,EAAE,QAAQ,IAAK,MAAM,WAAW,kBAAkB;AAGxD,SAAO;AACT;AAEA,eAAe,YAAyC;AACtD,QAAM,EAAE,cAAc,IAAK,MAAM,WAAW,UAAU;AAGtD,SAAO;AACT;AAGA,eAAsB,uBAA4C;AAChE,QAAM,CAAC,UAAU,aAAa,IAAI,MAAM,QAAQ,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,CAAC;AAC/E,QAAM,WAAW,cAAc,IAAI,IAAI,mBAAmB,YAAY,GAAG,CAAC;AAC1E,SAAO,SAAS,QAAQ;AAC1B;AAGA,eAAsB,cAAc,UAAuC;AACzE,QAAM,CAAC,UAAU,aAAa,IAAI,MAAM,QAAQ,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,CAAC;AAC/E,QAAM,OAAO,cAAc,IAAI,IAAI,aAAa,QAAQ,IAAI,YAAY,GAAG,CAAC;AAC5E,SAAO,SAAS,IAAI;AACtB;AAMA,eAAsB,gBAAgE;AACpF,QAAM,CAAC,UAAU,SAAS,aAAa,IAAI,MAAM,QAAQ,IAAI;AAAA,IAC3D,WAAW;AAAA,IACX,UAAU;AAAA,IACV,UAAU;AAAA,EACZ,CAAC;AACD,MAAI;AACJ,MAAI;AACF,cAAU,MAAM,QAAQ,cAAc,IAAI,IAAI,cAAc,YAAY,GAAG,CAAC,CAAC;AAAA,EAC/E,QAAQ;AACN,WAAO,CAAC;AAAA,EACV;AACA,QAAM,MAA6C,CAAC;AACpD,aAAW,QAAQ,SAAS;AAC1B,QAAI,CAAC,KAAK,SAAS,QAAQ,EAAG;AAC9B,UAAM,QAAQ,MAAM;AAAA,MAClB,cAAc,IAAI,IAAI,aAAa,IAAI,IAAI,YAAY,GAAG,CAAC;AAAA,IAC7D;AACA,QAAI,KAAK,EAAE,MAAM,MAAM,CAAC;AAAA,EAC1B;AACA,SAAO;AACT;","names":[]}
package/gigapdf.wasm CHANGED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrcommunication/gigapdf-lib",
3
- "version": "0.52.5",
3
+ "version": "0.53.0",
4
4
  "description": "TypeScript SDK for gigapdf-lib — a Rust→WASM document engine with no third-party PDF/Office/image library: read/edit/render, OCR, full-text search, AcroForm fields (read · fill · create), annotations, signing, encryption, PDF↔Office/HTML/RTF conversions, and a native HTML+CSS→PDF renderer with inline JavaScript (no headless browser). Cryptography uses audited RustCrypto; JavaScript uses the Boa engine; everything else is pure Rust. Single wasm-bindgen-free .wasm with one host import (entropy).",
5
5
  "license": "PolyForm-Noncommercial-1.0.0",
6
6
  "author": "Rony Licha / QR Communication",
@@ -8,6 +8,10 @@
8
8
  "main": "./dist/index.cjs",
9
9
  "module": "./dist/index.js",
10
10
  "types": "./dist/index.d.ts",
11
+ "browser": {
12
+ "./dist/node-fs.js": "./dist/node-fs.browser.js",
13
+ "./dist/node-fs.cjs": "./dist/node-fs.browser.cjs"
14
+ },
11
15
  "exports": {
12
16
  ".": {
13
17
  "types": "./dist/index.d.ts",