@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @tobyt/expo-pdf-markup
2
2
 
3
+ ## 1.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 2970fc6: Support pdfjs-dist v6 on the web renderer. Adapt to the v6 API changes: `getDocument` now takes a parameters object (`{ url }`) rather than a bare string, and `PDFDocumentProxy.destroy()` was removed in favour of `loadingTask.destroy()`. Pass `canvas: null` to `page.render()` so pdfjs keeps rendering into our own 2D context (the v6 types made `canvas` required) without taking ownership of the canvas element.
8
+
9
+ pdfjs-dist v6 also moved image decoding (JBIG2/CCITT fax, JPEG2000, ICC colour) into WebAssembly, which is fetched at runtime from a configurable `wasmUrl`. Without it, affected image data — scanned pages and some music notation — renders blank. `withPdfMarkup` now copies the WASM files to `public/wasm/`, the view sets `wasmUrl` to `./wasm/` by default, and a new `setPdfJsWasmUrl()` export lets consumers point it elsewhere.
10
+
11
+ These calls remain compatible with earlier pdfjs-dist versions, so the optional peer dependency range is unchanged.
12
+
13
+ - a361c91: Verify compatibility with Expo SDK 57 (React Native 0.86). Fix TypeScript strictness errors surfaced by the updated toolchain (`verbatimModuleSyntax`, `noUncheckedIndexedAccess`) with no behaviour change.
14
+
15
+ ## 1.1.1
16
+
17
+ ### Patch Changes
18
+
19
+ - 3f4fa8c: Android: fix touch-interception lifecycle in the PDF view. The view previously called `requestDisallowInterceptTouchEvent(true)` on every touch event and never released it, and in-progress gestures were never reset when interrupted. This could leave stale touch state on ancestor views shared with sibling screens (e.g. list rows behind the PDF screen becoming unresponsive to taps after navigating back, especially after locking/unlocking the device), and caused unnecessary gesture-handler contention while scrolling.
20
+
21
+ Now the parent intercept hold is requested on `ACTION_DOWN` and released on the final `ACTION_UP`/`ACTION_CANCEL` (held across multi-touch pinch), and all in-progress gestures (ink stroke, highlight/underline drag, annotation move, fling) are cancelled and the hold released when the window loses focus (device lock) or the view detaches. Note: an ink stroke interrupted by a device lock is discarded rather than committed.
22
+
3
23
  ## 1.1.0
4
24
 
5
25
  ### Minor Changes
package/README.md CHANGED
@@ -47,25 +47,28 @@ const config = getDefaultConfig(__dirname);
47
47
  module.exports = withPdfMarkup(config);
48
48
  ```
49
49
 
50
- `withPdfMarkup` does two things automatically:
50
+ `withPdfMarkup` does three things automatically:
51
51
 
52
- 1. **Patches `import.meta`** in pdfjs-dist so Metro can bundle it (pdfjs-dist v4 uses ESM syntax in a Node.js-only code path that is otherwise unreachable in a browser).
52
+ 1. **Patches `import.meta`** in pdfjs-dist so Metro can bundle it (pdfjs-dist uses ESM syntax in a Node.js-only code path that is otherwise unreachable in a browser).
53
53
  2. **Copies the pdfjs worker** to `public/pdf.worker.min.mjs` in your project root so it is served alongside your app (same-origin, no CORS issues). The default worker URL is `./pdf.worker.min.mjs` (relative to the page), so it works whether your app is hosted at the root or a sub-path.
54
+ 3. **Copies the pdfjs WebAssembly files** to `public/wasm/` in your project root. pdfjs-dist v6 decodes some image data (JBIG2/CCITT fax, JPEG2000, ICC colour) in WebAssembly and fetches these files at runtime; without them such content — scanned pages, some music notation — renders blank. The default WASM URL is `./wasm/` (relative to the page).
54
55
 
55
- The `public/pdf.worker.min.mjs` file is regenerated on each Metro start if missing, so you can add it to `.gitignore`:
56
+ Both are regenerated on each Metro start if missing, so you can add them to `.gitignore`:
56
57
 
57
58
  ```
58
59
  public/pdf.worker.min.mjs
60
+ public/wasm/
59
61
  ```
60
62
 
61
- #### Using a different worker URL
63
+ #### Using a different worker or WASM URL
62
64
 
63
- If you are not using Metro (e.g. Webpack or a custom CDN), set the worker URL before mounting the view:
65
+ If you are not using Metro (e.g. Webpack or a custom CDN), set the URLs before mounting the view:
64
66
 
65
67
  ```ts
66
- import { setPdfJsWorkerSrc } from '@tobyt/expo-pdf-markup';
68
+ import { setPdfJsWorkerSrc, setPdfJsWasmUrl } from '@tobyt/expo-pdf-markup';
67
69
 
68
70
  setPdfJsWorkerSrc('https://your-cdn.example.com/pdf.worker.min.mjs');
