@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.
- package/dist/columnar-entity-preparation.d.ts +3 -0
- package/dist/columnar-entity-preparation.d.ts.map +1 -1
- package/dist/columnar-entity-preparation.js +101 -11
- package/dist/columnar-entity-preparation.js.map +1 -1
- package/dist/columnar-parser-indexes.d.ts +17 -1
- package/dist/columnar-parser-indexes.d.ts.map +1 -1
- package/dist/columnar-parser-indexes.js +31 -21
- package/dist/columnar-parser-indexes.js.map +1 -1
- package/dist/columnar-parser.d.ts +10 -1
- package/dist/columnar-parser.d.ts.map +1 -1
- package/dist/columnar-parser.js +14 -2
- package/dist/columnar-parser.js.map +1 -1
- package/dist/cost-extractor.d.ts +10 -0
- package/dist/cost-extractor.d.ts.map +1 -0
- package/dist/cost-extractor.js +369 -0
- package/dist/cost-extractor.js.map +1 -0
- package/dist/cost-schedule-2x3.d.ts +31 -0
- package/dist/cost-schedule-2x3.d.ts.map +1 -0
- package/dist/cost-schedule-2x3.js +75 -0
- package/dist/cost-schedule-2x3.js.map +1 -0
- package/dist/cost-types.d.ts +105 -0
- package/dist/cost-types.d.ts.map +1 -0
- package/dist/cost-types.js +5 -0
- package/dist/cost-types.js.map +1 -0
- package/dist/data-store-transport.d.ts +1 -0
- package/dist/data-store-transport.d.ts.map +1 -1
- package/dist/data-store-transport.js +5 -29
- package/dist/data-store-transport.js.map +1 -1
- package/dist/drop-census.d.ts +136 -0
- package/dist/drop-census.d.ts.map +1 -0
- package/dist/drop-census.js +53 -0
- package/dist/drop-census.js.map +1 -0
- package/dist/entity-scanner.d.ts.map +1 -1
- package/dist/entity-scanner.js +10 -5
- package/dist/entity-scanner.js.map +1 -1
- package/dist/generated/ifc2x3/schema-registry.d.ts +50 -0
- package/dist/generated/ifc2x3/schema-registry.d.ts.map +1 -0
- package/dist/generated/ifc2x3/schema-registry.js +50052 -0
- package/dist/generated/ifc2x3/schema-registry.js.map +1 -0
- package/dist/generated/ifc4x3/schema-registry.d.ts +50 -0
- package/dist/generated/ifc4x3/schema-registry.d.ts.map +1 -0
- package/dist/generated/ifc4x3/schema-registry.js +71299 -0
- package/dist/generated/ifc4x3/schema-registry.js.map +1 -0
- package/dist/generated/schema-registry-by-version.d.ts +61 -0
- package/dist/generated/schema-registry-by-version.d.ts.map +1 -0
- package/dist/generated/schema-registry-by-version.js +86 -0
- package/dist/generated/schema-registry-by-version.js.map +1 -0
- package/dist/georef-extractor.js +5 -5
- package/dist/georef-extractor.js.map +1 -1
- package/dist/group-assignment-factor.d.ts +13 -0
- package/dist/group-assignment-factor.d.ts.map +1 -0
- package/dist/group-assignment-factor.js +30 -0
- package/dist/group-assignment-factor.js.map +1 -0
- package/dist/ifczip.d.ts +7 -1
- package/dist/ifczip.d.ts.map +1 -1
- package/dist/ifczip.js +80 -14
- package/dist/ifczip.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/on-demand-extractors.d.ts +1 -0
- package/dist/on-demand-extractors.d.ts.map +1 -1
- package/dist/on-demand-extractors.js +2 -1
- package/dist/on-demand-extractors.js.map +1 -1
- package/dist/property-value-parser.d.ts +10 -0
- package/dist/property-value-parser.d.ts.map +1 -1
- package/dist/property-value-parser.js +40 -1
- package/dist/property-value-parser.js.map +1 -1
- package/dist/scan-entities-balanced.d.ts.map +1 -1
- package/dist/scan-entities-balanced.js +11 -6
- package/dist/scan-entities-balanced.js.map +1 -1
- package/dist/scan-worker-lexing.d.ts +14 -0
- package/dist/scan-worker-lexing.d.ts.map +1 -0
- package/dist/scan-worker-lexing.js +106 -0
- package/dist/scan-worker-lexing.js.map +1 -0
- package/dist/scan-worker-source.d.ts +1 -1
- package/dist/scan-worker-source.d.ts.map +1 -1
- package/dist/scan-worker-source.js +64 -59
- package/dist/scan-worker-source.js.map +1 -1
- package/dist/schedule-extractor.d.ts +2 -80
- package/dist/schedule-extractor.d.ts.map +1 -1
- package/dist/schedule-extractor.js +100 -225
- package/dist/schedule-extractor.js.map +1 -1
- package/dist/schedule-serializer-builders.d.ts +28 -0
- package/dist/schedule-serializer-builders.d.ts.map +1 -0
- package/dist/schedule-serializer-builders.js +163 -0
- package/dist/schedule-serializer-builders.js.map +1 -0
- package/dist/schedule-serializer.d.ts +6 -0
- package/dist/schedule-serializer.d.ts.map +1 -1
- package/dist/schedule-serializer.js +26 -165
- package/dist/schedule-serializer.js.map +1 -1
- package/dist/schedule-types.d.ts +211 -0
- package/dist/schedule-types.d.ts.map +1 -0
- package/dist/schedule-types.js +221 -0
- package/dist/schedule-types.js.map +1 -0
- package/dist/spatial-hierarchy-ambiguity.d.ts +39 -0
- package/dist/spatial-hierarchy-ambiguity.d.ts.map +1 -0
- package/dist/spatial-hierarchy-ambiguity.js +25 -0
- package/dist/spatial-hierarchy-ambiguity.js.map +1 -0
- package/dist/spatial-hierarchy-attributes.d.ts +54 -0
- package/dist/spatial-hierarchy-attributes.d.ts.map +1 -0
- package/dist/spatial-hierarchy-attributes.js +145 -0
- package/dist/spatial-hierarchy-attributes.js.map +1 -0
- package/dist/spatial-hierarchy-builder.d.ts +0 -30
- package/dist/spatial-hierarchy-builder.d.ts.map +1 -1
- package/dist/spatial-hierarchy-builder.js +45 -167
- package/dist/spatial-hierarchy-builder.js.map +1 -1
- package/dist/spatial-hierarchy-canonical-parent.d.ts +52 -2
- package/dist/spatial-hierarchy-canonical-parent.d.ts.map +1 -1
- package/dist/spatial-hierarchy-canonical-parent.js +153 -4
- package/dist/spatial-hierarchy-canonical-parent.js.map +1 -1
- package/dist/step-lexing.d.ts +1 -1
- package/dist/step-lexing.d.ts.map +1 -1
- package/dist/step-lexing.js +1 -56
- package/dist/step-lexing.js.map +1 -1
- package/dist/step-record-boundary.d.ts +28 -0
- package/dist/step-record-boundary.d.ts.map +1 -0
- package/dist/step-record-boundary.js +133 -0
- package/dist/step-record-boundary.js.map +1 -0
- package/dist/step-record-boundary.vectors.d.ts +102 -0
- package/dist/step-record-boundary.vectors.d.ts.map +1 -0
- package/dist/step-record-boundary.vectors.js +131 -0
- package/dist/step-record-boundary.vectors.js.map +1 -0
- package/dist/structural-extractor.d.ts +9 -0
- package/dist/structural-extractor.d.ts.map +1 -0
- package/dist/structural-extractor.js +310 -0
- package/dist/structural-extractor.js.map +1 -0
- package/dist/structural-load-extractor.d.ts +147 -0
- package/dist/structural-load-extractor.d.ts.map +1 -0
- package/dist/structural-load-extractor.js +178 -0
- package/dist/structural-load-extractor.js.map +1 -0
- package/dist/structural-step-values.d.ts +51 -0
- package/dist/structural-step-values.d.ts.map +1 -0
- package/dist/structural-step-values.js +109 -0
- package/dist/structural-step-values.js.map +1 -0
- package/dist/structural-types.d.ts +145 -0
- package/dist/structural-types.d.ts.map +1 -0
- package/dist/structural-types.js +5 -0
- package/dist/structural-types.js.map +1 -0
- package/dist/tokenizer.d.ts +11 -5
- package/dist/tokenizer.d.ts.map +1 -1
- package/dist/tokenizer.js +78 -21
- package/dist/tokenizer.js.map +1 -1
- package/dist/wasm-init-retry.d.ts +6 -42
- package/dist/wasm-init-retry.d.ts.map +1 -1
- package/dist/wasm-init-retry.js +6 -99
- package/dist/wasm-init-retry.js.map +1 -1
- package/dist/wasm-panic-forward.d.ts +7 -63
- package/dist/wasm-panic-forward.d.ts.map +1 -1
- package/dist/wasm-panic-forward.js +7 -100
- package/dist/wasm-panic-forward.js.map +1 -1
- 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
|
|
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"}
|
package/dist/wasm-init-retry.js
CHANGED
|
@@ -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
|
-
*
|
|
5
|
+
* Re-export of the shared WASM load-retry classification (issue #4247).
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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
|
|
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
|
|
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
|
-
*
|
|
3
|
-
* (#
|
|
2
|
+
* Re-export of the shared worker-to-main-thread wasm panic-location forwarder
|
|
3
|
+
* (issue #4247).
|
|
4
4
|
*
|
|
5
|
-
* The
|
|
6
|
-
* `
|
|
7
|
-
*
|
|
8
|
-
*
|
|
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
|
|
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
|
|
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
|
-
*
|
|
6
|
-
* (#
|
|
5
|
+
* Re-export of the shared worker-to-main-thread wasm panic-location forwarder
|
|
6
|
+
* (issue #4247).
|
|
7
7
|
*
|
|
8
|
-
* The
|
|
9
|
-
* `
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
|
|
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
|
|
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": "
|
|
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.
|
|
22
|
+
"@ifc-lite/data": "^4.2.1",
|
|
23
23
|
"@ifc-lite/encoding": "^2.2.0",
|
|
24
|
-
"@ifc-lite/
|
|
25
|
-
"@ifc-lite/wasm": "^
|
|
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",
|