@tscircuit/core 0.0.867 → 0.0.869

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
@@ -16649,19 +16649,9 @@ declare const voltageSourceProps: z.ZodObject<{
16649
16649
  schY?: number | undefined;
16650
16650
  pcbX?: number | undefined;
16651
16651
  pcbY?: number | undefined;
16652
- voltage?: number | undefined;
16653
- frequency?: number | undefined;
16654
- pcbStyle?: {
16655
- silkscreenFontSize?: number | undefined;
16656
- silkscreenTextPosition?: "centered" | "outside" | "none" | {
16657
- offsetX: number;
16658
- offsetY: number;
16659
- } | undefined;
16660
- silkscreenTextVisibility?: "hidden" | "visible" | "inherit" | undefined;
16661
- } | undefined;
16662
- pcbPositionAnchor?: string | undefined;
16663
16652
  pcbOffsetX?: number | undefined;
16664
16653
  pcbOffsetY?: number | undefined;
16654
+ pcbPositionAnchor?: string | undefined;
16665
16655
  pcbPositionMode?: "auto" | "relative_to_group_anchor" | "relative_to_board_anchor" | "relative_to_component_anchor" | undefined;
16666
16656
  pcbMarginTop?: number | undefined;
16667
16657
  pcbMarginRight?: number | undefined;
@@ -16669,6 +16659,14 @@ declare const voltageSourceProps: z.ZodObject<{
16669
16659
  pcbMarginLeft?: number | undefined;
16670
16660
  pcbMarginX?: number | undefined;
16671
16661
  pcbMarginY?: number | undefined;
16662
+ pcbStyle?: {
16663
+ silkscreenFontSize?: number | undefined;
16664
+ silkscreenTextPosition?: "centered" | "outside" | "none" | {
16665
+ offsetX: number;
16666
+ offsetY: number;
16667
+ } | undefined;
16668
+ silkscreenTextVisibility?: "hidden" | "visible" | "inherit" | undefined;
16669
+ } | undefined;
16672
16670
  schMarginTop?: number | undefined;
16673
16671
  schMarginRight?: number | undefined;
16674
16672
  schMarginBottom?: number | undefined;
@@ -16678,6 +16676,7 @@ declare const voltageSourceProps: z.ZodObject<{
16678
16676
  schRotation?: number | undefined;
16679
16677
  schRelative?: boolean | undefined;
16680
16678
  pcbRelative?: boolean | undefined;
16679
+ supplierPartNumbers?: Partial<Record<"jlcpcb" | "macrofab" | "pcbway" | "digikey" | "mouser" | "lcsc", string[]>> | undefined;
16681
16680
  cadModel?: string | react.ReactElement<any, string | react.JSXElementConstructor<any>> | {
16682
16681
  stlUrl: string;
16683
16682
  rotationOffset?: number | {
@@ -16813,6 +16812,9 @@ declare const voltageSourceProps: z.ZodObject<{
16813
16812
  modelUnitToMmScale?: number | undefined;
16814
16813
  zOffsetFromSurface?: number | undefined;
16815
16814
  } | null | undefined;
16815
+ symbolName?: string | undefined;
16816
+ doNotPlace?: boolean | undefined;
16817
+ obstructsWithinBounds?: boolean | undefined;
16816
16818
  pinAttributes?: Record<string, {
16817
16819
  providesPower?: boolean | undefined;
16818
16820
  requiresPower?: boolean | undefined;
@@ -16824,13 +16826,11 @@ declare const voltageSourceProps: z.ZodObject<{
16824
16826
  includeInBoardPinout?: boolean | undefined;
16825
16827
  highlightColor?: string | undefined;
16826
16828
  }> | undefined;
16829
+ voltage?: number | undefined;
16830
+ frequency?: number | undefined;
16827
16831
  peakToPeakVoltage?: number | undefined;
16828
16832
  waveShape?: "square" | "sinewave" | "triangle" | "sawtooth" | undefined;
16829
16833
  dutyCycle?: number | undefined;
16830
- supplierPartNumbers?: Partial<Record<"jlcpcb" | "macrofab" | "pcbway" | "digikey" | "mouser" | "lcsc", string[]>> | undefined;
16831
- symbolName?: string | undefined;
16832
- doNotPlace?: boolean | undefined;
16833
- obstructsWithinBounds?: boolean | undefined;
16834
16834
  }, {
16835
16835
  name: string;
16836
16836
  symbol?: _tscircuit_props.SymbolProp | undefined;
@@ -16847,19 +16847,9 @@ declare const voltageSourceProps: z.ZodObject<{
16847
16847
  schY?: string | number | undefined;
16848
16848
  pcbX?: string | number | undefined;
16849
16849
  pcbY?: string | number | undefined;
16850
- voltage?: string | number | undefined;
16851
- frequency?: string | number | undefined;
16852
- pcbStyle?: {
16853
- silkscreenFontSize?: string | number | undefined;
16854
- silkscreenTextPosition?: "centered" | "outside" | "none" | {
16855
- offsetX: number;
16856
- offsetY: number;
16857
- } | undefined;
16858
- silkscreenTextVisibility?: "hidden" | "visible" | "inherit" | undefined;
16859
- } | undefined;
16860
- pcbPositionAnchor?: string | undefined;
16861
16850
  pcbOffsetX?: string | number | undefined;
16862
16851
  pcbOffsetY?: string | number | undefined;
16852
+ pcbPositionAnchor?: string | undefined;
16863
16853
  pcbPositionMode?: "auto" | "relative_to_group_anchor" | "relative_to_board_anchor" | "relative_to_component_anchor" | undefined;
16864
16854
  pcbMarginTop?: string | number | undefined;
16865
16855
  pcbMarginRight?: string | number | undefined;
@@ -16867,6 +16857,14 @@ declare const voltageSourceProps: z.ZodObject<{
16867
16857
  pcbMarginLeft?: string | number | undefined;
16868
16858
  pcbMarginX?: string | number | undefined;
16869
16859
  pcbMarginY?: string | number | undefined;
16860
+ pcbStyle?: {
16861
+ silkscreenFontSize?: string | number | undefined;
16862
+ silkscreenTextPosition?: "centered" | "outside" | "none" | {
16863
+ offsetX: number;
16864
+ offsetY: number;
16865
+ } | undefined;
16866
+ silkscreenTextVisibility?: "hidden" | "visible" | "inherit" | undefined;
16867
+ } | undefined;
16870
16868
  schMarginTop?: string | number | undefined;
16871
16869
  schMarginRight?: string | number | undefined;
16872
16870
  schMarginBottom?: string | number | undefined;
@@ -16876,6 +16874,7 @@ declare const voltageSourceProps: z.ZodObject<{
16876
16874
  schRotation?: string | number | undefined;
16877
16875
  schRelative?: boolean | undefined;
16878
16876
  pcbRelative?: boolean | undefined;
16877
+ supplierPartNumbers?: Partial<Record<"jlcpcb" | "macrofab" | "pcbway" | "digikey" | "mouser" | "lcsc", string[]>> | undefined;
16879
16878
  cadModel?: string | react.ReactElement<any, string | react.JSXElementConstructor<any>> | {
16880
16879
  stlUrl: string;
16881
16880
  rotationOffset?: number | {
@@ -17011,6 +17010,9 @@ declare const voltageSourceProps: z.ZodObject<{
17011
17010
  modelUnitToMmScale?: string | number | undefined;
17012
17011
  zOffsetFromSurface?: string | number | undefined;
17013
17012
  } | null | undefined;
17013
+ symbolName?: string | undefined;
17014
+ doNotPlace?: boolean | undefined;
17015
+ obstructsWithinBounds?: boolean | undefined;
17014
17016
  pinAttributes?: Record<string, {
17015
17017
  providesPower?: boolean | undefined;
17016
17018
  requiresPower?: boolean | undefined;
@@ -17022,13 +17024,11 @@ declare const voltageSourceProps: z.ZodObject<{
17022
17024
  includeInBoardPinout?: boolean | undefined;
17023
17025
  highlightColor?: string | undefined;
17024
17026
  }> | undefined;
17027
+ voltage?: string | number | undefined;
17028
+ frequency?: string | number | undefined;
17025
17029
  peakToPeakVoltage?: string | number | undefined;
17026
17030
  waveShape?: "square" | "sinewave" | "triangle" | "sawtooth" | undefined;
17027
17031
  dutyCycle?: number | undefined;
17028
- supplierPartNumbers?: Partial<Record<"jlcpcb" | "macrofab" | "pcbway" | "digikey" | "mouser" | "lcsc", string[]>> | undefined;
17029
- symbolName?: string | undefined;
17030
- doNotPlace?: boolean | undefined;
17031
- obstructsWithinBounds?: boolean | undefined;
17032
17032
  }>;
17033
17033
  declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "terminal1" | "terminal2"> {
17034
17034
  get config(): {
@@ -17738,19 +17738,9 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
17738
17738
  schY?: number | undefined;
17739
17739
  pcbX?: number | undefined;
17740
17740
  pcbY?: number | undefined;
17741
- voltage?: number | undefined;
17742
- frequency?: number | undefined;
17743
- pcbStyle?: {
17744
- silkscreenFontSize?: number | undefined;
17745
- silkscreenTextPosition?: "centered" | "outside" | "none" | {
17746
- offsetX: number;
17747
- offsetY: number;
17748
- } | undefined;
17749
- silkscreenTextVisibility?: "hidden" | "visible" | "inherit" | undefined;
17750
- } | undefined;
17751
- pcbPositionAnchor?: string | undefined;
17752
17741
  pcbOffsetX?: number | undefined;
17753
17742
  pcbOffsetY?: number | undefined;
17743
+ pcbPositionAnchor?: string | undefined;
17754
17744
  pcbPositionMode?: "auto" | "relative_to_group_anchor" | "relative_to_board_anchor" | "relative_to_component_anchor" | undefined;
17755
17745
  pcbMarginTop?: number | undefined;
17756
17746
  pcbMarginRight?: number | undefined;
@@ -17758,6 +17748,14 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
17758
17748
  pcbMarginLeft?: number | undefined;
17759
17749
  pcbMarginX?: number | undefined;
17760
17750
  pcbMarginY?: number | undefined;
17751
+ pcbStyle?: {
17752
+ silkscreenFontSize?: number | undefined;
17753
+ silkscreenTextPosition?: "centered" | "outside" | "none" | {
17754
+ offsetX: number;
17755
+ offsetY: number;
17756
+ } | undefined;
17757
+ silkscreenTextVisibility?: "hidden" | "visible" | "inherit" | undefined;
17758
+ } | undefined;
17761
17759
  schMarginTop?: number | undefined;
17762
17760
  schMarginRight?: number | undefined;
17763
17761
  schMarginBottom?: number | undefined;
@@ -17767,6 +17765,7 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
17767
17765
  schRotation?: number | undefined;
17768
17766
  schRelative?: boolean | undefined;
17769
17767
  pcbRelative?: boolean | undefined;
17768
+ supplierPartNumbers?: Partial<Record<"jlcpcb" | "macrofab" | "pcbway" | "digikey" | "mouser" | "lcsc", string[]>> | undefined;
17770
17769
  cadModel?: string | react.ReactElement<any, string | react.JSXElementConstructor<any>> | {
17771
17770
  stlUrl: string;
17772
17771
  rotationOffset?: number | {
@@ -17902,6 +17901,9 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
17902
17901
  modelUnitToMmScale?: number | undefined;
17903
17902
  zOffsetFromSurface?: number | undefined;
17904
17903
  } | null | undefined;
17904
+ symbolName?: string | undefined;
17905
+ doNotPlace?: boolean | undefined;
17906
+ obstructsWithinBounds?: boolean | undefined;
17905
17907
  pinAttributes?: Record<string, {
17906
17908
  providesPower?: boolean | undefined;
17907
17909
  requiresPower?: boolean | undefined;
@@ -17913,13 +17915,11 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
17913
17915
  includeInBoardPinout?: boolean | undefined;
17914
17916
  highlightColor?: string | undefined;
17915
17917
  }> | undefined;
17918
+ voltage?: number | undefined;
17919
+ frequency?: number | undefined;
17916
17920
  peakToPeakVoltage?: number | undefined;
17917
17921
  waveShape?: "square" | "sinewave" | "triangle" | "sawtooth" | undefined;
17918
17922
  dutyCycle?: number | undefined;
17919
- supplierPartNumbers?: Partial<Record<"jlcpcb" | "macrofab" | "pcbway" | "digikey" | "mouser" | "lcsc", string[]>> | undefined;
17920
- symbolName?: string | undefined;
17921
- doNotPlace?: boolean | undefined;
17922
- obstructsWithinBounds?: boolean | undefined;
17923
17923
  }, {
17924
17924
  name: string;
17925
17925
  symbol?: _tscircuit_props.SymbolProp | undefined;
@@ -17936,19 +17936,9 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
17936
17936
  schY?: string | number | undefined;
17937
17937
  pcbX?: string | number | undefined;
17938
17938
  pcbY?: string | number | undefined;
17939
- voltage?: string | number | undefined;
17940
- frequency?: string | number | undefined;
17941
- pcbStyle?: {
17942
- silkscreenFontSize?: string | number | undefined;
17943
- silkscreenTextPosition?: "centered" | "outside" | "none" | {
17944
- offsetX: number;
17945
- offsetY: number;
17946
- } | undefined;
17947
- silkscreenTextVisibility?: "hidden" | "visible" | "inherit" | undefined;
17948
- } | undefined;
17949
- pcbPositionAnchor?: string | undefined;
17950
17939
  pcbOffsetX?: string | number | undefined;
17951
17940
  pcbOffsetY?: string | number | undefined;
17941
+ pcbPositionAnchor?: string | undefined;
17952
17942
  pcbPositionMode?: "auto" | "relative_to_group_anchor" | "relative_to_board_anchor" | "relative_to_component_anchor" | undefined;
17953
17943
  pcbMarginTop?: string | number | undefined;
17954
17944
  pcbMarginRight?: string | number | undefined;
@@ -17956,6 +17946,14 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
17956
17946
  pcbMarginLeft?: string | number | undefined;
17957
17947
  pcbMarginX?: string | number | undefined;
17958
17948
  pcbMarginY?: string | number | undefined;
17949
+ pcbStyle?: {
17950
+ silkscreenFontSize?: string | number | undefined;
17951
+ silkscreenTextPosition?: "centered" | "outside" | "none" | {
17952
+ offsetX: number;
17953
+ offsetY: number;
17954
+ } | undefined;
17955
+ silkscreenTextVisibility?: "hidden" | "visible" | "inherit" | undefined;
17956
+ } | undefined;
17959
17957
  schMarginTop?: string | number | undefined;
17960
17958
  schMarginRight?: string | number | undefined;
17961
17959
  schMarginBottom?: string | number | undefined;
@@ -17965,6 +17963,7 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
17965
17963
  schRotation?: string | number | undefined;
17966
17964
  schRelative?: boolean | undefined;
17967
17965
  pcbRelative?: boolean | undefined;
17966
+ supplierPartNumbers?: Partial<Record<"jlcpcb" | "macrofab" | "pcbway" | "digikey" | "mouser" | "lcsc", string[]>> | undefined;
17968
17967
  cadModel?: string | react.ReactElement<any, string | react.JSXElementConstructor<any>> | {
17969
17968
  stlUrl: string;
17970
17969
  rotationOffset?: number | {
@@ -18100,6 +18099,9 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
18100
18099
  modelUnitToMmScale?: string | number | undefined;
18101
18100
  zOffsetFromSurface?: string | number | undefined;
18102
18101
  } | null | undefined;
18102
+ symbolName?: string | undefined;
18103
+ doNotPlace?: boolean | undefined;
18104
+ obstructsWithinBounds?: boolean | undefined;
18103
18105
  pinAttributes?: Record<string, {
18104
18106
  providesPower?: boolean | undefined;
18105
18107
  requiresPower?: boolean | undefined;
@@ -18111,13 +18113,11 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
18111
18113
  includeInBoardPinout?: boolean | undefined;
18112
18114
  highlightColor?: string | undefined;
18113
18115
  }> | undefined;
18116
+ voltage?: string | number | undefined;
18117
+ frequency?: string | number | undefined;
18114
18118
  peakToPeakVoltage?: string | number | undefined;
18115
18119
  waveShape?: "square" | "sinewave" | "triangle" | "sawtooth" | undefined;
18116
18120
  dutyCycle?: number | undefined;
18117
- supplierPartNumbers?: Partial<Record<"jlcpcb" | "macrofab" | "pcbway" | "digikey" | "mouser" | "lcsc", string[]>> | undefined;
18118
- symbolName?: string | undefined;
18119
- doNotPlace?: boolean | undefined;
18120
- obstructsWithinBounds?: boolean | undefined;
18121
18121
  }>;
18122
18122
  sourceFtype: Ftype;
18123
18123
  };
@@ -39158,6 +39158,9 @@ declare class AnalogSimulation extends PrimitiveComponent<typeof analogSimulatio
39158
39158
 
39159
39159
  declare class VoltageProbe extends PrimitiveComponent<typeof voltageProbeProps> {
39160
39160
  simulation_voltage_probe_id: string | null;
39161
+ schematic_voltage_probe_id: string | null;
39162
+ finalProbeName: string | null;
39163
+ color: string | null;
39161
39164
  get config(): {
39162
39165
  componentName: string;
39163
39166
  zodProps: z.ZodObject<Omit<{
@@ -40233,6 +40236,7 @@ declare class VoltageProbe extends PrimitiveComponent<typeof voltageProbeProps>
40233
40236
  }>;
40234
40237
  };
40235
40238
  doInitialSimulationRender(): void;
40239
+ doInitialSchematicReplaceNetLabelsWithSymbols(): void;
40236
40240
  }
40237
40241
 
40238
40242
  declare const useRenderedCircuit: (reactElements: react__default.ReactElement) => {
package/dist/index.js CHANGED
@@ -12918,6 +12918,42 @@ var getSpiceyEngine = () => {
12918
12918
  };
12919
12919
  };
12920
12920
 
12921
+ // lib/utils/simulation/getSimulationColorForId.ts
12922
+ var SIMULATION_COLOR_PALETTE = [
12923
+ "rgb(132, 0, 0)",
12924
+ "rgb(194, 194, 0)",
12925
+ "rgb(194, 0, 194)",
12926
+ "rgb(194, 0, 0)",
12927
+ "rgb(0, 132, 132)",
12928
+ "rgb(0, 132, 0)",
12929
+ "rgb(0, 0, 132)",
12930
+ "rgb(132, 132, 132)",
12931
+ "rgb(132, 0, 132)",
12932
+ "rgb(194, 194, 194)",
12933
+ "rgb(132, 0, 132)",
12934
+ "rgb(132, 0, 0)",
12935
+ "rgb(132, 132, 0)",
12936
+ "rgb(194, 194, 194)",
12937
+ "rgb(0, 0, 132)",
12938
+ "rgb(0, 132, 0)"
12939
+ ];
12940
+ var idToColorMap = /* @__PURE__ */ new Map();
12941
+ var colorIndex = 0;
12942
+ function getSimulationColorForId(id) {
12943
+ if (idToColorMap.has(id)) {
12944
+ const color2 = idToColorMap.get(id);
12945
+ return color2;
12946
+ }
12947
+ const color = SIMULATION_COLOR_PALETTE[colorIndex];
12948
+ colorIndex = (colorIndex + 1) % SIMULATION_COLOR_PALETTE.length;
12949
+ idToColorMap.set(id, color);
12950
+ return color;
12951
+ }
12952
+ function resetSimulationColorState() {
12953
+ idToColorMap.clear();
12954
+ colorIndex = 0;
12955
+ }
12956
+
12921
12957
  // lib/components/primitive-components/Group/Group_doInitialSimulationSpiceEngineRender.ts
12922
12958
  var debug10 = Debug12("tscircuit:core:Group_doInitialSimulationSpiceEngineRender");
12923
12959
  function Group_doInitialSimulationSpiceEngineRender(group) {
@@ -12926,14 +12962,17 @@ function Group_doInitialSimulationSpiceEngineRender(group) {
12926
12962
  if (!root) return;
12927
12963
  const analogSims = group.selectAll("analogsimulation");
12928
12964
  if (analogSims.length === 0) return;
12965
+ const voltageProbes = group.selectAll("voltageprobe");
12966
+ resetSimulationColorState();
12929
12967
  const spiceEngineMap = { ...root.platform?.spiceEngineMap };
12930
12968
  if (!spiceEngineMap.spicey) {
12931
12969
  spiceEngineMap.spicey = getSpiceyEngine();
12932
12970
  }
12933
12971
  const circuitJson = root.db.toArray();
12934
12972
  let spiceString;
12973
+ let spiceNetlist;
12935
12974
  try {
12936
- const spiceNetlist = circuitJsonToSpice(circuitJson);
12975
+ spiceNetlist = circuitJsonToSpice(circuitJson);
12937
12976
  spiceString = spiceNetlist.toSpiceString();
12938
12977
  debug10(`Generated SPICE string:
12939
12978
  ${spiceString}`);
@@ -12970,6 +13009,10 @@ ${spiceString}`);
12970
13009
  for (const element of result.simulationResultCircuitJson) {
12971
13010
  if (element.type === "simulation_transient_voltage_graph") {
12972
13011
  element.simulation_experiment_id = simulationExperiment.simulation_experiment_id;
13012
+ const probeMatch = voltageProbes.find(
13013
+ (p) => p.finalProbeName === element.name
13014
+ );
13015
+ if (probeMatch) element.color = probeMatch.color;
12973
13016
  }
12974
13017
  const elementType = element.type;
12975
13018
  if (elementType && root.db[elementType]) {
@@ -16082,6 +16125,78 @@ function inflateSourceTrace(sourceTrace, inflatorContext) {
16082
16125
  subcircuit.add(trace);
16083
16126
  }
16084
16127
 
16128
+ // lib/components/normal-components/Transistor.ts
16129
+ import { transistorProps } from "@tscircuit/props";
16130
+ var Transistor = class extends NormalComponent3 {
16131
+ get config() {
16132
+ const baseSymbolName = this.props.type === "npn" ? "npn_bipolar_transistor" : "pnp_bipolar_transistor";
16133
+ return {
16134
+ componentName: "Transistor",
16135
+ schematicSymbolName: this.props.symbolName ?? baseSymbolName,
16136
+ zodProps: transistorProps,
16137
+ sourceFtype: "simple_transistor",
16138
+ shouldRenderAsSchematicBox: false
16139
+ };
16140
+ }
16141
+ initPorts() {
16142
+ const pinAliases = {
16143
+ pin1: ["collector", "c"],
16144
+ pin2: ["emitter", "e"],
16145
+ pin3: ["base", "b"]
16146
+ };
16147
+ super.initPorts({
16148
+ pinCount: 3,
16149
+ additionalAliases: pinAliases
16150
+ });
16151
+ }
16152
+ emitter = this.portMap.pin1;
16153
+ collector = this.portMap.pin2;
16154
+ base = this.portMap.pin3;
16155
+ doInitialCreateNetsFromProps() {
16156
+ this._createNetsFromProps([...this._getNetsFromConnectionsProp()]);
16157
+ }
16158
+ doInitialCreateTracesFromProps() {
16159
+ this._createTracesFromConnectionsProp();
16160
+ }
16161
+ doInitialSourceRender() {
16162
+ const { db } = this.root;
16163
+ const { _parsedProps: props } = this;
16164
+ const source_component = db.source_component.insert({
16165
+ ftype: "simple_transistor",
16166
+ name: this.name,
16167
+ transistor_type: props.type
16168
+ });
16169
+ this.source_component_id = source_component.source_component_id;
16170
+ }
16171
+ };
16172
+
16173
+ // lib/components/primitive-components/Group/Subcircuit/inflators/inflateSourceTransistor.ts
16174
+ function inflateSourceTransistor(sourceElm, inflatorContext) {
16175
+ const { injectionDb, subcircuit, groupsMap } = inflatorContext;
16176
+ const pcbElm = injectionDb.pcb_component.getWhere({
16177
+ source_component_id: sourceElm.source_component_id
16178
+ });
16179
+ const cadElm = injectionDb.cad_component.getWhere({
16180
+ source_component_id: sourceElm.source_component_id
16181
+ });
16182
+ const transistor = new Transistor({
16183
+ name: sourceElm.name,
16184
+ type: sourceElm.transistor_type
16185
+ });
16186
+ if (pcbElm) {
16187
+ inflatePcbComponent(pcbElm, {
16188
+ ...inflatorContext,
16189
+ normalComponent: transistor
16190
+ });
16191
+ }
16192
+ if (sourceElm.source_group_id && groupsMap?.has(sourceElm.source_group_id)) {
16193
+ const group = groupsMap.get(sourceElm.source_group_id);
16194
+ group.add(transistor);
16195
+ } else {
16196
+ subcircuit.add(transistor);
16197
+ }
16198
+ }
16199
+
16085
16200
  // lib/components/primitive-components/Group/Subcircuit/Subcircuit.ts
16086
16201
  var Subcircuit = class extends Group6 {
16087
16202
  constructor(props) {
@@ -16139,6 +16254,9 @@ var Subcircuit = class extends Group6 {
16139
16254
  case "simple_chip":
16140
16255
  inflateSourceChip(sourceComponent, inflationCtx);
16141
16256
  break;
16257
+ case "simple_transistor":
16258
+ inflateSourceTransistor(sourceComponent, inflationCtx);
16259
+ break;
16142
16260
  default:
16143
16261
  throw new Error(
16144
16262
  `No inflator implemented for source component ftype: "${sourceComponent.ftype}"`
@@ -17141,51 +17259,6 @@ var Crystal = class extends NormalComponent3 {
17141
17259
  }
17142
17260
  };
17143
17261
 
17144
- // lib/components/normal-components/Transistor.ts
17145
- import { transistorProps } from "@tscircuit/props";
17146
- var Transistor = class extends NormalComponent3 {
17147
- get config() {
17148
- const baseSymbolName = this.props.type === "npn" ? "npn_bipolar_transistor" : "pnp_bipolar_transistor";
17149
- return {
17150
- componentName: "Transistor",
17151
- schematicSymbolName: this.props.symbolName ?? baseSymbolName,
17152
- zodProps: transistorProps,
17153
- sourceFtype: "simple_transistor",
17154
- shouldRenderAsSchematicBox: false
17155
- };
17156
- }
17157
- initPorts() {
17158
- const pinAliases = {
17159
- pin1: ["collector", "c"],
17160
- pin2: ["emitter", "e"],
17161
- pin3: ["base", "b"]
17162
- };
17163
- super.initPorts({
17164
- pinCount: 3,
17165
- additionalAliases: pinAliases
17166
- });
17167
- }
17168
- emitter = this.portMap.pin1;
17169
- collector = this.portMap.pin2;
17170
- base = this.portMap.pin3;
17171
- doInitialCreateNetsFromProps() {
17172
- this._createNetsFromProps([...this._getNetsFromConnectionsProp()]);
17173
- }
17174
- doInitialCreateTracesFromProps() {
17175
- this._createTracesFromConnectionsProp();
17176
- }
17177
- doInitialSourceRender() {
17178
- const { db } = this.root;
17179
- const { _parsedProps: props } = this;
17180
- const source_component = db.source_component.insert({
17181
- ftype: "simple_transistor",
17182
- name: this.name,
17183
- transistor_type: props.type
17184
- });
17185
- this.source_component_id = source_component.source_component_id;
17186
- }
17187
- };
17188
-
17189
17262
  // lib/components/normal-components/Mosfet.ts
17190
17263
  import { mosfetProps } from "@tscircuit/props";
17191
17264
  var Mosfet = class extends NormalComponent3 {
@@ -17947,6 +18020,9 @@ import { voltageProbeProps } from "@tscircuit/props";
17947
18020
  import "zod";
17948
18021
  var VoltageProbe = class extends PrimitiveComponent2 {
17949
18022
  simulation_voltage_probe_id = null;
18023
+ schematic_voltage_probe_id = null;
18024
+ finalProbeName = null;
18025
+ color = null;
17950
18026
  get config() {
17951
18027
  return {
17952
18028
  componentName: "VoltageProbe",
@@ -17983,14 +18059,68 @@ var VoltageProbe = class extends PrimitiveComponent2 {
17983
18059
  );
17984
18060
  return;
17985
18061
  }
18062
+ const connectedId = port?.source_port_id ?? net?.source_net_id;
18063
+ if (!connectedId) {
18064
+ this.renderError(`Could not identify connected source for VoltageProbe`);
18065
+ return;
18066
+ }
18067
+ this.color = getSimulationColorForId(connectedId);
18068
+ let finalName = name;
18069
+ if (!finalName) {
18070
+ finalName = targets[0].split(" > ").map((s) => s.replace(/^\./, "")).join(".");
18071
+ }
18072
+ this.finalProbeName = finalName;
17986
18073
  const { simulation_voltage_probe_id } = db.simulation_voltage_probe.insert({
17987
- name: name ?? this.name,
18074
+ name: finalName,
17988
18075
  source_port_id: port?.source_port_id ?? void 0,
17989
18076
  source_net_id: net?.source_net_id ?? void 0,
17990
- subcircuit_id: subcircuit.subcircuit_id || void 0
18077
+ subcircuit_id: subcircuit.subcircuit_id || void 0,
18078
+ color: this.color
17991
18079
  });
17992
18080
  this.simulation_voltage_probe_id = simulation_voltage_probe_id;
17993
18081
  }
18082
+ doInitialSchematicReplaceNetLabelsWithSymbols() {
18083
+ if (this.root?.schematicDisabled) return;
18084
+ const { db } = this.root;
18085
+ const { connectsTo, name } = this._parsedProps;
18086
+ const subcircuit = this.getSubcircuit();
18087
+ if (!subcircuit) {
18088
+ return;
18089
+ }
18090
+ const targets = Array.isArray(connectsTo) ? connectsTo : [connectsTo];
18091
+ if (targets.length !== 1) {
18092
+ return;
18093
+ }
18094
+ const targetSelector = targets[0];
18095
+ const port = subcircuit.selectOne(targetSelector, {
18096
+ type: "port"
18097
+ });
18098
+ if (!port) return;
18099
+ if (!port.schematic_port_id) return;
18100
+ const position = port._getGlobalSchematicPositionAfterLayout();
18101
+ let targetTraceId = null;
18102
+ for (const trace of db.schematic_trace.list()) {
18103
+ for (const edge of trace.edges) {
18104
+ if (Math.abs(edge.from.x - position.x) < 1e-6 && Math.abs(edge.from.y - position.y) < 1e-6 || Math.abs(edge.to.x - position.x) < 1e-6 && Math.abs(edge.to.y - position.y) < 1e-6) {
18105
+ targetTraceId = trace.schematic_trace_id;
18106
+ break;
18107
+ }
18108
+ }
18109
+ if (targetTraceId) break;
18110
+ }
18111
+ if (!targetTraceId) {
18112
+ return;
18113
+ }
18114
+ const probeName = this.finalProbeName;
18115
+ const schematic_voltage_probe = db.schematic_voltage_probe.insert({
18116
+ name: probeName,
18117
+ position,
18118
+ schematic_trace_id: targetTraceId,
18119
+ subcircuit_id: subcircuit.subcircuit_id || void 0,
18120
+ color: this.color ?? void 0
18121
+ });
18122
+ this.schematic_voltage_probe_id = schematic_voltage_probe.schematic_voltage_probe_id;
18123
+ }
17994
18124
  };
17995
18125
 
17996
18126
  // lib/RootCircuit.ts
@@ -18002,7 +18132,7 @@ import { identity as identity6 } from "transformation-matrix";
18002
18132
  var package_default = {
18003
18133
  name: "@tscircuit/core",
18004
18134
  type: "module",
18005
- version: "0.0.866",
18135
+ version: "0.0.868",
18006
18136
  types: "dist/index.d.ts",
18007
18137
  main: "dist/index.js",
18008
18138
  module: "dist/index.js",
@@ -18045,7 +18175,7 @@ var package_default = {
18045
18175
  "@tscircuit/matchpack": "^0.0.16",
18046
18176
  "@tscircuit/math-utils": "^0.0.29",
18047
18177
  "@tscircuit/miniflex": "^0.0.4",
18048
- "@tscircuit/ngspice-spice-engine": "^0.0.2",
18178
+ "@tscircuit/ngspice-spice-engine": "^0.0.3",
18049
18179
  "@tscircuit/props": "^0.0.403",
18050
18180
  "@tscircuit/schematic-autolayout": "^0.0.6",
18051
18181
  "@tscircuit/schematic-match-adapt": "^0.0.16",
@@ -18060,13 +18190,13 @@ var package_default = {
18060
18190
  "bun-match-svg": "0.0.12",
18061
18191
  "calculate-elbow": "^0.0.12",
18062
18192
  "chokidar-cli": "^3.0.0",
18063
- "circuit-json": "^0.0.308",
18193
+ "circuit-json": "^0.0.316",
18064
18194
  "circuit-json-to-bpc": "^0.0.13",
18065
18195
  "circuit-json-to-connectivity-map": "^0.0.22",
18066
18196
  "circuit-json-to-gltf": "^0.0.31",
18067
18197
  "circuit-json-to-simple-3d": "^0.0.9",
18068
- "circuit-json-to-spice": "^0.0.16",
18069
- "circuit-to-svg": "^0.0.269",
18198
+ "circuit-json-to-spice": "^0.0.24",
18199
+ "circuit-to-svg": "^0.0.271",
18070
18200
  concurrently: "^9.1.2",
18071
18201
  "connectivity-map": "^1.0.0",
18072
18202
  debug: "^4.3.6",
@@ -18082,7 +18212,7 @@ var package_default = {
18082
18212
  react: "^19.1.0",
18083
18213
  "react-dom": "^19.1.0",
18084
18214
  "schematic-symbols": "^0.0.202",
18085
- spicey: "^0.0.10",
18215
+ spicey: "^0.0.14",
18086
18216
  "ts-expect": "^1.3.0",
18087
18217
  tsup: "^8.2.4"
18088
18218
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.867",
4
+ "version": "0.0.869",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -44,7 +44,7 @@
44
44
  "@tscircuit/matchpack": "^0.0.16",
45
45
  "@tscircuit/math-utils": "^0.0.29",
46
46
  "@tscircuit/miniflex": "^0.0.4",
47
- "@tscircuit/ngspice-spice-engine": "^0.0.2",
47
+ "@tscircuit/ngspice-spice-engine": "^0.0.3",
48
48
  "@tscircuit/props": "^0.0.403",
49
49
  "@tscircuit/schematic-autolayout": "^0.0.6",
50
50
  "@tscircuit/schematic-match-adapt": "^0.0.16",
@@ -59,13 +59,13 @@
59
59
  "bun-match-svg": "0.0.12",
60
60
  "calculate-elbow": "^0.0.12",
61
61
  "chokidar-cli": "^3.0.0",
62
- "circuit-json": "^0.0.308",
62
+ "circuit-json": "^0.0.316",
63
63
  "circuit-json-to-bpc": "^0.0.13",
64
64
  "circuit-json-to-connectivity-map": "^0.0.22",
65
65
  "circuit-json-to-gltf": "^0.0.31",
66
66
  "circuit-json-to-simple-3d": "^0.0.9",
67
- "circuit-json-to-spice": "^0.0.16",
68
- "circuit-to-svg": "^0.0.269",
67
+ "circuit-json-to-spice": "^0.0.24",
68
+ "circuit-to-svg": "^0.0.271",
69
69
  "concurrently": "^9.1.2",
70
70
  "connectivity-map": "^1.0.0",
71
71
  "debug": "^4.3.6",
@@ -81,7 +81,7 @@
81
81
  "react": "^19.1.0",
82
82
  "react-dom": "^19.1.0",
83
83
  "schematic-symbols": "^0.0.202",
84
- "spicey": "^0.0.10",
84
+ "spicey": "^0.0.14",
85
85
  "ts-expect": "^1.3.0",
86
86
  "tsup": "^8.2.4"
87
87
  },