71
+ setPdfJsWasmUrl('https://your-cdn.example.com/wasm/');
69
72
  ```
70
73
 
71
74
  #### Asset loading on web
@@ -248,6 +248,13 @@ class ContinuousPdfView(context: Context) : View(context) {
248
248
  }
249
249
 
250
250
  override fun onTouchEvent(event: MotionEvent): Boolean {
251
+ // Hold off parent interception (e.g. gesture-handler root, scroll
252
+ // containers) for the duration of each gesture only; leaving it set
253
+ // permanently can strand ancestors shared with sibling screens.
254
+ TouchInterceptPolicy.disallowInterceptFor(event.actionMasked)?.let {
255
+ parent?.requestDisallowInterceptTouchEvent(it)
256
+ }
257
+
251
258
  // Always let scale detector handle pinch zoom
252
259
  scaleDetector.onTouchEvent(event)
253
260
 
@@ -306,10 +313,40 @@ class ContinuousPdfView(context: Context) : View(context) {
306
313
  }
307
314
  }
308
315
 
309
- parent?.requestDisallowInterceptTouchEvent(true)
310
316
  return true
311
317
  }
312
318
 
319
+ /**
320
+ * Cancels any in-progress gesture (ink stroke, drag, move, fling) and
321
+ * releases the parent touch-intercept hold. Needed when the gesture is
322
+ * interrupted without a final ACTION_UP/ACTION_CANCEL — device lock
323
+ * (window focus loss) or view teardown — so that no stale touch state
324
+ * survives on this view or its ancestors. An interrupted ink stroke is
325
+ * discarded rather than committed.
326
+ */
327
+ fun cancelActiveGestures() {
328
+ isDrawingInk = false
329
+ currentInkPoints.clear()
330
+ inkScreenPath.reset()
331
+ isDragging = false
332
+ dragStartPoint = null
333
+ dragCurrentPoint = null
334
+ clearMovePreview()
335
+ scroller.forceFinished(true)
336
+ parent?.requestDisallowInterceptTouchEvent(false)
337
+ invalidate()
338
+ }
339
+
340
+ override fun onWindowFocusChanged(hasWindowFocus: Boolean) {
341
+ super.onWindowFocusChanged(hasWindowFocus)
342
+ if (!hasWindowFocus) cancelActiveGestures()
343
+ }
344
+
345
+ override fun onDetachedFromWindow() {
346
+ cancelActiveGestures()
347
+ super.onDetachedFromWindow()
348
+ }
349
+
313
350
  // --- Ink mode ---
314
351
 
315
352
  private fun handleInkTouch(event: MotionEvent) {
@@ -321,7 +358,6 @@ class ContinuousPdfView(context: Context) : View(context) {
321
358
  val pt = AnnotationPoint(event.x, event.y)
322
359
  currentInkPoints.add(pt)
323
360
  inkScreenPath.moveTo(event.x, event.y)
324
- parent?.requestDisallowInterceptTouchEvent(true)
325
361
  }
326
362
 
327
363
  MotionEvent.ACTION_MOVE -> {
@@ -385,7 +421,6 @@ class ContinuousPdfView(context: Context) : View(context) {
385
421
  isDragging = true
386
422
  dragStartPoint = AnnotationPoint(event.x, event.y)
387
423
  dragCurrentPoint = dragStartPoint
388
- parent?.requestDisallowInterceptTouchEvent(true)
389
424
  }
390
425
 
391
426
  MotionEvent.ACTION_MOVE -> {
@@ -477,7 +512,6 @@ class ContinuousPdfView(context: Context) : View(context) {
477
512
  movingAnnotation = hit
478
513
  movingPreviewAnnotation = hit
479
514
  moveStartPdfPoint = pdfTouch.point
480
- parent?.requestDisallowInterceptTouchEvent(true)
481
515
  invalidate()
482
516
  }
483
517
  }
@@ -201,6 +201,7 @@ class ExpoPdfMarkupView(context: Context, appContext: AppContext) : ExpoView(con
201
201
 
202
202
  override fun onDetachedFromWindow() {
203
203
  super.onDetachedFromWindow()
204
+ pdfView.cancelActiveGestures()
204
205
  // Save the successfully-loaded source before close() so we can reload on re-attach.
205
206
  // (currentSource is always null after loadPdf() because close() resets it there.)
206
207
  sourceToReloadOnAttach = lastLoadedSource
@@ -0,0 +1,20 @@
1
+ package dev.terhoeven.expopdfmarkup
2
+
3
+ import android.view.MotionEvent
4
+
5
+ /**
6
+ * Decides whether the parent's touch interception should be disallowed for a
7
+ * given masked motion action, or left unchanged (null).
8
+ *
9
+ * The disallow flag is held for the whole gesture: requested on the initial
10
+ * ACTION_DOWN and released only on the final ACTION_UP or ACTION_CANCEL.
11
+ * ACTION_POINTER_DOWN/ACTION_POINTER_UP (extra fingers during pinch zoom)
12
+ * must not release it mid-gesture.
13
+ */
14
+ object TouchInterceptPolicy {
15
+ fun disallowInterceptFor(actionMasked: Int): Boolean? = when (actionMasked) {
16
+ MotionEvent.ACTION_DOWN -> true
17
+ MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> false
18
+ else -> null
19
+ }
20
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoPdfMarkup.types.d.ts","sourceRoot":"","sources":["../src/ExpoPdfMarkup.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,MAAM,eAAe,GAAG;IAAE,CAAC,E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ACjF;;;;;;OAMG;IACH,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7E,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoPdfMarkup.types.js","sourceRoot":"","sources":["../src/ExpoPdfMarkup.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { StyleProp, ViewStyle } from 'react-native';\n\nexport type AnnotationPoint = { x: number; y: number };\n\nexport type AnnotationBounds = { x: number; y: number; width: number; height: number };\n\nexport type InkAnnotation = {\n id: string;\n type: 'ink';\n page: number;\n color: string;\n lineWidth: number;\n paths: AnnotationPoint[][];\n createdAt?: number;\n};\n\nexport type HighlightAnnotation = {\n id: string;\n type: 'highlight';\n page: number;\n color: string;\n alpha?: number;\n bounds: AnnotationBounds;\n createdAt?: number;\n};\n\nexport type UnderlineAnnotation = {\n id: string;\n type: 'underline';\n page: number;\n color: string;\n bounds: AnnotationBounds;\n createdAt?: number;\n};\n\nexport type TextAnnotation = {\n id: string;\n type: 'text' | 'freeText';\n page: number;\n color: string;\n bounds: AnnotationBounds;\n contents?: string;\n fontSize?: number;\n /**\n * Font family for the text annotation. Platform-specific:\n * - iOS: PostScript name (`\"Georgia\"`, `\"Courier\"`) or `undefined` for system font (San Francisco)\n * - Android: family name (`\"serif\"`, `\"monospace\"`) or `undefined` for default sans-serif\n * - Web: CSS font family (`\"Georgia, serif\"`) or `undefined` for `sans-serif`\n */\n fontFamily?: string;\n createdAt?: number;\n};\n\nexport type StampAnnotation = {\n id: string;\n type: 'stamp';\n page: number;\n /** Colour applied to the text glyph, as a CSS colour string (e.g. `'#FF0000'`). Has no visible effect on full-colour emoji. */\n color: string;\n bounds: AnnotationBounds;\n /** A glyph or short string to render (e.g. an emoji, or a plain character like `'f'`). */\n text: string;\n createdAt?: number;\n};\n\nexport type Annotation =\n | InkAnnotation\n | HighlightAnnotation\n | UnderlineAnnotation\n | TextAnnotation\n | StampAnnotation;\n\nexport type AnnotationsData = {\n version: 1;\n annotations: Annotation[];\n};\n\nexport type AnnotationMode =\n | 'none'\n | 'ink'\n | 'highlight'\n | 'underline'\n | 'text'\n | 'stamp'\n | 'eraser'\n | 'move';\n\n/**\n * Recommended shape for describing a consumer-defined stamp set (e.g. domain-specific glyphs).\n * Purely a convenience type for organizing your own stamp picker UI — never sent to native;\n * extract `text` to set as the `stampText` prop before placement.\n */\nexport type StampDefinition = {\n id: string;\n label: string;\n text: string;\n};\n\nexport type TextInputRequest = {\n mode: 'create' | 'edit';\n page: number;\n point: AnnotationPoint;\n currentText?: string;\n};\n\nexport type ExpoPdfMarkupViewProps = {\n /** Absolute local file path of the PDF to display. */\n source: string;\n /** 0-based page number to display. Can be used to restore scroll position on orientation change. */\n page?: number;\n /** Background colour shown behind the PDF pages. */\n backgroundColor?: string;\n /** Serialised {@link AnnotationsData} JSON string to load when the document opens. */\n annotations?: string;\n /** Active annotation tool. Defaults to `'none'` (view-only). */\n annotationMode?: AnnotationMode;\n /** Colour applied to new annotations, as a CSS colour string (e.g. `'#FF0000'`). */\n annotationColor?: string;\n /** Stroke width in points applied to new ink annotations. */\n annotationLineWidth?: number;\n /**\n * Default font family for new text annotations. Platform-specific:\n * - iOS: PostScript name (`\"Georgia\"`, `\"Courier\"`) or `undefined` for system font (San Francisco)\n * - Android: React Native / Expo font family name (`\"Montserrat-Regular\"`, `\"serif\"`) or `undefined` for default sans-serif\n * - Web: CSS font family (`\"Georgia, serif\"`) or `undefined` for `sans-serif`\n */\n annotationFontFamily?: string;\n /** Glyph or short string for the next stamp to place. Required for the `'stamp'` tool to place anything on tap. */\n stampText?: string;\n /** Side length, in PDF points, of the square bounding box for newly placed stamps. Defaults to 48. */\n stampSize?: number;\n /** Fired when the visible page changes. */\n onPageChanged?: (event: {\n nativeEvent: { page: number; pageCount: number; pageWidth: number; pageHeight: number };\n }) => void;\n /** Fired once the document has finished loading. */\n onLoadComplete?: (event: { nativeEvent: { pageCount: number } }) => void;\n /** Fired when the document fails to load. */\n onError?: (event: { nativeEvent: { message: string } }) => void;\n /** Fired after annotations are created or edited. `annotations` is a serialised {@link AnnotationsData} JSON string. */\n onAnnotationsChanged?: (event: { nativeEvent: { annotations: string } }) => void;\n /**\n * Optional async callback for the text annotation tool. When provided, this is called instead of\n * the native platform dialog (UIAlertController / AlertDialog) when the user taps to place a text\n * annotation. When editing an existing text annotation, `request.currentText` is populated and\n * `request.mode` is `'edit'`. Return the text string to create/update the annotation, or `null`\n * to cancel.\n */\n onTextInputRequested?: (request: TextInputRequest) => Promise<string | null>;\n style?: StyleProp<ViewStyle>;\n};\n"]}
1
+ {"version":3,"file":"ExpoPdfMarkup.types.js","sourceRoot":"","sources":["../src/ExpoPdfMarkup.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { StyleProp, ViewStyle } from 'react-native';\n\nexport type AnnotationPoint = { x: number; y: number };\n\nexport type AnnotationBounds = { x: number; y: number; width: number; height: number };\n\nexport type InkAnnotation = {\n id: string;\n type: 'ink';\n page: number;\n color: string;\n lineWidth: number;\n paths: AnnotationPoint[][];\n createdAt?: number;\n};\n\nexport type HighlightAnnotation = {\n id: string;\n type: 'highlight';\n page: number;\n color: string;\n alpha?: number;\n bounds: AnnotationBounds;\n createdAt?: number;\n};\n\nexport type UnderlineAnnotation = {\n id: string;\n type: 'underline';\n page: number;\n color: string;\n bounds: AnnotationBounds;\n createdAt?: number;\n};\n\nexport type TextAnnotation = {\n id: string;\n type: 'text' | 'freeText';\n page: number;\n color: string;\n bounds: AnnotationBounds;\n contents?: string;\n fontSize?: number;\n /**\n * Font family for the text annotation. Platform-specific:\n * - iOS: PostScript name (`\"Georgia\"`, `\"Courier\"`) or `undefined` for system font (San Francisco)\n * - Android: family name (`\"serif\"`, `\"monospace\"`) or `undefined` for default sans-serif\n * - Web: CSS font family (`\"Georgia, serif\"`) or `undefined` for `sans-serif`\n */\n fontFamily?: string;\n createdAt?: number;\n};\n\nexport type StampAnnotation = {\n id: string;\n type: 'stamp';\n page: number;\n /** Colour applied to the text glyph, as a CSS colour string (e.g. `'#FF0000'`). Has no visible effect on full-colour emoji. */\n color: string;\n bounds: AnnotationBounds;\n /** A glyph or short string to render (e.g. an emoji, or a plain character like `'f'`). */\n text: string;\n createdAt?: number;\n};\n\nexport type Annotation =\n InkAnnotation | HighlightAnnotation | UnderlineAnnotation | TextAnnotation | StampAnnotation;\n\nexport type AnnotationsData = {\n version: 1;\n annotations: Annotation[];\n};\n\nexport type AnnotationMode =\n 'none' | 'ink' | 'highlight' | 'underline' | 'text' | 'stamp' | 'eraser' | 'move';\n\n/**\n * Recommended shape for describing a consumer-defined stamp set (e.g. domain-specific glyphs).\n * Purely a convenience type for organizing your own stamp picker UI — never sent to native;\n * extract `text` to set as the `stampText` prop before placement.\n */\nexport type StampDefinition = {\n id: string;\n label: string;\n text: string;\n};\n\nexport type TextInputRequest = {\n mode: 'create' | 'edit';\n page: number;\n point: AnnotationPoint;\n currentText?: string;\n};\n\nexport type ExpoPdfMarkupViewProps = {\n /** Absolute local file path of the PDF to display. */\n source: string;\n /** 0-based page number to display. Can be used to restore scroll position on orientation change. */\n page?: number;\n /** Background colour shown behind the PDF pages. */\n backgroundColor?: string;\n /** Serialised {@link AnnotationsData} JSON string to load when the document opens. */\n annotations?: string;\n /** Active annotation tool. Defaults to `'none'` (view-only). */\n annotationMode?: AnnotationMode;\n /** Colour applied to new annotations, as a CSS colour string (e.g. `'#FF0000'`). */\n annotationColor?: string;\n /** Stroke width in points applied to new ink annotations. */\n annotationLineWidth?: number;\n /**\n * Default font family for new text annotations. Platform-specific:\n * - iOS: PostScript name (`\"Georgia\"`, `\"Courier\"`) or `undefined` for system font (San Francisco)\n * - Android: React Native / Expo font family name (`\"Montserrat-Regular\"`, `\"serif\"`) or `undefined` for default sans-serif\n * - Web: CSS font family (`\"Georgia, serif\"`) or `undefined` for `sans-serif`\n */\n annotationFontFamily?: string;\n /** Glyph or short string for the next stamp to place. Required for the `'stamp'` tool to place anything on tap. */\n stampText?: string;\n /** Side length, in PDF points, of the square bounding box for newly placed stamps. Defaults to 48. */\n stampSize?: number;\n /** Fired when the visible page changes. */\n onPageChanged?: (event: {\n nativeEvent: { page: number; pageCount: number; pageWidth: number; pageHeight: number };\n }) => void;\n /** Fired once the document has finished loading. */\n onLoadComplete?: (event: { nativeEvent: { pageCount: number } }) => void;\n /** Fired when the document fails to load. */\n onError?: (event: { nativeEvent: { message: string } }) => void;\n /** Fired after annotations are created or edited. `annotations` is a serialised {@link AnnotationsData} JSON string. */\n onAnnotationsChanged?: (event: { nativeEvent: { annotations: string } }) => void;\n /**\n * Optional async callback for the text annotation tool. When provided, this is called instead of\n * the native platform dialog (UIAlertController / AlertDialog) when the user taps to place a text\n * annotation. When editing an existing text annotation, `request.currentText` is populated and\n * `request.mode` is `'edit'`. Return the text string to create/update the annotation, or `null`\n * to cancel.\n */\n onTextInputRequested?: (request: TextInputRequest) => Promise<string | null>;\n style?: StyleProp<ViewStyle>;\n};\n"]}
@@ -1,4 +1,4 @@
1
1
  import * as React from 'react';
