@pixldocs/canvas-renderer 0.5.171 → 0.5.172
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-BgOzEKmN.cjs → index-DYtJJzdk.cjs} +127 -5
- package/dist/{index-BgOzEKmN.cjs.map → index-DYtJJzdk.cjs.map} +1 -1
- package/dist/{index-Cq9sQGri.js → index-DuI8QJDd.js} +142 -20
- package/dist/{index-Cq9sQGri.js.map → index-DuI8QJDd.js.map} +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +31 -0
- package/dist/index.js +16 -15
- package/dist/{vectorPdfExport-BrwXcGkA.cjs → vectorPdfExport-CDOztP1H.cjs} +4 -4
- package/dist/{vectorPdfExport-BrwXcGkA.cjs.map → vectorPdfExport-CDOztP1H.cjs.map} +1 -1
- package/dist/{vectorPdfExport--EtCdnlG.js → vectorPdfExport-wH2x4QIj.js} +4 -4
- package/dist/{vectorPdfExport--EtCdnlG.js.map → vectorPdfExport-wH2x4QIj.js.map} +1 -1
- package/package.json +1 -1
|
@@ -12001,6 +12001,59 @@ const DEFAULT_DATA_V2_VERSION = 2;
|
|
|
12001
12001
|
function isDefaultDataV2(data) {
|
|
12002
12002
|
return typeof data === "object" && data !== null && !Array.isArray(data) && data.version === DEFAULT_DATA_V2_VERSION && typeof data.sectionState === "object" && data.sectionState !== null;
|
|
12003
12003
|
}
|
|
12004
|
+
function defaultSectionState(sections) {
|
|
12005
|
+
const state = {};
|
|
12006
|
+
const repeatables = sections.filter((s) => s.type === "repeatable");
|
|
12007
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
12008
|
+
for (const section of repeatables) {
|
|
12009
|
+
if (!section.parentId) continue;
|
|
12010
|
+
if (!childrenByParent.has(section.parentId)) childrenByParent.set(section.parentId, []);
|
|
12011
|
+
childrenByParent.get(section.parentId).push(section);
|
|
12012
|
+
}
|
|
12013
|
+
const createEmptyEntry = (section) => {
|
|
12014
|
+
const entry = {};
|
|
12015
|
+
for (const field of section.entryFields) {
|
|
12016
|
+
entry[field.key] = field.type === "list" ? [] : field.type === "toggle" ? "false" : "";
|
|
12017
|
+
}
|
|
12018
|
+
return entry;
|
|
12019
|
+
};
|
|
12020
|
+
const createInitialEntries = (section) => {
|
|
12021
|
+
const count = Math.max(0, section.initialEntryCount ?? 1);
|
|
12022
|
+
return Array.from({ length: count }, () => createEmptyEntry(section));
|
|
12023
|
+
};
|
|
12024
|
+
const seedNested = (parentSection, parentStateKey, parentEntryIndex) => {
|
|
12025
|
+
const children = childrenByParent.get(parentSection.id) ?? [];
|
|
12026
|
+
for (const child of children) {
|
|
12027
|
+
const childStateKey = `${parentStateKey}_${parentEntryIndex}_${child.id}`;
|
|
12028
|
+
const childEntries = createInitialEntries(child);
|
|
12029
|
+
state[childStateKey] = childEntries;
|
|
12030
|
+
childEntries.forEach((_, childEntryIndex) => seedNested(child, childStateKey, childEntryIndex));
|
|
12031
|
+
}
|
|
12032
|
+
};
|
|
12033
|
+
for (const section of sections) {
|
|
12034
|
+
if (section.type !== "single") continue;
|
|
12035
|
+
const obj = {};
|
|
12036
|
+
for (const f of section.fields) {
|
|
12037
|
+
obj[f.key] = f.type === "list" ? [] : f.type === "toggle" ? "false" : "";
|
|
12038
|
+
}
|
|
12039
|
+
state[section.id] = obj;
|
|
12040
|
+
}
|
|
12041
|
+
const topLevelRepeatables = repeatables.filter((s) => !s.parentId);
|
|
12042
|
+
for (const section of topLevelRepeatables) {
|
|
12043
|
+
const entries = createInitialEntries(section);
|
|
12044
|
+
state[section.id] = entries;
|
|
12045
|
+
entries.forEach((_, entryIndex) => seedNested(section, section.id, entryIndex));
|
|
12046
|
+
}
|
|
12047
|
+
const singleSectionIds = new Set(sections.filter((s) => s.type === "single").map((s) => s.id));
|
|
12048
|
+
for (const section of repeatables) {
|
|
12049
|
+
if (section.parentId && singleSectionIds.has(section.parentId)) {
|
|
12050
|
+
const entries = createInitialEntries(section);
|
|
12051
|
+
state[section.id] = entries;
|
|
12052
|
+
entries.forEach((_, entryIndex) => seedNested(section, section.id, entryIndex));
|
|
12053
|
+
}
|
|
12054
|
+
}
|
|
12055
|
+
return state;
|
|
12056
|
+
}
|
|
12004
12057
|
function flattenSectionStateToFormData(sectionState, sections) {
|
|
12005
12058
|
const flat = {};
|
|
12006
12059
|
const repeatables = sections.filter((s) => s.type === "repeatable");
|
|
@@ -15751,6 +15804,74 @@ function paintRepeatableSections(config, repeatableSections) {
|
|
|
15751
15804
|
}
|
|
15752
15805
|
}
|
|
15753
15806
|
}
|
|
15807
|
+
async function getTemplateForm(options) {
|
|
15808
|
+
var _a, _b;
|
|
15809
|
+
const { templateId, supabaseUrl, supabaseAnonKey } = options;
|
|
15810
|
+
if (!supabaseUrl || !supabaseAnonKey) {
|
|
15811
|
+
throw new Error("[getTemplateForm] supabaseUrl and supabaseAnonKey are required");
|
|
15812
|
+
}
|
|
15813
|
+
const templateRow = await fetchRow(supabaseUrl, supabaseAnonKey, "templates", templateId);
|
|
15814
|
+
const templateConfig = templateRow.config;
|
|
15815
|
+
const templateFormSchema = templateRow.form_schema;
|
|
15816
|
+
const boundFormSchemaId = options.formSchemaId ?? (typeof templateRow.form_schema_id === "string" ? templateRow.form_schema_id : null);
|
|
15817
|
+
if (templateFormSchema) {
|
|
15818
|
+
if (!Array.isArray(templateConfig.dynamicFields) && Array.isArray(templateFormSchema.dynamicFields)) {
|
|
15819
|
+
templateConfig.dynamicFields = templateFormSchema.dynamicFields;
|
|
15820
|
+
}
|
|
15821
|
+
if (!Array.isArray(templateConfig.fieldGroups) && Array.isArray(templateFormSchema.fieldGroups)) {
|
|
15822
|
+
templateConfig.fieldGroups = templateFormSchema.fieldGroups;
|
|
15823
|
+
}
|
|
15824
|
+
}
|
|
15825
|
+
let formSchema;
|
|
15826
|
+
let defaultForm = null;
|
|
15827
|
+
if (boundFormSchemaId) {
|
|
15828
|
+
const [schemaRow, defForm] = await Promise.all([
|
|
15829
|
+
fetchRow(supabaseUrl, supabaseAnonKey, "form_schemas", boundFormSchemaId).catch(() => null),
|
|
15830
|
+
fetchDefaultForm(supabaseUrl, supabaseAnonKey, boundFormSchemaId)
|
|
15831
|
+
]);
|
|
15832
|
+
formSchema = schemaRow == null ? void 0 : schemaRow.schema;
|
|
15833
|
+
defaultForm = defForm;
|
|
15834
|
+
}
|
|
15835
|
+
const repeatableNodeMap = /* @__PURE__ */ new Map();
|
|
15836
|
+
const repeatableFromSchema = templateFormSchema == null ? void 0 : templateFormSchema.repeatableSections;
|
|
15837
|
+
if (repeatableFromSchema) {
|
|
15838
|
+
for (const r of repeatableFromSchema) {
|
|
15839
|
+
if (!repeatableNodeMap.has(r.label)) repeatableNodeMap.set(r.label, r.nodeId);
|
|
15840
|
+
const labelKey = r.label.trim().toLowerCase();
|
|
15841
|
+
if (!repeatableNodeMap.has(labelKey)) repeatableNodeMap.set(labelKey, r.nodeId);
|
|
15842
|
+
}
|
|
15843
|
+
}
|
|
15844
|
+
const schemaSections = getRenderableFormSections(formSchema);
|
|
15845
|
+
let sections;
|
|
15846
|
+
if (schemaSections == null ? void 0 : schemaSections.length) {
|
|
15847
|
+
sections = formDefSectionsToInferred(schemaSections, repeatableNodeMap);
|
|
15848
|
+
} else if ((_a = templateConfig.dynamicFields) == null ? void 0 : _a.length) {
|
|
15849
|
+
sections = inferFormSchemaFromTemplate(
|
|
15850
|
+
templateConfig.dynamicFields,
|
|
15851
|
+
templateConfig.fieldGroups || [],
|
|
15852
|
+
((_b = templateConfig.pages) == null ? void 0 : _b.length) ? { pages: templateConfig.pages } : void 0
|
|
15853
|
+
);
|
|
15854
|
+
} else {
|
|
15855
|
+
sections = [];
|
|
15856
|
+
}
|
|
15857
|
+
const seeded = defaultSectionState(sections);
|
|
15858
|
+
const templateDefaultData = templateRow.default_data;
|
|
15859
|
+
let overlay = null;
|
|
15860
|
+
if (templateDefaultData && isDefaultDataV2(templateDefaultData)) {
|
|
15861
|
+
overlay = templateDefaultData.sectionState;
|
|
15862
|
+
} else {
|
|
15863
|
+
overlay = extractSectionStateCandidate(defaultForm == null ? void 0 : defaultForm.values, sections) ?? extractSectionStateCandidate(defaultForm == null ? void 0 : defaultForm.saved_data, sections) ?? null;
|
|
15864
|
+
}
|
|
15865
|
+
const initialSectionState = overlay ? { ...seeded, ...overlay } : seeded;
|
|
15866
|
+
return {
|
|
15867
|
+
templateId,
|
|
15868
|
+
templateName: templateRow.name || "Untitled",
|
|
15869
|
+
price: templateRow.price ?? 0,
|
|
15870
|
+
formSchemaId: boundFormSchemaId,
|
|
15871
|
+
sections,
|
|
15872
|
+
initialSectionState
|
|
15873
|
+
};
|
|
15874
|
+
}
|
|
15754
15875
|
const PREVIEW_DEBUG_PREFIX = "[canvas-renderer][preview-debug]";
|
|
15755
15876
|
function computeFontSignature(config) {
|
|
15756
15877
|
var _a;
|
|
@@ -16117,9 +16238,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
16117
16238
|
}
|
|
16118
16239
|
return svgString;
|
|
16119
16240
|
}
|
|
16120
|
-
const resolvedPackageVersion = "0.5.
|
|
16241
|
+
const resolvedPackageVersion = "0.5.172";
|
|
16121
16242
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
16122
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
16243
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.172";
|
|
16123
16244
|
const roundParityValue = (value) => {
|
|
16124
16245
|
if (typeof value !== "number") return value;
|
|
16125
16246
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -16617,7 +16738,7 @@ class PixldocsRenderer {
|
|
|
16617
16738
|
await this.waitForCanvasScene(container, cloned, i);
|
|
16618
16739
|
}
|
|
16619
16740
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
16620
|
-
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport
|
|
16741
|
+
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-wH2x4QIj.js");
|
|
16621
16742
|
const prepared = preparePagesForExport(
|
|
16622
16743
|
cloned.pages,
|
|
16623
16744
|
canvasWidth,
|
|
@@ -18752,7 +18873,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
18752
18873
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
18753
18874
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
18754
18875
|
try {
|
|
18755
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport
|
|
18876
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-wH2x4QIj.js");
|
|
18756
18877
|
try {
|
|
18757
18878
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
18758
18879
|
} catch {
|
|
@@ -19097,7 +19218,7 @@ function setAutoShrinkDebug(enabled) {
|
|
|
19097
19218
|
}
|
|
19098
19219
|
}
|
|
19099
19220
|
export {
|
|
19100
|
-
|
|
19221
|
+
setBundledAssetPrefixes as $,
|
|
19101
19222
|
API_URL as A,
|
|
19102
19223
|
collectImageUrls as B,
|
|
19103
19224
|
configHasAutoShrinkText$1 as C,
|
|
@@ -19111,23 +19232,24 @@ export {
|
|
|
19111
19232
|
extractFontFamiliesFromSvgs as K,
|
|
19112
19233
|
getEmbeddedJsPDFFontName as L,
|
|
19113
19234
|
getPublishedTemplate as M,
|
|
19114
|
-
|
|
19115
|
-
|
|
19235
|
+
getTemplateForm as N,
|
|
19236
|
+
isBundledAssetUrl as O,
|
|
19116
19237
|
PACKAGE_VERSION as P,
|
|
19117
|
-
|
|
19118
|
-
|
|
19119
|
-
|
|
19238
|
+
isFontAvailable as Q,
|
|
19239
|
+
isPrivateUrl as R,
|
|
19240
|
+
listPublishedTemplates as S,
|
|
19120
19241
|
TRIANGLE_STROKE_MITER_LIMIT as T,
|
|
19121
|
-
|
|
19122
|
-
|
|
19123
|
-
|
|
19124
|
-
|
|
19125
|
-
|
|
19126
|
-
|
|
19127
|
-
|
|
19242
|
+
loadGoogleFontCSS as U,
|
|
19243
|
+
normalizeFontFamily as V,
|
|
19244
|
+
resolveFontWeight as W,
|
|
19245
|
+
resolveFromForm as X,
|
|
19246
|
+
resolveTemplateData as Y,
|
|
19247
|
+
rewriteSvgFontsForJsPDF as Z,
|
|
19248
|
+
setAutoShrinkDebug as _,
|
|
19128
19249
|
getAbsoluteBounds as a,
|
|
19129
|
-
|
|
19130
|
-
|
|
19250
|
+
warmResolvedTemplateForPreview as a0,
|
|
19251
|
+
warmTemplateFromForm as a1,
|
|
19252
|
+
canvasImageLoader as a2,
|
|
19131
19253
|
getProxiedImageUrl as b,
|
|
19132
19254
|
captureFabricCanvasSvgForPdf as c,
|
|
19133
19255
|
bakeEdgeFade as d,
|
|
@@ -19154,4 +19276,4 @@ export {
|
|
|
19154
19276
|
collectFontDescriptorsFromConfig as y,
|
|
19155
19277
|
collectFontsFromConfig as z
|
|
19156
19278
|
};
|
|
19157
|
-
//# sourceMappingURL=index-
|
|
19279
|
+
//# sourceMappingURL=index-DuI8QJDd.js.map
|