@taulabs/openrscad-engine 0.11.0-beta.2 → 0.11.0-beta.4

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/node.d.ts CHANGED
@@ -1,5 +1,13 @@
1
- /** Resolves immediately — the wasm is already instantiated on import in Node. */
1
+ import { type Backend } from "./core.js";
2
+ /** Resolves immediately — whichever binding bound is initialized on import. */
2
3
  export declare function ensureReady(): Promise<void>;
4
+ /** Which binding this process bound. `"wasm"` means no platform package matched
5
+ * the host and the in-package WebAssembly build took over. */
6
+ export declare const backend: Backend;
7
+ /** The native loader's failure chain when `backend` is `"wasm"` and the addon
8
+ * was tried, else `undefined`. Never flattened to a string — it names every
9
+ * candidate the loader attempted. */
10
+ export declare const backendCause: unknown;
3
11
  export declare const render: (source: string, opts?: import("./core.js").RenderOptions) => Promise<import("./core.js").RenderOutput>;
4
12
  export declare const renderToGlb: (source: string, opts?: import("./core.js").RenderToGlbOptions) => Promise<import("./core.js").ExportShape3DOutput>;
5
13
  export declare const exportShape2D: (source: string, format: "dxf" | "svg", opts?: import("./core.js").RenderOptions) => Promise<string>;
