brepjs 12.7.3 → 12.8.1

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 (72) hide show
  1. package/dist/2d/blueprints/boolean2D.d.ts.map +1 -1
  2. package/dist/2d/blueprints/lib.d.ts.map +1 -1
  3. package/dist/2d/blueprints/offset.d.ts.map +1 -1
  4. package/dist/2d.cjs +2 -2
  5. package/dist/2d.js +3 -3
  6. package/dist/{Blueprint-CnDVffSX.cjs → Blueprint-CQ28WJhz.cjs} +29 -30
  7. package/dist/{Blueprint-C3lWY1Jf.js → Blueprint-DbVaf6k7.js} +7 -8
  8. package/dist/{boolean2D-DyQJt8Na.cjs → boolean2D-0blbVtJ8.cjs} +70 -61
  9. package/dist/{boolean2D-CwZAIJDS.js → boolean2D-y3E92F0u.js} +37 -28
  10. package/dist/{booleanFns-CcNUsgI8.js → booleanFns-BCTjYZAg.js} +4 -4
  11. package/dist/{booleanFns-D7HmkpYt.cjs → booleanFns-gmsX3Cv2.cjs} +59 -59
  12. package/dist/brepjs.cjs +319 -372
  13. package/dist/brepjs.js +358 -411
  14. package/dist/core/errors.d.ts +14 -5
  15. package/dist/core/errors.d.ts.map +1 -1
  16. package/dist/core.cjs +30 -31
  17. package/dist/core.js +19 -20
  18. package/dist/{cornerFinder-BV-l1BCw.js → cornerFinder-Ckz-mPHE.js} +1 -1
  19. package/dist/{cornerFinder-3zfbQvXg.cjs → cornerFinder-ZmOyOOsh.cjs} +1 -1
  20. package/dist/{curveFns-Ch87sD5O.cjs → curveFns-BZngcnQ1.cjs} +17 -17
  21. package/dist/{curveFns-CloOqAQ_.js → curveFns-mROFhiuG.js} +1 -1
  22. package/dist/{drawFns-5myJTgtX.js → drawFns-Bwakrq7w.js} +24 -25
  23. package/dist/{drawFns-CDNafQhv.cjs → drawFns-CjRc1NfQ.cjs} +51 -52
  24. package/dist/{faceFns-B6ebRh5I.js → faceFns-B8GnxjdY.js} +1 -1
  25. package/dist/{faceFns-BLTEPBKq.cjs → faceFns-DB1Fc5gy.cjs} +20 -20
  26. package/dist/{helpers-6kn30cSD.cjs → helpers-C8NoT0Wu.cjs} +14 -14
  27. package/dist/{helpers-C9KvE1RW.js → helpers-X0juxnwj.js} +4 -4
  28. package/dist/io.cjs +26 -26
  29. package/dist/io.js +3 -3
  30. package/dist/kernel/brepkitAdapter.d.ts +8 -8
  31. package/dist/kernel/brepkitAdapter.d.ts.map +1 -1
  32. package/dist/kernel/brepkitWasmTypes.d.ts +6 -0
  33. package/dist/kernel/brepkitWasmTypes.d.ts.map +1 -1
  34. package/dist/kernel/historyOps.d.ts +3 -3
  35. package/dist/kernel/historyOps.d.ts.map +1 -1
  36. package/dist/kernel/types.d.ts +8 -8
  37. package/dist/kernel/types.d.ts.map +1 -1
  38. package/dist/{loft-BcZUCGKi.js → loft-Bhw-FMoL.js} +4 -4
  39. package/dist/{loft-DR1UN5uN.cjs → loft-hp3pc1M7.cjs} +43 -43
  40. package/dist/{measurement-DoYXRaKI.cjs → measurement-BoNTUBAp.cjs} +1 -1
  41. package/dist/{measurement-oWvhSVZG.js → measurement-D8EJ694A.js} +1 -1
  42. package/dist/measurement.cjs +1 -1
  43. package/dist/measurement.js +1 -1
  44. package/dist/{meshFns-3gy0empP.cjs → meshFns-BnV0ZR8w.cjs} +17 -17
  45. package/dist/{meshFns-DsLRd3tA.js → meshFns-nQjK38EC.js} +2 -2
  46. package/dist/{operations-Dcz6YlOt.js → operations-BfbkK6DU.js} +5 -5
  47. package/dist/{operations-DLFzmdFX.cjs → operations-CYpmLSC4.cjs} +75 -75
  48. package/dist/operations.cjs +2 -2
  49. package/dist/operations.js +2 -2
  50. package/dist/query.cjs +3 -3
  51. package/dist/query.js +4 -4
  52. package/dist/{errors-B7kgv0cd.js → result-BaSD1fqR.js} +43 -23
  53. package/dist/{errors-9fDehDNc.cjs → result-fAX0OZzI.cjs} +20 -0
  54. package/dist/result.cjs +30 -41
  55. package/dist/result.js +18 -29
  56. package/dist/{shapeFns-D-MOoqJd.cjs → shapeFns-C2SnNvdH.cjs} +39 -39
  57. package/dist/{shapeFns-D2PlLFE6.js → shapeFns-FDuKkrDR.js} +4 -4
  58. package/dist/sketching.cjs +2 -2
  59. package/dist/sketching.js +2 -2
  60. package/dist/{solidBuilders-BzfRBizW.cjs → solidBuilders-994_MQwB.cjs} +12 -12
  61. package/dist/{solidBuilders-BXhh5hP2.js → solidBuilders-DmwhTCCd.js} +2 -2
  62. package/dist/{surfaceBuilders-Be_ENWSA.cjs → surfaceBuilders-5VA34a3_.cjs} +27 -27
  63. package/dist/{surfaceBuilders-D6iDVPIM.js → surfaceBuilders-nQdJ56fe.js} +2 -2
  64. package/dist/{topology-CKtCGLmb.cjs → topology-ANwCzGL8.cjs} +54 -54
  65. package/dist/{topology-DxD58iQ6.js → topology-C7x98OVn.js} +8 -8
  66. package/dist/topology.cjs +6 -6
  67. package/dist/topology.js +6 -6
  68. package/dist/{vectors-CESkzEm6.js → vectors-Bx8wkNui.js} +1 -1
  69. package/dist/{vectors-BafmMf96.cjs → vectors-D_IiZx0q.cjs} +6 -6
  70. package/dist/vectors.cjs +1 -1
  71. package/dist/vectors.js +1 -1
  72. package/package.json +5 -8
