circuit-json-to-tscircuit 0.0.70 → 0.0.72

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.
@@ -493,6 +493,7 @@ var isNonCollinear = ({
493
493
  // lib/generate-board-schematic-tsx/convert-symbol-primitives.ts
494
494
  import { schematic_text as schematic_text2 } from "circuit-json";
495
495
  import { applyToPoint as applyToPoint4 } from "transformation-matrix";
496
+ var DEFAULT_SYMBOL_CIRCLE_STROKE_WIDTH = 0.02;
496
497
  var anchors = {
497
498
  middle_top: "top_center",
498
499
  middle_bottom: "bottom_center",
@@ -545,6 +546,7 @@ var convertSymbolPrimitives = ({
545
546
  return formatElement("schematiccircle", {
546
547
  center,
547
548
  radius: Math.hypot(radiusVector.x, radiusVector.y),
549
+ strokeWidth: DEFAULT_SYMBOL_CIRCLE_STROKE_WIDTH,
548
550
  isFilled: primitive.fill
549
551
  });
550
552
  }
@@ -726,7 +728,7 @@ var convertNetLabels = (circuitJson) => su4(circuitJson).schematic_net_label.lis
726
728
  anchorPosition.x,
727
729
  anchorPosition.y
728
730
  ),
729
- reference: "",
731
+ reference: schematicNetLabel.text,
730
732
  displayText: schematicNetLabel.text
731
733
  });
732
734
  }
package/dist/cli/main.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  convertCircuitJsonToTscircuit
4
- } from "../chunk-7VW2746G.js";
4
+ } from "../chunk-2BNMFKVO.js";
5
5
 
6
6
  // cli/main.ts
7
7
  import { Command } from "commander";
@@ -16,7 +16,7 @@ var package_default = {
16
16
  "./cli": "./dist/cli/main.js"
17
17
  },
18
18
  type: "module",
19
- version: "0.0.69",
19
+ version: "0.0.71",
20
20
  repository: {
21
21
  type: "git",
22
22
  url: "https://github.com/tscircuit/circuit-json-to-tscircuit.git"
package/dist/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  convertCircuitJsonToTscircuit
3
- } from "../chunk-7VW2746G.js";
3
+ } from "../chunk-2BNMFKVO.js";
4
4
  export {
5
5
  convertCircuitJsonToTscircuit
6
6
  };
@@ -22,7 +22,7 @@ export const convertNetLabels: SchematicElementConverter = (circuitJson) =>
22
22
  anchorPosition.x,
23
23
  anchorPosition.y,
24
24
  ),
25
- reference: "",
25
+ reference: schematicNetLabel.text,
26
26
  displayText: schematicNetLabel.text,
27
27
  })
28
28
  }
@@ -3,6 +3,10 @@ import type { SchSymbol } from "schematic-symbols"
3
3
  import { applyToPoint, type Matrix } from "transformation-matrix"
4
4
  import { formatElement } from "./format-attributes"
5
5
 
6
+ // Circuit JSON symbol primitives do not encode a stroke width. This matches
7
+ // the component outline width used by circuit-to-svg.
8
+ const DEFAULT_SYMBOL_CIRCLE_STROKE_WIDTH = 0.02
9
+
6
10
  const anchors = {
7
11
  middle_top: "top_center",
8
12
  middle_bottom: "bottom_center",
@@ -68,6 +72,7 @@ export const convertSymbolPrimitives = ({
68
72
  return formatElement("schematiccircle", {
69
73
  center,
70
74
  radius: Math.hypot(radiusVector.x, radiusVector.y),
75
+ strokeWidth: DEFAULT_SYMBOL_CIRCLE_STROKE_WIDTH,
71
76
  isFilled: primitive.fill,
72
77
  })
73
78
  }
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "./cli": "./dist/cli/main.js"
7
7
  },
8
8
  "type": "module",
9
- "version": "0.0.70",
9
+ "version": "0.0.72",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "https://github.com/tscircuit/circuit-json-to-tscircuit.git"
@@ -0,0 +1,47 @@
1
+ import { expect, test } from "bun:test"
2
+ import type { CircuitJson } from "circuit-json"
3
+ import { convertCircuitJsonToTscircuit } from "lib"
4
+ import { runTscircuitCode } from "tscircuit"
5
+
6
+ test("preserves text for imported symbolic net labels", async () => {
7
+ const circuitJson: CircuitJson = [
8
+ {
9
+ type: "pcb_board",
10
+ pcb_board_id: "board",
11
+ center: { x: 0, y: 0 },
12
+ width: 10,
13
+ height: 10,
14
+ num_layers: 2,
15
+ thickness: 1.6,
16
+ material: "fr4",
17
+ },
18
+ {
19
+ type: "source_net",
20
+ source_net_id: "power_good_net",
21
+ name: "PGOOD",
22
+ member_source_group_ids: [],
23
+ },
24
+ {
25
+ type: "schematic_net_label",
26
+ schematic_net_label_id: "power_good_label",
27
+ source_net_id: "power_good_net",
28
+ text: "PGOOD",
29
+ center: { x: 1, y: 2 },
30
+ anchor_position: { x: 1, y: 2 },
31
+ anchor_side: "left",
32
+ symbol_name: "vcc_right",
33
+ },
34
+ ]
35
+ const renderedCircuitJson = await runTscircuitCode(
36
+ convertCircuitJsonToTscircuit(circuitJson, {
37
+ componentName: "NetLabelBoard",
38
+ }),
39
+ )
40
+
41
+ expect(
42
+ renderedCircuitJson.some(
43
+ (element) =>
44
+ element.type === "schematic_text" && element.text === "PGOOD",
45
+ ),
46
+ ).toBe(true)
47
+ })
@@ -3,7 +3,7 @@ import { convertSymbolPrimitives } from "../lib/generate-board-schematic-tsx/con
3
3
  import { compose, rotateDEG, scale, translate } from "transformation-matrix"
4
4
  import { runTscircuitCode } from "tscircuit"
5
5
 
6
- test("transforms symbol circle and box dimensions through a rotated matrix", async () => {
6
+ test("transforms symbol primitives with compiled circle styling", async () => {
7
7
  const elementStrings = convertSymbolPrimitives({
8
8
  symbol: {
9
9
  center: { x: 0, y: 0 },
@@ -41,6 +41,7 @@ test("transforms symbol circle and box dimensions through a rotated matrix", asy
41
41
  expect(circle.center.x).toBeCloseTo(6)
42
42
  expect(circle.center.y).toBeCloseTo(22)
43
43
  expect(circle.radius).toBeCloseTo(4)
44
+ expect(circle.stroke_width).toBe(0.02)
44
45
  expect(rect.center.x).toBeCloseTo(6)
45
46
  expect(rect.center.y).toBeCloseTo(22)
46
47
  expect(rect.width).toBeCloseTo(6)