2
- import { ExpoPdfMarkupViewProps } from './ExpoPdfMarkup.types';
2
+ import type { ExpoPdfMarkupViewProps } from './ExpoPdfMarkup.types';
3
3
  export default function ExpoPdfMarkupView({ onTextInputRequested, ...props }: ExpoPdfMarkupViewProps): React.JSX.Element;
4
4
  //# sourceMappingURL=ExpoPdfMarkupView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoPdfMarkupView.d.ts","sourceRoot":"","sources":["../src/ExpoPdfMarkupView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,sBAAsB,EAAoB,MAAM,uBAAuB,CAAC;AAajF,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,oBAAoB,EACpB,GAAG,KAAK,EACT,EAAE,sBAAsB,qBAsBxB"}
1
+ {"version":3,"file":"ExpoPdfMarkupView.d.ts","sourceRoot":"","sources":["../src/ExpoPdfMarkupView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,sBAAsB,EAAoB,MAAM,uBAAuB,CAAC;AAatF,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,oBAAoB,EACpB,GAAG,KAAK,EACT,EAAE,sBAAsB,qBAsBxB"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import { requireNativeModule, requireNativeView } from 'expo';
2
3
  import * as React from 'react';
3
4
  import { findNodeHandle } from 'react-native';
@@ -14,6 +15,6 @@ export default function ExpoPdfMarkupView({ onTextInputRequested, ...props }) {
14
15
  const text = await onTextInputRequested(event.nativeEvent);
15
16
  await NativeModule.provideTextInput(tag, text ?? null);
16
17
  }, [onTextInputRequested]);
17
- return (<NativeView ref={nativeRef} {...props} useJsTextDialog={!!onTextInputRequested} onTextInputRequested={onTextInputRequested ? handleNativeTextInputRequested : undefined}/>);
18
+ return (_jsx(NativeView, { ref: nativeRef, ...props, useJsTextDialog: !!onTextInputRequested, onTextInputRequested: onTextInputRequested ? handleNativeTextInputRequested : undefined }));
18
19
  }
