@ifc-lite/parser 5.0.0 → 5.2.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.
Files changed (82) hide show
  1. package/dist/classification-resolver.d.ts +28 -2
  2. package/dist/classification-resolver.d.ts.map +1 -1
  3. package/dist/classification-resolver.js +49 -6
  4. package/dist/classification-resolver.js.map +1 -1
  5. package/dist/columnar-entity-preparation.d.ts +22 -0
  6. package/dist/columnar-entity-preparation.d.ts.map +1 -0
  7. package/dist/columnar-entity-preparation.js +192 -0
  8. package/dist/columnar-entity-preparation.js.map +1 -0
  9. package/dist/columnar-parser-root-attributes.d.ts +66 -0
  10. package/dist/columnar-parser-root-attributes.d.ts.map +1 -0
  11. package/dist/columnar-parser-root-attributes.js +245 -0
  12. package/dist/columnar-parser-root-attributes.js.map +1 -0
  13. package/dist/columnar-parser.d.ts +17 -63
  14. package/dist/columnar-parser.d.ts.map +1 -1
  15. package/dist/columnar-parser.js +371 -779
  16. package/dist/columnar-parser.js.map +1 -1
  17. package/dist/compact-entity-index-columns.d.ts +17 -0
  18. package/dist/compact-entity-index-columns.d.ts.map +1 -0
  19. package/dist/compact-entity-index-columns.js +15 -0
  20. package/dist/compact-entity-index-columns.js.map +1 -0
  21. package/dist/compact-entity-index-transport.d.ts +2 -12
  22. package/dist/compact-entity-index-transport.d.ts.map +1 -1
  23. package/dist/compact-entity-index-transport.js +1 -11
  24. package/dist/compact-entity-index-transport.js.map +1 -1
  25. package/dist/compact-entity-index.d.ts +7 -0
  26. package/dist/compact-entity-index.d.ts.map +1 -1
  27. package/dist/compact-entity-index.js +20 -32
  28. package/dist/compact-entity-index.js.map +1 -1
  29. package/dist/data-store-transport.d.ts +9 -16
  30. package/dist/data-store-transport.d.ts.map +1 -1
  31. package/dist/data-store-transport.js +14 -20
  32. package/dist/data-store-transport.js.map +1 -1
  33. package/dist/entity-refs-from-index.d.ts +10 -0
  34. package/dist/entity-refs-from-index.d.ts.map +1 -1
  35. package/dist/entity-refs-from-index.js +64 -49
  36. package/dist/entity-refs-from-index.js.map +1 -1
  37. package/dist/entity-scanner.d.ts +5 -0
  38. package/dist/entity-scanner.d.ts.map +1 -1
  39. package/dist/entity-scanner.js +20 -7
  40. package/dist/entity-scanner.js.map +1 -1
  41. package/dist/entity-type-byte-interner.d.ts +12 -0
  42. package/dist/entity-type-byte-interner.d.ts.map +1 -0
  43. package/dist/entity-type-byte-interner.js +66 -0
  44. package/dist/entity-type-byte-interner.js.map +1 -0
  45. package/dist/index.d.ts +4 -5
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +4 -5
  48. package/dist/index.js.map +1 -1
  49. package/dist/on-demand-extractors.d.ts +1 -1
  50. package/dist/on-demand-extractors.d.ts.map +1 -1
  51. package/dist/on-demand-georeferencing.d.ts +3 -3
  52. package/dist/on-demand-georeferencing.js +27 -4
  53. package/dist/on-demand-georeferencing.js.map +1 -1
  54. package/dist/parser.worker.d.ts +6 -3
  55. package/dist/parser.worker.d.ts.map +1 -1
  56. package/dist/parser.worker.js +36 -13
  57. package/dist/parser.worker.js.map +1 -1
  58. package/dist/prepass-source-fingerprint.d.ts +3 -0
  59. package/dist/prepass-source-fingerprint.d.ts.map +1 -0
  60. package/dist/prepass-source-fingerprint.js +13 -0
  61. package/dist/prepass-source-fingerprint.js.map +1 -0
  62. package/dist/select-entity-columns.d.ts +7 -0
  63. package/dist/select-entity-columns.d.ts.map +1 -0
  64. package/dist/select-entity-columns.js +43 -0
  65. package/dist/select-entity-columns.js.map +1 -0
  66. package/dist/spatial-hierarchy-builder.d.ts +6 -8
  67. package/dist/spatial-hierarchy-builder.d.ts.map +1 -1
  68. package/dist/spatial-hierarchy-builder.js +4 -0
  69. package/dist/spatial-hierarchy-builder.js.map +1 -1
  70. package/dist/spatial-hierarchy-canonical-parent.d.ts +36 -0
  71. package/dist/spatial-hierarchy-canonical-parent.d.ts.map +1 -0
  72. package/dist/spatial-hierarchy-canonical-parent.js +63 -0
  73. package/dist/spatial-hierarchy-canonical-parent.js.map +1 -0
  74. package/dist/worker-index-publication.d.ts +43 -0
  75. package/dist/worker-index-publication.d.ts.map +1 -0
  76. package/dist/worker-index-publication.js +129 -0
  77. package/dist/worker-index-publication.js.map +1 -0
  78. package/dist/worker-parser.d.ts +5 -2
  79. package/dist/worker-parser.d.ts.map +1 -1
  80. package/dist/worker-parser.js +30 -12
  81. package/dist/worker-parser.js.map +1 -1
  82. package/package.json +2 -2
@@ -4,591 +4,412 @@
4
4
  import { SpatialHierarchyBuilder } from './spatial-hierarchy-builder.js';
5
5
  import { EntityExtractor } from './entity-extractor.js';
6
6
  import { extractLengthUnitScale } from './unit-extractor.js';
7
- import { getAttributeNames, getAttributeNamesAcrossSchemas, getInheritanceChain } from './ifc-schema.js';
8
7
  import { parsePropertyValueWithComplex } from './on-demand-extractors.js';
9
8
  import { readQuantitySet } from './quantity-collect.js';
10
- import { buildCompactEntityIndexAsync } from './compact-entity-index.js';
9
+ import { prepareColumnarEntities } from './columnar-entity-preparation.js';
11
10
  import { yieldToEventLoop } from './yield-to-event-loop.js';
12
11
  import { StringTable, EntityTableBuilder, PropertyTableBuilder, QuantityTableBuilder, RelationshipGraphBuilder, RelationshipType, } from '@ifc-lite/data';
13
12
  import { BufferEntitySource } from './entity-source.js';
14
13
  import { batchExtractGlobalIdAndName } from './columnar-parser-attributes.js';
15
- import { GEOMETRY_TYPES, REL_TYPE_MAP, SPATIAL_TYPES, HIERARCHY_REL_TYPES, PROPERTY_REL_TYPES, ASSOCIATION_REL_TYPES, SKIP_DISPLAY_ATTRS, PROPERTY_ENTITY_TYPES, PROPERTY_CONTAINER_TYPES, isIfcTypeLikeEntity, } from './columnar-parser-indexes.js';
14
+ import { REL_TYPE_MAP, } from './columnar-parser-indexes.js';
16
15
  import { extractRelFast, extractPropertyRelFast } from './columnar-parser-relationships.js';
17
16
  import { detectSchemaVersion, parseSourceHeader } from './source-header.js';
18
17
  import { contiguousSourceBytes } from './source-bytes.js';
18
+ import { getEntityRefFromStore, extractRootAttributesFromEntity, pickLongName } from './columnar-parser-root-attributes.js';
19
+ // Re-exported: part of the package's public on-demand-extraction surface
20
+ // (see packages/parser/src/index.ts).
21
+ export { extractEntityAttributesOnDemand, extractAllEntityAttributes, getRawNamedAttributes, extractRootAttributesFromEntity, } from './columnar-parser-root-attributes.js';
19
22
  /** Appends `ref` to `map.get(objId)`, skipping a repeat — these maps win over the deduped graph (#3760/#3782). */
20
23
  function addOnDemandRef(map, objId, ref) {
21
24
  const list = map.get(objId) ?? map.set(objId, []).get(objId);
22
25
  if (!list.includes(ref))
23
26
  list.push(ref);
24
27
  }
