biscuitboard 1.0.16 → 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.d.cts CHANGED
@@ -221,6 +221,8 @@ interface BiscuitBoardProps {
221
221
  minTraceWidth?: number;
222
222
  /** Preferred post-route trace width in millimeters. Defaults to 0.3 mm. */
223
223
  nominalTraceWidth?: number;
224
+ /** Optional extra autorouter inset without changing the board's DRC rule. */
225
+ autorouterEdgeClearance?: number;
224
226
  routingDisabled?: boolean;
225
227
  }
226
228
  /**
@@ -228,7 +230,7 @@ interface BiscuitBoardProps {
228
230
  * Child components use ordinary tscircuit TSX; the default local autorouter
229
231
  * can change layers only at the checked-in prefabricated via positions.
230
232
  */
231
- declare const BiscuitBoard: ({ children, autorouter, autorouterOptions, minTraceWidth, nominalTraceWidth, routingDisabled, }: BiscuitBoardProps) => react.JSX.Element;
233
+ declare const BiscuitBoard: ({ children, autorouter, autorouterOptions, minTraceWidth, nominalTraceWidth, autorouterEdgeClearance, routingDisabled, }: BiscuitBoardProps) => react.JSX.Element;
232
234
 
233
235
  declare const BOOSTERPACK_CLAD_WIDTH = 75;
234
236
  declare const BOOSTERPACK_CLAD_HEIGHT = 55;
package/dist/npm.d.ts CHANGED
@@ -221,6 +221,8 @@ interface BiscuitBoardProps {
221
221
  minTraceWidth?: number;
222
222
  /** Preferred post-route trace width in millimeters. Defaults to 0.3 mm. */
223
223
  nominalTraceWidth?: number;
224
+ /** Optional extra autorouter inset without changing the board's DRC rule. */
225
+ autorouterEdgeClearance?: number;
224
226
  routingDisabled?: boolean;
225
227
  }
226
228
  /**
@@ -228,7 +230,7 @@ interface BiscuitBoardProps {
228
230
  * Child components use ordinary tscircuit TSX; the default local autorouter
229
231
  * can change layers only at the checked-in prefabricated via positions.
230
232
  */
231
- declare const BiscuitBoard: ({ children, autorouter, autorouterOptions, minTraceWidth, nominalTraceWidth, routingDisabled, }: BiscuitBoardProps) => react.JSX.Element;
233
+ declare const BiscuitBoard: ({ children, autorouter, autorouterOptions, minTraceWidth, nominalTraceWidth, autorouterEdgeClearance, routingDisabled, }: BiscuitBoardProps) => react.JSX.Element;
232
234
 
233
235
  declare const BOOSTERPACK_CLAD_WIDTH = 75;
234
236
  declare const BOOSTERPACK_CLAD_HEIGHT = 55;
