circuit-json-to-tscircuit 0.0.47 → 0.0.48

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.
@@ -445,9 +445,14 @@ var convertSilkscreen = (circuitJson) => {
445
445
  const silkscreenCircles = su9(circuitJson).pcb_silkscreen_circle.list();
446
446
  const elementStrings = [];
447
447
  for (const silkscreenPath of silkscreenPaths) {
448
- elementStrings.push(
449
- `<silkscreenpath route={${JSON.stringify(silkscreenPath.route)}} />`
450
- );
448
+ const attrs = [`route={${JSON.stringify(silkscreenPath.route)}}`];
449
+ if (silkscreenPath.stroke_width !== void 0) {
450
+ attrs.push(`strokeWidth={${silkscreenPath.stroke_width}}`);
451
+ }
452
+ if (silkscreenPath.layer === "bottom") {
453
+ attrs.push(`layer="bottom"`);
454
+ }
455
+ elementStrings.push(`<silkscreenpath ${attrs.join(" ")} />`);
451
456
  }
452
457
  for (const silkscreenRect of silkscreenRects) {
453
458
  const center = silkscreenRect.center ?? { x: 0, y: 0 };
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-E24YLRWU.js";
4
+ } from "../chunk-YHGRHULT.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.46",
19
+ version: "0.0.47",
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-E24YLRWU.js";
3
+ } from "../chunk-YHGRHULT.js";
4
4
  export {
5
5
  convertCircuitJsonToTscircuit
6
6
  };
