@pixldocs/canvas-renderer 0.5.188 → 0.5.190

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.
@@ -13309,6 +13309,7 @@ function isStaticOnNewPage(node) {
13309
13309
  function cloneNodeWithNewIds(node) {
13310
13310
  const base = node.__baseNodeId;
13311
13311
  const source = node.__sourceId;
13312
+ const effectiveSource = source ?? node.id;
13312
13313
  if (isGroup(node)) {
13313
13314
  const g = node;
13314
13315
  const cloned2 = {
@@ -13317,14 +13318,14 @@ function cloneNodeWithNewIds(node) {
13317
13318
  children: (g.children ?? []).map(cloneNodeWithNewIds)
13318
13319
  };
13319
13320
  if (base != null) cloned2.__baseNodeId = base;
13320
- if (source != null) cloned2.__sourceId = source;
13321
+ cloned2.__sourceId = effectiveSource;
13321
13322
  return cloned2;
13322
13323
  }
13323
13324
  const el = node;
13324
13325
  const prefix = el.type === "text" ? "text" : el.type === "image" ? "img" : el.type === "shape" ? "shape" : "line";
13325
13326
  const cloned = { ...el, id: generateId(prefix) };
13326
13327
  if (base != null) cloned.__baseNodeId = base;
13327
- if (source != null) cloned.__sourceId = source;
13328
+ cloned.__sourceId = effectiveSource;
13328
13329
  return cloned;
13329
13330
  }
13330
13331
  function cloneNodeWithStableIds(node, baseId2, path) {
@@ -13630,7 +13631,51 @@ function applyContentBoundsPagination(config) {
13630
13631
  resultPages.push(...paginated);
13631
13632
  }
13632
13633
  if (!mutated) return config;
13633
- return { ...config, pages: resultPages };
13634
+ const next = { ...config, pages: resultPages };
13635
+ remapCloneIdMapAfterPagination(next);
13636
+ return next;
13637
+ }
13638
+ function remapCloneIdMapAfterPagination(config) {
13639
+ const cloneIdMap = config.__cloneIdMap;
13640
+ if (!cloneIdMap || typeof cloneIdMap !== "object") return;
13641
+ const allIds = /* @__PURE__ */ new Set();
13642
+ const sourceToNew = /* @__PURE__ */ new Map();
13643
+ const walk = (node) => {
13644
+ if (!node || typeof node !== "object") return;
13645
+ const n = node;
13646
+ if (typeof n.id === "string") {
13647
+ allIds.add(n.id);
13648
+ const src = n.__sourceId;
13649
+ if (typeof src === "string" && src !== n.id) {
13650
+ const arr = sourceToNew.get(src);
13651
+ if (arr) arr.push(n.id);
13652
+ else sourceToNew.set(src, [n.id]);
13653
+ }
13654
+ }
13655
+ const children = n.children;
13656
+ if (Array.isArray(children)) for (const c of children) walk(c);
13657
+ };
13658
+ for (const page of config.pages ?? []) {
13659
+ const ch = page.children;
13660
+ if (Array.isArray(ch)) for (const c of ch) walk(c);
13661
+ }
13662
+ const updated = {};
13663
+ for (const [key, val] of Object.entries(cloneIdMap)) {
13664
+ const oldIds = Array.isArray(val) ? val : [val];
13665
+ const newIds = [];
13666
+ for (const oid of oldIds) {
13667
+ if (typeof oid !== "string") continue;
13668
+ if (allIds.has(oid)) newIds.push(oid);
13669
+ const clones = sourceToNew.get(oid);
13670
+ if (clones) {
13671
+ for (const c of clones) if (allIds.has(c)) newIds.push(c);
13672
+ }
13673
+ }
13674
+ if (newIds.length === 0) continue;
13675
+ const uniq = Array.from(new Set(newIds));
13676
+ updated[key] = uniq.length === 1 ? uniq[0] : uniq;
13677
+ }
13678
+ config.__cloneIdMap = updated;
13634
13679
  }
13635
13680
  const __vite_import_meta_env__ = {};
13636
13681
  const FONT_WEIGHT_LABELS = {
@@ -16239,6 +16284,49 @@ function addAllToSet(val, out) {
16239
16284
  out.add(val);
16240
16285
  return true;
16241
16286
  }
16287
+ function collectPageTreeElementIds(config, pageIndex = "all") {
16288
+ const out = /* @__PURE__ */ new Set();
16289
+ const pages = config == null ? void 0 : config.pages;
16290
+ if (!Array.isArray(pages)) return out;
16291
+ const targets = pageIndex === "all" ? pages : pages[pageIndex] != null ? [pages[pageIndex]] : [];
16292
+ const walk = (node) => {
16293
+ if (!node || typeof node !== "object") return;
16294
+ if (typeof node.id === "string") out.add(node.id);
16295
+ const children = node.children || node.elements;
16296
+ if (Array.isArray(children)) for (const c of children) walk(c);
16297
+ };
16298
+ for (const page of targets) {
16299
+ const children = (page == null ? void 0 : page.children) || (page == null ? void 0 : page.elements);
16300
+ if (Array.isArray(children)) for (const c of children) walk(c);
16301
+ }
16302
+ return out;
16303
+ }
16304
+ function collectIdsBySourceMatch(config, targetIds, pageIndex = "all") {
16305
+ const targets = /* @__PURE__ */ new Set();
16306
+ for (const t of targetIds) if (typeof t === "string" && t) targets.add(t);
16307
+ if (targets.size === 0) return [];
16308
+ const pages = config == null ? void 0 : config.pages;
16309
+ if (!Array.isArray(pages)) return [];
16310
+ const visitPages = pageIndex === "all" ? pages : pages[pageIndex] != null ? [pages[pageIndex]] : [];
16311
+ const out = /* @__PURE__ */ new Set();
16312
+ const walk = (node) => {
16313
+ if (!node || typeof node !== "object") return;
16314
+ const src = typeof node.__sourceId === "string" ? node.__sourceId : void 0;
16315
+ const base = typeof node.__baseNodeId === "string" ? node.__baseNodeId : void 0;
16316
+ if (typeof node.id === "string") {
16317
+ if (targets.has(node.id)) out.add(node.id);
16318
+ else if (src && targets.has(src)) out.add(node.id);
16319
+ else if (base && targets.has(base)) out.add(node.id);
16320
+ }
16321
+ const children = node.children || node.elements;
16322
+ if (Array.isArray(children)) for (const c of children) walk(c);
16323
+ };
16324
+ for (const page of visitPages) {
16325
+ const children = (page == null ? void 0 : page.children) || (page == null ? void 0 : page.elements);
16326
+ if (Array.isArray(children)) for (const c of children) walk(c);
16327
+ }
16328
+ return Array.from(out);
16329
+ }
16242
16330
  function resolveBlurElementExactIdsFromFlatFormKeys(config, flatFormKeys, options) {
16243
16331
  const cloneIdMap = (config == null ? void 0 : config.__cloneIdMap) || {};
16244
16332
  if (!cloneIdMap || typeof cloneIdMap !== "object") return [];
@@ -16263,10 +16351,60 @@ function resolveBlurElementExactIdsFromFlatFormKeys(config, flatFormKeys, option
16263
16351
  }
16264
16352
  }
16265
16353
  }
16266
- return Array.from(out);
16354
+ if (out.size === 0) return [];
16355
+ if (options == null ? void 0 : options.skipTreeVerification) return Array.from(out);
16356
+ const treeIds = collectPageTreeElementIds(
16357
+ config,
16358
+ (options == null ? void 0 : options.pageIndex) ?? "all"
16359
+ );
16360
+ if (treeIds.size === 0) return Array.from(out);
16361
+ const verified = [];
16362
+ for (const id of out) if (treeIds.has(id)) verified.push(id);
16363
+ if (verified.length > 0) return verified;
16364
+ return collectIdsBySourceMatch(config, out, (options == null ? void 0 : options.pageIndex) ?? "all");
16365
+ }
16366
+ function buildTeaserBlurFlatKeys(sectionState, sections, options) {
16367
+ const afterRow = Math.max(0, options.afterRow | 0);
16368
+ const bindings = options.bindings ?? "value";
16369
+ const out = [];
16370
+ if (!sectionState || !Array.isArray(sections)) return out;
16371
+ const repeatables = sections.filter((s) => (s == null ? void 0 : s.type) === "repeatable");
16372
+ const childrenByParent = /* @__PURE__ */ new Map();
16373
+ for (const r of repeatables) {
16374
+ if (!r.parentId) continue;
16375
+ const arr = childrenByParent.get(r.parentId) || [];
16376
+ arr.push(r);
16377
+ childrenByParent.set(r.parentId, arr);
16378
+ }
16379
+ const emitForEntryFields = (section, keyPrefix, entryIdx1) => {
16380
+ const fields = section.entryFields || [];
16381
+ for (const f of fields) {
16382
+ if (!(f == null ? void 0 : f.key)) continue;
16383
+ if (bindings === "value" && f.key !== "value") continue;
16384
+ out.push(`${keyPrefix}_${f.key}`);
16385
+ }
16386
+ };
16387
+ const walkRepeatable = (section, parentKeyPrefix) => {
16388
+ const entries = sectionState == null ? void 0 : sectionState[section.id];
16389
+ if (!Array.isArray(entries)) return;
16390
+ for (let i = 0; i < entries.length; i++) {
16391
+ const entryIdx1 = i + 1;
16392
+ const isBlurred = entryIdx1 > afterRow;
16393
+ const keyPrefix = parentKeyPrefix ? `${parentKeyPrefix}_field_${section.id}_${entryIdx1}` : `field_${section.id}_${entryIdx1}`;
16394
+ if (isBlurred) emitForEntryFields(section, keyPrefix);
16395
+ const children = childrenByParent.get(section.id) || [];
16396
+ for (const child of children) walkRepeatable(child, keyPrefix);
16397
+ }
16398
+ };
16399
+ for (const r of repeatables) {
16400
+ if (r.parentId) continue;
16401
+ walkRepeatable(r, "");
16402
+ }
16403
+ return out;
16267
16404
  }
16268
16405
  const previewBlur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
16269
16406
  __proto__: null,
16407
+ buildTeaserBlurFlatKeys,
16270
16408
  hasAnyPreviewBlur,
16271
16409
  injectPreviewBlur,
16272
16410
  resolveBlurElementExactIdsFromFlatFormKeys
@@ -16751,9 +16889,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
16751
16889
  }
