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/index.js CHANGED
@@ -6121,6 +6121,40 @@ var handleSilkscreenCircle = (circle, index) => {
6121
6121
  stroke_width: mil10ToMm(circle.width)
6122
6122
  });
6123
6123
  };
6124
+ var handleRect = (rect, index) => {
6125
+ const width = milx10(rect.width);
6126
+ const height = milx10(rect.height);
6127
+ const center = {
6128
+ x: milx10(rect.x) + width / 2,
6129
+ y: milx10(rect.y) + height / 2
6130
+ };
6131
+ const layer = getSideFromLayer(rect.layer);
6132
+ if (isCourtyardLayer(rect.layer)) {
6133
+ return pcb_courtyard_rect.parse({
6134
+ type: "pcb_courtyard_rect",
6135
+ pcb_courtyard_rect_id: `pcb_courtyard_rect_${index + 1}`,
6136
+ pcb_component_id: "pcb_component_1",
6137
+ center,
6138
+ width,
6139
+ height,
6140
+ layer,
6141
+ ccw_rotation: rect.rotation
6142
+ });
6143
+ }
6144
+ return pcb_silkscreen_rect.parse({
6145
+ type: "pcb_silkscreen_rect",
6146
+ pcb_silkscreen_rect_id: `pcb_silkscreen_rect_${index + 1}`,
6147
+ pcb_component_id: "pcb_component_1",
6148
+ center,
6149
+ width,
6150
+ height,
6151
+ layer,
6152
+ stroke_width: mil2mm(rect.lineWidth),
6153
+ is_filled: rect.fillStyle !== "none",
6154
+ has_stroke: rect.lineWidth > 0,
6155
+ ccw_rotation: rect.rotation
6156
+ });
6157
+ };
6124
6158
  var handleHole = (hole, index) => {
6125
6159
  return pcb_hole.parse({
6126
6160
  type: "pcb_hole",
@@ -6396,6 +6430,8 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
6396
6430
  if (isSilkscreenLayer(shape.layer)) {
6397
6431
  circuitElements.push(handleSilkscreenCircle(shape, index));
6398
6432
  }
6433
+ } else if (shape.type === "RECT") {
6434
+ circuitElements.push(handleRect(shape, index));
6399
6435
  } else if (shape.type === "ARC") {
6400
6436
  if (!isCourtyardLayer(shape.layer)) {
6401
6437
  circuitElements.push(handleSilkscreenArc(shape, index));
@@ -6428,6 +6464,9 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
6428
6464
  R: "bottom_right"
6429
6465
  }[shape.textAnchor ?? "L"],
6430
6466
  font_size: shape.size_mm || 1,
6467
+ ...shape.rotation !== void 0 && {
6468
+ ccw_rotation: shape.rotation
6469
+ },
6431
6470
  layer: "top"
6432
6471
  })
6433
6472
  );
@@ -6453,7 +6492,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
6453
6492
  );
6454
6493
  }
6455
6494
  const pcbElements = circuitElements.filter(
6456
- (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"
6495
+ (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"
6457
6496
  );
6458
6497
  if (pcbElements.length > 0) {
6459
6498
  const bounds = findBoundsAndCenter(pcbElements);
@@ -7094,7 +7133,18 @@ var ShapeItemSchema = z179.object({
7094
7133
  });
7095
7134
  }
7096
7135
  case "TEXT": {
7097
- const [textAnchor, x, y, size2, layer, id, rotation2, , font, text] = shape.data.split("~");
7136
+ const [
7137
+ textAnchor,
7138
+ x,
7139
+ y,
7140
+ size2,
7141
+ rotation2,
7142
+ _mirror,
7143
+ layer,
7144
+ _net,
7145
+ font,
7146
+ text
7147
+ ] = shape.data.split("~");
7098
7148
  const r = rotation2 ? Number(rotation2) : void 0;
7099
7149
  return TextSchema.parse({
7100
7150
  type: "TEXT",
@@ -7104,7 +7154,6 @@ var ShapeItemSchema = z179.object({
7104
7154
  size_mm: Number(size2) * 2.54,
7105
7155
  // empirically this seems to match, C5248081 is a good test case
7106
7156
  layer: layer ? Number(layer) : void 0,
7107
- id,
7108
7157
  rotation: Number.isNaN(r) ? void 0 : r,
7109
7158
  textAnchor,
7110
7159
  font: font || void 0
@@ -7786,8 +7835,10 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
7786
7835
  for (const silkscreenText of silkscreenTexts) {
7787
7836
  const isRefDes = silkscreenText.text === "{NAME}";
7788
7837
  const textValue = isRefDes ? JSON.stringify("{NAME}") : JSON.stringify(silkscreenText.text);
7838
+ const rotation2 = silkscreenText.ccw_rotation || 0;
7839
+ const rotationAttr = rotation2 ? ` pcbRotation="${rotation2}deg"` : "";
7789
7840
  elementStrings.push(
7790
- `<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)}"` : ""} />`
7841
+ `<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)}"` : ""} />`
7791
7842
  );
7792
7843
  }
7793
7844
  for (const courtyardOutline of courtyardOutlines) {