easyeda 0.0.326 → 0.0.328
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/browser/index.d.ts +29 -11
- package/dist/browser/index.js +175 -28
- package/dist/browser/index.js.map +1 -1
- package/dist/index.d.ts +29 -11
- package/dist/index.js +175 -28
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +177 -30
- package/dist/main.cjs.map +1 -1
- package/package.json +2 -2
package/dist/browser/index.d.ts
CHANGED
|
@@ -234,9 +234,9 @@ declare const DataStrSchema: z.ZodEffects<z.ZodObject<{
|
|
|
234
234
|
y: number;
|
|
235
235
|
};
|
|
236
236
|
radius: number;
|
|
237
|
+
pathData: string;
|
|
237
238
|
lineWidth: number;
|
|
238
239
|
sweepFlag: boolean;
|
|
239
|
-
pathData: string;
|
|
240
240
|
color: string;
|
|
241
241
|
} | {
|
|
242
242
|
path: string;
|
|
@@ -606,9 +606,9 @@ declare const DataStrSchema: z.ZodEffects<z.ZodObject<{
|
|
|
606
606
|
y: number;
|
|
607
607
|
};
|
|
608
608
|
radius: number;
|
|
609
|
+
pathData: string;
|
|
609
610
|
lineWidth: number;
|
|
610
611
|
sweepFlag: boolean;
|
|
611
|
-
pathData: string;
|
|
612
612
|
color: string;
|
|
613
613
|
}, {
|
|
614
614
|
type: "ARC";
|
|
@@ -622,9 +622,9 @@ declare const DataStrSchema: z.ZodEffects<z.ZodObject<{
|
|
|
622
622
|
y: number;
|
|
623
623
|
};
|
|
624
624
|
radius: number;
|
|
625
|
+
pathData: string;
|
|
625
626
|
lineWidth: number;
|
|
626
627
|
sweepFlag: boolean;
|
|
627
|
-
pathData: string;
|
|
628
628
|
color: string;
|
|
629
629
|
}>]>>, "many">;
|
|
630
630
|
BBox: z.ZodOptional<z.ZodObject<{
|
|
@@ -681,9 +681,9 @@ declare const DataStrSchema: z.ZodEffects<z.ZodObject<{
|
|
|
681
681
|
y: number;
|
|
682
682
|
};
|
|
683
683
|
radius: number;
|
|
684
|
+
pathData: string;
|
|
684
685
|
lineWidth: number;
|
|
685
686
|
sweepFlag: boolean;
|
|
686
|
-
pathData: string;
|
|
687
687
|
color: string;
|
|
688
688
|
} | {
|
|
689
689
|
path: string;
|
|
@@ -831,9 +831,9 @@ declare const DataStrSchema: z.ZodEffects<z.ZodObject<{
|
|
|
831
831
|
y: number;
|
|
832
832
|
};
|
|
833
833
|
radius: number;
|
|
834
|
+
pathData: string;
|
|
834
835
|
lineWidth: number;
|
|
835
836
|
sweepFlag: boolean;
|
|
836
|
-
pathData: string;
|
|
837
837
|
color: string;
|
|
838
838
|
} | {
|
|
839
839
|
path: string;
|
|
@@ -1036,6 +1036,7 @@ declare const PackageDetailDataStrSchema: z.ZodObject<{
|
|
|
1036
1036
|
y: number;
|
|
1037
1037
|
}[];
|
|
1038
1038
|
layermask: number;
|
|
1039
|
+
pathData: string;
|
|
1039
1040
|
fillStyle: string;
|
|
1040
1041
|
id?: string | undefined;
|
|
1041
1042
|
layer?: number | undefined;
|
|
@@ -1294,6 +1295,7 @@ declare const PackageDetailDataStrSchema: z.ZodObject<{
|
|
|
1294
1295
|
} & {
|
|
1295
1296
|
type: z.ZodLiteral<"SOLIDREGION">;
|
|
1296
1297
|
layermask: z.ZodNumber;
|
|
1298
|
+
pathData: z.ZodString;
|
|
1297
1299
|
points: z.ZodArray<z.ZodPipeline<z.ZodEffects<z.ZodAny, any, any>, z.ZodObject<{
|
|
1298
1300
|
x: z.ZodNumber;
|
|
1299
1301
|
y: z.ZodNumber;
|
|
@@ -1312,6 +1314,7 @@ declare const PackageDetailDataStrSchema: z.ZodObject<{
|
|
|
1312
1314
|
y: number;
|
|
1313
1315
|
}[];
|
|
1314
1316
|
layermask: number;
|
|
1317
|
+
pathData: string;
|
|
1315
1318
|
fillStyle: string;
|
|
1316
1319
|
id?: string | undefined;
|
|
1317
1320
|
layer?: number | undefined;
|
|
@@ -1319,6 +1322,7 @@ declare const PackageDetailDataStrSchema: z.ZodObject<{
|
|
|
1319
1322
|
type: "SOLIDREGION";
|
|
1320
1323
|
points: any[];
|
|
1321
1324
|
layermask: number;
|
|
1325
|
+
pathData: string;
|
|
1322
1326
|
id?: string | undefined;
|
|
1323
1327
|
layer?: number | undefined;
|
|
1324
1328
|
fillStyle?: string | undefined;
|
|
@@ -1602,6 +1606,7 @@ declare const PackageDetailDataStrSchema: z.ZodObject<{
|
|
|
1602
1606
|
y: number;
|
|
1603
1607
|
}[];
|
|
1604
1608
|
layermask: number;
|
|
1609
|
+
pathData: string;
|
|
1605
1610
|
fillStyle: string;
|
|
1606
1611
|
id?: string | undefined;
|
|
1607
1612
|
layer?: number | undefined;
|
|
@@ -1845,6 +1850,7 @@ declare const PackageDetailSchema: z.ZodObject<{
|
|
|
1845
1850
|
y: number;
|
|
1846
1851
|
}[];
|
|
1847
1852
|
layermask: number;
|
|
1853
|
+
pathData: string;
|
|
1848
1854
|
fillStyle: string;
|
|
1849
1855
|
id?: string | undefined;
|
|
1850
1856
|
layer?: number | undefined;
|
|
@@ -2103,6 +2109,7 @@ declare const PackageDetailSchema: z.ZodObject<{
|
|
|
2103
2109
|
} & {
|
|
2104
2110
|
type: z.ZodLiteral<"SOLIDREGION">;
|
|
2105
2111
|
layermask: z.ZodNumber;
|
|
2112
|
+
pathData: z.ZodString;
|
|
2106
2113
|
points: z.ZodArray<z.ZodPipeline<z.ZodEffects<z.ZodAny, any, any>, z.ZodObject<{
|
|
2107
2114
|
x: z.ZodNumber;
|
|
2108
2115
|
y: z.ZodNumber;
|
|
@@ -2121,6 +2128,7 @@ declare const PackageDetailSchema: z.ZodObject<{
|
|
|
2121
2128
|
y: number;
|
|
2122
2129
|
}[];
|
|
2123
2130
|
layermask: number;
|
|
2131
|
+
pathData: string;
|
|
2124
2132
|
fillStyle: string;
|
|
2125
2133
|
id?: string | undefined;
|
|
2126
2134
|
layer?: number | undefined;
|
|
@@ -2128,6 +2136,7 @@ declare const PackageDetailSchema: z.ZodObject<{
|
|
|
2128
2136
|
type: "SOLIDREGION";
|
|
2129
2137
|
points: any[];
|
|
2130
2138
|
layermask: number;
|
|
2139
|
+
pathData: string;
|
|
2131
2140
|
id?: string | undefined;
|
|
2132
2141
|
layer?: number | undefined;
|
|
2133
2142
|
fillStyle?: string | undefined;
|
|
@@ -2411,6 +2420,7 @@ declare const PackageDetailSchema: z.ZodObject<{
|
|
|
2411
2420
|
y: number;
|
|
2412
2421
|
}[];
|
|
2413
2422
|
layermask: number;
|
|
2423
|
+
pathData: string;
|
|
2414
2424
|
fillStyle: string;
|
|
2415
2425
|
id?: string | undefined;
|
|
2416
2426
|
layer?: number | undefined;
|
|
@@ -2606,6 +2616,7 @@ declare const PackageDetailSchema: z.ZodObject<{
|
|
|
2606
2616
|
y: number;
|
|
2607
2617
|
}[];
|
|
2608
2618
|
layermask: number;
|
|
2619
|
+
pathData: string;
|
|
2609
2620
|
fillStyle: string;
|
|
2610
2621
|
id?: string | undefined;
|
|
2611
2622
|
layer?: number | undefined;
|
|
@@ -2942,9 +2953,9 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
|
|
|
2942
2953
|
y: number;
|
|
2943
2954
|
};
|
|
2944
2955
|
radius: number;
|
|
2956
|
+
pathData: string;
|
|
2945
2957
|
lineWidth: number;
|
|
2946
2958
|
sweepFlag: boolean;
|
|
2947
|
-
pathData: string;
|
|
2948
2959
|
color: string;
|
|
2949
2960
|
} | {
|
|
2950
2961
|
path: string;
|
|
@@ -3314,9 +3325,9 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
|
|
|
3314
3325
|
y: number;
|
|
3315
3326
|
};
|
|
3316
3327
|
radius: number;
|
|
3328
|
+
pathData: string;
|
|
3317
3329
|
lineWidth: number;
|
|
3318
3330
|
sweepFlag: boolean;
|
|
3319
|
-
pathData: string;
|
|
3320
3331
|
color: string;
|
|
3321
3332
|
}, {
|
|
3322
3333
|
type: "ARC";
|
|
@@ -3330,9 +3341,9 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
|
|
|
3330
3341
|
y: number;
|
|
3331
3342
|
};
|
|
3332
3343
|
radius: number;
|
|
3344
|
+
pathData: string;
|
|
3333
3345
|
lineWidth: number;
|
|
3334
3346
|
sweepFlag: boolean;
|
|
3335
|
-
pathData: string;
|
|
3336
3347
|
color: string;
|
|
3337
3348
|
}>]>>, "many">;
|
|
3338
3349
|
BBox: z.ZodOptional<z.ZodObject<{
|
|
@@ -3389,9 +3400,9 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
|
|
|
3389
3400
|
y: number;
|
|
3390
3401
|
};
|
|
3391
3402
|
radius: number;
|
|
3403
|
+
pathData: string;
|
|
3392
3404
|
lineWidth: number;
|
|
3393
3405
|
sweepFlag: boolean;
|
|
3394
|
-
pathData: string;
|
|
3395
3406
|
color: string;
|
|
3396
3407
|
} | {
|
|
3397
3408
|
path: string;
|
|
@@ -3539,9 +3550,9 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
|
|
|
3539
3550
|
y: number;
|
|
3540
3551
|
};
|
|
3541
3552
|
radius: number;
|
|
3553
|
+
pathData: string;
|
|
3542
3554
|
lineWidth: number;
|
|
3543
3555
|
sweepFlag: boolean;
|
|
3544
|
-
pathData: string;
|
|
3545
3556
|
color: string;
|
|
3546
3557
|
} | {
|
|
3547
3558
|
path: string;
|
|
@@ -3773,6 +3784,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
|
|
|
3773
3784
|
y: number;
|
|
3774
3785
|
}[];
|
|
3775
3786
|
layermask: number;
|
|
3787
|
+
pathData: string;
|
|
3776
3788
|
fillStyle: string;
|
|
3777
3789
|
id?: string | undefined;
|
|
3778
3790
|
layer?: number | undefined;
|
|
@@ -4031,6 +4043,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
|
|
|
4031
4043
|
} & {
|
|
4032
4044
|
type: z.ZodLiteral<"SOLIDREGION">;
|
|
4033
4045
|
layermask: z.ZodNumber;
|
|
4046
|
+
pathData: z.ZodString;
|
|
4034
4047
|
points: z.ZodArray<z.ZodPipeline<z.ZodEffects<z.ZodAny, any, any>, z.ZodObject<{
|
|
4035
4048
|
x: z.ZodNumber;
|
|
4036
4049
|
y: z.ZodNumber;
|
|
@@ -4049,6 +4062,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
|
|
|
4049
4062
|
y: number;
|
|
4050
4063
|
}[];
|
|
4051
4064
|
layermask: number;
|
|
4065
|
+
pathData: string;
|
|
4052
4066
|
fillStyle: string;
|
|
4053
4067
|
id?: string | undefined;
|
|
4054
4068
|
layer?: number | undefined;
|
|
@@ -4056,6 +4070,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
|
|
|
4056
4070
|
type: "SOLIDREGION";
|
|
4057
4071
|
points: any[];
|
|
4058
4072
|
layermask: number;
|
|
4073
|
+
pathData: string;
|
|
4059
4074
|
id?: string | undefined;
|
|
4060
4075
|
layer?: number | undefined;
|
|
4061
4076
|
fillStyle?: string | undefined;
|
|
@@ -4339,6 +4354,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
|
|
|
4339
4354
|
y: number;
|
|
4340
4355
|
}[];
|
|
4341
4356
|
layermask: number;
|
|
4357
|
+
pathData: string;
|
|
4342
4358
|
fillStyle: string;
|
|
4343
4359
|
id?: string | undefined;
|
|
4344
4360
|
layer?: number | undefined;
|
|
@@ -4534,6 +4550,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
|
|
|
4534
4550
|
y: number;
|
|
4535
4551
|
}[];
|
|
4536
4552
|
layermask: number;
|
|
4553
|
+
pathData: string;
|
|
4537
4554
|
fillStyle: string;
|
|
4538
4555
|
id?: string | undefined;
|
|
4539
4556
|
layer?: number | undefined;
|
|
@@ -4801,9 +4818,9 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
|
|
|
4801
4818
|
y: number;
|
|
4802
4819
|
};
|
|
4803
4820
|
radius: number;
|
|
4821
|
+
pathData: string;
|
|
4804
4822
|
lineWidth: number;
|
|
4805
4823
|
sweepFlag: boolean;
|
|
4806
|
-
pathData: string;
|
|
4807
4824
|
color: string;
|
|
4808
4825
|
} | {
|
|
4809
4826
|
path: string;
|
|
@@ -4982,6 +4999,7 @@ declare const EasyEdaJsonSchema: z.ZodObject<{
|
|
|
4982
4999
|
y: number;
|
|
4983
5000
|
}[];
|
|
4984
5001
|
layermask: number;
|
|
5002
|
+
pathData: string;
|
|
4985
5003
|
fillStyle: string;
|
|
4986
5004
|
id?: string | undefined;
|
|
4987
5005
|
layer?: number | undefined;
|
package/dist/browser/index.js
CHANGED
|
@@ -9456,9 +9456,9 @@ var insertionDirectionToVec = (direction) => {
|
|
|
9456
9456
|
return { x: -1, y: 0 };
|
|
9457
9457
|
case "from_right":
|
|
9458
9458
|
return { x: 1, y: 0 };
|
|
9459
|
-
case "
|
|
9459
|
+
case "from_top":
|
|
9460
9460
|
return { x: 0, y: 1 };
|
|
9461
|
-
case "
|
|
9461
|
+
case "from_bottom":
|
|
9462
9462
|
return { x: 0, y: -1 };
|
|
9463
9463
|
}
|
|
9464
9464
|
};
|
|
@@ -9468,11 +9468,15 @@ var vecToInsertionDirection = ({
|
|
|
9468
9468
|
}) => {
|
|
9469
9469
|
if (x > 0) return "from_right";
|
|
9470
9470
|
if (x < 0) return "from_left";
|
|
9471
|
-
if (y > 0) return "
|
|
9472
|
-
return "
|
|
9471
|
+
if (y > 0) return "from_top";
|
|
9472
|
+
return "from_bottom";
|
|
9473
9473
|
};
|
|
9474
9474
|
var transformInsertionDirection = (direction, opts) => {
|
|
9475
|
-
if (!direction
|
|
9475
|
+
if (!direction) return direction;
|
|
9476
|
+
if (direction === "from_above" || direction === "from_below") {
|
|
9477
|
+
if (!opts.isFlipped) return direction;
|
|
9478
|
+
return direction === "from_above" ? "from_below" : "from_above";
|
|
9479
|
+
}
|
|
9476
9480
|
let { x, y } = insertionDirectionToVec(direction);
|
|
9477
9481
|
let quarterTurns = Math.round(opts.rotationDegrees / 90);
|
|
9478
9482
|
while (quarterTurns > 0) {
|
|
@@ -9495,7 +9499,7 @@ var transformPCBElement = (elm, matrix) => {
|
|
|
9495
9499
|
const flipPadWidthHeight = Math.abs(getQuarterTurns(tsr.rotation.angle)) % 2 === 1;
|
|
9496
9500
|
const rotationDegrees = tsr.rotation.angle / Math.PI * 180;
|
|
9497
9501
|
const isFlipped = tsr.scale.sy < 0;
|
|
9498
|
-
if (elm.type === "pcb_plated_hole" || elm.type === "pcb_hole" || elm.type === "pcb_via" || elm.type === "pcb_smtpad" || elm.type === "pcb_port") {
|
|
9502
|
+
if (elm.type === "pcb_plated_hole" || elm.type === "pcb_hole" || elm.type === "pcb_via" || elm.type === "pcb_smtpad" || elm.type === "pcb_solder_paste" || elm.type === "pcb_port") {
|
|
9499
9503
|
const { x, y } = applyToPoint(matrix, {
|
|
9500
9504
|
x: Number(elm.x),
|
|
9501
9505
|
y: Number(elm.y)
|
|
@@ -9515,10 +9519,14 @@ var transformPCBElement = (elm, matrix) => {
|
|
|
9515
9519
|
elm.center = applyToPoint(matrix, elm.center);
|
|
9516
9520
|
} else if (elm.type === "pcb_silkscreen_text" || elm.type === "pcb_fabrication_note_text" || elm.type === "pcb_note_text") {
|
|
9517
9521
|
elm.anchor_position = applyToPoint(matrix, elm.anchor_position);
|
|
9522
|
+
} else if (elm.type === "pcb_copper_text") {
|
|
9523
|
+
if (elm.anchor_position) {
|
|
9524
|
+
elm.anchor_position = applyToPoint(matrix, elm.anchor_position);
|
|
9525
|
+
}
|
|
9518
9526
|
} else if (elm.type === "pcb_courtyard_rect") {
|
|
9519
9527
|
elm.center = applyToPoint(matrix, elm.center);
|
|
9520
9528
|
elm.ccw_rotation = ((elm.ccw_rotation ?? 0) + rotationDegrees) % 360;
|
|
9521
|
-
} else if (elm.type === "pcb_silkscreen_circle" || elm.type === "pcb_silkscreen_rect" || elm.type === "pcb_note_rect" || elm.type === "pcb_courtyard_circle") {
|
|
9529
|
+
} else if (elm.type === "pcb_silkscreen_circle" || elm.type === "pcb_silkscreen_rect" || elm.type === "pcb_silkscreen_pill" || elm.type === "pcb_silkscreen_oval" || elm.type === "pcb_note_rect" || elm.type === "pcb_courtyard_circle") {
|
|
9522
9530
|
elm.center = applyToPoint(matrix, elm.center);
|
|
9523
9531
|
} else if (elm.type === "pcb_component") {
|
|
9524
9532
|
elm.center = applyToPoint(matrix, elm.center);
|
|
@@ -9555,7 +9563,19 @@ var transformPCBElement = (elm, matrix) => {
|
|
|
9555
9563
|
p.y = tp.y;
|
|
9556
9564
|
return p;
|
|
9557
9565
|
});
|
|
9558
|
-
} else if (elm.type === "
|
|
9566
|
+
} else if (elm.type === "pcb_trace") {
|
|
9567
|
+
elm.route = elm.route.map((rp) => {
|
|
9568
|
+
if (!("x" in rp)) {
|
|
9569
|
+
rp.start = applyToPoint(matrix, rp.start);
|
|
9570
|
+
rp.end = applyToPoint(matrix, rp.end);
|
|
9571
|
+
return rp;
|
|
9572
|
+
}
|
|
9573
|
+
const tp = applyToPoint(matrix, rp);
|
|
9574
|
+
rp.x = tp.x;
|
|
9575
|
+
rp.y = tp.y;
|
|
9576
|
+
return rp;
|
|
9577
|
+
});
|
|
9578
|
+
} else if (elm.type === "pcb_silkscreen_path" || elm.type === "pcb_trace_hint" || elm.type === "pcb_fabrication_note_path" || elm.type === "pcb_note_path") {
|
|
9559
9579
|
elm.route = elm.route.map((rp) => {
|
|
9560
9580
|
const tp = applyToPoint(matrix, rp);
|
|
9561
9581
|
rp.x = tp.x;
|
|
@@ -9588,7 +9608,7 @@ var transformPCBElements = (elms, matrix) => {
|
|
|
9588
9608
|
let transformedElms = elms.map((elm) => transformPCBElement(elm, matrix));
|
|
9589
9609
|
if (flipPadWidthHeight) {
|
|
9590
9610
|
transformedElms = transformedElms.map((elm) => {
|
|
9591
|
-
if (elm.type === "pcb_smtpad" && (elm.shape === "rect" || elm.shape === "pill")) {
|
|
9611
|
+
if ((elm.type === "pcb_smtpad" || elm.type === "pcb_solder_paste") && (elm.shape === "rect" || elm.shape === "pill")) {
|
|
9592
9612
|
;
|
|
9593
9613
|
[elm.width, elm.height] = [elm.height, elm.width];
|
|
9594
9614
|
}
|
|
@@ -9743,7 +9763,10 @@ var getDebugLayoutObject = (lo) => {
|
|
|
9743
9763
|
const content = lo;
|
|
9744
9764
|
if (x === void 0 || y === void 0) return null;
|
|
9745
9765
|
if (width === void 0) {
|
|
9746
|
-
if ("
|
|
9766
|
+
if ("radius" in lo) {
|
|
9767
|
+
width = lo.radius * 2;
|
|
9768
|
+
height = lo.radius * 2;
|
|
9769
|
+
} else if ("outer_diameter" in lo) {
|
|
9747
9770
|
width = lo.outer_diameter;
|
|
9748
9771
|
height = lo.outer_diameter;
|
|
9749
9772
|
} else if ("rect_pad_width" in lo && "rect_pad_height" in lo) {
|
|
@@ -9798,6 +9821,17 @@ var findBoundsAndCenter = (elements) => {
|
|
|
9798
9821
|
const center = { x: minX + width / 2, y: minY + height / 2 };
|
|
9799
9822
|
return { center, width, height };
|
|
9800
9823
|
};
|
|
9824
|
+
var PIN1_LOCATION_PARTS = {
|
|
9825
|
+
leftside_top: { side: "leftside", alignment: "top" },
|
|
9826
|
+
leftside_bottom: { side: "leftside", alignment: "bottom" },
|
|
9827
|
+
rightside_top: { side: "rightside", alignment: "top" },
|
|
9828
|
+
rightside_bottom: { side: "rightside", alignment: "bottom" },
|
|
9829
|
+
topside_left: { side: "topside", alignment: "left" },
|
|
9830
|
+
topside_right: { side: "topside", alignment: "right" },
|
|
9831
|
+
bottomside_left: { side: "bottomside", alignment: "left" },
|
|
9832
|
+
bottomside_right: { side: "bottomside", alignment: "right" }
|
|
9833
|
+
};
|
|
9834
|
+
var PIN1_LOCATIONS = Object.keys(PIN1_LOCATION_PARTS);
|
|
9801
9835
|
|
|
9802
9836
|
// node_modules/@tscircuit/mm/dist/index.js
|
|
9803
9837
|
var unitToMm = {
|
|
@@ -10289,6 +10323,62 @@ var handleFabricationNotePath = (track, index) => pcb_fabrication_note_path.pars
|
|
|
10289
10323
|
})),
|
|
10290
10324
|
stroke_width: mil10ToMm(track.width)
|
|
10291
10325
|
});
|
|
10326
|
+
var handleFabricationNoteSolidRegion = (solidRegion, index) => {
|
|
10327
|
+
const rawRoute = [];
|
|
10328
|
+
let currentPoint;
|
|
10329
|
+
for (const commandMatch of solidRegion.pathData.matchAll(
|
|
10330
|
+
/([MLAZ])([^MLAZ]*)/gi
|
|
10331
|
+
)) {
|
|
10332
|
+
const command = commandMatch[1]?.toUpperCase();
|
|
10333
|
+
const values = commandMatch[2]?.match(/[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g)?.map(Number) ?? [];
|
|
10334
|
+
if ((command === "M" || command === "L") && values.length >= 2) {
|
|
10335
|
+
currentPoint = { x: values[0], y: values[1] };
|
|
10336
|
+
rawRoute.push(currentPoint);
|
|
10337
|
+
} else if (command === "A" && currentPoint && values.length >= 7) {
|
|
10338
|
+
const [radiusX, , , largeArcFlag, sweepFlag, endX, endY] = values;
|
|
10339
|
+
const generatedArcRoute = generateArcFromSweep(
|
|
10340
|
+
currentPoint.x,
|
|
10341
|
+
currentPoint.y,
|
|
10342
|
+
endX,
|
|
10343
|
+
endY,
|
|
10344
|
+
radiusX,
|
|
10345
|
+
largeArcFlag === 1,
|
|
10346
|
+
sweepFlag === 1
|
|
10347
|
+
);
|
|
10348
|
+
const maxArcSegments = 16;
|
|
10349
|
+
const arcRoute = generatedArcRoute.length <= maxArcSegments + 1 ? generatedArcRoute : Array.from(
|
|
10350
|
+
{ length: maxArcSegments + 1 },
|
|
10351
|
+
(_, pointIndex) => generatedArcRoute.at(
|
|
10352
|
+
Math.round(
|
|
10353
|
+
pointIndex * (generatedArcRoute.length - 1) / maxArcSegments
|
|
10354
|
+
)
|
|
10355
|
+
)
|
|
10356
|
+
).filter((point2) => !!point2);
|
|
10357
|
+
rawRoute.push(...arcRoute.slice(1));
|
|
10358
|
+
currentPoint = { x: endX, y: endY };
|
|
10359
|
+
}
|
|
10360
|
+
}
|
|
10361
|
+
const route = rawRoute.map((point2) => ({
|
|
10362
|
+
x: mil10ToMm(point2.x),
|
|
10363
|
+
y: mil10ToMm(point2.y)
|
|
10364
|
+
}));
|
|
10365
|
+
const firstPoint = route[0];
|
|
10366
|
+
const lastPoint = route.at(-1);
|
|
10367
|
+
if (firstPoint && lastPoint && (firstPoint.x !== lastPoint.x || firstPoint.y !== lastPoint.y)) {
|
|
10368
|
+
route.push({ ...firstPoint });
|
|
10369
|
+
}
|
|
10370
|
+
if (route.length < 2) return null;
|
|
10371
|
+
return pcb_fabrication_note_path.parse({
|
|
10372
|
+
type: "pcb_fabrication_note_path",
|
|
10373
|
+
pcb_fabrication_note_path_id: `pcb_fabrication_note_solid_region_${index + 1}`,
|
|
10374
|
+
pcb_component_id: "pcb_component_1",
|
|
10375
|
+
layer: "top",
|
|
10376
|
+
route,
|
|
10377
|
+
// EasyEDA solid regions have no stroke width. Use its standard 1-unit
|
|
10378
|
+
// document stroke so the closed region remains visible as a note path.
|
|
10379
|
+
stroke_width: mil10ToMm(1)
|
|
10380
|
+
});
|
|
10381
|
+
};
|
|
10292
10382
|
var getSideFromLayer = (layer) => {
|
|
10293
10383
|
if (layer === 4 || layer === 14) return "bottom";
|
|
10294
10384
|
return "top";
|
|
@@ -10315,24 +10405,17 @@ var handleSilkscreenArc = (arc, index) => {
|
|
|
10315
10405
|
stroke_width: mil10ToMm(arc.width)
|
|
10316
10406
|
});
|
|
10317
10407
|
};
|
|
10318
|
-
var SILKSCREEN_CIRCLE_SEGMENTS = 24;
|
|
10319
10408
|
var handleSilkscreenCircle = (circle, index) => {
|
|
10320
|
-
|
|
10321
|
-
|
|
10322
|
-
|
|
10323
|
-
const angle = Math.PI * 2 * segmentIndex / SILKSCREEN_CIRCLE_SEGMENTS;
|
|
10324
|
-
return {
|
|
10325
|
-
x: milx10(circle.center.x + Math.cos(angle) * circle.radius),
|
|
10326
|
-
y: milx10(circle.center.y + Math.sin(angle) * circle.radius)
|
|
10327
|
-
};
|
|
10328
|
-
}
|
|
10329
|
-
);
|
|
10330
|
-
return pcb_silkscreen_path.parse({
|
|
10331
|
-
type: "pcb_silkscreen_path",
|
|
10332
|
-
pcb_silkscreen_path_id: `pcb_silkscreen_circle_${index + 1}`,
|
|
10409
|
+
return pcb_silkscreen_circle.parse({
|
|
10410
|
+
type: "pcb_silkscreen_circle",
|
|
10411
|
+
pcb_silkscreen_circle_id: `pcb_silkscreen_circle_${index + 1}`,
|
|
10333
10412
|
pcb_component_id: "pcb_component_1",
|
|
10334
10413
|
layer: getSideFromLayer(circle.layer),
|
|
10335
|
-
|
|
10414
|
+
center: {
|
|
10415
|
+
x: milx10(circle.center.x),
|
|
10416
|
+
y: milx10(circle.center.y)
|
|
10417
|
+
},
|
|
10418
|
+
radius: milx10(circle.radius),
|
|
10336
10419
|
stroke_width: mil10ToMm(circle.width)
|
|
10337
10420
|
});
|
|
10338
10421
|
};
|
|
@@ -10666,6 +10749,9 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
10666
10749
|
} else if (isDocumentLayer(shape.layer)) {
|
|
10667
10750
|
circuitElements.push(handleFabricationNotePath(shape, index));
|
|
10668
10751
|
}
|
|
10752
|
+
} else if (shape.type === "SOLIDREGION" && isDocumentLayer(shape.layermask)) {
|
|
10753
|
+
const fabricationNote = handleFabricationNoteSolidRegion(shape, index);
|
|
10754
|
+
if (fabricationNote) circuitElements.push(fabricationNote);
|
|
10669
10755
|
} else if (shape.type === "CIRCLE") {
|
|
10670
10756
|
if (isSilkscreenLayer(shape.layer)) {
|
|
10671
10757
|
circuitElements.push(handleSilkscreenCircle(shape, index));
|
|
@@ -10732,7 +10818,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
10732
10818
|
);
|
|
10733
10819
|
}
|
|
10734
10820
|
const pcbElements = circuitElements.filter(
|
|
10735
|
-
(e) => e.type === "pcb_smtpad" || e.type === "pcb_plated_hole" || e.type === "pcb_hole" || e.type === "pcb_via" || e.type === "pcb_courtyard_outline" || e.type === "pcb_courtyard_rect" || e.type === "pcb_silkscreen_path" || e.type === "pcb_silkscreen_rect" || e.type === "pcb_silkscreen_text"
|
|
10821
|
+
(e) => e.type === "pcb_smtpad" || e.type === "pcb_plated_hole" || e.type === "pcb_hole" || e.type === "pcb_via" || e.type === "pcb_courtyard_outline" || e.type === "pcb_courtyard_rect" || e.type === "pcb_silkscreen_path" || e.type === "pcb_silkscreen_circle" || e.type === "pcb_silkscreen_rect" || e.type === "pcb_silkscreen_text"
|
|
10736
10822
|
);
|
|
10737
10823
|
if (pcbElements.length > 0) {
|
|
10738
10824
|
const bounds = findBoundsAndCenter(pcbElements);
|
|
@@ -10799,7 +10885,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
10799
10885
|
}
|
|
10800
10886
|
if (shouldRecenter) {
|
|
10801
10887
|
const elementsForBounds = circuitElements.filter(
|
|
10802
|
-
(e) => e.type !== "pcb_component" && e.type !== "cad_component"
|
|
10888
|
+
(e) => e.type !== "pcb_component" && e.type !== "cad_component" && e.type !== "pcb_silkscreen_circle"
|
|
10803
10889
|
);
|
|
10804
10890
|
const bounds = findBoundsAndCenter(elementsForBounds);
|
|
10805
10891
|
if (Number.isFinite(bounds.center.x) && Number.isFinite(bounds.center.y)) {
|
|
@@ -10975,6 +11061,7 @@ var CircleSchema = BaseShapeSchema.extend({
|
|
|
10975
11061
|
var SolidRegionSchema = BaseShapeSchema.extend({
|
|
10976
11062
|
type: external_exports.literal("SOLIDREGION"),
|
|
10977
11063
|
layermask: external_exports.number(),
|
|
11064
|
+
pathData: external_exports.string(),
|
|
10978
11065
|
points: external_exports.array(PointSchema),
|
|
10979
11066
|
fillStyle: external_exports.string().default("none")
|
|
10980
11067
|
});
|
|
@@ -11169,6 +11256,7 @@ var ShapeItemSchema = external_exports.object({
|
|
|
11169
11256
|
return SolidRegionSchema.parse({
|
|
11170
11257
|
type: "SOLIDREGION",
|
|
11171
11258
|
layermask: Number(layermask),
|
|
11259
|
+
pathData,
|
|
11172
11260
|
points,
|
|
11173
11261
|
fillStyle: fillStyle || void 0,
|
|
11174
11262
|
id
|
|
@@ -11836,15 +11924,27 @@ var mapPortHints = (portHints, portHintsMap) => {
|
|
|
11836
11924
|
if (!portHintsMap || !portHints) return portHints;
|
|
11837
11925
|
return [...new Set(portHints.flatMap((hint) => portHintsMap[hint] ?? [hint]))];
|
|
11838
11926
|
};
|
|
11927
|
+
var getLayerAttr = (layer) => layer && layer !== "top" ? ` layer="${layer}"` : "";
|
|
11928
|
+
var getRotationAttr = (rotation2) => rotation2 ? ` pcbRotation="${rotation2}deg"` : "";
|
|
11929
|
+
var getStringAttr = (name, value) => value === void 0 ? "" : ` ${name}=${JSON.stringify(value)}`;
|
|
11839
11930
|
var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
11840
11931
|
const holes = su(circuitJson).pcb_hole.list();
|
|
11841
11932
|
const platedHoles = su(circuitJson).pcb_plated_hole.list();
|
|
11842
11933
|
const smtPads = su(circuitJson).pcb_smtpad.list();
|
|
11843
11934
|
const vias = su(circuitJson).pcb_via.list();
|
|
11844
11935
|
const silkscreenPaths = su(circuitJson).pcb_silkscreen_path.list();
|
|
11936
|
+
const silkscreenCircles = su(circuitJson).pcb_silkscreen_circle.list();
|
|
11845
11937
|
const silkscreenRects = su(circuitJson).pcb_silkscreen_rect.list();
|
|
11846
11938
|
const silkscreenTexts = su(circuitJson).pcb_silkscreen_text.list();
|
|
11847
11939
|
const fabricationNotePaths = su(circuitJson).pcb_fabrication_note_path.list();
|
|
11940
|
+
const fabricationNoteTexts = su(circuitJson).pcb_fabrication_note_text.list();
|
|
11941
|
+
const fabricationNoteRects = su(circuitJson).pcb_fabrication_note_rect.list();
|
|
11942
|
+
const fabricationNoteDimensions = su(circuitJson).pcb_fabrication_note_dimension.list();
|
|
11943
|
+
const pcbNoteTexts = su(circuitJson).pcb_note_text.list();
|
|
11944
|
+
const pcbNoteRects = su(circuitJson).pcb_note_rect.list();
|
|
11945
|
+
const pcbNotePaths = su(circuitJson).pcb_note_path.list();
|
|
11946
|
+
const pcbNoteLines = su(circuitJson).pcb_note_line.list();
|
|
11947
|
+
const pcbNoteDimensions = su(circuitJson).pcb_note_dimension.list();
|
|
11848
11948
|
const courtyardOutlines = su(circuitJson).pcb_courtyard_outline.list();
|
|
11849
11949
|
const elementStrings = [];
|
|
11850
11950
|
for (const hole of holes) {
|
|
@@ -11912,6 +12012,11 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
|
11912
12012
|
`<silkscreenpath route={${JSON.stringify(silkscreenPath.route)}} />`
|
|
11913
12013
|
);
|
|
11914
12014
|
}
|
|
12015
|
+
for (const silkscreenCircle of silkscreenCircles) {
|
|
12016
|
+
elementStrings.push(
|
|
12017
|
+
`<silkscreencircle pcbX="${mmStr(silkscreenCircle.center.x)}" pcbY="${mmStr(silkscreenCircle.center.y)}" radius="${mmStr(silkscreenCircle.radius)}" />`
|
|
12018
|
+
);
|
|
12019
|
+
}
|
|
11915
12020
|
for (const silkscreenRect of silkscreenRects) {
|
|
11916
12021
|
const rotation2 = silkscreenRect.ccw_rotation || 0;
|
|
11917
12022
|
const rotationAttr = rotation2 ? ` pcbRotation="${rotation2}deg"` : "";
|
|
@@ -11932,7 +12037,49 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
|
|
|
11932
12037
|
}
|
|
11933
12038
|
for (const fabricationNotePath of fabricationNotePaths) {
|
|
11934
12039
|
elementStrings.push(
|
|
11935
|
-
`<fabricationnotepath route={${JSON.stringify(fabricationNotePath.route)}} strokeWidth="${mmStr(fabricationNotePath.stroke_width)}" />`
|
|
12040
|
+
`<fabricationnotepath route={${JSON.stringify(fabricationNotePath.route)}} strokeWidth="${mmStr(fabricationNotePath.stroke_width)}"${getStringAttr("color", fabricationNotePath.color)}${getLayerAttr(fabricationNotePath.layer)} />`
|
|
12041
|
+
);
|
|
12042
|
+
}
|
|
12043
|
+
for (const fabricationNoteText of fabricationNoteTexts) {
|
|
12044
|
+
elementStrings.push(
|
|
12045
|
+
`<fabricationnotetext text=${JSON.stringify(fabricationNoteText.text)} pcbX="${mmStr(fabricationNoteText.anchor_position.x)}" pcbY="${mmStr(fabricationNoteText.anchor_position.y)}" anchorAlignment="${fabricationNoteText.anchor_alignment}"${getStringAttr("font", fabricationNoteText.font)}${fabricationNoteText.font_size === void 0 ? "" : ` fontSize="${mmStr(fabricationNoteText.font_size)}"`}${getStringAttr("color", fabricationNoteText.color)}${getRotationAttr(fabricationNoteText.ccw_rotation)}${getLayerAttr(fabricationNoteText.layer)} />`
|
|
12046
|
+
);
|
|
12047
|
+
}
|
|
12048
|
+
for (const fabricationNoteRect of fabricationNoteRects) {
|
|
12049
|
+
elementStrings.push(
|
|
12050
|
+
`<fabricationnoterect pcbX="${mmStr(fabricationNoteRect.center.x)}" pcbY="${mmStr(fabricationNoteRect.center.y)}" width="${mmStr(fabricationNoteRect.width)}" height="${mmStr(fabricationNoteRect.height)}" strokeWidth="${mmStr(fabricationNoteRect.stroke_width)}"${fabricationNoteRect.corner_radius === void 0 ? "" : ` cornerRadius="${mmStr(fabricationNoteRect.corner_radius)}"`}${fabricationNoteRect.is_filled === void 0 ? "" : ` isFilled={${fabricationNoteRect.is_filled}}`}${fabricationNoteRect.has_stroke === void 0 ? "" : ` hasStroke={${fabricationNoteRect.has_stroke}}`}${fabricationNoteRect.is_stroke_dashed === void 0 ? "" : ` isStrokeDashed={${fabricationNoteRect.is_stroke_dashed}}`}${getStringAttr("color", fabricationNoteRect.color)}${getLayerAttr(fabricationNoteRect.layer)} />`
|
|
12051
|
+
);
|
|
12052
|
+
}
|
|
12053
|
+
for (const fabricationNoteDimension of fabricationNoteDimensions) {
|
|
12054
|
+
const offset = "offset" in fabricationNoteDimension ? fabricationNoteDimension.offset : fabricationNoteDimension.offset_distance;
|
|
12055
|
+
elementStrings.push(
|
|
12056
|
+
`<fabricationnotedimension from={${JSON.stringify(fabricationNoteDimension.from)}} to={${JSON.stringify(fabricationNoteDimension.to)}}${getStringAttr("text", fabricationNoteDimension.text)}${getStringAttr("font", fabricationNoteDimension.font)}${fabricationNoteDimension.font_size === void 0 ? "" : ` fontSize="${mmStr(fabricationNoteDimension.font_size)}"`}${fabricationNoteDimension.arrow_size === void 0 ? "" : ` arrowSize="${mmStr(fabricationNoteDimension.arrow_size)}"`}${offset === void 0 ? "" : ` offset="${mmStr(offset)}"`}${getStringAttr("color", fabricationNoteDimension.color)}${getLayerAttr(fabricationNoteDimension.layer)} />`
|
|
12057
|
+
);
|
|
12058
|
+
}
|
|
12059
|
+
for (const pcbNoteText of pcbNoteTexts) {
|
|
12060
|
+
elementStrings.push(
|
|
12061
|
+
`<pcbnotetext text=${JSON.stringify(pcbNoteText.text ?? "")} pcbX="${mmStr(pcbNoteText.anchor_position.x)}" pcbY="${mmStr(pcbNoteText.anchor_position.y)}" anchorAlignment="${pcbNoteText.anchor_alignment}"${getStringAttr("font", pcbNoteText.font)}${pcbNoteText.font_size === void 0 ? "" : ` fontSize="${mmStr(pcbNoteText.font_size)}"`}${getStringAttr("color", pcbNoteText.color)}${getLayerAttr(pcbNoteText.layer)} />`
|
|
12062
|
+
);
|
|
12063
|
+
}
|
|
12064
|
+
for (const pcbNoteRect of pcbNoteRects) {
|
|
12065
|
+
elementStrings.push(
|
|
12066
|
+
`<pcbnoterect pcbX="${mmStr(pcbNoteRect.center.x)}" pcbY="${mmStr(pcbNoteRect.center.y)}" width="${mmStr(pcbNoteRect.width)}" height="${mmStr(pcbNoteRect.height)}" strokeWidth="${mmStr(pcbNoteRect.stroke_width)}"${pcbNoteRect.corner_radius === void 0 ? "" : ` cornerRadius="${mmStr(pcbNoteRect.corner_radius)}"`}${pcbNoteRect.is_filled === void 0 ? "" : ` isFilled={${pcbNoteRect.is_filled}}`}${pcbNoteRect.has_stroke === void 0 ? "" : ` hasStroke={${pcbNoteRect.has_stroke}}`}${pcbNoteRect.is_stroke_dashed === void 0 ? "" : ` isStrokeDashed={${pcbNoteRect.is_stroke_dashed}}`}${getStringAttr("color", pcbNoteRect.color)}${getLayerAttr(pcbNoteRect.layer)} />`
|
|
12067
|
+
);
|
|
12068
|
+
}
|
|
12069
|
+
for (const pcbNotePath of pcbNotePaths) {
|
|
12070
|
+
elementStrings.push(
|
|
12071
|
+
`<pcbnotepath route={${JSON.stringify(pcbNotePath.route)}} strokeWidth="${mmStr(pcbNotePath.stroke_width)}"${getStringAttr("color", pcbNotePath.color)}${getLayerAttr(pcbNotePath.layer)} />`
|
|
12072
|
+
);
|
|
12073
|
+
}
|
|
12074
|
+
for (const pcbNoteLine of pcbNoteLines) {
|
|
12075
|
+
elementStrings.push(
|
|
12076
|
+
`<pcbnoteline x1="${mmStr(pcbNoteLine.x1)}" y1="${mmStr(pcbNoteLine.y1)}" x2="${mmStr(pcbNoteLine.x2)}" y2="${mmStr(pcbNoteLine.y2)}" strokeWidth="${mmStr(pcbNoteLine.stroke_width)}"${pcbNoteLine.is_dashed === void 0 ? "" : ` isDashed={${pcbNoteLine.is_dashed}}`}${getStringAttr("color", pcbNoteLine.color)}${getLayerAttr(pcbNoteLine.layer)} />`
|
|
12077
|
+
);
|
|
12078
|
+
}
|
|
12079
|
+
for (const pcbNoteDimension of pcbNoteDimensions) {
|
|
12080
|
+
const offset = pcbNoteDimension.offset_distance;
|
|
12081
|
+
elementStrings.push(
|
|
12082
|
+
`<pcbnotedimension from={${JSON.stringify(pcbNoteDimension.from)}} to={${JSON.stringify(pcbNoteDimension.to)}}${getStringAttr("text", pcbNoteDimension.text)}${getStringAttr("font", pcbNoteDimension.font)}${pcbNoteDimension.font_size === void 0 ? "" : ` fontSize="${mmStr(pcbNoteDimension.font_size)}"`}${pcbNoteDimension.arrow_size === void 0 ? "" : ` arrowSize="${mmStr(pcbNoteDimension.arrow_size)}"`}${offset === void 0 ? "" : ` offset="${mmStr(offset)}"`}${getStringAttr("color", pcbNoteDimension.color)}${getLayerAttr(pcbNoteDimension.layer)} />`
|
|
11936
12083
|
);
|
|
11937
12084
|
}
|
|
11938
12085
|
for (const courtyardOutline of courtyardOutlines) {
|