@tscircuit/core 0.0.107 → 0.0.109

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 +1190 -1097
  2. package/dist/index.js +253 -186
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -27,7 +27,9 @@ __export(components_exports, {
27
27
  PrimitiveComponent: () => PrimitiveComponent,
28
28
  Renderable: () => Renderable,
29
29
  Resistor: () => Resistor,
30
+ SilkscreenCircle: () => SilkscreenCircle,
30
31
  SilkscreenPath: () => SilkscreenPath,
32
+ SilkscreenRect: () => SilkscreenRect,
31
33
  SilkscreenText: () => SilkscreenText,
32
34
  SmtPad: () => SmtPad,
33
35
  Trace: () => Trace,
@@ -662,7 +664,7 @@ var PrimitiveComponent = class extends Renderable {
662
664
  }
663
665
  getSubcircuit() {
664
666
  if (this.isSubcircuit) return this;
665
- const group = this.parent?.getSubcircuit();
667
+ const group = this.parent?.getSubcircuit?.();
666
668
  if (!group)
667
669
  throw new Error("Component is not inside an opaque group (no board?)");
668
670
  return group;
@@ -2337,8 +2339,17 @@ var Board = class extends Group {
2337
2339
  }
2338
2340
  };
2339
2341
 
2340
- // lib/components/normal-components/Resistor.ts
2341
- import { resistorProps } from "@tscircuit/props";
2342
+ // lib/components/normal-components/Capacitor.ts
2343
+ import { capacitorProps } from "@tscircuit/props";
2344
+
2345
+ // lib/utils/constants.ts
2346
+ var stringProxy = new Proxy(
2347
+ {},
2348
+ {
2349
+ get: (target, prop) => prop
2350
+ }
2351
+ );
2352
+ var FTYPE = stringProxy;
2342
2353
 
2343
2354
  // lib/components/primitive-components/Trace.ts
2344
2355
  import { traceProps } from "@tscircuit/props";
@@ -2987,116 +2998,7 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
2987
2998
  }
2988
2999
  };
2989
3000
 
2990
- // lib/components/normal-components/Resistor.ts
2991
- var Resistor = class extends NormalComponent {
2992
- // @ts-ignore (cause the symbolName is string and not fixed)
2993
- get config() {
2994
- return {
2995
- componentName: "Resistor",
2996
- schematicSymbolName: this.props.symbolName ?? "boxresistor_horz",
2997
- zodProps: resistorProps,
2998
- sourceFtype: "simple_resistor"
2999
- };
3000
- }
3001
- initPorts() {
3002
- this.add(new Port({ name: "pin1", pinNumber: 1, aliases: ["anode", "pos"] }));
3003
- this.add(new Port({ name: "pin2", pinNumber: 2, aliases: ["cathode", "neg"] }));
3004
- }
3005
- doInitialCreateNetsFromProps() {
3006
- this._createNetsFromProps([this.props.pullupFor, this.props.pullupTo]);
3007
- }
3008
- doInitialCreateTracesFromProps() {
3009
- if (this.props.pullupFor && this.props.pullupTo) {
3010
- this.add(
3011
- new Trace({
3012
- from: `${this.getSubcircuitSelector()} > port.1`,
3013
- to: this.props.pullupFor
3014
- })
3015
- );
3016
- this.add(
3017
- new Trace({
3018
- from: `${this.getSubcircuitSelector()} > port.2`,
3019
- to: this.props.pullupTo
3020
- })
3021
- );
3022
- }
3023
- }
3024
- doInitialSourceRender() {
3025
- const { db } = this.root;
3026
- const { _parsedProps: props } = this;
3027
- const source_component = db.source_component.insert({
3028
- ftype: "simple_resistor",
3029
- name: props.name,
3030
- // @ts-ignore
3031
- manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
3032
- supplier_part_numbers: props.supplierPartNumbers,
3033
- resistance: props.resistance
3034
- });
3035
- this.source_component_id = source_component.source_component_id;
3036
- }
3037
- };
3038
-
3039
- // lib/components/normal-components/Led.ts
3040
- import { ledProps } from "@tscircuit/props";
3041
- var Led = class extends NormalComponent {
3042
- // @ts-ignore
3043
- get config() {
3044
- return {
3045
- componentName: "Led",
3046
- schematicSymbolName: this.props.symbolName ?? "led_horz",
3047
- zodProps: ledProps,
3048
- sourceFtype: "simple_diode"
3049
- };
3050
- }
3051
- initPorts() {
3052
- this.add(new Port({ name: "pin1", pinNumber: 1, aliases: ["anode", "pos"] }));
3053
- this.add(new Port({ name: "pin2", pinNumber: 2, aliases: ["cathode", "neg"] }));
3054
- }
3055
- pos = this.portMap.pin1;
3056
- anode = this.portMap.pin1;
3057
- neg = this.portMap.pin2;
3058
- cathode = this.portMap.pin2;
3059
- };
3060
-
3061
- // lib/components/normal-components/Diode.ts
3062
- import { diodeProps } from "@tscircuit/props";
3063
-
3064
- // lib/utils/constants.ts
3065
- var stringProxy = new Proxy(
3066
- {},
3067
- {
3068
- get: (target, prop) => prop
3069
- }
3070
- );
3071
- var FTYPE = stringProxy;
3072
-
3073
- // lib/components/normal-components/Diode.ts
3074
- var Diode = class extends NormalComponent {
3075
- // @ts-ignore
3076
- get config() {
3077
- return {
3078
- schematicSymbolName: this.props.symbolName ?? "diode_horz",
3079
- componentName: "Diode",
3080
- zodProps: diodeProps,
3081
- sourceFtype: "simple_diode"
3082
- };
3083
- }
3084
- initPorts() {
3085
- this.add(
3086
- new Port({ name: "pin1", pinNumber: 1, aliases: ["anode", "pos"] })
3087
- );
3088
- this.add(
3089
- new Port({ name: "pin2", pinNumber: 2, aliases: ["cathode", "neg"] })
3090
- );
3091
- }
3092
- pos = this.portMap.pin1;
3093
- anode = this.portMap.pin1;
3094
- neg = this.portMap.pin2;
3095
- cathode = this.portMap.pin2;
3096
- };
3097
-
3098
3001
  // lib/components/normal-components/Capacitor.ts
