@bldrs-ai/conway 1.369.1178 → 1.372.1179

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.
@@ -4070,6 +4070,7 @@ var StepModelBase = class {
4070
4070
  this.schema = schema;
4071
4071
  this.buffer_ = buffer_;
4072
4072
  this.vtableBuilder_ = new StepVtableBuilder();
4073
+ this.descriptorCache_ = [];
4073
4074
  this.elementMemoization = true;
4074
4075
  this.nullOnErrors = true;
4075
4076
  const localElementIndex = elementIndex;
@@ -4107,7 +4108,68 @@ var StepModelBase = class {
4107
4108
  }
4108
4109
  const expressIDMap = new InterpolationSearchTable32(expressIdTable, expressIdsAlreadySorted);
4109
4110
  this.expressIDMap_ = expressIDMap;
4110
- this.elementIndex_ = localElementIndex;
4111
+ const count = inlineElementEnd;
4112
+ const address = new Uint32Array(count);
4113
+ const lengths = new Uint32Array(count);
4114
+ const typeIDs = new Int32Array(count);
4115
+ const expressIDs = new Uint32Array(firstInlineElement);
4116
+ let complexEntries = void 0;
4117
+ for (let localID = 0; localID < count; ++localID) {
4118
+ const element = localElementIndex[localID];
4119
+ address[localID] = element.address;
4120
+ lengths[localID] = element.length;
4121
+ typeIDs[localID] = element.typeID === void 0 ? -1 : element.typeID;
4122
+ if (localID < firstInlineElement) {
4123
+ expressIDs[localID] = element.expressID;
4124
+ }
4125
+ if (element.multiMapping !== void 0) {
4126
+ (complexEntries ??= /* @__PURE__ */ new Map()).set(localID, element);
4127
+ }
4128
+ }
4129
+ this.address_ = address;
4130
+ this.length_ = lengths;
4131
+ this.typeID_ = typeIDs;
4132
+ this.expressID_ = expressIDs;
4133
+ this.count_ = count;
4134
+ this.firstInlineElement_ = firstInlineElement;
4135
+ this.complexEntries_ = complexEntries;
4136
+ }
4137
+ /**
4138
+ * Materialise the descriptor object for a local ID from the columns. Only the
4139
+ * persistent scalars are set; lazy fields (vtable, buffer, entity) are filled
4140
+ * in on demand by populateVtableEntry / entity construction.
4141
+ *
4142
+ * @param localID The local ID to build a descriptor for.
4143
+ * @return {StepEntityInternalReferencePrivate} The descriptor.
4144
+ */
4145
+ makeDescriptor(localID) {
4146
+ const typeID = this.typeID_[localID];
4147
+ return {
4148
+ address: this.address_[localID],
4149
+ length: this.length_[localID],
4150
+ typeID: typeID === -1 ? void 0 : typeID,
4151
+ expressID: localID < this.firstInlineElement_ ? this.expressID_[localID] : void 0
4152
+ };
4153
+ }
4154
+ /**
4155
+ * Get the (cached or freshly materialised) descriptor for a local ID. The
4156
+ * same object is returned for repeated calls until invalidate(), so entities
4157
+ * built on it and populateVtableEntry() mutations agree.
4158
+ *
4159
+ * @param localID The local ID to get a descriptor for.
4160
+ * @return {StepEntityInternalReferencePrivate} The descriptor.
4161
+ */
4162
+ entry(localID) {
4163
+ const complex = this.complexEntries_?.get(localID);
4164
+ if (complex !== void 0) {
4165
+ return complex;
4166
+ }
4167
+ let descriptor = this.descriptorCache_[localID];
4168
+ if (descriptor === void 0) {
4169
+ descriptor = this.makeDescriptor(localID);
4170
+ this.descriptorCache_[localID] = descriptor;
4171
+ }
4172
+ return descriptor;
4111
4173
  }
