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
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  const shapeTypes = require("./shapeTypes-7xEam9Ri.cjs");
3
3
  const vecOps = require("./vecOps-CjRL1jau.cjs");
4
- const errors = require("./errors-9fDehDNc.cjs");
5
- const loft = require("./loft-DR1UN5uN.cjs");
6
- const booleanFns = require("./booleanFns-D7HmkpYt.cjs");
7
- const shapeFns = require("./shapeFns-D-MOoqJd.cjs");
8
- const faceFns = require("./faceFns-BLTEPBKq.cjs");
4
+ const result = require("./result-fAX0OZzI.cjs");
5
+ const loft = require("./loft-hp3pc1M7.cjs");
6
+ const booleanFns = require("./booleanFns-gmsX3Cv2.cjs");
7
+ const shapeFns = require("./shapeFns-C2SnNvdH.cjs");
8
+ const faceFns = require("./faceFns-DB1Fc5gy.cjs");
9
9
  function uuidv() {
10
10
  return (String([1e7]) + String(-1e3) + String(-4e3) + String(-8e3) + String(-1e11)).replace(
11
11
  /[018]/g,
@@ -44,10 +44,10 @@ function makeHelixWire(pitch, height, radius, center, dir, _lefthand = false) {
44
44
  }
45
45
  function extrude(face, extrusionVec) {
46
46
  if (shapeTypes.getKernel().isNull(face.wrapped)) {
47
- return errors.err(errors.validationError(errors.BrepErrorCode.NULL_SHAPE_INPUT, "extrude: face is a null shape"));
47
+ return result.err(result.validationError(result.BrepErrorCode.NULL_SHAPE_INPUT, "extrude: face is a null shape"));
48
48
  }
49
49
  if (vecOps.vecLength(extrusionVec) === 0) {
50
- return errors.err(errors.validationError("EXTRUDE_ZERO_VECTOR", "extrude: extrusion vector has zero length"));
50
+ return result.err(result.validationError("EXTRUDE_ZERO_VECTOR", "extrude: extrusion vector has zero length"));
51
51
  }
52
52
  try {
53
53
  const kernel = shapeTypes.getKernel();
@@ -56,10 +56,10 @@ function extrude(face, extrusionVec) {
56
56
  const shape = kernel.extrude(face.wrapped, [...dir], len);
57
57
  const downcastShape = kernel.downcast(shape, "solid");
58
58
  const solid = shapeTypes.createSolid(downcastShape);
59
- return errors.ok(solid);
59
+ return result.ok(solid);
60
60
  } catch (e) {
61
- return errors.err(
62
- errors.kernelError("EXTRUDE_FAILED", "Extrusion operation failed", e, {
61
+ return result.err(
62
+ result.kernelError("EXTRUDE_FAILED", "Extrusion operation failed", e, {
63
63
  operation: "extrude",
64
64
  vectorLength: vecOps.vecLength(extrusionVec)
65
65
  })
@@ -68,15 +68,15 @@ function extrude(face, extrusionVec) {
68
68
  }
69
69
  function revolve(face, center = [0, 0, 0], direction = [0, 0, 1], angle = 360) {
70
70
  if (shapeTypes.getKernel().isNull(face.wrapped)) {
71
- return errors.err(errors.validationError(errors.BrepErrorCode.NULL_SHAPE_INPUT, "revolve: face is a null shape"));
71
+ return result.err(result.validationError(result.BrepErrorCode.NULL_SHAPE_INPUT, "revolve: face is a null shape"));
72
72
  }
73
73
  const kernel = shapeTypes.getKernel();
74
74
  const shape = kernel.revolveVec(face.wrapped, [...center], [...direction], angle);
75
- const result = shapeTypes.castShape(shape);
76
- if (!shapeTypes.isShape3D(result)) {
77
- return errors.err(errors.typeCastError("REVOLUTION_NOT_3D", "Revolution did not produce a 3D shape"));
75
+ const result$1 = shapeTypes.castShape(shape);
76
+ if (!shapeTypes.isShape3D(result$1)) {
77
+ return result.err(result.typeCastError("REVOLUTION_NOT_3D", "Revolution did not produce a 3D shape"));
78
78
  }
79
- return errors.ok(result);
79
+ return result.ok(result$1);
80
80
  }
81
81
  function sweep(wire, spine, config = {}, shellMode = false) {
82
82
  if (config.mode === "simple" && !shellMode) {
@@ -84,9 +84,9 @@ function sweep(wire, spine, config = {}, shellMode = false) {
84
84
  const resultOc = kernel2.simplePipe(wire.wrapped, spine.wrapped);
85
85
  const shape2 = shapeTypes.castShape(resultOc);
86
86
  if (!shapeTypes.isShape3D(shape2)) {
87
- return errors.err(errors.typeCastError("SWEEP_NOT_3D", "Simple pipe did not produce a 3D shape"));
87
+ return result.err(result.typeCastError("SWEEP_NOT_3D", "Simple pipe did not produce a 3D shape"));
88
88
  }
89
- return errors.ok(shape2);
89
+ return result.ok(shape2);
90
90
  }
91
91
  const {
92
92
  frenet = false,
@@ -104,7 +104,7 @@ function sweep(wire, spine, config = {}, shellMode = false) {
104
104
  } = config;
105
105
  const kernel = shapeTypes.getKernel();
106
106
  const withCorrection = transitionMode === "round" ? true : !!forceProfileSpineOthogonality;
107
- const result = kernel.sweepPipeShell(wire.wrapped, spine.wrapped, {
107
+ const result$1 = kernel.sweepPipeShell(wire.wrapped, spine.wrapped, {
108
108
  transitionMode,
109
109
  contact: !!withContact,
110
110
  correction: withCorrection,
@@ -119,26 +119,26 @@ function sweep(wire, spine, config = {}, shellMode = false) {
119
119
  maxDegree,
120
120
  maxSegments
121
121
  });
122
- if (shellMode && typeof result === "object" && "firstShape" in result) {
123
- const shape2 = shapeTypes.castShape(result.shape);
122
+ if (shellMode && typeof result$1 === "object" && "firstShape" in result$1) {
123
+ const shape2 = shapeTypes.castShape(result$1.shape);
124
124
  if (!shapeTypes.isShape3D(shape2)) {
125
- return errors.err(errors.typeCastError("SWEEP_NOT_3D", "Sweep did not produce a 3D shape"));
125
+ return result.err(result.typeCastError("SWEEP_NOT_3D", "Sweep did not produce a 3D shape"));
126
126
  }
127
- const startWire = shapeTypes.castShape(result.firstShape);
128
- const endWire = shapeTypes.castShape(result.lastShape);
127
+ const startWire = shapeTypes.castShape(result$1.firstShape);
128
+ const endWire = shapeTypes.castShape(result$1.lastShape);
129
129
  if (!shapeTypes.isWire(startWire)) {
130
- return errors.err(errors.typeCastError("SWEEP_START_NOT_WIRE", "Sweep did not produce a start Wire"));
130
+ return result.err(result.typeCastError("SWEEP_START_NOT_WIRE", "Sweep did not produce a start Wire"));
131
131
  }
132
132
  if (!shapeTypes.isWire(endWire)) {
133
- return errors.err(errors.typeCastError("SWEEP_END_NOT_WIRE", "Sweep did not produce an end Wire"));
133
+ return result.err(result.typeCastError("SWEEP_END_NOT_WIRE", "Sweep did not produce an end Wire"));
134
134
  }
135
- return errors.ok([shape2, startWire, endWire]);
135
+ return result.ok([shape2, startWire, endWire]);
136
136
  }
137
- const shape = shapeTypes.castShape(result);
137
+ const shape = shapeTypes.castShape(result$1);
138
138
  if (!shapeTypes.isShape3D(shape)) {
139
- return errors.err(errors.typeCastError("SWEEP_NOT_3D", "Sweep did not produce a 3D shape"));
139
+ return result.err(result.typeCastError("SWEEP_NOT_3D", "Sweep did not produce a 3D shape"));
140
140
  }
141
- return errors.ok(shape);
141
+ return result.ok(shape);
142
142
  }
143
143
  function supportExtrude(wire, center, normal, support) {
144
144
  const endPoint = vecOps.vecAdd(center, normal);
@@ -148,30 +148,30 @@ function supportExtrude(wire, center, normal, support) {
148
148
  function complexExtrude(wire, center, normal, profileShape, shellMode = false) {
149
149
  const extrusionLength = vecOps.vecLength(normal);
150
150
  if (extrusionLength === 0) {
151
- return errors.err(
152
- errors.validationError("ZERO_LENGTH_EXTRUSION", "Extrusion vector cannot have zero length")
151
+ return result.err(
152
+ result.validationError("ZERO_LENGTH_EXTRUSION", "Extrusion vector cannot have zero length")
153
153
  );
154
154
  }
155
155
  const endPoint = vecOps.vecAdd(center, normal);
156
156
  const spine = makeSpineWire(center, endPoint);
157
- const law = profileShape ? errors.unwrap(loft.buildLawFromProfile(extrusionLength, profileShape)) : null;
157
+ const law = profileShape ? result.unwrap(loft.buildLawFromProfile(extrusionLength, profileShape)) : null;
158
158
  return sweep(wire, spine, { law }, shellMode);
159
159
  }
160
160
  function twistExtrude(wire, angleDegrees, center, normal, profileShape, shellMode = false) {
161
161
  if (angleDegrees === 0) {
162
- return errors.err(errors.validationError("ZERO_TWIST_ANGLE", "Twist angle cannot be zero"));
162
+ return result.err(result.validationError("ZERO_TWIST_ANGLE", "Twist angle cannot be zero"));
163
163
  }
164
164
  const extrusionLength = vecOps.vecLength(normal);
165
165
  if (extrusionLength === 0) {
166
- return errors.err(
167
- errors.validationError("ZERO_LENGTH_EXTRUSION", "Extrusion vector cannot have zero length")
166
+ return result.err(
167
+ result.validationError("ZERO_LENGTH_EXTRUSION", "Extrusion vector cannot have zero length")
168
168
  );
169
169
  }
170
170
  const endPoint = vecOps.vecAdd(center, normal);
171
171
  const spine = makeSpineWire(center, endPoint);
172
172
  const pitch = 360 / angleDegrees * extrusionLength;
173
173
  const auxiliarySpine = makeHelixWire(pitch, extrusionLength, 1, center, normal);
174
- const law = profileShape ? errors.unwrap(loft.buildLawFromProfile(extrusionLength, profileShape)) : null;
174
+ const law = profileShape ? result.unwrap(loft.buildLawFromProfile(extrusionLength, profileShape)) : null;
175
175
  return sweep(wire, spine, { auxiliarySpine, law }, shellMode);
176
176
  }
177
177
  function exportAssemblySTEP(shapes = [], { unit, modelUnit } = {}) {
@@ -198,19 +198,19 @@ function exportAssemblySTEP(shapes = [], { unit, modelUnit } = {}) {
198
198
  try {
199
199
  const stepString = kernel.writeXCAFToSTEP(doc, { unit, modelUnit });
200
200
  if (!stepString) {
201
- return errors.err(errors.ioError("STEP_EXPORT_FAILED", "Failed to write STEP file"));
201
+ return result.err(result.ioError("STEP_EXPORT_FAILED", "Failed to write STEP file"));
202
202
  }
203
- return errors.ok(new Blob([stepString], { type: "application/STEP" }));
203
+ return result.ok(new Blob([stepString], { type: "application/STEP" }));
204
204
  } finally {
205
205
  doc.delete();
206
206
  }
207
207
  }
208
208
  function linearPattern(shape, direction, count, spacing, options) {
209
209
  if (count < 1)
210
- return errors.err(errors.validationError("PATTERN_INVALID_COUNT", "Pattern count must be at least 1"));
211
- if (count === 1) return errors.ok(shape);
210
+ return result.err(result.validationError("PATTERN_INVALID_COUNT", "Pattern count must be at least 1"));
211
+ if (count === 1) return result.ok(shape);
212
212
  if (vecOps.vecIsZero(direction))
213
- return errors.err(errors.validationError("PATTERN_ZERO_DIRECTION", "Pattern direction cannot be zero"));
213
+ return result.err(result.validationError("PATTERN_ZERO_DIRECTION", "Pattern direction cannot be zero"));
214
214
  const dir = vecOps.vecNormalize(direction);
215
215
  const ocShapes = shapeTypes.getKernel().linearPattern(shape.wrapped, [...dir], spacing, count);
216
216
  const copies = ocShapes.map((s) => shapeTypes.castShape(s));
@@ -218,10 +218,10 @@ function linearPattern(shape, direction, count, spacing, options) {
218
218
  }
219
219
  function circularPattern(shape, axis, count, fullAngle = 360, center = [0, 0, 0], options) {
220
220
  if (count < 1)
221
- return errors.err(errors.validationError("PATTERN_INVALID_COUNT", "Pattern count must be at least 1"));
222
- if (count === 1) return errors.ok(shape);
221
+ return result.err(result.validationError("PATTERN_INVALID_COUNT", "Pattern count must be at least 1"));
222
+ if (count === 1) return result.ok(shape);
223
223
  if (vecOps.vecIsZero(axis))
224
- return errors.err(errors.validationError("PATTERN_ZERO_AXIS", "Pattern axis cannot be zero"));
224
+ return result.err(result.validationError("PATTERN_ZERO_AXIS", "Pattern axis cannot be zero"));
225
225
  const angleStep = fullAngle / count;
226
226
  const ocShapes = shapeTypes.getKernel().circularPattern(
227
227
  shape.wrapped,
@@ -235,12 +235,12 @@ function circularPattern(shape, axis, count, fullAngle = 360, center = [0, 0, 0]
235
235
  }
236
236
  function gridPattern(shape, directionX, directionY, countX, countY, spacingX, spacingY, options) {
237
237
  if (countX < 1 || countY < 1)
238
- return errors.err(errors.validationError("PATTERN_INVALID_COUNT", "Grid pattern counts must be at least 1"));
239
- if (countX === 1 && countY === 1) return errors.ok(shape);
238
+ return result.err(result.validationError("PATTERN_INVALID_COUNT", "Grid pattern counts must be at least 1"));
239
+ if (countX === 1 && countY === 1) return result.ok(shape);
240
240
  if (vecOps.vecIsZero(directionX))
241
- return errors.err(errors.validationError("PATTERN_ZERO_DIRECTION", "Grid directionX cannot be zero"));
241
+ return result.err(result.validationError("PATTERN_ZERO_DIRECTION", "Grid directionX cannot be zero"));
242
242
  if (vecOps.vecIsZero(directionY))
243
- return errors.err(errors.validationError("PATTERN_ZERO_DIRECTION", "Grid directionY cannot be zero"));
243
+ return result.err(result.validationError("PATTERN_ZERO_DIRECTION", "Grid directionY cannot be zero"));
244
244
  const kernel = shapeTypes.getKernel();
245
245
  const dirX = vecOps.vecNormalize(directionX);
246
246
  const dirY = vecOps.vecNormalize(directionY);
@@ -254,7 +254,7 @@ function gridPattern(shape, directionX, directionY, countX, countY, spacingX, sp
254
254
  countX,
255
255
  countY
256
256
  );
257
- return errors.ok(shapeTypes.castShape(compound));
257
+ return result.ok(shapeTypes.castShape(compound));
258
258
  }
259
259
  const rowResult = linearPattern(shape, directionX, countX, spacingX, options);
260
260
  if (!rowResult.ok) return rowResult;
@@ -378,14 +378,14 @@ function replayHistory(history, registry) {
378
378
  for (const step of history.steps) {
379
379
  const fn = registry.operations.get(step.type);
380
380
  if (!fn) {
381
- return errors.err(errors.computationError("REPLAY_UNKNOWN_OP", `Unknown operation type: ${step.type}`));
381
+ return result.err(result.computationError("REPLAY_UNKNOWN_OP", `Unknown operation type: ${step.type}`));
382
382
  }
383
383
  const inputs = [];
384
384
  for (const inputId of step.inputIds) {
385
385
  const shape = current.shapes.get(inputId);
386
386
  if (!shape) {
387
- return errors.err(
388
- errors.computationError(
387
+ return result.err(
388
+ result.computationError(
389
389
  "REPLAY_MISSING_INPUT",
390
390
  `Missing input shape: ${inputId} for step ${step.id}`
391
391
  )
@@ -407,20 +407,20 @@ function replayHistory(history, registry) {
407
407
  output
408
408
  );
409
409
  } catch (e) {
410
- return errors.err(
411
- errors.computationError(
410
+ return result.err(
411
+ result.computationError(
412
412
  "REPLAY_STEP_FAILED",
413
413
  `Step ${step.id} (${step.type}) failed: ${e instanceof Error ? e.message : String(e)}`
414
414
  )
415
415
  );
416
416
  }
417
417
  }
418
- return errors.ok(current);
418
+ return result.ok(current);
419
419
  }
420
420
  function replayFrom(history, stepId, registry) {
421
421
  const idx = history.steps.findIndex((s) => s.id === stepId);
422
422
  if (idx === -1) {
423
- return errors.err(errors.computationError("REPLAY_STEP_NOT_FOUND", `Step not found: ${stepId}`));
423
+ return result.err(result.computationError("REPLAY_STEP_NOT_FOUND", `Step not found: ${stepId}`));
424
424
  }
425
425
  const shapesMap = new Map(history.shapes);
426
426
  for (let i = idx; i < history.steps.length; i++) {
@@ -438,14 +438,14 @@ function replayFrom(history, stepId, registry) {
438
438
  if (!step) continue;
439
439
  const fn = registry.operations.get(step.type);
440
440
  if (!fn) {
441
- return errors.err(errors.computationError("REPLAY_UNKNOWN_OP", `Unknown operation type: ${step.type}`));
441
+ return result.err(result.computationError("REPLAY_UNKNOWN_OP", `Unknown operation type: ${step.type}`));
442
442
  }
443
443
  const inputs = [];
444
444
  for (const inputId of step.inputIds) {
445
445
  const shape = current.shapes.get(inputId);
446
446
  if (!shape) {
447
- return errors.err(
448
- errors.computationError(
447
+ return result.err(
448
+ result.computationError(
449
449
  "REPLAY_MISSING_INPUT",
450
450
  `Missing input shape: ${inputId} for step ${step.id}`
451
451
  )
@@ -467,20 +467,20 @@ function replayFrom(history, stepId, registry) {
467
467
  output
468
468
  );
469
469
  } catch (e) {
470
- return errors.err(
471
- errors.computationError(
470
+ return result.err(
471
+ result.computationError(
472
472
  "REPLAY_STEP_FAILED",
473
473
  `Step ${step.id} (${step.type}) failed: ${e instanceof Error ? e.message : String(e)}`
474
474
  )
475
475
  );
476
476
  }
477
477
  }
478
- return errors.ok(current);
478
+ return result.ok(current);
479
479
  }
480
480
  function modifyStep(history, stepId, newParams, registry) {
481
481
  const idx = history.steps.findIndex((s) => s.id === stepId);
482
482
  if (idx === -1) {
483
- return errors.err(errors.computationError("MODIFY_STEP_NOT_FOUND", `Step not found: ${stepId}`));
483
+ return result.err(result.computationError("MODIFY_STEP_NOT_FOUND", `Step not found: ${stepId}`));
484
484
  }
485
485
  const modifiedSteps = history.steps.map(
486
486
  (s) => s.id === stepId ? { ...s, parameters: newParams } : s
@@ -494,40 +494,40 @@ function serializeHistory(history) {
494
494
  try {
495
495
  shapes[id] = shapeFns.toBREP(shape);
496
496
  } catch (e) {
497
- return errors.err(
498
- errors.computationError(
497
+ return result.err(
498
+ result.computationError(
499
499
  "SERIALIZE_SHAPE_FAILED",
500
500
  `Failed to serialize shape "${id}": ${e instanceof Error ? e.message : String(e)}`
501
501
  )
502
502
  );
503
503
  }
504
504
  }
505
- return errors.ok({ steps: history.steps, shapes });
505
+ return result.ok({ steps: history.steps, shapes });
506
506
  }
507
507
  function deserializeHistory(data) {
508
508
  const shapes = /* @__PURE__ */ new Map();
509
509
  for (const [id, brep] of Object.entries(data.shapes)) {
510
510
  try {
511
- const result = faceFns.fromBREP(brep);
512
- if (!result.ok) {
513
- return errors.err(
514
- errors.computationError(
511
+ const result$1 = faceFns.fromBREP(brep);
512
+ if (!result$1.ok) {
513
+ return result.err(
514
+ result.computationError(
515
515
  "DESERIALIZE_SHAPE_FAILED",
516
- `Failed to deserialize shape "${id}": ${result.error.message}`
516
+ `Failed to deserialize shape "${id}": ${result$1.error.message}`
517
517
  )
518
518
  );
519
519
  }
520
- shapes.set(id, result.value);
520
+ shapes.set(id, result$1.value);
521
521
  } catch (e) {
522
- return errors.err(
523
- errors.computationError(
522
+ return result.err(
523
+ result.computationError(
524
524
  "DESERIALIZE_SHAPE_FAILED",
525
525
  `Failed to deserialize shape "${id}": ${e instanceof Error ? e.message : String(e)}`
526
526
  )
527
527
  );
528
528
  }
529
529
  }
530
- return errors.ok({ steps: data.steps, shapes });
530
+ return result.ok({ steps: data.steps, shapes });
531
531
  }
532
532
  exports.addChild = addChild;
533
533
  exports.addStep = addStep;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const operations = require("./operations-DLFzmdFX.cjs");
4
- const loft = require("./loft-DR1UN5uN.cjs");
3
+ const operations = require("./operations-CYpmLSC4.cjs");
4
+ const loft = require("./loft-hp3pc1M7.cjs");
5
5
  exports.addChild = operations.addChild;
6
6
  exports.addStep = operations.addStep;
7
7
  exports.circularPattern = operations.circularPattern;
@@ -1,5 +1,5 @@
1
- import { a, b, c, d, f, g, h, i, j, k, n, o, p, q, H, l, t, u, v, x, y, z, B, C, D, s, E, F, G, w } from "./operations-Dcz6YlOt.js";
2
- import { b as b2, g as g2, l as l2, r } from "./loft-BcZUCGKi.js";
1
+ import { a, b, c, d, f, g, h, i, j, k, n, o, p, q, H, l, t, u, v, x, y, z, B, C, D, s, E, F, G, w } from "./operations-BfbkK6DU.js";
2
+ import { b as b2, g as g2, l as l2, r } from "./loft-Bhw-FMoL.js";
3
3
  export {
4
4
  a as addChild,
5
5
  b as addStep,
package/dist/query.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const helpers = require("./helpers-6kn30cSD.cjs");
4
- const cornerFinder = require("./cornerFinder-3zfbQvXg.cjs");
3
+ const helpers = require("./helpers-C8NoT0Wu.cjs");
4
+ const cornerFinder = require("./cornerFinder-ZmOyOOsh.cjs");
5
5
  const shapeTypes = require("./shapeTypes-7xEam9Ri.cjs");
6
6
  const vecOps = require("./vecOps-CjRL1jau.cjs");
7
- const curveFns = require("./curveFns-Ch87sD5O.cjs");
7
+ const curveFns = require("./curveFns-BZngcnQ1.cjs");
8
8
  function edgeDirectionFilter(dir, angle) {
9
9
  const d = vecOps.vecNormalize(helpers.resolveDir(dir));
10
10
  return (edge) => {
package/dist/query.js CHANGED
@@ -1,9 +1,9 @@
1
- import { l as createTypedFinder, n as distanceFromPointFilter, o as resolveDir } from "./helpers-C9KvE1RW.js";
2
- import { m, g } from "./helpers-C9KvE1RW.js";
3
- import { c } from "./cornerFinder-BV-l1BCw.js";
1
+ import { l as createTypedFinder, n as distanceFromPointFilter, o as resolveDir } from "./helpers-X0juxnwj.js";
2
+ import { m, g } from "./helpers-X0juxnwj.js";
3
+ import { c } from "./cornerFinder-Ckz-mPHE.js";
4
4
  import { B as getKernel } from "./shapeTypes-CpSaBLDv.js";
5
5
  import { j as vecNormalize, d as vecDot, D as DEG2RAD } from "./vecOps-ZDdZWbwT.js";
6
- import { l as getCurveType, f as curveLength } from "./curveFns-CloOqAQ_.js";
6
+ import { l as getCurveType, f as curveLength } from "./curveFns-mROFhiuG.js";
7
7
  function edgeDirectionFilter(dir, angle) {
8
8
  const d = vecNormalize(resolveDir(dir));
9
9
  return (edge) => {
@@ -117,6 +117,17 @@ function pipeline(input) {
117
117
  }
118
118
  return makePipeline(initial);
119
119
  }
120
+ class BrepBugError extends Error {
121
+ location;
122
+ constructor(location, message) {
123
+ super(`Bug in ${location}: ${message}`);
124
+ this.name = "BrepBugError";
125
+ this.location = location;
126
+ }
127
+ }
128
+ function bug(location, message) {
129
+ throw new BrepBugError(location, message);
130
+ }
120
131
  const BrepErrorCode = {
121
132
  // kernel operation errors
122
133
  BSPLINE_FAILED: "BSPLINE_FAILED",
@@ -320,41 +331,50 @@ function translateKernelError(kernelMessage) {
320
331
  }
321
332
  return kernelMessage;
322
333
  }
334
+ function safeIndex(arr, index, context) {
335
+ if (index < 0 || index >= arr.length) {
336
+ bug(context ?? "safeIndex", `Index ${index} is out of bounds (array length ${arr.length})`);
337
+ }
338
+ return arr[index];
339
+ }
323
340
  export {
324
- all as A,
325
- BrepErrorCode as B,
326
- fromNullable as C,
327
- or as D,
328
- orElse as E,
329
- pipeline as F,
330
- tap as G,
331
- tapErr as H,
332
- zip as I,
341
+ BrepErrorCode as A,
342
+ BrepBugError as B,
343
+ safeIndex as C,
344
+ translateKernelError as D,
345
+ all as E,
346
+ fromNullable as F,
347
+ or as G,
348
+ orElse as H,
349
+ pipeline as I,
350
+ tap as J,
351
+ tapErr as K,
352
+ zip as L,
333
353
  OK as O,
334
354
  andThen as a,
335
- computationError as b,
355
+ bug as b,
336
356
  collect as c,
337
- isErr as d,
357
+ computationError as d,
338
358
  err as e,
339
359
  flatMap as f,
340
- isOk as g,
341
- mapErr as h,
360
+ isErr as g,
361
+ isOk as h,
342
362
  ioError as i,
343
- match as j,
363
+ mapErr as j,
344
364
  kernelError as k,
345
- moduleInitError as l,
365
+ match as l,
346
366
  map as m,
347
- tryCatchAsync as n,
367
+ moduleInitError as n,
348
368
  ok as o,
349
- typeCastError as p,
369
+ tryCatchAsync as p,
350
370
  queryError as q,
351
- unwrap as r,
371
+ typeCastError as r,
352
372
  sketcherStateError as s,
353
373
  tryCatch as t,
354
374
  unsupportedError as u,
355
- unwrapErr as v,
356
- unwrapOr as w,
357
- unwrapOrElse as x,
358
- validationError as y,
359
- translateKernelError as z
375
+ unwrap as v,
376
+ unwrapErr as w,
377
+ unwrapOr as x,
378
+ unwrapOrElse as y,
379
+ validationError as z
360
380
  };
@@ -118,6 +118,17 @@ function pipeline(input) {
118
118
  }
119
119
  return makePipeline(initial);
120
120
  }
121
+ class BrepBugError extends Error {
122
+ location;
123
+ constructor(location, message) {
124
+ super(`Bug in ${location}: ${message}`);
125
+ this.name = "BrepBugError";
126
+ this.location = location;
127
+ }
128
+ }
129
+ function bug(location, message) {
130
+ throw new BrepBugError(location, message);
131
+ }
121
132
  const BrepErrorCode = {
122
133
  // kernel operation errors
123
134
  BSPLINE_FAILED: "BSPLINE_FAILED",
@@ -321,10 +332,18 @@ function translateKernelError(kernelMessage) {
321
332
  }
322
333
  return kernelMessage;
323
334
  }
335
+ function safeIndex(arr, index, context) {
336
+ if (index < 0 || index >= arr.length) {
337
+ bug(context ?? "safeIndex", `Index ${index} is out of bounds (array length ${arr.length})`);
338
+ }
339
+ return arr[index];
340
+ }
341
+ exports.BrepBugError = BrepBugError;
324
342
  exports.BrepErrorCode = BrepErrorCode;
325
343
  exports.OK = OK;
326
344
  exports.all = all;
327
345
  exports.andThen = andThen;
346
+ exports.bug = bug;
328
347
  exports.collect = collect;
329
348
  exports.computationError = computationError;
330
349
  exports.err = err;
@@ -343,6 +362,7 @@ exports.or = or;
343
362
  exports.orElse = orElse;
344
363
  exports.pipeline = pipeline;
345
364
  exports.queryError = queryError;
365
+ exports.safeIndex = safeIndex;
346
366
  exports.sketcherStateError = sketcherStateError;
347
367
  exports.tap = tap;
348
368
  exports.tapErr = tapErr;
package/dist/result.cjs CHANGED
@@ -1,43 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const errors = require("./errors-9fDehDNc.cjs");
4
- class BrepBugError extends Error {
5
- location;
6
- constructor(location, message) {
7
- super(`Bug in ${location}: ${message}`);
8
- this.name = "BrepBugError";
9
- this.location = location;
10
- }
11
- }
12
- function bug(location, message) {
13
- throw new BrepBugError(location, message);
14
- }
15
- exports.BrepErrorCode = errors.BrepErrorCode;
16
- exports.OK = errors.OK;
17
- exports.andThen = errors.andThen;
18
- exports.collect = errors.collect;
19
- exports.computationError = errors.computationError;
20
- exports.err = errors.err;
21
- exports.flatMap = errors.flatMap;
22
- exports.ioError = errors.ioError;
23
- exports.isErr = errors.isErr;
24
- exports.isOk = errors.isOk;
25
- exports.kernelError = errors.kernelError;
26
- exports.map = errors.map;
27
- exports.mapErr = errors.mapErr;
28
- exports.match = errors.match;
29
- exports.moduleInitError = errors.moduleInitError;
30
- exports.ok = errors.ok;
31
- exports.pipeline = errors.pipeline;
32
- exports.queryError = errors.queryError;
33
- exports.sketcherStateError = errors.sketcherStateError;
34
- exports.tryCatch = errors.tryCatch;
35
- exports.tryCatchAsync = errors.tryCatchAsync;
36
- exports.typeCastError = errors.typeCastError;
37
- exports.unwrap = errors.unwrap;
38
- exports.unwrapErr = errors.unwrapErr;
39
- exports.unwrapOr = errors.unwrapOr;
40
- exports.unwrapOrElse = errors.unwrapOrElse;
41
- exports.validationError = errors.validationError;
42
- exports.BrepBugError = BrepBugError;
43
- exports.bug = bug;
3
+ const result = require("./result-fAX0OZzI.cjs");
4
+ exports.BrepBugError = result.BrepBugError;
5
+ exports.BrepErrorCode = result.BrepErrorCode;
6
+ exports.OK = result.OK;
7
+ exports.andThen = result.andThen;
8
+ exports.bug = result.bug;
9
+ exports.collect = result.collect;
10
+ exports.computationError = result.computationError;
11
+ exports.err = result.err;
12
+ exports.flatMap = result.flatMap;
13
+ exports.ioError = result.ioError;
14
+ exports.isErr = result.isErr;
15
+ exports.isOk = result.isOk;
16
+ exports.kernelError = result.kernelError;
17
+ exports.map = result.map;
18
+ exports.mapErr = result.mapErr;
19
+ exports.match = result.match;
20
+ exports.moduleInitError = result.moduleInitError;
21
+ exports.ok = result.ok;
22
+ exports.pipeline = result.pipeline;
23
+ exports.queryError = result.queryError;
24
+ exports.sketcherStateError = result.sketcherStateError;
25
+ exports.tryCatch = result.tryCatch;
26
+ exports.tryCatchAsync = result.tryCatchAsync;
27
+ exports.typeCastError = result.typeCastError;
28
+ exports.unwrap = result.unwrap;
29
+ exports.unwrapErr = result.unwrapErr;
30
+ exports.unwrapOr = result.unwrapOr;
31
+ exports.unwrapOrElse = result.unwrapOrElse;
32
+ exports.validationError = result.validationError;