@prose-reader/core 1.54.0 → 1.56.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/dist/index.js +17 -6
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +17 -6
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -401,6 +401,12 @@ const layoutEnhancer = (next) => (options) => {
|
|
|
401
401
|
};
|
|
402
402
|
};
|
|
403
403
|
const ROOT_NAMESPACE = `@prose-reader/core`;
|
|
404
|
+
const getWindow = () => {
|
|
405
|
+
if (typeof window === "undefined") {
|
|
406
|
+
return void 0;
|
|
407
|
+
}
|
|
408
|
+
return window;
|
|
409
|
+
};
|
|
404
410
|
const wrap = (str) => `[${str}]`;
|
|
405
411
|
const time = (name, targetDuration = 0) => {
|
|
406
412
|
let tick = 0;
|
|
@@ -414,7 +420,8 @@ const time = (name, targetDuration = 0) => {
|
|
|
414
420
|
const createReport = (namespace) => ({
|
|
415
421
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
416
422
|
log: (...data) => {
|
|
417
|
-
|
|
423
|
+
var _a;
|
|
424
|
+
if ((_a = getWindow()) == null ? void 0 : _a.__PROSE_READER_DEBUG) {
|
|
418
425
|
if (namespace)
|
|
419
426
|
console.log(wrap(ROOT_NAMESPACE), wrap(namespace), ...data);
|
|
420
427
|
else
|
|
@@ -423,7 +430,8 @@ const createReport = (namespace) => ({
|
|
|
423
430
|
},
|
|
424
431
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
425
432
|
warn: (...data) => {
|
|
426
|
-
|
|
433
|
+
var _a;
|
|
434
|
+
if ((_a = getWindow()) == null ? void 0 : _a.__PROSE_READER_DEBUG) {
|
|
427
435
|
if (namespace)
|
|
428
436
|
console.warn(wrap(ROOT_NAMESPACE), wrap(namespace), ...data);
|
|
429
437
|
else
|
|
@@ -448,7 +456,8 @@ const createReport = (namespace) => ({
|
|
|
448
456
|
// },
|
|
449
457
|
time,
|
|
450
458
|
logMetric: (performanceEntry, targetDuration = 0) => {
|
|
451
|
-
|
|
459
|
+
var _a;
|
|
460
|
+
if ((_a = getWindow()) == null ? void 0 : _a.__PROSE_READER_DEBUG) {
|
|
452
461
|
if (performanceEntry.duration <= targetDuration)
|
|
453
462
|
;
|
|
454
463
|
else {
|
|
@@ -461,7 +470,8 @@ const createReport = (namespace) => ({
|
|
|
461
470
|
},
|
|
462
471
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
463
472
|
measurePerformance: (name, targetDuration = 10, functionToMeasure, { disable } = {}) => {
|
|
464
|
-
|
|
473
|
+
var _a;
|
|
474
|
+
if (disable || !((_a = getWindow()) == null ? void 0 : _a.__PROSE_READER_DEBUG))
|
|
465
475
|
return functionToMeasure;
|
|
466
476
|
return (...args) => {
|
|
467
477
|
const t0 = performance.now();
|
|
@@ -2826,6 +2836,7 @@ const createEventsHelper = ({
|
|
|
2826
2836
|
const { clientX, clientY } = spineItem.translateFramePositionIntoPage(event);
|
|
2827
2837
|
const newEvent = new PointerEvent(event.type, {
|
|
2828
2838
|
...event,
|
|
2839
|
+
pointerId: event.pointerId,
|
|
2829
2840
|
clientX,
|
|
2830
2841
|
clientY
|
|
2831
2842
|
});
|
|
@@ -6385,9 +6396,9 @@ const progressionEnhancer = (next) => (options) => {
|
|
|
6385
6396
|
totalProgress = getTotalProgressFromPercentages(estimateBeforeThisItem, currentItemWeight, progressWithinThisItem);
|
|
6386
6397
|
}
|
|
6387
6398
|
if (currentSpineIndex === readingOrderLength - 1 && pageIndex === numberOfPages - 1 && totalProgress > 0.99) {
|
|
6388
|
-
return
|
|
6399
|
+
return 1;
|
|
6389
6400
|
}
|
|
6390
|
-
return totalProgress
|
|
6401
|
+
return totalProgress;
|
|
6391
6402
|
};
|
|
6392
6403
|
const getTotalProgressFromPercentages = (estimateBeforeThisItem, currentItemWeight, progressWithinThisItem) => {
|
|
6393
6404
|
return estimateBeforeThisItem + currentItemWeight * progressWithinThisItem;
|