@tscircuit/core 0.0.1351 → 0.0.1353
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 +104 -73
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -20385,16 +20385,33 @@ var insertNetLabelsForPortsMissingTrace = ({
|
|
|
20385
20385
|
const dx = existingNetLabelForCurrentSourceConnection.anchor_position.x - schPort.center.x;
|
|
20386
20386
|
const dy = existingNetLabelForCurrentSourceConnection.anchor_position.y - schPort.center.y;
|
|
20387
20387
|
const labelIsNearPort = dx * dx + dy * dy < NEAR_EXISTING_NET_LABEL_DISTANCE * NEAR_EXISTING_NET_LABEL_DISTANCE;
|
|
20388
|
-
if (labelIsNearPort
|
|
20389
|
-
|
|
20390
|
-
|
|
20391
|
-
|
|
20392
|
-
|
|
20393
|
-
|
|
20394
|
-
|
|
20395
|
-
|
|
20396
|
-
|
|
20397
|
-
|
|
20388
|
+
if (labelIsNearPort) {
|
|
20389
|
+
if (isGndNet) {
|
|
20390
|
+
db.schematic_net_label.update(
|
|
20391
|
+
existingNetLabelForCurrentSourceConnection.schematic_net_label_id,
|
|
20392
|
+
{
|
|
20393
|
+
text,
|
|
20394
|
+
anchor_position: schPort.center,
|
|
20395
|
+
center,
|
|
20396
|
+
anchor_side: side
|
|
20397
|
+
}
|
|
20398
|
+
);
|
|
20399
|
+
} else if (!isPowerNet && existingNetLabelForCurrentSourceConnection.text === text) {
|
|
20400
|
+
const anchor_side = existingNetLabelForCurrentSourceConnection.anchor_side ?? side;
|
|
20401
|
+
db.schematic_net_label.update(
|
|
20402
|
+
existingNetLabelForCurrentSourceConnection.schematic_net_label_id,
|
|
20403
|
+
{
|
|
20404
|
+
text,
|
|
20405
|
+
anchor_position: schPort.center,
|
|
20406
|
+
center: computeSchematicNetLabelCenter({
|
|
20407
|
+
anchor_position: schPort.center,
|
|
20408
|
+
anchor_side,
|
|
20409
|
+
text
|
|
20410
|
+
}),
|
|
20411
|
+
anchor_side
|
|
20412
|
+
}
|
|
20413
|
+
);
|
|
20414
|
+
}
|
|
20398
20415
|
continue;
|
|
20399
20416
|
}
|
|
20400
20417
|
const existingAtPort = db.schematic_net_label.list().some((nl) => {
|
|
@@ -20550,24 +20567,19 @@ var Group_doInitialSchematicTraceRender = (group) => {
|
|
|
20550
20567
|
import { circuitJsonToSpice } from "circuit-json-to-spice";
|
|
20551
20568
|
import Debug13 from "debug";
|
|
20552
20569
|
|
|
20553
|
-
// lib/
|
|
20554
|
-
|
|
20555
|
-
|
|
20556
|
-
|
|
20557
|
-
|
|
20558
|
-
|
|
20559
|
-
|
|
20560
|
-
const
|
|
20561
|
-
|
|
20562
|
-
parsedCircuit,
|
|
20563
|
-
simulation_experiment_id
|
|
20564
|
-
);
|
|
20565
|
-
return {
|
|
20566
|
-
simulationResultCircuitJson: voltageGraphs
|
|
20567
|
-
};
|
|
20570
|
+
// lib/utils/simulation/get-transient-voltage-graph-names-from-spice-netlist.ts
|
|
20571
|
+
function getTransientVoltageGraphNamesFromSpiceNetlist(spiceNetlist) {
|
|
20572
|
+
const graphNames = [];
|
|
20573
|
+
for (const printStatement of spiceNetlist.printStatements) {
|
|
20574
|
+
const match = printStatement.match(/^\.PRINT\s+TRAN\s+(.+)$/i);
|
|
20575
|
+
if (!match) continue;
|
|
20576
|
+
for (const voltageExpression of match[1].match(/V\(([^)]+)\)/g) ?? []) {
|
|
20577
|
+
const nodeList = voltageExpression.slice(2, -1);
|
|
20578
|
+
graphNames.push(nodeList.replace(",", "-"));
|
|
20568
20579
|
}
|
|
20569
|
-
}
|
|
20570
|
-
|
|
20580
|
+
}
|
|
20581
|
+
return graphNames;
|
|
20582
|
+
}
|
|
20571
20583
|
|
|
20572
20584
|
// lib/utils/simulation/getSimulationColorForId.ts
|
|
20573
20585
|
var SIMULATION_COLOR_PALETTE = [
|
|
@@ -20606,19 +20618,24 @@ function resetSimulationColorState() {
|
|
|
20606
20618
|
colorIndex = 0;
|
|
20607
20619
|
}
|
|
20608
20620
|
|
|
20609
|
-
// lib/
|
|
20610
|
-
|
|
20611
|
-
|
|
20612
|
-
|
|
20613
|
-
|
|
20614
|
-
|
|
20615
|
-
|
|
20616
|
-
const
|
|
20617
|
-
|
|
20621
|
+
// lib/spice/get-spicey-engine.ts
|
|
20622
|
+
import { simulate, spiceyTranToVGraphs } from "spicey";
|
|
20623
|
+
var getSpiceyEngine = () => {
|
|
20624
|
+
return {
|
|
20625
|
+
async simulate(spiceString) {
|
|
20626
|
+
const simulation_experiment_id = "spice-experiment-1";
|
|
20627
|
+
const { circuit: parsedCircuit, tran } = simulate(spiceString);
|
|
20628
|
+
const voltageGraphs = spiceyTranToVGraphs(
|
|
20629
|
+
tran,
|
|
20630
|
+
parsedCircuit,
|
|
20631
|
+
simulation_experiment_id
|
|
20632
|
+
);
|
|
20633
|
+
return {
|
|
20634
|
+
simulationResultCircuitJson: voltageGraphs
|
|
20635
|
+
};
|
|
20618
20636
|
}
|
|
20619
|
-
}
|
|
20620
|
-
|
|
20621
|
-
}
|
|
20637
|
+
};
|
|
20638
|
+
};
|
|
20622
20639
|
|
|
20623
20640
|
// lib/components/primitive-components/Group/Group_doInitialSimulationSpiceEngineRender.ts
|
|
20624
20641
|
var debug11 = Debug13("tscircuit:core:Group_doInitialSimulationSpiceEngineRender");
|
|
@@ -20658,6 +20675,9 @@ ${spiceString}`);
|
|
|
20658
20675
|
const currentProbesById = new Map(
|
|
20659
20676
|
root.db.simulation_current_probe.list().map((probe) => [probe.simulation_current_probe_id, probe])
|
|
20660
20677
|
);
|
|
20678
|
+
const currentProbesByName = new Map(
|
|
20679
|
+
root.db.simulation_current_probe.list().filter((probe) => probe.name).map((probe) => [probe.name, probe])
|
|
20680
|
+
);
|
|
20661
20681
|
const orderedSimulationProbes = root.db.simulation_voltage_probe.list().filter((probe) => voltageProbesById.has(probe.simulation_voltage_probe_id));
|
|
20662
20682
|
const graphNamesFromNetlist = getTransientVoltageGraphNamesFromSpiceNetlist(spiceNetlist);
|
|
20663
20683
|
if (graphNamesFromNetlist.length === orderedSimulationProbes.length) {
|
|
@@ -20705,12 +20725,18 @@ ${spiceString}`);
|
|
|
20705
20725
|
if (element.type === "simulation_transient_voltage_graph") {
|
|
20706
20726
|
element.simulation_experiment_id = simulationExperiment.simulation_experiment_id;
|
|
20707
20727
|
const probeMatch = element.name ? graphNameToProbe.get(element.name) : void 0;
|
|
20708
|
-
if (probeMatch)
|
|
20728
|
+
if (probeMatch) {
|
|
20729
|
+
element.color = probeMatch.color;
|
|
20730
|
+
element.source_probe_id = probeMatch.simulation_voltage_probe_id;
|
|
20731
|
+
}
|
|
20709
20732
|
}
|
|
20710
20733
|
if (element.type === "simulation_transient_current_graph") {
|
|
20711
20734
|
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)
|
|
20735
|
+
const probeMatch = (element.source_probe_id ? currentProbesById.get(element.source_probe_id) : void 0) ?? (element.name ? currentProbesByName.get(element.name) : void 0);
|
|
20736
|
+
if (probeMatch) {
|
|
20737
|
+
element.color = probeMatch.color;
|
|
20738
|
+
element.source_probe_id = probeMatch.simulation_current_probe_id;
|
|
20739
|
+
}
|
|
20714
20740
|
}
|
|
20715
20741
|
const elementType = element.type;
|
|
20716
20742
|
if (elementType && root.db[elementType]) {
|
|
@@ -24188,7 +24214,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
24188
24214
|
var package_default = {
|
|
24189
24215
|
name: "@tscircuit/core",
|
|
24190
24216
|
type: "module",
|
|
24191
|
-
version: "0.0.
|
|
24217
|
+
version: "0.0.1352",
|
|
24192
24218
|
types: "dist/index.d.ts",
|
|
24193
24219
|
main: "dist/index.js",
|
|
24194
24220
|
module: "dist/index.js",
|
|
@@ -24251,13 +24277,13 @@ var package_default = {
|
|
|
24251
24277
|
"bun-match-svg": "0.0.12",
|
|
24252
24278
|
"calculate-elbow": "^0.0.12",
|
|
24253
24279
|
"chokidar-cli": "^3.0.0",
|
|
24254
|
-
"circuit-json": "^0.0.
|
|
24280
|
+
"circuit-json": "^0.0.438",
|
|
24255
24281
|
"circuit-json-to-bpc": "^0.0.13",
|
|
24256
24282
|
"circuit-json-to-connectivity-map": "^0.0.23",
|
|
24257
24283
|
"circuit-json-to-gltf": "^0.0.105",
|
|
24258
24284
|
"circuit-json-to-simple-3d": "^0.0.9",
|
|
24259
24285
|
"circuit-json-to-spice": "^0.0.39",
|
|
24260
|
-
"circuit-to-svg": "^0.0.
|
|
24286
|
+
"circuit-to-svg": "^0.0.360",
|
|
24261
24287
|
concurrently: "^9.1.2",
|
|
24262
24288
|
"connectivity-map": "^1.0.0",
|
|
24263
24289
|
debug: "^4.3.6",
|
|
@@ -26922,36 +26948,39 @@ var Ammeter = class extends NormalComponent3 {
|
|
|
26922
26948
|
}
|
|
26923
26949
|
doInitialSourceRender() {
|
|
26924
26950
|
const { db } = this.root;
|
|
26925
|
-
const {
|
|
26951
|
+
const { supplierPartNumbers, displayName, color, display } = this._parsedProps;
|
|
26926
26952
|
const source_component = db.source_component.insert({
|
|
26927
26953
|
ftype: "simple_ammeter",
|
|
26928
26954
|
name: this.name,
|
|
26929
|
-
supplier_part_numbers:
|
|
26930
|
-
display_name:
|
|
26955
|
+
supplier_part_numbers: supplierPartNumbers,
|
|
26956
|
+
display_name: displayName
|
|
26931
26957
|
});
|
|
26932
26958
|
this.source_component_id = source_component.source_component_id;
|
|
26933
26959
|
}
|
|
26934
26960
|
doInitialSimulationRender() {
|
|
26935
26961
|
const { db } = this.root;
|
|
26936
|
-
const {
|
|
26962
|
+
const { color, display } = this._parsedProps;
|
|
26937
26963
|
const posPort = this.portMap.pos;
|
|
26938
26964
|
const negPort = this.portMap.neg;
|
|
26939
|
-
const
|
|
26940
|
-
db.simulation_current_probe.insert({
|
|
26965
|
+
const { simulation_current_probe_id } = db.simulation_current_probe.insert({
|
|
26941
26966
|
type: "simulation_current_probe",
|
|
26942
26967
|
name: this.name,
|
|
26943
26968
|
source_component_id: this.source_component_id,
|
|
26944
26969
|
positive_source_port_id: posPort.source_port_id,
|
|
26945
26970
|
negative_source_port_id: negPort.source_port_id,
|
|
26946
26971
|
subcircuit_id: this.getSubcircuit()?.subcircuit_id ?? void 0,
|
|
26947
|
-
color
|
|
26948
|
-
|
|
26949
|
-
|
|
26950
|
-
|
|
26951
|
-
|
|
26952
|
-
|
|
26953
|
-
|
|
26954
|
-
|
|
26972
|
+
color
|
|
26973
|
+
});
|
|
26974
|
+
if (display) {
|
|
26975
|
+
db.simulation_oscilloscope_trace.insert({
|
|
26976
|
+
simulation_current_probe_id,
|
|
26977
|
+
display_name: display.label,
|
|
26978
|
+
color,
|
|
26979
|
+
display_center_value: display.center,
|
|
26980
|
+
display_center_offset_divs: display.offsetDivs,
|
|
26981
|
+
amps_per_div: display.unitsPerDiv
|
|
26982
|
+
});
|
|
26983
|
+
}
|
|
26955
26984
|
}
|
|
26956
26985
|
pos = this.portMap.pos;
|
|
26957
26986
|
neg = this.portMap.neg;
|
|
@@ -30696,9 +30725,7 @@ var SchematicCell = class extends PrimitiveComponent2 {
|
|
|
30696
30725
|
};
|
|
30697
30726
|
|
|
30698
30727
|
// lib/components/primitive-components/AnalogSimulation.ts
|
|
30699
|
-
import {
|
|
30700
|
-
analogSimulationProps
|
|
30701
|
-
} from "@tscircuit/props";
|
|
30728
|
+
import { analogSimulationProps } from "@tscircuit/props";
|
|
30702
30729
|
var AnalogSimulation = class extends PrimitiveComponent2 {
|
|
30703
30730
|
get config() {
|
|
30704
30731
|
return {
|
|
@@ -30708,11 +30735,11 @@ var AnalogSimulation = class extends PrimitiveComponent2 {
|
|
|
30708
30735
|
}
|
|
30709
30736
|
doInitialSimulationRender() {
|
|
30710
30737
|
const { db } = this.root;
|
|
30711
|
-
const { duration, startTime, timePerStep, spiceOptions } = this._parsedProps;
|
|
30738
|
+
const { duration, name, startTime, timePerStep, spiceOptions } = this._parsedProps;
|
|
30712
30739
|
const durationMs = duration || 10;
|
|
30713
30740
|
const timePerStepMs = timePerStep || 0.01;
|
|
30714
30741
|
db.simulation_experiment.insert({
|
|
30715
|
-
name: "spice_transient_analysis",
|
|
30742
|
+
name: name ?? "spice_transient_analysis",
|
|
30716
30743
|
experiment_type: "spice_transient_analysis",
|
|
30717
30744
|
end_time_ms: durationMs,
|
|
30718
30745
|
start_time_ms: startTime,
|
|
@@ -30724,7 +30751,6 @@ var AnalogSimulation = class extends PrimitiveComponent2 {
|
|
|
30724
30751
|
|
|
30725
30752
|
// lib/components/primitive-components/VoltageProbe.ts
|
|
30726
30753
|
import { voltageProbeProps } from "@tscircuit/props";
|
|
30727
|
-
import "zod";
|
|
30728
30754
|
|
|
30729
30755
|
// lib/utils/schematic/selectBestLabelAlignment.ts
|
|
30730
30756
|
import { doBoundsOverlap as doBoundsOverlap2 } from "@tscircuit/math-utils";
|
|
@@ -30846,6 +30872,7 @@ function selectBestLabelAlignment({
|
|
|
30846
30872
|
}
|
|
30847
30873
|
|
|
30848
30874
|
// lib/components/primitive-components/VoltageProbe.ts
|
|
30875
|
+
import "zod";
|
|
30849
30876
|
var VoltageProbe = class extends PrimitiveComponent2 {
|
|
30850
30877
|
simulation_voltage_probe_id = null;
|
|
30851
30878
|
schematic_voltage_probe_id = null;
|
|
@@ -30889,7 +30916,7 @@ var VoltageProbe = class extends PrimitiveComponent2 {
|
|
|
30889
30916
|
}
|
|
30890
30917
|
const connectedId = port?.source_port_id ?? net?.source_net_id;
|
|
30891
30918
|
if (!connectedId) {
|
|
30892
|
-
this.renderError(
|
|
30919
|
+
this.renderError("Could not identify connected source for VoltageProbe");
|
|
30893
30920
|
return;
|
|
30894
30921
|
}
|
|
30895
30922
|
let referencePort = null;
|
|
@@ -30933,15 +30960,19 @@ var VoltageProbe = class extends PrimitiveComponent2 {
|
|
|
30933
30960
|
reference_input_source_port_id: referencePort?.source_port_id ?? void 0,
|
|
30934
30961
|
reference_input_source_net_id: referenceNet?.source_net_id ?? void 0,
|
|
30935
30962
|
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
|
|
30963
|
+
color: this.color
|
|
30943
30964
|
});
|
|
30944
30965
|
this.simulation_voltage_probe_id = simulation_voltage_probe_id;
|
|
30966
|
+
if (display) {
|
|
30967
|
+
db.simulation_oscilloscope_trace.insert({
|
|
30968
|
+
simulation_voltage_probe_id,
|
|
30969
|
+
display_name: display.label,
|
|
30970
|
+
color: color ?? void 0,
|
|
30971
|
+
display_center_value: display.center,
|
|
30972
|
+
display_center_offset_divs: display.offsetDivs,
|
|
30973
|
+
volts_per_div: display.unitsPerDiv
|
|
30974
|
+
});
|
|
30975
|
+
}
|
|
30945
30976
|
}
|
|
30946
30977
|
doInitialSchematicReplaceNetLabelsWithSymbols() {
|
|
30947
30978
|
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.1353",
|
|
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",
|