@tscircuit/core 0.0.118 → 0.0.120

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
@@ -552,6 +552,7 @@ declare class Port extends PrimitiveComponent<typeof portProps> {
552
552
  schematicSymbolPortDef: SchSymbol["ports"][number] | null;
553
553
  matchedComponents: PrimitiveComponent[];
554
554
  facingDirection: "up" | "down" | "left" | "right" | null;
555
+ originDescription: string | null;
555
556
  get config(): {
556
557
  componentName: string;
557
558
  zodProps: z.ZodObject<{
@@ -568,7 +569,9 @@ declare class Port extends PrimitiveComponent<typeof portProps> {
568
569
  aliases?: string[] | undefined;
569
570
  }>;
570
571
  };
571
- constructor(props: z.input<typeof portProps>);
572
+ constructor(props: z.input<typeof portProps>, opts?: {
573
+ originDescription?: string;
574
+ });
572
575
  _getGlobalPcbPositionBeforeLayout(): {
573
576
  x: number;
574
577
  y: number;
@@ -1046,6 +1049,8 @@ declare class Capacitor extends NormalComponent<typeof capacitorProps, PassivePo
1046
1049
  }>]>>;
1047
1050
  children: zod.ZodOptional<zod.ZodAny>;
1048
1051
  symbolName: zod.ZodOptional<zod.ZodString>;
1052
+ width: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
1053
+ height: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
1049
1054
  }>, {
1050
1055
  capacitance: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
1051
1056
  decouplingFor: zod.ZodOptional<zod.ZodString>;
@@ -1120,6 +1125,8 @@ declare class Capacitor extends NormalComponent<typeof capacitorProps, PassivePo
1120
1125
  } | undefined;
1121
1126
  children?: any;
1122
1127
  symbolName?: string | undefined;
1128
+ width?: number | undefined;
1129
+ height?: number | undefined;
1123
1130
  decouplingFor?: string | undefined;
1124
1131
  decouplingTo?: string | undefined;
1125
1132
  bypassFor?: string | undefined;
@@ -1194,6 +1201,8 @@ declare class Capacitor extends NormalComponent<typeof capacitorProps, PassivePo
1194
1201
  } | undefined;
1195
1202
  children?: any;
1196
1203
  symbolName?: string | undefined;
1204
+ width?: string | number | undefined;
1205
+ height?: string | number | undefined;
1197
1206
  decouplingFor?: string | undefined;
1198
1207
  decouplingTo?: string | undefined;
1199
1208
  bypassFor?: string | undefined;
@@ -1493,9 +1502,11 @@ declare class Chip<PinLabels extends string = never> extends NormalComponent<typ
1493
1502
  }>]>>;
1494
1503
  children: zod.ZodOptional<zod.ZodAny>;
1495
1504
  symbolName: zod.ZodOptional<zod.ZodString>;
1505
+ width: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
1506
+ height: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
1496
1507
  }>, {
1497
1508
  manufacturerPartNumber: zod.ZodOptional<zod.ZodString>;
1498
- pinLabels: zod.ZodOptional<zod.ZodRecord<zod.ZodUnion<[zod.ZodNumber, zod.ZodString]>, zod.ZodString>>;
1509
+ pinLabels: zod.ZodOptional<zod.ZodRecord<zod.ZodUnion<[zod.ZodNumber, zod.ZodString]>, zod.ZodUnion<[zod.ZodString, zod.ZodArray<zod.ZodString, "many">]>>>;
1499
1510
  schPortArrangement: zod.ZodOptional<zod.ZodObject<{
1500
1511
  leftSize: zod.ZodOptional<zod.ZodNumber>;
1501
1512
  topSize: zod.ZodOptional<zod.ZodNumber>;
@@ -1682,8 +1693,10 @@ declare class Chip<PinLabels extends string = never> extends NormalComponent<typ
1682
1693
  } | undefined;
1683
1694
  children?: any;
1684
1695
  symbolName?: string | undefined;
1696
+ width?: number | undefined;
1697
+ height?: number | undefined;
1685
1698
  manufacturerPartNumber?: string | undefined;
1686
- pinLabels?: Record<string | number, string> | undefined;
1699
+ pinLabels?: Record<string | number, string | string[]> | undefined;
1687
1700
  schPortArrangement?: {
1688
1701
  leftSize?: number | undefined;
1689
1702
  topSize?: number | undefined;
@@ -1788,8 +1801,10 @@ declare class Chip<PinLabels extends string = never> extends NormalComponent<typ
1788
1801
  } | undefined;
1789
1802
  children?: any;
1790
1803
  symbolName?: string | undefined;
1804
+ width?: string | number | undefined;
1805
+ height?: string | number | undefined;
1791
1806
  manufacturerPartNumber?: string | undefined;
1792
- pinLabels?: Record<string | number, string> | undefined;
1807
+ pinLabels?: Record<string | number, string | string[]> | undefined;
1793
1808
  schPortArrangement?: {
1794
1809
  leftSize?: number | undefined;
1795
1810
  topSize?: number | undefined;
@@ -2092,6 +2107,8 @@ declare class Diode extends NormalComponent<typeof diodeProps, PolarizedPassiveP
2092
2107
  }>]>>;
