easyeda 0.0.16 → 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/LICENSE +21 -0
- 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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 tscircuit
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/cli/main.cjs
CHANGED
|
@@ -6480,14 +6480,14 @@ var require_dist2 = __commonJS({
|
|
|
6480
6480
|
x,
|
|
6481
6481
|
y: -Math.sqrt(1 - x ** 2)
|
|
6482
6482
|
}));
|
|
6483
|
-
var
|
|
6483
|
+
var import_mm4 = require("@tscircuit/mm");
|
|
6484
6484
|
var platedhole = (pn, x, y, id, od) => {
|
|
6485
6485
|
return {
|
|
6486
6486
|
type: "pcb_plated_hole",
|
|
6487
6487
|
x,
|
|
6488
6488
|
y,
|
|
6489
|
-
hole_diameter: (0,
|
|
6490
|
-
outer_diameter: (0,
|
|
6489
|
+
hole_diameter: (0, import_mm4.mm)(id),
|
|
6490
|
+
outer_diameter: (0, import_mm4.mm)(od),
|
|
6491
6491
|
pcb_port_id: "",
|
|
6492
6492
|
layers: ["top", "bottom"],
|
|
6493
6493
|
port_hints: [pn.toString()]
|
|
@@ -28311,8 +28311,8 @@ ${template_code}%`;
|
|
|
28311
28311
|
}
|
|
28312
28312
|
};
|
|
28313
28313
|
var excellonDrill = () => new ExcellonDrillBuilder();
|
|
28314
|
-
var mmToInch = (
|
|
28315
|
-
return
|
|
28314
|
+
var mmToInch = (mm4) => {
|
|
28315
|
+
return mm4 / 25.4;
|
|
28316
28316
|
};
|
|
28317
28317
|
var convertSoupToExcellonDrillCommands = ({
|
|
28318
28318
|
soup: soup2,
|
|
@@ -28699,7 +28699,6 @@ async function fetchEasyEDAComponent(jlcpcbPartNumber) {
|
|
|
28699
28699
|
|
|
28700
28700
|
// lib/schemas/package-detail-shape-schema.ts
|
|
28701
28701
|
var import_zod = require("zod");
|
|
28702
|
-
var import_mm = require("@tscircuit/mm");
|
|
28703
28702
|
var tenthmil = import_zod.z.union([import_zod.z.number(), import_zod.z.string()]).optional().transform(
|
|
28704
28703
|
(n) => typeof n === "string" && n.endsWith("mil") ? n : `${Number.parseFloat(n) * 10}mil`
|
|
28705
28704
|
).pipe(import_zod.z.string());
|
|
@@ -28782,6 +28781,16 @@ var HoleSchema = BaseShapeSchema.extend({
|
|
|
28782
28781
|
center: PointSchema,
|
|
28783
28782
|
radius: import_zod.z.number()
|
|
28784
28783
|
});
|
|
28784
|
+
var RectSchema = BaseShapeSchema.extend({
|
|
28785
|
+
type: import_zod.z.literal("RECT"),
|
|
28786
|
+
x: tenthmil,
|
|
28787
|
+
y: tenthmil,
|
|
28788
|
+
width: tenthmil,
|
|
28789
|
+
height: tenthmil,
|
|
28790
|
+
lineWidth: import_zod.z.number(),
|
|
28791
|
+
fillStyle: import_zod.z.string(),
|
|
28792
|
+
rotation: import_zod.z.number().optional()
|
|
28793
|
+
});
|
|
28785
28794
|
var PackageDetailShapeSchema = import_zod.z.discriminatedUnion("type", [
|
|
28786
28795
|
TrackSchema,
|
|
28787
28796
|
PadSchema,
|
|
@@ -28789,7 +28798,8 @@ var PackageDetailShapeSchema = import_zod.z.discriminatedUnion("type", [
|
|
|
28789
28798
|
CircleSchema,
|
|
28790
28799
|
SolidRegionSchema,
|
|
28791
28800
|
SVGNodeSchema,
|
|
28792
|
-
HoleSchema
|
|
28801
|
+
HoleSchema,
|
|
28802
|
+
RectSchema
|
|
28793
28803
|
]);
|
|
28794
28804
|
var pairs = (arr) => {
|
|
28795
28805
|
const pairs2 = [];
|
|
@@ -28916,6 +28926,21 @@ var ShapeItemSchema = import_zod.z.object({
|
|
|
28916
28926
|
const svgData = JSON.parse(shape.data);
|
|
28917
28927
|
return SVGNodeSchema.parse({ type: "SVGNODE", svgData });
|
|
28918
28928
|
}
|
|
28929
|
+
case "RECT": {
|
|
28930
|
+
const [x, y, width, height, lineWidth, id, rotation, layer, fillStyle] = shape.data.split("~");
|
|
28931
|
+
return RectSchema.parse({
|
|
28932
|
+
type: "RECT",
|
|
28933
|
+
x,
|
|
28934
|
+
y,
|
|
28935
|
+
width,
|
|
28936
|
+
height,
|
|
28937
|
+
lineWidth: Number(lineWidth),
|
|
28938
|
+
id,
|
|
28939
|
+
rotation: rotation ? Number(rotation) : void 0,
|
|
28940
|
+
layer: layer ? Number(layer) : void 0,
|
|
28941
|
+
fillStyle: fillStyle || void 0
|
|
28942
|
+
});
|
|
28943
|
+
}
|
|
28919
28944
|
default:
|
|
28920
28945
|
throw new Error(`Unknown shape type: ${shape.type}`);
|
|
28921
28946
|
return BaseShapeSchema.parse({ type: shape.type });
|
|
@@ -28978,15 +29003,15 @@ var import_builder = __toESM(require_dist7(), 1);
|
|
|
28978
29003
|
var import_transformation_matrix = require("transformation-matrix");
|
|
28979
29004
|
|
|
28980
29005
|
// lib/compute-center-offset.ts
|
|
28981
|
-
var
|
|
29006
|
+
var import_mm = require("@tscircuit/mm");
|
|
28982
29007
|
var computeCenterOffset = (easyeda) => {
|
|
28983
29008
|
const pads = easyeda.packageDetail.dataStr.shape.filter(
|
|
28984
29009
|
(shape) => shape.type === "PAD"
|
|
28985
29010
|
);
|
|
28986
|
-
const minX = Math.min(...pads.map((pad) => (0,
|
|
28987
|
-
const maxX = Math.max(...pads.map((pad) => (0,
|
|
28988
|
-
const minY = Math.min(...pads.map((pad) => (0,
|
|
28989
|
-
const maxY = Math.max(...pads.map((pad) => (0,
|
|
29011
|
+
const minX = Math.min(...pads.map((pad) => (0, import_mm.mm)(pad.center.x)));
|
|
29012
|
+
const maxX = Math.max(...pads.map((pad) => (0, import_mm.mm)(pad.center.x)));
|
|
29013
|
+
const minY = Math.min(...pads.map((pad) => (0, import_mm.mm)(pad.center.y)));
|
|
29014
|
+
const maxY = Math.max(...pads.map((pad) => (0, import_mm.mm)(pad.center.y)));
|
|
28990
29015
|
const centerX = (minX + maxX) / 2;
|
|
28991
29016
|
const centerY = (minY + maxY) / 2;
|
|
28992
29017
|
return {
|
|
@@ -28996,7 +29021,7 @@ var computeCenterOffset = (easyeda) => {
|
|
|
28996
29021
|
};
|
|
28997
29022
|
|
|
28998
29023
|
// lib/convert-easyeda-json-to-tscircuit-soup-json.ts
|
|
28999
|
-
var
|
|
29024
|
+
var import_mm2 = require("@tscircuit/mm");
|
|
29000
29025
|
var handleSilkscreenPath = (track, index) => {
|
|
29001
29026
|
return import_soup.pcb_silkscreen_path.parse({
|
|
29002
29027
|
type: "pcb_silkscreen_path",
|
|
@@ -29060,17 +29085,17 @@ var convertEasyEdaJsonToTscircuitSoupJson = (easyEdaJson, { useModelCdn, shouldR
|
|
|
29060
29085
|
source_component_id: "source_component_1",
|
|
29061
29086
|
name: portNumber
|
|
29062
29087
|
});
|
|
29063
|
-
if (pad.holeRadius !== void 0 && (0,
|
|
29088
|
+
if (pad.holeRadius !== void 0 && (0, import_mm2.mm)(pad.holeRadius) !== 0) {
|
|
29064
29089
|
soupElements.push(
|
|
29065
29090
|
import_soup.pcb_plated_hole.parse({
|
|
29066
29091
|
type: "pcb_plated_hole",
|
|
29067
29092
|
pcb_plated_hole_id: `pcb_plated_hole_${index + 1}`,
|
|
29068
29093
|
shape: "circle",
|
|
29069
|
-
x: (0,
|
|
29070
|
-
y: (0,
|
|
29071
|
-
hole_diameter: (0,
|
|
29072
|
-
outer_diameter: (0,
|
|
29073
|
-
radius: (0,
|
|
29094
|
+
x: (0, import_mm2.mm)(pad.center.x),
|
|
29095
|
+
y: (0, import_mm2.mm)(pad.center.y),
|
|
29096
|
+
hole_diameter: (0, import_mm2.mm)(pad.holeRadius) * 2,
|
|
29097
|
+
outer_diameter: (0, import_mm2.mm)(pad.width),
|
|
29098
|
+
radius: (0, import_mm2.mm)(pad.holeRadius),
|
|
29074
29099
|
port_hints: [portNumber],
|
|
29075
29100
|
pcb_component_id: "pcb_component_1",
|
|
29076
29101
|
pcb_port_id: `pcb_port_${index + 1}`,
|
|
@@ -29094,9 +29119,9 @@ var convertEasyEdaJsonToTscircuitSoupJson = (easyEdaJson, { useModelCdn, shouldR
|
|
|
29094
29119
|
type: "pcb_smtpad",
|
|
29095
29120
|
pcb_smtpad_id: `pcb_smtpad_${index + 1}`,
|
|
29096
29121
|
shape: soupShape,
|
|
29097
|
-
x: (0,
|
|
29098
|
-
y: (0,
|
|
29099
|
-
...soupShape === "rect" ? { width: (0,
|
|
29122
|
+
x: (0, import_mm2.mm)(pad.center.x),
|
|
29123
|
+
y: (0, import_mm2.mm)(pad.center.y),
|
|
29124
|
+
...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 },
|
|
29100
29125
|
layer: "top",
|
|
29101
29126
|
port_hints: [portNumber],
|
|
29102
29127
|
pcb_component_id: "pcb_component_1",
|
|
@@ -29148,10 +29173,8 @@ var import_promises = __toESM(require("fs/promises"), 1);
|
|
|
29148
29173
|
var package_default = {
|
|
29149
29174
|
name: "easyeda",
|
|
29150
29175
|
type: "module",
|
|
29151
|
-
version: "0.0.
|
|
29152
|
-
files: [
|
|
29153
|
-
"dist"
|
|
29154
|
-
],
|
|
29176
|
+
version: "0.0.17",
|
|
29177
|
+
files: ["dist"],
|
|
29155
29178
|
repository: {
|
|
29156
29179
|
type: "git",
|
|
29157
29180
|
url: "https://github.com/tscircuit/easyeda-converter"
|
|
@@ -29488,7 +29511,7 @@ var import_soup_util = __toESM(require_dist4(), 1);
|
|
|
29488
29511
|
|
|
29489
29512
|
// lib/generate-footprint-tsx.ts
|
|
29490
29513
|
var import_zod5 = require("zod");
|
|
29491
|
-
var
|
|
29514
|
+
var import_mm3 = require("@tscircuit/mm");
|
|
29492
29515
|
var generateFootprintTsx = (easyEdaJson) => {
|
|
29493
29516
|
const pads = easyEdaJson.packageDetail.dataStr.shape.filter(
|
|
29494
29517
|
(shape) => shape.type === "PAD"
|
|
@@ -29498,16 +29521,16 @@ var generateFootprintTsx = (easyEdaJson) => {
|
|
|
29498
29521
|
const centerY = centerOffset.y;
|
|
29499
29522
|
const footprintElements = pads.map((pad) => {
|
|
29500
29523
|
const { center, width, height, holeRadius, number } = pad;
|
|
29501
|
-
const isPlatedHole = holeRadius !== void 0 && (0,
|
|
29502
|
-
const normalizedX = (0,
|
|
29503
|
-
const normalizedY = (0,
|
|
29524
|
+
const isPlatedHole = holeRadius !== void 0 && (0, import_mm3.mm)(holeRadius) > 0;
|
|
29525
|
+
const normalizedX = (0, import_mm3.mm)(center.x) - centerX;
|
|
29526
|
+
const normalizedY = (0, import_mm3.mm)(center.y) - centerY;
|
|
29504
29527
|
if (isPlatedHole) {
|
|
29505
29528
|
return `
|
|
29506
29529
|
<platedhole
|
|
29507
29530
|
pcbX="${normalizedX.toFixed(2)}mm"
|
|
29508
29531
|
pcbY="${normalizedY.toFixed(2)}mm"
|
|
29509
|
-
hole_diameter="${(0,
|
|
29510
|
-
outer_diameter="${(0,
|
|
29532
|
+
hole_diameter="${(0, import_mm3.mm)(holeRadius) * 2}mm"
|
|
29533
|
+
outer_diameter="${(0, import_mm3.mm)(width)}mm"
|
|
29511
29534
|
portHints={["${number}"]}
|
|
29512
29535
|
/>`.replace(/\n/, "");
|
|
29513
29536
|
} else {
|
|
@@ -29515,8 +29538,8 @@ var generateFootprintTsx = (easyEdaJson) => {
|
|
|
29515
29538
|
<smtpad
|
|
29516
29539
|
pcbX="${normalizedX.toFixed(2)}mm"
|
|
29517
29540
|
pcbY="${normalizedY.toFixed(2)}mm"
|
|
29518
|
-
width="${(0,
|
|
29519
|
-
height="${(0,
|
|
29541
|
+
width="${(0, import_mm3.mm)(width)}mm"
|
|
29542
|
+
height="${(0, import_mm3.mm)(height)}mm"
|
|
29520
29543
|
shape="rect"
|
|
29521
29544
|
portHints={["${number}"]}
|
|
29522
29545
|
/>`.replace(/\n/, "");
|