@bldrs-ai/conway 1.399.1223 → 1.401.1237

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 (56) hide show
  1. package/compiled/Dist/ConwayGeomWasmNode.js +0 -0
  2. package/compiled/Dist/ConwayGeomWasmNodeMT.js +0 -0
  3. package/compiled/Dist/ConwayGeomWasmWeb.js +0 -0
  4. package/compiled/Dist/ConwayGeomWasmWebMT.js +1 -1
  5. package/compiled/Dist/ConwayGeomWasmWebMT.wasm +0 -0
  6. package/compiled/dependencies/conway-geom/Dist/ConwayGeomWasmNode.js +0 -0
  7. package/compiled/dependencies/conway-geom/Dist/ConwayGeomWasmNodeMT.js +0 -0
  8. package/compiled/dependencies/conway-geom/Dist/ConwayGeomWasmWeb.js +0 -0
  9. package/compiled/dependencies/conway-geom/Dist/ConwayGeomWasmWebMT.js +1 -1
  10. package/compiled/dependencies/conway-geom/Dist/ConwayGeomWasmWebMT.wasm +0 -0
  11. package/compiled/examples/browser-bundled.cjs +184 -11
  12. package/compiled/examples/cli-bundled.cjs +213 -40
  13. package/compiled/examples/cli-step-bundled.cjs +105 -37
  14. package/compiled/examples/validator-bundled.cjs +184 -11
  15. package/compiled/src/ifc/ifc_step_model.d.ts +5 -2
  16. package/compiled/src/ifc/ifc_step_model.d.ts.map +1 -1
  17. package/compiled/src/ifc/ifc_step_model.js +5 -3
  18. package/compiled/src/ifc/ifc_step_parser.d.ts +36 -0
  19. package/compiled/src/ifc/ifc_step_parser.d.ts.map +1 -1
  20. package/compiled/src/ifc/ifc_step_parser.js +40 -0
  21. package/compiled/src/ifc/ifc_stream_model.test.d.ts +2 -0
  22. package/compiled/src/ifc/ifc_stream_model.test.d.ts.map +1 -0
  23. package/compiled/src/ifc/ifc_stream_model.test.js +70 -0
  24. package/compiled/src/parsing/parsing_buffer.d.ts +23 -0
  25. package/compiled/src/parsing/parsing_buffer.d.ts.map +1 -1
  26. package/compiled/src/parsing/parsing_buffer.js +31 -0
  27. package/compiled/src/step/parsing/byte_source.d.ts +55 -0
  28. package/compiled/src/step/parsing/byte_source.d.ts.map +1 -0
  29. package/compiled/src/step/parsing/byte_source.js +35 -0
  30. package/compiled/src/step/parsing/incremental_type_index.d.ts +64 -0
  31. package/compiled/src/step/parsing/incremental_type_index.d.ts.map +1 -0
  32. package/compiled/src/step/parsing/incremental_type_index.js +92 -0
  33. package/compiled/src/step/parsing/incremental_type_index.test.d.ts +2 -0
  34. package/compiled/src/step/parsing/incremental_type_index.test.d.ts.map +1 -0
  35. package/compiled/src/step/parsing/incremental_type_index.test.js +55 -0
  36. package/compiled/src/step/parsing/step_parser.d.ts +19 -0
  37. package/compiled/src/step/parsing/step_parser.d.ts.map +1 -1
  38. package/compiled/src/step/parsing/step_parser.js +48 -4
  39. package/compiled/src/step/parsing/streaming_index_builder.d.ts +70 -0
  40. package/compiled/src/step/parsing/streaming_index_builder.d.ts.map +1 -0
  41. package/compiled/src/step/parsing/streaming_index_builder.js +125 -0
  42. package/compiled/src/step/parsing/streaming_index_builder.test.d.ts +2 -0
  43. package/compiled/src/step/parsing/streaming_index_builder.test.d.ts.map +1 -0
  44. package/compiled/src/step/parsing/streaming_index_builder.test.js +107 -0
  45. package/compiled/src/step/parsing/streaming_record_dispatcher.d.ts +55 -0
  46. package/compiled/src/step/parsing/streaming_record_dispatcher.d.ts.map +1 -0
  47. package/compiled/src/step/parsing/streaming_record_dispatcher.js +67 -0
  48. package/compiled/src/step/parsing/streaming_record_dispatcher.test.d.ts +2 -0
  49. package/compiled/src/step/parsing/streaming_record_dispatcher.test.d.ts.map +1 -0
  50. package/compiled/src/step/parsing/streaming_record_dispatcher.test.js +66 -0
  51. package/compiled/src/step/step_model_base.d.ts +9 -3
  52. package/compiled/src/step/step_model_base.d.ts.map +1 -1
  53. package/compiled/src/step/step_model_base.js +9 -3
  54. package/compiled/src/version/version.js +1 -1
  55. package/compiled/tsconfig.tsbuildinfo +1 -1
  56. package/package.json +1 -1
