brepjs 18.118.7 → 18.118.9

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 (78) hide show
  1. package/dist/2d.cjs +6 -6
  2. package/dist/2d.js +6 -6
  3. package/dist/{adjacencyFns-DGMGVQl7.js → adjacencyFns-CTNUxf0c.js} +74 -32
  4. package/dist/{adjacencyFns-BmnrcGXe.cjs → adjacencyFns-Wc3R-UZr.cjs} +74 -32
  5. package/dist/{blueprint-Cq4SoX4f.js → blueprint-nrz4fL3I.js} +5 -5
  6. package/dist/{blueprint-8aYTu_pt.cjs → blueprint-qWwhQGSr.cjs} +5 -5
  7. package/dist/{blueprintFns-BFCNzqOo.js → blueprintFns-BaWyLnF-.js} +2 -2
  8. package/dist/{blueprintFns-DeFKRkeJ.cjs → blueprintFns-BhiWnHuR.cjs} +2 -2
  9. package/dist/{blueprintSketcher-BbT1WvI0.cjs → blueprintSketcher-D5AHgjkT.cjs} +3 -3
  10. package/dist/{blueprintSketcher-L_UQ6PjH.js → blueprintSketcher-cgkF6uCj.js} +3 -3
  11. package/dist/{boolean2D-gvWTFM1D.cjs → boolean2D-Bemx5WZV.cjs} +4 -4
  12. package/dist/{boolean2D-Bo8N_bkO.js → boolean2D-CSZIZMaq.js} +4 -4
  13. package/dist/brepjs.cjs +25 -25
  14. package/dist/brepjs.js +25 -25
  15. package/dist/{cameraFns-BgMZW_YF.cjs → cameraFns-taUY1CFZ.cjs} +2 -2
  16. package/dist/{cameraFns-CX0GX3TA.js → cameraFns-xD28Tsqu.js} +2 -2
  17. package/dist/core/shapeTypes.d.ts +9 -0
  18. package/dist/core.cjs +1 -1
  19. package/dist/core.js +1 -1
  20. package/dist/{cornerFinder-Dg00ADRE.cjs → cornerFinder-BDwDNTdN.cjs} +1 -1
  21. package/dist/{cornerFinder-ug3d1MIj.js → cornerFinder-DGI6Ud6N.js} +1 -1
  22. package/dist/{curveFns-Bbq8YwiP.cjs → curveFns-Bb3wuFj4.cjs} +1 -1
  23. package/dist/{curveFns-QU4XEJMN.js → curveFns-Y1TTdL_y.js} +1 -1
  24. package/dist/{drawFns-BaoKhtS2.cjs → drawFns-Bgug3W7c.cjs} +12 -12
  25. package/dist/{drawFns-t8qlCOhw.js → drawFns-BksvLjN1.js} +12 -12
  26. package/dist/{faceFns-DlUhG1i5.cjs → faceFns-BhBJ_Hsb.cjs} +2 -2
  27. package/dist/{faceFns-CnCX9BM_.js → faceFns-Bm3-D75M.js} +2 -2
  28. package/dist/{healingFns-DS2jVC-6.cjs → healingFns-DoJQUwBN.cjs} +5 -5
  29. package/dist/{healingFns-DWODzlw2.js → healingFns-g8JymEUi.js} +5 -5
  30. package/dist/{helpers-CXHMPCPr.cjs → helpers-DKfkqED3.cjs} +6 -6
  31. package/dist/{helpers-nTMuqwBX.js → helpers-DzOME9UE.js} +6 -6
  32. package/dist/{importFns-JVnMjbVT.js → importFns-BnQAQt7q.js} +2 -2
  33. package/dist/{importFns-Rtl8_piv.cjs → importFns-D8i8O8di.cjs} +2 -2
  34. package/dist/io.cjs +2 -2
  35. package/dist/io.js +2 -2
  36. package/dist/{loftFns-CYHPZMOq.cjs → loftFns-BJiGxTys.cjs} +1 -1
  37. package/dist/{loftFns-jXPjUwdV.js → loftFns-CK4PP1IR.js} +1 -1
  38. package/dist/{measureFns-DDlmrOwH.js → measureFns-1akKMnXO.js} +3 -3
  39. package/dist/{measureFns-BXpXVoE1.cjs → measureFns-DJ1SESSY.cjs} +3 -3
  40. package/dist/measurement.cjs +1 -1
  41. package/dist/measurement.js +1 -1
  42. package/dist/{meshFns-BcvYEb05.js → meshFns-Dt93gFGp.js} +3 -3
  43. package/dist/{meshFns-tNFtjrAg.cjs → meshFns-s-c0lABa.cjs} +3 -3
  44. package/dist/operations.cjs +2 -2
  45. package/dist/operations.js +2 -2
  46. package/dist/{primitiveFns-CTCpyACp.cjs → primitiveFns-BDdThy3-.cjs} +4 -4
  47. package/dist/{primitiveFns-C1uYmrtf.js → primitiveFns-D-hFA6e9.js} +4 -4
  48. package/dist/projection.cjs +1 -1
  49. package/dist/projection.js +1 -1
  50. package/dist/query.cjs +2 -2
  51. package/dist/query.js +2 -2
  52. package/dist/{refResolveFns-BdEmu7yh.cjs → refResolveFns-AbuzUhGC.cjs} +6 -6
  53. package/dist/{refResolveFns-BT4g71BY.js → refResolveFns-BNzUtX4y.js} +6 -6
  54. package/dist/{shapeFns-7T0gykWr.cjs → shapeFns-1aqO2bz4.cjs} +2 -2
  55. package/dist/{shapeFns-B0tRZG0L.js → shapeFns-Dqlpy8wm.js} +2 -2
  56. package/dist/shapeRef.cjs +1 -1
  57. package/dist/shapeRef.js +1 -1
  58. package/dist/{shapeTypes-OqAALhek.cjs → shapeTypes-B8a39SS3.cjs} +24 -2
  59. package/dist/{shapeTypes-USExUZfW.js → shapeTypes-D8Fprilr.js} +19 -3
  60. package/dist/sketching.cjs +3 -3
  61. package/dist/sketching.js +3 -3
  62. package/dist/{solidBuilders-DGhhY8ct.js → solidBuilders-B_N5miaY.js} +5 -5
  63. package/dist/{solidBuilders-oBXWp32X.cjs → solidBuilders-CkkgC2se.cjs} +5 -5
  64. package/dist/{surfaceBuilders-BPTkEKy4.js → surfaceBuilders-B15_8txg.js} +2 -2
  65. package/dist/{surfaceBuilders-_pFeqIF8.cjs → surfaceBuilders-DUG4Y0qA.cjs} +2 -2
  66. package/dist/text.cjs +2 -2
  67. package/dist/text.js +2 -2
  68. package/dist/{textBlueprints-BKi0ghsT.cjs → textBlueprints-BXtV_DY6.cjs} +7 -7
  69. package/dist/{textBlueprints-lsM-HJ_1.js → textBlueprints-BYz-7-MZ.js} +7 -7
  70. package/dist/{textMetrics-66K6zyvX.cjs → textMetrics-DBdtpVNo.cjs} +1 -1
  71. package/dist/{textMetrics-C89j257P.js → textMetrics-yyHcpdUd.js} +1 -1
  72. package/dist/{threadFns-oZG40DKL.js → threadFns-CMdXdlIH.js} +7 -7
  73. package/dist/{threadFns-CILCsLs1.cjs → threadFns-CWIlyEcP.cjs} +7 -7
  74. package/dist/topology.cjs +9 -9
  75. package/dist/topology.js +9 -9
  76. package/dist/{topologyQueryFns-DK-ktEI-.cjs → topologyQueryFns-BJbOwoZm.cjs} +10 -10
  77. package/dist/{topologyQueryFns-Jg9SyAWe.js → topologyQueryFns-DfThB5LA.js} +10 -10
  78. package/package.json +1 -1
