@tscircuit/core 0.0.1509 → 0.0.1511

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 +50 -66
  2. package/package.json +1 -1
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
+ schematicPortIds: [a, b],
22282
22252
  netId: userNetId,
22283
22253
  netLabelWidth
22284
22254
  });
@@ -22293,22 +22263,23 @@ function createSchematicTraceSolverInputProblem(group, opts = {}) {
22293
22263
  connKeyToSourceNet.set(net.subcircuit_connectivity_map_key, net);
22294
22264
  }
22295
22265
  }
22296
- const connKeyToPinIds = /* @__PURE__ */ new Map();
22266
+ const connKeyToSchematicPortIds = /* @__PURE__ */ new Map();
22297
22267
  for (const [schId, srcPortId] of schPortIdToSourcePortId) {
22298
22268
  const sp = db.source_port.get(srcPortId);
22299
22269
  if (!sp?.subcircuit_connectivity_map_key) continue;
22300
22270
  const connKey = sp.subcircuit_connectivity_map_key;
22301
- if (!connKeyToPinIds.has(connKey)) connKeyToPinIds.set(connKey, []);
22302
- connKeyToPinIds.get(connKey).push(schId);
22271
+ if (!connKeyToSchematicPortIds.has(connKey)) {
22272
+ connKeyToSchematicPortIds.set(connKey, []);
22273
+ }
22274
+ connKeyToSchematicPortIds.get(connKey).push(schId);
22303
22275
  }
