@tscircuit/core 0.0.975 → 0.0.977

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/index.d.ts CHANGED
@@ -355,6 +355,7 @@ interface ISubcircuit extends PrimitiveComponent {
355
355
  getNextAvailableName(elm: PrimitiveComponent): string;
356
356
  _getSubcircuitLayerCount(): number;
357
357
  subcircuit_id: string | null;
358
+ getNormalComponentNameMap?: () => Map<string, NormalComponent[]>;
358
359
  }
359
360
 
360
361
  interface IGroup extends PrimitiveComponent {
@@ -1369,6 +1370,12 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
1369
1370
  schematic_group_id: string | null;
1370
1371
  subcircuit_id: string | null;
1371
1372
  _hasStartedAsyncAutorouting: boolean;
1373
+ private _normalComponentNameMap;
1374
+ /**
1375
+ * Returns a cached map of component names to NormalComponent instances within this subcircuit.
1376
+ * The map is built lazily on first access and cached for subsequent calls.
1377
+ */
1378
+ getNormalComponentNameMap(): Map<string, NormalComponent[]>;
1372
1379
  _asyncAutoroutingResult: {
1373
1380
  output_simple_route_json?: SimpleRouteJson;
1374
1381
  output_pcb_traces?: (PcbTrace$1 | PcbVia)[];
package/dist/index.js CHANGED
@@ -2355,10 +2355,10 @@ var SmtPad = class extends PrimitiveComponent2 {
2355
2355
  pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
2356
2356
  });
2357
2357
  } else if (props.shape === "polygon") {
2358
- const transformedPoints = props.points.map((point2) => {
2358
+ const transformedPoints = props.points.map((point4) => {
2359
2359
  const transformed = applyToPoint2(globalTransform, {
2360
- x: distance.parse(point2.x),
2361
- y: distance.parse(point2.y)
2360
+ x: distance.parse(point4.x),
2361
+ y: distance.parse(point4.y)
2362
2362
  });
2363
2363
  return {
2364
2364
  x: transformed.x,
@@ -2590,18 +2590,18 @@ var SilkscreenPath = class extends PrimitiveComponent2 {
2590
2590
  if (!currentPath) return;
2591
2591
  let currentCenterX = 0;
2592
2592
  let currentCenterY = 0;
2593
- for (const point2 of currentPath.route) {
2594
- currentCenterX += point2.x;
2595
- currentCenterY += point2.y;
2593
+ for (const point4 of currentPath.route) {
2594
+ currentCenterX += point4.x;
2595
+ currentCenterY += point4.y;
2596
2596
  }
2597
2597
  currentCenterX /= currentPath.route.length;
2598
2598
  currentCenterY /= currentPath.route.length;
2599
2599
  const offsetX = newCenter.x - currentCenterX;
2600
2600
  const offsetY = newCenter.y - currentCenterY;
2601
- const newRoute = currentPath.route.map((point2) => ({
2602
- ...point2,
2603
- x: point2.x + offsetX,
2604
- y: point2.y + offsetY
2601
+ const newRoute = currentPath.route.map((point4) => ({
2602
+ ...point4,
2603
+ x: point4.x + offsetX,
2604
+ y: point4.y + offsetY
2605
2605
  }));
2606
2606
  db.pcb_silkscreen_path.update(this.pcb_silkscreen_path_id, {
2607
2607
  route: newRoute
@@ -2631,11 +2631,11 @@ var SilkscreenPath = class extends PrimitiveComponent2 {
2631
2631
  return { width: 0, height: 0 };
2632
2632
  }
2633
2633
  let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
2634
- for (const point2 of props.route) {
2635
- minX = Math.min(minX, point2.x);
2636
- maxX = Math.max(maxX, point2.x);
2637
- minY = Math.min(minY, point2.y);
2638
- maxY = Math.max(maxY, point2.y);
2634
+ for (const point4 of props.route) {
2635
+ minX = Math.min(minX, point4.x);
2636
+ maxX = Math.max(maxX, point4.x);
2637
+ minY = Math.min(minY, point4.y);
2638
+ maxY = Math.max(maxY, point4.y);
2639
2639
  }
2640
2640
  return {
2641
2641
  width: maxX - minX,
@@ -2671,14 +2671,14 @@ var PcbTrace = class extends PrimitiveComponent2 {
2671
2671
  const subcircuit = this.getSubcircuit();
2672
2672
  const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
2673
2673
  const parentTransform = this._computePcbGlobalTransformBeforeLayout();
2674
- const transformedRoute = props.route.map((point2) => {
2675
- const { x, y, ...restOfPoint } = point2;
2674
+ const transformedRoute = props.route.map((point4) => {
2675
+ const { x, y, ...restOfPoint } = point4;
2676
2676
  const transformedPoint = applyToPoint4(parentTransform, { x, y });
2677
- if (point2.route_type === "wire" && point2.layer) {
2677
+ if (point4.route_type === "wire" && point4.layer) {
2678
2678
  return {
2679
2679
  ...transformedPoint,
2680
2680
  ...restOfPoint,
2681
- layer: maybeFlipLayer(point2.layer)
2681
+ layer: maybeFlipLayer(point4.layer)
2682
2682
  };
2683
2683
  }
2684
2684
  return { ...transformedPoint, ...restOfPoint };
@@ -2698,16 +2698,16 @@ var PcbTrace = class extends PrimitiveComponent2 {
2698
2698
  return { width: 0, height: 0 };
2699
2699
  }
2700
2700
  let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
2701
- for (const point2 of props.route) {
2702
- minX = Math.min(minX, point2.x);
2703
- maxX = Math.max(maxX, point2.x);
2704
- minY = Math.min(minY, point2.y);
2705
- maxY = Math.max(maxY, point2.y);
2706
- if (point2.route_type === "wire") {
2707
- minX = Math.min(minX, point2.x - point2.width / 2);
2708
- maxX = Math.max(maxX, point2.x + point2.width / 2);
2709
- minY = Math.min(minY, point2.y - point2.width / 2);
2710
- maxY = Math.max(maxY, point2.y + point2.width / 2);
2701
+ for (const point4 of props.route) {
2702
+ minX = Math.min(minX, point4.x);
2703
+ maxX = Math.max(maxX, point4.x);
2704
+ minY = Math.min(minY, point4.y);
2705
+ maxY = Math.max(maxY, point4.y);
2706
+ if (point4.route_type === "wire") {
2707
+ minX = Math.min(minX, point4.x - point4.width / 2);
2708
+ maxX = Math.max(maxX, point4.x + point4.width / 2);
2709
+ minY = Math.min(minY, point4.y - point4.width / 2);
2710
+ maxY = Math.max(maxY, point4.y + point4.width / 2);
2711
2711
  }
2712
2712
  }
2713
2713
  if (minX === Infinity || maxX === -Infinity || minY === Infinity || maxY === -Infinity) {
@@ -2974,9 +2974,9 @@ var PlatedHole = class extends PrimitiveComponent2 {
2974
2974
  });
2975
2975
  this.pcb_plated_hole_id = pcb_plated_hole.pcb_plated_hole_id;
2976
2976
  } else if (props.shape === "hole_with_polygon_pad") {
2977
- const padOutline = (props.padOutline || []).map((point2) => {
2978
- const x = typeof point2.x === "number" ? point2.x : parseFloat(String(point2.x));
2979
- const y = typeof point2.y === "number" ? point2.y : parseFloat(String(point2.y));
2977
+ const padOutline = (props.padOutline || []).map((point4) => {
2978
+ const x = typeof point4.x === "number" ? point4.x : parseFloat(String(point4.x));
2979
+ const y = typeof point4.y === "number" ? point4.y : parseFloat(String(point4.y));
2980
2980
  return {
2981
2981
  x,
2982
2982
  y
@@ -3395,11 +3395,11 @@ var Cutout = class extends PrimitiveComponent2 {
3395
3395
  if (props.shape === "polygon") {
3396
3396
  if (props.points.length === 0) return { width: 0, height: 0 };
3397
3397
  let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
3398
- for (const point2 of props.points) {
3399
- minX = Math.min(minX, point2.x);
3400
- maxX = Math.max(maxX, point2.x);
3401
- minY = Math.min(minY, point2.y);
3402
- maxY = Math.max(maxY, point2.y);
3398
+ for (const point4 of props.points) {
3399
+ minX = Math.min(minX, point4.x);
3400
+ maxX = Math.max(maxX, point4.x);
3401
+ minY = Math.min(minY, point4.y);
3402
+ maxY = Math.max(maxY, point4.y);
3403
3403
  }
3404
3404
  return { width: maxX - minX, height: maxY - minY };
3405
3405
  }
@@ -3438,11 +3438,11 @@ var Cutout = class extends PrimitiveComponent2 {
3438
3438
  } else if (cutout.shape === "polygon") {
3439
3439
  if (cutout.points.length === 0) return super._getPcbCircuitJsonBounds();
3440
3440
  let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
3441
- for (const point2 of cutout.points) {
3442
- minX = Math.min(minX, point2.x);
3443
- maxX = Math.max(maxX, point2.x);
3444
- minY = Math.min(minY, point2.y);
3445
- maxY = Math.max(maxY, point2.y);
3441
+ for (const point4 of cutout.points) {
3442
+ minX = Math.min(minX, point4.x);
3443
+ maxX = Math.max(maxX, point4.x);
3444
+ minY = Math.min(minY, point4.y);
3445
+ maxY = Math.max(maxY, point4.y);
3446
3446
  }
3447
3447
  return {
3448
3448
  center: { x: (minX + maxX) / 2, y: (minY + maxY) / 2 },
@@ -5485,13 +5485,13 @@ var getDistance = (a, b) => {
5485
5485
  const bPos = "_getGlobalPcbPositionBeforeLayout" in b ? b._getGlobalPcbPositionBeforeLayout() : b;
5486
5486
  return Math.sqrt((aPos.x - bPos.x) ** 2 + (aPos.y - bPos.y) ** 2);
5487
5487
  };
5488
- function getClosest(point2, candidates) {
5488
+ function getClosest(point4, candidates) {
5489
5489
  if (candidates.length === 0)
5490
5490
  throw new Error("No candidates given to getClosest method");
5491
5491
  let closest = candidates[0];
5492
5492
  let closestDist = Infinity;
5493
5493
  for (const candidate of candidates) {
5494
- const dist = getDistance(point2, candidate);
5494
+ const dist = getDistance(point4, candidate);
5495
5495
  if (dist < closestDist) {
5496
5496
  closest = candidate;
5497
5497
  closestDist = dist;
@@ -5625,24 +5625,24 @@ var isRouteOutsideBoard = (mergedRoute, { db }) => {
5625
5625
  const pcbBoard = db.pcb_board.list()[0];
5626
5626
  if (pcbBoard.outline) {
5627
5627
  const boardOutline = pcbBoard.outline;
5628
- const isInsidePolygon = (point2, polygon) => {
5628
+ const isInsidePolygon = (point4, polygon) => {
5629
5629
  let inside = false;
5630
5630
  for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
5631
5631
  const xi = polygon[i].x, yi = polygon[i].y;
5632
5632
  const xj = polygon[j].x, yj = polygon[j].y;
5633
- const intersect = yi > point2.y !== yj > point2.y && point2.x < (xj - xi) * (point2.y - yi) / (yj - yi) + xi;
5633
+ const intersect = yi > point4.y !== yj > point4.y && point4.x < (xj - xi) * (point4.y - yi) / (yj - yi) + xi;
5634
5634
  if (intersect) inside = !inside;
5635
5635
  }
5636
5636
  return inside;
5637
5637
  };
5638
- return mergedRoute.some((point2) => !isInsidePolygon(point2, boardOutline));
5638
+ return mergedRoute.some((point4) => !isInsidePolygon(point4, boardOutline));
5639
5639
  }
5640
5640
  const boardWidth = pcbBoard.width;
5641
5641
  const boardHeight = pcbBoard.height;
5642
5642
  const boardCenterX = pcbBoard.center.x;
5643
5643
  const boardCenterY = pcbBoard.center.y;
5644
- const outsideBoard = mergedRoute.some((point2) => {
5645
- return point2.x < boardCenterX - boardWidth / 2 || point2.y < boardCenterY - boardHeight / 2 || point2.x > boardCenterX + boardWidth / 2 || point2.y > boardCenterY + boardHeight / 2;
5644
+ const outsideBoard = mergedRoute.some((point4) => {
5645
+ return point4.x < boardCenterX - boardWidth / 2 || point4.y < boardCenterY - boardHeight / 2 || point4.x > boardCenterX + boardWidth / 2 || point4.y > boardCenterY + boardHeight / 2;
5646
5646
  });
5647
5647
  return outsideBoard;
5648
5648
  };
@@ -6224,12 +6224,12 @@ var createSchematicTraceCrossingSegments = ({
6224
6224
 
6225
6225
  // lib/components/primitive-components/Trace/trace-utils/create-schematic-trace-junctions.ts
6226
6226
  var TOLERANCE = 1e-3;
6227
- var isPointWithinEdge = (point2, edge) => {
6227
+ var isPointWithinEdge = (point4, edge) => {
6228
6228
  const minX = Math.min(edge.from.x, edge.to.x);
6229
6229
  const maxX = Math.max(edge.from.x, edge.to.x);
6230
6230
  const minY = Math.min(edge.from.y, edge.to.y);
6231
6231
  const maxY = Math.max(edge.from.y, edge.to.y);
6232
- return point2.x >= minX && point2.x <= maxX && point2.y >= minY && point2.y <= maxY;
6232
+ return point4.x >= minX && point4.x <= maxX && point4.y >= minY && point4.y <= maxY;
6233
6233
  };
6234
6234
  var getEdgeOrientation = (edge) => {
6235
6235
  const isVertical = Math.abs(edge.from.x - edge.to.x) < TOLERANCE;
@@ -6837,15 +6837,15 @@ import { getFullConnectivityMapFromCircuitJson } from "circuit-json-to-connectiv
6837
6837
  function getTraceLength(route) {
6838
6838
  let totalLength = 0;
6839
6839
  for (let i = 0; i < route.length; i++) {
6840
- const point2 = route[i];
6841
- if (point2.route_type === "wire") {
6840
+ const point4 = route[i];
6841
+ if (point4.route_type === "wire") {
6842
6842
  const nextPoint = route[i + 1];
6843
6843
  if (nextPoint) {
6844
- const dx = nextPoint.x - point2.x;
6845
- const dy = nextPoint.y - point2.y;
6844
+ const dx = nextPoint.x - point4.x;
6845
+ const dy = nextPoint.y - point4.y;
6846
6846
  totalLength += Math.sqrt(dx * dx + dy * dy);
6847
6847
  }
6848
- } else if (point2.route_type === "via") {
6848
+ } else if (point4.route_type === "via") {
6849
6849
  totalLength += 1.6;
6850
6850
  }
6851
6851
  }
@@ -7155,17 +7155,17 @@ function Trace_doInitialPcbTraceRender(trace) {
7155
7155
  });
7156
7156
  trace._portsRoutedOnPcb = ports;
7157
7157
  trace.pcb_trace_id = pcb_trace.pcb_trace_id;
7158
- for (const point2 of mergedRoute) {
7159
- if (point2.route_type === "via") {
7158
+ for (const point4 of mergedRoute) {
7159
+ if (point4.route_type === "via") {
7160
7160
  db.pcb_via.insert({
7161
7161
  pcb_trace_id: pcb_trace.pcb_trace_id,
7162
- x: point2.x,
7163
- y: point2.y,
7162
+ x: point4.x,
7163
+ y: point4.y,
7164
7164
  hole_diameter: holeDiameter,
7165
7165
  outer_diameter: padDiameter,
7166
- layers: [point2.from_layer, point2.to_layer],
7167
- from_layer: point2.from_layer,
7168
- to_layer: point2.to_layer
7166
+ layers: [point4.from_layer, point4.to_layer],
7167
+ from_layer: point4.from_layer,
7168
+ to_layer: point4.to_layer
7169
7169
  });
7170
7170
  }
7171
7171
  }
@@ -8551,11 +8551,10 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
8551
8551
  doInitialSourceNameDuplicateComponentRemoval() {
8552
8552
  if (!this.name) return;
8553
8553
  const root = this.root;
8554
- const componentsWithSameName = this.getSubcircuit().selectAll(
8555
- `.${this.name}`
8556
- );
8554
+ const nameMap = this.getSubcircuit().getNormalComponentNameMap?.();
8555
+ const componentsWithSameName = nameMap?.get(this.props.name) ?? [];
8557
8556
  const conflictingComponents = componentsWithSameName.filter(
8558
- (component) => component !== this && component._isNormalComponent && component.renderPhaseStates?.SourceNameDuplicateComponentRemoval?.initialized
8557
+ (component) => component !== this && component.renderPhaseStates.SourceNameDuplicateComponentRemoval.initialized
8559
8558
  );
8560
8559
  if (conflictingComponents.length > 0) {
8561
8560
  const pcbPosition = this._getGlobalPcbPositionBeforeLayout();
@@ -10550,7 +10549,7 @@ var getSimpleRouteJsonFromCircuitJson = ({
10550
10549
  layerCount: board?.num_layers ?? 2,
10551
10550
  minTraceWidth,
10552
10551
  nominalTraceWidth,
10553
- outline: board?.outline?.map((point2) => ({ ...point2 }))
10552
+ outline: board?.outline?.map((point4) => ({ ...point4 }))
10554
10553
  },
10555
10554
  connMap
10556
10555
  };
@@ -14246,16 +14245,16 @@ function splitRouteAtJumperPads(route, padInfos) {
14246
14245
  const segments = [];
14247
14246
  let currentSegment = [];
14248
14247
  for (let i = 0; i < route.length; i++) {
14249
- const point2 = route[i];
14250
- currentSegment.push(point2);
14251
- if (point2.route_type === "wire" && i > 0 && i < route.length - 1) {
14252
- const padInfo = findJumperPortContainingPoint(padInfos, point2.x, point2.y);
14248
+ const point4 = route[i];
14249
+ currentSegment.push(point4);
14250
+ if (point4.route_type === "wire" && i > 0 && i < route.length - 1) {
14251
+ const padInfo = findJumperPortContainingPoint(padInfos, point4.x, point4.y);
14253
14252
  if (padInfo) {
14254
- if (!point2.end_pcb_port_id) {
14255
- point2.end_pcb_port_id = padInfo.pcb_port_id;
14253
+ if (!point4.end_pcb_port_id) {
14254
+ point4.end_pcb_port_id = padInfo.pcb_port_id;
14256
14255
  }
14257
14256
  segments.push(currentSegment);
14258
- const newStartPoint = { ...point2 };
14257
+ const newStartPoint = { ...point4 };
14259
14258
  delete newStartPoint.end_pcb_port_id;
14260
14259
  if (!newStartPoint.start_pcb_port_id) {
14261
14260
  newStartPoint.start_pcb_port_id = padInfo.pcb_port_id;
@@ -14312,6 +14311,35 @@ var Group6 = class extends NormalComponent3 {
14312
14311
  schematic_group_id = null;
14313
14312
  subcircuit_id = null;
14314
14313
  _hasStartedAsyncAutorouting = false;
14314
+ _normalComponentNameMap = null;
14315
+ /**
14316
+ * Returns a cached map of component names to NormalComponent instances within this subcircuit.
14317
+ * The map is built lazily on first access and cached for subsequent calls.
14318
+ */
14319
+ getNormalComponentNameMap() {
14320
+ if (this._normalComponentNameMap) {
14321
+ return this._normalComponentNameMap;
14322
+ }
14323
+ const nameMap = /* @__PURE__ */ new Map();
14324
+ const collectNamedComponents = (component) => {
14325
+ if (component._isNormalComponent && component.name) {
14326
+ const componentsWithSameName = nameMap.get(component.name);
14327
+ if (componentsWithSameName) {
14328
+ componentsWithSameName.push(component);
14329
+ } else {
14330
+ nameMap.set(component.name, [component]);
14331
+ }
14332
+ }
14333
+ for (const child of component.children) {
14334
+ if (!child.isSubcircuit) collectNamedComponents(child);
14335
+ }
14336
+ };
14337
+ for (const child of this.children) {
14338
+ if (!child.isSubcircuit) collectNamedComponents(child);
14339
+ }
14340
+ this._normalComponentNameMap = nameMap;
14341
+ return nameMap;
14342
+ }
14315
14343
  _asyncAutoroutingResult = null;
14316
14344
  get config() {
14317
14345
  return {
@@ -14364,9 +14392,9 @@ var Group6 = class extends NormalComponent3 {
14364
14392
  const { _parsedProps: props } = this;
14365
14393
  const groupProps2 = props;
14366
14394
  const hasOutline = groupProps2.outline && groupProps2.outline.length > 0;
14367
- const numericOutline = hasOutline ? groupProps2.outline.map((point2) => ({
14368
- x: distance8.parse(point2.x),
14369
- y: distance8.parse(point2.y)
14395
+ const numericOutline = hasOutline ? groupProps2.outline.map((point4) => ({
14396
+ x: distance8.parse(point4.x),
14397
+ y: distance8.parse(point4.y)
14370
14398
  })) : void 0;
14371
14399
  const ctx = this.props;
14372
14400
  const anchorPosition = this._getGlobalPcbPositionBeforeLayout();
@@ -14403,9 +14431,9 @@ var Group6 = class extends NormalComponent3 {
14403
14431
  const hasOutline = props.outline && props.outline.length > 0;
14404
14432
  const hasExplicitPositioning = this._parsedProps.pcbX !== void 0 || this._parsedProps.pcbY !== void 0;
14405
14433
  if (hasOutline) {
14406
- const numericOutline = props.outline.map((point2) => ({
14407
- x: distance8.parse(point2.x),
14408
- y: distance8.parse(point2.y)
14434
+ const numericOutline = props.outline.map((point4) => ({
14435
+ x: distance8.parse(point4.x),
14436
+ y: distance8.parse(point4.y)
14409
14437
  }));
14410
14438
  const outlineBounds = getBoundsFromPoints3(numericOutline);
14411
14439
  if (!outlineBounds) return;
@@ -14875,20 +14903,20 @@ var Group6 = class extends NormalComponent3 {
14875
14903
  continue;
14876
14904
  }
14877
14905
  if (pcb_trace.type === "pcb_trace") {
14878
- for (const point2 of pcb_trace.route) {
14879
- if (point2.route_type === "via") {
14906
+ for (const point4 of pcb_trace.route) {
14907
+ if (point4.route_type === "via") {
14880
14908
  db.pcb_via.insert({
14881
14909
  pcb_trace_id: pcb_trace.pcb_trace_id,
14882
- x: point2.x,
14883
- y: point2.y,
14910
+ x: point4.x,
14911
+ y: point4.y,
14884
14912
  hole_diameter: holeDiameter,
14885
14913
  outer_diameter: padDiameter,
14886
14914
  layers: [
14887
- point2.from_layer,
14888
- point2.to_layer
14915
+ point4.from_layer,
14916
+ point4.to_layer
14889
14917
  ],
14890
- from_layer: point2.from_layer,
14891
- to_layer: point2.to_layer
14918
+ from_layer: point4.from_layer,
14919
+ to_layer: point4.to_layer
14892
14920
  });
14893
14921
  }
14894
14922
  }
@@ -16372,9 +16400,9 @@ var Board = class extends Group6 {
16372
16400
  center
16373
16401
  };
16374
16402
  if (outline) {
16375
- update.outline = outline.map((point2) => ({
16376
- x: point2.x + (props.outlineOffsetX ?? 0),
16377
- y: point2.y + (props.outlineOffsetY ?? 0)
16403
+ update.outline = outline.map((point4) => ({
16404
+ x: point4.x + (props.outlineOffsetX ?? 0),
16405
+ y: point4.y + (props.outlineOffsetY ?? 0)
16378
16406
  }));
16379
16407
  }
16380
16408
  db.pcb_board.update(this.pcb_board_id, update);
@@ -16461,8 +16489,8 @@ var Board = class extends Group6 {
16461
16489
  });
16462
16490
  }
16463
16491
  if (props.outline) {
16464
- const xValues = props.outline.map((point2) => point2.x);
16465
- const yValues = props.outline.map((point2) => point2.y);
16492
+ const xValues = props.outline.map((point4) => point4.x);
16493
+ const yValues = props.outline.map((point4) => point4.y);
16466
16494
  const minX = Math.min(...xValues);
16467
16495
  const maxX = Math.max(...xValues);
16468
16496
  const minY = Math.min(...yValues);
@@ -16497,9 +16525,9 @@ var Board = class extends Group6 {
16497
16525
  num_layers: this.allLayers.length,
16498
16526
  width: computedWidth,
16499
16527
  height: computedHeight,
16500
- outline: outline?.map((point2) => ({
16501
- x: point2.x + (props.outlineOffsetX ?? 0) + outlineTranslation.x,
16502
- y: point2.y + (props.outlineOffsetY ?? 0) + outlineTranslation.y
16528
+ outline: outline?.map((point4) => ({
16529
+ x: point4.x + (props.outlineOffsetX ?? 0) + outlineTranslation.x,
16530
+ y: point4.y + (props.outlineOffsetY ?? 0) + outlineTranslation.y
16503
16531
  })),
16504
16532
  material: props.material
16505
16533
  });
@@ -16613,6 +16641,7 @@ import { distance as distance11 } from "circuit-json";
16613
16641
 
16614
16642
  // lib/utils/panels/generate-panel-tabs-and-mouse-bites.ts
16615
16643
  import * as Flatten from "@flatten-js/core";
16644
+ import { point as point2, Polygon as Polygon2 } from "@flatten-js/core";
16616
16645
  var DEFAULT_TAB_LENGTH = 5;
16617
16646
  var DEFAULT_TAB_WIDTH = 2;
16618
16647
  var generateCutoutsAndMousebitesForOutline = (outline, options) => {
@@ -16742,7 +16771,33 @@ var generateCutoutsAndMousebitesForOutline = (outline, options) => {
16742
16771
  function generatePanelTabsAndMouseBites(boards, options) {
16743
16772
  const finalTabCutouts = [];
16744
16773
  const allMouseBites = [];
16745
- const { tabWidth, tabLength, mouseBites: useMouseBites } = options;
16774
+ let { tabWidth, tabLength, mouseBites: useMouseBites } = options;
16775
+ const boardDimensions = [];
16776
+ for (const board of boards) {
16777
+ if (board.width && board.height) {
16778
+ boardDimensions.push(Math.min(board.width, board.height));
16779
+ } else if (board.outline && board.outline.length > 0) {
16780
+ const outlinePolygon = new Polygon2(
16781
+ board.outline.map((p) => point2(p.x, p.y))
16782
+ );
16783
+ const area = Math.abs(outlinePolygon.area());
16784
+ if (area > 0) {
16785
+ boardDimensions.push(Math.sqrt(area));
16786
+ }
16787
+ }
16788
+ }
16789
+ if (boardDimensions.length > 0) {
16790
+ const minBoardDimension = Math.min(...boardDimensions);
16791
+ const scaleFactor = minBoardDimension / 20;
16792
+ tabWidth = Math.min(
16793
+ tabWidth,
16794
+ DEFAULT_TAB_WIDTH * Math.max(scaleFactor, 0.3)
16795
+ );
16796
+ tabLength = Math.min(
16797
+ tabLength,
16798
+ DEFAULT_TAB_LENGTH * Math.max(scaleFactor, 0.3)
16799
+ );
16800
+ }
16746
16801
  const processedBoards = boards.map((board) => {
16747
16802
  if ((!board.outline || board.outline.length === 0) && board.width && board.height) {
16748
16803
  const w2 = board.width / 2;
@@ -17935,10 +17990,10 @@ var FabricationNotePath = class extends PrimitiveComponent2 {
17935
17990
  const { _parsedProps: props } = this;
17936
17991
  if (props.route.length === 0) return { width: 0, height: 0 };
17937
17992
  const xs = props.route.map(
17938
- (point2) => typeof point2.x === "string" ? parseFloat(point2.x) : point2.x
17993
+ (point4) => typeof point4.x === "string" ? parseFloat(point4.x) : point4.x
17939
17994
  );
17940
17995
  const ys = props.route.map(
17941
- (point2) => typeof point2.y === "string" ? parseFloat(point2.y) : point2.y
17996
+ (point4) => typeof point4.y === "string" ? parseFloat(point4.y) : point4.y
17942
17997
  );
17943
17998
  const minX = Math.min(...xs);
17944
17999
  const maxX = Math.max(...xs);
@@ -18356,8 +18411,8 @@ var PcbNotePath = class extends PrimitiveComponent2 {
18356
18411
  const subcircuit = this.getSubcircuit();
18357
18412
  const group = this.getGroup();
18358
18413
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? void 0;
18359
- const transformedRoute = props.route.map((point2) => {
18360
- const { x, y, ...rest } = point2;
18414
+ const transformedRoute = props.route.map((point4) => {
18415
+ const { x, y, ...rest } = point4;
18361
18416
  const numericX = typeof x === "string" ? parseFloat(x) : x;
18362
18417
  const numericY = typeof y === "string" ? parseFloat(y) : y;
18363
18418
  const transformed = applyToPoint15(transform, { x: numericX, y: numericY });
@@ -18377,10 +18432,10 @@ var PcbNotePath = class extends PrimitiveComponent2 {
18377
18432
  const { _parsedProps: props } = this;
18378
18433
  if (props.route.length === 0) return { width: 0, height: 0 };
18379
18434
  const xs = props.route.map(
18380
- (point2) => typeof point2.x === "string" ? parseFloat(point2.x) : point2.x
18435
+ (point4) => typeof point4.x === "string" ? parseFloat(point4.x) : point4.x
18381
18436
  );
18382
18437
  const ys = props.route.map(
18383
- (point2) => typeof point2.y === "string" ? parseFloat(point2.y) : point2.y
18438
+ (point4) => typeof point4.y === "string" ? parseFloat(point4.y) : point4.y
18384
18439
  );
18385
18440
  const minX = Math.min(...xs);
18386
18441
  const maxX = Math.max(...xs);
@@ -18656,11 +18711,11 @@ var BreakoutPoint = class extends PrimitiveComponent2 {
18656
18711
  if (this.root?.pcbDisabled) return;
18657
18712
  const { db } = this.root;
18658
18713
  if (!this.pcb_breakout_point_id) return;
18659
- const point2 = db.pcb_breakout_point.get(this.pcb_breakout_point_id);
18660
- if (point2) {
18714
+ const point4 = db.pcb_breakout_point.get(this.pcb_breakout_point_id);
18715
+ if (point4) {
18661
18716
  db.pcb_breakout_point.update(this.pcb_breakout_point_id, {
18662
- x: point2.x + deltaX,
18663
- y: point2.y + deltaY
18717
+ x: point4.x + deltaX,
18718
+ y: point4.y + deltaY
18664
18719
  });
18665
18720
  }
18666
18721
  }
@@ -20221,9 +20276,9 @@ var SchematicPath = class extends PrimitiveComponent2 {
20221
20276
  const schematic_component_id = this.getPrimitiveContainer()?.parent?.schematic_component_id;
20222
20277
  db.schematic_path.insert({
20223
20278
  schematic_component_id,
20224
- points: props.points.map((point2) => ({
20225
- x: point2.x + globalPos.x,
20226
- y: point2.y + globalPos.y
20279
+ points: props.points.map((point4) => ({
20280
+ x: point4.x + globalPos.x,
20281
+ y: point4.y + globalPos.y
20227
20282
  })),
20228
20283
  is_filled: props.isFilled,
20229
20284
  fill_color: props.fillColor,
@@ -20898,7 +20953,7 @@ import { identity as identity5 } from "transformation-matrix";
20898
20953
  var package_default = {
20899
20954
  name: "@tscircuit/core",
20900
20955
  type: "module",
20901
- version: "0.0.974",
20956
+ version: "0.0.976",
20902
20957
  types: "dist/index.d.ts",
20903
20958
  main: "dist/index.js",
20904
20959
  module: "dist/index.js",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.975",
4
+ "version": "0.0.977",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",