@tscircuit/core 0.0.1508 → 0.0.1510

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
@@ -132627,9 +132627,9 @@ declare class Transistor extends NormalComponent<typeof transistorProps, Transis
132627
132627
  shouldRenderAsSchematicBox: boolean;
132628
132628
  };
132629
132629
  initPorts(): void;
132630
- emitter: Port;
132631
- collector: Port;
132632
- base: Port;
132630
+ get collector(): Port;
132631
+ get base(): Port;
132632
+ get emitter(): Port;
132633
132633
  doInitialCreateNetsFromProps(): void;
132634
132634
  doInitialCreateTracesFromProps(): void;
132635
132635
  doInitialSourceRender(): void;
package/dist/index.js CHANGED
@@ -21074,6 +21074,10 @@ var oppositeSide = (input) => {
21074
21074
  }
21075
21075
  };
21076
21076
 
21077
+ // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/port-id-types.ts
21078
+ var asSchematicPortId = (id) => id;
21079
+ var asSourcePortId = (id) => id;
21080
+
21077
21081
  // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyNetLabelPlacements.ts
21078
21082
  var debug8 = Debug10("Group_doInitialSchematicTraceRender");
21079
21083
  var isSameNet = (label, sourceNet) => label.source_net_id != null && label.source_net_id === sourceNet.source_net_id;
