circuit-to-svg 0.0.159 → 0.0.161

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
@@ -3622,6 +3622,18 @@ var createSvgSchErrorText = ({
3622
3622
  };
3623
3623
  };
3624
3624
 
3625
+ // lib/utils/is-source-port-connected.ts
3626
+ var isSourcePortConnected = (circuitJson, sourcePortId) => {
3627
+ for (const elm of circuitJson) {
3628
+ if (elm.type !== "source_trace") continue;
3629
+ const trace = elm;
3630
+ if (Array.isArray(trace.connected_source_port_ids) && trace.connected_source_port_ids.includes(sourcePortId)) {
3631
+ return true;
3632
+ }
3633
+ }
3634
+ return false;
3635
+ };
3636
+
3625
3637
  // lib/sch/svg-object-fns/create-svg-objects-from-sch-component-with-symbol.ts
3626
3638
  var ninePointAnchorToTextAnchor2 = {
3627
3639
  top_left: "start",
@@ -3681,6 +3693,12 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
3681
3693
  const texts = symbol.primitives.filter((p) => p.type === "text");
3682
3694
  const circles = symbol.primitives.filter((p) => p.type === "circle");
3683
3695
  const boxes = symbol.primitives.filter((p) => p.type === "box");
3696
+ const connectedSymbolPorts = /* @__PURE__ */ new Set();
3697
+ for (const match of schPortsWithSymbolPorts) {
3698
+ if (isSourcePortConnected(circuitJson, match.schPort.source_port_id)) {
3699
+ connectedSymbolPorts.add(match.symbolPort);
3700
+ }
3701
+ }
3684
3702
  const bounds = {
3685
3703
  minX: Math.min(...paths.flatMap((p) => p.points.map((pt) => pt.x))),
3686
3704
  maxX: Math.max(...paths.flatMap((p) => p.points.map((pt) => pt.x))),
@@ -3805,6 +3823,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
3805
3823
  });
3806
3824
  }
