@paprize/core 0.0.6 → 0.0.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/paprize-core.d.ts +18 -2
- package/dist/paprize-core.js +190 -163
- package/dist/paprize-core.js.map +1 -1
- package/dist/paprize-core.umd.cjs +5 -5
- package/dist/paprize-core.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/paprize-core.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
const
|
|
2
|
-
let
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
},
|
|
6
|
-
function
|
|
1
|
+
const me = "paprize", fe = "pz-temp-container", it = "pz-current-element", ot = "pz-current-text", rt = "pz-ignored-element", st = "pz-ignored-text", X = "paprize-global-style", U = "pz-page", _e = "pz-section", T = "pz-preview", C = "data-pz-";
|
|
2
|
+
let oe = !1;
|
|
3
|
+
const at = () => {
|
|
4
|
+
oe = !0;
|
|
5
|
+
}, ve = () => oe;
|
|
6
|
+
function re(i) {
|
|
7
7
|
return i.nodeType === Node.ELEMENT_NODE;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function be(i) {
|
|
10
10
|
return i.nodeType === Node.TEXT_NODE;
|
|
11
11
|
}
|
|
12
12
|
function $(i) {
|
|
13
13
|
const e = i.getBoundingClientRect(), t = getComputedStyle(i), n = parseFloat(t.marginTop) || 0, o = parseFloat(t.marginBottom) || 0;
|
|
14
14
|
return e.height + n + o;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function lt(i) {
|
|
17
17
|
i.style.visibility = "hidden", i.style.position = "absolute", i.style.left = "-9999px", i.style.top = "-9999px";
|
|
18
18
|
}
|
|
19
|
-
const
|
|
19
|
+
const se = {
|
|
20
20
|
hyphen: "-",
|
|
21
21
|
keepOnSamePage: !1,
|
|
22
22
|
hyphenationDisabled: !1
|
|
23
|
-
},
|
|
23
|
+
}, ae = {
|
|
24
24
|
hyphen: {
|
|
25
25
|
key: `${C}hyphen`,
|
|
26
26
|
reader: (i) => String(i)
|
|
@@ -34,52 +34,52 @@ const re = {
|
|
|
34
34
|
reader: (i) => i === "true"
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
function
|
|
37
|
+
function ct(i) {
|
|
38
38
|
const e = {};
|
|
39
39
|
for (const [t, n] of Object.entries(i)) {
|
|
40
|
-
const o =
|
|
40
|
+
const o = ae[t];
|
|
41
41
|
o !== void 0 && n !== void 0 && (e[o.key] = String(n));
|
|
42
42
|
}
|
|
43
43
|
return e;
|
|
44
44
|
}
|
|
45
45
|
const K = /* @__PURE__ */ new WeakMap();
|
|
46
|
-
function
|
|
46
|
+
function ye(i, e, t, n) {
|
|
47
47
|
if (t == null)
|
|
48
48
|
return;
|
|
49
49
|
const o = e(t);
|
|
50
50
|
o !== void 0 && (n[i] = o);
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function le(i) {
|
|
53
53
|
if (!i)
|
|
54
54
|
return {};
|
|
55
55
|
if (!(i instanceof Element))
|
|
56
|
-
return
|
|
56
|
+
return le(i?.parentNode);
|
|
57
57
|
const e = {};
|
|
58
|
-
for (const o of Object.keys(
|
|
59
|
-
const r = o, s =
|
|
60
|
-
|
|
58
|
+
for (const o of Object.keys(se)) {
|
|
59
|
+
const r = o, s = ae[r], d = i.getAttribute(s.key);
|
|
60
|
+
ye(r, s.reader, d, e);
|
|
61
61
|
}
|
|
62
62
|
const n = { ...i.parentNode ? K.get(i.parentNode) : void 0, ...e };
|
|
63
63
|
return K.set(i, n), n;
|
|
64
64
|
}
|
|
65
|
-
const
|
|
65
|
+
const ce = {
|
|
66
66
|
id: "default",
|
|
67
67
|
plugins: [],
|
|
68
|
-
...
|
|
68
|
+
...se
|
|
69
69
|
};
|
|
70
|
-
function
|
|
71
|
-
const t =
|
|
72
|
-
return { ...
|
|
70
|
+
function we(i, e) {
|
|
71
|
+
const t = le(i);
|
|
72
|
+
return { ...ce, ...e, ...t };
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function Se(i) {
|
|
75
75
|
return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
|
|
76
76
|
}
|
|
77
|
-
var O = { exports: {} },
|
|
78
|
-
function
|
|
77
|
+
var O = { exports: {} }, Ce = O.exports, Y;
|
|
78
|
+
function Ne() {
|
|
79
79
|
return Y || (Y = 1, (function(i) {
|
|
80
80
|
(function(e, t) {
|
|
81
81
|
i.exports ? i.exports = t() : e.log = t();
|
|
82
|
-
})(
|
|
82
|
+
})(Ce, function() {
|
|
83
83
|
var e = function() {
|
|
84
84
|
}, t = "undefined", n = typeof window !== t && typeof window.navigator !== t && /Trident\/|MSIE /.test(window.navigator.userAgent), o = [
|
|
85
85
|
"trace",
|
|
@@ -123,9 +123,9 @@ function Ce() {
|
|
|
123
123
|
return b(l) || _.apply(this, arguments);
|
|
124
124
|
}
|
|
125
125
|
function q(l, p) {
|
|
126
|
-
var a = this, R,
|
|
126
|
+
var a = this, R, j, y, m = "loglevel";
|
|
127
127
|
typeof l == "string" ? m += ":" + l : typeof l == "symbol" && (m = void 0);
|
|
128
|
-
function
|
|
128
|
+
function pe(c) {
|
|
129
129
|
var u = (o[c] || "silent").toUpperCase();
|
|
130
130
|
if (!(typeof window === t || !m)) {
|
|
131
131
|
try {
|
|
@@ -139,7 +139,7 @@ function Ce() {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function J() {
|
|
143
143
|
var c;
|
|
144
144
|
if (!(typeof window === t || !m)) {
|
|
145
145
|
try {
|
|
@@ -148,16 +148,16 @@ function Ce() {
|
|
|
148
148
|
}
|
|
149
149
|
if (typeof c === t)
|
|
150
150
|
try {
|
|
151
|
-
var u = window.document.cookie, H = encodeURIComponent(m),
|
|
152
|
-
|
|
153
|
-
u.slice(
|
|
151
|
+
var u = window.document.cookie, H = encodeURIComponent(m), Z = u.indexOf(H + "=");
|
|
152
|
+
Z !== -1 && (c = /^([^;]+)/.exec(
|
|
153
|
+
u.slice(Z + H.length + 1)
|
|
154
154
|
)[1]);
|
|
155
155
|
} catch {
|
|
156
156
|
}
|
|
157
157
|
return a.levels[c] === void 0 && (c = void 0), c;
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
function
|
|
160
|
+
function ue() {
|
|
161
161
|
if (!(typeof window === t || !m)) {
|
|
162
162
|
try {
|
|
163
163
|
window.localStorage.removeItem(m);
|
|
@@ -183,13 +183,13 @@ function Ce() {
|
|
|
183
183
|
ERROR: 4,
|
|
184
184
|
SILENT: 5
|
|
185
185
|
}, a.methodFactory = p || W, a.getLevel = function() {
|
|
186
|
-
return y ??
|
|
186
|
+
return y ?? j ?? R;
|
|
187
187
|
}, a.setLevel = function(c, u) {
|
|
188
|
-
return y = E(c), u !== !1 &&
|
|
188
|
+
return y = E(c), u !== !1 && pe(y), f.call(a);
|
|
189
189
|
}, a.setDefaultLevel = function(c) {
|
|
190
|
-
|
|
190
|
+
j = E(c), J() || a.setLevel(c, !1);
|
|
191
191
|
}, a.resetLevel = function() {
|
|
192
|
-
y = null,
|
|
192
|
+
y = null, ue(), f.call(a);
|
|
193
193
|
}, a.enableAll = function(c) {
|
|
194
194
|
a.setLevel(a.levels.TRACE, c);
|
|
195
195
|
}, a.disableAll = function(c) {
|
|
@@ -201,8 +201,8 @@ function Ce() {
|
|
|
201
201
|
}, R = E(
|
|
202
202
|
s ? s.getLevel() : "WARN"
|
|
203
203
|
);
|
|
204
|
-
var
|
|
205
|
-
|
|
204
|
+
var G = J();
|
|
205
|
+
G != null && (y = E(G)), f.call(a);
|
|
206
206
|
}
|
|
207
207
|
s = new q(), s.getLogger = function(p) {
|
|
208
208
|
if (typeof p != "symbol" && typeof p != "string" || p === "")
|
|
@@ -213,37 +213,37 @@ function Ce() {
|
|
|
213
213
|
s.methodFactory
|
|
214
214
|
)), a;
|
|
215
215
|
};
|
|
216
|
-
var
|
|
216
|
+
var ge = typeof window !== t ? window.log : void 0;
|
|
217
217
|
return s.noConflict = function() {
|
|
218
|
-
return typeof window !== t && window.log === s && (window.log =
|
|
218
|
+
return typeof window !== t && window.log === s && (window.log = ge), s;
|
|
219
219
|
}, s.getLoggers = function() {
|
|
220
220
|
return r;
|
|
221
221
|
}, s.default = s, s;
|
|
222
222
|
});
|
|
223
223
|
})(O)), O.exports;
|
|
224
224
|
}
|
|
225
|
-
var
|
|
226
|
-
const S = /* @__PURE__ */
|
|
225
|
+
var xe = Ne();
|
|
226
|
+
const S = /* @__PURE__ */ Se(xe), g = S.getLogger(me);
|
|
227
227
|
g.setDefaultLevel("info");
|
|
228
|
-
const
|
|
228
|
+
const M = "\x1B[46mPLUGIN\x1B[0m";
|
|
229
229
|
function N(i, e, ...t) {
|
|
230
230
|
i.sort((n, o) => n.order - o.order).forEach((n) => {
|
|
231
231
|
const o = n[e];
|
|
232
232
|
if (o) {
|
|
233
233
|
g.debug(
|
|
234
|
-
|
|
234
|
+
M,
|
|
235
235
|
`executing plugin ${n.name}:${String(e)} ()`,
|
|
236
236
|
t
|
|
237
237
|
);
|
|
238
238
|
try {
|
|
239
239
|
o(...t), g.debug(
|
|
240
|
-
|
|
240
|
+
M,
|
|
241
241
|
`plugin ${n.name}:${String(e)} executed`,
|
|
242
242
|
t
|
|
243
243
|
);
|
|
244
244
|
} catch (r) {
|
|
245
245
|
g.debug(
|
|
246
|
-
|
|
246
|
+
M,
|
|
247
247
|
`plugin ${n.name}:${String(e)} failed`,
|
|
248
248
|
r
|
|
249
249
|
);
|
|
@@ -309,7 +309,7 @@ class F {
|
|
|
309
309
|
return this._node;
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
|
-
class
|
|
312
|
+
class Pe {
|
|
313
313
|
_node;
|
|
314
314
|
type = x.Text;
|
|
315
315
|
transaction;
|
|
@@ -333,14 +333,14 @@ class xe {
|
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
function z(i, e, t) {
|
|
336
|
-
if (
|
|
337
|
-
return new
|
|
338
|
-
if (
|
|
336
|
+
if (be(i))
|
|
337
|
+
return new Pe(i, e, t);
|
|
338
|
+
if (re(i))
|
|
339
339
|
return new F(i, e, t);
|
|
340
340
|
throw new Error("Unsupported node type");
|
|
341
341
|
}
|
|
342
342
|
const k = "\x1B[106mDOM\x1B[0m";
|
|
343
|
-
class
|
|
343
|
+
class Ee {
|
|
344
344
|
_transaction;
|
|
345
345
|
_treeWalker;
|
|
346
346
|
_config;
|
|
@@ -385,14 +385,14 @@ class Pe {
|
|
|
385
385
|
this._previousNode = this._currentNode, this._currentNode = z(
|
|
386
386
|
this._treeWalker.currentNode,
|
|
387
387
|
this._transaction,
|
|
388
|
-
|
|
388
|
+
we(this._treeWalker.currentNode, this._config)
|
|
389
389
|
), g.debug(k, "moved to node", {
|
|
390
390
|
currentNode: this._currentNode,
|
|
391
391
|
previousNode: this._previousNode
|
|
392
392
|
});
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
|
-
class
|
|
395
|
+
class Te {
|
|
396
396
|
_onRollback;
|
|
397
397
|
_onCommit;
|
|
398
398
|
isActive;
|
|
@@ -564,7 +564,7 @@ const h = {
|
|
|
564
564
|
SplitChildren: 2
|
|
565
565
|
// The node is too large for the page, and its children must be paginated individually.
|
|
566
566
|
};
|
|
567
|
-
function
|
|
567
|
+
function ke(i, e) {
|
|
568
568
|
const t = ee(i, e);
|
|
569
569
|
if (t !== h.None)
|
|
570
570
|
return t;
|
|
@@ -586,17 +586,17 @@ function ee(i, e) {
|
|
|
586
586
|
const t = e.appendChild(i, !1);
|
|
587
587
|
return e.isOverFlow() ? (t.remove(), h.None) : h.SplitChildren;
|
|
588
588
|
}
|
|
589
|
-
function
|
|
589
|
+
function Ae(i, e) {
|
|
590
590
|
let t = h.FullNodePlaced;
|
|
591
591
|
const n = i.textContent.split(/(\s+)/).filter((s) => s !== "");
|
|
592
592
|
let o, r = 0;
|
|
593
593
|
for (; o || r < n.length; ) {
|
|
594
|
-
const s = o ?? n[r], d =
|
|
594
|
+
const s = o ?? n[r], d = Le(s, e, i.config);
|
|
595
595
|
d.completed || (t = h.None), d.pendingToken ? o = d.pendingToken : (o = void 0, r++);
|
|
596
596
|
}
|
|
597
597
|
return t;
|
|
598
598
|
}
|
|
599
|
-
function
|
|
599
|
+
function Le(i, e, t) {
|
|
600
600
|
e.hasEmptySpace() || e.nextPage();
|
|
601
601
|
const n = e.addTextNode(""), o = n.textContent;
|
|
602
602
|
if (n.textContent += i, !e.isOverFlow())
|
|
@@ -604,13 +604,13 @@ function Ae(i, e, t) {
|
|
|
604
604
|
completed: !0
|
|
605
605
|
};
|
|
606
606
|
n.textContent = o;
|
|
607
|
-
const r =
|
|
607
|
+
const r = Fe(i, e, t);
|
|
608
608
|
return {
|
|
609
609
|
pendingToken: r.leftovers,
|
|
610
610
|
completed: r.completed
|
|
611
611
|
};
|
|
612
612
|
}
|
|
613
|
-
function
|
|
613
|
+
function Fe(i, e, t) {
|
|
614
614
|
const { rollback: n, commit: o } = e.startTransaction();
|
|
615
615
|
if (e.nextPage(), e.addTextNode(i), !e.isOverFlow())
|
|
616
616
|
return o(), {
|
|
@@ -620,13 +620,13 @@ function Le(i, e, t) {
|
|
|
620
620
|
return g.warn("Hyphenation disabled, skipping oversized token:", i), {
|
|
621
621
|
completed: !1
|
|
622
622
|
};
|
|
623
|
-
const r =
|
|
623
|
+
const r = Ie(i, t.hyphen, e);
|
|
624
624
|
return {
|
|
625
625
|
completed: !0,
|
|
626
626
|
leftovers: r && r.length > 0 ? r : void 0
|
|
627
627
|
};
|
|
628
628
|
}
|
|
629
|
-
function
|
|
629
|
+
function Ie(i, e, t) {
|
|
630
630
|
const n = t.addTextNode("");
|
|
631
631
|
let o = "";
|
|
632
632
|
for (let r = 0; r < i.length; r++) {
|
|
@@ -645,7 +645,7 @@ class B {
|
|
|
645
645
|
_tempContainer;
|
|
646
646
|
_config;
|
|
647
647
|
constructor(e, t, n) {
|
|
648
|
-
this._config = { ...
|
|
648
|
+
this._config = { ...ce, ...n }, this._tempContainer = B.createTempContainer(this._config.id), this._transaction = new Te(), this._domState = new Ee(e, this._transaction, this._config), this._pageManager = new V(
|
|
649
649
|
this._tempContainer,
|
|
650
650
|
t,
|
|
651
651
|
this._transaction,
|
|
@@ -654,11 +654,11 @@ class B {
|
|
|
654
654
|
}
|
|
655
655
|
static createTempContainer(e) {
|
|
656
656
|
const t = document.createElement("div");
|
|
657
|
-
return t.style.display = "flex", t.style.flexDirection = "column", t.style.gap = "20px", t.setAttribute(`${C}-section-id`, e), t.classList.add(
|
|
657
|
+
return t.style.display = "flex", t.style.flexDirection = "column", t.style.gap = "20px", t.setAttribute(`${C}-section-id`, e), t.classList.add(fe), document.body.appendChild(t), t;
|
|
658
658
|
}
|
|
659
659
|
static paginate(e, t, n) {
|
|
660
660
|
const o = new B(e, t, n);
|
|
661
|
-
return o.processAllNodes(), Array.from(o._tempContainer.childNodes).filter((s) =>
|
|
661
|
+
return o.processAllNodes(), Array.from(o._tempContainer.childNodes).filter((s) => re(s)).map((s) => s.innerHTML);
|
|
662
662
|
}
|
|
663
663
|
processAllNodes() {
|
|
664
664
|
this._domState.goToNextNode();
|
|
@@ -717,7 +717,7 @@ class B {
|
|
|
717
717
|
this._domState,
|
|
718
718
|
this._pageManager,
|
|
719
719
|
e
|
|
720
|
-
), e.result !== void 0 ? e.result :
|
|
720
|
+
), e.result !== void 0 ? e.result : ke(
|
|
721
721
|
this._domState.currentNode,
|
|
722
722
|
this._pageManager
|
|
723
723
|
);
|
|
@@ -730,14 +730,14 @@ class B {
|
|
|
730
730
|
this._domState,
|
|
731
731
|
this._pageManager,
|
|
732
732
|
e
|
|
733
|
-
), e.result !== void 0 ? e.result :
|
|
733
|
+
), e.result !== void 0 ? e.result : Ae(
|
|
734
734
|
this._domState.currentNode,
|
|
735
735
|
this._pageManager
|
|
736
736
|
);
|
|
737
737
|
}
|
|
738
738
|
}
|
|
739
739
|
}
|
|
740
|
-
class
|
|
740
|
+
class de {
|
|
741
741
|
registry = /* @__PURE__ */ new Map();
|
|
742
742
|
addEventListener(e, t) {
|
|
743
743
|
const { registry: n } = this, o = new Set(n.get(e));
|
|
@@ -747,14 +747,14 @@ class ce {
|
|
|
747
747
|
const { registry: n } = this, o = new Set(n.get(e));
|
|
748
748
|
o.delete(t), n.set(e, o);
|
|
749
749
|
}
|
|
750
|
-
dispatch(e, ...t) {
|
|
750
|
+
async dispatch(e, ...t) {
|
|
751
751
|
const { registry: n } = this, o = n.get(e);
|
|
752
752
|
if (o)
|
|
753
753
|
for (const r of o)
|
|
754
|
-
r(...t);
|
|
754
|
+
await r(...t);
|
|
755
755
|
}
|
|
756
756
|
}
|
|
757
|
-
const
|
|
757
|
+
const dt = {
|
|
758
758
|
/** 841mm x 594mm */
|
|
759
759
|
A1: { height: "841mm", width: "594mm" },
|
|
760
760
|
/** 594mm x 420mm */
|
|
@@ -779,7 +779,7 @@ const at = {
|
|
|
779
779
|
Legal: { height: "11in", width: "8.5in" },
|
|
780
780
|
/** 11in x 17in */
|
|
781
781
|
Tabloid: { height: "11in", width: "17in" }
|
|
782
|
-
},
|
|
782
|
+
}, Re = {
|
|
783
783
|
/** Top, Right, Bottom, Left: 1in */
|
|
784
784
|
Normal: {
|
|
785
785
|
top: "1in",
|
|
@@ -808,19 +808,19 @@ const at = {
|
|
|
808
808
|
bottom: "0in",
|
|
809
809
|
left: "0in"
|
|
810
810
|
}
|
|
811
|
-
};
|
|
812
|
-
function
|
|
811
|
+
}, He = "__PAPRIZE_IS_INITIALIZED", te = "__PAPRIZE_IS_READY", ne = "__PAPRIZE_READ_JSON_DATA_FILE";
|
|
812
|
+
function Oe(i) {
|
|
813
813
|
const e = i.getBoundingClientRect(), t = getComputedStyle(i), n = parseFloat(t.marginLeft) || 0, o = parseFloat(t.marginRight) || 0;
|
|
814
814
|
return {
|
|
815
815
|
height: $(i),
|
|
816
816
|
width: e.width + n + o
|
|
817
817
|
};
|
|
818
818
|
}
|
|
819
|
-
function
|
|
820
|
-
const { height: n, width: o } =
|
|
819
|
+
function $e(i, e, t) {
|
|
820
|
+
const { height: n, width: o } = Oe(i), r = e ? $(e) : 0, s = t ? $(t) : 0;
|
|
821
821
|
return { height: n, width: o, sectionHeaderHeight: r, sectionFooterHeight: s };
|
|
822
822
|
}
|
|
823
|
-
function
|
|
823
|
+
function ze(i, e, t) {
|
|
824
824
|
return {
|
|
825
825
|
name: "sectionPageHeight",
|
|
826
826
|
order: 1,
|
|
@@ -833,10 +833,20 @@ function Oe(i, e, t) {
|
|
|
833
833
|
}
|
|
834
834
|
};
|
|
835
835
|
}
|
|
836
|
-
function
|
|
836
|
+
function Be(i) {
|
|
837
837
|
return i ? `${i.top} ${i.right} ${i.bottom} ${i.left}` : "0";
|
|
838
838
|
}
|
|
839
|
-
|
|
839
|
+
function De(i) {
|
|
840
|
+
let e = null;
|
|
841
|
+
return () => (e || (e = i()), e);
|
|
842
|
+
}
|
|
843
|
+
async function We() {
|
|
844
|
+
if (!(ne in window))
|
|
845
|
+
return null;
|
|
846
|
+
const i = await window[ne]?.();
|
|
847
|
+
return i ? JSON.parse(i) : null;
|
|
848
|
+
}
|
|
849
|
+
const je = `
|
|
840
850
|
html {
|
|
841
851
|
box-sizing: border-box;
|
|
842
852
|
}
|
|
@@ -876,7 +886,7 @@ const ze = `
|
|
|
876
886
|
background-color: var(--paprize-page-background-color);
|
|
877
887
|
}
|
|
878
888
|
|
|
879
|
-
.${
|
|
889
|
+
.${_e} {
|
|
880
890
|
margin-bottom: var(--paprize-section-margin-bottom);
|
|
881
891
|
}
|
|
882
892
|
}
|
|
@@ -886,37 +896,37 @@ const ze = `
|
|
|
886
896
|
display: none !important;
|
|
887
897
|
}
|
|
888
898
|
}
|
|
889
|
-
`,
|
|
899
|
+
`, Me = {
|
|
890
900
|
display: "flex",
|
|
891
901
|
flexDirection: "column"
|
|
892
|
-
},
|
|
902
|
+
}, Ue = {
|
|
893
903
|
position: "absolute",
|
|
894
904
|
left: "-9999px",
|
|
895
905
|
top: "-9999px",
|
|
896
906
|
visibility: "hidden"
|
|
897
|
-
},
|
|
907
|
+
}, Ve = (i, e) => ({
|
|
898
908
|
display: "flex",
|
|
899
909
|
flexDirection: "column",
|
|
900
910
|
width: i.width,
|
|
901
911
|
height: i.height,
|
|
902
912
|
maxHeight: i.height,
|
|
903
913
|
position: "relative",
|
|
904
|
-
padding:
|
|
914
|
+
padding: Be(e),
|
|
905
915
|
zIndex: "1"
|
|
906
|
-
}),
|
|
916
|
+
}), qe = {
|
|
907
917
|
overflow: "hidden",
|
|
908
918
|
width: "100%",
|
|
909
919
|
height: "100%"
|
|
910
|
-
},
|
|
920
|
+
}, Je = {
|
|
911
921
|
position: "absolute",
|
|
912
922
|
width: "100%",
|
|
913
923
|
height: "100%",
|
|
914
924
|
left: 0,
|
|
915
925
|
top: 0
|
|
916
|
-
},
|
|
926
|
+
}, Ge = (i) => ({
|
|
917
927
|
page: `section-${i}`
|
|
918
928
|
});
|
|
919
|
-
function
|
|
929
|
+
function Ze(i, e) {
|
|
920
930
|
return `@page section-${i} {
|
|
921
931
|
margin: none;
|
|
922
932
|
size:${e.width} ${e.height};
|
|
@@ -925,19 +935,19 @@ function Ve(i, e) {
|
|
|
925
935
|
}`;
|
|
926
936
|
}
|
|
927
937
|
const v = {
|
|
928
|
-
globalStyle:
|
|
929
|
-
component:
|
|
930
|
-
outOfScreen:
|
|
931
|
-
page:
|
|
932
|
-
overlay:
|
|
933
|
-
pageContent:
|
|
934
|
-
sectionPageMedia:
|
|
935
|
-
section:
|
|
938
|
+
globalStyle: je,
|
|
939
|
+
component: Me,
|
|
940
|
+
outOfScreen: Ue,
|
|
941
|
+
page: Ve,
|
|
942
|
+
overlay: Je,
|
|
943
|
+
pageContent: qe,
|
|
944
|
+
sectionPageMedia: Ze,
|
|
945
|
+
section: Ge
|
|
936
946
|
};
|
|
937
947
|
function L(i) {
|
|
938
948
|
return i?.cloneNode(!0) ?? null;
|
|
939
949
|
}
|
|
940
|
-
function
|
|
950
|
+
function Xe(i) {
|
|
941
951
|
return {
|
|
942
952
|
sectionHeader: L(i.sectionHeader),
|
|
943
953
|
sectionFooter: L(i.sectionFooter),
|
|
@@ -946,15 +956,15 @@ function qe(i) {
|
|
|
946
956
|
pageContent: L(i.pageContent)
|
|
947
957
|
};
|
|
948
958
|
}
|
|
949
|
-
const
|
|
950
|
-
class
|
|
959
|
+
const Ke = "data-pz-page-break";
|
|
960
|
+
class Ye {
|
|
951
961
|
name = "pageBreak";
|
|
952
962
|
order = 1;
|
|
953
963
|
onVisitElement = (e, t, n, o) => {
|
|
954
|
-
t.currentNode.getNode().getAttribute(
|
|
964
|
+
t.currentNode.getNode().getAttribute(Ke) === "true" && (n.markPageAsFull(), o.result = h.FullNodePlaced);
|
|
955
965
|
};
|
|
956
966
|
}
|
|
957
|
-
class
|
|
967
|
+
class Qe {
|
|
958
968
|
_options = {};
|
|
959
969
|
name = "table";
|
|
960
970
|
order = 1;
|
|
@@ -1021,10 +1031,10 @@ class Je {
|
|
|
1021
1031
|
return n.cells.length !== 1 ? !1 : n.cells[0].textContent.trim() === "";
|
|
1022
1032
|
}
|
|
1023
1033
|
}
|
|
1024
|
-
const
|
|
1025
|
-
new
|
|
1026
|
-
new
|
|
1027
|
-
],
|
|
1034
|
+
const et = [
|
|
1035
|
+
new Ye(),
|
|
1036
|
+
new Qe()
|
|
1037
|
+
], gt = {
|
|
1028
1038
|
name: "debug",
|
|
1029
1039
|
order: Number.MAX_SAFE_INTEGER,
|
|
1030
1040
|
onNewPage: (i, e) => {
|
|
@@ -1034,9 +1044,9 @@ const Xe = [
|
|
|
1034
1044
|
e.getPageState().pageHeight.toString()
|
|
1035
1045
|
);
|
|
1036
1046
|
}
|
|
1037
|
-
},
|
|
1038
|
-
class
|
|
1039
|
-
name =
|
|
1047
|
+
}, tt = "sectionToc";
|
|
1048
|
+
class pt {
|
|
1049
|
+
name = tt;
|
|
1040
1050
|
order = 1;
|
|
1041
1051
|
_state = /* @__PURE__ */ new Map();
|
|
1042
1052
|
getContentList = () => Array.from(this._state.values()).flat();
|
|
@@ -1058,7 +1068,6 @@ class ct {
|
|
|
1058
1068
|
return /^H[1-6]$/.test(t) ? parseInt(t.charAt(1), 10) : null;
|
|
1059
1069
|
}
|
|
1060
1070
|
}
|
|
1061
|
-
const Ye = "__PAPRIZE_IS_INITIALIZED", te = "__PAPRIZE_IS_READY", dt = "__PAPRIZE_READ_JSON_DATA_FILE";
|
|
1062
1071
|
class D {
|
|
1063
1072
|
_promises;
|
|
1064
1073
|
monitor;
|
|
@@ -1069,7 +1078,7 @@ class D {
|
|
|
1069
1078
|
) : Promise.resolve();
|
|
1070
1079
|
}
|
|
1071
1080
|
constructor() {
|
|
1072
|
-
this._promises = [], this.monitor = new
|
|
1081
|
+
this._promises = [], this.monitor = new de();
|
|
1073
1082
|
}
|
|
1074
1083
|
async add(e = []) {
|
|
1075
1084
|
if (this._promises.push(...e.map(D.toTracked)), await new Promise((t) => setTimeout(t, 0)), this.getPending().length === 0) {
|
|
@@ -1099,21 +1108,21 @@ class D {
|
|
|
1099
1108
|
);
|
|
1100
1109
|
}
|
|
1101
1110
|
}
|
|
1102
|
-
function
|
|
1111
|
+
function ut(i, e) {
|
|
1103
1112
|
return `${i}-${e + 1}`;
|
|
1104
1113
|
}
|
|
1105
|
-
function
|
|
1114
|
+
function nt(i, e) {
|
|
1106
1115
|
return e === "landscape" ? { height: i.width, width: i.height } : i;
|
|
1107
1116
|
}
|
|
1108
1117
|
const w = "\x1B[43mREPORT\x1B[0m";
|
|
1109
|
-
class
|
|
1118
|
+
class ht {
|
|
1110
1119
|
_sections;
|
|
1111
1120
|
_monitor;
|
|
1112
1121
|
_paginationInProgress;
|
|
1113
1122
|
_pendingPaginateResolvers;
|
|
1114
1123
|
_currentAbortController;
|
|
1115
1124
|
constructor() {
|
|
1116
|
-
this._sections = /* @__PURE__ */ new Map(), this._monitor = new
|
|
1125
|
+
this._sections = /* @__PURE__ */ new Map(), this._monitor = new de(), this._paginationInProgress = !1, this._pendingPaginateResolvers = [], this._currentAbortController = null, window[He] = !0, this._injectStyle(v.globalStyle);
|
|
1117
1126
|
}
|
|
1118
1127
|
/**
|
|
1119
1128
|
* Monitor instance used to subscribe to pagination events.
|
|
@@ -1136,7 +1145,7 @@ class pt {
|
|
|
1136
1145
|
* @param onPaginationCompleted - Callback invoked when pagination for the section is completed.
|
|
1137
1146
|
* @returns `true` if the section was added to the report’s section list, or `false` if it already exists.
|
|
1138
1147
|
*/
|
|
1139
|
-
tryAddSection(e, t, n) {
|
|
1148
|
+
async tryAddSection(e, t, n) {
|
|
1140
1149
|
if (this._sections.has(e.id))
|
|
1141
1150
|
return !1;
|
|
1142
1151
|
const o = {
|
|
@@ -1150,7 +1159,7 @@ class pt {
|
|
|
1150
1159
|
context: o,
|
|
1151
1160
|
options: {
|
|
1152
1161
|
...e,
|
|
1153
|
-
size:
|
|
1162
|
+
size: nt(
|
|
1154
1163
|
e.size,
|
|
1155
1164
|
e.orientation ?? "portrait"
|
|
1156
1165
|
)
|
|
@@ -1159,7 +1168,7 @@ class pt {
|
|
|
1159
1168
|
onPaginationCompleted: n
|
|
1160
1169
|
}), this._injectStyle(
|
|
1161
1170
|
v.sectionPageMedia(e.id, e.size)
|
|
1162
|
-
), this._monitor.dispatch("sectionCreated", o), !0;
|
|
1171
|
+
), await this._monitor.dispatch("sectionCreated", o), !0;
|
|
1163
1172
|
}
|
|
1164
1173
|
/**
|
|
1165
1174
|
* Schedules a pagination operation.
|
|
@@ -1189,6 +1198,24 @@ class pt {
|
|
|
1189
1198
|
this._pendingPaginateResolvers.push({ resolve: e, reject: t });
|
|
1190
1199
|
}) : this._executePagination());
|
|
1191
1200
|
}
|
|
1201
|
+
/**
|
|
1202
|
+
* Retrieves JSON data injected by **@paprize/puppeteer** during server-side rendering (SSR).
|
|
1203
|
+
*
|
|
1204
|
+
* If no injected data is available, the function returns the provided `defaultData`, or `null` if none is given.
|
|
1205
|
+
*
|
|
1206
|
+
* ⚠️ **Important Notes:**
|
|
1207
|
+
* - This function is **not type-safe** — it performs **no runtime type validation** on the returned data.
|
|
1208
|
+
* - It is available **only during server-side rendering** when using **@paprize/puppeteer**.
|
|
1209
|
+
* - When used in **client-side rendering** or **development** mode, you should provide a `defaultData` value for testing purposes.
|
|
1210
|
+
*
|
|
1211
|
+
* @template T - The expected type of the injected JSON data.
|
|
1212
|
+
* @param defaultData - Optional fallback value to return if no injected data is found.
|
|
1213
|
+
* @returns A promise resolving to the injected JSON data if available, otherwise the provided default value or `null`.
|
|
1214
|
+
*/
|
|
1215
|
+
async getJsonData(e) {
|
|
1216
|
+
return await this._lazyJsonDataReader().catch(() => e) ?? e ?? null;
|
|
1217
|
+
}
|
|
1218
|
+
_lazyJsonDataReader = De(We);
|
|
1192
1219
|
async _executePagination() {
|
|
1193
1220
|
this._paginationInProgress = !0, this._currentAbortController = new AbortController();
|
|
1194
1221
|
const e = this._currentAbortController.signal;
|
|
@@ -1214,8 +1241,8 @@ class pt {
|
|
|
1214
1241
|
}), t.push(r);
|
|
1215
1242
|
}
|
|
1216
1243
|
const n = new D();
|
|
1217
|
-
return n.monitor.addEventListener("onChange", () => {
|
|
1218
|
-
g.debug(w, "Report pagination completed."), this._monitor.dispatch("paginationCycleCompleted", {
|
|
1244
|
+
return n.monitor.addEventListener("onChange", async () => {
|
|
1245
|
+
g.debug(w, "Report pagination completed."), await this._monitor.dispatch("paginationCycleCompleted", {
|
|
1219
1246
|
sections: [...this._sections.values()].map(
|
|
1220
1247
|
(o) => o.context
|
|
1221
1248
|
)
|
|
@@ -1257,10 +1284,10 @@ class pt {
|
|
|
1257
1284
|
t.style,
|
|
1258
1285
|
v.page(
|
|
1259
1286
|
e.options.size,
|
|
1260
|
-
e.options.margin ??
|
|
1287
|
+
e.options.margin ?? Re.None
|
|
1261
1288
|
)
|
|
1262
|
-
),
|
|
1263
|
-
const n =
|
|
1289
|
+
), ve() || Object.assign(t.style, v.outOfScreen);
|
|
1290
|
+
const n = Xe(e.components);
|
|
1264
1291
|
n.sectionHeader && (Object.assign(
|
|
1265
1292
|
n.sectionHeader.style,
|
|
1266
1293
|
v.component
|
|
@@ -1268,7 +1295,7 @@ class pt {
|
|
|
1268
1295
|
n.sectionFooter.style,
|
|
1269
1296
|
v.component
|
|
1270
1297
|
), t.appendChild(n.sectionFooter)), document.body.appendChild(t);
|
|
1271
|
-
const { height: o, width: r, sectionHeaderHeight: s, sectionFooterHeight: d } =
|
|
1298
|
+
const { height: o, width: r, sectionHeaderHeight: s, sectionFooterHeight: d } = $e(
|
|
1272
1299
|
n.pageContent,
|
|
1273
1300
|
n.sectionHeader,
|
|
1274
1301
|
n.sectionFooter
|
|
@@ -1278,8 +1305,8 @@ class pt {
|
|
|
1278
1305
|
{
|
|
1279
1306
|
id: e.options.id,
|
|
1280
1307
|
plugins: [
|
|
1281
|
-
...e.options.plugins ??
|
|
1282
|
-
|
|
1308
|
+
...e.options.plugins ?? et,
|
|
1309
|
+
ze(
|
|
1283
1310
|
o,
|
|
1284
1311
|
s,
|
|
1285
1312
|
d
|
|
@@ -1296,7 +1323,7 @@ class pt {
|
|
|
1296
1323
|
}));
|
|
1297
1324
|
e.onPaginationCompleted(b);
|
|
1298
1325
|
for (const _ of b)
|
|
1299
|
-
this._monitor.dispatch("pageCompleted", _);
|
|
1326
|
+
await this._monitor.dispatch("pageCompleted", _);
|
|
1300
1327
|
const f = {
|
|
1301
1328
|
...e.context,
|
|
1302
1329
|
isPaginated: !0,
|
|
@@ -1306,10 +1333,10 @@ class pt {
|
|
|
1306
1333
|
this._sections.set(e.options.id, {
|
|
1307
1334
|
...e,
|
|
1308
1335
|
context: f
|
|
1309
|
-
}), this._monitor.dispatch("sectionCompleted", f);
|
|
1336
|
+
}), await this._monitor.dispatch("sectionCompleted", f);
|
|
1310
1337
|
}
|
|
1311
1338
|
}
|
|
1312
|
-
const
|
|
1339
|
+
const ie = [
|
|
1313
1340
|
"ad",
|
|
1314
1341
|
"adipisicing",
|
|
1315
1342
|
"aliqua",
|
|
@@ -1373,59 +1400,59 @@ const ne = [
|
|
|
1373
1400
|
"veniam",
|
|
1374
1401
|
"voluptate"
|
|
1375
1402
|
];
|
|
1376
|
-
function
|
|
1403
|
+
function mt(i, e) {
|
|
1377
1404
|
if (i <= 0)
|
|
1378
1405
|
return "";
|
|
1379
1406
|
const t = [], n = Math.floor(e * 982451653);
|
|
1380
1407
|
for (let o = 0; o < i; o++) {
|
|
1381
1408
|
const r = (n + o * 2654435761) % Math.pow(2, 32), s = Math.floor(
|
|
1382
|
-
r / Math.pow(2, 32) *
|
|
1409
|
+
r / Math.pow(2, 32) * ie.length
|
|
1383
1410
|
);
|
|
1384
|
-
t.push(
|
|
1411
|
+
t.push(ie[s]);
|
|
1385
1412
|
}
|
|
1386
1413
|
return t.length > 0 && (t[0] = t[0].charAt(0).toUpperCase() + t[0].slice(1)), t.join(" ") + ".";
|
|
1387
1414
|
}
|
|
1388
1415
|
export {
|
|
1389
|
-
|
|
1390
|
-
|
|
1416
|
+
de as EventDispatcher,
|
|
1417
|
+
Ye as PageBreakPlugin,
|
|
1391
1418
|
B as Paginator,
|
|
1392
|
-
|
|
1393
|
-
|
|
1419
|
+
ht as ReportBuilder,
|
|
1420
|
+
pt as SectionTocPlugin,
|
|
1394
1421
|
h as SplitResult,
|
|
1395
|
-
|
|
1396
|
-
|
|
1422
|
+
Qe as TablePlugin,
|
|
1423
|
+
nt as adjustPageSize,
|
|
1397
1424
|
C as attributePrefix,
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1425
|
+
ut as buildPageId,
|
|
1426
|
+
Xe as cloneComponents,
|
|
1427
|
+
mt as createLoremIpsumParagraph,
|
|
1428
|
+
it as currentElementClassName,
|
|
1429
|
+
ot as currentTextClassName,
|
|
1430
|
+
gt as debugPlugin,
|
|
1431
|
+
et as defaultPlugins,
|
|
1432
|
+
at as enableDebugMode,
|
|
1406
1433
|
$ as getVisibleHeight,
|
|
1407
|
-
|
|
1434
|
+
je as globalStyle,
|
|
1408
1435
|
X as globalStyleId,
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1436
|
+
rt as ignoredElementClassName,
|
|
1437
|
+
st as ignoredTextClassName,
|
|
1438
|
+
ve as isDebugMode,
|
|
1439
|
+
re as isElement,
|
|
1440
|
+
be as isTextNode,
|
|
1441
|
+
ct as layoutOptionsToAttributes,
|
|
1415
1442
|
g as logger,
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1443
|
+
me as loggerName,
|
|
1444
|
+
lt as moveOffscreen,
|
|
1445
|
+
Ke as pageBreakAttributeName,
|
|
1419
1446
|
U as pageClassName,
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1447
|
+
Re as pageMargin,
|
|
1448
|
+
dt as pageSize,
|
|
1449
|
+
He as paprize_isInitialized,
|
|
1423
1450
|
te as paprize_isReady,
|
|
1424
|
-
|
|
1451
|
+
ne as paprize_readJsonDataFile,
|
|
1425
1452
|
T as previewClassName,
|
|
1426
1453
|
v as reportStyles,
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1454
|
+
_e as sectionClassName,
|
|
1455
|
+
tt as sectionTocName,
|
|
1456
|
+
fe as tempContainerClassName
|
|
1430
1457
|
};
|
|
1431
1458
|
//# sourceMappingURL=paprize-core.js.map
|