@@ -43,18 +43,17 @@ var __callDispose = (stack, error, hasError) => {
43
43
  };
44
44
  return next();
45
45
  };
46
- import { a as createPlane } from "./vectors-CESkzEm6.js";
47
- import { o as ok, e as err, b as computationError, r as unwrap, g as isOk } from "./errors-B7kgv0cd.js";
48
- import { d as downcast, u as uvBounds, p as pointOnSurface, n as normalAt } from "./faceFns-B6ebRh5I.js";
46
+ import { a as createPlane } from "./vectors-Bx8wkNui.js";
47
+ import { o as ok, e as err, d as computationError, v as unwrap, h as isOk, C as safeIndex, b as bug } from "./result-BaSD1fqR.js";
48
+ import { d as downcast, u as uvBounds, p as pointOnSurface, n as normalAt } from "./faceFns-B8GnxjdY.js";
49
49
  import { a as toVec3 } from "./types-CWDdqcrq.js";
50
50
  import { n as vecScale, j as vecNormalize, b as vecCross, D as DEG2RAD, R as RAD2DEG } from "./vecOps-ZDdZWbwT.js";
51
- import { r as revolution, c as complexExtrude, t as twistExtrude, b as basicFaceExtrusion, g as genericSweep, l as loft } from "./loft-BcZUCGKi.js";
51
+ import { r as revolution, c as complexExtrude, t as twistExtrude, b as basicFaceExtrusion, g as genericSweep, l as loft } from "./loft-Bhw-FMoL.js";
52
52
  import { J as getKernel2D, I as createFace, G as createWire, B as getKernel, H as createEdge, D as DisposalScope } from "./shapeTypes-CpSaBLDv.js";
