@ecency/render-helper 2.5.34 → 2.5.36

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.
@@ -10255,10 +10255,6 @@ function markdown2Html(obj, forApp = true, _webp = false, parentDomain = "ecency
10255
10255
  }
10256
10256
 
10257
10257
  // src/catch-post-image.ts
10258
- var gifLinkRegex = /\.(gif)$/i;
10259
- function isGifLink(link) {
10260
- return gifLinkRegex.test(link);
10261
- }
10262
10258
  var BACKTICK_FENCE_RE = /```[\s\S]*?```/g;
10263
10259
  var TILDE_FENCE_RE = /~~~[\s\S]*?~~~/g;
10264
10260
  var INLINE_CODE_RE = /`[^`\n]*`/g;
@@ -10763,11 +10759,7 @@ function firstMetaUrl(value) {
10763
10759
  return void 0;
10764
10760
  }
10765
10761
  function proxifyFound(src, width, height, format) {
10766
- const decoded = decodeEntities(src);
10767
- if (isGifLink(decoded)) {
10768
- return proxifyImageSrc(decoded, 0, 0, format);
10769
- }
10770
- return proxifyImageSrc(decoded, width, height, format);
10762
+ return proxifyImageSrc(decodeEntities(src), width, height, format);
10771
10763
  }
10772
10764
  function getImage(entry, width = 0, height = 0, format = "match", fastMode = false) {
10773
10765
  let meta;
@@ -10782,29 +10774,17 @@ function getImage(entry, width = 0, height = 0, format = "match", fastMode = fal
10782
10774
  }
10783
10775
  const thumbnail = firstMetaUrl(meta?.thumbnails);
10784
10776
  if (thumbnail) {
10785
- const decodedThumbnail = decodeEntities(thumbnail);
10786
- const proxied = isGifLink(decodedThumbnail) ? proxifyImageSrc(decodedThumbnail, 0, 0, format) : proxifyImageSrc(decodedThumbnail, width, height, format);
10777
+ const proxied = proxifyImageSrc(decodeEntities(thumbnail), width, height, format);
10787
10778
  if (proxied) {
10788
10779
  return proxied;
10789
10780
  }
10790
10781
  }
10791
10782
  if (meta && typeof meta.image === "string" && meta.image.length > 0) {
10792
- const decodedImage = decodeEntities(meta.image);
10793
- if (isGifLink(decodedImage)) {
10794
- return proxifyImageSrc(decodedImage, 0, 0, format);
10795
- }
10796
- return proxifyImageSrc(decodedImage, width, height, format);
10783
+ return proxifyImageSrc(decodeEntities(meta.image), width, height, format);
10797
10784
  }
10798
10785
  if (meta && meta.image && !!meta.image.length && meta.image[0]) {
10799
10786
  if (typeof meta.image[0] === "string") {
10800
- const decodedImage = decodeEntities(meta.image[0]);
10801
- if (isGifLink(decodedImage)) {
10802
- return proxifyImageSrc(decodedImage, 0, 0, format);
10803
- }
10804
- return proxifyImageSrc(decodedImage, width, height, format);
10805
- }
10806
- if (isGifLink(meta.image[0])) {
10807
- return proxifyImageSrc(meta.image[0], 0, 0, format);
10787
+ return proxifyImageSrc(decodeEntities(meta.image[0]), width, height, format);
10808
10788
  }
10809
10789
  return proxifyImageSrc(meta.image[0], width, height, format);
10810
10790
  }
@@ -10830,6 +10810,26 @@ function getImage(entry, width = 0, height = 0, format = "match", fastMode = fal
10830
10810
  }
10831
10811
  return null;
10832
10812
  }
10813
+ function getEntryCardImageRawUrl(obj) {
10814
+ if (typeof obj === "string") {
10815
+ return getEntryImageRawUrl(obj);
10816
+ }
10817
+ let meta;
10818
+ if (typeof obj.json_metadata === "object") {
10819
+ meta = obj.json_metadata;
10820
+ } else {
10821
+ try {
10822
+ meta = JSON.parse(obj.json_metadata);
10823
+ } catch (e) {
10824
+ meta = null;
10825
+ }
10826
+ }
10827
+ const thumbnail = firstMetaUrl(meta?.thumbnails);
10828
+ if (thumbnail) {
10829
+ return decodeImageSrc(thumbnail);
10830
+ }
10831
+ return getEntryImageRawUrl(obj);
10832
+ }
10833
10833
  function getEntryImageRawUrl(obj) {
10834
10834
  if (typeof obj === "string") {
10835
10835
  const src = findFirstImageUrl(obj, true);
@@ -10981,6 +10981,6 @@ function getPostBodySummary(obj, length, platform) {
10981
10981
  return res;
10982
10982
  }
10983
10983
 
10984
- export { IMAGE_SIZES, SECTION_LIST, buildPictureSources, buildSrcSet, buildSrcSetForFormat, catchPostImage, getEntryImageRawUrl, isAllowedEmbedSrc, isLegacySizedProxyUrl, isPictureEligibleRawUrl, isValidPermlink, getPostBodySummary as postBodySummary, proxifyImageSrc, markdown2Html as renderPostBody, setCacheSize, setProxyBase, setSlowRenderThresholdMs, simpleMarkdownToHTML };
10984
+ export { IMAGE_SIZES, SECTION_LIST, buildPictureSources, buildSrcSet, buildSrcSetForFormat, catchPostImage, getEntryCardImageRawUrl, getEntryImageRawUrl, isAllowedEmbedSrc, isLegacySizedProxyUrl, isPictureEligibleRawUrl, isValidPermlink, getPostBodySummary as postBodySummary, proxifyImageSrc, markdown2Html as renderPostBody, setCacheSize, setProxyBase, setSlowRenderThresholdMs, simpleMarkdownToHTML };
10985
10985
  //# sourceMappingURL=index.mjs.map
10986
10986
  //# sourceMappingURL=index.mjs.map