2093
2108
  children: zod.ZodOptional<zod.ZodAny>;
2094
2109
  symbolName: zod.ZodOptional<zod.ZodString>;
2110
+ width: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
2111
+ height: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
2095
2112
  }>, {}>, "strip", zod.ZodTypeAny, {
2096
2113
  name: string;
2097
2114
  pcbX?: number | undefined;
@@ -2159,6 +2176,8 @@ declare class Diode extends NormalComponent<typeof diodeProps, PolarizedPassiveP
2159
2176
  } | undefined;
2160
2177
  children?: any;
2161
2178
  symbolName?: string | undefined;
2179
+ width?: number | undefined;
2180
+ height?: number | undefined;
2162
2181
  }, {
2163
2182
  name: string;
2164
2183
  pcbX?: string | number | undefined;
@@ -2228,6 +2247,8 @@ declare class Diode extends NormalComponent<typeof diodeProps, PolarizedPassiveP
2228
2247
  } | undefined;
2229
2248
  children?: any;
2230
2249
  symbolName?: string | undefined;
2250
+ width?: string | number | undefined;
2251
+ height?: string | number | undefined;
2231
2252
  }>;
2232
2253
  sourceFtype: Ftype;
2233
2254
  };
@@ -2498,6 +2519,8 @@ declare class Jumper<PinLabels extends string = never> extends NormalComponent<t
2498
2519
  }>]>>;
2499
2520
  children: zod.ZodOptional<zod.ZodAny>;
2500
2521
  symbolName: zod.ZodOptional<zod.ZodString>;
2522
+ width: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
2523
+ height: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
2501
2524
  }>, {
2502
2525
  manufacturerPartNumber: zod.ZodOptional<zod.ZodString>;
2503
2526
  pinLabels: zod.ZodOptional<zod.ZodRecord<zod.ZodUnion<[zod.ZodNumber, zod.ZodString]>, zod.ZodString>>;
@@ -2688,6 +2711,8 @@ declare class Jumper<PinLabels extends string = never> extends NormalComponent<t
2688
2711
  } | undefined;
2689
2712
  children?: any;
2690
2713
  symbolName?: string | undefined;
2714
+ width?: number | undefined;
2715
+ height?: number | undefined;
2691
2716
  manufacturerPartNumber?: string | undefined;
2692
2717
  pinLabels?: Record<string | number, string> | undefined;
2693
2718
  schPortArrangement?: {
@@ -2795,6 +2820,8 @@ declare class Jumper<PinLabels extends string = never> extends NormalComponent<t
2795
2820
  } | undefined;
2796
2821
  children?: any;
2797
2822
  symbolName?: string | undefined;
2823
+ width?: string | number | undefined;
2824
+ height?: string | number | undefined;
2798
2825
  manufacturerPartNumber?: string | undefined;
2799
2826
  pinLabels?: Record<string | number, string> | undefined;
2800
2827
  schPortArrangement?: {
@@ -3100,6 +3127,8 @@ declare class Led extends NormalComponent<typeof ledProps, PolarizedPassivePorts
3100
3127
  }>]>>;
3101
3128
  children: zod.ZodOptional<zod.ZodAny>;
3102
3129
  symbolName: zod.ZodOptional<zod.ZodString>;
3130
+ width: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
3131
+ height: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
3103
3132
  }>, {
3104
3133
  color: zod.ZodOptional<zod.ZodString>;
3105
3134
  }>, "strip", zod.ZodTypeAny, {
@@ -3169,6 +3198,8 @@ declare class Led extends NormalComponent<typeof ledProps, PolarizedPassivePorts
3169
3198
  } | undefined;
