@bldrs-ai/conway 1.389.1221 → 1.394.1504

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 (382) hide show
  1. package/README.md +36 -22
  2. package/compiled/Dist/ConwayGeomWasmNode.js +0 -0
  3. package/compiled/Dist/ConwayGeomWasmNodeMT.js +0 -0
  4. package/compiled/Dist/ConwayGeomWasmWeb.js +0 -0
  5. package/compiled/Dist/ConwayGeomWasmWebMT.js +1 -1
  6. package/compiled/Dist/ConwayGeomWasmWebMT.wasm +0 -0
  7. package/compiled/dependencies/conway-geom/Dist/ConwayGeomWasmNode.js +0 -0
  8. package/compiled/dependencies/conway-geom/Dist/ConwayGeomWasmNodeMT.js +0 -0
  9. package/compiled/dependencies/conway-geom/Dist/ConwayGeomWasmWeb.js +0 -0
  10. package/compiled/dependencies/conway-geom/Dist/ConwayGeomWasmWebMT.js +1 -1
  11. package/compiled/dependencies/conway-geom/Dist/ConwayGeomWasmWebMT.wasm +0 -0
  12. package/compiled/dependencies/conway-geom/interface/conway_geometry.d.ts +19 -0
  13. package/compiled/dependencies/conway-geom/interface/conway_geometry.d.ts.map +1 -1
  14. package/compiled/dependencies/conway-geom/interface/conway_geometry.js +17 -0
  15. package/compiled/dependencies/conway-geom/interface/parameters/surface_object.d.ts +6 -0
  16. package/compiled/dependencies/conway-geom/interface/parameters/surface_object.d.ts.map +1 -1
  17. package/compiled/examples/browser-bundled.cjs +1569 -51
  18. package/compiled/examples/cli-bundled.cjs +2790 -436
  19. package/compiled/examples/cli-step-bundled.cjs +1904 -229
  20. package/compiled/examples/validator-bundled.cjs +1569 -51
  21. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/b_spline_curve.gen.d.ts +2 -2
  22. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/b_spline_curve.gen.d.ts.map +1 -1
  23. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/b_spline_curve.gen.js +2 -2
  24. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/b_spline_surface.gen.d.ts +3 -3
  25. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/b_spline_surface.gen.d.ts.map +1 -1
  26. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/b_spline_surface.gen.js +3 -3
  27. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/composite_curve.gen.d.ts +1 -1
  28. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/composite_curve.gen.d.ts.map +1 -1
  29. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/composite_curve.gen.js +1 -1
  30. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/offset_curve_2d.gen.d.ts +1 -1
  31. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/offset_curve_2d.gen.d.ts.map +1 -1
  32. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/offset_curve_2d.gen.js +1 -1
  33. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/offset_curve_3d.gen.d.ts +1 -1
  34. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/offset_curve_3d.gen.d.ts.map +1 -1
  35. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/offset_curve_3d.gen.js +1 -1
  36. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/offset_surface.gen.d.ts +1 -1
  37. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/offset_surface.gen.d.ts.map +1 -1
  38. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/offset_surface.gen.js +1 -1
  39. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/presentation_style_assignment.gen.d.ts.map +1 -1
  40. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/presentation_style_assignment.gen.js +2 -2
  41. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/schema_ap214.gen.js +11 -11
  42. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/shape_aspect.gen.d.ts +1 -1
  43. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/shape_aspect.gen.d.ts.map +1 -1
  44. package/compiled/src/AP214E3_2010/AP214E3_2010_gen/shape_aspect.gen.js +1 -1
  45. package/compiled/src/AP214E3_2010/ap214_command_line_main.js +7 -3
  46. package/compiled/src/AP214E3_2010/ap214_geometry_extraction.d.ts +181 -7
  47. package/compiled/src/AP214E3_2010/ap214_geometry_extraction.d.ts.map +1 -1
  48. package/compiled/src/AP214E3_2010/ap214_geometry_extraction.js +906 -137
  49. package/compiled/src/AP214E3_2010/ap214_geometry_extraction.test.js +10 -2
  50. package/compiled/src/AP214E3_2010/ap214_logical_attribute.test.d.ts +2 -0
  51. package/compiled/src/AP214E3_2010/ap214_logical_attribute.test.d.ts.map +1 -0
  52. package/compiled/src/AP214E3_2010/ap214_logical_attribute.test.js +114 -0
  53. package/compiled/src/AP214E3_2010/ap214_model_geometry.d.ts +6 -0
  54. package/compiled/src/AP214E3_2010/ap214_model_geometry.d.ts.map +1 -1
  55. package/compiled/src/AP214E3_2010/ap214_model_geometry.js +9 -0
  56. package/compiled/src/AP214E3_2010/ap214_pcurve_basis_surfaces.test.d.ts +2 -0
  57. package/compiled/src/AP214E3_2010/ap214_pcurve_basis_surfaces.test.d.ts.map +1 -0
  58. package/compiled/src/AP214E3_2010/ap214_pcurve_basis_surfaces.test.js +233 -0
  59. package/compiled/src/AP214E3_2010/ap214_sphere_vertex_loop.test.d.ts +2 -0
  60. package/compiled/src/AP214E3_2010/ap214_sphere_vertex_loop.test.d.ts.map +1 -0
  61. package/compiled/src/AP214E3_2010/ap214_sphere_vertex_loop.test.js +147 -0
  62. package/compiled/src/AP214E3_2010/ap214_step_model.d.ts +2 -1
  63. package/compiled/src/AP214E3_2010/ap214_step_model.d.ts.map +1 -1
  64. package/compiled/src/AP214E3_2010/ap214_step_model.js +1 -1
  65. package/compiled/src/AP214E3_2010/ap214_typed_select_enum.test.d.ts +2 -0
  66. package/compiled/src/AP214E3_2010/ap214_typed_select_enum.test.d.ts.map +1 -0
  67. package/compiled/src/AP214E3_2010/ap214_typed_select_enum.test.js +65 -0
  68. package/compiled/src/AP214E3_2010/ap214_unit_scale.test.d.ts +2 -0
  69. package/compiled/src/AP214E3_2010/ap214_unit_scale.test.d.ts.map +1 -0
  70. package/compiled/src/AP214E3_2010/ap214_unit_scale.test.js +111 -0
  71. package/compiled/src/compat/web-ifc/ap214_streamed_open.test.d.ts +2 -0
  72. package/compiled/src/compat/web-ifc/ap214_streamed_open.test.d.ts.map +1 -0
  73. package/compiled/src/compat/web-ifc/ap214_streamed_open.test.js +190 -0
  74. package/compiled/src/compat/web-ifc/coordination_export_order.test.d.ts +2 -0
  75. package/compiled/src/compat/web-ifc/coordination_export_order.test.d.ts.map +1 -0
  76. package/compiled/src/compat/web-ifc/coordination_export_order.test.js +110 -0
  77. package/compiled/src/compat/web-ifc/coordination_f64.d.ts +165 -0
  78. package/compiled/src/compat/web-ifc/coordination_f64.d.ts.map +1 -0
  79. package/compiled/src/compat/web-ifc/coordination_f64.js +286 -0
  80. package/compiled/src/compat/web-ifc/coordination_f64.test.d.ts +2 -0
  81. package/compiled/src/compat/web-ifc/coordination_f64.test.d.ts.map +1 -0
  82. package/compiled/src/compat/web-ifc/coordination_f64.test.js +225 -0
  83. package/compiled/src/compat/web-ifc/ifc_api.d.ts +154 -0
  84. package/compiled/src/compat/web-ifc/ifc_api.d.ts.map +1 -1
  85. package/compiled/src/compat/web-ifc/ifc_api.js +211 -3
  86. package/compiled/src/compat/web-ifc/ifc_api_deferred_open.test.d.ts +2 -0
  87. package/compiled/src/compat/web-ifc/ifc_api_deferred_open.test.d.ts.map +1 -0
  88. package/compiled/src/compat/web-ifc/ifc_api_deferred_open.test.js +288 -0
  89. package/compiled/src/compat/web-ifc/ifc_api_model_passthrough.d.ts +39 -0
  90. package/compiled/src/compat/web-ifc/ifc_api_model_passthrough.d.ts.map +1 -1
  91. package/compiled/src/compat/web-ifc/ifc_api_model_passthrough_factory.d.ts +30 -0
  92. package/compiled/src/compat/web-ifc/ifc_api_model_passthrough_factory.d.ts.map +1 -1
  93. package/compiled/src/compat/web-ifc/ifc_api_model_passthrough_factory.js +83 -0
  94. package/compiled/src/compat/web-ifc/ifc_api_preview_channel.test.d.ts +2 -0
  95. package/compiled/src/compat/web-ifc/ifc_api_preview_channel.test.d.ts.map +1 -0
  96. package/compiled/src/compat/web-ifc/ifc_api_preview_channel.test.js +383 -0
  97. package/compiled/src/compat/web-ifc/ifc_api_preview_coordination.test.d.ts +2 -0
  98. package/compiled/src/compat/web-ifc/ifc_api_preview_coordination.test.d.ts.map +1 -0
  99. package/compiled/src/compat/web-ifc/ifc_api_preview_coordination.test.js +124 -0
  100. package/compiled/src/compat/web-ifc/ifc_api_proxy_ap214.d.ts +132 -0
  101. package/compiled/src/compat/web-ifc/ifc_api_proxy_ap214.d.ts.map +1 -1
  102. package/compiled/src/compat/web-ifc/ifc_api_proxy_ap214.js +488 -92
  103. package/compiled/src/compat/web-ifc/ifc_api_proxy_ifc.d.ts +268 -0
  104. package/compiled/src/compat/web-ifc/ifc_api_proxy_ifc.d.ts.map +1 -1
  105. package/compiled/src/compat/web-ifc/ifc_api_proxy_ifc.js +996 -149
  106. package/compiled/src/compat/web-ifc/ifc_api_streamed_open.test.d.ts +2 -0
  107. package/compiled/src/compat/web-ifc/ifc_api_streamed_open.test.d.ts.map +1 -0
  108. package/compiled/src/compat/web-ifc/ifc_api_streamed_open.test.js +129 -0
  109. package/compiled/src/compat/web-ifc/spatial_imposter.d.ts +134 -0
  110. package/compiled/src/compat/web-ifc/spatial_imposter.d.ts.map +1 -0
  111. package/compiled/src/compat/web-ifc/spatial_imposter.js +933 -0
  112. package/compiled/src/compat/web-ifc/spatial_imposter.test.d.ts +2 -0
  113. package/compiled/src/compat/web-ifc/spatial_imposter.test.d.ts.map +1 -0
  114. package/compiled/src/compat/web-ifc/spatial_imposter.test.js +467 -0
  115. package/compiled/src/compat/web-ifc/store_preview_channel.d.ts +187 -0
  116. package/compiled/src/compat/web-ifc/store_preview_channel.d.ts.map +1 -0
  117. package/compiled/src/compat/web-ifc/store_preview_channel.js +524 -0
  118. package/compiled/src/compat/web-ifc/store_preview_channel.test.d.ts +2 -0
  119. package/compiled/src/compat/web-ifc/store_preview_channel.test.d.ts.map +1 -0
  120. package/compiled/src/compat/web-ifc/store_preview_channel.test.js +234 -0
  121. package/compiled/src/compat/web-ifc/streamed_preview_channel.d.ts +306 -0
  122. package/compiled/src/compat/web-ifc/streamed_preview_channel.d.ts.map +1 -0
  123. package/compiled/src/compat/web-ifc/streamed_preview_channel.js +580 -0
  124. package/compiled/src/compat/web-ifc/web_wasm_directory.test.d.ts +2 -0
  125. package/compiled/src/compat/web-ifc/web_wasm_directory.test.d.ts.map +1 -0
  126. package/compiled/src/compat/web-ifc/web_wasm_directory.test.js +22 -0
  127. package/compiled/src/core/composed_model_skeleton.d.ts +63 -0
  128. package/compiled/src/core/composed_model_skeleton.d.ts.map +1 -0
  129. package/compiled/src/core/composed_model_skeleton.js +66 -0
  130. package/compiled/src/core/composed_model_skeleton.test.d.ts +2 -0
  131. package/compiled/src/core/composed_model_skeleton.test.d.ts.map +1 -0
  132. package/compiled/src/core/composed_model_skeleton.test.js +69 -0
  133. package/compiled/src/core/demand_geometry_queue.d.ts +147 -0
  134. package/compiled/src/core/demand_geometry_queue.d.ts.map +1 -0
  135. package/compiled/src/core/demand_geometry_queue.js +223 -0
  136. package/compiled/src/core/demand_geometry_queue.test.d.ts +2 -0
  137. package/compiled/src/core/demand_geometry_queue.test.d.ts.map +1 -0
  138. package/compiled/src/core/demand_geometry_queue.test.js +133 -0
  139. package/compiled/src/core/demand_residency_pump.d.ts +93 -0
  140. package/compiled/src/core/demand_residency_pump.d.ts.map +1 -0
  141. package/compiled/src/core/demand_residency_pump.js +120 -0
  142. package/compiled/src/core/demand_residency_pump.test.d.ts +2 -0
  143. package/compiled/src/core/demand_residency_pump.test.d.ts.map +1 -0
  144. package/compiled/src/core/demand_residency_pump.test.js +148 -0
  145. package/compiled/src/core/geometry_tile_bindings.d.ts +110 -0
  146. package/compiled/src/core/geometry_tile_bindings.d.ts.map +1 -0
  147. package/compiled/src/core/geometry_tile_bindings.js +76 -0
  148. package/compiled/src/core/geometry_tile_bindings.test.d.ts +2 -0
  149. package/compiled/src/core/geometry_tile_bindings.test.d.ts.map +1 -0
  150. package/compiled/src/core/geometry_tile_bindings.test.js +211 -0
  151. package/compiled/src/core/geometry_tile_pool.d.ts +99 -0
  152. package/compiled/src/core/geometry_tile_pool.d.ts.map +1 -0
  153. package/compiled/src/core/geometry_tile_pool.js +104 -0
  154. package/compiled/src/core/geometry_tile_pool.test.d.ts +2 -0
  155. package/compiled/src/core/geometry_tile_pool.test.d.ts.map +1 -0
  156. package/compiled/src/core/geometry_tile_pool.test.js +180 -0
  157. package/compiled/src/core/mem/chunked_pool.d.ts +116 -0
  158. package/compiled/src/core/mem/chunked_pool.d.ts.map +1 -0
  159. package/compiled/src/core/mem/chunked_pool.js +149 -0
  160. package/compiled/src/core/mem/chunked_pool.test.d.ts +2 -0
  161. package/compiled/src/core/mem/chunked_pool.test.d.ts.map +1 -0
  162. package/compiled/src/core/mem/chunked_pool.test.js +63 -0
  163. package/compiled/src/core/mem/shared_asset_pool.d.ts +82 -0
  164. package/compiled/src/core/mem/shared_asset_pool.d.ts.map +1 -0
  165. package/compiled/src/core/mem/shared_asset_pool.js +113 -0
  166. package/compiled/src/core/mem/shared_asset_pool.test.d.ts +2 -0
  167. package/compiled/src/core/mem/shared_asset_pool.test.d.ts.map +1 -0
  168. package/compiled/src/core/mem/shared_asset_pool.test.js +49 -0
  169. package/compiled/src/core/model_registry.d.ts +87 -0
  170. package/compiled/src/core/model_registry.d.ts.map +1 -0
  171. package/compiled/src/core/model_registry.js +101 -0
  172. package/compiled/src/core/model_registry.test.d.ts +2 -0
  173. package/compiled/src/core/model_registry.test.d.ts.map +1 -0
  174. package/compiled/src/core/model_registry.test.js +60 -0
  175. package/compiled/src/core/model_uri.d.ts +57 -0
  176. package/compiled/src/core/model_uri.d.ts.map +1 -0
  177. package/compiled/src/core/model_uri.js +101 -0
  178. package/compiled/src/core/model_uri.test.d.ts +2 -0
  179. package/compiled/src/core/model_uri.test.d.ts.map +1 -0
  180. package/compiled/src/core/model_uri.test.js +49 -0
  181. package/compiled/src/core/progress.d.ts +16 -2
  182. package/compiled/src/core/progress.d.ts.map +1 -1
  183. package/compiled/src/core/progress.js +31 -5
  184. package/compiled/src/core/progress.test.js +11 -2
  185. package/compiled/src/core/progress_log.d.ts +1 -0
  186. package/compiled/src/core/progress_log.d.ts.map +1 -1
  187. package/compiled/src/core/progress_log.js +7 -2
  188. package/compiled/src/core/progress_log.test.js +21 -0
  189. package/compiled/src/core/shared_byte_budget.d.ts +60 -0
  190. package/compiled/src/core/shared_byte_budget.d.ts.map +1 -0
  191. package/compiled/src/core/shared_byte_budget.js +85 -0
  192. package/compiled/src/core/shared_byte_budget.test.d.ts +2 -0
  193. package/compiled/src/core/shared_byte_budget.test.d.ts.map +1 -0
  194. package/compiled/src/core/shared_byte_budget.test.js +55 -0
  195. package/compiled/src/core/wasm_heap.d.ts +208 -0
  196. package/compiled/src/core/wasm_heap.d.ts.map +1 -0
  197. package/compiled/src/core/wasm_heap.js +417 -0
  198. package/compiled/src/core/wasm_heap.test.d.ts +2 -0
  199. package/compiled/src/core/wasm_heap.test.d.ts.map +1 -0
  200. package/compiled/src/core/wasm_heap.test.js +546 -0
  201. package/compiled/src/demand/index.d.ts +23 -0
  202. package/compiled/src/demand/index.d.ts.map +1 -0
  203. package/compiled/src/demand/index.js +22 -0
  204. package/compiled/src/ifc/ifc4_gen/IfcLogical.gen.d.ts +1 -1
  205. package/compiled/src/ifc/ifc4_gen/IfcLogical.gen.d.ts.map +1 -1
  206. package/compiled/src/ifc/ifc4_gen/IfcLogical.gen.js +1 -1
  207. package/compiled/src/ifc/ifc4_gen/IfcPresentationStyleAssignment.gen.d.ts.map +1 -1
  208. package/compiled/src/ifc/ifc4_gen/IfcPresentationStyleAssignment.gen.js +2 -2
  209. package/compiled/src/ifc/ifc4_gen/IfcRelInterferesElements.gen.d.ts +1 -1
  210. package/compiled/src/ifc/ifc4_gen/IfcRelInterferesElements.gen.d.ts.map +1 -1
  211. package/compiled/src/ifc/ifc4_gen/IfcRelInterferesElements.gen.js +1 -1
  212. package/compiled/src/ifc/ifc4_gen/schema_ifc.gen.js +2 -2
  213. package/compiled/src/ifc/ifc_demand_extraction.test.d.ts +2 -0
  214. package/compiled/src/ifc/ifc_demand_extraction.test.d.ts.map +1 -0
  215. package/compiled/src/ifc/ifc_demand_extraction.test.js +251 -0
  216. package/compiled/src/ifc/ifc_geometry_extraction.d.ts +367 -6
  217. package/compiled/src/ifc/ifc_geometry_extraction.d.ts.map +1 -1
  218. package/compiled/src/ifc/ifc_geometry_extraction.js +1322 -389
  219. package/compiled/src/ifc/ifc_grid_placement.test.d.ts +2 -0
  220. package/compiled/src/ifc/ifc_grid_placement.test.d.ts.map +1 -0
  221. package/compiled/src/ifc/ifc_grid_placement.test.js +261 -0
  222. package/compiled/src/ifc/ifc_model_geometry.d.ts +12 -0
  223. package/compiled/src/ifc/ifc_model_geometry.d.ts.map +1 -1
  224. package/compiled/src/ifc/ifc_model_geometry.js +15 -0
  225. package/compiled/src/ifc/ifc_regression_batch_main.js +210 -12
  226. package/compiled/src/ifc/ifc_spatial_skeleton.d.ts +145 -0
  227. package/compiled/src/ifc/ifc_spatial_skeleton.d.ts.map +1 -0
  228. package/compiled/src/ifc/ifc_spatial_skeleton.js +266 -0
  229. package/compiled/src/ifc/ifc_spatial_skeleton.test.d.ts +2 -0
  230. package/compiled/src/ifc/ifc_spatial_skeleton.test.d.ts.map +1 -0
  231. package/compiled/src/ifc/ifc_spatial_skeleton.test.js +199 -0
  232. package/compiled/src/ifc/ifc_step_model.d.ts +6 -2
  233. package/compiled/src/ifc/ifc_step_model.d.ts.map +1 -1
  234. package/compiled/src/ifc/ifc_step_model.js +6 -4
  235. package/compiled/src/ifc/ifc_step_parser.d.ts +58 -0
  236. package/compiled/src/ifc/ifc_step_parser.d.ts.map +1 -1
  237. package/compiled/src/ifc/ifc_step_parser.js +64 -0
  238. package/compiled/src/ifc/ifc_stream_model.test.d.ts +2 -0
  239. package/compiled/src/ifc/ifc_stream_model.test.d.ts.map +1 -0
  240. package/compiled/src/ifc/ifc_stream_model.test.js +70 -0
  241. package/compiled/src/ifc/ifc_stream_open.d.ts +131 -0
  242. package/compiled/src/ifc/ifc_stream_open.d.ts.map +1 -0
  243. package/compiled/src/ifc/ifc_stream_open.js +116 -0
  244. package/compiled/src/ifc/ifc_stream_open.test.d.ts +2 -0
  245. package/compiled/src/ifc/ifc_stream_open.test.d.ts.map +1 -0
  246. package/compiled/src/ifc/ifc_stream_open.test.js +230 -0
  247. package/compiled/src/ifc/ifc_tile_extractor.d.ts +84 -0
  248. package/compiled/src/ifc/ifc_tile_extractor.d.ts.map +1 -0
  249. package/compiled/src/ifc/ifc_tile_extractor.js +134 -0
  250. package/compiled/src/ifc/ifc_tile_extractor.test.d.ts +2 -0
  251. package/compiled/src/ifc/ifc_tile_extractor.test.d.ts.map +1 -0
  252. package/compiled/src/ifc/ifc_tile_extractor.test.js +118 -0
  253. package/compiled/src/ifc/ifc_typed_select_enum.test.d.ts +2 -0
  254. package/compiled/src/ifc/ifc_typed_select_enum.test.d.ts.map +1 -0
  255. package/compiled/src/ifc/ifc_typed_select_enum.test.js +60 -0
  256. package/compiled/src/index.d.ts +21 -1
  257. package/compiled/src/index.d.ts.map +1 -1
  258. package/compiled/src/index.js +28 -1
  259. package/compiled/src/logging/logger.d.ts +16 -2
  260. package/compiled/src/logging/logger.d.ts.map +1 -1
  261. package/compiled/src/logging/logger.js +34 -7
  262. package/compiled/src/logging/logger.test.js +30 -0
  263. package/compiled/src/mem/index.d.ts +17 -0
  264. package/compiled/src/mem/index.d.ts.map +1 -0
  265. package/compiled/src/mem/index.js +16 -0
  266. package/compiled/src/namespace_surface.test.d.ts +2 -0
  267. package/compiled/src/namespace_surface.test.d.ts.map +1 -0
  268. package/compiled/src/namespace_surface.test.js +43 -0
  269. package/compiled/src/parsing/parsing_buffer.d.ts +23 -0
  270. package/compiled/src/parsing/parsing_buffer.d.ts.map +1 -1
  271. package/compiled/src/parsing/parsing_buffer.js +31 -0
  272. package/compiled/src/scripts/model_report_displacement.test.d.ts +2 -0
  273. package/compiled/src/scripts/model_report_displacement.test.d.ts.map +1 -0
  274. package/compiled/src/scripts/model_report_displacement.test.js +104 -0
  275. package/compiled/src/scripts/render_glb_paths.test.d.ts +2 -0
  276. package/compiled/src/scripts/render_glb_paths.test.d.ts.map +1 -0
  277. package/compiled/src/scripts/render_glb_paths.test.js +115 -0
  278. package/compiled/src/step/indexing/step_type_indexer.d.ts +20 -0
  279. package/compiled/src/step/indexing/step_type_indexer.d.ts.map +1 -1
  280. package/compiled/src/step/indexing/step_type_indexer.js +67 -0
  281. package/compiled/src/step/parsing/byte_source.d.ts +153 -0
  282. package/compiled/src/step/parsing/byte_source.d.ts.map +1 -0
  283. package/compiled/src/step/parsing/byte_source.js +106 -0
  284. package/compiled/src/step/parsing/byte_source.test.d.ts +2 -0
  285. package/compiled/src/step/parsing/byte_source.test.d.ts.map +1 -0
  286. package/compiled/src/step/parsing/byte_source.test.js +47 -0
  287. package/compiled/src/step/parsing/byte_source_node.d.ts +41 -0
  288. package/compiled/src/step/parsing/byte_source_node.d.ts.map +1 -0
  289. package/compiled/src/step/parsing/byte_source_node.js +54 -0
  290. package/compiled/src/step/parsing/columnar_index.d.ts +103 -0
  291. package/compiled/src/step/parsing/columnar_index.d.ts.map +1 -0
  292. package/compiled/src/step/parsing/columnar_index.js +224 -0
  293. package/compiled/src/step/parsing/columnar_index.test.d.ts +2 -0
  294. package/compiled/src/step/parsing/columnar_index.test.d.ts.map +1 -0
  295. package/compiled/src/step/parsing/columnar_index.test.js +155 -0
  296. package/compiled/src/step/parsing/cross_reference_registry.d.ts +95 -0
  297. package/compiled/src/step/parsing/cross_reference_registry.d.ts.map +1 -0
  298. package/compiled/src/step/parsing/cross_reference_registry.js +91 -0
  299. package/compiled/src/step/parsing/cross_reference_registry.test.d.ts +2 -0
  300. package/compiled/src/step/parsing/cross_reference_registry.test.d.ts.map +1 -0
  301. package/compiled/src/step/parsing/cross_reference_registry.test.js +66 -0
  302. package/compiled/src/step/parsing/decode_utf8.d.ts +15 -0
  303. package/compiled/src/step/parsing/decode_utf8.d.ts.map +1 -1
  304. package/compiled/src/step/parsing/decode_utf8.js +28 -0
  305. package/compiled/src/step/parsing/express_ref_scan.d.ts +20 -0
  306. package/compiled/src/step/parsing/express_ref_scan.d.ts.map +1 -0
  307. package/compiled/src/step/parsing/express_ref_scan.js +91 -0
  308. package/compiled/src/step/parsing/express_ref_scan.test.d.ts +2 -0
  309. package/compiled/src/step/parsing/express_ref_scan.test.d.ts.map +1 -0
  310. package/compiled/src/step/parsing/express_ref_scan.test.js +28 -0
  311. package/compiled/src/step/parsing/index_sidecar.d.ts +81 -0
  312. package/compiled/src/step/parsing/index_sidecar.d.ts.map +1 -0
  313. package/compiled/src/step/parsing/index_sidecar.js +283 -0
  314. package/compiled/src/step/parsing/index_sidecar.test.d.ts +2 -0
  315. package/compiled/src/step/parsing/index_sidecar.test.d.ts.map +1 -0
  316. package/compiled/src/step/parsing/index_sidecar.test.js +122 -0
  317. package/compiled/src/step/parsing/inf_recovery_index.test.d.ts +2 -0
  318. package/compiled/src/step/parsing/inf_recovery_index.test.d.ts.map +1 -0
  319. package/compiled/src/step/parsing/inf_recovery_index.test.js +108 -0
  320. package/compiled/src/step/parsing/prefix_type_index.d.ts +124 -0
  321. package/compiled/src/step/parsing/prefix_type_index.d.ts.map +1 -0
  322. package/compiled/src/step/parsing/prefix_type_index.js +207 -0
  323. package/compiled/src/step/parsing/prefix_type_index.test.d.ts +2 -0
  324. package/compiled/src/step/parsing/prefix_type_index.test.d.ts.map +1 -0
  325. package/compiled/src/step/parsing/prefix_type_index.test.js +298 -0
  326. package/compiled/src/step/parsing/range_byte_source.d.ts +69 -0
  327. package/compiled/src/step/parsing/range_byte_source.d.ts.map +1 -0
  328. package/compiled/src/step/parsing/range_byte_source.js +78 -0
  329. package/compiled/src/step/parsing/range_byte_source.test.d.ts +2 -0
  330. package/compiled/src/step/parsing/range_byte_source.test.d.ts.map +1 -0
  331. package/compiled/src/step/parsing/range_byte_source.test.js +70 -0
  332. package/compiled/src/step/parsing/record_event.d.ts +23 -0
  333. package/compiled/src/step/parsing/record_event.d.ts.map +1 -0
  334. package/compiled/src/step/parsing/record_event.js +1 -0
  335. package/compiled/src/step/parsing/record_field_cursor.d.ts +94 -0
  336. package/compiled/src/step/parsing/record_field_cursor.d.ts.map +1 -0
  337. package/compiled/src/step/parsing/record_field_cursor.js +189 -0
  338. package/compiled/src/step/parsing/step_deserialization_functions.d.ts +29 -0
  339. package/compiled/src/step/parsing/step_deserialization_functions.d.ts.map +1 -1
  340. package/compiled/src/step/parsing/step_deserialization_functions.js +45 -0
  341. package/compiled/src/step/parsing/step_deserialization_functions.test.js +59 -1
  342. package/compiled/src/step/parsing/step_parser.d.ts +66 -1
  343. package/compiled/src/step/parsing/step_parser.d.ts.map +1 -1
  344. package/compiled/src/step/parsing/step_parser.js +164 -10
  345. package/compiled/src/step/parsing/step_string_parser.js +8 -8
  346. package/compiled/src/step/parsing/streaming_index_builder.d.ts +141 -0
  347. package/compiled/src/step/parsing/streaming_index_builder.d.ts.map +1 -0
  348. package/compiled/src/step/parsing/streaming_index_builder.js +280 -0
  349. package/compiled/src/step/parsing/streaming_index_builder.test.d.ts +2 -0
  350. package/compiled/src/step/parsing/streaming_index_builder.test.d.ts.map +1 -0
  351. package/compiled/src/step/parsing/streaming_index_builder.test.js +107 -0
  352. package/compiled/src/step/parsing/streaming_index_builder_async.test.d.ts +2 -0
  353. package/compiled/src/step/parsing/streaming_index_builder_async.test.d.ts.map +1 -0
  354. package/compiled/src/step/parsing/streaming_index_builder_async.test.js +109 -0
  355. package/compiled/src/step/parsing/streaming_record_dispatcher.d.ts +71 -0
  356. package/compiled/src/step/parsing/streaming_record_dispatcher.d.ts.map +1 -0
  357. package/compiled/src/step/parsing/streaming_record_dispatcher.js +88 -0
  358. package/compiled/src/step/parsing/streaming_record_dispatcher.test.d.ts +2 -0
  359. package/compiled/src/step/parsing/streaming_record_dispatcher.test.d.ts.map +1 -0
  360. package/compiled/src/step/parsing/streaming_record_dispatcher.test.js +66 -0
  361. package/compiled/src/step/parsing/uint32_sink.d.ts +72 -0
  362. package/compiled/src/step/parsing/uint32_sink.d.ts.map +1 -0
  363. package/compiled/src/step/parsing/uint32_sink.js +180 -0
  364. package/compiled/src/step/parsing/uint32_sink.test.d.ts +2 -0
  365. package/compiled/src/step/parsing/uint32_sink.test.d.ts.map +1 -0
  366. package/compiled/src/step/parsing/uint32_sink.test.js +199 -0
  367. package/compiled/src/step/step_buffer_provider.d.ts +48 -3
  368. package/compiled/src/step/step_buffer_provider.d.ts.map +1 -1
  369. package/compiled/src/step/step_buffer_provider.js +60 -11
  370. package/compiled/src/step/step_buffer_provider.test.js +14 -0
  371. package/compiled/src/step/step_entity_base.d.ts +65 -3
  372. package/compiled/src/step/step_entity_base.d.ts.map +1 -1
  373. package/compiled/src/step/step_entity_base.js +135 -3
  374. package/compiled/src/step/step_model_base.d.ts +221 -8
  375. package/compiled/src/step/step_model_base.d.ts.map +1 -1
  376. package/compiled/src/step/step_model_base.js +542 -7
  377. package/compiled/src/stream/index.d.ts +34 -0
  378. package/compiled/src/stream/index.d.ts.map +1 -0
  379. package/compiled/src/stream/index.js +32 -0
  380. package/compiled/src/version/version.js +1 -1
  381. package/compiled/tsconfig.tsbuildinfo +1 -1
  382. package/package.json +16 -1
