brepjs 13.2.0 → 14.1.2

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 (147) hide show
  1. package/dist/2d/curve2dGeometryFns.d.ts +107 -0
  2. package/dist/2d/curve2dGeometryFns.d.ts.map +1 -0
  3. package/dist/2d.cjs +230 -3
  4. package/dist/2d.d.ts +2 -0
  5. package/dist/2d.d.ts.map +1 -1
  6. package/dist/2d.js +207 -4
  7. package/dist/arrayAccess-CmulMesb.cjs +40 -0
  8. package/dist/arrayAccess-xxcB3YNq.js +23 -0
  9. package/dist/{blueprint-DYCdRlW5.js → blueprint-B3A5x7P9.js} +10 -10
  10. package/dist/{blueprint-PLJan-W5.cjs → blueprint-D0XChcek.cjs} +14 -14
  11. package/dist/{blueprintFns-eWh7NpZx.js → blueprintFns-BwAMXY3t.js} +3 -3
  12. package/dist/{blueprintFns-Bsx25BG7.cjs → blueprintFns-COrEYX29.cjs} +3 -3
  13. package/dist/{boolean2D-CtB21ajK.cjs → boolean2D-BPsyKImE.cjs} +20 -19
  14. package/dist/{boolean2D-52qVCooY.js → boolean2D-D_Te-6N6.js} +13 -12
  15. package/dist/{booleanFns-BrptUFkP.cjs → booleanFns-B6M6Lm0V.cjs} +24 -22
  16. package/dist/{booleanFns-iM6UPb8e.js → booleanFns-CgsaJFBf.js} +8 -6
  17. package/dist/brepjs.cjs +304 -211
  18. package/dist/brepjs.js +188 -145
  19. package/dist/constants-B9u763C3.js +9 -0
  20. package/dist/constants-unWN8k4c.cjs +26 -0
  21. package/dist/core/curve2dHandle.d.ts +27 -0
  22. package/dist/core/curve2dHandle.d.ts.map +1 -0
  23. package/dist/core/errors.d.ts +11 -1
  24. package/dist/core/errors.d.ts.map +1 -1
  25. package/dist/core/kernelCall.d.ts.map +1 -1
  26. package/dist/core/kernelErrorTranslation.d.ts +2 -0
  27. package/dist/core/kernelErrorTranslation.d.ts.map +1 -1
  28. package/dist/core.cjs +9 -8
  29. package/dist/core.js +6 -5
  30. package/dist/{cornerFinder-C7aDyYLJ.js → cornerFinder-AEFnAxt4.js} +3 -3
  31. package/dist/{cornerFinder-SF-xmMO1.cjs → cornerFinder-DTt_SvtC.cjs} +4 -4
  32. package/dist/{curveFns-C-jU1_Y_.js → curveFns-CcInoOEA.js} +2 -2
  33. package/dist/{curveFns-ywh7Ctyk.cjs → curveFns-DCEcwcpd.cjs} +2 -2
  34. package/dist/{drawFns-DknEB-Qs.cjs → drawFns-BOwBIzPa.cjs} +35 -18
  35. package/dist/{drawFns-D-0p86Lf.js → drawFns-n9qif7QN.js} +17 -15
  36. package/dist/{errors-DupKEMqI.cjs → errors-9zQcQK1H.cjs} +34 -0
  37. package/dist/{errors-B_T0aMQF.js → errors-C-cgQA3w.js} +29 -1
  38. package/dist/{extrudeFns-LsH1rDMa.js → extrudeFns-DrDr9-nU.js} +3 -3
  39. package/dist/{extrudeFns-CGCIbydL.cjs → extrudeFns-Rcut7h8S.cjs} +3 -3
  40. package/dist/{faceFns-EnGcKFAr.js → faceFns-TSH54pPQ.js} +94 -4
  41. package/dist/{faceFns-8dGb8q3J.cjs → faceFns-cE2WxY6I.cjs} +111 -3
  42. package/dist/{helpers-pQpV9Mwh.cjs → helpers-DZje6XWE.cjs} +18 -17
  43. package/dist/{helpers-Rf0vhX6I.js → helpers-XrXlKm8D.js} +8 -7
  44. package/dist/{historyFns-XkjLAQyu.js → historyFns-2hCWrX_X.js} +10 -10
  45. package/dist/{historyFns-lNalnOdR.cjs → historyFns-BiQ9dmzp.cjs} +10 -10
  46. package/dist/{importFns-BSH9cGIp.cjs → importFns-DGE5nCSW.cjs} +4 -4
  47. package/dist/{importFns-Bgs-FYAP.js → importFns-m0xyj0Zt.js} +4 -4
  48. package/dist/index.d.ts +14 -0
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/io.cjs +2 -2
  51. package/dist/io.js +2 -2
  52. package/dist/kernel/brepkit/brepkitAdapter.d.ts +150 -241
  53. package/dist/kernel/brepkit/brepkitAdapter.d.ts.map +1 -1
  54. package/dist/kernel/brepkit/evolutionOps.d.ts +1 -0
  55. package/dist/kernel/brepkit/evolutionOps.d.ts.map +1 -1
  56. package/dist/kernel/index.d.ts +1 -1
  57. package/dist/kernel/index.d.ts.map +1 -1
  58. package/dist/kernel/interfaces/curveOps.d.ts +3 -1
  59. package/dist/kernel/interfaces/curveOps.d.ts.map +1 -1
  60. package/dist/kernel/interfaces/surfaceOps.d.ts +3 -1
  61. package/dist/kernel/interfaces/surfaceOps.d.ts.map +1 -1
  62. package/dist/kernel/occt/defaultAdapter.d.ts +3 -1
  63. package/dist/kernel/occt/defaultAdapter.d.ts.map +1 -1
  64. package/dist/kernel/occt/nurbsQueryOps.d.ts +12 -0
  65. package/dist/kernel/occt/nurbsQueryOps.d.ts.map +1 -0
  66. package/dist/kernel/types.d.ts +26 -0
  67. package/dist/kernel/types.d.ts.map +1 -1
  68. package/dist/{measureFns-D7J6qUY_.js → measureFns-DHByqdmn.js} +9 -16
  69. package/dist/{measureFns-CFdHa_fj.cjs → measureFns-D_QKZ5yg.cjs} +9 -16
  70. package/dist/measurement/measureFns.d.ts.map +1 -1
  71. package/dist/measurement.cjs +1 -1
  72. package/dist/measurement.js +1 -1
  73. package/dist/{meshFns-2XnDXgIh.cjs → meshFns-CVe3Kc77.cjs} +4 -4
  74. package/dist/{meshFns-B7uklc4M.js → meshFns-DL4Djz3w.js} +3 -3
  75. package/dist/ns/booleans.d.ts +10 -0
  76. package/dist/ns/booleans.d.ts.map +1 -0
  77. package/dist/ns/construction.d.ts +10 -0
  78. package/dist/ns/construction.d.ts.map +1 -0
  79. package/dist/ns/ioNs.d.ts +18 -0
  80. package/dist/ns/ioNs.d.ts.map +1 -0
  81. package/dist/ns/measurement.d.ts +6 -0
  82. package/dist/ns/measurement.d.ts.map +1 -0
  83. package/dist/ns/modifiers.d.ts +6 -0
  84. package/dist/ns/modifiers.d.ts.map +1 -0
  85. package/dist/ns/patterns.d.ts +5 -0
  86. package/dist/ns/patterns.d.ts.map +1 -0
  87. package/dist/ns/primitives.d.ts +7 -0
  88. package/dist/ns/primitives.d.ts.map +1 -0
  89. package/dist/ns/query.d.ts +6 -0
  90. package/dist/ns/query.d.ts.map +1 -0
  91. package/dist/ns/transforms.d.ts +5 -0
  92. package/dist/ns/transforms.d.ts.map +1 -0
  93. package/dist/operations.cjs +2 -2
  94. package/dist/operations.js +2 -2
  95. package/dist/{planeOps-cTxDywpG.cjs → planeOps-6Wu7dMDN.cjs} +5 -4
  96. package/dist/{planeOps-BuBXTLBr.js → planeOps-gTOEarV2.js} +4 -3
  97. package/dist/{primitiveFns-DKtvEA0i.cjs → primitiveFns-CRPGjIFg.cjs} +101 -69
  98. package/dist/{primitiveFns-CASk8g16.js → primitiveFns-CeKiYSSW.js} +28 -8
  99. package/dist/query.cjs +2 -2
  100. package/dist/query.js +2 -2
  101. package/dist/result.cjs +1 -1
  102. package/dist/result.js +1 -1
  103. package/dist/{arrayAccess-Dps31ERU.js → shapeFns-DCi9O27X.js} +8 -30
  104. package/dist/{arrayAccess-peFKE9Ob.cjs → shapeFns-aEeSHNqX.cjs} +24 -64
  105. package/dist/shapeRef.cjs +8 -0
  106. package/dist/shapeRef.d.ts +5 -0
  107. package/dist/shapeRef.d.ts.map +1 -0
  108. package/dist/shapeRef.js +2 -0
  109. package/dist/shapeRefFns-B1TODUMl.js +194 -0
  110. package/dist/shapeRefFns-CVdS6jWS.cjs +229 -0
  111. package/dist/{shapeTypes-CYb8Byqj.js → shapeTypes-BO1aiDhi.js} +3937 -3697
  112. package/dist/{shapeTypes-CElaawp7.cjs → shapeTypes-BqWQlrYE.cjs} +3937 -3697
  113. package/dist/sketching.cjs +2 -2
  114. package/dist/sketching.js +2 -2
  115. package/dist/{solidBuilders-Cs4XyL58.cjs → solidBuilders-0iVdiZUw.cjs} +3 -3
  116. package/dist/{solidBuilders-ClJxiUa3.js → solidBuilders-jk7HfWs8.js} +3 -3
  117. package/dist/{surfaceBuilders-ZUTb3z6i.cjs → surfaceBuilders-C_8rs79F.cjs} +3 -3
  118. package/dist/{surfaceBuilders-DnGdDW8i.js → surfaceBuilders-DE5e6bp8.js} +3 -3
  119. package/dist/topology/api.d.ts +3 -3
  120. package/dist/topology/api.d.ts.map +1 -1
  121. package/dist/topology/nurbsFns.d.ts +13 -0
  122. package/dist/topology/nurbsFns.d.ts.map +1 -0
  123. package/dist/topology/shapeFns.d.ts +4 -3
  124. package/dist/topology/shapeFns.d.ts.map +1 -1
  125. package/dist/topology/shapeRef/index.d.ts +7 -0
  126. package/dist/topology/shapeRef/index.d.ts.map +1 -0
  127. package/dist/topology/shapeRef/scoring.d.ts +16 -0
  128. package/dist/topology/shapeRef/scoring.d.ts.map +1 -0
  129. package/dist/topology/shapeRef/shapeRefFns.d.ts +47 -0
  130. package/dist/topology/shapeRef/shapeRefFns.d.ts.map +1 -0
  131. package/dist/topology/shapeRef/shapeRefTypes.d.ts +40 -0
  132. package/dist/topology/shapeRef/shapeRefTypes.d.ts.map +1 -0
  133. package/dist/topology.cjs +22 -20
  134. package/dist/topology.d.ts +1 -0
  135. package/dist/topology.d.ts.map +1 -1
  136. package/dist/topology.js +7 -7
  137. package/dist/{vecOps-4iBMiet9.cjs → vecOps-BXvBYIor.cjs} +0 -26
  138. package/dist/{vecOps-B9-MTeC8.js → vecOps-D9etjPgV.js} +1 -9
  139. package/dist/vectors.cjs +6 -5
  140. package/dist/vectors.js +4 -3
  141. package/dist/worker.cjs +1 -1
  142. package/dist/worker.js +1 -1
  143. package/package.json +14 -4
  144. /package/dist/{types-Bb4KK_iG.js → types-BWBlwp6w.js} +0 -0
  145. /package/dist/{types-BD-VVaWB.cjs → types-BjDcsS7l.cjs} +0 -0
  146. /package/dist/{workerHandler-nLkvSOKX.cjs → workerHandler-C-7OUJsa.cjs} +0 -0
  147. /package/dist/{workerHandler-BrOTzYRI.js → workerHandler-o2xzAfFk.js} +0 -0
