@tobyt/expo-pdf-markup 1.1.1 → 1.1.3

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 (69) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +9 -6
  3. package/build/ExpoPdfMarkup.types.d.ts.map +1 -1
  4. package/build/ExpoPdfMarkup.types.js.map +1 -1
  5. package/build/ExpoPdfMarkupView.d.ts +1 -1
  6. package/build/ExpoPdfMarkupView.d.ts.map +1 -1
  7. package/build/ExpoPdfMarkupView.js +2 -1
  8. package/build/ExpoPdfMarkupView.js.map +1 -1
  9. package/build/ExpoPdfMarkupView.web.d.ts +2 -0
  10. package/build/ExpoPdfMarkupView.web.d.ts.map +1 -1
  11. package/build/ExpoPdfMarkupView.web.js +39 -36
  12. package/build/ExpoPdfMarkupView.web.js.map +1 -1
  13. package/build/index.d.ts +1 -1
  14. package/build/index.d.ts.map +1 -1
  15. package/build/index.js +1 -1
  16. package/build/index.js.map +1 -1
  17. package/build/pdfjs.d.ts +1 -0
  18. package/build/pdfjs.d.ts.map +1 -1
  19. package/build/pdfjs.js +3 -0
  20. package/build/pdfjs.js.map +1 -1
  21. package/build/pdfjs.web.d.ts +1 -1
  22. package/build/pdfjs.web.d.ts.map +1 -1
  23. package/build/pdfjs.web.js +1 -1
  24. package/build/pdfjs.web.js.map +1 -1
  25. package/build/web/annotationUtils.d.ts.map +1 -1
  26. package/build/web/annotationUtils.js +13 -5
  27. package/build/web/annotationUtils.js.map +1 -1
  28. package/docs/.nojekyll +1 -0
  29. package/docs/assets/hierarchy.js +1 -0
  30. package/docs/assets/highlight.css +113 -0
  31. package/docs/assets/icons.js +18 -0
  32. package/docs/assets/icons.svg +1 -0
  33. package/docs/assets/main.js +60 -0
  34. package/docs/assets/navigation.js +1 -0
  35. package/docs/assets/search.js +1 -0
  36. package/docs/assets/style.css +1648 -0
  37. package/docs/functions/ExpoPdfMarkupView.html +42 -0
  38. package/docs/functions/setPdfJsWorkerSrc.html +42 -0
  39. package/docs/hierarchy.html +29 -0
  40. package/docs/index.html +148 -0
  41. package/docs/modules.html +40 -0
  42. package/docs/types/Annotation.html +33 -0
  43. package/docs/types/AnnotationBounds.html +73 -0
  44. package/docs/types/AnnotationMode.html +33 -0
  45. package/docs/types/AnnotationPoint.html +61 -0
  46. package/docs/types/AnnotationsData.html +61 -0
  47. package/docs/types/ExpoPdfMarkupViewProps.html +184 -0
  48. package/docs/types/HighlightAnnotation.html +91 -0
  49. package/docs/types/InkAnnotation.html +91 -0
  50. package/docs/types/StampAnnotation.html +95 -0
  51. package/docs/types/StampDefinition.html +72 -0
  52. package/docs/types/TextAnnotation.html +110 -0
  53. package/docs/types/TextInputRequest.html +73 -0
  54. package/docs/types/UnderlineAnnotation.html +85 -0
  55. package/ios/AnnotationSerializer.swift +6 -34
  56. package/ios/ExpoPdfMarkupView+Ink.swift +2 -10
  57. package/ios/ExpoPdfMarkupView+Move.swift +4 -3
  58. package/ios/ExpoPdfMarkupView.swift +4 -3
  59. package/ios/InkPDFAnnotation.swift +45 -0
  60. package/ios/Tests/AnnotationSerializerTests.swift +26 -0
  61. package/metro.js +47 -20
  62. package/package.json +8 -8
  63. package/src/ExpoPdfMarkup.types.ts +2 -13
  64. package/src/ExpoPdfMarkupView.tsx +1 -1
  65. package/src/ExpoPdfMarkupView.web.tsx +26 -13
  66. package/src/index.ts +1 -1
  67. package/src/pdfjs.ts +4 -0
  68. package/src/pdfjs.web.ts +1 -1
  69. package/src/web/annotationUtils.ts +11 -5
@@ -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
  }