package/dist/npm.js CHANGED
@@ -8516,6 +8516,8 @@ var BuildBiscuitBoardTracesSolver = class extends BaseSolver {
8516
8516
  const protectedNodeIndexes = /* @__PURE__ */ new Set();
8517
8517
  for (const route of this.routed.routes) {
8518
8518
  const demand = this.prepared.demandById.get(route.routeId);
8519
+ protectedNodeIndexes.add(demand.sourceNode);
8520
+ protectedNodeIndexes.add(demand.targetNode);
8519
8521
  for (const endpointNode of [route.nodePath[0], route.nodePath.at(-1)]) {
8520
8522
  if (endpointNode !== void 0 && endpointNode !== demand.sourceNode && endpointNode !== demand.targetNode) {
8521
8523
  protectedNodeIndexes.add(endpointNode);
@@ -11313,6 +11315,8 @@ var postProcessBiscuitBoardTracesOnce = (prepared, solution) => {
11313
11315
  const protectedJunctionKeys = /* @__PURE__ */ new Set();
11314
11316
  for (const route of solution.routes) {
11315
11317
  const demand = prepared.demandById.get(route.routeId);
11318
+ protectedJunctionKeys.add(junctionKey(prepared.nodes[demand.sourceNode]));
11319
+ protectedJunctionKeys.add(junctionKey(prepared.nodes[demand.targetNode]));
11316
11320
  for (const endpointNode of [route.nodePath[0], route.nodePath.at(-1)]) {
11317
11321
  if (endpointNode !== void 0 && endpointNode !== demand.sourceNode && endpointNode !== demand.targetNode) {
11318
11322
  protectedJunctionKeys.add(junctionKey(prepared.nodes[endpointNode]));
@@ -11581,7 +11585,13 @@ var getIndexedWireSegments = (trace) => {
11581
11585
  }
11582
11586
  return segments;
11583
11587
  };
11584
- var getProtectedJunctionKeys = (traces) => {
11588
+ var getProtectedJunctionKeys = (prepared, traces) => {
11589
+ const protectedKeys = new Set(
11590
+ prepared.demands.flatMap((demand) => [
11591
+ pointKey(prepared.nodes[demand.sourceNode]),
11592
+ pointKey(prepared.nodes[demand.targetNode])
11593
+ ])
11594
+ );
11585
11595
  const traceIndexesByPoint = /* @__PURE__ */ new Map();
11586
11596
  for (const [traceIndex, trace] of traces.entries()) {
11587
11597
  for (const point of trace.route) {
@@ -11591,9 +11601,10 @@ var getProtectedJunctionKeys = (traces) => {
11591
11601
  traceIndexesByPoint.set(pointKey(point), indexes);
11592
11602
  }
11593
11603
  }
11594
- return new Set(
11595
- [...traceIndexesByPoint.entries()].filter(([, traceIndexes]) => traceIndexes.size > 1).map(([key]) => key)
11596
- );
11604
+ for (const [key, traceIndexes] of traceIndexesByPoint) {
11605
+ if (traceIndexes.size > 1) protectedKeys.add(key);
11606
+ }
11607
+ return protectedKeys;
11597
11608
  };
11598
11609
  var routeGeometryEqual = (first, second) => first.length === second.length && first.every((point, index) => {
11599
11610
  const other = second[index];
@@ -11767,7 +11778,7 @@ var createParallelConsolidationCandidate = (prepared, solution, traceIndex, rout
11767
11778
  };
11768
11779
  var consolidateSameNetTraces = (prepared, solution, clearance) => {
11769
11780
  const traces = cloneTraces2(solution.traces);
11770
- const protectedJunctionKeys = getProtectedJunctionKeys(traces);
11781
+ const protectedJunctionKeys = getProtectedJunctionKeys(prepared, traces);
11771
11782
  let consolidationCount = 0;
11772
11783
  for (let pass = 0; pass < traces.length; pass++) {
11773
11784
  let changed = false;
@@ -11937,7 +11948,7 @@ var isManhattanCorner = (previous, corner, next) => {
11937
11948
  };
11938
11949
  var chamferTraceCorners = (prepared, solution, clearance) => {
11939
11950
  const traces = cloneTraces2(solution.traces);
11940
- const protectedJunctionKeys = getProtectedJunctionKeys(traces);
11951
+ const protectedJunctionKeys = getProtectedJunctionKeys(prepared, traces);
11941
11952
  let chamferCount = 0;
11942
11953
  for (let traceIndex = 0; traceIndex < traces.length; traceIndex++) {
11943
11954
  let route = traces[traceIndex].route;
@@ -13483,7 +13494,17 @@ var getTraceEndpoints = (trace) => {
13483
13494
  );
13484
13495
  return wires.length === 0 ? [] : [wires[0], wires.at(-1)];
13485
13496
  };
13486
- var getTraceEndpointKeys = (trace) => getTraceEndpoints(trace).map(vertexKey);
13497
+ var getDemandTerminalKeys = ({
13498
+ prepared,
13499
+ solution,
13500
+ traceIndex
13501
+ }) => {
13502
+ const demand = prepared.demandById.get(solution.routes[traceIndex].routeId);
13503
+ return [
13504
+ vertexKey(prepared.nodes[demand.sourceNode]),
13505
+ vertexKey(prepared.nodes[demand.targetNode])
13506
+ ];
13507
+ };
13487
13508
  var addSplitRatio = (segment, ratio) => {
13488
13509
  if (ratio < -EPSILON4 || ratio > 1 + EPSILON4) return;
13489
13510
  const clamped = Math.max(0, Math.min(1, ratio));
@@ -13551,8 +13572,7 @@ var buildCopperGraph = (prepared, traces) => {
13551
13572
  const graph = {
13552
13573
  vertices: /* @__PURE__ */ new Map(),
13553
13574
  edges: /* @__PURE__ */ new Map(),
13554
- adjacency: /* @__PURE__ */ new Map(),
13555
- edgeKeysByTrace: traces.map(() => /* @__PURE__ */ new Set())
13575
+ adjacency: /* @__PURE__ */ new Map()
13556
13576
  };
13557
13577
  const segments = [];
13558
13578
  for (let traceIndex = 0; traceIndex < traces.length; traceIndex++) {
@@ -13564,8 +13584,7 @@ var buildCopperGraph = (prepared, traces) => {
13564
13584
  segments.push({
13565
13585
  start: point,
13566
13586
  end: next,
13567
- splitRatios: [0, 1],
13568
- traceIndex
13587
+ splitRatios: [0, 1]
13569
13588
  });
13570
13589
  }
13571
13590
  if (point.route_type !== "through_obstacle") continue;
@@ -13598,7 +13617,6 @@ var buildCopperGraph = (prepared, traces) => {
13598
13617
  kind: "fixed_via",
13599
13618
  prefabViaId: prefabVia.prefabViaId
13600
13619
  });
13601
- graph.edgeKeysByTrace[traceIndex].add(key);
13602
13620
  }
13603
13621
  }
13604
13622
  const traceEndpoints = traces.flatMap(getTraceEndpoints);
@@ -13635,7 +13653,6 @@ var buildCopperGraph = (prepared, traces) => {
13635
13653
  cost: Math.hypot(first.x - second.x, first.y - second.y),
13636
13654
  kind: "wire"
13637
13655
  });
13638
- graph.edgeKeysByTrace[segment.traceIndex].add(key);
13639
13656
  }
13640
13657
  }
13641
13658
  finishGraph(graph);
@@ -13669,7 +13686,9 @@ var selectTerminalTree = (graph, terminalKeys) => {
13669
13686
  );
13670
13687
  }
13671
13688
  }
13672
- const parent = new Map([...graph.vertices.keys()].map((key) => [key, key]));
13689
+ const parent = new Map(
13690
+ [...graph.vertices.keys()].map((key) => [key, key])
13691
+ );
13673
13692
  const find = (key) => {
13674
13693
  const current = parent.get(key);
13675
13694
  if (current === key) return key;
@@ -13784,8 +13803,8 @@ var pathToTrace = (prepared, demand, original, graph, path, sourceKey) => {
13784
13803
  ...original,
13785
13804
  connectsTo: [
13786
13805
  .../* @__PURE__ */ new Set([
13787
- ...(original.connectsTo ?? []).filter(
13788
- (id) => !prepared.fixedViaById.has(id)
13806
+ ...[demand.sourcePointId, demand.targetPointId].filter(
13807
+ (id) => Boolean(id)
13789
13808
  ),
13790
13809
  ...usedViaIds
13791
13810
  ])
@@ -13811,23 +13830,24 @@ var pruneRedundantSameNetCopper = (prepared, solution) => {
13811
13830
  );
13812
13831
  if (!graphHasCycle(graph)) continue;
13813
13832
  const terminalKeys = indexes.flatMap(
13814
- (index) => getTraceEndpointKeys(solution.traces[index])
13833
+ (traceIndex) => getDemandTerminalKeys({ prepared, solution, traceIndex })
13815
13834
  );
13816
13835
  const selectedEdges = selectTerminalTree(graph, terminalKeys);
13817
13836
  const originalNetTraces = indexes.map((index) => traces[index]);
13818
13837
  for (let netTraceIndex = 0; netTraceIndex < indexes.length; netTraceIndex++) {
13819
- const index = indexes[netTraceIndex];
13820
- const originalUsesPrunedEdge = [
13821
- ...graph.edgeKeysByTrace[netTraceIndex]
13822
- ].some((edge) => !selectedEdges.has(edge));
13823
- if (!originalUsesPrunedEdge) continue;
13824
- const demand = prepared.demandById.get(solution.routes[index].routeId);
13825
- const [source, target] = getTraceEndpointKeys(solution.traces[index]);
13826
- if (!source || !target) continue;
13827
- traces[index] = pathToTrace(
13838
+ const traceIndex = indexes[netTraceIndex];
13839
+ const demand = prepared.demandById.get(
13840
+ solution.routes[traceIndex].routeId
13841
+ );
13842
+ const [source, target] = getDemandTerminalKeys({
13843
+ prepared,
13844
+ solution,
13845
+ traceIndex
13846
+ });
13847
+ traces[traceIndex] = pathToTrace(
13828
13848
  prepared,
13829
13849
  demand,
13830
- solution.traces[index],
13850
+ solution.traces[traceIndex],
13831
13851
  graph,
13832
13852
  findTreePath(graph, selectedEdges, source, target),
13833
13853
  source
@@ -14253,6 +14273,7 @@ var BiscuitBoard = ({
14253
14273
  autorouterOptions,
14254
14274
  minTraceWidth,
14255
14275
  nominalTraceWidth = 0.3,
14276
+ autorouterEdgeClearance,
14256
14277
  routingDisabled = false
14257
14278
  }) => /* @__PURE__ */ jsxs(
14258
14279
  "board",
@@ -14270,7 +14291,7 @@ var BiscuitBoard = ({
14270
14291
  autorouter: autorouter ?? createPrefabricatedViaAutorouter({
14271
14292
  width: BISCUIT_BOARD_WIDTH,
14272
14293
  height: BISCUIT_BOARD_HEIGHT,
14273
- edgeClearance: BISCUIT_BOARD_EDGE_CLEARANCE,
14294
+ edgeClearance: autorouterEdgeClearance ?? BISCUIT_BOARD_EDGE_CLEARANCE,
14274
14295
  options: autorouterOptions,
14275
14296
  minimumTraceWidth: minTraceWidth,
14276
14297
  nominalTraceWidth