@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
package/dist/cli/main.js
CHANGED
|
@@ -39878,7 +39878,7 @@ __export2(exports_dist_3YR26ALR, {
|
|
|
39878
39878
|
convertCircuitJsonToSchematicSvg: () => convertCircuitJsonToSchematicSvg3,
|
|
39879
39879
|
convertCircuitJsonToSchematicSimulationSvg: () => convertCircuitJsonToSchematicSimulationSvg2,
|
|
39880
39880
|
convertCircuitJsonToPinoutSvg: () => convertCircuitJsonToPinoutSvg,
|
|
39881
|
-
convertCircuitJsonToPcbSvg: () =>
|
|
39881
|
+
convertCircuitJsonToPcbSvg: () => convertCircuitJsonToPcbSvg4,
|
|
39882
39882
|
convertCircuitJsonToAssemblySvg: () => convertCircuitJsonToAssemblySvg,
|
|
39883
39883
|
circuitJsonToSchematicSvg: () => circuitJsonToSchematicSvg,
|
|
39884
39884
|
circuitJsonToPcbSvg: () => circuitJsonToPcbSvg,
|
|
@@ -46226,7 +46226,7 @@ function getOutlineBounds(outline) {
|
|
|
46226
46226
|
return;
|
|
46227
46227
|
return { minX, minY, maxX, maxY };
|
|
46228
46228
|
}
|
|
46229
|
-
function
|
|
46229
|
+
function convertCircuitJsonToPcbSvg4(circuitJson, options) {
|
|
46230
46230
|
const drawPaddingOutsideBoard = options?.drawPaddingOutsideBoard ?? true;
|
|
46231
46231
|
const layer = options?.layer;
|
|
46232
46232
|
const colorOverrides = options?.colorOverrides;
|
|
@@ -52774,7 +52774,7 @@ var init_dist_3YR26ALR = __esm(() => {
|
|
|
52774
52774
|
pcb_component_outside_board_error: 80,
|
|
52775
52775
|
pcb_rats_nest: 85
|
|
52776
52776
|
};
|
|
52777
|
-
circuitJsonToPcbSvg =
|
|
52777
|
+
circuitJsonToPcbSvg = convertCircuitJsonToPcbSvg4;
|
|
52778
52778
|
DEFAULT_BOARD_STYLE = {
|
|
52779
52779
|
fill: "none",
|
|
52780
52780
|
stroke: "rgb(0,0,0)",
|
|
@@ -93628,7 +93628,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
|
|
|
93628
93628
|
// lib/getVersion.ts
|
|
93629
93629
|
import { createRequire as createRequire2 } from "node:module";
|
|
93630
93630
|
// package.json
|
|
93631
|
-
var version = "0.1.
|
|
93631
|
+
var version = "0.1.1631";
|
|
93632
93632
|
var package_default = {
|
|
93633
93633
|
name: "@tscircuit/cli",
|
|
93634
93634
|
version,
|
|
@@ -97762,8 +97762,23 @@ var saveProjectConfig = (config, projectDir = process.cwd()) => {
|
|
|
97762
97762
|
// lib/shared/autorouter-diagnostics.ts
|
|
97763
97763
|
import fs16 from "node:fs";
|
|
97764
97764
|
import path16 from "node:path";
|
|
97765
|
+
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg";
|
|
97766
|
+
|
|
97767
|
+
// lib/shared/convert-svg-to-png.ts
|
|
97768
|
+
import { Resvg } from "@resvg/resvg-js";
|
|
97769
|
+
var convertSvgToPngBuffer = (svg) => {
|
|
97770
|
+
const resvg = new Resvg(svg, {
|
|
97771
|
+
fitTo: {
|
|
97772
|
+
mode: "original"
|
|
97773
|
+
}
|
|
97774
|
+
});
|
|
97775
|
+
return resvg.render().asPng();
|
|
97776
|
+
};
|
|
97777
|
+
|
|
97778
|
+
// lib/shared/autorouter-diagnostics.ts
|
|
97765
97779
|
var DEFAULT_DEBUG_DIR = path16.join("dist", "autorouter-debug");
|
|
97766
97780
|
var PROGRESS_LOG_INTERVAL_MS = 1e4;
|
|
97781
|
+
var CIRCUIT_JSON_ID_PATTERN = /\b(?:source|pcb|schematic|subcircuit|cad|simulation)_[a-z0-9_]*_\d+\b/gi;
|
|
97767
97782
|
var parseAutorouterTimeout = (duration) => {
|
|
97768
97783
|
const trimmed = duration.trim();
|
|
97769
97784
|
const match = trimmed.match(/^(\d+(?:\.\d+)?)(ms|s|m)?$/);
|
|
@@ -97807,6 +97822,7 @@ class AutorouterDiagnostics {
|
|
|
97807
97822
|
traceCountBySubcircuit = new Map;
|
|
97808
97823
|
activePhase = null;
|
|
97809
97824
|
completedPhaseTraces = [];
|
|
97825
|
+
hasWrittenPlacementSnapshot = false;
|
|
97810
97826
|
summary = [];
|
|
97811
97827
|
rootCircuit;
|
|
97812
97828
|
constructor(options = {}) {
|
|
@@ -97839,7 +97855,6 @@ class AutorouterDiagnostics {
|
|
|
97839
97855
|
const phaseLabel = this.getPhaseLabel(this.activePhase);
|
|
97840
97856
|
const message = `Autorouter timeout after ${this.formatElapsed(elapsedMs)} in ${phaseLabel}.`;
|
|
97841
97857
|
this.log(kleur_default.red(message));
|
|
97842
|
-
this.log(`Wrote debug artifact: ${path16.relative(process.cwd(), artifactPath)}`);
|
|
97843
97858
|
throw new AutorouterPhaseTimeoutError(message, artifactPath);
|
|
97844
97859
|
}
|
|
97845
97860
|
finalize(circuitJson) {
|
|
@@ -97866,7 +97881,7 @@ class AutorouterDiagnostics {
|
|
|
97866
97881
|
const previousTraceCount = event.previousTraceCount ?? this.traceCountBySubcircuit.get(subcircuitId) ?? 0;
|
|
97867
97882
|
this.activePhase = {
|
|
97868
97883
|
subcircuitId,
|
|
97869
|
-
componentDisplayName: event.componentDisplayName ??
|
|
97884
|
+
componentDisplayName: event.componentDisplayName ?? "subcircuit",
|
|
97870
97885
|
routingPhaseIndex,
|
|
97871
97886
|
phaseOrdinal,
|
|
97872
97887
|
phaseCount: event.phaseCount,
|
|
@@ -97881,6 +97896,11 @@ class AutorouterDiagnostics {
|
|
|
97881
97896
|
hasLoggedStart: false,
|
|
97882
97897
|
longRunningLoggingStarted: false
|
|
97883
97898
|
};
|
|
97899
|
+
if (this.options.enabled && !this.hasWrittenPlacementSnapshot) {
|
|
97900
|
+
const placementCircuitJson = this.getCurrentCircuitJson().filter((element) => !this.isRouteElement(element));
|
|
97901
|
+
this.writePngSnapshot("placement-unrouted.png", placementCircuitJson);
|
|
97902
|
+
this.hasWrittenPlacementSnapshot = true;
|
|
97903
|
+
}
|
|
97884
97904
|
if (this.options.enabled) {
|
|
97885
97905
|
this.logPhaseStart(this.activePhase);
|
|
97886
97906
|
}
|
|
@@ -97943,6 +97963,9 @@ class AutorouterDiagnostics {
|
|
|
97943
97963
|
if (this.shouldDumpSuccessfulOutput(activePhase.routingPhaseIndex)) {
|
|
97944
97964
|
this.writeJson(this.getPhaseFileName(activePhase, "output.traces.json"), outputSrj?.traces ?? []);
|
|
97945
97965
|
}
|
|
97966
|
+
if (this.options.enabled) {
|
|
97967
|
+
this.writePngSnapshot(`phase-${activePhase.routingPhaseIndex}-routed.png`, this.getCircuitJsonWithCompletedPhaseTraces());
|
|
97968
|
+
}
|
|
97946
97969
|
if (this.activePhase === activePhase) {
|
|
97947
97970
|
this.activePhase = null;
|
|
97948
97971
|
}
|
|
@@ -97971,7 +97994,7 @@ class AutorouterDiagnostics {
|
|
|
97971
97994
|
if (!activePhase.hasLoggedStart) {
|
|
97972
97995
|
this.logPhaseStart(activePhase, "failed");
|
|
97973
97996
|
}
|
|
97974
|
-
this.log(` ${this.getPhaseLabel(activePhase)} error after ${this.formatElapsed(elapsedMs)}: ${error.message}`);
|
|
97997
|
+
this.log(` ${this.getPhaseLabel(activePhase)} error after ${this.formatElapsed(elapsedMs)}: ${this.formatUserFacingText(error.message)}`);
|
|
97975
97998
|
}
|
|
97976
97999
|
if (this.shouldDumpFailedInput(activePhase.routingPhaseIndex)) {
|
|
97977
98000
|
this.writeJson(this.getPhaseFileName(activePhase, "input.simple-route.json"), event.simpleRouteJson ?? activePhase.simpleRouteJson ?? {});
|
|
@@ -98047,7 +98070,7 @@ class AutorouterDiagnostics {
|
|
|
98047
98070
|
logPhaseStart(activePhase, reason) {
|
|
98048
98071
|
const reasonText = reason ? ` ${reason}` : "";
|
|
98049
98072
|
this.log([
|
|
98050
|
-
`Autorouting ${
|
|
98073
|
+
`Autorouting ${this.formatUserFacingText(activePhase.componentDisplayName)} ${this.getPhaseLabel(activePhase)}${reasonText} start:`,
|
|
98051
98074
|
`connections=${activePhase.connectionCount},`,
|
|
98052
98075
|
`obstacles=${activePhase.obstacleCount},`,
|
|
98053
98076
|
`previous_traces=${activePhase.previousTraceCount}`,
|
|
@@ -98102,8 +98125,54 @@ class AutorouterDiagnostics {
|
|
|
98102
98125
|
fs16.mkdirSync(debugDir, { recursive: true });
|
|
98103
98126
|
const filePath = path16.join(debugDir, fileName);
|
|
98104
98127
|
fs16.writeFileSync(filePath, JSON.stringify(value, null, 2));
|
|
98128
|
+
this.logArtifact(filePath);
|
|
98105
98129
|
return filePath;
|
|
98106
98130
|
}
|
|
98131
|
+
writePngSnapshot(fileName, circuitJson) {
|
|
98132
|
+
const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson);
|
|
98133
|
+
const png = convertSvgToPngBuffer(pcbSvg);
|
|
98134
|
+
const debugDir = path16.resolve(this.options.debugDir ?? DEFAULT_DEBUG_DIR);
|
|
98135
|
+
fs16.mkdirSync(debugDir, { recursive: true });
|
|
98136
|
+
const filePath = path16.join(debugDir, fileName);
|
|
98137
|
+
fs16.writeFileSync(filePath, png);
|
|
98138
|
+
this.logArtifact(filePath);
|
|
98139
|
+
}
|
|
98140
|
+
logArtifact(filePath) {
|
|
98141
|
+
this.log(`Wrote debug artifact: ${path16.relative(process.cwd(), filePath)}`);
|
|
98142
|
+
}
|
|
98143
|
+
getCircuitJsonWithCompletedPhaseTraces() {
|
|
98144
|
+
const circuitJson = [...this.getCurrentCircuitJson()];
|
|
98145
|
+
const elementIndexById = new Map;
|
|
98146
|
+
for (const [index, element] of circuitJson.entries()) {
|
|
98147
|
+
const id = this.getCircuitElementId(element);
|
|
98148
|
+
if (id)
|
|
98149
|
+
elementIndexById.set(id, index);
|
|
98150
|
+
}
|
|
98151
|
+
for (const trace of this.completedPhaseTraces) {
|
|
98152
|
+
if (!trace || typeof trace !== "object")
|
|
98153
|
+
continue;
|
|
98154
|
+
const element = trace;
|
|
98155
|
+
const id = this.getCircuitElementId(element);
|
|
98156
|
+
const existingIndex = id ? elementIndexById.get(id) : undefined;
|
|
98157
|
+
if (existingIndex === undefined) {
|
|
98158
|
+
circuitJson.push(element);
|
|
98159
|
+
if (id)
|
|
98160
|
+
elementIndexById.set(id, circuitJson.length - 1);
|
|
98161
|
+
} else {
|
|
98162
|
+
circuitJson[existingIndex] = element;
|
|
98163
|
+
}
|
|
98164
|
+
}
|
|
98165
|
+
return circuitJson;
|
|
98166
|
+
}
|
|
98167
|
+
getCircuitElementId(element) {
|
|
98168
|
+
if (typeof element.type !== "string")
|
|
98169
|
+
return;
|
|
98170
|
+
const id = element[`${element.type}_id`];
|
|
98171
|
+
return typeof id === "string" ? id : undefined;
|
|
98172
|
+
}
|
|
98173
|
+
isRouteElement(element) {
|
|
98174
|
+
return element.type === "pcb_trace" || element.type === "pcb_via";
|
|
98175
|
+
}
|
|
98107
98176
|
getPhaseFileName(activePhase, suffix) {
|
|
98108
98177
|
const phaseNumber = activePhase.routingPhaseIndex;
|
|
98109
98178
|
return `phase-${phaseNumber}.${suffix}`;
|
|
@@ -98128,10 +98197,61 @@ class AutorouterDiagnostics {
|
|
|
98128
98197
|
return parts.join(", ");
|
|
98129
98198
|
}
|
|
98130
98199
|
getConnectionNames(simpleRouteJson) {
|
|
98131
|
-
return
|
|
98132
|
-
|
|
98133
|
-
|
|
98134
|
-
|
|
98200
|
+
return [
|
|
98201
|
+
...new Set((simpleRouteJson?.connections ?? []).map((connection) => [
|
|
98202
|
+
connection.rootConnectionName,
|
|
98203
|
+
connection.name,
|
|
98204
|
+
connection.source_trace_id
|
|
98205
|
+
].filter((value) => typeof value === "string").map((value) => this.resolveCircuitJsonId(value)).find((value) => value !== null)).filter((name) => name !== null))
|
|
98206
|
+
];
|
|
98207
|
+
}
|
|
98208
|
+
resolveCircuitJsonId(value) {
|
|
98209
|
+
const circuitJson = this.getCurrentCircuitJson();
|
|
98210
|
+
const element = circuitJson.find((candidate) => Object.entries(candidate).some(([key, candidateValue]) => key.endsWith("_id") && candidateValue === value));
|
|
98211
|
+
if (!element)
|
|
98212
|
+
return value;
|
|
98213
|
+
if (element.type === "source_trace") {
|
|
98214
|
+
if (typeof element.name === "string")
|
|
98215
|
+
return element.name;
|
|
98216
|
+
return this.getTraceSelector(element, circuitJson);
|
|
98217
|
+
}
|
|
98218
|
+
if (element.type === "source_net" && typeof element.name === "string") {
|
|
98219
|
+
return `net.${element.name}`;
|
|
98220
|
+
}
|
|
98221
|
+
if (element.type === "source_port") {
|
|
98222
|
+
return this.getPortSelector(element, circuitJson);
|
|
98223
|
+
}
|
|
98224
|
+
return null;
|
|
98225
|
+
}
|
|
98226
|
+
formatUserFacingText(value) {
|
|
98227
|
+
let formattedValue = value;
|
|
98228
|
+
for (const element of this.getCurrentCircuitJson()) {
|
|
98229
|
+
for (const [key, id] of Object.entries(element)) {
|
|
98230
|
+
if (!key.endsWith("_id") || typeof id !== "string")
|
|
98231
|
+
continue;
|
|
98232
|
+
formattedValue = formattedValue.replaceAll(id, this.resolveCircuitJsonId(id) ?? "internal element");
|
|
98233
|
+
}
|
|
98234
|
+
}
|
|
98235
|
+
return formattedValue.replace(CIRCUIT_JSON_ID_PATTERN, "internal element");
|
|
98236
|
+
}
|
|
98237
|
+
getTraceSelector(trace, circuitJson) {
|
|
98238
|
+
const portIds = trace.connected_source_port_ids;
|
|
98239
|
+
if (!Array.isArray(portIds))
|
|
98240
|
+
return null;
|
|
98241
|
+
const selectors = portIds.map((portId) => typeof portId === "string" ? this.getPortSelectorById(portId, circuitJson) : null).filter((selector) => selector !== null);
|
|
98242
|
+
return selectors.length >= 2 ? selectors.join(" to ") : null;
|
|
98243
|
+
}
|
|
98244
|
+
getPortSelectorById(sourcePortId, circuitJson) {
|
|
98245
|
+
const port = circuitJson.find((element) => element.type === "source_port" && element.source_port_id === sourcePortId);
|
|
98246
|
+
return port ? this.getPortSelector(port, circuitJson) : null;
|
|
98247
|
+
}
|
|
98248
|
+
getPortSelector(port, circuitJson) {
|
|
98249
|
+
const portName = typeof port.most_frequently_referenced_by_name === "string" ? port.most_frequently_referenced_by_name : typeof port.name === "string" ? port.name : null;
|
|
98250
|
+
if (!portName)
|
|
98251
|
+
return null;
|
|
98252
|
+
const component = circuitJson.find((element) => element.type === "source_component" && element.source_component_id === port.source_component_id);
|
|
98253
|
+
const componentName = component && typeof component.name === "string" ? component.name : null;
|
|
98254
|
+
return componentName ? `${componentName}.${portName}` : portName;
|
|
98135
98255
|
}
|
|
98136
98256
|
countErrors(simpleRouteJson) {
|
|
98137
98257
|
const errors = simpleRouteJson?.errors;
|
|
@@ -98139,7 +98259,8 @@ class AutorouterDiagnostics {
|
|
|
98139
98259
|
}
|
|
98140
98260
|
getCurrentCircuitJson() {
|
|
98141
98261
|
try {
|
|
98142
|
-
|
|
98262
|
+
const circuitJson = this.rootCircuit?.db?.toArray?.();
|
|
98263
|
+
return Array.isArray(circuitJson) ? circuitJson : [];
|
|
98143
98264
|
} catch {
|
|
98144
98265
|
return [];
|
|
98145
98266
|
}
|
|
@@ -105398,7 +105519,7 @@ async function generateCircuitJson({
|
|
|
105398
105519
|
}
|
|
105399
105520
|
runner.emit("renderComplete");
|
|
105400
105521
|
const circuitJson = await runner.getCircuitJson();
|
|
105401
|
-
autorouterDiagnostics.finalize(circuitJson);
|
|
105522
|
+
await autorouterDiagnostics.finalize(circuitJson);
|
|
105402
105523
|
if (saveToFile) {
|
|
105403
105524
|
debug(`Saving circuit JSON to ${outputPath}`);
|
|
105404
105525
|
fs25.writeFileSync(outputPath, JSON.stringify(circuitJson, null, 2));
|
|
@@ -106104,6 +106225,9 @@ var renderCircuitJsonTo3dPng = async (circuitJson, options = {}) => {
|
|
|
106104
106225
|
return renderGLTFToPNGFromGLB(glbArrayBuffer, getRenderCamera(circuitJson, defaultCamera, options));
|
|
106105
106226
|
};
|
|
106106
106227
|
|
|
106228
|
+
// cli/build/worker-output-generators.ts
|
|
106229
|
+
import { convertCircuitJsonToGltf as convertCircuitJsonToGltf2 } from "circuit-json-to-gltf";
|
|
106230
|
+
|
|
106107
106231
|
// node_modules/circuit-json-to-step/node_modules/stepts/dist/index.js
|
|
106108
106232
|
var Entity = class {
|
|
106109
106233
|
static parse(_a, _ctx) {
|
|
@@ -108390,42 +108514,11 @@ async function circuitJsonToStep(circuitJson, options = {}) {
|
|
|
108390
108514
|
}
|
|
108391
108515
|
|
|
108392
108516
|
// cli/build/worker-output-generators.ts
|
|
108393
|
-
import { convertCircuitJsonToGltf as convertCircuitJsonToGltf2 } from "circuit-json-to-gltf";
|
|
108394
108517
|
import {
|
|
108395
|
-
convertCircuitJsonToPcbSvg,
|
|
108518
|
+
convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg2,
|
|
108396
108519
|
convertCircuitJsonToSchematicSvg
|
|
108397
108520
|
} from "circuit-to-svg";
|
|
108398
108521
|
|
|
108399
|
-
// cli/build/worker-binary-utils.ts
|
|
108400
|
-
var viewToArrayBuffer3 = (view) => {
|
|
108401
|
-
const copy = new Uint8Array(view.byteLength);
|
|
108402
|
-
copy.set(new Uint8Array(view.buffer, view.byteOffset, view.byteLength));
|
|
108403
|
-
return copy.buffer;
|
|
108404
|
-
};
|
|
108405
|
-
var normalizeToUint8Array3 = (value) => {
|
|
108406
|
-
if (value instanceof Uint8Array) {
|
|
108407
|
-
return value;
|
|
108408
|
-
}
|
|
108409
|
-
if (value instanceof ArrayBuffer) {
|
|
108410
|
-
return new Uint8Array(value);
|
|
108411
|
-
}
|
|
108412
|
-
if (ArrayBuffer.isView(value)) {
|
|
108413
|
-
return new Uint8Array(viewToArrayBuffer3(value));
|
|
108414
|
-
}
|
|
108415
|
-
throw new Error("Expected Uint8Array, ArrayBuffer, or ArrayBufferView for binary data");
|
|
108416
|
-
};
|
|
108417
|
-
|
|
108418
|
-
// cli/build/svg-to-png.ts
|
|
108419
|
-
import { Resvg } from "@resvg/resvg-js";
|
|
108420
|
-
var convertSvgToPngBuffer = async (svg) => {
|
|
108421
|
-
const resvg = new Resvg(svg, {
|
|
108422
|
-
fitTo: {
|
|
108423
|
-
mode: "original"
|
|
108424
|
-
}
|
|
108425
|
-
});
|
|
108426
|
-
return resvg.render().asPng();
|
|
108427
|
-
};
|
|
108428
|
-
|
|
108429
108522
|
// lib/shared/load-local-step-model-fs-map.ts
|
|
108430
108523
|
import { existsSync as existsSync6 } from "node:fs";
|
|
108431
108524
|
import { readFile } from "node:fs/promises";
|
|
@@ -108488,6 +108581,25 @@ var getSimulationSvgAssetsFromCircuitJson = (circuitJson) => {
|
|
|
108488
108581
|
};
|
|
108489
108582
|
};
|
|
108490
108583
|
|
|
108584
|
+
// cli/build/worker-binary-utils.ts
|
|
108585
|
+
var viewToArrayBuffer3 = (view) => {
|
|
108586
|
+
const copy = new Uint8Array(view.byteLength);
|
|
108587
|
+
copy.set(new Uint8Array(view.buffer, view.byteOffset, view.byteLength));
|
|
108588
|
+
return copy.buffer;
|
|
108589
|
+
};
|
|
108590
|
+
var normalizeToUint8Array3 = (value) => {
|
|
108591
|
+
if (value instanceof Uint8Array) {
|
|
108592
|
+
return value;
|
|
108593
|
+
}
|
|
108594
|
+
if (value instanceof ArrayBuffer) {
|
|
108595
|
+
return new Uint8Array(value);
|
|
108596
|
+
}
|
|
108597
|
+
if (ArrayBuffer.isView(value)) {
|
|
108598
|
+
return new Uint8Array(viewToArrayBuffer3(value));
|
|
108599
|
+
}
|
|
108600
|
+
throw new Error("Expected Uint8Array, ArrayBuffer, or ArrayBufferView for binary data");
|
|
108601
|
+
};
|
|
108602
|
+
|
|
108491
108603
|
// cli/build/worker-output-generators.ts
|
|
108492
108604
|
var writeSimulationSvgAssetsFromCircuitJson = (circuitJson, outputDir, imageFormats) => {
|
|
108493
108605
|
if (!imageFormats.simulationSvgs && !imageFormats.simulationSchematicSvgs) {
|
|
@@ -108524,11 +108636,11 @@ var writeImageAssetsFromCircuitJson = async (circuitJson, options) => {
|
|
|
108524
108636
|
const { outputDir, imageFormats, pcbSnapshotSettings } = options;
|
|
108525
108637
|
fs30.mkdirSync(outputDir, { recursive: true });
|
|
108526
108638
|
if (imageFormats.pcbSvgs) {
|
|
108527
|
-
const pcbSvg =
|
|
108639
|
+
const pcbSvg = convertCircuitJsonToPcbSvg2(circuitJson, pcbSnapshotSettings);
|
|
108528
108640
|
fs30.writeFileSync(path33.join(outputDir, "pcb.svg"), pcbSvg, "utf-8");
|
|
108529
108641
|
}
|
|
108530
108642
|
if (imageFormats.pcbPngs) {
|
|
108531
|
-
const pcbSvg =
|
|
108643
|
+
const pcbSvg = convertCircuitJsonToPcbSvg2(circuitJson, pcbSnapshotSettings);
|
|
108532
108644
|
fs30.writeFileSync(path33.join(outputDir, "pcb.png"), await convertSvgToPngBuffer(pcbSvg));
|
|
108533
108645
|
}
|
|
108534
108646
|
if (imageFormats.schematicSvgs) {
|
|
@@ -108627,7 +108739,7 @@ var buildPreviewGltf = async ({
|
|
|
108627
108739
|
import fs33 from "node:fs";
|
|
108628
108740
|
import path36 from "node:path";
|
|
108629
108741
|
import {
|
|
108630
|
-
convertCircuitJsonToPcbSvg as
|
|
108742
|
+
convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg3,
|
|
108631
108743
|
convertCircuitJsonToSchematicSvg as convertCircuitJsonToSchematicSvg2
|
|
108632
108744
|
} from "circuit-to-svg";
|
|
108633
108745
|
var generatePreviewAssets = async ({
|
|
@@ -108651,7 +108763,7 @@ var generatePreviewAssets = async ({
|
|
|
108651
108763
|
if (imageFormats.pcbSvgs) {
|
|
108652
108764
|
try {
|
|
108653
108765
|
console.log(`${prefix}Generating PCB SVG...`);
|
|
108654
|
-
const pcbSvg =
|
|
108766
|
+
const pcbSvg = convertCircuitJsonToPcbSvg3(circuitJson, pcbSnapshotSettings);
|
|
108655
108767
|
fs33.writeFileSync(path36.join(outputDir, "pcb.svg"), pcbSvg, "utf-8");
|
|
108656
108768
|
console.log(`${prefix}Written pcb.svg`);
|
|
108657
108769
|
} catch (error) {
|
|
@@ -108661,7 +108773,7 @@ var generatePreviewAssets = async ({
|
|
|
108661
108773
|
if (imageFormats.pcbPngs) {
|
|
108662
108774
|
try {
|
|
108663
108775
|
console.log(`${prefix}Generating PCB PNG...`);
|
|
108664
|
-
const pcbSvg =
|
|
108776
|
+
const pcbSvg = convertCircuitJsonToPcbSvg3(circuitJson, pcbSnapshotSettings);
|
|
108665
108777
|
fs33.writeFileSync(path36.join(outputDir, "pcb.png"), await convertSvgToPngBuffer(pcbSvg));
|
|
108666
108778
|
console.log(`${prefix}Written pcb.png`);
|
|
108667
108779
|
} catch (error) {
|
|
@@ -215125,9 +215237,9 @@ var addStartAndEndPortIdsIfMissing = (soup) => {
|
|
|
215125
215237
|
}
|
|
215126
215238
|
}
|
|
215127
215239
|
};
|
|
215128
|
-
var
|
|
215240
|
+
var CIRCUIT_JSON_ID_PATTERN2 = /\b(?:pcb|source|schematic|subcircuit)_[a-z0-9_]+\b/i;
|
|
215129
215241
|
var sanitizeReadableName = (candidate, id2, fallbackLabel) => {
|
|
215130
|
-
if (!candidate || candidate === id2 ||
|
|
215242
|
+
if (!candidate || candidate === id2 || CIRCUIT_JSON_ID_PATTERN2.test(candidate)) {
|
|
215131
215243
|
return fallbackLabel;
|
|
215132
215244
|
}
|
|
215133
215245
|
return candidate;
|
|
@@ -215164,7 +215276,7 @@ var getReadableNameForPort = (circuitJson, pcbPortId) => {
|
|
|
215164
215276
|
return sanitizeReadableName(getReadableNameForPcbPort(circuitJson, pcbPortId) ?? getReadableNameForElement(circuitJson, pcbPortId), pcbPortId, "port");
|
|
215165
215277
|
};
|
|
215166
215278
|
var getReadableNameForElementId = (circuitJson, elementId) => sanitizeReadableName(getReadableNameForElement(circuitJson, elementId), elementId, "element");
|
|
215167
|
-
var containsCircuitJsonId = (message) =>
|
|
215279
|
+
var containsCircuitJsonId = (message) => CIRCUIT_JSON_ID_PATTERN2.test(message);
|
|
215168
215280
|
function checkEachPcbPortConnectedToPcbTraces(circuitJson) {
|
|
215169
215281
|
addStartAndEndPortIdsIfMissing(circuitJson);
|
|
215170
215282
|
const sourceTraces = circuitJson.filter((item) => item.type === "source_trace");
|
|
@@ -264684,6 +264796,28 @@ Publish completed with ${uploadResults.succeeded.length} files uploaded and ${up
|
|
|
264684
264796
|
var debug13 = Debug3("tscircuit:devserver");
|
|
264685
264797
|
var BINARY_FILE_EXTENSIONS2 = new Set([".glb", ".png", ".jpeg", ".jpg"]);
|
|
264686
264798
|
var CONFIG_MODULE_FILENAMES2 = ["tscircuit.config.ts", "tscircuit.config.js"];
|
|
264799
|
+
var CIRCUIT_JSON_ID_PATTERN3 = /\b(?:source|pcb|schematic|subcircuit|cad|simulation)_[a-z0-9_]*_\d+\b/gi;
|
|
264800
|
+
var formatAutorouterDebugEvent = (event) => {
|
|
264801
|
+
const parts = [
|
|
264802
|
+
typeof event.componentDisplayName === "string" ? `component=${event.componentDisplayName}` : null,
|
|
264803
|
+
typeof event.phase === "string" ? `phase=${event.phase}` : null,
|
|
264804
|
+
typeof event.solverName === "string" ? `solver=${event.solverName}` : null,
|
|
264805
|
+
typeof event.connectionCount === "number" ? `connections=${event.connectionCount}` : null,
|
|
264806
|
+
typeof event.obstacleCount === "number" ? `obstacles=${event.obstacleCount}` : null,
|
|
264807
|
+
typeof event.steps === "number" ? `steps=${event.steps}` : null,
|
|
264808
|
+
typeof event.iteration === "number" ? `iteration=${event.iteration}` : null,
|
|
264809
|
+
typeof event.progress === "number" ? `progress=${Math.round(event.progress * 100)}%` : null,
|
|
264810
|
+
typeof event.iterationsPerSecond === "number" ? `iterations_per_second=${Math.round(event.iterationsPerSecond)}` : null,
|
|
264811
|
+
typeof event.elapsedMs === "number" ? `elapsed=${Math.round(event.elapsedMs)}ms` : null
|
|
264812
|
+
].filter((part) => part !== null);
|
|
264813
|
+
const error2 = event.error;
|
|
264814
|
+
const errorMessage = error2 && typeof error2 === "object" && "message" in error2 ? error2.message : typeof error2 === "string" ? error2 : null;
|
|
264815
|
+
if (typeof errorMessage === "string") {
|
|
264816
|
+
parts.push(`error=${errorMessage.replace(CIRCUIT_JSON_ID_PATTERN3, "internal element")}`);
|
|
264817
|
+
}
|
|
264818
|
+
const eventType = typeof event.event_type === "string" ? event.event_type : "autorouting";
|
|
264819
|
+
return `[autorouter] ${eventType}${parts.length > 0 ? ` ${parts.join(" ")}` : ""}`;
|
|
264820
|
+
};
|
|
264687
264821
|
|
|
264688
264822
|
class DevServer {
|
|
264689
264823
|
port;
|
|
@@ -264735,7 +264869,7 @@ class DevServer {
|
|
|
264735
264869
|
this.eventsWatcher.on("*", (event) => {
|
|
264736
264870
|
if (!String(event.event_type).startsWith("autorouting:"))
|
|
264737
264871
|
return;
|
|
264738
|
-
console.log(kleur_default.cyan(
|
|
264872
|
+
console.log(kleur_default.cyan(formatAutorouterDebugEvent(event)));
|
|
264739
264873
|
});
|
|
264740
264874
|
}
|
|
264741
264875
|
this.filesystemWatcher = watch(this.projectDir, {
|
|
@@ -265214,7 +265348,7 @@ import path63 from "node:path";
|
|
|
265214
265348
|
import { promisify as promisify3 } from "node:util";
|
|
265215
265349
|
import { convertCircuitJsonToGltf as convertCircuitJsonToGltf4 } from "circuit-json-to-gltf";
|
|
265216
265350
|
import {
|
|
265217
|
-
convertCircuitJsonToPcbSvg as
|
|
265351
|
+
convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg5,
|
|
265218
265352
|
convertCircuitJsonToSchematicSvg as convertCircuitJsonToSchematicSvg4,
|
|
265219
265353
|
convertCircuitJsonToAssemblySvg as convertCircuitJsonToAssemblySvg2
|
|
265220
265354
|
} from "circuit-to-svg";
|
|
@@ -268860,7 +268994,7 @@ var exportSnippet = async ({
|
|
|
268860
268994
|
outputContent = convertCircuitJsonToSchematicSvg4(circuitJson);
|
|
268861
268995
|
break;
|
|
268862
268996
|
case "pcb-svg":
|
|
268863
|
-
outputContent =
|
|
268997
|
+
outputContent = convertCircuitJsonToPcbSvg5(circuitJson, pcbSnapshotSettings);
|
|
268864
268998
|
break;
|
|
268865
268999
|
case "specctra-dsn":
|
|
268866
269000
|
outputContent = convertCircuitJsonToDsnString(circuitJson);
|
|
@@ -290015,7 +290149,7 @@ var snapshotFilesWithWorkerPool = async (options) => {
|
|
|
290015
290149
|
import fs66 from "node:fs";
|
|
290016
290150
|
import path73 from "node:path";
|
|
290017
290151
|
import {
|
|
290018
|
-
convertCircuitJsonToPcbSvg as
|
|
290152
|
+
convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg6,
|
|
290019
290153
|
convertCircuitJsonToSchematicSvg as convertCircuitJsonToSchematicSvg5
|
|
290020
290154
|
} from "circuit-to-svg";
|
|
290021
290155
|
|
|
@@ -290099,7 +290233,7 @@ var processSnapshotFile = async ({
|
|
|
290099
290233
|
}
|
|
290100
290234
|
if (!simulationOnly) {
|
|
290101
290235
|
try {
|
|
290102
|
-
pcbSvg =
|
|
290236
|
+
pcbSvg = convertCircuitJsonToPcbSvg6(circuitJson, {
|
|
290103
290237
|
...pcbSnapshotSettings,
|
|
290104
290238
|
layer: pcbLayer
|
|
290105
290239
|
});
|