@ifc-lite/parser 5.2.0 → 6.2.1

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.
Files changed (153) hide show
  1. package/dist/columnar-entity-preparation.d.ts +3 -0
  2. package/dist/columnar-entity-preparation.d.ts.map +1 -1
  3. package/dist/columnar-entity-preparation.js +101 -11
  4. package/dist/columnar-entity-preparation.js.map +1 -1
  5. package/dist/columnar-parser-indexes.d.ts +17 -1
  6. package/dist/columnar-parser-indexes.d.ts.map +1 -1
  7. package/dist/columnar-parser-indexes.js +31 -21
  8. package/dist/columnar-parser-indexes.js.map +1 -1
  9. package/dist/columnar-parser.d.ts +10 -1
  10. package/dist/columnar-parser.d.ts.map +1 -1
  11. package/dist/columnar-parser.js +14 -2
  12. package/dist/columnar-parser.js.map +1 -1
  13. package/dist/cost-extractor.d.ts +10 -0
  14. package/dist/cost-extractor.d.ts.map +1 -0
  15. package/dist/cost-extractor.js +369 -0
  16. package/dist/cost-extractor.js.map +1 -0
  17. package/dist/cost-schedule-2x3.d.ts +31 -0
  18. package/dist/cost-schedule-2x3.d.ts.map +1 -0
  19. package/dist/cost-schedule-2x3.js +75 -0
  20. package/dist/cost-schedule-2x3.js.map +1 -0
  21. package/dist/cost-types.d.ts +105 -0
  22. package/dist/cost-types.d.ts.map +1 -0
  23. package/dist/cost-types.js +5 -0
  24. package/dist/cost-types.js.map +1 -0
  25. package/dist/data-store-transport.d.ts +1 -0
  26. package/dist/data-store-transport.d.ts.map +1 -1
  27. package/dist/data-store-transport.js +5 -29
  28. package/dist/data-store-transport.js.map +1 -1
  29. package/dist/drop-census.d.ts +136 -0
  30. package/dist/drop-census.d.ts.map +1 -0
  31. package/dist/drop-census.js +53 -0
  32. package/dist/drop-census.js.map +1 -0
  33. package/dist/entity-scanner.d.ts.map +1 -1
  34. package/dist/entity-scanner.js +10 -5
  35. package/dist/entity-scanner.js.map +1 -1
  36. package/dist/generated/ifc2x3/schema-registry.d.ts +50 -0
  37. package/dist/generated/ifc2x3/schema-registry.d.ts.map +1 -0
  38. package/dist/generated/ifc2x3/schema-registry.js +50052 -0
  39. package/dist/generated/ifc2x3/schema-registry.js.map +1 -0
  40. package/dist/generated/ifc4x3/schema-registry.d.ts +50 -0
  41. package/dist/generated/ifc4x3/schema-registry.d.ts.map +1 -0
  42. package/dist/generated/ifc4x3/schema-registry.js +71299 -0
  43. package/dist/generated/ifc4x3/schema-registry.js.map +1 -0
  44. package/dist/generated/schema-registry-by-version.d.ts +61 -0
  45. package/dist/generated/schema-registry-by-version.d.ts.map +1 -0
  46. package/dist/generated/schema-registry-by-version.js +86 -0
  47. package/dist/generated/schema-registry-by-version.js.map +1 -0
  48. package/dist/georef-extractor.js +5 -5
  49. package/dist/georef-extractor.js.map +1 -1
  50. package/dist/group-assignment-factor.d.ts +13 -0
  51. package/dist/group-assignment-factor.d.ts.map +1 -0
  52. package/dist/group-assignment-factor.js +30 -0
  53. package/dist/group-assignment-factor.js.map +1 -0
  54. package/dist/ifczip.d.ts +7 -1
  55. package/dist/ifczip.d.ts.map +1 -1
  56. package/dist/ifczip.js +80 -14
  57. package/dist/ifczip.js.map +1 -1
  58. package/dist/index.d.ts +7 -2
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +13 -2
  61. package/dist/index.js.map +1 -1
  62. package/dist/on-demand-extractors.d.ts +1 -0
  63. package/dist/on-demand-extractors.d.ts.map +1 -1
  64. package/dist/on-demand-extractors.js +2 -1
  65. package/dist/on-demand-extractors.js.map +1 -1
  66. package/dist/property-value-parser.d.ts +10 -0
  67. package/dist/property-value-parser.d.ts.map +1 -1
  68. package/dist/property-value-parser.js +40 -1
  69. package/dist/property-value-parser.js.map +1 -1
  70. package/dist/scan-entities-balanced.d.ts.map +1 -1
  71. package/dist/scan-entities-balanced.js +11 -6
  72. package/dist/scan-entities-balanced.js.map +1 -1
  73. package/dist/scan-worker-lexing.d.ts +14 -0
  74. package/dist/scan-worker-lexing.d.ts.map +1 -0
  75. package/dist/scan-worker-lexing.js +106 -0
  76. package/dist/scan-worker-lexing.js.map +1 -0
  77. package/dist/scan-worker-source.d.ts +1 -1
  78. package/dist/scan-worker-source.d.ts.map +1 -1
  79. package/dist/scan-worker-source.js +64 -59
  80. package/dist/scan-worker-source.js.map +1 -1
  81. package/dist/schedule-extractor.d.ts +2 -80
  82. package/dist/schedule-extractor.d.ts.map +1 -1
  83. package/dist/schedule-extractor.js +100 -225
  84. package/dist/schedule-extractor.js.map +1 -1
  85. package/dist/schedule-serializer-builders.d.ts +28 -0
  86. package/dist/schedule-serializer-builders.d.ts.map +1 -0
  87. package/dist/schedule-serializer-builders.js +163 -0
  88. package/dist/schedule-serializer-builders.js.map +1 -0
  89. package/dist/schedule-serializer.d.ts +6 -0
  90. package/dist/schedule-serializer.d.ts.map +1 -1
  91. package/dist/schedule-serializer.js +26 -165
  92. package/dist/schedule-serializer.js.map +1 -1
  93. package/dist/schedule-types.d.ts +211 -0
  94. package/dist/schedule-types.d.ts.map +1 -0
  95. package/dist/schedule-types.js +221 -0
  96. package/dist/schedule-types.js.map +1 -0
  97. package/dist/spatial-hierarchy-ambiguity.d.ts +39 -0
  98. package/dist/spatial-hierarchy-ambiguity.d.ts.map +1 -0
  99. package/dist/spatial-hierarchy-ambiguity.js +25 -0
  100. package/dist/spatial-hierarchy-ambiguity.js.map +1 -0
  101. package/dist/spatial-hierarchy-attributes.d.ts +54 -0
  102. package/dist/spatial-hierarchy-attributes.d.ts.map +1 -0
  103. package/dist/spatial-hierarchy-attributes.js +145 -0
  104. package/dist/spatial-hierarchy-attributes.js.map +1 -0
  105. package/dist/spatial-hierarchy-builder.d.ts +0 -30
  106. package/dist/spatial-hierarchy-builder.d.ts.map +1 -1
  107. package/dist/spatial-hierarchy-builder.js +45 -167
  108. package/dist/spatial-hierarchy-builder.js.map +1 -1
  109. package/dist/spatial-hierarchy-canonical-parent.d.ts +52 -2
  110. package/dist/spatial-hierarchy-canonical-parent.d.ts.map +1 -1
  111. package/dist/spatial-hierarchy-canonical-parent.js +153 -4
  112. package/dist/spatial-hierarchy-canonical-parent.js.map +1 -1
  113. package/dist/step-lexing.d.ts +1 -1
  114. package/dist/step-lexing.d.ts.map +1 -1
  115. package/dist/step-lexing.js +1 -56
  116. package/dist/step-lexing.js.map +1 -1
  117. package/dist/step-record-boundary.d.ts +28 -0
  118. package/dist/step-record-boundary.d.ts.map +1 -0
  119. package/dist/step-record-boundary.js +133 -0
  120. package/dist/step-record-boundary.js.map +1 -0
  121. package/dist/step-record-boundary.vectors.d.ts +102 -0
  122. package/dist/step-record-boundary.vectors.d.ts.map +1 -0
  123. package/dist/step-record-boundary.vectors.js +131 -0
  124. package/dist/step-record-boundary.vectors.js.map +1 -0
  125. package/dist/structural-extractor.d.ts +9 -0
  126. package/dist/structural-extractor.d.ts.map +1 -0
  127. package/dist/structural-extractor.js +310 -0
  128. package/dist/structural-extractor.js.map +1 -0
  129. package/dist/structural-load-extractor.d.ts +147 -0
  130. package/dist/structural-load-extractor.d.ts.map +1 -0
  131. package/dist/structural-load-extractor.js +178 -0
  132. package/dist/structural-load-extractor.js.map +1 -0
  133. package/dist/structural-step-values.d.ts +51 -0
  134. package/dist/structural-step-values.d.ts.map +1 -0
  135. package/dist/structural-step-values.js +109 -0
  136. package/dist/structural-step-values.js.map +1 -0
  137. package/dist/structural-types.d.ts +145 -0
  138. package/dist/structural-types.d.ts.map +1 -0
  139. package/dist/structural-types.js +5 -0
  140. package/dist/structural-types.js.map +1 -0
  141. package/dist/tokenizer.d.ts +11 -5
  142. package/dist/tokenizer.d.ts.map +1 -1
  143. package/dist/tokenizer.js +78 -21
  144. package/dist/tokenizer.js.map +1 -1
  145. package/dist/wasm-init-retry.d.ts +6 -42
  146. package/dist/wasm-init-retry.d.ts.map +1 -1
  147. package/dist/wasm-init-retry.js +6 -99
  148. package/dist/wasm-init-retry.js.map +1 -1
  149. package/dist/wasm-panic-forward.d.ts +7 -63
  150. package/dist/wasm-panic-forward.d.ts.map +1 -1
  151. package/dist/wasm-panic-forward.js +7 -100
  152. package/dist/wasm-panic-forward.js.map +1 -1
  153. package/package.json +5 -4
