easyeda 0.0.326 → 0.0.327

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
@@ -5607,9 +5607,9 @@ var insertionDirectionToVec = (direction) => {
5607
5607
  return { x: -1, y: 0 };
5608
5608
  case "from_right":
5609
5609
  return { x: 1, y: 0 };
5610
- case "from_front":
5610
+ case "from_top":
5611
5611
  return { x: 0, y: 1 };
5612
- case "from_back":
5612
+ case "from_bottom":
5613
5613
  return { x: 0, y: -1 };
5614
5614
  }
5615
5615
  };
@@ -5619,11 +5619,15 @@ var vecToInsertionDirection = ({
5619
5619
  }) => {
5620
5620
  if (x > 0) return "from_right";
5621
5621
  if (x < 0) return "from_left";
5622
- if (y > 0) return "from_front";
5623
- return "from_back";
5622
+ if (y > 0) return "from_top";
5623
+ return "from_bottom";
5624
5624
  };
5625
5625
  var transformInsertionDirection = (direction, opts) => {
5626
- if (!direction || direction === "from_above") return direction;
5626
+ if (!direction) return direction;
5627
+ if (direction === "from_above" || direction === "from_below") {
5628
+ if (!opts.isFlipped) return direction;
5629
+ return direction === "from_above" ? "from_below" : "from_above";
5630
+ }
5627
5631
  let { x, y } = insertionDirectionToVec(direction);
5628
5632
  let quarterTurns = Math.round(opts.rotationDegrees / 90);
5629
5633
  while (quarterTurns > 0) {
@@ -5646,7 +5650,7 @@ var transformPCBElement = (elm, matrix) => {
5646
5650
  const flipPadWidthHeight = Math.abs(getQuarterTurns(tsr.rotation.angle)) % 2 === 1;
5647
5651
  const rotationDegrees = tsr.rotation.angle / Math.PI * 180;
5648
5652
  const isFlipped = tsr.scale.sy < 0;
5649
- if (elm.type === "pcb_plated_hole" || elm.type === "pcb_hole" || elm.type === "pcb_via" || elm.type === "pcb_smtpad" || elm.type === "pcb_port") {
5653
+ if (elm.type === "pcb_plated_hole" || elm.type === "pcb_hole" || elm.type === "pcb_via" || elm.type === "pcb_smtpad" || elm.type === "pcb_solder_paste" || elm.type === "pcb_port") {
5650
5654
  const { x, y } = applyToPoint(matrix, {
5651
5655
  x: Number(elm.x),
5652
5656
  y: Number(elm.y)
@@ -5666,10 +5670,14 @@ var transformPCBElement = (elm, matrix) => {
5666
5670
  elm.center = applyToPoint(matrix, elm.center);
5667
5671
  } else if (elm.type === "pcb_silkscreen_text" || elm.type === "pcb_fabrication_note_text" || elm.type === "pcb_note_text") {
5668
5672
  elm.anchor_position = applyToPoint(matrix, elm.anchor_position);
5673
+ } else if (elm.type === "pcb_copper_text") {
5674
+ if (elm.anchor_position) {
5675
+ elm.anchor_position = applyToPoint(matrix, elm.anchor_position);
5676
+ }
5669
5677
  } else if (elm.type === "pcb_courtyard_rect") {
5670
5678
  elm.center = applyToPoint(matrix, elm.center);
5671
5679
  elm.ccw_rotation = ((elm.ccw_rotation ?? 0) + rotationDegrees) % 360;
5672
- } else if (elm.type === "pcb_silkscreen_circle" || elm.type === "pcb_silkscreen_rect" || elm.type === "pcb_note_rect" || elm.type === "pcb_courtyard_circle") {
5680
+ } else if (elm.type === "pcb_silkscreen_circle" || elm.type === "pcb_silkscreen_rect" || elm.type === "pcb_silkscreen_pill" || elm.type === "pcb_silkscreen_oval" || elm.type === "pcb_note_rect" || elm.type === "pcb_courtyard_circle") {
5673
5681
  elm.center = applyToPoint(matrix, elm.center);
5674
5682
  } else if (elm.type === "pcb_component") {
5675
5683
  elm.center = applyToPoint(matrix, elm.center);
@@ -5706,7 +5714,19 @@ var transformPCBElement = (elm, matrix) => {
5706
5714
  p.y = tp.y;
5707
5715
  return p;
5708
5716
  });
5709
- } else if (elm.type === "pcb_silkscreen_path" || elm.type === "pcb_trace" || elm.type === "pcb_fabrication_note_path" || elm.type === "pcb_note_path") {
5717
+ } else if (elm.type === "pcb_trace") {
5718
+ elm.route = elm.route.map((rp) => {
5719
+ if (!("x" in rp)) {
5720
+ rp.start = applyToPoint(matrix, rp.start);
5721
+ rp.end = applyToPoint(matrix, rp.end);
5722
+ return rp;
5723
+ }
5724
+ const tp = applyToPoint(matrix, rp);
5725
+ rp.x = tp.x;
5726
+ rp.y = tp.y;
5727
+ return rp;
5728
+ });
5729
+ } else if (elm.type === "pcb_silkscreen_path" || elm.type === "pcb_trace_hint" || elm.type === "pcb_fabrication_note_path" || elm.type === "pcb_note_path") {
5710
5730
  elm.route = elm.route.map((rp) => {
5711
5731
  const tp = applyToPoint(matrix, rp);
5712
5732
  rp.x = tp.x;
@@ -5739,7 +5759,7 @@ var transformPCBElements = (elms, matrix) => {
5739
5759
  let transformedElms = elms.map((elm) => transformPCBElement(elm, matrix));
5740
5760
  if (flipPadWidthHeight) {
5741
5761
  transformedElms = transformedElms.map((elm) => {
5742
- if (elm.type === "pcb_smtpad" && (elm.shape === "rect" || elm.shape === "pill")) {
5762
+ if ((elm.type === "pcb_smtpad" || elm.type === "pcb_solder_paste") && (elm.shape === "rect" || elm.shape === "pill")) {
5743
5763
  ;
5744
5764
  [elm.width, elm.height] = [elm.height, elm.width];
5745
5765
  }
@@ -5894,7 +5914,10 @@ var getDebugLayoutObject = (lo) => {
5894
5914
  const content = lo;
5895
5915
  if (x === void 0 || y === void 0) return null;
5896
5916
  if (width === void 0) {
5897
- if ("outer_diameter" in lo) {
5917
+ if ("radius" in lo) {
5918
+ width = lo.radius * 2;
5919
+ height = lo.radius * 2;
5920
+ } else if ("outer_diameter" in lo) {
5898
5921
  width = lo.outer_diameter;
5899
5922
  height = lo.outer_diameter;
5900
5923
  } else if ("rect_pad_width" in lo && "rect_pad_height" in lo) {
@@ -5949,6 +5972,17 @@ var findBoundsAndCenter = (elements) => {
5949
5972
  const center = { x: minX + width / 2, y: minY + height / 2 };
5950
5973
  return { center, width, height };
5951
5974
  };
5975
+ var PIN1_LOCATION_PARTS = {
5976
+ leftside_top: { side: "leftside", alignment: "top" },
5977
+ leftside_bottom: { side: "leftside", alignment: "bottom" },
5978
+ rightside_top: { side: "rightside", alignment: "top" },
5979
+ rightside_bottom: { side: "rightside", alignment: "bottom" },
5980
+ topside_left: { side: "topside", alignment: "left" },
5981
+ topside_right: { side: "topside", alignment: "right" },
5982
+ bottomside_left: { side: "bottomside", alignment: "left" },
5983
+ bottomside_right: { side: "bottomside", alignment: "right" }
5984
+ };
5985
+ var PIN1_LOCATIONS = Object.keys(PIN1_LOCATION_PARTS);
5952
5986
 
5953
5987
  // node_modules/@tscircuit/mm/dist/index.js
5954
5988
  var unitToMm = {
@@ -6466,24 +6500,17 @@ var handleSilkscreenArc = (arc, index) => {
6466
6500
  stroke_width: mil10ToMm(arc.width)
6467
6501
  });
6468
6502
  };
6469
- var SILKSCREEN_CIRCLE_SEGMENTS = 24;
6470
6503
  var handleSilkscreenCircle = (circle, index) => {
6471
- const route = Array.from(
6472
- { length: SILKSCREEN_CIRCLE_SEGMENTS + 1 },
6473
- (_, segmentIndex) => {
6474
- const angle = Math.PI * 2 * segmentIndex / SILKSCREEN_CIRCLE_SEGMENTS;
6475
- return {
6476
- x: milx10(circle.center.x + Math.cos(angle) * circle.radius),
6477
- y: milx10(circle.center.y + Math.sin(angle) * circle.radius)
6478
- };
6479
- }
6480
- );
6481
- return pcb_silkscreen_path.parse({
6482
- type: "pcb_silkscreen_path",
6483
- pcb_silkscreen_path_id: `pcb_silkscreen_circle_${index + 1}`,
6504
+ return pcb_silkscreen_circle.parse({
6505
+ type: "pcb_silkscreen_circle",
6506
+ pcb_silkscreen_circle_id: `pcb_silkscreen_circle_${index + 1}`,
6484
6507
  pcb_component_id: "pcb_component_1",
6485
6508
  layer: getSideFromLayer(circle.layer),
6486
- route,
6509
+ center: {
6510
+ x: milx10(circle.center.x),
6511
+ y: milx10(circle.center.y)
6512
+ },
6513
+ radius: milx10(circle.radius),
6487
6514
  stroke_width: mil10ToMm(circle.width)
6488
6515
  });
6489
6516
  };
@@ -6883,7 +6910,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
6883
6910
  );
6884
6911
  }
6885
6912
  const pcbElements = circuitElements.filter(
6886
- (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"
6913
+ (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_circle" || e.type === "pcb_silkscreen_rect" || e.type === "pcb_silkscreen_text"
6887
6914
  );
6888
6915
  if (pcbElements.length > 0) {
6889
6916
  const bounds = findBoundsAndCenter(pcbElements);
@@ -6950,7 +6977,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
6950
6977
  }
6951
6978
  if (shouldRecenter) {
6952
6979
  const elementsForBounds = circuitElements.filter(
6953
- (e) => e.type !== "pcb_component" && e.type !== "cad_component"
6980
+ (e) => e.type !== "pcb_component" && e.type !== "cad_component" && e.type !== "pcb_silkscreen_circle"
6954
6981
  );
6955
6982
  const bounds = findBoundsAndCenter(elementsForBounds);
6956
6983
  if (Number.isFinite(bounds.center.x) && Number.isFinite(bounds.center.y)) {
@@ -8157,6 +8184,7 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
8157
8184
  const smtPads = su(circuitJson).pcb_smtpad.list();
8158
8185
  const vias = su(circuitJson).pcb_via.list();
8159
8186
  const silkscreenPaths = su(circuitJson).pcb_silkscreen_path.list();
8187
+ const silkscreenCircles = su(circuitJson).pcb_silkscreen_circle.list();
8160
8188
  const silkscreenRects = su(circuitJson).pcb_silkscreen_rect.list();
8161
8189
  const silkscreenTexts = su(circuitJson).pcb_silkscreen_text.list();
8162
8190
  const fabricationNotePaths = su(circuitJson).pcb_fabrication_note_path.list();
@@ -8227,6 +8255,11 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
8227
8255
  `<silkscreenpath route={${JSON.stringify(silkscreenPath.route)}} />`
8228
8256
  );
8229
8257
  }
8258
+ for (const silkscreenCircle of silkscreenCircles) {
8259
+ elementStrings.push(
8260
+ `<silkscreencircle pcbX="${mmStr(silkscreenCircle.center.x)}" pcbY="${mmStr(silkscreenCircle.center.y)}" radius="${mmStr(silkscreenCircle.radius)}" />`
8261
+ );
8262
+ }
8230
8263
  for (const silkscreenRect of silkscreenRects) {
8231
8264
  const rotation2 = silkscreenRect.ccw_rotation || 0;
8232
8265
  const rotationAttr = rotation2 ? ` pcbRotation="${rotation2}deg"` : "";