okgeometry-api 1.1.20 → 1.1.22

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.
@@ -1 +1 @@
1
- {"version":3,"file":"wasm-base64.js","sourceRoot":"","sources":["../src/wasm-base64.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,MAAM,CAAC,MAAM,QAAQ,GAAG,sh5tCAAsh5tC,CAAC"}
1
+ {"version":3,"file":"wasm-base64.js","sourceRoot":"","sources":["../src/wasm-base64.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,MAAM,CAAC,MAAM,QAAQ,GAAG,0yquCAA0yquC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "okgeometry-api",
3
- "version": "1.1.20",
3
+ "version": "1.1.22",
4
4
  "description": "Geometry engine API for AEC applications — NURBS, meshes, booleans, intersections. Powered by Rust/WASM.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/Mesh.ts CHANGED
@@ -181,12 +181,18 @@ export interface MeshBooleanReproOptions {
181
181
  includeResult?: boolean;
182
182
  debugOptions?: MeshBooleanDebugOptions;
183
183
  }
184
-
185
- /**
186
- * Buffer-backed triangle mesh with GPU-ready accessors.
187
- * All geometry lives in a Float64Array from WASM.
188
- *
189
- * Buffer format: [vertexCount, x1,y1,z1, ..., i1,i2,i3, ...]
184
+
185
+ function shouldFallbackFromWorkerFailure(error: unknown): boolean {
186
+ if (!error || typeof error !== "object") return false;
187
+ const code = "code" in error ? error.code : undefined;
188
+ return code === "worker_unavailable" || code === "worker_crashed" || code === "worker_protocol";
189
+ }
190
+
191
+ /**
192
+ * Buffer-backed triangle mesh with GPU-ready accessors.
193
+ * All geometry lives in a Float64Array from WASM.
194
+ *
195
+ * Buffer format: [vertexCount, x1,y1,z1, ..., i1,i2,i3, ...]
190
196
  */
191
197
  export class Mesh {
192
198
  private _buffer: Float64Array;
@@ -1807,50 +1813,80 @@ export class Mesh {
1807
1813
  /**
1808
1814
  * Compute boolean union in a dedicated Web Worker (non-blocking).
1809
1815
  * Defaults to allowUnsafe=true so high-poly jobs can run off the UI thread.
1810
- */
1811
- async unionAsync(other: Mesh, options?: MeshBooleanAsyncOptions): Promise<Mesh> {
1812
- const result = await runMeshBooleanInWorkerPool(
1813
- "union",
1814
- this._buffer,
1815
- other._buffer,
1816
- this._trustedBooleanInput,
1817
- other._trustedBooleanInput,
1818
- options,
1819
- );
1820
- return Mesh.fromTrustedBuffer(result);
1821
- }
1816
+ */
1817
+ async unionAsync(other: Mesh, options?: MeshBooleanAsyncOptions): Promise<Mesh> {
1818
+ try {
1819
+ const result = await runMeshBooleanInWorkerPool(
1820
+ "union",
1821
+ this._buffer,
1822
+ other._buffer,
1823
+ this._trustedBooleanInput,
1824
+ other._trustedBooleanInput,
1825
+ options,
1826
+ );
1827
+ return Mesh.fromTrustedBuffer(result);
1828
+ } catch (error) {
1829
+ if (!shouldFallbackFromWorkerFailure(error)) throw error;
1830
+ console.warn("Mesh.unionAsync worker failed; falling back to main-thread boolean.", error);
1831
+ return this.union(other, {
1832
+ allowUnsafe: options?.allowUnsafe ?? true,
1833
+ limits: options?.limits,
1834
+ debugForceFaceID: options?.debugForceFaceID,
1835
+ });
1836
+ }
1837
+ }
1822
1838
 
1823
- /**
1824
- * Compute boolean subtraction in a dedicated Web Worker (non-blocking).
1825
- * Defaults to allowUnsafe=true so high-poly jobs can run off the UI thread.
1826
- */
1827
- async subtractAsync(other: Mesh, options?: MeshBooleanAsyncOptions): Promise<Mesh> {
1828
- const result = await runMeshBooleanInWorkerPool(
1829
- "subtraction",
1830
- this._buffer,
1831
- other._buffer,
1832
- this._trustedBooleanInput,
1833
- other._trustedBooleanInput,
1834
- options,
1835
- );
1836
- return Mesh.fromTrustedBuffer(result);
1837
- }
1839
+ /**
1840
+ * Compute boolean subtraction in a dedicated Web Worker (non-blocking).
1841
+ * Defaults to allowUnsafe=true so high-poly jobs can run off the UI thread.
1842
+ */
1843
+ async subtractAsync(other: Mesh, options?: MeshBooleanAsyncOptions): Promise<Mesh> {
1844
+ try {
1845
+ const result = await runMeshBooleanInWorkerPool(
1846
+ "subtraction",
1847
+ this._buffer,
1848
+ other._buffer,
1849
+ this._trustedBooleanInput,
1850
+ other._trustedBooleanInput,
1851
+ options,
1852
+ );
1853
+ return Mesh.fromTrustedBuffer(result);
1854
+ } catch (error) {
1855
+ if (!shouldFallbackFromWorkerFailure(error)) throw error;
1856
+ console.warn("Mesh.subtractAsync worker failed; falling back to main-thread boolean.", error);
1857
+ return this.subtract(other, {
1858
+ allowUnsafe: options?.allowUnsafe ?? true,
1859
+ limits: options?.limits,
1860
+ debugForceFaceID: options?.debugForceFaceID,
1861
+ });
1862
+ }
1863
+ }
1838
1864
 
1839
- /**
1840
- * Compute boolean intersection in a dedicated Web Worker (non-blocking).
1841
- * Defaults to allowUnsafe=true so high-poly jobs can run off the UI thread.
1842
- */
1843
- async intersectAsync(other: Mesh, options?: MeshBooleanAsyncOptions): Promise<Mesh> {
1844
- const result = await runMeshBooleanInWorkerPool(
1845
- "intersection",
1846
- this._buffer,
1847
- other._buffer,
1848
- this._trustedBooleanInput,
1849
- other._trustedBooleanInput,
1850
- options,
1851
- );
1852
- return Mesh.fromTrustedBuffer(result);
1853
- }
1865
+ /**
1866
+ * Compute boolean intersection in a dedicated Web Worker (non-blocking).
1867
+ * Defaults to allowUnsafe=true so high-poly jobs can run off the UI thread.
1868
+ */
1869
+ async intersectAsync(other: Mesh, options?: MeshBooleanAsyncOptions): Promise<Mesh> {
1870
+ try {
1871
+ const result = await runMeshBooleanInWorkerPool(
1872
+ "intersection",
1873
+ this._buffer,
1874
+ other._buffer,
1875
+ this._trustedBooleanInput,
1876
+ other._trustedBooleanInput,
1877
+ options,
1878
+ );
1879
+ return Mesh.fromTrustedBuffer(result);
1880
+ } catch (error) {
1881
+ if (!shouldFallbackFromWorkerFailure(error)) throw error;
1882
+ console.warn("Mesh.intersectAsync worker failed; falling back to main-thread boolean.", error);
1883
+ return this.intersect(other, {
1884
+ allowUnsafe: options?.allowUnsafe ?? true,
1885
+ limits: options?.limits,
1886
+ debugForceFaceID: options?.debugForceFaceID,
1887
+ });
1888
+ }
1889
+ }
1854
1890
 
1855
1891
  // ── Intersection queries ───────────────────────────────────────
1856
1892