@pixldocs/canvas-renderer 0.5.186 → 0.5.187
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 +74 -0
- package/dist/{index-Xg0sHfrw.js → index-C9H38u7P.js} +242 -65
- package/dist/index-C9H38u7P.js.map +1 -0
- package/dist/{index-_ogxqALr.cjs → index-DgMi1JSR.cjs} +199 -22
- package/dist/index-DgMi1JSR.cjs.map +1 -0
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +47 -0
- package/dist/index.js +40 -37
- package/dist/{vectorPdfExport-v3mr9nks.js → vectorPdfExport-BkERGCkM.js} +4 -4
- package/dist/{vectorPdfExport-v3mr9nks.js.map → vectorPdfExport-BkERGCkM.js.map} +1 -1
- package/dist/{vectorPdfExport-Dh3el4F0.cjs → vectorPdfExport-BknzMTNP.cjs} +4 -4
- package/dist/{vectorPdfExport-Dh3el4F0.cjs.map → vectorPdfExport-BknzMTNP.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/index-Xg0sHfrw.js.map +0 -1
- package/dist/index-_ogxqALr.cjs.map +0 -1
- package/dist/previewBlur-CDBjIIjX.js +0 -104
- package/dist/previewBlur-CDBjIIjX.js.map +0 -1
- package/dist/previewBlur-D2aWUrre.cjs +0 -104
- package/dist/previewBlur-D2aWUrre.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -482,3 +482,77 @@ const blurFieldIds = ['text-reference-name', 'text-phone', 'text-address'];
|
|
|
482
482
|
**downloads** (PNG/PDF) you still want to run `injectPreviewBlur(...)` on
|
|
483
483
|
the resolved config before handing it to the imperative renderer, so the
|
|
484
484
|
blur is baked into the exported pixels.
|
|
485
|
+
|
|
486
|
+
### Biodata teaser previews — blur by flat form key (v0.5.187+)
|
|
487
|
+
|
|
488
|
+
Form-driven apps (BioMaker, the pixldocs.com Use page, etc.) already
|
|
489
|
+
speak the **flat form-key** language produced by `applyFormDataToConfig`
|
|
490
|
+
— e.g.
|
|
491
|
+
|
|
492
|
+
```
|
|
493
|
+
field_<treeNodeId>_<entryIdx1>_<fieldKey>
|
|
494
|
+
field_<parentTree>_<pi>_field_<childTree>_<ci>_<fieldKey> // nested
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
Instead of reverse-engineering `config.__cloneIdMap` keys or the
|
|
498
|
+
`__cN` / `_eN` clone suffixes on canvas element ids, you can pass those
|
|
499
|
+
flat keys straight to `<PixldocsPreview>` and the package resolves them:
|
|
500
|
+
|
|
501
|
+
```tsx
|
|
502
|
+
import { PixldocsPreview } from '@pixldocs/canvas-renderer';
|
|
503
|
+
|
|
504
|
+
// e.g. for a biodata teaser: blur every detail-row VALUE after row 3.
|
|
505
|
+
const blurFlatFormKeys = buildTeaserBlurFlatKeys(sectionState, schema, {
|
|
506
|
+
afterRow: 3,
|
|
507
|
+
bindings: 'value',
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
<PixldocsPreview
|
|
511
|
+
config={displayConfig}
|
|
512
|
+
frostedBlur
|
|
513
|
+
blurFlatFormKeys={blurFlatFormKeys}
|
|
514
|
+
// Optional — defaults to { bindings: 'value' } so only `*_value` keys
|
|
515
|
+
// are honoured. Pass 'all' to blur labels / titles too.
|
|
516
|
+
blurFlatFormKeyOptions={{ bindings: 'value' }}
|
|
517
|
+
/>
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
Notes:
|
|
521
|
+
|
|
522
|
+
- Matching is done on `config.__cloneIdMap` and handles all alias
|
|
523
|
+
variants (`grp-…_4_value`, `…_4_field_detail_section_N_field_N_value`,
|
|
524
|
+
with or without the wrapper `field_` prefix). Unknown keys are
|
|
525
|
+
silently ignored — the package never blurs an element it can't
|
|
526
|
+
positively identify, so a stale key won't accidentally blur the full
|
|
527
|
+
name, photo, or section titles.
|
|
528
|
+
- Defaults to `bindings: 'value'`, i.e. only flat keys whose last
|
|
529
|
+
segment is `value` resolve. This is exactly the biodata teaser
|
|
530
|
+
pattern: blur row values, leave labels / section titles / full-name /
|
|
531
|
+
photo sharp. Switch to `'all'` if you want labels blurred too.
|
|
532
|
+
- This only drives the live preview overlay. For the watermarked
|
|
533
|
+
PNG/PDF download path, resolve the same keys to exact ids and bake
|
|
534
|
+
them in (see below).
|
|
535
|
+
|
|
536
|
+
#### Watermarked downloads — same resolver + `injectPreviewBlur`
|
|
537
|
+
|
|
538
|
+
```ts
|
|
539
|
+
import {
|
|
540
|
+
injectPreviewBlur,
|
|
541
|
+
resolveBlurElementExactIdsFromFlatFormKeys,
|
|
542
|
+
} from '@pixldocs/canvas-renderer';
|
|
543
|
+
|
|
544
|
+
const exactIds = resolveBlurElementExactIdsFromFlatFormKeys(
|
|
545
|
+
resolvedConfig,
|
|
546
|
+
blurFlatFormKeys,
|
|
547
|
+
// { bindings: 'value' } by default
|
|
548
|
+
);
|
|
549
|
+
|
|
550
|
+
const exportConfig = injectPreviewBlur(resolvedConfig, {
|
|
551
|
+
extraElementExactIds: new Set(exactIds),
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
// Hand `exportConfig` to renderer.renderAllPages / renderPdf / …
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
Same resolution path as the live preview — so the on-screen overlay and
|
|
558
|
+
the downloaded PNG/PDF blur exactly the same elements.
|
|
@@ -16115,6 +16115,44 @@ async function getTemplateForm(options) {
|
|
|
16115
16115
|
initialSectionState
|
|
16116
16116
|
};
|
|
16117
16117
|
}
|
|
16118
|
+
function stripFieldPrefix(s) {
|
|
16119
|
+
return s.startsWith("field_") ? s.slice("field_".length) : s;
|
|
16120
|
+
}
|
|
16121
|
+
function addAll(val, out) {
|
|
16122
|
+
if (!val) return false;
|
|
16123
|
+
if (Array.isArray(val)) {
|
|
16124
|
+
for (const v of val) out.add(v);
|
|
16125
|
+
return val.length > 0;
|
|
16126
|
+
}
|
|
16127
|
+
out.add(val);
|
|
16128
|
+
return true;
|
|
16129
|
+
}
|
|
16130
|
+
function resolveBlurElementExactIdsFromFlatFormKeys(config, flatFormKeys, options) {
|
|
16131
|
+
const cloneIdMap = (config == null ? void 0 : config.__cloneIdMap) || {};
|
|
16132
|
+
if (!cloneIdMap || typeof cloneIdMap !== "object") return [];
|
|
16133
|
+
const bindings = (options == null ? void 0 : options.bindings) ?? "value";
|
|
16134
|
+
const out = /* @__PURE__ */ new Set();
|
|
16135
|
+
for (const rawId of flatFormKeys) {
|
|
16136
|
+
if (typeof rawId !== "string" || !rawId) continue;
|
|
16137
|
+
if (bindings === "value" && !rawId.endsWith("_value")) continue;
|
|
16138
|
+
const candidates = [rawId];
|
|
16139
|
+
if (rawId.startsWith("field_")) {
|
|
16140
|
+
const topStripped = stripFieldPrefix(rawId);
|
|
16141
|
+
candidates.push(topStripped);
|
|
16142
|
+
const nestedIdx = topStripped.indexOf("_field_");
|
|
16143
|
+
if (nestedIdx >= 0) {
|
|
16144
|
+
const nestedStripped = topStripped.slice(0, nestedIdx + 1) + topStripped.slice(nestedIdx + 1 + "field_".length);
|
|
16145
|
+
candidates.push(nestedStripped);
|
|
16146
|
+
}
|
|
16147
|
+
}
|
|
16148
|
+
for (const k of candidates) {
|
|
16149
|
+
if (k in cloneIdMap) {
|
|
16150
|
+
if (addAll(cloneIdMap[k], out)) break;
|
|
16151
|
+
}
|
|
16152
|
+
}
|
|
16153
|
+
}
|
|
16154
|
+
return Array.from(out);
|
|
16155
|
+
}
|
|
16118
16156
|
const PREVIEW_DEBUG_PREFIX = "[canvas-renderer][preview-debug]";
|
|
16119
16157
|
function computeFontSignature(config) {
|
|
16120
16158
|
var _a;
|
|
@@ -16208,7 +16246,9 @@ function PixldocsPreview(props) {
|
|
|
16208
16246
|
frostedBlur = true,
|
|
16209
16247
|
frostedBlurOptions,
|
|
16210
16248
|
blurFieldIds,
|
|
16211
|
-
blurElementExactIds
|
|
16249
|
+
blurElementExactIds,
|
|
16250
|
+
blurFlatFormKeys,
|
|
16251
|
+
blurFlatFormKeyOptions
|
|
16212
16252
|
} = props;
|
|
16213
16253
|
useEffect(() => {
|
|
16214
16254
|
setPackageApiUrl(imageProxyUrl);
|
|
@@ -16329,8 +16369,26 @@ function PixldocsPreview(props) {
|
|
|
16329
16369
|
[blurFieldIds ? blurFieldIds.join("|") : ""]
|
|
16330
16370
|
);
|
|
16331
16371
|
const blurExactSet = useMemo(
|
|
16332
|
-
() =>
|
|
16333
|
-
|
|
16372
|
+
() => {
|
|
16373
|
+
const merged = /* @__PURE__ */ new Set();
|
|
16374
|
+
if (blurElementExactIds) for (const id of blurElementExactIds) merged.add(id);
|
|
16375
|
+
if (config && blurFlatFormKeys && blurFlatFormKeys.length) {
|
|
16376
|
+
for (const id of resolveBlurElementExactIdsFromFlatFormKeys(
|
|
16377
|
+
config,
|
|
16378
|
+
blurFlatFormKeys,
|
|
16379
|
+
blurFlatFormKeyOptions
|
|
16380
|
+
)) {
|
|
16381
|
+
merged.add(id);
|
|
16382
|
+
}
|
|
16383
|
+
}
|
|
16384
|
+
return merged.size > 0 ? merged : void 0;
|
|
16385
|
+
},
|
|
16386
|
+
[
|
|
16387
|
+
blurElementExactIds ? blurElementExactIds.join("|") : "",
|
|
16388
|
+
blurFlatFormKeys ? blurFlatFormKeys.join("|") : "",
|
|
16389
|
+
blurFlatFormKeyOptions == null ? void 0 : blurFlatFormKeyOptions.bindings,
|
|
16390
|
+
config
|
|
16391
|
+
]
|
|
16334
16392
|
);
|
|
16335
16393
|
const frostedBounds = useMemo(
|
|
16336
16394
|
() => frostedBlur ? computeFrostedBoundsForPage(config, pageIndex, blurBaseSet, blurExactSet) : [],
|
|
@@ -16575,9 +16633,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
16575
16633
|
}
|
|
16576
16634
|
return svgString;
|
|
16577
16635
|
}
|
|
16578
|
-
const resolvedPackageVersion = "0.5.
|
|
16636
|
+
const resolvedPackageVersion = "0.5.187";
|
|
16579
16637
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
16580
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
16638
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.187";
|
|
16581
16639
|
const roundParityValue = (value) => {
|
|
16582
16640
|
if (typeof value !== "number") return value;
|
|
16583
16641
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -16876,8 +16934,8 @@ class PixldocsRenderer {
|
|
|
16876
16934
|
if (shouldWatermark) {
|
|
16877
16935
|
const { injectWatermark } = await import("./canvasWatermark-pkhacGge.js");
|
|
16878
16936
|
configToRender = injectWatermark(configToRender, watermarkOptions);
|
|
16879
|
-
const { injectPreviewBlur } = await
|
|
16880
|
-
configToRender =
|
|
16937
|
+
const { injectPreviewBlur: injectPreviewBlur2 } = await Promise.resolve().then(() => previewBlur);
|
|
16938
|
+
configToRender = injectPreviewBlur2(configToRender);
|
|
16881
16939
|
}
|
|
16882
16940
|
return this.renderAllPages(configToRender, renderOpts);
|
|
16883
16941
|
}
|
|
@@ -16935,8 +16993,8 @@ class PixldocsRenderer {
|
|
|
16935
16993
|
if (shouldWatermark) {
|
|
16936
16994
|
const { injectWatermark } = await import("./canvasWatermark-pkhacGge.js");
|
|
16937
16995
|
configToRender = injectWatermark(configToRender, watermarkOptions);
|
|
16938
|
-
const { injectPreviewBlur } = await
|
|
16939
|
-
configToRender =
|
|
16996
|
+
const { injectPreviewBlur: injectPreviewBlur2 } = await Promise.resolve().then(() => previewBlur);
|
|
16997
|
+
configToRender = injectPreviewBlur2(configToRender);
|
|
16940
16998
|
}
|
|
16941
16999
|
return this.renderAllPageSvgs(configToRender);
|
|
16942
17000
|
}
|
|
@@ -16979,8 +17037,8 @@ class PixldocsRenderer {
|
|
|
16979
17037
|
if (shouldWatermark) {
|
|
16980
17038
|
const { injectWatermark } = await import("./canvasWatermark-pkhacGge.js");
|
|
16981
17039
|
configToRender = injectWatermark(configToRender, watermarkOptions);
|
|
16982
|
-
const { injectPreviewBlur } = await
|
|
16983
|
-
configToRender =
|
|
17040
|
+
const { injectPreviewBlur: injectPreviewBlur2 } = await Promise.resolve().then(() => previewBlur);
|
|
17041
|
+
configToRender = injectPreviewBlur2(configToRender);
|
|
16984
17042
|
}
|
|
16985
17043
|
return this.renderPdfViaClientExport(configToRender, {
|
|
16986
17044
|
title: title ?? resolved.config.name,
|
|
@@ -17085,7 +17143,7 @@ class PixldocsRenderer {
|
|
|
17085
17143
|
await this.waitForCanvasScene(container, cloned, i);
|
|
17086
17144
|
}
|
|
17087
17145
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
17088
|
-
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-
|
|
17146
|
+
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BkERGCkM.js");
|
|
17089
17147
|
const prepared = preparePagesForExport(
|
|
17090
17148
|
cloned.pages,
|
|
17091
17149
|
canvasWidth,
|
|
@@ -17927,7 +17985,7 @@ function collectFontSpecsFromMarkup(markup) {
|
|
|
17927
17985
|
}
|
|
17928
17986
|
return Array.from(specs);
|
|
17929
17987
|
}
|
|
17930
|
-
function parseColor(color) {
|
|
17988
|
+
function parseColor$1(color) {
|
|
17931
17989
|
if (!color) return null;
|
|
17932
17990
|
const raw = color.trim().toLowerCase();
|
|
17933
17991
|
if (!raw || raw === "transparent" || raw === "none") return null;
|
|
@@ -18480,7 +18538,7 @@ function stripSuspiciousFullPageOverlayNodes(svg) {
|
|
|
18480
18538
|
if (!(pageWidth > 0 && pageHeight > 0)) return;
|
|
18481
18539
|
const isNear = (a, b, tolerance = 0.75) => Math.abs(a - b) <= tolerance;
|
|
18482
18540
|
const isDarkPaint = (value) => {
|
|
18483
|
-
const rgb = value ? parseColor(value) : null;
|
|
18541
|
+
const rgb = value ? parseColor$1(value) : null;
|
|
18484
18542
|
return rgb ? rgb.r <= 32 && rgb.g <= 32 && rgb.b <= 32 : false;
|
|
18485
18543
|
};
|
|
18486
18544
|
const removeIfSuspicious = (el) => {
|
|
@@ -18593,13 +18651,13 @@ function inlineComputedStyles(svg) {
|
|
|
18593
18651
|
const fill = cs.fill;
|
|
18594
18652
|
const stroke = cs.stroke;
|
|
18595
18653
|
if (fill && fill !== "none" && fill !== "rgba(0, 0, 0, 0)") {
|
|
18596
|
-
const parsed = parseColor(fill);
|
|
18654
|
+
const parsed = parseColor$1(fill);
|
|
18597
18655
|
if (parsed) el.setAttribute("fill", rgbToHex(parsed.r, parsed.g, parsed.b));
|
|
18598
18656
|
} else if (fill === "rgba(0, 0, 0, 0)" || fill === "transparent") {
|
|
18599
18657
|
el.setAttribute("fill", "none");
|
|
18600
18658
|
}
|
|
18601
18659
|
if (stroke && stroke !== "none" && stroke !== "rgba(0, 0, 0, 0)") {
|
|
18602
|
-
const parsed = parseColor(stroke);
|
|
18660
|
+
const parsed = parseColor$1(stroke);
|
|
18603
18661
|
if (parsed) el.setAttribute("stroke", rgbToHex(parsed.r, parsed.g, parsed.b));
|
|
18604
18662
|
}
|
|
18605
18663
|
}
|
|
@@ -18747,7 +18805,7 @@ function setPdfColorFromSvg(pdf, svg, _elementId) {
|
|
|
18747
18805
|
const { fill, stroke } = getFirstExplicitColorFromSvg(svg);
|
|
18748
18806
|
const setColor = (hex, setter) => {
|
|
18749
18807
|
if (!hex) return;
|
|
18750
|
-
const c = parseColor(hex);
|
|
18808
|
+
const c = parseColor$1(hex);
|
|
18751
18809
|
if (c) pdf[setter](c.r, c.g, c.b);
|
|
18752
18810
|
};
|
|
18753
18811
|
setColor(fill, "setFillColor");
|
|
@@ -19230,7 +19288,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
19230
19288
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
19231
19289
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
19232
19290
|
try {
|
|
19233
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-
|
|
19291
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BkERGCkM.js");
|
|
19234
19292
|
try {
|
|
19235
19293
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
19236
19294
|
} catch {
|
|
@@ -19250,7 +19308,7 @@ function drawPageBackground(pdf, pageIndex, pageWidth, pageHeight, backgroundCol
|
|
|
19250
19308
|
if (backgroundGradient && ((_a = backgroundGradient.stops) == null ? void 0 : _a.length) >= 2) {
|
|
19251
19309
|
const grad = backgroundGradient;
|
|
19252
19310
|
const colorStops = grad.stops.map((s) => {
|
|
19253
|
-
const c = parseColor(s.color);
|
|
19311
|
+
const c = parseColor$1(s.color);
|
|
19254
19312
|
return {
|
|
19255
19313
|
offset: Math.max(0, Math.min(1, Number(s.offset))),
|
|
19256
19314
|
color: c ? [c.r, c.g, c.b] : [0, 0, 0]
|
|
@@ -19306,7 +19364,7 @@ function drawPageBackground(pdf, pageIndex, pageWidth, pageHeight, backgroundCol
|
|
|
19306
19364
|
pdf.rect(0, 0, pageWidth, pageHeight, "F");
|
|
19307
19365
|
}
|
|
19308
19366
|
} else {
|
|
19309
|
-
const bgColor = parseColor(backgroundColor && backgroundColor !== "transparent" ? backgroundColor : "#ffffff");
|
|
19367
|
+
const bgColor = parseColor$1(backgroundColor && backgroundColor !== "transparent" ? backgroundColor : "#ffffff");
|
|
19310
19368
|
if (bgColor) {
|
|
19311
19369
|
pdf.setFillColor(bgColor.r, bgColor.g, bgColor.b);
|
|
19312
19370
|
pdf.rect(0, 0, pageWidth, pageHeight, "F");
|
|
@@ -19429,6 +19487,123 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
|
|
|
19429
19487
|
pages: svgResults.map((p) => ({ width: p.width, height: p.height }))
|
|
19430
19488
|
};
|
|
19431
19489
|
}
|
|
19490
|
+
const OVERLAY_ID_PREFIX = "__pb_";
|
|
19491
|
+
function getNumber(v, fallback = 0) {
|
|
19492
|
+
return typeof v === "number" && Number.isFinite(v) ? v : fallback;
|
|
19493
|
+
}
|
|
19494
|
+
function resolveSize(node, key) {
|
|
19495
|
+
const v = node == null ? void 0 : node[key];
|
|
19496
|
+
if (typeof v === "number" && Number.isFinite(v)) return v;
|
|
19497
|
+
return 0;
|
|
19498
|
+
}
|
|
19499
|
+
function collectOverlays(node, parentLeft, parentTop, inheritedBlur, extraBaseIds, extraExactIds, out) {
|
|
19500
|
+
if (!node || typeof node !== "object") return;
|
|
19501
|
+
const matchesBase = !!(extraBaseIds && typeof node.id === "string" && extraBaseIds.has(baseId(node.id)));
|
|
19502
|
+
const matchesExact = !!(extraExactIds && typeof node.id === "string" && extraExactIds.has(node.id));
|
|
19503
|
+
const isBlurred = inheritedBlur || node.previewBlur === true || matchesBase || matchesExact;
|
|
19504
|
+
const absLeft = parentLeft + getNumber(node.left, 0);
|
|
19505
|
+
const absTop = parentTop + getNumber(node.top, 0);
|
|
19506
|
+
if (node.type === "group") {
|
|
19507
|
+
const children = node.children || node.elements;
|
|
19508
|
+
if (Array.isArray(children)) {
|
|
19509
|
+
for (const child of children) {
|
|
19510
|
+
collectOverlays(child, absLeft, absTop, isBlurred, extraBaseIds, extraExactIds, out);
|
|
19511
|
+
}
|
|
19512
|
+
}
|
|
19513
|
+
return;
|
|
19514
|
+
}
|
|
19515
|
+
if (!isBlurred) return;
|
|
19516
|
+
const scaleX = getNumber(node.scaleX, 1) || 1;
|
|
19517
|
+
const scaleY = getNumber(node.scaleY, 1) || 1;
|
|
19518
|
+
const w = Math.max(4, resolveSize(node, "width") * scaleX);
|
|
19519
|
+
const h = Math.max(4, resolveSize(node, "height") * scaleY);
|
|
19520
|
+
out.push({
|
|
19521
|
+
left: absLeft,
|
|
19522
|
+
top: absTop,
|
|
19523
|
+
width: w,
|
|
19524
|
+
height: h,
|
|
19525
|
+
hintFill: typeof node.fill === "string" ? node.fill : void 0
|
|
19526
|
+
});
|
|
19527
|
+
}
|
|
19528
|
+
function parseColor(c) {
|
|
19529
|
+
if (!c) return null;
|
|
19530
|
+
const s = c.trim();
|
|
19531
|
+
const hex = s.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);
|
|
19532
|
+
if (hex) {
|
|
19533
|
+
let h = hex[1];
|
|
19534
|
+
if (h.length === 3) h = h.split("").map((x) => x + x).join("");
|
|
19535
|
+
return {
|
|
19536
|
+
r: parseInt(h.slice(0, 2), 16),
|
|
19537
|
+
g: parseInt(h.slice(2, 4), 16),
|
|
19538
|
+
b: parseInt(h.slice(4, 6), 16)
|
|
19539
|
+
};
|
|
19540
|
+
}
|
|
19541
|
+
const rgb = s.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);
|
|
19542
|
+
if (rgb) return { r: +rgb[1], g: +rgb[2], b: +rgb[3] };
|
|
19543
|
+
return null;
|
|
19544
|
+
}
|
|
19545
|
+
function buildOverlay(b, idx) {
|
|
19546
|
+
const c = parseColor(b.hintFill);
|
|
19547
|
+
const lum = c ? (0.299 * c.r + 0.587 * c.g + 0.114 * c.b) / 255 : 0.2;
|
|
19548
|
+
const isLightGlass = lum < 0.5;
|
|
19549
|
+
const baseFill = isLightGlass ? "rgba(245,245,245,0.68)" : "rgba(30,30,30,0.62)";
|
|
19550
|
+
return {
|
|
19551
|
+
id: `${OVERLAY_ID_PREFIX}${idx}`,
|
|
19552
|
+
type: "shape",
|
|
19553
|
+
shapeType: "rounded-rect",
|
|
19554
|
+
left: b.left,
|
|
19555
|
+
top: b.top,
|
|
19556
|
+
width: b.width,
|
|
19557
|
+
height: b.height,
|
|
19558
|
+
cornerRadius: 0,
|
|
19559
|
+
fill: baseFill,
|
|
19560
|
+
stroke: "transparent",
|
|
19561
|
+
strokeWidth: 0,
|
|
19562
|
+
opacity: 1,
|
|
19563
|
+
selectable: false,
|
|
19564
|
+
locked: true,
|
|
19565
|
+
visible: true,
|
|
19566
|
+
scaleX: 1,
|
|
19567
|
+
scaleY: 1
|
|
19568
|
+
};
|
|
19569
|
+
}
|
|
19570
|
+
function injectPreviewBlur(config, options) {
|
|
19571
|
+
const cloned = typeof structuredClone === "function" ? structuredClone(config) : JSON.parse(JSON.stringify(config));
|
|
19572
|
+
const extraBase = (options == null ? void 0 : options.extraElementBaseIds) && options.extraElementBaseIds.size > 0 ? options.extraElementBaseIds : void 0;
|
|
19573
|
+
const extraExact = (options == null ? void 0 : options.extraElementExactIds) && options.extraElementExactIds.size > 0 ? options.extraElementExactIds : void 0;
|
|
19574
|
+
let idx = 0;
|
|
19575
|
+
for (const page of cloned.pages || []) {
|
|
19576
|
+
const children = page.children || page.elements;
|
|
19577
|
+
if (!Array.isArray(children)) continue;
|
|
19578
|
+
const overlays = [];
|
|
19579
|
+
for (const child of children) {
|
|
19580
|
+
collectOverlays(child, 0, 0, false, extraBase, extraExact, overlays);
|
|
19581
|
+
}
|
|
19582
|
+
if (overlays.length === 0) continue;
|
|
19583
|
+
for (const b of overlays) {
|
|
19584
|
+
children.push(buildOverlay(b, idx++));
|
|
19585
|
+
}
|
|
19586
|
+
}
|
|
19587
|
+
return cloned;
|
|
19588
|
+
}
|
|
19589
|
+
function hasAnyPreviewBlur(config) {
|
|
19590
|
+
function walk(node) {
|
|
19591
|
+
if (!node || typeof node !== "object") return false;
|
|
19592
|
+
if (node.previewBlur === true) return true;
|
|
19593
|
+
const children = node.children || node.elements;
|
|
19594
|
+
if (Array.isArray(children)) {
|
|
19595
|
+
for (const c of children) if (walk(c)) return true;
|
|
19596
|
+
}
|
|
19597
|
+
return false;
|
|
19598
|
+
}
|
|
19599
|
+
for (const page of config.pages || []) if (walk(page)) return true;
|
|
19600
|
+
return false;
|
|
19601
|
+
}
|
|
19602
|
+
const previewBlur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
19603
|
+
__proto__: null,
|
|
19604
|
+
hasAnyPreviewBlur,
|
|
19605
|
+
injectPreviewBlur
|
|
19606
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
19432
19607
|
const SELECT_COLUMNS = "id,name,description,category,thumbnail_url,preview_images,price,download_count,workspace_id,sort_order,created_at,updated_at";
|
|
19433
19608
|
async function listPublishedTemplates(options) {
|
|
19434
19609
|
const { workspaceId, supabaseUrl, supabaseAnonKey, category, limit = 200, offset = 0 } = options;
|
|
@@ -19568,63 +19743,65 @@ function setAutoShrinkDebug(enabled) {
|
|
|
19568
19743
|
}
|
|
19569
19744
|
}
|
|
19570
19745
|
export {
|
|
19571
|
-
|
|
19746
|
+
resolveTemplateData as $,
|
|
19572
19747
|
API_URL as A,
|
|
19573
|
-
|
|
19574
|
-
|
|
19748
|
+
collectImageUrls as B,
|
|
19749
|
+
configHasAutoShrinkText$1 as C,
|
|
19575
19750
|
DEPLOYMENT_VERSION_MARKER as D,
|
|
19576
|
-
|
|
19751
|
+
dumpSvgTextDiagnostics as E,
|
|
19577
19752
|
FONT_FALLBACK_DEVANAGARI as F,
|
|
19578
|
-
|
|
19579
|
-
|
|
19580
|
-
|
|
19581
|
-
|
|
19582
|
-
|
|
19583
|
-
|
|
19584
|
-
|
|
19585
|
-
|
|
19586
|
-
|
|
19753
|
+
embedFont as G,
|
|
19754
|
+
embedFontsForConfig as H,
|
|
19755
|
+
embedFontsInPdf as I,
|
|
19756
|
+
ensureFontsForResolvedConfig as J,
|
|
19757
|
+
extractFontFamiliesFromSvgs as K,
|
|
19758
|
+
getEmbeddedJsPDFFontName as L,
|
|
19759
|
+
getPublishedTemplate as M,
|
|
19760
|
+
getTemplateForm as N,
|
|
19761
|
+
hasAnyPreviewBlur as O,
|
|
19587
19762
|
PACKAGE_VERSION as P,
|
|
19588
|
-
|
|
19589
|
-
|
|
19590
|
-
|
|
19763
|
+
injectPreviewBlur as Q,
|
|
19764
|
+
isBundledAssetUrl as R,
|
|
19765
|
+
isFontAvailable as S,
|
|
19591
19766
|
TRIANGLE_STROKE_MITER_LIMIT as T,
|
|
19592
|
-
|
|
19593
|
-
|
|
19594
|
-
|
|
19595
|
-
|
|
19596
|
-
|
|
19597
|
-
|
|
19598
|
-
|
|
19767
|
+
isPrivateUrl as U,
|
|
19768
|
+
listPublishedTemplates as V,
|
|
19769
|
+
loadGoogleFontCSS as W,
|
|
19770
|
+
normalizeFontFamily as X,
|
|
19771
|
+
resolveBlurElementExactIdsFromFlatFormKeys as Y,
|
|
19772
|
+
resolveFontWeight as Z,
|
|
19773
|
+
resolveFromForm as _,
|
|
19599
19774
|
getAbsoluteBounds as a,
|
|
19600
|
-
|
|
19601
|
-
|
|
19602
|
-
|
|
19603
|
-
|
|
19604
|
-
|
|
19775
|
+
rewriteSvgFontsForJsPDF as a0,
|
|
19776
|
+
setAutoShrinkDebug as a1,
|
|
19777
|
+
setBundledAssetPrefixes as a2,
|
|
19778
|
+
warmResolvedTemplateForPreview as a3,
|
|
19779
|
+
warmTemplateFromForm as a4,
|
|
19780
|
+
canvasImageLoader as a5,
|
|
19781
|
+
getProxiedImageUrl as b,
|
|
19605
19782
|
captureFabricCanvasSvgForPdf as c,
|
|
19606
|
-
|
|
19607
|
-
|
|
19783
|
+
bakeEdgeFade as d,
|
|
19784
|
+
isGroup as e,
|
|
19608
19785
|
findNodeById as f,
|
|
19609
19786
|
getCanvasForPage as g,
|
|
19610
19787
|
hasEdgeFade as h,
|
|
19611
19788
|
isElement as i,
|
|
19612
|
-
|
|
19613
|
-
|
|
19614
|
-
|
|
19615
|
-
|
|
19789
|
+
buildRoundedTrianglePath as j,
|
|
19790
|
+
getImageProxyFetchOptions as k,
|
|
19791
|
+
getRoundedRectRadii as l,
|
|
19792
|
+
getTrianglePoints as m,
|
|
19616
19793
|
normalizeShapeType as n,
|
|
19617
|
-
|
|
19794
|
+
FONT_FALLBACK_MATH as o,
|
|
19618
19795
|
parseTextMarkdown as p,
|
|
19619
|
-
|
|
19796
|
+
FONT_FALLBACK_SYMBOLS as q,
|
|
19620
19797
|
renderSmartElementToSvg as r,
|
|
19621
|
-
|
|
19622
|
-
|
|
19623
|
-
|
|
19624
|
-
|
|
19625
|
-
|
|
19626
|
-
|
|
19627
|
-
|
|
19628
|
-
|
|
19798
|
+
FONT_FILES as s,
|
|
19799
|
+
PixldocsPreview as t,
|
|
19800
|
+
PixldocsRenderer as u,
|
|
19801
|
+
applyThemeToConfig as v,
|
|
19802
|
+
assemblePdfFromSvgs as w,
|
|
19803
|
+
awaitFontsForConfig as x,
|
|
19804
|
+
collectFontDescriptorsFromConfig as y,
|
|
19805
|
+
collectFontsFromConfig as z
|
|
19629
19806
|
};
|
|
19630
|
-
//# sourceMappingURL=index-
|
|
19807
|
+
//# sourceMappingURL=index-C9H38u7P.js.map
|