rn-update 1.0.0
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/LICENSE +22 -0
- package/README-CN.md +97 -0
- package/README.md +97 -0
- package/THIRD_PARTY_NOTICES.md +8 -0
- package/android/build.gradle +253 -0
- package/android/jni/Android.mk +41 -0
- package/android/jni/Application.mk +20 -0
- package/android/jni/HDiffPatch/.travis.yml +33 -0
- package/android/jni/HDiffPatch/CHANGELOG.md +153 -0
- package/android/jni/HDiffPatch/LICENSE +48 -0
- package/android/jni/HDiffPatch/Makefile +157 -0
- package/android/jni/HDiffPatch/README.md +307 -0
- package/android/jni/HDiffPatch/_atosize.h +83 -0
- package/android/jni/HDiffPatch/_clock_for_demo.h +47 -0
- package/android/jni/HDiffPatch/_dir_ignore.h +191 -0
- package/android/jni/HDiffPatch/builds/android_ndk_jni_mk/Android.mk +37 -0
- package/android/jni/HDiffPatch/builds/android_ndk_jni_mk/Application.mk +7 -0
- package/android/jni/HDiffPatch/builds/android_ndk_jni_mk/build_libs.bat +1 -0
- package/android/jni/HDiffPatch/builds/android_ndk_jni_mk/build_libs.sh +1 -0
- package/android/jni/HDiffPatch/builds/android_ndk_jni_mk/hpatch.c +18 -0
- package/android/jni/HDiffPatch/builds/android_ndk_jni_mk/hpatch.h +20 -0
- package/android/jni/HDiffPatch/builds/android_ndk_jni_mk/hpatch_jni.c +28 -0
- package/android/jni/HDiffPatch/builds/android_ndk_jni_mk/java/com/github/sisong/HPatch.java +8 -0
- package/android/jni/HDiffPatch/builds/codeblocks/HDiffPatch.workspace +8 -0
- package/android/jni/HDiffPatch/builds/codeblocks/HDiffZ.cbp +219 -0
- package/android/jni/HDiffPatch/builds/codeblocks/HPatchZ.cbp +156 -0
- package/android/jni/HDiffPatch/builds/codeblocks/unitTest.cbp +65 -0
- package/android/jni/HDiffPatch/builds/vc/HDiffPatch.sln +105 -0
- package/android/jni/HDiffPatch/builds/vc/HDiffZ.vcxproj +237 -0
- package/android/jni/HDiffPatch/builds/vc/HDiffZ.vcxproj.user +3 -0
- package/android/jni/HDiffPatch/builds/vc/HPatchZ.vcxproj +318 -0
- package/android/jni/HDiffPatch/builds/vc/HPatchZ.vcxproj.user +3 -0
- package/android/jni/HDiffPatch/builds/vc/unitTest.vcxproj +182 -0
- package/android/jni/HDiffPatch/builds/vc/unitTest.vcxproj.user +3 -0
- package/android/jni/HDiffPatch/builds/xcode/HDiffPatch.xcworkspace/contents.xcworkspacedata +30 -0
- package/android/jni/HDiffPatch/builds/xcode/HDiffPatch.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/android/jni/HDiffPatch/builds/xcode/bestParams.xcodeproj/project.pbxproj +408 -0
- package/android/jni/HDiffPatch/builds/xcode/bestParams.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/android/jni/HDiffPatch/builds/xcode/hdiffz.xcodeproj/project.pbxproj +573 -0
- package/android/jni/HDiffPatch/builds/xcode/hdiffz.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/android/jni/HDiffPatch/builds/xcode/hdiffz.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/android/jni/HDiffPatch/builds/xcode/hpatchz.xcodeproj/project.pbxproj +396 -0
- package/android/jni/HDiffPatch/builds/xcode/hpatchz.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/android/jni/HDiffPatch/builds/xcode/lz4.xcodeproj/project.pbxproj +268 -0
- package/android/jni/HDiffPatch/builds/xcode/lz4.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/android/jni/HDiffPatch/builds/xcode/lzma.xcodeproj/project.pbxproj +361 -0
- package/android/jni/HDiffPatch/builds/xcode/lzma.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/android/jni/HDiffPatch/builds/xcode/testHashClash.xcodeproj/project.pbxproj +301 -0
- package/android/jni/HDiffPatch/builds/xcode/testHashClash.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/android/jni/HDiffPatch/builds/xcode/testHashClash.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/android/jni/HDiffPatch/builds/xcode/unitTest.xcodeproj/project.pbxproj +411 -0
- package/android/jni/HDiffPatch/builds/xcode/unitTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/android/jni/HDiffPatch/builds/xcode/zstd.xcodeproj/project.pbxproj +504 -0
- package/android/jni/HDiffPatch/builds/xcode/zstd.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/android/jni/HDiffPatch/checksum_plugin_demo.h +344 -0
- package/android/jni/HDiffPatch/compress_parallel.cpp +166 -0
- package/android/jni/HDiffPatch/compress_parallel.h +59 -0
- package/android/jni/HDiffPatch/compress_plugin_demo.h +1152 -0
- package/android/jni/HDiffPatch/decompress_plugin_demo.h +995 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_diff/dir_diff.cpp +797 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_diff/dir_diff.h +65 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_diff/dir_diff_tools.cpp +200 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_diff/dir_diff_tools.h +178 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_diff/dir_manifest.cpp +357 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_diff/dir_manifest.h +87 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_diff/file_for_dirDiff.h +151 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_patch/dir_patch.c +770 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_patch/dir_patch.h +236 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_patch/dir_patch_private.h +47 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_patch/dir_patch_tools.c +112 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_patch/dir_patch_tools.h +53 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_patch/dir_patch_types.h +61 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_patch/new_dir_output.c +331 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_patch/new_dir_output.h +144 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_patch/new_stream.c +176 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_patch/new_stream.h +84 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_patch/ref_stream.c +146 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_patch/ref_stream.h +61 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_patch/res_handle_limit.c +152 -0
- package/android/jni/HDiffPatch/dirDiffPatch/dir_patch/res_handle_limit.h +76 -0
- package/android/jni/HDiffPatch/file_for_patch.c +524 -0
- package/android/jni/HDiffPatch/file_for_patch.h +259 -0
- package/android/jni/HDiffPatch/hdiffz.cpp +1570 -0
- package/android/jni/HDiffPatch/hpatch_dir_listener.h +290 -0
- package/android/jni/HDiffPatch/hpatchz.c +1221 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/diff.cpp +1025 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/diff.h +116 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/diff_types.h +72 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/bytes_rle.cpp +213 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/bytes_rle.h +63 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/compress_detect.cpp +170 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/compress_detect.h +86 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/config.h +89 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/divsufsort.c +13 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/divsufsort.c.inc.h +398 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/divsufsort.h +194 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/divsufsort64.c +13 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/divsufsort64.h +204 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/divsufsort_private.h +207 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/sssort.c.inc.h +815 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/trsort.c.inc.h +586 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/utils.c.inc.h +381 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/adler_roll.c +352 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/adler_roll.h +137 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/bloom_filter.h +137 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/covers.h +70 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/digest_matcher.cpp +628 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/digest_matcher.h +87 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/stream_serialize.cpp +363 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/stream_serialize.h +139 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/mem_buf.h +68 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/pack_uint.h +115 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/suffix_string.cpp +342 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HDiff/private_diff/suffix_string.h +94 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HPatch/checksum_plugin.h +52 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HPatch/patch.c +2292 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HPatch/patch.h +215 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HPatch/patch_private.h +165 -0
- package/android/jni/HDiffPatch/libHDiffPatch/HPatch/patch_types.h +251 -0
- package/android/jni/HDiffPatch/libParallel/parallel_channel.cpp +174 -0
- package/android/jni/HDiffPatch/libParallel/parallel_channel.h +73 -0
- package/android/jni/HDiffPatch/libParallel/parallel_import.cpp +367 -0
- package/android/jni/HDiffPatch/libParallel/parallel_import.h +92 -0
- package/android/jni/hpatch.c +232 -0
- package/android/jni/hpatch.h +43 -0
- package/android/jni/lzma/Asm/arm/7zCrcOpt.asm +100 -0
- package/android/jni/lzma/Asm/x86/7zAsm.asm +147 -0
- package/android/jni/lzma/Asm/x86/7zCrcOpt.asm +147 -0
- package/android/jni/lzma/Asm/x86/AesOpt.asm +237 -0
- package/android/jni/lzma/Asm/x86/LzmaDecOpt.asm +1258 -0
- package/android/jni/lzma/Asm/x86/XzCrc64Opt.asm +205 -0
- package/android/jni/lzma/C/7z.h +202 -0
- package/android/jni/lzma/C/7zAlloc.c +80 -0
- package/android/jni/lzma/C/7zAlloc.h +19 -0
- package/android/jni/lzma/C/7zArcIn.c +1771 -0
- package/android/jni/lzma/C/7zBuf.c +36 -0
- package/android/jni/lzma/C/7zBuf.h +35 -0
- package/android/jni/lzma/C/7zBuf2.c +52 -0
- package/android/jni/lzma/C/7zCrc.c +128 -0
- package/android/jni/lzma/C/7zCrc.h +25 -0
- package/android/jni/lzma/C/7zCrcOpt.c +115 -0
- package/android/jni/lzma/C/7zDec.c +591 -0
- package/android/jni/lzma/C/7zFile.c +286 -0
- package/android/jni/lzma/C/7zFile.h +83 -0
- package/android/jni/lzma/C/7zStream.c +176 -0
- package/android/jni/lzma/C/7zTypes.h +375 -0
- package/android/jni/lzma/C/7zVersion.h +27 -0
- package/android/jni/lzma/C/7zVersion.rc +55 -0
- package/android/jni/lzma/C/Aes.c +306 -0
- package/android/jni/lzma/C/Aes.h +38 -0
- package/android/jni/lzma/C/AesOpt.c +184 -0
- package/android/jni/lzma/C/Alloc.c +455 -0
- package/android/jni/lzma/C/Alloc.h +51 -0
- package/android/jni/lzma/C/Bcj2.c +257 -0
- package/android/jni/lzma/C/Bcj2.h +146 -0
- package/android/jni/lzma/C/Bcj2Enc.c +311 -0
- package/android/jni/lzma/C/Bra.c +230 -0
- package/android/jni/lzma/C/Bra.h +64 -0
- package/android/jni/lzma/C/Bra86.c +82 -0
- package/android/jni/lzma/C/BraIA64.c +53 -0
- package/android/jni/lzma/C/Compiler.h +33 -0
- package/android/jni/lzma/C/CpuArch.c +218 -0
- package/android/jni/lzma/C/CpuArch.h +336 -0
- package/android/jni/lzma/C/Delta.c +64 -0
- package/android/jni/lzma/C/Delta.h +19 -0
- package/android/jni/lzma/C/DllSecur.c +108 -0
- package/android/jni/lzma/C/DllSecur.h +20 -0
- package/android/jni/lzma/C/LzFind.c +1127 -0
- package/android/jni/lzma/C/LzFind.h +121 -0
- package/android/jni/lzma/C/LzFindMt.c +853 -0
- package/android/jni/lzma/C/LzFindMt.h +101 -0
- package/android/jni/lzma/C/LzHash.h +57 -0
- package/android/jni/lzma/C/Lzma2Dec.c +488 -0
- package/android/jni/lzma/C/Lzma2Dec.h +120 -0
- package/android/jni/lzma/C/Lzma2DecMt.c +1082 -0
- package/android/jni/lzma/C/Lzma2DecMt.h +79 -0
- package/android/jni/lzma/C/Lzma2Enc.c +803 -0
- package/android/jni/lzma/C/Lzma2Enc.h +55 -0
- package/android/jni/lzma/C/Lzma86.h +111 -0
- package/android/jni/lzma/C/Lzma86Dec.c +54 -0
- package/android/jni/lzma/C/Lzma86Enc.c +106 -0
- package/android/jni/lzma/C/LzmaDec.c +1185 -0
- package/android/jni/lzma/C/LzmaDec.h +234 -0
- package/android/jni/lzma/C/LzmaEnc.c +2976 -0
- package/android/jni/lzma/C/LzmaEnc.h +76 -0
- package/android/jni/lzma/C/LzmaLib.c +40 -0
- package/android/jni/lzma/C/LzmaLib.h +131 -0
- package/android/jni/lzma/C/MtCoder.c +601 -0
- package/android/jni/lzma/C/MtCoder.h +141 -0
- package/android/jni/lzma/C/MtDec.c +1138 -0
- package/android/jni/lzma/C/MtDec.h +201 -0
- package/android/jni/lzma/C/Ppmd.h +85 -0
- package/android/jni/lzma/C/Ppmd7.c +712 -0
- package/android/jni/lzma/C/Ppmd7.h +142 -0
- package/android/jni/lzma/C/Ppmd7Dec.c +191 -0
- package/android/jni/lzma/C/Ppmd7Enc.c +187 -0
- package/android/jni/lzma/C/Precomp.h +10 -0
- package/android/jni/lzma/C/RotateDefs.h +30 -0
- package/android/jni/lzma/C/Sha256.c +248 -0
- package/android/jni/lzma/C/Sha256.h +26 -0
- package/android/jni/lzma/C/Sort.c +141 -0
- package/android/jni/lzma/C/Sort.h +18 -0
- package/android/jni/lzma/C/Threads.c +95 -0
- package/android/jni/lzma/C/Threads.h +70 -0
- package/android/jni/lzma/C/ThreadsP.c +396 -0
- package/android/jni/lzma/C/ThreadsP.h +31 -0
- package/android/jni/lzma/C/Util/7z/7z.dsp +241 -0
- package/android/jni/lzma/C/Util/7z/7z.dsw +29 -0
- package/android/jni/lzma/C/Util/7z/7zMain.c +686 -0
- package/android/jni/lzma/C/Util/7z/Precomp.c +4 -0
- package/android/jni/lzma/C/Util/7z/Precomp.h +10 -0
- package/android/jni/lzma/C/Util/7z/makefile +40 -0
- package/android/jni/lzma/C/Util/7z/makefile.gcc +75 -0
- package/android/jni/lzma/C/Util/Lzma/LzmaUtil.c +258 -0
- package/android/jni/lzma/C/Util/Lzma/LzmaUtil.dsp +168 -0
- package/android/jni/lzma/C/Util/Lzma/LzmaUtil.dsw +29 -0
- package/android/jni/lzma/C/Util/Lzma/makefile +28 -0
- package/android/jni/lzma/C/Util/Lzma/makefile.gcc +44 -0
- package/android/jni/lzma/C/Util/LzmaLib/LzmaLib.def +4 -0
- package/android/jni/lzma/C/Util/LzmaLib/LzmaLib.dsp +178 -0
- package/android/jni/lzma/C/Util/LzmaLib/LzmaLib.dsw +29 -0
- package/android/jni/lzma/C/Util/LzmaLib/LzmaLibExports.c +14 -0
- package/android/jni/lzma/C/Util/LzmaLib/makefile +34 -0
- package/android/jni/lzma/C/Util/LzmaLib/resource.rc +3 -0
- package/android/jni/lzma/C/Util/SfxSetup/Precomp.c +4 -0
- package/android/jni/lzma/C/Util/SfxSetup/Precomp.h +10 -0
- package/android/jni/lzma/C/Util/SfxSetup/SfxSetup.c +640 -0
- package/android/jni/lzma/C/Util/SfxSetup/SfxSetup.dsp +231 -0
- package/android/jni/lzma/C/Util/SfxSetup/SfxSetup.dsw +29 -0
- package/android/jni/lzma/C/Util/SfxSetup/makefile +37 -0
- package/android/jni/lzma/C/Util/SfxSetup/makefile_con +38 -0
- package/android/jni/lzma/C/Util/SfxSetup/resource.rc +5 -0
- package/android/jni/lzma/C/Util/SfxSetup/setup.ico +0 -0
- package/android/jni/lzma/C/Xz.c +90 -0
- package/android/jni/lzma/C/Xz.h +460 -0
- package/android/jni/lzma/C/XzCrc64.c +86 -0
- package/android/jni/lzma/C/XzCrc64.h +26 -0
- package/android/jni/lzma/C/XzCrc64Opt.c +69 -0
- package/android/jni/lzma/C/XzDec.c +2766 -0
- package/android/jni/lzma/C/XzEnc.c +1329 -0
- package/android/jni/lzma/C/XzEnc.h +60 -0
- package/android/jni/lzma/C/XzIn.c +319 -0
- package/android/jni/lzma/CPP/7zip/7zip.mak +240 -0
- package/android/jni/lzma/CPP/7zip/Aes.mak +7 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zCompressionMode.cpp +3 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zCompressionMode.h +76 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zDecode.cpp +569 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zDecode.h +70 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zEncode.cpp +678 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zEncode.h +92 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zExtract.cpp +423 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zFolderInStream.cpp +139 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zFolderInStream.h +61 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zHandler.cpp +763 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zHandler.h +181 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zHandlerOut.cpp +942 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zHeader.cpp +19 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zHeader.h +148 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zIn.cpp +1666 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zIn.h +445 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zItem.h +202 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zOut.cpp +901 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zOut.h +335 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zProperties.cpp +174 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zProperties.h +22 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zRegister.cpp +21 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zSpecStream.cpp +22 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zSpecStream.h +35 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zUpdate.cpp +2500 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/7zUpdate.h +139 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/StdAfx.cpp +3 -0
- package/android/jni/lzma/CPP/7zip/Archive/7z/StdAfx.h +8 -0
- package/android/jni/lzma/CPP/7zip/Archive/Archive.def +12 -0
- package/android/jni/lzma/CPP/7zip/Archive/Archive2.def +19 -0
- package/android/jni/lzma/CPP/7zip/Archive/ArchiveExports.cpp +151 -0
- package/android/jni/lzma/CPP/7zip/Archive/Common/CoderMixer2.cpp +1125 -0
- package/android/jni/lzma/CPP/7zip/Archive/Common/CoderMixer2.h +447 -0
- package/android/jni/lzma/CPP/7zip/Archive/Common/DummyOutStream.cpp +17 -0
- package/android/jni/lzma/CPP/7zip/Archive/Common/DummyOutStream.h +25 -0
- package/android/jni/lzma/CPP/7zip/Archive/Common/HandlerOut.cpp +232 -0
- package/android/jni/lzma/CPP/7zip/Archive/Common/HandlerOut.h +110 -0
- package/android/jni/lzma/CPP/7zip/Archive/Common/InStreamWithCRC.cpp +46 -0
- package/android/jni/lzma/CPP/7zip/Archive/Common/InStreamWithCRC.h +67 -0
- package/android/jni/lzma/CPP/7zip/Archive/Common/ItemNameUtils.cpp +88 -0
- package/android/jni/lzma/CPP/7zip/Archive/Common/ItemNameUtils.h +28 -0
- package/android/jni/lzma/CPP/7zip/Archive/Common/MultiStream.cpp +191 -0
- package/android/jni/lzma/CPP/7zip/Archive/Common/MultiStream.h +89 -0
- package/android/jni/lzma/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp +18 -0
- package/android/jni/lzma/CPP/7zip/Archive/Common/OutStreamWithCRC.h +37 -0
- package/android/jni/lzma/CPP/7zip/Archive/Common/ParseProperties.cpp +3 -0
- package/android/jni/lzma/CPP/7zip/Archive/Common/ParseProperties.h +6 -0
- package/android/jni/lzma/CPP/7zip/Archive/Common/StdAfx.h +8 -0
- package/android/jni/lzma/CPP/7zip/Archive/DllExports2.cpp +122 -0
- package/android/jni/lzma/CPP/7zip/Archive/IArchive.h +608 -0
- package/android/jni/lzma/CPP/7zip/Archive/Icons/7z.ico +0 -0
- package/android/jni/lzma/CPP/7zip/Archive/LzmaHandler.cpp +629 -0
- package/android/jni/lzma/CPP/7zip/Archive/SplitHandler.cpp +359 -0
- package/android/jni/lzma/CPP/7zip/Archive/StdAfx.h +8 -0
- package/android/jni/lzma/CPP/7zip/Archive/XzHandler.cpp +1308 -0
- package/android/jni/lzma/CPP/7zip/Archive/XzHandler.h +11 -0
- package/android/jni/lzma/CPP/7zip/Asm.mak +9 -0
- package/android/jni/lzma/CPP/7zip/Bundles/Alone7z/Alone.dsp +1910 -0
- package/android/jni/lzma/CPP/7zip/Bundles/Alone7z/Alone.dsw +29 -0
- package/android/jni/lzma/CPP/7zip/Bundles/Alone7z/StdAfx.cpp +3 -0
- package/android/jni/lzma/CPP/7zip/Bundles/Alone7z/StdAfx.h +8 -0
- package/android/jni/lzma/CPP/7zip/Bundles/Alone7z/makefile +154 -0
- package/android/jni/lzma/CPP/7zip/Bundles/Alone7z/resource.rc +7 -0
- package/android/jni/lzma/CPP/7zip/Bundles/Format7zExtractR/StdAfx.cpp +3 -0
- package/android/jni/lzma/CPP/7zip/Bundles/Format7zExtractR/StdAfx.h +8 -0
- package/android/jni/lzma/CPP/7zip/Bundles/Format7zExtractR/makefile +96 -0
- package/android/jni/lzma/CPP/7zip/Bundles/Format7zExtractR/resource.rc +5 -0
- package/android/jni/lzma/CPP/7zip/Bundles/Format7zR/StdAfx.cpp +3 -0
- package/android/jni/lzma/CPP/7zip/Bundles/Format7zR/StdAfx.h +8 -0
- package/android/jni/lzma/CPP/7zip/Bundles/Format7zR/makefile +116 -0
- package/android/jni/lzma/CPP/7zip/Bundles/Format7zR/resource.rc +5 -0
- package/android/jni/lzma/CPP/7zip/Bundles/LzmaCon/LzmaAlone.cpp +799 -0
- package/android/jni/lzma/CPP/7zip/Bundles/LzmaCon/LzmaCon.dsp +477 -0
- package/android/jni/lzma/CPP/7zip/Bundles/LzmaCon/LzmaCon.dsw +29 -0
- package/android/jni/lzma/CPP/7zip/Bundles/LzmaCon/StdAfx.cpp +3 -0
- package/android/jni/lzma/CPP/7zip/Bundles/LzmaCon/StdAfx.h +8 -0
- package/android/jni/lzma/CPP/7zip/Bundles/LzmaCon/makefile +59 -0
- package/android/jni/lzma/CPP/7zip/Bundles/LzmaCon/makefile.gcc +195 -0
- package/android/jni/lzma/CPP/7zip/Bundles/LzmaCon/resource.rc +3 -0
- package/android/jni/lzma/CPP/7zip/Bundles/LzmaSpec/LzmaSpec.cpp +715 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXCon/7z.ico +0 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXCon/SFXCon.dsp +912 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXCon/SFXCon.dsw +29 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXCon/SfxCon.cpp +482 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXCon/StdAfx.cpp +3 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXCon/StdAfx.h +8 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXCon/makefile +134 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXCon/resource.rc +5 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXSetup/ExtractCallbackSfx.cpp +246 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXSetup/ExtractCallbackSfx.h +86 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXSetup/ExtractEngine.cpp +137 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXSetup/ExtractEngine.h +11 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp +803 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsw +29 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXSetup/SfxSetup.cpp +364 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXSetup/StdAfx.cpp +3 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXSetup/StdAfx.h +13 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXSetup/makefile +117 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXSetup/resource.h +6 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXSetup/resource.rc +16 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXSetup/setup.ico +0 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXWin/7z.ico +0 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXWin/SFXWin.dsp +988 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXWin/SFXWin.dsw +29 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXWin/SfxWin.cpp +241 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXWin/StdAfx.cpp +3 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXWin/StdAfx.h +14 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXWin/makefile +153 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXWin/resource.h +1 -0
- package/android/jni/lzma/CPP/7zip/Bundles/SFXWin/resource.rc +50 -0
- package/android/jni/lzma/CPP/7zip/Common/CWrappers.cpp +250 -0
- package/android/jni/lzma/CPP/7zip/Common/CWrappers.h +120 -0
- package/android/jni/lzma/CPP/7zip/Common/CreateCoder.cpp +536 -0
- package/android/jni/lzma/CPP/7zip/Common/CreateCoder.h +192 -0
- package/android/jni/lzma/CPP/7zip/Common/FilePathAutoRename.cpp +46 -0
- package/android/jni/lzma/CPP/7zip/Common/FilePathAutoRename.h +10 -0
- package/android/jni/lzma/CPP/7zip/Common/FileStreams.cpp +475 -0
- package/android/jni/lzma/CPP/7zip/Common/FileStreams.h +166 -0
- package/android/jni/lzma/CPP/7zip/Common/FilterCoder.cpp +435 -0
- package/android/jni/lzma/CPP/7zip/Common/FilterCoder.h +205 -0
- package/android/jni/lzma/CPP/7zip/Common/InBuffer.cpp +163 -0
- package/android/jni/lzma/CPP/7zip/Common/InBuffer.h +92 -0
- package/android/jni/lzma/CPP/7zip/Common/InOutTempBuffer.cpp +127 -0
- package/android/jni/lzma/CPP/7zip/Common/InOutTempBuffer.h +48 -0
- package/android/jni/lzma/CPP/7zip/Common/LimitedStreams.cpp +367 -0
- package/android/jni/lzma/CPP/7zip/Common/LimitedStreams.h +252 -0
- package/android/jni/lzma/CPP/7zip/Common/LockedStream.cpp +3 -0
- package/android/jni/lzma/CPP/7zip/Common/LockedStream.h +6 -0
- package/android/jni/lzma/CPP/7zip/Common/MethodId.cpp +3 -0
- package/android/jni/lzma/CPP/7zip/Common/MethodId.h +10 -0
- package/android/jni/lzma/CPP/7zip/Common/MethodProps.cpp +509 -0
- package/android/jni/lzma/CPP/7zip/Common/MethodProps.h +264 -0
- package/android/jni/lzma/CPP/7zip/Common/OffsetStream.cpp +39 -0
- package/android/jni/lzma/CPP/7zip/Common/OffsetStream.h +26 -0
- package/android/jni/lzma/CPP/7zip/Common/OutBuffer.cpp +111 -0
- package/android/jni/lzma/CPP/7zip/Common/OutBuffer.h +66 -0
- package/android/jni/lzma/CPP/7zip/Common/ProgressUtils.cpp +51 -0
- package/android/jni/lzma/CPP/7zip/Common/ProgressUtils.h +35 -0
- package/android/jni/lzma/CPP/7zip/Common/PropId.cpp +108 -0
- package/android/jni/lzma/CPP/7zip/Common/RegisterArc.h +78 -0
- package/android/jni/lzma/CPP/7zip/Common/RegisterCodec.h +106 -0
- package/android/jni/lzma/CPP/7zip/Common/StdAfx.h +8 -0
- package/android/jni/lzma/CPP/7zip/Common/StreamBinder.cpp +156 -0
- package/android/jni/lzma/CPP/7zip/Common/StreamBinder.h +60 -0
- package/android/jni/lzma/CPP/7zip/Common/StreamObjects.cpp +285 -0
- package/android/jni/lzma/CPP/7zip/Common/StreamObjects.h +157 -0
- package/android/jni/lzma/CPP/7zip/Common/StreamUtils.cpp +56 -0
- package/android/jni/lzma/CPP/7zip/Common/StreamUtils.h +13 -0
- package/android/jni/lzma/CPP/7zip/Common/UniqBlocks.cpp +57 -0
- package/android/jni/lzma/CPP/7zip/Common/UniqBlocks.h +26 -0
- package/android/jni/lzma/CPP/7zip/Common/VirtThread.cpp +48 -0
- package/android/jni/lzma/CPP/7zip/Common/VirtThread.h +24 -0
- package/android/jni/lzma/CPP/7zip/Compress/Bcj2Coder.cpp +666 -0
- package/android/jni/lzma/CPP/7zip/Compress/Bcj2Coder.h +120 -0
- package/android/jni/lzma/CPP/7zip/Compress/Bcj2Register.cpp +24 -0
- package/android/jni/lzma/CPP/7zip/Compress/BcjCoder.cpp +24 -0
- package/android/jni/lzma/CPP/7zip/Compress/BcjCoder.h +31 -0
- package/android/jni/lzma/CPP/7zip/Compress/BcjRegister.cpp +17 -0
- package/android/jni/lzma/CPP/7zip/Compress/BranchMisc.cpp +23 -0
- package/android/jni/lzma/CPP/7zip/Compress/BranchMisc.h +35 -0
- package/android/jni/lzma/CPP/7zip/Compress/BranchRegister.cpp +41 -0
- package/android/jni/lzma/CPP/7zip/Compress/ByteSwap.cpp +92 -0
- package/android/jni/lzma/CPP/7zip/Compress/CodecExports.cpp +344 -0
- package/android/jni/lzma/CPP/7zip/Compress/CopyCoder.cpp +120 -0
- package/android/jni/lzma/CPP/7zip/Compress/CopyCoder.h +49 -0
- package/android/jni/lzma/CPP/7zip/Compress/CopyRegister.cpp +15 -0
- package/android/jni/lzma/CPP/7zip/Compress/DeltaFilter.cpp +128 -0
- package/android/jni/lzma/CPP/7zip/Compress/Lzma2Decoder.cpp +265 -0
- package/android/jni/lzma/CPP/7zip/Compress/Lzma2Decoder.h +96 -0
- package/android/jni/lzma/CPP/7zip/Compress/Lzma2Encoder.cpp +122 -0
- package/android/jni/lzma/CPP/7zip/Compress/Lzma2Encoder.h +42 -0
- package/android/jni/lzma/CPP/7zip/Compress/Lzma2Register.cpp +22 -0
- package/android/jni/lzma/CPP/7zip/Compress/LzmaDecoder.cpp +343 -0
- package/android/jni/lzma/CPP/7zip/Compress/LzmaDecoder.h +113 -0
- package/android/jni/lzma/CPP/7zip/Compress/LzmaEncoder.cpp +182 -0
- package/android/jni/lzma/CPP/7zip/Compress/LzmaEncoder.h +46 -0
- package/android/jni/lzma/CPP/7zip/Compress/LzmaRegister.cpp +22 -0
- package/android/jni/lzma/CPP/7zip/Compress/PpmdDecoder.cpp +170 -0
- package/android/jni/lzma/CPP/7zip/Compress/PpmdDecoder.h +86 -0
- package/android/jni/lzma/CPP/7zip/Compress/PpmdEncoder.cpp +152 -0
- package/android/jni/lzma/CPP/7zip/Compress/PpmdEncoder.h +58 -0
- package/android/jni/lzma/CPP/7zip/Compress/PpmdRegister.cpp +22 -0
- package/android/jni/lzma/CPP/7zip/Compress/StdAfx.h +8 -0
- package/android/jni/lzma/CPP/7zip/Compress/XzDecoder.cpp +150 -0
- package/android/jni/lzma/CPP/7zip/Compress/XzDecoder.h +92 -0
- package/android/jni/lzma/CPP/7zip/Compress/XzEncoder.cpp +245 -0
- package/android/jni/lzma/CPP/7zip/Compress/XzEncoder.h +46 -0
- package/android/jni/lzma/CPP/7zip/Crc.mak +8 -0
- package/android/jni/lzma/CPP/7zip/Crc64.mak +8 -0
- package/android/jni/lzma/CPP/7zip/Crypto/7zAes.cpp +280 -0
- package/android/jni/lzma/CPP/7zip/Crypto/7zAes.h +118 -0
- package/android/jni/lzma/CPP/7zip/Crypto/7zAesRegister.cpp +17 -0
- package/android/jni/lzma/CPP/7zip/Crypto/MyAes.cpp +112 -0
- package/android/jni/lzma/CPP/7zip/Crypto/MyAes.h +57 -0
- package/android/jni/lzma/CPP/7zip/Crypto/MyAesReg.cpp +16 -0
- package/android/jni/lzma/CPP/7zip/Crypto/RandGen.cpp +233 -0
- package/android/jni/lzma/CPP/7zip/Crypto/RandGen.h +40 -0
- package/android/jni/lzma/CPP/7zip/Crypto/StdAfx.h +8 -0
- package/android/jni/lzma/CPP/7zip/GuiCommon.rc +84 -0
- package/android/jni/lzma/CPP/7zip/Guid.txt +220 -0
- package/android/jni/lzma/CPP/7zip/ICoder.h +399 -0
- package/android/jni/lzma/CPP/7zip/IDecl.h +28 -0
- package/android/jni/lzma/CPP/7zip/IPassword.h +23 -0
- package/android/jni/lzma/CPP/7zip/IProgress.h +19 -0
- package/android/jni/lzma/CPP/7zip/IStream.h +127 -0
- package/android/jni/lzma/CPP/7zip/LzmaDec.mak +5 -0
- package/android/jni/lzma/CPP/7zip/MyVersion.h +2 -0
- package/android/jni/lzma/CPP/7zip/MyVersionInfo.rc +2 -0
- package/android/jni/lzma/CPP/7zip/PropID.h +127 -0
- package/android/jni/lzma/CPP/7zip/SubBuild.mak +3 -0
- package/android/jni/lzma/CPP/7zip/UI/Client7z/Client7z.cpp +993 -0
- package/android/jni/lzma/CPP/7zip/UI/Client7z/Client7z.dsp +235 -0
- package/android/jni/lzma/CPP/7zip/UI/Client7z/Client7z.dsw +29 -0
- package/android/jni/lzma/CPP/7zip/UI/Client7z/StdAfx.cpp +3 -0
- package/android/jni/lzma/CPP/7zip/UI/Client7z/StdAfx.h +8 -0
- package/android/jni/lzma/CPP/7zip/UI/Client7z/makefile +28 -0
- package/android/jni/lzma/CPP/7zip/UI/Client7z/resource.rc +3 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/ArchiveCommandLine.cpp +1295 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/ArchiveCommandLine.h +136 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp +1715 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/ArchiveExtractCallback.h +403 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/ArchiveName.cpp +155 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/ArchiveName.h +10 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp +161 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/ArchiveOpenCallback.h +112 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/Bench.cpp +3618 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/Bench.h +77 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/DefaultName.cpp +37 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/DefaultName.h +11 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/DirItem.h +190 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/EnumDirItems.cpp +1096 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/EnumDirItems.h +42 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/ExitCode.h +27 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/Extract.cpp +482 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/Extract.h +94 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/ExtractMode.h +34 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/ExtractingFilePath.cpp +280 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/ExtractingFilePath.h +31 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/HashCalc.cpp +347 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/HashCalc.h +110 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/IFileExtractCallback.h +114 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/LoadCodecs.cpp +1074 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/LoadCodecs.h +424 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/OpenArchive.cpp +3553 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/OpenArchive.h +436 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/PropIDUtils.cpp +668 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/PropIDUtils.h +18 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/Property.h +14 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/SetProperties.cpp +80 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/SetProperties.h +10 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/SortUtils.cpp +25 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/SortUtils.h +10 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/StdAfx.h +8 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/TempFiles.cpp +19 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/TempFiles.h +16 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/Update.cpp +1704 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/Update.h +200 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/UpdateAction.cpp +64 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/UpdateAction.h +66 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/UpdateCallback.cpp +771 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/UpdateCallback.h +162 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/UpdatePair.cpp +233 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/UpdatePair.h +27 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/UpdateProduce.cpp +70 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/UpdateProduce.h +55 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/WorkDir.cpp +94 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/WorkDir.h +26 -0
- package/android/jni/lzma/CPP/7zip/UI/Common/ZipRegistry.h +130 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/BenchCon.cpp +41 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/BenchCon.h +14 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/Console.mak +43 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/Console.manifest +13 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/ConsoleClose.cpp +69 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/ConsoleClose.h +33 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp +825 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/ExtractCallbackConsole.h +164 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/HashCon.cpp +367 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/HashCon.h +48 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/List.cpp +1359 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/List.h +27 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/Main.cpp +1154 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/MainAr.cpp +175 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/OpenCallbackConsole.cpp +115 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/OpenCallbackConsole.h +66 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/PercentPrinter.cpp +183 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/PercentPrinter.h +62 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/StdAfx.cpp +3 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/StdAfx.h +8 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp +702 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/UpdateCallbackConsole.h +124 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/UserInputUtils.cpp +110 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/UserInputUtils.h +27 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/makefile +64 -0
- package/android/jni/lzma/CPP/7zip/UI/Console/resource.rc +7 -0
- package/android/jni/lzma/CPP/7zip/UI/Explorer/MyMessages.cpp +37 -0
- package/android/jni/lzma/CPP/7zip/UI/Explorer/MyMessages.h +16 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/BrowseDialog.cpp +1025 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/BrowseDialog.h +21 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/BrowseDialogRes.h +9 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/ComboDialog.cpp +64 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/ComboDialog.h +28 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/ComboDialogRes.h +4 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/DialogSize.h +16 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/ExtractCallback.cpp +1037 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/ExtractCallback.h +328 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/FormatUtils.cpp +28 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/FormatUtils.h +14 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/LangUtils.h +40 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/MyWindowsNew.h +76 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/OverwriteDialog.cpp +122 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/OverwriteDialog.h +69 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/OverwriteDialog.rc +91 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/OverwriteDialogRes.h +17 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/PasswordDialog.cpp +58 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/PasswordDialog.h +28 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/PasswordDialog.rc +14 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/PasswordDialogRes.h +5 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/ProgressDialog.cpp +196 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/ProgressDialog.h +170 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/ProgressDialog.rc +12 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/ProgressDialog2.cpp +1337 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/ProgressDialog2.h +351 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/ProgressDialog2.rc +40 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/ProgressDialog2Res.h +48 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/ProgressDialog2a.rc +80 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/ProgressDialogRes.h +3 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/PropertyName.cpp +23 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/PropertyName.h +10 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/PropertyNameRes.h +95 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/SysIconUtils.cpp +255 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/SysIconUtils.h +62 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/resource.h +177 -0
- package/android/jni/lzma/CPP/7zip/UI/FileManager/resourceGui.h +15 -0
- package/android/jni/lzma/CPP/7zip/UI/GUI/Extract.rc +59 -0
- package/android/jni/lzma/CPP/7zip/UI/GUI/ExtractDialog.cpp +418 -0
- package/android/jni/lzma/CPP/7zip/UI/GUI/ExtractDialog.h +113 -0
- package/android/jni/lzma/CPP/7zip/UI/GUI/ExtractDialog.rc +98 -0
- package/android/jni/lzma/CPP/7zip/UI/GUI/ExtractDialogRes.h +24 -0
- package/android/jni/lzma/CPP/7zip/UI/GUI/ExtractGUI.cpp +280 -0
- package/android/jni/lzma/CPP/7zip/UI/GUI/ExtractGUI.h +38 -0
- package/android/jni/lzma/CPP/7zip/UI/GUI/ExtractRes.h +51 -0
- package/android/jni/lzma/CPP/7zip/UI/GUI/HashGUI.h +27 -0
- package/android/jni/lzma/CPP/7zip/UI/GUI/resource2.h +2 -0
- package/android/jni/lzma/CPP/Build.mak +156 -0
- package/android/jni/lzma/CPP/Common/AutoPtr.h +35 -0
- package/android/jni/lzma/CPP/Common/CRC.cpp +7 -0
- package/android/jni/lzma/CPP/Common/C_FileIO.cpp +92 -0
- package/android/jni/lzma/CPP/Common/C_FileIO.h +53 -0
- package/android/jni/lzma/CPP/Common/ComTry.h +21 -0
- package/android/jni/lzma/CPP/Common/CommandLineParser.cpp +197 -0
- package/android/jni/lzma/CPP/Common/CommandLineParser.h +63 -0
- package/android/jni/lzma/CPP/Common/Common.h +43 -0
- package/android/jni/lzma/CPP/Common/CrcReg.cpp +98 -0
- package/android/jni/lzma/CPP/Common/Defs.h +15 -0
- package/android/jni/lzma/CPP/Common/DynamicBuffer.h +64 -0
- package/android/jni/lzma/CPP/Common/IntToString.cpp +193 -0
- package/android/jni/lzma/CPP/Common/IntToString.h +28 -0
- package/android/jni/lzma/CPP/Common/Lang.h +23 -0
- package/android/jni/lzma/CPP/Common/ListFileUtils.cpp +132 -0
- package/android/jni/lzma/CPP/Common/ListFileUtils.h +18 -0
- package/android/jni/lzma/CPP/Common/MyBuffer.h +259 -0
- package/android/jni/lzma/CPP/Common/MyBuffer2.h +100 -0
- package/android/jni/lzma/CPP/Common/MyCom.h +277 -0
- package/android/jni/lzma/CPP/Common/MyException.h +14 -0
- package/android/jni/lzma/CPP/Common/MyGuidDef.h +54 -0
- package/android/jni/lzma/CPP/Common/MyInitGuid.h +45 -0
- package/android/jni/lzma/CPP/Common/MyLinux.h +42 -0
- package/android/jni/lzma/CPP/Common/MyString.cpp +1659 -0
- package/android/jni/lzma/CPP/Common/MyString.h +868 -0
- package/android/jni/lzma/CPP/Common/MyTypes.h +35 -0
- package/android/jni/lzma/CPP/Common/MyUnknown.h +17 -0
- package/android/jni/lzma/CPP/Common/MyVector.cpp +3 -0
- package/android/jni/lzma/CPP/Common/MyVector.h +634 -0
- package/android/jni/lzma/CPP/Common/MyWindows.cpp +145 -0
- package/android/jni/lzma/CPP/Common/MyWindows.h +231 -0
- package/android/jni/lzma/CPP/Common/NewHandler.cpp +163 -0
- package/android/jni/lzma/CPP/Common/NewHandler.h +88 -0
- package/android/jni/lzma/CPP/Common/Sha256Reg.cpp +40 -0
- package/android/jni/lzma/CPP/Common/StdAfx.h +8 -0
- package/android/jni/lzma/CPP/Common/StdInStream.cpp +89 -0
- package/android/jni/lzma/CPP/Common/StdInStream.h +38 -0
- package/android/jni/lzma/CPP/Common/StdOutStream.cpp +163 -0
- package/android/jni/lzma/CPP/Common/StdOutStream.h +71 -0
- package/android/jni/lzma/CPP/Common/StringConvert.cpp +319 -0
- package/android/jni/lzma/CPP/Common/StringConvert.h +88 -0
- package/android/jni/lzma/CPP/Common/StringToInt.cpp +144 -0
- package/android/jni/lzma/CPP/Common/StringToInt.h +21 -0
- package/android/jni/lzma/CPP/Common/TextConfig.cpp +124 -0
- package/android/jni/lzma/CPP/Common/TextConfig.h +19 -0
- package/android/jni/lzma/CPP/Common/UTFConvert.cpp +288 -0
- package/android/jni/lzma/CPP/Common/UTFConvert.h +12 -0
- package/android/jni/lzma/CPP/Common/Wildcard.cpp +676 -0
- package/android/jni/lzma/CPP/Common/Wildcard.h +149 -0
- package/android/jni/lzma/CPP/Common/XzCrc64Init.cpp +7 -0
- package/android/jni/lzma/CPP/Common/XzCrc64Reg.cpp +42 -0
- package/android/jni/lzma/CPP/Windows/COM.h +70 -0
- package/android/jni/lzma/CPP/Windows/CommonDialog.cpp +185 -0
- package/android/jni/lzma/CPP/Windows/CommonDialog.h +23 -0
- package/android/jni/lzma/CPP/Windows/Control/ComboBox.cpp +66 -0
- package/android/jni/lzma/CPP/Windows/Control/ComboBox.h +65 -0
- package/android/jni/lzma/CPP/Windows/Control/CommandBar.h +52 -0
- package/android/jni/lzma/CPP/Windows/Control/Dialog.cpp +251 -0
- package/android/jni/lzma/CPP/Windows/Control/Dialog.h +170 -0
- package/android/jni/lzma/CPP/Windows/Control/Edit.h +19 -0
- package/android/jni/lzma/CPP/Windows/Control/ImageList.cpp +10 -0
- package/android/jni/lzma/CPP/Windows/Control/ImageList.h +87 -0
- package/android/jni/lzma/CPP/Windows/Control/ListView.cpp +155 -0
- package/android/jni/lzma/CPP/Windows/Control/ListView.h +146 -0
- package/android/jni/lzma/CPP/Windows/Control/ProgressBar.h +35 -0
- package/android/jni/lzma/CPP/Windows/Control/PropertyPage.cpp +143 -0
- package/android/jni/lzma/CPP/Windows/Control/PropertyPage.h +50 -0
- package/android/jni/lzma/CPP/Windows/Control/ReBar.h +34 -0
- package/android/jni/lzma/CPP/Windows/Control/Static.h +28 -0
- package/android/jni/lzma/CPP/Windows/Control/StatusBar.h +42 -0
- package/android/jni/lzma/CPP/Windows/Control/StdAfx.h +8 -0
- package/android/jni/lzma/CPP/Windows/Control/ToolBar.h +43 -0
- package/android/jni/lzma/CPP/Windows/Control/Trackbar.h +27 -0
- package/android/jni/lzma/CPP/Windows/Control/Window2.cpp +200 -0
- package/android/jni/lzma/CPP/Windows/Control/Window2.h +51 -0
- package/android/jni/lzma/CPP/Windows/DLL.cpp +109 -0
- package/android/jni/lzma/CPP/Windows/DLL.h +58 -0
- package/android/jni/lzma/CPP/Windows/Defs.h +17 -0
- package/android/jni/lzma/CPP/Windows/ErrorMsg.cpp +66 -0
- package/android/jni/lzma/CPP/Windows/ErrorMsg.h +15 -0
- package/android/jni/lzma/CPP/Windows/FileDir.cpp +714 -0
- package/android/jni/lzma/CPP/Windows/FileDir.h +117 -0
- package/android/jni/lzma/CPP/Windows/FileFind.cpp +749 -0
- package/android/jni/lzma/CPP/Windows/FileFind.h +161 -0
- package/android/jni/lzma/CPP/Windows/FileIO.cpp +432 -0
- package/android/jni/lzma/CPP/Windows/FileIO.h +212 -0
- package/android/jni/lzma/CPP/Windows/FileLink.cpp +440 -0
- package/android/jni/lzma/CPP/Windows/FileMapping.cpp +12 -0
- package/android/jni/lzma/CPP/Windows/FileMapping.h +66 -0
- package/android/jni/lzma/CPP/Windows/FileName.cpp +839 -0
- package/android/jni/lzma/CPP/Windows/FileName.h +115 -0
- package/android/jni/lzma/CPP/Windows/FileSystem.cpp +131 -0
- package/android/jni/lzma/CPP/Windows/FileSystem.h +27 -0
- package/android/jni/lzma/CPP/Windows/Handle.h +37 -0
- package/android/jni/lzma/CPP/Windows/MemoryLock.cpp +112 -0
- package/android/jni/lzma/CPP/Windows/MemoryLock.h +40 -0
- package/android/jni/lzma/CPP/Windows/NtCheck.h +46 -0
- package/android/jni/lzma/CPP/Windows/PropVariant.cpp +347 -0
- package/android/jni/lzma/CPP/Windows/PropVariant.h +114 -0
- package/android/jni/lzma/CPP/Windows/PropVariantConv.cpp +138 -0
- package/android/jni/lzma/CPP/Windows/PropVariantConv.h +37 -0
- package/android/jni/lzma/CPP/Windows/Registry.cpp +390 -0
- package/android/jni/lzma/CPP/Windows/Registry.h +84 -0
- package/android/jni/lzma/CPP/Windows/ResourceString.cpp +103 -0
- package/android/jni/lzma/CPP/Windows/ResourceString.h +16 -0
- package/android/jni/lzma/CPP/Windows/SecurityUtils.cpp +181 -0
- package/android/jni/lzma/CPP/Windows/SecurityUtils.h +167 -0
- package/android/jni/lzma/CPP/Windows/Shell.cpp +358 -0
- package/android/jni/lzma/CPP/Windows/Shell.h +94 -0
- package/android/jni/lzma/CPP/Windows/StdAfx.h +8 -0
- package/android/jni/lzma/CPP/Windows/Synchronization.cpp +10 -0
- package/android/jni/lzma/CPP/Windows/Synchronization.h +164 -0
- package/android/jni/lzma/CPP/Windows/System.cpp +142 -0
- package/android/jni/lzma/CPP/Windows/System.h +40 -0
- package/android/jni/lzma/CPP/Windows/Thread.h +38 -0
- package/android/jni/lzma/CPP/Windows/TimeUtils.cpp +213 -0
- package/android/jni/lzma/CPP/Windows/TimeUtils.h +32 -0
- package/android/jni/lzma/CPP/Windows/Window.cpp +179 -0
- package/android/jni/lzma/CPP/Windows/Window.h +284 -0
- package/android/jni/lzma/CS/7zip/Common/CRC.cs +55 -0
- package/android/jni/lzma/CS/7zip/Common/CommandLineParser.cs +274 -0
- package/android/jni/lzma/CS/7zip/Common/InBuffer.cs +72 -0
- package/android/jni/lzma/CS/7zip/Common/OutBuffer.cs +47 -0
- package/android/jni/lzma/CS/7zip/Compress/LZ/IMatchFinder.cs +24 -0
- package/android/jni/lzma/CS/7zip/Compress/LZ/LzBinTree.cs +367 -0
- package/android/jni/lzma/CS/7zip/Compress/LZ/LzInWindow.cs +132 -0
- package/android/jni/lzma/CS/7zip/Compress/LZ/LzOutWindow.cs +110 -0
- package/android/jni/lzma/CS/7zip/Compress/LZMA/LzmaBase.cs +76 -0
- package/android/jni/lzma/CS/7zip/Compress/LZMA/LzmaDecoder.cs +398 -0
- package/android/jni/lzma/CS/7zip/Compress/LZMA/LzmaEncoder.cs +1480 -0
- package/android/jni/lzma/CS/7zip/Compress/LzmaAlone/LzmaAlone.cs +364 -0
- package/android/jni/lzma/CS/7zip/Compress/LzmaAlone/LzmaAlone.csproj +90 -0
- package/android/jni/lzma/CS/7zip/Compress/LzmaAlone/LzmaAlone.sln +20 -0
- package/android/jni/lzma/CS/7zip/Compress/LzmaAlone/LzmaBench.cs +340 -0
- package/android/jni/lzma/CS/7zip/Compress/LzmaAlone/Properties/AssemblyInfo.cs +29 -0
- package/android/jni/lzma/CS/7zip/Compress/LzmaAlone/Properties/Resources.cs +70 -0
- package/android/jni/lzma/CS/7zip/Compress/LzmaAlone/Properties/Settings.cs +42 -0
- package/android/jni/lzma/CS/7zip/Compress/RangeCoder/RangeCoder.cs +234 -0
- package/android/jni/lzma/CS/7zip/Compress/RangeCoder/RangeCoderBit.cs +117 -0
- package/android/jni/lzma/CS/7zip/Compress/RangeCoder/RangeCoderBitTree.cs +157 -0
- package/android/jni/lzma/CS/7zip/ICoder.cs +157 -0
- package/android/jni/lzma/DOC/7zC.txt +187 -0
- package/android/jni/lzma/DOC/7zFormat.txt +469 -0
- package/android/jni/lzma/DOC/Methods.txt +173 -0
- package/android/jni/lzma/DOC/installer.txt +166 -0
- package/android/jni/lzma/DOC/lzma-history.txt +446 -0
- package/android/jni/lzma/DOC/lzma-sdk.txt +357 -0
- package/android/jni/lzma/DOC/lzma-specification.txt +1176 -0
- package/android/jni/lzma/DOC/lzma.txt +328 -0
- package/android/jni/lzma/Java/SevenZip/CRC.java +52 -0
- package/android/jni/lzma/Java/SevenZip/Compression/LZ/BinTree.java +382 -0
- package/android/jni/lzma/Java/SevenZip/Compression/LZ/InWindow.java +131 -0
- package/android/jni/lzma/Java/SevenZip/Compression/LZ/OutWindow.java +85 -0
- package/android/jni/lzma/Java/SevenZip/Compression/LZMA/Base.java +88 -0
- package/android/jni/lzma/Java/SevenZip/Compression/LZMA/Decoder.java +329 -0
- package/android/jni/lzma/Java/SevenZip/Compression/LZMA/Encoder.java +1416 -0
- package/android/jni/lzma/Java/SevenZip/Compression/RangeCoder/BitTreeDecoder.java +55 -0
- package/android/jni/lzma/Java/SevenZip/Compression/RangeCoder/BitTreeEncoder.java +99 -0
- package/android/jni/lzma/Java/SevenZip/Compression/RangeCoder/Decoder.java +88 -0
- package/android/jni/lzma/Java/SevenZip/Compression/RangeCoder/Encoder.java +151 -0
- package/android/jni/lzma/Java/SevenZip/ICodeProgress.java +6 -0
- package/android/jni/lzma/Java/SevenZip/LzmaAlone.java +253 -0
- package/android/jni/lzma/Java/SevenZip/LzmaBench.java +392 -0
- package/android/jni/lzma/bin/7zS2.sfx +0 -0
- package/android/jni/lzma/bin/7zS2con.sfx +0 -0
- package/android/jni/lzma/bin/7zSD.sfx +0 -0
- package/android/jni/lzma/bin/installer/config.txt +5 -0
- package/android/jni/lzma/bin/installer/cr.bat +5 -0
- package/android/lib/arm64-v8a/librnupdate.so +0 -0
- package/android/lib/armeabi-v7a/librnupdate.so +0 -0
- package/android/lib/x86/librnupdate.so +0 -0
- package/android/lib/x86_64/librnupdate.so +0 -0
- package/android/proguard.pro +83 -0
- package/android/src/main/AndroidManifest.xml +14 -0
- package/android/src/main/AndroidManifestNew.xml +13 -0
- package/android/src/main/java/cn/reactnative/modules/update/ApkInstaller.java +292 -0
- package/android/src/main/java/cn/reactnative/modules/update/ArchiveLimits.java +50 -0
- package/android/src/main/java/cn/reactnative/modules/update/ArchivePatchPlanResult.java +11 -0
- package/android/src/main/java/cn/reactnative/modules/update/BundledResourceCopier.java +394 -0
- package/android/src/main/java/cn/reactnative/modules/update/CleanupKeepNames.java +30 -0
- package/android/src/main/java/cn/reactnative/modules/update/CopyGroupResult.java +11 -0
- package/android/src/main/java/cn/reactnative/modules/update/CrashRescue.java +120 -0
- package/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java +954 -0
- package/android/src/main/java/cn/reactnative/modules/update/DownloadTaskParams.java +64 -0
- package/android/src/main/java/cn/reactnative/modules/update/ErrorCodes.java +32 -0
- package/android/src/main/java/cn/reactnative/modules/update/FileOperationException.java +20 -0
- package/android/src/main/java/cn/reactnative/modules/update/HttpUtils.java +64 -0
- package/android/src/main/java/cn/reactnative/modules/update/InstallRecord.java +156 -0
- package/android/src/main/java/cn/reactnative/modules/update/NativeCheckOrchestrator.java +725 -0
- package/android/src/main/java/cn/reactnative/modules/update/NativeUpdateCore.java +43 -0
- package/android/src/main/java/cn/reactnative/modules/update/NativeUpdateFlow.java +30 -0
- package/android/src/main/java/cn/reactnative/modules/update/PackageInstallerStatusReceiver.java +17 -0
- package/android/src/main/java/cn/reactnative/modules/update/PatchFailedException.java +21 -0
- package/android/src/main/java/cn/reactnative/modules/update/ReactReloadManager.java +274 -0
- package/android/src/main/java/cn/reactnative/modules/update/SafeZipFile.java +187 -0
- package/android/src/main/java/cn/reactnative/modules/update/StateCoreResult.java +22 -0
- package/android/src/main/java/cn/reactnative/modules/update/StateSerialRunner.java +70 -0
- package/android/src/main/java/cn/reactnative/modules/update/UiThreadRunner.java +42 -0
- package/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java +952 -0
- package/android/src/main/java/cn/reactnative/modules/update/UpdateEventEmitter.java +70 -0
- package/android/src/main/java/cn/reactnative/modules/update/UpdateFileUtils.java +110 -0
- package/android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java +403 -0
- package/android/src/main/java/cn/reactnative/modules/update/UpdatePackage.java +51 -0
- package/android/src/main/java/expo/modules/pakta/ExpoPaktaModule.kt +15 -0
- package/android/src/main/java/expo/modules/pakta/ExpoPaktaPackage.java +29 -0
- package/android/src/newarch/cn/reactnative/modules/update/UpdateModule.java +126 -0
- package/android/src/oldarch/cn/reactnative/modules/update/UpdateModule.java +130 -0
- package/cpp/patch_core/archive_limits.h +49 -0
- package/cpp/patch_core/archive_patch_core.cpp +146 -0
- package/cpp/patch_core/archive_patch_core.h +69 -0
- package/cpp/patch_core/digest.cpp +235 -0
- package/cpp/patch_core/digest.h +66 -0
- package/cpp/patch_core/error_codes.h +57 -0
- package/cpp/patch_core/hbc_transform.cpp +152 -0
- package/cpp/patch_core/hbc_transform.h +58 -0
- package/cpp/patch_core/hbc_transform_wire.cpp +332 -0
- package/cpp/patch_core/hbc_transform_wire.h +57 -0
- package/cpp/patch_core/install_record.h +41 -0
- package/cpp/patch_core/jni_util.h +65 -0
- package/cpp/patch_core/patch_core.cpp +849 -0
- package/cpp/patch_core/patch_core.h +103 -0
- package/cpp/patch_core/patch_core_android.cpp +102 -0
- package/cpp/patch_core/state_core.cpp +122 -0
- package/cpp/patch_core/state_core.h +66 -0
- package/cpp/patch_core/state_ops.h +29 -0
- package/cpp/patch_core/update_core_android.cpp +502 -0
- package/cpp/update_flow_core/flow_json.cpp +660 -0
- package/cpp/update_flow_core/flow_json.h +121 -0
- package/cpp/update_flow_core/update_flow_core.cpp +418 -0
- package/cpp/update_flow_core/update_flow_core.h +100 -0
- package/cpp/update_flow_core/update_flow_jni.cpp +157 -0
- package/expo-module.config.json +13 -0
- package/harmony/hvigor-plugin.ts +212 -0
- package/harmony/pakta/src/README.md +74 -0
- package/harmony/pakta/src/main/cpp/CMakeLists.txt +92 -0
- package/harmony/pakta/src/main/cpp/PaktaPackage.h +60 -0
- package/harmony/pakta/src/main/cpp/PaktaTurboModule.cpp +123 -0
- package/harmony/pakta/src/main/cpp/PaktaTurboModule.h +43 -0
- package/harmony/pakta/src/main/cpp/pakta.cpp +1243 -0
- package/harmony/pakta/src/main/ets/ArchiveLimits.ts +144 -0
- package/harmony/pakta/src/main/ets/DownloadTask.ts +1375 -0
- package/harmony/pakta/src/main/ets/DownloadTaskParams.ts +27 -0
- package/harmony/pakta/src/main/ets/ErrorCodes.ts +80 -0
- package/harmony/pakta/src/main/ets/EventHub.ts +46 -0
- package/harmony/pakta/src/main/ets/InstallRecord.ts +192 -0
- package/harmony/pakta/src/main/ets/Logger.ts +83 -0
- package/harmony/pakta/src/main/ets/MonotonicClock.ts +18 -0
- package/harmony/pakta/src/main/ets/NativeCheckOrchestrator.ts +640 -0
- package/harmony/pakta/src/main/ets/NativePatchCore.ts +123 -0
- package/harmony/pakta/src/main/ets/PaktaFileJSBundleProvider.ets +54 -0
- package/harmony/pakta/src/main/ets/PaktaPackage.ets +15 -0
- package/harmony/pakta/src/main/ets/PaktaPackageCompat.ts +15 -0
- package/harmony/pakta/src/main/ets/PaktaPackageFactory.ts +19 -0
- package/harmony/pakta/src/main/ets/PaktaTurboModule.ts +433 -0
- package/harmony/pakta/src/main/ets/PathUtils.ts +32 -0
- package/harmony/pakta/src/main/ets/SaveFile.ts +39 -0
- package/harmony/pakta/src/main/ets/UpdateContext.ts +1059 -0
- package/harmony/pakta/src/main/module.json5 +14 -0
- package/harmony/pakta/src/main/resources/base/element/string.json +8 -0
- package/harmony/pakta/src/main/resources/en_US/element/string.json +8 -0
- package/harmony/pakta/src/main/resources/zh_CN/element/string.json +8 -0
- package/harmony/pakta.har +0 -0
- package/ios/Expo/ExpoPaktaModule.swift +12 -0
- package/ios/Expo/ExpoPaktaReactDelegateHandler.swift +25 -0
- package/ios/ImportReact.h +7 -0
- package/ios/PrivacyInfo.xcprivacy +84 -0
- package/ios/RCTPakta/RCTPakta.h +14 -0
- package/ios/RCTPakta/RCTPakta.mm +2775 -0
- package/ios/RCTPakta/RCTPaktaDownloader.h +29 -0
- package/ios/RCTPakta/RCTPaktaDownloader.mm +625 -0
- package/ios/pakta_build_time.txt +1 -0
- package/package.json +88 -0
- package/react-native.config.js +6 -0
- package/rn-update.podspec +221 -0
- package/src/NativePakta.ts +85 -0
- package/src/client.ts +1839 -0
- package/src/context.ts +102 -0
- package/src/core.ts +190 -0
- package/src/endpoint.ts +204 -0
- package/src/error.ts +168 -0
- package/src/errorReporting.ts +141 -0
- package/src/globals.d.ts +6 -0
- package/src/i18n.ts +113 -0
- package/src/index.ts +46 -0
- package/src/locales/en.ts +77 -0
- package/src/locales/zh.ts +71 -0
- package/src/metadata.ts +175 -0
- package/src/provider.tsx +629 -0
- package/src/telemetry.ts +104 -0
- package/src/type.ts +243 -0
- package/src/updateFlowCore.ts +428 -0
- package/src/utils.ts +268 -0
package/src/client.ts
ADDED
|
@@ -0,0 +1,1839 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [INPUT]: 依赖 react-native 的平台与设备事件,依赖 core 冻结的启动版本身份/原生状态桥、endpoint 回退执行器、updateFlowCore 纯决策、error/telemetry/type 协议及 utils 网络工具
|
|
3
|
+
* [OUTPUT]: 对外提供 UpdateErrorListener、进程级 sharedState,以及带版本绑定成功确认的 Pakta 热更新客户端
|
|
4
|
+
* [POS]: src 的应用服务编排核心,协调检查、下载、补丁、激活和端点降级,并保证本地生命周期到服务端回执的单次归类及激活前有界投递
|
|
5
|
+
*/
|
|
6
|
+
import {
|
|
7
|
+
DeviceEventEmitter,
|
|
8
|
+
type EmitterSubscription,
|
|
9
|
+
Platform,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import {
|
|
12
|
+
buildTime,
|
|
13
|
+
channel,
|
|
14
|
+
cInfo,
|
|
15
|
+
currentVersion,
|
|
16
|
+
currentVersionInfo,
|
|
17
|
+
getBundleHash,
|
|
18
|
+
isFirstTime,
|
|
19
|
+
isRolledBack,
|
|
20
|
+
PaktaModule,
|
|
21
|
+
packageVersion,
|
|
22
|
+
paktaNativeEventEmitter,
|
|
23
|
+
rolledBackVersion,
|
|
24
|
+
setLocalHashInfo,
|
|
25
|
+
supportedDiffVersion,
|
|
26
|
+
} from './core';
|
|
27
|
+
import { dedupeEndpoints, executeEndpointFallback } from './endpoint';
|
|
28
|
+
import {
|
|
29
|
+
readErrorCode,
|
|
30
|
+
toUpdateError,
|
|
31
|
+
UpdateError,
|
|
32
|
+
type UpdateErrorCode,
|
|
33
|
+
} from './error';
|
|
34
|
+
import {
|
|
35
|
+
type ErrorReportContext,
|
|
36
|
+
type ErrorReportingOptions,
|
|
37
|
+
installGlobalErrorHandler,
|
|
38
|
+
type SerializedException,
|
|
39
|
+
serializeException,
|
|
40
|
+
} from './errorReporting';
|
|
41
|
+
import i18n from './i18n';
|
|
42
|
+
import {
|
|
43
|
+
resolveServerEventHash,
|
|
44
|
+
resolveServerEventType,
|
|
45
|
+
truncateDetail,
|
|
46
|
+
} from './telemetry';
|
|
47
|
+
import type {
|
|
48
|
+
BeforeReloadContext,
|
|
49
|
+
CheckResult,
|
|
50
|
+
ClientOptions,
|
|
51
|
+
EventType,
|
|
52
|
+
ProgressData,
|
|
53
|
+
UpdateCheckState,
|
|
54
|
+
UpdateServerConfig,
|
|
55
|
+
} from './type';
|
|
56
|
+
import {
|
|
57
|
+
buildCheckFingerprint,
|
|
58
|
+
buildCheckRequestBody,
|
|
59
|
+
type DownloadPlan,
|
|
60
|
+
type DownloadStrategyType,
|
|
61
|
+
decideDownload,
|
|
62
|
+
isMirrorRetryableCode,
|
|
63
|
+
isValidCheckResult,
|
|
64
|
+
} from './updateFlowCore';
|
|
65
|
+
import {
|
|
66
|
+
assertWeb,
|
|
67
|
+
computeProgress,
|
|
68
|
+
DEFAULT_FETCH_TIMEOUT_MS,
|
|
69
|
+
fetchWithTimeout,
|
|
70
|
+
info,
|
|
71
|
+
log,
|
|
72
|
+
noop,
|
|
73
|
+
promiseAny,
|
|
74
|
+
setDebugLogging,
|
|
75
|
+
testUrls,
|
|
76
|
+
warn,
|
|
77
|
+
} from './utils';
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Receives every error the client reports, alongside the report event type.
|
|
81
|
+
* The UpdateProvider subscribes to surface errors as lastError/Alert; user
|
|
82
|
+
* code can subscribe too. Listeners run before any throwError rethrow.
|
|
83
|
+
*/
|
|
84
|
+
export type UpdateErrorListener = (
|
|
85
|
+
error: UpdateError,
|
|
86
|
+
eventType: EventType
|
|
87
|
+
) => void;
|
|
88
|
+
|
|
89
|
+
const SERVER_PRESET: UpdateServerConfig = {
|
|
90
|
+
// Pakta 将区域服务端点置于一条确定性的回退链中。
|
|
91
|
+
// 前两个是品牌全球 API,后两个保留既有中国区边缘路由,确保迁移后仍可达。
|
|
92
|
+
main: [
|
|
93
|
+
'https://api.pakta.dev',
|
|
94
|
+
'https://api.pakta.app',
|
|
95
|
+
'https://update.react-native.cn/api',
|
|
96
|
+
'https://update.reactnative.cn/api',
|
|
97
|
+
],
|
|
98
|
+
queryUrls: [
|
|
99
|
+
'https://cdn.jsdelivr.net/gh/reactnativecn/react-native-update@master/endpoints.json',
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const cloneServerConfig = (server: UpdateServerConfig): UpdateServerConfig => ({
|
|
104
|
+
main: dedupeEndpoints([...(server.main || [])]),
|
|
105
|
+
queryUrls: server.queryUrls ? [...server.queryUrls] : undefined,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// How long after a resolved reloadUpdate the process may still be alive before
|
|
109
|
+
// the switch is considered not to have restarted the app (see switchVersion).
|
|
110
|
+
const RELOAD_WATCHDOG_MS = 5000;
|
|
111
|
+
|
|
112
|
+
// Non-2xx check responses are usually HTML error pages; keep only the head
|
|
113
|
+
// for the error message (it can end up in an alert) and the logger.
|
|
114
|
+
const MAX_HTTP_ERROR_TEXT = 200;
|
|
115
|
+
|
|
116
|
+
const excludeConfiguredEndpoints = (
|
|
117
|
+
endpoints: string[],
|
|
118
|
+
configuredEndpoints: string[]
|
|
119
|
+
) => {
|
|
120
|
+
const configured = new Set(configuredEndpoints);
|
|
121
|
+
return endpoints.filter((endpoint) => !configured.has(endpoint));
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
assertWeb();
|
|
125
|
+
|
|
126
|
+
const createDefaultClientOptions = (): ClientOptions => ({
|
|
127
|
+
appKey: '',
|
|
128
|
+
autoMarkSuccess: true,
|
|
129
|
+
updateStrategy: __DEV__ ? 'alwaysAlert' : 'alertUpdateAndIgnoreError',
|
|
130
|
+
checkStrategy: 'both',
|
|
131
|
+
logger: noop,
|
|
132
|
+
debug: false,
|
|
133
|
+
throwError: false,
|
|
134
|
+
disableErrorReporting: false,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
export const sharedState: {
|
|
138
|
+
progressHandlers: Record<string, EmitterSubscription>;
|
|
139
|
+
downloadingTasks: Record<string, Promise<string | undefined>>;
|
|
140
|
+
// Progress callbacks per hash: concurrent downloadUpdate callers of the
|
|
141
|
+
// same hash each register theirs here instead of the second one being
|
|
142
|
+
// silently dropped by the in-flight dedup.
|
|
143
|
+
progressCallbacks: Record<string, Set<(data: ProgressData) => void>>;
|
|
144
|
+
downloadedHash?: string;
|
|
145
|
+
toHash?: string;
|
|
146
|
+
apkStatus: 'downloading' | 'downloaded' | null;
|
|
147
|
+
marked: boolean;
|
|
148
|
+
applyingUpdate: boolean;
|
|
149
|
+
} = {
|
|
150
|
+
progressHandlers: {},
|
|
151
|
+
downloadingTasks: {},
|
|
152
|
+
progressCallbacks: {},
|
|
153
|
+
downloadedHash: undefined,
|
|
154
|
+
apkStatus: null,
|
|
155
|
+
marked: false,
|
|
156
|
+
applyingUpdate: false,
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// A reset/new switch invalidates ownership of older async completions and
|
|
160
|
+
// watchdogs before the process-wide applyingUpdate flag can be reused.
|
|
161
|
+
let applyingUpdateGeneration = 0;
|
|
162
|
+
let reloadWatchdogTimer: ReturnType<typeof setTimeout> | undefined;
|
|
163
|
+
|
|
164
|
+
const clearReloadWatchdog = () => {
|
|
165
|
+
if (reloadWatchdogTimer !== undefined) {
|
|
166
|
+
clearTimeout(reloadWatchdogTimer);
|
|
167
|
+
reloadWatchdogTimer = undefined;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const beginApplyingUpdate = (): number => {
|
|
172
|
+
clearReloadWatchdog();
|
|
173
|
+
sharedState.applyingUpdate = true;
|
|
174
|
+
return ++applyingUpdateGeneration;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const ownsApplyingUpdate = (generation: number): boolean =>
|
|
178
|
+
generation === applyingUpdateGeneration && sharedState.applyingUpdate;
|
|
179
|
+
|
|
180
|
+
const finishApplyingUpdate = (generation: number): boolean => {
|
|
181
|
+
if (!ownsApplyingUpdate(generation)) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
clearReloadWatchdog();
|
|
185
|
+
sharedState.applyingUpdate = false;
|
|
186
|
+
return true;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const invalidateApplyingUpdate = () => {
|
|
190
|
+
applyingUpdateGeneration++;
|
|
191
|
+
clearReloadWatchdog();
|
|
192
|
+
sharedState.applyingUpdate = false;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const armReloadWatchdog = (generation: number, onTimeout: () => void) => {
|
|
196
|
+
if (!ownsApplyingUpdate(generation)) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
clearReloadWatchdog();
|
|
200
|
+
const timer = setTimeout(() => {
|
|
201
|
+
// A cancelled callback may already be queued; both identities must match.
|
|
202
|
+
if (reloadWatchdogTimer !== timer || !ownsApplyingUpdate(generation)) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
reloadWatchdogTimer = undefined;
|
|
206
|
+
sharedState.applyingUpdate = false;
|
|
207
|
+
onTimeout();
|
|
208
|
+
}, RELOAD_WATCHDOG_MS);
|
|
209
|
+
reloadWatchdogTimer = timer;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// The SDK is a process-level singleton: module-level sharedState, the global
|
|
213
|
+
// i18n locale and the native update state are all per-process, so a second
|
|
214
|
+
// client would silently share (and fight over) them. Constructing one is a
|
|
215
|
+
// hard integration error, except for the idempotent re-creation of the same
|
|
216
|
+
// client (same appKey), which dev fast-refresh triggers legitimately.
|
|
217
|
+
let activeClient: Pakta | undefined;
|
|
218
|
+
|
|
219
|
+
const assertHash = (hash: string) => {
|
|
220
|
+
if (!sharedState.downloadedHash) {
|
|
221
|
+
log(`no downloaded hash yet, ignore switch to ${hash}`);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (hash !== sharedState.downloadedHash) {
|
|
225
|
+
log(`use downloaded hash ${sharedState.downloadedHash} first`);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
return true;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export class Pakta {
|
|
232
|
+
options: ClientOptions = createDefaultClientOptions();
|
|
233
|
+
clientType: 'Pakta' = 'Pakta';
|
|
234
|
+
lastChecking?: number;
|
|
235
|
+
lastRespJson?: Promise<CheckResult>;
|
|
236
|
+
lastCheckFingerprint?: string;
|
|
237
|
+
// Endpoint that most recently served a successful checkUpdate; telemetry
|
|
238
|
+
// reuses it instead of re-running the fallback race.
|
|
239
|
+
private lastWorkingEndpoint?: string;
|
|
240
|
+
private syncedNativeConfigJson?: string;
|
|
241
|
+
private pendingNativeConfigJson?: string;
|
|
242
|
+
private nativeConfigSyncInFlight = false;
|
|
243
|
+
private reportedInvalidUpdates = new Set<string>();
|
|
244
|
+
private reportedExceptions = new WeakSet<object>();
|
|
245
|
+
private globalErrorCleanup?: () => void;
|
|
246
|
+
|
|
247
|
+
version = cInfo.rnu;
|
|
248
|
+
loggerPromise = (() => {
|
|
249
|
+
let resolve: (value?: unknown) => void = () => {};
|
|
250
|
+
const promise = new Promise((res) => {
|
|
251
|
+
resolve = res;
|
|
252
|
+
});
|
|
253
|
+
return {
|
|
254
|
+
promise,
|
|
255
|
+
resolve,
|
|
256
|
+
};
|
|
257
|
+
})();
|
|
258
|
+
|
|
259
|
+
constructor(options: ClientOptions) {
|
|
260
|
+
if (activeClient) {
|
|
261
|
+
if (activeClient.options.appKey === options.appKey) {
|
|
262
|
+
// Same client re-created (e.g. fast refresh re-running the module
|
|
263
|
+
// that builds it): apply the latest options and hand back the
|
|
264
|
+
// existing instance instead of forking process-level state.
|
|
265
|
+
activeClient.setOptions(options);
|
|
266
|
+
// biome-ignore lint/correctness/noConstructorReturn: intentional singleton — identical re-creation must yield the existing instance
|
|
267
|
+
return activeClient;
|
|
268
|
+
}
|
|
269
|
+
throw new UpdateError(
|
|
270
|
+
i18n.t('error_client_singleton'),
|
|
271
|
+
'SINGLETON_VIOLATION'
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
this.options.server = cloneServerConfig(SERVER_PRESET);
|
|
275
|
+
|
|
276
|
+
i18n.setLocale(options.locale ?? 'zh');
|
|
277
|
+
|
|
278
|
+
// Every native platform (Harmony included) needs the appKey; without it
|
|
279
|
+
// the check URL is `/checkUpdate/` and the failure would surface as an
|
|
280
|
+
// opaque 404 instead of this explicit code.
|
|
281
|
+
if (Platform.OS !== 'web' && !options.appKey) {
|
|
282
|
+
throw new UpdateError(i18n.t('error_appkey_required'), 'APPKEY_REQUIRED');
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
this.setOptions(options);
|
|
286
|
+
if (isRolledBack) {
|
|
287
|
+
this.report({
|
|
288
|
+
type: 'rollback',
|
|
289
|
+
data: {
|
|
290
|
+
rolledBackVersion,
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
activeClient = this;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Bumped on every setOptions call. `options` is mutated in place (its
|
|
299
|
+
* identity never changes), so reactive consumers (the UpdateProvider)
|
|
300
|
+
* subscribe via onOptionsChange and re-read using this version as the
|
|
301
|
+
* change signal.
|
|
302
|
+
*/
|
|
303
|
+
optionsVersion = 0;
|
|
304
|
+
private optionsListeners = new Set<() => void>();
|
|
305
|
+
/**
|
|
306
|
+
* Subscribe to option changes (any setOptions call). Returns an
|
|
307
|
+
* unsubscribe function.
|
|
308
|
+
*/
|
|
309
|
+
onOptionsChange = (listener: () => void) => {
|
|
310
|
+
this.optionsListeners.add(listener);
|
|
311
|
+
return () => {
|
|
312
|
+
this.optionsListeners.delete(listener);
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
setOptions = (options: Partial<ClientOptions>) => {
|
|
317
|
+
for (const [key, value] of Object.entries(options)) {
|
|
318
|
+
if (value !== undefined) {
|
|
319
|
+
(this.options as any)[key] =
|
|
320
|
+
key === 'server'
|
|
321
|
+
? cloneServerConfig(value as UpdateServerConfig)
|
|
322
|
+
: value;
|
|
323
|
+
if (key === 'logger') {
|
|
324
|
+
this.loggerPromise.resolve();
|
|
325
|
+
}
|
|
326
|
+
if (key === 'locale') {
|
|
327
|
+
// The constructor applies the initial locale; a runtime switch (or
|
|
328
|
+
// the fast-refresh re-creation path, which only goes through here)
|
|
329
|
+
// must apply just the same.
|
|
330
|
+
i18n.setLocale(value as 'zh' | 'en');
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
setDebugLogging(!!this.options.debug);
|
|
335
|
+
this.optionsVersion++;
|
|
336
|
+
for (const listener of this.optionsListeners) {
|
|
337
|
+
try {
|
|
338
|
+
listener();
|
|
339
|
+
} catch (e: any) {
|
|
340
|
+
log('onOptionsChange listener error:', e?.message || e);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
this.syncAutomaticErrorReporting();
|
|
344
|
+
this.syncNativeConfig();
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
private syncAutomaticErrorReporting = (): void => {
|
|
348
|
+
if (this.options.disableTelemetry || this.options.disableErrorReporting) {
|
|
349
|
+
this.globalErrorCleanup?.();
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
this.enableErrorReporting();
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
/** Build the subset of options used by the native cold-start check. */
|
|
356
|
+
private getNativeConfig = (): Record<string, unknown> | undefined => {
|
|
357
|
+
if (
|
|
358
|
+
Platform.OS === 'web' ||
|
|
359
|
+
typeof PaktaModule.syncNativeConfig !== 'function'
|
|
360
|
+
) {
|
|
361
|
+
// Older natives lack the method; on web PaktaModule is a noop Proxy
|
|
362
|
+
// and the feature-detect would false-positive.
|
|
363
|
+
return undefined;
|
|
364
|
+
}
|
|
365
|
+
const {
|
|
366
|
+
appKey,
|
|
367
|
+
server,
|
|
368
|
+
updateStrategy,
|
|
369
|
+
checkStrategy,
|
|
370
|
+
disableNativeCheck,
|
|
371
|
+
} = this.options;
|
|
372
|
+
if (disableNativeCheck) {
|
|
373
|
+
// Explicit opt-out: keep the identity fields so the persisted config
|
|
374
|
+
// still describes this app, and let the orchestrators bail on `disabled`
|
|
375
|
+
// before any IO.
|
|
376
|
+
return { disabled: true, appKey, rnu: cInfo.rnu, rn: cInfo.rn };
|
|
377
|
+
}
|
|
378
|
+
if (!appKey || !server?.main?.length) {
|
|
379
|
+
// Unusable rather than merely absent: the JS check would fail on these
|
|
380
|
+
// options too (NO_ENDPOINTS / APPKEY_REQUIRED). The caller turns this
|
|
381
|
+
// into an explicit disabled state.
|
|
382
|
+
return undefined;
|
|
383
|
+
}
|
|
384
|
+
// An app that turned automatic checks off (checkStrategy: null) must not
|
|
385
|
+
// be handed a version switch it never asked for. The cold-start check
|
|
386
|
+
// still runs and still downloads — that is what keeps a bricked device
|
|
387
|
+
// rescuable — but activation waits for the JS side, or for the server's
|
|
388
|
+
// explicit per-version forceBoot directive (shouldActivateAfterDownload).
|
|
389
|
+
const autoCheckEnabled = checkStrategy != null;
|
|
390
|
+
return {
|
|
391
|
+
appKey,
|
|
392
|
+
channel,
|
|
393
|
+
packageVersion: this.getEffectivePackageVersion(),
|
|
394
|
+
endpoints: server.main,
|
|
395
|
+
queryUrls: server.queryUrls ?? [],
|
|
396
|
+
// The native check may activate a downloaded version (next launch)
|
|
397
|
+
// only under the silent strategies; alert-style strategies keep
|
|
398
|
+
// activation with the JS side (§6/§10.1).
|
|
399
|
+
afterDownload:
|
|
400
|
+
autoCheckEnabled &&
|
|
401
|
+
(updateStrategy === 'silentAndNow' ||
|
|
402
|
+
updateStrategy === 'silentAndLater')
|
|
403
|
+
? 'setNeedUpdate'
|
|
404
|
+
: 'none',
|
|
405
|
+
rnu: cInfo.rnu,
|
|
406
|
+
rn: cInfo.rn,
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
private getNativeConfigJson = (): string | undefined => {
|
|
411
|
+
const config = this.getNativeConfig();
|
|
412
|
+
return config ? JSON.stringify(config) : undefined;
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
private flushNativeConfig = () => {
|
|
416
|
+
if (this.nativeConfigSyncInFlight) {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const configJson = this.pendingNativeConfigJson;
|
|
420
|
+
this.pendingNativeConfigJson = undefined;
|
|
421
|
+
if (!configJson || configJson === this.syncedNativeConfigJson) {
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
this.nativeConfigSyncInFlight = true;
|
|
425
|
+
let syncResult: Promise<void>;
|
|
426
|
+
try {
|
|
427
|
+
syncResult = Promise.resolve(PaktaModule.syncNativeConfig(configJson));
|
|
428
|
+
} catch (e: any) {
|
|
429
|
+
this.nativeConfigSyncInFlight = false;
|
|
430
|
+
log('syncNativeConfig failed:', e?.message || e);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
syncResult
|
|
434
|
+
.then(() => {
|
|
435
|
+
this.syncedNativeConfigJson = configJson;
|
|
436
|
+
})
|
|
437
|
+
.catch((e: any) => {
|
|
438
|
+
log('syncNativeConfig failed:', e?.message || e);
|
|
439
|
+
})
|
|
440
|
+
.finally(() => {
|
|
441
|
+
this.nativeConfigSyncInFlight = false;
|
|
442
|
+
this.flushNativeConfig();
|
|
443
|
+
});
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Tell the native cold-start orchestrator that this process already holds a
|
|
448
|
+
* valid check response for the current config, so its delayed round (5s
|
|
449
|
+
* after launch) does not repeat the request. Fire-and-forget: a failure
|
|
450
|
+
* costs one duplicate check. Never called on a failed check — the native
|
|
451
|
+
* rescue must keep running when JS could not reach the server.
|
|
452
|
+
*/
|
|
453
|
+
private markJsCheckCompleted = () => {
|
|
454
|
+
if (
|
|
455
|
+
Platform.OS === 'web' ||
|
|
456
|
+
typeof PaktaModule.markJsCheckCompleted !== 'function'
|
|
457
|
+
) {
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
const configJson = this.getNativeConfigJson();
|
|
461
|
+
if (!configJson) {
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
try {
|
|
465
|
+
Promise.resolve(PaktaModule.markJsCheckCompleted(configJson)).catch(
|
|
466
|
+
(e: any) => {
|
|
467
|
+
log('markJsCheckCompleted failed:', e?.message || e);
|
|
468
|
+
}
|
|
469
|
+
);
|
|
470
|
+
} catch (e: any) {
|
|
471
|
+
log('markJsCheckCompleted failed:', e?.message || e);
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
private syncNativeConfig = () => {
|
|
476
|
+
if (
|
|
477
|
+
Platform.OS === 'web' ||
|
|
478
|
+
typeof PaktaModule.syncNativeConfig !== 'function'
|
|
479
|
+
) {
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
const configJson = this.getNativeConfigJson();
|
|
483
|
+
if (!configJson) {
|
|
484
|
+
// No usable config (empty appKey / no endpoints) is almost always a
|
|
485
|
+
// transient state while options are being assembled. Persisting a
|
|
486
|
+
// disabled config over the last good one would switch off the
|
|
487
|
+
// cold-start rescue for every later launch, so keep what native has.
|
|
488
|
+
// (Web and older natives never reach this point — no method.)
|
|
489
|
+
log('native check config unusable, keeping the last synced config');
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
// Always record the latest desired value, even when it matches the last
|
|
493
|
+
// completed write. Example: A synced -> B in flight -> options revert to
|
|
494
|
+
// A. Comparing only with synced(A) would drop the revert and leave native
|
|
495
|
+
// storage at B after that in-flight write completes.
|
|
496
|
+
// Coalesce rapid setOptions calls, but serialize bridge writes so an older
|
|
497
|
+
// completion can never overwrite the newest desired configuration.
|
|
498
|
+
this.pendingNativeConfigJson = configJson;
|
|
499
|
+
this.flushNativeConfig();
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
/** Package version used by every server-side update decision. */
|
|
503
|
+
getEffectivePackageVersion = () =>
|
|
504
|
+
this.options.overridePackageVersion || packageVersion;
|
|
505
|
+
|
|
506
|
+
private jsonValuesEqual = (left: unknown, right: unknown): boolean => {
|
|
507
|
+
const compare = (a: unknown, b: unknown): boolean => {
|
|
508
|
+
if (a === b) {
|
|
509
|
+
return true;
|
|
510
|
+
}
|
|
511
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
512
|
+
return (
|
|
513
|
+
Array.isArray(a) &&
|
|
514
|
+
Array.isArray(b) &&
|
|
515
|
+
a.length === b.length &&
|
|
516
|
+
a.every((value, index) => compare(value, b[index]))
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
if (
|
|
520
|
+
a === null ||
|
|
521
|
+
b === null ||
|
|
522
|
+
typeof a !== 'object' ||
|
|
523
|
+
typeof b !== 'object'
|
|
524
|
+
) {
|
|
525
|
+
return false;
|
|
526
|
+
}
|
|
527
|
+
const leftObject = a as Record<string, unknown>;
|
|
528
|
+
const rightObject = b as Record<string, unknown>;
|
|
529
|
+
// Match JSON.stringify semantics for request extras: object properties
|
|
530
|
+
// whose value is undefined are omitted from the wire fingerprint.
|
|
531
|
+
const leftKeys = Object.keys(leftObject)
|
|
532
|
+
.filter((key) => leftObject[key] !== undefined)
|
|
533
|
+
.sort();
|
|
534
|
+
const rightKeys = Object.keys(rightObject)
|
|
535
|
+
.filter((key) => rightObject[key] !== undefined)
|
|
536
|
+
.sort();
|
|
537
|
+
return (
|
|
538
|
+
leftKeys.length === rightKeys.length &&
|
|
539
|
+
leftKeys.every(
|
|
540
|
+
(key, index) =>
|
|
541
|
+
key === rightKeys[index] &&
|
|
542
|
+
compare(leftObject[key], rightObject[key])
|
|
543
|
+
)
|
|
544
|
+
);
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
return compare(left, right);
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
private providerMounted = false;
|
|
551
|
+
/**
|
|
552
|
+
* Called by UpdateProvider on mount. A second concurrently mounted
|
|
553
|
+
* provider is the same integration error as a second client — fail hard
|
|
554
|
+
* instead of double-subscribing app-state listeners and update checks.
|
|
555
|
+
* Returns the release function used on unmount.
|
|
556
|
+
*/
|
|
557
|
+
claimProviderMount = () => {
|
|
558
|
+
if (this.providerMounted) {
|
|
559
|
+
throw new UpdateError(
|
|
560
|
+
this.t('error_provider_singleton'),
|
|
561
|
+
'SINGLETON_VIOLATION'
|
|
562
|
+
);
|
|
563
|
+
}
|
|
564
|
+
this.providerMounted = true;
|
|
565
|
+
return () => {
|
|
566
|
+
this.providerMounted = false;
|
|
567
|
+
};
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Get translated text using the current Pakta locale
|
|
572
|
+
* @param key - Translation key
|
|
573
|
+
* @param values - Values for interpolation (optional)
|
|
574
|
+
* @returns Translated string
|
|
575
|
+
*/
|
|
576
|
+
t = (key: string, values?: Record<string, string | number>) => {
|
|
577
|
+
return i18n.t(key as any, values);
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
reportInvalidUpdateOnce = (
|
|
581
|
+
reason: 'missingHash' | 'noArtifact',
|
|
582
|
+
hash = ''
|
|
583
|
+
) => {
|
|
584
|
+
const key = `${this.options.appKey}:${reason}:${hash}`;
|
|
585
|
+
if (this.reportedInvalidUpdates.has(key)) {
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
this.reportedInvalidUpdates.add(key);
|
|
589
|
+
this.report({
|
|
590
|
+
type: 'errorUpdate',
|
|
591
|
+
message:
|
|
592
|
+
reason === 'missingHash'
|
|
593
|
+
? 'update response is missing a version hash'
|
|
594
|
+
: 'update response contains no downloadable artifact',
|
|
595
|
+
...(hash ? { data: { newVersion: hash } } : {}),
|
|
596
|
+
});
|
|
597
|
+
};
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Best-effort JS exception reporting for the currently running OTA release.
|
|
601
|
+
* It is intentionally synchronous to call and never throws; the transport
|
|
602
|
+
* runs in the background and preserves the app's existing error flow.
|
|
603
|
+
*/
|
|
604
|
+
captureException = (
|
|
605
|
+
error: unknown,
|
|
606
|
+
context: ErrorReportContext = {}
|
|
607
|
+
): void => {
|
|
608
|
+
try {
|
|
609
|
+
if (
|
|
610
|
+
__DEV__ ||
|
|
611
|
+
this.options.disableTelemetry ||
|
|
612
|
+
this.options.disableErrorReporting
|
|
613
|
+
) {
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
if (
|
|
617
|
+
error !== null &&
|
|
618
|
+
(typeof error === 'object' || typeof error === 'function')
|
|
619
|
+
) {
|
|
620
|
+
const object = error as object;
|
|
621
|
+
if (this.reportedExceptions.has(object)) {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
this.reportedExceptions.add(object);
|
|
625
|
+
}
|
|
626
|
+
this.reportExceptionToServer(serializeException(error, context));
|
|
627
|
+
} catch (e: any) {
|
|
628
|
+
log('exception telemetry error:', e?.message || e);
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* Ensure uncaught JS exception capture is installed and return a runtime
|
|
634
|
+
* cleanup function. Capture is installed automatically by default; this
|
|
635
|
+
* method remains an idempotent compatibility hook. The wrapper always
|
|
636
|
+
* chains the handler that was installed before it and only restores that
|
|
637
|
+
* handler when no later integration has replaced ours.
|
|
638
|
+
*/
|
|
639
|
+
enableErrorReporting = (
|
|
640
|
+
options: ErrorReportingOptions = {}
|
|
641
|
+
): (() => void) => {
|
|
642
|
+
if (
|
|
643
|
+
options.captureGlobal === false ||
|
|
644
|
+
this.options.disableTelemetry ||
|
|
645
|
+
this.options.disableErrorReporting
|
|
646
|
+
) {
|
|
647
|
+
return () => {};
|
|
648
|
+
}
|
|
649
|
+
if (this.globalErrorCleanup) {
|
|
650
|
+
return this.globalErrorCleanup;
|
|
651
|
+
}
|
|
652
|
+
const uninstall = installGlobalErrorHandler((error, isFatal) => {
|
|
653
|
+
this.captureException(error, { fatal: isFatal === true });
|
|
654
|
+
});
|
|
655
|
+
let active = true;
|
|
656
|
+
const cleanup = () => {
|
|
657
|
+
if (!active) {
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
active = false;
|
|
661
|
+
uninstall();
|
|
662
|
+
if (this.globalErrorCleanup === cleanup) {
|
|
663
|
+
this.globalErrorCleanup = undefined;
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
this.globalErrorCleanup = cleanup;
|
|
667
|
+
return cleanup;
|
|
668
|
+
};
|
|
669
|
+
|
|
670
|
+
private reportExceptionToServer = (error: SerializedException): void => {
|
|
671
|
+
try {
|
|
672
|
+
if (
|
|
673
|
+
__DEV__ ||
|
|
674
|
+
this.options.disableTelemetry ||
|
|
675
|
+
this.options.disableErrorReporting ||
|
|
676
|
+
!currentVersion
|
|
677
|
+
) {
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
const { appKey } = this.options;
|
|
681
|
+
const endpoint =
|
|
682
|
+
this.lastWorkingEndpoint || this.options.server?.main?.[0];
|
|
683
|
+
if (!appKey || !endpoint) {
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
fetchWithTimeout(
|
|
687
|
+
`${endpoint}/report/${appKey}`,
|
|
688
|
+
{
|
|
689
|
+
method: 'POST',
|
|
690
|
+
headers: { 'Content-Type': 'application/json' },
|
|
691
|
+
body: JSON.stringify({
|
|
692
|
+
type: 'js_exception',
|
|
693
|
+
hash: currentVersion,
|
|
694
|
+
packageVersion: this.getEffectivePackageVersion(),
|
|
695
|
+
cInfo,
|
|
696
|
+
error,
|
|
697
|
+
}),
|
|
698
|
+
},
|
|
699
|
+
DEFAULT_FETCH_TIMEOUT_MS
|
|
700
|
+
).catch((e: any) => {
|
|
701
|
+
log('exception telemetry report failed:', e?.message || e);
|
|
702
|
+
});
|
|
703
|
+
} catch (e: any) {
|
|
704
|
+
log('exception telemetry error:', e?.message || e);
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
report = async ({
|
|
709
|
+
type,
|
|
710
|
+
message = '',
|
|
711
|
+
code,
|
|
712
|
+
data = {},
|
|
713
|
+
}: {
|
|
714
|
+
type: EventType;
|
|
715
|
+
message?: string;
|
|
716
|
+
code?: UpdateErrorCode;
|
|
717
|
+
data?: Record<string, string | number>;
|
|
718
|
+
}) => {
|
|
719
|
+
log(`${type} ${code ? `[${code}] ` : ''}${message}`);
|
|
720
|
+
// The task starts immediately. Most reports remain fire-and-forget, but
|
|
721
|
+
// downloadSuccess awaits this bounded task before a silent restart.
|
|
722
|
+
const telemetryTask = this.reportToServer({ type, message, code, data });
|
|
723
|
+
if (this.options.logger === noop) {
|
|
724
|
+
// Wait briefly for a logger to arrive via setOptions (e.g. the rollback
|
|
725
|
+
// report fires in the constructor before the user configures one), but
|
|
726
|
+
// give up after a bound instead of retaining the closure forever when
|
|
727
|
+
// no logger is ever provided.
|
|
728
|
+
// The shared SDK is compiled with both DOM/RN and Node ambient timer
|
|
729
|
+
// declarations, whose overloads disagree on the handle type.
|
|
730
|
+
let timer: unknown;
|
|
731
|
+
await Promise.race([
|
|
732
|
+
this.loggerPromise.promise,
|
|
733
|
+
new Promise((resolve) => {
|
|
734
|
+
timer = setTimeout(resolve, 10 * 1000);
|
|
735
|
+
}),
|
|
736
|
+
]);
|
|
737
|
+
// React Native/browser timers are numbers; Node's ambient types expose
|
|
738
|
+
// an object handle. Number() preserves the native numeric id in both
|
|
739
|
+
// environments and keeps this shared SDK type-checkable in e2etest.
|
|
740
|
+
if (timer !== undefined) {
|
|
741
|
+
clearTimeout(Number(timer));
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
const { logger = noop, appKey } = this.options;
|
|
745
|
+
const overridePackageVersion = this.options.overridePackageVersion;
|
|
746
|
+
try {
|
|
747
|
+
logger({
|
|
748
|
+
type,
|
|
749
|
+
data: {
|
|
750
|
+
appKey,
|
|
751
|
+
currentVersion,
|
|
752
|
+
cInfo,
|
|
753
|
+
packageVersion,
|
|
754
|
+
overridePackageVersion,
|
|
755
|
+
buildTime,
|
|
756
|
+
message,
|
|
757
|
+
code,
|
|
758
|
+
...currentVersionInfo,
|
|
759
|
+
...data,
|
|
760
|
+
},
|
|
761
|
+
});
|
|
762
|
+
} catch (e: any) {
|
|
763
|
+
// A user-provided logger must never break the update flow, and report()
|
|
764
|
+
// calls are fire-and-forget so a throw here would be an unhandled
|
|
765
|
+
// rejection.
|
|
766
|
+
log('logger error:', e?.message || e);
|
|
767
|
+
}
|
|
768
|
+
return telemetryTask;
|
|
769
|
+
};
|
|
770
|
+
/**
|
|
771
|
+
* Best-effort lifecycle event reporting to the update server (aggregate
|
|
772
|
+
* counts + sampled failure details power the version health view and the
|
|
773
|
+
* rollback safety net server-side). Single POST to the last known working
|
|
774
|
+
* endpoint, no retry, no fallback race; any failure is swallowed — telemetry
|
|
775
|
+
* must never affect the update flow. Opt out with disableTelemetry.
|
|
776
|
+
*/
|
|
777
|
+
private reportToServer = ({
|
|
778
|
+
type,
|
|
779
|
+
message = '',
|
|
780
|
+
code,
|
|
781
|
+
data = {},
|
|
782
|
+
}: {
|
|
783
|
+
type: EventType;
|
|
784
|
+
message?: string;
|
|
785
|
+
code?: UpdateErrorCode;
|
|
786
|
+
data?: Record<string, string | number>;
|
|
787
|
+
}): Promise<void> => {
|
|
788
|
+
try {
|
|
789
|
+
if (__DEV__ || this.options.disableTelemetry) {
|
|
790
|
+
return Promise.resolve();
|
|
791
|
+
}
|
|
792
|
+
const serverType = resolveServerEventType(type, code);
|
|
793
|
+
if (!serverType) {
|
|
794
|
+
return Promise.resolve();
|
|
795
|
+
}
|
|
796
|
+
const { appKey } = this.options;
|
|
797
|
+
const endpoint =
|
|
798
|
+
this.lastWorkingEndpoint || this.options.server?.main?.[0];
|
|
799
|
+
if (!appKey || !endpoint) {
|
|
800
|
+
return Promise.resolve();
|
|
801
|
+
}
|
|
802
|
+
const hash = resolveServerEventHash({ serverType, data, currentVersion });
|
|
803
|
+
if (!hash) {
|
|
804
|
+
return Promise.resolve();
|
|
805
|
+
}
|
|
806
|
+
return fetchWithTimeout(
|
|
807
|
+
`${endpoint}/report/${appKey}`,
|
|
808
|
+
{
|
|
809
|
+
method: 'POST',
|
|
810
|
+
headers: { 'Content-Type': 'application/json' },
|
|
811
|
+
body: JSON.stringify({
|
|
812
|
+
type: serverType,
|
|
813
|
+
hash,
|
|
814
|
+
packageVersion: this.getEffectivePackageVersion(),
|
|
815
|
+
channel,
|
|
816
|
+
buildTime,
|
|
817
|
+
cInfo,
|
|
818
|
+
detail: truncateDetail(message || undefined),
|
|
819
|
+
}),
|
|
820
|
+
},
|
|
821
|
+
DEFAULT_FETCH_TIMEOUT_MS
|
|
822
|
+
)
|
|
823
|
+
.then(() => undefined)
|
|
824
|
+
.catch((e: any) => {
|
|
825
|
+
log('telemetry report failed:', e?.message || e);
|
|
826
|
+
});
|
|
827
|
+
} catch (e: any) {
|
|
828
|
+
log('telemetry error:', e?.message || e);
|
|
829
|
+
return Promise.resolve();
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
throwIfEnabled = (e: Error) => {
|
|
833
|
+
if (this.options.throwError) {
|
|
834
|
+
throw e;
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
private errorListeners = new Set<UpdateErrorListener>();
|
|
838
|
+
private emittedErrors = new WeakSet<Error>();
|
|
839
|
+
/**
|
|
840
|
+
* Subscribe to every error the client reports (regardless of throwError).
|
|
841
|
+
* Returns an unsubscribe function.
|
|
842
|
+
*/
|
|
843
|
+
onError = (listener: UpdateErrorListener) => {
|
|
844
|
+
this.errorListeners.add(listener);
|
|
845
|
+
return () => {
|
|
846
|
+
this.errorListeners.delete(listener);
|
|
847
|
+
};
|
|
848
|
+
};
|
|
849
|
+
/**
|
|
850
|
+
* Whether this exact error object already went through emitError (and was
|
|
851
|
+
* therefore delivered to onError subscribers). Lets UI layers decide if a
|
|
852
|
+
* caught error still needs surfacing — checking `e.code` is not enough,
|
|
853
|
+
* since axios/system errors carry their own code without ever entering the
|
|
854
|
+
* pipeline.
|
|
855
|
+
*/
|
|
856
|
+
wasEmitted = (e: unknown): boolean =>
|
|
857
|
+
e instanceof Error && this.emittedErrors.has(e);
|
|
858
|
+
/**
|
|
859
|
+
* Single exit point for errors: reports to the logger (with the stable
|
|
860
|
+
* code) and notifies onError listeners. Whether to also throw stays with
|
|
861
|
+
* the caller (throwIfEnabled or an unconditional rethrow).
|
|
862
|
+
*/
|
|
863
|
+
private emitError = (
|
|
864
|
+
error: UpdateError,
|
|
865
|
+
type: EventType,
|
|
866
|
+
{
|
|
867
|
+
message = error.message,
|
|
868
|
+
data,
|
|
869
|
+
}: { message?: string; data?: Record<string, string | number> } = {}
|
|
870
|
+
) => {
|
|
871
|
+
this.emittedErrors.add(error);
|
|
872
|
+
this.report({
|
|
873
|
+
type,
|
|
874
|
+
message,
|
|
875
|
+
code: error.code,
|
|
876
|
+
// Structured context from the error (e.g. HTTP status) reaches the
|
|
877
|
+
// logger; explicit data wins on key conflicts.
|
|
878
|
+
data: error.extra ? { ...error.extra, ...data } : data,
|
|
879
|
+
});
|
|
880
|
+
for (const listener of this.errorListeners) {
|
|
881
|
+
try {
|
|
882
|
+
listener(error, type);
|
|
883
|
+
} catch (e: any) {
|
|
884
|
+
log('onError listener error:', e?.message || e);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
};
|
|
888
|
+
notifyAfterCheckUpdate = (state: UpdateCheckState) => {
|
|
889
|
+
const { afterCheckUpdate } = this.options;
|
|
890
|
+
if (!afterCheckUpdate) {
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
// 这里仅做状态通知,不阻塞原有检查流程
|
|
894
|
+
Promise.resolve(afterCheckUpdate(state)).catch((error: any) => {
|
|
895
|
+
log('afterCheckUpdate failed:', error?.message || error);
|
|
896
|
+
});
|
|
897
|
+
};
|
|
898
|
+
runBeforeReload = async (context: BeforeReloadContext) => {
|
|
899
|
+
const { beforeReload } = this.options;
|
|
900
|
+
if (!beforeReload) {
|
|
901
|
+
return true;
|
|
902
|
+
}
|
|
903
|
+
const shouldReload = await beforeReload(context);
|
|
904
|
+
if (shouldReload === false) {
|
|
905
|
+
log('beforeReload returned false, skipping reload');
|
|
906
|
+
return false;
|
|
907
|
+
}
|
|
908
|
+
return true;
|
|
909
|
+
};
|
|
910
|
+
getCheckUrl = (endpoint: string) => {
|
|
911
|
+
return `${endpoint}/checkUpdate/${this.options.appKey}`;
|
|
912
|
+
};
|
|
913
|
+
getConfiguredCheckEndpoints = () => {
|
|
914
|
+
const { server } = this.options;
|
|
915
|
+
if (!server) {
|
|
916
|
+
return [];
|
|
917
|
+
}
|
|
918
|
+
return dedupeEndpoints(server.main);
|
|
919
|
+
};
|
|
920
|
+
getRemoteEndpoints = async () => {
|
|
921
|
+
const { server } = this.options;
|
|
922
|
+
if (!server?.queryUrls?.length) {
|
|
923
|
+
return [];
|
|
924
|
+
}
|
|
925
|
+
try {
|
|
926
|
+
// Race the parsed lists, not the raw responses: fetch resolves for
|
|
927
|
+
// 404/403/5xx and anti-bot HTML too, and this path only runs once the
|
|
928
|
+
// main endpoints are already failing — a mirror that answers first
|
|
929
|
+
// with an error page must not beat the healthy one.
|
|
930
|
+
const remoteEndpoints = await promiseAny(
|
|
931
|
+
server.queryUrls.map(async (queryUrl) => {
|
|
932
|
+
const resp = await fetchWithTimeout(
|
|
933
|
+
queryUrl,
|
|
934
|
+
{},
|
|
935
|
+
DEFAULT_FETCH_TIMEOUT_MS
|
|
936
|
+
);
|
|
937
|
+
if (!resp.ok) {
|
|
938
|
+
throw Error(`${queryUrl}: ${resp.status}`);
|
|
939
|
+
}
|
|
940
|
+
const list: unknown = await resp.json();
|
|
941
|
+
if (!Array.isArray(list)) {
|
|
942
|
+
throw Error(`${queryUrl}: not an endpoint list`);
|
|
943
|
+
}
|
|
944
|
+
return list;
|
|
945
|
+
})
|
|
946
|
+
);
|
|
947
|
+
log('fetch endpoints:', remoteEndpoints);
|
|
948
|
+
return excludeConfiguredEndpoints(
|
|
949
|
+
dedupeEndpoints(
|
|
950
|
+
remoteEndpoints.filter(
|
|
951
|
+
// The list is fetched from a public mirror; it may add
|
|
952
|
+
// endpoints but never move the check outside TLS.
|
|
953
|
+
(endpoint): endpoint is string =>
|
|
954
|
+
typeof endpoint === 'string' && /^https:\/\//i.test(endpoint)
|
|
955
|
+
)
|
|
956
|
+
),
|
|
957
|
+
this.getConfiguredCheckEndpoints()
|
|
958
|
+
);
|
|
959
|
+
} catch (e) {
|
|
960
|
+
log('failed to fetch endpoints from: ', server.queryUrls, e);
|
|
961
|
+
}
|
|
962
|
+
return [];
|
|
963
|
+
};
|
|
964
|
+
requestCheckResult = async (
|
|
965
|
+
endpoint: string,
|
|
966
|
+
fetchPayload: Parameters<typeof fetch>[1],
|
|
967
|
+
signal?: AbortSignal
|
|
968
|
+
) => {
|
|
969
|
+
const resp = await fetchWithTimeout(
|
|
970
|
+
this.getCheckUrl(endpoint),
|
|
971
|
+
signal ? { ...fetchPayload, signal } : fetchPayload,
|
|
972
|
+
DEFAULT_FETCH_TIMEOUT_MS
|
|
973
|
+
);
|
|
974
|
+
|
|
975
|
+
if (!resp.ok) {
|
|
976
|
+
const respText = (await resp.text()).slice(0, MAX_HTTP_ERROR_TEXT);
|
|
977
|
+
throw new UpdateError(
|
|
978
|
+
this.t('error_http_status', {
|
|
979
|
+
status: resp.status,
|
|
980
|
+
statusText: respText,
|
|
981
|
+
}),
|
|
982
|
+
'HTTP_STATUS',
|
|
983
|
+
{ extra: { status: resp.status } }
|
|
984
|
+
);
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
const result: unknown = await resp.json();
|
|
988
|
+
if (!isValidCheckResult(result)) {
|
|
989
|
+
// A 2xx that is not a verdict (`{"error": ...}`, a captive-portal page
|
|
990
|
+
// that parsed, ...) is a failed endpoint: throwing keeps the fallback
|
|
991
|
+
// moving to the next one instead of treating it as "no update".
|
|
992
|
+
throw new UpdateError(
|
|
993
|
+
this.t('error_invalid_check_response'),
|
|
994
|
+
'INVALID_RESPONSE'
|
|
995
|
+
);
|
|
996
|
+
}
|
|
997
|
+
return result;
|
|
998
|
+
};
|
|
999
|
+
fetchCheckResult = async (fetchPayload: Parameters<typeof fetch>[1]) => {
|
|
1000
|
+
const { endpoint, value } = await executeEndpointFallback<CheckResult>({
|
|
1001
|
+
configuredEndpoints: this.getConfiguredCheckEndpoints(),
|
|
1002
|
+
getRemoteEndpoints: this.getRemoteEndpoints,
|
|
1003
|
+
tryEndpoint: async (currentEndpoint, signal) => {
|
|
1004
|
+
try {
|
|
1005
|
+
return await this.requestCheckResult(
|
|
1006
|
+
currentEndpoint,
|
|
1007
|
+
fetchPayload,
|
|
1008
|
+
signal
|
|
1009
|
+
);
|
|
1010
|
+
} catch (e) {
|
|
1011
|
+
log('check endpoint failed', currentEndpoint, e);
|
|
1012
|
+
throw e;
|
|
1013
|
+
}
|
|
1014
|
+
},
|
|
1015
|
+
onFirstFailure: ({ error }) => {
|
|
1016
|
+
this.report({
|
|
1017
|
+
type: 'errorChecking',
|
|
1018
|
+
message: this.t('error_cannot_connect_backup', {
|
|
1019
|
+
message: error.message,
|
|
1020
|
+
}),
|
|
1021
|
+
});
|
|
1022
|
+
},
|
|
1023
|
+
});
|
|
1024
|
+
|
|
1025
|
+
log('check endpoint success', endpoint);
|
|
1026
|
+
this.lastWorkingEndpoint = endpoint;
|
|
1027
|
+
return value;
|
|
1028
|
+
};
|
|
1029
|
+
/**
|
|
1030
|
+
* Reuse the native cold-start check's cached response when fresh
|
|
1031
|
+
* (NATIVE_CHECKUPDATE_DESIGN §10.3) instead of re-checking. Returns
|
|
1032
|
+
* undefined whenever the cache is absent, stale, or unreadable — any
|
|
1033
|
+
* failure falls through to a normal network check.
|
|
1034
|
+
*/
|
|
1035
|
+
private readNativeCheckCache = async (
|
|
1036
|
+
requestBody: Record<string, any>
|
|
1037
|
+
): Promise<CheckResult | undefined> => {
|
|
1038
|
+
try {
|
|
1039
|
+
if (__DEV__ || typeof PaktaModule.getNativeCheckCache !== 'function') {
|
|
1040
|
+
return undefined;
|
|
1041
|
+
}
|
|
1042
|
+
const raw = await Promise.resolve(PaktaModule.getNativeCheckCache());
|
|
1043
|
+
if (!raw || typeof raw !== 'string') {
|
|
1044
|
+
return undefined;
|
|
1045
|
+
}
|
|
1046
|
+
const entry = JSON.parse(raw);
|
|
1047
|
+
const config = this.getNativeConfig();
|
|
1048
|
+
const cachedRequest =
|
|
1049
|
+
typeof entry?.request === 'string'
|
|
1050
|
+
? JSON.parse(entry.request)
|
|
1051
|
+
: undefined;
|
|
1052
|
+
const cachedConfig =
|
|
1053
|
+
typeof entry?.config === 'string'
|
|
1054
|
+
? JSON.parse(entry.config)
|
|
1055
|
+
: undefined;
|
|
1056
|
+
if (
|
|
1057
|
+
typeof entry?.ts !== 'number' ||
|
|
1058
|
+
typeof entry?.body !== 'string' ||
|
|
1059
|
+
!this.jsonValuesEqual(cachedRequest, requestBody) ||
|
|
1060
|
+
!config ||
|
|
1061
|
+
!this.jsonValuesEqual(cachedConfig, config)
|
|
1062
|
+
) {
|
|
1063
|
+
return undefined;
|
|
1064
|
+
}
|
|
1065
|
+
const ageSeconds = Date.now() / 1000 - entry.ts;
|
|
1066
|
+
if (ageSeconds < 0 || ageSeconds > 120) {
|
|
1067
|
+
return undefined;
|
|
1068
|
+
}
|
|
1069
|
+
const result: unknown = JSON.parse(entry.body);
|
|
1070
|
+
// Same schema gate as the network path: a native old enough to have
|
|
1071
|
+
// cached a 200 `{"error": ...}` must not turn it into "no update".
|
|
1072
|
+
if (!isValidCheckResult(result)) {
|
|
1073
|
+
return undefined;
|
|
1074
|
+
}
|
|
1075
|
+
log('reusing native check response cache');
|
|
1076
|
+
return result;
|
|
1077
|
+
} catch {
|
|
1078
|
+
return undefined;
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1081
|
+
|
|
1082
|
+
assertDebug = (matter: string) => {
|
|
1083
|
+
if (__DEV__ && !this.options.debug) {
|
|
1084
|
+
info(this.t('dev_debug_disabled', { matter }));
|
|
1085
|
+
return false;
|
|
1086
|
+
}
|
|
1087
|
+
return true;
|
|
1088
|
+
};
|
|
1089
|
+
markSuccess = async () => {
|
|
1090
|
+
if (sharedState.marked) {
|
|
1091
|
+
log('markSuccess skipped: already marked');
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1094
|
+
if (__DEV__) {
|
|
1095
|
+
log('markSuccess skipped: development build');
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
if (!isFirstTime) {
|
|
1099
|
+
warn('markSuccess skipped: native launch marker is false', {
|
|
1100
|
+
expectedHash: currentVersion,
|
|
1101
|
+
});
|
|
1102
|
+
return;
|
|
1103
|
+
}
|
|
1104
|
+
try {
|
|
1105
|
+
const accepted = await Promise.resolve(
|
|
1106
|
+
PaktaModule.markSuccess(currentVersion)
|
|
1107
|
+
);
|
|
1108
|
+
if (!accepted) {
|
|
1109
|
+
warn('markSuccess rejected by native', {
|
|
1110
|
+
expectedHash: currentVersion,
|
|
1111
|
+
});
|
|
1112
|
+
return false;
|
|
1113
|
+
}
|
|
1114
|
+
} catch (e) {
|
|
1115
|
+
const err = toUpdateError(e, 'MARK_SUCCESS_FAILED');
|
|
1116
|
+
this.emitError(err, 'errorMarkSuccess');
|
|
1117
|
+
throw err;
|
|
1118
|
+
}
|
|
1119
|
+
sharedState.marked = true;
|
|
1120
|
+
this.report({ type: 'markSuccess' });
|
|
1121
|
+
// 救砖回执:这个版本是被救援通道送进来的,且活过了健康确认——遥测里
|
|
1122
|
+
// 一条 rescue 回执就是"这台设备被捞回来了"的证据。
|
|
1123
|
+
if (currentVersionInfo.forceBootRescue) {
|
|
1124
|
+
this.report({ type: 'forceBootRescue' });
|
|
1125
|
+
}
|
|
1126
|
+
if (currentVersionInfo.crashRescue) {
|
|
1127
|
+
this.report({ type: 'crashRescue' });
|
|
1128
|
+
}
|
|
1129
|
+
return true;
|
|
1130
|
+
};
|
|
1131
|
+
/**
|
|
1132
|
+
* Reload into a downloaded version. Resolves true once the native reload
|
|
1133
|
+
* was requested, false when the call was ignored (not the downloaded hash,
|
|
1134
|
+
* a switch already in progress, beforeReload declined, dev without debug).
|
|
1135
|
+
*/
|
|
1136
|
+
switchVersion = async (hash: string): Promise<boolean> => {
|
|
1137
|
+
if (!this.assertDebug('switchVersion()')) {
|
|
1138
|
+
return false;
|
|
1139
|
+
}
|
|
1140
|
+
if (!assertHash(hash)) {
|
|
1141
|
+
return false;
|
|
1142
|
+
}
|
|
1143
|
+
if (sharedState.applyingUpdate) {
|
|
1144
|
+
log(`switchVersion: ${hash} ignored, a switch is already in progress`);
|
|
1145
|
+
return false;
|
|
1146
|
+
}
|
|
1147
|
+
log(`switchVersion: ${hash}`);
|
|
1148
|
+
const applyingGeneration = beginApplyingUpdate();
|
|
1149
|
+
try {
|
|
1150
|
+
if (!(await this.runBeforeReload({ type: 'switchVersion', hash }))) {
|
|
1151
|
+
finishApplyingUpdate(applyingGeneration);
|
|
1152
|
+
return false;
|
|
1153
|
+
}
|
|
1154
|
+
} catch (e) {
|
|
1155
|
+
finishApplyingUpdate(applyingGeneration);
|
|
1156
|
+
// A throw from the user's beforeReload hook is business-code failure,
|
|
1157
|
+
// not an update-pipeline one: give it a distinct code so telemetry
|
|
1158
|
+
// excludes it from the server-side patch-health stats.
|
|
1159
|
+
const err = toUpdateError(e, 'USER_HOOK_ERROR');
|
|
1160
|
+
this.emitError(err, 'errorSwitchVersion', {
|
|
1161
|
+
data: { newVersion: hash },
|
|
1162
|
+
});
|
|
1163
|
+
throw err;
|
|
1164
|
+
}
|
|
1165
|
+
// resetToPackagedBundle may have completed while beforeReload awaited.
|
|
1166
|
+
if (!ownsApplyingUpdate(applyingGeneration)) {
|
|
1167
|
+
return false;
|
|
1168
|
+
}
|
|
1169
|
+
try {
|
|
1170
|
+
await PaktaModule.reloadUpdate({ hash });
|
|
1171
|
+
} catch (e) {
|
|
1172
|
+
// Do not let a superseded rejection clear a newer switch.
|
|
1173
|
+
finishApplyingUpdate(applyingGeneration);
|
|
1174
|
+
const err = toUpdateError(e, 'SWITCH_VERSION_FAILED');
|
|
1175
|
+
this.emitError(err, 'errorSwitchVersion', {
|
|
1176
|
+
data: { newVersion: hash },
|
|
1177
|
+
});
|
|
1178
|
+
throw err;
|
|
1179
|
+
}
|
|
1180
|
+
// A resolved reloadUpdate normally tears this JS context down right away.
|
|
1181
|
+
// iOS has been seen resolving without restarting (89c638e); a stuck
|
|
1182
|
+
// applyingUpdate would then silently swallow every later switchVersion,
|
|
1183
|
+
// so release it once the process has outlived the reload and tell the
|
|
1184
|
+
// logger (RESTART_FAILED: restart mechanics, not patch health).
|
|
1185
|
+
armReloadWatchdog(applyingGeneration, () => {
|
|
1186
|
+
this.report({
|
|
1187
|
+
type: 'errorSwitchVersion',
|
|
1188
|
+
code: 'RESTART_FAILED',
|
|
1189
|
+
message: 'reloadUpdate resolved but the app did not restart',
|
|
1190
|
+
data: { newVersion: hash },
|
|
1191
|
+
});
|
|
1192
|
+
});
|
|
1193
|
+
return true;
|
|
1194
|
+
};
|
|
1195
|
+
|
|
1196
|
+
switchVersionLater = async (hash: string) => {
|
|
1197
|
+
if (!this.assertDebug('switchVersionLater()')) {
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
if (assertHash(hash)) {
|
|
1201
|
+
log(`switchVersionLater: ${hash}`);
|
|
1202
|
+
try {
|
|
1203
|
+
return await PaktaModule.setNeedUpdate({ hash });
|
|
1204
|
+
} catch (e) {
|
|
1205
|
+
const err = toUpdateError(e, 'SWITCH_VERSION_FAILED');
|
|
1206
|
+
this.emitError(err, 'errorSwitchVersion', {
|
|
1207
|
+
data: { newVersion: hash },
|
|
1208
|
+
});
|
|
1209
|
+
throw err;
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
checkUpdate = async (extra?: Record<string, any>) => {
|
|
1214
|
+
if (!this.assertDebug('checkUpdate()')) {
|
|
1215
|
+
this.notifyAfterCheckUpdate({ status: 'skipped' });
|
|
1216
|
+
return;
|
|
1217
|
+
}
|
|
1218
|
+
if (!assertWeb()) {
|
|
1219
|
+
this.notifyAfterCheckUpdate({ status: 'skipped' });
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
if (
|
|
1223
|
+
this.options.beforeCheckUpdate &&
|
|
1224
|
+
(await this.options.beforeCheckUpdate()) === false
|
|
1225
|
+
) {
|
|
1226
|
+
log('beforeCheckUpdate returned false, skipping check');
|
|
1227
|
+
this.notifyAfterCheckUpdate({ status: 'skipped' });
|
|
1228
|
+
return;
|
|
1229
|
+
}
|
|
1230
|
+
// 内容寻址的二进制身份,服务端据此精确判定 pdiff 适用性(取代 buildTime
|
|
1231
|
+
// 启发式)。同步读 core 里已预取的值:还没算完就省略字段(服务端回退
|
|
1232
|
+
// buildTime 启发式),下一次检查自然带上——绝不为它 await、拖慢或复杂化
|
|
1233
|
+
// 检查流程。
|
|
1234
|
+
const bundleHash = __DEV__ ? '' : getBundleHash();
|
|
1235
|
+
const fetchBody = buildCheckRequestBody({
|
|
1236
|
+
packageVersion: this.getEffectivePackageVersion(),
|
|
1237
|
+
channel,
|
|
1238
|
+
currentVersion,
|
|
1239
|
+
buildTime,
|
|
1240
|
+
cInfo,
|
|
1241
|
+
supportedDiffVersion,
|
|
1242
|
+
bundleHash,
|
|
1243
|
+
isDev: __DEV__,
|
|
1244
|
+
extra,
|
|
1245
|
+
});
|
|
1246
|
+
const stringifyBody = JSON.stringify(fetchBody);
|
|
1247
|
+
// Identity of this check: only a check with the exact same request (same
|
|
1248
|
+
// extra / test hash / bundleHash / binary identity) against the same
|
|
1249
|
+
// endpoint set may share an in-flight or just-settled response. Two
|
|
1250
|
+
// checks 2s apart with different `extra` are different questions.
|
|
1251
|
+
const fingerprint = buildCheckFingerprint({
|
|
1252
|
+
appKey: this.options.appKey,
|
|
1253
|
+
endpoints: this.options.server?.main,
|
|
1254
|
+
queryUrls: this.options.server?.queryUrls,
|
|
1255
|
+
// The client uuid travels inside cInfo, i.e. inside `body`.
|
|
1256
|
+
body: stringifyBody,
|
|
1257
|
+
});
|
|
1258
|
+
const now = Date.now();
|
|
1259
|
+
if (
|
|
1260
|
+
this.lastRespJson &&
|
|
1261
|
+
this.lastChecking &&
|
|
1262
|
+
this.lastCheckFingerprint === fingerprint &&
|
|
1263
|
+
now - this.lastChecking < 1000 * 5
|
|
1264
|
+
) {
|
|
1265
|
+
try {
|
|
1266
|
+
const result = await this.lastRespJson;
|
|
1267
|
+
this.notifyAfterCheckUpdate({ status: 'completed', result });
|
|
1268
|
+
return result;
|
|
1269
|
+
} catch (e: any) {
|
|
1270
|
+
// The shared in-flight check failed. Its initiating call reports it
|
|
1271
|
+
// through emitError/throw; this call must still honor its own
|
|
1272
|
+
// contract — afterCheckUpdate always fires and throwError applies —
|
|
1273
|
+
// without double-reporting the same error.
|
|
1274
|
+
const err = toUpdateError(e, 'CHECK_FAILED');
|
|
1275
|
+
this.notifyAfterCheckUpdate({ status: 'error', error: err });
|
|
1276
|
+
this.throwIfEnabled(err);
|
|
1277
|
+
return undefined;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
this.lastChecking = now;
|
|
1281
|
+
this.lastCheckFingerprint = fingerprint;
|
|
1282
|
+
// harmony fetch body is not string
|
|
1283
|
+
let body: any = fetchBody;
|
|
1284
|
+
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
1285
|
+
body = stringifyBody;
|
|
1286
|
+
}
|
|
1287
|
+
const fetchPayload = {
|
|
1288
|
+
method: 'POST',
|
|
1289
|
+
headers: {
|
|
1290
|
+
Accept: 'application/json',
|
|
1291
|
+
'Content-Type': 'application/json',
|
|
1292
|
+
},
|
|
1293
|
+
body,
|
|
1294
|
+
};
|
|
1295
|
+
let respJsonPromise: Promise<CheckResult> | undefined;
|
|
1296
|
+
try {
|
|
1297
|
+
this.report({
|
|
1298
|
+
type: 'checking',
|
|
1299
|
+
message: `${this.options.appKey}: ${stringifyBody}`,
|
|
1300
|
+
});
|
|
1301
|
+
// The native cold-start check may have a fresh response on disk
|
|
1302
|
+
// (§10.3); reuse it instead of re-checking. The read happens INSIDE
|
|
1303
|
+
// the promise so no await lands between the dedup window above and the
|
|
1304
|
+
// lastRespJson assignment below (the JS2-1 double-send lesson).
|
|
1305
|
+
respJsonPromise = (async (): Promise<CheckResult> => {
|
|
1306
|
+
// While bundleHash prefetch is still pending, the JS request omits
|
|
1307
|
+
// that key whereas the native request always includes its synchronously
|
|
1308
|
+
// computed value. That narrow first-launch window intentionally misses
|
|
1309
|
+
// the cache rather than delaying checkUpdate for hashing.
|
|
1310
|
+
const cached = await this.readNativeCheckCache(fetchBody);
|
|
1311
|
+
return cached ?? (await this.fetchCheckResult(fetchPayload));
|
|
1312
|
+
})();
|
|
1313
|
+
this.lastRespJson = respJsonPromise;
|
|
1314
|
+
const result: CheckResult = await respJsonPromise;
|
|
1315
|
+
|
|
1316
|
+
log('checking result:', result);
|
|
1317
|
+
|
|
1318
|
+
if (result?.bundleStatus === 'unknownBundle') {
|
|
1319
|
+
// 服务端判定当前二进制内嵌 bundle 未注册,增量已被降级为全量。只面向
|
|
1320
|
+
// 开发者(日志 + 遥测,控制台聚合是主渠道);终端用户无感知。
|
|
1321
|
+
warn(this.t('warn_unknown_bundle'));
|
|
1322
|
+
this.report({
|
|
1323
|
+
type: 'bundleMismatch',
|
|
1324
|
+
data: bundleHash ? { bundleHash } : {},
|
|
1325
|
+
});
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
this.notifyAfterCheckUpdate({ status: 'completed', result });
|
|
1329
|
+
this.markJsCheckCompleted();
|
|
1330
|
+
return result;
|
|
1331
|
+
} catch (e: any) {
|
|
1332
|
+
// A failed check must not keep vouching for an older response: clear
|
|
1333
|
+
// the dedup slot so the next call re-asks the server — unless a newer
|
|
1334
|
+
// check already owns the slot, which this failure says nothing about.
|
|
1335
|
+
if (this.lastRespJson === respJsonPromise) {
|
|
1336
|
+
this.lastRespJson = undefined;
|
|
1337
|
+
this.lastCheckFingerprint = undefined;
|
|
1338
|
+
}
|
|
1339
|
+
const err = toUpdateError(e, 'CHECK_FAILED');
|
|
1340
|
+
this.emitError(err, 'errorChecking', {
|
|
1341
|
+
message: err.message || this.t('error_cannot_connect_server'),
|
|
1342
|
+
});
|
|
1343
|
+
this.notifyAfterCheckUpdate({ status: 'error', error: err });
|
|
1344
|
+
this.throwIfEnabled(err);
|
|
1345
|
+
// No silent fallback to a previous successful response: a stale result
|
|
1346
|
+
// would let a server outage look like "still updatable" and drive the
|
|
1347
|
+
// provider's auto-download off it. Return undefined so callers can
|
|
1348
|
+
// distinguish "check failed" from a real empty result and keep their
|
|
1349
|
+
// last good updateInfo.
|
|
1350
|
+
return undefined;
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1353
|
+
downloadUpdate = async (
|
|
1354
|
+
updateInfo: CheckResult,
|
|
1355
|
+
onDownloadProgress?: (data: ProgressData) => void
|
|
1356
|
+
) => {
|
|
1357
|
+
if (
|
|
1358
|
+
this.options.beforeDownloadUpdate &&
|
|
1359
|
+
(await this.options.beforeDownloadUpdate(updateInfo)) === false
|
|
1360
|
+
) {
|
|
1361
|
+
log('beforeDownloadUpdate returned false, skipping download');
|
|
1362
|
+
return;
|
|
1363
|
+
}
|
|
1364
|
+
const decision = decideDownload(
|
|
1365
|
+
updateInfo,
|
|
1366
|
+
{ currentVersion, rolledBackVersion },
|
|
1367
|
+
__DEV__
|
|
1368
|
+
);
|
|
1369
|
+
if (decision.action === 'none') {
|
|
1370
|
+
if (decision.reason === 'alreadyCurrent') {
|
|
1371
|
+
log(`current hash ${currentVersion}, ignored`);
|
|
1372
|
+
} else if (decision.reason === 'rolledBack') {
|
|
1373
|
+
log(`rolledback hash ${rolledBackVersion}, ignored`);
|
|
1374
|
+
} else if (decision.reason === 'noArtifact') {
|
|
1375
|
+
// A server response that advertises an update but provides no usable
|
|
1376
|
+
// artifact is a bad release signal, not an ordinary no-update result.
|
|
1377
|
+
// Keep the user flow silent and report at most once per bad release in
|
|
1378
|
+
// this process: repeated checks must not inflate download_fail health.
|
|
1379
|
+
this.reportInvalidUpdateOnce('noArtifact', updateInfo.hash || '');
|
|
1380
|
+
}
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
const { hash } = decision;
|
|
1384
|
+
if (sharedState.downloadedHash === hash) {
|
|
1385
|
+
log(`duplicated downloaded hash ${sharedState.downloadedHash}, ignored`);
|
|
1386
|
+
return sharedState.downloadedHash;
|
|
1387
|
+
}
|
|
1388
|
+
// Deduplicate concurrent downloads of the same hash regardless of whether a
|
|
1389
|
+
// progress callback was passed: all callers await the single in-flight
|
|
1390
|
+
// promise instead of triggering parallel native downloads.
|
|
1391
|
+
const existingTask = sharedState.downloadingTasks[hash];
|
|
1392
|
+
if (existingTask) {
|
|
1393
|
+
log(`download for hash ${hash} already in progress, reusing it`);
|
|
1394
|
+
// The second caller's progress callback must still fire.
|
|
1395
|
+
if (onDownloadProgress) {
|
|
1396
|
+
sharedState.progressCallbacks[hash]?.add(onDownloadProgress);
|
|
1397
|
+
}
|
|
1398
|
+
return existingTask;
|
|
1399
|
+
}
|
|
1400
|
+
const task = this.performDownload(updateInfo, decision, onDownloadProgress);
|
|
1401
|
+
sharedState.downloadingTasks[hash] = task;
|
|
1402
|
+
try {
|
|
1403
|
+
return await task;
|
|
1404
|
+
} finally {
|
|
1405
|
+
delete sharedState.downloadingTasks[hash];
|
|
1406
|
+
}
|
|
1407
|
+
};
|
|
1408
|
+
/**
|
|
1409
|
+
* Orders candidate mirrors for one artifact: the HEAD-race winner first
|
|
1410
|
+
* (its post-redirect URL), then the remaining mirrors in configured order.
|
|
1411
|
+
* Empty when there is nothing to try.
|
|
1412
|
+
*/
|
|
1413
|
+
private rankDownloadUrls = async (urls?: string[]): Promise<string[]> => {
|
|
1414
|
+
if (!urls?.length) {
|
|
1415
|
+
return [];
|
|
1416
|
+
}
|
|
1417
|
+
const winner = await testUrls(urls);
|
|
1418
|
+
const ordered: string[] = [];
|
|
1419
|
+
const push = (url?: string | null) => {
|
|
1420
|
+
if (url && !ordered.includes(url)) {
|
|
1421
|
+
ordered.push(url);
|
|
1422
|
+
}
|
|
1423
|
+
};
|
|
1424
|
+
push(winner);
|
|
1425
|
+
for (const url of urls) {
|
|
1426
|
+
push(url);
|
|
1427
|
+
}
|
|
1428
|
+
return ordered;
|
|
1429
|
+
};
|
|
1430
|
+
private performDownload = async (
|
|
1431
|
+
updateInfo: CheckResult,
|
|
1432
|
+
plan: DownloadPlan,
|
|
1433
|
+
onDownloadProgress?: (data: ProgressData) => void
|
|
1434
|
+
) => {
|
|
1435
|
+
const { name, description = '', metaInfo } = updateInfo;
|
|
1436
|
+
const { hash, attempts, devNoop } = plan;
|
|
1437
|
+
if (devNoop) {
|
|
1438
|
+
// Dev without a full package URL: nothing can be fetched, let alone
|
|
1439
|
+
// installed. Say so and deliver nothing — faking a success here used to
|
|
1440
|
+
// hand the caller a hash whose switchVersion the native side (rightly)
|
|
1441
|
+
// rejects with SWITCH_VERSION_FAILED.
|
|
1442
|
+
log(this.t('dev_incremental_update_disabled'));
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
const patchStartTime = Date.now();
|
|
1446
|
+
// One native listener per hash dispatching to a callback set, so
|
|
1447
|
+
// concurrent callers deduped onto this task can each observe progress
|
|
1448
|
+
// (they register via downloadUpdate).
|
|
1449
|
+
const progressCallbacks = new Set<(data: ProgressData) => void>();
|
|
1450
|
+
if (onDownloadProgress) {
|
|
1451
|
+
progressCallbacks.add(onDownloadProgress);
|
|
1452
|
+
}
|
|
1453
|
+
sharedState.progressCallbacks[hash] = progressCallbacks;
|
|
1454
|
+
const dispatchProgress = (data: ProgressData) => {
|
|
1455
|
+
const callbacks = sharedState.progressCallbacks[hash];
|
|
1456
|
+
if (!callbacks || callbacks.size === 0) {
|
|
1457
|
+
return;
|
|
1458
|
+
}
|
|
1459
|
+
const payload = {
|
|
1460
|
+
...data,
|
|
1461
|
+
progress: computeProgress(data.received, data.total),
|
|
1462
|
+
};
|
|
1463
|
+
callbacks.forEach((callback) => {
|
|
1464
|
+
// One subscriber throwing must not starve the others or abort the
|
|
1465
|
+
// download: business callbacks are isolated, the error is logged.
|
|
1466
|
+
try {
|
|
1467
|
+
callback(payload);
|
|
1468
|
+
} catch (e) {
|
|
1469
|
+
warn('onDownloadProgress callback threw', e);
|
|
1470
|
+
}
|
|
1471
|
+
});
|
|
1472
|
+
};
|
|
1473
|
+
// RN >= 0.87 types native event listeners as `(...args: readonly Object[])`,
|
|
1474
|
+
// which a `(data: ProgressData) => void` callback is not assignable to. Take
|
|
1475
|
+
// the raw event and narrow it here so this compiles on every RN version.
|
|
1476
|
+
const onNativeProgress = (event: unknown) => {
|
|
1477
|
+
const progressData = event as ProgressData;
|
|
1478
|
+
if (progressData.hash === hash) {
|
|
1479
|
+
dispatchProgress(progressData);
|
|
1480
|
+
}
|
|
1481
|
+
};
|
|
1482
|
+
// @ts-expect-error harmony not in existing platforms
|
|
1483
|
+
if (Platform.OS === 'harmony') {
|
|
1484
|
+
sharedState.progressHandlers[hash] = DeviceEventEmitter.addListener(
|
|
1485
|
+
'RCTPaktaDownloadProgress',
|
|
1486
|
+
onNativeProgress
|
|
1487
|
+
);
|
|
1488
|
+
} else {
|
|
1489
|
+
sharedState.progressHandlers[hash] = paktaNativeEventEmitter.addListener(
|
|
1490
|
+
'RCTPaktaDownloadProgress',
|
|
1491
|
+
onNativeProgress
|
|
1492
|
+
);
|
|
1493
|
+
}
|
|
1494
|
+
const maxRetries = Math.max(0, Math.floor(this.options.maxRetries ?? 3));
|
|
1495
|
+
let succeeded = '';
|
|
1496
|
+
let lastError: UpdateError | undefined;
|
|
1497
|
+
const errorMessages: string[] = [];
|
|
1498
|
+
// A strategy whose bytes arrived but could not be applied fails the same
|
|
1499
|
+
// way on every retry (same artifact, same base): remember it — with its
|
|
1500
|
+
// message, so the final report still names it — and skip it on later
|
|
1501
|
+
// attempts instead of downloading and patching it again.
|
|
1502
|
+
const exhaustedStrategies = new Map<DownloadStrategyType, string>();
|
|
1503
|
+
// Whether any strategy, in any attempt, failed at the patch stage. The
|
|
1504
|
+
// downloadFallback report carries that as its code even when a later,
|
|
1505
|
+
// unrelated transport failure happened to be the last error seen.
|
|
1506
|
+
let patchFailed = false;
|
|
1507
|
+
|
|
1508
|
+
// The ordered attempts come from decideDownload (the pure decision layer);
|
|
1509
|
+
// this side only executes them: probe candidate URLs, run the matching
|
|
1510
|
+
// native download, fall through to the next attempt on failure.
|
|
1511
|
+
const runners: Record<
|
|
1512
|
+
DownloadStrategyType,
|
|
1513
|
+
(url: string) => Promise<void>
|
|
1514
|
+
> = {
|
|
1515
|
+
diff: (url) =>
|
|
1516
|
+
PaktaModule.downloadPatchFromPpk({
|
|
1517
|
+
updateUrl: url,
|
|
1518
|
+
hash,
|
|
1519
|
+
originHash: currentVersion,
|
|
1520
|
+
}),
|
|
1521
|
+
pdiff: (url) =>
|
|
1522
|
+
PaktaModule.downloadPatchFromPackage({
|
|
1523
|
+
updateUrl: url,
|
|
1524
|
+
hash,
|
|
1525
|
+
}),
|
|
1526
|
+
full: (url) =>
|
|
1527
|
+
PaktaModule.downloadFullUpdate({
|
|
1528
|
+
updateUrl: url,
|
|
1529
|
+
hash,
|
|
1530
|
+
}),
|
|
1531
|
+
};
|
|
1532
|
+
const errorKeys = {
|
|
1533
|
+
diff: 'error_diff_failed',
|
|
1534
|
+
pdiff: 'error_pdiff_failed',
|
|
1535
|
+
full: 'error_full_patch_failed',
|
|
1536
|
+
} as const;
|
|
1537
|
+
|
|
1538
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
1539
|
+
if (attempt > 0) {
|
|
1540
|
+
// Exponential backoff with jitter: a bad CDN edge otherwise gets
|
|
1541
|
+
// every client back at the same 1/2/4s marks.
|
|
1542
|
+
const backoffMs = Math.round(
|
|
1543
|
+
Math.min(1000 * 2 ** (attempt - 1), 10000) *
|
|
1544
|
+
(0.75 + Math.random() * 0.5)
|
|
1545
|
+
);
|
|
1546
|
+
log(`retry attempt ${attempt}/${maxRetries}, waiting ${backoffMs}ms`);
|
|
1547
|
+
await new Promise((r) => setTimeout(r, backoffMs));
|
|
1548
|
+
errorMessages.length = 0;
|
|
1549
|
+
errorMessages.push(...exhaustedStrategies.values());
|
|
1550
|
+
lastError = undefined;
|
|
1551
|
+
succeeded = '';
|
|
1552
|
+
}
|
|
1553
|
+
this.report({
|
|
1554
|
+
type: 'downloading',
|
|
1555
|
+
data: {
|
|
1556
|
+
newVersion: hash,
|
|
1557
|
+
attempt,
|
|
1558
|
+
},
|
|
1559
|
+
});
|
|
1560
|
+
for (const { type, urls } of attempts) {
|
|
1561
|
+
if (succeeded) {
|
|
1562
|
+
break;
|
|
1563
|
+
}
|
|
1564
|
+
if (exhaustedStrategies.has(type)) {
|
|
1565
|
+
continue;
|
|
1566
|
+
}
|
|
1567
|
+
// The HEAD race only ranks mirrors; it is not proof that a mirror can
|
|
1568
|
+
// serve the whole artifact (CDNs answer HEAD and GET differently, and
|
|
1569
|
+
// a transfer can die mid-stream). Every mirror of the same artifact
|
|
1570
|
+
// gets a real download attempt before the strategy is abandoned —
|
|
1571
|
+
// the native cold-start path already behaves this way.
|
|
1572
|
+
const orderedUrls = await this.rankDownloadUrls(urls);
|
|
1573
|
+
for (const url of orderedUrls) {
|
|
1574
|
+
log(`downloading ${type} from ${url}`);
|
|
1575
|
+
try {
|
|
1576
|
+
await runners[type](url);
|
|
1577
|
+
succeeded = type;
|
|
1578
|
+
break;
|
|
1579
|
+
} catch (e: unknown) {
|
|
1580
|
+
// The native rejection's stable code (e.g. PATCH_FAILED vs
|
|
1581
|
+
// DOWNLOAD_FAILED — telemetry classifies on it) may sit on the
|
|
1582
|
+
// `code` property or, from bridges that cannot set it, as a
|
|
1583
|
+
// `[CODE] ` message prefix. Either way it survives into the
|
|
1584
|
+
// i18n-wrapped error together with the original as cause.
|
|
1585
|
+
const { code, message } = readErrorCode(e);
|
|
1586
|
+
const errorMessage = this.t(errorKeys[type], {
|
|
1587
|
+
message: message || String(e ?? ''),
|
|
1588
|
+
});
|
|
1589
|
+
errorMessages.push(errorMessage);
|
|
1590
|
+
lastError = new UpdateError(
|
|
1591
|
+
errorMessage,
|
|
1592
|
+
code ?? 'DOWNLOAD_FAILED',
|
|
1593
|
+
{
|
|
1594
|
+
cause: e,
|
|
1595
|
+
}
|
|
1596
|
+
);
|
|
1597
|
+
log(errorMessage);
|
|
1598
|
+
if (lastError.code === 'PATCH_FAILED') {
|
|
1599
|
+
patchFailed = true;
|
|
1600
|
+
}
|
|
1601
|
+
if (!isMirrorRetryableCode(lastError.code)) {
|
|
1602
|
+
// The bytes arrived but could not be applied (patch/manifest
|
|
1603
|
+
// mismatch): every mirror serves the same artifact, so move
|
|
1604
|
+
// on to the next strategy instead of re-downloading it.
|
|
1605
|
+
exhaustedStrategies.set(type, errorMessage);
|
|
1606
|
+
break;
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
if (
|
|
1612
|
+
succeeded ||
|
|
1613
|
+
attempts.every(({ type }) => exhaustedStrategies.has(type))
|
|
1614
|
+
) {
|
|
1615
|
+
// Nothing left that a retry could change.
|
|
1616
|
+
break;
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
if (sharedState.progressHandlers[hash]) {
|
|
1620
|
+
sharedState.progressHandlers[hash].remove();
|
|
1621
|
+
delete sharedState.progressHandlers[hash];
|
|
1622
|
+
}
|
|
1623
|
+
delete sharedState.progressCallbacks[hash];
|
|
1624
|
+
if (succeeded && errorMessages.length > 0) {
|
|
1625
|
+
// An earlier strategy failed and a later one rescued the download
|
|
1626
|
+
// (e.g. pdiff copiesCrc mismatch on a rebuilt binary → full). Surface
|
|
1627
|
+
// the degradation: it is invisible to the end user but tells the
|
|
1628
|
+
// platform that incremental delivery is failing for this binary.
|
|
1629
|
+
this.report({
|
|
1630
|
+
type: 'downloadFallback',
|
|
1631
|
+
// The patch-health signal wins over whatever transport failure
|
|
1632
|
+
// happened to come last (diff PATCH_FAILED, then pdiff network
|
|
1633
|
+
// error, then full succeeded is still a patch_fail server-side).
|
|
1634
|
+
code: patchFailed ? 'PATCH_FAILED' : lastError?.code,
|
|
1635
|
+
data: {
|
|
1636
|
+
newVersion: hash,
|
|
1637
|
+
succeeded,
|
|
1638
|
+
},
|
|
1639
|
+
message: errorMessages.join(';'),
|
|
1640
|
+
});
|
|
1641
|
+
}
|
|
1642
|
+
if (!succeeded) {
|
|
1643
|
+
const message = errorMessages.join(';');
|
|
1644
|
+
if (lastError) {
|
|
1645
|
+
const err = toUpdateError(lastError, 'DOWNLOAD_FAILED');
|
|
1646
|
+
this.emitError(err, 'errorUpdate', {
|
|
1647
|
+
message,
|
|
1648
|
+
data: { newVersion: hash },
|
|
1649
|
+
});
|
|
1650
|
+
throw err;
|
|
1651
|
+
}
|
|
1652
|
+
// No download URL was even attempted (e.g. dev without a full URL):
|
|
1653
|
+
// report for diagnostics but there is no error object to surface.
|
|
1654
|
+
this.report({
|
|
1655
|
+
type: 'errorUpdate',
|
|
1656
|
+
data: { newVersion: hash },
|
|
1657
|
+
message,
|
|
1658
|
+
});
|
|
1659
|
+
return;
|
|
1660
|
+
} else {
|
|
1661
|
+
const duration = Date.now() - patchStartTime;
|
|
1662
|
+
const data: Record<string, any> = {
|
|
1663
|
+
newVersion: hash,
|
|
1664
|
+
diff: succeeded,
|
|
1665
|
+
duration,
|
|
1666
|
+
};
|
|
1667
|
+
if (errorMessages.length > 0) {
|
|
1668
|
+
data.error = errorMessages.join(';');
|
|
1669
|
+
}
|
|
1670
|
+
// silentAndNow 紧接着重启 JS 运行时。这里等待有超时且失败已吞掉的
|
|
1671
|
+
// 回执,避免下载成功记录在重启时被截断,同时不让遥测阻塞更新。
|
|
1672
|
+
await this.report({
|
|
1673
|
+
type: 'downloadSuccess',
|
|
1674
|
+
data,
|
|
1675
|
+
});
|
|
1676
|
+
}
|
|
1677
|
+
log(`downloaded ${succeeded} hash:`, hash);
|
|
1678
|
+
const hashInfo: Record<string, any> = {
|
|
1679
|
+
name,
|
|
1680
|
+
description,
|
|
1681
|
+
metaInfo,
|
|
1682
|
+
};
|
|
1683
|
+
if (sharedState.toHash === hash) {
|
|
1684
|
+
hashInfo.debugChannel = true;
|
|
1685
|
+
}
|
|
1686
|
+
// The version is "downloaded" only once its metadata is persisted: a
|
|
1687
|
+
// lost hash-info write would leave the next launch with a nameless
|
|
1688
|
+
// version and a switchVersion that the native side may refuse.
|
|
1689
|
+
try {
|
|
1690
|
+
await setLocalHashInfo(hash, hashInfo);
|
|
1691
|
+
} catch (e: any) {
|
|
1692
|
+
const err = toUpdateError(e, 'FILE_OPERATION_FAILED');
|
|
1693
|
+
this.emitError(err, 'errorUpdate', {
|
|
1694
|
+
message: err.message,
|
|
1695
|
+
data: { newVersion: hash },
|
|
1696
|
+
});
|
|
1697
|
+
throw err;
|
|
1698
|
+
}
|
|
1699
|
+
sharedState.downloadedHash = hash;
|
|
1700
|
+
return hash;
|
|
1701
|
+
};
|
|
1702
|
+
downloadAndInstallApk = async (
|
|
1703
|
+
url: string,
|
|
1704
|
+
onDownloadProgress?: (data: ProgressData) => void
|
|
1705
|
+
) => {
|
|
1706
|
+
if (Platform.OS !== 'android') {
|
|
1707
|
+
return;
|
|
1708
|
+
}
|
|
1709
|
+
if (sharedState.apkStatus === 'downloading') {
|
|
1710
|
+
return;
|
|
1711
|
+
}
|
|
1712
|
+
if (sharedState.apkStatus === 'downloaded') {
|
|
1713
|
+
const err = new UpdateError(
|
|
1714
|
+
this.t('error_apk_pending_install'),
|
|
1715
|
+
'APK_INSTALL_PENDING'
|
|
1716
|
+
);
|
|
1717
|
+
this.emitError(err, 'errorInstallApk');
|
|
1718
|
+
this.throwIfEnabled(err);
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1721
|
+
sharedState.apkStatus = 'downloading';
|
|
1722
|
+
this.report({ type: 'downloadingApk' });
|
|
1723
|
+
const progressKey = 'downloadingApk';
|
|
1724
|
+
if (onDownloadProgress) {
|
|
1725
|
+
if (sharedState.progressHandlers[progressKey]) {
|
|
1726
|
+
sharedState.progressHandlers[progressKey].remove();
|
|
1727
|
+
}
|
|
1728
|
+
sharedState.progressHandlers[progressKey] =
|
|
1729
|
+
paktaNativeEventEmitter.addListener(
|
|
1730
|
+
'RCTPaktaDownloadProgress',
|
|
1731
|
+
(event: unknown) => {
|
|
1732
|
+
const progressData = event as ProgressData;
|
|
1733
|
+
if (progressData.hash === progressKey) {
|
|
1734
|
+
onDownloadProgress(progressData);
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
);
|
|
1738
|
+
}
|
|
1739
|
+
try {
|
|
1740
|
+
await PaktaModule.downloadAndInstallApk({
|
|
1741
|
+
url,
|
|
1742
|
+
target: 'update.apk',
|
|
1743
|
+
hash: progressKey,
|
|
1744
|
+
});
|
|
1745
|
+
sharedState.apkStatus = 'downloaded';
|
|
1746
|
+
} catch (e) {
|
|
1747
|
+
sharedState.apkStatus = null;
|
|
1748
|
+
// Keep the native error (message/stack) instead of discarding it.
|
|
1749
|
+
const err = toUpdateError(e, 'APK_DOWNLOAD_FAILED');
|
|
1750
|
+
this.emitError(err, 'errorDownloadAndInstallApk', {
|
|
1751
|
+
message: err.message || this.t('error_apk_download_failed'),
|
|
1752
|
+
});
|
|
1753
|
+
this.throwIfEnabled(err);
|
|
1754
|
+
} finally {
|
|
1755
|
+
if (sharedState.progressHandlers[progressKey]) {
|
|
1756
|
+
sharedState.progressHandlers[progressKey].remove();
|
|
1757
|
+
delete sharedState.progressHandlers[progressKey];
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
};
|
|
1761
|
+
restartApp = async () => {
|
|
1762
|
+
try {
|
|
1763
|
+
if (!(await this.runBeforeReload({ type: 'restartApp' }))) {
|
|
1764
|
+
return;
|
|
1765
|
+
}
|
|
1766
|
+
} catch (e) {
|
|
1767
|
+
const err = toUpdateError(e, 'USER_HOOK_ERROR');
|
|
1768
|
+
this.emitError(err, 'errorRestart');
|
|
1769
|
+
throw err;
|
|
1770
|
+
}
|
|
1771
|
+
try {
|
|
1772
|
+
return await PaktaModule.restartApp();
|
|
1773
|
+
} catch (e) {
|
|
1774
|
+
const err = toUpdateError(e, 'RESTART_FAILED');
|
|
1775
|
+
this.emitError(err, 'errorRestart');
|
|
1776
|
+
throw err;
|
|
1777
|
+
}
|
|
1778
|
+
};
|
|
1779
|
+
/**
|
|
1780
|
+
* Reset to the bundle packaged in the binary: wipes every downloaded update
|
|
1781
|
+
* and the whole update state on the native side, so the app loads the
|
|
1782
|
+
* built-in bundle on the next launch (or immediately with
|
|
1783
|
+
* `{ restart: true }`). The client uuid is preserved.
|
|
1784
|
+
*
|
|
1785
|
+
* Returns whether the reset actually happened. Like the other update-flow
|
|
1786
|
+
* APIs it never throws by default — failures land in lastError/onError with
|
|
1787
|
+
* code RESET_FAILED — but the boolean must not be ignored: a false means the
|
|
1788
|
+
* app is still running the hot-updated bundle. Set `throwError` to throw.
|
|
1789
|
+
*/
|
|
1790
|
+
resetToPackagedBundle = async (options?: {
|
|
1791
|
+
restart?: boolean;
|
|
1792
|
+
}): Promise<boolean> => {
|
|
1793
|
+
if (!assertWeb()) {
|
|
1794
|
+
// On web PaktaModule is a Proxy of noops, so the feature-detect below
|
|
1795
|
+
// would report a false success.
|
|
1796
|
+
return false;
|
|
1797
|
+
}
|
|
1798
|
+
if (typeof PaktaModule.resetToPackagedBundle !== 'function') {
|
|
1799
|
+
// The JS layer can arrive via hot update onto an older binary whose
|
|
1800
|
+
// native module predates this method.
|
|
1801
|
+
const err = new UpdateError(
|
|
1802
|
+
this.t('error_reset_not_supported'),
|
|
1803
|
+
'RESET_FAILED'
|
|
1804
|
+
);
|
|
1805
|
+
this.emitError(err, 'errorReset');
|
|
1806
|
+
this.throwIfEnabled(err);
|
|
1807
|
+
return false;
|
|
1808
|
+
}
|
|
1809
|
+
try {
|
|
1810
|
+
await PaktaModule.resetToPackagedBundle();
|
|
1811
|
+
} catch (e) {
|
|
1812
|
+
const err = toUpdateError(e, 'RESET_FAILED');
|
|
1813
|
+
this.emitError(err, 'errorReset');
|
|
1814
|
+
this.throwIfEnabled(err);
|
|
1815
|
+
return false;
|
|
1816
|
+
}
|
|
1817
|
+
// The downloaded versions are gone; drop JS bookkeeping referring to them
|
|
1818
|
+
// so a stale downloadedHash cannot be switched to.
|
|
1819
|
+
sharedState.downloadedHash = undefined;
|
|
1820
|
+
sharedState.toHash = undefined;
|
|
1821
|
+
sharedState.marked = false;
|
|
1822
|
+
// Invalidate the private owner too: old promises/timers must not touch
|
|
1823
|
+
// a switch that starts after this reset.
|
|
1824
|
+
invalidateApplyingUpdate();
|
|
1825
|
+
sharedState.apkStatus = null;
|
|
1826
|
+
this.report({ type: 'reset' });
|
|
1827
|
+
if (options?.restart) {
|
|
1828
|
+
try {
|
|
1829
|
+
await this.restartApp();
|
|
1830
|
+
} catch (e: any) {
|
|
1831
|
+
// The reset itself succeeded and the restart failure was already
|
|
1832
|
+
// reported through the pipeline; the boolean must still say "state
|
|
1833
|
+
// is reset".
|
|
1834
|
+
log('restart after reset failed:', e?.message || e);
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
return true;
|
|
1838
|
+
};
|
|
1839
|
+
}
|