@@ -30,7 +30,7 @@ var import_node_process = require("node:process");
30
30
  var readline = __toESM(require("node:readline"), 1);
31
31
 
32
32
  // compiled/src/version/version.js
33
- var versionString = "Conway v1.399.1223";
33
+ var versionString = "Conway v1.401.1237";
34
34
 
35
35
  // compiled/dependencies/conway-geom/interface/conway_geometry.js
36
36
  var wasmType = "";
@@ -1286,6 +1286,37 @@ var ParsingBuffer = class {
1286
1286
  this.buffer = buffer;
1287
1287
  this.end = endOffset;
1288
1288
  }
1289
+ /**
1290
+ * Streaming support: repoint this buffer at a fresh window over the same
1291
+ * logical stream while keeping `address` file-absolute.
1292
+ *
1293
+ * A moving-window parse holds only a slice of the source in memory at a
1294
+ * time. Between top-level records (where the rewind stack is empty) the
1295
+ * driver slides the window forward: it copies the unconsumed tail to the
1296
+ * front of a reused buffer, appends freshly-read bytes, and calls this to
1297
+ * repoint the parser. `addressBase` is the file offset that window index 0
1298
+ * now corresponds to; we store it as a negative initial offset so
1299
+ * `address` ( = cursor − initialOffset ) stays the file-absolute value the
1300
+ * non-streaming parse would have produced.
1301
+ *
1302
+ * Must only be called with the rewind stack empty (i.e. at a record
1303
+ * boundary) — the stack holds window-relative cursors that a slide would
1304
+ * invalidate. Throws otherwise.
1305
+ *
1306
+ * @param buffer The new window buffer.
1307
+ * @param cursorInWindow The cursor position within the new window.
1308
+ * @param endInWindow The count of valid bytes in the new window.
1309
+ * @param addressBase The file offset that window index 0 maps to.
1310
+ */
1311
+ rebaseWindow(buffer, cursorInWindow, endInWindow, addressBase) {
1312
+ if (this.rewindStack_.length !== 0) {
1313
+ throw Error("rebaseWindow called mid-transaction (rewind stack non-empty)");
1314
+ }
1315
+ this.buffer = buffer;
1316
+ this.cursor_ = cursorInWindow;
1317
+ this.initialOffset_ = -addressBase;
1318
+ this.end = endInWindow;
1319
+ }
1289
1320
  /**
1290
1321
  * Construct this with a buffer, initial offset into the buffer and an end offset.
1291
1322
  *
@@ -2538,6 +2569,34 @@ var StepParser = class extends StepHeaderParser {
2538
2569
  onProgress?.(next.value);
2539
2570
  }
2540
2571
  }
2572
+ /**
2573
+ * Streaming driver over parseDataBlockIncremental: identical parse (same
2574
+ * generator body) but invokes `onRecordBoundary` at every top-level record
2575
+ * boundary so a caller feeding the parser from a moving window can slide
2576
+ * that window forward while the rewind stack is empty. See
2577
+ * streaming_index_builder.ts for the coordinator that owns the window.
2578
+ *
2579
+ * @param input The input parsing buffer, positioned at the data section.
2580
+ * @param onRecordBoundary Called at each top-level record boundary with the
2581
+ * buffer; the callback may rebase the buffer's window in place.
2582
+ * @param onRecordIndexed Called as each top-level record is indexed, with
2583
+ * its localID, expressID and typeID (0 for external-mapping records) — the
2584
+ * seam for incremental semantic consumers (type index, roots registry,
2585
+ * names skeleton). Must be synchronous and cheap; expensive work belongs on
2586
+ * a demand queue, not the parse path.
2587
+ * @param onProgress Optional byte-cursor progress callback.
2588
+ * @return {BlockParseResult} The parsing result, including the index and result enum.
2589
+ */
2590
+ parseDataBlockStreamed(input2, onRecordBoundary, onRecordIndexed, onProgress) {
2591
+ const parser211 = this.parseDataBlockIncremental(input2, onRecordBoundary, onRecordIndexed);
2592
+ while (true) {
2593
+ const next = parser211.next();
2594
+ if (next.done === true) {
2595
+ return next.value;
2596
+ }
2597
+ onProgress?.(next.value);
2598
+ }
2599
+ }
2541
2600
  /**
2542
2601
  * Cooperative variant of parseDataBlock: identical parse (same generator
2543
2602
  * body), but periodically awaits a macrotask so the event loop can run —
@@ -2575,7 +2634,7 @@ var StepParser = class extends StepHeaderParser {
2575
2634
  * @yields {number} The current byte cursor within the input buffer.
2576
2635
  * @return {BlockParseResult} The parsing result, including the index and result enum.
2577
2636
  */
