easyeda 0.0.17 → 0.0.18
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.cjs +57 -34
- package/dist/cli/main.cjs.map +1 -1
- package/dist/lib/index.cjs +55 -30
- package/dist/lib/index.cjs.map +1 -1
- package/dist/lib/index.d.cts +94 -15
- package/package.json +1 -1
package/dist/lib/index.cjs
CHANGED
|
@@ -6479,14 +6479,14 @@ var require_dist2 = __commonJS({
|
|
|
6479
6479
|
x,
|
|
6480
6480
|
y: -Math.sqrt(1 - x ** 2)
|
|
6481
6481
|
}));
|
|
6482
|
-
var
|
|
6482
|
+
var import_mm4 = require("@tscircuit/mm");
|
|
6483
6483
|
var platedhole = (pn, x, y, id, od) => {
|
|
6484
6484
|
return {
|
|
6485
6485
|
type: "pcb_plated_hole",
|
|
6486
6486
|
x,
|
|
6487
6487
|
y,
|
|
6488
|
-
hole_diameter: (0,
|
|
6489
|
-
outer_diameter: (0,
|
|
6488
|
+
hole_diameter: (0, import_mm4.mm)(id),
|
|
6489
|
+
outer_diameter: (0, import_mm4.mm)(od),
|
|
6490
6490
|
pcb_port_id: "",
|
|
6491
6491
|
layers: ["top", "bottom"],
|
|
6492
6492
|
port_hints: [pn.toString()]
|
|
@@ -28310,8 +28310,8 @@ ${template_code}%`;
|
|
|
28310
28310
|
}
|
|
28311
28311
|
};
|
|
28312
28312
|
var excellonDrill = () => new ExcellonDrillBuilder();
|
|
28313
|
-
var mmToInch = (
|
|
28314
|
-
return
|
|
28313
|
+
var mmToInch = (mm4) => {
|
|
28314
|
+
return mm4 / 25.4;
|
|
28315
28315
|
};
|
|
28316
28316
|
var convertSoupToExcellonDrillCommands = ({
|
|
28317
28317
|
soup: soup2,
|
|
@@ -28656,7 +28656,6 @@ module.exports = __toCommonJS(lib_exports);
|
|
|
28656
28656
|
|
|
28657
28657
|
// lib/schemas/package-detail-shape-schema.ts
|
|
28658
28658
|
var import_zod = require("zod");
|
|
28659
|
-
var import_mm = require("@tscircuit/mm");
|
|
28660
28659
|
var tenthmil = import_zod.z.union([import_zod.z.number(), import_zod.z.string()]).optional().transform(
|
|
28661
28660
|
(n) => typeof n === "string" && n.endsWith("mil") ? n : `${Number.parseFloat(n) * 10}mil`
|
|
28662
28661
|
).pipe(import_zod.z.string());
|
|
@@ -28739,6 +28738,16 @@ var HoleSchema = BaseShapeSchema.extend({
|
|
|
28739
28738
|
center: PointSchema,
|
|
28740
28739
|
radius: import_zod.z.number()
|
|
28741
28740
|
});
|
|
28741
|
+
var RectSchema = BaseShapeSchema.extend({
|
|
28742
|
+
type: import_zod.z.literal("RECT"),
|
|
28743
|
+
x: tenthmil,
|
|
28744
|
+
y: tenthmil,
|
|
28745
|
+
width: tenthmil,
|
|
28746
|
+
height: tenthmil,
|
|
28747
|
+
lineWidth: import_zod.z.number(),
|
|
28748
|
+
fillStyle: import_zod.z.string(),
|
|
28749
|
+
rotation: import_zod.z.number().optional()
|
|
28750
|
+
});
|
|
28742
28751
|
var PackageDetailShapeSchema = import_zod.z.discriminatedUnion("type", [
|
|
28743
28752
|
TrackSchema,
|
|
28744
28753
|
PadSchema,
|
|
@@ -28746,7 +28755,8 @@ var PackageDetailShapeSchema = import_zod.z.discriminatedUnion("type", [
|
|
|
28746
28755
|
CircleSchema,
|
|
28747
28756
|
SolidRegionSchema,
|
|
28748
28757
|
SVGNodeSchema,
|
|
28749
|
-
HoleSchema
|
|
28758
|
+
HoleSchema,
|
|
28759
|
+
RectSchema
|
|
28750
28760
|
]);
|
|
28751
28761
|
var pairs = (arr) => {
|
|
28752
28762
|
const pairs2 = [];
|
|
@@ -28873,6 +28883,21 @@ var ShapeItemSchema = import_zod.z.object({
|
|
|
28873
28883
|
const svgData = JSON.parse(shape.data);
|
|
28874
28884
|
return SVGNodeSchema.parse({ type: "SVGNODE", svgData });
|
|
28875
28885
|
}
|
|
28886
|
+
case "RECT": {
|
|
28887
|
+
const [x, y, width, height, lineWidth, id, rotation, layer, fillStyle] = shape.data.split("~");
|
|
28888
|
+
return RectSchema.parse({
|
|
28889
|
+
type: "RECT",
|
|
28890
|
+
x,
|
|
28891
|
+
y,
|
|
28892
|
+
width,
|
|
28893
|
+
height,
|
|
28894
|
+
lineWidth: Number(lineWidth),
|
|
28895
|
+
id,
|
|
28896
|
+
rotation: rotation ? Number(rotation) : void 0,
|
|
28897
|
+
layer: layer ? Number(layer) : void 0,
|
|
28898
|
+
fillStyle: fillStyle || void 0
|
|
28899
|
+
});
|
|
28900
|
+
}
|
|
28876
28901
|
default:
|
|
28877
28902
|
throw new Error(`Unknown shape type: ${shape.type}`);
|
|
28878
28903
|
return BaseShapeSchema.parse({ type: shape.type });
|
|
@@ -28935,15 +28960,15 @@ var import_builder = __toESM(require_dist7(), 1);
|
|
|
28935
28960
|
var import_transformation_matrix = require("transformation-matrix");
|
|
28936
28961
|
|
|
28937
28962
|
// lib/compute-center-offset.ts
|
|
28938
|
-
var
|
|
28963
|
+
var import_mm = require("@tscircuit/mm");
|
|
28939
28964
|
var computeCenterOffset = (easyeda) => {
|
|
28940
28965
|
const pads = easyeda.packageDetail.dataStr.shape.filter(
|
|
28941
28966
|
(shape) => shape.type === "PAD"
|
|
28942
28967
|
);
|
|
28943
|
-
const minX = Math.min(...pads.map((pad) => (0,
|
|
28944
|
-
const maxX = Math.max(...pads.map((pad) => (0,
|
|
28945
|
-
const minY = Math.min(...pads.map((pad) => (0,
|
|
28946
|
-
const maxY = Math.max(...pads.map((pad) => (0,
|
|
28968
|
+
const minX = Math.min(...pads.map((pad) => (0, import_mm.mm)(pad.center.x)));
|
|
28969
|
+
const maxX = Math.max(...pads.map((pad) => (0, import_mm.mm)(pad.center.x)));
|
|
28970
|
+
const minY = Math.min(...pads.map((pad) => (0, import_mm.mm)(pad.center.y)));
|
|
28971
|
+
const maxY = Math.max(...pads.map((pad) => (0, import_mm.mm)(pad.center.y)));
|
|
28947
28972
|
const centerX = (minX + maxX) / 2;
|
|
28948
28973
|
const centerY = (minY + maxY) / 2;
|
|
28949
28974
|
return {
|
|
@@ -28953,7 +28978,7 @@ var computeCenterOffset = (easyeda) => {
|
|
|
28953
28978
|
};
|
|
28954
28979
|
|
|
28955
28980
|
// lib/convert-easyeda-json-to-tscircuit-soup-json.ts
|
|
28956
|
-
var
|
|
28981
|
+
var import_mm2 = require("@tscircuit/mm");
|
|
28957
28982
|
var handleSilkscreenPath = (track, index) => {
|
|
28958
28983
|
return import_soup.pcb_silkscreen_path.parse({
|
|
28959
28984
|
type: "pcb_silkscreen_path",
|
|
@@ -29017,17 +29042,17 @@ var convertEasyEdaJsonToTscircuitSoupJson = (easyEdaJson, { useModelCdn, shouldR
|
|
|
29017
29042
|
source_component_id: "source_component_1",
|
|
29018
29043
|
name: portNumber
|
|
29019
29044
|
});
|
|
29020
|
-
if (pad.holeRadius !== void 0 && (0,
|
|
29045
|
+
if (pad.holeRadius !== void 0 && (0, import_mm2.mm)(pad.holeRadius) !== 0) {
|
|
29021
29046
|
soupElements.push(
|
|
29022
29047
|
import_soup.pcb_plated_hole.parse({
|
|
29023
29048
|
type: "pcb_plated_hole",
|
|
29024
29049
|
pcb_plated_hole_id: `pcb_plated_hole_${index + 1}`,
|
|
29025
29050
|
shape: "circle",
|
|
29026
|
-
x: (0,
|
|
29027
|
-
y: (0,
|
|
29028
|
-
hole_diameter: (0,
|
|
29029
|
-
outer_diameter: (0,
|
|
29030
|
-
radius: (0,
|
|
29051
|
+
x: (0, import_mm2.mm)(pad.center.x),
|
|
29052
|
+
y: (0, import_mm2.mm)(pad.center.y),
|
|
29053
|
+
hole_diameter: (0, import_mm2.mm)(pad.holeRadius) * 2,
|
|
29054
|
+
outer_diameter: (0, import_mm2.mm)(pad.width),
|
|
29055
|
+
radius: (0, import_mm2.mm)(pad.holeRadius),
|
|
29031
29056
|
port_hints: [portNumber],
|
|
29032
29057
|
pcb_component_id: "pcb_component_1",
|
|
29033
29058
|
pcb_port_id: `pcb_port_${index + 1}`,
|
|
@@ -29051,9 +29076,9 @@ var convertEasyEdaJsonToTscircuitSoupJson = (easyEdaJson, { useModelCdn, shouldR
|
|
|
29051
29076
|
type: "pcb_smtpad",
|
|
29052
29077
|
pcb_smtpad_id: `pcb_smtpad_${index + 1}`,
|
|
29053
29078
|
shape: soupShape,
|
|
29054
|
-
x: (0,
|
|
29055
|
-
y: (0,
|
|
29056
|
-
...soupShape === "rect" ? { width: (0,
|
|
29079
|
+
x: (0, import_mm2.mm)(pad.center.x),
|
|
29080
|
+
y: (0, import_mm2.mm)(pad.center.y),
|
|
29081
|
+
...soupShape === "rect" ? { width: (0, import_mm2.mm)(pad.width), height: (0, import_mm2.mm)(pad.height) } : { radius: Math.min((0, import_mm2.mm)(pad.width), (0, import_mm2.mm)(pad.height)) / 2 },
|
|
29057
29082
|
layer: "top",
|
|
29058
29083
|
port_hints: [portNumber],
|
|
29059
29084
|
pcb_component_id: "pcb_component_1",
|
|
@@ -29446,7 +29471,7 @@ var import_soup_util = __toESM(require_dist4(), 1);
|
|
|
29446
29471
|
|
|
29447
29472
|
// lib/generate-footprint-tsx.ts
|
|
29448
29473
|
var import_zod5 = require("zod");
|
|
29449
|
-
var
|
|
29474
|
+
var import_mm3 = require("@tscircuit/mm");
|
|
29450
29475
|
var generateFootprintTsx = (easyEdaJson) => {
|
|
29451
29476
|
const pads = easyEdaJson.packageDetail.dataStr.shape.filter(
|
|
29452
29477
|
(shape) => shape.type === "PAD"
|
|
@@ -29456,16 +29481,16 @@ var generateFootprintTsx = (easyEdaJson) => {
|
|
|
29456
29481
|
const centerY = centerOffset.y;
|
|
29457
29482
|
const footprintElements = pads.map((pad) => {
|
|
29458
29483
|
const { center, width, height, holeRadius, number } = pad;
|
|
29459
|
-
const isPlatedHole = holeRadius !== void 0 && (0,
|
|
29460
|
-
const normalizedX = (0,
|
|
29461
|
-
const normalizedY = (0,
|
|
29484
|
+
const isPlatedHole = holeRadius !== void 0 && (0, import_mm3.mm)(holeRadius) > 0;
|
|
29485
|
+
const normalizedX = (0, import_mm3.mm)(center.x) - centerX;
|
|
29486
|
+
const normalizedY = (0, import_mm3.mm)(center.y) - centerY;
|
|
29462
29487
|
if (isPlatedHole) {
|
|
29463
29488
|
return `
|
|
29464
29489
|
<platedhole
|
|
29465
29490
|
pcbX="${normalizedX.toFixed(2)}mm"
|
|
29466
29491
|
pcbY="${normalizedY.toFixed(2)}mm"
|
|
29467
|
-
hole_diameter="${(0,
|
|
29468
|
-
outer_diameter="${(0,
|
|
29492
|
+
hole_diameter="${(0, import_mm3.mm)(holeRadius) * 2}mm"
|
|
29493
|
+
outer_diameter="${(0, import_mm3.mm)(width)}mm"
|
|
29469
29494
|
portHints={["${number}"]}
|
|
29470
29495
|
/>`.replace(/\n/, "");
|
|
29471
29496
|
} else {
|
|
@@ -29473,8 +29498,8 @@ var generateFootprintTsx = (easyEdaJson) => {
|
|
|
29473
29498
|
<smtpad
|
|
29474
29499
|
pcbX="${normalizedX.toFixed(2)}mm"
|
|
29475
29500
|
pcbY="${normalizedY.toFixed(2)}mm"
|
|
29476
|
-
width="${(0,
|
|
29477
|
-
height="${(0,
|
|
29501
|
+
width="${(0, import_mm3.mm)(width)}mm"
|
|
29502
|
+
height="${(0, import_mm3.mm)(height)}mm"
|
|
29478
29503
|
shape="rect"
|
|
29479
29504
|
portHints={["${number}"]}
|
|
29480
29505
|
/>`.replace(/\n/, "");
|