@tscircuit/core 0.0.614 → 0.0.616

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
@@ -11,7 +11,7 @@ import { CircuitJsonUtilObjects } from '@tscircuit/circuit-json-util';
11
11
  import { ConnectivityMap } from 'circuit-json-to-connectivity-map';
12
12
  import { GraphicsObject } from 'graphics-debug';
13
13
 
14
- declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "PcbFootprintStringRender", "InitializePortsFromChildren", "CreateNetsFromProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SchematicPrimitiveRender", "SchematicLayout", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbLayout", "PcbBoardAutoSize", "PcbTraceHintRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbDesignRuleChecks", "CadModelRender", "PartsEngineRender"];
14
+ declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "PcbFootprintStringRender", "InitializePortsFromChildren", "CreateNetsFromProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SchematicPrimitiveRender", "SchematicLayout", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbLayout", "PcbBoardAutoSize", "PcbTraceHintRender", "PcbManualTraceRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbDesignRuleChecks", "CadModelRender", "PartsEngineRender"];
15
15
  type RenderPhase = (typeof orderedRenderPhases)[number];
16
16
  type RenderPhaseFn<K extends RenderPhase = RenderPhase> = `doInitial${K}` | `update${K}` | `remove${K}`;
17
17
  type RenderPhaseStates = Record<RenderPhase, {
@@ -602,6 +602,17 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
602
602
  } | undefined;
603
603
  trace_width?: string | number | undefined;
604
604
  }>, "many">>;
605
+ pcbPathRelativeTo: z.ZodOptional<z.ZodString>;
606
+ pcbPath: z.ZodOptional<z.ZodArray<z.ZodObject<{
607
+ x: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
608
+ y: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
609
+ }, "strip", z.ZodTypeAny, {
610
+ x: number;
611
+ y: number;
612
+ }, {
613
+ x: string | number;
614
+ y: string | number;
615
+ }>, "many">>;
605
616
  schDisplayLabel: z.ZodOptional<z.ZodString>;
606
617
  maxLength: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
607
618
  } & {
@@ -628,6 +639,11 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
628
639
  to_layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
629
640
  trace_width?: number | undefined;
630
641
  }[] | undefined;
642
+ pcbPathRelativeTo?: string | undefined;
643
+ pcbPath?: {
644
+ x: number;
645
+ y: number;
646
+ }[] | undefined;
631
647
  schDisplayLabel?: string | undefined;
632
648
  }, {
633
649
  path: (string | {
@@ -649,6 +665,11 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
649
665
  } | undefined;
650
666
  trace_width?: string | number | undefined;
651
667
  }[] | undefined;
668
+ pcbPathRelativeTo?: string | undefined;
669
+ pcbPath?: {
670
+ x: string | number;
671
+ y: string | number;
672
+ }[] | undefined;
652
673
  schDisplayLabel?: string | undefined;
653
674
  }>, z.ZodObject<{
654
675
  key: z.ZodOptional<z.ZodString>;
@@ -692,6 +713,17 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
692
713
  } | undefined;
693
714
  trace_width?: string | number | undefined;
694
715
  }>, "many">>;
716
+ pcbPathRelativeTo: z.ZodOptional<z.ZodString>;
717
+ pcbPath: z.ZodOptional<z.ZodArray<z.ZodObject<{
718
+ x: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
719
+ y: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
720
+ }, "strip", z.ZodTypeAny, {
721
+ x: number;
722
+ y: number;
723
+ }, {
724
+ x: string | number;
725
+ y: string | number;
726
+ }>, "many">>;
695
727
  schDisplayLabel: z.ZodOptional<z.ZodString>;
696
728
  maxLength: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
697
729
  } & {
@@ -726,6 +758,11 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
726
758
  to_layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
727
759
  trace_width?: number | undefined;
728
760
  }[] | undefined;
761
+ pcbPathRelativeTo?: string | undefined;
762
+ pcbPath?: {
763
+ x: number;
764
+ y: number;
765
+ }[] | undefined;
729
766
  schDisplayLabel?: string | undefined;
