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