brepjs 11.0.1 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/2d/lib/definitions.d.ts +2 -1
  2. package/dist/2d/lib/definitions.d.ts.map +1 -1
  3. package/dist/2d/lib/precision.d.ts +4 -7
  4. package/dist/2d/lib/precision.d.ts.map +1 -1
  5. package/dist/2d/lib/vectorOperations.d.ts +1 -37
  6. package/dist/2d/lib/vectorOperations.d.ts.map +1 -1
  7. package/dist/2d.cjs +2 -2
  8. package/dist/2d.js +3 -3
  9. package/dist/{Blueprint-BbgdNjMG.cjs → Blueprint-CFdLzoy5.cjs} +16 -8
  10. package/dist/{Blueprint-SMLvu1pH.js → Blueprint-DQ18yiAI.js} +21 -13
  11. package/dist/{boolean2D-DiHJyuu4.cjs → boolean2D-C5tjWX5T.cjs} +18 -18
  12. package/dist/{boolean2D-BGxBWwCm.js → boolean2D-Dq3HF-Pd.js} +9 -9
  13. package/dist/{booleanFns-Bl8hInM_.js → booleanFns-DdU6eLxI.js} +5 -5
  14. package/dist/{booleanFns-BaMEij5u.cjs → booleanFns-PbcD1St_.cjs} +5 -5
  15. package/dist/brepjs.cjs +24 -20
  16. package/dist/brepjs.js +204 -200
  17. package/dist/core/errors.d.ts +4 -1
  18. package/dist/core/errors.d.ts.map +1 -1
  19. package/dist/core/kernelCall.d.ts.map +1 -1
  20. package/dist/core.cjs +4 -3
  21. package/dist/core.d.ts +1 -1
  22. package/dist/core.d.ts.map +1 -1
  23. package/dist/core.js +10 -9
  24. package/dist/{cornerFinder-CDkc5qfD.cjs → cornerFinder-BphV9OLn.cjs} +1 -1
  25. package/dist/{cornerFinder-C_rN-yag.js → cornerFinder-Dv3C7Yen.js} +1 -1
  26. package/dist/{curveFns-Dtaf2CvG.cjs → curveFns-CeHbFVDc.cjs} +2 -2
  27. package/dist/{curveFns-DeYQQ18o.js → curveFns-GOcBuoCc.js} +2 -2
  28. package/dist/{drawFns-CkFd3lT4.js → drawFns-7fN_tn1I.js} +13 -13
  29. package/dist/{drawFns-NsqGSBEK.cjs → drawFns-F5uDtd2v.cjs} +13 -13
  30. package/dist/{errors-DiTn5EoC.cjs → errors-9fDehDNc.cjs} +7 -1
  31. package/dist/{errors-lBwyc8YG.js → errors-B7kgv0cd.js} +21 -15
  32. package/dist/{faceFns-DVo4NiOl.cjs → faceFns-Bhlm333o.cjs} +2 -2
  33. package/dist/{faceFns-DZU8VAlq.js → faceFns-g5hzl_xe.js} +2 -2
  34. package/dist/{helpers-BOPjTzbq.cjs → helpers-D3jdmQoR.cjs} +9 -18
  35. package/dist/{helpers-D8jYqufG.js → helpers-Vqsg_fss.js} +8 -17
  36. package/dist/index.d.ts +1 -1
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/io.cjs +4 -4
  39. package/dist/io.js +4 -4
  40. package/dist/kernel/brepkit2d.d.ts +6 -0
  41. package/dist/kernel/brepkit2d.d.ts.map +1 -1
  42. package/dist/kernel/index.d.ts.map +1 -1
  43. package/dist/kernel/meshOps.d.ts +3 -18
  44. package/dist/kernel/meshOps.d.ts.map +1 -1
  45. package/dist/{loft-BpScchbu.cjs → loft-B3ZDn94G.cjs} +5 -5
  46. package/dist/{loft-BmO0VYht.js → loft-BGHICbBS.js} +5 -5
  47. package/dist/{measurement-Crexq3aQ.cjs → measurement--jEL3ePF.cjs} +2 -2
  48. package/dist/{measurement-CZzV1bmg.js → measurement-Ce4oE8Fg.js} +2 -2
  49. package/dist/measurement.cjs +1 -1
  50. package/dist/measurement.js +1 -1
  51. package/dist/{meshFns-DE8uUdKS.js → meshFns-bHjCcOZp.js} +3 -3
  52. package/dist/{meshFns-d6Ta_uov.cjs → meshFns-rTBykpgO.cjs} +3 -3
  53. package/dist/{operations-CGbdoQvO.cjs → operations-Cb4gWPwL.cjs} +6 -6
  54. package/dist/{operations-Qr5m0lUU.js → operations-D3BtYsAB.js} +6 -6
  55. package/dist/operations.cjs +2 -2
  56. package/dist/operations.js +2 -2
  57. package/dist/projection/cameraFns.d.ts.map +1 -1
  58. package/dist/query.cjs +4 -4
  59. package/dist/query.js +5 -5
  60. package/dist/result.cjs +1 -1
  61. package/dist/result.js +7 -7
  62. package/dist/{shapeFns-vrqpeRIf.cjs → shapeFns-BHSGfqFS.cjs} +3 -3
  63. package/dist/{shapeFns-BmOzkjTF.js → shapeFns-smSl7yhL.js} +3 -3
  64. package/dist/{shapeTypes-CHvr4HNj.cjs → shapeTypes-BzrjB5be.cjs} +4 -307
  65. package/dist/{shapeTypes-CGYrwYIi.js → shapeTypes-Py3LEyDe.js} +4 -307
  66. package/dist/sketching.cjs +2 -2
  67. package/dist/sketching.js +2 -2
  68. package/dist/{solidBuilders-Bo8N2UV1.cjs → solidBuilders-DINhvxLC.cjs} +3 -3
  69. package/dist/{solidBuilders-CDzxISP2.js → solidBuilders-Jh5Bnm02.js} +3 -3
  70. package/dist/{surfaceBuilders-DIPPckQg.cjs → surfaceBuilders-BCd-ugN2.cjs} +3 -3
  71. package/dist/{surfaceBuilders-CIEQ9j7C.js → surfaceBuilders-CD_9kc1m.js} +3 -3
  72. package/dist/{topology-DiWPQ0YS.cjs → topology-B15z3Ts4.cjs} +9 -9
  73. package/dist/{topology-9-u8A3nq.js → topology-DmQY6469.js} +9 -9
  74. package/dist/topology.cjs +6 -6
  75. package/dist/topology.js +6 -6
  76. package/dist/utils/vec2d.d.ts +55 -0
  77. package/dist/utils/vec2d.d.ts.map +1 -0
  78. package/dist/{vectors-DqQXtR8s.cjs → vectors-TlfO1hu2.cjs} +1 -1
  79. package/dist/{vectors-B8RRTytu.js → vectors-cec8p8NQ.js} +1 -1
  80. package/dist/vectors.cjs +1 -1
  81. package/dist/vectors.js +1 -1
  82. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
