next-flipbook 0.8.9 → 0.10.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.
Files changed (143) hide show
  1. package/LICENSE +97 -21
  2. package/README.md +25 -3
  3. package/dist/core/appearance/AppearanceStore.d.ts +71 -0
  4. package/dist/core/appearance/AppearanceStore.d.ts.map +1 -0
  5. package/dist/core/appearance/AppearanceStore.js +130 -0
  6. package/dist/core/appearance/AppearanceStore.js.map +1 -0
  7. package/dist/core/index.d.ts +3 -1
  8. package/dist/core/index.d.ts.map +1 -1
  9. package/dist/core/index.js +1 -0
  10. package/dist/core/index.js.map +1 -1
  11. package/dist/core/types.d.ts +22 -1
  12. package/dist/core/types.d.ts.map +1 -1
  13. package/dist/index.d.ts +3 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/license/check.d.ts +19 -0
  18. package/dist/license/check.d.ts.map +1 -0
  19. package/dist/license/check.js +42 -0
  20. package/dist/license/check.js.map +1 -0
  21. package/dist/license/format.d.ts +47 -0
  22. package/dist/license/format.d.ts.map +1 -0
  23. package/dist/license/format.js +114 -0
  24. package/dist/license/format.js.map +1 -0
  25. package/dist/license/index.d.ts +10 -0
  26. package/dist/license/index.d.ts.map +1 -0
  27. package/dist/license/index.js +7 -0
  28. package/dist/license/index.js.map +1 -0
  29. package/dist/license/publicKey.d.ts +10 -0
  30. package/dist/license/publicKey.d.ts.map +1 -0
  31. package/dist/license/publicKey.js +14 -0
  32. package/dist/license/publicKey.js.map +1 -0
  33. package/dist/license/revoked.d.ts +8 -0
  34. package/dist/license/revoked.d.ts.map +1 -0
  35. package/dist/license/revoked.js +8 -0
  36. package/dist/license/revoked.js.map +1 -0
  37. package/dist/license/types.d.ts +76 -0
  38. package/dist/license/types.d.ts.map +1 -0
  39. package/dist/license/types.js +2 -0
  40. package/dist/license/types.js.map +1 -0
  41. package/dist/license/verify.d.ts +25 -0
  42. package/dist/license/verify.d.ts.map +1 -0
  43. package/dist/license/verify.js +48 -0
  44. package/dist/license/verify.js.map +1 -0
  45. package/dist/license/warn.d.ts +14 -0
  46. package/dist/license/warn.d.ts.map +1 -0
  47. package/dist/license/warn.js +47 -0
  48. package/dist/license/warn.js.map +1 -0
  49. package/dist/pdf/readPageText.d.ts +14 -0
  50. package/dist/pdf/readPageText.d.ts.map +1 -0
  51. package/dist/pdf/readPageText.js +37 -0
  52. package/dist/pdf/readPageText.js.map +1 -0
  53. package/dist/pdf/session.d.ts.map +1 -1
  54. package/dist/pdf/session.js +2 -1
  55. package/dist/pdf/session.js.map +1 -1
  56. package/dist/pdf/types.d.ts +2 -0
  57. package/dist/pdf/types.d.ts.map +1 -1
  58. package/dist/react/backgroundChoices.d.ts +18 -0
  59. package/dist/react/backgroundChoices.d.ts.map +1 -0
  60. package/dist/react/backgroundChoices.js +44 -0
  61. package/dist/react/backgroundChoices.js.map +1 -0
  62. package/dist/react/components/FlipBook.d.ts.map +1 -1
  63. package/dist/react/components/FlipBook.js +5 -4
  64. package/dist/react/components/FlipBook.js.map +1 -1
  65. package/dist/react/components/FlipBookBackgroundControl.d.ts +11 -0
  66. package/dist/react/components/FlipBookBackgroundControl.d.ts.map +1 -0
  67. package/dist/react/components/FlipBookBackgroundControl.js +157 -0
  68. package/dist/react/components/FlipBookBackgroundControl.js.map +1 -0
  69. package/dist/react/components/FlipBookLicenseMark.d.ts +11 -0
  70. package/dist/react/components/FlipBookLicenseMark.d.ts.map +1 -0
  71. package/dist/react/components/FlipBookLicenseMark.js +46 -0
  72. package/dist/react/components/FlipBookLicenseMark.js.map +1 -0
  73. package/dist/react/components/FlipBookLicenseProvider.d.ts +18 -0
  74. package/dist/react/components/FlipBookLicenseProvider.d.ts.map +1 -0
  75. package/dist/react/components/FlipBookLicenseProvider.js +17 -0
  76. package/dist/react/components/FlipBookLicenseProvider.js.map +1 -0
  77. package/dist/react/components/FlipBookProvider.d.ts.map +1 -1
  78. package/dist/react/components/FlipBookProvider.js +19 -2
  79. package/dist/react/components/FlipBookProvider.js.map +1 -1
  80. package/dist/react/components/FlipBookSidePanel.d.ts.map +1 -1
  81. package/dist/react/components/FlipBookSidePanel.js +2 -1
  82. package/dist/react/components/FlipBookSidePanel.js.map +1 -1
  83. package/dist/react/components/FlipBookStage.d.ts.map +1 -1
  84. package/dist/react/components/FlipBookStage.js +4 -3
  85. package/dist/react/components/FlipBookStage.js.map +1 -1
  86. package/dist/react/components/FlipBookThumbnailSizeControl.d.ts +12 -0
  87. package/dist/react/components/FlipBookThumbnailSizeControl.d.ts.map +1 -0
  88. package/dist/react/components/FlipBookThumbnailSizeControl.js +20 -0
  89. package/dist/react/components/FlipBookThumbnailSizeControl.js.map +1 -0
  90. package/dist/react/components/FlipBookThumbnails.d.ts +4 -1
  91. package/dist/react/components/FlipBookThumbnails.d.ts.map +1 -1
  92. package/dist/react/components/FlipBookThumbnails.js +20 -4
  93. package/dist/react/components/FlipBookThumbnails.js.map +1 -1
  94. package/dist/react/components/FlipBookToolbar.d.ts.map +1 -1
  95. package/dist/react/components/FlipBookToolbar.js +3 -1
  96. package/dist/react/components/FlipBookToolbar.js.map +1 -1
  97. package/dist/react/components/FlipBookToolbarButton.d.ts +2 -0
  98. package/dist/react/components/FlipBookToolbarButton.d.ts.map +1 -1
  99. package/dist/react/components/FlipBookToolbarButton.js +2 -2
  100. package/dist/react/components/FlipBookToolbarButton.js.map +1 -1
  101. package/dist/react/components/Thumbnail.js +7 -1
  102. package/dist/react/components/Thumbnail.js.map +1 -1
  103. package/dist/react/context.d.ts +9 -0
  104. package/dist/react/context.d.ts.map +1 -1
  105. package/dist/react/context.js.map +1 -1
  106. package/dist/react/controller.d.ts +2 -0
  107. package/dist/react/controller.d.ts.map +1 -1
  108. package/dist/react/controller.js +6 -1
  109. package/dist/react/controller.js.map +1 -1
  110. package/dist/react/hooks/useAppearance.d.ts +14 -0
  111. package/dist/react/hooks/useAppearance.d.ts.map +1 -0
  112. package/dist/react/hooks/useAppearance.js +27 -0
  113. package/dist/react/hooks/useAppearance.js.map +1 -0
  114. package/dist/react/hooks/useBookExtras.d.ts +2 -0
  115. package/dist/react/hooks/useBookExtras.d.ts.map +1 -1
  116. package/dist/react/hooks/useBookExtras.js +16 -1
  117. package/dist/react/hooks/useBookExtras.js.map +1 -1
  118. package/dist/react/hooks/useFlipBook.d.ts +4 -0
  119. package/dist/react/hooks/useFlipBook.d.ts.map +1 -1
  120. package/dist/react/hooks/useFlipBook.js +5 -2
  121. package/dist/react/hooks/useFlipBook.js.map +1 -1
  122. package/dist/react/hooks/useLicense.d.ts +9 -0
  123. package/dist/react/hooks/useLicense.d.ts.map +1 -0
  124. package/dist/react/hooks/useLicense.js +32 -0
  125. package/dist/react/hooks/useLicense.js.map +1 -0
  126. package/dist/react/icons.d.ts +1 -1
  127. package/dist/react/icons.d.ts.map +1 -1
  128. package/dist/react/icons.js +1 -0
  129. package/dist/react/icons.js.map +1 -1
  130. package/dist/react/index.d.ts +7 -0
  131. package/dist/react/index.d.ts.map +1 -1
  132. package/dist/react/index.js +4 -0
  133. package/dist/react/index.js.map +1 -1
  134. package/dist/react/licenseContext.d.ts +3 -0
  135. package/dist/react/licenseContext.d.ts.map +1 -0
  136. package/dist/react/licenseContext.js +5 -0
  137. package/dist/react/licenseContext.js.map +1 -0
  138. package/dist/react/locale.d.ts.map +1 -1
  139. package/dist/react/locale.js +10 -0
  140. package/dist/react/locale.js.map +1 -1
  141. package/dist/types/index.d.ts +64 -3
  142. package/dist/types/index.d.ts.map +1 -1
  143. package/package.json +3 -3