@@ -21098,7 +21102,6 @@ function applyNetLabelPlacements(args) {
21098
21102
  solver,
21099
21103
  connKeyToSourceNet,
21100
21104
  userNetIdToConnKey,
21101
- pinIdToSchematicPortId,
21102
21105
  connKeysWithExplicitPortNetTraces,
21103
21106
  schematicPortIdsWithPreExistingNetLabels,
21104
21107
  schematicPortIdsWithRoutedTraces
@@ -21157,9 +21160,7 @@ function applyNetLabelPlacements(args) {
21157
21160
  if (placementConnKey) {
21158
21161
  sourceNet = connKeyToSourceNet.get(placementConnKey);
21159
21162
  }
21160
- const schPortIds = placement.pinIds.map(
21161
- (pinId) => pinIdToSchematicPortId.get(pinId)
21162
- );
21163
+ const schPortIds = placement.pinIds.map(asSchematicPortId);
21163
21164
  let schematicSheetId = group._resolveSchematicSheetId();
21164
21165
  const schematicPort = db.schematic_port.get(schPortIds[0]);
21165
21166
  if (schematicPort?.schematic_sheet_id) {
@@ -21618,10 +21619,6 @@ var getPortForSchematicSymbolPort = (port) => {
21618
21619
  ) ?? port;
21619
21620
  };
21620
21621
 
21621
- // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/port-id-types.ts
21622
- var asSchematicPortId = (id) => id;
21623
- var asSourcePortId = (id) => id;
21624
-
21625
21622
  // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/remove-overlapping-same-net-crossing-segments.ts
21626
21623
  var TOL3 = 1e-6;
21627
21624
  function isCollinear(a, b, tol = TOL3) {
@@ -21775,7 +21772,6 @@ function applyTracesFromSolverOutput(args) {
21775
21772
  const {
21776
21773
  group,
21777
21774
  solver,
21778
- pinIdToSchematicPortId,
21779
21775
  userNetIdToConnKey,
21780
21776
  schematicPortIdsWithPreExistingNetLabels
21781
21777
  } = args;
@@ -21810,7 +21806,7 @@ function applyTracesFromSolverOutput(args) {
21810
21806
  debug9(`Traces inside SchematicTraceSolver output: ${(traces ?? []).length}`);
21811
21807
  for (const solvedTracePath of traces ?? []) {
21812
21808
  const uniquePinIds = Array.from(new Set(solvedTracePath.pinIds ?? []));
21813
- const solvedTraceSchematicPortIds = uniquePinIds.map((pinId) => pinIdToSchematicPortId.get(pinId)).filter((id) => Boolean(id));
21809
+ const solvedTraceSchematicPortIds = uniquePinIds.map(asSchematicPortId);
21814
21810
  const isNetLabelCoveredTrace = solvedTraceSchematicPortIds.length > 0 && solvedTraceSchematicPortIds.every(
21815
21811
  (id) => schematicPortIdsWithPreExistingNetLabels.has(id)
21816
21812
  );
@@ -21845,8 +21841,10 @@ function applyTracesFromSolverOutput(args) {
21845
21841
  const source_trace_id = String(solvedTracePath?.mspPairId);
21846
21842
  let subcircuit_connectivity_map_key;
21847
21843
  if (Array.isArray(solvedTracePath?.pins) && solvedTracePath.pins.length === 2) {
21848
- const pA = pinIdToSchematicPortId.get(solvedTracePath.pins[0]?.pinId);
21849
- const pB = pinIdToSchematicPortId.get(solvedTracePath.pins[1]?.pinId);
21844
+ const firstPinId = solvedTracePath.pins[0]?.pinId;
21845
+ const secondPinId = solvedTracePath.pins[1]?.pinId;
21846
+ const pA = firstPinId ? asSchematicPortId(firstPinId) : void 0;
21847
+ const pB = secondPinId ? asSchematicPortId(secondPinId) : void 0;
21850
21848
  if (pA && pB) {
21851
21849
  const routedSchematicPortIds = /* @__PURE__ */ new Set([pA, pB]);
21852
21850
  for (const routedSchematicPortId of routedSchematicPortIds) {
@@ -21970,16 +21968,6 @@ import {
21970
21968
  } from "@tscircuit/math-utils";
21971
21969
  import "@tscircuit/schematic-trace-solver";
21972
21970
 
21973
- // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/getSchematicPortSelector.ts
21974
- var getSchematicPortSelector = ({
21975
- componentName,
21976
- schematicPort,
21977
- sourcePort
21978
- }) => {
21979
- const pinIdentifier = schematicPort.pin_number ?? sourcePort?.name ?? sourcePort?.port_hints?.[0];
21980
- return `${componentName}.${pinIdentifier ?? schematicPort.schematic_port_id}`;
21981
- };
21982
-
21983
21971
  // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/schematicTextToTextBounds.ts
21984
21972
  import {
21985
21973
  getBoundFromCenteredRect as getBoundFromCenteredRect3,
@@ -22128,34 +22116,16 @@ function createSchematicTraceSolverInputProblem(group, opts = {}) {
22128
22116
  }
22129
22117
  }
22130
22118
  const chips = [];
22131
- const pinIdToSchematicPortId = /* @__PURE__ */ new Map();
22132
- const schematicPortIdToPinId = /* @__PURE__ */ new Map();
22133
22119
  for (const schematicComponent of schematicComponents) {
22134
22120
  const chipId = schematicComponent.schematic_component_id;
22135
22121
  const pins = [];
22136
- const sourceComponent = db.source_component.getWhere({
22137
- source_component_id: schematicComponent.source_component_id
22138
- });
22139
22122
  const schematicPorts = db.schematic_port.list({
22140
22123
  schematic_component_id: schematicComponent.schematic_component_id
22141
22124
  });
22142
22125
  for (const schematicPort of schematicPorts) {
22143
- const sourcePort = db.source_port.get(schematicPort.source_port_id);
22144
- const selector = getSchematicPortSelector({
22145
- componentName: sourceComponent?.name ?? schematicComponent.schematic_component_id,
22146
- schematicPort,
22147
- sourcePort
22148
- });
22149
22126
  const schematicPortId = asSchematicPortId(schematicPort.schematic_port_id);
22150
- pinIdToSchematicPortId.set(selector, schematicPortId);
22151
- schematicPortIdToPinId.set(schematicPortId, selector);
22152
- }
22153
- for (const schematicPort of schematicPorts) {
22154
- const pinId = schematicPortIdToPinId.get(
22155
- asSchematicPortId(schematicPort.schematic_port_id)
22156
- );
22157
22127
  pins.push({
22158
- pinId,
22128
+ pinId: schematicPortId,
22159
22129
  x: schematicPort.center.x,
22160
22130
  y: schematicPort.center.y,
22161
22131
  // Pass the port's true facing direction (known from the schematic
@@ -22190,8 +22160,8 @@ function createSchematicTraceSolverInputProblem(group, opts = {}) {
22190
22160
  const schPortIdToSourcePortId = /* @__PURE__ */ new Map();
22191
22161
  const sourcePortIdToSchPortId = /* @__PURE__ */ new Map();
22192
22162
  const userNetIdToConnKey = /* @__PURE__ */ new Map();
22193
- const componentPortBySourcePortId = new Map(
22194
- group.selectAll("port").filter((port) => port.source_port_id).map((port) => [asSourcePortId(port.source_port_id), port])
22163
+ const componentPortBySchematicPortId = new Map(
22164
+ group.selectAll("port").filter((port) => port.schematic_port_id).map((port) => [asSchematicPortId(port.schematic_port_id), port])
22195
22165
  );
22196
22166
  for (const sc of schematicComponents) {
22197
22167
  const ports = db.schematic_port.list({
@@ -22278,7 +22248,7 @@ function createSchematicTraceSolverInputProblem(group, opts = {}) {
22278
22248
  );
22279
22249
  }
22280
22250
  directConnections.push({
22281
- pinIds: [a, b].map((id) => schematicPortIdToPinId.get(id)),
22251
+ pinIds: [a, b],
22282
22252
  netId: userNetId,
22283
22253
  netLabelWidth
22284
22254
  });
@@ -22307,8 +22277,7 @@ function createSchematicTraceSolverInputProblem(group, opts = {}) {
22307
22277
  const seenRoutedSchematicPortIds = /* @__PURE__ */ new Set();
22308
22278
  const uniqueSchematicPortIds = schematicPortIds.filter(
22309
22279
  (schematicPortId) => {
22310
- const sourcePortId = schPortIdToSourcePortId.get(schematicPortId);
22311
- const componentPort = sourcePortId ? componentPortBySourcePortId.get(sourcePortId) : void 0;
22280
+ const componentPort = componentPortBySchematicPortId.get(schematicPortId);
22312
22281
  const routedSchematicPortIdValue = componentPort ? getPortForSchematicSymbolPort(componentPort).schematic_port_id : null;
22313
22282
  const routedSchematicPortId = routedSchematicPortIdValue ? asSchematicPortId(routedSchematicPortIdValue) : schematicPortId;
22314
22283
  if (seenRoutedSchematicPortIds.has(routedSchematicPortId)) {
@@ -22333,9 +22302,7 @@ function createSchematicTraceSolverInputProblem(group, opts = {}) {
22333
22302
  }
22334
22303
  netConnections.push({
22335
22304
  netId: userNetId,
22336
- pinIds: uniqueSchematicPortIds.map(
22337
- (portId) => schematicPortIdToPinId.get(portId)
22338
- ),
22305
+ pinIds: uniqueSchematicPortIds,
22339
22306
  netLabelWidth,
22340
22307
  netLabelHeight
22341
22308
  });
@@ -22369,7 +22336,6 @@ function createSchematicTraceSolverInputProblem(group, opts = {}) {
22369
22336
  };
22370
22337
  return {
22371
22338
  inputProblem,
22372
- pinIdToSchematicPortId,
22373
22339
  connKeyToSourceNet,
22374
22340
  userNetIdToConnKey,
22375
22341
  connKeysWithExplicitPortNetTraces,
@@ -22396,8 +22362,7 @@ var getSchematicPortIdsWithAssignedNetLabels = (group) => {
22396
22362
 
22397
22363
  // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/getSchematicPortIdsWithRoutedTraces.ts
22398
22364
  var getSchematicPortIdsWithRoutedTraces = ({
22399
- solver,
22400
- pinIdToSchematicPortId
22365
+ solver
22401
22366
  }) => {
22402
22367
  const solvedTraces = solver.traceCleanupSolver?.getOutput().traces ?? solver.traceLabelOverlapAvoidanceSolver?.getOutput().traces ?? solver.schematicTraceLinesSolver?.solvedTracePaths ?? [];
22403
22368
  const schematicPortIdsWithRoutedTraces = /* @__PURE__ */ new Set();
@@ -22406,7 +22371,7 @@ var getSchematicPortIdsWithRoutedTraces = ({
22406
22371
  if (!Array.isArray(points) || points.length < 2) continue;
22407
22372
  const pinIds = Array.isArray(solvedTrace.pins) ? solvedTrace.pins.map((pin) => pin.pinId) : solvedTrace.pinIds;
22408
22373
  for (const pinId of pinIds) {
22409
- const schPortId = pinIdToSchematicPortId.get(pinId);
22374
+ const schPortId = asSchematicPortId(pinId);
22410
22375
  if (schPortId) {
22411
22376
  schematicPortIdsWithRoutedTraces.add(schPortId);
22412
22377
  }
@@ -22637,7 +22602,6 @@ var renderSchematicTracesForSheet = ({
22637
22602
  }) => {
22638
22603
  const {
22639
22604
  inputProblem,
22640
- pinIdToSchematicPortId,
22641
22605
  connKeyToSourceNet,
22642
22606
  schematicPortIdsInScope,
22643
22607
  schPortIdToSourcePortId,
@@ -22674,13 +22638,11 @@ var renderSchematicTracesForSheet = ({
22674
22638
  });
22675
22639
  solver.solve();
22676
22640
  const schematicPortIdsWithRoutedTraces = getSchematicPortIdsWithRoutedTraces({
22677
- solver,
22678
- pinIdToSchematicPortId
22641
+ solver
22679
22642
  });
22680
22643
  applyTracesFromSolverOutput({
22681
22644
  group,
22682
22645
  solver,
22683
- pinIdToSchematicPortId,
22684
22646
  userNetIdToConnKey,
22685
22647
  schematicPortIdsWithPreExistingNetLabels
22686
22648
  });
@@ -22688,7 +22650,6 @@ var renderSchematicTracesForSheet = ({
22688
22650
  group,
22689
22651
  solver,
22690
22652
  connKeyToSourceNet,
22691
- pinIdToSchematicPortId,
22692
22653
  userNetIdToConnKey,
22693
22654
  connKeysWithExplicitPortNetTraces,
22694
22655
  schematicPortIdsWithPreExistingNetLabels,
@@ -23714,7 +23675,7 @@ function Group_getRoutingPhasePlans(group) {
23714
23675
  var package_default = {
23715
23676
  name: "@tscircuit/core",
23716
23677
  type: "module",
23717
- version: "0.0.1507",
23678
+ version: "0.0.1509",
23718
23679
  types: "dist/index.d.ts",
23719
23680
  main: "dist/index.js",
23720
23681
  module: "dist/index.js",
@@ -26892,6 +26853,11 @@ function inflateSourceTrace(sourceTrace, inflatorContext) {
26892
26853
 
26893
26854
  // lib/components/normal-components/Transistor.ts
26894
26855
  import { transistorProps } from "@tscircuit/props";
26856
+ var SHORT_ALIASES = {
26857
+ collector: ["c"],
26858
+ base: ["b"],
26859
+ emitter: ["e"]
26860
+ };
26895
26861
  var Transistor = class extends NormalComponent3 {
26896
26862
  get config() {
26897
26863
  const baseSymbolName = this.props.type === "npn" ? "npn_bipolar_transistor" : "pnp_bipolar_transistor";
@@ -26904,19 +26870,32 @@ var Transistor = class extends NormalComponent3 {
26904
26870
  };
26905
26871
  }
26906
26872
  initPorts() {
26907
- const pinAliases = {
26908
- pin1: ["collector", "c"],
26909
- pin2: ["emitter", "e"],
26910
- pin3: ["base", "b"]
26911
- };
26873
+ const additionalAliases = {};
26874
+ const symbol = this.getSchematicSymbol();
26875
+ for (const symPort of symbol?.ports ?? []) {
26876
+ const pinNumber = getPinNumberFromLabels(symPort.labels);
26877
+ if (!pinNumber) continue;
26878
+ for (const label of symPort.labels) {
26879
+ const shortAliases = SHORT_ALIASES[label];
26880
+ if (shortAliases) {
26881
+ additionalAliases[`pin${pinNumber}`] = shortAliases;
26882
+ }
26883
+ }
26884
+ }
26912
26885
  super.initPorts({
26913
26886
  pinCount: 3,
26914
- additionalAliases: pinAliases
26887
+ additionalAliases
26915
26888
  });
26916
26889
  }
26917
- emitter = this.portMap.pin1;
26918
- collector = this.portMap.pin2;
26919
- base = this.portMap.pin3;
26890
+ get collector() {
26891
+ return this.portMap.collector;
26892
+ }
26893
+ get base() {
26894
+ return this.portMap.base;
26895
+ }
26896
+ get emitter() {
26897
+ return this.portMap.emitter;
26898
+ }
26920
26899
  doInitialCreateNetsFromProps() {
26921
26900
  this._createNetsFromProps([...this._getNetsFromConnectionsProp()]);
26922
26901
  }
@@ -26929,6 +26908,8 @@ var Transistor = class extends NormalComponent3 {
26929
26908
  const source_component = db.source_component.insert({
26930
26909
  ftype: "simple_transistor",
26931
26910
  name: this.name,
26911
+ manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
26912
+ supplier_part_numbers: props.supplierPartNumbers,
26932
26913
  transistor_type: props.type,
26933
26914
  display_name: props.displayName
26934
26915
  });
@@ -29351,6 +29332,8 @@ var Fuse = class extends NormalComponent3 {
29351
29332
  const source_component = db.source_component.insert({
29352
29333
  name: this.name,
29353
29334
  ftype: FTYPE.simple_fuse,
29335
+ manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
29336
+ supplier_part_numbers: props.supplierPartNumbers,
29354
29337
  current_rating_amps: currentRating,
29355
29338
  voltage_rating_volts: voltageRating,
29356
29339
  display_current_rating: `${formatSiUnit4(currentRating)}A`,
@@ -29507,11 +29490,14 @@ var Interconnect = class extends NormalComponent3 {
29507
29490
  }
29508
29491
  doInitialSourceRender() {
29509
29492
  const { db } = this.root;
29493
+ const { _parsedProps: props } = this;
29510
29494
  const source_component = db.source_component.insert({
29511
29495
  ftype: "interconnect",
29512
29496
  name: this.name,
29497
+ manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
29498
+ supplier_part_numbers: props.supplierPartNumbers,
29513
29499
  are_pins_interchangeable: true,
29514
- display_name: this._parsedProps.displayName
29500
+ display_name: props.displayName
29515
29501
  });
29516
29502
  this.source_component_id = source_component.source_component_id;
29517
29503
  }
@@ -33441,6 +33427,8 @@ var Potentiometer = class extends NormalComponent3 {
33441
33427
  const source_component = db.source_component.insert({
33442
33428
  ftype: "simple_potentiometer",
33443
33429
  name: this.name,
33430
+ manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
33431
+ supplier_part_numbers: props.supplierPartNumbers,
33444
33432
  max_resistance: props.maxResistance,
33445
33433
  pin_variant: pinVariant,
33446
33434
  are_pins_interchangeable: pinVariant === "two_pin",
@@ -33494,6 +33482,8 @@ var Crystal = class extends NormalComponent3 {
33494
33482
  const source_component = db.source_component.insert({
33495
33483
  name: this.name,
33496
33484
  ftype: "simple_crystal",
33485
+ manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
33486
+ supplier_part_numbers: props.supplierPartNumbers,
33497
33487
  frequency: props.frequency,
33498
33488
  load_capacitance: props.loadCapacitance,
33499
33489
  pin_variant: props.pinVariant || "two_pin",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1508",
4
+ "version": "0.0.1510",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",