@tscircuit/core 0.0.1160 → 0.0.1161

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 (2) hide show
  1. package/dist/index.js +56 -33
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -10524,6 +10524,39 @@ var shouldCheckPortForMissingTrace = (component, port) => {
10524
10524
  return true;
10525
10525
  };
10526
10526
 
10527
+ // lib/components/base-components/NormalComponent/utils/getLogicalPortsFromPortHintGroups.ts
10528
+ function getLogicalPortsFromPortHintGroups(portHintGroups, opts) {
10529
+ let implicitPinNumber = 1;
10530
+ const portsByPinNumber = /* @__PURE__ */ new Map();
10531
+ for (const portHintGroup of portHintGroups) {
10532
+ const filteredPortHints = portHintGroup.hints.filter(
10533
+ (hint) => hint && hint.trim() !== ""
10534
+ );
10535
+ if (filteredPortHints.length === 0) continue;
10536
+ let portHintsList = filteredPortHints;
10537
+ const hasPinIdentifier = portHintsList.some(
10538
+ (hint) => hint.startsWith("pin") || /^(?:pin)?\d+$/.test(hint)
10539
+ );
10540
+ if (!hasPinIdentifier) {
10541
+ portHintsList = [...portHintsList, `pin${implicitPinNumber}`];
10542
+ }
10543
+ implicitPinNumber++;
10544
+ const newPort = getPortFromHints(portHintsList, opts);
10545
+ if (!newPort) continue;
10546
+ newPort.originDescription = portHintGroup.originDescription;
10547
+ const pinNumber = newPort._parsedProps.pinNumber;
10548
+ if (pinNumber === void 0) continue;
10549
+ const existingPort = portsByPinNumber.get(pinNumber);
10550
+ if (!existingPort) {
10551
+ portsByPinNumber.set(pinNumber, newPort);
10552
+ continue;
10553
+ }
10554
+ const mergedAliases = newPort.getNameAndAliases().filter((alias) => !existingPort.getNameAndAliases().includes(alias));
10555
+ existingPort.externallyAddedAliases.push(...mergedAliases);
10556
+ }
10557
+ return Array.from(portsByPinNumber.values());
10558
+ }
10559
+
10527
10560
  // lib/components/base-components/NormalComponent/NormalComponent.ts
10528
10561
  var debug3 = Debug5("tscircuit:core");
10529
10562
  var rotation32 = z9.object({
@@ -11372,41 +11405,31 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
11372
11405
  this._queueInvalidFootprintPropMessage(footprint, error);
11373
11406
  return [];
11374
11407
  }
11375
- const newPorts2 = [];
11376
- for (const elm of fpCircuitJson) {
11377
- if ("port_hints" in elm && elm.port_hints) {
11378
- const newPort = getPortFromHints(elm.port_hints, opts);
11379
- if (!newPort) continue;
11380
- newPort.originDescription = `footprint:string:${footprint}:port_hints[0]:${elm.port_hints[0]}`;
11381
- newPorts2.push(newPort);
11382
- }
11383
- }
11384
- return newPorts2;
11408
+ return getLogicalPortsFromPortHintGroups(
11409
+ fpCircuitJson.flatMap(
11410
+ (elm) => "port_hints" in elm && elm.port_hints ? [
11411
+ {
11412
+ hints: elm.port_hints,
11413
+ originDescription: `footprint:string:${footprint}:port_hints[0]:${elm.port_hints[0]}`
11414
+ }
11415
+ ] : []
11416
+ ),
11417
+ opts
11418
+ );
11385
11419
  }
11386
11420
  if (!isValidElement(footprint) && footprint && footprint.componentName === "Footprint") {
11387
11421
  const fp2 = footprint;
11388
- let pinNumber = 1;
11389
- const newPorts2 = [];
11390
- for (const fpChild of fp2.children) {
11391
- if (!fpChild.props.portHints) continue;
11392
- const filteredPortHints = fpChild.props.portHints.filter(
11393
- (hint) => hint && hint.trim() !== ""
11394
- );
11395
- if (filteredPortHints.length === 0) continue;
11396
- let portHintsList = filteredPortHints;
11397
- const hasPinIdentifier = portHintsList.some(
11398
- (hint) => hint.startsWith("pin") || /^(?:pin)?\d+$/.test(hint)
11399
- );
11400
- if (!hasPinIdentifier) {
11401
- portHintsList = [...portHintsList, `pin${pinNumber}`];
11402
- }
11403
- pinNumber++;
11404
- const newPort = getPortFromHints(portHintsList);
11405
- if (!newPort) continue;
11406
- newPort.originDescription = `footprint:${footprint}`;
11407
- newPorts2.push(newPort);
11408
- }
11409
- return newPorts2;
11422
+ return getLogicalPortsFromPortHintGroups(
11423
+ fp2.children.flatMap(
11424
+ (fpChild) => fpChild.props.portHints ? [
11425
+ {
11426
+ hints: fpChild.props.portHints,
11427
+ originDescription: `footprint:${footprint}`
11428
+ }
11429
+ ] : []
11430
+ ),
11431
+ opts
11432
+ );
11410
11433
  }
11411
11434
  const newPorts = [];
11412
11435
  if (!footprint) {
@@ -19322,7 +19345,7 @@ import { identity as identity5 } from "transformation-matrix";
19322
19345
  var package_default = {
19323
19346
  name: "@tscircuit/core",
19324
19347
  type: "module",
19325
- version: "0.0.1159",
19348
+ version: "0.0.1160",
19326
19349
  types: "dist/index.d.ts",
19327
19350
  main: "dist/index.js",
19328
19351
  module: "dist/index.js",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1160",
4
+ "version": "0.0.1161",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",