@tscircuit/cli 0.1.2457 → 0.1.2459
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/build/build.worker.js +118 -98
- package/dist/cli/main.js +2 -2
- package/dist/cli/snapshot/snapshot.worker.js +60 -40
- package/package.json +1 -1
|
@@ -31483,7 +31483,7 @@ var init_dot_prop = __esm(() => {
|
|
|
31483
31483
|
});
|
|
31484
31484
|
|
|
31485
31485
|
// node_modules/env-paths/index.js
|
|
31486
|
-
import
|
|
31486
|
+
import path15 from "node:path";
|
|
31487
31487
|
import os from "node:os";
|
|
31488
31488
|
import process3 from "node:process";
|
|
31489
31489
|
function envPaths(name, { suffix = "nodejs" } = {}) {
|
|
@@ -31502,32 +31502,32 @@ function envPaths(name, { suffix = "nodejs" } = {}) {
|
|
|
31502
31502
|
return linux(name);
|
|
31503
31503
|
}
|
|
31504
31504
|
var homedir, tmpdir, env, macos = (name) => {
|
|
31505
|
-
const library =
|
|
31505
|
+
const library = path15.join(homedir, "Library");
|
|
31506
31506
|
return {
|
|
31507
|
-
data:
|
|
31508
|
-
config:
|
|
31509
|
-
cache:
|
|
31510
|
-
log:
|
|
31511
|
-
temp:
|
|
31507
|
+
data: path15.join(library, "Application Support", name),
|
|
31508
|
+
config: path15.join(library, "Preferences", name),
|
|
31509
|
+
cache: path15.join(library, "Caches", name),
|
|
31510
|
+
log: path15.join(library, "Logs", name),
|
|
31511
|
+
temp: path15.join(tmpdir, name)
|
|
31512
31512
|
};
|
|
31513
31513
|
}, windows = (name) => {
|
|
31514
|
-
const appData = env.APPDATA ||
|
|
31515
|
-
const localAppData = env.LOCALAPPDATA ||
|
|
31514
|
+
const appData = env.APPDATA || path15.join(homedir, "AppData", "Roaming");
|
|
31515
|
+
const localAppData = env.LOCALAPPDATA || path15.join(homedir, "AppData", "Local");
|
|
31516
31516
|
return {
|
|
31517
|
-
data:
|
|
31518
|
-
config:
|
|
31519
|
-
cache:
|
|
31520
|
-
log:
|
|
31521
|
-
temp:
|
|
31517
|
+
data: path15.join(localAppData, name, "Data"),
|
|
31518
|
+
config: path15.join(appData, name, "Config"),
|
|
31519
|
+
cache: path15.join(localAppData, name, "Cache"),
|
|
31520
|
+
log: path15.join(localAppData, name, "Log"),
|
|
31521
|
+
temp: path15.join(tmpdir, name)
|
|
31522
31522
|
};
|
|
31523
31523
|
}, linux = (name) => {
|
|
31524
|
-
const username =
|
|
31524
|
+
const username = path15.basename(homedir);
|
|
31525
31525
|
return {
|
|
31526
|
-
data:
|
|
31527
|
-
config:
|
|
31528
|
-
cache:
|
|
31529
|
-
log:
|
|
31530
|
-
temp:
|
|
31526
|
+
data: path15.join(env.XDG_DATA_HOME || path15.join(homedir, ".local", "share"), name),
|
|
31527
|
+
config: path15.join(env.XDG_CONFIG_HOME || path15.join(homedir, ".config"), name),
|
|
31528
|
+
cache: path15.join(env.XDG_CACHE_HOME || path15.join(homedir, ".cache"), name),
|
|
31529
|
+
log: path15.join(env.XDG_STATE_HOME || path15.join(homedir, ".local", "state"), name),
|
|
31530
|
+
temp: path15.join(tmpdir, username, name)
|
|
31531
31531
|
};
|
|
31532
31532
|
};
|
|
31533
31533
|
var init_env_paths = __esm(() => {
|
|
@@ -31835,7 +31835,7 @@ var init_node = __esm(() => {
|
|
|
31835
31835
|
});
|
|
31836
31836
|
|
|
31837
31837
|
// node_modules/atomically/dist/utils/temp.js
|
|
31838
|
-
import
|
|
31838
|
+
import path16 from "node:path";
|
|
31839
31839
|
var Temp, temp_default;
|
|
31840
31840
|
var init_temp = __esm(() => {
|
|
31841
31841
|
init_dist4();
|
|
@@ -31877,7 +31877,7 @@ var init_temp = __esm(() => {
|
|
|
31877
31877
|
}
|
|
31878
31878
|
},
|
|
31879
31879
|
truncate: (filePath) => {
|
|
31880
|
-
const basename =
|
|
31880
|
+
const basename = path16.basename(filePath);
|
|
31881
31881
|
if (basename.length <= LIMIT_BASENAME_LENGTH)
|
|
31882
31882
|
return filePath;
|
|
31883
31883
|
const truncable = /^(\.?)(.*?)((?:\.[^.]+)?(?:\.tmp-\d{10}[a-f0-9]{6})?)$/.exec(basename);
|
|
@@ -31892,7 +31892,7 @@ var init_temp = __esm(() => {
|
|
|
31892
31892
|
});
|
|
31893
31893
|
|
|
31894
31894
|
// node_modules/atomically/dist/index.js
|
|
31895
|
-
import
|
|
31895
|
+
import path17 from "node:path";
|
|
31896
31896
|
function writeFileSync2(filePath, data, options = DEFAULT_WRITE_OPTIONS) {
|
|
31897
31897
|
if (isString(options))
|
|
31898
31898
|
return writeFileSync2(filePath, data, { encoding: options });
|
|
@@ -31921,7 +31921,7 @@ function writeFileSync2(filePath, data, options = DEFAULT_WRITE_OPTIONS) {
|
|
|
31921
31921
|
}
|
|
31922
31922
|
}
|
|
31923
31923
|
if (!filePathExists) {
|
|
31924
|
-
const parentPath =
|
|
31924
|
+
const parentPath = path17.dirname(filePath);
|
|
31925
31925
|
dist_default.attempt.mkdirSync(parentPath, {
|
|
31926
31926
|
mode: DEFAULT_FOLDER_MODE,
|
|
31927
31927
|
recursive: true
|
|
@@ -39866,7 +39866,7 @@ var init_uint8array_extras = __esm(() => {
|
|
|
39866
39866
|
import { isDeepStrictEqual } from "node:util";
|
|
39867
39867
|
import process8 from "node:process";
|
|
39868
39868
|
import fs12 from "node:fs";
|
|
39869
|
-
import
|
|
39869
|
+
import path18 from "node:path";
|
|
39870
39870
|
import crypto from "node:crypto";
|
|
39871
39871
|
import assert3 from "node:assert";
|
|
39872
39872
|
var import__2020, import_ajv_formats, import_semver2, ajvFormats, encryptionAlgorithm = "aes-256-cbc", createPlainObject = () => Object.create(null), isExist = (data) => data !== undefined && data !== null, checkValueType = (key, value) => {
|
|
@@ -39952,7 +39952,7 @@ var init_source = __esm(() => {
|
|
|
39952
39952
|
this.events = new EventTarget;
|
|
39953
39953
|
this.#encryptionKey = options.encryptionKey;
|
|
39954
39954
|
const fileExtension = options.fileExtension ? `.${options.fileExtension}` : "";
|
|
39955
|
-
this.path =
|
|
39955
|
+
this.path = path18.resolve(options.cwd, `${options.configName ?? "config"}${fileExtension}`);
|
|
39956
39956
|
const fileStore = this.store;
|
|
39957
39957
|
const store = Object.assign(createPlainObject(), options.defaults, fileStore);
|
|
39958
39958
|
if (options.migrations) {
|
|
@@ -40126,7 +40126,7 @@ var init_source = __esm(() => {
|
|
|
40126
40126
|
throw new Error("Config schema violation: " + errors.join("; "));
|
|
40127
40127
|
}
|
|
40128
40128
|
_ensureDirectory() {
|
|
40129
|
-
fs12.mkdirSync(
|
|
40129
|
+
fs12.mkdirSync(path18.dirname(this.path), { recursive: true });
|
|
40130
40130
|
}
|
|
40131
40131
|
_write(value) {
|
|
40132
40132
|
let data = this._serialize(value);
|
|
@@ -40302,7 +40302,7 @@ var init_esm2 = __esm(() => {
|
|
|
40302
40302
|
// lib/shared/handle-registry-auth-error.ts
|
|
40303
40303
|
import fs13 from "node:fs";
|
|
40304
40304
|
import os2 from "node:os";
|
|
40305
|
-
import
|
|
40305
|
+
import path19 from "node:path";
|
|
40306
40306
|
function isUnauthorizedError(error) {
|
|
40307
40307
|
const output = [
|
|
40308
40308
|
error instanceof Error ? error.message : "",
|
|
@@ -40334,8 +40334,8 @@ function handleRegistryAuthError({
|
|
|
40334
40334
|
if (!isUnauthorizedError(error))
|
|
40335
40335
|
return;
|
|
40336
40336
|
const npmrcPaths = [
|
|
40337
|
-
|
|
40338
|
-
|
|
40337
|
+
path19.join(projectDir, ".npmrc"),
|
|
40338
|
+
path19.join(os2.homedir(), ".npmrc")
|
|
40339
40339
|
];
|
|
40340
40340
|
const hasToken = npmrcPaths.some(hasTsciAuthToken);
|
|
40341
40341
|
if (hasToken) {
|
|
@@ -40353,7 +40353,7 @@ var init_handle_registry_auth_error = __esm(() => {
|
|
|
40353
40353
|
// lib/cli-config/index.ts
|
|
40354
40354
|
import fs14 from "node:fs";
|
|
40355
40355
|
import os3 from "node:os";
|
|
40356
|
-
import
|
|
40356
|
+
import path20 from "node:path";
|
|
40357
40357
|
var getCliConfig = (opts = {}) => {
|
|
40358
40358
|
return new Conf({
|
|
40359
40359
|
projectName: "tscircuit",
|
|
@@ -40363,8 +40363,8 @@ var getCliConfig = (opts = {}) => {
|
|
|
40363
40363
|
return process.env.TSCIRCUIT_TOKEN || cliConfig.get("sessionToken");
|
|
40364
40364
|
}, getSessionTokenFromNpmrc = () => {
|
|
40365
40365
|
const npmrcPaths = [
|
|
40366
|
-
|
|
40367
|
-
|
|
40366
|
+
path20.join(process.cwd(), ".npmrc"),
|
|
40367
|
+
path20.join(os3.homedir(), ".npmrc")
|
|
40368
40368
|
];
|
|
40369
40369
|
for (const npmrcPath of npmrcPaths) {
|
|
40370
40370
|
if (!fs14.existsSync(npmrcPath))
|
|
@@ -40413,7 +40413,7 @@ var init_get_circuit_json_to_gltf_options = __esm(() => {
|
|
|
40413
40413
|
});
|
|
40414
40414
|
|
|
40415
40415
|
// cli/build/convert-model-urls-to-file-urls.ts
|
|
40416
|
-
import
|
|
40416
|
+
import path21 from "node:path";
|
|
40417
40417
|
import { pathToFileURL as pathToFileURL5 } from "node:url";
|
|
40418
40418
|
var convertModelUrlsToFileUrls = (circuitJson) => {
|
|
40419
40419
|
const modelUrlKeys = [
|
|
@@ -40440,7 +40440,7 @@ var convertModelUrlsToFileUrls = (circuitJson) => {
|
|
|
40440
40440
|
if (value.startsWith("/") || value.match(/^[a-zA-Z]:\\/)) {
|
|
40441
40441
|
updated[key] = pathToFileURL5(value).href;
|
|
40442
40442
|
} else if (value.startsWith(".")) {
|
|
40443
|
-
updated[key] = pathToFileURL5(
|
|
40443
|
+
updated[key] = pathToFileURL5(path21.resolve(process.cwd(), value)).href;
|
|
40444
40444
|
}
|
|
40445
40445
|
}
|
|
40446
40446
|
}
|
|
@@ -40454,7 +40454,7 @@ import { parentPort } from "node:worker_threads";
|
|
|
40454
40454
|
|
|
40455
40455
|
// cli/build/worker-build-handlers.ts
|
|
40456
40456
|
import fs16 from "node:fs";
|
|
40457
|
-
import
|
|
40457
|
+
import path23 from "node:path";
|
|
40458
40458
|
|
|
40459
40459
|
// lib/project-config/index.ts
|
|
40460
40460
|
import * as fs from "node:fs";
|
|
@@ -40757,7 +40757,7 @@ function writeBuildErrorsFile(circuitJsonOutputPath, errors) {
|
|
|
40757
40757
|
|
|
40758
40758
|
// lib/shared/generate-circuit-json.tsx
|
|
40759
40759
|
import fs9 from "node:fs";
|
|
40760
|
-
import
|
|
40760
|
+
import path12 from "node:path";
|
|
40761
40761
|
import { pathToFileURL as pathToFileURL4 } from "node:url";
|
|
40762
40762
|
import Debug from "debug";
|
|
40763
40763
|
|
|
@@ -42690,9 +42690,29 @@ var registerStaticAssetLoaders = (platformConfig, projectDir = process.cwd()) =>
|
|
|
42690
42690
|
}
|
|
42691
42691
|
};
|
|
42692
42692
|
|
|
42693
|
+
// lib/shared/rethrow-with-project-setup-hint.ts
|
|
42694
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
42695
|
+
import path9 from "node:path";
|
|
42696
|
+
var rethrowWithProjectSetupHint = (error, projectDir) => {
|
|
42697
|
+
if (!(error instanceof Error) || !/^Cannot find (?:module|package) ['"](?:react(?:\/jsx(?:-dev)?-runtime)?|tscircuit)['"]/.test(error.message)) {
|
|
42698
|
+
throw error;
|
|
42699
|
+
}
|
|
42700
|
+
let directory = path9.resolve(projectDir);
|
|
42701
|
+
while (!existsSync2(path9.join(directory, "package.json"))) {
|
|
42702
|
+
const parent = path9.dirname(directory);
|
|
42703
|
+
if (parent === directory) {
|
|
42704
|
+
throw new Error(`${error.message}
|
|
42705
|
+
Run "tsci init --yes" in ${path9.resolve(projectDir)} to initialize the project and install its dependencies.`, { cause: error });
|
|
42706
|
+
}
|
|
42707
|
+
directory = parent;
|
|
42708
|
+
}
|
|
42709
|
+
throw new Error(`${error.message}
|
|
42710
|
+
Run "tsci install" in ${directory} to install the project's dependencies. Ensure the project includes tscircuit and react.`, { cause: error });
|
|
42711
|
+
};
|
|
42712
|
+
|
|
42693
42713
|
// lib/shared/circuit-json-build-cache.ts
|
|
42694
42714
|
import fs7 from "node:fs";
|
|
42695
|
-
import
|
|
42715
|
+
import path10 from "node:path";
|
|
42696
42716
|
import { createHash as createHash2 } from "node:crypto";
|
|
42697
42717
|
var SOURCE_FILE_EXTENSIONS = new Set([
|
|
42698
42718
|
".tsx",
|
|
@@ -42716,43 +42736,43 @@ var IGNORED_DIRECTORY_NAMES = new Set([
|
|
|
42716
42736
|
".git"
|
|
42717
42737
|
]);
|
|
42718
42738
|
var isPathInside = (childPath, parentPath) => {
|
|
42719
|
-
const relative =
|
|
42720
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
42739
|
+
const relative = path10.relative(parentPath, childPath);
|
|
42740
|
+
return relative === "" || !relative.startsWith("..") && !path10.isAbsolute(relative);
|
|
42721
42741
|
};
|
|
42722
42742
|
var findCircuitProjectDir = (filePath) => {
|
|
42723
|
-
const absoluteFilePath =
|
|
42724
|
-
let currentDir =
|
|
42743
|
+
const absoluteFilePath = path10.resolve(filePath);
|
|
42744
|
+
let currentDir = path10.dirname(absoluteFilePath);
|
|
42725
42745
|
while (true) {
|
|
42726
|
-
if (fs7.existsSync(
|
|
42746
|
+
if (fs7.existsSync(path10.join(currentDir, "package.json"))) {
|
|
42727
42747
|
return currentDir;
|
|
42728
42748
|
}
|
|
42729
|
-
const parentDir =
|
|
42749
|
+
const parentDir = path10.dirname(currentDir);
|
|
42730
42750
|
if (parentDir === currentDir)
|
|
42731
42751
|
break;
|
|
42732
42752
|
currentDir = parentDir;
|
|
42733
42753
|
}
|
|
42734
|
-
const cwd =
|
|
42735
|
-
return isPathInside(absoluteFilePath, cwd) ? cwd :
|
|
42754
|
+
const cwd = path10.resolve(process.cwd());
|
|
42755
|
+
return isPathInside(absoluteFilePath, cwd) ? cwd : path10.dirname(absoluteFilePath);
|
|
42736
42756
|
};
|
|
42737
42757
|
var getCircuitJsonOutputDirName = (relativePath) => {
|
|
42738
42758
|
const normalizedRelativePath = relativePath.toLowerCase().replaceAll("\\", "/");
|
|
42739
42759
|
if (normalizedRelativePath === "circuit.json" || normalizedRelativePath.endsWith("/circuit.json")) {
|
|
42740
|
-
return
|
|
42760
|
+
return path10.dirname(relativePath);
|
|
42741
42761
|
}
|
|
42742
42762
|
return relativePath.replace(/(\.board|\.circuit)?\.tsx$/, "").replace(/\.circuit\.json$/, "");
|
|
42743
42763
|
};
|
|
42744
42764
|
var getCircuitJsonBuildOutputPath = (filePath) => {
|
|
42745
|
-
const absoluteFilePath =
|
|
42765
|
+
const absoluteFilePath = path10.resolve(filePath);
|
|
42746
42766
|
const projectDir = findCircuitProjectDir(absoluteFilePath);
|
|
42747
|
-
const relativePath =
|
|
42748
|
-
return
|
|
42767
|
+
const relativePath = path10.relative(projectDir, absoluteFilePath);
|
|
42768
|
+
return path10.join(projectDir, "dist", getCircuitJsonOutputDirName(relativePath), "circuit.json");
|
|
42749
42769
|
};
|
|
42750
42770
|
var getSourceFilePaths = (projectDir) => {
|
|
42751
42771
|
const sourceFilePaths = [];
|
|
42752
42772
|
const visit = (directoryPath) => {
|
|
42753
42773
|
const entries = fs7.readdirSync(directoryPath, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
|
|
42754
42774
|
for (const entry of entries) {
|
|
42755
|
-
const entryPath =
|
|
42775
|
+
const entryPath = path10.join(directoryPath, entry.name);
|
|
42756
42776
|
if (entry.isDirectory()) {
|
|
42757
42777
|
if (IGNORED_DIRECTORY_NAMES.has(entry.name) || entry.name.startsWith(".")) {
|
|
42758
42778
|
continue;
|
|
@@ -42760,7 +42780,7 @@ var getSourceFilePaths = (projectDir) => {
|
|
|
42760
42780
|
visit(entryPath);
|
|
42761
42781
|
continue;
|
|
42762
42782
|
}
|
|
42763
|
-
if (!entry.isFile() || entry.name.endsWith(".circuit.json") || !SOURCE_FILE_EXTENSIONS.has(
|
|
42783
|
+
if (!entry.isFile() || entry.name.endsWith(".circuit.json") || !SOURCE_FILE_EXTENSIONS.has(path10.extname(entry.name).toLowerCase())) {
|
|
42764
42784
|
continue;
|
|
42765
42785
|
}
|
|
42766
42786
|
sourceFilePaths.push(entryPath);
|
|
@@ -42773,7 +42793,7 @@ var getSourceFilesystemMd5Hash = (filePath) => {
|
|
|
42773
42793
|
const projectDir = findCircuitProjectDir(filePath);
|
|
42774
42794
|
const hash = createHash2("md5");
|
|
42775
42795
|
for (const sourceFilePath of getSourceFilePaths(projectDir)) {
|
|
42776
|
-
const relativePath =
|
|
42796
|
+
const relativePath = path10.relative(projectDir, sourceFilePath).split(path10.sep).join("/");
|
|
42777
42797
|
const content = fs7.readFileSync(sourceFilePath);
|
|
42778
42798
|
hash.update(`${Buffer.byteLength(relativePath)}:`);
|
|
42779
42799
|
hash.update(relativePath);
|
|
@@ -42824,7 +42844,7 @@ var readCurrentCircuitJsonBuild = ({
|
|
|
42824
42844
|
|
|
42825
42845
|
// lib/shared/solver-diagnostics.ts
|
|
42826
42846
|
import fs8 from "node:fs";
|
|
42827
|
-
import
|
|
42847
|
+
import path11 from "node:path";
|
|
42828
42848
|
var escapeJsonPointerSegment = (segment) => segment.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
42829
42849
|
var cloneAsJson = (value, ancestors = new WeakMap, path = "#") => {
|
|
42830
42850
|
if (value === undefined)
|
|
@@ -42925,7 +42945,7 @@ class SolverDiagnostics {
|
|
|
42925
42945
|
finalize() {
|
|
42926
42946
|
if (!this.options.enabled)
|
|
42927
42947
|
return;
|
|
42928
|
-
fs8.mkdirSync(
|
|
42948
|
+
fs8.mkdirSync(path11.dirname(this.options.outputPath), { recursive: true });
|
|
42929
42949
|
fs8.writeFileSync(this.options.outputPath, `${JSON.stringify({
|
|
42930
42950
|
format: "tscircuit_solver_debug_v1",
|
|
42931
42951
|
entrypoint: this.options.entrypoint,
|
|
@@ -42969,11 +42989,11 @@ async function generateCircuitJson({
|
|
|
42969
42989
|
}) {
|
|
42970
42990
|
debug(`Generating circuit JSON for ${filePath}`);
|
|
42971
42991
|
const currentSourceFilesystemMd5Hash = sourceFilesystemMd5Hash ?? getSourceFilesystemMd5Hash(filePath);
|
|
42972
|
-
const projectRootDir =
|
|
42973
|
-
const React = await importFromUserLand("react", projectRootDir);
|
|
42992
|
+
const projectRootDir = path12.resolve(projectDirOption ?? process.cwd());
|
|
42993
|
+
const React = await importFromUserLand("react", projectRootDir).catch((error) => rethrowWithProjectSetupHint(error, projectRootDir));
|
|
42974
42994
|
globalThis.React = React;
|
|
42975
42995
|
registerStaticAssetLoaders(platformConfig, projectRootDir);
|
|
42976
|
-
const userLandTscircuit = await importFromUserLand("tscircuit", projectRootDir);
|
|
42996
|
+
const userLandTscircuit = await importFromUserLand("tscircuit", projectRootDir).catch((error) => rethrowWithProjectSetupHint(error, projectRootDir));
|
|
42977
42997
|
const runner = new userLandTscircuit.RootCircuit({
|
|
42978
42998
|
platform: platformConfig
|
|
42979
42999
|
});
|
|
@@ -42982,12 +43002,12 @@ async function generateCircuitJson({
|
|
|
42982
43002
|
const solverDiagnostics = solverDiagnosticsOptions ? new SolverDiagnostics(solverDiagnosticsOptions) : null;
|
|
42983
43003
|
solverDiagnostics?.attachToRootCircuit(runner);
|
|
42984
43004
|
attachAutoroutingArtifacts(runner, filePath, projectRootDir);
|
|
42985
|
-
const absoluteFilePath =
|
|
42986
|
-
const sourceDir =
|
|
43005
|
+
const absoluteFilePath = path12.isAbsolute(filePath) ? filePath : path12.resolve(projectRootDir, filePath);
|
|
43006
|
+
const sourceDir = path12.dirname(absoluteFilePath);
|
|
42987
43007
|
const resolvedOutputDir = outputDir ?? sourceDir;
|
|
42988
|
-
const relativeComponentPath =
|
|
42989
|
-
const baseFileName = outputFileName ||
|
|
42990
|
-
const outputPath =
|
|
43008
|
+
const relativeComponentPath = path12.relative(sourceDir, absoluteFilePath);
|
|
43009
|
+
const baseFileName = outputFileName || path12.basename(absoluteFilePath).replace(/\.[^.]+$/, "");
|
|
43010
|
+
const outputPath = path12.join(resolvedOutputDir, `${baseFileName}.circuit.json`);
|
|
42991
43011
|
debug(`Project directory: ${sourceDir}`);
|
|
42992
43012
|
debug(`Relative component path: ${relativeComponentPath}`);
|
|
42993
43013
|
debug(`Output path: ${outputPath}`);
|
|
@@ -43007,7 +43027,7 @@ async function generateCircuitJson({
|
|
|
43007
43027
|
return false;
|
|
43008
43028
|
if (normalizedFilePath.match(/^\.[^/]/))
|
|
43009
43029
|
return false;
|
|
43010
|
-
if (!ALLOWED_FILE_EXTENSIONS.includes(
|
|
43030
|
+
if (!ALLOWED_FILE_EXTENSIONS.includes(path12.extname(normalizedFilePath)))
|
|
43011
43031
|
return false;
|
|
43012
43032
|
return true;
|
|
43013
43033
|
},
|
|
@@ -43015,7 +43035,7 @@ async function generateCircuitJson({
|
|
|
43015
43035
|
})
|
|
43016
43036
|
};
|
|
43017
43037
|
debug(`fsMap: ${abbreviateStringifyObject(fsMap)}`);
|
|
43018
|
-
const MainComponent = await import(pathToFileURL4(absoluteFilePath).href);
|
|
43038
|
+
const MainComponent = await import(pathToFileURL4(absoluteFilePath).href).catch((error) => rethrowWithProjectSetupHint(error, projectRootDir));
|
|
43019
43039
|
let records;
|
|
43020
43040
|
if (Array.isArray(MainComponent.circuitJson)) {
|
|
43021
43041
|
records = MainComponent.circuitJson;
|
|
@@ -43066,7 +43086,7 @@ async function generateCircuitJson({
|
|
|
43066
43086
|
var import_semver = __toESM(require_semver2(), 1);
|
|
43067
43087
|
import { createHash as createHash3 } from "node:crypto";
|
|
43068
43088
|
import fs10 from "node:fs";
|
|
43069
|
-
import
|
|
43089
|
+
import path13 from "node:path";
|
|
43070
43090
|
import { getPlatformConfig } from "@tscircuit/eval/platform-config";
|
|
43071
43091
|
|
|
43072
43092
|
// lib/shared/platform-config-utils.ts
|
|
@@ -43127,13 +43147,13 @@ var getPlatformFetch = (upstreamFetch = globalThis.fetch) => {
|
|
|
43127
43147
|
};
|
|
43128
43148
|
|
|
43129
43149
|
// lib/shared/get-platform-config-with-cli-defaults.ts
|
|
43130
|
-
function createLocalCacheEngine(cacheDir =
|
|
43150
|
+
function createLocalCacheEngine(cacheDir = path13.join(process.cwd(), ".tscircuit", "cache")) {
|
|
43131
43151
|
return {
|
|
43132
43152
|
getItem: (key) => {
|
|
43133
43153
|
try {
|
|
43134
43154
|
const hash = createHash3("md5").update(key).digest("hex");
|
|
43135
43155
|
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
43136
|
-
const filePath =
|
|
43156
|
+
const filePath = path13.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
43137
43157
|
return fs10.readFileSync(filePath, "utf-8");
|
|
43138
43158
|
} catch {
|
|
43139
43159
|
return null;
|
|
@@ -43144,7 +43164,7 @@ function createLocalCacheEngine(cacheDir = path12.join(process.cwd(), ".tscircui
|
|
|
43144
43164
|
fs10.mkdirSync(cacheDir, { recursive: true });
|
|
43145
43165
|
const hash = createHash3("md5").update(key).digest("hex");
|
|
43146
43166
|
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
43147
|
-
const filePath =
|
|
43167
|
+
const filePath = path13.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
43148
43168
|
fs10.writeFileSync(filePath, value);
|
|
43149
43169
|
} catch {}
|
|
43150
43170
|
}
|
|
@@ -43153,7 +43173,7 @@ function createLocalCacheEngine(cacheDir = path12.join(process.cwd(), ".tscircui
|
|
|
43153
43173
|
function getPlatformConfigWithCliDefaults(userConfig, options) {
|
|
43154
43174
|
const projectDir = options?.projectDir ?? process.cwd();
|
|
43155
43175
|
const basePlatformConfig = getPlatformConfig();
|
|
43156
|
-
const cacheDir =
|
|
43176
|
+
const cacheDir = path13.join(projectDir, ".tscircuit", "cache");
|
|
43157
43177
|
const defaultConfig = {
|
|
43158
43178
|
...basePlatformConfig,
|
|
43159
43179
|
autorouterThreads: process.versions.bun && !import_semver.default.satisfies(process.versions.bun, ">=1.4.2") ? 1 : 4,
|
|
@@ -43165,14 +43185,14 @@ function getPlatformConfigWithCliDefaults(userConfig, options) {
|
|
|
43165
43185
|
loadFromUrl: async (url) => {
|
|
43166
43186
|
let fetchUrl = url;
|
|
43167
43187
|
if (url.startsWith("./") || url.startsWith("../")) {
|
|
43168
|
-
const absolutePath =
|
|
43188
|
+
const absolutePath = path13.resolve(projectDir, url);
|
|
43169
43189
|
fetchUrl = `file://${absolutePath}`;
|
|
43170
43190
|
} else if (url.startsWith("/")) {
|
|
43171
43191
|
if (fs10.existsSync(url)) {
|
|
43172
43192
|
fetchUrl = `file://${url}`;
|
|
43173
43193
|
} else {
|
|
43174
43194
|
const relativePath = `.${url}`;
|
|
43175
|
-
const absolutePath =
|
|
43195
|
+
const absolutePath = path13.resolve(projectDir, relativePath);
|
|
43176
43196
|
if (fs10.existsSync(absolutePath)) {
|
|
43177
43197
|
fetchUrl = `file://${absolutePath}`;
|
|
43178
43198
|
} else {
|
|
@@ -43443,7 +43463,7 @@ function convertCircuitJsonToPcbSvg2(elements, options = {}) {
|
|
|
43443
43463
|
|
|
43444
43464
|
// cli/build/worker-output-generators.ts
|
|
43445
43465
|
import fs15 from "node:fs";
|
|
43446
|
-
import
|
|
43466
|
+
import path22 from "node:path";
|
|
43447
43467
|
|
|
43448
43468
|
// node_modules/circuit-json-to-3d-png/dist/index.js
|
|
43449
43469
|
function normalizeDir(dir) {
|
|
@@ -62463,9 +62483,9 @@ var getSystemSvgAssets = async (circuitJson) => {
|
|
|
62463
62483
|
};
|
|
62464
62484
|
|
|
62465
62485
|
// lib/shared/load-local-step-model-fs-map.ts
|
|
62466
|
-
import { existsSync as
|
|
62486
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
62467
62487
|
import { readFile } from "node:fs/promises";
|
|
62468
|
-
import
|
|
62488
|
+
import path14 from "node:path";
|
|
62469
62489
|
var isRemoteUrl = (value) => /^https?:\/\//i.test(value);
|
|
62470
62490
|
async function loadLocalStepModelFsMap(circuitJson) {
|
|
62471
62491
|
const fsMap = {};
|
|
@@ -62477,8 +62497,8 @@ async function loadLocalStepModelFsMap(circuitJson) {
|
|
|
62477
62497
|
continue;
|
|
62478
62498
|
if (isRemoteUrl(modelUrl) || fsMap[modelUrl])
|
|
62479
62499
|
continue;
|
|
62480
|
-
const localPath =
|
|
62481
|
-
if (!
|
|
62500
|
+
const localPath = path14.resolve(process.cwd(), modelUrl);
|
|
62501
|
+
if (!existsSync3(localPath))
|
|
62482
62502
|
continue;
|
|
62483
62503
|
fsMap[modelUrl] = await readFile(localPath, "utf-8");
|
|
62484
62504
|
}
|
|
@@ -62590,10 +62610,10 @@ var writeDiagramSvgAssetsFromCircuitJson = async (circuitJson, outputDir, imageF
|
|
|
62590
62610
|
for (const fileName of fs15.readdirSync(outputDir)) {
|
|
62591
62611
|
const selected = imageFormats.systemSvgs && /^system(?:-.*)?\.svg$/.test(fileName) || imageFormats.assemblySvgs && fileName === "assembly.svg";
|
|
62592
62612
|
if (selected && !generatedNames.has(fileName))
|
|
62593
|
-
fs15.rmSync(
|
|
62613
|
+
fs15.rmSync(path22.join(outputDir, fileName), { force: true });
|
|
62594
62614
|
}
|
|
62595
62615
|
for (const { fileName, svg } of assets)
|
|
62596
|
-
fs15.writeFileSync(
|
|
62616
|
+
fs15.writeFileSync(path22.join(outputDir, fileName), svg, "utf-8");
|
|
62597
62617
|
return assets.map((asset) => asset.fileName);
|
|
62598
62618
|
};
|
|
62599
62619
|
var writeSimulationSvgAssetsFromCircuitJson = (circuitJson, outputDir, imageFormats) => {
|
|
@@ -62609,12 +62629,12 @@ var writeSimulationSvgAssetsFromCircuitJson = (circuitJson, outputDir, imageForm
|
|
|
62609
62629
|
for (const simulationSvgAsset of simulationSvgAssets) {
|
|
62610
62630
|
if (imageFormats.simulationSvgs) {
|
|
62611
62631
|
const fileName = hasMultipleSimulations ? `simulation-${simulationSvgAsset.fileNameSuffix}.svg` : "simulation.svg";
|
|
62612
|
-
fs15.writeFileSync(
|
|
62632
|
+
fs15.writeFileSync(path22.join(outputDir, fileName), simulationSvgAsset.simulationSvg, "utf-8");
|
|
62613
62633
|
simulationFileNames.push(fileName);
|
|
62614
62634
|
}
|
|
62615
62635
|
if (imageFormats.simulationSchematicSvgs) {
|
|
62616
62636
|
const fileName = hasMultipleSimulations ? `simulation-schematic-${simulationSvgAsset.fileNameSuffix}.svg` : "simulation-schematic.svg";
|
|
62617
|
-
fs15.writeFileSync(
|
|
62637
|
+
fs15.writeFileSync(path22.join(outputDir, fileName), simulationSvgAsset.schematicSimulationSvg, "utf-8");
|
|
62618
62638
|
schematicSimulationFileNames.push(fileName);
|
|
62619
62639
|
}
|
|
62620
62640
|
}
|
|
@@ -62624,7 +62644,7 @@ var writeGlbFromCircuitJson = async (circuitJson, glbOutputPath) => {
|
|
|
62624
62644
|
const circuitJsonWithFileUrls = convertModelUrlsToFileUrls(circuitJson);
|
|
62625
62645
|
const glbBuffer = await convertCircuitJsonToGltf(circuitJsonWithFileUrls, getCircuitJsonToGltfOptions({ format: "glb" }));
|
|
62626
62646
|
const glbData = normalizeToUint8Array2(glbBuffer);
|
|
62627
|
-
fs15.mkdirSync(
|
|
62647
|
+
fs15.mkdirSync(path22.dirname(glbOutputPath), { recursive: true });
|
|
62628
62648
|
fs15.writeFileSync(glbOutputPath, Buffer.from(glbData));
|
|
62629
62649
|
};
|
|
62630
62650
|
var writeStepFromCircuitJson = async (circuitJson, stepOutputPath) => {
|
|
@@ -62634,7 +62654,7 @@ var writeStepFromCircuitJson = async (circuitJson, stepOutputPath) => {
|
|
|
62634
62654
|
includeExternalMeshes: true,
|
|
62635
62655
|
fsMap: await loadLocalStepModelFsMap(circuitJson)
|
|
62636
62656
|
});
|
|
62637
|
-
fs15.mkdirSync(
|
|
62657
|
+
fs15.mkdirSync(path22.dirname(stepOutputPath), { recursive: true });
|
|
62638
62658
|
fs15.writeFileSync(stepOutputPath, stepContent);
|
|
62639
62659
|
};
|
|
62640
62660
|
var writeImageAssetsFromCircuitJson = async (circuitJson, options) => {
|
|
@@ -62643,31 +62663,31 @@ var writeImageAssetsFromCircuitJson = async (circuitJson, options) => {
|
|
|
62643
62663
|
const hasSchematic = circuitJson.some((e) => e.type.startsWith("schematic_"));
|
|
62644
62664
|
if (!hasSchematic) {
|
|
62645
62665
|
if (imageFormats.schematicSvgs)
|
|
62646
|
-
fs15.rmSync(
|
|
62666
|
+
fs15.rmSync(path22.join(outputDir, "schematic.svg"), { force: true });
|
|
62647
62667
|
if (imageFormats.schematicPngs)
|
|
62648
|
-
fs15.rmSync(
|
|
62668
|
+
fs15.rmSync(path22.join(outputDir, "schematic.png"), { force: true });
|
|
62649
62669
|
}
|
|
62650
62670
|
if (imageFormats.pcbSvgs) {
|
|
62651
62671
|
const pcbSvg = convertCircuitJsonToPcbSvg2(circuitJson, pcbSnapshotSettings);
|
|
62652
|
-
fs15.writeFileSync(
|
|
62672
|
+
fs15.writeFileSync(path22.join(outputDir, "pcb.svg"), pcbSvg, "utf-8");
|
|
62653
62673
|
}
|
|
62654
62674
|
if (imageFormats.pcbPngs) {
|
|
62655
62675
|
const pcbSvg = convertCircuitJsonToPcbSvg2(circuitJson, pcbSnapshotSettings);
|
|
62656
|
-
fs15.writeFileSync(
|
|
62676
|
+
fs15.writeFileSync(path22.join(outputDir, "pcb.png"), await convertSvgToPngBuffer(pcbSvg));
|
|
62657
62677
|
}
|
|
62658
62678
|
if (imageFormats.schematicSvgs && hasSchematic) {
|
|
62659
62679
|
const schematicSvg = convertCircuitJsonToSchematicSvg(circuitJson);
|
|
62660
|
-
fs15.writeFileSync(
|
|
62680
|
+
fs15.writeFileSync(path22.join(outputDir, "schematic.svg"), schematicSvg, "utf-8");
|
|
62661
62681
|
}
|
|
62662
62682
|
if (imageFormats.schematicPngs && hasSchematic) {
|
|
62663
62683
|
const schematicSvg = convertCircuitJsonToSchematicSvg(circuitJson);
|
|
62664
|
-
fs15.writeFileSync(
|
|
62684
|
+
fs15.writeFileSync(path22.join(outputDir, "schematic.png"), await convertSvgToPngBuffer(schematicSvg));
|
|
62665
62685
|
}
|
|
62666
62686
|
writeSimulationSvgAssetsFromCircuitJson(circuitJson, outputDir, imageFormats);
|
|
62667
62687
|
await writeDiagramSvgAssetsFromCircuitJson(circuitJson, outputDir, imageFormats);
|
|
62668
62688
|
if (imageFormats.threeDPngs) {
|
|
62669
62689
|
const pngBuffer = await render3dThumbnail(circuitJson);
|
|
62670
|
-
fs15.writeFileSync(
|
|
62690
|
+
fs15.writeFileSync(path22.join(outputDir, "3d.png"), Buffer.from(pngBuffer));
|
|
62671
62691
|
}
|
|
62672
62692
|
};
|
|
62673
62693
|
|
|
@@ -62681,7 +62701,7 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
62681
62701
|
const warnings = [];
|
|
62682
62702
|
const startedAt = options?.profile ? performance.now() : 0;
|
|
62683
62703
|
try {
|
|
62684
|
-
workerLog(`Generating circuit JSON for ${
|
|
62704
|
+
workerLog(`Generating circuit JSON for ${path23.relative(projectDir, filePath)}...`);
|
|
62685
62705
|
await registerStaticAssetLoaders(undefined, projectDir);
|
|
62686
62706
|
const projectConfig = await loadRuntimeProjectConfig(projectDir);
|
|
62687
62707
|
const platformConfig = mergePlatformConfigs(projectConfig?.platformConfig, options?.platformConfig);
|
|
@@ -62705,9 +62725,9 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
62705
62725
|
workerStatus(`waiting on ${asyncEffectName}…`);
|
|
62706
62726
|
}
|
|
62707
62727
|
})).circuitJson;
|
|
62708
|
-
fs16.mkdirSync(
|
|
62728
|
+
fs16.mkdirSync(path23.dirname(outputPath), { recursive: true });
|
|
62709
62729
|
fs16.writeFileSync(outputPath, JSON.stringify(circuitJson, null, 2));
|
|
62710
|
-
workerLog(`Circuit JSON written to ${
|
|
62730
|
+
workerLog(`Circuit JSON written to ${path23.relative(projectDir, outputPath)}`);
|
|
62711
62731
|
const diagnostics = analyzeCircuitJson(circuitJson);
|
|
62712
62732
|
const filteredDiagnostics = filterDiagnosticsByDrcCategory({
|
|
62713
62733
|
errors: diagnostics.errors,
|
|
@@ -62739,7 +62759,7 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
62739
62759
|
for (const line of omittedLines)
|
|
62740
62760
|
workerLog(`Error: ${line}`);
|
|
62741
62761
|
if (errorsFilePath) {
|
|
62742
|
-
workerLog(`${filteredDiagnostics.errors.length} error(s), all written to ${
|
|
62762
|
+
workerLog(`${filteredDiagnostics.errors.length} error(s), all written to ${path23.relative(projectDir, errorsFilePath)}:`);
|
|
62743
62763
|
for (const line of getIssueTypeCountLines(filteredDiagnostics.errors)) {
|
|
62744
62764
|
workerLog(line);
|
|
62745
62765
|
}
|
|
@@ -62754,7 +62774,7 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
62754
62774
|
let previewError;
|
|
62755
62775
|
if (glbOutputPath) {
|
|
62756
62776
|
try {
|
|
62757
|
-
workerLog(`Converting ${
|
|
62777
|
+
workerLog(`Converting ${path23.relative(projectDir, outputPath)} to GLB in same worker...`);
|
|
62758
62778
|
await writeGlbFromCircuitJson(circuitJson, glbOutputPath);
|
|
62759
62779
|
glbOk = true;
|
|
62760
62780
|
} catch (err) {
|
|
@@ -62765,7 +62785,7 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
62765
62785
|
}
|
|
62766
62786
|
if (stepOutputPath) {
|
|
62767
62787
|
try {
|
|
62768
|
-
workerLog(`Converting ${
|
|
62788
|
+
workerLog(`Converting ${path23.relative(projectDir, outputPath)} to STEP in same worker...`);
|
|
62769
62789
|
await writeStepFromCircuitJson(circuitJson, stepOutputPath);
|
|
62770
62790
|
stepOk = true;
|
|
62771
62791
|
} catch (err) {
|
|
@@ -62776,8 +62796,8 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
62776
62796
|
}
|
|
62777
62797
|
if (options?.generatePreviewAssets) {
|
|
62778
62798
|
try {
|
|
62779
|
-
const resolvedPreviewOutputDir = previewOutputDir ??
|
|
62780
|
-
workerLog(`Generating preview assets for ${
|
|
62799
|
+
const resolvedPreviewOutputDir = previewOutputDir ?? path23.dirname(outputPath);
|
|
62800
|
+
workerLog(`Generating preview assets for ${path23.relative(projectDir, resolvedPreviewOutputDir)} in same worker...`);
|
|
62781
62801
|
await writeImageAssetsFromCircuitJson(circuitJson, {
|
|
62782
62802
|
outputDir: resolvedPreviewOutputDir,
|
|
62783
62803
|
imageFormats: options?.imageFormats ?? DEFAULT_IMAGE_FORMAT_SELECTION,
|
package/dist/cli/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/dist/cli/main.js
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 48012653 bytes
|
|
4
|
+
sha256: bffb20646c7ebc2d2797aca469737007eb1d0c9e9c9b45b5ecc337fbd39a6e1f
|
|
@@ -19606,7 +19606,7 @@ function convertCircuitJsonToPcbSvg(elements, options = {}) {
|
|
|
19606
19606
|
|
|
19607
19607
|
// lib/shared/process-snapshot-file.ts
|
|
19608
19608
|
import fs10 from "node:fs";
|
|
19609
|
-
import
|
|
19609
|
+
import path12 from "node:path";
|
|
19610
19610
|
|
|
19611
19611
|
// node_modules/circuit-json-to-3d-png/dist/index.js
|
|
19612
19612
|
function normalizeDir(dir) {
|
|
@@ -19931,7 +19931,7 @@ var readCurrentCircuitJsonBuild = ({
|
|
|
19931
19931
|
|
|
19932
19932
|
// lib/shared/generate-circuit-json.tsx
|
|
19933
19933
|
import fs7 from "node:fs";
|
|
19934
|
-
import
|
|
19934
|
+
import path10 from "node:path";
|
|
19935
19935
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
19936
19936
|
import Debug from "debug";
|
|
19937
19937
|
|
|
@@ -21864,9 +21864,29 @@ var registerStaticAssetLoaders = (platformConfig, projectDir = process.cwd()) =>
|
|
|
21864
21864
|
}
|
|
21865
21865
|
};
|
|
21866
21866
|
|
|
21867
|
+
// lib/shared/rethrow-with-project-setup-hint.ts
|
|
21868
|
+
import { existsSync } from "node:fs";
|
|
21869
|
+
import path8 from "node:path";
|
|
21870
|
+
var rethrowWithProjectSetupHint = (error, projectDir) => {
|
|
21871
|
+
if (!(error instanceof Error) || !/^Cannot find (?:module|package) ['"](?:react(?:\/jsx(?:-dev)?-runtime)?|tscircuit)['"]/.test(error.message)) {
|
|
21872
|
+
throw error;
|
|
21873
|
+
}
|
|
21874
|
+
let directory = path8.resolve(projectDir);
|
|
21875
|
+
while (!existsSync(path8.join(directory, "package.json"))) {
|
|
21876
|
+
const parent = path8.dirname(directory);
|
|
21877
|
+
if (parent === directory) {
|
|
21878
|
+
throw new Error(`${error.message}
|
|
21879
|
+
Run "tsci init --yes" in ${path8.resolve(projectDir)} to initialize the project and install its dependencies.`, { cause: error });
|
|
21880
|
+
}
|
|
21881
|
+
directory = parent;
|
|
21882
|
+
}
|
|
21883
|
+
throw new Error(`${error.message}
|
|
21884
|
+
Run "tsci install" in ${directory} to install the project's dependencies. Ensure the project includes tscircuit and react.`, { cause: error });
|
|
21885
|
+
};
|
|
21886
|
+
|
|
21867
21887
|
// lib/shared/solver-diagnostics.ts
|
|
21868
21888
|
import fs6 from "node:fs";
|
|
21869
|
-
import
|
|
21889
|
+
import path9 from "node:path";
|
|
21870
21890
|
var escapeJsonPointerSegment = (segment) => segment.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
21871
21891
|
var cloneAsJson = (value, ancestors = new WeakMap, path = "#") => {
|
|
21872
21892
|
if (value === undefined)
|
|
@@ -21967,7 +21987,7 @@ class SolverDiagnostics {
|
|
|
21967
21987
|
finalize() {
|
|
21968
21988
|
if (!this.options.enabled)
|
|
21969
21989
|
return;
|
|
21970
|
-
fs6.mkdirSync(
|
|
21990
|
+
fs6.mkdirSync(path9.dirname(this.options.outputPath), { recursive: true });
|
|
21971
21991
|
fs6.writeFileSync(this.options.outputPath, `${JSON.stringify({
|
|
21972
21992
|
format: "tscircuit_solver_debug_v1",
|
|
21973
21993
|
entrypoint: this.options.entrypoint,
|
|
@@ -22011,11 +22031,11 @@ async function generateCircuitJson({
|
|
|
22011
22031
|
}) {
|
|
22012
22032
|
debug(`Generating circuit JSON for ${filePath}`);
|
|
22013
22033
|
const currentSourceFilesystemMd5Hash = sourceFilesystemMd5Hash ?? getSourceFilesystemMd5Hash(filePath);
|
|
22014
|
-
const projectRootDir =
|
|
22015
|
-
const React = await importFromUserLand("react", projectRootDir);
|
|
22034
|
+
const projectRootDir = path10.resolve(projectDirOption ?? process.cwd());
|
|
22035
|
+
const React = await importFromUserLand("react", projectRootDir).catch((error) => rethrowWithProjectSetupHint(error, projectRootDir));
|
|
22016
22036
|
globalThis.React = React;
|
|
22017
22037
|
registerStaticAssetLoaders(platformConfig, projectRootDir);
|
|
22018
|
-
const userLandTscircuit = await importFromUserLand("tscircuit", projectRootDir);
|
|
22038
|
+
const userLandTscircuit = await importFromUserLand("tscircuit", projectRootDir).catch((error) => rethrowWithProjectSetupHint(error, projectRootDir));
|
|
22019
22039
|
const runner = new userLandTscircuit.RootCircuit({
|
|
22020
22040
|
platform: platformConfig
|
|
22021
22041
|
});
|
|
@@ -22024,12 +22044,12 @@ async function generateCircuitJson({
|
|
|
22024
22044
|
const solverDiagnostics = solverDiagnosticsOptions ? new SolverDiagnostics(solverDiagnosticsOptions) : null;
|
|
22025
22045
|
solverDiagnostics?.attachToRootCircuit(runner);
|
|
22026
22046
|
attachAutoroutingArtifacts(runner, filePath, projectRootDir);
|
|
22027
|
-
const absoluteFilePath =
|
|
22028
|
-
const sourceDir =
|
|
22047
|
+
const absoluteFilePath = path10.isAbsolute(filePath) ? filePath : path10.resolve(projectRootDir, filePath);
|
|
22048
|
+
const sourceDir = path10.dirname(absoluteFilePath);
|
|
22029
22049
|
const resolvedOutputDir = outputDir ?? sourceDir;
|
|
22030
|
-
const relativeComponentPath =
|
|
22031
|
-
const baseFileName = outputFileName ||
|
|
22032
|
-
const outputPath =
|
|
22050
|
+
const relativeComponentPath = path10.relative(sourceDir, absoluteFilePath);
|
|
22051
|
+
const baseFileName = outputFileName || path10.basename(absoluteFilePath).replace(/\.[^.]+$/, "");
|
|
22052
|
+
const outputPath = path10.join(resolvedOutputDir, `${baseFileName}.circuit.json`);
|
|
22033
22053
|
debug(`Project directory: ${sourceDir}`);
|
|
22034
22054
|
debug(`Relative component path: ${relativeComponentPath}`);
|
|
22035
22055
|
debug(`Output path: ${outputPath}`);
|
|
@@ -22049,7 +22069,7 @@ async function generateCircuitJson({
|
|
|
22049
22069
|
return false;
|
|
22050
22070
|
if (normalizedFilePath.match(/^\.[^/]/))
|
|
22051
22071
|
return false;
|
|
22052
|
-
if (!ALLOWED_FILE_EXTENSIONS.includes(
|
|
22072
|
+
if (!ALLOWED_FILE_EXTENSIONS.includes(path10.extname(normalizedFilePath)))
|
|
22053
22073
|
return false;
|
|
22054
22074
|
return true;
|
|
22055
22075
|
},
|
|
@@ -22057,7 +22077,7 @@ async function generateCircuitJson({
|
|
|
22057
22077
|
})
|
|
22058
22078
|
};
|
|
22059
22079
|
debug(`fsMap: ${abbreviateStringifyObject(fsMap)}`);
|
|
22060
|
-
const MainComponent = await import(pathToFileURL3(absoluteFilePath).href);
|
|
22080
|
+
const MainComponent = await import(pathToFileURL3(absoluteFilePath).href).catch((error) => rethrowWithProjectSetupHint(error, projectRootDir));
|
|
22061
22081
|
let records;
|
|
22062
22082
|
if (Array.isArray(MainComponent.circuitJson)) {
|
|
22063
22083
|
records = MainComponent.circuitJson;
|
|
@@ -22132,7 +22152,7 @@ var getOrGenerateCircuitJson = async (options) => {
|
|
|
22132
22152
|
var import_semver = __toESM(require_semver2(), 1);
|
|
22133
22153
|
import { createHash as createHash3 } from "node:crypto";
|
|
22134
22154
|
import fs8 from "node:fs";
|
|
22135
|
-
import
|
|
22155
|
+
import path11 from "node:path";
|
|
22136
22156
|
import { getPlatformConfig } from "@tscircuit/eval/platform-config";
|
|
22137
22157
|
|
|
22138
22158
|
// lib/shared/platform-config-utils.ts
|
|
@@ -22193,13 +22213,13 @@ var getPlatformFetch = (upstreamFetch = globalThis.fetch) => {
|
|
|
22193
22213
|
};
|
|
22194
22214
|
|
|
22195
22215
|
// lib/shared/get-platform-config-with-cli-defaults.ts
|
|
22196
|
-
function createLocalCacheEngine(cacheDir =
|
|
22216
|
+
function createLocalCacheEngine(cacheDir = path11.join(process.cwd(), ".tscircuit", "cache")) {
|
|
22197
22217
|
return {
|
|
22198
22218
|
getItem: (key) => {
|
|
22199
22219
|
try {
|
|
22200
22220
|
const hash = createHash3("md5").update(key).digest("hex");
|
|
22201
22221
|
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
22202
|
-
const filePath =
|
|
22222
|
+
const filePath = path11.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
22203
22223
|
return fs8.readFileSync(filePath, "utf-8");
|
|
22204
22224
|
} catch {
|
|
22205
22225
|
return null;
|
|
@@ -22210,7 +22230,7 @@ function createLocalCacheEngine(cacheDir = path10.join(process.cwd(), ".tscircui
|
|
|
22210
22230
|
fs8.mkdirSync(cacheDir, { recursive: true });
|
|
22211
22231
|
const hash = createHash3("md5").update(key).digest("hex");
|
|
22212
22232
|
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
22213
|
-
const filePath =
|
|
22233
|
+
const filePath = path11.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
22214
22234
|
fs8.writeFileSync(filePath, value);
|
|
22215
22235
|
} catch {}
|
|
22216
22236
|
}
|
|
@@ -22219,7 +22239,7 @@ function createLocalCacheEngine(cacheDir = path10.join(process.cwd(), ".tscircui
|
|
|
22219
22239
|
function getPlatformConfigWithCliDefaults(userConfig, options) {
|
|
22220
22240
|
const projectDir = options?.projectDir ?? process.cwd();
|
|
22221
22241
|
const basePlatformConfig = getPlatformConfig();
|
|
22222
|
-
const cacheDir =
|
|
22242
|
+
const cacheDir = path11.join(projectDir, ".tscircuit", "cache");
|
|
22223
22243
|
const defaultConfig = {
|
|
22224
22244
|
...basePlatformConfig,
|
|
22225
22245
|
autorouterThreads: process.versions.bun && !import_semver.default.satisfies(process.versions.bun, ">=1.4.2") ? 1 : 4,
|
|
@@ -22231,14 +22251,14 @@ function getPlatformConfigWithCliDefaults(userConfig, options) {
|
|
|
22231
22251
|
loadFromUrl: async (url) => {
|
|
22232
22252
|
let fetchUrl = url;
|
|
22233
22253
|
if (url.startsWith("./") || url.startsWith("../")) {
|
|
22234
|
-
const absolutePath =
|
|
22254
|
+
const absolutePath = path11.resolve(projectDir, url);
|
|
22235
22255
|
fetchUrl = `file://${absolutePath}`;
|
|
22236
22256
|
} else if (url.startsWith("/")) {
|
|
22237
22257
|
if (fs8.existsSync(url)) {
|
|
22238
22258
|
fetchUrl = `file://${url}`;
|
|
22239
22259
|
} else {
|
|
22240
22260
|
const relativePath = `.${url}`;
|
|
22241
|
-
const absolutePath =
|
|
22261
|
+
const absolutePath = path11.resolve(projectDir, relativePath);
|
|
22242
22262
|
if (fs8.existsSync(absolutePath)) {
|
|
22243
22263
|
fetchUrl = `file://${absolutePath}`;
|
|
22244
22264
|
} else {
|
|
@@ -22375,7 +22395,7 @@ var processSnapshotFile = async ({
|
|
|
22375
22395
|
cameraPreset,
|
|
22376
22396
|
pcbLayer
|
|
22377
22397
|
}) => {
|
|
22378
|
-
const relativeFilePath =
|
|
22398
|
+
const relativeFilePath = path12.relative(projectDir, file);
|
|
22379
22399
|
const successPaths = [];
|
|
22380
22400
|
const warningMessages = [];
|
|
22381
22401
|
const mismatches = [];
|
|
@@ -22471,11 +22491,11 @@ var processSnapshotFile = async ({
|
|
|
22471
22491
|
} catch (error) {
|
|
22472
22492
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
22473
22493
|
if (errorMessage.includes("No pcb_board found in circuit JSON")) {
|
|
22474
|
-
const fileDir =
|
|
22475
|
-
const relativeDir =
|
|
22476
|
-
const snapDir = snapshotsDirName ?
|
|
22477
|
-
const base =
|
|
22478
|
-
const snap3dPath =
|
|
22494
|
+
const fileDir = path12.dirname(file);
|
|
22495
|
+
const relativeDir = path12.relative(projectDir, fileDir);
|
|
22496
|
+
const snapDir = snapshotsDirName ? path12.join(projectDir, snapshotsDirName, relativeDir) : path12.join(fileDir, "__snapshots__");
|
|
22497
|
+
const base = path12.basename(file).replace(/\.[^.]+$/, "");
|
|
22498
|
+
const snap3dPath = path12.join(snapDir, `${base}-3d.snap.png`);
|
|
22479
22499
|
const existing3dSnapshot = fs10.existsSync(snap3dPath);
|
|
22480
22500
|
if (existing3dSnapshot) {
|
|
22481
22501
|
return {
|
|
@@ -22487,7 +22507,7 @@ var processSnapshotFile = async ({
|
|
|
22487
22507
|
errorMessage: kleur_default.red(`
|
|
22488
22508
|
❌ Failed to generate 3D snapshot for ${relativeFilePath}:
|
|
22489
22509
|
`) + kleur_default.red(` No pcb_board found in circuit JSON
|
|
22490
|
-
`) + kleur_default.red(` Existing snapshot: ${
|
|
22510
|
+
`) + kleur_default.red(` Existing snapshot: ${path12.relative(projectDir, snap3dPath)}
|
|
22491
22511
|
`)
|
|
22492
22512
|
};
|
|
22493
22513
|
}
|
|
@@ -22508,9 +22528,9 @@ var processSnapshotFile = async ({
|
|
|
22508
22528
|
}
|
|
22509
22529
|
}
|
|
22510
22530
|
}
|
|
22511
|
-
const snapDir = snapshotsDirName ?
|
|
22531
|
+
const snapDir = snapshotsDirName ? path12.join(projectDir, snapshotsDirName, path12.relative(projectDir, path12.dirname(file))) : path12.join(path12.dirname(file), "__snapshots__");
|
|
22512
22532
|
fs10.mkdirSync(snapDir, { recursive: true });
|
|
22513
|
-
const base =
|
|
22533
|
+
const base = path12.basename(file).replace(/\.[^.]+$/, "");
|
|
22514
22534
|
const snapshots = [];
|
|
22515
22535
|
if (!simulationOnly && (pcbOnly || !schematicOnly)) {
|
|
22516
22536
|
let pcbSnapshotType = "pcb";
|
|
@@ -22551,13 +22571,13 @@ var processSnapshotFile = async ({
|
|
|
22551
22571
|
for (const snapshot of snapshots) {
|
|
22552
22572
|
const { type } = snapshot;
|
|
22553
22573
|
const is3d = type === "3d";
|
|
22554
|
-
const snapPath =
|
|
22574
|
+
const snapPath = path12.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
|
|
22555
22575
|
const existing = fs10.existsSync(snapPath);
|
|
22556
22576
|
const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
|
|
22557
22577
|
const newContentForFile = snapshot.content;
|
|
22558
22578
|
if (!existing) {
|
|
22559
22579
|
fs10.writeFileSync(snapPath, newContentForFile);
|
|
22560
|
-
successPaths.push(
|
|
22580
|
+
successPaths.push(path12.relative(projectDir, snapPath));
|
|
22561
22581
|
didUpdate = true;
|
|
22562
22582
|
continue;
|
|
22563
22583
|
}
|
|
@@ -22575,16 +22595,16 @@ var processSnapshotFile = async ({
|
|
|
22575
22595
|
}
|
|
22576
22596
|
if (update) {
|
|
22577
22597
|
if (!forceUpdate && equal) {
|
|
22578
|
-
successPaths.push(
|
|
22598
|
+
successPaths.push(path12.relative(projectDir, snapPath));
|
|
22579
22599
|
} else {
|
|
22580
22600
|
fs10.writeFileSync(snapPath, newContentForFile);
|
|
22581
|
-
successPaths.push(
|
|
22601
|
+
successPaths.push(path12.relative(projectDir, snapPath));
|
|
22582
22602
|
didUpdate = true;
|
|
22583
22603
|
}
|
|
22584
22604
|
} else if (!equal) {
|
|
22585
22605
|
mismatches.push(diffPath ? `${snapPath} (diff: ${diffPath})` : snapPath);
|
|
22586
22606
|
} else {
|
|
22587
|
-
successPaths.push(
|
|
22607
|
+
successPaths.push(path12.relative(projectDir, snapPath));
|
|
22588
22608
|
}
|
|
22589
22609
|
}
|
|
22590
22610
|
return {
|
|
@@ -22598,7 +22618,7 @@ var processSnapshotFile = async ({
|
|
|
22598
22618
|
|
|
22599
22619
|
// lib/project-config/index.ts
|
|
22600
22620
|
import * as fs11 from "node:fs";
|
|
22601
|
-
import * as
|
|
22621
|
+
import * as path13 from "node:path";
|
|
22602
22622
|
import { pathToFileURL as pathToFileURL4 } from "node:url";
|
|
22603
22623
|
|
|
22604
22624
|
// lib/project-config/project-config-schema.ts
|
|
@@ -22701,7 +22721,7 @@ var stripWrappingQuotes = (value) => {
|
|
|
22701
22721
|
var loadProjectEnv = (projectDir) => {
|
|
22702
22722
|
const initialEnvKeys = new Set(Object.keys(process.env));
|
|
22703
22723
|
for (const envFileName of ENV_FILENAMES) {
|
|
22704
|
-
const envPath =
|
|
22724
|
+
const envPath = path13.join(projectDir, envFileName);
|
|
22705
22725
|
if (!fs11.existsSync(envPath))
|
|
22706
22726
|
continue;
|
|
22707
22727
|
const envContent = fs11.readFileSync(envPath, "utf8");
|
|
@@ -22722,7 +22742,7 @@ var loadProjectEnv = (projectDir) => {
|
|
|
22722
22742
|
}
|
|
22723
22743
|
};
|
|
22724
22744
|
var loadProjectConfigSync = (projectDir = process.cwd(), options = {}) => {
|
|
22725
|
-
const configPath =
|
|
22745
|
+
const configPath = path13.join(projectDir, CONFIG_FILENAME);
|
|
22726
22746
|
if (!fs11.existsSync(configPath)) {
|
|
22727
22747
|
return null;
|
|
22728
22748
|
}
|
|
@@ -22740,7 +22760,7 @@ var loadProjectConfigSync = (projectDir = process.cwd(), options = {}) => {
|
|
|
22740
22760
|
var loadProjectConfigModule = async (projectDir, options = {}) => {
|
|
22741
22761
|
loadProjectEnv(projectDir);
|
|
22742
22762
|
for (const configFileName of CONFIG_MODULE_FILENAMES) {
|
|
22743
|
-
const configPath =
|
|
22763
|
+
const configPath = path13.join(projectDir, configFileName);
|
|
22744
22764
|
if (!fs11.existsSync(configPath))
|
|
22745
22765
|
continue;
|
|
22746
22766
|
try {
|
|
@@ -22801,7 +22821,7 @@ var getSnapshotsDir = (projectDir = process.cwd()) => {
|
|
|
22801
22821
|
return config?.snapshotsDir;
|
|
22802
22822
|
};
|
|
22803
22823
|
var saveProjectConfig = (config, projectDir = process.cwd()) => {
|
|
22804
|
-
const configPath =
|
|
22824
|
+
const configPath = path13.join(projectDir, CONFIG_FILENAME);
|
|
22805
22825
|
try {
|
|
22806
22826
|
const configWithSchema = {
|
|
22807
22827
|
$schema: CONFIG_SCHEMA_URL,
|