@ecency/render-helper 2.5.33 → 2.5.35

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.
@@ -75,6 +75,17 @@ declare function markdown2Html(obj: Entry | string, forApp?: boolean, _webp?: bo
75
75
  * URL). Returns null when the fast path finds no unambiguous image (the caller
76
76
  * can fall back to catchPostImage).
77
77
  */
78
+ /**
79
+ * The RAW (pre-proxify) URL of the image a CARD renders.
80
+ *
81
+ * Mirrors catchPostImage's precedence — `json_metadata.thumbnails` first, then
82
+ * `json_metadata.image`, then the first body image — which is NOT the order
83
+ * getEntryImageRawUrl uses: that one answers a body/LCP-preload question and
84
+ * deliberately skips thumbnails. Use this when a caller has to reason about the
85
+ * file the card will actually request (its extension, say), or it can end up
86
+ * inspecting one asset while the card renders another.
87
+ */
88
+ declare function getEntryCardImageRawUrl(obj: Entry | string): string | null;
78
89
  declare function getEntryImageRawUrl(obj: Entry | string): string | null;
79
90
  interface CatchPostImageOptions {
80
91
  /**
@@ -200,4 +211,4 @@ declare function isValidPermlink(permlink: string): boolean;
200
211
  */
201
212
  declare function simpleMarkdownToHTML(input: string): string;
202
213
 
203
- export { type Entry, IMAGE_SIZES, type ProxifyOptions, type RenderOptions, SECTION_LIST, type SeoContext, buildPictureSources, buildSrcSet, buildSrcSetForFormat, catchPostImage, getEntryImageRawUrl, isAllowedEmbedSrc, isLegacySizedProxyUrl, isPictureEligibleRawUrl, isValidPermlink, getPostBodySummary as postBodySummary, proxifyImageSrc, markdown2Html as renderPostBody, setCacheSize, setProxyBase, setSlowRenderThresholdMs, simpleMarkdownToHTML };
214
+ export { type Entry, IMAGE_SIZES, type ProxifyOptions, type RenderOptions, SECTION_LIST, type SeoContext, buildPictureSources, buildSrcSet, buildSrcSetForFormat, catchPostImage, getEntryCardImageRawUrl, getEntryImageRawUrl, isAllowedEmbedSrc, isLegacySizedProxyUrl, isPictureEligibleRawUrl, isValidPermlink, getPostBodySummary as postBodySummary, proxifyImageSrc, markdown2Html as renderPostBody, setCacheSize, setProxyBase, setSlowRenderThresholdMs, simpleMarkdownToHTML };
@@ -749,7 +749,6 @@ var isSafeNavValue = (value) => {
749
749
  const isRelative = /^(\/\/|\/[^/]?|#|\?|[a-z0-9._\-]+(\/|$))/i.test(trimmed);
750
750
  return isSafeScheme || isRelative;
751
751
  };
752
- var decodeEntities2 = (input) => input.replace(/&#(\d+);?/g, (_, dec) => String.fromCodePoint(Number(dec))).replace(/&#x([0-9a-f]+);?/gi, (_, hex) => String.fromCodePoint(parseInt(hex, 16)));
753
752
  var isProxyPSrcset = (srcset) => {
754
753
  const base = trimTrailingSlash(getProxyBase());
755
754
  const candidates = srcset.split(",").map((c) => c.trim().split(/\s+/)[0]).filter(Boolean);
@@ -763,7 +762,7 @@ function sanitizeHtml(html) {
763
762
  css: false,
764
763
  // block style attrs entirely for safety
765
764
  onTagAttr: (tag, name, value) => {
766
- const decoded = decodeEntities2(value.trim());
765
+ const decoded = decodeEntities(value.trim());
767
766
  const decodedLower = decoded.toLowerCase();
768
767
  if (name.startsWith("on")) return "";
769
768
  if (tag === "img" && name === "src" && !/^https?:\/\//.test(decodedLower)) return "";
@@ -2786,6 +2785,26 @@ function getImage(entry, width = 0, height = 0, format = "match", fastMode = fal
2786
2785
  }
2787
2786
  return null;
2788
2787
  }
2788
+ function getEntryCardImageRawUrl(obj) {
2789
+ if (typeof obj === "string") {
2790
+ return getEntryImageRawUrl(obj);
2791
+ }
2792
+ let meta;
2793
+ if (typeof obj.json_metadata === "object") {
2794
+ meta = obj.json_metadata;
2795
+ } else {
2796
+ try {
2797
+ meta = JSON.parse(obj.json_metadata);
2798
+ } catch (e) {
2799
+ meta = null;
2800
+ }
2801
+ }
2802
+ const thumbnail = firstMetaUrl(meta?.thumbnails);
2803
+ if (thumbnail) {
2804
+ return decodeImageSrc(thumbnail);
2805
+ }
2806
+ return getEntryImageRawUrl(obj);
2807
+ }
2789
2808
  function getEntryImageRawUrl(obj) {
2790
2809
  if (typeof obj === "string") {
2791
2810
  const src = findFirstImageUrl(obj, true);
@@ -2935,6 +2954,6 @@ function getPostBodySummary(obj, length, platform) {
2935
2954
  return res;
2936
2955
  }
2937
2956
 
2938
- 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 };
2957
+ 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 };
2939
2958
  //# sourceMappingURL=index.js.map
2940
2959
  //# sourceMappingURL=index.js.map