@faicad/faijs 0.22.2 → 0.29.5

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 (488) hide show
  1. package/LICENSE +202 -28
  2. package/dist/api/api-namespace.d.ts +5 -5
  3. package/dist/api/api-namespace.d.ts.map +1 -1
  4. package/dist/api/api-namespace.js +4 -4
  5. package/dist/api/api-namespace.js.map +1 -1
  6. package/dist/api/appearance.d.ts +138 -0
  7. package/dist/api/appearance.d.ts.map +1 -0
  8. package/dist/api/appearance.js +230 -0
  9. package/dist/api/appearance.js.map +1 -0
  10. package/dist/api/assert.d.ts +2 -2
  11. package/dist/api/assert.js +8 -8
  12. package/dist/api/assert.js.map +1 -1
  13. package/dist/api/asset.d.ts +1 -1
  14. package/dist/api/asset.js +2 -2
  15. package/dist/api/asset.js.map +1 -1
  16. package/dist/api/boolean.d.ts +1 -1
  17. package/dist/api/boolean.d.ts.map +1 -1
  18. package/dist/api/boolean.js +128 -16
  19. package/dist/api/boolean.js.map +1 -1
  20. package/dist/api/cadquery-selectors/borrow-bridge.d.ts +14 -0
  21. package/dist/api/cadquery-selectors/borrow-bridge.d.ts.map +1 -0
  22. package/dist/api/cadquery-selectors/borrow-bridge.js +52 -0
  23. package/dist/api/cadquery-selectors/borrow-bridge.js.map +1 -0
  24. package/dist/api/cadquery-selectors/edge.d.ts +40 -0
  25. package/dist/api/cadquery-selectors/edge.d.ts.map +1 -0
  26. package/dist/api/cadquery-selectors/edge.js +70 -0
  27. package/dist/api/cadquery-selectors/edge.js.map +1 -0
  28. package/dist/api/cadquery-selectors/entity.d.ts +121 -0
  29. package/dist/api/cadquery-selectors/entity.d.ts.map +1 -0
  30. package/dist/api/cadquery-selectors/entity.js +167 -0
  31. package/dist/api/cadquery-selectors/entity.js.map +1 -0
  32. package/dist/api/cadquery-selectors/face.d.ts +33 -0
  33. package/dist/api/cadquery-selectors/face.d.ts.map +1 -0
  34. package/dist/api/cadquery-selectors/face.js +353 -0
  35. package/dist/api/cadquery-selectors/face.js.map +1 -0
  36. package/dist/api/cadquery-selectors/grammar.d.ts +50 -0
  37. package/dist/api/cadquery-selectors/grammar.d.ts.map +1 -0
  38. package/dist/api/cadquery-selectors/grammar.js +345 -0
  39. package/dist/api/cadquery-selectors/grammar.js.map +1 -0
  40. package/dist/api/cadquery-selectors/index.d.ts +18 -0
  41. package/dist/api/cadquery-selectors/index.d.ts.map +1 -0
  42. package/dist/api/cadquery-selectors/index.js +17 -0
  43. package/dist/api/cadquery-selectors/index.js.map +1 -0
  44. package/dist/api/cadquery-selectors/predicates.d.ts +76 -0
  45. package/dist/api/cadquery-selectors/predicates.d.ts.map +1 -0
  46. package/dist/api/cadquery-selectors/predicates.js +85 -0
  47. package/dist/api/cadquery-selectors/predicates.js.map +1 -0
  48. package/dist/api/cadquery-selectors/resolve.d.ts +41 -0
  49. package/dist/api/cadquery-selectors/resolve.d.ts.map +1 -0
  50. package/dist/api/cadquery-selectors/resolve.js +243 -0
  51. package/dist/api/cadquery-selectors/resolve.js.map +1 -0
  52. package/dist/api/cadquery-selectors/types.d.ts +96 -0
  53. package/dist/api/cadquery-selectors/types.d.ts.map +1 -0
  54. package/dist/api/cadquery-selectors/types.js +11 -0
  55. package/dist/api/cadquery-selectors/types.js.map +1 -0
  56. package/dist/api/chamfer.d.ts +13 -5
  57. package/dist/api/chamfer.d.ts.map +1 -1
  58. package/dist/api/chamfer.js +63 -7
  59. package/dist/api/chamfer.js.map +1 -1
  60. package/dist/api/compound-geom.d.ts +1 -1
  61. package/dist/api/compound-geom.js +1 -1
  62. package/dist/api/compound-geom.js.map +1 -1
  63. package/dist/api/draft.d.ts +1 -1
  64. package/dist/api/draft.js +1 -1
  65. package/dist/api/draft.js.map +1 -1
  66. package/dist/api/edge-ref.d.ts +1 -1
  67. package/dist/api/edge-ref.d.ts.map +1 -1
  68. package/dist/api/edge-ref.js +11 -3
  69. package/dist/api/edge-ref.js.map +1 -1
  70. package/dist/api/engrave.d.ts +1 -1
  71. package/dist/api/engrave.js +7 -7
  72. package/dist/api/engrave.js.map +1 -1
  73. package/dist/api/extrude.d.ts +6 -1
  74. package/dist/api/extrude.d.ts.map +1 -1
  75. package/dist/api/extrude.js +59 -5
  76. package/dist/api/extrude.js.map +1 -1
  77. package/dist/api/face-ref.d.ts +1 -1
  78. package/dist/api/face-ref.js +1 -1
  79. package/dist/api/face-ref.js.map +1 -1
  80. package/dist/api/feature-repair.d.ts +1 -1
  81. package/dist/api/feature-repair.js +1 -1
  82. package/dist/api/feature-repair.js.map +1 -1
  83. package/dist/api/fillet-variable.d.ts +1 -1
  84. package/dist/api/fillet-variable.js +1 -1
  85. package/dist/api/fillet-variable.js.map +1 -1
  86. package/dist/api/fillet.d.ts +28 -8
  87. package/dist/api/fillet.d.ts.map +1 -1
  88. package/dist/api/fillet.js +64 -9
  89. package/dist/api/fillet.js.map +1 -1
  90. package/dist/api/geom.d.ts +1 -1
  91. package/dist/api/geom.js +1 -1
  92. package/dist/api/geom.js.map +1 -1
  93. package/dist/api/helix.d.ts +1 -1
  94. package/dist/api/helix.js +1 -1
  95. package/dist/api/helix.js.map +1 -1
  96. package/dist/api/import-brep.d.ts +20 -2
  97. package/dist/api/import-brep.d.ts.map +1 -1
  98. package/dist/api/import-brep.js +28 -3
  99. package/dist/api/import-brep.js.map +1 -1
  100. package/dist/api/import-step.d.ts +17 -2
  101. package/dist/api/import-step.d.ts.map +1 -1
  102. package/dist/api/import-step.js +51 -3
  103. package/dist/api/import-step.js.map +1 -1
  104. package/dist/api/index.d.ts +6 -1
  105. package/dist/api/index.d.ts.map +1 -1
  106. package/dist/api/index.js +7 -2
  107. package/dist/api/index.js.map +1 -1
  108. package/dist/api/internal/compat-op.js +1 -1
  109. package/dist/api/internal/compat-op.js.map +1 -1
  110. package/dist/api/internal/mesh-solid-op.d.ts +236 -0
  111. package/dist/api/internal/mesh-solid-op.d.ts.map +1 -0
  112. package/dist/api/internal/mesh-solid-op.js +352 -0
  113. package/dist/api/internal/mesh-solid-op.js.map +1 -0
  114. package/dist/api/internal/svg-asset-resolver.d.ts +1 -1
  115. package/dist/api/internal/svg-asset-resolver.js +1 -1
  116. package/dist/api/internal/svg-asset-resolver.js.map +1 -1
  117. package/dist/api/knurl.d.ts +1 -1
  118. package/dist/api/knurl.js +2 -2
  119. package/dist/api/knurl.js.map +1 -1
  120. package/dist/api/loft.d.ts +1 -1
  121. package/dist/api/loft.js +1 -1
  122. package/dist/api/loft.js.map +1 -1
  123. package/dist/api/measurement/index.d.ts +9 -5
  124. package/dist/api/measurement/index.d.ts.map +1 -1
  125. package/dist/api/measurement/index.js +47 -20
  126. package/dist/api/measurement/index.js.map +1 -1
  127. package/dist/api/meta.d.ts +93 -0
  128. package/dist/api/meta.d.ts.map +1 -0
  129. package/dist/api/meta.js +99 -0
  130. package/dist/api/meta.js.map +1 -0
  131. package/dist/api/pattern.d.ts +5 -3
  132. package/dist/api/pattern.d.ts.map +1 -1
  133. package/dist/api/pattern.js +32 -4
  134. package/dist/api/pattern.js.map +1 -1
  135. package/dist/api/place.d.ts +1 -1
  136. package/dist/api/place.js +1 -1
  137. package/dist/api/place.js.map +1 -1
  138. package/dist/api/primitives.d.ts +1 -1
  139. package/dist/api/primitives.d.ts.map +1 -1
  140. package/dist/api/primitives.js +119 -4
  141. package/dist/api/primitives.js.map +1 -1
  142. package/dist/api/profile.d.ts +39 -12
  143. package/dist/api/profile.d.ts.map +1 -1
  144. package/dist/api/profile.js +4 -4
  145. package/dist/api/profile.js.map +1 -1
  146. package/dist/api/reconcile.d.ts +1 -1
  147. package/dist/api/reconcile.js +1 -1
  148. package/dist/api/reconcile.js.map +1 -1
  149. package/dist/api/replicate.d.ts.map +1 -1
  150. package/dist/api/replicate.js +122 -1
  151. package/dist/api/replicate.js.map +1 -1
  152. package/dist/api/screw.d.ts +1 -1
  153. package/dist/api/screw.js +3 -3
  154. package/dist/api/screw.js.map +1 -1
  155. package/dist/api/sdf.d.ts +1 -1
  156. package/dist/api/sdf.js +2 -2
  157. package/dist/api/sdf.js.map +1 -1
  158. package/dist/api/section-by-plane.d.ts +1 -1
  159. package/dist/api/section-by-plane.d.ts.map +1 -1
  160. package/dist/api/section-by-plane.js +2 -1
  161. package/dist/api/section-by-plane.js.map +1 -1
  162. package/dist/api/shell.d.ts +11 -4
  163. package/dist/api/shell.d.ts.map +1 -1
  164. package/dist/api/shell.js +53 -7
  165. package/dist/api/shell.js.map +1 -1
  166. package/dist/api/sketch-on-face.d.ts +41 -0
  167. package/dist/api/sketch-on-face.d.ts.map +1 -1
  168. package/dist/api/sketch-on-face.js +100 -1
  169. package/dist/api/sketch-on-face.js.map +1 -1
  170. package/dist/api/sketch-on-plane.d.ts +7 -5
  171. package/dist/api/sketch-on-plane.d.ts.map +1 -1
  172. package/dist/api/sketch-on-plane.js +6 -7
  173. package/dist/api/sketch-on-plane.js.map +1 -1
  174. package/dist/api/split-by-plane.d.ts +1 -1
  175. package/dist/api/split-by-plane.d.ts.map +1 -1
  176. package/dist/api/split-by-plane.js +2 -1
  177. package/dist/api/split-by-plane.js.map +1 -1
  178. package/dist/api/split.d.ts +1 -1
  179. package/dist/api/split.js +2 -2
  180. package/dist/api/split.js.map +1 -1
  181. package/dist/api/sweep.d.ts +1 -1
  182. package/dist/api/sweep.js +1 -1
  183. package/dist/api/sweep.js.map +1 -1
  184. package/dist/api/thicken.d.ts +1 -1
  185. package/dist/api/thicken.js +1 -1
  186. package/dist/api/thicken.js.map +1 -1
  187. package/dist/api/topo-resolve.d.ts +74 -1
  188. package/dist/api/topo-resolve.d.ts.map +1 -1
  189. package/dist/api/topo-resolve.js +180 -2
  190. package/dist/api/topo-resolve.js.map +1 -1
  191. package/dist/api/transform.d.ts +5 -1
  192. package/dist/api/transform.d.ts.map +1 -1
  193. package/dist/api/transform.js +62 -11
  194. package/dist/api/transform.js.map +1 -1
  195. package/dist/api/wire.d.ts +1 -1
  196. package/dist/api/wire.js +1 -1
  197. package/dist/api/wire.js.map +1 -1
  198. package/dist/brep/brep-ops.d.ts +9 -7
  199. package/dist/brep/brep-ops.d.ts.map +1 -1
  200. package/dist/brep/brep-ops.js +50 -26
  201. package/dist/brep/brep-ops.js.map +1 -1
  202. package/dist/brep/brep-topology.d.ts +5 -4
  203. package/dist/brep/brep-topology.d.ts.map +1 -1
  204. package/dist/brep/brep-topology.js +6 -5
  205. package/dist/brep/brep-topology.js.map +1 -1
  206. package/dist/brep/effective-deflection.d.ts +35 -0
  207. package/dist/brep/effective-deflection.d.ts.map +1 -0
  208. package/dist/brep/effective-deflection.js +49 -0
  209. package/dist/brep/effective-deflection.js.map +1 -0
  210. package/dist/brep/engine/adapters/brep-mock.d.ts.map +1 -1
  211. package/dist/brep/engine/adapters/brep-mock.js +27 -0
  212. package/dist/brep/engine/adapters/brep-mock.js.map +1 -1
  213. package/dist/brep/engine/adapters/brepkit.d.ts +18 -0
  214. package/dist/brep/engine/adapters/brepkit.d.ts.map +1 -1
  215. package/dist/brep/engine/adapters/brepkit.js +46 -1
  216. package/dist/brep/engine/adapters/brepkit.js.map +1 -1
  217. package/dist/brep/engine/adapters/occt.d.ts +1 -1
  218. package/dist/brep/engine/adapters/occt.d.ts.map +1 -1
  219. package/dist/brep/engine/adapters/occt.js +4 -2
  220. package/dist/brep/engine/adapters/occt.js.map +1 -1
  221. package/dist/brep/engine/primitives.d.ts +29 -7
  222. package/dist/brep/engine/primitives.d.ts.map +1 -1
  223. package/dist/brep/engine/primitives.js.map +1 -1
  224. package/dist/brep/engine/registry.d.ts +24 -1
  225. package/dist/brep/engine/registry.d.ts.map +1 -1
  226. package/dist/brep/engine/registry.js +24 -0
  227. package/dist/brep/engine/registry.js.map +1 -1
  228. package/dist/brep/engine/types.d.ts +54 -3
  229. package/dist/brep/engine/types.d.ts.map +1 -1
  230. package/dist/brep/engine/types.js +10 -0
  231. package/dist/brep/engine/types.js.map +1 -1
  232. package/dist/brep/export/export-model.d.ts +40 -0
  233. package/dist/brep/export/export-model.d.ts.map +1 -1
  234. package/dist/brep/export/export-model.js +274 -30
  235. package/dist/brep/export/export-model.js.map +1 -1
  236. package/dist/brep/export/step-meta-header.d.ts +102 -0
  237. package/dist/brep/export/step-meta-header.d.ts.map +1 -0
  238. package/dist/brep/export/step-meta-header.js +225 -0
  239. package/dist/brep/export/step-meta-header.js.map +1 -0
  240. package/dist/brep/export/step.d.ts +5 -1
  241. package/dist/brep/export/step.d.ts.map +1 -1
  242. package/dist/brep/export/step.js +11 -2
  243. package/dist/brep/export/step.js.map +1 -1
  244. package/dist/brep/face-evolution.d.ts +1 -1
  245. package/dist/brep/face-evolution.d.ts.map +1 -1
  246. package/dist/brep/face-evolution.js +20 -1
  247. package/dist/brep/face-evolution.js.map +1 -1
  248. package/dist/brep/handle-bridge.d.ts +1 -1
  249. package/dist/brep/handle-bridge.js +1 -1
  250. package/dist/brep/handle-bridge.js.map +1 -1
  251. package/dist/brep/mesh-solid.d.ts +218 -0
  252. package/dist/brep/mesh-solid.d.ts.map +1 -0
  253. package/dist/brep/mesh-solid.js +229 -0
  254. package/dist/brep/mesh-solid.js.map +1 -0
  255. package/dist/brep/text/fontRegistry.d.ts +32 -1
  256. package/dist/brep/text/fontRegistry.d.ts.map +1 -1
  257. package/dist/brep/text/fontRegistry.js +51 -1
  258. package/dist/brep/text/fontRegistry.js.map +1 -1
  259. package/dist/brep/text/text-to-solid.d.ts.map +1 -1
  260. package/dist/brep/text/text-to-solid.js +8 -3
  261. package/dist/brep/text/text-to-solid.js.map +1 -1
  262. package/dist/brepkit-kernel/brepkitKernel.d.ts +18 -2
  263. package/dist/brepkit-kernel/brepkitKernel.d.ts.map +1 -1
  264. package/dist/brepkit-kernel/brepkitKernel.js +449 -123
  265. package/dist/brepkit-kernel/brepkitKernel.js.map +1 -1
  266. package/dist/brepkit-kernel/brepkitWasm.d.ts +8 -0
  267. package/dist/brepkit-kernel/brepkitWasm.d.ts.map +1 -1
  268. package/dist/brepkit-kernel/brepkitWasm.js +10 -0
  269. package/dist/brepkit-kernel/brepkitWasm.js.map +1 -1
  270. package/dist/browser-host/browser-font-provider.d.ts +12 -0
  271. package/dist/browser-host/browser-font-provider.d.ts.map +1 -1
  272. package/dist/browser-host/browser-font-provider.js +25 -0
  273. package/dist/browser-host/browser-font-provider.js.map +1 -1
  274. package/dist/browser.d.ts +6 -3
  275. package/dist/browser.d.ts.map +1 -1
  276. package/dist/browser.js +10 -3
  277. package/dist/browser.js.map +1 -1
  278. package/dist/cad-runtime/backend-dispatch.d.ts +28 -3
  279. package/dist/cad-runtime/backend-dispatch.d.ts.map +1 -1
  280. package/dist/cad-runtime/backend-dispatch.js +119 -4
  281. package/dist/cad-runtime/backend-dispatch.js.map +1 -1
  282. package/dist/cad-runtime/browser-lib-loader.js.map +1 -1
  283. package/dist/cad-runtime/direct-executor.d.ts +15 -3
  284. package/dist/cad-runtime/direct-executor.d.ts.map +1 -1
  285. package/dist/cad-runtime/direct-executor.js +33 -1
  286. package/dist/cad-runtime/direct-executor.js.map +1 -1
  287. package/dist/cad-runtime/ports.d.ts +3 -3
  288. package/dist/cad-runtime/ports.d.ts.map +1 -1
  289. package/dist/cad-runtime/ports.js.map +1 -1
  290. package/dist/cad-runtime/preview-exec.d.ts +4 -4
  291. package/dist/cad-runtime/preview-exec.js +2 -2
  292. package/dist/cad-runtime/preview-exec.js.map +1 -1
  293. package/dist/cad-runtime/runtime.d.ts +42 -7
  294. package/dist/cad-runtime/runtime.d.ts.map +1 -1
  295. package/dist/cad-runtime/runtime.js +68 -5
  296. package/dist/cad-runtime/runtime.js.map +1 -1
  297. package/dist/define-op.d.ts +15 -1
  298. package/dist/define-op.d.ts.map +1 -1
  299. package/dist/define-op.js +73 -2
  300. package/dist/define-op.js.map +1 -1
  301. package/dist/env-agnostic.d.ts +2 -2
  302. package/dist/env-agnostic.d.ts.map +1 -1
  303. package/dist/env-agnostic.js +1 -1
  304. package/dist/env-agnostic.js.map +1 -1
  305. package/dist/geometry2d/adapt.d.ts +39 -4
  306. package/dist/geometry2d/adapt.d.ts.map +1 -1
  307. package/dist/geometry2d/adapt.js +14 -3
  308. package/dist/geometry2d/adapt.js.map +1 -1
  309. package/dist/geometry2d/blueprint.d.ts +2 -2
  310. package/dist/geometry2d/blueprint.js +2 -2
  311. package/dist/geometry2d/blueprint.js.map +1 -1
  312. package/dist/geometry2d/bridge/lift-on-plane.d.ts +18 -8
  313. package/dist/geometry2d/bridge/lift-on-plane.d.ts.map +1 -1
  314. package/dist/geometry2d/bridge/lift-on-plane.js +65 -12
  315. package/dist/geometry2d/bridge/lift-on-plane.js.map +1 -1
  316. package/dist/geometry2d/bridge/plane.d.ts +17 -0
  317. package/dist/geometry2d/bridge/plane.d.ts.map +1 -1
  318. package/dist/geometry2d/bridge/plane.js +22 -0
  319. package/dist/geometry2d/bridge/plane.js.map +1 -1
  320. package/dist/geometry2d/curve2d.d.ts +25 -0
  321. package/dist/geometry2d/curve2d.d.ts.map +1 -1
  322. package/dist/geometry2d/curve2d.js +41 -5
  323. package/dist/geometry2d/curve2d.js.map +1 -1
  324. package/dist/index.d.ts +6 -2
  325. package/dist/index.d.ts.map +1 -1
  326. package/dist/index.js +10 -3
  327. package/dist/index.js.map +1 -1
  328. package/dist/io/bytes-node.d.ts +11 -0
  329. package/dist/io/bytes-node.d.ts.map +1 -0
  330. package/dist/io/bytes-node.js +28 -0
  331. package/dist/io/bytes-node.js.map +1 -0
  332. package/dist/io/bytes.d.ts +33 -0
  333. package/dist/io/bytes.d.ts.map +1 -0
  334. package/dist/io/bytes.js +41 -0
  335. package/dist/io/bytes.js.map +1 -0
  336. package/dist/io/fai-zip/container-read.d.ts +102 -0
  337. package/dist/io/fai-zip/container-read.d.ts.map +1 -0
  338. package/dist/io/fai-zip/container-read.js +305 -0
  339. package/dist/io/fai-zip/container-read.js.map +1 -0
  340. package/dist/io/fai-zip/container-write.d.ts +70 -0
  341. package/dist/io/fai-zip/container-write.d.ts.map +1 -0
  342. package/dist/io/fai-zip/container-write.js +186 -0
  343. package/dist/io/fai-zip/container-write.js.map +1 -0
  344. package/dist/io/fai-zip/container.d.ts +107 -0
  345. package/dist/io/fai-zip/container.d.ts.map +1 -0
  346. package/dist/io/fai-zip/container.js +89 -0
  347. package/dist/io/fai-zip/container.js.map +1 -0
  348. package/dist/io/fai-zip/index.d.ts +18 -0
  349. package/dist/io/fai-zip/index.d.ts.map +1 -0
  350. package/dist/io/fai-zip/index.js +4 -0
  351. package/dist/io/fai-zip/index.js.map +1 -0
  352. package/dist/io/index.d.ts +10 -0
  353. package/dist/io/index.d.ts.map +1 -0
  354. package/dist/io/index.js +13 -0
  355. package/dist/io/index.js.map +1 -0
  356. package/dist/io/zip.d.ts +68 -0
  357. package/dist/io/zip.d.ts.map +1 -0
  358. package/dist/io/zip.js +147 -0
  359. package/dist/io/zip.js.map +1 -0
  360. package/dist/lang/code-to-args.d.ts +1 -1
  361. package/dist/lang/code-to-args.js +1 -1
  362. package/dist/lang/code-to-args.js.map +1 -1
  363. package/dist/lang/metadata-extractor.d.ts.map +1 -1
  364. package/dist/lang/metadata-extractor.js +2 -21
  365. package/dist/lang/metadata-extractor.js.map +1 -1
  366. package/dist/lang/statement-summary.d.ts +1 -1
  367. package/dist/lang/statement-summary.js +1 -1
  368. package/dist/lang/statement-summary.js.map +1 -1
  369. package/dist/lang/types.d.ts +6 -7
  370. package/dist/lang/types.d.ts.map +1 -1
  371. package/dist/lang/types.js +1 -1
  372. package/dist/lang/types.js.map +1 -1
  373. package/dist/mesh/index.d.ts +2 -1
  374. package/dist/mesh/index.d.ts.map +1 -1
  375. package/dist/mesh/index.js +2 -1
  376. package/dist/mesh/index.js.map +1 -1
  377. package/dist/mesh/io.d.ts +13 -0
  378. package/dist/mesh/io.d.ts.map +1 -1
  379. package/dist/mesh/io.js +38 -17
  380. package/dist/mesh/io.js.map +1 -1
  381. package/dist/mesh/primitives.d.ts.map +1 -1
  382. package/dist/mesh/primitives.js +41 -6
  383. package/dist/mesh/primitives.js.map +1 -1
  384. package/dist/mesh/reconcile.d.ts +1 -1
  385. package/dist/mesh/reconcile.js +1 -1
  386. package/dist/mesh/reconcile.js.map +1 -1
  387. package/dist/mesh/rigid-transform.d.ts +3 -3
  388. package/dist/mesh/rigid-transform.js +3 -3
  389. package/dist/mesh/rigid-transform.js.map +1 -1
  390. package/dist/mesh/stl-unit.d.ts +24 -0
  391. package/dist/mesh/stl-unit.d.ts.map +1 -0
  392. package/dist/mesh/stl-unit.js +17 -0
  393. package/dist/mesh/stl-unit.js.map +1 -0
  394. package/dist/mesh/threemf-bambu.d.ts +142 -0
  395. package/dist/mesh/threemf-bambu.d.ts.map +1 -0
  396. package/dist/mesh/threemf-bambu.js +334 -0
  397. package/dist/mesh/threemf-bambu.js.map +1 -0
  398. package/dist/mesh/threemf-loader.d.ts +65 -7
  399. package/dist/mesh/threemf-loader.d.ts.map +1 -1
  400. package/dist/mesh/threemf-loader.js +738 -99
  401. package/dist/mesh/threemf-loader.js.map +1 -1
  402. package/dist/mesh/threemf-view.d.ts +71 -0
  403. package/dist/mesh/threemf-view.d.ts.map +1 -0
  404. package/dist/mesh/threemf-view.js +100 -0
  405. package/dist/mesh/threemf-view.js.map +1 -0
  406. package/dist/mesh/types.d.ts +38 -0
  407. package/dist/mesh/types.d.ts.map +1 -1
  408. package/dist/mesh/types.js.map +1 -1
  409. package/dist/node-host/cli.d.ts +44 -6
  410. package/dist/node-host/cli.d.ts.map +1 -1
  411. package/dist/node-host/cli.js +76 -26
  412. package/dist/node-host/cli.js.map +1 -1
  413. package/dist/node-host/font-family-index.d.ts +93 -0
  414. package/dist/node-host/font-family-index.d.ts.map +1 -0
  415. package/dist/node-host/font-family-index.js +273 -0
  416. package/dist/node-host/font-family-index.js.map +1 -0
  417. package/dist/node-host/fs-asset-resolver.d.ts +8 -3
  418. package/dist/node-host/fs-asset-resolver.d.ts.map +1 -1
  419. package/dist/node-host/fs-asset-resolver.js +13 -5
  420. package/dist/node-host/fs-asset-resolver.js.map +1 -1
  421. package/dist/node-host/index.d.ts +8 -0
  422. package/dist/node-host/index.d.ts.map +1 -1
  423. package/dist/node-host/index.js +1 -0
  424. package/dist/node-host/index.js.map +1 -1
  425. package/dist/node-host/node-font-provider.d.ts +28 -0
  426. package/dist/node-host/node-font-provider.d.ts.map +1 -1
  427. package/dist/node-host/node-font-provider.js +49 -0
  428. package/dist/node-host/node-font-provider.js.map +1 -1
  429. package/dist/node.d.ts +1 -0
  430. package/dist/node.d.ts.map +1 -1
  431. package/dist/node.js +1 -0
  432. package/dist/node.js.map +1 -1
  433. package/dist/occt-kernel/highLevelApi.d.ts +4 -1
  434. package/dist/occt-kernel/highLevelApi.d.ts.map +1 -1
  435. package/dist/occt-kernel/highLevelApi.js +4 -2
  436. package/dist/occt-kernel/highLevelApi.js.map +1 -1
  437. package/dist/occt-kernel/occt-primitives.d.ts.map +1 -1
  438. package/dist/occt-kernel/occt-primitives.js +36 -3
  439. package/dist/occt-kernel/occt-primitives.js.map +1 -1
  440. package/dist/occt-kernel/occtKernel.d.ts +19 -14
  441. package/dist/occt-kernel/occtKernel.d.ts.map +1 -1
  442. package/dist/occt-kernel/occtKernel.js +19 -32
  443. package/dist/occt-kernel/occtKernel.js.map +1 -1
  444. package/dist/occt-kernel/stepColorParser.d.ts +18 -0
  445. package/dist/occt-kernel/stepColorParser.d.ts.map +1 -1
  446. package/dist/occt-kernel/stepColorParser.js +38 -0
  447. package/dist/occt-kernel/stepColorParser.js.map +1 -1
  448. package/dist/occt-kernel/stepMetaParser.d.ts +44 -0
  449. package/dist/occt-kernel/stepMetaParser.d.ts.map +1 -0
  450. package/dist/occt-kernel/stepMetaParser.js +166 -0
  451. package/dist/occt-kernel/stepMetaParser.js.map +1 -0
  452. package/dist/occt-kernel/topologyExt.d.ts +1 -1
  453. package/dist/occt-kernel/topologyExt.d.ts.map +1 -1
  454. package/dist/occt-kernel/topologyExt.js +4 -5
  455. package/dist/occt-kernel/topologyExt.js.map +1 -1
  456. package/dist/primitives/text/cjk-font.d.ts +2 -15
  457. package/dist/primitives/text/cjk-font.d.ts.map +1 -1
  458. package/dist/primitives/text/cjk-font.js +13 -1
  459. package/dist/primitives/text/cjk-font.js.map +1 -1
  460. package/dist/runtime-state.d.ts +85 -9
  461. package/dist/runtime-state.d.ts.map +1 -1
  462. package/dist/runtime-state.js +72 -2
  463. package/dist/runtime-state.js.map +1 -1
  464. package/dist/sdk.d.ts +3 -3
  465. package/dist/sdk.d.ts.map +1 -1
  466. package/dist/sdk.js +5 -5
  467. package/dist/sdk.js.map +1 -1
  468. package/dist/shape.d.ts +108 -5
  469. package/dist/shape.d.ts.map +1 -1
  470. package/dist/shape.js +130 -3
  471. package/dist/shape.js.map +1 -1
  472. package/dist/step/stepMetaParser.d.ts +55 -0
  473. package/dist/step/stepMetaParser.d.ts.map +1 -0
  474. package/dist/step/stepMetaParser.js +177 -0
  475. package/dist/step/stepMetaParser.js.map +1 -0
  476. package/dist/topology/naming/lineage.d.ts +6 -0
  477. package/dist/topology/naming/lineage.d.ts.map +1 -1
  478. package/dist/topology/naming/lineage.js +8 -0
  479. package/dist/topology/naming/lineage.js.map +1 -1
  480. package/dist/topology/naming/resolve-edge.d.ts +20 -1
  481. package/dist/topology/naming/resolve-edge.d.ts.map +1 -1
  482. package/dist/topology/naming/resolve-edge.js +54 -20
  483. package/dist/topology/naming/resolve-edge.js.map +1 -1
  484. package/dist/weapp.d.ts +6 -2
  485. package/dist/weapp.d.ts.map +1 -1
  486. package/dist/weapp.js +7 -1
  487. package/dist/weapp.js.map +1 -1
  488. package/package.json +19 -3
