@pixldocs/canvas-renderer 0.5.183 → 0.5.184
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/README.md +26 -0
- package/dist/{index-IYEhmMeo.js → index-D2deevHj.js} +103 -23
- package/dist/{index-IYEhmMeo.js.map → index-D2deevHj.js.map} +1 -1
- package/dist/{index-B1BBI3Bg.cjs → index-DUJw7ypl.cjs} +103 -23
- package/dist/{index-B1BBI3Bg.cjs.map → index-DUJw7ypl.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1 -1
- package/dist/{previewBlur-B2SedQxb.cjs → previewBlur-Dbd6dn62.cjs} +2 -2
- package/dist/{previewBlur-B2SedQxb.cjs.map → previewBlur-Dbd6dn62.cjs.map} +1 -1
- package/dist/{previewBlur-Dkg1mMKM.js → previewBlur-Dwbjk5sM.js} +2 -2
- package/dist/{previewBlur-Dkg1mMKM.js.map → previewBlur-Dwbjk5sM.js.map} +1 -1
- package/dist/{vectorPdfExport-B73_TC4T.cjs → vectorPdfExport-BIgSi-Ef.cjs} +4 -4
- package/dist/{vectorPdfExport-B73_TC4T.cjs.map → vectorPdfExport-BIgSi-Ef.cjs.map} +1 -1
- package/dist/{vectorPdfExport-C09pvz-H.js → vectorPdfExport-CBUTexHq.js} +4 -4
- package/dist/{vectorPdfExport-C09pvz-H.js.map → vectorPdfExport-CBUTexHq.js.map} +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -367,6 +367,32 @@ Preview-blur is gated identically to the watermark: it only runs when
|
|
|
367
367
|
`watermark === true` (or, by default, when `template.price > 0` and the user
|
|
368
368
|
hasn't paid). Clean / paid downloads always render the original content.
|
|
369
369
|
|
|
370
|
+
### Live `backdrop-filter` overlay in `<PixldocsPreview>`
|
|
371
|
+
|
|
372
|
+
The React `<PixldocsPreview>` component automatically renders a real CSS
|
|
373
|
+
`backdrop-filter: blur()` frosted-glass overlay on top of every element
|
|
374
|
+
marked `previewBlur: true`. Bounds are auto-derived from the config
|
|
375
|
+
(groups respected), so no extra wiring is required.
|
|
376
|
+
|
|
377
|
+
Defaults: `blur(5px) saturate(130%)` with a `rgba(255,255,255,0.12)` tint,
|
|
378
|
+
square corners, no stroke, no shadow — identical to the in-app preview on
|
|
379
|
+
pixldocs.com.
|
|
380
|
+
|
|
381
|
+
Opt-out or tune via props:
|
|
382
|
+
|
|
383
|
+
```tsx
|
|
384
|
+
<PixldocsPreview
|
|
385
|
+
config={config}
|
|
386
|
+
// disable entirely
|
|
387
|
+
frostedBlur={false}
|
|
388
|
+
// or tune
|
|
389
|
+
frostedBlurOptions={{ blurPx: 6, saturatePct: 140, background: 'rgba(255,255,255,0.15)' }}
|
|
390
|
+
/>
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
The imperative PNG / PDF export paths still use the static translucent
|
|
394
|
+
rectangle (the closest pure-vector approximation), unchanged.
|
|
395
|
+
|
|
370
396
|
```ts
|
|
371
397
|
// In your template config
|
|
372
398
|
{
|
|
@@ -16144,7 +16144,39 @@ function countUnderlinedNodes(config) {
|
|
|
16144
16144
|
for (const page of config.pages) walk(page.children || []);
|
|
16145
16145
|
return count;
|
|
16146
16146
|
}
|
|
16147
|
+
function getNum(v, fallback = 0) {
|
|
16148
|
+
return typeof v === "number" && Number.isFinite(v) ? v : fallback;
|
|
16149
|
+
}
|
|
16150
|
+
function collectBlurBounds(node, parentLeft, parentTop, inheritedBlur, out) {
|
|
16151
|
+
if (!node || typeof node !== "object") return;
|
|
16152
|
+
const isBlurred = inheritedBlur || node.previewBlur === true;
|
|
16153
|
+
const absLeft = parentLeft + getNum(node.left, 0);
|
|
16154
|
+
const absTop = parentTop + getNum(node.top, 0);
|
|
16155
|
+
if (node.type === "group") {
|
|
16156
|
+
const children = node.children || node.elements;
|
|
16157
|
+
if (Array.isArray(children)) {
|
|
16158
|
+
for (const c of children) collectBlurBounds(c, absLeft, absTop, isBlurred, out);
|
|
16159
|
+
}
|
|
16160
|
+
return;
|
|
16161
|
+
}
|
|
16162
|
+
if (!isBlurred) return;
|
|
16163
|
+
const sx = getNum(node.scaleX, 1) || 1;
|
|
16164
|
+
const sy = getNum(node.scaleY, 1) || 1;
|
|
16165
|
+
const w = Math.max(4, getNum(node.width, 0) * sx);
|
|
16166
|
+
const h = Math.max(4, getNum(node.height, 0) * sy);
|
|
16167
|
+
out.push({ left: absLeft, top: absTop, width: w, height: h });
|
|
16168
|
+
}
|
|
16169
|
+
function computeFrostedBoundsForPage(config, pageIndex) {
|
|
16170
|
+
var _a;
|
|
16171
|
+
const page = (_a = config == null ? void 0 : config.pages) == null ? void 0 : _a[pageIndex];
|
|
16172
|
+
const children = (page == null ? void 0 : page.children) || (page == null ? void 0 : page.elements);
|
|
16173
|
+
if (!Array.isArray(children)) return [];
|
|
16174
|
+
const out = [];
|
|
16175
|
+
for (const c of children) collectBlurBounds(c, 0, 0, false, out);
|
|
16176
|
+
return out;
|
|
16177
|
+
}
|
|
16147
16178
|
function PixldocsPreview(props) {
|
|
16179
|
+
var _a, _b;
|
|
16148
16180
|
const {
|
|
16149
16181
|
pageIndex = 0,
|
|
16150
16182
|
zoom = 1,
|
|
@@ -16168,7 +16200,9 @@ function PixldocsPreview(props) {
|
|
|
16168
16200
|
// `captureSvgViaPreviewCanvas`) already pass `skipFontReadyWait: false`
|
|
16169
16201
|
// for this exact reason — that's why the downloaded PDF was correct
|
|
16170
16202
|
// while the on-screen preview wasn't.
|
|
16171
|
-
skipFontReadyWait = false
|
|
16203
|
+
skipFontReadyWait = false,
|
|
16204
|
+
frostedBlur = true,
|
|
16205
|
+
frostedBlurOptions
|
|
16172
16206
|
} = props;
|
|
16173
16207
|
useEffect(() => {
|
|
16174
16208
|
setPackageApiUrl(imageProxyUrl);
|
|
@@ -16205,10 +16239,10 @@ function PixldocsPreview(props) {
|
|
|
16205
16239
|
supabaseUrl: p.supabaseUrl,
|
|
16206
16240
|
supabaseAnonKey: p.supabaseAnonKey
|
|
16207
16241
|
}).then((resolved) => {
|
|
16208
|
-
var
|
|
16242
|
+
var _a2, _b2;
|
|
16209
16243
|
if (!cancelled) {
|
|
16210
16244
|
console.log(PREVIEW_DEBUG_PREFIX, "resolve-done", {
|
|
16211
|
-
pages: ((
|
|
16245
|
+
pages: ((_b2 = (_a2 = resolved.config) == null ? void 0 : _a2.pages) == null ? void 0 : _b2.length) ?? 0,
|
|
16212
16246
|
underlinedNodes: countUnderlinedNodes(resolved.config)
|
|
16213
16247
|
});
|
|
16214
16248
|
setResolvedConfig(resolved.config);
|
|
@@ -16284,6 +16318,16 @@ function PixldocsPreview(props) {
|
|
|
16284
16318
|
setCanvasSettled(true);
|
|
16285
16319
|
onReady == null ? void 0 : onReady();
|
|
16286
16320
|
}, [onReady, pageIndex]);
|
|
16321
|
+
const frostedBounds = useMemo(
|
|
16322
|
+
() => frostedBlur ? computeFrostedBoundsForPage(config, pageIndex) : [],
|
|
16323
|
+
[frostedBlur, config, pageIndex]
|
|
16324
|
+
);
|
|
16325
|
+
const blurPx = (frostedBlurOptions == null ? void 0 : frostedBlurOptions.blurPx) ?? 5;
|
|
16326
|
+
const satPct = (frostedBlurOptions == null ? void 0 : frostedBlurOptions.saturatePct) ?? 130;
|
|
16327
|
+
const bgTint = (frostedBlurOptions == null ? void 0 : frostedBlurOptions.background) ?? "rgba(255,255,255,0.12)";
|
|
16328
|
+
const canvasW = getNum((_a = config == null ? void 0 : config.canvas) == null ? void 0 : _a.width, 0);
|
|
16329
|
+
const canvasH = getNum((_b = config == null ? void 0 : config.canvas) == null ? void 0 : _b.height, 0);
|
|
16330
|
+
const hasOverlays = frostedBounds.length > 0 && canvasW > 0 && canvasH > 0;
|
|
16287
16331
|
if (isLoading) {
|
|
16288
16332
|
return /* @__PURE__ */ jsx("div", { className, style: { ...style, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) });
|
|
16289
16333
|
}
|
|
@@ -16292,19 +16336,55 @@ function PixldocsPreview(props) {
|
|
|
16292
16336
|
return /* @__PURE__ */ jsx("div", { className, style: { ...style, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) });
|
|
16293
16337
|
}
|
|
16294
16338
|
return /* @__PURE__ */ jsxs("div", { className, style: { ...style, position: "relative" }, children: [
|
|
16295
|
-
/* @__PURE__ */
|
|
16296
|
-
|
|
16339
|
+
/* @__PURE__ */ jsxs(
|
|
16340
|
+
"div",
|
|
16297
16341
|
{
|
|
16298
|
-
|
|
16299
|
-
|
|
16300
|
-
|
|
16301
|
-
|
|
16302
|
-
|
|
16303
|
-
|
|
16304
|
-
|
|
16305
|
-
|
|
16306
|
-
|
|
16307
|
-
|
|
16342
|
+
style: hasOverlays ? { visibility: canvasSettled ? "visible" : "hidden", position: "relative", width: canvasW * zoom, height: canvasH * zoom } : { visibility: canvasSettled ? "visible" : "hidden" },
|
|
16343
|
+
children: [
|
|
16344
|
+
/* @__PURE__ */ jsx(
|
|
16345
|
+
PreviewCanvas,
|
|
16346
|
+
{
|
|
16347
|
+
config,
|
|
16348
|
+
pageIndex,
|
|
16349
|
+
zoom,
|
|
16350
|
+
absoluteZoom,
|
|
16351
|
+
skipFontReadyWait,
|
|
16352
|
+
onDynamicFieldClick,
|
|
16353
|
+
onReady: handleCanvasReady
|
|
16354
|
+
},
|
|
16355
|
+
previewKey
|
|
16356
|
+
),
|
|
16357
|
+
hasOverlays && /* @__PURE__ */ jsx(
|
|
16358
|
+
"div",
|
|
16359
|
+
{
|
|
16360
|
+
style: {
|
|
16361
|
+
position: "absolute",
|
|
16362
|
+
inset: 0,
|
|
16363
|
+
pointerEvents: "none",
|
|
16364
|
+
zIndex: 5
|
|
16365
|
+
},
|
|
16366
|
+
children: frostedBounds.map((b, i) => /* @__PURE__ */ jsx(
|
|
16367
|
+
"div",
|
|
16368
|
+
{
|
|
16369
|
+
style: {
|
|
16370
|
+
position: "absolute",
|
|
16371
|
+
left: b.left * zoom,
|
|
16372
|
+
top: b.top * zoom,
|
|
16373
|
+
width: b.width * zoom,
|
|
16374
|
+
height: b.height * zoom,
|
|
16375
|
+
borderRadius: 0,
|
|
16376
|
+
backdropFilter: `blur(${blurPx}px) saturate(${satPct}%)`,
|
|
16377
|
+
WebkitBackdropFilter: `blur(${blurPx}px) saturate(${satPct}%)`,
|
|
16378
|
+
background: bgTint
|
|
16379
|
+
}
|
|
16380
|
+
},
|
|
16381
|
+
`frost-${pageIndex}-${i}`
|
|
16382
|
+
))
|
|
16383
|
+
}
|
|
16384
|
+
)
|
|
16385
|
+
]
|
|
16386
|
+
}
|
|
16387
|
+
),
|
|
16308
16388
|
!canvasSettled && /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) })
|
|
16309
16389
|
] });
|
|
16310
16390
|
}
|
|
@@ -16481,9 +16561,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
16481
16561
|
}
|
|
16482
16562
|
return svgString;
|
|
16483
16563
|
}
|
|
16484
|
-
const resolvedPackageVersion = "0.5.
|
|
16564
|
+
const resolvedPackageVersion = "0.5.184";
|
|
16485
16565
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
16486
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
16566
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.184";
|
|
16487
16567
|
const roundParityValue = (value) => {
|
|
16488
16568
|
if (typeof value !== "number") return value;
|
|
16489
16569
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -16782,7 +16862,7 @@ class PixldocsRenderer {
|
|
|
16782
16862
|
if (shouldWatermark) {
|
|
16783
16863
|
const { injectWatermark } = await import("./canvasWatermark-pkhacGge.js");
|
|
16784
16864
|
configToRender = injectWatermark(configToRender, watermarkOptions);
|
|
16785
|
-
const { injectPreviewBlur } = await import("./previewBlur-
|
|
16865
|
+
const { injectPreviewBlur } = await import("./previewBlur-Dwbjk5sM.js");
|
|
16786
16866
|
configToRender = injectPreviewBlur(configToRender);
|
|
16787
16867
|
}
|
|
16788
16868
|
return this.renderAllPages(configToRender, renderOpts);
|
|
@@ -16841,7 +16921,7 @@ class PixldocsRenderer {
|
|
|
16841
16921
|
if (shouldWatermark) {
|
|
16842
16922
|
const { injectWatermark } = await import("./canvasWatermark-pkhacGge.js");
|
|
16843
16923
|
configToRender = injectWatermark(configToRender, watermarkOptions);
|
|
16844
|
-
const { injectPreviewBlur } = await import("./previewBlur-
|
|
16924
|
+
const { injectPreviewBlur } = await import("./previewBlur-Dwbjk5sM.js");
|
|
16845
16925
|
configToRender = injectPreviewBlur(configToRender);
|
|
16846
16926
|
}
|
|
16847
16927
|
return this.renderAllPageSvgs(configToRender);
|
|
@@ -16885,7 +16965,7 @@ class PixldocsRenderer {
|
|
|
16885
16965
|
if (shouldWatermark) {
|
|
16886
16966
|
const { injectWatermark } = await import("./canvasWatermark-pkhacGge.js");
|
|
16887
16967
|
configToRender = injectWatermark(configToRender, watermarkOptions);
|
|
16888
|
-
const { injectPreviewBlur } = await import("./previewBlur-
|
|
16968
|
+
const { injectPreviewBlur } = await import("./previewBlur-Dwbjk5sM.js");
|
|
16889
16969
|
configToRender = injectPreviewBlur(configToRender);
|
|
16890
16970
|
}
|
|
16891
16971
|
return this.renderPdfViaClientExport(configToRender, {
|
|
@@ -16991,7 +17071,7 @@ class PixldocsRenderer {
|
|
|
16991
17071
|
await this.waitForCanvasScene(container, cloned, i);
|
|
16992
17072
|
}
|
|
16993
17073
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
16994
|
-
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-
|
|
17074
|
+
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CBUTexHq.js");
|
|
16995
17075
|
const prepared = preparePagesForExport(
|
|
16996
17076
|
cloned.pages,
|
|
16997
17077
|
canvasWidth,
|
|
@@ -19136,7 +19216,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
19136
19216
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
19137
19217
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
19138
19218
|
try {
|
|
19139
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-
|
|
19219
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CBUTexHq.js");
|
|
19140
19220
|
try {
|
|
19141
19221
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
19142
19222
|
} catch {
|
|
@@ -19533,4 +19613,4 @@ export {
|
|
|
19533
19613
|
awaitFontsForConfig as y,
|
|
19534
19614
|
collectFontDescriptorsFromConfig as z
|
|
19535
19615
|
};
|
|
19536
|
-
//# sourceMappingURL=index-
|
|
19616
|
+
//# sourceMappingURL=index-D2deevHj.js.map
|