@xiboplayer/renderer 0.6.9 → 0.6.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiboplayer/renderer",
3
- "version": "0.6.9",
3
+ "version": "0.6.10",
4
4
  "description": "RendererLite - Fast, efficient XLF layout rendering engine",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -13,9 +13,9 @@
13
13
  "dependencies": {
14
14
  "nanoevents": "^9.1.0",
15
15
  "pdfjs-dist": "^4.10.38",
16
- "@xiboplayer/cache": "0.6.9",
17
- "@xiboplayer/utils": "0.6.9",
18
- "@xiboplayer/schedule": "0.6.9"
16
+ "@xiboplayer/cache": "0.6.10",
17
+ "@xiboplayer/schedule": "0.6.10",
18
+ "@xiboplayer/utils": "0.6.10"
19
19
  },
20
20
  "devDependencies": {
21
21
  "vitest": "^2.0.0",
@@ -2622,18 +2622,27 @@ export class RendererLite {
2622
2622
  await cyclePage();
2623
2623
 
2624
2624
  // Pause: stop page cycling (called by _hideWidget during region cycling / replay)
2625
+ // Returns a promise that resolves when the active render is fully cancelled.
2626
+ let cancelPromise = null;
2625
2627
  container._pdfCleanup = () => {
2626
2628
  stopped = true;
2627
2629
  if (cycleTimer) clearTimeout(cycleTimer);
2628
2630
  cycleTimer = null;
2629
2631
  if (activeRenderTask) {
2630
- activeRenderTask.cancel();
2632
+ const task = activeRenderTask;
2631
2633
  activeRenderTask = null;
2634
+ task.cancel();
2635
+ cancelPromise = task.promise.catch(() => {}); // wait for cancellation to propagate
2632
2636
  }
2633
2637
  };
2634
2638
 
2635
2639
  // Resume: restart page cycling from page 1 (called by _showWidget on reuse)
2636
- container._pdfResume = () => {
2640
+ // Always cleanup first — the PDF may still be rendering from preload
2641
+ // (pre-create starts cyclePage immediately, but the widget isn't "shown"
2642
+ // until the layout swap, so _pdfCleanup was never called).
2643
+ container._pdfResume = async () => {
2644
+ container._pdfCleanup(); // stop any in-flight render
2645
+ if (cancelPromise) { await cancelPromise; cancelPromise = null; }
2637
2646
  stopped = false;
2638
2647
  currentPage = 1;
2639
2648
  cyclePage();