circuit-to-svg 0.0.269 → 0.0.271

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
@@ -2804,10 +2804,25 @@ function createSvgObjectsFromPcbPanel(pcbPanel, ctx) {
2804
2804
  const { transform, colorMap: colorMap2, showSolderMask } = ctx;
2805
2805
  const width = Number(pcbPanel.width);
2806
2806
  const height = Number(pcbPanel.height);
2807
- const topLeft = applyToPoint22(transform, [0, 0]);
2808
- const topRight = applyToPoint22(transform, [width, 0]);
2809
- const bottomRight = applyToPoint22(transform, [width, height]);
2810
- const bottomLeft = applyToPoint22(transform, [0, height]);
2807
+ const center = pcbPanel.center ?? { x: width / 2, y: height / 2 };
2808
+ const halfWidth = width / 2;
2809
+ const halfHeight = height / 2;
2810
+ const topLeft = applyToPoint22(transform, [
2811
+ center.x - halfWidth,
2812
+ center.y - halfHeight
2813
+ ]);
2814
+ const topRight = applyToPoint22(transform, [
2815
+ center.x + halfWidth,
2816
+ center.y - halfHeight
2817
+ ]);
2818
+ const bottomRight = applyToPoint22(transform, [
2819
+ center.x + halfWidth,
2820
+ center.y + halfHeight
2821
+ ]);
2822
+ const bottomLeft = applyToPoint22(transform, [
2823
+ center.x - halfWidth,
2824
+ center.y + halfHeight
2825
+ ]);
2811
2826
  const path = `M ${topLeft[0]} ${topLeft[1]} L ${topRight[0]} ${topRight[1]} L ${bottomRight[0]} ${bottomRight[1]} L ${bottomLeft[0]} ${bottomLeft[1]} Z`;
2812
2827
  const isCoveredWithSolderMask = pcbPanel.covered_with_solder_mask !== false;
2813
2828
  const shouldshowSolderMask = Boolean(
@@ -3963,7 +3978,7 @@ function getSoftwareUsedString(circuitJson) {
3963
3978
  var package_default = {
3964
3979
  name: "circuit-to-svg",
3965
3980
  type: "module",
3966
- version: "0.0.268",
3981
+ version: "0.0.270",
3967
3982
  description: "Convert Circuit JSON to SVG",
3968
3983
  main: "dist/index.js",
3969
3984
  files: [
@@ -3987,7 +4002,7 @@ var package_default = {
3987
4002
  "bun-match-svg": "^0.0.12",
3988
4003
  esbuild: "^0.20.2",
3989
4004
  "performance-now": "^2.1.0",
3990
- "circuit-json": "^0.0.309",
4005
+ "circuit-json": "^0.0.315",
3991
4006
  react: "19.1.0",
3992
4007
  "react-cosmos": "7.0.0",
3993
4008
  "react-cosmos-plugin-vite": "7.0.0",
@@ -4184,7 +4199,7 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
4184
4199
  if (width === void 0 || height === void 0) {
4185
4200
  continue;
4186
4201
  }
4187
- const center = { x: width / 2, y: height / 2 };
4202
+ const center = panel.center ?? { x: width / 2, y: height / 2 };
4188
4203
  updateBounds(center, width, height);
4189
4204
  } else if (circuitJsonElm.type === "pcb_board") {
4190
4205
  if (circuitJsonElm.outline && Array.isArray(circuitJsonElm.outline) && circuitJsonElm.outline.length >= 3) {
@@ -8900,6 +8915,7 @@ function createSvgObjectsFromSchVoltageProbe({
8900
8915
  probe.position.x,
8901
8916
  probe.position.y
8902
8917
  ]);
8918
+ const probeColor = probe.color ?? colorMap2.schematic.reference;
8903
8919
  const arrowLength = Math.abs(transform.a) * 0.6;
8904
8920
  const arrowWidth = Math.abs(transform.a) * 0.28;
8905
8921
  const baseX = screenX + arrowLength * Math.cos(-50 * Math.PI / 180);
@@ -8974,8 +8990,8 @@ function createSvgObjectsFromSchVoltageProbe({
8974
8990
  type: "element",
8975
8991
  attributes: {
8976
8992
  d: arrowPath,
8977
- stroke: colorMap2.schematic.reference,
8978
- fill: colorMap2.schematic.reference,
8993
+ stroke: probeColor,
8994
+ fill: probeColor,
8979
8995
  "stroke-width": `${getSchStrokeSize(transform)}px`
8980
8996
  },
8981
8997
  value: "",
@@ -8988,7 +9004,7 @@ function createSvgObjectsFromSchVoltageProbe({
8988
9004
  attributes: {
8989
9005
  x,
8990
9006
  y: baseY.toString(),
8991
- fill: colorMap2.schematic.reference,
9007
+ fill: probeColor,
8992
9008
  "text-anchor": "start",
8993
9009
  "dominant-baseline": "middle",
8994
9010
  "font-family": "sans-serif",
@@ -10554,19 +10570,23 @@ function convertCircuitJsonToSimulationGraphSvg({
10554
10570
  function prepareSimulationGraphs(graphs, circuitJson) {
10555
10571
  const palette = Array.isArray(colorMap.palette) ? colorMap.palette : [];
10556
10572
  const voltageProbes = circuitJson.filter(isSimulationVoltageProbe);
10557
- const probeIdToName = /* @__PURE__ */ new Map();
10573
+ const sourceComponentIdToProbeName = /* @__PURE__ */ new Map();
10574
+ const sourceComponentIdToProbeColor = /* @__PURE__ */ new Map();
10558
10575
  for (const probe of voltageProbes) {
10559
- if (probe.name && probe.simulation_voltage_probe_id) {
10560
- probeIdToName.set(probe.simulation_voltage_probe_id, probe.name);
10576
+ if (probe.name && probe.source_component_id) {
10577
+ sourceComponentIdToProbeName.set(probe.source_component_id, probe.name);
10578
+ }
10579
+ if (probe.color && probe.source_component_id) {
10580
+ sourceComponentIdToProbeColor.set(probe.source_component_id, probe.color);
10561
10581
  }
10562
10582
  }
10563
10583
  return graphs.map((graph, index) => {
10564
10584
  const points = createGraphPoints(graph);
10565
10585
  const paletteColor = palette.length > 0 ? palette[index % palette.length] : FALLBACK_LINE_COLOR;
10566
- const color = paletteColor ?? FALLBACK_LINE_COLOR;
10567
- const probeId = graph.simulation_voltage_probe_id ?? graph.schematic_voltage_probe_id;
10568
- const probeName = probeId ? probeIdToName.get(probeId) : void 0;
10569
- const label = probeName ? `V(${probeName})` : graph.name || (probeId ? `Probe ${probeId}` : graph.simulation_transient_voltage_graph_id);
10586
+ const probeColor = graph.source_component_id ? sourceComponentIdToProbeColor.get(graph.source_component_id) : void 0;
10587
+ const color = graph.color ?? probeColor ?? paletteColor ?? FALLBACK_LINE_COLOR;
10588
+ const probeName = graph.source_component_id ? sourceComponentIdToProbeName.get(graph.source_component_id) : void 0;
10589
+ const label = probeName ? `V(${probeName})` : graph.name || (graph.source_component_id ? `Probe ${graph.source_component_id}` : graph.simulation_transient_voltage_graph_id);
10570
10590
  return { graph, points, color, label };
10571
10591
  }).filter((entry) => entry.points.length > 0);
10572
10592
  }
@@ -10950,8 +10970,8 @@ function createDataGroup(graphs, clipPathId, scaleX, scaleY) {
10950
10970
  "clip-path": `url(#${clipPathId})`,
10951
10971
  "data-simulation-transient-voltage-graph-id": entry.graph.simulation_transient_voltage_graph_id
10952
10972
  };
10953
- if (entry.graph.schematic_voltage_probe_id) {
10954
- baseAttributes["data-schematic-voltage-probe-id"] = entry.graph.schematic_voltage_probe_id;
10973
+ if (entry.graph.source_component_id) {
10974
+ baseAttributes["data-source-component-id"] = entry.graph.source_component_id;
10955
10975
  }
10956
10976
  if (entry.graph.subcircuit_connectivity_map_key) {
10957
10977
  baseAttributes["data-subcircuit-connectivity-map-key"] = entry.graph.subcircuit_connectivity_map_key;
@@ -11286,7 +11306,8 @@ function convertCircuitJsonToSolderPasteMask(circuitJson, options) {
11286
11306
  const width = distance2.parse(panel.width);
11287
11307
  const height = distance2.parse(panel.height);
11288
11308
  if (width !== void 0 && height !== void 0) {
11289
- updateBounds({ x: width / 2, y: height / 2 }, width, height);
11309
+ const center = panel.center ?? { x: width / 2, y: height / 2 };
11310
+ updateBounds(center, width, height);
11290
11311
  }
11291
11312
  } else if (item.type === "pcb_solder_paste" && "x" in item && "y" in item) {
11292
11313
  updateBounds({ x: item.x, y: item.y }, 0, 0);