easyeda 0.0.257 → 0.0.258

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
@@ -6652,7 +6652,13 @@ var getRotatedOffsetMm = ({
6652
6652
  };
6653
6653
  var getCadModelOffsetMm = (easyEdaJson) => {
6654
6654
  const svgNode = getCadSvgNode(easyEdaJson);
6655
- const bounds = easyEdaJson._objMetadata?.bounds;
6655
+ return getCadModelOffsetMmFromBounds(
6656
+ easyEdaJson,
6657
+ easyEdaJson._objMetadata?.bounds
6658
+ );
6659
+ };
6660
+ var getCadModelOffsetMmFromBounds = (easyEdaJson, bounds) => {
6661
+ const svgNode = getCadSvgNode(easyEdaJson);
6656
6662
  if (!svgNode || !bounds) return null;
6657
6663
  const [originX, originY] = String(svgNode.svgData.attrs?.c_origin ?? "0,0").split(",").map((value) => Number(value.trim()));
6658
6664
  if (!Number.isFinite(originX) || !Number.isFinite(originY)) return null;
@@ -6731,9 +6737,8 @@ var getPositionZMmFromBounds = (bounds, svgNodeZOffsetMm) => {
6731
6737
  var getEasyEdaCadModelPlacement = async (easyEdaJson, { fetch: fetch2 = globalThis.fetch } = {}) => {
6732
6738
  const modelUuid = getCadSvgNodeModelUuid(easyEdaJson);
6733
6739
  const partNumber = easyEdaJson.lcsc.number;
6734
- const derivedOffsetMm = getCadModelOffsetMm(easyEdaJson);
6735
6740
  const svgNodeZOffsetMm = getCadSvgNodeZOffsetMm(easyEdaJson);
6736
- if (!modelUuid || !partNumber || svgNodeZOffsetMm == null || !derivedOffsetMm || !fetch2) {
6741
+ if (!modelUuid || !partNumber || svgNodeZOffsetMm == null || !fetch2) {
6737
6742
  return null;
6738
6743
  }
6739
6744
  const modelObjUrl = getModelObjCdnUrl({
@@ -6746,6 +6751,8 @@ var getEasyEdaCadModelPlacement = async (easyEdaJson, { fetch: fetch2 = globalTh
6746
6751
  });
6747
6752
  const metadataBounds = easyEdaJson._objMetadata?.bounds;
6748
6753
  if (metadataBounds) {
6754
+ const derivedOffsetMm = getCadModelOffsetMm(easyEdaJson);
6755
+ if (!derivedOffsetMm) return null;
6749
6756
  return {
6750
6757
  modelObjUrl,
6751
6758
  positionXMm: derivedOffsetMm.x,
@@ -6765,6 +6772,8 @@ var getEasyEdaCadModelPlacement = async (easyEdaJson, { fetch: fetch2 = globalTh
6765
6772
  const objText = await response.text();
6766
6773
  const bounds = parseObjBounds2(objText);
6767
6774
  if (!bounds) return null;
6775
+ const derivedOffsetMm = getCadModelOffsetMmFromBounds(easyEdaJson, bounds);
6776
+ if (!derivedOffsetMm) return null;
6768
6777
  return {
6769
6778
  modelObjUrl,
6770
6779
  positionXMm: derivedOffsetMm.x,