easyeda 0.0.17 → 0.0.19

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 CHANGED
@@ -6480,14 +6480,14 @@ var require_dist2 = __commonJS({
6480
6480
  x,
6481
6481
  y: -Math.sqrt(1 - x ** 2)
6482
6482
  }));
6483
- var import_mm5 = require("@tscircuit/mm");
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, import_mm5.mm)(id),
6490
- outer_diameter: (0, import_mm5.mm)(od),
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 = (mm5) => {
28315
- return mm5 / 25.4;
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 import_mm2 = require("@tscircuit/mm");
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, import_mm2.mm)(pad.center.x)));
28987
- const maxX = Math.max(...pads.map((pad) => (0, import_mm2.mm)(pad.center.x)));
28988
- const minY = Math.min(...pads.map((pad) => (0, import_mm2.mm)(pad.center.y)));
28989
- const maxY = Math.max(...pads.map((pad) => (0, import_mm2.mm)(pad.center.y)));
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 import_mm3 = require("@tscircuit/mm");
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, import_mm3.mm)(pad.holeRadius) !== 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, import_mm3.mm)(pad.center.x),
29070
- y: (0, import_mm3.mm)(pad.center.y),
29071
- hole_diameter: (0, import_mm3.mm)(pad.holeRadius) * 2,
29072
- outer_diameter: (0, import_mm3.mm)(pad.width),
29073
- radius: (0, import_mm3.mm)(pad.holeRadius),
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, import_mm3.mm)(pad.center.x),
29098
- y: (0, import_mm3.mm)(pad.center.y),
29099
- ...soupShape === "rect" ? { width: (0, import_mm3.mm)(pad.width), height: (0, import_mm3.mm)(pad.height) } : { radius: Math.min((0, import_mm3.mm)(pad.width), (0, import_mm3.mm)(pad.height)) / 2 },
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.16",
29152
- files: [
29153
- "dist"
29154
- ],
29176
+ version: "0.0.18",
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 import_mm4 = require("@tscircuit/mm");
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, import_mm4.mm)(holeRadius) > 0;
29502
- const normalizedX = (0, import_mm4.mm)(center.x) - centerX;
29503
- const normalizedY = (0, import_mm4.mm)(center.y) - centerY;
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, import_mm4.mm)(holeRadius) * 2}mm"
29510
- outer_diameter="${(0, import_mm4.mm)(width)}mm"
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, import_mm4.mm)(width)}mm"
29519
- height="${(0, import_mm4.mm)(height)}mm"
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/, "");
@@ -29585,7 +29608,8 @@ var convertToTypescriptComponent = ({
29585
29608
  soup,
29586
29609
  easyeda: easyEdaJson
29587
29610
  }) => {
29588
- const pn = easyEdaJson.lcsc.number;
29611
+ const rawPn = easyEdaJson.dataStr.head.c_para["Manufacturer Part"];
29612
+ const pn = normalizeManufacturerPartNumber(rawPn);
29589
29613
  const [cad_component2] = (0, import_soup_util2.su)(soup).cad_component.list();
29590
29614
  const smtpads = (0, import_soup_util2.su)(soup).pcb_smtpad.list();
29591
29615
  const plated_holes = (0, import_soup_util2.su)(soup).pcb_plated_hole.list();
@@ -29615,6 +29639,14 @@ var convertToTypescriptComponent = ({
29615
29639
  easyEdaJson
29616
29640
  });
29617
29641
  };
29642
+ function normalizeManufacturerPartNumber(partNumber) {
29643
+ let normalized = partNumber.replace(/-/g, "_");
29644
+ normalized = normalized.replace(/[^a-zA-Z0-9_$]/g, "");
29645
+ if (/^\d/.test(normalized)) {
29646
+ normalized = "A" + normalized;
29647
+ }
29648
+ return normalized;
29649
+ }
29618
29650
 
29619
29651
  // cli/main.ts
29620
29652
  var path = __toESM(require("path"), 1);