@papyrus-sdk/engine-native 0.2.22-beta.9.epub.2 → 0.2.23
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.
- package/PapyrusNativeEngine.podspec +45 -0
- package/android/build.gradle +1 -0
- package/android/src/main/cpp/CMakeLists.txt +137 -0
- package/android/src/main/cpp/PapyrusComicArchiveJni.cpp +68 -0
- package/android/src/main/cpp/PapyrusComicArchiveTest.cpp +55 -0
- package/android/src/main/cpp/papyrus_outline_loader_test.cpp +240 -0
- package/android/src/main/cpp/papyrus_text_word_test.cpp +72 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusComicArchiveNative.java +14 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusComicDocumentView.java +491 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusComicDocumentViewManager.java +32 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusComicPageLayout.java +38 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusNativeEngineModule.java +305 -35
- package/android/src/main/java/com/papyrus/engine/PapyrusNativeTextModel.java +195 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusPackage.java +3 -1
- package/android/src/main/java/com/papyrus/engine/PapyrusPdfViewerView.java +195 -5
- package/android/src/main/java/com/papyrus/engine/PapyrusPdfViewerViewManager.java +20 -1
- package/android/src/main/java/com/papyrus/engine/PapyrusSelectionMenuIcon.java +48 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusTextAnnotationModel.java +22 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusTextDocumentView.java +661 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusTextDocumentViewManager.java +49 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusTextStore.java +43 -0
- package/dist/index.d.mts +614 -4
- package/dist/index.d.ts +614 -4
- package/dist/index.js +484 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +477 -7
- package/dist/index.mjs.map +1 -1
- package/ios/PapyrusComicDocumentView.h +21 -0
- package/ios/PapyrusComicDocumentView.m +554 -0
- package/ios/PapyrusComicDocumentViewManager.m +23 -0
- package/ios/PapyrusEngineStore.h +3 -0
- package/ios/PapyrusEngineStore.m +32 -6
- package/ios/PapyrusNativeEngine.m +684 -5
- package/ios/PapyrusPageRotationRegistry.h +29 -0
- package/ios/PapyrusPageRotationRegistry.m +179 -0
- package/ios/PapyrusPageView.m +38 -11
- package/ios/PapyrusPdfDocumentView.h +55 -0
- package/ios/PapyrusPdfDocumentView.m +2370 -0
- package/ios/PapyrusPdfDocumentViewManager.m +61 -0
- package/ios/PapyrusPdfPageTheme.h +15 -0
- package/ios/PapyrusPdfPageTheme.m +218 -0
- package/ios/PapyrusSelectionMenu.h +27 -0
- package/ios/PapyrusTextAnnotationRange.h +2 -0
- package/ios/PapyrusTextAnnotationRange.m +29 -0
- package/ios/PapyrusTextDocumentView.h +32 -0
- package/ios/PapyrusTextDocumentView.m +518 -0
- package/ios/PapyrusTextDocumentViewManager.m +34 -0
- package/ios/PapyrusTextStore.h +13 -0
- package/ios/PapyrusTextStore.m +73 -0
- package/package.json +12 -10
- package/react-native.config.js +1 -1
- package/third_party_licenses/BLAKE2-NOTICE.txt +11 -0
- package/third_party_licenses/libarchive-COPYING +65 -0
- package/vendor/libarchive/PapyrusComicArchive.cpp +376 -0
- package/vendor/libarchive/PapyrusComicArchive.h +30 -0
- package/vendor/libarchive/README.papyrus.md +15 -0
- package/vendor/libarchive/android.h +192 -0
- package/vendor/libarchive/config/PapyrusArchiveConfig.h +71 -0
- package/vendor/libarchive/libarchive/CMakeLists.txt +293 -0
- package/vendor/libarchive/libarchive/android_lf.h +36 -0
- package/vendor/libarchive/libarchive/archive.h +1266 -0
- package/vendor/libarchive/libarchive/archive_acl.c +2025 -0
- package/vendor/libarchive/libarchive/archive_acl_private.h +85 -0
- package/vendor/libarchive/libarchive/archive_blake2.h +197 -0
- package/vendor/libarchive/libarchive/archive_blake2_impl.h +161 -0
- package/vendor/libarchive/libarchive/archive_blake2s_ref.c +369 -0
- package/vendor/libarchive/libarchive/archive_blake2sp_ref.c +361 -0
- package/vendor/libarchive/libarchive/archive_check_magic.c +183 -0
- package/vendor/libarchive/libarchive/archive_cmdline.c +211 -0
- package/vendor/libarchive/libarchive/archive_cmdline_private.h +45 -0
- package/vendor/libarchive/libarchive/archive_crc32.h +123 -0
- package/vendor/libarchive/libarchive/archive_cryptor.c +534 -0
- package/vendor/libarchive/libarchive/archive_cryptor_private.h +199 -0
- package/vendor/libarchive/libarchive/archive_digest.c +1584 -0
- package/vendor/libarchive/libarchive/archive_digest_private.h +431 -0
- package/vendor/libarchive/libarchive/archive_disk_acl_darwin.c +558 -0
- package/vendor/libarchive/libarchive/archive_disk_acl_freebsd.c +712 -0
- package/vendor/libarchive/libarchive/archive_disk_acl_linux.c +760 -0
- package/vendor/libarchive/libarchive/archive_disk_acl_sunos.c +824 -0
- package/vendor/libarchive/libarchive/archive_endian.h +234 -0
- package/vendor/libarchive/libarchive/archive_entry.3 +147 -0
- package/vendor/libarchive/libarchive/archive_entry.c +2297 -0
- package/vendor/libarchive/libarchive/archive_entry.h +763 -0
- package/vendor/libarchive/libarchive/archive_entry_acl.3 +458 -0
- package/vendor/libarchive/libarchive/archive_entry_copy_bhfi.c +55 -0
- package/vendor/libarchive/libarchive/archive_entry_copy_stat.c +82 -0
- package/vendor/libarchive/libarchive/archive_entry_link_resolver.c +472 -0
- package/vendor/libarchive/libarchive/archive_entry_linkify.3 +224 -0
- package/vendor/libarchive/libarchive/archive_entry_locale.h +90 -0
- package/vendor/libarchive/libarchive/archive_entry_misc.3 +63 -0
- package/vendor/libarchive/libarchive/archive_entry_paths.3 +153 -0
- package/vendor/libarchive/libarchive/archive_entry_perms.3 +210 -0
- package/vendor/libarchive/libarchive/archive_entry_private.h +205 -0
- package/vendor/libarchive/libarchive/archive_entry_sparse.c +156 -0
- package/vendor/libarchive/libarchive/archive_entry_stat.3 +274 -0
- package/vendor/libarchive/libarchive/archive_entry_stat.c +121 -0
- package/vendor/libarchive/libarchive/archive_entry_strmode.c +69 -0
- package/vendor/libarchive/libarchive/archive_entry_time.3 +127 -0
- package/vendor/libarchive/libarchive/archive_entry_xattr.c +155 -0
- package/vendor/libarchive/libarchive/archive_hmac.c +345 -0
- package/vendor/libarchive/libarchive/archive_hmac_private.h +119 -0
- package/vendor/libarchive/libarchive/archive_integer.h +267 -0
- package/vendor/libarchive/libarchive/archive_match.c +1869 -0
- package/vendor/libarchive/libarchive/archive_openssl_evp_private.h +54 -0
- package/vendor/libarchive/libarchive/archive_openssl_hmac_private.h +54 -0
- package/vendor/libarchive/libarchive/archive_options.c +219 -0
- package/vendor/libarchive/libarchive/archive_options_private.h +49 -0
- package/vendor/libarchive/libarchive/archive_pack_dev.c +330 -0
- package/vendor/libarchive/libarchive/archive_pack_dev.h +49 -0
- package/vendor/libarchive/libarchive/archive_parse_date.c +1173 -0
- package/vendor/libarchive/libarchive/archive_pathmatch.c +480 -0
- package/vendor/libarchive/libarchive/archive_pathmatch.h +50 -0
- package/vendor/libarchive/libarchive/archive_platform.h +213 -0
- package/vendor/libarchive/libarchive/archive_platform_acl.h +53 -0
- package/vendor/libarchive/libarchive/archive_platform_stat.h +45 -0
- package/vendor/libarchive/libarchive/archive_platform_xattr.h +45 -0
- package/vendor/libarchive/libarchive/archive_ppmd7.c +1173 -0
- package/vendor/libarchive/libarchive/archive_ppmd7_private.h +119 -0
- package/vendor/libarchive/libarchive/archive_ppmd8.c +1293 -0
- package/vendor/libarchive/libarchive/archive_ppmd8_private.h +123 -0
- package/vendor/libarchive/libarchive/archive_ppmd_private.h +159 -0
- package/vendor/libarchive/libarchive/archive_private.h +209 -0
- package/vendor/libarchive/libarchive/archive_random.c +274 -0
- package/vendor/libarchive/libarchive/archive_random_private.h +36 -0
- package/vendor/libarchive/libarchive/archive_rb.c +709 -0
- package/vendor/libarchive/libarchive/archive_rb.h +113 -0
- package/vendor/libarchive/libarchive/archive_read.3 +250 -0
- package/vendor/libarchive/libarchive/archive_read.c +1814 -0
- package/vendor/libarchive/libarchive/archive_read_add_passphrase.3 +72 -0
- package/vendor/libarchive/libarchive/archive_read_add_passphrase.c +189 -0
- package/vendor/libarchive/libarchive/archive_read_append_filter.c +209 -0
- package/vendor/libarchive/libarchive/archive_read_data.3 +128 -0
- package/vendor/libarchive/libarchive/archive_read_data_into_fd.c +207 -0
- package/vendor/libarchive/libarchive/archive_read_disk.3 +422 -0
- package/vendor/libarchive/libarchive/archive_read_disk_entry_from_file.c +1086 -0
- package/vendor/libarchive/libarchive/archive_read_disk_posix.c +2639 -0
- package/vendor/libarchive/libarchive/archive_read_disk_private.h +97 -0
- package/vendor/libarchive/libarchive/archive_read_disk_set_standard_lookup.c +315 -0
- package/vendor/libarchive/libarchive/archive_read_disk_windows.c +2603 -0
- package/vendor/libarchive/libarchive/archive_read_extract.3 +135 -0
- package/vendor/libarchive/libarchive/archive_read_extract.c +59 -0
- package/vendor/libarchive/libarchive/archive_read_extract2.c +154 -0
- package/vendor/libarchive/libarchive/archive_read_filter.3 +163 -0
- package/vendor/libarchive/libarchive/archive_read_format.3 +190 -0
- package/vendor/libarchive/libarchive/archive_read_free.3 +91 -0
- package/vendor/libarchive/libarchive/archive_read_header.3 +89 -0
- package/vendor/libarchive/libarchive/archive_read_new.3 +57 -0
- package/vendor/libarchive/libarchive/archive_read_open.3 +247 -0
- package/vendor/libarchive/libarchive/archive_read_open_fd.c +236 -0
- package/vendor/libarchive/libarchive/archive_read_open_file.c +257 -0
- package/vendor/libarchive/libarchive/archive_read_open_filename.c +652 -0
- package/vendor/libarchive/libarchive/archive_read_open_memory.c +188 -0
- package/vendor/libarchive/libarchive/archive_read_private.h +274 -0
- package/vendor/libarchive/libarchive/archive_read_set_format.c +116 -0
- package/vendor/libarchive/libarchive/archive_read_set_options.3 +290 -0
- package/vendor/libarchive/libarchive/archive_read_set_options.c +132 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_all.c +84 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_by_code.c +68 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_bzip2.c +360 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_compress.c +457 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_grzip.c +108 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_gzip.c +538 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_lrzip.c +119 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_lz4.c +829 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_lzop.c +493 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_none.c +51 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_program.c +497 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_rpm.c +249 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_uu.c +739 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_xz.c +792 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_zstd.c +356 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_7zip.c +4650 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_all.c +88 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_ar.c +597 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_by_code.c +76 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_cab.c +3410 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_cpio.c +1152 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_empty.c +95 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_iso9660.c +3516 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_lha.c +2931 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_mtree.c +2113 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_rar.c +3932 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_rar5.c +4501 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_raw.c +194 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_tar.c +3785 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_warc.c +875 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_xar.c +3770 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_zip.c +4710 -0
- package/vendor/libarchive/libarchive/archive_string.c +4391 -0
- package/vendor/libarchive/libarchive/archive_string.h +244 -0
- package/vendor/libarchive/libarchive/archive_string_composition.h +2289 -0
- package/vendor/libarchive/libarchive/archive_string_sprintf.c +200 -0
- package/vendor/libarchive/libarchive/archive_time.c +168 -0
- package/vendor/libarchive/libarchive/archive_time_private.h +47 -0
- package/vendor/libarchive/libarchive/archive_util.3 +239 -0
- package/vendor/libarchive/libarchive/archive_util.c +668 -0
- package/vendor/libarchive/libarchive/archive_version_details.c +516 -0
- package/vendor/libarchive/libarchive/archive_virtual.c +162 -0
- package/vendor/libarchive/libarchive/archive_windows.c +1035 -0
- package/vendor/libarchive/libarchive/archive_windows.h +332 -0
- package/vendor/libarchive/libarchive/archive_write.3 +266 -0
- package/vendor/libarchive/libarchive/archive_write.c +896 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter.c +71 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_b64encode.c +329 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_by_name.c +76 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_bzip2.c +411 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_compress.c +459 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_grzip.c +143 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_gzip.c +493 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_lrzip.c +214 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_lz4.c +710 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_lzop.c +500 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_none.c +42 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_program.c +398 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_uuencode.c +320 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_xz.c +547 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_zstd.c +608 -0
- package/vendor/libarchive/libarchive/archive_write_blocksize.3 +112 -0
- package/vendor/libarchive/libarchive/archive_write_data.3 +88 -0
- package/vendor/libarchive/libarchive/archive_write_disk.3 +360 -0
- package/vendor/libarchive/libarchive/archive_write_disk_posix.c +4789 -0
- package/vendor/libarchive/libarchive/archive_write_disk_private.h +43 -0
- package/vendor/libarchive/libarchive/archive_write_disk_set_standard_lookup.c +265 -0
- package/vendor/libarchive/libarchive/archive_write_disk_windows.c +2952 -0
- package/vendor/libarchive/libarchive/archive_write_filter.3 +140 -0
- package/vendor/libarchive/libarchive/archive_write_finish_entry.3 +77 -0
- package/vendor/libarchive/libarchive/archive_write_format.3 +187 -0
- package/vendor/libarchive/libarchive/archive_write_free.3 +94 -0
- package/vendor/libarchive/libarchive/archive_write_header.3 +71 -0
- package/vendor/libarchive/libarchive/archive_write_new.3 +56 -0
- package/vendor/libarchive/libarchive/archive_write_open.3 +270 -0
- package/vendor/libarchive/libarchive/archive_write_open_fd.c +141 -0
- package/vendor/libarchive/libarchive/archive_write_open_file.c +102 -0
- package/vendor/libarchive/libarchive/archive_write_open_filename.c +272 -0
- package/vendor/libarchive/libarchive/archive_write_open_memory.c +110 -0
- package/vendor/libarchive/libarchive/archive_write_private.h +166 -0
- package/vendor/libarchive/libarchive/archive_write_set_format.c +124 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_7zip.c +2571 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_ar.c +540 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_by_name.c +93 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_cpio.c +11 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_cpio_binary.c +618 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_cpio_newc.c +457 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_cpio_odc.c +508 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_filter_by_ext.c +141 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_gnutar.c +790 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_iso9660.c +8216 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_mtree.c +2307 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_pax.c +2249 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_private.h +40 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_raw.c +123 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_shar.c +650 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_ustar.c +768 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_v7tar.c +648 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_warc.c +491 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_xar.c +3799 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_zip.c +2548 -0
- package/vendor/libarchive/libarchive/archive_write_set_options.3 +779 -0
- package/vendor/libarchive/libarchive/archive_write_set_options.c +129 -0
- package/vendor/libarchive/libarchive/archive_write_set_passphrase.3 +72 -0
- package/vendor/libarchive/libarchive/archive_write_set_passphrase.c +95 -0
- package/vendor/libarchive/libarchive/archive_xxhash.h +48 -0
- package/vendor/libarchive/libarchive/config_freebsd.h +275 -0
- package/vendor/libarchive/libarchive/cpio.5 +389 -0
- package/vendor/libarchive/libarchive/filter_fork.h +44 -0
- package/vendor/libarchive/libarchive/filter_fork_posix.c +269 -0
- package/vendor/libarchive/libarchive/filter_fork_windows.c +270 -0
- package/vendor/libarchive/libarchive/libarchive-formats.5 +478 -0
- package/vendor/libarchive/libarchive/libarchive.3 +297 -0
- package/vendor/libarchive/libarchive/libarchive_changes.3 +339 -0
- package/vendor/libarchive/libarchive/libarchive_internals.3 +363 -0
- package/vendor/libarchive/libarchive/module.modulemap +34 -0
- package/vendor/libarchive/libarchive/mtree.5 +323 -0
- package/vendor/libarchive/libarchive/tar.5 +947 -0
- package/vendor/libarchive/libarchive/xxhash.c +531 -0
- package/ios/PapyrusNativeEngine.podspec +0 -15
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
NativeModules,
|
|
4
4
|
Platform,
|
|
5
|
+
UIManager,
|
|
5
6
|
TurboModuleRegistry,
|
|
6
7
|
requireNativeComponent,
|
|
7
8
|
View
|
|
@@ -69,6 +70,38 @@ var resolvePapyrusNativeModule = (registries) => {
|
|
|
69
70
|
return registries.nativeModules.PapyrusNativeEngine ?? null;
|
|
70
71
|
};
|
|
71
72
|
|
|
73
|
+
// nativeViewAvailability.ts
|
|
74
|
+
var isNativeViewManagerRegistered = (registry, managerName) => {
|
|
75
|
+
if (typeof registry.hasViewManagerConfig !== "function") return false;
|
|
76
|
+
try {
|
|
77
|
+
return registry.hasViewManagerConfig(managerName);
|
|
78
|
+
} catch {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// nativeTextModel.ts
|
|
84
|
+
var clampTextOffset = (offset, textLength) => {
|
|
85
|
+
const max = Math.max(0, Math.floor(Number.isFinite(textLength) ? textLength : 0));
|
|
86
|
+
return Math.max(0, Math.min(max, Math.floor(Number.isFinite(offset) ? offset : 0)));
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// nativeDocumentRoute.ts
|
|
90
|
+
var resolveNativeMobileDocumentRoute = ({
|
|
91
|
+
type,
|
|
92
|
+
platform,
|
|
93
|
+
nativeModuleAvailable = false,
|
|
94
|
+
nativeViewAvailable = false
|
|
95
|
+
}) => {
|
|
96
|
+
if (type === "pdf") return "native-pdf";
|
|
97
|
+
if (type === "epub") return "webview";
|
|
98
|
+
const supportedMobilePlatform = platform === "ios" || platform === "android";
|
|
99
|
+
if (!supportedMobilePlatform || !nativeModuleAvailable || !nativeViewAvailable) {
|
|
100
|
+
return "webview";
|
|
101
|
+
}
|
|
102
|
+
return type === "text" ? "native-text" : "native-comic";
|
|
103
|
+
};
|
|
104
|
+
|
|
72
105
|
// index.ts
|
|
73
106
|
var MODULE_NAME = "PapyrusNativeEngine";
|
|
74
107
|
var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -150,6 +183,31 @@ var encodeBase64 = (bytes) => {
|
|
|
150
183
|
};
|
|
151
184
|
var isLoadRequest = (input) => typeof input === "object" && input !== null && "source" in input && "type" in input;
|
|
152
185
|
var normalizeLoadInput = (input) => isLoadRequest(input) ? { source: input.source, type: input.type, format: input.format } : { source: input };
|
|
186
|
+
var normalizeNativeSource = async (source, allowPlainText) => {
|
|
187
|
+
if (typeof source === "string") {
|
|
188
|
+
const dataUri = parseDataUri2(source);
|
|
189
|
+
if (dataUri?.isBase64) return { data: decodeBase64(dataUri.data) };
|
|
190
|
+
if (dataUri && allowPlainText) {
|
|
191
|
+
return { text: decodeURIComponent(dataUri.data) };
|
|
192
|
+
}
|
|
193
|
+
if (looksLikeUri(source)) return { uri: source };
|
|
194
|
+
if (!allowPlainText && isLikelyBase64(source)) return { data: decodeBase64(source) };
|
|
195
|
+
return allowPlainText ? { text: source } : { uri: source };
|
|
196
|
+
}
|
|
197
|
+
if (typeof source === "object" && source !== null && "uri" in source) {
|
|
198
|
+
return { uri: source.uri };
|
|
199
|
+
}
|
|
200
|
+
if (typeof source === "object" && source !== null && "data" in source) {
|
|
201
|
+
const data = source.data instanceof Uint8Array ? source.data : new Uint8Array(source.data);
|
|
202
|
+
return { data };
|
|
203
|
+
}
|
|
204
|
+
if (typeof source === "object" && source !== null && typeof source.arrayBuffer === "function") {
|
|
205
|
+
return { data: new Uint8Array(await source.arrayBuffer()) };
|
|
206
|
+
}
|
|
207
|
+
if (source instanceof ArrayBuffer) return { data: new Uint8Array(source) };
|
|
208
|
+
if (source instanceof Uint8Array) return { data: source };
|
|
209
|
+
throw new Error("[Papyrus] Unsupported native document source");
|
|
210
|
+
};
|
|
153
211
|
var normalizeNativeDestination = (dest) => {
|
|
154
212
|
if (!dest) return null;
|
|
155
213
|
if (typeof dest === "string") {
|
|
@@ -189,19 +247,53 @@ var resolvePapyrusPageView = () => {
|
|
|
189
247
|
return View;
|
|
190
248
|
}
|
|
191
249
|
};
|
|
192
|
-
var
|
|
193
|
-
|
|
250
|
+
var PAPYRUS_PDF_DOCUMENT_VIEW_NAME = "PapyrusPdfDocumentView";
|
|
251
|
+
var hasPapyrusPdfDocumentViewManager = () => Platform.OS === "ios" && isNativeViewManagerRegistered(UIManager, PAPYRUS_PDF_DOCUMENT_VIEW_NAME);
|
|
252
|
+
var unavailablePapyrusPdfDocumentView = () => null;
|
|
253
|
+
var resolvePapyrusPdfDocumentView = () => {
|
|
254
|
+
if (!hasPapyrusPdfDocumentViewManager()) return null;
|
|
194
255
|
try {
|
|
195
256
|
return requireNativeComponent(
|
|
196
|
-
|
|
257
|
+
PAPYRUS_PDF_DOCUMENT_VIEW_NAME
|
|
258
|
+
);
|
|
259
|
+
} catch {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
var resolvePapyrusAndroidPdfViewerView = () => {
|
|
264
|
+
try {
|
|
265
|
+
return requireNativeComponent(
|
|
266
|
+
"PapyrusPdfViewerView"
|
|
197
267
|
);
|
|
198
268
|
} catch {
|
|
199
269
|
return View;
|
|
200
270
|
}
|
|
201
271
|
};
|
|
272
|
+
var papyrusPdfDocumentView = resolvePapyrusPdfDocumentView();
|
|
273
|
+
var isPapyrusPdfDocumentViewAvailable = () => papyrusPdfDocumentView !== null && hasPapyrusPdfDocumentViewManager();
|
|
202
274
|
var PapyrusPageView = resolvePapyrusPageView();
|
|
203
|
-
var PapyrusPdfViewerView =
|
|
275
|
+
var PapyrusPdfViewerView = Platform.OS === "ios" ? papyrusPdfDocumentView ?? unavailablePapyrusPdfDocumentView : resolvePapyrusAndroidPdfViewerView();
|
|
204
276
|
var PapyrusPdfDocumentView = PapyrusPdfViewerView;
|
|
277
|
+
var PAPYRUS_TEXT_DOCUMENT_VIEW_NAME = "PapyrusTextDocumentView";
|
|
278
|
+
var PAPYRUS_COMIC_DOCUMENT_VIEW_NAME = "PapyrusComicDocumentView";
|
|
279
|
+
var resolveNativeView = (name) => {
|
|
280
|
+
if (!isNativeViewManagerRegistered(UIManager, name)) return null;
|
|
281
|
+
try {
|
|
282
|
+
return requireNativeComponent(name);
|
|
283
|
+
} catch {
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
var papyrusTextDocumentView = resolveNativeView(
|
|
288
|
+
PAPYRUS_TEXT_DOCUMENT_VIEW_NAME
|
|
289
|
+
);
|
|
290
|
+
var papyrusComicDocumentView = resolveNativeView(
|
|
291
|
+
PAPYRUS_COMIC_DOCUMENT_VIEW_NAME
|
|
292
|
+
);
|
|
293
|
+
var isPapyrusTextDocumentViewAvailable = () => papyrusTextDocumentView !== null;
|
|
294
|
+
var isPapyrusComicDocumentViewAvailable = () => papyrusComicDocumentView !== null;
|
|
295
|
+
var PapyrusTextDocumentView = papyrusTextDocumentView ?? unavailablePapyrusPdfDocumentView;
|
|
296
|
+
var PapyrusComicDocumentView = papyrusComicDocumentView ?? unavailablePapyrusPdfDocumentView;
|
|
205
297
|
var NativeDocumentEngine = class extends BaseDocumentEngine {
|
|
206
298
|
constructor() {
|
|
207
299
|
super();
|
|
@@ -243,6 +335,8 @@ var NativeDocumentEngine = class extends BaseDocumentEngine {
|
|
|
243
335
|
this.pageCount = 0;
|
|
244
336
|
}
|
|
245
337
|
this.currentPage = 1;
|
|
338
|
+
this.zoom = 1;
|
|
339
|
+
this.rotation = 0;
|
|
246
340
|
}
|
|
247
341
|
getPageCount() {
|
|
248
342
|
return this.pageCount;
|
|
@@ -410,9 +504,281 @@ var NativeDocumentEngine = class extends BaseDocumentEngine {
|
|
|
410
504
|
return null;
|
|
411
505
|
}
|
|
412
506
|
};
|
|
507
|
+
var NativeTextDocumentEngine = class extends BaseDocumentEngine {
|
|
508
|
+
constructor() {
|
|
509
|
+
super(...arguments);
|
|
510
|
+
this.nativeModule = resolveNativeModule();
|
|
511
|
+
this.engineId = this.nativeModule?.createEngine?.() ?? "default";
|
|
512
|
+
this.loadGeneration = 0;
|
|
513
|
+
this.documentGeneration = 0;
|
|
514
|
+
this.textLength = 0;
|
|
515
|
+
this.currentOffset = 0;
|
|
516
|
+
}
|
|
517
|
+
async load(input) {
|
|
518
|
+
const { source, type } = normalizeLoadInput(input);
|
|
519
|
+
if (type && type !== "text") {
|
|
520
|
+
throw new Error("[NativeTextDocumentEngine] Unsupported type: " + type);
|
|
521
|
+
}
|
|
522
|
+
const generation = ++this.loadGeneration;
|
|
523
|
+
if (this.documentGeneration > 0) {
|
|
524
|
+
this.nativeModule?.closeText?.(this.engineId, this.documentGeneration);
|
|
525
|
+
}
|
|
526
|
+
this.documentGeneration = 0;
|
|
527
|
+
this.textLength = 0;
|
|
528
|
+
this.currentOffset = 0;
|
|
529
|
+
const nativeSource = await normalizeNativeSource(source, true);
|
|
530
|
+
if (generation !== this.loadGeneration) return;
|
|
531
|
+
const native = this.assertNativeModule();
|
|
532
|
+
if (!native.loadText) {
|
|
533
|
+
throw new Error("[Papyrus] Native TXT loading is not available");
|
|
534
|
+
}
|
|
535
|
+
const result = await native.loadText(
|
|
536
|
+
this.engineId,
|
|
537
|
+
generation,
|
|
538
|
+
nativeSource
|
|
539
|
+
);
|
|
540
|
+
if (generation !== this.loadGeneration) {
|
|
541
|
+
native.closeText?.(this.engineId, generation);
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
this.documentGeneration = generation;
|
|
545
|
+
this.textLength = Math.max(0, Math.floor(result.textLength));
|
|
546
|
+
this.currentOffset = 0;
|
|
547
|
+
}
|
|
548
|
+
getNativeTextEngineId() {
|
|
549
|
+
return this.engineId;
|
|
550
|
+
}
|
|
551
|
+
getDocumentGeneration() {
|
|
552
|
+
return this.documentGeneration;
|
|
553
|
+
}
|
|
554
|
+
getTextLength() {
|
|
555
|
+
return this.textLength;
|
|
556
|
+
}
|
|
557
|
+
getCurrentTextOffset() {
|
|
558
|
+
return this.currentOffset;
|
|
559
|
+
}
|
|
560
|
+
goToTextOffset(offset) {
|
|
561
|
+
this.currentOffset = clampTextOffset(offset, this.textLength);
|
|
562
|
+
}
|
|
563
|
+
async resolveAnnotationTextRange(annotation) {
|
|
564
|
+
if (annotation.anchor?.kind !== "text-range") return annotation.textRange ?? null;
|
|
565
|
+
const generation = this.documentGeneration;
|
|
566
|
+
const range = await this.assertNativeModule().resolveTextAnnotationRange?.(this.engineId, generation, annotation.anchor);
|
|
567
|
+
return generation === this.documentGeneration ? range ?? null : null;
|
|
568
|
+
}
|
|
569
|
+
async getTextRange(start, end) {
|
|
570
|
+
const native = this.assertNativeModule();
|
|
571
|
+
if (!native.getTextRange) return "";
|
|
572
|
+
return native.getTextRange(
|
|
573
|
+
this.engineId,
|
|
574
|
+
this.documentGeneration,
|
|
575
|
+
clampTextOffset(start, this.textLength),
|
|
576
|
+
clampTextOffset(end, this.textLength)
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
async searchTextRanges(query) {
|
|
580
|
+
const native = this.assertNativeModule();
|
|
581
|
+
if (!native.searchTextRanges) return [];
|
|
582
|
+
return native.searchTextRanges(this.engineId, this.documentGeneration, query);
|
|
583
|
+
}
|
|
584
|
+
getRenderTargetType() {
|
|
585
|
+
return "native-text";
|
|
586
|
+
}
|
|
587
|
+
getPageCount() {
|
|
588
|
+
return 0;
|
|
589
|
+
}
|
|
590
|
+
getCurrentPage() {
|
|
591
|
+
return 1;
|
|
592
|
+
}
|
|
593
|
+
goToPage(page) {
|
|
594
|
+
}
|
|
595
|
+
setZoom(zoom) {
|
|
596
|
+
}
|
|
597
|
+
getZoom() {
|
|
598
|
+
return 1;
|
|
599
|
+
}
|
|
600
|
+
rotate(direction) {
|
|
601
|
+
}
|
|
602
|
+
getRotation() {
|
|
603
|
+
return 0;
|
|
604
|
+
}
|
|
605
|
+
async renderPage() {
|
|
606
|
+
}
|
|
607
|
+
async renderTextLayer() {
|
|
608
|
+
}
|
|
609
|
+
async getTextContent() {
|
|
610
|
+
return [];
|
|
611
|
+
}
|
|
612
|
+
async getPageDimensions() {
|
|
613
|
+
return { width: 0, height: 0 };
|
|
614
|
+
}
|
|
615
|
+
async selectText() {
|
|
616
|
+
return null;
|
|
617
|
+
}
|
|
618
|
+
async getOutline() {
|
|
619
|
+
return [];
|
|
620
|
+
}
|
|
621
|
+
async getPageIndex() {
|
|
622
|
+
return null;
|
|
623
|
+
}
|
|
624
|
+
destroy() {
|
|
625
|
+
this.loadGeneration += 1;
|
|
626
|
+
const engineId = this.engineId;
|
|
627
|
+
if (this.documentGeneration > 0) {
|
|
628
|
+
this.nativeModule?.closeText?.(engineId, this.documentGeneration);
|
|
629
|
+
}
|
|
630
|
+
this.nativeModule?.destroyEngine?.(engineId);
|
|
631
|
+
this.engineId = "default";
|
|
632
|
+
this.textLength = 0;
|
|
633
|
+
this.currentOffset = 0;
|
|
634
|
+
this.documentGeneration = 0;
|
|
635
|
+
}
|
|
636
|
+
assertNativeModule() {
|
|
637
|
+
if (!this.nativeModule) this.nativeModule = resolveNativeModule();
|
|
638
|
+
if (!this.nativeModule) {
|
|
639
|
+
throw new Error('[Papyrus] Native module "PapyrusNativeEngine" not found. Use a dev client or native build.');
|
|
640
|
+
}
|
|
641
|
+
if (this.engineId === "default" && this.nativeModule.createEngine) {
|
|
642
|
+
this.engineId = this.nativeModule.createEngine();
|
|
643
|
+
}
|
|
644
|
+
return this.nativeModule;
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
var NativeComicDocumentEngine = class extends BaseDocumentEngine {
|
|
648
|
+
constructor() {
|
|
649
|
+
super(...arguments);
|
|
650
|
+
this.nativeModule = resolveNativeModule();
|
|
651
|
+
this.engineId = this.nativeModule?.createEngine?.() ?? "default";
|
|
652
|
+
this.loadGeneration = 0;
|
|
653
|
+
this.documentGeneration = 0;
|
|
654
|
+
this.pageCount = 0;
|
|
655
|
+
this.currentPage = 1;
|
|
656
|
+
this.zoom = 1;
|
|
657
|
+
this.format = "cbz";
|
|
658
|
+
}
|
|
659
|
+
async load(input) {
|
|
660
|
+
const { source, type, format } = normalizeLoadInput(input);
|
|
661
|
+
if (type && type !== "comic") {
|
|
662
|
+
throw new Error("[NativeComicDocumentEngine] Unsupported type: " + type);
|
|
663
|
+
}
|
|
664
|
+
const generation = ++this.loadGeneration;
|
|
665
|
+
if (this.documentGeneration > 0) {
|
|
666
|
+
this.nativeModule?.closeComic?.(this.engineId, this.documentGeneration);
|
|
667
|
+
}
|
|
668
|
+
this.documentGeneration = 0;
|
|
669
|
+
this.pageCount = 0;
|
|
670
|
+
this.currentPage = 1;
|
|
671
|
+
this.zoom = 1;
|
|
672
|
+
const nativeSource = await normalizeNativeSource(source, false);
|
|
673
|
+
if (generation !== this.loadGeneration) return;
|
|
674
|
+
const native = this.assertNativeModule();
|
|
675
|
+
if (!native.loadComic) {
|
|
676
|
+
throw new Error("[Papyrus] Native comic archive loading is not available");
|
|
677
|
+
}
|
|
678
|
+
const engineId = this.engineId;
|
|
679
|
+
this.format = resolveComicFormat(source, format);
|
|
680
|
+
const result = await native.loadComic(
|
|
681
|
+
engineId,
|
|
682
|
+
generation,
|
|
683
|
+
nativeSource,
|
|
684
|
+
this.format
|
|
685
|
+
);
|
|
686
|
+
if (generation !== this.loadGeneration) {
|
|
687
|
+
native.closeComic?.(engineId, generation);
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
this.documentGeneration = generation;
|
|
691
|
+
this.pageCount = Math.max(0, Math.floor(result.pageCount));
|
|
692
|
+
this.currentPage = 1;
|
|
693
|
+
}
|
|
694
|
+
getNativeComicEngineId() {
|
|
695
|
+
return this.engineId;
|
|
696
|
+
}
|
|
697
|
+
getDocumentGeneration() {
|
|
698
|
+
return this.documentGeneration;
|
|
699
|
+
}
|
|
700
|
+
getComicFormat() {
|
|
701
|
+
return this.format;
|
|
702
|
+
}
|
|
703
|
+
getPageCount() {
|
|
704
|
+
return this.pageCount;
|
|
705
|
+
}
|
|
706
|
+
getCurrentPage() {
|
|
707
|
+
return this.currentPage;
|
|
708
|
+
}
|
|
709
|
+
goToPage(page) {
|
|
710
|
+
if (page >= 1 && page <= this.pageCount) this.currentPage = page;
|
|
711
|
+
}
|
|
712
|
+
getRenderTargetType() {
|
|
713
|
+
return "native-comic";
|
|
714
|
+
}
|
|
715
|
+
async getPagePreview(pageIndex) {
|
|
716
|
+
const native = this.assertNativeModule();
|
|
717
|
+
return await native.getComicPagePreview?.(
|
|
718
|
+
this.engineId,
|
|
719
|
+
this.documentGeneration,
|
|
720
|
+
pageIndex,
|
|
721
|
+
1024
|
|
722
|
+
) ?? null;
|
|
723
|
+
}
|
|
724
|
+
setZoom(zoom) {
|
|
725
|
+
this.zoom = Math.max(1, Math.min(5, zoom));
|
|
726
|
+
}
|
|
727
|
+
getZoom() {
|
|
728
|
+
return this.zoom;
|
|
729
|
+
}
|
|
730
|
+
rotate(direction) {
|
|
731
|
+
}
|
|
732
|
+
getRotation() {
|
|
733
|
+
return 0;
|
|
734
|
+
}
|
|
735
|
+
async renderPage() {
|
|
736
|
+
}
|
|
737
|
+
async renderTextLayer() {
|
|
738
|
+
}
|
|
739
|
+
async getTextContent() {
|
|
740
|
+
return [];
|
|
741
|
+
}
|
|
742
|
+
async getPageDimensions() {
|
|
743
|
+
return { width: 0, height: 0 };
|
|
744
|
+
}
|
|
745
|
+
async selectText() {
|
|
746
|
+
return null;
|
|
747
|
+
}
|
|
748
|
+
async getOutline() {
|
|
749
|
+
return [];
|
|
750
|
+
}
|
|
751
|
+
async getPageIndex() {
|
|
752
|
+
return null;
|
|
753
|
+
}
|
|
754
|
+
destroy() {
|
|
755
|
+
this.loadGeneration += 1;
|
|
756
|
+
const engineId = this.engineId;
|
|
757
|
+
if (this.documentGeneration > 0) {
|
|
758
|
+
this.nativeModule?.closeComic?.(engineId, this.documentGeneration);
|
|
759
|
+
}
|
|
760
|
+
this.nativeModule?.destroyEngine?.(engineId);
|
|
761
|
+
this.engineId = "default";
|
|
762
|
+
this.documentGeneration = 0;
|
|
763
|
+
this.pageCount = 0;
|
|
764
|
+
this.currentPage = 1;
|
|
765
|
+
this.zoom = 1;
|
|
766
|
+
}
|
|
767
|
+
assertNativeModule() {
|
|
768
|
+
if (!this.nativeModule) this.nativeModule = resolveNativeModule();
|
|
769
|
+
if (!this.nativeModule) {
|
|
770
|
+
throw new Error('[Papyrus] Native module "PapyrusNativeEngine" not found. Use a dev client or native build.');
|
|
771
|
+
}
|
|
772
|
+
if (this.engineId === "default" && this.nativeModule.createEngine) {
|
|
773
|
+
this.engineId = this.nativeModule.createEngine();
|
|
774
|
+
}
|
|
775
|
+
return this.nativeModule;
|
|
776
|
+
}
|
|
777
|
+
};
|
|
413
778
|
var WebViewDocumentEngine = class extends BaseDocumentEngine {
|
|
414
779
|
constructor(options = {}) {
|
|
415
780
|
super();
|
|
781
|
+
this.documentSessionId = "";
|
|
416
782
|
this.bridge = null;
|
|
417
783
|
this.ready = false;
|
|
418
784
|
this.requestId = 0;
|
|
@@ -427,6 +793,17 @@ var WebViewDocumentEngine = class extends BaseDocumentEngine {
|
|
|
427
793
|
this.webViewRuntimeSource = options.webViewRuntimeSource;
|
|
428
794
|
this.webViewRuntimeConfig = options.webViewRuntimeConfig;
|
|
429
795
|
}
|
|
796
|
+
getWebViewDocumentSessionId() {
|
|
797
|
+
return this.documentSessionId;
|
|
798
|
+
}
|
|
799
|
+
async syncEpubAnnotations(annotations, documentId, labels) {
|
|
800
|
+
if (!this.documentSessionId) return;
|
|
801
|
+
await this.request("epub-annotations", { documentSessionId: this.documentSessionId, annotations, documentId, labels });
|
|
802
|
+
}
|
|
803
|
+
async goToAnnotation(annotation) {
|
|
804
|
+
if (annotation.anchor?.kind !== "epub-cfi") return;
|
|
805
|
+
await this.request("epub-annotation-navigate", { documentSessionId: this.documentSessionId, annotationId: annotation.id });
|
|
806
|
+
}
|
|
430
807
|
getWebViewRuntimeSource() {
|
|
431
808
|
return this.webViewRuntimeSource;
|
|
432
809
|
}
|
|
@@ -613,15 +990,20 @@ var WebViewDocumentEngine = class extends BaseDocumentEngine {
|
|
|
613
990
|
"[WebViewDocumentEngine] Use o NativeDocumentEngine para PDFs no mobile."
|
|
614
991
|
);
|
|
615
992
|
}
|
|
993
|
+
const session = `epub-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
994
|
+
this.documentSessionId = session;
|
|
616
995
|
const payloadSource = await this.normalizeRuntimeSource(
|
|
617
996
|
resolvedType,
|
|
618
997
|
source
|
|
619
998
|
);
|
|
999
|
+
if (session !== this.documentSessionId) throw new Error("Stale document load");
|
|
620
1000
|
const response = await this.request("load", {
|
|
621
1001
|
type: resolvedType,
|
|
1002
|
+
documentSessionId: session,
|
|
622
1003
|
source: payloadSource,
|
|
623
1004
|
...resolvedType === "comic" ? { format: resolveComicFormat(source, format) } : {}
|
|
624
1005
|
});
|
|
1006
|
+
if (session !== this.documentSessionId) throw new Error("Stale document load");
|
|
625
1007
|
if (typeof response?.pageCount === "number")
|
|
626
1008
|
this.pageCount = response.pageCount;
|
|
627
1009
|
if (Array.isArray(response?.outline)) this.outline = response.outline;
|
|
@@ -638,6 +1020,15 @@ var WebViewDocumentEngine = class extends BaseDocumentEngine {
|
|
|
638
1020
|
this.currentPage = page;
|
|
639
1021
|
void this.request("go-to-page", { page });
|
|
640
1022
|
}
|
|
1023
|
+
setEpubReadingMode(mode) {
|
|
1024
|
+
return this.request("set-epub-view-mode", { epubMode: mode, documentSessionId: this.documentSessionId }).then(() => void 0);
|
|
1025
|
+
}
|
|
1026
|
+
goToEpubLocation(cfi) {
|
|
1027
|
+
return this.request("epub-go-to-location", { cfi, documentSessionId: this.documentSessionId }).then(() => void 0);
|
|
1028
|
+
}
|
|
1029
|
+
turnEpubPage(direction) {
|
|
1030
|
+
return this.request("epub-turn-page", { direction, documentSessionId: this.documentSessionId }).then(() => void 0);
|
|
1031
|
+
}
|
|
641
1032
|
setZoom(zoom) {
|
|
642
1033
|
this.zoom = Math.max(0.5, Math.min(4, zoom));
|
|
643
1034
|
void this.request("set-zoom", { zoom: this.zoom });
|
|
@@ -885,7 +1276,10 @@ var WebViewDocumentEngine = class extends BaseDocumentEngine {
|
|
|
885
1276
|
var MobileDocumentEngine = class extends BaseDocumentEngine {
|
|
886
1277
|
constructor(options = {}) {
|
|
887
1278
|
super();
|
|
1279
|
+
this.loadGeneration = 0;
|
|
888
1280
|
this.pdfEngine = new NativeDocumentEngine();
|
|
1281
|
+
this.textEngine = new NativeTextDocumentEngine();
|
|
1282
|
+
this.comicEngine = new NativeComicDocumentEngine();
|
|
889
1283
|
this.webEngine = new WebViewDocumentEngine(options);
|
|
890
1284
|
this.activeEngine = this.pdfEngine;
|
|
891
1285
|
}
|
|
@@ -901,12 +1295,47 @@ var MobileDocumentEngine = class extends BaseDocumentEngine {
|
|
|
901
1295
|
getNativeEngineId() {
|
|
902
1296
|
return this.activeEngine === this.pdfEngine ? this.pdfEngine.getNativeEngineId() : null;
|
|
903
1297
|
}
|
|
1298
|
+
getNativeTextEngineId() {
|
|
1299
|
+
return this.activeEngine === this.textEngine ? this.textEngine.getNativeTextEngineId() : null;
|
|
1300
|
+
}
|
|
1301
|
+
getNativeTextDocumentGeneration() {
|
|
1302
|
+
return this.activeEngine === this.textEngine ? this.textEngine.getDocumentGeneration() : 0;
|
|
1303
|
+
}
|
|
1304
|
+
getNativeComicEngineId() {
|
|
1305
|
+
return this.activeEngine === this.comicEngine ? this.comicEngine.getNativeComicEngineId() : null;
|
|
1306
|
+
}
|
|
1307
|
+
getNativeComicDocumentGeneration() {
|
|
1308
|
+
return this.activeEngine === this.comicEngine ? this.comicEngine.getDocumentGeneration() : 0;
|
|
1309
|
+
}
|
|
1310
|
+
getTextLength() {
|
|
1311
|
+
return this.activeEngine.getTextLength?.() ?? 0;
|
|
1312
|
+
}
|
|
1313
|
+
getCurrentTextOffset() {
|
|
1314
|
+
return this.activeEngine.getCurrentTextOffset?.() ?? 0;
|
|
1315
|
+
}
|
|
1316
|
+
goToTextOffset(offset) {
|
|
1317
|
+
this.activeEngine.goToTextOffset?.(offset);
|
|
1318
|
+
}
|
|
904
1319
|
getLifecycleStats() {
|
|
905
1320
|
return {
|
|
906
1321
|
...this.pdfEngine.getLifecycleStats(),
|
|
907
1322
|
...this.webEngine.getLifecycleStats()
|
|
908
1323
|
};
|
|
909
1324
|
}
|
|
1325
|
+
resolveAnnotationTextRange(annotation) {
|
|
1326
|
+
return this.textEngine.resolveAnnotationTextRange(annotation);
|
|
1327
|
+
}
|
|
1328
|
+
getWebViewDocumentSessionId() {
|
|
1329
|
+
return this.webEngine.getWebViewDocumentSessionId();
|
|
1330
|
+
}
|
|
1331
|
+
syncEpubAnnotations(annotations, documentId, labels) {
|
|
1332
|
+
return this.webEngine.syncEpubAnnotations(annotations, documentId, labels);
|
|
1333
|
+
}
|
|
1334
|
+
goToAnnotation(annotation) {
|
|
1335
|
+
if (annotation.anchor?.kind === "epub-cfi") return this.webEngine.goToAnnotation(annotation);
|
|
1336
|
+
if (annotation.anchor?.kind === "text-range") return this.textEngine.goToTextOffset(annotation.anchor.start);
|
|
1337
|
+
this.activeEngine.goToPage((annotation.anchor?.kind === "pdf-geometry" ? annotation.anchor.pageIndex : annotation.pageIndex) + 1);
|
|
1338
|
+
}
|
|
910
1339
|
attachWebView(bridge) {
|
|
911
1340
|
this.webEngine.attachBridge(bridge);
|
|
912
1341
|
}
|
|
@@ -919,12 +1348,25 @@ var MobileDocumentEngine = class extends BaseDocumentEngine {
|
|
|
919
1348
|
async load(input) {
|
|
920
1349
|
const { source, type, format } = normalizeLoadInput(input);
|
|
921
1350
|
const resolvedType = type ?? inferDocumentType(source);
|
|
922
|
-
|
|
923
|
-
|
|
1351
|
+
const generation = ++this.loadGeneration;
|
|
1352
|
+
const route = resolveNativeMobileDocumentRoute({
|
|
1353
|
+
type: resolvedType,
|
|
1354
|
+
format: resolvedType === "comic" ? resolveComicFormat(source, format) : void 0,
|
|
1355
|
+
platform: Platform.OS,
|
|
1356
|
+
nativeModuleAvailable: resolveNativeModule() !== null,
|
|
1357
|
+
nativeViewAvailable: resolvedType === "text" ? isPapyrusTextDocumentViewAvailable() : resolvedType === "comic" ? isPapyrusComicDocumentViewAvailable() : true
|
|
1358
|
+
});
|
|
1359
|
+
const nextEngine = route === "native-pdf" ? this.pdfEngine : route === "native-text" ? this.textEngine : route === "native-comic" ? this.comicEngine : this.webEngine;
|
|
1360
|
+
if (this.activeEngine !== nextEngine) this.activeEngine.destroy();
|
|
1361
|
+
this.activeEngine = nextEngine;
|
|
1362
|
+
await nextEngine.load({
|
|
924
1363
|
type: resolvedType,
|
|
925
1364
|
source,
|
|
926
1365
|
...resolvedType === "comic" && format ? { format } : {}
|
|
927
1366
|
});
|
|
1367
|
+
if (generation !== this.loadGeneration && this.activeEngine !== nextEngine) {
|
|
1368
|
+
return;
|
|
1369
|
+
}
|
|
928
1370
|
}
|
|
929
1371
|
getPageCount() {
|
|
930
1372
|
return this.activeEngine.getPageCount();
|
|
@@ -935,6 +1377,18 @@ var MobileDocumentEngine = class extends BaseDocumentEngine {
|
|
|
935
1377
|
goToPage(page) {
|
|
936
1378
|
this.activeEngine.goToPage(page);
|
|
937
1379
|
}
|
|
1380
|
+
setEpubReadingMode(mode) {
|
|
1381
|
+
const engine = this.activeEngine;
|
|
1382
|
+
return engine.setEpubReadingMode?.(mode) ?? Promise.reject(new Error("EPUB reading mode unavailable"));
|
|
1383
|
+
}
|
|
1384
|
+
goToEpubLocation(cfi) {
|
|
1385
|
+
const engine = this.activeEngine;
|
|
1386
|
+
return engine.goToEpubLocation?.(cfi) ?? Promise.reject(new Error("EPUB location unavailable"));
|
|
1387
|
+
}
|
|
1388
|
+
turnEpubPage(direction) {
|
|
1389
|
+
const engine = this.activeEngine;
|
|
1390
|
+
return engine.turnEpubPage?.(direction) ?? Promise.resolve();
|
|
1391
|
+
}
|
|
938
1392
|
setZoom(zoom) {
|
|
939
1393
|
this.activeEngine.setZoom(zoom);
|
|
940
1394
|
}
|
|
@@ -969,6 +1423,12 @@ var MobileDocumentEngine = class extends BaseDocumentEngine {
|
|
|
969
1423
|
}
|
|
970
1424
|
return [];
|
|
971
1425
|
}
|
|
1426
|
+
async searchTextRanges(query) {
|
|
1427
|
+
if (typeof this.activeEngine.searchTextRanges === "function") {
|
|
1428
|
+
return await this.activeEngine.searchTextRanges(query);
|
|
1429
|
+
}
|
|
1430
|
+
return [];
|
|
1431
|
+
}
|
|
972
1432
|
async selectText(pageIndex, rect, endpoints) {
|
|
973
1433
|
if (typeof this.activeEngine.selectText === "function") {
|
|
974
1434
|
return await this.activeEngine.selectText(pageIndex, rect, endpoints);
|
|
@@ -982,17 +1442,27 @@ var MobileDocumentEngine = class extends BaseDocumentEngine {
|
|
|
982
1442
|
return await this.activeEngine.getPageIndex(dest);
|
|
983
1443
|
}
|
|
984
1444
|
destroy() {
|
|
1445
|
+
this.loadGeneration += 1;
|
|
985
1446
|
this.pdfEngine.destroy();
|
|
1447
|
+
this.textEngine.destroy();
|
|
1448
|
+
this.comicEngine.destroy();
|
|
986
1449
|
this.webEngine.destroy();
|
|
987
1450
|
}
|
|
988
1451
|
};
|
|
989
1452
|
export {
|
|
990
1453
|
MobileDocumentEngine,
|
|
1454
|
+
NativeComicDocumentEngine,
|
|
991
1455
|
NativeDocumentEngine,
|
|
1456
|
+
NativeTextDocumentEngine,
|
|
1457
|
+
PapyrusComicDocumentView,
|
|
992
1458
|
PapyrusPageView,
|
|
993
1459
|
PapyrusPdfDocumentView,
|
|
994
1460
|
PapyrusPdfViewerView,
|
|
1461
|
+
PapyrusTextDocumentView,
|
|
995
1462
|
WebViewDocumentEngine,
|
|
996
|
-
|
|
1463
|
+
isPapyrusComicDocumentViewAvailable,
|
|
1464
|
+
isPapyrusPdfDocumentViewAvailable,
|
|
1465
|
+
isPapyrusTablet,
|
|
1466
|
+
isPapyrusTextDocumentViewAvailable
|
|
997
1467
|
};
|
|
998
1468
|
//# sourceMappingURL=index.mjs.map
|