@react-pdf-kit/viewer 2.9.1-rc.0 → 2.9.1-rc.1

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.
@@ -1,52 +1,60 @@
1
- import { r as e } from "../PaginationContext-DIzsZhFd.js";
2
- import { Queue as t } from "../utils/Queue.js";
3
- import { renderPage as n } from "../utils/renderPage.js";
4
- import { createContext as r, useCallback as i, useContext as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
5
- import { jsx as u } from "react/jsx-runtime";
1
+ import { useDocumentContext as e } from "./RPDocumentContext.js";
2
+ import { r as t } from "../PaginationContext-DIzsZhFd.js";
3
+ import { Queue as n } from "../utils/Queue.js";
4
+ import { renderPage as r } from "../utils/renderPage.js";
5
+ import { createContext as i, useCallback as a, useContext as o, useEffect as s, useMemo as c, useRef as l, useState as u } from "react";
6
+ import { jsx as d } from "react/jsx-runtime";
6
7
  //#region lib/contexts/RenderQueueProvider.tsx
7
- var d = r(null), f = ({ children: r }) => {
8
- let a = c(!1), f = c(/* @__PURE__ */ new Map()), [p, m] = l([]), h = i((e) => {
9
- m((t) => [...t, {
8
+ var f = i(null), p = ({ children: i }) => {
9
+ let o = l(!1), p = l(/* @__PURE__ */ new Map()), [m, h] = u([]), g = a((e) => {
10
+ h((t) => [...t, {
10
11
  id: e.page.pageNumber.toString(),
11
12
  data: e,
12
13
  priority: 0
13
14
  }]);
14
- }, []), g = s(() => new t(h), [h]), { focusedPage: _ } = e(), v = i((e) => {
15
- a.current = !0;
16
- let t = f.current.get(e.id);
17
- t && (t.cancel(), f.current.delete(e.id));
18
- let r = n(e.data.page, e.data.canvasElem, e.data.options);
19
- return f.current.set(e.id, r), e.data.onRenderTask?.(r), r.promise.then(() => {
15
+ }, []), _ = c(() => new n(g), [g]), { focusedPage: v } = t(), { pdf: y } = e(), b = a((e) => {
16
+ o.current = !0;
17
+ let t = p.current.get(e.id);
18
+ t && (t.cancel(), p.current.delete(e.id));
19
+ let n;
20
+ try {
21
+ n = r(e.data.page, e.data.canvasElem, e.data.options);
22
+ } catch {
23
+ return e.data.onRenderTask?.(null), Promise.resolve();
24
+ }
25
+ return p.current.set(e.id, n), e.data.onRenderTask?.(n), n.promise.then(() => {
20
26
  e.data.canvasElem.hidden = !1, e.data.onLoaded && e.data.onLoaded();
21
27
  }).catch((t) => {
22
28
  t.name !== "RenderingCancelledException" && console.error(`Error rendering page ${e.data.page.pageNumber}:`, t);
23
29
  }).finally(() => {
24
- f.current.delete(e.id), e.data.onRenderTask?.(null);
30
+ p.current.delete(e.id), e.data.onRenderTask?.(null);
25
31
  });
26
32
  }, []);
27
- return o(() => {
28
- _ && (g.changePagePriority(`^page-${_}`, 0), g.changePagePriority(`^thumbnail-${_}`, 1));
29
- }, [_]), o(() => {
30
- if (g.isEmpty() || a.current) return;
33
+ return s(() => {
34
+ p.current.forEach((e) => e.cancel()), p.current.clear(), _.clear(), h(_.peekAll());
35
+ }, [y, _]), s(() => {
36
+ v && (_.changePagePriority(`^page-${v}`, 0), _.changePagePriority(`^thumbnail-${v}`, 1));
37
+ }, [v]), s(() => {
38
+ if (_.isEmpty() || o.current) return;
31
39
  let e = () => {
32
- let t = g.dequeue();
33
- t ? v(t).catch(() => {}).finally(() => {
40
+ let t = _.dequeue();
41
+ t ? b(t).catch(() => {}).finally(() => {
34
42
  e();
35
- }) : (a.current = !1, m(g.peekAll()));
43
+ }) : (o.current = !1, h(_.peekAll()));
36
44
  };
37
45
  e();
38
46
  }, [
39
- g,
40
- v,
41
- p
42
- ]), /* @__PURE__ */ u(d.Provider, {
43
- value: g,
44
- children: r
47
+ _,
48
+ b,
49
+ m
50
+ ]), /* @__PURE__ */ d(f.Provider, {
51
+ value: _,
52
+ children: i
45
53
  });
46
- }, p = () => {
47
- let e = a(d);
54
+ }, m = () => {
55
+ let e = o(f);
48
56
  if (!e) throw Error("RenderQueue not found");
49
57
  return e;
50
58
  };
51
59
  //#endregion
52
- export { d as RenderQueueContext, f as RenderQueueProvider, p as useRenderQueue };
60
+ export { f as RenderQueueContext, p as RenderQueueProvider, m as useRenderQueue };
@@ -3,7 +3,7 @@ import { LicenseType as t } from "../types.js";
3
3
  import { appConsole as n } from "../appConsole.js";
4
4
  import { useCallback as r, useEffect as i, useState as a } from "react";
5
5
  //#region lib/utils/hooks/useLicense.ts
6
- var o = /* @__PURE__ */ new Date("2026-08-21T06:39:48.138Z"), s = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvIokvErJ0Fctu0jduSAx\ngr+5Har/VSuZLlOunS28hnlqqA+OF1apHL7RYkjBosS15yvviYdLrVWYHpHnoY4b\nHLQ9I6YX6FMB9T/VbB4xLdVdKvfi8r49aTScl5EKuSpgpPgz2VSJTfvVGcRuth/Y\nBm7PPGYdL2l2gvKDxchmmsHFPukGki9L4JOUeIVX0GXAxabENckaEH/iC1NZhX+W\nvXnpHeHuIIKlZ16LSivXNgo6BH2Z3GFdg4G3cAaXr6qNP8fsacYNqv2SpTW1viFD\nvzcGRabN25gpJAp9/syeScefWH3OiJY1lmw88oTiJbjIoiq6AkPhfn3G9mF54nvR\nkwIDAQAB\n-----END PUBLIC KEY-----", c = "Please visit https://app.react-pdf-kit.dev to generate a new license key.", l = {
6
+ var o = /* @__PURE__ */ new Date("2026-08-25T06:02:29.432Z"), s = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvIokvErJ0Fctu0jduSAx\ngr+5Har/VSuZLlOunS28hnlqqA+OF1apHL7RYkjBosS15yvviYdLrVWYHpHnoY4b\nHLQ9I6YX6FMB9T/VbB4xLdVdKvfi8r49aTScl5EKuSpgpPgz2VSJTfvVGcRuth/Y\nBm7PPGYdL2l2gvKDxchmmsHFPukGki9L4JOUeIVX0GXAxabENckaEH/iC1NZhX+W\nvXnpHeHuIIKlZ16LSivXNgo6BH2Z3GFdg4G3cAaXr6qNP8fsacYNqv2SpTW1viFD\nvzcGRabN25gpJAp9/syeScefWH3OiJY1lmw88oTiJbjIoiq6AkPhfn3G9mF54nvR\nkwIDAQAB\n-----END PUBLIC KEY-----", c = "Please visit https://app.react-pdf-kit.dev to generate a new license key.", l = {
7
7
  invalidLicense: `You are currently using without a valid license. ${c}`,
8
8
  mismatchedDomain: `Your license key is not valid for the current domain / IP. ${c}`,
9
9
  expired: `Your license key has expired. ${c}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pdf-kit/viewer",
3
- "version": "2.9.1-rc.0",
3
+ "version": "2.9.1-rc.1",
4
4
  "private": false,
5
5
  "description": "A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.",
6
6
  "keywords": [