@tscircuit/core 0.0.830 → 0.0.831

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
@@ -913,6 +913,7 @@ declare const portProps: z.ZodObject<{
913
913
  schX: z.ZodOptional<z.ZodNumber>;
914
914
  schY: z.ZodOptional<z.ZodNumber>;
915
915
  direction: z.ZodOptional<z.ZodEnum<["up", "down", "left", "right"]>>;
916
+ connectsTo: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
916
917
  }, "strip", z.ZodTypeAny, {
917
918
  name?: string | undefined;
918
919
  layer?: string | undefined;
@@ -922,6 +923,7 @@ declare const portProps: z.ZodObject<{
922
923
  schX?: number | undefined;
923
924
  schY?: number | undefined;
924
925
  direction?: "left" | "right" | "up" | "down" | undefined;
926
+ connectsTo?: string | string[] | undefined;
925
927
  }, {
926
928
  name?: string | undefined;
927
929
  layer?: string | undefined;
@@ -931,6 +933,7 @@ declare const portProps: z.ZodObject<{
931
933
  schX?: number | undefined;
932
934
  schY?: number | undefined;
933
935
  direction?: "left" | "right" | "up" | "down" | undefined;
936
+ connectsTo?: string | string[] | undefined;
934
937
  }>;
935
938
  declare class Port extends PrimitiveComponent<typeof portProps> {
936
939
  source_port_id: string | null;
@@ -951,6 +954,7 @@ declare class Port extends PrimitiveComponent<typeof portProps> {
951
954
  schX: z.ZodOptional<z.ZodNumber>;
952
955
  schY: z.ZodOptional<z.ZodNumber>;
953
956
  direction: z.ZodOptional<z.ZodEnum<["up", "down", "left", "right"]>>;
957
+ connectsTo: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
954
958
  }, "strip", z.ZodTypeAny, {
955
959
  name?: string | undefined;
956
960
  layer?: string | undefined;
@@ -960,6 +964,7 @@ declare class Port extends PrimitiveComponent<typeof portProps> {
960
964
  schX?: number | undefined;
961
965
  schY?: number | undefined;
962
966
  direction?: "left" | "right" | "up" | "down" | undefined;
967
+ connectsTo?: string | string[] | undefined;
963
968
  }, {
964
969
  name?: string | undefined;
965
970
  layer?: string | undefined;
@@ -969,11 +974,15 @@ declare class Port extends PrimitiveComponent<typeof portProps> {
969
974
  schX?: number | undefined;
970
975
  schY?: number | undefined;
971
976
  direction?: "left" | "right" | "up" | "down" | undefined;
977
+ connectsTo?: string | string[] | undefined;
972
978
  }>;
973
979
  };
974
980
  constructor(props: z.input<typeof portProps>, opts?: {
975
981
  originDescription?: string;
976
982
  });
983
+ isGroupPort(): boolean;
984
+ isComponentPort(): boolean;
985
+ _getConnectedPortsFromConnectsTo(): Port[];
977
986
  _isBoardPinoutFromAttributes(): boolean | undefined;
978
987
  _getGlobalPcbPositionBeforeLayout(): {
979
988
  x: number;
package/dist/index.js CHANGED
@@ -3481,7 +3481,8 @@ var portProps = z6.object({
3481
3481
  layers: z6.array(z6.string()).optional(),
3482
3482
  schX: z6.number().optional(),
3483
3483
  schY: z6.number().optional(),
3484
- direction: z6.enum(["up", "down", "left", "right"]).optional()
3484
+ direction: z6.enum(["up", "down", "left", "right"]).optional(),
3485
+ connectsTo: z6.union([z6.string(), z6.array(z6.string())]).optional()
3485
3486
  });
3486
3487
  var Port = class extends PrimitiveComponent2 {
3487
3488
  source_port_id = null;
@@ -3509,6 +3510,28 @@ var Port = class extends PrimitiveComponent2 {
3509
3510
  }
3510
3511
  this.matchedComponents = [];
3511
3512
  }
3513
+ isGroupPort() {
3514
+ return this.parent?.componentName === "Group";
3515
+ }
3516
+ isComponentPort() {
3517
+ return !this.isGroupPort();
3518
+ }
3519
+ _getConnectedPortsFromConnectsTo() {
3520
+ const { _parsedProps: props } = this;
3521
+ const connectsTo = props.connectsTo;
3522
+ if (!connectsTo) return [];
3523
+ const connectedPorts = [];
3524
+ const connectsToArray = Array.isArray(connectsTo) ? connectsTo : [connectsTo];
3525
+ for (const connection of connectsToArray) {
3526
+ const port = this.getSubcircuit().selectOne(connection, {
3527
+ type: "port"
3528
+ });
3529
+ if (port) {
3530
+ connectedPorts.push(port);
3531
+ }
3532
+ }
3533
+ return connectedPorts;
3534
+ }
3512
3535
  _isBoardPinoutFromAttributes() {
3513
3536
  const parent = this.parent;
3514
3537
  if (parent?._parsedProps?.pinAttributes) {
@@ -3737,6 +3760,13 @@ var Port = class extends PrimitiveComponent2 {
3737
3760
  const { db } = this.root;
3738
3761
  const parentNormalComponent = this.getParentNormalComponent();
3739
3762
  const parentWithSourceId = this.parent?.source_component_id ? this.parent : parentNormalComponent;
3763
+ if (this.isGroupPort()) {
3764
+ db.source_port.update(this.source_port_id, {
3765
+ source_component_id: null,
3766
+ subcircuit_id: this.getSubcircuit()?.subcircuit_id
3767
+ });
3768
+ return;
3769
+ }
3740
3770
  if (!parentWithSourceId?.source_component_id) {
3741
3771
  throw new Error(
3742
3772
  `${this.getString()} has no parent source component (parent: ${this.parent?.getString()})`
@@ -3752,6 +3782,30 @@ var Port = class extends PrimitiveComponent2 {
3752
3782
  if (this.root?.pcbDisabled) return;
3753
3783
  const { db } = this.root;
3754
3784
  const { matchedComponents } = this;
3785
+ if (this.isGroupPort()) {
3786
+ const connectedPorts = this._getConnectedPortsFromConnectsTo();
3787
+ if (connectedPorts.length === 0) {
3788
+ return;
3789
+ }
3790
+ const connectedPort = connectedPorts[0];
3791
+ if (!connectedPort.pcb_port_id) {
3792
+ return;
3793
+ }
3794
+ const connectedPcbPort = db.pcb_port.get(connectedPort.pcb_port_id);
3795
+ const matchCenter2 = { x: connectedPcbPort.x, y: connectedPcbPort.y };
3796
+ const subcircuit = this.getSubcircuit();
3797
+ const pcb_port = db.pcb_port.insert({
3798
+ pcb_component_id: void 0,
3799
+ layers: connectedPort.getAvailablePcbLayers(),
3800
+ subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
3801
+ pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0,
3802
+ ...matchCenter2,
3803
+ source_port_id: this.source_port_id,
3804
+ is_board_pinout: false
3805
+ });
3806
+ this.pcb_port_id = pcb_port.pcb_port_id;
3807
+ return;
3808
+ }
3755
3809
  const parentNormalComponent = this.getParentNormalComponent();
3756
3810
  const parentWithPcbComponentId = this.parent?.pcb_component_id ? this.parent : parentNormalComponent;
3757
3811
  if (!parentWithPcbComponentId?.pcb_component_id) {
@@ -3798,6 +3852,26 @@ var Port = class extends PrimitiveComponent2 {
3798
3852
  if (this.root?.pcbDisabled) return;
3799
3853
  const { db } = this.root;
3800
3854
  if (this.pcb_port_id) return;
3855
+ if (this.isGroupPort()) {
3856
+ const connectedPorts = this._getConnectedPortsFromConnectsTo();
3857
+ if (connectedPorts.length === 0) return;
3858
+ const connectedPort = connectedPorts[0];
3859
+ if (!connectedPort.pcb_port_id) return;
3860
+ const connectedPcbPort = db.pcb_port.get(connectedPort.pcb_port_id);
3861
+ const matchCenter2 = { x: connectedPcbPort.x, y: connectedPcbPort.y };
3862
+ const subcircuit2 = this.getSubcircuit();
3863
+ const pcb_port2 = db.pcb_port.insert({
3864
+ pcb_component_id: void 0,
3865
+ layers: connectedPort.getAvailablePcbLayers(),
3866
+ subcircuit_id: subcircuit2?.subcircuit_id ?? void 0,
3867
+ pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0,
3868
+ ...matchCenter2,
3869
+ source_port_id: this.source_port_id,
3870
+ is_board_pinout: false
3871
+ });
3872
+ this.pcb_port_id = pcb_port2.pcb_port_id;
3873
+ return;
3874
+ }
3801
3875
  const pcbMatches = this.matchedComponents.filter((c) => c.isPcbPrimitive);
3802
3876
  if (pcbMatches.length === 0) return;
3803
3877
  let matchCenter = null;
@@ -17409,7 +17483,7 @@ import { identity as identity6 } from "transformation-matrix";
17409
17483
  var package_default = {
17410
17484
  name: "@tscircuit/core",
17411
17485
  type: "module",
17412
- version: "0.0.829",
17486
+ version: "0.0.830",
17413
17487
  types: "dist/index.d.ts",
17414
17488
  main: "dist/index.js",
17415
17489
  module: "dist/index.js",
@@ -17464,7 +17538,7 @@ var package_default = {
17464
17538
  "bun-match-svg": "0.0.12",
17465
17539
  "calculate-elbow": "^0.0.12",
17466
17540
  "chokidar-cli": "^3.0.0",
17467
- "circuit-json": "^0.0.291",
17541
+ "circuit-json": "^0.0.295",
17468
17542
  "circuit-json-to-bpc": "^0.0.13",
17469
17543
  "circuit-json-to-connectivity-map": "^0.0.22",
17470
17544
  "circuit-json-to-gltf": "^0.0.31",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.830",
4
+ "version": "0.0.831",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -56,7 +56,7 @@
56
56
  "bun-match-svg": "0.0.12",
57
57
  "calculate-elbow": "^0.0.12",
58
58
  "chokidar-cli": "^3.0.0",
59
- "circuit-json": "^0.0.291",
59
+ "circuit-json": "^0.0.295",
60
60
  "circuit-json-to-bpc": "^0.0.13",
61
61
  "circuit-json-to-connectivity-map": "^0.0.22",
62
62
  "circuit-json-to-gltf": "^0.0.31",