@pixldocs/canvas-renderer 0.5.219 → 0.5.221

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.
@@ -13626,7 +13626,9 @@ function formDefSectionsToInferred(schemaSections, repeatableNodeMap) {
13626
13626
  function convert(defs, parentId) {
13627
13627
  var _a, _b;
13628
13628
  for (const def of defs) {
13629
- if (def.repeatable) {
13629
+ const isRepeatable = def.repeatable === true || def.type === "repeatable";
13630
+ const defFields = def.fields ?? def.entryFields ?? [];
13631
+ if (isRepeatable) {
13630
13632
  const rawPrefix = def.templateKeyPrefix || def.label.toLowerCase().replace(/\s+/g, "_");
13631
13633
  const labelPrefix = rawPrefix.startsWith("field_") ? rawPrefix : `field_${rawPrefix}`;
13632
13634
  const treeNodeId = repeatableNodeMap == null ? void 0 : repeatableNodeMap.get(def.label.trim().toLowerCase());
@@ -13640,7 +13642,7 @@ function formDefSectionsToInferred(schemaSections, repeatableNodeMap) {
13640
13642
  templateKeyPrefix: prefix,
13641
13643
  minEntries,
13642
13644
  maxEntries: def.maxEntries,
13643
- entryFields: def.fields.map((f, i) => ({
13645
+ entryFields: defFields.map((f, i) => ({
13644
13646
  key: f.key,
13645
13647
  label: f.label,
13646
13648
  type: mapFormDefFieldType(f.type),
@@ -13665,7 +13667,7 @@ function formDefSectionsToInferred(schemaSections, repeatableNodeMap) {
13665
13667
  label: def.label,
13666
13668
  order: def.order ?? 0,
13667
13669
  type: "single",
13668
- fields: def.fields.map((f, i) => ({
13670
+ fields: defFields.map((f, i) => ({
13669
13671
  key: f.key,
13670
13672
  label: f.label,
13671
13673
  type: mapFormDefFieldType(f.type),
@@ -17276,7 +17278,7 @@ function repeatablePageToSection(page) {
17276
17278
  label: page.label,
17277
17279
  description: page.description,
17278
17280
  order: typeof page.order === "number" ? page.order + 1e4 : 1e4,
17279
- fields: page.fields,
17281
+ fields: page.fields ?? page.entryFields ?? [],
17280
17282
  repeatable: true,
17281
17283
  minEntries: page.minEntries,
17282
17284
  maxEntries: page.maxEntries,
@@ -17560,10 +17562,11 @@ async function resolveTemplateData(options) {
17560
17562
  async function resolveFromForm(options) {
17561
17563
  var _a, _b, _c;
17562
17564
  const { templateId, formSchemaId, sectionState, flatFormData: directFlatFormData, themeId, supabaseUrl, supabaseAnonKey, prefetched } = options;
17563
- if (!formSchemaId) {
17565
+ const hasSectionStateInput = !!sectionState && Object.keys(sectionState).length > 0;
17566
+ if (!formSchemaId && !hasSectionStateInput) {
17564
17567
  return resolveTemplateData({
17565
17568
  templateId,
17566
- formData: directFlatFormData ?? sectionState ?? {},
17569
+ formData: directFlatFormData ?? {},
17567
17570
  supabaseUrl,
17568
17571
  supabaseAnonKey,
17569
17572
  prefetched: (prefetched == null ? void 0 : prefetched.templateRow) ? { templateRow: prefetched.templateRow } : void 0
@@ -17571,12 +17574,12 @@ async function resolveFromForm(options) {
17571
17574
  }
17572
17575
  const [templateRow, formSchemaRow, defaultForm] = await Promise.all([
17573
17576
  (prefetched == null ? void 0 : prefetched.templateRow) ? Promise.resolve(prefetched.templateRow) : fetchRow(supabaseUrl, supabaseAnonKey, "templates", templateId),
17574
- (prefetched == null ? void 0 : prefetched.formSchemaRow) !== void 0 ? Promise.resolve(prefetched.formSchemaRow) : fetchRow(supabaseUrl, supabaseAnonKey, "form_schemas", formSchemaId),
17575
- (prefetched == null ? void 0 : prefetched.defaultForm) !== void 0 ? Promise.resolve(prefetched.defaultForm) : fetchDefaultForm(supabaseUrl, supabaseAnonKey, formSchemaId)
17577
+ (prefetched == null ? void 0 : prefetched.formSchemaRow) !== void 0 ? Promise.resolve(prefetched.formSchemaRow) : formSchemaId ? fetchRow(supabaseUrl, supabaseAnonKey, "form_schemas", formSchemaId).catch(() => null) : Promise.resolve(null),
17578
+ (prefetched == null ? void 0 : prefetched.defaultForm) !== void 0 ? Promise.resolve(prefetched.defaultForm) : formSchemaId ? fetchDefaultForm(supabaseUrl, supabaseAnonKey, formSchemaId) : Promise.resolve(null)
17576
17579
  ]);
17577
17580
  const templateConfig = templateRow.config;
17578
17581
  const templateFormSchema = templateRow.form_schema;
17579
- const formSchema = formSchemaRow.schema;
17582
+ const formSchema = (formSchemaRow == null ? void 0 : formSchemaRow.schema) ?? void 0;
17580
17583
  if (templateFormSchema) {
17581
17584
  if (!Array.isArray(templateConfig.dynamicFields) && Array.isArray(templateFormSchema.dynamicFields)) {
17582
17585
  templateConfig.dynamicFields = templateFormSchema.dynamicFields;
@@ -17646,7 +17649,8 @@ async function resolveFromForm(options) {
17646
17649
  (repeatableFromSchema ?? []).map((r) => [baseId(r.nodeId), r])
17647
17650
  );
17648
17651
  const topLevelRepeatables = inferredSections.filter((s) => s.type === "repeatable" && !s.parentId).map((s) => {
17649
- const entries = mergedSectionState[s.id] ?? [];
17652
+ const rawEntries = mergedSectionState[s.id];
17653
+ const entries = Array.isArray(rawEntries) ? rawEntries : [];
17650
17654
  const nodeId = s.treeNodeId ?? s.id;
17651
17655
  const schemaRepeatable = repeatableFromSchemaByBase.get(baseId(nodeId));
17652
17656
  const entryMeta = entries.map((e) => getRepeatableEntryMeta(e, s));
@@ -17658,11 +17662,13 @@ async function resolveFromForm(options) {
17658
17662
  const parentId = s.parentId;
17659
17663
  const parentSection = inferredSections.find((ps) => ps.id === parentId);
17660
17664
  const parentNodeId = parentSection ? parentSection.treeNodeId ?? parentSection.id : parentId;
17661
- const parentEntries = mergedSectionState[parentId] ?? [];
17665
+ const rawParentEntries = mergedSectionState[parentId];
17666
+ const parentEntries = Array.isArray(rawParentEntries) ? rawParentEntries : [];
17662
17667
  const nestedEntryMeta = {};
17663
17668
  const merged = [];
17664
17669
  for (let pi = 0; pi < parentEntries.length; pi++) {
17665
- const childEntries = mergedSectionState[`${parentId}_${pi}_${s.id}`] ?? [];
17670
+ const rawChildEntries = mergedSectionState[`${parentId}_${pi}_${s.id}`];
17671
+ const childEntries = Array.isArray(rawChildEntries) ? rawChildEntries : [];
17666
17672
  const meta = childEntries.map((e) => getRepeatableEntryMeta(e, s));
17667
17673
  nestedEntryMeta[`${baseId(parentNodeId)}_${pi + 1}_${baseId(nodeId)}`] = meta;
17668
17674
  merged.push(...meta);
@@ -17702,13 +17708,15 @@ async function resolveFromForm(options) {
17702
17708
  if (s.type !== "repeatable") continue;
17703
17709
  const parentId = s.parentId;
17704
17710
  if (parentId == null) continue;
17705
- const parentEntries = mergedSectionState[parentId] ?? [];
17711
+ const rawParentEntries2 = mergedSectionState[parentId];
17712
+ const parentEntries = Array.isArray(rawParentEntries2) ? rawParentEntries2 : [];
17706
17713
  const parentSection = inferredSections.find((ps) => ps.id === parentId);
17707
17714
  const parentTreeNodeId = parentSection ? parentSection.treeNodeId ?? parentSection.id : parentId;
17708
17715
  const childTreeNodeId = s.treeNodeId ?? s.id;
17709
17716
  for (let pi = 0; pi < parentEntries.length; pi++) {
17710
17717
  const compositeKey = `${parentId}_${pi}_${s.id}`;
17711
- const entries = mergedSectionState[compositeKey] ?? [];
17718
+ const rawEntries2 = mergedSectionState[compositeKey];
17719
+ const entries = Array.isArray(rawEntries2) ? rawEntries2 : [];
17712
17720
  const nestedKey = `${baseId(parentTreeNodeId)}_${pi + 1}_${baseId(childTreeNodeId)}`;
17713
17721
  repeatableNestedEntryCounts[nestedKey] = Math.max(1, entries.length);
17714
17722
  }
@@ -19067,9 +19075,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
19067
19075
  }
19068
19076
  return svgString;
19069
19077
  }
19070
- const resolvedPackageVersion = "0.5.219";
19078
+ const resolvedPackageVersion = "0.5.221";
19071
19079
  const PACKAGE_VERSION = resolvedPackageVersion;
19072
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.219";
19080
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.221";
19073
19081
  const roundParityValue = (value) => {
19074
19082
  if (typeof value !== "number") return value;
19075
19083
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -19813,7 +19821,7 @@ class PixldocsRenderer {
19813
19821
  await this.waitForCanvasScene(container, cloned, i);
19814
19822
  }
19815
19823
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
19816
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-Dejgf_PM.js");
19824
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BR2dJuvJ.js");
19817
19825
  const prepared = preparePagesForExport(
19818
19826
  cloned.pages,
19819
19827
  canvasWidth,
@@ -22003,7 +22011,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
22003
22011
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
22004
22012
  sanitizeSvgTreeForPdf(svgToDraw);
22005
22013
  try {
22006
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-Dejgf_PM.js");
22014
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BR2dJuvJ.js");
22007
22015
  try {
22008
22016
  await logTextMeasurementDiagnostic(svgToDraw);
22009
22017
  } catch {
@@ -22403,4 +22411,4 @@ export {
22403
22411
  buildTeaserBlurFlatKeys as y,
22404
22412
  collectFontDescriptorsFromConfig as z
22405
22413
  };
22406
- //# sourceMappingURL=index-DbUPI6zs.js.map
22414
+ //# sourceMappingURL=index-mmjF0tPc.js.map