@bldrs-ai/conway 1.509.1435 → 1.511.1441

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 (73) hide show
  1. package/compiled/examples/browser-bundled.cjs +410 -16
  2. package/compiled/examples/cli-bundled.cjs +544 -18
  3. package/compiled/examples/cli-step-bundled.cjs +312 -16
  4. package/compiled/examples/validator-bundled.cjs +410 -16
  5. package/compiled/src/compat/web-ifc/ifc_api.d.ts +33 -0
  6. package/compiled/src/compat/web-ifc/ifc_api.d.ts.map +1 -1
  7. package/compiled/src/compat/web-ifc/ifc_api.js +47 -0
  8. package/compiled/src/compat/web-ifc/ifc_api_deferred_open.test.js +29 -0
  9. package/compiled/src/compat/web-ifc/ifc_api_model_passthrough.d.ts +8 -0
  10. package/compiled/src/compat/web-ifc/ifc_api_model_passthrough.d.ts.map +1 -1
  11. package/compiled/src/compat/web-ifc/ifc_api_model_passthrough_factory.d.ts +14 -0
  12. package/compiled/src/compat/web-ifc/ifc_api_model_passthrough_factory.d.ts.map +1 -1
  13. package/compiled/src/compat/web-ifc/ifc_api_model_passthrough_factory.js +33 -0
  14. package/compiled/src/compat/web-ifc/ifc_api_proxy_ap214.d.ts +7 -0
  15. package/compiled/src/compat/web-ifc/ifc_api_proxy_ap214.d.ts.map +1 -1
  16. package/compiled/src/compat/web-ifc/ifc_api_proxy_ap214.js +16 -0
  17. package/compiled/src/compat/web-ifc/ifc_api_proxy_ifc.d.ts +64 -0
  18. package/compiled/src/compat/web-ifc/ifc_api_proxy_ifc.d.ts.map +1 -1
  19. package/compiled/src/compat/web-ifc/ifc_api_proxy_ifc.js +293 -30
  20. package/compiled/src/compat/web-ifc/ifc_api_streamed_open.test.js +29 -0
  21. package/compiled/src/ifc/ifc_demand_extraction.test.js +12 -1
  22. package/compiled/src/ifc/ifc_geometry_extraction.d.ts +35 -0
  23. package/compiled/src/ifc/ifc_geometry_extraction.d.ts.map +1 -1
  24. package/compiled/src/ifc/ifc_geometry_extraction.js +142 -2
  25. package/compiled/src/ifc/ifc_step_parser.d.ts +23 -1
  26. package/compiled/src/ifc/ifc_step_parser.d.ts.map +1 -1
  27. package/compiled/src/ifc/ifc_step_parser.js +23 -1
  28. package/compiled/src/ifc/ifc_stream_open.d.ts +28 -1
  29. package/compiled/src/ifc/ifc_stream_open.d.ts.map +1 -1
  30. package/compiled/src/ifc/ifc_stream_open.js +44 -1
  31. package/compiled/src/ifc/ifc_stream_open.test.js +10 -1
  32. package/compiled/src/index.d.ts +3 -2
  33. package/compiled/src/index.d.ts.map +1 -1
  34. package/compiled/src/index.js +3 -2
  35. package/compiled/src/namespace_surface.test.js +3 -0
  36. package/compiled/src/step/parsing/byte_source.d.ts +98 -0
  37. package/compiled/src/step/parsing/byte_source.d.ts.map +1 -1
  38. package/compiled/src/step/parsing/byte_source.js +71 -0
  39. package/compiled/src/step/parsing/byte_source.test.d.ts +2 -0
  40. package/compiled/src/step/parsing/byte_source.test.d.ts.map +1 -0
  41. package/compiled/src/step/parsing/byte_source.test.js +47 -0
  42. package/compiled/src/step/parsing/byte_source_node.d.ts +41 -0
  43. package/compiled/src/step/parsing/byte_source_node.d.ts.map +1 -0
  44. package/compiled/src/step/parsing/byte_source_node.js +54 -0
  45. package/compiled/src/step/parsing/express_ref_scan.d.ts +20 -0
  46. package/compiled/src/step/parsing/express_ref_scan.d.ts.map +1 -0
  47. package/compiled/src/step/parsing/express_ref_scan.js +91 -0
  48. package/compiled/src/step/parsing/express_ref_scan.test.d.ts +2 -0
  49. package/compiled/src/step/parsing/express_ref_scan.test.d.ts.map +1 -0
  50. package/compiled/src/step/parsing/express_ref_scan.test.js +28 -0
  51. package/compiled/src/step/parsing/step_parser.d.ts +7 -4
  52. package/compiled/src/step/parsing/step_parser.d.ts.map +1 -1
  53. package/compiled/src/step/parsing/step_parser.js +25 -6
  54. package/compiled/src/step/parsing/streaming_index_builder.d.ts +3 -3
  55. package/compiled/src/step/parsing/streaming_index_builder.d.ts.map +1 -1
  56. package/compiled/src/step/parsing/streaming_index_builder.js +27 -7
  57. package/compiled/src/step/parsing/streaming_index_builder_async.test.js +13 -1
  58. package/compiled/src/step/step_buffer_provider.d.ts +44 -0
  59. package/compiled/src/step/step_buffer_provider.d.ts.map +1 -1
  60. package/compiled/src/step/step_buffer_provider.js +56 -8
  61. package/compiled/src/step/step_buffer_provider.test.js +14 -0
  62. package/compiled/src/step/step_entity_base.d.ts +15 -0
  63. package/compiled/src/step/step_entity_base.d.ts.map +1 -1
  64. package/compiled/src/step/step_entity_base.js +33 -0
  65. package/compiled/src/step/step_model_base.d.ts +62 -0
  66. package/compiled/src/step/step_model_base.d.ts.map +1 -1
  67. package/compiled/src/step/step_model_base.js +136 -0
  68. package/compiled/src/stream/index.d.ts +3 -2
  69. package/compiled/src/stream/index.d.ts.map +1 -1
  70. package/compiled/src/stream/index.js +3 -2
  71. package/compiled/src/version/version.js +1 -1
  72. package/compiled/tsconfig.tsbuildinfo +1 -1
  73. package/package.json +1 -1
