7zip-native 0.0.7 → 0.0.10
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/README.md +96 -24
- package/bench/compare.mts +25 -11
- package/bench/folder-concurrency.mts +56 -14
- package/bench/multiprocess-extract.cjs +334 -0
- package/dist/index.cjs +194 -102
- package/dist/index.d.cts +10 -9
- package/dist/index.d.mts +10 -9
- package/dist/index.d.ts +10 -9
- package/dist/index.mjs +196 -104
- package/native/addon.cpp +1399 -71
- package/package.json +5 -3
- package/patches/deflate-input-buffer-size.patch +47 -0
- package/prebuilds/darwin-arm64/7zip_native.node +0 -0
- package/prebuilds/darwin-arm64/lib7z.dylib +0 -0
- package/prebuilds/darwin-x64/7zip_native.node +0 -0
- package/prebuilds/darwin-x64/lib7z.dylib +0 -0
- package/prebuilds/linux-arm/7z.so +0 -0
- package/prebuilds/linux-arm/7zip_native.node +0 -0
- package/prebuilds/linux-arm64/7z.so +0 -0
- package/prebuilds/linux-arm64/7zip_native.node +0 -0
- package/prebuilds/linux-ia32/7z.so +0 -0
- package/prebuilds/linux-ia32/7zip_native.node +0 -0
- package/prebuilds/linux-x64/7z.so +0 -0
- package/prebuilds/linux-x64/7zip_native.node +0 -0
- package/prebuilds/win32-arm64/7z.dll +0 -0
- package/prebuilds/win32-arm64/7zip_native.node +0 -0
- package/prebuilds/win32-x64/7z.dll +0 -0
- package/prebuilds/win32-x64/7zip_native.node +0 -0
- package/scripts/build-native.mjs +22 -1
- package/vendor/7zip/CPP/7zip/Archive/Archive2.def +1 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7z.so +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zAes.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zAesRegister.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zBuf2.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zCompressionMode.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zCrc.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zCrcOpt.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zDecode.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zEncode.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zExtract.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zFolderInStream.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zHandlerOut.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zHeader.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zIn.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zOut.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zProperties.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zRegister.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zSpecStream.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zStream.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/7zUpdate.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Aes.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/AesOpt.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Alloc.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ApfsHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ApmHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ArHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ArchiveExports.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ArjHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/BZip2Crc.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/BZip2Decoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/BZip2Encoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/BZip2Register.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Base64Handler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Bcj2.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Bcj2Coder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Bcj2Enc.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Bcj2Register.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/BcjCoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/BcjRegister.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/BitlDecoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Blake2s.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Bra.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Bra86.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/BraIA64.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/BranchMisc.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/BranchRegister.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/BwtSort.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ByteSwap.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Bz2Handler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/CRC.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/CWrappers.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/CabBlockInStream.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/CabHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/CabHeader.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/CabIn.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/CabRegister.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ChmHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ChmIn.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/CodecExports.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/CoderMixer2.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ComHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/CopyCoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/CopyRegister.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/CpioHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/CpuArch.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/CramfsHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/CrcReg.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/CreateCoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Deflate64Register.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/DeflateDecoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/DeflateEncoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/DeflateProps.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/DeflateRegister.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Delta.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/DeltaFilter.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/DllExports2.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/DmgHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/DummyOutStream.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/DynLimBuf.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ElfHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ExtHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/FatHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/FileDir.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/FileFind.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/FileIO.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/FileName.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/FilterCoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/FindSignature.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/FlvHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/GptHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/GzHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/HandlerCont.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/HandlerOut.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/HfsHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/HmacSha1.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/HmacSha256.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/HuffEnc.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/IhexHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ImplodeDecoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/InBuffer.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/InOutTempBuffer.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/InStreamWithCRC.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/IntToString.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/IsoHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/IsoHeader.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/IsoIn.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/IsoRegister.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ItemNameUtils.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/LimitedStreams.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/LockedStream.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/LpHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/LzFind.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/LzFindMt.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/LzFindOpt.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/LzFindPrepare.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/LzOutWindow.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/LzfseDecoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/LzhDecoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/LzhHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Lzma2Dec.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Lzma2DecMt.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Lzma2Decoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Lzma2Enc.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Lzma2Encoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Lzma2Register.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/LzmaDec.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/LzmaDecoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/LzmaEnc.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/LzmaEncoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/LzmaHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/LzmaRegister.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/LzmsDecoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/LzxDecoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/MachoHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/MbrHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Md5.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Md5Reg.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/MemBlocks.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/MethodId.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/MethodProps.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/MslzHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/MtCoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/MtDec.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/MubHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/MultiStream.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/MyAes.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/MyAesReg.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/MyMap.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/MyString.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/MyVector.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/MyWindows.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/MyXml.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/NewHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/NsisDecode.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/NsisHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/NsisIn.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/NsisRegister.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/NtfsHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/OffsetStream.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/OutBuffer.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/OutMemStream.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/OutStreamWithCRC.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/OutStreamWithSha1.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ParseProperties.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Pbkdf2HmacSha1.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/PeHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Ppmd7.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Ppmd7Dec.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Ppmd7Enc.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Ppmd7aDec.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Ppmd8.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Ppmd8Dec.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Ppmd8Enc.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/PpmdDecoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/PpmdEncoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/PpmdHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/PpmdRegister.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/PpmdZip.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ProgressMt.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ProgressUtils.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/PropId.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/PropVariant.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/PropVariantConv.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/PropVariantUtils.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/QcowHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/QuantumDecoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/RandGen.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Rar1Decoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Rar20Crypto.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Rar2Decoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Rar3Decoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Rar3Vm.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Rar5Aes.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Rar5Decoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Rar5Handler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/RarAes.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/RarCodecsRegister.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/RarHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/RpmHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Sha1.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Sha1Opt.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Sha1Prepare.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Sha1Reg.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Sha256.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Sha256Opt.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Sha256Prepare.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Sha256Reg.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Sha3.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Sha3Reg.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Sha512.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Sha512Opt.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Sha512Prepare.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Sha512Reg.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ShrinkDecoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Sort.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/SparseHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/SplitHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/SquashfsHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/StreamBinder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/StreamObjects.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/StreamUtils.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/StringConvert.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/StringToInt.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/SwapBytes.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/SwfHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Synchronization.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/System.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/TarHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/TarHandlerOut.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/TarHeader.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/TarIn.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/TarOut.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/TarRegister.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/TarUpdate.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Threads.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/TimeUtils.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/UTFConvert.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/UdfHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/UdfIn.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/UefiHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/UniqBlocks.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/VdiHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/VhdHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/VhdxHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/VirtThread.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/VmdkHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Wildcard.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/WimHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/WimHandlerOut.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/WimIn.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/WimRegister.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/WzAes.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/XarHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/XpressDecoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Xxh64.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Xxh64Reg.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/Xz.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/XzCrc64.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/XzCrc64Init.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/XzCrc64Opt.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/XzCrc64Reg.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/XzDec.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/XzDecoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/XzEnc.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/XzEncoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/XzHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/XzIn.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ZDecoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ZHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ZipAddCommon.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ZipCrypto.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ZipHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ZipHandlerOut.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ZipIn.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ZipItem.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ZipOut.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ZipRegister.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ZipStrong.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ZipUpdate.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ZlibDecoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ZlibEncoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ZstdDec.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ZstdDecoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/ZstdHandler.o +0 -0
- package/vendor/7zip/CPP/7zip/Compress/DeflateDecoder.cpp +15 -1
- package/scripts/clean-upstream-build.mjs +0 -9
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { existsSync
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
2
|
import { rename, link, rm, lstat, mkdir } from 'node:fs/promises';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
4
|
import { createRequire } from 'node:module';
|
|
5
5
|
import { availableParallelism } from 'node:os';
|
|
6
6
|
import { dirname, resolve, join, extname, relative, sep } from 'node:path';
|
|
7
|
-
import { Readable
|
|
7
|
+
import { Readable } from 'node:stream';
|
|
8
8
|
import { pipeline } from 'node:stream/promises';
|
|
9
|
-
import { fileURLToPath } from 'node:url';
|
|
10
9
|
|
|
11
10
|
class ArchiveError extends Error {
|
|
12
11
|
code;
|
|
@@ -18,6 +17,9 @@ class ArchiveError extends Error {
|
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
const defaultMaxOutputBytes = 4n * 1024n * 1024n * 1024n;
|
|
20
|
+
const defaultDeflateBufferSize = 32 * 1024;
|
|
21
|
+
const minDeflateBufferSize = 4 * 1024;
|
|
22
|
+
const maxDeflateBufferSize = 2 * 1024 * 1024;
|
|
21
23
|
function normalizeMaxBytes(value, label) {
|
|
22
24
|
if (value === undefined) {
|
|
23
25
|
return defaultMaxOutputBytes;
|
|
@@ -44,7 +46,7 @@ if (process.platform === 'win32') {
|
|
|
44
46
|
else if (process.platform === 'darwin') {
|
|
45
47
|
engineName = 'lib7z.dylib';
|
|
46
48
|
}
|
|
47
|
-
const packageDirectory = dirname(
|
|
49
|
+
const packageDirectory = dirname(require$1.resolve('7zip-native'));
|
|
48
50
|
const runtimeDirectory = [
|
|
49
51
|
resolve(packageDirectory, `../prebuilds/${process.platform}-${process.arch}`),
|
|
50
52
|
resolve(packageDirectory, '../build/Release'),
|
|
@@ -157,6 +159,19 @@ async function assertReplaceableOutput(filePath) {
|
|
|
157
159
|
}
|
|
158
160
|
}
|
|
159
161
|
}
|
|
162
|
+
async function assertFolderOutputDoesNotExist(filePath) {
|
|
163
|
+
try {
|
|
164
|
+
await lstat(filePath);
|
|
165
|
+
const error = new Error(`Output file already exists: ${filePath}`);
|
|
166
|
+
Object.assign(error, { code: 'EEXIST' });
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
if (error.code !== 'ENOENT') {
|
|
171
|
+
throw error;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
160
175
|
async function assertOutputDoesNotExist(filePath) {
|
|
161
176
|
try {
|
|
162
177
|
await lstat(filePath);
|
|
@@ -186,7 +201,7 @@ async function normalizeCreateEntry(entry) {
|
|
|
186
201
|
if (details.isSymbolicLink() || !details.isFile()) {
|
|
187
202
|
throw new ArchiveError('ERR_ARCHIVE_CREATE', `Archive creation source is not a regular file: ${sourcePath}`);
|
|
188
203
|
}
|
|
189
|
-
return { sourcePath, path: internalPath };
|
|
204
|
+
return { sourcePath, path: internalPath, mtimeMs: details.mtimeMs };
|
|
190
205
|
}
|
|
191
206
|
async function ensureExtractionRoot(root) {
|
|
192
207
|
try {
|
|
@@ -316,6 +331,7 @@ class Archive {
|
|
|
316
331
|
handle;
|
|
317
332
|
closed = false;
|
|
318
333
|
entriesPromise;
|
|
334
|
+
entryIndexes;
|
|
319
335
|
constructor(handle) {
|
|
320
336
|
this.handle = handle;
|
|
321
337
|
}
|
|
@@ -340,8 +356,14 @@ class Archive {
|
|
|
340
356
|
throw new RangeError('Password exceeds the 1 MiB native password limit');
|
|
341
357
|
}
|
|
342
358
|
}
|
|
359
|
+
const deflateBufferSize = options.deflateBufferSize ?? defaultDeflateBufferSize;
|
|
360
|
+
if (!Number.isSafeInteger(deflateBufferSize)
|
|
361
|
+
|| deflateBufferSize < minDeflateBufferSize
|
|
362
|
+
|| deflateBufferSize > maxDeflateBufferSize) {
|
|
363
|
+
throw new RangeError(`Deflate buffer size must be an integer between ${minDeflateBufferSize} and ${maxDeflateBufferSize} bytes`);
|
|
364
|
+
}
|
|
343
365
|
try {
|
|
344
|
-
const handle = await native.open(resolve(path), options.password, enginePath);
|
|
366
|
+
const handle = await native.open(resolve(path), options.password, enginePath, deflateBufferSize);
|
|
345
367
|
return new Archive(handle);
|
|
346
368
|
}
|
|
347
369
|
catch (cause) {
|
|
@@ -383,7 +405,7 @@ class Archive {
|
|
|
383
405
|
if (extension === '.7z') {
|
|
384
406
|
format = '7z';
|
|
385
407
|
}
|
|
386
|
-
else if (extension === '.zip'
|
|
408
|
+
else if (extension === '.zip') {
|
|
387
409
|
format = 'zip';
|
|
388
410
|
}
|
|
389
411
|
else if (extension === '.tar') {
|
|
@@ -453,7 +475,23 @@ class Archive {
|
|
|
453
475
|
if (typeof idOrPath === 'number' && (!Number.isSafeInteger(idOrPath) || idOrPath < 0)) {
|
|
454
476
|
throw new RangeError('Entry ID must be a non-negative safe integer');
|
|
455
477
|
}
|
|
456
|
-
|
|
478
|
+
const entries = await this.entries();
|
|
479
|
+
if (!this.entryIndexes) {
|
|
480
|
+
const pathEntries = Object.create(null);
|
|
481
|
+
const idEntries = Object.create(null);
|
|
482
|
+
for (const entry of entries) {
|
|
483
|
+
pathEntries[entry.path] ??= entry;
|
|
484
|
+
idEntries[entry.id] ??= entry;
|
|
485
|
+
}
|
|
486
|
+
this.entryIndexes = { pathEntries, idEntries };
|
|
487
|
+
}
|
|
488
|
+
if (typeof idOrPath === 'number') {
|
|
489
|
+
return this.entryIndexes.idEntries[idOrPath];
|
|
490
|
+
}
|
|
491
|
+
if (typeof idOrPath === 'string') {
|
|
492
|
+
return this.entryIndexes.pathEntries[idOrPath];
|
|
493
|
+
}
|
|
494
|
+
return undefined;
|
|
457
495
|
}
|
|
458
496
|
async extract(idOrPathOrPaths) {
|
|
459
497
|
this.assertOpen();
|
|
@@ -531,9 +569,6 @@ class Archive {
|
|
|
531
569
|
|| options.concurrency > 128)) {
|
|
532
570
|
throw new RangeError('Folder extraction concurrency must be an integer between 1 and 128');
|
|
533
571
|
}
|
|
534
|
-
if (options.onProgress !== undefined && typeof options.onProgress !== 'function') {
|
|
535
|
-
throw new TypeError('Folder extraction onProgress option must be a function');
|
|
536
|
-
}
|
|
537
572
|
if (options.onExtract !== undefined && typeof options.onExtract !== 'function') {
|
|
538
573
|
throw new TypeError('Folder extraction onExtract option must be a function');
|
|
539
574
|
}
|
|
@@ -576,33 +611,13 @@ class Archive {
|
|
|
576
611
|
}
|
|
577
612
|
const root = resolve(destination);
|
|
578
613
|
const plans = makeOutputPlans(root, selectedEntries);
|
|
579
|
-
const
|
|
580
|
-
if (maxBytes !== null &&
|
|
614
|
+
const totalBytes = selectedEntries.reduce((total, entry) => total + (entry.isDirectory ? 0n : entry.size), 0n);
|
|
615
|
+
if (maxBytes !== null && totalBytes > maxBytes) {
|
|
581
616
|
throw new ArchiveError('ERR_RESOURCE_LIMIT', `Folder output exceeds the ${maxBytes}-byte limit`);
|
|
582
617
|
}
|
|
583
618
|
options.signal?.throwIfAborted();
|
|
584
619
|
await ensureExtractionRoot(root);
|
|
585
|
-
let extractedBytes = 0n;
|
|
586
620
|
let filesExtracted = 0;
|
|
587
|
-
const totalFiles = plans.filter(plan => !plan.isDirectory).length;
|
|
588
|
-
const reportProgress = () => {
|
|
589
|
-
let percent = 0;
|
|
590
|
-
if (expectedBytes > 0n) {
|
|
591
|
-
const scaledPercent = extractedBytes * 10000n / expectedBytes;
|
|
592
|
-
percent = Number(scaledPercent > 9900n ? 9900n : scaledPercent) / 100;
|
|
593
|
-
}
|
|
594
|
-
if (filesExtracted === totalFiles) {
|
|
595
|
-
percent = 100;
|
|
596
|
-
}
|
|
597
|
-
options.onProgress?.({
|
|
598
|
-
filesExtracted,
|
|
599
|
-
totalFiles,
|
|
600
|
-
bytesProcessed: extractedBytes,
|
|
601
|
-
totalBytes: expectedBytes,
|
|
602
|
-
percent,
|
|
603
|
-
});
|
|
604
|
-
};
|
|
605
|
-
reportProgress();
|
|
606
621
|
for (const plan of plans) {
|
|
607
622
|
options.signal?.throwIfAborted();
|
|
608
623
|
if (plan.isDirectory) {
|
|
@@ -614,7 +629,6 @@ class Archive {
|
|
|
614
629
|
const extractionSignal = controller.signal;
|
|
615
630
|
let hasFailure = false;
|
|
616
631
|
let failure;
|
|
617
|
-
let nextFileIndex = 0;
|
|
618
632
|
const stop = (error) => {
|
|
619
633
|
if (!hasFailure) {
|
|
620
634
|
hasFailure = true;
|
|
@@ -628,78 +642,77 @@ class Archive {
|
|
|
628
642
|
stop(options.signal?.reason);
|
|
629
643
|
};
|
|
630
644
|
options.signal?.addEventListener('abort', abortFromCaller, { once: true });
|
|
631
|
-
const
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
645
|
+
const groupCount = Math.min(concurrency, filePlans.length);
|
|
646
|
+
const fileGroups = Array.from({ length: groupCount }, () => []);
|
|
647
|
+
filePlans.forEach((plan, index) => {
|
|
648
|
+
fileGroups[index % groupCount].push(plan);
|
|
649
|
+
});
|
|
650
|
+
const extractGroup = async (group) => {
|
|
651
|
+
const outputs = [];
|
|
652
|
+
let completionFailed = false;
|
|
653
|
+
let completionFailure;
|
|
654
|
+
try {
|
|
655
|
+
for (const plan of group) {
|
|
656
|
+
await ensureOutputParents(root, plan.targetPath);
|
|
657
|
+
extractionSignal.throwIfAborted();
|
|
658
|
+
if (options.overwrite) {
|
|
659
|
+
await assertReplaceableOutput(plan.targetPath);
|
|
643
660
|
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
return;
|
|
661
|
+
else {
|
|
662
|
+
await assertFolderOutputDoesNotExist(plan.targetPath);
|
|
647
663
|
}
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
const temporaryPath = join(dirname(plan.targetPath), `.7zip-native-${randomUUID()}.tmp`);
|
|
654
|
-
try {
|
|
655
|
-
await pipeline(this.createReadStream(plan.entry.id, {
|
|
656
|
-
signal: extractionSignal,
|
|
657
|
-
maxBytes: null,
|
|
658
|
-
}), limit, createWriteStream(temporaryPath, { flags: 'wx', mode: 0o600 }), { signal: extractionSignal });
|
|
659
|
-
extractionSignal.throwIfAborted();
|
|
660
|
-
await assertReplaceableOutput(plan.targetPath);
|
|
661
|
-
extractionSignal.throwIfAborted();
|
|
662
|
-
await rename(temporaryPath, plan.targetPath);
|
|
664
|
+
outputs.push({
|
|
665
|
+
id: plan.entry.id,
|
|
666
|
+
path: plan.targetPath,
|
|
667
|
+
overwrite: options.overwrite === true,
|
|
668
|
+
});
|
|
663
669
|
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
670
|
+
let onFileCompleted;
|
|
671
|
+
const onExtract = options.onExtract;
|
|
672
|
+
if (onExtract) {
|
|
673
|
+
const plansById = new Map(group.map(plan => [plan.entry.id, plan]));
|
|
674
|
+
onFileCompleted = (id) => {
|
|
675
|
+
if (completionFailed || hasFailure) {
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
try {
|
|
679
|
+
const plan = plansById.get(id);
|
|
680
|
+
if (plan === undefined) {
|
|
681
|
+
throw new ArchiveError('ERR_ARCHIVE_EXTRACT', 'Native folder extraction returned an unknown file completion');
|
|
682
|
+
}
|
|
683
|
+
extractionSignal.throwIfAborted();
|
|
684
|
+
filesExtracted++;
|
|
685
|
+
onExtract({
|
|
686
|
+
entry: plan.entry,
|
|
687
|
+
outputPath: plan.targetPath,
|
|
688
|
+
percent: filesExtracted * 100 / filePlans.length,
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
catch (error) {
|
|
692
|
+
completionFailed = true;
|
|
693
|
+
completionFailure = error;
|
|
694
|
+
stop(error);
|
|
695
|
+
}
|
|
696
|
+
};
|
|
667
697
|
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
signal: extractionSignal,
|
|
672
|
-
maxBytes: null,
|
|
673
|
-
}), limit, createWriteStream(plan.targetPath, { flags: 'wx', mode: 0o600 }), { signal: extractionSignal });
|
|
674
|
-
}
|
|
675
|
-
filesExtracted++;
|
|
676
|
-
reportProgress();
|
|
677
|
-
options.onExtract?.({ entry: plan.entry, outputPath: plan.targetPath });
|
|
678
|
-
};
|
|
679
|
-
const runWorker = async () => {
|
|
680
|
-
while (!hasFailure) {
|
|
681
|
-
if (options.signal?.aborted) {
|
|
682
|
-
stop(options.signal.reason);
|
|
683
|
-
return;
|
|
684
|
-
}
|
|
685
|
-
const plan = filePlans[nextFileIndex++];
|
|
686
|
-
if (!plan) {
|
|
687
|
-
return;
|
|
688
|
-
}
|
|
689
|
-
try {
|
|
690
|
-
await extractFile(plan);
|
|
691
|
-
}
|
|
692
|
-
catch (error) {
|
|
693
|
-
stop(error);
|
|
694
|
-
return;
|
|
698
|
+
await this.extractEntriesToFiles(outputs, extractionSignal, onFileCompleted);
|
|
699
|
+
if (completionFailed) {
|
|
700
|
+
throw completionFailure;
|
|
695
701
|
}
|
|
696
702
|
}
|
|
703
|
+
catch (caughtError) {
|
|
704
|
+
throw completionFailed ? completionFailure : caughtError;
|
|
705
|
+
}
|
|
697
706
|
};
|
|
698
707
|
try {
|
|
699
708
|
options.signal?.throwIfAborted();
|
|
700
|
-
const workers =
|
|
701
|
-
|
|
702
|
-
|
|
709
|
+
const workers = fileGroups.map(group => extractGroup(group));
|
|
710
|
+
try {
|
|
711
|
+
await Promise.all(workers);
|
|
712
|
+
}
|
|
713
|
+
catch (error) {
|
|
714
|
+
stop(error);
|
|
715
|
+
await Promise.allSettled(workers);
|
|
703
716
|
throw failure;
|
|
704
717
|
}
|
|
705
718
|
}
|
|
@@ -707,8 +720,67 @@ class Archive {
|
|
|
707
720
|
options.signal?.removeEventListener('abort', abortFromCaller);
|
|
708
721
|
}
|
|
709
722
|
}
|
|
710
|
-
async read(
|
|
723
|
+
async read(idOrPathOrPaths, options) {
|
|
711
724
|
this.assertOpen();
|
|
725
|
+
const maxUInt64 = (1n << 64n) - 1n;
|
|
726
|
+
const normalizeRange = (range) => {
|
|
727
|
+
const offset = this.toUnsignedBigInt(range.offset ?? 0, 'offset');
|
|
728
|
+
const length = this.toUnsignedBigInt(range.length, 'length');
|
|
729
|
+
if (offset > maxUInt64 || length > maxUInt64 - offset) {
|
|
730
|
+
throw new ArchiveError('ERR_INVALID_RANGE', 'Read range exceeds the native 64-bit offset limit');
|
|
731
|
+
}
|
|
732
|
+
return { offset, length };
|
|
733
|
+
};
|
|
734
|
+
if (options === undefined) {
|
|
735
|
+
if (!Array.isArray(idOrPathOrPaths)) {
|
|
736
|
+
throw new TypeError('Read options are required for an entry selector');
|
|
737
|
+
}
|
|
738
|
+
const requests = idOrPathOrPaths;
|
|
739
|
+
const normalized = await Promise.all(requests.map(async (request) => {
|
|
740
|
+
if (!request || typeof request !== 'object' || !('entry' in request)) {
|
|
741
|
+
throw new TypeError('Batch read requests must include an entry selector');
|
|
742
|
+
}
|
|
743
|
+
const range = normalizeRange(request);
|
|
744
|
+
return {
|
|
745
|
+
id: await this.resolveEntryId(request.entry),
|
|
746
|
+
...range,
|
|
747
|
+
};
|
|
748
|
+
}));
|
|
749
|
+
if (!normalized.length) {
|
|
750
|
+
return [];
|
|
751
|
+
}
|
|
752
|
+
try {
|
|
753
|
+
return await native.readMany(this.handle, normalized);
|
|
754
|
+
}
|
|
755
|
+
catch (cause) {
|
|
756
|
+
throw extractionError(cause);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
const isBatch = Array.isArray(idOrPathOrPaths);
|
|
760
|
+
let selectors;
|
|
761
|
+
if (isBatch) {
|
|
762
|
+
selectors = idOrPathOrPaths;
|
|
763
|
+
}
|
|
764
|
+
else {
|
|
765
|
+
selectors = [idOrPathOrPaths];
|
|
766
|
+
}
|
|
767
|
+
const { offset, length } = normalizeRange(options);
|
|
768
|
+
if (isBatch) {
|
|
769
|
+
const ids = await Promise.all(selectors.map(selector => this.resolveEntryId(selector)));
|
|
770
|
+
const uniqueIds = [...new Set(ids)];
|
|
771
|
+
if (!uniqueIds.length) {
|
|
772
|
+
return [];
|
|
773
|
+
}
|
|
774
|
+
try {
|
|
775
|
+
const buffers = await native.readMany(this.handle, uniqueIds.map(id => ({ id, offset, length })));
|
|
776
|
+
const buffersById = new Map(uniqueIds.map((id, index) => [id, buffers[index]]));
|
|
777
|
+
return ids.map(id => buffersById.get(id));
|
|
778
|
+
}
|
|
779
|
+
catch (cause) {
|
|
780
|
+
throw extractionError(cause);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
const idOrPath = selectors[0];
|
|
712
784
|
let id;
|
|
713
785
|
if (typeof idOrPath === 'number') {
|
|
714
786
|
this.validateIds([idOrPath]);
|
|
@@ -717,12 +789,6 @@ class Archive {
|
|
|
717
789
|
else {
|
|
718
790
|
id = await this.resolveEntryId(idOrPath);
|
|
719
791
|
}
|
|
720
|
-
const offset = this.toUnsignedBigInt(options.offset ?? 0, 'offset');
|
|
721
|
-
const length = this.toUnsignedBigInt(options.length, 'length');
|
|
722
|
-
const maxUInt64 = (1n << 64n) - 1n;
|
|
723
|
-
if (offset > maxUInt64 || length > maxUInt64 - offset) {
|
|
724
|
-
throw new ArchiveError('ERR_INVALID_RANGE', 'Read range exceeds the native 64-bit offset limit');
|
|
725
|
-
}
|
|
726
792
|
try {
|
|
727
793
|
return await native.read(this.handle, id, offset, length);
|
|
728
794
|
}
|
|
@@ -730,6 +796,32 @@ class Archive {
|
|
|
730
796
|
throw extractionError(cause);
|
|
731
797
|
}
|
|
732
798
|
}
|
|
799
|
+
async extractEntriesToFiles(outputs, signal, onFileCompleted) {
|
|
800
|
+
let task;
|
|
801
|
+
const cancelTask = () => {
|
|
802
|
+
if (task) {
|
|
803
|
+
native.cancelExtractToFiles(task.taskId);
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
try {
|
|
807
|
+
signal.throwIfAborted();
|
|
808
|
+
task = native.startExtractToFiles(this.handle, outputs, onFileCompleted);
|
|
809
|
+
signal.addEventListener('abort', cancelTask, { once: true });
|
|
810
|
+
if (signal.aborted) {
|
|
811
|
+
cancelTask();
|
|
812
|
+
}
|
|
813
|
+
return await task.promise;
|
|
814
|
+
}
|
|
815
|
+
catch (cause) {
|
|
816
|
+
if (signal.aborted) {
|
|
817
|
+
throw signal.reason ?? cause;
|
|
818
|
+
}
|
|
819
|
+
throw extractionError(cause);
|
|
820
|
+
}
|
|
821
|
+
finally {
|
|
822
|
+
signal.removeEventListener('abort', cancelTask);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
733
825
|
async close() {
|
|
734
826
|
if (this.closed) {
|
|
735
827
|
return;
|