@tscircuit/cli 0.1.1628 → 0.1.1629
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 +676 -265
- package/dist/cli/main.js +1749 -1292
- package/dist/cli/snapshot/snapshot.worker.js +484 -77
- package/dist/lib/index.js +12 -2
- package/package.json +1 -1
|
@@ -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(path10) {
|
|
5612
|
+
let input = path10;
|
|
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 [path10, query] = wsComponent.resourceName.split("?");
|
|
5856
|
+
wsComponent.path = path10 && path10 !== "/" ? path10 : 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, fs8, 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, fs8[f]);
|
|
9800
9800
|
}
|
|
9801
9801
|
module.exports = exports = formatsPlugin;
|
|
9802
9802
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -11651,8 +11651,8 @@ 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 fs12 from "node:fs";
|
|
11655
|
+
import path16 from "node:path";
|
|
11656
11656
|
|
|
11657
11657
|
// lib/project-config/index.ts
|
|
11658
11658
|
import * as fs from "node:fs";
|
|
@@ -11858,8 +11858,8 @@ function analyzeCircuitJson(circuitJson) {
|
|
|
11858
11858
|
}
|
|
11859
11859
|
|
|
11860
11860
|
// lib/shared/generate-circuit-json.tsx
|
|
11861
|
-
import
|
|
11862
|
-
import
|
|
11861
|
+
import fs5 from "node:fs";
|
|
11862
|
+
import path5 from "node:path";
|
|
11863
11863
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
11864
11864
|
import Debug from "debug";
|
|
11865
11865
|
|
|
@@ -11880,14 +11880,515 @@ var abbreviateStringifyObject = (obj) => {
|
|
|
11880
11880
|
// lib/shared/generate-circuit-json.tsx
|
|
11881
11881
|
var import_make_vfs = __toESM(require_dist(), 1);
|
|
11882
11882
|
|
|
11883
|
-
// lib/shared/
|
|
11884
|
-
import { createRequire as createRequire2 } from "node:module";
|
|
11883
|
+
// lib/shared/autorouter-diagnostics.ts
|
|
11885
11884
|
import fs2 from "node:fs";
|
|
11886
11885
|
import path2 from "node:path";
|
|
11886
|
+
|
|
11887
|
+
// node_modules/kleur/index.mjs
|
|
11888
|
+
var FORCE_COLOR;
|
|
11889
|
+
var NODE_DISABLE_COLORS;
|
|
11890
|
+
var NO_COLOR;
|
|
11891
|
+
var TERM;
|
|
11892
|
+
var isTTY = true;
|
|
11893
|
+
if (typeof process !== "undefined") {
|
|
11894
|
+
({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {});
|
|
11895
|
+
isTTY = process.stdout && process.stdout.isTTY;
|
|
11896
|
+
}
|
|
11897
|
+
var $ = {
|
|
11898
|
+
enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY),
|
|
11899
|
+
reset: init(0, 0),
|
|
11900
|
+
bold: init(1, 22),
|
|
11901
|
+
dim: init(2, 22),
|
|
11902
|
+
italic: init(3, 23),
|
|
11903
|
+
underline: init(4, 24),
|
|
11904
|
+
inverse: init(7, 27),
|
|
11905
|
+
hidden: init(8, 28),
|
|
11906
|
+
strikethrough: init(9, 29),
|
|
11907
|
+
black: init(30, 39),
|
|
11908
|
+
red: init(31, 39),
|
|
11909
|
+
green: init(32, 39),
|
|
11910
|
+
yellow: init(33, 39),
|
|
11911
|
+
blue: init(34, 39),
|
|
11912
|
+
magenta: init(35, 39),
|
|
11913
|
+
cyan: init(36, 39),
|
|
11914
|
+
white: init(37, 39),
|
|
11915
|
+
gray: init(90, 39),
|
|
11916
|
+
grey: init(90, 39),
|
|
11917
|
+
bgBlack: init(40, 49),
|
|
11918
|
+
bgRed: init(41, 49),
|
|
11919
|
+
bgGreen: init(42, 49),
|
|
11920
|
+
bgYellow: init(43, 49),
|
|
11921
|
+
bgBlue: init(44, 49),
|
|
11922
|
+
bgMagenta: init(45, 49),
|
|
11923
|
+
bgCyan: init(46, 49),
|
|
11924
|
+
bgWhite: init(47, 49)
|
|
11925
|
+
};
|
|
11926
|
+
function run(arr, str) {
|
|
11927
|
+
let i = 0, tmp, beg = "", end = "";
|
|
11928
|
+
for (;i < arr.length; i++) {
|
|
11929
|
+
tmp = arr[i];
|
|
11930
|
+
beg += tmp.open;
|
|
11931
|
+
end += tmp.close;
|
|
11932
|
+
if (!!~str.indexOf(tmp.close)) {
|
|
11933
|
+
str = str.replace(tmp.rgx, tmp.close + tmp.open);
|
|
11934
|
+
}
|
|
11935
|
+
}
|
|
11936
|
+
return beg + str + end;
|
|
11937
|
+
}
|
|
11938
|
+
function chain(has, keys) {
|
|
11939
|
+
let ctx = { has, keys };
|
|
11940
|
+
ctx.reset = $.reset.bind(ctx);
|
|
11941
|
+
ctx.bold = $.bold.bind(ctx);
|
|
11942
|
+
ctx.dim = $.dim.bind(ctx);
|
|
11943
|
+
ctx.italic = $.italic.bind(ctx);
|
|
11944
|
+
ctx.underline = $.underline.bind(ctx);
|
|
11945
|
+
ctx.inverse = $.inverse.bind(ctx);
|
|
11946
|
+
ctx.hidden = $.hidden.bind(ctx);
|
|
11947
|
+
ctx.strikethrough = $.strikethrough.bind(ctx);
|
|
11948
|
+
ctx.black = $.black.bind(ctx);
|
|
11949
|
+
ctx.red = $.red.bind(ctx);
|
|
11950
|
+
ctx.green = $.green.bind(ctx);
|
|
11951
|
+
ctx.yellow = $.yellow.bind(ctx);
|
|
11952
|
+
ctx.blue = $.blue.bind(ctx);
|
|
11953
|
+
ctx.magenta = $.magenta.bind(ctx);
|
|
11954
|
+
ctx.cyan = $.cyan.bind(ctx);
|
|
11955
|
+
ctx.white = $.white.bind(ctx);
|
|
11956
|
+
ctx.gray = $.gray.bind(ctx);
|
|
11957
|
+
ctx.grey = $.grey.bind(ctx);
|
|
11958
|
+
ctx.bgBlack = $.bgBlack.bind(ctx);
|
|
11959
|
+
ctx.bgRed = $.bgRed.bind(ctx);
|
|
11960
|
+
ctx.bgGreen = $.bgGreen.bind(ctx);
|
|
11961
|
+
ctx.bgYellow = $.bgYellow.bind(ctx);
|
|
11962
|
+
ctx.bgBlue = $.bgBlue.bind(ctx);
|
|
11963
|
+
ctx.bgMagenta = $.bgMagenta.bind(ctx);
|
|
11964
|
+
ctx.bgCyan = $.bgCyan.bind(ctx);
|
|
11965
|
+
ctx.bgWhite = $.bgWhite.bind(ctx);
|
|
11966
|
+
return ctx;
|
|
11967
|
+
}
|
|
11968
|
+
function init(open, close) {
|
|
11969
|
+
let blk = {
|
|
11970
|
+
open: `\x1B[${open}m`,
|
|
11971
|
+
close: `\x1B[${close}m`,
|
|
11972
|
+
rgx: new RegExp(`\\x1b\\[${close}m`, "g")
|
|
11973
|
+
};
|
|
11974
|
+
return function(txt) {
|
|
11975
|
+
if (this !== undefined && this.has !== undefined) {
|
|
11976
|
+
!!~this.has.indexOf(open) || (this.has.push(open), this.keys.push(blk));
|
|
11977
|
+
return txt === undefined ? this : $.enabled ? run(this.keys, txt + "") : txt + "";
|
|
11978
|
+
}
|
|
11979
|
+
return txt === undefined ? chain([open], [blk]) : $.enabled ? run([blk], txt + "") : txt + "";
|
|
11980
|
+
};
|
|
11981
|
+
}
|
|
11982
|
+
var kleur_default = $;
|
|
11983
|
+
|
|
11984
|
+
// lib/shared/autorouter-diagnostics.ts
|
|
11985
|
+
var DEFAULT_DEBUG_DIR = path2.join("dist", "autorouter-debug");
|
|
11986
|
+
var PROGRESS_LOG_INTERVAL_MS = 1e4;
|
|
11987
|
+
var parseAutorouterTimeout = (duration) => {
|
|
11988
|
+
const trimmed = duration.trim();
|
|
11989
|
+
const match = trimmed.match(/^(\d+(?:\.\d+)?)(ms|s|m)?$/);
|
|
11990
|
+
if (!match) {
|
|
11991
|
+
throw new Error(`Invalid --autorouter-timeout value "${duration}". Use values like "120s", "2m", or "5000ms".`);
|
|
11992
|
+
}
|
|
11993
|
+
const value = Number.parseFloat(match[1]);
|
|
11994
|
+
const unit = match[2] ?? "ms";
|
|
11995
|
+
const multiplier = unit === "m" ? 60000 : unit === "s" ? 1000 : 1;
|
|
11996
|
+
const timeoutMs = Math.round(value * multiplier);
|
|
11997
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
11998
|
+
throw new Error("--autorouter-timeout must be greater than zero");
|
|
11999
|
+
}
|
|
12000
|
+
return timeoutMs;
|
|
12001
|
+
};
|
|
12002
|
+
var parseAutorouterDumpSrjMode = (value) => {
|
|
12003
|
+
if (value === undefined || value === false)
|
|
12004
|
+
return;
|
|
12005
|
+
if (value === true || value === "")
|
|
12006
|
+
return "failed";
|
|
12007
|
+
if (value === "all" || value === "failed")
|
|
12008
|
+
return value;
|
|
12009
|
+
const phaseMatch = value.match(/^phase:(\d+)$/);
|
|
12010
|
+
if (phaseMatch)
|
|
12011
|
+
return `phase:${Number.parseInt(phaseMatch[1], 10)}`;
|
|
12012
|
+
throw new Error(`Invalid --autorouter-dump-srj value "${value}". Use "all", "failed", or "phase:<index>".`);
|
|
12013
|
+
};
|
|
12014
|
+
|
|
12015
|
+
class AutorouterPhaseTimeoutError extends Error {
|
|
12016
|
+
debugArtifactPath;
|
|
12017
|
+
constructor(message, debugArtifactPath) {
|
|
12018
|
+
super(message);
|
|
12019
|
+
this.name = "AutorouterPhaseTimeoutError";
|
|
12020
|
+
this.debugArtifactPath = debugArtifactPath;
|
|
12021
|
+
}
|
|
12022
|
+
}
|
|
12023
|
+
|
|
12024
|
+
class AutorouterDiagnostics {
|
|
12025
|
+
options;
|
|
12026
|
+
phaseOrdinalBySubcircuit = new Map;
|
|
12027
|
+
traceCountBySubcircuit = new Map;
|
|
12028
|
+
activePhase = null;
|
|
12029
|
+
completedPhaseTraces = [];
|
|
12030
|
+
summary = [];
|
|
12031
|
+
rootCircuit;
|
|
12032
|
+
constructor(options = {}) {
|
|
12033
|
+
this.options = {
|
|
12034
|
+
...options,
|
|
12035
|
+
debugDir: options.debugDir ?? DEFAULT_DEBUG_DIR,
|
|
12036
|
+
log: options.log ?? console.log
|
|
12037
|
+
};
|
|
12038
|
+
}
|
|
12039
|
+
get isActive() {
|
|
12040
|
+
return Boolean(this.options.enabled || this.options.timeoutMs || this.options.dumpSrj || this.options.logOnError || this.options.longRunningLogThresholdMs);
|
|
12041
|
+
}
|
|
12042
|
+
attachToRootCircuit(rootCircuit) {
|
|
12043
|
+
if (!this.isActive)
|
|
12044
|
+
return;
|
|
12045
|
+
this.rootCircuit = rootCircuit;
|
|
12046
|
+
rootCircuit.on?.("autorouting:start", (event) => this.handleStart(event));
|
|
12047
|
+
rootCircuit.on?.("autorouting:progress", (event) => this.handleProgress(event));
|
|
12048
|
+
rootCircuit.on?.("autorouting:end", (event) => this.handleEnd(event));
|
|
12049
|
+
rootCircuit.on?.("autorouting:error", (event) => this.handleError(event));
|
|
12050
|
+
}
|
|
12051
|
+
checkTimeout() {
|
|
12052
|
+
this.checkLongRunning();
|
|
12053
|
+
if (!this.options.timeoutMs || !this.activePhase)
|
|
12054
|
+
return;
|
|
12055
|
+
const elapsedMs = performance.now() - this.activePhase.startedAt;
|
|
12056
|
+
if (elapsedMs < this.options.timeoutMs)
|
|
12057
|
+
return;
|
|
12058
|
+
const artifactPath = this.writeTimeoutArtifact(this.activePhase, elapsedMs);
|
|
12059
|
+
const phaseLabel = this.getPhaseLabel(this.activePhase);
|
|
12060
|
+
const message = `Autorouter timeout after ${this.formatElapsed(elapsedMs)} in ${phaseLabel}.`;
|
|
12061
|
+
this.log(kleur_default.red(message));
|
|
12062
|
+
this.log(`Wrote debug artifact: ${path2.relative(process.cwd(), artifactPath)}`);
|
|
12063
|
+
throw new AutorouterPhaseTimeoutError(message, artifactPath);
|
|
12064
|
+
}
|
|
12065
|
+
finalize(circuitJson) {
|
|
12066
|
+
if (!this.isActive || this.summary.length === 0 || !this.options.enabled && !this.options.dumpSrj) {
|
|
12067
|
+
return;
|
|
12068
|
+
}
|
|
12069
|
+
this.writeJson("board.meta.json", {
|
|
12070
|
+
type: "autorouter_debug_summary",
|
|
12071
|
+
generatedAt: new Date().toISOString(),
|
|
12072
|
+
phaseCount: this.summary.length,
|
|
12073
|
+
phases: this.summary,
|
|
12074
|
+
circuitJsonElementCount: circuitJson?.length
|
|
12075
|
+
});
|
|
12076
|
+
}
|
|
12077
|
+
handleStart(event) {
|
|
12078
|
+
const simpleRouteJson = event.simpleRouteJson;
|
|
12079
|
+
const subcircuitId = event.subcircuit_id ?? event.subcircuitId ?? "unknown-subcircuit";
|
|
12080
|
+
const previousOrdinal = this.phaseOrdinalBySubcircuit.get(subcircuitId) ?? 0;
|
|
12081
|
+
const phaseOrdinal = event.phaseOrdinal ?? previousOrdinal + 1;
|
|
12082
|
+
this.phaseOrdinalBySubcircuit.set(subcircuitId, phaseOrdinal);
|
|
12083
|
+
const routingPhaseIndex = event.routingPhaseIndex ?? phaseOrdinal - 1;
|
|
12084
|
+
const connectionCount = event.connectionCount ?? simpleRouteJson?.connections?.length ?? 0;
|
|
12085
|
+
const obstacleCount = event.obstacleCount ?? simpleRouteJson?.obstacles?.length ?? 0;
|
|
12086
|
+
const previousTraceCount = event.previousTraceCount ?? this.traceCountBySubcircuit.get(subcircuitId) ?? 0;
|
|
12087
|
+
this.activePhase = {
|
|
12088
|
+
subcircuitId,
|
|
12089
|
+
componentDisplayName: event.componentDisplayName ?? subcircuitId,
|
|
12090
|
+
routingPhaseIndex,
|
|
12091
|
+
phaseOrdinal,
|
|
12092
|
+
phaseCount: event.phaseCount,
|
|
12093
|
+
connectionCount,
|
|
12094
|
+
obstacleCount,
|
|
12095
|
+
previousTraceCount,
|
|
12096
|
+
startedAt: performance.now(),
|
|
12097
|
+
startedAtIso: new Date().toISOString(),
|
|
12098
|
+
simpleRouteJson,
|
|
12099
|
+
routerDescription: this.formatRouter(event),
|
|
12100
|
+
lastProgressLogAt: 0,
|
|
12101
|
+
hasLoggedStart: false,
|
|
12102
|
+
longRunningLoggingStarted: false
|
|
12103
|
+
};
|
|
12104
|
+
if (this.options.enabled) {
|
|
12105
|
+
this.logPhaseStart(this.activePhase);
|
|
12106
|
+
}
|
|
12107
|
+
if (this.shouldDumpInput(routingPhaseIndex)) {
|
|
12108
|
+
this.writeJson(this.getPhaseFileName(this.activePhase, "input.simple-route.json"), simpleRouteJson ?? {});
|
|
12109
|
+
}
|
|
12110
|
+
}
|
|
12111
|
+
handleProgress(event) {
|
|
12112
|
+
if (!this.activePhase)
|
|
12113
|
+
return;
|
|
12114
|
+
const now = performance.now();
|
|
12115
|
+
this.activePhase.lastProgress = event;
|
|
12116
|
+
if (!this.shouldLogPhaseDetails(this.activePhase))
|
|
12117
|
+
return;
|
|
12118
|
+
if (this.activePhase.lastProgressLogAt > 0 && now - this.activePhase.lastProgressLogAt < PROGRESS_LOG_INTERVAL_MS) {
|
|
12119
|
+
return;
|
|
12120
|
+
}
|
|
12121
|
+
this.activePhase.lastProgressLogAt = now;
|
|
12122
|
+
this.logProgress(this.activePhase, event, now);
|
|
12123
|
+
}
|
|
12124
|
+
handleEnd(event) {
|
|
12125
|
+
const activePhase = this.matchActivePhase(event);
|
|
12126
|
+
if (!activePhase)
|
|
12127
|
+
return;
|
|
12128
|
+
const elapsedMs = performance.now() - activePhase.startedAt;
|
|
12129
|
+
const outputSrj = event.simpleRouteJson;
|
|
12130
|
+
const outputTraceCount = outputSrj?.traces?.length ?? 0;
|
|
12131
|
+
const outputJumperCount = outputSrj?.jumpers?.length ?? 0;
|
|
12132
|
+
const errorCount = this.countErrors(outputSrj);
|
|
12133
|
+
const cumulativeTraceCount = activePhase.previousTraceCount + outputTraceCount;
|
|
12134
|
+
this.traceCountBySubcircuit.set(activePhase.subcircuitId, cumulativeTraceCount);
|
|
12135
|
+
this.completedPhaseTraces.push(...outputSrj?.traces ?? []);
|
|
12136
|
+
this.summary.push({
|
|
12137
|
+
subcircuit_id: activePhase.subcircuitId,
|
|
12138
|
+
componentDisplayName: activePhase.componentDisplayName,
|
|
12139
|
+
routingPhaseIndex: activePhase.routingPhaseIndex,
|
|
12140
|
+
phaseOrdinal: activePhase.phaseOrdinal,
|
|
12141
|
+
phaseCount: activePhase.phaseCount,
|
|
12142
|
+
connectionCount: activePhase.connectionCount,
|
|
12143
|
+
obstacleCount: activePhase.obstacleCount,
|
|
12144
|
+
previousTraceCount: activePhase.previousTraceCount,
|
|
12145
|
+
outputTraceCount,
|
|
12146
|
+
outputJumperCount,
|
|
12147
|
+
errorCount,
|
|
12148
|
+
elapsedMs: Math.round(elapsedMs),
|
|
12149
|
+
startedAt: activePhase.startedAtIso,
|
|
12150
|
+
completedAt: new Date().toISOString()
|
|
12151
|
+
});
|
|
12152
|
+
if (this.shouldLogPhaseDetails(activePhase) || this.didCrossLongRunningThreshold(activePhase, elapsedMs)) {
|
|
12153
|
+
if (!activePhase.hasLoggedStart) {
|
|
12154
|
+
this.startLongRunningLogging(activePhase, elapsedMs);
|
|
12155
|
+
}
|
|
12156
|
+
this.logPhaseEnd(activePhase, {
|
|
12157
|
+
outputTraceCount,
|
|
12158
|
+
outputJumperCount,
|
|
12159
|
+
errorCount,
|
|
12160
|
+
elapsedMs
|
|
12161
|
+
});
|
|
12162
|
+
}
|
|
12163
|
+
if (this.shouldDumpSuccessfulOutput(activePhase.routingPhaseIndex)) {
|
|
12164
|
+
this.writeJson(this.getPhaseFileName(activePhase, "output.traces.json"), outputSrj?.traces ?? []);
|
|
12165
|
+
}
|
|
12166
|
+
if (this.activePhase === activePhase) {
|
|
12167
|
+
this.activePhase = null;
|
|
12168
|
+
}
|
|
12169
|
+
}
|
|
12170
|
+
handleError(event) {
|
|
12171
|
+
const activePhase = this.matchActivePhase(event);
|
|
12172
|
+
if (!activePhase)
|
|
12173
|
+
return;
|
|
12174
|
+
const elapsedMs = performance.now() - activePhase.startedAt;
|
|
12175
|
+
const error = this.serializeError(event.error);
|
|
12176
|
+
this.summary.push({
|
|
12177
|
+
subcircuit_id: activePhase.subcircuitId,
|
|
12178
|
+
componentDisplayName: activePhase.componentDisplayName,
|
|
12179
|
+
routingPhaseIndex: activePhase.routingPhaseIndex,
|
|
12180
|
+
phaseOrdinal: activePhase.phaseOrdinal,
|
|
12181
|
+
phaseCount: activePhase.phaseCount,
|
|
12182
|
+
connectionCount: activePhase.connectionCount,
|
|
12183
|
+
obstacleCount: activePhase.obstacleCount,
|
|
12184
|
+
previousTraceCount: activePhase.previousTraceCount,
|
|
12185
|
+
elapsedMs: Math.round(elapsedMs),
|
|
12186
|
+
error,
|
|
12187
|
+
startedAt: activePhase.startedAtIso,
|
|
12188
|
+
completedAt: new Date().toISOString()
|
|
12189
|
+
});
|
|
12190
|
+
if (this.options.enabled || this.options.logOnError) {
|
|
12191
|
+
if (!activePhase.hasLoggedStart) {
|
|
12192
|
+
this.logPhaseStart(activePhase, "failed");
|
|
12193
|
+
}
|
|
12194
|
+
this.log(` ${this.getPhaseLabel(activePhase)} error after ${this.formatElapsed(elapsedMs)}: ${error.message}`);
|
|
12195
|
+
}
|
|
12196
|
+
if (this.shouldDumpFailedInput(activePhase.routingPhaseIndex)) {
|
|
12197
|
+
this.writeJson(this.getPhaseFileName(activePhase, "input.simple-route.json"), event.simpleRouteJson ?? activePhase.simpleRouteJson ?? {});
|
|
12198
|
+
this.writeJson(this.getPhaseFileName(activePhase, "error.json"), {
|
|
12199
|
+
type: "autorouter_phase_error",
|
|
12200
|
+
subcircuit_id: activePhase.subcircuitId,
|
|
12201
|
+
routingPhaseIndex: activePhase.routingPhaseIndex,
|
|
12202
|
+
phaseOrdinal: activePhase.phaseOrdinal,
|
|
12203
|
+
phaseCount: activePhase.phaseCount,
|
|
12204
|
+
elapsedMs: Math.round(elapsedMs),
|
|
12205
|
+
connectionCount: activePhase.connectionCount,
|
|
12206
|
+
obstacleCount: activePhase.obstacleCount,
|
|
12207
|
+
previousTraceCount: activePhase.previousTraceCount,
|
|
12208
|
+
error
|
|
12209
|
+
});
|
|
12210
|
+
}
|
|
12211
|
+
if (this.activePhase === activePhase) {
|
|
12212
|
+
this.activePhase = null;
|
|
12213
|
+
}
|
|
12214
|
+
}
|
|
12215
|
+
writeTimeoutArtifact(activePhase, elapsedMs) {
|
|
12216
|
+
const inputFile = this.getPhaseFileName(activePhase, "input.simple-route.json");
|
|
12217
|
+
const previousTracesFile = this.getPhaseFileName(activePhase, "previous-output.traces.json");
|
|
12218
|
+
const timeoutFile = this.getPhaseFileName(activePhase, "timeout.json");
|
|
12219
|
+
const boardFile = "board.source-and-pcb.circuit.json";
|
|
12220
|
+
this.writeJson(inputFile, activePhase.simpleRouteJson ?? {});
|
|
12221
|
+
this.writeJson(previousTracesFile, this.completedPhaseTraces);
|
|
12222
|
+
this.writeJson(boardFile, this.getCurrentCircuitJson());
|
|
12223
|
+
return this.writeJson(timeoutFile, {
|
|
12224
|
+
type: "autorouter_phase_timeout",
|
|
12225
|
+
subcircuit_id: activePhase.subcircuitId,
|
|
12226
|
+
componentDisplayName: activePhase.componentDisplayName,
|
|
12227
|
+
routingPhaseIndex: activePhase.routingPhaseIndex,
|
|
12228
|
+
phaseOrdinal: activePhase.phaseOrdinal,
|
|
12229
|
+
phaseCount: activePhase.phaseCount,
|
|
12230
|
+
elapsedMs: Math.round(elapsedMs),
|
|
12231
|
+
connectionCount: activePhase.connectionCount,
|
|
12232
|
+
obstacleCount: activePhase.obstacleCount,
|
|
12233
|
+
previousTraceCount: activePhase.previousTraceCount,
|
|
12234
|
+
autorouter: {
|
|
12235
|
+
kind: "default-or-core"
|
|
12236
|
+
},
|
|
12237
|
+
files: {
|
|
12238
|
+
inputSimpleRouteJson: inputFile,
|
|
12239
|
+
previousOutputTraces: previousTracesFile,
|
|
12240
|
+
boardCircuitJson: boardFile
|
|
12241
|
+
},
|
|
12242
|
+
lastProgress: activePhase.lastProgress
|
|
12243
|
+
});
|
|
12244
|
+
}
|
|
12245
|
+
checkLongRunning() {
|
|
12246
|
+
if (!this.activePhase)
|
|
12247
|
+
return;
|
|
12248
|
+
const elapsedMs = performance.now() - this.activePhase.startedAt;
|
|
12249
|
+
if (!this.didCrossLongRunningThreshold(this.activePhase, elapsedMs))
|
|
12250
|
+
return;
|
|
12251
|
+
this.startLongRunningLogging(this.activePhase, elapsedMs);
|
|
12252
|
+
}
|
|
12253
|
+
didCrossLongRunningThreshold(activePhase, elapsedMs) {
|
|
12254
|
+
return Boolean(!this.options.enabled && this.options.longRunningLogThresholdMs && !activePhase.longRunningLoggingStarted && elapsedMs >= this.options.longRunningLogThresholdMs);
|
|
12255
|
+
}
|
|
12256
|
+
startLongRunningLogging(activePhase, elapsedMs) {
|
|
12257
|
+
activePhase.longRunningLoggingStarted = true;
|
|
12258
|
+
this.log(kleur_default.yellow(`Autorouting ${this.getPhaseLabel(activePhase)} has been running for ${this.formatElapsed(elapsedMs)}; enabling phase diagnostics. Re-run with --autorouter-debug for full autorouter logs from the start.`));
|
|
12259
|
+
this.logPhaseStart(activePhase, "long-running");
|
|
12260
|
+
if (activePhase.lastProgress) {
|
|
12261
|
+
this.logProgress(activePhase, activePhase.lastProgress, performance.now());
|
|
12262
|
+
}
|
|
12263
|
+
}
|
|
12264
|
+
shouldLogPhaseDetails(activePhase) {
|
|
12265
|
+
return Boolean(this.options.enabled || activePhase.longRunningLoggingStarted);
|
|
12266
|
+
}
|
|
12267
|
+
logPhaseStart(activePhase, reason) {
|
|
12268
|
+
const reasonText = reason ? ` ${reason}` : "";
|
|
12269
|
+
this.log([
|
|
12270
|
+
`Autorouting ${activePhase.componentDisplayName} (${activePhase.subcircuitId}) ${this.getPhaseLabel(activePhase)}${reasonText} start:`,
|
|
12271
|
+
`connections=${activePhase.connectionCount},`,
|
|
12272
|
+
`obstacles=${activePhase.obstacleCount},`,
|
|
12273
|
+
`previous_traces=${activePhase.previousTraceCount}`,
|
|
12274
|
+
activePhase.routerDescription ? `, ${activePhase.routerDescription}` : ""
|
|
12275
|
+
].join(" "));
|
|
12276
|
+
const connectionNames = this.getConnectionNames(activePhase.simpleRouteJson);
|
|
12277
|
+
if (connectionNames.length > 0) {
|
|
12278
|
+
this.log(` connections: ${connectionNames.join(", ")}`);
|
|
12279
|
+
}
|
|
12280
|
+
activePhase.hasLoggedStart = true;
|
|
12281
|
+
}
|
|
12282
|
+
logProgress(activePhase, event, now) {
|
|
12283
|
+
const elapsedMs = event.elapsedMs ?? now - activePhase.startedAt;
|
|
12284
|
+
const details = [
|
|
12285
|
+
event.solverName ? `solver=${event.solverName}` : null,
|
|
12286
|
+
event.phase ? `solver_phase=${event.phase}` : null,
|
|
12287
|
+
event.iteration !== undefined ? `iter=${event.iteration}` : event.steps !== undefined ? `steps=${event.steps}` : null,
|
|
12288
|
+
event.progress !== undefined ? `progress=${Math.round(event.progress * 100)}%` : null,
|
|
12289
|
+
event.iterationsPerSecond !== undefined ? `iterations_per_second=${Math.round(event.iterationsPerSecond)}` : null,
|
|
12290
|
+
`elapsed=${this.formatElapsed(elapsedMs)}`
|
|
12291
|
+
].filter(Boolean);
|
|
12292
|
+
this.log(` ${this.getPhaseLabel(activePhase)} progress: ${details.join(" ")}`);
|
|
12293
|
+
}
|
|
12294
|
+
logPhaseEnd(activePhase, {
|
|
12295
|
+
outputTraceCount,
|
|
12296
|
+
outputJumperCount,
|
|
12297
|
+
errorCount,
|
|
12298
|
+
elapsedMs
|
|
12299
|
+
}) {
|
|
12300
|
+
this.log(` ${this.getPhaseLabel(activePhase)} done: routed_traces=${outputTraceCount}, jumpers=${outputJumperCount}, errors=${errorCount}, elapsed=${this.formatElapsed(elapsedMs)}`);
|
|
12301
|
+
}
|
|
12302
|
+
matchActivePhase(event) {
|
|
12303
|
+
if (!this.activePhase)
|
|
12304
|
+
return null;
|
|
12305
|
+
const subcircuitId = event.subcircuit_id ?? event.subcircuitId;
|
|
12306
|
+
if (subcircuitId && subcircuitId !== this.activePhase.subcircuitId) {
|
|
12307
|
+
return null;
|
|
12308
|
+
}
|
|
12309
|
+
return this.activePhase;
|
|
12310
|
+
}
|
|
12311
|
+
shouldDumpInput(routingPhaseIndex) {
|
|
12312
|
+
return this.options.dumpSrj === "all" || this.options.dumpSrj === `phase:${routingPhaseIndex}`;
|
|
12313
|
+
}
|
|
12314
|
+
shouldDumpSuccessfulOutput(routingPhaseIndex) {
|
|
12315
|
+
return this.options.dumpSrj === "all" || this.options.dumpSrj === `phase:${routingPhaseIndex}`;
|
|
12316
|
+
}
|
|
12317
|
+
shouldDumpFailedInput(routingPhaseIndex) {
|
|
12318
|
+
return this.options.dumpSrj === "all" || this.options.dumpSrj === "failed" || this.options.dumpSrj === `phase:${routingPhaseIndex}`;
|
|
12319
|
+
}
|
|
12320
|
+
writeJson(fileName, value) {
|
|
12321
|
+
const debugDir = path2.resolve(this.options.debugDir ?? DEFAULT_DEBUG_DIR);
|
|
12322
|
+
fs2.mkdirSync(debugDir, { recursive: true });
|
|
12323
|
+
const filePath = path2.join(debugDir, fileName);
|
|
12324
|
+
fs2.writeFileSync(filePath, JSON.stringify(value, null, 2));
|
|
12325
|
+
return filePath;
|
|
12326
|
+
}
|
|
12327
|
+
getPhaseFileName(activePhase, suffix) {
|
|
12328
|
+
const phaseNumber = activePhase.routingPhaseIndex;
|
|
12329
|
+
return `phase-${phaseNumber}.${suffix}`;
|
|
12330
|
+
}
|
|
12331
|
+
getPhaseLabel(activePhase) {
|
|
12332
|
+
if (activePhase.phaseCount) {
|
|
12333
|
+
return `phase ${activePhase.phaseOrdinal}/${activePhase.phaseCount}`;
|
|
12334
|
+
}
|
|
12335
|
+
return `phase ${activePhase.phaseOrdinal}`;
|
|
12336
|
+
}
|
|
12337
|
+
formatElapsed(elapsedMs) {
|
|
12338
|
+
if (elapsedMs < 1000)
|
|
12339
|
+
return `${Math.round(elapsedMs)}ms`;
|
|
12340
|
+
return `${(elapsedMs / 1000).toFixed(1)}s`;
|
|
12341
|
+
}
|
|
12342
|
+
formatRouter(event) {
|
|
12343
|
+
const parts = [
|
|
12344
|
+
event.autorouterName ? `router=${event.autorouterName}` : null,
|
|
12345
|
+
event.autorouterVersion ? `version=${event.autorouterVersion}` : null,
|
|
12346
|
+
event.effort !== undefined ? `effort=${event.effort}` : null
|
|
12347
|
+
].filter(Boolean);
|
|
12348
|
+
return parts.join(", ");
|
|
12349
|
+
}
|
|
12350
|
+
getConnectionNames(simpleRouteJson) {
|
|
12351
|
+
return (simpleRouteJson?.connections ?? []).map((connection) => {
|
|
12352
|
+
const name = connection.name ?? connection.rootConnectionName ?? connection.source_trace_id;
|
|
12353
|
+
return typeof name === "string" ? name : null;
|
|
12354
|
+
}).filter((name) => Boolean(name));
|
|
12355
|
+
}
|
|
12356
|
+
countErrors(simpleRouteJson) {
|
|
12357
|
+
const errors = simpleRouteJson?.errors;
|
|
12358
|
+
return Array.isArray(errors) ? errors.length : 0;
|
|
12359
|
+
}
|
|
12360
|
+
getCurrentCircuitJson() {
|
|
12361
|
+
try {
|
|
12362
|
+
return this.rootCircuit?.db?.toArray?.() ?? [];
|
|
12363
|
+
} catch {
|
|
12364
|
+
return [];
|
|
12365
|
+
}
|
|
12366
|
+
}
|
|
12367
|
+
serializeError(error) {
|
|
12368
|
+
if (error instanceof Error) {
|
|
12369
|
+
return { message: error.message, stack: error.stack };
|
|
12370
|
+
}
|
|
12371
|
+
if (typeof error === "string") {
|
|
12372
|
+
return { message: error };
|
|
12373
|
+
}
|
|
12374
|
+
return {
|
|
12375
|
+
message: error?.message ?? "Unknown autorouting error",
|
|
12376
|
+
stack: error?.stack
|
|
12377
|
+
};
|
|
12378
|
+
}
|
|
12379
|
+
log(message) {
|
|
12380
|
+
this.options.log(message);
|
|
12381
|
+
}
|
|
12382
|
+
}
|
|
12383
|
+
|
|
12384
|
+
// lib/shared/importFromUserLand.ts
|
|
12385
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
12386
|
+
import fs3 from "node:fs";
|
|
12387
|
+
import path3 from "node:path";
|
|
11887
12388
|
async function importFromUserLand(moduleName) {
|
|
11888
|
-
const userModulePath =
|
|
11889
|
-
if (
|
|
11890
|
-
const userRequire = createRequire2(
|
|
12389
|
+
const userModulePath = path3.join(process.cwd(), "node_modules", moduleName);
|
|
12390
|
+
if (fs3.existsSync(userModulePath)) {
|
|
12391
|
+
const userRequire = createRequire2(path3.join(process.cwd(), "noop.js"));
|
|
11891
12392
|
try {
|
|
11892
12393
|
const resolvedUserPath = userRequire.resolve(moduleName);
|
|
11893
12394
|
return await import(resolvedUserPath);
|
|
@@ -11910,8 +12411,8 @@ async function importFromUserLand(moduleName) {
|
|
|
11910
12411
|
}
|
|
11911
12412
|
|
|
11912
12413
|
// lib/shared/register-static-asset-loaders.ts
|
|
11913
|
-
import
|
|
11914
|
-
import
|
|
12414
|
+
import fs4 from "node:fs";
|
|
12415
|
+
import path4 from "node:path";
|
|
11915
12416
|
var STATIC_ASSET_EXTENSIONS = [
|
|
11916
12417
|
".glb",
|
|
11917
12418
|
".gltf",
|
|
@@ -11936,15 +12437,15 @@ var TEXT_STATIC_ASSET_EXTENSIONS = new Set([
|
|
|
11936
12437
|
".kicad_sch"
|
|
11937
12438
|
]);
|
|
11938
12439
|
var readFileContentForStaticLoader = (filePath) => {
|
|
11939
|
-
const ext =
|
|
12440
|
+
const ext = path4.extname(filePath).toLowerCase();
|
|
11940
12441
|
if (TEXT_STATIC_ASSET_EXTENSIONS.has(ext)) {
|
|
11941
|
-
return
|
|
12442
|
+
return fs4.readFileSync(filePath, "utf-8");
|
|
11942
12443
|
}
|
|
11943
|
-
const buffer =
|
|
12444
|
+
const buffer = fs4.readFileSync(filePath);
|
|
11944
12445
|
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
11945
12446
|
};
|
|
11946
12447
|
var getStaticFileLoader = (filePath) => {
|
|
11947
|
-
const extWithDot =
|
|
12448
|
+
const extWithDot = path4.extname(filePath).toLowerCase();
|
|
11948
12449
|
const ext = extWithDot.replace(/^\./, "");
|
|
11949
12450
|
return activePlatformConfig?.staticFileLoaderMap?.[ext] ?? activePlatformConfig?.staticFileLoaderMap?.[extWithDot];
|
|
11950
12451
|
};
|
|
@@ -11958,12 +12459,12 @@ var normalizeStaticFileLoaderResult = (result) => {
|
|
|
11958
12459
|
};
|
|
11959
12460
|
};
|
|
11960
12461
|
var getBaseUrlFromTsConfig = () => {
|
|
11961
|
-
const tsconfigPath =
|
|
12462
|
+
const tsconfigPath = path4.join(process.cwd(), "tsconfig.json");
|
|
11962
12463
|
try {
|
|
11963
|
-
if (!
|
|
12464
|
+
if (!fs4.existsSync(tsconfigPath)) {
|
|
11964
12465
|
return null;
|
|
11965
12466
|
}
|
|
11966
|
-
const tsconfigContent =
|
|
12467
|
+
const tsconfigContent = fs4.readFileSync(tsconfigPath, "utf-8");
|
|
11967
12468
|
const tsconfig = JSON.parse(tsconfigContent);
|
|
11968
12469
|
if (tsconfig.compilerOptions?.baseUrl) {
|
|
11969
12470
|
return tsconfig.compilerOptions.baseUrl;
|
|
@@ -11990,8 +12491,8 @@ var registerStaticAssetLoaders = (platformConfig) => {
|
|
|
11990
12491
|
loader: "object"
|
|
11991
12492
|
};
|
|
11992
12493
|
}
|
|
11993
|
-
const baseDir = baseUrl ?
|
|
11994
|
-
const relativePath =
|
|
12494
|
+
const baseDir = baseUrl ? path4.resolve(process.cwd(), baseUrl) : process.cwd();
|
|
12495
|
+
const relativePath = path4.relative(baseDir, args.path).split(path4.sep).join("/");
|
|
11995
12496
|
const pathStr = `./${relativePath}`;
|
|
11996
12497
|
return {
|
|
11997
12498
|
exports: {
|
|
@@ -12030,7 +12531,8 @@ async function generateCircuitJson({
|
|
|
12030
12531
|
saveToFile = false,
|
|
12031
12532
|
platformConfig,
|
|
12032
12533
|
injectedProps,
|
|
12033
|
-
onAsyncEffectStatus
|
|
12534
|
+
onAsyncEffectStatus,
|
|
12535
|
+
autorouterDiagnostics: autorouterDiagnosticsOptions
|
|
12034
12536
|
}) {
|
|
12035
12537
|
debug(`Generating circuit JSON for ${filePath}`);
|
|
12036
12538
|
const React = await importFromUserLand("react");
|
|
@@ -12040,12 +12542,14 @@ async function generateCircuitJson({
|
|
|
12040
12542
|
const runner = new userLandTscircuit.RootCircuit({
|
|
12041
12543
|
platform: platformConfig
|
|
12042
12544
|
});
|
|
12043
|
-
const
|
|
12044
|
-
|
|
12545
|
+
const autorouterDiagnostics = new AutorouterDiagnostics(autorouterDiagnosticsOptions);
|
|
12546
|
+
autorouterDiagnostics.attachToRootCircuit(runner);
|
|
12547
|
+
const absoluteFilePath = path5.isAbsolute(filePath) ? filePath : path5.resolve(process.cwd(), filePath);
|
|
12548
|
+
const projectDir = path5.dirname(absoluteFilePath);
|
|
12045
12549
|
const resolvedOutputDir = outputDir ?? projectDir;
|
|
12046
|
-
const relativeComponentPath =
|
|
12047
|
-
const baseFileName = outputFileName ||
|
|
12048
|
-
const outputPath =
|
|
12550
|
+
const relativeComponentPath = path5.relative(projectDir, absoluteFilePath);
|
|
12551
|
+
const baseFileName = outputFileName || path5.basename(absoluteFilePath).replace(/\.[^.]+$/, "");
|
|
12552
|
+
const outputPath = path5.join(resolvedOutputDir, `${baseFileName}.circuit.json`);
|
|
12049
12553
|
debug(`Project directory: ${projectDir}`);
|
|
12050
12554
|
debug(`Relative component path: ${relativeComponentPath}`);
|
|
12051
12555
|
debug(`Output path: ${outputPath}`);
|
|
@@ -12065,7 +12569,7 @@ async function generateCircuitJson({
|
|
|
12065
12569
|
return false;
|
|
12066
12570
|
if (normalizedFilePath.match(/^\.[^/]/))
|
|
12067
12571
|
return false;
|
|
12068
|
-
if (!ALLOWED_FILE_EXTENSIONS.includes(
|
|
12572
|
+
if (!ALLOWED_FILE_EXTENSIONS.includes(path5.extname(normalizedFilePath)))
|
|
12069
12573
|
return false;
|
|
12070
12574
|
return true;
|
|
12071
12575
|
},
|
|
@@ -12092,14 +12596,16 @@ async function generateCircuitJson({
|
|
|
12092
12596
|
loggedAsyncEffectNames.add(asyncEffectName);
|
|
12093
12597
|
onAsyncEffectStatus?.(asyncEffectName);
|
|
12094
12598
|
}
|
|
12599
|
+
autorouterDiagnostics.checkTimeout();
|
|
12095
12600
|
await new Promise((resolve2) => setTimeout(resolve2, 100));
|
|
12096
12601
|
runner.render();
|
|
12097
12602
|
}
|
|
12098
12603
|
runner.emit("renderComplete");
|
|
12099
12604
|
const circuitJson = await runner.getCircuitJson();
|
|
12605
|
+
autorouterDiagnostics.finalize(circuitJson);
|
|
12100
12606
|
if (saveToFile) {
|
|
12101
12607
|
debug(`Saving circuit JSON to ${outputPath}`);
|
|
12102
|
-
|
|
12608
|
+
fs5.writeFileSync(outputPath, JSON.stringify(circuitJson, null, 2));
|
|
12103
12609
|
}
|
|
12104
12610
|
return {
|
|
12105
12611
|
circuitJson,
|
|
@@ -12110,28 +12616,28 @@ async function generateCircuitJson({
|
|
|
12110
12616
|
|
|
12111
12617
|
// lib/shared/get-platform-config-with-cli-defaults.ts
|
|
12112
12618
|
import { createHash } from "node:crypto";
|
|
12113
|
-
import
|
|
12114
|
-
import
|
|
12619
|
+
import fs6 from "node:fs";
|
|
12620
|
+
import path6 from "node:path";
|
|
12115
12621
|
import { getPlatformConfig } from "@tscircuit/eval/platform-config";
|
|
12116
|
-
function createLocalCacheEngine(cacheDir =
|
|
12622
|
+
function createLocalCacheEngine(cacheDir = path6.join(process.cwd(), ".tscircuit", "cache")) {
|
|
12117
12623
|
return {
|
|
12118
12624
|
getItem: (key) => {
|
|
12119
12625
|
try {
|
|
12120
12626
|
const hash = createHash("md5").update(key).digest("hex");
|
|
12121
12627
|
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
12122
|
-
const filePath =
|
|
12123
|
-
return
|
|
12628
|
+
const filePath = path6.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
12629
|
+
return fs6.readFileSync(filePath, "utf-8");
|
|
12124
12630
|
} catch {
|
|
12125
12631
|
return null;
|
|
12126
12632
|
}
|
|
12127
12633
|
},
|
|
12128
12634
|
setItem: (key, value) => {
|
|
12129
12635
|
try {
|
|
12130
|
-
|
|
12636
|
+
fs6.mkdirSync(cacheDir, { recursive: true });
|
|
12131
12637
|
const hash = createHash("md5").update(key).digest("hex");
|
|
12132
12638
|
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
12133
|
-
const filePath =
|
|
12134
|
-
|
|
12639
|
+
const filePath = path6.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
12640
|
+
fs6.writeFileSync(filePath, value);
|
|
12135
12641
|
} catch {}
|
|
12136
12642
|
}
|
|
12137
12643
|
};
|
|
@@ -12147,15 +12653,15 @@ function getPlatformConfigWithCliDefaults(userConfig) {
|
|
|
12147
12653
|
loadFromUrl: async (url) => {
|
|
12148
12654
|
let fetchUrl = url;
|
|
12149
12655
|
if (url.startsWith("./") || url.startsWith("../")) {
|
|
12150
|
-
const absolutePath =
|
|
12656
|
+
const absolutePath = path6.resolve(process.cwd(), url);
|
|
12151
12657
|
fetchUrl = `file://${absolutePath}`;
|
|
12152
12658
|
} else if (url.startsWith("/")) {
|
|
12153
|
-
if (
|
|
12659
|
+
if (fs6.existsSync(url)) {
|
|
12154
12660
|
fetchUrl = `file://${url}`;
|
|
12155
12661
|
} else {
|
|
12156
12662
|
const relativePath = `.${url}`;
|
|
12157
|
-
const absolutePath =
|
|
12158
|
-
if (
|
|
12663
|
+
const absolutePath = path6.resolve(process.cwd(), relativePath);
|
|
12664
|
+
if (fs6.existsSync(absolutePath)) {
|
|
12159
12665
|
fetchUrl = `file://${absolutePath}`;
|
|
12160
12666
|
} else {
|
|
12161
12667
|
fetchUrl = `file://${url}`;
|
|
@@ -12380,8 +12886,8 @@ var resolveImageFormatSelection = (options) => {
|
|
|
12380
12886
|
};
|
|
12381
12887
|
|
|
12382
12888
|
// cli/build/worker-output-generators.ts
|
|
12383
|
-
import
|
|
12384
|
-
import
|
|
12889
|
+
import fs11 from "node:fs";
|
|
12890
|
+
import path15 from "node:path";
|
|
12385
12891
|
|
|
12386
12892
|
// node_modules/circuit-json-to-3d-png/dist/index.js
|
|
12387
12893
|
function normalizeDir(dir) {
|
|
@@ -14862,8 +15368,8 @@ import {
|
|
|
14862
15368
|
// node_modules/conf/dist/source/index.js
|
|
14863
15369
|
import { isDeepStrictEqual } from "node:util";
|
|
14864
15370
|
import process7 from "node:process";
|
|
14865
|
-
import
|
|
14866
|
-
import
|
|
15371
|
+
import fs8 from "node:fs";
|
|
15372
|
+
import path10 from "node:path";
|
|
14867
15373
|
import crypto from "node:crypto";
|
|
14868
15374
|
import assert from "node:assert";
|
|
14869
15375
|
|
|
@@ -14878,12 +15384,12 @@ var disallowedKeys = new Set([
|
|
|
14878
15384
|
"constructor"
|
|
14879
15385
|
]);
|
|
14880
15386
|
var digits = new Set("0123456789");
|
|
14881
|
-
function getPathSegments(
|
|
15387
|
+
function getPathSegments(path7) {
|
|
14882
15388
|
const parts = [];
|
|
14883
15389
|
let currentSegment = "";
|
|
14884
15390
|
let currentPart = "start";
|
|
14885
15391
|
let isIgnoring = false;
|
|
14886
|
-
for (const character of
|
|
15392
|
+
for (const character of path7) {
|
|
14887
15393
|
switch (character) {
|
|
14888
15394
|
case "\\": {
|
|
14889
15395
|
if (currentPart === "index") {
|
|
@@ -15005,11 +15511,11 @@ function assertNotStringIndex(object, key) {
|
|
|
15005
15511
|
throw new Error("Cannot use string index");
|
|
15006
15512
|
}
|
|
15007
15513
|
}
|
|
15008
|
-
function getProperty(object,
|
|
15009
|
-
if (!isObject(object) || typeof
|
|
15514
|
+
function getProperty(object, path7, value) {
|
|
15515
|
+
if (!isObject(object) || typeof path7 !== "string") {
|
|
15010
15516
|
return value === undefined ? object : value;
|
|
15011
15517
|
}
|
|
15012
|
-
const pathArray = getPathSegments(
|
|
15518
|
+
const pathArray = getPathSegments(path7);
|
|
15013
15519
|
if (pathArray.length === 0) {
|
|
15014
15520
|
return value;
|
|
15015
15521
|
}
|
|
@@ -15029,12 +15535,12 @@ function getProperty(object, path6, value) {
|
|
|
15029
15535
|
}
|
|
15030
15536
|
return object === undefined ? value : object;
|
|
15031
15537
|
}
|
|
15032
|
-
function setProperty(object,
|
|
15033
|
-
if (!isObject(object) || typeof
|
|
15538
|
+
function setProperty(object, path7, value) {
|
|
15539
|
+
if (!isObject(object) || typeof path7 !== "string") {
|
|
15034
15540
|
return object;
|
|
15035
15541
|
}
|
|
15036
15542
|
const root = object;
|
|
15037
|
-
const pathArray = getPathSegments(
|
|
15543
|
+
const pathArray = getPathSegments(path7);
|
|
15038
15544
|
for (let index = 0;index < pathArray.length; index++) {
|
|
15039
15545
|
const key = pathArray[index];
|
|
15040
15546
|
assertNotStringIndex(object, key);
|
|
@@ -15047,11 +15553,11 @@ function setProperty(object, path6, value) {
|
|
|
15047
15553
|
}
|
|
15048
15554
|
return root;
|
|
15049
15555
|
}
|
|
15050
|
-
function deleteProperty(object,
|
|
15051
|
-
if (!isObject(object) || typeof
|
|
15556
|
+
function deleteProperty(object, path7) {
|
|
15557
|
+
if (!isObject(object) || typeof path7 !== "string") {
|
|
15052
15558
|
return false;
|
|
15053
15559
|
}
|
|
15054
|
-
const pathArray = getPathSegments(
|
|
15560
|
+
const pathArray = getPathSegments(path7);
|
|
15055
15561
|
for (let index = 0;index < pathArray.length; index++) {
|
|
15056
15562
|
const key = pathArray[index];
|
|
15057
15563
|
assertNotStringIndex(object, key);
|
|
@@ -15065,11 +15571,11 @@ function deleteProperty(object, path6) {
|
|
|
15065
15571
|
}
|
|
15066
15572
|
}
|
|
15067
15573
|
}
|
|
15068
|
-
function hasProperty(object,
|
|
15069
|
-
if (!isObject(object) || typeof
|
|
15574
|
+
function hasProperty(object, path7) {
|
|
15575
|
+
if (!isObject(object) || typeof path7 !== "string") {
|
|
15070
15576
|
return false;
|
|
15071
15577
|
}
|
|
15072
|
-
const pathArray = getPathSegments(
|
|
15578
|
+
const pathArray = getPathSegments(path7);
|
|
15073
15579
|
if (pathArray.length === 0) {
|
|
15074
15580
|
return false;
|
|
15075
15581
|
}
|
|
@@ -15083,41 +15589,41 @@ function hasProperty(object, path6) {
|
|
|
15083
15589
|
}
|
|
15084
15590
|
|
|
15085
15591
|
// node_modules/env-paths/index.js
|
|
15086
|
-
import
|
|
15592
|
+
import path7 from "node:path";
|
|
15087
15593
|
import os from "node:os";
|
|
15088
15594
|
import process2 from "node:process";
|
|
15089
15595
|
var homedir = os.homedir();
|
|
15090
15596
|
var tmpdir = os.tmpdir();
|
|
15091
15597
|
var { env } = process2;
|
|
15092
15598
|
var macos = (name) => {
|
|
15093
|
-
const library =
|
|
15599
|
+
const library = path7.join(homedir, "Library");
|
|
15094
15600
|
return {
|
|
15095
|
-
data:
|
|
15096
|
-
config:
|
|
15097
|
-
cache:
|
|
15098
|
-
log:
|
|
15099
|
-
temp:
|
|
15601
|
+
data: path7.join(library, "Application Support", name),
|
|
15602
|
+
config: path7.join(library, "Preferences", name),
|
|
15603
|
+
cache: path7.join(library, "Caches", name),
|
|
15604
|
+
log: path7.join(library, "Logs", name),
|
|
15605
|
+
temp: path7.join(tmpdir, name)
|
|
15100
15606
|
};
|
|
15101
15607
|
};
|
|
15102
15608
|
var windows = (name) => {
|
|
15103
|
-
const appData = env.APPDATA ||
|
|
15104
|
-
const localAppData = env.LOCALAPPDATA ||
|
|
15609
|
+
const appData = env.APPDATA || path7.join(homedir, "AppData", "Roaming");
|
|
15610
|
+
const localAppData = env.LOCALAPPDATA || path7.join(homedir, "AppData", "Local");
|
|
15105
15611
|
return {
|
|
15106
|
-
data:
|
|
15107
|
-
config:
|
|
15108
|
-
cache:
|
|
15109
|
-
log:
|
|
15110
|
-
temp:
|
|
15612
|
+
data: path7.join(localAppData, name, "Data"),
|
|
15613
|
+
config: path7.join(appData, name, "Config"),
|
|
15614
|
+
cache: path7.join(localAppData, name, "Cache"),
|
|
15615
|
+
log: path7.join(localAppData, name, "Log"),
|
|
15616
|
+
temp: path7.join(tmpdir, name)
|
|
15111
15617
|
};
|
|
15112
15618
|
};
|
|
15113
15619
|
var linux = (name) => {
|
|
15114
|
-
const username =
|
|
15620
|
+
const username = path7.basename(homedir);
|
|
15115
15621
|
return {
|
|
15116
|
-
data:
|
|
15117
|
-
config:
|
|
15118
|
-
cache:
|
|
15119
|
-
log:
|
|
15120
|
-
temp:
|
|
15622
|
+
data: path7.join(env.XDG_DATA_HOME || path7.join(homedir, ".local", "share"), name),
|
|
15623
|
+
config: path7.join(env.XDG_CONFIG_HOME || path7.join(homedir, ".config"), name),
|
|
15624
|
+
cache: path7.join(env.XDG_CACHE_HOME || path7.join(homedir, ".cache"), name),
|
|
15625
|
+
log: path7.join(env.XDG_STATE_HOME || path7.join(homedir, ".local", "state"), name),
|
|
15626
|
+
temp: path7.join(tmpdir, username, name)
|
|
15121
15627
|
};
|
|
15122
15628
|
};
|
|
15123
15629
|
function envPaths(name, { suffix = "nodejs" } = {}) {
|
|
@@ -15137,10 +15643,10 @@ function envPaths(name, { suffix = "nodejs" } = {}) {
|
|
|
15137
15643
|
}
|
|
15138
15644
|
|
|
15139
15645
|
// node_modules/atomically/dist/index.js
|
|
15140
|
-
import
|
|
15646
|
+
import path9 from "node:path";
|
|
15141
15647
|
|
|
15142
15648
|
// node_modules/stubborn-fs/dist/index.js
|
|
15143
|
-
import
|
|
15649
|
+
import fs7 from "node:fs";
|
|
15144
15650
|
import { promisify } from "node:util";
|
|
15145
15651
|
|
|
15146
15652
|
// node_modules/stubborn-utils/dist/attemptify_async.js
|
|
@@ -15270,41 +15776,41 @@ var RETRYIFY_OPTIONS = {
|
|
|
15270
15776
|
// node_modules/stubborn-fs/dist/index.js
|
|
15271
15777
|
var FS = {
|
|
15272
15778
|
attempt: {
|
|
15273
|
-
chmod: attemptify_async_default(promisify(
|
|
15274
|
-
chown: attemptify_async_default(promisify(
|
|
15275
|
-
close: attemptify_async_default(promisify(
|
|
15276
|
-
fsync: attemptify_async_default(promisify(
|
|
15277
|
-
mkdir: attemptify_async_default(promisify(
|
|
15278
|
-
realpath: attemptify_async_default(promisify(
|
|
15279
|
-
stat: attemptify_async_default(promisify(
|
|
15280
|
-
unlink: attemptify_async_default(promisify(
|
|
15281
|
-
chmodSync: attemptify_sync_default(
|
|
15282
|
-
chownSync: attemptify_sync_default(
|
|
15283
|
-
closeSync: attemptify_sync_default(
|
|
15284
|
-
existsSync: attemptify_sync_default(
|
|
15285
|
-
fsyncSync: attemptify_sync_default(
|
|
15286
|
-
mkdirSync: attemptify_sync_default(
|
|
15287
|
-
realpathSync: attemptify_sync_default(
|
|
15288
|
-
statSync: attemptify_sync_default(
|
|
15289
|
-
unlinkSync: attemptify_sync_default(
|
|
15779
|
+
chmod: attemptify_async_default(promisify(fs7.chmod), ATTEMPTIFY_CHANGE_ERROR_OPTIONS),
|
|
15780
|
+
chown: attemptify_async_default(promisify(fs7.chown), ATTEMPTIFY_CHANGE_ERROR_OPTIONS),
|
|
15781
|
+
close: attemptify_async_default(promisify(fs7.close), ATTEMPTIFY_NOOP_OPTIONS),
|
|
15782
|
+
fsync: attemptify_async_default(promisify(fs7.fsync), ATTEMPTIFY_NOOP_OPTIONS),
|
|
15783
|
+
mkdir: attemptify_async_default(promisify(fs7.mkdir), ATTEMPTIFY_NOOP_OPTIONS),
|
|
15784
|
+
realpath: attemptify_async_default(promisify(fs7.realpath), ATTEMPTIFY_NOOP_OPTIONS),
|
|
15785
|
+
stat: attemptify_async_default(promisify(fs7.stat), ATTEMPTIFY_NOOP_OPTIONS),
|
|
15786
|
+
unlink: attemptify_async_default(promisify(fs7.unlink), ATTEMPTIFY_NOOP_OPTIONS),
|
|
15787
|
+
chmodSync: attemptify_sync_default(fs7.chmodSync, ATTEMPTIFY_CHANGE_ERROR_OPTIONS),
|
|
15788
|
+
chownSync: attemptify_sync_default(fs7.chownSync, ATTEMPTIFY_CHANGE_ERROR_OPTIONS),
|
|
15789
|
+
closeSync: attemptify_sync_default(fs7.closeSync, ATTEMPTIFY_NOOP_OPTIONS),
|
|
15790
|
+
existsSync: attemptify_sync_default(fs7.existsSync, ATTEMPTIFY_NOOP_OPTIONS),
|
|
15791
|
+
fsyncSync: attemptify_sync_default(fs7.fsync, ATTEMPTIFY_NOOP_OPTIONS),
|
|
15792
|
+
mkdirSync: attemptify_sync_default(fs7.mkdirSync, ATTEMPTIFY_NOOP_OPTIONS),
|
|
15793
|
+
realpathSync: attemptify_sync_default(fs7.realpathSync, ATTEMPTIFY_NOOP_OPTIONS),
|
|
15794
|
+
statSync: attemptify_sync_default(fs7.statSync, ATTEMPTIFY_NOOP_OPTIONS),
|
|
15795
|
+
unlinkSync: attemptify_sync_default(fs7.unlinkSync, ATTEMPTIFY_NOOP_OPTIONS)
|
|
15290
15796
|
},
|
|
15291
15797
|
retry: {
|
|
15292
|
-
close: retryify_async_default(promisify(
|
|
15293
|
-
fsync: retryify_async_default(promisify(
|
|
15294
|
-
open: retryify_async_default(promisify(
|
|
15295
|
-
readFile: retryify_async_default(promisify(
|
|
15296
|
-
rename: retryify_async_default(promisify(
|
|
15297
|
-
stat: retryify_async_default(promisify(
|
|
15298
|
-
write: retryify_async_default(promisify(
|
|
15299
|
-
writeFile: retryify_async_default(promisify(
|
|
15300
|
-
closeSync: retryify_sync_default(
|
|
15301
|
-
fsyncSync: retryify_sync_default(
|
|
15302
|
-
openSync: retryify_sync_default(
|
|
15303
|
-
readFileSync: retryify_sync_default(
|
|
15304
|
-
renameSync: retryify_sync_default(
|
|
15305
|
-
statSync: retryify_sync_default(
|
|
15306
|
-
writeSync: retryify_sync_default(
|
|
15307
|
-
writeFileSync: retryify_sync_default(
|
|
15798
|
+
close: retryify_async_default(promisify(fs7.close), RETRYIFY_OPTIONS),
|
|
15799
|
+
fsync: retryify_async_default(promisify(fs7.fsync), RETRYIFY_OPTIONS),
|
|
15800
|
+
open: retryify_async_default(promisify(fs7.open), RETRYIFY_OPTIONS),
|
|
15801
|
+
readFile: retryify_async_default(promisify(fs7.readFile), RETRYIFY_OPTIONS),
|
|
15802
|
+
rename: retryify_async_default(promisify(fs7.rename), RETRYIFY_OPTIONS),
|
|
15803
|
+
stat: retryify_async_default(promisify(fs7.stat), RETRYIFY_OPTIONS),
|
|
15804
|
+
write: retryify_async_default(promisify(fs7.write), RETRYIFY_OPTIONS),
|
|
15805
|
+
writeFile: retryify_async_default(promisify(fs7.writeFile), RETRYIFY_OPTIONS),
|
|
15806
|
+
closeSync: retryify_sync_default(fs7.closeSync, RETRYIFY_OPTIONS),
|
|
15807
|
+
fsyncSync: retryify_sync_default(fs7.fsyncSync, RETRYIFY_OPTIONS),
|
|
15808
|
+
openSync: retryify_sync_default(fs7.openSync, RETRYIFY_OPTIONS),
|
|
15809
|
+
readFileSync: retryify_sync_default(fs7.readFileSync, RETRYIFY_OPTIONS),
|
|
15810
|
+
renameSync: retryify_sync_default(fs7.renameSync, RETRYIFY_OPTIONS),
|
|
15811
|
+
statSync: retryify_sync_default(fs7.statSync, RETRYIFY_OPTIONS),
|
|
15812
|
+
writeSync: retryify_sync_default(fs7.writeSync, RETRYIFY_OPTIONS),
|
|
15813
|
+
writeFileSync: retryify_sync_default(fs7.writeFileSync, RETRYIFY_OPTIONS)
|
|
15308
15814
|
}
|
|
15309
15815
|
};
|
|
15310
15816
|
var dist_default = FS;
|
|
@@ -15334,7 +15840,7 @@ var isUndefined = (value) => {
|
|
|
15334
15840
|
};
|
|
15335
15841
|
|
|
15336
15842
|
// node_modules/atomically/dist/utils/temp.js
|
|
15337
|
-
import
|
|
15843
|
+
import path8 from "node:path";
|
|
15338
15844
|
|
|
15339
15845
|
// node_modules/when-exit/dist/node/interceptor.js
|
|
15340
15846
|
import process6 from "node:process";
|
|
@@ -15434,7 +15940,7 @@ var Temp = {
|
|
|
15434
15940
|
}
|
|
15435
15941
|
},
|
|
15436
15942
|
truncate: (filePath) => {
|
|
15437
|
-
const basename =
|
|
15943
|
+
const basename = path8.basename(filePath);
|
|
15438
15944
|
if (basename.length <= LIMIT_BASENAME_LENGTH)
|
|
15439
15945
|
return filePath;
|
|
15440
15946
|
const truncable = /^(\.?)(.*?)((?:\.[^.]+)?(?:\.tmp-\d{10}[a-f0-9]{6})?)$/.exec(basename);
|
|
@@ -15476,7 +15982,7 @@ function writeFileSync2(filePath, data, options = DEFAULT_WRITE_OPTIONS) {
|
|
|
15476
15982
|
}
|
|
15477
15983
|
}
|
|
15478
15984
|
if (!filePathExists) {
|
|
15479
|
-
const parentPath =
|
|
15985
|
+
const parentPath = path9.dirname(filePath);
|
|
15480
15986
|
dist_default.attempt.mkdirSync(parentPath, {
|
|
15481
15987
|
mode: DEFAULT_FOLDER_MODE,
|
|
15482
15988
|
recursive: true
|
|
@@ -15792,7 +16298,7 @@ class Conf {
|
|
|
15792
16298
|
this.events = new EventTarget;
|
|
15793
16299
|
this.#encryptionKey = options.encryptionKey;
|
|
15794
16300
|
const fileExtension = options.fileExtension ? `.${options.fileExtension}` : "";
|
|
15795
|
-
this.path =
|
|
16301
|
+
this.path = path10.resolve(options.cwd, `${options.configName ?? "config"}${fileExtension}`);
|
|
15796
16302
|
const fileStore = this.store;
|
|
15797
16303
|
const store = Object.assign(createPlainObject(), options.defaults, fileStore);
|
|
15798
16304
|
if (options.migrations) {
|
|
@@ -15895,7 +16401,7 @@ class Conf {
|
|
|
15895
16401
|
}
|
|
15896
16402
|
get store() {
|
|
15897
16403
|
try {
|
|
15898
|
-
const data =
|
|
16404
|
+
const data = fs8.readFileSync(this.path, this.#encryptionKey ? null : "utf8");
|
|
15899
16405
|
const dataString = this._encryptData(data);
|
|
15900
16406
|
const deserializedData = this._deserialize(dataString);
|
|
15901
16407
|
this._validate(deserializedData);
|
|
@@ -15966,7 +16472,7 @@ class Conf {
|
|
|
15966
16472
|
throw new Error("Config schema violation: " + errors.join("; "));
|
|
15967
16473
|
}
|
|
15968
16474
|
_ensureDirectory() {
|
|
15969
|
-
|
|
16475
|
+
fs8.mkdirSync(path10.dirname(this.path), { recursive: true });
|
|
15970
16476
|
}
|
|
15971
16477
|
_write(value) {
|
|
15972
16478
|
let data = this._serialize(value);
|
|
@@ -15977,13 +16483,13 @@ class Conf {
|
|
|
15977
16483
|
data = concatUint8Arrays([initializationVector, stringToUint8Array(":"), cipher.update(stringToUint8Array(data)), cipher.final()]);
|
|
15978
16484
|
}
|
|
15979
16485
|
if (process7.env.SNAP) {
|
|
15980
|
-
|
|
16486
|
+
fs8.writeFileSync(this.path, data, { mode: this.#options.configFileMode });
|
|
15981
16487
|
} else {
|
|
15982
16488
|
try {
|
|
15983
16489
|
writeFileSync2(this.path, data, { mode: this.#options.configFileMode });
|
|
15984
16490
|
} catch (error) {
|
|
15985
16491
|
if (error?.code === "EXDEV") {
|
|
15986
|
-
|
|
16492
|
+
fs8.writeFileSync(this.path, data, { mode: this.#options.configFileMode });
|
|
15987
16493
|
return;
|
|
15988
16494
|
}
|
|
15989
16495
|
throw error;
|
|
@@ -15992,15 +16498,15 @@ class Conf {
|
|
|
15992
16498
|
}
|
|
15993
16499
|
_watch() {
|
|
15994
16500
|
this._ensureDirectory();
|
|
15995
|
-
if (!
|
|
16501
|
+
if (!fs8.existsSync(this.path)) {
|
|
15996
16502
|
this._write(createPlainObject());
|
|
15997
16503
|
}
|
|
15998
16504
|
if (process7.platform === "win32") {
|
|
15999
|
-
|
|
16505
|
+
fs8.watch(this.path, { persistent: false }, debounce_fn_default(() => {
|
|
16000
16506
|
this.events.dispatchEvent(new Event("change"));
|
|
16001
16507
|
}, { wait: 100 }));
|
|
16002
16508
|
} else {
|
|
16003
|
-
|
|
16509
|
+
fs8.watchFile(this.path, { persistent: false }, debounce_fn_default(() => {
|
|
16004
16510
|
this.events.dispatchEvent(new Event("change"));
|
|
16005
16511
|
}, { wait: 5000 }));
|
|
16006
16512
|
}
|
|
@@ -16136,113 +16642,14 @@ function jwtDecode(token, options) {
|
|
|
16136
16642
|
}
|
|
16137
16643
|
|
|
16138
16644
|
// lib/cli-config/index.ts
|
|
16139
|
-
import
|
|
16645
|
+
import fs10 from "node:fs";
|
|
16140
16646
|
import os3 from "node:os";
|
|
16141
|
-
import
|
|
16647
|
+
import path12 from "node:path";
|
|
16142
16648
|
|
|
16143
16649
|
// lib/shared/handle-registry-auth-error.ts
|
|
16144
|
-
import
|
|
16650
|
+
import fs9 from "node:fs";
|
|
16145
16651
|
import os2 from "node:os";
|
|
16146
|
-
import
|
|
16147
|
-
|
|
16148
|
-
// node_modules/kleur/index.mjs
|
|
16149
|
-
var FORCE_COLOR;
|
|
16150
|
-
var NODE_DISABLE_COLORS;
|
|
16151
|
-
var NO_COLOR;
|
|
16152
|
-
var TERM;
|
|
16153
|
-
var isTTY = true;
|
|
16154
|
-
if (typeof process !== "undefined") {
|
|
16155
|
-
({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {});
|
|
16156
|
-
isTTY = process.stdout && process.stdout.isTTY;
|
|
16157
|
-
}
|
|
16158
|
-
var $ = {
|
|
16159
|
-
enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY),
|
|
16160
|
-
reset: init(0, 0),
|
|
16161
|
-
bold: init(1, 22),
|
|
16162
|
-
dim: init(2, 22),
|
|
16163
|
-
italic: init(3, 23),
|
|
16164
|
-
underline: init(4, 24),
|
|
16165
|
-
inverse: init(7, 27),
|
|
16166
|
-
hidden: init(8, 28),
|
|
16167
|
-
strikethrough: init(9, 29),
|
|
16168
|
-
black: init(30, 39),
|
|
16169
|
-
red: init(31, 39),
|
|
16170
|
-
green: init(32, 39),
|
|
16171
|
-
yellow: init(33, 39),
|
|
16172
|
-
blue: init(34, 39),
|
|
16173
|
-
magenta: init(35, 39),
|
|
16174
|
-
cyan: init(36, 39),
|
|
16175
|
-
white: init(37, 39),
|
|
16176
|
-
gray: init(90, 39),
|
|
16177
|
-
grey: init(90, 39),
|
|
16178
|
-
bgBlack: init(40, 49),
|
|
16179
|
-
bgRed: init(41, 49),
|
|
16180
|
-
bgGreen: init(42, 49),
|
|
16181
|
-
bgYellow: init(43, 49),
|
|
16182
|
-
bgBlue: init(44, 49),
|
|
16183
|
-
bgMagenta: init(45, 49),
|
|
16184
|
-
bgCyan: init(46, 49),
|
|
16185
|
-
bgWhite: init(47, 49)
|
|
16186
|
-
};
|
|
16187
|
-
function run(arr, str) {
|
|
16188
|
-
let i = 0, tmp, beg = "", end = "";
|
|
16189
|
-
for (;i < arr.length; i++) {
|
|
16190
|
-
tmp = arr[i];
|
|
16191
|
-
beg += tmp.open;
|
|
16192
|
-
end += tmp.close;
|
|
16193
|
-
if (!!~str.indexOf(tmp.close)) {
|
|
16194
|
-
str = str.replace(tmp.rgx, tmp.close + tmp.open);
|
|
16195
|
-
}
|
|
16196
|
-
}
|
|
16197
|
-
return beg + str + end;
|
|
16198
|
-
}
|
|
16199
|
-
function chain(has, keys) {
|
|
16200
|
-
let ctx = { has, keys };
|
|
16201
|
-
ctx.reset = $.reset.bind(ctx);
|
|
16202
|
-
ctx.bold = $.bold.bind(ctx);
|
|
16203
|
-
ctx.dim = $.dim.bind(ctx);
|
|
16204
|
-
ctx.italic = $.italic.bind(ctx);
|
|
16205
|
-
ctx.underline = $.underline.bind(ctx);
|
|
16206
|
-
ctx.inverse = $.inverse.bind(ctx);
|
|
16207
|
-
ctx.hidden = $.hidden.bind(ctx);
|
|
16208
|
-
ctx.strikethrough = $.strikethrough.bind(ctx);
|
|
16209
|
-
ctx.black = $.black.bind(ctx);
|
|
16210
|
-
ctx.red = $.red.bind(ctx);
|
|
16211
|
-
ctx.green = $.green.bind(ctx);
|
|
16212
|
-
ctx.yellow = $.yellow.bind(ctx);
|
|
16213
|
-
ctx.blue = $.blue.bind(ctx);
|
|
16214
|
-
ctx.magenta = $.magenta.bind(ctx);
|
|
16215
|
-
ctx.cyan = $.cyan.bind(ctx);
|
|
16216
|
-
ctx.white = $.white.bind(ctx);
|
|
16217
|
-
ctx.gray = $.gray.bind(ctx);
|
|
16218
|
-
ctx.grey = $.grey.bind(ctx);
|
|
16219
|
-
ctx.bgBlack = $.bgBlack.bind(ctx);
|
|
16220
|
-
ctx.bgRed = $.bgRed.bind(ctx);
|
|
16221
|
-
ctx.bgGreen = $.bgGreen.bind(ctx);
|
|
16222
|
-
ctx.bgYellow = $.bgYellow.bind(ctx);
|
|
16223
|
-
ctx.bgBlue = $.bgBlue.bind(ctx);
|
|
16224
|
-
ctx.bgMagenta = $.bgMagenta.bind(ctx);
|
|
16225
|
-
ctx.bgCyan = $.bgCyan.bind(ctx);
|
|
16226
|
-
ctx.bgWhite = $.bgWhite.bind(ctx);
|
|
16227
|
-
return ctx;
|
|
16228
|
-
}
|
|
16229
|
-
function init(open, close) {
|
|
16230
|
-
let blk = {
|
|
16231
|
-
open: `\x1B[${open}m`,
|
|
16232
|
-
close: `\x1B[${close}m`,
|
|
16233
|
-
rgx: new RegExp(`\\x1b\\[${close}m`, "g")
|
|
16234
|
-
};
|
|
16235
|
-
return function(txt) {
|
|
16236
|
-
if (this !== undefined && this.has !== undefined) {
|
|
16237
|
-
!!~this.has.indexOf(open) || (this.has.push(open), this.keys.push(blk));
|
|
16238
|
-
return txt === undefined ? this : $.enabled ? run(this.keys, txt + "") : txt + "";
|
|
16239
|
-
}
|
|
16240
|
-
return txt === undefined ? chain([open], [blk]) : $.enabled ? run([blk], txt + "") : txt + "";
|
|
16241
|
-
};
|
|
16242
|
-
}
|
|
16243
|
-
var kleur_default = $;
|
|
16244
|
-
|
|
16245
|
-
// lib/shared/handle-registry-auth-error.ts
|
|
16652
|
+
import path11 from "node:path";
|
|
16246
16653
|
var AUTH_TOKEN_REGEX = /^\/\/npm\.tscircuit\.com\/:_authToken=(.+)$/m;
|
|
16247
16654
|
function isUnauthorizedError(error) {
|
|
16248
16655
|
const output = [
|
|
@@ -16263,9 +16670,9 @@ function isUnauthorizedError(error) {
|
|
|
16263
16670
|
return /\b(401|E401)\b/i.test(output) || /unauthorized/i.test(output);
|
|
16264
16671
|
}
|
|
16265
16672
|
function hasTsciAuthToken(npmrcPath) {
|
|
16266
|
-
if (!
|
|
16673
|
+
if (!fs9.existsSync(npmrcPath))
|
|
16267
16674
|
return false;
|
|
16268
|
-
const content =
|
|
16675
|
+
const content = fs9.readFileSync(npmrcPath, "utf-8");
|
|
16269
16676
|
return AUTH_TOKEN_REGEX.test(content);
|
|
16270
16677
|
}
|
|
16271
16678
|
function handleRegistryAuthError({
|
|
@@ -16275,8 +16682,8 @@ function handleRegistryAuthError({
|
|
|
16275
16682
|
if (!isUnauthorizedError(error))
|
|
16276
16683
|
return;
|
|
16277
16684
|
const npmrcPaths = [
|
|
16278
|
-
|
|
16279
|
-
|
|
16685
|
+
path11.join(projectDir, ".npmrc"),
|
|
16686
|
+
path11.join(os2.homedir(), ".npmrc")
|
|
16280
16687
|
];
|
|
16281
16688
|
const hasToken = npmrcPaths.some(hasTsciAuthToken);
|
|
16282
16689
|
if (hasToken) {
|
|
@@ -16299,13 +16706,13 @@ var getSessionToken = () => {
|
|
|
16299
16706
|
};
|
|
16300
16707
|
var getSessionTokenFromNpmrc = () => {
|
|
16301
16708
|
const npmrcPaths = [
|
|
16302
|
-
|
|
16303
|
-
|
|
16709
|
+
path12.join(process.cwd(), ".npmrc"),
|
|
16710
|
+
path12.join(os3.homedir(), ".npmrc")
|
|
16304
16711
|
];
|
|
16305
16712
|
for (const npmrcPath of npmrcPaths) {
|
|
16306
|
-
if (!
|
|
16713
|
+
if (!fs10.existsSync(npmrcPath))
|
|
16307
16714
|
continue;
|
|
16308
|
-
const content =
|
|
16715
|
+
const content = fs10.readFileSync(npmrcPath, "utf-8");
|
|
16309
16716
|
const match = content.match(AUTH_TOKEN_REGEX);
|
|
16310
16717
|
if (match?.[1]) {
|
|
16311
16718
|
return match[1].trim();
|
|
@@ -16343,7 +16750,7 @@ var getCircuitJsonToGltfOptions = ({
|
|
|
16343
16750
|
};
|
|
16344
16751
|
|
|
16345
16752
|
// cli/build/convert-model-urls-to-file-urls.ts
|
|
16346
|
-
import
|
|
16753
|
+
import path13 from "node:path";
|
|
16347
16754
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
16348
16755
|
var convertModelUrlsToFileUrls = (circuitJson) => {
|
|
16349
16756
|
const modelUrlKeys2 = [
|
|
@@ -16370,7 +16777,7 @@ var convertModelUrlsToFileUrls = (circuitJson) => {
|
|
|
16370
16777
|
if (value.startsWith("/") || value.match(/^[a-zA-Z]:\\/)) {
|
|
16371
16778
|
updated[key] = pathToFileURL3(value).href;
|
|
16372
16779
|
} else if (value.startsWith(".")) {
|
|
16373
|
-
updated[key] = pathToFileURL3(
|
|
16780
|
+
updated[key] = pathToFileURL3(path13.resolve(process.cwd(), value)).href;
|
|
16374
16781
|
}
|
|
16375
16782
|
}
|
|
16376
16783
|
}
|
|
@@ -16411,7 +16818,7 @@ var convertSvgToPngBuffer = async (svg) => {
|
|
|
16411
16818
|
// lib/shared/load-local-step-model-fs-map.ts
|
|
16412
16819
|
import { existsSync as existsSync2 } from "node:fs";
|
|
16413
16820
|
import { readFile } from "node:fs/promises";
|
|
16414
|
-
import
|
|
16821
|
+
import path14 from "node:path";
|
|
16415
16822
|
var isRemoteUrl = (value) => /^https?:\/\//i.test(value);
|
|
16416
16823
|
async function loadLocalStepModelFsMap(circuitJson) {
|
|
16417
16824
|
const fsMap = {};
|
|
@@ -16423,7 +16830,7 @@ async function loadLocalStepModelFsMap(circuitJson) {
|
|
|
16423
16830
|
continue;
|
|
16424
16831
|
if (isRemoteUrl(modelUrl) || fsMap[modelUrl])
|
|
16425
16832
|
continue;
|
|
16426
|
-
const localPath =
|
|
16833
|
+
const localPath = path14.resolve(process.cwd(), modelUrl);
|
|
16427
16834
|
if (!existsSync2(localPath))
|
|
16428
16835
|
continue;
|
|
16429
16836
|
fsMap[modelUrl] = await readFile(localPath, "utf-8");
|
|
@@ -16479,10 +16886,10 @@ var writeSimulationSvgAssetsFromCircuitJson = (circuitJson, outputDir, imageForm
|
|
|
16479
16886
|
if (!simulationSvgAssets)
|
|
16480
16887
|
return false;
|
|
16481
16888
|
if (imageFormats.simulationSvgs) {
|
|
16482
|
-
|
|
16889
|
+
fs11.writeFileSync(path15.join(outputDir, "simulation.svg"), simulationSvgAssets.simulationSvg, "utf-8");
|
|
16483
16890
|
}
|
|
16484
16891
|
if (imageFormats.simulationSchematicSvgs) {
|
|
16485
|
-
|
|
16892
|
+
fs11.writeFileSync(path15.join(outputDir, "simulation-schematic.svg"), simulationSvgAssets.schematicSimulationSvg, "utf-8");
|
|
16486
16893
|
}
|
|
16487
16894
|
return true;
|
|
16488
16895
|
};
|
|
@@ -16490,8 +16897,8 @@ var writeGlbFromCircuitJson = async (circuitJson, glbOutputPath) => {
|
|
|
16490
16897
|
const circuitJsonWithFileUrls = convertModelUrlsToFileUrls(circuitJson);
|
|
16491
16898
|
const glbBuffer = await convertCircuitJsonToGltf(circuitJsonWithFileUrls, getCircuitJsonToGltfOptions({ format: "glb" }));
|
|
16492
16899
|
const glbData = normalizeToUint8Array2(glbBuffer);
|
|
16493
|
-
|
|
16494
|
-
|
|
16900
|
+
fs11.mkdirSync(path15.dirname(glbOutputPath), { recursive: true });
|
|
16901
|
+
fs11.writeFileSync(glbOutputPath, Buffer.from(glbData));
|
|
16495
16902
|
};
|
|
16496
16903
|
var writeStepFromCircuitJson = async (circuitJson, stepOutputPath) => {
|
|
16497
16904
|
const stepContent = await circuitJsonToStep(circuitJson, {
|
|
@@ -16499,34 +16906,34 @@ var writeStepFromCircuitJson = async (circuitJson, stepOutputPath) => {
|
|
|
16499
16906
|
includeExternalMeshes: true,
|
|
16500
16907
|
fsMap: await loadLocalStepModelFsMap(circuitJson)
|
|
16501
16908
|
});
|
|
16502
|
-
|
|
16503
|
-
|
|
16909
|
+
fs11.mkdirSync(path15.dirname(stepOutputPath), { recursive: true });
|
|
16910
|
+
fs11.writeFileSync(stepOutputPath, stepContent);
|
|
16504
16911
|
};
|
|
16505
16912
|
var writeImageAssetsFromCircuitJson = async (circuitJson, options) => {
|
|
16506
16913
|
const { outputDir, imageFormats, pcbSnapshotSettings } = options;
|
|
16507
|
-
|
|
16914
|
+
fs11.mkdirSync(outputDir, { recursive: true });
|
|
16508
16915
|
if (imageFormats.pcbSvgs) {
|
|
16509
16916
|
const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson, pcbSnapshotSettings);
|
|
16510
|
-
|
|
16917
|
+
fs11.writeFileSync(path15.join(outputDir, "pcb.svg"), pcbSvg, "utf-8");
|
|
16511
16918
|
}
|
|
16512
16919
|
if (imageFormats.pcbPngs) {
|
|
16513
16920
|
const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson, pcbSnapshotSettings);
|
|
16514
|
-
|
|
16921
|
+
fs11.writeFileSync(path15.join(outputDir, "pcb.png"), await convertSvgToPngBuffer(pcbSvg));
|
|
16515
16922
|
}
|
|
16516
16923
|
if (imageFormats.schematicSvgs) {
|
|
16517
16924
|
const schematicSvg = convertCircuitJsonToSchematicSvg(circuitJson);
|
|
16518
|
-
|
|
16925
|
+
fs11.writeFileSync(path15.join(outputDir, "schematic.svg"), schematicSvg, "utf-8");
|
|
16519
16926
|
}
|
|
16520
16927
|
writeSimulationSvgAssetsFromCircuitJson(circuitJson, outputDir, imageFormats);
|
|
16521
16928
|
if (imageFormats.threeDPngs) {
|
|
16522
16929
|
const pngBuffer = await renderCircuitJsonTo3dPng(circuitJson);
|
|
16523
|
-
|
|
16930
|
+
fs11.writeFileSync(path15.join(outputDir, "3d.png"), Buffer.from(pngBuffer));
|
|
16524
16931
|
}
|
|
16525
16932
|
};
|
|
16526
16933
|
|
|
16527
16934
|
// cli/build/worker-build-handlers.ts
|
|
16528
16935
|
var loadCircuitJsonFromInputFile = (filePath) => {
|
|
16529
|
-
const parsed = JSON.parse(
|
|
16936
|
+
const parsed = JSON.parse(fs12.readFileSync(filePath, "utf-8"));
|
|
16530
16937
|
return Array.isArray(parsed) ? parsed : [];
|
|
16531
16938
|
};
|
|
16532
16939
|
var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath, previewOutputDir, projectDir, options, workerLog, workerStatus) => {
|
|
@@ -16535,7 +16942,7 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
16535
16942
|
const startedAt = options?.profile ? performance.now() : 0;
|
|
16536
16943
|
try {
|
|
16537
16944
|
process.chdir(projectDir);
|
|
16538
|
-
workerLog(`Generating circuit JSON for ${
|
|
16945
|
+
workerLog(`Generating circuit JSON for ${path16.relative(projectDir, filePath)}...`);
|
|
16539
16946
|
await registerStaticAssetLoaders();
|
|
16540
16947
|
const projectConfig = await loadRuntimeProjectConfig(projectDir);
|
|
16541
16948
|
const platformConfig = mergePlatformConfigs(projectConfig?.platformConfig, options?.platformConfig);
|
|
@@ -16546,13 +16953,17 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
16546
16953
|
filePath,
|
|
16547
16954
|
platformConfig: platformConfigWithCliDefaults,
|
|
16548
16955
|
injectedProps: options?.injectedProps,
|
|
16956
|
+
autorouterDiagnostics: options?.autorouterDiagnostics ? {
|
|
16957
|
+
...options.autorouterDiagnostics,
|
|
16958
|
+
log: (message) => workerLog(message)
|
|
16959
|
+
} : undefined,
|
|
16549
16960
|
onAsyncEffectStatus: (asyncEffectName) => {
|
|
16550
16961
|
workerStatus(`waiting on ${asyncEffectName}…`);
|
|
16551
16962
|
}
|
|
16552
16963
|
})).circuitJson;
|
|
16553
|
-
|
|
16554
|
-
|
|
16555
|
-
workerLog(`Circuit JSON written to ${
|
|
16964
|
+
fs12.mkdirSync(path16.dirname(outputPath), { recursive: true });
|
|
16965
|
+
fs12.writeFileSync(outputPath, JSON.stringify(circuitJson, null, 2));
|
|
16966
|
+
workerLog(`Circuit JSON written to ${path16.relative(projectDir, outputPath)}`);
|
|
16556
16967
|
const diagnostics = analyzeCircuitJson(circuitJson);
|
|
16557
16968
|
const filteredDiagnostics = filterDiagnosticsByDrcCategory({
|
|
16558
16969
|
errors: diagnostics.errors,
|
|
@@ -16582,7 +16993,7 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
16582
16993
|
let previewError;
|
|
16583
16994
|
if (glbOutputPath) {
|
|
16584
16995
|
try {
|
|
16585
|
-
workerLog(`Converting ${
|
|
16996
|
+
workerLog(`Converting ${path16.relative(projectDir, outputPath)} to GLB in same worker...`);
|
|
16586
16997
|
await writeGlbFromCircuitJson(circuitJson, glbOutputPath);
|
|
16587
16998
|
glbOk = true;
|
|
16588
16999
|
} catch (err) {
|
|
@@ -16593,7 +17004,7 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
16593
17004
|
}
|
|
16594
17005
|
if (stepOutputPath) {
|
|
16595
17006
|
try {
|
|
16596
|
-
workerLog(`Converting ${
|
|
17007
|
+
workerLog(`Converting ${path16.relative(projectDir, outputPath)} to STEP in same worker...`);
|
|
16597
17008
|
await writeStepFromCircuitJson(circuitJson, stepOutputPath);
|
|
16598
17009
|
stepOk = true;
|
|
16599
17010
|
} catch (err) {
|
|
@@ -16604,8 +17015,8 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
16604
17015
|
}
|
|
16605
17016
|
if (options?.generatePreviewAssets) {
|
|
16606
17017
|
try {
|
|
16607
|
-
const resolvedPreviewOutputDir = previewOutputDir ??
|
|
16608
|
-
workerLog(`Generating preview assets for ${
|
|
17018
|
+
const resolvedPreviewOutputDir = previewOutputDir ?? path16.dirname(outputPath);
|
|
17019
|
+
workerLog(`Generating preview assets for ${path16.relative(projectDir, resolvedPreviewOutputDir)} in same worker...`);
|
|
16609
17020
|
await writeImageAssetsFromCircuitJson(circuitJson, {
|
|
16610
17021
|
outputDir: resolvedPreviewOutputDir,
|
|
16611
17022
|
imageFormats: options?.imageFormats ?? DEFAULT_IMAGE_FORMAT_SELECTION,
|