@tobyt/expo-pdf-markup 1.1.0 → 1.1.2

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 (66) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +9 -6
  3. package/android/src/main/java/dev/terhoeven/expopdfmarkup/ContinuousPdfView.kt +38 -4
  4. package/android/src/main/java/dev/terhoeven/expopdfmarkup/ExpoPdfMarkupView.kt +1 -0
  5. package/android/src/main/java/dev/terhoeven/expopdfmarkup/TouchInterceptPolicy.kt +20 -0
  6. package/build/ExpoPdfMarkup.types.d.ts.map +1 -1
  7. package/build/ExpoPdfMarkup.types.js.map +1 -1
  8. package/build/ExpoPdfMarkupView.d.ts +1 -1
  9. package/build/ExpoPdfMarkupView.d.ts.map +1 -1
  10. package/build/ExpoPdfMarkupView.js +2 -1
  11. package/build/ExpoPdfMarkupView.js.map +1 -1
  12. package/build/ExpoPdfMarkupView.web.d.ts +2 -0
  13. package/build/ExpoPdfMarkupView.web.d.ts.map +1 -1
  14. package/build/ExpoPdfMarkupView.web.js +39 -36
  15. package/build/ExpoPdfMarkupView.web.js.map +1 -1
  16. package/build/index.d.ts +1 -1
  17. package/build/index.d.ts.map +1 -1
  18. package/build/index.js +1 -1
  19. package/build/index.js.map +1 -1
  20. package/build/pdfjs.d.ts +1 -0
  21. package/build/pdfjs.d.ts.map +1 -1
  22. package/build/pdfjs.js +3 -0
  23. package/build/pdfjs.js.map +1 -1
  24. package/build/pdfjs.web.d.ts +1 -1
  25. package/build/pdfjs.web.d.ts.map +1 -1
  26. package/build/pdfjs.web.js +1 -1
  27. package/build/pdfjs.web.js.map +1 -1
  28. package/build/web/annotationUtils.d.ts.map +1 -1
  29. package/build/web/annotationUtils.js +13 -5
  30. package/build/web/annotationUtils.js.map +1 -1
  31. package/docs/.nojekyll +1 -0
  32. package/docs/assets/hierarchy.js +1 -0
  33. package/docs/assets/highlight.css +113 -0
  34. package/docs/assets/icons.js +18 -0
  35. package/docs/assets/icons.svg +1 -0
  36. package/docs/assets/main.js +60 -0
  37. package/docs/assets/navigation.js +1 -0
  38. package/docs/assets/search.js +1 -0
  39. package/docs/assets/style.css +1648 -0
  40. package/docs/functions/ExpoPdfMarkupView.html +42 -0
  41. package/docs/functions/setPdfJsWorkerSrc.html +42 -0
  42. package/docs/hierarchy.html +29 -0
  43. package/docs/index.html +148 -0
  44. package/docs/modules.html +40 -0
  45. package/docs/types/Annotation.html +33 -0
  46. package/docs/types/AnnotationBounds.html +73 -0
  47. package/docs/types/AnnotationMode.html +33 -0
  48. package/docs/types/AnnotationPoint.html +61 -0
  49. package/docs/types/AnnotationsData.html +61 -0
  50. package/docs/types/ExpoPdfMarkupViewProps.html +184 -0
  51. package/docs/types/HighlightAnnotation.html +91 -0
  52. package/docs/types/InkAnnotation.html +91 -0
  53. package/docs/types/StampAnnotation.html +95 -0
  54. package/docs/types/StampDefinition.html +72 -0
  55. package/docs/types/TextAnnotation.html +110 -0
  56. package/docs/types/TextInputRequest.html +73 -0
  57. package/docs/types/UnderlineAnnotation.html +85 -0
  58. package/metro.js +47 -20
  59. package/package.json +8 -8
  60. package/src/ExpoPdfMarkup.types.ts +2 -13
  61. package/src/ExpoPdfMarkupView.tsx +1 -1
  62. package/src/ExpoPdfMarkupView.web.tsx +26 -13
  63. package/src/index.ts +1 -1
  64. package/src/pdfjs.ts +4 -0
  65. package/src/pdfjs.web.ts +1 -1
  66. package/src/web/annotationUtils.ts +11 -5
