@ecency/render-helper 2.4.35 → 2.5.0
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/browser/index.d.ts +2 -1
- package/dist/browser/index.js +22 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +22 -1
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +22 -2
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -1726,10 +1726,25 @@ function cacheSet(key, value) {
|
|
|
1726
1726
|
}
|
|
1727
1727
|
|
|
1728
1728
|
// src/markdown-2-html.ts
|
|
1729
|
+
var isNodeRuntime = typeof process !== "undefined" && typeof process?.versions?.node === "string";
|
|
1730
|
+
var slowRenderThresholdMs = isNodeRuntime ? 500 : 0;
|
|
1731
|
+
function setSlowRenderThresholdMs(ms) {
|
|
1732
|
+
slowRenderThresholdMs = Math.max(0, ms);
|
|
1733
|
+
}
|
|
1734
|
+
function logIfSlow(durationMs, context) {
|
|
1735
|
+
if (slowRenderThresholdMs > 0 && durationMs >= slowRenderThresholdMs) {
|
|
1736
|
+
console.warn(
|
|
1737
|
+
`[render-helper] slow markdown render: ${durationMs.toFixed(0)}ms ${context}`
|
|
1738
|
+
);
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1729
1741
|
function markdown2Html(obj, forApp = true, _webp = false, parentDomain = "ecency.com", seoContext, renderOptions) {
|
|
1730
1742
|
if (typeof obj === "string") {
|
|
1731
1743
|
const cleanedStr = cleanReply(obj);
|
|
1732
|
-
|
|
1744
|
+
const t02 = performance.now();
|
|
1745
|
+
const res2 = markdownToHTML(cleanedStr, forApp, parentDomain, seoContext, renderOptions);
|
|
1746
|
+
logIfSlow(performance.now() - t02, `body_len=${obj.length}`);
|
|
1747
|
+
return res2;
|
|
1733
1748
|
}
|
|
1734
1749
|
const key = `${makeEntryCacheKey(obj)}-md-${forApp ? "app" : "site"}-${parentDomain}${seoContext ? `-seo${seoContext.authorReputation ?? ""}-${seoContext.postPayout ?? ""}` : ""}${renderOptions?.embedVideosDirectly ? "-embed" : ""}`;
|
|
1735
1750
|
const item = cacheGet(key);
|
|
@@ -1737,7 +1752,12 @@ function markdown2Html(obj, forApp = true, _webp = false, parentDomain = "ecency
|
|
|
1737
1752
|
return item;
|
|
1738
1753
|
}
|
|
1739
1754
|
const cleanBody = cleanReply(obj.body);
|
|
1755
|
+
const t0 = performance.now();
|
|
1740
1756
|
const res = markdownToHTML(cleanBody, forApp, parentDomain, seoContext, renderOptions);
|
|
1757
|
+
logIfSlow(
|
|
1758
|
+
performance.now() - t0,
|
|
1759
|
+
`author=@${obj.author} permlink=${obj.permlink} body_len=${obj.body?.length ?? 0}`
|
|
1760
|
+
);
|
|
1741
1761
|
cacheSet(key, res);
|
|
1742
1762
|
return res;
|
|
1743
1763
|
}
|
|
@@ -1950,6 +1970,6 @@ function getPostBodySummary(obj, length, platform) {
|
|
|
1950
1970
|
return res;
|
|
1951
1971
|
}
|
|
1952
1972
|
|
|
1953
|
-
export { SECTION_LIST, buildSrcSet, catchPostImage, isValidPermlink, getPostBodySummary as postBodySummary, proxifyImageSrc, markdown2Html as renderPostBody, setCacheSize, setProxyBase, simpleMarkdownToHTML };
|
|
1973
|
+
export { SECTION_LIST, buildSrcSet, catchPostImage, isValidPermlink, getPostBodySummary as postBodySummary, proxifyImageSrc, markdown2Html as renderPostBody, setCacheSize, setProxyBase, setSlowRenderThresholdMs, simpleMarkdownToHTML };
|
|
1954
1974
|
//# sourceMappingURL=index.mjs.map
|
|
1955
1975
|
//# sourceMappingURL=index.mjs.map
|