easyeda 0.0.305 → 0.0.307

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/main.cjs CHANGED
@@ -3528,7 +3528,7 @@ var import_promises = __toESM(require("fs/promises"), 1);
3528
3528
  var package_default = {
3529
3529
  name: "easyeda",
3530
3530
  type: "module",
3531
- version: "0.0.304",
3531
+ version: "0.0.306",
3532
3532
  files: [
3533
3533
  "dist"
3534
3534
  ],
@@ -9702,6 +9702,40 @@ var handleSilkscreenCircle = (circle, index) => {
9702
9702
  stroke_width: mil10ToMm(circle.width)
9703
9703
  });
9704
9704
  };
9705
+ var handleRect = (rect, index) => {
9706
+ const width = milx10(rect.width);
9707
+ const height = milx10(rect.height);
9708
+ const center = {
9709
+ x: milx10(rect.x) + width / 2,
9710
+ y: milx10(rect.y) + height / 2
9711
+ };
9712
+ const layer = getSideFromLayer(rect.layer);
9713
+ if (isCourtyardLayer(rect.layer)) {
9714
+ return pcb_courtyard_rect.parse({
9715
+ type: "pcb_courtyard_rect",
9716
+ pcb_courtyard_rect_id: `pcb_courtyard_rect_${index + 1}`,
9717
+ pcb_component_id: "pcb_component_1",
9718
+ center,
9719
+ width,
9720
+ height,
9721
+ layer,
9722
+ ccw_rotation: rect.rotation
9723
+ });
9724
+ }
9725
+ return pcb_silkscreen_rect.parse({
9726
+ type: "pcb_silkscreen_rect",
9727
+ pcb_silkscreen_rect_id: `pcb_silkscreen_rect_${index + 1}`,
9728
+ pcb_component_id: "pcb_component_1",
9729
+ center,
9730
+ width,
9731
+ height,
9732
+ layer,
9733
+ stroke_width: mil2mm(rect.lineWidth),
9734
+ is_filled: rect.fillStyle !== "none",
9735
+ has_stroke: rect.lineWidth > 0,
9736
+ ccw_rotation: rect.rotation
9737
+ });
9738
+ };
9705
9739
  var handleHole = (hole, index) => {
9706
9740
  return pcb_hole.parse({
9707
9741
  type: "pcb_hole",
@@ -9977,6 +10011,8 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
9977
10011
  if (isSilkscreenLayer(shape.layer)) {
9978
10012
  circuitElements.push(handleSilkscreenCircle(shape, index));
9979
10013
  }
10014
+ } else if (shape.type === "RECT") {
10015
+ circuitElements.push(handleRect(shape, index));
9980
10016
  } else if (shape.type === "ARC") {
9981
10017
  if (!isCourtyardLayer(shape.layer)) {
9982
10018
  circuitElements.push(handleSilkscreenArc(shape, index));
@@ -10009,6 +10045,9 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
10009
10045
  R: "bottom_right"
10010
10046
  }[shape.textAnchor ?? "L"],
10011
10047
  font_size: shape.size_mm || 1,
10048
+ ...shape.rotation !== void 0 && {
10049
+ ccw_rotation: shape.rotation
10050
+ },
10012
10051
  layer: "top"
10013
10052
  })
10014
10053
  );
@@ -10034,7 +10073,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
10034
10073
  );
10035
10074
  }
10036
10075
  const pcbElements = circuitElements.filter(
10037
- (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_silkscreen_path" || e.type === "pcb_silkscreen_text"
10076
+ (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"
10038
10077
  );
10039
10078
  if (pcbElements.length > 0) {
10040
10079
  const bounds = findBoundsAndCenter(pcbElements);
@@ -10501,7 +10540,18 @@ var ShapeItemSchema = import_zod179.z.object({
10501
10540
  });
10502
10541
  }
10503
10542
  case "TEXT": {
10504
- const [textAnchor, x, y, size2, layer, id, rotation2, , font, text] = shape.data.split("~");
10543
+ const [
10544
+ textAnchor,
10545
+ x,
10546
+ y,
10547
+ size2,
10548
+ rotation2,
10549
+ _mirror,
10550
+ layer,
10551
+ _net,
10552
+ font,
10553
+ text
10554
+ ] = shape.data.split("~");
10505
10555
  const r = rotation2 ? Number(rotation2) : void 0;
10506
10556
  return TextSchema.parse({
10507
10557
  type: "TEXT",
@@ -10511,7 +10561,6 @@ var ShapeItemSchema = import_zod179.z.object({
10511
10561
  size_mm: Number(size2) * 2.54,
10512
10562
  // empirically this seems to match, C5248081 is a good test case
10513
10563
  layer: layer ? Number(layer) : void 0,
10514
- id,
10515
10564
  rotation: Number.isNaN(r) ? void 0 : r,
10516
10565
  textAnchor,
10517
10566
  font: font || void 0
@@ -11193,8 +11242,10 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
11193
11242
  for (const silkscreenText of silkscreenTexts) {
11194
11243
  const isRefDes = silkscreenText.text === "{NAME}";
11195
11244
  const textValue = isRefDes ? JSON.stringify("{NAME}") : JSON.stringify(silkscreenText.text);
11245
+ const rotation2 = silkscreenText.ccw_rotation || 0;
11246
+ const rotationAttr = rotation2 ? ` pcbRotation="${rotation2}deg"` : "";
11196
11247
  elementStrings.push(
11197
- `<silkscreentext text=${textValue} pcbX="${mmStr(silkscreenText.anchor_position.x)}" pcbY="${mmStr(silkscreenText.anchor_position.y)}" anchorAlignment="${silkscreenText.anchor_alignment}" ${silkscreenText.font_size ? `fontSize="${mmStr(silkscreenText.font_size)}"` : ""} />`
11248
+ `<silkscreentext text=${textValue} pcbX="${mmStr(silkscreenText.anchor_position.x)}" pcbY="${mmStr(silkscreenText.anchor_position.y)}" anchorAlignment="${silkscreenText.anchor_alignment}"${rotationAttr}${silkscreenText.font_size ? ` fontSize="${mmStr(silkscreenText.font_size)}"` : ""} />`
11198
11249
  );
11199
11250
  }
11200
11251
  for (const courtyardOutline of courtyardOutlines) {