@@ -4430,8 +4430,13 @@ export class IfcGeometryExtraction {
4430
4430
  const styledItems = this.model.types(IfcStyledItem);
4431
4431
  for (const styledItem of styledItems) {
4432
4432
  try {
4433
- if (styledItem.Item !== null) {
4434
- this.materials.styledItemMap.set(styledItem.Item.localID, styledItem.localID);
4433
+ // IfcStyledItem.Item — same vtable slot as the generated
4434
+ // getter's extractElement(0, 0, 1, true, ...). Hydrating Item
4435
+ // would acquire the faceset record (often the packed geometry
4436
+ // itself) for every styled item at once.
4437
+ const itemLocalID = styledItem.extractReferenceLocalID(0, 0, 1, true);
4438
+ if (itemLocalID !== null) {
4439
+ this.materials.styledItemMap.set(itemLocalID, styledItem.localID);
4435
4440
  }
4436
4441
  }
4437
4442
  catch (ex) {
@@ -4736,6 +4741,141 @@ export class IfcGeometryExtraction {
4736
4741
  this.extractProductGeometry(element);
4737
4742
  return true;
4738
4743
  }
4744
+ /**
4745
+ * Page in every record {@link prepareDemandExtraction} will read, so
4746
+ * the relationship sweeps succeed on a windowed source. Call before
4747
+ * the first prepare on a model whose source is external.
4748
+ *
4749
+ * Pins the prep-type records themselves (and a 1-hop of product /
4750
+ * material records the relationship getters hydrate). Does **not**
4751
+ * BFS-pin styled-item Item closures — those are facesets, and
4752
+ * walking them here pulled most of the file into the windowed LRU
4753
+ * before the first product extract.
4754
+ *
4755
+ * @return {Promise<Set<number>>} Pinned local IDs — caller must
4756
+ * {@link StepModelBase.unpinLocalIDs} after prepare/extract.
4757
+ */
4758
+ async ensureResidentForDemandPrep() {
4759
+ const pinned = new Set();
4760
+ if (!this.model.isSourceExternal) {
4761
+ return pinned;
4762
+ }
4763
+ // Small trees: project units, material-definition style stacks.
4764
+ for (const type of [IfcProject, IfcMaterialDefinitionRepresentation]) {
4765
+ for (const expressID of this.model.expressIDsOfTypes(type)) {
4766
+ await this.model.ensureResidentClosureByExpressID(expressID, void 0, pinned);
4767
+ }
4768
+ }
4769
+ const recordOnlyTypes = [
4770
+ IfcRelAssociatesMaterial,
4771
+ IfcRelVoidsElement,
4772
+ IfcStyledItem,
4773
+ IfcRelAggregates,
4774
+ ];
4775
+ for (const type of recordOnlyTypes) {
4776
+ for (const expressID of this.model.expressIDsOfTypes(type)) {
4777
+ const localID = this.model.resolveExpressID(expressID);
4778
+ if (localID === void 0 || pinned.has(localID)) {
4779
+ continue;
4780
+ }
4781
+ await this.model.ensureResidentByLocalID(localID);
4782
+ this.model.pinByLocalID(localID);
4783
+ pinned.add(localID);
4784
+ }
4785
+ }
4786
+ // Relationship getters hydrate the related product / material
4787
+ // records (not their geometry). Pin that 1-hop so populate can
4788
+ // read `.localID` without a full closure walk.
4789
+ const oneHopTypes = [
4790
+ IfcRelAssociatesMaterial,
4791
+ IfcRelVoidsElement,
4792
+ IfcRelAggregates,
4793
+ ];
4794
+ for (const type of oneHopTypes) {
4795
+ for (const expressID of this.model.expressIDsOfTypes(type)) {
4796
+ const localID = this.model.resolveExpressID(expressID);
4797
+ if (localID === void 0) {
4798
+ continue;
4799
+ }
4800
+ for (const refExpressID of this.model.referencedExpressIDs(localID)) {
4801
+ const refLocalID = this.model.resolveExpressID(refExpressID);
4802
+ if (refLocalID === void 0 || pinned.has(refLocalID)) {
4803
+ continue;
4804
+ }
4805
+ await this.model.ensureResidentByLocalID(refLocalID);
4806
+ this.model.pinByLocalID(refLocalID);
4807
+ pinned.add(refLocalID);
4808
+ }
4809
+ }
4810
+ }
4811
+ return pinned;
4812
+ }
4813
+ /**
4814
+ * Page in the `#ref` closure a per-product extract will acquire,
4815
+ * including this product's voids, bound materials and styled items
4816
+ * (those are inverse — not written in the product record).
4817
+ *
4818
+ * @param localID The product's local ID.
4819
+ * @return {Promise<Set<number>>} Pinned local IDs — caller must unpin
4820
+ * after extract.
4821
+ */
4822
+ async ensureResidentForProductExtract(localID, seen) {
4823
+ if (!this.model.isSourceExternal) {
4824
+ return seen ?? new Set();
4825
+ }
4826
+ const extra = [];
4827
+ const voids = this.productToVoidGeometryMap.get(localID);
4828
+ if (voids !== void 0) {
4829
+ extra.push(...voids);
4830
+ }
4831
+ const material = this.materials.relMaterialsMap.get(localID);
4832
+ if (material !== void 0) {
4833
+ extra.push(material);
4834
+ }
4835
+ const visited = await this.model.ensureResidentClosureByLocalID(localID, extra, seen);
4836
+ const styleExtra = [];
4837
+ for (const visitedID of visited) {
4838
+ const styled = this.materials.styledItemMap.get(visitedID);
4839
+ if (styled !== void 0) {
4840
+ styleExtra.push(styled);
4841
+ }
4842
+ const definition = this.materials.materialDefinitionsMap.get(visitedID);
4843
+ if (definition !== void 0) {
4844
+ styleExtra.push(definition);
4845
+ }
4846
+ }
4847
+ if (styleExtra.length > 0) {
4848
+ await this.model.ensureResidentClosureByLocalID(localID, styleExtra, visited);
4849
+ }
4850
+ return visited;
4851
+ }
4852
+ /**
4853
+ * Page in the records {@link extractRelAggregateGeometry} will
4854
+ * acquire: the relationship, the relating product (and its voids)
4855
+ * and every related product.
4856
+ *
4857
+ * @param relAggregate The relationship to prefetch.
4858
+ * @return {Promise<Set<number>>} Pinned local IDs — caller must unpin
4859
+ * after extract.
4860
+ */
4861
+ async ensureResidentForAggregateExtract(relAggregate) {
4862
+ if (!this.model.isSourceExternal) {
4863
+ return new Set();
4864
+ }
4865
+ const pinned = await this.model.ensureResidentClosureByLocalID(relAggregate.localID);
4866
+ const relating = relAggregate.RelatingObject;
4867
+ if (relating !== null && relating !== void 0) {
4868
+ await this.ensureResidentForProductExtract(relating.localID, pinned);
4869
+ }
4870
+ const related = relAggregate.RelatedObjects;
4871
+ if (related === null || related === void 0) {
4872
+ return pinned;
4873
+ }
4874
+ for (const product of related) {
4875
+ await this.ensureResidentForProductExtract(product.localID, pinned);
4876
+ }
4877
+ return pinned;
4878
+ }
4739
4879
  /**
4740
4880
  * The whole-model walk's SECOND product pass, shared with the demand
4741
4881
  * pump: for every IfcRelAggregates, re-extract the related products
@@ -2,7 +2,7 @@ import ParsingBuffer from "../parsing/parsing_buffer.js";
2
2
  import StepParser, { ParseProgressCallback, ParseResult } from "../step/parsing/step_parser.js";
3
3
  import EntityTypesIfc from "./ifc4_gen/entity_types_ifc.gen.js";
4
4
  import IfcStepModel from "./ifc_step_model.js";
5
- import { ByteSource } from "../step/parsing/byte_source.js";
5
+ import { ByteSource, ReadableByteSource } from "../step/parsing/byte_source.js";
6
6
  import { StepExternalByteStore } from "../step/step_buffer_provider.js";
7
7
  /**
8
8
  * Parser for taking IFC file serialized in step and turning them into a lazily parsed model.
@@ -78,5 +78,27 @@ export default class IfcStepParser extends StepParser<EntityTypesIfc> {
78
78
  ParseResult,
79
79
  IfcStepModel | undefined
80
80
  ];
81
+ /**
82
+ * Cooperative twin of {@link parseStreamToModel}: the index build
83
+ * yields to the event loop and can fill windows from an async
84
+ * {@link ReadableByteSource} (an OPFS `File.slice()` store). The
85
+ * model is still windowed — geometry extract must
86
+ * `ensureResident` first.
87
+ *
88
+ * @param source Sync or async byte source feeding the parse.
89
+ * @param store Async external store backing the windowed model.
90
+ * @param opts Optional window sizing plus parse progress.
91
+ * @return {Promise<[ParseResult, IfcStepModel | undefined]>} The
92
+ * parse result and the windowed model.
93
+ */
94
+ parseStreamToModelAsync(source: ReadableByteSource, store: StepExternalByteStore, opts?: {
95
+ pool?: number;
96
+ chunkBytes?: number;
97
+ maxResidentChunks?: number;
98
+ onProgress?: (absoluteByteCursor: number) => void;
99
+ }): Promise<[
100
+ ParseResult,
101
+ IfcStepModel | undefined
102
+ ]>;
81
103
  }
82
104
  //# sourceMappingURL=ifc_step_parser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ifc_step_parser.d.ts","sourceRoot":"","sources":["../../../src/ifc/ifc_step_parser.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,2BAA2B,CAAA;AACrD,OAAO,UAAU,EAAE,EAAC,qBAAqB,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AAC1F,OAAO,cAAc,MAAM,iCAAiC,CAAA;AAE5D,OAAO,YAAY,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAExD,OAAO,EACL,qBAAqB,EAEtB,MAAM,8BAA8B,CAAA;AAOrC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU,CAAE,cAAc,CAAE;IACrE;;OAEG;;IAKH;;;;;OAKG;IACH,gBAAuB,QAAQ,gBAAsB;IAErD;;;;;;;OAOG;IACI,gBAAgB,CACnB,KAAK,EAAE,aAAa,EACpB,UAAU,CAAC,EAAE,qBAAqB,GAAI,CAAC,WAAW,EAAE,YAAY,GAAG,SAAS,CAAC;IAMjF;;;;;;;;OAQG;IACU,qBAAqB,CAC9B,KAAK,EAAE,aAAa,EACpB,UAAU,CAAC,EAAE,qBAAqB,GAClC,OAAO,CAAC,CAAC,WAAW,EAAE,YAAY,GAAG,SAAS,CAAC,CAAC;IAMpD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACI,kBAAkB,CACrB,MAAM,EAAE,UAAU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CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;KAAE,GACzE;QAAC,WAAW;QAAE,YAAY,GAAG,SAAS;KAAC;IAmB3C;;;;;;;;;;;;OAYG;IACU,uBAAuB,CAChC,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,qBAAqB,EAC5B,IAAI,CAAC,EAAE;QACL,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,iBAAiB,CAAC,EAAE,MAAM,CAAA;QAC1B,UAAU,CAAC,EAAE,CAAE,kBAAkB,EAAE,MAAM,KAAM,IAAI,CAAA;KACpD,GACD,OAAO,CAAC,CAAC,WAAW,EAAE,YAAY,GAAG,SAAS,CAAC,CAAC;CAkBrD"}
@@ -1,7 +1,7 @@
1
1
  import StepParser from "../step/parsing/step_parser.js";
2
2
  import EntitTypesIfcSearch from "./ifc4_gen/entity_types_search.gen.js";
3
3
  import IfcStepModel from "./ifc_step_model.js";
4
- import { buildColumnarIndexStreaming } from "../step/parsing/streaming_index_builder.js";
4
+ import { buildColumnarIndexStreaming, buildColumnarIndexStreamingAsync, } from "../step/parsing/streaming_index_builder.js";
5
5
  import { WindowedStepBufferProvider, } from "../step/step_buffer_provider.js";
6
6
  /** Default moving-window size for the streaming index build (1 MiB). */
7
7
  // eslint-disable-next-line no-magic-numbers
@@ -78,6 +78,28 @@ class IfcStepParser extends StepParser {
78
78
  const provider = new WindowedStepBufferProvider(store, opts?.chunkBytes, opts?.maxResidentChunks);
79
79
  return [result, new IfcStepModel(void 0, columns, provider)];
80
80
  }
81
+ /**
82
+ * Cooperative twin of {@link parseStreamToModel}: the index build
83
+ * yields to the event loop and can fill windows from an async
84
+ * {@link ReadableByteSource} (an OPFS `File.slice()` store). The
85
+ * model is still windowed — geometry extract must
86
+ * `ensureResident` first.
87
+ *
88
+ * @param source Sync or async byte source feeding the parse.
89
+ * @param store Async external store backing the windowed model.
90
+ * @param opts Optional window sizing plus parse progress.
91
+ * @return {Promise<[ParseResult, IfcStepModel | undefined]>} The
92
+ * parse result and the windowed model.
93
+ */
94
+ async parseStreamToModelAsync(source, store, opts) {
95
+ if (store.byteLength !== source.byteLength) {
96
+ throw new Error(`Streaming store byteLength ${store.byteLength} does not match ` +
97
+ `source byteLength ${source.byteLength}`);
98
+ }
99
+ const { columns, result } = await buildColumnarIndexStreamingAsync(source, this, opts?.pool ?? DEFAULT_STREAM_POOL_BYTES, void 0, opts?.onProgress);
100
+ const provider = new WindowedStepBufferProvider(store, opts?.chunkBytes, opts?.maxResidentChunks);
101
+ return [result, new IfcStepModel(void 0, columns, provider)];
102
+ }
81
103
  }
82
104
  /**
83
105
  * An easily accessible and re-usable instance of the parser.
@@ -1,4 +1,4 @@
1
- import { ByteSource } from "../step/parsing/byte_source.js";
1
+ import { ByteSource, ReadableByteSource } from "../step/parsing/byte_source.js";
2
2
  import { StepIndexColumns } from "../step/parsing/columnar_index.js";
3
3
  import { StreamingIndexStats } from "../step/parsing/streaming_index_builder.js";
4
4
  import { ParseResult, StepHeader } from "../step/parsing/step_parser.js";
@@ -65,4 +65,31 @@ export interface StreamedIfcOpen {
65
65
  * @return {StreamedIfcOpen} The model + header, columns, and diagnostics.
66
66
  */
67
67
  export declare function openStreamedIfcModel(source: ByteSource, store: StepExternalByteStore, options?: StreamedIfcOpenOptions): StreamedIfcOpen;
68
+ /**
69
+ * Cooperative twin of {@link openStreamedIfcModel}: the index build
70
+ * yields to the event loop and can fill windows from an async
71
+ * {@link ReadableByteSource}. Pass a {@link StoreByteSource} wrapping
72
+ * `store` to parse a file that is already in OPFS without ever
73
+ * holding it as one `ArrayBuffer`.
74
+ *
75
+ * @param source Sync or async parse source.
76
+ * @param store The random-access store the model reads from afterwards.
77
+ * @param options See {@link StreamedIfcOpenOptions} plus `onProgress`.
78
+ * @return {Promise<StreamedIfcOpen>} The model + header, columns, diagnostics.
79
+ */
80
+ export declare function openStreamedIfcModelAsync(source: ReadableByteSource, store: StepExternalByteStore, options?: StreamedIfcOpenOptions & {
81
+ onProgress?: (absoluteByteCursor: number) => void;
82
+ }): Promise<StreamedIfcOpen>;
83
+ /**
84
+ * Open a windowed IFC model from a store alone — parse windows and
85
+ * post-parse reads share `store`. This is the M1b embedder entry for
86
+ * a file already sitting in OPFS.
87
+ *
88
+ * @param store The source of truth for the file bytes.
89
+ * @param options See {@link openStreamedIfcModelAsync}.
90
+ * @return {Promise<StreamedIfcOpen>} The model + header, columns, diagnostics.
91
+ */
92
+ export declare function openStreamedIfcModelFromStore(store: StepExternalByteStore, options?: StreamedIfcOpenOptions & {
93
+ onProgress?: (absoluteByteCursor: number) => void;
94
+ }): Promise<StreamedIfcOpen>;
68
95
  //# sourceMappingURL=ifc_stream_open.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ifc_stream_open.d.ts","sourceRoot":"","sources":["../../../src/ifc/ifc_stream_open.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,EAEL,mBAAmB,EACpB,MAAM,yCAAyC,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EACL,qBAAqB,EAEtB,MAAM,8BAA8B,CAAA;AACrC,OAAO,cAAc,MAAM,iCAAiC,CAAA;AAC5D,OAAO,YAAY,MAAM,kBAAkB,CAAA;AAI3C;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IAErC,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB,iEAAiE;IACjE,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B;;;;OAIG;IACH,eAAe,CAAC,EACd,CAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,M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AAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,SAAS,KAAM,IAAI,CAAA;CACrF;AAGD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAE9B,0EAA0E;IAC1E,KAAK,EAAE,YAAY,GAAG,SAAS,CAAA;IAE/B,wBAAwB;IACxB,MAAM,EAAE,WAAW,CAAA;IAEnB,8DAA8D;IAC9D,MAAM,EAAE,UAAU,CAAA;IAElB;;;;OAIG;IACH,OAAO,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAA;IAEzC,mDAAmD;IACnD,KAAK,EAAE,mBAAmB,CAAA;CAC3B;AAOD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,oBAAoB,CAChC,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,qBAAqB,EAC5B,OAAO,CAAC,EAAE,sBAAsB,GAAI,eAAe,CA4BtD;AAGD;;;;;;;;;;;GAWG;AACH,wBAAsB,yBAAyB,CAC3C,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,qBAAqB,EAC5B,OAAO,CAAC,EAAE,sBAAsB,GAAG;IACjC,UAAU,CAAC,EAAE,CAAE,kBAAkB,EAAE,MAAM,KAAM,IAAI,CAAA;CACpD,GAAI,OAAO,CAAC,eAAe,CAAC,CA6BhC;AAGD;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CACzC,KAAK,EAAE,qBAAqB,EAC5B,OAAO,CAAC,EAAE,sBAAsB,GAAG;IACjC,UAAU,CAAC,EAAE,CAAE,kBAAkB,EAAE,MAAM,KAAM,IAAI,CAAA;CACpD,GAAI,OAAO,CAAC,eAAe,CAAC,CAGhC"}
@@ -1,4 +1,5 @@
1
- import { buildColumnarIndexStreaming, } from "../step/parsing/streaming_index_builder.js";
1
+ import { StoreByteSource } from "../step/parsing/byte_source.js";
2
+ import { buildColumnarIndexStreaming, buildColumnarIndexStreamingAsync, } from "../step/parsing/streaming_index_builder.js";
2
3
  import { ParseResult } from "../step/parsing/step_parser.js";
3
4
  import { WindowedStepBufferProvider, } from "../step/step_buffer_provider.js";
4
5
  import IfcStepModel from "./ifc_step_model.js";
@@ -44,3 +45,45 @@ export function openStreamedIfcModel(source, store, options) {
44
45
  stats,
45
46
  };
46
47
  }
48
+ /**
49
+ * Cooperative twin of {@link openStreamedIfcModel}: the index build
50
+ * yields to the event loop and can fill windows from an async
51
+ * {@link ReadableByteSource}. Pass a {@link StoreByteSource} wrapping
52
+ * `store` to parse a file that is already in OPFS without ever
53
+ * holding it as one `ArrayBuffer`.
54
+ *
55
+ * @param source Sync or async parse source.
56
+ * @param store The random-access store the model reads from afterwards.
57
+ * @param options See {@link StreamedIfcOpenOptions} plus `onProgress`.
58
+ * @return {Promise<StreamedIfcOpen>} The model + header, columns, diagnostics.
59
+ */
60
+ export async function openStreamedIfcModelAsync(source, store, options) {
61
+ if (store.byteLength !== source.byteLength) {
62
+ throw new Error(`Streaming store byteLength ${store.byteLength} does not match ` +
63
+ `source byteLength ${source.byteLength}`);
64
+ }
65
+ const { header, columns, result, stats } = await buildColumnarIndexStreamingAsync(source, IfcStepParser.Instance, options?.pool ?? DEFAULT_STREAM_POOL_BYTES, options?.onRecordIndexed, options?.onProgress);
66
+ if (result !== ParseResult.COMPLETE) {
67
+ return { model: void 0, result, header, columns, stats };
68
+ }
69
+ const provider = new WindowedStepBufferProvider(store, options?.chunkBytes, options?.maxResidentChunks);
70
+ return {
71
+ model: new IfcStepModel(void 0, columns, provider),
72
+ result,
73
+ header,
74
+ columns,
75
+ stats,
76
+ };
77
+ }
78
+ /**
79
+ * Open a windowed IFC model from a store alone — parse windows and
80
+ * post-parse reads share `store`. This is the M1b embedder entry for
81
+ * a file already sitting in OPFS.
82
+ *
83
+ * @param store The source of truth for the file bytes.
84
+ * @param options See {@link openStreamedIfcModelAsync}.
85
+ * @return {Promise<StreamedIfcOpen>} The model + header, columns, diagnostics.
86
+ */
87
+ export function openStreamedIfcModelFromStore(store, options) {
88
+ return openStreamedIfcModelAsync(new StoreByteSource(store), store, options);
89
+ }
@@ -7,7 +7,7 @@ import * as fs from "fs";
7
7
  import { beforeAll, describe, expect, test } from "@jest/globals";
8
8
  import ParsingBuffer from "../parsing/parsing_buffer.js";
9
9
  import IfcStepParser from "./ifc_step_parser.js";
10
- import { openStreamedIfcModel } from "./ifc_stream_open.js";
10
+ import { openStreamedIfcModel, openStreamedIfcModelFromStore } from "./ifc_stream_open.js";
11
11
  import { BufferByteSource } from "../step/parsing/byte_source.js";
12
12
  import { InMemoryStepByteStore } from "../step/step_buffer_provider.js";
13
13
  import { ParseResult } from "../step/parsing/step_parser.js";
@@ -60,4 +60,13 @@ describe("openStreamedIfcModel (Phase B3)", () => {
60
60
  expect(() => openStreamedIfcModel(new BufferByteSource(bytes), new InMemoryStepByteStore(bytes.subarray(0, 100))))
61
61
  .toThrow(/does not match/);
62
62
  });
63
+ test("openStreamedIfcModelFromStore matches the sync open", async () => {
64
+ const store = new InMemoryStepByteStore(bytes);
65
+ const fromStore = await openStreamedIfcModelFromStore(store, { pool: 4 * 1024 });
66
+ const streamed = openStreamedIfcModel(new BufferByteSource(bytes), store, { pool: 4 * 1024 });
67
+ expect(fromStore.result).toBe(ParseResult.COMPLETE);
68
+ expect(fromStore.model.isSourceExternal).toBe(true);
69
+ expect([...fromStore.model.expressIDsOfTypes(IfcRoot)])
70
+ .toEqual([...streamed.model.expressIDsOfTypes(IfcRoot)]);
71
+ });
63
72
  });