+ import { Point2D } from '../../utils/vec2d.js';
1
2
  /** A 2D point or vector represented as an `[x, y]` tuple. */
2
- export type Point2D = [number, number];
3
+ export type { Point2D } from '../../utils/vec2d.js';
3
4
  /** Type guard that checks whether a value is a `Point2D`. */
4
5
  export declare function isPoint2D(point: unknown): point is Point2D;
5
6
  /** A 2x2 matrix represented as two row tuples. */
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../../src/2d/lib/definitions.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEvC,6DAA6D;AAC7D,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAO1D;AAED,kDAAkD;AAClD,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE7D,+DAA+D;AAC/D,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,SAAS,CAYhE"}
1
+ {"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../../src/2d/lib/definitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,6DAA6D;AAC7D,YAAY,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,6DAA6D;AAC7D,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAO1D;AAED,kDAAkD;AAClD,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE7D,+DAA+D;AAC/D,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,SAAS,CAYhE"}
@@ -1,15 +1,12 @@
1
1
  /**
2
- * Shared precision constants for the 2D module.
2
+ * Shared precision constants for the 2D module — re-exports from Layer 0.
3
+ *
4
+ * ADR-0006: src/utils/vec2d.ts is the canonical source.
3
5
  *
4
6
  * Hierarchy (from tightest to loosest):
5
7
  * - PRECISION_INTERSECTION (1e-9): curve intersection, parameter lookups
6
8
  * - PRECISION_OFFSET (1e-8): offset operations (scaled ×10, ÷100, ×100 internally)
7
9
  * - PRECISION_POINT (1e-6): point-equality checks (default for samePoint)
8
10
  */
9
- /** Precision for curve intersection and parameter operations. */
10
- export declare const PRECISION_INTERSECTION = 1e-9;
11
- /** Base precision for offset operations — scaled internally for sub-tasks. */
12
- export declare const PRECISION_OFFSET = 1e-8;
13
- /** Default precision for point-equality comparisons. */
14
- export declare const PRECISION_POINT = 0.000001;
11
+ export { PRECISION_INTERSECTION, PRECISION_OFFSET, PRECISION_POINT } from '../../utils/vec2d.js';
15
12
  //# sourceMappingURL=precision.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"precision.d.ts","sourceRoot":"","sources":["../../../src/2d/lib/precision.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,iEAAiE;AACjE,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC,wDAAwD;AACxD,eAAO,MAAM,eAAe,WAAO,CAAC"}
