circuit-json-to-tscircuit 0.0.64 → 0.0.65

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.
@@ -736,9 +736,13 @@ var convertNetLabels = (circuitJson) => su4(circuitJson).schematic_net_label.lis
736
736
 
737
737
  // lib/generate-board-schematic-tsx/convert-traces.ts
738
738
  import { su as su5 } from "@tscircuit/soup-util";
739
+ var SCHEMATIC_WIRE_COLOR = "#009600";
739
740
  var convertTraces = (circuitJson) => su5(circuitJson).schematic_trace.list().flatMap((schematicTrace) => [
740
741
  ...schematicTrace.edges.map(
741
- (edge) => formatElement("schematicpath", { points: [edge.from, edge.to] })
742
+ (edge) => formatElement("schematicpath", {
743
+ points: [edge.from, edge.to],
744
+ strokeColor: SCHEMATIC_WIRE_COLOR
745
+ })
742
746
  ),
743
747
  ...schematicTrace.junctions.map(
744
748
  (center) => formatElement("schematiccircle", {
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-KBH5O2WR.js";
4
+ } from "../chunk-BEFEQ6FB.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.63",
19
+ version: "0.0.64",
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-KBH5O2WR.js";
3
+ } from "../chunk-BEFEQ6FB.js";
4
4
  export {
5
5
  convertCircuitJsonToTscircuit
6
6
  };
@@ -2,12 +2,17 @@ import { su } from "@tscircuit/soup-util"
2
2
  import type { SchematicElementConverter } from "./converter-types"
3
3
  import { formatElement } from "./format-attributes"
4
4
 
5
+ const SCHEMATIC_WIRE_COLOR = "#009600"
6
+
5
7
  export const convertTraces: SchematicElementConverter = (circuitJson) =>
6
8
  su(circuitJson)
7
9
  .schematic_trace.list()
8
10
  .flatMap((schematicTrace) => [
9
11
  ...schematicTrace.edges.map((edge) =>
10
- formatElement("schematicpath", { points: [edge.from, edge.to] }),
12
+ formatElement("schematicpath", {
13
+ points: [edge.from, edge.to],
14
+ strokeColor: SCHEMATIC_WIRE_COLOR,
15
+ }),
11
16
  ),
12
17
  ...schematicTrace.junctions.map((center) =>
13
18
  formatElement("schematiccircle", {
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.64",
9
+ "version": "0.0.65",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "https://github.com/tscircuit/circuit-json-to-tscircuit.git"
@@ -22,4 +22,4 @@
22
22
  .pin-number { fill: rgb(169, 0, 0); }
23
23
  .port-label { fill: rgb(0, 100, 100); }
24
24
  .component-name { fill: rgb(0, 100, 100); }
25
- </style><rect class="boundary" x="0" y="0" width="1200" height="600"/><circle cx="567.7065134203" cy="373.29972421080004" r="1.937609194779" fill="#008800" stroke="#008800" stroke-width="7.750436779116" data-schematic-circle-id="schematic_circle_0"/><path d="M 632.2934865796 405.59321079045003 L 761.4674328982001 405.59321079045003 L 761.4674328982001 211.83229131255 L 632.2934865796 211.83229131255 L 632.2934865796 405.59321079045003" stroke="#840000" stroke-width="1.291739463186" fill="#ffffc2" stroke-linecap="round" stroke-linejoin="round"/><path d="M 438.5325671017 373.29972421080004 L 567.7065134203 373.29972421080004" stroke="rgb(132, 0, 0)" stroke-width="1.291739463186" fill="none" stroke-linecap="round" stroke-linejoin="round"/><path d="M 567.7065134203 373.29972421080004 L 567.7065134203 567.0606436887" stroke="rgb(132, 0, 0)" stroke-width="1.291739463186" fill="none" stroke-linecap="round" stroke-linejoin="round"/><text x="632.2934865796" y="179.53880473290002" fill="#000000" text-anchor="start" dominant-baseline="ideographic" font-family="sans-serif" font-size="12.91739463186px" transform="rotate(90, 632.2934865796, 179.53880473290002)">U1 "controller" {flyback}</text></svg>
25
+ </style><rect class="boundary" x="0" y="0" width="1200" height="600"/><circle cx="567.7065134203" cy="373.29972421080004" r="1.937609194779" fill="#008800" stroke="#008800" stroke-width="7.750436779116" data-schematic-circle-id="schematic_circle_0"/><path d="M 632.2934865796 405.59321079045003 L 761.4674328982001 405.59321079045003 L 761.4674328982001 211.83229131255 L 632.2934865796 211.83229131255 L 632.2934865796 405.59321079045003" stroke="#840000" stroke-width="1.291739463186" fill="#ffffc2" stroke-linecap="round" stroke-linejoin="round"/><path d="M 438.5325671017 373.29972421080004 L 567.7065134203 373.29972421080004" stroke="#009600" stroke-width="1.291739463186" fill="none" stroke-linecap="round" stroke-linejoin="round"/><path d="M 567.7065134203 373.29972421080004 L 567.7065134203 567.0606436887" stroke="#009600" stroke-width="1.291739463186" fill="none" stroke-linecap="round" stroke-linejoin="round"/><text x="632.2934865796" y="179.53880473290002" fill="#000000" text-anchor="start" dominant-baseline="ideographic" font-family="sans-serif" font-size="12.91739463186px" transform="rotate(90, 632.2934865796, 179.53880473290002)">U1 "controller" {flyback}</text></svg>
@@ -0,0 +1,36 @@
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 the compiled schematic wire color", 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: "schematic_trace",
20
+ schematic_trace_id: "wire",
21
+ source_trace_id: "trace",
22
+ edges: [{ from: { x: -1, y: 0 }, to: { x: 1, y: 0 } }],
23
+ junctions: [],
24
+ },
25
+ ]
26
+ const renderedCircuitJson = await runTscircuitCode(
27
+ convertCircuitJsonToTscircuit(circuitJson, {
28
+ componentName: "WireColorBoard",
29
+ }),
30
+ )
31
+ const path = renderedCircuitJson.find(
32
+ (element) => element.type === "schematic_path",
33
+ )
34
+
35
+ expect(path).toMatchObject({ stroke_color: "#009600" })
36
+ })