@paprize/core 0.0.5 → 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/README.md +1 -1
- package/dist/paprize-core.d.ts +308 -133
- package/dist/paprize-core.js +382 -296
- package/dist/paprize-core.js.map +1 -1
- package/dist/paprize-core.umd.cjs +7 -7
- package/dist/paprize-core.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/paprize-core.js
CHANGED
|
@@ -1,98 +1,85 @@
|
|
|
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
|
-
function
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
(n) => n === "true",
|
|
36
|
-
t
|
|
37
|
-
);
|
|
19
|
+
const se = {
|
|
20
|
+
hyphen: "-",
|
|
21
|
+
keepOnSamePage: !1,
|
|
22
|
+
hyphenationDisabled: !1
|
|
23
|
+
}, ae = {
|
|
24
|
+
hyphen: {
|
|
25
|
+
key: `${C}hyphen`,
|
|
26
|
+
reader: (i) => String(i)
|
|
27
|
+
},
|
|
28
|
+
keepOnSamePage: {
|
|
29
|
+
key: `${C}keep-on-same-page`,
|
|
30
|
+
reader: (i) => i === "true"
|
|
31
|
+
},
|
|
32
|
+
hyphenationDisabled: {
|
|
33
|
+
key: `${C}hyphenation-disabled`,
|
|
34
|
+
reader: (i) => i === "true"
|
|
38
35
|
}
|
|
39
|
-
}
|
|
40
|
-
const B = {
|
|
41
|
-
hyphen: C.createStr("hyphen", "-"),
|
|
42
|
-
keepOnSamePage: C.createBool("keep-on-same-page", !1),
|
|
43
|
-
hyphenationEnabled: C.createBool(
|
|
44
|
-
"hyphenation-enabled",
|
|
45
|
-
!0
|
|
46
|
-
)
|
|
47
36
|
};
|
|
48
|
-
function
|
|
37
|
+
function ct(i) {
|
|
49
38
|
const e = {};
|
|
50
|
-
for (const t
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
const o = B[t];
|
|
54
|
-
e[`${F}${o.name}`] = String(n);
|
|
55
|
-
}
|
|
39
|
+
for (const [t, n] of Object.entries(i)) {
|
|
40
|
+
const o = ae[t];
|
|
41
|
+
o !== void 0 && n !== void 0 && (e[o.key] = String(n));
|
|
56
42
|
}
|
|
57
43
|
return e;
|
|
58
44
|
}
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
45
|
+
const K = /* @__PURE__ */ new WeakMap();
|
|
46
|
+
function ye(i, e, t, n) {
|
|
47
|
+
if (t == null)
|
|
48
|
+
return;
|
|
49
|
+
const o = e(t);
|
|
50
|
+
o !== void 0 && (n[i] = o);
|
|
51
|
+
}
|
|
52
|
+
function le(i) {
|
|
66
53
|
if (!i)
|
|
67
54
|
return {};
|
|
68
55
|
if (!(i instanceof Element))
|
|
69
|
-
return
|
|
56
|
+
return le(i?.parentNode);
|
|
70
57
|
const e = {};
|
|
71
|
-
for (const o
|
|
72
|
-
const r =
|
|
73
|
-
|
|
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);
|
|
74
61
|
}
|
|
75
|
-
const n = { ...i.parentNode ?
|
|
76
|
-
return
|
|
62
|
+
const n = { ...i.parentNode ? K.get(i.parentNode) : void 0, ...e };
|
|
63
|
+
return K.set(i, n), n;
|
|
77
64
|
}
|
|
78
|
-
const
|
|
65
|
+
const ce = {
|
|
79
66
|
id: "default",
|
|
80
67
|
plugins: [],
|
|
81
|
-
...
|
|
68
|
+
...se
|
|
82
69
|
};
|
|
83
70
|
function we(i, e) {
|
|
84
|
-
const t =
|
|
85
|
-
return { ...
|
|
71
|
+
const t = le(i);
|
|
72
|
+
return { ...ce, ...e, ...t };
|
|
86
73
|
}
|
|
87
|
-
function
|
|
74
|
+
function Se(i) {
|
|
88
75
|
return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
|
|
89
76
|
}
|
|
90
|
-
var O = { exports: {} },
|
|
91
|
-
function
|
|
92
|
-
return
|
|
77
|
+
var O = { exports: {} }, Ce = O.exports, Y;
|
|
78
|
+
function Ne() {
|
|
79
|
+
return Y || (Y = 1, (function(i) {
|
|
93
80
|
(function(e, t) {
|
|
94
81
|
i.exports ? i.exports = t() : e.log = t();
|
|
95
|
-
})(
|
|
82
|
+
})(Ce, function() {
|
|
96
83
|
var e = function() {
|
|
97
84
|
}, t = "undefined", n = typeof window !== t && typeof window.navigator !== t && /Trident\/|MSIE /.test(window.navigator.userAgent), o = [
|
|
98
85
|
"trace",
|
|
@@ -101,7 +88,7 @@ function Ce() {
|
|
|
101
88
|
"warn",
|
|
102
89
|
"error"
|
|
103
90
|
], r = {}, s = null;
|
|
104
|
-
function
|
|
91
|
+
function d(l, p) {
|
|
105
92
|
var a = l[p];
|
|
106
93
|
if (typeof a.bind == "function")
|
|
107
94
|
return a.bind(l);
|
|
@@ -117,7 +104,7 @@ function Ce() {
|
|
|
117
104
|
console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
|
|
118
105
|
}
|
|
119
106
|
function b(l) {
|
|
120
|
-
return l === "debug" && (l = "log"), typeof console === t ? !1 : l === "trace" && n ? P : console[l] !== void 0 ?
|
|
107
|
+
return l === "debug" && (l = "log"), typeof console === t ? !1 : l === "trace" && n ? P : console[l] !== void 0 ? d(console, l) : console.log !== void 0 ? d(console, "log") : e;
|
|
121
108
|
}
|
|
122
109
|
function f() {
|
|
123
110
|
for (var l = this.getLevel(), p = 0; p < o.length; p++) {
|
|
@@ -132,14 +119,14 @@ function Ce() {
|
|
|
132
119
|
typeof console !== t && (f.call(this), this[l].apply(this, arguments));
|
|
133
120
|
};
|
|
134
121
|
}
|
|
135
|
-
function
|
|
122
|
+
function W(l, p, a) {
|
|
136
123
|
return b(l) || _.apply(this, arguments);
|
|
137
124
|
}
|
|
138
|
-
function
|
|
139
|
-
var a = this,
|
|
125
|
+
function q(l, p) {
|
|
126
|
+
var a = this, R, j, y, m = "loglevel";
|
|
140
127
|
typeof l == "string" ? m += ":" + l : typeof l == "symbol" && (m = void 0);
|
|
141
|
-
function
|
|
142
|
-
var u = (o[
|
|
128
|
+
function pe(c) {
|
|
129
|
+
var u = (o[c] || "silent").toUpperCase();
|
|
143
130
|
if (!(typeof window === t || !m)) {
|
|
144
131
|
try {
|
|
145
132
|
window.localStorage[m] = u;
|
|
@@ -153,24 +140,24 @@ function Ce() {
|
|
|
153
140
|
}
|
|
154
141
|
}
|
|
155
142
|
function J() {
|
|
156
|
-
var
|
|
143
|
+
var c;
|
|
157
144
|
if (!(typeof window === t || !m)) {
|
|
158
145
|
try {
|
|
159
|
-
|
|
146
|
+
c = window.localStorage[m];
|
|
160
147
|
} catch {
|
|
161
148
|
}
|
|
162
|
-
if (typeof
|
|
149
|
+
if (typeof c === t)
|
|
163
150
|
try {
|
|
164
|
-
var u = window.document.cookie,
|
|
165
|
-
|
|
166
|
-
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)
|
|
167
154
|
)[1]);
|
|
168
155
|
} catch {
|
|
169
156
|
}
|
|
170
|
-
return a.levels[
|
|
157
|
+
return a.levels[c] === void 0 && (c = void 0), c;
|
|
171
158
|
}
|
|
172
159
|
}
|
|
173
|
-
function
|
|
160
|
+
function ue() {
|
|
174
161
|
if (!(typeof window === t || !m)) {
|
|
175
162
|
try {
|
|
176
163
|
window.localStorage.removeItem(m);
|
|
@@ -182,11 +169,11 @@ function Ce() {
|
|
|
182
169
|
}
|
|
183
170
|
}
|
|
184
171
|
}
|
|
185
|
-
function E(
|
|
186
|
-
var u =
|
|
172
|
+
function E(c) {
|
|
173
|
+
var u = c;
|
|
187
174
|
if (typeof u == "string" && a.levels[u.toUpperCase()] !== void 0 && (u = a.levels[u.toUpperCase()]), typeof u == "number" && u >= 0 && u <= a.levels.SILENT)
|
|
188
175
|
return u;
|
|
189
|
-
throw new TypeError("log.setLevel() called with invalid level: " +
|
|
176
|
+
throw new TypeError("log.setLevel() called with invalid level: " + c);
|
|
190
177
|
}
|
|
191
178
|
a.name = l, a.levels = {
|
|
192
179
|
TRACE: 0,
|
|
@@ -195,68 +182,68 @@ function Ce() {
|
|
|
195
182
|
WARN: 3,
|
|
196
183
|
ERROR: 4,
|
|
197
184
|
SILENT: 5
|
|
198
|
-
}, a.methodFactory = p ||
|
|
199
|
-
return
|
|
200
|
-
}, a.setLevel = function(
|
|
201
|
-
return
|
|
202
|
-
}, a.setDefaultLevel = function(
|
|
203
|
-
|
|
185
|
+
}, a.methodFactory = p || W, a.getLevel = function() {
|
|
186
|
+
return y ?? j ?? R;
|
|
187
|
+
}, a.setLevel = function(c, u) {
|
|
188
|
+
return y = E(c), u !== !1 && pe(y), f.call(a);
|
|
189
|
+
}, a.setDefaultLevel = function(c) {
|
|
190
|
+
j = E(c), J() || a.setLevel(c, !1);
|
|
204
191
|
}, a.resetLevel = function() {
|
|
205
|
-
|
|
206
|
-
}, a.enableAll = function(
|
|
207
|
-
a.setLevel(a.levels.TRACE,
|
|
208
|
-
}, a.disableAll = function(
|
|
209
|
-
a.setLevel(a.levels.SILENT,
|
|
192
|
+
y = null, ue(), f.call(a);
|
|
193
|
+
}, a.enableAll = function(c) {
|
|
194
|
+
a.setLevel(a.levels.TRACE, c);
|
|
195
|
+
}, a.disableAll = function(c) {
|
|
196
|
+
a.setLevel(a.levels.SILENT, c);
|
|
210
197
|
}, a.rebuild = function() {
|
|
211
|
-
if (s !== a && (
|
|
212
|
-
for (var
|
|
213
|
-
r[
|
|
214
|
-
},
|
|
198
|
+
if (s !== a && (R = E(s.getLevel())), f.call(a), s === a)
|
|
199
|
+
for (var c in r)
|
|
200
|
+
r[c].rebuild();
|
|
201
|
+
}, R = E(
|
|
215
202
|
s ? s.getLevel() : "WARN"
|
|
216
203
|
);
|
|
217
|
-
var
|
|
218
|
-
|
|
204
|
+
var G = J();
|
|
205
|
+
G != null && (y = E(G)), f.call(a);
|
|
219
206
|
}
|
|
220
|
-
s = new
|
|
207
|
+
s = new q(), s.getLogger = function(p) {
|
|
221
208
|
if (typeof p != "symbol" && typeof p != "string" || p === "")
|
|
222
209
|
throw new TypeError("You must supply a name when creating a logger.");
|
|
223
210
|
var a = r[p];
|
|
224
|
-
return a || (a = r[p] = new
|
|
211
|
+
return a || (a = r[p] = new q(
|
|
225
212
|
p,
|
|
226
213
|
s.methodFactory
|
|
227
214
|
)), a;
|
|
228
215
|
};
|
|
229
|
-
var
|
|
216
|
+
var ge = typeof window !== t ? window.log : void 0;
|
|
230
217
|
return s.noConflict = function() {
|
|
231
|
-
return typeof window !== t && window.log === s && (window.log =
|
|
218
|
+
return typeof window !== t && window.log === s && (window.log = ge), s;
|
|
232
219
|
}, s.getLoggers = function() {
|
|
233
220
|
return r;
|
|
234
221
|
}, s.default = s, s;
|
|
235
222
|
});
|
|
236
223
|
})(O)), O.exports;
|
|
237
224
|
}
|
|
238
|
-
var
|
|
239
|
-
const S = /* @__PURE__ */
|
|
225
|
+
var xe = Ne();
|
|
226
|
+
const S = /* @__PURE__ */ Se(xe), g = S.getLogger(me);
|
|
240
227
|
g.setDefaultLevel("info");
|
|
241
|
-
const
|
|
228
|
+
const M = "\x1B[46mPLUGIN\x1B[0m";
|
|
242
229
|
function N(i, e, ...t) {
|
|
243
230
|
i.sort((n, o) => n.order - o.order).forEach((n) => {
|
|
244
231
|
const o = n[e];
|
|
245
232
|
if (o) {
|
|
246
233
|
g.debug(
|
|
247
|
-
|
|
234
|
+
M,
|
|
248
235
|
`executing plugin ${n.name}:${String(e)} ()`,
|
|
249
236
|
t
|
|
250
237
|
);
|
|
251
238
|
try {
|
|
252
239
|
o(...t), g.debug(
|
|
253
|
-
|
|
240
|
+
M,
|
|
254
241
|
`plugin ${n.name}:${String(e)} executed`,
|
|
255
242
|
t
|
|
256
243
|
);
|
|
257
244
|
} catch (r) {
|
|
258
245
|
g.debug(
|
|
259
|
-
|
|
246
|
+
M,
|
|
260
247
|
`plugin ${n.name}:${String(e)} failed`,
|
|
261
248
|
r
|
|
262
249
|
);
|
|
@@ -268,7 +255,7 @@ const x = {
|
|
|
268
255
|
Element: "element",
|
|
269
256
|
Text: "text"
|
|
270
257
|
};
|
|
271
|
-
class
|
|
258
|
+
class F {
|
|
272
259
|
_node;
|
|
273
260
|
config;
|
|
274
261
|
type = x.Element;
|
|
@@ -290,7 +277,7 @@ class I {
|
|
|
290
277
|
}), this._node.appendChild(e.getNode());
|
|
291
278
|
}
|
|
292
279
|
clone(e) {
|
|
293
|
-
const t = this._node.cloneNode(e), n = new
|
|
280
|
+
const t = this._node.cloneNode(e), n = new F(
|
|
294
281
|
t,
|
|
295
282
|
this.transaction,
|
|
296
283
|
this.config,
|
|
@@ -305,7 +292,7 @@ class I {
|
|
|
305
292
|
), n;
|
|
306
293
|
}
|
|
307
294
|
getHeight() {
|
|
308
|
-
return
|
|
295
|
+
return $(this._node);
|
|
309
296
|
}
|
|
310
297
|
remove() {
|
|
311
298
|
this.transaction.addCommitCallback(() => {
|
|
@@ -322,7 +309,7 @@ class I {
|
|
|
322
309
|
return this._node;
|
|
323
310
|
}
|
|
324
311
|
}
|
|
325
|
-
class
|
|
312
|
+
class Pe {
|
|
326
313
|
_node;
|
|
327
314
|
type = x.Text;
|
|
328
315
|
transaction;
|
|
@@ -345,15 +332,15 @@ class xe {
|
|
|
345
332
|
return this._node;
|
|
346
333
|
}
|
|
347
334
|
}
|
|
348
|
-
function
|
|
349
|
-
if (
|
|
350
|
-
return new
|
|
351
|
-
if (
|
|
352
|
-
return new
|
|
335
|
+
function z(i, e, t) {
|
|
336
|
+
if (be(i))
|
|
337
|
+
return new Pe(i, e, t);
|
|
338
|
+
if (re(i))
|
|
339
|
+
return new F(i, e, t);
|
|
353
340
|
throw new Error("Unsupported node type");
|
|
354
341
|
}
|
|
355
342
|
const k = "\x1B[106mDOM\x1B[0m";
|
|
356
|
-
class
|
|
343
|
+
class Ee {
|
|
357
344
|
_transaction;
|
|
358
345
|
_treeWalker;
|
|
359
346
|
_config;
|
|
@@ -395,7 +382,7 @@ class Pe {
|
|
|
395
382
|
return this._treeWalker.firstChild() ? (g.debug(k, "moving to first child node"), this.setState(), { parentsTraversed: 1 }) : (this.goToNextNode(), { parentsTraversed: 0 });
|
|
396
383
|
}
|
|
397
384
|
setState() {
|
|
398
|
-
this._previousNode = this._currentNode, this._currentNode =
|
|
385
|
+
this._previousNode = this._currentNode, this._currentNode = z(
|
|
399
386
|
this._treeWalker.currentNode,
|
|
400
387
|
this._transaction,
|
|
401
388
|
we(this._treeWalker.currentNode, this._config)
|
|
@@ -405,7 +392,7 @@ class Pe {
|
|
|
405
392
|
});
|
|
406
393
|
}
|
|
407
394
|
}
|
|
408
|
-
class
|
|
395
|
+
class Te {
|
|
409
396
|
_onRollback;
|
|
410
397
|
_onCommit;
|
|
411
398
|
isActive;
|
|
@@ -434,8 +421,8 @@ class Ee {
|
|
|
434
421
|
this.isActive && (this.isActive = !1, this._onCommit.forEach((e) => e()));
|
|
435
422
|
};
|
|
436
423
|
}
|
|
437
|
-
const
|
|
438
|
-
class
|
|
424
|
+
const Q = "\x1B[102mPAGE\x1B[0m";
|
|
425
|
+
class I {
|
|
439
426
|
currentPage;
|
|
440
427
|
activeElement;
|
|
441
428
|
currentElement;
|
|
@@ -443,11 +430,11 @@ class R {
|
|
|
443
430
|
pageIsFull;
|
|
444
431
|
pageIndex;
|
|
445
432
|
pageHeight;
|
|
446
|
-
constructor(e, t, n, o, r, s,
|
|
447
|
-
this.currentPage = e, this.activeElement = t, this.currentElement = n, this.parentStack = o, this.pageIsFull = r, this.pageIndex = s, this.pageHeight =
|
|
433
|
+
constructor(e, t, n, o, r, s, d) {
|
|
434
|
+
this.currentPage = e, this.activeElement = t, this.currentElement = n, this.parentStack = o, this.pageIsFull = r, this.pageIndex = s, this.pageHeight = d;
|
|
448
435
|
}
|
|
449
436
|
static create(e, t, n, o) {
|
|
450
|
-
return new
|
|
437
|
+
return new I(
|
|
451
438
|
e,
|
|
452
439
|
null,
|
|
453
440
|
e,
|
|
@@ -457,7 +444,7 @@ class R {
|
|
|
457
444
|
o
|
|
458
445
|
);
|
|
459
446
|
}
|
|
460
|
-
clone = () => new
|
|
447
|
+
clone = () => new I(
|
|
461
448
|
this.currentPage,
|
|
462
449
|
this.activeElement,
|
|
463
450
|
this.currentElement,
|
|
@@ -467,22 +454,22 @@ class R {
|
|
|
467
454
|
this.pageHeight
|
|
468
455
|
);
|
|
469
456
|
}
|
|
470
|
-
class
|
|
457
|
+
class V {
|
|
471
458
|
_pageState;
|
|
472
459
|
_transaction;
|
|
473
460
|
_tempContainer;
|
|
474
461
|
_config;
|
|
475
462
|
constructor(e, t, n, o) {
|
|
476
463
|
this._tempContainer = e, this._config = o, this._transaction = n;
|
|
477
|
-
const r =
|
|
464
|
+
const r = V.createPageHtmlElement(
|
|
478
465
|
t.width
|
|
479
466
|
), s = this.createNewPage(r);
|
|
480
|
-
this._pageState =
|
|
467
|
+
this._pageState = I.create(s, [], 0, t.height), N(this._config.plugins, "onNewPage", o.id, this);
|
|
481
468
|
}
|
|
482
469
|
nextPage() {
|
|
483
470
|
const e = this.createNewPage(
|
|
484
471
|
this._pageState.currentPage.getNode().cloneNode(!1)
|
|
485
|
-
), t =
|
|
472
|
+
), t = I.create(
|
|
486
473
|
e,
|
|
487
474
|
[],
|
|
488
475
|
this._pageState.pageIndex + 1,
|
|
@@ -514,7 +501,7 @@ class G {
|
|
|
514
501
|
if (!this._pageState.activeElement || this._pageState.activeElement.type !== x.Element)
|
|
515
502
|
throw new Error("Invalid state: activeElement is not an Element");
|
|
516
503
|
g.debug(
|
|
517
|
-
|
|
504
|
+
Q,
|
|
518
505
|
"entering an element",
|
|
519
506
|
this._pageState.activeElement
|
|
520
507
|
), this._pageState.currentElement = this._pageState.activeElement, this._pageState.parentStack.push(this._pageState.activeElement);
|
|
@@ -522,7 +509,7 @@ class G {
|
|
|
522
509
|
leaveElement() {
|
|
523
510
|
this._pageState.activeElement = null;
|
|
524
511
|
const e = this._pageState.parentStack.pop();
|
|
525
|
-
g.debug(
|
|
512
|
+
g.debug(Q, "leaving a parent element", e);
|
|
526
513
|
const t = this._pageState.parentStack.at(-1);
|
|
527
514
|
this._pageState.currentElement = t ?? this._pageState.currentPage;
|
|
528
515
|
}
|
|
@@ -533,7 +520,7 @@ class G {
|
|
|
533
520
|
createNewPage(e) {
|
|
534
521
|
return this._tempContainer.appendChild(e), this._transaction.isActive && this._transaction.addRollbackCallback(() => {
|
|
535
522
|
this._tempContainer.removeChild(e);
|
|
536
|
-
}),
|
|
523
|
+
}), z(e, this._transaction, this._config);
|
|
537
524
|
}
|
|
538
525
|
startTransaction() {
|
|
539
526
|
this._transaction.start();
|
|
@@ -558,7 +545,7 @@ class G {
|
|
|
558
545
|
addTextNode(e) {
|
|
559
546
|
if (this._pageState.activeElement?.type === x.Text)
|
|
560
547
|
return this._pageState.activeElement;
|
|
561
|
-
const t = document.createTextNode(e), n =
|
|
548
|
+
const t = document.createTextNode(e), n = z(
|
|
562
549
|
t,
|
|
563
550
|
this._transaction,
|
|
564
551
|
this._config
|
|
@@ -577,16 +564,16 @@ const h = {
|
|
|
577
564
|
SplitChildren: 2
|
|
578
565
|
// The node is too large for the page, and its children must be paginated individually.
|
|
579
566
|
};
|
|
580
|
-
function
|
|
581
|
-
const t =
|
|
567
|
+
function ke(i, e) {
|
|
568
|
+
const t = ee(i, e);
|
|
582
569
|
if (t !== h.None)
|
|
583
570
|
return t;
|
|
584
571
|
const { rollback: n, commit: o } = e.startTransaction();
|
|
585
572
|
e.nextPage();
|
|
586
|
-
const r =
|
|
573
|
+
const r = ee(i, e);
|
|
587
574
|
return r !== h.None ? (o(), r) : (n(), g.debug("Element is too big to fit on a page", i), h.None);
|
|
588
575
|
}
|
|
589
|
-
function
|
|
576
|
+
function ee(i, e) {
|
|
590
577
|
if (e.hasEmptySpace(i.getHeight())) {
|
|
591
578
|
const n = e.appendChild(i, !0);
|
|
592
579
|
if (e.isOverFlow())
|
|
@@ -599,17 +586,17 @@ function ne(i, e) {
|
|
|
599
586
|
const t = e.appendChild(i, !1);
|
|
600
587
|
return e.isOverFlow() ? (t.remove(), h.None) : h.SplitChildren;
|
|
601
588
|
}
|
|
602
|
-
function
|
|
589
|
+
function Ae(i, e) {
|
|
603
590
|
let t = h.FullNodePlaced;
|
|
604
591
|
const n = i.textContent.split(/(\s+)/).filter((s) => s !== "");
|
|
605
592
|
let o, r = 0;
|
|
606
593
|
for (; o || r < n.length; ) {
|
|
607
|
-
const s = o ?? n[r],
|
|
608
|
-
|
|
594
|
+
const s = o ?? n[r], d = Le(s, e, i.config);
|
|
595
|
+
d.completed || (t = h.None), d.pendingToken ? o = d.pendingToken : (o = void 0, r++);
|
|
609
596
|
}
|
|
610
597
|
return t;
|
|
611
598
|
}
|
|
612
|
-
function
|
|
599
|
+
function Le(i, e, t) {
|
|
613
600
|
e.hasEmptySpace() || e.nextPage();
|
|
614
601
|
const n = e.addTextNode(""), o = n.textContent;
|
|
615
602
|
if (n.textContent += i, !e.isOverFlow())
|
|
@@ -617,48 +604,48 @@ function Ae(i, e, t) {
|
|
|
617
604
|
completed: !0
|
|
618
605
|
};
|
|
619
606
|
n.textContent = o;
|
|
620
|
-
const r =
|
|
607
|
+
const r = Fe(i, e, t);
|
|
621
608
|
return {
|
|
622
609
|
pendingToken: r.leftovers,
|
|
623
610
|
completed: r.completed
|
|
624
611
|
};
|
|
625
612
|
}
|
|
626
|
-
function
|
|
613
|
+
function Fe(i, e, t) {
|
|
627
614
|
const { rollback: n, commit: o } = e.startTransaction();
|
|
628
615
|
if (e.nextPage(), e.addTextNode(i), !e.isOverFlow())
|
|
629
616
|
return o(), {
|
|
630
617
|
completed: !0
|
|
631
618
|
};
|
|
632
|
-
if (n(),
|
|
619
|
+
if (n(), t.hyphenationDisabled)
|
|
633
620
|
return g.warn("Hyphenation disabled, skipping oversized token:", i), {
|
|
634
621
|
completed: !1
|
|
635
622
|
};
|
|
636
|
-
const r =
|
|
623
|
+
const r = Ie(i, t.hyphen, e);
|
|
637
624
|
return {
|
|
638
625
|
completed: !0,
|
|
639
626
|
leftovers: r && r.length > 0 ? r : void 0
|
|
640
627
|
};
|
|
641
628
|
}
|
|
642
|
-
function
|
|
629
|
+
function Ie(i, e, t) {
|
|
643
630
|
const n = t.addTextNode("");
|
|
644
631
|
let o = "";
|
|
645
632
|
for (let r = 0; r < i.length; r++) {
|
|
646
|
-
const s = i[r],
|
|
647
|
-
if (n.textContent =
|
|
633
|
+
const s = i[r], d = o + s;
|
|
634
|
+
if (n.textContent = d + e, !t.hasEmptySpace())
|
|
648
635
|
return n.textContent = o ? o + e : "", t.markPageAsFull(), i.slice(r);
|
|
649
|
-
o =
|
|
636
|
+
o = d;
|
|
650
637
|
}
|
|
651
638
|
return null;
|
|
652
639
|
}
|
|
653
640
|
const A = "\x1B[103mPAGINATOR\x1B[0m";
|
|
654
|
-
class
|
|
641
|
+
class B {
|
|
655
642
|
_domState;
|
|
656
643
|
_pageManager;
|
|
657
644
|
_transaction;
|
|
658
645
|
_tempContainer;
|
|
659
646
|
_config;
|
|
660
647
|
constructor(e, t, n) {
|
|
661
|
-
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(
|
|
662
649
|
this._tempContainer,
|
|
663
650
|
t,
|
|
664
651
|
this._transaction,
|
|
@@ -667,11 +654,11 @@ class M {
|
|
|
667
654
|
}
|
|
668
655
|
static createTempContainer(e) {
|
|
669
656
|
const t = document.createElement("div");
|
|
670
|
-
return t.style.display = "flex", t.style.flexDirection = "column", t.style.gap = "20px", t.setAttribute(`${
|
|
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;
|
|
671
658
|
}
|
|
672
659
|
static paginate(e, t, n) {
|
|
673
|
-
const o = new
|
|
674
|
-
return o.processAllNodes(), Array.from(o._tempContainer.childNodes).filter((s) =>
|
|
660
|
+
const o = new B(e, t, n);
|
|
661
|
+
return o.processAllNodes(), Array.from(o._tempContainer.childNodes).filter((s) => re(s)).map((s) => s.innerHTML);
|
|
675
662
|
}
|
|
676
663
|
processAllNodes() {
|
|
677
664
|
this._domState.goToNextNode();
|
|
@@ -730,7 +717,7 @@ class M {
|
|
|
730
717
|
this._domState,
|
|
731
718
|
this._pageManager,
|
|
732
719
|
e
|
|
733
|
-
), e.result !== void 0 ? e.result :
|
|
720
|
+
), e.result !== void 0 ? e.result : ke(
|
|
734
721
|
this._domState.currentNode,
|
|
735
722
|
this._pageManager
|
|
736
723
|
);
|
|
@@ -743,14 +730,14 @@ class M {
|
|
|
743
730
|
this._domState,
|
|
744
731
|
this._pageManager,
|
|
745
732
|
e
|
|
746
|
-
), e.result !== void 0 ? e.result :
|
|
733
|
+
), e.result !== void 0 ? e.result : Ae(
|
|
747
734
|
this._domState.currentNode,
|
|
748
735
|
this._pageManager
|
|
749
736
|
);
|
|
750
737
|
}
|
|
751
738
|
}
|
|
752
739
|
}
|
|
753
|
-
class
|
|
740
|
+
class de {
|
|
754
741
|
registry = /* @__PURE__ */ new Map();
|
|
755
742
|
addEventListener(e, t) {
|
|
756
743
|
const { registry: n } = this, o = new Set(n.get(e));
|
|
@@ -760,41 +747,77 @@ class ce {
|
|
|
760
747
|
const { registry: n } = this, o = new Set(n.get(e));
|
|
761
748
|
o.delete(t), n.set(e, o);
|
|
762
749
|
}
|
|
763
|
-
dispatch(e, ...t) {
|
|
750
|
+
async dispatch(e, ...t) {
|
|
764
751
|
const { registry: n } = this, o = n.get(e);
|
|
765
752
|
if (o)
|
|
766
753
|
for (const r of o)
|
|
767
|
-
r(...t);
|
|
754
|
+
await r(...t);
|
|
768
755
|
}
|
|
769
756
|
}
|
|
770
|
-
const
|
|
757
|
+
const dt = {
|
|
758
|
+
/** 841mm x 594mm */
|
|
771
759
|
A1: { height: "841mm", width: "594mm" },
|
|
760
|
+
/** 594mm x 420mm */
|
|
772
761
|
A2: { height: "594mm", width: "420mm" },
|
|
762
|
+
/** 420mm x 297mm */
|
|
773
763
|
A3: { height: "420mm", width: "297mm" },
|
|
764
|
+
/** 297mm x 210mm */
|
|
774
765
|
A4: { height: "297mm", width: "210mm" },
|
|
766
|
+
/** 210mm x 148mm */
|
|
775
767
|
A5: { height: "210mm", width: "148mm" },
|
|
768
|
+
/** 148mm x 105mm */
|
|
776
769
|
A6: { height: "148mm", width: "105mm" },
|
|
770
|
+
/** 500mm x 353mm */
|
|
777
771
|
B3: { height: "500mm", width: "353mm" },
|
|
772
|
+
/** 353mm x 250mm */
|
|
778
773
|
B4: { height: "353mm", width: "250mm" },
|
|
774
|
+
/** 250mm x 176mm */
|
|
779
775
|
B5: { height: "250mm", width: "176mm" },
|
|
776
|
+
/** 8.5in x 11in */
|
|
780
777
|
Letter: { height: "8.5in", width: "11in" },
|
|
778
|
+
/** 11in x 8.5in */
|
|
781
779
|
Legal: { height: "11in", width: "8.5in" },
|
|
780
|
+
/** 11in x 17in */
|
|
782
781
|
Tabloid: { height: "11in", width: "17in" }
|
|
783
782
|
}, Re = {
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
783
|
+
/** Top, Right, Bottom, Left: 1in */
|
|
784
|
+
Normal: {
|
|
785
|
+
top: "1in",
|
|
786
|
+
right: "1in",
|
|
787
|
+
bottom: "1in",
|
|
788
|
+
left: "1in"
|
|
789
|
+
},
|
|
790
|
+
/** Top: 0.4in, Right, Bottom, Left: 0.6in */
|
|
791
|
+
Narrow: {
|
|
792
|
+
top: "0.4in",
|
|
793
|
+
right: "0.6in",
|
|
794
|
+
bottom: "0.6in",
|
|
795
|
+
left: "0.6in"
|
|
796
|
+
},
|
|
797
|
+
/** Top, Bottom: 0.5in, Right, Left: 2in */
|
|
798
|
+
Wide: {
|
|
799
|
+
top: "0.5in",
|
|
800
|
+
right: "2in",
|
|
801
|
+
bottom: "0.5in",
|
|
802
|
+
left: "2in"
|
|
803
|
+
},
|
|
804
|
+
/** Top, Right, Bottom, Left: 0 */
|
|
805
|
+
None: {
|
|
806
|
+
top: "0in",
|
|
807
|
+
right: "0in",
|
|
808
|
+
bottom: "0in",
|
|
809
|
+
left: "0in"
|
|
810
|
+
}
|
|
811
|
+
}, He = "__PAPRIZE_IS_INITIALIZED", te = "__PAPRIZE_IS_READY", ne = "__PAPRIZE_READ_JSON_DATA_FILE";
|
|
812
|
+
function Oe(i) {
|
|
790
813
|
const e = i.getBoundingClientRect(), t = getComputedStyle(i), n = parseFloat(t.marginLeft) || 0, o = parseFloat(t.marginRight) || 0;
|
|
791
814
|
return {
|
|
792
|
-
height:
|
|
815
|
+
height: $(i),
|
|
793
816
|
width: e.width + n + o
|
|
794
817
|
};
|
|
795
818
|
}
|
|
796
|
-
function
|
|
797
|
-
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;
|
|
798
821
|
return { height: n, width: o, sectionHeaderHeight: r, sectionFooterHeight: s };
|
|
799
822
|
}
|
|
800
823
|
function ze(i, e, t) {
|
|
@@ -813,7 +836,17 @@ function ze(i, e, t) {
|
|
|
813
836
|
function Be(i) {
|
|
814
837
|
return i ? `${i.top} ${i.right} ${i.bottom} ${i.left}` : "0";
|
|
815
838
|
}
|
|
816
|
-
|
|
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 = `
|
|
817
850
|
html {
|
|
818
851
|
box-sizing: border-box;
|
|
819
852
|
}
|
|
@@ -847,13 +880,13 @@ const De = `
|
|
|
847
880
|
padding: var(--paprize-preview-padding);
|
|
848
881
|
}
|
|
849
882
|
|
|
850
|
-
.${
|
|
883
|
+
.${U} {
|
|
851
884
|
box-shadow: var(--paprize-page-box-shadow);
|
|
852
885
|
margin-bottom: var(--paprize-page-margin-bottom);
|
|
853
886
|
background-color: var(--paprize-page-background-color);
|
|
854
887
|
}
|
|
855
888
|
|
|
856
|
-
.${
|
|
889
|
+
.${_e} {
|
|
857
890
|
margin-bottom: var(--paprize-section-margin-bottom);
|
|
858
891
|
}
|
|
859
892
|
}
|
|
@@ -866,12 +899,12 @@ const De = `
|
|
|
866
899
|
`, Me = {
|
|
867
900
|
display: "flex",
|
|
868
901
|
flexDirection: "column"
|
|
869
|
-
},
|
|
902
|
+
}, Ue = {
|
|
870
903
|
position: "absolute",
|
|
871
904
|
left: "-9999px",
|
|
872
905
|
top: "-9999px",
|
|
873
906
|
visibility: "hidden"
|
|
874
|
-
},
|
|
907
|
+
}, Ve = (i, e) => ({
|
|
875
908
|
display: "flex",
|
|
876
909
|
flexDirection: "column",
|
|
877
910
|
width: i.width,
|
|
@@ -880,20 +913,20 @@ const De = `
|
|
|
880
913
|
position: "relative",
|
|
881
914
|
padding: Be(e),
|
|
882
915
|
zIndex: "1"
|
|
883
|
-
}),
|
|
916
|
+
}), qe = {
|
|
884
917
|
overflow: "hidden",
|
|
885
918
|
width: "100%",
|
|
886
919
|
height: "100%"
|
|
887
|
-
},
|
|
920
|
+
}, Je = {
|
|
888
921
|
position: "absolute",
|
|
889
922
|
width: "100%",
|
|
890
923
|
height: "100%",
|
|
891
924
|
left: 0,
|
|
892
925
|
top: 0
|
|
893
|
-
},
|
|
926
|
+
}, Ge = (i) => ({
|
|
894
927
|
page: `section-${i}`
|
|
895
928
|
});
|
|
896
|
-
function
|
|
929
|
+
function Ze(i, e) {
|
|
897
930
|
return `@page section-${i} {
|
|
898
931
|
margin: none;
|
|
899
932
|
size:${e.width} ${e.height};
|
|
@@ -902,19 +935,19 @@ function Ge(i, e) {
|
|
|
902
935
|
}`;
|
|
903
936
|
}
|
|
904
937
|
const v = {
|
|
905
|
-
globalStyle:
|
|
938
|
+
globalStyle: je,
|
|
906
939
|
component: Me,
|
|
907
|
-
outOfScreen:
|
|
908
|
-
page:
|
|
909
|
-
overlay:
|
|
910
|
-
pageContent:
|
|
911
|
-
sectionPageMedia:
|
|
912
|
-
section:
|
|
940
|
+
outOfScreen: Ue,
|
|
941
|
+
page: Ve,
|
|
942
|
+
overlay: Je,
|
|
943
|
+
pageContent: qe,
|
|
944
|
+
sectionPageMedia: Ze,
|
|
945
|
+
section: Ge
|
|
913
946
|
};
|
|
914
947
|
function L(i) {
|
|
915
948
|
return i?.cloneNode(!0) ?? null;
|
|
916
949
|
}
|
|
917
|
-
function
|
|
950
|
+
function Xe(i) {
|
|
918
951
|
return {
|
|
919
952
|
sectionHeader: L(i.sectionHeader),
|
|
920
953
|
sectionFooter: L(i.sectionFooter),
|
|
@@ -923,15 +956,15 @@ function Ze(i) {
|
|
|
923
956
|
pageContent: L(i.pageContent)
|
|
924
957
|
};
|
|
925
958
|
}
|
|
926
|
-
const
|
|
927
|
-
class
|
|
959
|
+
const Ke = "data-pz-page-break";
|
|
960
|
+
class Ye {
|
|
928
961
|
name = "pageBreak";
|
|
929
962
|
order = 1;
|
|
930
963
|
onVisitElement = (e, t, n, o) => {
|
|
931
|
-
t.currentNode.getNode().getAttribute(
|
|
964
|
+
t.currentNode.getNode().getAttribute(Ke) === "true" && (n.markPageAsFull(), o.result = h.FullNodePlaced);
|
|
932
965
|
};
|
|
933
966
|
}
|
|
934
|
-
class
|
|
967
|
+
class Qe {
|
|
935
968
|
_options = {};
|
|
936
969
|
name = "table";
|
|
937
970
|
order = 1;
|
|
@@ -946,15 +979,15 @@ class Ye {
|
|
|
946
979
|
);
|
|
947
980
|
if (!o || !o.clonedFrom)
|
|
948
981
|
return;
|
|
949
|
-
const r = o.clonedFrom, s = r.getNode(),
|
|
950
|
-
if (!(
|
|
982
|
+
const r = o.clonedFrom, s = r.getNode(), d = s.tHead;
|
|
983
|
+
if (!(d !== null))
|
|
951
984
|
return;
|
|
952
985
|
const b = s.tBodies;
|
|
953
986
|
if (!this._isTableBodyEmpty(b))
|
|
954
987
|
return;
|
|
955
988
|
if (r.remove(), o.getNode().tHead === null) {
|
|
956
|
-
const _ =
|
|
957
|
-
|
|
989
|
+
const _ = z(
|
|
990
|
+
d.cloneNode(!0),
|
|
958
991
|
o.transaction,
|
|
959
992
|
o.config
|
|
960
993
|
);
|
|
@@ -970,21 +1003,21 @@ class Ye {
|
|
|
970
1003
|
return;
|
|
971
1004
|
const o = n.getOriginalNode(), r = o.tHead;
|
|
972
1005
|
if (r && this._options.cloneHeader === !0) {
|
|
973
|
-
const
|
|
1006
|
+
const d = new F(
|
|
974
1007
|
r.cloneNode(!0),
|
|
975
1008
|
n.transaction,
|
|
976
1009
|
n.config
|
|
977
1010
|
);
|
|
978
|
-
n.appendChild(
|
|
1011
|
+
n.appendChild(d);
|
|
979
1012
|
}
|
|
980
1013
|
const s = o.tFoot;
|
|
981
1014
|
if (s && this._options.cloneFooter === !0) {
|
|
982
|
-
const
|
|
1015
|
+
const d = new F(
|
|
983
1016
|
s.cloneNode(!0),
|
|
984
1017
|
n.transaction,
|
|
985
1018
|
n.config
|
|
986
1019
|
);
|
|
987
|
-
n.appendChild(
|
|
1020
|
+
n.appendChild(d);
|
|
988
1021
|
}
|
|
989
1022
|
};
|
|
990
1023
|
_isTable(e) {
|
|
@@ -998,22 +1031,22 @@ class Ye {
|
|
|
998
1031
|
return n.cells.length !== 1 ? !1 : n.cells[0].textContent.trim() === "";
|
|
999
1032
|
}
|
|
1000
1033
|
}
|
|
1001
|
-
const
|
|
1002
|
-
new
|
|
1003
|
-
new
|
|
1004
|
-
],
|
|
1034
|
+
const et = [
|
|
1035
|
+
new Ye(),
|
|
1036
|
+
new Qe()
|
|
1037
|
+
], gt = {
|
|
1005
1038
|
name: "debug",
|
|
1006
1039
|
order: Number.MAX_SAFE_INTEGER,
|
|
1007
1040
|
onNewPage: (i, e) => {
|
|
1008
1041
|
const t = e.getPageState().currentPage.getNode();
|
|
1009
|
-
t.classList.contains(
|
|
1010
|
-
`${
|
|
1042
|
+
t.classList.contains(U) || t.classList.add(U), t.setAttribute(`${C}-element`, "page"), t.setAttribute(
|
|
1043
|
+
`${C}-height`,
|
|
1011
1044
|
e.getPageState().pageHeight.toString()
|
|
1012
1045
|
);
|
|
1013
1046
|
}
|
|
1014
|
-
},
|
|
1015
|
-
class
|
|
1016
|
-
name =
|
|
1047
|
+
}, tt = "sectionToc";
|
|
1048
|
+
class pt {
|
|
1049
|
+
name = tt;
|
|
1017
1050
|
order = 1;
|
|
1018
1051
|
_state = /* @__PURE__ */ new Map();
|
|
1019
1052
|
getContentList = () => Array.from(this._state.values()).flat();
|
|
@@ -1035,8 +1068,7 @@ class dt {
|
|
|
1035
1068
|
return /^H[1-6]$/.test(t) ? parseInt(t.charAt(1), 10) : null;
|
|
1036
1069
|
}
|
|
1037
1070
|
}
|
|
1038
|
-
|
|
1039
|
-
class W {
|
|
1071
|
+
class D {
|
|
1040
1072
|
_promises;
|
|
1041
1073
|
monitor;
|
|
1042
1074
|
get promise() {
|
|
@@ -1046,10 +1078,10 @@ class W {
|
|
|
1046
1078
|
) : Promise.resolve();
|
|
1047
1079
|
}
|
|
1048
1080
|
constructor() {
|
|
1049
|
-
this._promises = [], this.monitor = new
|
|
1081
|
+
this._promises = [], this.monitor = new de();
|
|
1050
1082
|
}
|
|
1051
1083
|
async add(e = []) {
|
|
1052
|
-
if (this._promises.push(...e.map(
|
|
1084
|
+
if (this._promises.push(...e.map(D.toTracked)), await new Promise((t) => setTimeout(t, 0)), this.getPending().length === 0) {
|
|
1053
1085
|
this.monitor.dispatch("onChange", 0);
|
|
1054
1086
|
return;
|
|
1055
1087
|
}
|
|
@@ -1076,27 +1108,48 @@ class W {
|
|
|
1076
1108
|
);
|
|
1077
1109
|
}
|
|
1078
1110
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1111
|
+
function ut(i, e) {
|
|
1112
|
+
return `${i}-${e + 1}`;
|
|
1113
|
+
}
|
|
1114
|
+
function nt(i, e) {
|
|
1115
|
+
return e === "landscape" ? { height: i.width, width: i.height } : i;
|
|
1116
|
+
}
|
|
1117
|
+
const w = "\x1B[43mREPORT\x1B[0m";
|
|
1118
|
+
class ht {
|
|
1081
1119
|
_sections;
|
|
1082
1120
|
_monitor;
|
|
1083
1121
|
_paginationInProgress;
|
|
1084
1122
|
_pendingPaginateResolvers;
|
|
1085
1123
|
_currentAbortController;
|
|
1086
1124
|
constructor() {
|
|
1087
|
-
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);
|
|
1088
1126
|
}
|
|
1127
|
+
/**
|
|
1128
|
+
* Monitor instance used to subscribe to pagination events.
|
|
1129
|
+
* See {@link ReportBuilderEvents} for available event types.
|
|
1130
|
+
*/
|
|
1089
1131
|
get monitor() {
|
|
1090
1132
|
return this._monitor;
|
|
1091
1133
|
}
|
|
1134
|
+
/**
|
|
1135
|
+
* Removes a section from the registered sections, if it has already been registered in the report.
|
|
1136
|
+
*/
|
|
1092
1137
|
removeSection(e) {
|
|
1093
1138
|
this._sections.delete(e);
|
|
1094
1139
|
}
|
|
1095
|
-
|
|
1140
|
+
/**
|
|
1141
|
+
* Registers a section by its ID, specifying the page size, margins, and other options.
|
|
1142
|
+
*
|
|
1143
|
+
* @param options - Configuration options for the section.
|
|
1144
|
+
* @param components - The DOM components associated with the section.
|
|
1145
|
+
* @param onPaginationCompleted - Callback invoked when pagination for the section is completed.
|
|
1146
|
+
* @returns `true` if the section was added to the report’s section list, or `false` if it already exists.
|
|
1147
|
+
*/
|
|
1148
|
+
async tryAddSection(e, t, n) {
|
|
1096
1149
|
if (this._sections.has(e.id))
|
|
1097
1150
|
return !1;
|
|
1098
1151
|
const o = {
|
|
1099
|
-
|
|
1152
|
+
sectionIndex: this._sections.size,
|
|
1100
1153
|
sectionId: e.id,
|
|
1101
1154
|
isPaginated: !1,
|
|
1102
1155
|
isSuspended: !!e.suspense?.length,
|
|
@@ -1104,19 +1157,40 @@ class pt {
|
|
|
1104
1157
|
};
|
|
1105
1158
|
return this._sections.set(e.id, {
|
|
1106
1159
|
context: o,
|
|
1107
|
-
options:
|
|
1160
|
+
options: {
|
|
1161
|
+
...e,
|
|
1162
|
+
size: nt(
|
|
1163
|
+
e.size,
|
|
1164
|
+
e.orientation ?? "portrait"
|
|
1165
|
+
)
|
|
1166
|
+
},
|
|
1108
1167
|
components: t,
|
|
1109
1168
|
onPaginationCompleted: n
|
|
1110
1169
|
}), this._injectStyle(
|
|
1111
|
-
v.sectionPageMedia(e.id, e.
|
|
1112
|
-
), this._monitor.dispatch("sectionCreated", o), !0;
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1170
|
+
v.sectionPageMedia(e.id, e.size)
|
|
1171
|
+
), await this._monitor.dispatch("sectionCreated", o), !0;
|
|
1172
|
+
}
|
|
1173
|
+
/**
|
|
1174
|
+
* Schedules a pagination operation.
|
|
1175
|
+
*
|
|
1176
|
+
* It is not possible to schedule multiple pagination operations in parallel,
|
|
1177
|
+
* as the process involves DOM manipulation, and concurrent modifications
|
|
1178
|
+
* could cause conflicts and unexpected results.
|
|
1179
|
+
* Each newly scheduled operation is queued and executed sequentially.
|
|
1180
|
+
* When a new pagination is scheduled, any ongoing or pending operations
|
|
1181
|
+
* will be aborted, and the new pagination will start immediately afterward.
|
|
1182
|
+
*
|
|
1183
|
+
* @returns A promise that resolves when the first pagination cycle is completed.
|
|
1184
|
+
* It does not wait for suspended sections to resolve and be paginated.
|
|
1185
|
+
* To wait for all sections to complete pagination, use the
|
|
1186
|
+
* `suspension` property of the returned result object.
|
|
1187
|
+
*/
|
|
1188
|
+
async schedulePagination() {
|
|
1189
|
+
return this._sections.size === 0 ? (window[te] = !0, {
|
|
1116
1190
|
sections: [],
|
|
1117
1191
|
suspension: Promise.resolve()
|
|
1118
1192
|
}) : (this._paginationInProgress && this._currentAbortController && (g.debug(
|
|
1119
|
-
|
|
1193
|
+
w,
|
|
1120
1194
|
"Cancelling previous pagination operation."
|
|
1121
1195
|
), this._currentAbortController.abort(
|
|
1122
1196
|
"Cancelled by new paginate call"
|
|
@@ -1124,33 +1198,51 @@ class pt {
|
|
|
1124
1198
|
this._pendingPaginateResolvers.push({ resolve: e, reject: t });
|
|
1125
1199
|
}) : this._executePagination());
|
|
1126
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);
|
|
1127
1219
|
async _executePagination() {
|
|
1128
1220
|
this._paginationInProgress = !0, this._currentAbortController = new AbortController();
|
|
1129
1221
|
const e = this._currentAbortController.signal;
|
|
1130
1222
|
try {
|
|
1131
|
-
if (g.debug(
|
|
1223
|
+
if (g.debug(w, "Schedule paginate."), await document.fonts.ready, e.aborted)
|
|
1132
1224
|
return new Promise((o, r) => {
|
|
1133
1225
|
this._pendingPaginateResolvers.push({ resolve: o, reject: r });
|
|
1134
1226
|
});
|
|
1135
1227
|
const t = [];
|
|
1136
1228
|
for (const o of this._sections.values()) {
|
|
1137
1229
|
o.context.isPaginated = !1;
|
|
1138
|
-
const r = new
|
|
1230
|
+
const r = new D();
|
|
1139
1231
|
await r.add(o.options.suspense), r.monitor.addEventListener("onChange", (s) => {
|
|
1140
1232
|
g.debug(
|
|
1141
|
-
|
|
1233
|
+
w,
|
|
1142
1234
|
`${s} pending promises in section '${o.options.id}'.`
|
|
1143
1235
|
);
|
|
1144
1236
|
}), r.promise.then(async () => {
|
|
1145
1237
|
e.aborted || (g.debug(
|
|
1146
|
-
|
|
1238
|
+
w,
|
|
1147
1239
|
`Start paginating section '${o.options.id}'.`
|
|
1148
1240
|
), o.context.isSuspended = !1, this._paginateSection(o));
|
|
1149
1241
|
}), t.push(r);
|
|
1150
1242
|
}
|
|
1151
|
-
const n = new
|
|
1152
|
-
return n.monitor.addEventListener("onChange", () => {
|
|
1153
|
-
g.debug(
|
|
1243
|
+
const n = new D();
|
|
1244
|
+
return n.monitor.addEventListener("onChange", async () => {
|
|
1245
|
+
g.debug(w, "Report pagination completed."), await this._monitor.dispatch("paginationCycleCompleted", {
|
|
1154
1246
|
sections: [...this._sections.values()].map(
|
|
1155
1247
|
(o) => o.context
|
|
1156
1248
|
)
|
|
@@ -1160,7 +1252,7 @@ class pt {
|
|
|
1160
1252
|
}) : (await n.add(t.map((o) => o.promise)), {
|
|
1161
1253
|
sections: [...this._sections.values()].map((o) => o.context),
|
|
1162
1254
|
suspension: n.promise.then(() => {
|
|
1163
|
-
window[
|
|
1255
|
+
window[te] = !0;
|
|
1164
1256
|
})
|
|
1165
1257
|
});
|
|
1166
1258
|
} finally {
|
|
@@ -1171,7 +1263,7 @@ class pt {
|
|
|
1171
1263
|
if (this._pendingPaginateResolvers.length === 0)
|
|
1172
1264
|
return;
|
|
1173
1265
|
g.debug(
|
|
1174
|
-
|
|
1266
|
+
w,
|
|
1175
1267
|
`Processing ${this._pendingPaginateResolvers.length} pending paginate calls.`
|
|
1176
1268
|
);
|
|
1177
1269
|
const e = [...this._pendingPaginateResolvers];
|
|
@@ -1182,20 +1274,20 @@ class pt {
|
|
|
1182
1274
|
}
|
|
1183
1275
|
_injectStyle(e) {
|
|
1184
1276
|
let t = document.getElementById(
|
|
1185
|
-
|
|
1277
|
+
X
|
|
1186
1278
|
);
|
|
1187
|
-
t || (t = document.createElement("style"), t.id =
|
|
1279
|
+
t || (t = document.createElement("style"), t.id = X, t.textContent = "", document.head.appendChild(t)), t.textContent = (t.textContent + e).replace(/\s+/g, " ").replace(/\s*([:;{}])\s*/g, "$1").trim();
|
|
1188
1280
|
}
|
|
1189
1281
|
async _paginateSection(e) {
|
|
1190
1282
|
const t = document.createElement("div");
|
|
1191
1283
|
Object.assign(
|
|
1192
1284
|
t.style,
|
|
1193
1285
|
v.page(
|
|
1194
|
-
e.options.
|
|
1195
|
-
e.options.margin ??
|
|
1286
|
+
e.options.size,
|
|
1287
|
+
e.options.margin ?? Re.None
|
|
1196
1288
|
)
|
|
1197
|
-
),
|
|
1198
|
-
const n =
|
|
1289
|
+
), ve() || Object.assign(t.style, v.outOfScreen);
|
|
1290
|
+
const n = Xe(e.components);
|
|
1199
1291
|
n.sectionHeader && (Object.assign(
|
|
1200
1292
|
n.sectionHeader.style,
|
|
1201
1293
|
v.component
|
|
@@ -1203,35 +1295,35 @@ class pt {
|
|
|
1203
1295
|
n.sectionFooter.style,
|
|
1204
1296
|
v.component
|
|
1205
1297
|
), t.appendChild(n.sectionFooter)), document.body.appendChild(t);
|
|
1206
|
-
const { height: o, width: r, sectionHeaderHeight: s, sectionFooterHeight:
|
|
1298
|
+
const { height: o, width: r, sectionHeaderHeight: s, sectionFooterHeight: d } = $e(
|
|
1207
1299
|
n.pageContent,
|
|
1208
1300
|
n.sectionHeader,
|
|
1209
1301
|
n.sectionFooter
|
|
1210
|
-
), P =
|
|
1302
|
+
), P = B.paginate(
|
|
1211
1303
|
n.pageContent,
|
|
1212
1304
|
{ height: o, width: r },
|
|
1213
1305
|
{
|
|
1214
1306
|
id: e.options.id,
|
|
1215
1307
|
plugins: [
|
|
1216
|
-
...e.options.plugins ??
|
|
1308
|
+
...e.options.plugins ?? et,
|
|
1217
1309
|
ze(
|
|
1218
1310
|
o,
|
|
1219
1311
|
s,
|
|
1220
|
-
|
|
1312
|
+
d
|
|
1221
1313
|
)
|
|
1222
1314
|
]
|
|
1223
1315
|
}
|
|
1224
1316
|
);
|
|
1225
1317
|
t.remove();
|
|
1226
|
-
const b = P.map((_,
|
|
1227
|
-
|
|
1318
|
+
const b = P.map((_, W) => ({
|
|
1319
|
+
pageIndex: W,
|
|
1228
1320
|
totalPages: P.length,
|
|
1229
1321
|
sectionId: e.options.id,
|
|
1230
1322
|
pageContentHtml: _
|
|
1231
1323
|
}));
|
|
1232
1324
|
e.onPaginationCompleted(b);
|
|
1233
1325
|
for (const _ of b)
|
|
1234
|
-
this._monitor.dispatch("pageCompleted", _);
|
|
1326
|
+
await this._monitor.dispatch("pageCompleted", _);
|
|
1235
1327
|
const f = {
|
|
1236
1328
|
...e.context,
|
|
1237
1329
|
isPaginated: !0,
|
|
@@ -1241,10 +1333,10 @@ class pt {
|
|
|
1241
1333
|
this._sections.set(e.options.id, {
|
|
1242
1334
|
...e,
|
|
1243
1335
|
context: f
|
|
1244
|
-
}), this._monitor.dispatch("sectionCompleted", f);
|
|
1336
|
+
}), await this._monitor.dispatch("sectionCompleted", f);
|
|
1245
1337
|
}
|
|
1246
1338
|
}
|
|
1247
|
-
const
|
|
1339
|
+
const ie = [
|
|
1248
1340
|
"ad",
|
|
1249
1341
|
"adipisicing",
|
|
1250
1342
|
"aliqua",
|
|
@@ -1308,65 +1400,59 @@ const oe = [
|
|
|
1308
1400
|
"veniam",
|
|
1309
1401
|
"voluptate"
|
|
1310
1402
|
];
|
|
1311
|
-
function
|
|
1403
|
+
function mt(i, e) {
|
|
1312
1404
|
if (i <= 0)
|
|
1313
1405
|
return "";
|
|
1314
1406
|
const t = [], n = Math.floor(e * 982451653);
|
|
1315
1407
|
for (let o = 0; o < i; o++) {
|
|
1316
1408
|
const r = (n + o * 2654435761) % Math.pow(2, 32), s = Math.floor(
|
|
1317
|
-
r / Math.pow(2, 32) *
|
|
1409
|
+
r / Math.pow(2, 32) * ie.length
|
|
1318
1410
|
);
|
|
1319
|
-
t.push(
|
|
1411
|
+
t.push(ie[s]);
|
|
1320
1412
|
}
|
|
1321
1413
|
return t.length > 0 && (t[0] = t[0].charAt(0).toUpperCase() + t[0].slice(1)), t.join(" ") + ".";
|
|
1322
1414
|
}
|
|
1323
|
-
function ht(i, e) {
|
|
1324
|
-
return `${i}-${e + 1}`;
|
|
1325
|
-
}
|
|
1326
|
-
function mt(i, e) {
|
|
1327
|
-
return e === "landscape" ? { height: i.width, width: i.height } : i;
|
|
1328
|
-
}
|
|
1329
1415
|
export {
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1416
|
+
de as EventDispatcher,
|
|
1417
|
+
Ye as PageBreakPlugin,
|
|
1418
|
+
B as Paginator,
|
|
1419
|
+
ht as ReportBuilder,
|
|
1420
|
+
pt as SectionTocPlugin,
|
|
1335
1421
|
h as SplitResult,
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1422
|
+
Qe as TablePlugin,
|
|
1423
|
+
nt as adjustPageSize,
|
|
1424
|
+
C as attributePrefix,
|
|
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,
|
|
1433
|
+
$ as getVisibleHeight,
|
|
1434
|
+
je as globalStyle,
|
|
1435
|
+
X as globalStyleId,
|
|
1436
|
+
rt as ignoredElementClassName,
|
|
1437
|
+
st as ignoredTextClassName,
|
|
1438
|
+
ve as isDebugMode,
|
|
1439
|
+
re as isElement,
|
|
1440
|
+
be as isTextNode,
|
|
1441
|
+
ct as layoutOptionsToAttributes,
|
|
1356
1442
|
g as logger,
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1443
|
+
me as loggerName,
|
|
1444
|
+
lt as moveOffscreen,
|
|
1445
|
+
Ke as pageBreakAttributeName,
|
|
1446
|
+
U as pageClassName,
|
|
1447
|
+
Re as pageMargin,
|
|
1448
|
+
dt as pageSize,
|
|
1449
|
+
He as paprize_isInitialized,
|
|
1450
|
+
te as paprize_isReady,
|
|
1451
|
+
ne as paprize_readJsonDataFile,
|
|
1366
1452
|
T as previewClassName,
|
|
1367
1453
|
v as reportStyles,
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1454
|
+
_e as sectionClassName,
|
|
1455
|
+
tt as sectionTocName,
|
|
1456
|
+
fe as tempContainerClassName
|
|
1371
1457
|
};
|
|
1372
1458
|
//# sourceMappingURL=paprize-core.js.map
|