@@ -11,9 +11,10 @@ export { ExtractResult } from "./core/shared_constants.js";
11
11
  export { ProgressEvent, ProgressCallback, ProgressPhase, ProgressUnit, ProgressTracker, CountProgressCallback, yieldToEventLoop, } from "./core/progress.js";
12
12
  export { ModelLoadOptions } from "./loaders/conway_model_loader.js";
13
13
  export { LoadLogAccumulator, ModelInfo, ProgressEventLike, formatBar, formatMb, formatModelLine, formatSeconds, stageLabel, } from "./core/progress_log.js";
14
- export { openStreamedIfcModel, StreamedIfcOpen, StreamedIfcOpenOptions } from "./ifc/ifc_stream_open.js";
14
+ export { openStreamedIfcModel, openStreamedIfcModelAsync, openStreamedIfcModelFromStore, StreamedIfcOpen, StreamedIfcOpenOptions, } from "./ifc/ifc_stream_open.js";
15
15
  export { buildColumnarIndexStreaming, buildColumnarIndexStreamingAsync, } from "./step/parsing/streaming_index_builder.js";
16
- export { ByteSource, BufferByteSource } from "./step/parsing/byte_source.js";
16
+ export { ByteSource, BufferByteSource, AsyncByteSource, ReadableByteSource, StoreByteSource, SyncAccessHandleByteSource, SyncAccessHandleLike, } from "./step/parsing/byte_source.js";
17
+ export { scanExpressRefs } from "./step/parsing/express_ref_scan.js";
17
18
  export { StepExternalByteStore, InMemoryStepByteStore, StepBufferProvider, WindowedStepBufferProvider, } from "./step/step_buffer_provider.js";
