easyeda 0.0.193 → 0.0.195
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.js +26 -44
- package/dist/browser/index.js.map +1 -1
- package/dist/{chunk-IHHD3QWA.js → chunk-UZMC3PUZ.js} +27 -45
- package/dist/{chunk-IHHD3QWA.js.map → chunk-UZMC3PUZ.js.map} +1 -1
- package/dist/cli/main.js +3 -3
- package/dist/cli/main.js.map +1 -1
- package/dist/lib/index.d.ts +3 -3
- package/dist/lib/index.js +1 -1
- package/package.json +2 -2
package/dist/browser/index.js
CHANGED
|
@@ -16,7 +16,8 @@ var PointSchema = z.any().transform((p) => {
|
|
|
16
16
|
if (Array.isArray(p)) {
|
|
17
17
|
const [x, y] = p;
|
|
18
18
|
return { x, y };
|
|
19
|
-
}
|
|
19
|
+
}
|
|
20
|
+
if (typeof p === "object") {
|
|
20
21
|
return p;
|
|
21
22
|
}
|
|
22
23
|
throw new Error(`Invalid point: ${p}`);
|
|
@@ -144,8 +145,6 @@ var ShapeItemSchema = z.object({
|
|
|
144
145
|
type: z.string(),
|
|
145
146
|
data: z.string()
|
|
146
147
|
}).transform((shape) => {
|
|
147
|
-
const [firstParam, ...restParams] = shape.data.split("~");
|
|
148
|
-
const lastParam = restParams.pop();
|
|
149
148
|
switch (shape.type) {
|
|
150
149
|
case "TRACK": {
|
|
151
150
|
const [width, layer, _, pointsStr, id, _n] = shape.data.split("~");
|
|
@@ -164,14 +163,14 @@ var ShapeItemSchema = z.object({
|
|
|
164
163
|
number,
|
|
165
164
|
holeRadius,
|
|
166
165
|
...rest
|
|
167
|
-
] = params.map((p) => isNaN(Number(p)) ? p : Number(p));
|
|
166
|
+
] = params.map((p) => Number.isNaN(Number(p)) ? p : Number(p));
|
|
168
167
|
const center = { x: centerX, y: centerY };
|
|
169
|
-
let points
|
|
168
|
+
let points;
|
|
170
169
|
if (padShape === "RECT") {
|
|
171
170
|
points = parsePoints(rest[0]);
|
|
172
|
-
const r = Number(rest[1]);
|
|
173
|
-
rotation2 = Number.isNaN(r) ? void 0 : r;
|
|
174
171
|
}
|
|
172
|
+
const r = Number(rest[1]);
|
|
173
|
+
const rotation2 = Number.isNaN(r) ? void 0 : r;
|
|
175
174
|
const padInputParams = {
|
|
176
175
|
type: "PAD",
|
|
177
176
|
shape: padShape,
|
|
@@ -310,7 +309,6 @@ var ShapeItemSchema = z.object({
|
|
|
310
309
|
}
|
|
311
310
|
default:
|
|
312
311
|
throw new Error(`Unknown shape type: ${shape.type}`);
|
|
313
|
-
return BaseShapeSchema.parse({ type: shape.type });
|
|
314
312
|
}
|
|
315
313
|
}).pipe(PackageDetailShapeSchema);
|
|
316
314
|
var ShapesArraySchema = z.array(ShapeItemSchema);
|
|
@@ -2953,21 +2951,6 @@ import { compose, scale, translate, applyToPoint as applyToPoint2 } from "transf
|
|
|
2953
2951
|
|
|
2954
2952
|
// lib/compute-center-offset.ts
|
|
2955
2953
|
import { mm as mm2 } from "@tscircuit/mm";
|
|
2956
|
-
var computeCenterOffset = (easyeda) => {
|
|
2957
|
-
const pads = easyeda.packageDetail.dataStr.shape.filter(
|
|
2958
|
-
(shape) => shape.type === "PAD"
|
|
2959
|
-
);
|
|
2960
|
-
const minX = Math.min(...pads.map((pad) => mm2(pad.center.x)));
|
|
2961
|
-
const maxX = Math.max(...pads.map((pad) => mm2(pad.center.x)));
|
|
2962
|
-
const minY = Math.min(...pads.map((pad) => mm2(pad.center.y)));
|
|
2963
|
-
const maxY = Math.max(...pads.map((pad) => mm2(pad.center.y)));
|
|
2964
|
-
const centerX = (minX + maxX) / 2;
|
|
2965
|
-
const centerY = (minY + maxY) / 2;
|
|
2966
|
-
return {
|
|
2967
|
-
x: centerX,
|
|
2968
|
-
y: centerY
|
|
2969
|
-
};
|
|
2970
|
-
};
|
|
2971
2954
|
|
|
2972
2955
|
// lib/convert-easyeda-json-to-tscircuit-soup-json.ts
|
|
2973
2956
|
import { mm as mm3 } from "@tscircuit/mm";
|
|
@@ -3061,8 +3044,7 @@ var handleCutout = (solidRegion, index) => {
|
|
|
3061
3044
|
});
|
|
3062
3045
|
};
|
|
3063
3046
|
var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecenter = true } = {}) => {
|
|
3064
|
-
const
|
|
3065
|
-
const centerOffset = computeCenterOffset(easyEdaJson);
|
|
3047
|
+
const circuitElements = [];
|
|
3066
3048
|
const source_component = any_source_component.parse({
|
|
3067
3049
|
type: "source_component",
|
|
3068
3050
|
source_component_id: "source_component_1",
|
|
@@ -3083,7 +3065,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
|
|
|
3083
3065
|
center: { x: 0, y: 0 },
|
|
3084
3066
|
layer: "top"
|
|
3085
3067
|
});
|
|
3086
|
-
|
|
3068
|
+
circuitElements.push(source_component, pcb_component2);
|
|
3087
3069
|
const pads = easyEdaJson.packageDetail.dataStr.shape.filter(
|
|
3088
3070
|
(shape) => shape.type === "PAD"
|
|
3089
3071
|
);
|
|
@@ -3101,7 +3083,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
|
|
|
3101
3083
|
const pinNumber = Number.parseInt(
|
|
3102
3084
|
portHints.find((hint) => hint.match(/pin\d+/)).replace("pin", "")
|
|
3103
3085
|
);
|
|
3104
|
-
|
|
3086
|
+
circuitElements.push({
|
|
3105
3087
|
type: "source_port",
|
|
3106
3088
|
source_port_id: `source_port_${index + 1}`,
|
|
3107
3089
|
source_component_id: "source_component_1",
|
|
@@ -3151,7 +3133,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
|
|
|
3151
3133
|
radius: mil2mm(pad.holeRadius)
|
|
3152
3134
|
};
|
|
3153
3135
|
}
|
|
3154
|
-
|
|
3136
|
+
circuitElements.push(
|
|
3155
3137
|
pcb_plated_hole.parse({
|
|
3156
3138
|
...commonPlatedHoleProps,
|
|
3157
3139
|
...additionalPlatedHoleProps
|
|
@@ -3186,30 +3168,30 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
|
|
|
3186
3168
|
pcb_component_id: "pcb_component_1",
|
|
3187
3169
|
pcb_port_id: `pcb_port_${index + 1}`
|
|
3188
3170
|
});
|
|
3189
|
-
|
|
3171
|
+
circuitElements.push(parsedPcbSmtpad);
|
|
3190
3172
|
}
|
|
3191
3173
|
});
|
|
3192
3174
|
easyEdaJson.packageDetail.dataStr.shape.filter(
|
|
3193
3175
|
(shape) => shape.type === "HOLE"
|
|
3194
3176
|
).forEach((h, index) => {
|
|
3195
|
-
|
|
3196
|
-
|
|
3177
|
+
circuitElements.push(handleHole(h, index));
|
|
3178
|
+
circuitElements.push(handleHoleCutout(h, index));
|
|
3197
3179
|
});
|
|
3198
3180
|
easyEdaJson.packageDetail.dataStr.shape.filter((shape) => shape.type === "VIA").forEach((v, index) => {
|
|
3199
|
-
|
|
3181
|
+
circuitElements.push(handleVia(v, index));
|
|
3200
3182
|
});
|
|
3201
3183
|
easyEdaJson.packageDetail.dataStr.shape.filter(
|
|
3202
3184
|
(shape) => shape.type === "SOLIDREGION" && shape.fillStyle === "cutout"
|
|
3203
3185
|
).forEach((sr, index) => {
|
|
3204
|
-
|
|
3186
|
+
circuitElements.push(handleCutout(sr, index));
|
|
3205
3187
|
});
|
|
3206
3188
|
easyEdaJson.packageDetail.dataStr.shape.forEach((shape, index) => {
|
|
3207
3189
|
if (shape.type === "TRACK") {
|
|
3208
|
-
|
|
3190
|
+
circuitElements.push(handleSilkscreenPath(shape, index));
|
|
3209
3191
|
} else if (shape.type === "ARC") {
|
|
3210
|
-
|
|
3192
|
+
circuitElements.push(handleSilkscreenArc(shape, index));
|
|
3211
3193
|
} else if (shape.type === "TEXT") {
|
|
3212
|
-
|
|
3194
|
+
circuitElements.push(
|
|
3213
3195
|
pcb_silkscreen_text.parse({
|
|
3214
3196
|
type: "pcb_silkscreen_text",
|
|
3215
3197
|
pcb_silkscreen_text_id: `pcb_silkscreen_text_${index + 1}`,
|
|
@@ -3237,7 +3219,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
|
|
|
3237
3219
|
const objFileUrl = objFileUuid ? useModelCdn ? `https://modelcdn.tscircuit.com/easyeda_models/download?uuid=${objFileUuid}&pn=${easyEdaJson.lcsc.number}` : `https://modules.easyeda.com/3dmodel/${objFileUuid}` : void 0;
|
|
3238
3220
|
if (objFileUrl !== void 0) {
|
|
3239
3221
|
const [rx, ry, rz] = (svgNode?.svgData.attrs?.c_rotation ?? "0,0,0").split(",").map(Number);
|
|
3240
|
-
|
|
3222
|
+
circuitElements.push(
|
|
3241
3223
|
cad_component.parse({
|
|
3242
3224
|
type: "cad_component",
|
|
3243
3225
|
cad_component_id: "cad_component_1",
|
|
@@ -3253,14 +3235,14 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
|
|
|
3253
3235
|
const bounds = findBoundsAndCenter(
|
|
3254
3236
|
// exclude the pcb_component because it's center is currently incorrect,
|
|
3255
3237
|
// we set it to (0,0)
|
|
3256
|
-
|
|
3238
|
+
circuitElements.filter((e) => e.type !== "pcb_component")
|
|
3257
3239
|
);
|
|
3258
3240
|
const matrix = compose(
|
|
3259
3241
|
translate(-bounds.center.x, bounds.center.y),
|
|
3260
3242
|
scale(1, -1)
|
|
3261
3243
|
);
|
|
3262
|
-
transformPCBElements(
|
|
3263
|
-
|
|
3244
|
+
transformPCBElements(circuitElements, matrix);
|
|
3245
|
+
for (const e of circuitElements) {
|
|
3264
3246
|
if (e.type === "pcb_cutout") {
|
|
3265
3247
|
if (e.shape === "polygon") {
|
|
3266
3248
|
e.points = e.points.map((p) => applyToPoint2(matrix, p));
|
|
@@ -3268,10 +3250,10 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
|
|
|
3268
3250
|
e.center = applyToPoint2(matrix, e.center);
|
|
3269
3251
|
}
|
|
3270
3252
|
}
|
|
3271
|
-
}
|
|
3253
|
+
}
|
|
3272
3254
|
pcb_component2.center = { x: 0, y: 0 };
|
|
3273
3255
|
}
|
|
3274
|
-
return
|
|
3256
|
+
return circuitElements;
|
|
3275
3257
|
};
|
|
3276
3258
|
|
|
3277
3259
|
// lib/utils/normalize-manufacturer-part-number.ts
|
|
@@ -3303,8 +3285,8 @@ var convertBetterEasyToTsx = async ({
|
|
|
3303
3285
|
const sourcePorts = su_default(circuitJson).source_port.list();
|
|
3304
3286
|
const pinLabels = {};
|
|
3305
3287
|
const sortedPorts = sourcePorts.sort((a, b) => {
|
|
3306
|
-
const aNum = parseInt(a.name.replace("pin", ""));
|
|
3307
|
-
const bNum = parseInt(b.name.replace("pin", ""));
|
|
3288
|
+
const aNum = Number.parseInt(a.name.replace("pin", ""));
|
|
3289
|
+
const bNum = Number.parseInt(b.name.replace("pin", ""));
|
|
3308
3290
|
return aNum - bNum;
|
|
3309
3291
|
});
|
|
3310
3292
|
for (const sourcePort of sortedPorts) {
|