1
+ {"version":3,"file":"precision.d.ts","sourceRoot":"","sources":["../../../src/2d/lib/precision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1,45 +1,9 @@
1
1
  import { Point2D } from './definitions.js';
2
- /** Test whether two 2D points are equal within a given precision. */
3
- export declare const samePoint: ([x0, y0]: Point2D, [x1, y1]: Point2D, precision?: number) => boolean;
4
- /** Add two 2D vectors component-wise. */
5
- export declare const add2d: ([x0, y0]: Point2D, [x1, y1]: Point2D) => Point2D;
6
- /** Subtract the second 2D vector from the first. */
7
- export declare const subtract2d: ([x0, y0]: Point2D, [x1, y1]: Point2D) => Point2D;
8
- /** Multiply a 2D vector by a scalar. */
9
- export declare const scalarMultiply2d: ([x0, y0]: Point2D, scalar: number) => Point2D;
10
- /** Compute the Euclidean distance between two 2D points (defaults to distance from origin). */
11
- export declare const distance2d: ([x0, y0]: Point2D, [x1, y1]?: Point2D) => number;
12
- /** Compute the squared Euclidean distance between two 2D points (avoids a sqrt). */
13
- export declare const squareDistance2d: ([x0, y0]: Point2D, [x1, y1]?: Point2D) => number;
14
- /** Compute the 2D cross product (z-component of the 3D cross product). */
15
- export declare function crossProduct2d([x0, y0]: Point2D, [x1, y1]: Point2D): number;
16
- /** Compute the dot product of two 2D vectors. */
17
- export declare function dotProduct2d([x0, y0]: Point2D, [x1, y1]: Point2D): number;
18
- /** Compute the signed angle (in radians) between two 2D vectors. */
19
- export declare const angle2d: ([x0, y0]: Point2D, [x1, y1]?: Point2D) => number;
20
- /** Compute the polar angle (in radians) from the first point to the second. */
21
- export declare const polarAngle2d: ([x0, y0]: Point2D, [x1, y1]?: Point2D) => number;
2
+ export { samePoint, add2d, subtract2d, scalarMultiply2d, distance2d, squareDistance2d, crossProduct2d, dotProduct2d, angle2d, polarAngle2d, rotate2d, polarToCartesian, cartesianToPolar, } from '../../utils/vec2d.js';
22
3
  /**
23
4
  * Normalize a 2D vector to unit length.
24
5
  *
25
6
  * @throws When the vector has near-zero length.
26
7
  */
27
8
  export declare const normalize2d: ([x0, y0]: Point2D) => Point2D;
28
- /**
29
- * Rotate a 2D point around a center by a given angle (in radians).
30
- *
31
- * @example
32
- * ```ts
33
- * rotate2d([1, 0], Math.PI / 2); // approximately [0, 1]
34
- * ```
35
- */
36
- export declare const rotate2d: (point: Point2D, angle: number, center?: Point2D) => Point2D;
37
- /** Convert polar coordinates (r, theta) to a Cartesian Point2D. */
38
- export declare const polarToCartesian: (r: number, theta: number) => Point2D;
39
- /**
40
- * Convert a Cartesian Point2D to polar coordinates.
41
- *
42
- * @returns A tuple of `[radius, theta]`.
43
- */
44
- export declare const cartesianToPolar: ([x, y]: Point2D) => [number, number];
45
9
  //# sourceMappingURL=vectorOperations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vectorOperations.d.ts","sourceRoot":"","sources":["../../../src/2d/lib/vectorOperations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAIhD,qEAAqE;AACrE,eAAO,MAAM,SAAS,GACpB,UAAU,OAAO,EACjB,UAAU,OAAO,EACjB,kBAA2B,KAC1B,OAEF,CAAC;AAEF,yCAAyC;AACzC,eAAO,MAAM,KAAK,GAAI,UAAU,OAAO,EAAE,UAAU,OAAO,KAAG,OAE5D,CAAC;AAEF,oDAAoD;AACpD,eAAO,MAAM,UAAU,GAAI,UAAU,OAAO,EAAE,UAAU,OAAO,KAAG,OAEjE,CAAC;AAEF,wCAAwC;AACxC,eAAO,MAAM,gBAAgB,GAAI,UAAU,OAAO,EAAE,QAAQ,MAAM,KAAG,OAEpE,CAAC;AAEF,+FAA+F;AAC/F,eAAO,MAAM,UAAU,GAAI,UAAU,OAAO,EAAE,WAAU,OAAgB,KAAG,MAE1E,CAAC;AAEF,oFAAoF;AACpF,eAAO,MAAM,gBAAgB,GAAI,UAAU,OAAO,EAAE,WAAU,OAAgB,KAAG,MAEhF,CAAC;AAEF,0EAA0E;AAC1E,wBAAgB,cAAc,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,CAE3E;AAED,iDAAiD;AACjD,wBAAgB,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,CAEzE;AAED,oEAAoE;AACpE,eAAO,MAAM,OAAO,GAAI,UAAU,OAAO,EAAE,WAAU,OAAgB,KAAG,MAEvE,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,YAAY,GAAI,UAAU,OAAO,EAAE,WAAU,OAAgB,KAAG,MAE5E,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,OAAO,KAAG,OAM/C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,EAAE,OAAO,MAAM,EAAE,SAAQ,OAAgB,KAAG,OAclF,CAAC;AAEF,mEAAmE;AACnE,eAAO,MAAM,gBAAgB,GAAI,GAAG,MAAM,EAAE,OAAO,MAAM,KAAG,OAI3D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,OAAO,KAAG,CAAC,MAAM,EAAE,MAAM,CAKjE,CAAC"}
1
+ {"version":3,"file":"vectorOperations.d.ts","sourceRoot":"","sources":["../../../src/2d/lib/vectorOperations.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAIhD,OAAO,EACL,SAAS,EACT,KAAK,EACL,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAE9B;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,OAAO,KAAG,OAM/C,CAAC"}
package/dist/2d.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const Blueprint = require("./Blueprint-BbgdNjMG.cjs");
4
- const boolean2D = require("./boolean2D-DiHJyuu4.cjs");
3
+ const Blueprint = require("./Blueprint-CFdLzoy5.cjs");
4
+ const boolean2D = require("./boolean2D-C5tjWX5T.cjs");
5
5
  function reverseCurve(curve) {
6
6
  const cloned = curve.clone();
7
7
  cloned.reverse();
package/dist/2d.js CHANGED
@@ -1,6 +1,6 @@
1
- import { B as Blueprint } from "./Blueprint-SMLvu1pH.js";
2
- import { d, C } from "./Blueprint-SMLvu1pH.js";
3
- import { e, C as C2, f, l, g, n, k, q, o, p, r } from "./boolean2D-BGxBWwCm.js";
1
+ import { B as Blueprint } from "./Blueprint-DQ18yiAI.js";
2
+ import { d, C } from "./Blueprint-DQ18yiAI.js";
3
+ import { e, C as C2, f, l, g, n, k, q, o, p, r } from "./boolean2D-Dq3HF-Pd.js";
4
4
  function reverseCurve(curve) {
5
5
  const cloned = curve.clone();
6
6
  cloned.reverse();
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
- const vectors = require("./vectors-DqQXtR8s.cjs");
2
+ const vectors = require("./vectors-TlfO1hu2.cjs");
3
3
  const types = require("./types-CA_xrgDq.cjs");
4
- const shapeTypes = require("./shapeTypes-CHvr4HNj.cjs");
5
- const faceFns = require("./faceFns-DVo4NiOl.cjs");
6
- const curveFns = require("./curveFns-Dtaf2CvG.cjs");
7
- const errors = require("./errors-DiTn5EoC.cjs");
8
- const helpers = require("./helpers-BOPjTzbq.cjs");
4
+ const shapeTypes = require("./shapeTypes-BzrjB5be.cjs");
5
+ const faceFns = require("./faceFns-Bhlm333o.cjs");
6
+ const curveFns = require("./curveFns-CeHbFVDc.cjs");
7
+ const errors = require("./errors-9fDehDNc.cjs");
8
+ const helpers = require("./helpers-D3jdmQoR.cjs");
9
9
  const vecOps = require("./vecOps-CjRL1jau.cjs");
10
- const surfaceBuilders = require("./surfaceBuilders-DIPPckQg.cjs");
10
+ const surfaceBuilders = require("./surfaceBuilders-BCd-ugN2.cjs");
11
11
  const result = require("./result.cjs");
12
12
  function makePlane(plane, origin) {
13
13
  if (plane && typeof plane !== "string") {
@@ -139,6 +139,13 @@ class BoundingBox2d {
139
139
  return !shapeTypes.getKernel2D().isBBox2dOutPoint(this.wrapped, other[0], other[1]);
140
140
  }
141
141
  }
142
+ const normalize2d = ([x0, y0]) => {
143
+ const l = helpers.distance2d([x0, y0]);
144
+ if (l < 1e-12) {
145
+ result.bug("normalize2d", "Cannot normalize zero-length vector");
146
+ }
147
+ return [x0 / l, y0 / l];
148
+ };
142
149
  function deserializeCurve2D(data) {
143
150
  return new Curve2D(shapeTypes.getKernel().deserializeCurve2d(data));
144
151
  }
@@ -504,7 +511,7 @@ function make2dInerpolatedBSplineCurve(points, {
504
511
  const make2dArcFromCenter = (startPoint, endPoint, center, longArc = false) => {
505
512
  const midChord = helpers.scalarMultiply2d(helpers.add2d(startPoint, endPoint), 0.5);
506
513
  const orientedRadius = helpers.distance2d(center, startPoint) * (longArc ? -1 : 1);
507
- const midChordDir = helpers.normalize2d(helpers.subtract2d(midChord, center));
514
+ const midChordDir = normalize2d(helpers.subtract2d(midChord, center));
508
515
  return make2dThreePointArc(
509
516
  startPoint,
510
517
  helpers.add2d(helpers.scalarMultiply2d(midChordDir, orientedRadius), center),
@@ -991,5 +998,6 @@ exports.make2dTangentArc = make2dTangentArc;
991
998
  exports.make2dThreePointArc = make2dThreePointArc;
992
999
  exports.makePlane = makePlane;
993
1000
  exports.mirror = mirror;
1001
+ exports.normalize2d = normalize2d;
994
1002
  exports.removeDuplicatePoints = removeDuplicatePoints;
995
1003
  exports.viewbox = viewbox;
@@ -1,12 +1,12 @@
1
- import { r as resolvePlane } from "./vectors-B8RRTytu.js";
1
+ import { r as resolvePlane } from "./vectors-cec8p8NQ.js";
2
2
  import { a as toVec3 } from "./types-CWDdqcrq.js";
3
- import { B as getKernel, J as getKernel2D, K as registerForCleanup, L as unregisterFromCleanup, H as createEdge, G as createWire } from "./shapeTypes-CGYrwYIi.js";
4
- import { u as uvBounds, f as faceGeomType, e as faceCenter, h as uvCoordinates, c as cast } from "./faceFns-DZU8VAlq.js";
5
- import { g as getOrientation } from "./curveFns-DeYQQ18o.js";
6
- import { o as ok, e as err, b as computationError, u as unwrap, x as validationError } from "./errors-lBwyc8YG.js";
7
- import { d as distance2d, s as samePoint, b as scalarMultiply2d, c as add2d, n as normalize2d, e as subtract2d, g as getSingleFace } from "./helpers-D8jYqufG.js";
3
+ import { B as getKernel, J as getKernel2D, K as registerForCleanup, L as unregisterFromCleanup, H as createEdge, G as createWire } from "./shapeTypes-Py3LEyDe.js";
4
+ import { u as uvBounds, f as faceGeomType, e as faceCenter, h as uvCoordinates, c as cast } from "./faceFns-g5hzl_xe.js";
5
+ import { g as getOrientation } from "./curveFns-GOcBuoCc.js";
6
+ import { o as ok, e as err, b as computationError, r as unwrap, y as validationError } from "./errors-B7kgv0cd.js";
7
+ import { d as distance2d, s as samePoint, b as scalarMultiply2d, c as add2d, e as subtract2d, g as getSingleFace } from "./helpers-Vqsg_fss.js";
8
8
  import { R as RAD2DEG, D as DEG2RAD } from "./vecOps-ZDdZWbwT.js";
9
- import { m as makeFace } from "./surfaceBuilders-CIEQ9j7C.js";
9
+ import { m as makeFace } from "./surfaceBuilders-CD_9kc1m.js";
10
10
  import { bug } from "./result.js";
11
11
  function makePlane(plane, origin) {
12
12
  if (plane && typeof plane !== "string") {
@@ -138,6 +138,13 @@ class BoundingBox2d {
138
138
  return !getKernel2D().isBBox2dOutPoint(this.wrapped, other[0], other[1]);
139
139
  }
140
140
  }
141
+ const normalize2d = ([x0, y0]) => {
142
+ const l = distance2d([x0, y0]);
143
+ if (l < 1e-12) {
144
+ bug("normalize2d", "Cannot normalize zero-length vector");
145
+ }
146
+ return [x0 / l, y0 / l];
147
+ };
141
148
  function deserializeCurve2D(data) {
142
149
  return new Curve2D(getKernel().deserializeCurve2d(data));
143
150
  }
@@ -986,11 +993,12 @@ export {
986
993
  isPoint2D as k,
987
994
  make2dThreePointArc as l,
988
995
  mirror as m,
989
- asSVG as n,
990
- make2dEllipseArc as o,
991
- make2dTangentArc as p,
992
- make2dBezierCurve as q,
993
- removeDuplicatePoints as r,
994
- makePlane as s,
996
+ normalize2d as n,
997
+ asSVG as o,
998
+ make2dEllipseArc as p,
999
+ make2dTangentArc as q,
1000
+ make2dBezierCurve as r,
1001
+ removeDuplicatePoints as s,
1002
+ makePlane as t,
995
1003
  viewbox as v
996
1004
  };
@@ -44,18 +44,18 @@ var __callDispose = (stack, error, hasError) => {
44
44
  };
45
45
  return next();
46
46
  };
47
- const vectors = require("./vectors-DqQXtR8s.cjs");
48
- const errors = require("./errors-DiTn5EoC.cjs");
49
- const faceFns = require("./faceFns-DVo4NiOl.cjs");
47
+ const vectors = require("./vectors-TlfO1hu2.cjs");
48
+ const errors = require("./errors-9fDehDNc.cjs");
49
+ const faceFns = require("./faceFns-Bhlm333o.cjs");
50
50
  const types = require("./types-CA_xrgDq.cjs");
51
51
  const vecOps = require("./vecOps-CjRL1jau.cjs");
52
- const loft = require("./loft-BpScchbu.cjs");
53
- const shapeTypes = require("./shapeTypes-CHvr4HNj.cjs");
54
- const curveFns = require("./curveFns-Dtaf2CvG.cjs");
55
- const surfaceBuilders = require("./surfaceBuilders-DIPPckQg.cjs");
52
+ const loft = require("./loft-B3ZDn94G.cjs");
53
+ const shapeTypes = require("./shapeTypes-BzrjB5be.cjs");
54
+ const curveFns = require("./curveFns-CeHbFVDc.cjs");
55
+ const surfaceBuilders = require("./surfaceBuilders-BCd-ugN2.cjs");
56
56
  const result = require("./result.cjs");
57
- const helpers = require("./helpers-BOPjTzbq.cjs");
58
- const Blueprint = require("./Blueprint-BbgdNjMG.cjs");
57
+ const helpers = require("./helpers-D3jdmQoR.cjs");
58
+ const Blueprint = require("./Blueprint-CFdLzoy5.cjs");
59
59
  const intersectCurves = (first, second, precision = 1e-9) => {
60
60
  if (first.boundingBox.isOut(second.boundingBox))
61
61
  return errors.ok({ intersections: [], commonSegments: [], commonSegmentsPoints: [] });
@@ -92,7 +92,7 @@ const selfIntersections = (curve, precision = 1e-9) => {
92
92
  return errors.ok(intersections);
93
93
  };
94
94
  const offsetEndPoints = (firstPoint, lastPoint, offset) => {
95
- const tangent = helpers.normalize2d(helpers.subtract2d(lastPoint, firstPoint));
95
+ const tangent = Blueprint.normalize2d(helpers.subtract2d(lastPoint, firstPoint));
96
96
  const normal = [tangent[1], -tangent[0]];
97
97
  const offsetVec = [normal[0] * offset, normal[1] * offset];
98
98
  return {
@@ -113,7 +113,7 @@ const make2dOffset = (curve, offset) => {
113
113
  if (newRadius < 1e-10) {
114
114
  const center = [cx, cy];
115
115
  const offsetViaCenter = (point) => {
116
- const [x, y] = helpers.normalize2d(helpers.subtract2d(point, center));
116
+ const [x, y] = Blueprint.normalize2d(helpers.subtract2d(point, center));
117
117
  return helpers.add2d(point, [orientedOffset * x, orientedOffset * y]);
118
118
  };
119
119
  return {
@@ -170,7 +170,7 @@ function removeCorner(firstCurve, secondCurve, radius) {
170
170
  const center = potentialCenter;
171
171
  const splitForFillet = (curve, offsetCurve) => {
172
172
  const [x, y] = offsetCurve.tangentAt(center);
173
- const normal = helpers.normalize2d([-y, x]);
173
+ const normal = Blueprint.normalize2d([-y, x]);
174
174
  const splitPoint = helpers.add2d(center, helpers.scalarMultiply2d(normal, offset));
175
175
  const splitParam = errors.unwrap(curve.parameter(splitPoint, 1e-6));
176
176
  return curve.splitAt([splitParam]);
@@ -196,8 +196,8 @@ function chamferCurves(firstCurve, secondCurve, radius) {
196
196
  return [first, Blueprint.make2dSegmentCurve(first.lastPoint, second.firstPoint), second];
197
197
  }
198
198
  function dogboneFilletCurves(firstCurve, secondCurve, radius) {
199
- const tgt1 = helpers.normalize2d(firstCurve.tangentAt(1));
200
- const tgt2 = helpers.normalize2d(secondCurve.tangentAt(0));
199
+ const tgt1 = Blueprint.normalize2d(firstCurve.tangentAt(1));
200
+ const tgt2 = Blueprint.normalize2d(secondCurve.tangentAt(0));
201
201
  const sinAngle = helpers.crossProduct2d(tgt1, tgt2);
202
202
  const a = Math.asin(sinAngle);
203
203
  if (Math.abs(sinAngle) < 1e-10) return [firstCurve, secondCurve];
@@ -1251,7 +1251,7 @@ function makeEllipseArcFromSvgParams(startUV, endUV, majorRadius, minorRadius, r
1251
1251
  const convertAxis = (ax) => helpers.distance2d(convertToUV(ax));
1252
1252
  const r1 = convertAxis(helpers.polarToCartesian(majorRadius, radRotationAngle));
1253
1253
  const r2 = convertAxis(helpers.polarToCartesian(minorRadius, radRotationAngle + Math.PI / 2));
1254
- const xDir = helpers.normalize2d(convertToUV(helpers.rotate2d([1, 0], radRotationAngle)));
1254
+ const xDir = Blueprint.normalize2d(convertToUV(helpers.rotate2d([1, 0], radRotationAngle)));
1255
1255
  const [, newRotationAngle] = helpers.cartesianToPolar(xDir);
1256
1256
  const { cx, cy, startAngle, endAngle, clockwise, rx, ry } = convertSvgEllipseParams(
1257
1257
  startUV,
@@ -1407,7 +1407,7 @@ class BaseSketcher2d {
1407
1407
  /** Draw a line tangent to the previous curve, extending by the given distance. */
1408
1408
  tangentLine(distance) {
1409
1409
  const previousCurve = this._requireLastCurve("Sketcher2d.tangentLine", "sketch a tangent line");
1410
- const direction = helpers.normalize2d(this._convertFromUV(previousCurve.tangentAt(1)));
1410
+ const direction = Blueprint.normalize2d(this._convertFromUV(previousCurve.tangentAt(1)));
1411
1411
  return this.line(direction[0] * distance, direction[1] * distance);
1412
1412
  }
1413
1413
  // ── Three-point arcs ──
@@ -1569,7 +1569,7 @@ class BaseSketcher2d {
1569
1569
  } else {
1570
1570
  startPoleDirection = this._convertFromUV(previousCurve.tangentAt(1));
1571
1571
  }
1572
- startPoleDirection = helpers.normalize2d(startPoleDirection);
1572
+ startPoleDirection = Blueprint.normalize2d(startPoleDirection);
1573
1573
  const startControl = [
1574
1574
  this.pointer[0] + startPoleDirection[0] * startFactor * defaultDistance,
1575
1575
  this.pointer[1] + startPoleDirection[1] * startFactor * defaultDistance
@@ -1580,7 +1580,7 @@ class BaseSketcher2d {
1580
1580
  } else {
1581
1581
  endPoleDirection = endTangent;
1582
1582
  }
1583
- endPoleDirection = helpers.normalize2d(endPoleDirection);
1583
+ endPoleDirection = Blueprint.normalize2d(endPoleDirection);
1584
1584
  const endControl = [
1585
1585
  end[0] - endPoleDirection[0] * endFactor * defaultDistance,
1586
1586
  end[1] - endPoleDirection[1] * endFactor * defaultDistance
@@ -43,18 +43,18 @@ var __callDispose = (stack, error, hasError) => {
43
43
  };
44
44
  return next();
45
45
  };
46
- import { a as createPlane } from "./vectors-B8RRTytu.js";
47
- import { o as ok, e as err, b as computationError, u as unwrap, g as isOk } from "./errors-lBwyc8YG.js";
48
- import { d as downcast, u as uvBounds, p as pointOnSurface, n as normalAt } from "./faceFns-DZU8VAlq.js";
46
+ import { a as createPlane } from "./vectors-cec8p8NQ.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-g5hzl_xe.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-BmO0VYht.js";
52
- import { J as getKernel2D, I as createFace, G as createWire, B as getKernel, H as createEdge, D as DisposalScope } from "./shapeTypes-CGYrwYIi.js";
53
- import { d as curveStartPoint, c as curveTangentAt, e as curveIsClosed } from "./curveFns-DeYQQ18o.js";
54
- import { m as makeFace, l as makeNewFaceWithinFace, b as assembleWire, z as zip } from "./surfaceBuilders-CIEQ9j7C.js";
51
+ import { r as revolution, c as complexExtrude, t as twistExtrude, b as basicFaceExtrusion, g as genericSweep, l as loft } from "./loft-BGHICbBS.js";
52
+ import { J as getKernel2D, I as createFace, G as createWire, B as getKernel, H as createEdge, D as DisposalScope } from "./shapeTypes-Py3LEyDe.js";
53
+ import { d as curveStartPoint, c as curveTangentAt, e as curveIsClosed } from "./curveFns-GOcBuoCc.js";
54
+ import { m as makeFace, l as makeNewFaceWithinFace, b as assembleWire, z as zip } from "./surfaceBuilders-CD_9kc1m.js";
55
55
  import { bug } from "./result.js";
56
- import { s as samePoint$1, n as normalize2d, e as subtract2d, c as add2d, i as crossProduct2d, b as scalarMultiply2d, f as polarToCartesian, r as rotate2d, j as cartesianToPolar, d as distance2d, p as polarAngle2d, k as PRECISION_INTERSECTION } from "./helpers-D8jYqufG.js";
57
- import { C as Curve2D, a as make2dSegmentCurve, j as approximateAsBSpline, b as make2dArcFromCenter, k as isPoint2D, g as make2dCircle, l as make2dThreePointArc, d as BoundingBox2d, v as viewbox, n as asSVG, B as Blueprint, o as make2dEllipseArc, p as make2dTangentArc, q as make2dBezierCurve, r as removeDuplicatePoints } from "./Blueprint-SMLvu1pH.js";
56
+ import { s as samePoint$1, e as subtract2d, c as add2d, i as crossProduct2d, b as scalarMultiply2d, f as polarToCartesian, r as rotate2d, j as cartesianToPolar, d as distance2d, p as polarAngle2d, k as PRECISION_INTERSECTION } from "./helpers-Vqsg_fss.js";
57
+ import { C as Curve2D, a as make2dSegmentCurve, j as approximateAsBSpline, n as normalize2d, b as make2dArcFromCenter, k as isPoint2D, g as make2dCircle, l as make2dThreePointArc, d as BoundingBox2d, v as viewbox, o as asSVG, B as Blueprint, p as make2dEllipseArc, q as make2dTangentArc, r as make2dBezierCurve, s as removeDuplicatePoints } from "./Blueprint-DQ18yiAI.js";
58
58
  const intersectCurves = (first, second, precision = 1e-9) => {
59
59
  if (first.boundingBox.isOut(second.boundingBox))
60
60
  return ok({ intersections: [], commonSegments: [], commonSegmentsPoints: [] });
@@ -1,9 +1,9 @@
1
- import { B as getKernel, c as castShape, p as isShape3D } from "./shapeTypes-CGYrwYIi.js";
2
- import { o as ok, d as isErr, e as err, x as validationError, B as BrepErrorCode, p as typeCastError, k as kernelError } from "./errors-lBwyc8YG.js";
3
- import { r as resolvePlane } from "./vectors-B8RRTytu.js";
1
+ import { B as getKernel, c as castShape, p as isShape3D } from "./shapeTypes-Py3LEyDe.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-cec8p8NQ.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 propagateOriginsFromEvolution, b as propagateOriginsByHash, g as getFaceOrigins, c as getWires, d as getEdges, e as getVertices } from "./shapeFns-BmOzkjTF.js";
6
- import { m as makeFace } from "./surfaceBuilders-CIEQ9j7C.js";
5
+ import { a as getFaces, p as propagateOriginsFromEvolution, b as propagateOriginsByHash, g as getFaceOrigins, c as getWires, d as getEdges, e as getVertices } from "./shapeFns-smSl7yhL.js";
6
+ import { m as makeFace } from "./surfaceBuilders-CD_9kc1m.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
- const shapeTypes = require("./shapeTypes-CHvr4HNj.cjs");
3
- const errors = require("./errors-DiTn5EoC.cjs");
4
- const vectors = require("./vectors-DqQXtR8s.cjs");
2
+ const shapeTypes = require("./shapeTypes-BzrjB5be.cjs");
3
+ const errors = require("./errors-9fDehDNc.cjs");
4
+ const vectors = require("./vectors-TlfO1hu2.cjs");
5
5
  const vecOps = require("./vecOps-CjRL1jau.cjs");
6
- const shapeFns = require("./shapeFns-vrqpeRIf.cjs");
7
- const surfaceBuilders = require("./surfaceBuilders-DIPPckQg.cjs");
6
+ const shapeFns = require("./shapeFns-BHSGfqFS.cjs");
7
+ const surfaceBuilders = require("./surfaceBuilders-BCd-ugN2.cjs");
8
8
  const shapeTagStore = /* @__PURE__ */ new WeakMap();
9
9
  const tagMetadataStore = /* @__PURE__ */ new WeakMap();
10
10
  function hasFaceTags(shape) {
package/dist/brepjs.cjs CHANGED
@@ -45,31 +45,31 @@ var __callDispose = (stack, error, hasError) => {
45
45
  return next();
46
46
  };
47
47
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
48
- const shapeTypes = require("./shapeTypes-CHvr4HNj.cjs");
49
- const errors = require("./errors-DiTn5EoC.cjs");
48
+ const shapeTypes = require("./shapeTypes-BzrjB5be.cjs");
49
+ const errors = require("./errors-9fDehDNc.cjs");
50
50
  const vecOps = require("./vecOps-CjRL1jau.cjs");
51
- const Blueprint = require("./Blueprint-BbgdNjMG.cjs");
52
- const loft$2 = require("./loft-BpScchbu.cjs");
53
- const operations = require("./operations-CGbdoQvO.cjs");
54
- const boolean2D = require("./boolean2D-DiHJyuu4.cjs");
51
+ const Blueprint = require("./Blueprint-CFdLzoy5.cjs");
52
+ const loft$2 = require("./loft-B3ZDn94G.cjs");
53
+ const operations = require("./operations-Cb4gWPwL.cjs");
54
+ const boolean2D = require("./boolean2D-C5tjWX5T.cjs");
55
55
  const _2d = require("./2d.cjs");
56
- const helpers = require("./helpers-BOPjTzbq.cjs");
56
+ const helpers = require("./helpers-D3jdmQoR.cjs");
57
57
  const io = require("./io.cjs");
58
- const drawFns = require("./drawFns-NsqGSBEK.cjs");
58
+ const drawFns = require("./drawFns-F5uDtd2v.cjs");
59
59
  const types = require("./types-CA_xrgDq.cjs");
60
- const vectors = require("./vectors-DqQXtR8s.cjs");
61
- const shapeFns = require("./shapeFns-vrqpeRIf.cjs");
62
- const booleanFns = require("./booleanFns-BaMEij5u.cjs");
63
- const topology = require("./topology-DiWPQ0YS.cjs");
64
- const curveFns = require("./curveFns-Dtaf2CvG.cjs");
65
- const faceFns = require("./faceFns-DVo4NiOl.cjs");
66
- const meshFns = require("./meshFns-d6Ta_uov.cjs");
67
- const measurement = require("./measurement-Crexq3aQ.cjs");
68
- const surfaceBuilders = require("./surfaceBuilders-DIPPckQg.cjs");
60
+ const vectors = require("./vectors-TlfO1hu2.cjs");
61
+ const shapeFns = require("./shapeFns-BHSGfqFS.cjs");
62
+ const booleanFns = require("./booleanFns-PbcD1St_.cjs");
63
+ const topology = require("./topology-B15z3Ts4.cjs");
64
+ const curveFns = require("./curveFns-CeHbFVDc.cjs");
65
+ const faceFns = require("./faceFns-Bhlm333o.cjs");
66
+ const meshFns = require("./meshFns-rTBykpgO.cjs");
67
+ const measurement = require("./measurement--jEL3ePF.cjs");
68
+ const surfaceBuilders = require("./surfaceBuilders-BCd-ugN2.cjs");
69
69
  const query = require("./query.cjs");
70
- const solidBuilders = require("./solidBuilders-Bo8N2UV1.cjs");
70
+ const solidBuilders = require("./solidBuilders-DINhvxLC.cjs");
71
71
  const result = require("./result.cjs");
72
- const cornerFinder = require("./cornerFinder-CDkc5qfD.cjs");
72
+ const cornerFinder = require("./cornerFinder-BphV9OLn.cjs");
73
73
  const worker = require("./worker.cjs");
74
74
  function supportsProjection(kernel) {
75
75
  return "projectShape" in kernel;
@@ -82,7 +82,10 @@ const errorFactories = {
82
82
  MODULE_INIT: (code, message, cause) => ({ kind: "MODULE_INIT", code, message, cause }),
83
83
  COMPUTATION: (code, message, cause) => ({ kind: "COMPUTATION", code, message, cause }),
84
84
  IO: (code, message, cause) => ({ kind: "IO", code, message, cause }),
85
- QUERY: (code, message, cause) => ({ kind: "QUERY", code, message, cause })
85
+ QUERY: (code, message, cause) => ({ kind: "QUERY", code, message, cause }),
86
+ // NB: UNSUPPORTED exists for Record<BrepErrorKind> exhaustiveness.
87
+ // Prefer explicit `return err(unsupportedError(...))` in adapter code (ADR-0006).
88
+ UNSUPPORTED: (code, message, cause) => ({ kind: "UNSUPPORTED", code, message, cause })
86
89
  };
87
90
  function kernelCall(fn, code, message, kind = "KERNEL_OPERATION") {
88
91
  try {
@@ -2663,6 +2666,7 @@ exports.tapErr = errors.tapErr;
2663
2666
  exports.tryCatch = errors.tryCatch;
2664
2667
  exports.tryCatchAsync = errors.tryCatchAsync;
2665
2668
  exports.typeCastError = errors.typeCastError;
2669
+ exports.unsupportedError = errors.unsupportedError;
2666
2670
  exports.unwrap = errors.unwrap;
2667
2671
  exports.unwrapErr = errors.unwrapErr;
2668
2672
  exports.unwrapOr = errors.unwrapOr;