@faicad/faijs 0.16.1 → 0.17.0

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 (490) hide show
  1. package/LICENSE +4 -5
  2. package/NOTICE +5 -6
  3. package/dist/api/api-namespace.d.ts.map +1 -1
  4. package/dist/api/api-namespace.js +19 -1
  5. package/dist/api/api-namespace.js.map +1 -1
  6. package/dist/api/assembly/entities.d.ts +1 -1
  7. package/dist/api/assembly/entities.d.ts.map +1 -1
  8. package/dist/api/assembly/entities.js.map +1 -1
  9. package/dist/api/assembly/joints.d.ts +2 -2
  10. package/dist/api/assembly/joints.d.ts.map +1 -1
  11. package/dist/api/assembly/joints.js +2 -2
  12. package/dist/api/assembly/joints.js.map +1 -1
  13. package/dist/api/assembly/lower.d.ts +1 -1
  14. package/dist/api/assembly/lower.d.ts.map +1 -1
  15. package/dist/api/assembly/lower.js.map +1 -1
  16. package/dist/api/assembly/pose.d.ts +3 -3
  17. package/dist/api/assembly/pose.d.ts.map +1 -1
  18. package/dist/api/assembly/pose.js +1 -1
  19. package/dist/api/assembly/pose.js.map +1 -1
  20. package/dist/api/assembly/preview.d.ts +1 -1
  21. package/dist/api/assembly/preview.d.ts.map +1 -1
  22. package/dist/api/assembly/preview.js +1 -1
  23. package/dist/api/assembly/preview.js.map +1 -1
  24. package/dist/api/assembly/solve.d.ts.map +1 -1
  25. package/dist/api/assembly/solve.js +3 -3
  26. package/dist/api/assembly/solve.js.map +1 -1
  27. package/dist/api/assembly/solvers/assembly-tree.d.ts +98 -0
  28. package/dist/api/assembly/solvers/assembly-tree.d.ts.map +1 -0
  29. package/dist/api/assembly/solvers/assembly-tree.js +130 -0
  30. package/dist/api/assembly/solvers/assembly-tree.js.map +1 -0
  31. package/dist/api/assembly/solvers/chain-solver.d.ts +27 -0
  32. package/dist/api/assembly/solvers/chain-solver.d.ts.map +1 -0
  33. package/dist/api/assembly/solvers/chain-solver.js +330 -0
  34. package/dist/api/assembly/solvers/chain-solver.js.map +1 -0
  35. package/dist/api/assembly/solvers/global-solver.js +2 -2
  36. package/dist/api/assembly/solvers/global-solver.js.map +1 -1
  37. package/dist/api/assembly/solvers/joints-kinematics.d.ts +308 -0
  38. package/dist/api/assembly/solvers/joints-kinematics.d.ts.map +1 -0
  39. package/dist/api/assembly/solvers/joints-kinematics.js +643 -0
  40. package/dist/api/assembly/solvers/joints-kinematics.js.map +1 -0
  41. package/dist/api/assembly/solvers/quat.d.ts +35 -0
  42. package/dist/api/assembly/solvers/quat.d.ts.map +1 -0
  43. package/dist/api/assembly/solvers/quat.js +84 -0
  44. package/dist/api/assembly/solvers/quat.js.map +1 -0
  45. package/dist/api/assembly/solvers/types.d.ts +33 -0
  46. package/dist/api/assembly/solvers/types.d.ts.map +1 -1
  47. package/dist/api/assembly/solvers/types.js.map +1 -1
  48. package/dist/api/boolean.d.ts.map +1 -1
  49. package/dist/api/boolean.js +3 -4
  50. package/dist/api/boolean.js.map +1 -1
  51. package/dist/api/brep-mirror/booleanFns.d.ts +40 -0
  52. package/dist/api/brep-mirror/booleanFns.d.ts.map +1 -0
  53. package/dist/api/brep-mirror/booleanFns.js +99 -0
  54. package/dist/api/brep-mirror/booleanFns.js.map +1 -0
  55. package/dist/api/brep-mirror/brepHelpers.d.ts +55 -0
  56. package/dist/api/brep-mirror/brepHelpers.d.ts.map +1 -0
  57. package/dist/api/brep-mirror/brepHelpers.js +131 -0
  58. package/dist/api/brep-mirror/brepHelpers.js.map +1 -0
  59. package/dist/api/brep-mirror/compoundFns.d.ts +47 -0
  60. package/dist/api/brep-mirror/compoundFns.d.ts.map +1 -0
  61. package/dist/api/brep-mirror/compoundFns.js +300 -0
  62. package/dist/api/brep-mirror/compoundFns.js.map +1 -0
  63. package/dist/api/brep-mirror/healingFns.d.ts +78 -0
  64. package/dist/api/brep-mirror/healingFns.d.ts.map +1 -0
  65. package/dist/api/brep-mirror/healingFns.js +294 -0
  66. package/dist/api/brep-mirror/healingFns.js.map +1 -0
  67. package/dist/api/brep-mirror/hullFns.d.ts +20 -0
  68. package/dist/api/brep-mirror/hullFns.d.ts.map +1 -0
  69. package/dist/api/brep-mirror/hullFns.js +46 -0
  70. package/dist/api/brep-mirror/hullFns.js.map +1 -0
  71. package/dist/api/brep-mirror/patternFns.d.ts +43 -0
  72. package/dist/api/brep-mirror/patternFns.d.ts.map +1 -0
  73. package/dist/api/brep-mirror/patternFns.js +178 -0
  74. package/dist/api/brep-mirror/patternFns.js.map +1 -0
  75. package/dist/api/brep-mirror/primitiveFns.d.ts +42 -0
  76. package/dist/api/brep-mirror/primitiveFns.d.ts.map +1 -0
  77. package/dist/api/brep-mirror/primitiveFns.js +104 -0
  78. package/dist/api/brep-mirror/primitiveFns.js.map +1 -0
  79. package/dist/api/brep-mirror/roofFns.d.ts +24 -0
  80. package/dist/api/brep-mirror/roofFns.d.ts.map +1 -0
  81. package/dist/api/brep-mirror/roofFns.js +229 -0
  82. package/dist/api/brep-mirror/roofFns.js.map +1 -0
  83. package/dist/api/brep-mirror/straightSkeleton.d.ts +36 -0
  84. package/dist/api/brep-mirror/straightSkeleton.d.ts.map +1 -0
  85. package/dist/api/brep-mirror/straightSkeleton.js +443 -0
  86. package/dist/api/brep-mirror/straightSkeleton.js.map +1 -0
  87. package/dist/api/brep-mirror/sweepFns.d.ts +55 -0
  88. package/dist/api/brep-mirror/sweepFns.d.ts.map +1 -0
  89. package/dist/api/brep-mirror/sweepFns.js +200 -0
  90. package/dist/api/brep-mirror/sweepFns.js.map +1 -0
  91. package/dist/api/brep-mirror/threadFns.d.ts +15 -0
  92. package/dist/api/brep-mirror/threadFns.d.ts.map +1 -1
  93. package/dist/api/brep-mirror/threadFns.js +37 -2
  94. package/dist/api/brep-mirror/threadFns.js.map +1 -1
  95. package/dist/api/brep-mirror/topologyFns.d.ts +74 -0
  96. package/dist/api/brep-mirror/topologyFns.d.ts.map +1 -0
  97. package/dist/api/brep-mirror/topologyFns.js +273 -0
  98. package/dist/api/brep-mirror/topologyFns.js.map +1 -0
  99. package/dist/api/brep-topology.d.ts +190 -0
  100. package/dist/api/brep-topology.d.ts.map +1 -0
  101. package/dist/api/brep-topology.js +337 -0
  102. package/dist/api/brep-topology.js.map +1 -0
  103. package/dist/api/brepjs-compat/constants.d.ts +11 -0
  104. package/dist/api/brepjs-compat/constants.d.ts.map +1 -0
  105. package/dist/api/brepjs-compat/constants.js +11 -0
  106. package/dist/api/brepjs-compat/constants.js.map +1 -0
  107. package/dist/api/brepjs-compat/index.d.ts +19 -232
  108. package/dist/api/brepjs-compat/index.d.ts.map +1 -1
  109. package/dist/api/brepjs-compat/index.js +19 -286
  110. package/dist/api/brepjs-compat/index.js.map +1 -1
  111. package/dist/api/brepjs-compat/planeOps.d.ts +98 -0
  112. package/dist/api/brepjs-compat/planeOps.d.ts.map +1 -0
  113. package/dist/api/brepjs-compat/planeOps.js +170 -0
  114. package/dist/api/brepjs-compat/planeOps.js.map +1 -0
  115. package/dist/api/brepjs-compat/planeTypes.d.ts +24 -0
  116. package/dist/api/brepjs-compat/planeTypes.d.ts.map +1 -0
  117. package/dist/api/brepjs-compat/planeTypes.js +8 -0
  118. package/dist/api/brepjs-compat/planeTypes.js.map +1 -0
  119. package/dist/api/brepjs-compat/types.d.ts +64 -0
  120. package/dist/api/brepjs-compat/types.d.ts.map +1 -0
  121. package/dist/api/brepjs-compat/types.js +48 -0
  122. package/dist/api/brepjs-compat/types.js.map +1 -0
  123. package/dist/api/brepjs-compat/vecOps.d.ts +124 -0
  124. package/dist/api/brepjs-compat/vecOps.d.ts.map +1 -0
  125. package/dist/api/brepjs-compat/vecOps.js +202 -0
  126. package/dist/api/brepjs-compat/vecOps.js.map +1 -0
  127. package/dist/api/chamfer.d.ts +5 -0
  128. package/dist/api/chamfer.d.ts.map +1 -1
  129. package/dist/api/chamfer.js +13 -8
  130. package/dist/api/chamfer.js.map +1 -1
  131. package/dist/api/compound-geom.d.ts.map +1 -1
  132. package/dist/api/compound-geom.js +8 -2
  133. package/dist/api/compound-geom.js.map +1 -1
  134. package/dist/api/draft.d.ts +69 -0
  135. package/dist/api/draft.d.ts.map +1 -0
  136. package/dist/api/draft.js +109 -0
  137. package/dist/api/draft.js.map +1 -0
  138. package/dist/api/edge-ref.d.ts.map +1 -1
  139. package/dist/api/edge-ref.js +2 -2
  140. package/dist/api/edge-ref.js.map +1 -1
  141. package/dist/api/engrave.d.ts.map +1 -1
  142. package/dist/api/engrave.js +2 -3
  143. package/dist/api/engrave.js.map +1 -1
  144. package/dist/api/extrude.d.ts.map +1 -1
  145. package/dist/api/extrude.js +28 -13
  146. package/dist/api/extrude.js.map +1 -1
  147. package/dist/api/face-ref.d.ts.map +1 -1
  148. package/dist/api/face-ref.js +2 -2
  149. package/dist/api/face-ref.js.map +1 -1
  150. package/dist/api/feature-repair.d.ts +137 -0
  151. package/dist/api/feature-repair.d.ts.map +1 -0
  152. package/dist/api/feature-repair.js +221 -0
  153. package/dist/api/feature-repair.js.map +1 -0
  154. package/dist/api/fillet-variable.d.ts +35 -0
  155. package/dist/api/fillet-variable.d.ts.map +1 -0
  156. package/dist/api/fillet-variable.js +71 -0
  157. package/dist/api/fillet-variable.js.map +1 -0
  158. package/dist/api/fillet.d.ts +3 -0
  159. package/dist/api/fillet.d.ts.map +1 -1
  160. package/dist/api/fillet.js +7 -4
  161. package/dist/api/fillet.js.map +1 -1
  162. package/dist/api/generated/2d.d.ts +1 -13
  163. package/dist/api/generated/2d.d.ts.map +1 -1
  164. package/dist/api/generated/2d.js +6 -1
  165. package/dist/api/generated/2d.js.map +1 -1
  166. package/dist/api/generated/brepjs/index.d.ts +298 -298
  167. package/dist/api/generated/brepjs/index.d.ts.map +1 -1
  168. package/dist/api/generated/brepjs/index.js +183 -183
  169. package/dist/api/generated/brepjs/index.js.map +1 -1
  170. package/dist/api/generated/core.d.ts +3 -123
  171. package/dist/api/generated/core.d.ts.map +1 -1
  172. package/dist/api/generated/core.js +2 -81
  173. package/dist/api/generated/core.js.map +1 -1
  174. package/dist/api/generated/gear.d.ts +1 -15
  175. package/dist/api/generated/gear.d.ts.map +1 -1
  176. package/dist/api/generated/gear.js +6 -3
  177. package/dist/api/generated/gear.js.map +1 -1
  178. package/dist/api/generated/io.d.ts +1 -13
  179. package/dist/api/generated/io.d.ts.map +1 -1
  180. package/dist/api/generated/io.js +6 -1
  181. package/dist/api/generated/io.js.map +1 -1
  182. package/dist/api/generated/kernel.d.ts +1 -39
  183. package/dist/api/generated/kernel.d.ts.map +1 -1
  184. package/dist/api/generated/kernel.js +6 -4
  185. package/dist/api/generated/kernel.js.map +1 -1
  186. package/dist/api/generated/measurement.d.ts +53 -97
  187. package/dist/api/generated/measurement.d.ts.map +1 -1
  188. package/dist/api/generated/measurement.js +48 -143
  189. package/dist/api/generated/measurement.js.map +1 -1
  190. package/dist/api/generated/ns.d.ts +1 -10
  191. package/dist/api/generated/ns.d.ts.map +1 -1
  192. package/dist/api/generated/ns.js +2 -10
  193. package/dist/api/generated/ns.js.map +1 -1
  194. package/dist/api/generated/operations.d.ts +65 -110
  195. package/dist/api/generated/operations.d.ts.map +1 -1
  196. package/dist/api/generated/operations.js +132 -80
  197. package/dist/api/generated/operations.js.map +1 -1
  198. package/dist/api/generated/projection.d.ts +1 -8
  199. package/dist/api/generated/projection.d.ts.map +1 -1
  200. package/dist/api/generated/projection.js +6 -4
  201. package/dist/api/generated/projection.js.map +1 -1
  202. package/dist/api/generated/query.d.ts +1 -9
  203. package/dist/api/generated/query.d.ts.map +1 -1
  204. package/dist/api/generated/query.js +6 -1
  205. package/dist/api/generated/query.js.map +1 -1
  206. package/dist/api/generated/script-face-manifest.d.ts +2 -0
  207. package/dist/api/generated/script-face-manifest.d.ts.map +1 -1
  208. package/dist/api/generated/script-face-manifest.js +34 -22
  209. package/dist/api/generated/script-face-manifest.js.map +1 -1
  210. package/dist/api/generated/script-face.d.ts +52 -27
  211. package/dist/api/generated/script-face.d.ts.map +1 -1
  212. package/dist/api/generated/script-face.js +18 -4
  213. package/dist/api/generated/script-face.js.map +1 -1
  214. package/dist/api/generated/sketching.d.ts +4 -7
  215. package/dist/api/generated/sketching.d.ts.map +1 -1
  216. package/dist/api/generated/sketching.js +10 -8
  217. package/dist/api/generated/sketching.js.map +1 -1
  218. package/dist/api/generated/text.d.ts +1 -6
  219. package/dist/api/generated/text.d.ts.map +1 -1
  220. package/dist/api/generated/text.js +6 -3
  221. package/dist/api/generated/text.js.map +1 -1
  222. package/dist/api/generated/topology.d.ts +77 -175
  223. package/dist/api/generated/topology.d.ts.map +1 -1
  224. package/dist/api/generated/topology.js +172 -131
  225. package/dist/api/generated/topology.js.map +1 -1
  226. package/dist/api/geom.d.ts.map +1 -1
  227. package/dist/api/geom.js +2 -2
  228. package/dist/api/geom.js.map +1 -1
  229. package/dist/api/helix.d.ts +51 -0
  230. package/dist/api/helix.d.ts.map +1 -0
  231. package/dist/api/helix.js +63 -0
  232. package/dist/api/helix.js.map +1 -0
  233. package/dist/api/import-step.d.ts.map +1 -1
  234. package/dist/api/import-step.js +6 -2
  235. package/dist/api/import-step.js.map +1 -1
  236. package/dist/api/index.d.ts +18 -5
  237. package/dist/api/index.d.ts.map +1 -1
  238. package/dist/api/index.js +29 -12
  239. package/dist/api/index.js.map +1 -1
  240. package/dist/api/internal/compat-op.d.ts +10 -0
  241. package/dist/api/internal/compat-op.d.ts.map +1 -1
  242. package/dist/api/internal/compat-op.js +9 -3
  243. package/dist/api/internal/compat-op.js.map +1 -1
  244. package/dist/api/internal/compat-projection.d.ts +4 -4
  245. package/dist/api/internal/compat-projection.js +7 -7
  246. package/dist/api/internal/compat-projection.js.map +1 -1
  247. package/dist/api/internal/l3-bridge.d.ts +75 -42
  248. package/dist/api/internal/l3-bridge.d.ts.map +1 -1
  249. package/dist/api/internal/l3-bridge.js +105 -50
  250. package/dist/api/internal/l3-bridge.js.map +1 -1
  251. package/dist/api/internal/profile-wire.d.ts +31 -0
  252. package/dist/api/internal/profile-wire.d.ts.map +1 -0
  253. package/dist/api/internal/profile-wire.js +37 -0
  254. package/dist/api/internal/profile-wire.js.map +1 -0
  255. package/dist/api/internal/replica-role-table.js +2 -2
  256. package/dist/api/internal/replica-role-table.js.map +1 -1
  257. package/dist/api/loft.d.ts +66 -0
  258. package/dist/api/loft.d.ts.map +1 -0
  259. package/dist/api/loft.js +111 -0
  260. package/dist/api/loft.js.map +1 -0
  261. package/dist/api/measurement/index.d.ts +51 -0
  262. package/dist/api/measurement/index.d.ts.map +1 -0
  263. package/dist/api/measurement/index.js +71 -0
  264. package/dist/api/measurement/index.js.map +1 -0
  265. package/dist/api/occt-kernel-bridge.d.ts +5 -8
  266. package/dist/api/occt-kernel-bridge.d.ts.map +1 -1
  267. package/dist/api/occt-kernel-bridge.js +18 -14
  268. package/dist/api/occt-kernel-bridge.js.map +1 -1
  269. package/dist/api/pattern.d.ts.map +1 -1
  270. package/dist/api/pattern.js +3 -4
  271. package/dist/api/pattern.js.map +1 -1
  272. package/dist/api/place.d.ts.map +1 -1
  273. package/dist/api/place.js +2 -4
  274. package/dist/api/place.js.map +1 -1
  275. package/dist/api/primitives.d.ts.map +1 -1
  276. package/dist/api/primitives.js +3 -4
  277. package/dist/api/primitives.js.map +1 -1
  278. package/dist/api/replicate.d.ts +28 -1
  279. package/dist/api/replicate.d.ts.map +1 -1
  280. package/dist/api/replicate.js +29 -19
  281. package/dist/api/replicate.js.map +1 -1
  282. package/dist/api/result.d.ts +6 -11
  283. package/dist/api/result.d.ts.map +1 -1
  284. package/dist/api/result.js +6 -11
  285. package/dist/api/result.js.map +1 -1
  286. package/dist/api/revolve.d.ts.map +1 -1
  287. package/dist/api/revolve.js +15 -14
  288. package/dist/api/revolve.js.map +1 -1
  289. package/dist/api/screw.d.ts +3 -0
  290. package/dist/api/screw.d.ts.map +1 -1
  291. package/dist/api/screw.js +9 -4
  292. package/dist/api/screw.js.map +1 -1
  293. package/dist/api/sdf.d.ts +1 -1
  294. package/dist/api/section-by-plane.d.ts +42 -0
  295. package/dist/api/section-by-plane.d.ts.map +1 -0
  296. package/dist/api/section-by-plane.js +61 -0
  297. package/dist/api/section-by-plane.js.map +1 -0
  298. package/dist/api/shell.d.ts +45 -0
  299. package/dist/api/shell.d.ts.map +1 -0
  300. package/dist/api/shell.js +73 -0
  301. package/dist/api/shell.js.map +1 -0
  302. package/dist/api/sketch.d.ts +8 -1
  303. package/dist/api/sketch.d.ts.map +1 -1
  304. package/dist/api/sketch.js +12 -7
  305. package/dist/api/sketch.js.map +1 -1
  306. package/dist/api/split-by-plane.d.ts +41 -0
  307. package/dist/api/split-by-plane.d.ts.map +1 -0
  308. package/dist/api/split-by-plane.js +60 -0
  309. package/dist/api/split-by-plane.js.map +1 -0
  310. package/dist/api/split.d.ts +6 -1
  311. package/dist/api/split.d.ts.map +1 -1
  312. package/dist/api/split.js +23 -9
  313. package/dist/api/split.js.map +1 -1
  314. package/dist/api/surface/arg-spec.d.ts +22 -0
  315. package/dist/api/surface/arg-spec.d.ts.map +1 -1
  316. package/dist/api/surface/arg-spec.js +723 -476
  317. package/dist/api/surface/arg-spec.js.map +1 -1
  318. package/dist/api/sweep.d.ts +55 -0
  319. package/dist/api/sweep.d.ts.map +1 -0
  320. package/dist/api/sweep.js +86 -0
  321. package/dist/api/sweep.js.map +1 -0
  322. package/dist/api/thicken.d.ts +36 -0
  323. package/dist/api/thicken.d.ts.map +1 -0
  324. package/dist/api/thicken.js +55 -0
  325. package/dist/api/thicken.js.map +1 -0
  326. package/dist/api/transform.d.ts +8 -0
  327. package/dist/api/transform.d.ts.map +1 -1
  328. package/dist/api/transform.js +15 -4
  329. package/dist/api/transform.js.map +1 -1
  330. package/dist/api/view/cameraFns.d.ts +48 -0
  331. package/dist/api/view/cameraFns.d.ts.map +1 -0
  332. package/dist/api/view/cameraFns.js +75 -0
  333. package/dist/api/view/cameraFns.js.map +1 -0
  334. package/dist/api/view/projectionPlanes.d.ts +25 -0
  335. package/dist/api/view/projectionPlanes.d.ts.map +1 -0
  336. package/dist/api/view/projectionPlanes.js +30 -0
  337. package/dist/api/view/projectionPlanes.js.map +1 -0
  338. package/dist/api/view/view-camera.d.ts +2 -2
  339. package/dist/api/view/view-camera.d.ts.map +1 -1
  340. package/dist/api/view/view-camera.js +3 -3
  341. package/dist/api/view/view-camera.js.map +1 -1
  342. package/dist/api/view/view-projection.d.ts +9 -6
  343. package/dist/api/view/view-projection.d.ts.map +1 -1
  344. package/dist/api/view/view-projection.js +132 -65
  345. package/dist/api/view/view-projection.js.map +1 -1
  346. package/dist/api/wire.d.ts +45 -0
  347. package/dist/api/wire.d.ts.map +1 -0
  348. package/dist/api/wire.js +96 -0
  349. package/dist/api/wire.js.map +1 -0
  350. package/dist/boolean/creased-normals.d.ts +50 -0
  351. package/dist/boolean/creased-normals.d.ts.map +1 -0
  352. package/dist/boolean/creased-normals.js +114 -0
  353. package/dist/boolean/creased-normals.js.map +1 -0
  354. package/dist/boolean/deriveNormals.d.ts +4 -1
  355. package/dist/boolean/deriveNormals.d.ts.map +1 -1
  356. package/dist/boolean/deriveNormals.js +5 -2
  357. package/dist/boolean/deriveNormals.js.map +1 -1
  358. package/dist/brep/brep-ops.d.ts +6 -0
  359. package/dist/brep/brep-ops.d.ts.map +1 -1
  360. package/dist/brep/brep-ops.js +11 -2
  361. package/dist/brep/brep-ops.js.map +1 -1
  362. package/dist/brep/brep-topology.d.ts +4 -0
  363. package/dist/brep/brep-topology.d.ts.map +1 -1
  364. package/dist/brep/brep-topology.js +4 -0
  365. package/dist/brep/brep-topology.js.map +1 -1
  366. package/dist/brep/engine/adapters/brep-mock.d.ts.map +1 -1
  367. package/dist/brep/engine/adapters/brep-mock.js +79 -59
  368. package/dist/brep/engine/adapters/brep-mock.js.map +1 -1
  369. package/dist/brep/engine/adapters/brepkit.d.ts.map +1 -1
  370. package/dist/brep/engine/adapters/brepkit.js +7 -1
  371. package/dist/brep/engine/adapters/brepkit.js.map +1 -1
  372. package/dist/brep/engine/adapters/occt.d.ts +15 -7
  373. package/dist/brep/engine/adapters/occt.d.ts.map +1 -1
  374. package/dist/brep/engine/adapters/occt.js +52 -167
  375. package/dist/brep/engine/adapters/occt.js.map +1 -1
  376. package/dist/brep/engine/primitives.d.ts +93 -130
  377. package/dist/brep/engine/primitives.d.ts.map +1 -1
  378. package/dist/brep/engine/primitives.js +9 -7
  379. package/dist/brep/engine/primitives.js.map +1 -1
  380. package/dist/brep/engine/types.d.ts +14 -1
  381. package/dist/brep/engine/types.d.ts.map +1 -1
  382. package/dist/brep/engine/types.js +11 -1
  383. package/dist/brep/engine/types.js.map +1 -1
  384. package/dist/brep/export/step.d.ts +3 -0
  385. package/dist/brep/export/step.d.ts.map +1 -1
  386. package/dist/brep/export/step.js +7 -1
  387. package/dist/brep/export/step.js.map +1 -1
  388. package/dist/brep/face-evolution.d.ts +8 -0
  389. package/dist/brep/face-evolution.d.ts.map +1 -1
  390. package/dist/brep/face-evolution.js +15 -3
  391. package/dist/brep/face-evolution.js.map +1 -1
  392. package/dist/brep/handle-bridge.d.ts +20 -2
  393. package/dist/brep/handle-bridge.d.ts.map +1 -1
  394. package/dist/brep/handle-bridge.js +25 -2
  395. package/dist/brep/handle-bridge.js.map +1 -1
  396. package/dist/brepkit-kernel/brepkitKernel.d.ts +25 -5
  397. package/dist/brepkit-kernel/brepkitKernel.d.ts.map +1 -1
  398. package/dist/brepkit-kernel/brepkitKernel.js +336 -144
  399. package/dist/brepkit-kernel/brepkitKernel.js.map +1 -1
  400. package/dist/cad-runtime/admit-compat-lib.d.ts +6 -1
  401. package/dist/cad-runtime/admit-compat-lib.d.ts.map +1 -1
  402. package/dist/cad-runtime/admit-compat-lib.js +5 -1
  403. package/dist/cad-runtime/admit-compat-lib.js.map +1 -1
  404. package/dist/cad-runtime/backend-dispatch.d.ts +9 -3
  405. package/dist/cad-runtime/backend-dispatch.d.ts.map +1 -1
  406. package/dist/cad-runtime/backend-dispatch.js +32 -2
  407. package/dist/cad-runtime/backend-dispatch.js.map +1 -1
  408. package/dist/cad-runtime/direct-executor.d.ts.map +1 -1
  409. package/dist/cad-runtime/direct-executor.js +8 -2
  410. package/dist/cad-runtime/direct-executor.js.map +1 -1
  411. package/dist/cad-runtime/runtime.d.ts +3 -0
  412. package/dist/cad-runtime/runtime.d.ts.map +1 -1
  413. package/dist/cad-runtime/runtime.js +3 -1
  414. package/dist/cad-runtime/runtime.js.map +1 -1
  415. package/dist/define-op.d.ts +18 -2
  416. package/dist/define-op.d.ts.map +1 -1
  417. package/dist/define-op.js +29 -1
  418. package/dist/define-op.js.map +1 -1
  419. package/dist/env-agnostic.d.ts +3 -0
  420. package/dist/env-agnostic.d.ts.map +1 -1
  421. package/dist/env-agnostic.js +7 -0
  422. package/dist/env-agnostic.js.map +1 -1
  423. package/dist/index.d.ts.map +1 -1
  424. package/dist/index.js +3 -4
  425. package/dist/index.js.map +1 -1
  426. package/dist/lang/symbol-table.generated.d.ts +28 -0
  427. package/dist/lang/symbol-table.generated.d.ts.map +1 -1
  428. package/dist/lang/symbol-table.generated.js +29 -1
  429. package/dist/lang/symbol-table.generated.js.map +1 -1
  430. package/dist/occt-kernel/highLevelApi.d.ts.map +1 -1
  431. package/dist/occt-kernel/highLevelApi.js +6 -3
  432. package/dist/occt-kernel/highLevelApi.js.map +1 -1
  433. package/dist/occt-kernel/hullGeometry.d.ts +31 -0
  434. package/dist/occt-kernel/hullGeometry.d.ts.map +1 -0
  435. package/dist/occt-kernel/hullGeometry.js +319 -0
  436. package/dist/occt-kernel/hullGeometry.js.map +1 -0
  437. package/dist/occt-kernel/hullOps.d.ts +24 -0
  438. package/dist/occt-kernel/hullOps.d.ts.map +1 -0
  439. package/dist/occt-kernel/hullOps.js +52 -0
  440. package/dist/occt-kernel/hullOps.js.map +1 -0
  441. package/dist/occt-kernel/occt-primitives.d.ts +14 -0
  442. package/dist/occt-kernel/occt-primitives.d.ts.map +1 -0
  443. package/dist/occt-kernel/occt-primitives.js +351 -0
  444. package/dist/occt-kernel/occt-primitives.js.map +1 -0
  445. package/dist/occt-kernel/occtKernel.d.ts +14 -6
  446. package/dist/occt-kernel/occtKernel.d.ts.map +1 -1
  447. package/dist/occt-kernel/occtKernel.js +11 -3
  448. package/dist/occt-kernel/occtKernel.js.map +1 -1
  449. package/dist/occt-kernel/topologyExt.js +2 -2
  450. package/dist/occt-kernel/topologyExt.js.map +1 -1
  451. package/dist/primitives/brep-primitives.d.ts +4 -0
  452. package/dist/primitives/brep-primitives.d.ts.map +1 -1
  453. package/dist/primitives/brep-primitives.js +4 -0
  454. package/dist/primitives/brep-primitives.js.map +1 -1
  455. package/dist/result/bug.d.ts +22 -0
  456. package/dist/result/bug.d.ts.map +1 -0
  457. package/dist/result/bug.js +28 -0
  458. package/dist/result/bug.js.map +1 -0
  459. package/dist/result/errors.d.ts +270 -0
  460. package/dist/result/errors.d.ts.map +1 -0
  461. package/dist/result/errors.js +317 -0
  462. package/dist/result/errors.js.map +1 -0
  463. package/dist/result/kernelErrorTranslation.d.ts +21 -0
  464. package/dist/result/kernelErrorTranslation.d.ts.map +1 -0
  465. package/dist/result/kernelErrorTranslation.js +102 -0
  466. package/dist/result/kernelErrorTranslation.js.map +1 -0
  467. package/dist/result/result.d.ts +213 -0
  468. package/dist/result/result.d.ts.map +1 -0
  469. package/dist/result/result.js +336 -0
  470. package/dist/result/result.js.map +1 -0
  471. package/dist/result/vec3.d.ts +12 -0
  472. package/dist/result/vec3.d.ts.map +1 -0
  473. package/dist/result/vec3.js +14 -0
  474. package/dist/result/vec3.js.map +1 -0
  475. package/dist/runtime-state.d.ts +9 -0
  476. package/dist/runtime-state.d.ts.map +1 -1
  477. package/dist/runtime-state.js.map +1 -1
  478. package/dist/sdk.d.ts +3 -1
  479. package/dist/sdk.d.ts.map +1 -1
  480. package/dist/sdk.js +2 -1
  481. package/dist/sdk.js.map +1 -1
  482. package/dist/shape.d.ts +43 -1
  483. package/dist/shape.d.ts.map +1 -1
  484. package/dist/shape.js +57 -1
  485. package/dist/shape.js.map +1 -1
  486. package/dist/topology/naming/geom-hint.js +1 -1
  487. package/dist/topology/naming/geom-hint.js.map +1 -1
  488. package/dist/topology/naming/score.js +1 -1
  489. package/dist/topology/naming/score.js.map +1 -1
  490. package/package.json +6 -16