16752
16890
  return svgString;
16753
16891
  }
16754
- const resolvedPackageVersion = "0.5.188";
16892
+ const resolvedPackageVersion = "0.5.190";
16755
16893
  const PACKAGE_VERSION = resolvedPackageVersion;
16756
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.188";
16894
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.190";
16757
16895
  const roundParityValue = (value) => {
16758
16896
  if (typeof value !== "number") return value;
16759
16897
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -17261,7 +17399,7 @@ class PixldocsRenderer {
17261
17399
  await this.waitForCanvasScene(container, cloned, i);
17262
17400
  }
17263
17401
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
17264
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CSh0zFox.js");
17402
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DFGqTzvI.js");
17265
17403
  const prepared = preparePagesForExport(
17266
17404
  cloned.pages,
17267
17405
  canvasWidth,
@@ -19406,7 +19544,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
19406
19544
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
19407
19545
  sanitizeSvgTreeForPdf(svgToDraw);
19408
19546
  try {
19409
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CSh0zFox.js");
19547
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DFGqTzvI.js");
19410
19548
  try {
19411
19549
  await logTextMeasurementDiagnostic(svgToDraw);
19412
19550
  } catch {
@@ -19744,41 +19882,42 @@ function setAutoShrinkDebug(enabled) {
19744
19882
  }
19745
19883
  }
19746
19884
  export {
19747
- resolveTemplateData as $,
19885
+ resolveFromForm as $,
19748
19886
  API_URL as A,
19749
- collectImageUrls as B,
19750
- configHasAutoShrinkText$1 as C,
19887
+ collectFontsFromConfig as B,
19888
+ collectImageUrls as C,
19751
19889
  DEPLOYMENT_VERSION_MARKER as D,
19752
- dumpSvgTextDiagnostics as E,
19890
+ configHasAutoShrinkText$1 as E,
19753
19891
  FONT_FALLBACK_DEVANAGARI as F,
19754
- embedFont as G,
19755
- embedFontsForConfig as H,
19756
- embedFontsInPdf as I,
19757
- ensureFontsForResolvedConfig as J,
19758
- extractFontFamiliesFromSvgs as K,
19759
- getEmbeddedJsPDFFontName as L,
19760
- getPublishedTemplate as M,
19761
- getTemplateForm as N,
19762
- hasAnyPreviewBlur as O,
19892
+ dumpSvgTextDiagnostics as G,
19893
+ embedFont as H,
19894
+ embedFontsForConfig as I,
19895
+ embedFontsInPdf as J,
19896
+ ensureFontsForResolvedConfig as K,
19897
+ extractFontFamiliesFromSvgs as L,
19898
+ getEmbeddedJsPDFFontName as M,
19899
+ getPublishedTemplate as N,
19900
+ getTemplateForm as O,
19763
19901
  PACKAGE_VERSION as P,
19764
- injectPreviewBlur as Q,
19765
- isBundledAssetUrl as R,
19766
- isFontAvailable as S,
19902
+ hasAnyPreviewBlur as Q,
19903
+ injectPreviewBlur as R,
19904
+ isBundledAssetUrl as S,
19767
19905
  TRIANGLE_STROKE_MITER_LIMIT as T,
19768
- isPrivateUrl as U,
19769
- listPublishedTemplates as V,
19770
- loadGoogleFontCSS as W,
19771
- normalizeFontFamily as X,
19772
- resolveBlurElementExactIdsFromFlatFormKeys as Y,
19773
- resolveFontWeight as Z,
19774
- resolveFromForm as _,
19906
+ isFontAvailable as U,
19907
+ isPrivateUrl as V,
19908
+ listPublishedTemplates as W,
19909
+ loadGoogleFontCSS as X,
19910
+ normalizeFontFamily as Y,
19911
+ resolveBlurElementExactIdsFromFlatFormKeys as Z,
19912
+ resolveFontWeight as _,
19775
19913
  getAbsoluteBounds as a,
19776
- rewriteSvgFontsForJsPDF as a0,
19777
- setAutoShrinkDebug as a1,
19778
- setBundledAssetPrefixes as a2,
19779
- warmResolvedTemplateForPreview as a3,
19780
- warmTemplateFromForm as a4,
19781
- canvasImageLoader as a5,
19914
+ resolveTemplateData as a0,
19915
+ rewriteSvgFontsForJsPDF as a1,
19916
+ setAutoShrinkDebug as a2,
19917
+ setBundledAssetPrefixes as a3,
19918
+ warmResolvedTemplateForPreview as a4,
19919
+ warmTemplateFromForm as a5,
19920
+ canvasImageLoader as a6,
19782
19921
  getProxiedImageUrl as b,
19783
19922
  captureFabricCanvasSvgForPdf as c,
19784
19923
  bakeEdgeFade as d,
@@ -19802,7 +19941,7 @@ export {
19802
19941
  applyThemeToConfig as v,
19803
19942
  assemblePdfFromSvgs as w,
19804
19943
  awaitFontsForConfig as x,
19805
- collectFontDescriptorsFromConfig as y,
19806
- collectFontsFromConfig as z
19944
+ buildTeaserBlurFlatKeys as y,
19945
+ collectFontDescriptorsFromConfig as z
19807
19946
  };
19808
- //# sourceMappingURL=index-CjZZhQH6.js.map
19947
+ //# sourceMappingURL=index-Dt4aPZtQ.js.map