easyeda 0.0.257 → 0.0.259

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
@@ -5368,15 +5368,12 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
5368
5368
  const innerWidth = largestOuterDimensionName === "width" ? largestInnerDimension : smallestInnerDimension;
5369
5369
  const innerHeight = largestOuterDimensionName === "height" ? largestInnerDimension : smallestInnerDimension;
5370
5370
  additionalPlatedHoleProps = {
5371
- shape: "pill_hole_with_rect_pad",
5372
- hole_shape: "pill",
5373
- pad_shape: "rect",
5371
+ shape: "pill",
5374
5372
  hole_width: innerWidth,
5375
5373
  hole_height: innerHeight,
5376
- rect_pad_width: mil2mm(pad.width),
5377
- rect_pad_height: mil2mm(pad.height),
5378
- hole_offset_x: 0,
5379
- hole_offset_y: 0
5374
+ outer_width: mil2mm(pad.width),
5375
+ outer_height: mil2mm(pad.height),
5376
+ ccw_rotation: pad.rotation || 0
5380
5377
  };
5381
5378
  } else if (pad.shape === "RECT") {
5382
5379
  const padWidth = mil2mm(pad.width);
@@ -6652,7 +6649,13 @@ var getRotatedOffsetMm = ({
6652
6649
  };
6653
6650
  var getCadModelOffsetMm = (easyEdaJson) => {
6654
6651
  const svgNode = getCadSvgNode(easyEdaJson);
6655
- const bounds = easyEdaJson._objMetadata?.bounds;
6652
+ return getCadModelOffsetMmFromBounds(
6653
+ easyEdaJson,
6654
+ easyEdaJson._objMetadata?.bounds
6655
+ );
6656
+ };
6657
+ var getCadModelOffsetMmFromBounds = (easyEdaJson, bounds) => {
6658
+ const svgNode = getCadSvgNode(easyEdaJson);
6656
6659
  if (!svgNode || !bounds) return null;
6657
6660
  const [originX, originY] = String(svgNode.svgData.attrs?.c_origin ?? "0,0").split(",").map((value) => Number(value.trim()));
6658
6661
  if (!Number.isFinite(originX) || !Number.isFinite(originY)) return null;
@@ -6731,9 +6734,8 @@ var getPositionZMmFromBounds = (bounds, svgNodeZOffsetMm) => {
6731
6734
  var getEasyEdaCadModelPlacement = async (easyEdaJson, { fetch: fetch2 = globalThis.fetch } = {}) => {
6732
6735
  const modelUuid = getCadSvgNodeModelUuid(easyEdaJson);
6733
6736
  const partNumber = easyEdaJson.lcsc.number;
6734
- const derivedOffsetMm = getCadModelOffsetMm(easyEdaJson);
6735
6737
  const svgNodeZOffsetMm = getCadSvgNodeZOffsetMm(easyEdaJson);
6736
- if (!modelUuid || !partNumber || svgNodeZOffsetMm == null || !derivedOffsetMm || !fetch2) {
6738
+ if (!modelUuid || !partNumber || svgNodeZOffsetMm == null || !fetch2) {
6737
6739
  return null;
6738
6740
  }
6739
6741
  const modelObjUrl = getModelObjCdnUrl({
@@ -6746,6 +6748,8 @@ var getEasyEdaCadModelPlacement = async (easyEdaJson, { fetch: fetch2 = globalTh
6746
6748
  });
6747
6749
  const metadataBounds = easyEdaJson._objMetadata?.bounds;
6748
6750
  if (metadataBounds) {
6751
+ const derivedOffsetMm = getCadModelOffsetMm(easyEdaJson);
6752
+ if (!derivedOffsetMm) return null;
6749
6753
  return {
6750
6754
  modelObjUrl,
6751
6755
  positionXMm: derivedOffsetMm.x,
@@ -6765,6 +6769,8 @@ var getEasyEdaCadModelPlacement = async (easyEdaJson, { fetch: fetch2 = globalTh
6765
6769
  const objText = await response.text();
6766
6770
  const bounds = parseObjBounds2(objText);
6767
6771
  if (!bounds) return null;
6772
+ const derivedOffsetMm = getCadModelOffsetMmFromBounds(easyEdaJson, bounds);
6773
+ if (!derivedOffsetMm) return null;
6768
6774
  return {
6769
6775
  modelObjUrl,
6770
6776
  positionXMm: derivedOffsetMm.x,
@@ -6806,7 +6812,13 @@ var generateFootprintTsx = (circuitJson) => {
6806
6812
  }
6807
6813
  }
6808
6814
  for (const platedHole of platedHoles) {
6809
- if (platedHole.shape === "pill_hole_with_rect_pad") {
6815
+ if (platedHole.shape === "pill" || platedHole.shape === "oval") {
6816
+ const cccwRotationDegree = platedHole.ccw_rotation || 0;
6817
+ const rotation2 = cccwRotationDegree ? ` pcbRotation="${cccwRotationDegree}deg"` : "";
6818
+ elementStrings.push(
6819
+ `<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${mmStr(platedHole.x)}" pcbY="${mmStr(platedHole.y)}" holeWidth="${mmStr(platedHole.hole_width)}" holeHeight="${mmStr(platedHole.hole_height)}" outerWidth="${mmStr(platedHole.outer_width)}" outerHeight="${mmStr(platedHole.outer_height)}"${rotation2} shape="${platedHole.shape}" />`
6820
+ );
6821
+ } else if (platedHole.shape === "pill_hole_with_rect_pad") {
6810
6822
  elementStrings.push(
6811
6823
  `<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${mmStr(platedHole.x)}" pcbY="${mmStr(platedHole.y)}" holeWidth="${mmStr(platedHole.hole_width)}" holeHeight="${mmStr(platedHole.hole_height)}" outerWidth="${mmStr(platedHole.rect_pad_width)}" outerHeight="${mmStr(platedHole.rect_pad_height)}" shape="pill" />`
6812
6824
  );