circuit-to-svg 0.0.413 → 0.0.415

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
@@ -7745,7 +7745,7 @@ function getSoftwareUsedString(circuitJson) {
7745
7745
  var package_default = {
7746
7746
  name: "circuit-to-svg",
7747
7747
  type: "module",
7748
- version: "0.0.412",
7748
+ version: "0.0.414",
7749
7749
  repository: {
7750
7750
  type: "git",
7751
7751
  url: "https://github.com/tscircuit/circuit-to-svg.git"
@@ -7775,7 +7775,7 @@ var package_default = {
7775
7775
  "@vitejs/plugin-react": "5.0.0",
7776
7776
  biome: "^0.3.3",
7777
7777
  "bun-match-svg": "^0.0.12",
7778
- "circuit-json": "^0.0.479",
7778
+ "circuit-json": "^0.0.486",
7779
7779
  esbuild: "^0.20.2",
7780
7780
  "format-si-unit": "^0.0.12",
7781
7781
  "performance-now": "^2.1.0",
@@ -14034,6 +14034,34 @@ var createSvgObjectsForSchPortIndicator = ({
14034
14034
  return svgObjects;
14035
14035
  };
14036
14036
 
14037
+ // lib/utils/create-svg-text-parts.ts
14038
+ var createSvgTextPart = (part) => ({
14039
+ type: "element",
14040
+ name: "tspan",
14041
+ value: "",
14042
+ attributes: part.is_overlined ? { "text-decoration": "overline" } : {},
14043
+ children: [
14044
+ {
14045
+ type: "text",
14046
+ name: "",
14047
+ value: part.text,
14048
+ attributes: {},
14049
+ children: []
14050
+ }
14051
+ ]
14052
+ });
14053
+ var createSvgTextParts = (parts) => parts.filter((part) => part.text).map(createSvgTextPart);
14054
+ var createSvgTextPartLines = (parts) => {
14055
+ const lines = [[]];
14056
+ for (const part of parts) {
14057
+ part.text.split("\n").forEach((text, index) => {
14058
+ if (index > 0) lines.push([]);
14059
+ if (text) lines.at(-1).push(createSvgTextPart({ ...part, text }));
14060
+ });
14061
+ }
14062
+ return lines;
14063
+ };
14064
+
14037
14065
  // lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
14038
14066
  import { applyToPoint as applyToPoint70 } from "transformation-matrix";
14039
14067
  var createSvgSchText = ({
@@ -14073,7 +14101,8 @@ var createSvgSchText = ({
14073
14101
  center_left: "middle"
14074
14102
  };
14075
14103
  const lines = elm.text.split("\n");
14076
- const children = lines.length === 1 ? [
14104
+ const styledLines = createSvgTextPartLines(elm.text_parts ?? []);
14105
+ const children = lines.length === 1 ? elm.text_parts?.length ? styledLines[0] : [
14077
14106
  {
14078
14107
  type: "text",
14079
14108
  value: elm.text,
@@ -14089,7 +14118,7 @@ var createSvgSchText = ({
14089
14118
  x: center.x.toString(),
14090
14119
  ...idx > 0 ? { dy: "1em" } : {}
14091
14120
  },
14092
- children: [
14121
+ children: elm.text_parts?.length ? styledLines[idx] ?? [] : [
14093
14122
  {
14094
14123
  type: "text",
14095
14124
  value: line,
@@ -14847,6 +14876,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
14847
14876
  if (!label) return [];
14848
14877
  const isNegated = label.startsWith("N_");
14849
14878
  const displayLabel = isNegated ? label.slice(2) : label;
14879
+ const textParts = schPort.display_pin_label_text_parts;
14850
14880
  const is_drawn_with_inversion_circle = schPort.is_drawn_with_inversion_circle ?? false;
14851
14881
  const fontSizePx = getSchScreenFontSize(
14852
14882
  transform,
@@ -14860,14 +14890,14 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
14860
14890
  class: labelClassName,
14861
14891
  x: screenPinNumberTextPos.x.toString(),
14862
14892
  y: screenPinNumberTextPos.y.toString(),
14863
- style: `font-family: sans-serif;${isNegated ? " text-decoration: overline;" : ""}`,
14893
+ style: `font-family: sans-serif;${isNegated && !textParts?.length ? " text-decoration: overline;" : ""}`,
14864
14894
  fill: labelColor,
14865
14895
  "text-anchor": schPort.side_of_component === "left" || schPort.side_of_component === "bottom" ? "start" : "end",
14866
14896
  "dominant-baseline": "middle",
14867
14897
  "font-size": `${fontSizePx}px`,
14868
14898
  transform: schPort.side_of_component === "top" || schPort.side_of_component === "bottom" ? `rotate(-90 ${screenPinNumberTextPos.x} ${screenPinNumberTextPos.y})` : ""
14869
14899
  },
14870
- children: [
14900
+ children: textParts?.length ? createSvgTextParts(textParts) : [
14871
14901
  {
14872
14902
  type: "text",
14873
14903
  value: displayLabel || "",