19
20
  //# sourceMappingURL=ExpoPdfMarkupView.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoPdfMarkupView.js","sourceRoot":"","sources":["../src/ExpoPdfMarkupView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAS9C,MAAM,UAAU,GAAG,iBAAiB,CAAC,eAAe,CAEnD,CAAC;AAEF,MAAM,YAAY,GAAG,mBAAmB,CAAC,eAAe,CAAC,CAAC;AAE1D,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,oBAAoB,EACpB,GAAG,KAAK,EACe;IACvB,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAU,IAAI,CAAC,CAAC;IAE9C,MAAM,8BAA8B,GAAG,KAAK,CAAC,WAAW,CACtD,KAAK,EAAE,KAAwC,EAAE,EAAE;QACjD,IAAI,CAAC,oBAAoB;YAAE,OAAO;QAClC,MAAM,GAAG,GAAG,cAAc,CAAC,SAAS,CAAC,OAA+C,CAAC,CAAC;QACtF,IAAI,GAAG,IAAI,IAAI;YAAE,OAAO;QACxB,MAAM,IAAI,GAAG,MAAM,oBAAoB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC3D,MAAM,YAAY,CAAC,gBAAgB,CAAC,GAAG,EAAE,IAAI,IAAI,IAAI,CAAC,CAAC;IACzD,CAAC,EACD,CAAC,oBAAoB,CAAC,CACvB,CAAC;IAEF,OAAO,CACL,CAAC,UAAU,CACT,GAAG,CAAC,CAAC,SAAS,CAAC,CACf,IAAI,KAAK,CAAC,CACV,eAAe,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CACxC,oBAAoB,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAC,SAAS,CAAC,EACxF,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { requireNativeModule, requireNativeView } from 'expo';\nimport * as React from 'react';\nimport { findNodeHandle } from 'react-native';\n\nimport { ExpoPdfMarkupViewProps, TextInputRequest } from './ExpoPdfMarkup.types';\n\ntype NativeViewProps = Omit<ExpoPdfMarkupViewProps, 'onTextInputRequested'> & {\n useJsTextDialog?: boolean;\n onTextInputRequested?: (event: { nativeEvent: TextInputRequest }) => void;\n};\n\nconst NativeView = requireNativeView('ExpoPdfMarkup') as React.ForwardRefExoticComponent<\n NativeViewProps & React.RefAttributes<unknown>\n>;\n\nconst NativeModule = requireNativeModule('ExpoPdfMarkup');\n\nexport default function ExpoPdfMarkupView({\n onTextInputRequested,\n ...props\n}: ExpoPdfMarkupViewProps) {\n const nativeRef = React.useRef<unknown>(null);\n\n const handleNativeTextInputRequested = React.useCallback(\n async (event: { nativeEvent: TextInputRequest }) => {\n if (!onTextInputRequested) return;\n const tag = findNodeHandle(nativeRef.current as Parameters<typeof findNodeHandle>[0]);\n if (tag == null) return;\n const text = await onTextInputRequested(event.nativeEvent);\n await NativeModule.provideTextInput(tag, text ?? null);\n },\n [onTextInputRequested]\n );\n\n return (\n <NativeView\n ref={nativeRef}\n {...props}\n useJsTextDialog={!!onTextInputRequested}\n onTextInputRequested={onTextInputRequested ? handleNativeTextInputRequested : undefined}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"ExpoPdfMarkupView.js","sourceRoot":"","sources":["../src/ExpoPdfMarkupView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAS9C,MAAM,UAAU,GAAG,iBAAiB,CAAC,eAAe,CAEnD,CAAC;AAEF,MAAM,YAAY,GAAG,mBAAmB,CAAC,eAAe,CAAC,CAAC;AAE1D,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,oBAAoB,EACpB,GAAG,KAAK,EACe;IACvB,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAU,IAAI,CAAC,CAAC;IAE9C,MAAM,8BAA8B,GAAG,KAAK,CAAC,WAAW,CACtD,KAAK,EAAE,KAAwC,EAAE,EAAE;QACjD,IAAI,CAAC,oBAAoB;YAAE,OAAO;QAClC,MAAM,GAAG,GAAG,cAAc,CAAC,SAAS,CAAC,OAA+C,CAAC,CAAC;QACtF,IAAI,GAAG,IAAI,IAAI;YAAE,OAAO;QACxB,MAAM,IAAI,GAAG,MAAM,oBAAoB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC3D,MAAM,YAAY,CAAC,gBAAgB,CAAC,GAAG,EAAE,IAAI,IAAI,IAAI,CAAC,CAAC;IACzD,CAAC,EACD,CAAC,oBAAoB,CAAC,CACvB,CAAC;IAEF,OAAO,CACL,KAAC,UAAU,IACT,GAAG,EAAE,SAAS,KACV,KAAK,EACT,eAAe,EAAE,CAAC,CAAC,oBAAoB,EACvC,oBAAoB,EAAE,oBAAoB,CAAC,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAC,SAAS,GACvF,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { requireNativeModule, requireNativeView } from 'expo';\nimport * as React from 'react';\nimport { findNodeHandle } from 'react-native';\n\nimport type { ExpoPdfMarkupViewProps, TextInputRequest } from './ExpoPdfMarkup.types';\n\ntype NativeViewProps = Omit<ExpoPdfMarkupViewProps, 'onTextInputRequested'> & {\n useJsTextDialog?: boolean;\n onTextInputRequested?: (event: { nativeEvent: TextInputRequest }) => void;\n};\n\nconst NativeView = requireNativeView('ExpoPdfMarkup') as React.ForwardRefExoticComponent<\n NativeViewProps & React.RefAttributes<unknown>\n>;\n\nconst NativeModule = requireNativeModule('ExpoPdfMarkup');\n\nexport default function ExpoPdfMarkupView({\n onTextInputRequested,\n ...props\n}: ExpoPdfMarkupViewProps) {\n const nativeRef = React.useRef<unknown>(null);\n\n const handleNativeTextInputRequested = React.useCallback(\n async (event: { nativeEvent: TextInputRequest }) => {\n if (!onTextInputRequested) return;\n const tag = findNodeHandle(nativeRef.current as Parameters<typeof findNodeHandle>[0]);\n if (tag == null) return;\n const text = await onTextInputRequested(event.nativeEvent);\n await NativeModule.provideTextInput(tag, text ?? null);\n },\n [onTextInputRequested]\n );\n\n return (\n <NativeView\n ref={nativeRef}\n {...props}\n useJsTextDialog={!!onTextInputRequested}\n onTextInputRequested={onTextInputRequested ? handleNativeTextInputRequested : undefined}\n />\n );\n}\n"]}