@@ -0,0 +1,85 @@
1
+ <!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>UnderlineAnnotation | @tobyt/expo-pdf-markup - v1.1.1</title><meta name="description" content="Documentation for @tobyt/expo-pdf-markup"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar">
2
+ <div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@tobyt/expo-pdf-markup - v1.1.1</a>
3
+ <div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/>
4
+ <ul role="listbox" id="tsd-search-results"></ul>
5
+ <div id="tsd-search-status" aria-live="polite" aria-atomic="true">
6
+ <div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header>
7
+ <div class="container container-main">
8
+ <div class="col-content">
9
+ <div class="tsd-page-title">
10
+ <ul class="tsd-breadcrumb" aria-label="Breadcrumb">
11
+ <li><a href="" aria-current="page">UnderlineAnnotation</a></li></ul>
12
+ <h1>Type Alias UnderlineAnnotation</h1></div>
13
+ <div class="tsd-signature"><span class="tsd-signature-keyword">type</span> <span class="tsd-kind-type-alias">UnderlineAnnotation</span> <span class="tsd-signature-symbol">=</span> <span class="tsd-signature-symbol">{</span><br/>    <a class="tsd-kind-property" href="#bounds">bounds</a><span class="tsd-signature-symbol">:</span> <a href="AnnotationBounds.html" class="tsd-signature-type tsd-kind-type-alias">AnnotationBounds</a><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="#color">color</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="#createdat">createdAt</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="#id">id</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="#page">page</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="#type">type</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;underline&quot;</span><span class="tsd-signature-symbol">;</span><br/><span class="tsd-signature-symbol">}</span></div><aside class="tsd-sources">
14
+ <ul>
15
+ <li>Defined in <a href="https://github.com/tobyt42/expo-pdf-markup/blob/f632112f16a9c9695af79990482a3b51b32ac893/src/ExpoPdfMarkup.types.ts#L27">ExpoPdfMarkup.types.ts:27</a></li></ul></aside>
16
+ <section class="tsd-panel-group tsd-index-group">
17
+ <section class="tsd-panel tsd-index-panel">
18
+ <details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>
19
+ <h5 class="tsd-index-heading uppercase">Index</h5></summary>
20
+ <div class="tsd-accordion-details">
21
+ <section class="tsd-index-section">
22
+ <h3 class="tsd-index-heading tsd-anchor-link" id="properties">Properties<a href="#properties" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
23
+ <div class="tsd-index-list"><a href="#bounds" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>bounds</span></a>
24
+ <a href="#color" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>color</span></a>
25
+ <a href="#createdat" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>created<wbr/>At?</span></a>
26
+ <a href="#id" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>id</span></a>
27
+ <a href="#page" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>page</span></a>
28
+ <a href="#type" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>type</span></a>
29
+ </div></section></div></details></section></section>
30
+ <details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>
31
+ <h2 class="tsd-anchor-link" id="properties-1">Properties<a href="#properties-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2></summary>
32
+ <section>
33
+ <section class="tsd-panel tsd-member">
34
+ <h3 class="tsd-anchor-link" id="bounds"><span>bounds</span><a href="#bounds" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
35
+ <div class="tsd-signature"><span class="tsd-kind-property">bounds</span><span class="tsd-signature-symbol">:</span> <a href="AnnotationBounds.html" class="tsd-signature-type tsd-kind-type-alias">AnnotationBounds</a></div><aside class="tsd-sources">
36
+ <ul>
37
+ <li>Defined in <a href="https://github.com/tobyt42/expo-pdf-markup/blob/f632112f16a9c9695af79990482a3b51b32ac893/src/ExpoPdfMarkup.types.ts#L32">ExpoPdfMarkup.types.ts:32</a></li></ul></aside></section>
38
+ <section class="tsd-panel tsd-member">
39
+ <h3 class="tsd-anchor-link" id="color"><span>color</span><a href="#color" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
40
+ <div class="tsd-signature"><span class="tsd-kind-property">color</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources">
41
+ <ul>
42
+ <li>Defined in <a href="https://github.com/tobyt42/expo-pdf-markup/blob/f632112f16a9c9695af79990482a3b51b32ac893/src/ExpoPdfMarkup.types.ts#L31">ExpoPdfMarkup.types.ts:31</a></li></ul></aside></section>
43
+ <section class="tsd-panel tsd-member">
44
+ <h3 class="tsd-anchor-link" id="createdat"><code class="tsd-tag">Optional</code><span>created<wbr/>At</span><a href="#createdat" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
45
+ <div class="tsd-signature"><span class="tsd-kind-property">createdAt</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources">
46
+ <ul>
47
+ <li>Defined in <a href="https://github.com/tobyt42/expo-pdf-markup/blob/f632112f16a9c9695af79990482a3b51b32ac893/src/ExpoPdfMarkup.types.ts#L33">ExpoPdfMarkup.types.ts:33</a></li></ul></aside></section>
48
+ <section class="tsd-panel tsd-member">
49
+ <h3 class="tsd-anchor-link" id="id"><span>id</span><a href="#id" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
50
+ <div class="tsd-signature"><span class="tsd-kind-property">id</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources">
51
+ <ul>
52
+ <li>Defined in <a href="https://github.com/tobyt42/expo-pdf-markup/blob/f632112f16a9c9695af79990482a3b51b32ac893/src/ExpoPdfMarkup.types.ts#L28">ExpoPdfMarkup.types.ts:28</a></li></ul></aside></section>
53
+ <section class="tsd-panel tsd-member">
54
+ <h3 class="tsd-anchor-link" id="page"><span>page</span><a href="#page" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
55
+ <div class="tsd-signature"><span class="tsd-kind-property">page</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources">
56
+ <ul>
57
+ <li>Defined in <a href="https://github.com/tobyt42/expo-pdf-markup/blob/f632112f16a9c9695af79990482a3b51b32ac893/src/ExpoPdfMarkup.types.ts#L30">ExpoPdfMarkup.types.ts:30</a></li></ul></aside></section>
58
+ <section class="tsd-panel tsd-member">
59
+ <h3 class="tsd-anchor-link" id="type"><span>type</span><a href="#type" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
60
+ <div class="tsd-signature"><span class="tsd-kind-property">type</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;underline&quot;</span></div><aside class="tsd-sources">
61
+ <ul>
62
+ <li>Defined in <a href="https://github.com/tobyt42/expo-pdf-markup/blob/f632112f16a9c9695af79990482a3b51b32ac893/src/ExpoPdfMarkup.types.ts#L29">ExpoPdfMarkup.types.ts:29</a></li></ul></aside></section></section></details></div>
63
+ <div class="col-sidebar">
64
+ <div class="page-menu">
65
+ <div class="tsd-navigation settings">
66
+ <details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>
67
+ <h3>Settings</h3></summary>
68
+ <div class="tsd-accordion-details">
69
+ <div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span>
70
+ <ul id="tsd-filter-options">
71
+ <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li>
72
+ <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li>
73
+ <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div>
74
+ <div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div>
75
+ <details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>
76
+ <h3>On This Page</h3></summary>
77
+ <div class="tsd-accordion-details">
78
+ <details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary>
79
+ <div><a href="#bounds"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>bounds</span></a><a href="#color"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>color</span></a><a href="#createdat"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>created<wbr/>At</span></a><a href="#id"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>id</span></a><a href="#page"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>page</span></a><a href="#type"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>type</span></a></div></details></div></details></div>
80
+ <div class="site-menu">
81
+ <nav class="tsd-navigation"><a href="../modules.html">@tobyt/expo-pdf-markup - v1.1.1</a>
82
+ <ul class="tsd-small-nested-navigation" id="tsd-nav-container">
83
+ <li>Loading...</li></ul></nav></div></div></div><footer>
84
+ <p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer>
85
+ <div class="overlay"></div></body></html>
package/metro.js CHANGED
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * This does two things:
12
12
  * 1. Patches `import.meta` in pdfjs-dist source before Babel/hermes-parser
