@tscircuit/cli 0.1.1079 → 0.1.1081

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/cli/main.js CHANGED
@@ -71664,7 +71664,7 @@ var registerStaticAssetLoaders = () => {
71664
71664
  // cli/main.ts
71665
71665
  var import_perfect_cli = __toESM2(require_dist2(), 1);
71666
71666
  // package.json
71667
- var version = "0.1.1078";
71667
+ var version = "0.1.1080";
71668
71668
  var package_default = {
71669
71669
  name: "@tscircuit/cli",
71670
71670
  version,
@@ -71680,7 +71680,7 @@ var package_default = {
71680
71680
  "@tscircuit/fake-snippets": "^0.0.182",
71681
71681
  "@tscircuit/file-server": "^0.0.32",
71682
71682
  "@tscircuit/math-utils": "0.0.29",
71683
- "@tscircuit/props": "^0.0.487",
71683
+ "@tscircuit/props": "^0.0.494",
71684
71684
  "@tscircuit/runframe": "^0.0.1712",
71685
71685
  "@tscircuit/schematic-match-adapt": "^0.0.22",
71686
71686
  "@types/bun": "^1.2.2",
@@ -71693,7 +71693,8 @@ var package_default = {
71693
71693
  "@types/semver": "^7.5.8",
71694
71694
  "bun-match-svg": "^0.0.12",
71695
71695
  chokidar: "4.0.1",
71696
- "circuit-json-to-kicad": "^0.0.82",
71696
+ "circuit-json": "^0.0.397",
71697
+ "circuit-json-to-kicad": "^0.0.84",
71697
71698
  "circuit-json-to-readable-netlist": "^0.0.14",
71698
71699
  "circuit-json-to-spice": "^0.0.10",
71699
71700
  "circuit-json-to-tscircuit": "^0.0.9",
@@ -71727,7 +71728,7 @@ var package_default = {
71727
71728
  semver: "^7.6.3",
71728
71729
  sharp: "0.32.6",
71729
71730
  tempy: "^3.1.0",
71730
- tscircuit: "0.0.1464-libonly",
71731
+ tscircuit: "0.0.1472-libonly",
71731
71732
  tsx: "^4.7.1",
71732
71733
  "typed-ky": "^0.0.4",
71733
71734
  zod: "^3.23.8"
@@ -89806,6 +89807,14 @@ var debug10 = Debug10("dsn-converter:parse-dsn-to-dsn-json");
89806
89807
 
89807
89808
  // lib/shared/export-snippet.ts
89808
89809
  var import_jszip4 = __toESM2(require_lib4(), 1);
89810
+
89811
+ // lib/shared/is-circuit-json-file.ts
89812
+ var isCircuitJsonFile = (filePath) => {
89813
+ const normalizedPath = filePath.toLowerCase().replaceAll("\\", "/");
89814
+ return normalizedPath.endsWith(".circuit.json") || normalizedPath.endsWith("/circuit.json");
89815
+ };
89816
+
89817
+ // lib/shared/export-snippet.ts
89809
89818
  var writeFileAsync = promisify3(fs51.writeFile);
89810
89819
  var ALLOWED_EXPORT_FORMATS = [
89811
89820
  "json",
@@ -89820,7 +89829,8 @@ var ALLOWED_EXPORT_FORMATS = [
89820
89829
  "kicad_sch",
89821
89830
  "kicad_pcb",
89822
89831
  "kicad_zip",
89823
- "kicad-library"
89832
+ "kicad-library",
89833
+ "srj"
89824
89834
  ];
89825
89835
  var OUTPUT_EXTENSIONS = {
89826
89836
  json: ".circuit.json",
@@ -89835,7 +89845,8 @@ var OUTPUT_EXTENSIONS = {
89835
89845
  kicad_sch: ".kicad_sch",
89836
89846
  kicad_pcb: ".kicad_pcb",
89837
89847
  kicad_zip: "-kicad.zip",
89838
- "kicad-library": ""
89848
+ "kicad-library": "",
89849
+ srj: ".simple-route.json"
89839
89850
  };
89840
89851
  var exportSnippet = async ({
89841
89852
  filePath,
@@ -89871,52 +89882,81 @@ var exportSnippet = async ({
89871
89882
  return onExit(1);
89872
89883
  }
89873
89884
  }
89874
- const circuitData = await generateCircuitJson({
89875
- filePath,
89876
- saveToFile: format === "circuit-json",
89877
- platformConfig
89878
- }).catch((err) => {
89879
- onError(`Error generating circuit JSON: ${err}`);
89880
- return null;
89881
- });
89882
- if (!circuitData)
89883
- return onExit(1);
89885
+ let circuitJson;
89886
+ if (isCircuitJsonFile(filePath)) {
89887
+ const rawCircuitJson = await fs51.promises.readFile(filePath, "utf-8").catch((err) => {
89888
+ onError(`Error reading circuit JSON file: ${err}`);
89889
+ return null;
89890
+ });
89891
+ if (!rawCircuitJson)
89892
+ return onExit(1);
89893
+ try {
89894
+ const parsedCircuitJson = JSON.parse(rawCircuitJson);
89895
+ if (!Array.isArray(parsedCircuitJson)) {
89896
+ onError("Error parsing circuit JSON file: expected an array");
89897
+ return onExit(1);
89898
+ }
89899
+ circuitJson = parsedCircuitJson;
89900
+ } catch (err) {
89901
+ onError(`Error parsing circuit JSON file: ${err}`);
89902
+ return onExit(1);
89903
+ }
89904
+ } else {
89905
+ const circuitData = await generateCircuitJson({
89906
+ filePath,
89907
+ saveToFile: format === "circuit-json",
89908
+ platformConfig
89909
+ }).catch((err) => {
89910
+ onError(`Error generating circuit JSON: ${err}`);
89911
+ return null;
89912
+ });
89913
+ if (!circuitData)
89914
+ return onExit(1);
89915
+ circuitJson = circuitData.circuitJson;
89916
+ }
89884
89917
  let outputContent;
89885
89918
  switch (format) {
89886
89919
  case "schematic-svg":
89887
- outputContent = convertCircuitJsonToSchematicSvg2(circuitData.circuitJson);
89920
+ outputContent = convertCircuitJsonToSchematicSvg2(circuitJson);
89888
89921
  break;
89889
89922
  case "pcb-svg":
89890
- outputContent = convertCircuitJsonToPcbSvg2(circuitData.circuitJson);
89923
+ outputContent = convertCircuitJsonToPcbSvg2(circuitJson);
89891
89924
  break;
89892
89925
  case "specctra-dsn":
89893
- outputContent = convertCircuitJsonToDsnString(circuitData.circuitJson);
89926
+ outputContent = convertCircuitJsonToDsnString(circuitJson);
89894
89927
  break;
89895
89928
  case "readable-netlist":
89896
- outputContent = convertCircuitJsonToReadableNetlist(circuitData.circuitJson);
89929
+ outputContent = convertCircuitJsonToReadableNetlist(circuitJson);
89897
89930
  break;
89898
89931
  case "gltf":
89899
- outputContent = JSON.stringify(await convertCircuitJsonToGltf4(circuitData.circuitJson, getCircuitJsonToGltfOptions({ format: "gltf" })), null, 2);
89932
+ outputContent = JSON.stringify(await convertCircuitJsonToGltf4(circuitJson, getCircuitJsonToGltfOptions({ format: "gltf" })), null, 2);
89900
89933
  break;
89901
89934
  case "glb":
89902
- outputContent = Buffer.from(await convertCircuitJsonToGltf4(circuitData.circuitJson, getCircuitJsonToGltfOptions({ format: "glb" })));
89935
+ outputContent = Buffer.from(await convertCircuitJsonToGltf4(circuitJson, getCircuitJsonToGltfOptions({ format: "glb" })));
89936
+ break;
89937
+ case "srj":
89938
+ {
89939
+ const userLandTscircuit = await importFromUserLand("tscircuit");
89940
+ const simpleRouteJson = userLandTscircuit.getSimpleRouteJsonFromCircuitJson({ circuitJson });
89941
+ outputContent = JSON.stringify(simpleRouteJson, null, 2);
89942
+ }
89903
89943
  break;
89904
89944
  case "kicad_sch": {
89905
- const converter = new CircuitJsonToKicadSchConverter(circuitData.circuitJson);
89945
+ const converter = new CircuitJsonToKicadSchConverter(circuitJson);
89906
89946
  converter.runUntilFinished();
89907
89947
  outputContent = converter.getOutputString();
89908
89948
  break;
89909
89949
  }
89910
89950
  case "kicad_pcb": {
89911
- const converter = new CircuitJsonToKicadPcbConverter(circuitData.circuitJson);
89951
+ const converter = new CircuitJsonToKicadPcbConverter(circuitJson);
89912
89952
  converter.runUntilFinished();
89913
89953
  outputContent = converter.getOutputString();
89914
89954
  break;
89915
89955
  }
89916
89956
  case "kicad_zip": {
89917
- const schConverter = new CircuitJsonToKicadSchConverter(circuitData.circuitJson);
89957
+ const schConverter = new CircuitJsonToKicadSchConverter(circuitJson);
89918
89958
  schConverter.runUntilFinished();
89919
- const pcbConverter = new CircuitJsonToKicadPcbConverter(circuitData.circuitJson);
89959
+ const pcbConverter = new CircuitJsonToKicadPcbConverter(circuitJson);
89920
89960
  pcbConverter.runUntilFinished();
89921
89961
  const zip = new import_jszip4.default;
89922
89962
  zip.file(`${outputBaseName}.kicad_sch`, schConverter.getOutputString());
@@ -89925,7 +89965,7 @@ var exportSnippet = async ({
89925
89965
  break;
89926
89966
  }
89927
89967
  default:
89928
- outputContent = JSON.stringify(circuitData.circuitJson, null, 2);
89968
+ outputContent = JSON.stringify(circuitJson, null, 2);
89929
89969
  }
89930
89970
  if (writeFile) {
89931
89971
  await writeFileAsync(outputDestination, outputContent).catch((err) => {
@@ -178106,10 +178146,6 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath, createDiff = true)
178106
178146
  };
178107
178147
 
178108
178148
  // lib/shared/process-snapshot-file.ts
178109
- var isCircuitJsonFile = (filePath) => {
178110
- const normalizedPath = filePath.toLowerCase().replaceAll("\\", "/");
178111
- return normalizedPath.endsWith(".circuit.json") || normalizedPath.endsWith("/circuit.json");
178112
- };
178113
178149
  var processSnapshotFile = async ({
178114
178150
  file,
178115
178151
  projectDir,
@@ -13271,11 +13271,13 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath, createDiff = true)
13271
13271
  return { equal };
13272
13272
  };
13273
13273
 
13274
- // lib/shared/process-snapshot-file.ts
13274
+ // lib/shared/is-circuit-json-file.ts
13275
13275
  var isCircuitJsonFile = (filePath) => {
13276
13276
  const normalizedPath = filePath.toLowerCase().replaceAll("\\", "/");
13277
13277
  return normalizedPath.endsWith(".circuit.json") || normalizedPath.endsWith("/circuit.json");
13278
13278
  };
13279
+
13280
+ // lib/shared/process-snapshot-file.ts
13279
13281
  var processSnapshotFile = async ({
13280
13282
  file,
13281
13283
  projectDir,
package/dist/lib/index.js CHANGED
@@ -60435,7 +60435,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
60435
60435
  }));
60436
60436
  };
60437
60437
  // package.json
60438
- var version = "0.1.1078";
60438
+ var version = "0.1.1080";
60439
60439
  var package_default = {
60440
60440
  name: "@tscircuit/cli",
60441
60441
  version,
@@ -60451,7 +60451,7 @@ var package_default = {
60451
60451
  "@tscircuit/fake-snippets": "^0.0.182",
60452
60452
  "@tscircuit/file-server": "^0.0.32",
60453
60453
  "@tscircuit/math-utils": "0.0.29",
60454
- "@tscircuit/props": "^0.0.487",
60454
+ "@tscircuit/props": "^0.0.494",
60455
60455
  "@tscircuit/runframe": "^0.0.1712",
60456
60456
  "@tscircuit/schematic-match-adapt": "^0.0.22",
60457
60457
  "@types/bun": "^1.2.2",
@@ -60464,7 +60464,8 @@ var package_default = {
60464
60464
  "@types/semver": "^7.5.8",
60465
60465
  "bun-match-svg": "^0.0.12",
60466
60466
  chokidar: "4.0.1",
60467
- "circuit-json-to-kicad": "^0.0.82",
60467
+ "circuit-json": "^0.0.397",
60468
+ "circuit-json-to-kicad": "^0.0.84",
60468
60469
  "circuit-json-to-readable-netlist": "^0.0.14",
60469
60470
  "circuit-json-to-spice": "^0.0.10",
60470
60471
  "circuit-json-to-tscircuit": "^0.0.9",
@@ -60498,7 +60499,7 @@ var package_default = {
60498
60499
  semver: "^7.6.3",
60499
60500
  sharp: "0.32.6",
60500
60501
  tempy: "^3.1.0",
60501
- tscircuit: "0.0.1464-libonly",
60502
+ tscircuit: "0.0.1472-libonly",
60502
60503
  tsx: "^4.7.1",
60503
60504
  "typed-ky": "^0.0.4",
60504
60505
  zod: "^3.23.8"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.1079",
3
+ "version": "0.1.1081",
4
4
  "main": "dist/cli/main.js",
5
5
  "exports": {
6
6
  ".": "./dist/cli/main.js",
@@ -13,7 +13,7 @@
13
13
  "@tscircuit/fake-snippets": "^0.0.182",
14
14
  "@tscircuit/file-server": "^0.0.32",
15
15
  "@tscircuit/math-utils": "0.0.29",
16
- "@tscircuit/props": "^0.0.487",
16
+ "@tscircuit/props": "^0.0.494",
17
17
  "@tscircuit/runframe": "^0.0.1712",
18
18
  "@tscircuit/schematic-match-adapt": "^0.0.22",
19
19
  "@types/bun": "^1.2.2",
@@ -26,7 +26,8 @@
26
26
  "@types/semver": "^7.5.8",
27
27
  "bun-match-svg": "^0.0.12",
28
28
  "chokidar": "4.0.1",
29
- "circuit-json-to-kicad": "^0.0.82",
29
+ "circuit-json": "^0.0.397",
30
+ "circuit-json-to-kicad": "^0.0.84",
30
31
  "circuit-json-to-readable-netlist": "^0.0.14",
31
32
  "circuit-json-to-spice": "^0.0.10",
32
33
  "circuit-json-to-tscircuit": "^0.0.9",
@@ -60,7 +61,7 @@
60
61
  "semver": "^7.6.3",
61
62
  "sharp": "0.32.6",
62
63
  "tempy": "^3.1.0",
63
- "tscircuit": "0.0.1464-libonly",
64
+ "tscircuit": "0.0.1472-libonly",
64
65
  "tsx": "^4.7.1",
65
66
  "typed-ky": "^0.0.4",
66
67
  "zod": "^3.23.8"