2578
- *parseDataBlockIncremental(input2) {
2637
+ *parseDataBlockIncremental(input2, onRecordBoundary, onRecordIndexed) {
2579
2638
  const indexResult = { elements: [] };
2580
2639
  const match = input2.match;
2581
2640
  const comment = () => match(commentParser2);
@@ -2622,7 +2681,7 @@ var StepParser = class extends StepHeaderParser {
2622
2681
  return syntaxError();
2623
2682
  }
2624
2683
  whitespace();
2625
- const startElement = input2.cursor;
2684
+ const startElement = input2.address;
2626
2685
  let stackDepth = 1;
2627
2686
  const savedInlineElements = inlineElements;
2628
2687
  inlineElements = void 0;
@@ -2716,6 +2775,7 @@ var StepParser = class extends StepHeaderParser {
2716
2775
  if ((++parsedElementCount & PARSE_PROGRESS_ELEMENT_MASK) === 0) {
2717
2776
  yield input2.cursor;
2718
2777
  }
2778
+ onRecordBoundary?.(input2);
2719
2779
  if (!charws(HASH2)) {
2720
2780
  if (tokenws(END_SECTION)) {
2721
2781
  return parseResult2(ParseResult.COMPLETE);
@@ -2738,7 +2798,7 @@ var StepParser = class extends StepHeaderParser {
2738
2798
  }
2739
2799
  whitespace();
2740
2800
  inlineElements = void 0;
2741
- const startElement2 = input2.cursor;
2801
+ const startElement2 = input2.address;
2742
2802
  while (!charws(CLOSE_PAREN2)) {
2743
2803
  input2.begin();
2744
2804
  const elementResult = parseInlineElement(expressID);
@@ -2751,6 +2811,7 @@ var StepParser = class extends StepHeaderParser {
2751
2811
  if (!charws(SEMICOLON)) {
2752
2812
  return syntaxError();
2753
2813
  }
2814
+ onRecordIndexed?.(indexResult.elements.length, expressID, 0);
2754
2815
  indexResult.elements.push({
2755
2816
  address: startElement2,
2756
2817
  length: input2.address - startElement2,
@@ -2769,7 +2830,7 @@ var StepParser = class extends StepHeaderParser {
2769
2830
  return syntaxError();
2770
2831
  }
2771
2832
  whitespace();
2772
- const startElement = input2.cursor;
2833
+ const startElement = input2.address;
2773
2834
  let stackDepth = 1;
2774
2835
  inlineElements = void 0;
2775
2836
  while (stackDepth > 0) {
@@ -2842,6 +2903,7 @@ var StepParser = class extends StepHeaderParser {
2842
2903
  if (!charws(SEMICOLON)) {
2843
2904
  return syntaxError();
2844
2905
  }
2906
+ onRecordIndexed?.(indexResult.elements.length, expressID, foundItem);
2845
2907
  indexResult.elements.push({
2846
2908
  address: startElement,
2847
2909
  length: input2.address - startElement,
@@ -4920,18 +4982,24 @@ var StepModelBase = class {
4920
4982
  * Construct this step model with its matching schema, a buffer to read from and an element index.
4921
4983
  *
4922
4984
  * @param schema The Step schema this is based on.
4923
- * @param buffer_ The buffer to read this from.
4985
+ * @param buffer_ The buffer to read this from. Pass `undefined` together
4986
+ * with `provider` to build a model whose source is windowed from
4987
+ * construction (e.g. a streaming open — see buildModelStreaming); the
4988
+ * synchronous read paths (geometry extraction) then require the relevant
4989
+ * ranges to be resident, exactly as after `spillSourceToExternalStore`.
4924
4990
  * @param elementIndex The element index for this, parsed or deserialized - note this takes
4925
4991
  * ownership of this array in the sense it will modify values/unfold inline elements etc.
4992
+ * @param provider Optional pre-built buffer provider. When omitted, a
4993
+ * resident provider over `buffer_` is used (the classic path).
4926
4994
  */
4927
- constructor(schema, buffer_, elementIndex) {
4995
+ constructor(schema, buffer_, elementIndex, provider) {
4928
4996
  this.schema = schema;
4929
4997
  this.buffer_ = buffer_;
4930
4998
  this.vtableBuilder_ = new StepVtableBuilder();
4931
4999
  this.descriptorCache_ = [];
4932
5000
  this.elementMemoization = true;
4933
5001
  this.nullOnErrors = true;
4934
- this.bufferProvider_ = new ResidentStepBufferProvider(buffer_);
5002
+ this.bufferProvider_ = provider ?? new ResidentStepBufferProvider(buffer_);
4935
5003
  const localElementIndex = elementIndex;
4936
5004
  let where = 0;
4937
5005
  const firstInlineElement = localElementIndex.length;
@@ -70694,11 +70762,13 @@ var IfcStepModel = class extends StepModelBase {
70694
70762
  * Construct this model given a buffer containing the data and the parsed data index on that,
70695
70763
  * adding the typeIndex on top of that.
70696
70764
  *
70697
- * @param buffer The buffer to values from.
70765
+ * @param buffer The buffer to values from, or `undefined` with `provider`
70766
+ * set for a windowed (streaming) source.
70698
70767
  * @param elementIndex The parsed index to elements in the STEP.
70768
+ * @param provider Optional pre-built buffer provider (windowed source).
70699
70769
  */
70700
- constructor(buffer, elementIndex) {
70701
- super(schema_ifc_gen_default, buffer, elementIndex);
70770
+ constructor(buffer, elementIndex, provider) {
70771
+ super(schema_ifc_gen_default, buffer, elementIndex, provider);
70702
70772
  this.externalMappingType = ifc_step_external_mapping_default;
70703
70773
  this.geometry = new IfcModelGeometry(this);
70704
70774
  this.voidGeometry = new IfcModelGeometry(this, true);
@@ -70712,7 +70782,76 @@ var IfcStepModel = class extends StepModelBase {
70712
70782
  }
70713
70783
  };
70714
70784
 
70785
+ // compiled/src/step/parsing/streaming_index_builder.js
70786
+ function buildIndexStreaming(source, parser211, pool3, onRecordIndexed) {
70787
+ const fileSize = source.byteLength;
70788
+ let windowBytes = Math.max(pool3, MIN_WINDOW);
70789
+ for (; ; ) {
70790
+ const window2 = new Uint8Array(windowBytes);
70791
+ let windowStartFile = 0;
70792
+ let windowLen = source.read(0, windowBytes, window2, 0);
70793
+ let bytesRead = windowLen;
70794
+ const input2 = new ParsingBuffer(window2, 0, windowLen);
70795
+ const [header, headerResult] = parser211.parseHeader(input2);
70796
+ if (headerResult !== ParseResult.COMPLETE) {
70797
+ return {
70798
+ header,
70799
+ elements: [],
70800
+ result: headerResult,
70801
+ stats: { pool: pool3, windowBytes, slides: 0, maxRecordLen: 0, bytesRead }
70802
+ };
70803
+ }
70804
+ const slideThreshold = windowBytes >> 1;
70805
+ let slides = 0;
70806
+ let maxRecordLen = 0;
70807
+ let prevBoundaryFile = windowStartFile + input2.cursor;
70808
+ const onRecordBoundary = (buffer) => {
70809
+ const cursor = buffer.cursor;
70810
+ const recordFileStart = windowStartFile + cursor;
70811
+ const recordLen = recordFileStart - prevBoundaryFile;
70812
+ if (recordLen > maxRecordLen) {
70813
+ maxRecordLen = recordLen;
70814
+ }
70815
+ prevBoundaryFile = recordFileStart;
70816
+ if (windowStartFile + windowLen >= fileSize) {
70817
+ return;
70818
+ }
70819
+ if (cursor < slideThreshold) {
70820
+ return;
70821
+ }
70822
+ const tail = windowLen - cursor;
70823
+ window2.copyWithin(0, cursor, windowLen);
70824
+ const want = windowBytes - tail;
70825
+ const got = source.read(windowStartFile + windowLen, want, window2, tail);
70826
+ bytesRead += got;
70827
+ windowLen = tail + got;
70828
+ windowStartFile = recordFileStart;
70829
+ buffer.rebaseWindow(window2, 0, windowLen, windowStartFile);
70830
+ ++slides;
70831
+ };
70832
+ const [index, result] = parser211.parseDataBlockStreamed(input2, onRecordBoundary, onRecordIndexed);
70833
+ const stoppedShort = result !== ParseResult.COMPLETE;
70834
+ const notAtEof = windowStartFile + windowLen < fileSize;
70835
+ if (stoppedShort && notAtEof) {
70836
+ windowBytes *= 2;
70837
+ continue;
70838
+ }
70839
+ const lastRecordLen = windowStartFile + input2.cursor - prevBoundaryFile;
70840
+ if (lastRecordLen > maxRecordLen) {
70841
+ maxRecordLen = lastRecordLen;
70842
+ }
70843
+ return {
70844
+ header,
70845
+ elements: index.elements,
70846
+ result,
70847
+ stats: { pool: pool3, windowBytes, slides, maxRecordLen, bytesRead }
70848
+ };
70849
+ }
70850
+ }
70851
+ var MIN_WINDOW = 4 * 1024;
70852
+
70715
70853
  // compiled/src/ifc/ifc_step_parser.js
70854
+ var DEFAULT_STREAM_POOL_BYTES = 1024 * 1024;
70716
70855
  var IfcStepParser = class extends StepParser {
70717
70856
  /**
70718
70857
  * Construct the IFC step parser.
@@ -70745,6 +70884,40 @@ var IfcStepParser = class extends StepParser {
70745
70884
  const [itemIndex, parseResult2] = await this.parseDataBlockAsync(input2, onProgress);
70746
70885
  return [parseResult2, new IfcStepModel(input2.buffer, itemIndex.elements)];
70747
70886
  }
70887
+ /**
70888
+ * Build a model by streaming the source through a bounded moving window
70889
+ * (see buildIndexStreaming / M0) rather than parsing one resident buffer,
70890
+ * then backing the model with a windowed provider over `store` — so the
70891
+ * source is never held fully resident in the JS heap.
70892
+ *
70893
+ * `source` serves the parse (synchronous windowed reads — on a worker this
70894
+ * is an OPFS sync-access handle; in node/tests a file descriptor or buffer)
70895
+ * and `store` serves the model's post-parse property access (asynchronous
70896
+ * windowed reads paged in on demand — OPFS `File.slice()` in the browser).
70897
+ * Both view the same file bytes, so the file-absolute addresses the index
70898
+ * records resolve identically through either.
70899
+ *
70900
+ * NOTE (M1 scope): this delivers the bounded-memory *parse*. Synchronous
70901
+ * geometry extraction still needs its record ranges resident — as after
70902
+ * `spillSourceToExternalStore` — so a caller that extracts geometry must
70903
+ * `ensureResident` first (demand-driven geometry is M3). Property / index
70904
+ * access works directly via the async surfaces.
70905
+ *
70906
+ * @param source Synchronous byte source feeding the streaming parse.
70907
+ * @param store Async external store backing the windowed model.
70908
+ * @param opts Optional window sizing: `pool` (parse window),
70909
+ * `chunkBytes` / `maxResidentChunks` (model window).
70910
+ * @return {[ParseResult, IfcStepModel | undefined]} The parse result and
70911
+ * the windowed model.
70912
+ */
70913
+ parseStreamToModel(source, store, opts) {
70914
+ if (store.byteLength !== source.byteLength) {
70915
+ throw new Error(`Streaming store byteLength ${store.byteLength} does not match source byteLength ${source.byteLength}`);
70916
+ }
70917
+ const { elements, result } = buildIndexStreaming(source, this, opts?.pool ?? DEFAULT_STREAM_POOL_BYTES);
70918
+ const provider = new WindowedStepBufferProvider(store, opts?.chunkBytes, opts?.maxResidentChunks);
70919
+ return [result, new IfcStepModel(void 0, elements, provider)];
70920
+ }
70748
70921
  };
70749
70922
  IfcStepParser.Instance = new IfcStepParser();
70750
70923
  var ifc_step_parser_default = IfcStepParser;