@@ -10,5 +18,11 @@ export declare const exportShape3D: {
10
18
  export declare const parameters: (source: string) => Promise<string>;
11
19
  export declare const version: () => Promise<string>;
12
20
  export declare const clearCache: () => Promise<void>;
13
- export type { Diagnostic, ExportGlbOptions, ExportShape3DFormat, ExportShape3DOutput, RenderOptions, RenderOutput, RenderToGlbOptions, } from "./core.js";
21
+ export declare const exportCache: (opts?: {
22
+ sinceEpoch?: number;
23
+ }) => Promise<Uint8Array>;
24
+ export declare const importCache: (bytes: Uint8Array) => Promise<import("./core.js").CacheImportReport>;
25
+ export declare const cacheStats: () => Promise<import("./core.js").CacheStats>;
26
+ export declare const cacheKeys: () => Promise<BigUint64Array>;
27
+ export type { Backend, CacheImportReport, CacheStats, Diagnostic, ExportGlbOptions, ExportShape3DFormat, ExportShape3DOutput, RenderOptions, RenderOutput, RenderToGlbOptions, } from "./core.js";
14
28
  //# sourceMappingURL=node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAiBA,iFAAiF;AACjF,wBAAgB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3C;AAcD,eAAO,MAAM,MAAM,yGAAa,CAAC;AACjC,eAAO,MAAM,WAAW,qHAAkB,CAAC;AAC3C,eAAO,MAAM,aAAa,sGAAoB,CAAC;AAC/C,eAAO,MAAM,aAAa;;;CAAoB,CAAC;AAC/C,eAAO,MAAM,UAAU,qCAAiB,CAAC;AACzC,eAAO,MAAM,OAAO,uBAAc,CAAC;AACnC,eAAO,MAAM,UAAU,qBAAiB,CAAC;AAEzC,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,kBAAkB,GACnB,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAW,KAAK,OAAO,EAAkB,MAAM,WAAW,CAAC;AAElE,+EAA+E;AAC/E,wBAAgB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3C;AA8BD;+DAC+D;AAC/D,eAAO,MAAM,OAAO,EAAE,OAAe,CAAC;AAEtC;;sCAEsC;AACtC,eAAO,MAAM,YAAY,EAAE,OAAe,CAAC;AAI3C,eAAO,MAAM,MAAM,yGAAa,CAAC;AACjC,eAAO,MAAM,WAAW,qHAAkB,CAAC;AAC3C,eAAO,MAAM,aAAa,sGAAoB,CAAC;AAC/C,eAAO,MAAM,aAAa;;;CAAoB,CAAC;AAC/C,eAAO,MAAM,UAAU,qCAAiB,CAAC;AACzC,eAAO,MAAM,OAAO,uBAAc,CAAC;AACnC,eAAO,MAAM,UAAU,qBAAiB,CAAC;AACzC,eAAO,MAAM,WAAW;cAiBgsT,CAAC;yBAjB/qT,CAAC;AAC3C,eAAO,MAAM,WAAW,uEAAkB,CAAC;AAC3C,eAAO,MAAM,UAAU,+CAAiB,CAAC;AACzC,eAAO,MAAM,SAAS,+BAAgB,CAAC;AAEvC,YAAY,EACV,OAAO,EACP,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,kBAAkB,GACnB,MAAM,WAAW,CAAC"}
package/dist/node.js CHANGED
@@ -1,24 +1,59 @@
1
1
  // Node entry (the `node` + `import` export condition).
2
2
  //
3
- // The nodejs-target glue instantiates the wasm synchronously on import, so there
4
- // is no async init step: `ensureReady()` resolves immediately and exists only
5
- // for API parity with the browser entry. (CommonJS `require()` consumers resolve
6
- // to the raw `pkg/node/openrscad.js` glue directly — see the package `exports` map.)
7
- import { render_with_files as rawRenderWithFiles, export_2d as rawExport2d, export_3d as rawExport3d, render_to_glb as rawRenderToGlb, parameters as rawParameters, version as rawVersion, clear_cache as rawClearCache, } from "../pkg/node/openrscad.js";
3
+ // One package, two payloads. `@taulabs/openrscad-engine` compiles one Rust
4
+ // pipeline (`crates/openrscad-api`) through two marshalling layers, so this
5
+ // entry binds the N-API addon when a platform package — or a colocated build —
6
+ // matches the host, and the in-package wasm Node build when none does. Both
7
+ // bindings are fed the same `makeApi()` facade, so there is no second place for
8
+ // the two engines' semantics to drift apart; `src/api-parity.ts` asserts this
9
+ // module and the browser entry stay structurally identical.
10
+ //
11
+ // The addon is loaded through the NAPI-RS-generated loader (never a
12
+ // hand-written platform table), which throws one `Error` whose `cause` chains
13
+ // every failed candidate. An uncovered platform must not lose the engine, so
14
+ // that error is kept on `backendCause` and the wasm build takes over instead of
15
+ // the import throwing. `backend` says which one bound — the fallback is never
16
+ // silent. (CommonJS `require()` consumers resolve the raw `pkg/node/openrscad.js`
17
+ // glue directly and are always wasm — see the package `exports` map.)
8
18
  import { makeApi } from "./core.js";
9
- /** Resolves immediately — the wasm is already instantiated on import in Node. */
19
+ /** Resolves immediately — whichever binding bound is initialized on import. */
10
20
  export function ensureReady() {
11
21
  return Promise.resolve();
12
22
  }
13
- const engine = {
14
- render_with_files: rawRenderWithFiles,
15
- export_2d: rawExport2d,
16
- export_3d: rawExport3d,
17
- render_to_glb: rawRenderToGlb,
18
- parameters: rawParameters,
19
- version: rawVersion,
20
- clear_cache: rawClearCache,
21
- };
23
+ async function loadWasm() {
24
+ const glue = await import("../pkg/node/openrscad.js");
25
+ return {
26
+ render_with_files: glue.render_with_files,
27
+ export_2d: glue.export_2d,
28
+ export_3d: glue.export_3d,
29
+ render_to_glb: glue.render_to_glb,
30
+ parameters: glue.parameters,
31
+ version: glue.version,
32
+ clear_cache: glue.clear_cache,
33
+ cache_export: glue.cache_export,
34
+ cache_import: glue.cache_import,
35
+ cache_stats: glue.cache_stats,
36
+ cache_keys: glue.cache_keys,
37
+ };
38
+ }
39
+ let bound = "native";
40
+ let cause;
41
+ let engine;
42
+ try {
43
+ engine = (await import("./native/index.js"));
44
+ }
45
+ catch (error) {
46
+ cause = error;
47
+ bound = "wasm";
48
+ engine = await loadWasm();
49
+ }
50
+ /** Which binding this process bound. `"wasm"` means no platform package matched
51
+ * the host and the in-package WebAssembly build took over. */
52
+ export const backend = bound;
53
+ /** The native loader's failure chain when `backend` is `"wasm"` and the addon
54
+ * was tried, else `undefined`. Never flattened to a string — it names every
55
+ * candidate the loader attempted. */
56
+ export const backendCause = cause;
22
57
  const api = makeApi(engine, ensureReady);
23
58
  export const render = api.render;
24
59
  export const renderToGlb = api.renderToGlb;
@@ -27,4 +62,8 @@ export const exportShape3D = api.exportShape3D;
27
62
  export const parameters = api.parameters;
28
63
  export const version = api.version;
29
64
  export const clearCache = api.clearCache;
65
+ export const exportCache = api.exportCache;
66
+ export const importCache = api.importCache;
67
+ export const cacheStats = api.cacheStats;
68
+ export const cacheKeys = api.cacheKeys;
30
69
  //# sourceMappingURL=node.js.map
package/dist/node.js.map CHANGED
@@ -1 +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CAAC;IACf,MAAM,GAAG,MAAM,QAAQ,EAAE,CAAC;AAC5B,CAAC;AAED;+DAC+D;AAC/D,MAAM,CAAC,MAAM,OAAO,GAAY,KAAK,CAAC;AAEtC;;sCAEsC;AACtC,MAAM,CAAC,MAAM,YAAY,GAAY,KAAK,CAAC;AAE3C,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAEzC,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;AACjC,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC;AAC3C,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC,aAAa,CAAC;AAC/C,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC,aAAa,CAAC;AAC/C,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC;AACzC,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;AACnC,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC;AACzC,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC;AAC3C,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC;AAC3C,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC;AACzC,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taulabs/openrscad-engine",
3
- "version": "0.11.0-beta.2",
3
+ "version": "0.11.0-beta.4",
4
4
  "description": "Tau's fork of the OpenRSCAD geometry engine, compiled to WebAssembly — parse .scad source and render solid 3D meshes in the browser or Node. Adds an authored-scene GLB/3MF export path with source-derived feature edges; tracks upstream.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0 OR MIT",
@@ -44,6 +44,10 @@
44
44
  "default": "./dist/browser.js"
45
45
  }
