@tscircuit/core 0.0.1181 → 0.0.1182

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 +59 -20
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -17462,22 +17462,23 @@ var getSpiceyEngine = () => {
17462
17462
 
17463
17463
  // lib/utils/simulation/getSimulationColorForId.ts
17464
17464
  var SIMULATION_COLOR_PALETTE = [
17465
- "rgb(132, 0, 0)",
17466
- "rgb(194, 194, 0)",
17467
- "rgb(194, 0, 194)",
17468
- "rgb(194, 0, 0)",
17469
- "rgb(0, 132, 132)",
17470
- "rgb(0, 132, 0)",
17465
+ // Start with the colors users most commonly expect from circuit sims.
17466
+ "rgb(0, 150, 0)",
17467
+ "rgb(0, 0, 220)",
17468
+ "rgb(220, 0, 0)",
17469
+ "rgb(0, 160, 160)",
17470
+ "rgb(180, 0, 180)",
17471
+ "rgb(170, 140, 0)",
17472
+ "rgb(220, 120, 0)",
17473
+ "rgb(128, 128, 128)",
17474
+ "rgb(100, 0, 180)",
17475
+ "rgb(140, 70, 0)",
17476
+ "rgb(220, 80, 120)",
17477
+ "rgb(0, 120, 220)",
17478
+ "rgb(0, 120, 120)",
17479
+ "rgb(120, 0, 0)",
17471
17480
  "rgb(0, 0, 132)",
17472
- "rgb(132, 132, 132)",
17473
- "rgb(132, 0, 132)",
17474
- "rgb(194, 194, 194)",
17475
- "rgb(132, 0, 132)",
17476
- "rgb(132, 0, 0)",
17477
- "rgb(132, 132, 0)",
17478
- "rgb(194, 194, 194)",
17479
- "rgb(0, 0, 132)",
17480
- "rgb(0, 132, 0)"
17481
+ "rgb(80, 80, 80)"
17481
17482
  ];
17482
17483
  var idToColorMap = /* @__PURE__ */ new Map();
17483
17484
  var colorIndex = 0;
@@ -17496,6 +17497,20 @@ function resetSimulationColorState() {
17496
17497
  colorIndex = 0;
17497
17498
  }
17498
17499
 
17500
+ // lib/utils/simulation/get-transient-voltage-graph-names-from-spice-netlist.ts
17501
+ function getTransientVoltageGraphNamesFromSpiceNetlist(spiceNetlist) {
17502
+ const graphNames = [];
17503
+ for (const printStatement of spiceNetlist.printStatements) {
17504
+ const match = printStatement.match(/^\.PRINT\s+TRAN\s+(.+)$/i);
17505
+ if (!match) continue;
17506
+ for (const voltageExpression of match[1].match(/V\(([^)]+)\)/g) ?? []) {
17507
+ const nodeList = voltageExpression.slice(2, -1);
17508
+ graphNames.push(nodeList.replace(",", "-"));
17509
+ }
17510
+ }
17511
+ return graphNames;
17512
+ }
17513
+
17499
17514
  // lib/components/primitive-components/Group/Group_doInitialSimulationSpiceEngineRender.ts
17500
17515
  var debug10 = Debug12("tscircuit:core:Group_doInitialSimulationSpiceEngineRender");
17501
17516
  function Group_doInitialSimulationSpiceEngineRender(group) {
@@ -17522,6 +17537,32 @@ ${spiceString}`);
17522
17537
  debug10(`Failed to convert circuit JSON to SPICE: ${error}`);
17523
17538
  return;
17524
17539
  }
17540
+ const graphNameToProbe = /* @__PURE__ */ new Map();
17541
+ for (const probe of voltageProbes) {
17542
+ if (probe.finalProbeName) {
17543
+ graphNameToProbe.set(probe.finalProbeName, probe);
17544
+ }
17545
+ }
17546
+ const voltageProbesById = new Map(
17547
+ voltageProbes.filter((probe) => probe.simulation_voltage_probe_id).map((probe) => [probe.simulation_voltage_probe_id, probe])
17548
+ );
17549
+ const orderedSimulationProbes = root.db.simulation_voltage_probe.list().filter((probe) => voltageProbesById.has(probe.simulation_voltage_probe_id));
17550
+ const graphNamesFromNetlist = getTransientVoltageGraphNamesFromSpiceNetlist(spiceNetlist);
17551
+ if (graphNamesFromNetlist.length === orderedSimulationProbes.length) {
17552
+ for (const [index, simulationProbe] of orderedSimulationProbes.entries()) {
17553
+ const probe = voltageProbesById.get(
17554
+ simulationProbe.simulation_voltage_probe_id
17555
+ );
17556
+ const graphName = graphNamesFromNetlist[index];
17557
+ if (probe && graphName) {
17558
+ graphNameToProbe.set(graphName, probe);
17559
+ }
17560
+ }
17561
+ } else {
17562
+ debug10(
17563
+ `Skipping probe-to-graph order mapping because counts differ: probes=${orderedSimulationProbes.length} graphNames=${graphNamesFromNetlist.length}`
17564
+ );
17565
+ }
17525
17566
  for (const analogSim of analogSims) {
17526
17567
  const engineName = analogSim._parsedProps.spiceEngine ?? "spicey";
17527
17568
  const spiceEngine = spiceEngineMap[engineName];
@@ -17551,9 +17592,7 @@ ${spiceString}`);
17551
17592
  for (const element of result.simulationResultCircuitJson) {
17552
17593
  if (element.type === "simulation_transient_voltage_graph") {
17553
17594
  element.simulation_experiment_id = simulationExperiment.simulation_experiment_id;
17554
- const probeMatch = voltageProbes.find(
17555
- (p) => p.finalProbeName === element.name
17556
- );
17595
+ const probeMatch = element.name ? graphNameToProbe.get(element.name) : void 0;
17557
17596
  if (probeMatch) element.color = probeMatch.color;
17558
17597
  }
17559
17598
  const elementType = element.type;
@@ -19872,7 +19911,7 @@ import { identity as identity5 } from "transformation-matrix";
19872
19911
  var package_default = {
19873
19912
  name: "@tscircuit/core",
19874
19913
  type: "module",
19875
- version: "0.0.1180",
19914
+ version: "0.0.1181",
19876
19915
  types: "dist/index.d.ts",
19877
19916
  main: "dist/index.js",
19878
19917
  module: "dist/index.js",
@@ -19938,7 +19977,7 @@ var package_default = {
19938
19977
  "circuit-json-to-gltf": "^0.0.91",
19939
19978
  "circuit-json-to-simple-3d": "^0.0.9",
19940
19979
  "circuit-json-to-spice": "^0.0.34",
19941
- "circuit-to-svg": "^0.0.343",
19980
+ "circuit-to-svg": "^0.0.345",
19942
19981
  concurrently: "^9.1.2",
19943
19982
  "connectivity-map": "^1.0.0",
19944
19983
  debug: "^4.3.6",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1181",
4
+ "version": "0.0.1182",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -67,7 +67,7 @@
67
67
  "circuit-json-to-gltf": "^0.0.91",
68
68
  "circuit-json-to-simple-3d": "^0.0.9",
69
69
  "circuit-json-to-spice": "^0.0.34",
70
- "circuit-to-svg": "^0.0.343",
70
+ "circuit-to-svg": "^0.0.345",
71
71
  "concurrently": "^9.1.2",
72
72
  "connectivity-map": "^1.0.0",
73
73
  "debug": "^4.3.6",