circuit-to-svg 0.0.165 → 0.0.166

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/README.md CHANGED
@@ -72,6 +72,11 @@ writeFileSync('board.svg', pcbSvg)
72
72
 
73
73
  Converts a schematic circuit description to an SVG string.
74
74
 
75
+ #### Options
76
+
77
+ - `includeVersion` – if `true`, add a `data-circuit-to-svg-version` attribute to
78
+ the root `<svg>`.
79
+
75
80
  ### convertCircuitJsonToPcbSvg
76
81
 
77
82
  `convertCircuitJsonToPcbSvg(circuitJson: AnyCircuitElement[], options?): string`
@@ -87,6 +92,8 @@ Converts a PCB layout description to an SVG string.
87
92
  `"#000"`.
88
93
  - `drawPaddingOutsideBoard` – if `false`, omit the board outline and extra
89
94
  padding around it. Defaults to `true`.
95
+ - `includeVersion` – if `true`, add a `data-circuit-to-svg-version` attribute to
96
+ the root `<svg>`.
90
97
 
91
98
  ### convertCircuitJsonToAssemblySvg
92
99
 
@@ -97,6 +104,8 @@ Converts circuit JSON into an assembly view of the board and components.
97
104
  #### Options
98
105
 
99
106
  - `width` and `height` – dimensions of the output SVG. Defaults to `800x600`.
107
+ - `includeVersion` – if `true`, add a `data-circuit-to-svg-version` attribute to
108
+ the root `<svg>`.
100
109
 
101
110
  ## Contributing
102
111
 
package/dist/index.d.ts CHANGED
@@ -40,6 +40,7 @@ interface Options$3 {
40
40
  matchBoardAspectRatio?: boolean;
41
41
  backgroundColor?: string;
42
42
  drawPaddingOutsideBoard?: boolean;
43
+ includeVersion?: boolean;
43
44
  }
