@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.cjs
CHANGED
|
@@ -1755,10 +1755,25 @@ function cacheSet(key, value) {
|
|
|
1755
1755
|
}
|
|
1756
1756
|
|
|
1757
1757
|
// src/markdown-2-html.ts
|
|
1758
|
+
var isNodeRuntime = typeof process !== "undefined" && typeof process?.versions?.node === "string";
|
|
1759
|
+
var slowRenderThresholdMs = isNodeRuntime ? 500 : 0;
|
|
1760
|
+
function setSlowRenderThresholdMs(ms) {
|
|
1761
|
+
slowRenderThresholdMs = Math.max(0, ms);
|
|
1762
|
+
}
|
|
1763
|
+
function logIfSlow(durationMs, context) {
|
|
1764
|
+
if (slowRenderThresholdMs > 0 && durationMs >= slowRenderThresholdMs) {
|
|
1765
|
+
console.warn(
|
|
1766
|
+
`[render-helper] slow markdown render: ${durationMs.toFixed(0)}ms ${context}`
|
|
1767
|
+
);
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1758
1770
|
function markdown2Html(obj, forApp = true, _webp = false, parentDomain = "ecency.com", seoContext, renderOptions) {
|
|
1759
1771
|
if (typeof obj === "string") {
|
|
1760
1772
|
const cleanedStr = cleanReply(obj);
|
|
1761
|
-
|
|
1773
|
+
const t02 = performance.now();
|
|
1774
|
+
const res2 = markdownToHTML(cleanedStr, forApp, parentDomain, seoContext, renderOptions);
|
|
1775
|
+
logIfSlow(performance.now() - t02, `body_len=${obj.length}`);
|
|
1776
|
+
return res2;
|
|
1762
1777
|
}
|
|
1763
1778
|
const key = `${makeEntryCacheKey(obj)}-md-${forApp ? "app" : "site"}-${parentDomain}${seoContext ? `-seo${seoContext.authorReputation ?? ""}-${seoContext.postPayout ?? ""}` : ""}${renderOptions?.embedVideosDirectly ? "-embed" : ""}`;
|
|
1764
1779
|
const item = cacheGet(key);
|
|
@@ -1766,7 +1781,12 @@ function markdown2Html(obj, forApp = true, _webp = false, parentDomain = "ecency
|
|
|
1766
1781
|
return item;
|
|
1767
1782
|
}
|
|
1768
1783
|
const cleanBody = cleanReply(obj.body);
|
|
1784
|
+
const t0 = performance.now();
|
|
1769
1785
|
const res = markdownToHTML(cleanBody, forApp, parentDomain, seoContext, renderOptions);
|
|
1786
|
+
logIfSlow(
|
|
1787
|
+
performance.now() - t0,
|
|
1788
|
+
`author=@${obj.author} permlink=${obj.permlink} body_len=${obj.body?.length ?? 0}`
|
|
1789
|
+
);
|
|
1770
1790
|
cacheSet(key, res);
|
|
1771
1791
|
return res;
|
|
1772
1792
|
}
|
|
@@ -1988,6 +2008,7 @@ exports.proxifyImageSrc = proxifyImageSrc;
|
|
|
1988
2008
|
exports.renderPostBody = markdown2Html;
|
|
1989
2009
|
exports.setCacheSize = setCacheSize;
|
|
1990
2010
|
exports.setProxyBase = setProxyBase;
|
|
2011
|
+
exports.setSlowRenderThresholdMs = setSlowRenderThresholdMs;
|
|
1991
2012
|
exports.simpleMarkdownToHTML = simpleMarkdownToHTML;
|
|
1992
2013
|
//# sourceMappingURL=index.cjs.map
|
|
1993
2014
|
//# sourceMappingURL=index.cjs.map
|