@tscircuit/core 0.0.1278 → 0.0.1280

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
@@ -2363,6 +2363,13 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
2363
2363
  doInitialCreateTraceHintsFromProps(): void;
2364
2364
  doInitialSourceAddConnectivityMapKey(): void;
2365
2365
  _areChildSubcircuitsRouted(): boolean;
2366
+ /**
2367
+ * Find subcircuit groups that are direct children of this subcircuit in
2368
+ * the component tree. Unlike selectAll("group"), this walks the children
2369
+ * array directly because the css-select adapter used by selectAll
2370
+ * intentionally skips subcircuit boundaries.
2371
+ */
2372
+ _findDirectChildSubcircuits(): Group[];
2366
2373
  _shouldRouteAsync(): boolean;
2367
2374
  _getRoutingPhasePlans(): RoutingPhasePlan[];
2368
2375
  _hasTracesToRoute(): boolean;
@@ -147401,6 +147408,8 @@ declare class SchematicLine extends PrimitiveComponent<typeof schematicLineProps
147401
147408
  strokeWidth: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
147402
147409
  color: zod.ZodOptional<zod.ZodString>;
147403
147410
  isDashed: zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>;
147411
+ dashLength: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
147412
+ dashGap: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
147404
147413
  }, "strip", zod.ZodTypeAny, {
147405
147414
  isDashed: boolean;
147406
147415
  x1: number;
@@ -147409,6 +147418,8 @@ declare class SchematicLine extends PrimitiveComponent<typeof schematicLineProps
147409
147418
  y2: number;
147410
147419
  strokeWidth?: number | undefined;
147411
147420
  color?: string | undefined;
147421
+ dashLength?: number | undefined;
147422
+ dashGap?: number | undefined;
147412
147423
  }, {
147413
147424
  x1: string | number;
147414
147425
  y1: string | number;
@@ -147417,6 +147428,8 @@ declare class SchematicLine extends PrimitiveComponent<typeof schematicLineProps
147417
147428
  strokeWidth?: string | number | undefined;
147418
147429
  color?: string | undefined;
147419
147430
  isDashed?: boolean | undefined;
147431
+ dashLength?: string | number | undefined;
147432
+ dashGap?: string | number | undefined;
147420
147433
  }>;
147421
147434
  };
147422
147435
  schematic_line_id?: string;
@@ -147593,6 +147606,8 @@ declare class SchematicPath extends PrimitiveComponent<typeof schematicPathProps
147593
147606
  svgPath: zod.ZodOptional<zod.ZodString>;
147594
147607
  strokeWidth: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
147595
147608
  strokeColor: zod.ZodOptional<zod.ZodString>;
147609
+ dashLength: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
147610
+ dashGap: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
147596
147611
  isFilled: zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>;
147597
147612
  fillColor: zod.ZodOptional<zod.ZodString>;
147598
147613
  }, "strip", zod.ZodTypeAny, {
@@ -147603,6 +147618,8 @@ declare class SchematicPath extends PrimitiveComponent<typeof schematicPathProps
147603
147618
  y: number;
147604
147619
  }[] | undefined;
147605
147620
  fillColor?: string | undefined;
147621
+ dashLength?: number | undefined;
147622
+ dashGap?: number | undefined;
147606
147623
  svgPath?: string | undefined;
147607
147624
  strokeColor?: string | undefined;
147608
147625
  }, {
@@ -147613,6 +147630,8 @@ declare class SchematicPath extends PrimitiveComponent<typeof schematicPathProps
147613
147630
  }[] | undefined;
147614
147631
  isFilled?: boolean | undefined;
147615
147632
  fillColor?: string | undefined;
147633
+ dashLength?: string | number | undefined;
147634
+ dashGap?: string | number | undefined;
147616
147635
  svgPath?: string | undefined;
147617
147636
  strokeColor?: string | undefined;
147618
147637
  }>;
@@ -147757,12 +147776,15 @@ declare class SchematicSection extends PrimitiveComponent<typeof schematicSectio
147757
147776
  zodProps: zod.ZodObject<{
147758
147777
  displayName: zod.ZodOptional<zod.ZodString>;
147759
147778
  name: zod.ZodString;
147779
+ sectionTitleFontSize: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
147760
147780
  }, "strip", zod.ZodTypeAny, {
147761
147781
  name: string;
147762
147782
  displayName?: string | undefined;
147783
+ sectionTitleFontSize?: number | undefined;
147763
147784
  }, {
147764
147785
  name: string;
147765
147786
  displayName?: string | undefined;
147787
+ sectionTitleFontSize?: string | number | undefined;
147766
147788
  }>;
