@tscircuit/cli 0.1.900 → 0.1.902
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/main.js +988 -508
- package/dist/lib/index.js +684 -273
- package/package.json +2 -2
- package/types/tscircuit.config.schema.json +4 -0
package/dist/cli/main.js
CHANGED
|
@@ -54868,7 +54868,7 @@ var require_utils2 = __commonJS((exports2) => {
|
|
|
54868
54868
|
}
|
|
54869
54869
|
}
|
|
54870
54870
|
};
|
|
54871
|
-
function
|
|
54871
|
+
function identity5(input) {
|
|
54872
54872
|
return input;
|
|
54873
54873
|
}
|
|
54874
54874
|
function stringToArrayLike(str, array) {
|
|
@@ -54944,7 +54944,7 @@ var require_utils2 = __commonJS((exports2) => {
|
|
|
54944
54944
|
}
|
|
54945
54945
|
var transform = {};
|
|
54946
54946
|
transform["string"] = {
|
|
54947
|
-
string:
|
|
54947
|
+
string: identity5,
|
|
54948
54948
|
array: function(input) {
|
|
54949
54949
|
return stringToArrayLike(input, new Array(input.length));
|
|
54950
54950
|
},
|
|
@@ -54960,7 +54960,7 @@ var require_utils2 = __commonJS((exports2) => {
|
|
|
54960
54960
|
};
|
|
54961
54961
|
transform["array"] = {
|
|
54962
54962
|
string: arrayLikeToString,
|
|
54963
|
-
array:
|
|
54963
|
+
array: identity5,
|
|
54964
54964
|
arraybuffer: function(input) {
|
|
54965
54965
|
return new Uint8Array(input).buffer;
|
|
54966
54966
|
},
|
|
@@ -54978,7 +54978,7 @@ var require_utils2 = __commonJS((exports2) => {
|
|
|
54978
54978
|
array: function(input) {
|
|
54979
54979
|
return arrayLikeToArrayLike(new Uint8Array(input), new Array(input.byteLength));
|
|
54980
54980
|
},
|
|
54981
|
-
arraybuffer:
|
|
54981
|
+
arraybuffer: identity5,
|
|
54982
54982
|
uint8array: function(input) {
|
|
54983
54983
|
return new Uint8Array(input);
|
|
54984
54984
|
},
|
|
@@ -54994,7 +54994,7 @@ var require_utils2 = __commonJS((exports2) => {
|
|
|
54994
54994
|
arraybuffer: function(input) {
|
|
54995
54995
|
return input.buffer;
|
|
54996
54996
|
},
|
|
54997
|
-
uint8array:
|
|
54997
|
+
uint8array: identity5,
|
|
54998
54998
|
nodebuffer: function(input) {
|
|
54999
54999
|
return nodejsUtils.newBufferFrom(input);
|
|
55000
55000
|
}
|
|
@@ -55010,7 +55010,7 @@ var require_utils2 = __commonJS((exports2) => {
|
|
|
55010
55010
|
uint8array: function(input) {
|
|
55011
55011
|
return arrayLikeToArrayLike(input, new Uint8Array(input.length));
|
|
55012
55012
|
},
|
|
55013
|
-
nodebuffer:
|
|
55013
|
+
nodebuffer: identity5
|
|
55014
55014
|
};
|
|
55015
55015
|
exports2.transformTo = function(outputType, input) {
|
|
55016
55016
|
if (!input) {
|
|
@@ -73493,6 +73493,7 @@ var projectConfigSchema = z.object({
|
|
|
73493
73493
|
kicadLibrary: z.boolean().optional(),
|
|
73494
73494
|
kicadPcm: z.boolean().optional(),
|
|
73495
73495
|
previewImages: z.boolean().optional(),
|
|
73496
|
+
glbs: z.boolean().optional(),
|
|
73496
73497
|
typescriptLibrary: z.boolean().optional()
|
|
73497
73498
|
}).optional()
|
|
73498
73499
|
});
|
|
@@ -74383,7 +74384,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
74383
74384
|
import { execSync as execSync2 } from "node:child_process";
|
|
74384
74385
|
var import_semver2 = __toESM2(require_semver2(), 1);
|
|
74385
74386
|
// package.json
|
|
74386
|
-
var version = "0.1.
|
|
74387
|
+
var version = "0.1.901";
|
|
74387
74388
|
var package_default = {
|
|
74388
74389
|
name: "@tscircuit/cli",
|
|
74389
74390
|
main: "dist/cli/main.js",
|
|
@@ -74414,7 +74415,7 @@ var package_default = {
|
|
|
74414
74415
|
chokidar: "4.0.1",
|
|
74415
74416
|
"circuit-json": "0.0.325",
|
|
74416
74417
|
"circuit-json-to-gltf": "^0.0.58",
|
|
74417
|
-
"circuit-json-to-kicad": "^0.0.
|
|
74418
|
+
"circuit-json-to-kicad": "^0.0.71",
|
|
74418
74419
|
"circuit-json-to-readable-netlist": "^0.0.13",
|
|
74419
74420
|
"circuit-json-to-spice": "^0.0.10",
|
|
74420
74421
|
"circuit-json-to-tscircuit": "^0.0.9",
|
|
@@ -76360,44 +76361,62 @@ import {
|
|
|
76360
76361
|
Setup
|
|
76361
76362
|
} from "kicadts";
|
|
76362
76363
|
import { PcbNet } from "kicadts";
|
|
76363
|
-
import { Footprint
|
|
76364
|
-
import { applyToPoint as
|
|
76364
|
+
import { Footprint } from "kicadts";
|
|
76365
|
+
import { applyToPoint as applyToPoint10 } from "transformation-matrix";
|
|
76366
|
+
import { FpCircle, Stroke as Stroke3 } from "kicadts";
|
|
76367
|
+
import { FpCircle as FpCircle2, Stroke as Stroke4 } from "kicadts";
|
|
76368
|
+
import { FpRect, Stroke as Stroke5 } from "kicadts";
|
|
76369
|
+
import { FpRect as FpRect2, Stroke as Stroke6 } from "kicadts";
|
|
76370
|
+
import { FpRect as FpRect3, Stroke as Stroke7 } from "kicadts";
|
|
76371
|
+
import { FpPoly, Pts as Pts3, Xy as Xy3, Stroke as Stroke8 } from "kicadts";
|
|
76372
|
+
import"kicadts";
|
|
76373
|
+
import { FpText, TextEffects as TextEffects4, TextEffectsFont as TextEffectsFont4 } from "kicadts";
|
|
76374
|
+
import { applyToPoint as applyToPoint5, rotate, identity } from "transformation-matrix";
|
|
76375
|
+
import { FpText as FpText3, TextEffects as TextEffects5, TextEffectsFont as TextEffectsFont5 } from "kicadts";
|
|
76376
|
+
import { applyToPoint as applyToPoint6, rotate as rotate2, identity as identity2 } from "transformation-matrix";
|
|
76377
|
+
import { FootprintModel } from "kicadts";
|
|
76365
76378
|
import {
|
|
76366
76379
|
FootprintPad,
|
|
76367
76380
|
PadPrimitives,
|
|
76368
76381
|
PadPrimitiveGrPoly,
|
|
76369
|
-
Pts as
|
|
76370
|
-
Xy as
|
|
76382
|
+
Pts as Pts4,
|
|
76383
|
+
Xy as Xy4,
|
|
76371
76384
|
PadOptions,
|
|
76372
76385
|
PadNet
|
|
76373
76386
|
} from "kicadts";
|
|
76374
76387
|
import {
|
|
76375
|
-
applyToPoint as
|
|
76388
|
+
applyToPoint as applyToPoint7,
|
|
76376
76389
|
compose as compose2,
|
|
76377
76390
|
translate as translate2,
|
|
76378
76391
|
scale as scale2,
|
|
76379
|
-
rotate
|
|
76392
|
+
rotate as rotate3
|
|
76380
76393
|
} from "transformation-matrix";
|
|
76381
76394
|
import { FootprintPad as FootprintPad2, PadDrill, PadNet as PadNet2 } from "kicadts";
|
|
76382
|
-
import { applyToPoint as applyToPoint6, rotate as rotate2, identity } from "transformation-matrix";
|
|
76383
|
-
import { FootprintPad as FootprintPad3, PadDrill as PadDrill2 } from "kicadts";
|
|
76384
|
-
import { applyToPoint as applyToPoint7, rotate as rotate3, identity as identity2 } from "transformation-matrix";
|
|
76385
|
-
import { FpText, TextEffects as TextEffects4, TextEffectsFont as TextEffectsFont4 } from "kicadts";
|
|
76386
76395
|
import { applyToPoint as applyToPoint8, rotate as rotate4, identity as identity3 } from "transformation-matrix";
|
|
76396
|
+
import { FootprintPad as FootprintPad3, PadDrill as PadDrill2 } from "kicadts";
|
|
76397
|
+
import { applyToPoint as applyToPoint9, rotate as rotate5, identity as identity4 } from "transformation-matrix";
|
|
76387
76398
|
import { Segment, SegmentNet } from "kicadts";
|
|
76388
|
-
import { applyToPoint as applyToPoint10 } from "transformation-matrix";
|
|
76389
|
-
import { Via, ViaNet } from "kicadts";
|
|
76390
76399
|
import { applyToPoint as applyToPoint11 } from "transformation-matrix";
|
|
76400
|
+
import { Via, ViaNet } from "kicadts";
|
|
76401
|
+
import { applyToPoint as applyToPoint12 } from "transformation-matrix";
|
|
76391
76402
|
import { GrLine } from "kicadts";
|
|
76392
|
-
import { applyToPoint as applyToPoint13 } from "transformation-matrix";
|
|
76393
76403
|
import {
|
|
76404
|
+
At,
|
|
76394
76405
|
GrText,
|
|
76395
|
-
TextEffects as
|
|
76396
|
-
TextEffectsFont as
|
|
76397
|
-
TextEffectsJustify as TextEffectsJustify3
|
|
76398
|
-
At
|
|
76406
|
+
TextEffects as TextEffects6,
|
|
76407
|
+
TextEffectsFont as TextEffectsFont6,
|
|
76408
|
+
TextEffectsJustify as TextEffectsJustify3
|
|
76399
76409
|
} from "kicadts";
|
|
76400
|
-
import { applyToPoint as
|
|
76410
|
+
import { applyToPoint as applyToPoint13 } from "transformation-matrix";
|
|
76411
|
+
import { applyToPoint as applyToPoint15 } from "transformation-matrix";
|
|
76412
|
+
import {
|
|
76413
|
+
GrText as GrText2,
|
|
76414
|
+
TextEffects as TextEffects7,
|
|
76415
|
+
TextEffectsFont as TextEffectsFont7,
|
|
76416
|
+
TextEffectsJustify as TextEffectsJustify4,
|
|
76417
|
+
At as At2
|
|
76418
|
+
} from "kicadts";
|
|
76419
|
+
import { applyToPoint as applyToPoint14 } from "transformation-matrix";
|
|
76401
76420
|
import { cju as cju3 } from "@tscircuit/circuit-json-util";
|
|
76402
76421
|
import { cju as cju4 } from "@tscircuit/circuit-json-util";
|
|
76403
76422
|
import { parseKicadSexpr, KicadSch as KicadSch2 } from "kicadts";
|
|
@@ -76405,12 +76424,12 @@ import {
|
|
|
76405
76424
|
parseKicadSexpr as parseKicadSexpr2,
|
|
76406
76425
|
KicadPcb as KicadPcb2,
|
|
76407
76426
|
FootprintModel as FootprintModel2,
|
|
76408
|
-
At as
|
|
76427
|
+
At as At3,
|
|
76409
76428
|
EmbeddedFonts as EmbeddedFonts4,
|
|
76410
76429
|
FootprintAttr,
|
|
76411
76430
|
Property,
|
|
76412
|
-
TextEffects as
|
|
76413
|
-
TextEffectsFont as
|
|
76431
|
+
TextEffects as TextEffects8,
|
|
76432
|
+
TextEffectsFont as TextEffectsFont8
|
|
76414
76433
|
} from "kicadts";
|
|
76415
76434
|
import { KicadSymbolLib } from "kicadts";
|
|
76416
76435
|
import { parseKicadMod } from "kicadts";
|
|
@@ -76418,8 +76437,8 @@ import {
|
|
|
76418
76437
|
parseKicadSexpr as parseKicadSexpr3,
|
|
76419
76438
|
Footprint as Footprint3,
|
|
76420
76439
|
Property as Property2,
|
|
76421
|
-
TextEffects as
|
|
76422
|
-
TextEffectsFont as
|
|
76440
|
+
TextEffects as TextEffects9,
|
|
76441
|
+
TextEffectsFont as TextEffectsFont9
|
|
76423
76442
|
} from "kicadts";
|
|
76424
76443
|
import { parseKicadMod as parseKicadMod2 } from "kicadts";
|
|
76425
76444
|
import {
|
|
@@ -76427,9 +76446,9 @@ import {
|
|
|
76427
76446
|
SymbolPinNames as SymbolPinNames2,
|
|
76428
76447
|
SymbolPinNumbers as SymbolPinNumbers2,
|
|
76429
76448
|
SymbolProperty as SymbolProperty4,
|
|
76430
|
-
TextEffects as
|
|
76431
|
-
TextEffectsFont as
|
|
76432
|
-
TextEffectsJustify as
|
|
76449
|
+
TextEffects as TextEffects10,
|
|
76450
|
+
TextEffectsFont as TextEffectsFont10,
|
|
76451
|
+
TextEffectsJustify as TextEffectsJustify5
|
|
76433
76452
|
} from "kicadts";
|
|
76434
76453
|
import { KicadSymbolLib as KicadSymbolLib2 } from "kicadts";
|
|
76435
76454
|
var ConverterStage = class {
|
|
@@ -76683,7 +76702,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
76683
76702
|
schematicComponent,
|
|
76684
76703
|
description: this.getDescription(sourceComp),
|
|
76685
76704
|
keywords: this.getKeywords(sourceComp),
|
|
76686
|
-
fpFilters: this.getFpFilters(sourceComp),
|
|
76705
|
+
fpFilters: this.getFpFilters(sourceComp, schematicSymbol.name),
|
|
76687
76706
|
footprintRef: footprintName ? `tscircuit:${footprintName}` : "",
|
|
76688
76707
|
referencePrefix: getReferencePrefixForComponent(sourceComp)
|
|
76689
76708
|
});
|
|
@@ -76693,9 +76712,23 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
76693
76712
|
const circles = circuitJson.filter((el) => el.type === "schematic_circle" && el.schematic_symbol_id === schematicSymbolId);
|
|
76694
76713
|
const lines = circuitJson.filter((el) => el.type === "schematic_line" && el.schematic_symbol_id === schematicSymbolId);
|
|
76695
76714
|
const paths = circuitJson.filter((el) => el.type === "schematic_path" && el.schematic_symbol_id === schematicSymbolId);
|
|
76696
|
-
let ports = circuitJson.filter((el) => el.type === "schematic_port" && el.schematic_symbol_id === schematicSymbolId);
|
|
76715
|
+
let ports = circuitJson.filter((el) => el.type === "schematic_port" && ("schematic_symbol_id" in el) && el.schematic_symbol_id === schematicSymbolId);
|
|
76697
76716
|
if (ports.length === 0 && schematicComponentId) {
|
|
76698
|
-
ports = circuitJson.filter((el) => el.type === "schematic_port" && el.schematic_component_id === schematicComponentId && el.display_pin_label);
|
|
76717
|
+
ports = circuitJson.filter((el) => el.type === "schematic_port" && el.schematic_component_id === schematicComponentId && el.display_pin_label !== undefined);
|
|
76718
|
+
if (ports.length === 0) {
|
|
76719
|
+
const allPorts = circuitJson.filter((el) => el.type === "schematic_port" && el.schematic_component_id === schematicComponentId);
|
|
76720
|
+
const seenPinNumbers = /* @__PURE__ */ new Set;
|
|
76721
|
+
ports = allPorts.filter((port) => {
|
|
76722
|
+
const pinNum = port.pin_number;
|
|
76723
|
+
if (pinNum !== undefined) {
|
|
76724
|
+
if (seenPinNumbers.has(pinNum)) {
|
|
76725
|
+
return false;
|
|
76726
|
+
}
|
|
76727
|
+
seenPinNumbers.add(pinNum);
|
|
76728
|
+
}
|
|
76729
|
+
return true;
|
|
76730
|
+
});
|
|
76731
|
+
}
|
|
76699
76732
|
}
|
|
76700
76733
|
const primitives2 = [];
|
|
76701
76734
|
for (const circle of circles) {
|
|
@@ -76704,7 +76737,8 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
76704
76737
|
x: circle.center?.x ?? 0,
|
|
76705
76738
|
y: circle.center?.y ?? 0,
|
|
76706
76739
|
radius: circle.radius ?? 0.5,
|
|
76707
|
-
fill: circle.is_filled ?? false
|
|
76740
|
+
fill: circle.is_filled ?? false,
|
|
76741
|
+
fillColor: circle.fill_color
|
|
76708
76742
|
});
|
|
76709
76743
|
}
|
|
76710
76744
|
for (const line of lines) {
|
|
@@ -76720,7 +76754,9 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
76720
76754
|
if (path14.points && path14.points.length > 0) {
|
|
76721
76755
|
primitives2.push({
|
|
76722
76756
|
type: "path",
|
|
76723
|
-
points: path14.points
|
|
76757
|
+
points: path14.points,
|
|
76758
|
+
fill: path14.is_filled ?? false,
|
|
76759
|
+
fillColor: path14.fill_color
|
|
76724
76760
|
});
|
|
76725
76761
|
}
|
|
76726
76762
|
}
|
|
@@ -76930,7 +76966,10 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
76930
76966
|
return "U IC chip";
|
|
76931
76967
|
return "";
|
|
76932
76968
|
}
|
|
76933
|
-
getFpFilters(sourceComp) {
|
|
76969
|
+
getFpFilters(sourceComp, symbolName) {
|
|
76970
|
+
if (symbolName) {
|
|
76971
|
+
return `${symbolName}*`;
|
|
76972
|
+
}
|
|
76934
76973
|
if (sourceComp?.ftype === "simple_resistor")
|
|
76935
76974
|
return "R_*";
|
|
76936
76975
|
if (sourceComp?.ftype === "simple_capacitor")
|
|
@@ -76947,10 +76986,12 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
76947
76986
|
const drawingSymbol = new SchematicSymbol({
|
|
76948
76987
|
libraryId: `${libId.split(":")[1]}_0_1`
|
|
76949
76988
|
});
|
|
76950
|
-
const
|
|
76989
|
+
const GRID_ALIGNED_SCALE = 15.24;
|
|
76990
|
+
const standardScale = this.ctx.c2kMatSch?.a || 15;
|
|
76991
|
+
const symbolScale = isChip ? standardScale : GRID_ALIGNED_SCALE;
|
|
76951
76992
|
for (const primitive of symbolData.primitives || []) {
|
|
76952
76993
|
if (primitive.type === "path" && primitive.points) {
|
|
76953
|
-
const fillType = isChip ? "background" : "none";
|
|
76994
|
+
const fillType = isChip || primitive.fill ? "background" : "none";
|
|
76954
76995
|
const polyline = this.createPolylineFromPoints({
|
|
76955
76996
|
points: primitive.points,
|
|
76956
76997
|
scale: symbolScale,
|
|
@@ -77015,7 +77056,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
77015
77056
|
stroke.type = "default";
|
|
77016
77057
|
c._sxStroke = stroke;
|
|
77017
77058
|
const fill = new SymbolCircleFill;
|
|
77018
|
-
fill.type = primitive.fill ? "
|
|
77059
|
+
fill.type = primitive.fill ? "background" : "none";
|
|
77019
77060
|
c._sxFill = fill;
|
|
77020
77061
|
return circle;
|
|
77021
77062
|
}
|
|
@@ -77035,7 +77076,9 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
77035
77076
|
pin.pinGraphicStyle = "line";
|
|
77036
77077
|
const { x, y, angle } = this.calculatePinPosition(port, symbolData.center, symbolData.size, isChip, i, schematicComponent);
|
|
77037
77078
|
pin.at = [x, y, angle];
|
|
77038
|
-
|
|
77079
|
+
const CHIP_PIN_LENGTH = 6;
|
|
77080
|
+
const CUSTOM_SYMBOL_PIN_LENGTH = 2.54;
|
|
77081
|
+
pin.length = isChip ? CHIP_PIN_LENGTH : CUSTOM_SYMBOL_PIN_LENGTH;
|
|
77039
77082
|
const nameFont = new TextEffectsFont;
|
|
77040
77083
|
nameFont.size = { height: 1.27, width: 1.27 };
|
|
77041
77084
|
const nameEffects = new TextEffects({ font: nameFont });
|
|
@@ -77054,11 +77097,13 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
77054
77097
|
return pinSymbol;
|
|
77055
77098
|
}
|
|
77056
77099
|
calculatePinPosition(port, center, size, isChip, portIndex, schematicComponent) {
|
|
77057
|
-
const
|
|
77100
|
+
const GRID_ALIGNED_SCALE = 15.24;
|
|
77101
|
+
const standardScale = this.ctx.c2kMatSch?.a || 15;
|
|
77102
|
+
const symbolScale = isChip ? standardScale : GRID_ALIGNED_SCALE;
|
|
77058
77103
|
let portX = port.x ?? 0;
|
|
77059
77104
|
let portY = port.y ?? 0;
|
|
77060
77105
|
let usingCircuitJsonPort = false;
|
|
77061
|
-
if (portIndex !== undefined && schematicComponent) {
|
|
77106
|
+
if (isChip && portIndex !== undefined && schematicComponent) {
|
|
77062
77107
|
const schematicPorts = this.ctx.db.schematic_port.list().filter((p) => p.schematic_component_id === schematicComponent.schematic_component_id).sort((a, b) => (a.pin_number || 0) - (b.pin_number || 0));
|
|
77063
77108
|
if (schematicPorts[portIndex]) {
|
|
77064
77109
|
const schPort = schematicPorts[portIndex];
|
|
@@ -77092,7 +77137,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
77092
77137
|
}
|
|
77093
77138
|
let x = scaled.x;
|
|
77094
77139
|
let y = scaled.y;
|
|
77095
|
-
const
|
|
77140
|
+
const CHIP_PIN_LENGTH = 6;
|
|
77096
77141
|
if (isChip && size) {
|
|
77097
77142
|
const halfWidth = size.width / 2 * symbolScale;
|
|
77098
77143
|
const halfHeight = size.height / 2 * symbolScale;
|
|
@@ -77107,34 +77152,26 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
77107
77152
|
let angle = 0;
|
|
77108
77153
|
if (isHorizontalPin) {
|
|
77109
77154
|
if (dx > 0) {
|
|
77155
|
+
angle = 180;
|
|
77110
77156
|
if (isChip) {
|
|
77111
|
-
|
|
77112
|
-
x = x + chipPinLength;
|
|
77113
|
-
} else {
|
|
77114
|
-
angle = 0;
|
|
77157
|
+
x = x + CHIP_PIN_LENGTH;
|
|
77115
77158
|
}
|
|
77116
77159
|
} else {
|
|
77160
|
+
angle = 0;
|
|
77117
77161
|
if (isChip) {
|
|
77118
|
-
|
|
77119
|
-
x = x - chipPinLength;
|
|
77120
|
-
} else {
|
|
77121
|
-
angle = 180;
|
|
77162
|
+
x = x - CHIP_PIN_LENGTH;
|
|
77122
77163
|
}
|
|
77123
77164
|
}
|
|
77124
77165
|
} else {
|
|
77125
77166
|
if (dy > 0) {
|
|
77167
|
+
angle = 270;
|
|
77126
77168
|
if (isChip) {
|
|
77127
|
-
|
|
77128
|
-
y = y + chipPinLength;
|
|
77129
|
-
} else {
|
|
77130
|
-
angle = 90;
|
|
77169
|
+
y = y + CHIP_PIN_LENGTH;
|
|
77131
77170
|
}
|
|
77132
77171
|
} else {
|
|
77172
|
+
angle = 90;
|
|
77133
77173
|
if (isChip) {
|
|
77134
|
-
|
|
77135
|
-
y = y - chipPinLength;
|
|
77136
|
-
} else {
|
|
77137
|
-
angle = 270;
|
|
77174
|
+
y = y - CHIP_PIN_LENGTH;
|
|
77138
77175
|
}
|
|
77139
77176
|
}
|
|
77140
77177
|
}
|
|
@@ -77376,6 +77413,13 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
|
|
|
77376
77413
|
description: "Switch"
|
|
77377
77414
|
};
|
|
77378
77415
|
}
|
|
77416
|
+
if (sourceComp.ftype === "simple_potentiometer") {
|
|
77417
|
+
return {
|
|
77418
|
+
reference,
|
|
77419
|
+
value: sourceComp.display_max_resistance || "",
|
|
77420
|
+
description: "Potentiometer"
|
|
77421
|
+
};
|
|
77422
|
+
}
|
|
77379
77423
|
return {
|
|
77380
77424
|
reference,
|
|
77381
77425
|
value: name,
|
|
@@ -77780,10 +77824,13 @@ var CircuitJsonToKicadSchConverter = class {
|
|
|
77780
77824
|
};
|
|
77781
77825
|
var InitializePcbStage = class extends ConverterStage {
|
|
77782
77826
|
_step() {
|
|
77783
|
-
const { kicadPcb } = this.ctx;
|
|
77827
|
+
const { kicadPcb, db } = this.ctx;
|
|
77784
77828
|
if (!kicadPcb) {
|
|
77785
77829
|
throw new Error("KicadPcb instance not initialized in context");
|
|
77786
77830
|
}
|
|
77831
|
+
const pcbBoard = db.pcb_board?.list()?.[0];
|
|
77832
|
+
const numLayers = pcbBoard?.num_layers ?? 2;
|
|
77833
|
+
this.ctx.numLayers = numLayers;
|
|
77787
77834
|
kicadPcb.version = 20241229;
|
|
77788
77835
|
const paper = new Paper2;
|
|
77789
77836
|
paper.size = "A4";
|
|
@@ -77796,27 +77843,13 @@ var InitializePcbStage = class extends ConverterStage {
|
|
|
77796
77843
|
kicadPcb.setup = setup;
|
|
77797
77844
|
const layers = new PcbLayers;
|
|
77798
77845
|
const layerDefinitions = [
|
|
77799
|
-
new PcbLayerDefinition({ index: 0, name: "F.Cu", type: "signal" })
|
|
77800
|
-
new PcbLayerDefinition({ index: 2, name: "B.Cu", type: "signal" }),
|
|
77801
|
-
new PcbLayerDefinition({ index: 9, name: "F.Adhes", type: "user" }),
|
|
77802
|
-
new PcbLayerDefinition({ index: 11, name: "B.Adhes", type: "user" }),
|
|
77803
|
-
new PcbLayerDefinition({ index: 13, name: "F.Paste", type: "user" }),
|
|
77804
|
-
new PcbLayerDefinition({ index: 15, name: "B.Paste", type: "user" }),
|
|
77805
|
-
new PcbLayerDefinition({ index: 5, name: "F.SilkS", type: "user" }),
|
|
77806
|
-
new PcbLayerDefinition({ index: 7, name: "B.SilkS", type: "user" }),
|
|
77807
|
-
new PcbLayerDefinition({ index: 1, name: "F.Mask", type: "user" }),
|
|
77808
|
-
new PcbLayerDefinition({ index: 3, name: "B.Mask", type: "user" }),
|
|
77809
|
-
new PcbLayerDefinition({ index: 20, name: "Dwgs.User", type: "user" }),
|
|
77810
|
-
new PcbLayerDefinition({ index: 21, name: "Cmts.User", type: "user" }),
|
|
77811
|
-
new PcbLayerDefinition({ index: 22, name: "Eco1.User", type: "user" }),
|
|
77812
|
-
new PcbLayerDefinition({ index: 23, name: "Eco2.User", type: "user" }),
|
|
77813
|
-
new PcbLayerDefinition({ index: 24, name: "Edge.Cuts", type: "user" }),
|
|
77814
|
-
new PcbLayerDefinition({ index: 25, name: "Margin", type: "user" }),
|
|
77815
|
-
new PcbLayerDefinition({ index: 17, name: "B.CrtYd", type: "user" }),
|
|
77816
|
-
new PcbLayerDefinition({ index: 16, name: "F.CrtYd", type: "user" }),
|
|
77817
|
-
new PcbLayerDefinition({ index: 19, name: "B.Fab", type: "user" }),
|
|
77818
|
-
new PcbLayerDefinition({ index: 18, name: "F.Fab", type: "user" })
|
|
77846
|
+
new PcbLayerDefinition({ index: 0, name: "F.Cu", type: "signal" })
|
|
77819
77847
|
];
|
|
77848
|
+
for (let i = 1;i < numLayers - 1; i++) {
|
|
77849
|
+
layerDefinitions.push(new PcbLayerDefinition({ index: i, name: `In${i}.Cu`, type: "signal" }));
|
|
77850
|
+
}
|
|
77851
|
+
layerDefinitions.push(new PcbLayerDefinition({ index: 31, name: "B.Cu", type: "signal" }));
|
|
77852
|
+
layerDefinitions.push(new PcbLayerDefinition({ index: 32, name: "B.Adhes", type: "user" }), new PcbLayerDefinition({ index: 33, name: "F.Adhes", type: "user" }), new PcbLayerDefinition({ index: 34, name: "B.Paste", type: "user" }), new PcbLayerDefinition({ index: 35, name: "F.Paste", type: "user" }), new PcbLayerDefinition({ index: 36, name: "B.SilkS", type: "user" }), new PcbLayerDefinition({ index: 37, name: "F.SilkS", type: "user" }), new PcbLayerDefinition({ index: 38, name: "B.Mask", type: "user" }), new PcbLayerDefinition({ index: 39, name: "F.Mask", type: "user" }), new PcbLayerDefinition({ index: 40, name: "Dwgs.User", type: "user" }), new PcbLayerDefinition({ index: 41, name: "Cmts.User", type: "user" }), new PcbLayerDefinition({ index: 42, name: "Eco1.User", type: "user" }), new PcbLayerDefinition({ index: 43, name: "Eco2.User", type: "user" }), new PcbLayerDefinition({ index: 44, name: "Edge.Cuts", type: "user" }), new PcbLayerDefinition({ index: 45, name: "Margin", type: "user" }), new PcbLayerDefinition({ index: 46, name: "B.CrtYd", type: "user" }), new PcbLayerDefinition({ index: 47, name: "F.CrtYd", type: "user" }), new PcbLayerDefinition({ index: 48, name: "B.Fab", type: "user" }), new PcbLayerDefinition({ index: 49, name: "F.Fab", type: "user" }));
|
|
77820
77853
|
layers.definitions = layerDefinitions;
|
|
77821
77854
|
kicadPcb.layers = layers;
|
|
77822
77855
|
this.finished = true;
|
|
@@ -77902,6 +77935,269 @@ function generateDeterministicUuid(data) {
|
|
|
77902
77935
|
const hash = simpleHash(data);
|
|
77903
77936
|
return `${hash.slice(0, 8)}-${hash.slice(8, 12)}-${hash.slice(12, 16)}-${hash.slice(16, 20)}-${hash.slice(20, 32)}`;
|
|
77904
77937
|
}
|
|
77938
|
+
function convertSilkscreenCircles(silkscreenCircles, componentCenter) {
|
|
77939
|
+
const fpCircles = [];
|
|
77940
|
+
for (const circle of silkscreenCircles) {
|
|
77941
|
+
const relX = circle.center.x - componentCenter.x;
|
|
77942
|
+
const relY = -(circle.center.y - componentCenter.y);
|
|
77943
|
+
const layerMap = {
|
|
77944
|
+
top: "F.SilkS",
|
|
77945
|
+
bottom: "B.SilkS"
|
|
77946
|
+
};
|
|
77947
|
+
const kicadLayer = layerMap[circle.layer] || circle.layer || "F.SilkS";
|
|
77948
|
+
const fpCircle = new FpCircle({
|
|
77949
|
+
center: { x: relX, y: relY },
|
|
77950
|
+
end: { x: relX + circle.radius, y: relY },
|
|
77951
|
+
layer: kicadLayer,
|
|
77952
|
+
stroke: new Stroke3,
|
|
77953
|
+
fill: false
|
|
77954
|
+
});
|
|
77955
|
+
if (fpCircle.stroke) {
|
|
77956
|
+
fpCircle.stroke.width = circle.stroke_width || 0.05;
|
|
77957
|
+
fpCircle.stroke.type = "default";
|
|
77958
|
+
}
|
|
77959
|
+
fpCircles.push(fpCircle);
|
|
77960
|
+
}
|
|
77961
|
+
return fpCircles;
|
|
77962
|
+
}
|
|
77963
|
+
function convertCourtyardCircles(courtyardCircles, componentCenter) {
|
|
77964
|
+
const fpCircles = [];
|
|
77965
|
+
for (const circle of courtyardCircles) {
|
|
77966
|
+
const relX = circle.center.x - componentCenter.x;
|
|
77967
|
+
const relY = -(circle.center.y - componentCenter.y);
|
|
77968
|
+
const layerMap = {
|
|
77969
|
+
top: "F.CrtYd",
|
|
77970
|
+
bottom: "B.CrtYd"
|
|
77971
|
+
};
|
|
77972
|
+
const kicadLayer = layerMap[circle.layer] || "F.CrtYd";
|
|
77973
|
+
const fpCircle = new FpCircle2({
|
|
77974
|
+
center: { x: relX, y: relY },
|
|
77975
|
+
end: { x: relX + circle.radius, y: relY },
|
|
77976
|
+
layer: kicadLayer,
|
|
77977
|
+
stroke: new Stroke4,
|
|
77978
|
+
fill: false
|
|
77979
|
+
});
|
|
77980
|
+
if (fpCircle.stroke) {
|
|
77981
|
+
fpCircle.stroke.width = 0.05;
|
|
77982
|
+
fpCircle.stroke.type = "default";
|
|
77983
|
+
}
|
|
77984
|
+
fpCircles.push(fpCircle);
|
|
77985
|
+
}
|
|
77986
|
+
return fpCircles;
|
|
77987
|
+
}
|
|
77988
|
+
function convertFabricationNoteRects(fabRects, componentCenter) {
|
|
77989
|
+
const fpRects = [];
|
|
77990
|
+
for (const rect of fabRects) {
|
|
77991
|
+
const relX = rect.center.x - componentCenter.x;
|
|
77992
|
+
const relY = -(rect.center.y - componentCenter.y);
|
|
77993
|
+
const halfW = rect.width / 2;
|
|
77994
|
+
const halfH = rect.height / 2;
|
|
77995
|
+
const layerMap = {
|
|
77996
|
+
top: "F.Fab",
|
|
77997
|
+
bottom: "B.Fab"
|
|
77998
|
+
};
|
|
77999
|
+
const kicadLayer = layerMap[rect.layer] || rect.layer || "F.Fab";
|
|
78000
|
+
const fpRect = new FpRect({
|
|
78001
|
+
start: { x: relX - halfW, y: relY - halfH },
|
|
78002
|
+
end: { x: relX + halfW, y: relY + halfH },
|
|
78003
|
+
layer: kicadLayer,
|
|
78004
|
+
stroke: new Stroke5,
|
|
78005
|
+
fill: false
|
|
78006
|
+
});
|
|
78007
|
+
if (fpRect.stroke) {
|
|
78008
|
+
fpRect.stroke.width = rect.stroke_width || 0.1;
|
|
78009
|
+
fpRect.stroke.type = "default";
|
|
78010
|
+
}
|
|
78011
|
+
fpRects.push(fpRect);
|
|
78012
|
+
}
|
|
78013
|
+
return fpRects;
|
|
78014
|
+
}
|
|
78015
|
+
function convertNoteRects(noteRects, componentCenter) {
|
|
78016
|
+
const fpRects = [];
|
|
78017
|
+
for (const rect of noteRects) {
|
|
78018
|
+
const relX = rect.center.x - componentCenter.x;
|
|
78019
|
+
const relY = -(rect.center.y - componentCenter.y);
|
|
78020
|
+
const halfW = rect.width / 2;
|
|
78021
|
+
const halfH = rect.height / 2;
|
|
78022
|
+
const kicadLayer = "F.Fab";
|
|
78023
|
+
const fpRect = new FpRect2({
|
|
78024
|
+
start: { x: relX - halfW, y: relY - halfH },
|
|
78025
|
+
end: { x: relX + halfW, y: relY + halfH },
|
|
78026
|
+
layer: kicadLayer,
|
|
78027
|
+
stroke: new Stroke6,
|
|
78028
|
+
fill: false
|
|
78029
|
+
});
|
|
78030
|
+
if (fpRect.stroke) {
|
|
78031
|
+
fpRect.stroke.width = rect.stroke_width || 0.1;
|
|
78032
|
+
fpRect.stroke.type = "default";
|
|
78033
|
+
}
|
|
78034
|
+
fpRects.push(fpRect);
|
|
78035
|
+
}
|
|
78036
|
+
return fpRects;
|
|
78037
|
+
}
|
|
78038
|
+
function convertCourtyardRects(courtyardRects, componentCenter) {
|
|
78039
|
+
const fpRects = [];
|
|
78040
|
+
for (const rect of courtyardRects) {
|
|
78041
|
+
const relX = rect.center.x - componentCenter.x;
|
|
78042
|
+
const relY = -(rect.center.y - componentCenter.y);
|
|
78043
|
+
const halfW = rect.width / 2;
|
|
78044
|
+
const halfH = rect.height / 2;
|
|
78045
|
+
const layerMap = {
|
|
78046
|
+
top: "F.CrtYd",
|
|
78047
|
+
bottom: "B.CrtYd"
|
|
78048
|
+
};
|
|
78049
|
+
const kicadLayer = layerMap[rect.layer] || "F.CrtYd";
|
|
78050
|
+
const fpRect = new FpRect3({
|
|
78051
|
+
start: { x: relX - halfW, y: relY - halfH },
|
|
78052
|
+
end: { x: relX + halfW, y: relY + halfH },
|
|
78053
|
+
layer: kicadLayer,
|
|
78054
|
+
stroke: new Stroke7,
|
|
78055
|
+
fill: false
|
|
78056
|
+
});
|
|
78057
|
+
if (fpRect.stroke) {
|
|
78058
|
+
fpRect.stroke.width = 0.05;
|
|
78059
|
+
fpRect.stroke.type = "default";
|
|
78060
|
+
}
|
|
78061
|
+
fpRects.push(fpRect);
|
|
78062
|
+
}
|
|
78063
|
+
return fpRects;
|
|
78064
|
+
}
|
|
78065
|
+
function convertCourtyardOutlines(courtyardOutlines, componentCenter) {
|
|
78066
|
+
const fpPolys = [];
|
|
78067
|
+
for (const outline of courtyardOutlines) {
|
|
78068
|
+
if (!outline.outline || outline.outline.length < 2)
|
|
78069
|
+
continue;
|
|
78070
|
+
const layerMap = {
|
|
78071
|
+
top: "F.CrtYd",
|
|
78072
|
+
bottom: "B.CrtYd"
|
|
78073
|
+
};
|
|
78074
|
+
const kicadLayer = layerMap[outline.layer] || "F.CrtYd";
|
|
78075
|
+
const xyPoints = outline.outline.map((point) => {
|
|
78076
|
+
const relX = point.x - componentCenter.x;
|
|
78077
|
+
const relY = -(point.y - componentCenter.y);
|
|
78078
|
+
return new Xy3(relX, relY);
|
|
78079
|
+
});
|
|
78080
|
+
const fpPoly = new FpPoly;
|
|
78081
|
+
fpPoly.points = new Pts3(xyPoints);
|
|
78082
|
+
fpPoly.layer = kicadLayer;
|
|
78083
|
+
fpPoly.fill = false;
|
|
78084
|
+
const stroke = new Stroke8;
|
|
78085
|
+
stroke.width = 0.05;
|
|
78086
|
+
stroke.type = "default";
|
|
78087
|
+
fpPoly.stroke = stroke;
|
|
78088
|
+
fpPolys.push(fpPoly);
|
|
78089
|
+
}
|
|
78090
|
+
return fpPolys;
|
|
78091
|
+
}
|
|
78092
|
+
function createFpTextFromCircuitJson({
|
|
78093
|
+
textElement,
|
|
78094
|
+
componentCenter,
|
|
78095
|
+
componentRotation = 0
|
|
78096
|
+
}) {
|
|
78097
|
+
if (!textElement.text || !textElement.anchor_position) {
|
|
78098
|
+
return null;
|
|
78099
|
+
}
|
|
78100
|
+
const relativeX = textElement.anchor_position.x - componentCenter.x;
|
|
78101
|
+
const relativeY = -(textElement.anchor_position.y - componentCenter.y);
|
|
78102
|
+
const rotationMatrix = componentRotation !== 0 ? rotate(componentRotation * Math.PI / 180) : identity();
|
|
78103
|
+
const rotatedPos = applyToPoint5(rotationMatrix, {
|
|
78104
|
+
x: relativeX,
|
|
78105
|
+
y: relativeY
|
|
78106
|
+
});
|
|
78107
|
+
const relativePosition = {
|
|
78108
|
+
x: rotatedPos.x,
|
|
78109
|
+
y: rotatedPos.y
|
|
78110
|
+
};
|
|
78111
|
+
const layerMap = {
|
|
78112
|
+
top: "F.SilkS",
|
|
78113
|
+
bottom: "B.SilkS"
|
|
78114
|
+
};
|
|
78115
|
+
const kicadLayer = layerMap[textElement.layer] || textElement.layer || "F.SilkS";
|
|
78116
|
+
const fontSize = (textElement.font_size || 1) / 1.5;
|
|
78117
|
+
const font = new TextEffectsFont4;
|
|
78118
|
+
font.size = { width: fontSize, height: fontSize };
|
|
78119
|
+
const textEffects = new TextEffects4({
|
|
78120
|
+
font
|
|
78121
|
+
});
|
|
78122
|
+
const rotation = textElement.ccw_rotation || 0;
|
|
78123
|
+
return new FpText({
|
|
78124
|
+
type: "user",
|
|
78125
|
+
text: textElement.text,
|
|
78126
|
+
position: {
|
|
78127
|
+
x: relativePosition.x,
|
|
78128
|
+
y: relativePosition.y,
|
|
78129
|
+
angle: rotation
|
|
78130
|
+
},
|
|
78131
|
+
layer: kicadLayer,
|
|
78132
|
+
effects: textEffects
|
|
78133
|
+
});
|
|
78134
|
+
}
|
|
78135
|
+
function convertSilkscreenTexts(silkscreenTexts, componentCenter, componentRotation, sourceComponentName) {
|
|
78136
|
+
const fpTexts = [];
|
|
78137
|
+
for (const textElement of silkscreenTexts) {
|
|
78138
|
+
const fpText = createFpTextFromCircuitJson({
|
|
78139
|
+
textElement,
|
|
78140
|
+
componentCenter,
|
|
78141
|
+
componentRotation
|
|
78142
|
+
});
|
|
78143
|
+
if (fpText) {
|
|
78144
|
+
if (sourceComponentName && textElement.text === sourceComponentName) {
|
|
78145
|
+
fpText.type = "reference";
|
|
78146
|
+
}
|
|
78147
|
+
fpTexts.push(fpText);
|
|
78148
|
+
}
|
|
78149
|
+
}
|
|
78150
|
+
return fpTexts;
|
|
78151
|
+
}
|
|
78152
|
+
function convertNoteTexts(noteTexts, componentCenter, componentRotation) {
|
|
78153
|
+
const fpTexts = [];
|
|
78154
|
+
for (const textElement of noteTexts) {
|
|
78155
|
+
const relX = textElement.anchor_position.x - componentCenter.x;
|
|
78156
|
+
const relY = -(textElement.anchor_position.y - componentCenter.y);
|
|
78157
|
+
const rotationMatrix = componentRotation !== 0 ? rotate2(componentRotation * Math.PI / 180) : identity2();
|
|
78158
|
+
const rotatedPos = applyToPoint6(rotationMatrix, { x: relX, y: relY });
|
|
78159
|
+
const fontSize = textElement.font_size || 1;
|
|
78160
|
+
const font = new TextEffectsFont5;
|
|
78161
|
+
font.size = { width: fontSize, height: fontSize };
|
|
78162
|
+
const textEffects = new TextEffects5({ font });
|
|
78163
|
+
const fpText = new FpText3({
|
|
78164
|
+
type: "user",
|
|
78165
|
+
text: textElement.text,
|
|
78166
|
+
position: { x: rotatedPos.x, y: rotatedPos.y, angle: 0 },
|
|
78167
|
+
layer: "F.Fab",
|
|
78168
|
+
effects: textEffects
|
|
78169
|
+
});
|
|
78170
|
+
fpTexts.push(fpText);
|
|
78171
|
+
}
|
|
78172
|
+
return fpTexts;
|
|
78173
|
+
}
|
|
78174
|
+
function create3DModelsFromCadComponent(cadComponent, componentCenter) {
|
|
78175
|
+
const models = [];
|
|
78176
|
+
const modelUrl = cadComponent.model_step_url || cadComponent.model_wrl_url;
|
|
78177
|
+
if (!modelUrl)
|
|
78178
|
+
return models;
|
|
78179
|
+
const model = new FootprintModel(modelUrl);
|
|
78180
|
+
if (cadComponent.position) {
|
|
78181
|
+
model.offset = {
|
|
78182
|
+
x: (cadComponent.position.x || 0) - componentCenter.x,
|
|
78183
|
+
y: -((cadComponent.position.y || 0) - componentCenter.y),
|
|
78184
|
+
z: cadComponent.position.z || 0
|
|
78185
|
+
};
|
|
78186
|
+
}
|
|
78187
|
+
if (cadComponent.rotation) {
|
|
78188
|
+
model.rotate = {
|
|
78189
|
+
x: cadComponent.rotation.x || 0,
|
|
78190
|
+
y: cadComponent.rotation.y || 0,
|
|
78191
|
+
z: cadComponent.rotation.z || 0
|
|
78192
|
+
};
|
|
78193
|
+
}
|
|
78194
|
+
if (cadComponent.model_unit_to_mm_scale_factor) {
|
|
78195
|
+
const scale4 = cadComponent.model_unit_to_mm_scale_factor;
|
|
78196
|
+
model.scale = { x: scale4, y: scale4, z: scale4 };
|
|
78197
|
+
}
|
|
78198
|
+
models.push(model);
|
|
78199
|
+
return models;
|
|
78200
|
+
}
|
|
77905
78201
|
function createSmdPadFromCircuitJson({
|
|
77906
78202
|
pcbPad,
|
|
77907
78203
|
componentCenter,
|
|
@@ -77922,8 +78218,8 @@ function createSmdPadFromCircuitJson({
|
|
|
77922
78218
|
} else {
|
|
77923
78219
|
throw new Error("Pad must have either x/y coordinates or points array");
|
|
77924
78220
|
}
|
|
77925
|
-
const cj2kicadMatrix = compose2(componentRotation !== 0 ?
|
|
77926
|
-
const rotatedPos =
|
|
78221
|
+
const cj2kicadMatrix = compose2(componentRotation !== 0 ? rotate3(componentRotation * Math.PI / 180) : { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }, scale2(1, -1), translate2(-componentCenter.x, -componentCenter.y));
|
|
78222
|
+
const rotatedPos = applyToPoint7(cj2kicadMatrix, {
|
|
77927
78223
|
x: padX,
|
|
77928
78224
|
y: padY
|
|
77929
78225
|
});
|
|
@@ -77946,11 +78242,11 @@ function createSmdPadFromCircuitJson({
|
|
|
77946
78242
|
const points = pcbPad.points;
|
|
77947
78243
|
const pointTransformMatrix = compose2(scale2(1, -1), translate2(-padX, -padY));
|
|
77948
78244
|
const relativePoints = points.map((p) => {
|
|
77949
|
-
const transformed =
|
|
77950
|
-
return new
|
|
78245
|
+
const transformed = applyToPoint7(pointTransformMatrix, { x: p.x, y: p.y });
|
|
78246
|
+
return new Xy4(transformed.x, transformed.y);
|
|
77951
78247
|
});
|
|
77952
78248
|
const grPoly = new PadPrimitiveGrPoly;
|
|
77953
|
-
grPoly.contours = [new
|
|
78249
|
+
grPoly.contours = [new Pts4(relativePoints)];
|
|
77954
78250
|
grPoly.width = 0;
|
|
77955
78251
|
grPoly.filled = true;
|
|
77956
78252
|
padPrimitives = new PadPrimitives;
|
|
@@ -77991,6 +78287,24 @@ function createSmdPadFromCircuitJson({
|
|
|
77991
78287
|
}
|
|
77992
78288
|
return pad;
|
|
77993
78289
|
}
|
|
78290
|
+
function convertSmdPads(pcbPads, componentCenter, componentRotation, componentId, startPadNumber, getNetInfo) {
|
|
78291
|
+
const pads = [];
|
|
78292
|
+
let padNumber = startPadNumber;
|
|
78293
|
+
for (const pcbPad of pcbPads) {
|
|
78294
|
+
const netInfo = getNetInfo(pcbPad.pcb_port_id);
|
|
78295
|
+
const pad = createSmdPadFromCircuitJson({
|
|
78296
|
+
pcbPad,
|
|
78297
|
+
componentCenter,
|
|
78298
|
+
padNumber,
|
|
78299
|
+
componentRotation,
|
|
78300
|
+
netInfo,
|
|
78301
|
+
componentId
|
|
78302
|
+
});
|
|
78303
|
+
pads.push(pad);
|
|
78304
|
+
padNumber++;
|
|
78305
|
+
}
|
|
78306
|
+
return { pads, nextPadNumber: padNumber };
|
|
78307
|
+
}
|
|
77994
78308
|
function createThruHolePadFromCircuitJson({
|
|
77995
78309
|
platedHole,
|
|
77996
78310
|
componentCenter,
|
|
@@ -78004,8 +78318,8 @@ function createThruHolePadFromCircuitJson({
|
|
|
78004
78318
|
}
|
|
78005
78319
|
const relativeX = platedHole.x - componentCenter.x;
|
|
78006
78320
|
const relativeY = -(platedHole.y - componentCenter.y);
|
|
78007
|
-
const rotationMatrix = componentRotation !== 0 ?
|
|
78008
|
-
const rotatedPos =
|
|
78321
|
+
const rotationMatrix = componentRotation !== 0 ? rotate4(componentRotation * Math.PI / 180) : identity3();
|
|
78322
|
+
const rotatedPos = applyToPoint8(rotationMatrix, {
|
|
78009
78323
|
x: relativeX,
|
|
78010
78324
|
y: relativeY
|
|
78011
78325
|
});
|
|
@@ -78021,7 +78335,7 @@ function createThruHolePadFromCircuitJson({
|
|
|
78021
78335
|
y: platedHole.hole_offset_y ?? 0
|
|
78022
78336
|
};
|
|
78023
78337
|
if (rawOffset.x !== 0 || rawOffset.y !== 0) {
|
|
78024
|
-
const rotatedOffset =
|
|
78338
|
+
const rotatedOffset = applyToPoint8(rotationMatrix, {
|
|
78025
78339
|
x: -rawOffset.x,
|
|
78026
78340
|
y: rawOffset.y
|
|
78027
78341
|
});
|
|
@@ -78104,6 +78418,26 @@ function createThruHolePadFromCircuitJson({
|
|
|
78104
78418
|
}
|
|
78105
78419
|
return pad;
|
|
78106
78420
|
}
|
|
78421
|
+
function convertPlatedHoles(platedHoles, componentCenter, componentRotation, componentId, startPadNumber, getNetInfo) {
|
|
78422
|
+
const pads = [];
|
|
78423
|
+
let padNumber = startPadNumber;
|
|
78424
|
+
for (const platedHole of platedHoles) {
|
|
78425
|
+
const netInfo = getNetInfo(platedHole.pcb_port_id);
|
|
78426
|
+
const pad = createThruHolePadFromCircuitJson({
|
|
78427
|
+
platedHole,
|
|
78428
|
+
componentCenter,
|
|
78429
|
+
padNumber,
|
|
78430
|
+
componentRotation,
|
|
78431
|
+
netInfo,
|
|
78432
|
+
componentId
|
|
78433
|
+
});
|
|
78434
|
+
if (pad) {
|
|
78435
|
+
pads.push(pad);
|
|
78436
|
+
padNumber++;
|
|
78437
|
+
}
|
|
78438
|
+
}
|
|
78439
|
+
return { pads, nextPadNumber: padNumber };
|
|
78440
|
+
}
|
|
78107
78441
|
function createNpthPadFromCircuitJson({
|
|
78108
78442
|
pcbHole,
|
|
78109
78443
|
componentCenter,
|
|
@@ -78114,8 +78448,8 @@ function createNpthPadFromCircuitJson({
|
|
|
78114
78448
|
}
|
|
78115
78449
|
const relativeX = pcbHole.x - componentCenter.x;
|
|
78116
78450
|
const relativeY = -(pcbHole.y - componentCenter.y);
|
|
78117
|
-
const rotationMatrix = componentRotation !== 0 ?
|
|
78118
|
-
const rotatedPos =
|
|
78451
|
+
const rotationMatrix = componentRotation !== 0 ? rotate5(componentRotation * Math.PI / 180) : identity4();
|
|
78452
|
+
const rotatedPos = applyToPoint9(rotationMatrix, {
|
|
78119
78453
|
x: relativeX,
|
|
78120
78454
|
y: relativeY
|
|
78121
78455
|
});
|
|
@@ -78157,48 +78491,19 @@ function createNpthPadFromCircuitJson({
|
|
|
78157
78491
|
uuid: crypto.randomUUID()
|
|
78158
78492
|
});
|
|
78159
78493
|
}
|
|
78160
|
-
function
|
|
78161
|
-
|
|
78162
|
-
|
|
78163
|
-
|
|
78164
|
-
|
|
78165
|
-
|
|
78166
|
-
|
|
78494
|
+
function convertNpthHoles(pcbHoles, componentCenter, componentRotation) {
|
|
78495
|
+
const pads = [];
|
|
78496
|
+
for (const pcbHole of pcbHoles) {
|
|
78497
|
+
const pad = createNpthPadFromCircuitJson({
|
|
78498
|
+
pcbHole,
|
|
78499
|
+
componentCenter,
|
|
78500
|
+
componentRotation
|
|
78501
|
+
});
|
|
78502
|
+
if (pad) {
|
|
78503
|
+
pads.push(pad);
|
|
78504
|
+
}
|
|
78167
78505
|
}
|
|
78168
|
-
|
|
78169
|
-
const relativeY = -(textElement.anchor_position.y - componentCenter.y);
|
|
78170
|
-
const rotationMatrix = componentRotation !== 0 ? rotate4(componentRotation * Math.PI / 180) : identity3();
|
|
78171
|
-
const rotatedPos = applyToPoint8(rotationMatrix, {
|
|
78172
|
-
x: relativeX,
|
|
78173
|
-
y: relativeY
|
|
78174
|
-
});
|
|
78175
|
-
const relativePosition = {
|
|
78176
|
-
x: rotatedPos.x,
|
|
78177
|
-
y: rotatedPos.y
|
|
78178
|
-
};
|
|
78179
|
-
const layerMap = {
|
|
78180
|
-
top: "F.SilkS",
|
|
78181
|
-
bottom: "B.SilkS"
|
|
78182
|
-
};
|
|
78183
|
-
const kicadLayer = layerMap[textElement.layer] || textElement.layer || "F.SilkS";
|
|
78184
|
-
const fontSize = (textElement.font_size || 1) / 1.5;
|
|
78185
|
-
const font = new TextEffectsFont4;
|
|
78186
|
-
font.size = { width: fontSize, height: fontSize };
|
|
78187
|
-
const textEffects = new TextEffects4({
|
|
78188
|
-
font
|
|
78189
|
-
});
|
|
78190
|
-
const rotation = textElement.ccw_rotation || 0;
|
|
78191
|
-
return new FpText({
|
|
78192
|
-
type: "user",
|
|
78193
|
-
text: textElement.text,
|
|
78194
|
-
position: {
|
|
78195
|
-
x: relativePosition.x,
|
|
78196
|
-
y: relativePosition.y,
|
|
78197
|
-
angle: rotation
|
|
78198
|
-
},
|
|
78199
|
-
layer: kicadLayer,
|
|
78200
|
-
effects: textEffects
|
|
78201
|
-
});
|
|
78506
|
+
return pads;
|
|
78202
78507
|
}
|
|
78203
78508
|
var AddFootprintsStage = class extends ConverterStage {
|
|
78204
78509
|
componentsProcessed = 0;
|
|
@@ -78224,33 +78529,6 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
78224
78529
|
const cadComponents = this.ctx.db.cad_component?.list() || [];
|
|
78225
78530
|
return cadComponents.find((cad) => cad.pcb_component_id === pcbComponentId);
|
|
78226
78531
|
}
|
|
78227
|
-
create3DModelsFromCadComponent(cadComponent, componentCenter) {
|
|
78228
|
-
const models = [];
|
|
78229
|
-
const modelUrl = cadComponent.model_step_url || cadComponent.model_wrl_url;
|
|
78230
|
-
if (!modelUrl)
|
|
78231
|
-
return models;
|
|
78232
|
-
const model = new FootprintModel(modelUrl);
|
|
78233
|
-
if (cadComponent.position) {
|
|
78234
|
-
model.offset = {
|
|
78235
|
-
x: (cadComponent.position.x || 0) - componentCenter.x,
|
|
78236
|
-
y: -((cadComponent.position.y || 0) - componentCenter.y),
|
|
78237
|
-
z: cadComponent.position.z || 0
|
|
78238
|
-
};
|
|
78239
|
-
}
|
|
78240
|
-
if (cadComponent.rotation) {
|
|
78241
|
-
model.rotate = {
|
|
78242
|
-
x: cadComponent.rotation.x || 0,
|
|
78243
|
-
y: cadComponent.rotation.y || 0,
|
|
78244
|
-
z: cadComponent.rotation.z || 0
|
|
78245
|
-
};
|
|
78246
|
-
}
|
|
78247
|
-
if (cadComponent.model_unit_to_mm_scale_factor) {
|
|
78248
|
-
const scale4 = cadComponent.model_unit_to_mm_scale_factor;
|
|
78249
|
-
model.scale = { x: scale4, y: scale4, z: scale4 };
|
|
78250
|
-
}
|
|
78251
|
-
models.push(model);
|
|
78252
|
-
return models;
|
|
78253
|
-
}
|
|
78254
78532
|
constructor(input, ctx) {
|
|
78255
78533
|
super(input, ctx);
|
|
78256
78534
|
this.pcbComponents = this.ctx.db.pcb_component.list();
|
|
@@ -78271,7 +78549,7 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
78271
78549
|
const sourceComponent = component.source_component_id ? this.ctx.db.source_component.get(component.source_component_id) : null;
|
|
78272
78550
|
const cadComponent = this.getCadComponentForPcbComponent(component.pcb_component_id);
|
|
78273
78551
|
const footprintName = sourceComponent ? getKicadCompatibleComponentName(sourceComponent, cadComponent) : "Unknown";
|
|
78274
|
-
const transformedPos =
|
|
78552
|
+
const transformedPos = applyToPoint10(c2kMatPcb, {
|
|
78275
78553
|
x: component.center.x,
|
|
78276
78554
|
y: component.center.y
|
|
78277
78555
|
});
|
|
@@ -78284,66 +78562,43 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
78284
78562
|
});
|
|
78285
78563
|
const fpTexts = footprint.fpTexts;
|
|
78286
78564
|
const pcbSilkscreenTexts = this.ctx.db.pcb_silkscreen_text?.list().filter((text) => text.pcb_component_id === component.pcb_component_id) || [];
|
|
78287
|
-
|
|
78288
|
-
|
|
78289
|
-
|
|
78290
|
-
componentCenter: component.center,
|
|
78291
|
-
componentRotation: component.rotation || 0
|
|
78292
|
-
});
|
|
78293
|
-
if (fpText) {
|
|
78294
|
-
if (sourceComponent?.name && textElement.text === sourceComponent.name) {
|
|
78295
|
-
fpText.type = "reference";
|
|
78296
|
-
}
|
|
78297
|
-
fpTexts.push(fpText);
|
|
78298
|
-
}
|
|
78299
|
-
}
|
|
78565
|
+
fpTexts.push(...convertSilkscreenTexts(pcbSilkscreenTexts, component.center, component.rotation || 0, sourceComponent?.name));
|
|
78566
|
+
const pcbNoteTexts = this.ctx.db.pcb_note_text?.list().filter((text) => text.pcb_component_id === component.pcb_component_id) || [];
|
|
78567
|
+
fpTexts.push(...convertNoteTexts(pcbNoteTexts, component.center, component.rotation || 0));
|
|
78300
78568
|
footprint.fpTexts = fpTexts;
|
|
78301
|
-
const pcbPads = this.ctx.db.pcb_smtpad?.list().filter((pad) => pad.pcb_component_id === component.pcb_component_id) || [];
|
|
78302
78569
|
const fpPads = footprint.fpPads;
|
|
78303
|
-
|
|
78304
|
-
|
|
78305
|
-
|
|
78306
|
-
|
|
78307
|
-
pcbPad,
|
|
78308
|
-
componentCenter: component.center,
|
|
78309
|
-
padNumber,
|
|
78310
|
-
componentRotation: component.rotation || 0,
|
|
78311
|
-
netInfo,
|
|
78312
|
-
componentId: component.pcb_component_id
|
|
78313
|
-
});
|
|
78314
|
-
fpPads.push(pad);
|
|
78315
|
-
padNumber++;
|
|
78316
|
-
}
|
|
78570
|
+
const getNetInfo = (pcbPortId) => this.getNetInfoForPcbPort(pcbPortId);
|
|
78571
|
+
const pcbPads = this.ctx.db.pcb_smtpad?.list().filter((pad) => pad.pcb_component_id === component.pcb_component_id) || [];
|
|
78572
|
+
const { pads: smdPads, nextPadNumber } = convertSmdPads(pcbPads, component.center, component.rotation || 0, component.pcb_component_id, 1, getNetInfo);
|
|
78573
|
+
fpPads.push(...smdPads);
|
|
78317
78574
|
const pcbPlatedHoles = this.ctx.db.pcb_plated_hole?.list().filter((hole) => hole.pcb_component_id === component.pcb_component_id) || [];
|
|
78318
|
-
|
|
78319
|
-
|
|
78320
|
-
const pad = createThruHolePadFromCircuitJson({
|
|
78321
|
-
platedHole,
|
|
78322
|
-
componentCenter: component.center,
|
|
78323
|
-
padNumber,
|
|
78324
|
-
componentRotation: component.rotation || 0,
|
|
78325
|
-
netInfo,
|
|
78326
|
-
componentId: component.pcb_component_id
|
|
78327
|
-
});
|
|
78328
|
-
if (pad) {
|
|
78329
|
-
fpPads.push(pad);
|
|
78330
|
-
padNumber++;
|
|
78331
|
-
}
|
|
78332
|
-
}
|
|
78575
|
+
const { pads: thruHolePads } = convertPlatedHoles(pcbPlatedHoles, component.center, component.rotation || 0, component.pcb_component_id, nextPadNumber, getNetInfo);
|
|
78576
|
+
fpPads.push(...thruHolePads);
|
|
78333
78577
|
const pcbHoles = this.ctx.db.pcb_hole?.list().filter((hole) => hole.subcircuit_id === component.subcircuit_id) || [];
|
|
78334
|
-
|
|
78335
|
-
|
|
78336
|
-
pcbHole,
|
|
78337
|
-
componentCenter: component.center,
|
|
78338
|
-
componentRotation: component.rotation || 0
|
|
78339
|
-
});
|
|
78340
|
-
if (pad) {
|
|
78341
|
-
fpPads.push(pad);
|
|
78342
|
-
}
|
|
78343
|
-
}
|
|
78578
|
+
const npthPads = convertNpthHoles(pcbHoles, component.center, component.rotation || 0);
|
|
78579
|
+
fpPads.push(...npthPads);
|
|
78344
78580
|
footprint.fpPads = fpPads;
|
|
78581
|
+
const pcbSilkscreenCircles = this.ctx.db.pcb_silkscreen_circle?.list().filter((circle) => circle.pcb_component_id === component.pcb_component_id) || [];
|
|
78582
|
+
const fpCircles = footprint.fpCircles ?? [];
|
|
78583
|
+
fpCircles.push(...convertSilkscreenCircles(pcbSilkscreenCircles, component.center));
|
|
78584
|
+
const pcbCourtyardCircles = this.ctx.db.pcb_courtyard_circle?.list().filter((circle) => circle.pcb_component_id === component.pcb_component_id) || [];
|
|
78585
|
+
fpCircles.push(...convertCourtyardCircles(pcbCourtyardCircles, component.center));
|
|
78586
|
+
footprint.fpCircles = fpCircles;
|
|
78587
|
+
const pcbFabRects = this.ctx.db.pcb_fabrication_note_rect?.list().filter((rect) => rect.pcb_component_id === component.pcb_component_id) || [];
|
|
78588
|
+
const fpRects = footprint.fpRects ?? [];
|
|
78589
|
+
fpRects.push(...convertFabricationNoteRects(pcbFabRects, component.center));
|
|
78590
|
+
const pcbNoteRects = this.ctx.db.pcb_note_rect?.list().filter((rect) => rect.pcb_component_id === component.pcb_component_id) || [];
|
|
78591
|
+
fpRects.push(...convertNoteRects(pcbNoteRects, component.center));
|
|
78592
|
+
const pcbCourtyardRects = this.ctx.db.pcb_courtyard_rect?.list().filter((rect) => rect.pcb_component_id === component.pcb_component_id) || [];
|
|
78593
|
+
fpRects.push(...convertCourtyardRects(pcbCourtyardRects, component.center));
|
|
78594
|
+
footprint.fpRects = fpRects;
|
|
78595
|
+
const pcbCourtyardOutlines = this.ctx.db.pcb_courtyard_outline?.list().filter((outline) => outline.pcb_component_id === component.pcb_component_id) || [];
|
|
78596
|
+
const fpPolys = convertCourtyardOutlines(pcbCourtyardOutlines, component.center);
|
|
78597
|
+
if (fpPolys.length > 0) {
|
|
78598
|
+
footprint.fpPolys = fpPolys;
|
|
78599
|
+
}
|
|
78345
78600
|
if (cadComponent) {
|
|
78346
|
-
const models =
|
|
78601
|
+
const models = create3DModelsFromCadComponent(cadComponent, component.center);
|
|
78347
78602
|
if (models.length > 0) {
|
|
78348
78603
|
footprint.models = models;
|
|
78349
78604
|
}
|
|
@@ -78357,6 +78612,29 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
78357
78612
|
return this.ctx.kicadPcb;
|
|
78358
78613
|
}
|
|
78359
78614
|
};
|
|
78615
|
+
var circuitJsonLayerToKicadLayer = {
|
|
78616
|
+
top: "F.Cu",
|
|
78617
|
+
bottom: "B.Cu",
|
|
78618
|
+
inner1: "In1.Cu",
|
|
78619
|
+
inner2: "In2.Cu",
|
|
78620
|
+
inner3: "In3.Cu",
|
|
78621
|
+
inner4: "In4.Cu",
|
|
78622
|
+
inner5: "In5.Cu",
|
|
78623
|
+
inner6: "In6.Cu"
|
|
78624
|
+
};
|
|
78625
|
+
function getKicadLayer(circuitJsonLayer) {
|
|
78626
|
+
if (!circuitJsonLayer)
|
|
78627
|
+
return "F.Cu";
|
|
78628
|
+
return circuitJsonLayerToKicadLayer[circuitJsonLayer] || circuitJsonLayer || "F.Cu";
|
|
78629
|
+
}
|
|
78630
|
+
function getViaLayers(numLayers) {
|
|
78631
|
+
const layers = ["F.Cu"];
|
|
78632
|
+
for (let i = 1;i < numLayers - 1; i++) {
|
|
78633
|
+
layers.push(`In${i}.Cu`);
|
|
78634
|
+
}
|
|
78635
|
+
layers.push("B.Cu");
|
|
78636
|
+
return layers;
|
|
78637
|
+
}
|
|
78360
78638
|
var AddTracesStage = class extends ConverterStage {
|
|
78361
78639
|
tracesProcessed = 0;
|
|
78362
78640
|
pcbTraces = [];
|
|
@@ -78381,14 +78659,15 @@ var AddTracesStage = class extends ConverterStage {
|
|
|
78381
78659
|
this.tracesProcessed++;
|
|
78382
78660
|
return;
|
|
78383
78661
|
}
|
|
78662
|
+
let lastKnownLayer = trace.route[0]?.layer;
|
|
78384
78663
|
for (let i = 0;i < trace.route.length - 1; i++) {
|
|
78385
78664
|
const startPoint = trace.route[i];
|
|
78386
78665
|
const endPoint = trace.route[i + 1];
|
|
78387
|
-
const transformedStart =
|
|
78666
|
+
const transformedStart = applyToPoint11(c2kMatPcb, {
|
|
78388
78667
|
x: startPoint.x,
|
|
78389
78668
|
y: startPoint.y
|
|
78390
78669
|
});
|
|
78391
|
-
const transformedEnd =
|
|
78670
|
+
const transformedEnd = applyToPoint11(c2kMatPcb, {
|
|
78392
78671
|
x: endPoint.x,
|
|
78393
78672
|
y: endPoint.y
|
|
78394
78673
|
});
|
|
@@ -78420,11 +78699,8 @@ var AddTracesStage = class extends ConverterStage {
|
|
|
78420
78699
|
netInfo = pcbNetMap.get(connectivityKey);
|
|
78421
78700
|
}
|
|
78422
78701
|
}
|
|
78423
|
-
const
|
|
78424
|
-
|
|
78425
|
-
bottom: "B.Cu"
|
|
78426
|
-
};
|
|
78427
|
-
const kicadLayer = layerMap[startPoint.layer] || startPoint.layer || "F.Cu";
|
|
78702
|
+
const segmentLayerSource = startPoint.layer ?? endPoint.layer ?? lastKnownLayer;
|
|
78703
|
+
const kicadLayer = getKicadLayer(segmentLayerSource);
|
|
78428
78704
|
const segmentData = `segment:${transformedStart.x},${transformedStart.y}:${transformedEnd.x},${transformedEnd.y}:${kicadLayer}:${netInfo?.id ?? 0}`;
|
|
78429
78705
|
const segment = new Segment({
|
|
78430
78706
|
start: { x: transformedStart.x, y: transformedStart.y },
|
|
@@ -78437,6 +78713,12 @@ var AddTracesStage = class extends ConverterStage {
|
|
|
78437
78713
|
const segments = kicadPcb.segments;
|
|
78438
78714
|
segments.push(segment);
|
|
78439
78715
|
kicadPcb.segments = segments;
|
|
78716
|
+
if (startPoint.layer) {
|
|
78717
|
+
lastKnownLayer = startPoint.layer;
|
|
78718
|
+
}
|
|
78719
|
+
if (endPoint.layer) {
|
|
78720
|
+
lastKnownLayer = endPoint.layer;
|
|
78721
|
+
}
|
|
78440
78722
|
}
|
|
78441
78723
|
this.tracesProcessed++;
|
|
78442
78724
|
}
|
|
@@ -78464,7 +78746,7 @@ var AddViasStage = class extends ConverterStage {
|
|
|
78464
78746
|
return;
|
|
78465
78747
|
}
|
|
78466
78748
|
const via = this.pcbVias[this.viasProcessed];
|
|
78467
|
-
const transformedPos =
|
|
78749
|
+
const transformedPos = applyToPoint12(c2kMatPcb, {
|
|
78468
78750
|
x: via.x,
|
|
78469
78751
|
y: via.y
|
|
78470
78752
|
});
|
|
@@ -78506,12 +78788,14 @@ var AddViasStage = class extends ConverterStage {
|
|
|
78506
78788
|
netInfo = pcbNetMap.get(connectivityKey);
|
|
78507
78789
|
}
|
|
78508
78790
|
}
|
|
78791
|
+
const numLayers = this.ctx.numLayers ?? 2;
|
|
78792
|
+
const viaLayers = via.layers ? via.layers.map((l) => l === "top" ? "F.Cu" : l === "bottom" ? "B.Cu" : `In${l.replace("inner", "")}.Cu`) : getViaLayers(numLayers);
|
|
78509
78793
|
const viaData = `via:${transformedPos.x},${transformedPos.y}:${via.outer_diameter || 0.8}:${via.hole_diameter || 0.4}:${netInfo?.id ?? 0}`;
|
|
78510
78794
|
const kicadVia = new Via({
|
|
78511
78795
|
at: [transformedPos.x, transformedPos.y],
|
|
78512
78796
|
size: via.outer_diameter || 0.8,
|
|
78513
78797
|
drill: via.hole_diameter || 0.4,
|
|
78514
|
-
layers:
|
|
78798
|
+
layers: viaLayers,
|
|
78515
78799
|
net: new ViaNet(netInfo?.id ?? 0),
|
|
78516
78800
|
uuid: generateDeterministicUuid(viaData)
|
|
78517
78801
|
});
|
|
@@ -78524,6 +78808,62 @@ var AddViasStage = class extends ConverterStage {
|
|
|
78524
78808
|
return this.ctx.kicadPcb;
|
|
78525
78809
|
}
|
|
78526
78810
|
};
|
|
78811
|
+
function createFabricationNoteTextFromCircuitJson({
|
|
78812
|
+
textElement,
|
|
78813
|
+
c2kMatPcb
|
|
78814
|
+
}) {
|
|
78815
|
+
if (!textElement.text || !textElement.anchor_position) {
|
|
78816
|
+
return null;
|
|
78817
|
+
}
|
|
78818
|
+
const transformedPos = applyToPoint13(c2kMatPcb, {
|
|
78819
|
+
x: textElement.anchor_position.x,
|
|
78820
|
+
y: textElement.anchor_position.y
|
|
78821
|
+
});
|
|
78822
|
+
const layerMap = {
|
|
78823
|
+
top: "F.Fab",
|
|
78824
|
+
bottom: "B.Fab"
|
|
78825
|
+
};
|
|
78826
|
+
const kicadLayer = layerMap[textElement.layer] || textElement.layer || "F.Fab";
|
|
78827
|
+
const fontSize = (textElement.font_size || 1) / 1.5;
|
|
78828
|
+
const font = new TextEffectsFont6;
|
|
78829
|
+
font.size = { width: fontSize, height: fontSize };
|
|
78830
|
+
const justify = new TextEffectsJustify3;
|
|
78831
|
+
const anchorAlignment = textElement.anchor_alignment || "center";
|
|
78832
|
+
switch (anchorAlignment) {
|
|
78833
|
+
case "top_left":
|
|
78834
|
+
justify.horizontal = "left";
|
|
78835
|
+
justify.vertical = "top";
|
|
78836
|
+
break;
|
|
78837
|
+
case "top_right":
|
|
78838
|
+
justify.horizontal = "right";
|
|
78839
|
+
justify.vertical = "top";
|
|
78840
|
+
break;
|
|
78841
|
+
case "bottom_left":
|
|
78842
|
+
justify.horizontal = "left";
|
|
78843
|
+
justify.vertical = "bottom";
|
|
78844
|
+
break;
|
|
78845
|
+
case "bottom_right":
|
|
78846
|
+
justify.horizontal = "right";
|
|
78847
|
+
justify.vertical = "bottom";
|
|
78848
|
+
break;
|
|
78849
|
+
case "center":
|
|
78850
|
+
break;
|
|
78851
|
+
}
|
|
78852
|
+
const textEffects = new TextEffects6({
|
|
78853
|
+
font
|
|
78854
|
+
});
|
|
78855
|
+
if (anchorAlignment !== "center") {
|
|
78856
|
+
textEffects.justify = justify;
|
|
78857
|
+
}
|
|
78858
|
+
const position = new At([transformedPos.x, transformedPos.y, 0]);
|
|
78859
|
+
const grText = new GrText({
|
|
78860
|
+
text: textElement.text,
|
|
78861
|
+
layer: kicadLayer,
|
|
78862
|
+
effects: textEffects
|
|
78863
|
+
});
|
|
78864
|
+
grText.position = position;
|
|
78865
|
+
return grText;
|
|
78866
|
+
}
|
|
78527
78867
|
function createGrTextFromCircuitJson({
|
|
78528
78868
|
textElement,
|
|
78529
78869
|
c2kMatPcb
|
|
@@ -78531,7 +78871,7 @@ function createGrTextFromCircuitJson({
|
|
|
78531
78871
|
if (!textElement.text || !textElement.anchor_position) {
|
|
78532
78872
|
return null;
|
|
78533
78873
|
}
|
|
78534
|
-
const transformedPos =
|
|
78874
|
+
const transformedPos = applyToPoint14(c2kMatPcb, {
|
|
78535
78875
|
x: textElement.anchor_position.x,
|
|
78536
78876
|
y: textElement.anchor_position.y
|
|
78537
78877
|
});
|
|
@@ -78541,9 +78881,9 @@ function createGrTextFromCircuitJson({
|
|
|
78541
78881
|
};
|
|
78542
78882
|
const kicadLayer = layerMap[textElement.layer] || textElement.layer || "F.SilkS";
|
|
78543
78883
|
const fontSize = (textElement.font_size || 1) / 1.5;
|
|
78544
|
-
const font = new
|
|
78884
|
+
const font = new TextEffectsFont7;
|
|
78545
78885
|
font.size = { width: fontSize, height: fontSize };
|
|
78546
|
-
const justify = new
|
|
78886
|
+
const justify = new TextEffectsJustify4;
|
|
78547
78887
|
const anchorAlignment = textElement.anchor_alignment || "center";
|
|
78548
78888
|
switch (anchorAlignment) {
|
|
78549
78889
|
case "top_left":
|
|
@@ -78565,15 +78905,15 @@ function createGrTextFromCircuitJson({
|
|
|
78565
78905
|
case "center":
|
|
78566
78906
|
break;
|
|
78567
78907
|
}
|
|
78568
|
-
const textEffects = new
|
|
78908
|
+
const textEffects = new TextEffects7({
|
|
78569
78909
|
font
|
|
78570
78910
|
});
|
|
78571
78911
|
if (anchorAlignment !== "center") {
|
|
78572
78912
|
textEffects.justify = justify;
|
|
78573
78913
|
}
|
|
78574
78914
|
const rotation = textElement.ccw_rotation || 0;
|
|
78575
|
-
const position = new
|
|
78576
|
-
const grText = new
|
|
78915
|
+
const position = new At2([transformedPos.x, transformedPos.y, rotation]);
|
|
78916
|
+
const grText = new GrText2({
|
|
78577
78917
|
text: textElement.text,
|
|
78578
78918
|
layer: kicadLayer,
|
|
78579
78919
|
effects: textEffects
|
|
@@ -78599,11 +78939,11 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
78599
78939
|
const endPoint = path14.route[i + 1];
|
|
78600
78940
|
if (!startPoint || !endPoint)
|
|
78601
78941
|
continue;
|
|
78602
|
-
const transformedStart =
|
|
78942
|
+
const transformedStart = applyToPoint15(c2kMatPcb, {
|
|
78603
78943
|
x: startPoint.x,
|
|
78604
78944
|
y: startPoint.y
|
|
78605
78945
|
});
|
|
78606
|
-
const transformedEnd =
|
|
78946
|
+
const transformedEnd = applyToPoint15(c2kMatPcb, {
|
|
78607
78947
|
x: endPoint.x,
|
|
78608
78948
|
y: endPoint.y
|
|
78609
78949
|
});
|
|
@@ -78635,6 +78975,18 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
78635
78975
|
kicadPcb.graphicTexts = graphicTexts;
|
|
78636
78976
|
}
|
|
78637
78977
|
}
|
|
78978
|
+
const fabricationNoteTexts = this.ctx.db.pcb_fabrication_note_text?.list() || [];
|
|
78979
|
+
for (const textElement of fabricationNoteTexts) {
|
|
78980
|
+
const grText = createFabricationNoteTextFromCircuitJson({
|
|
78981
|
+
textElement,
|
|
78982
|
+
c2kMatPcb
|
|
78983
|
+
});
|
|
78984
|
+
if (grText) {
|
|
78985
|
+
const graphicTexts = kicadPcb.graphicTexts;
|
|
78986
|
+
graphicTexts.push(grText);
|
|
78987
|
+
kicadPcb.graphicTexts = graphicTexts;
|
|
78988
|
+
}
|
|
78989
|
+
}
|
|
78638
78990
|
const pcbBoards = this.ctx.db.pcb_board?.list() || [];
|
|
78639
78991
|
if (pcbBoards.length > 0) {
|
|
78640
78992
|
const board = pcbBoards[0];
|
|
@@ -78655,7 +79007,7 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
78655
79007
|
{ x: board.center.x - halfWidth, y: board.center.y + halfHeight }
|
|
78656
79008
|
];
|
|
78657
79009
|
}
|
|
78658
|
-
const transformedCorners = corners.map((corner) =>
|
|
79010
|
+
const transformedCorners = corners.map((corner) => applyToPoint15(c2kMatPcb, corner));
|
|
78659
79011
|
for (let i = 0;i < transformedCorners.length; i++) {
|
|
78660
79012
|
const start = transformedCorners[i];
|
|
78661
79013
|
const end = transformedCorners[(i + 1) % transformedCorners.length];
|
|
@@ -78853,6 +79205,9 @@ var ExtractSymbolsStage = class extends ConverterStage {
|
|
|
78853
79205
|
if (!uniqueSymbols.has(symbolName)) {
|
|
78854
79206
|
symbol.libraryId = symbolName;
|
|
78855
79207
|
this.updateFootprintProperty(symbol, fpLibraryName);
|
|
79208
|
+
if (!isCustom) {
|
|
79209
|
+
this.snapPinPositionsToGrid(symbol);
|
|
79210
|
+
}
|
|
78856
79211
|
uniqueSymbols.set(symbolName, {
|
|
78857
79212
|
symbolName,
|
|
78858
79213
|
symbol,
|
|
@@ -78886,10 +79241,34 @@ var ExtractSymbolsStage = class extends ConverterStage {
|
|
|
78886
79241
|
const name = parts.length > 1 ? parts[1] : parts[0];
|
|
78887
79242
|
return name?.replace(/[\\\/]/g, "-").trim() || "symbol";
|
|
78888
79243
|
}
|
|
79244
|
+
snapPinPositionsToGrid(symbol) {
|
|
79245
|
+
const KICAD_GRID = 1.27;
|
|
79246
|
+
for (const subSymbol of symbol.subSymbols ?? []) {
|
|
79247
|
+
for (const pin of subSymbol.pins ?? []) {
|
|
79248
|
+
if (pin.at) {
|
|
79249
|
+
pin.at.x = Math.round(pin.at.x / KICAD_GRID) * KICAD_GRID;
|
|
79250
|
+
pin.at.y = Math.round(pin.at.y / KICAD_GRID) * KICAD_GRID;
|
|
79251
|
+
}
|
|
79252
|
+
}
|
|
79253
|
+
for (const polyline of subSymbol.polylines ?? []) {
|
|
79254
|
+
if (polyline.points?.points) {
|
|
79255
|
+
for (const pt of polyline.points.points) {
|
|
79256
|
+
if ("x" in pt && "y" in pt) {
|
|
79257
|
+
pt.x = Math.round(pt.x / KICAD_GRID) * KICAD_GRID;
|
|
79258
|
+
pt.y = Math.round(pt.y / KICAD_GRID) * KICAD_GRID;
|
|
79259
|
+
}
|
|
79260
|
+
}
|
|
79261
|
+
}
|
|
79262
|
+
}
|
|
79263
|
+
}
|
|
79264
|
+
}
|
|
78889
79265
|
getOutput() {
|
|
78890
79266
|
return this.ctx.libraryOutput;
|
|
78891
79267
|
}
|
|
78892
79268
|
};
|
|
79269
|
+
var KICAD_FP_VERSION = 20240108;
|
|
79270
|
+
var KICAD_FP_GENERATOR = "pcbnew";
|
|
79271
|
+
var KICAD_FP_GENERATOR_VERSION = "8.0";
|
|
78893
79272
|
function getBasename(filePath) {
|
|
78894
79273
|
const parts = filePath.split(/[/\\]/);
|
|
78895
79274
|
return parts[parts.length - 1] || filePath;
|
|
@@ -78953,9 +79332,12 @@ var ExtractFootprintsStage = class extends ConverterStage {
|
|
|
78953
79332
|
const footprintName = (parts.length > 1 ? parts[1] : parts[0])?.replace(/[\\\/]/g, "-").trim() || "footprint";
|
|
78954
79333
|
const isBuiltin = !customFootprintNames.has(footprintName);
|
|
78955
79334
|
footprint.libraryLink = footprintName;
|
|
78956
|
-
footprint.position =
|
|
79335
|
+
footprint.position = At3.from([0, 0, 0]);
|
|
78957
79336
|
footprint.locked = false;
|
|
78958
79337
|
footprint.placed = false;
|
|
79338
|
+
footprint.version = KICAD_FP_VERSION;
|
|
79339
|
+
footprint.generator = KICAD_FP_GENERATOR;
|
|
79340
|
+
footprint.generatorVersion = KICAD_FP_GENERATOR_VERSION;
|
|
78959
79341
|
if (!footprint.descr) {
|
|
78960
79342
|
footprint.descr = "";
|
|
78961
79343
|
}
|
|
@@ -78979,15 +79361,32 @@ var ExtractFootprintsStage = class extends ConverterStage {
|
|
|
78979
79361
|
footprint.path = undefined;
|
|
78980
79362
|
footprint.sheetfile = undefined;
|
|
78981
79363
|
footprint.sheetname = undefined;
|
|
78982
|
-
const defaultFont = new
|
|
79364
|
+
const defaultFont = new TextEffectsFont8;
|
|
78983
79365
|
defaultFont.size = { width: 1.27, height: 1.27 };
|
|
78984
79366
|
defaultFont.thickness = 0.15;
|
|
78985
|
-
const defaultEffects = new
|
|
79367
|
+
const defaultEffects = new TextEffects8({ font: defaultFont });
|
|
79368
|
+
const fpPads = footprint.fpPads ?? [];
|
|
79369
|
+
let minY = 0;
|
|
79370
|
+
let maxY = 0;
|
|
79371
|
+
for (const pad of fpPads) {
|
|
79372
|
+
const at = pad.at;
|
|
79373
|
+
const size = pad.size;
|
|
79374
|
+
if (at && size) {
|
|
79375
|
+
const padY = at.y ?? 0;
|
|
79376
|
+
const padHeight = size.height ?? 0;
|
|
79377
|
+
const padTop = padY - padHeight / 2;
|
|
79378
|
+
const padBottom = padY + padHeight / 2;
|
|
79379
|
+
minY = Math.min(minY, padTop);
|
|
79380
|
+
maxY = Math.max(maxY, padBottom);
|
|
79381
|
+
}
|
|
79382
|
+
}
|
|
79383
|
+
const refY = minY - 0.5;
|
|
79384
|
+
const valY = maxY + 0.5;
|
|
78986
79385
|
footprint.properties = [
|
|
78987
79386
|
new Property({
|
|
78988
79387
|
key: "Reference",
|
|
78989
|
-
value: "
|
|
78990
|
-
position: [0,
|
|
79388
|
+
value: "REF**",
|
|
79389
|
+
position: [0, refY, 0],
|
|
78991
79390
|
layer: "F.SilkS",
|
|
78992
79391
|
uuid: generateDeterministicUuid(`${footprintName}-property-Reference`),
|
|
78993
79392
|
effects: defaultEffects
|
|
@@ -78995,7 +79394,7 @@ var ExtractFootprintsStage = class extends ConverterStage {
|
|
|
78995
79394
|
new Property({
|
|
78996
79395
|
key: "Value",
|
|
78997
79396
|
value: "Val**",
|
|
78998
|
-
position: [0,
|
|
79397
|
+
position: [0, valY, 0],
|
|
78999
79398
|
layer: "F.Fab",
|
|
79000
79399
|
uuid: generateDeterministicUuid(`${footprintName}-property-Value`),
|
|
79001
79400
|
effects: defaultEffects
|
|
@@ -79237,6 +79636,23 @@ function renameKicadFootprint(params2) {
|
|
|
79237
79636
|
model3dSourcePaths: kicadFootprint.model3dSourcePaths
|
|
79238
79637
|
};
|
|
79239
79638
|
}
|
|
79639
|
+
function createTextEffects(metadataEffects) {
|
|
79640
|
+
const font = new TextEffectsFont9;
|
|
79641
|
+
if (metadataEffects?.font?.size) {
|
|
79642
|
+
font.size = {
|
|
79643
|
+
width: Number(metadataEffects.font.size.x),
|
|
79644
|
+
height: Number(metadataEffects.font.size.y)
|
|
79645
|
+
};
|
|
79646
|
+
} else {
|
|
79647
|
+
font.size = { width: 1.27, height: 1.27 };
|
|
79648
|
+
}
|
|
79649
|
+
if (metadataEffects?.font?.thickness !== undefined) {
|
|
79650
|
+
font.thickness = Number(metadataEffects.font.thickness);
|
|
79651
|
+
} else {
|
|
79652
|
+
font.thickness = 0.15;
|
|
79653
|
+
}
|
|
79654
|
+
return new TextEffects9({ font });
|
|
79655
|
+
}
|
|
79240
79656
|
function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
|
|
79241
79657
|
try {
|
|
79242
79658
|
const parsed = parseKicadSexpr3(kicadModString);
|
|
@@ -79255,10 +79671,6 @@ function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
|
|
|
79255
79671
|
}
|
|
79256
79672
|
if (metadata.embeddedFonts !== undefined) {}
|
|
79257
79673
|
if (metadata.properties) {
|
|
79258
|
-
const defaultFont = new TextEffectsFont7;
|
|
79259
|
-
defaultFont.size = { width: 1.27, height: 1.27 };
|
|
79260
|
-
defaultFont.thickness = 0.15;
|
|
79261
|
-
const defaultEffects = new TextEffects7({ font: defaultFont });
|
|
79262
79674
|
const newProperties = [];
|
|
79263
79675
|
const refMeta = metadata.properties.Reference;
|
|
79264
79676
|
newProperties.push(new Property2({
|
|
@@ -79271,7 +79683,7 @@ function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
|
|
|
79271
79683
|
] : [0, 0, 0],
|
|
79272
79684
|
layer: refMeta?.layer ?? "F.SilkS",
|
|
79273
79685
|
uuid: refMeta?.uuid ?? generateDeterministicUuid(`${footprintName}-property-Reference`),
|
|
79274
|
-
effects:
|
|
79686
|
+
effects: createTextEffects(refMeta?.effects),
|
|
79275
79687
|
hidden: refMeta?.hide
|
|
79276
79688
|
}));
|
|
79277
79689
|
const valMeta = metadata.properties.Value;
|
|
@@ -79285,7 +79697,7 @@ function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
|
|
|
79285
79697
|
] : [0, 0, 0],
|
|
79286
79698
|
layer: valMeta?.layer ?? "F.Fab",
|
|
79287
79699
|
uuid: valMeta?.uuid ?? generateDeterministicUuid(`${footprintName}-property-Value`),
|
|
79288
|
-
effects:
|
|
79700
|
+
effects: createTextEffects(valMeta?.effects),
|
|
79289
79701
|
hidden: valMeta?.hide
|
|
79290
79702
|
}));
|
|
79291
79703
|
const dsMeta = metadata.properties.Datasheet;
|
|
@@ -79299,7 +79711,7 @@ function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
|
|
|
79299
79711
|
] : [0, 0, 0],
|
|
79300
79712
|
layer: dsMeta?.layer ?? "F.Fab",
|
|
79301
79713
|
uuid: dsMeta?.uuid ?? generateDeterministicUuid(`${footprintName}-property-Datasheet`),
|
|
79302
|
-
effects:
|
|
79714
|
+
effects: createTextEffects(dsMeta?.effects),
|
|
79303
79715
|
hidden: dsMeta?.hide ?? true
|
|
79304
79716
|
}));
|
|
79305
79717
|
const descMeta = metadata.properties.Description;
|
|
@@ -79313,7 +79725,7 @@ function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
|
|
|
79313
79725
|
] : [0, 0, 0],
|
|
79314
79726
|
layer: descMeta?.layer ?? "F.Fab",
|
|
79315
79727
|
uuid: descMeta?.uuid ?? generateDeterministicUuid(`${footprintName}-property-Description`),
|
|
79316
|
-
effects:
|
|
79728
|
+
effects: createTextEffects(descMeta?.effects),
|
|
79317
79729
|
hidden: descMeta?.hide ?? true
|
|
79318
79730
|
}));
|
|
79319
79731
|
footprint.properties = newProperties;
|
|
@@ -79476,16 +79888,16 @@ var toNumber = (value, fallback) => {
|
|
|
79476
79888
|
return fallback;
|
|
79477
79889
|
return parsed;
|
|
79478
79890
|
};
|
|
79479
|
-
var
|
|
79891
|
+
var createTextEffects2 = (effectsMeta, fallback) => {
|
|
79480
79892
|
if (!effectsMeta)
|
|
79481
79893
|
return fallback;
|
|
79482
|
-
const effects = new
|
|
79894
|
+
const effects = new TextEffects10({
|
|
79483
79895
|
font: fallback?.font,
|
|
79484
79896
|
justify: fallback?.justify,
|
|
79485
79897
|
hiddenText: fallback?.hiddenText ?? false
|
|
79486
79898
|
});
|
|
79487
79899
|
if (!effects.font) {
|
|
79488
|
-
const defaultFont = new
|
|
79900
|
+
const defaultFont = new TextEffectsFont10;
|
|
79489
79901
|
defaultFont.size = { width: DEFAULT_TEXT_SIZE, height: DEFAULT_TEXT_SIZE };
|
|
79490
79902
|
effects.font = defaultFont;
|
|
79491
79903
|
}
|
|
@@ -79530,7 +79942,7 @@ var createJustify = (justifyInput) => {
|
|
|
79530
79942
|
if (!options.horizontal && !options.vertical && !options.mirror) {
|
|
79531
79943
|
return;
|
|
79532
79944
|
}
|
|
79533
|
-
return new
|
|
79945
|
+
return new TextEffectsJustify5(options);
|
|
79534
79946
|
};
|
|
79535
79947
|
var applySymbolProperty = (symbol, key, propertyMeta) => {
|
|
79536
79948
|
const existingProperty = symbol.properties.find((prop) => prop.key === key);
|
|
@@ -79540,7 +79952,7 @@ var applySymbolProperty = (symbol, key, propertyMeta) => {
|
|
|
79540
79952
|
toNumber(propertyMeta.at.y, 0),
|
|
79541
79953
|
toNumber(propertyMeta.at.rotation, 0)
|
|
79542
79954
|
] : existingProperty?.at;
|
|
79543
|
-
const nextEffects =
|
|
79955
|
+
const nextEffects = createTextEffects2(propertyMeta.effects, existingProperty?.effects);
|
|
79544
79956
|
if (existingProperty) {
|
|
79545
79957
|
existingProperty.value = propertyMeta.value;
|
|
79546
79958
|
if (nextId !== undefined) {
|
|
@@ -79600,7 +80012,9 @@ function applyKicadSymbolMetadata(kicadSymbol, metadata) {
|
|
|
79600
80012
|
}
|
|
79601
80013
|
return kicadSymbol;
|
|
79602
80014
|
}
|
|
80015
|
+
var addedSymbolNames = /* @__PURE__ */ new Set;
|
|
79603
80016
|
function classifyKicadSymbols(ctx) {
|
|
80017
|
+
addedSymbolNames.clear();
|
|
79604
80018
|
for (const extractedKicadComponent of ctx.extractedKicadComponents) {
|
|
79605
80019
|
classifySymbolsForComponent({
|
|
79606
80020
|
ctx,
|
|
@@ -79618,25 +80032,21 @@ function classifySymbolsForComponent({
|
|
|
79618
80032
|
const metadata = ctx.symbolMetadataMap.get(tscircuitComponentName);
|
|
79619
80033
|
for (const kicadSymbol of kicadSymbols) {
|
|
79620
80034
|
if (!kicadSymbol.isBuiltin) {
|
|
79621
|
-
|
|
79622
|
-
|
|
79623
|
-
|
|
80035
|
+
const symbolName = kicadSymbol.symbolName;
|
|
80036
|
+
if (addedSymbolNames.has(symbolName)) {
|
|
80037
|
+
continue;
|
|
80038
|
+
}
|
|
80039
|
+
addedSymbolNames.add(symbolName);
|
|
80040
|
+
if (hasCustomFootprint) {
|
|
80041
|
+
updateKicadSymbolFootprint({
|
|
79624
80042
|
kicadSymbol,
|
|
79625
|
-
|
|
80043
|
+
kicadLibraryName: ctx.kicadLibraryName,
|
|
80044
|
+
kicadFootprintName: tscircuitComponentName,
|
|
80045
|
+
isPcm: ctx.isPcm
|
|
79626
80046
|
});
|
|
79627
|
-
if (hasCustomFootprint) {
|
|
79628
|
-
updateKicadSymbolFootprint({
|
|
79629
|
-
kicadSymbol: renamedSymbol,
|
|
79630
|
-
kicadLibraryName: ctx.kicadLibraryName,
|
|
79631
|
-
kicadFootprintName: tscircuitComponentName,
|
|
79632
|
-
isPcm: ctx.isPcm
|
|
79633
|
-
});
|
|
79634
|
-
}
|
|
79635
|
-
const updatedSymbol = metadata ? applyKicadSymbolMetadata(renamedSymbol, metadata) : renamedSymbol;
|
|
79636
|
-
addUserSymbol({ ctx, kicadSymbol: updatedSymbol });
|
|
79637
|
-
} else {
|
|
79638
|
-
addUserSymbol({ ctx, kicadSymbol });
|
|
79639
80047
|
}
|
|
80048
|
+
const updatedSymbol = metadata ? applyKicadSymbolMetadata(kicadSymbol, metadata) : kicadSymbol;
|
|
80049
|
+
addUserSymbol({ ctx, kicadSymbol: updatedSymbol });
|
|
79640
80050
|
} else if (hasCustomFootprint && !hasAddedUserSymbol) {
|
|
79641
80051
|
hasAddedUserSymbol = true;
|
|
79642
80052
|
const renamedSymbol = renameKicadSymbol({
|
|
@@ -79663,10 +80073,11 @@ function addUserSymbol({
|
|
|
79663
80073
|
ctx,
|
|
79664
80074
|
kicadSymbol
|
|
79665
80075
|
}) {
|
|
79666
|
-
const
|
|
79667
|
-
if (
|
|
79668
|
-
|
|
80076
|
+
const alreadyExistsByName = ctx.userKicadSymbols.some((s) => s.symbolName === kicadSymbol.symbolName);
|
|
80077
|
+
if (alreadyExistsByName) {
|
|
80078
|
+
return;
|
|
79669
80079
|
}
|
|
80080
|
+
ctx.userKicadSymbols.push(kicadSymbol);
|
|
79670
80081
|
}
|
|
79671
80082
|
function addBuiltinSymbol({
|
|
79672
80083
|
ctx,
|
|
@@ -85022,7 +85433,7 @@ import {
|
|
|
85022
85433
|
import { convertCircuitJsonToGltf } from "circuit-json-to-gltf";
|
|
85023
85434
|
|
|
85024
85435
|
// node_modules/dsn-converter/dist/index.js
|
|
85025
|
-
import { applyToPoint as
|
|
85436
|
+
import { applyToPoint as applyToPoint16, scale as scale4 } from "transformation-matrix";
|
|
85026
85437
|
import { su as su4 } from "@tscircuit/soup-util";
|
|
85027
85438
|
import { su as su22 } from "@tscircuit/soup-util";
|
|
85028
85439
|
import Debug3 from "debug";
|
|
@@ -85190,7 +85601,7 @@ function processComponentsAndPads(componentGroups, circuitElements, pcb) {
|
|
|
85190
85601
|
const sourceComponent = su4(circuitElements).source_component.list().find((e) => e.source_component_id === pcbComponent?.source_component_id);
|
|
85191
85602
|
const footprintName = getFootprintName(sourceComponent, pcbComponent);
|
|
85192
85603
|
const componentName = sourceComponent?.name || "Unknown";
|
|
85193
|
-
const circuitSpaceCoordinates =
|
|
85604
|
+
const circuitSpaceCoordinates = applyToPoint16(transformMmToUm, pcbComponent.center);
|
|
85194
85605
|
if (!componentsByFootprint.has(footprintName)) {
|
|
85195
85606
|
componentsByFootprint.set(footprintName, []);
|
|
85196
85607
|
}
|
|
@@ -95267,7 +95678,7 @@ var any_circuit_element = external_exports.union([
|
|
|
95267
95678
|
var any_soup_element = any_circuit_element;
|
|
95268
95679
|
expectTypesMatch(true);
|
|
95269
95680
|
expectStringUnionsMatch(true);
|
|
95270
|
-
function
|
|
95681
|
+
function applyToPoint18(matrix, point2) {
|
|
95271
95682
|
return Array.isArray(point2) ? [
|
|
95272
95683
|
matrix.a * point2[0] + matrix.c * point2[1] + matrix.e,
|
|
95273
95684
|
matrix.b * point2[0] + matrix.d * point2[1] + matrix.f
|
|
@@ -95319,7 +95730,7 @@ function isUndefined2(val) {
|
|
|
95319
95730
|
return typeof val === "undefined";
|
|
95320
95731
|
}
|
|
95321
95732
|
var { cos, sin, PI } = Math;
|
|
95322
|
-
function
|
|
95733
|
+
function rotate6(angle, cx2, cy2) {
|
|
95323
95734
|
const cosAngle = cos(angle);
|
|
95324
95735
|
const sinAngle = sin(angle);
|
|
95325
95736
|
const rotationMatrix = {
|
|
@@ -95340,7 +95751,7 @@ function rotate5(angle, cx2, cy2) {
|
|
|
95340
95751
|
]);
|
|
95341
95752
|
}
|
|
95342
95753
|
function rotateDEG(angle, cx2 = undefined, cy2 = undefined) {
|
|
95343
|
-
return
|
|
95754
|
+
return rotate6(angle * PI / 180, cx2, cy2);
|
|
95344
95755
|
}
|
|
95345
95756
|
function scale6(sx2, sy2 = undefined, cx2 = undefined, cy2 = undefined) {
|
|
95346
95757
|
if (isUndefined2(sy2))
|
|
@@ -95362,7 +95773,7 @@ function scale6(sx2, sy2 = undefined, cx2 = undefined, cy2 = undefined) {
|
|
|
95362
95773
|
translate4(-cx2, -cy2)
|
|
95363
95774
|
]);
|
|
95364
95775
|
}
|
|
95365
|
-
function
|
|
95776
|
+
function identity5() {
|
|
95366
95777
|
return {
|
|
95367
95778
|
a: 1,
|
|
95368
95779
|
c: 0,
|
|
@@ -96236,25 +96647,25 @@ var oppositeSide = (sideOrDir) => {
|
|
|
96236
96647
|
};
|
|
96237
96648
|
var transformSchematicElement = (elm, matrix) => {
|
|
96238
96649
|
if (elm.type === "schematic_component") {
|
|
96239
|
-
elm.center =
|
|
96650
|
+
elm.center = applyToPoint18(matrix, elm.center);
|
|
96240
96651
|
} else if (elm.type === "schematic_port") {
|
|
96241
|
-
elm.center =
|
|
96652
|
+
elm.center = applyToPoint18(matrix, elm.center);
|
|
96242
96653
|
if (elm.facing_direction) {
|
|
96243
96654
|
elm.facing_direction = rotateDirection(elm.facing_direction, -(Math.atan2(matrix.b, matrix.a) / Math.PI) * 2);
|
|
96244
96655
|
}
|
|
96245
96656
|
} else if (elm.type === "schematic_text") {
|
|
96246
|
-
elm.position =
|
|
96657
|
+
elm.position = applyToPoint18(matrix, elm.position);
|
|
96247
96658
|
} else if (elm.type === "schematic_trace") {
|
|
96248
96659
|
const anyElm = elm;
|
|
96249
96660
|
anyElm.route = (anyElm.route ?? []).map((rp2) => {
|
|
96250
|
-
const tp2 =
|
|
96661
|
+
const tp2 = applyToPoint18(matrix, rp2);
|
|
96251
96662
|
rp2.x = tp2.x;
|
|
96252
96663
|
rp2.y = tp2.y;
|
|
96253
96664
|
return rp2;
|
|
96254
96665
|
});
|
|
96255
96666
|
if (Array.isArray(anyElm.junctions)) {
|
|
96256
96667
|
anyElm.junctions = anyElm.junctions.map((j2) => {
|
|
96257
|
-
const tp2 =
|
|
96668
|
+
const tp2 = applyToPoint18(matrix, j2);
|
|
96258
96669
|
j2.x = tp2.x;
|
|
96259
96670
|
j2.y = tp2.y;
|
|
96260
96671
|
return j2;
|
|
@@ -96262,18 +96673,18 @@ var transformSchematicElement = (elm, matrix) => {
|
|
|
96262
96673
|
}
|
|
96263
96674
|
if (Array.isArray(anyElm.edges)) {
|
|
96264
96675
|
anyElm.edges = anyElm.edges.map((e3) => {
|
|
96265
|
-
e3.from =
|
|
96266
|
-
e3.to =
|
|
96676
|
+
e3.from = applyToPoint18(matrix, e3.from);
|
|
96677
|
+
e3.to = applyToPoint18(matrix, e3.to);
|
|
96267
96678
|
return e3;
|
|
96268
96679
|
});
|
|
96269
96680
|
}
|
|
96270
96681
|
} else if (elm.type === "schematic_box") {
|
|
96271
|
-
const { x, y } =
|
|
96682
|
+
const { x, y } = applyToPoint18(matrix, { x: elm.x, y: elm.y });
|
|
96272
96683
|
elm.x = x;
|
|
96273
96684
|
elm.y = y;
|
|
96274
96685
|
} else if (elm.type === "schematic_line") {
|
|
96275
|
-
const { x: x12, y: y12 } =
|
|
96276
|
-
const { x: x22, y: y22 } =
|
|
96686
|
+
const { x: x12, y: y12 } = applyToPoint18(matrix, { x: elm.x1, y: elm.y1 });
|
|
96687
|
+
const { x: x22, y: y22 } = applyToPoint18(matrix, { x: elm.x2, y: elm.y2 });
|
|
96277
96688
|
elm.x1 = x12;
|
|
96278
96689
|
elm.y1 = y12;
|
|
96279
96690
|
elm.x2 = x22;
|
|
@@ -96288,20 +96699,20 @@ var transformPCBElement = (elm, matrix) => {
|
|
|
96288
96699
|
const tsr = decomposeTSR(matrix);
|
|
96289
96700
|
const flipPadWidthHeight = Math.round(tsr.rotation.angle / (Math.PI / 2)) % 2 === 1;
|
|
96290
96701
|
if (elm.type === "pcb_plated_hole" || elm.type === "pcb_hole" || elm.type === "pcb_via" || elm.type === "pcb_smtpad" || elm.type === "pcb_port") {
|
|
96291
|
-
const { x, y } =
|
|
96702
|
+
const { x, y } = applyToPoint18(matrix, {
|
|
96292
96703
|
x: Number(elm.x),
|
|
96293
96704
|
y: Number(elm.y)
|
|
96294
96705
|
});
|
|
96295
96706
|
elm.x = x;
|
|
96296
96707
|
elm.y = y;
|
|
96297
96708
|
} else if (elm.type === "pcb_keepout" || elm.type === "pcb_board") {
|
|
96298
|
-
elm.center =
|
|
96709
|
+
elm.center = applyToPoint18(matrix, elm.center);
|
|
96299
96710
|
} else if (elm.type === "pcb_silkscreen_text" || elm.type === "pcb_fabrication_note_text") {
|
|
96300
|
-
elm.anchor_position =
|
|
96711
|
+
elm.anchor_position = applyToPoint18(matrix, elm.anchor_position);
|
|
96301
96712
|
} else if (elm.type === "pcb_silkscreen_circle" || elm.type === "pcb_silkscreen_rect") {
|
|
96302
|
-
elm.center =
|
|
96713
|
+
elm.center = applyToPoint18(matrix, elm.center);
|
|
96303
96714
|
} else if (elm.type === "pcb_component") {
|
|
96304
|
-
elm.center =
|
|
96715
|
+
elm.center = applyToPoint18(matrix, elm.center);
|
|
96305
96716
|
elm.rotation = elm.rotation + tsr.rotation.angle / Math.PI * 180;
|
|
96306
96717
|
elm.rotation = elm.rotation % 360;
|
|
96307
96718
|
if (flipPadWidthHeight) {
|
|
@@ -96309,7 +96720,7 @@ var transformPCBElement = (elm, matrix) => {
|
|
|
96309
96720
|
}
|
|
96310
96721
|
} else if (elm.type === "pcb_silkscreen_path" || elm.type === "pcb_trace" || elm.type === "pcb_fabrication_note_path") {
|
|
96311
96722
|
elm.route = elm.route.map((rp2) => {
|
|
96312
|
-
const tp2 =
|
|
96723
|
+
const tp2 = applyToPoint18(matrix, rp2);
|
|
96313
96724
|
rp2.x = tp2.x;
|
|
96314
96725
|
rp2.y = tp2.y;
|
|
96315
96726
|
return rp2;
|
|
@@ -96317,14 +96728,14 @@ var transformPCBElement = (elm, matrix) => {
|
|
|
96317
96728
|
} else if (elm.type === "pcb_silkscreen_line") {
|
|
96318
96729
|
const p12 = { x: elm.x1, y: elm.y1 };
|
|
96319
96730
|
const p22 = { x: elm.x2, y: elm.y2 };
|
|
96320
|
-
const p1t =
|
|
96321
|
-
const p2t =
|
|
96731
|
+
const p1t = applyToPoint18(matrix, p12);
|
|
96732
|
+
const p2t = applyToPoint18(matrix, p22);
|
|
96322
96733
|
elm.x1 = p1t.x;
|
|
96323
96734
|
elm.y1 = p1t.y;
|
|
96324
96735
|
elm.x2 = p2t.x;
|
|
96325
96736
|
elm.y2 = p2t.y;
|
|
96326
96737
|
} else if (elm.type === "cad_component") {
|
|
96327
|
-
const newPos =
|
|
96738
|
+
const newPos = applyToPoint18(matrix, {
|
|
96328
96739
|
x: elm.position.x,
|
|
96329
96740
|
y: elm.position.y
|
|
96330
96741
|
});
|
|
@@ -97183,7 +97594,7 @@ var E = (t, o) => {
|
|
|
97183
97594
|
}), c = a.map((p) => ({ ...p, ..._(n, p) }));
|
|
97184
97595
|
return { primitives: m, center: l, ports: c, size: y, ...o };
|
|
97185
97596
|
};
|
|
97186
|
-
var
|
|
97597
|
+
var At4 = (t, o) => {
|
|
97187
97598
|
let { newOrientation: i, overrides: l } = o, a = { up: Math.PI / 2, right: 0, down: -Math.PI / 2, left: -Math.PI }, y = sr(i ? a[i] : Math.PI / 2, t.center.x, t.center.y), { primitives: n, center: m, size: c, ports: p } = t, x = n.map((h) => {
|
|
97188
97599
|
switch (h = { ...h }, h.type) {
|
|
97189
97600
|
case "path":
|
|
@@ -97201,7 +97612,7 @@ var At3 = (t, o) => {
|
|
|
97201
97612
|
}), f = p.map((h) => ({ ...h, ..._(y, h) })), d = _t(x);
|
|
97202
97613
|
return { primitives: x, center: m, ports: f, size: { width: d.maxX - d.minX, height: d.maxY - d.minY }, ...l };
|
|
97203
97614
|
};
|
|
97204
|
-
var r = (t, o = "down", i = {}) =>
|
|
97615
|
+
var r = (t, o = "down", i = {}) => At4(t, { newOrientation: o, overrides: i });
|
|
97205
97616
|
var nr = class {
|
|
97206
97617
|
symbol;
|
|
97207
97618
|
constructor(o) {
|
|
@@ -97214,7 +97625,7 @@ var nr = class {
|
|
|
97214
97625
|
return this.symbol = { ...this.symbol, ports: this.symbol.ports.map((l) => l.labels.includes(o) ? { ...l, labels: i } : l) }, this;
|
|
97215
97626
|
}
|
|
97216
97627
|
rotateRightFacingSymbol(o) {
|
|
97217
|
-
return this.symbol =
|
|
97628
|
+
return this.symbol = At4(this.symbol, { newOrientation: o }), this;
|
|
97218
97629
|
}
|
|
97219
97630
|
computeSize() {
|
|
97220
97631
|
let o = _t(this.symbol.primitives);
|
|
@@ -97280,7 +97691,7 @@ function s(t) {
|
|
|
97280
97691
|
var wp = { paths: { path43: { type: "path", points: [{ x: -0.06, y: 0.19 }, { x: -0.06, y: -0.12 }], color: "primary", fill: false }, "path43-6": { type: "path", points: [{ x: 0.02, y: 0.13 }, { x: 0.02, y: -0.06 }], color: "primary", fill: false }, path44: { type: "path", points: [{ x: -0.06, y: 0.03 }, { x: -0.45, y: 0.03 }], color: "primary", fill: false }, "path44-0": { type: "path", points: [{ x: 0.45, y: 0.03 }, { x: 0.03, y: 0.03 }], color: "primary", fill: false } }, texts: { top1: { type: "text", text: "{REF}", x: -0.03, y: 0.27 }, bottom1: { type: "text", text: "{VAL}", x: -0.03, y: -0.28 } }, refblocks: { left1: { x: -0.45, y: 0.03 }, right1: { x: 0.45, y: 0.03 } }, bounds: { minX: -0.47, maxX: 0.47, minY: -0.38, maxY: 0.27, width: 0.95, height: 0.29, centerX: 0, centerY: 0.06 }, circles: {} };
|
|
97281
97692
|
var { paths: Cf, texts: Ap, bounds: Ht, refblocks: Pp, circles: Nf } = wp;
|
|
97282
97693
|
var Zt = s({ primitives: [...Object.values(Cf), ...Object.values(Nf), { ...Ap.top1, anchor: "middle_bottom" }, { ...Ap.bottom1, anchor: "middle_top" }], ports: [{ ...Pp.left1, labels: ["1"] }, { ...Pp.right1, labels: ["2"] }], size: { width: Ht.width, height: Ht.height }, center: { x: Ht.centerX, y: Ht.centerY } });
|
|
97283
|
-
var Sp =
|
|
97694
|
+
var Sp = At4(Zt, { newOrientation: "up" });
|
|
97284
97695
|
var j = { paths: { path1: { type: "path", points: [{ x: -0.53, y: 0.05 }, { x: -0.25, y: 0.05 }], color: "primary", fill: false }, path2: { type: "path", points: [{ x: 0.28, y: 0.05 }, { x: 0.57, y: 0.05 }], color: "primary", fill: false }, path3: { type: "path", points: [{ x: 0.02, y: 0.18 }, { x: 0.28, y: 0.18 }, { x: 0.28, y: -0.09 }, { x: -0.25, y: -0.09 }, { x: -0.25, y: 0.18 }, { x: 0.02, y: 0.18 }], color: "primary", fill: false } }, texts: { top1: { type: "text", text: "{REF}", x: 0, y: 0.25 }, bottom1: { type: "text", text: "{VAL}", x: 0, y: -0.25 } }, refblocks: { left1: { x: -0.53, y: 0.05 }, right1: { x: 0.57, y: 0.05 } }, bounds: { minX: -0.56, maxX: 0.56, minY: -0.25, maxY: 0.25, width: 1.12, height: 0.5, centerX: 0, centerY: 0 }, circles: {} };
|
|
97285
97696
|
var { paths: Bf, texts: q5, bounds: Fp, refblocks: Rp, circles: qf } = j;
|
|
97286
97697
|
var Tp = e({ primitives: [...Object.values(Bf), ...Object.values(qf), { type: "text", text: "{REF}", x: -0.16, y: 0.2294553499999995 }, { type: "text", text: "{VAL}", x: 0.16, y: 0.2294553499999995 }], ports: [{ ...Rp.left1, labels: ["1"] }, { ...Rp.right1, labels: ["2"] }], center: { x: Fp.centerX, y: Fp.centerY } }).changeTextAnchor("{VAL}", "middle_bottom").rotateRightFacingSymbol("down").labelPort("left1", ["1"]).labelPort("right1", ["2"]).changeTextAnchor("{REF}", "middle_left").build();
|
|
@@ -97502,7 +97913,7 @@ Ir.x = 0.46;
|
|
|
97502
97913
|
Ir.y += 0.265;
|
|
97503
97914
|
Br.y -= 0.265;
|
|
97504
97915
|
Br.x = 0.46;
|
|
97505
|
-
var
|
|
97916
|
+
var Xy5 = Nr;
|
|
97506
97917
|
var Ly = { paths: { path11: { type: "path", points: [{ x: -0.38, y: 0.06 }, { x: -0.14, y: 0.06 }], color: "primary", fill: false }, "path11-0": { type: "path", points: [{ x: -0.09, y: 0.07 }, { x: 0.1, y: 0.2 }], color: "primary", fill: false }, path12: { type: "path", points: [{ x: 0.13, y: 0.06 }, { x: 0.38, y: 0.06 }], color: "primary", fill: false }, "path11-5": { type: "path", points: [{ x: -0.38, y: -0.17 }, { x: -0.14, y: -0.17 }], color: "primary", fill: false }, "path11-0-3": { type: "path", points: [{ x: -0.09, y: -0.16 }, { x: 0.1, y: -0.03 }], color: "primary", fill: false }, "path12-0": { type: "path", points: [{ x: 0.13, y: -0.17 }, { x: 0.38, y: -0.17 }], color: "primary", fill: false } }, texts: { top1: { type: "text", text: "{REF}", x: 0, y: 0.42 }, bottom1: { type: "text", text: "{VAL}", x: 0, y: -0.42 } }, refblocks: { left1: { x: -0.38, y: -0.17 }, left3: { x: -0.38, y: 0.06 }, right1: { x: 0.38, y: -0.17 }, right3: { x: 0.38, y: 0.06 } }, bounds: { minX: -0.4, maxX: 0.4, minY: -0.4, maxY: 0.4, width: 0.81, height: 0.79, centerX: 0, centerY: 0 }, circles: { "circle-4": { type: "circle", x: 0.1, y: 0.06, radius: 0.02, color: "primary", fill: false }, "circle-2": { type: "circle", x: 0.1, y: -0.17, radius: 0.02, color: "primary", fill: false }, "circle-3": { type: "circle", x: -0.11, y: 0.06, radius: 0.02, color: "primary", fill: false }, "circle-1": { type: "circle", x: -0.11, y: -0.17, radius: 0.02, color: "primary", fill: false } } };
|
|
97507
97918
|
var q = e(Ly).labelPort("left1", ["1"]).labelPort("right1", ["2"]).labelPort("right3", ["4"]).labelPort("left3", ["3"]).changeTextAnchor("{REF}", "middle_bottom").changeTextAnchor("{VAL}", "middle_top").build();
|
|
97508
97919
|
var qr = r(q, "down");
|
|
@@ -98373,7 +98784,7 @@ var jb = Il.primitives.find((t) => t.type === "text" && t.text === "{VAL}");
|
|
|
98373
98784
|
Vb.anchor = "middle_left";
|
|
98374
98785
|
jb.anchor = "middle_right";
|
|
98375
98786
|
var tf = Il;
|
|
98376
|
-
var ef = { ac_voltmeter_down: Wl, ac_voltmeter_horz: Zl, ac_voltmeter_left: Kl, ac_voltmeter_right: ep, ac_voltmeter_up: op, ac_voltmeter_vert: lp, avalanche_diode_down: ap, avalanche_diode_horz: yp, avalanche_diode_left: sp, avalanche_diode_right: mp, avalanche_diode_up: fp, avalanche_diode_vert: cp, backward_diode_down: bp, backward_diode_left: Ut, backward_diode_right: up, backward_diode_up: vp, battery_horz: Zt, battery_vert: Sp, boxresistor_down: Tp, boxresistor_left: Xp, boxresistor_right: jp, boxresistor_small_down: zp, boxresistor_small_left: Jp, boxresistor_small_right: Mp, boxresistor_small_up: Np, boxresistor_up: qp, bridged_ground_down: Up, bridged_ground_left: Zp, bridged_ground_right: re, bridged_ground_up: ta, capacitor_down: ra, capacitor_left: oa, capacitor_polarized_down: la, capacitor_polarized_left: pa, capacitor_polarized_right: ya, capacitor_polarized_up: sa, capacitor_right: ma, capacitor_up: fa, constant_current_diode_down: ca, constant_current_diode_horz: da, constant_current_diode_left: _a, constant_current_diode_right: ga, constant_current_diode_up: va, constant_current_diode_vert: Aa, crystal_4pin_down: Pa, crystal_4pin_left: Sa, crystal_4pin_right: Fa, crystal_4pin_up: Ra, crystal_down: Ea, crystal_left: Ya, crystal_right: Xa, crystal_up: Va, darlington_pair_transistor_down: ja, darlington_pair_transistor_horz: ka, darlington_pair_transistor_left: za, darlington_pair_transistor_right: Oa, darlington_pair_transistor_up: Ja, darlington_pair_transistor_vert: $a, dc_ammeter_horz: Pt, dc_ammeter_vert: Ia, dc_voltmeter_down: qa, dc_voltmeter_horz: Ga, dc_voltmeter_left: Wa, dc_voltmeter_right: Za, dc_voltmeter_up: Ka, dc_voltmeter_vert: ey, diac_down: ry, diac_horz: oy, diac_left: iy, diac_right: ly, diac_up: py, diac_vert: ay, digital_ground_down: xy, digital_ground_left: my, digital_ground_right: fy, digital_ground_up: cy, diode_down: by, diode_left: _y, diode_right: C, diode_up: gy, dpdt_normally_closed_switch_down: vy, dpdt_normally_closed_switch_left: wy, dpdt_normally_closed_switch_right: N, dpdt_normally_closed_switch_up: Ay, dpdt_switch_down: Sy, dpdt_switch_left: Fy, dpdt_switch_right: I, dpdt_switch_up: Ry, dpst_normally_closed_switch_down: Ey, dpst_normally_closed_switch_left: Yy, dpst_normally_closed_switch_right: B, dpst_normally_closed_switch_up:
|
|
98787
|
+
var ef = { ac_voltmeter_down: Wl, ac_voltmeter_horz: Zl, ac_voltmeter_left: Kl, ac_voltmeter_right: ep, ac_voltmeter_up: op, ac_voltmeter_vert: lp, avalanche_diode_down: ap, avalanche_diode_horz: yp, avalanche_diode_left: sp, avalanche_diode_right: mp, avalanche_diode_up: fp, avalanche_diode_vert: cp, backward_diode_down: bp, backward_diode_left: Ut, backward_diode_right: up, backward_diode_up: vp, battery_horz: Zt, battery_vert: Sp, boxresistor_down: Tp, boxresistor_left: Xp, boxresistor_right: jp, boxresistor_small_down: zp, boxresistor_small_left: Jp, boxresistor_small_right: Mp, boxresistor_small_up: Np, boxresistor_up: qp, bridged_ground_down: Up, bridged_ground_left: Zp, bridged_ground_right: re, bridged_ground_up: ta, capacitor_down: ra, capacitor_left: oa, capacitor_polarized_down: la, capacitor_polarized_left: pa, capacitor_polarized_right: ya, capacitor_polarized_up: sa, capacitor_right: ma, capacitor_up: fa, constant_current_diode_down: ca, constant_current_diode_horz: da, constant_current_diode_left: _a, constant_current_diode_right: ga, constant_current_diode_up: va, constant_current_diode_vert: Aa, crystal_4pin_down: Pa, crystal_4pin_left: Sa, crystal_4pin_right: Fa, crystal_4pin_up: Ra, crystal_down: Ea, crystal_left: Ya, crystal_right: Xa, crystal_up: Va, darlington_pair_transistor_down: ja, darlington_pair_transistor_horz: ka, darlington_pair_transistor_left: za, darlington_pair_transistor_right: Oa, darlington_pair_transistor_up: Ja, darlington_pair_transistor_vert: $a, dc_ammeter_horz: Pt, dc_ammeter_vert: Ia, dc_voltmeter_down: qa, dc_voltmeter_horz: Ga, dc_voltmeter_left: Wa, dc_voltmeter_right: Za, dc_voltmeter_up: Ka, dc_voltmeter_vert: ey, diac_down: ry, diac_horz: oy, diac_left: iy, diac_right: ly, diac_up: py, diac_vert: ay, digital_ground_down: xy, digital_ground_left: my, digital_ground_right: fy, digital_ground_up: cy, diode_down: by, diode_left: _y, diode_right: C, diode_up: gy, dpdt_normally_closed_switch_down: vy, dpdt_normally_closed_switch_left: wy, dpdt_normally_closed_switch_right: N, dpdt_normally_closed_switch_up: Ay, dpdt_switch_down: Sy, dpdt_switch_left: Fy, dpdt_switch_right: I, dpdt_switch_up: Ry, dpst_normally_closed_switch_down: Ey, dpst_normally_closed_switch_left: Yy, dpst_normally_closed_switch_right: B, dpst_normally_closed_switch_up: Xy5, dpst_switch_down: Vy, dpst_switch_left: jy, dpst_switch_right: q, dpst_switch_up: ky2, ferrite_bead_down: Oy, ferrite_bead_left: Jy, ferrite_bead_right: Te, ferrite_bead_up: Re, filled_diode_down: My, filled_diode_horz: Ny, filled_diode_left: By, filled_diode_right: Dy, filled_diode_up: Uy, filled_diode_vert: Hy, frequency_meter_horz: St, frequency_meter_vert: tx, fuse_horz: Oe, fuse_vert: ox, ground_down: ix, ground_horz: lx, ground_left: px, ground_right: ax, ground_up: yx, ground_vert: xx, gunn_diode_horz: sx, gunn_diode_vert: mx, icled_down: fx, icled_left: hx, icled_right: D, icled_up: cx, igbt_transistor_horz: Je, igbt_transistor_vert: _x, illuminated_push_button_normally_open_horz: $e, illuminated_push_button_normally_open_vert: wx, inductor_down: Fx, inductor_left: Rx, inductor_right: ut, inductor_up: Ce, laser_diode_down: Tx, laser_diode_left: Ex, laser_diode_right: G, laser_diode_up: Yx, led_down: jx, led_left: kx, led_right: vt, led_up: Ie, light_dependent_resistor_horz: qe, light_dependent_resistor_vert: Cx, mosfet_depletion_normally_on_horz: Ge, mosfet_depletion_normally_on_vert: qx, mushroom_head_normally_open_momentary_horz: We, mushroom_head_normally_open_momentary_vert: Wx, n_channel_d_mosfet_transistor_horz: Qe, n_channel_d_mosfet_transistor_vert: ts2, n_channel_e_mosfet_transistor_horz: t0, n_channel_e_mosfet_transistor_vert: ls, njfet_transistor_horz: r0, njfet_transistor_vert: ss, not_connected_down: fs38, not_connected_left: hs, not_connected_right: U, not_connected_up: cs, npn_bipolar_transistor_down: ds, npn_bipolar_transistor_horz: bs, npn_bipolar_transistor_left: _s, npn_bipolar_transistor_right: gs, npn_bipolar_transistor_up: us, npn_bipolar_transistor_vert: vs, opamp_no_power_down: As, opamp_no_power_left: Ps, opamp_no_power_right: W, opamp_no_power_up: Ss, opamp_with_power_down: Rs, opamp_with_power_left: Ts, opamp_with_power_right: H, opamp_with_power_up: Es, p_channel_d_mosfet_transistor_horz: x0, p_channel_d_mosfet_transistor_vert: js, p_channel_e_mosfet_transistor_horz: m0, p_channel_e_mosfet_transistor_vert: $s, photodiode_horz: n0, photodiode_vert: Is, pjfet_transistor_horz: h0, pjfet_transistor_vert: Us, pnp_bipolar_transistor_down: Ws, pnp_bipolar_transistor_horz: Hs, pnp_bipolar_transistor_left: Zs, pnp_bipolar_transistor_right: Qs, pnp_bipolar_transistor_up: Ks, pnp_bipolar_transistor_vert: tm, potentiometer_horz: v0, potentiometer_vert: im, potentiometer2_down: ym, potentiometer2_left: xm, potentiometer2_right: Z, potentiometer2_up: sm, potentiometer3_down: mm, potentiometer3_left: nm, potentiometer3_right: fm, potentiometer3_up: hm, power_factor_meter_horz: R0, power_factor_meter_vert: _m, push_button_normally_closed_momentary_horz: E0, push_button_normally_closed_momentary_vert: wm, push_button_normally_open_momentary_horz: X0, push_button_normally_open_momentary_vert: Fm, rail_down: Tm, rail_left: Ym, rail_right: Lm, rail_up: jm, rectifier_diode_horz: j0, rectifier_diode_vert: Om, resistor_down: $m, resistor_left: Cm, resistor_right: Im, resistor_up: qm, resonator_down: Gm, resonator_horz: N0, resonator_left: Um, resonator_right: et, resonator_up: Wm, resonator_vert: Hm, schottky_diode_down: Qm, schottky_diode_left: Km, schottky_diode_right: rt, schottky_diode_up: tn, silicon_controlled_rectifier_horz: I0, silicon_controlled_rectifier_vert: on2, solderjumper2_bridged12_down: ln, solderjumper2_bridged12_left: pn, solderjumper2_bridged12_right: an, solderjumper2_bridged12_up: yn, solderjumper2_down: xn, solderjumper2_left: sn, solderjumper2_right: mn, solderjumper2_up: nn, solderjumper3_bridged12_down: fn, solderjumper3_bridged12_left: hn, solderjumper3_bridged12_right: cn, solderjumper3_bridged12_up: dn, solderjumper3_bridged123_down: bn, solderjumper3_bridged123_left: _n, solderjumper3_bridged123_right: gn, solderjumper3_bridged123_up: un, solderjumper3_bridged23_down: vn, solderjumper3_bridged23_left: wn, solderjumper3_bridged23_right: An, solderjumper3_bridged23_up: Pn, solderjumper3_down: Sn, solderjumper3_left: Fn, solderjumper3_right: Rn, solderjumper3_up: Tn, spdt_normally_closed_switch_down: Yn, spdt_normally_closed_switch_left: Xn, spdt_normally_closed_switch_right: xt, spdt_normally_closed_switch_up: Ln, spdt_switch_down: jn, spdt_switch_left: kn, spdt_switch_right: st, spdt_switch_up: zn, spst_normally_closed_switch_down: On, spst_normally_closed_switch_left: Jn, spst_normally_closed_switch_right: mt, spst_normally_closed_switch_up: $n, spst_switch_down: Mn, spst_switch_left: Cn, spst_switch_right: nt, spst_switch_up: Nn, square_wave_down: In, square_wave_left: Bn, square_wave_right: qn, square_wave_up: Dn, step_recovery_diode_horz: B0, step_recovery_diode_vert: Gn, tachometer_horz: Yt, tachometer_vert: Zn, testpoint_down: t1, testpoint_left: e1, testpoint_right: ht, testpoint_up: i1, tilted_ground_down: p1, tilted_ground_left: a1, tilted_ground_right: wt, tilted_ground_up: D0, triac_horz: G0, triac_vert: s1, tunnel_diode_horz: W0, tunnel_diode_vert: h1, unijunction_transistor_horz: Z0, unijunction_transistor_vert: u1, usbc: w1, var_meter_horz: K0, var_meter_vert: S1, varactor_diode_horz: er, varactor_diode_vert: E1, varistor_horz: or, varistor_vert: V1, varmeter_horz: Xt, varmeter_vert: O1, vcc_down: J1, vcc_left: $1, vcc_right: M1, vcc_up: C1, volt_meter_horz: lr, volt_meter_vert: N1, watt_hour_meter_horz: Lt, watt_hour_meter_vert: D1, wattmeter_horz: Vt, wattmeter_vert: H1, zener_diode_horz: xr, zener_diode_vert: tf };
|
|
98377
98788
|
var gM = Object.fromEntries(Object.keys(ef).map((t) => [t, t]));
|
|
98378
98789
|
function doesLineIntersectLine([a12, a22], [b12, b22], {
|
|
98379
98790
|
lineThickness = 0
|
|
@@ -130789,10 +131200,10 @@ var gt2 = class {
|
|
|
130789
131200
|
return o22 = Et2(t3.slice(e22, s22 + 1)), xt2(o22, this.toBBox), o22;
|
|
130790
131201
|
n22 || (n22 = Math.ceil(Math.log(i22) / Math.log(a22)), a22 = Math.ceil(i22 / Math.pow(a22, n22 - 1))), o22 = Et2([]), o22.leaf = false, o22.height = n22;
|
|
130791
131202
|
const r22 = Math.ceil(i22 / a22), h22 = r22 * Math.ceil(Math.sqrt(a22));
|
|
130792
|
-
|
|
131203
|
+
At6(t3, e22, s22, h22, this.compareMinX);
|
|
130793
131204
|
for (let i3 = e22;i3 <= s22; i3 += h22) {
|
|
130794
131205
|
const e32 = Math.min(i3 + h22 - 1, s22);
|
|
130795
|
-
|
|
131206
|
+
At6(t3, i3, e32, r22, this.compareMinY);
|
|
130796
131207
|
for (let s32 = i3;s32 <= e32; s32 += r22) {
|
|
130797
131208
|
const i4 = Math.min(s32 + r22 - 1, e32);
|
|
130798
131209
|
o22.children.push(this._build(t3, s32, i4, n22 - 1));
|
|
@@ -130911,7 +131322,7 @@ function Tt2(t3, e22) {
|
|
|
130911
131322
|
function Et2(t3) {
|
|
130912
131323
|
return { children: t3, height: 1, leaf: true, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
|
|
130913
131324
|
}
|
|
130914
|
-
function
|
|
131325
|
+
function At6(t3, e22, s22, n22, i22) {
|
|
130915
131326
|
const o22 = [e22, s22];
|
|
130916
131327
|
for (;o22.length; ) {
|
|
130917
131328
|
if ((s22 = o22.pop()) - (e22 = o22.pop()) <= n22)
|
|
@@ -155575,7 +155986,7 @@ function rectanglePolygon({
|
|
|
155575
155986
|
if (rotationDeg) {
|
|
155576
155987
|
const matrix2 = rotateDEG(rotationDeg, cx2, cy2);
|
|
155577
155988
|
const rotatedCorners = corners.map((pt22) => {
|
|
155578
|
-
const p22 =
|
|
155989
|
+
const p22 = applyToPoint18(matrix2, { x: pt22.x, y: pt22.y });
|
|
155579
155990
|
return new Point$3(p22.x, p22.y);
|
|
155580
155991
|
});
|
|
155581
155992
|
poly = new Polygon$1(rotatedCorners);
|
|
@@ -155640,7 +156051,7 @@ function computeOverlapDistance(compPoly, boardPoly, componentCenter, componentW
|
|
|
155640
156051
|
}
|
|
155641
156052
|
const matrix2 = rotateDEG(rotationDeg, componentCenter.x, componentCenter.y);
|
|
155642
156053
|
const rotatePoint3 = (pt22) => {
|
|
155643
|
-
const p22 =
|
|
156054
|
+
const p22 = applyToPoint18(matrix2, pt22);
|
|
155644
156055
|
return new Point$3(p22.x, p22.y);
|
|
155645
156056
|
};
|
|
155646
156057
|
const rotatedPoints = corners.concat(midpoints).map(rotatePoint3);
|
|
@@ -156649,25 +157060,25 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
156649
157060
|
computePcbPropsTransform() {
|
|
156650
157061
|
const { _parsedProps: props } = this;
|
|
156651
157062
|
const rotation5 = this._getPcbRotationBeforeLayout() ?? 0;
|
|
156652
|
-
const matrix2 = compose4(translate4(props.pcbX ?? 0, props.pcbY ?? 0),
|
|
157063
|
+
const matrix2 = compose4(translate4(props.pcbX ?? 0, props.pcbY ?? 0), rotate6(rotation5 * Math.PI / 180));
|
|
156653
157064
|
return matrix2;
|
|
156654
157065
|
}
|
|
156655
157066
|
_computePcbGlobalTransformBeforeLayout() {
|
|
156656
157067
|
const manualPlacement = this.getSubcircuit()._getPcbManualPlacementForComponent(this);
|
|
156657
157068
|
if (manualPlacement && this.props.pcbX === undefined && this.props.pcbY === undefined) {
|
|
156658
157069
|
const rotation5 = this._getPcbRotationBeforeLayout() ?? 0;
|
|
156659
|
-
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ??
|
|
157070
|
+
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity5(), compose4(translate4(manualPlacement.x, manualPlacement.y), rotate6(rotation5 * Math.PI / 180)));
|
|
156660
157071
|
}
|
|
156661
157072
|
if (this.isPcbPrimitive) {
|
|
156662
157073
|
const primitiveContainer = this.getPrimitiveContainer();
|
|
156663
157074
|
if (primitiveContainer) {
|
|
156664
157075
|
const isFlipped = primitiveContainer._parsedProps.layer === "bottom";
|
|
156665
157076
|
if (isFlipped) {
|
|
156666
|
-
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ??
|
|
157077
|
+
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity5(), flipY(), this.computePcbPropsTransform());
|
|
156667
157078
|
}
|
|
156668
157079
|
}
|
|
156669
157080
|
}
|
|
156670
|
-
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ??
|
|
157081
|
+
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity5(), this.computePcbPropsTransform());
|
|
156671
157082
|
}
|
|
156672
157083
|
getPrimitiveContainer() {
|
|
156673
157084
|
if (this.isPrimitiveContainer)
|
|
@@ -156714,7 +157125,7 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
156714
157125
|
const manualPlacementTransform = this._getSchematicGlobalManualPlacementTransform(this);
|
|
156715
157126
|
if (manualPlacementTransform)
|
|
156716
157127
|
return manualPlacementTransform;
|
|
156717
|
-
return compose4(this.parent?.computeSchematicGlobalTransform?.() ??
|
|
157128
|
+
return compose4(this.parent?.computeSchematicGlobalTransform?.() ?? identity5(), this.computeSchematicPropsTransform());
|
|
156718
157129
|
}
|
|
156719
157130
|
_getSchematicSymbolName() {
|
|
156720
157131
|
const { _parsedProps: props } = this;
|
|
@@ -156800,7 +157211,7 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
156800
157211
|
return null;
|
|
156801
157212
|
for (const position2 of placementConfigPositions) {
|
|
156802
157213
|
if (isMatchingSelector(component, position2.selector) || component.props.name === position2.selector) {
|
|
156803
|
-
const center2 =
|
|
157214
|
+
const center2 = applyToPoint18(this._computePcbGlobalTransformBeforeLayout(), position2.center);
|
|
156804
157215
|
return center2;
|
|
156805
157216
|
}
|
|
156806
157217
|
}
|
|
@@ -156817,7 +157228,7 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
156817
157228
|
return null;
|
|
156818
157229
|
for (const position2 of placementConfigPositions) {
|
|
156819
157230
|
if (isMatchingSelector(component, position2.selector) || component.props.name === position2.selector) {
|
|
156820
|
-
const center2 =
|
|
157231
|
+
const center2 = applyToPoint18(this.computeSchematicGlobalTransform(), position2.center);
|
|
156821
157232
|
return center2;
|
|
156822
157233
|
}
|
|
156823
157234
|
}
|
|
@@ -156830,20 +157241,20 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
156830
157241
|
for (const position2 of manualEdits.schematic_placements ?? []) {
|
|
156831
157242
|
if (isMatchingSelector(component, position2.selector) || component.props.name === position2.selector) {
|
|
156832
157243
|
if (position2.relative_to === "group_center") {
|
|
156833
|
-
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ??
|
|
157244
|
+
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity5(), translate4(position2.center.x, position2.center.y));
|
|
156834
157245
|
}
|
|
156835
157246
|
}
|
|
156836
157247
|
}
|
|
156837
157248
|
return null;
|
|
156838
157249
|
}
|
|
156839
157250
|
_getGlobalPcbPositionBeforeLayout() {
|
|
156840
|
-
return
|
|
157251
|
+
return applyToPoint18(this._computePcbGlobalTransformBeforeLayout(), {
|
|
156841
157252
|
x: 0,
|
|
156842
157253
|
y: 0
|
|
156843
157254
|
});
|
|
156844
157255
|
}
|
|
156845
157256
|
_getGlobalSchematicPositionBeforeLayout() {
|
|
156846
|
-
return
|
|
157257
|
+
return applyToPoint18(this.computeSchematicGlobalTransform(), { x: 0, y: 0 });
|
|
156847
157258
|
}
|
|
156848
157259
|
get root() {
|
|
156849
157260
|
return this.parent?.root ?? null;
|
|
@@ -157288,7 +157699,7 @@ var createInstanceFromReactElement = (reactElm) => {
|
|
|
157288
157699
|
this.children.push(instance);
|
|
157289
157700
|
},
|
|
157290
157701
|
computePcbGlobalTransform() {
|
|
157291
|
-
return
|
|
157702
|
+
return identity5();
|
|
157292
157703
|
}
|
|
157293
157704
|
};
|
|
157294
157705
|
const containerErrors = [];
|
|
@@ -157758,7 +158169,7 @@ var SmtPad = class extends PrimitiveComponent2 {
|
|
|
157758
158169
|
});
|
|
157759
158170
|
} else if (props.shape === "polygon") {
|
|
157760
158171
|
const transformedPoints = props.points.map((point5) => {
|
|
157761
|
-
const transformed =
|
|
158172
|
+
const transformed = applyToPoint18(globalTransform, {
|
|
157762
158173
|
x: distance.parse(point5.x),
|
|
157763
158174
|
y: distance.parse(point5.y)
|
|
157764
158175
|
});
|
|
@@ -157935,7 +158346,7 @@ var SilkscreenPath = class extends PrimitiveComponent2 {
|
|
|
157935
158346
|
pcb_component_id,
|
|
157936
158347
|
layer,
|
|
157937
158348
|
route: props.route.map((p22) => {
|
|
157938
|
-
const transformedPosition =
|
|
158349
|
+
const transformedPosition = applyToPoint18(transform2, {
|
|
157939
158350
|
x: p22.x,
|
|
157940
158351
|
y: p22.y
|
|
157941
158352
|
});
|
|
@@ -158018,7 +158429,7 @@ var PcbTrace = class extends PrimitiveComponent2 {
|
|
|
158018
158429
|
const parentTransform = this._computePcbGlobalTransformBeforeLayout();
|
|
158019
158430
|
const transformedRoute = props.route.map((point5) => {
|
|
158020
158431
|
const { x: x22, y: y22, ...restOfPoint } = point5;
|
|
158021
|
-
const transformedPoint =
|
|
158432
|
+
const transformedPoint = applyToPoint18(parentTransform, { x: x22, y: y22 });
|
|
158022
158433
|
if (point5.route_type === "wire" && point5.layer) {
|
|
158023
158434
|
return {
|
|
158024
158435
|
...transformedPoint,
|
|
@@ -158524,7 +158935,7 @@ var Cutout = class extends PrimitiveComponent2 {
|
|
|
158524
158935
|
inserted_pcb_cutout = db.pcb_cutout.insert(circleData);
|
|
158525
158936
|
} else if (props.shape === "polygon") {
|
|
158526
158937
|
const transform2 = this._computePcbGlobalTransformBeforeLayout();
|
|
158527
|
-
const transformedPoints = props.points.map((p22) =>
|
|
158938
|
+
const transformedPoints = props.points.map((p22) => applyToPoint18(transform2, p22));
|
|
158528
158939
|
const polygonData = {
|
|
158529
158940
|
shape: "polygon",
|
|
158530
158941
|
points: transformedPoints,
|
|
@@ -159225,7 +159636,7 @@ var Port = class extends PrimitiveComponent2 {
|
|
|
159225
159636
|
}
|
|
159226
159637
|
}
|
|
159227
159638
|
const transform2 = compose4(parentNormalComponent.computeSchematicGlobalTransform(), translate4(-symbol.center.x, -symbol.center.y));
|
|
159228
|
-
return
|
|
159639
|
+
return applyToPoint18(transform2, schematicSymbolPortDef);
|
|
159229
159640
|
}
|
|
159230
159641
|
const parentBoxDim = parentNormalComponent?._getSchematicBoxDimensions();
|
|
159231
159642
|
if (parentBoxDim && this.props.pinNumber !== undefined) {
|
|
@@ -159233,7 +159644,7 @@ var Port = class extends PrimitiveComponent2 {
|
|
|
159233
159644
|
if (!localPortPosition) {
|
|
159234
159645
|
throw new Error(`Couldn't find position for schematic_port for port ${this.getString()} inside of the schematic box`);
|
|
159235
159646
|
}
|
|
159236
|
-
return
|
|
159647
|
+
return applyToPoint18(parentNormalComponent.computeSchematicGlobalTransform(), localPortPosition);
|
|
159237
159648
|
}
|
|
159238
159649
|
throw new Error(`Couldn't find position for schematic_port for port ${this.getString()}`);
|
|
159239
159650
|
}
|
|
@@ -161836,7 +162247,7 @@ function Trace_doInitialPcbManualTraceRender(trace) {
|
|
|
161836
162247
|
layer,
|
|
161837
162248
|
start_pcb_port_id: anchorPort.pcb_port_id
|
|
161838
162249
|
});
|
|
161839
|
-
const transform2 = anchorPort?._computePcbGlobalTransformBeforeLayout?.() ||
|
|
162250
|
+
const transform2 = anchorPort?._computePcbGlobalTransformBeforeLayout?.() || identity5();
|
|
161840
162251
|
for (const pt22 of props.pcbPath) {
|
|
161841
162252
|
let coordinates;
|
|
161842
162253
|
let isGlobalPosition = false;
|
|
@@ -161862,7 +162273,7 @@ function Trace_doInitialPcbManualTraceRender(trace) {
|
|
|
161862
162273
|
coordinates = { x: pt22.x, y: pt22.y };
|
|
161863
162274
|
isGlobalPosition = false;
|
|
161864
162275
|
}
|
|
161865
|
-
const finalCoordinates = isGlobalPosition ? coordinates :
|
|
162276
|
+
const finalCoordinates = isGlobalPosition ? coordinates : applyToPoint18(transform2, coordinates);
|
|
161866
162277
|
route.push({
|
|
161867
162278
|
route_type: "wire",
|
|
161868
162279
|
x: finalCoordinates.x,
|
|
@@ -164051,7 +164462,7 @@ var TraceHint = class extends PrimitiveComponent2 {
|
|
|
164051
164462
|
return [];
|
|
164052
164463
|
const globalTransform = this._computePcbGlobalTransformBeforeLayout();
|
|
164053
164464
|
return offsets.map((offset) => ({
|
|
164054
|
-
...
|
|
164465
|
+
...applyToPoint18(globalTransform, offset),
|
|
164055
164466
|
via: offset.via,
|
|
164056
164467
|
to_layer: offset.to_layer,
|
|
164057
164468
|
trace_width: offset.trace_width
|
|
@@ -165935,7 +166346,7 @@ var applyPackOutput = (group, packOutput, clusterMap) => {
|
|
|
165935
166346
|
if (!member)
|
|
165936
166347
|
continue;
|
|
165937
166348
|
const originalCenter2 = member.center;
|
|
165938
|
-
const transformMatrix2 = compose4(group._computePcbGlobalTransformBeforeLayout(), translate4(center2.x + rotatedRel.x, center2.y + rotatedRel.y),
|
|
166349
|
+
const transformMatrix2 = compose4(group._computePcbGlobalTransformBeforeLayout(), translate4(center2.x + rotatedRel.x, center2.y + rotatedRel.y), rotate6(angleRad), translate4(-originalCenter2.x, -originalCenter2.y));
|
|
165939
166350
|
const related = db.toArray().filter((elm) => ("pcb_component_id" in elm) && elm.pcb_component_id === memberId);
|
|
165940
166351
|
transformPCBElements(related, transformMatrix2);
|
|
165941
166352
|
updateCadRotation({
|
|
@@ -165957,7 +166368,7 @@ var applyPackOutput = (group, packOutput, clusterMap) => {
|
|
|
165957
166368
|
}
|
|
165958
166369
|
const originalCenter2 = pcbComponent.center;
|
|
165959
166370
|
const rotationDegrees2 = ccwRotationDegrees ?? ccwRotationOffset ?? 0;
|
|
165960
|
-
const transformMatrix2 = compose4(group._computePcbGlobalTransformBeforeLayout(), translate4(center2.x, center2.y),
|
|
166371
|
+
const transformMatrix2 = compose4(group._computePcbGlobalTransformBeforeLayout(), translate4(center2.x, center2.y), rotate6(rotationDegrees2 * Math.PI / 180), translate4(-originalCenter2.x, -originalCenter2.y));
|
|
165961
166372
|
const related = db.toArray().filter((elm) => ("pcb_component_id" in elm) && elm.pcb_component_id === componentId);
|
|
165962
166373
|
transformPCBElements(related, transformMatrix2);
|
|
165963
166374
|
updateCadRotation({
|
|
@@ -165973,7 +166384,7 @@ var applyPackOutput = (group, packOutput, clusterMap) => {
|
|
|
165973
166384
|
continue;
|
|
165974
166385
|
const originalCenter = pcbGroup.center;
|
|
165975
166386
|
const rotationDegrees = ccwRotationDegrees ?? ccwRotationOffset ?? 0;
|
|
165976
|
-
const transformMatrix = compose4(group._computePcbGlobalTransformBeforeLayout(), translate4(center2.x, center2.y),
|
|
166387
|
+
const transformMatrix = compose4(group._computePcbGlobalTransformBeforeLayout(), translate4(center2.x, center2.y), rotate6(rotationDegrees * Math.PI / 180), translate4(-originalCenter.x, -originalCenter.y));
|
|
165977
166388
|
const relatedElements = db.toArray().filter((elm) => {
|
|
165978
166389
|
if ("source_group_id" in elm && elm.source_group_id) {
|
|
165979
166390
|
if (elm.source_group_id === componentId) {
|
|
@@ -168366,7 +168777,7 @@ var Board = class extends Group6 {
|
|
|
168366
168777
|
this.pcb_board_id = null;
|
|
168367
168778
|
}
|
|
168368
168779
|
_computePcbGlobalTransformBeforeLayout() {
|
|
168369
|
-
return
|
|
168780
|
+
return identity5();
|
|
168370
168781
|
}
|
|
168371
168782
|
doInitialPcbDesignRuleChecks() {
|
|
168372
168783
|
if (this.root?.pcbDisabled)
|
|
@@ -169361,7 +169772,7 @@ var FabricationNotePath = class extends PrimitiveComponent2 {
|
|
|
169361
169772
|
layer,
|
|
169362
169773
|
color: props.color,
|
|
169363
169774
|
route: props.route.map((p22) => {
|
|
169364
|
-
const transformedPosition =
|
|
169775
|
+
const transformedPosition = applyToPoint18(transform2, {
|
|
169365
169776
|
x: p22.x,
|
|
169366
169777
|
y: p22.y
|
|
169367
169778
|
});
|
|
@@ -169422,13 +169833,13 @@ var FabricationNoteDimension = class extends PrimitiveComponent2 {
|
|
|
169422
169833
|
const target = this.getSubcircuit().selectOne(input);
|
|
169423
169834
|
if (!target) {
|
|
169424
169835
|
this.renderError(`FabricationNoteDimension could not find selector "${input}"`);
|
|
169425
|
-
return
|
|
169836
|
+
return applyToPoint18(transform2, { x: 0, y: 0 });
|
|
169426
169837
|
}
|
|
169427
169838
|
return target._getGlobalPcbPositionBeforeLayout();
|
|
169428
169839
|
}
|
|
169429
169840
|
const numericX = typeof input.x === "string" ? parseFloat(input.x) : input.x;
|
|
169430
169841
|
const numericY = typeof input.y === "string" ? parseFloat(input.y) : input.y;
|
|
169431
|
-
return
|
|
169842
|
+
return applyToPoint18(transform2, { x: numericX, y: numericY });
|
|
169432
169843
|
}
|
|
169433
169844
|
doInitialPcbPrimitiveRender() {
|
|
169434
169845
|
if (this.root?.pcbDisabled)
|
|
@@ -169508,8 +169919,8 @@ var PcbNoteLine = class extends PrimitiveComponent2 {
|
|
|
169508
169919
|
const subcircuit = this.getSubcircuit();
|
|
169509
169920
|
const group = this.getGroup();
|
|
169510
169921
|
const transform2 = this._computePcbGlobalTransformBeforeLayout();
|
|
169511
|
-
const start =
|
|
169512
|
-
const end =
|
|
169922
|
+
const start = applyToPoint18(transform2, { x: props.x1, y: props.y1 });
|
|
169923
|
+
const end = applyToPoint18(transform2, { x: props.x2, y: props.y2 });
|
|
169513
169924
|
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? undefined;
|
|
169514
169925
|
const pcb_note_line2 = db.pcb_note_line.insert({
|
|
169515
169926
|
pcb_component_id,
|
|
@@ -169548,7 +169959,7 @@ var PcbNoteRect = class extends PrimitiveComponent2 {
|
|
|
169548
169959
|
const { db } = this.root;
|
|
169549
169960
|
const { _parsedProps: props } = this;
|
|
169550
169961
|
const transform2 = this._computePcbGlobalTransformBeforeLayout();
|
|
169551
|
-
const center2 =
|
|
169962
|
+
const center2 = applyToPoint18(transform2, { x: 0, y: 0 });
|
|
169552
169963
|
const subcircuit = this.getSubcircuit();
|
|
169553
169964
|
const group = this.getGroup();
|
|
169554
169965
|
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? undefined;
|
|
@@ -169590,7 +170001,7 @@ var PcbNoteText = class extends PrimitiveComponent2 {
|
|
|
169590
170001
|
const { db } = this.root;
|
|
169591
170002
|
const { _parsedProps: props } = this;
|
|
169592
170003
|
const transform2 = this._computePcbGlobalTransformBeforeLayout();
|
|
169593
|
-
const anchorPosition =
|
|
170004
|
+
const anchorPosition = applyToPoint18(transform2, { x: 0, y: 0 });
|
|
169594
170005
|
const subcircuit = this.getSubcircuit();
|
|
169595
170006
|
const group = this.getGroup();
|
|
169596
170007
|
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? undefined;
|
|
@@ -169638,7 +170049,7 @@ var PcbNotePath = class extends PrimitiveComponent2 {
|
|
|
169638
170049
|
const { x: x22, y: y22, ...rest } = point5;
|
|
169639
170050
|
const numericX = typeof x22 === "string" ? parseFloat(x22) : x22;
|
|
169640
170051
|
const numericY = typeof y22 === "string" ? parseFloat(y22) : y22;
|
|
169641
|
-
const transformed =
|
|
170052
|
+
const transformed = applyToPoint18(transform2, { x: numericX, y: numericY });
|
|
169642
170053
|
return { ...rest, x: transformed.x, y: transformed.y };
|
|
169643
170054
|
});
|
|
169644
170055
|
const pcb_note_path2 = db.pcb_note_path.insert({
|
|
@@ -169678,13 +170089,13 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
|
|
|
169678
170089
|
const target = this.getSubcircuit().selectOne(`.${input}`);
|
|
169679
170090
|
if (!target) {
|
|
169680
170091
|
this.renderError(`PcbNoteDimension could not find selector "${input}"`);
|
|
169681
|
-
return
|
|
170092
|
+
return applyToPoint18(transform2, { x: 0, y: 0 });
|
|
169682
170093
|
}
|
|
169683
170094
|
return target._getGlobalPcbPositionBeforeLayout();
|
|
169684
170095
|
}
|
|
169685
170096
|
const numericX = typeof input.x === "string" ? parseFloat(input.x) : input.x;
|
|
169686
170097
|
const numericY = typeof input.y === "string" ? parseFloat(input.y) : input.y;
|
|
169687
|
-
return
|
|
170098
|
+
return applyToPoint18(transform2, { x: numericX, y: numericY });
|
|
169688
170099
|
}
|
|
169689
170100
|
doInitialPcbPrimitiveRender() {
|
|
169690
170101
|
if (this.root?.pcbDisabled)
|
|
@@ -170090,7 +170501,7 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
170090
170501
|
const connectedPorts = this._getConnectedPorts();
|
|
170091
170502
|
if (connectedPorts.length > 0) {
|
|
170092
170503
|
const portPos = connectedPorts[0]._getGlobalSchematicPositionBeforeLayout();
|
|
170093
|
-
const parentCenter =
|
|
170504
|
+
const parentCenter = applyToPoint18(this.parent?.computeSchematicGlobalTransform?.() ?? identity5(), { x: 0, y: 0 });
|
|
170094
170505
|
return translate4(portPos.x - parentCenter.x, portPos.y - parentCenter.y);
|
|
170095
170506
|
}
|
|
170096
170507
|
}
|
|
@@ -172231,22 +172642,22 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
|
|
|
172231
172642
|
for (const e22 of circuitElements) {
|
|
172232
172643
|
if (e22.type === "pcb_cutout") {
|
|
172233
172644
|
if (e22.shape === "polygon") {
|
|
172234
|
-
e22.points = e22.points.map((p22) =>
|
|
172645
|
+
e22.points = e22.points.map((p22) => applyToPoint18(matrix2, p22));
|
|
172235
172646
|
} else if (e22.shape === "circle" || e22.shape === "rect") {
|
|
172236
|
-
e22.center =
|
|
172647
|
+
e22.center = applyToPoint18(matrix2, e22.center);
|
|
172237
172648
|
} else if ("route" in e22) {
|
|
172238
172649
|
const cutoutPath = e22;
|
|
172239
|
-
cutoutPath.route = cutoutPath.route.map((p22) =>
|
|
172650
|
+
cutoutPath.route = cutoutPath.route.map((p22) => applyToPoint18(matrix2, p22));
|
|
172240
172651
|
}
|
|
172241
172652
|
} else if (e22.type === "pcb_smtpad" && e22.shape === "polygon") {
|
|
172242
|
-
e22.points = e22.points.map((p22) =>
|
|
172653
|
+
e22.points = e22.points.map((p22) => applyToPoint18(matrix2, p22));
|
|
172243
172654
|
}
|
|
172244
172655
|
}
|
|
172245
172656
|
const cad = circuitElements.find((e22) => e22.type === "cad_component");
|
|
172246
172657
|
if (cad) {
|
|
172247
172658
|
if (!cad.rotation)
|
|
172248
172659
|
cad.rotation = { x: 0, y: 0, z: 0 };
|
|
172249
|
-
const p22 =
|
|
172660
|
+
const p22 = applyToPoint18(matrix2, { x: cad.position.x, y: cad.position.y });
|
|
172250
172661
|
cad.position.x = p22.x;
|
|
172251
172662
|
cad.position.y = p22.y;
|
|
172252
172663
|
const side = pcb_component2.layer ?? "top";
|
|
@@ -173892,8 +174303,8 @@ var registerRemove = (program3) => {
|
|
|
173892
174303
|
};
|
|
173893
174304
|
|
|
173894
174305
|
// cli/build/register.ts
|
|
173895
|
-
import
|
|
173896
|
-
import
|
|
174306
|
+
import path55 from "node:path";
|
|
174307
|
+
import fs54 from "node:fs";
|
|
173897
174308
|
|
|
173898
174309
|
// cli/build/build-file.ts
|
|
173899
174310
|
import path42 from "node:path";
|
|
@@ -174241,6 +174652,9 @@ var resolveBuildOptions = ({
|
|
|
174241
174652
|
if (!cliOptions?.previewImages && configBuild?.previewImages) {
|
|
174242
174653
|
configAppliedOpts.push("preview-images");
|
|
174243
174654
|
}
|
|
174655
|
+
if (!cliOptions?.glbs && configBuild?.glbs) {
|
|
174656
|
+
configAppliedOpts.push("glbs");
|
|
174657
|
+
}
|
|
174244
174658
|
if (!cliOptions?.transpile && configBuild?.typescriptLibrary) {
|
|
174245
174659
|
configAppliedOpts.push("transpile");
|
|
174246
174660
|
}
|
|
@@ -174250,6 +174664,7 @@ var resolveBuildOptions = ({
|
|
|
174250
174664
|
kicadLibrary: cliOptions?.kicadLibrary ?? configBuild?.kicadLibrary,
|
|
174251
174665
|
kicadPcm: cliOptions?.kicadPcm ?? configBuild?.kicadPcm,
|
|
174252
174666
|
previewImages: cliOptions?.previewImages ?? configBuild?.previewImages,
|
|
174667
|
+
glbs: cliOptions?.glbs ?? configBuild?.glbs,
|
|
174253
174668
|
transpile: cliOptions?.transpile ?? configBuild?.typescriptLibrary
|
|
174254
174669
|
};
|
|
174255
174670
|
return { options, configAppliedOpts };
|
|
@@ -174632,9 +175047,66 @@ var buildPreviewGltf = async ({
|
|
|
174632
175047
|
}
|
|
174633
175048
|
};
|
|
174634
175049
|
|
|
174635
|
-
// cli/build/
|
|
175050
|
+
// cli/build/build-glbs.ts
|
|
174636
175051
|
import fs48 from "node:fs";
|
|
174637
175052
|
import path49 from "node:path";
|
|
175053
|
+
import { convertCircuitJsonToGltf as convertCircuitJsonToGltf4 } from "circuit-json-to-gltf";
|
|
175054
|
+
var viewToArrayBuffer2 = (view) => {
|
|
175055
|
+
const copy = new Uint8Array(view.byteLength);
|
|
175056
|
+
copy.set(new Uint8Array(view.buffer, view.byteOffset, view.byteLength));
|
|
175057
|
+
return copy.buffer;
|
|
175058
|
+
};
|
|
175059
|
+
var normalizeToUint8Array2 = (value) => {
|
|
175060
|
+
if (value instanceof Uint8Array) {
|
|
175061
|
+
return value;
|
|
175062
|
+
}
|
|
175063
|
+
if (value instanceof ArrayBuffer) {
|
|
175064
|
+
return new Uint8Array(value);
|
|
175065
|
+
}
|
|
175066
|
+
if (ArrayBuffer.isView(value)) {
|
|
175067
|
+
return new Uint8Array(viewToArrayBuffer2(value));
|
|
175068
|
+
}
|
|
175069
|
+
throw new Error("Expected Uint8Array, ArrayBuffer, or ArrayBufferView for GLB");
|
|
175070
|
+
};
|
|
175071
|
+
var buildGlbs = async ({
|
|
175072
|
+
builtFiles,
|
|
175073
|
+
distDir
|
|
175074
|
+
}) => {
|
|
175075
|
+
const successfulBuilds = builtFiles.filter((file) => file.ok);
|
|
175076
|
+
if (successfulBuilds.length === 0) {
|
|
175077
|
+
console.warn("No successful build output available for GLB generation.");
|
|
175078
|
+
return;
|
|
175079
|
+
}
|
|
175080
|
+
for (const build of successfulBuilds) {
|
|
175081
|
+
const outputDir = path49.dirname(build.outputPath);
|
|
175082
|
+
const prefixRelative = path49.relative(distDir, outputDir) || ".";
|
|
175083
|
+
const prefix = prefixRelative === "." ? "" : `[${prefixRelative}] `;
|
|
175084
|
+
let circuitJson;
|
|
175085
|
+
try {
|
|
175086
|
+
const circuitJsonRaw = fs48.readFileSync(build.outputPath, "utf-8");
|
|
175087
|
+
circuitJson = JSON.parse(circuitJsonRaw);
|
|
175088
|
+
} catch (error) {
|
|
175089
|
+
console.error(`${prefix}Failed to read circuit JSON:`, error);
|
|
175090
|
+
continue;
|
|
175091
|
+
}
|
|
175092
|
+
try {
|
|
175093
|
+
console.log(`${prefix}Converting circuit to GLB...`);
|
|
175094
|
+
const circuitJsonWithFileUrls = convertModelUrlsToFileUrls(circuitJson);
|
|
175095
|
+
const glbBuffer = await convertCircuitJsonToGltf4(circuitJsonWithFileUrls, {
|
|
175096
|
+
format: "glb"
|
|
175097
|
+
});
|
|
175098
|
+
const glbData = normalizeToUint8Array2(glbBuffer);
|
|
175099
|
+
fs48.writeFileSync(path49.join(outputDir, "3d.glb"), Buffer.from(glbData));
|
|
175100
|
+
console.log(`${prefix}Written 3d.glb`);
|
|
175101
|
+
} catch (error) {
|
|
175102
|
+
console.error(`${prefix}Failed to generate GLB:`, error);
|
|
175103
|
+
}
|
|
175104
|
+
}
|
|
175105
|
+
};
|
|
175106
|
+
|
|
175107
|
+
// cli/build/generate-kicad-project.ts
|
|
175108
|
+
import fs49 from "node:fs";
|
|
175109
|
+
import path50 from "node:path";
|
|
174638
175110
|
var createKicadProContent = ({
|
|
174639
175111
|
projectName,
|
|
174640
175112
|
schematicFileName,
|
|
@@ -174674,10 +175146,10 @@ var generateKicadProject = async ({
|
|
|
174674
175146
|
boardFileName
|
|
174675
175147
|
});
|
|
174676
175148
|
if (writeFiles) {
|
|
174677
|
-
|
|
174678
|
-
|
|
174679
|
-
|
|
174680
|
-
|
|
175149
|
+
fs49.mkdirSync(outputDir, { recursive: true });
|
|
175150
|
+
fs49.writeFileSync(path50.join(outputDir, schematicFileName), schContent);
|
|
175151
|
+
fs49.writeFileSync(path50.join(outputDir, boardFileName), pcbContent);
|
|
175152
|
+
fs49.writeFileSync(path50.join(outputDir, projectFileName), proContent);
|
|
174681
175153
|
}
|
|
174682
175154
|
return {
|
|
174683
175155
|
pcbContent,
|
|
@@ -174689,8 +175161,8 @@ var generateKicadProject = async ({
|
|
|
174689
175161
|
};
|
|
174690
175162
|
|
|
174691
175163
|
// cli/build/transpile/index.ts
|
|
174692
|
-
import
|
|
174693
|
-
import
|
|
175164
|
+
import path52 from "node:path";
|
|
175165
|
+
import fs51 from "node:fs";
|
|
174694
175166
|
import { rollup } from "rollup";
|
|
174695
175167
|
import typescript from "@rollup/plugin-typescript";
|
|
174696
175168
|
import resolve11 from "@rollup/plugin-node-resolve";
|
|
@@ -174699,11 +175171,11 @@ import json from "@rollup/plugin-json";
|
|
|
174699
175171
|
import dts from "rollup-plugin-dts";
|
|
174700
175172
|
|
|
174701
175173
|
// cli/build/transpile/static-asset-plugin.ts
|
|
174702
|
-
import
|
|
174703
|
-
import
|
|
175174
|
+
import fs50 from "node:fs";
|
|
175175
|
+
import path51 from "node:path";
|
|
174704
175176
|
import { createHash } from "node:crypto";
|
|
174705
175177
|
function normalizePathSeparators(filePath) {
|
|
174706
|
-
return filePath.split(
|
|
175178
|
+
return filePath.split(path51.sep).join("/");
|
|
174707
175179
|
}
|
|
174708
175180
|
var STATIC_ASSET_EXTENSIONS = new Set([
|
|
174709
175181
|
".glb",
|
|
@@ -174734,24 +175206,24 @@ var createStaticAssetPlugin = ({
|
|
|
174734
175206
|
return {
|
|
174735
175207
|
name: "tsci-static-assets",
|
|
174736
175208
|
resolveId(source, importer) {
|
|
174737
|
-
const ext =
|
|
175209
|
+
const ext = path51.extname(source).toLowerCase();
|
|
174738
175210
|
if (!STATIC_ASSET_EXTENSIONS.has(ext))
|
|
174739
175211
|
return null;
|
|
174740
|
-
if (
|
|
174741
|
-
return
|
|
175212
|
+
if (path51.isAbsolute(source)) {
|
|
175213
|
+
return fs50.existsSync(source) ? { id: normalizePathSeparators(source), external: true } : null;
|
|
174742
175214
|
}
|
|
174743
175215
|
if (importer) {
|
|
174744
|
-
const importerNative = importer.split("/").join(
|
|
174745
|
-
const resolvedFromImporter =
|
|
174746
|
-
if (
|
|
175216
|
+
const importerNative = importer.split("/").join(path51.sep);
|
|
175217
|
+
const resolvedFromImporter = path51.resolve(path51.dirname(importerNative), source);
|
|
175218
|
+
if (fs50.existsSync(resolvedFromImporter)) {
|
|
174747
175219
|
return {
|
|
174748
175220
|
id: normalizePathSeparators(resolvedFromImporter),
|
|
174749
175221
|
external: true
|
|
174750
175222
|
};
|
|
174751
175223
|
}
|
|
174752
175224
|
}
|
|
174753
|
-
const resolvedFromProject =
|
|
174754
|
-
if (
|
|
175225
|
+
const resolvedFromProject = path51.resolve(resolvedBaseUrl, source);
|
|
175226
|
+
if (fs50.existsSync(resolvedFromProject)) {
|
|
174755
175227
|
return {
|
|
174756
175228
|
id: normalizePathSeparators(resolvedFromProject),
|
|
174757
175229
|
external: true
|
|
@@ -174764,8 +175236,8 @@ var createStaticAssetPlugin = ({
|
|
|
174764
175236
|
const wildcard = isWildcard ? source.slice(patternPrefix.length) : "";
|
|
174765
175237
|
for (const target of targets) {
|
|
174766
175238
|
const targetPath = isWildcard ? target.replace("*", wildcard) : target;
|
|
174767
|
-
const resolvedTarget =
|
|
174768
|
-
if (
|
|
175239
|
+
const resolvedTarget = path51.resolve(resolvedBaseUrl, targetPath);
|
|
175240
|
+
if (fs50.existsSync(resolvedTarget)) {
|
|
174769
175241
|
return {
|
|
174770
175242
|
id: normalizePathSeparators(resolvedTarget),
|
|
174771
175243
|
external: true
|
|
@@ -174791,18 +175263,18 @@ var createStaticAssetPlugin = ({
|
|
|
174791
175263
|
if (chunk.type !== "chunk")
|
|
174792
175264
|
continue;
|
|
174793
175265
|
for (const importedId of chunk.imports) {
|
|
174794
|
-
const ext =
|
|
175266
|
+
const ext = path51.extname(importedId).toLowerCase();
|
|
174795
175267
|
if (!STATIC_ASSET_EXTENSIONS.has(ext))
|
|
174796
175268
|
continue;
|
|
174797
175269
|
if (!copiedAssets.has(importedId)) {
|
|
174798
|
-
const assetDir =
|
|
174799
|
-
|
|
174800
|
-
const nativePath = importedId.split("/").join(
|
|
174801
|
-
const fileBuffer =
|
|
175270
|
+
const assetDir = path51.join(outputDir, "assets");
|
|
175271
|
+
fs50.mkdirSync(assetDir, { recursive: true });
|
|
175272
|
+
const nativePath = importedId.split("/").join(path51.sep);
|
|
175273
|
+
const fileBuffer = fs50.readFileSync(nativePath);
|
|
174802
175274
|
const hash = createHash("sha1").update(fileBuffer).digest("hex").slice(0, 8);
|
|
174803
|
-
const fileName = `${
|
|
174804
|
-
const outputFilePath =
|
|
174805
|
-
|
|
175275
|
+
const fileName = `${path51.basename(importedId, ext)}-${hash}${ext}`;
|
|
175276
|
+
const outputFilePath = path51.join(assetDir, fileName);
|
|
175277
|
+
fs50.writeFileSync(outputFilePath, fileBuffer);
|
|
174806
175278
|
copiedAssets.set(importedId, `./assets/${fileName}`);
|
|
174807
175279
|
assetIdToOutputPath.set(importedId, `./assets/${fileName}`);
|
|
174808
175280
|
}
|
|
@@ -174824,17 +175296,17 @@ function escapeRegExp(string) {
|
|
|
174824
175296
|
|
|
174825
175297
|
// cli/build/transpile/index.ts
|
|
174826
175298
|
var createExternalFunction = (projectDir, tsconfigPath) => (id) => {
|
|
174827
|
-
if (id.startsWith(".") || id.startsWith("/") ||
|
|
175299
|
+
if (id.startsWith(".") || id.startsWith("/") || path52.isAbsolute(id)) {
|
|
174828
175300
|
return false;
|
|
174829
175301
|
}
|
|
174830
175302
|
let baseUrl = projectDir;
|
|
174831
175303
|
let pathMappings = {};
|
|
174832
|
-
if (tsconfigPath &&
|
|
175304
|
+
if (tsconfigPath && fs51.existsSync(tsconfigPath)) {
|
|
174833
175305
|
try {
|
|
174834
|
-
const tsconfigContent =
|
|
175306
|
+
const tsconfigContent = fs51.readFileSync(tsconfigPath, "utf-8");
|
|
174835
175307
|
const tsconfig = JSON.parse(tsconfigContent);
|
|
174836
175308
|
if (tsconfig.compilerOptions?.baseUrl) {
|
|
174837
|
-
baseUrl =
|
|
175309
|
+
baseUrl = path52.resolve(path52.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
|
|
174838
175310
|
}
|
|
174839
175311
|
if (tsconfig.compilerOptions?.paths) {
|
|
174840
175312
|
pathMappings = tsconfig.compilerOptions.paths;
|
|
@@ -174848,17 +175320,17 @@ var createExternalFunction = (projectDir, tsconfigPath) => (id) => {
|
|
|
174848
175320
|
}
|
|
174849
175321
|
}
|
|
174850
175322
|
const potentialPaths = [
|
|
174851
|
-
|
|
174852
|
-
|
|
174853
|
-
|
|
174854
|
-
|
|
174855
|
-
|
|
174856
|
-
|
|
174857
|
-
|
|
174858
|
-
|
|
174859
|
-
|
|
175323
|
+
path52.join(baseUrl, id),
|
|
175324
|
+
path52.join(baseUrl, `${id}.ts`),
|
|
175325
|
+
path52.join(baseUrl, `${id}.tsx`),
|
|
175326
|
+
path52.join(baseUrl, `${id}.js`),
|
|
175327
|
+
path52.join(baseUrl, `${id}.jsx`),
|
|
175328
|
+
path52.join(baseUrl, id, "index.ts"),
|
|
175329
|
+
path52.join(baseUrl, id, "index.tsx"),
|
|
175330
|
+
path52.join(baseUrl, id, "index.js"),
|
|
175331
|
+
path52.join(baseUrl, id, "index.jsx")
|
|
174860
175332
|
];
|
|
174861
|
-
if (potentialPaths.some((p4) =>
|
|
175333
|
+
if (potentialPaths.some((p4) => fs51.existsSync(p4))) {
|
|
174862
175334
|
return false;
|
|
174863
175335
|
}
|
|
174864
175336
|
return true;
|
|
@@ -174869,17 +175341,17 @@ var transpileFile = async ({
|
|
|
174869
175341
|
projectDir
|
|
174870
175342
|
}) => {
|
|
174871
175343
|
try {
|
|
174872
|
-
|
|
174873
|
-
const tsconfigPath =
|
|
174874
|
-
const hasTsConfig =
|
|
175344
|
+
fs51.mkdirSync(outputDir, { recursive: true });
|
|
175345
|
+
const tsconfigPath = path52.join(projectDir, "tsconfig.json");
|
|
175346
|
+
const hasTsConfig = fs51.existsSync(tsconfigPath);
|
|
174875
175347
|
let tsconfigBaseUrl = projectDir;
|
|
174876
175348
|
let tsconfigPathMappings;
|
|
174877
175349
|
if (hasTsConfig) {
|
|
174878
175350
|
try {
|
|
174879
|
-
const tsconfigContent =
|
|
175351
|
+
const tsconfigContent = fs51.readFileSync(tsconfigPath, "utf-8");
|
|
174880
175352
|
const tsconfig = JSON.parse(tsconfigContent);
|
|
174881
175353
|
if (tsconfig.compilerOptions?.baseUrl) {
|
|
174882
|
-
tsconfigBaseUrl =
|
|
175354
|
+
tsconfigBaseUrl = path52.resolve(path52.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
|
|
174883
175355
|
}
|
|
174884
175356
|
if (tsconfig.compilerOptions?.paths) {
|
|
174885
175357
|
tsconfigPathMappings = tsconfig.compilerOptions.paths;
|
|
@@ -174934,27 +175406,27 @@ var transpileFile = async ({
|
|
|
174934
175406
|
external: createExternalFunction(projectDir, hasTsConfig ? tsconfigPath : undefined),
|
|
174935
175407
|
plugins: getPlugins()
|
|
174936
175408
|
});
|
|
174937
|
-
const esmOutputPath =
|
|
175409
|
+
const esmOutputPath = path52.join(outputDir, "index.js");
|
|
174938
175410
|
await esmBundle.write({
|
|
174939
175411
|
file: esmOutputPath,
|
|
174940
175412
|
format: "es",
|
|
174941
175413
|
sourcemap: false
|
|
174942
175414
|
});
|
|
174943
|
-
console.log(`ESM bundle written to ${
|
|
175415
|
+
console.log(`ESM bundle written to ${path52.relative(projectDir, esmOutputPath)}`);
|
|
174944
175416
|
console.log("Building CommonJS bundle...");
|
|
174945
175417
|
const cjsBundle = await rollup({
|
|
174946
175418
|
input,
|
|
174947
175419
|
external: createExternalFunction(projectDir, hasTsConfig ? tsconfigPath : undefined),
|
|
174948
175420
|
plugins: getPlugins()
|
|
174949
175421
|
});
|
|
174950
|
-
const cjsOutputPath =
|
|
175422
|
+
const cjsOutputPath = path52.join(outputDir, "index.cjs");
|
|
174951
175423
|
console.log("Writing CJS bundle to:", cjsOutputPath);
|
|
174952
175424
|
await cjsBundle.write({
|
|
174953
175425
|
file: cjsOutputPath,
|
|
174954
175426
|
format: "cjs",
|
|
174955
175427
|
sourcemap: false
|
|
174956
175428
|
});
|
|
174957
|
-
console.log(`CommonJS bundle written to ${
|
|
175429
|
+
console.log(`CommonJS bundle written to ${path52.relative(projectDir, cjsOutputPath)}`);
|
|
174958
175430
|
console.log("Generating type declarations...");
|
|
174959
175431
|
const dtsBundle = await rollup({
|
|
174960
175432
|
input,
|
|
@@ -174979,9 +175451,9 @@ var transpileFile = async ({
|
|
|
174979
175451
|
dtsContent = dtsContent.replace(/import \* as [\w_]+ from ['"]react\/jsx-runtime['"];?\s*\n?/g, "");
|
|
174980
175452
|
dtsContent = dtsContent.replace(/[\w_]+\.JSX\.Element/g, "any");
|
|
174981
175453
|
dtsContent = dtsContent.replace(/export\s*{\s*};\s*$/gm, "").trim();
|
|
174982
|
-
const dtsOutputPath =
|
|
174983
|
-
|
|
174984
|
-
console.log(`Type declarations written to ${
|
|
175454
|
+
const dtsOutputPath = path52.join(outputDir, "index.d.ts");
|
|
175455
|
+
fs51.writeFileSync(dtsOutputPath, dtsContent);
|
|
175456
|
+
console.log(`Type declarations written to ${path52.relative(projectDir, dtsOutputPath)}`);
|
|
174985
175457
|
console.log(kleur_default.green("Transpilation complete!"));
|
|
174986
175458
|
return true;
|
|
174987
175459
|
} catch (err) {
|
|
@@ -174994,17 +175466,17 @@ var transpileFile = async ({
|
|
|
174994
175466
|
};
|
|
174995
175467
|
|
|
174996
175468
|
// cli/utils/validate-main-in-dist.ts
|
|
174997
|
-
import
|
|
174998
|
-
import
|
|
175469
|
+
import fs52 from "node:fs";
|
|
175470
|
+
import path53 from "node:path";
|
|
174999
175471
|
var validateMainInDist = (projectDir, distDir) => {
|
|
175000
|
-
const packageJsonPath =
|
|
175001
|
-
if (!
|
|
175472
|
+
const packageJsonPath = path53.join(projectDir, "package.json");
|
|
175473
|
+
if (!fs52.existsSync(packageJsonPath))
|
|
175002
175474
|
return;
|
|
175003
|
-
const packageJson = JSON.parse(
|
|
175475
|
+
const packageJson = JSON.parse(fs52.readFileSync(packageJsonPath, "utf-8"));
|
|
175004
175476
|
if (typeof packageJson.main !== "string")
|
|
175005
175477
|
return;
|
|
175006
|
-
const resolvedMainPath =
|
|
175007
|
-
const isMainInDist = resolvedMainPath === distDir || resolvedMainPath.startsWith(`${distDir}${
|
|
175478
|
+
const resolvedMainPath = path53.resolve(projectDir, packageJson.main);
|
|
175479
|
+
const isMainInDist = resolvedMainPath === distDir || resolvedMainPath.startsWith(`${distDir}${path53.sep}`);
|
|
175008
175480
|
if (!isMainInDist) {
|
|
175009
175481
|
console.warn('When using transpilation, your package\'s "main" field should point inside the `dist/*` directory, usually to "dist/index.js"');
|
|
175010
175482
|
}
|
|
@@ -175026,19 +175498,19 @@ async function getLatestTscircuitCdnUrl() {
|
|
|
175026
175498
|
}
|
|
175027
175499
|
|
|
175028
175500
|
// cli/build/worker-pool.ts
|
|
175029
|
-
import
|
|
175030
|
-
import
|
|
175501
|
+
import path54 from "node:path";
|
|
175502
|
+
import fs53 from "node:fs";
|
|
175031
175503
|
import { Worker } from "node:worker_threads";
|
|
175032
175504
|
var getWorkerEntrypointPath = () => {
|
|
175033
|
-
const tsPath =
|
|
175034
|
-
if (
|
|
175505
|
+
const tsPath = path54.join(import.meta.dir, "build-worker-entrypoint.ts");
|
|
175506
|
+
if (fs53.existsSync(tsPath)) {
|
|
175035
175507
|
return tsPath;
|
|
175036
175508
|
}
|
|
175037
|
-
const jsBundledPath =
|
|
175038
|
-
if (
|
|
175509
|
+
const jsBundledPath = path54.join(import.meta.dir, "build", "build-worker-entrypoint.js");
|
|
175510
|
+
if (fs53.existsSync(jsBundledPath)) {
|
|
175039
175511
|
return jsBundledPath;
|
|
175040
175512
|
}
|
|
175041
|
-
return
|
|
175513
|
+
return path54.join(import.meta.dir, "build-worker-entrypoint.js");
|
|
175042
175514
|
};
|
|
175043
175515
|
|
|
175044
175516
|
class WorkerPool {
|
|
@@ -175197,25 +175669,25 @@ async function buildFilesWithWorkerPool(options) {
|
|
|
175197
175669
|
}
|
|
175198
175670
|
|
|
175199
175671
|
// cli/build/register.ts
|
|
175200
|
-
var normalizeRelativePath = (projectDir, targetPath) =>
|
|
175672
|
+
var normalizeRelativePath = (projectDir, targetPath) => path55.relative(projectDir, targetPath).split(path55.sep).join("/");
|
|
175201
175673
|
var registerBuild = (program3) => {
|
|
175202
|
-
program3.command("build").description("Run tscircuit eval and output circuit json").argument("[file]", "Path to the entry file").option("--ci", "Run install and optional prebuild/build commands (or default CI build)").option("--ignore-errors", "Do not exit with code 1 on errors").option("--ignore-warnings", "Do not log warnings").option("--ignore-config", "Ignore options from tscircuit.config.json").option("--disable-pcb", "Disable PCB outputs").option("--disable-parts-engine", "Disable the parts engine").option("--site", "Generate a static site in the dist directory").option("--transpile", "Transpile the entry file to JavaScript").option("--preview-images", "Generate preview images in the dist directory").option("--all-images", "Generate preview images for every successful build output").option("--kicad", "Generate KiCad project directories for each successful build output").option("--kicad-library", "Generate KiCad library in dist/kicad-library").option("--preview-gltf", "Generate a GLTF file from the preview entrypoint").option("--kicad-pcm", "Generate KiCad PCM (Plugin and Content Manager) assets in dist/pcm").option("--use-cdn-javascript", "Use CDN-hosted JavaScript instead of bundled standalone file for --site").option("--concurrency <number>", "Number of files to build in parallel (default: 1)", "1").action(async (file, options) => {
|
|
175674
|
+
program3.command("build").description("Run tscircuit eval and output circuit json").argument("[file]", "Path to the entry file").option("--ci", "Run install and optional prebuild/build commands (or default CI build)").option("--ignore-errors", "Do not exit with code 1 on errors").option("--ignore-warnings", "Do not log warnings").option("--ignore-config", "Ignore options from tscircuit.config.json").option("--disable-pcb", "Disable PCB outputs").option("--disable-parts-engine", "Disable the parts engine").option("--site", "Generate a static site in the dist directory").option("--transpile", "Transpile the entry file to JavaScript").option("--preview-images", "Generate preview images in the dist directory").option("--all-images", "Generate preview images for every successful build output").option("--kicad", "Generate KiCad project directories for each successful build output").option("--kicad-library", "Generate KiCad library in dist/kicad-library").option("--preview-gltf", "Generate a GLTF file from the preview entrypoint").option("--glbs", "Generate GLB 3D model files for every successful build").option("--kicad-pcm", "Generate KiCad PCM (Plugin and Content Manager) assets in dist/pcm").option("--use-cdn-javascript", "Use CDN-hosted JavaScript instead of bundled standalone file for --site").option("--concurrency <number>", "Number of files to build in parallel (default: 1)", "1").action(async (file, options) => {
|
|
175203
175675
|
try {
|
|
175204
|
-
const resolvedRoot =
|
|
175676
|
+
const resolvedRoot = path55.resolve(process.cwd());
|
|
175205
175677
|
let projectDir;
|
|
175206
175678
|
if (file) {
|
|
175207
|
-
const resolved =
|
|
175208
|
-
if (
|
|
175679
|
+
const resolved = path55.resolve(resolvedRoot, file);
|
|
175680
|
+
if (fs54.existsSync(resolved) && fs54.statSync(resolved).isDirectory()) {
|
|
175209
175681
|
projectDir = resolvedRoot;
|
|
175210
175682
|
} else {
|
|
175211
|
-
let currentDir =
|
|
175212
|
-
while (currentDir !==
|
|
175213
|
-
if (
|
|
175683
|
+
let currentDir = path55.dirname(resolved);
|
|
175684
|
+
while (currentDir !== path55.dirname(currentDir)) {
|
|
175685
|
+
if (fs54.existsSync(path55.join(currentDir, "package.json"))) {
|
|
175214
175686
|
break;
|
|
175215
175687
|
}
|
|
175216
|
-
currentDir =
|
|
175688
|
+
currentDir = path55.dirname(currentDir);
|
|
175217
175689
|
}
|
|
175218
|
-
projectDir =
|
|
175690
|
+
projectDir = fs54.existsSync(path55.join(currentDir, "package.json")) ? currentDir : resolvedRoot;
|
|
175219
175691
|
}
|
|
175220
175692
|
} else {
|
|
175221
175693
|
projectDir = resolvedRoot;
|
|
@@ -175253,8 +175725,8 @@ var registerBuild = (program3) => {
|
|
|
175253
175725
|
}
|
|
175254
175726
|
return config;
|
|
175255
175727
|
})();
|
|
175256
|
-
const distDir =
|
|
175257
|
-
|
|
175728
|
+
const distDir = path55.join(projectDir, "dist");
|
|
175729
|
+
fs54.mkdirSync(distDir, { recursive: true });
|
|
175258
175730
|
const concurrencyValue = Math.max(1, Number.parseInt(resolvedOptions?.concurrency || "1", 10));
|
|
175259
175731
|
if (concurrencyValue > 1) {
|
|
175260
175732
|
console.log(`Building ${circuitFiles.length} file(s) with concurrency ${concurrencyValue}...`);
|
|
@@ -175273,7 +175745,7 @@ var registerBuild = (program3) => {
|
|
|
175273
175745
|
platformConfig: platformConfig2
|
|
175274
175746
|
};
|
|
175275
175747
|
const processBuildResult = async (filePath, outputPath, buildOutcome) => {
|
|
175276
|
-
const relative10 =
|
|
175748
|
+
const relative10 = path55.relative(projectDir, filePath);
|
|
175277
175749
|
const outputDirName = relative10.replace(/(\.board|\.circuit)?\.tsx$/, "");
|
|
175278
175750
|
builtFiles.push({
|
|
175279
175751
|
sourcePath: filePath,
|
|
@@ -175287,9 +175759,9 @@ var registerBuild = (program3) => {
|
|
|
175287
175759
|
console.error(kleur_default.red(`Fatal error [${buildOutcome.isFatalError.errorType}]: ${buildOutcome.isFatalError.message}`));
|
|
175288
175760
|
}
|
|
175289
175761
|
} else if (resolvedOptions?.site) {
|
|
175290
|
-
const normalizedSourcePath = relative10.split(
|
|
175291
|
-
const relativeOutputPath =
|
|
175292
|
-
const normalizedOutputPath = relativeOutputPath.split(
|
|
175762
|
+
const normalizedSourcePath = relative10.split(path55.sep).join("/");
|
|
175763
|
+
const relativeOutputPath = path55.join(outputDirName, "circuit.json");
|
|
175764
|
+
const normalizedOutputPath = relativeOutputPath.split(path55.sep).join("/");
|
|
175293
175765
|
staticFileReferences.push({
|
|
175294
175766
|
filePath: normalizedSourcePath,
|
|
175295
175767
|
fileStaticAssetUrl: `./${normalizedOutputPath}`
|
|
@@ -175297,12 +175769,12 @@ var registerBuild = (program3) => {
|
|
|
175297
175769
|
}
|
|
175298
175770
|
if (buildOutcome.ok && shouldGenerateKicad) {
|
|
175299
175771
|
let circuitJson = buildOutcome.circuitJson;
|
|
175300
|
-
if (!circuitJson &&
|
|
175301
|
-
circuitJson = JSON.parse(
|
|
175772
|
+
if (!circuitJson && fs54.existsSync(outputPath)) {
|
|
175773
|
+
circuitJson = JSON.parse(fs54.readFileSync(outputPath, "utf-8"));
|
|
175302
175774
|
}
|
|
175303
175775
|
if (circuitJson) {
|
|
175304
|
-
const projectOutputDir =
|
|
175305
|
-
const projectName =
|
|
175776
|
+
const projectOutputDir = path55.join(distDir, outputDirName, "kicad");
|
|
175777
|
+
const projectName = path55.basename(outputDirName);
|
|
175306
175778
|
const project = await generateKicadProject({
|
|
175307
175779
|
circuitJson,
|
|
175308
175780
|
outputDir: projectOutputDir,
|
|
@@ -175318,19 +175790,19 @@ var registerBuild = (program3) => {
|
|
|
175318
175790
|
};
|
|
175319
175791
|
const buildSequentially = async () => {
|
|
175320
175792
|
for (const filePath of circuitFiles) {
|
|
175321
|
-
const relative10 =
|
|
175793
|
+
const relative10 = path55.relative(projectDir, filePath);
|
|
175322
175794
|
console.log(`Building ${relative10}...`);
|
|
175323
175795
|
const outputDirName = relative10.replace(/(\.board|\.circuit)?\.tsx$/, "");
|
|
175324
|
-
const outputPath =
|
|
175796
|
+
const outputPath = path55.join(distDir, outputDirName, "circuit.json");
|
|
175325
175797
|
const buildOutcome = await buildFile(filePath, outputPath, projectDir, buildOptions);
|
|
175326
175798
|
await processBuildResult(filePath, outputPath, buildOutcome);
|
|
175327
175799
|
}
|
|
175328
175800
|
};
|
|
175329
175801
|
const buildWithWorkers = async () => {
|
|
175330
175802
|
const filesToBuild = circuitFiles.map((filePath) => {
|
|
175331
|
-
const relative10 =
|
|
175803
|
+
const relative10 = path55.relative(projectDir, filePath);
|
|
175332
175804
|
const outputDirName = relative10.replace(/(\.board|\.circuit)?\.tsx$/, "");
|
|
175333
|
-
const outputPath =
|
|
175805
|
+
const outputPath = path55.join(distDir, outputDirName, "circuit.json");
|
|
175334
175806
|
return { filePath, outputPath };
|
|
175335
175807
|
});
|
|
175336
175808
|
await buildFilesWithWorkerPool({
|
|
@@ -175344,7 +175816,7 @@ var registerBuild = (program3) => {
|
|
|
175344
175816
|
}
|
|
175345
175817
|
},
|
|
175346
175818
|
onJobComplete: async (result) => {
|
|
175347
|
-
const relative10 =
|
|
175819
|
+
const relative10 = path55.relative(projectDir, result.filePath);
|
|
175348
175820
|
if (result.ok) {
|
|
175349
175821
|
console.log(kleur_default.green(`✓ ${relative10}`));
|
|
175350
175822
|
} else {
|
|
@@ -175388,6 +175860,13 @@ var registerBuild = (program3) => {
|
|
|
175388
175860
|
previewComponentPath
|
|
175389
175861
|
});
|
|
175390
175862
|
}
|
|
175863
|
+
if (resolvedOptions?.glbs) {
|
|
175864
|
+
console.log("Generating GLB models for all builds...");
|
|
175865
|
+
await buildGlbs({
|
|
175866
|
+
builtFiles,
|
|
175867
|
+
distDir
|
|
175868
|
+
});
|
|
175869
|
+
}
|
|
175391
175870
|
if (resolvedOptions?.transpile) {
|
|
175392
175871
|
validateMainInDist(projectDir, distDir);
|
|
175393
175872
|
console.log("Transpiling entry file...");
|
|
@@ -175415,14 +175894,14 @@ var registerBuild = (program3) => {
|
|
|
175415
175894
|
if (resolvedOptions?.useCdnJavascript) {
|
|
175416
175895
|
standaloneScriptSrc = await getLatestTscircuitCdnUrl();
|
|
175417
175896
|
} else {
|
|
175418
|
-
|
|
175897
|
+
fs54.writeFileSync(path55.join(distDir, "standalone.min.js"), standalone_min_default);
|
|
175419
175898
|
}
|
|
175420
175899
|
const indexHtml = getStaticIndexHtmlFile({
|
|
175421
175900
|
files: staticFileReferences,
|
|
175422
175901
|
standaloneScriptSrc,
|
|
175423
175902
|
defaultMainComponentPath: siteDefaultComponentPath ? normalizeRelativePath(projectDir, siteDefaultComponentPath) : undefined
|
|
175424
175903
|
});
|
|
175425
|
-
|
|
175904
|
+
fs54.writeFileSync(path55.join(distDir, "index.html"), indexHtml);
|
|
175426
175905
|
}
|
|
175427
175906
|
if (resolvedOptions?.kicadLibrary) {
|
|
175428
175907
|
console.log("Generating KiCad library...");
|
|
@@ -175442,14 +175921,14 @@ var registerBuild = (program3) => {
|
|
|
175442
175921
|
}
|
|
175443
175922
|
} else {
|
|
175444
175923
|
const libraryName = resolveKicadLibraryName({ projectDir });
|
|
175445
|
-
const kicadLibOutputDir =
|
|
175924
|
+
const kicadLibOutputDir = path55.join(distDir, "kicad-library");
|
|
175446
175925
|
try {
|
|
175447
175926
|
await convertToKicadLibrary({
|
|
175448
175927
|
filePath: entryFile,
|
|
175449
175928
|
libraryName,
|
|
175450
175929
|
outputDir: kicadLibOutputDir
|
|
175451
175930
|
});
|
|
175452
|
-
console.log(` KiCad library generated at ${kleur_default.dim(
|
|
175931
|
+
console.log(` KiCad library generated at ${kleur_default.dim(path55.relative(process.cwd(), kicadLibOutputDir))}`);
|
|
175453
175932
|
} catch (err) {
|
|
175454
175933
|
console.error(`Error generating KiCad library: ${err instanceof Error ? err.message : err}`);
|
|
175455
175934
|
if (!resolvedOptions?.ignoreErrors) {
|
|
@@ -175496,6 +175975,7 @@ var registerBuild = (program3) => {
|
|
|
175496
175975
|
resolvedOptions?.transpile && "transpile",
|
|
175497
175976
|
resolvedOptions?.previewImages && "preview-images",
|
|
175498
175977
|
resolvedOptions?.allImages && "all-images",
|
|
175978
|
+
resolvedOptions?.glbs && "glbs",
|
|
175499
175979
|
resolvedOptions?.kicad && "kicad",
|
|
175500
175980
|
resolvedOptions?.kicadLibrary && "kicad-library",
|
|
175501
175981
|
resolvedOptions?.kicadPcm && "kicad-pcm",
|
|
@@ -175510,7 +175990,7 @@ var registerBuild = (program3) => {
|
|
|
175510
175990
|
if (configAppliedOpts.length > 0) {
|
|
175511
175991
|
console.log(` Config ${kleur_default.magenta(configAppliedOpts.join(", "))} ${kleur_default.dim("(from tscircuit.config.json)")}`);
|
|
175512
175992
|
}
|
|
175513
|
-
console.log(` Output ${kleur_default.dim(
|
|
175993
|
+
console.log(` Output ${kleur_default.dim(path55.relative(process.cwd(), distDir) || "dist")}`);
|
|
175514
175994
|
console.log(hasErrors ? kleur_default.yellow(`
|
|
175515
175995
|
⚠ Build completed with errors`) : kleur_default.green(`
|
|
175516
175996
|
✓ Done`));
|
|
@@ -175524,19 +176004,19 @@ var registerBuild = (program3) => {
|
|
|
175524
176004
|
};
|
|
175525
176005
|
|
|
175526
176006
|
// lib/shared/snapshot-project.ts
|
|
175527
|
-
import
|
|
175528
|
-
import
|
|
176007
|
+
import fs56 from "node:fs";
|
|
176008
|
+
import path56 from "node:path";
|
|
175529
176009
|
import looksSame2 from "looks-same";
|
|
175530
176010
|
import {
|
|
175531
176011
|
convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg3,
|
|
175532
176012
|
convertCircuitJsonToSchematicSvg as convertCircuitJsonToSchematicSvg3
|
|
175533
176013
|
} from "circuit-to-svg";
|
|
175534
|
-
import { convertCircuitJsonToGltf as
|
|
176014
|
+
import { convertCircuitJsonToGltf as convertCircuitJsonToGltf5 } from "circuit-json-to-gltf";
|
|
175535
176015
|
import { renderGLTFToPNGBufferFromGLBBuffer as renderGLTFToPNGBufferFromGLBBuffer2 } from "poppygl";
|
|
175536
176016
|
|
|
175537
176017
|
// lib/shared/compare-images.ts
|
|
175538
176018
|
import looksSame from "looks-same";
|
|
175539
|
-
import
|
|
176019
|
+
import fs55 from "node:fs/promises";
|
|
175540
176020
|
var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
|
|
175541
176021
|
const { equal: equal2 } = await looksSame(buffer1, buffer2, {
|
|
175542
176022
|
strict: false,
|
|
@@ -175552,7 +176032,7 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
|
|
|
175552
176032
|
tolerance: 2
|
|
175553
176033
|
});
|
|
175554
176034
|
} else {
|
|
175555
|
-
await
|
|
176035
|
+
await fs55.writeFile(diffPath, buffer2);
|
|
175556
176036
|
}
|
|
175557
176037
|
}
|
|
175558
176038
|
return { equal: equal2 };
|
|
@@ -175577,7 +176057,7 @@ var snapshotProject = async ({
|
|
|
175577
176057
|
...DEFAULT_IGNORED_PATTERNS,
|
|
175578
176058
|
...ignored.map(normalizeIgnorePattern)
|
|
175579
176059
|
];
|
|
175580
|
-
const resolvedPaths = filePaths.map((f2) =>
|
|
176060
|
+
const resolvedPaths = filePaths.map((f2) => path56.resolve(projectDir, f2));
|
|
175581
176061
|
const boardFiles = findBoardFiles({
|
|
175582
176062
|
projectDir,
|
|
175583
176063
|
ignore,
|
|
@@ -175591,7 +176071,7 @@ var snapshotProject = async ({
|
|
|
175591
176071
|
const mismatches = [];
|
|
175592
176072
|
let didUpdate = false;
|
|
175593
176073
|
for (const file of boardFiles) {
|
|
175594
|
-
const relativeFilePath =
|
|
176074
|
+
const relativeFilePath = path56.relative(projectDir, file);
|
|
175595
176075
|
let circuitJson;
|
|
175596
176076
|
let pcbSvg;
|
|
175597
176077
|
let schSvg;
|
|
@@ -175633,7 +176113,7 @@ var snapshotProject = async ({
|
|
|
175633
176113
|
let png3d = null;
|
|
175634
176114
|
if (threeD) {
|
|
175635
176115
|
try {
|
|
175636
|
-
const glbBuffer = await
|
|
176116
|
+
const glbBuffer = await convertCircuitJsonToGltf5(circuitJson, {
|
|
175637
176117
|
format: "glb"
|
|
175638
176118
|
});
|
|
175639
176119
|
if (!(glbBuffer instanceof ArrayBuffer)) {
|
|
@@ -175646,17 +176126,17 @@ var snapshotProject = async ({
|
|
|
175646
176126
|
} catch (error) {
|
|
175647
176127
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
175648
176128
|
if (errorMessage.includes("No pcb_board found in circuit JSON")) {
|
|
175649
|
-
const fileDir =
|
|
175650
|
-
const relativeDir =
|
|
175651
|
-
const snapDir2 = snapshotsDirName ?
|
|
175652
|
-
const base2 =
|
|
175653
|
-
const snap3dPath =
|
|
175654
|
-
const existing3dSnapshot =
|
|
176129
|
+
const fileDir = path56.dirname(file);
|
|
176130
|
+
const relativeDir = path56.relative(projectDir, fileDir);
|
|
176131
|
+
const snapDir2 = snapshotsDirName ? path56.join(projectDir, snapshotsDirName, relativeDir) : path56.join(fileDir, "__snapshots__");
|
|
176132
|
+
const base2 = path56.basename(file).replace(/\.tsx$/, "");
|
|
176133
|
+
const snap3dPath = path56.join(snapDir2, `${base2}-3d.snap.png`);
|
|
176134
|
+
const existing3dSnapshot = fs56.existsSync(snap3dPath);
|
|
175655
176135
|
if (existing3dSnapshot) {
|
|
175656
176136
|
onError(kleur_default.red(`
|
|
175657
176137
|
❌ Failed to generate 3D snapshot for ${relativeFilePath}:
|
|
175658
176138
|
`) + kleur_default.red(` No pcb_board found in circuit JSON
|
|
175659
|
-
`) + kleur_default.red(` Existing snapshot: ${
|
|
176139
|
+
`) + kleur_default.red(` Existing snapshot: ${path56.relative(projectDir, snap3dPath)}
|
|
175660
176140
|
`));
|
|
175661
176141
|
return onExit2(1);
|
|
175662
176142
|
} else {
|
|
@@ -175672,9 +176152,9 @@ var snapshotProject = async ({
|
|
|
175672
176152
|
}
|
|
175673
176153
|
}
|
|
175674
176154
|
}
|
|
175675
|
-
const snapDir = snapshotsDirName ?
|
|
175676
|
-
|
|
175677
|
-
const base =
|
|
176155
|
+
const snapDir = snapshotsDirName ? path56.join(projectDir, snapshotsDirName, path56.relative(projectDir, path56.dirname(file))) : path56.join(path56.dirname(file), "__snapshots__");
|
|
176156
|
+
fs56.mkdirSync(snapDir, { recursive: true });
|
|
176157
|
+
const base = path56.basename(file).replace(/\.tsx$/, "");
|
|
175678
176158
|
const snapshots = [];
|
|
175679
176159
|
if (pcbOnly || !schematicOnly) {
|
|
175680
176160
|
snapshots.push({ type: "pcb", content: pcbSvg, isBinary: false });
|
|
@@ -175692,31 +176172,31 @@ var snapshotProject = async ({
|
|
|
175692
176172
|
for (const snapshot of snapshots) {
|
|
175693
176173
|
const { type } = snapshot;
|
|
175694
176174
|
const is3d = type === "3d";
|
|
175695
|
-
const snapPath =
|
|
175696
|
-
const existing =
|
|
176175
|
+
const snapPath = path56.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
|
|
176176
|
+
const existing = fs56.existsSync(snapPath);
|
|
175697
176177
|
const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
|
|
175698
176178
|
const newContentForFile = snapshot.content;
|
|
175699
176179
|
if (!existing) {
|
|
175700
|
-
|
|
175701
|
-
console.log("✅", kleur_default.gray(
|
|
176180
|
+
fs56.writeFileSync(snapPath, newContentForFile);
|
|
176181
|
+
console.log("✅", kleur_default.gray(path56.relative(projectDir, snapPath)));
|
|
175702
176182
|
didUpdate = true;
|
|
175703
176183
|
continue;
|
|
175704
176184
|
}
|
|
175705
|
-
const oldContentBuffer =
|
|
176185
|
+
const oldContentBuffer = fs56.readFileSync(snapPath);
|
|
175706
176186
|
const diffPath = snapPath.replace(is3d ? ".snap.png" : ".snap.svg", is3d ? ".diff.png" : ".diff.svg");
|
|
175707
176187
|
const { equal: equal2 } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath);
|
|
175708
176188
|
if (update) {
|
|
175709
176189
|
if (!forceUpdate && equal2) {
|
|
175710
|
-
console.log("✅", kleur_default.gray(
|
|
176190
|
+
console.log("✅", kleur_default.gray(path56.relative(projectDir, snapPath)));
|
|
175711
176191
|
} else {
|
|
175712
|
-
|
|
175713
|
-
console.log("✅", kleur_default.gray(
|
|
176192
|
+
fs56.writeFileSync(snapPath, newContentForFile);
|
|
176193
|
+
console.log("✅", kleur_default.gray(path56.relative(projectDir, snapPath)));
|
|
175714
176194
|
didUpdate = true;
|
|
175715
176195
|
}
|
|
175716
176196
|
} else if (!equal2) {
|
|
175717
176197
|
mismatches.push(`${snapPath} (diff: ${diffPath})`);
|
|
175718
176198
|
} else {
|
|
175719
|
-
console.log("✅", kleur_default.gray(
|
|
176199
|
+
console.log("✅", kleur_default.gray(path56.relative(projectDir, snapPath)));
|
|
175720
176200
|
}
|
|
175721
176201
|
}
|
|
175722
176202
|
}
|
|
@@ -175755,22 +176235,22 @@ var registerSnapshot = (program3) => {
|
|
|
175755
176235
|
};
|
|
175756
176236
|
|
|
175757
176237
|
// lib/shared/setup-github-actions.ts
|
|
175758
|
-
import
|
|
175759
|
-
import
|
|
176238
|
+
import fs57 from "node:fs";
|
|
176239
|
+
import path57 from "node:path";
|
|
175760
176240
|
var setupGithubActions = (projectDir = process.cwd()) => {
|
|
175761
176241
|
const findGitRoot = (startDir) => {
|
|
175762
|
-
let dir =
|
|
175763
|
-
while (dir !==
|
|
175764
|
-
if (
|
|
176242
|
+
let dir = path57.resolve(startDir);
|
|
176243
|
+
while (dir !== path57.parse(dir).root) {
|
|
176244
|
+
if (fs57.existsSync(path57.join(dir, ".git"))) {
|
|
175765
176245
|
return dir;
|
|
175766
176246
|
}
|
|
175767
|
-
dir =
|
|
176247
|
+
dir = path57.dirname(dir);
|
|
175768
176248
|
}
|
|
175769
176249
|
return null;
|
|
175770
176250
|
};
|
|
175771
176251
|
const gitRoot = findGitRoot(projectDir) ?? projectDir;
|
|
175772
|
-
const workflowsDir =
|
|
175773
|
-
|
|
176252
|
+
const workflowsDir = path57.join(gitRoot, ".github", "workflows");
|
|
176253
|
+
fs57.mkdirSync(workflowsDir, { recursive: true });
|
|
175774
176254
|
const buildWorkflow = `name: tscircuit Build
|
|
175775
176255
|
|
|
175776
176256
|
on:
|
|
@@ -175809,8 +176289,8 @@ jobs:
|
|
|
175809
176289
|
- run: bun install
|
|
175810
176290
|
- run: bunx tsci snapshot
|
|
175811
176291
|
`;
|
|
175812
|
-
writeFileIfNotExists(
|
|
175813
|
-
writeFileIfNotExists(
|
|
176292
|
+
writeFileIfNotExists(path57.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
|
|
176293
|
+
writeFileIfNotExists(path57.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
|
|
175814
176294
|
};
|
|
175815
176295
|
|
|
175816
176296
|
// cli/setup/register.ts
|
|
@@ -175848,8 +176328,8 @@ function registerAuthSetupNpmrc(program3) {
|
|
|
175848
176328
|
}
|
|
175849
176329
|
|
|
175850
176330
|
// cli/convert/register.ts
|
|
175851
|
-
import
|
|
175852
|
-
import
|
|
176331
|
+
import fs58 from "node:fs/promises";
|
|
176332
|
+
import path58 from "node:path";
|
|
175853
176333
|
import { parseKicadModToCircuitJson } from "kicad-component-converter";
|
|
175854
176334
|
|
|
175855
176335
|
// node_modules/@tscircuit/mm/dist/index.js
|
|
@@ -175970,15 +176450,15 @@ var convertCircuitJsonToTscircuit = (circuitJson, opts) => {
|
|
|
175970
176450
|
var registerConvert = (program3) => {
|
|
175971
176451
|
program3.command("convert").description("Convert a .kicad_mod footprint to a tscircuit component").argument("<file>", "Path to the .kicad_mod file").option("-o, --output <path>", "Output TSX file path").option("-n, --name <component>", "Component name for export").action(async (file, options) => {
|
|
175972
176452
|
try {
|
|
175973
|
-
const inputPath =
|
|
175974
|
-
const modContent = await
|
|
176453
|
+
const inputPath = path58.resolve(file);
|
|
176454
|
+
const modContent = await fs58.readFile(inputPath, "utf-8");
|
|
175975
176455
|
const circuitJson = await parseKicadModToCircuitJson(modContent);
|
|
175976
|
-
const componentName = options.name ??
|
|
176456
|
+
const componentName = options.name ?? path58.basename(inputPath, ".kicad_mod");
|
|
175977
176457
|
const tsx = convertCircuitJsonToTscircuit(circuitJson, {
|
|
175978
176458
|
componentName
|
|
175979
176459
|
});
|
|
175980
|
-
const outputPath = options.output ?
|
|
175981
|
-
await
|
|
176460
|
+
const outputPath = options.output ? path58.resolve(options.output) : path58.join(path58.dirname(inputPath), `${componentName}.tsx`);
|
|
176461
|
+
await fs58.writeFile(outputPath, tsx);
|
|
175982
176462
|
console.log(kleur_default.green(`Converted ${outputPath}`));
|
|
175983
176463
|
} catch (error) {
|
|
175984
176464
|
console.error(kleur_default.red("Failed to convert footprint:"), error instanceof Error ? error.message : error);
|
|
@@ -176094,7 +176574,7 @@ var registerInstall = (program3) => {
|
|
|
176094
176574
|
};
|
|
176095
176575
|
|
|
176096
176576
|
// cli/transpile/register.ts
|
|
176097
|
-
import
|
|
176577
|
+
import path59 from "node:path";
|
|
176098
176578
|
var registerTranspile = (program3) => {
|
|
176099
176579
|
program3.command("transpile").description("Transpile TypeScript/TSX to JavaScript (ESM, CommonJS, and type declarations)").argument("[file]", "Path to the entry file").action(async (file) => {
|
|
176100
176580
|
try {
|
|
@@ -176102,7 +176582,7 @@ var registerTranspile = (program3) => {
|
|
|
176102
176582
|
fileOrDir: file,
|
|
176103
176583
|
includeBoardFiles: false
|
|
176104
176584
|
});
|
|
176105
|
-
const distDir =
|
|
176585
|
+
const distDir = path59.join(projectDir, "dist");
|
|
176106
176586
|
validateMainInDist(projectDir, distDir);
|
|
176107
176587
|
console.log("Transpiling entry file...");
|
|
176108
176588
|
const entryFile = mainEntrypoint || circuitFiles[0];
|
|
@@ -176130,8 +176610,8 @@ var registerTranspile = (program3) => {
|
|
|
176130
176610
|
};
|
|
176131
176611
|
|
|
176132
176612
|
// lib/shared/register-static-asset-loaders.ts
|
|
176133
|
-
import
|
|
176134
|
-
import
|
|
176613
|
+
import fs59 from "node:fs";
|
|
176614
|
+
import path60 from "node:path";
|
|
176135
176615
|
var STATIC_ASSET_EXTENSIONS2 = [
|
|
176136
176616
|
".glb",
|
|
176137
176617
|
".gltf",
|
|
@@ -176144,12 +176624,12 @@ var STATIC_ASSET_EXTENSIONS2 = [
|
|
|
176144
176624
|
var staticAssetFilter = new RegExp(`(${STATIC_ASSET_EXTENSIONS2.map((ext) => ext.replace(".", "\\.")).join("|")})$`, "i");
|
|
176145
176625
|
var registered = false;
|
|
176146
176626
|
var getBaseUrlFromTsConfig = () => {
|
|
176147
|
-
const tsconfigPath =
|
|
176627
|
+
const tsconfigPath = path60.join(process.cwd(), "tsconfig.json");
|
|
176148
176628
|
try {
|
|
176149
|
-
if (!
|
|
176629
|
+
if (!fs59.existsSync(tsconfigPath)) {
|
|
176150
176630
|
return null;
|
|
176151
176631
|
}
|
|
176152
|
-
const tsconfigContent =
|
|
176632
|
+
const tsconfigContent = fs59.readFileSync(tsconfigPath, "utf-8");
|
|
176153
176633
|
const tsconfig = JSON.parse(tsconfigContent);
|
|
176154
176634
|
if (tsconfig.compilerOptions?.baseUrl) {
|
|
176155
176635
|
return tsconfig.compilerOptions.baseUrl;
|
|
@@ -176167,8 +176647,8 @@ var registerStaticAssetLoaders = () => {
|
|
|
176167
176647
|
name: "tsci-static-assets",
|
|
176168
176648
|
setup(build) {
|
|
176169
176649
|
build.onLoad({ filter: staticAssetFilter }, (args) => {
|
|
176170
|
-
const baseDir = baseUrl ?
|
|
176171
|
-
const relativePath =
|
|
176650
|
+
const baseDir = baseUrl ? path60.resolve(process.cwd(), baseUrl) : process.cwd();
|
|
176651
|
+
const relativePath = path60.relative(baseDir, args.path).split(path60.sep).join("/");
|
|
176172
176652
|
const pathStr = `./${relativePath}`;
|
|
176173
176653
|
return {
|
|
176174
176654
|
exports: {
|
|
@@ -176199,15 +176679,15 @@ var checkLoggedIn = () => {
|
|
|
176199
176679
|
|
|
176200
176680
|
// cli/doctor/checks/check-npmrc-registry.ts
|
|
176201
176681
|
import { spawnSync } from "node:child_process";
|
|
176202
|
-
import
|
|
176682
|
+
import fs60 from "node:fs";
|
|
176203
176683
|
import os9 from "node:os";
|
|
176204
|
-
import
|
|
176684
|
+
import path61 from "node:path";
|
|
176205
176685
|
var hasBunInstalled = () => {
|
|
176206
176686
|
const result = spawnSync("bun", ["--version"], { stdio: "ignore" });
|
|
176207
176687
|
return result.status === 0;
|
|
176208
176688
|
};
|
|
176209
176689
|
var createTempProject = (tempDir) => {
|
|
176210
|
-
const packageJsonPath =
|
|
176690
|
+
const packageJsonPath = path61.join(tempDir, "package.json");
|
|
176211
176691
|
const packageJson = {
|
|
176212
176692
|
name: "tsci-doctor-check",
|
|
176213
176693
|
version: "0.0.0",
|
|
@@ -176216,7 +176696,7 @@ var createTempProject = (tempDir) => {
|
|
|
176216
176696
|
"@tsci/does-not-exist": "0.0.0"
|
|
176217
176697
|
}
|
|
176218
176698
|
};
|
|
176219
|
-
|
|
176699
|
+
fs60.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
176220
176700
|
};
|
|
176221
176701
|
var checkGlobalNpmrcRegistry = async () => {
|
|
176222
176702
|
const name = "Global .npmrc configured for tscircuit NPM registry?";
|
|
@@ -176227,7 +176707,7 @@ var checkGlobalNpmrcRegistry = async () => {
|
|
|
176227
176707
|
details: "Bun is required to verify registry settings. Install Bun and rerun `tsci doctor`."
|
|
176228
176708
|
};
|
|
176229
176709
|
}
|
|
176230
|
-
const tempDir =
|
|
176710
|
+
const tempDir = fs60.mkdtempSync(path61.join(os9.tmpdir(), "tsci-doctor-"));
|
|
176231
176711
|
try {
|
|
176232
176712
|
createTempProject(tempDir);
|
|
176233
176713
|
const result = spawnSync("bun", ["install"], {
|
|
@@ -176265,7 +176745,7 @@ ${result.stderr ?? ""}`;
|
|
|
176265
176745
|
}
|
|
176266
176746
|
return { name, success: true };
|
|
176267
176747
|
} finally {
|
|
176268
|
-
|
|
176748
|
+
fs60.rmSync(tempDir, { recursive: true, force: true });
|
|
176269
176749
|
}
|
|
176270
176750
|
};
|
|
176271
176751
|
|