3807
3825
  for (const port of symbol.ports) {
3826
+ if (connectedSymbolPorts.has(port)) continue;
3808
3827
  const screenPortPos = applyToPoint26(
3809
3828
  compose7(realToScreenTransform, transformFromSymbolToReal),
3810
3829
  port
@@ -3921,19 +3940,22 @@ var createSvgObjectsForSchPortBoxLine = ({
3921
3940
  value: "",
3922
3941
  children: []
3923
3942
  });
3924
- svgObjects.push({
3925
- name: "circle",
3926
- type: "element",
3927
- attributes: {
3928
- class: "component-pin",
3929
- cx: screenSchPortPos.x.toString(),
3930
- cy: screenSchPortPos.y.toString(),
3931
- r: (Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM).toString(),
3932
- "stroke-width": `${getSchStrokeSize(transform)}px`
3933
- },
3934
- value: "",
3935
- children: []
3936
- });
3943
+ const isConnected = isSourcePortConnected(circuitJson, schPort.source_port_id);
3944
+ if (!isConnected) {
3945
+ svgObjects.push({
3946
+ name: "circle",
3947
+ type: "element",
3948
+ attributes: {
3949
+ class: "component-pin",
3950
+ cx: screenSchPortPos.x.toString(),
3951
+ cy: screenSchPortPos.y.toString(),
3952
+ r: (Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM).toString(),
3953
+ "stroke-width": `${getSchStrokeSize(transform)}px`
3954
+ },
3955
+ value: "",
3956
+ children: []
3957
+ });
3958
+ }
3937
3959
  return svgObjects;
3938
3960
  };
3939
3961
 
@@ -4003,6 +4025,8 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
4003
4025
  const screenPinNumberTextPos = applyToPoint29(transform, realPinNumberPos);
4004
4026
  const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
4005
4027
  if (!label) return [];
4028
+ const isNegated = label.startsWith("N_");
4029
+ const displayLabel = isNegated ? label.slice(2) : label;
4006
4030
  svgObjects.push({
4007
4031
  name: "text",
4008
4032
  type: "element",
@@ -4010,7 +4034,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
4010
4034
  class: "pin-number",
4011
4035
  x: screenPinNumberTextPos.x.toString(),
4012
4036
  y: screenPinNumberTextPos.y.toString(),
4013
- style: "font-family: sans-serif;",
4037
+ style: `font-family: sans-serif;${isNegated ? " text-decoration: overline;" : ""}`,
4014
4038
  fill: colorMap.schematic.pin_number,
4015
4039
  "text-anchor": schPort.side_of_component === "left" || schPort.side_of_component === "bottom" ? "start" : "end",
4016
4040
  "dominant-baseline": "middle",
@@ -4020,7 +4044,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
4020
4044
  children: [
4021
4045
  {
4022
4046
  type: "text",
4023
- value: label || "",
4047
+ value: displayLabel || "",
4024
4048
  name: "",
4025
4049
  attributes: {},
4026
4050
  children: []
@@ -4572,6 +4596,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
4572
4596
  colorMap: colorMap2
4573
4597
  }) => {
4574
4598
  if (!schNetLabel.text) return [];
4599
+ const isNegated = schNetLabel.text.startsWith("N_");
4600
+ const labelText = isNegated ? schNetLabel.text.slice(2) : schNetLabel.text;
4575
4601
  const svgObjects = [];
4576
4602
  const symbol = symbols3[schNetLabel.symbol_name];
4577
4603
  if (!symbol) {
@@ -4595,8 +4621,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
4595
4621
  maxY: Math.max(...symbolPaths.flatMap((p) => p.points.map((pt) => pt.y)))
4596
4622
  };
4597
4623
  const fontSizeMm = getSchMmFontSize("net_label");
4598
- const textWidthFSR = estimateTextWidth(schNetLabel.text || "");
4599
- const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * schNetLabel.text.length + END_PADDING_FSR;
4624
+ const textWidthFSR = estimateTextWidth(labelText || "");
4625
+ const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
4600
4626
  const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
4601
4627
  schNetLabel.anchor_side
4602
4628
  );
@@ -4697,7 +4723,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
4697
4723
  );
4698
4724
  let textValue = text.text;
4699
4725
  if (textValue === "{REF}") {
4700
- textValue = schNetLabel.text || "";
4726
+ textValue = labelText || "";
4701
4727
  } else if (textValue === "{VAL}") {
4702
4728
  textValue = "";
4703
4729
  }
@@ -4717,7 +4743,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
4717
4743
  "font-family": "sans-serif",
4718
4744
  "text-anchor": ninePointAnchorToTextAnchor[text.anchor],
4719
4745
  "dominant-baseline": ninePointAnchorToDominantBaseline[text.anchor],
4720
- "font-size": `${getSchScreenFontSize(realToScreenTransform, "reference_designator")}px`
4746
+ "font-size": `${getSchScreenFontSize(realToScreenTransform, "reference_designator")}px`,
4747
+ ...isNegated && textValue === labelText ? { style: "text-decoration: overline;" } : {}
4721
4748
  },
4722
4749
  children: [
4723
4750
  {
@@ -4788,6 +4815,8 @@ var createSvgObjectsForSchNetLabel = ({
4788
4815
  colorMap: colorMap2
4789
4816
  }) => {
4790
4817
  if (!schNetLabel.text) return [];
4818
+ const isNegated = schNetLabel.text.startsWith("N_");
4819
+ const labelText = isNegated ? schNetLabel.text.slice(2) : schNetLabel.text;
4791
4820
  if (schNetLabel.symbol_name) {
4792
4821
  return createSvgObjectsForSchNetLabelWithSymbol({
4793
4822
  schNetLabel,
@@ -4798,14 +4827,14 @@ var createSvgObjectsForSchNetLabel = ({
4798
4827
  const svgObjects = [];
4799
4828
  const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
4800
4829
  const fontSizeMm = getSchMmFontSize("net_label");
4801
- const textWidthFSR = estimateTextWidth(schNetLabel.text || "");
4830
+ const textWidthFSR = estimateTextWidth(labelText || "");
4802
4831
  const screenCenter = applyToPoint37(realToScreenTransform, schNetLabel.center);
4803
4832
  const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
4804
4833
  schNetLabel.anchor_side
4805
4834
  );
4806
4835
  const screenTextGrowthVec = { ...realTextGrowthVec };
4807
4836
  screenTextGrowthVec.y *= -1;
4808
- const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * schNetLabel.text.length + END_PADDING_FSR;
4837
+ const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
4809
4838
  const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint37(realToScreenTransform, schNetLabel.anchor_position) : {
4810
4839
  x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
4811
4840
  y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
@@ -4833,12 +4862,12 @@ var createSvgObjectsForSchNetLabel = ({
4833
4862
  },
4834
4863
  // Top right corner in font-relative coordinates
4835
4864
  {
4836
- x: ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_FSR + END_PADDING_EXTRA_PER_CHARACTER_FSR * schNetLabel.text.length + textWidthFSR,
4865
+ x: ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_FSR + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + textWidthFSR,
4837
4866
  y: 0.6
4838
4867
  },
4839
4868
  // Bottom right corner in font-relative coordinates
4840
4869
  {
4841
- x: ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_FSR + END_PADDING_EXTRA_PER_CHARACTER_FSR * schNetLabel.text.length + textWidthFSR,
4870
+ x: ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_FSR + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + textWidthFSR,
4842
4871
  y: -0.6
4843
4872
  },
4844
4873
  // Bottom left corner in font-relative coordinates
@@ -4907,12 +4936,13 @@ var createSvgObjectsForSchNetLabel = ({
4907
4936
  "font-family": "sans-serif",
4908
4937
  "font-variant-numeric": "tabular-nums",
4909
4938
  "font-size": `${fontSizePx}px`,
4910
- transform: textTransformString
4939
+ transform: textTransformString,
4940
+ ...isNegated ? { style: "text-decoration: overline;" } : {}
4911
4941
  },
4912
4942
  children: [
4913
4943
  {
4914
4944
  type: "text",
4915
- value: schNetLabel.text || "",
4945
+ value: labelText || "",
4916
4946
  name: "",
4917
4947
  attributes: {},
4918
4948
  children: []