22304
- for (const [connKey, schematicPortIds] of connKeyToPinIds) {
22276
+ for (const [connKey, schematicPortIds] of connKeyToSchematicPortIds) {
22305
22277
  const sourceNet = connKeyToSourceNet.get(connKey);
22306
22278
  if (sourceNet && schematicPortIds.length >= 1) {
22307
22279
  const seenRoutedSchematicPortIds = /* @__PURE__ */ new Set();
22308
22280
  const uniqueSchematicPortIds = schematicPortIds.filter(
22309
22281
  (schematicPortId) => {
22310
- const sourcePortId = schPortIdToSourcePortId.get(schematicPortId);
22311
- const componentPort = sourcePortId ? componentPortBySourcePortId.get(sourcePortId) : void 0;
22282
+ const componentPort = componentPortBySchematicPortId.get(schematicPortId);
22312
22283
  const routedSchematicPortIdValue = componentPort ? getPortForSchematicSymbolPort(componentPort).schematic_port_id : null;
22313
22284
  const routedSchematicPortId = routedSchematicPortIdValue ? asSchematicPortId(routedSchematicPortIdValue) : schematicPortId;
22314
22285
  if (seenRoutedSchematicPortIds.has(routedSchematicPortId)) {
@@ -22333,9 +22304,7 @@ function createSchematicTraceSolverInputProblem(group, opts = {}) {
22333
22304
  }
22334
22305
  netConnections.push({
22335
22306
  netId: userNetId,
22336
- pinIds: uniqueSchematicPortIds.map(
22337
- (portId) => schematicPortIdToPinId.get(portId)
22338
- ),
22307
+ schematicPortIds: uniqueSchematicPortIds,
22339
22308
  netLabelWidth,
22340
22309
  netLabelHeight
22341
22310
  });
@@ -22361,15 +22330,24 @@ function createSchematicTraceSolverInputProblem(group, opts = {}) {
22361
22330
  })();
22362
22331
  const inputProblem = {
22363
22332
  chips,
22364
- directConnections,
22365
- netConnections,
22333
+ directConnections: directConnections.map(
22334
+ ({ schematicPortIds, ...connection }) => ({
22335
+ ...connection,
22336
+ pinIds: schematicPortIds
22337
+ })
22338
+ ),
22339
+ netConnections: netConnections.map(
22340
+ ({ schematicPortIds, ...connection }) => ({
22341
+ ...connection,
22342
+ pinIds: schematicPortIds
22343
+ })
22344
+ ),
22366
22345
  textBoxes,
22367
22346
  availableNetLabelOrientations,
22368
22347
  maxMspPairDistance: group._parsedProps.schMaxTraceDistance ?? DEFAULT_MAX_MSP_PAIR_DISTANCE
22369
22348
  };
22370
22349
  return {
22371
22350
  inputProblem,
22372
- pinIdToSchematicPortId,
22373
22351
  connKeyToSourceNet,
22374
22352
  userNetIdToConnKey,
22375
22353
  connKeysWithExplicitPortNetTraces,
@@ -22396,8 +22374,7 @@ var getSchematicPortIdsWithAssignedNetLabels = (group) => {
22396
22374
 
22397
22375
  // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/getSchematicPortIdsWithRoutedTraces.ts
22398
22376
  var getSchematicPortIdsWithRoutedTraces = ({
22399
- solver,
22400
- pinIdToSchematicPortId
22377
+ solver
22401
22378
  }) => {
22402
22379
  const solvedTraces = solver.traceCleanupSolver?.getOutput().traces ?? solver.traceLabelOverlapAvoidanceSolver?.getOutput().traces ?? solver.schematicTraceLinesSolver?.solvedTracePaths ?? [];
22403
22380
  const schematicPortIdsWithRoutedTraces = /* @__PURE__ */ new Set();
@@ -22406,7 +22383,7 @@ var getSchematicPortIdsWithRoutedTraces = ({
22406
22383
  if (!Array.isArray(points) || points.length < 2) continue;
22407
22384
  const pinIds = Array.isArray(solvedTrace.pins) ? solvedTrace.pins.map((pin) => pin.pinId) : solvedTrace.pinIds;
22408
22385
  for (const pinId of pinIds) {
22409
- const schPortId = pinIdToSchematicPortId.get(pinId);
22386
+ const schPortId = asSchematicPortId(pinId);
22410
22387
  if (schPortId) {
22411
22388
  schematicPortIdsWithRoutedTraces.add(schPortId);
22412
22389
  }
@@ -22637,7 +22614,6 @@ var renderSchematicTracesForSheet = ({
22637
22614
  }) => {
22638
22615
  const {
22639
22616
  inputProblem,
22640
- pinIdToSchematicPortId,
22641
22617
  connKeyToSourceNet,
22642
22618
  schematicPortIdsInScope,
22643
22619
  schPortIdToSourcePortId,
@@ -22674,13 +22650,11 @@ var renderSchematicTracesForSheet = ({
22674
22650
  });
22675
22651
  solver.solve();
22676
22652
  const schematicPortIdsWithRoutedTraces = getSchematicPortIdsWithRoutedTraces({
22677
- solver,
22678
- pinIdToSchematicPortId
22653
+ solver
22679
22654
  });
22680
22655
  applyTracesFromSolverOutput({
22681
22656
  group,
22682
22657
  solver,
22683
- pinIdToSchematicPortId,
22684
22658
  userNetIdToConnKey,
22685
22659
  schematicPortIdsWithPreExistingNetLabels
22686
22660
  });
@@ -22688,7 +22662,6 @@ var renderSchematicTracesForSheet = ({
22688
22662
  group,
22689
22663
  solver,
22690
22664
  connKeyToSourceNet,
22691
- pinIdToSchematicPortId,
22692
22665
  userNetIdToConnKey,
22693
22666
  connKeysWithExplicitPortNetTraces,
22694
22667
  schematicPortIdsWithPreExistingNetLabels,
@@ -23714,7 +23687,7 @@ function Group_getRoutingPhasePlans(group) {
23714
23687
  var package_default = {
23715
23688
  name: "@tscircuit/core",
23716
23689
  type: "module",
23717
- version: "0.0.1508",
23690
+ version: "0.0.1510",
23718
23691
  types: "dist/index.d.ts",
23719
23692
  main: "dist/index.js",
23720
23693
  module: "dist/index.js",
@@ -26947,6 +26920,8 @@ var Transistor = class extends NormalComponent3 {
26947
26920
  const source_component = db.source_component.insert({
26948
26921
  ftype: "simple_transistor",
26949
26922
  name: this.name,
26923
+ manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
26924
+ supplier_part_numbers: props.supplierPartNumbers,
26950
26925
  transistor_type: props.type,
26951
26926
  display_name: props.displayName
26952
26927
  });
@@ -29369,6 +29344,8 @@ var Fuse = class extends NormalComponent3 {
29369
29344
  const source_component = db.source_component.insert({
29370
29345
  name: this.name,
29371
29346
  ftype: FTYPE.simple_fuse,
29347
+ manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
29348
+ supplier_part_numbers: props.supplierPartNumbers,
29372
29349
  current_rating_amps: currentRating,
29373
29350
  voltage_rating_volts: voltageRating,
29374
29351
  display_current_rating: `${formatSiUnit4(currentRating)}A`,
@@ -29525,11 +29502,14 @@ var Interconnect = class extends NormalComponent3 {
29525
29502
  }
29526
29503
  doInitialSourceRender() {
29527
29504
  const { db } = this.root;
29505
+ const { _parsedProps: props } = this;
29528
29506
  const source_component = db.source_component.insert({
29529
29507
  ftype: "interconnect",
29530
29508
  name: this.name,
29509
+ manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
29510
+ supplier_part_numbers: props.supplierPartNumbers,
29531
29511
  are_pins_interchangeable: true,
29532
- display_name: this._parsedProps.displayName
29512
+ display_name: props.displayName
29533
29513
  });
29534
29514
  this.source_component_id = source_component.source_component_id;
29535
29515
  }
@@ -33459,6 +33439,8 @@ var Potentiometer = class extends NormalComponent3 {
33459
33439
  const source_component = db.source_component.insert({
33460
33440
  ftype: "simple_potentiometer",
33461
33441
  name: this.name,
33442
+ manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
33443
+ supplier_part_numbers: props.supplierPartNumbers,
33462
33444
  max_resistance: props.maxResistance,
33463
33445
  pin_variant: pinVariant,
33464
33446
  are_pins_interchangeable: pinVariant === "two_pin",
@@ -33512,6 +33494,8 @@ var Crystal = class extends NormalComponent3 {
33512
33494
  const source_component = db.source_component.insert({
33513
33495
  name: this.name,
33514
33496
  ftype: "simple_crystal",
33497
+ manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
33498
+ supplier_part_numbers: props.supplierPartNumbers,
33515
33499
  frequency: props.frequency,
33516
33500
  load_capacitance: props.loadCapacitance,
33517
33501
  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.1509",
4
+ "version": "0.0.1511",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",