@@ -0,0 +1,47 @@
1
+ import type { LicensePayload } from "./types.js";
2
+ /**
3
+ * A license key is three parts joined by dots:
4
+ *
5
+ * FB1.<payload>.<signature>
6
+ *
7
+ * The payload is JSON (see `LicensePayload`) and the signature covers the text `FB1.<payload>`
8
+ * exactly as written, so there is nothing to canonicalize. Both parts are base64url. The
9
+ * signature is ECDSA with P-256 and SHA-256, in the 64-byte `r || s` form that `crypto.subtle`
10
+ * uses. That algorithm is the one every browser's `crypto.subtle` has had for years; Ed25519 is
11
+ * not available in the older ones.
12
+ *
13
+ * This file is plain functions with no browser or Node APIs beyond `atob` and `TextDecoder`, so
14
+ * the same code runs in the browser, on the server and in tests.
15
+ */
16
+ export declare const LICENSE_KEY_PREFIX = "FB1";
17
+ export interface ParsedLicenseKey {
18
+ payload: LicensePayload;
19
+ /** The text the signature covers. */
20
+ signedText: string;
21
+ /** The 64 signature bytes. */
22
+ signature: Uint8Array<ArrayBuffer>;
23
+ }
24
+ /** Bytes from base64url text, or null if it is not that. */
25
+ export declare function fromBase64Url(text: string): Uint8Array<ArrayBuffer> | null;
26
+ /**
27
+ * Splits a key into its payload and signature. Spaces and line breaks are ignored, because keys
28
+ * get pasted from emails and wrapped. Returns null for anything that is not shaped like a key.
29
+ * Nothing in the result can be trusted until the signature has been checked.
30
+ */
31
+ export declare function parseLicenseKey(input: string): ParsedLicenseKey | null;
32
+ /** A host name or domain in the form that is compared: lower case, with no brackets or trailing dot. */
33
+ export declare function normalizeHost(value: string): string;
34
+ /**
35
+ * Whether `host` is `domain` or one of its subdomains. A key for `example.com` covers
36
+ * `www.example.com` and `app.example.com`, and not `notexample.com`. A domain with a single label
37
+ * (`com`, `intranet`) matches only itself, so a key can never cover a whole top-level domain.
38
+ */
39
+ export declare function hostMatchesDomain(host: string, domain: string): boolean;
40
+ /**
41
+ * Whether the viewer runs on a developer's own machine or network: there is no website to check a
42
+ * key against, and a warning on every `npm run dev` would only train people to ignore it. This
43
+ * covers `localhost`, loopback and private-network addresses, `*.local`, `*.test`, `*.internal`,
44
+ * and pages that are not on a host at all (`file:`).
45
+ */
46
+ export declare function isDevelopmentHost(host: string): boolean;
47
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/license/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,cAAc,CAAC;IACxB,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,SAAS,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;CACpC;AAED,4DAA4D;AAC5D,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAY1E;AAmBD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAkBtE;AAED,wGAAwG;AACxG,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAMvE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAevD"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * A license key is three parts joined by dots:
3
+ *
4
+ * FB1.<payload>.<signature>
5
+ *
6
+ * The payload is JSON (see `LicensePayload`) and the signature covers the text `FB1.<payload>`
7
+ * exactly as written, so there is nothing to canonicalize. Both parts are base64url. The
8
+ * signature is ECDSA with P-256 and SHA-256, in the 64-byte `r || s` form that `crypto.subtle`
9
+ * uses. That algorithm is the one every browser's `crypto.subtle` has had for years; Ed25519 is
10
+ * not available in the older ones.
11
+ *
12
+ * This file is plain functions with no browser or Node APIs beyond `atob` and `TextDecoder`, so
13
+ * the same code runs in the browser, on the server and in tests.
14
+ */
15
+ export const LICENSE_KEY_PREFIX = "FB1";
16
+ /** Bytes from base64url text, or null if it is not that. */
17
+ export function fromBase64Url(text) {
18
+ if (!/^[A-Za-z0-9_-]*$/.test(text))
19
+ return null;
20
+ const padded = text.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat((4 - (text.length % 4)) % 4);
21
+ let binary;
22
+ try {
23
+ binary = atob(padded);
24
+ }
25
+ catch {
26
+ return null;
27
+ }
28
+ const bytes = new Uint8Array(new ArrayBuffer(binary.length));
29
+ for (let index = 0; index < binary.length; index += 1)
30
+ bytes[index] = binary.charCodeAt(index);
31
+ return bytes;
32
+ }
33
+ function isPayload(value) {
34
+ if (typeof value !== "object" || value === null)
35
+ return false;
36
+ const payload = value;
37
+ const whole = (n) => typeof n === "number" && Number.isSafeInteger(n) && n >= 0;
38
+ return (payload.v === 1 &&
39
+ typeof payload.id === "string" &&
40
+ payload.id.length > 0 &&
41
+ payload.id.length <= 32 &&
42
+ typeof payload.d === "string" &&
43
+ payload.d.length > 0 &&
44
+ payload.d.length <= 253 &&
45
+ whole(payload.iat) &&
46
+ (payload.exp === undefined || whole(payload.exp)));
47
+ }
48
+ /**
49
+ * Splits a key into its payload and signature. Spaces and line breaks are ignored, because keys
50
+ * get pasted from emails and wrapped. Returns null for anything that is not shaped like a key.
51
+ * Nothing in the result can be trusted until the signature has been checked.
52
+ */
53
+ export function parseLicenseKey(input) {
54
+ const text = input.replace(/\s+/g, "");
55
+ const parts = text.split(".");
56
+ if (parts.length !== 3 || parts[0] !== LICENSE_KEY_PREFIX)
57
+ return null;
58
+ const [prefix, encodedPayload, encodedSignature] = parts;
59
+ const payloadBytes = fromBase64Url(encodedPayload);
60
+ const signature = fromBase64Url(encodedSignature);
61
+ if (!payloadBytes || !signature || signature.length !== 64)
62
+ return null;
63
+ let payload;
64
+ try {
65
+ payload = JSON.parse(new TextDecoder().decode(payloadBytes));
66
+ }
67
+ catch {
68
+ return null;
69
+ }
70
+ if (!isPayload(payload))
71
+ return null;
72
+ return { payload, signedText: `${prefix}.${encodedPayload}`, signature };
73
+ }
74
+ /** A host name or domain in the form that is compared: lower case, with no brackets or trailing dot. */
75
+ export function normalizeHost(value) {
76
+ return value.trim().toLowerCase().replace(/^\[|\]$/g, "").replace(/\.+$/, "");
77
+ }
78
+ /**
79
+ * Whether `host` is `domain` or one of its subdomains. A key for `example.com` covers
80
+ * `www.example.com` and `app.example.com`, and not `notexample.com`. A domain with a single label
81
+ * (`com`, `intranet`) matches only itself, so a key can never cover a whole top-level domain.
82
+ */
83
+ export function hostMatchesDomain(host, domain) {
84
+ const h = normalizeHost(host);
85
+ const d = normalizeHost(domain);
86
+ if (h === "" || d === "")
87
+ return false;
88
+ if (h === d)
89
+ return true;
90
+ return d.includes(".") && h.endsWith(`.${d}`);
91
+ }
92
+ /**
93
+ * Whether the viewer runs on a developer's own machine or network: there is no website to check a
94
+ * key against, and a warning on every `npm run dev` would only train people to ignore it. This
95
+ * covers `localhost`, loopback and private-network addresses, `*.local`, `*.test`, `*.internal`,
96
+ * and pages that are not on a host at all (`file:`).
97
+ */
98
+ export function isDevelopmentHost(host) {
99
+ const h = normalizeHost(host);
100
+ if (h === "")
101
+ return true;
102
+ if (h === "localhost" || /\.(localhost|local|test|internal)$/.test(h))
103
+ return true;
104
+ const v4 = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(h);
105
+ if (v4) {
106
+ const a = Number(v4[1]);
107
+ const b = Number(v4[2]);
108
+ return (a === 0 || a === 10 || a === 127 || (a === 169 && b === 254) || (a === 172 && b >= 16 && b <= 31) || (a === 192 && b === 168));
109
+ }
110
+ if (h.includes(":"))
111
+ return h === "::" || h === "::1" || /^f[cd][0-9a-f]{2}:/.test(h) || /^fe[89ab][0-9a-f]:/.test(h);
112
+ return false;
113
+ }
114
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/license/format.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAUxC,4DAA4D;AAC5D,MAAM,UAAU,aAAa,CAAC,I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OAAO,CACL,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAC9H,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtH,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,10 @@
1
+ export { checkLicense, currentHostname, resetLicenseChecks } from "./check.js";
2
+ export { LICENSE_KEY_PREFIX, hostMatchesDomain, isDevelopmentHost, normalizeHost, parseLicenseKey, } from "./format.js";
3
+ export type { ParsedLicenseKey } from "./format.js";
4
+ export { LICENSE_PUBLIC_KEY } from "./publicKey.js";
5
+ export { REVOKED_LICENSE_IDS } from "./revoked.js";
6
+ export type { LicensePayload, LicenseProblem, LicensePublicKey, LicenseStatus } from "./types.js";
7
+ export { verifyLicense } from "./verify.js";
8
+ export type { VerifyLicenseOptions } from "./verify.js";
9
+ export { LICENSE_INFO_URL, describeLicense, resetLicenseWarnings, warnAboutLicense } from "./warn.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/license/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAClG,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { checkLicense, currentHostname, resetLicenseChecks } from "./check.js";
2
+ export { LICENSE_KEY_PREFIX, hostMatchesDomain, isDevelopmentHost, normalizeHost, parseLicenseKey, } from "./format.js";
3
+ export { LICENSE_PUBLIC_KEY } from "./publicKey.js";
4
+ export { REVOKED_LICENSE_IDS } from "./revoked.js";
5
+ export { verifyLicense } from "./verify.js";
6
+ export { LICENSE_INFO_URL, describeLicense, resetLicenseWarnings, warnAboutLicense } from "./warn.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/license/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { LicensePublicKey } from "./types.js";
2
+ /**
3
+ * The half of the signing key that checks license keys. It is not a secret: it goes out in every
4
+ * copy of the package, and it can only check keys, never make them.
5
+ *
6
+ * Written by `npm run license -- init`. A build with no key here (`null`) accepts no license key at
7
+ * all, and `npm run verify:release` refuses to publish it.
8
+ */
9
+ export declare const LICENSE_PUBLIC_KEY: LicensePublicKey | null;
10
+ //# sourceMappingURL=publicKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publicKey.d.ts","sourceRoot":"","sources":["../../src/license/publicKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,GAAG,IAKnD,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The half of the signing key that checks license keys. It is not a secret: it goes out in every
3
+ * copy of the package, and it can only check keys, never make them.
4
+ *
5
+ * Written by `npm run license -- init`. A build with no key here (`null`) accepts no license key at
6
+ * all, and `npm run verify:release` refuses to publish it.
7
+ */
8
+ export const LICENSE_PUBLIC_KEY = {
9
+ kty: "EC",
10
+ crv: "P-256",
11
+ x: "Jq6blXQje0K12yUu6S6fOWFJSDvju2JIjAYmbzTIB2E",
12
+ y: "M5acONLudl9xHsvDa2J5XYVTfgWYTlZnRwgD6dRb7Wk",
13
+ };
14
+ //# sourceMappingURL=publicKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publicKey.js","sourceRoot":"","sources":["../../src/license/publicKey.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA4B;IACzD,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,OAAO;IACZ,CAAC,EAAE,6CAA6C;IAChD,CAAC,EAAE,6CAA6C;CACjD,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Serial numbers of license keys that have been withdrawn. A key cannot be recalled once it is
3
+ * sent, so a withdrawal reaches a website with the next release of the package that it installs.
4
+ *
5
+ * This file is written by `npm run license -- revoke <id>`.
6
+ */
7
+ export declare const REVOKED_LICENSE_IDS: readonly string[];
8
+ //# sourceMappingURL=revoked.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revoked.d.ts","sourceRoot":"","sources":["../../src/license/revoked.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAAO,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Serial numbers of license keys that have been withdrawn. A key cannot be recalled once it is
3
+ * sent, so a withdrawal reaches a website with the next release of the package that it installs.
4
+ *
5
+ * This file is written by `npm run license -- revoke <id>`.
6
+ */
7
+ export const REVOKED_LICENSE_IDS = [];
8
+ //# sourceMappingURL=revoked.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revoked.js","sourceRoot":"","sources":["../../src/license/revoked.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAsB,EAAE,CAAC"}
@@ -0,0 +1,76 @@
1
+ /** Why a license key does not unlock the viewer. */
2
+ export type LicenseProblem =
3
+ /** No key was given. */
4
+ "missing"
5
+ /** The text is not a license key: cut off, mistyped, or not ours. */
6
+ | "malformed"
7
+ /** The key was not signed by the author of next-flipbook. */
8
+ | "signature"
9
+ /** The key is genuine, but for another website. */
10
+ | "domain"
11
+ /** The key is genuine and for this website, but its end date has passed. */
12
+ | "expired"
13
+ /** The key was withdrawn by the author. */
14
+ | "revoked"
15
+ /** This build of the package has no public key to check keys against. */
16
+ | "no-public-key";
17
+ /**
18
+ * What the license check found, for the website the viewer is running on.
19
+ *
20
+ * Only `unlicensed` changes what the reader sees: the viewer shows a watermark. It never stops
21
+ * working, whatever the state.
22
+ */
23
+ export type LicenseStatus =
24
+ /** Not checked yet: on the server, and in the first moment in the browser. */
25
+ {
26
+ state: "pending";
27
+ }
28
+ /** A local or private-network address (`localhost`, `192.168.x.x`, `*.local`, ...). Nothing to check. */
29
+ | {
30
+ state: "development";
31
+ host: string;
32
+ }
33
+ /** A genuine key for this website. */
34
+ | {
35
+ state: "licensed";
36
+ id: string;
37
+ domain: string;
38
+ expiresAt: number | null;
39
+ }
40
+ /** The key could not be checked here, because the browser has no `crypto.subtle` (plain HTTP). */
41
+ | {
42
+ state: "unverified";
43
+ host: string;
44
+ reason: "no-webcrypto";
45
+ }
46
+ /** No key, or one that does not unlock this website. */
47
+ | {
48
+ state: "unlicensed";
49
+ host: string;
50
+ reason: LicenseProblem;
51
+ /** For `domain`: the website the key was issued for. */
52
+ licensedFor?: string;
53
+ /** For `expired`: when it ended, in milliseconds since 1970. */
54
+ expiredAt?: number;
55
+ };
56
+ /** The signing key's public half, as the JSON Web Key that `crypto.subtle` imports. */
57
+ export interface LicensePublicKey {
58
+ kty: "EC";
59
+ crv: "P-256";
60
+ x: string;
61
+ y: string;
62
+ }
63
+ /** What a key says, once its signature has been checked. */
64
+ export interface LicensePayload {
65
+ /** The format version. */
66
+ v: 1;
67
+ /** The serial number, such as `fb-0003`. Revoking a key names it. */
68
+ id: string;
69
+ /** The website the key is for, such as `example.com`. It covers the subdomains too. */
70
+ d: string;
71
+ /** When the key was issued, in seconds since 1970. */
72
+ iat: number;
73
+ /** When the key ends, in seconds since 1970. A key without it never ends. */
74
+ exp?: number;
75
+ }
76
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/license/types.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,MAAM,cAAc;AACxB,wBAAwB;AACtB,SAAS;AACX,qEAAqE;GACnE,WAAW;AACb,6DAA6D;GAC3D,WAAW;AACb,mDAAmD;GAC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@@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/license/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ import type { LicensePublicKey, LicenseStatus } from "./types.js";
2
+ export interface VerifyLicenseOptions {
3
+ /** The key the app passed, or nothing. */
4
+ key: string | null | undefined;
5
+ /** The website the viewer is running on: `location.hostname`. */
6
+ hostname: string;
7
+ /** The key that checks signatures. `null` when the build has none. */
8
+ publicKey: LicensePublicKey | null;
9
+ /** Serial numbers that have been withdrawn. */
10
+ revoked?: readonly string[];
11
+ /** The time to compare the key's end date with, in milliseconds. Default: now. */
12
+ now?: number;
13
+ /** The WebCrypto to use. Default: `globalThis.crypto.subtle`. `null` when there is none. */
14
+ subtle?: SubtleCrypto | null;
15
+ }
16
+ /**
17
+ * Checks a license key against the website it runs on, with no server and no network: the key
18
+ * carries its own signature, and the public key that checks it ships with the package.
19
+ *
20
+ * It never throws and never rejects. The answer is a `LicenseStatus`, and only
21
+ * `{ state: "unlicensed" }` means "show the watermark". Anything the check cannot decide leaves the
22
+ * viewer unmarked (`unverified`), so a missing browser feature cannot break a customer's site.
23
+ */
24
+ export declare function verifyLicense(options: VerifyLicenseOptions): Promise<LicenseStatus>;
25
+ //# sourceMappingURL=verify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/license/verify.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAElE,MAAM,WAAW,oBAAoB;IACnC,0CAA0C;IAC1C,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/B,iEAAiE;IACjE,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACnC,+CAA+C;IAC/C,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,kFAAkF;IAClF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4FAA4F;IAC5F,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CAgDzF"}
@@ -0,0 +1,48 @@
1
+ import { hostMatchesDomain, isDevelopmentHost, normalizeHost, parseLicenseKey } from "./format.js";
2
+ /**
3
+ * Checks a license key against the website it runs on, with no server and no network: the key
4
+ * carries its own signature, and the public key that checks it ships with the package.
5
+ *
6
+ * It never throws and never rejects. The answer is a `LicenseStatus`, and only
7
+ * `{ state: "unlicensed" }` means "show the watermark". Anything the check cannot decide leaves the
8
+ * viewer unmarked (`unverified`), so a missing browser feature cannot break a customer's site.
9
+ */
10
+ export async function verifyLicense(options) {
11
+ const host = normalizeHost(options.hostname);
12
+ if (isDevelopmentHost(host))
13
+ return { state: "development", host };
14
+ const unlicensed = (reason, extra = {}) => ({ state: "unlicensed", host, reason, ...extra });
15
+ const text = typeof options.key === "string" ? options.key.trim() : "";
16
+ if (text === "")
17
+ return unlicensed("missing");
18
+ const parsed = parseLicenseKey(text);
19
+ if (!parsed)
20
+ return unlicensed("malformed");
21
+ if (!options.publicKey)
22
+ return unlicensed("no-public-key");
23
+ const subtle = options.subtle === undefined ? (globalThis.crypto?.subtle ?? null) : options.subtle;
24
+ if (!subtle)
25
+ return { state: "unverified", host, reason: "no-webcrypto" };
26
+ let genuine;
27
+ try {
28
+ const key = await subtle.importKey("jwk", { ...options.publicKey, ext: true }, { name: "ECDSA", namedCurve: "P-256" }, false, ["verify"]);
29
+ genuine = await subtle.verify({ name: "ECDSA", hash: "SHA-256" }, key, parsed.signature, new TextEncoder().encode(parsed.signedText));
30
+ }
31
+ catch {
32
+ // The browser has `crypto.subtle` but cannot do P-256 with it. That is not the customer's fault.
33
+ return { state: "unverified", host, reason: "no-webcrypto" };
34
+ }
35
+ if (!genuine)
36
+ return unlicensed("signature");
37
+ // The payload can be believed from here on.
38
+ const { id, d: domain, exp } = parsed.payload;
39
+ if (options.revoked?.includes(id))
40
+ return unlicensed("revoked", { licensedFor: domain });
41
+ if (exp !== undefined && (options.now ?? Date.now()) >= exp * 1000) {
42
+ return unlicensed("expired", { licensedFor: domain, expiredAt: exp * 1000 });
43
+ }
44
+ if (!hostMatchesDomain(host, domain))
45
+ return unlicensed("domain", { licensedFor: domain });
46
+ return { state: "licensed", id, domain, expiresAt: exp === undefined ? null : exp * 1000 };
47
+ }
48
+ //# sourceMappingURL=verify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/license/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAkBnG;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA6B;IAC/D,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7C,IAAI,iBAAiB,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;IAEnE,MAAM,UAAU,GAAG,CACjB,MAAiE,EACjE,QAAsD,EAAE,EACzC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;IAEtE,MAAM,IAAI,GAAG,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACvE,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC;IAC9C,MAAM,MAAM,GAA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AAE,GAAG,MAAM,CAAC,OAAO,CAAC;IAC9C,IAAI,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;QAAE,OAAO,UAAU,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;IACzF,IAAI,GAAG,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,GAAG,GAAG,IAAI,EAAE,CAAC;QACnE,OAAO,UAAU,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,GAAG,IAAI,EAAE,CAAC,CAAC;IAC/E,CAAC;IACD,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC;QAAE,OAAO,UAAU,CAAC,QAAQ,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;IAE3F,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,EAAE,CAAC;AAC7F,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { LicenseStatus } from "./types.js";
2
+ /** Where the license terms and the way to get a key are explained. */
3
+ export declare const LICENSE_INFO_URL = "https://github.com/dsamithmendis/next-flipbook/blob/main/docs/licensing.md";
4
+ /** What to tell the developer about a status, or null when there is nothing to say. */
5
+ export declare function describeLicense(status: LicenseStatus): string | null;
6
+ /**
7
+ * Writes the status's message to the console, once per message for the life of the page: several
8
+ * viewers, or a re-render, do not repeat it. The one place the library uses the console, because
9
+ * the license warning is for the developer who reads it there.
10
+ */
11
+ export declare function warnAboutLicense(status: LicenseStatus): void;
12
+ /** Forgets what was said. For tests: a page never needs it. */
13
+ export declare function resetLicenseWarnings(): void;
14
+ //# sourceMappingURL=warn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"warn.d.ts","sourceRoot":"","sources":["../../src/license/warn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,sEAAsE;AACtE,eAAO,MAAM,gBAAgB,+EAA+E,CAAC;AAI7G,uFAAuF;AACvF,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAwBpE;AAID;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAK5D;AAED,+DAA+D;AAC/D,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
@@ -0,0 +1,47 @@
1
+ /** Where the license terms and the way to get a key are explained. */
2
+ export const LICENSE_INFO_URL = "https://github.com/dsamithmendis/next-flipbook/blob/main/docs/licensing.md";
3
+ const formatDate = (milliseconds) => new Date(milliseconds).toISOString().slice(0, 10);
4
+ /** What to tell the developer about a status, or null when there is nothing to say. */
5
+ export function describeLicense(status) {
6
+ const more = ` See ${LICENSE_INFO_URL}`;
7
+ if (status.state === "unverified") {
8
+ return `Could not check the license key on ${status.host}: this browser has no crypto.subtle, which needs HTTPS. The viewer is not marked.`;
9
+ }
10
+ if (status.state !== "unlicensed")
11
+ return null;
12
+ const mark = `The viewer shows a watermark on ${status.host}.`;
13
+ switch (status.reason) {
14
+ case "missing":
15
+ return `No license key. ${mark} Pass licenseKey to <FlipBook>, or wrap the app in <FlipBookLicenseProvider licenseKey="...">.${more}`;
16
+ case "malformed":
17
+ return `The license key is not valid: it looks cut off or mistyped, or it is not a next-flipbook key. ${mark}${more}`;
18
+ case "signature":
19
+ return `The license key was not issued by next-flipbook (its signature does not match). ${mark}${more}`;
20
+ case "domain":
21
+ return `This license key is for ${status.licensedFor ?? "another website"}, not ${status.host}. A key works on one website. ${mark}${more}`;
22
+ case "expired":
23
+ return `This license key ended on ${status.expiredAt === undefined ? "an earlier date" : formatDate(status.expiredAt)}. ${mark}${more}`;
24
+ case "revoked":
25
+ return `This license key has been withdrawn. ${mark}${more}`;
26
+ case "no-public-key":
27
+ return `This build of next-flipbook cannot check license keys (it has no public key). ${mark}${more}`;
28
+ }
29
+ }
30
+ const told = new Set();
31
+ /**
32
+ * Writes the status's message to the console, once per message for the life of the page: several
33
+ * viewers, or a re-render, do not repeat it. The one place the library uses the console, because
34
+ * the license warning is for the developer who reads it there.
35
+ */
36
+ export function warnAboutLicense(status) {
37
+ const message = describeLicense(status);
38
+ if (message === null || told.has(message))
39
+ return;
40
+ told.add(message);
41
+ console.warn(`[next-flipbook] ${message}`);
42
+ }
43
+ /** Forgets what was said. For tests: a page never needs it. */
44
+ export function resetLicenseWarnings() {
45
+ told.clear();
46
+ }
47
+ //# sourceMappingURL=warn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"warn.js","sourceRoot":"","sources":["../../src/license/warn.ts"],"names":[],"mappings":"AAEA,sEAAsE;AACtE,MAAM,CAAC,MAAM,gBAAgB,GAAG,4EAA4E,CAAC;AAE7G,MAAM,UAAU,GAAG,CAAC,YAAoB,EAAU,EAAE,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAEvG,uFAAuF;AACvF,MAAM,UAAU,eAAe,CAAC,MAAqB;IACnD,MAAM,IAAI,GAAG,QAAQ,gBAAgB,EAAE,CAAC;IACxC,IAAI,MAAM,CAAC,KAAK,KAAK,YAAY,EAAE,CAAC;QAClC,OAAO,sCAAsC,MAAM,CAAC,IAAI,mFAAmF,CAAC;IAC9I,CAAC;IACD,IAAI,MAAM,CAAC,KAAK,KAAK,YAAY;QAAE,OAAO,IAAI,CAAC;IAE/C,MAAM,IAAI,GAAG,mCAAmC,MAAM,CAAC,IAAI,GAAG,CAAC;IAC/D,QAAQ,MAAM,CAAC,MAAM,EAAE,CAAC;QACtB,KAAK,SAAS;YACZ,OAAO,mBAAmB,IAAI,iGAAiG,IAAI,EAAE,CAAC;QACxI,KAAK,WAAW;YACd,OAAO,iGAAiG,IAAI,GAAG,IAAI,EAAE,CAAC;QACxH,KAAK,WAAW;YACd,OAAO,mFAAmF,IAAI,GAAG,IAAI,EAAE,CAAC;QAC1G,KAAK,QAAQ;YACX,OAAO,2BAA2B,MAAM,CAAC,WAAW,IAAI,iBAAiB,SAAS,MAAM,CAAC,IAAI,iCAAiC,IAAI,GAAG,IAAI,EAAE,CAAC;QAC9I,KAAK,SAAS;YACZ,OAAO,6BAA6B,MAAM,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,IAAI,GAAG,IAAI,EAAE,CAAC;QAC1I,KAAK,SAAS;YACZ,OAAO,wCAAwC,IAAI,GAAG,IAAI,EAAE,CAAC;QAC/D,KAAK,eAAe;YAClB,OAAO,iFAAiF,IAAI,GAAG,IAAI,EAAE,CAAC;IAC1G,CAAC;AACH,CAAC;AAED,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;AAE/B;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAqB;IACpD,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACxC,IAAI,OAAO,KAAK,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO;IAClD,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAClB,OAAO,CAAC,IAAI,CAAC,mBAAmB,OAAO,EAAE,CAAC,CAAC;AAC7C,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,oBAAoB;IAClC,IAAI,CAAC,KAAK,EAAE,CAAC;AACf,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { PdfPageProxy, PdfTextContent } from "./types.js";
2
+ /**
3
+ * Reads the text of one page.
4
+ *
5
+ * PDF.js's own `getTextContent()` collects the page's text with `for await (const chunk of stream)`.
6
+ * A browser that cannot iterate a `ReadableStream` that way, Safari at least in older versions,
7
+ * throws there: every page read fails, so a search finds nothing while the pages draw as usual.
8
+ * Reading the same stream through its reader works in every browser, so that is what is done here.
9
+ * `getTextContent()` is the fallback for a PDF.js that has no `streamTextContent()`.
10
+ *
11
+ * Resolves to `null` when the page cannot give text at all.
12
+ */
13
+ export declare function readPageText(page: PdfPageProxy): Promise<PdfTextContent | null>;
14
+ //# sourceMappingURL=readPageText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readPageText.d.ts","sourceRoot":"","sources":["../../src/pdf/readPageText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE/D;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAqBrF"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Reads the text of one page.
3
+ *
4
+ * PDF.js's own `getTextContent()` collects the page's text with `for await (const chunk of stream)`.
5
+ * A browser that cannot iterate a `ReadableStream` that way, Safari at least in older versions,
6
+ * throws there: every page read fails, so a search finds nothing while the pages draw as usual.
7
+ * Reading the same stream through its reader works in every browser, so that is what is done here.
8
+ * `getTextContent()` is the fallback for a PDF.js that has no `streamTextContent()`.
9
+ *
10
+ * Resolves to `null` when the page cannot give text at all.
11
+ */
12
+ export async function readPageText(page) {
13
+ if (typeof page.streamTextContent !== "function") {
14
+ return (await page.getTextContent?.()) ?? null;
15
+ }
16
+ const reader = page.streamTextContent().getReader();
17
+ const items = [];
18
+ try {
19
+ for (;;) {
20
+ const { done, value } = await reader.read();
21
+ if (done)
22
+ break;
23
+ for (const item of value.items)
24
+ items.push(item);
25
+ }
26
+ }
27
+ catch (error) {
28
+ // Free the stream, so that PDF.js does not go on producing text for nobody.
29
+ reader.cancel(error).catch(() => undefined);
30
+ throw error;
31
+ }
32
+ finally {
33
+ reader.releaseLock();
34
+ }
35
+ return { items };
36
+ }
37
+ //# sourceMappingURL=readPageText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readPageText.js","sourceRoot":"","sources":["../../src/pdf/readPageText.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAkB;IACnD,IAAI,OAAO,IAAI,CAAC,iBAAiB,KAAK,UAAU,EAAE,CAAC;QACjD,OAAO,CAAC,MAAM,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC;IACjD,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC,SAAS,EAAE,CAAC;IACpD,MAAM,KAAK,GAAsC,EAAE,CAAC;IACpD,IAAI,CAAC;QACH,SAAS,CAAC;YACR,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAC5C,IAAI,IAAI;gBAAE,MAAM;YAChB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK;gBAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,4EAA4E;QAC5E,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5C,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,CAAC;AACnB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/pdf/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAwB,KAAK,aAA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CjD,oFAAoF;IACpF,UAAU,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAmCvC;;;OAGG;IACH,OAAO,IAAI,IAAI;CA0BhB"}
@@ -2,6 +2,7 @@ import { FlipBookRuntimeError } from "../core/errors.js";
2
2
  import { buildPageText, estimateTextBytes } from "../core/search/text.js";
3
3
  import { CancelledError, isCancellation, mapPdfError } from "./errors.js";
4
4
  import { safeUrl } from "./links.js";
5
+ import { readPageText } from "./readPageText.js";
5
6
  import { chooseRenderScale, defaultCanvasFactory, renderPdfPage, } from "./renderer.js";
6
7
  import { resolveDocumentInit } from "./source.js";
7
8
  import { loadPdfjs } from "./worker.js";
@@ -635,7 +636,7 @@ export class PdfSession {
635
636
  try {
636
637
  if (this.destroyed)
637
638
  throw new CancelledError();
638
- const content = await page.getTextContent?.();
639
+ const content = await readPageText(page);
639
640
  if (!content)
640
641
  return null;
641
642
  if (this.destroyed)