@@ -1,6 +1,6 @@
1
- const require_vecOps = require("./vecOps-4iBMiet9.cjs");
2
- const require_arrayAccess = require("./arrayAccess-peFKE9Ob.cjs");
3
- const require_helpers = require("./helpers-pQpV9Mwh.cjs");
1
+ const require_constants = require("./constants-unWN8k4c.cjs");
2
+ const require_arrayAccess = require("./arrayAccess-CmulMesb.cjs");
3
+ const require_helpers = require("./helpers-DZje6XWE.cjs");
4
4
  //#region src/query/cornerFinder.ts
5
5
  var PI_2 = 2 * Math.PI;
6
6
  function positiveHalfAngle(angle) {
@@ -39,7 +39,7 @@ function buildCornerFinder(filters) {
39
39
  ofAngle: (angle) => withFilter((corner) => {
40
40
  const tgt1 = corner.firstCurve.tangentAt(1);
41
41
  const tgt2 = corner.secondCurve.tangentAt(0);
42
- return Math.abs(positiveHalfAngle(require_helpers.angle2d(tgt1, tgt2)) - positiveHalfAngle(require_vecOps.DEG2RAD * angle)) < 1e-9;
42
+ return Math.abs(positiveHalfAngle(require_helpers.angle2d(tgt1, tgt2)) - positiveHalfAngle(require_constants.DEG2RAD * angle)) < 1e-9;
43
43
  }),
44
44
  not: (fn) => {
45
45
  const inner = fn(buildCornerFinder([]));
@@ -1,5 +1,5 @@
1
- import { Y as getKernel, f as isEdge, t as castShape, y as isWire } from "./shapeTypes-CYb8Byqj.js";
2
- import { k as ok, l as typeCastError, y as err } from "./errors-B_T0aMQF.js";
1
+ import { Y as getKernel, f as isEdge, t as castShape, y as isWire } from "./shapeTypes-BO1aiDhi.js";
2
+ import { A as ok, b as err, l as typeCastError } from "./errors-C-cgQA3w.js";
3
3
  //#region src/topology/curveFns.ts
4
4
  /**
5
5
  * Curve and 1D shape functions — functional replacements for _1DShape/Curve methods.
@@ -1,5 +1,5 @@
1
- const require_shapeTypes = require("./shapeTypes-CElaawp7.cjs");
2
- const require_errors = require("./errors-DupKEMqI.cjs");
1
+ const require_shapeTypes = require("./shapeTypes-BqWQlrYE.cjs");
2
+ const require_errors = require("./errors-9zQcQK1H.cjs");
3
3
  //#region src/topology/curveFns.ts
4
4
  /**
5
5
  * Curve and 1D shape functions — functional replacements for _1DShape/Curve methods.
@@ -5,6 +5,15 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __exportAll = (all, no_symbols) => {
9
+ let target = {};
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
14
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
15
+ return target;
16
+ };
8
17
  var __copyProps = (to, from, except, desc) => {
9
18
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
19
  key = keys[i];
@@ -20,21 +29,23 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
20
29
  enumerable: true
21
30
  }) : target, mod));
22
31
  //#endregion
23
- const require_shapeTypes = require("./shapeTypes-CElaawp7.cjs");
24
- const require_errors = require("./errors-DupKEMqI.cjs");
25
- const require_vecOps = require("./vecOps-4iBMiet9.cjs");
26
- const require_types = require("./types-BD-VVaWB.cjs");
27
- const require_planeOps = require("./planeOps-cTxDywpG.cjs");
28
- const require_faceFns = require("./faceFns-8dGb8q3J.cjs");
29
- const require_arrayAccess = require("./arrayAccess-peFKE9Ob.cjs");
30
- const require_curveFns = require("./curveFns-ywh7Ctyk.cjs");
31
- const require_surfaceBuilders = require("./surfaceBuilders-ZUTb3z6i.cjs");
32
- const require_boolean2D = require("./boolean2D-CtB21ajK.cjs");
33
- const require_helpers = require("./helpers-pQpV9Mwh.cjs");
34
- const require_blueprint = require("./blueprint-PLJan-W5.cjs");
35
- const require_solidBuilders = require("./solidBuilders-Cs4XyL58.cjs");
36
- const require_cornerFinder = require("./cornerFinder-SF-xmMO1.cjs");
37
- const require_extrudeFns = require("./extrudeFns-CGCIbydL.cjs");
32
+ const require_shapeTypes = require("./shapeTypes-BqWQlrYE.cjs");
33
+ const require_errors = require("./errors-9zQcQK1H.cjs");
34
+ const require_faceFns = require("./faceFns-cE2WxY6I.cjs");
35
+ const require_constants = require("./constants-unWN8k4c.cjs");
36
+ const require_types = require("./types-BjDcsS7l.cjs");
37
+ const require_vecOps = require("./vecOps-BXvBYIor.cjs");
38
+ const require_planeOps = require("./planeOps-6Wu7dMDN.cjs");
39
+ const require_shapeFns = require("./shapeFns-aEeSHNqX.cjs");
40
+ const require_curveFns = require("./curveFns-DCEcwcpd.cjs");
41
+ const require_arrayAccess = require("./arrayAccess-CmulMesb.cjs");
42
+ const require_surfaceBuilders = require("./surfaceBuilders-C_8rs79F.cjs");
43
+ const require_boolean2D = require("./boolean2D-BPsyKImE.cjs");
44
+ const require_helpers = require("./helpers-DZje6XWE.cjs");
45
+ const require_blueprint = require("./blueprint-D0XChcek.cjs");
46
+ const require_solidBuilders = require("./solidBuilders-0iVdiZUw.cjs");
47
+ const require_cornerFinder = require("./cornerFinder-DTt_SvtC.cjs");
48
+ const require_extrudeFns = require("./extrudeFns-Rcut7h8S.cjs");
38
49
  let opentype_js = require("opentype.js");
39
50
  opentype_js = __toESM(opentype_js);
40
51
  //#region src/2d/lib/stitching.ts
@@ -391,7 +402,7 @@ var sketchEllipse = (xRadius = 1, yRadius = 2, planeConfig = {}) => {
391
402
  let majR = xRadius;
392
403
  let minR = yRadius;
393
404
  if (yRadius > xRadius) {
394
- xDir = require_vecOps.vecRotate(xDir, plane.zDir, 90 * require_vecOps.DEG2RAD);
405
+ xDir = require_vecOps.vecRotate(xDir, plane.zDir, 90 * require_constants.DEG2RAD);
395
406
  majR = yRadius;
396
407
  minR = xRadius;
397
408
  }
@@ -1589,7 +1600,7 @@ function isProjectionPlane(plane) {
1589
1600
  //#region src/projection/makeProjectedEdges.ts
1590
1601
  var getEdgesFromOc = (shape) => {
1591
1602
  if (shape.IsNull()) return [];
1592
- return require_arrayAccess.getEdges(require_shapeTypes.castShape(shape));
1603
+ return require_shapeFns.getEdges(require_shapeTypes.castShape(shape));
1593
1604
  };
1594
1605
  /**
1595
1606
  * Project a 3D shape onto a 2D plane using hidden-line removal (HLR).
@@ -1746,7 +1757,7 @@ function drawFaceOutline(face) {
1746
1757
  var _usingCtx3 = require_shapeTypes._usingCtx();
1747
1758
  const scope = _usingCtx3.u(new require_shapeTypes.DisposalScope());
1748
1759
  const clonedFace = scope.register(require_shapeTypes.createFace(require_errors.unwrap(require_faceFns.downcast(face.wrapped))));
1749
- const stitchedCurves = stitchCurves(require_arrayAccess.getEdges(scope.register(require_faceFns.outerWire(clonedFace))).map((e) => require_blueprint.edgeToCurve(e, face))).map((s) => new require_blueprint.Blueprint(s));
1760
+ const stitchedCurves = stitchCurves(require_shapeFns.getEdges(scope.register(require_faceFns.outerWire(clonedFace))).map((e) => require_blueprint.edgeToCurve(e, face))).map((s) => new require_blueprint.Blueprint(s));
1750
1761
  if (stitchedCurves.length === 0) return new Drawing();
1751
1762
  if (stitchedCurves.length === 1) return new Drawing(stitchedCurves[0]);
1752
1763
  return new Drawing(new require_boolean2D.Blueprints(stitchedCurves));
@@ -2035,6 +2046,12 @@ Object.defineProperty(exports, "Sketches", {
2035
2046
  return Sketches;
2036
2047
  }
2037
2048
  });
2049
+ Object.defineProperty(exports, "__exportAll", {
2050
+ enumerable: true,
2051
+ get: function() {
2052
+ return __exportAll;
2053
+ }
2054
+ });
2038
2055
  Object.defineProperty(exports, "cameraFromPlane", {
2039
2056
  enumerable: true,
2040
2057
  get: function() {
@@ -1,18 +1,20 @@
1
- import { J as _usingCtx, L as DisposalScope, Y as getKernel, o as createFace, p as isFace, t as castShape, u as createWire } from "./shapeTypes-CYb8Byqj.js";
2
- import { L as unwrap, d as validationError, k as ok, m as bug, r as ioError, s as safeIndex, t as BrepErrorCode, w as isOk, y as err } from "./errors-B_T0aMQF.js";
3
- import { _ as DEG2RAD, c as vecLength, d as vecNormalize, g as vecSub, h as vecScale, m as vecRotate, r as vecCross } from "./vecOps-B9-MTeC8.js";
4
- import { r as toVec3 } from "./types-Bb4KK_iG.js";
5
- import { a as planeToWorld, o as resolvePlane } from "./planeOps-BuBXTLBr.js";
6
- import { _ as downcast, c as normalAt, g as cast, l as outerWire, n as faceCenter } from "./faceFns-EnGcKFAr.js";
7
- import { F as getEdges, n as getAtOrThrow, r as lastOrThrow, t as firstOrThrow } from "./arrayAccess-Dps31ERU.js";
8
- import { m as offsetWire2D } from "./curveFns-C-jU1_Y_.js";
9
- import { c as makeBSplineApproximation, d as makeEllipse, p as makeHelix, r as makeFace, s as assembleWire, t as addHolesInFace, u as makeCircle } from "./surfaceBuilders-DnGdDW8i.js";
10
- import { _ as chamferCurves, b as intersectCurves, c as roundedRectangleBlueprint, f as Sketch, g as Blueprints, h as CompoundBlueprint, l as BaseSketcher2d, m as organiseBlueprints, n as fuse2D, r as intersect2D, s as polysidesBlueprint, t as cut2D, u as BlueprintSketcher, v as filletCurves, x as Flatbush, y as make2dOffset } from "./boolean2D-52qVCooY.js";
11
- import { _ as samePoint$1, b as subtract2d, c as PRECISION_OFFSET, l as add2d, y as squareDistance2d } from "./helpers-Rf0vhX6I.js";
12
- import { _ as Curve2D, a as edgeToCurve, c as make2dCircle, d as make2dInerpolatedBSplineCurve, f as make2dSegmentCurve, g as approximateAsSvgCompatibleCurve, i as curvesAsEdgesOnPlane, l as make2dEllipse, o as make2dArcFromCenter, t as Blueprint, v as deserializeCurve2D, y as BoundingBox2d } from "./blueprint-DYCdRlW5.js";
13
- import { o as makeSolid, t as makeCompound } from "./solidBuilders-ClJxiUa3.js";
14
- import { t as cornerFinder } from "./cornerFinder-C7aDyYLJ.js";
15
- import { c as twistExtrude, n as revolve, r as complexExtrude, t as extrude } from "./extrudeFns-LsH1rDMa.js";
1
+ import { J as _usingCtx, L as DisposalScope, Y as getKernel, o as createFace, p as isFace, t as castShape, u as createWire } from "./shapeTypes-BO1aiDhi.js";
2
+ import { A as ok, R as unwrap, T as isOk, b as err, d as validationError, h as bug, r as ioError, s as safeIndex, t as BrepErrorCode } from "./errors-C-cgQA3w.js";
3
+ import { _ as downcast, c as normalAt, g as cast, l as outerWire, n as faceCenter } from "./faceFns-TSH54pPQ.js";
4
+ import { t as DEG2RAD } from "./constants-B9u763C3.js";
5
+ import { r as toVec3 } from "./types-BWBlwp6w.js";
6
+ import { c as vecLength, d as vecNormalize, g as vecSub, h as vecScale, m as vecRotate, r as vecCross } from "./vecOps-D9etjPgV.js";
7
+ import { a as planeToWorld, o as resolvePlane } from "./planeOps-gTOEarV2.js";
8
+ import { M as getEdges } from "./shapeFns-DCi9O27X.js";
9
+ import { m as offsetWire2D } from "./curveFns-CcInoOEA.js";
10
+ import { n as getAtOrThrow, r as lastOrThrow, t as firstOrThrow } from "./arrayAccess-xxcB3YNq.js";
11
+ import { c as makeBSplineApproximation, d as makeEllipse, p as makeHelix, r as makeFace, s as assembleWire, t as addHolesInFace, u as makeCircle } from "./surfaceBuilders-DE5e6bp8.js";
12
+ import { _ as chamferCurves, b as intersectCurves, c as roundedRectangleBlueprint, f as Sketch, g as Blueprints, h as CompoundBlueprint, l as BaseSketcher2d, m as organiseBlueprints, n as fuse2D, r as intersect2D, s as polysidesBlueprint, t as cut2D, u as BlueprintSketcher, v as filletCurves, x as Flatbush, y as make2dOffset } from "./boolean2D-D_Te-6N6.js";
13
+ import { _ as samePoint$1, b as subtract2d, c as PRECISION_OFFSET, l as add2d, y as squareDistance2d } from "./helpers-XrXlKm8D.js";
14
+ import { _ as Curve2D, a as edgeToCurve, c as make2dCircle, d as make2dInerpolatedBSplineCurve, f as make2dSegmentCurve, g as approximateAsSvgCompatibleCurve, i as curvesAsEdgesOnPlane, l as make2dEllipse, o as make2dArcFromCenter, t as Blueprint, v as deserializeCurve2D, y as BoundingBox2d } from "./blueprint-B3A5x7P9.js";
15
+ import { o as makeSolid, t as makeCompound } from "./solidBuilders-jk7HfWs8.js";
16
+ import { t as cornerFinder } from "./cornerFinder-AEFnAxt4.js";
17
+ import { c as twistExtrude, n as revolve, r as complexExtrude, t as extrude } from "./extrudeFns-DrDr9-nU.js";
16
18
  import opentype from "opentype.js";
17
19
  //#region src/2d/lib/stitching.ts
18
20
  /**
@@ -247,6 +247,24 @@ var kernel_ERROR_PATTERNS = [
247
247
  translation: "Shape validation failed. The resulting shape has invalid topology. Try healing the shape or checking input geometry."
248
248
  }
249
249
  ];
250
+ var ERROR_CODE_SUGGESTIONS = {
251
+ FUSE_FAILED: "Try autoHeal() on both operands before the boolean operation. Check for overlapping faces or zero-thickness geometry.",
252
+ CUT_FAILED: "Try autoHeal() on both operands before the boolean operation. Check for overlapping faces or zero-thickness geometry.",
253
+ FUSE_NOT_3D: "The boolean result was not a 3D solid. Ensure both input shapes are valid 3D solids, not shells or open surfaces.",
254
+ CUT_NOT_3D: "The boolean result was not a 3D solid. Ensure both input shapes are valid 3D solids, not shells or open surfaces.",
255
+ INTERSECT_NOT_3D: "The boolean result was not a 3D solid. Ensure both input shapes are valid 3D solids, not shells or open surfaces.",
256
+ SWEEP_FAILED: "Ensure the spine curve has no sharp corners or self-intersections. Try simplifying the profile or using a smoother path.",
257
+ LOFT_FAILED: "Check that all profiles have the same number of edges and consistent orientation. Try reordering profiles.",
258
+ FILLET_NOT_3D: "The fillet radius may be too large for the selected edges. Try a smaller radius or check that adjacent faces have enough room.",
259
+ CHAMFER_NOT_3D: "The chamfer distance may be too large. Try a smaller distance or check edge geometry.",
260
+ SHELL_NOT_3D: "The shell thickness may be too large for the shape. Try reducing thickness or removing problematic faces.",
261
+ OFFSET_NOT_3D: "The offset distance may be too large for the shape geometry. Try a smaller distance.",
262
+ DRAFT_FAILED: "The draft angle may be too large or the selected faces incompatible. Try a smaller angle or different faces."
263
+ };
264
+ /** Look up an actionable suggestion for a given error code. */
265
+ function getSuggestionForCode(code) {
266
+ return ERROR_CODE_SUGGESTIONS[code];
267
+ }
250
268
  /**
251
269
  * Translate an kernel error message into a user-friendly explanation.
252
270
  * If no pattern matches, returns the original message.
@@ -347,6 +365,7 @@ var BrepErrorCode = {
347
365
  INTERSECTION_FAILED: "INTERSECTION_FAILED",
348
366
  SELF_INTERSECTION_FAILED: "SELF_INTERSECTION_FAILED",
349
367
  STRAIGHT_SKELETON_FAILED: "STRAIGHT_SKELETON_FAILED",
368
+ CENTER_OF_MASS_FAILED: "CENTER_OF_MASS_FAILED",
350
369
  COMPOUND_NO_FACES: "COMPOUND_NO_FACES",
351
370
  COMPOUND_FACE_NOT_FOUND: "COMPOUND_FACE_NOT_FOUND",
352
371
  FINDER_NOT_UNIQUE: "FINDER_NOT_UNIQUE",
@@ -378,6 +397,15 @@ var BrepErrorCode = {
378
397
  FONT_FETCH_FAILED: "FONT_FETCH_FAILED",
379
398
  FONT_PARSE_FAILED: "FONT_PARSE_FAILED",
380
399
  NO_FONT_LOADED: "NO_FONT_LOADED",
400
+ CURVE2D_CONSTRUCTION_FAILED: "CURVE2D_CONSTRUCTION_FAILED",
401
+ CURVE2D_INVALID_RADIUS: "CURVE2D_INVALID_RADIUS",
402
+ CURVE2D_TRANSFORM_FAILED: "CURVE2D_TRANSFORM_FAILED",
403
+ CURVE2D_QUERY_FAILED: "CURVE2D_QUERY_FAILED",
404
+ CURVE2D_INTERSECTION_FAILED: "CURVE2D_INTERSECTION_FAILED",
405
+ CURVE2D_BRIDGE_FAILED: "CURVE2D_BRIDGE_FAILED",
406
+ CLONE_FAILED: "CLONE_FAILED",
407
+ SIMPLIFY_FAILED: "SIMPLIFY_FAILED",
408
+ TO_BREP_FAILED: "TO_BREP_FAILED",
381
409
  UNSUPPORTED_CAPABILITY: "UNSUPPORTED_CAPABILITY"
382
410
  };
383
411
  function makeError(kind, code, message, cause, metadata, suggestion) {
@@ -528,6 +556,12 @@ Object.defineProperty(exports, "fromNullable", {
528
556
  return fromNullable;
529
557
  }
530
558
  });
559
+ Object.defineProperty(exports, "getSuggestionForCode", {
560
+ enumerable: true,
561
+ get: function() {
562
+ return getSuggestionForCode;
563
+ }
564
+ });
531
565
  Object.defineProperty(exports, "ioError", {
532
566
  enumerable: true,
533
567
  get: function() {
@@ -247,6 +247,24 @@ var kernel_ERROR_PATTERNS = [
247
247
  translation: "Shape validation failed. The resulting shape has invalid topology. Try healing the shape or checking input geometry."
248
248
  }
249
249
  ];
250
+ var ERROR_CODE_SUGGESTIONS = {
251
+ FUSE_FAILED: "Try autoHeal() on both operands before the boolean operation. Check for overlapping faces or zero-thickness geometry.",
252
+ CUT_FAILED: "Try autoHeal() on both operands before the boolean operation. Check for overlapping faces or zero-thickness geometry.",
253
+ FUSE_NOT_3D: "The boolean result was not a 3D solid. Ensure both input shapes are valid 3D solids, not shells or open surfaces.",
254
+ CUT_NOT_3D: "The boolean result was not a 3D solid. Ensure both input shapes are valid 3D solids, not shells or open surfaces.",
255
+ INTERSECT_NOT_3D: "The boolean result was not a 3D solid. Ensure both input shapes are valid 3D solids, not shells or open surfaces.",
256
+ SWEEP_FAILED: "Ensure the spine curve has no sharp corners or self-intersections. Try simplifying the profile or using a smoother path.",
257
+ LOFT_FAILED: "Check that all profiles have the same number of edges and consistent orientation. Try reordering profiles.",
258
+ FILLET_NOT_3D: "The fillet radius may be too large for the selected edges. Try a smaller radius or check that adjacent faces have enough room.",
259
+ CHAMFER_NOT_3D: "The chamfer distance may be too large. Try a smaller distance or check edge geometry.",
260
+ SHELL_NOT_3D: "The shell thickness may be too large for the shape. Try reducing thickness or removing problematic faces.",
261
+ OFFSET_NOT_3D: "The offset distance may be too large for the shape geometry. Try a smaller distance.",
262
+ DRAFT_FAILED: "The draft angle may be too large or the selected faces incompatible. Try a smaller angle or different faces."
263
+ };
264
+ /** Look up an actionable suggestion for a given error code. */
265
+ function getSuggestionForCode(code) {
266
+ return ERROR_CODE_SUGGESTIONS[code];
267
+ }
250
268
  /**
251
269
  * Translate an kernel error message into a user-friendly explanation.
252
270
  * If no pattern matches, returns the original message.
@@ -347,6 +365,7 @@ var BrepErrorCode = {
347
365
  INTERSECTION_FAILED: "INTERSECTION_FAILED",
348
366
  SELF_INTERSECTION_FAILED: "SELF_INTERSECTION_FAILED",
349
367
  STRAIGHT_SKELETON_FAILED: "STRAIGHT_SKELETON_FAILED",
368
+ CENTER_OF_MASS_FAILED: "CENTER_OF_MASS_FAILED",
350
369
  COMPOUND_NO_FACES: "COMPOUND_NO_FACES",
351
370
  COMPOUND_FACE_NOT_FOUND: "COMPOUND_FACE_NOT_FOUND",
352
371
  FINDER_NOT_UNIQUE: "FINDER_NOT_UNIQUE",
@@ -378,6 +397,15 @@ var BrepErrorCode = {
378
397
  FONT_FETCH_FAILED: "FONT_FETCH_FAILED",
379
398
  FONT_PARSE_FAILED: "FONT_PARSE_FAILED",
380
399
  NO_FONT_LOADED: "NO_FONT_LOADED",
400
+ CURVE2D_CONSTRUCTION_FAILED: "CURVE2D_CONSTRUCTION_FAILED",
401
+ CURVE2D_INVALID_RADIUS: "CURVE2D_INVALID_RADIUS",
402
+ CURVE2D_TRANSFORM_FAILED: "CURVE2D_TRANSFORM_FAILED",
403
+ CURVE2D_QUERY_FAILED: "CURVE2D_QUERY_FAILED",
404
+ CURVE2D_INTERSECTION_FAILED: "CURVE2D_INTERSECTION_FAILED",
405
+ CURVE2D_BRIDGE_FAILED: "CURVE2D_BRIDGE_FAILED",
406
+ CLONE_FAILED: "CLONE_FAILED",
407
+ SIMPLIFY_FAILED: "SIMPLIFY_FAILED",
408
+ TO_BREP_FAILED: "TO_BREP_FAILED",
381
409
  UNSUPPORTED_CAPABILITY: "UNSUPPORTED_CAPABILITY"
382
410
  };
383
411
  function makeError(kind, code, message, cause, metadata, suggestion) {
@@ -456,4 +484,4 @@ function safeIndex(arr, index, context) {
456
484
  return arr[index];
457
485
  }
458
486
  //#endregion
459
- export { or as A, unwrapOrElse as B, isErr as C, mapErr as D, mapBoth as E, tryCatch as F, tryCatchAsync as I, unwrap as L, pipeline as M, tap as N, match as O, tapErr as P, unwrapErr as R, fromNullable as S, map as T, zip as V, andThen as _, moduleInitError as a, flatMap as b, sketcherStateError as c, validationError as d, translateKernelError as f, all as g, OK as h, kernelError as i, orElse as j, ok as k, typeCastError as l, bug as m, computationError as n, queryError as o, BrepBugError as p, ioError as r, safeIndex as s, BrepErrorCode as t, unsupportedError as u, collect as v, isOk as w, flatten as x, err as y, unwrapOr as z };
487
+ export { ok as A, unwrapOr as B, fromNullable as C, mapBoth as D, map as E, tapErr as F, zip as H, tryCatch as I, tryCatchAsync as L, orElse as M, pipeline as N, mapErr as O, tap as P, unwrap as R, flatten as S, isOk as T, unwrapOrElse as V, all as _, moduleInitError as a, err as b, sketcherStateError as c, validationError as d, getSuggestionForCode as f, OK as g, bug as h, kernelError as i, or as j, match as k, typeCastError as l, BrepBugError as m, computationError as n, queryError as o, translateKernelError as p, ioError as r, safeIndex as s, BrepErrorCode as t, unsupportedError as u, andThen as v, isErr as w, flatMap as x, collect as y, unwrapErr as z };
@@ -1,6 +1,6 @@
1
- import { Y as getKernel, c as createSolid, h as isShape3D, t as castShape, y as isWire } from "./shapeTypes-CYb8Byqj.js";
2
- import { L as unwrap, d as validationError, i as kernelError, k as ok, l as typeCastError, t as BrepErrorCode, y as err } from "./errors-B_T0aMQF.js";
3
- import { c as vecLength, d as vecNormalize, t as vecAdd } from "./vecOps-B9-MTeC8.js";
1
+ import { Y as getKernel, c as createSolid, h as isShape3D, t as castShape, y as isWire } from "./shapeTypes-BO1aiDhi.js";
2
+ import { A as ok, R as unwrap, b as err, d as validationError, i as kernelError, l as typeCastError, t as BrepErrorCode } from "./errors-C-cgQA3w.js";
3
+ import { c as vecLength, d as vecNormalize, t as vecAdd } from "./vecOps-D9etjPgV.js";
4
4
  //#region src/operations/extrudeUtils.ts
5
5
  /**
6
6
  * Build an kernel scaling law from an extrusion profile configuration.
@@ -1,6 +1,6 @@
1
- const require_shapeTypes = require("./shapeTypes-CElaawp7.cjs");
2
- const require_errors = require("./errors-DupKEMqI.cjs");
3
- const require_vecOps = require("./vecOps-4iBMiet9.cjs");
1
+ const require_shapeTypes = require("./shapeTypes-BqWQlrYE.cjs");
2
+ const require_errors = require("./errors-9zQcQK1H.cjs");
3
+ const require_vecOps = require("./vecOps-BXvBYIor.cjs");
4
4
  //#region src/operations/extrudeUtils.ts
5
5
  /**
6
6
  * Build an kernel scaling law from an extrusion profile configuration.
@@ -1,6 +1,96 @@
1
- import { Y as getKernel, t as castShape } from "./shapeTypes-CYb8Byqj.js";
2
- import { L as unwrap, k as ok, l as typeCastError, y as err } from "./errors-B_T0aMQF.js";
3
- import { r as toVec3 } from "./types-Bb4KK_iG.js";
1
+ import { J as _usingCtx, L as DisposalScope, Y as getKernel, t as castShape } from "./shapeTypes-BO1aiDhi.js";
2
+ import { A as ok, R as unwrap, b as err, f as getSuggestionForCode, l as typeCastError, p as translateKernelError } from "./errors-C-cgQA3w.js";
3
+ import { r as toVec3 } from "./types-BWBlwp6w.js";
4
+ //#region src/core/kernelCall.ts
5
+ function buildError(kind, code, message, cause, suggestion) {
6
+ const base = {
7
+ kind,
8
+ code,
9
+ message,
10
+ cause
11
+ };
12
+ if (suggestion) return {
13
+ ...base,
14
+ suggestion
15
+ };
16
+ return base;
17
+ }
18
+ var errorFactories = {
19
+ KERNEL_OPERATION: (code, message, cause, suggestion) => buildError("KERNEL_OPERATION", code, message, cause, suggestion),
20
+ VALIDATION: (code, message, cause, suggestion) => buildError("VALIDATION", code, message, cause, suggestion),
21
+ TYPE_CAST: (code, message, cause, suggestion) => buildError("TYPE_CAST", code, message, cause, suggestion),
22
+ SKETCHER_STATE: (code, message, cause, suggestion) => buildError("SKETCHER_STATE", code, message, cause, suggestion),
23
+ MODULE_INIT: (code, message, cause, suggestion) => buildError("MODULE_INIT", code, message, cause, suggestion),
24
+ COMPUTATION: (code, message, cause, suggestion) => buildError("COMPUTATION", code, message, cause, suggestion),
25
+ IO: (code, message, cause, suggestion) => buildError("IO", code, message, cause, suggestion),
26
+ QUERY: (code, message, cause, suggestion) => buildError("QUERY", code, message, cause, suggestion),
27
+ UNSUPPORTED: (code, message, cause, suggestion) => buildError("UNSUPPORTED", code, message, cause, suggestion)
28
+ };
29
+ /**
30
+ * Wrap a kernel call that returns an KernelShape, automatically casting
31
+ * the result into a branded AnyShape. On exception, returns an Err
32
+ * with the given error code and message.
33
+ *
34
+ * kernel error messages are automatically translated into user-friendly
35
+ * explanations when the error kind is KERNEL_OPERATION.
36
+ */
37
+ function kernelCall(fn, code, message, kind = "KERNEL_OPERATION") {
38
+ try {
39
+ return ok(castShape(fn()));
40
+ } catch (e) {
41
+ const rawMessage = e instanceof Error ? e.message : String(e);
42
+ const translatedMessage = kind === "KERNEL_OPERATION" ? translateKernelError(rawMessage) : rawMessage;
43
+ const suggestion = getSuggestionForCode(code);
44
+ return err(errorFactories[kind](code, `${message}: ${translatedMessage}`, e, suggestion));
45
+ }
46
+ }
47
+ /**
48
+ * Wrap a kernel call that returns an arbitrary value. On exception,
49
+ * returns an Err with the given error code and message.
50
+ *
51
+ * kernel error messages are automatically translated into user-friendly
52
+ * explanations when the error kind is KERNEL_OPERATION.
53
+ */
54
+ function kernelCallRaw(fn, code, message, kind = "KERNEL_OPERATION") {
55
+ try {
56
+ return ok(fn());
57
+ } catch (e) {
58
+ const rawMessage = e instanceof Error ? e.message : String(e);
59
+ const translatedMessage = kind === "KERNEL_OPERATION" ? translateKernelError(rawMessage) : rawMessage;
60
+ const suggestion = getSuggestionForCode(code);
61
+ return err(errorFactories[kind](code, `${message}: ${translatedMessage}`, e, suggestion));
62
+ }
63
+ }
64
+ /**
65
+ * Wrap a kernel call that needs intermediate kernel allocations.
66
+ *
67
+ * A DisposalScope is created and passed to fn. The scope is disposed
68
+ * deterministically after fn returns or throws — ensuring no intermediate
69
+ * handles are leaked even on error paths.
70
+ *
71
+ * ```ts
72
+ * return kernelCallScoped(
73
+ * (scope) => {
74
+ * const axis = scope.register(makeKernelAx1(origin, dir));
75
+ * return getKernel().revolveVec(...) // was: oc.BRepBuilderAPI_MakeRevol_1(shape.wrapped, axis).Shape();
76
+ * },
77
+ * BrepErrorCode.REVOLUTION_NOT_3D,
78
+ * 'Revolution failed'
79
+ * );
80
+ * ```
81
+ */
82
+ function kernelCallScoped(fn, code, message, kind = "KERNEL_OPERATION") {
83
+ try {
84
+ var _usingCtx$1 = _usingCtx();
85
+ const scope = _usingCtx$1.u(new DisposalScope());
86
+ return kernelCall(() => fn(scope), code, message, kind);
87
+ } catch (_) {
88
+ _usingCtx$1.e = _;
89
+ } finally {
90
+ _usingCtx$1.d();
91
+ }
92
+ }
93
+ //#endregion
4
94
  //#region src/topology/cast.ts
5
95
  var TOPO_ENUM = {
6
96
  compound: 0,
@@ -214,4 +304,4 @@ function innerWires(face) {
214
304
  return Array.from(iterTopo(face.wrapped, "wire")).map((w) => castShape(unwrap(downcast(w)))).filter((w) => !getKernel().isSame(w.wrapped, outer.wrapped));
215
305
  }
216
306
  //#endregion
217
- export { downcast as _, flipFaceOrientation as a, iterTopo as b, normalAt as c, projectPointOnFace as d, removeHolesFromFace as f, cast as g, asTopo as h, faceOrientation as i, outerWire as l, uvCoordinates as m, faceCenter as n, getSurfaceType as o, uvBounds as p, faceGeomType as r, innerWires as s, classifyPointOnFace as t, pointOnSurface as u, fromBREP as v, shapeType as x, isCompSolid as y };
307
+ export { kernelCallRaw as C, kernelCall as S, downcast as _, flipFaceOrientation as a, iterTopo as b, normalAt as c, projectPointOnFace as d, removeHolesFromFace as f, cast as g, asTopo as h, faceOrientation as i, outerWire as l, uvCoordinates as m, faceCenter as n, getSurfaceType as o, uvBounds as p, faceGeomType as r, innerWires as s, classifyPointOnFace as t, pointOnSurface as u, fromBREP as v, kernelCallScoped as w, shapeType as x, isCompSolid as y };
@@ -1,6 +1,96 @@
1
- const require_shapeTypes = require("./shapeTypes-CElaawp7.cjs");
2
- const require_errors = require("./errors-DupKEMqI.cjs");
3
- const require_types = require("./types-BD-VVaWB.cjs");
1
+ const require_shapeTypes = require("./shapeTypes-BqWQlrYE.cjs");
2
+ const require_errors = require("./errors-9zQcQK1H.cjs");
3
+ const require_types = require("./types-BjDcsS7l.cjs");
4
+ //#region src/core/kernelCall.ts
5
+ function buildError(kind, code, message, cause, suggestion) {
6
+ const base = {
7
+ kind,
8
+ code,
9
+ message,
10
+ cause
11
+ };
12
+ if (suggestion) return {
13
+ ...base,
14
+ suggestion
15
+ };
16
+ return base;
17
+ }
18
+ var errorFactories = {
19
+ KERNEL_OPERATION: (code, message, cause, suggestion) => buildError("KERNEL_OPERATION", code, message, cause, suggestion),
20
+ VALIDATION: (code, message, cause, suggestion) => buildError("VALIDATION", code, message, cause, suggestion),
21
+ TYPE_CAST: (code, message, cause, suggestion) => buildError("TYPE_CAST", code, message, cause, suggestion),
22
+ SKETCHER_STATE: (code, message, cause, suggestion) => buildError("SKETCHER_STATE", code, message, cause, suggestion),
23
+ MODULE_INIT: (code, message, cause, suggestion) => buildError("MODULE_INIT", code, message, cause, suggestion),
24
+ COMPUTATION: (code, message, cause, suggestion) => buildError("COMPUTATION", code, message, cause, suggestion),
25
+ IO: (code, message, cause, suggestion) => buildError("IO", code, message, cause, suggestion),
26
+ QUERY: (code, message, cause, suggestion) => buildError("QUERY", code, message, cause, suggestion),
27
+ UNSUPPORTED: (code, message, cause, suggestion) => buildError("UNSUPPORTED", code, message, cause, suggestion)
28
+ };
29
+ /**
30
+ * Wrap a kernel call that returns an KernelShape, automatically casting
31
+ * the result into a branded AnyShape. On exception, returns an Err
32
+ * with the given error code and message.
33
+ *
34
+ * kernel error messages are automatically translated into user-friendly
35
+ * explanations when the error kind is KERNEL_OPERATION.
36
+ */
37
+ function kernelCall(fn, code, message, kind = "KERNEL_OPERATION") {
38
+ try {
39
+ return require_errors.ok(require_shapeTypes.castShape(fn()));
40
+ } catch (e) {
41
+ const rawMessage = e instanceof Error ? e.message : String(e);
42
+ const translatedMessage = kind === "KERNEL_OPERATION" ? require_errors.translateKernelError(rawMessage) : rawMessage;
43
+ const suggestion = require_errors.getSuggestionForCode(code);
44
+ return require_errors.err(errorFactories[kind](code, `${message}: ${translatedMessage}`, e, suggestion));
45
+ }
46
+ }
47
+ /**
48
+ * Wrap a kernel call that returns an arbitrary value. On exception,
49
+ * returns an Err with the given error code and message.
50
+ *
51
+ * kernel error messages are automatically translated into user-friendly
52
+ * explanations when the error kind is KERNEL_OPERATION.
53
+ */
54
+ function kernelCallRaw(fn, code, message, kind = "KERNEL_OPERATION") {
55
+ try {
56
+ return require_errors.ok(fn());
57
+ } catch (e) {
58
+ const rawMessage = e instanceof Error ? e.message : String(e);
59
+ const translatedMessage = kind === "KERNEL_OPERATION" ? require_errors.translateKernelError(rawMessage) : rawMessage;
60
+ const suggestion = require_errors.getSuggestionForCode(code);
61
+ return require_errors.err(errorFactories[kind](code, `${message}: ${translatedMessage}`, e, suggestion));
62
+ }
63
+ }
64
+ /**
65
+ * Wrap a kernel call that needs intermediate kernel allocations.
66
+ *
67
+ * A DisposalScope is created and passed to fn. The scope is disposed
68
+ * deterministically after fn returns or throws — ensuring no intermediate
69
+ * handles are leaked even on error paths.
70
+ *
71
+ * ```ts
72
+ * return kernelCallScoped(
73
+ * (scope) => {
74
+ * const axis = scope.register(makeKernelAx1(origin, dir));
75
+ * return getKernel().revolveVec(...) // was: oc.BRepBuilderAPI_MakeRevol_1(shape.wrapped, axis).Shape();
76
+ * },
77
+ * BrepErrorCode.REVOLUTION_NOT_3D,
78
+ * 'Revolution failed'
79
+ * );
80
+ * ```
81
+ */
82
+ function kernelCallScoped(fn, code, message, kind = "KERNEL_OPERATION") {
83
+ try {
84
+ var _usingCtx$1 = require_shapeTypes._usingCtx();
85
+ const scope = _usingCtx$1.u(new require_shapeTypes.DisposalScope());
86
+ return kernelCall(() => fn(scope), code, message, kind);
87
+ } catch (_) {
88
+ _usingCtx$1.e = _;
89
+ } finally {
90
+ _usingCtx$1.d();
91
+ }
92
+ }
93
+ //#endregion
4
94
  //#region src/topology/cast.ts
5
95
  var TOPO_ENUM = {
6
96
  compound: 0,
@@ -292,6 +382,24 @@ Object.defineProperty(exports, "iterTopo", {
292
382
  return iterTopo;
293
383
  }
294
384
  });
385
+ Object.defineProperty(exports, "kernelCall", {
386
+ enumerable: true,
387
+ get: function() {
388
+ return kernelCall;
389
+ }
390
+ });
391
+ Object.defineProperty(exports, "kernelCallRaw", {
392
+ enumerable: true,
393
+ get: function() {
394
+ return kernelCallRaw;
395
+ }
396
+ });
397
+ Object.defineProperty(exports, "kernelCallScoped", {
398
+ enumerable: true,
399
+ get: function() {
400
+ return kernelCallScoped;
401
+ }
402
+ });
295
403
  Object.defineProperty(exports, "normalAt", {
296
404
  enumerable: true,
297
405
  get: function() {
@@ -1,10 +1,11 @@
1
- const require_shapeTypes = require("./shapeTypes-CElaawp7.cjs");
2
- const require_errors = require("./errors-DupKEMqI.cjs");
3
- const require_vecOps = require("./vecOps-4iBMiet9.cjs");
4
- const require_faceFns = require("./faceFns-8dGb8q3J.cjs");
5
- const require_arrayAccess = require("./arrayAccess-peFKE9Ob.cjs");
6
- const require_curveFns = require("./curveFns-ywh7Ctyk.cjs");
7
- const require_measureFns = require("./measureFns-CFdHa_fj.cjs");
1
+ const require_shapeTypes = require("./shapeTypes-BqWQlrYE.cjs");
2
+ const require_errors = require("./errors-9zQcQK1H.cjs");
3
+ const require_faceFns = require("./faceFns-cE2WxY6I.cjs");
4
+ const require_constants = require("./constants-unWN8k4c.cjs");
5
+ const require_vecOps = require("./vecOps-BXvBYIor.cjs");
6
+ const require_shapeFns = require("./shapeFns-aEeSHNqX.cjs");
7
+ const require_curveFns = require("./curveFns-DCEcwcpd.cjs");
8
+ const require_measureFns = require("./measureFns-D_QKZ5yg.cjs");
8
9
  //#region src/utils/vec2d.ts
9
10
  /** Precision for curve intersection and parameter operations. */
10
11
  var PRECISION_INTERSECTION = 1e-9;
@@ -138,10 +139,10 @@ function createTypedFinder(topoKind, filters, rebuild, extend) {
138
139
  const shouldKeep = (element) => filters.every((f) => f(element));
139
140
  function getCachedElements(shape) {
140
141
  switch (topoKind) {
141
- case "edge": return require_arrayAccess.getEdges(shape);
142
- case "face": return require_arrayAccess.getFaces(shape);
143
- case "wire": return require_arrayAccess.getWires(shape);
144
- case "vertex": return require_arrayAccess.getVertices(shape);
142
+ case "edge": return require_shapeFns.getEdges(shape);
143
+ case "face": return require_shapeFns.getFaces(shape);
144
+ case "wire": return require_shapeFns.getWires(shape);
145
+ case "vertex": return require_shapeFns.getVertices(shape);
145
146
  }
146
147
  }
147
148
  const extractElements = (shape) => {
@@ -157,14 +158,14 @@ function createTypedFinder(topoKind, filters, rebuild, extend) {
157
158
  inList: (elements) => {
158
159
  const hashSet = /* @__PURE__ */ new Map();
159
160
  for (const e of elements) {
160
- const h = require_arrayAccess.getHashCode(e);
161
+ const h = require_shapeFns.getHashCode(e);
161
162
  const bucket = hashSet.get(h);
162
163
  if (bucket) bucket.push(e);
163
164
  else hashSet.set(h, [e]);
164
165
  }
165
166
  return withFilter((el) => {
166
- const bucket = hashSet.get(require_arrayAccess.getHashCode(el));
167
- return !!bucket && bucket.some((e) => require_arrayAccess.isSameShape(e, el));
167
+ const bucket = hashSet.get(require_shapeFns.getHashCode(el));
168
+ return !!bucket && bucket.some((e) => require_shapeFns.isSameShape(e, el));
168
169
  });
169
170
  },
170
171
  not: (builderFn) => {
@@ -250,7 +251,7 @@ function edgeDirectionFilter(dir, angle) {
250
251
  const { tangent: rawTangent } = kernel.curveTangent(edge.wrapped, midParam);
251
252
  const tangent = require_vecOps.vecNormalize(rawTangent);
252
253
  const ang = Math.acos(Math.min(1, Math.abs(require_vecOps.vecDot(tangent, d))));
253
- return Math.abs(ang - require_vecOps.DEG2RAD * angle) < 1e-6;
254
+ return Math.abs(ang - require_constants.DEG2RAD * angle) < 1e-6;
254
255
  };
255
256
  }
256
257
  function buildEdgeFinder(filters) {
@@ -275,7 +276,7 @@ function faceDirectionFilter(dir, angle) {
275
276
  return (face) => {
276
277
  const n = require_faceFns.normalAt(face);
277
278
  const ang = Math.acos(Math.min(1, Math.abs(require_vecOps.vecDot(require_vecOps.vecNormalize(n), d))));
278
- return Math.abs(ang - require_vecOps.DEG2RAD * angle) < 1e-6;
279
+ return Math.abs(ang - require_constants.DEG2RAD * angle) < 1e-6;
279
280
  };
280
281
  }
281
282
  function buildFaceFinder(filters) {
@@ -302,7 +303,7 @@ function buildWireFinder(filters) {
302
303
  return createTypedFinder("wire", filters, buildWireFinder, (_base, withFilter) => ({
303
304
  isClosed: () => withFilter((wire) => require_curveFns.curveIsClosed(wire)),
304
305
  isOpen: () => withFilter((wire) => !require_curveFns.curveIsClosed(wire)),
305
- ofEdgeCount: (count) => withFilter((wire) => require_arrayAccess.getEdges(wire).length === count)
306
+ ofEdgeCount: (count) => withFilter((wire) => require_shapeFns.getEdges(wire).length === count)
306
307
  }));
307
308
  }
308
309
  /** Create an immutable wire finder. */