46
46
  },
47
+ "./core": {
48
+ "types": "./dist/core.d.ts",
49
+ "default": "./dist/core.js"
50
+ },
47
51
  "./web": {
48
52
  "types": "./pkg/web/openrscad.d.ts",
49
53
  "default": "./pkg/web/openrscad.js"
@@ -61,6 +65,7 @@
61
65
  ],
62
66
  "files": [
63
67
  "dist",
68
+ "!dist/native/*.node",
64
69
  "pkg/web",
65
70
  "pkg/node",
66
71
  "examples",
@@ -68,21 +73,44 @@
68
73
  "LICENSE-APACHE",
69
74
  "LICENSE-MIT"
70
75
  ],
76
+ "engines": {
77
+ "node": ">=20"
78
+ },
71
79
  "publishConfig": {
72
80
  "access": "public",
73
81
  "provenance": true
74
82
  },
75
83
  "scripts": {
76
- "build": "npm run build:wasm && npm run build:facade",
84
+ "build": "npm run build:wasm && npm run build:addon && npm run build:facade",
77
85
  "build:wasm": "wasm-pack build ../../crates/openrscad-wasm --release --target web --out-dir \"$PWD/pkg/web\" --out-name openrscad && wasm-pack build ../../crates/openrscad-wasm --release --target nodejs --out-dir \"$PWD/pkg/node\" --out-name openrscad && rm -f pkg/web/.gitignore pkg/node/.gitignore",
78
86
  "build:wasm:profile": "wasm-pack build ../../crates/openrscad-wasm --release --target web --out-dir \"$PWD/pkg/web\" --out-name openrscad -- --features benchmark-profile && wasm-pack build ../../crates/openrscad-wasm --release --target nodejs --out-dir \"$PWD/pkg/node\" --out-name openrscad -- --features benchmark-profile && rm -f pkg/web/.gitignore pkg/node/.gitignore",
79
- "build:facade": "tsc -p tsconfig.json",
87
+ "build:addon": "napi build --platform --release --esm --js index.js --dts index.d.ts --output-dir ./src/native --manifest-path ../../crates/openrscad-napi/Cargo.toml",
88
+ "build:facade": "tsc -p tsconfig.json && node scripts/copy-native.mjs",
80
89
  "test": "npm run build:facade && node --test test/*.test.mjs"
81
90
  },