@@ -9,9 +9,16 @@ export const convertSilkscreen: FootprintElementConverter = (circuitJson) => {
9
9
  const elementStrings: string[] = []
10
10
 
11
11
  for (const silkscreenPath of silkscreenPaths) {
12
- elementStrings.push(
13
- `<silkscreenpath route={${JSON.stringify(silkscreenPath.route)}} />`,
14
- )
12
+ const attrs = [`route={${JSON.stringify(silkscreenPath.route)}}`]
13
+
14
+ if (silkscreenPath.stroke_width !== undefined) {
15
+ attrs.push(`strokeWidth={${silkscreenPath.stroke_width}}`)
16
+ }
17
+ if (silkscreenPath.layer === "bottom") {
18
+ attrs.push(`layer="bottom"`)
19
+ }
20
+
21
+ elementStrings.push(`<silkscreenpath ${attrs.join(" ")} />`)
15
22
  }
16
23
 
17
24
  for (const silkscreenRect of silkscreenRects) {
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.47",
9
+ "version": "0.0.48",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "https://github.com/tscircuit/circuit-json-to-tscircuit.git"
@@ -24,8 +24,8 @@ test("should convert sample circuit.json to TSX", async () => {
24
24
  footprint={<footprint>
25
25
  <smtpad portHints={["pin2"]} pcbX="0.753364mm" pcbY="0mm" layer="top" coveredWithSolderMask={false} width="0.8064754mm" height="0.8640064mm" shape="rect" />
26
26
  <smtpad portHints={["pin1"]} pcbX="-0.753364mm" pcbY="0mm" layer="top" coveredWithSolderMask={false} width="0.8064754mm" height="0.8640064mm" shape="rect" />
27
- <silkscreenpath route={[{"x":0.42621199999996406,"y":-0.6606031999999686},{"x":1.3850873999999749,"y":-0.6606031999999686},{"x":1.3850873999999749,"y":0.6606031999999686},{"x":0.42621199999996406,"y":0.6606031999999686}]} />
28
- <silkscreenpath route={[{"x":-0.42621200000007775,"y":-0.6606031999999686},{"x":-1.3850874000000886,"y":-0.6606031999999686},{"x":-1.3850874000000886,"y":0.6606031999999686},{"x":-0.42621200000007775,"y":0.6606031999999686}]} />
27
+ <silkscreenpath route={[{"x":0.42621199999996406,"y":-0.6606031999999686},{"x":1.3850873999999749,"y":-0.6606031999999686},{"x":1.3850873999999749,"y":0.6606031999999686},{"x":0.42621199999996406,"y":0.6606031999999686}]} strokeWidth={0.1} />
28
+ <silkscreenpath route={[{"x":-0.42621200000007775,"y":-0.6606031999999686},{"x":-1.3850874000000886,"y":-0.6606031999999686},{"x":-1.3850874000000886,"y":0.6606031999999686},{"x":-0.42621200000007775,"y":0.6606031999999686}]} strokeWidth={0.1} />
29
29
  <silkscreentext pcbX={-0.0127} pcbY={1.6604} anchorAlignment="center" fontSize={1} font="tscircuit2024" pcbRotation="0deg" layer="top" text="unnamed_chip1" />
30
30
  <courtyardoutline outline={[{"x":-1.647000000000162,"y":0.9103999999999814},{"x":1.6216000000000577,"y":0.9103999999999814},{"x":1.6216000000000577,"y":-0.9103999999998678},{"x":-1.647000000000162,"y":-0.9103999999998678},{"x":-1.647000000000162,"y":0.9103999999999814}]} layer="top" />
31
31
  </footprint>}
@@ -1,7 +1,7 @@
1
- import { test, expect } from "bun:test"
2
- import { convertCircuitJsonToTscircuit } from "lib/index"
1
+ import { expect, test } from "bun:test"
3
2
  import { readFile } from "node:fs/promises"
4
3
  import { join } from "node:path"
4
+ import { convertCircuitJsonToTscircuit } from "lib/index"
5
5
 
6
6
  declare module "bun:test" {
7
7
  interface Matchers<T = unknown> {
@@ -30,8 +30,8 @@ test("test1 basic circuit", async () => {
30
30
  footprint={<footprint>
31
31
  <smtpad portHints={["pin2"]} pcbX="0.753364mm" pcbY="0mm" layer="top" coveredWithSolderMask={false} width="0.8064754mm" height="0.8640064mm" shape="rect" />
32
32
  <smtpad portHints={["pin1"]} pcbX="-0.753364mm" pcbY="0mm" layer="top" coveredWithSolderMask={false} width="0.8064754mm" height="0.8640064mm" shape="rect" />
33
- <silkscreenpath route={[{"x":0.42621199999996406,"y":-0.6606031999999686},{"x":1.3850873999999749,"y":-0.6606031999999686},{"x":1.3850873999999749,"y":0.6606031999999686},{"x":0.42621199999996406,"y":0.6606031999999686}]} />
34
- <silkscreenpath route={[{"x":-0.42621200000007775,"y":-0.6606031999999686},{"x":-1.3850874000000886,"y":-0.6606031999999686},{"x":-1.3850874000000886,"y":0.6606031999999686},{"x":-0.42621200000007775,"y":0.6606031999999686}]} />
33
+ <silkscreenpath route={[{"x":0.42621199999996406,"y":-0.6606031999999686},{"x":1.3850873999999749,"y":-0.6606031999999686},{"x":1.3850873999999749,"y":0.6606031999999686},{"x":0.42621199999996406,"y":0.6606031999999686}]} strokeWidth={0.1} />
34
+ <silkscreenpath route={[{"x":-0.42621200000007775,"y":-0.6606031999999686},{"x":-1.3850874000000886,"y":-0.6606031999999686},{"x":-1.3850874000000886,"y":0.6606031999999686},{"x":-0.42621200000007775,"y":0.6606031999999686}]} strokeWidth={0.1} />
35
35
  <silkscreentext pcbX={-0.0127} pcbY={1.6604} anchorAlignment="center" fontSize={1} font="tscircuit2024" pcbRotation="0deg" layer="top" text="unnamed_chip1" />
36
36
  <courtyardoutline outline={[{"x":-1.647000000000162,"y":0.9103999999999814},{"x":1.6216000000000577,"y":0.9103999999999814},{"x":1.6216000000000577,"y":-0.9103999999998678},{"x":-1.647000000000162,"y":-0.9103999999998678},{"x":-1.647000000000162,"y":0.9103999999999814}]} layer="top" />
37
37
  </footprint>}
@@ -1,4 +1,4 @@
1
- import { test, expect } from "bun:test"
1
+ import { expect, test } from "bun:test"
2
2
  import { readFile } from "node:fs/promises"
3
3
  import { join } from "node:path"
4
4
  import { getComponentUsingTemplate } from "lib/get-component-using-template"
@@ -38,8 +38,8 @@ test("test2 getComponentUsingTemplate", async () => {
38
38
  footprint={<footprint>
39
39
  <smtpad portHints={["pin2"]} pcbX="0.753364mm" pcbY="0mm" layer="top" coveredWithSolderMask={false} width="0.8064754mm" height="0.8640064mm" shape="rect" />
40
40
  <smtpad portHints={["pin1"]} pcbX="-0.753364mm" pcbY="0mm" layer="top" coveredWithSolderMask={false} width="0.8064754mm" height="0.8640064mm" shape="rect" />
41
- <silkscreenpath route={[{"x":0.42621199999996406,"y":-0.6606031999999686},{"x":1.3850873999999749,"y":-0.6606031999999686},{"x":1.3850873999999749,"y":0.6606031999999686},{"x":0.42621199999996406,"y":0.6606031999999686}]} />
42
- <silkscreenpath route={[{"x":-0.42621200000007775,"y":-0.6606031999999686},{"x":-1.3850874000000886,"y":-0.6606031999999686},{"x":-1.3850874000000886,"y":0.6606031999999686},{"x":-0.42621200000007775,"y":0.6606031999999686}]} />
41
+ <silkscreenpath route={[{"x":0.42621199999996406,"y":-0.6606031999999686},{"x":1.3850873999999749,"y":-0.6606031999999686},{"x":1.3850873999999749,"y":0.6606031999999686},{"x":0.42621199999996406,"y":0.6606031999999686}]} strokeWidth={0.1} />
42
+ <silkscreenpath route={[{"x":-0.42621200000007775,"y":-0.6606031999999686},{"x":-1.3850874000000886,"y":-0.6606031999999686},{"x":-1.3850874000000886,"y":0.6606031999999686},{"x":-0.42621200000007775,"y":0.6606031999999686}]} strokeWidth={0.1} />
43
43
  <silkscreentext pcbX={-0.0127} pcbY={1.6604} anchorAlignment="center" fontSize={1} font="tscircuit2024" pcbRotation="0deg" layer="top" text="unnamed_chip1" />
44
44
  <courtyardoutline outline={[{"x":-1.647000000000162,"y":0.9103999999999814},{"x":1.6216000000000577,"y":0.9103999999999814},{"x":1.6216000000000577,"y":-0.9103999999998678},{"x":-1.647000000000162,"y":-0.9103999999998678},{"x":-1.647000000000162,"y":0.9103999999999814}]} layer="top" />
45
45
  </footprint>}
@@ -1,7 +1,7 @@
1
1
  import { expect, test } from "bun:test"
2
2
  import { convertCircuitJsonToTscircuit } from "lib"
3
3
 
4
- test.failing("test21 silkscreen path props tsx", async () => {
4
+ test("test21 silkscreen path props tsx", async () => {
5
5
  const tscircuit = convertCircuitJsonToTscircuit(circuitJson, {
6
6
  componentName: "Test21Component",
7
7
  })
@@ -3,14 +3,12 @@ import type { AnyCircuitElement } from "circuit-json"
3
3
  import { convertCircuitJsonToTscircuit } from "lib"
4
4
  import { runTscircuitCode } from "tscircuit"
5
5
 
6
- test.failing(
7
- "test22 silkscreen path props roundtrip",
8
- async () => {
9
- const tscircuit = convertCircuitJsonToTscircuit(circuitJson, {
10
- componentName: "Test22Component",
11
- })
6
+ test("test22 silkscreen path props roundtrip", async () => {
7
+ const tscircuit = convertCircuitJsonToTscircuit(circuitJson, {
8
+ componentName: "Test22Component",
9
+ })
12
10
 
13
- const renderedCircuitJson = (await runTscircuitCode(`
11
+ const renderedCircuitJson = (await runTscircuitCode(`
14
12
  ${tscircuit}
15
13
 
16
14
  circuit.add(
@@ -20,16 +18,14 @@ circuit.add(
20
18
  )
21
19
  `)) as AnyCircuitElement[]
22
20
 
23
- const silkscreenPath = renderedCircuitJson.find(
24
- (el) => el.type === "pcb_silkscreen_path",
25
- ) as any
21
+ const silkscreenPath = renderedCircuitJson.find(
22
+ (el) => el.type === "pcb_silkscreen_path",
23
+ ) as any
26
24
 
27
- expect(silkscreenPath).toBeDefined()
28
- expect(silkscreenPath.layer).toBe("bottom")
29
- expect(silkscreenPath.stroke_width).toBe(0.2)
30
- },
31
- 15000,
32
- )
25
+ expect(silkscreenPath).toBeDefined()
26
+ expect(silkscreenPath.layer).toBe("bottom")
27
+ expect(silkscreenPath.stroke_width).toBe(0.2)
28
+ }, 15000)
33
29
 
34
30
  const circuitJson: any = [
35
31
  {
@@ -1,4 +1,4 @@
1
- import { test, expect } from "bun:test"
1
+ import { expect, test } from "bun:test"
2
2
  import { convertCircuitJsonToTscircuit } from "lib"
3
3
 
4
4
  test("test3 kicad mod circuit json example", async () => {
@@ -66,14 +66,14 @@ test("test3 kicad mod circuit json example", async () => {
66
66
  <smtpad portHints={["13"]} pcbX="8.337mm" pcbY="5.08mm" layer="top" width="1.626mm" height="1.208mm" shape="rect" />
67
67
  <smtpad portHints={["14"]} pcbX="8.278mm" pcbY="7.62mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
68
68
  <smtpad portHints={["14"]} pcbX="8.278mm" pcbY="7.62mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
69
- <silkscreenpath route={[{"x":-8.89,"y":-8.509},{"x":-8.89,"y":8.636}]} />
70
- <silkscreenpath route={[{"x":-6.985,"y":-10.414},{"x":6.985,"y":-10.414}]} />
71
- <silkscreenpath route={[{"x":6.985,"y":10.541},{"x":-6.985,"y":10.541}]} />
72
- <silkscreenpath route={[{"x":8.89,"y":-8.509},{"x":8.89,"y":8.636}]} />
73
- <silkscreenpath route={[{"x":-8.89,"y":8.636},{"x":-8.634777964987212,"y":9.588499698293818},{"x":-7.937499698293819,"y":10.285777964987211},{"x":-6.985,"y":10.541}]} />
74
- <silkscreenpath route={[{"x":-6.985,"y":-10.414},{"x":-7.937499698293818,"y":-10.158777964987209},{"x":-8.63477796498721,"y":-9.461499698293817},{"x":-8.89,"y":-8.509}]} />
75
- <silkscreenpath route={[{"x":6.985,"y":10.541},{"x":7.937499698293818,"y":10.285777964987211},{"x":8.63477796498721,"y":9.588499698293818},{"x":8.889999999999999,"y":8.636}]} />
76
- <silkscreenpath route={[{"x":8.89,"y":-8.509},{"x":8.63477796498721,"y":-9.461499698293817},{"x":7.937499698293818,"y":-10.158777964987209},{"x":6.985,"y":-10.413999999999998}]} />
69
+ <silkscreenpath route={[{"x":-8.89,"y":-8.509},{"x":-8.89,"y":8.636}]} strokeWidth={0.1} />
70
+ <silkscreenpath route={[{"x":-6.985,"y":-10.414},{"x":6.985,"y":-10.414}]} strokeWidth={0.1} />
71
+ <silkscreenpath route={[{"x":6.985,"y":10.541},{"x":-6.985,"y":10.541}]} strokeWidth={0.1} />
72
+ <silkscreenpath route={[{"x":8.89,"y":-8.509},{"x":8.89,"y":8.636}]} strokeWidth={0.1} />
73
+ <silkscreenpath route={[{"x":-8.89,"y":8.636},{"x":-8.634777964987212,"y":9.588499698293818},{"x":-7.937499698293819,"y":10.285777964987211},{"x":-6.985,"y":10.541}]} strokeWidth={0.1} />
74
+ <silkscreenpath route={[{"x":-6.985,"y":-10.414},{"x":-7.937499698293818,"y":-10.158777964987209},{"x":-8.63477796498721,"y":-9.461499698293817},{"x":-8.89,"y":-8.509}]} strokeWidth={0.1} />
75
+ <silkscreenpath route={[{"x":6.985,"y":10.541},{"x":7.937499698293818,"y":10.285777964987211},{"x":8.63477796498721,"y":9.588499698293818},{"x":8.889999999999999,"y":8.636}]} strokeWidth={0.1} />
76
+ <silkscreenpath route={[{"x":8.89,"y":-8.509},{"x":8.63477796498721,"y":-9.461499698293817},{"x":7.937499698293818,"y":-10.158777964987209},{"x":6.985,"y":-10.413999999999998}]} strokeWidth={0.1} />
77
77
  <fabricationnotetext pcbX={-8} pcbY={11.5} anchorAlignment="center" text="REF**" font="tscircuit2024" fontSize={1.27} />
78
78
  <fabricationnotetext pcbX={0} pcbY={0} anchorAlignment="center" text="XIAO-Add-On" font="tscircuit2024" fontSize={1.27} />
79
79
  </footprint>}