53
- import { c as curveStartPoint, a as curveTangentAt, b as curveIsClosed } from "./curveFns-CloOqAQ_.js";
54
- import { m as makeFace, h as makeNewFaceWithinFace, b as assembleWire, z as zip } from "./surfaceBuilders-D6iDVPIM.js";
55
- import { bug } from "./result.js";
56
- import { s as samePoint$1, e as subtract2d, c as add2d, h as crossProduct2d, b as scalarMultiply2d, p as polarToCartesian, r as rotate2d, i as cartesianToPolar, d as distance2d, j as polarAngle2d, k as PRECISION_INTERSECTION } from "./helpers-C9KvE1RW.js";
57
- import { C as Curve2D, a as make2dSegmentCurve, k as approximateAsBSpline, n as normalize2d, b as make2dArcFromCenter, l as isPoint2D, h as make2dCircle, o as make2dThreePointArc, e as BoundingBox2d, v as viewbox, p as asSVG, B as Blueprint, q as make2dEllipseArc, r as make2dTangentArc, s as make2dBezierCurve, t as removeDuplicatePoints } from "./Blueprint-C3lWY1Jf.js";
53
+ import { c as curveStartPoint, a as curveTangentAt, b as curveIsClosed } from "./curveFns-mROFhiuG.js";
54
+ import { m as makeFace, h as makeNewFaceWithinFace, b as assembleWire, z as zip } from "./surfaceBuilders-nQdJ56fe.js";
55
+ import { s as samePoint$1, e as subtract2d, c as add2d, h as crossProduct2d, b as scalarMultiply2d, p as polarToCartesian, r as rotate2d, i as cartesianToPolar, d as distance2d, j as polarAngle2d, k as PRECISION_INTERSECTION } from "./helpers-X0juxnwj.js";
56
+ import { C as Curve2D, a as make2dSegmentCurve, k as approximateAsBSpline, n as normalize2d, b as make2dArcFromCenter, l as isPoint2D, h as make2dCircle, o as make2dThreePointArc, e as BoundingBox2d, v as viewbox, p as asSVG, B as Blueprint, q as make2dEllipseArc, r as make2dTangentArc, s as make2dBezierCurve, t as removeDuplicatePoints } from "./Blueprint-DbVaf6k7.js";
58
57
  const intersectCurves = (first, second, precision = 1e-9) => {
59
58
  if (first.boundingBox.isOut(second.boundingBox))
60
59
  return ok({ intersections: [], commonSegments: [], commonSegmentsPoints: [] });
@@ -863,7 +862,7 @@ class Blueprints {
863
862
  }
864
863
  const groupByBoundingBoxOverlap = (blueprints) => {
865
864
  if (blueprints.length === 0) return [];
866
- if (blueprints.length === 1) return [[blueprints[0]]];
865
+ if (blueprints.length === 1) return [[safeIndex(blueprints, 0, "groupByBoundingBoxOverlap")]];
867
866
  const index = new Flatbush(blueprints.length);
868
867
  for (const bp of blueprints) {
869
868
  const [[xMin, yMin], [xMax, yMax]] = bp.boundingBox.bounds;
@@ -874,8 +873,9 @@ const groupByBoundingBoxOverlap = (blueprints) => {
874
873
  const [[xMin, yMin], [xMax, yMax]] = blueprint.boundingBox.bounds;
875
874
  const candidates = index.search(xMin, yMin, xMax, yMax);
876
875
  return candidates.filter(
877
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- index from spatial query within bounds
878
- (j) => j > i && !blueprint.boundingBox.isOut(blueprints[j].boundingBox)
876
+ (j) => j > i && !blueprint.boundingBox.isOut(
877
+ safeIndex(blueprints, j, "groupByBoundingBoxOverlap").boundingBox
878
+ )
879
879
  );
880
880
  });
881
881
  const groups = [];
@@ -886,7 +886,7 @@ const groupByBoundingBoxOverlap = (blueprints) => {
886
886
  myGroup = [];
887
887
  groups.push(myGroup);
888
888
  }
889
- myGroup.push(blueprints[i]);
889
+ myGroup.push(safeIndex(blueprints, i, "groupByBoundingBoxOverlap"));
890
890
  if (indices.length) {
891
891
  indices.forEach((idx) => {
892
892
  groupsInOverlaps[idx] = myGroup;
@@ -897,7 +897,7 @@ const groupByBoundingBoxOverlap = (blueprints) => {
897
897
  };
898
898
  const addContainmentInfo = (groupedBlueprints) => {
899
899
  return groupedBlueprints.map((blueprint, index) => {
900
- const firstCurve = blueprint.curves[0];
900
+ const firstCurve = safeIndex(blueprint.curves, 0, "addContainmentInfo");
901
901
  const point = firstCurve.value((firstCurve.lastParameter + firstCurve.firstParameter) / 2);
902
902
  const isIn = groupedBlueprints.filter((potentialOuterBlueprint, j) => {
903
903
  if (index === j) return false;
@@ -941,7 +941,7 @@ const organiseBlueprints = (blueprints) => {
941
941
  const basicGrouping = groupByBoundingBoxOverlap(blueprints).map(addContainmentInfo);
942
942
  return new Blueprints(
943
943
  basicGrouping.flatMap(cleanEdgeCases).map((compounds) => {
944
- if (compounds.length === 1) return compounds[0].blueprint;
944
+ if (compounds.length === 1) return safeIndex(compounds, 0, "organiseBlueprints").blueprint;
945
945
  compounds.sort((a, b) => a.isIn.length - b.isIn.length);
946
946
  return new CompoundBlueprint(compounds.map(({ blueprint }) => blueprint));
947
947
  })
@@ -2266,7 +2266,11 @@ const fuseIntersectingBlueprints = (blueprints) => {
2266
2266
  if (!genericIntersects(blueprint, otherBlueprint)) return;
2267
2267
  let newFused;
2268
2268
  if (blueprint instanceof Blueprints || otherBlueprint instanceof Blueprints) {
2269
- newFused = fuse2D(blueprint, otherBlueprint);
2269
+ const fused2 = fuse2D(blueprint, otherBlueprint);
2270
+ if (fused2 === null) {
2271
+ bug("fuseIntersectingBlueprints", "fuse2D returned null for non-null inputs");
2272
+ }
2273
+ newFused = fused2;
2270
2274
  } else {
2271
2275
  newFused = genericFuse(blueprint, otherBlueprint);
2272
2276
  }
@@ -2274,7 +2278,7 @@ const fuseIntersectingBlueprints = (blueprints) => {
2274
2278
  if (newFused instanceof Blueprints && newFused.blueprints.length === 2) {
2275
2279
  return;
2276
2280
  } else if (newFused instanceof Blueprints && newFused.blueprints.length === 1) {
2277
- newFused = newFused.blueprints[0];
2281
+ newFused = safeIndex(newFused.blueprints, 0, "fuseIntersectingBlueprints");
2278
2282
  } else if (!(newFused instanceof Blueprints)) {
2279
2283
  bug("fuseIntersectingBlueprints", "Fuse produced unexpected non-blueprint result");
2280
2284
  }
@@ -2293,7 +2297,10 @@ const allBlueprints = (shape) => {
2293
2297
  return [];
2294
2298
  };
2295
2299
  const fuseBlueprintWithCompound = (blueprint, compound) => {
2296
- const outerFused = fuseBlueprints(blueprint, compound.blueprints[0]);
2300
+ const outerFused = fuseBlueprints(
2301
+ blueprint,
2302
+ safeIndex(compound.blueprints, 0, "fuseBlueprintWithCompound")
2303
+ );
2297
2304
  const innerFused = compound.blueprints.slice(1).map((c) => cutBlueprints(c, blueprint));
2298
2305
  return organiseBlueprints([
2299
2306
  ...allBlueprints(outerFused),
@@ -2310,9 +2317,11 @@ function allPairs(list1, list2) {
2310
2317
  return result;
2311
2318
  }
2312
2319
  const fuseCompoundWithCompound = (first, second) => {
2313
- const outerFused = fuseBlueprints(first.blueprints[0], second.blueprints[0]);
2314
- const inner1Fused = second.blueprints.slice(1).map((c) => cutBlueprints(c, first.blueprints[0]));
2315
- const inner2Fused = first.blueprints.slice(1).map((c) => cutBlueprints(c, second.blueprints[0]));
2320
+ const firstOuter = safeIndex(first.blueprints, 0, "fuseCompoundWithCompound");
2321
+ const secondOuter = safeIndex(second.blueprints, 0, "fuseCompoundWithCompound");
2322
+ const outerFused = fuseBlueprints(firstOuter, secondOuter);
2323
+ const inner1Fused = second.blueprints.slice(1).map((c) => cutBlueprints(c, firstOuter));
2324
+ const inner2Fused = first.blueprints.slice(1).map((c) => cutBlueprints(c, secondOuter));
2316
2325
  const innerIntersections = allPairs(
2317
2326
  first.blueprints.slice(1),
2318
2327
  second.blueprints.slice(1)
@@ -2340,7 +2349,7 @@ const fuse2D = (first, second) => {
2340
2349
  return fuseIntersectingBlueprints([second, ...first.blueprints]);
2341
2350
  }
2342
2351
  if (first instanceof Blueprints && second instanceof Blueprints) {
2343
- let out = fuse2D(first.blueprints[0], second);
2352
+ let out = fuse2D(safeIndex(first.blueprints, 0, "fuse2D"), second);
2344
2353
  first.blueprints.slice(1).forEach((bp) => {
2345
2354
  out = fuse2D(bp, out);
2346
2355
  });
@@ -2379,7 +2388,7 @@ const mergeNonIntersecting = (shapes) => {
2379
2388
  if (s instanceof Blueprints) return s.blueprints;
2380
2389
  return s;
2381
2390
  });
2382
- if (exploded.length === 1) return exploded[0];
2391
+ if (exploded.length === 1) return safeIndex(exploded, 0, "mergeNonIntersecting");
2383
2392
  return new Blueprints(exploded);
2384
2393
  };
2385
2394
  const cut2D = (first, second) => {
@@ -2393,13 +2402,13 @@ const cut2D = (first, second) => {
2393
2402
  return mergeNonIntersecting(first.blueprints.map((bp) => cut2D(bp, second)));
2394
2403
  }
2395
2404
  if (first instanceof CompoundBlueprint) {
2396
- const wrapper = first.blueprints[0];
2405
+ const wrapper = safeIndex(first.blueprints, 0, "cut2D");
2397
2406
  if (second instanceof Blueprint && !second.intersects(wrapper)) {
2398
2407
  if (!wrapper.isInside(second.firstPoint)) return null;
2399
2408
  const cuts = fuse2D(second, new Blueprints(first.blueprints.slice(1)));
2400
2409
  return organiseBlueprints([wrapper, ...allBlueprints(cuts)]);
2401
2410
  } else {
2402
- let out = cut2D(first.blueprints[0], second);
2411
+ let out = cut2D(wrapper, second);
2403
2412
  first.blueprints.slice(1).forEach((bp) => {
2404
2413
  out = cut2D(out, bp);
2405
2414
  });
@@ -2410,7 +2419,7 @@ const cut2D = (first, second) => {
2410
2419
  return mergeNonIntersecting(second.blueprints.map((bp) => cut2D(first, bp)));
2411
2420
  }
2412
2421
  if (second instanceof CompoundBlueprint) {
2413
- let out = cutBlueprints(first, second.blueprints[0]);
2422
+ let out = cutBlueprints(first, safeIndex(second.blueprints, 0, "cut2D"));
2414
2423
  second.blueprints.slice(1).forEach((bp) => {
2415
2424
  out = fuse2D(out, intersectBlueprints(bp, first));
2416
2425
  });
@@ -2430,7 +2439,7 @@ function intersect2D(first, second) {
2430
2439
  return mergeNonIntersecting(first.blueprints.map((bp) => intersect2D(bp, second)));
2431
2440
  }
2432
2441
  if (first instanceof CompoundBlueprint) {
2433
- const wrapper = first.blueprints[0];
2442
+ const wrapper = safeIndex(first.blueprints, 0, "intersect2D");
2434
2443
  const cuts = first.blueprints.slice(1);
2435
2444
  if (cuts.length === 0) {
2436
2445
  return intersect2D(wrapper, second);
@@ -2445,7 +2454,7 @@ function intersect2D(first, second) {
2445
2454
  return mergeNonIntersecting(second.blueprints.map((bp) => intersect2D(first, bp)));
2446
2455
  }
2447
2456
  if (second instanceof CompoundBlueprint) {
2448
- const wrapper = second.blueprints[0];
2457
+ const wrapper = safeIndex(second.blueprints, 0, "intersect2D");
2449
2458
  const cuts = second.blueprints.slice(1);
2450
2459
  if (cuts.length === 0) {
2451
2460
  return intersect2D(wrapper, first);
@@ -1,9 +1,9 @@
1
1
  import { B as getKernel, c as castShape, p as isShape3D } from "./shapeTypes-CpSaBLDv.js";
2
- import { o as ok, d as isErr, e as err, y as validationError, B as BrepErrorCode, p as typeCastError, k as kernelError } from "./errors-B7kgv0cd.js";
3
- import { r as resolvePlane } from "./vectors-CESkzEm6.js";
2
+ import { o as ok, g as isErr, e as err, z as validationError, A as BrepErrorCode, r as typeCastError, k as kernelError } from "./result-BaSD1fqR.js";
3
+ import { r as resolvePlane } from "./vectors-Bx8wkNui.js";
4
4
  import { H as HASH_CODE_MAX, n as vecScale, v as vecAdd } from "./vecOps-ZDdZWbwT.js";
5
- import { a as getFaces, p as propagateOriginsByHash, b as propagateOriginsFromEvolution, c as getWires, d as getEdges, e as getVertices, g as getFaceOrigins } from "./shapeFns-D2PlLFE6.js";
6
- import { m as makeFace } from "./surfaceBuilders-D6iDVPIM.js";
5
+ import { a as getFaces, p as propagateOriginsByHash, b as propagateOriginsFromEvolution, c as getWires, d as getEdges, e as getVertices, g as getFaceOrigins } from "./shapeFns-FDuKkrDR.js";
6
+ import { m as makeFace } from "./surfaceBuilders-nQdJ56fe.js";
7
7
  const shapeTagStore = /* @__PURE__ */ new WeakMap();
8
8
  const tagMetadataStore = /* @__PURE__ */ new WeakMap();
9
9
  function hasFaceTags(shape) {
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  const shapeTypes = require("./shapeTypes-7xEam9Ri.cjs");
3
- const errors = require("./errors-9fDehDNc.cjs");
4
- const vectors = require("./vectors-BafmMf96.cjs");
3
+ const result = require("./result-fAX0OZzI.cjs");
4
+ const vectors = require("./vectors-D_IiZx0q.cjs");
5
5
  const vecOps = require("./vecOps-CjRL1jau.cjs");
6
- const shapeFns = require("./shapeFns-D-MOoqJd.cjs");
7
- const surfaceBuilders = require("./surfaceBuilders-Be_ENWSA.cjs");
6
+ const shapeFns = require("./shapeFns-C2SnNvdH.cjs");
7
+ const surfaceBuilders = require("./surfaceBuilders-5VA34a3_.cjs");
8
8
  const shapeTagStore = /* @__PURE__ */ new WeakMap();
9
9
  const tagMetadataStore = /* @__PURE__ */ new WeakMap();
10
10
  function hasFaceTags(shape) {
@@ -41,19 +41,19 @@ function findFacesByTag(shape, tag) {
41
41
  if (!tagMap) return [];
42
42
  const hashes = tagMap.get(tag);
43
43
  if (!hashes || hashes.size === 0) return [];
44
- const result = [];
44
+ const result2 = [];
45
45
  for (const face of shapeFns.getFaces(shape)) {
46
46
  const hash = shapeTypes.getKernel().hashCode(face.wrapped, vecOps.HASH_CODE_MAX);
47
47
  if (hashes.has(hash)) {
48
- result.push(face);
48
+ result2.push(face);
49
49
  }
50
50
  }
51
- return result;
51
+ return result2;
52
52
  }
53
53
  function getFaceTags(shape) {
54
- const result = /* @__PURE__ */ new Map();
54
+ const result2 = /* @__PURE__ */ new Map();
55
55
  const tagMap = shapeTagStore.get(shape.wrapped);
56
- if (!tagMap) return result;
56
+ if (!tagMap) return result2;
57
57
  const faces = shapeFns.getFaces(shape);
58
58
  const faceByHash = /* @__PURE__ */ new Map();
59
59
  for (const face of faces) {
@@ -66,10 +66,10 @@ function getFaceTags(shape) {
66
66
  if (face) taggedFaces.push(face);
67
67
  }
68
68
  if (taggedFaces.length > 0) {
69
- result.set(tag, taggedFaces);
69
+ result2.set(tag, taggedFaces);
70
70
  }
71
71
  }
72
- return result;
72
+ return result2;
73
73
  }
74
74
  function setTagMetadata(shape, tag, metadata) {
75
75
  const metaMap = getMetaMap(shape);
@@ -79,8 +79,8 @@ function setTagMetadata(shape, tag, metadata) {
79
79
  function getTagMetadata(shape, tag) {
80
80
  return tagMetadataStore.get(shape.wrapped)?.get(tag);
81
81
  }
82
- function propagateFaceTagsFromEvolution(evolution, inputs, result) {
83
- const resultTagMap = getTagMap(result);
82
+ function propagateFaceTagsFromEvolution(evolution, inputs, result2) {
83
+ const resultTagMap = getTagMap(result2);
84
84
  for (const input of inputs) {
85
85
  const inputTagMap = shapeTagStore.get(input.wrapped);
86
86
  if (!inputTagMap) continue;
@@ -113,7 +113,7 @@ function propagateFaceTagsFromEvolution(evolution, inputs, result) {
113
113
  }
114
114
  const inputMetaMap = tagMetadataStore.get(input.wrapped);
115
115
  if (inputMetaMap) {
116
- const resultMetaMap = getMetaMap(result);
116
+ const resultMetaMap = getMetaMap(result2);
117
117
  for (const [tag, meta] of inputMetaMap) {
118
118
  if (!resultMetaMap.has(tag)) {
119
119
  resultMetaMap.set(tag, meta);
@@ -171,15 +171,15 @@ function getFaceColor(shape, face) {
171
171
  if (!map) return void 0;
172
172
  return map.get(shapeTypes.getKernel().hashCode(face.wrapped, vecOps.HASH_CODE_MAX));
173
173
  }
174
- function propagateColorsFromEvolution(evolution, inputs, result) {
174
+ function propagateColorsFromEvolution(evolution, inputs, result2) {
175
175
  for (const input of inputs) {
176
176
  const c = shapeColorStore.get(input.wrapped);
177
177
  if (c) {
178
- shapeColorStore.set(result.wrapped, c);
178
+ shapeColorStore.set(result2.wrapped, c);
179
179
  break;
180
180
  }
181
181
  }
182
- const resultFaceMap = getFaceColorMap(result);
182
+ const resultFaceMap = getFaceColorMap(result2);
183
183
  for (const input of inputs) {
184
184
  const inputFaceMap = faceColorStore.get(input.wrapped);
185
185
  if (!inputFaceMap || inputFaceMap.size === 0) continue;
@@ -198,9 +198,9 @@ function propagateColorsFromEvolution(evolution, inputs, result) {
198
198
  }
199
199
  function validateShape3D(shape, label) {
200
200
  if (shapeTypes.getKernel().isNull(shape.wrapped)) {
201
- return errors.err(errors.validationError(errors.BrepErrorCode.NULL_SHAPE_INPUT, `${label} is a null shape`));
201
+ return result.err(result.validationError(result.BrepErrorCode.NULL_SHAPE_INPUT, `${label} is a null shape`));
202
202
  }
203
- return errors.ok(void 0);
203
+ return result.ok(void 0);
204
204
  }
205
205
  function castToShape3D(shape, errorCode, errorMsg) {
206
206
  const wrapped = shapeTypes.castShape(shape);
@@ -219,9 +219,9 @@ function castToShape3D(shape, errorCode, errorMsg) {
219
219
  ];
220
220
  const typeName = typeNames[shapeType] ?? `UNKNOWN(${shapeType})`;
221
221
  wrapped[Symbol.dispose]();
222
- return errors.err(errors.typeCastError(errorCode, `${errorMsg}. Got ${typeName} instead.`));
222
+ return result.err(result.typeCastError(errorCode, `${errorMsg}. Got ${typeName} instead.`));
223
223
  }
224
- return errors.ok(wrapped);
224
+ return result.ok(wrapped);
225
225
  }
226
226
  function collectInputFaceHashes(inputs) {
227
227
  const hasMetadata = inputs.some(
@@ -240,9 +240,9 @@ function collectInputFaceHashes(inputs) {
240
240
  function fuse(a, b, { optimisation = "none", simplify = false, signal, fuzzyValue } = {}) {
241
241
  if (signal?.aborted) throw signal.reason;
242
242
  const checkA = validateShape3D(a, "fuse: first operand");
243
- if (errors.isErr(checkA)) return checkA;
243
+ if (result.isErr(checkA)) return checkA;
244
244
  const checkB = validateShape3D(b, "fuse: second operand");
245
- if (errors.isErr(checkB)) return checkB;
245
+ if (result.isErr(checkB)) return checkB;
246
246
  const inputFaceHashes = collectInputFaceHashes([a, b]);
247
247
  const { shape: resultShape, evolution } = shapeTypes.getKernel().fuseWithHistory(
248
248
  a.wrapped,
@@ -262,9 +262,9 @@ function fuse(a, b, { optimisation = "none", simplify = false, signal, fuzzyValu
262
262
  function cut(base, tool, { optimisation = "none", simplify = false, signal, fuzzyValue } = {}) {
263
263
  if (signal?.aborted) throw signal.reason;
264
264
  const checkBase = validateShape3D(base, "cut: base");
265
- if (errors.isErr(checkBase)) return checkBase;
265
+ if (result.isErr(checkBase)) return checkBase;
266
266
  const checkTool = validateShape3D(tool, "cut: tool");
267
- if (errors.isErr(checkTool)) return checkTool;
267
+ if (result.isErr(checkTool)) return checkTool;
268
268
  const inputFaceHashes = collectInputFaceHashes([base, tool]);
269
269
  const { shape: resultShape, evolution } = shapeTypes.getKernel().cutWithHistory(
270
270
  base.wrapped,
@@ -284,9 +284,9 @@ function cut(base, tool, { optimisation = "none", simplify = false, signal, fuzz
284
284
  function intersect(a, b, { simplify = false, signal, fuzzyValue } = {}) {
285
285
  if (signal?.aborted) throw signal.reason;
286
286
  const checkA = validateShape3D(a, "intersect: first operand");
287
- if (errors.isErr(checkA)) return checkA;
287
+ if (result.isErr(checkA)) return checkA;
288
288
  const checkB = validateShape3D(b, "intersect: second operand");
289
- if (errors.isErr(checkB)) return checkB;
289
+ if (result.isErr(checkB)) return checkB;
290
290
  const inputFaceHashes = collectInputFaceHashes([a, b]);
291
291
  const { shape: resultShape, evolution } = shapeTypes.getKernel().intersectWithHistory(
292
292
  a.wrapped,
@@ -310,7 +310,7 @@ function intersect(a, b, { simplify = false, signal, fuzzyValue } = {}) {
310
310
  function fuseAllPairwise(shapes, start, end, optimisation, simplify, isTopLevel, signal, fuzzyValue) {
311
311
  if (signal?.aborted) throw signal.reason;
312
312
  const count = end - start;
313
- if (count === 1) return errors.ok(shapes[start]);
313
+ if (count === 1) return result.ok(shapes[start]);
314
314
  if (count === 2) {
315
315
  return fuse(shapes[start], shapes[start + 1], {
316
316
  optimisation,
@@ -330,7 +330,7 @@ function fuseAllPairwise(shapes, start, end, optimisation, simplify, isTopLevel,
330
330
  signal,
331
331
  fuzzyValue
332
332
  );
333
- if (errors.isErr(leftResult)) return leftResult;
333
+ if (result.isErr(leftResult)) return leftResult;
334
334
  const rightResult = fuseAllPairwise(
335
335
  shapes,
336
336
  mid,
@@ -341,7 +341,7 @@ function fuseAllPairwise(shapes, start, end, optimisation, simplify, isTopLevel,
341
341
  signal,
342
342
  fuzzyValue
343
343
  );
344
- if (errors.isErr(rightResult)) return rightResult;
344
+ if (result.isErr(rightResult)) return rightResult;
345
345
  return fuse(leftResult.value, rightResult.value, {
346
346
  optimisation,
347
347
  simplify: isTopLevel ? simplify : false,
@@ -358,19 +358,19 @@ function fuseAll(shapes, {
358
358
  } = {}) {
359
359
  if (signal?.aborted) throw signal.reason;
360
360
  if (shapes.length === 0)
361
- return errors.err(errors.validationError("FUSE_ALL_EMPTY", "fuseAll requires at least one shape"));
362
- if (shapes.length === 1) return errors.ok(shapes[0]);
361
+ return result.err(result.validationError("FUSE_ALL_EMPTY", "fuseAll requires at least one shape"));
362
+ if (shapes.length === 1) return result.ok(shapes[0]);
363
363
  for (let i = 0; i < shapes.length; i++) {
364
364
  const check = validateShape3D(shapes[i], `fuseAll: shape at index ${i}`);
365
- if (errors.isErr(check)) return check;
365
+ if (result.isErr(check)) return check;
366
366
  }
367
367
  if (strategy === "native") {
368
- const result = shapeTypes.getKernel().fuseAll(
368
+ const result2 = shapeTypes.getKernel().fuseAll(
369
369
  shapes.map((s) => s.wrapped),
370
370
  { optimisation, simplify, strategy, fuzzyValue, ...signal ? { signal } : {} }
371
371
  );
372
372
  const fuseAllResult = castToShape3D(
373
- result,
373
+ result2,
374
374
  "FUSE_ALL_NOT_3D",
375
375
  "fuseAll did not produce a 3D shape"
376
376
  );
@@ -392,20 +392,20 @@ function fuseAll(shapes, {
392
392
  }
393
393
  function cutAll(base, tools, { optimisation = "none", simplify = false, signal, fuzzyValue } = {}) {
394
394
  if (signal?.aborted) throw signal.reason;
395
- if (tools.length === 0) return errors.ok(base);
395
+ if (tools.length === 0) return result.ok(base);
396
396
  const checkBase = validateShape3D(base, "cutAll: base");
397
- if (errors.isErr(checkBase)) return checkBase;
397
+ if (result.isErr(checkBase)) return checkBase;
398
398
  for (let i = 0; i < tools.length; i++) {
399
399
  const check = validateShape3D(tools[i], `cutAll: tool at index ${i}`);
400
- if (errors.isErr(check)) return check;
400
+ if (result.isErr(check)) return check;
401
401
  }
402
402
  const allInputs = [base, ...tools];
403
- const result = shapeTypes.getKernel().cutAll(
403
+ const result$1 = shapeTypes.getKernel().cutAll(
404
404
  base.wrapped,
405
405
  tools.map((s) => s.wrapped),
406
406
  { optimisation, simplify, fuzzyValue }
407
407
  );
408
- const cutAllResult = castToShape3D(result, "CUT_ALL_NOT_3D", "cutAll did not produce a 3D shape");
408
+ const cutAllResult = castToShape3D(result$1, "CUT_ALL_NOT_3D", "cutAll did not produce a 3D shape");
409
409
  if (cutAllResult.ok) {
410
410
  shapeFns.propagateOriginsByHash(allInputs, cutAllResult.value);
411
411
  }
@@ -436,7 +436,7 @@ function makeSectionFace(plane, size) {
436
436
  }
437
437
  function section(shape, plane, { approximation = true, planeSize = 1e4 } = {}) {
438
438
  if (shapeTypes.getKernel().isNull(shape.wrapped)) {
439
- return errors.err(errors.validationError(errors.BrepErrorCode.NULL_SHAPE_INPUT, "section: shape is a null shape"));
439
+ return result.err(result.validationError(result.BrepErrorCode.NULL_SHAPE_INPUT, "section: shape is a null shape"));
440
440
  }
441
441
  const resolvedPlane = typeof plane === "string" ? vectors.resolvePlane(plane) : plane;
442
442
  const sectionFace = makeSectionFace(resolvedPlane, planeSize);
@@ -444,12 +444,12 @@ function section(shape, plane, { approximation = true, planeSize = 1e4 } = {}) {
444
444
  const kernel = shapeTypes.getKernel();
445
445
  const resultOc = kernel.section(shape.wrapped, sectionFace, approximation);
446
446
  const wrapped = shapeTypes.castShape(resultOc);
447
- return errors.ok(wrapped);
447
+ return result.ok(wrapped);
448
448
  } catch (e) {
449
449
  const raw = e instanceof Error ? e.message : String(e);
450
450
  const planeName = typeof plane === "string" ? plane : "custom";
451
- return errors.err(
452
- errors.kernelError("SECTION_FAILED", `Section with ${planeName} plane failed: ${raw}`, e, {
451
+ return result.err(
452
+ result.kernelError("SECTION_FAILED", `Section with ${planeName} plane failed: ${raw}`, e, {
453
453
  operation: "section",
454
454
  plane: planeName
455
455
  })
@@ -465,7 +465,7 @@ function sectionToFace(shape, plane, options = {}) {
465
465
  if (wires.length === 0) {
466
466
  const edges = shapeFns.getEdges(sectionResult.value);
467
467
  if (edges.length === 0) {
468
- return errors.err(errors.kernelError("SECTION_FAILED", "sectionToFace: section produced no geometry"));
468
+ return result.err(result.kernelError("SECTION_FAILED", "sectionToFace: section produced no geometry"));
469
469
  }
470
470
  const kernel = shapeTypes.getKernel();
471
471
  const vertexToEdges = /* @__PURE__ */ new Map();
@@ -518,7 +518,7 @@ function sectionToFace(shape, plane, options = {}) {
518
518
  }
519
519
  }
520
520
  if (wires.length === 0) {
521
- return errors.err(errors.kernelError("SECTION_FAILED", "sectionToFace: section produced no usable geometry"));
521
+ return result.err(result.kernelError("SECTION_FAILED", "sectionToFace: section produced no usable geometry"));
522
522
  }
523
523
  let outerIdx = 0;
524
524
  let maxDiag = -1;
@@ -543,30 +543,30 @@ function sectionToFace(shape, plane, options = {}) {
543
543
  );
544
544
  }
545
545
  function split(shape, tools) {
546
- if (tools.length === 0) return errors.ok(shape);
546
+ if (tools.length === 0) return result.ok(shape);
547
547
  if (shapeTypes.getKernel().isNull(shape.wrapped)) {
548
- return errors.err(errors.validationError(errors.BrepErrorCode.NULL_SHAPE_INPUT, "split: shape is a null shape"));
548
+ return result.err(result.validationError(result.BrepErrorCode.NULL_SHAPE_INPUT, "split: shape is a null shape"));
549
549
  }
550
550
  for (let i = 0; i < tools.length; i++) {
551
551
  if (shapeTypes.getKernel().isNull(tools[i].wrapped)) {
552
- return errors.err(
553
- errors.validationError(
554
- errors.BrepErrorCode.NULL_SHAPE_INPUT,
552
+ return result.err(
553
+ result.validationError(
554
+ result.BrepErrorCode.NULL_SHAPE_INPUT,
555
555
  `splitShape: tool at index ${i} is a null shape`
556
556
  )
557
557
  );
558
558
  }
559
559
  }
560
560
  try {
561
- const result = shapeTypes.getKernel().split(
561
+ const result$1 = shapeTypes.getKernel().split(
562
562
  shape.wrapped,
563
563
  tools.map((t) => t.wrapped)
564
564
  );
565
- return errors.ok(shapeTypes.castShape(result));
565
+ return result.ok(shapeTypes.castShape(result$1));
566
566
  } catch (e) {
567
567
  const raw = e instanceof Error ? e.message : String(e);
568
- return errors.err(
569
- errors.kernelError("SPLIT_FAILED", `Split operation failed on ${tools.length} tool(s): ${raw}`, e, {
568
+ return result.err(
569
+ result.kernelError("SPLIT_FAILED", `Split operation failed on ${tools.length} tool(s): ${raw}`, e, {
570
570
  operation: "split",
571
571
  toolCount: tools.length
572
572
  })
@@ -576,11 +576,11 @@ function split(shape, tools) {
576
576
  function slice(shape, planes, options = {}) {
577
577
  const results = [];
578
578
  for (const plane of planes) {
579
- const result = section(shape, plane, options);
580
- if (errors.isErr(result)) return result;
581
- results.push(result.value);
579
+ const result$1 = section(shape, plane, options);
580
+ if (result.isErr(result$1)) return result$1;
581
+ results.push(result$1.value);
582
582
  }
583
- return errors.ok(results);
583
+ return result.ok(results);
584
584
  }
585
585
  exports.colorFaces = colorFaces;
586
586
  exports.colorShape = colorShape;