82
91
  "devDependencies": {
92
+ "@napi-rs/cli": "3.8.6",
83
93
  "typescript": "^5.5.3"
84
94
  },
85
95
  "contributors": [
86
96
  "Richard Fontein (Tau)"
87
- ]
88
- }
97
+ ],
98
+ "napi": {
99
+ "binaryName": "openrscad",
100
+ "packageName": "@taulabs/openrscad-engine",
101
+ "targets": [
102
+ "aarch64-apple-darwin",
103
+ "x86_64-apple-darwin",
104
+ "x86_64-unknown-linux-gnu",
105
+ "aarch64-unknown-linux-gnu",
106
+ "x86_64-pc-windows-msvc"
107
+ ]
108
+ },
109
+ "optionalDependencies": {
110
+ "@taulabs/openrscad-engine-darwin-arm64": "0.11.0-beta.4",
111
+ "@taulabs/openrscad-engine-darwin-x64": "0.11.0-beta.4",
112
+ "@taulabs/openrscad-engine-linux-x64-gnu": "0.11.0-beta.4",
113
+ "@taulabs/openrscad-engine-linux-arm64-gnu": "0.11.0-beta.4",
114
+ "@taulabs/openrscad-engine-win32-x64-msvc": "0.11.0-beta.4"
115
+ }
116
+ }
@@ -107,6 +107,28 @@ export class RenderResult {
107
107
  readonly warnings: string;
108
108
  }
109
109
 
110
+ /**
111
+ * Serialize the geometry-cache entries added at or after `since_epoch`
112
+ * (`0` = everything) as an opaque, versioned blob for the host to persist.
113
+ */
114
+ export function cache_export(since_epoch: number): Uint8Array;
115
+
116
+ /**
117
+ * Rehydrate entries from a `cache_export` blob of the same engine version and
118
+ * kernel. Returns a JSON report; throws on a foreign or malformed blob.
119
+ */
120
+ export function cache_import(bytes: Uint8Array): string;
121
+
122
+ /**
123
+ * Every resident structural key, ascending, as a `BigUint64Array`.
124
+ */
125
+ export function cache_keys(): BigUint64Array;
126
+
127
+ /**
128
+ * Resident-cache accounting, caps and envelope as JSON.
129
+ */
130
+ export function cache_stats(): string;
131
+
110
132
  /**
111
133
  * Drop the persistent geometry cache (e.g. when loading a new document).
112
134
  */
