@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
|
@@ -16162,7 +16162,39 @@ function countUnderlinedNodes(config) {
|
|
|
16162
16162
|
for (const page of config.pages) walk(page.children || []);
|
|
16163
16163
|
return count;
|
|
16164
16164
|
}
|
|
16165
|
+
function getNum(v, fallback = 0) {
|
|
16166
|
+
return typeof v === "number" && Number.isFinite(v) ? v : fallback;
|
|
16167
|
+
}
|
|
16168
|
+
function collectBlurBounds(node, parentLeft, parentTop, inheritedBlur, out) {
|
|
16169
|
+
if (!node || typeof node !== "object") return;
|
|
16170
|
+
const isBlurred = inheritedBlur || node.previewBlur === true;
|
|
16171
|
+
const absLeft = parentLeft + getNum(node.left, 0);
|
|
16172
|
+
const absTop = parentTop + getNum(node.top, 0);
|
|
16173
|
+
if (node.type === "group") {
|
|
16174
|
+
const children = node.children || node.elements;
|
|
16175
|
+
if (Array.isArray(children)) {
|
|
16176
|
+
for (const c of children) collectBlurBounds(c, absLeft, absTop, isBlurred, out);
|
|
16177
|
+
}
|
|
16178
|
+
return;
|
|
16179
|
+
}
|
|
16180
|
+
if (!isBlurred) return;
|
|
16181
|
+
const sx = getNum(node.scaleX, 1) || 1;
|
|
16182
|
+
const sy = getNum(node.scaleY, 1) || 1;
|
|
16183
|
+
const w = Math.max(4, getNum(node.width, 0) * sx);
|
|
16184
|
+
const h = Math.max(4, getNum(node.height, 0) * sy);
|
|
16185
|
+
out.push({ left: absLeft, top: absTop, width: w, height: h });
|
|
16186
|
+
}
|
|
16187
|
+
function computeFrostedBoundsForPage(config, pageIndex) {
|
|
16188
|
+
var _a;
|
|
16189
|
+
const page = (_a = config == null ? void 0 : config.pages) == null ? void 0 : _a[pageIndex];
|
|
16190
|
+
const children = (page == null ? void 0 : page.children) || (page == null ? void 0 : page.elements);
|
|
16191
|
+
if (!Array.isArray(children)) return [];
|
|
16192
|
+
const out = [];
|
|
16193
|
+
for (const c of children) collectBlurBounds(c, 0, 0, false, out);
|
|
16194
|
+
return out;
|
|
16195
|
+
}
|
|
16165
16196
|
function PixldocsPreview(props) {
|
|
16197
|
+
var _a, _b;
|
|
16166
16198
|
const {
|
|
16167
16199
|
pageIndex = 0,
|
|
16168
16200
|
zoom = 1,
|
|
@@ -16186,7 +16218,9 @@ function PixldocsPreview(props) {
|
|
|
16186
16218
|
// `captureSvgViaPreviewCanvas`) already pass `skipFontReadyWait: false`
|
|
16187
16219
|
// for this exact reason — that's why the downloaded PDF was correct
|
|
16188
16220
|
// while the on-screen preview wasn't.
|
|
16189
|
-
skipFontReadyWait = false
|
|
16221
|
+
skipFontReadyWait = false,
|
|
16222
|
+
frostedBlur = true,
|
|
16223
|
+
frostedBlurOptions
|
|
16190
16224
|
} = props;
|
|
16191
16225
|
react.useEffect(() => {
|
|
16192
16226
|
setPackageApiUrl(imageProxyUrl);
|
|
@@ -16223,10 +16257,10 @@ function PixldocsPreview(props) {
|
|
|
16223
16257
|
supabaseUrl: p.supabaseUrl,
|
|
16224
16258
|
supabaseAnonKey: p.supabaseAnonKey
|
|
16225
16259
|
}).then((resolved) => {
|
|
16226
|
-
var
|
|
16260
|
+
var _a2, _b2;
|
|
16227
16261
|
if (!cancelled) {
|
|
16228
16262
|
console.log(PREVIEW_DEBUG_PREFIX, "resolve-done", {
|
|
16229
|
-
pages: ((
|
|
16263
|
+
pages: ((_b2 = (_a2 = resolved.config) == null ? void 0 : _a2.pages) == null ? void 0 : _b2.length) ?? 0,
|
|
16230
16264
|
underlinedNodes: countUnderlinedNodes(resolved.config)
|
|
16231
16265
|
});
|
|
16232
16266
|
setResolvedConfig(resolved.config);
|
|
@@ -16302,6 +16336,16 @@ function PixldocsPreview(props) {
|
|
|
16302
16336
|
setCanvasSettled(true);
|
|
16303
16337
|
onReady == null ? void 0 : onReady();
|
|
16304
16338
|
}, [onReady, pageIndex]);
|
|
16339
|
+
const frostedBounds = react.useMemo(
|
|
16340
|
+
() => frostedBlur ? computeFrostedBoundsForPage(config, pageIndex) : [],
|
|
16341
|
+
[frostedBlur, config, pageIndex]
|
|
16342
|
+
);
|
|
16343
|
+
const blurPx = (frostedBlurOptions == null ? void 0 : frostedBlurOptions.blurPx) ?? 5;
|
|
16344
|
+
const satPct = (frostedBlurOptions == null ? void 0 : frostedBlurOptions.saturatePct) ?? 130;
|
|
16345
|
+
const bgTint = (frostedBlurOptions == null ? void 0 : frostedBlurOptions.background) ?? "rgba(255,255,255,0.12)";
|
|
16346
|
+
const canvasW = getNum((_a = config == null ? void 0 : config.canvas) == null ? void 0 : _a.width, 0);
|
|
16347
|
+
const canvasH = getNum((_b = config == null ? void 0 : config.canvas) == null ? void 0 : _b.height, 0);
|
|
16348
|
+
const hasOverlays = frostedBounds.length > 0 && canvasW > 0 && canvasH > 0;
|
|
16305
16349
|
if (isLoading) {
|
|
16306
16350
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, style: { ...style, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) });
|
|
16307
16351
|
}
|
|
@@ -16310,19 +16354,55 @@ function PixldocsPreview(props) {
|
|
|
16310
16354
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, style: { ...style, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) });
|
|
16311
16355
|
}
|
|
16312
16356
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...style, position: "relative" }, children: [
|
|
16313
|
-
/* @__PURE__ */ jsxRuntime.
|
|
16314
|
-
|
|
16357
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
16358
|
+
"div",
|
|
16315
16359
|
{
|
|
16316
|
-
|
|
16317
|
-
|
|
16318
|
-
|
|
16319
|
-
|
|
16320
|
-
|
|
16321
|
-
|
|
16322
|
-
|
|
16323
|
-
|
|
16324
|
-
|
|
16325
|
-
|
|
16360
|
+
style: hasOverlays ? { visibility: canvasSettled ? "visible" : "hidden", position: "relative", width: canvasW * zoom, height: canvasH * zoom } : { visibility: canvasSettled ? "visible" : "hidden" },
|
|
16361
|
+
children: [
|
|
16362
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
16363
|
+
PreviewCanvas,
|
|
16364
|
+
{
|
|
16365
|
+
config,
|
|
16366
|
+
pageIndex,
|
|
16367
|
+
zoom,
|
|
16368
|
+
absoluteZoom,
|
|
16369
|
+
skipFontReadyWait,
|
|
16370
|
+
onDynamicFieldClick,
|
|
16371
|
+
onReady: handleCanvasReady
|
|
16372
|
+
},
|
|
16373
|
+
previewKey
|
|
16374
|
+
),
|
|
16375
|
+
hasOverlays && /* @__PURE__ */ jsxRuntime.jsx(
|
|
16376
|
+
"div",
|
|
16377
|
+
{
|
|
16378
|
+
style: {
|
|
16379
|
+
position: "absolute",
|
|
16380
|
+
inset: 0,
|
|
16381
|
+
pointerEvents: "none",
|
|
16382
|
+
zIndex: 5
|
|
16383
|
+
},
|
|
16384
|
+
children: frostedBounds.map((b, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
16385
|
+
"div",
|
|
16386
|
+
{
|
|
16387
|
+
style: {
|
|
16388
|
+
position: "absolute",
|
|
16389
|
+
left: b.left * zoom,
|
|
16390
|
+
top: b.top * zoom,
|
|
16391
|
+
width: b.width * zoom,
|
|
16392
|
+
height: b.height * zoom,
|
|
16393
|
+
borderRadius: 0,
|
|
16394
|
+
backdropFilter: `blur(${blurPx}px) saturate(${satPct}%)`,
|
|
16395
|
+
WebkitBackdropFilter: `blur(${blurPx}px) saturate(${satPct}%)`,
|
|
16396
|
+
background: bgTint
|
|
16397
|
+
}
|
|
16398
|
+
},
|
|
16399
|
+
`frost-${pageIndex}-${i}`
|
|
16400
|
+
))
|
|
16401
|
+
}
|
|
16402
|
+
)
|
|
16403
|
+
]
|
|
16404
|
+
}
|
|
16405
|
+
),
|
|
16326
16406
|
!canvasSettled && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) })
|
|
16327
16407
|
] });
|
|
16328
16408
|
}
|
|
@@ -16499,9 +16579,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
16499
16579
|
}
|
|
16500
16580
|
return svgString;
|
|
16501
16581
|
}
|
|
16502
|
-
const resolvedPackageVersion = "0.5.
|
|
16582
|
+
const resolvedPackageVersion = "0.5.184";
|
|
16503
16583
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
16504
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
16584
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.184";
|
|
16505
16585
|
const roundParityValue = (value) => {
|
|
16506
16586
|
if (typeof value !== "number") return value;
|
|
16507
16587
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -16800,7 +16880,7 @@ class PixldocsRenderer {
|
|
|
16800
16880
|
if (shouldWatermark) {
|
|
16801
16881
|
const { injectWatermark } = await Promise.resolve().then(() => require("./canvasWatermark-B0ab38Ok.cjs"));
|
|
16802
16882
|
configToRender = injectWatermark(configToRender, watermarkOptions);
|
|
16803
|
-
const { injectPreviewBlur } = await Promise.resolve().then(() => require("./previewBlur-
|
|
16883
|
+
const { injectPreviewBlur } = await Promise.resolve().then(() => require("./previewBlur-Dbd6dn62.cjs"));
|
|
16804
16884
|
configToRender = injectPreviewBlur(configToRender);
|
|
16805
16885
|
}
|
|
16806
16886
|
return this.renderAllPages(configToRender, renderOpts);
|
|
@@ -16859,7 +16939,7 @@ class PixldocsRenderer {
|
|
|
16859
16939
|
if (shouldWatermark) {
|
|
16860
16940
|
const { injectWatermark } = await Promise.resolve().then(() => require("./canvasWatermark-B0ab38Ok.cjs"));
|
|
16861
16941
|
configToRender = injectWatermark(configToRender, watermarkOptions);
|
|
16862
|
-
const { injectPreviewBlur } = await Promise.resolve().then(() => require("./previewBlur-
|
|
16942
|
+
const { injectPreviewBlur } = await Promise.resolve().then(() => require("./previewBlur-Dbd6dn62.cjs"));
|
|
16863
16943
|
configToRender = injectPreviewBlur(configToRender);
|
|
16864
16944
|
}
|
|
16865
16945
|
return this.renderAllPageSvgs(configToRender);
|
|
@@ -16903,7 +16983,7 @@ class PixldocsRenderer {
|
|
|
16903
16983
|
if (shouldWatermark) {
|
|
16904
16984
|
const { injectWatermark } = await Promise.resolve().then(() => require("./canvasWatermark-B0ab38Ok.cjs"));
|
|
16905
16985
|
configToRender = injectWatermark(configToRender, watermarkOptions);
|
|
16906
|
-
const { injectPreviewBlur } = await Promise.resolve().then(() => require("./previewBlur-
|
|
16986
|
+
const { injectPreviewBlur } = await Promise.resolve().then(() => require("./previewBlur-Dbd6dn62.cjs"));
|
|
16907
16987
|
configToRender = injectPreviewBlur(configToRender);
|
|
16908
16988
|
}
|
|
16909
16989
|
return this.renderPdfViaClientExport(configToRender, {
|
|
@@ -17009,7 +17089,7 @@ class PixldocsRenderer {
|
|
|
17009
17089
|
await this.waitForCanvasScene(container, cloned, i);
|
|
17010
17090
|
}
|
|
17011
17091
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
17012
|
-
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
17092
|
+
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BIgSi-Ef.cjs"));
|
|
17013
17093
|
const prepared = preparePagesForExport(
|
|
17014
17094
|
cloned.pages,
|
|
17015
17095
|
canvasWidth,
|
|
@@ -19154,7 +19234,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
19154
19234
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
19155
19235
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
19156
19236
|
try {
|
|
19157
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
19237
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BIgSi-Ef.cjs"));
|
|
19158
19238
|
try {
|
|
19159
19239
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
19160
19240
|
} catch {
|
|
@@ -19548,4 +19628,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
|
|
|
19548
19628
|
exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
|
|
19549
19629
|
exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
|
|
19550
19630
|
exports.warmTemplateFromForm = warmTemplateFromForm;
|
|
19551
|
-
//# sourceMappingURL=index-
|
|
19631
|
+
//# sourceMappingURL=index-DUJw7ypl.cjs.map
|