package/dist/2d.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_shapeTypes = require("./shapeTypes-OqAALhek.cjs");
2
+ const require_shapeTypes = require("./shapeTypes-B8a39SS3.cjs");
3
3
  const require_errors = require("./errors-CXJtc4I7.cjs");
4
- const require_topologyQueryFns = require("./topologyQueryFns-DK-ktEI-.cjs");
5
- const require_blueprintSketcher = require("./blueprintSketcher-BbT1WvI0.cjs");
6
- const require_blueprint = require("./blueprint-8aYTu_pt.cjs");
7
- const require_boolean2D = require("./boolean2D-gvWTFM1D.cjs");
8
- const require_blueprintFns = require("./blueprintFns-DeFKRkeJ.cjs");
4
+ const require_topologyQueryFns = require("./topologyQueryFns-BJbOwoZm.cjs");
5
+ const require_blueprintSketcher = require("./blueprintSketcher-D5AHgjkT.cjs");
6
+ const require_blueprint = require("./blueprint-qWwhQGSr.cjs");
7
+ const require_boolean2D = require("./boolean2D-Bemx5WZV.cjs");
8
+ const require_blueprintFns = require("./blueprintFns-BhiWnHuR.cjs");
9
9
  //#region src/core/curve2dHandle.ts
10
10
  /**
11
11
  * Wrap a raw kernel 2D curve handle with brand + disposal tracking.
package/dist/2d.js CHANGED
@@ -1,10 +1,10 @@
1
- import { W as createKernelHandle, nt as getKernel2D, o as createEdge } from "./shapeTypes-USExUZfW.js";
1
+ import { G as createKernelHandle, rt as getKernel2D, s as createEdge } from "./shapeTypes-D8Fprilr.js";
2
2
  import { A as ok, b as err, d as validationError, t as BrepErrorCode } from "./errors-DNWJsfVU.js";
3
- import { w as kernelCallRaw } from "./topologyQueryFns-Jg9SyAWe.js";
4
- import { a as Blueprints, i as CompoundBlueprint, r as organiseBlueprints } from "./blueprintSketcher-L_UQ6PjH.js";
5
- import { _ as Curve2D, t as Blueprint, y as BoundingBox2d } from "./blueprint-Cq4SoX4f.js";
6
- import { a as fuseBlueprints, c as roundedRectangleBlueprint, i as cutBlueprints, n as fuse2D, o as intersectBlueprints, r as intersect2D, s as polysidesBlueprint, t as cut2D } from "./boolean2D-Bo8N_bkO.js";
7
- import { S as reverseCurve, _ as curve2dIsOnCurve, a as isInside2D, b as curve2dSplitAt, c as scale2D, d as stretch2D, f as toSVGPathD, g as curve2dFirstPoint, h as curve2dDistanceFrom, i as getOrientation2D, l as sketchOnFace2D, m as curve2dBoundingBox, o as mirror2D, p as translate2D, r as getBounds2D, s as rotate2D, t as createBlueprint, u as sketchOnPlane2D, v as curve2dLastPoint, x as curve2dTangentAt, y as curve2dParameter } from "./blueprintFns-BFCNzqOo.js";
3
+ import { w as kernelCallRaw } from "./topologyQueryFns-DfThB5LA.js";
4
+ import { a as Blueprints, i as CompoundBlueprint, r as organiseBlueprints } from "./blueprintSketcher-cgkF6uCj.js";
5
+ import { _ as Curve2D, t as Blueprint, y as BoundingBox2d } from "./blueprint-nrz4fL3I.js";
6
+ import { a as fuseBlueprints, c as roundedRectangleBlueprint, i as cutBlueprints, n as fuse2D, o as intersectBlueprints, r as intersect2D, s as polysidesBlueprint, t as cut2D } from "./boolean2D-CSZIZMaq.js";
7
+ import { S as reverseCurve, _ as curve2dIsOnCurve, a as isInside2D, b as curve2dSplitAt, c as scale2D, d as stretch2D, f as toSVGPathD, g as curve2dFirstPoint, h as curve2dDistanceFrom, i as getOrientation2D, l as sketchOnFace2D, m as curve2dBoundingBox, o as mirror2D, p as translate2D, r as getBounds2D, s as rotate2D, t as createBlueprint, u as sketchOnPlane2D, v as curve2dLastPoint, x as curve2dTangentAt, y as curve2dParameter } from "./blueprintFns-BaWyLnF-.js";
8
8
  //#region src/core/curve2dHandle.ts
9
9
  /**
10
10
  * Wrap a raw kernel 2D curve handle with brand + disposal tracking.
@@ -1,5 +1,5 @@
1
- import { i as castShapeWithKnownType, tt as getKernel } from "./shapeTypes-USExUZfW.js";
2
- import { l as getOrCreateCache } from "./topologyQueryFns-Jg9SyAWe.js";
1
+ import { a as castShapeWithKnownType, n as castResultShapeWithKnownType, nt as getKernel } from "./shapeTypes-D8Fprilr.js";
2
+ import { c as getFaces, f as getVertices, l as getOrCreateCache, s as getEdges } from "./topologyQueryFns-DfThB5LA.js";
3
3
  import { n as HASH_CODE_MAX } from "./constants-ITRzCnCp.js";
4
4
  //#region src/topology/adjacencyFns.ts
5
5
  /**
@@ -8,6 +8,11 @@ import { n as HASH_CODE_MAX } from "./constants-ITRzCnCp.js";
8
8
  * Uses cached topology extraction and an edge→faces adjacency map
9
9
  * (built once per parent shape and cached) to avoid redundant WASM calls.
10
10
  */
