@pixldocs/canvas-renderer 0.5.5 → 0.5.7
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.cjs +13 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +81 -0
- package/dist/index.js +13 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FormConfig } from '../../../src/lib/formsApi';
|
|
1
2
|
import { InferredSection } from '../../../src/lib/inferFormSchemaFromTemplate';
|
|
2
3
|
import { jsPDF } from 'jspdf';
|
|
3
4
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
@@ -147,6 +148,52 @@ declare type FontWeightFiles = {
|
|
|
147
148
|
semiboldItalic?: string;
|
|
148
149
|
};
|
|
149
150
|
|
|
151
|
+
declare type FormDefField = {
|
|
152
|
+
id: string;
|
|
153
|
+
label: string;
|
|
154
|
+
key: string;
|
|
155
|
+
type: 'text' | 'textarea' | 'email' | 'tel' | 'url' | 'date' | 'number' | 'image' | 'color' | 'select' | 'toggle' | 'currency' | 'rating';
|
|
156
|
+
placeholder?: string;
|
|
157
|
+
options?: {
|
|
158
|
+
value: string;
|
|
159
|
+
label: string;
|
|
160
|
+
}[];
|
|
161
|
+
order: number;
|
|
162
|
+
width?: 'full' | 'half' | 'third';
|
|
163
|
+
description?: string;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
declare type FormDefRepeatablePage = {
|
|
167
|
+
id: string;
|
|
168
|
+
label: string;
|
|
169
|
+
description?: string;
|
|
170
|
+
order: number;
|
|
171
|
+
templateKeyPrefix: string;
|
|
172
|
+
fields: FormDefField[];
|
|
173
|
+
minEntries?: number;
|
|
174
|
+
maxEntries?: number;
|
|
175
|
+
children?: FormDefSection[];
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
declare type FormDefSchema = {
|
|
179
|
+
sections: FormDefSection[];
|
|
180
|
+
repeatablePages?: FormDefRepeatablePage[];
|
|
181
|
+
formRenderPreset?: 'default' | 'compact' | 'cards' | 'minimal' | 'biodata';
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
declare type FormDefSection = {
|
|
185
|
+
id: string;
|
|
186
|
+
label: string;
|
|
187
|
+
description?: string;
|
|
188
|
+
order: number;
|
|
189
|
+
fields: FormDefField[];
|
|
190
|
+
repeatable?: boolean;
|
|
191
|
+
minEntries?: number;
|
|
192
|
+
maxEntries?: number;
|
|
193
|
+
templateKeyPrefix?: string;
|
|
194
|
+
children?: FormDefSection[];
|
|
195
|
+
};
|
|
196
|
+
|
|
150
197
|
/**
|
|
151
198
|
* Get the embedded jsPDF font name for a given font family + weight + italic.
|
|
152
199
|
* This is the name used for pdf.setFont() and must match the font-family
|
|
@@ -197,6 +244,8 @@ export declare interface PdfFromFormOptions {
|
|
|
197
244
|
themeId?: string;
|
|
198
245
|
/** Whether to inject watermark. Default: auto (true for paid templates, false for free). */
|
|
199
246
|
watermark?: boolean;
|
|
247
|
+
/** Optional prefetched rows from a trusted server to skip browser-side REST fetching. */
|
|
248
|
+
prefetched?: ResolveFromFormOptions['prefetched'];
|
|
200
249
|
/** PDF document title */
|
|
201
250
|
title?: string;
|
|
202
251
|
/** Base URL for TTF font files for PDF font embedding */
|
|
@@ -359,6 +408,8 @@ export declare interface RenderFromFormOptions extends Omit<RenderOptions, 'page
|
|
|
359
408
|
themeId?: string;
|
|
360
409
|
/** Whether to inject watermark on preview. Default: auto (true for paid templates, false for free). */
|
|
361
410
|
watermark?: boolean;
|
|
411
|
+
/** Optional prefetched rows from a trusted server to skip browser-side REST fetching. */
|
|
412
|
+
prefetched?: ResolveFromFormOptions['prefetched'];
|
|
362
413
|
}
|
|
363
414
|
|
|
364
415
|
export declare interface RenderOptions {
|
|
@@ -417,6 +468,36 @@ export declare interface ResolveFromFormOptions {
|
|
|
417
468
|
supabaseUrl: string;
|
|
418
469
|
/** Supabase anon key */
|
|
419
470
|
supabaseAnonKey: string;
|
|
471
|
+
/** Optional prefetched rows from a trusted server so browser-side package resolution can skip REST fetches entirely. */
|
|
472
|
+
prefetched?: {
|
|
473
|
+
templateRow?: {
|
|
474
|
+
id?: string;
|
|
475
|
+
name?: string;
|
|
476
|
+
price?: number;
|
|
477
|
+
config: TemplateConfig;
|
|
478
|
+
form_schema?: {
|
|
479
|
+
repeatableSections?: {
|
|
480
|
+
nodeId: string;
|
|
481
|
+
label: string;
|
|
482
|
+
minEntries?: number;
|
|
483
|
+
maxEntries?: number;
|
|
484
|
+
}[];
|
|
485
|
+
repeatablePages?: unknown[];
|
|
486
|
+
dynamicFields?: DynamicField[];
|
|
487
|
+
fieldGroups?: any[];
|
|
488
|
+
} | null;
|
|
489
|
+
default_data?: unknown;
|
|
490
|
+
};
|
|
491
|
+
formSchemaRow?: {
|
|
492
|
+
id?: string;
|
|
493
|
+
schema: FormDefSchema;
|
|
494
|
+
} | null;
|
|
495
|
+
defaultForm?: {
|
|
496
|
+
config: FormConfig;
|
|
497
|
+
values: Record<string, any>;
|
|
498
|
+
saved_data: Record<string, any>;
|
|
499
|
+
} | null;
|
|
500
|
+
};
|
|
420
501
|
}
|
|
421
502
|
|
|
422
503
|
export declare interface ResolveOptions {
|
package/dist/index.js
CHANGED
|
@@ -10497,11 +10497,11 @@ async function resolveTemplateData(options) {
|
|
|
10497
10497
|
}
|
|
10498
10498
|
async function resolveFromForm(options) {
|
|
10499
10499
|
var _a, _b, _c;
|
|
10500
|
-
const { templateId, formSchemaId, sectionState, themeId, supabaseUrl, supabaseAnonKey } = options;
|
|
10500
|
+
const { templateId, formSchemaId, sectionState, themeId, supabaseUrl, supabaseAnonKey, prefetched } = options;
|
|
10501
10501
|
const [templateRow, formSchemaRow, defaultForm] = await Promise.all([
|
|
10502
|
-
fetchRow(supabaseUrl, supabaseAnonKey, "templates", templateId),
|
|
10503
|
-
fetchRow(supabaseUrl, supabaseAnonKey, "form_schemas", formSchemaId),
|
|
10504
|
-
fetchDefaultForm(supabaseUrl, supabaseAnonKey, formSchemaId)
|
|
10502
|
+
(prefetched == null ? void 0 : prefetched.templateRow) ? Promise.resolve(prefetched.templateRow) : fetchRow(supabaseUrl, supabaseAnonKey, "templates", templateId),
|
|
10503
|
+
(prefetched == null ? void 0 : prefetched.formSchemaRow) !== void 0 ? Promise.resolve(prefetched.formSchemaRow) : fetchRow(supabaseUrl, supabaseAnonKey, "form_schemas", formSchemaId),
|
|
10504
|
+
(prefetched == null ? void 0 : prefetched.defaultForm) !== void 0 ? Promise.resolve(prefetched.defaultForm) : fetchDefaultForm(supabaseUrl, supabaseAnonKey, formSchemaId)
|
|
10505
10505
|
]);
|
|
10506
10506
|
const templateConfig = templateRow.config;
|
|
10507
10507
|
const templateFormSchema = templateRow.form_schema;
|
|
@@ -11114,14 +11114,15 @@ class PixldocsRenderer {
|
|
|
11114
11114
|
* This is the primary external API for the package.
|
|
11115
11115
|
*/
|
|
11116
11116
|
async renderFromForm(options) {
|
|
11117
|
-
const { templateId, formSchemaId, sectionState, themeId, watermark, ...renderOpts } = options;
|
|
11117
|
+
const { templateId, formSchemaId, sectionState, themeId, watermark, prefetched, ...renderOpts } = options;
|
|
11118
11118
|
const resolved = await resolveFromForm({
|
|
11119
11119
|
templateId,
|
|
11120
11120
|
formSchemaId,
|
|
11121
11121
|
sectionState,
|
|
11122
11122
|
themeId,
|
|
11123
11123
|
supabaseUrl: this.config.supabaseUrl,
|
|
11124
|
-
supabaseAnonKey: this.config.supabaseAnonKey
|
|
11124
|
+
supabaseAnonKey: this.config.supabaseAnonKey,
|
|
11125
|
+
prefetched
|
|
11125
11126
|
});
|
|
11126
11127
|
const shouldWatermark = watermark ?? resolved.price > 0;
|
|
11127
11128
|
let configToRender = resolved.config;
|
|
@@ -11166,14 +11167,15 @@ class PixldocsRenderer {
|
|
|
11166
11167
|
* Resolve from V2 sectionState and return SVGs for all pages (for server vector PDF).
|
|
11167
11168
|
*/
|
|
11168
11169
|
async renderSvgsFromForm(options) {
|
|
11169
|
-
const { templateId, formSchemaId, sectionState, themeId, watermark } = options;
|
|
11170
|
+
const { templateId, formSchemaId, sectionState, themeId, watermark, prefetched } = options;
|
|
11170
11171
|
const resolved = await resolveFromForm({
|
|
11171
11172
|
templateId,
|
|
11172
11173
|
formSchemaId,
|
|
11173
11174
|
sectionState,
|
|
11174
11175
|
themeId,
|
|
11175
11176
|
supabaseUrl: this.config.supabaseUrl,
|
|
11176
|
-
supabaseAnonKey: this.config.supabaseAnonKey
|
|
11177
|
+
supabaseAnonKey: this.config.supabaseAnonKey,
|
|
11178
|
+
prefetched
|
|
11177
11179
|
});
|
|
11178
11180
|
const shouldWatermark = watermark ?? resolved.price > 0;
|
|
11179
11181
|
let configToRender = resolved.config;
|
|
@@ -11197,14 +11199,15 @@ class PixldocsRenderer {
|
|
|
11197
11199
|
* This is the primary PDF export API — mirrors renderFromForm() but returns a PDF.
|
|
11198
11200
|
*/
|
|
11199
11201
|
async renderPdfFromForm(options) {
|
|
11200
|
-
const { templateId, formSchemaId, sectionState, themeId, watermark, title, fontBaseUrl } = options;
|
|
11202
|
+
const { templateId, formSchemaId, sectionState, themeId, watermark, prefetched, title, fontBaseUrl } = options;
|
|
11201
11203
|
const resolved = await resolveFromForm({
|
|
11202
11204
|
templateId,
|
|
11203
11205
|
formSchemaId,
|
|
11204
11206
|
sectionState,
|
|
11205
11207
|
themeId,
|
|
11206
11208
|
supabaseUrl: this.config.supabaseUrl,
|
|
11207
|
-
supabaseAnonKey: this.config.supabaseAnonKey
|
|
11209
|
+
supabaseAnonKey: this.config.supabaseAnonKey,
|
|
11210
|
+
prefetched
|
|
11208
11211
|
});
|
|
11209
11212
|
const shouldWatermark = watermark ?? resolved.price > 0;
|
|
11210
11213
|
let configToRender = resolved.config;
|