@tscircuit/core 0.0.425 → 0.0.426

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
@@ -12470,6 +12470,30 @@ type RenderEvent = {
12470
12470
  */
12471
12471
  declare const getPhaseTimingsFromRenderEvents: (renderEvents: RenderEvent[]) => Record<string, number>;
12472
12472
 
12473
+ /**
12474
+ * Normalizes pin labels such that they are unique while preserving numbering
12475
+ * where not confusing.
12476
+ *
12477
+ * Example input:
12478
+ * [
12479
+ * ["1", "GND"],
12480
+ * ["2", "GND"],
12481
+ * ["3", "VCC"],
12482
+ * ["3"],
12483
+ * ["4"]
12484
+ * ]
12485
+ *
12486
+ * Example output:
12487
+ * [
12488
+ * ["pin1", "GND1"],
12489
+ * ["pin2", "GND2"],
12490
+ * ["pin3", "VCC"],
12491
+ * ["pin5", "pin3_alt1"],
12492
+ * ["pin4"]
12493
+ * ]
12494
+ */
12495
+ declare const normalizePinLabels: (inputPinLabels: string[][]) => string[][];
12496
+
12473
12497
  type Nums16 = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12" | "13" | "14" | "15" | "16";
12474
12498
  type Nums40 = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" | "18" | "19" | "20" | "21" | "22" | "23" | "24" | "25" | "26" | "27" | "28" | "29" | "30" | "31" | "32" | "33" | "34" | "35" | "36" | "37" | "38" | "39" | "40";
12475
12499
  type PinNumbers100 = "pin0" | "pin1" | "pin2" | "pin3" | "pin4" | "pin5" | "pin6" | "pin7" | "pin8" | "pin9" | "pin10" | "pin11" | "pin12" | "pin13" | "pin14" | "pin15" | "pin16" | "pin17" | "pin18" | "pin19" | "pin20" | "pin21" | "pin22" | "pin23" | "pin24" | "pin25" | "pin26" | "pin27" | "pin28" | "pin29" | "pin30" | "pin31" | "pin32" | "pin33" | "pin34" | "pin35" | "pin36" | "pin37" | "pin38" | "pin39" | "pin40" | "pin41" | "pin42" | "pin43" | "pin44" | "pin45" | "pin46" | "pin47" | "pin48" | "pin49" | "pin50" | "pin51" | "pin52" | "pin53" | "pin54" | "pin55" | "pin56" | "pin57" | "pin58" | "pin59" | "pin60" | "pin61" | "pin62" | "pin63" | "pin64" | "pin65" | "pin66" | "pin67" | "pin68" | "pin69" | "pin70" | "pin71" | "pin72" | "pin73" | "pin74" | "pin75" | "pin76" | "pin77" | "pin78" | "pin79" | "pin80" | "pin81" | "pin82" | "pin83" | "pin84" | "pin85" | "pin86" | "pin87" | "pin88" | "pin89" | "pin90" | "pin91" | "pin92" | "pin93" | "pin94" | "pin95" | "pin96" | "pin97" | "pin98" | "pin99" | "pin100";
@@ -12632,4 +12656,4 @@ declare module "react/jsx-runtime" {
12632
12656
  }
12633
12657
  }
12634
12658
 
