circuit-to-svg 0.0.268 → 0.0.270

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 CHANGED
@@ -3963,7 +3963,7 @@ function getSoftwareUsedString(circuitJson) {
3963
3963
  var package_default = {
3964
3964
  name: "circuit-to-svg",
3965
3965
  type: "module",
3966
- version: "0.0.267",
3966
+ version: "0.0.269",
3967
3967
  description: "Convert Circuit JSON to SVG",
3968
3968
  main: "dist/index.js",
3969
3969
  files: [
@@ -3987,7 +3987,7 @@ var package_default = {
3987
3987
  "bun-match-svg": "^0.0.12",
3988
3988
  esbuild: "^0.20.2",
3989
3989
  "performance-now": "^2.1.0",
3990
- "circuit-json": "^0.0.309",
3990
+ "circuit-json": "^0.0.315",
3991
3991
  react: "19.1.0",
3992
3992
  "react-cosmos": "7.0.0",
3993
3993
  "react-cosmos-plugin-vite": "7.0.0",
@@ -8900,6 +8900,7 @@ function createSvgObjectsFromSchVoltageProbe({
8900
8900
  probe.position.x,
8901
8901
  probe.position.y
8902
8902
  ]);
8903
+ const probeColor = probe.color ?? colorMap2.schematic.reference;
8903
8904
  const arrowLength = Math.abs(transform.a) * 0.6;
8904
8905
  const arrowWidth = Math.abs(transform.a) * 0.28;
8905
8906
  const baseX = screenX + arrowLength * Math.cos(-50 * Math.PI / 180);
@@ -8914,12 +8915,59 @@ function createSvgObjectsFromSchVoltageProbe({
8914
8915
  `L ${tipX - arrowWidth * Math.cos((-50 + 210) * Math.PI / 180)},${tipY - arrowWidth * Math.sin((-50 + 210) * Math.PI / 180)}`,
8915
8916
  "Z"
8916
8917
  ].join(" ");
8917
- const textParts = [];
8918
- if (probe.name) {
8919
- textParts.push(probe.name);
8920
- }
8921
- if (probe.voltage !== void 0) {
8922
- textParts.push(`${probe.voltage}V`);
8918
+ const x = (baseX + 8 - (baseX - baseX)).toString();
8919
+ const textChildren = [];
8920
+ if (probe.name && probe.voltage !== void 0) {
8921
+ textChildren.push({
8922
+ type: "element",
8923
+ name: "tspan",
8924
+ value: "",
8925
+ attributes: {
8926
+ x
8927
+ },
8928
+ children: [
8929
+ {
8930
+ type: "text",
8931
+ value: probe.name,
8932
+ name: "",
8933
+ attributes: {},
8934
+ children: []
8935
+ }
8936
+ ]
8937
+ });
8938
+ textChildren.push({
8939
+ type: "element",
8940
+ name: "tspan",
8941
+ value: "",
8942
+ attributes: {
8943
+ x,
8944
+ dy: "1.2em"
8945
+ },
8946
+ children: [
8947
+ {
8948
+ type: "text",
8949
+ value: `${probe.voltage}V`,
8950
+ name: "",
8951
+ attributes: {},
8952
+ children: []
8953
+ }
8954
+ ]
8955
+ });
8956
+ } else {
8957
+ const textParts = [];
8958
+ if (probe.name) {
8959
+ textParts.push(probe.name);
8960
+ }
8961
+ if (probe.voltage !== void 0) {
8962
+ textParts.push(`${probe.voltage}V`);
8963
+ }
8964
+ textChildren.push({
8965
+ type: "text",
8966
+ value: textParts.join(" "),
8967
+ name: "",
8968
+ attributes: {},
8969
+ children: []
8970
+ });
8923
8971
  }
8924
8972
  return [
8925
8973
  {
@@ -8927,8 +8975,8 @@ function createSvgObjectsFromSchVoltageProbe({
8927
8975
  type: "element",
8928
8976
  attributes: {
8929
8977
  d: arrowPath,
8930
- stroke: colorMap2.schematic.reference,
8931
- fill: colorMap2.schematic.reference,
8978
+ stroke: probeColor,
8979
+ fill: probeColor,
8932
8980
  "stroke-width": `${getSchStrokeSize(transform)}px`
8933
8981
  },
8934
8982
  value: "",
@@ -8939,25 +8987,17 @@ function createSvgObjectsFromSchVoltageProbe({
8939
8987
  name: "text",
8940
8988
  value: "",
8941
8989
  attributes: {
8942
- x: (baseX + 8 - (baseX - baseX)).toString(),
8943
- y: (baseY - 10 + (baseY - baseY)).toString(),
8944
- fill: colorMap2.schematic.reference,
8945
- "text-anchor": "middle",
8990
+ x,
8991
+ y: baseY.toString(),
8992
+ fill: probeColor,
8993
+ "text-anchor": "start",
8946
8994
  "dominant-baseline": "middle",
8947
8995
  "font-family": "sans-serif",
8948
8996
  "font-size": `${getSchScreenFontSize(transform, "reference_designator")}px`,
8949
8997
  "font-weight": "bold",
8950
8998
  "data-schematic-voltage-probe-id": probe.schematic_voltage_probe_id
8951
8999
  },
8952
- children: [
8953
- {
8954
- type: "text",
8955
- value: textParts.join(" "),
8956
- name: "",
8957
- attributes: {},
8958
- children: []
8959
- }
8960
- ]
9000
+ children: textChildren
8961
9001
  }
8962
9002
  ];
8963
9003
  }
@@ -10515,19 +10555,23 @@ function convertCircuitJsonToSimulationGraphSvg({
10515
10555
  function prepareSimulationGraphs(graphs, circuitJson) {
10516
10556
  const palette = Array.isArray(colorMap.palette) ? colorMap.palette : [];
10517
10557
  const voltageProbes = circuitJson.filter(isSimulationVoltageProbe);
10518
- const probeIdToName = /* @__PURE__ */ new Map();
10558
+ const sourceComponentIdToProbeName = /* @__PURE__ */ new Map();
10559
+ const sourceComponentIdToProbeColor = /* @__PURE__ */ new Map();
10519
10560
  for (const probe of voltageProbes) {
10520
- if (probe.name && probe.simulation_voltage_probe_id) {
10521
- probeIdToName.set(probe.simulation_voltage_probe_id, probe.name);
10561
+ if (probe.name && probe.source_component_id) {
10562
+ sourceComponentIdToProbeName.set(probe.source_component_id, probe.name);
10563
+ }
10564
+ if (probe.color && probe.source_component_id) {
10565
+ sourceComponentIdToProbeColor.set(probe.source_component_id, probe.color);
10522
10566
  }
10523
10567
  }
10524
10568
  return graphs.map((graph, index) => {
10525
10569
  const points = createGraphPoints(graph);
10526
10570
  const paletteColor = palette.length > 0 ? palette[index % palette.length] : FALLBACK_LINE_COLOR;
10527
- const color = paletteColor ?? FALLBACK_LINE_COLOR;
10528
- const probeId = graph.simulation_voltage_probe_id ?? graph.schematic_voltage_probe_id;
10529
- const probeName = probeId ? probeIdToName.get(probeId) : void 0;
10530
- const label = probeName ? `V(${probeName})` : graph.name || (probeId ? `Probe ${probeId}` : graph.simulation_transient_voltage_graph_id);
10571
+ const probeColor = graph.source_component_id ? sourceComponentIdToProbeColor.get(graph.source_component_id) : void 0;
10572
+ const color = graph.color ?? probeColor ?? paletteColor ?? FALLBACK_LINE_COLOR;
10573
+ const probeName = graph.source_component_id ? sourceComponentIdToProbeName.get(graph.source_component_id) : void 0;
10574
+ const label = probeName ? `V(${probeName})` : graph.name || (graph.source_component_id ? `Probe ${graph.source_component_id}` : graph.simulation_transient_voltage_graph_id);
10531
10575
  return { graph, points, color, label };
10532
10576
  }).filter((entry) => entry.points.length > 0);
10533
10577
  }
@@ -10911,8 +10955,8 @@ function createDataGroup(graphs, clipPathId, scaleX, scaleY) {
10911
10955
  "clip-path": `url(#${clipPathId})`,
10912
10956
  "data-simulation-transient-voltage-graph-id": entry.graph.simulation_transient_voltage_graph_id
10913
10957
  };
10914
- if (entry.graph.schematic_voltage_probe_id) {
10915
- baseAttributes["data-schematic-voltage-probe-id"] = entry.graph.schematic_voltage_probe_id;
10958
+ if (entry.graph.source_component_id) {
10959
+ baseAttributes["data-source-component-id"] = entry.graph.source_component_id;
10916
10960
  }
10917
10961
  if (entry.graph.subcircuit_connectivity_map_key) {
10918
10962
  baseAttributes["data-subcircuit-connectivity-map-key"] = entry.graph.subcircuit_connectivity_map_key;