@tscircuit/cli 0.1.855 → 0.1.857

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.
@@ -16,6 +16,15 @@ var __toESM = (mod, isNodeMode, target) => {
16
16
  return to;
17
17
  };
18
18
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
+ var __export = (target, all) => {
20
+ for (var name in all)
21
+ __defProp(target, name, {
22
+ get: all[name],
23
+ enumerable: true,
24
+ configurable: true,
25
+ set: (newValue) => all[name] = () => newValue
26
+ });
27
+ };
19
28
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
20
29
 
21
30
  // node_modules/make-vfs/dist/index.js
@@ -29,7 +38,7 @@ var require_dist = __commonJS((exports, module) => {
29
38
  var __commonJS2 = (cb, mod) => function __require2() {
30
39
  return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
31
40
  };
32
- var __export = (target, all) => {
41
+ var __export2 = (target, all) => {
33
42
  for (var name in all)
34
43
  __defProp2(target, name, { get: all[name], enumerable: true });
35
44
  };
@@ -2335,7 +2344,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
2335
2344
  }
2336
2345
  });
2337
2346
  var src_exports = {};
2338
- __export(src_exports, {
2347
+ __export2(src_exports, {
2339
2348
  getMatchingFilePaths: () => getMatchingFilePaths,
2340
2349
  getVirtualFileSystemFromDirPath: () => getVirtualFileSystemFromDirPath,
2341
2350
  getVirtualFilesystemModuleFromDirPath: () => getVirtualFilesystemModuleFromDirPath
package/dist/main.js CHANGED
@@ -17,6 +17,15 @@ var __toESM2 = (mod, isNodeMode, target) => {
17
17
  return to;
18
18
  };
19
19
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
20
+ var __export2 = (target, all) => {
21
+ for (var name in all)
22
+ __defProp2(target, name, {
23
+ get: all[name],
24
+ enumerable: true,
25
+ configurable: true,
26
+ set: (newValue) => all[name] = () => newValue
27
+ });
28
+ };
20
29
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
21
30
 
22
31
  // node_modules/commander/lib/error.js
@@ -16050,7 +16059,7 @@ var require_dist3 = __commonJS((exports2, module2) => {
16050
16059
  var __commonJS2 = (cb, mod) => function __require2() {
16051
16060
  return mod || (0, cb[__getOwnPropNames22(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
16052
16061
  };
16053
- var __export2 = (target, all) => {
16062
+ var __export22 = (target, all) => {
16054
16063
  for (var name in all)
16055
16064
  __defProp22(target, name, { get: all[name], enumerable: true });
16056
16065
  };
@@ -32706,7 +32715,7 @@ var crypto = new Crypto();
32706
32715
  }
32707
32716
  });
32708
32717
  var src_exports = {};
32709
- __export2(src_exports, {
32718
+ __export22(src_exports, {
32710
32719
  buildToFetchEvent: () => buildToFetchEvent,
32711
32720
  buildToHeaders: () => buildToHeaders,
32712
32721
  buildToNodeHandler: () => buildToNodeHandler,
@@ -49287,7 +49296,7 @@ var require_load = __commonJS((exports2, module2) => {
49287
49296
  var __getProtoOf3 = Object.getPrototypeOf;
49288
49297
  var __hasOwnProp3 = Object.prototype.hasOwnProperty;
49289
49298
  var __name2 = (target, value) => __defProp3(target, "name", { value, configurable: true });
49290
- var __export2 = (target, all) => {
49299
+ var __export3 = (target, all) => {
49291
49300
  for (var name in all)
49292
49301
  __defProp3(target, name, { get: all[name], enumerable: true });
49293
49302
  };
@@ -49302,7 +49311,7 @@ var require_load = __commonJS((exports2, module2) => {
49302
49311
  var __toESM3 = (mod, isNodeMode, target) => (target = mod != null ? __create3(__getProtoOf3(mod)) : {}, __copyProps2(isNodeMode || !mod || !mod.__esModule ? __defProp3(target, "default", { value: mod, enumerable: true }) : target, mod));
49303
49312
  var __toCommonJS2 = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
49304
49313
  var load_exports2 = {};
49305
- __export2(load_exports2, {
49314
+ __export3(load_exports2, {
49306
49315
  load: () => load2
49307
49316
  });
49308
49317
  module2.exports = __toCommonJS2(load_exports2);
@@ -49522,7 +49531,7 @@ var require_dist5 = __commonJS((exports2, module2) => {
49522
49531
  var __commonJS2 = (cb, mod) => function __require2() {
49523
49532
  return mod || (0, cb[__getOwnPropNames3(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
49524
49533
  };
49525
- var __export2 = (target, all) => {
49534
+ var __export3 = (target, all) => {
49526
49535
  for (var name in all)
49527
49536
  __defProp3(target, name, { get: all[name], enumerable: true });
49528
49537
  };
@@ -51828,7 +51837,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
51828
51837
  }
51829
51838
  });
51830
51839
  var src_exports = {};
51831
- __export2(src_exports, {
51840
+ __export3(src_exports, {
51832
51841
  getMatchingFilePaths: () => getMatchingFilePaths,
51833
51842
  getVirtualFileSystemFromDirPath: () => getVirtualFileSystemFromDirPath,
51834
51843
  getVirtualFilesystemModuleFromDirPath: () => getVirtualFilesystemModuleFromDirPath,
@@ -51939,7 +51948,7 @@ var require_dist6 = __commonJS((exports2, module2) => {
51939
51948
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
51940
51949
  var __getOwnPropNames3 = Object.getOwnPropertyNames;
51941
51950
  var __hasOwnProp3 = Object.prototype.hasOwnProperty;
51942
- var __export2 = (target, all) => {
51951
+ var __export3 = (target, all) => {
51943
51952
  for (var name in all)
51944
51953
  __defProp3(target, name, { get: all[name], enumerable: true });
51945
51954
  };
@@ -51953,7 +51962,7 @@ var require_dist6 = __commonJS((exports2, module2) => {
51953
51962
  };
51954
51963
  var __toCommonJS2 = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
51955
51964
  var src_exports = {};
51956
- __export2(src_exports, {
51965
+ __export3(src_exports, {
51957
51966
  default: () => src_default,
51958
51967
  getRouteMatcher: () => getRouteMatcher,
51959
51968
  getRouteMatcherUgly: () => getRouteMatcherUgly
@@ -67162,7 +67171,7 @@ var require_dist7 = __commonJS((exports2, module2) => {
67162
67171
  }
67163
67172
  return target;
67164
67173
  };
67165
- var __export2 = (target, all) => {
67174
+ var __export3 = (target, all) => {
67166
67175
  for (var name in all)
67167
67176
  __defProp3(target, name, { get: all[name], enumerable: true });
67168
67177
  };
@@ -67197,7 +67206,7 @@ var require_dist7 = __commonJS((exports2, module2) => {
67197
67206
  });
67198
67207
  };
67199
67208
  var src_exports = {};
67200
- __export2(src_exports, {
67209
+ __export3(src_exports, {
67201
67210
  getCommandFromPath: () => getCommandFromPath,
67202
67211
  getCommandPathOnly: () => getCommandPathOnly,
67203
67212
  perfectCli: () => perfectCli
@@ -67493,7 +67502,7 @@ var require_dist8 = __commonJS((exports2, module2) => {
67493
67502
  var __commonJS2 = (cb, mod) => function __require2() {
67494
67503
  return mod || (0, cb[__getOwnPropNames3(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
67495
67504
  };
67496
- var __export2 = (target, all) => {
67505
+ var __export3 = (target, all) => {
67497
67506
  for (var name in all)
67498
67507
  __defProp3(target, name, { get: all[name], enumerable: true });
67499
67508
  };
@@ -69799,7 +69808,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
69799
69808
  }
69800
69809
  });
69801
69810
  var src_exports = {};
69802
- __export2(src_exports, {
69811
+ __export3(src_exports, {
69803
69812
  getMatchingFilePaths: () => getMatchingFilePaths2,
69804
69813
  getVirtualFileSystemFromDirPath: () => getVirtualFileSystemFromDirPath,
69805
69814
  getVirtualFilesystemModuleFromDirPath: () => getVirtualFilesystemModuleFromDirPath
@@ -74375,7 +74384,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
74375
74384
  import { execSync as execSync2 } from "node:child_process";
74376
74385
  var import_semver2 = __toESM2(require_semver2(), 1);
74377
74386
  // package.json
74378
- var version = "0.1.854";
74387
+ var version = "0.1.856";
74379
74388
  var package_default = {
74380
74389
  name: "@tscircuit/cli",
74381
74390
  version,
@@ -74387,7 +74396,7 @@ var package_default = {
74387
74396
  "@tscircuit/fake-snippets": "^0.0.182",
74388
74397
  "@tscircuit/file-server": "^0.0.32",
74389
74398
  "@tscircuit/math-utils": "0.0.29",
74390
- "@tscircuit/props": "^0.0.448",
74399
+ "@tscircuit/props": "^0.0.458",
74391
74400
  "@tscircuit/runframe": "^0.0.1555",
74392
74401
  "@tscircuit/schematic-match-adapt": "^0.0.22",
74393
74402
  "@types/bun": "^1.2.2",
@@ -76264,6 +76273,14 @@ import path15 from "node:path";
76264
76273
  import { pathToFileURL } from "node:url";
76265
76274
 
76266
76275
  // node_modules/circuit-json-to-kicad/dist/index.js
76276
+ var exports_dist = {};
76277
+ __export2(exports_dist, {
76278
+ KicadLibraryConverter: () => KicadLibraryConverter,
76279
+ CircuitJsonToKicadSchConverter: () => CircuitJsonToKicadSchConverter,
76280
+ CircuitJsonToKicadProConverter: () => CircuitJsonToKicadProConverter,
76281
+ CircuitJsonToKicadPcbConverter: () => CircuitJsonToKicadPcbConverter,
76282
+ CircuitJsonToKicadLibraryConverter: () => CircuitJsonToKicadLibraryConverter
76283
+ });
76267
76284
  import { KicadSch } from "kicadts";
76268
76285
  import { cju } from "@tscircuit/circuit-json-util";
76269
76286
  import { compose, translate, scale } from "transformation-matrix";
@@ -78710,6 +78727,83 @@ var CircuitJsonToKicadPcbConverter = class {
78710
78727
  return this.ctx.kicadPcb.getString();
78711
78728
  }
78712
78729
  };
78730
+ var CircuitJsonToKicadProConverter = class {
78731
+ ctx;
78732
+ project;
78733
+ constructor(circuitJson, options = {}) {
78734
+ const projectName = options.projectName ?? circuitJson?.project?.name ?? "circuit-json-project";
78735
+ const schematicFilename = options.schematicFilename ?? `${projectName}.kicad_sch`;
78736
+ const pcbFilename = options.pcbFilename ?? `${projectName}.kicad_pcb`;
78737
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
78738
+ this.ctx = {
78739
+ db: cju3(circuitJson),
78740
+ circuitJson
78741
+ };
78742
+ this.project = {
78743
+ version: 1,
78744
+ head: {
78745
+ generator: "circuit-json-to-kicad",
78746
+ generator_version: "0.0.1",
78747
+ project_name: projectName,
78748
+ created: timestamp,
78749
+ modified: timestamp
78750
+ },
78751
+ meta: {
78752
+ version: 1
78753
+ },
78754
+ text_variables: {},
78755
+ libraries: {
78756
+ pinned_symbol_libs: [],
78757
+ pinned_footprint_libs: []
78758
+ },
78759
+ boards: [],
78760
+ cvpcb: {
78761
+ meta: {
78762
+ version: 0
78763
+ }
78764
+ },
78765
+ erc: {
78766
+ meta: {
78767
+ version: 0
78768
+ },
78769
+ erc_exclusions: []
78770
+ },
78771
+ net_settings: {
78772
+ meta: {
78773
+ version: 1
78774
+ },
78775
+ last_net_id: 0,
78776
+ classes: []
78777
+ },
78778
+ pcbnew: {
78779
+ page_layout_descr_file: "",
78780
+ last_paths: {}
78781
+ },
78782
+ schematic: {
78783
+ meta: {
78784
+ version: 1
78785
+ },
78786
+ page_layout_descr_file: "",
78787
+ last_opened_files: [schematicFilename]
78788
+ },
78789
+ board: {
78790
+ meta: {
78791
+ version: 1
78792
+ },
78793
+ last_opened_board: pcbFilename
78794
+ },
78795
+ sheets: [[Math.random().toString(36).substring(2, 15), "Root"]]
78796
+ };
78797
+ }
78798
+ runUntilFinished() {}
78799
+ getOutput() {
78800
+ return this.project;
78801
+ }
78802
+ getOutputString() {
78803
+ return `${JSON.stringify(this.project, null, 2)}
78804
+ `;
78805
+ }
78806
+ };
78713
78807
  var GenerateKicadSchAndPcbStage = class extends ConverterStage {
78714
78808
  _step() {
78715
78809
  const schConverter = new CircuitJsonToKicadSchConverter(this.ctx.circuitJson);
@@ -79905,6 +79999,75 @@ function extractKicadFootprintMetadata(Component, options = {}) {
79905
79999
  return {};
79906
80000
  }
79907
80001
 
80002
+ // lib/shared/extract-kicad-symbol-metadata.ts
80003
+ function extractKicadSymbolMetadata(Component, options = {}) {
80004
+ const { maxIterations = 100, debug = false } = options;
80005
+ let reactElm;
80006
+ try {
80007
+ reactElm = Component({});
80008
+ } catch (e) {
80009
+ if (debug) {
80010
+ console.log(`[extractKicadSymbolMetadata] Failed to call root component:`, e);
80011
+ }
80012
+ return {};
80013
+ }
80014
+ if (!reactElm) {
80015
+ return {};
80016
+ }
80017
+ const queue = [reactElm];
80018
+ let iterations = 0;
80019
+ while (queue.length > 0) {
80020
+ iterations++;
80021
+ if (iterations > maxIterations) {
80022
+ if (debug) {
80023
+ console.log(`[extractKicadSymbolMetadata] Max iterations (${maxIterations}) reached`);
80024
+ }
80025
+ break;
80026
+ }
80027
+ const elm = queue.shift();
80028
+ if (!elm)
80029
+ continue;
80030
+ if (typeof elm.type === "function") {
80031
+ try {
80032
+ let childElm = null;
80033
+ try {
80034
+ childElm = elm.type(elm.props || {});
80035
+ } catch {
80036
+ childElm = elm.type();
80037
+ }
80038
+ if (childElm) {
80039
+ queue.push(childElm);
80040
+ }
80041
+ } catch (e) {
80042
+ if (debug) {
80043
+ console.log(`[extractKicadSymbolMetadata] Failed to call functional component:`, e);
80044
+ }
80045
+ }
80046
+ }
80047
+ if (elm?.props?.kicadSymbolMetadata) {
80048
+ return elm.props.kicadSymbolMetadata;
80049
+ }
80050
+ if (elm?.props) {
80051
+ const children = elm.props.children;
80052
+ if (Array.isArray(children)) {
80053
+ for (const child of children) {
80054
+ if (child && typeof child === "object") {
80055
+ queue.push(child);
80056
+ }
80057
+ }
80058
+ } else if (children && typeof children === "object") {
80059
+ queue.push(children);
80060
+ }
80061
+ for (const [key, value] of Object.entries(elm.props)) {
80062
+ if (key !== "children" && value && typeof value === "object" && "type" in value && "props" in value) {
80063
+ queue.push(value);
80064
+ }
80065
+ }
80066
+ }
80067
+ }
80068
+ return {};
80069
+ }
80070
+
79908
80071
  // lib/shared/convert-to-kicad-library.tsx
79909
80072
  import { jsxDEV } from "react/jsx-dev-runtime";
79910
80073
  async function convertToKicadLibrary({
@@ -79912,13 +80075,15 @@ async function convertToKicadLibrary({
79912
80075
  libraryName,
79913
80076
  outputDir,
79914
80077
  isPcm,
79915
- kicadPcmPackageId
80078
+ kicadPcmPackageId,
80079
+ circuitJsonToKicadModule
79916
80080
  }) {
79917
80081
  const absoluteFilePath = path15.isAbsolute(filePath) ? filePath : path15.resolve(process.cwd(), filePath);
79918
80082
  const React = await importFromUserLand("react");
79919
80083
  globalThis.React = React;
79920
80084
  const userLandTscircuit = await importFromUserLand("tscircuit");
79921
- const converter = new KicadLibraryConverter({
80085
+ const { KicadLibraryConverter: KicadLibraryConverter2 } = circuitJsonToKicadModule ?? exports_dist;
80086
+ const converter = new KicadLibraryConverter2({
79922
80087
  kicadLibraryName: libraryName,
79923
80088
  entrypoint: absoluteFilePath,
79924
80089
  buildFileToCircuitJson: async (filePath2, componentName) => {
@@ -79955,6 +80120,18 @@ async function convertToKicadLibrary({
79955
80120
  return null;
79956
80121
  }
79957
80122
  },
80123
+ getComponentKicadSymbolMetadata: async (filePath2, componentName) => {
80124
+ try {
80125
+ const module2 = await import(pathToFileURL(filePath2).href);
80126
+ const Component = module2[componentName];
80127
+ if (!Component || typeof Component !== "function") {
80128
+ return null;
80129
+ }
80130
+ return extractKicadSymbolMetadata(Component);
80131
+ } catch (error) {
80132
+ return null;
80133
+ }
80134
+ },
79958
80135
  includeBuiltins: true,
79959
80136
  isPcm,
79960
80137
  kicadPcmPackageId
@@ -80190,7 +80367,8 @@ async function buildKicadPcm({
80190
80367
  entryFile,
80191
80368
  projectDir,
80192
80369
  distDir,
80193
- baseUrl: baseUrlOption
80370
+ baseUrl: baseUrlOption,
80371
+ circuitJsonToKicadModule
80194
80372
  }) {
80195
80373
  const packageJsonPath = path18.join(projectDir, "package.json");
80196
80374
  if (!fs15.existsSync(packageJsonPath)) {
@@ -80211,7 +80389,8 @@ async function buildKicadPcm({
80211
80389
  libraryName,
80212
80390
  outputDir: kicadLibOutputDir,
80213
80391
  isPcm: true,
80214
- kicadPcmPackageId
80392
+ kicadPcmPackageId,
80393
+ circuitJsonToKicadModule
80215
80394
  });
80216
80395
  const pcmOutputDir = path18.join(distDir, "pcm");
80217
80396
  const envDeploymentUrl = process.env.TSCIRCUIT_DEPLOYMENT_URL?.replace(/\/+$/, "");
@@ -87837,7 +88016,7 @@ var __require2 = /* @__PURE__ */ ((x) => __require)(function(x) {
87837
88016
  var __commonJS2 = (cb, mod) => function __require22() {
87838
88017
  return mod || (0, cb[__getOwnPropNames3(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
87839
88018
  };
87840
- var __export2 = (target, all) => {
88019
+ var __export3 = (target, all) => {
87841
88020
  for (var name in all)
87842
88021
  __defProp3(target, name, { get: all[name], enumerable: true });
87843
88022
  };
@@ -88631,7 +88810,7 @@ var require_svgson_umd = __commonJS2({
88631
88810
  }
88632
88811
  });
88633
88812
  var dist_exports = {};
88634
- __export2(dist_exports, {
88813
+ __export3(dist_exports, {
88635
88814
  all_layers: () => all_layers,
88636
88815
  any_circuit_element: () => any_circuit_element,
88637
88816
  any_soup_element: () => any_soup_element,
@@ -88809,7 +88988,7 @@ __export2(dist_exports, {
88809
88988
  wave_shape: () => wave_shape
88810
88989
  });
88811
88990
  var external_exports = {};
88812
- __export2(external_exports, {
88991
+ __export3(external_exports, {
88813
88992
  BRAND: () => BRAND,
88814
88993
  DIRTY: () => DIRTY,
88815
88994
  EMPTY_PATH: () => EMPTY_PATH,
@@ -122615,7 +122794,7 @@ var import_constants14 = __toESM3(require_constants6(), 1);
122615
122794
  var import_debug62 = __toESM3(require_browser(), 1);
122616
122795
  var import_debug72 = __toESM3(require_browser(), 1);
122617
122796
  var esm_exports2 = {};
122618
- __export2(esm_exports2, {
122797
+ __export3(esm_exports2, {
122619
122798
  DocumentPosition: () => DocumentPosition,
122620
122799
  append: () => append,
122621
122800
  appendChild: () => appendChild,
@@ -155830,12 +156009,12 @@ var import_jsx_runtime5 = __toESM3(require_jsx_runtime(), 1);
155830
156009
  var import_jsx_runtime6 = __toESM3(require_jsx_runtime(), 1);
155831
156010
  var import_react7 = __toESM3(require_react(), 1);
155832
156011
  var __defProp32 = Object.defineProperty;
155833
- var __export3 = (target, all) => {
156012
+ var __export32 = (target, all) => {
155834
156013
  for (var name in all)
155835
156014
  __defProp32(target, name, { get: all[name], enumerable: true });
155836
156015
  };
155837
156016
  var components_exports = {};
155838
- __export3(components_exports, {
156017
+ __export32(components_exports, {
155839
156018
  AnalogSimulation: () => AnalogSimulation,
155840
156019
  Battery: () => Battery,
155841
156020
  Board: () => Board,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.855",
3
+ "version": "0.1.857",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",
@@ -9,7 +9,7 @@
9
9
  "@tscircuit/fake-snippets": "^0.0.182",
10
10
  "@tscircuit/file-server": "^0.0.32",
11
11
  "@tscircuit/math-utils": "0.0.29",
12
- "@tscircuit/props": "^0.0.448",
12
+ "@tscircuit/props": "^0.0.458",
13
13
  "@tscircuit/runframe": "^0.0.1555",
14
14
  "@tscircuit/schematic-match-adapt": "^0.0.22",
15
15
  "@types/bun": "^1.2.2",