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/main.cjs CHANGED
@@ -1026,7 +1026,7 @@ var import_promises = __toESM(require("fs/promises"), 1);
1026
1026
  var package_default = {
1027
1027
  name: "easyeda",
1028
1028
  type: "module",
1029
- version: "0.0.325",
1029
+ version: "0.0.326",
1030
1030
  files: [
1031
1031
  "dist"
1032
1032
  ],
@@ -1039,7 +1039,7 @@ var package_default = {
1039
1039
  devDependencies: {
1040
1040
  "@biomejs/biome": "^1.9.4",
1041
1041
  "@tscircuit/alphabet": "^0.0.22",
1042
- "@tscircuit/circuit-json-util": "^0.0.101",
1042
+ "@tscircuit/circuit-json-util": "^0.0.111",
1043
1043
  "@tscircuit/math-utils": "^0.0.36",
1044
1044
  "@tscircuit/mm": "^0.0.9",
1045
1045
  "@tscircuit/props": "^0.0.598",
@@ -6686,9 +6686,9 @@ var insertionDirectionToVec = (direction) => {
6686
6686
  return { x: -1, y: 0 };
6687
6687
  case "from_right":
6688
6688
  return { x: 1, y: 0 };
6689
- case "from_front":
6689
+ case "from_top":
6690
6690
  return { x: 0, y: 1 };
6691
- case "from_back":
6691
+ case "from_bottom":
6692
6692
  return { x: 0, y: -1 };
6693
6693
  }
6694
6694
  };
@@ -6698,11 +6698,15 @@ var vecToInsertionDirection = ({
6698
6698
  }) => {
6699
6699
  if (x > 0) return "from_right";
6700
6700
  if (x < 0) return "from_left";
6701
- if (y > 0) return "from_front";
6702
- return "from_back";
6701
+ if (y > 0) return "from_top";
6702
+ return "from_bottom";
6703
6703
  };
6704
6704
  var transformInsertionDirection = (direction, opts) => {
6705
- if (!direction || direction === "from_above") return direction;
6705
+ if (!direction) return direction;
6706
+ if (direction === "from_above" || direction === "from_below") {
6707
+ if (!opts.isFlipped) return direction;
6708
+ return direction === "from_above" ? "from_below" : "from_above";
6709
+ }
6706
6710
  let { x, y } = insertionDirectionToVec(direction);
6707
6711
  let quarterTurns = Math.round(opts.rotationDegrees / 90);
6708
6712
  while (quarterTurns > 0) {
@@ -6725,7 +6729,7 @@ var transformPCBElement = (elm, matrix) => {
6725
6729
  const flipPadWidthHeight = Math.abs(getQuarterTurns(tsr.rotation.angle)) % 2 === 1;
6726
6730
  const rotationDegrees = tsr.rotation.angle / Math.PI * 180;
6727
6731
  const isFlipped = tsr.scale.sy < 0;
6728
- if (elm.type === "pcb_plated_hole" || elm.type === "pcb_hole" || elm.type === "pcb_via" || elm.type === "pcb_smtpad" || elm.type === "pcb_port") {
6732
+ 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") {
6729
6733
  const { x, y } = applyToPoint(matrix, {
6730
6734
  x: Number(elm.x),
6731
6735
  y: Number(elm.y)
@@ -6745,10 +6749,14 @@ var transformPCBElement = (elm, matrix) => {
6745
6749
  elm.center = applyToPoint(matrix, elm.center);
6746
6750
  } else if (elm.type === "pcb_silkscreen_text" || elm.type === "pcb_fabrication_note_text" || elm.type === "pcb_note_text") {
6747
6751
  elm.anchor_position = applyToPoint(matrix, elm.anchor_position);
6752
+ } else if (elm.type === "pcb_copper_text") {
6753
+ if (elm.anchor_position) {
6754
+ elm.anchor_position = applyToPoint(matrix, elm.anchor_position);
6755
+ }
6748
6756
  } else if (elm.type === "pcb_courtyard_rect") {
6749
6757
  elm.center = applyToPoint(matrix, elm.center);
6750
6758
  elm.ccw_rotation = ((elm.ccw_rotation ?? 0) + rotationDegrees) % 360;
6751
- } else if (elm.type === "pcb_silkscreen_circle" || elm.type === "pcb_silkscreen_rect" || elm.type === "pcb_note_rect" || elm.type === "pcb_courtyard_circle") {
6759
+ } 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") {
6752
6760
  elm.center = applyToPoint(matrix, elm.center);
6753
6761
  } else if (elm.type === "pcb_component") {
6754
6762
  elm.center = applyToPoint(matrix, elm.center);
@@ -6785,7 +6793,19 @@ var transformPCBElement = (elm, matrix) => {
6785
6793
  p.y = tp.y;
6786
6794
  return p;
6787
6795
  });
6788
- } else if (elm.type === "pcb_silkscreen_path" || elm.type === "pcb_trace" || elm.type === "pcb_fabrication_note_path" || elm.type === "pcb_note_path") {
6796
+ } else if (elm.type === "pcb_trace") {
6797
+ elm.route = elm.route.map((rp) => {
6798
+ if (!("x" in rp)) {
6799
+ rp.start = applyToPoint(matrix, rp.start);
6800
+ rp.end = applyToPoint(matrix, rp.end);
6801
+ return rp;
6802
+ }
6803
+ const tp = applyToPoint(matrix, rp);
6804
+ rp.x = tp.x;
6805
+ rp.y = tp.y;
6806
+ return rp;
6807
+ });
6808
+ } else if (elm.type === "pcb_silkscreen_path" || elm.type === "pcb_trace_hint" || elm.type === "pcb_fabrication_note_path" || elm.type === "pcb_note_path") {
6789
6809
  elm.route = elm.route.map((rp) => {
6790
6810
  const tp = applyToPoint(matrix, rp);
6791
6811
  rp.x = tp.x;
@@ -6818,7 +6838,7 @@ var transformPCBElements = (elms, matrix) => {
6818
6838
  let transformedElms = elms.map((elm) => transformPCBElement(elm, matrix));
6819
6839
  if (flipPadWidthHeight) {
6820
6840
  transformedElms = transformedElms.map((elm) => {
6821
- if (elm.type === "pcb_smtpad" && (elm.shape === "rect" || elm.shape === "pill")) {
6841
+ if ((elm.type === "pcb_smtpad" || elm.type === "pcb_solder_paste") && (elm.shape === "rect" || elm.shape === "pill")) {
6822
6842
  ;
6823
6843
  [elm.width, elm.height] = [elm.height, elm.width];
6824
6844
  }
@@ -6973,7 +6993,10 @@ var getDebugLayoutObject = (lo) => {
6973
6993
  const content = lo;
6974
6994
  if (x === void 0 || y === void 0) return null;
6975
6995
  if (width === void 0) {
6976
- if ("outer_diameter" in lo) {
6996
+ if ("radius" in lo) {
6997
+ width = lo.radius * 2;
6998
+ height = lo.radius * 2;
6999
+ } else if ("outer_diameter" in lo) {
6977
7000
  width = lo.outer_diameter;
6978
7001
  height = lo.outer_diameter;
6979
7002
  } else if ("rect_pad_width" in lo && "rect_pad_height" in lo) {
@@ -7028,6 +7051,17 @@ var findBoundsAndCenter = (elements) => {
7028
7051
  const center = { x: minX + width / 2, y: minY + height / 2 };
7029
7052
  return { center, width, height };
7030
7053
  };
7054
+ var PIN1_LOCATION_PARTS = {
7055
+ leftside_top: { side: "leftside", alignment: "top" },
7056
+ leftside_bottom: { side: "leftside", alignment: "bottom" },
7057
+ rightside_top: { side: "rightside", alignment: "top" },
7058
+ rightside_bottom: { side: "rightside", alignment: "bottom" },
7059
+ topside_left: { side: "topside", alignment: "left" },
7060
+ topside_right: { side: "topside", alignment: "right" },
7061
+ bottomside_left: { side: "bottomside", alignment: "left" },
7062
+ bottomside_right: { side: "bottomside", alignment: "right" }
7063
+ };
7064
+ var PIN1_LOCATIONS = Object.keys(PIN1_LOCATION_PARTS);
7031
7065
 
7032
7066
  // node_modules/@tscircuit/mm/dist/index.js
7033
7067
  var unitToMm = {
@@ -7545,24 +7579,17 @@ var handleSilkscreenArc = (arc, index) => {
7545
7579
  stroke_width: mil10ToMm(arc.width)
7546
7580
  });
7547
7581
  };
7548
- var SILKSCREEN_CIRCLE_SEGMENTS = 24;
7549
7582
  var handleSilkscreenCircle = (circle, index) => {
7550
- const route = Array.from(
7551
- { length: SILKSCREEN_CIRCLE_SEGMENTS + 1 },
7552
- (_, segmentIndex) => {
7553
- const angle = Math.PI * 2 * segmentIndex / SILKSCREEN_CIRCLE_SEGMENTS;
7554
- return {
7555
- x: milx10(circle.center.x + Math.cos(angle) * circle.radius),
7556
- y: milx10(circle.center.y + Math.sin(angle) * circle.radius)
7557
- };
7558
- }
7559
- );
7560
- return pcb_silkscreen_path.parse({
7561
- type: "pcb_silkscreen_path",
7562
- pcb_silkscreen_path_id: `pcb_silkscreen_circle_${index + 1}`,
7583
+ return pcb_silkscreen_circle.parse({
7584
+ type: "pcb_silkscreen_circle",
7585
+ pcb_silkscreen_circle_id: `pcb_silkscreen_circle_${index + 1}`,
7563
7586
  pcb_component_id: "pcb_component_1",
7564
7587
  layer: getSideFromLayer(circle.layer),
7565
- route,
7588
+ center: {
7589
+ x: milx10(circle.center.x),
7590
+ y: milx10(circle.center.y)
7591
+ },
7592
+ radius: milx10(circle.radius),
7566
7593
  stroke_width: mil10ToMm(circle.width)
7567
7594
  });
7568
7595
  };
@@ -7962,7 +7989,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
7962
7989
  );
7963
7990
  }
7964
7991
  const pcbElements = circuitElements.filter(
7965
- (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"
7992
+ (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"
7966
7993
  );
7967
7994
  if (pcbElements.length > 0) {
7968
7995
  const bounds = findBoundsAndCenter(pcbElements);
@@ -8029,7 +8056,7 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
8029
8056
  }
8030
8057
  if (shouldRecenter) {
8031
8058
  const elementsForBounds = circuitElements.filter(
8032
- (e) => e.type !== "pcb_component" && e.type !== "cad_component"
8059
+ (e) => e.type !== "pcb_component" && e.type !== "cad_component" && e.type !== "pcb_silkscreen_circle"
8033
8060
  );
8034
8061
  const bounds = findBoundsAndCenter(elementsForBounds);
8035
8062
  if (Number.isFinite(bounds.center.x) && Number.isFinite(bounds.center.y)) {
@@ -9062,6 +9089,7 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
9062
9089
  const smtPads = su(circuitJson).pcb_smtpad.list();
9063
9090
  const vias = su(circuitJson).pcb_via.list();
9064
9091
  const silkscreenPaths = su(circuitJson).pcb_silkscreen_path.list();
9092
+ const silkscreenCircles = su(circuitJson).pcb_silkscreen_circle.list();
9065
9093
  const silkscreenRects = su(circuitJson).pcb_silkscreen_rect.list();
9066
9094
  const silkscreenTexts = su(circuitJson).pcb_silkscreen_text.list();
9067
9095
  const fabricationNotePaths = su(circuitJson).pcb_fabrication_note_path.list();
@@ -9132,6 +9160,11 @@ var generateFootprintTsx = (circuitJson, options = {}) => {
9132
9160
  `<silkscreenpath route={${JSON.stringify(silkscreenPath.route)}} />`
9133
9161
  );
9134
9162
  }
9163
+ for (const silkscreenCircle of silkscreenCircles) {
9164
+ elementStrings.push(
9165
+ `<silkscreencircle pcbX="${mmStr(silkscreenCircle.center.x)}" pcbY="${mmStr(silkscreenCircle.center.y)}" radius="${mmStr(silkscreenCircle.radius)}" />`
9166
+ );
9167
+ }
9135
9168
  for (const silkscreenRect of silkscreenRects) {
9136
9169
  const rotation2 = silkscreenRect.ccw_rotation || 0;
9137
9170
  const rotationAttr = rotation2 ? ` pcbRotation="${rotation2}deg"` : "";