@ifc-lite/wasm 6.1.1 → 6.3.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/README.md CHANGED
@@ -43,9 +43,14 @@ plus unit scale, RTC offset, void/style indices) followed by
43
43
  ```typescript
44
44
  import init, { IfcAPI } from '@ifc-lite/wasm';
45
45
 
46
+ // Your renderer, and your own adapter from a wasm mesh to its mesh type.
47
+ declare const scene: { add(m: unknown): void };
48
+ declare function toThreeMesh(mesh: unknown): unknown;
49
+
46
50
  await init();
47
51
  const api = new IfcAPI();
48
- const bytes = new Uint8Array(await fetch('model.ifc').then(r => r.arrayBuffer()));
52
+ const modelBuffer = await fetch('model.ifc').then(r => r.arrayBuffer());
53
+ const bytes = new Uint8Array(modelBuffer);
49
54
 
50
55
  const pre = api.buildPrePassOnce(bytes);
51
56
  // Large-coordinate models: pre.needsShift / pre.rtcOffset give the RTC origin.
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "IFC-Lite Contributors"
6
6
  ],
7
7
  "description": "WebAssembly bindings for IFC-Lite",
8
- "version": "6.1.1",
8
+ "version": "6.3.0",
9
9
  "license": "MPL-2.0",
10
10
  "repository": {
11
11
  "type": "git",
package/pkg/ifc-lite.d.ts CHANGED
@@ -394,6 +394,24 @@ export class IfcAPI {
394
394
  * ```
395
395
  */
396
396
  exportHbjson(content: Uint8Array, name: string): Uint8Array;
397
+ /**
398
+ * Like [`Self::export_hbjson`], but also returns the export's coverage stats
399
+ * (`HbjsonStats`: spaces seen, rooms emitted, spaces skipped as degenerate, plus
400
+ * apertures / doors / shades / constructions / interior adjacencies) so a caller
401
+ * can tell whether the "success" result silently dropped input.
402
+ *
403
+ * Returns a plain JS object `{ content: Uint8Array, stats: HbjsonStats }`; `content`
404
+ * is UTF-8 HBJSON bytes (same encoding rationale as [`Self::export_hbjson`] — not
405
+ * capped by the V8 max-string ceiling). Runs the export once — `content` and `stats`
406
+ * come from the same pass, not two separate exports.
407
+ *
408
+ * ```javascript
409
+ * const api = new IfcAPI();
410
+ * const { content, stats } = api.exportHbjsonWithStats(ifcContent, "my_model");
411
+ * if (stats.skipped > 0) console.warn(`${stats.skipped} spaces skipped as degenerate`);
412
+ * ```
413
+ */
414
+ exportHbjsonWithStats(content: Uint8Array, name: string): any;
397
415
  /**
398
416
  * Export **IFC5 / IFCX** (the USD-style node graph). `only_known_properties` keeps
399
417
  * only properties with an official IFC5 schema.
@@ -536,7 +554,7 @@ export class IfcAPI {
536
554
  * `Float32Array` of 3D line-list vertices `[x0,y0,z0, x1,y1,z1, …]` in
537
555
  * the renderer's Y-up world space (RTC-subtracted, metres). Consecutive
538
556
  * samples form line segments. Feed straight to
539
- * `renderer.uploadAnnotationLines3D(...)`.
557
+ * `renderer.setLineOverlay('alignment', ...)`.
540
558
  *
541
559
  * Returns an empty array when the file has no alignments (or none with a
542
560
  * resolvable Axis curve), so the caller can clear the overlay cheaply.
@@ -552,7 +570,7 @@ export class IfcAPI {
552
570
  * Parse the file and return every `IfcGridAxis` as a flat `Float32Array`
553
571
  * of 3D line-list vertices `[x0,y0,z0, x1,y1,z1, …]` (one segment per
554
572
  * axis) in the renderer's Y-up world space (RTC-subtracted, metres). Feed
555
- * straight to a line pipeline (e.g. `uploadAnnotationLines3D`).
573
+ * straight to a line pipeline (e.g. `renderer.setLineOverlay('grid', …)`).
556
574
  *
557
575
  * Returns an empty array when the file has no grids, so the caller can
558
576
  * clear the overlay cheaply.
@@ -655,8 +673,9 @@ export class IfcAPI {
655
673
  * range_end)` shard; the main thread stitches the returned columns into the
656
674
  * full entity index (byte-identical to the single-threaded
657
675
  * `build_entity_index`) by binary-searching each shard for the previous
658
- * shard's `handoff`. Delegates to `ifc_lite_processing::scan_shard_classified`
659
- * — a separately-maintained loop over the same `EntityScanner` primitive as
676
+ * shard's `handoff`. Delegates to
677
+ * `ifc_lite_processing::scan_shard_classified_with_refusals` a
678
+ * separately-maintained loop over the same `EntityScanner` primitive as
660
679
  * `scan_shard` (the one the native `build_entity_index_parallel` fans across
661
680
  * cores), plus a per-record class column this sharded path also needs. The
662
681
  * two loops' records/handoff are kept in parity by a dedicated test
@@ -666,12 +685,24 @@ export class IfcAPI {
666
685
  * Byte offsets returned are GLOBAL (relative to file start), so shards
667
686
  * concatenate without rewriting. Returns a plain object:
668
687
  * `{ ids: Uint32Array, starts: Uint32Array, lengths: Uint32Array,
669
- * classes: Uint8Array, handoff: number }`
688
+ * classes: Uint8Array, handoff: number,
689
+ * oversizedIdStarts: Uint32Array }`
670
690
  * where `classes` is the parallel per-record prepass class byte
671
691
  * (`PREPASS_CLASS_*`: named code in the low bits plus the geometry-job /
672
692
  * type-candidate flags) the host filters on to rebuild pre-pass span
673
693
  * lists, and `handoff` is the global start of the first entity at/after
674
694
  * `range_end` (the next shard's first real entity), or `-1` at EOF.
695
+ *
696
+ * `oversizedIdStarts` carries the global start byte of every record this
697
+ * shard refused for an express id above `u32::MAX` (#3395). Offsets, not
698
+ * a count, and deliberately NOT reported from here: a shard begins at an
699
+ * arbitrary byte, so it can start inside a quoted value and refuse a
700
+ * string literal shaped like `#4294967297=IFCWALL(` — text no file
701
+ * declared. Reporting per shard would warn "skipped N records" on a file
702
+ * that is fine. The host's stitch keeps only the offsets at/after the
703
+ * retained boundary it computed for this shard and reports once, which is
704
+ * what makes the number attributable to a record the stitch retained
705
+ * (#3430).
675
706
  */