13
- * sees it (pdfjs-dist v4 uses it in a Node.js-only code path that is dead
13
+ * sees it (pdfjs-dist uses it in a Node.js-only code path that is dead
14
14
  * code in the browser, but Metro bundles as a non-module script so the
15
15
  * browser's JS engine refuses to parse the bundle).
16
16
  * 2. Copies the pdfjs worker file to <projectRoot>/public/pdf.worker.min.mjs
@@ -43,8 +43,9 @@ function upstream(projectRoot) {
43
43
 
44
44
  module.exports.transform = function transform({ filename, src, options, plugins }) {
45
45
  // Replace `import.meta` with `({})` in pdfjs-dist files before any parser
46
- // sees the source. `({}).url` → undefined, which is harmless: the method
47
- // that uses it (NodeCanvasFactory._createCanvas) is Node.js-only dead code.
46
+ // sees the source. `({}).url` → undefined, which is harmless: the only use
47
+ // (NodeCanvasFactory._createCanvas → createRequire(import.meta.url)) is
48
+ // Node.js-only dead code that never runs in the browser.
48
49
  if (filename.includes('pdfjs-dist') && src.includes('import.meta')) {
49
50
  src = src.replace(/import\.meta/g, '({})');
50
51
  }
@@ -59,29 +60,55 @@ module.exports.withPdfMarkup = function withPdfMarkup(config) {
59
60
  // 1. Swap in this file as the babel transformer so import.meta is patched.
60
61
  config.transformer.babelTransformerPath = require.resolve('./metro.js');
61
62
 
62
- // 2. Copy the pdfjs worker to <projectRoot>/public/ so it is served at
63
- // /pdf.worker.min.mjs (same-origin). Only copies if not already present,
64
- // so repeated Metro restarts are fast.
65
63
  const projectRoot = config.projectRoot ?? process.cwd();
66
64
  const publicDir = path.join(projectRoot, 'public');
67
- const dest = path.join(publicDir, 'pdf.worker.min.mjs');
68
65
 
69
- if (!fs.existsSync(dest)) {
70
- let workerSrc;
71
- try {
72
- workerSrc = require.resolve('pdfjs-dist/build/pdf.worker.min.mjs');
73
- } catch {
74
- console.warn(
75
- '[expo-pdf-markup] Could not find pdfjs-dist. ' +
76
- 'Install it as a dependency to enable web PDF rendering.'
77
- );
78
- return config;
79
- }
66
+ // Locate the installed pdfjs-dist so we can copy its runtime assets.
67
+ let pdfjsDir;
68
+ try {
69
+ pdfjsDir = path.dirname(require.resolve('pdfjs-dist/package.json'));
70
+ } catch {
71
+ console.warn(
72
+ '[expo-pdf-markup] Could not find pdfjs-dist. ' +
73
+ 'Install it as a dependency to enable web PDF rendering.'
74
+ );
75
+ return config;
76
+ }
77
+
78
+ // 2. Copy the pdfjs worker to <projectRoot>/public/ so it is served at
79
+ // /pdf.worker.min.mjs (same-origin). Only copies if not already present,
80
+ // so repeated Metro restarts are fast.
81
+ const workerDest = path.join(publicDir, 'pdf.worker.min.mjs');
82
+ if (!fs.existsSync(workerDest)) {
80
83
  if (!fs.existsSync(publicDir)) {
81
84
  fs.mkdirSync(publicDir, { recursive: true });
82
85
  }
83
- fs.copyFileSync(workerSrc, dest);
84
- console.log('[expo-pdf-markup] Copied pdfjs worker → ' + dest);
86
+ fs.copyFileSync(path.join(pdfjsDir, 'build', 'pdf.worker.min.mjs'), workerDest);
87
+ console.log('[expo-pdf-markup] Copied pdfjs worker → ' + workerDest);
88
+ }
89
+
90
+ // 3. Copy the pdfjs WebAssembly assets to <projectRoot>/public/wasm/ so they
91
+ // are served at /wasm/ (same-origin). pdfjs-dist v6 decodes JBIG2/CCITT
92
+ // fax, JPEG2000 and ICC data in WebAssembly and fetches these files at
93
+ // runtime; without them such image data (e.g. scanned pages, some music
94
+ // notation) renders blank. Copies any files not already present.
95
+ const wasmSrcDir = path.join(pdfjsDir, 'wasm');
96
+ const wasmDestDir = path.join(publicDir, 'wasm');
97
+ if (fs.existsSync(wasmSrcDir)) {
98
+ let copied = 0;
99
+ for (const file of fs.readdirSync(wasmSrcDir)) {
100
+ const dest = path.join(wasmDestDir, file);
101
+ if (!fs.existsSync(dest)) {
102
+ if (!fs.existsSync(wasmDestDir)) {
103
+ fs.mkdirSync(wasmDestDir, { recursive: true });
104
+ }
105
+ fs.copyFileSync(path.join(wasmSrcDir, file), dest);
106
+ copied++;
107
+ }
108
+ }
109
+ if (copied > 0) {
110
+ console.log('[expo-pdf-markup] Copied ' + copied + ' pdfjs wasm file(s) → ' + wasmDestDir);
111
+ }
85
112
  }
86
113
 
87
114
  return config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tobyt/expo-pdf-markup",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "An Expo module for displaying and annotating PDFs",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -10,8 +10,8 @@
10
10
  "lint": "expo-module lint",
11
11
  "lint:swift": "swiftlint lint ios/",
12
12
  "lint:kotlin": "ktlint 'android/src/**/*.kt'",
13
- "format": "prettier --write \"src/**/*.{ts,tsx}\"",
14
- "format:check": "prettier --check \"src/**/*.{ts,tsx}\"",
13
+ "format": "node ./node_modules/prettier/bin/prettier.cjs --write \"src/**/*.{ts,tsx}\"",
14
+ "format:check": "node ./node_modules/prettier/bin/prettier.cjs --check \"src/**/*.{ts,tsx}\"",
15
15
  "format:swift": "swiftformat ios/",
16
16
  "format:swift:check": "swiftformat --lint ios/",
17
17
  "format:kotlin": "ktlint --format 'android/src/**/*.kt'",
@@ -53,12 +53,12 @@
53
53
  },
54
54
  "devDependencies": {
55
55
  "@changesets/cli": "^2.30.0",
56
- "@types/react": "~19.2.10",
56
+ "@types/react": "~19.2.17",
57
57
  "@types/react-test-renderer": "^19.1.0",
58
- "expo": "~55.0.26",
59
- "expo-module-scripts": "^55.0.2",
60
- "pdfjs-dist": "^4.10.38",
61
- "react-native": "0.83.6",
58
+ "expo": "~56.0.16",
59
+ "expo-module-scripts": "^56.0.3",
60
+ "pdfjs-dist": "^6.1.200",
61
+ "react-native": "^0.85.3",
62
62
  "react-native-web": "^0.21.2",
63
63
  "typedoc": "^0.28.17"
64
64
  },
@@ -64,11 +64,7 @@ export type StampAnnotation = {
64
64
  };
65
65
 
66
66
  export type Annotation =
67
- | InkAnnotation
68
- | HighlightAnnotation
69
- | UnderlineAnnotation
70
- | TextAnnotation
71
- | StampAnnotation;
67
+ InkAnnotation | HighlightAnnotation | UnderlineAnnotation | TextAnnotation | StampAnnotation;
72
68
 
73
69
  export type AnnotationsData = {
74
70
  version: 1;
@@ -76,14 +72,7 @@ export type AnnotationsData = {
76
72
  };
77
73
 
78
74
  export type AnnotationMode =
79
- | 'none'
80
- | 'ink'
81
- | 'highlight'
82
- | 'underline'
83
- | 'text'
84
- | 'stamp'
85
- | 'eraser'
86
- | 'move';
75
+ 'none' | 'ink' | 'highlight' | 'underline' | 'text' | 'stamp' | 'eraser' | 'move';
87
76
 
88
77
  /**
89
78
  * Recommended shape for describing a consumer-defined stamp set (e.g. domain-specific glyphs).
@@ -2,7 +2,7 @@ import { requireNativeModule, requireNativeView } from 'expo';
2
2
  import * as React from 'react';
3
3
  import { findNodeHandle } from 'react-native';
4
4
 
5
- import { ExpoPdfMarkupViewProps, TextInputRequest } from './ExpoPdfMarkup.types';
5
+ import type { ExpoPdfMarkupViewProps, TextInputRequest } from './ExpoPdfMarkup.types';
6
6
 
7
7
  type NativeViewProps = Omit<ExpoPdfMarkupViewProps, 'onTextInputRequested'> & {
8
8
  useJsTextDialog?: boolean;
@@ -36,6 +36,18 @@ export function setPdfJsWorkerSrc(url: string): void {
36
36
  pdfjs.GlobalWorkerOptions.workerSrc = url;
37
37
  }
38
38
 
39
+ // pdfjs-dist v6 decodes image data (JBIG2/CCITT fax, JPEG2000, ICC) in
40
+ // WebAssembly and must be told where the .wasm files live. withPdfMarkup() in
41
+ // metro.js copies them to public/wasm/. Relative URL so the worker resolves it
42
+ // regardless of the sub-path the app is hosted at. Override with
43
+ // setPdfJsWasmUrl() for a different bundler or CDN.
44
+ let wasmUrl = './wasm/';
45
+
46
+ /** Allow consumers to override the pdfjs WebAssembly directory URL before mounting the view. */
47
+ export function setPdfJsWasmUrl(url: string): void {
48
+ wasmUrl = url;
49
+ }
50
+
39
51
  // ---------------------------------------------------------------------------
40
52
  // Zoom constants
41
53
  // ---------------------------------------------------------------------------
@@ -122,7 +134,7 @@ function PageView({
122
134
  const ctx = canvas.getContext('2d');
123
135
  if (!ctx) return;
124
136
  const viewport = page.getViewport({ scale: meta.scale * dpr });
125
- const task = page.render({ canvasContext: ctx, viewport });
137
+ const task = page.render({ canvas: null, canvasContext: ctx, viewport });
126
138
  renderTaskRef.current = task;
127
139
  try {
128
140
  await task.promise;
@@ -162,6 +174,7 @@ function PageView({
162
174
  ctx.beginPath();
163
175
  for (let i = 0; i < liveInkPoints.length; i++) {
164
176
  const pt = liveInkPoints[i];
177
+ if (!pt) continue;
165
178
  if (i === 0) ctx.moveTo(pt.x, pt.y);
166
179
  else ctx.lineTo(pt.x, pt.y);
167
180
  }
@@ -378,10 +391,10 @@ function PageView({
378
391
  annotationMode === 'move'
379
392
  ? 'grab'
380
393
  : annotationMode === 'eraser'
381
- ? 'not-allowed'
382
- : annotationMode === 'stamp'
383
- ? 'copy'
384
- : 'crosshair';
394
+ ? 'not-allowed'
395
+ : annotationMode === 'stamp'
396
+ ? 'copy'
397
+ : 'crosshair';
385
398
 
386
399
  return (
387
400
  <div
@@ -512,8 +525,8 @@ export default function ExpoPdfMarkupView(props: ExpoPdfMarkupViewProps) {
512
525
  let pinchStart: { dist: number; zoom: number; midX: number; midY: number } | null = null;
513
526
 
514
527
  function getTouchDist(touches: TouchList): number {
515
- const dx = touches[0].clientX - touches[1].clientX;
516
- const dy = touches[0].clientY - touches[1].clientY;
528
+ const dx = touches[0]!.clientX - touches[1]!.clientX;
529
+ const dy = touches[0]!.clientY - touches[1]!.clientY;
517
530
  return Math.sqrt(dx * dx + dy * dy);
518
531
  }
519
532
 
@@ -523,8 +536,8 @@ export default function ExpoPdfMarkupView(props: ExpoPdfMarkupViewProps) {
523
536
  pinchStart = {
524
537
  dist: getTouchDist(e.touches),
525
538
  zoom: zoomRef.current,
526
- midX: (e.touches[0].clientX + e.touches[1].clientX) / 2 - rect.left,
527
- midY: (e.touches[0].clientY + e.touches[1].clientY) / 2 - rect.top,
539
+ midX: (e.touches[0]!.clientX + e.touches[1]!.clientX) / 2 - rect.left,
540
+ midY: (e.touches[0]!.clientY + e.touches[1]!.clientY) / 2 - rect.top,
528
541
  };
529
542
  }
530
543
 
@@ -561,10 +574,10 @@ export default function ExpoPdfMarkupView(props: ExpoPdfMarkupViewProps) {
561
574
 
562
575
  async function load() {
563
576
  try {
564
- const task = pdfjs.getDocument(source);
577
+ const task = pdfjs.getDocument({ url: source, wasmUrl });
565
578
  const loadedDoc = await task.promise;
566
579
  if (cancelled || loadingSourceRef.current !== source) {
567
- loadedDoc.destroy();
580
+ loadedDoc.loadingTask.destroy();
568
581
  return;
569
582
  }
570
583
  const metas: PdfPageMeta[] = [];
@@ -573,7 +586,7 @@ export default function ExpoPdfMarkupView(props: ExpoPdfMarkupViewProps) {
573
586
  const pg = await loadedDoc.getPage(i);
574
587
  if (cancelled) {
575
588
  pg.cleanup();
576
- loadedDoc.destroy();
589
+ loadedDoc.loadingTask.destroy();
577
590
  return;
578
591
  }
579
592
  const viewport = pg.getViewport({ scale: 1 });
@@ -588,7 +601,7 @@ export default function ExpoPdfMarkupView(props: ExpoPdfMarkupViewProps) {
588
601
  });
589
602
  pg.cleanup();
590
603
  }
591
- docRef.current?.destroy();
604
+ docRef.current?.loadingTask.destroy();
592
605
  docRef.current = loadedDoc;
593
606
  setDoc(loadedDoc);
594
607
  setPageMetas(metas);
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { default as ExpoPdfMarkupView } from './ExpoPdfMarkupView';
2
- export { setPdfJsWorkerSrc } from './pdfjs';
2
+ export { setPdfJsWorkerSrc, setPdfJsWasmUrl } from './pdfjs';
3
3
  export * from './ExpoPdfMarkup.types';
package/src/pdfjs.ts CHANGED
@@ -2,3 +2,7 @@
2
2
  export function setPdfJsWorkerSrc(_url: string): void {
3
3
  // no-op on native
4
4
  }
5
+
6
+ export function setPdfJsWasmUrl(_url: string): void {
7
+ // no-op on native
8
+ }
package/src/pdfjs.web.ts CHANGED
@@ -1 +1 @@
1
- export { setPdfJsWorkerSrc } from './ExpoPdfMarkupView.web';
1
+ export { setPdfJsWorkerSrc, setPdfJsWasmUrl } from './ExpoPdfMarkupView.web';
@@ -204,17 +204,21 @@ export function hitTestAnnotation(
204
204
  const onPage = annotations.filter((a) => a.page === pageIndex);
205
205
  for (let i = onPage.length - 1; i >= 0; i--) {
206
206
  const annotation = onPage[i];
207
+ if (!annotation) continue;
207
208
  if (annotation.type === 'ink') {
208
209
  const tolerance = Math.max(annotation.lineWidth ?? 2, 10);
209
210
  const paths = annotation.paths ?? [];
210
211
  for (const stroke of paths) {
211
- if (stroke.length === 1) {
212
- const dx = pdfPoint.x - stroke[0].x;
213
- const dy = pdfPoint.y - stroke[0].y;
212
+ const first = stroke[0];
213
+ if (stroke.length === 1 && first) {
214
+ const dx = pdfPoint.x - first.x;
215
+ const dy = pdfPoint.y - first.y;
214
216
  if (Math.sqrt(dx * dx + dy * dy) <= tolerance) return annotation;
215
217
  }
216
218
  for (let j = 0; j < stroke.length - 1; j++) {
217
- if (distanceToSegment(pdfPoint, stroke[j], stroke[j + 1]) <= tolerance) {
219
+ const from = stroke[j];
220
+ const to = stroke[j + 1];
221
+ if (from && to && distanceToSegment(pdfPoint, from, to) <= tolerance) {
218
222
  return annotation;
219
223
  }
220
224
  }
@@ -271,7 +275,9 @@ export function drawAnnotationsOnCanvas(
271
275
  if (stroke.length === 0) continue;
272
276
  ctx.beginPath();
273
277
  for (let i = 0; i < stroke.length; i++) {
274
- const { x, y } = pdfToCanvas(stroke[i].x, stroke[i].y, scale, pdfHeight);
278
+ const point = stroke[i];
279
+ if (!point) continue;
280
+ const { x, y } = pdfToCanvas(point.x, point.y, scale, pdfHeight);
275
281
  if (i === 0) ctx.moveTo(x, y);
276
282
  else ctx.lineTo(x, y);
277
283
  }