@papyrus-sdk/engine-native 0.2.22-beta.8 → 0.2.22-beta.9.epub.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 (274) hide show
  1. package/android/build.gradle +0 -1
  2. package/android/src/main/cpp/CMakeLists.txt +0 -137
  3. package/android/src/main/java/com/papyrus/engine/PapyrusNativeEngineModule.java +35 -305
  4. package/android/src/main/java/com/papyrus/engine/PapyrusPackage.java +1 -3
  5. package/android/src/main/java/com/papyrus/engine/PapyrusPdfViewerView.java +5 -195
  6. package/android/src/main/java/com/papyrus/engine/PapyrusPdfViewerViewManager.java +1 -20
  7. package/dist/index.d.mts +4 -608
  8. package/dist/index.d.ts +4 -608
  9. package/dist/index.js +8 -463
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +7 -456
  12. package/dist/index.mjs.map +1 -1
  13. package/ios/PapyrusEngineStore.h +0 -3
  14. package/ios/PapyrusEngineStore.m +6 -32
  15. package/ios/PapyrusNativeEngine.m +5 -684
  16. package/ios/PapyrusNativeEngine.podspec +15 -0
  17. package/ios/PapyrusPageView.m +11 -38
  18. package/package.json +4 -6
  19. package/react-native.config.js +1 -1
  20. package/PapyrusNativeEngine.podspec +0 -45
  21. package/android/src/main/cpp/PapyrusComicArchiveJni.cpp +0 -68
  22. package/android/src/main/cpp/PapyrusComicArchiveTest.cpp +0 -55
  23. package/android/src/main/java/com/papyrus/engine/PapyrusComicArchiveNative.java +0 -14
  24. package/android/src/main/java/com/papyrus/engine/PapyrusComicDocumentView.java +0 -491
  25. package/android/src/main/java/com/papyrus/engine/PapyrusComicDocumentViewManager.java +0 -32
  26. package/android/src/main/java/com/papyrus/engine/PapyrusComicPageLayout.java +0 -38
  27. package/android/src/main/java/com/papyrus/engine/PapyrusNativeTextModel.java +0 -195
  28. package/android/src/main/java/com/papyrus/engine/PapyrusSelectionMenuIcon.java +0 -48
  29. package/android/src/main/java/com/papyrus/engine/PapyrusTextAnnotationModel.java +0 -22
  30. package/android/src/main/java/com/papyrus/engine/PapyrusTextDocumentView.java +0 -661
  31. package/android/src/main/java/com/papyrus/engine/PapyrusTextDocumentViewManager.java +0 -49
  32. package/android/src/main/java/com/papyrus/engine/PapyrusTextStore.java +0 -43
  33. package/ios/PapyrusComicDocumentView.h +0 -21
  34. package/ios/PapyrusComicDocumentView.m +0 -547
  35. package/ios/PapyrusComicDocumentViewManager.m +0 -23
  36. package/ios/PapyrusPageRotationRegistry.h +0 -29
  37. package/ios/PapyrusPageRotationRegistry.m +0 -179
  38. package/ios/PapyrusPdfDocumentView.h +0 -55
  39. package/ios/PapyrusPdfDocumentView.m +0 -2338
  40. package/ios/PapyrusPdfDocumentViewManager.m +0 -61
  41. package/ios/PapyrusPdfPageTheme.h +0 -15
  42. package/ios/PapyrusPdfPageTheme.m +0 -218
  43. package/ios/PapyrusSelectionMenu.h +0 -27
  44. package/ios/PapyrusTextAnnotationRange.h +0 -2
  45. package/ios/PapyrusTextAnnotationRange.m +0 -29
  46. package/ios/PapyrusTextDocumentView.h +0 -32
  47. package/ios/PapyrusTextDocumentView.m +0 -518
  48. package/ios/PapyrusTextDocumentViewManager.m +0 -34
  49. package/ios/PapyrusTextStore.h +0 -13
  50. package/ios/PapyrusTextStore.m +0 -73
  51. package/third_party_licenses/BLAKE2-NOTICE.txt +0 -11
  52. package/third_party_licenses/libarchive-COPYING +0 -65
  53. package/vendor/libarchive/PapyrusComicArchive.cpp +0 -376
  54. package/vendor/libarchive/PapyrusComicArchive.h +0 -30
  55. package/vendor/libarchive/README.papyrus.md +0 -15
  56. package/vendor/libarchive/android.h +0 -192
  57. package/vendor/libarchive/config/PapyrusArchiveConfig.h +0 -71
  58. package/vendor/libarchive/libarchive/CMakeLists.txt +0 -293
  59. package/vendor/libarchive/libarchive/android_lf.h +0 -36
  60. package/vendor/libarchive/libarchive/archive.h +0 -1266
  61. package/vendor/libarchive/libarchive/archive_acl.c +0 -2025
  62. package/vendor/libarchive/libarchive/archive_acl_private.h +0 -85
  63. package/vendor/libarchive/libarchive/archive_blake2.h +0 -197
  64. package/vendor/libarchive/libarchive/archive_blake2_impl.h +0 -161
  65. package/vendor/libarchive/libarchive/archive_blake2s_ref.c +0 -369
  66. package/vendor/libarchive/libarchive/archive_blake2sp_ref.c +0 -361
  67. package/vendor/libarchive/libarchive/archive_check_magic.c +0 -183
  68. package/vendor/libarchive/libarchive/archive_cmdline.c +0 -211
  69. package/vendor/libarchive/libarchive/archive_cmdline_private.h +0 -45
  70. package/vendor/libarchive/libarchive/archive_crc32.h +0 -123
  71. package/vendor/libarchive/libarchive/archive_cryptor.c +0 -534
  72. package/vendor/libarchive/libarchive/archive_cryptor_private.h +0 -199
  73. package/vendor/libarchive/libarchive/archive_digest.c +0 -1584
  74. package/vendor/libarchive/libarchive/archive_digest_private.h +0 -431
  75. package/vendor/libarchive/libarchive/archive_disk_acl_darwin.c +0 -558
  76. package/vendor/libarchive/libarchive/archive_disk_acl_freebsd.c +0 -712
  77. package/vendor/libarchive/libarchive/archive_disk_acl_linux.c +0 -760
  78. package/vendor/libarchive/libarchive/archive_disk_acl_sunos.c +0 -824
  79. package/vendor/libarchive/libarchive/archive_endian.h +0 -234
  80. package/vendor/libarchive/libarchive/archive_entry.3 +0 -147
  81. package/vendor/libarchive/libarchive/archive_entry.c +0 -2297
  82. package/vendor/libarchive/libarchive/archive_entry.h +0 -763
  83. package/vendor/libarchive/libarchive/archive_entry_acl.3 +0 -458
  84. package/vendor/libarchive/libarchive/archive_entry_copy_bhfi.c +0 -55
  85. package/vendor/libarchive/libarchive/archive_entry_copy_stat.c +0 -82
  86. package/vendor/libarchive/libarchive/archive_entry_link_resolver.c +0 -472
  87. package/vendor/libarchive/libarchive/archive_entry_linkify.3 +0 -224
  88. package/vendor/libarchive/libarchive/archive_entry_locale.h +0 -90
  89. package/vendor/libarchive/libarchive/archive_entry_misc.3 +0 -63
  90. package/vendor/libarchive/libarchive/archive_entry_paths.3 +0 -153
  91. package/vendor/libarchive/libarchive/archive_entry_perms.3 +0 -210
  92. package/vendor/libarchive/libarchive/archive_entry_private.h +0 -205
  93. package/vendor/libarchive/libarchive/archive_entry_sparse.c +0 -156
  94. package/vendor/libarchive/libarchive/archive_entry_stat.3 +0 -274
  95. package/vendor/libarchive/libarchive/archive_entry_stat.c +0 -121
  96. package/vendor/libarchive/libarchive/archive_entry_strmode.c +0 -69
  97. package/vendor/libarchive/libarchive/archive_entry_time.3 +0 -127
  98. package/vendor/libarchive/libarchive/archive_entry_xattr.c +0 -155
  99. package/vendor/libarchive/libarchive/archive_hmac.c +0 -345
  100. package/vendor/libarchive/libarchive/archive_hmac_private.h +0 -119
  101. package/vendor/libarchive/libarchive/archive_integer.h +0 -267
  102. package/vendor/libarchive/libarchive/archive_match.c +0 -1869
  103. package/vendor/libarchive/libarchive/archive_openssl_evp_private.h +0 -54
  104. package/vendor/libarchive/libarchive/archive_openssl_hmac_private.h +0 -54
  105. package/vendor/libarchive/libarchive/archive_options.c +0 -219
  106. package/vendor/libarchive/libarchive/archive_options_private.h +0 -49
  107. package/vendor/libarchive/libarchive/archive_pack_dev.c +0 -330
  108. package/vendor/libarchive/libarchive/archive_pack_dev.h +0 -49
  109. package/vendor/libarchive/libarchive/archive_parse_date.c +0 -1173
  110. package/vendor/libarchive/libarchive/archive_pathmatch.c +0 -480
  111. package/vendor/libarchive/libarchive/archive_pathmatch.h +0 -50
  112. package/vendor/libarchive/libarchive/archive_platform.h +0 -213
  113. package/vendor/libarchive/libarchive/archive_platform_acl.h +0 -53
  114. package/vendor/libarchive/libarchive/archive_platform_stat.h +0 -45
  115. package/vendor/libarchive/libarchive/archive_platform_xattr.h +0 -45
  116. package/vendor/libarchive/libarchive/archive_ppmd7.c +0 -1173
  117. package/vendor/libarchive/libarchive/archive_ppmd7_private.h +0 -119
  118. package/vendor/libarchive/libarchive/archive_ppmd8.c +0 -1293
  119. package/vendor/libarchive/libarchive/archive_ppmd8_private.h +0 -123
  120. package/vendor/libarchive/libarchive/archive_ppmd_private.h +0 -159
  121. package/vendor/libarchive/libarchive/archive_private.h +0 -209
  122. package/vendor/libarchive/libarchive/archive_random.c +0 -274
  123. package/vendor/libarchive/libarchive/archive_random_private.h +0 -36
  124. package/vendor/libarchive/libarchive/archive_rb.c +0 -709
  125. package/vendor/libarchive/libarchive/archive_rb.h +0 -113
  126. package/vendor/libarchive/libarchive/archive_read.3 +0 -250
  127. package/vendor/libarchive/libarchive/archive_read.c +0 -1814
  128. package/vendor/libarchive/libarchive/archive_read_add_passphrase.3 +0 -72
  129. package/vendor/libarchive/libarchive/archive_read_add_passphrase.c +0 -189
  130. package/vendor/libarchive/libarchive/archive_read_append_filter.c +0 -209
  131. package/vendor/libarchive/libarchive/archive_read_data.3 +0 -128
  132. package/vendor/libarchive/libarchive/archive_read_data_into_fd.c +0 -207
  133. package/vendor/libarchive/libarchive/archive_read_disk.3 +0 -422
  134. package/vendor/libarchive/libarchive/archive_read_disk_entry_from_file.c +0 -1086
  135. package/vendor/libarchive/libarchive/archive_read_disk_posix.c +0 -2639
  136. package/vendor/libarchive/libarchive/archive_read_disk_private.h +0 -97
  137. package/vendor/libarchive/libarchive/archive_read_disk_set_standard_lookup.c +0 -315
  138. package/vendor/libarchive/libarchive/archive_read_disk_windows.c +0 -2603
  139. package/vendor/libarchive/libarchive/archive_read_extract.3 +0 -135
  140. package/vendor/libarchive/libarchive/archive_read_extract.c +0 -59
  141. package/vendor/libarchive/libarchive/archive_read_extract2.c +0 -154
  142. package/vendor/libarchive/libarchive/archive_read_filter.3 +0 -163
  143. package/vendor/libarchive/libarchive/archive_read_format.3 +0 -190
  144. package/vendor/libarchive/libarchive/archive_read_free.3 +0 -91
  145. package/vendor/libarchive/libarchive/archive_read_header.3 +0 -89
  146. package/vendor/libarchive/libarchive/archive_read_new.3 +0 -57
  147. package/vendor/libarchive/libarchive/archive_read_open.3 +0 -247
  148. package/vendor/libarchive/libarchive/archive_read_open_fd.c +0 -236
  149. package/vendor/libarchive/libarchive/archive_read_open_file.c +0 -257
  150. package/vendor/libarchive/libarchive/archive_read_open_filename.c +0 -652
  151. package/vendor/libarchive/libarchive/archive_read_open_memory.c +0 -188
  152. package/vendor/libarchive/libarchive/archive_read_private.h +0 -274
  153. package/vendor/libarchive/libarchive/archive_read_set_format.c +0 -116
  154. package/vendor/libarchive/libarchive/archive_read_set_options.3 +0 -290
  155. package/vendor/libarchive/libarchive/archive_read_set_options.c +0 -132
  156. package/vendor/libarchive/libarchive/archive_read_support_filter_all.c +0 -84
  157. package/vendor/libarchive/libarchive/archive_read_support_filter_by_code.c +0 -68
  158. package/vendor/libarchive/libarchive/archive_read_support_filter_bzip2.c +0 -360
  159. package/vendor/libarchive/libarchive/archive_read_support_filter_compress.c +0 -457
  160. package/vendor/libarchive/libarchive/archive_read_support_filter_grzip.c +0 -108
  161. package/vendor/libarchive/libarchive/archive_read_support_filter_gzip.c +0 -538
  162. package/vendor/libarchive/libarchive/archive_read_support_filter_lrzip.c +0 -119
  163. package/vendor/libarchive/libarchive/archive_read_support_filter_lz4.c +0 -829
  164. package/vendor/libarchive/libarchive/archive_read_support_filter_lzop.c +0 -493
  165. package/vendor/libarchive/libarchive/archive_read_support_filter_none.c +0 -51
  166. package/vendor/libarchive/libarchive/archive_read_support_filter_program.c +0 -497
  167. package/vendor/libarchive/libarchive/archive_read_support_filter_rpm.c +0 -249
  168. package/vendor/libarchive/libarchive/archive_read_support_filter_uu.c +0 -739
  169. package/vendor/libarchive/libarchive/archive_read_support_filter_xz.c +0 -792
  170. package/vendor/libarchive/libarchive/archive_read_support_filter_zstd.c +0 -356
  171. package/vendor/libarchive/libarchive/archive_read_support_format_7zip.c +0 -4650
  172. package/vendor/libarchive/libarchive/archive_read_support_format_all.c +0 -88
  173. package/vendor/libarchive/libarchive/archive_read_support_format_ar.c +0 -597
  174. package/vendor/libarchive/libarchive/archive_read_support_format_by_code.c +0 -76
  175. package/vendor/libarchive/libarchive/archive_read_support_format_cab.c +0 -3410
  176. package/vendor/libarchive/libarchive/archive_read_support_format_cpio.c +0 -1152
  177. package/vendor/libarchive/libarchive/archive_read_support_format_empty.c +0 -95
  178. package/vendor/libarchive/libarchive/archive_read_support_format_iso9660.c +0 -3516
  179. package/vendor/libarchive/libarchive/archive_read_support_format_lha.c +0 -2931
  180. package/vendor/libarchive/libarchive/archive_read_support_format_mtree.c +0 -2113
  181. package/vendor/libarchive/libarchive/archive_read_support_format_rar.c +0 -3932
  182. package/vendor/libarchive/libarchive/archive_read_support_format_rar5.c +0 -4501
  183. package/vendor/libarchive/libarchive/archive_read_support_format_raw.c +0 -194
  184. package/vendor/libarchive/libarchive/archive_read_support_format_tar.c +0 -3785
  185. package/vendor/libarchive/libarchive/archive_read_support_format_warc.c +0 -875
  186. package/vendor/libarchive/libarchive/archive_read_support_format_xar.c +0 -3770
  187. package/vendor/libarchive/libarchive/archive_read_support_format_zip.c +0 -4710
  188. package/vendor/libarchive/libarchive/archive_string.c +0 -4391
  189. package/vendor/libarchive/libarchive/archive_string.h +0 -244
  190. package/vendor/libarchive/libarchive/archive_string_composition.h +0 -2289
  191. package/vendor/libarchive/libarchive/archive_string_sprintf.c +0 -200
  192. package/vendor/libarchive/libarchive/archive_time.c +0 -168
  193. package/vendor/libarchive/libarchive/archive_time_private.h +0 -47
  194. package/vendor/libarchive/libarchive/archive_util.3 +0 -239
  195. package/vendor/libarchive/libarchive/archive_util.c +0 -668
  196. package/vendor/libarchive/libarchive/archive_version_details.c +0 -516
  197. package/vendor/libarchive/libarchive/archive_virtual.c +0 -162
  198. package/vendor/libarchive/libarchive/archive_windows.c +0 -1035
  199. package/vendor/libarchive/libarchive/archive_windows.h +0 -332
  200. package/vendor/libarchive/libarchive/archive_write.3 +0 -266
  201. package/vendor/libarchive/libarchive/archive_write.c +0 -896
  202. package/vendor/libarchive/libarchive/archive_write_add_filter.c +0 -71
  203. package/vendor/libarchive/libarchive/archive_write_add_filter_b64encode.c +0 -329
  204. package/vendor/libarchive/libarchive/archive_write_add_filter_by_name.c +0 -76
  205. package/vendor/libarchive/libarchive/archive_write_add_filter_bzip2.c +0 -411
  206. package/vendor/libarchive/libarchive/archive_write_add_filter_compress.c +0 -459
  207. package/vendor/libarchive/libarchive/archive_write_add_filter_grzip.c +0 -143
  208. package/vendor/libarchive/libarchive/archive_write_add_filter_gzip.c +0 -493
  209. package/vendor/libarchive/libarchive/archive_write_add_filter_lrzip.c +0 -214
  210. package/vendor/libarchive/libarchive/archive_write_add_filter_lz4.c +0 -710
  211. package/vendor/libarchive/libarchive/archive_write_add_filter_lzop.c +0 -500
  212. package/vendor/libarchive/libarchive/archive_write_add_filter_none.c +0 -42
  213. package/vendor/libarchive/libarchive/archive_write_add_filter_program.c +0 -398
  214. package/vendor/libarchive/libarchive/archive_write_add_filter_uuencode.c +0 -320
  215. package/vendor/libarchive/libarchive/archive_write_add_filter_xz.c +0 -547
  216. package/vendor/libarchive/libarchive/archive_write_add_filter_zstd.c +0 -608
  217. package/vendor/libarchive/libarchive/archive_write_blocksize.3 +0 -112
  218. package/vendor/libarchive/libarchive/archive_write_data.3 +0 -88
  219. package/vendor/libarchive/libarchive/archive_write_disk.3 +0 -360
  220. package/vendor/libarchive/libarchive/archive_write_disk_posix.c +0 -4789
  221. package/vendor/libarchive/libarchive/archive_write_disk_private.h +0 -43
  222. package/vendor/libarchive/libarchive/archive_write_disk_set_standard_lookup.c +0 -265
  223. package/vendor/libarchive/libarchive/archive_write_disk_windows.c +0 -2952
  224. package/vendor/libarchive/libarchive/archive_write_filter.3 +0 -140
  225. package/vendor/libarchive/libarchive/archive_write_finish_entry.3 +0 -77
  226. package/vendor/libarchive/libarchive/archive_write_format.3 +0 -187
  227. package/vendor/libarchive/libarchive/archive_write_free.3 +0 -94
  228. package/vendor/libarchive/libarchive/archive_write_header.3 +0 -71
  229. package/vendor/libarchive/libarchive/archive_write_new.3 +0 -56
  230. package/vendor/libarchive/libarchive/archive_write_open.3 +0 -270
  231. package/vendor/libarchive/libarchive/archive_write_open_fd.c +0 -141
  232. package/vendor/libarchive/libarchive/archive_write_open_file.c +0 -102
  233. package/vendor/libarchive/libarchive/archive_write_open_filename.c +0 -272
  234. package/vendor/libarchive/libarchive/archive_write_open_memory.c +0 -110
  235. package/vendor/libarchive/libarchive/archive_write_private.h +0 -166
  236. package/vendor/libarchive/libarchive/archive_write_set_format.c +0 -124
  237. package/vendor/libarchive/libarchive/archive_write_set_format_7zip.c +0 -2571
  238. package/vendor/libarchive/libarchive/archive_write_set_format_ar.c +0 -540
  239. package/vendor/libarchive/libarchive/archive_write_set_format_by_name.c +0 -93
  240. package/vendor/libarchive/libarchive/archive_write_set_format_cpio.c +0 -11
  241. package/vendor/libarchive/libarchive/archive_write_set_format_cpio_binary.c +0 -618
  242. package/vendor/libarchive/libarchive/archive_write_set_format_cpio_newc.c +0 -457
  243. package/vendor/libarchive/libarchive/archive_write_set_format_cpio_odc.c +0 -508
  244. package/vendor/libarchive/libarchive/archive_write_set_format_filter_by_ext.c +0 -141
  245. package/vendor/libarchive/libarchive/archive_write_set_format_gnutar.c +0 -790
  246. package/vendor/libarchive/libarchive/archive_write_set_format_iso9660.c +0 -8216
  247. package/vendor/libarchive/libarchive/archive_write_set_format_mtree.c +0 -2307
  248. package/vendor/libarchive/libarchive/archive_write_set_format_pax.c +0 -2249
  249. package/vendor/libarchive/libarchive/archive_write_set_format_private.h +0 -40
  250. package/vendor/libarchive/libarchive/archive_write_set_format_raw.c +0 -123
  251. package/vendor/libarchive/libarchive/archive_write_set_format_shar.c +0 -650
  252. package/vendor/libarchive/libarchive/archive_write_set_format_ustar.c +0 -768
  253. package/vendor/libarchive/libarchive/archive_write_set_format_v7tar.c +0 -648
  254. package/vendor/libarchive/libarchive/archive_write_set_format_warc.c +0 -491
  255. package/vendor/libarchive/libarchive/archive_write_set_format_xar.c +0 -3799
  256. package/vendor/libarchive/libarchive/archive_write_set_format_zip.c +0 -2548
  257. package/vendor/libarchive/libarchive/archive_write_set_options.3 +0 -779
  258. package/vendor/libarchive/libarchive/archive_write_set_options.c +0 -129
  259. package/vendor/libarchive/libarchive/archive_write_set_passphrase.3 +0 -72
  260. package/vendor/libarchive/libarchive/archive_write_set_passphrase.c +0 -95
  261. package/vendor/libarchive/libarchive/archive_xxhash.h +0 -48
  262. package/vendor/libarchive/libarchive/config_freebsd.h +0 -275
  263. package/vendor/libarchive/libarchive/cpio.5 +0 -389
  264. package/vendor/libarchive/libarchive/filter_fork.h +0 -44
  265. package/vendor/libarchive/libarchive/filter_fork_posix.c +0 -269
  266. package/vendor/libarchive/libarchive/filter_fork_windows.c +0 -270
  267. package/vendor/libarchive/libarchive/libarchive-formats.5 +0 -478
  268. package/vendor/libarchive/libarchive/libarchive.3 +0 -297
  269. package/vendor/libarchive/libarchive/libarchive_changes.3 +0 -339
  270. package/vendor/libarchive/libarchive/libarchive_internals.3 +0 -363
  271. package/vendor/libarchive/libarchive/module.modulemap +0 -34
  272. package/vendor/libarchive/libarchive/mtree.5 +0 -323
  273. package/vendor/libarchive/libarchive/tar.5 +0 -947
  274. package/vendor/libarchive/libarchive/xxhash.c +0 -531
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../index.ts","../documentType.ts","../nativeModuleResolution.ts","../nativeViewAvailability.ts","../nativeTextModel.ts","../nativeDocumentRoute.ts"],"sourcesContent":["import type { ComponentType, RefAttributes } from \"react\";\nimport {\n NativeModules,\n Platform,\n UIManager,\n TurboModuleRegistry,\n requireNativeComponent,\n View,\n type ViewProps,\n} from \"react-native\";\nimport { BaseDocumentEngine, papyrusEvents } from \"@papyrus-sdk/core\";\nimport {\n DocumentLoadInput,\n DocumentLoadRequest,\n DocumentEngine,\n DocumentSource,\n DocumentType,\n ComicFormat,\n ComicFitMode,\n ComicLayoutMode,\n ComicReadingDirection,\n PageDestination,\n PapyrusEventType,\n RenderTargetType,\n TextItem,\n OutlineItem,\n FileLike,\n SearchResult,\n TextSearchResult,\n TextRangeSelection,\n TextSelection,\n TextSelectionEndpoints,\n RenderPageResult,\n RenderPageTelemetryContext,\n PageTheme,\n Annotation,\n AnnotationAnchor,\n InkStrokeCommit,\n PdfVisiblePage,\n} from \"@papyrus-sdk/types\";\nimport { inferDocumentType, resolveComicFormat } from \"./documentType\";\nimport { resolvePapyrusNativeModule } from \"./nativeModuleResolution\";\nimport { isNativeViewManagerRegistered } from \"./nativeViewAvailability\";\nimport { clampTextOffset } from \"./nativeTextModel\";\nimport { resolveNativeMobileDocumentRoute } from \"./nativeDocumentRoute\";\n\nconst MODULE_NAME = \"PapyrusNativeEngine\";\n\nconst BASE64_CHARS =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\nconst BASE64_LOOKUP = (() => {\n const table = new Uint8Array(256);\n table.fill(255);\n for (let i = 0; i < BASE64_CHARS.length; i += 1) {\n table[BASE64_CHARS.charCodeAt(i)] = i;\n }\n return table;\n})();\n\nconst parseDataUri = (\n value: string\n): { mime: string; isBase64: boolean; data: string } | null => {\n const match = /^data:([^;,]+)?(;base64)?,(.*)$/.exec(value);\n if (!match) return null;\n return {\n mime: match[1] ?? \"\",\n isBase64: Boolean(match[2]),\n data: match[3] ?? \"\",\n };\n};\n\nconst looksLikeUri = (value: string): boolean =>\n value.startsWith(\"http://\") ||\n value.startsWith(\"https://\") ||\n value.startsWith(\"/\") ||\n value.startsWith(\"./\") ||\n value.startsWith(\"../\") ||\n value.startsWith(\"file://\") ||\n value.startsWith(\"content://\") ||\n value.startsWith(\"android.resource://\");\n\nconst isLikelyBase64 = (value: string): boolean => {\n if (looksLikeUri(value)) return false;\n if (value.includes(\".\")) return false;\n if (value.length < 16) return false;\n return /^[A-Za-z0-9+/=]+$/.test(value);\n};\n\nconst isHttpUri = (value: string): boolean =>\n value.startsWith(\"http://\") || value.startsWith(\"https://\");\n\n// Metro serves bundled React Native assets over the development server. Keep\n// those URIs intact so the WebView can stream them directly instead of\n// downloading the whole EPUB/CBR through the RN bridge first.\nconst isMetroAssetUri = (value: string): boolean => {\n try {\n const url = new URL(value);\n return (\n (url.protocol === \"http:\" || url.protocol === \"https:\") &&\n url.pathname.startsWith(\"/assets/\") &&\n url.searchParams.has(\"platform\") &&\n url.searchParams.has(\"hash\")\n );\n } catch {\n return false;\n }\n};\n\nconst isLocalUri = (value: string): boolean =>\n value.startsWith(\"content://\") ||\n value.startsWith(\"file://\") ||\n value.startsWith(\"android.resource://\");\n\nconst decodeBase64 = (value: string): Uint8Array => {\n const clean = value.replace(/[^A-Za-z0-9+/=]/g, \"\");\n const padding = clean.endsWith(\"==\") ? 2 : clean.endsWith(\"=\") ? 1 : 0;\n const outputLength = Math.max(0, (clean.length * 3) / 4 - padding);\n const output = new Uint8Array(outputLength);\n\n let buffer = 0;\n let bits = 0;\n let index = 0;\n\n for (let i = 0; i < clean.length; i += 1) {\n const charCode = clean.charCodeAt(i);\n if (charCode === 61) break;\n const valueIndex = BASE64_LOOKUP[charCode];\n if (valueIndex === 255) continue;\n buffer = (buffer << 6) | valueIndex;\n bits += 6;\n if (bits >= 8) {\n bits -= 8;\n output[index++] = (buffer >> bits) & 0xff;\n }\n }\n return output;\n};\n\nconst encodeBase64 = (bytes: Uint8Array): string => {\n let output = \"\";\n let buffer = 0;\n let bits = 0;\n\n for (let i = 0; i < bytes.length; i += 1) {\n buffer = (buffer << 8) | bytes[i];\n bits += 8;\n while (bits >= 6) {\n bits -= 6;\n output += BASE64_CHARS[(buffer >> bits) & 0x3f];\n }\n }\n\n if (bits > 0) {\n output += BASE64_CHARS[(buffer << (6 - bits)) & 0x3f];\n }\n\n const remainder = bytes.length % 3;\n if (remainder === 1) return `${output}==`;\n if (remainder === 2) return `${output}=`;\n return output;\n};\n\nconst isLoadRequest = (\n input: DocumentLoadInput\n): input is DocumentLoadRequest =>\n typeof input === \"object\" &&\n input !== null &&\n \"source\" in input &&\n \"type\" in input;\n\nconst normalizeLoadInput = (\n input: DocumentLoadInput\n): { source: DocumentSource; type?: DocumentType; format?: ComicFormat } =>\n isLoadRequest(input)\n ? { source: input.source, type: input.type, format: input.format }\n : { source: input };\n\nconst normalizeNativeSource = async (\n source: DocumentSource,\n allowPlainText: boolean\n): Promise<NativeDocumentSource> => {\n if (typeof source === \"string\") {\n const dataUri = parseDataUri(source);\n if (dataUri?.isBase64) return { data: decodeBase64(dataUri.data) };\n if (dataUri && allowPlainText) {\n return { text: decodeURIComponent(dataUri.data) };\n }\n if (looksLikeUri(source)) return { uri: source };\n if (!allowPlainText && isLikelyBase64(source)) return { data: decodeBase64(source) };\n return allowPlainText ? { text: source } : { uri: source };\n }\n if (typeof source === \"object\" && source !== null && \"uri\" in source) {\n return { uri: source.uri };\n }\n if (typeof source === \"object\" && source !== null && \"data\" in source) {\n const data =\n source.data instanceof Uint8Array\n ? source.data\n : new Uint8Array(source.data);\n return { data };\n }\n if (\n typeof source === \"object\" &&\n source !== null &&\n typeof (source as FileLike).arrayBuffer === \"function\"\n ) {\n return { data: new Uint8Array(await (source as FileLike).arrayBuffer()) };\n }\n if (source instanceof ArrayBuffer) return { data: new Uint8Array(source) };\n if (source instanceof Uint8Array) return { data: source };\n throw new Error(\"[Papyrus] Unsupported native document source\");\n};\n\ntype NativeDocumentSource = {\n uri?: string;\n data?: Uint8Array;\n text?: string;\n};\n\ntype NativePageDestination = {\n kind: \"pageIndex\" | \"pageNumber\" | \"named\";\n value: number | string;\n};\n\nconst normalizeNativeDestination = (\n dest: PageDestination\n): NativePageDestination | null => {\n if (!dest) return null;\n if (typeof dest === \"string\") {\n return { kind: \"named\", value: dest };\n }\n\n if (\n dest.kind === \"pageIndex\" ||\n dest.kind === \"pageNumber\" ||\n dest.kind === \"named\"\n ) {\n return { kind: dest.kind, value: dest.value };\n }\n\n return null;\n};\n\ntype NativeEngineModule = {\n createEngine?: () => string;\n isTablet?: () => boolean;\n destroyEngine?: (engineId: string) => void;\n load?: (\n engineId: string,\n source: NativeDocumentSource\n ) => Promise<{ pageCount?: number } | void>;\n getPageCount?: (engineId: string) => number;\n getLifecycleStats?: () => Record<string, number>;\n renderPage?: (\n engineId: string,\n pageIndex: number,\n target: number,\n scale: number,\n zoom: number,\n rotation: number,\n requestId: string,\n telemetry?: RenderPageTelemetryContext\n ) => Promise<RenderPageResult>;\n renderTextLayer?: (\n engineId: string,\n pageIndex: number,\n target: number,\n scale: number,\n zoom: number,\n rotation: number\n ) => void;\n getTextContent?: (engineId: string, pageIndex: number) => Promise<TextItem[]>;\n getPageDimensions?: (\n engineId: string,\n pageIndex: number\n ) => Promise<{ width: number; height: number }>;\n searchText?: (engineId: string, query: string) => Promise<SearchResult[]>;\n selectText?: (\n engineId: string,\n pageIndex: number,\n x: number,\n y: number,\n width: number,\n height: number,\n startX: number,\n startY: number,\n endX: number,\n endY: number\n ) => Promise<TextSelection | null>;\n getOutline?: (engineId: string) => Promise<OutlineItem[]>;\n getPageIndex?: (\n engineId: string,\n dest: NativePageDestination\n ) => Promise<number | null>;\n readFileChunk?: (\n uri: string,\n offset: number,\n length: number\n ) => Promise<{ data: string; done: boolean }>;\n loadText?: (\n engineId: string,\n generation: number,\n source: NativeDocumentSource\n ) => Promise<{ textLength: number }>;\n closeText?: (engineId: string, generation: number) => void;\n resolveTextAnnotationRange?: (engineId:string,generation:number,anchor:AnnotationAnchor) => Promise<{start:number;end:number}|null>;\n getTextRange?: (\n engineId: string,\n generation: number,\n start: number,\n end: number\n ) => Promise<string>;\n searchTextRanges?: (\n engineId: string,\n generation: number,\n query: string\n ) => Promise<TextSearchResult[]>;\n loadComic?: (\n engineId: string,\n generation: number,\n source: NativeDocumentSource,\n format: ComicFormat\n ) => Promise<{ pageCount: number }>;\n closeComic?: (engineId: string, generation: number) => void;\n getComicPagePreview?: (\n engineId: string,\n generation: number,\n pageIndex: number,\n maxEdge: number\n ) => Promise<string | null>;\n};\n\nexport type PapyrusPageViewProps = ViewProps & {\n engineId?: string;\n pageTheme?: PageTheme;\n};\n\nexport type PapyrusPdfViewerViewProps = ViewProps & {\n annotationLabels?: Record<string,string>;\n defineEnabled?: boolean;\n copyLabel?: string;\n selectAllLabel?: string;\n onAnnotateSelection?: (event: {nativeEvent: {text:string;pageIndex:number;rects:{x:number;y:number;width:number;height:number}[];style:\"highlight\"|\"underline\"|\"strikeout\"|\"comment\"}}) => void;\n engineId?: string;\n pageTheme?: PageTheme;\n zoom?: number;\n currentPage?: number;\n activeTool?: string;\n activeDrawToolPreset?: \"ink\" | \"highlight\" | \"underline\";\n inkStrokeWidth?: number;\n annotationColor?: string;\n annotationSelectionColor?: string;\n annotationOpacity?: number;\n searchResults?: SearchResult[];\n activeSearchIndex?: number;\n annotations?: Annotation[];\n annotationNavigationRequest?: {pageIndex:number;rect:{x:number;y:number;width:number;height:number};nonce:number} | null;\n selectedAnnotationId?: string | null;\n onPageChanged?: (event: { nativeEvent: { page: number } }) => void;\n onZoomChanged?: (event: { nativeEvent: { zoom: number } }) => void;\n onPageChange?: (event: { nativeEvent: { page: number } }) => void;\n onZoomChange?: (event: { nativeEvent: { zoom: number } }) => void;\n onVisiblePagesChange?: (event: { nativeEvent: { pages: PdfVisiblePage[] } }) => void;\n onAnnotationCreated?: (event: { nativeEvent: Annotation }) => void;\n onTap?: (event: { nativeEvent: { pageIndex: number; x: number; y: number } }) => void;\n onAnnotationTap?: (event: { nativeEvent: { id: string; pageIndex: number; type: string; color: string } }) => void;\n onAnnotationDelete?: (event: { nativeEvent: { id: string } }) => void;\n onAnnotationDeselected?: (event: { nativeEvent: Record<string, never> }) => void;\n onInkDrawingCommitted?: (event: {\n nativeEvent: { pageIndex: number; strokes: InkStrokeCommit[] };\n }) => void;\n onInkToolPickerVisibilityChange?: (event: {\n nativeEvent: { visible: boolean };\n }) => void;\n onTextSelected?: (event: { nativeEvent: { text: string; pageIndex: number; rects: { x: number; y: number; width: number; height: number }[] } }) => void;\n onDefineSelection?: (event: { nativeEvent: { text: string; pageIndex: number } }) => void;\n onScroll?: (event: { nativeEvent: { offsetY: number } }) => void;\n selectionActive?: boolean;\n defineLabel?: string;\n defineSelectionMode?: \"selection\" | \"single-word\";\n annotateLabel?: string;\n annotationHighlightLabel?: string;\n annotationUnderlineLabel?: string;\n annotationStrikeoutLabel?: string;\n annotationSquigglyLabel?: string;\n annotationNoteLabel?: string;\n annotationDeleteLabel?: string;\n viewMode?: \"continuous\" | \"single\";\n};\n\nexport type PapyrusTextDocumentViewProps = ViewProps & {\n annotations?: Annotation[];\n annotationLabels?: Record<string, string>;\n onAnnotateSelection?: (event: {nativeEvent: TextRangeSelection & {style: \"highlight\" | \"underline\" | \"strikeout\" | \"comment\"; prefix?: string; suffix?: string}}) => void;\n onAnnotationTap?: (event: {nativeEvent: {id: string}}) => void;\n engineId?: string;\n documentGeneration?: number;\n textLength?: number;\n currentTextOffset?: number;\n scrollToTextOffsetSignal?: number | null;\n textNavigationRequest?: {offset:number;nonce:number} | null;\n searchResults?: TextSearchResult[];\n activeSearchIndex?: number;\n pageTheme?: PageTheme;\n uiTheme?: \"light\" | \"dark\";\n fontSize?: number;\n lineHeight?: number;\n pageMargin?: number;\n defineLabel?: string;\n defineSelectionMode?: \"selection\" | \"single-word\";\n onTextOffsetChange?: (event: { nativeEvent: { offset: number } }) => void;\n onTextRangeSelected?: (event: {\n nativeEvent: { text: string; start: number; end: number };\n }) => void;\n onDefineSelection?: (event: {\n nativeEvent: { text: string; start: number; end: number };\n }) => void;\n};\n\nexport type PapyrusComicDocumentViewProps = ViewProps & {\n engineId?: string;\n documentGeneration?: number;\n pageCount?: number;\n currentPage?: number;\n layoutMode?: ComicLayoutMode;\n fitMode?: ComicFitMode;\n readingDirection?: ComicReadingDirection;\n zoom?: number;\n pageTheme?: PageTheme;\n onPageChanged?: (event: { nativeEvent: { page: number } }) => void;\n onZoomChanged?: (event: { nativeEvent: { zoom: number } }) => void;\n onError?: (event: { nativeEvent: { message: string } }) => void;\n};\n\ntype PapyrusPageViewComponent = ComponentType<\n PapyrusPageViewProps & RefAttributes<View>\n>;\n\ntype PapyrusPdfViewerViewComponent = ComponentType<\n PapyrusPdfViewerViewProps & RefAttributes<View>\n>;\n\nconst resolveNativeModule = (): NativeEngineModule | null => {\n return resolvePapyrusNativeModule<NativeEngineModule>({\n nativeModules: NativeModules as Record<string, unknown>,\n turboModuleRegistry: TurboModuleRegistry,\n });\n};\n\nlet cachedAndroidTabletFormFactor: boolean | undefined;\n\nexport const isPapyrusTablet = (): boolean => {\n if (Platform.OS === \"ios\") return Platform.isPad;\n if (Platform.OS !== \"android\") return false;\n if (cachedAndroidTabletFormFactor !== undefined) {\n return cachedAndroidTabletFormFactor;\n }\n\n try {\n cachedAndroidTabletFormFactor = resolveNativeModule()?.isTablet?.() === true;\n } catch {\n cachedAndroidTabletFormFactor = false;\n }\n\n return cachedAndroidTabletFormFactor;\n};\n\nconst resolvePapyrusPageView = (): PapyrusPageViewComponent => {\n try {\n return requireNativeComponent<PapyrusPageViewProps>(\n \"PapyrusPageView\"\n ) as unknown as PapyrusPageViewComponent;\n } catch {\n return View as unknown as PapyrusPageViewComponent;\n }\n};\n\nconst PAPYRUS_PDF_DOCUMENT_VIEW_NAME = \"PapyrusPdfDocumentView\";\n\nconst hasPapyrusPdfDocumentViewManager = (): boolean =>\n Platform.OS === \"ios\" &&\n isNativeViewManagerRegistered(UIManager, PAPYRUS_PDF_DOCUMENT_VIEW_NAME);\n\nconst unavailablePapyrusPdfDocumentView: PapyrusPdfViewerViewComponent = () =>\n null;\n\nconst resolvePapyrusPdfDocumentView = (): PapyrusPdfViewerViewComponent | null => {\n if (!hasPapyrusPdfDocumentViewManager()) return null;\n try {\n return requireNativeComponent<PapyrusPdfViewerViewProps>(\n PAPYRUS_PDF_DOCUMENT_VIEW_NAME\n ) as unknown as PapyrusPdfViewerViewComponent;\n } catch {\n return null;\n }\n};\n\nconst resolvePapyrusAndroidPdfViewerView = (): PapyrusPdfViewerViewComponent => {\n try {\n return requireNativeComponent<PapyrusPdfViewerViewProps>(\n \"PapyrusPdfViewerView\"\n ) as unknown as PapyrusPdfViewerViewComponent;\n } catch {\n return View as unknown as PapyrusPdfViewerViewComponent;\n }\n};\n\nconst papyrusPdfDocumentView = resolvePapyrusPdfDocumentView();\n\nexport const isPapyrusPdfDocumentViewAvailable = (): boolean =>\n papyrusPdfDocumentView !== null && hasPapyrusPdfDocumentViewManager();\n\nexport const PapyrusPageView = resolvePapyrusPageView();\nexport const PapyrusPdfViewerView =\n Platform.OS === \"ios\"\n ? papyrusPdfDocumentView ?? unavailablePapyrusPdfDocumentView\n : resolvePapyrusAndroidPdfViewerView();\nexport const PapyrusPdfDocumentView = PapyrusPdfViewerView;\n\nconst PAPYRUS_TEXT_DOCUMENT_VIEW_NAME = \"PapyrusTextDocumentView\";\nconst PAPYRUS_COMIC_DOCUMENT_VIEW_NAME = \"PapyrusComicDocumentView\";\n\nconst resolveNativeView = <Props extends ViewProps>(\n name: string\n): ComponentType<Props & RefAttributes<unknown>> | null => {\n if (!isNativeViewManagerRegistered(UIManager, name)) return null;\n try {\n return requireNativeComponent<Props>(name) as unknown as ComponentType<\n Props & RefAttributes<unknown>\n >;\n } catch {\n return null;\n }\n};\n\nconst papyrusTextDocumentView =\n resolveNativeView<PapyrusTextDocumentViewProps>(\n PAPYRUS_TEXT_DOCUMENT_VIEW_NAME\n );\nconst papyrusComicDocumentView =\n resolveNativeView<PapyrusComicDocumentViewProps>(\n PAPYRUS_COMIC_DOCUMENT_VIEW_NAME\n );\n\nexport const isPapyrusTextDocumentViewAvailable = (): boolean =>\n papyrusTextDocumentView !== null;\nexport const isPapyrusComicDocumentViewAvailable = (): boolean =>\n papyrusComicDocumentView !== null;\nexport const PapyrusTextDocumentView =\n papyrusTextDocumentView ?? unavailablePapyrusPdfDocumentView;\nexport const PapyrusComicDocumentView =\n papyrusComicDocumentView ?? unavailablePapyrusPdfDocumentView;\n\nexport class NativeDocumentEngine extends BaseDocumentEngine {\n private nativeModule: NativeEngineModule | null = null;\n private engineId: string = \"default\";\n private pageCount: number = 0;\n private currentPage: number = 1;\n private zoom: number = 1.0;\n private rotation: number = 0;\n private renderRequestCounter: number = 0;\n\n constructor() {\n super();\n this.nativeModule = resolveNativeModule();\n this.engineId = this.nativeModule?.createEngine\n ? this.nativeModule.createEngine()\n : \"default\";\n }\n\n async load(input: DocumentLoadInput): Promise<void> {\n const { source, type } = normalizeLoadInput(input);\n if (type && type !== \"pdf\") {\n throw new Error(\n `[NativeDocumentEngine] Tipo de documento não suportado: ${type}`\n );\n }\n\n const native = this.assertNativeModule();\n const normalized = await this.normalizeSource(source);\n let result;\n try {\n result = native.load\n ? await native.load(this.engineId, normalized)\n : undefined;\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n if (\n !/engine not found|papyrus_no_engine/i.test(message) ||\n !native.createEngine\n ) {\n throw error;\n }\n\n // Fast Refresh can preserve this JS instance after the native store was\n // recreated. Recover the stale id once instead of surfacing a redbox.\n this.engineId = native.createEngine();\n result = native.load\n ? await native.load(this.engineId, normalized)\n : undefined;\n }\n\n if (result && typeof result.pageCount === \"number\") {\n this.pageCount = result.pageCount;\n } else if (native.getPageCount) {\n this.pageCount = native.getPageCount(this.engineId);\n } else {\n this.pageCount = 0;\n }\n\n this.currentPage = 1;\n this.zoom = 1.0;\n this.rotation = 0;\n }\n\n getPageCount(): number {\n return this.pageCount;\n }\n\n getLifecycleStats(): Record<string, number> {\n return this.nativeModule?.getLifecycleStats?.() ?? {};\n }\n\n getCurrentPage(): number {\n return this.currentPage;\n }\n\n goToPage(page: number): void {\n if (page >= 1 && page <= this.pageCount) {\n this.currentPage = page;\n }\n }\n\n setZoom(zoom: number): void {\n this.zoom = Math.max(0.1, Math.min(5.0, zoom));\n }\n\n getZoom(): number {\n return this.zoom;\n }\n\n rotate(direction: \"clockwise\" | \"counterclockwise\"): void {\n if (direction === \"clockwise\") {\n this.rotation = (this.rotation + 90) % 360;\n } else {\n this.rotation = (this.rotation - 90) % 360;\n if (this.rotation < 0) this.rotation += 360;\n }\n }\n\n getRotation(): number {\n return this.rotation;\n }\n\n getNativeEngineId(): string {\n return this.engineId;\n }\n\n async renderPage(\n pageIndex: number,\n target: any,\n scale: number,\n telemetry?: RenderPageTelemetryContext\n ): Promise<void | RenderPageResult> {\n const native = this.assertNativeModule();\n if (!native.renderPage) return;\n const viewTag = this.toNativeViewTag(target);\n if (viewTag === null) return;\n const requestId = `native-render-${++this.renderRequestCounter}`;\n return native.renderPage(\n this.engineId,\n pageIndex,\n viewTag,\n scale,\n this.zoom,\n this.rotation,\n requestId,\n telemetry\n );\n }\n\n async renderTextLayer(\n pageIndex: number,\n target: any,\n scale: number\n ): Promise<void> {\n const native = this.assertNativeModule();\n if (!native.renderTextLayer) return;\n const viewTag = this.toNativeViewTag(target);\n if (viewTag === null) return;\n native.renderTextLayer(\n this.engineId,\n pageIndex,\n viewTag,\n scale,\n this.zoom,\n this.rotation\n );\n }\n\n async getTextContent(pageIndex: number): Promise<TextItem[]> {\n const native = this.assertNativeModule();\n if (!native.getTextContent) return [];\n return native.getTextContent(this.engineId, pageIndex);\n }\n\n async getPageDimensions(\n pageIndex: number\n ): Promise<{ width: number; height: number }> {\n const native = this.assertNativeModule();\n if (!native.getPageDimensions) return { width: 0, height: 0 };\n return native.getPageDimensions(this.engineId, pageIndex);\n }\n\n async selectText(\n pageIndex: number,\n rect: { x: number; y: number; width: number; height: number },\n endpoints?: TextSelectionEndpoints\n ): Promise<TextSelection | null> {\n const native = this.assertNativeModule();\n if (!native.selectText) return null;\n return native.selectText(\n this.engineId,\n pageIndex,\n rect.x,\n rect.y,\n rect.width,\n rect.height,\n endpoints?.start.x ?? -1,\n endpoints?.start.y ?? -1,\n endpoints?.end.x ?? -1,\n endpoints?.end.y ?? -1\n );\n }\n\n async getOutline(): Promise<OutlineItem[]> {\n const native = this.assertNativeModule();\n if (!native.getOutline) return [];\n return native.getOutline(this.engineId);\n }\n\n async searchText(query: string): Promise<SearchResult[]> {\n const native = this.assertNativeModule();\n if (!native.searchText) return [];\n return native.searchText(this.engineId, query);\n }\n\n async getPageIndex(dest: PageDestination): Promise<number | null> {\n if (!dest) return null;\n if (typeof dest !== \"string\") {\n if (dest.kind === \"pageIndex\") return dest.value;\n if (dest.kind === \"pageNumber\") return Math.max(0, dest.value - 1);\n }\n\n const native = this.assertNativeModule();\n if (!native.getPageIndex) return null;\n const normalized = normalizeNativeDestination(dest);\n if (!normalized || normalized.kind !== \"named\") return null;\n return native.getPageIndex(this.engineId, normalized);\n }\n\n destroy(): void {\n this.nativeModule?.destroyEngine?.(this.engineId);\n }\n\n private assertNativeModule(): NativeEngineModule {\n if (!this.nativeModule) {\n this.nativeModule = resolveNativeModule();\n }\n if (!this.nativeModule) {\n throw new Error(\n `[Papyrus] Native module \"${MODULE_NAME}\" not found. Use a dev client or a native build (Expo Go is not supported).`\n );\n }\n return this.nativeModule;\n }\n\n private async normalizeSource(\n source: DocumentSource\n ): Promise<NativeDocumentSource> {\n if (typeof source === \"string\") {\n const dataUri = parseDataUri(source);\n if (dataUri?.isBase64) {\n return { data: decodeBase64(dataUri.data) };\n }\n if (looksLikeUri(source)) return { uri: source };\n if (isLikelyBase64(source)) return { data: decodeBase64(source) };\n return { uri: source };\n }\n if (this.isUriSource(source)) return { uri: source.uri };\n if (this.isDataSource(source)) {\n const data =\n source.data instanceof Uint8Array\n ? source.data\n : new Uint8Array(source.data);\n return { data };\n }\n if (this.isFileLike(source)) {\n const buffer = await source.arrayBuffer();\n return { data: new Uint8Array(buffer) };\n }\n if (source instanceof ArrayBuffer) return { data: new Uint8Array(source) };\n if (source instanceof Uint8Array) return { data: source };\n return { data: new Uint8Array(source as ArrayBuffer) };\n }\n\n private isUriSource(source: DocumentSource): source is { uri: string } {\n return typeof source === \"object\" && source !== null && \"uri\" in source;\n }\n\n private isDataSource(\n source: DocumentSource\n ): source is { data: ArrayBuffer | Uint8Array } {\n return typeof source === \"object\" && source !== null && \"data\" in source;\n }\n\n private isFileLike(source: DocumentSource): source is FileLike {\n return (\n typeof source === \"object\" &&\n source !== null &&\n typeof (source as FileLike).arrayBuffer === \"function\"\n );\n }\n\n private toNativeViewTag(target: any): number | null {\n if (typeof target === \"number\") return target;\n if (target?.nativeTag && typeof target.nativeTag === \"number\")\n return target.nativeTag;\n return null;\n }\n}\n\nexport class NativeTextDocumentEngine extends BaseDocumentEngine {\n private nativeModule: NativeEngineModule | null = resolveNativeModule();\n private engineId: string = this.nativeModule?.createEngine?.() ?? \"default\";\n private loadGeneration = 0;\n private documentGeneration = 0;\n private textLength = 0;\n private currentOffset = 0;\n\n async load(input: DocumentLoadInput): Promise<void> {\n const { source, type } = normalizeLoadInput(input);\n if (type && type !== \"text\") {\n throw new Error(\"[NativeTextDocumentEngine] Unsupported type: \" + type);\n }\n\n const generation = ++this.loadGeneration;\n if (this.documentGeneration > 0) {\n this.nativeModule?.closeText?.(this.engineId, this.documentGeneration);\n }\n this.documentGeneration = 0;\n this.textLength = 0;\n this.currentOffset = 0;\n const nativeSource = await normalizeNativeSource(source, true);\n if (generation !== this.loadGeneration) return;\n\n const native = this.assertNativeModule();\n if (!native.loadText) {\n throw new Error(\"[Papyrus] Native TXT loading is not available\");\n }\n const result = await native.loadText(\n this.engineId,\n generation,\n nativeSource\n );\n if (generation !== this.loadGeneration) {\n native.closeText?.(this.engineId, generation);\n return;\n }\n this.documentGeneration = generation;\n this.textLength = Math.max(0, Math.floor(result.textLength));\n this.currentOffset = 0;\n }\n\n getNativeTextEngineId(): string {\n return this.engineId;\n }\n getDocumentGeneration(): number {\n return this.documentGeneration;\n }\n getTextLength(): number {\n return this.textLength;\n }\n getCurrentTextOffset(): number {\n return this.currentOffset;\n }\n goToTextOffset(offset: number): void {\n this.currentOffset = clampTextOffset(offset, this.textLength);\n }\n async resolveAnnotationTextRange(annotation:Annotation):Promise<{start:number;end:number}|null> {\n if(annotation.anchor?.kind!==\"text-range\")return annotation.textRange??null;\n const generation=this.documentGeneration;\n const range=await this.assertNativeModule().resolveTextAnnotationRange?.(this.engineId,generation,annotation.anchor);\n return generation===this.documentGeneration?range??null:null;\n }\n async getTextRange(start: number, end: number): Promise<string> {\n const native = this.assertNativeModule();\n if (!native.getTextRange) return \"\";\n return native.getTextRange(\n this.engineId,\n this.documentGeneration,\n clampTextOffset(start, this.textLength),\n clampTextOffset(end, this.textLength)\n );\n }\n async searchTextRanges(query: string): Promise<TextSearchResult[]> {\n const native = this.assertNativeModule();\n if (!native.searchTextRanges) return [];\n return native.searchTextRanges(this.engineId, this.documentGeneration, query);\n }\n getRenderTargetType(): RenderTargetType {\n return \"native-text\";\n }\n getPageCount(): number { return 0; }\n getCurrentPage(): number { return 1; }\n goToPage(page: number): void { void page; }\n setZoom(zoom: number): void { void zoom; }\n getZoom(): number { return 1; }\n rotate(direction: \"clockwise\" | \"counterclockwise\"): void { void direction; }\n getRotation(): number { return 0; }\n async renderPage(): Promise<void> {}\n async renderTextLayer(): Promise<void> {}\n async getTextContent(): Promise<TextItem[]> { return []; }\n async getPageDimensions(): Promise<{ width: number; height: number }> {\n return { width: 0, height: 0 };\n }\n async selectText(): Promise<TextSelection | null> { return null; }\n async getOutline(): Promise<OutlineItem[]> { return []; }\n async getPageIndex(): Promise<number | null> { return null; }\n destroy(): void {\n this.loadGeneration += 1;\n const engineId = this.engineId;\n if (this.documentGeneration > 0) {\n this.nativeModule?.closeText?.(engineId, this.documentGeneration);\n }\n this.nativeModule?.destroyEngine?.(engineId);\n this.engineId = \"default\";\n this.textLength = 0;\n this.currentOffset = 0;\n this.documentGeneration = 0;\n }\n private assertNativeModule(): NativeEngineModule {\n if (!this.nativeModule) this.nativeModule = resolveNativeModule();\n if (!this.nativeModule) {\n throw new Error('[Papyrus] Native module \"PapyrusNativeEngine\" not found. Use a dev client or native build.');\n }\n if (this.engineId === \"default\" && this.nativeModule.createEngine) {\n this.engineId = this.nativeModule.createEngine();\n }\n return this.nativeModule;\n }\n}\n\nexport class NativeComicDocumentEngine extends BaseDocumentEngine {\n private nativeModule: NativeEngineModule | null = resolveNativeModule();\n private engineId: string = this.nativeModule?.createEngine?.() ?? \"default\";\n private loadGeneration = 0;\n private documentGeneration = 0;\n private pageCount = 0;\n private currentPage = 1;\n private zoom = 1;\n private format: ComicFormat = \"cbz\";\n\n async load(input: DocumentLoadInput): Promise<void> {\n const { source, type, format } = normalizeLoadInput(input);\n if (type && type !== \"comic\") {\n throw new Error(\"[NativeComicDocumentEngine] Unsupported type: \" + type);\n }\n const generation = ++this.loadGeneration;\n if (this.documentGeneration > 0) {\n this.nativeModule?.closeComic?.(this.engineId, this.documentGeneration);\n }\n this.documentGeneration = 0;\n this.pageCount = 0;\n this.currentPage = 1;\n this.zoom = 1;\n const nativeSource = await normalizeNativeSource(source, false);\n if (generation !== this.loadGeneration) return;\n const native = this.assertNativeModule();\n if (!native.loadComic) {\n throw new Error(\"[Papyrus] Native comic archive loading is not available\");\n }\n const engineId = this.engineId;\n this.format = resolveComicFormat(source, format);\n const result = await native.loadComic(\n engineId, generation, nativeSource, this.format\n );\n if (generation !== this.loadGeneration) {\n native.closeComic?.(engineId, generation);\n return;\n }\n this.documentGeneration = generation;\n this.pageCount = Math.max(0, Math.floor(result.pageCount));\n this.currentPage = 1;\n }\n getNativeComicEngineId(): string { return this.engineId; }\n getDocumentGeneration(): number { return this.documentGeneration; }\n getComicFormat(): ComicFormat { return this.format; }\n getPageCount(): number { return this.pageCount; }\n getCurrentPage(): number { return this.currentPage; }\n goToPage(page: number): void {\n if (page >= 1 && page <= this.pageCount) this.currentPage = page;\n }\n getRenderTargetType(): RenderTargetType { return \"native-comic\"; }\n async getPagePreview(pageIndex: number): Promise<string | null> {\n const native = this.assertNativeModule();\n return (await native.getComicPagePreview?.(\n this.engineId, this.documentGeneration, pageIndex, 1024\n )) ?? null;\n }\n setZoom(zoom: number): void { this.zoom = Math.max(1, Math.min(5, zoom)); }\n getZoom(): number { return this.zoom; }\n rotate(direction: \"clockwise\" | \"counterclockwise\"): void { void direction; }\n getRotation(): number { return 0; }\n async renderPage(): Promise<void> {}\n async renderTextLayer(): Promise<void> {}\n async getTextContent(): Promise<TextItem[]> { return []; }\n async getPageDimensions(): Promise<{ width: number; height: number }> {\n return { width: 0, height: 0 };\n }\n async selectText(): Promise<TextSelection | null> { return null; }\n async getOutline(): Promise<OutlineItem[]> { return []; }\n async getPageIndex(): Promise<number | null> { return null; }\n destroy(): void {\n this.loadGeneration += 1;\n const engineId = this.engineId;\n if (this.documentGeneration > 0) {\n this.nativeModule?.closeComic?.(engineId, this.documentGeneration);\n }\n this.nativeModule?.destroyEngine?.(engineId);\n this.engineId = \"default\";\n this.documentGeneration = 0;\n this.pageCount = 0;\n this.currentPage = 1;\n this.zoom = 1;\n }\n private assertNativeModule(): NativeEngineModule {\n if (!this.nativeModule) this.nativeModule = resolveNativeModule();\n if (!this.nativeModule) {\n throw new Error('[Papyrus] Native module \"PapyrusNativeEngine\" not found. Use a dev client or native build.');\n }\n if (this.engineId === \"default\" && this.nativeModule.createEngine) {\n this.engineId = this.nativeModule.createEngine();\n }\n return this.nativeModule;\n }\n}\n\ntype WebViewBridge = {\n postMessage: (message: string) => void;\n};\n\ntype Deferred<T> = {\n resolve: (value: T) => void;\n reject: (error: Error) => void;\n};\n\nexport type WebViewRuntimeSource =\n | string\n | number\n | { uri: string };\n\nexport type WebViewRuntimeConfig = Record<string, string>;\n\nexport type MobileDocumentEngineOptions = {\n /** Optional asset URI/require result for a runtime extension such as CBR. */\n webViewRuntimeSource?: WebViewRuntimeSource;\n webViewRuntimeConfig?: WebViewRuntimeConfig;\n};\n\ntype WebViewResponseMessage = {\n type: \"response\";\n id: string;\n ok: boolean;\n data?: any;\n error?: string;\n};\n\ntype WebViewEventMessage = {\n type: \"event\";\n name: string;\n payload?: any;\n};\n\ntype WebViewStateMessage = {\n type: \"state\";\n payload: {\n pageCount?: number;\n currentPage?: number;\n zoom?: number;\n outline?: OutlineItem[];\n };\n};\n\ntype WebViewAssetRequestMessage = {\n type: \"asset-request\";\n id: string;\n url: string;\n encoding: \"text\" | \"base64\";\n};\n\ntype WebViewFileChunkRequestMessage = {\n type: \"file-chunk-request\";\n id: string;\n uri: string;\n offset: number;\n length: number;\n};\n\ntype WebViewReadyMessage = {\n type: \"ready\";\n};\n\ntype WebViewRuntimeMessage =\n | WebViewResponseMessage\n | WebViewEventMessage\n | WebViewStateMessage\n | WebViewAssetRequestMessage\n | WebViewFileChunkRequestMessage\n | WebViewReadyMessage;\n\ntype WebViewSourcePayload =\n | { kind: \"uri\"; uri: string }\n | { kind: \"base64\"; data: string; mime?: string }\n | { kind: \"text\"; text: string };\n\nexport class WebViewDocumentEngine extends BaseDocumentEngine {\n private documentSessionId = \"\";\n getWebViewDocumentSessionId(): string { return this.documentSessionId; }\n async syncEpubAnnotations(annotations: Annotation[], documentId?: string, labels?: {comment:string}): Promise<void> {\n if (!this.documentSessionId) return;\n await this.request(\"epub-annotations\", { documentSessionId: this.documentSessionId, annotations, documentId, labels });\n }\n async goToAnnotation(annotation: Annotation): Promise<void> {\n if (annotation.anchor?.kind !== \"epub-cfi\") return;\n await this.request(\"epub-annotation-navigate\", {documentSessionId: this.documentSessionId, annotationId: annotation.id});\n }\n private readonly webViewRuntimeSource?: WebViewRuntimeSource;\n private readonly webViewRuntimeConfig?: WebViewRuntimeConfig;\n private bridge: WebViewBridge | null = null;\n private ready = false;\n private requestId = 0;\n private pending = new Map<\n string,\n { resolve: (data: any) => void; reject: (error: Error) => void }\n >();\n private bridgeResolvers: Array<Deferred<WebViewBridge>> = [];\n private readyResolvers: Array<Deferred<void>> = [];\n private pageCount = 0;\n private currentPage = 1;\n private zoom = 1.0;\n private rotation = 0;\n private outline: OutlineItem[] = [];\n\n constructor(options: MobileDocumentEngineOptions = {}) {\n super();\n this.webViewRuntimeSource = options.webViewRuntimeSource;\n this.webViewRuntimeConfig = options.webViewRuntimeConfig;\n }\n\n getWebViewRuntimeSource(): WebViewRuntimeSource | undefined {\n return this.webViewRuntimeSource;\n }\n\n getWebViewRuntimeConfig(): WebViewRuntimeConfig | undefined {\n return this.webViewRuntimeConfig;\n }\n\n getRenderTargetType(): \"webview\" {\n return \"webview\";\n }\n\n getLifecycleStats(): Record<string, number> {\n return {\n webViewCount: this.bridge ? 1 : 0,\n pendingBridgeRequests: this.pending.size,\n };\n }\n\n attachBridge(bridge: WebViewBridge): void {\n this.bridge = bridge;\n this.ready = false;\n this.bridgeResolvers.forEach(({ resolve }) => resolve(bridge));\n this.bridgeResolvers = [];\n }\n\n detachBridge(): void {\n const error = new Error(\"[Papyrus] WebView detached\");\n this.pending.forEach(({ reject }) => reject(error));\n this.pending.clear();\n this.bridgeResolvers.forEach(({ reject }) => reject(error));\n this.readyResolvers.forEach(({ reject }) => reject(error));\n this.bridgeResolvers = [];\n this.readyResolvers = [];\n this.bridge = null;\n this.ready = false;\n }\n\n handleMessage(raw: string): void {\n let message: WebViewRuntimeMessage | null = null;\n try {\n message = JSON.parse(raw) as WebViewRuntimeMessage;\n } catch {\n return;\n }\n\n if (!message) return;\n\n if (message.type === \"asset-request\") {\n void this.handleAssetRequest(message);\n return;\n }\n\n if (message.type === \"file-chunk-request\") {\n void this.handleFileChunkRequest(message);\n return;\n }\n\n if (message.type === \"ready\") {\n this.ready = true;\n this.readyResolvers.forEach(({ resolve }) => resolve());\n this.readyResolvers = [];\n return;\n }\n\n if (message.type === \"response\") {\n const pending = this.pending.get(message.id);\n if (!pending) return;\n this.pending.delete(message.id);\n if (message.ok) {\n pending.resolve(message.data);\n } else {\n pending.reject(\n new Error(message.error ?? \"[Papyrus] WebView runtime error\")\n );\n }\n return;\n }\n\n if (message.type === \"state\") {\n if (typeof message.payload.pageCount === \"number\")\n this.pageCount = message.payload.pageCount;\n if (typeof message.payload.currentPage === \"number\")\n this.currentPage = message.payload.currentPage;\n if (typeof message.payload.zoom === \"number\")\n this.zoom = message.payload.zoom;\n if (Array.isArray(message.payload.outline))\n this.outline = message.payload.outline;\n return;\n }\n\n if (message.type === \"event\") {\n const payload = message.payload ?? {};\n if (message.name === \"RUNTIME_LOG\") {\n if (__DEV__) {\n const text =\n typeof payload?.message === \"string\"\n ? payload.message\n : JSON.stringify(payload);\n console.log(\"[Papyrus WebView runtime]\", text);\n }\n return;\n }\n if (message.name === \"RUNTIME_ERROR\") {\n const errorMessage =\n typeof payload?.message === \"string\" ? payload.message : \"\";\n if (errorMessage.includes(\"ResizeObserver loop\")) {\n return;\n }\n if (__DEV__) {\n console.warn(\"[Papyrus WebView runtime]\", payload);\n }\n return;\n }\n if (message.name === PapyrusEventType.TEXT_SELECTED) {\n papyrusEvents.emit(PapyrusEventType.TEXT_SELECTED, payload);\n } else if (message.name === PapyrusEventType.SEARCH_TRIGGERED) {\n papyrusEvents.emit(PapyrusEventType.SEARCH_TRIGGERED, payload);\n } else if (message.name === PapyrusEventType.DOCUMENT_LOADED) {\n if (typeof payload.pageCount === \"number\") {\n this.pageCount = payload.pageCount;\n }\n papyrusEvents.emit(PapyrusEventType.DOCUMENT_LOADED, payload);\n }\n return;\n }\n\n if (__DEV__) {\n console.warn(\"[Papyrus WebView] Unknown message\", message);\n }\n }\n\n private async handleAssetRequest(\n message: WebViewAssetRequestMessage,\n ): Promise<void> {\n const bridge = this.bridge;\n if (!bridge) return;\n\n try {\n const response = await fetch(message.url);\n if (!response.ok) {\n throw new Error(`status ${response.status}`);\n }\n\n const data =\n message.encoding === \"text\"\n ? await response.text()\n : `data:application/wasm;base64,${encodeBase64(\n new Uint8Array(await response.arrayBuffer()),\n )}`;\n bridge.postMessage(\n JSON.stringify({\n type: \"asset-response\",\n id: message.id,\n ok: true,\n data,\n }),\n );\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n bridge.postMessage(\n JSON.stringify({\n type: \"asset-response\",\n id: message.id,\n ok: false,\n error: reason,\n }),\n );\n }\n }\n\n private async handleFileChunkRequest(\n message: WebViewFileChunkRequestMessage,\n ): Promise<void> {\n const bridge = this.bridge;\n if (!bridge) return;\n\n try {\n const nativeModule = resolveNativeModule();\n if (!nativeModule?.readFileChunk) {\n throw new Error(\"Leitura nativa de arquivos não está disponível\");\n }\n const result = await nativeModule.readFileChunk(\n message.uri,\n message.offset,\n message.length,\n );\n bridge.postMessage(\n JSON.stringify({\n type: \"file-chunk-response\",\n id: message.id,\n ok: true,\n data: result.data,\n done: result.done,\n }),\n );\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n bridge.postMessage(\n JSON.stringify({\n type: \"file-chunk-response\",\n id: message.id,\n ok: false,\n error: reason,\n }),\n );\n }\n }\n\n async load(input: DocumentLoadInput): Promise<void> {\n const { source, type, format } = normalizeLoadInput(input);\n const resolvedType = type ?? inferDocumentType(source);\n if (resolvedType === \"pdf\") {\n throw new Error(\n \"[WebViewDocumentEngine] Use o NativeDocumentEngine para PDFs no mobile.\"\n );\n }\n\n const session = `epub-${Date.now()}-${Math.random().toString(36).slice(2)}`;\n this.documentSessionId = session;\n const payloadSource = await this.normalizeRuntimeSource(\n resolvedType,\n source\n );\n if(session !== this.documentSessionId) throw new Error(\"Stale document load\");\n const response = await this.request<{\n pageCount?: number;\n outline?: OutlineItem[];\n }>(\"load\", {\n type: resolvedType,\n documentSessionId: session,\n source: payloadSource,\n ...(resolvedType === \"comic\"\n ? { format: resolveComicFormat(source, format) }\n : {}),\n });\n if(session !== this.documentSessionId) throw new Error(\"Stale document load\");\n\n if (typeof response?.pageCount === \"number\")\n this.pageCount = response.pageCount;\n if (Array.isArray(response?.outline)) this.outline = response.outline;\n this.currentPage = 1;\n }\n\n getPageCount(): number {\n return this.pageCount;\n }\n\n getCurrentPage(): number {\n return this.currentPage;\n }\n\n goToPage(page: number): void {\n if (page < 1) return;\n this.currentPage = page;\n void this.request(\"go-to-page\", { page });\n }\n\n setZoom(zoom: number): void {\n this.zoom = Math.max(0.5, Math.min(4.0, zoom));\n void this.request(\"set-zoom\", { zoom: this.zoom });\n }\n\n getZoom(): number {\n return this.zoom;\n }\n\n rotate(direction: \"clockwise\" | \"counterclockwise\"): void {\n if (direction === \"clockwise\") {\n this.rotation = (this.rotation + 90) % 360;\n } else {\n this.rotation = (this.rotation - 90) % 360;\n if (this.rotation < 0) this.rotation += 360;\n }\n void this.request(\"set-rotation\", { rotation: this.rotation });\n }\n\n getRotation(): number {\n return this.rotation;\n }\n\n async renderPage(\n pageIndex: number,\n target: any,\n scale: number,\n _telemetry?: RenderPageTelemetryContext\n ): Promise<void> {\n void pageIndex;\n void target;\n void scale;\n }\n\n async renderTextLayer(\n pageIndex: number,\n container: any,\n scale: number\n ): Promise<void> {\n void pageIndex;\n void container;\n void scale;\n }\n\n async getTextContent(pageIndex: number): Promise<TextItem[]> {\n return await this.request<TextItem[]>(\"get-text-content\", { pageIndex });\n }\n\n async getPageDimensions(\n pageIndex: number\n ): Promise<{ width: number; height: number }> {\n return await this.request<{ width: number; height: number }>(\n \"get-page-dimensions\",\n { pageIndex }\n );\n }\n\n async getPagePreview(pageIndex: number): Promise<string | null> {\n return await this.request<string | null>(\"get-page-preview\", {\n pageIndex,\n });\n }\n\n async searchText(query: string): Promise<SearchResult[]> {\n return await this.request<SearchResult[]>(\"search-text\", { query });\n }\n\n async selectText(\n pageIndex: number,\n rect: { x: number; y: number; width: number; height: number },\n endpoints?: TextSelectionEndpoints\n ): Promise<TextSelection | null> {\n return await this.request<TextSelection | null>(\"select-text\", {\n pageIndex,\n rect,\n endpoints,\n });\n }\n\n async getOutline(): Promise<OutlineItem[]> {\n if (this.outline.length > 0) return this.outline;\n return await this.request<OutlineItem[]>(\"get-outline\");\n }\n\n async getPageIndex(dest: PageDestination): Promise<number | null> {\n if (!dest) return null;\n if (typeof dest !== \"string\") {\n if (dest.kind === \"pageIndex\") return dest.value;\n if (dest.kind === \"pageNumber\") return Math.max(0, dest.value - 1);\n if (dest.kind === \"href\") {\n return await this.request<number | null>(\"get-page-index\", {\n dest: dest.value,\n });\n }\n return null;\n }\n return await this.request<number | null>(\"get-page-index\", { dest });\n }\n\n destroy(): void {\n this.detachBridge();\n }\n\n private async ensureBridge(): Promise<WebViewBridge> {\n if (this.bridge) return this.bridge;\n return new Promise((resolve, reject) => {\n this.bridgeResolvers.push({ resolve, reject });\n });\n }\n\n private async ensureReady(): Promise<void> {\n if (this.ready) return;\n return new Promise((resolve, reject) => {\n this.readyResolvers.push({ resolve, reject });\n });\n }\n\n private async request<T = any>(kind: string, payload?: any): Promise<T> {\n const bridge = await this.ensureBridge();\n await this.ensureReady();\n const id = `${Date.now()}-${this.requestId++}`;\n return new Promise<T>((resolve, reject) => {\n const timeoutMs =\n kind === \"load\" ? 180000 : kind === \"get-page-preview\" ? 30000 : 8000;\n const timeoutId = setTimeout(() => {\n this.pending.delete(id);\n reject(new Error(`[Papyrus] WebView response timeout: ${kind}`));\n }, timeoutMs);\n this.pending.set(id, {\n resolve: (data) => {\n clearTimeout(timeoutId);\n resolve(data);\n },\n reject: (error) => {\n clearTimeout(timeoutId);\n reject(error);\n },\n });\n bridge.postMessage(JSON.stringify({ id, kind, payload }));\n });\n }\n\n private async normalizeRuntimeSource(\n type: DocumentType,\n source: DocumentSource\n ): Promise<WebViewSourcePayload> {\n if (typeof source === \"string\") {\n const dataUri = parseDataUri(source);\n if (dataUri) {\n if (dataUri.isBase64) {\n return {\n kind: \"base64\",\n data: dataUri.data,\n mime: dataUri.mime || undefined,\n };\n }\n const text = decodeURIComponent(dataUri.data);\n return { kind: \"text\", text };\n }\n\n if (looksLikeUri(source)) {\n if (isMetroAssetUri(source)) {\n return { kind: \"uri\", uri: source };\n }\n if (isHttpUri(source)) {\n const fetched = await this.fetchRemoteSource(type, source);\n if (fetched) return fetched;\n }\n if (isLocalUri(source)) {\n return await this.fetchLocalSource(type, source);\n }\n return { kind: \"uri\", uri: source };\n }\n\n if (isLikelyBase64(source)) {\n return { kind: \"base64\", data: source };\n }\n\n if (type === \"text\") {\n return { kind: \"text\", text: source };\n }\n\n return { kind: \"uri\", uri: source };\n }\n\n if (this.isUriSource(source)) {\n const uri = source.uri;\n const dataUri = parseDataUri(uri);\n if (dataUri) {\n if (dataUri.isBase64) {\n return {\n kind: \"base64\",\n data: dataUri.data,\n mime: dataUri.mime || undefined,\n };\n }\n return { kind: \"text\", text: decodeURIComponent(dataUri.data) };\n }\n if (isMetroAssetUri(uri)) {\n return { kind: \"uri\", uri };\n }\n if (isHttpUri(uri)) {\n const fetched = await this.fetchRemoteSource(type, uri);\n if (fetched) return fetched;\n }\n if (isLocalUri(uri)) {\n return await this.fetchLocalSource(type, uri);\n }\n return { kind: \"uri\", uri };\n }\n if (this.isDataSource(source)) {\n const bytes =\n source.data instanceof Uint8Array\n ? source.data\n : new Uint8Array(source.data);\n return { kind: \"base64\", data: encodeBase64(bytes) };\n }\n if (this.isFileLike(source)) {\n const buffer = await source.arrayBuffer();\n return { kind: \"base64\", data: encodeBase64(new Uint8Array(buffer)) };\n }\n if (source instanceof ArrayBuffer || source instanceof Uint8Array) {\n const bytes =\n source instanceof Uint8Array ? source : new Uint8Array(source);\n return { kind: \"base64\", data: encodeBase64(bytes) };\n }\n\n return {\n kind: \"base64\",\n data: encodeBase64(new Uint8Array(source as ArrayBuffer)),\n };\n }\n\n private async fetchRemoteSource(\n type: DocumentType,\n uri: string\n ): Promise<WebViewSourcePayload | null> {\n try {\n const response = await fetch(uri);\n if (!response.ok) return null;\n if (type === \"text\") {\n const text = await response.text();\n return { kind: \"text\", text };\n }\n if (type === \"epub\") {\n const buffer = await this.readResponseBuffer(response);\n return { kind: \"base64\", data: encodeBase64(new Uint8Array(buffer)) };\n }\n if (type === \"comic\") {\n const buffer = await this.readResponseBuffer(response);\n return { kind: \"base64\", data: encodeBase64(new Uint8Array(buffer)) };\n }\n return null;\n } catch {\n return null;\n }\n }\n\n private async fetchLocalSource(\n type: DocumentType,\n uri: string\n ): Promise<WebViewSourcePayload> {\n if (type === \"epub\" || type === \"comic\") {\n return { kind: \"uri\", uri };\n }\n\n try {\n const response = await fetch(uri);\n if (!response.ok && response.status !== 0) {\n throw new Error(`status ${response.status}`);\n }\n if (type === \"text\") {\n return { kind: \"text\", text: await response.text() };\n }\n throw new Error(`tipo não suportado: ${type}`);\n } catch (error) {\n const reason = error instanceof Error ? `: ${error.message}` : \"\";\n throw new Error(\n `[WebViewDocumentEngine] Não foi possível ler o arquivo local ${uri}${reason}`\n );\n }\n }\n\n private async readResponseBuffer(response: Response): Promise<ArrayBuffer> {\n try {\n return await response.arrayBuffer();\n } catch {\n const blob = await response.blob();\n return await new Promise<ArrayBuffer>((resolve, reject) => {\n const reader = new FileReader();\n reader.onerror = () =>\n reject(new Error(\"[Papyrus] Failed to read response blob\"));\n reader.onload = () => resolve(reader.result as ArrayBuffer);\n reader.readAsArrayBuffer(blob);\n });\n }\n }\n\n private isUriSource(source: DocumentSource): source is { uri: string } {\n return typeof source === \"object\" && source !== null && \"uri\" in source;\n }\n\n private isDataSource(\n source: DocumentSource\n ): source is { data: ArrayBuffer | Uint8Array } {\n return typeof source === \"object\" && source !== null && \"data\" in source;\n }\n\n private isFileLike(source: DocumentSource): source is FileLike {\n return (\n typeof source === \"object\" &&\n source !== null &&\n typeof (source as FileLike).arrayBuffer === \"function\"\n );\n }\n}\n\nexport class MobileDocumentEngine extends BaseDocumentEngine {\n private pdfEngine: NativeDocumentEngine;\n private textEngine: NativeTextDocumentEngine;\n private comicEngine: NativeComicDocumentEngine;\n private webEngine: WebViewDocumentEngine;\n private activeEngine: DocumentEngine;\n private loadGeneration = 0;\n\n constructor(options: MobileDocumentEngineOptions = {}) {\n super();\n this.pdfEngine = new NativeDocumentEngine();\n this.textEngine = new NativeTextDocumentEngine();\n this.comicEngine = new NativeComicDocumentEngine();\n this.webEngine = new WebViewDocumentEngine(options);\n this.activeEngine = this.pdfEngine;\n }\n\n getWebViewRuntimeSource(): WebViewRuntimeSource | undefined {\n return this.webEngine.getWebViewRuntimeSource();\n }\n\n getWebViewRuntimeConfig(): WebViewRuntimeConfig | undefined {\n return this.webEngine.getWebViewRuntimeConfig();\n }\n\n getRenderTargetType(): RenderTargetType {\n return this.activeEngine.getRenderTargetType?.() ?? \"canvas\";\n }\n\n getNativeEngineId(): string | null {\n return this.activeEngine === this.pdfEngine\n ? this.pdfEngine.getNativeEngineId()\n : null;\n }\n\n getNativeTextEngineId(): string | null {\n return this.activeEngine === this.textEngine\n ? this.textEngine.getNativeTextEngineId()\n : null;\n }\n\n getNativeTextDocumentGeneration(): number {\n return this.activeEngine === this.textEngine\n ? this.textEngine.getDocumentGeneration()\n : 0;\n }\n\n getNativeComicEngineId(): string | null {\n return this.activeEngine === this.comicEngine\n ? this.comicEngine.getNativeComicEngineId()\n : null;\n }\n\n getNativeComicDocumentGeneration(): number {\n return this.activeEngine === this.comicEngine\n ? this.comicEngine.getDocumentGeneration()\n : 0;\n }\n\n getTextLength(): number {\n return this.activeEngine.getTextLength?.() ?? 0;\n }\n\n getCurrentTextOffset(): number {\n return this.activeEngine.getCurrentTextOffset?.() ?? 0;\n }\n\n goToTextOffset(offset: number): void {\n this.activeEngine.goToTextOffset?.(offset);\n }\n\n getLifecycleStats(): Record<string, number> {\n return {\n ...this.pdfEngine.getLifecycleStats(),\n ...this.webEngine.getLifecycleStats(),\n };\n }\n\n resolveAnnotationTextRange(annotation:Annotation):Promise<{start:number;end:number}|null> {return this.textEngine.resolveAnnotationTextRange(annotation);}\n getWebViewDocumentSessionId(): string { return this.webEngine.getWebViewDocumentSessionId(); }\n syncEpubAnnotations(annotations: Annotation[], documentId?: string, labels?: {comment:string}): Promise<void> { return this.webEngine.syncEpubAnnotations(annotations,documentId,labels); }\n goToAnnotation(annotation: Annotation): void | Promise<void> {\n if (annotation.anchor?.kind === \"epub-cfi\") return this.webEngine.goToAnnotation(annotation);\n if (annotation.anchor?.kind === \"text-range\") return this.textEngine.goToTextOffset(annotation.anchor.start);\n this.activeEngine.goToPage((annotation.anchor?.kind === \"pdf-geometry\" ? annotation.anchor.pageIndex : annotation.pageIndex)+1);\n }\n\n attachWebView(bridge: WebViewBridge): void {\n this.webEngine.attachBridge(bridge);\n }\n\n detachWebView(): void {\n this.webEngine.detachBridge();\n }\n\n handleWebViewMessage(data: string): void {\n this.webEngine.handleMessage(data);\n }\n\n async load(input: DocumentLoadInput): Promise<void> {\n const { source, type, format } = normalizeLoadInput(input);\n const resolvedType = type ?? inferDocumentType(source);\n const generation = ++this.loadGeneration;\n const route = resolveNativeMobileDocumentRoute({\n type: resolvedType,\n format: resolvedType === \"comic\" ? resolveComicFormat(source, format) : undefined,\n platform: Platform.OS,\n nativeModuleAvailable: resolveNativeModule() !== null,\n nativeViewAvailable:\n resolvedType === \"text\"\n ? isPapyrusTextDocumentViewAvailable()\n : resolvedType === \"comic\"\n ? isPapyrusComicDocumentViewAvailable()\n : true,\n });\n const nextEngine =\n route === \"native-pdf\"\n ? this.pdfEngine\n : route === \"native-text\"\n ? this.textEngine\n : route === \"native-comic\"\n ? this.comicEngine\n : this.webEngine;\n\n if (this.activeEngine !== nextEngine) this.activeEngine.destroy();\n this.activeEngine = nextEngine;\n await nextEngine.load({\n type: resolvedType,\n source,\n ...(resolvedType === \"comic\" && format ? { format } : {}),\n });\n if (generation !== this.loadGeneration && this.activeEngine !== nextEngine) {\n return;\n }\n }\n\n getPageCount(): number {\n return this.activeEngine.getPageCount();\n }\n\n getCurrentPage(): number {\n return this.activeEngine.getCurrentPage();\n }\n\n goToPage(page: number): void {\n this.activeEngine.goToPage(page);\n }\n\n setZoom(zoom: number): void {\n this.activeEngine.setZoom(zoom);\n }\n\n getZoom(): number {\n return this.activeEngine.getZoom();\n }\n\n rotate(direction: \"clockwise\" | \"counterclockwise\"): void {\n this.activeEngine.rotate(direction);\n }\n\n getRotation(): number {\n return this.activeEngine.getRotation();\n }\n\n async renderPage(\n pageIndex: number,\n target: any,\n scale: number,\n telemetry?: RenderPageTelemetryContext\n ): Promise<void> {\n await this.activeEngine.renderPage(pageIndex, target, scale, telemetry);\n }\n\n async renderTextLayer(\n pageIndex: number,\n container: any,\n scale: number\n ): Promise<void> {\n await this.activeEngine.renderTextLayer(pageIndex, container, scale);\n }\n\n async getTextContent(pageIndex: number): Promise<TextItem[]> {\n return await this.activeEngine.getTextContent(pageIndex);\n }\n\n async getPageDimensions(\n pageIndex: number\n ): Promise<{ width: number; height: number }> {\n return await this.activeEngine.getPageDimensions(pageIndex);\n }\n\n async getPagePreview(pageIndex: number): Promise<string | null> {\n const engine = this.activeEngine as DocumentEngine & {\n getPagePreview?: (pageIndex: number) => Promise<string | null>;\n };\n return (await engine.getPagePreview?.(pageIndex)) ?? null;\n }\n\n async searchText(query: string): Promise<SearchResult[]> {\n if (typeof this.activeEngine.searchText === \"function\") {\n return await this.activeEngine.searchText(query);\n }\n return [];\n }\n\n async searchTextRanges(query: string): Promise<TextSearchResult[]> {\n if (typeof this.activeEngine.searchTextRanges === \"function\") {\n return await this.activeEngine.searchTextRanges(query);\n }\n return [];\n }\n\n async selectText(\n pageIndex: number,\n rect: { x: number; y: number; width: number; height: number },\n endpoints?: TextSelectionEndpoints\n ): Promise<TextSelection | null> {\n if (typeof this.activeEngine.selectText === \"function\") {\n return await this.activeEngine.selectText(pageIndex, rect, endpoints);\n }\n return null;\n }\n\n async getOutline(): Promise<OutlineItem[]> {\n return await this.activeEngine.getOutline();\n }\n\n async getPageIndex(dest: PageDestination): Promise<number | null> {\n return await this.activeEngine.getPageIndex(dest);\n }\n\n destroy(): void {\n this.loadGeneration += 1;\n this.pdfEngine.destroy();\n this.textEngine.destroy();\n this.comicEngine.destroy();\n this.webEngine.destroy();\n }\n}\n","import type {\n ComicFormat,\n DocumentSource,\n DocumentType,\n} from \"@papyrus-sdk/types\";\n\nconst parseDataUri = (\n value: string\n): { mime: string; isBase64: boolean; data: string } | null => {\n const match = /^data:([^;,]+)?(;base64)?,(.*)$/.exec(value);\n if (!match) return null;\n return {\n mime: match[1] ?? \"\",\n isBase64: Boolean(match[2]),\n data: match[3] ?? \"\",\n };\n};\n\nconst typeFromExtension = (value: string): DocumentType | null => {\n const clean = value.split(\"?\")[0].split(\"#\")[0].toLowerCase();\n const extension = clean.includes(\".\")\n ? clean.split(\".\").pop()\n : undefined;\n\n if (extension === \"epub\") return \"epub\";\n if (extension === \"txt\") return \"text\";\n if (extension === \"pdf\") return \"pdf\";\n if (extension === \"cbz\" || extension === \"cbr\") return \"comic\";\n return null;\n};\n\nexport const inferComicFormat = (source: DocumentSource): ComicFormat => {\n const candidate =\n typeof source === \"string\"\n ? source\n : typeof source === \"object\" && source !== null && \"uri\" in source\n ? source.uri\n : \"\";\n const dataUri = parseDataUri(candidate);\n const mime = dataUri?.mime.toLowerCase() ?? \"\";\n if (mime.includes(\"rar\") || /\\.cbr(?:$|[?#])/i.test(candidate)) {\n return \"cbr\";\n }\n return \"cbz\";\n};\n\nexport const resolveComicFormat = (\n source: DocumentSource,\n explicitFormat?: ComicFormat\n): ComicFormat => explicitFormat ?? inferComicFormat(source);\n\nexport const inferDocumentType = (source: DocumentSource): DocumentType => {\n if (typeof source === \"string\") {\n const dataUri = parseDataUri(source);\n if (dataUri?.mime) {\n const mime = dataUri.mime.toLowerCase();\n if (mime.includes(\"epub\")) return \"epub\";\n if (\n mime.includes(\"comicbook\") ||\n mime.includes(\"zip\") ||\n mime.includes(\"rar\")\n ) {\n return \"comic\";\n }\n if (mime.includes(\"text\")) return \"text\";\n if (mime.includes(\"pdf\")) return \"pdf\";\n }\n\n return typeFromExtension(source) ?? \"pdf\";\n }\n\n if (typeof source === \"object\" && source !== null && \"uri\" in source) {\n return typeFromExtension(source.uri) ?? \"pdf\";\n }\n\n return \"pdf\";\n};\n","type NativeModuleRegistry = Record<string, unknown>;\n\ntype ModuleRegistry = {\n nativeModules: NativeModuleRegistry;\n turboModuleRegistry: { get: (name: string) => unknown };\n};\n\nexport const resolvePapyrusNativeModule = <T>(\n registries: ModuleRegistry,\n): T | null => {\n const turboModule = registries.turboModuleRegistry.get(\n \"PapyrusNativeEngine\",\n ) as T | null;\n if (turboModule) return turboModule;\n\n return (registries.nativeModules.PapyrusNativeEngine as T | undefined) ?? null;\n};\n","export type NativeViewManagerRegistry = {\n hasViewManagerConfig?: (name: string) => boolean;\n};\n\nexport const isNativeViewManagerRegistered = (\n registry: NativeViewManagerRegistry,\n managerName: string\n): boolean => {\n if (typeof registry.hasViewManagerConfig !== \"function\") return false;\n\n try {\n return registry.hasViewManagerConfig(managerName);\n } catch {\n return false;\n }\n};\n","export type TextRange = { start: number; end: number };\n\ntype NormalizedText = {\n value: string;\n sourceRanges: TextRange[];\n};\n\nconst decodeWith = (bytes: Uint8Array, encoding: string): string => {\n try {\n return new TextDecoder(encoding, { fatal: true }).decode(bytes);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new Error(`Invalid text encoding (${encoding}): ${message}`);\n }\n};\n\nexport const decodeTextBytes = (input: Uint8Array): string => {\n const bytes = input;\n if (\n bytes.length >= 4 &&\n ((bytes[0] === 0xff && bytes[1] === 0xfe && bytes[2] === 0 && bytes[3] === 0) ||\n (bytes[0] === 0 && bytes[1] === 0 && bytes[2] === 0xfe && bytes[3] === 0xff))\n ) {\n throw new Error(\"Invalid text encoding: UTF-32 is not supported\");\n }\n\n if (bytes.length >= 2 && bytes[0] === 0xff && bytes[1] === 0xfe) {\n return decodeWith(bytes.subarray(2), \"utf-16le\");\n }\n if (bytes.length >= 2 && bytes[0] === 0xfe && bytes[1] === 0xff) {\n const swapped = new Uint8Array(bytes.length - 2);\n for (let index = 2; index + 1 < bytes.length; index += 2) {\n swapped[index - 2] = bytes[index + 1];\n swapped[index - 1] = bytes[index];\n }\n if ((bytes.length - 2) % 2 !== 0) {\n throw new Error(\"Invalid text encoding: incomplete UTF-16BE code unit\");\n }\n return decodeWith(swapped, \"utf-16le\");\n }\n\n const utf8 = bytes.length >= 3 &&\n bytes[0] === 0xef && bytes[1] === 0xbb && bytes[2] === 0xbf\n ? bytes.subarray(3)\n : bytes;\n return decodeWith(utf8, \"utf-8\");\n};\n\nconst isMark = (value: string): boolean => /\\p{M}/u.test(value);\n\nconst normalizeWithSourceRanges = (source: string): NormalizedText => {\n let value = \"\";\n const sourceRanges: TextRange[] = [];\n let pendingSpace: TextRange | null = null;\n\n for (let offset = 0; offset < source.length;) {\n const start = offset;\n let codePoint = source.codePointAt(offset);\n if (codePoint === undefined) break;\n let cluster = String.fromCodePoint(codePoint);\n offset += cluster.length;\n\n while (offset < source.length) {\n codePoint = source.codePointAt(offset);\n if (codePoint === undefined) break;\n const next = String.fromCodePoint(codePoint);\n if (!isMark(next)) break;\n cluster += next;\n offset += next.length;\n }\n\n const end = offset;\n const normalized = cluster\n .normalize(\"NFD\")\n .replace(/\\p{M}/gu, \"\")\n .toLowerCase();\n\n if (!normalized) continue;\n if (/^\\s+$/u.test(normalized)) {\n if (pendingSpace) pendingSpace.end = end;\n else pendingSpace = { start, end };\n continue;\n }\n\n if (pendingSpace && value.length > 0) {\n value += \" \";\n sourceRanges.push(pendingSpace);\n }\n pendingSpace = null;\n\n value += normalized;\n for (let index = 0; index < normalized.length; index += 1) {\n sourceRanges.push({ start, end });\n }\n }\n\n if (pendingSpace && value.length > 0) {\n value += \" \";\n sourceRanges.push(pendingSpace);\n }\n\n return { value, sourceRanges };\n};\n\nconst normalizeQuery = (query: string): string =>\n query\n .normalize(\"NFD\")\n .replace(/\\p{M}/gu, \"\")\n .toLowerCase()\n .replace(/\\s+/gu, \" \")\n .trim();\n\nexport const findTextRanges = (source: string, query: string): TextRange[] => {\n const normalizedQuery = normalizeQuery(query);\n if (!normalizedQuery) return [];\n\n const normalizedSource = normalizeWithSourceRanges(source);\n const matches: TextRange[] = [];\n let matchAt = normalizedSource.value.indexOf(normalizedQuery);\n while (matchAt !== -1) {\n const first = normalizedSource.sourceRanges[matchAt];\n const last = normalizedSource.sourceRanges[\n matchAt + normalizedQuery.length - 1\n ];\n if (first && last) {\n matches.push({ start: first.start, end: last.end });\n }\n matchAt = normalizedSource.value.indexOf(\n normalizedQuery,\n matchAt + 1\n );\n }\n return matches;\n};\n\nexport const clampTextOffset = (offset: number, textLength: number): number => {\n const max = Math.max(0, Math.floor(Number.isFinite(textLength) ? textLength : 0));\n return Math.max(0, Math.min(max, Math.floor(Number.isFinite(offset) ? offset : 0)));\n};\n\nexport const textOffsetProgress = (offset: number, textLength: number): number =>\n textLength > 0 ? clampTextOffset(offset, textLength) / textLength : 0;\n","import type { ComicFormat, DocumentType } from \"@papyrus-sdk/types\";\n\nexport type NativeMobileDocumentRoute =\n | \"native-pdf\"\n | \"native-text\"\n | \"native-comic\"\n | \"webview\";\n\nexport type NativeMobileDocumentRouteInput = {\n type: DocumentType;\n format?: ComicFormat;\n platform?: \"ios\" | \"android\" | \"web\" | string;\n nativeModuleAvailable?: boolean;\n nativeViewAvailable?: boolean;\n};\n\nexport const resolveNativeMobileDocumentRoute = ({\n type,\n platform,\n nativeModuleAvailable = false,\n nativeViewAvailable = false,\n}: NativeMobileDocumentRouteInput): NativeMobileDocumentRoute => {\n if (type === \"pdf\") return \"native-pdf\";\n if (type === \"epub\") return \"webview\";\n\n const supportedMobilePlatform = platform === \"ios\" || platform === \"android\";\n if (\n !supportedMobilePlatform ||\n !nativeModuleAvailable ||\n !nativeViewAvailable\n ) {\n return \"webview\";\n }\n\n return type === \"text\" ? \"native-text\" : \"native-comic\";\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAQO;AACP,kBAAkD;AAClD,mBA4BO;;;ACjCP,IAAM,eAAe,CACnB,UAC6D;AAC7D,QAAM,QAAQ,kCAAkC,KAAK,KAAK;AAC1D,MAAI,CAAC,MAAO,QAAO;AACnB,SAAO;AAAA,IACL,MAAM,MAAM,CAAC,KAAK;AAAA,IAClB,UAAU,QAAQ,MAAM,CAAC,CAAC;AAAA,IAC1B,MAAM,MAAM,CAAC,KAAK;AAAA,EACpB;AACF;AAEA,IAAM,oBAAoB,CAAC,UAAuC;AAChE,QAAM,QAAQ,MAAM,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,EAAE,YAAY;AAC5D,QAAM,YAAY,MAAM,SAAS,GAAG,IAChC,MAAM,MAAM,GAAG,EAAE,IAAI,IACrB;AAEJ,MAAI,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EA,UAAgB;AACd,SAAK,kBAAkB;AACvB,SAAK,UAAU,QAAQ;AACvB,SAAK,WAAW,QAAQ;AACxB,SAAK,YAAY,QAAQ;AACzB,SAAK,UAAU,QAAQ;AAAA,EACzB;AACF;","names":["parseDataUri"]}
1
+ {"version":3,"sources":["../index.ts","../documentType.ts","../nativeModuleResolution.ts"],"sourcesContent":["import type { ComponentType, RefAttributes } from \"react\";\nimport {\n NativeModules,\n Platform,\n TurboModuleRegistry,\n requireNativeComponent,\n View,\n type ViewProps,\n} from \"react-native\";\nimport { BaseDocumentEngine, papyrusEvents } from \"@papyrus-sdk/core\";\nimport {\n DocumentLoadInput,\n DocumentLoadRequest,\n DocumentEngine,\n DocumentSource,\n DocumentType,\n ComicFormat,\n PageDestination,\n PapyrusEventType,\n RenderTargetType,\n TextItem,\n OutlineItem,\n FileLike,\n SearchResult,\n TextSelection,\n TextSelectionEndpoints,\n RenderPageResult,\n RenderPageTelemetryContext,\n PageTheme,\n Annotation,\n PdfVisiblePage,\n} from \"@papyrus-sdk/types\";\nimport { inferDocumentType, resolveComicFormat } from \"./documentType\";\nimport { resolvePapyrusNativeModule } from \"./nativeModuleResolution\";\n\nconst MODULE_NAME = \"PapyrusNativeEngine\";\n\nconst BASE64_CHARS =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\nconst BASE64_LOOKUP = (() => {\n const table = new Uint8Array(256);\n table.fill(255);\n for (let i = 0; i < BASE64_CHARS.length; i += 1) {\n table[BASE64_CHARS.charCodeAt(i)] = i;\n }\n return table;\n})();\n\nconst parseDataUri = (\n value: string\n): { mime: string; isBase64: boolean; data: string } | null => {\n const match = /^data:([^;,]+)?(;base64)?,(.*)$/.exec(value);\n if (!match) return null;\n return {\n mime: match[1] ?? \"\",\n isBase64: Boolean(match[2]),\n data: match[3] ?? \"\",\n };\n};\n\nconst looksLikeUri = (value: string): boolean =>\n value.startsWith(\"http://\") ||\n value.startsWith(\"https://\") ||\n value.startsWith(\"/\") ||\n value.startsWith(\"./\") ||\n value.startsWith(\"../\") ||\n value.startsWith(\"file://\") ||\n value.startsWith(\"content://\") ||\n value.startsWith(\"android.resource://\");\n\nconst isLikelyBase64 = (value: string): boolean => {\n if (looksLikeUri(value)) return false;\n if (value.includes(\".\")) return false;\n if (value.length < 16) return false;\n return /^[A-Za-z0-9+/=]+$/.test(value);\n};\n\nconst isHttpUri = (value: string): boolean =>\n value.startsWith(\"http://\") || value.startsWith(\"https://\");\n\n// Metro serves bundled React Native assets over the development server. Keep\n// those URIs intact so the WebView can stream them directly instead of\n// downloading the whole EPUB/CBR through the RN bridge first.\nconst isMetroAssetUri = (value: string): boolean => {\n try {\n const url = new URL(value);\n return (\n (url.protocol === \"http:\" || url.protocol === \"https:\") &&\n url.pathname.startsWith(\"/assets/\") &&\n url.searchParams.has(\"platform\") &&\n url.searchParams.has(\"hash\")\n );\n } catch {\n return false;\n }\n};\n\nconst isLocalUri = (value: string): boolean =>\n value.startsWith(\"content://\") ||\n value.startsWith(\"file://\") ||\n value.startsWith(\"android.resource://\");\n\nconst decodeBase64 = (value: string): Uint8Array => {\n const clean = value.replace(/[^A-Za-z0-9+/=]/g, \"\");\n const padding = clean.endsWith(\"==\") ? 2 : clean.endsWith(\"=\") ? 1 : 0;\n const outputLength = Math.max(0, (clean.length * 3) / 4 - padding);\n const output = new Uint8Array(outputLength);\n\n let buffer = 0;\n let bits = 0;\n let index = 0;\n\n for (let i = 0; i < clean.length; i += 1) {\n const charCode = clean.charCodeAt(i);\n if (charCode === 61) break;\n const valueIndex = BASE64_LOOKUP[charCode];\n if (valueIndex === 255) continue;\n buffer = (buffer << 6) | valueIndex;\n bits += 6;\n if (bits >= 8) {\n bits -= 8;\n output[index++] = (buffer >> bits) & 0xff;\n }\n }\n return output;\n};\n\nconst encodeBase64 = (bytes: Uint8Array): string => {\n let output = \"\";\n let buffer = 0;\n let bits = 0;\n\n for (let i = 0; i < bytes.length; i += 1) {\n buffer = (buffer << 8) | bytes[i];\n bits += 8;\n while (bits >= 6) {\n bits -= 6;\n output += BASE64_CHARS[(buffer >> bits) & 0x3f];\n }\n }\n\n if (bits > 0) {\n output += BASE64_CHARS[(buffer << (6 - bits)) & 0x3f];\n }\n\n const remainder = bytes.length % 3;\n if (remainder === 1) return `${output}==`;\n if (remainder === 2) return `${output}=`;\n return output;\n};\n\nconst isLoadRequest = (\n input: DocumentLoadInput\n): input is DocumentLoadRequest =>\n typeof input === \"object\" &&\n input !== null &&\n \"source\" in input &&\n \"type\" in input;\n\nconst normalizeLoadInput = (\n input: DocumentLoadInput\n): { source: DocumentSource; type?: DocumentType; format?: ComicFormat } =>\n isLoadRequest(input)\n ? { source: input.source, type: input.type, format: input.format }\n : { source: input };\n\ntype NativeDocumentSource = {\n uri?: string;\n data?: Uint8Array;\n};\n\ntype NativePageDestination = {\n kind: \"pageIndex\" | \"pageNumber\" | \"named\";\n value: number | string;\n};\n\nconst normalizeNativeDestination = (\n dest: PageDestination\n): NativePageDestination | null => {\n if (!dest) return null;\n if (typeof dest === \"string\") {\n return { kind: \"named\", value: dest };\n }\n\n if (\n dest.kind === \"pageIndex\" ||\n dest.kind === \"pageNumber\" ||\n dest.kind === \"named\"\n ) {\n return { kind: dest.kind, value: dest.value };\n }\n\n return null;\n};\n\ntype NativeEngineModule = {\n createEngine?: () => string;\n isTablet?: () => boolean;\n destroyEngine?: (engineId: string) => void;\n load?: (\n engineId: string,\n source: NativeDocumentSource\n ) => Promise<{ pageCount?: number } | void>;\n getPageCount?: (engineId: string) => number;\n getLifecycleStats?: () => Record<string, number>;\n renderPage?: (\n engineId: string,\n pageIndex: number,\n target: number,\n scale: number,\n zoom: number,\n rotation: number,\n requestId: string,\n telemetry?: RenderPageTelemetryContext\n ) => Promise<RenderPageResult>;\n renderTextLayer?: (\n engineId: string,\n pageIndex: number,\n target: number,\n scale: number,\n zoom: number,\n rotation: number\n ) => void;\n getTextContent?: (engineId: string, pageIndex: number) => Promise<TextItem[]>;\n getPageDimensions?: (\n engineId: string,\n pageIndex: number\n ) => Promise<{ width: number; height: number }>;\n searchText?: (engineId: string, query: string) => Promise<SearchResult[]>;\n selectText?: (\n engineId: string,\n pageIndex: number,\n x: number,\n y: number,\n width: number,\n height: number,\n startX: number,\n startY: number,\n endX: number,\n endY: number\n ) => Promise<TextSelection | null>;\n getOutline?: (engineId: string) => Promise<OutlineItem[]>;\n getPageIndex?: (\n engineId: string,\n dest: NativePageDestination\n ) => Promise<number | null>;\n readFileChunk?: (\n uri: string,\n offset: number,\n length: number\n ) => Promise<{ data: string; done: boolean }>;\n};\n\nexport type PapyrusPageViewProps = ViewProps & {\n engineId?: string;\n pageTheme?: PageTheme;\n};\n\nexport type PapyrusPdfViewerViewProps = ViewProps & {\n engineId?: string;\n pageTheme?: PageTheme;\n zoom?: number;\n currentPage?: number;\n activeTool?: string;\n annotationColor?: string;\n inkStrokeWidth?: number;\n annotationOpacity?: number;\n searchResults?: SearchResult[];\n annotations?: Annotation[];\n onPageChanged?: (event: { nativeEvent: { page: number } }) => void;\n onZoomChanged?: (event: { nativeEvent: { zoom: number } }) => void;\n onPageChange?: (event: { nativeEvent: { page: number } }) => void;\n onZoomChange?: (event: { nativeEvent: { zoom: number } }) => void;\n onVisiblePagesChange?: (event: { nativeEvent: { pages: PdfVisiblePage[] } }) => void;\n onAnnotationCreated?: (event: { nativeEvent: Annotation }) => void;\n onTap?: (event: { nativeEvent: { pageIndex: number; x: number; y: number } }) => void;\n onAnnotationTap?: (event: { nativeEvent: { id: string; pageIndex: number; type: string; color: string } }) => void;\n onTextSelected?: (event: { nativeEvent: { text: string; pageIndex: number; rects: { x: number; y: number; width: number; height: number }[] } }) => void;\n onScroll?: (event: { nativeEvent: { offsetY: number } }) => void;\n selectionActive?: boolean;\n viewMode?: \"continuous\" | \"single\";\n};\n\ntype PapyrusPageViewComponent = ComponentType<\n PapyrusPageViewProps & RefAttributes<View>\n>;\n\ntype PapyrusPdfViewerViewComponent = ComponentType<\n PapyrusPdfViewerViewProps & RefAttributes<View>\n>;\n\nconst resolveNativeModule = (): NativeEngineModule | null => {\n return resolvePapyrusNativeModule<NativeEngineModule>({\n nativeModules: NativeModules as Record<string, unknown>,\n turboModuleRegistry: TurboModuleRegistry,\n });\n};\n\nlet cachedAndroidTabletFormFactor: boolean | undefined;\n\nexport const isPapyrusTablet = (): boolean => {\n if (Platform.OS === \"ios\") return Platform.isPad;\n if (Platform.OS !== \"android\") return false;\n if (cachedAndroidTabletFormFactor !== undefined) {\n return cachedAndroidTabletFormFactor;\n }\n\n try {\n cachedAndroidTabletFormFactor = resolveNativeModule()?.isTablet?.() === true;\n } catch {\n cachedAndroidTabletFormFactor = false;\n }\n\n return cachedAndroidTabletFormFactor;\n};\n\nconst resolvePapyrusPageView = (): PapyrusPageViewComponent => {\n try {\n return requireNativeComponent<PapyrusPageViewProps>(\n \"PapyrusPageView\"\n ) as unknown as PapyrusPageViewComponent;\n } catch {\n return View as unknown as PapyrusPageViewComponent;\n }\n};\n\nconst resolvePapyrusPdfViewerView = (): PapyrusPdfViewerViewComponent => {\n const componentName =\n Platform.OS === \"ios\" ? \"PapyrusPdfDocumentView\" : \"PapyrusPdfViewerView\";\n try {\n return requireNativeComponent<PapyrusPdfViewerViewProps>(\n componentName\n ) as unknown as PapyrusPdfViewerViewComponent;\n } catch {\n return View as unknown as PapyrusPdfViewerViewComponent;\n }\n};\n\nexport const PapyrusPageView = resolvePapyrusPageView();\nexport const PapyrusPdfViewerView = resolvePapyrusPdfViewerView();\nexport const PapyrusPdfDocumentView = PapyrusPdfViewerView;\n\nexport class NativeDocumentEngine extends BaseDocumentEngine {\n private nativeModule: NativeEngineModule | null = null;\n private engineId: string = \"default\";\n private pageCount: number = 0;\n private currentPage: number = 1;\n private zoom: number = 1.0;\n private rotation: number = 0;\n private renderRequestCounter: number = 0;\n\n constructor() {\n super();\n this.nativeModule = resolveNativeModule();\n this.engineId = this.nativeModule?.createEngine\n ? this.nativeModule.createEngine()\n : \"default\";\n }\n\n async load(input: DocumentLoadInput): Promise<void> {\n const { source, type } = normalizeLoadInput(input);\n if (type && type !== \"pdf\") {\n throw new Error(\n `[NativeDocumentEngine] Tipo de documento não suportado: ${type}`\n );\n }\n\n const native = this.assertNativeModule();\n const normalized = await this.normalizeSource(source);\n let result;\n try {\n result = native.load\n ? await native.load(this.engineId, normalized)\n : undefined;\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n if (\n !/engine not found|papyrus_no_engine/i.test(message) ||\n !native.createEngine\n ) {\n throw error;\n }\n\n // Fast Refresh can preserve this JS instance after the native store was\n // recreated. Recover the stale id once instead of surfacing a redbox.\n this.engineId = native.createEngine();\n result = native.load\n ? await native.load(this.engineId, normalized)\n : undefined;\n }\n\n if (result && typeof result.pageCount === \"number\") {\n this.pageCount = result.pageCount;\n } else if (native.getPageCount) {\n this.pageCount = native.getPageCount(this.engineId);\n } else {\n this.pageCount = 0;\n }\n\n this.currentPage = 1;\n }\n\n getPageCount(): number {\n return this.pageCount;\n }\n\n getLifecycleStats(): Record<string, number> {\n return this.nativeModule?.getLifecycleStats?.() ?? {};\n }\n\n getCurrentPage(): number {\n return this.currentPage;\n }\n\n goToPage(page: number): void {\n if (page >= 1 && page <= this.pageCount) {\n this.currentPage = page;\n }\n }\n\n setZoom(zoom: number): void {\n this.zoom = Math.max(0.1, Math.min(5.0, zoom));\n }\n\n getZoom(): number {\n return this.zoom;\n }\n\n rotate(direction: \"clockwise\" | \"counterclockwise\"): void {\n if (direction === \"clockwise\") {\n this.rotation = (this.rotation + 90) % 360;\n } else {\n this.rotation = (this.rotation - 90) % 360;\n if (this.rotation < 0) this.rotation += 360;\n }\n }\n\n getRotation(): number {\n return this.rotation;\n }\n\n getNativeEngineId(): string {\n return this.engineId;\n }\n\n async renderPage(\n pageIndex: number,\n target: any,\n scale: number,\n telemetry?: RenderPageTelemetryContext\n ): Promise<void | RenderPageResult> {\n const native = this.assertNativeModule();\n if (!native.renderPage) return;\n const viewTag = this.toNativeViewTag(target);\n if (viewTag === null) return;\n const requestId = `native-render-${++this.renderRequestCounter}`;\n return native.renderPage(\n this.engineId,\n pageIndex,\n viewTag,\n scale,\n this.zoom,\n this.rotation,\n requestId,\n telemetry\n );\n }\n\n async renderTextLayer(\n pageIndex: number,\n target: any,\n scale: number\n ): Promise<void> {\n const native = this.assertNativeModule();\n if (!native.renderTextLayer) return;\n const viewTag = this.toNativeViewTag(target);\n if (viewTag === null) return;\n native.renderTextLayer(\n this.engineId,\n pageIndex,\n viewTag,\n scale,\n this.zoom,\n this.rotation\n );\n }\n\n async getTextContent(pageIndex: number): Promise<TextItem[]> {\n const native = this.assertNativeModule();\n if (!native.getTextContent) return [];\n return native.getTextContent(this.engineId, pageIndex);\n }\n\n async getPageDimensions(\n pageIndex: number\n ): Promise<{ width: number; height: number }> {\n const native = this.assertNativeModule();\n if (!native.getPageDimensions) return { width: 0, height: 0 };\n return native.getPageDimensions(this.engineId, pageIndex);\n }\n\n async selectText(\n pageIndex: number,\n rect: { x: number; y: number; width: number; height: number },\n endpoints?: TextSelectionEndpoints\n ): Promise<TextSelection | null> {\n const native = this.assertNativeModule();\n if (!native.selectText) return null;\n return native.selectText(\n this.engineId,\n pageIndex,\n rect.x,\n rect.y,\n rect.width,\n rect.height,\n endpoints?.start.x ?? -1,\n endpoints?.start.y ?? -1,\n endpoints?.end.x ?? -1,\n endpoints?.end.y ?? -1\n );\n }\n\n async getOutline(): Promise<OutlineItem[]> {\n const native = this.assertNativeModule();\n if (!native.getOutline) return [];\n return native.getOutline(this.engineId);\n }\n\n async searchText(query: string): Promise<SearchResult[]> {\n const native = this.assertNativeModule();\n if (!native.searchText) return [];\n return native.searchText(this.engineId, query);\n }\n\n async getPageIndex(dest: PageDestination): Promise<number | null> {\n if (!dest) return null;\n if (typeof dest !== \"string\") {\n if (dest.kind === \"pageIndex\") return dest.value;\n if (dest.kind === \"pageNumber\") return Math.max(0, dest.value - 1);\n }\n\n const native = this.assertNativeModule();\n if (!native.getPageIndex) return null;\n const normalized = normalizeNativeDestination(dest);\n if (!normalized || normalized.kind !== \"named\") return null;\n return native.getPageIndex(this.engineId, normalized);\n }\n\n destroy(): void {\n this.nativeModule?.destroyEngine?.(this.engineId);\n }\n\n private assertNativeModule(): NativeEngineModule {\n if (!this.nativeModule) {\n this.nativeModule = resolveNativeModule();\n }\n if (!this.nativeModule) {\n throw new Error(\n `[Papyrus] Native module \"${MODULE_NAME}\" not found. Use a dev client or a native build (Expo Go is not supported).`\n );\n }\n return this.nativeModule;\n }\n\n private async normalizeSource(\n source: DocumentSource\n ): Promise<NativeDocumentSource> {\n if (typeof source === \"string\") {\n const dataUri = parseDataUri(source);\n if (dataUri?.isBase64) {\n return { data: decodeBase64(dataUri.data) };\n }\n if (looksLikeUri(source)) return { uri: source };\n if (isLikelyBase64(source)) return { data: decodeBase64(source) };\n return { uri: source };\n }\n if (this.isUriSource(source)) return { uri: source.uri };\n if (this.isDataSource(source)) {\n const data =\n source.data instanceof Uint8Array\n ? source.data\n : new Uint8Array(source.data);\n return { data };\n }\n if (this.isFileLike(source)) {\n const buffer = await source.arrayBuffer();\n return { data: new Uint8Array(buffer) };\n }\n if (source instanceof ArrayBuffer) return { data: new Uint8Array(source) };\n if (source instanceof Uint8Array) return { data: source };\n return { data: new Uint8Array(source as ArrayBuffer) };\n }\n\n private isUriSource(source: DocumentSource): source is { uri: string } {\n return typeof source === \"object\" && source !== null && \"uri\" in source;\n }\n\n private isDataSource(\n source: DocumentSource\n ): source is { data: ArrayBuffer | Uint8Array } {\n return typeof source === \"object\" && source !== null && \"data\" in source;\n }\n\n private isFileLike(source: DocumentSource): source is FileLike {\n return (\n typeof source === \"object\" &&\n source !== null &&\n typeof (source as FileLike).arrayBuffer === \"function\"\n );\n }\n\n private toNativeViewTag(target: any): number | null {\n if (typeof target === \"number\") return target;\n if (target?.nativeTag && typeof target.nativeTag === \"number\")\n return target.nativeTag;\n return null;\n }\n}\n\ntype WebViewBridge = {\n postMessage: (message: string) => void;\n};\n\ntype Deferred<T> = {\n resolve: (value: T) => void;\n reject: (error: Error) => void;\n};\n\nexport type WebViewRuntimeSource =\n | string\n | number\n | { uri: string };\n\nexport type WebViewRuntimeConfig = Record<string, string>;\n\nexport type MobileDocumentEngineOptions = {\n /** Optional asset URI/require result for a runtime extension such as CBR. */\n webViewRuntimeSource?: WebViewRuntimeSource;\n webViewRuntimeConfig?: WebViewRuntimeConfig;\n};\n\ntype WebViewResponseMessage = {\n type: \"response\";\n id: string;\n ok: boolean;\n data?: any;\n error?: string;\n};\n\ntype WebViewEventMessage = {\n type: \"event\";\n name: string;\n payload?: any;\n};\n\ntype WebViewStateMessage = {\n type: \"state\";\n payload: {\n pageCount?: number;\n currentPage?: number;\n zoom?: number;\n outline?: OutlineItem[];\n };\n};\n\ntype WebViewAssetRequestMessage = {\n type: \"asset-request\";\n id: string;\n url: string;\n encoding: \"text\" | \"base64\";\n};\n\ntype WebViewFileChunkRequestMessage = {\n type: \"file-chunk-request\";\n id: string;\n uri: string;\n offset: number;\n length: number;\n};\n\ntype WebViewReadyMessage = {\n type: \"ready\";\n};\n\ntype WebViewRuntimeMessage =\n | WebViewResponseMessage\n | WebViewEventMessage\n | WebViewStateMessage\n | WebViewAssetRequestMessage\n | WebViewFileChunkRequestMessage\n | WebViewReadyMessage;\n\ntype WebViewSourcePayload =\n | { kind: \"uri\"; uri: string }\n | { kind: \"base64\"; data: string; mime?: string }\n | { kind: \"text\"; text: string };\n\nexport class WebViewDocumentEngine extends BaseDocumentEngine {\n private readonly webViewRuntimeSource?: WebViewRuntimeSource;\n private readonly webViewRuntimeConfig?: WebViewRuntimeConfig;\n private bridge: WebViewBridge | null = null;\n private ready = false;\n private requestId = 0;\n private pending = new Map<\n string,\n { resolve: (data: any) => void; reject: (error: Error) => void }\n >();\n private bridgeResolvers: Array<Deferred<WebViewBridge>> = [];\n private readyResolvers: Array<Deferred<void>> = [];\n private pageCount = 0;\n private currentPage = 1;\n private zoom = 1.0;\n private rotation = 0;\n private outline: OutlineItem[] = [];\n\n constructor(options: MobileDocumentEngineOptions = {}) {\n super();\n this.webViewRuntimeSource = options.webViewRuntimeSource;\n this.webViewRuntimeConfig = options.webViewRuntimeConfig;\n }\n\n getWebViewRuntimeSource(): WebViewRuntimeSource | undefined {\n return this.webViewRuntimeSource;\n }\n\n getWebViewRuntimeConfig(): WebViewRuntimeConfig | undefined {\n return this.webViewRuntimeConfig;\n }\n\n getRenderTargetType(): \"webview\" {\n return \"webview\";\n }\n\n getLifecycleStats(): Record<string, number> {\n return {\n webViewCount: this.bridge ? 1 : 0,\n pendingBridgeRequests: this.pending.size,\n };\n }\n\n attachBridge(bridge: WebViewBridge): void {\n this.bridge = bridge;\n this.ready = false;\n this.bridgeResolvers.forEach(({ resolve }) => resolve(bridge));\n this.bridgeResolvers = [];\n }\n\n detachBridge(): void {\n const error = new Error(\"[Papyrus] WebView detached\");\n this.pending.forEach(({ reject }) => reject(error));\n this.pending.clear();\n this.bridgeResolvers.forEach(({ reject }) => reject(error));\n this.readyResolvers.forEach(({ reject }) => reject(error));\n this.bridgeResolvers = [];\n this.readyResolvers = [];\n this.bridge = null;\n this.ready = false;\n }\n\n handleMessage(raw: string): void {\n let message: WebViewRuntimeMessage | null = null;\n try {\n message = JSON.parse(raw) as WebViewRuntimeMessage;\n } catch {\n return;\n }\n\n if (!message) return;\n\n if (message.type === \"asset-request\") {\n void this.handleAssetRequest(message);\n return;\n }\n\n if (message.type === \"file-chunk-request\") {\n void this.handleFileChunkRequest(message);\n return;\n }\n\n if (message.type === \"ready\") {\n this.ready = true;\n this.readyResolvers.forEach(({ resolve }) => resolve());\n this.readyResolvers = [];\n return;\n }\n\n if (message.type === \"response\") {\n const pending = this.pending.get(message.id);\n if (!pending) return;\n this.pending.delete(message.id);\n if (message.ok) {\n pending.resolve(message.data);\n } else {\n pending.reject(\n new Error(message.error ?? \"[Papyrus] WebView runtime error\")\n );\n }\n return;\n }\n\n if (message.type === \"state\") {\n if (typeof message.payload.pageCount === \"number\")\n this.pageCount = message.payload.pageCount;\n if (typeof message.payload.currentPage === \"number\")\n this.currentPage = message.payload.currentPage;\n if (typeof message.payload.zoom === \"number\")\n this.zoom = message.payload.zoom;\n if (Array.isArray(message.payload.outline))\n this.outline = message.payload.outline;\n return;\n }\n\n if (message.type === \"event\") {\n const payload = message.payload ?? {};\n if (message.name === \"RUNTIME_LOG\") {\n if (__DEV__) {\n const text =\n typeof payload?.message === \"string\"\n ? payload.message\n : JSON.stringify(payload);\n console.log(\"[Papyrus WebView runtime]\", text);\n }\n return;\n }\n if (message.name === \"RUNTIME_ERROR\") {\n const errorMessage =\n typeof payload?.message === \"string\" ? payload.message : \"\";\n if (errorMessage.includes(\"ResizeObserver loop\")) {\n return;\n }\n if (__DEV__) {\n console.warn(\"[Papyrus WebView runtime]\", payload);\n }\n return;\n }\n if (message.name === PapyrusEventType.TEXT_SELECTED) {\n papyrusEvents.emit(PapyrusEventType.TEXT_SELECTED, payload);\n } else if (message.name === PapyrusEventType.SEARCH_TRIGGERED) {\n papyrusEvents.emit(PapyrusEventType.SEARCH_TRIGGERED, payload);\n } else if (message.name === PapyrusEventType.DOCUMENT_LOADED) {\n if (typeof payload.pageCount === \"number\") {\n this.pageCount = payload.pageCount;\n }\n papyrusEvents.emit(PapyrusEventType.DOCUMENT_LOADED, payload);\n }\n return;\n }\n\n if (__DEV__) {\n console.warn(\"[Papyrus WebView] Unknown message\", message);\n }\n }\n\n private async handleAssetRequest(\n message: WebViewAssetRequestMessage,\n ): Promise<void> {\n const bridge = this.bridge;\n if (!bridge) return;\n\n try {\n const response = await fetch(message.url);\n if (!response.ok) {\n throw new Error(`status ${response.status}`);\n }\n\n const data =\n message.encoding === \"text\"\n ? await response.text()\n : `data:application/wasm;base64,${encodeBase64(\n new Uint8Array(await response.arrayBuffer()),\n )}`;\n bridge.postMessage(\n JSON.stringify({\n type: \"asset-response\",\n id: message.id,\n ok: true,\n data,\n }),\n );\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n bridge.postMessage(\n JSON.stringify({\n type: \"asset-response\",\n id: message.id,\n ok: false,\n error: reason,\n }),\n );\n }\n }\n\n private async handleFileChunkRequest(\n message: WebViewFileChunkRequestMessage,\n ): Promise<void> {\n const bridge = this.bridge;\n if (!bridge) return;\n\n try {\n const nativeModule = resolveNativeModule();\n if (!nativeModule?.readFileChunk) {\n throw new Error(\"Leitura nativa de arquivos não está disponível\");\n }\n const result = await nativeModule.readFileChunk(\n message.uri,\n message.offset,\n message.length,\n );\n bridge.postMessage(\n JSON.stringify({\n type: \"file-chunk-response\",\n id: message.id,\n ok: true,\n data: result.data,\n done: result.done,\n }),\n );\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n bridge.postMessage(\n JSON.stringify({\n type: \"file-chunk-response\",\n id: message.id,\n ok: false,\n error: reason,\n }),\n );\n }\n }\n\n async load(input: DocumentLoadInput): Promise<void> {\n const { source, type, format } = normalizeLoadInput(input);\n const resolvedType = type ?? inferDocumentType(source);\n if (resolvedType === \"pdf\") {\n throw new Error(\n \"[WebViewDocumentEngine] Use o NativeDocumentEngine para PDFs no mobile.\"\n );\n }\n\n const payloadSource = await this.normalizeRuntimeSource(\n resolvedType,\n source\n );\n const response = await this.request<{\n pageCount?: number;\n outline?: OutlineItem[];\n }>(\"load\", {\n type: resolvedType,\n source: payloadSource,\n ...(resolvedType === \"comic\"\n ? { format: resolveComicFormat(source, format) }\n : {}),\n });\n\n if (typeof response?.pageCount === \"number\")\n this.pageCount = response.pageCount;\n if (Array.isArray(response?.outline)) this.outline = response.outline;\n this.currentPage = 1;\n }\n\n getPageCount(): number {\n return this.pageCount;\n }\n\n getCurrentPage(): number {\n return this.currentPage;\n }\n\n goToPage(page: number): void {\n if (page < 1) return;\n this.currentPage = page;\n void this.request(\"go-to-page\", { page });\n }\n\n setZoom(zoom: number): void {\n this.zoom = Math.max(0.5, Math.min(4.0, zoom));\n void this.request(\"set-zoom\", { zoom: this.zoom });\n }\n\n getZoom(): number {\n return this.zoom;\n }\n\n rotate(direction: \"clockwise\" | \"counterclockwise\"): void {\n if (direction === \"clockwise\") {\n this.rotation = (this.rotation + 90) % 360;\n } else {\n this.rotation = (this.rotation - 90) % 360;\n if (this.rotation < 0) this.rotation += 360;\n }\n void this.request(\"set-rotation\", { rotation: this.rotation });\n }\n\n getRotation(): number {\n return this.rotation;\n }\n\n async renderPage(\n pageIndex: number,\n target: any,\n scale: number,\n _telemetry?: RenderPageTelemetryContext\n ): Promise<void> {\n void pageIndex;\n void target;\n void scale;\n }\n\n async renderTextLayer(\n pageIndex: number,\n container: any,\n scale: number\n ): Promise<void> {\n void pageIndex;\n void container;\n void scale;\n }\n\n async getTextContent(pageIndex: number): Promise<TextItem[]> {\n return await this.request<TextItem[]>(\"get-text-content\", { pageIndex });\n }\n\n async getPageDimensions(\n pageIndex: number\n ): Promise<{ width: number; height: number }> {\n return await this.request<{ width: number; height: number }>(\n \"get-page-dimensions\",\n { pageIndex }\n );\n }\n\n async getPagePreview(pageIndex: number): Promise<string | null> {\n return await this.request<string | null>(\"get-page-preview\", {\n pageIndex,\n });\n }\n\n async searchText(query: string): Promise<SearchResult[]> {\n return await this.request<SearchResult[]>(\"search-text\", { query });\n }\n\n async selectText(\n pageIndex: number,\n rect: { x: number; y: number; width: number; height: number },\n endpoints?: TextSelectionEndpoints\n ): Promise<TextSelection | null> {\n return await this.request<TextSelection | null>(\"select-text\", {\n pageIndex,\n rect,\n endpoints,\n });\n }\n\n async getOutline(): Promise<OutlineItem[]> {\n if (this.outline.length > 0) return this.outline;\n return await this.request<OutlineItem[]>(\"get-outline\");\n }\n\n async getPageIndex(dest: PageDestination): Promise<number | null> {\n if (!dest) return null;\n if (typeof dest !== \"string\") {\n if (dest.kind === \"pageIndex\") return dest.value;\n if (dest.kind === \"pageNumber\") return Math.max(0, dest.value - 1);\n if (dest.kind === \"href\") {\n return await this.request<number | null>(\"get-page-index\", {\n dest: dest.value,\n });\n }\n return null;\n }\n return await this.request<number | null>(\"get-page-index\", { dest });\n }\n\n destroy(): void {\n this.detachBridge();\n }\n\n private async ensureBridge(): Promise<WebViewBridge> {\n if (this.bridge) return this.bridge;\n return new Promise((resolve, reject) => {\n this.bridgeResolvers.push({ resolve, reject });\n });\n }\n\n private async ensureReady(): Promise<void> {\n if (this.ready) return;\n return new Promise((resolve, reject) => {\n this.readyResolvers.push({ resolve, reject });\n });\n }\n\n private async request<T = any>(kind: string, payload?: any): Promise<T> {\n const bridge = await this.ensureBridge();\n await this.ensureReady();\n const id = `${Date.now()}-${this.requestId++}`;\n return new Promise<T>((resolve, reject) => {\n const timeoutMs =\n kind === \"load\" ? 180000 : kind === \"get-page-preview\" ? 30000 : 8000;\n const timeoutId = setTimeout(() => {\n this.pending.delete(id);\n reject(new Error(`[Papyrus] WebView response timeout: ${kind}`));\n }, timeoutMs);\n this.pending.set(id, {\n resolve: (data) => {\n clearTimeout(timeoutId);\n resolve(data);\n },\n reject: (error) => {\n clearTimeout(timeoutId);\n reject(error);\n },\n });\n bridge.postMessage(JSON.stringify({ id, kind, payload }));\n });\n }\n\n private async normalizeRuntimeSource(\n type: DocumentType,\n source: DocumentSource\n ): Promise<WebViewSourcePayload> {\n if (typeof source === \"string\") {\n const dataUri = parseDataUri(source);\n if (dataUri) {\n if (dataUri.isBase64) {\n return {\n kind: \"base64\",\n data: dataUri.data,\n mime: dataUri.mime || undefined,\n };\n }\n const text = decodeURIComponent(dataUri.data);\n return { kind: \"text\", text };\n }\n\n if (looksLikeUri(source)) {\n if (isMetroAssetUri(source)) {\n return { kind: \"uri\", uri: source };\n }\n if (isHttpUri(source)) {\n const fetched = await this.fetchRemoteSource(type, source);\n if (fetched) return fetched;\n }\n if (isLocalUri(source)) {\n return await this.fetchLocalSource(type, source);\n }\n return { kind: \"uri\", uri: source };\n }\n\n if (isLikelyBase64(source)) {\n return { kind: \"base64\", data: source };\n }\n\n if (type === \"text\") {\n return { kind: \"text\", text: source };\n }\n\n return { kind: \"uri\", uri: source };\n }\n\n if (this.isUriSource(source)) {\n const uri = source.uri;\n const dataUri = parseDataUri(uri);\n if (dataUri) {\n if (dataUri.isBase64) {\n return {\n kind: \"base64\",\n data: dataUri.data,\n mime: dataUri.mime || undefined,\n };\n }\n return { kind: \"text\", text: decodeURIComponent(dataUri.data) };\n }\n if (isMetroAssetUri(uri)) {\n return { kind: \"uri\", uri };\n }\n if (isHttpUri(uri)) {\n const fetched = await this.fetchRemoteSource(type, uri);\n if (fetched) return fetched;\n }\n if (isLocalUri(uri)) {\n return await this.fetchLocalSource(type, uri);\n }\n return { kind: \"uri\", uri };\n }\n if (this.isDataSource(source)) {\n const bytes =\n source.data instanceof Uint8Array\n ? source.data\n : new Uint8Array(source.data);\n return { kind: \"base64\", data: encodeBase64(bytes) };\n }\n if (this.isFileLike(source)) {\n const buffer = await source.arrayBuffer();\n return { kind: \"base64\", data: encodeBase64(new Uint8Array(buffer)) };\n }\n if (source instanceof ArrayBuffer || source instanceof Uint8Array) {\n const bytes =\n source instanceof Uint8Array ? source : new Uint8Array(source);\n return { kind: \"base64\", data: encodeBase64(bytes) };\n }\n\n return {\n kind: \"base64\",\n data: encodeBase64(new Uint8Array(source as ArrayBuffer)),\n };\n }\n\n private async fetchRemoteSource(\n type: DocumentType,\n uri: string\n ): Promise<WebViewSourcePayload | null> {\n try {\n const response = await fetch(uri);\n if (!response.ok) return null;\n if (type === \"text\") {\n const text = await response.text();\n return { kind: \"text\", text };\n }\n if (type === \"epub\") {\n const buffer = await this.readResponseBuffer(response);\n return { kind: \"base64\", data: encodeBase64(new Uint8Array(buffer)) };\n }\n if (type === \"comic\") {\n const buffer = await this.readResponseBuffer(response);\n return { kind: \"base64\", data: encodeBase64(new Uint8Array(buffer)) };\n }\n return null;\n } catch {\n return null;\n }\n }\n\n private async fetchLocalSource(\n type: DocumentType,\n uri: string\n ): Promise<WebViewSourcePayload> {\n if (type === \"epub\" || type === \"comic\") {\n return { kind: \"uri\", uri };\n }\n\n try {\n const response = await fetch(uri);\n if (!response.ok && response.status !== 0) {\n throw new Error(`status ${response.status}`);\n }\n if (type === \"text\") {\n return { kind: \"text\", text: await response.text() };\n }\n throw new Error(`tipo não suportado: ${type}`);\n } catch (error) {\n const reason = error instanceof Error ? `: ${error.message}` : \"\";\n throw new Error(\n `[WebViewDocumentEngine] Não foi possível ler o arquivo local ${uri}${reason}`\n );\n }\n }\n\n private async readResponseBuffer(response: Response): Promise<ArrayBuffer> {\n try {\n return await response.arrayBuffer();\n } catch {\n const blob = await response.blob();\n return await new Promise<ArrayBuffer>((resolve, reject) => {\n const reader = new FileReader();\n reader.onerror = () =>\n reject(new Error(\"[Papyrus] Failed to read response blob\"));\n reader.onload = () => resolve(reader.result as ArrayBuffer);\n reader.readAsArrayBuffer(blob);\n });\n }\n }\n\n private isUriSource(source: DocumentSource): source is { uri: string } {\n return typeof source === \"object\" && source !== null && \"uri\" in source;\n }\n\n private isDataSource(\n source: DocumentSource\n ): source is { data: ArrayBuffer | Uint8Array } {\n return typeof source === \"object\" && source !== null && \"data\" in source;\n }\n\n private isFileLike(source: DocumentSource): source is FileLike {\n return (\n typeof source === \"object\" &&\n source !== null &&\n typeof (source as FileLike).arrayBuffer === \"function\"\n );\n }\n}\n\nexport class MobileDocumentEngine extends BaseDocumentEngine {\n private pdfEngine: NativeDocumentEngine;\n private webEngine: WebViewDocumentEngine;\n private activeEngine: DocumentEngine;\n\n constructor(options: MobileDocumentEngineOptions = {}) {\n super();\n this.pdfEngine = new NativeDocumentEngine();\n this.webEngine = new WebViewDocumentEngine(options);\n this.activeEngine = this.pdfEngine;\n }\n\n getWebViewRuntimeSource(): WebViewRuntimeSource | undefined {\n return this.webEngine.getWebViewRuntimeSource();\n }\n\n getWebViewRuntimeConfig(): WebViewRuntimeConfig | undefined {\n return this.webEngine.getWebViewRuntimeConfig();\n }\n\n getRenderTargetType(): RenderTargetType {\n return this.activeEngine.getRenderTargetType?.() ?? \"canvas\";\n }\n\n getNativeEngineId(): string | null {\n return this.activeEngine === this.pdfEngine\n ? this.pdfEngine.getNativeEngineId()\n : null;\n }\n\n getLifecycleStats(): Record<string, number> {\n return {\n ...this.pdfEngine.getLifecycleStats(),\n ...this.webEngine.getLifecycleStats(),\n };\n }\n\n attachWebView(bridge: WebViewBridge): void {\n this.webEngine.attachBridge(bridge);\n }\n\n detachWebView(): void {\n this.webEngine.detachBridge();\n }\n\n handleWebViewMessage(data: string): void {\n this.webEngine.handleMessage(data);\n }\n\n async load(input: DocumentLoadInput): Promise<void> {\n const { source, type, format } = normalizeLoadInput(input);\n const resolvedType = type ?? inferDocumentType(source);\n this.activeEngine =\n resolvedType === \"pdf\" ? this.pdfEngine : this.webEngine;\n await this.activeEngine.load({\n type: resolvedType,\n source,\n ...(resolvedType === \"comic\" && format ? { format } : {}),\n });\n }\n\n getPageCount(): number {\n return this.activeEngine.getPageCount();\n }\n\n getCurrentPage(): number {\n return this.activeEngine.getCurrentPage();\n }\n\n goToPage(page: number): void {\n this.activeEngine.goToPage(page);\n }\n\n setZoom(zoom: number): void {\n this.activeEngine.setZoom(zoom);\n }\n\n getZoom(): number {\n return this.activeEngine.getZoom();\n }\n\n rotate(direction: \"clockwise\" | \"counterclockwise\"): void {\n this.activeEngine.rotate(direction);\n }\n\n getRotation(): number {\n return this.activeEngine.getRotation();\n }\n\n async renderPage(\n pageIndex: number,\n target: any,\n scale: number,\n telemetry?: RenderPageTelemetryContext\n ): Promise<void> {\n await this.activeEngine.renderPage(pageIndex, target, scale, telemetry);\n }\n\n async renderTextLayer(\n pageIndex: number,\n container: any,\n scale: number\n ): Promise<void> {\n await this.activeEngine.renderTextLayer(pageIndex, container, scale);\n }\n\n async getTextContent(pageIndex: number): Promise<TextItem[]> {\n return await this.activeEngine.getTextContent(pageIndex);\n }\n\n async getPageDimensions(\n pageIndex: number\n ): Promise<{ width: number; height: number }> {\n return await this.activeEngine.getPageDimensions(pageIndex);\n }\n\n async getPagePreview(pageIndex: number): Promise<string | null> {\n const engine = this.activeEngine as DocumentEngine & {\n getPagePreview?: (pageIndex: number) => Promise<string | null>;\n };\n return (await engine.getPagePreview?.(pageIndex)) ?? null;\n }\n\n async searchText(query: string): Promise<SearchResult[]> {\n if (typeof this.activeEngine.searchText === \"function\") {\n return await this.activeEngine.searchText(query);\n }\n return [];\n }\n\n async selectText(\n pageIndex: number,\n rect: { x: number; y: number; width: number; height: number },\n endpoints?: TextSelectionEndpoints\n ): Promise<TextSelection | null> {\n if (typeof this.activeEngine.selectText === \"function\") {\n return await this.activeEngine.selectText(pageIndex, rect, endpoints);\n }\n return null;\n }\n\n async getOutline(): Promise<OutlineItem[]> {\n return await this.activeEngine.getOutline();\n }\n\n async getPageIndex(dest: PageDestination): Promise<number | null> {\n return await this.activeEngine.getPageIndex(dest);\n }\n\n destroy(): void {\n this.pdfEngine.destroy();\n this.webEngine.destroy();\n }\n}\n","import type {\n ComicFormat,\n DocumentSource,\n DocumentType,\n} from \"@papyrus-sdk/types\";\n\nconst parseDataUri = (\n value: string\n): { mime: string; isBase64: boolean; data: string } | null => {\n const match = /^data:([^;,]+)?(;base64)?,(.*)$/.exec(value);\n if (!match) return null;\n return {\n mime: match[1] ?? \"\",\n isBase64: Boolean(match[2]),\n data: match[3] ?? \"\",\n };\n};\n\nconst typeFromExtension = (value: string): DocumentType | null => {\n const clean = value.split(\"?\")[0].split(\"#\")[0].toLowerCase();\n const extension = clean.includes(\".\")\n ? clean.split(\".\").pop()\n : undefined;\n\n if (extension === \"epub\") return \"epub\";\n if (extension === \"txt\") return \"text\";\n if (extension === \"pdf\") return \"pdf\";\n if (extension === \"cbz\" || extension === \"cbr\") return \"comic\";\n return null;\n};\n\nexport const inferComicFormat = (source: DocumentSource): ComicFormat => {\n const candidate =\n typeof source === \"string\"\n ? source\n : typeof source === \"object\" && source !== null && \"uri\" in source\n ? source.uri\n : \"\";\n const dataUri = parseDataUri(candidate);\n const mime = dataUri?.mime.toLowerCase() ?? \"\";\n if (mime.includes(\"rar\") || /\\.cbr(?:$|[?#])/i.test(candidate)) {\n return \"cbr\";\n }\n return \"cbz\";\n};\n\nexport const resolveComicFormat = (\n source: DocumentSource,\n explicitFormat?: ComicFormat\n): ComicFormat => explicitFormat ?? inferComicFormat(source);\n\nexport const inferDocumentType = (source: DocumentSource): DocumentType => {\n if (typeof source === \"string\") {\n const dataUri = parseDataUri(source);\n if (dataUri?.mime) {\n const mime = dataUri.mime.toLowerCase();\n if (mime.includes(\"epub\")) return \"epub\";\n if (\n mime.includes(\"comicbook\") ||\n mime.includes(\"zip\") ||\n mime.includes(\"rar\")\n ) {\n return \"comic\";\n }\n if (mime.includes(\"text\")) return \"text\";\n if (mime.includes(\"pdf\")) return \"pdf\";\n }\n\n return typeFromExtension(source) ?? \"pdf\";\n }\n\n if (typeof source === \"object\" && source !== null && \"uri\" in source) {\n return typeFromExtension(source.uri) ?? \"pdf\";\n }\n\n return \"pdf\";\n};\n","type NativeModuleRegistry = Record<string, unknown>;\n\ntype ModuleRegistry = {\n nativeModules: NativeModuleRegistry;\n turboModuleRegistry: { get: (name: string) => unknown };\n};\n\nexport const resolvePapyrusNativeModule = <T>(\n registries: ModuleRegistry,\n): T | null => {\n const turboModule = registries.turboModuleRegistry.get(\n \"PapyrusNativeEngine\",\n ) as T | null;\n if (turboModule) return turboModule;\n\n return (registries.nativeModules.PapyrusNativeEngine as T | undefined) ?? null;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAOO;AACP,kBAAkD;AAClD,mBAqBO;;;ACzBP,IAAM,eAAe,CACnB,UAC6D;AAC7D,QAAM,QAAQ,kCAAkC,KAAK,KAAK;AAC1D,MAAI,CAAC,MAAO,QAAO;AACnB,SAAO;AAAA,IACL,MAAM,MAAM,CAAC,KAAK;AAAA,IAClB,UAAU,QAAQ,MAAM,CAAC,CAAC;AAAA,IAC1B,MAAM,MAAM,CAAC,KAAK;AAAA,EACpB;AACF;AAEA,IAAM,oBAAoB,CAAC,UA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