@@ -444,6 +444,78 @@ class RenderResult {
444
444
  if (Symbol.dispose) RenderResult.prototype[Symbol.dispose] = RenderResult.prototype.free;
445
445
  exports.RenderResult = RenderResult;
446
446
 
447
+ /**
448
+ * Serialize the geometry-cache entries added at or after `since_epoch`
449
+ * (`0` = everything) as an opaque, versioned blob for the host to persist.
450
+ * @param {number} since_epoch
451
+ * @returns {Uint8Array}
452
+ */
453
+ function cache_export(since_epoch) {
454
+ const ret = wasm.cache_export(since_epoch);
455
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
456
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
457
+ return v1;
458
+ }
459
+ exports.cache_export = cache_export;
460
+
461
+ /**
462
+ * Rehydrate entries from a `cache_export` blob of the same engine version and
463
+ * kernel. Returns a JSON report; throws on a foreign or malformed blob.
464
+ * @param {Uint8Array} bytes
465
+ * @returns {string}
466
+ */
467
+ function cache_import(bytes) {
468
+ let deferred3_0;
469
+ let deferred3_1;
470
+ try {
471
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
472
+ const len0 = WASM_VECTOR_LEN;
473
+ const ret = wasm.cache_import(ptr0, len0);
474
+ var ptr2 = ret[0];
475
+ var len2 = ret[1];
476
+ if (ret[3]) {
477
+ ptr2 = 0; len2 = 0;
478
+ throw takeFromExternrefTable0(ret[2]);
479
+ }
480
+ deferred3_0 = ptr2;
481
+ deferred3_1 = len2;
482
+ return getStringFromWasm0(ptr2, len2);
483
+ } finally {
484
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
485
+ }
486
+ }
487
+ exports.cache_import = cache_import;
488
+
489
+ /**
490
+ * Every resident structural key, ascending, as a `BigUint64Array`.
491
+ * @returns {BigUint64Array}
492
+ */
493
+ function cache_keys() {
494
+ const ret = wasm.cache_keys();
495
+ var v1 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
496
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
497
+ return v1;
498
+ }
499
+ exports.cache_keys = cache_keys;
500
+
501
+ /**
502
+ * Resident-cache accounting, caps and envelope as JSON.
503
+ * @returns {string}
504
+ */
505
+ function cache_stats() {
506
+ let deferred1_0;
507
+ let deferred1_1;
508
+ try {
509
+ const ret = wasm.cache_stats();
510
+ deferred1_0 = ret[0];
511
+ deferred1_1 = ret[1];
512
+ return getStringFromWasm0(ret[0], ret[1]);
513
+ } finally {
514
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
515
+ }
516
+ }
517
+ exports.cache_stats = cache_stats;
518
+
447
519
  /**
448
520
  * Drop the persistent geometry cache (e.g. when loading a new document).
449
521
  */
@@ -734,6 +806,10 @@ exports.version = version;
734
806
  function __wbg_get_imports() {
735
807
  const import0 = {
736
808
  __proto__: null,
809
+ __wbg_Error_92b29b0548f8b746: function(arg0, arg1) {
810
+ const ret = Error(getStringFromWasm0(arg0, arg1));
811
+ return ret;
812
+ },
737
813
  __wbg___wbindgen_string_get_b0ca35b86a603356: function(arg0, arg1) {
738
814
  const obj = arg1;
739
815
  const ret = typeof(obj) === 'string' ? obj : undefined;
@@ -801,11 +877,24 @@ function getArrayF32FromWasm0(ptr, len) {
801
877
  return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
802
878
  }
803
879
 
880
+ function getArrayU64FromWasm0(ptr, len) {
881
+ ptr = ptr >>> 0;
882
+ return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
883
+ }
884
+
804
885
  function getArrayU8FromWasm0(ptr, len) {
805
886
  ptr = ptr >>> 0;
806
887
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
807
888
  }
808
889
 
890
+ let cachedBigUint64ArrayMemory0 = null;
891
+ function getBigUint64ArrayMemory0() {
892
+ if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
893
+ cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
894
+ }
895
+ return cachedBigUint64ArrayMemory0;
896
+ }
897
+
809
898
  let cachedDataViewMemory0 = null;
810
899
  function getDataViewMemory0() {
811
900
  if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
@@ -838,6 +927,13 @@ function isLikeNone(x) {
838
927
  return x === undefined || x === null;
839
928
  }
840
929
 
930
+ function passArray8ToWasm0(arg, malloc) {
931
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
932
+ getUint8ArrayMemory0().set(arg, ptr / 1);
933
+ WASM_VECTOR_LEN = arg.length;
934
+ return ptr;
935
+ }
936
+
841
937
  function passArrayJsValueToWasm0(array, malloc) {
842
938
  const ptr = malloc(array.length * 4, 4) >>> 0;
843
939
  for (let i = 0; i < array.length; i++) {
@@ -885,6 +981,12 @@ function passStringToWasm0(arg, malloc, realloc) {
885
981
  return ptr;
886
982
  }
887
983
 
984
+ function takeFromExternrefTable0(idx) {
985
+ const value = wasm.__wbindgen_externrefs.get(idx);
986
+ wasm.__externref_table_dealloc(idx);
987
+ return value;
988
+ }
989
+
888
990
  let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
889
991
  cachedTextDecoder.decode();
890
992
  function decodeText(ptr, len) {
Binary file
@@ -3,6 +3,10 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_exportshape3dresult_free: (a: number, b: number) => void;
5
5
  export const __wbg_renderresult_free: (a: number, b: number) => void;
6
+ export const cache_export: (a: number) => [number, number];
7
+ export const cache_import: (a: number, b: number) => [number, number, number, number];
8
+ export const cache_keys: () => [number, number];
9
+ export const cache_stats: () => [number, number];
6
10
  export const export_2d: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number) => [number, number];
7
11
  export const export_3d: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number) => number;
8
12
  export const exportshape3dresult_area: (a: number) => number;
@@ -45,12 +49,13 @@ export const renderresult_viewport: (a: number) => [number, number];
45
49
  export const renderresult_warnings: (a: number) => [number, number];
46
50
  export const version: () => [number, number];
47
51
  export const start: () => void;
48
- export const clear_cache: () => void;
49
52
  export const renderresult_area: (a: number) => number;
50
53
  export const renderresult_volume: (a: number) => number;
54
+ export const clear_cache: () => void;
51
55
  export const __wbindgen_malloc: (a: number, b: number) => number;
52
56
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
53
57
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
54
58
  export const __wbindgen_externrefs: WebAssembly.Table;
59
+ export const __externref_table_dealloc: (a: number) => void;
55
60
  export const __externref_table_alloc: () => number;
56
61
  export const __wbindgen_start: () => void;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openrscad-wasm",
3
- "version": "0.11.0-beta.2",
3
+ "version": "0.11.0-beta.4",
4
4
  "license": "Apache-2.0 OR MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -107,6 +107,28 @@ export class RenderResult {
107
107
  readonly warnings: string;
108
108
  }
109
109
 
110
+ /**
111
+ * Serialize the geometry-cache entries added at or after `since_epoch`
112
+ * (`0` = everything) as an opaque, versioned blob for the host to persist.
113
+ */
114
+ export function cache_export(since_epoch: number): Uint8Array;
115
+
116
+ /**
117
+ * Rehydrate entries from a `cache_export` blob of the same engine version and
118
+ * kernel. Returns a JSON report; throws on a foreign or malformed blob.
119
+ */
120
+ export function cache_import(bytes: Uint8Array): string;
121
+
122
+ /**
123
+ * Every resident structural key, ascending, as a `BigUint64Array`.
124
+ */
125
+ export function cache_keys(): BigUint64Array;
126
+
127
+ /**
128
+ * Resident-cache accounting, caps and envelope as JSON.
129
+ */
130
+ export function cache_stats(): string;
131
+
110
132
  /**
111
133
  * Drop the persistent geometry cache (e.g. when loading a new document).
112
134
  */
@@ -179,6 +201,10 @@ export interface InitOutput {
179
201
  readonly memory: WebAssembly.Memory;
180
202
  readonly __wbg_exportshape3dresult_free: (a: number, b: number) => void;
181
203
  readonly __wbg_renderresult_free: (a: number, b: number) => void;
204
+ readonly cache_export: (a: number) => [number, number];
205
+ readonly cache_import: (a: number, b: number) => [number, number, number, number];
206
+ readonly cache_keys: () => [number, number];
207
+ readonly cache_stats: () => [number, number];
182
208
  readonly export_2d: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number) => [number, number];
183
209
  readonly export_3d: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number) => number;
184
210
  readonly exportshape3dresult_area: (a: number) => number;
@@ -221,13 +247,14 @@ export interface InitOutput {
221
247
  readonly renderresult_warnings: (a: number) => [number, number];
222
248
  readonly version: () => [number, number];
223
249
  readonly start: () => void;
224
- readonly clear_cache: () => void;
225
250
  readonly renderresult_area: (a: number) => number;
226
251
  readonly renderresult_volume: (a: number) => number;
252
+ readonly clear_cache: () => void;
227
253
  readonly __wbindgen_malloc: (a: number, b: number) => number;
228
254
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
229
255
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
230
256
  readonly __wbindgen_externrefs: WebAssembly.Table;
257
+ readonly __externref_table_dealloc: (a: number) => void;
231
258
  readonly __externref_table_alloc: () => number;
232
259
  readonly __wbindgen_start: () => void;
233
260
  }
@@ -442,6 +442,74 @@ export class RenderResult {
442
442
  }
443
443
  if (Symbol.dispose) RenderResult.prototype[Symbol.dispose] = RenderResult.prototype.free;
444
444
 
445
+ /**
446
+ * Serialize the geometry-cache entries added at or after `since_epoch`
447
+ * (`0` = everything) as an opaque, versioned blob for the host to persist.
448
+ * @param {number} since_epoch
449
+ * @returns {Uint8Array}
450
+ */
451
+ export function cache_export(since_epoch) {
452
+ const ret = wasm.cache_export(since_epoch);
453
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
454
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
455
+ return v1;
456
+ }
457
+
458
+ /**
459
+ * Rehydrate entries from a `cache_export` blob of the same engine version and
460
+ * kernel. Returns a JSON report; throws on a foreign or malformed blob.
461
+ * @param {Uint8Array} bytes
462
+ * @returns {string}
463
+ */
464
+ export function cache_import(bytes) {
465
+ let deferred3_0;
466
+ let deferred3_1;
467
+ try {
468
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
469
+ const len0 = WASM_VECTOR_LEN;
470
+ const ret = wasm.cache_import(ptr0, len0);
471
+ var ptr2 = ret[0];
472
+ var len2 = ret[1];
473
+ if (ret[3]) {
474
+ ptr2 = 0; len2 = 0;
475
+ throw takeFromExternrefTable0(ret[2]);
476
+ }
477
+ deferred3_0 = ptr2;
478
+ deferred3_1 = len2;
479
+ return getStringFromWasm0(ptr2, len2);
480
+ } finally {
481
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
482
+ }
483
+ }
484
+
485
+ /**
486
+ * Every resident structural key, ascending, as a `BigUint64Array`.
487
+ * @returns {BigUint64Array}
488
+ */
489
+ export function cache_keys() {
490
+ const ret = wasm.cache_keys();
491
+ var v1 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
492
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
493
+ return v1;
494
+ }
495
+
496
+ /**
497
+ * Resident-cache accounting, caps and envelope as JSON.
498
+ * @returns {string}
499
+ */
500
+ export function cache_stats() {
501
+ let deferred1_0;
502
+ let deferred1_1;
503
+ try {
504
+ const ret = wasm.cache_stats();
505
+ deferred1_0 = ret[0];
506
+ deferred1_1 = ret[1];
507
+ return getStringFromWasm0(ret[0], ret[1]);
508
+ } finally {
509
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
510
+ }
511
+ }
512
+
445
513
  /**
446
514
  * Drop the persistent geometry cache (e.g. when loading a new document).
447
515
  */
@@ -721,6 +789,10 @@ export function version() {
721
789
  function __wbg_get_imports() {
722
790
  const import0 = {
723
791
  __proto__: null,
792
+ __wbg_Error_92b29b0548f8b746: function(arg0, arg1) {
793
+ const ret = Error(getStringFromWasm0(arg0, arg1));
794
+ return ret;
795
+ },
724
796
  __wbg___wbindgen_string_get_b0ca35b86a603356: function(arg0, arg1) {
725
797
  const obj = arg1;
726
798
  const ret = typeof(obj) === 'string' ? obj : undefined;
@@ -788,11 +860,24 @@ function getArrayF32FromWasm0(ptr, len) {
788
860
  return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
789
861
  }
790
862
 
863
+ function getArrayU64FromWasm0(ptr, len) {
864
+ ptr = ptr >>> 0;
865
+ return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
866
+ }
867
+
791
868
  function getArrayU8FromWasm0(ptr, len) {
792
869
  ptr = ptr >>> 0;
793
870
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
794
871
  }
795
872
 
873
+ let cachedBigUint64ArrayMemory0 = null;
874
+ function getBigUint64ArrayMemory0() {
875
+ if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
876
+ cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
877
+ }
878
+ return cachedBigUint64ArrayMemory0;
879
+ }
880
+
796
881
  let cachedDataViewMemory0 = null;
797
882
  function getDataViewMemory0() {
798
883
  if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
@@ -825,6 +910,13 @@ function isLikeNone(x) {
825
910
  return x === undefined || x === null;
826
911
  }
827
912
 
913
+ function passArray8ToWasm0(arg, malloc) {
914
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
915
+ getUint8ArrayMemory0().set(arg, ptr / 1);
916
+ WASM_VECTOR_LEN = arg.length;
917
+ return ptr;
918
+ }
919
+
828
920
  function passArrayJsValueToWasm0(array, malloc) {
829
921
  const ptr = malloc(array.length * 4, 4) >>> 0;
830
922
  for (let i = 0; i < array.length; i++) {
@@ -872,6 +964,12 @@ function passStringToWasm0(arg, malloc, realloc) {
872
964
  return ptr;
873
965
  }
874
966
 
967
+ function takeFromExternrefTable0(idx) {
968
+ const value = wasm.__wbindgen_externrefs.get(idx);
969
+ wasm.__externref_table_dealloc(idx);
970
+ return value;
971
+ }
972
+
875
973
  let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
876
974
  cachedTextDecoder.decode();
877
975
  const MAX_SAFARI_DECODE_BYTES = 2146435072;
@@ -906,6 +1004,7 @@ function __wbg_finalize_init(instance, module) {
906
1004
  wasmInstance = instance;
907
1005
  wasm = instance.exports;
908
1006
  wasmModule = module;
1007
+ cachedBigUint64ArrayMemory0 = null;
909
1008
  cachedDataViewMemory0 = null;
910
1009
  cachedFloat32ArrayMemory0 = null;
911
1010
  cachedUint8ArrayMemory0 = null;
Binary file
@@ -3,6 +3,10 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_exportshape3dresult_free: (a: number, b: number) => void;
5
5
  export const __wbg_renderresult_free: (a: number, b: number) => void;
6
+ export const cache_export: (a: number) => [number, number];
7
+ export const cache_import: (a: number, b: number) => [number, number, number, number];
8
+ export const cache_keys: () => [number, number];
9
+ export const cache_stats: () => [number, number];
6
10
  export const export_2d: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number) => [number, number];
7
11
  export const export_3d: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number) => number;
8
12
  export const exportshape3dresult_area: (a: number) => number;
@@ -45,12 +49,13 @@ export const renderresult_viewport: (a: number) => [number, number];
45
49
  export const renderresult_warnings: (a: number) => [number, number];
46
50
  export const version: () => [number, number];
47
51
  export const start: () => void;
48
- export const clear_cache: () => void;
49
52
  export const renderresult_area: (a: number) => number;
50
53
  export const renderresult_volume: (a: number) => number;
54
+ export const clear_cache: () => void;
51
55
  export const __wbindgen_malloc: (a: number, b: number) => number;
52
56
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
53
57
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
54
58
  export const __wbindgen_externrefs: WebAssembly.Table;
59
+ export const __externref_table_dealloc: (a: number) => void;
55
60
  export const __externref_table_alloc: () => number;
56
61
  export const __wbindgen_start: () => void;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "openrscad-wasm",
3
3
  "type": "module",
4
- "version": "0.11.0-beta.2",
4
+ "version": "0.11.0-beta.4",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "repository": {
7
7
  "type": "git",