3099
- import { capacitorProps } from "@tscircuit/props";
3100
3002
  var Capacitor = class extends NormalComponent {
3101
3003
  // @ts-ignore (cause the symbolName is string and not fixed)
3102
3004
  get config() {
@@ -3108,8 +3010,8 @@ var Capacitor = class extends NormalComponent {
3108
3010
  };
3109
3011
  }
3110
3012
  initPorts() {
3111
- this.add(new Port({ name: "pin1", pinNumber: 1, aliases: ["anode", "pos"] }));
3112
- this.add(new Port({ name: "pin2", pinNumber: 2, aliases: ["cathode", "neg"] }));
3013
+ this.add(new Port({ name: "pin1", pinNumber: 1, aliases: ["anode", "pos", "left"] }));
3014
+ this.add(new Port({ name: "pin2", pinNumber: 2, aliases: ["cathode", "neg", "right"] }));
3113
3015
  }
3114
3016
  doInitialCreateNetsFromProps() {
3115
3017
  this._createNetsFromProps([
@@ -3497,6 +3399,32 @@ var Chip = class extends NormalComponent {
3497
3399
  }
3498
3400
  };
3499
3401
 
3402
+ // lib/components/normal-components/Diode.ts
3403
+ import { diodeProps } from "@tscircuit/props";
3404
+ var Diode = class extends NormalComponent {
3405
+ // @ts-ignore
3406
+ get config() {
3407
+ return {
3408
+ schematicSymbolName: this.props.symbolName ?? "diode_horz",
3409
+ componentName: "Diode",
3410
+ zodProps: diodeProps,
3411
+ sourceFtype: "simple_diode"
3412
+ };
3413
+ }
3414
+ initPorts() {
3415
+ this.add(
3416
+ new Port({ name: "pin1", pinNumber: 1, aliases: ["anode", "pos"] })
3417
+ );
3418
+ this.add(
3419
+ new Port({ name: "pin2", pinNumber: 2, aliases: ["cathode", "neg"] })
3420
+ );
3421
+ }
3422
+ pos = this.portMap.pin1;
3423
+ anode = this.portMap.pin1;
3424
+ neg = this.portMap.pin2;
3425
+ cathode = this.portMap.pin2;
3426
+ };
3427
+
3500
3428
  // lib/components/normal-components/Jumper.ts
3501
3429
  import { jumperProps } from "@tscircuit/props";
3502
3430
  var Jumper = class extends NormalComponent {
@@ -3571,6 +3499,78 @@ var Jumper = class extends NormalComponent {
3571
3499
  }
3572
3500
  };
3573
3501
 
3502
+ // lib/components/normal-components/Led.ts
3503
+ import { ledProps } from "@tscircuit/props";
3504
+ var Led = class extends NormalComponent {
3505
+ // @ts-ignore
3506
+ get config() {
3507
+ return {
3508
+ componentName: "Led",
3509
+ schematicSymbolName: this.props.symbolName ?? "led_horz",
3510
+ zodProps: ledProps,
3511
+ sourceFtype: "simple_diode"
3512
+ };
3513
+ }
3514
+ initPorts() {
3515
+ this.add(new Port({ name: "pin1", pinNumber: 1, aliases: ["anode", "pos"] }));
3516
+ this.add(new Port({ name: "pin2", pinNumber: 2, aliases: ["cathode", "neg"] }));
3517
+ }
3518
+ pos = this.portMap.pin1;
3519
+ anode = this.portMap.pin1;
3520
+ neg = this.portMap.pin2;
3521
+ cathode = this.portMap.pin2;
3522
+ };
3523
+
3524
+ // lib/components/normal-components/Resistor.ts
3525
+ import { resistorProps } from "@tscircuit/props";
3526
+ var Resistor = class extends NormalComponent {
3527
+ // @ts-ignore (cause the symbolName is string and not fixed)
3528
+ get config() {
3529
+ return {
3530
+ componentName: "Resistor",
3531
+ schematicSymbolName: this.props.symbolName ?? "boxresistor_horz",
3532
+ zodProps: resistorProps,
3533
+ sourceFtype: "simple_resistor"
3534
+ };
3535
+ }
3536
+ initPorts() {
3537
+ this.add(new Port({ name: "pin1", pinNumber: 1, aliases: ["anode", "pos", "left"] }));
3538
+ this.add(new Port({ name: "pin2", pinNumber: 2, aliases: ["cathode", "neg", "right"] }));
3539
+ }
3540
+ doInitialCreateNetsFromProps() {
3541
+ this._createNetsFromProps([this.props.pullupFor, this.props.pullupTo]);
3542
+ }
3543
+ doInitialCreateTracesFromProps() {
3544
+ if (this.props.pullupFor && this.props.pullupTo) {
3545
+ this.add(
3546
+ new Trace({
3547
+ from: `${this.getSubcircuitSelector()} > port.1`,
3548
+ to: this.props.pullupFor
3549
+ })
3550
+ );
3551
+ this.add(
3552
+ new Trace({
3553
+ from: `${this.getSubcircuitSelector()} > port.2`,
3554
+ to: this.props.pullupTo
3555
+ })
3556
+ );
3557
+ }
3558
+ }
3559
+ doInitialSourceRender() {
3560
+ const { db } = this.root;
3561
+ const { _parsedProps: props } = this;
3562
+ const source_component = db.source_component.insert({
3563
+ ftype: "simple_resistor",
3564
+ name: props.name,
3565
+ // @ts-ignore
3566
+ manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
3567
+ supplier_part_numbers: props.supplierPartNumbers,
3568
+ resistance: props.resistance
3569
+ });
3570
+ this.source_component_id = source_component.source_component_id;
3571
+ }
3572
+ };
3573
+
3574
3574
  // lib/components/primitive-components/Constraint.ts
3575
3575
  import { constraintProps } from "@tscircuit/props";
3576
3576
  import "zod";
@@ -3634,6 +3634,77 @@ var Constraint2 = class extends PrimitiveComponent {
3634
3634
  }
3635
3635
  };
3636
3636
 
3637
+ // lib/components/primitive-components/FabricationNotePath.ts
3638
+ import { fabricationNotePathProps } from "@tscircuit/props";
3639
+ import { applyToPoint as applyToPoint6 } from "transformation-matrix";
3640
+ var FabricationNotePath = class extends PrimitiveComponent {
3641
+ fabrication_note_path_id = null;
3642
+ get config() {
3643
+ return {
3644
+ componentName: "FabricationNotePath",
3645
+ zodProps: fabricationNotePathProps
3646
+ };
3647
+ }
3648
+ doInitialPcbPrimitiveRender() {
3649
+ const { db } = this.root;
3650
+ const { _parsedProps: props } = this;
3651
+ const layer = props.layer ?? "top";
3652
+ if (layer !== "top" && layer !== "bottom") {
3653
+ throw new Error(
3654
+ `Invalid layer "${layer}" for SilkscreenPath. Must be "top" or "bottom".`
3655
+ );
3656
+ }
3657
+ const transform = this._computePcbGlobalTransformBeforeLayout();
3658
+ const fabrication_note_path = db.pcb_fabrication_note_path.insert({
3659
+ pcb_component_id: this.parent?.pcb_component_id,
3660
+ layer,
3661
+ color: props.color,
3662
+ route: props.route.map((p) => {
3663
+ const transformedPosition = applyToPoint6(transform, {
3664
+ x: p.x,
3665
+ y: p.y
3666
+ });
3667
+ return {
3668
+ ...p,
3669
+ x: transformedPosition.x,
3670
+ y: transformedPosition.y
3671
+ };
3672
+ }),
3673
+ stroke_width: props.strokeWidth ?? 0.1
3674
+ });
3675
+ this.fabrication_note_path_id = fabrication_note_path.pcb_fabrication_note_path_id;
3676
+ }
3677
+ };
3678
+
3679
+ // lib/components/primitive-components/FabricationNoteText.ts
3680
+ import { fabricationNoteTextProps } from "@tscircuit/props";
3681
+ var FabricationNoteText = class extends PrimitiveComponent {
3682
+ get config() {
3683
+ return {
3684
+ componentName: "FabricationNoteText",
3685
+ zodProps: fabricationNoteTextProps
3686
+ };
3687
+ }
3688
+ doInitialPcbPrimitiveRender() {
3689
+ const { db } = this.root;
3690
+ const { _parsedProps: props } = this;
3691
+ const container = this.getPrimitiveContainer();
3692
+ db.pcb_fabrication_note_text.insert({
3693
+ anchor_alignment: props.anchorAlignment,
3694
+ anchor_position: {
3695
+ x: props.pcbX ?? 0,
3696
+ y: props.pcbY ?? 0
3697
+ },
3698
+ font: props.font ?? "tscircuit2024",
3699
+ font_size: props.fontSize ?? 1,
3700
+ layer: "top",
3701
+ color: props.color,
3702
+ text: props.text ?? "",
3703
+ pcb_component_id: container.pcb_component_id
3704
+ });
3705
+ }
3706
+ };
3707
+
3637
3708
  // lib/components/primitive-components/Hole.ts
3638
3709
  import { holeProps } from "@tscircuit/props";
3639
3710
  var Hole = class extends PrimitiveComponent {
@@ -3687,6 +3758,72 @@ var Hole = class extends PrimitiveComponent {
3687
3758
  }
3688
3759
  };
3689
3760
 
3761
+ // lib/components/primitive-components/SilkscreenCircle.ts
3762
+ import { silkscreenCircleProps } from "@tscircuit/props";
3763
+ var SilkscreenCircle = class extends PrimitiveComponent {
3764
+ pcb_silkscreen_circle_id = null;
3765
+ get config() {
3766
+ return {
3767
+ componentName: "SilkscreenCircle",
3768
+ zodProps: silkscreenCircleProps
3769
+ };
3770
+ }
3771
+ doInitialPcbPrimitiveRender() {
3772
+ const { db } = this.root;
3773
+ const { _parsedProps: props } = this;
3774
+ const layer = props.layer ?? "top";
3775
+ if (layer !== "top" && layer !== "bottom") {
3776
+ throw new Error(
3777
+ `Invalid layer "${layer}" for SilkscreenCircle. Must be "top" or "bottom".`
3778
+ );
3779
+ }
3780
+ const transform = this._computePcbGlobalTransformBeforeLayout();
3781
+ const pcb_silkscreen_circle = db.pcb_silkscreen_circle.insert({
3782
+ pcb_component_id: this.parent?.pcb_component_id,
3783
+ layer,
3784
+ center: {
3785
+ x: props.pcbX ?? 0,
3786
+ y: props.pcbY ?? 0
3787
+ },
3788
+ radius: props.radius
3789
+ });
3790
+ this.pcb_silkscreen_circle_id = pcb_silkscreen_circle.pcb_silkscreen_circle_id;
3791
+ }
3792
+ };
3793
+
3794
+ // lib/components/primitive-components/SilkscreenRect.ts
3795
+ import { silkscreenRectProps } from "@tscircuit/props";
3796
+ var SilkscreenRect = class extends PrimitiveComponent {
3797
+ pcb_silkscreen_rect_id = null;
3798
+ get config() {
3799
+ return {
3800
+ componentName: "SilkscreenRect",
3801
+ zodProps: silkscreenRectProps
3802
+ };
3803
+ }
3804
+ doInitialPcbPrimitiveRender() {
3805
+ const { db } = this.root;
3806
+ const { _parsedProps: props } = this;
3807
+ const layer = props.layer ?? "top";
3808
+ if (layer !== "top" && layer !== "bottom") {
3809
+ throw new Error(
3810
+ `Invalid layer "${layer}" for SilkscreenRect. Must be "top" or "bottom".`
3811
+ );
3812
+ }
3813
+ const pcb_silkscreen_rect = db.pcb_silkscreen_rect.insert({
3814
+ pcb_component_id: this.parent?.pcb_component_id,
3815
+ layer,
3816
+ center: {
3817
+ x: props.pcbX ?? 0,
3818
+ y: props.pcbY ?? 0
3819
+ },
3820
+ width: props.width,
3821
+ height: props.height
3822
+ });
3823
+ this.pcb_silkscreen_rect_id = pcb_silkscreen_rect.pcb_silkscreen_rect_id;
3824
+ }
3825
+ };
3826
+
3690
3827
  // lib/components/primitive-components/SilkscreenText.ts
3691
3828
  import { silkscreenTextProps } from "@tscircuit/props";
3692
3829
  var SilkscreenText = class extends PrimitiveComponent {
@@ -3726,77 +3863,6 @@ var SilkscreenText = class extends PrimitiveComponent {
3726
3863
  }
3727
3864
  };
3728
3865
 
3729
- // lib/components/primitive-components/FabricationNoteText.ts
3730
- import { fabricationNoteTextProps } from "@tscircuit/props";
3731
- var FabricationNoteText = class extends PrimitiveComponent {
3732
- get config() {
3733
- return {
3734
- componentName: "FabricationNoteText",
3735
- zodProps: fabricationNoteTextProps
3736
- };
3737
- }
3738
- doInitialPcbPrimitiveRender() {
3739
- const { db } = this.root;
3740
- const { _parsedProps: props } = this;
3741
- const container = this.getPrimitiveContainer();
3742
- db.pcb_fabrication_note_text.insert({
3743
- anchor_alignment: props.anchorAlignment,
3744
- anchor_position: {
3745
- x: props.pcbX ?? 0,
3746
- y: props.pcbY ?? 0
3747
- },
3748
- font: props.font ?? "tscircuit2024",
3749
- font_size: props.fontSize ?? 1,
3750
- layer: "top",
3751
- color: props.color,
3752
- text: props.text ?? "",
3753
- pcb_component_id: container.pcb_component_id
3754
- });
3755
- }
3756
- };
3757
-
3758
- // lib/components/primitive-components/FabricationNotePath.ts
3759
- import { fabricationNotePathProps } from "@tscircuit/props";
3760
- import { applyToPoint as applyToPoint6 } from "transformation-matrix";
3761
- var FabricationNotePath = class extends PrimitiveComponent {
3762
- fabrication_note_path_id = null;
3763
- get config() {
3764
- return {
3765
- componentName: "FabricationNotePath",
3766
- zodProps: fabricationNotePathProps
3767
- };
3768
- }
3769
- doInitialPcbPrimitiveRender() {
3770
- const { db } = this.root;
3771
- const { _parsedProps: props } = this;
3772
- const layer = props.layer ?? "top";
3773
- if (layer !== "top" && layer !== "bottom") {
3774
- throw new Error(
3775
- `Invalid layer "${layer}" for SilkscreenPath. Must be "top" or "bottom".`
3776
- );
3777
- }
3778
- const transform = this._computePcbGlobalTransformBeforeLayout();
3779
- const fabrication_note_path = db.pcb_fabrication_note_path.insert({
3780
- pcb_component_id: this.parent?.pcb_component_id,
3781
- layer,
3782
- color: props.color,
3783
- route: props.route.map((p) => {
3784
- const transformedPosition = applyToPoint6(transform, {
3785
- x: p.x,
3786
- y: p.y
3787
- });
3788
- return {
3789
- ...p,
3790
- x: transformedPosition.x,
3791
- y: transformedPosition.y
3792
- };
3793
- }),
3794
- stroke_width: props.strokeWidth ?? 0.1
3795
- });
3796
- this.fabrication_note_path_id = fabrication_note_path.pcb_fabrication_note_path_id;
3797
- }
3798
- };
3799
-
3800
3866
  // lib/components/primitive-components/Via.ts
3801
3867
  import { viaProps } from "@tscircuit/props";
3802
3868
  var Via = class extends PrimitiveComponent {
@@ -3838,7 +3904,6 @@ var Via = class extends PrimitiveComponent {
3838
3904
  x: newCenter.x,
3839
3905
  y: newCenter.y
3840
3906
  });
3841
- this.matchedPort?._setPositionFromLayout(newCenter);
3842
3907
  }
3843
3908
  doInitialPcbPrimitiveRender() {
3844
3909
  const { db } = this.root;
@@ -4016,7 +4081,9 @@ export {
4016
4081
  Project,
4017
4082
  Renderable,
4018
4083
  Resistor,
4084
+ SilkscreenCircle,
4019
4085
  SilkscreenPath,
4086
+ SilkscreenRect,
4020
4087
  SilkscreenText,
4021
4088
  SmtPad,
4022
4089
  Trace,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.107",
4
+ "version": "0.0.109",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",