11
+ /**
12
+ * Brand cache-owned raw sub-shapes (from the edge/face adjacency maps) without
13
+ * consuming them. Each cast allocates a fresh downcast the caller disposes; the
14
+ * cached source stays intact — so this must NOT release its input.
15
+ */
11
16
  function wrapAll(shapes, type) {
12
17
  return shapes.map((s) => castShapeWithKnownType(s, type));
13
18
  }
@@ -16,7 +21,11 @@ function wrapAll(shapes, type) {
16
21
  * hash+isSame, and return branded handles of type `T`.
17
22
  *
18
23
  * Used by edgesOfFace, wiresOfFace, and verticesOfEdge — all of which need
19
- * the same deduplicated-children pattern on a raw KernelShape.
24
+ * the same deduplicated-children pattern on a raw KernelShape. Each iterated
25
+ * sub-shape is a fresh arena slot the caller owns: uniques are cast with
26
+ * `castResultShapeWithKnownType` (releasing the orphaned pre-downcast source),
27
+ * and duplicates are released outright — otherwise every call leaks one slot
28
+ * per sub-shape on the occt-wasm arena kernel.
20
29
  */
21
30
  function deduplicatedSubShapes(parentKernel, type) {
22
31
  const kernel = getKernel();
@@ -26,64 +35,94 @@ function deduplicatedSubShapes(parentKernel, type) {
26
35
  for (const item of items) {
27
36
  const hash = kernel.hashCode(item, HASH_CODE_MAX);
28
37
  const bucket = seen.get(hash);
29
- if (!bucket) {
30
- seen.set(hash, [item]);
31
- results.push(item);
32
- } else if (!bucket.some((r) => kernel.isSame(r, item))) {
33
- bucket.push(item);
34
- results.push(item);
38
+ if (bucket?.some((r) => kernel.isSame(r, item))) {
39
+ kernel.dispose(item);
40
+ continue;
35
41
  }
42
+ const casted = castResultShapeWithKnownType(item, type);
43
+ results.push(casted);
44
+ if (bucket) bucket.push(casted.wrapped);
45
+ else seen.set(hash, [casted.wrapped]);
46
+ }
47
+ return results;
48
+ }
49
+ /** Hash-index branded sub-shapes for isSame lookup by hash code. */
50
+ function indexByHash(items) {
51
+ const kernel = getKernel();
52
+ const index = /* @__PURE__ */ new Map();
53
+ for (const item of items) {
54
+ const hash = kernel.hashCode(item.wrapped, HASH_CODE_MAX);
55
+ const bucket = index.get(hash);
56
+ if (bucket) bucket.push(item);
57
+ else index.set(hash, [item]);
36
58
  }
37
- return wrapAll(results, type);
59
+ return index;
60
+ }
61
+ /** The managed handle matching a raw sub-shape by hash + isSame, or undefined. */
62
+ function findManaged(index, raw, hash) {
63
+ const kernel = getKernel();
64
+ return index.get(hash)?.find((m) => kernel.isSame(m.wrapped, raw));
38
65
  }
39
66
  /**
40
67
  * Build or retrieve the cached edge→faces adjacency map for a parent shape.
41
68
  * Maps edge hash codes to edge-face pairs, storing the edge alongside each
42
69
  * face so facesOfEdge can verify via isSame without re-extracting face edges.
70
+ *
71
+ * The stored handles are the parent's **managed** `getEdges`/`getFaces` handles
72
+ * (owned by the topology cache), never fresh iterated slots — so the map holds
73
+ * no arena slots of its own. The transient per-face edges used only for
74
+ * matching are released immediately.
43
75
  */
44
76
  function getEdgeToFacesMap(parent) {
45
77
  const cache = getOrCreateCache(parent);
46
78
  if (cache.edgeToFaces) return cache.edgeToFaces;
47
79
  const kernel = getKernel();
80
+ const faces = getFaces(parent);
81
+ const edgeIndex = indexByHash(getEdges(parent));
48
82
  const edgeToFaces = /* @__PURE__ */ new Map();
49
- const allFaces = kernel.iterShapes(parent.wrapped, "face");
50
- for (const f of allFaces) {
51
- const edges = kernel.iterShapes(f, "edge");
52
- for (const e of edges) {
53
- const hash = kernel.hashCode(e, HASH_CODE_MAX);
54
- let bucket = edgeToFaces.get(hash);
55
- if (!bucket) {
56
- bucket = [];
57
- edgeToFaces.set(hash, bucket);
58
- }
59
- if (!bucket.some((entry) => kernel.isSame(entry.edge, e) && kernel.isSame(entry.face, f))) bucket.push({
60
- edge: e,
61
- face: f
62
- });
83
+ for (const face of faces) for (const rawEdge of kernel.iterShapes(face.wrapped, "edge")) {
84
+ const hash = kernel.hashCode(rawEdge, HASH_CODE_MAX);
85
+ const managedEdge = findManaged(edgeIndex, rawEdge, hash);
86
+ kernel.dispose(rawEdge);
87
+ if (!managedEdge) continue;
88
+ let bucket = edgeToFaces.get(hash);
89
+ if (!bucket) {
90
+ bucket = [];
91
+ edgeToFaces.set(hash, bucket);
63
92
  }
93
+ if (!bucket.some((entry) => kernel.isSame(entry.edge, managedEdge.wrapped) && kernel.isSame(entry.face, face.wrapped))) bucket.push({
94
+ edge: managedEdge.wrapped,
95
+ face: face.wrapped
96
+ });
64
97
  }
65
98
  cache.edgeToFaces = edgeToFaces;
66
99
  return edgeToFaces;
67
100
  }
68
101
  /**
69
102
  * Build or retrieve the cached vertex→faces adjacency map for a parent shape —
70
- * the vertex analogue of {@link getEdgeToFacesMap}.
103
+ * the vertex analogue of {@link getEdgeToFacesMap}. Stores the parent's managed
104
+ * `getVertices`/`getFaces` handles and releases the transient per-face vertices.
71
105
  */
72
106
  function getVertexToFacesMap(parent) {
73
107
  const cache = getOrCreateCache(parent);
74
108
  if (cache.vertexToFaces) return cache.vertexToFaces;
75
109
  const kernel = getKernel();
110
+ const faces = getFaces(parent);
111
+ const vertexIndex = indexByHash(getVertices(parent));
76
112
  const vertexToFaces = /* @__PURE__ */ new Map();
77
- for (const f of kernel.iterShapes(parent.wrapped, "face")) for (const v of kernel.iterShapes(f, "vertex")) {
78
- const hash = kernel.hashCode(v, HASH_CODE_MAX);
113
+ for (const face of faces) for (const rawVertex of kernel.iterShapes(face.wrapped, "vertex")) {
114
+ const hash = kernel.hashCode(rawVertex, HASH_CODE_MAX);
115
+ const managedVertex = findManaged(vertexIndex, rawVertex, hash);
116
+ kernel.dispose(rawVertex);
117
+ if (!managedVertex) continue;
79
118
  let bucket = vertexToFaces.get(hash);
80
119
  if (!bucket) {
81
120
  bucket = [];
82
121
  vertexToFaces.set(hash, bucket);
83
122
  }
84
- if (!bucket.some((entry) => kernel.isSame(entry.vertex, v) && kernel.isSame(entry.face, f))) bucket.push({
85
- vertex: v,
86
- face: f
123
+ if (!bucket.some((entry) => kernel.isSame(entry.vertex, managedVertex.wrapped) && kernel.isSame(entry.face, face.wrapped))) bucket.push({
124
+ vertex: managedVertex.wrapped,
125
+ face: face.wrapped
87
126
  });
88
127
  }
89
128
  cache.vertexToFaces = vertexToFaces;
@@ -216,6 +255,7 @@ function adjacentFaces(parent, face) {
216
255
  }
217
256
  }
218
257
  }
258
+ for (const e of faceEdgeHandles) e[Symbol.dispose]();
219
259
  return wrapAll(neighborRaw, "face");
220
260
  }
221
261
  /**
@@ -240,8 +280,10 @@ function sharedEdges(face1, face2) {
240
280
  bucket.push(e2);
241
281
  }
242
282
  const shared = [];
243
- for (const e1 of edges1) if (edge2Map.get(kernel.hashCode(e1, 2147483647))?.some((e2) => kernel.isSame(e1, e2))) shared.push(e1);
244
- return wrapAll(shared, "edge");
283
+ for (const e1 of edges1) if (edge2Map.get(kernel.hashCode(e1, 2147483647))?.some((e2) => kernel.isSame(e1, e2))) shared.push(castResultShapeWithKnownType(e1, "edge"));
284
+ else kernel.dispose(e1);
285
+ for (const e2 of edges2) kernel.dispose(e2);
286
+ return shared;
245
287
  }
246
288
  //#endregion
247
289
  export { sharedEdges as a, wiresOfFace as c, facesOfVertex as i, edgesOfFace as n, verticesOfEdge as o, facesOfEdge as r, verticesOfFace as s, adjacentFaces as t };
@@ -1,5 +1,5 @@
1
- const require_shapeTypes = require("./shapeTypes-OqAALhek.cjs");
2
- const require_topologyQueryFns = require("./topologyQueryFns-DK-ktEI-.cjs");
1
+ const require_shapeTypes = require("./shapeTypes-B8a39SS3.cjs");
2
+ const require_topologyQueryFns = require("./topologyQueryFns-BJbOwoZm.cjs");
3
3
  const require_constants = require("./constants-BOVyEYGH.cjs");
4
4
  //#region src/topology/adjacencyFns.ts
5
5
  /**
@@ -8,6 +8,11 @@ const require_constants = require("./constants-BOVyEYGH.cjs");
8
8
  * Uses cached topology extraction and an edge→faces adjacency map
9
9
  * (built once per parent shape and cached) to avoid redundant WASM calls.
10
10
  */
11
+ /**
12
+ * Brand cache-owned raw sub-shapes (from the edge/face adjacency maps) without
13
+ * consuming them. Each cast allocates a fresh downcast the caller disposes; the
14
+ * cached source stays intact — so this must NOT release its input.
15
+ */
11
16
  function wrapAll(shapes, type) {
12
17
  return shapes.map((s) => require_shapeTypes.castShapeWithKnownType(s, type));
13
18
  }
@@ -16,7 +21,11 @@ function wrapAll(shapes, type) {
16
21
  * hash+isSame, and return branded handles of type `T`.
17
22
  *
18
23
  * Used by edgesOfFace, wiresOfFace, and verticesOfEdge — all of which need
19
- * the same deduplicated-children pattern on a raw KernelShape.
24
+ * the same deduplicated-children pattern on a raw KernelShape. Each iterated
25
+ * sub-shape is a fresh arena slot the caller owns: uniques are cast with
26
+ * `castResultShapeWithKnownType` (releasing the orphaned pre-downcast source),
27
+ * and duplicates are released outright — otherwise every call leaks one slot
28
+ * per sub-shape on the occt-wasm arena kernel.
20
29
  */
21
30
  function deduplicatedSubShapes(parentKernel, type) {
22
31
  const kernel = require_shapeTypes.getKernel();
@@ -26,64 +35,94 @@ function deduplicatedSubShapes(parentKernel, type) {
26
35
  for (const item of items) {
27
36
  const hash = kernel.hashCode(item, require_constants.HASH_CODE_MAX);
28
37
  const bucket = seen.get(hash);
29
- if (!bucket) {
30
- seen.set(hash, [item]);
31
- results.push(item);
32
- } else if (!bucket.some((r) => kernel.isSame(r, item))) {
33
- bucket.push(item);
34
- results.push(item);
38
+ if (bucket?.some((r) => kernel.isSame(r, item))) {
39
+ kernel.dispose(item);
40
+ continue;
35
41
  }
42
+ const casted = require_shapeTypes.castResultShapeWithKnownType(item, type);
43
+ results.push(casted);
44
+ if (bucket) bucket.push(casted.wrapped);
45
+ else seen.set(hash, [casted.wrapped]);
46
+ }
47
+ return results;
48
+ }
49
+ /** Hash-index branded sub-shapes for isSame lookup by hash code. */
50
+ function indexByHash(items) {
51
+ const kernel = require_shapeTypes.getKernel();
52
+ const index = /* @__PURE__ */ new Map();
53
+ for (const item of items) {
54
+ const hash = kernel.hashCode(item.wrapped, require_constants.HASH_CODE_MAX);
55
+ const bucket = index.get(hash);
56
+ if (bucket) bucket.push(item);
57
+ else index.set(hash, [item]);
36
58
  }
37
- return wrapAll(results, type);
59
+ return index;
60
+ }
61
+ /** The managed handle matching a raw sub-shape by hash + isSame, or undefined. */
62
+ function findManaged(index, raw, hash) {
63
+ const kernel = require_shapeTypes.getKernel();
64
+ return index.get(hash)?.find((m) => kernel.isSame(m.wrapped, raw));
38
65
  }
39
66
  /**
40
67
  * Build or retrieve the cached edge→faces adjacency map for a parent shape.
41
68
  * Maps edge hash codes to edge-face pairs, storing the edge alongside each
42
69
  * face so facesOfEdge can verify via isSame without re-extracting face edges.
70
+ *
71
+ * The stored handles are the parent's **managed** `getEdges`/`getFaces` handles
72
+ * (owned by the topology cache), never fresh iterated slots — so the map holds
73
+ * no arena slots of its own. The transient per-face edges used only for
74
+ * matching are released immediately.
43
75
  */
44
76
  function getEdgeToFacesMap(parent) {
45
77
  const cache = require_topologyQueryFns.getOrCreateCache(parent);
46
78
  if (cache.edgeToFaces) return cache.edgeToFaces;
47
79
  const kernel = require_shapeTypes.getKernel();
80
+ const faces = require_topologyQueryFns.getFaces(parent);
81
+ const edgeIndex = indexByHash(require_topologyQueryFns.getEdges(parent));
48
82
  const edgeToFaces = /* @__PURE__ */ new Map();
49
- const allFaces = kernel.iterShapes(parent.wrapped, "face");
50
- for (const f of allFaces) {
51
- const edges = kernel.iterShapes(f, "edge");
52
- for (const e of edges) {
53
- const hash = kernel.hashCode(e, require_constants.HASH_CODE_MAX);
54
- let bucket = edgeToFaces.get(hash);
55
- if (!bucket) {
56
- bucket = [];
57
- edgeToFaces.set(hash, bucket);
58
- }
59
- if (!bucket.some((entry) => kernel.isSame(entry.edge, e) && kernel.isSame(entry.face, f))) bucket.push({
60
- edge: e,
61
- face: f
62
- });
83
+ for (const face of faces) for (const rawEdge of kernel.iterShapes(face.wrapped, "edge")) {
84
+ const hash = kernel.hashCode(rawEdge, require_constants.HASH_CODE_MAX);
85
+ const managedEdge = findManaged(edgeIndex, rawEdge, hash);
86
+ kernel.dispose(rawEdge);
87
+ if (!managedEdge) continue;
88
+ let bucket = edgeToFaces.get(hash);
89
+ if (!bucket) {
90
+ bucket = [];
91
+ edgeToFaces.set(hash, bucket);
63
92
  }
93
+ if (!bucket.some((entry) => kernel.isSame(entry.edge, managedEdge.wrapped) && kernel.isSame(entry.face, face.wrapped))) bucket.push({
94
+ edge: managedEdge.wrapped,
95
+ face: face.wrapped
96
+ });
64
97
  }
65
98
  cache.edgeToFaces = edgeToFaces;
66
99
  return edgeToFaces;
67
100
  }
68
101
  /**
69
102
  * Build or retrieve the cached vertex→faces adjacency map for a parent shape —
70
- * the vertex analogue of {@link getEdgeToFacesMap}.
103
+ * the vertex analogue of {@link getEdgeToFacesMap}. Stores the parent's managed
104
+ * `getVertices`/`getFaces` handles and releases the transient per-face vertices.
71
105
  */
72
106
  function getVertexToFacesMap(parent) {
73
107
  const cache = require_topologyQueryFns.getOrCreateCache(parent);
74
108
  if (cache.vertexToFaces) return cache.vertexToFaces;
75
109
  const kernel = require_shapeTypes.getKernel();
110
+ const faces = require_topologyQueryFns.getFaces(parent);
111
+ const vertexIndex = indexByHash(require_topologyQueryFns.getVertices(parent));
76
112
  const vertexToFaces = /* @__PURE__ */ new Map();
77
- for (const f of kernel.iterShapes(parent.wrapped, "face")) for (const v of kernel.iterShapes(f, "vertex")) {
78
- const hash = kernel.hashCode(v, require_constants.HASH_CODE_MAX);
113
+ for (const face of faces) for (const rawVertex of kernel.iterShapes(face.wrapped, "vertex")) {
114
+ const hash = kernel.hashCode(rawVertex, require_constants.HASH_CODE_MAX);
115
+ const managedVertex = findManaged(vertexIndex, rawVertex, hash);
116
+ kernel.dispose(rawVertex);
117
+ if (!managedVertex) continue;
79
118
  let bucket = vertexToFaces.get(hash);
80
119
  if (!bucket) {
81
120
  bucket = [];
82
121
  vertexToFaces.set(hash, bucket);
83
122
  }
84
- if (!bucket.some((entry) => kernel.isSame(entry.vertex, v) && kernel.isSame(entry.face, f))) bucket.push({
85
- vertex: v,
86
- face: f
123
+ if (!bucket.some((entry) => kernel.isSame(entry.vertex, managedVertex.wrapped) && kernel.isSame(entry.face, face.wrapped))) bucket.push({
124
+ vertex: managedVertex.wrapped,
125
+ face: face.wrapped
87
126
  });
88
127
  }
89
128
  cache.vertexToFaces = vertexToFaces;
@@ -216,6 +255,7 @@ function adjacentFaces(parent, face) {
216
255
  }
217
256
  }
218
257
  }
258
+ for (const e of faceEdgeHandles) e[Symbol.dispose]();
219
259
  return wrapAll(neighborRaw, "face");
220
260
  }
221
261
  /**
@@ -240,8 +280,10 @@ function sharedEdges(face1, face2) {
240
280
  bucket.push(e2);
241
281
  }
242
282
  const shared = [];
243
- for (const e1 of edges1) if (edge2Map.get(kernel.hashCode(e1, 2147483647))?.some((e2) => kernel.isSame(e1, e2))) shared.push(e1);
244
- return wrapAll(shared, "edge");
283
+ for (const e1 of edges1) if (edge2Map.get(kernel.hashCode(e1, 2147483647))?.some((e2) => kernel.isSame(e1, e2))) shared.push(require_shapeTypes.castResultShapeWithKnownType(e1, "edge"));
284
+ else kernel.dispose(e1);
285
+ for (const e2 of edges2) kernel.dispose(e2);
286
+ return shared;
245
287
  }
246
288
  //#endregion
247
289
  Object.defineProperty(exports, "adjacentFaces", {
@@ -1,14 +1,14 @@
1
- import { Y as unregisterFromCleanup, d as createWire, nt as getKernel2D, o as createEdge, q as registerForCleanup, tt as getKernel } from "./shapeTypes-USExUZfW.js";
1
+ import { J as registerForCleanup, X as unregisterFromCleanup, f as createWire, nt as getKernel, rt as getKernel2D, s as createEdge } from "./shapeTypes-D8Fprilr.js";
2
2
  import { n as wasmIndex } from "./vec3-Dpha8d5k.js";
3
3
  import { A as ok, R as unwrap, b as err, d as validationError, h as bug, n as computationError } from "./errors-DNWJsfVU.js";
4
4
  import { r as RAD2DEG, t as DEG2RAD } from "./constants-ITRzCnCp.js";
5
5
  import { r as toVec3 } from "./types-D24Y27N0.js";
6
6
  import { r as makePlane } from "./planeOps-DSjjtrjg.js";
7
- import { _ as cast, h as uvCoordinates, i as faceGeomType, m as uvBounds, r as faceCenter } from "./faceFns-CnCX9BM_.js";
8
- import { p as getOrientation } from "./curveFns-QU4XEJMN.js";
7
+ import { _ as cast, h as uvCoordinates, i as faceGeomType, m as uvBounds, r as faceCenter } from "./faceFns-Bm3-D75M.js";
8
+ import { p as getOrientation } from "./curveFns-Y1TTdL_y.js";
9
9
  import { n as getAtOrThrow, r as lastOrThrow, t as firstOrThrow } from "./arrayAccess-DrUGPADn.js";
10
- import { r as makeFace } from "./surfaceBuilders-BPTkEKy4.js";
11
- import { _ as samePoint, b as subtract2d, l as add2d, o as normalize2d, p as distance2d, t as getSingleFace, v as scalarMultiply2d } from "./helpers-nTMuqwBX.js";
10
+ import { r as makeFace } from "./surfaceBuilders-B15_8txg.js";
11
+ import { _ as samePoint, b as subtract2d, l as add2d, o as normalize2d, p as distance2d, t as getSingleFace, v as scalarMultiply2d } from "./helpers-DzOME9UE.js";
12
12
  //#region src/2d/lib/definitions.ts
13
13
  /** Type guard that checks whether a value is a `Point2D`. */
14
14
  function isPoint2D(point) {
@@ -1,14 +1,14 @@
1
- const require_shapeTypes = require("./shapeTypes-OqAALhek.cjs");
1
+ const require_shapeTypes = require("./shapeTypes-B8a39SS3.cjs");
2
2
  const require_vec3 = require("./vec3-CFwOI0ZI.cjs");
3
3
  const require_errors = require("./errors-CXJtc4I7.cjs");
4
4
  const require_constants = require("./constants-BOVyEYGH.cjs");
5
5
  const require_types = require("./types-KjA8tY4Y.cjs");
6
6
  const require_planeOps = require("./planeOps-BA4HfgQu.cjs");
7
- const require_faceFns = require("./faceFns-DlUhG1i5.cjs");
8
- const require_curveFns = require("./curveFns-Bbq8YwiP.cjs");
7
+ const require_faceFns = require("./faceFns-BhBJ_Hsb.cjs");
8
+ const require_curveFns = require("./curveFns-Bb3wuFj4.cjs");
9
9
  const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
10
- const require_surfaceBuilders = require("./surfaceBuilders-_pFeqIF8.cjs");
11
- const require_helpers = require("./helpers-CXHMPCPr.cjs");
10
+ const require_surfaceBuilders = require("./surfaceBuilders-DUG4Y0qA.cjs");
11
+ const require_helpers = require("./helpers-DKfkqED3.cjs");
12
12
  //#region src/2d/lib/definitions.ts
13
13
  /** Type guard that checks whether a value is a `Point2D`. */
14
14
  function isPoint2D(point) {
@@ -1,6 +1,6 @@
1
1
  import { A as ok, b as err, d as validationError, t as BrepErrorCode } from "./errors-DNWJsfVU.js";
2
- import { i as CompoundBlueprint } from "./blueprintSketcher-L_UQ6PjH.js";
3
- import { t as Blueprint } from "./blueprint-Cq4SoX4f.js";
2
+ import { i as CompoundBlueprint } from "./blueprintSketcher-cgkF6uCj.js";
3
+ import { t as Blueprint } from "./blueprint-nrz4fL3I.js";
4
4
  //#region src/2d/lib/curve2dFns.ts
5
5
  /**
6
6
  * Return a reversed copy of the curve (non-mutating).
@@ -1,6 +1,6 @@
1
1
  const require_errors = require("./errors-CXJtc4I7.cjs");
2
- const require_blueprintSketcher = require("./blueprintSketcher-BbT1WvI0.cjs");
3
- const require_blueprint = require("./blueprint-8aYTu_pt.cjs");
2
+ const require_blueprintSketcher = require("./blueprintSketcher-D5AHgjkT.cjs");
3
+ const require_blueprint = require("./blueprint-qWwhQGSr.cjs");
4
4
  //#region src/2d/lib/curve2dFns.ts
5
5
  /**
6
6
  * Return a reversed copy of the curve (non-mutating).
@@ -1,10 +1,10 @@
1
- const require_shapeTypes = require("./shapeTypes-OqAALhek.cjs");
1
+ const require_shapeTypes = require("./shapeTypes-B8a39SS3.cjs");
2
2
  const require_vec3 = require("./vec3-CFwOI0ZI.cjs");
3
3
  const require_errors = require("./errors-CXJtc4I7.cjs");
4
4
  const require_constants = require("./constants-BOVyEYGH.cjs");
5
5
  const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
6
- const require_helpers = require("./helpers-CXHMPCPr.cjs");
7
- const require_blueprint = require("./blueprint-8aYTu_pt.cjs");
6
+ const require_helpers = require("./helpers-DKfkqED3.cjs");
7
+ const require_blueprint = require("./blueprint-qWwhQGSr.cjs");
8
8
  //#region node_modules/flatqueue/index.js
9
9
  /**
10
10
  * @typedef {Float64ArrayConstructor | Float32ArrayConstructor |
@@ -1,10 +1,10 @@
1
- import { nt as getKernel2D, tt as getKernel } from "./shapeTypes-USExUZfW.js";
1
+ import { nt as getKernel, rt as getKernel2D } from "./shapeTypes-D8Fprilr.js";
2
2
  import { n as wasmIndex } from "./vec3-Dpha8d5k.js";
3
3
  import { A as ok, R as unwrap, T as isOk, b as err, h as bug, n as computationError, s as safeIndex } from "./errors-DNWJsfVU.js";
4
4
  import { r as RAD2DEG, t as DEG2RAD } from "./constants-ITRzCnCp.js";
5
5
  import { t as firstOrThrow } from "./arrayAccess-DrUGPADn.js";
6
- import { _ as samePoint, b as subtract2d, d as cartesianToPolar, f as crossProduct2d, g as rotate2d, h as polarToCartesian, l as add2d, m as polarAngle2d, o as normalize2d, p as distance2d, v as scalarMultiply2d } from "./helpers-nTMuqwBX.js";
7
- import { _ as Curve2D, c as make2dCircle, f as make2dSegmentCurve, h as approximateAsBSpline, m as make2dThreePointArc, n as asSVG, o as make2dArcFromCenter, p as make2dTangentArc, r as viewbox, s as make2dBezierCurve, t as Blueprint, u as make2dEllipseArc, x as isPoint2D, y as BoundingBox2d } from "./blueprint-Cq4SoX4f.js";
6
+ import { _ as samePoint, b as subtract2d, d as cartesianToPolar, f as crossProduct2d, g as rotate2d, h as polarToCartesian, l as add2d, m as polarAngle2d, o as normalize2d, p as distance2d, v as scalarMultiply2d } from "./helpers-DzOME9UE.js";
7
+ import { _ as Curve2D, c as make2dCircle, f as make2dSegmentCurve, h as approximateAsBSpline, m as make2dThreePointArc, n as asSVG, o as make2dArcFromCenter, p as make2dTangentArc, r as viewbox, s as make2dBezierCurve, t as Blueprint, u as make2dEllipseArc, x as isPoint2D, y as BoundingBox2d } from "./blueprint-nrz4fL3I.js";
8
8
  //#region node_modules/flatqueue/index.js
9
9
  /**
10
10
  * @typedef {Float64ArrayConstructor | Float32ArrayConstructor |
@@ -1,10 +1,10 @@
1
1
  const require_vec3 = require("./vec3-CFwOI0ZI.cjs");
2
2
  const require_errors = require("./errors-CXJtc4I7.cjs");
3
3
  const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
4
- const require_surfaceBuilders = require("./surfaceBuilders-_pFeqIF8.cjs");
5
- const require_blueprintSketcher = require("./blueprintSketcher-BbT1WvI0.cjs");
6
- const require_helpers = require("./helpers-CXHMPCPr.cjs");
7
- const require_blueprint = require("./blueprint-8aYTu_pt.cjs");
4
+ const require_surfaceBuilders = require("./surfaceBuilders-DUG4Y0qA.cjs");
5
+ const require_blueprintSketcher = require("./blueprintSketcher-D5AHgjkT.cjs");
6
+ const require_helpers = require("./helpers-DKfkqED3.cjs");
7
+ const require_blueprint = require("./blueprint-qWwhQGSr.cjs");
8
8
  //#region src/2d/blueprints/cannedBlueprints.ts
9
9
  /**
10
10
  * Create a regular polygon blueprint inscribed in a circle of the given radius.
@@ -1,10 +1,10 @@
1
1
  import { n as wasmIndex } from "./vec3-Dpha8d5k.js";
2
2
  import { R as unwrap, h as bug, s as safeIndex } from "./errors-DNWJsfVU.js";
3
3
  import { r as lastOrThrow } from "./arrayAccess-DrUGPADn.js";
4
- import { v as zip } from "./surfaceBuilders-BPTkEKy4.js";
5
- import { a as Blueprints, i as CompoundBlueprint, l as intersectCurves, r as organiseBlueprints, t as BlueprintSketcher, u as Flatbush } from "./blueprintSketcher-L_UQ6PjH.js";
6
- import { _ as samePoint$1, b as subtract2d, f as crossProduct2d, s as PRECISION_INTERSECTION } from "./helpers-nTMuqwBX.js";
7
- import { b as removeDuplicatePoints, f as make2dSegmentCurve, t as Blueprint } from "./blueprint-Cq4SoX4f.js";
4
+ import { v as zip } from "./surfaceBuilders-B15_8txg.js";
5
+ import { a as Blueprints, i as CompoundBlueprint, l as intersectCurves, r as organiseBlueprints, t as BlueprintSketcher, u as Flatbush } from "./blueprintSketcher-cgkF6uCj.js";
6
+ import { _ as samePoint$1, b as subtract2d, f as crossProduct2d, s as PRECISION_INTERSECTION } from "./helpers-DzOME9UE.js";
7
+ import { b as removeDuplicatePoints, f as make2dSegmentCurve, t as Blueprint } from "./blueprint-nrz4fL3I.js";
8
8
  //#region src/2d/blueprints/cannedBlueprints.ts
9
9
  /**
10
10
  * Create a regular polygon blueprint inscribed in a circle of the given radius.
package/dist/brepjs.cjs CHANGED
@@ -1,38 +1,38 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_textBlueprints = require("./textBlueprints-BKi0ghsT.cjs");
3
- const require_shapeTypes = require("./shapeTypes-OqAALhek.cjs");
2
+ const require_textBlueprints = require("./textBlueprints-BXtV_DY6.cjs");
3
+ const require_shapeTypes = require("./shapeTypes-B8a39SS3.cjs");
4
4
  const require_occtWasmAdapter = require("./occtWasmAdapter-8wX1Z2-I.cjs");
5
5
  const require_vec3 = require("./vec3-CFwOI0ZI.cjs");
6
6
  const require_errors = require("./errors-CXJtc4I7.cjs");
7
- const require_topologyQueryFns = require("./topologyQueryFns-DK-ktEI-.cjs");
7
+ const require_topologyQueryFns = require("./topologyQueryFns-BJbOwoZm.cjs");
8
8
  const require_constants = require("./constants-BOVyEYGH.cjs");
9
9
  const require_types = require("./types-KjA8tY4Y.cjs");
10
10
  const require_vecOps = require("./vecOps-CCnJt-yH.cjs");
11
11
  const require_planeOps = require("./planeOps-BA4HfgQu.cjs");
12
- const require_faceFns = require("./faceFns-DlUhG1i5.cjs");
13
- const require_shapeFns = require("./shapeFns-7T0gykWr.cjs");
14
- const require_curveFns = require("./curveFns-Bbq8YwiP.cjs");
15
- const require_meshFns = require("./meshFns-tNFtjrAg.cjs");
12
+ const require_faceFns = require("./faceFns-BhBJ_Hsb.cjs");
13
+ const require_shapeFns = require("./shapeFns-1aqO2bz4.cjs");
14
+ const require_curveFns = require("./curveFns-Bb3wuFj4.cjs");
15
+ const require_meshFns = require("./meshFns-s-c0lABa.cjs");
16
16
  const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
17
- const require_surfaceBuilders = require("./surfaceBuilders-_pFeqIF8.cjs");
18
- const require_solidBuilders = require("./solidBuilders-oBXWp32X.cjs");
19
- const require_healingFns = require("./healingFns-DS2jVC-6.cjs");
20
- const require_threadFns = require("./threadFns-CILCsLs1.cjs");
21
- const require_blueprintSketcher = require("./blueprintSketcher-BbT1WvI0.cjs");
22
- const require_helpers = require("./helpers-CXHMPCPr.cjs");
23
- const require_drawFns = require("./drawFns-BaoKhtS2.cjs");
24
- const require_measureFns = require("./measureFns-BXpXVoE1.cjs");
25
- const require_cornerFinder = require("./cornerFinder-Dg00ADRE.cjs");
26
- const require_boolean2D = require("./boolean2D-gvWTFM1D.cjs");
27
- const require_blueprintFns = require("./blueprintFns-DeFKRkeJ.cjs");
28
- const require_importFns = require("./importFns-Rtl8_piv.cjs");
29
- const require_loftFns = require("./loftFns-CYHPZMOq.cjs");
30
- const require_cameraFns = require("./cameraFns-BgMZW_YF.cjs");
31
- const require_textMetrics = require("./textMetrics-66K6zyvX.cjs");
32
- const require_adjacencyFns = require("./adjacencyFns-BmnrcGXe.cjs");
33
- const require_refResolveFns = require("./refResolveFns-BdEmu7yh.cjs");
17
+ const require_surfaceBuilders = require("./surfaceBuilders-DUG4Y0qA.cjs");
18
+ const require_solidBuilders = require("./solidBuilders-CkkgC2se.cjs");
19
+ const require_healingFns = require("./healingFns-DoJQUwBN.cjs");
20
+ const require_threadFns = require("./threadFns-CWIlyEcP.cjs");
21
+ const require_blueprintSketcher = require("./blueprintSketcher-D5AHgjkT.cjs");
22
+ const require_helpers = require("./helpers-DKfkqED3.cjs");
23
+ const require_drawFns = require("./drawFns-Bgug3W7c.cjs");
24
+ const require_measureFns = require("./measureFns-DJ1SESSY.cjs");
25
+ const require_cornerFinder = require("./cornerFinder-BDwDNTdN.cjs");
26
+ const require_boolean2D = require("./boolean2D-Bemx5WZV.cjs");
27
+ const require_blueprintFns = require("./blueprintFns-BhiWnHuR.cjs");
28
+ const require_importFns = require("./importFns-D8i8O8di.cjs");
29
+ const require_loftFns = require("./loftFns-BJiGxTys.cjs");
30
+ const require_cameraFns = require("./cameraFns-taUY1CFZ.cjs");
31
+ const require_textMetrics = require("./textMetrics-DBdtpVNo.cjs");
32
+ const require_adjacencyFns = require("./adjacencyFns-Wc3R-UZr.cjs");
33
+ const require_refResolveFns = require("./refResolveFns-AbuzUhGC.cjs");
34
34
  const require_workerPool = require("./workerPool-D30NsiIW.cjs");
35
- const require_primitiveFns = require("./primitiveFns-CTCpyACp.cjs");
35
+ const require_primitiveFns = require("./primitiveFns-BDdThy3-.cjs");
36
36
  //#region src/topology/shapeBooleans.ts
37
37
  var BOPAlgo_GlueShift = 1;
38
38
  var BOPAlgo_GlueFull = 2;