676
707
  scanEntityIndexShard(data: Uint8Array, range_start: number, range_end: number): any;
677
708
  /**
@@ -1225,6 +1256,12 @@ export class ProfileCollection {
1225
1256
  * Number of profiles.
1226
1257
  */
1227
1258
  readonly length: number;
1259
+ /**
1260
+ * Express IDs of elements that had an `IfcExtrudedAreaSolid` (direct or
1261
+ * mapped) but whose profile could not be extracted, so they are MISSING
1262
+ * from this collection. Empty on a clean model.
1263
+ */
1264
+ readonly skippedExpressIds: Uint32Array;
1228
1265
  }
1229
1266
 
1230
1267
  /**
@@ -1772,7 +1809,8 @@ export function get_memory(): any;
1772
1809
  * Initialize the WASM module.
1773
1810
  *
1774
1811
  * This function is called automatically when the WASM module is loaded.
1775
- * It sets up panic hooks for better error messages in the browser console.
1812
+ * It sets up panic hooks for better error messages in the browser console,
1813
+ * and points core's scan diagnostics at that console too.
1776
1814
  */
1777
1815
  export function init(): void;
1778
1816
 
@@ -1945,6 +1983,7 @@ export interface InitOutput {
1945
1983
  readonly ifcapi_exportGlb: (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) => void;
1946
1984
  readonly ifcapi_exportGlbFromMeshes: (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) => void;
1947
1985
  readonly ifcapi_exportHbjson: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
1986
+ readonly ifcapi_exportHbjsonWithStats: (a: number, b: number, c: number, d: number, e: number) => number;
1948
1987
  readonly ifcapi_exportIfcx: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
1949
1988
  readonly ifcapi_exportJson: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
1950
1989
  readonly ifcapi_exportJsonld: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
@@ -2038,6 +2077,7 @@ export interface InitOutput {
2038
2077
  readonly partitionedbatch_takeShard: (a: number, b: number) => void;
2039
2078
  readonly profilecollection_get: (a: number, b: number) => number;
2040
2079
  readonly profilecollection_length: (a: number) => number;
2080
+ readonly profilecollection_skippedExpressIds: (a: number) => number;
2041
2081
  readonly profileentryjs_expressId: (a: number) => number;
2042
2082
  readonly profileentryjs_extrusionDepth: (a: number) => number;
2043
2083
  readonly profileentryjs_extrusionDir: (a: number) => number;
@@ -2145,7 +2185,6 @@ export interface InitOutput {
2145
2185
  readonly zonesplitjs_piece: (a: number, b: number) => number;
2146
2186
  readonly zonesplitjs_pieceCount: (a: number) => number;
2147
2187
  readonly zonesplitjs_remainderFailed: (a: number) => number;
2148
- readonly init: () => void;
2149
2188
  readonly meshoutlinejs_contourCount: (a: number) => number;
2150
2189
  readonly symbolicpolyline_pointCount: (a: number) => number;
2151
2190
  readonly get_memory: () => number;
@@ -2164,6 +2203,7 @@ export interface InitOutput {
2164
2203
  readonly zonepiecejs_volume: (a: number) => number;
2165
2204
  readonly zonesplitjs_sumErrorRel: (a: number) => number;
2166
2205
  readonly zonesplitjs_wholeVolume: (a: number) => number;
2206
+ readonly init: () => void;
2167
2207
  readonly __wbindgen_export: (a: number, b: number) => number;
2168
2208
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
2169
2209
  readonly __wbindgen_export3: (a: number) => void;
package/pkg/ifc-lite.js CHANGED
@@ -1010,6 +1010,34 @@ export class IfcAPI {
1010
1010
  wasm.__wbindgen_add_to_stack_pointer(16);
1011
1011
  }
1012
1012
  }
1013
+ /**
1014
+ * Like [`Self::export_hbjson`], but also returns the export's coverage stats
1015
+ * (`HbjsonStats`: spaces seen, rooms emitted, spaces skipped as degenerate, plus
1016
+ * apertures / doors / shades / constructions / interior adjacencies) so a caller
1017
+ * can tell whether the "success" result silently dropped input.
1018
+ *
1019
+ * Returns a plain JS object `{ content: Uint8Array, stats: HbjsonStats }`; `content`
1020
+ * is UTF-8 HBJSON bytes (same encoding rationale as [`Self::export_hbjson`] — not
1021
+ * capped by the V8 max-string ceiling). Runs the export once — `content` and `stats`
1022
+ * come from the same pass, not two separate exports.
1023
+ *
1024
+ * ```javascript
1025
+ * const api = new IfcAPI();
1026
+ * const { content, stats } = api.exportHbjsonWithStats(ifcContent, "my_model");
1027
+ * if (stats.skipped > 0) console.warn(`${stats.skipped} spaces skipped as degenerate`);
1028
+ * ```
1029
+ * @param {Uint8Array} content
1030
+ * @param {string} name
1031
+ * @returns {any}
1032
+ */
1033
+ exportHbjsonWithStats(content, name) {
1034
+ const ptr0 = passArray8ToWasm0(content, wasm.__wbindgen_export);
1035
+ const len0 = WASM_VECTOR_LEN;
1036
+ const ptr1 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1037
+ const len1 = WASM_VECTOR_LEN;
1038
+ const ret = wasm.ifcapi_exportHbjsonWithStats(this.__wbg_ptr, ptr0, len0, ptr1, len1);
1039
+ return takeObject(ret);
1040
+ }
1013
1041
  /**
1014
1042
  * Export **IFC5 / IFCX** (the USD-style node graph). `only_known_properties` keeps
1015
1043
  * only properties with an official IFC5 schema.
@@ -1450,7 +1478,7 @@ export class IfcAPI {
1450
1478
  * `Float32Array` of 3D line-list vertices `[x0,y0,z0, x1,y1,z1, …]` in
1451
1479
  * the renderer's Y-up world space (RTC-subtracted, metres). Consecutive
1452
1480
  * samples form line segments. Feed straight to
1453
- * `renderer.uploadAnnotationLines3D(...)`.
1481
+ * `renderer.setLineOverlay('alignment', ...)`.
1454
1482
  *
1455
1483
  * Returns an empty array when the file has no alignments (or none with a
1456
1484
  * resolvable Axis curve), so the caller can clear the overlay cheaply.
@@ -1480,7 +1508,7 @@ export class IfcAPI {
1480
1508
  * Parse the file and return every `IfcGridAxis` as a flat `Float32Array`
1481
1509
  * of 3D line-list vertices `[x0,y0,z0, x1,y1,z1, …]` (one segment per
1482
1510
  * axis) in the renderer's Y-up world space (RTC-subtracted, metres). Feed
1483
- * straight to a line pipeline (e.g. `uploadAnnotationLines3D`).
1511
+ * straight to a line pipeline (e.g. `renderer.setLineOverlay('grid', …)`).
1484
1512
  *
1485
1513
  * Returns an empty array when the file has no grids, so the caller can
1486
1514
  * clear the overlay cheaply.
@@ -1835,8 +1863,9 @@ export class IfcAPI {
1835
1863
  * range_end)` shard; the main thread stitches the returned columns into the
1836
1864
  * full entity index (byte-identical to the single-threaded
1837
1865
  * `build_entity_index`) by binary-searching each shard for the previous
1838
- * shard's `handoff`. Delegates to `ifc_lite_processing::scan_shard_classified`
1839
- * — a separately-maintained loop over the same `EntityScanner` primitive as
1866
+ * shard's `handoff`. Delegates to
1867
+ * `ifc_lite_processing::scan_shard_classified_with_refusals` a
1868
+ * separately-maintained loop over the same `EntityScanner` primitive as
1840
1869
  * `scan_shard` (the one the native `build_entity_index_parallel` fans across
1841
1870
  * cores), plus a per-record class column this sharded path also needs. The
1842
1871
  * two loops' records/handoff are kept in parity by a dedicated test
@@ -1846,12 +1875,24 @@ export class IfcAPI {
1846
1875
  * Byte offsets returned are GLOBAL (relative to file start), so shards
1847
1876
  * concatenate without rewriting. Returns a plain object:
1848
1877
  * `{ ids: Uint32Array, starts: Uint32Array, lengths: Uint32Array,
1849
- * classes: Uint8Array, handoff: number }`
1878
+ * classes: Uint8Array, handoff: number,
1879
+ * oversizedIdStarts: Uint32Array }`
1850
1880
  * where `classes` is the parallel per-record prepass class byte
1851
1881
  * (`PREPASS_CLASS_*`: named code in the low bits plus the geometry-job /
1852
1882
  * type-candidate flags) the host filters on to rebuild pre-pass span
1853
1883
  * lists, and `handoff` is the global start of the first entity at/after
1854
1884
  * `range_end` (the next shard's first real entity), or `-1` at EOF.
1885
+ *
1886
+ * `oversizedIdStarts` carries the global start byte of every record this
1887
+ * shard refused for an express id above `u32::MAX` (#3395). Offsets, not
1888
+ * a count, and deliberately NOT reported from here: a shard begins at an
1889
+ * arbitrary byte, so it can start inside a quoted value and refuse a
1890
+ * string literal shaped like `#4294967297=IFCWALL(` — text no file
1891
+ * declared. Reporting per shard would warn "skipped N records" on a file
1892
+ * that is fine. The host's stitch keeps only the offsets at/after the
1893
+ * retained boundary it computed for this shard and reports once, which is
1894
+ * what makes the number attributable to a record the stitch retained
1895
+ * (#3430).
1855
1896
  * @param {Uint8Array} data
1856
1897
  * @param {number} range_start
1857
1898
  * @param {number} range_end
@@ -2927,6 +2968,16 @@ export class ProfileCollection {
2927
2968
  const ret = wasm.profilecollection_length(this.__wbg_ptr);
2928
2969
  return ret >>> 0;
2929
2970
  }
2971
+ /**
2972
+ * Express IDs of elements that had an `IfcExtrudedAreaSolid` (direct or
2973
+ * mapped) but whose profile could not be extracted, so they are MISSING
2974
+ * from this collection. Empty on a clean model.
2975
+ * @returns {Uint32Array}
2976
+ */
2977
+ get skippedExpressIds() {
2978
+ const ret = wasm.profilecollection_skippedExpressIds(this.__wbg_ptr);
2979
+ return takeObject(ret);
2980
+ }
2930
2981
  }
2931
2982
  if (Symbol.dispose) ProfileCollection.prototype[Symbol.dispose] = ProfileCollection.prototype.free;
2932
2983
 
@@ -4723,7 +4774,8 @@ export function get_memory() {
4723
4774
  * Initialize the WASM module.
4724
4775
  *
4725
4776
  * This function is called automatically when the WASM module is loaded.
4726
- * It sets up panic hooks for better error messages in the browser console.
4777
+ * It sets up panic hooks for better error messages in the browser console,
4778
+ * and points core's scan diagnostics at that console too.
4727
4779
  */
4728
4780
  export function init() {
4729
4781
  wasm.init();
Binary file