@@ -2,5 +2,7 @@ import * as React from 'react';
2
2
  import type { ExpoPdfMarkupViewProps } from './ExpoPdfMarkup.types';
3
3
  /** Allow consumers to override the pdfjs worker URL before mounting the view. */
4
4
  export declare function setPdfJsWorkerSrc(url: string): void;
5
+ /** Allow consumers to override the pdfjs WebAssembly directory URL before mounting the view. */
6
+ export declare function setPdfJsWasmUrl(url: string): void;
5
7
  export default function ExpoPdfMarkupView(props: ExpoPdfMarkupViewProps): React.JSX.Element;
6
8
  //# sourceMappingURL=ExpoPdfMarkupView.web.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoPdfMarkupView.web.d.ts","sourceRoot":"","sources":["../src/ExpoPdfMarkupView.web.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAGV,sBAAsB,EAGvB,MAAM,uBAAuB,CAAC;AAuB/B,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEnD;AAoYD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,qBAqWtE"}
1
+ {"version":3,"file":"ExpoPdfMarkupView.web.d.ts","sourceRoot":"","sources":["../src/ExpoPdfMarkupView.web.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAGV,sBAAsB,EAGvB,MAAM,uBAAuB,CAAC;AAuB/B,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEnD;AASD,gGAAgG;AAChG,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEjD;AAqYD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,qBAqWtE"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
2
  import * as pdfjs from 'pdfjs-dist';
2
3
  import * as React from 'react';
3
4
  import { clampAnnotationTranslation, canvasRectToPdfBounds, canvasToPdf, drawAnnotationsOnCanvas, hitTestAnnotation, newAnnotationId, parseAnnotations, serializeAnnotations, translateAnnotation, } from './web/annotationUtils';
@@ -13,6 +14,16 @@ if (!pdfjs.GlobalWorkerOptions.workerSrc) {
13
14
  export function setPdfJsWorkerSrc(url) {
14
15
  pdfjs.GlobalWorkerOptions.workerSrc = url;
15
16
  }
17
+ // pdfjs-dist v6 decodes image data (JBIG2/CCITT fax, JPEG2000, ICC) in
18
+ // WebAssembly and must be told where the .wasm files live. withPdfMarkup() in
19
+ // metro.js copies them to public/wasm/. Relative URL so the worker resolves it
20
+ // regardless of the sub-path the app is hosted at. Override with
21
+ // setPdfJsWasmUrl() for a different bundler or CDN.
22
+ let wasmUrl = './wasm/';
23
+ /** Allow consumers to override the pdfjs WebAssembly directory URL before mounting the view. */
24
+ export function setPdfJsWasmUrl(url) {
25
+ wasmUrl = url;
26
+ }
16
27
  // ---------------------------------------------------------------------------
17
28
  // Zoom constants
18
29
  // ---------------------------------------------------------------------------
@@ -57,7 +68,7 @@ function PageView({ doc, pageIndex, meta, annotations, annotationMode, annotatio
57
68
  if (!ctx)
58
69
  return;
59
70
  const viewport = page.getViewport({ scale: meta.scale * dpr });
60
- const task = page.render({ canvasContext: ctx, viewport });
71
+ const task = page.render({ canvas: null, canvasContext: ctx, viewport });
61
72
  renderTaskRef.current = task;
62
73
  try {
63
74
  await task.promise;
@@ -98,6 +109,8 @@ function PageView({ doc, pageIndex, meta, annotations, annotationMode, annotatio
98
109
  ctx.beginPath();
99
110
  for (let i = 0; i < liveInkPoints.length; i++) {
100
111
  const pt = liveInkPoints[i];
112
+ if (!pt)
113
+ continue;
101
114
  if (i === 0)
102
115
  ctx.moveTo(pt.x, pt.y);
103
116
  else
@@ -312,25 +325,22 @@ function PageView({ doc, pageIndex, meta, annotations, annotationMode, annotatio
312
325
  : annotationMode === 'stamp'
313
326
  ? 'copy'
314
327
  : 'crosshair';
315
- return (<div ref={containerRef} style={{ position: 'relative', width: cssWidth, height: cssHeight, margin: '0 auto' }}>
316
- <canvas ref={pdfCanvasRef} style={{
317
- position: 'absolute',
318
- top: 0,
319
- left: 0,
320
- width: cssWidth,
321
- height: cssHeight,
322
- pointerEvents: 'none',
323
- }}/>
324
- <canvas ref={annotCanvasRef} style={{
325
- position: 'absolute',
326
- top: 0,
327
- left: 0,
328
- width: cssWidth,
329
- height: cssHeight,
330
- cursor,
331
- pointerEvents,
332
- }} onPointerDown={handlePointerDown} onPointerMove={handlePointerMove} onPointerUp={handlePointerUp}/>
333
- </div>);
328
+ return (_jsxs("div", { ref: containerRef, style: { position: 'relative', width: cssWidth, height: cssHeight, margin: '0 auto' }, children: [_jsx("canvas", { ref: pdfCanvasRef, style: {
329
+ position: 'absolute',
330
+ top: 0,
331
+ left: 0,
332
+ width: cssWidth,
333
+ height: cssHeight,
334
+ pointerEvents: 'none',
335
+ } }), _jsx("canvas", { ref: annotCanvasRef, style: {
336
+ position: 'absolute',
337
+ top: 0,
338
+ left: 0,
339
+ width: cssWidth,
340
+ height: cssHeight,
341
+ cursor,
342
+ pointerEvents,
343
+ }, onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, onPointerUp: handlePointerUp })] }));
334
344
  }
335
345
  // ---------------------------------------------------------------------------
336
346
  // Main component
@@ -448,10 +458,10 @@ export default function ExpoPdfMarkupView(props) {
448
458
  loadingSourceRef.current = source;
449
459
  async function load() {
450
460
  try {
451
- const task = pdfjs.getDocument(source);
461
+ const task = pdfjs.getDocument({ url: source, wasmUrl });
452
462
  const loadedDoc = await task.promise;
453
463
  if (cancelled || loadingSourceRef.current !== source) {
454
- loadedDoc.destroy();
464
+ loadedDoc.loadingTask.destroy();
455
465
  return;
456
466
  }
457
467
  const metas = [];
@@ -460,7 +470,7 @@ export default function ExpoPdfMarkupView(props) {
460
470
  const pg = await loadedDoc.getPage(i);
461
471
  if (cancelled) {
462
472
  pg.cleanup();
463
- loadedDoc.destroy();
473
+ loadedDoc.loadingTask.destroy();
464
474
  return;
465
475
  }
466
476
  const viewport = pg.getViewport({ scale: 1 });
@@ -475,7 +485,7 @@ export default function ExpoPdfMarkupView(props) {
475
485
  });
476
486
  pg.cleanup();
477
487
  }
478
- docRef.current?.destroy();
488
+ docRef.current?.loadingTask.destroy();
479
489
  docRef.current = loadedDoc;
480
490
  setDoc(loadedDoc);
481
491
  setPageMetas(metas);
@@ -598,22 +608,15 @@ export default function ExpoPdfMarkupView(props) {
598
608
  onTextInputRequested,
599
609
  ]);
600
610
  const styleObj = style;
601
- return (<div ref={scrollContainerRef} style={{
611
+ return (_jsx("div", { ref: scrollContainerRef, style: {
602
612
  overflowY: 'scroll',
603
613
  overflowX: 'auto',
604
614
  backgroundColor,
605
615
  height: '100%',
606
616
  ...styleObj,
607
- }}>
608
- <div style={{ zoom: zoomLevel }}>
609
- {doc &&
610
- pageMetas.map((meta, i) => (<React.Fragment key={i}>
611
- <PageView doc={doc} pageIndex={i} meta={meta} annotations={annotations} annotationMode={annotationMode} annotationColor={annotationColor} annotationLineWidth={annotationLineWidth} stampText={stampText} stampSize={stampSize} zoomLevel={zoomLevel} onAnnotationAdded={handleAnnotationAdded} onAnnotationRemoved={handleAnnotationRemoved} onAnnotationUpdated={handleAnnotationUpdated} onTextInputRequested={handleTextInputRequested} containerRef={(el) => {
612
- pageContainerRefs.current[i] = el;
613
- }}/>
614
- {i < pageMetas.length - 1 && <div style={{ height: 8 }} aria-hidden/>}
615
- </React.Fragment>))}
616
- </div>
617
- </div>);
617
+ }, children: _jsx("div", { style: { zoom: zoomLevel }, children: doc &&
618
+ pageMetas.map((meta, i) => (_jsxs(React.Fragment, { children: [_jsx(PageView, { doc: doc, pageIndex: i, meta: meta, annotations: annotations, annotationMode: annotationMode, annotationColor: annotationColor, annotationLineWidth: annotationLineWidth, stampText: stampText, stampSize: stampSize, zoomLevel: zoomLevel, onAnnotationAdded: handleAnnotationAdded, onAnnotationRemoved: handleAnnotationRemoved, onAnnotationUpdated: handleAnnotationUpdated, onTextInputRequested: handleTextInputRequested, containerRef: (el) => {
619
+ pageContainerRefs.current[i] = el;
620
+ } }), i < pageMetas.length - 1 && _jsx("div", { style: { height: 8 }, "aria-hidden": true })] }, i))) }) }));
618
621
  }
619
622
  //# sourceMappingURL=ExpoPdfMarkupView.web.js.map