@@ -1 +1 @@
1
- {"version":3,"file":"progress_log.d.ts","sourceRoot":"","sources":["../../../src/core/progress_log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,+EAA+E;AAC/E,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,yEAAyE;IACzE,MAAM,CAAC,EAAE,M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E,SAAS,GAAI,MAAM,CA0BzD;AA6DD;;;;;;;;GAQG;AACH,qBAAa,kBAAkB;IAE7B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IACzC,OAAO,CAAC,QAAQ,CAAwB;IACxC,OAAO,CAAC,eAAe,CAAoB;IAC3C,OAAO,CAAC,cAAc,CAAY;IAClC,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,WAAW,CAAoB;IACvC,OAAO,CAAC,UAAU,CAAoB;IAEtC;;;;;OAKG;IACI,YAAY,CAAE,IAAI,EAAE,SAAS,GAAI,MAAM;IAM9C;;;;;;OAMG;IACI,UAAU,CAAE,KAAK,EAAE,iBAAiB,GAAI,MAAM,GAAG,SAAS;IAiDjE;;;;;;;;OAQG;IACI,iBAAiB,CAAE,WAAW,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAI,MAAM,GAAG,SAAS;IAuBzF;;;;OAIG;IACI,WAAW,IAAI,MAAM,GAAG,SAAS;IAQxC;;;;OAIG;IACI,aAAa,IAAI,MAAM,EAAE;IAIhC;;;;;OAKG;IACI,SAAS,IAAI,MAAM;IAY1B;;;;;OAKG;IACI,QAAQ,IAAI,MAAM,EAAE;CAY5B"}
@@ -143,14 +143,16 @@ function heapDeltaSuffix(state) {
143
143
  function formatStageLine(state, final) {
144
144
  const duration = state.lastElapsedMs - state.startElapsedMs;
145
145
  const heap = heapDeltaSuffix(state);
146
+ const window = state.residentSourceMb !== void 0 ?
147
+ `, window=${formatMb(state.residentSourceMb)} MB` : '';
146
148
  const determinate = state.percent !== void 0;
147
149
  // Completed: no bar, colon-separated. A determinate stage that stopped
148
150
  // short of 100% is a failure — keep its bar to show the reach.
149
151
  if (final && !(determinate && state.percent < PERCENT)) {
150
- return `${state.label}: ${formatSeconds(duration)}${heap}`;
152
+ return `${state.label}: ${formatSeconds(duration)}${heap}${window}`;
151
153
  }
152
154
  const bar = formatBar(determinate ? state.percent : void 0);
153
- return `${state.label} ${bar} ${formatSeconds(duration)}${heap}`;
155
+ return `${state.label} ${bar} ${formatSeconds(duration)}${heap}${window}`;
154
156
  }
155
157
  /**
156
158
  * Accumulates progress events into the normalized text report: a live
@@ -211,6 +213,9 @@ export class LoadLogAccumulator {
211
213
  current.startHeapMb ??= event.memoryMb;
212
214
  current.lastHeapMb = event.memoryMb;
213
215
  }
216
+ if (event.residentSourceMb !== void 0) {
217
+ current.residentSourceMb = event.residentSourceMb;
218
+ }
214
219
  if (event.total !== void 0 && event.total > 0) {
215
220
  current.percent = (event.completed / event.total) * PERCENT;
216
221
  }
@@ -76,6 +76,27 @@ describe("LoadLogAccumulator", () => {
76
76
  expect(log.finishedLines()[0]).toBe("Geometry: 16.500s, +220.000000 MB heap");
77
77
  expect(log.totalLine()).toBe("Total: 16.500s, 500.000000 \u2192 720.000000 MB heap");
78
78
  });
79
+ test("appends window residency on the Geometry line when provided", () => {
80
+ const log = new LoadLogAccumulator();
81
+ log.onProgress({
82
+ phase: "geometry",
83
+ completed: 0,
84
+ total: 10,
85
+ elapsedMs: 0,
86
+ memoryMb: 100,
87
+ residentSourceMb: 64,
88
+ });
89
+ log.onProgress({
90
+ phase: "geometry",
91
+ completed: 10,
92
+ total: 10,
93
+ elapsedMs: 1000,
94
+ memoryMb: 120,
95
+ residentSourceMb: 64,
96
+ });
97
+ log.closeCurrentStage();
98
+ expect(log.finishedLines()[0]).toBe("Geometry: 1.000s, +20.000000 MB heap, window=64.000000 MB");
99
+ });
79
100
  test("handles indeterminate stages and missing memory", () => {
80
101
  const log = new LoadLogAccumulator();
81
102
  log.onProgress({ phase: "geometry", completed: 0, elapsedMs: 0 });
@@ -0,0 +1,60 @@
1
+ /**
2
+ * A byte budget shared across many models (M5 / design S3).
3
+ *
4
+ * The federation invariant: budgets must be **per browser, not per model**, or
5
+ * opening N cross-referenced files re-introduces O(N) memory. This is the one
6
+ * accounting primitive that enforces it — every model's demand-geometry queue
7
+ * and window pool draws from a single {@link SharedByteBudget}, so the total
8
+ * resident footprint across all open models is bounded no matter how many are
9
+ * federated in.
10
+ *
11
+ * It owns only the accounting (reserve / release / availability); the eviction
12
+ * policy that frees bytes when a reservation can't be met stays with each
13
+ * model's scheduler (M3's {@link DemandGeometryQueue}) — the budget just tells
14
+ * a caller how much it must evict first via {@link overageFor}.
15
+ */
16
+ export declare class SharedByteBudget {
17
+ private readonly totalBytes_;
18
+ private used_;
19
+ /**
20
+ * @param totalBytes_ The global ceiling shared across all models.
21
+ */
22
+ constructor(totalBytes_: number);
23
+ /**
24
+ * @return {number} The global ceiling.
25
+ */
26
+ get total(): number;
27
+ /**
28
+ * @return {number} Bytes currently reserved across all models.
29
+ */
30
+ get used(): number;
31
+ /**
32
+ * @return {number} Bytes still reservable without eviction.
33
+ */
34
+ get available(): number;
35
+ /**
36
+ * Try to reserve `bytes` against the shared ceiling. Succeeds (and charges
37
+ * the budget) only if it fits without exceeding the total; otherwise makes
38
+ * no change and returns false, leaving the caller to evict and retry.
39
+ *
40
+ * @param bytes The bytes to reserve (≥ 0).
41
+ * @return {boolean} True if reserved.
42
+ */
43
+ reserve(bytes: number): boolean;
44
+ /**
45
+ * Release previously reserved bytes back to the shared budget.
46
+ *
47
+ * @param bytes The bytes to release (≥ 0). Clamped so `used` never goes
48
+ * negative — a double-release is a no-op past zero, not a corruption.
49
+ */
50
+ release(bytes: number): void;
51
+ /**
52
+ * How many bytes a caller must evict (anywhere, across any model) before a
53
+ * reservation of `bytes` would fit. Zero when it already fits.
54
+ *
55
+ * @param bytes The desired reservation.
56
+ * @return {number} The bytes of eviction required (≥ 0).
57
+ */
58
+ overageFor(bytes: number): number;
59
+ }
60
+ //# sourceMappingURL=shared_byte_budget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared_byte_budget.d.ts","sourceRoot":"","sources":["../../../src/core/shared_byte_budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,qBAAa,gBAAgB;IAOd,OAAO,CAAC,QAAQ,CAAC,WAAW;IALzC,OAAO,CAAC,KAAK,CAAI;IAEjB;;OAEG;gBAC2B,WAAW,EAAE,MAAM;IAOjD;;OAEG;IACH,IAAW,KAAK,IAAI,MAAM,CAEzB;IAED;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED;;;;;;;OAOG;IACI,OAAO,CAAE,KAAK,EAAE,MAAM,GAAI,OAAO;IAexC;;;;;OAKG;IACI,OAAO,CAAE,KAAK,EAAE,MAAM,GAAI,IAAI;IASrC;;;;;;OAMG;IACI,UAAU,CAAE,KAAK,EAAE,MAAM,GAAI,MAAM;CAG3C"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * A byte budget shared across many models (M5 / design S3).
3
+ *
4
+ * The federation invariant: budgets must be **per browser, not per model**, or
5
+ * opening N cross-referenced files re-introduces O(N) memory. This is the one
6
+ * accounting primitive that enforces it — every model's demand-geometry queue
7
+ * and window pool draws from a single {@link SharedByteBudget}, so the total
8
+ * resident footprint across all open models is bounded no matter how many are
9
+ * federated in.
10
+ *
11
+ * It owns only the accounting (reserve / release / availability); the eviction
12
+ * policy that frees bytes when a reservation can't be met stays with each
13
+ * model's scheduler (M3's {@link DemandGeometryQueue}) — the budget just tells
14
+ * a caller how much it must evict first via {@link overageFor}.
15
+ */
16
+ export class SharedByteBudget {
17
+ /**
18
+ * @param totalBytes_ The global ceiling shared across all models.
19
+ */
20
+ constructor(totalBytes_) {
21
+ this.totalBytes_ = totalBytes_;
22
+ this.used_ = 0;
23
+ if (totalBytes_ <= 0) {
24
+ throw new Error(`Invalid totalBytes ${totalBytes_}`);
25
+ }
26
+ }
27
+ /**
28
+ * @return {number} The global ceiling.
29
+ */
30
+ get total() {
31
+ return this.totalBytes_;
32
+ }
33
+ /**
34
+ * @return {number} Bytes currently reserved across all models.
35
+ */
36
+ get used() {
37
+ return this.used_;
38
+ }
39
+ /**
40
+ * @return {number} Bytes still reservable without eviction.
41
+ */
42
+ get available() {
43
+ return this.totalBytes_ - this.used_;
44
+ }
45
+ /**
46
+ * Try to reserve `bytes` against the shared ceiling. Succeeds (and charges
47
+ * the budget) only if it fits without exceeding the total; otherwise makes
48
+ * no change and returns false, leaving the caller to evict and retry.
49
+ *
50
+ * @param bytes The bytes to reserve (≥ 0).
51
+ * @return {boolean} True if reserved.
52
+ */
53
+ reserve(bytes) {
54
+ if (bytes < 0) {
55
+ throw new Error(`Cannot reserve negative bytes ${bytes}`);
56
+ }
57
+ if (bytes > this.available) {
58
+ return false;
59
+ }
60
+ this.used_ += bytes;
61
+ return true;
62
+ }
63
+ /**
64
+ * Release previously reserved bytes back to the shared budget.
65
+ *
66
+ * @param bytes The bytes to release (≥ 0). Clamped so `used` never goes
67
+ * negative — a double-release is a no-op past zero, not a corruption.
68
+ */
69
+ release(bytes) {
70
+ if (bytes < 0) {
71
+ throw new Error(`Cannot release negative bytes ${bytes}`);
72
+ }
73
+ this.used_ = Math.max(0, this.used_ - bytes);
74
+ }
75
+ /**
76
+ * How many bytes a caller must evict (anywhere, across any model) before a
77
+ * reservation of `bytes` would fit. Zero when it already fits.
78
+ *
79
+ * @param bytes The desired reservation.
80
+ * @return {number} The bytes of eviction required (≥ 0).
81
+ */
82
+ overageFor(bytes) {
83
+ return Math.max(0, bytes - this.available);
84
+ }
85
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=shared_byte_budget.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared_byte_budget.test.d.ts","sourceRoot":"","sources":["../../../src/core/shared_byte_budget.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,55 @@
1
+ /* eslint-disable no-magic-numbers */
2
+ // M5: the per-browser shared budget is what keeps federation from re-growing
3
+ // memory O(N) with the number of open models — reservations across all models
4
+ // draw from one ceiling.
5
+ import { describe, expect, test } from "@jest/globals";
6
+ import { SharedByteBudget } from "./shared_byte_budget.js";
7
+ describe("SharedByteBudget", () => {
8
+ test("reserves up to the ceiling and refuses to overcommit", () => {
9
+ const budget = new SharedByteBudget(1000);
10
+ expect(budget.reserve(600)).toBe(true);
11
+ expect(budget.reserve(300)).toBe(true);
12
+ expect(budget.used).toBe(900);
13
+ expect(budget.available).toBe(100);
14
+ // 200 doesn't fit in the remaining 100 — refused, no change.
15
+ expect(budget.reserve(200)).toBe(false);
16
+ expect(budget.used).toBe(900);
17
+ });
18
+ test("releasing frees room for later reservations", () => {
19
+ const budget = new SharedByteBudget(1000);
20
+ budget.reserve(800);
21
+ expect(budget.reserve(300)).toBe(false);
22
+ budget.release(500);
23
+ expect(budget.used).toBe(300);
24
+ expect(budget.reserve(300)).toBe(true);
25
+ });
26
+ test("release clamps at zero (a double release is not corruption)", () => {
27
+ const budget = new SharedByteBudget(1000);
28
+ budget.reserve(100);
29
+ budget.release(100);
30
+ budget.release(100);
31
+ expect(budget.used).toBe(0);
32
+ });
33
+ test("overageFor reports how much must be evicted before a reservation fits", () => {
34
+ const budget = new SharedByteBudget(1000);
35
+ budget.reserve(700);
36
+ // 500 wanted, 300 available → must evict 200.
37
+ expect(budget.overageFor(500)).toBe(200);
38
+ // 200 wanted, 300 available → fits, no eviction.
39
+ expect(budget.overageFor(200)).toBe(0);
40
+ });
41
+ test("the ceiling is shared: two models cannot each spend the whole budget", () => {
42
+ const budget = new SharedByteBudget(1000);
43
+ // "Model A" and "model B" both draw from the same budget.
44
+ expect(budget.reserve(700)).toBe(true); // A
45
+ expect(budget.reserve(700)).toBe(false); // B — only 300 left
46
+ expect(budget.reserve(300)).toBe(true); // B fits in the remainder
47
+ expect(budget.used).toBe(budget.total);
48
+ });
49
+ test("rejects an invalid ceiling and negative amounts", () => {
50
+ expect(() => new SharedByteBudget(0)).toThrow();
51
+ const budget = new SharedByteBudget(10);
52
+ expect(() => budget.reserve(-1)).toThrow();
53
+ expect(() => budget.release(-1)).toThrow();
54
+ });
55
+ });
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Reading and writing the wasm heap from JS, through views that are known to
3
+ * belong to the heap as it is RIGHT NOW.
4
+ *
5
+ * This lives in one place because the two geometry extractors had a copy each,
6
+ * and the copies had drifted: one honoured the source view's window and the
7
+ * other did not, and neither checked what _malloc returned. The failure modes
8
+ * are quiet enough to be worth naming here.
9
+ *
10
+ * See bldrs-ai/conway#485 for what an uninstrumented failure on this path
11
+ * costs: `Invalid typed array length: 80`, no context, and two sightings
12
+ * across two models before it could even be located.
13
+ *
14
+ * The confirmed mechanism behind #485
15
+ * -----------------------------------
16
+ * conway's MT builds create their memory as
17
+ * `new WebAssembly.Memory({ initial, maximum: 65536, shared: true })` with no
18
+ * `maxByteLength`, so `wasmMemory.buffer` is a **non-extensible**
19
+ * SharedArrayBuffer - `growable === false`, `maxByteLength === byteLength`
20
+ * (verified against Dist/ConwayGeomWasmNodeMT.js and by inspecting a live
21
+ * module). A non-extensible buffer cannot grow in place, so
22
+ * `WebAssembly.Memory.grow()` materialises a NEW SharedArrayBuffer, which the
23
+ * `.buffer` getter hands out from then on.
24
+ *
25
+ * emscripten rebuilds `Module.HEAPU8` and friends over that new buffer in
26
+ * `updateMemoryViews()` - but only on the thread that did the growing, and
27
+ * only when its own glue passes through `growMemViews()`. Growth driven by a
28
+ * pthread runs `updateMemoryViews()` in the WORKER's JS scope; the main
29
+ * thread's `Module.HEAPU8` stays bound to the pre-growth buffer until some
30
+ * main-thread glue call happens to run `growMemViews()`. `_malloc` is a raw
31
+ * wasm export, so it is not one of those calls: it can hand back an address in
32
+ * the newly added region while the JS-side view still ends before it. That is
33
+ * exactly the state #498's diagnostic captured in CI - view length equal to
34
+ * its own buffer's byteLength (so not stale relative to that buffer),
35
+ * `extensible false` (so that buffer never grew), and the pointer past the end
36
+ * of both.
37
+ *
38
+ * Which is why every view here is built through wasmHeapView(): it re-reads
39
+ * the module's view, reconciles it against the pointer, and only then
40
+ * constructs.
41
+ */
42
+ /**
43
+ * What the wasm module exposes that this needs. Deliberately narrow.
44
+ *
45
+ * Everything past `HEAPU8` is a refresh route that MAY be present; see
46
+ * refreshHeapViews for what each one is worth and which of them conway's
47
+ * current builds actually have.
48
+ */
49
+ export interface WasmHeapModule {
50
+ _malloc(bytes: number): number;
51
+ _free(pointer: number): void;
52
+ HEAPU8: Uint8Array;
53
+ /**
54
+ * emscripten's own view rebuilder, if the build exports it. Not exported by
55
+ * any conway build today.
56
+ */
57
+ updateMemoryViews?: () => void;
58
+ /**
59
+ * The live `WebAssembly.Memory`, if the build exposes it. Its `.buffer`
60
+ * getter always yields the current buffer, which makes staleness
61
+ * unrepresentable. Not exposed by any conway build today.
62
+ */
63
+ wasmMemory?: {
64
+ readonly buffer: ArrayBufferLike;
65
+ };
66
+ /**
67
+ * embind's `std::vector<std::string>`. Present on every conway-geom build;
68
+ * used as a refresh route of last resort (see refreshHeapViews).
69
+ */
70
+ stringVector?: new () => {
71
+ push_back(value: string): void;
72
+ delete(): void;
73
+ };
74
+ }
75
+ export type CopyableArray = Float32Array | Float64Array | Uint32Array;
76
+ /**
77
+ * The part of a typed-array constructor wasmHeapView needs: build over a
78
+ * buffer at a byte offset, and say how wide an element is.
79
+ */
80
+ export interface WasmHeapArrayConstructor<TArray> {
81
+ new (buffer: ArrayBufferLike, byteOffset: number, length: number): TArray;
82
+ readonly BYTES_PER_ELEMENT: number;
83
+ }
84
+ /**
85
+ * Build a typed-array view over a region of the wasm heap.
86
+ *
87
+ * Every view onto the heap in this repo goes through here, because the
88
+ * property that makes a view safe - that its buffer is the heap's CURRENT
89
+ * buffer - is not something a caller can check by looking at its own code. It
90
+ * depends on whether some other thread grew the heap between the call that
91
+ * produced `pointer` and this line.
92
+ *
93
+ * Two things beyond the reconcile are worth knowing:
94
+ *
95
+ * - The pointer is normalised to unsigned. Pointers reaching JS from raw i32
96
+ * wasm exports arrive NEGATIVE once the heap passes 2GB, and every target
97
+ * builds with `maximum: 65536` pages (4GB), so that is a reachable state and
98
+ * not a theoretical one. (This build's `applySignatureConversions` already
99
+ * wraps `_malloc` as `a0 => f(a0) >>> 0`; pointers from other exports and
100
+ * from other builds are not covered by that, so it is done here too.)
101
+ * - A view is CONSTRUCTED rather than `subarray`d off the module's view.
102
+ * `subarray` silently clamps an out-of-range window, which turns "the heap
103
+ * moved" into a short view and then into a copy that lands somewhere else
104
+ * entirely; the constructor throws instead, and by then the reconcile has
105
+ * already made throwing the right answer.
106
+ *
107
+ * @param wasmModule The module owning the heap.
108
+ * @param arrayType The typed-array constructor for the element type wanted.
109
+ * @param pointer Byte address in the heap, signed or unsigned.
110
+ * @param elementCount How many elements the view spans.
111
+ * @return {TArray} A view over the live heap. Do not retain it across any
112
+ * further call into wasm.
113
+ */
114
+ export declare function wasmHeapView<TArray>(wasmModule: WasmHeapModule, arrayType: WasmHeapArrayConstructor<TArray>, pointer: number, elementCount: number): TArray;
115
+ /**
116
+ * How many bytes of wasm heap there currently are.
117
+ *
118
+ * Refreshes first, unconditionally - which is the opposite of what
119
+ * wasmHeapView does, and deliberate. There is nothing to compare a size
120
+ * against, so lag here cannot be detected the way an out-of-range pointer can;
121
+ * and `HEAPU8.length` on its own under-reports by a whole growth step whenever
122
+ * the module's views are behind (see this file's header), which is the one
123
+ * thing a high-water figure must not do. This is a reporting call - a line at
124
+ * the end of a run - so paying microseconds for a true answer is the right
125
+ * trade. Do not put it in a loop.
126
+ *
127
+ * That the refresh cannot throw (see refreshHeapViews) matters more here than
128
+ * at the other call site: this figure's only consumer is the AP214 CLI's
129
+ * high-water log line, so an embind failure escaping would abort an otherwise
130
+ * complete extraction from a log statement. A lagging number is the right
131
+ * answer there.
132
+ *
133
+ * @param wasmModule The module to measure.
134
+ * @return {number} The heap's size in bytes, or 0 if it has no heap yet.
135
+ */
136
+ export declare function wasmHeapByteLength(wasmModule: WasmHeapModule): number;
137
+ /**
138
+ * Copy an array into a fresh wasm heap allocation.
139
+ *
140
+ * @param wasmModule The module to allocate in.
141
+ * @param array The data to copy. May be a view into a larger buffer.
142
+ * @return {number} Pointer to the copy, owned by the caller.
143
+ */
144
+ export declare function arrayToWasmHeap(wasmModule: WasmHeapModule, array: CopyableArray): number;
145
+ /**
146
+ * Copy several arrays into the wasm heap, all or nothing.
147
+ *
148
+ * arrayToWasmHeap throws on a failed allocation, which is the right thing on
149
+ * its own but turns a caller that allocates N buffers before freeing any into
150
+ * a leak: the throw on buffer 2 strands buffer 1, the per-record catch
151
+ * upstream moves to the next record, and the leak repeats - accelerating the
152
+ * exhaustion being reported. Callers that hold several at once use this
153
+ * instead, which frees what it took before letting the error out.
154
+ *
155
+ * @param wasmModule The module to allocate in.
156
+ * @param arrays The data to copy, in order.
157
+ * @return {number[]} Pointers in the same order, owned by the caller.
158
+ */
159
+ export declare function arraysToWasmHeap(wasmModule: WasmHeapModule, arrays: readonly CopyableArray[]): number[];
160
+ /**
161
+ * Run a resource release so it cannot replace an exception already in flight.
162
+ *
163
+ * Releases here re-enter the wasm runtime - _free, embind delete(), returning
164
+ * a pooled buffer - and they run from finally blocks that may be unwinding
165
+ * because that runtime just failed. A throw from one of them would REPLACE the
166
+ * original error, so the caller upstream would see a generic teardown failure
167
+ * instead of the diagnostic that says what actually went wrong. Losing the
168
+ * cause is strictly worse than failing to reclaim memory on a path where the
169
+ * heap is already lost.
170
+ *
171
+ * Reported at debug rather than swallowed outright, so it is still findable
172
+ * with -vv, and NOT at warning/error: this runs during teardown of an already
173
+ * failing record, where a second message would be noise on top of the one that
174
+ * matters.
175
+ *
176
+ * @param release The release step to run.
177
+ */
178
+ export declare function releaseQuietly(release: () => void): void;
179
+ /**
180
+ * Run `body`, then release - propagating a release failure on success, and
181
+ * suppressing it only when something is already being unwound.
182
+ *
183
+ * That asymmetry is the point. releaseQuietly on its own is right during
184
+ * unwinding and wrong otherwise: on the success path a teardown failure is a
185
+ * real fault with nothing competing to report it, and swallowing it would let
186
+ * a record be reported COMPLETE while its resources were never reclaimed. So
187
+ * the quiet treatment applies to exactly the case it was argued for.
188
+ *
189
+ * @param body The work that needs the resource.
190
+ * @param release How to give the resource back.
191
+ * @return {T} Whatever body returned.
192
+ */
193
+ export declare function withRelease<T>(body: () => T, release: () => void): T;
194
+ /**
195
+ * Free several pointers, independently.
196
+ *
197
+ * One failing free must not abandon the rest - batching them into a single
198
+ * statement means the first failure strands every pointer after it - and it
199
+ * must not be lost either, so the first error is re-thrown once they have all
200
+ * been attempted. Combined with withRelease that gives the wanted behaviour on
201
+ * both paths: everything is freed either way, and the failure surfaces on the
202
+ * success path while staying quiet during unwinding.
203
+ *
204
+ * @param wasmModule The module the pointers belong to.
205
+ * @param pointers The allocations to release.
206
+ */
207
+ export declare function freeAll(wasmModule: WasmHeapModule, pointers: readonly number[]): void;
208
+ //# sourceMappingURL=wasm_heap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasm_heap.d.ts","sourceRoot":"","sources":["../../../src/core/wasm_heap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAKH;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAE,KAAK,EAAE,MAAM,GAAI,MAAM,CAAA;IAChC,KAAK,CAAE,OAAO,EAAE,MAAM,GAAI,IAAI,CAAA;IAC9B,MAAM,EAAE,UAAU,CAAA;IAElB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAA;IAE9B;;;;OAIG;IACH,UAAU,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;KAAE,CAAA;IAEjD;;;OAGG;IACH,YAAY,CAAC,EAAE,UAAU;QAAE,SAAS,CAAE,KAAK,EAAE,MAAM,GAAI,IAAI,CAAC;QAAC,MAAM,IAAI,IAAI,CAAA;KAAE,CAAA;CAC9E;AAED,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,YAAY,GAAG,WAAW,CAAA;AAMrE;;;GAGG;AACH,MAAM,WAAW,wBAAwB,CAAE,MAAM;IAC/C,KAAM,MAAM,EAAE,eAAe,EAAE,UAAU,EAA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