@tscircuit/cli 0.1.1610 → 0.1.1611
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 +438 -222
- package/dist/cli/main.js +5 -2
- package/dist/lib/index.js +1 -1
- package/package.json +1 -1
|
@@ -522,11 +522,11 @@ var require_dist = __commonJS((exports, module) => {
|
|
|
522
522
|
if (pad) {
|
|
523
523
|
var need = width - c.length;
|
|
524
524
|
if (need > 0) {
|
|
525
|
-
var
|
|
525
|
+
var z2 = new Array(need + 1).join("0");
|
|
526
526
|
if (i < 0)
|
|
527
|
-
c = "-" +
|
|
527
|
+
c = "-" + z2 + c.slice(1);
|
|
528
528
|
else
|
|
529
|
-
c =
|
|
529
|
+
c = z2 + c;
|
|
530
530
|
}
|
|
531
531
|
}
|
|
532
532
|
}
|
|
@@ -5608,8 +5608,8 @@ var require_utils = __commonJS((exports, module) => {
|
|
|
5608
5608
|
}
|
|
5609
5609
|
return ind;
|
|
5610
5610
|
}
|
|
5611
|
-
function removeDotSegments(
|
|
5612
|
-
let input =
|
|
5611
|
+
function removeDotSegments(path9) {
|
|
5612
|
+
let input = path9;
|
|
5613
5613
|
const output = [];
|
|
5614
5614
|
let nextSlash = -1;
|
|
5615
5615
|
let len = 0;
|
|
@@ -5852,8 +5852,8 @@ var require_schemes = __commonJS((exports, module) => {
|
|
|
5852
5852
|
wsComponent.secure = undefined;
|
|
5853
5853
|
}
|
|
5854
5854
|
if (wsComponent.resourceName) {
|
|
5855
|
-
const [
|
|
5856
|
-
wsComponent.path =
|
|
5855
|
+
const [path9, query] = wsComponent.resourceName.split("?");
|
|
5856
|
+
wsComponent.path = path9 && path9 !== "/" ? path9 : undefined;
|
|
5857
5857
|
wsComponent.query = query;
|
|
5858
5858
|
wsComponent.resourceName = undefined;
|
|
5859
5859
|
}
|
|
@@ -9791,12 +9791,12 @@ var require_dist2 = __commonJS((exports, module) => {
|
|
|
9791
9791
|
throw new Error(`Unknown format "${name}"`);
|
|
9792
9792
|
return f;
|
|
9793
9793
|
};
|
|
9794
|
-
function addFormats(ajv, list,
|
|
9794
|
+
function addFormats(ajv, list, fs7, exportName) {
|
|
9795
9795
|
var _a;
|
|
9796
9796
|
var _b;
|
|
9797
9797
|
(_a = (_b = ajv.opts.code).formats) !== null && _a !== undefined || (_b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`);
|
|
9798
9798
|
for (const f of list)
|
|
9799
|
-
ajv.addFormat(f,
|
|
9799
|
+
ajv.addFormat(f, fs7[f]);
|
|
9800
9800
|
}
|
|
9801
9801
|
module.exports = exports = formatsPlugin;
|
|
9802
9802
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -10815,16 +10815,16 @@ var require_range = __commonJS((exports, module) => {
|
|
|
10815
10815
|
};
|
|
10816
10816
|
var replaceTilde = (comp, options) => {
|
|
10817
10817
|
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
10818
|
-
const
|
|
10818
|
+
const z2 = options.includePrerelease ? "-0" : "";
|
|
10819
10819
|
return comp.replace(r, (_, M, m, p, pr) => {
|
|
10820
10820
|
debug2("tilde", comp, _, M, m, p, pr);
|
|
10821
10821
|
let ret;
|
|
10822
10822
|
if (isX(M)) {
|
|
10823
10823
|
ret = "";
|
|
10824
10824
|
} else if (isX(m)) {
|
|
10825
|
-
ret = `>=${M}.0.0${
|
|
10825
|
+
ret = `>=${M}.0.0${z2} <${+M + 1}.0.0-0`;
|
|
10826
10826
|
} else if (isX(p)) {
|
|
10827
|
-
ret = `>=${M}.${m}.0${
|
|
10827
|
+
ret = `>=${M}.${m}.0${z2} <${M}.${+m + 1}.0-0`;
|
|
10828
10828
|
} else if (pr) {
|
|
10829
10829
|
debug2("replaceTilde pr", pr);
|
|
10830
10830
|
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
@@ -10841,19 +10841,19 @@ var require_range = __commonJS((exports, module) => {
|
|
|
10841
10841
|
var replaceCaret = (comp, options) => {
|
|
10842
10842
|
debug2("caret", comp, options);
|
|
10843
10843
|
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
10844
|
-
const
|
|
10844
|
+
const z2 = options.includePrerelease ? "-0" : "";
|
|
10845
10845
|
return comp.replace(r, (_, M, m, p, pr) => {
|
|
10846
10846
|
debug2("caret", comp, _, M, m, p, pr);
|
|
10847
10847
|
let ret;
|
|
10848
10848
|
if (isX(M)) {
|
|
10849
10849
|
ret = "";
|
|
10850
10850
|
} else if (isX(m)) {
|
|
10851
|
-
ret = `>=${M}.0.0${
|
|
10851
|
+
ret = `>=${M}.0.0${z2} <${+M + 1}.0.0-0`;
|
|
10852
10852
|
} else if (isX(p)) {
|
|
10853
10853
|
if (M === "0") {
|
|
10854
|
-
ret = `>=${M}.${m}.0${
|
|
10854
|
+
ret = `>=${M}.${m}.0${z2} <${M}.${+m + 1}.0-0`;
|
|
10855
10855
|
} else {
|
|
10856
|
-
ret = `>=${M}.${m}.0${
|
|
10856
|
+
ret = `>=${M}.${m}.0${z2} <${+M + 1}.0.0-0`;
|
|
10857
10857
|
}
|
|
10858
10858
|
} else if (pr) {
|
|
10859
10859
|
debug2("replaceCaret pr", pr);
|
|
@@ -11651,8 +11651,188 @@ var require_semver2 = __commonJS((exports, module) => {
|
|
|
11651
11651
|
import { parentPort } from "node:worker_threads";
|
|
11652
11652
|
|
|
11653
11653
|
// cli/build/worker-build-handlers.ts
|
|
11654
|
-
import
|
|
11655
|
-
import
|
|
11654
|
+
import fs11 from "node:fs";
|
|
11655
|
+
import path15 from "node:path";
|
|
11656
|
+
|
|
11657
|
+
// lib/project-config/index.ts
|
|
11658
|
+
import * as fs from "node:fs";
|
|
11659
|
+
import * as path from "node:path";
|
|
11660
|
+
import { pathToFileURL } from "node:url";
|
|
11661
|
+
|
|
11662
|
+
// lib/project-config/project-config-schema.ts
|
|
11663
|
+
import { z } from "zod";
|
|
11664
|
+
var pcbSnapshotSettingsSchema = z.object({
|
|
11665
|
+
showCourtyards: z.boolean().optional(),
|
|
11666
|
+
showPcbNotes: z.boolean().optional(),
|
|
11667
|
+
showFabricationNotes: z.boolean().optional()
|
|
11668
|
+
});
|
|
11669
|
+
var projectConfigSchema = z.object({
|
|
11670
|
+
mainEntrypoint: z.string().optional(),
|
|
11671
|
+
libraryEntrypoint: z.string().optional(),
|
|
11672
|
+
previewComponentPath: z.string().optional(),
|
|
11673
|
+
siteDefaultComponentPath: z.string().optional(),
|
|
11674
|
+
ignoredFiles: z.array(z.string()).optional(),
|
|
11675
|
+
includeBoardFiles: z.array(z.string()).optional(),
|
|
11676
|
+
snapshotsDir: z.string().optional(),
|
|
11677
|
+
pcbSnapshotSettings: pcbSnapshotSettingsSchema.optional(),
|
|
11678
|
+
prebuildCommand: z.string().optional(),
|
|
11679
|
+
buildCommand: z.string().optional(),
|
|
11680
|
+
kicadProjectEntrypointPath: z.string().optional(),
|
|
11681
|
+
kicadLibraryEntrypointPath: z.string().optional(),
|
|
11682
|
+
kicadLibraryName: z.string().optional(),
|
|
11683
|
+
alwaysUseLatestTscircuitOnCloud: z.boolean().optional(),
|
|
11684
|
+
build: z.object({
|
|
11685
|
+
circuitJson: z.boolean().optional(),
|
|
11686
|
+
kicadProject: z.boolean().optional(),
|
|
11687
|
+
kicadLibrary: z.boolean().optional(),
|
|
11688
|
+
kicadPcm: z.boolean().optional(),
|
|
11689
|
+
previewImages: z.boolean().optional(),
|
|
11690
|
+
glbs: z.boolean().optional(),
|
|
11691
|
+
step: z.boolean().optional(),
|
|
11692
|
+
workerTimeoutMs: z.number().int().positive().optional(),
|
|
11693
|
+
routingDisabled: z.boolean().optional(),
|
|
11694
|
+
typescriptLibrary: z.boolean().optional()
|
|
11695
|
+
}).optional()
|
|
11696
|
+
});
|
|
11697
|
+
|
|
11698
|
+
// lib/project-config/index.ts
|
|
11699
|
+
var CONFIG_FILENAME = "tscircuit.config.json";
|
|
11700
|
+
var CONFIG_MODULE_FILENAMES = [
|
|
11701
|
+
"tscircuit.config.ts",
|
|
11702
|
+
"tscircuit.config.js"
|
|
11703
|
+
];
|
|
11704
|
+
var ENV_FILENAMES = [".env", ".env.local"];
|
|
11705
|
+
var CONFIG_SCHEMA_URL = "https://cdn.jsdelivr.net/npm/@tscircuit/cli/types/tscircuit.config.schema.json";
|
|
11706
|
+
var DEFAULT_BOARD_FILE_PATTERNS = [
|
|
11707
|
+
"**/*.board.tsx",
|
|
11708
|
+
"**/*.circuit.tsx",
|
|
11709
|
+
"**/*.circuit.json"
|
|
11710
|
+
];
|
|
11711
|
+
var parseProjectConfigObject = (config) => {
|
|
11712
|
+
if (!config || typeof config !== "object" || Array.isArray(config)) {
|
|
11713
|
+
throw new Error("tscircuit config must export an object");
|
|
11714
|
+
}
|
|
11715
|
+
const { platformConfig, ...serializableConfig } = config;
|
|
11716
|
+
const parsedConfig = projectConfigSchema.parse(serializableConfig);
|
|
11717
|
+
if (platformConfig === undefined) {
|
|
11718
|
+
return parsedConfig;
|
|
11719
|
+
}
|
|
11720
|
+
return {
|
|
11721
|
+
...parsedConfig,
|
|
11722
|
+
platformConfig
|
|
11723
|
+
};
|
|
11724
|
+
};
|
|
11725
|
+
var stripWrappingQuotes = (value) => {
|
|
11726
|
+
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
11727
|
+
return value.slice(1, -1);
|
|
11728
|
+
}
|
|
11729
|
+
return value;
|
|
11730
|
+
};
|
|
11731
|
+
var loadProjectEnv = (projectDir) => {
|
|
11732
|
+
const initialEnvKeys = new Set(Object.keys(process.env));
|
|
11733
|
+
for (const envFileName of ENV_FILENAMES) {
|
|
11734
|
+
const envPath = path.join(projectDir, envFileName);
|
|
11735
|
+
if (!fs.existsSync(envPath))
|
|
11736
|
+
continue;
|
|
11737
|
+
const envContent = fs.readFileSync(envPath, "utf8");
|
|
11738
|
+
for (const rawLine of envContent.split(/\r?\n/)) {
|
|
11739
|
+
const line = rawLine.trim();
|
|
11740
|
+
if (!line || line.startsWith("#"))
|
|
11741
|
+
continue;
|
|
11742
|
+
const lineWithoutExport = line.startsWith("export ") ? line.slice("export ".length) : line;
|
|
11743
|
+
const separatorIndex = lineWithoutExport.indexOf("=");
|
|
11744
|
+
if (separatorIndex <= 0)
|
|
11745
|
+
continue;
|
|
11746
|
+
const key = lineWithoutExport.slice(0, separatorIndex).trim();
|
|
11747
|
+
if (!key || initialEnvKeys.has(key))
|
|
11748
|
+
continue;
|
|
11749
|
+
const value = stripWrappingQuotes(lineWithoutExport.slice(separatorIndex + 1).trim());
|
|
11750
|
+
process.env[key] = value;
|
|
11751
|
+
}
|
|
11752
|
+
}
|
|
11753
|
+
};
|
|
11754
|
+
var loadProjectConfigSync = (projectDir = process.cwd()) => {
|
|
11755
|
+
const configPath = path.join(projectDir, CONFIG_FILENAME);
|
|
11756
|
+
if (!fs.existsSync(configPath)) {
|
|
11757
|
+
return null;
|
|
11758
|
+
}
|
|
11759
|
+
try {
|
|
11760
|
+
const configContent = fs.readFileSync(configPath, "utf8");
|
|
11761
|
+
const parsedConfig = JSON.parse(configContent);
|
|
11762
|
+
return projectConfigSchema.parse(parsedConfig);
|
|
11763
|
+
} catch (error) {
|
|
11764
|
+
console.error(`Error loading tscircuit config: ${error}`);
|
|
11765
|
+
return null;
|
|
11766
|
+
}
|
|
11767
|
+
};
|
|
11768
|
+
var loadProjectConfigModule = async (projectDir) => {
|
|
11769
|
+
loadProjectEnv(projectDir);
|
|
11770
|
+
for (const configFileName of CONFIG_MODULE_FILENAMES) {
|
|
11771
|
+
const configPath = path.join(projectDir, configFileName);
|
|
11772
|
+
if (!fs.existsSync(configPath))
|
|
11773
|
+
continue;
|
|
11774
|
+
try {
|
|
11775
|
+
const moduleUrl = pathToFileURL(configPath);
|
|
11776
|
+
const stat = fs.statSync(configPath);
|
|
11777
|
+
moduleUrl.searchParams.set("tsci", String(stat.mtimeMs));
|
|
11778
|
+
const importedModule = await import(moduleUrl.href);
|
|
11779
|
+
const exportedConfig = importedModule.default ?? importedModule.config ?? importedModule;
|
|
11780
|
+
return parseProjectConfigObject(exportedConfig);
|
|
11781
|
+
} catch (error) {
|
|
11782
|
+
console.error(`Error loading ${configFileName}: ${error}`);
|
|
11783
|
+
return null;
|
|
11784
|
+
}
|
|
11785
|
+
}
|
|
11786
|
+
return null;
|
|
11787
|
+
};
|
|
11788
|
+
var loadRuntimeProjectConfig = async (projectDir = process.cwd()) => {
|
|
11789
|
+
const jsonConfig = loadProjectConfigSync(projectDir);
|
|
11790
|
+
const moduleConfig = await loadProjectConfigModule(projectDir);
|
|
11791
|
+
if (!jsonConfig && !moduleConfig) {
|
|
11792
|
+
return null;
|
|
11793
|
+
}
|
|
11794
|
+
return {
|
|
11795
|
+
...jsonConfig ?? {},
|
|
11796
|
+
...moduleConfig ?? {},
|
|
11797
|
+
build: {
|
|
11798
|
+
...jsonConfig?.build,
|
|
11799
|
+
...moduleConfig?.build
|
|
11800
|
+
},
|
|
11801
|
+
pcbSnapshotSettings: {
|
|
11802
|
+
...jsonConfig?.pcbSnapshotSettings,
|
|
11803
|
+
...moduleConfig?.pcbSnapshotSettings
|
|
11804
|
+
}
|
|
11805
|
+
};
|
|
11806
|
+
};
|
|
11807
|
+
var loadProjectConfig = (projectDir = process.cwd()) => {
|
|
11808
|
+
return loadProjectConfigSync(projectDir);
|
|
11809
|
+
};
|
|
11810
|
+
var getBoardFilePatterns = (projectDir = process.cwd()) => {
|
|
11811
|
+
const config = loadProjectConfigSync(projectDir);
|
|
11812
|
+
const patterns = config?.includeBoardFiles?.filter((pattern) => pattern.trim());
|
|
11813
|
+
if (patterns && patterns.length > 0) {
|
|
11814
|
+
return patterns;
|
|
11815
|
+
}
|
|
11816
|
+
return DEFAULT_BOARD_FILE_PATTERNS;
|
|
11817
|
+
};
|
|
11818
|
+
var getSnapshotsDir = (projectDir = process.cwd()) => {
|
|
11819
|
+
const config = loadProjectConfigSync(projectDir);
|
|
11820
|
+
return config?.snapshotsDir;
|
|
11821
|
+
};
|
|
11822
|
+
var saveProjectConfig = (config, projectDir = process.cwd()) => {
|
|
11823
|
+
const configPath = path.join(projectDir, CONFIG_FILENAME);
|
|
11824
|
+
try {
|
|
11825
|
+
const configWithSchema = {
|
|
11826
|
+
$schema: CONFIG_SCHEMA_URL,
|
|
11827
|
+
...config ?? {}
|
|
11828
|
+
};
|
|
11829
|
+
fs.writeFileSync(configPath, JSON.stringify(configWithSchema, null, 2));
|
|
11830
|
+
return true;
|
|
11831
|
+
} catch (error) {
|
|
11832
|
+
console.error(`Error saving tscircuit config: ${error}`);
|
|
11833
|
+
return false;
|
|
11834
|
+
}
|
|
11835
|
+
};
|
|
11656
11836
|
|
|
11657
11837
|
// lib/shared/circuit-json-diagnostics.ts
|
|
11658
11838
|
function analyzeCircuitJson(circuitJson) {
|
|
@@ -11678,9 +11858,9 @@ function analyzeCircuitJson(circuitJson) {
|
|
|
11678
11858
|
}
|
|
11679
11859
|
|
|
11680
11860
|
// lib/shared/generate-circuit-json.tsx
|
|
11681
|
-
import
|
|
11682
|
-
import
|
|
11683
|
-
import { pathToFileURL } from "node:url";
|
|
11861
|
+
import fs4 from "node:fs";
|
|
11862
|
+
import path4 from "node:path";
|
|
11863
|
+
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
11684
11864
|
import Debug from "debug";
|
|
11685
11865
|
|
|
11686
11866
|
// lib/utils/abbreviate-stringify-object.ts
|
|
@@ -11702,12 +11882,12 @@ var import_make_vfs = __toESM(require_dist(), 1);
|
|
|
11702
11882
|
|
|
11703
11883
|
// lib/shared/importFromUserLand.ts
|
|
11704
11884
|
import { createRequire as createRequire2 } from "node:module";
|
|
11705
|
-
import
|
|
11706
|
-
import
|
|
11885
|
+
import fs2 from "node:fs";
|
|
11886
|
+
import path2 from "node:path";
|
|
11707
11887
|
async function importFromUserLand(moduleName) {
|
|
11708
|
-
const userModulePath =
|
|
11709
|
-
if (
|
|
11710
|
-
const userRequire = createRequire2(
|
|
11888
|
+
const userModulePath = path2.join(process.cwd(), "node_modules", moduleName);
|
|
11889
|
+
if (fs2.existsSync(userModulePath)) {
|
|
11890
|
+
const userRequire = createRequire2(path2.join(process.cwd(), "noop.js"));
|
|
11711
11891
|
try {
|
|
11712
11892
|
const resolvedUserPath = userRequire.resolve(moduleName);
|
|
11713
11893
|
return await import(resolvedUserPath);
|
|
@@ -11730,8 +11910,8 @@ async function importFromUserLand(moduleName) {
|
|
|
11730
11910
|
}
|
|
11731
11911
|
|
|
11732
11912
|
// lib/shared/register-static-asset-loaders.ts
|
|
11733
|
-
import
|
|
11734
|
-
import
|
|
11913
|
+
import fs3 from "node:fs";
|
|
11914
|
+
import path3 from "node:path";
|
|
11735
11915
|
var STATIC_ASSET_EXTENSIONS = [
|
|
11736
11916
|
".glb",
|
|
11737
11917
|
".gltf",
|
|
@@ -11756,15 +11936,15 @@ var TEXT_STATIC_ASSET_EXTENSIONS = new Set([
|
|
|
11756
11936
|
".kicad_sch"
|
|
11757
11937
|
]);
|
|
11758
11938
|
var readFileContentForStaticLoader = (filePath) => {
|
|
11759
|
-
const ext =
|
|
11939
|
+
const ext = path3.extname(filePath).toLowerCase();
|
|
11760
11940
|
if (TEXT_STATIC_ASSET_EXTENSIONS.has(ext)) {
|
|
11761
|
-
return
|
|
11941
|
+
return fs3.readFileSync(filePath, "utf-8");
|
|
11762
11942
|
}
|
|
11763
|
-
const buffer =
|
|
11943
|
+
const buffer = fs3.readFileSync(filePath);
|
|
11764
11944
|
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
11765
11945
|
};
|
|
11766
11946
|
var getStaticFileLoader = (filePath) => {
|
|
11767
|
-
const extWithDot =
|
|
11947
|
+
const extWithDot = path3.extname(filePath).toLowerCase();
|
|
11768
11948
|
const ext = extWithDot.replace(/^\./, "");
|
|
11769
11949
|
return activePlatformConfig?.staticFileLoaderMap?.[ext] ?? activePlatformConfig?.staticFileLoaderMap?.[extWithDot];
|
|
11770
11950
|
};
|
|
@@ -11778,12 +11958,12 @@ var normalizeStaticFileLoaderResult = (result) => {
|
|
|
11778
11958
|
};
|
|
11779
11959
|
};
|
|
11780
11960
|
var getBaseUrlFromTsConfig = () => {
|
|
11781
|
-
const tsconfigPath =
|
|
11961
|
+
const tsconfigPath = path3.join(process.cwd(), "tsconfig.json");
|
|
11782
11962
|
try {
|
|
11783
|
-
if (!
|
|
11963
|
+
if (!fs3.existsSync(tsconfigPath)) {
|
|
11784
11964
|
return null;
|
|
11785
11965
|
}
|
|
11786
|
-
const tsconfigContent =
|
|
11966
|
+
const tsconfigContent = fs3.readFileSync(tsconfigPath, "utf-8");
|
|
11787
11967
|
const tsconfig = JSON.parse(tsconfigContent);
|
|
11788
11968
|
if (tsconfig.compilerOptions?.baseUrl) {
|
|
11789
11969
|
return tsconfig.compilerOptions.baseUrl;
|
|
@@ -11810,8 +11990,8 @@ var registerStaticAssetLoaders = (platformConfig) => {
|
|
|
11810
11990
|
loader: "object"
|
|
11811
11991
|
};
|
|
11812
11992
|
}
|
|
11813
|
-
const baseDir = baseUrl ?
|
|
11814
|
-
const relativePath =
|
|
11993
|
+
const baseDir = baseUrl ? path3.resolve(process.cwd(), baseUrl) : process.cwd();
|
|
11994
|
+
const relativePath = path3.relative(baseDir, args.path).split(path3.sep).join("/");
|
|
11815
11995
|
const pathStr = `./${relativePath}`;
|
|
11816
11996
|
return {
|
|
11817
11997
|
exports: {
|
|
@@ -11860,12 +12040,12 @@ async function generateCircuitJson({
|
|
|
11860
12040
|
const runner = new userLandTscircuit.RootCircuit({
|
|
11861
12041
|
platform: platformConfig
|
|
11862
12042
|
});
|
|
11863
|
-
const absoluteFilePath =
|
|
11864
|
-
const projectDir =
|
|
12043
|
+
const absoluteFilePath = path4.isAbsolute(filePath) ? filePath : path4.resolve(process.cwd(), filePath);
|
|
12044
|
+
const projectDir = path4.dirname(absoluteFilePath);
|
|
11865
12045
|
const resolvedOutputDir = outputDir ?? projectDir;
|
|
11866
|
-
const relativeComponentPath =
|
|
11867
|
-
const baseFileName = outputFileName ||
|
|
11868
|
-
const outputPath =
|
|
12046
|
+
const relativeComponentPath = path4.relative(projectDir, absoluteFilePath);
|
|
12047
|
+
const baseFileName = outputFileName || path4.basename(absoluteFilePath).replace(/\.[^.]+$/, "");
|
|
12048
|
+
const outputPath = path4.join(resolvedOutputDir, `${baseFileName}.circuit.json`);
|
|
11869
12049
|
debug(`Project directory: ${projectDir}`);
|
|
11870
12050
|
debug(`Relative component path: ${relativeComponentPath}`);
|
|
11871
12051
|
debug(`Output path: ${outputPath}`);
|
|
@@ -11885,7 +12065,7 @@ async function generateCircuitJson({
|
|
|
11885
12065
|
return false;
|
|
11886
12066
|
if (normalizedFilePath.match(/^\.[^/]/))
|
|
11887
12067
|
return false;
|
|
11888
|
-
if (!ALLOWED_FILE_EXTENSIONS.includes(
|
|
12068
|
+
if (!ALLOWED_FILE_EXTENSIONS.includes(path4.extname(normalizedFilePath)))
|
|
11889
12069
|
return false;
|
|
11890
12070
|
return true;
|
|
11891
12071
|
},
|
|
@@ -11893,7 +12073,7 @@ async function generateCircuitJson({
|
|
|
11893
12073
|
})
|
|
11894
12074
|
};
|
|
11895
12075
|
debug(`fsMap: ${abbreviateStringifyObject(fsMap)}`);
|
|
11896
|
-
const MainComponent = await import(
|
|
12076
|
+
const MainComponent = await import(pathToFileURL2(absoluteFilePath).href);
|
|
11897
12077
|
const Component = MainComponent.default || (Object.keys(MainComponent).find((k) => k[0] === k[0].toUpperCase()) !== undefined ? MainComponent[Object.keys(MainComponent).find((k) => k[0] === k[0].toUpperCase())] : undefined);
|
|
11898
12078
|
if (!Component) {
|
|
11899
12079
|
throw new Error(`No component found in "${absoluteFilePath}". Make sure you export a component.`);
|
|
@@ -11919,7 +12099,7 @@ async function generateCircuitJson({
|
|
|
11919
12099
|
const circuitJson = await runner.getCircuitJson();
|
|
11920
12100
|
if (saveToFile) {
|
|
11921
12101
|
debug(`Saving circuit JSON to ${outputPath}`);
|
|
11922
|
-
|
|
12102
|
+
fs4.writeFileSync(outputPath, JSON.stringify(circuitJson, null, 2));
|
|
11923
12103
|
}
|
|
11924
12104
|
return {
|
|
11925
12105
|
circuitJson,
|
|
@@ -11930,28 +12110,28 @@ async function generateCircuitJson({
|
|
|
11930
12110
|
|
|
11931
12111
|
// lib/shared/get-platform-config-with-cli-defaults.ts
|
|
11932
12112
|
import { createHash } from "node:crypto";
|
|
11933
|
-
import
|
|
11934
|
-
import
|
|
12113
|
+
import fs5 from "node:fs";
|
|
12114
|
+
import path5 from "node:path";
|
|
11935
12115
|
import { getPlatformConfig } from "@tscircuit/eval/platform-config";
|
|
11936
|
-
function createLocalCacheEngine(cacheDir =
|
|
12116
|
+
function createLocalCacheEngine(cacheDir = path5.join(process.cwd(), ".tscircuit", "cache")) {
|
|
11937
12117
|
return {
|
|
11938
12118
|
getItem: (key) => {
|
|
11939
12119
|
try {
|
|
11940
12120
|
const hash = createHash("md5").update(key).digest("hex");
|
|
11941
12121
|
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
11942
|
-
const filePath =
|
|
11943
|
-
return
|
|
12122
|
+
const filePath = path5.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
12123
|
+
return fs5.readFileSync(filePath, "utf-8");
|
|
11944
12124
|
} catch {
|
|
11945
12125
|
return null;
|
|
11946
12126
|
}
|
|
11947
12127
|
},
|
|
11948
12128
|
setItem: (key, value) => {
|
|
11949
12129
|
try {
|
|
11950
|
-
|
|
12130
|
+
fs5.mkdirSync(cacheDir, { recursive: true });
|
|
11951
12131
|
const hash = createHash("md5").update(key).digest("hex");
|
|
11952
12132
|
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
11953
|
-
const filePath =
|
|
11954
|
-
|
|
12133
|
+
const filePath = path5.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
12134
|
+
fs5.writeFileSync(filePath, value);
|
|
11955
12135
|
} catch {}
|
|
11956
12136
|
}
|
|
11957
12137
|
};
|
|
@@ -11967,15 +12147,15 @@ function getPlatformConfigWithCliDefaults(userConfig) {
|
|
|
11967
12147
|
loadFromUrl: async (url) => {
|
|
11968
12148
|
let fetchUrl = url;
|
|
11969
12149
|
if (url.startsWith("./") || url.startsWith("../")) {
|
|
11970
|
-
const absolutePath =
|
|
12150
|
+
const absolutePath = path5.resolve(process.cwd(), url);
|
|
11971
12151
|
fetchUrl = `file://${absolutePath}`;
|
|
11972
12152
|
} else if (url.startsWith("/")) {
|
|
11973
|
-
if (
|
|
12153
|
+
if (fs5.existsSync(url)) {
|
|
11974
12154
|
fetchUrl = `file://${url}`;
|
|
11975
12155
|
} else {
|
|
11976
12156
|
const relativePath = `.${url}`;
|
|
11977
|
-
const absolutePath =
|
|
11978
|
-
if (
|
|
12157
|
+
const absolutePath = path5.resolve(process.cwd(), relativePath);
|
|
12158
|
+
if (fs5.existsSync(absolutePath)) {
|
|
11979
12159
|
fetchUrl = `file://${absolutePath}`;
|
|
11980
12160
|
} else {
|
|
11981
12161
|
fetchUrl = `file://${url}`;
|
|
@@ -12007,6 +12187,40 @@ function getPlatformConfigWithCliDefaults(userConfig) {
|
|
|
12007
12187
|
return mergedConfig;
|
|
12008
12188
|
}
|
|
12009
12189
|
|
|
12190
|
+
// lib/shared/platform-config-utils.ts
|
|
12191
|
+
var mergePlatformConfigs = (...configs) => {
|
|
12192
|
+
const definedConfigs = configs.filter(Boolean);
|
|
12193
|
+
if (definedConfigs.length === 0) {
|
|
12194
|
+
return;
|
|
12195
|
+
}
|
|
12196
|
+
return definedConfigs.reduce((mergedConfig, config) => {
|
|
12197
|
+
return {
|
|
12198
|
+
...mergedConfig,
|
|
12199
|
+
...config,
|
|
12200
|
+
footprintLibraryMap: {
|
|
12201
|
+
...mergedConfig.footprintLibraryMap,
|
|
12202
|
+
...config.footprintLibraryMap
|
|
12203
|
+
},
|
|
12204
|
+
footprintFileParserMap: {
|
|
12205
|
+
...mergedConfig.footprintFileParserMap,
|
|
12206
|
+
...config.footprintFileParserMap
|
|
12207
|
+
},
|
|
12208
|
+
staticFileLoaderMap: {
|
|
12209
|
+
...mergedConfig.staticFileLoaderMap,
|
|
12210
|
+
...config.staticFileLoaderMap
|
|
12211
|
+
},
|
|
12212
|
+
autorouterMap: {
|
|
12213
|
+
...mergedConfig.autorouterMap,
|
|
12214
|
+
...config.autorouterMap
|
|
12215
|
+
},
|
|
12216
|
+
spiceEngineMap: {
|
|
12217
|
+
...mergedConfig.spiceEngineMap,
|
|
12218
|
+
...config.spiceEngineMap
|
|
12219
|
+
}
|
|
12220
|
+
};
|
|
12221
|
+
}, {});
|
|
12222
|
+
};
|
|
12223
|
+
|
|
12010
12224
|
// cli/build/drc-diagnostic-filter.ts
|
|
12011
12225
|
import {
|
|
12012
12226
|
categorizeErrorOrWarning
|
|
@@ -12166,8 +12380,8 @@ var resolveImageFormatSelection = (options) => {
|
|
|
12166
12380
|
};
|
|
12167
12381
|
|
|
12168
12382
|
// cli/build/worker-output-generators.ts
|
|
12169
|
-
import
|
|
12170
|
-
import
|
|
12383
|
+
import fs10 from "node:fs";
|
|
12384
|
+
import path14 from "node:path";
|
|
12171
12385
|
|
|
12172
12386
|
// node_modules/circuit-json-to-3d-png/dist/index.js
|
|
12173
12387
|
function normalizeDir(dir) {
|
|
@@ -12450,12 +12664,12 @@ var Axis2Placement3D = class _Axis2Placement3D extends Entity {
|
|
|
12450
12664
|
};
|
|
12451
12665
|
register("AXIS2_PLACEMENT_3D", Axis2Placement3D.parse.bind(Axis2Placement3D));
|
|
12452
12666
|
var CartesianPoint = class _CartesianPoint extends Entity {
|
|
12453
|
-
constructor(name, x, y,
|
|
12667
|
+
constructor(name, x, y, z2) {
|
|
12454
12668
|
super();
|
|
12455
12669
|
this.name = name;
|
|
12456
12670
|
this.x = x;
|
|
12457
12671
|
this.y = y;
|
|
12458
|
-
this.z =
|
|
12672
|
+
this.z = z2;
|
|
12459
12673
|
}
|
|
12460
12674
|
type = "CARTESIAN_POINT";
|
|
12461
12675
|
static parse(a, ctx) {
|
|
@@ -13459,22 +13673,22 @@ function createStyledItems(repo, options) {
|
|
|
13459
13673
|
function rotatePoint3(point, rotation) {
|
|
13460
13674
|
if (!rotation)
|
|
13461
13675
|
return point;
|
|
13462
|
-
let { x, y, z } = point;
|
|
13676
|
+
let { x, y, z: z2 } = point;
|
|
13463
13677
|
if (rotation.x) {
|
|
13464
13678
|
const cos = Math.cos(rotation.x);
|
|
13465
13679
|
const sin = Math.sin(rotation.x);
|
|
13466
|
-
const nextY = y * cos -
|
|
13467
|
-
const nextZ = y * sin +
|
|
13680
|
+
const nextY = y * cos - z2 * sin;
|
|
13681
|
+
const nextZ = y * sin + z2 * cos;
|
|
13468
13682
|
y = nextY;
|
|
13469
|
-
|
|
13683
|
+
z2 = nextZ;
|
|
13470
13684
|
}
|
|
13471
13685
|
if (rotation.y) {
|
|
13472
13686
|
const cos = Math.cos(rotation.y);
|
|
13473
13687
|
const sin = Math.sin(rotation.y);
|
|
13474
|
-
const nextX = x * cos +
|
|
13475
|
-
const nextZ = -x * sin +
|
|
13688
|
+
const nextX = x * cos + z2 * sin;
|
|
13689
|
+
const nextZ = -x * sin + z2 * cos;
|
|
13476
13690
|
x = nextX;
|
|
13477
|
-
|
|
13691
|
+
z2 = nextZ;
|
|
13478
13692
|
}
|
|
13479
13693
|
if (rotation.z) {
|
|
13480
13694
|
const cos = Math.cos(rotation.z);
|
|
@@ -13484,7 +13698,7 @@ function rotatePoint3(point, rotation) {
|
|
|
13484
13698
|
x = nextX;
|
|
13485
13699
|
y = nextY;
|
|
13486
13700
|
}
|
|
13487
|
-
return { x, y, z };
|
|
13701
|
+
return { x, y, z: z2 };
|
|
13488
13702
|
}
|
|
13489
13703
|
function createVertex(repo, point) {
|
|
13490
13704
|
return repo.add(new VertexPoint("", repo.add(new CartesianPoint("", point.x, point.y, point.z))));
|
|
@@ -13722,22 +13936,22 @@ function transformDirection(vector, rotation) {
|
|
|
13722
13936
|
return rotateVector(vector, rotation);
|
|
13723
13937
|
}
|
|
13724
13938
|
function rotateVector(vector, rotation) {
|
|
13725
|
-
let [x, y,
|
|
13939
|
+
let [x, y, z2] = vector;
|
|
13726
13940
|
if (rotation.x !== 0) {
|
|
13727
13941
|
const cosX = Math.cos(rotation.x);
|
|
13728
13942
|
const sinX = Math.sin(rotation.x);
|
|
13729
|
-
const y1 = y * cosX -
|
|
13730
|
-
const z1 = y * sinX +
|
|
13943
|
+
const y1 = y * cosX - z2 * sinX;
|
|
13944
|
+
const z1 = y * sinX + z2 * cosX;
|
|
13731
13945
|
y = y1;
|
|
13732
|
-
|
|
13946
|
+
z2 = z1;
|
|
13733
13947
|
}
|
|
13734
13948
|
if (rotation.y !== 0) {
|
|
13735
13949
|
const cosY = Math.cos(rotation.y);
|
|
13736
13950
|
const sinY = Math.sin(rotation.y);
|
|
13737
|
-
const x1 = x * cosY +
|
|
13738
|
-
const z1 = -x * sinY +
|
|
13951
|
+
const x1 = x * cosY + z2 * sinY;
|
|
13952
|
+
const z1 = -x * sinY + z2 * cosY;
|
|
13739
13953
|
x = x1;
|
|
13740
|
-
|
|
13954
|
+
z2 = z1;
|
|
13741
13955
|
}
|
|
13742
13956
|
if (rotation.z !== 0) {
|
|
13743
13957
|
const cosZ = Math.cos(rotation.z);
|
|
@@ -13747,7 +13961,7 @@ function rotateVector(vector, rotation) {
|
|
|
13747
13961
|
x = x1;
|
|
13748
13962
|
y = y1;
|
|
13749
13963
|
}
|
|
13750
|
-
return [x, y,
|
|
13964
|
+
return [x, y, z2];
|
|
13751
13965
|
}
|
|
13752
13966
|
async function readStepFile(modelUrl) {
|
|
13753
13967
|
if (!/^https?:\/\//i.test(modelUrl)) {
|
|
@@ -13927,19 +14141,19 @@ function adjustTransformForPlacement(entries, transform, placement) {
|
|
|
13927
14141
|
let maxY = -Infinity;
|
|
13928
14142
|
let maxZ = -Infinity;
|
|
13929
14143
|
for (const point of points) {
|
|
13930
|
-
const [x, y,
|
|
14144
|
+
const [x, y, z2] = rotateVector(point, rotationRadians);
|
|
13931
14145
|
if (x < minX)
|
|
13932
14146
|
minX = x;
|
|
13933
14147
|
if (y < minY)
|
|
13934
14148
|
minY = y;
|
|
13935
|
-
if (
|
|
13936
|
-
minZ =
|
|
14149
|
+
if (z2 < minZ)
|
|
14150
|
+
minZ = z2;
|
|
13937
14151
|
if (x > maxX)
|
|
13938
14152
|
maxX = x;
|
|
13939
14153
|
if (y > maxY)
|
|
13940
14154
|
maxY = y;
|
|
13941
|
-
if (
|
|
13942
|
-
maxZ =
|
|
14155
|
+
if (z2 > maxZ)
|
|
14156
|
+
maxZ = z2;
|
|
13943
14157
|
}
|
|
13944
14158
|
if (!Number.isFinite(minX))
|
|
13945
14159
|
return;
|
|
@@ -14169,21 +14383,21 @@ function rotatePoint(x, y, centerX, centerY, angle) {
|
|
|
14169
14383
|
y: centerY + dx * sin + dy * cos
|
|
14170
14384
|
};
|
|
14171
14385
|
}
|
|
14172
|
-
function createVertexAt(repo, x, y,
|
|
14173
|
-
return repo.add(new VertexPoint("", repo.add(new CartesianPoint("", x, y,
|
|
14386
|
+
function createVertexAt(repo, x, y, z2) {
|
|
14387
|
+
return repo.add(new VertexPoint("", repo.add(new CartesianPoint("", x, y, z2))));
|
|
14174
14388
|
}
|
|
14175
|
-
function createVertexCache(repo,
|
|
14389
|
+
function createVertexCache(repo, z2) {
|
|
14176
14390
|
const vertices = /* @__PURE__ */ new Map;
|
|
14177
14391
|
const normalize = (value) => {
|
|
14178
14392
|
const rounded = Number(value.toFixed(9));
|
|
14179
14393
|
return Object.is(rounded, -0) ? 0 : rounded;
|
|
14180
14394
|
};
|
|
14181
14395
|
return (x, y) => {
|
|
14182
|
-
const key = `${normalize(x)},${normalize(y)},${normalize(
|
|
14396
|
+
const key = `${normalize(x)},${normalize(y)},${normalize(z2)}`;
|
|
14183
14397
|
const existing = vertices.get(key);
|
|
14184
14398
|
if (existing)
|
|
14185
14399
|
return existing;
|
|
14186
|
-
const vertex = createVertexAt(repo, x, y,
|
|
14400
|
+
const vertex = createVertexAt(repo, x, y, z2);
|
|
14187
14401
|
vertices.set(key, vertex);
|
|
14188
14402
|
return vertex;
|
|
14189
14403
|
};
|
|
@@ -14216,13 +14430,13 @@ function createLineSegment(repo, start, end, getVertex) {
|
|
|
14216
14430
|
end: endVertex
|
|
14217
14431
|
};
|
|
14218
14432
|
}
|
|
14219
|
-
function createArcSegment(repo, centerX, centerY,
|
|
14433
|
+
function createArcSegment(repo, centerX, centerY, z2, radius, startAngle, endAngle, rotation, centerX0, centerY0, getVertex) {
|
|
14220
14434
|
const start = rotatePoint(centerX + radius * Math.cos(startAngle), centerY + radius * Math.sin(startAngle), centerX0, centerY0, rotation);
|
|
14221
14435
|
const end = rotatePoint(centerX + radius * Math.cos(endAngle), centerY + radius * Math.sin(endAngle), centerX0, centerY0, rotation);
|
|
14222
14436
|
const center = rotatePoint(centerX, centerY, centerX0, centerY0, rotation);
|
|
14223
14437
|
const startVertex = getVertex(start.x, start.y);
|
|
14224
14438
|
const endVertex = getVertex(end.x, end.y);
|
|
14225
|
-
const centerPoint = repo.add(new CartesianPoint("", center.x, center.y,
|
|
14439
|
+
const centerPoint = repo.add(new CartesianPoint("", center.x, center.y, z2));
|
|
14226
14440
|
const normalDir = repo.add(new Direction("", 0, 0, -1));
|
|
14227
14441
|
const refDir = repo.add(new Direction("", Math.cos(rotation), Math.sin(rotation), 0));
|
|
14228
14442
|
const placement = repo.add(new Axis2Placement3D("", centerPoint, normalDir, refDir));
|
|
@@ -14237,7 +14451,7 @@ function createArcSegment(repo, centerX, centerY, z, radius, startAngle, endAngl
|
|
|
14237
14451
|
radius
|
|
14238
14452
|
};
|
|
14239
14453
|
}
|
|
14240
|
-
function createPillBoundarySegments(repo, hole,
|
|
14454
|
+
function createPillBoundarySegments(repo, hole, z2) {
|
|
14241
14455
|
const geom = getPillGeometry(hole);
|
|
14242
14456
|
const {
|
|
14243
14457
|
centerX,
|
|
@@ -14248,19 +14462,19 @@ function createPillBoundarySegments(repo, hole, z) {
|
|
|
14248
14462
|
isHorizontal
|
|
14249
14463
|
} = geom;
|
|
14250
14464
|
const capOffset = straightHalfLength;
|
|
14251
|
-
const getVertex = createVertexCache(repo,
|
|
14465
|
+
const getVertex = createVertexCache(repo, z2);
|
|
14252
14466
|
if (isHorizontal) {
|
|
14253
14467
|
return [
|
|
14254
|
-
createArcSegment(repo, centerX + capOffset, centerY,
|
|
14468
|
+
createArcSegment(repo, centerX + capOffset, centerY, z2, radius, -Math.PI / 2, Math.PI / 2, rotation, centerX, centerY, getVertex),
|
|
14255
14469
|
createLineSegment(repo, rotatePoint(centerX + capOffset, centerY - radius, centerX, centerY, rotation), rotatePoint(centerX - capOffset, centerY - radius, centerX, centerY, rotation), getVertex),
|
|
14256
|
-
createArcSegment(repo, centerX - capOffset, centerY,
|
|
14470
|
+
createArcSegment(repo, centerX - capOffset, centerY, z2, radius, Math.PI / 2, 3 * Math.PI / 2, rotation, centerX, centerY, getVertex),
|
|
14257
14471
|
createLineSegment(repo, rotatePoint(centerX - capOffset, centerY + radius, centerX, centerY, rotation), rotatePoint(centerX + capOffset, centerY + radius, centerX, centerY, rotation), getVertex)
|
|
14258
14472
|
];
|
|
14259
14473
|
}
|
|
14260
14474
|
return [
|
|
14261
|
-
createArcSegment(repo, centerX, centerY - capOffset,
|
|
14475
|
+
createArcSegment(repo, centerX, centerY - capOffset, z2, radius, Math.PI, 0, rotation, centerX, centerY, getVertex),
|
|
14262
14476
|
createLineSegment(repo, rotatePoint(centerX + radius, centerY - capOffset, centerX, centerY, rotation), rotatePoint(centerX + radius, centerY + capOffset, centerX, centerY, rotation), getVertex),
|
|
14263
|
-
createArcSegment(repo, centerX, centerY + capOffset,
|
|
14477
|
+
createArcSegment(repo, centerX, centerY + capOffset, z2, radius, 0, Math.PI, rotation, centerX, centerY, getVertex),
|
|
14264
14478
|
createLineSegment(repo, rotatePoint(centerX - radius, centerY + capOffset, centerX, centerY, rotation), rotatePoint(centerX - radius, centerY - capOffset, centerX, centerY, rotation), getVertex)
|
|
14265
14479
|
];
|
|
14266
14480
|
}
|
|
@@ -14407,7 +14621,7 @@ async function circuitJsonToStep(circuitJson, options = {}) {
|
|
|
14407
14621
|
[boardCenterX + halfWidth, boardCenterY + halfHeight, halfBoardThickness],
|
|
14408
14622
|
[boardCenterX - halfWidth, boardCenterY + halfHeight, halfBoardThickness]
|
|
14409
14623
|
];
|
|
14410
|
-
const vertices = corners.map(([x, y,
|
|
14624
|
+
const vertices = corners.map(([x, y, z2]) => repo.add(new VertexPoint("", repo.add(new CartesianPoint("", x, y, z2)))));
|
|
14411
14625
|
bottomVertices = [vertices[0], vertices[1], vertices[2], vertices[3]];
|
|
14412
14626
|
topVertices = [vertices[4], vertices[5], vertices[6], vertices[7]];
|
|
14413
14627
|
}
|
|
@@ -14648,8 +14862,8 @@ import {
|
|
|
14648
14862
|
// node_modules/conf/dist/source/index.js
|
|
14649
14863
|
import { isDeepStrictEqual } from "node:util";
|
|
14650
14864
|
import process7 from "node:process";
|
|
14651
|
-
import
|
|
14652
|
-
import
|
|
14865
|
+
import fs7 from "node:fs";
|
|
14866
|
+
import path9 from "node:path";
|
|
14653
14867
|
import crypto from "node:crypto";
|
|
14654
14868
|
import assert from "node:assert";
|
|
14655
14869
|
|
|
@@ -14664,12 +14878,12 @@ var disallowedKeys = new Set([
|
|
|
14664
14878
|
"constructor"
|
|
14665
14879
|
]);
|
|
14666
14880
|
var digits = new Set("0123456789");
|
|
14667
|
-
function getPathSegments(
|
|
14881
|
+
function getPathSegments(path6) {
|
|
14668
14882
|
const parts = [];
|
|
14669
14883
|
let currentSegment = "";
|
|
14670
14884
|
let currentPart = "start";
|
|
14671
14885
|
let isIgnoring = false;
|
|
14672
|
-
for (const character of
|
|
14886
|
+
for (const character of path6) {
|
|
14673
14887
|
switch (character) {
|
|
14674
14888
|
case "\\": {
|
|
14675
14889
|
if (currentPart === "index") {
|
|
@@ -14791,11 +15005,11 @@ function assertNotStringIndex(object, key) {
|
|
|
14791
15005
|
throw new Error("Cannot use string index");
|
|
14792
15006
|
}
|
|
14793
15007
|
}
|
|
14794
|
-
function getProperty(object,
|
|
14795
|
-
if (!isObject(object) || typeof
|
|
15008
|
+
function getProperty(object, path6, value) {
|
|
15009
|
+
if (!isObject(object) || typeof path6 !== "string") {
|
|
14796
15010
|
return value === undefined ? object : value;
|
|
14797
15011
|
}
|
|
14798
|
-
const pathArray = getPathSegments(
|
|
15012
|
+
const pathArray = getPathSegments(path6);
|
|
14799
15013
|
if (pathArray.length === 0) {
|
|
14800
15014
|
return value;
|
|
14801
15015
|
}
|
|
@@ -14815,12 +15029,12 @@ function getProperty(object, path5, value) {
|
|
|
14815
15029
|
}
|
|
14816
15030
|
return object === undefined ? value : object;
|
|
14817
15031
|
}
|
|
14818
|
-
function setProperty(object,
|
|
14819
|
-
if (!isObject(object) || typeof
|
|
15032
|
+
function setProperty(object, path6, value) {
|
|
15033
|
+
if (!isObject(object) || typeof path6 !== "string") {
|
|
14820
15034
|
return object;
|
|
14821
15035
|
}
|
|
14822
15036
|
const root = object;
|
|
14823
|
-
const pathArray = getPathSegments(
|
|
15037
|
+
const pathArray = getPathSegments(path6);
|
|
14824
15038
|
for (let index = 0;index < pathArray.length; index++) {
|
|
14825
15039
|
const key = pathArray[index];
|
|
14826
15040
|
assertNotStringIndex(object, key);
|
|
@@ -14833,11 +15047,11 @@ function setProperty(object, path5, value) {
|
|
|
14833
15047
|
}
|
|
14834
15048
|
return root;
|
|
14835
15049
|
}
|
|
14836
|
-
function deleteProperty(object,
|
|
14837
|
-
if (!isObject(object) || typeof
|
|
15050
|
+
function deleteProperty(object, path6) {
|
|
15051
|
+
if (!isObject(object) || typeof path6 !== "string") {
|
|
14838
15052
|
return false;
|
|
14839
15053
|
}
|
|
14840
|
-
const pathArray = getPathSegments(
|
|
15054
|
+
const pathArray = getPathSegments(path6);
|
|
14841
15055
|
for (let index = 0;index < pathArray.length; index++) {
|
|
14842
15056
|
const key = pathArray[index];
|
|
14843
15057
|
assertNotStringIndex(object, key);
|
|
@@ -14851,11 +15065,11 @@ function deleteProperty(object, path5) {
|
|
|
14851
15065
|
}
|
|
14852
15066
|
}
|
|
14853
15067
|
}
|
|
14854
|
-
function hasProperty(object,
|
|
14855
|
-
if (!isObject(object) || typeof
|
|
15068
|
+
function hasProperty(object, path6) {
|
|
15069
|
+
if (!isObject(object) || typeof path6 !== "string") {
|
|
14856
15070
|
return false;
|
|
14857
15071
|
}
|
|
14858
|
-
const pathArray = getPathSegments(
|
|
15072
|
+
const pathArray = getPathSegments(path6);
|
|
14859
15073
|
if (pathArray.length === 0) {
|
|
14860
15074
|
return false;
|
|
14861
15075
|
}
|
|
@@ -14869,41 +15083,41 @@ function hasProperty(object, path5) {
|
|
|
14869
15083
|
}
|
|
14870
15084
|
|
|
14871
15085
|
// node_modules/env-paths/index.js
|
|
14872
|
-
import
|
|
15086
|
+
import path6 from "node:path";
|
|
14873
15087
|
import os from "node:os";
|
|
14874
15088
|
import process2 from "node:process";
|
|
14875
15089
|
var homedir = os.homedir();
|
|
14876
15090
|
var tmpdir = os.tmpdir();
|
|
14877
15091
|
var { env } = process2;
|
|
14878
15092
|
var macos = (name) => {
|
|
14879
|
-
const library =
|
|
15093
|
+
const library = path6.join(homedir, "Library");
|
|
14880
15094
|
return {
|
|
14881
|
-
data:
|
|
14882
|
-
config:
|
|
14883
|
-
cache:
|
|
14884
|
-
log:
|
|
14885
|
-
temp:
|
|
15095
|
+
data: path6.join(library, "Application Support", name),
|
|
15096
|
+
config: path6.join(library, "Preferences", name),
|
|
15097
|
+
cache: path6.join(library, "Caches", name),
|
|
15098
|
+
log: path6.join(library, "Logs", name),
|
|
15099
|
+
temp: path6.join(tmpdir, name)
|
|
14886
15100
|
};
|
|
14887
15101
|
};
|
|
14888
15102
|
var windows = (name) => {
|
|
14889
|
-
const appData = env.APPDATA ||
|
|
14890
|
-
const localAppData = env.LOCALAPPDATA ||
|
|
15103
|
+
const appData = env.APPDATA || path6.join(homedir, "AppData", "Roaming");
|
|
15104
|
+
const localAppData = env.LOCALAPPDATA || path6.join(homedir, "AppData", "Local");
|
|
14891
15105
|
return {
|
|
14892
|
-
data:
|
|
14893
|
-
config:
|
|
14894
|
-
cache:
|
|
14895
|
-
log:
|
|
14896
|
-
temp:
|
|
15106
|
+
data: path6.join(localAppData, name, "Data"),
|
|
15107
|
+
config: path6.join(appData, name, "Config"),
|
|
15108
|
+
cache: path6.join(localAppData, name, "Cache"),
|
|
15109
|
+
log: path6.join(localAppData, name, "Log"),
|
|
15110
|
+
temp: path6.join(tmpdir, name)
|
|
14897
15111
|
};
|
|
14898
15112
|
};
|
|
14899
15113
|
var linux = (name) => {
|
|
14900
|
-
const username =
|
|
15114
|
+
const username = path6.basename(homedir);
|
|
14901
15115
|
return {
|
|
14902
|
-
data:
|
|
14903
|
-
config:
|
|
14904
|
-
cache:
|
|
14905
|
-
log:
|
|
14906
|
-
temp:
|
|
15116
|
+
data: path6.join(env.XDG_DATA_HOME || path6.join(homedir, ".local", "share"), name),
|
|
15117
|
+
config: path6.join(env.XDG_CONFIG_HOME || path6.join(homedir, ".config"), name),
|
|
15118
|
+
cache: path6.join(env.XDG_CACHE_HOME || path6.join(homedir, ".cache"), name),
|
|
15119
|
+
log: path6.join(env.XDG_STATE_HOME || path6.join(homedir, ".local", "state"), name),
|
|
15120
|
+
temp: path6.join(tmpdir, username, name)
|
|
14907
15121
|
};
|
|
14908
15122
|
};
|
|
14909
15123
|
function envPaths(name, { suffix = "nodejs" } = {}) {
|
|
@@ -14923,10 +15137,10 @@ function envPaths(name, { suffix = "nodejs" } = {}) {
|
|
|
14923
15137
|
}
|
|
14924
15138
|
|
|
14925
15139
|
// node_modules/atomically/dist/index.js
|
|
14926
|
-
import
|
|
15140
|
+
import path8 from "node:path";
|
|
14927
15141
|
|
|
14928
15142
|
// node_modules/stubborn-fs/dist/index.js
|
|
14929
|
-
import
|
|
15143
|
+
import fs6 from "node:fs";
|
|
14930
15144
|
import { promisify } from "node:util";
|
|
14931
15145
|
|
|
14932
15146
|
// node_modules/stubborn-utils/dist/attemptify_async.js
|
|
@@ -15056,41 +15270,41 @@ var RETRYIFY_OPTIONS = {
|
|
|
15056
15270
|
// node_modules/stubborn-fs/dist/index.js
|
|
15057
15271
|
var FS = {
|
|
15058
15272
|
attempt: {
|
|
15059
|
-
chmod: attemptify_async_default(promisify(
|
|
15060
|
-
chown: attemptify_async_default(promisify(
|
|
15061
|
-
close: attemptify_async_default(promisify(
|
|
15062
|
-
fsync: attemptify_async_default(promisify(
|
|
15063
|
-
mkdir: attemptify_async_default(promisify(
|
|
15064
|
-
realpath: attemptify_async_default(promisify(
|
|
15065
|
-
stat: attemptify_async_default(promisify(
|
|
15066
|
-
unlink: attemptify_async_default(promisify(
|
|
15067
|
-
chmodSync: attemptify_sync_default(
|
|
15068
|
-
chownSync: attemptify_sync_default(
|
|
15069
|
-
closeSync: attemptify_sync_default(
|
|
15070
|
-
existsSync: attemptify_sync_default(
|
|
15071
|
-
fsyncSync: attemptify_sync_default(
|
|
15072
|
-
mkdirSync: attemptify_sync_default(
|
|
15073
|
-
realpathSync: attemptify_sync_default(
|
|
15074
|
-
statSync: attemptify_sync_default(
|
|
15075
|
-
unlinkSync: attemptify_sync_default(
|
|
15273
|
+
chmod: attemptify_async_default(promisify(fs6.chmod), ATTEMPTIFY_CHANGE_ERROR_OPTIONS),
|
|
15274
|
+
chown: attemptify_async_default(promisify(fs6.chown), ATTEMPTIFY_CHANGE_ERROR_OPTIONS),
|
|
15275
|
+
close: attemptify_async_default(promisify(fs6.close), ATTEMPTIFY_NOOP_OPTIONS),
|
|
15276
|
+
fsync: attemptify_async_default(promisify(fs6.fsync), ATTEMPTIFY_NOOP_OPTIONS),
|
|
15277
|
+
mkdir: attemptify_async_default(promisify(fs6.mkdir), ATTEMPTIFY_NOOP_OPTIONS),
|
|
15278
|
+
realpath: attemptify_async_default(promisify(fs6.realpath), ATTEMPTIFY_NOOP_OPTIONS),
|
|
15279
|
+
stat: attemptify_async_default(promisify(fs6.stat), ATTEMPTIFY_NOOP_OPTIONS),
|
|
15280
|
+
unlink: attemptify_async_default(promisify(fs6.unlink), ATTEMPTIFY_NOOP_OPTIONS),
|
|
15281
|
+
chmodSync: attemptify_sync_default(fs6.chmodSync, ATTEMPTIFY_CHANGE_ERROR_OPTIONS),
|
|
15282
|
+
chownSync: attemptify_sync_default(fs6.chownSync, ATTEMPTIFY_CHANGE_ERROR_OPTIONS),
|
|
15283
|
+
closeSync: attemptify_sync_default(fs6.closeSync, ATTEMPTIFY_NOOP_OPTIONS),
|
|
15284
|
+
existsSync: attemptify_sync_default(fs6.existsSync, ATTEMPTIFY_NOOP_OPTIONS),
|
|
15285
|
+
fsyncSync: attemptify_sync_default(fs6.fsync, ATTEMPTIFY_NOOP_OPTIONS),
|
|
15286
|
+
mkdirSync: attemptify_sync_default(fs6.mkdirSync, ATTEMPTIFY_NOOP_OPTIONS),
|
|
15287
|
+
realpathSync: attemptify_sync_default(fs6.realpathSync, ATTEMPTIFY_NOOP_OPTIONS),
|
|
15288
|
+
statSync: attemptify_sync_default(fs6.statSync, ATTEMPTIFY_NOOP_OPTIONS),
|
|
15289
|
+
unlinkSync: attemptify_sync_default(fs6.unlinkSync, ATTEMPTIFY_NOOP_OPTIONS)
|
|
15076
15290
|
},
|
|
15077
15291
|
retry: {
|
|
15078
|
-
close: retryify_async_default(promisify(
|
|
15079
|
-
fsync: retryify_async_default(promisify(
|
|
15080
|
-
open: retryify_async_default(promisify(
|
|
15081
|
-
readFile: retryify_async_default(promisify(
|
|
15082
|
-
rename: retryify_async_default(promisify(
|
|
15083
|
-
stat: retryify_async_default(promisify(
|
|
15084
|
-
write: retryify_async_default(promisify(
|
|
15085
|
-
writeFile: retryify_async_default(promisify(
|
|
15086
|
-
closeSync: retryify_sync_default(
|
|
15087
|
-
fsyncSync: retryify_sync_default(
|
|
15088
|
-
openSync: retryify_sync_default(
|
|
15089
|
-
readFileSync: retryify_sync_default(
|
|
15090
|
-
renameSync: retryify_sync_default(
|
|
15091
|
-
statSync: retryify_sync_default(
|
|
15092
|
-
writeSync: retryify_sync_default(
|
|
15093
|
-
writeFileSync: retryify_sync_default(
|
|
15292
|
+
close: retryify_async_default(promisify(fs6.close), RETRYIFY_OPTIONS),
|
|
15293
|
+
fsync: retryify_async_default(promisify(fs6.fsync), RETRYIFY_OPTIONS),
|
|
15294
|
+
open: retryify_async_default(promisify(fs6.open), RETRYIFY_OPTIONS),
|
|
15295
|
+
readFile: retryify_async_default(promisify(fs6.readFile), RETRYIFY_OPTIONS),
|
|
15296
|
+
rename: retryify_async_default(promisify(fs6.rename), RETRYIFY_OPTIONS),
|
|
15297
|
+
stat: retryify_async_default(promisify(fs6.stat), RETRYIFY_OPTIONS),
|
|
15298
|
+
write: retryify_async_default(promisify(fs6.write), RETRYIFY_OPTIONS),
|
|
15299
|
+
writeFile: retryify_async_default(promisify(fs6.writeFile), RETRYIFY_OPTIONS),
|
|
15300
|
+
closeSync: retryify_sync_default(fs6.closeSync, RETRYIFY_OPTIONS),
|
|
15301
|
+
fsyncSync: retryify_sync_default(fs6.fsyncSync, RETRYIFY_OPTIONS),
|
|
15302
|
+
openSync: retryify_sync_default(fs6.openSync, RETRYIFY_OPTIONS),
|
|
15303
|
+
readFileSync: retryify_sync_default(fs6.readFileSync, RETRYIFY_OPTIONS),
|
|
15304
|
+
renameSync: retryify_sync_default(fs6.renameSync, RETRYIFY_OPTIONS),
|
|
15305
|
+
statSync: retryify_sync_default(fs6.statSync, RETRYIFY_OPTIONS),
|
|
15306
|
+
writeSync: retryify_sync_default(fs6.writeSync, RETRYIFY_OPTIONS),
|
|
15307
|
+
writeFileSync: retryify_sync_default(fs6.writeFileSync, RETRYIFY_OPTIONS)
|
|
15094
15308
|
}
|
|
15095
15309
|
};
|
|
15096
15310
|
var dist_default = FS;
|
|
@@ -15120,7 +15334,7 @@ var isUndefined = (value) => {
|
|
|
15120
15334
|
};
|
|
15121
15335
|
|
|
15122
15336
|
// node_modules/atomically/dist/utils/temp.js
|
|
15123
|
-
import
|
|
15337
|
+
import path7 from "node:path";
|
|
15124
15338
|
|
|
15125
15339
|
// node_modules/when-exit/dist/node/interceptor.js
|
|
15126
15340
|
import process6 from "node:process";
|
|
@@ -15220,7 +15434,7 @@ var Temp = {
|
|
|
15220
15434
|
}
|
|
15221
15435
|
},
|
|
15222
15436
|
truncate: (filePath) => {
|
|
15223
|
-
const basename =
|
|
15437
|
+
const basename = path7.basename(filePath);
|
|
15224
15438
|
if (basename.length <= LIMIT_BASENAME_LENGTH)
|
|
15225
15439
|
return filePath;
|
|
15226
15440
|
const truncable = /^(\.?)(.*?)((?:\.[^.]+)?(?:\.tmp-\d{10}[a-f0-9]{6})?)$/.exec(basename);
|
|
@@ -15234,9 +15448,9 @@ node_default(Temp.purgeSyncAll);
|
|
|
15234
15448
|
var temp_default = Temp;
|
|
15235
15449
|
|
|
15236
15450
|
// node_modules/atomically/dist/index.js
|
|
15237
|
-
function
|
|
15451
|
+
function writeFileSync2(filePath, data, options = DEFAULT_WRITE_OPTIONS) {
|
|
15238
15452
|
if (isString(options))
|
|
15239
|
-
return
|
|
15453
|
+
return writeFileSync2(filePath, data, { encoding: options });
|
|
15240
15454
|
const timeout = options.timeout ?? DEFAULT_TIMEOUT_SYNC;
|
|
15241
15455
|
const retryOptions = { timeout };
|
|
15242
15456
|
let tempDisposer = null;
|
|
@@ -15262,7 +15476,7 @@ function writeFileSync(filePath, data, options = DEFAULT_WRITE_OPTIONS) {
|
|
|
15262
15476
|
}
|
|
15263
15477
|
}
|
|
15264
15478
|
if (!filePathExists) {
|
|
15265
|
-
const parentPath =
|
|
15479
|
+
const parentPath = path8.dirname(filePath);
|
|
15266
15480
|
dist_default.attempt.mkdirSync(parentPath, {
|
|
15267
15481
|
mode: DEFAULT_FOLDER_MODE,
|
|
15268
15482
|
recursive: true
|
|
@@ -15578,7 +15792,7 @@ class Conf {
|
|
|
15578
15792
|
this.events = new EventTarget;
|
|
15579
15793
|
this.#encryptionKey = options.encryptionKey;
|
|
15580
15794
|
const fileExtension = options.fileExtension ? `.${options.fileExtension}` : "";
|
|
15581
|
-
this.path =
|
|
15795
|
+
this.path = path9.resolve(options.cwd, `${options.configName ?? "config"}${fileExtension}`);
|
|
15582
15796
|
const fileStore = this.store;
|
|
15583
15797
|
const store = Object.assign(createPlainObject(), options.defaults, fileStore);
|
|
15584
15798
|
if (options.migrations) {
|
|
@@ -15681,7 +15895,7 @@ class Conf {
|
|
|
15681
15895
|
}
|
|
15682
15896
|
get store() {
|
|
15683
15897
|
try {
|
|
15684
|
-
const data =
|
|
15898
|
+
const data = fs7.readFileSync(this.path, this.#encryptionKey ? null : "utf8");
|
|
15685
15899
|
const dataString = this._encryptData(data);
|
|
15686
15900
|
const deserializedData = this._deserialize(dataString);
|
|
15687
15901
|
this._validate(deserializedData);
|
|
@@ -15752,7 +15966,7 @@ class Conf {
|
|
|
15752
15966
|
throw new Error("Config schema violation: " + errors.join("; "));
|
|
15753
15967
|
}
|
|
15754
15968
|
_ensureDirectory() {
|
|
15755
|
-
|
|
15969
|
+
fs7.mkdirSync(path9.dirname(this.path), { recursive: true });
|
|
15756
15970
|
}
|
|
15757
15971
|
_write(value) {
|
|
15758
15972
|
let data = this._serialize(value);
|
|
@@ -15763,13 +15977,13 @@ class Conf {
|
|
|
15763
15977
|
data = concatUint8Arrays([initializationVector, stringToUint8Array(":"), cipher.update(stringToUint8Array(data)), cipher.final()]);
|
|
15764
15978
|
}
|
|
15765
15979
|
if (process7.env.SNAP) {
|
|
15766
|
-
|
|
15980
|
+
fs7.writeFileSync(this.path, data, { mode: this.#options.configFileMode });
|
|
15767
15981
|
} else {
|
|
15768
15982
|
try {
|
|
15769
|
-
|
|
15983
|
+
writeFileSync2(this.path, data, { mode: this.#options.configFileMode });
|
|
15770
15984
|
} catch (error) {
|
|
15771
15985
|
if (error?.code === "EXDEV") {
|
|
15772
|
-
|
|
15986
|
+
fs7.writeFileSync(this.path, data, { mode: this.#options.configFileMode });
|
|
15773
15987
|
return;
|
|
15774
15988
|
}
|
|
15775
15989
|
throw error;
|
|
@@ -15778,15 +15992,15 @@ class Conf {
|
|
|
15778
15992
|
}
|
|
15779
15993
|
_watch() {
|
|
15780
15994
|
this._ensureDirectory();
|
|
15781
|
-
if (!
|
|
15995
|
+
if (!fs7.existsSync(this.path)) {
|
|
15782
15996
|
this._write(createPlainObject());
|
|
15783
15997
|
}
|
|
15784
15998
|
if (process7.platform === "win32") {
|
|
15785
|
-
|
|
15999
|
+
fs7.watch(this.path, { persistent: false }, debounce_fn_default(() => {
|
|
15786
16000
|
this.events.dispatchEvent(new Event("change"));
|
|
15787
16001
|
}, { wait: 100 }));
|
|
15788
16002
|
} else {
|
|
15789
|
-
|
|
16003
|
+
fs7.watchFile(this.path, { persistent: false }, debounce_fn_default(() => {
|
|
15790
16004
|
this.events.dispatchEvent(new Event("change"));
|
|
15791
16005
|
}, { wait: 5000 }));
|
|
15792
16006
|
}
|
|
@@ -15922,14 +16136,14 @@ function jwtDecode(token, options) {
|
|
|
15922
16136
|
}
|
|
15923
16137
|
|
|
15924
16138
|
// lib/cli-config/index.ts
|
|
15925
|
-
import
|
|
16139
|
+
import fs9 from "node:fs";
|
|
15926
16140
|
import os3 from "node:os";
|
|
15927
|
-
import
|
|
16141
|
+
import path11 from "node:path";
|
|
15928
16142
|
|
|
15929
16143
|
// lib/shared/handle-registry-auth-error.ts
|
|
15930
|
-
import
|
|
16144
|
+
import fs8 from "node:fs";
|
|
15931
16145
|
import os2 from "node:os";
|
|
15932
|
-
import
|
|
16146
|
+
import path10 from "node:path";
|
|
15933
16147
|
|
|
15934
16148
|
// node_modules/kleur/index.mjs
|
|
15935
16149
|
var FORCE_COLOR;
|
|
@@ -16049,9 +16263,9 @@ function isUnauthorizedError(error) {
|
|
|
16049
16263
|
return /\b(401|E401)\b/i.test(output) || /unauthorized/i.test(output);
|
|
16050
16264
|
}
|
|
16051
16265
|
function hasTsciAuthToken(npmrcPath) {
|
|
16052
|
-
if (!
|
|
16266
|
+
if (!fs8.existsSync(npmrcPath))
|
|
16053
16267
|
return false;
|
|
16054
|
-
const content =
|
|
16268
|
+
const content = fs8.readFileSync(npmrcPath, "utf-8");
|
|
16055
16269
|
return AUTH_TOKEN_REGEX.test(content);
|
|
16056
16270
|
}
|
|
16057
16271
|
function handleRegistryAuthError({
|
|
@@ -16061,8 +16275,8 @@ function handleRegistryAuthError({
|
|
|
16061
16275
|
if (!isUnauthorizedError(error))
|
|
16062
16276
|
return;
|
|
16063
16277
|
const npmrcPaths = [
|
|
16064
|
-
|
|
16065
|
-
|
|
16278
|
+
path10.join(projectDir, ".npmrc"),
|
|
16279
|
+
path10.join(os2.homedir(), ".npmrc")
|
|
16066
16280
|
];
|
|
16067
16281
|
const hasToken = npmrcPaths.some(hasTsciAuthToken);
|
|
16068
16282
|
if (hasToken) {
|
|
@@ -16085,13 +16299,13 @@ var getSessionToken = () => {
|
|
|
16085
16299
|
};
|
|
16086
16300
|
var getSessionTokenFromNpmrc = () => {
|
|
16087
16301
|
const npmrcPaths = [
|
|
16088
|
-
|
|
16089
|
-
|
|
16302
|
+
path11.join(process.cwd(), ".npmrc"),
|
|
16303
|
+
path11.join(os3.homedir(), ".npmrc")
|
|
16090
16304
|
];
|
|
16091
16305
|
for (const npmrcPath of npmrcPaths) {
|
|
16092
|
-
if (!
|
|
16306
|
+
if (!fs9.existsSync(npmrcPath))
|
|
16093
16307
|
continue;
|
|
16094
|
-
const content =
|
|
16308
|
+
const content = fs9.readFileSync(npmrcPath, "utf-8");
|
|
16095
16309
|
const match = content.match(AUTH_TOKEN_REGEX);
|
|
16096
16310
|
if (match?.[1]) {
|
|
16097
16311
|
return match[1].trim();
|
|
@@ -16129,8 +16343,8 @@ var getCircuitJsonToGltfOptions = ({
|
|
|
16129
16343
|
};
|
|
16130
16344
|
|
|
16131
16345
|
// cli/build/convert-model-urls-to-file-urls.ts
|
|
16132
|
-
import
|
|
16133
|
-
import { pathToFileURL as
|
|
16346
|
+
import path12 from "node:path";
|
|
16347
|
+
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
16134
16348
|
var convertModelUrlsToFileUrls = (circuitJson) => {
|
|
16135
16349
|
const modelUrlKeys2 = [
|
|
16136
16350
|
"model_glb_url",
|
|
@@ -16154,9 +16368,9 @@ var convertModelUrlsToFileUrls = (circuitJson) => {
|
|
|
16154
16368
|
if (value.match(/^[a-zA-Z]+:\/\//))
|
|
16155
16369
|
continue;
|
|
16156
16370
|
if (value.startsWith("/") || value.match(/^[a-zA-Z]:\\/)) {
|
|
16157
|
-
updated[key] =
|
|
16371
|
+
updated[key] = pathToFileURL3(value).href;
|
|
16158
16372
|
} else if (value.startsWith(".")) {
|
|
16159
|
-
updated[key] =
|
|
16373
|
+
updated[key] = pathToFileURL3(path12.resolve(process.cwd(), value)).href;
|
|
16160
16374
|
}
|
|
16161
16375
|
}
|
|
16162
16376
|
}
|
|
@@ -16195,9 +16409,9 @@ var convertSvgToPngBuffer = async (svg) => {
|
|
|
16195
16409
|
};
|
|
16196
16410
|
|
|
16197
16411
|
// lib/shared/load-local-step-model-fs-map.ts
|
|
16198
|
-
import { existsSync } from "node:fs";
|
|
16412
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
16199
16413
|
import { readFile } from "node:fs/promises";
|
|
16200
|
-
import
|
|
16414
|
+
import path13 from "node:path";
|
|
16201
16415
|
var isRemoteUrl = (value) => /^https?:\/\//i.test(value);
|
|
16202
16416
|
async function loadLocalStepModelFsMap(circuitJson) {
|
|
16203
16417
|
const fsMap = {};
|
|
@@ -16209,8 +16423,8 @@ async function loadLocalStepModelFsMap(circuitJson) {
|
|
|
16209
16423
|
continue;
|
|
16210
16424
|
if (isRemoteUrl(modelUrl) || fsMap[modelUrl])
|
|
16211
16425
|
continue;
|
|
16212
|
-
const localPath =
|
|
16213
|
-
if (!
|
|
16426
|
+
const localPath = path13.resolve(process.cwd(), modelUrl);
|
|
16427
|
+
if (!existsSync2(localPath))
|
|
16214
16428
|
continue;
|
|
16215
16429
|
fsMap[modelUrl] = await readFile(localPath, "utf-8");
|
|
16216
16430
|
}
|
|
@@ -16265,10 +16479,10 @@ var writeSimulationSvgAssetsFromCircuitJson = (circuitJson, outputDir, imageForm
|
|
|
16265
16479
|
if (!simulationSvgAssets)
|
|
16266
16480
|
return false;
|
|
16267
16481
|
if (imageFormats.simulationSvgs) {
|
|
16268
|
-
|
|
16482
|
+
fs10.writeFileSync(path14.join(outputDir, "simulation.svg"), simulationSvgAssets.simulationSvg, "utf-8");
|
|
16269
16483
|
}
|
|
16270
16484
|
if (imageFormats.simulationSchematicSvgs) {
|
|
16271
|
-
|
|
16485
|
+
fs10.writeFileSync(path14.join(outputDir, "simulation-schematic.svg"), simulationSvgAssets.schematicSimulationSvg, "utf-8");
|
|
16272
16486
|
}
|
|
16273
16487
|
return true;
|
|
16274
16488
|
};
|
|
@@ -16276,8 +16490,8 @@ var writeGlbFromCircuitJson = async (circuitJson, glbOutputPath) => {
|
|
|
16276
16490
|
const circuitJsonWithFileUrls = convertModelUrlsToFileUrls(circuitJson);
|
|
16277
16491
|
const glbBuffer = await convertCircuitJsonToGltf(circuitJsonWithFileUrls, getCircuitJsonToGltfOptions({ format: "glb" }));
|
|
16278
16492
|
const glbData = normalizeToUint8Array2(glbBuffer);
|
|
16279
|
-
|
|
16280
|
-
|
|
16493
|
+
fs10.mkdirSync(path14.dirname(glbOutputPath), { recursive: true });
|
|
16494
|
+
fs10.writeFileSync(glbOutputPath, Buffer.from(glbData));
|
|
16281
16495
|
};
|
|
16282
16496
|
var writeStepFromCircuitJson = async (circuitJson, stepOutputPath) => {
|
|
16283
16497
|
const stepContent = await circuitJsonToStep(circuitJson, {
|
|
@@ -16285,34 +16499,34 @@ var writeStepFromCircuitJson = async (circuitJson, stepOutputPath) => {
|
|
|
16285
16499
|
includeExternalMeshes: true,
|
|
16286
16500
|
fsMap: await loadLocalStepModelFsMap(circuitJson)
|
|
16287
16501
|
});
|
|
16288
|
-
|
|
16289
|
-
|
|
16502
|
+
fs10.mkdirSync(path14.dirname(stepOutputPath), { recursive: true });
|
|
16503
|
+
fs10.writeFileSync(stepOutputPath, stepContent);
|
|
16290
16504
|
};
|
|
16291
16505
|
var writeImageAssetsFromCircuitJson = async (circuitJson, options) => {
|
|
16292
16506
|
const { outputDir, imageFormats, pcbSnapshotSettings } = options;
|
|
16293
|
-
|
|
16507
|
+
fs10.mkdirSync(outputDir, { recursive: true });
|
|
16294
16508
|
if (imageFormats.pcbSvgs) {
|
|
16295
16509
|
const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson, pcbSnapshotSettings);
|
|
16296
|
-
|
|
16510
|
+
fs10.writeFileSync(path14.join(outputDir, "pcb.svg"), pcbSvg, "utf-8");
|
|
16297
16511
|
}
|
|
16298
16512
|
if (imageFormats.pcbPngs) {
|
|
16299
16513
|
const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson, pcbSnapshotSettings);
|
|
16300
|
-
|
|
16514
|
+
fs10.writeFileSync(path14.join(outputDir, "pcb.png"), await convertSvgToPngBuffer(pcbSvg));
|
|
16301
16515
|
}
|
|
16302
16516
|
if (imageFormats.schematicSvgs) {
|
|
16303
16517
|
const schematicSvg = convertCircuitJsonToSchematicSvg(circuitJson);
|
|
16304
|
-
|
|
16518
|
+
fs10.writeFileSync(path14.join(outputDir, "schematic.svg"), schematicSvg, "utf-8");
|
|
16305
16519
|
}
|
|
16306
16520
|
writeSimulationSvgAssetsFromCircuitJson(circuitJson, outputDir, imageFormats);
|
|
16307
16521
|
if (imageFormats.threeDPngs) {
|
|
16308
16522
|
const pngBuffer = await renderCircuitJsonTo3dPng(circuitJson);
|
|
16309
|
-
|
|
16523
|
+
fs10.writeFileSync(path14.join(outputDir, "3d.png"), Buffer.from(pngBuffer));
|
|
16310
16524
|
}
|
|
16311
16525
|
};
|
|
16312
16526
|
|
|
16313
16527
|
// cli/build/worker-build-handlers.ts
|
|
16314
16528
|
var loadCircuitJsonFromInputFile = (filePath) => {
|
|
16315
|
-
const parsed = JSON.parse(
|
|
16529
|
+
const parsed = JSON.parse(fs11.readFileSync(filePath, "utf-8"));
|
|
16316
16530
|
return Array.isArray(parsed) ? parsed : [];
|
|
16317
16531
|
};
|
|
16318
16532
|
var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath, previewOutputDir, projectDir, options, workerLog, workerStatus) => {
|
|
@@ -16321,9 +16535,11 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
16321
16535
|
const startedAt = options?.profile ? performance.now() : 0;
|
|
16322
16536
|
try {
|
|
16323
16537
|
process.chdir(projectDir);
|
|
16324
|
-
workerLog(`Generating circuit JSON for ${
|
|
16538
|
+
workerLog(`Generating circuit JSON for ${path15.relative(projectDir, filePath)}...`);
|
|
16325
16539
|
await registerStaticAssetLoaders();
|
|
16326
|
-
const
|
|
16540
|
+
const projectConfig = await loadRuntimeProjectConfig(projectDir);
|
|
16541
|
+
const platformConfig = mergePlatformConfigs(projectConfig?.platformConfig, options?.platformConfig);
|
|
16542
|
+
const platformConfigWithCliDefaults = getPlatformConfigWithCliDefaults(platformConfig);
|
|
16327
16543
|
const normalizedInputPath = filePath.toLowerCase().replaceAll("\\", "/");
|
|
16328
16544
|
const isPrebuiltCircuitJson = normalizedInputPath.endsWith(".circuit.json") || normalizedInputPath.endsWith("/circuit.json");
|
|
16329
16545
|
const circuitJson = isPrebuiltCircuitJson ? loadCircuitJsonFromInputFile(filePath) : (await generateCircuitJson({
|
|
@@ -16334,9 +16550,9 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
16334
16550
|
workerStatus(`waiting on ${asyncEffectName}…`);
|
|
16335
16551
|
}
|
|
16336
16552
|
})).circuitJson;
|
|
16337
|
-
|
|
16338
|
-
|
|
16339
|
-
workerLog(`Circuit JSON written to ${
|
|
16553
|
+
fs11.mkdirSync(path15.dirname(outputPath), { recursive: true });
|
|
16554
|
+
fs11.writeFileSync(outputPath, JSON.stringify(circuitJson, null, 2));
|
|
16555
|
+
workerLog(`Circuit JSON written to ${path15.relative(projectDir, outputPath)}`);
|
|
16340
16556
|
const diagnostics = analyzeCircuitJson(circuitJson);
|
|
16341
16557
|
const filteredDiagnostics = filterDiagnosticsByDrcCategory({
|
|
16342
16558
|
errors: diagnostics.errors,
|
|
@@ -16366,7 +16582,7 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
16366
16582
|
let previewError;
|
|
16367
16583
|
if (glbOutputPath) {
|
|
16368
16584
|
try {
|
|
16369
|
-
workerLog(`Converting ${
|
|
16585
|
+
workerLog(`Converting ${path15.relative(projectDir, outputPath)} to GLB in same worker...`);
|
|
16370
16586
|
await writeGlbFromCircuitJson(circuitJson, glbOutputPath);
|
|
16371
16587
|
glbOk = true;
|
|
16372
16588
|
} catch (err) {
|
|
@@ -16377,7 +16593,7 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
16377
16593
|
}
|
|
16378
16594
|
if (stepOutputPath) {
|
|
16379
16595
|
try {
|
|
16380
|
-
workerLog(`Converting ${
|
|
16596
|
+
workerLog(`Converting ${path15.relative(projectDir, outputPath)} to STEP in same worker...`);
|
|
16381
16597
|
await writeStepFromCircuitJson(circuitJson, stepOutputPath);
|
|
16382
16598
|
stepOk = true;
|
|
16383
16599
|
} catch (err) {
|
|
@@ -16388,8 +16604,8 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
16388
16604
|
}
|
|
16389
16605
|
if (options?.generatePreviewAssets) {
|
|
16390
16606
|
try {
|
|
16391
|
-
const resolvedPreviewOutputDir = previewOutputDir ??
|
|
16392
|
-
workerLog(`Generating preview assets for ${
|
|
16607
|
+
const resolvedPreviewOutputDir = previewOutputDir ?? path15.dirname(outputPath);
|
|
16608
|
+
workerLog(`Generating preview assets for ${path15.relative(projectDir, resolvedPreviewOutputDir)} in same worker...`);
|
|
16393
16609
|
await writeImageAssetsFromCircuitJson(circuitJson, {
|
|
16394
16610
|
outputDir: resolvedPreviewOutputDir,
|
|
16395
16611
|
imageFormats: options?.imageFormats ?? DEFAULT_IMAGE_FORMAT_SELECTION,
|
package/dist/cli/main.js
CHANGED
|
@@ -93628,7 +93628,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
|
|
|
93628
93628
|
// lib/getVersion.ts
|
|
93629
93629
|
import { createRequire as createRequire2 } from "node:module";
|
|
93630
93630
|
// package.json
|
|
93631
|
-
var version = "0.1.
|
|
93631
|
+
var version = "0.1.1610";
|
|
93632
93632
|
var package_default = {
|
|
93633
93633
|
name: "@tscircuit/cli",
|
|
93634
93634
|
version,
|
|
@@ -109782,7 +109782,10 @@ var registerBuild = (program2) => {
|
|
|
109782
109782
|
files: filesToBuild,
|
|
109783
109783
|
projectDir,
|
|
109784
109784
|
concurrency: concurrencyValue,
|
|
109785
|
-
buildOptions
|
|
109785
|
+
buildOptions: {
|
|
109786
|
+
...buildOptions,
|
|
109787
|
+
platformConfig: commandPlatformConfig
|
|
109788
|
+
},
|
|
109786
109789
|
workerJobTimeoutMs: projectConfig?.build?.workerTimeoutMs,
|
|
109787
109790
|
stopOnFatal: true,
|
|
109788
109791
|
onLog: (lines) => {
|
package/dist/lib/index.js
CHANGED
|
@@ -65811,7 +65811,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
|
|
|
65811
65811
|
}));
|
|
65812
65812
|
};
|
|
65813
65813
|
// package.json
|
|
65814
|
-
var version = "0.1.
|
|
65814
|
+
var version = "0.1.1610";
|
|
65815
65815
|
var package_default = {
|
|
65816
65816
|
name: "@tscircuit/cli",
|
|
65817
65817
|
version,
|