@tscircuit/core 0.0.425 → 0.0.427

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 {
@@ -7424,7 +7498,7 @@ var Led = class extends NormalComponent {
7424
7498
  componentName: "Led",
7425
7499
  schematicSymbolName: this.props.symbolName ?? "led",
7426
7500
  zodProps: ledProps,
7427
- sourceFtype: "simple_diode"
7501
+ sourceFtype: "simple_led"
7428
7502
  };
7429
7503
  }
7430
7504
  initPorts() {
@@ -7439,8 +7513,10 @@ var Led = class extends NormalComponent {
7439
7513
  const { db } = this.root;
7440
7514
  const { _parsedProps: props } = this;
7441
7515
  const source_component = db.source_component.insert({
7442
- ftype: "simple_diode",
7516
+ ftype: "simple_led",
7443
7517
  name: props.name,
7518
+ wave_length: props.wavelength,
7519
+ color: props.color,
7444
7520
  // @ts-ignore
7445
7521
  manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
7446
7522
  supplier_part_numbers: props.supplierPartNumbers,
@@ -8530,7 +8606,7 @@ import { identity as identity4 } from "transformation-matrix";
8530
8606
  var package_default = {
8531
8607
  name: "@tscircuit/core",
8532
8608
  type: "module",
8533
- version: "0.0.424",
8609
+ version: "0.0.426",
8534
8610
  types: "dist/index.d.ts",
8535
8611
  main: "dist/index.js",
8536
8612
  module: "dist/index.js",
@@ -8562,7 +8638,7 @@ var package_default = {
8562
8638
  "@tscircuit/layout": "^0.0.28",
8563
8639
  "@tscircuit/log-soup": "^1.0.2",
8564
8640
  "@tscircuit/math-utils": "^0.0.18",
8565
- "@tscircuit/props": "^0.0.190",
8641
+ "@tscircuit/props": "^0.0.193",
8566
8642
  "@tscircuit/schematic-autolayout": "^0.0.6",
8567
8643
  "@types/bun": "latest",
8568
8644
  "@types/debug": "^4.1.12",
@@ -8571,7 +8647,7 @@ var package_default = {
8571
8647
  "@types/react-reconciler": "^0.28.9",
8572
8648
  "bun-match-svg": "0.0.8",
8573
8649
  "chokidar-cli": "^3.0.0",
8574
- "circuit-json": "^0.0.186",
8650
+ "circuit-json": "^0.0.190",
8575
8651
  "circuit-json-to-connectivity-map": "^0.0.22",
8576
8652
  "circuit-json-to-simple-3d": "^0.0.2",
8577
8653
  "circuit-to-svg": "^0.0.127",
@@ -9030,6 +9106,7 @@ export {
9030
9106
  createUseComponent,
9031
9107
  getPhaseTimingsFromRenderEvents,
9032
9108
  getSimpleRouteJsonFromCircuitJson,
9109
+ normalizePinLabels,
9033
9110
  orderedRenderPhases,
9034
9111
  sel,
9035
9112
  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.427",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -33,7 +33,7 @@
33
33
  "@tscircuit/layout": "^0.0.28",
34
34
  "@tscircuit/log-soup": "^1.0.2",
35
35
  "@tscircuit/math-utils": "^0.0.18",
36
- "@tscircuit/props": "^0.0.190",
36
+ "@tscircuit/props": "^0.0.193",
37
37
  "@tscircuit/schematic-autolayout": "^0.0.6",
38
38
  "@types/bun": "latest",
39
39
  "@types/debug": "^4.1.12",
@@ -42,7 +42,7 @@
42
42
  "@types/react-reconciler": "^0.28.9",
43
43
  "bun-match-svg": "0.0.8",
44
44
  "chokidar-cli": "^3.0.0",
45
- "circuit-json": "^0.0.186",
45
+ "circuit-json": "^0.0.190",
46
46
  "circuit-json-to-connectivity-map": "^0.0.22",
47
47
  "circuit-json-to-simple-3d": "^0.0.2",
48
48
  "circuit-to-svg": "^0.0.127",