@tscircuit/core 0.0.1070 → 0.0.1072

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
@@ -1619,7 +1619,19 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
1619
1619
  doInitialInitializePortsFromChildren(): void;
1620
1620
  doInitialReactSubtreesRender(): void;
1621
1621
  doInitialPcbFootprintStringRender(): void;
1622
+ /**
1623
+ * Get all ports from children, including ports inside Symbol.
1624
+ * This doesn't use selectAll to avoid caching issues during initPorts.
1625
+ */
1626
+ _getAllPortsFromChildren(): Port[];
1622
1627
  _hasExistingPortExactly(port1: Port): boolean;
1628
+ /**
1629
+ * Check if a port with the same pinNumber already exists.
1630
+ * This is used to prevent duplicate ports for the same physical pin.
1631
+ * Note: We only check pinNumber, not aliases, because different physical pins
1632
+ * can have the same alias (e.g., multiple GND pins).
1633
+ */
1634
+ _hasMatchingPort(port1: Port): boolean;
1623
1635
  add(componentOrElm: PrimitiveComponent | ReactElement): void;
1624
1636
  getPortsFromFootprint(opts?: {
1625
1637
  additionalAliases?: Record<string, string[]>;
package/dist/index.js CHANGED
@@ -9997,12 +9997,24 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
9997
9997
  this.addAll(portsToCreate);
9998
9998
  }
9999
9999
  if (!this._getSchematicPortArrangement()) {
10000
- const portsFromFootprint = this.getPortsFromFootprint(opts);
10001
- for (const port of portsFromFootprint) {
10002
- if (!portsToCreate.some(
10003
- (p) => p.isMatchingAnyOf(port.getNameAndAliases())
10004
- )) {
10005
- portsToCreate.push(port);
10000
+ const hasReactSymbol = isValidElement(this.props.symbol);
10001
+ const symbolAlreadyAdded = this.children.some(
10002
+ (c) => c.componentName === "Symbol"
10003
+ );
10004
+ if (hasReactSymbol && !symbolAlreadyAdded) {
10005
+ } else {
10006
+ const portsFromFootprint = this.getPortsFromFootprint(opts);
10007
+ const existingPorts = this._getAllPortsFromChildren();
10008
+ for (const port of portsFromFootprint) {
10009
+ const alreadyInPortsToCreate = portsToCreate.some(
10010
+ (p) => p.isMatchingAnyOf(port.getNameAndAliases())
10011
+ );
10012
+ const alreadyInExistingPorts = existingPorts.some(
10013
+ (p) => p.isMatchingAnyOf(port.getNameAndAliases())
10014
+ );
10015
+ if (!alreadyInPortsToCreate && !alreadyInExistingPorts) {
10016
+ portsToCreate.push(port);
10017
+ }
10006
10018
  }
10007
10019
  }
10008
10020
  }
@@ -10508,16 +10520,47 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
10508
10520
  (name, effect) => this._queueAsyncEffect(name, effect)
10509
10521
  );
10510
10522
  }
10523
+ /**
10524
+ * Get all ports from children, including ports inside Symbol.
10525
+ * This doesn't use selectAll to avoid caching issues during initPorts.
10526
+ */
10527
+ _getAllPortsFromChildren() {
10528
+ const ports = [];
10529
+ const collectPorts = (component) => {
10530
+ if (component.componentName === "Port") {
10531
+ ports.push(component);
10532
+ }
10533
+ for (const child of component.children) {
10534
+ collectPorts(child);
10535
+ }
10536
+ };
10537
+ for (const child of this.children) {
10538
+ collectPorts(child);
10539
+ }
10540
+ return ports;
10541
+ }
10511
10542
  _hasExistingPortExactly(port1) {
10512
- const existingPorts = this.children.filter(
10513
- (c) => c.componentName === "Port"
10514
- );
10543
+ const existingPorts = this._getAllPortsFromChildren();
10515
10544
  return existingPorts.some((port2) => {
10516
10545
  const aliases1 = port1.getNameAndAliases();
10517
10546
  const aliases2 = port2.getNameAndAliases();
10518
10547
  return aliases1.length === aliases2.length && aliases1.every((alias) => aliases2.includes(alias));
10519
10548
  });
10520
10549
  }
10550
+ /**
10551
+ * Check if a port with the same pinNumber already exists.
10552
+ * This is used to prevent duplicate ports for the same physical pin.
10553
+ * Note: We only check pinNumber, not aliases, because different physical pins
10554
+ * can have the same alias (e.g., multiple GND pins).
10555
+ */
10556
+ _hasMatchingPort(port1) {
10557
+ const existingPorts = this._getAllPortsFromChildren();
10558
+ const pinNumber1 = port1._parsedProps.pinNumber;
10559
+ if (pinNumber1 === void 0) return false;
10560
+ return existingPorts.some(
10561
+ (port2) => port2._parsedProps.pinNumber === pinNumber1
10562
+ );
10563
+ }
10521
10564
  add(componentOrElm) {
10522
10565
  let component;
10523
10566
  if (isReactElement2(componentOrElm)) {
@@ -10529,16 +10572,11 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
10529
10572
  }
10530
10573
  if (component.componentName === "Port") {
10531
10574
  if (this._hasExistingPortExactly(component)) return;
10532
- const existingPorts = this.children.filter(
10533
- (c) => c.componentName === "Port"
10534
- );
10535
- const conflictingPort = existingPorts.find(
10536
- (p) => p.isMatchingAnyOf(component.getNameAndAliases())
10537
- );
10538
- if (conflictingPort) {
10575
+ if (this._hasMatchingPort(component)) {
10539
10576
  debug3(
10540
- `Similar ports added. Port 1: ${conflictingPort}, Port 2: ${component}`
10577
+ `Skipping port ${component} because a matching port already exists`
10541
10578
  );
10579
+ return;
10542
10580
  }
10543
10581
  }
10544
10582
  super.add(component);
@@ -18056,7 +18094,7 @@ import { identity as identity5 } from "transformation-matrix";
18056
18094
  var package_default = {
18057
18095
  name: "@tscircuit/core",
18058
18096
  type: "module",
18059
- version: "0.0.1069",
18097
+ version: "0.0.1071",
18060
18098
  types: "dist/index.d.ts",
18061
18099
  main: "dist/index.js",
18062
18100
  module: "dist/index.js",
@@ -18089,7 +18127,7 @@ var package_default = {
18089
18127
  "@resvg/resvg-js": "^2.6.2",
18090
18128
  "@tscircuit/alphabet": "0.0.18",
18091
18129
  "@tscircuit/capacity-autorouter": "^0.0.299",
18092
- "@tscircuit/checks": "0.0.98",
18130
+ "@tscircuit/checks": "0.0.99",
18093
18131
  "@tscircuit/circuit-json-util": "^0.0.80",
18094
18132
  "@tscircuit/common": "^0.0.20",
18095
18133
  "@tscircuit/copper-pour-solver": "^0.0.20",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1070",
4
+ "version": "0.0.1072",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -34,7 +34,7 @@
34
34
  "@resvg/resvg-js": "^2.6.2",
35
35
  "@tscircuit/alphabet": "0.0.18",
36
36
  "@tscircuit/capacity-autorouter": "^0.0.299",
37
- "@tscircuit/checks": "0.0.98",
37
+ "@tscircuit/checks": "0.0.99",
38
38
  "@tscircuit/circuit-json-util": "^0.0.80",
39
39
  "@tscircuit/common": "^0.0.20",
40
40
  "@tscircuit/copper-pour-solver": "^0.0.20",