18
19
  export { StepIndexColumns } from "./step/parsing/columnar_index.js";
19
20
  export { serializeIndexSidecarFromColumns, deserializeIndexSidecarToColumns, sidecarMatchesSource, hashSource, } from "./step/parsing/index_sidecar.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AACrE,OAAO,EACL,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,eAAe,GAChB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE/F,OAAO,EAAE,OAAO,EAAE,+BAA+B,EAAE,MAAM,iCAAiC,CAAA;AAC1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAC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AM,8BAA8B,CAAA;AAC9D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA"}
@@ -18,9 +18,10 @@ export { LoadLogAccumulator, formatBar, formatMb, formatModelLine, formatSeconds
18
18
  // `/demand`, and `/mem` — which is where new conway-native APIs land (the
19
19
  // web-ifc compat shim stays an adapter and is headed for retirement). The
20
20
  // flat re-exports below are kept for root-import compatibility.
21
- export { openStreamedIfcModel } from "./ifc/ifc_stream_open.js";
21
+ export { openStreamedIfcModel, openStreamedIfcModelAsync, openStreamedIfcModelFromStore, } from "./ifc/ifc_stream_open.js";
22
22
  export { buildColumnarIndexStreaming, buildColumnarIndexStreamingAsync, } from "./step/parsing/streaming_index_builder.js";
23
- export { BufferByteSource } from "./step/parsing/byte_source.js";
23
+ export { BufferByteSource, StoreByteSource, SyncAccessHandleByteSource, } from "./step/parsing/byte_source.js";
24
+ export { scanExpressRefs } from "./step/parsing/express_ref_scan.js";
24
25
  export { InMemoryStepByteStore, WindowedStepBufferProvider, } from "./step/step_buffer_provider.js";
25
26
  export { serializeIndexSidecarFromColumns, deserializeIndexSidecarToColumns, sidecarMatchesSource, hashSource, } from "./step/parsing/index_sidecar.js";
26
27
  export { StreamingRecordDispatcher } from "./step/parsing/streaming_record_dispatcher.js";
@@ -9,7 +9,10 @@ import * as stream from "./stream/index.js";
9
9
  describe("plane namespace surface", () => {
10
10
  test("stream exposes the fixed-memory open plane", () => {
11
11
  expect(typeof stream.openStreamedIfcModel).toBe("function");
12
+ expect(typeof stream.openStreamedIfcModelFromStore).toBe("function");
12
13
  expect(typeof stream.BufferByteSource).toBe("function");
14
+ expect(typeof stream.StoreByteSource).toBe("function");
15
+ expect(typeof stream.SyncAccessHandleByteSource).toBe("function");
13
16
  expect(typeof stream.InMemoryStepByteStore).toBe("function");
14
17
  expect(typeof stream.WindowedStepBufferProvider).toBe("function");
15
18
  expect(typeof stream.serializeIndexSidecarFromColumns).toBe("function");
@@ -52,4 +52,102 @@ export declare class BufferByteSource implements ByteSource {
52
52
  */
53
53
  read(offset: number, length: number, into: Uint8Array, intoOffset: number): number;
54
54
  }
55
+ /**
56
+ * A `ByteSource` whose `read` is asynchronous — a `StepExternalByteStore`
57
+ * (OPFS `File.slice()`), or any other store that cannot serve bytes
58
+ * synchronously on this thread. `buildIndexStreamingAsync` accepts either
59
+ * this or a sync {@link ByteSource}; the sync builder does not.
60
+ */
61
+ export interface AsyncByteSource {
62
+ /** Total length of the source in bytes. */
63
+ readonly byteLength: number;
64
+ /**
65
+ * Read up to `length` bytes starting at `offset` into `into` at
66
+ * `intoOffset`. Same contract as {@link ByteSource.read}, but async.
67
+ *
68
+ * @param offset Absolute source offset to read from.
69
+ * @param length Maximum number of bytes to read.
70
+ * @param into Destination buffer.
71
+ * @param intoOffset Offset within `into` to write at.
72
+ * @return {Promise<number>} The number of bytes copied.
73
+ */
74
+ read(offset: number, length: number, into: Uint8Array, intoOffset: number): Promise<number>;
75
+ }
76
+ /**
77
+ * Either a sync or async positioned byte source. The cooperative index
78
+ * builder awaits each fill; a sync source just resolves immediately.
79
+ */
80
+ export type ReadableByteSource = ByteSource | AsyncByteSource;
81
+ /**
82
+ * Minimal sync-access handle (OPFS `FileSystemSyncAccessHandle` in a
83
+ * worker). Defined here so the source has no DOM lib dependency.
84
+ */
85
+ export interface SyncAccessHandleLike {
86
+ /**
87
+ * Read into `buffer` starting at file offset `options.at`.
88
+ *
89
+ * @param buffer Destination view.
90
+ * @param options `{ at }` file offset (default 0).
91
+ * @return {number} Bytes copied.
92
+ */
93
+ read(buffer: Uint8Array, options?: {
94
+ at?: number;
95
+ }): number;
96
+ /**
97
+ * @return {number} File size in bytes.
98
+ */
99
+ getSize(): number;
100
+ }
101
+ /**
102
+ * A `ByteSource` over an OPFS (or similar) synchronous access handle —
103
+ * the worker-side parse feed for M1b write-through. Reads never
104
+ * materialise the file as one `ArrayBuffer`.
105
+ */
106
+ export declare class SyncAccessHandleByteSource implements ByteSource {
107
+ private readonly handle_;
108
+ /**
109
+ * @param handle_ A sync-access handle already opened on the file.
110
+ */
111
+ constructor(handle_: SyncAccessHandleLike);
112
+ /**
113
+ * @return {number} The file length.
114
+ */
115
+ get byteLength(): number;
116
+ /**
117
+ * @param offset Absolute source offset to read from.
118
+ * @param length Maximum number of bytes to read.
119
+ * @param into Destination buffer.
120
+ * @param intoOffset Offset within `into` to write at.
121
+ * @return {number} The number of bytes copied.
122
+ */
123
+ read(offset: number, length: number, into: Uint8Array, intoOffset: number): number;
124
+ }
125
+ /**
126
+ * An {@link AsyncByteSource} over a {@link StepExternalByteStore} — the
127
+ * main-thread parse feed for a file that is already in OPFS (or any
128
+ * store whose `read` is async). Peak parse scratch is one window, not
129
+ * the whole file.
130
+ */
131
+ export declare class StoreByteSource implements AsyncByteSource {
132
+ private readonly store_;
133
+ /**
134
+ * @param store_ The external store (same bytes the model will page).
135
+ */
136
+ constructor(store_: {
137
+ readonly byteLength: number;
138
+ read(offset: number, length: number): Promise<Uint8Array>;
139
+ });
140
+ /**
141
+ * @return {number} The store length.
142
+ */
143
+ get byteLength(): number;
144
+ /**
145
+ * @param offset Absolute source offset to read from.
146
+ * @param length Maximum number of bytes to read.
147
+ * @param into Destination buffer.
148
+ * @param intoOffset Offset within `into` to write at.
149
+ * @return {Promise<number>} The number of bytes copied.
150
+ */
151
+ read(offset: number, length: number, into: Uint8Array, intoOffset: number): Promise<number>;
152
+ }
55
153
  //# sourceMappingURL=byte_source.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"byte_source.d.ts","sourceRoot":"","sources":["../../../../src/step/parsing/byte_source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,UAAU;IAEzB,2CAA2C;IAC3C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAE3B;;;;;;;;;;OAUG;IACH,IAAI,CAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAA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}
35
35
  }
36
+ /**
37
+ * A `ByteSource` over an OPFS (or similar) synchronous access handle —
38
+ * the worker-side parse feed for M1b write-through. Reads never
39
+ * materialise the file as one `ArrayBuffer`.
40
+ */
41
+ export class SyncAccessHandleByteSource {
42
+ /**
43
+ * @param handle_ A sync-access handle already opened on the file.
44
+ */
45
+ constructor(handle_) {
46
+ this.handle_ = handle_;
47
+ }
48
+ /**
49
+ * @return {number} The file length.
50
+ */
51
+ get byteLength() {
52
+ return this.handle_.getSize();
53
+ }
54
+ /**
55
+ * @param offset Absolute source offset to read from.
56
+ * @param length Maximum number of bytes to read.
57
+ * @param into Destination buffer.
58
+ * @param intoOffset Offset within `into` to write at.
59
+ * @return {number} The number of bytes copied.
60
+ */
61
+ read(offset, length, into, intoOffset) {
62
+ const end = Math.min(offset + length, this.byteLength);
63
+ if (end <= offset) {
64
+ return 0;
65
+ }
66
+ const want = end - offset;
67
+ return this.handle_.read(into.subarray(intoOffset, intoOffset + want), { at: offset });
68
+ }
69
+ }
70
+ /**
71
+ * An {@link AsyncByteSource} over a {@link StepExternalByteStore} — the
72
+ * main-thread parse feed for a file that is already in OPFS (or any
73
+ * store whose `read` is async). Peak parse scratch is one window, not
74
+ * the whole file.
75
+ */
76
+ export class StoreByteSource {
77
+ /**
78
+ * @param store_ The external store (same bytes the model will page).
79
+ */
80
+ constructor(store_) {
81
+ this.store_ = store_;
82
+ }
83
+ /**
84
+ * @return {number} The store length.
85
+ */
86
+ get byteLength() {
87
+ return this.store_.byteLength;
88
+ }
89
+ /**
90
+ * @param offset Absolute source offset to read from.
91
+ * @param length Maximum number of bytes to read.
92
+ * @param into Destination buffer.
93
+ * @param intoOffset Offset within `into` to write at.
94
+ * @return {Promise<number>} The number of bytes copied.
95
+ */
96
+ async read(offset, length, into, intoOffset) {
97
+ const end = Math.min(offset + length, this.store_.byteLength);
98
+ if (end <= offset) {
99
+ return 0;
100
+ }
101
+ const want = end - offset;
102
+ const bytes = await this.store_.read(offset, want);
103
+ into.set(bytes.subarray(0, want), intoOffset);
104
+ return Math.min(bytes.byteLength, want);
105
+ }
106
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=byte_source.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"byte_source.test.d.ts","sourceRoot":"","sources":["../../../../src/step/parsing/byte_source.test.ts"],"names":[],"mappings":""}