147767
147789
  };
147768
147790
  _computeSectionBounds(board: PrimitiveComponent): Bounds | null;
package/dist/index.js CHANGED
@@ -14436,6 +14436,9 @@ var getSimpleRouteJsonFromCircuitJson = ({
14436
14436
  db = su4(subcircuitElements);
14437
14437
  const pcbGroup = subcircuit_id ? db.pcb_group.getWhere({ subcircuit_id }) : void 0;
14438
14438
  const connMap = getFullConnectivityMapFromCircuitJson3(subcircuitElements);
14439
+ const breakoutPoints = db.pcb_breakout_point.list().filter(
14440
+ (bp) => !subcircuit_id || relevantSubcircuitIds?.has(bp.subcircuit_id)
14441
+ );
14439
14442
  const obstacles = getObstaclesFromCircuitJson(
14440
14443
  [
14441
14444
  ...db.pcb_component.list(),
@@ -14445,8 +14448,6 @@ var getSimpleRouteJsonFromCircuitJson = ({
14445
14448
  ...db.pcb_via.list(),
14446
14449
  ...db.pcb_keepout.list(),
14447
14450
  ...db.pcb_cutout.list()
14448
- // getObstaclesFromSoup is old and doesn't support diagonal traces
14449
- // ...db.pcb_trace.list(),
14450
14451
  ].filter(
14451
14452
  (e) => !subcircuit_id || relevantSubcircuitIds?.has(e.subcircuit_id)
14452
14453
  ),
@@ -14460,6 +14461,13 @@ var getSimpleRouteJsonFromCircuitJson = ({
14460
14461
  group: pcbGroup
14461
14462
  })
14462
14463
  );
14464
+ const descendantTraces = subcircuit_id ? db.pcb_trace.list().filter(
14465
+ (t) => t.subcircuit_id && t.subcircuit_id !== subcircuit_id && relevantSubcircuitIds.has(t.subcircuit_id)
14466
+ ).map((t) => ({
14467
+ type: "pcb_trace",
14468
+ pcb_trace_id: t.pcb_trace_id,
14469
+ route: t.route
14470
+ })) : [];
14463
14471
  for (const obstacle of obstacles) {
14464
14472
  const additionalIds = obstacle.connectedTo.flatMap(
14465
14473
  (id) => connMap.getIdsConnectedToNet(id)
@@ -14555,7 +14563,14 @@ var getSimpleRouteJsonFromCircuitJson = ({
14555
14563
  const routedTraceIds = new Set(
14556
14564
  db.pcb_trace.list().map((t) => t.source_trace_id).filter((id) => Boolean(id))
14557
14565
  );
14558
- const directTraceConnections = db.source_trace.list().filter((trace) => !routedTraceIds.has(trace.source_trace_id)).map((trace) => {
14566
+ const sourcePortIdToBreakoutPoint = /* @__PURE__ */ new Map();
14567
+ for (const bp of breakoutPoints) {
14568
+ const spId = bp.source_port_id;
14569
+ if (spId) sourcePortIdToBreakoutPoint.set(spId, bp);
14570
+ }
14571
+ const directTraceConnections = db.source_trace.list().filter((trace) => !routedTraceIds.has(trace.source_trace_id)).filter(
14572
+ (trace) => !subcircuit_id || trace.subcircuit_id === subcircuit_id
14573
+ ).map((trace) => {
14559
14574
  const connectedPorts = trace.connected_source_port_ids.map((id) => {
14560
14575
  const source_port = db.source_port.get(id);
14561
14576
  const pcb_port = db.pcb_port.getWhere({ source_port_id: id });
@@ -14595,33 +14610,39 @@ var getSimpleRouteJsonFromCircuitJson = ({
14595
14610
  });
14596
14611
  }
14597
14612
  }
14613
+ const getPortOrBreakoutPoint = (port, layer, sourcePortId) => {
14614
+ const bp = sourcePortIdToBreakoutPoint.get(sourcePortId);
14615
+ if (bp && bp.subcircuit_id !== subcircuit_id) {
14616
+ return { x: bp.x, y: bp.y, layer };
14617
+ }
14618
+ return {
14619
+ x: port.x,
14620
+ y: port.y,
14621
+ layer,
14622
+ pointId: port.pcb_port_id,
14623
+ pcb_port_id: port.pcb_port_id
14624
+ };
14625
+ };
14598
14626
  return {
14599
14627
  name: trace.source_trace_id ?? connMap.getNetConnectedToId(trace.source_trace_id) ?? "",
14600
14628
  source_trace_id: trace.source_trace_id,
14601
14629
  nominalTraceWidth: trace.min_trace_thickness,
14602
14630
  width: trace.min_trace_thickness,
14603
14631
  pointsToConnect: [
14604
- {
14605
- x: portA.x,
14606
- y: portA.y,
14607
- layer: layerA,
14608
- pointId: portA.pcb_port_id,
14609
- pcb_port_id: portA.pcb_port_id
14610
- },
14632
+ getPortOrBreakoutPoint(
14633
+ portA,
14634
+ layerA,
14635
+ trace.connected_source_port_ids[0]
14636
+ ),
14611
14637
  ...hintPoints,
14612
- {
14613
- x: portB.x,
14614
- y: portB.y,
14615
- layer: layerB,
14616
- pointId: portB.pcb_port_id,
14617
- pcb_port_id: portB.pcb_port_id
14618
- }
14638
+ getPortOrBreakoutPoint(
14639
+ portB,
14640
+ layerB,
14641
+ trace.connected_source_port_ids[1]
14642
+ )
14619
14643
  ]
14620
14644
  };
14621
14645
  }).filter((c) => c !== null);
14622
- const directTraceConnectionsById = new Map(
14623
- directTraceConnections.map((c) => [c.source_trace_id, c])
14624
- );
14625
14646
  const source_nets = db.source_net.list().filter(
14626
14647
  (e) => !subcircuit_id || relevantSubcircuitIds?.has(e.subcircuit_id)
14627
14648
  );
@@ -14654,27 +14675,38 @@ var getSimpleRouteJsonFromCircuitJson = ({
14654
14675
  })
14655
14676
  });
14656
14677
  }
14657
- const breakoutPoints = db.pcb_breakout_point.list().filter(
14658
- (bp) => !subcircuit_id || relevantSubcircuitIds?.has(bp.subcircuit_id)
14659
- );
14660
14678
  const connectionsFromBreakoutPoints = [];
14661
- const breakoutTraceConnectionsById = /* @__PURE__ */ new Map();
14662
14679
  for (const bp of breakoutPoints) {
14680
+ const bpSourcePortId = bp.source_port_id;
14663
14681
  const pt = { x: bp.x, y: bp.y, layer: "top" };
14664
- if (bp.source_trace_id) {
14665
- const conn = directTraceConnectionsById.get(bp.source_trace_id) ?? breakoutTraceConnectionsById.get(bp.source_trace_id);
14666
- if (conn) {
14667
- conn.pointsToConnect.push(pt);
14668
- } else {
14669
- const newConn = {
14670
- name: bp.source_trace_id,
14671
- source_trace_id: bp.source_trace_id,
14672
- pointsToConnect: [pt]
14673
- };
14674
- connectionsFromBreakoutPoints.push(newConn);
14675
- breakoutTraceConnectionsById.set(bp.source_trace_id, newConn);
14682
+ if (bpSourcePortId) {
14683
+ const pcb_port = db.pcb_port.getWhere({
14684
+ source_port_id: bpSourcePortId
14685
+ });
14686
+ if (!pcb_port) continue;
14687
+ const portPt = {
14688
+ x: pcb_port.x,
14689
+ y: pcb_port.y,
14690
+ layer: pcb_port.layers?.[0] ?? "top",
14691
+ pointId: pcb_port.pcb_port_id,
14692
+ pcb_port_id: pcb_port.pcb_port_id
14693
+ };
14694
+ if (bp.subcircuit_id === subcircuit_id) {
14695
+ connectionsFromBreakoutPoints.push({
14696
+ name: bpSourcePortId,
14697
+ pointsToConnect: [portPt, pt]
14698
+ });
14699
+ continue;
14700
+ }
14701
+ if (!bp.source_trace_id) {
14702
+ connectionsFromBreakoutPoints.push({
14703
+ name: bpSourcePortId,
14704
+ pointsToConnect: [portPt, pt]
14705
+ });
14676
14706
  }
14677
- } else if (bp.source_net_id) {
14707
+ continue;
14708
+ }
14709
+ if (bp.source_net_id) {
14678
14710
  const conn = connectionsFromNets.find((c) => c.name === bp.source_net_id);
14679
14711
  if (conn) {
14680
14712
  conn.pointsToConnect.push(pt);
@@ -14684,28 +14716,6 @@ var getSimpleRouteJsonFromCircuitJson = ({
14684
14716
  pointsToConnect: [pt]
14685
14717
  });
14686
14718
  }
14687
- } else if (bp.source_port_id) {
14688
- const pcb_port = db.pcb_port.getWhere({
14689
- source_port_id: bp.source_port_id
14690
- });
14691
- if (pcb_port) {
14692
- connectionsFromBreakoutPoints.push({
14693
- name: bp.source_port_id,
14694
- // direct connection from port to breakout point
14695
- source_trace_id: void 0,
14696
- pointsToConnect: [
14697
- {
14698
- x: pcb_port.x,
14699
- y: pcb_port.y,
14700
- layer: pcb_port.layers?.[0] ?? "top",
14701
- pointId: pcb_port.pcb_port_id,
14702
- // @ts-ignore
14703
- pcb_port_id: pcb_port.pcb_port_id
14704
- },
14705
- pt
14706
- ]
14707
- });
14708
- }
14709
14719
  }
14710
14720
  }
14711
14721
  const allConns = [
@@ -14751,8 +14761,7 @@ var getSimpleRouteJsonFromCircuitJson = ({
14751
14761
  bounds,
14752
14762
  obstacles,
14753
14763
  connections: allConns,
14754
- // TODO add traces so that we don't run into things routed by another
14755
- // subcircuit
14764
+ traces: descendantTraces.length > 0 ? descendantTraces : void 0,
14756
14765
  layerCount: board?.num_layers ?? 2,
14757
14766
  minTraceWidth: minTraceWidth ?? board?.min_trace_width ?? 0.1,
14758
14767
  minViaDiameter: resolvedMinViaPadDiameter,
@@ -19930,16 +19939,36 @@ var Group5 = class extends NormalComponent3 {
19930
19939
  Group_doInitialSourceAddConnectivityMapKey(this);
19931
19940
  }
19932
19941
  _areChildSubcircuitsRouted() {
19933
- const subcircuitChildren = this.selectAll("group").filter(
19934
- (g) => g.isSubcircuit
19935
- );
19942
+ const subcircuitChildren = this._findDirectChildSubcircuits();
19936
19943
  for (const subcircuitChild of subcircuitChildren) {
19944
+ if (subcircuitChild._isInflatedFromCircuitJson) continue;
19945
+ if (!subcircuitChild._hasTracesToRoute()) continue;
19937
19946
  if (subcircuitChild._shouldRouteAsync() && !subcircuitChild._asyncAutoroutingResult) {
19938
19947
  return false;
19939
19948
  }
19940
19949
  }
19941
19950
  return true;
19942
19951
  }
19952
+ /**
19953
+ * Find subcircuit groups that are direct children of this subcircuit in
19954
+ * the component tree. Unlike selectAll("group"), this walks the children
19955
+ * array directly because the css-select adapter used by selectAll
19956
+ * intentionally skips subcircuit boundaries.
19957
+ */
19958
+ _findDirectChildSubcircuits() {
19959
+ const result = [];
19960
+ const visit = (children) => {
19961
+ for (const child of children) {
19962
+ if (child.isSubcircuit && child !== this) {
19963
+ result.push(child);
19964
+ } else {
19965
+ visit(child.children);
19966
+ }
19967
+ }
19968
+ };
19969
+ visit(this.children);
19970
+ return result;
19971
+ }
19943
19972
  _shouldRouteAsync() {
19944
19973
  const autorouter = this._getAutorouterConfig();
19945
19974
  if (autorouter.groupMode === "sequential-trace") return false;
@@ -21827,7 +21856,7 @@ import { identity as identity5 } from "transformation-matrix";
21827
21856
  var package_default = {
21828
21857
  name: "@tscircuit/core",
21829
21858
  type: "module",
21830
- version: "0.0.1277",
21859
+ version: "0.0.1279",
21831
21860
  types: "dist/index.d.ts",
21832
21861
  main: "dist/index.js",
21833
21862
  module: "dist/index.js",
@@ -21862,7 +21891,7 @@ var package_default = {
21862
21891
  "@tscircuit/breakout-point-solver": "github:tscircuit/breakout-point-solver#bac9629",
21863
21892
  "@tscircuit/capacity-autorouter": "^0.0.529",
21864
21893
  "@tscircuit/checks": "0.0.133",
21865
- "@tscircuit/circuit-json-util": "^0.0.94",
21894
+ "@tscircuit/circuit-json-util": "^0.0.95",
21866
21895
  "@tscircuit/common": "^0.0.20",
21867
21896
  "@tscircuit/copper-pour-solver": "^0.0.29",
21868
21897
  "@tscircuit/footprinter": "^0.0.357",
@@ -21875,7 +21904,7 @@ var package_default = {
21875
21904
  "@tscircuit/math-utils": "^0.0.36",
21876
21905
  "@tscircuit/miniflex": "^0.0.4",
21877
21906
  "@tscircuit/ngspice-spice-engine": "^0.0.8",
21878
- "@tscircuit/props": "^0.0.540",
21907
+ "@tscircuit/props": "^0.0.542",
21879
21908
  "@tscircuit/schematic-match-adapt": "^0.0.16",
21880
21909
  "@tscircuit/schematic-trace-solver": "^0.0.60",
21881
21910
  "@tscircuit/solver-utils": "^0.0.3",
@@ -21889,7 +21918,7 @@ var package_default = {
21889
21918
  "bun-match-svg": "0.0.12",
21890
21919
  "calculate-elbow": "^0.0.12",
21891
21920
  "chokidar-cli": "^3.0.0",
21892
- "circuit-json": "^0.0.430",
21921
+ "circuit-json": "^0.0.431",
21893
21922
  "circuit-json-to-bpc": "^0.0.13",
21894
21923
  "circuit-json-to-connectivity-map": "^0.0.23",
21895
21924
  "circuit-json-to-gltf": "^0.0.102",
@@ -27688,7 +27717,7 @@ var SchematicSection = class _SchematicSection extends PrimitiveComponent2 {
27688
27717
  (l) => Math.abs(l.start.x - l.end.x) < TOL3
27689
27718
  );
27690
27719
  for (const { section, cell, rawBounds } of sectionData) {
27691
- const { displayName } = section._parsedProps;
27720
+ const { displayName, sectionTitleFontSize } = section._parsedProps;
27692
27721
  if (!displayName) continue;
27693
27722
  const dividersAbove = hDividers.map((l) => l.start.y).filter((y) => y > cell.minY);
27694
27723
  const topBoundary = dividersAbove.length > 0 ? Math.min(...dividersAbove) : outer.maxY;
@@ -27697,7 +27726,7 @@ var SchematicSection = class _SchematicSection extends PrimitiveComponent2 {
27697
27726
  db.schematic_text.insert({
27698
27727
  anchor: "top_left",
27699
27728
  text: displayName,
27700
- font_size: 0.18,
27729
+ font_size: sectionTitleFontSize ?? 0.18,
27701
27730
  color: "#000000",
27702
27731
  position: {
27703
27732
  x: leftBoundary + LABEL_PADDING,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1278",
4
+ "version": "0.0.1280",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -36,7 +36,7 @@
36
36
  "@tscircuit/breakout-point-solver": "github:tscircuit/breakout-point-solver#bac9629",
37
37
  "@tscircuit/capacity-autorouter": "^0.0.529",
38
38
  "@tscircuit/checks": "0.0.133",
39
- "@tscircuit/circuit-json-util": "^0.0.94",
39
+ "@tscircuit/circuit-json-util": "^0.0.95",
40
40
  "@tscircuit/common": "^0.0.20",
41
41
  "@tscircuit/copper-pour-solver": "^0.0.29",
42
42
  "@tscircuit/footprinter": "^0.0.357",
@@ -49,7 +49,7 @@
49
49
  "@tscircuit/math-utils": "^0.0.36",
50
50
  "@tscircuit/miniflex": "^0.0.4",
51
51
  "@tscircuit/ngspice-spice-engine": "^0.0.8",
52
- "@tscircuit/props": "^0.0.540",
52
+ "@tscircuit/props": "^0.0.542",
53
53
  "@tscircuit/schematic-match-adapt": "^0.0.16",
54
54
  "@tscircuit/schematic-trace-solver": "^0.0.60",
55
55
  "@tscircuit/solver-utils": "^0.0.3",
@@ -63,7 +63,7 @@
63
63
  "bun-match-svg": "0.0.12",
64
64
  "calculate-elbow": "^0.0.12",
65
65
  "chokidar-cli": "^3.0.0",
66
- "circuit-json": "^0.0.430",
66
+ "circuit-json": "^0.0.431",
67
67
  "circuit-json-to-bpc": "^0.0.13",
68
68
  "circuit-json-to-connectivity-map": "^0.0.23",
69
69
  "circuit-json-to-gltf": "^0.0.102",