@tscircuit/core 0.0.91 → 0.0.93

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +417 -116
  2. package/dist/index.js +97 -58
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -34,13 +34,15 @@ __export(components_exports, {
34
34
  TraceHint: () => TraceHint
35
35
  });
36
36
 
37
+ // lib/components/primitive-components/Footprint.ts
38
+ import { footprintProps } from "@tscircuit/props";
39
+
37
40
  // lib/components/base-components/PrimitiveComponent.ts
38
41
  import { z } from "zod";
39
42
  import { symbols } from "schematic-symbols";
40
43
  import "react";
41
44
 
42
45
  // lib/components/base-components/Renderable.ts
43
- import "react";
44
46
  var orderedRenderPhases = [
45
47
  "ReactSubtreesRender",
46
48
  "InitializePortsFromChildren",
@@ -177,13 +179,18 @@ var PrimitiveComponent = class extends Renderable {
177
179
  childrenPendingRemoval;
178
180
  get config() {
179
181
  return {
182
+ componentName: "",
180
183
  zodProps: z.object({}).passthrough()
181
184
  };
182
185
  }
183
186
  props;
184
187
  _parsedProps;
185
- componentName = "";
186
- lowercaseComponentName = "";
188
+ get componentName() {
189
+ return this.config.componentName;
190
+ }
191
+ get lowercaseComponentName() {
192
+ return this.componentName.toLowerCase();
193
+ }
187
194
  externallyAddedAliases;
188
195
  /**
189
196
  * An subcircuit is self-contained. All the selectors inside
@@ -220,10 +227,6 @@ var PrimitiveComponent = class extends Renderable {
220
227
  this._parsedProps = this.config.zodProps.parse(
221
228
  props ?? {}
222
229
  );
223
- if (!this.componentName) {
224
- this.componentName = this.constructor.name;
225
- }
226
- this.lowercaseComponentName = this.componentName.toLowerCase();
227
230
  }
228
231
  setProps(props) {
229
232
  const newProps = this.config.zodProps.parse({
@@ -573,7 +576,12 @@ import * as kiwi from "@lume/kiwi";
573
576
  import Debug from "debug";
574
577
  var debug = Debug("tscircuit:core:footprint");
575
578
  var Footprint = class extends PrimitiveComponent {
576
- componentName = "Footprint";
579
+ get config() {
580
+ return {
581
+ componentName: "Footprint",
582
+ zodProps: footprintProps
583
+ };
584
+ }
577
585
  /**
578
586
  * A footprint is a constrainedlayout, the db elements are adjusted according
579
587
  * to any constraints that are defined.
@@ -774,9 +782,6 @@ var Footprint = class extends PrimitiveComponent {
774
782
  // lib/components/base-components/NormalComponent.ts
775
783
  import { z as z4 } from "zod";
776
784
 
777
- // lib/components/primitive-components/Port.ts
778
- import { z as z2 } from "zod";
779
-
780
785
  // lib/utils/get-relative-direction.ts
781
786
  function getRelativeDirection(pointA, pointB) {
782
787
  const dx = pointB.x - pointA.x;
@@ -790,6 +795,7 @@ function getRelativeDirection(pointA, pointB) {
790
795
  // lib/components/primitive-components/Port.ts
791
796
  import "schematic-symbols";
792
797
  import { applyToPoint as applyToPoint2, compose as compose2, translate as translate2 } from "transformation-matrix";
798
+ import { z as z2 } from "zod";
793
799
  var portProps = z2.object({
794
800
  name: z2.string().optional(),
795
801
  pinNumber: z2.number().optional(),
@@ -802,7 +808,12 @@ var Port = class extends PrimitiveComponent {
802
808
  schematicSymbolPortDef = null;
803
809
  matchedComponents;
804
810
  facingDirection = null;
805
- componentName = "Port";
811
+ get config() {
812
+ return {
813
+ componentName: "Port",
814
+ zodProps: portProps
815
+ };
816
+ }
806
817
  constructor(props) {
807
818
  if (!props.name && props.pinNumber) props.name = `pin${props.pinNumber}`;
808
819
  if (!props.name) {
@@ -842,12 +853,12 @@ var Port = class extends PrimitiveComponent {
842
853
  x: 0,
843
854
  y: 0
844
855
  });
845
- throw new Error(
846
- `Could not find schematic symbol port for port ${this} so couldn't determine port position`
847
- );
848
856
  }
849
857
  const symbol = this.parent?.getSchematicSymbol();
850
- if (!symbol) throw new Error(`Could not find parent symbol for ${this}`);
858
+ if (!symbol) {
859
+ console.warn(`Could not find parent symbol for ${this}`);
860
+ return { x: 0, y: 0 };
861
+ }
851
862
  const transform = compose2(
852
863
  this.parent.computeSchematicGlobalTransform(),
853
864
  translate2(-symbol.center.x, -symbol.center.y)
@@ -981,7 +992,7 @@ var Port = class extends PrimitiveComponent {
981
992
  };
982
993
 
983
994
  // lib/components/base-components/NormalComponent.ts
984
- import { symbols as symbols3 } from "schematic-symbols";
995
+ import { symbols as symbols2 } from "schematic-symbols";
985
996
  import { fp } from "footprinter";
986
997
  import {
987
998
  isValidElement as isReactElement2,
@@ -1164,9 +1175,9 @@ var SmtPad = class extends PrimitiveComponent {
1164
1175
  pcb_smtpad_id = null;
1165
1176
  matchedPort = null;
1166
1177
  isPcbPrimitive = true;
1167
- componentName = "SmtPad";
1168
1178
  get config() {
1169
1179
  return {
1180
+ componentName: "SmtPad",
1170
1181
  zodProps: smtPadProps
1171
1182
  };
1172
1183
  }
@@ -1295,9 +1306,9 @@ import { silkscreenPathProps } from "@tscircuit/props";
1295
1306
  import { applyToPoint as applyToPoint4 } from "transformation-matrix";
1296
1307
  var SilkscreenPath = class extends PrimitiveComponent {
1297
1308
  pcb_silkscreen_path_id = null;
1298
- componentName = "SilkscreenPath";
1299
1309
  get config() {
1300
1310
  return {
1311
+ componentName: "SilkscreenPath",
1301
1312
  zodProps: silkscreenPathProps
1302
1313
  };
1303
1314
  }
@@ -1337,9 +1348,9 @@ var PlatedHole = class extends PrimitiveComponent {
1337
1348
  pcb_plated_hole_id = null;
1338
1349
  matchedPort = null;
1339
1350
  isPcbPrimitive = true;
1340
- componentName = "PlatedHole";
1341
1351
  get config() {
1342
1352
  return {
1353
+ componentName: "PlatedHole",
1343
1354
  zodProps: platedHoleProps
1344
1355
  };
1345
1356
  }
@@ -1432,9 +1443,9 @@ import { decomposeTSR as decomposeTSR2 } from "transformation-matrix";
1432
1443
  var Keepout = class extends PrimitiveComponent {
1433
1444
  pcb_keepout_id = null;
1434
1445
  isPcbPrimitive = true;
1435
- componentName = "Keepout";
1436
1446
  get config() {
1437
1447
  return {
1448
+ componentName: "Keepout",
1438
1449
  zodProps: pcbKeepoutProps
1439
1450
  };
1440
1451
  }
@@ -1567,7 +1578,12 @@ var netProps = z3.object({
1567
1578
  });
1568
1579
  var Net = class extends PrimitiveComponent {
1569
1580
  source_net_id;
1570
- componentName = "Net";
1581
+ get config() {
1582
+ return {
1583
+ componentName: "Net",
1584
+ zodProps: netProps
1585
+ };
1586
+ }
1571
1587
  getPortSelector() {
1572
1588
  return `net.${this.props.name}`;
1573
1589
  }
@@ -1773,7 +1789,7 @@ var NormalComponent = class extends PrimitiveComponent {
1773
1789
  const { config } = this;
1774
1790
  const portsToCreate = [];
1775
1791
  if (config.schematicSymbolName) {
1776
- const sym = symbols3[`${config.schematicSymbolName}_horz`];
1792
+ const sym = symbols2[`${config.schematicSymbolName}_horz`];
1777
1793
  if (!sym) return;
1778
1794
  for (const symPort of sym.ports) {
1779
1795
  const port = getPortFromHints(symPort.labels);
@@ -1863,8 +1879,8 @@ var NormalComponent = class extends PrimitiveComponent {
1863
1879
  const { db } = this.root;
1864
1880
  const { schematicSymbolName } = this.config;
1865
1881
  if (!schematicSymbolName) return;
1866
- const symbol_name = `${this.config.schematicSymbolName}_horz`;
1867
- const symbol = symbols3[symbol_name];
1882
+ const symbol_name = `${this.config.schematicSymbolName}`;
1883
+ const symbol = symbols2[symbol_name];
1868
1884
  if (!symbol) {
1869
1885
  throw new Error(`Could not find schematic-symbol "${symbol_name}"`);
1870
1886
  }
@@ -2000,7 +2016,7 @@ var NormalComponent = class extends PrimitiveComponent {
2000
2016
  getPortsFromSchematicSymbol() {
2001
2017
  const { config } = this;
2002
2018
  if (!config.schematicSymbolName) return [];
2003
- const symbol = symbols3[config.schematicSymbolName];
2019
+ const symbol = symbols2[config.schematicSymbolName];
2004
2020
  if (!symbol) return [];
2005
2021
  const newPorts = [];
2006
2022
  for (const symbolPort of symbol.ports) {
@@ -2113,11 +2129,16 @@ import "transformation-matrix";
2113
2129
  import "zod";
2114
2130
 
2115
2131
  // lib/components/primitive-components/TraceHint.ts
2116
- import "@tscircuit/props";
2132
+ import { traceHintProps } from "@tscircuit/props";
2117
2133
  import { applyToPoint as applyToPoint5 } from "transformation-matrix";
2118
2134
  var TraceHint = class extends PrimitiveComponent {
2119
2135
  matchedPort = null;
2120
- componentName = "TraceHint";
2136
+ get config() {
2137
+ return {
2138
+ componentName: "TraceHint",
2139
+ zodProps: traceHintProps
2140
+ };
2141
+ }
2121
2142
  doInitialPortMatching() {
2122
2143
  const { db } = this.root;
2123
2144
  const { _parsedProps: props, parent } = this;
@@ -2171,10 +2192,10 @@ var TraceHint = class extends PrimitiveComponent {
2171
2192
  var Group = class extends NormalComponent {
2172
2193
  get config() {
2173
2194
  return {
2174
- zodProps: groupProps
2195
+ zodProps: groupProps,
2196
+ componentName: "Group"
2175
2197
  };
2176
2198
  }
2177
- componentName = "Group";
2178
2199
  doInitialCreateTraceHintsFromProps() {
2179
2200
  const { _parsedProps: props } = this;
2180
2201
  const { db } = this.root;
@@ -2196,12 +2217,12 @@ var Group = class extends NormalComponent {
2196
2217
  // lib/components/normal-components/Board.ts
2197
2218
  var Board = class extends Group {
2198
2219
  pcb_board_id = null;
2199
- componentName = "Board";
2200
2220
  get isSubcircuit() {
2201
2221
  return true;
2202
2222
  }
2203
2223
  get config() {
2204
2224
  return {
2225
+ componentName: "Board",
2205
2226
  zodProps: boardProps
2206
2227
  };
2207
2228
  }
@@ -2244,7 +2265,6 @@ var Board = class extends Group {
2244
2265
 
2245
2266
  // lib/components/normal-components/Resistor.ts
2246
2267
  import { resistorProps } from "@tscircuit/props";
2247
- import "zod";
2248
2268
 
2249
2269
  // lib/components/primitive-components/Trace.ts
2250
2270
  import { traceProps } from "@tscircuit/props";
@@ -2439,14 +2459,14 @@ var Trace = class extends PrimitiveComponent {
2439
2459
  pcb_trace_id = null;
2440
2460
  schematic_trace_id = null;
2441
2461
  _portsRoutedOnPcb;
2442
- componentName = "Trace";
2443
2462
  constructor(props) {
2444
2463
  super(props);
2445
2464
  this._portsRoutedOnPcb = [];
2446
2465
  }
2447
2466
  get config() {
2448
2467
  return {
2449
- zodProps: traceProps
2468
+ zodProps: traceProps,
2469
+ componentName: "Trace"
2450
2470
  };
2451
2471
  }
2452
2472
  _getTracePortOrNetSelectorListFromProps() {
@@ -2878,16 +2898,19 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
2878
2898
 
2879
2899
  // lib/components/normal-components/Resistor.ts
2880
2900
  var Resistor = class extends NormalComponent {
2881
- componentName = "Resistor";
2901
+ // @ts-ignore (cause the symbolName is string and not fixed)
2882
2902
  get config() {
2883
2903
  return {
2884
- schematicSymbolName: "boxresistor",
2904
+ componentName: "Resistor",
2905
+ schematicSymbolName: this.props.symbolName ?? "boxresistor_horz",
2885
2906
  zodProps: resistorProps,
2886
2907
  sourceFtype: "simple_resistor"
2887
2908
  };
2888
2909
  }
2889
- pin1 = this.portMap.pin1;
2890
- pin2 = this.portMap.pin2;
2910
+ initPorts() {
2911
+ this.add(new Port({ name: "pin1", pinNumber: 1, aliases: ["anode", "pos"] }));
2912
+ this.add(new Port({ name: "pin2", pinNumber: 2, aliases: ["cathode", "neg"] }));
2913
+ }
2891
2914
  doInitialCreateNetsFromProps() {
2892
2915
  this._createNetsFromProps([this.props.pullupFor, this.props.pullupTo]);
2893
2916
  }
@@ -2925,19 +2948,22 @@ var Resistor = class extends NormalComponent {
2925
2948
  // lib/components/normal-components/Led.ts
2926
2949
  import { ledProps } from "@tscircuit/props";
2927
2950
  var Led = class extends NormalComponent {
2951
+ // @ts-ignore
2928
2952
  get config() {
2929
2953
  return {
2930
- schematicSymbolName: "led",
2954
+ componentName: "Led",
2955
+ schematicSymbolName: this.props.symbolName ?? "led_horz",
2931
2956
  zodProps: ledProps,
2932
2957
  sourceFtype: "simple_diode"
2933
2958
  };
2934
2959
  }
2935
- componentName = "Led";
2960
+ initPorts() {
2961
+ this.add(new Port({ name: "pin1", pinNumber: 1, aliases: ["anode", "pos"] }));
2962
+ this.add(new Port({ name: "pin2", pinNumber: 2, aliases: ["cathode", "neg"] }));
2963
+ }
2936
2964
  pos = this.portMap.pin1;
2937
- pin1 = this.portMap.pin1;
2938
2965
  anode = this.portMap.pin1;
2939
2966
  neg = this.portMap.pin2;
2940
- pin2 = this.portMap.pin2;
2941
2967
  cathode = this.portMap.pin2;
2942
2968
  };
2943
2969
 
@@ -2960,11 +2986,11 @@ var Diode = class extends NormalComponent {
2960
2986
  get config() {
2961
2987
  return {
2962
2988
  // schematicSymbolName: "diode" as BaseSymbolName,
2989
+ componentName: "Diode",
2963
2990
  zodProps: diodeProps,
2964
2991
  sourceFtype: "simple_diode"
2965
2992
  };
2966
2993
  }
2967
- componentName = "Diode";
2968
2994
  initPorts() {
2969
2995
  this.add(new Port({ name: "pin1", aliases: ["1", "pin1"] }));
2970
2996
  this.add(new Port({ name: "pin2", aliases: ["2", "pin2"] }));
@@ -2972,18 +2998,21 @@ var Diode = class extends NormalComponent {
2972
2998
  };
2973
2999
 
2974
3000
  // lib/components/normal-components/Capacitor.ts
2975
- import { ledProps as ledProps2 } from "@tscircuit/props";
3001
+ import { capacitorProps } from "@tscircuit/props";
2976
3002
  var Capacitor = class extends NormalComponent {
3003
+ // @ts-ignore (cause the symbolName is string and not fixed)
2977
3004
  get config() {
2978
3005
  return {
2979
- // schematicSymbolName: BASE_SYMBOLS.capacitor,
2980
- zodProps: ledProps2,
3006
+ componentName: "Capacitor",
3007
+ schematicSymbolName: this.props.symbolName ?? "capacitor_horz",
3008
+ zodProps: capacitorProps,
2981
3009
  sourceFtype: FTYPE.simple_capacitor
2982
3010
  };
2983
3011
  }
2984
- componentName = "Capacitor";
2985
- pin1 = this.portMap.pin1;
2986
- pin2 = this.portMap.pin2;
3012
+ initPorts() {
3013
+ this.add(new Port({ name: "pin1", pinNumber: 1, aliases: ["anode", "pos"] }));
3014
+ this.add(new Port({ name: "pin2", pinNumber: 2, aliases: ["cathode", "neg"] }));
3015
+ }
2987
3016
  doInitialCreateNetsFromProps() {
2988
3017
  this._createNetsFromProps([
2989
3018
  this.props.decouplingFor,
@@ -3314,10 +3343,10 @@ var Chip = class extends NormalComponent {
3314
3343
  schematicDimensions = null;
3315
3344
  get config() {
3316
3345
  return {
3346
+ componentName: "Chip",
3317
3347
  zodProps: chipProps
3318
3348
  };
3319
3349
  }
3320
- componentName = "Chip";
3321
3350
  doInitialSourceRender() {
3322
3351
  const { db } = this.root;
3323
3352
  const { _parsedProps: props } = this;
@@ -3384,10 +3413,10 @@ var Jumper = class extends NormalComponent {
3384
3413
  schematicDimensions = null;
3385
3414
  get config() {
3386
3415
  return {
3416
+ componentName: "Jumper",
3387
3417
  zodProps: jumperProps
3388
3418
  };
3389
3419
  }
3390
- componentName = "Jumper";
3391
3420
  doInitialSourceRender() {
3392
3421
  const { db } = this.root;
3393
3422
  const { _parsedProps: props } = this;
@@ -3463,9 +3492,9 @@ var edgeSpecifiers = [
3463
3492
  "center"
3464
3493
  ];
3465
3494
  var Constraint2 = class extends PrimitiveComponent {
3466
- componentName = "Constraint";
3467
3495
  get config() {
3468
3496
  return {
3497
+ componentName: "Constraint",
3469
3498
  zodProps: constraintProps
3470
3499
  };
3471
3500
  }
@@ -3520,9 +3549,9 @@ import { holeProps } from "@tscircuit/props";
3520
3549
  var Hole = class extends PrimitiveComponent {
3521
3550
  pcb_hole_id = null;
3522
3551
  isPcbPrimitive = true;
3523
- componentName = "Hole";
3524
3552
  get config() {
3525
3553
  return {
3554
+ componentName: "Hole",
3526
3555
  zodProps: holeProps
3527
3556
  };
3528
3557
  }
@@ -3569,10 +3598,15 @@ var Hole = class extends PrimitiveComponent {
3569
3598
  };
3570
3599
 
3571
3600
  // lib/components/primitive-components/SilkscreenText.ts
3572
- import "@tscircuit/props";
3601
+ import { silkscreenTextProps } from "@tscircuit/props";
3573
3602
  var SilkscreenText = class extends PrimitiveComponent {
3574
3603
  isPcbPrimitive = true;
3575
- componentName = "SilkscreenText";
3604
+ get config() {
3605
+ return {
3606
+ componentName: "SilkscreenText",
3607
+ zodProps: silkscreenTextProps
3608
+ };
3609
+ }
3576
3610
  doInitialPcbPrimitiveRender() {
3577
3611
  const { db } = this.root;
3578
3612
  const { _parsedProps: props } = this;
@@ -3603,9 +3637,14 @@ var SilkscreenText = class extends PrimitiveComponent {
3603
3637
  };
3604
3638
 
3605
3639
  // lib/components/primitive-components/FabricationNoteText.ts
3606
- import "@tscircuit/props";
3640
+ import { fabricationNoteTextProps } from "@tscircuit/props";
3607
3641
  var FabricationNoteText = class extends PrimitiveComponent {
3608
- componentName = "FabricationNoteText";
3642
+ get config() {
3643
+ return {
3644
+ componentName: "FabricationNoteText",
3645
+ zodProps: fabricationNoteTextProps
3646
+ };
3647
+ }
3609
3648
  doInitialPcbPrimitiveRender() {
3610
3649
  const { db } = this.root;
3611
3650
  const { _parsedProps: props } = this;
@@ -3630,10 +3669,10 @@ var FabricationNoteText = class extends PrimitiveComponent {
3630
3669
  import { fabricationNotePathProps } from "@tscircuit/props";
3631
3670
  import { applyToPoint as applyToPoint6 } from "transformation-matrix";
3632
3671
  var FabricationNotePath = class extends PrimitiveComponent {
3633
- componentName = "FabricationNotePath";
3634
3672
  fabrication_note_path_id = null;
3635
3673
  get config() {
3636
3674
  return {
3675
+ componentName: "FabricationNotePath",
3637
3676
  zodProps: fabricationNotePathProps
3638
3677
  };
3639
3678
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.91",
4
+ "version": "0.0.93",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -43,7 +43,7 @@
43
43
  "performance-now": "^2.1.0",
44
44
  "react": "^18.3.1",
45
45
  "react-reconciler": "^0.29.2",
46
- "schematic-symbols": "0.0.17",
46
+ "schematic-symbols": "0.0.19",
47
47
  "transformation-matrix": "^2.16.1",
48
48
  "zod": "^3.23.8"
49
49
  }