25
- export class ColumnarParser {
26
- /**
27
- * Parse IFC file into columnar data store
28
- *
29
- * Uses fast semicolon-based scanning with on-demand property extraction.
30
- * Properties are parsed lazily when accessed, not upfront.
31
- * This provides instant UI responsiveness even for very large files.
32
- */
33
- async parseLite(buffer, entityRefs, options = {}) {
34
- const startTime = performance.now();
35
- const uint8Buffer = new Uint8Array(buffer);
36
- const totalEntities = entityRefs.length;
37
- // Phase timing for performance telemetry
38
- let phaseStart = startTime;
39
- const emitDiagnostic = (message) => {
40
- options.onDiagnostic?.(message);
41
- };
42
- const logPhase = (name) => {
43
- const now = performance.now();
44
- const elapsed = Math.round(now - phaseStart);
45
- console.log(`[parseLite] ${name}: ${elapsed}ms`);
46
- emitDiagnostic(`${name}: ${elapsed}ms`);
47
- phaseStart = now;
48
- };
49
- options.onProgress?.({ phase: 'building', percent: 0 });
50
- // Capture verbatim HEADER fields so a round-trip export can reproduce
51
- // the source FILE_DESCRIPTION items + exact FILE_SCHEMA token instead
52
- // of regenerating a fresh ifc-lite header. Cheap: the scan stops at the
53
- // header's ENDSEC, so the DATA section is never touched.
54
- const sourceHeader = parseSourceHeader(uint8Buffer);
55
- // Schema version comes from that header's FILE_SCHEMA declaration, not
56
- // from a substring scan of the raw bytes — exporter product names in
57
- // FILE_NAME free text carry schema tokens too (issue #3278).
58
- const schemaVersion = detectSchemaVersion(uint8Buffer, sourceHeader);
59
- // Initialize builders (entity table capacity set after categorization below)
60
- const strings = new StringTable();
61
- const propertyTableBuilder = new PropertyTableBuilder(strings);
62
- const quantityTableBuilder = new QuantityTableBuilder(strings);
63
- const relationshipGraphBuilder = new RelationshipGraphBuilder();
64
- logPhase('init builders');
65
- // Single pass: build byType index AND categorize entities simultaneously.
66
- // Uses a type-name cache to avoid calling .toUpperCase() on 4.4M refs
67
- // (only ~776 unique type names in IFC4).
68
- const byType = new Map();
69
- const deferPropertyAtomIndex = options.deferPropertyAtomIndex === true;
70
- const typeUpperCache = new Map();
71
- const getTypeUpper = (type) => {
72
- let upper = typeUpperCache.get(type);
73
- if (upper === undefined) {
74
- upper = type.toUpperCase();
75
- typeUpperCache.set(type, upper);
76
- }
77
- return upper;
78
- };
79
- // Non-product helper entities that on-demand extraction / StepExporter
80
- // need addressable in `byId`. These are not IfcProduct subtypes so the
81
- // schema-driven IFCPRODUCT subtype check below cannot capture them.
82
- // Without them, findPreferredGeometricRepresentationContextId() and
83
- // findLengthUnitReference() fail because the entities are missing from
84
- // the compact entity index.
85
- const RELEVANT_NON_PRODUCT_HELPERS = new Set([
86
- 'IFCGEOMETRICREPRESENTATIONCONTEXT', 'IFCGEOMETRICREPRESENTATIONSUBCONTEXT',
87
- 'IFCUNITASSIGNMENT', 'IFCSIUNIT', 'IFCCONVERSIONBASEDUNIT',
88
- 'IFCDERIVEDUNIT', 'IFCDERIVEDUNITELEMENT', 'IFCMEASUREWITHUNIT',
89
- 'IFCDIMENSIONALEXPONENTS',
90
- 'IFCMAPCONVERSION', 'IFCPROJECTEDCRS',
91
- 'IFCMATERIALLAYER', 'IFCMATERIALLAYERSET', 'IFCMATERIALLAYERSETUSAGE',
92
- 'IFCMATERIALCONSTITUENTSET', 'IFCMATERIALCONSTITUENT',
93
- 'IFCMATERIALPROFILESET', 'IFCMATERIALPROFILE', 'IFCMATERIAL',
94
- 'IFCCLASSIFICATION', 'IFCCLASSIFICATIONREFERENCE',
95
- 'IFCDOCUMENTINFORMATION', 'IFCDOCUMENTREFERENCE',
96
- ]);
97
- // Schema-driven inclusion: every IfcProduct subtype belongs in the
98
- // EntityTable. The previous hardcoded enumeration of IFC4 building-
99
- // element leaves (IFCWALL, IFCSLAB, …) and IFC4x3 infrastructure
100
- // leaves (IFCREFERENT, IFCSIGNAL, IFCALIGNMENT, IFCPAVEMENT, …) drifted
101
- // with every schema bump — new entities silently became CAT_SKIP and
102
- // disappeared from the hierarchy panel. The generated schema registry
103
- // already knows the full inheritance chain, so use it.
104
- const RELEVANT_PRODUCT_ROOTS = new Set(['IFCPRODUCT']);
105
- // IfcGroup family (IfcZone, IfcSystem, IfcDistributionSystem,
106
- // IfcBuildingSystem, IfcDistributionCircuit, …). These are NOT
107
- // IfcProduct subtypes, so without an explicit branch they fall through
108
- // to CAT_SKIP and never enter the EntityTable — leaving their Name
109
- // unresolvable (`getName` → '') and making them invisible to
110
- // `getByType`. The Relationships card then shows "Group #<id>" and the
111
- // lens/lists can't surface them. Route them into their own bucket so we
112
- // can extract Name/LongName/ObjectType for the group label (#1075).
113
- const GROUP_ROOTS = new Set(['IFCGROUP']);
114
- // Category constants for the lookup cache
115
- const CAT_SKIP = 0, CAT_SPATIAL = 1, CAT_GEOMETRY = 2, CAT_HIERARCHY_REL = 3, CAT_PROPERTY_REL = 4, CAT_PROPERTY_ENTITY = 5, CAT_ASSOCIATION_REL = 6, CAT_TYPE_OBJECT = 7, CAT_RELEVANT = 8, CAT_GROUP = 9;
116
- /** Returns true if `upper` (already uppercased) is a subtype of any type in `set`. */
117
- function isSubtypeOfAny(upper, set) {
118
- const chain = getInheritanceChain(upper);
119
- return chain.some(ancestor => set.has(ancestor.toUpperCase()));
120
- }
121
- // Cache: type name → category (avoids 4.4M .toUpperCase() calls)
122
- const typeCategoryCache = new Map();
123
- function getCategory(type) {
124
- let cat = typeCategoryCache.get(type);
125
- if (cat !== undefined)
126
- return cat;
127
- const upper = getTypeUpper(type);
128
- if (SPATIAL_TYPES.has(upper) || isSubtypeOfAny(upper, SPATIAL_TYPES))
129
- cat = CAT_SPATIAL;
130
- else if (GEOMETRY_TYPES.has(upper) || isSubtypeOfAny(upper, GEOMETRY_TYPES))
131
- cat = CAT_GEOMETRY;
132
- else if (HIERARCHY_REL_TYPES.has(upper))
133
- cat = CAT_HIERARCHY_REL;
134
- else if (PROPERTY_REL_TYPES.has(upper))
135
- cat = CAT_PROPERTY_REL;
136
- else if (PROPERTY_ENTITY_TYPES.has(upper))
137
- cat = CAT_PROPERTY_ENTITY;
138
- else if (ASSOCIATION_REL_TYPES.has(upper))
139
- cat = CAT_ASSOCIATION_REL;
140
- else if (isIfcTypeLikeEntity(upper))
141
- cat = CAT_TYPE_OBJECT;
142
- else if (isSubtypeOfAny(upper, GROUP_ROOTS))
143
- cat = CAT_GROUP;
144
- else if (RELEVANT_NON_PRODUCT_HELPERS.has(upper)
145
- || isSubtypeOfAny(upper, RELEVANT_PRODUCT_ROOTS)
146
- || upper.startsWith('IFCREL'))
147
- cat = CAT_RELEVANT;
148
- else
149
- cat = CAT_SKIP;
150
- typeCategoryCache.set(type, cat);
151
- return cat;
152
- }
153
- // Time-based yielding: yield to the main thread every ~80ms so geometry
154
- // streaming callbacks can fire. This limits main-thread blocking to short
155
- // bursts that don't starve geometry, while adding minimal overhead (~15 yields
156
- // × ~1ms each ≈ 15ms total over the full parse).
157
- const YIELD_INTERVAL_MS = Math.max(16, options.yieldIntervalMs ?? 80);
158
- let lastYieldTime = performance.now();
159
- const yieldIfNeeded = async () => {
160
- const now = performance.now();
161
- if (now - lastYieldTime >= YIELD_INTERVAL_MS) {
162
- await yieldToEventLoop();
163
- lastYieldTime = performance.now();
164
- }
165
- };
166
- emitDiagnostic(`parseLite start: totalEntities=${totalEntities} yieldInterval=${YIELD_INTERVAL_MS}ms`);
167
- const spatialRefs = [];
168
- const geometryRefs = [];
169
- const relationshipRefs = [];
170
- const propertyRelRefs = [];
171
- const propertyContainerRefs = [];
172
- const propertyAtomRefs = [];
173
- const associationRelRefs = [];
174
- const typeObjectRefs = [];
175
- const otherRelevantRefs = [];
176
- const groupRefs = [];
177
- for (let i = 0; i < entityRefs.length; i++) {
178
- if ((i & 0x3FF) === 0)
179
- await yieldIfNeeded();
180
- const ref = entityRefs[i];
181
- // Categorize (cached — .toUpperCase() called once per unique type)
182
- const cat = getCategory(ref.type);
183
- const typeUpper = cat === CAT_PROPERTY_ENTITY ? getTypeUpper(ref.type) : '';
184
- // ALL entities must be indexed in byType for on-demand extraction
185
- // (e.g. IfcGeometricRepresentationContext, IfcSiUnit, IfcMaterialLayer).
186
- // Only property atoms are optionally deferred for huge-file lazy loading.
187
- const includeInPrimaryIndex = !deferPropertyAtomIndex || cat !== CAT_PROPERTY_ENTITY || PROPERTY_CONTAINER_TYPES.has(typeUpper);
188
- if (includeInPrimaryIndex) {
189
- // STEP convention is uppercase entity type names and every
190
- // downstream consumer (schedule-extractor, property readers,
191
- // test helpers) keys on uppercase. The tokenizer preserves
192
- // original case though, so if a STEP writer ever emits
193
- // mixed-case or lowercase types the index would miss on
194
- // canonical lookups. Normalise once here — `getTypeUpper`
195
- // is already cached by type name so the cost is ~0.
196
- const typeKey = getTypeUpper(ref.type);
197
- let typeList = byType.get(typeKey);
198
- if (!typeList) {
199
- typeList = [];
200
- byType.set(typeKey, typeList);
201
- }
202
- typeList.push(ref.expressId);
203
- }
204
- if (cat === CAT_SPATIAL)
205
- spatialRefs.push(ref);
206
- else if (cat === CAT_GEOMETRY)
207
- geometryRefs.push(ref);
208
- else if (cat === CAT_HIERARCHY_REL)
209
- relationshipRefs.push(ref);
210
- else if (cat === CAT_PROPERTY_REL)
211
- propertyRelRefs.push(ref);
212
- else if (cat === CAT_PROPERTY_ENTITY) {
213
- if (PROPERTY_CONTAINER_TYPES.has(typeUpper))
214
- propertyContainerRefs.push(ref);
215
- else
216
- propertyAtomRefs.push(ref);
217
- }
218
- else if (cat === CAT_ASSOCIATION_REL)
219
- associationRelRefs.push(ref);
220
- else if (cat === CAT_TYPE_OBJECT)
221
- typeObjectRefs.push(ref);
222
- else if (cat === CAT_GROUP)
223
- groupRefs.push(ref);
224
- else if (cat === CAT_RELEVANT)
225
- otherRelevantRefs.push(ref);
226
- }
227
- logPhase(`categorize ${totalEntities} → spatial:${spatialRefs.length} geom:${geometryRefs.length} rel:${relationshipRefs.length} propRel:${propertyRelRefs.length} propContainers:${propertyContainerRefs.length} propAtoms:${propertyAtomRefs.length} assocRel:${associationRelRefs.length} type:${typeObjectRefs.length} group:${groupRefs.length} other:${otherRelevantRefs.length}`);
228
- // Pre-scan association rels to discover relatingRef target IDs (e.g.
229
- // IfcClassificationReference, IfcMaterial, IfcDocumentReference). These
230
- // entities are typically categorised as CAT_SKIP and would otherwise be
231
- // missing from the compact index, making on-demand extraction fail.
232
- const associationTargetIds = new Set();
233
- for (const ref of associationRelRefs) {
234
- const result = extractPropertyRelFast(uint8Buffer, ref.byteOffset, ref.byteLength);
235
- if (result)
236
- for (const id of result.relatingDefs)
237
- associationTargetIds.add(id);
238
- }
239
- // Collect EntityRefs for association targets that aren't already categorised.
240
- // Single O(n) pass over entityRefs filtered to the (small) target ID set.
241
- const alreadyIndexedIds = new Set();
242
- for (const arr of [spatialRefs, geometryRefs, relationshipRefs, propertyRelRefs,
243
- propertyContainerRefs, associationRelRefs, typeObjectRefs, groupRefs, otherRelevantRefs,
244
- ...(deferPropertyAtomIndex ? [] : [propertyAtomRefs])]) {
245
- for (const r of arr)
246
- alreadyIndexedIds.add(r.expressId);
247
- }
248
- const extraAssocRefs = [];
249
- for (const ref of entityRefs) {
250
- if (associationTargetIds.has(ref.expressId) && !alreadyIndexedIds.has(ref.expressId)) {
251
- extraAssocRefs.push(ref);
252
- }
253
- }
254
- logPhase(`association target pre-scan: ${associationTargetIds.size} targets, ${extraAssocRefs.length} extra refs`);
255
- // ALL entity refs must be indexed in byId so that on-demand extraction
256
- // can look up any entity by expressId (e.g. IfcUnitAssignment,
257
- // IfcGeometricRepresentationContext, IfcSiUnit, IfcLocalPlacement, etc.).
258
- // Only property atoms are optionally deferred for huge-file lazy loading.
259
- const indexedRefs = deferPropertyAtomIndex
260
- ? entityRefs.filter(ref => {
261
- const cat = getCategory(ref.type);
262
- return cat !== CAT_PROPERTY_ENTITY || PROPERTY_CONTAINER_TYPES.has(getTypeUpper(ref.type));
263
- })
264
- : entityRefs;
265
- emitDiagnostic(`index input: indexedRefs=${indexedRefs.length} deferredPropertyAtoms=${deferPropertyAtomIndex ? propertyAtomRefs.length : 0} extraAssocTargets=${extraAssocRefs.length}`);
266
- // Build compact entity index from only the refs that survive lite parsing.
267
- // This avoids spending huge-file startup time indexing millions of skipped
268
- // representation/helper entities that the viewer never queries.
269
- const compactByIdIndex = await buildCompactEntityIndexAsync(indexedRefs);
270
- logPhase('compact entity index');
271
- // Create entity table builder with EXACT capacity (not totalEntities which
272
- // includes millions of geometry-representation entities we don't store).
273
- // For a 14M entity file, this reduces allocation from ~546MB to ~20MB.
274
- const relevantCount = spatialRefs.length + geometryRefs.length + typeObjectRefs.length
275
- + relationshipRefs.length + groupRefs.length + otherRelevantRefs.length;
276
- const entityTableBuilder = new EntityTableBuilder(relevantCount, strings);
277
- const entityIndex = {
278
- byId: compactByIdIndex,
279
- byType,
280
- };
281
- // === TARGETED PARSING using batch byte-level extraction ===
282
- // Uses 2 TextDecoder.decode() calls total for ALL entity GlobalIds/Names
283
- // (instead of per-entity calls), and pure byte scanning for relationships.
284
- options.onProgress?.({ phase: 'parsing entities', percent: 10 });
285
- const extractor = new EntityExtractor(uint8Buffer);
286
- // Spatial entities: small count, use extractEntity for full accuracy
287
- const parsedEntityData = new Map();
288
- for (const ref of spatialRefs) {
289
- const entity = extractor.extractEntity(ref);
290
- if (entity) {
291
- const attrs = entity.attributes || [];
292
- parsedEntityData.set(ref.expressId, {
293
- globalId: typeof attrs[0] === 'string' ? attrs[0] : '',
294
- name: typeof attrs[2] === 'string' ? attrs[2] : '',
295
- });
296
- }
28
+ /** Internal implementation shared by public refs and parser-worker columns. */
29
+ export async function parseColumnarInput(buffer, input, options = {}) {
30
+ const startTime = performance.now();
31
+ const uint8Buffer = new Uint8Array(buffer);
32
+ const totalEntities = Array.isArray(input) ? input.length : input.expressIds.length;
33
+ // Phase timing for performance telemetry
34
+ let phaseStart = startTime;
35
+ const emitDiagnostic = (message) => {
36
+ options.onDiagnostic?.(message);
37
+ };
38
+ const logPhase = (name) => {
39
+ const now = performance.now();
40
+ const elapsed = Math.round(now - phaseStart);
41
+ console.log(`[parseLite] ${name}: ${elapsed}ms`);
42
+ emitDiagnostic(`${name}: ${elapsed}ms`);
43
+ phaseStart = now;
44
+ };
45
+ options.onProgress?.({ phase: 'building', percent: 0 });
46
+ // Capture verbatim HEADER fields so a round-trip export can reproduce
47
+ // the source FILE_DESCRIPTION items + exact FILE_SCHEMA token instead
48
+ // of regenerating a fresh ifc-lite header. Cheap: the scan stops at the
49
+ // header's ENDSEC, so the DATA section is never touched.
50
+ const sourceHeader = parseSourceHeader(uint8Buffer);
51
+ // Schema version comes from that header's FILE_SCHEMA declaration, not
52
+ // from a substring scan of the raw bytes — exporter product names in
53
+ // FILE_NAME free text carry schema tokens too (issue #3278).
54
+ const schemaVersion = detectSchemaVersion(uint8Buffer, sourceHeader);
55
+ // Initialize builders (entity table capacity set after categorization below)
56
+ const strings = new StringTable();
57
+ const propertyTableBuilder = new PropertyTableBuilder(strings);
58
+ const quantityTableBuilder = new QuantityTableBuilder(strings);
59
+ const relationshipGraphBuilder = new RelationshipGraphBuilder();
60
+ logPhase('init builders');
61
+ // Time-based yielding: yield to the main thread every ~80ms so geometry
62
+ // streaming callbacks can fire. This limits main-thread blocking to short
63
+ // bursts that don't starve geometry, while adding minimal overhead (~15 yields
64
+ // × ~1ms each ≈ 15ms total over the full parse).
65
+ const YIELD_INTERVAL_MS = Math.max(16, options.yieldIntervalMs ?? 80);
66
+ let lastYieldTime = performance.now();
67
+ const yieldIfNeeded = async () => {
68
+ const now = performance.now();
69
+ if (now - lastYieldTime >= YIELD_INTERVAL_MS) {
70
+ await yieldToEventLoop();
71
+ lastYieldTime = performance.now();
297
72
  }
298
- logPhase('spatial entities');
299
- await yieldIfNeeded();
300
- // Group family (IfcZone / IfcSystem / IfcDistributionSystem / …): small
301
- // count, full extract so we can resolve Name + LongName + ObjectType for
302
- // the group label. Name is often empty on these the human label lives
303
- // in LongName (IfcZone/IfcDistributionSystem) so fall back to it, and
304
- // keep ObjectType (e.g. a system designation) for richer display. (#1075)
305
- const groupExtra = new Map();
306
- for (const ref of groupRefs) {
307
- const entity = extractor.extractEntity(ref);
308
- if (!entity)
309
- continue;
310
- const root = extractRootAttributesFromEntity(entity);
311
- const longName = pickLongName(entity);
73
+ };
74
+ emitDiagnostic(`parseLite start: totalEntities=${totalEntities} yieldInterval=${YIELD_INTERVAL_MS}ms`);
75
+ const prepared = await prepareColumnarEntities(input, options.deferPropertyAtomIndex === true, yieldIfNeeded);
76
+ const { byType, getTypeUpper, spatialRefs, geometryRefs, relationshipRefs, propertyRelRefs, propertyContainerRefs, associationRelRefs, typeObjectRefs, otherRelevantRefs, groupRefs } = prepared;
77
+ logPhase(`categorize ${totalEntities} spatial:${spatialRefs.length} geom:${geometryRefs.length} rel:${relationshipRefs.length} propRel:${propertyRelRefs.length} propContainers:${propertyContainerRefs.length} propAtoms:${prepared.propertyAtomCount} assocRel:${associationRelRefs.length} type:${typeObjectRefs.length} group:${groupRefs.length} other:${otherRelevantRefs.length}`);
78
+ emitDiagnostic(`index input: indexedRefs=${prepared.indexedCount} deferredPropertyAtoms=${options.deferPropertyAtomIndex ? prepared.propertyAtomCount : 0}`);
79
+ const compactByIdIndex = await prepared.buildPrimaryIndex();
80
+ logPhase('compact entity index');
81
+ // Create entity table builder with EXACT capacity (not totalEntities which
82
+ // includes millions of geometry-representation entities we don't store).
83
+ // For a 14M entity file, this reduces allocation from ~546MB to ~20MB.
84
+ const relevantCount = spatialRefs.length + geometryRefs.length + typeObjectRefs.length
85
+ + relationshipRefs.length + groupRefs.length + otherRelevantRefs.length;
86
+ const entityTableBuilder = new EntityTableBuilder(relevantCount, strings);
87
+ const entityIndex = {
88
+ byId: compactByIdIndex,
89
+ byType,
90
+ };
91
+ // === TARGETED PARSING using batch byte-level extraction ===
92
+ // Uses 2 TextDecoder.decode() calls total for ALL entity GlobalIds/Names
93
+ // (instead of per-entity calls), and pure byte scanning for relationships.
94
+ options.onProgress?.({ phase: 'parsing entities', percent: 10 });
95
+ const extractor = new EntityExtractor(uint8Buffer);
96
+ // Spatial entities: small count, use extractEntity for full accuracy
97
+ const parsedEntityData = new Map();
98
+ for (const ref of spatialRefs) {
99
+ const entity = extractor.extractEntity(ref);
100
+ if (entity) {
101
+ const attrs = entity.attributes || [];
312
102
  parsedEntityData.set(ref.expressId, {
313
- globalId: root.globalId,
314
- name: root.name || longName,
103
+ globalId: typeof attrs[0] === 'string' ? attrs[0] : '',
104
+ name: typeof attrs[2] === 'string' ? attrs[2] : '',
315
105
  });
316
- groupExtra.set(ref.expressId, { description: root.description, objectType: root.objectType });
317
106
  }
318
- logPhase('group entities');
319
- await yieldIfNeeded();
320
- // Geometry + type object entities: batch extract GlobalId+Name with 2 TextDecoder calls
321
- options.onProgress?.({ phase: 'parsing geometry names', percent: 12 });
322
- const geomData = await batchExtractGlobalIdAndName(uint8Buffer, geometryRefs, yieldIfNeeded);
323
- for (const [id, data] of geomData)
324
- parsedEntityData.set(id, data);
325
- await yieldIfNeeded();
326
- const typeData = await batchExtractGlobalIdAndName(uint8Buffer, typeObjectRefs, yieldIfNeeded);
327
- for (const [id, data] of typeData)
328
- parsedEntityData.set(id, data);
329
- logPhase('batch geom GlobalId+Name');
330
- await yieldIfNeeded();
331
- // Other relevant products (IfcSpatialZone, IfcVirtualElement, IfcGrid,
332
- // IfcAnnotation, ): batch GlobalId+Name so they show their Name in the
333
- // hierarchy / lists instead of nothing. Previously these were added to
334
- // the EntityTable with an empty name (parsedEntityData never covered
335
- // this bucket), so e.g. IfcSpatialZone listed without a label. (#1075)
336
- const otherData = await batchExtractGlobalIdAndName(uint8Buffer, otherRelevantRefs, yieldIfNeeded);
337
- for (const [id, data] of otherData)
338
- parsedEntityData.set(id, data);
339
- logPhase('batch other-relevant GlobalId+Name');
340
- await yieldIfNeeded();
341
- // Relationships: byte-level scanning (numbers only, no TextDecoder)
342
- options.onProgress?.({ phase: 'parsing relationships', percent: 20 });
343
- for (let i = 0; i < relationshipRefs.length; i++) {
344
- if ((i & 0x3FF) === 0)
345
- await yieldIfNeeded();
346
- const ref = relationshipRefs[i];
347
- const typeUpper = getTypeUpper(ref.type);
348
- const rel = extractRelFast(uint8Buffer, ref.byteOffset, ref.byteLength, typeUpper);
349
- if (rel) {
350
- const relType = REL_TYPE_MAP[typeUpper];
351
- if (relType) {
352
- for (const targetId of rel.relatedObjects) {
353
- relationshipGraphBuilder.addEdge(rel.relatingObject, targetId, relType, ref.expressId);
354
- }
107
+ }
108
+ logPhase('spatial entities');
109
+ await yieldIfNeeded();
110
+ // Group family (IfcZone / IfcSystem / IfcDistributionSystem / …): small
111
+ // count, full extract so we can resolve Name + LongName + ObjectType for
112
+ // the group label. Name is often empty on these — the human label lives
113
+ // in LongName (IfcZone/IfcDistributionSystem) — so fall back to it, and
114
+ // keep ObjectType (e.g. a system designation) for richer display. (#1075)
115
+ const groupExtra = new Map();
116
+ for (const ref of groupRefs) {
117
+ const entity = extractor.extractEntity(ref);
118
+ if (!entity)
119
+ continue;
120
+ const root = extractRootAttributesFromEntity(entity);
121
+ const longName = pickLongName(entity);
122
+ parsedEntityData.set(ref.expressId, {
123
+ globalId: root.globalId,
124
+ name: root.name || longName,
125
+ });
126
+ groupExtra.set(ref.expressId, { description: root.description, objectType: root.objectType });
127
+ }
128
+ logPhase('group entities');
129
+ await yieldIfNeeded();
130
+ // Geometry + type object entities: batch extract GlobalId+Name with 2 TextDecoder calls
131
+ options.onProgress?.({ phase: 'parsing geometry names', percent: 12 });
132
+ const geomData = await batchExtractGlobalIdAndName(uint8Buffer, geometryRefs, yieldIfNeeded);
133
+ for (const [id, data] of geomData)
134
+ parsedEntityData.set(id, data);
135
+ await yieldIfNeeded();
136
+ const typeData = await batchExtractGlobalIdAndName(uint8Buffer, typeObjectRefs, yieldIfNeeded);
137
+ for (const [id, data] of typeData)
138
+ parsedEntityData.set(id, data);
139
+ logPhase('batch geom GlobalId+Name');
140
+ await yieldIfNeeded();
141
+ // Other relevant products (IfcSpatialZone, IfcVirtualElement, IfcGrid,
142
+ // IfcAnnotation, …): batch GlobalId+Name so they show their Name in the
143
+ // hierarchy / lists instead of nothing. Previously these were added to
144
+ // the EntityTable with an empty name (parsedEntityData never covered
145
+ // this bucket), so e.g. IfcSpatialZone listed without a label. (#1075)
146
+ const otherData = await batchExtractGlobalIdAndName(uint8Buffer, otherRelevantRefs, yieldIfNeeded);
147
+ for (const [id, data] of otherData)
148
+ parsedEntityData.set(id, data);
149
+ logPhase('batch other-relevant GlobalId+Name');
150
+ await yieldIfNeeded();
151
+ // Relationships: byte-level scanning (numbers only, no TextDecoder)
152
+ options.onProgress?.({ phase: 'parsing relationships', percent: 20 });
153
+ for (let i = 0; i < relationshipRefs.length; i++) {
154
+ if ((i & 0x3FF) === 0)
155
+ await yieldIfNeeded();
156
+ const ref = relationshipRefs[i];
157
+ const typeUpper = getTypeUpper(ref.type);
158
+ const rel = extractRelFast(uint8Buffer, ref.byteOffset, ref.byteLength, typeUpper);
159
+ if (rel) {
160
+ const relType = REL_TYPE_MAP[typeUpper];
161
+ if (relType) {
162
+ for (const targetId of rel.relatedObjects) {
163
+ relationshipGraphBuilder.addEdge(rel.relatingObject, targetId, relType, ref.expressId);
355
164
  }
356
165
  }
357
166
  }
358
- logPhase('byte-level relationships');
359
- // === BUILD ENTITY TABLE from categorized arrays ===
360
- // Instead of iterating ALL 4.4M entityRefs, iterate only categorized arrays
361
- // (~100K-200K total). This eliminates a 200-300ms loop over 4.4M items.
362
- options.onProgress?.({ phase: 'building entities', percent: 30 });
363
- // Helper to add entities with pre-parsed data
364
- const addEntityBatch = (refs, hasGeometry, isType) => {
365
- for (const ref of refs) {
366
- const entityData = parsedEntityData.get(ref.expressId);
367
- entityTableBuilder.add(ref.expressId, ref.type, entityData?.globalId || '', entityData?.name || '', '', // description
368
- '', // objectType
369
- hasGeometry, isType);
370
- }
371
- };
372
- addEntityBatch(spatialRefs, false, false);
373
- addEntityBatch(geometryRefs, true, false);
374
- addEntityBatch(typeObjectRefs, false, true);
375
- addEntityBatch(relationshipRefs, false, false);
376
- addEntityBatch(otherRelevantRefs, false, false);
377
- // Groups carry Description + ObjectType (the system designation), which
378
- // the shared addEntityBatch drops as ''. Add them with the extra fields
379
- // so the Properties title / lists / lens can surface them. (#1075)
380
- for (const ref of groupRefs) {
167
+ }
168
+ logPhase('byte-level relationships');
169
+ // === BUILD ENTITY TABLE from categorized arrays ===
170
+ // Instead of iterating ALL 4.4M entityRefs, iterate only categorized arrays
171
+ // (~100K-200K total). This eliminates a 200-300ms loop over 4.4M items.
172
+ options.onProgress?.({ phase: 'building entities', percent: 30 });
173
+ // Helper to add entities with pre-parsed data
174
+ const addEntityBatch = (refs, hasGeometry, isType) => {
175
+ for (const ref of refs) {
381
176
  const entityData = parsedEntityData.get(ref.expressId);
382
- const extra = groupExtra.get(ref.expressId);
383
- entityTableBuilder.add(ref.expressId, ref.type, entityData?.globalId || '', entityData?.name || '', extra?.description || '', extra?.objectType || '', false, false);
384
- }
385
- logPhase('add entity batches');
386
- const entityTable = entityTableBuilder.build();
387
- logPhase('entity table build()');
388
- // Empty property/quantity tables - use on-demand extraction instead
389
- const propertyTable = propertyTableBuilder.build();
390
- const quantityTable = quantityTableBuilder.build();
391
- // Build intermediate relationship graph (spatial/hierarchy edges only).
392
- // Property/association edges are added later; final graph is rebuilt at the end.
393
- const hierarchyRelGraph = relationshipGraphBuilder.build();
394
- logPhase('hierarchy rel graph build()');
395
- await yieldIfNeeded();
396
- // === EXTRACT LENGTH UNIT SCALE ===
397
- options.onProgress?.({ phase: 'extracting units', percent: 85 });
398
- const lengthUnitScale = extractLengthUnitScale(uint8Buffer, entityIndex);
399
- // === BUILD SPATIAL HIERARCHY ===
400
- options.onProgress?.({ phase: 'building hierarchy', percent: 90 });
401
- let spatialHierarchy;
402
- try {
403
- const hierarchyBuilder = new SpatialHierarchyBuilder();
404
- spatialHierarchy = hierarchyBuilder.build(entityTable, hierarchyRelGraph, strings, uint8Buffer, entityIndex, lengthUnitScale);
405
- logPhase('spatial hierarchy');
177
+ entityTableBuilder.add(ref.expressId, ref.type, entityData?.globalId || '', entityData?.name || '', '', // description
178
+ '', // objectType
179
+ hasGeometry, isType);
406
180
  }
407
- catch (error) {
408
- console.warn('[ColumnarParser] Failed to build spatial hierarchy:', error);
409
- }
410
- // === EMIT SPATIAL HIERARCHY EARLY ===
411
- // The hierarchy panel can render immediately while property/association
412
- // parsing continues. This lets the panel appear at the same time as
413
- // geometry streaming completes.
414
- // ONE accessor, shared by the store field and the entity source.
415
- //
416
- // These used to be built separately -- `BufferEntitySource` got the raw
417
- // `uint8Buffer` and wrapped it in its own accessor, while `source` got
418
- // another. That is invisible while both are resident views over the
419
- // same bytes, and fatal once the source can switch to compressed
420
- // storage in place (#2183): `getEntity` would keep reading its private
421
- // resident accessor, so the original buffer would never be released and
422
- // the store would serve entities from one representation and properties
423
- // from the other. Measured: with two accessors the buffer survives GC
424
- // after the swap; with one it is collected.
425
- const source = contiguousSourceBytes(uint8Buffer);
426
- const entitySource = new BufferEntitySource(source, entityIndex);
427
- const earlyStore = {
428
- fileSize: buffer.byteLength,
429
- schemaVersion,
430
- sourceHeader,
431
- entityCount: totalEntities,
432
- parseTime: performance.now() - startTime,
433
- source,
434
- entityIndex,
435
- strings,
436
- entities: entityTable,
437
- properties: propertyTable,
438
- quantities: quantityTable,
439
- relationships: hierarchyRelGraph,
440
- spatialHierarchy,
441
- lengthUnitScale,
442
- getEntity(expressId) { return entitySource.getEntity(expressId); },
443
- getEntitiesByType(typeName) { return entitySource.getEntitiesByType(typeName); },
444
- getProperties(expressId) { return this.properties.getForEntity(expressId); },
445
- getQuantities(expressId) { return this.quantities.getForEntity(expressId); },
446
- };
447
- options.onSpatialReady?.(earlyStore);
448
- await yieldIfNeeded(); // Let geometry process after hierarchy emission
449
- // === DEFERRED: Parse property and association relationships ===
450
- // These are NOT needed for the spatial hierarchy panel.
451
- options.onProgress?.({ phase: 'parsing property refs', percent: 92 });
452
- const onDemandPropertyMap = new Map();
453
- const onDemandQuantityMap = new Map();
454
- // Pre-build Sets of property set / quantity set IDs from already-categorized refs.
455
- // This replaces 252K binary searches on the 14M compact entity index with O(1) Set lookups.
456
- const propertySetIds = new Set();
457
- const quantitySetIds = new Set();
458
- for (const ref of propertyContainerRefs) {
459
- const tu = getTypeUpper(ref.type);
460
- if (tu === 'IFCPROPERTYSET')
461
- propertySetIds.add(ref.expressId);
462
- else if (tu === 'IFCELEMENTQUANTITY')
463
- quantitySetIds.add(ref.expressId);
464
- }
465
- // Property rels: byte-level scanning + addEdge (now fast with SoA builder).
466
- let totalPropRelObjects = 0;
467
- for (let pi = 0; pi < propertyRelRefs.length; pi++) {
468
- if ((pi & 0x3FF) === 0)
469
- await yieldIfNeeded();
470
- const ref = propertyRelRefs[pi];
471
- const result = extractPropertyRelFast(uint8Buffer, ref.byteOffset, ref.byteLength);
472
- if (result) {
473
- const { relatedObjects, relatingDefs } = result;
474
- totalPropRelObjects += relatedObjects.length;
475
- // RelatingPropertyDefinition is IfcPropertySetDefinitionSelect, whose
476
- // second alternative (IfcPropertySetDefinitionSet) is a SET of pset/
477
- // qset definitions — `relatingDefs` has more than one entry for that
478
- // case. Every entry in the group applies to every related object.
479
- for (const relatingDef of relatingDefs) {
181
+ };
182
+ addEntityBatch(spatialRefs, false, false);
183
+ addEntityBatch(geometryRefs, true, false);
184
+ addEntityBatch(typeObjectRefs, false, true);
185
+ addEntityBatch(relationshipRefs, false, false);
186
+ addEntityBatch(otherRelevantRefs, false, false);
187
+ // Groups carry Description + ObjectType (the system designation), which
188
+ // the shared addEntityBatch drops as ''. Add them with the extra fields
189
+ // so the Properties title / lists / lens can surface them. (#1075)
190
+ for (const ref of groupRefs) {
191
+ const entityData = parsedEntityData.get(ref.expressId);
192
+ const extra = groupExtra.get(ref.expressId);
193
+ entityTableBuilder.add(ref.expressId, ref.type, entityData?.globalId || '', entityData?.name || '', extra?.description || '', extra?.objectType || '', false, false);
194
+ }
195
+ logPhase('add entity batches');
196
+ const entityTable = entityTableBuilder.build();
197
+ logPhase('entity table build()');
198
+ // Empty property/quantity tables - use on-demand extraction instead
199
+ const propertyTable = propertyTableBuilder.build();
200
+ const quantityTable = quantityTableBuilder.build();
201
+ // Build intermediate relationship graph (spatial/hierarchy edges only).
202
+ // Property/association edges are added later; final graph is rebuilt at the end.
203
+ const hierarchyRelGraph = relationshipGraphBuilder.build();
204
+ logPhase('hierarchy rel graph build()');
205
+ await yieldIfNeeded();
206
+ // === EXTRACT LENGTH UNIT SCALE ===
207
+ options.onProgress?.({ phase: 'extracting units', percent: 85 });
208
+ const lengthUnitScale = extractLengthUnitScale(uint8Buffer, entityIndex);
209
+ // === BUILD SPATIAL HIERARCHY ===
210
+ options.onProgress?.({ phase: 'building hierarchy', percent: 90 });
211
+ let spatialHierarchy;
212
+ try {
213
+ const hierarchyBuilder = new SpatialHierarchyBuilder();
214
+ spatialHierarchy = hierarchyBuilder.build(entityTable, hierarchyRelGraph, strings, uint8Buffer, entityIndex, lengthUnitScale);
215
+ logPhase('spatial hierarchy');
216
+ }
217
+ catch (error) {
218
+ console.warn('[ColumnarParser] Failed to build spatial hierarchy:', error);
219
+ }
220
+ // === EMIT SPATIAL HIERARCHY EARLY ===
221
+ // The hierarchy panel can render immediately while property/association
222
+ // parsing continues. This lets the panel appear at the same time as
223
+ // geometry streaming completes.
224
+ // ONE accessor, shared by the store field and the entity source.
225
+ //
226
+ // These used to be built separately -- `BufferEntitySource` got the raw
227
+ // `uint8Buffer` and wrapped it in its own accessor, while `source` got
228
+ // another. That is invisible while both are resident views over the
229
+ // same bytes, and fatal once the source can switch to compressed
230
+ // storage in place (#2183): `getEntity` would keep reading its private
231
+ // resident accessor, so the original buffer would never be released and
232
+ // the store would serve entities from one representation and properties
233
+ // from the other. Measured: with two accessors the buffer survives GC
234
+ // after the swap; with one it is collected.
235
+ const source = contiguousSourceBytes(uint8Buffer);
236
+ const entitySource = new BufferEntitySource(source, entityIndex);
237
+ const earlyStore = {
238
+ fileSize: buffer.byteLength,
239
+ schemaVersion,
240
+ sourceHeader,
241
+ entityCount: totalEntities,
242
+ parseTime: performance.now() - startTime,
243
+ source,
244
+ entityIndex,
245
+ strings,
246
+ entities: entityTable,
247
+ properties: propertyTable,
248
+ quantities: quantityTable,
249
+ relationships: hierarchyRelGraph,
250
+ spatialHierarchy,
251
+ lengthUnitScale,
252
+ getEntity(expressId) { return entitySource.getEntity(expressId); },
253
+ getEntitiesByType(typeName) { return entitySource.getEntitiesByType(typeName); },
254
+ getProperties(expressId) { return this.properties.getForEntity(expressId); },
255
+ getQuantities(expressId) { return this.quantities.getForEntity(expressId); },
256
+ };
257
+ options.onSpatialReady?.(earlyStore);
258
+ await yieldIfNeeded(); // Let geometry process after hierarchy emission
259
+ // === DEFERRED: Parse property and association relationships ===
260
+ // These are NOT needed for the spatial hierarchy panel.
261
+ options.onProgress?.({ phase: 'parsing property refs', percent: 92 });
262
+ const onDemandPropertyMap = new Map();
263
+ const onDemandQuantityMap = new Map();
264
+ // Pre-build Sets of property set / quantity set IDs from already-categorized refs.
265
+ // This replaces 252K binary searches on the 14M compact entity index with O(1) Set lookups.
266
+ const propertySetIds = new Set();
267
+ const quantitySetIds = new Set();
268
+ for (const ref of propertyContainerRefs) {
269
+ const tu = getTypeUpper(ref.type);
270
+ if (tu === 'IFCPROPERTYSET')
271
+ propertySetIds.add(ref.expressId);
272
+ else if (tu === 'IFCELEMENTQUANTITY')
273
+ quantitySetIds.add(ref.expressId);
274
+ }
275
+ // Property rels: byte-level scanning + addEdge (now fast with SoA builder).
276
+ let totalPropRelObjects = 0;
277
+ for (let pi = 0; pi < propertyRelRefs.length; pi++) {
278
+ if ((pi & 0x3FF) === 0)
279
+ await yieldIfNeeded();
280
+ const ref = propertyRelRefs[pi];
281
+ const result = extractPropertyRelFast(uint8Buffer, ref.byteOffset, ref.byteLength);
282
+ if (result) {
283
+ const { relatedObjects, relatingDefs } = result;
284
+ totalPropRelObjects += relatedObjects.length;
285
+ // RelatingPropertyDefinition is IfcPropertySetDefinitionSelect, whose
286
+ // second alternative (IfcPropertySetDefinitionSet) is a SET of pset/
287
+ // qset definitions — `relatingDefs` has more than one entry for that
288
+ // case. Every entry in the group applies to every related object.
289
+ for (const relatingDef of relatingDefs) {
290
+ for (const objId of relatedObjects) {
291
+ relationshipGraphBuilder.addEdge(relatingDef, objId, RelationshipType.DefinesByProperties, ref.expressId);
292
+ }
293
+ // Build on-demand property/quantity maps using pre-built Sets (O(1) vs binary search)
294
+ const isPropSet = propertySetIds.has(relatingDef);
295
+ const isQtySet = !isPropSet && quantitySetIds.has(relatingDef);
296
+ if (isPropSet || isQtySet) {
297
+ const targetMap = isPropSet ? onDemandPropertyMap : onDemandQuantityMap;
480
298
  for (const objId of relatedObjects) {
481
- relationshipGraphBuilder.addEdge(relatingDef, objId, RelationshipType.DefinesByProperties, ref.expressId);
482
- }
483
- // Build on-demand property/quantity maps using pre-built Sets (O(1) vs binary search)
484
- const isPropSet = propertySetIds.has(relatingDef);
485
- const isQtySet = !isPropSet && quantitySetIds.has(relatingDef);
486
- if (isPropSet || isQtySet) {
487
- const targetMap = isPropSet ? onDemandPropertyMap : onDemandQuantityMap;
488
- for (const objId of relatedObjects) {
489
- addOnDemandRef(targetMap, objId, relatingDef);
490
- }
299
+ addOnDemandRef(targetMap, objId, relatingDef);
491
300
  }
492
301
  }
493
302
  }
494
303
  }
495
- await yieldIfNeeded();
496
- // Association rels: byte-level scanning, no addEdge (same reasoning as property rels)
497
- options.onProgress?.({ phase: 'parsing associations', percent: 95 });
498
- const onDemandClassificationMap = new Map();
499
- const onDemandMaterialMap = new Map();
500
- const onDemandDocumentMap = new Map();
501
- // Determinism rule for elements with MULTIPLE IfcRelAssociatesMaterial:
502
- // the map keeps EVERY association (list-valued), ordered by rel express
503
- // id, so list[0] the "primary" is the RelatingMaterial of the
504
- // LOWEST rel express id regardless of file order. The cache rebuild
505
- // (viewer spatialHierarchy rebuildOnDemandMaps) applies the same rule
506
- // via edge relationshipIds, so fresh-parse and cache-load agree.
507
- const materialRelIds = new Map();
508
- for (let i = 0; i < associationRelRefs.length; i++) {
509
- if ((i & 0x3FF) === 0)
510
- await yieldIfNeeded();
511
- const ref = associationRelRefs[i];
512
- const result = extractPropertyRelFast(uint8Buffer, ref.byteOffset, ref.byteLength);
513
- if (result) {
514
- // IfcRelAssociates{Material,Classification,Document}'s Relating*
515
- // selects are always single refs (unlike RelatingPropertyDefinition
516
- // above, none of IfcMaterialSelect/IfcClassificationSelect/
517
- // IfcDocumentSelect admit a SET alternative) — take the one entry.
518
- const { relatedObjects, relatingDefs } = result;
519
- const relatingRef = relatingDefs[0];
520
- const typeUpper = getTypeUpper(ref.type);
521
- if (typeUpper === 'IFCRELASSOCIATESCLASSIFICATION') {
522
- for (const objId of relatedObjects) {
523
- addOnDemandRef(onDemandClassificationMap, objId, relatingRef);
524
- relationshipGraphBuilder.addEdge(relatingRef, objId, RelationshipType.AssociatesClassification, ref.expressId);
525
- }
304
+ }
305
+ await yieldIfNeeded();
306
+ // Association rels: byte-level scanning, no addEdge (same reasoning as property rels)
307
+ options.onProgress?.({ phase: 'parsing associations', percent: 95 });
308
+ const onDemandClassificationMap = new Map();
309
+ const onDemandMaterialMap = new Map();
310
+ const onDemandDocumentMap = new Map();
311
+ // Determinism rule for elements with MULTIPLE IfcRelAssociatesMaterial:
312
+ // the map keeps EVERY association (list-valued), ordered by rel express
313
+ // id, so list[0] the "primary" is the RelatingMaterial of the
314
+ // LOWEST rel express id regardless of file order. The cache rebuild
315
+ // (viewer spatialHierarchy rebuildOnDemandMaps) applies the same rule
316
+ // via edge relationshipIds, so fresh-parse and cache-load agree.
317
+ const materialRelIds = new Map();
318
+ for (let i = 0; i < associationRelRefs.length; i++) {
319
+ if ((i & 0x3FF) === 0)
320
+ await yieldIfNeeded();
321
+ const ref = associationRelRefs[i];
322
+ const result = extractPropertyRelFast(uint8Buffer, ref.byteOffset, ref.byteLength);
323
+ if (result) {
324
+ // IfcRelAssociates{Material,Classification,Document}'s Relating*
325
+ // selects are always single refs (unlike RelatingPropertyDefinition
326
+ // above, none of IfcMaterialSelect/IfcClassificationSelect/
327
+ // IfcDocumentSelect admit a SET alternative) — take the one entry.
328
+ const { relatedObjects, relatingDefs } = result;
329
+ const relatingRef = relatingDefs[0];
330
+ const typeUpper = getTypeUpper(ref.type);
331
+ if (typeUpper === 'IFCRELASSOCIATESCLASSIFICATION') {
332
+ for (const objId of relatedObjects) {
333
+ addOnDemandRef(onDemandClassificationMap, objId, relatingRef);
334
+ relationshipGraphBuilder.addEdge(relatingRef, objId, RelationshipType.AssociatesClassification, ref.expressId);
526
335
  }
527
- else if (typeUpper === 'IFCRELASSOCIATESMATERIAL') {
528
- for (const objId of relatedObjects) {
529
- let list = onDemandMaterialMap.get(objId);
530
- let relIds = materialRelIds.get(objId);
531
- if (!list || !relIds) {
532
- list = [];
533
- onDemandMaterialMap.set(objId, list);
534
- relIds = [];
535
- materialRelIds.set(objId, relIds);
536
- }
537
- // Deliberately NOT deduped (#3782 review): buildMaterialUsageIndex
538
- // already dedupes downstream (seenPerMaterial), per material-fraction-and-associations.test.ts.
539
- let at = relIds.length;
540
- while (at > 0 && relIds[at - 1] > ref.expressId)
541
- at--;
542
- relIds.splice(at, 0, ref.expressId);
543
- list.splice(at, 0, relatingRef);
544
- relationshipGraphBuilder.addEdge(relatingRef, objId, RelationshipType.AssociatesMaterial, ref.expressId);
336
+ }
337
+ else if (typeUpper === 'IFCRELASSOCIATESMATERIAL') {
338
+ for (const objId of relatedObjects) {
339
+ let list = onDemandMaterialMap.get(objId);
340
+ let relIds = materialRelIds.get(objId);
341
+ if (!list || !relIds) {
342
+ list = [];
343
+ onDemandMaterialMap.set(objId, list);
344
+ relIds = [];
345
+ materialRelIds.set(objId, relIds);
545
346
  }
347
+ // Deliberately NOT deduped (#3782 review): buildMaterialUsageIndex
348
+ // already dedupes downstream (seenPerMaterial), per material-fraction-and-associations.test.ts.
349
+ let at = relIds.length;
350
+ while (at > 0 && relIds[at - 1] > ref.expressId)
351
+ at--;
352
+ relIds.splice(at, 0, ref.expressId);
353
+ list.splice(at, 0, relatingRef);
354
+ relationshipGraphBuilder.addEdge(relatingRef, objId, RelationshipType.AssociatesMaterial, ref.expressId);
546
355
  }
547
- else if (typeUpper === 'IFCRELASSOCIATESDOCUMENT') {
548
- for (const objId of relatedObjects) {
549
- addOnDemandRef(onDemandDocumentMap, objId, relatingRef);
550
- relationshipGraphBuilder.addEdge(relatingRef, objId, RelationshipType.AssociatesDocument, ref.expressId);
551
- }
356
+ }
357
+ else if (typeUpper === 'IFCRELASSOCIATESDOCUMENT') {
358
+ for (const objId of relatedObjects) {
359
+ addOnDemandRef(onDemandDocumentMap, objId, relatingRef);
360
+ relationshipGraphBuilder.addEdge(relatingRef, objId, RelationshipType.AssociatesDocument, ref.expressId);
552
361
  }
553
362
  }
554
363
  }
555
- logPhase('property+association rels');
556
- // Rebuild relationship graph with ALL edges (hierarchy + property + association)
557
- const fullRelationshipGraph = relationshipGraphBuilder.build();
558
- logPhase('relationship graph build()');
559
- let deferredEntityIndex;
560
- if (deferPropertyAtomIndex && propertyAtomRefs.length > 0) {
561
- options.onProgress?.({ phase: 'indexing property atoms', percent: 98 });
562
- deferredEntityIndex = await buildCompactEntityIndexAsync(propertyAtomRefs, undefined, 1024, 2);
563
- logPhase('deferred property atom index');
564
- }
565
- const parseTime = performance.now() - startTime;
566
- options.onProgress?.({ phase: 'complete', percent: 100 });
567
- const finalStore = {
568
- ...earlyStore,
569
- parseTime,
570
- relationships: fullRelationshipGraph,
571
- deferredEntityIndex,
572
- onDemandPropertyMap,
573
- onDemandQuantityMap,
574
- onDemandClassificationMap,
575
- onDemandMaterialMap,
576
- onDemandDocumentMap,
577
- lengthUnitScale,
578
- getEntity(expressId) { return entitySource.getEntity(expressId); },
579
- getEntitiesByType(typeName) { return entitySource.getEntitiesByType(typeName); },
580
- getProperties(expressId) {
581
- if (onDemandPropertyMap.size > 0)
582
- return extractPropertiesOnDemand(this, expressId);
583
- return this.properties.getForEntity(expressId);
584
- },
585
- getQuantities(expressId) {
586
- if (onDemandQuantityMap.size > 0)
587
- return extractQuantitiesOnDemand(this, expressId);
588
- return this.quantities.getForEntity(expressId);
589
- },
590
- };
591
- return finalStore;
364
+ }
365
+ logPhase('property+association rels');
366
+ // Rebuild relationship graph with ALL edges (hierarchy + property + association)
367
+ const fullRelationshipGraph = relationshipGraphBuilder.build();
368
+ logPhase('relationship graph build()');
369
+ let deferredEntityIndex;
370
+ if (options.deferPropertyAtomIndex && prepared.propertyAtomCount > 0) {
371
+ options.onProgress?.({ phase: 'indexing property atoms', percent: 98 });
372
+ deferredEntityIndex = await prepared.buildDeferredIndex();
373
+ logPhase('deferred property atom index');
374
+ }
375
+ const parseTime = performance.now() - startTime;
376
+ options.onProgress?.({ phase: 'complete', percent: 100 });
377
+ const finalStore = {
378
+ ...earlyStore,
379
+ parseTime,
380
+ relationships: fullRelationshipGraph,
381
+ deferredEntityIndex,
382
+ onDemandPropertyMap,
383
+ onDemandQuantityMap,
384
+ onDemandClassificationMap,
385
+ onDemandMaterialMap,
386
+ onDemandDocumentMap,
387
+ lengthUnitScale,
388
+ getEntity(expressId) { return entitySource.getEntity(expressId); },
389
+ getEntitiesByType(typeName) { return entitySource.getEntitiesByType(typeName); },
390
+ getProperties(expressId) {
391
+ if (onDemandPropertyMap.size > 0)
392
+ return extractPropertiesOnDemand(this, expressId);
393
+ return this.properties.getForEntity(expressId);
394
+ },
395
+ getQuantities(expressId) {
396
+ if (onDemandQuantityMap.size > 0)
397
+ return extractQuantitiesOnDemand(this, expressId);
398
+ return this.quantities.getForEntity(expressId);
399
+ },
400
+ };
401
+ return finalStore;
402
+ }
403
+ export class ColumnarParser {
404
+ /**
405
+ * Parse IFC file into columnar data store
406
+ *
407
+ * Uses fast semicolon-based scanning with on-demand property extraction.
408
+ * Properties are parsed lazily when accessed, not upfront.
409
+ * This provides instant UI responsiveness even for very large files.
410
+ */
411
+ async parseLite(buffer, entityRefs, options = {}) {
412
+ return parseColumnarInput(buffer, entityRefs, options);
592
413
  }
593
414
  /**
594
415
  * Extract properties for a single entity ON-DEMAND
@@ -694,235 +515,6 @@ export function extractQuantitiesOnDemand(store, entityId) {
694
515
  const parser = new ColumnarParser();
695
516
  return parser.extractQuantitiesOnDemand(store, entityId);
696
517
  }
697
- function getEntityRefFromStore(store, expressId) {
698
- return store.entityIndex.byId.get(expressId) ?? store.deferredEntityIndex?.get(expressId);
699
- }
700
- /**
701
- * Extract entity attributes on-demand from source buffer.
702
- * Returns globalId, name, description, objectType, tag mapped by schema name
703
- * (see {@link extractRootAttributesFromEntity}), so the result stays correct
704
- * for entity types whose attribute order differs from the IfcElement layout.
705
- * This is used for entities that weren't fully parsed during initial load.
706
- */
707
- export function extractEntityAttributesOnDemand(store, entityId) {
708
- const ref = store.entityIndex.byId.get(entityId);
709
- if (!ref) {
710
- return { globalId: '', name: '', description: '', objectType: '', tag: '' };
711
- }
712
- const extractor = new EntityExtractor(store.source);
713
- const entity = extractor.extractEntity(ref);
714
- if (!entity) {
715
- return { globalId: '', name: '', description: '', objectType: '', tag: '' };
716
- }
717
- return extractRootAttributesFromEntity(entity);
718
- }
719
- /**
720
- * Extract ALL named entity attributes on-demand from source buffer.
721
- * Uses the IFC schema to map attribute indices to names.
722
- * Returns only string/enum attributes, skipping references and structural attributes.
723
- */
724
- export function extractAllEntityAttributes(store, entityId) {
725
- const ref = store.entityIndex.byId.get(entityId);
726
- if (!ref)
727
- return [];
728
- const extractor = new EntityExtractor(store.source);
729
- const entity = extractor.extractEntity(ref);
730
- if (!entity)
731
- return [];
732
- const attrs = entity.attributes || [];
733
- // Use properly-cased type name from entity table (IfcTypeEnumToString)
734
- // instead of ref.type which is UPPERCASE from STEP (e.g., IFCWALLSTANDARDCASE)
735
- // and breaks multi-word type normalization in getAttributeNames.
736
- // For resource-level entities (IfcTask, IfcTaskTime, IfcMaterial,
737
- // IfcClassification, ...) the entity table returns 'Unknown';
738
- // fall back to ref.type so the schema-driven attribute-name
739
- // resolution still works for those types.
740
- const tableName = store.entities.getTypeName(entityId);
741
- const typeName = tableName && tableName !== 'Unknown' ? tableName : ref.type;
742
- // Named across the bundled schema union (2X3 + 4 + 4X3), not through the
743
- // IFC4 codegen pin alone. The pin answers an EMPTY list — not a wrong one —
744
- // for every class it does not carry, and 251 real classes are outside it:
745
- // the IFC2X3 ones IFC4 dropped and the whole IFC4X3 infrastructure
746
- // vocabulary (`IfcCourse`, `IfcPavement`, `IfcKerb`, `IfcSignal`, `IfcRoad`,
747
- // …). An empty list means this function returns NO attributes for such an
748
- // entity, so every caller that looks one up by name silently finds nothing
749
- // and cannot tell that apart from an unset slot. The model-diff adapters
750
- // read `PredefinedType` this way, which made a cleared `PredefinedType` —
751
- // the single most common edit in a real infrastructure revision — compare
752
- // equal to itself on exactly the classes IFC4X3 exists for. Same pinned-
753
- // registry family as #2001/#2003/#2021.
754
- //
755
- // Provably additive: `getAttributeNamesAcrossSchemas` returns the pinned
756
- // result unchanged whenever the pin has one, so no IFC2X3 or IFC4 entity's
757
- // attribute list — or the hash anyone derives from it — moves.
758
- const attrNames = getAttributeNamesAcrossSchemas(typeName);
759
- const result = [];
760
- const len = Math.min(attrs.length, attrNames.length);
761
- for (let i = 0; i < len; i++) {
762
- const attrName = attrNames[i];
763
- if (SKIP_DISPLAY_ATTRS.has(attrName))
764
- continue;
765
- const raw = attrs[i];
766
- // STEP `$` (unset) and `*` (derived) deserialize as null /
767
- // undefined and must be skipped. Strings are emitted with
768
- // `.ENUM.` markers stripped. Empty strings are preserved so
769
- // IDS optional-attribute checks can distinguish "slot truly
770
- // absent" from "slot explicitly empty". Numbers and booleans
771
- // pass through unchanged so e.g. `CountValue = 0` reads as
772
- // present.
773
- if (typeof raw === 'string') {
774
- // STEP logical-unknown markers (`.U.`, `.X.`) read as
775
- // "no value" per IDS spec — they fail any attribute
776
- // check, including a bare existence check, so don't
777
- // surface them as if the slot were populated.
778
- if (raw === '.U.' || raw === '.X.')
779
- continue;
780
- // Bare boolean tokens (`.T.` / `.F.`) on a schema-typed
781
- // IfcBoolean attribute slot — resolve to JS boolean so
782
- // IDS checks comparing against `true` / `false` literals
783
- // pass without case-sensitive string contortions.
784
- if (raw === '.T.') {
785
- result.push({ name: attrName, value: true });
786
- continue;
787
- }
788
- if (raw === '.F.') {
789
- result.push({ name: attrName, value: false });
790
- continue;
791
- }
792
- const display = raw.startsWith('.') && raw.endsWith('.')
793
- ? raw.slice(1, -1)
794
- : raw;
795
- result.push({ name: attrName, value: display });
796
- }
797
- else if (typeof raw === 'number' || typeof raw === 'boolean') {
798
- result.push({ name: attrName, value: raw });
799
- }
800
- else if (Array.isArray(raw) && raw.length === 2) {
801
- // Typed STEP values like IFCREAL(0.0), IFCBOOLEAN(.T.) —
802
- // return the underlying primitive so attribute existence
803
- // and value checks can compare it directly.
804
- const inner = raw[1];
805
- const tag = String(raw[0]).toUpperCase();
806
- if (tag.includes('BOOLEAN')) {
807
- result.push({ name: attrName, value: inner === '.T.' || inner === true });
808
- }
809
- else if (tag.includes('LOGICAL')) {
810
- if (inner === '.U.' || inner === '.X.') {
811
- // UNKNOWN logical → don't surface (treated as absent)
812
- continue;
813
- }
814
- result.push({ name: attrName, value: inner === '.T.' || inner === true });
815
- }
816
- else if (typeof inner === 'number' || typeof inner === 'boolean') {
817
- result.push({ name: attrName, value: inner });
818
- }
819
- else if (typeof inner === 'string' && inner) {
820
- const display = inner.startsWith('.') && inner.endsWith('.')
821
- ? inner.slice(1, -1)
822
- : inner;
823
- result.push({ name: attrName, value: display });
824
- }
825
- }
826
- }
827
- return result;
828
- }
829
- /**
830
- * Returns named raw attribute pairs for an entity, filtered to display-relevant attributes.
831
- * Skips structural/reference attributes using the IFC schema. Used by query layer for coercion.
832
- */
833
- export function getRawNamedAttributes(entity) {
834
- const attrs = entity.attributes || [];
835
- const attrNames = getAttributeNames(entity.type);
836
- const result = [];
837
- const len = Math.min(attrs.length, attrNames.length);
838
- for (let i = 0; i < len; i++) {
839
- const attrName = attrNames[i];
840
- if (SKIP_DISPLAY_ATTRS.has(attrName))
841
- continue;
842
- result.push({ name: attrName, raw: attrs[i] });
843
- }
844
- return result;
845
- }
846
- // getAttributeNames() walks the schema registry (an O(types) scan for the
847
- // UPPERCASE STEP names entities carry), so memoise the per-type index lookup.
848
- // There are only a few hundred distinct types but potentially millions of
849
- // entities, keeping the on-demand path cheap even when called per entity.
850
- const rootAttrIndexCache = new Map();
851
- function getRootAttrIndices(type) {
852
- let idx = rootAttrIndexCache.get(type);
853
- if (!idx) {
854
- const names = getAttributeNames(type);
855
- idx = {
856
- known: names.length > 0,
857
- globalId: names.indexOf('GlobalId'),
858
- name: names.indexOf('Name'),
859
- description: names.indexOf('Description'),
860
- objectType: names.indexOf('ObjectType'),
861
- tag: names.indexOf('Tag'),
862
- longName: names.indexOf('LongName'),
863
- };
864
- rootAttrIndexCache.set(type, idx);
865
- }
866
- return idx;
867
- }
868
- /**
869
- * Resolve the common IfcRoot-family display attributes (GlobalId, Name,
870
- * Description, ObjectType, Tag) from an entity's raw attribute array.
871
- *
872
- * These are mapped by schema-derived attribute *name*, not fixed index. The
873
- * fixed indices `[0],[2],[3],[4],[7]` only hold for the IfcElement layout: for
874
- * a spatial element `attrs[7]` is LongName (not Tag), and for a resource entity
875
- * like IfcMaterial `attrs[0]` is Name (not GlobalId). Name-mapping keeps all of
876
- * these correct for every entity type, returning '' for attributes the type
877
- * does not declare.
878
- *
879
- * For types the schema registry does not recognise (e.g. an IFC4x3 infra leaf
880
- * outside the codegen pin, or a vendor extension) we fall back to the canonical
881
- * IfcRoot/IfcElement positions so we never regress vs. the old fixed-index path.
882
- */
883
- export function extractRootAttributesFromEntity(entity) {
884
- const attrs = entity.attributes || [];
885
- const enumIdx = entity.enumAttrIndices;
886
- const idx = getRootAttrIndices(entity.type);
887
- const pick = (schemaIndex, fallbackIndex) => {
888
- const i = idx.known ? schemaIndex : fallbackIndex;
889
- const raw = i >= 0 ? attrs[i] : undefined;
890
- if (typeof raw !== 'string')
891
- return '';
892
- // Unknown-type fallback only: a fixed index can land on a STEP bare-enum
893
- // token — e.g. a PredefinedType at attr 7 for a non-IfcElement layout —
894
- // which must not leak into a Tag/Description cell. Reject by token KIND
895
- // via the extractor's side channel (#1799), not by dotted-string shape:
896
- // a quoted string that merely looks like an enum ('.USERDEFINED.')
897
- // survives, exactly matching the Rust server path (string_at accepts
898
- // AttributeValue::String and rejects ::Enum, #1779). Skipped for known
899
- // types, whose schema indices point at genuine string slots.
900
- if (!idx.known && enumIdx !== undefined && enumIdx.includes(i))
901
- return '';
902
- return raw;
903
- };
904
- return {
905
- globalId: pick(idx.globalId, 0),
906
- name: pick(idx.name, 2),
907
- description: pick(idx.description, 3),
908
- objectType: pick(idx.objectType, 4),
909
- tag: pick(idx.tag, 7),
910
- };
911
- }
912
- /**
913
- * Resolve an entity's LongName (IfcZone, IfcSystem subtypes, IfcSpatialZone,
914
- * IfcBuildingSystem, …) by schema attribute name. Groups frequently leave Name
915
- * empty and carry their human label in LongName, so consumers fall back to this
916
- * for the display label. Returns '' when the type does not declare LongName.
917
- * (#1075)
918
- */
919
- export function pickLongName(entity) {
920
- const idx = getRootAttrIndices(entity.type);
921
- if (!idx.known || idx.longName < 0)
922
- return '';
923
- const raw = (entity.attributes || [])[idx.longName];
924
- return typeof raw === 'string' ? raw : '';
925
- }
926
518
  // Re-export on-demand extraction functions from focused module
927
519
  export { extractClassificationsOnDemand, extractClassificationSystemsOnDemand, extractMaterialsOnDemand, extractAllMaterialsOnDemand, extractMaterialPropertiesOnDemand, extractMaterialPropertiesForMaterialId, resolveMaterialDefId, resolveAllMaterialDefIds, collectMaterialLeaves, buildMaterialUsageIndex, getMaterialDisplay, extractTypePropertiesOnDemand, extractTypeEntityOwnProperties, extractTypeQuantitiesOnDemand, extractDocumentsOnDemand, extractRelationshipsOnDemand, extractGroupMembersOnDemand, extractGeoreferencingOnDemand, parsePropertyValue, extractPsetsFromIds, extractQsetsFromIds, } from './on-demand-extractors.js';
928
520
  export { mergeInheritedPropertySets, mergeInheritedQuantitySets } from './property-set-merge.js';