4112
4174
  /**
4113
4175
  * Invalidate the cache store for this, so new items will be created.
@@ -4118,26 +4180,26 @@ var StepModelBase = class {
4118
4180
  invalidate(dropVtable = false) {
4119
4181
  if (dropVtable) {
4120
4182
  this.vtableBuilder_.clear(true);
4121
- for (const item of this.elementIndex_) {
4122
- if (Array.isArray(item)) {
4123
- for (const subItem of item) {
4124
- subItem.buffer = void 0;
4125
- subItem.entity = void 0;
4126
- subItem.vtable = void 0;
4127
- subItem.vtableCount = void 0;
4128
- subItem.vtableIndex = void 0;
4129
- }
4130
- continue;
4183
+ this.descriptorCache_ = [];
4184
+ if (this.complexEntries_ !== void 0) {
4185
+ for (const item of this.complexEntries_.values()) {
4186
+ item.buffer = void 0;
4187
+ item.entity = void 0;
4188
+ item.vtable = void 0;
4189
+ item.vtableCount = void 0;
4190
+ item.vtableIndex = void 0;
4131
4191
  }
4132
- item.buffer = void 0;
4133
- item.entity = void 0;
4134
- item.vtable = void 0;
4135
- item.vtableCount = void 0;
4136
- item.vtableIndex = void 0;
4137
4192
  }
4138
4193
  } else {
4139
- for (const item of this.elementIndex_) {
4140
- item.entity = void 0;
4194
+ for (const item of this.descriptorCache_) {
4195
+ if (item !== void 0) {
4196
+ item.entity = void 0;
4197
+ }
4198
+ }
4199
+ if (this.complexEntries_ !== void 0) {
4200
+ for (const item of this.complexEntries_.values()) {
4201
+ item.entity = void 0;
4202
+ }
4141
4203
  }
4142
4204
  }
4143
4205
  }
@@ -4171,10 +4233,10 @@ var StepModelBase = class {
4171
4233
  * @return {boolean} Did the vtable entry populate correctly?
4172
4234
  */