3170
3199
  children?: any;
3171
3200
  symbolName?: string | undefined;
3201
+ width?: number | undefined;
3202
+ height?: number | undefined;
3172
3203
  color?: string | undefined;
3173
3204
  }, {
3174
3205
  name: string;
@@ -3239,6 +3270,8 @@ declare class Led extends NormalComponent<typeof ledProps, PolarizedPassivePorts
3239
3270
  } | undefined;
3240
3271
  children?: any;
3241
3272
  symbolName?: string | undefined;
3273
+ width?: string | number | undefined;
3274
+ height?: string | number | undefined;
3242
3275
  color?: string | undefined;
3243
3276
  }>;
3244
3277
  sourceFtype: Ftype;
@@ -3510,6 +3543,8 @@ declare class PowerSource extends NormalComponent<typeof powerSourceProps, Polar
3510
3543
  }>]>>;
3511
3544
  children: zod.ZodOptional<zod.ZodAny>;
3512
3545
  symbolName: zod.ZodOptional<zod.ZodString>;
3546
+ width: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
3547
+ height: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
3513
3548
  }>, {
3514
3549
  voltage: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
3515
3550
  }>, "strip", zod.ZodTypeAny, {
@@ -3580,6 +3615,8 @@ declare class PowerSource extends NormalComponent<typeof powerSourceProps, Polar
3580
3615
  } | undefined;
3581
3616
  children?: any;
3582
3617
  symbolName?: string | undefined;
3618
+ width?: number | undefined;
3619
+ height?: number | undefined;
3583
3620
  }, {
3584
3621
  name: string;
3585
3622
  voltage: string | number;
@@ -3650,6 +3687,8 @@ declare class PowerSource extends NormalComponent<typeof powerSourceProps, Polar
3650
3687
  } | undefined;
3651
3688
  children?: any;
3652
3689
  symbolName?: string | undefined;
3690
+ width?: string | number | undefined;
3691
+ height?: string | number | undefined;
3653
3692
  }>;
3654
3693
  sourceFtype: Ftype;
3655
3694
  };
@@ -3920,6 +3959,8 @@ declare class Resistor extends NormalComponent<typeof resistorProps, PassivePort
3920
3959
  }>]>>;
3921
3960
  children: zod.ZodOptional<zod.ZodAny>;
3922
3961
  symbolName: zod.ZodOptional<zod.ZodString>;
3962
+ width: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
3963
+ height: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
3923
3964
  }>, {
3924
3965
  resistance: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
3925
3966
  pullupFor: zod.ZodOptional<zod.ZodString>;
@@ -3994,6 +4035,8 @@ declare class Resistor extends NormalComponent<typeof resistorProps, PassivePort
3994
4035
  } | undefined;
3995
4036
  children?: any;
3996
4037
  symbolName?: string | undefined;
4038
+ width?: number | undefined;
4039
+ height?: number | undefined;
3997
4040
  pullupFor?: string | undefined;
3998
4041
  pullupTo?: string | undefined;
3999
4042
  pulldownFor?: string | undefined;
@@ -4068,6 +4111,8 @@ declare class Resistor extends NormalComponent<typeof resistorProps, PassivePort
4068
4111
  } | undefined;
4069
4112
  children?: any;
4070
4113
  symbolName?: string | undefined;
4114
+ width?: string | number | undefined;
4115
+ height?: string | number | undefined;
4071
4116
  pullupFor?: string | undefined;
4072
4117
  pullupTo?: string | undefined;
4073
4118
  pulldownFor?: string | undefined;
package/dist/index.js CHANGED
@@ -739,6 +739,9 @@ var PrimitiveComponent = class extends Renderable {
739
739
  }
