@tscircuit/cli 0.1.1630 → 0.1.1632
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 +250 -140
- package/dist/cli/main.js +193 -59
- package/dist/cli/snapshot/snapshot.worker.js +133 -12
- package/dist/lib/index.js +24 -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(path11) {
|
|
5612
|
+
let input = path11;
|
|
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 [path11, query] = wsComponent.resourceName.split("?");
|
|
5856
|
+
wsComponent.path = path11 && path11 !== "/" ? path11 : undefined;
|
|
5857
5857
|
wsComponent.query = query;
|
|
5858
5858
|
wsComponent.resourceName = undefined;
|
|
5859
5859
|
}
|
|
@@ -11883,6 +11883,7 @@ var import_make_vfs = __toESM(require_dist(), 1);
|
|
|
11883
11883
|
// lib/shared/autorouter-diagnostics.ts
|
|
11884
11884
|
import fs2 from "node:fs";
|
|
11885
11885
|
import path2 from "node:path";
|
|
11886
|
+
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg";
|
|
11886
11887
|
|
|
11887
11888
|
// node_modules/kleur/index.mjs
|
|
11888
11889
|
var FORCE_COLOR;
|
|
@@ -11981,9 +11982,21 @@ function init(open, close) {
|
|
|
11981
11982
|
}
|
|
11982
11983
|
var kleur_default = $;
|
|
11983
11984
|
|
|
11985
|
+
// lib/shared/convert-svg-to-png.ts
|
|
11986
|
+
import { Resvg } from "@resvg/resvg-js";
|
|
11987
|
+
var convertSvgToPngBuffer = (svg) => {
|
|
11988
|
+
const resvg = new Resvg(svg, {
|
|
11989
|
+
fitTo: {
|
|
11990
|
+
mode: "original"
|
|
11991
|
+
}
|
|
11992
|
+
});
|
|
11993
|
+
return resvg.render().asPng();
|
|
11994
|
+
};
|
|
11995
|
+
|
|
11984
11996
|
// lib/shared/autorouter-diagnostics.ts
|
|
11985
11997
|
var DEFAULT_DEBUG_DIR = path2.join("dist", "autorouter-debug");
|
|
11986
11998
|
var PROGRESS_LOG_INTERVAL_MS = 1e4;
|
|
11999
|
+
var CIRCUIT_JSON_ID_PATTERN = /\b(?:source|pcb|schematic|subcircuit|cad|simulation)_[a-z0-9_]*_\d+\b/gi;
|
|
11987
12000
|
var parseAutorouterTimeout = (duration) => {
|
|
11988
12001
|
const trimmed = duration.trim();
|
|
11989
12002
|
const match = trimmed.match(/^(\d+(?:\.\d+)?)(ms|s|m)?$/);
|
|
@@ -12027,6 +12040,7 @@ class AutorouterDiagnostics {
|
|
|
12027
12040
|
traceCountBySubcircuit = new Map;
|
|
12028
12041
|
activePhase = null;
|
|
12029
12042
|
completedPhaseTraces = [];
|
|
12043
|
+
hasWrittenPlacementSnapshot = false;
|
|
12030
12044
|
summary = [];
|
|
12031
12045
|
rootCircuit;
|
|
12032
12046
|
constructor(options = {}) {
|
|
@@ -12059,7 +12073,6 @@ class AutorouterDiagnostics {
|
|
|
12059
12073
|
const phaseLabel = this.getPhaseLabel(this.activePhase);
|
|
12060
12074
|
const message = `Autorouter timeout after ${this.formatElapsed(elapsedMs)} in ${phaseLabel}.`;
|
|
12061
12075
|
this.log(kleur_default.red(message));
|
|
12062
|
-
this.log(`Wrote debug artifact: ${path2.relative(process.cwd(), artifactPath)}`);
|
|
12063
12076
|
throw new AutorouterPhaseTimeoutError(message, artifactPath);
|
|
12064
12077
|
}
|
|
12065
12078
|
finalize(circuitJson) {
|
|
@@ -12086,7 +12099,7 @@ class AutorouterDiagnostics {
|
|
|
12086
12099
|
const previousTraceCount = event.previousTraceCount ?? this.traceCountBySubcircuit.get(subcircuitId) ?? 0;
|
|
12087
12100
|
this.activePhase = {
|
|
12088
12101
|
subcircuitId,
|
|
12089
|
-
componentDisplayName: event.componentDisplayName ??
|
|
12102
|
+
componentDisplayName: event.componentDisplayName ?? "subcircuit",
|
|
12090
12103
|
routingPhaseIndex,
|
|
12091
12104
|
phaseOrdinal,
|
|
12092
12105
|
phaseCount: event.phaseCount,
|
|
@@ -12101,6 +12114,11 @@ class AutorouterDiagnostics {
|
|
|
12101
12114
|
hasLoggedStart: false,
|
|
12102
12115
|
longRunningLoggingStarted: false
|
|
12103
12116
|
};
|
|
12117
|
+
if (this.options.enabled && !this.hasWrittenPlacementSnapshot) {
|
|
12118
|
+
const placementCircuitJson = this.getCurrentCircuitJson().filter((element) => !this.isRouteElement(element));
|
|
12119
|
+
this.writePngSnapshot("placement-unrouted.png", placementCircuitJson);
|
|
12120
|
+
this.hasWrittenPlacementSnapshot = true;
|
|
12121
|
+
}
|
|
12104
12122
|
if (this.options.enabled) {
|
|
12105
12123
|
this.logPhaseStart(this.activePhase);
|
|
12106
12124
|
}
|
|
@@ -12163,6 +12181,9 @@ class AutorouterDiagnostics {
|
|
|
12163
12181
|
if (this.shouldDumpSuccessfulOutput(activePhase.routingPhaseIndex)) {
|
|
12164
12182
|
this.writeJson(this.getPhaseFileName(activePhase, "output.traces.json"), outputSrj?.traces ?? []);
|
|
12165
12183
|
}
|
|
12184
|
+
if (this.options.enabled) {
|
|
12185
|
+
this.writePngSnapshot(`phase-${activePhase.routingPhaseIndex}-routed.png`, this.getCircuitJsonWithCompletedPhaseTraces());
|
|
12186
|
+
}
|
|
12166
12187
|
if (this.activePhase === activePhase) {
|
|
12167
12188
|
this.activePhase = null;
|
|
12168
12189
|
}
|
|
@@ -12191,7 +12212,7 @@ class AutorouterDiagnostics {
|
|
|
12191
12212
|
if (!activePhase.hasLoggedStart) {
|
|
12192
12213
|
this.logPhaseStart(activePhase, "failed");
|
|
12193
12214
|
}
|
|
12194
|
-
this.log(` ${this.getPhaseLabel(activePhase)} error after ${this.formatElapsed(elapsedMs)}: ${error.message}`);
|
|
12215
|
+
this.log(` ${this.getPhaseLabel(activePhase)} error after ${this.formatElapsed(elapsedMs)}: ${this.formatUserFacingText(error.message)}`);
|
|
12195
12216
|
}
|
|
12196
12217
|
if (this.shouldDumpFailedInput(activePhase.routingPhaseIndex)) {
|
|
12197
12218
|
this.writeJson(this.getPhaseFileName(activePhase, "input.simple-route.json"), event.simpleRouteJson ?? activePhase.simpleRouteJson ?? {});
|
|
@@ -12267,7 +12288,7 @@ class AutorouterDiagnostics {
|
|
|
12267
12288
|
logPhaseStart(activePhase, reason) {
|
|
12268
12289
|
const reasonText = reason ? ` ${reason}` : "";
|
|
12269
12290
|
this.log([
|
|
12270
|
-
`Autorouting ${
|
|
12291
|
+
`Autorouting ${this.formatUserFacingText(activePhase.componentDisplayName)} ${this.getPhaseLabel(activePhase)}${reasonText} start:`,
|
|
12271
12292
|
`connections=${activePhase.connectionCount},`,
|
|
12272
12293
|
`obstacles=${activePhase.obstacleCount},`,
|
|
12273
12294
|
`previous_traces=${activePhase.previousTraceCount}`,
|
|
@@ -12322,8 +12343,54 @@ class AutorouterDiagnostics {
|
|
|
12322
12343
|
fs2.mkdirSync(debugDir, { recursive: true });
|
|
12323
12344
|
const filePath = path2.join(debugDir, fileName);
|
|
12324
12345
|
fs2.writeFileSync(filePath, JSON.stringify(value, null, 2));
|
|
12346
|
+
this.logArtifact(filePath);
|
|
12325
12347
|
return filePath;
|
|
12326
12348
|
}
|
|
12349
|
+
writePngSnapshot(fileName, circuitJson) {
|
|
12350
|
+
const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson);
|
|
12351
|
+
const png = convertSvgToPngBuffer(pcbSvg);
|
|
12352
|
+
const debugDir = path2.resolve(this.options.debugDir ?? DEFAULT_DEBUG_DIR);
|
|
12353
|
+
fs2.mkdirSync(debugDir, { recursive: true });
|
|
12354
|
+
const filePath = path2.join(debugDir, fileName);
|
|
12355
|
+
fs2.writeFileSync(filePath, png);
|
|
12356
|
+
this.logArtifact(filePath);
|
|
12357
|
+
}
|
|
12358
|
+
logArtifact(filePath) {
|
|
12359
|
+
this.log(`Wrote debug artifact: ${path2.relative(process.cwd(), filePath)}`);
|
|
12360
|
+
}
|
|
12361
|
+
getCircuitJsonWithCompletedPhaseTraces() {
|
|
12362
|
+
const circuitJson = [...this.getCurrentCircuitJson()];
|
|
12363
|
+
const elementIndexById = new Map;
|
|
12364
|
+
for (const [index, element] of circuitJson.entries()) {
|
|
12365
|
+
const id = this.getCircuitElementId(element);
|
|
12366
|
+
if (id)
|
|
12367
|
+
elementIndexById.set(id, index);
|
|
12368
|
+
}
|
|
12369
|
+
for (const trace of this.completedPhaseTraces) {
|
|
12370
|
+
if (!trace || typeof trace !== "object")
|
|
12371
|
+
continue;
|
|
12372
|
+
const element = trace;
|
|
12373
|
+
const id = this.getCircuitElementId(element);
|
|
12374
|
+
const existingIndex = id ? elementIndexById.get(id) : undefined;
|
|
12375
|
+
if (existingIndex === undefined) {
|
|
12376
|
+
circuitJson.push(element);
|
|
12377
|
+
if (id)
|
|
12378
|
+
elementIndexById.set(id, circuitJson.length - 1);
|
|
12379
|
+
} else {
|
|
12380
|
+
circuitJson[existingIndex] = element;
|
|
12381
|
+
}
|
|
12382
|
+
}
|
|
12383
|
+
return circuitJson;
|
|
12384
|
+
}
|
|
12385
|
+
getCircuitElementId(element) {
|
|
12386
|
+
if (typeof element.type !== "string")
|
|
12387
|
+
return;
|
|
12388
|
+
const id = element[`${element.type}_id`];
|
|
12389
|
+
return typeof id === "string" ? id : undefined;
|
|
12390
|
+
}
|
|
12391
|
+
isRouteElement(element) {
|
|
12392
|
+
return element.type === "pcb_trace" || element.type === "pcb_via";
|
|
12393
|
+
}
|
|
12327
12394
|
getPhaseFileName(activePhase, suffix) {
|
|
12328
12395
|
const phaseNumber = activePhase.routingPhaseIndex;
|
|
12329
12396
|
return `phase-${phaseNumber}.${suffix}`;
|
|
@@ -12348,10 +12415,61 @@ class AutorouterDiagnostics {
|
|
|
12348
12415
|
return parts.join(", ");
|
|
12349
12416
|
}
|
|
12350
12417
|
getConnectionNames(simpleRouteJson) {
|
|
12351
|
-
return
|
|
12352
|
-
|
|
12353
|
-
|
|
12354
|
-
|
|
12418
|
+
return [
|
|
12419
|
+
...new Set((simpleRouteJson?.connections ?? []).map((connection) => [
|
|
12420
|
+
connection.rootConnectionName,
|
|
12421
|
+
connection.name,
|
|
12422
|
+
connection.source_trace_id
|
|
12423
|
+
].filter((value) => typeof value === "string").map((value) => this.resolveCircuitJsonId(value)).find((value) => value !== null)).filter((name) => name !== null))
|
|
12424
|
+
];
|
|
12425
|
+
}
|
|
12426
|
+
resolveCircuitJsonId(value) {
|
|
12427
|
+
const circuitJson = this.getCurrentCircuitJson();
|
|
12428
|
+
const element = circuitJson.find((candidate) => Object.entries(candidate).some(([key, candidateValue]) => key.endsWith("_id") && candidateValue === value));
|
|
12429
|
+
if (!element)
|
|
12430
|
+
return value;
|
|
12431
|
+
if (element.type === "source_trace") {
|
|
12432
|
+
if (typeof element.name === "string")
|
|
12433
|
+
return element.name;
|
|
12434
|
+
return this.getTraceSelector(element, circuitJson);
|
|
12435
|
+
}
|
|
12436
|
+
if (element.type === "source_net" && typeof element.name === "string") {
|
|
12437
|
+
return `net.${element.name}`;
|
|
12438
|
+
}
|
|
12439
|
+
if (element.type === "source_port") {
|
|
12440
|
+
return this.getPortSelector(element, circuitJson);
|
|
12441
|
+
}
|
|
12442
|
+
return null;
|
|
12443
|
+
}
|
|
12444
|
+
formatUserFacingText(value) {
|
|
12445
|
+
let formattedValue = value;
|
|
12446
|
+
for (const element of this.getCurrentCircuitJson()) {
|
|
12447
|
+
for (const [key, id] of Object.entries(element)) {
|
|
12448
|
+
if (!key.endsWith("_id") || typeof id !== "string")
|
|
12449
|
+
continue;
|
|
12450
|
+
formattedValue = formattedValue.replaceAll(id, this.resolveCircuitJsonId(id) ?? "internal element");
|
|
12451
|
+
}
|
|
12452
|
+
}
|
|
12453
|
+
return formattedValue.replace(CIRCUIT_JSON_ID_PATTERN, "internal element");
|
|
12454
|
+
}
|
|
12455
|
+
getTraceSelector(trace, circuitJson) {
|
|
12456
|
+
const portIds = trace.connected_source_port_ids;
|
|
12457
|
+
if (!Array.isArray(portIds))
|
|
12458
|
+
return null;
|
|
12459
|
+
const selectors = portIds.map((portId) => typeof portId === "string" ? this.getPortSelectorById(portId, circuitJson) : null).filter((selector) => selector !== null);
|
|
12460
|
+
return selectors.length >= 2 ? selectors.join(" to ") : null;
|
|
12461
|
+
}
|
|
12462
|
+
getPortSelectorById(sourcePortId, circuitJson) {
|
|
12463
|
+
const port = circuitJson.find((element) => element.type === "source_port" && element.source_port_id === sourcePortId);
|
|
12464
|
+
return port ? this.getPortSelector(port, circuitJson) : null;
|
|
12465
|
+
}
|
|
12466
|
+
getPortSelector(port, circuitJson) {
|
|
12467
|
+
const portName = typeof port.most_frequently_referenced_by_name === "string" ? port.most_frequently_referenced_by_name : typeof port.name === "string" ? port.name : null;
|
|
12468
|
+
if (!portName)
|
|
12469
|
+
return null;
|
|
12470
|
+
const component = circuitJson.find((element) => element.type === "source_component" && element.source_component_id === port.source_component_id);
|
|
12471
|
+
const componentName = component && typeof component.name === "string" ? component.name : null;
|
|
12472
|
+
return componentName ? `${componentName}.${portName}` : portName;
|
|
12355
12473
|
}
|
|
12356
12474
|
countErrors(simpleRouteJson) {
|
|
12357
12475
|
const errors = simpleRouteJson?.errors;
|
|
@@ -12359,7 +12477,8 @@ class AutorouterDiagnostics {
|
|
|
12359
12477
|
}
|
|
12360
12478
|
getCurrentCircuitJson() {
|
|
12361
12479
|
try {
|
|
12362
|
-
|
|
12480
|
+
const circuitJson = this.rootCircuit?.db?.toArray?.();
|
|
12481
|
+
return Array.isArray(circuitJson) ? circuitJson : [];
|
|
12363
12482
|
} catch {
|
|
12364
12483
|
return [];
|
|
12365
12484
|
}
|
|
@@ -12602,7 +12721,7 @@ async function generateCircuitJson({
|
|
|
12602
12721
|
}
|
|
12603
12722
|
runner.emit("renderComplete");
|
|
12604
12723
|
const circuitJson = await runner.getCircuitJson();
|
|
12605
|
-
autorouterDiagnostics.finalize(circuitJson);
|
|
12724
|
+
await autorouterDiagnostics.finalize(circuitJson);
|
|
12606
12725
|
if (saveToFile) {
|
|
12607
12726
|
debug(`Saving circuit JSON to ${outputPath}`);
|
|
12608
12727
|
fs5.writeFileSync(outputPath, JSON.stringify(circuitJson, null, 2));
|
|
@@ -13073,6 +13192,9 @@ var renderCircuitJsonTo3dPng = async (circuitJson, options = {}) => {
|
|
|
13073
13192
|
return renderGLTFToPNGFromGLB(glbArrayBuffer, getRenderCamera(circuitJson, defaultCamera, options));
|
|
13074
13193
|
};
|
|
13075
13194
|
|
|
13195
|
+
// cli/build/worker-output-generators.ts
|
|
13196
|
+
import { convertCircuitJsonToGltf } from "circuit-json-to-gltf";
|
|
13197
|
+
|
|
13076
13198
|
// node_modules/circuit-json-to-step/node_modules/stepts/dist/index.js
|
|
13077
13199
|
var Entity = class {
|
|
13078
13200
|
static parse(_a, _ctx) {
|
|
@@ -15359,17 +15481,78 @@ async function circuitJsonToStep(circuitJson, options = {}) {
|
|
|
15359
15481
|
}
|
|
15360
15482
|
|
|
15361
15483
|
// cli/build/worker-output-generators.ts
|
|
15362
|
-
import { convertCircuitJsonToGltf } from "circuit-json-to-gltf";
|
|
15363
15484
|
import {
|
|
15364
|
-
convertCircuitJsonToPcbSvg,
|
|
15485
|
+
convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg2,
|
|
15365
15486
|
convertCircuitJsonToSchematicSvg
|
|
15366
15487
|
} from "circuit-to-svg";
|
|
15367
15488
|
|
|
15489
|
+
// lib/shared/load-local-step-model-fs-map.ts
|
|
15490
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
15491
|
+
import { readFile } from "node:fs/promises";
|
|
15492
|
+
import path7 from "node:path";
|
|
15493
|
+
var isRemoteUrl = (value) => /^https?:\/\//i.test(value);
|
|
15494
|
+
async function loadLocalStepModelFsMap(circuitJson) {
|
|
15495
|
+
const fsMap = {};
|
|
15496
|
+
for (const element of circuitJson) {
|
|
15497
|
+
if (!element || typeof element !== "object")
|
|
15498
|
+
continue;
|
|
15499
|
+
const modelUrl = element.model_step_url;
|
|
15500
|
+
if (typeof modelUrl !== "string" || modelUrl.length === 0)
|
|
15501
|
+
continue;
|
|
15502
|
+
if (isRemoteUrl(modelUrl) || fsMap[modelUrl])
|
|
15503
|
+
continue;
|
|
15504
|
+
const localPath = path7.resolve(process.cwd(), modelUrl);
|
|
15505
|
+
if (!existsSync2(localPath))
|
|
15506
|
+
continue;
|
|
15507
|
+
fsMap[modelUrl] = await readFile(localPath, "utf-8");
|
|
15508
|
+
}
|
|
15509
|
+
return fsMap;
|
|
15510
|
+
}
|
|
15511
|
+
|
|
15512
|
+
// lib/shared/simulation-svg-assets.ts
|
|
15513
|
+
import {
|
|
15514
|
+
convertCircuitJsonToSchematicSimulationSvg,
|
|
15515
|
+
convertCircuitJsonToSimulationGraphSvg,
|
|
15516
|
+
isSimulationExperiment,
|
|
15517
|
+
isSimulationTransientVoltageGraph
|
|
15518
|
+
} from "circuit-to-svg";
|
|
15519
|
+
var isSimulationTransientCurrentGraph = (element) => element.type === "simulation_transient_current_graph";
|
|
15520
|
+
var getSimulationSvgInputs = (circuitJson) => {
|
|
15521
|
+
const simulationExperiment = circuitJson.find(isSimulationExperiment);
|
|
15522
|
+
if (!simulationExperiment)
|
|
15523
|
+
return;
|
|
15524
|
+
const simulationTransientCurrentGraphIds = circuitJson.filter((element) => isSimulationTransientCurrentGraph(element) && element.simulation_experiment_id === simulationExperiment.simulation_experiment_id).map((element) => element.simulation_transient_current_graph_id);
|
|
15525
|
+
const simulationTransientVoltageGraphIds = circuitJson.filter((element) => isSimulationTransientVoltageGraph(element) && element.simulation_experiment_id === simulationExperiment.simulation_experiment_id).map((element) => element.simulation_transient_voltage_graph_id);
|
|
15526
|
+
if (simulationTransientCurrentGraphIds.length === 0 && simulationTransientVoltageGraphIds.length === 0) {
|
|
15527
|
+
return;
|
|
15528
|
+
}
|
|
15529
|
+
return {
|
|
15530
|
+
simulation_experiment_id: simulationExperiment.simulation_experiment_id,
|
|
15531
|
+
simulation_transient_current_graph_ids: simulationTransientCurrentGraphIds,
|
|
15532
|
+
simulation_transient_voltage_graph_ids: simulationTransientVoltageGraphIds
|
|
15533
|
+
};
|
|
15534
|
+
};
|
|
15535
|
+
var getSimulationSvgAssetsFromCircuitJson = (circuitJson) => {
|
|
15536
|
+
const simulationSvgInputs = getSimulationSvgInputs(circuitJson);
|
|
15537
|
+
if (!simulationSvgInputs)
|
|
15538
|
+
return;
|
|
15539
|
+
return {
|
|
15540
|
+
simulationSvg: convertCircuitJsonToSimulationGraphSvg({
|
|
15541
|
+
circuitJson,
|
|
15542
|
+
...simulationSvgInputs
|
|
15543
|
+
}),
|
|
15544
|
+
schematicSimulationSvg: convertCircuitJsonToSchematicSimulationSvg({
|
|
15545
|
+
circuitJson,
|
|
15546
|
+
...simulationSvgInputs
|
|
15547
|
+
})
|
|
15548
|
+
};
|
|
15549
|
+
};
|
|
15550
|
+
|
|
15368
15551
|
// node_modules/conf/dist/source/index.js
|
|
15369
15552
|
import { isDeepStrictEqual } from "node:util";
|
|
15370
15553
|
import process7 from "node:process";
|
|
15371
15554
|
import fs8 from "node:fs";
|
|
15372
|
-
import
|
|
15555
|
+
import path11 from "node:path";
|
|
15373
15556
|
import crypto from "node:crypto";
|
|
15374
15557
|
import assert from "node:assert";
|
|
15375
15558
|
|
|
@@ -15384,12 +15567,12 @@ var disallowedKeys = new Set([
|
|
|
15384
15567
|
"constructor"
|
|
15385
15568
|
]);
|
|
15386
15569
|
var digits = new Set("0123456789");
|
|
15387
|
-
function getPathSegments(
|
|
15570
|
+
function getPathSegments(path8) {
|
|
15388
15571
|
const parts = [];
|
|
15389
15572
|
let currentSegment = "";
|
|
15390
15573
|
let currentPart = "start";
|
|
15391
15574
|
let isIgnoring = false;
|
|
15392
|
-
for (const character of
|
|
15575
|
+
for (const character of path8) {
|
|
15393
15576
|
switch (character) {
|
|
15394
15577
|
case "\\": {
|
|
15395
15578
|
if (currentPart === "index") {
|
|
@@ -15511,11 +15694,11 @@ function assertNotStringIndex(object, key) {
|
|
|
15511
15694
|
throw new Error("Cannot use string index");
|
|
15512
15695
|
}
|
|
15513
15696
|
}
|
|
15514
|
-
function getProperty(object,
|
|
15515
|
-
if (!isObject(object) || typeof
|
|
15697
|
+
function getProperty(object, path8, value) {
|
|
15698
|
+
if (!isObject(object) || typeof path8 !== "string") {
|
|
15516
15699
|
return value === undefined ? object : value;
|
|
15517
15700
|
}
|
|
15518
|
-
const pathArray = getPathSegments(
|
|
15701
|
+
const pathArray = getPathSegments(path8);
|
|
15519
15702
|
if (pathArray.length === 0) {
|
|
15520
15703
|
return value;
|
|
15521
15704
|
}
|
|
@@ -15535,12 +15718,12 @@ function getProperty(object, path7, value) {
|
|
|
15535
15718
|
}
|
|
15536
15719
|
return object === undefined ? value : object;
|
|
15537
15720
|
}
|
|
15538
|
-
function setProperty(object,
|
|
15539
|
-
if (!isObject(object) || typeof
|
|
15721
|
+
function setProperty(object, path8, value) {
|
|
15722
|
+
if (!isObject(object) || typeof path8 !== "string") {
|
|
15540
15723
|
return object;
|
|
15541
15724
|
}
|
|
15542
15725
|
const root = object;
|
|
15543
|
-
const pathArray = getPathSegments(
|
|
15726
|
+
const pathArray = getPathSegments(path8);
|
|
15544
15727
|
for (let index = 0;index < pathArray.length; index++) {
|
|
15545
15728
|
const key = pathArray[index];
|
|
15546
15729
|
assertNotStringIndex(object, key);
|
|
@@ -15553,11 +15736,11 @@ function setProperty(object, path7, value) {
|
|
|
15553
15736
|
}
|
|
15554
15737
|
return root;
|
|
15555
15738
|
}
|
|
15556
|
-
function deleteProperty(object,
|
|
15557
|
-
if (!isObject(object) || typeof
|
|
15739
|
+
function deleteProperty(object, path8) {
|
|
15740
|
+
if (!isObject(object) || typeof path8 !== "string") {
|
|
15558
15741
|
return false;
|
|
15559
15742
|
}
|
|
15560
|
-
const pathArray = getPathSegments(
|
|
15743
|
+
const pathArray = getPathSegments(path8);
|
|
15561
15744
|
for (let index = 0;index < pathArray.length; index++) {
|
|
15562
15745
|
const key = pathArray[index];
|
|
15563
15746
|
assertNotStringIndex(object, key);
|
|
@@ -15571,11 +15754,11 @@ function deleteProperty(object, path7) {
|
|
|
15571
15754
|
}
|
|
15572
15755
|
}
|
|
15573
15756
|
}
|
|
15574
|
-
function hasProperty(object,
|
|
15575
|
-
if (!isObject(object) || typeof
|
|
15757
|
+
function hasProperty(object, path8) {
|
|
15758
|
+
if (!isObject(object) || typeof path8 !== "string") {
|
|
15576
15759
|
return false;
|
|
15577
15760
|
}
|
|
15578
|
-
const pathArray = getPathSegments(
|
|
15761
|
+
const pathArray = getPathSegments(path8);
|
|
15579
15762
|
if (pathArray.length === 0) {
|
|
15580
15763
|
return false;
|
|
15581
15764
|
}
|
|
@@ -15589,41 +15772,41 @@ function hasProperty(object, path7) {
|
|
|
15589
15772
|
}
|
|
15590
15773
|
|
|
15591
15774
|
// node_modules/env-paths/index.js
|
|
15592
|
-
import
|
|
15775
|
+
import path8 from "node:path";
|
|
15593
15776
|
import os from "node:os";
|
|
15594
15777
|
import process2 from "node:process";
|
|
15595
15778
|
var homedir = os.homedir();
|
|
15596
15779
|
var tmpdir = os.tmpdir();
|
|
15597
15780
|
var { env } = process2;
|
|
15598
15781
|
var macos = (name) => {
|
|
15599
|
-
const library =
|
|
15782
|
+
const library = path8.join(homedir, "Library");
|
|
15600
15783
|
return {
|
|
15601
|
-
data:
|
|
15602
|
-
config:
|
|
15603
|
-
cache:
|
|
15604
|
-
log:
|
|
15605
|
-
temp:
|
|
15784
|
+
data: path8.join(library, "Application Support", name),
|
|
15785
|
+
config: path8.join(library, "Preferences", name),
|
|
15786
|
+
cache: path8.join(library, "Caches", name),
|
|
15787
|
+
log: path8.join(library, "Logs", name),
|
|
15788
|
+
temp: path8.join(tmpdir, name)
|
|
15606
15789
|
};
|
|
15607
15790
|
};
|
|
15608
15791
|
var windows = (name) => {
|
|
15609
|
-
const appData = env.APPDATA ||
|
|
15610
|
-
const localAppData = env.LOCALAPPDATA ||
|
|
15792
|
+
const appData = env.APPDATA || path8.join(homedir, "AppData", "Roaming");
|
|
15793
|
+
const localAppData = env.LOCALAPPDATA || path8.join(homedir, "AppData", "Local");
|
|
15611
15794
|
return {
|
|
15612
|
-
data:
|
|
15613
|
-
config:
|
|
15614
|
-
cache:
|
|
15615
|
-
log:
|
|
15616
|
-
temp:
|
|
15795
|
+
data: path8.join(localAppData, name, "Data"),
|
|
15796
|
+
config: path8.join(appData, name, "Config"),
|
|
15797
|
+
cache: path8.join(localAppData, name, "Cache"),
|
|
15798
|
+
log: path8.join(localAppData, name, "Log"),
|
|
15799
|
+
temp: path8.join(tmpdir, name)
|
|
15617
15800
|
};
|
|
15618
15801
|
};
|
|
15619
15802
|
var linux = (name) => {
|
|
15620
|
-
const username =
|
|
15803
|
+
const username = path8.basename(homedir);
|
|
15621
15804
|
return {
|
|
15622
|
-
data:
|
|
15623
|
-
config:
|
|
15624
|
-
cache:
|
|
15625
|
-
log:
|
|
15626
|
-
temp:
|
|
15805
|
+
data: path8.join(env.XDG_DATA_HOME || path8.join(homedir, ".local", "share"), name),
|
|
15806
|
+
config: path8.join(env.XDG_CONFIG_HOME || path8.join(homedir, ".config"), name),
|
|
15807
|
+
cache: path8.join(env.XDG_CACHE_HOME || path8.join(homedir, ".cache"), name),
|
|
15808
|
+
log: path8.join(env.XDG_STATE_HOME || path8.join(homedir, ".local", "state"), name),
|
|
15809
|
+
temp: path8.join(tmpdir, username, name)
|
|
15627
15810
|
};
|
|
15628
15811
|
};
|
|
15629
15812
|
function envPaths(name, { suffix = "nodejs" } = {}) {
|
|
@@ -15643,7 +15826,7 @@ function envPaths(name, { suffix = "nodejs" } = {}) {
|
|
|
15643
15826
|
}
|
|
15644
15827
|
|
|
15645
15828
|
// node_modules/atomically/dist/index.js
|
|
15646
|
-
import
|
|
15829
|
+
import path10 from "node:path";
|
|
15647
15830
|
|
|
15648
15831
|
// node_modules/stubborn-fs/dist/index.js
|
|
15649
15832
|
import fs7 from "node:fs";
|
|
@@ -15840,7 +16023,7 @@ var isUndefined = (value) => {
|
|
|
15840
16023
|
};
|
|
15841
16024
|
|
|
15842
16025
|
// node_modules/atomically/dist/utils/temp.js
|
|
15843
|
-
import
|
|
16026
|
+
import path9 from "node:path";
|
|
15844
16027
|
|
|
15845
16028
|
// node_modules/when-exit/dist/node/interceptor.js
|
|
15846
16029
|
import process6 from "node:process";
|
|
@@ -15940,7 +16123,7 @@ var Temp = {
|
|
|
15940
16123
|
}
|
|
15941
16124
|
},
|
|
15942
16125
|
truncate: (filePath) => {
|
|
15943
|
-
const basename =
|
|
16126
|
+
const basename = path9.basename(filePath);
|
|
15944
16127
|
if (basename.length <= LIMIT_BASENAME_LENGTH)
|
|
15945
16128
|
return filePath;
|
|
15946
16129
|
const truncable = /^(\.?)(.*?)((?:\.[^.]+)?(?:\.tmp-\d{10}[a-f0-9]{6})?)$/.exec(basename);
|
|
@@ -15982,7 +16165,7 @@ function writeFileSync2(filePath, data, options = DEFAULT_WRITE_OPTIONS) {
|
|
|
15982
16165
|
}
|
|
15983
16166
|
}
|
|
15984
16167
|
if (!filePathExists) {
|
|
15985
|
-
const parentPath =
|
|
16168
|
+
const parentPath = path10.dirname(filePath);
|
|
15986
16169
|
dist_default.attempt.mkdirSync(parentPath, {
|
|
15987
16170
|
mode: DEFAULT_FOLDER_MODE,
|
|
15988
16171
|
recursive: true
|
|
@@ -16298,7 +16481,7 @@ class Conf {
|
|
|
16298
16481
|
this.events = new EventTarget;
|
|
16299
16482
|
this.#encryptionKey = options.encryptionKey;
|
|
16300
16483
|
const fileExtension = options.fileExtension ? `.${options.fileExtension}` : "";
|
|
16301
|
-
this.path =
|
|
16484
|
+
this.path = path11.resolve(options.cwd, `${options.configName ?? "config"}${fileExtension}`);
|
|
16302
16485
|
const fileStore = this.store;
|
|
16303
16486
|
const store = Object.assign(createPlainObject(), options.defaults, fileStore);
|
|
16304
16487
|
if (options.migrations) {
|
|
@@ -16472,7 +16655,7 @@ class Conf {
|
|
|
16472
16655
|
throw new Error("Config schema violation: " + errors.join("; "));
|
|
16473
16656
|
}
|
|
16474
16657
|
_ensureDirectory() {
|
|
16475
|
-
fs8.mkdirSync(
|
|
16658
|
+
fs8.mkdirSync(path11.dirname(this.path), { recursive: true });
|
|
16476
16659
|
}
|
|
16477
16660
|
_write(value) {
|
|
16478
16661
|
let data = this._serialize(value);
|
|
@@ -16644,12 +16827,12 @@ function jwtDecode(token, options) {
|
|
|
16644
16827
|
// lib/cli-config/index.ts
|
|
16645
16828
|
import fs10 from "node:fs";
|
|
16646
16829
|
import os3 from "node:os";
|
|
16647
|
-
import
|
|
16830
|
+
import path13 from "node:path";
|
|
16648
16831
|
|
|
16649
16832
|
// lib/shared/handle-registry-auth-error.ts
|
|
16650
16833
|
import fs9 from "node:fs";
|
|
16651
16834
|
import os2 from "node:os";
|
|
16652
|
-
import
|
|
16835
|
+
import path12 from "node:path";
|
|
16653
16836
|
var AUTH_TOKEN_REGEX = /^\/\/npm\.tscircuit\.com\/:_authToken=(.+)$/m;
|
|
16654
16837
|
function isUnauthorizedError(error) {
|
|
16655
16838
|
const output = [
|
|
@@ -16682,8 +16865,8 @@ function handleRegistryAuthError({
|
|
|
16682
16865
|
if (!isUnauthorizedError(error))
|
|
16683
16866
|
return;
|
|
16684
16867
|
const npmrcPaths = [
|
|
16685
|
-
|
|
16686
|
-
|
|
16868
|
+
path12.join(projectDir, ".npmrc"),
|
|
16869
|
+
path12.join(os2.homedir(), ".npmrc")
|
|
16687
16870
|
];
|
|
16688
16871
|
const hasToken = npmrcPaths.some(hasTsciAuthToken);
|
|
16689
16872
|
if (hasToken) {
|
|
@@ -16706,8 +16889,8 @@ var getSessionToken = () => {
|
|
|
16706
16889
|
};
|
|
16707
16890
|
var getSessionTokenFromNpmrc = () => {
|
|
16708
16891
|
const npmrcPaths = [
|
|
16709
|
-
|
|
16710
|
-
|
|
16892
|
+
path13.join(process.cwd(), ".npmrc"),
|
|
16893
|
+
path13.join(os3.homedir(), ".npmrc")
|
|
16711
16894
|
];
|
|
16712
16895
|
for (const npmrcPath of npmrcPaths) {
|
|
16713
16896
|
if (!fs10.existsSync(npmrcPath))
|
|
@@ -16750,7 +16933,7 @@ var getCircuitJsonToGltfOptions = ({
|
|
|
16750
16933
|
};
|
|
16751
16934
|
|
|
16752
16935
|
// cli/build/convert-model-urls-to-file-urls.ts
|
|
16753
|
-
import
|
|
16936
|
+
import path14 from "node:path";
|
|
16754
16937
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
16755
16938
|
var convertModelUrlsToFileUrls = (circuitJson) => {
|
|
16756
16939
|
const modelUrlKeys2 = [
|
|
@@ -16777,7 +16960,7 @@ var convertModelUrlsToFileUrls = (circuitJson) => {
|
|
|
16777
16960
|
if (value.startsWith("/") || value.match(/^[a-zA-Z]:\\/)) {
|
|
16778
16961
|
updated[key] = pathToFileURL3(value).href;
|
|
16779
16962
|
} else if (value.startsWith(".")) {
|
|
16780
|
-
updated[key] = pathToFileURL3(
|
|
16963
|
+
updated[key] = pathToFileURL3(path14.resolve(process.cwd(), value)).href;
|
|
16781
16964
|
}
|
|
16782
16965
|
}
|
|
16783
16966
|
}
|
|
@@ -16804,79 +16987,6 @@ var normalizeToUint8Array2 = (value) => {
|
|
|
16804
16987
|
throw new Error("Expected Uint8Array, ArrayBuffer, or ArrayBufferView for binary data");
|
|
16805
16988
|
};
|
|
16806
16989
|
|
|
16807
|
-
// cli/build/svg-to-png.ts
|
|
16808
|
-
import { Resvg } from "@resvg/resvg-js";
|
|
16809
|
-
var convertSvgToPngBuffer = async (svg) => {
|
|
16810
|
-
const resvg = new Resvg(svg, {
|
|
16811
|
-
fitTo: {
|
|
16812
|
-
mode: "original"
|
|
16813
|
-
}
|
|
16814
|
-
});
|
|
16815
|
-
return resvg.render().asPng();
|
|
16816
|
-
};
|
|
16817
|
-
|
|
16818
|
-
// lib/shared/load-local-step-model-fs-map.ts
|
|
16819
|
-
import { existsSync as existsSync2 } from "node:fs";
|
|
16820
|
-
import { readFile } from "node:fs/promises";
|
|
16821
|
-
import path14 from "node:path";
|
|
16822
|
-
var isRemoteUrl = (value) => /^https?:\/\//i.test(value);
|
|
16823
|
-
async function loadLocalStepModelFsMap(circuitJson) {
|
|
16824
|
-
const fsMap = {};
|
|
16825
|
-
for (const element of circuitJson) {
|
|
16826
|
-
if (!element || typeof element !== "object")
|
|
16827
|
-
continue;
|
|
16828
|
-
const modelUrl = element.model_step_url;
|
|
16829
|
-
if (typeof modelUrl !== "string" || modelUrl.length === 0)
|
|
16830
|
-
continue;
|
|
16831
|
-
if (isRemoteUrl(modelUrl) || fsMap[modelUrl])
|
|
16832
|
-
continue;
|
|
16833
|
-
const localPath = path14.resolve(process.cwd(), modelUrl);
|
|
16834
|
-
if (!existsSync2(localPath))
|
|
16835
|
-
continue;
|
|
16836
|
-
fsMap[modelUrl] = await readFile(localPath, "utf-8");
|
|
16837
|
-
}
|
|
16838
|
-
return fsMap;
|
|
16839
|
-
}
|
|
16840
|
-
|
|
16841
|
-
// lib/shared/simulation-svg-assets.ts
|
|
16842
|
-
import {
|
|
16843
|
-
convertCircuitJsonToSchematicSimulationSvg,
|
|
16844
|
-
convertCircuitJsonToSimulationGraphSvg,
|
|
16845
|
-
isSimulationExperiment,
|
|
16846
|
-
isSimulationTransientVoltageGraph
|
|
16847
|
-
} from "circuit-to-svg";
|
|
16848
|
-
var isSimulationTransientCurrentGraph = (element) => element.type === "simulation_transient_current_graph";
|
|
16849
|
-
var getSimulationSvgInputs = (circuitJson) => {
|
|
16850
|
-
const simulationExperiment = circuitJson.find(isSimulationExperiment);
|
|
16851
|
-
if (!simulationExperiment)
|
|
16852
|
-
return;
|
|
16853
|
-
const simulationTransientCurrentGraphIds = circuitJson.filter((element) => isSimulationTransientCurrentGraph(element) && element.simulation_experiment_id === simulationExperiment.simulation_experiment_id).map((element) => element.simulation_transient_current_graph_id);
|
|
16854
|
-
const simulationTransientVoltageGraphIds = circuitJson.filter((element) => isSimulationTransientVoltageGraph(element) && element.simulation_experiment_id === simulationExperiment.simulation_experiment_id).map((element) => element.simulation_transient_voltage_graph_id);
|
|
16855
|
-
if (simulationTransientCurrentGraphIds.length === 0 && simulationTransientVoltageGraphIds.length === 0) {
|
|
16856
|
-
return;
|
|
16857
|
-
}
|
|
16858
|
-
return {
|
|
16859
|
-
simulation_experiment_id: simulationExperiment.simulation_experiment_id,
|
|
16860
|
-
simulation_transient_current_graph_ids: simulationTransientCurrentGraphIds,
|
|
16861
|
-
simulation_transient_voltage_graph_ids: simulationTransientVoltageGraphIds
|
|
16862
|
-
};
|
|
16863
|
-
};
|
|
16864
|
-
var getSimulationSvgAssetsFromCircuitJson = (circuitJson) => {
|
|
16865
|
-
const simulationSvgInputs = getSimulationSvgInputs(circuitJson);
|
|
16866
|
-
if (!simulationSvgInputs)
|
|
16867
|
-
return;
|
|
16868
|
-
return {
|
|
16869
|
-
simulationSvg: convertCircuitJsonToSimulationGraphSvg({
|
|
16870
|
-
circuitJson,
|
|
16871
|
-
...simulationSvgInputs
|
|
16872
|
-
}),
|
|
16873
|
-
schematicSimulationSvg: convertCircuitJsonToSchematicSimulationSvg({
|
|
16874
|
-
circuitJson,
|
|
16875
|
-
...simulationSvgInputs
|
|
16876
|
-
})
|
|
16877
|
-
};
|
|
16878
|
-
};
|
|
16879
|
-
|
|
16880
16990
|
// cli/build/worker-output-generators.ts
|
|
16881
16991
|
var writeSimulationSvgAssetsFromCircuitJson = (circuitJson, outputDir, imageFormats) => {
|
|
16882
16992
|
if (!imageFormats.simulationSvgs && !imageFormats.simulationSchematicSvgs) {
|
|
@@ -16913,11 +17023,11 @@ var writeImageAssetsFromCircuitJson = async (circuitJson, options) => {
|
|
|
16913
17023
|
const { outputDir, imageFormats, pcbSnapshotSettings } = options;
|
|
16914
17024
|
fs11.mkdirSync(outputDir, { recursive: true });
|
|
16915
17025
|
if (imageFormats.pcbSvgs) {
|
|
16916
|
-
const pcbSvg =
|
|
17026
|
+
const pcbSvg = convertCircuitJsonToPcbSvg2(circuitJson, pcbSnapshotSettings);
|
|
16917
17027
|
fs11.writeFileSync(path15.join(outputDir, "pcb.svg"), pcbSvg, "utf-8");
|
|
16918
17028
|
}
|
|
16919
17029
|
if (imageFormats.pcbPngs) {
|
|
16920
|
-
const pcbSvg =
|
|
17030
|
+
const pcbSvg = convertCircuitJsonToPcbSvg2(circuitJson, pcbSnapshotSettings);
|
|
16921
17031
|
fs11.writeFileSync(path15.join(outputDir, "pcb.png"), await convertSvgToPngBuffer(pcbSvg));
|
|
16922
17032
|
}
|
|
16923
17033
|
if (imageFormats.schematicSvgs) {
|