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/main.cjs CHANGED
@@ -997,7 +997,7 @@ var import_promises = __toESM(require("fs/promises"), 1);
997
997
  var package_default = {
998
998
  name: "easyeda",
999
999
  type: "module",
1000
- version: "0.0.256",
1000
+ version: "0.0.258",
1001
1001
  files: [
1002
1002
  "dist"
1003
1003
  ],
@@ -1038,12 +1038,12 @@ var package_default = {
1038
1038
  "@tscircuit/mm": "^0.0.9",
1039
1039
  "@types/bun": "latest",
1040
1040
  "bun-match-svg": "^0.0.13",
1041
- "circuit-json-to-gltf": "^0.0.87",
1041
+ "circuit-json-to-gltf": "^0.0.93",
1042
1042
  "circuit-to-svg": "^0.0.340",
1043
1043
  "looks-same": "^9.0.1",
1044
1044
  poppygl: "^0.0.19",
1045
1045
  "transformation-matrix": "^2.16.1",
1046
- tscircuit: "^0.0.1598",
1046
+ tscircuit: "^0.0.1599",
1047
1047
  tsup: "^8.5.0"
1048
1048
  },
1049
1049
  peerDependencies: {
@@ -6416,15 +6416,12 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
6416
6416
  const innerWidth = largestOuterDimensionName === "width" ? largestInnerDimension : smallestInnerDimension;
6417
6417
  const innerHeight = largestOuterDimensionName === "height" ? largestInnerDimension : smallestInnerDimension;
6418
6418
  additionalPlatedHoleProps = {
6419
- shape: "pill_hole_with_rect_pad",
6420
- hole_shape: "pill",
6421
- pad_shape: "rect",
6419
+ shape: "pill",
6422
6420
  hole_width: innerWidth,
6423
6421
  hole_height: innerHeight,
6424
- rect_pad_width: mil2mm(pad.width),
6425
- rect_pad_height: mil2mm(pad.height),
6426
- hole_offset_x: 0,
6427
- hole_offset_y: 0
6422
+ outer_width: mil2mm(pad.width),
6423
+ outer_height: mil2mm(pad.height),
6424
+ ccw_rotation: pad.rotation || 0
6428
6425
  };
6429
6426
  } else if (pad.shape === "RECT") {
6430
6427
  const padWidth = mil2mm(pad.width);
@@ -7555,7 +7552,13 @@ var getRotatedOffsetMm = ({
7555
7552
  };
7556
7553
  var getCadModelOffsetMm = (easyEdaJson) => {
7557
7554
  const svgNode = getCadSvgNode(easyEdaJson);
7558
- const bounds = easyEdaJson._objMetadata?.bounds;
7555
+ return getCadModelOffsetMmFromBounds(
7556
+ easyEdaJson,
7557
+ easyEdaJson._objMetadata?.bounds
7558
+ );
7559
+ };
7560
+ var getCadModelOffsetMmFromBounds = (easyEdaJson, bounds) => {
7561
+ const svgNode = getCadSvgNode(easyEdaJson);
7559
7562
  if (!svgNode || !bounds) return null;
7560
7563
  const [originX, originY] = String(svgNode.svgData.attrs?.c_origin ?? "0,0").split(",").map((value) => Number(value.trim()));
7561
7564
  if (!Number.isFinite(originX) || !Number.isFinite(originY)) return null;
@@ -7634,9 +7637,8 @@ var getPositionZMmFromBounds = (bounds, svgNodeZOffsetMm) => {
7634
7637
  var getEasyEdaCadModelPlacement = async (easyEdaJson, { fetch: fetch2 = globalThis.fetch } = {}) => {
7635
7638
  const modelUuid = getCadSvgNodeModelUuid(easyEdaJson);
7636
7639
  const partNumber = easyEdaJson.lcsc.number;
7637
- const derivedOffsetMm = getCadModelOffsetMm(easyEdaJson);
7638
7640
  const svgNodeZOffsetMm = getCadSvgNodeZOffsetMm(easyEdaJson);
7639
- if (!modelUuid || !partNumber || svgNodeZOffsetMm == null || !derivedOffsetMm || !fetch2) {
7641
+ if (!modelUuid || !partNumber || svgNodeZOffsetMm == null || !fetch2) {
7640
7642
  return null;
7641
7643
  }
7642
7644
  const modelObjUrl = getModelObjCdnUrl({
@@ -7649,6 +7651,8 @@ var getEasyEdaCadModelPlacement = async (easyEdaJson, { fetch: fetch2 = globalTh
7649
7651
  });
7650
7652
  const metadataBounds = easyEdaJson._objMetadata?.bounds;
7651
7653
  if (metadataBounds) {
7654
+ const derivedOffsetMm = getCadModelOffsetMm(easyEdaJson);
7655
+ if (!derivedOffsetMm) return null;
7652
7656
  return {
7653
7657
  modelObjUrl,
7654
7658
  positionXMm: derivedOffsetMm.x,
@@ -7668,6 +7672,8 @@ var getEasyEdaCadModelPlacement = async (easyEdaJson, { fetch: fetch2 = globalTh
7668
7672
  const objText = await response.text();
7669
7673
  const bounds = parseObjBounds2(objText);
7670
7674
  if (!bounds) return null;
7675
+ const derivedOffsetMm = getCadModelOffsetMmFromBounds(easyEdaJson, bounds);
7676
+ if (!derivedOffsetMm) return null;
7671
7677
  return {
7672
7678
  modelObjUrl,
7673
7679
  positionXMm: derivedOffsetMm.x,
@@ -7709,7 +7715,13 @@ var generateFootprintTsx = (circuitJson) => {
7709
7715
  }
7710
7716
  }
7711
7717
  for (const platedHole of platedHoles) {
7712
- if (platedHole.shape === "pill_hole_with_rect_pad") {
7718
+ if (platedHole.shape === "pill" || platedHole.shape === "oval") {
7719
+ const cccwRotationDegree = platedHole.ccw_rotation || 0;
7720
+ const rotation2 = cccwRotationDegree ? ` pcbRotation="${cccwRotationDegree}deg"` : "";
7721
+ elementStrings.push(
7722
+ `<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}" />`
7723
+ );
7724
+ } else if (platedHole.shape === "pill_hole_with_rect_pad") {
7713
7725
  elementStrings.push(
7714
7726
  `<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" />`
7715
7727
  );