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.
@@ -9984,6 +9984,40 @@ var handleSilkscreenCircle = (circle, index) => {
9984
9984
  stroke_width: mil10ToMm(circle.width)
9985
9985
  });
9986
9986
  };
9987
+ var handleRect = (rect, index) => {
9988
+ const width = milx10(rect.width);
9989
+ const height = milx10(rect.height);
9990
+ const center = {
9991
+ x: milx10(rect.x) + width / 2,
9992
+ y: milx10(rect.y) + height / 2
9993
+ };
9994
+ const layer = getSideFromLayer(rect.layer);
9995
+ if (isCourtyardLayer(rect.layer)) {
9996
+ return pcb_courtyard_rect.parse({
9997
+ type: "pcb_courtyard_rect",
9998
+ pcb_courtyard_rect_id: `pcb_courtyard_rect_${index + 1}`,
9999
+ pcb_component_id: "pcb_component_1",
10000
+ center,
10001
+ width,
10002
+ height,
10003
+ layer,
10004
+ ccw_rotation: rect.rotation
10005
+ });
10006
+ }
10007
+ return pcb_silkscreen_rect.parse({
10008
+ type: "pcb_silkscreen_rect",
10009
+ pcb_silkscreen_rect_id: `pcb_silkscreen_rect_${index + 1}`,
10010
+ pcb_component_id: "pcb_component_1",
10011
+ center,
10012
+ width,
10013
+ height,
10014
+ layer,
10015
+ stroke_width: mil2mm(rect.lineWidth),
10016
+ is_filled: rect.fillStyle !== "none",
10017
+ has_stroke: rect.lineWidth > 0,
10018
+ ccw_rotation: rect.rotation
10019
+ });
10020
+ };
9987
10021
  var handleHole = (hole, index) => {
9988
10022
  return pcb_hole.parse({
9989
10023
  type: "pcb_hole",
@@ -10259,6 +10293,8 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
10259
10293
  if (isSilkscreenLayer(shape.layer)) {
10260
10294
  circuitElements.push(handleSilkscreenCircle(shape, index));
10261
10295
  }
10296
+ } else if (shape.type === "RECT") {
10297
+ circuitElements.push(handleRect(shape, index));
10262
10298
  } else if (shape.type === "ARC") {
10263
10299
  if (!isCourtyardLayer(shape.layer)) {
10264
10300
  circuitElements.push(handleSilkscreenArc(shape, index));
@@ -10291,6 +10327,9 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
10291
10327
  R: "bottom_right"
10292
10328
  }[shape.textAnchor ?? "L"],
10293
10329
  font_size: shape.size_mm || 1,
10330
+ ...shape.rotation !== void 0 && {
10331
+ ccw_rotation: shape.rotation
10332
+ },
10294
10333
  layer: "top"
10295
10334
  })
10296
10335
  );
@@ -10316,7 +10355,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
10316
10355
  );
10317
10356
  }
10318
10357
  const pcbElements = circuitElements.filter(
10319
- (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"
10358
+ (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"
10320
10359
  );
10321
10360
  if (pcbElements.length > 0) {
10322
10361
  const bounds = findBoundsAndCenter(pcbElements);
@@ -10779,7 +10818,18 @@ var ShapeItemSchema = external_exports.object({
10779
10818
  });
10780
10819
  }
10781
10820
  case "TEXT": {
10782
- const [textAnchor, x, y, size2, layer, id, rotation2, , font, text] = shape.data.split("~");
10821
+ const [
10822
+ textAnchor,
10823
+ x,
10824
+ y,
10825
+ size2,
10826
+ rotation2,
10827
+ _mirror,
10828
+ layer,
10829
+ _net,
10830
+ font,
10831
+ text
10832
+ ] = shape.data.split("~");
10783
10833
  const r = rotation2 ? Number(rotation2) : void 0;
10784
10834
  return TextSchema.parse({
10785
10835
  type: "TEXT",
@@ -10789,7 +10839,6 @@ var ShapeItemSchema = external_exports.object({
10789
10839
  size_mm: Number(size2) * 2.54,
10790
10840
  // empirically this seems to match, C5248081 is a good test case
10791
10841
  layer: layer ? Number(layer) : void 0,
10792
- id,
10793
10842
  rotation: Number.isNaN(r) ? void 0 : r,
10794
10843
  textAnchor,
10795
10844
  font: font || void 0
@@ -11485,8 +11534,10 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
11485
11534
  for (const silkscreenText of silkscreenTexts) {
11486
11535
  const isRefDes = silkscreenText.text === "{NAME}";
11487
11536
  const textValue = isRefDes ? JSON.stringify("{NAME}") : JSON.stringify(silkscreenText.text);
11537
+ const rotation2 = silkscreenText.ccw_rotation || 0;
11538
+ const rotationAttr = rotation2 ? ` pcbRotation="${rotation2}deg"` : "";
11488
11539
  elementStrings.push(
11489
- `<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)}"` : ""} />`
11540
+ `<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)}"` : ""} />`
11490
11541
  );
11491
11542
  }
11492
11543
  for (const courtyardOutline of courtyardOutlines) {