4173
4235
  populateVtableEntry(localID) {
4174
- if (localID > this.elementIndex_.length) {
4236
+ if (localID >= this.count_) {
4175
4237
  throw new Error(`Invalid localID ${localID}`);
4176
4238
  }
4177
- const element = this.elementIndex_[localID];
4239
+ const element = this.entry(localID);
4178
4240
  if (element.vtableIndex !== void 0 || element.typeID === 0) {
4179
4241
  return true;
4180
4242
  }
@@ -4196,10 +4258,10 @@ var StepModelBase = class {
4196
4258
  * @throws {Error} Throws an error if the ID is invalid.
4197
4259
  */
4198
4260
  populateBufferEntry(localID) {
4199
- if (localID > this.elementIndex_.length) {
4261
+ if (localID >= this.count_) {
4200
4262
  throw new Error(`Invalid localID ${localID}`);
4201
4263
  }
4202
- const element = this.elementIndex_[localID];
4264
+ const element = this.entry(localID);
4203
4265
  element.buffer = this.buffer_;
4204
4266
  }
4205
4267
  /**
@@ -4216,7 +4278,7 @@ var StepModelBase = class {
4216
4278
  * @return {number} The number of elements.
4217
4279
  */
4218
4280
  get size() {
4219
- return this.elementIndex_.length;
4281
+ return this.count_;
4220
4282
  }
4221
4283
  /**
4222
4284
  * Get an inline element by address.
@@ -4292,10 +4354,10 @@ var StepModelBase = class {
4292
4354
  * if none exists.
4293
4355
  */
4294
4356
  getTypedElementByLocalID(localID, type) {
4295
- if (localID > this.elementIndex_.length) {
4357
+ if (localID >= this.count_) {
4296
4358
  return;
4297
4359
  }
4298
- const element = this.elementIndex_[localID];
4360
+ const element = this.entry(localID);
4299
4361
  const multiMapping = element.multiMapping;
4300
4362
  if (multiMapping !== void 0) {
4301
4363
  let multiElements = element.multiEntity;
@@ -4344,8 +4406,9 @@ var StepModelBase = class {
4344
4406
  * @return {Uint32Array} express ID array
4345
4407
  */
4346
4408
  mapLocalIDsToExpressIDs(from) {
4347
- const index = this.elementIndex_;
4348
- return from.map((value) => index[value]?.expressID ?? TriangleElementMap.NO_ELEMENT);
4409
+ const firstInlineElement = this.firstInlineElement_;
4410
+ const expressIDs = this.expressID_;
4411
+ return from.map((value) => value < firstInlineElement ? expressIDs[value] : TriangleElementMap.NO_ELEMENT);
4349
4412
  }
4350
4413
  /**
4351
4414
  * Given an express ID, return the matching element if one exists.
@@ -4355,8 +4418,7 @@ var StepModelBase = class {
4355
4418
  * otherwise undefined.
4356
4419
  */
4357
4420
  getExpressIDByLocalID(localID) {
4358
- const index = this.elementIndex_;
4359
- return index[localID]?.expressID;
4421
+ return localID < this.firstInlineElement_ ? this.expressID_[localID] : void 0;
4360
4422
  }
4361
4423
  /**
4362
4424
  * Given a local ID (i.e. dense index/reference), return the matching element if one
@@ -4367,10 +4429,10 @@ var StepModelBase = class {
4367
4429
  * if none exists.
4368
4430
  */
4369
4431
  getElementByLocalID(localID) {
4370
- if (localID > this.elementIndex_.length) {
4432
+ if (localID >= this.count_) {
4371
4433
  return;
4372
4434
  }
4373
- const element = this.elementIndex_[localID];
4435
+ const element = this.entry(localID);
4374
4436
  let entity = element.entity;
4375
4437
  const multiMapping = element.multiMapping;
4376
4438
  if (multiMapping !== void 0) {
@@ -4515,7 +4577,7 @@ var StepModelBase = class {
4515
4577
  * @yields An element per iteration for all the elements in this.
4516
4578
  */
4517
4579
  *[Symbol.iterator]() {
4518
- for (let localID = 0, endID = this.elementIndex_.length; localID < endID; ++localID) {
4580
+ for (let localID = 0, endID = this.count_; localID < endID; ++localID) {
4519
4581
  const foundElement = this.getElementByLocalID(localID);
4520
4582
  if (foundElement !== void 0) {
4521
4583
  yield foundElement;
@@ -69650,7 +69712,7 @@ IfcStepParser.Instance = new IfcStepParser();
69650
69712
  var ifc_step_parser_default = IfcStepParser;
69651
69713
 
69652
69714
  // compiled/src/version/version.js
69653
- var versionString = "Conway Web-Ifc Shim v1.369.1178";
69715
+ var versionString = "Conway Web-Ifc Shim v1.372.1179";
69654
69716
 
69655
69717
  // compiled/src/statistics/statistics.js
69656
69718
  var Statistics = class {
@@ -22,7 +22,14 @@ export default abstract class StepModelBase<EntityTypeIDs extends number, BaseEn
22
22
  private readonly vtableBuilder_;
23
23
  private readonly expressIDMap_;
24
24
  private readonly inlineAddressMap_;
25
- private readonly elementIndex_;
25
+ private readonly address_;
26
+ private readonly length_;
27
+ private readonly typeID_;
28
+ private readonly expressID_;
29
+ private readonly count_;
30
+ private readonly firstInlineElement_;
31
+ private descriptorCache_;
32
+ private readonly complexEntries_?;
26
33
  /**
27
34
  * Will this model memoize elements, set to false to disable,
28
35
  * true to enable.
@@ -48,6 +55,24 @@ export default abstract class StepModelBase<EntityTypeIDs extends number, BaseEn
48
55
  * ownership of this array in the sense it will modify values/unfold inline elements etc.
49
56
  */
50
57
  constructor(schema: StepEntitySchema<EntityTypeIDs, BaseEntity>, buffer_: Uint8Array, elementIndex: StepIndexEntry<EntityTypeIDs>[]);
58
+ /**
59
+ * Materialise the descriptor object for a local ID from the columns. Only the
60
+ * persistent scalars are set; lazy fields (vtable, buffer, entity) are filled
61
+ * in on demand by populateVtableEntry / entity construction.
62
+ *
63
+ * @param localID The local ID to build a descriptor for.
64
+ * @return {StepEntityInternalReferencePrivate} The descriptor.
65
+ */
66
+ private makeDescriptor;
67
+ /**
68
+ * Get the (cached or freshly materialised) descriptor for a local ID. The
69
+ * same object is returned for repeated calls until invalidate(), so entities
70
+ * built on it and populateVtableEntry() mutations agree.
71
+ *
72
+ * @param localID The local ID to get a descriptor for.
73
+ * @return {StepEntityInternalReferencePrivate} The descriptor.
74
+ */
75
+ private entry;
51
76
  /**
52
77
  * Invalidate the cache store for this, so new items will be created.
53
78
  *
@@ -1 +1 @@
1
- {"version":3,"file":"step_model_base.d.ts","sourceRoot":"","sources":["../../../src/step/step_model_base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,cAAc,MAAM,oBAAoB,CAAA;AAC/C,OAAO,gBAAgB,MAAM,sBAAsB,CAAA;AACnD,OAAO,2BAAmE,MAAM,kCAAkC,CAAA;AAClH,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,qBAAqB,EAAE,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAA;AAChG,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAGlE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAGxD;;GAEG;AACH,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,aAAa,CACzC,aAAa,SAAS,MAAM,EAC5B,UAAU,SAAS,cAAc,CAAC,aAAa,CAAC,GAAG,cAAc,CAAC,aAAa,CAAC,CAClF,YAAW,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK;aAsClB,MAAM,EAAE,gBAAgB,CAAE,aAAa,EAAE,UAAU,CAAE;IACrE,OAAO,CAAC,QAAQ,CAAC,OAAO;IAtC1B,kBAAyB,SAAS,EAAE,aAAa,CAAC,aAAa,CAAC,CAAA;I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D;;;;;;;OAOG;IACI,2BAA2B,CAAE,IAAI,EAAE,iBAAiB,GACzD,iBAAiB,GAAG,SAAS;IAK/B;;;;;;;OAOG;IACI,uBAAuB,CAAE,IAAI,EAAE,iBAAiB,GAAI,aAAa,GAAG,SAAS;CAIrF"}
@@ -18,6 +18,11 @@ export default class StepModelBase {
18
18
  this.schema = schema;
19
19
  this.buffer_ = buffer_;
20
20
  this.vtableBuilder_ = new StepVtableBuilder();
21
+ // Lazily-materialised descriptors for touched entities, indexed by local ID;
22
+ // dropped wholesale by invalidate(). A sparse array, not a Map: at PSB/SKYLARK
23
+ // scale most entities are touched during extraction, where a Map's ~45 B/entry
24
+ // overhead would dominate — an array slot is 8 B.
25
+ this.descriptorCache_ = [];
21
26
  /**
22
27
  * Will this model memoize elements, set to false to disable,
23
28
  * true to enable.
@@ -66,14 +71,74 @@ export default class StepModelBase {
66
71
  previousExpressID = currentExpressId;
67
72
  }
68
73
  const expressIDMap = new InterpolationSearchTable32(expressIdTable, expressIdsAlreadySorted);
69
- // Continguous dense array map from express IDs.
70
- // for (const element of elementIndex) {
71
- // if (element.expressID !== void 0) {
72
- // expressIDMap.set(element.expressID, indexId++)
73
- // }
74
- // }
75
74
  this.expressIDMap_ = expressIDMap;
76
- this.elementIndex_ = localElementIndex;
75
+ // Pack the persistent scalar fields into columns and pull the rare
76
+ // multiMapping (complex/external-mapping) entries aside as retained
77
+ // descriptor objects. After this the `localElementIndex` object array is
78
+ // unreferenced and collected — its per-entity objects no longer pin memory.
79
+ const count = inlineElementEnd;
80
+ const address = new Uint32Array(count);
81
+ const lengths = new Uint32Array(count);
82
+ const typeIDs = new Int32Array(count);
83
+ const expressIDs = new Uint32Array(firstInlineElement);
84
+ let complexEntries = void 0;
85
+ for (let localID = 0; localID < count; ++localID) {
86
+ const element = localElementIndex[localID];
87
+ address[localID] = element.address;
88
+ lengths[localID] = element.length;
89
+ typeIDs[localID] = element.typeID === void 0 ? -1 : element.typeID;
90
+ if (localID < firstInlineElement) {
91
+ expressIDs[localID] = element.expressID;
92
+ }
93
+ if (element.multiMapping !== void 0) {
94
+ (complexEntries ??= new Map()).set(localID, element);
95
+ }
96
+ }
97
+ this.address_ = address;
98
+ this.length_ = lengths;
99
+ this.typeID_ = typeIDs;
100
+ this.expressID_ = expressIDs;
101
+ this.count_ = count;
102
+ this.firstInlineElement_ = firstInlineElement;
103
+ this.complexEntries_ = complexEntries;
104
+ }
105
+ /**
106
+ * Materialise the descriptor object for a local ID from the columns. Only the
107
+ * persistent scalars are set; lazy fields (vtable, buffer, entity) are filled
108
+ * in on demand by populateVtableEntry / entity construction.
109
+ *
110
+ * @param localID The local ID to build a descriptor for.
111
+ * @return {StepEntityInternalReferencePrivate} The descriptor.
112
+ */
113
+ makeDescriptor(localID) {
114
+ const typeID = this.typeID_[localID];
115
+ return {
116
+ address: this.address_[localID],
117
+ length: this.length_[localID],
118
+ typeID: typeID === -1 ? void 0 : typeID,
119
+ expressID: localID < this.firstInlineElement_ ?
120
+ this.expressID_[localID] : void 0,
121
+ };
122
+ }
123
+ /**
124
+ * Get the (cached or freshly materialised) descriptor for a local ID. The
125
+ * same object is returned for repeated calls until invalidate(), so entities
126
+ * built on it and populateVtableEntry() mutations agree.
127
+ *
128
+ * @param localID The local ID to get a descriptor for.
129
+ * @return {StepEntityInternalReferencePrivate} The descriptor.
130
+ */
131
+ entry(localID) {
132
+ const complex = this.complexEntries_?.get(localID);
133
+ if (complex !== void 0) {
134
+ return complex;
135
+ }
136
+ let descriptor = this.descriptorCache_[localID];
137
+ if (descriptor === void 0) {
138
+ descriptor = this.makeDescriptor(localID);
139
+ this.descriptorCache_[localID] = descriptor;
140
+ }
141
+ return descriptor;
77
142
  }
78
143
  /**
79
144
  * Invalidate the cache store for this, so new items will be created.
@@ -84,27 +149,32 @@ export default class StepModelBase {
84
149
  invalidate(dropVtable = false) {
85
150
  if (dropVtable) {
86
151
  this.vtableBuilder_.clear(true);
87
- for (const item of this.elementIndex_) {
88
- if (Array.isArray(item)) {
89
- for (const subItem of item) {
90
- subItem.buffer = void 0;
91
- subItem.entity = void 0;
92
- subItem.vtable = void 0;
93
- subItem.vtableCount = void 0;
94
- subItem.vtableIndex = void 0;
95
- }
96
- continue;
152
+ // Common entries: drop their materialised descriptors outright — this is
153
+ // the memory the old retained object array could never release. They
154
+ // rematerialise from the columns on next access.
155
+ this.descriptorCache_ = [];
156
+ // Complex (multiMapping) entries are retained objects; clear their lazy
157
+ // fields in place, matching the previous per-entry reset.
158
+ if (this.complexEntries_ !== void 0) {
159
+ for (const item of this.complexEntries_.values()) {
160
+ item.buffer = void 0;
161
+ item.entity = void 0;
162
+ item.vtable = void 0;
163
+ item.vtableCount = void 0;
164
+ item.vtableIndex = void 0;
97
165
  }
98
- item.buffer = void 0;
99
- item.entity = void 0;
100
- item.vtable = void 0;
101
- item.vtableCount = void 0;
102
- item.vtableIndex = void 0;
103
166
  }
104
167
  }
105
168
  else {
106
- for (const item of this.elementIndex_) {
107
- item.entity = void 0;
169
+ for (const item of this.descriptorCache_) {
170
+ if (item !== void 0) {
171
+ item.entity = void 0;
172
+ }
173
+ }
174
+ if (this.complexEntries_ !== void 0) {
175
+ for (const item of this.complexEntries_.values()) {
176
+ item.entity = void 0;
177
+ }
108
178
  }
109
179
  }
110
180
  }
@@ -138,10 +208,10 @@ export default class StepModelBase {
138
208
  * @return {boolean} Did the vtable entry populate correctly?
139
209
  */
140
210
  populateVtableEntry(localID) {
141
- if (localID > this.elementIndex_.length) {
211
+ if (localID >= this.count_) {
142
212
  throw new Error(`Invalid localID ${localID}`);
143
213
  }
144
- const element = this.elementIndex_[localID];
214
+ const element = this.entry(localID);
145
215
  if (element.vtableIndex !== void 0 || element.typeID === 0) {
146
216
  return true;
147
217
  }
@@ -163,10 +233,10 @@ export default class StepModelBase {
163
233
  * @throws {Error} Throws an error if the ID is invalid.
164
234
  */
165
235
  populateBufferEntry(localID) {
166
- if (localID > this.elementIndex_.length) {
236
+ if (localID >= this.count_) {
167
237
  throw new Error(`Invalid localID ${localID}`);
168
238
  }
169
- const element = this.elementIndex_[localID];
239
+ const element = this.entry(localID);
170
240
  element.buffer = this.buffer_;
171
241
  }
172
242
  /**
@@ -183,7 +253,7 @@ export default class StepModelBase {
183
253
  * @return {number} The number of elements.
184
254
  */
185
255
  get size() {
186
- return this.elementIndex_.length;
256
+ return this.count_;
187
257
  }
188
258
  /**
189
259
  * Get an inline element by address.
@@ -259,10 +329,10 @@ export default class StepModelBase {
259
329
  * if none exists.
260
330
  */
261
331
  getTypedElementByLocalID(localID, type) {
262
- if (localID > this.elementIndex_.length) {
332
+ if (localID >= this.count_) {
263
333
  return;
264
334
  }
265
- const element = this.elementIndex_[localID];
335
+ const element = this.entry(localID);
266
336
  const multiMapping = element.multiMapping;
267
337
  if (multiMapping !== void 0) {
268
338
  let multiElements = element.multiEntity;
@@ -321,8 +391,9 @@ export default class StepModelBase {
321
391
  * @return {Uint32Array} express ID array
322
392
  */
323
393
  mapLocalIDsToExpressIDs(from) {
324
- const index = this.elementIndex_;
325
- return from.map((value) => index[value]?.expressID ?? TriangleElementMap.NO_ELEMENT);
394
+ const firstInlineElement = this.firstInlineElement_;
395
+ const expressIDs = this.expressID_;
396
+ return from.map((value) => value < firstInlineElement ? expressIDs[value] : TriangleElementMap.NO_ELEMENT);
326
397
  }
327
398
  /**
328
399
  * Given an express ID, return the matching element if one exists.
@@ -332,8 +403,7 @@ export default class StepModelBase {
332
403
  * otherwise undefined.
333
404
  */
334
405
  getExpressIDByLocalID(localID) {
335
- const index = this.elementIndex_;
336
- return index[localID]?.expressID;
406
+ return localID < this.firstInlineElement_ ? this.expressID_[localID] : void 0;
337
407
  }
338
408
  /**
339
409
  * Given a local ID (i.e. dense index/reference), return the matching element if one
@@ -344,10 +414,10 @@ export default class StepModelBase {
344
414
  * if none exists.
345
415
  */
346
416
  getElementByLocalID(localID) {
347
- if (localID > this.elementIndex_.length) {
417
+ if (localID >= this.count_) {
348
418
  return;
349
419
  }
350
- const element = this.elementIndex_[localID];
420
+ const element = this.entry(localID);
351
421
  let entity = element.entity;
352
422
  const multiMapping = element.multiMapping;
353
423
  if (multiMapping !== void 0) {
@@ -505,7 +575,7 @@ export default class StepModelBase {
505
575
  * @yields An element per iteration for all the elements in this.
506
576
  */
507
577
  *[Symbol.iterator]() {
508
- for (let localID = 0, endID = this.elementIndex_.length; localID < endID; ++localID) {
578
+ for (let localID = 0, endID = this.count_; localID < endID; ++localID) {
509
579
  const foundElement = this.getElementByLocalID(localID);
510
580
  if (foundElement !== void 0) {
511
581
  yield foundElement;
@@ -5,5 +5,5 @@
5
5
  // only the first segment (major) is meaningful and is the one CI carries forward.
6
6
  // Must stay in `vN.N.N` shape: the CI stamp regex, scripts/updateVersion.mjs, and
7
7
  // statistics.ts all match `v\d+\.\d+\.\d+`.
8
- const versionString = 'Conway Web-Ifc Shim v1.369.1178';
8
+ const versionString = 'Conway Web-Ifc Shim v1.372.1179';
9
9
  export { versionString };