@tscircuit/core 0.0.1351 → 0.0.1352
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.js +77 -63
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -20550,24 +20550,19 @@ var Group_doInitialSchematicTraceRender = (group) => {
|
|
|
20550
20550
|
import { circuitJsonToSpice } from "circuit-json-to-spice";
|
|
20551
20551
|
import Debug13 from "debug";
|
|
20552
20552
|
|
|
20553
|
-
// lib/
|
|
20554
|
-
|
|
20555
|
-
|
|
20556
|
-
|
|
20557
|
-
|
|
20558
|
-
|
|
20559
|
-
|
|
20560
|
-
const
|
|
20561
|
-
|
|
20562
|
-
parsedCircuit,
|
|
20563
|
-
simulation_experiment_id
|
|
20564
|
-
);
|
|
20565
|
-
return {
|
|
20566
|
-
simulationResultCircuitJson: voltageGraphs
|
|
20567
|
-
};
|
|
20553
|
+
// lib/utils/simulation/get-transient-voltage-graph-names-from-spice-netlist.ts
|
|
20554
|
+
function getTransientVoltageGraphNamesFromSpiceNetlist(spiceNetlist) {
|
|
20555
|
+
const graphNames = [];
|
|
20556
|
+
for (const printStatement of spiceNetlist.printStatements) {
|
|
20557
|
+
const match = printStatement.match(/^\.PRINT\s+TRAN\s+(.+)$/i);
|
|
20558
|
+
if (!match) continue;
|
|
20559
|
+
for (const voltageExpression of match[1].match(/V\(([^)]+)\)/g) ?? []) {
|
|
20560
|
+
const nodeList = voltageExpression.slice(2, -1);
|
|
20561
|
+
graphNames.push(nodeList.replace(",", "-"));
|
|
20568
20562
|
}
|
|
20569
|
-
}
|
|
20570
|
-
|
|
20563
|
+
}
|
|
20564
|
+
return graphNames;
|
|
20565
|
+
}
|
|
20571
20566
|
|
|
20572
20567
|
// lib/utils/simulation/getSimulationColorForId.ts
|
|
20573
20568
|
var SIMULATION_COLOR_PALETTE = [
|
|
@@ -20606,19 +20601,24 @@ function resetSimulationColorState() {
|
|
|
20606
20601
|
colorIndex = 0;
|
|
20607
20602
|
}
|
|
20608
20603
|
|
|
20609
|
-
// lib/
|
|
20610
|
-
|
|
20611
|
-
|
|
20612
|
-
|
|
20613
|
-
|
|
20614
|
-
|
|
20615
|
-
|
|
20616
|
-
const
|
|
20617
|
-
|
|
20604
|
+
// lib/spice/get-spicey-engine.ts
|
|
20605
|
+
import { simulate, spiceyTranToVGraphs } from "spicey";
|
|
20606
|
+
var getSpiceyEngine = () => {
|
|
20607
|
+
return {
|
|
20608
|
+
async simulate(spiceString) {
|
|
20609
|
+
const simulation_experiment_id = "spice-experiment-1";
|
|
20610
|
+
const { circuit: parsedCircuit, tran } = simulate(spiceString);
|
|
20611
|
+
const voltageGraphs = spiceyTranToVGraphs(
|
|
20612
|
+
tran,
|
|
20613
|
+
parsedCircuit,
|
|
20614
|
+
simulation_experiment_id
|
|
20615
|
+
);
|
|
20616
|
+
return {
|
|
20617
|
+
simulationResultCircuitJson: voltageGraphs
|
|
20618
|
+
};
|
|
20618
20619
|
}
|
|
20619
|
-
}
|
|
20620
|
-
|
|
20621
|
-
}
|
|
20620
|
+
};
|
|
20621
|
+
};
|
|
20622
20622
|
|
|
20623
20623
|
// lib/components/primitive-components/Group/Group_doInitialSimulationSpiceEngineRender.ts
|
|
20624
20624
|
var debug11 = Debug13("tscircuit:core:Group_doInitialSimulationSpiceEngineRender");
|
|
@@ -20658,6 +20658,9 @@ ${spiceString}`);
|
|
|
20658
20658
|
const currentProbesById = new Map(
|
|
20659
20659
|
root.db.simulation_current_probe.list().map((probe) => [probe.simulation_current_probe_id, probe])
|
|
20660
20660
|
);
|
|
20661
|
+
const currentProbesByName = new Map(
|
|
20662
|
+
root.db.simulation_current_probe.list().filter((probe) => probe.name).map((probe) => [probe.name, probe])
|
|
20663
|
+
);
|
|
20661
20664
|
const orderedSimulationProbes = root.db.simulation_voltage_probe.list().filter((probe) => voltageProbesById.has(probe.simulation_voltage_probe_id));
|
|
20662
20665
|
const graphNamesFromNetlist = getTransientVoltageGraphNamesFromSpiceNetlist(spiceNetlist);
|
|
20663
20666
|
if (graphNamesFromNetlist.length === orderedSimulationProbes.length) {
|
|
@@ -20705,12 +20708,18 @@ ${spiceString}`);
|
|
|
20705
20708
|
if (element.type === "simulation_transient_voltage_graph") {
|
|
20706
20709
|
element.simulation_experiment_id = simulationExperiment.simulation_experiment_id;
|
|
20707
20710
|
const probeMatch = element.name ? graphNameToProbe.get(element.name) : void 0;
|
|
20708
|
-
if (probeMatch)
|
|
20711
|
+
if (probeMatch) {
|
|
20712
|
+
element.color = probeMatch.color;
|
|
20713
|
+
element.source_probe_id = probeMatch.simulation_voltage_probe_id;
|
|
20714
|
+
}
|
|
20709
20715
|
}
|
|
20710
20716
|
if (element.type === "simulation_transient_current_graph") {
|
|
20711
20717
|
element.simulation_experiment_id = simulationExperiment.simulation_experiment_id;
|
|
20712
|
-
const probeMatch = element.source_probe_id ? currentProbesById.get(element.source_probe_id) : void 0;
|
|
20713
|
-
if (probeMatch)
|
|
20718
|
+
const probeMatch = (element.source_probe_id ? currentProbesById.get(element.source_probe_id) : void 0) ?? (element.name ? currentProbesByName.get(element.name) : void 0);
|
|
20719
|
+
if (probeMatch) {
|
|
20720
|
+
element.color = probeMatch.color;
|
|
20721
|
+
element.source_probe_id = probeMatch.simulation_current_probe_id;
|
|
20722
|
+
}
|
|
20714
20723
|
}
|
|
20715
20724
|
const elementType = element.type;
|
|
20716
20725
|
if (elementType && root.db[elementType]) {
|
|
@@ -24188,7 +24197,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
24188
24197
|
var package_default = {
|
|
24189
24198
|
name: "@tscircuit/core",
|
|
24190
24199
|
type: "module",
|
|
24191
|
-
version: "0.0.
|
|
24200
|
+
version: "0.0.1351",
|
|
24192
24201
|
types: "dist/index.d.ts",
|
|
24193
24202
|
main: "dist/index.js",
|
|
24194
24203
|
module: "dist/index.js",
|
|
@@ -24251,13 +24260,13 @@ var package_default = {
|
|
|
24251
24260
|
"bun-match-svg": "0.0.12",
|
|
24252
24261
|
"calculate-elbow": "^0.0.12",
|
|
24253
24262
|
"chokidar-cli": "^3.0.0",
|
|
24254
|
-
"circuit-json": "^0.0.
|
|
24263
|
+
"circuit-json": "^0.0.438",
|
|
24255
24264
|
"circuit-json-to-bpc": "^0.0.13",
|
|
24256
24265
|
"circuit-json-to-connectivity-map": "^0.0.23",
|
|
24257
24266
|
"circuit-json-to-gltf": "^0.0.105",
|
|
24258
24267
|
"circuit-json-to-simple-3d": "^0.0.9",
|
|
24259
24268
|
"circuit-json-to-spice": "^0.0.39",
|
|
24260
|
-
"circuit-to-svg": "^0.0.
|
|
24269
|
+
"circuit-to-svg": "^0.0.360",
|
|
24261
24270
|
concurrently: "^9.1.2",
|
|
24262
24271
|
"connectivity-map": "^1.0.0",
|
|
24263
24272
|
debug: "^4.3.6",
|
|
@@ -26922,36 +26931,39 @@ var Ammeter = class extends NormalComponent3 {
|
|
|
26922
26931
|
}
|
|
26923
26932
|
doInitialSourceRender() {
|
|
26924
26933
|
const { db } = this.root;
|
|
26925
|
-
const {
|
|
26934
|
+
const { supplierPartNumbers, displayName, color, display } = this._parsedProps;
|
|
26926
26935
|
const source_component = db.source_component.insert({
|
|
26927
26936
|
ftype: "simple_ammeter",
|
|
26928
26937
|
name: this.name,
|
|
26929
|
-
supplier_part_numbers:
|
|
26930
|
-
display_name:
|
|
26938
|
+
supplier_part_numbers: supplierPartNumbers,
|
|
26939
|
+
display_name: displayName
|
|
26931
26940
|
});
|
|
26932
26941
|
this.source_component_id = source_component.source_component_id;
|
|
26933
26942
|
}
|
|
26934
26943
|
doInitialSimulationRender() {
|
|
26935
26944
|
const { db } = this.root;
|
|
26936
|
-
const {
|
|
26945
|
+
const { color, display } = this._parsedProps;
|
|
26937
26946
|
const posPort = this.portMap.pos;
|
|
26938
26947
|
const negPort = this.portMap.neg;
|
|
26939
|
-
const
|
|
26940
|
-
db.simulation_current_probe.insert({
|
|
26948
|
+
const { simulation_current_probe_id } = db.simulation_current_probe.insert({
|
|
26941
26949
|
type: "simulation_current_probe",
|
|
26942
26950
|
name: this.name,
|
|
26943
26951
|
source_component_id: this.source_component_id,
|
|
26944
26952
|
positive_source_port_id: posPort.source_port_id,
|
|
26945
26953
|
negative_source_port_id: negPort.source_port_id,
|
|
26946
26954
|
subcircuit_id: this.getSubcircuit()?.subcircuit_id ?? void 0,
|
|
26947
|
-
color
|
|
26948
|
-
|
|
26949
|
-
|
|
26950
|
-
|
|
26951
|
-
|
|
26952
|
-
|
|
26953
|
-
|
|
26954
|
-
|
|
26955
|
+
color
|
|
26956
|
+
});
|
|
26957
|
+
if (display) {
|
|
26958
|
+
db.simulation_oscilloscope_trace.insert({
|
|
26959
|
+
simulation_current_probe_id,
|
|
26960
|
+
display_name: display.label,
|
|
26961
|
+
color,
|
|
26962
|
+
display_center_value: display.center,
|
|
26963
|
+
display_center_offset_divs: display.offsetDivs,
|
|
26964
|
+
amps_per_div: display.unitsPerDiv
|
|
26965
|
+
});
|
|
26966
|
+
}
|
|
26955
26967
|
}
|
|
26956
26968
|
pos = this.portMap.pos;
|
|
26957
26969
|
neg = this.portMap.neg;
|
|
@@ -30696,9 +30708,7 @@ var SchematicCell = class extends PrimitiveComponent2 {
|
|
|
30696
30708
|
};
|
|
30697
30709
|
|
|
30698
30710
|
// lib/components/primitive-components/AnalogSimulation.ts
|
|
30699
|
-
import {
|
|
30700
|
-
analogSimulationProps
|
|
30701
|
-
} from "@tscircuit/props";
|
|
30711
|
+
import { analogSimulationProps } from "@tscircuit/props";
|
|
30702
30712
|
var AnalogSimulation = class extends PrimitiveComponent2 {
|
|
30703
30713
|
get config() {
|
|
30704
30714
|
return {
|
|
@@ -30708,11 +30718,11 @@ var AnalogSimulation = class extends PrimitiveComponent2 {
|
|
|
30708
30718
|
}
|
|
30709
30719
|
doInitialSimulationRender() {
|
|
30710
30720
|
const { db } = this.root;
|
|
30711
|
-
const { duration, startTime, timePerStep, spiceOptions } = this._parsedProps;
|
|
30721
|
+
const { duration, name, startTime, timePerStep, spiceOptions } = this._parsedProps;
|
|
30712
30722
|
const durationMs = duration || 10;
|
|
30713
30723
|
const timePerStepMs = timePerStep || 0.01;
|
|
30714
30724
|
db.simulation_experiment.insert({
|
|
30715
|
-
name: "spice_transient_analysis",
|
|
30725
|
+
name: name ?? "spice_transient_analysis",
|
|
30716
30726
|
experiment_type: "spice_transient_analysis",
|
|
30717
30727
|
end_time_ms: durationMs,
|
|
30718
30728
|
start_time_ms: startTime,
|
|
@@ -30724,7 +30734,6 @@ var AnalogSimulation = class extends PrimitiveComponent2 {
|
|
|
30724
30734
|
|
|
30725
30735
|
// lib/components/primitive-components/VoltageProbe.ts
|
|
30726
30736
|
import { voltageProbeProps } from "@tscircuit/props";
|
|
30727
|
-
import "zod";
|
|
30728
30737
|
|
|
30729
30738
|
// lib/utils/schematic/selectBestLabelAlignment.ts
|
|
30730
30739
|
import { doBoundsOverlap as doBoundsOverlap2 } from "@tscircuit/math-utils";
|
|
@@ -30846,6 +30855,7 @@ function selectBestLabelAlignment({
|
|
|
30846
30855
|
}
|
|
30847
30856
|
|
|
30848
30857
|
// lib/components/primitive-components/VoltageProbe.ts
|
|
30858
|
+
import "zod";
|
|
30849
30859
|
var VoltageProbe = class extends PrimitiveComponent2 {
|
|
30850
30860
|
simulation_voltage_probe_id = null;
|
|
30851
30861
|
schematic_voltage_probe_id = null;
|
|
@@ -30889,7 +30899,7 @@ var VoltageProbe = class extends PrimitiveComponent2 {
|
|
|
30889
30899
|
}
|
|
30890
30900
|
const connectedId = port?.source_port_id ?? net?.source_net_id;
|
|
30891
30901
|
if (!connectedId) {
|
|
30892
|
-
this.renderError(
|
|
30902
|
+
this.renderError("Could not identify connected source for VoltageProbe");
|
|
30893
30903
|
return;
|
|
30894
30904
|
}
|
|
30895
30905
|
let referencePort = null;
|
|
@@ -30933,15 +30943,19 @@ var VoltageProbe = class extends PrimitiveComponent2 {
|
|
|
30933
30943
|
reference_input_source_port_id: referencePort?.source_port_id ?? void 0,
|
|
30934
30944
|
reference_input_source_net_id: referenceNet?.source_net_id ?? void 0,
|
|
30935
30945
|
subcircuit_id: subcircuit.subcircuit_id || void 0,
|
|
30936
|
-
color: this.color
|
|
30937
|
-
display_options: display ? {
|
|
30938
|
-
label: display.label,
|
|
30939
|
-
center: display.center,
|
|
30940
|
-
offset_divs: display.offsetDivs,
|
|
30941
|
-
units_per_div: display.unitsPerDiv
|
|
30942
|
-
} : void 0
|
|
30946
|
+
color: this.color
|
|
30943
30947
|
});
|
|
30944
30948
|
this.simulation_voltage_probe_id = simulation_voltage_probe_id;
|
|
30949
|
+
if (display) {
|
|
30950
|
+
db.simulation_oscilloscope_trace.insert({
|
|
30951
|
+
simulation_voltage_probe_id,
|
|
30952
|
+
display_name: display.label,
|
|
30953
|
+
color: color ?? void 0,
|
|
30954
|
+
display_center_value: display.center,
|
|
30955
|
+
display_center_offset_divs: display.offsetDivs,
|
|
30956
|
+
volts_per_div: display.unitsPerDiv
|
|
30957
|
+
});
|
|
30958
|
+
}
|
|
30945
30959
|
}
|
|
30946
30960
|
doInitialSchematicReplaceNetLabelsWithSymbols() {
|
|
30947
30961
|
if (this.root?.schematicDisabled) return;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.1352",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -64,13 +64,13 @@
|
|
|
64
64
|
"bun-match-svg": "0.0.12",
|
|
65
65
|
"calculate-elbow": "^0.0.12",
|
|
66
66
|
"chokidar-cli": "^3.0.0",
|
|
67
|
-
"circuit-json": "^0.0.
|
|
67
|
+
"circuit-json": "^0.0.438",
|
|
68
68
|
"circuit-json-to-bpc": "^0.0.13",
|
|
69
69
|
"circuit-json-to-connectivity-map": "^0.0.23",
|
|
70
70
|
"circuit-json-to-gltf": "^0.0.105",
|
|
71
71
|
"circuit-json-to-simple-3d": "^0.0.9",
|
|
72
72
|
"circuit-json-to-spice": "^0.0.39",
|
|
73
|
-
"circuit-to-svg": "^0.0.
|
|
73
|
+
"circuit-to-svg": "^0.0.360",
|
|
74
74
|
"concurrently": "^9.1.2",
|
|
75
75
|
"connectivity-map": "^1.0.0",
|
|
76
76
|
"debug": "^4.3.6",
|