740
740
  getString() {
741
741
  const { lowercaseComponentName: cname, _parsedProps: props, parent } = this;
742
+ if (props?.pinNumber !== void 0 && parent?.props?.name && props?.name) {
743
+ return `<${cname}#${this._renderId}(pin:${props.pinNumber} .${parent?.props.name}>.${props.name}) />`;
744
+ }
742
745
  if (parent?.props?.name && props?.name) {
743
746
  return `<${cname}#${this._renderId}(.${parent?.props.name}>.${props?.name}) />`;
744
747
  }
@@ -974,7 +977,7 @@ var SmtPad = class extends PrimitiveComponent {
974
977
  const decomposedMat = decomposeTSR(
975
978
  this._computePcbGlobalTransformBeforeLayout()
976
979
  );
977
- const isRotated90 = Math.abs(decomposedMat.rotation.angle * (180 / Math.PI) - 90) < 0.01;
980
+ const isRotated90 = Math.abs(decomposedMat.rotation.angle * (180 / Math.PI) - 90) % 180 < 0.01;
978
981
  const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
979
982
  let pcb_smtpad = null;
980
983
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
@@ -1239,7 +1242,7 @@ var Keepout = class extends PrimitiveComponent {
1239
1242
  const decomposedMat = decomposeTSR2(
1240
1243
  this._computePcbGlobalTransformBeforeLayout()
1241
1244
  );
1242
- const isRotated90 = Math.abs(decomposedMat.rotation.angle * (180 / Math.PI) - 90) < 0.01;
1245
+ const isRotated90 = Math.abs(decomposedMat.rotation.angle * (180 / Math.PI) - 90) % 180 < 0.01;
1243
1246
  let pcb_keepout = null;
1244
1247
  if (props.shape === "circle") {
1245
1248
  pcb_keepout = db.pcb_keepout.insert({
@@ -1465,18 +1468,22 @@ var Port = class extends PrimitiveComponent {
1465
1468
  schematicSymbolPortDef = null;
1466
1469
  matchedComponents;
1467
1470
  facingDirection = null;
1471
+ originDescription = null;
1468
1472
  get config() {
1469
1473
  return {
1470
1474
  componentName: "Port",
1471
1475
  zodProps: portProps
1472
1476
  };
1473
1477
  }
1474
- constructor(props) {
1478
+ constructor(props, opts = {}) {
1475
1479
  if (!props.name && props.pinNumber) props.name = `pin${props.pinNumber}`;
1476
1480
  if (!props.name) {
1477
1481
  throw new Error("Port must have a name or a pinNumber");
1478
1482
  }
1479
1483
  super(props);
1484
+ if (opts.originDescription) {
1485
+ this.originDescription = opts.originDescription;
1486
+ }
1480
1487
  this.matchedComponents = [];
1481
1488
  }
1482
1489
  _getGlobalPcbPositionBeforeLayout() {
@@ -1879,6 +1886,8 @@ var Footprint = class extends PrimitiveComponent {
1879
1886
  };
1880
1887
 
1881
1888
  // lib/components/base-components/NormalComponent.ts
1889
+ import Debug2 from "debug";
1890
+ var debug2 = Debug2("tscircuit:core");
1882
1891
  var rotation3 = z4.object({
1883
1892
  x: rotation,
1884
1893
  y: rotation,
@@ -1915,7 +1924,16 @@ var NormalComponent = class extends PrimitiveComponent {
1915
1924
  const pins = schPortArrangement[side].pins;
1916
1925
  if (Array.isArray(pins)) {
1917
1926
  for (const pinNumber of pins) {
1918
- portsToCreate.push(new Port({ pinNumber }));
1927
+ portsToCreate.push(
1928
+ new Port(
1929
+ {
1930
+ pinNumber
1931
+ },
1932
+ {
1933
+ originDescription: `schPortArrangement:${side}`
1934
+ }
1935
+ )
1936
+ );
1919
1937
  }
1920
1938
  }
1921
1939
  }
@@ -1927,15 +1945,23 @@ var NormalComponent = class extends PrimitiveComponent {
1927
1945
  let existingPort = portsToCreate.find(
1928
1946
  (p) => p._parsedProps.pinNumber === Number(pinNumber)
1929
1947
  );
1948
+ const primaryLabel = Array.isArray(label) ? label[0] : label;
1949
+ const otherLabels = Array.isArray(label) ? label.slice(1) : [];
1930
1950
  if (!existingPort) {
1931
- existingPort = new Port({
1932
- pinNumber: parseInt(pinNumber),
1933
- name: label
1934
- });
1951
+ existingPort = new Port(
1952
+ {
1953
+ pinNumber: parseInt(pinNumber),
1954
+ name: primaryLabel,
1955
+ aliases: otherLabels
1956
+ },
1957
+ {
1958
+ originDescription: `pinLabels:pin${pinNumber}`
1959
+ }
1960
+ );
1935
1961
  portsToCreate.push(existingPort);
1936
1962
  } else {
1937
- existingPort.externallyAddedAliases.push(label);
1938
- existingPort.props.name = label;
1963
+ existingPort.externallyAddedAliases.push(primaryLabel, ...otherLabels);
1964
+ existingPort.props.name = primaryLabel;
1939
1965
  }
1940
1966
  }
1941
1967
  }
@@ -1945,6 +1971,7 @@ var NormalComponent = class extends PrimitiveComponent {
1945
1971
  for (const symPort of sym.ports) {
1946
1972
  const port = getPortFromHints(symPort.labels);
1947
1973
  if (port) {
1974
+ port.originDescription = `schematicSymbol:labels[0]:${symPort.labels[0]}`;
1948
1975
  port.schematicSymbolPortDef = symPort;
1949
1976
  portsToCreate.push(port);
1950
1977
  }
@@ -2107,8 +2134,8 @@ var NormalComponent = class extends PrimitiveComponent {
2107
2134
  (p) => p.isMatchingAnyOf(component.getNameAndAliases())
2108
2135
  );
2109
2136
  if (conflictingPort) {
2110
- throw new Error(
2111
- `Conflicting ports added. Port 1: ${conflictingPort}, Port 2: ${component}`
2137
+ debug2(
2138
+ `Similar ports added. Port 1: ${conflictingPort}, Port 2: ${component}`
2112
2139
  );
2113
2140
  }
2114
2141
  }
@@ -2126,6 +2153,7 @@ var NormalComponent = class extends PrimitiveComponent {
2126
2153
  if ("port_hints" in elm && elm.port_hints) {
2127
2154
  const newPort = getPortFromHints(elm.port_hints);
2128
2155
  if (!newPort) continue;
2156
+ newPort.originDescription = `footprint:string:${footprint}:port_hints[0]:${elm.port_hints[0]}`;
2129
2157
  newPorts2.push(newPort);
2130
2158
  }
2131
2159
  }
@@ -2137,6 +2165,7 @@ var NormalComponent = class extends PrimitiveComponent {
2137
2165
  for (const fpChild of fp2.children) {
2138
2166
  const newPort = getPortFromHints(fpChild.props.portHints ?? []);
2139
2167
  if (!newPort) continue;
2168
+ newPort.originDescription = `footprint:${footprint}`;
2140
2169
  newPorts2.push(newPort);
2141
2170
  }
2142
2171
  return newPorts2;
@@ -3437,6 +3466,10 @@ var Chip = class extends NormalComponent {
3437
3466
  schPortArrangement: props.schPortArrangement
3438
3467
  });
3439
3468
  this.schematicDimensions = dimensions;
3469
+ const primaryPortLabels = {};
3470
+ for (const [port, label] of Object.entries(props.pinLabels ?? {})) {
3471
+ primaryPortLabels[port] = Array.isArray(label) ? label[0] : label;
3472
+ }
3440
3473
  const schematic_component2 = db.schematic_component.insert({
3441
3474
  center: { x: props.schX ?? 0, y: props.schY ?? 0 },
3442
3475
  rotation: props.schRotation ?? 0,
@@ -3447,7 +3480,7 @@ var Chip = class extends NormalComponent {
3447
3480
  pin_spacing: pinSpacing,
3448
3481
  // @ts-ignore soup needs to support distance for pin_styles
3449
3482
  pin_styles: underscorifyPinStyles(props.schPinStyle),
3450
- port_labels: props.pinLabels,
3483
+ port_labels: primaryPortLabels,
3451
3484
  source_component_id: this.source_component_id
3452
3485
  });
3453
3486
  this.schematic_component_id = schematic_component2.schematic_component_id;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.118",
4
+ "version": "0.0.120",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -39,7 +39,7 @@
39
39
  "@tscircuit/footprinter": "^0.0.71",
40
40
  "@tscircuit/infgrid-ijump-astar": "^0.0.21",
41
41
  "@tscircuit/math-utils": "^0.0.4",
42
- "@tscircuit/props": "^0.0.68",
42
+ "@tscircuit/props": "^0.0.70",
43
43
  "@tscircuit/soup-util": "^0.0.33",
44
44
  "circuit-json": "^0.0.85",
45
45
  "circuit-json-to-connectivity-map": "^0.0.17",