@@ -0,0 +1,213 @@
1
+ /**
2
+ * Rust-inspired Result<T, E> type for explicit error handling.
3
+ *
4
+ * 第一方模块(2026-09-25 core-decouple Phase 1):复制自 brepjs
5
+ * `src/core/result.ts`(同源复制,签名不变);import 来源改为 core 第一方
6
+ * `result/` 内模块。Zero internal imports beyond errors — pure foundation module.
7
+ */
8
+ import type { BrepError } from './errors.js';
9
+ /** The Ok variant of a Result, holding a success value. */
10
+ export interface Ok<T> {
11
+ readonly ok: true;
12
+ readonly value: T;
13
+ }
14
+ /** The Err variant of a Result, holding an error value. */
15
+ export interface Err<E> {
16
+ readonly ok: false;
17
+ readonly error: E;
18
+ }
19
+ /** Discriminated union of {@link Ok} and {@link Err} for explicit error handling. */
20
+ export type Result<T, E = BrepError> = Ok<T> | Err<E>;
21
+ /** Type used for Results that carry no value. */
22
+ export type Unit = undefined;
23
+ /** Wrap a success value in an Ok Result.
24
+ *
25
+ * @param value - The success value to wrap.
26
+ * @returns An Ok Result containing the value.
27
+ */
28
+ export declare function ok<T>(value: T): Ok<T>;
29
+ /** Wrap an error value in an Err Result.
30
+ *
31
+ * @param error - The error value to wrap.
32
+ * @returns An Err Result containing the error.
33
+ */
34
+ export declare function err<E>(error: E): Err<E>;
35
+ /** Singleton Ok Result carrying no value. */
36
+ export declare const OK: Ok<Unit>;
37
+ /** Type guard: check whether a Result is Ok.
38
+ *
39
+ * @param result - The Result to check.
40
+ * @returns True if the Result is Ok.
41
+ */
42
+ export declare function isOk<T, E>(result: Result<T, E>): result is Ok<T>;
43
+ /** Type guard: check whether a Result is Err.
44
+ *
45
+ * @param result - The Result to check.
46
+ * @returns True if the Result is Err.
47
+ */
48
+ export declare function isErr<T, E>(result: Result<T, E>): result is Err<E>;
49
+ /** Transform the Ok value of a Result, leaving Err unchanged.
50
+ *
51
+ * @param result - The Result to transform.
52
+ * @param fn - Function applied to the Ok value.
53
+ * @returns A Result with the transformed value, or the original error.
54
+ */
55
+ export declare function map<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E>;
56
+ /** Transform the Err value of a Result, leaving Ok unchanged.
57
+ *
58
+ * @param result - The Result to transform.
59
+ * @param fn - Function applied to the error value.
60
+ * @returns A Result with the transformed error, or the original value.
61
+ */
62
+ export declare function mapErr<T, E, F>(result: Result<T, E>, fn: (error: E) => F): Result<T, F>;
63
+ /** Chain a Result-returning function onto an Ok value.
64
+ *
65
+ * @param result - The Result to chain from.
66
+ * @param fn - Function applied to the Ok value, returning a new Result.
67
+ * @returns The chained Result, or the original error.
68
+ */
69
+ export declare function andThen<T, U, E>(result: Result<T, E>, fn: (value: T) => Result<U, E>): Result<U, E>;
70
+ /** Alias for andThen */
71
+ export declare const flatMap: typeof andThen;
72
+ /** Return `a` if Ok, otherwise return `b`.
73
+ *
74
+ * @param a - The first Result.
75
+ * @param b - The fallback Result used when `a` is Err.
76
+ * @returns `a` if Ok, otherwise `b`.
77
+ */
78
+ export declare function or<T, E, F>(a: Result<T, E>, b: Result<T, F>): Result<T, F>;
79
+ /** Return `result` if Ok, otherwise call `fn` with the error and return its result.
80
+ *
81
+ * @param result - The Result to start from.
82
+ * @param fn - Recovery function receiving the error.
83
+ * @returns The original Result if Ok, otherwise the recovery Result.
84
+ */
85
+ export declare function orElse<T, E, F>(result: Result<T, E>, fn: (error: E) => Result<T, F>): Result<T, F>;
86
+ /** Combine two independent Results into a Result of a tuple.
87
+ *
88
+ * @param a - The first Result.
89
+ * @param b - The second Result.
90
+ * @returns Ok of the value tuple, or the first Err encountered.
91
+ */
92
+ export declare function zip<A, B, E>(a: Result<A, E>, b: Result<B, E>): Result<[A, B], E>;
93
+ /** Collect an array of Results into a Result of an array. Alias for {@link collect}. */
94
+ export declare const all: typeof collect;
95
+ /** Run a side-effect on an Ok value without transforming the result.
96
+ *
97
+ * @param result - The Result to tap.
98
+ * @param fn - Side-effect function called with the Ok value.
99
+ * @returns The original Result, unchanged.
100
+ */
101
+ export declare function tap<T, E>(result: Result<T, E>, fn: (value: T) => void): Result<T, E>;
102
+ /** Run a side-effect on an Err value without transforming the result.
103
+ *
104
+ * @param result - The Result to tap.
105
+ * @param fn - Side-effect function called with the error value.
106
+ * @returns The original Result, unchanged.
107
+ */
108
+ export declare function tapErr<T, E>(result: Result<T, E>, fn: (error: E) => void): Result<T, E>;
109
+ /** Flatten a nested Result<Result<T, E>, E> into Result<T, E>.
110
+ *
111
+ * @param result - The nested Result to flatten.
112
+ * @returns The inner Result if Ok, otherwise the outer error.
113
+ */
114
+ export declare function flatten<T, E>(result: Result<Result<T, E>, E>): Result<T, E>;
115
+ /** Map both Ok and Err variants in a single pass.
116
+ *
117
+ * @param result - The Result to transform.
118
+ * @param okFn - Function applied to the Ok value.
119
+ * @param errFn - Function applied to the error value.
120
+ * @returns A Result with both variants transformed.
121
+ */
122
+ export declare function mapBoth<T, U, E, F>(result: Result<T, E>, okFn: (value: T) => U, errFn: (error: E) => F): Result<U, F>;
123
+ /** Convert a nullable value to a Result, using `errorFn` to produce the error for null/undefined.
124
+ *
125
+ * @param value - The value to wrap; may be null or undefined.
126
+ * @param errorFn - Factory producing the error for null/undefined input.
127
+ * @returns Ok containing the value, or Err from `errorFn`.
128
+ */
129
+ export declare function fromNullable<T, E>(value: T | null | undefined, errorFn: () => E): Result<T, E>;
130
+ /** Extract the Ok value, throwing if the Result is Err.
131
+ *
132
+ * @param result - The Result to unwrap.
133
+ * @returns The Ok value.
134
+ */
135
+ export declare function unwrap<T, E>(result: Result<T, E>): T;
136
+ /** Extract the Ok value, returning a default if the Result is Err.
137
+ *
138
+ * @param result - The Result to unwrap.
139
+ * @param defaultValue - Value returned when the Result is Err.
140
+ * @returns The Ok value, or the default.
141
+ */
142
+ export declare function unwrapOr<T, E>(result: Result<T, E>, defaultValue: T): T;
143
+ /** Extract the Ok value, computing a fallback from the error if the Result is Err.
144
+ *
145
+ * @param result - The Result to unwrap.
146
+ * @param fn - Function producing a fallback value from the error.
147
+ * @returns The Ok value, or the fallback.
148
+ */
149
+ export declare function unwrapOrElse<T, E>(result: Result<T, E>, fn: (error: E) => T): T;
150
+ /** Extract the Err value, throwing if the Result is Ok.
151
+ *
152
+ * @param result - The Result to unwrap.
153
+ * @returns The error value.
154
+ */
155
+ export declare function unwrapErr<T, E>(result: Result<T, E>): E;
156
+ /** Pattern-match a Result, applying the ok or err handler.
157
+ *
158
+ * @param result - The Result to match on.
159
+ * @param handlers - Object with `ok` and `err` handler functions.
160
+ * @returns The value produced by the matching handler.
161
+ */
162
+ export declare function match<T, E, U>(result: Result<T, E>, handlers: {
163
+ ok: (value: T) => U;
164
+ err: (error: E) => U;
165
+ }): U;
166
+ /**
167
+ * Collects an array of Results into a Result of an array.
168
+ * Short-circuits on the first Err.
169
+ *
170
+ * @param results - The array of Results to collect.
171
+ * @returns Ok of all values, or the first Err.
172
+ */
173
+ export declare function collect<T, E>(results: Result<T, E>[]): Result<T[], E>;
174
+ /**
175
+ * Wraps a throwing function into a Result.
176
+ * The mapError function converts the caught exception into the error type.
177
+ *
178
+ * @param fn - The function to execute.
179
+ * @param mapError - Converts a caught exception into the error type.
180
+ * @returns Ok of the result, or Err of the mapped exception.
181
+ */
182
+ export declare function tryCatch<T, E>(fn: () => T, mapError: (error: unknown) => E): Result<T, E>;
183
+ /**
184
+ * Wraps an async throwing function into a Result.
185
+ * The mapError function converts the caught exception into the error type.
186
+ *
187
+ * @param fn - The async function to execute.
188
+ * @param mapError - Converts a caught exception into the error type.
189
+ * @returns A promise resolving to Ok of the result, or Err of the mapped exception.
190
+ */
191
+ export declare function tryCatchAsync<T, E>(fn: () => Promise<T>, mapError: (error: unknown) => E): Promise<Result<T, E>>;
192
+ /** A chainable pipeline that short-circuits on the first Err. */
193
+ export interface ResultPipeline<T, E> {
194
+ /** Chain a Result-returning transform. Short-circuits on Err. */
195
+ then<U>(fn: (value: T) => Result<U, E>): ResultPipeline<U, E>;
196
+ /** Extract the final Result. */
197
+ readonly result: Result<T, E>;
198
+ }
199
+ /**
200
+ * Create a chainable pipeline from a value or Result.
201
+ *
202
+ * ```ts
203
+ * pipeline(shape)
204
+ * .then(s => filletShape(s, edges, 2))
205
+ * .then(s => shellShape(s, [topFace], 1))
206
+ * .result // → Result<Shape3D>
207
+ * ```
208
+ *
209
+ * @param input - A plain value or a Result to start the pipeline from.
210
+ * @returns A chainable pipeline wrapping the input.
211
+ */
212
+ export declare function pipeline<T, E = BrepError>(input: T | Result<T, E>): ResultPipeline<T, E>;
213
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../src/result/result.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAM1C,2DAA2D;AAC3D,MAAM,WAAW,EAAE,CAAC,CAAC;IACnB,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;CACnB;AAED,2DAA2D;AAC3D,MAAM,WAAW,GAAG,CAAC,CAAC;IACpB,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;CACnB;AAED,qFAAqF;AACrF,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AAEtD,iDAAiD;AACjD,MAAM,MAAM,IAAI,GAAG,SAAS,CAAC;AAM7B;;;;GAIG;AACH,wBAAgB,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAErC;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,C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;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CA0BxF"}
@@ -0,0 +1,336 @@
1
+ /**
2
+ * Rust-inspired Result<T, E> type for explicit error handling.
3
+ *
4
+ * 第一方模块(2026-09-25 core-decouple Phase 1):复制自 brepjs
5
+ * `src/core/result.ts`(同源复制,签名不变);import 来源改为 core 第一方
6
+ * `result/` 内模块。Zero internal imports beyond errors — pure foundation module.
7
+ */
8
+ // ---------------------------------------------------------------------------
9
+ // Constructors
10
+ // ---------------------------------------------------------------------------
11
+ /** Wrap a success value in an Ok Result.
12
+ *
13
+ * @param value - The success value to wrap.
14
+ * @returns An Ok Result containing the value.
15
+ */
16
+ export function ok(value) {
17
+ return { ok: true, value };
18
+ }
19
+ /** Wrap an error value in an Err Result.
20
+ *
21
+ * @param error - The error value to wrap.
22
+ * @returns An Err Result containing the error.
23
+ */
24
+ export function err(error) {
25
+ return { ok: false, error };
26
+ }
27
+ /** Singleton Ok Result carrying no value. */
28
+ export const OK = ok(undefined);
29
+ // ---------------------------------------------------------------------------
30
+ // Type guards
31
+ // ---------------------------------------------------------------------------
32
+ /** Type guard: check whether a Result is Ok.
33
+ *
34
+ * @param result - The Result to check.
35
+ * @returns True if the Result is Ok.
36
+ */
37
+ export function isOk(result) {
38
+ return result.ok;
39
+ }
40
+ /** Type guard: check whether a Result is Err.
41
+ *
42
+ * @param result - The Result to check.
43
+ * @returns True if the Result is Err.
44
+ */
45
+ export function isErr(result) {
46
+ return !result.ok;
47
+ }
48
+ // ---------------------------------------------------------------------------
49
+ // Combinators
50
+ // ---------------------------------------------------------------------------
51
+ /** Transform the Ok value of a Result, leaving Err unchanged.
52
+ *
53
+ * @param result - The Result to transform.
54
+ * @param fn - Function applied to the Ok value.
55
+ * @returns A Result with the transformed value, or the original error.
56
+ */
57
+ export function map(result, fn) {
58
+ if (result.ok)
59
+ return ok(fn(result.value));
60
+ return result;
61
+ }
62
+ /** Transform the Err value of a Result, leaving Ok unchanged.
63
+ *
64
+ * @param result - The Result to transform.
65
+ * @param fn - Function applied to the error value.
66
+ * @returns A Result with the transformed error, or the original value.
67
+ */
68
+ export function mapErr(result, fn) {
69
+ if (result.ok)
70
+ return result;
71
+ return err(fn(result.error));
72
+ }
73
+ /** Chain a Result-returning function onto an Ok value.
74
+ *
75
+ * @param result - The Result to chain from.
76
+ * @param fn - Function applied to the Ok value, returning a new Result.
77
+ * @returns The chained Result, or the original error.
78
+ */
79
+ export function andThen(result, fn) {
80
+ if (result.ok)
81
+ return fn(result.value);
82
+ return result;
83
+ }
84
+ /** Alias for andThen */
85
+ export const flatMap = andThen;
86
+ /** Return `a` if Ok, otherwise return `b`.
87
+ *
88
+ * @param a - The first Result.
89
+ * @param b - The fallback Result used when `a` is Err.
90
+ * @returns `a` if Ok, otherwise `b`.
91
+ */
92
+ export function or(a, b) {
93
+ if (a.ok)
94
+ return a;
95
+ return b;
96
+ }
97
+ /** Return `result` if Ok, otherwise call `fn` with the error and return its result.
98
+ *
99
+ * @param result - The Result to start from.
100
+ * @param fn - Recovery function receiving the error.
101
+ * @returns The original Result if Ok, otherwise the recovery Result.
102
+ */
103
+ export function orElse(result, fn) {
104
+ if (result.ok)
105
+ return result;
106
+ return fn(result.error);
107
+ }
108
+ /** Combine two independent Results into a Result of a tuple.
109
+ *
110
+ * @param a - The first Result.
111
+ * @param b - The second Result.
112
+ * @returns Ok of the value tuple, or the first Err encountered.
113
+ */
114
+ export function zip(a, b) {
115
+ if (!a.ok)
116
+ return a;
117
+ if (!b.ok)
118
+ return b;
119
+ return ok([a.value, b.value]);
120
+ }
121
+ /** Collect an array of Results into a Result of an array. Alias for {@link collect}. */
122
+ export const all = collect;
123
+ /** Run a side-effect on an Ok value without transforming the result.
124
+ *
125
+ * @param result - The Result to tap.
126
+ * @param fn - Side-effect function called with the Ok value.
127
+ * @returns The original Result, unchanged.
128
+ */
129
+ export function tap(result, fn) {
130
+ if (result.ok)
131
+ fn(result.value);
132
+ return result;
133
+ }
134
+ /** Run a side-effect on an Err value without transforming the result.
135
+ *
136
+ * @param result - The Result to tap.
137
+ * @param fn - Side-effect function called with the error value.
138
+ * @returns The original Result, unchanged.
139
+ */
140
+ export function tapErr(result, fn) {
141
+ if (!result.ok)
142
+ fn(result.error);
143
+ return result;
144
+ }
145
+ /** Flatten a nested Result<Result<T, E>, E> into Result<T, E>.
146
+ *
147
+ * @param result - The nested Result to flatten.
148
+ * @returns The inner Result if Ok, otherwise the outer error.
149
+ */
150
+ export function flatten(result) {
151
+ return result.ok ? result.value : result;
152
+ }
153
+ /** Map both Ok and Err variants in a single pass.
154
+ *
155
+ * @param result - The Result to transform.
156
+ * @param okFn - Function applied to the Ok value.
157
+ * @param errFn - Function applied to the error value.
158
+ * @returns A Result with both variants transformed.
159
+ */
160
+ export function mapBoth(result, okFn, errFn) {
161
+ return result.ok ? ok(okFn(result.value)) : err(errFn(result.error));
162
+ }
163
+ /** Convert a nullable value to a Result, using `errorFn` to produce the error for null/undefined.
164
+ *
165
+ * @param value - The value to wrap; may be null or undefined.
166
+ * @param errorFn - Factory producing the error for null/undefined input.
167
+ * @returns Ok containing the value, or Err from `errorFn`.
168
+ */
169
+ export function fromNullable(value, errorFn) {
170
+ if (value === null || value === undefined)
171
+ return err(errorFn());
172
+ return ok(value);
173
+ }
174
+ // ---------------------------------------------------------------------------
175
+ // Extraction
176
+ // ---------------------------------------------------------------------------
177
+ /** Format an error for display, handling BrepError objects specially */
178
+ function formatError(error) {
179
+ if (typeof error === 'object' &&
180
+ error !== null &&
181
+ 'kind' in error &&
182
+ 'code' in error &&
183
+ 'message' in error) {
184
+ // BrepError-like object
185
+ const e = error;
186
+ return `[${e.kind}] ${e.code}: ${e.message}`;
187
+ }
188
+ return String(error);
189
+ }
190
+ /** Extract the Ok value, throwing if the Result is Err.
191
+ *
192
+ * @param result - The Result to unwrap.
193
+ * @returns The Ok value.
194
+ */
195
+ export function unwrap(result) {
196
+ if (result.ok)
197
+ return result.value;
198
+ throw new Error(`Called unwrap() on an Err: ${formatError(result.error)}`);
199
+ }
200
+ /** Extract the Ok value, returning a default if the Result is Err.
201
+ *
202
+ * @param result - The Result to unwrap.
203
+ * @param defaultValue - Value returned when the Result is Err.
204
+ * @returns The Ok value, or the default.
205
+ */
206
+ export function unwrapOr(result, defaultValue) {
207
+ if (result.ok)
208
+ return result.value;
209
+ return defaultValue;
210
+ }
211
+ /** Extract the Ok value, computing a fallback from the error if the Result is Err.
212
+ *
213
+ * @param result - The Result to unwrap.
214
+ * @param fn - Function producing a fallback value from the error.
215
+ * @returns The Ok value, or the fallback.
216
+ */
217
+ export function unwrapOrElse(result, fn) {
218
+ if (result.ok)
219
+ return result.value;
220
+ return fn(result.error);
221
+ }
222
+ /** Extract the Err value, throwing if the Result is Ok.
223
+ *
224
+ * @param result - The Result to unwrap.
225
+ * @returns The error value.
226
+ */
227
+ export function unwrapErr(result) {
228
+ if (!result.ok)
229
+ return result.error;
230
+ throw new Error(`Called unwrapErr() on an Ok: ${String(result.value)}`);
231
+ }
232
+ // ---------------------------------------------------------------------------
233
+ // Pattern matching
234
+ // ---------------------------------------------------------------------------
235
+ /** Pattern-match a Result, applying the ok or err handler.
236
+ *
237
+ * @param result - The Result to match on.
238
+ * @param handlers - Object with `ok` and `err` handler functions.
239
+ * @returns The value produced by the matching handler.
240
+ */
241
+ export function match(result, handlers) {
242
+ if (result.ok)
243
+ return handlers.ok(result.value);
244
+ return handlers.err(result.error);
245
+ }
246
+ // ---------------------------------------------------------------------------
247
+ // Collection
248
+ // ---------------------------------------------------------------------------
249
+ /**
250
+ * Collects an array of Results into a Result of an array.
251
+ * Short-circuits on the first Err.
252
+ *
253
+ * @param results - The array of Results to collect.
254
+ * @returns Ok of all values, or the first Err.
255
+ */
256
+ export function collect(results) {
257
+ const values = [];
258
+ for (const result of results) {
259
+ if (!result.ok)
260
+ return result;
261
+ values.push(result.value);
262
+ }
263
+ return ok(values);
264
+ }
265
+ // ---------------------------------------------------------------------------
266
+ // Try-catch boundary
267
+ // ---------------------------------------------------------------------------
268
+ /**
269
+ * Wraps a throwing function into a Result.
270
+ * The mapError function converts the caught exception into the error type.
271
+ *
272
+ * @param fn - The function to execute.
273
+ * @param mapError - Converts a caught exception into the error type.
274
+ * @returns Ok of the result, or Err of the mapped exception.
275
+ */
276
+ export function tryCatch(fn, mapError) {
277
+ try {
278
+ return ok(fn());
279
+ }
280
+ catch (e) {
281
+ return err(mapError(e));
282
+ }
283
+ }
284
+ /**
285
+ * Wraps an async throwing function into a Result.
286
+ * The mapError function converts the caught exception into the error type.
287
+ *
288
+ * @param fn - The async function to execute.
289
+ * @param mapError - Converts a caught exception into the error type.
290
+ * @returns A promise resolving to Ok of the result, or Err of the mapped exception.
291
+ */
292
+ export async function tryCatchAsync(fn, mapError) {
293
+ try {
294
+ return ok(await fn());
295
+ }
296
+ catch (e) {
297
+ return err(mapError(e));
298
+ }
299
+ }
300
+ /**
301
+ * Create a chainable pipeline from a value or Result.
302
+ *
303
+ * ```ts
304
+ * pipeline(shape)
305
+ * .then(s => filletShape(s, edges, 2))
306
+ * .then(s => shellShape(s, [topFace], 1))
307
+ * .result // → Result<Shape3D>
308
+ * ```
309
+ *
310
+ * @param input - A plain value or a Result to start the pipeline from.
311
+ * @returns A chainable pipeline wrapping the input.
312
+ */
313
+ export function pipeline(input) {
314
+ // Detect Result objects by checking the 'ok' discriminant is a boolean
315
+ function isResult(v) {
316
+ return (typeof v === 'object' &&
317
+ v !== null &&
318
+ 'ok' in v &&
319
+ typeof v['ok'] === 'boolean');
320
+ }
321
+ const initial = isResult(input) ? input : ok(input);
322
+ function makePipeline(current) {
323
+ return {
324
+ then(fn) {
325
+ if (!current.ok)
326
+ return makePipeline(current);
327
+ return makePipeline(fn(current.value));
328
+ },
329
+ get result() {
330
+ return current;
331
+ },
332
+ };
333
+ }
334
+ return makePipeline(initial);
335
+ }
336
+ //# sourceMappingURL=result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/result/result.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA0BH,8EAA8E;AAC9E,eAAe;AACf,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,UAAU,EAAE,CAAI,KAAQ;IAC5B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC7B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAAI,KAAQ;IAC7B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC;AAED,6CAA6C;AAC7C,MAAM,CAAC,MAAM,EAAE,GAAa,EAAE,CAAC,SAAS,CAAC,CAAC;AAE1C,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAO,MAAoB;IAC7C,OAAO,MAAM,CAAC,EAAE,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAO,MAAoB;IAC9C,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;AACpB,CAAC;AAED,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,UAAU,GAAG,CAAU,MAAoB,EAAE,EAAmB;IACpE,IAAI,MAAM,CAAC,EAAE;QAAE,OAAO,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3C,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAU,MAAoB,EAAE,EAAmB;IACvE,IAAI,MAAM,CAAC,EAAE;QAAE,OAAO,MAAM,CAAC;IAC7B,OAAO,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/B,CA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A8B;gBACpC,IAAI,CAAC,OAAO,CAAC,EAAE;oBAAE,OAAO,YAAY,CAAC,OAAuB,CAAC,CAAC;gBAC9D,OAAO,YAAY,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;YACzC,CAAC;YACD,IAAI,MAAM;gBACR,OAAO,OAAO,CAAC;YACjB,CAAC;SACF,CAAC;IACJ,CAAC;IAED,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["/**\r\n * Rust-inspired Result<T, E> type for explicit error handling.\r\n *\r\n * 第一方模块(2026-09-25 core-decouple Phase 1):复制自 brepjs\r\n * `src/core/result.ts`(同源复制,签名不变);import 来源改为 core 第一方\r\n * `result/` 内模块。Zero internal imports beyond errors — pure foundation module.\r\n */\r\n\r\nimport type { BrepError } from './errors';\r\n\r\n// ---------------------------------------------------------------------------\r\n// Core types\r\n// ---------------------------------------------------------------------------\r\n\r\n/** The Ok variant of a Result, holding a success value. */\r\nexport interface Ok<T> {\r\n readonly ok: true;\r\n readonly value: T;\r\n}\r\n\r\n/** The Err variant of a Result, holding an error value. */\r\nexport interface Err<E> {\r\n readonly ok: false;\r\n readonly error: E;\r\n}\r\n\r\n/** Discriminated union of {@link Ok} and {@link Err} for explicit error handling. */\r\nexport type Result<T, E = BrepError> = Ok<T> | Err<E>;\r\n\r\n/** Type used for Results that carry no value. */\r\nexport type Unit = undefined;\r\n\r\n// ---------------------------------------------------------------------------\r\n// Constructors\r\n// ---------------------------------------------------------------------------\r\n\r\n/** Wrap a success value in an Ok Result.\r\n *\r\n * @param value - The success value to wrap.\r\n * @returns An Ok Result containing the value.\r\n */\r\nexport function ok<T>(value: T): Ok<T> {\r\n return { ok: true, value };\r\n}\r\n\r\n/** Wrap an error value in an Err Result.\r\n *\r\n * @param error - The error value to wrap.\r\n * @returns An Err Result containing the error.\r\n */\r\nexport function err<E>(error: E): Err<E> {\r\n return { ok: false, error };\r\n}\r\n\r\n/** Singleton Ok Result carrying no value. */\r\nexport const OK: Ok<Unit> = ok(undefined);\r\n\r\n// ---------------------------------------------------------------------------\r\n// Type guards\r\n// ---------------------------------------------------------------------------\r\n\r\n/** Type guard: check whether a Result is Ok.\r\n *\r\n * @param result - The Result to check.\r\n * @returns True if the Result is Ok.\r\n */\r\nexport function isOk<T, E>(result: Result<T, E>): result is Ok<T> {\r\n return result.ok;\r\n}\r\n\r\n/** Type guard: check whether a Result is Err.\r\n *\r\n * @param result - The Result to check.\r\n * @returns True if the Result is Err.\r\n */\r\nexport function isErr<T, E>(result: Result<T, E>): result is Err<E> {\r\n return !result.ok;\r\n}\r\n\r\n// ---------------------------------------------------------------------------\r\n// Combinators\r\n// ---------------------------------------------------------------------------\r\n\r\n/** Transform the Ok value of a Result, leaving Err unchanged.\r\n *\r\n * @param result - The Result to transform.\r\n * @param fn - Function applied to the Ok value.\r\n * @returns A Result with the transformed value, or the original error.\r\n */\r\nexport function map<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E> {\r\n if (result.ok) return ok(fn(result.value));\r\n return result;\r\n}\r\n\r\n/** Transform the Err value of a Result, leaving Ok unchanged.\r\n *\r\n * @param result - The Result to transform.\r\n * @param fn - Function applied to the error value.\r\n * @returns A Result with the transformed error, or the original value.\r\n */\r\nexport function mapErr<T, E, F>(result: Result<T, E>, fn: (error: E) => F): Result<T, F> {\r\n if (result.ok) return result;\r\n return err(fn(result.error));\r\n}\r\n\r\n/** Chain a Result-returning function onto an Ok value.\r\n *\r\n * @param result - The Result to chain from.\r\n * @param fn - Function applied to the Ok value, returning a new Result.\r\n * @returns The chained Result, or the original error.\r\n */\r\nexport function andThen<T, U, E>(\r\n result: Result<T, E>,\r\n fn: (value: T) => Result<U, E>\r\n): Result<U, E> {\r\n if (result.ok) return fn(result.value);\r\n return result;\r\n}\r\n\r\n/** Alias for andThen */\r\nexport const flatMap = andThen;\r\n\r\n/** Return `a` if Ok, otherwise return `b`.\r\n *\r\n * @param a - The first Result.\r\n * @param b - The fallback Result used when `a` is Err.\r\n * @returns `a` if Ok, otherwise `b`.\r\n */\r\nexport function or<T, E, F>(a: Result<T, E>, b: Result<T, F>): Result<T, F> {\r\n if (a.ok) return a;\r\n return b;\r\n}\r\n\r\n/** Return `result` if Ok, otherwise call `fn` with the error and return its result.\r\n *\r\n * @param result - The Result to start from.\r\n * @param fn - Recovery function receiving the error.\r\n * @returns The original Result if Ok, otherwise the recovery Result.\r\n */\r\nexport function orElse<T, E, F>(\r\n result: Result<T, E>,\r\n fn: (error: E) => Result<T, F>\r\n): Result<T, F> {\r\n if (result.ok) return result;\r\n return fn(result.error);\r\n}\r\n\r\n/** Combine two independent Results into a Result of a tuple.\r\n *\r\n * @param a - The first Result.\r\n * @param b - The second Result.\r\n * @returns Ok of the value tuple, or the first Err encountered.\r\n */\r\nexport function zip<A, B, E>(a: Result<A, E>, b: Result<B, E>): Result<[A, B], E> {\r\n if (!a.ok) return a;\r\n if (!b.ok) return b;\r\n return ok([a.value, b.value]);\r\n}\r\n\r\n/** Collect an array of Results into a Result of an array. Alias for {@link collect}. */\r\nexport const all = collect;\r\n\r\n/** Run a side-effect on an Ok value without transforming the result.\r\n *\r\n * @param result - The Result to tap.\r\n * @param fn - Side-effect function called with the Ok value.\r\n * @returns The original Result, unchanged.\r\n */\r\nexport function tap<T, E>(result: Result<T, E>, fn: (value: T) => void): Result<T, E> {\r\n if (result.ok) fn(result.value);\r\n return result;\r\n}\r\n\r\n/** Run a side-effect on an Err value without transforming the result.\r\n *\r\n * @param result - The Result to tap.\r\n * @param fn - Side-effect function called with the error value.\r\n * @returns The original Result, unchanged.\r\n */\r\nexport function tapErr<T, E>(result: Result<T, E>, fn: (error: E) => void): Result<T, E> {\r\n if (!result.ok) fn(result.error);\r\n return result;\r\n}\r\n\r\n/** Flatten a nested Result<Result<T, E>, E> into Result<T, E>.\r\n *\r\n * @param result - The nested Result to flatten.\r\n * @returns The inner Result if Ok, otherwise the outer error.\r\n */\r\nexport function flatten<T, E>(result: Result<Result<T, E>, E>): Result<T, E> {\r\n return result.ok ? result.value : result;\r\n}\r\n\r\n/** Map both Ok and Err variants in a single pass.\r\n *\r\n * @param result - The Result to transform.\r\n * @param okFn - Function applied to the Ok value.\r\n * @param errFn - Function applied to the error value.\r\n * @returns A Result with both variants transformed.\r\n */\r\nexport function mapBoth<T, U, E, F>(\r\n result: Result<T, E>,\r\n okFn: (value: T) => U,\r\n errFn: (error: E) => F\r\n): Result<U, F> {\r\n return result.ok ? ok(okFn(result.value)) : err(errFn(result.error));\r\n}\r\n\r\n/** Convert a nullable value to a Result, using `errorFn` to produce the error for null/undefined.\r\n *\r\n * @param value - The value to wrap; may be null or undefined.\r\n * @param errorFn - Factory producing the error for null/undefined input.\r\n * @returns Ok containing the value, or Err from `errorFn`.\r\n */\r\nexport function fromNullable<T, E>(value: T | null | undefined, errorFn: () => E): Result<T, E> {\r\n if (value === null || value === undefined) return err(errorFn());\r\n return ok(value);\r\n}\r\n\r\n// ---------------------------------------------------------------------------\r\n// Extraction\r\n// ---------------------------------------------------------------------------\r\n\r\n/** Format an error for display, handling BrepError objects specially */\r\nfunction formatError(error: unknown): string {\r\n if (\r\n typeof error === 'object' &&\r\n error !== null &&\r\n 'kind' in error &&\r\n 'code' in error &&\r\n 'message' in error\r\n ) {\r\n // BrepError-like object\r\n const e = error as { kind: string; code: string; message: string };\r\n return `[${e.kind}] ${e.code}: ${e.message}`;\r\n }\r\n return String(error);\r\n}\r\n\r\n/** Extract the Ok value, throwing if the Result is Err.\r\n *\r\n * @param result - The Result to unwrap.\r\n * @returns The Ok value.\r\n */\r\nexport function unwrap<T, E>(result: Result<T, E>): T {\r\n if (result.ok) return result.value;\r\n throw new Error(`Called unwrap() on an Err: ${formatError(result.error)}`);\r\n}\r\n\r\n/** Extract the Ok value, returning a default if the Result is Err.\r\n *\r\n * @param result - The Result to unwrap.\r\n * @param defaultValue - Value returned when the Result is Err.\r\n * @returns The Ok value, or the default.\r\n */\r\nexport function unwrapOr<T, E>(result: Result<T, E>, defaultValue: T): T {\r\n if (result.ok) return result.value;\r\n return defaultValue;\r\n}\r\n\r\n/** Extract the Ok value, computing a fallback from the error if the Result is Err.\r\n *\r\n * @param result - The Result to unwrap.\r\n * @param fn - Function producing a fallback value from the error.\r\n * @returns The Ok value, or the fallback.\r\n */\r\nexport function unwrapOrElse<T, E>(result: Result<T, E>, fn: (error: E) => T): T {\r\n if (result.ok) return result.value;\r\n return fn(result.error);\r\n}\r\n\r\n/** Extract the Err value, throwing if the Result is Ok.\r\n *\r\n * @param result - The Result to unwrap.\r\n * @returns The error value.\r\n */\r\nexport function unwrapErr<T, E>(result: Result<T, E>): E {\r\n if (!result.ok) return result.error;\r\n throw new Error(`Called unwrapErr() on an Ok: ${String(result.value)}`);\r\n}\r\n\r\n// ---------------------------------------------------------------------------\r\n// Pattern matching\r\n// ---------------------------------------------------------------------------\r\n\r\n/** Pattern-match a Result, applying the ok or err handler.\r\n *\r\n * @param result - The Result to match on.\r\n * @param handlers - Object with `ok` and `err` handler functions.\r\n * @returns The value produced by the matching handler.\r\n */\r\nexport function match<T, E, U>(\r\n result: Result<T, E>,\r\n handlers: { ok: (value: T) => U; err: (error: E) => U }\r\n): U {\r\n if (result.ok) return handlers.ok(result.value);\r\n return handlers.err(result.error);\r\n}\r\n\r\n// ---------------------------------------------------------------------------\r\n// Collection\r\n// ---------------------------------------------------------------------------\r\n\r\n/**\r\n * Collects an array of Results into a Result of an array.\r\n * Short-circuits on the first Err.\r\n *\r\n * @param results - The array of Results to collect.\r\n * @returns Ok of all values, or the first Err.\r\n */\r\nexport function collect<T, E>(results: Result<T, E>[]): Result<T[], E> {\r\n const values: T[] = [];\r\n for (const result of results) {\r\n if (!result.ok) return result;\r\n values.push(result.value);\r\n }\r\n return ok(values);\r\n}\r\n\r\n// ---------------------------------------------------------------------------\r\n// Try-catch boundary\r\n// ---------------------------------------------------------------------------\r\n\r\n/**\r\n * Wraps a throwing function into a Result.\r\n * The mapError function converts the caught exception into the error type.\r\n *\r\n * @param fn - The function to execute.\r\n * @param mapError - Converts a caught exception into the error type.\r\n * @returns Ok of the result, or Err of the mapped exception.\r\n */\r\nexport function tryCatch<T, E>(fn: () => T, mapError: (error: unknown) => E): Result<T, E> {\r\n try {\r\n return ok(fn());\r\n } catch (e: unknown) {\r\n return err(mapError(e));\r\n }\r\n}\r\n\r\n/**\r\n * Wraps an async throwing function into a Result.\r\n * The mapError function converts the caught exception into the error type.\r\n *\r\n * @param fn - The async function to execute.\r\n * @param mapError - Converts a caught exception into the error type.\r\n * @returns A promise resolving to Ok of the result, or Err of the mapped exception.\r\n */\r\nexport async function tryCatchAsync<T, E>(\r\n fn: () => Promise<T>,\r\n mapError: (error: unknown) => E\r\n): Promise<Result<T, E>> {\r\n try {\r\n return ok(await fn());\r\n } catch (e: unknown) {\r\n return err(mapError(e));\r\n }\r\n}\r\n\r\n// ---------------------------------------------------------------------------\r\n// Pipeline combinator\r\n// ---------------------------------------------------------------------------\r\n\r\n/** A chainable pipeline that short-circuits on the first Err. */\r\nexport interface ResultPipeline<T, E> {\r\n /** Chain a Result-returning transform. Short-circuits on Err. */\r\n then<U>(fn: (value: T) => Result<U, E>): ResultPipeline<U, E>;\r\n /** Extract the final Result. */\r\n readonly result: Result<T, E>;\r\n}\r\n\r\n/**\r\n * Create a chainable pipeline from a value or Result.\r\n *\r\n * ```ts\r\n * pipeline(shape)\r\n * .then(s => filletShape(s, edges, 2))\r\n * .then(s => shellShape(s, [topFace], 1))\r\n * .result // → Result<Shape3D>\r\n * ```\r\n *\r\n * @param input - A plain value or a Result to start the pipeline from.\r\n * @returns A chainable pipeline wrapping the input.\r\n */\r\nexport function pipeline<T, E = BrepError>(input: T | Result<T, E>): ResultPipeline<T, E> {\r\n // Detect Result objects by checking the 'ok' discriminant is a boolean\r\n function isResult(v: unknown): v is Result<T, E> {\r\n return (\r\n typeof v === 'object' &&\r\n v !== null &&\r\n 'ok' in v &&\r\n typeof (v as Record<string, unknown>)['ok'] === 'boolean'\r\n );\r\n }\r\n\r\n const initial: Result<T, E> = isResult(input) ? input : ok(input);\r\n\r\n function makePipeline<U>(current: Result<U, E>): ResultPipeline<U, E> {\r\n return {\r\n then<V>(fn: (value: U) => Result<V, E>): ResultPipeline<V, E> {\r\n if (!current.ok) return makePipeline(current as Result<V, E>);\r\n return makePipeline(fn(current.value));\r\n },\r\n get result(): Result<U, E> {\r\n return current;\r\n },\r\n };\r\n }\r\n\r\n return makePipeline(initial);\r\n}\r\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 第一方模块(2026-09-25 core-decouple Phase 1):`wasmIndex` 复制自 brepjs
3
+ * `src/utils/vec3.ts`(同源复制,仅提取 errors.ts 依赖的最小符号)。
4
+ */
5
+ /** Safe typed array index access(brepjs 原语义:`arr[i] as T`)。
6
+ *
7
+ * @param arr - The array to index into.
8
+ * @param i - The index to access.
9
+ * @returns The element at index `i`.
10
+ */
11
+ export declare function wasmIndex<T>(arr: ArrayLike<T>, i: number): T;
12
+ //# sourceMappingURL=vec3.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vec3.d.ts","sourceRoot":"","sources":["../../src/result/vec3.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,CAE5D"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 第一方模块(2026-09-25 core-decouple Phase 1):`wasmIndex` 复制自 brepjs
3
+ * `src/utils/vec3.ts`(同源复制,仅提取 errors.ts 依赖的最小符号)。
4
+ */
5
+ /** Safe typed array index access(brepjs 原语义:`arr[i] as T`)。
6
+ *
7
+ * @param arr - The array to index into.
8
+ * @param i - The index to access.
9
+ * @returns The element at index `i`.
10
+ */
11
+ export function wasmIndex(arr, i) {
12
+ return arr[i];
13
+ }
14
+ //# sourceMappingURL=vec3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vec3.js","sourceRoot":"","sources":["../../src/result/vec3.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAI,GAAiB,EAAE,CAAS;IACvD,OAAO,GAAG,CAAC,CAAC,CAAM,CAAC;AACrB,CAAC","sourcesContent":["/**\n * 第一方模块(2026-09-25 core-decouple Phase 1):`wasmIndex` 复制自 brepjs\n * `src/utils/vec3.ts`(同源复制,仅提取 errors.ts 依赖的最小符号)。\n */\n\n/** Safe typed array index access(brepjs 原语义:`arr[i] as T`)。\n *\n * @param arr - The array to index into.\n * @param i - The index to access.\n * @returns The element at index `i`.\n */\nexport function wasmIndex<T>(arr: ArrayLike<T>, i: number): T {\n return arr[i] as T;\n}\n"]}
@@ -55,6 +55,15 @@ export interface Backends {
55
55
  */
56
56
  brepCapabilities?: {
57
57
  evolution?: readonly string[];
58
+ /**
59
+ * 非演化内核方法名(D5):本引擎**实际提供**的 L1 中立方法名
60
+ * (`getBoundingBox` / `getVolume` / `getSurfaceArea` / `getLength` /
61
+ * `getCenterOfMass` 等)。2026-09-24 narrowing plan §2.4:与
62
+ * `backend-dispatch.EngineCapabilitiesLike` 对齐(该类型有 `methods`,
63
+ * 运行时配置镜像此前缺失——非字面量赋值不做 excess property 检查,
64
+ * `methods` 判定"能用但没被契约钉住")。
65
+ */
66
+ methods?: readonly string[];
58
67
  heal?: boolean;
59
68
  directEdit?: boolean;
60
69
  advSurface?: boolean;