package/dist/shape.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * stdlib shape — 类型化构造器 + 身份槽
2
+ * api shape — 类型化构造器 + 身份槽
3
3
  *
4
4
  *
5
5
  * 变更要点:
@@ -10,11 +10,19 @@
10
10
  * - 新增 hasBrep / brepOf:引擎侧判定"某 Shape 是否在 BREP 链上"。
11
11
  */
12
12
  import type { Shape } from './mesh/types.js';
13
+ import { type ShapeAppearanceMethods } from './api/appearance.js';
14
+ import { type ShapeMetaMethods } from './api/meta.js';
13
15
  import { type ShapeSlot } from './runtime-state.js';
14
16
  /** Discriminator for the concrete shape kinds. */
15
17
  export type ShapeKind = 'solid' | 'shape2d' | 'curve' | 'compound';
16
- /** A solid mesh shape produced by a constructor. */
17
- export interface SolidShape extends Shape {
18
+ /**
19
+ * A solid mesh shape produced by a constructor.
20
+ *
21
+ * 运行时形态带外观方法(attachAppearanceMethods 在 solid()/curve() 挂载,
22
+ * 设计文档 2026-10-05 v2 §3.2/§4.2):`box1.setColor(...)` 等成员调用走
23
+ * `asm1.solve()` 同款语句形态;方法不序列化,`appearance` 字段随产物传递。
24
+ */
25
+ export interface SolidShape extends Shape, ShapeAppearanceMethods, ShapeMetaMethods {
18
26
  kind: 'solid';
19
27
  }
20
28
  /** A structural compound grouping a list of child shapes. */
@@ -29,10 +37,10 @@ export interface CompoundShape {
29
37
  * `fromBrepCurve()`)。执行链路照走 `solidToShape`(wire → 空 0/0 载荷,不抛),
30
38
  * 显示经 `wireframe`。
31
39
  */
32
- export interface CurveShape extends Shape {
40
+ export interface CurveShape extends Shape, ShapeAppearanceMethods, ShapeMetaMethods {
33
41
  kind: 'curve';
34
42
  }
35
- /** A shape that the stdlib exports as a finished result. */
43
+ /** A shape that the api layer exports as a finished result. */
36
44
  export type StdShape = SolidShape | CompoundShape | CurveShape;
37
45
  /**
38
46
  * 实体 Shape 构造器:mesh 产物必须经此创建。
@@ -77,6 +85,101 @@ export declare function fromBrep(mesh: Shape, holder: BrepHolder): SolidShape;
77
85
  * @returns the created curve shape with the BREP handle attached.
78
86
  */
79
87
  export declare function fromBrepCurve(mesh: Shape, holder: BrepHolder): CurveShape;
88
+ /**
89
+ * 网格实体产物的构造器:与 `fromBrep` 对称,登记网格实体句柄(近似链)而非
90
+ * BREP 句柄(精度链)。
91
+ *
92
+ * ```ts
93
+ * return fromMeshSolid(displayMesh, { meshSolid: result.solid })
94
+ * ```
95
+ *
96
+ * 与 `fromBrep` 的三点差别(方案 §3.2):
97
+ * 1. 写 `slot.meshSolid`,**不写** `slot.solid`——网格零件永不进 BREP 链;
98
+ * 2. 不登记函数 BREP 域(`registerFunctionBrep`)——句柄所有权在
99
+ * `MeshSolidRegistry`,按 BREP 内核释放是错的(可能是另一个内核);
100
+ * 3. 不旁挂 roleTable(近似拓扑不给语义 role——role 是 BREP 真拓扑的专有能力)。
101
+ *
102
+ * @param mesh - the mesh shape to wrap as a solid (display mesh).
103
+ * @param holder - the mesh-solid holder providing the handle identity.
104
+ * @returns the created solid shape carrying the mesh-solid slot.
105
+ */
106
+ export declare function fromMeshSolid(mesh: Shape, holder: MeshSolidHolder): SolidShape;
107
+ /** 网格实体句柄容器(与 `BrepHolder` 对称;类型为 unknown 以保持零依赖)。 */
108
+ export interface MeshSolidHolder {
109
+ /** 网格实体句柄的**身份**(句柄本体在 `MeshSolidRegistry`)。 */
110
+ meshSolid: unknown;
111
+ }
112
+ /**
113
+ * 网格链**面**产物的构造器(方案 2026-10-01 §4 Phase 3)。与 `fromBrep` 的
114
+ * 面产物对称:BREP 侧 `sketchOnFace` 返回 `fromBrep(solidToShape(kernel, face),
115
+ * { solid: face })`,这里返回 `fromMeshFace(meshShape(face), { meshFace: face })`。
116
+ *
117
+ * `kind` 沿用 `'solid'`(不是 `'shape2d'`):与 BREP 侧的面 Shape 保持同一形态,
118
+ * 好让 `extrude` 的 `isCurveShape` 预检在两条链上行为一致——面不是 1D 曲线,
119
+ * 不该被面消费 op 当成曲线拒掉。
120
+ *
121
+ * @param mesh - the face's display mesh (its own tessellation).
122
+ * @param holder - the mesh-face holder providing the handle identity.
123
+ * @returns the created shape carrying the mesh-face slot.
124
+ */
125
+ export declare function fromMeshFace(mesh: Shape, holder: MeshFaceHolder): SolidShape;
126
+ /** 网格链面句柄容器(与 `MeshSolidHolder` 对称;类型为 unknown 以保持零依赖)。 */
127
+ export interface MeshFaceHolder {
128
+ /** 网格链面句柄的**身份**。 */
129
+ meshFace: unknown;
130
+ }
131
+ /**
132
+ * 把网格实体句柄登记到已构造的 Shape。
133
+ *
134
+ * 互斥红线:该 Shape 已有 BREP 句柄或网格链面句柄时**直接抛错**——一个 Shape
135
+ * 同时声称两种链身份是设计缺陷,不能静默覆盖任何一侧。
136
+ *
137
+ * @param s - the already-constructed shape.
138
+ * @param meshSolid - the mesh solid handle.
139
+ * @throws {Error} `E_SHAPE_SLOT_EXCLUSIVE` when the shape already carries another chain identity.
140
+ */
141
+ export declare function attachMeshSolid(s: Shape, meshSolid: unknown): void;
142
+ /**
143
+ * 把网格链**面**句柄登记到已构造的 Shape。
144
+ *
145
+ * 与 `attachMeshSolid` 同一条互斥红线:已有任意另一种链身份即抛错。
146
+ *
147
+ * @param s - the already-constructed shape.
148
+ * @param meshFace - the mesh-chain face handle.
149
+ * @throws {Error} `E_SHAPE_SLOT_EXCLUSIVE` when the shape already carries another chain identity.
150
+ */
151
+ export declare function attachMeshFace(s: Shape, meshFace: unknown): void;
152
+ /**
153
+ * 该 Shape 是否携带网格链面(`sketchOnFace` 在近似拓扑面上的产物)。
154
+ *
155
+ * @param shape - the shape to test.
156
+ * @returns true if the shape carries a mesh-chain face handle.
157
+ */
158
+ export declare function hasMeshFace(shape: Shape): boolean;
159
+ /**
160
+ * 读取该 Shape 的网格链面句柄(无则 undefined)。
161
+ *
162
+ * @param shape - the shape whose mesh-chain face handle to read.
163
+ * @returns the mesh-chain face handle, or undefined if none.
164
+ */
165
+ export declare function meshFaceOf(shape: Shape): unknown | undefined;
166
+ /**
167
+ * 该 Shape 是否携带网格实体(网格零件)。引擎分派与 UI 查询用。
168
+ *
169
+ * 与 `hasBrep` 互斥:正常路径下二者不可能同时为真(`attachMeshSolid` 已经把
170
+ * 互斥钉在写入侧,`assertShapeSlotExclusive` 在分派前再兜一层)。
171
+ *
172
+ * @param shape - the shape to test.
173
+ * @returns true if the shape carries a mesh solid handle.
174
+ */
175
+ export declare function hasMeshSolid(shape: Shape): boolean;
176
+ /**
177
+ * 读取该 Shape 的网格实体句柄(无则 undefined)。
178
+ *
179
+ * @param shape - the shape whose mesh solid handle to read.
180
+ * @returns the mesh solid handle, or undefined if none.
181
+ */
182
+ export declare function meshSolidOf(shape: Shape): unknown | undefined;
80
183
  /** BREP 句柄 + 面演化 + 拓扑命名 RoleTable(对应 OCCT 的 ShapeHandle)。类型为 unknown 以保持零依赖。 */
81
184
  export interface BrepHolder {
82
185
  solid: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../src/shape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAiE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAM/G,kDAAkD;AAClD,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,CAAA;AAElE,oDAAoD;AACpD,MAAM,WAAW,UAAW,SAAQ,KAAK;IACvC,IAAI,EAAE,OAAO,CAAA;CACd;AAED,6DAA6D;AAC7D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,UAAU,CAAA;IAChB,QAAQ,EAAE,KAAK,EAAE,CAAA;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,UAAW,SAAQ,KAAK;IACvC,IAAI,EAAE,OAAO,CAAA;CACd;AAED,4DAA4D;AAC5D,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,aAAa,GAAG,UAAU,CAAA;AAE9D;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,KAAK,GAAG,UAAU,CAI7C;AAED;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,KAAK,GAAG,UAAU,CAI7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,GAAG,UAAU,CAIpE;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAA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,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,aAAa,CAIzD;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,KAAK,CAE9C;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,aAAa,CAEzD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,aAAa,CAI7D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,UAAU,CAExD;AAID,YAAY,EAAE,SAAS,EAAE,CAAA;AAEzB;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAE5D;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAQnD;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAGjE;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAE7C;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,GAAG,SAAS,CAExD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,EAAE,CAEtD"}
package/dist/shape.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * stdlib shape — 类型化构造器 + 身份槽
2
+ * api shape — 类型化构造器 + 身份槽
3
3
  *
4
4
  *
5
5
  * 变更要点:
@@ -9,6 +9,8 @@
9
9
  * 库函数不再手动登记(P2 落地)。
10
10
  * - 新增 hasBrep / brepOf:引擎侧判定"某 Shape 是否在 BREP 链上"。
11
11
  */
12
+ import { attachAppearanceMethods } from './api/appearance.js';
13
+ import { attachMetaMethods } from './api/meta.js';
12
14
  import { getRuntimeState, registerFunctionBrep, nameOf, getCurrentStmt } from './runtime-state.js';
13
15
  import { asStmtId } from './identity.js';
14
16
  import { runtimeLineage } from './topology/naming/lineage.js';
@@ -21,7 +23,7 @@ import { runtimeLineage } from './topology/naming/lineage.js';
21
23
  export function solid(mesh) {
22
24
  const s = { ...mesh, kind: 'solid' };
23
25
  getRuntimeState().created.add(s);
24
- return s;
26
+ return attachMetaMethods(attachAppearanceMethods(s));
25
27
  }
26
28
  /**
27
29
  * 1D 曲线 Shape 构造器(wire / helix / edge-loop 等 1D 产物)。
@@ -35,7 +37,7 @@ export function solid(mesh) {
35
37
  export function curve(mesh) {
36
38
  const s = { ...mesh, kind: 'curve' };
37
39
  getRuntimeState().created.add(s);
38
- return s;
40
+ return attachMetaMethods(attachAppearanceMethods(s));
39
41
  }
40
42
  /**
41
43
  * BREP 产物构造器:同时登记 mesh 与 OCCT 句柄(+ 可选面演化)。
@@ -71,6 +73,126 @@ export function fromBrepCurve(mesh, holder) {
71
73
  attachBrep(s, holder);
72
74
  return s;
73
75
  }
76
+ /**
77
+ * 网格实体产物的构造器:与 `fromBrep` 对称,登记网格实体句柄(近似链)而非
78
+ * BREP 句柄(精度链)。
79
+ *
80
+ * ```ts
81
+ * return fromMeshSolid(displayMesh, { meshSolid: result.solid })
82
+ * ```
83
+ *
84
+ * 与 `fromBrep` 的三点差别(方案 §3.2):
85
+ * 1. 写 `slot.meshSolid`,**不写** `slot.solid`——网格零件永不进 BREP 链;
86
+ * 2. 不登记函数 BREP 域(`registerFunctionBrep`)——句柄所有权在
87
+ * `MeshSolidRegistry`,按 BREP 内核释放是错的(可能是另一个内核);
88
+ * 3. 不旁挂 roleTable(近似拓扑不给语义 role——role 是 BREP 真拓扑的专有能力)。
89
+ *
90
+ * @param mesh - the mesh shape to wrap as a solid (display mesh).
91
+ * @param holder - the mesh-solid holder providing the handle identity.
92
+ * @returns the created solid shape carrying the mesh-solid slot.
93
+ */
94
+ export function fromMeshSolid(mesh, holder) {
95
+ const s = solid(mesh);
96
+ attachMeshSolid(s, holder.meshSolid);
97
+ return s;
98
+ }
99
+ /**
100
+ * 网格链**面**产物的构造器(方案 2026-10-01 §4 Phase 3)。与 `fromBrep` 的
101
+ * 面产物对称:BREP 侧 `sketchOnFace` 返回 `fromBrep(solidToShape(kernel, face),
102
+ * { solid: face })`,这里返回 `fromMeshFace(meshShape(face), { meshFace: face })`。
103
+ *
104
+ * `kind` 沿用 `'solid'`(不是 `'shape2d'`):与 BREP 侧的面 Shape 保持同一形态,
105
+ * 好让 `extrude` 的 `isCurveShape` 预检在两条链上行为一致——面不是 1D 曲线,
106
+ * 不该被面消费 op 当成曲线拒掉。
107
+ *
108
+ * @param mesh - the face's display mesh (its own tessellation).
109
+ * @param holder - the mesh-face holder providing the handle identity.
110
+ * @returns the created shape carrying the mesh-face slot.
111
+ */
112
+ export function fromMeshFace(mesh, holder) {
113
+ const s = solid(mesh);
114
+ attachMeshFace(s, holder.meshFace);
115
+ return s;
116
+ }
117
+ /**
118
+ * 把网格实体句柄登记到已构造的 Shape。
119
+ *
120
+ * 互斥红线:该 Shape 已有 BREP 句柄或网格链面句柄时**直接抛错**——一个 Shape
121
+ * 同时声称两种链身份是设计缺陷,不能静默覆盖任何一侧。
122
+ *
123
+ * @param s - the already-constructed shape.
124
+ * @param meshSolid - the mesh solid handle.
125
+ * @throws {Error} `E_SHAPE_SLOT_EXCLUSIVE` when the shape already carries another chain identity.
126
+ */
127
+ export function attachMeshSolid(s, meshSolid) {
128
+ const state = getRuntimeState();
129
+ const slot = state.slots.get(s) ?? {};
130
+ if (slot.solid !== undefined) {
131
+ throw new Error('E_SHAPE_SLOT_EXCLUSIVE: shape already carries a BREP handle — a shape is either on the precision chain or the mesh chain, never both');
132
+ }
133
+ if (slot.meshFace !== undefined) {
134
+ throw new Error('E_SHAPE_SLOT_EXCLUSIVE: shape already carries a mesh-chain face handle — a shape is either a mesh solid or a mesh-chain face, never both');
135
+ }
136
+ slot.meshSolid = meshSolid;
137
+ state.slots.set(s, slot);
138
+ }
139
+ /**
140
+ * 把网格链**面**句柄登记到已构造的 Shape。
141
+ *
142
+ * 与 `attachMeshSolid` 同一条互斥红线:已有任意另一种链身份即抛错。
143
+ *
144
+ * @param s - the already-constructed shape.
145
+ * @param meshFace - the mesh-chain face handle.
146
+ * @throws {Error} `E_SHAPE_SLOT_EXCLUSIVE` when the shape already carries another chain identity.
147
+ */
148
+ export function attachMeshFace(s, meshFace) {
149
+ const state = getRuntimeState();
150
+ const slot = state.slots.get(s) ?? {};
151
+ if (slot.solid !== undefined || slot.meshSolid !== undefined) {
152
+ throw new Error('E_SHAPE_SLOT_EXCLUSIVE: shape already carries a BREP or mesh-solid handle — a mesh-chain face is its own identity');
153
+ }
154
+ slot.meshFace = meshFace;
155
+ state.slots.set(s, slot);
156
+ }
157
+ /**
158
+ * 该 Shape 是否携带网格链面(`sketchOnFace` 在近似拓扑面上的产物)。
159
+ *
160
+ * @param shape - the shape to test.
161
+ * @returns true if the shape carries a mesh-chain face handle.
162
+ */
163
+ export function hasMeshFace(shape) {
164
+ return getRuntimeState().slots.get(shape)?.meshFace !== undefined;
165
+ }
166
+ /**
167
+ * 读取该 Shape 的网格链面句柄(无则 undefined)。
168
+ *
169
+ * @param shape - the shape whose mesh-chain face handle to read.
170
+ * @returns the mesh-chain face handle, or undefined if none.
171
+ */
172
+ export function meshFaceOf(shape) {
173
+ return getRuntimeState().slots.get(shape)?.meshFace;
174
+ }
175
+ /**
176
+ * 该 Shape 是否携带网格实体(网格零件)。引擎分派与 UI 查询用。
177
+ *
178
+ * 与 `hasBrep` 互斥:正常路径下二者不可能同时为真(`attachMeshSolid` 已经把
179
+ * 互斥钉在写入侧,`assertShapeSlotExclusive` 在分派前再兜一层)。
180
+ *
181
+ * @param shape - the shape to test.
182
+ * @returns true if the shape carries a mesh solid handle.
183
+ */
184
+ export function hasMeshSolid(shape) {
185
+ return getRuntimeState().slots.get(shape)?.meshSolid !== undefined;
186
+ }
187
+ /**
188
+ * 读取该 Shape 的网格实体句柄(无则 undefined)。
189
+ *
190
+ * @param shape - the shape whose mesh solid handle to read.
191
+ * @returns the mesh solid handle, or undefined if none.
192
+ */
193
+ export function meshSolidOf(shape) {
194
+ return getRuntimeState().slots.get(shape)?.meshSolid;
195
+ }
74
196
  /**
75
197
  * 把 BREP 句柄登记到已构造的 Shape(由 `solid` / `curve` 产出)。
76
198
  *
@@ -85,6 +207,11 @@ export function fromBrepCurve(mesh, holder) {
85
207
  function attachBrep(s, holder) {
86
208
  const state = getRuntimeState();
87
209
  const slot = state.slots.get(s) ?? {};
210
+ if (slot.meshSolid !== undefined || slot.meshFace !== undefined) {
211
+ // 互斥红线的另一侧:网格链产物不得再被登记成 BREP 实体(一个 Shape 只能
212
+ // 在精度链或网格链之一上)。
213
+ throw new Error('E_SHAPE_SLOT_EXCLUSIVE: shape already carries a mesh-chain handle — a shape is either on the precision chain or the mesh chain, never both');
214
+ }
88
215
  slot.solid = holder.solid;
89
216
  if (holder.faceEvolution)
90
217
  slot.faceEvolution = holder.faceEvolution;
package/dist/shape.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"shape.js","sourceRoot":"","sources":["../src/shape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,EAAE,cAAc,EAAkB,MAAM,iBAAiB,CAAA;AAC/G,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAgC1D;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,IAAW;IAC/B,MAAM,CAAC,GAAe,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;IAChD,eAAe,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CA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,CAAC,CAAC,CAAA;AACnD,CAAC","sourcesContent":["/**\n * stdlib shape — 类型化构造器 + 身份槽\n *\n *\n * 变更要点:\n * - 身份表(created / slots / shapeToName)改读全局锚点 runtime-state,\n * 使\"两份 faijs 代码\"共享同一份状态(解决 Shape 身份孤岛)。\n * - 新增 fromBrep(mesh, holder):BREP 产物一次登记句柄与面演化,\n * 库函数不再手动登记(P2 落地)。\n * - 新增 hasBrep / brepOf:引擎侧判定\"某 Shape 是否在 BREP 链上\"。\n */\n\nimport type { Shape } from './mesh/types'\nimport { getRuntimeState, registerFunctionBrep, nameOf, getCurrentStmt, type ShapeSlot } from './runtime-state'\nimport { asStmtId } from './identity'\nimport { runtimeLineage } from './topology/naming/lineage'\n\n// ── Shape 构造器 ──\n\n/** Discriminator for the concrete shape kinds. */\nexport type ShapeKind = 'solid' | 'shape2d' | 'curve' | 'compound'\n\n/** A solid mesh shape produced by a constructor. */\nexport interface SolidShape extends Shape {\n kind: 'solid'\n}\n\n/** A structural compound grouping a list of child shapes. */\nexport interface CompoundShape {\n kind: 'compound'\n children: Shape[]\n}\n\n/**\n * 1D 曲线 Shape(wire / helix / edge-loop 等无三角载荷的 1D 几何)。\n *\n * `kind: 'curve'` 表达「无三角载荷」,与 `'solid'` 对称(见 `curve()` /\n * `fromBrepCurve()`)。执行链路照走 `solidToShape`(wire → 空 0/0 载荷,不抛),\n * 显示经 `wireframe`。\n */\nexport interface CurveShape extends Shape {\n kind: 'curve'\n}\n\n/** A shape that the stdlib exports as a finished result. */\nexport type StdShape = SolidShape | CompoundShape | CurveShape\n\n/**\n * 实体 Shape 构造器:mesh 产物必须经此创建。\n *\n * @param mesh - the mesh shape to wrap as a solid.\n * @returns the created solid shape.\n */\nexport function solid(mesh: Shape): SolidShape {\n const s: SolidShape = { ...mesh, kind: 'solid' }\n getRuntimeState().created.add(s)\n return s\n}\n\n/**\n * 1D 曲线 Shape 构造器(wire / helix / edge-loop 等 1D 产物)。\n *\n * 与 `solid` 对称:登记到 identity 表(供 `isShape` 识别),`kind` 设为 `'curve'`\n * 以表达「无三角载荷的 1D 几何」(执行链路照走 `solidToShape`,显示经 `wireframe`)。\n *\n * @param mesh - the mesh payload (positions/indices) to wrap as a curve.\n * @returns the created curve shape.\n */\nexport function curve(mesh: Shape): CurveShape {\n const s: CurveShape = { ...mesh, kind: 'curve' }\n getRuntimeState().created.add(s)\n return s\n}\n\n/**\n * BREP 产物构造器:同时登记 mesh 与 OCCT 句柄(+ 可选面演化)。\n *\n * 库函数用它替代 `solid(mesh)` + 手动登记句柄两步行:\n * ```ts\n * return fromBrep(solidToShape(kernel, resultSolid), {\n * solid: resultSolid,\n * faceEvolution: identityEvolution(kernel, resultSolid),\n * })\n * ```\n *\n * @param mesh - the mesh shape to register.\n * @param holder - the BREP holder providing the OCCT handle and optional face evolution.\n * @returns the created solid shape with the BREP handle attached.\n */\nexport function fromBrep(mesh: Shape, holder: BrepHolder): SolidShape {\n const s = solid(mesh)\n attachBrep(s, holder)\n return s\n}\n\n/**\n * 1D 曲线产物的 BREP 登记构造器:与 `fromBrep` 对称,但 `kind` 取 `'curve'`\n * (维持既有「有无三角载荷」语义——1D 几何无三角载荷,不得报 `'solid'`)。\n * 登记逻辑与 `fromBrep` 共用 `attachBrep`,保证两种形态走同一份身份/血缘/释放语义。\n *\n * @param mesh - the mesh payload (positions/indices) to wrap as a curve.\n * @param holder - the BREP holder providing the OCCT handle and optional face evolution.\n * @returns the created curve shape with the BREP handle attached.\n */\nexport function fromBrepCurve(mesh: Shape, holder: BrepHolder): CurveShape {\n const s = curve(mesh)\n attachBrep(s, holder)\n return s\n}\n\n/**\n * 把 BREP 句柄登记到已构造的 Shape(由 `solid` / `curve` 产出)。\n *\n * 集中 brep 登记的四步(identity 槽登记已由构造器完成;此处只补:① 身份槽挂载\n * 句柄 / ② 血缘图语句键旁挂 roleTable / ③ 函数 BREP 域登记)。供 `fromBrep` /\n * `fromBrepCurve` 共用——禁止绕开本函数手写登记(否则等于复制一整套身份、血缘与\n * 释放语义)。\n *\n * @param s - the already-constructed shape (solid or curve).\n * @param holder - the BREP holder to attach.\n */\nfunction attachBrep(s: Shape, holder: BrepHolder): void {\n const state = getRuntimeState()\n const slot = state.slots.get(s) ?? {}\n slot.solid = holder.solid\n if (holder.faceEvolution) slot.faceEvolution = holder.faceEvolution\n // 1.10 前置③:roleTable **不再写 slot**(字段已删)——权威落点是下方血缘图\n // 旁挂(语句键 + part 键),解析缓存 miss 由回走重算恢复。\n state.slots.set(s, slot)\n // 1.10 前置③:roleTable 权威旁挂(**语句键**)在血缘图。part 键的记录在\n // define-op.wrapped(impl 返回后 anchor.outputs 名字已定)——此处 shape 还未\n // 被 executor 命名,nameOf(s) 为 undefined,不能在这里记 part 键。\n const stmt = getCurrentStmt()\n if (stmt && (holder.roleTable || holder.solid !== undefined)) {\n runtimeLineage.recordOutput(\n asStmtId(stmt.id),\n holder.roleTable as ReadonlyMap<string, ReadonlyMap<string, readonly number[]>> | undefined,\n holder.solid,\n )\n }\n // 函数 BREP 域(§5.6):函数体内 op 产生的新句柄登记到当前域,函数返回后统一释放\n registerFunctionBrep(holder.solid)\n}\n\n/** BREP 句柄 + 面演化 + 拓扑命名 RoleTable(对应 OCCT 的 ShapeHandle)。类型为 unknown 以保持零依赖。 */\nexport interface BrepHolder {\n solid: unknown\n faceEvolution?: Map<number, number[]>\n /**\n * 1.10 前置③:产形 op 交付 role 表的唯一入口。fromBrep 把它**旁挂到血缘图**\n * (语句键 + part 键);slot 侧的缓存存储已删(ShapeSlot 不再有该字段)。\n */\n roleTable?: unknown\n}\n\n/**\n * compound Shape 构造器:结构(层级)而非新几何。\n *\n * @param children - the child shapes to group.\n * @returns the created compound shape.\n */\nexport function compound(children: Shape[]): CompoundShape {\n const c: CompoundShape = { kind: 'compound', children }\n getRuntimeState().created.add(c)\n return c\n}\n\n/**\n * 是否为构造器产物(终端判定与 compound 检测的依据)。\n *\n * @param v - the value to test.\n * @returns true if the value was created by a shape constructor.\n */\nexport function isShape(v: unknown): v is Shape {\n return !!v && typeof v === 'object' && getRuntimeState().created.has(v)\n}\n\n/**\n * Returns true if the value is a strict compound shape created by a constructor.\n *\n * @param v - the value to test.\n * @returns true if the value is a strict compound shape.\n */\nexport function isCompound(v: unknown): v is CompoundShape {\n return isShape(v) && (v as { kind?: string }).kind === 'compound'\n}\n\n/**\n * 结构判定:是否为 compound 形态(keep-syntax §5.3 D5,对任意库函数零要求)。\n * 引擎内部的终端/消费判定用结构判定;SDK 公开的 isShape/isCompound 保持 WeakSet 严格。\n *\n * @param v - the value to test.\n * @returns true if the value has compound shape structure.\n */\nexport function isCompoundLike(v: unknown): v is CompoundShape {\n return !!v && typeof v === 'object'\n && (v as { kind?: string }).kind === 'compound'\n && Array.isArray((v as { children?: unknown }).children)\n}\n\n/**\n * 1D 曲线判定(1D 判别位,Phase 3):`kind === 'curve'`。\n *\n * 面消费 op(extrude / revolve / sweep 等)用它做**执行前**输入维度预检——\n * 1D 产物(wire / helix / sketch as:'wire')喂给面 op 时必须是明确的预检失败,\n * 不得落进内核深层才报「操作失败」。与 SDK 的 WeakSet 严格 `isShape` 不同,\n * 本判定是结构判定(与 `isCompoundLike` 同族),对跨库产物零要求。\n *\n * @param v - the value to test.\n * @returns true when the value is a 1D curve shape.\n */\nexport function isCurveShape(v: unknown): v is CurveShape {\n return !!v && typeof v === 'object' && (v as { kind?: string }).kind === 'curve'\n}\n\n// ── 身份槽 ──\n\nexport type { ShapeSlot }\n\n/**\n * 读取 Shape 的身份槽(无则 undefined)。\n *\n * @param shape - the shape whose slot to read.\n * @returns the identity slot, or undefined if none is registered.\n */\nexport function getSlot(shape: object): ShapeSlot | undefined {\n return getRuntimeState().slots.get(shape)\n}\n\n/**\n * 读取或创建 Shape 的身份槽。\n *\n * @param shape - the shape whose slot to read or create.\n * @returns the shape's identity slot.\n */\nexport function ensureSlot(shape: object): ShapeSlot {\n const state = getRuntimeState()\n let slot = state.slots.get(shape)\n if (!slot) {\n slot = {}\n state.slots.set(shape, slot)\n }\n return slot\n}\n\n/**\n * 读输入 Shape 的 roleTable(op 实现读**输入**表的唯一读口,1.10 前置③)。\n *\n * 语义 = 旧 `getSlot(shape)?.roleTable`:权威落点在血缘图的 part 键旁挂\n * (上一条语句 fromBrep 时记录),slot 缓存字段已删除。未记录 → undefined\n * (mesh 产物 / 无命名)。\n *\n * @param shape - the input shape whose role table to read.\n * @returns the role table (unknown — callers assert their table type), or undefined.\n */\nexport function inputRoleTable(shape: object): unknown | undefined {\n const name = nameOf(shape)\n return name ? runtimeLineage.tableOfPart(name) : undefined\n}\n\n/**\n * 该 Shape 是否在 BREP 链上(有 OCCT 句柄)。引擎分派与 UI 查询用。\n *\n * @param shape - the shape to test.\n * @returns true if the shape has an attached OCCT handle.\n */\nexport function hasBrep(shape: Shape): boolean {\n return getRuntimeState().slots.get(shape)?.solid !== undefined\n}\n\n/**\n * 读取该 Shape 的 OCCT 句柄(无则 undefined)。库函数用前必须判空。\n *\n * @param shape - the shape whose handle to read.\n * @returns the OCCT handle, or undefined if none.\n */\nexport function brepOf(shape: Shape): unknown | undefined {\n return getRuntimeState().slots.get(shape)?.solid\n}\n\n/**\n * nameOf 批量版:Shape[] → 成员名(装配 memberNames,P6 替代读 IR)。\n *\n * @param shapes - the shapes to name.\n * @returns the member names, one per shape (empty string when unnamed).\n */\nexport function nameOfShapes(shapes: Shape[]): string[] {\n return shapes.map((s) => String(nameOf(s) ?? ''))\n}\n"]}
1
+ {"version":3,"file":"shape.js","sourceRoot":"","sources":["../src/shape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,uBAAuB,EAA+B,MAAM,kBAAkB,CAAA;AACvF,OAAO,EAAE,iBAAiB,EAAyB,MAAM,YAAY,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,EAAE,cAAc,EAAkB,MAAM,iBAAiB,CAAA;AAC/G,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC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;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAe;IAC1C,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;AACnD,CAAC","sourcesContent":["/**\n * api shape — 类型化构造器 + 身份槽\n *\n *\n * 变更要点:\n * - 身份表(created / slots / shapeToName)改读全局锚点 runtime-state,\n * 使\"两份 faijs 代码\"共享同一份状态(解决 Shape 身份孤岛)。\n * - 新增 fromBrep(mesh, holder):BREP 产物一次登记句柄与面演化,\n * 库函数不再手动登记(P2 落地)。\n * - 新增 hasBrep / brepOf:引擎侧判定\"某 Shape 是否在 BREP 链上\"。\n */\n\nimport type { Shape } from './mesh/types'\nimport { attachAppearanceMethods, type ShapeAppearanceMethods } from './api/appearance'\nimport { attachMetaMethods, type ShapeMetaMethods } from './api/meta'\nimport { getRuntimeState, registerFunctionBrep, nameOf, getCurrentStmt, type ShapeSlot } from './runtime-state'\nimport { asStmtId } from './identity'\nimport { runtimeLineage } from './topology/naming/lineage'\n\n// ── Shape 构造器 ──\n\n/** Discriminator for the concrete shape kinds. */\nexport type ShapeKind = 'solid' | 'shape2d' | 'curve' | 'compound'\n\n/**\n * A solid mesh shape produced by a constructor.\n *\n * 运行时形态带外观方法(attachAppearanceMethods 在 solid()/curve() 挂载,\n * 设计文档 2026-10-05 v2 §3.2/§4.2):`box1.setColor(...)` 等成员调用走\n * `asm1.solve()` 同款语句形态;方法不序列化,`appearance` 字段随产物传递。\n */\nexport interface SolidShape extends Shape, ShapeAppearanceMethods, ShapeMetaMethods {\n kind: 'solid'\n}\n\n/** A structural compound grouping a list of child shapes. */\nexport interface CompoundShape {\n kind: 'compound'\n children: Shape[]\n}\n\n/**\n * 1D 曲线 Shape(wire / helix / edge-loop 等无三角载荷的 1D 几何)。\n *\n * `kind: 'curve'` 表达「无三角载荷」,与 `'solid'` 对称(见 `curve()` /\n * `fromBrepCurve()`)。执行链路照走 `solidToShape`(wire → 空 0/0 载荷,不抛),\n * 显示经 `wireframe`。\n */\nexport interface CurveShape extends Shape, ShapeAppearanceMethods, ShapeMetaMethods {\n kind: 'curve'\n}\n\n/** A shape that the api layer exports as a finished result. */\nexport type StdShape = SolidShape | CompoundShape | CurveShape\n\n/**\n * 实体 Shape 构造器:mesh 产物必须经此创建。\n *\n * @param mesh - the mesh shape to wrap as a solid.\n * @returns the created solid shape.\n */\nexport function solid(mesh: Shape): SolidShape {\n const s = { ...mesh, kind: 'solid' } as SolidShape\n getRuntimeState().created.add(s)\n return attachMetaMethods(attachAppearanceMethods(s)) as SolidShape\n}\n\n/**\n * 1D 曲线 Shape 构造器(wire / helix / edge-loop 等 1D 产物)。\n *\n * 与 `solid` 对称:登记到 identity 表(供 `isShape` 识别),`kind` 设为 `'curve'`\n * 以表达「无三角载荷的 1D 几何」(执行链路照走 `solidToShape`,显示经 `wireframe`)。\n *\n * @param mesh - the mesh payload (positions/indices) to wrap as a curve.\n * @returns the created curve shape.\n */\nexport function curve(mesh: Shape): CurveShape {\n const s = { ...mesh, kind: 'curve' } as CurveShape\n getRuntimeState().created.add(s)\n return attachMetaMethods(attachAppearanceMethods(s)) as CurveShape\n}\n\n/**\n * BREP 产物构造器:同时登记 mesh 与 OCCT 句柄(+ 可选面演化)。\n *\n * 库函数用它替代 `solid(mesh)` + 手动登记句柄两步行:\n * ```ts\n * return fromBrep(solidToShape(kernel, resultSolid), {\n * solid: resultSolid,\n * faceEvolution: identityEvolution(kernel, resultSolid),\n * })\n * ```\n *\n * @param mesh - the mesh shape to register.\n * @param holder - the BREP holder providing the OCCT handle and optional face evolution.\n * @returns the created solid shape with the BREP handle attached.\n */\nexport function fromBrep(mesh: Shape, holder: BrepHolder): SolidShape {\n const s = solid(mesh)\n attachBrep(s, holder)\n return s\n}\n\n/**\n * 1D 曲线产物的 BREP 登记构造器:与 `fromBrep` 对称,但 `kind` 取 `'curve'`\n * (维持既有「有无三角载荷」语义——1D 几何无三角载荷,不得报 `'solid'`)。\n * 登记逻辑与 `fromBrep` 共用 `attachBrep`,保证两种形态走同一份身份/血缘/释放语义。\n *\n * @param mesh - the mesh payload (positions/indices) to wrap as a curve.\n * @param holder - the BREP holder providing the OCCT handle and optional face evolution.\n * @returns the created curve shape with the BREP handle attached.\n */\nexport function fromBrepCurve(mesh: Shape, holder: BrepHolder): CurveShape {\n const s = curve(mesh)\n attachBrep(s, holder)\n return s\n}\n\n/**\n * 网格实体产物的构造器:与 `fromBrep` 对称,登记网格实体句柄(近似链)而非\n * BREP 句柄(精度链)。\n *\n * ```ts\n * return fromMeshSolid(displayMesh, { meshSolid: result.solid })\n * ```\n *\n * 与 `fromBrep` 的三点差别(方案 §3.2):\n * 1. 写 `slot.meshSolid`,**不写** `slot.solid`——网格零件永不进 BREP 链;\n * 2. 不登记函数 BREP 域(`registerFunctionBrep`)——句柄所有权在\n * `MeshSolidRegistry`,按 BREP 内核释放是错的(可能是另一个内核);\n * 3. 不旁挂 roleTable(近似拓扑不给语义 role——role 是 BREP 真拓扑的专有能力)。\n *\n * @param mesh - the mesh shape to wrap as a solid (display mesh).\n * @param holder - the mesh-solid holder providing the handle identity.\n * @returns the created solid shape carrying the mesh-solid slot.\n */\nexport function fromMeshSolid(mesh: Shape, holder: MeshSolidHolder): SolidShape {\n const s = solid(mesh)\n attachMeshSolid(s, holder.meshSolid)\n return s\n}\n\n/** 网格实体句柄容器(与 `BrepHolder` 对称;类型为 unknown 以保持零依赖)。 */\nexport interface MeshSolidHolder {\n /** 网格实体句柄的**身份**(句柄本体在 `MeshSolidRegistry`)。 */\n meshSolid: unknown\n}\n\n/**\n * 网格链**面**产物的构造器(方案 2026-10-01 §4 Phase 3)。与 `fromBrep` 的\n * 面产物对称:BREP 侧 `sketchOnFace` 返回 `fromBrep(solidToShape(kernel, face),\n * { solid: face })`,这里返回 `fromMeshFace(meshShape(face), { meshFace: face })`。\n *\n * `kind` 沿用 `'solid'`(不是 `'shape2d'`):与 BREP 侧的面 Shape 保持同一形态,\n * 好让 `extrude` 的 `isCurveShape` 预检在两条链上行为一致——面不是 1D 曲线,\n * 不该被面消费 op 当成曲线拒掉。\n *\n * @param mesh - the face's display mesh (its own tessellation).\n * @param holder - the mesh-face holder providing the handle identity.\n * @returns the created shape carrying the mesh-face slot.\n */\nexport function fromMeshFace(mesh: Shape, holder: MeshFaceHolder): SolidShape {\n const s = solid(mesh)\n attachMeshFace(s, holder.meshFace)\n return s\n}\n\n/** 网格链面句柄容器(与 `MeshSolidHolder` 对称;类型为 unknown 以保持零依赖)。 */\nexport interface MeshFaceHolder {\n /** 网格链面句柄的**身份**。 */\n meshFace: unknown\n}\n\n/**\n * 把网格实体句柄登记到已构造的 Shape。\n *\n * 互斥红线:该 Shape 已有 BREP 句柄或网格链面句柄时**直接抛错**——一个 Shape\n * 同时声称两种链身份是设计缺陷,不能静默覆盖任何一侧。\n *\n * @param s - the already-constructed shape.\n * @param meshSolid - the mesh solid handle.\n * @throws {Error} `E_SHAPE_SLOT_EXCLUSIVE` when the shape already carries another chain identity.\n */\nexport function attachMeshSolid(s: Shape, meshSolid: unknown): void {\n const state = getRuntimeState()\n const slot = state.slots.get(s) ?? {}\n if (slot.solid !== undefined) {\n throw new Error(\n 'E_SHAPE_SLOT_EXCLUSIVE: shape already carries a BREP handle — a shape is either on the precision chain or the mesh chain, never both',\n )\n }\n if (slot.meshFace !== undefined) {\n throw new Error(\n 'E_SHAPE_SLOT_EXCLUSIVE: shape already carries a mesh-chain face handle — a shape is either a mesh solid or a mesh-chain face, never both',\n )\n }\n slot.meshSolid = meshSolid\n state.slots.set(s, slot)\n}\n\n/**\n * 把网格链**面**句柄登记到已构造的 Shape。\n *\n * 与 `attachMeshSolid` 同一条互斥红线:已有任意另一种链身份即抛错。\n *\n * @param s - the already-constructed shape.\n * @param meshFace - the mesh-chain face handle.\n * @throws {Error} `E_SHAPE_SLOT_EXCLUSIVE` when the shape already carries another chain identity.\n */\nexport function attachMeshFace(s: Shape, meshFace: unknown): void {\n const state = getRuntimeState()\n const slot = state.slots.get(s) ?? {}\n if (slot.solid !== undefined || slot.meshSolid !== undefined) {\n throw new Error(\n 'E_SHAPE_SLOT_EXCLUSIVE: shape already carries a BREP or mesh-solid handle — a mesh-chain face is its own identity',\n )\n }\n slot.meshFace = meshFace\n state.slots.set(s, slot)\n}\n\n/**\n * 该 Shape 是否携带网格链面(`sketchOnFace` 在近似拓扑面上的产物)。\n *\n * @param shape - the shape to test.\n * @returns true if the shape carries a mesh-chain face handle.\n */\nexport function hasMeshFace(shape: Shape): boolean {\n return getRuntimeState().slots.get(shape)?.meshFace !== undefined\n}\n\n/**\n * 读取该 Shape 的网格链面句柄(无则 undefined)。\n *\n * @param shape - the shape whose mesh-chain face handle to read.\n * @returns the mesh-chain face handle, or undefined if none.\n */\nexport function meshFaceOf(shape: Shape): unknown | undefined {\n return getRuntimeState().slots.get(shape)?.meshFace\n}\n\n/**\n * 该 Shape 是否携带网格实体(网格零件)。引擎分派与 UI 查询用。\n *\n * 与 `hasBrep` 互斥:正常路径下二者不可能同时为真(`attachMeshSolid` 已经把\n * 互斥钉在写入侧,`assertShapeSlotExclusive` 在分派前再兜一层)。\n *\n * @param shape - the shape to test.\n * @returns true if the shape carries a mesh solid handle.\n */\nexport function hasMeshSolid(shape: Shape): boolean {\n return getRuntimeState().slots.get(shape)?.meshSolid !== undefined\n}\n\n/**\n * 读取该 Shape 的网格实体句柄(无则 undefined)。\n *\n * @param shape - the shape whose mesh solid handle to read.\n * @returns the mesh solid handle, or undefined if none.\n */\nexport function meshSolidOf(shape: Shape): unknown | undefined {\n return getRuntimeState().slots.get(shape)?.meshSolid\n}\n\n/**\n * 把 BREP 句柄登记到已构造的 Shape(由 `solid` / `curve` 产出)。\n *\n * 集中 brep 登记的四步(identity 槽登记已由构造器完成;此处只补:① 身份槽挂载\n * 句柄 / ② 血缘图语句键旁挂 roleTable / ③ 函数 BREP 域登记)。供 `fromBrep` /\n * `fromBrepCurve` 共用——禁止绕开本函数手写登记(否则等于复制一整套身份、血缘与\n * 释放语义)。\n *\n * @param s - the already-constructed shape (solid or curve).\n * @param holder - the BREP holder to attach.\n */\nfunction attachBrep(s: Shape, holder: BrepHolder): void {\n const state = getRuntimeState()\n const slot = state.slots.get(s) ?? {}\n if (slot.meshSolid !== undefined || slot.meshFace !== undefined) {\n // 互斥红线的另一侧:网格链产物不得再被登记成 BREP 实体(一个 Shape 只能\n // 在精度链或网格链之一上)。\n throw new Error(\n 'E_SHAPE_SLOT_EXCLUSIVE: shape already carries a mesh-chain handle — a shape is either on the precision chain or the mesh chain, never both',\n )\n }\n slot.solid = holder.solid\n if (holder.faceEvolution) slot.faceEvolution = holder.faceEvolution\n // 1.10 前置③:roleTable **不再写 slot**(字段已删)——权威落点是下方血缘图\n // 旁挂(语句键 + part 键),解析缓存 miss 由回走重算恢复。\n state.slots.set(s, slot)\n // 1.10 前置③:roleTable 权威旁挂(**语句键**)在血缘图。part 键的记录在\n // define-op.wrapped(impl 返回后 anchor.outputs 名字已定)——此处 shape 还未\n // 被 executor 命名,nameOf(s) 为 undefined,不能在这里记 part 键。\n const stmt = getCurrentStmt()\n if (stmt && (holder.roleTable || holder.solid !== undefined)) {\n runtimeLineage.recordOutput(\n asStmtId(stmt.id),\n holder.roleTable as ReadonlyMap<string, ReadonlyMap<string, readonly number[]>> | undefined,\n holder.solid,\n )\n }\n // 函数 BREP 域(§5.6):函数体内 op 产生的新句柄登记到当前域,函数返回后统一释放\n registerFunctionBrep(holder.solid)\n}\n\n/** BREP 句柄 + 面演化 + 拓扑命名 RoleTable(对应 OCCT 的 ShapeHandle)。类型为 unknown 以保持零依赖。 */\nexport interface BrepHolder {\n solid: unknown\n faceEvolution?: Map<number, number[]>\n /**\n * 1.10 前置③:产形 op 交付 role 表的唯一入口。fromBrep 把它**旁挂到血缘图**\n * (语句键 + part 键);slot 侧的缓存存储已删(ShapeSlot 不再有该字段)。\n */\n roleTable?: unknown\n}\n\n/**\n * compound Shape 构造器:结构(层级)而非新几何。\n *\n * @param children - the child shapes to group.\n * @returns the created compound shape.\n */\nexport function compound(children: Shape[]): CompoundShape {\n const c: CompoundShape = { kind: 'compound', children }\n getRuntimeState().created.add(c)\n return c\n}\n\n/**\n * 是否为构造器产物(终端判定与 compound 检测的依据)。\n *\n * @param v - the value to test.\n * @returns true if the value was created by a shape constructor.\n */\nexport function isShape(v: unknown): v is Shape {\n return !!v && typeof v === 'object' && getRuntimeState().created.has(v)\n}\n\n/**\n * Returns true if the value is a strict compound shape created by a constructor.\n *\n * @param v - the value to test.\n * @returns true if the value is a strict compound shape.\n */\nexport function isCompound(v: unknown): v is CompoundShape {\n return isShape(v) && (v as { kind?: string }).kind === 'compound'\n}\n\n/**\n * 结构判定:是否为 compound 形态(keep-syntax §5.3 D5,对任意库函数零要求)。\n * 引擎内部的终端/消费判定用结构判定;SDK 公开的 isShape/isCompound 保持 WeakSet 严格。\n *\n * @param v - the value to test.\n * @returns true if the value has compound shape structure.\n */\nexport function isCompoundLike(v: unknown): v is CompoundShape {\n return !!v && typeof v === 'object'\n && (v as { kind?: string }).kind === 'compound'\n && Array.isArray((v as { children?: unknown }).children)\n}\n\n/**\n * 1D 曲线判定(1D 判别位,Phase 3):`kind === 'curve'`。\n *\n * 面消费 op(extrude / revolve / sweep 等)用它做**执行前**输入维度预检——\n * 1D 产物(wire / helix / sketch as:'wire')喂给面 op 时必须是明确的预检失败,\n * 不得落进内核深层才报「操作失败」。与 SDK 的 WeakSet 严格 `isShape` 不同,\n * 本判定是结构判定(与 `isCompoundLike` 同族),对跨库产物零要求。\n *\n * @param v - the value to test.\n * @returns true when the value is a 1D curve shape.\n */\nexport function isCurveShape(v: unknown): v is CurveShape {\n return !!v && typeof v === 'object' && (v as { kind?: string }).kind === 'curve'\n}\n\n// ── 身份槽 ──\n\nexport type { ShapeSlot }\n\n/**\n * 读取 Shape 的身份槽(无则 undefined)。\n *\n * @param shape - the shape whose slot to read.\n * @returns the identity slot, or undefined if none is registered.\n */\nexport function getSlot(shape: object): ShapeSlot | undefined {\n return getRuntimeState().slots.get(shape)\n}\n\n/**\n * 读取或创建 Shape 的身份槽。\n *\n * @param shape - the shape whose slot to read or create.\n * @returns the shape's identity slot.\n */\nexport function ensureSlot(shape: object): ShapeSlot {\n const state = getRuntimeState()\n let slot = state.slots.get(shape)\n if (!slot) {\n slot = {}\n state.slots.set(shape, slot)\n }\n return slot\n}\n\n/**\n * 读输入 Shape 的 roleTable(op 实现读**输入**表的唯一读口,1.10 前置③)。\n *\n * 语义 = 旧 `getSlot(shape)?.roleTable`:权威落点在血缘图的 part 键旁挂\n * (上一条语句 fromBrep 时记录),slot 缓存字段已删除。未记录 → undefined\n * (mesh 产物 / 无命名)。\n *\n * @param shape - the input shape whose role table to read.\n * @returns the role table (unknown — callers assert their table type), or undefined.\n */\nexport function inputRoleTable(shape: object): unknown | undefined {\n const name = nameOf(shape)\n return name ? runtimeLineage.tableOfPart(name) : undefined\n}\n\n/**\n * 该 Shape 是否在 BREP 链上(有 OCCT 句柄)。引擎分派与 UI 查询用。\n *\n * @param shape - the shape to test.\n * @returns true if the shape has an attached OCCT handle.\n */\nexport function hasBrep(shape: Shape): boolean {\n return getRuntimeState().slots.get(shape)?.solid !== undefined\n}\n\n/**\n * 读取该 Shape 的 OCCT 句柄(无则 undefined)。库函数用前必须判空。\n *\n * @param shape - the shape whose handle to read.\n * @returns the OCCT handle, or undefined if none.\n */\nexport function brepOf(shape: Shape): unknown | undefined {\n return getRuntimeState().slots.get(shape)?.solid\n}\n\n/**\n * nameOf 批量版:Shape[] → 成员名(装配 memberNames,P6 替代读 IR)。\n *\n * @param shapes - the shapes to name.\n * @returns the member names, one per shape (empty string when unnamed).\n */\nexport function nameOfShapes(shapes: Shape[]): string[] {\n return shapes.map((s) => String(nameOf(s) ?? ''))\n}\n"]}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * STEP 元数据解析器 — 从 STEP (P21) 文本头部与 PRODUCT 层提取
3
+ * FileMeta(文件级)与 ShapeMeta(零件级描述字/料号)。
4
+ *
5
+ * 与 stepColorParser 同一原则:纯文本扫描,不依赖 OCCT 内核(XCAF label 层
6
+ * 是否暴露 description/属性不确定,见设计文档 2026-10-05-meta §6.3 风险 2)。
7
+ *
8
+ * 读取面映射(§3.3):
9
+ * - HEADER FILE_NAME(name,time_stamp,author,organization,preprocessor,originator)
10
+ * → title / creationDate / author / organization / application / designer。
11
+ * - HEADER FILE_DESCRIPTION(...) → description(逗号拼接,去首尾引号)。
12
+ * - DATA PRODUCT(name,description,frame)(第一个、leaf 使用的)→ 零件 description。
13
+ * name 已由 OCCT label 提供(不在本解析器处理)。
14
+ * - PRODUCT → PRODUCT_DEFINITION_FORMATION/WITH_SPECIFIED_SOURCE-关联的料号通道:
15
+ * PART_NUMBER_PROPERTY/IDENTIFICATION 命名在 §3.3 表里列出的 PART 层通道(P4
16
+ * 标 "IDENTIFICATION 内核支持" 待实测),这里尽量从 PRODUCT_DEFINITION 挂的
17
+ * UDA(GENERAL_PROPERTY + PROPERTY_DEFINITION)捞自定义属性。
18
+ *
19
+ * 所有扫描都容错:找不到就不给对应字段,绝不让解析器抛(信息性收益)。
20
+ */
21
+ /** Header 级人物贡献字段(FILE_NAME 组内的三四五参数)。 */
22
+ export interface StepFileMeta {
23
+ title?: string;
24
+ creationDate?: string;
25
+ designer?: string;
26
+ author?: string;
27
+ organization?: string;
28
+ application?: string;
29
+ description?: string;
30
+ /** 自定义 FILE_DESCRIPTION/FILE_NAME 之外的 vendor 属性(metadata 笼)。 */
31
+ metadata?: Record<string, string>;
32
+ }
33
+ /** STEP 伙伴级 P21 解析出的轻量属性。 */
34
+ export interface StepPartMeta {
35
+ /** 产品描述(PRODUCT( ..., description, id ))。空串/缺省不设。 */
36
+ description?: string;
37
+ /** 自定义属性:`PROPERTY_DEFINITION(...)` + `GENERAL_PROPERTY('name', value, ...)`。 */
38
+ metadata?: Record<string, string>;
39
+ }
40
+ /**
41
+ * Header 段整块(FILE_NAME / FILE_DESCRIPTION)→ `StepFileMeta`。
42
+ *
43
+ * @param text STEP 全文(ISO-10303-21)。
44
+ * @returns 解析出的文件级元数据;无 header 时返回空对象。
45
+ */
46
+ export declare function parseStepHeaderMeta(text: string): StepFileMeta;
47
+ /**
48
+ * 伙伴层 `PRODUCT` 描述 + 根自定义属性(UDA,`GENERAL_PROPERTY`)解析
49
+ * (简化:description 只取第一个 `PRODUCT`)。
50
+ *
51
+ * @param text STEP 全文(ISO-10303-21)。
52
+ * @returns 解析出的部分级元数据(`description`/`metadata`)。
53
+ */
54
+ export declare function parseStepPartMeta(text: string): StepPartMeta;
55
+ //# sourceMappingURL=stepMetaParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stepMetaParser.d.ts","sourceRoot":"","sources":["../../src/step/stepMetaParser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,0CAA0C;AAC1C,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAClC;AAED,6BAA6B;AAC7B,MAAM,WAAW,YAAY;IAC3B,qDAAqD;IACrD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAClC;AA2DD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CA+C9D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAyB5D"}
@@ -0,0 +1,177 @@
1
+ /**
2
+ * STEP 元数据解析器 — 从 STEP (P21) 文本头部与 PRODUCT 层提取
3
+ * FileMeta(文件级)与 ShapeMeta(零件级描述字/料号)。
4
+ *
5
+ * 与 stepColorParser 同一原则:纯文本扫描,不依赖 OCCT 内核(XCAF label 层
6
+ * 是否暴露 description/属性不确定,见设计文档 2026-10-05-meta §6.3 风险 2)。
7
+ *
8
+ * 读取面映射(§3.3):
9
+ * - HEADER FILE_NAME(name,time_stamp,author,organization,preprocessor,originator)
10
+ * → title / creationDate / author / organization / application / designer。
11
+ * - HEADER FILE_DESCRIPTION(...) → description(逗号拼接,去首尾引号)。
12
+ * - DATA PRODUCT(name,description,frame)(第一个、leaf 使用的)→ 零件 description。
13
+ * name 已由 OCCT label 提供(不在本解析器处理)。
14
+ * - PRODUCT → PRODUCT_DEFINITION_FORMATION/WITH_SPECIFIED_SOURCE-关联的料号通道:
15
+ * PART_NUMBER_PROPERTY/IDENTIFICATION 命名在 §3.3 表里列出的 PART 层通道(P4
16
+ * 标 "IDENTIFICATION 内核支持" 待实测),这里尽量从 PRODUCT_DEFINITION 挂的
17
+ * UDA(GENERAL_PROPERTY + PROPERTY_DEFINITION)捞自定义属性。
18
+ *
19
+ * 所有扫描都容错:找不到就不给对应字段,绝不让解析器抛(信息性收益)。
20
+ */
21
+ /** 剥离一层引号(STEP 字符串形如 `'abc'`),出双引号化转义;去末尾换行。 */
22
+ function unquote(s) {
23
+ const t = s.trim();
24
+ if (t.startsWith("'") && t.endsWith("'"))
25
+ return t.slice(1, -1);
26
+ return t;
27
+ }
28
+ /** 任一 `HEADER`/`DATA` 段中的实体文本(多行),从 header 段中取整行。 */
29
+ function headerLines(text) {
30
+ const m = /HEADER;\n([\s\S]*?)\nENDSEC;/.exec(text);
31
+ return m ? m[1] : '';
32
+ }
33
+ /** `TYPE(...)` 实体块捕获:从开括号起做括号配平扫描到闭合(容错 LIST/嵌套)。 */
34
+ function entityBlock(text, type) {
35
+ const re = new RegExp(`${type}\\s*\\(`, 'g');
36
+ let m;
37
+ while ((m = re.exec(text)) !== null) {
38
+ let depth = 0;
39
+ let inQuote = false;
40
+ let i = m.index + m[0].length - 1; // 停在开括号
41
+ for (; i < text.length; i++) {
42
+ const c = text[i];
43
+ if (c === "'")
44
+ inQuote = !inQuote;
45
+ if (inQuote)
46
+ continue;
47
+ if (c === '(')
48
+ depth++;
49
+ else if (c === ')') {
50
+ depth--;
51
+ if (depth === 0)
52
+ return text.slice(m.index, i + 1);
53
+ }
54
+ }
55
+ }
56
+ return undefined;
57
+ }
58
+ /** 逗号分隔的顶层简单参数(忽略嵌套括号内容仍按逗号简单切——够用即可)。 */
59
+ function splitTopLevel(body) {
60
+ // 剥离外层括号后,按未被引号包裹的逗号切分(不处理嵌套括号——STEP 伙伴级
61
+ // FILE_NAME/FILE_DESCRIPTION 参数都是简单标量/字符串,不涉及深层嵌套)。
62
+ const s = body.slice(body.indexOf('(') + 1, body.lastIndexOf(')'));
63
+ const parts = [];
64
+ let cur = '';
65
+ let inQuote = false;
66
+ for (let i = 0; i < s.length; i++) {
67
+ const c = s[i];
68
+ if (c === "'")
69
+ inQuote = !inQuote;
70
+ if (c === ',' && !inQuote) {
71
+ parts.push(cur);
72
+ cur = '';
73
+ }
74
+ else {
75
+ cur += c;
76
+ }
77
+ }
78
+ parts.push(cur);
79
+ return parts.map((p) => p.trim());
80
+ }
81
+ /**
82
+ * Header 段整块(FILE_NAME / FILE_DESCRIPTION)→ `StepFileMeta`。
83
+ *
84
+ * @param text STEP 全文(ISO-10303-21)。
85
+ * @returns 解析出的文件级元数据;无 header 时返回空对象。
86
+ */
87
+ export function parseStepHeaderMeta(text) {
88
+ const meta = {};
89
+ const header = headerLines(text);
90
+ if (!header)
91
+ return meta;
92
+ const fileBlock = entityBlock(header, 'FILE_NAME');
93
+ if (fileBlock) {
94
+ const parts = splitTopLevel(fileBlock);
95
+ // FILE_NAME(name, time_stamp, author(list), organization(list), preprocessor, originator)
96
+ // 引号数组形如 `('x')`,去首尾括号后 unquote;author/organization 可能为列表。
97
+ const inline = (p) => {
98
+ if (!p)
99
+ return undefined;
100
+ const v = unquote(p.replace(/^\(|\)$/g, ''));
101
+ return v === '' ? undefined : v;
102
+ };
103
+ const title = inline(parts[0]);
104
+ if (title)
105
+ meta.title = title;
106
+ const cdate = inline(parts[1]);
107
+ if (cdate)
108
+ meta.creationDate = cdate;
109
+ const author = inline(parts[2] ?? '');
110
+ if (author)
111
+ meta.author = author;
112
+ const org = inline(parts[3] ?? '');
113
+ if (org)
114
+ meta.organization = org;
115
+ // preprocessor → application(编辑器导入后端把 preprocessor 视为 APP);
116
+ // originator → designer。
117
+ const pre = inline(parts[4] ?? '');
118
+ if (pre)
119
+ meta.application = pre;
120
+ const origin = inline(parts[5] ?? '');
121
+ if (origin)
122
+ meta.designer = origin;
123
+ }
124
+ const descBlock = entityBlock(header, 'FILE_DESCRIPTION');
125
+ if (descBlock) {
126
+ // FILE_DESCRIPTION(description_list, implementation_context):描述只取第一个
127
+ // 顶层参数(描述串列表,`('a','b')` 形态含内层逗号);实现上下文不算。
128
+ // 直接取 `FILE_DESCRIPTION((…),` 里第一层括号内的引号字符串列表。
129
+ const m = /FILE_DESCRIPTION\s*\(\s*\((.*?)\)\s*,\s*/.exec(descBlock);
130
+ if (m) {
131
+ const joined = m[1]
132
+ .split(',')
133
+ .map((p) => unquote(p.trim()))
134
+ .filter((v) => v !== '');
135
+ if (joined.length > 0)
136
+ meta.description = joined.join(', ');
137
+ }
138
+ }
139
+ return meta;
140
+ }
141
+ /**
142
+ * 伙伴层 `PRODUCT` 描述 + 根自定义属性(UDA,`GENERAL_PROPERTY`)解析
143
+ * (简化:description 只取第一个 `PRODUCT`)。
144
+ *
145
+ * @param text STEP 全文(ISO-10303-21)。
146
+ * @returns 解析出的部分级元数据(`description`/`metadata`)。
147
+ */
148
+ export function parseStepPartMeta(text) {
149
+ const out = {};
150
+ // 逐 PRODUCT 取 description(第 2 个参数)。
151
+ const dataRe = /PRODUCT\s*\(/g;
152
+ let m;
153
+ while ((m = dataRe.exec(text)) !== null) {
154
+ const close = text.indexOf(')', m.index);
155
+ if (close < 0)
156
+ break;
157
+ const inner = text.slice(m.index, close + 1);
158
+ const descM = /,\s*'([^']*)'/.exec(inner);
159
+ if (descM) {
160
+ const d = descM[1];
161
+ if (d !== '')
162
+ out.description = d;
163
+ break; // 只取第一个
164
+ }
165
+ }
166
+ // 属性笼(UDA:GENERAL_PROPERTY('name', value?) 挂在 PROPERTY_DEFINITION 上)。
167
+ const props = {};
168
+ const gpRe = /GENERAL_PROPERTY\s*\(\s*'([^']*)'\s*,\s*([^,)]+)/g;
169
+ let gm;
170
+ while ((gm = gpRe.exec(text)) !== null) {
171
+ props[gm[1]] = unquote(gm[2]);
172
+ }
173
+ if (Object.keys(props).length > 0)
174
+ out.metadata = props;
175
+ return out;
176
+ }
177
+ //# sourceMappingURL=stepMetaParser.js.map