@tscircuit/core 0.0.611 → 0.0.612

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
@@ -11,7 +11,7 @@ import { CircuitJsonUtilObjects } from '@tscircuit/circuit-json-util';
11
11
  import { ConnectivityMap } from 'circuit-json-to-connectivity-map';
12
12
  import { GraphicsObject } from 'graphics-debug';
13
13
 
14
- declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "PcbFootprintStringRender", "InitializePortsFromChildren", "CreateNetsFromProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SchematicComponentRender", "SchematicPortRender", "SchematicPrimitiveRender", "SchematicLayout", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbLayout", "PcbBoardAutoSize", "PcbTraceHintRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbDesignRuleChecks", "CadModelRender", "PartsEngineRender"];
14
+ declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "PcbFootprintStringRender", "InitializePortsFromChildren", "CreateNetsFromProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SchematicPrimitiveRender", "SchematicLayout", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbLayout", "PcbBoardAutoSize", "PcbTraceHintRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbDesignRuleChecks", "CadModelRender", "PartsEngineRender"];
15
15
  type RenderPhase = (typeof orderedRenderPhases)[number];
16
16
  type RenderPhaseFn<K extends RenderPhase = RenderPhase> = `doInitial${K}` | `update${K}` | `remove${K}`;
17
17
  type RenderPhaseStates = Record<RenderPhase, {
@@ -3467,6 +3467,7 @@ declare class Chip<PinLabels extends string = never> extends NormalComponent<typ
3467
3467
  doInitialSourceRender(): void;
3468
3468
  doInitialPcbComponentRender(): void;
3469
3469
  doInitialCreateTracesFromProps(): void;
3470
+ doInitialSimulationRender(): void;
3470
3471
  }
3471
3472
 
3472
3473
  declare class Diode extends NormalComponent<typeof diodeProps, PolarizedPassivePorts> {
package/dist/index.js CHANGED
@@ -98,6 +98,7 @@ var orderedRenderPhases = [
98
98
  "OptimizeSelectorCache",
99
99
  "SourceTraceRender",
100
100
  "SourceAddConnectivityMapKey",
101
+ "SimulationRender",
101
102
  "SchematicComponentRender",
102
103
  "SchematicPortRender",
103
104
  "SchematicPrimitiveRender",
@@ -9536,6 +9537,54 @@ var Chip = class extends NormalComponent {
9536
9537
  }
9537
9538
  this._createTracesFromConnectionsProp();
9538
9539
  }
9540
+ doInitialSimulationRender() {
9541
+ const { db } = this.root;
9542
+ const { pinAttributes } = this.props;
9543
+ if (!pinAttributes) return;
9544
+ let powerPort = null;
9545
+ let groundPort = null;
9546
+ let voltage;
9547
+ const ports = this.selectAll("port");
9548
+ for (const port of ports) {
9549
+ for (const alias of port.getNameAndAliases()) {
9550
+ if (pinAttributes[alias]) {
9551
+ const attributes = pinAttributes[alias];
9552
+ if (attributes.providesPower) {
9553
+ powerPort = port;
9554
+ voltage = attributes.providesVoltage;
9555
+ }
9556
+ if (attributes.providesGround) {
9557
+ groundPort = port;
9558
+ }
9559
+ }
9560
+ }
9561
+ }
9562
+ if (!powerPort || !groundPort || voltage === void 0) {
9563
+ return;
9564
+ }
9565
+ const powerSourcePort = db.source_port.get(powerPort.source_port_id);
9566
+ if (!powerSourcePort?.subcircuit_connectivity_map_key) return;
9567
+ const groundSourcePort = db.source_port.get(groundPort.source_port_id);
9568
+ if (!groundSourcePort?.subcircuit_connectivity_map_key) return;
9569
+ const powerNet = db.source_net.getWhere({
9570
+ subcircuit_connectivity_map_key: powerSourcePort.subcircuit_connectivity_map_key
9571
+ });
9572
+ const groundNet = db.source_net.getWhere({
9573
+ subcircuit_connectivity_map_key: groundSourcePort.subcircuit_connectivity_map_key
9574
+ });
9575
+ if (!powerNet || !groundNet) {
9576
+ return;
9577
+ }
9578
+ ;
9579
+ db.simulation_voltage_source.insert({
9580
+ type: "simulation_voltage_source",
9581
+ positive_source_port_id: powerPort.source_port_id,
9582
+ positive_source_net_id: powerNet.source_net_id,
9583
+ negative_source_port_id: groundPort.source_port_id,
9584
+ negative_source_net_id: groundNet.source_net_id,
9585
+ voltage
9586
+ });
9587
+ }
9539
9588
  };
9540
9589
 
9541
9590
  // lib/components/normal-components/Diode.ts
@@ -11546,7 +11595,7 @@ import { identity as identity5 } from "transformation-matrix";
11546
11595
  var package_default = {
11547
11596
  name: "@tscircuit/core",
11548
11597
  type: "module",
11549
- version: "0.0.610",
11598
+ version: "0.0.611",
11550
11599
  types: "dist/index.d.ts",
11551
11600
  main: "dist/index.js",
11552
11601
  module: "dist/index.js",
@@ -11592,7 +11641,7 @@ var package_default = {
11592
11641
  "bun-match-svg": "0.0.12",
11593
11642
  "calculate-elbow": "^0.0.5",
11594
11643
  "chokidar-cli": "^3.0.0",
11595
- "circuit-json": "^0.0.224",
11644
+ "circuit-json": "^0.0.226",
11596
11645
  "circuit-json-to-bpc": "^0.0.13",
11597
11646
  "circuit-json-to-connectivity-map": "^0.0.22",
11598
11647
  "circuit-json-to-simple-3d": "^0.0.6",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.611",
4
+ "version": "0.0.612",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -47,7 +47,7 @@
47
47
  "bun-match-svg": "0.0.12",
48
48
  "calculate-elbow": "^0.0.5",
49
49
  "chokidar-cli": "^3.0.0",
50
- "circuit-json": "^0.0.224",
50
+ "circuit-json": "^0.0.226",
51
51
  "circuit-json-to-bpc": "^0.0.13",
52
52
  "circuit-json-to-connectivity-map": "^0.0.22",
53
53
  "circuit-json-to-simple-3d": "^0.0.6",