12635
- export { type AsyncEffect, type AutorouterCompleteEvent, type AutorouterErrorEvent, type AutorouterEvent, type AutorouterProgressEvent, type AutoroutingEndEvent, type AutoroutingErrorEvent, type AutoroutingProgressEvent, type AutoroutingStartEvent, Battery, Board, Capacitor, Chip, Circuit, type ComponentWithPins, Constraint, Crystal, Cutout, Diode, FabricationNotePath, FabricationNoteText, Footprint, type GenericConnectionsAndSelectorsSel, type GenericLocalAutorouter, Group, Hole, type IRenderable, Inductor, Jumper, Keepout, Led, type LocalCacheEngine, Mosfet, Net, NetAlias, NormalComponent, type Obstacle, PcbTrace, PinHeader, type PinLabelSpec, PlatedHole, Port, Potentiometer, PowerSource, PrimitiveComponent, Project, PushButton, type RenderPhase, type RenderPhaseFn, type RenderPhaseFunctions, type RenderPhaseStates, Renderable, Resistor, Resonator, RootCircuit, type RootCircuitEventName, SchematicText, type Sel, SilkscreenCircle, SilkscreenLine, SilkscreenPath, SilkscreenRect, SilkscreenText, type SimpleRouteConnection, type SimpleRouteJson, type SimplifiedPcbTrace, SmtPad, Subcircuit, Switch, Trace, TraceHint, Transistor, Via, applyEditEvents, applyEditEventsToManualEditsFile, applyPcbEditEventsToManualEditsFile, applySchematicEditEventsToManualEditsFile, createUseComponent, getPhaseTimingsFromRenderEvents, getSimpleRouteJsonFromCircuitJson, orderedRenderPhases, sel, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
12659
+ export { type AsyncEffect, type AutorouterCompleteEvent, type AutorouterErrorEvent, type AutorouterEvent, type AutorouterProgressEvent, type AutoroutingEndEvent, type AutoroutingErrorEvent, type AutoroutingProgressEvent, type AutoroutingStartEvent, Battery, Board, Capacitor, Chip, Circuit, type ComponentWithPins, Constraint, Crystal, Cutout, Diode, FabricationNotePath, FabricationNoteText, Footprint, type GenericConnectionsAndSelectorsSel, type GenericLocalAutorouter, Group, Hole, type IRenderable, Inductor, Jumper, Keepout, Led, type LocalCacheEngine, Mosfet, Net, NetAlias, NormalComponent, type Obstacle, PcbTrace, PinHeader, type PinLabelSpec, PlatedHole, Port, Potentiometer, PowerSource, PrimitiveComponent, Project, PushButton, type RenderPhase, type RenderPhaseFn, type RenderPhaseFunctions, type RenderPhaseStates, Renderable, Resistor, Resonator, RootCircuit, type RootCircuitEventName, SchematicText, type Sel, SilkscreenCircle, SilkscreenLine, SilkscreenPath, SilkscreenRect, SilkscreenText, type SimpleRouteConnection, type SimpleRouteJson, type SimplifiedPcbTrace, SmtPad, Subcircuit, Switch, Trace, TraceHint, Transistor, Via, applyEditEvents, applyEditEventsToManualEditsFile, applyPcbEditEventsToManualEditsFile, applySchematicEditEventsToManualEditsFile, createUseComponent, getPhaseTimingsFromRenderEvents, getSimpleRouteJsonFromCircuitJson, normalizePinLabels, orderedRenderPhases, sel, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
package/dist/index.js CHANGED
@@ -6419,6 +6419,80 @@ var getPhaseTimingsFromRenderEvents = (renderEvents) => {
6419
6419
  return phaseTimings;
6420
6420
  };
6421
6421
 
6422
+ // lib/utils/schematic/normalizePinLabels.ts
6423
+ var normalizePinLabels = (inputPinLabels) => {
6424
+ const unqInputPinLabels = inputPinLabels.map((labels) => [...new Set(labels)]);
6425
+ const result = unqInputPinLabels.map(() => []);
6426
+ const desiredNumbers = unqInputPinLabels.map(() => null);
6427
+ for (let i = 0; i < unqInputPinLabels.length; i++) {
6428
+ for (const label of unqInputPinLabels[i]) {
6429
+ if (/^\d+$/.test(label)) {
6430
+ desiredNumbers[i] = Number.parseInt(label);
6431
+ break;
6432
+ }
6433
+ }
6434
+ }
6435
+ let highestPinNumber = 0;
6436
+ const alreadyAcceptedDesiredNumbers = /* @__PURE__ */ new Set();
6437
+ for (let i = 0; i < desiredNumbers.length; i++) {
6438
+ const desiredNumber = desiredNumbers[i];
6439
+ if (desiredNumber === null || desiredNumber < 1) {
6440
+ continue;
6441
+ }
6442
+ if (!alreadyAcceptedDesiredNumbers.has(desiredNumber)) {
6443
+ alreadyAcceptedDesiredNumbers.add(desiredNumber);
6444
+ result[i].push(`pin${desiredNumber}`);
6445
+ highestPinNumber = Math.max(highestPinNumber, desiredNumber);
6446
+ continue;
6447
+ }
6448
+ let existingAltsForPin = 0;
6449
+ for (const label of result[i]) {
6450
+ if (label.startsWith(`pin${desiredNumber}_alt`)) {
6451
+ existingAltsForPin++;
6452
+ }
6453
+ }
6454
+ result[i].push(`pin${desiredNumber}_alt${existingAltsForPin + 1}`);
6455
+ }
6456
+ for (let i = 0; i < result.length; i++) {
6457
+ const firstLabel = result[i][0];
6458
+ if (firstLabel?.includes("_alt")) {
6459
+ highestPinNumber++;
6460
+ result[i].unshift(`pin${highestPinNumber}`);
6461
+ }
6462
+ }
6463
+ for (let i = 0; i < result.length; i++) {
6464
+ if (result[i].length === 0) {
6465
+ highestPinNumber++;
6466
+ result[i].push(`pin${highestPinNumber}`);
6467
+ }
6468
+ }
6469
+ const totalLabelCounts = {};
6470
+ for (const inputLabels of unqInputPinLabels) {
6471
+ for (const label of inputLabels) {
6472
+ if (/^\d+$/.test(label)) {
6473
+ continue;
6474
+ }
6475
+ totalLabelCounts[label] = (totalLabelCounts[label] ?? 0) + 1;
6476
+ }
6477
+ }
6478
+ const incrementalLabelCounts = {};
6479
+ for (let i = 0; i < unqInputPinLabels.length; i++) {
6480
+ const inputLabels = unqInputPinLabels[i];
6481
+ for (const label of inputLabels) {
6482
+ if (/^\d+$/.test(label)) {
6483
+ continue;
6484
+ }
6485
+ if (totalLabelCounts[label] === 1) {
6486
+ result[i].push(label);
6487
+ } else {
6488
+ incrementalLabelCounts[label] = (incrementalLabelCounts[label] ?? 0) + 1;
6489
+ result[i].push(`${label}${incrementalLabelCounts[label]}`);
6490
+ }
6491
+ }
6492
+ }
6493
+ return result;
6494
+ };
6495
+
6422
6496
  // lib/components/primitive-components/Group/Group.ts
6423
6497
  import "@tscircuit/checks";
6424
6498
  var Group = class extends NormalComponent {
@@ -8530,7 +8604,7 @@ import { identity as identity4 } from "transformation-matrix";
8530
8604
  var package_default = {
8531
8605
  name: "@tscircuit/core",
8532
8606
  type: "module",
8533
- version: "0.0.424",
8607
+ version: "0.0.425",
8534
8608
  types: "dist/index.d.ts",
8535
8609
  main: "dist/index.js",
8536
8610
  module: "dist/index.js",
@@ -9030,6 +9104,7 @@ export {
9030
9104
  createUseComponent,
9031
9105
  getPhaseTimingsFromRenderEvents,
9032
9106
  getSimpleRouteJsonFromCircuitJson,
9107
+ normalizePinLabels,
9033
9108
  orderedRenderPhases,
9034
9109
  sel,
9035
9110
  useCapacitor,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.425",
4
+ "version": "0.0.426",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",