44
45
  interface PcbContext {
45
46
  transform: Matrix;
@@ -57,6 +58,7 @@ declare const circuitJsonToPcbSvg: typeof convertCircuitJsonToPcbSvg;
57
58
  interface Options$2 {
58
59
  width?: number;
59
60
  height?: number;
61
+ includeVersion?: boolean;
60
62
  }
61
63
  interface AssemblySvgContext {
62
64
  transform: Matrix;
@@ -239,6 +241,7 @@ interface Options$1 {
239
241
  y: number;
240
242
  label: string;
241
243
  }>;
244
+ includeVersion?: boolean;
242
245
  }
243
246
  declare function convertCircuitJsonToSchematicSvg(circuitJson: AnyCircuitElement[], options?: Options$1): string;
244
247
  /**
@@ -250,9 +253,12 @@ interface Options {
250
253
  layer: "top" | "bottom";
251
254
  width?: number;
252
255
  height?: number;
256
+ includeVersion?: boolean;
253
257
  }
254
258
  declare function convertCircuitJsonToSolderPasteMask(circuitJson: AnyCircuitElement[], options: Options): string;
255
259
 
256
260
  declare function getSoftwareUsedString(circuitJson: AnyCircuitElement[]): string | undefined;
257
261
 
258
- export { type AssemblySvgContext, type ColorMap, type ColorOverrides, type PcbColorMap, type PcbColorOverrides, type PcbContext, circuitJsonToPcbSvg, circuitJsonToSchematicSvg, convertCircuitJsonToAssemblySvg, convertCircuitJsonToPcbSvg, convertCircuitJsonToSchematicSvg, convertCircuitJsonToSolderPasteMask, getSoftwareUsedString };
262
+ declare const CIRCUIT_TO_SVG_VERSION: string;
263
+
264
+ export { type AssemblySvgContext, CIRCUIT_TO_SVG_VERSION, type ColorMap, type ColorOverrides, type PcbColorMap, type PcbColorOverrides, type PcbContext, circuitJsonToPcbSvg, circuitJsonToSchematicSvg, convertCircuitJsonToAssemblySvg, convertCircuitJsonToPcbSvg, convertCircuitJsonToSchematicSvg, convertCircuitJsonToSolderPasteMask, getSoftwareUsedString };
package/dist/index.js CHANGED
@@ -1442,6 +1442,72 @@ function getSoftwareUsedString(circuitJson) {
1442
1442
  return metadata?.software_used_string;
1443
1443
  }
1444
1444
 
1445
+ // package.json
1446
+ var package_default = {
1447
+ name: "circuit-to-svg",
1448
+ type: "module",
1449
+ version: "0.0.165",
1450
+ description: "Convert Circuit JSON to SVG",
1451
+ main: "dist/index.js",
1452
+ files: [
1453
+ "dist"
1454
+ ],
1455
+ scripts: {
1456
+ start: "storybook dev -p 6006",
1457
+ prepublish: "npm run build",
1458
+ build: "tsup-node ./lib/index.ts --format esm --dts --sourcemap",
1459
+ format: "biome format . --write",
1460
+ "format:check": "biome format .",
1461
+ storybook: "storybook dev -p 6006",
1462
+ "build-storybook": "storybook build"
1463
+ },
1464
+ license: "ISC",
1465
+ devDependencies: {
1466
+ "@biomejs/biome": "^1.9.4",
1467
+ "@chromatic-com/storybook": "^1.6.1",
1468
+ "@storybook/addon-essentials": "^8.2.5",
1469
+ "@storybook/addon-interactions": "^8.2.5",
1470
+ "@storybook/addon-links": "^8.2.5",
1471
+ "@storybook/addon-onboarding": "^8.2.5",
1472
+ "@storybook/blocks": "^8.2.5",
1473
+ "@storybook/react": "^8.2.5",
1474
+ "@storybook/react-vite": "^8.2.5",
1475
+ "@storybook/test": "^8.2.5",
1476
+ "@tscircuit/core": "0.0.477",
1477
+ "@tscircuit/plop": "^0.0.10",
1478
+ "@types/bun": "^1.2.8",
1479
+ biome: "^0.3.3",
1480
+ "bun-match-svg": "^0.0.6",
1481
+ "circuit-json": "^0.0.218",
1482
+ esbuild: "^0.20.2",
1483
+ "performance-now": "^2.1.0",
1484
+ react: "^18.3.1",
1485
+ "schematic-symbols": "^0.0.153",
1486
+ storybook: "^8.2.5",
1487
+ tsup: "^8.0.2",
1488
+ typescript: "^5.4.5",
1489
+ "vite-tsconfig-paths": "^5.0.1",
1490
+ "@tscircuit/checks": "^0.0.44",
1491
+ "@tscircuit/circuit-json-util": "^0.0.47",
1492
+ "@tscircuit/footprinter": "^0.0.91"
1493
+ },
1494
+ peerDependencies: {
1495
+ "circuit-json": "*",
1496
+ "@tscircuit/circuit-json-util": "*",
1497
+ "@tscircuit/footprinter": "*",
1498
+ "schematic-symbols": "*"
1499
+ },
1500
+ dependencies: {
1501
+ "@types/node": "^22.5.5",
1502
+ "bun-types": "^1.1.40",
1503
+ svgson: "^5.3.1",
1504
+ "transformation-matrix": "^2.16.1"
1505
+ }
1506
+ };
1507
+
1508
+ // lib/package-version.ts
1509
+ var CIRCUIT_TO_SVG_VERSION = package_default.version;
1510
+
1445
1511
  // lib/pcb/convert-circuit-json-to-pcb-svg.ts
1446
1512
  var OBJECT_ORDER = [
1447
1513
  "pcb_trace_error",
@@ -1641,6 +1707,7 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
1641
1707
  }
1642
1708
  children.push(...svgObjects);
1643
1709
  const softwareUsedString = getSoftwareUsedString(circuitJson);
1710
+ const version = CIRCUIT_TO_SVG_VERSION;
1644
1711
  const svgObject = {
1645
1712
  name: "svg",
1646
1713
  type: "element",
@@ -1650,6 +1717,9 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
1650
1717
  height: svgHeight.toString(),
1651
1718
  ...softwareUsedString && {
1652
1719
  "data-software-used-string": softwareUsedString
1720
+ },
1721
+ ...options?.includeVersion && {
1722
+ "data-circuit-to-svg-version": version
1653
1723
  }
1654
1724
  },
1655
1725
  value: "",
@@ -2470,6 +2540,7 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
2470
2540
  (a, b) => (OBJECT_ORDER2.indexOf(b.type) ?? 9999) - (OBJECT_ORDER2.indexOf(a.type) ?? 9999)
2471
2541
  ).flatMap((item) => createSvgObjects2(item, ctx, soup));
2472
2542
  const softwareUsedString = getSoftwareUsedString(soup);
2543
+ const version = CIRCUIT_TO_SVG_VERSION;
2473
2544
  const svgObject = {
2474
2545
  name: "svg",
2475
2546
  type: "element",
@@ -2479,6 +2550,9 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
2479
2550
  height: svgHeight.toString(),
2480
2551
  ...softwareUsedString && {
2481
2552
  "data-software-used-string": softwareUsedString
2553
+ },
2554
+ ...options?.includeVersion && {
2555
+ "data-circuit-to-svg-version": version
2482
2556
  }
2483
2557
  },
2484
2558
  value: "",
@@ -5874,6 +5948,7 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
5874
5948
  );
5875
5949
  }
5876
5950
  const softwareUsedString = getSoftwareUsedString(circuitJson);
5951
+ const version = CIRCUIT_TO_SVG_VERSION;
5877
5952
  const svgObject = {
5878
5953
  name: "svg",
5879
5954
  type: "element",
@@ -5885,6 +5960,9 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
5885
5960
  "data-real-to-screen-transform": toSVG(transform),
5886
5961
  ...softwareUsedString && {
5887
5962
  "data-software-used-string": softwareUsedString
5963
+ },
5964
+ ...options?.includeVersion && {
5965
+ "data-circuit-to-svg-version": version
5888
5966
  }
5889
5967
  },
5890
5968
  children: [
@@ -6072,6 +6150,7 @@ function convertCircuitJsonToSolderPasteMask(circuitJson, options) {
6072
6150
  (a, b) => (OBJECT_ORDER3.indexOf(b.type) ?? 9999) - (OBJECT_ORDER3.indexOf(a.type) ?? 9999)
6073
6151
  ).flatMap((item) => createSvgObjects3({ elm: item, ctx }));
6074
6152
  const softwareUsedString = getSoftwareUsedString(circuitJson);
6153
+ const version = CIRCUIT_TO_SVG_VERSION;
6075
6154
  const svgObject = {
6076
6155
  name: "svg",
6077
6156
  type: "element",
@@ -6081,6 +6160,9 @@ function convertCircuitJsonToSolderPasteMask(circuitJson, options) {
6081
6160
  height: svgHeight.toString(),
6082
6161
  ...softwareUsedString && {
6083
6162
  "data-software-used-string": softwareUsedString
6163
+ },
6164
+ ...options.includeVersion && {
6165
+ "data-circuit-to-svg-version": version
6084
6166
  }
6085
6167
  },
6086
6168
  value: "",
@@ -6170,6 +6252,7 @@ function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
6170
6252
  };
6171
6253
  }
6172
6254
  export {
6255
+ CIRCUIT_TO_SVG_VERSION,
6173
6256
  circuitJsonToPcbSvg,
6174
6257
  circuitJsonToSchematicSvg,
6175
6258
  convertCircuitJsonToAssemblySvg,