@tscircuit/cli 0.1.505 → 0.1.507

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/main.js CHANGED
@@ -72387,7 +72387,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
72387
72387
  import { execSync as execSync2 } from "node:child_process";
72388
72388
  var import_semver2 = __toESM2(require_semver2(), 1);
72389
72389
  // package.json
72390
- var version = "0.1.504";
72390
+ var version = "0.1.506";
72391
72391
  var package_default = {
72392
72392
  name: "@tscircuit/cli",
72393
72393
  version,
@@ -72465,7 +72465,8 @@ var package_default = {
72465
72465
  },
72466
72466
  files: [
72467
72467
  "dist",
72468
- "cli/entrypoint.js"
72468
+ "cli/entrypoint.js",
72469
+ "types"
72469
72470
  ],
72470
72471
  scripts: {
72471
72472
  start: "bun run dev",
@@ -196227,8 +196228,8 @@ var registerRemove = (program3) => {
196227
196228
  };
196228
196229
 
196229
196230
  // cli/build/register.ts
196230
- import path36 from "node:path";
196231
- import fs37 from "node:fs";
196231
+ import path37 from "node:path";
196232
+ import fs38 from "node:fs";
196232
196233
 
196233
196234
  // cli/build/build-file.ts
196234
196235
  import path30 from "node:path";
@@ -196323,6 +196324,17 @@ var isSubPath2 = (maybeChild, maybeParent) => {
196323
196324
  const relative9 = path31.relative(maybeParent, maybeChild);
196324
196325
  return relative9 === "" || !relative9.startsWith("..") && !path31.isAbsolute(relative9);
196325
196326
  };
196327
+ var findProjectRoot = (startDir) => {
196328
+ let currentDir = startDir;
196329
+ while (currentDir !== path31.dirname(currentDir)) {
196330
+ const packageJsonPath = path31.join(currentDir, "package.json");
196331
+ if (fs32.existsSync(packageJsonPath)) {
196332
+ return currentDir;
196333
+ }
196334
+ currentDir = path31.dirname(currentDir);
196335
+ }
196336
+ return startDir;
196337
+ };
196326
196338
  async function getBuildEntrypoints({
196327
196339
  fileOrDir,
196328
196340
  rootDir = process.cwd()
@@ -196373,7 +196385,9 @@ async function getBuildEntrypoints({
196373
196385
  circuitFiles
196374
196386
  };
196375
196387
  }
196376
- return { projectDir: path31.dirname(resolved), circuitFiles: [resolved] };
196388
+ const fileDir = path31.dirname(resolved);
196389
+ const projectDir = findProjectRoot(fileDir);
196390
+ return { projectDir, circuitFiles: [resolved] };
196377
196391
  }
196378
196392
  return buildFromProjectDir();
196379
196393
  }
@@ -196683,96 +196697,150 @@ ${libTableEntries.join(`
196683
196697
  }
196684
196698
  };
196685
196699
 
196686
- // cli/build/transpile.ts
196687
- import path35 from "node:path";
196688
- import fs36 from "node:fs";
196700
+ // cli/build/transpile/index.ts
196701
+ import path36 from "node:path";
196702
+ import fs37 from "node:fs";
196689
196703
  import { rollup } from "rollup";
196690
196704
  import typescript from "@rollup/plugin-typescript";
196691
196705
  import resolve12 from "@rollup/plugin-node-resolve";
196692
196706
  import commonjs from "@rollup/plugin-commonjs";
196693
196707
  import json from "@rollup/plugin-json";
196694
196708
  import dts from "rollup-plugin-dts";
196709
+
196710
+ // cli/build/transpile/static-asset-plugin.ts
196711
+ import fs36 from "node:fs";
196712
+ import path35 from "node:path";
196713
+ import { createHash } from "node:crypto";
196714
+ var STATIC_ASSET_EXTENSIONS = new Set([
196715
+ ".glb",
196716
+ ".gltf",
196717
+ ".png",
196718
+ ".jpg",
196719
+ ".jpeg",
196720
+ ".svg",
196721
+ ".webp",
196722
+ ".gif",
196723
+ ".bmp",
196724
+ ".step",
196725
+ ".kicad_mod",
196726
+ ".kicad_pcb",
196727
+ ".kicad_pro",
196728
+ ".kicad_sch"
196729
+ ]);
196730
+ var createStaticAssetPlugin = ({
196731
+ outputDir
196732
+ }) => {
196733
+ const copiedAssets = new Map;
196734
+ return {
196735
+ name: "tsci-static-assets",
196736
+ load(id2) {
196737
+ const ext = path35.extname(id2).toLowerCase();
196738
+ if (!STATIC_ASSET_EXTENSIONS.has(ext))
196739
+ return null;
196740
+ const assetDir = path35.join(outputDir, "assets");
196741
+ fs36.mkdirSync(assetDir, { recursive: true });
196742
+ const fileBuffer = fs36.readFileSync(id2);
196743
+ const hash = createHash("sha1").update(fileBuffer).digest("hex").slice(0, 8);
196744
+ const fileName = `${path35.basename(id2, ext)}-${hash}${ext}`;
196745
+ const outputPath = path35.join(assetDir, fileName);
196746
+ if (!copiedAssets.has(id2)) {
196747
+ fs36.writeFileSync(outputPath, fileBuffer);
196748
+ copiedAssets.set(id2, outputPath);
196749
+ }
196750
+ const relativePath = `./assets/${fileName}`;
196751
+ return `export default ${JSON.stringify(relativePath)};`;
196752
+ }
196753
+ };
196754
+ };
196755
+
196756
+ // cli/build/transpile/index.ts
196757
+ var __dirname = "/home/runner/work/cli/cli/cli/build/transpile";
196758
+ var CLI_TYPES_ROOT = path36.resolve(__dirname, "../../../types");
196759
+ var externalFunction = (id2) => {
196760
+ if (id2.startsWith(".") || id2.startsWith("/")) {
196761
+ return false;
196762
+ }
196763
+ if (path36.isAbsolute(id2)) {
196764
+ return false;
196765
+ }
196766
+ return true;
196767
+ };
196695
196768
  var transpileFile = async ({
196696
196769
  input,
196697
196770
  outputDir,
196698
196771
  projectDir
196699
196772
  }) => {
196700
196773
  try {
196701
- fs36.mkdirSync(outputDir, { recursive: true });
196774
+ fs37.mkdirSync(outputDir, { recursive: true });
196775
+ const typeRootCandidates = [
196776
+ path36.join(projectDir, "node_modules", "@types"),
196777
+ path36.join(projectDir, "types"),
196778
+ CLI_TYPES_ROOT
196779
+ ];
196780
+ const typeRoots = Array.from(new Set(typeRootCandidates.filter((candidate) => fs37.existsSync(candidate))));
196702
196781
  console.log("Building ESM bundle...");
196782
+ const staticAssetExtensions = Array.from(STATIC_ASSET_EXTENSIONS);
196783
+ const getPlugins = (moduleKind) => [
196784
+ createStaticAssetPlugin({ outputDir }),
196785
+ resolve12({
196786
+ extensions: [
196787
+ ".ts",
196788
+ ".tsx",
196789
+ ".js",
196790
+ ".jsx",
196791
+ ".json",
196792
+ ...staticAssetExtensions
196793
+ ]
196794
+ }),
196795
+ commonjs(),
196796
+ json(),
196797
+ typescript({
196798
+ jsx: "react",
196799
+ tsconfig: false,
196800
+ compilerOptions: {
196801
+ target: "ES2020",
196802
+ module: moduleKind,
196803
+ jsx: "react",
196804
+ declaration: false,
196805
+ sourceMap: false,
196806
+ skipLibCheck: true,
196807
+ resolveJsonModule: true,
196808
+ allowSyntheticDefaultImports: true,
196809
+ allowArbitraryExtensions: true,
196810
+ ...typeRoots.length ? { typeRoots } : {}
196811
+ }
196812
+ })
196813
+ ];
196703
196814
  const esmBundle = await rollup({
196704
196815
  input,
196705
- external: (id2) => {
196706
- return !id2.startsWith(".") && !id2.startsWith("/");
196707
- },
196708
- plugins: [
196709
- resolve12({
196710
- extensions: [".ts", ".tsx", ".js", ".jsx"]
196711
- }),
196712
- commonjs(),
196713
- json(),
196714
- typescript({
196715
- jsx: "react",
196716
- tsconfig: false,
196717
- compilerOptions: {
196718
- target: "ES2020",
196719
- module: "ESNext",
196720
- jsx: "react",
196721
- declaration: false,
196722
- sourceMap: false,
196723
- skipLibCheck: true,
196724
- resolveJsonModule: true,
196725
- allowSyntheticDefaultImports: true
196726
- }
196727
- })
196728
- ]
196816
+ external: externalFunction,
196817
+ plugins: getPlugins("ESNext")
196729
196818
  });
196819
+ const esmOutputPath = path36.join(outputDir, "index.js");
196730
196820
  await esmBundle.write({
196731
- file: path35.join(outputDir, "index.js"),
196821
+ file: esmOutputPath,
196732
196822
  format: "es",
196733
196823
  sourcemap: false
196734
196824
  });
196735
- console.log(`ESM bundle written to ${path35.relative(projectDir, path35.join(outputDir, "index.js"))}`);
196825
+ console.log(`ESM bundle written to ${path36.relative(projectDir, esmOutputPath)}`);
196736
196826
  console.log("Building CommonJS bundle...");
196737
196827
  const cjsBundle = await rollup({
196738
196828
  input,
196739
- external: (id2) => {
196740
- return !id2.startsWith(".") && !id2.startsWith("/");
196741
- },
196742
- plugins: [
196743
- resolve12({
196744
- extensions: [".ts", ".tsx", ".js", ".jsx"]
196745
- }),
196746
- commonjs(),
196747
- json(),
196748
- typescript({
196749
- jsx: "react",
196750
- tsconfig: false,
196751
- compilerOptions: {
196752
- target: "ES2020",
196753
- module: "CommonJS",
196754
- jsx: "react",
196755
- declaration: false,
196756
- sourceMap: false,
196757
- skipLibCheck: true,
196758
- resolveJsonModule: true,
196759
- allowSyntheticDefaultImports: true
196760
- }
196761
- })
196762
- ]
196829
+ external: externalFunction,
196830
+ plugins: getPlugins("CommonJS")
196763
196831
  });
196832
+ const cjsOutputPath = path36.join(outputDir, "index.cjs");
196833
+ console.log("[DEBUG] Writing CJS bundle to:", cjsOutputPath);
196764
196834
  await cjsBundle.write({
196765
- file: path35.join(outputDir, "index.cjs"),
196835
+ file: cjsOutputPath,
196766
196836
  format: "cjs",
196767
196837
  sourcemap: false
196768
196838
  });
196769
- console.log(`CommonJS bundle written to ${path35.relative(projectDir, path35.join(outputDir, "index.cjs"))}`);
196839
+ console.log(`CommonJS bundle written to ${path36.relative(projectDir, cjsOutputPath)}`);
196770
196840
  console.log("Generating type declarations...");
196771
196841
  const dtsBundle = await rollup({
196772
196842
  input,
196773
- external: (id2) => {
196774
- return !id2.startsWith(".") && !id2.startsWith("/");
196775
- },
196843
+ external: externalFunction,
196776
196844
  plugins: [
196777
196845
  dts({
196778
196846
  respectExternal: true
@@ -196786,8 +196854,9 @@ var transpileFile = async ({
196786
196854
  dtsContent = dtsContent.replace(/import \* as [\w_]+ from ['"]react\/jsx-runtime['"];?\s*\n?/g, "");
196787
196855
  dtsContent = dtsContent.replace(/[\w_]+\.JSX\.Element/g, "any");
196788
196856
  dtsContent = dtsContent.replace(/export\s*{\s*};\s*$/gm, "").trim();
196789
- fs36.writeFileSync(path35.join(outputDir, "index.d.ts"), dtsContent);
196790
- console.log(`Type declarations written to ${path35.relative(projectDir, path35.join(outputDir, "index.d.ts"))}`);
196857
+ const dtsOutputPath = path36.join(outputDir, "index.d.ts");
196858
+ fs37.writeFileSync(dtsOutputPath, dtsContent);
196859
+ console.log(`Type declarations written to ${path36.relative(projectDir, dtsOutputPath)}`);
196791
196860
  console.log(kleur_default.green("Transpilation complete!"));
196792
196861
  return true;
196793
196862
  } catch (err) {
@@ -196818,8 +196887,8 @@ var registerBuild = (program3) => {
196818
196887
  }
196819
196888
  return config;
196820
196889
  })();
196821
- const distDir = path36.join(projectDir, "dist");
196822
- fs37.mkdirSync(distDir, { recursive: true });
196890
+ const distDir = path37.join(projectDir, "dist");
196891
+ fs38.mkdirSync(distDir, { recursive: true });
196823
196892
  console.log(`Building ${circuitFiles.length} file(s)...`);
196824
196893
  let hasErrors = false;
196825
196894
  const staticFileReferences = [];
@@ -196827,10 +196896,10 @@ var registerBuild = (program3) => {
196827
196896
  const kicadProjects = [];
196828
196897
  const shouldGenerateKicad = options?.kicad || options?.kicadFootprintLibrary;
196829
196898
  for (const filePath of circuitFiles) {
196830
- const relative9 = path36.relative(projectDir, filePath);
196899
+ const relative9 = path37.relative(projectDir, filePath);
196831
196900
  console.log(`Building ${relative9}...`);
196832
196901
  const outputDirName = relative9.replace(/(\.board|\.circuit)?\.tsx$/, "");
196833
- const outputPath = path36.join(distDir, outputDirName, "circuit.json");
196902
+ const outputPath = path37.join(distDir, outputDirName, "circuit.json");
196834
196903
  const buildOutcome = await buildFile(filePath, outputPath, projectDir, {
196835
196904
  ignoreErrors: options?.ignoreErrors,
196836
196905
  ignoreWarnings: options?.ignoreWarnings,
@@ -196844,17 +196913,17 @@ var registerBuild = (program3) => {
196844
196913
  if (!buildOutcome.ok) {
196845
196914
  hasErrors = true;
196846
196915
  } else if (options?.site) {
196847
- const normalizedSourcePath = relative9.split(path36.sep).join("/");
196848
- const relativeOutputPath = path36.join(outputDirName, "circuit.json");
196849
- const normalizedOutputPath = relativeOutputPath.split(path36.sep).join("/");
196916
+ const normalizedSourcePath = relative9.split(path37.sep).join("/");
196917
+ const relativeOutputPath = path37.join(outputDirName, "circuit.json");
196918
+ const normalizedOutputPath = relativeOutputPath.split(path37.sep).join("/");
196850
196919
  staticFileReferences.push({
196851
196920
  filePath: normalizedSourcePath,
196852
196921
  fileStaticAssetUrl: `./${normalizedOutputPath}`
196853
196922
  });
196854
196923
  }
196855
196924
  if (buildOutcome.ok && shouldGenerateKicad && buildOutcome.circuitJson) {
196856
- const projectOutputDir = path36.join(distDir, outputDirName, "kicad");
196857
- const projectName = path36.basename(outputDirName);
196925
+ const projectOutputDir = path37.join(distDir, outputDirName, "kicad");
196926
+ const projectName = path37.basename(outputDirName);
196858
196927
  const project = await generateKicadProject({
196859
196928
  circuitJson: buildOutcome.circuitJson,
196860
196929
  outputDir: projectOutputDir,
@@ -196902,8 +196971,8 @@ var registerBuild = (program3) => {
196902
196971
  files: staticFileReferences,
196903
196972
  standaloneScriptSrc: "./standalone.min.js"
196904
196973
  });
196905
- fs37.writeFileSync(path36.join(distDir, "index.html"), indexHtml);
196906
- fs37.writeFileSync(path36.join(distDir, "standalone.min.js"), standalone_min_default);
196974
+ fs38.writeFileSync(path37.join(distDir, "index.html"), indexHtml);
196975
+ fs38.writeFileSync(path37.join(distDir, "standalone.min.js"), standalone_min_default);
196907
196976
  }
196908
196977
  if (options?.kicadFootprintLibrary) {
196909
196978
  if (kicadProjects.length === 0) {
@@ -196926,8 +196995,8 @@ var registerBuild = (program3) => {
196926
196995
  };
196927
196996
 
196928
196997
  // lib/shared/snapshot-project.ts
196929
- import fs39 from "node:fs";
196930
- import path37 from "node:path";
196998
+ import fs40 from "node:fs";
196999
+ import path38 from "node:path";
196931
197000
  import looksSame2 from "looks-same";
196932
197001
  import {
196933
197002
  convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg3,
@@ -196938,7 +197007,7 @@ import { renderGLTFToPNGBufferFromGLBBuffer as renderGLTFToPNGBufferFromGLBBuffe
196938
197007
 
196939
197008
  // lib/shared/compare-images.ts
196940
197009
  import looksSame from "looks-same";
196941
- import fs38 from "node:fs/promises";
197010
+ import fs39 from "node:fs/promises";
196942
197011
  var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
196943
197012
  const { equal: equal2 } = await looksSame(buffer1, buffer2, {
196944
197013
  strict: false,
@@ -196954,7 +197023,7 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
196954
197023
  tolerance: 2
196955
197024
  });
196956
197025
  } else {
196957
- await fs38.writeFile(diffPath, buffer2);
197026
+ await fs39.writeFile(diffPath, buffer2);
196958
197027
  }
196959
197028
  }
196960
197029
  return { equal: equal2 };
@@ -196979,7 +197048,7 @@ var snapshotProject = async ({
196979
197048
  ...DEFAULT_IGNORED_PATTERNS,
196980
197049
  ...ignored.map(normalizeIgnorePattern)
196981
197050
  ];
196982
- const resolvedPaths = filePaths.map((f) => path37.resolve(projectDir, f));
197051
+ const resolvedPaths = filePaths.map((f) => path38.resolve(projectDir, f));
196983
197052
  const boardFiles = findBoardFiles({
196984
197053
  projectDir,
196985
197054
  ignore,
@@ -196993,7 +197062,7 @@ var snapshotProject = async ({
196993
197062
  const mismatches = [];
196994
197063
  let didUpdate = false;
196995
197064
  for (const file of boardFiles) {
196996
- const relativeFilePath = path37.relative(projectDir, file);
197065
+ const relativeFilePath = path38.relative(projectDir, file);
196997
197066
  let circuitJson;
196998
197067
  let pcbSvg;
196999
197068
  let schSvg;
@@ -197047,17 +197116,17 @@ var snapshotProject = async ({
197047
197116
  } catch (error) {
197048
197117
  const errorMessage = error instanceof Error ? error.message : String(error);
197049
197118
  if (errorMessage.includes("No pcb_board found in circuit JSON")) {
197050
- const fileDir = path37.dirname(file);
197051
- const relativeDir = path37.relative(projectDir, fileDir);
197052
- const snapDir2 = snapshotsDirName ? path37.join(projectDir, snapshotsDirName, relativeDir) : path37.join(fileDir, "__snapshots__");
197053
- const base2 = path37.basename(file).replace(/\.tsx$/, "");
197054
- const snap3dPath = path37.join(snapDir2, `${base2}-3d.snap.png`);
197055
- const existing3dSnapshot = fs39.existsSync(snap3dPath);
197119
+ const fileDir = path38.dirname(file);
197120
+ const relativeDir = path38.relative(projectDir, fileDir);
197121
+ const snapDir2 = snapshotsDirName ? path38.join(projectDir, snapshotsDirName, relativeDir) : path38.join(fileDir, "__snapshots__");
197122
+ const base2 = path38.basename(file).replace(/\.tsx$/, "");
197123
+ const snap3dPath = path38.join(snapDir2, `${base2}-3d.snap.png`);
197124
+ const existing3dSnapshot = fs40.existsSync(snap3dPath);
197056
197125
  if (existing3dSnapshot) {
197057
197126
  onError(kleur_default.red(`
197058
197127
  ❌ Failed to generate 3D snapshot for ${relativeFilePath}:
197059
197128
  `) + kleur_default.red(` No pcb_board found in circuit JSON
197060
- `) + kleur_default.red(` Existing snapshot: ${path37.relative(projectDir, snap3dPath)}
197129
+ `) + kleur_default.red(` Existing snapshot: ${path38.relative(projectDir, snap3dPath)}
197061
197130
  `));
197062
197131
  return onExit(1);
197063
197132
  } else {
@@ -197073,9 +197142,9 @@ var snapshotProject = async ({
197073
197142
  }
197074
197143
  }
197075
197144
  }
197076
- const snapDir = snapshotsDirName ? path37.join(projectDir, snapshotsDirName, path37.relative(projectDir, path37.dirname(file))) : path37.join(path37.dirname(file), "__snapshots__");
197077
- fs39.mkdirSync(snapDir, { recursive: true });
197078
- const base = path37.basename(file).replace(/\.tsx$/, "");
197145
+ const snapDir = snapshotsDirName ? path38.join(projectDir, snapshotsDirName, path38.relative(projectDir, path38.dirname(file))) : path38.join(path38.dirname(file), "__snapshots__");
197146
+ fs40.mkdirSync(snapDir, { recursive: true });
197147
+ const base = path38.basename(file).replace(/\.tsx$/, "");
197079
197148
  const snapshots = [];
197080
197149
  if (pcbOnly || !schematicOnly) {
197081
197150
  snapshots.push({ type: "pcb", content: pcbSvg, isBinary: false });
@@ -197093,31 +197162,31 @@ var snapshotProject = async ({
197093
197162
  for (const snapshot of snapshots) {
197094
197163
  const { type } = snapshot;
197095
197164
  const is3d = type === "3d";
197096
- const snapPath = path37.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
197097
- const existing = fs39.existsSync(snapPath);
197165
+ const snapPath = path38.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
197166
+ const existing = fs40.existsSync(snapPath);
197098
197167
  const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
197099
197168
  const newContentForFile = snapshot.content;
197100
197169
  if (!existing) {
197101
- fs39.writeFileSync(snapPath, newContentForFile);
197102
- console.log("✅", kleur_default.gray(path37.relative(projectDir, snapPath)));
197170
+ fs40.writeFileSync(snapPath, newContentForFile);
197171
+ console.log("✅", kleur_default.gray(path38.relative(projectDir, snapPath)));
197103
197172
  didUpdate = true;
197104
197173
  continue;
197105
197174
  }
197106
- const oldContentBuffer = fs39.readFileSync(snapPath);
197175
+ const oldContentBuffer = fs40.readFileSync(snapPath);
197107
197176
  const diffPath = snapPath.replace(is3d ? ".snap.png" : ".snap.svg", is3d ? ".diff.png" : ".diff.svg");
197108
197177
  const { equal: equal2 } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath);
197109
197178
  if (update) {
197110
197179
  if (!forceUpdate && equal2) {
197111
- console.log("✅", kleur_default.gray(path37.relative(projectDir, snapPath)));
197180
+ console.log("✅", kleur_default.gray(path38.relative(projectDir, snapPath)));
197112
197181
  } else {
197113
- fs39.writeFileSync(snapPath, newContentForFile);
197114
- console.log("✅", kleur_default.gray(path37.relative(projectDir, snapPath)));
197182
+ fs40.writeFileSync(snapPath, newContentForFile);
197183
+ console.log("✅", kleur_default.gray(path38.relative(projectDir, snapPath)));
197115
197184
  didUpdate = true;
197116
197185
  }
197117
197186
  } else if (!equal2) {
197118
197187
  mismatches.push(`${snapPath} (diff: ${diffPath})`);
197119
197188
  } else {
197120
- console.log("✅", kleur_default.gray(path37.relative(projectDir, snapPath)));
197189
+ console.log("✅", kleur_default.gray(path38.relative(projectDir, snapPath)));
197121
197190
  }
197122
197191
  }
197123
197192
  }
@@ -197156,22 +197225,22 @@ var registerSnapshot = (program3) => {
197156
197225
  };
197157
197226
 
197158
197227
  // lib/shared/setup-github-actions.ts
197159
- import fs40 from "node:fs";
197160
- import path38 from "node:path";
197228
+ import fs41 from "node:fs";
197229
+ import path39 from "node:path";
197161
197230
  var setupGithubActions = (projectDir = process.cwd()) => {
197162
197231
  const findGitRoot = (startDir) => {
197163
- let dir = path38.resolve(startDir);
197164
- while (dir !== path38.parse(dir).root) {
197165
- if (fs40.existsSync(path38.join(dir, ".git"))) {
197232
+ let dir = path39.resolve(startDir);
197233
+ while (dir !== path39.parse(dir).root) {
197234
+ if (fs41.existsSync(path39.join(dir, ".git"))) {
197166
197235
  return dir;
197167
197236
  }
197168
- dir = path38.dirname(dir);
197237
+ dir = path39.dirname(dir);
197169
197238
  }
197170
197239
  return null;
197171
197240
  };
197172
197241
  const gitRoot = findGitRoot(projectDir) ?? projectDir;
197173
- const workflowsDir = path38.join(gitRoot, ".github", "workflows");
197174
- fs40.mkdirSync(workflowsDir, { recursive: true });
197242
+ const workflowsDir = path39.join(gitRoot, ".github", "workflows");
197243
+ fs41.mkdirSync(workflowsDir, { recursive: true });
197175
197244
  const buildWorkflow = `name: tscircuit Build
197176
197245
 
197177
197246
  on:
@@ -197210,8 +197279,8 @@ jobs:
197210
197279
  - run: bun install
197211
197280
  - run: bunx tsci snapshot
197212
197281
  `;
197213
- writeFileIfNotExists(path38.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
197214
- writeFileIfNotExists(path38.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
197282
+ writeFileIfNotExists(path39.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
197283
+ writeFileIfNotExists(path39.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
197215
197284
  };
197216
197285
 
197217
197286
  // cli/setup/register.ts
@@ -197237,8 +197306,8 @@ var registerSetup = (program3) => {
197237
197306
  };
197238
197307
 
197239
197308
  // cli/convert/register.ts
197240
- import fs41 from "node:fs/promises";
197241
- import path39 from "node:path";
197309
+ import fs42 from "node:fs/promises";
197310
+ import path40 from "node:path";
197242
197311
  import { parseKicadModToCircuitJson } from "kicad-component-converter";
197243
197312
 
197244
197313
  // node_modules/@tscircuit/mm/dist/index.js
@@ -197358,15 +197427,15 @@ var convertCircuitJsonToTscircuit = (circuitJson, opts) => {
197358
197427
  var registerConvert = (program3) => {
197359
197428
  program3.command("convert").description("Convert a .kicad_mod footprint to a tscircuit component").argument("<file>", "Path to the .kicad_mod file").option("-o, --output <path>", "Output TSX file path").option("-n, --name <component>", "Component name for export").action(async (file, options) => {
197360
197429
  try {
197361
- const inputPath = path39.resolve(file);
197362
- const modContent = await fs41.readFile(inputPath, "utf-8");
197430
+ const inputPath = path40.resolve(file);
197431
+ const modContent = await fs42.readFile(inputPath, "utf-8");
197363
197432
  const circuitJson = await parseKicadModToCircuitJson(modContent);
197364
- const componentName = options.name ?? path39.basename(inputPath, ".kicad_mod");
197433
+ const componentName = options.name ?? path40.basename(inputPath, ".kicad_mod");
197365
197434
  const tsx = convertCircuitJsonToTscircuit(circuitJson, {
197366
197435
  componentName
197367
197436
  });
197368
- const outputPath = options.output ? path39.resolve(options.output) : path39.join(path39.dirname(inputPath), `${componentName}.tsx`);
197369
- await fs41.writeFile(outputPath, tsx);
197437
+ const outputPath = options.output ? path40.resolve(options.output) : path40.join(path40.dirname(inputPath), `${componentName}.tsx`);
197438
+ await fs42.writeFile(outputPath, tsx);
197370
197439
  console.log(kleur_default.green(`Converted ${outputPath}`));
197371
197440
  } catch (error) {
197372
197441
  console.error(kleur_default.red("Failed to convert footprint:"), error instanceof Error ? error.message : error);
@@ -197461,12 +197530,12 @@ var registerSimulate = (program3) => {
197461
197530
  };
197462
197531
 
197463
197532
  // lib/shared/install-project-dependencies.ts
197464
- import fs43 from "node:fs";
197465
- import path41 from "node:path";
197533
+ import fs44 from "node:fs";
197534
+ import path42 from "node:path";
197466
197535
 
197467
197536
  // lib/shared/collect-tsci-dependencies.ts
197468
- import fs42 from "node:fs";
197469
- import path40 from "node:path";
197537
+ import fs43 from "node:fs";
197538
+ import path41 from "node:path";
197470
197539
  var DEFAULT_PATTERNS = ["**/*.{ts,tsx,js,jsx}"];
197471
197540
  var DEFAULT_IGNORES = [
197472
197541
  "**/node_modules/**",
@@ -197481,7 +197550,7 @@ function collectTsciDependencies({
197481
197550
  patterns = DEFAULT_PATTERNS,
197482
197551
  ignore = DEFAULT_IGNORES
197483
197552
  } = {}) {
197484
- const searchRoot = path40.resolve(cwd);
197553
+ const searchRoot = path41.resolve(cwd);
197485
197554
  const files = globbySync(patterns, {
197486
197555
  cwd: searchRoot,
197487
197556
  absolute: true,
@@ -197491,7 +197560,7 @@ function collectTsciDependencies({
197491
197560
  const dependencies2 = new Set;
197492
197561
  for (const filePath of files) {
197493
197562
  try {
197494
- const fileContents = fs42.readFileSync(filePath, "utf-8");
197563
+ const fileContents = fs43.readFileSync(filePath, "utf-8");
197495
197564
  let match;
197496
197565
  while (true) {
197497
197566
  match = IMPORT_PATTERN.exec(fileContents);
@@ -197508,26 +197577,26 @@ function collectTsciDependencies({
197508
197577
  async function installProjectDependencies({
197509
197578
  cwd = process.cwd()
197510
197579
  } = {}) {
197511
- const projectRoot = path41.resolve(cwd);
197512
- const packageJsonPath = path41.join(projectRoot, "package.json");
197513
- const npmrcPath = path41.join(projectRoot, ".npmrc");
197580
+ const projectRoot = path42.resolve(cwd);
197581
+ const packageJsonPath = path42.join(projectRoot, "package.json");
197582
+ const npmrcPath = path42.join(projectRoot, ".npmrc");
197514
197583
  const packageManager = getPackageManager();
197515
- if (!fs43.existsSync(projectRoot)) {
197584
+ if (!fs44.existsSync(projectRoot)) {
197516
197585
  throw new Error(`Directory not found: ${projectRoot}`);
197517
197586
  }
197518
197587
  let packageJsonCreated = false;
197519
- if (!fs43.existsSync(packageJsonPath)) {
197588
+ if (!fs44.existsSync(packageJsonPath)) {
197520
197589
  console.log("No package.json found. Generating a new one.");
197521
197590
  generatePackageJson(projectRoot);
197522
197591
  packageJsonCreated = true;
197523
197592
  } else {
197524
197593
  console.log("Found existing package.json.");
197525
197594
  }
197526
- if (!fs43.existsSync(npmrcPath)) {
197595
+ if (!fs44.existsSync(npmrcPath)) {
197527
197596
  console.log("Creating .npmrc with tscircuit registry configuration.");
197528
- fs43.writeFileSync(npmrcPath, "@tsci:registry=https://npm.tscircuit.com");
197597
+ fs44.writeFileSync(npmrcPath, "@tsci:registry=https://npm.tscircuit.com");
197529
197598
  }
197530
- const packageJson = JSON.parse(fs43.readFileSync(packageJsonPath, "utf-8"));
197599
+ const packageJson = JSON.parse(fs44.readFileSync(packageJsonPath, "utf-8"));
197531
197600
  if (packageJsonCreated) {
197532
197601
  const tsciDependencies = collectTsciDependencies({ cwd: projectRoot });
197533
197602
  if (tsciDependencies.length > 0) {
@@ -197542,7 +197611,7 @@ async function installProjectDependencies({
197542
197611
  console.log("No @tsci dependencies detected in circuit files.");
197543
197612
  }
197544
197613
  }
197545
- fs43.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}
197614
+ fs44.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}
197546
197615
  `);
197547
197616
  console.log(`Installing dependencies using ${kleur_default.bold(packageManager.name)}...`);
197548
197617
  try {
@@ -197572,14 +197641,14 @@ var registerInstall = (program3) => {
197572
197641
  };
197573
197642
 
197574
197643
  // cli/transpile/register.ts
197575
- import path42 from "node:path";
197644
+ import path43 from "node:path";
197576
197645
  var registerTranspile = (program3) => {
197577
197646
  program3.command("transpile").description("Transpile TypeScript/TSX to JavaScript (ESM, CommonJS, and type declarations)").argument("[file]", "Path to the entry file").action(async (file) => {
197578
197647
  try {
197579
197648
  const { projectDir, circuitFiles, mainEntrypoint } = await getBuildEntrypoints({
197580
197649
  fileOrDir: file
197581
197650
  });
197582
- const distDir = path42.join(projectDir, "dist");
197651
+ const distDir = path43.join(projectDir, "dist");
197583
197652
  console.log("Transpiling entry file...");
197584
197653
  const entryFile = mainEntrypoint || circuitFiles[0];
197585
197654
  if (!entryFile) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.505",
3
+ "version": "0.1.507",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",
@@ -75,7 +75,8 @@
75
75
  },
76
76
  "files": [
77
77
  "dist",
78
- "cli/entrypoint.js"
78
+ "cli/entrypoint.js",
79
+ "types"
79
80
  ],
80
81
  "scripts": {
81
82
  "start": "bun run dev",
@@ -0,0 +1,6 @@
1
+ declare module "@tscircuit/fake-snippets/bundle" {
2
+ const bundle: {
3
+ makeRequest: (req: any, options: any) => Promise<any>
4
+ }
5
+ export default bundle
6
+ }
@@ -0,0 +1,69 @@
1
+ declare module "*.glb" {
2
+ const src: string
3
+ export default src
4
+ }
5
+
6
+ declare module "*.gltf" {
7
+ const src: string
8
+ export default src
9
+ }
10
+
11
+ declare module "*.png" {
12
+ const src: string
13
+ export default src
14
+ }
15
+
16
+ declare module "*.jpg" {
17
+ const src: string
18
+ export default src
19
+ }
20
+
21
+ declare module "*.jpeg" {
22
+ const src: string
23
+ export default src
24
+ }
25
+
26
+ declare module "*.svg" {
27
+ const src: string
28
+ export default src
29
+ }
30
+
31
+ declare module "*.gif" {
32
+ const src: string
33
+ export default src
34
+ }
35
+
36
+ declare module "*.webp" {
37
+ const src: string
38
+ export default src
39
+ }
40
+
41
+ declare module "*.bmp" {
42
+ const src: string
43
+ export default src
44
+ }
45
+
46
+ declare module "*.step" {
47
+ const src: string
48
+ export default src
49
+ }
50
+
51
+ declare module "*.kicad_mod" {
52
+ const src: string
53
+ export default src
54
+ }
55
+
56
+ declare module "*.kicad_pcb" {
57
+ const src: string
58
+ export default src
59
+ }
60
+
61
+ declare module "*.kicad_pro" {
62
+ const src: string
63
+ export default src
64
+ }
65
+
66
+ declare module "*.kicad_sch" {
67
+ const src: string
68
+ export default src
69
+ }