@@ -1 +1 @@
1
- {"version":3,"file":"wasm-init-retry.d.ts","sourceRoot":"","sources":["../src/wasm-init-retry.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAOjE;AA6CD,MAAM,WAAW,oBAAoB;IACnC,qEAAqE;IACrE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uDAAuD;IACvD,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,oDAAoD;IACpD,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAKD;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,EAC5B,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,IAAI,CAAC,CAgBf"}
1
+ {"version":3,"file":"wasm-init-retry.d.ts","sourceRoot":"","sources":["../src/wasm-init-retry.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,KAAK,oBAAoB,GAC1B,MAAM,0BAA0B,CAAC"}
@@ -2,105 +2,12 @@
2
2
  * License, v. 2.0. If a copy of the MPL was not distributed with this
3
3
  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
4
  /**
5
- * Resilient one-shot retry around wasm-bindgen's `init()`.
5
+ * Re-export of the shared WASM load-retry classification (issue #4247).
6
6
  *
7
- * wasm-bindgen's streaming loader rethrows on a non-OK HTTP status or a failed
8
- * fetch of `ifc-lite_bg.wasm` (it only falls back to `arrayBuffer`+`instantiate`
9
- * for the wrong-MIME case), surfacing as `TypeError: Failed to execute
10
- * 'compile' on 'WebAssembly': HTTP status code is not ok`. A transient blip — a
11
- * cold CDN edge, a mid-deploy race, a flaky proxy/antivirus — can produce a
12
- * one-off failure that a second attempt recovers.
13
- *
14
- * Extracted from the worker so it is unit-testable without a real wasm bundle.
15
- */
16
- /**
17
- * True when `message` looks like a transient transport/download failure of the
18
- * engine binary (worth one retry) rather than a genuine corrupt-module or
19
- * validation error (which must propagate immediately so real bugs aren't
20
- * masked).
21
- *
22
- * Per the WebAssembly Web API, the streaming loader validates the HTTP response
23
- * (status, MIME, CORS) and rejects with a `TypeError` BEFORE compiling, so only
24
- * those transport failures are retry-worthy. Invalid bytes (corrupt module,
25
- * wrong magic header) reject with a `CompileError` — retrying just refetches
26
- * the same bad bytes, so those fail fast.
27
- */
28
- export function isTransientWasmLoadError(message) {
29
- // Fail fast on genuine module-validation errors even if a transport-ish word
30
- // somehow appears in the message.
31
- if (/compileerror|validation error|magic (?:word|number)|invalid (?:wasm|module)/i.test(message)) {
32
- return false;
33
- }
34
- return /HTTP status code is not ok|failed to fetch|network ?error|load failed/i.test(message);
35
- }
36
- /**
37
- * A message that already names the thing that failed to load, so re-throwing it
38
- * with an attribution prefix would only add noise. Deliberately includes
39
- * `WebAssembly` (the `'compile' on 'WebAssembly'` phrasings) — those are exactly
40
- * the signatures `isWasmAssetUnavailableError` (wasm-asset-error.ts) matches to
41
- * drive the #1363 stale-deploy reload, and they must reach it byte-for-byte.
42
- */
43
- const SELF_IDENTIFYING = /wasm|webassembly/i;
44
- /**
45
- * A failed *module* load already carries its own specifier. Prefixing one with
46
- * `ifc-lite_bg.wasm` would make it look to that same #1363 matcher like a
47
- * rotated ENGINE BINARY (`/\.wasm/` + "dynamically imported module") and
48
- * trigger a spurious page reload, so those are passed through untouched.
49
- */
50
- const MODULE_LOAD_FAILURE = /dynamically imported module|module script/i;
51
- /**
52
- * Name the engine binary in a transport failure that names nothing (issue #1903).
53
- *
54
- * wasm-bindgen's generated loader `await`s the `fetch()` it starts, so a
55
- * network-level rejection propagates RAW: WebKit words it `TypeError: Load
56
- * failed`, Chromium `TypeError: Failed to fetch`, and because the rejection
57
- * originates inside the fetch rather than in our frames it carries an EMPTY
58
- * stack. Two words and no frames is unattributable by construction — the toast,
59
- * `classifyLoadError` in the viewer, and error tracking all see a bare
60
- * `TypeError` that could have come from anywhere in the load.
61
- *
62
- * So when the final failure identifies nothing, re-throw it naming the binary
63
- * and the call site, preserving the original as `.cause`. Anything that already
64
- * identifies itself is returned unchanged.
65
- */
66
- function attributeEngineLoadFailure(error, label) {
67
- if (!(error instanceof Error))
68
- return error;
69
- const msg = error.message;
70
- if (!isTransientWasmLoadError(msg))
71
- return error;
72
- if (SELF_IDENTIFYING.test(msg) || MODULE_LOAD_FAILURE.test(msg))
73
- return error;
74
- return new Error(`Failed to load the WASM engine binary (ifc-lite_bg.wasm) in ${label}: ${msg}`, { cause: error });
75
- }
76
- const defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
77
- /**
78
- * Run `init` once; on a transient-looking failure, wait and retry exactly once.
79
- * Non-transient failures propagate without a retry. The second failure (if any)
80
- * propagates to the caller — attributed to the engine binary when the browser's
81
- * own wording identifies nothing (see {@link attributeEngineLoadFailure}).
82
- *
83
- * @param init Thunk that performs the actual `init(...)` call (so callers can
84
- * bind their own wasm URL / arguments).
7
+ * The real implementation lives in `@ifc-lite/wasm-lifecycle` so
8
+ * `@ifc-lite/geometry` and `@ifc-lite/parser` share exactly one copy of the
9
+ * transient-vs-fatal WASM load-failure logic instead of maintaining two
10
+ * independently-editable "twin" files.
85
11
  */
86
- export async function initWasmWithRetry(init, options = {}) {
87
- const { retryDelayMs = 300, sleep = defaultSleep, warn = console.warn, label = 'wasm' } = options;
88
- try {
89
- await init();
90
- return;
91
- }
92
- catch (err) {
93
- const msg = err instanceof Error ? err.message : String(err);
94
- if (!isTransientWasmLoadError(msg))
95
- throw err;
96
- warn(`[${label}] WASM engine load failed (${msg}); retrying once`);
97
- await sleep(retryDelayMs);
98
- try {
99
- await init();
100
- }
101
- catch (retryErr) {
102
- throw attributeEngineLoadFailure(retryErr, label);
103
- }
104
- }
105
- }
12
+ export { initWasmWithRetry, isTransientWasmLoadError, } from '@ifc-lite/wasm-lifecycle';
106
13
  //# sourceMappingURL=wasm-init-retry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wasm-init-retry.js","sourceRoot":"","sources":["../src/wasm-init-retry.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAe;IACtD,6EAA6E;IAC7E,kCAAkC;IAClC,IAAI,8EAA8E,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACjG,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,wEAAwE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAChG,CAAC;AAED;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,mBAAmB,GAAG,4CAA4C,CAAC;AAEzE;;;;;;;;;;;;;;GAcG;AACH,SAAS,0BAA0B,CAAC,KAAc,EAAE,KAAa;IAC/D,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC;IAC1B,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACjD,IAAI,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAC9E,OAAO,IAAI,KAAK,CACd,+DAA+D,KAAK,KAAK,GAAG,EAAE,EAC9E,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;AACJ,CAAC;AAaD,MAAM,YAAY,GAAG,CAAC,EAAU,EAAiB,EAAE,CACjD,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAA4B,EAC5B,UAAgC,EAAE;IAElC,MAAM,EAAE,YAAY,GAAG,GAAG,EAAE,KAAK,GAAG,YAAY,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,KAAK,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC;IAClG,IAAI,CAAC;QACH,MAAM,IAAI,EAAE,CAAC;QACb,OAAO;IACT,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7D,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC;YAAE,MAAM,GAAG,CAAC;QAC9C,IAAI,CAAC,IAAI,KAAK,8BAA8B,GAAG,kBAAkB,CAAC,CAAC;QACnE,MAAM,KAAK,CAAC,YAAY,CAAC,CAAC;QAC1B,IAAI,CAAC;YACH,MAAM,IAAI,EAAE,CAAC;QACf,CAAC;QAAC,OAAO,QAAQ,EAAE,CAAC;YAClB,MAAM,0BAA0B,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"wasm-init-retry.js","sourceRoot":"","sources":["../src/wasm-init-retry.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;GAOG;AACH,OAAO,EACL,iBAAiB,EACjB,wBAAwB,GAEzB,MAAM,0BAA0B,CAAC"}
@@ -1,67 +1,11 @@
1
1
  /**
2
- * Forward a worker realm's wasm panic-location stash to the main thread
3
- * (#2527 follow-up).
2
+ * Re-export of the shared worker-to-main-thread wasm panic-location forwarder
3
+ * (issue #4247).
4
4
  *
5
- * The Rust panic hook (`rust/wasm-bindings/src/utils.rs`) stashes
6
- * `{ location, at }` on whichever realm's JS global it runs in — `self` in a
7
- * worker, `window` on the main thread. #2527 taught the main thread to read
8
- * its OWN global's stash and attach it to a trap's exception event
9
- * (`apps/viewer/src/lib/analytics-scrub.ts`'s `attachWasmPanicLocation`), but
10
- * a worker-realm trap leaves that stash stranded in the worker's global,
11
- * which the main thread can never see across the realm boundary.
12
- *
13
- * `takeWasmPanicStash` reads + consumes the stash worker-side so it can ride
14
- * the worker's own `{type:'error'}` message; `restashWasmPanicLocation`
15
- * re-plants it on the main thread's global so the EXISTING #2527 gate (same
16
- * key, same TTL, same consume-once semantics) picks it up unmodified.
17
- *
18
- * Location only, never the panic's message — the message can embed
19
- * model-derived text (see `utils.rs`'s privacy contract); the location alone
20
- * travels on the error message and through this module.
21
- *
22
- * NOTE: this file is intentionally byte-identical to
23
- * `packages/geometry/src/wasm-panic-forward.ts` — both `@ifc-lite/geometry`
24
- * and `@ifc-lite/parser` need the exact same realm-forwarding contract, and
25
- * neither package depends on the other (nor is `@ifc-lite/wasm`, the one
26
- * package both DO depend on, a safe home: it ships only the wasm-pack build
27
- * output, with no TypeScript build step of its own, and `test`/`typecheck`
28
- * for either consumer already runs its build via turbo's `^build` — adding a
29
- * hand-written TS module there would make every geometry/parser test run
30
- * gate on a full Rust→wasm rebuild). Keep any change to one copy in lockstep
31
- * with the other; `wasm-panic-forward.test.ts` is duplicated the same way.
32
- */
33
- /** Kept in lockstep with `PANIC_STASH_KEY` in `rust/wasm-bindings/src/utils.rs`,
34
- * `WASM_PANIC_STASH_KEY` in `apps/viewer/src/lib/analytics-scrub.ts`, and this
35
- * module's twin at `packages/geometry/src/wasm-panic-forward.ts`. */
36
- export declare const WASM_PANIC_STASH_KEY = "__ifclite_wasm_panic";
37
- export interface WasmPanicStash {
38
- location: string;
39
- at: number;
40
- }
41
- /**
42
- * Worker-side: read and CONSUME this realm's panic stash so it can be
43
- * forwarded on the worker's own error message. Consume-once regardless of
44
- * shape validity — an unconsumed malformed stash must not linger to
45
- * mislabel a later trap, mirroring the main-thread gate's own rule.
46
- */
47
- export declare function takeWasmPanicStash(realm: object): WasmPanicStash | undefined;
48
- /**
49
- * Main-side: re-plant a worker-forwarded stash on this realm's global so the
50
- * existing #2527 `attachWasmPanicLocation` gate consumes it unmodified.
51
- *
52
- * Gated on `errorMessage` looking like a wasm trap: the worker forwards
53
- * `wasmPanicLocation`/`wasmPanicAt` on ANY `{type:'error'}` message (a stale
54
- * stash from an earlier suppressed panic can ride out on an ordinary,
55
- * non-trap worker error), and re-planting unconditionally would let that
56
- * stale location sit on `globalThis` until an unrelated trap-shaped
57
- * exception consumed it — mislabeling that trap. Only a message that itself
58
- * looks like a wasm trap is allowed to re-plant.
59
- *
60
- * Never clobbers an existing, unconsumed stash — a genuine main-thread trap
61
- * that hasn't been captured yet must win over a worker trap that merely
62
- * arrived first (the older-looking stash, if stale, is simply dropped later
63
- * by the TTL check at attach time; this function never overwrites either
64
- * way).
5
+ * The real implementation lives in `@ifc-lite/wasm-lifecycle` so
6
+ * `@ifc-lite/geometry` and `@ifc-lite/parser` share exactly one copy of the
7
+ * #2527 realm-forwarding contract instead of maintaining two
8
+ * independently-editable "twin" files.
65
9
  */
66
- export declare function restashWasmPanicLocation(realm: object, location: unknown, at: unknown, errorMessage: string): void;
10
+ export { WASM_PANIC_STASH_KEY, takeWasmPanicStash, restashWasmPanicLocation, type WasmPanicStash, } from '@ifc-lite/wasm-lifecycle';
67
11
  //# sourceMappingURL=wasm-panic-forward.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wasm-panic-forward.d.ts","sourceRoot":"","sources":["../src/wasm-panic-forward.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH;;sEAEsE;AACtE,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAgB3D,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;CACZ;AAeD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAK5E;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,OAAO,EACjB,EAAE,EAAE,OAAO,EACX,YAAY,EAAE,MAAM,GACnB,IAAI,CAON"}
1
+ {"version":3,"file":"wasm-panic-forward.d.ts","sourceRoot":"","sources":["../src/wasm-panic-forward.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,KAAK,cAAc,GACpB,MAAM,0BAA0B,CAAC"}
@@ -2,106 +2,13 @@
2
2
  * License, v. 2.0. If a copy of the MPL was not distributed with this
3
3
  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
4
  /**
5
- * Forward a worker realm's wasm panic-location stash to the main thread
6
- * (#2527 follow-up).
5
+ * Re-export of the shared worker-to-main-thread wasm panic-location forwarder
6
+ * (issue #4247).
7
7
  *
8
- * The Rust panic hook (`rust/wasm-bindings/src/utils.rs`) stashes
9
- * `{ location, at }` on whichever realm's JS global it runs in — `self` in a
10
- * worker, `window` on the main thread. #2527 taught the main thread to read
11
- * its OWN global's stash and attach it to a trap's exception event
12
- * (`apps/viewer/src/lib/analytics-scrub.ts`'s `attachWasmPanicLocation`), but
13
- * a worker-realm trap leaves that stash stranded in the worker's global,
14
- * which the main thread can never see across the realm boundary.
15
- *
16
- * `takeWasmPanicStash` reads + consumes the stash worker-side so it can ride
17
- * the worker's own `{type:'error'}` message; `restashWasmPanicLocation`
18
- * re-plants it on the main thread's global so the EXISTING #2527 gate (same
19
- * key, same TTL, same consume-once semantics) picks it up unmodified.
20
- *
21
- * Location only, never the panic's message — the message can embed
22
- * model-derived text (see `utils.rs`'s privacy contract); the location alone
23
- * travels on the error message and through this module.
24
- *
25
- * NOTE: this file is intentionally byte-identical to
26
- * `packages/geometry/src/wasm-panic-forward.ts` — both `@ifc-lite/geometry`
27
- * and `@ifc-lite/parser` need the exact same realm-forwarding contract, and
28
- * neither package depends on the other (nor is `@ifc-lite/wasm`, the one
29
- * package both DO depend on, a safe home: it ships only the wasm-pack build
30
- * output, with no TypeScript build step of its own, and `test`/`typecheck`
31
- * for either consumer already runs its build via turbo's `^build` — adding a
32
- * hand-written TS module there would make every geometry/parser test run
33
- * gate on a full Rust→wasm rebuild). Keep any change to one copy in lockstep
34
- * with the other; `wasm-panic-forward.test.ts` is duplicated the same way.
35
- */
36
- /** Kept in lockstep with `PANIC_STASH_KEY` in `rust/wasm-bindings/src/utils.rs`,
37
- * `WASM_PANIC_STASH_KEY` in `apps/viewer/src/lib/analytics-scrub.ts`, and this
38
- * module's twin at `packages/geometry/src/wasm-panic-forward.ts`. */
39
- export const WASM_PANIC_STASH_KEY = '__ifclite_wasm_panic';
40
- /**
41
- * Trap-shape text match, kept in lockstep with `WASM_TRAP_TEXT` in
42
- * `apps/viewer/src/lib/analytics-scrub.ts` and this module's twin at
43
- * `packages/geometry/src/wasm-panic-forward.ts`. Deliberately excludes bare
44
- * "unreachable" inside network-failure phrasing ("network is unreachable",
45
- * "host unreachable") — those are not wasm traps.
46
- */
47
- const WASM_TRAP_TEXT = /(?<!network is |host |destination |address )\bunreachable\b|\bRuntimeError\b|memory access out of bounds|index out of bounds|indirect call to null|integer (?:overflow|divide by zero)|call stack exhausted/i;
48
- function looksLikeWasmTrap(message) {
49
- return WASM_TRAP_TEXT.test(message);
50
- }
51
- /** Validate + narrow an unknown stash value read off a realm global. */
52
- function readStashShape(value) {
53
- if (typeof value !== 'object' || value === null)
54
- return undefined;
55
- const { location, at } = value;
56
- if (typeof location !== 'string' || location === '')
57
- return undefined;
58
- // Reject non-finite (`NaN`/`Infinity`) and future timestamps — both pass
59
- // the analytics TTL gate's `Date.now() - at <= TTL` check trivially
60
- // (`Infinity` makes the delta `-Infinity`; a future `at` makes it
61
- // negative), which would let a malformed stash label a later trap.
62
- if (typeof at !== 'number' || !Number.isFinite(at) || at > Date.now())
63
- return undefined;
64
- return { location, at };
65
- }
66
- /**
67
- * Worker-side: read and CONSUME this realm's panic stash so it can be
68
- * forwarded on the worker's own error message. Consume-once regardless of
69
- * shape validity — an unconsumed malformed stash must not linger to
70
- * mislabel a later trap, mirroring the main-thread gate's own rule.
71
- */
72
- export function takeWasmPanicStash(realm) {
73
- const g = realm;
74
- const raw = g[WASM_PANIC_STASH_KEY];
75
- delete g[WASM_PANIC_STASH_KEY];
76
- return readStashShape(raw);
77
- }
78
- /**
79
- * Main-side: re-plant a worker-forwarded stash on this realm's global so the
80
- * existing #2527 `attachWasmPanicLocation` gate consumes it unmodified.
81
- *
82
- * Gated on `errorMessage` looking like a wasm trap: the worker forwards
83
- * `wasmPanicLocation`/`wasmPanicAt` on ANY `{type:'error'}` message (a stale
84
- * stash from an earlier suppressed panic can ride out on an ordinary,
85
- * non-trap worker error), and re-planting unconditionally would let that
86
- * stale location sit on `globalThis` until an unrelated trap-shaped
87
- * exception consumed it — mislabeling that trap. Only a message that itself
88
- * looks like a wasm trap is allowed to re-plant.
89
- *
90
- * Never clobbers an existing, unconsumed stash — a genuine main-thread trap
91
- * that hasn't been captured yet must win over a worker trap that merely
92
- * arrived first (the older-looking stash, if stale, is simply dropped later
93
- * by the TTL check at attach time; this function never overwrites either
94
- * way).
8
+ * The real implementation lives in `@ifc-lite/wasm-lifecycle` so
9
+ * `@ifc-lite/geometry` and `@ifc-lite/parser` share exactly one copy of the
10
+ * #2527 realm-forwarding contract instead of maintaining two
11
+ * independently-editable "twin" files.
95
12
  */
96
- export function restashWasmPanicLocation(realm, location, at, errorMessage) {
97
- const stash = readStashShape({ location, at });
98
- if (!stash)
99
- return;
100
- if (!looksLikeWasmTrap(errorMessage))
101
- return;
102
- const g = realm;
103
- if (g[WASM_PANIC_STASH_KEY] !== undefined)
104
- return;
105
- g[WASM_PANIC_STASH_KEY] = stash;
106
- }
13
+ export { WASM_PANIC_STASH_KEY, takeWasmPanicStash, restashWasmPanicLocation, } from '@ifc-lite/wasm-lifecycle';
107
14
  //# sourceMappingURL=wasm-panic-forward.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wasm-panic-forward.js","sourceRoot":"","sources":["../src/wasm-panic-forward.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH;;sEAEsE;AACtE,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAE3D;;;;;;GAMG;AACH,MAAM,cAAc,GAClB,8MAA8M,CAAC;AAEjN,SAAS,iBAAiB,CAAC,OAAe;IACxC,OAAO,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC;AAOD,wEAAwE;AACxE,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IAClE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,KAA6C,CAAC;IACvE,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,EAAE;QAAE,OAAO,SAAS,CAAC;IACtE,yEAAyE;IACzE,oEAAoE;IACpE,kEAAkE;IAClE,mEAAmE;IACnE,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE;QAAE,OAAO,SAAS,CAAC;IACxF,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,MAAM,CAAC,GAAG,KAAgC,CAAC;IAC3C,MAAM,GAAG,GAAG,CAAC,CAAC,oBAAoB,CAAC,CAAC;IACpC,OAAO,CAAC,CAAC,oBAAoB,CAAC,CAAC;IAC/B,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,wBAAwB,CACtC,KAAa,EACb,QAAiB,EACjB,EAAW,EACX,YAAoB;IAEpB,MAAM,KAAK,GAAG,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;IAC/C,IAAI,CAAC,KAAK;QAAE,OAAO;IACnB,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC;QAAE,OAAO;IAC7C,MAAM,CAAC,GAAG,KAAgC,CAAC;IAC3C,IAAI,CAAC,CAAC,oBAAoB,CAAC,KAAK,SAAS;QAAE,OAAO;IAClD,CAAC,CAAC,oBAAoB,CAAC,GAAG,KAAK,CAAC;AAClC,CAAC"}
1
+ {"version":3,"file":"wasm-panic-forward.js","sourceRoot":"","sources":["../src/wasm-panic-forward.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;GAQG;AACH,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,GAEzB,MAAM,0BAA0B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ifc-lite/parser",
3
- "version": "5.2.0",
3
+ "version": "6.2.1",
4
4
  "description": "IFC/STEP parser for IFC-Lite",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -19,10 +19,11 @@
19
19
  "dependencies": {
20
20
  "fflate": "^0.8.3",
21
21
  "jszip": "^3.10.0",
22
- "@ifc-lite/data": "^4.0.0",
22
+ "@ifc-lite/data": "^4.2.1",
23
23
  "@ifc-lite/encoding": "^2.2.0",
24
- "@ifc-lite/ifcx": "^4.0.0",
25
- "@ifc-lite/wasm": "^6.4.0"
24
+ "@ifc-lite/wasm": "^8.0.1",
25
+ "@ifc-lite/wasm-lifecycle": "^0.2.0",
26
+ "@ifc-lite/ifcx": "^4.1.1"
26
27
  },
27
28
  "devDependencies": {
28
29
  "typescript": "^6.0.3",