@paprize/core 0.2.0 → 0.3.0
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/CHANGELOG.md +11 -0
- package/dist/paprize-core.d.ts +729 -0
- package/dist/paprize-core.js +190 -190
- package/dist/paprize-core.js.map +1 -1
- package/dist/paprize-core.umd.cjs +3 -3
- package/dist/paprize-core.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/paprize-core.js
CHANGED
|
@@ -8,7 +8,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
8
8
|
}, c = (n, r, a) => (a = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule ? t(a, "default", {
|
|
9
9
|
value: n,
|
|
10
10
|
enumerable: !0
|
|
11
|
-
}) : a, n)), l = "paprize", u = "pz-temp-container", d = "pz-current-element", f = "pz-current-text", p = "pz-ignored-element", m = "pz-ignored-text", h = "paprize-global-style", g = "pz-page", _ = "pz-section", v = "pz-preview", y = "data-pz-", b = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
|
|
11
|
+
}) : a, n)), l = "paprize", u = "pz-temp-container", d = "pz-current-element", f = "pz-current-text", p = "pz-ignored-element", m = "pz-ignored-text", h = "paprize-global-style", g = "pz-page", _ = "pz-section", v = "pz-preview", y = "data-pz-", b = (/* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
|
|
12
12
|
(function(e, n) {
|
|
13
13
|
typeof define == "function" && define.amd ? define(n) : typeof t == "object" && t.exports ? t.exports = n() : e.log = n();
|
|
14
14
|
})(e, function() {
|
|
@@ -131,74 +131,74 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
131
131
|
return i;
|
|
132
132
|
}, a.default = a, a;
|
|
133
133
|
});
|
|
134
|
-
})))(), 1)
|
|
135
|
-
|
|
134
|
+
})))(), 1)).default.getLogger(l);
|
|
135
|
+
b.setDefaultLevel("info");
|
|
136
136
|
//#endregion
|
|
137
137
|
//#region src/debugUtilities/debugMode.ts
|
|
138
|
-
var
|
|
139
|
-
|
|
140
|
-
},
|
|
138
|
+
var ee = !1, te = () => {
|
|
139
|
+
b.setLevel("debug"), ee = !0;
|
|
140
|
+
}, x = () => ee;
|
|
141
141
|
//#endregion
|
|
142
142
|
//#region src/paginate/domUtilities.ts
|
|
143
|
-
function
|
|
143
|
+
function S(e) {
|
|
144
144
|
return e.nodeType === Node.ELEMENT_NODE;
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function ne(e) {
|
|
147
147
|
return e.nodeType === Node.TEXT_NODE;
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function C(e) {
|
|
150
150
|
let t = e.getBoundingClientRect(), n = getComputedStyle(e), r = parseFloat(n.marginTop) || 0, i = parseFloat(n.marginBottom) || 0;
|
|
151
151
|
return t.height + r + i;
|
|
152
152
|
}
|
|
153
|
-
function
|
|
153
|
+
function re(e) {
|
|
154
154
|
e.style.visibility = "hidden", e.style.position = "absolute", e.style.left = "-9999px", e.style.top = "-9999px";
|
|
155
155
|
}
|
|
156
156
|
//#endregion
|
|
157
157
|
//#region src/paginate/LayoutOptions.ts
|
|
158
|
-
var
|
|
158
|
+
var w = {
|
|
159
159
|
hyphen: "-",
|
|
160
160
|
keepOnSamePage: !1,
|
|
161
161
|
hyphenationDisabled: !1
|
|
162
|
-
},
|
|
162
|
+
}, T = `${y}hyphen`, E = `${y}keep-on-same-page`, D = `${y}hyphenation-disabled`, O = {
|
|
163
163
|
hyphen: {
|
|
164
|
-
key:
|
|
164
|
+
key: T,
|
|
165
165
|
reader: (e) => String(e)
|
|
166
166
|
},
|
|
167
167
|
keepOnSamePage: {
|
|
168
|
-
key:
|
|
168
|
+
key: E,
|
|
169
169
|
reader: (e) => {
|
|
170
170
|
switch (e) {
|
|
171
171
|
case "true": return !0;
|
|
172
172
|
case "false": return !1;
|
|
173
173
|
case "prefer": return "prefer";
|
|
174
|
-
default: return
|
|
174
|
+
default: return w.keepOnSamePage;
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
},
|
|
178
178
|
hyphenationDisabled: {
|
|
179
|
-
key:
|
|
179
|
+
key: D,
|
|
180
180
|
reader: (e) => e === "true"
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
|
-
function
|
|
183
|
+
function ie(e) {
|
|
184
184
|
let t = {};
|
|
185
185
|
for (let [n, r] of Object.entries(e)) {
|
|
186
|
-
let e =
|
|
186
|
+
let e = O[n];
|
|
187
187
|
e !== void 0 && r !== void 0 && (t[e.key] = String(r));
|
|
188
188
|
}
|
|
189
189
|
return t;
|
|
190
190
|
}
|
|
191
191
|
var k = /* @__PURE__ */ new WeakMap();
|
|
192
|
-
function
|
|
192
|
+
function ae(e, t, n, r) {
|
|
193
193
|
n != null && (r[e] = t(n));
|
|
194
194
|
}
|
|
195
195
|
function A(e) {
|
|
196
196
|
if (!e) return {};
|
|
197
197
|
if (!(e instanceof Element)) return A(e?.parentNode);
|
|
198
198
|
let t = {};
|
|
199
|
-
for (let n of Object.keys(
|
|
200
|
-
let r = n, i =
|
|
201
|
-
|
|
199
|
+
for (let n of Object.keys(w)) {
|
|
200
|
+
let r = n, i = O[r], a = e.getAttribute(i.key);
|
|
201
|
+
ae(r, i.reader, a, t);
|
|
202
202
|
}
|
|
203
203
|
let n = {
|
|
204
204
|
...e.parentNode ? k.get(e.parentNode) : void 0,
|
|
@@ -208,44 +208,44 @@ function A(e) {
|
|
|
208
208
|
}
|
|
209
209
|
//#endregion
|
|
210
210
|
//#region src/paginate/PaginationOptions.ts
|
|
211
|
-
var
|
|
211
|
+
var oe = {
|
|
212
212
|
id: "default",
|
|
213
213
|
plugins: [],
|
|
214
|
-
...
|
|
214
|
+
...w
|
|
215
215
|
};
|
|
216
216
|
function se(e, t) {
|
|
217
217
|
let n = A(e);
|
|
218
218
|
return {
|
|
219
|
-
...
|
|
219
|
+
...oe,
|
|
220
220
|
...t,
|
|
221
221
|
...n
|
|
222
222
|
};
|
|
223
223
|
}
|
|
224
224
|
//#endregion
|
|
225
225
|
//#region src/paginate/PaginationPlugin.ts
|
|
226
|
-
var
|
|
227
|
-
function
|
|
226
|
+
var j = "\x1B[46mPLUGIN\x1B[0m";
|
|
227
|
+
function M(e, t, ...n) {
|
|
228
228
|
e.sort((e, t) => e.order - t.order).forEach((e) => {
|
|
229
229
|
let r = e[t];
|
|
230
230
|
if (r) {
|
|
231
|
-
|
|
231
|
+
b.debug(j, `executing plugin ${e.name}:${String(t)} ()`, n);
|
|
232
232
|
try {
|
|
233
|
-
r(...n),
|
|
233
|
+
r(...n), b.debug(j, `plugin ${e.name}:${String(t)} executed`, n);
|
|
234
234
|
} catch (n) {
|
|
235
|
-
|
|
235
|
+
b.debug(j, `plugin ${e.name}:${String(t)} failed`, n);
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
});
|
|
239
239
|
}
|
|
240
240
|
//#endregion
|
|
241
241
|
//#region src/paginate/PageNodes.ts
|
|
242
|
-
var
|
|
242
|
+
var N = {
|
|
243
243
|
Element: "element",
|
|
244
244
|
Text: "text"
|
|
245
|
-
},
|
|
245
|
+
}, P = class e {
|
|
246
246
|
_node;
|
|
247
247
|
config;
|
|
248
|
-
type =
|
|
248
|
+
type = N.Element;
|
|
249
249
|
transaction;
|
|
250
250
|
clonedData;
|
|
251
251
|
constructor(e, t, n, r) {
|
|
@@ -269,10 +269,10 @@ var P = {
|
|
|
269
269
|
}
|
|
270
270
|
clone(t) {
|
|
271
271
|
let n = new e(this._node.cloneNode(t), this.transaction, this.config, this);
|
|
272
|
-
return
|
|
272
|
+
return M(this.config.plugins, "onClone", this.config.id, this._node, n), n;
|
|
273
273
|
}
|
|
274
274
|
getHeight() {
|
|
275
|
-
return
|
|
275
|
+
return C(this._node);
|
|
276
276
|
}
|
|
277
277
|
remove() {
|
|
278
278
|
this.transaction.addCommitCallback(() => {
|
|
@@ -290,7 +290,7 @@ var P = {
|
|
|
290
290
|
}
|
|
291
291
|
}, ce = class {
|
|
292
292
|
_node;
|
|
293
|
-
type =
|
|
293
|
+
type = N.Text;
|
|
294
294
|
transaction;
|
|
295
295
|
config;
|
|
296
296
|
constructor(e, t, n) {
|
|
@@ -311,25 +311,25 @@ var P = {
|
|
|
311
311
|
return this._node;
|
|
312
312
|
}
|
|
313
313
|
};
|
|
314
|
-
function
|
|
315
|
-
if (
|
|
316
|
-
if (
|
|
314
|
+
function F(e, t, n) {
|
|
315
|
+
if (ne(e)) return new ce(e, t, n);
|
|
316
|
+
if (S(e)) return new P(e, t, n);
|
|
317
317
|
throw Error("Unsupported node type");
|
|
318
318
|
}
|
|
319
319
|
//#endregion
|
|
320
320
|
//#region src/debugUtilities/pageNodeMarker.ts
|
|
321
321
|
function le(e) {
|
|
322
|
-
|
|
322
|
+
x() && (e && e.type == N.Element ? e.getNode().classList.add(p) : e && e.type == N.Text && e.getNode().parentElement?.classList.add(m));
|
|
323
323
|
}
|
|
324
324
|
function ue(e) {
|
|
325
|
-
|
|
325
|
+
x() && (e && e.type == N.Element ? e.getNode().classList.add(d) : e && e.type == N.Text && e.getNode().parentElement?.classList.add(f));
|
|
326
326
|
}
|
|
327
|
-
function
|
|
328
|
-
|
|
327
|
+
function I(e) {
|
|
328
|
+
x() && (e && e.type == N.Element ? e.getNode().classList.remove(d) : e && e.type == N.Text && e.getNode().parentElement?.classList.remove(f));
|
|
329
329
|
}
|
|
330
330
|
//#endregion
|
|
331
331
|
//#region src/paginate/DomState.ts
|
|
332
|
-
var
|
|
332
|
+
var L = "\x1B[106mDOM\x1B[0m", de = class {
|
|
333
333
|
_transaction;
|
|
334
334
|
_treeWalker;
|
|
335
335
|
_config;
|
|
@@ -349,22 +349,22 @@ var R = "\x1B[106mDOM\x1B[0m", de = class {
|
|
|
349
349
|
return this._previousNode;
|
|
350
350
|
}
|
|
351
351
|
goToNextNode() {
|
|
352
|
-
this._treeWalker.nextNode() || (this._completed = !0),
|
|
352
|
+
this._treeWalker.nextNode() || (this._completed = !0), b.debug(L, "moving to next node"), this.setState();
|
|
353
353
|
}
|
|
354
354
|
goToNextSiblingOrParentSibling() {
|
|
355
355
|
let e = 0;
|
|
356
|
-
if (this._treeWalker.nextSibling()) return
|
|
357
|
-
for (; this._treeWalker.parentNode();) if (e++, this._treeWalker.nextSibling()) return
|
|
356
|
+
if (this._treeWalker.nextSibling()) return b.debug(L, "moving to next sibling node"), this.setState(), { parentsTraversed: e };
|
|
357
|
+
for (; this._treeWalker.parentNode();) if (e++, this._treeWalker.nextSibling()) return b.debug(L, "moving to parent sibling node, traversed:", e), this.setState(), { parentsTraversed: e };
|
|
358
358
|
return this._completed = !0, { parentsTraversed: e };
|
|
359
359
|
}
|
|
360
360
|
goToFirstChildOrNextNode() {
|
|
361
|
-
return this._treeWalker.firstChild() ? (
|
|
361
|
+
return this._treeWalker.firstChild() ? (b.debug(L, "moving to first child node"), this.setState(), { parentsTraversed: 1 }) : (this.goToNextNode(), { parentsTraversed: 0 });
|
|
362
362
|
}
|
|
363
363
|
setState() {
|
|
364
|
-
this._previousNode = this._currentNode, this._currentNode =
|
|
364
|
+
this._previousNode = this._currentNode, this._currentNode = F(this._treeWalker.currentNode, this._transaction, se(this._treeWalker.currentNode, this._config));
|
|
365
365
|
DEV: ue(this._currentNode);
|
|
366
|
-
DEV:
|
|
367
|
-
|
|
366
|
+
DEV: I(this._previousNode);
|
|
367
|
+
b.debug(L, "moved to node", {
|
|
368
368
|
currentNode: this._currentNode,
|
|
369
369
|
previousNode: this._previousNode
|
|
370
370
|
});
|
|
@@ -396,21 +396,20 @@ var R = "\x1B[106mDOM\x1B[0m", de = class {
|
|
|
396
396
|
commit = () => {
|
|
397
397
|
this.isActive && (this.isActive = !1, this._onCommit.forEach((e) => e()));
|
|
398
398
|
};
|
|
399
|
-
},
|
|
399
|
+
}, R = "\x1B[102mPAGE\x1B[0m", z = class e {
|
|
400
400
|
currentPage;
|
|
401
401
|
activeElement;
|
|
402
402
|
currentElement;
|
|
403
403
|
parentStack;
|
|
404
|
-
pageIsFull;
|
|
405
404
|
pageIndex;
|
|
406
405
|
pageHeight;
|
|
407
|
-
constructor(e, t, n, r, i, a
|
|
408
|
-
this.currentPage = e, this.activeElement = t, this.currentElement = n, this.parentStack = r, this.
|
|
406
|
+
constructor(e, t, n, r, i, a) {
|
|
407
|
+
this.currentPage = e, this.activeElement = t, this.currentElement = n, this.parentStack = r, this.pageIndex = i, this.pageHeight = a;
|
|
409
408
|
}
|
|
410
409
|
static create(t, n, r, i) {
|
|
411
|
-
return new e(t, null, t, n,
|
|
410
|
+
return new e(t, null, t, n, r, i);
|
|
412
411
|
}
|
|
413
|
-
clone = () => new e(this.currentPage, this.activeElement, this.currentElement, [...this.parentStack], this.
|
|
412
|
+
clone = () => new e(this.currentPage, this.activeElement, this.currentElement, [...this.parentStack], this.pageIndex, this.pageHeight);
|
|
414
413
|
}, pe = class e {
|
|
415
414
|
_pageState;
|
|
416
415
|
_transaction;
|
|
@@ -419,11 +418,11 @@ var R = "\x1B[106mDOM\x1B[0m", de = class {
|
|
|
419
418
|
constructor(t, n, r, i) {
|
|
420
419
|
this._tempContainer = t, this._config = i, this._transaction = r;
|
|
421
420
|
let a = e.createPageHtmlElement(n.width), o = this.createNewPage(a);
|
|
422
|
-
this._pageState =
|
|
421
|
+
this._pageState = z.create(o, [], 0, n.height), M(this._config.plugins, "onNewPage", i.id, this);
|
|
423
422
|
}
|
|
424
423
|
nextPage() {
|
|
425
|
-
let e = this.createNewPage(this._pageState.currentPage.getNode().cloneNode(!1)), t =
|
|
426
|
-
this.cloneParentStackToNewPage(t), this.cleanupEmptyParent(), this._pageState = t,
|
|
424
|
+
let e = this.createNewPage(this._pageState.currentPage.getNode().cloneNode(!1)), t = z.create(e, [], this._pageState.pageIndex + 1, this._pageState.pageHeight);
|
|
425
|
+
this.cloneParentStackToNewPage(t), this.cleanupEmptyParent(), this._pageState = t, M(this._config.plugins, "onNewPage", this._config.id, this);
|
|
427
426
|
}
|
|
428
427
|
cloneParentStackToNewPage(e) {
|
|
429
428
|
for (let t of this._pageState.parentStack) {
|
|
@@ -441,13 +440,13 @@ var R = "\x1B[106mDOM\x1B[0m", de = class {
|
|
|
441
440
|
});
|
|
442
441
|
}
|
|
443
442
|
enterElement() {
|
|
444
|
-
if (!this._pageState.activeElement || this._pageState.activeElement.type !==
|
|
445
|
-
|
|
443
|
+
if (!this._pageState.activeElement || this._pageState.activeElement.type !== N.Element) throw Error("Invalid state: activeElement is not an Element");
|
|
444
|
+
b.debug(R, "entering an element", this._pageState.activeElement), this._pageState.currentElement = this._pageState.activeElement, this._pageState.parentStack.push(this._pageState.activeElement);
|
|
446
445
|
}
|
|
447
446
|
leaveElement() {
|
|
448
447
|
this._pageState.activeElement = null;
|
|
449
448
|
let e = this._pageState.parentStack.pop();
|
|
450
|
-
|
|
449
|
+
b.debug(R, "leaving a parent element", e);
|
|
451
450
|
let t = this._pageState.parentStack.at(-1);
|
|
452
451
|
this._pageState.currentElement = t ?? this._pageState.currentPage;
|
|
453
452
|
}
|
|
@@ -456,9 +455,9 @@ var R = "\x1B[106mDOM\x1B[0m", de = class {
|
|
|
456
455
|
return t.style.width = `${e}px`, t.style.maxWidth = `${e}px`, t.className = g, t;
|
|
457
456
|
}
|
|
458
457
|
createNewPage(e) {
|
|
459
|
-
return
|
|
458
|
+
return b.debug(R, "creating new page"), this._tempContainer.appendChild(e), this._transaction.isActive && this._transaction.addRollbackCallback(() => {
|
|
460
459
|
this._tempContainer.removeChild(e);
|
|
461
|
-
}),
|
|
460
|
+
}), F(e, this._transaction, this._config);
|
|
462
461
|
}
|
|
463
462
|
startTransaction() {
|
|
464
463
|
this._transaction.start();
|
|
@@ -468,28 +467,25 @@ var R = "\x1B[106mDOM\x1B[0m", de = class {
|
|
|
468
467
|
}), this._transaction;
|
|
469
468
|
}
|
|
470
469
|
hasEmptySpace(e) {
|
|
471
|
-
return
|
|
470
|
+
return this._pageState.currentPage.getHeight() + (e || 1e-4) <= this._pageState.pageHeight;
|
|
472
471
|
}
|
|
473
472
|
isOverFlow() {
|
|
474
|
-
return this._pageState.
|
|
475
|
-
}
|
|
476
|
-
markPageAsFull() {
|
|
477
|
-
x.debug(z, "marking page as full", this._pageState.activeElement), this._pageState.pageIsFull = !0;
|
|
473
|
+
return this._pageState.currentPage.getHeight() > this._pageState.pageHeight;
|
|
478
474
|
}
|
|
479
475
|
appendChild(e, t) {
|
|
480
476
|
let n = e.clone(t);
|
|
481
|
-
DEV:
|
|
477
|
+
DEV: I(n);
|
|
482
478
|
return this._pageState.currentElement.appendChild(n), this._pageState.activeElement = n, n;
|
|
483
479
|
}
|
|
484
480
|
addTextNode(e) {
|
|
485
|
-
if (this._pageState.activeElement?.type ===
|
|
486
|
-
let t =
|
|
481
|
+
if (this._pageState.activeElement?.type === N.Text) return this._pageState.activeElement;
|
|
482
|
+
let t = F(document.createTextNode(e), this._transaction, this._config);
|
|
487
483
|
return this._pageState.currentElement.appendChild(t), this._pageState.activeElement = t, t;
|
|
488
484
|
}
|
|
489
485
|
getPageState() {
|
|
490
486
|
return this._pageState;
|
|
491
487
|
}
|
|
492
|
-
},
|
|
488
|
+
}, B = {
|
|
493
489
|
None: 0,
|
|
494
490
|
FullNodePlaced: 1,
|
|
495
491
|
SplitChildren: 2
|
|
@@ -497,33 +493,33 @@ var R = "\x1B[106mDOM\x1B[0m", de = class {
|
|
|
497
493
|
//#endregion
|
|
498
494
|
//#region src/paginate/paginateElement.ts
|
|
499
495
|
function me(e, t) {
|
|
500
|
-
let n =
|
|
501
|
-
if (n !==
|
|
496
|
+
let n = V(e, t);
|
|
497
|
+
if (n !== B.None) return n;
|
|
502
498
|
let { rollback: r, commit: i } = t.startTransaction();
|
|
503
499
|
t.nextPage();
|
|
504
|
-
let a =
|
|
505
|
-
return a ===
|
|
500
|
+
let a = V(e, t);
|
|
501
|
+
return a === B.None ? (r(), e.config.keepOnSamePage === "prefer" ? H(e, t) : B.None) : (i(), a);
|
|
506
502
|
}
|
|
507
|
-
function
|
|
503
|
+
function V(e, t) {
|
|
508
504
|
if (t.hasEmptySpace(e.getHeight())) {
|
|
509
505
|
let n = t.appendChild(e, !0);
|
|
510
506
|
if (t.isOverFlow()) n.remove();
|
|
511
|
-
else return
|
|
507
|
+
else return B.FullNodePlaced;
|
|
512
508
|
}
|
|
513
|
-
return e.config.keepOnSamePage === !1 ?
|
|
509
|
+
return e.config.keepOnSamePage === !1 ? H(e, t) : B.None;
|
|
514
510
|
}
|
|
515
|
-
function
|
|
516
|
-
if (e.getChildrenCount() === 0) return
|
|
511
|
+
function H(e, t) {
|
|
512
|
+
if (e.getChildrenCount() === 0) return B.None;
|
|
517
513
|
let n = t.appendChild(e, !1);
|
|
518
|
-
return t.isOverFlow() ? (n.remove(),
|
|
514
|
+
return t.isOverFlow() ? (n.remove(), B.None) : B.SplitChildren;
|
|
519
515
|
}
|
|
520
516
|
//#endregion
|
|
521
517
|
//#region src/paginate/paginateText.ts
|
|
522
518
|
function he(e, t) {
|
|
523
|
-
let n =
|
|
519
|
+
let n = B.FullNodePlaced, r = e.textContent.split(/(\s+)/).filter((e) => e !== ""), i, a = 0;
|
|
524
520
|
for (; i || a < r.length;) {
|
|
525
521
|
let o = ge(i ?? r[a], t, e.config);
|
|
526
|
-
o.completed || (n =
|
|
522
|
+
o.completed || (n = B.None), o.pendingToken ? i = o.pendingToken : (i = void 0, a++);
|
|
527
523
|
}
|
|
528
524
|
return n;
|
|
529
525
|
}
|
|
@@ -540,7 +536,7 @@ function ge(e, t, n) {
|
|
|
540
536
|
function _e(e, t, n) {
|
|
541
537
|
let { rollback: r, commit: i } = t.startTransaction();
|
|
542
538
|
if (t.nextPage(), t.addTextNode(e), !t.isOverFlow()) return i(), { completed: !0 };
|
|
543
|
-
if (r(), n.hyphenationDisabled) return
|
|
539
|
+
if (r(), n.hyphenationDisabled) return b.warn("Hyphenation disabled, skipping oversized token:", e), { completed: !1 };
|
|
544
540
|
t.hasEmptySpace() || t.nextPage();
|
|
545
541
|
let a = ve(e, n.hyphen, t);
|
|
546
542
|
return {
|
|
@@ -552,14 +548,32 @@ function ve(e, t, n) {
|
|
|
552
548
|
let r = n.addTextNode(""), i = "";
|
|
553
549
|
for (let a = 0; a < e.length; a++) {
|
|
554
550
|
let o = e[a], s = i + o;
|
|
555
|
-
if (r.textContent = s + t, !n.hasEmptySpace()) return r.textContent = i ? i + t : "", n.
|
|
551
|
+
if (r.textContent = s + t, !n.hasEmptySpace()) return r.textContent = i ? i + t : "", n.nextPage(), e.slice(a);
|
|
556
552
|
i = s;
|
|
557
553
|
}
|
|
558
554
|
return null;
|
|
559
555
|
}
|
|
560
556
|
//#endregion
|
|
557
|
+
//#region src/utils.ts
|
|
558
|
+
function ye(e, t) {
|
|
559
|
+
return `${e}-${t + 1}`;
|
|
560
|
+
}
|
|
561
|
+
function U(e, t) {
|
|
562
|
+
return t === "landscape" ? {
|
|
563
|
+
height: e.width,
|
|
564
|
+
width: e.height
|
|
565
|
+
} : e;
|
|
566
|
+
}
|
|
567
|
+
function W(e) {
|
|
568
|
+
if (!e) return "undefined";
|
|
569
|
+
let t = e.getNode();
|
|
570
|
+
if (!(t instanceof Element)) return String(t).slice(0, 100);
|
|
571
|
+
let n = t.id ? `#${t.id}` : "", r = t.classList.length ? `.${Array.from(t.classList).join(".")}` : "";
|
|
572
|
+
return `<${t.tagName.toLowerCase()}${n}${r}>`;
|
|
573
|
+
}
|
|
574
|
+
//#endregion
|
|
561
575
|
//#region src/paginate/Paginator.ts
|
|
562
|
-
var
|
|
576
|
+
var G = "\x1B[103mPAGINATOR\x1B[0m", K = class e {
|
|
563
577
|
_domState;
|
|
564
578
|
_pageManager;
|
|
565
579
|
_transaction;
|
|
@@ -567,66 +581,66 @@ var W = "\x1B[103mPAGINATOR\x1B[0m", G = class e {
|
|
|
567
581
|
_config;
|
|
568
582
|
constructor(t, n, r) {
|
|
569
583
|
this._config = {
|
|
570
|
-
...
|
|
584
|
+
...oe,
|
|
571
585
|
...r
|
|
572
586
|
}, this._tempContainer = e.createTempContainer(this._config.id), this._transaction = new fe(), this._domState = new de(t, this._transaction, this._config), this._pageManager = new pe(this._tempContainer, n, this._transaction, this._config);
|
|
573
587
|
}
|
|
574
588
|
static createTempContainer(e) {
|
|
575
589
|
let t = document.createElement("div");
|
|
576
|
-
return t.style.display = "flex", t.style.flexDirection = "column", t.style.gap = "20px", t.setAttribute(`${y}-section-id`, e), t.classList.add(u),
|
|
590
|
+
return t.style.display = "flex", t.style.flexDirection = "column", t.style.gap = "20px", t.setAttribute(`${y}-section-id`, e), t.classList.add(u), x() || re(t), document.body.appendChild(t), t;
|
|
577
591
|
}
|
|
578
592
|
static paginate(t, n, r) {
|
|
579
593
|
let i = new e(t, n, r);
|
|
580
594
|
i.processAllNodes();
|
|
581
|
-
let a = Array.from(i._tempContainer.childNodes).filter((e) =>
|
|
582
|
-
return
|
|
595
|
+
let a = Array.from(i._tempContainer.childNodes).filter((e) => S(e)).map((e) => e.innerHTML);
|
|
596
|
+
return x() ? Array.from(i._tempContainer.childNodes).forEach((e) => {
|
|
583
597
|
let t = e;
|
|
584
598
|
t.style.height = `${n.height}px`, t.style.width = `${n.width}px`;
|
|
585
599
|
}) : i._tempContainer.remove(), a;
|
|
586
600
|
}
|
|
587
601
|
processAllNodes() {
|
|
588
|
-
|
|
602
|
+
M(this._config.plugins, "beforePagination", this._config.id, this._domState, this._pageManager), this._domState.goToNextNode();
|
|
589
603
|
do {
|
|
590
|
-
b.
|
|
604
|
+
b.debug(G, "paginating node", this._domState.currentNode);
|
|
591
605
|
let e = this.processCurrentNode();
|
|
592
|
-
switch (
|
|
593
|
-
case
|
|
606
|
+
switch (M(this._config.plugins, "afterVisitNode", this._config.id, e, this._domState, this._pageManager), e) {
|
|
607
|
+
case B.None:
|
|
594
608
|
this.handleNodeSkipped();
|
|
595
609
|
break;
|
|
596
|
-
case
|
|
610
|
+
case B.FullNodePlaced:
|
|
597
611
|
this.handleFullNodePlaced();
|
|
598
612
|
break;
|
|
599
|
-
case
|
|
613
|
+
case B.SplitChildren:
|
|
600
614
|
this.handleChildrenSplit();
|
|
601
615
|
break;
|
|
602
616
|
}
|
|
603
617
|
} while (this._domState.completed === !1);
|
|
604
|
-
|
|
618
|
+
M(this._config.plugins, "afterPagination", this._config.id, this._domState, this._pageManager), b.debug(G, "pagination completed");
|
|
605
619
|
}
|
|
606
620
|
handleNodeSkipped() {
|
|
607
|
-
b.
|
|
621
|
+
b.error("Node is too big to fit on a page. Skipping node:", W(this._domState.currentNode), this._domState.currentNode);
|
|
608
622
|
DEV: le(this._domState.currentNode);
|
|
609
623
|
this._domState.goToNextSiblingOrParentSibling();
|
|
610
624
|
}
|
|
611
625
|
handleFullNodePlaced() {
|
|
612
|
-
b.
|
|
626
|
+
b.debug(G, "node fully paginated");
|
|
613
627
|
let { parentsTraversed: e } = this._domState.goToNextSiblingOrParentSibling();
|
|
614
628
|
for (let t = 0; t < e; t++) this._pageManager.leaveElement();
|
|
615
629
|
}
|
|
616
630
|
handleChildrenSplit() {
|
|
617
|
-
b.
|
|
631
|
+
b.debug(G, "node partially paginated - splitting children"), this._domState.goToFirstChildOrNextNode().parentsTraversed === 1 && this._domState.previousNode?.type === N.Element && this._pageManager.enterElement();
|
|
618
632
|
}
|
|
619
633
|
processCurrentNode() {
|
|
620
|
-
if (!this._domState.currentNode) return
|
|
621
|
-
if (this._domState.currentNode.type ===
|
|
634
|
+
if (!this._domState.currentNode) return B.None;
|
|
635
|
+
if (this._domState.currentNode.type === N.Element) {
|
|
622
636
|
let e = {};
|
|
623
|
-
return
|
|
637
|
+
return M(this._config.plugins, "onVisitElement", this._config.id, this._domState, this._pageManager, e), e.result === void 0 ? me(this._domState.currentNode, this._pageManager) : e.result;
|
|
624
638
|
} else {
|
|
625
639
|
let e = {};
|
|
626
|
-
return
|
|
640
|
+
return M(this._config.plugins, "onVisitText", this._config.id, this._domState, this._pageManager, e), e.result === void 0 ? he(this._domState.currentNode, this._pageManager) : e.result;
|
|
627
641
|
}
|
|
628
642
|
}
|
|
629
|
-
},
|
|
643
|
+
}, q = class {
|
|
630
644
|
registry = /* @__PURE__ */ new Map();
|
|
631
645
|
addEventListener(e, t) {
|
|
632
646
|
let { registry: n } = this, r = new Set(n.get(e));
|
|
@@ -640,7 +654,7 @@ var W = "\x1B[103mPAGINATOR\x1B[0m", G = class e {
|
|
|
640
654
|
let { registry: n } = this, r = n.get(e);
|
|
641
655
|
if (r) for (let e of r) await e(...t);
|
|
642
656
|
}
|
|
643
|
-
},
|
|
657
|
+
}, be = {
|
|
644
658
|
A1: {
|
|
645
659
|
height: "841mm",
|
|
646
660
|
width: "594mm"
|
|
@@ -689,7 +703,7 @@ var W = "\x1B[103mPAGINATOR\x1B[0m", G = class e {
|
|
|
689
703
|
height: "11in",
|
|
690
704
|
width: "17in"
|
|
691
705
|
}
|
|
692
|
-
},
|
|
706
|
+
}, xe = {
|
|
693
707
|
Normal: {
|
|
694
708
|
top: "1in",
|
|
695
709
|
right: "1in",
|
|
@@ -714,26 +728,26 @@ var W = "\x1B[103mPAGINATOR\x1B[0m", G = class e {
|
|
|
714
728
|
bottom: "0in",
|
|
715
729
|
left: "0in"
|
|
716
730
|
}
|
|
717
|
-
}, J = "__PAPRIZE_IS_INITIALIZED", Y = "__PAPRIZE_IS_READY",
|
|
731
|
+
}, J = "__PAPRIZE_IS_INITIALIZED", Y = "__PAPRIZE_IS_READY", Se = "__PAPRIZE_READ_JSON_DATA_FILE";
|
|
718
732
|
//#endregion
|
|
719
733
|
//#region src/report/utils.ts
|
|
720
|
-
function
|
|
734
|
+
function Ce(e) {
|
|
721
735
|
let t = e.getBoundingClientRect(), n = getComputedStyle(e), r = parseFloat(n.marginLeft) || 0, i = parseFloat(n.marginRight) || 0;
|
|
722
736
|
return {
|
|
723
|
-
height:
|
|
737
|
+
height: C(e),
|
|
724
738
|
width: t.width + r + i
|
|
725
739
|
};
|
|
726
740
|
}
|
|
727
|
-
function
|
|
728
|
-
let { height: r, width: i } =
|
|
741
|
+
function we(e, t, n) {
|
|
742
|
+
let { height: r, width: i } = Ce(e);
|
|
729
743
|
return {
|
|
730
744
|
height: r,
|
|
731
745
|
width: i,
|
|
732
|
-
sectionHeaderHeight: t ?
|
|
733
|
-
sectionFooterHeight: n ?
|
|
746
|
+
sectionHeaderHeight: t ? C(t) : 0,
|
|
747
|
+
sectionFooterHeight: n ? C(n) : 0
|
|
734
748
|
};
|
|
735
749
|
}
|
|
736
|
-
function
|
|
750
|
+
function Te(e, t, n) {
|
|
737
751
|
return {
|
|
738
752
|
name: "sectionPageHeight",
|
|
739
753
|
order: 1,
|
|
@@ -746,21 +760,21 @@ function Ce(e, t, n) {
|
|
|
746
760
|
}
|
|
747
761
|
};
|
|
748
762
|
}
|
|
749
|
-
function
|
|
763
|
+
function Ee(e) {
|
|
750
764
|
return e ? `${e.top} ${e.right} ${e.bottom} ${e.left}` : "0";
|
|
751
765
|
}
|
|
752
|
-
function
|
|
766
|
+
function De(e) {
|
|
753
767
|
let t = null;
|
|
754
768
|
return () => (t ||= e(), t);
|
|
755
769
|
}
|
|
756
|
-
async function
|
|
770
|
+
async function Oe() {
|
|
757
771
|
if (!("__PAPRIZE_READ_JSON_DATA_FILE" in window)) return null;
|
|
758
|
-
let e = await window[
|
|
772
|
+
let e = await window[Se]?.();
|
|
759
773
|
return e ? JSON.parse(e) : null;
|
|
760
774
|
}
|
|
761
775
|
//#endregion
|
|
762
776
|
//#region src/report/reportStyles.ts
|
|
763
|
-
var
|
|
777
|
+
var ke = `
|
|
764
778
|
html {
|
|
765
779
|
box-sizing: border-box;
|
|
766
780
|
}
|
|
@@ -808,35 +822,35 @@ var De = `
|
|
|
808
822
|
display: none !important;
|
|
809
823
|
}
|
|
810
824
|
}
|
|
811
|
-
`,
|
|
825
|
+
`, Ae = {
|
|
812
826
|
display: "flex",
|
|
813
827
|
flexDirection: "column"
|
|
814
|
-
},
|
|
828
|
+
}, je = {
|
|
815
829
|
position: "absolute",
|
|
816
830
|
left: "-9999px",
|
|
817
831
|
top: "-9999px",
|
|
818
832
|
visibility: "hidden"
|
|
819
|
-
},
|
|
833
|
+
}, Me = (e, t) => ({
|
|
820
834
|
display: "flex",
|
|
821
835
|
flexDirection: "column",
|
|
822
836
|
width: e.width,
|
|
823
837
|
height: e.height,
|
|
824
838
|
maxHeight: e.height,
|
|
825
839
|
position: "relative",
|
|
826
|
-
padding:
|
|
840
|
+
padding: Ee(t),
|
|
827
841
|
zIndex: "1"
|
|
828
|
-
}),
|
|
842
|
+
}), Ne = {
|
|
829
843
|
overflow: "hidden",
|
|
830
844
|
width: "100%",
|
|
831
845
|
height: "100%"
|
|
832
|
-
},
|
|
846
|
+
}, Pe = {
|
|
833
847
|
position: "absolute",
|
|
834
848
|
width: "100%",
|
|
835
849
|
height: "100%",
|
|
836
850
|
left: 0,
|
|
837
851
|
top: 0
|
|
838
|
-
},
|
|
839
|
-
function
|
|
852
|
+
}, Fe = (e) => ({ page: `section-${e}` });
|
|
853
|
+
function Ie(e, t) {
|
|
840
854
|
return `@page section-${e} {
|
|
841
855
|
margin: none;
|
|
842
856
|
size:${t.width} ${t.height};
|
|
@@ -845,21 +859,21 @@ function Pe(e, t) {
|
|
|
845
859
|
}`;
|
|
846
860
|
}
|
|
847
861
|
var X = {
|
|
848
|
-
globalStyle:
|
|
849
|
-
component:
|
|
850
|
-
outOfScreen:
|
|
851
|
-
page:
|
|
852
|
-
overlay:
|
|
853
|
-
pageContent:
|
|
854
|
-
sectionPageMedia:
|
|
855
|
-
section:
|
|
862
|
+
globalStyle: ke,
|
|
863
|
+
component: Ae,
|
|
864
|
+
outOfScreen: je,
|
|
865
|
+
page: Me,
|
|
866
|
+
overlay: Pe,
|
|
867
|
+
pageContent: Ne,
|
|
868
|
+
sectionPageMedia: Ie,
|
|
869
|
+
section: Fe
|
|
856
870
|
};
|
|
857
871
|
//#endregion
|
|
858
872
|
//#region src/report/sectionComponents.ts
|
|
859
873
|
function Z(e) {
|
|
860
874
|
return e?.cloneNode(!0) ?? null;
|
|
861
875
|
}
|
|
862
|
-
function
|
|
876
|
+
function Le(e) {
|
|
863
877
|
return {
|
|
864
878
|
sectionHeader: Z(e.sectionHeader),
|
|
865
879
|
sectionFooter: Z(e.sectionFooter),
|
|
@@ -870,7 +884,7 @@ function Fe(e) {
|
|
|
870
884
|
}
|
|
871
885
|
//#endregion
|
|
872
886
|
//#region src/plugins/OrderedListPlugin.ts
|
|
873
|
-
var
|
|
887
|
+
var Re = class {
|
|
874
888
|
_originalItemCount = /* @__PURE__ */ new Map();
|
|
875
889
|
name = "orderedList";
|
|
876
890
|
order = 1;
|
|
@@ -911,14 +925,14 @@ var Ie = class {
|
|
|
911
925
|
_getListItemCount(e) {
|
|
912
926
|
return [...e.children].filter((e) => this._isListItem(e)).length;
|
|
913
927
|
}
|
|
914
|
-
},
|
|
928
|
+
}, Q = `${y}page-break`, ze = class {
|
|
915
929
|
name = "pageBreak";
|
|
916
930
|
order = 1;
|
|
917
931
|
onVisitElement = (e, t, n, r) => {
|
|
918
|
-
let i = t.currentNode.getNode().getAttribute(
|
|
919
|
-
(i === "true" || i === "") && (n.
|
|
932
|
+
let i = t.currentNode.getNode().getAttribute(Q);
|
|
933
|
+
(i === "true" || i === "") && (n.nextPage(), r.result = B.FullNodePlaced);
|
|
920
934
|
};
|
|
921
|
-
},
|
|
935
|
+
}, Be = class {
|
|
922
936
|
_options = {};
|
|
923
937
|
name = "table";
|
|
924
938
|
order = 1;
|
|
@@ -933,13 +947,13 @@ var Ie = class {
|
|
|
933
947
|
if (a === null) return;
|
|
934
948
|
let o = i.tBodies;
|
|
935
949
|
if (this._isTableBodyEmpty(o) && (r.remove(), n.getNode().tHead === null)) {
|
|
936
|
-
let e =
|
|
950
|
+
let e = F(a.cloneNode(!0), n.transaction, n.config);
|
|
937
951
|
n.appendChild(e);
|
|
938
952
|
}
|
|
939
953
|
};
|
|
940
954
|
onVisitElement = (e, t, n, r) => {
|
|
941
955
|
let i = t.currentNode.getNode();
|
|
942
|
-
i.tagName === "TR" ? t.currentNode.config.keepOnSamePage = "prefer" : (i.tagName === "TFOOT" && this._options.cloneFooter || i.tagName === "THEAD" && this._options.cloneHeader) && (r.result =
|
|
956
|
+
i.tagName === "TR" ? t.currentNode.config.keepOnSamePage = "prefer" : (i.tagName === "TFOOT" && this._options.cloneFooter || i.tagName === "THEAD" && this._options.cloneHeader) && (r.result = B.FullNodePlaced);
|
|
943
957
|
};
|
|
944
958
|
onClone = (e, t, n) => {
|
|
945
959
|
if (!this._isTable(t) || !n.clonedData.clonedFrom) return;
|
|
@@ -947,12 +961,12 @@ var Ie = class {
|
|
|
947
961
|
if (r.tHead || r.tFoot) return;
|
|
948
962
|
let i = n.getOriginalNode(), a = i.tHead;
|
|
949
963
|
if (a && this._options.cloneHeader === !0) {
|
|
950
|
-
let e = new
|
|
964
|
+
let e = new P(a.cloneNode(!0), n.transaction, n.config);
|
|
951
965
|
n.appendChild(e);
|
|
952
966
|
}
|
|
953
967
|
let o = i.tFoot;
|
|
954
968
|
if (o && this._options.cloneFooter === !0) {
|
|
955
|
-
let e = new
|
|
969
|
+
let e = new P(o.cloneNode(!0), n.transaction, n.config);
|
|
956
970
|
n.appendChild(e);
|
|
957
971
|
}
|
|
958
972
|
};
|
|
@@ -967,19 +981,19 @@ var Ie = class {
|
|
|
967
981
|
let n = t.rows[0];
|
|
968
982
|
return n.cells.length === 0 ? !0 : n.cells.length > 1 ? !1 : n.cells[0].textContent?.trim().length === 0;
|
|
969
983
|
}
|
|
970
|
-
},
|
|
971
|
-
new Re(),
|
|
984
|
+
}, Ve = [
|
|
972
985
|
new ze(),
|
|
973
|
-
new
|
|
974
|
-
|
|
986
|
+
new Be(),
|
|
987
|
+
new Re()
|
|
988
|
+
], He = {
|
|
975
989
|
name: "debug",
|
|
976
990
|
order: 2 ** 53 - 1,
|
|
977
991
|
onNewPage: (e, t) => {
|
|
978
992
|
let n = t.getPageState().currentPage.getNode();
|
|
979
993
|
n.classList.contains("pz-page") || n.classList.add(g), n.setAttribute(`${y}-element`, "page"), n.setAttribute(`${y}-height`, t.getPageState().pageHeight.toString());
|
|
980
994
|
}
|
|
981
|
-
},
|
|
982
|
-
name =
|
|
995
|
+
}, Ue = "sectionToc", We = class {
|
|
996
|
+
name = Ue;
|
|
983
997
|
order = 1;
|
|
984
998
|
_state = /* @__PURE__ */ new Map();
|
|
985
999
|
getContentList = () => Array.from(this._state.values()).flat();
|
|
@@ -1003,11 +1017,11 @@ var Ie = class {
|
|
|
1003
1017
|
let t = e.tagName;
|
|
1004
1018
|
return /^H[1-6]$/.test(t) ? parseInt(t.charAt(1), 10) : null;
|
|
1005
1019
|
}
|
|
1006
|
-
},
|
|
1020
|
+
}, Ge = class e {
|
|
1007
1021
|
_promises;
|
|
1008
1022
|
monitor;
|
|
1009
1023
|
constructor() {
|
|
1010
|
-
this._promises = [], this.monitor = new
|
|
1024
|
+
this._promises = [], this.monitor = new q();
|
|
1011
1025
|
}
|
|
1012
1026
|
toPromise() {
|
|
1013
1027
|
return this._promises.length > 0 ? Promise.allSettled(this._promises.map((e) => e.promise)).then((e) => {
|
|
@@ -1045,28 +1059,14 @@ var Ie = class {
|
|
|
1045
1059
|
getPending() {
|
|
1046
1060
|
return Array.from(this._promises.values()).filter((e) => e.status === "pending");
|
|
1047
1061
|
}
|
|
1048
|
-
}
|
|
1049
|
-
//#endregion
|
|
1050
|
-
//#region src/utils.ts
|
|
1051
|
-
function We(e, t) {
|
|
1052
|
-
return `${e}-${t + 1}`;
|
|
1053
|
-
}
|
|
1054
|
-
function Ge(e, t) {
|
|
1055
|
-
return t === "landscape" ? {
|
|
1056
|
-
height: e.width,
|
|
1057
|
-
width: e.height
|
|
1058
|
-
} : e;
|
|
1059
|
-
}
|
|
1060
|
-
//#endregion
|
|
1061
|
-
//#region src/report/ReportBuilder.ts
|
|
1062
|
-
var $ = "\x1B[43mREPORT\x1B[0m", Ke = class {
|
|
1062
|
+
}, $ = "\x1B[43mREPORT\x1B[0m", Ke = class {
|
|
1063
1063
|
_sections;
|
|
1064
1064
|
_monitor;
|
|
1065
1065
|
_paginationInProgress;
|
|
1066
1066
|
_pendingPaginateResolvers;
|
|
1067
1067
|
_currentAbortController;
|
|
1068
1068
|
constructor() {
|
|
1069
|
-
this._sections = /* @__PURE__ */ new Map(), this._monitor = new
|
|
1069
|
+
this._sections = /* @__PURE__ */ new Map(), this._monitor = new q(), this._paginationInProgress = !1, this._pendingPaginateResolvers = [], this._currentAbortController = null, window[J] = !0, this._injectStyle(X.globalStyle);
|
|
1070
1070
|
}
|
|
1071
1071
|
get monitor() {
|
|
1072
1072
|
return this._monitor;
|
|
@@ -1084,7 +1084,7 @@ var $ = "\x1B[43mREPORT\x1B[0m", Ke = class {
|
|
|
1084
1084
|
pages: [],
|
|
1085
1085
|
options: {
|
|
1086
1086
|
...e,
|
|
1087
|
-
size:
|
|
1087
|
+
size: U(e.size, e.orientation ?? "portrait")
|
|
1088
1088
|
},
|
|
1089
1089
|
components: t
|
|
1090
1090
|
};
|
|
@@ -1097,7 +1097,7 @@ var $ = "\x1B[43mREPORT\x1B[0m", Ke = class {
|
|
|
1097
1097
|
return this._sections.size === 0 ? (window[Y] = !0, {
|
|
1098
1098
|
sections: [],
|
|
1099
1099
|
suspension: Promise.resolve()
|
|
1100
|
-
}) : (this._paginationInProgress && this._currentAbortController && (
|
|
1100
|
+
}) : (this._paginationInProgress && this._currentAbortController && (b.debug($, "Cancelling previous pagination operation."), this._currentAbortController.abort("Cancelled by new paginate call")), this._paginationInProgress ? new Promise((e, t) => {
|
|
1101
1101
|
this._pendingPaginateResolvers.push({
|
|
1102
1102
|
resolve: e,
|
|
1103
1103
|
reject: t
|
|
@@ -1107,12 +1107,12 @@ var $ = "\x1B[43mREPORT\x1B[0m", Ke = class {
|
|
|
1107
1107
|
async getJsonData(e) {
|
|
1108
1108
|
return await this._lazyJsonDataReader().catch(() => e) ?? e ?? null;
|
|
1109
1109
|
}
|
|
1110
|
-
_lazyJsonDataReader =
|
|
1110
|
+
_lazyJsonDataReader = De(Oe);
|
|
1111
1111
|
async _executePagination() {
|
|
1112
1112
|
this._paginationInProgress = !0, this._currentAbortController = new AbortController();
|
|
1113
1113
|
let e = this._currentAbortController.signal;
|
|
1114
1114
|
try {
|
|
1115
|
-
if (
|
|
1115
|
+
if (b.debug($, "Schedule paginate."), await document.fonts.ready, e.aborted) return new Promise((e, t) => {
|
|
1116
1116
|
this._pendingPaginateResolvers.push({
|
|
1117
1117
|
resolve: e,
|
|
1118
1118
|
reject: t
|
|
@@ -1121,16 +1121,16 @@ var $ = "\x1B[43mREPORT\x1B[0m", Ke = class {
|
|
|
1121
1121
|
let t = [];
|
|
1122
1122
|
for (let n of this._sections.values()) {
|
|
1123
1123
|
n.context.isPaginated = !1;
|
|
1124
|
-
let r = new
|
|
1124
|
+
let r = new Ge();
|
|
1125
1125
|
await r.add(n.context.options.suspense), r.monitor.addEventListener("onChange", (e) => {
|
|
1126
|
-
|
|
1126
|
+
b.debug($, `${e} pending promises in section '${n.context.sectionId}'.`);
|
|
1127
1127
|
}), r.then(async () => {
|
|
1128
|
-
e.aborted || (
|
|
1128
|
+
e.aborted || (b.debug($, `Start paginating section '${n.context.sectionId}'.`), n.context.isSuspended = !1, await this._paginateSection(n));
|
|
1129
1129
|
}), t.push(r);
|
|
1130
1130
|
}
|
|
1131
|
-
let n = new
|
|
1131
|
+
let n = new Ge();
|
|
1132
1132
|
return n.monitor.addEventListener("onChange", async () => {
|
|
1133
|
-
|
|
1133
|
+
b.debug($, "Report pagination completed."), await this._monitor.dispatch("paginationCycleCompleted", { sections: [...this._sections.values()].map((e) => e.context) });
|
|
1134
1134
|
}), e.aborted ? new Promise((e, t) => {
|
|
1135
1135
|
this._pendingPaginateResolvers.push({
|
|
1136
1136
|
resolve: e,
|
|
@@ -1148,7 +1148,7 @@ var $ = "\x1B[43mREPORT\x1B[0m", Ke = class {
|
|
|
1148
1148
|
}
|
|
1149
1149
|
async _processPendingPagination() {
|
|
1150
1150
|
if (this._pendingPaginateResolvers.length === 0) return;
|
|
1151
|
-
|
|
1151
|
+
b.debug($, `Processing ${this._pendingPaginateResolvers.length} pending paginate calls.`);
|
|
1152
1152
|
let e = [...this._pendingPaginateResolvers];
|
|
1153
1153
|
this._pendingPaginateResolvers = [];
|
|
1154
1154
|
let t = await this._executePagination();
|
|
@@ -1161,17 +1161,17 @@ var $ = "\x1B[43mREPORT\x1B[0m", Ke = class {
|
|
|
1161
1161
|
async _paginateSection(e) {
|
|
1162
1162
|
let t = document.createElement("div");
|
|
1163
1163
|
/* v8 ignore if -- @preserve */
|
|
1164
|
-
Object.assign(t.style, X.page(e.context.options.size, e.context.options.margin ??
|
|
1165
|
-
let n =
|
|
1164
|
+
Object.assign(t.style, X.page(e.context.options.size, e.context.options.margin ?? xe.None)), x() || Object.assign(t.style, X.outOfScreen);
|
|
1165
|
+
let n = Le(e.context.components);
|
|
1166
1166
|
n.sectionHeader && (Object.assign(n.sectionHeader.style, X.component), t.appendChild(n.sectionHeader)), n.pageHeader && (Object.assign(n.pageHeader.style, X.component), t.appendChild(n.pageHeader)), Object.assign(n.pageContent.style, X.pageContent), t.appendChild(n.pageContent), n.pageFooter && (Object.assign(n.pageFooter.style, X.component), t.appendChild(n.pageFooter)), n.sectionFooter && (Object.assign(n.sectionFooter.style, X.component), t.appendChild(n.sectionFooter)), document.body.appendChild(t);
|
|
1167
|
-
let { height: r, width: i, sectionHeaderHeight: a, sectionFooterHeight: o } =
|
|
1168
|
-
if (r === 0) throw
|
|
1169
|
-
let s =
|
|
1167
|
+
let { height: r, width: i, sectionHeaderHeight: a, sectionFooterHeight: o } = we(n.pageContent, n.sectionHeader, n.sectionFooter);
|
|
1168
|
+
if (r === 0) throw b.error(`Pagination failed for section '${e.context.sectionId}': insufficient space for page content or content is empty. Ensure that the section has content and that the header and footer do not occupy all available space.`), t.remove(), Error(`Pagination failed: no available space for content in section '${e.context.sectionId}'.`);
|
|
1169
|
+
let s = K.paginate(n.pageContent, {
|
|
1170
1170
|
height: r,
|
|
1171
1171
|
width: i
|
|
1172
1172
|
}, {
|
|
1173
1173
|
id: e.context.sectionId,
|
|
1174
|
-
plugins: [...e.context.options.plugins ??
|
|
1174
|
+
plugins: [...e.context.options.plugins ?? Ve, Te(r, a, o)]
|
|
1175
1175
|
});
|
|
1176
1176
|
t.remove();
|
|
1177
1177
|
let c = s.map((t, n) => ({
|
|
@@ -1203,6 +1203,6 @@ function Je(e, t) {
|
|
|
1203
1203
|
return n.length > 0 && (n[0] = n[0].charAt(0).toUpperCase() + n[0].slice(1)), n.join(" ") + ".";
|
|
1204
1204
|
}
|
|
1205
1205
|
//#endregion
|
|
1206
|
-
export {
|
|
1206
|
+
export { q as EventDispatcher, Re as OrderedListPlugin, ze as PageBreakPlugin, K as Paginator, Ke as ReportBuilder, We as SectionTocPlugin, B as SplitResult, Be as TablePlugin, U as adjustPageSize, y as attributePrefix, ye as buildPageId, Le as cloneComponents, Je as createLoremIpsumParagraph, d as currentElementClassName, f as currentTextClassName, He as debugPlugin, Ve as defaultPlugins, te as enableDebugMode, A as getNodeLayoutOptionsFromAttribute, C as getVisibleHeight, ke as globalStyle, h as globalStyleId, p as ignoredElementClassName, m as ignoredTextClassName, x as isDebugMode, S as isElement, ne as isTextNode, T as layoutOptionHyphenAttribute, D as layoutOptionHyphenationDisabledAttribute, E as layoutOptionKeepOnSamePageAttribute, ie as layoutOptionsToAttributes, b as logger, l as loggerName, re as moveOffscreen, Q as pageBreakAttributeName, g as pageClassName, xe as pageMargin, W as pageNodeToString, be as pageSize, J as paprize_isInitialized, Y as paprize_isReady, Se as paprize_readJsonDataFile, v as previewClassName, X as reportStyles, _ as sectionClassName, Ue as sectionTocName, u as tempContainerClassName };
|
|
1207
1207
|
|
|
1208
1208
|
//# sourceMappingURL=paprize-core.js.map
|