biscuitboard 1.0.17 → 1.0.18

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.
package/dist/npm.cjs CHANGED
@@ -8658,6 +8658,8 @@ var BuildBiscuitBoardTracesSolver = class extends BaseSolver {
8658
8658
  const protectedNodeIndexes = /* @__PURE__ */ new Set();
8659
8659
  for (const route of this.routed.routes) {
8660
8660
  const demand = this.prepared.demandById.get(route.routeId);
8661
+ protectedNodeIndexes.add(demand.sourceNode);
8662
+ protectedNodeIndexes.add(demand.targetNode);
8661
8663
  for (const endpointNode of [route.nodePath[0], route.nodePath.at(-1)]) {
8662
8664
  if (endpointNode !== void 0 && endpointNode !== demand.sourceNode && endpointNode !== demand.targetNode) {
8663
8665
  protectedNodeIndexes.add(endpointNode);
@@ -11455,6 +11457,8 @@ var postProcessBiscuitBoardTracesOnce = (prepared, solution) => {
11455
11457
  const protectedJunctionKeys = /* @__PURE__ */ new Set();
11456
11458
  for (const route of solution.routes) {
11457
11459
  const demand = prepared.demandById.get(route.routeId);
11460
+ protectedJunctionKeys.add(junctionKey(prepared.nodes[demand.sourceNode]));
11461
+ protectedJunctionKeys.add(junctionKey(prepared.nodes[demand.targetNode]));
11458
11462
  for (const endpointNode of [route.nodePath[0], route.nodePath.at(-1)]) {
11459
11463
  if (endpointNode !== void 0 && endpointNode !== demand.sourceNode && endpointNode !== demand.targetNode) {
11460
11464
  protectedJunctionKeys.add(junctionKey(prepared.nodes[endpointNode]));
@@ -11723,7 +11727,13 @@ var getIndexedWireSegments = (trace) => {
11723
11727
  }
11724
11728
  return segments;
11725
11729
  };
11726
- var getProtectedJunctionKeys = (traces) => {
11730
+ var getProtectedJunctionKeys = (prepared, traces) => {
11731
+ const protectedKeys = new Set(
11732
+ prepared.demands.flatMap((demand) => [
11733
+ pointKey(prepared.nodes[demand.sourceNode]),
11734
+ pointKey(prepared.nodes[demand.targetNode])
11735
+ ])
11736
+ );
11727
11737
  const traceIndexesByPoint = /* @__PURE__ */ new Map();
11728
11738
  for (const [traceIndex, trace] of traces.entries()) {
11729
11739
  for (const point of trace.route) {
@@ -11733,9 +11743,10 @@ var getProtectedJunctionKeys = (traces) => {
11733
11743
  traceIndexesByPoint.set(pointKey(point), indexes);
11734
11744
  }
11735
11745
  }
11736
- return new Set(
11737
- [...traceIndexesByPoint.entries()].filter(([, traceIndexes]) => traceIndexes.size > 1).map(([key]) => key)
11738
- );
11746
+ for (const [key, traceIndexes] of traceIndexesByPoint) {
11747
+ if (traceIndexes.size > 1) protectedKeys.add(key);
11748
+ }
11749
+ return protectedKeys;
11739
11750
  };
11740
11751
  var routeGeometryEqual = (first, second) => first.length === second.length && first.every((point, index) => {
11741
11752
  const other = second[index];
@@ -11909,7 +11920,7 @@ var createParallelConsolidationCandidate = (prepared, solution, traceIndex, rout
11909
11920
  };
11910
11921
  var consolidateSameNetTraces = (prepared, solution, clearance) => {
11911
11922
  const traces = cloneTraces2(solution.traces);
11912
- const protectedJunctionKeys = getProtectedJunctionKeys(traces);
11923
+ const protectedJunctionKeys = getProtectedJunctionKeys(prepared, traces);
11913
11924
  let consolidationCount = 0;
11914
11925
  for (let pass = 0; pass < traces.length; pass++) {
11915
11926
  let changed = false;
@@ -12079,7 +12090,7 @@ var isManhattanCorner = (previous, corner, next) => {
12079
12090
  };
12080
12091
  var chamferTraceCorners = (prepared, solution, clearance) => {
12081
12092
  const traces = cloneTraces2(solution.traces);
12082
- const protectedJunctionKeys = getProtectedJunctionKeys(traces);
12093
+ const protectedJunctionKeys = getProtectedJunctionKeys(prepared, traces);
12083
12094
  let chamferCount = 0;
12084
12095
  for (let traceIndex = 0; traceIndex < traces.length; traceIndex++) {
12085
12096
  let route = traces[traceIndex].route;
@@ -13625,7 +13636,17 @@ var getTraceEndpoints = (trace) => {
13625
13636
  );
13626
13637
  return wires.length === 0 ? [] : [wires[0], wires.at(-1)];
13627
13638
  };
13628
- var getTraceEndpointKeys = (trace) => getTraceEndpoints(trace).map(vertexKey);
13639
+ var getDemandTerminalKeys = ({
13640
+ prepared,
13641
+ solution,
13642
+ traceIndex
13643
+ }) => {
13644
+ const demand = prepared.demandById.get(solution.routes[traceIndex].routeId);
13645
+ return [
13646
+ vertexKey(prepared.nodes[demand.sourceNode]),
13647
+ vertexKey(prepared.nodes[demand.targetNode])
13648
+ ];
13649
+ };
13629
13650
  var addSplitRatio = (segment, ratio) => {
13630
13651
  if (ratio < -EPSILON4 || ratio > 1 + EPSILON4) return;
13631
13652
  const clamped = Math.max(0, Math.min(1, ratio));
@@ -13693,8 +13714,7 @@ var buildCopperGraph = (prepared, traces) => {
13693
13714
  const graph = {
13694
13715
  vertices: /* @__PURE__ */ new Map(),
13695
13716
  edges: /* @__PURE__ */ new Map(),
13696
- adjacency: /* @__PURE__ */ new Map(),
13697
- edgeKeysByTrace: traces.map(() => /* @__PURE__ */ new Set())
13717
+ adjacency: /* @__PURE__ */ new Map()
13698
13718
  };
13699
13719
  const segments = [];
13700
13720
  for (let traceIndex = 0; traceIndex < traces.length; traceIndex++) {
@@ -13706,8 +13726,7 @@ var buildCopperGraph = (prepared, traces) => {
13706
13726
  segments.push({
13707
13727
  start: point,
13708
13728
  end: next,
13709
- splitRatios: [0, 1],
13710
- traceIndex
13729
+ splitRatios: [0, 1]
13711
13730
  });
13712
13731
  }
13713
13732
  if (point.route_type !== "through_obstacle") continue;
@@ -13740,7 +13759,6 @@ var buildCopperGraph = (prepared, traces) => {
13740
13759
  kind: "fixed_via",
13741
13760
  prefabViaId: prefabVia.prefabViaId
13742
13761
  });
13743
- graph.edgeKeysByTrace[traceIndex].add(key);
13744
13762
  }
13745
13763
  }
13746
13764
  const traceEndpoints = traces.flatMap(getTraceEndpoints);
@@ -13777,7 +13795,6 @@ var buildCopperGraph = (prepared, traces) => {
13777
13795
  cost: Math.hypot(first.x - second.x, first.y - second.y),
13778
13796
  kind: "wire"
13779
13797
  });
13780
- graph.edgeKeysByTrace[segment.traceIndex].add(key);
13781
13798
  }
13782
13799
  }
13783
13800
  finishGraph(graph);
@@ -13811,7 +13828,9 @@ var selectTerminalTree = (graph, terminalKeys) => {
13811
13828
  );
13812
13829
  }
13813
13830
  }
13814
- const parent = new Map([...graph.vertices.keys()].map((key) => [key, key]));
13831
+ const parent = new Map(
13832
+ [...graph.vertices.keys()].map((key) => [key, key])
13833
+ );
13815
13834
  const find = (key) => {
13816
13835
  const current = parent.get(key);
13817
13836
  if (current === key) return key;
@@ -13926,8 +13945,8 @@ var pathToTrace = (prepared, demand, original, graph, path, sourceKey) => {
13926
13945
  ...original,
13927
13946
  connectsTo: [
13928
13947
  .../* @__PURE__ */ new Set([
13929
- ...(original.connectsTo ?? []).filter(
13930
- (id) => !prepared.fixedViaById.has(id)
13948
+ ...[demand.sourcePointId, demand.targetPointId].filter(
13949
+ (id) => Boolean(id)
13931
13950
  ),
13932
13951
  ...usedViaIds
13933
13952
  ])
@@ -13953,23 +13972,24 @@ var pruneRedundantSameNetCopper = (prepared, solution) => {
13953
13972
  );
13954
13973
  if (!graphHasCycle(graph)) continue;
13955
13974
  const terminalKeys = indexes.flatMap(
13956
- (index) => getTraceEndpointKeys(solution.traces[index])
13975
+ (traceIndex) => getDemandTerminalKeys({ prepared, solution, traceIndex })
13957
13976
  );
13958
13977
  const selectedEdges = selectTerminalTree(graph, terminalKeys);
13959
13978
  const originalNetTraces = indexes.map((index) => traces[index]);
13960
13979
  for (let netTraceIndex = 0; netTraceIndex < indexes.length; netTraceIndex++) {
13961
- const index = indexes[netTraceIndex];
13962
- const originalUsesPrunedEdge = [
13963
- ...graph.edgeKeysByTrace[netTraceIndex]
13964
- ].some((edge) => !selectedEdges.has(edge));
13965
- if (!originalUsesPrunedEdge) continue;
13966
- const demand = prepared.demandById.get(solution.routes[index].routeId);
13967
- const [source, target] = getTraceEndpointKeys(solution.traces[index]);
13968
- if (!source || !target) continue;
13969
- traces[index] = pathToTrace(
13980
+ const traceIndex = indexes[netTraceIndex];
13981
+ const demand = prepared.demandById.get(
13982
+ solution.routes[traceIndex].routeId
13983
+ );
13984
+ const [source, target] = getDemandTerminalKeys({
13985
+ prepared,
13986
+ solution,
13987
+ traceIndex
13988
+ });
13989
+ traces[traceIndex] = pathToTrace(
13970
13990
  prepared,
13971
13991
  demand,
13972
- solution.traces[index],
13992
+ solution.traces[traceIndex],
13973
13993
  graph,
13974
13994
  findTreePath(graph, selectedEdges, source, target),
13975
13995
  source
@@ -14395,6 +14415,7 @@ var BiscuitBoard = ({
14395
14415
  autorouterOptions,
14396
14416
  minTraceWidth,
14397
14417
  nominalTraceWidth = 0.3,
14418
+ autorouterEdgeClearance,
14398
14419
  routingDisabled = false
14399
14420
  }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
14400
14421
  "board",
@@ -14412,7 +14433,7 @@ var BiscuitBoard = ({
14412
14433
  autorouter: autorouter ?? createPrefabricatedViaAutorouter({
14413
14434
  width: BISCUIT_BOARD_WIDTH,
14414
14435
  height: BISCUIT_BOARD_HEIGHT,
14415
- edgeClearance: BISCUIT_BOARD_EDGE_CLEARANCE,
14436
+ edgeClearance: autorouterEdgeClearance ?? BISCUIT_BOARD_EDGE_CLEARANCE,
14416
14437
  options: autorouterOptions,
14417
14438
  minimumTraceWidth: minTraceWidth,
14418
14439
  nominalTraceWidth