730
767
  }, {
731
768
  from: string | {
@@ -750,6 +787,11 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
750
787
  } | undefined;
751
788
  trace_width?: string | number | undefined;
752
789
  }[] | undefined;
790
+ pcbPathRelativeTo?: string | undefined;
791
+ pcbPath?: {
792
+ x: string | number;
793
+ y: string | number;
794
+ }[] | undefined;
753
795
  schDisplayLabel?: string | undefined;
754
796
  }>]>;
755
797
  componentName: string;
@@ -795,6 +837,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
795
837
  _computeTraceConnectionHash(): string | null;
796
838
  doInitialSourceTraceRender(): void;
797
839
  _insertErrorIfTraceIsOutsideBoard(mergedRoute: PcbTraceRoutePoint[], ports: Port[]): void;
840
+ doInitialPcbManualTraceRender(): void;
798
841
  doInitialPcbTraceRender(): void;
799
842
  _doInitialSchematicTraceRenderWithDisplayLabel(): void;
800
843
  _isSymbolToChipConnection(): boolean | undefined;
@@ -1163,6 +1206,25 @@ declare class Board extends Group<typeof boardProps> {
1163
1206
  pcbFlexColumn: zod.ZodOptional<zod.ZodBoolean>;
1164
1207
  pcbGap: zod.ZodOptional<zod.ZodUnion<[zod.ZodNumber, zod.ZodString]>>;
1165
1208
  pcbPack: zod.ZodOptional<zod.ZodBoolean>;
1209
+ schGrid: zod.ZodOptional<zod.ZodBoolean>;
1210
+ schGridCols: zod.ZodOptional<zod.ZodUnion<[zod.ZodNumber, zod.ZodString]>>;
1211
+ schGridRows: zod.ZodOptional<zod.ZodUnion<[zod.ZodNumber, zod.ZodString]>>;
1212
+ schGridTemplateRows: zod.ZodOptional<zod.ZodString>;
1213
+ schGridTemplateColumns: zod.ZodOptional<zod.ZodString>;
1214
+ schGridTemplate: zod.ZodOptional<zod.ZodString>;
1215
+ schGridGap: zod.ZodOptional<zod.ZodUnion<[zod.ZodNumber, zod.ZodString]>>;
1216
+ schGridRowGap: zod.ZodOptional<zod.ZodUnion<[zod.ZodNumber, zod.ZodString]>>;
1217
+ schGridColumnGap: zod.ZodOptional<zod.ZodUnion<[zod.ZodNumber, zod.ZodString]>>;
1218
+ schFlex: zod.ZodOptional<zod.ZodUnion<[zod.ZodBoolean, zod.ZodString]>>;
1219
+ schFlexGap: zod.ZodOptional<zod.ZodUnion<[zod.ZodNumber, zod.ZodString]>>;
1220
+ schFlexDirection: zod.ZodOptional<zod.ZodEnum<["row", "column"]>>;
1221
+ schAlignItems: zod.ZodOptional<zod.ZodEnum<["start", "center", "end", "stretch"]>>;
1222
+ schJustifyContent: zod.ZodOptional<zod.ZodEnum<["start", "center", "end", "stretch", "space-between", "space-around", "space-evenly"]>>;
1223
+ schFlexRow: zod.ZodOptional<zod.ZodBoolean>;
1224
+ schFlexColumn: zod.ZodOptional<zod.ZodBoolean>;
1225
+ schGap: zod.ZodOptional<zod.ZodUnion<[zod.ZodNumber, zod.ZodString]>>;
1226
+ schPack: zod.ZodOptional<zod.ZodBoolean>;
1227
+ schMatchAdapt: zod.ZodOptional<zod.ZodBoolean>;
1166
1228
  pcbWidth: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
1167
1229
  pcbHeight: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
1168
1230
  schWidth: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
@@ -1823,6 +1885,25 @@ declare class Board extends Group<typeof boardProps> {
1823
1885
  pcbFlexColumn?: boolean | undefined;
1824
1886
  pcbGap?: string | number | undefined;
1825
1887
  pcbPack?: boolean | undefined;
1888
+ schGrid?: boolean | undefined;
1889
+ schGridCols?: string | number | undefined;
1890
+ schGridRows?: string | number | undefined;
1891
+ schGridTemplateRows?: string | undefined;
1892
+ schGridTemplateColumns?: string | undefined;
1893
+ schGridTemplate?: string | undefined;
1894
+ schGridGap?: string | number | undefined;
1895
+ schGridRowGap?: string | number | undefined;
1896
+ schGridColumnGap?: string | number | undefined;
1897
+ schFlex?: string | boolean | undefined;
1898
+ schFlexGap?: string | number | undefined;
1899
+ schFlexDirection?: "row" | "column" | undefined;
1900
+ schAlignItems?: "center" | "start" | "end" | "stretch" | undefined;
1901
+ schJustifyContent?: "center" | "start" | "end" | "stretch" | "space-between" | "space-around" | "space-evenly" | undefined;
1902
+ schFlexRow?: boolean | undefined;
1903
+ schFlexColumn?: boolean | undefined;
1904
+ schGap?: string | number | undefined;
1905
+ schPack?: boolean | undefined;
1906
+ schMatchAdapt?: boolean | undefined;
1826
1907
  manualEdits?: {
1827
1908
  pcb_placements?: {
1828
1909
  selector: string;
@@ -2039,6 +2120,25 @@ declare class Board extends Group<typeof boardProps> {
2039
2120
  pcbFlexColumn?: boolean | undefined;
2040
2121
  pcbGap?: string | number | undefined;
2041
2122
  pcbPack?: boolean | undefined;
2123
+ schGrid?: boolean | undefined;
2124
+ schGridCols?: string | number | undefined;
2125
+ schGridRows?: string | number | undefined;
2126
+ schGridTemplateRows?: string | undefined;
2127
+ schGridTemplateColumns?: string | undefined;
2128
+ schGridTemplate?: string | undefined;
2129
+ schGridGap?: string | number | undefined;
2130
+ schGridRowGap?: string | number | undefined;
2131
+ schGridColumnGap?: string | number | undefined;
2132
+ schFlex?: string | boolean | undefined;
2133
+ schFlexGap?: string | number | undefined;
2134
+ schFlexDirection?: "row" | "column" | undefined;
2135
+ schAlignItems?: "center" | "start" | "end" | "stretch" | undefined;
2136
+ schJustifyContent?: "center" | "start" | "end" | "stretch" | "space-between" | "space-around" | "space-evenly" | undefined;
2137
+ schFlexRow?: boolean | undefined;
2138
+ schFlexColumn?: boolean | undefined;
2139
+ schGap?: string | number | undefined;
2140
+ schPack?: boolean | undefined;
2141
+ schMatchAdapt?: boolean | undefined;
2042
2142
  manualEdits?: {
2043
2143
  pcb_placements?: {
2044
2144
  selector: string;
package/dist/index.js CHANGED
@@ -114,6 +114,7 @@ var orderedRenderPhases = [
114
114
  "PcbLayout",
115
115
  "PcbBoardAutoSize",
116
116
  "PcbTraceHintRender",
117
+ "PcbManualTraceRender",
117
118
  "PcbTraceRender",
118
119
  "PcbRouteNetIslands",
119
120
  "PcbDesignRuleChecks",
@@ -5440,6 +5441,9 @@ function Trace_doInitialPcbTraceRender(trace) {
5440
5441
  trace.pcb_trace_id = pcb_trace2.pcb_trace_id;
5441
5442
  return;
5442
5443
  }
5444
+ if (props.pcbPath && props.pcbPath.length > 0) {
5445
+ return;
5446
+ }
5443
5447
  if (!subcircuit._shouldUseTraceByTraceRouting()) {
5444
5448
  return;
5445
5449
  }
@@ -5694,6 +5698,88 @@ function Trace_doInitialPcbTraceRender(trace) {
5694
5698
  trace._insertErrorIfTraceIsOutsideBoard(mergedRoute, ports);
5695
5699
  }
5696
5700
 
5701
+ // lib/components/primitive-components/Trace/Trace_doInitialPcbManualTraceRender.ts
5702
+ function Trace_doInitialPcbManualTraceRender(trace) {
5703
+ if (trace.root?.pcbDisabled) return;
5704
+ const { db } = trace.root;
5705
+ const { _parsedProps: props } = trace;
5706
+ const subcircuit = trace.getSubcircuit();
5707
+ if (!props.pcbPath || props.pcbPath.length === 0) return;
5708
+ const { allPortsFound, ports, portsWithSelectors } = trace._findConnectedPorts();
5709
+ if (!allPortsFound) return;
5710
+ const portsWithoutMatchedPcbPrimitive = [];
5711
+ for (const port of ports) {
5712
+ if (!port._hasMatchedPcbPrimitive()) {
5713
+ portsWithoutMatchedPcbPrimitive.push(port);
5714
+ }
5715
+ }
5716
+ if (portsWithoutMatchedPcbPrimitive.length > 0) {
5717
+ db.pcb_trace_error.insert({
5718
+ error_type: "pcb_trace_error",
5719
+ source_trace_id: trace.source_trace_id,
5720
+ message: `Some ports did not have a matching PCB primitive (e.g. a pad or plated hole), this can happen if a footprint is missing. As a result, ${trace} wasn't routed. Missing ports: ${portsWithoutMatchedPcbPrimitive.map((p) => p.getString()).join(", ")}`,
5721
+ pcb_trace_id: trace.pcb_trace_id,
5722
+ pcb_component_ids: [],
5723
+ pcb_port_ids: portsWithoutMatchedPcbPrimitive.map((p) => p.pcb_port_id).filter(Boolean)
5724
+ });
5725
+ return;
5726
+ }
5727
+ let anchorPort;
5728
+ if (props.pcbPathRelativeTo) {
5729
+ anchorPort = portsWithSelectors.find(
5730
+ (p) => p.selector === props.pcbPathRelativeTo
5731
+ )?.port;
5732
+ if (!anchorPort) {
5733
+ anchorPort = trace.getSubcircuit().selectOne(props.pcbPathRelativeTo);
5734
+ }
5735
+ }
5736
+ if (!anchorPort) {
5737
+ anchorPort = ports[0];
5738
+ }
5739
+ const otherPort = ports.find((p) => p !== anchorPort) ?? ports[1];
5740
+ const layer = anchorPort.getAvailablePcbLayers()[0] || "top";
5741
+ const width = props.thickness ?? trace.getSubcircuit()._parsedProps.minTraceWidth ?? 0.16;
5742
+ const anchorPos = anchorPort._getGlobalPcbPositionAfterLayout();
5743
+ const otherPos = otherPort._getGlobalPcbPositionAfterLayout();
5744
+ const route = [];
5745
+ route.push({
5746
+ route_type: "wire",
5747
+ x: anchorPos.x,
5748
+ y: anchorPos.y,
5749
+ width,
5750
+ layer,
5751
+ start_pcb_port_id: anchorPort.pcb_port_id
5752
+ });
5753
+ for (const pt of props.pcbPath) {
5754
+ route.push({
5755
+ route_type: "wire",
5756
+ x: anchorPos.x + pt.x,
5757
+ y: anchorPos.y + pt.y,
5758
+ width,
5759
+ layer
5760
+ });
5761
+ }
5762
+ route.push({
5763
+ route_type: "wire",
5764
+ x: otherPos.x,
5765
+ y: otherPos.y,
5766
+ width,
5767
+ layer,
5768
+ end_pcb_port_id: otherPort.pcb_port_id
5769
+ });
5770
+ const traceLength = getTraceLength(route);
5771
+ const pcb_trace = db.pcb_trace.insert({
5772
+ route,
5773
+ source_trace_id: trace.source_trace_id,
5774
+ subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
5775
+ pcb_group_id: trace.getGroup()?.pcb_group_id ?? void 0,
5776
+ trace_length: traceLength
5777
+ });
5778
+ trace._portsRoutedOnPcb = ports;
5779
+ trace.pcb_trace_id = pcb_trace.pcb_trace_id;
5780
+ trace._insertErrorIfTraceIsOutsideBoard(route, ports);
5781
+ }
5782
+
5697
5783
  // lib/components/primitive-components/Trace/Trace__doInitialSchematicTraceRenderWithDisplayLabel.ts
5698
5784
  function Trace__doInitialSchematicTraceRenderWithDisplayLabel(trace) {
5699
5785
  if (trace.root?.schematicDisabled) return;
@@ -6035,6 +6121,9 @@ var Trace3 = class extends PrimitiveComponent2 {
6035
6121
  });
6036
6122
  }
6037
6123
  }
6124
+ doInitialPcbManualTraceRender() {
6125
+ Trace_doInitialPcbManualTraceRender(this);
6126
+ }
6038
6127
  doInitialPcbTraceRender() {
6039
6128
  Trace_doInitialPcbTraceRender(this);
6040
6129
  }
@@ -10746,16 +10835,26 @@ var PinHeader = class extends NormalComponent {
10746
10835
  const holeDiameter = this._parsedProps.holeDiameter;
10747
10836
  const platedDiameter = this._parsedProps.platedDiameter;
10748
10837
  const pitch = this._parsedProps.pitch;
10838
+ const showSilkscreenPinLabels = this._parsedProps.showSilkscreenPinLabels;
10749
10839
  if (pinCount > 0) {
10840
+ let footprintString;
10750
10841
  if (pitch) {
10751
10842
  if (!holeDiameter && !platedDiameter) {
10752
- return `pinrow${pinCount}_p${pitch}`;
10843
+ footprintString = `pinrow${pinCount}_p${pitch}`;
10844
+ } else {
10845
+ footprintString = `pinrow${pinCount}_p${pitch}_id${holeDiameter}_od${platedDiameter}`;
10846
+ }
10847
+ } else {
10848
+ if (!holeDiameter && !platedDiameter) {
10849
+ footprintString = `pinrow${pinCount}`;
10850
+ } else {
10851
+ return null;
10753
10852
  }
10754
- return `pinrow${pinCount}_p${pitch}_id${holeDiameter}_od${platedDiameter}`;
10755
10853
  }
10756
- if (!holeDiameter && !platedDiameter) {
10757
- return `pinrow${pinCount}`;
10854
+ if (showSilkscreenPinLabels !== true) {
10855
+ footprintString += "_nopinlabels";
10758
10856
  }
10857
+ return footprintString;
10759
10858
  }
10760
10859
  return null;
10761
10860
  }
@@ -11647,7 +11746,7 @@ import { identity as identity5 } from "transformation-matrix";
11647
11746
  var package_default = {
11648
11747
  name: "@tscircuit/core",
11649
11748
  type: "module",
11650
- version: "0.0.613",
11749
+ version: "0.0.615",
11651
11750
  types: "dist/index.d.ts",
11652
11751
  main: "dist/index.js",
11653
11752
  module: "dist/index.js",
@@ -11679,7 +11778,7 @@ var package_default = {
11679
11778
  "@tscircuit/log-soup": "^1.0.2",
11680
11779
  "@tscircuit/math-utils": "^0.0.18",
11681
11780
  "@tscircuit/miniflex": "^0.0.4",
11682
- "@tscircuit/props": "^0.0.278",
11781
+ "@tscircuit/props": "^0.0.281",
11683
11782
  "@tscircuit/schematic-autolayout": "^0.0.6",
11684
11783
  "@tscircuit/schematic-corpus": "^0.0.110",
11685
11784
  "@tscircuit/schematic-match-adapt": "^0.0.16",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.614",
4
+ "version": "0.0.616",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -33,7 +33,7 @@
33
33
  "@tscircuit/log-soup": "^1.0.2",
34
34
  "@tscircuit/math-utils": "^0.0.18",
35
35
  "@tscircuit/miniflex": "^0.0.4",
36
- "@tscircuit/props": "^0.0.278",
36
+ "@tscircuit/props": "^0.0.281",
37
37
  "@tscircuit/schematic-autolayout": "^0.0.6",
38
38
  "@tscircuit/schematic-corpus": "^0.0.110",
39
39
  "@tscircuit/schematic-match-adapt": "^0.0.16",