@tscircuit/cli 0.1.855 → 0.1.856

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.
Files changed (2) hide show
  1. package/dist/main.js +83 -2
  2. package/package.json +2 -2
package/dist/main.js CHANGED
@@ -74375,7 +74375,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
74375
74375
  import { execSync as execSync2 } from "node:child_process";
74376
74376
  var import_semver2 = __toESM2(require_semver2(), 1);
74377
74377
  // package.json
74378
- var version = "0.1.854";
74378
+ var version = "0.1.855";
74379
74379
  var package_default = {
74380
74380
  name: "@tscircuit/cli",
74381
74381
  version,
@@ -74387,7 +74387,7 @@ var package_default = {
74387
74387
  "@tscircuit/fake-snippets": "^0.0.182",
74388
74388
  "@tscircuit/file-server": "^0.0.32",
74389
74389
  "@tscircuit/math-utils": "0.0.29",
74390
- "@tscircuit/props": "^0.0.448",
74390
+ "@tscircuit/props": "^0.0.458",
74391
74391
  "@tscircuit/runframe": "^0.0.1555",
74392
74392
  "@tscircuit/schematic-match-adapt": "^0.0.22",
74393
74393
  "@types/bun": "^1.2.2",
@@ -79905,6 +79905,75 @@ function extractKicadFootprintMetadata(Component, options = {}) {
79905
79905
  return {};
79906
79906
  }
79907
79907
 
79908
+ // lib/shared/extract-kicad-symbol-metadata.ts
79909
+ function extractKicadSymbolMetadata(Component, options = {}) {
79910
+ const { maxIterations = 100, debug = false } = options;
79911
+ let reactElm;
79912
+ try {
79913
+ reactElm = Component({});
79914
+ } catch (e) {
79915
+ if (debug) {
79916
+ console.log(`[extractKicadSymbolMetadata] Failed to call root component:`, e);
79917
+ }
79918
+ return {};
79919
+ }
79920
+ if (!reactElm) {
79921
+ return {};
79922
+ }
79923
+ const queue = [reactElm];
79924
+ let iterations = 0;
79925
+ while (queue.length > 0) {
79926
+ iterations++;
79927
+ if (iterations > maxIterations) {
79928
+ if (debug) {
79929
+ console.log(`[extractKicadSymbolMetadata] Max iterations (${maxIterations}) reached`);
79930
+ }
79931
+ break;
79932
+ }
79933
+ const elm = queue.shift();
79934
+ if (!elm)
79935
+ continue;
79936
+ if (typeof elm.type === "function") {
79937
+ try {
79938
+ let childElm = null;
79939
+ try {
79940
+ childElm = elm.type(elm.props || {});
79941
+ } catch {
79942
+ childElm = elm.type();
79943
+ }
79944
+ if (childElm) {
79945
+ queue.push(childElm);
79946
+ }
79947
+ } catch (e) {
79948
+ if (debug) {
79949
+ console.log(`[extractKicadSymbolMetadata] Failed to call functional component:`, e);
79950
+ }
79951
+ }
79952
+ }
79953
+ if (elm?.props?.kicadSymbolMetadata) {
79954
+ return elm.props.kicadSymbolMetadata;
79955
+ }
79956
+ if (elm?.props) {
79957
+ const children = elm.props.children;
79958
+ if (Array.isArray(children)) {
79959
+ for (const child of children) {
79960
+ if (child && typeof child === "object") {
79961
+ queue.push(child);
79962
+ }
79963
+ }
79964
+ } else if (children && typeof children === "object") {
79965
+ queue.push(children);
79966
+ }
79967
+ for (const [key, value] of Object.entries(elm.props)) {
79968
+ if (key !== "children" && value && typeof value === "object" && "type" in value && "props" in value) {
79969
+ queue.push(value);
79970
+ }
79971
+ }
79972
+ }
79973
+ }
79974
+ return {};
79975
+ }
79976
+
79908
79977
  // lib/shared/convert-to-kicad-library.tsx
79909
79978
  import { jsxDEV } from "react/jsx-dev-runtime";
79910
79979
  async function convertToKicadLibrary({
@@ -79955,6 +80024,18 @@ async function convertToKicadLibrary({
79955
80024
  return null;
79956
80025
  }
79957
80026
  },
80027
+ getComponentKicadSymbolMetadata: async (filePath2, componentName) => {
80028
+ try {
80029
+ const module2 = await import(pathToFileURL(filePath2).href);
80030
+ const Component = module2[componentName];
80031
+ if (!Component || typeof Component !== "function") {
80032
+ return null;
80033
+ }
80034
+ return extractKicadSymbolMetadata(Component);
80035
+ } catch (error) {
80036
+ return null;
80037
+ }
80038
+ },
79958
80039
  includeBuiltins: true,
79959
80040
  isPcm,
79960
80041
  kicadPcmPackageId
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.855",
3
+ "version": "0.1.856",
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",