@pdfme/common 6.0.6-dev.1 → 6.0.6-dev.12

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
@@ -607,11 +607,18 @@ var getDynamicTemplate = async (arg) => {
607
607
  //#endregion
608
608
  //#region src/expression.ts
609
609
  var expressionCache = /* @__PURE__ */ new Map();
610
- var parseDataCache = /* @__PURE__ */ new Map();
610
+ /**
611
+ * Parse each string value in `data` as JSON, falling back to the original
612
+ * string on failure. Previously memoized via a module-level `parseDataCache`
613
+ * Map keyed by `JSON.stringify(data)`, but that was a severe memory leak:
614
+ * - Cache was never evicted.
615
+ * - Key was a multi-MB string whenever `data` included schema.content with
616
+ * base64 (e.g. image schemas) or inputs containing base64 values. Every
617
+ * unique inputs state pinned its own multi-MB key for the app lifetime.
618
+ * Parsing is O(fields) and cheap; removing the cache is strictly a win.
619
+ */
611
620
  var parseData = (data) => {
612
- const key = JSON.stringify(data);
613
- if (parseDataCache.has(key)) return parseDataCache.get(key);
614
- const parsed = Object.fromEntries(Object.entries(data).map(([key, value]) => {
621
+ return Object.fromEntries(Object.entries(data).map(([key, value]) => {
615
622
  if (typeof value === "string") try {
616
623
  return [key, JSON.parse(value)];
617
624
  } catch {
@@ -619,8 +626,6 @@ var parseData = (data) => {
619
626
  }
620
627
  return [key, value];
621
628
  }));
622
- parseDataCache.set(key, parsed);
623
- return parsed;
624
629
  };
625
630
  var padZero = (num) => String(num).padStart(2, "0");
626
631
  var formatDate = (date) => `${date.getFullYear()}/${padZero(date.getMonth() + 1)}/${padZero(date.getDate())}`;