@keystrokehq/cli 0.1.2 → 0.1.4
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/dist/alias-RTYYYW3D-CLFgrowj.mjs +98 -0
- package/dist/alias-RTYYYW3D-CLFgrowj.mjs.map +1 -0
- package/dist/awk2-LA3USKJP-BbsfXVlR.mjs +2737 -0
- package/dist/awk2-LA3USKJP-BbsfXVlR.mjs.map +1 -0
- package/dist/base64-C2AIWVNC-C0WIgu5V.mjs +123 -0
- package/dist/base64-C2AIWVNC-C0WIgu5V.mjs.map +1 -0
- package/dist/basename-UB3CIYNI-BgNN3bGm.mjs +53 -0
- package/dist/basename-UB3CIYNI-BgNN3bGm.mjs.map +1 -0
- package/dist/bash-YZ33HQZQ-N6YyKtUH.mjs +118 -0
- package/dist/bash-YZ33HQZQ-N6YyKtUH.mjs.map +1 -0
- package/dist/cat-TSFMZVYS-Dz3-oHsV.mjs +63 -0
- package/dist/cat-TSFMZVYS-Dz3-oHsV.mjs.map +1 -0
- package/dist/chmod-TFEPA42X-YF02QJUv.mjs +125 -0
- package/dist/chmod-TFEPA42X-YF02QJUv.mjs.map +1 -0
- package/dist/chunk-27JIFWUR-B6ZjjMMI.mjs +100 -0
- package/dist/chunk-27JIFWUR-B6ZjjMMI.mjs.map +1 -0
- package/dist/chunk-4I3HOE5Z-BixWWVkW.mjs +719 -0
- package/dist/chunk-4I3HOE5Z-BixWWVkW.mjs.map +1 -0
- package/dist/chunk-4RUAZWKT-D60fyWAB.mjs +22543 -0
- package/dist/chunk-4RUAZWKT-D60fyWAB.mjs.map +1 -0
- package/dist/chunk-4WKZNNJK-CiwxAWRf.mjs +69 -0
- package/dist/chunk-4WKZNNJK-CiwxAWRf.mjs.map +1 -0
- package/dist/chunk-5H5SCKJM-BvfXlL01.mjs +606 -0
- package/dist/chunk-5H5SCKJM-BvfXlL01.mjs.map +1 -0
- package/dist/chunk-AQ6FYS2X-CkVetjym.mjs +37 -0
- package/dist/chunk-AQ6FYS2X-CkVetjym.mjs.map +1 -0
- package/dist/chunk-BZUGFHVS-CPWRFwK8.mjs +34 -0
- package/dist/chunk-BZUGFHVS-CPWRFwK8.mjs.map +1 -0
- package/dist/chunk-CHFEPBH4-BUdgjFtD.mjs +594 -0
- package/dist/chunk-CHFEPBH4-BUdgjFtD.mjs.map +1 -0
- package/dist/chunk-DLL7UR66-BUYgzxnR.mjs +14 -0
- package/dist/chunk-DLL7UR66-BUYgzxnR.mjs.map +1 -0
- package/dist/chunk-DiodbrVj.mjs +27 -0
- package/dist/chunk-EBAPSGAO-Ctfslw2R.mjs +247 -0
- package/dist/chunk-EBAPSGAO-Ctfslw2R.mjs.map +1 -0
- package/dist/chunk-FOCWZZDE-BIntqBh2.mjs +19 -0
- package/dist/chunk-FOCWZZDE-BIntqBh2.mjs.map +1 -0
- package/dist/chunk-HBVMHTO5-CJyD-QZX.mjs +10 -0
- package/dist/chunk-HBVMHTO5-CJyD-QZX.mjs.map +1 -0
- package/dist/chunk-L2UW7DWF-B3tEHhPF.mjs +14 -0
- package/dist/chunk-L2UW7DWF-B3tEHhPF.mjs.map +1 -0
- package/dist/chunk-L64BMZUV-CyR7RKok.mjs +30 -0
- package/dist/chunk-L64BMZUV-CyR7RKok.mjs.map +1 -0
- package/dist/chunk-LEKBROJD-CJMrAyu9.mjs +3113 -0
- package/dist/chunk-LEKBROJD-CJMrAyu9.mjs.map +1 -0
- package/dist/chunk-NRSASXYY-CuWyREpD.mjs +41 -0
- package/dist/chunk-NRSASXYY-CuWyREpD.mjs.map +1 -0
- package/dist/chunk-QAYAQNCG-Bl0Kbd53.mjs +63 -0
- package/dist/chunk-QAYAQNCG-Bl0Kbd53.mjs.map +1 -0
- package/dist/chunk-QIQMJJZ4-BwKdslXs.mjs +93 -0
- package/dist/chunk-QIQMJJZ4-BwKdslXs.mjs.map +1 -0
- package/dist/chunk-SAI2SPQQ-CVRoDNs9.mjs +26 -0
- package/dist/chunk-SAI2SPQQ-CVRoDNs9.mjs.map +1 -0
- package/dist/chunk-SO6R3ZKN-tTw_RMDX.mjs +140 -0
- package/dist/chunk-SO6R3ZKN-tTw_RMDX.mjs.map +1 -0
- package/dist/chunk-STHBFACM-lyj-j2a-.mjs +8 -0
- package/dist/chunk-STHBFACM-lyj-j2a-.mjs.map +1 -0
- package/dist/chunk-SX2HC7SO-Cc4Hpis1.mjs +20 -0
- package/dist/chunk-SX2HC7SO-Cc4Hpis1.mjs.map +1 -0
- package/dist/chunk-TDD4NFYE-wsWW75MX.mjs +21 -0
- package/dist/chunk-TDD4NFYE-wsWW75MX.mjs.map +1 -0
- package/dist/chunk-TN7HHBQW-CSB_R-XD.mjs +1137 -0
- package/dist/chunk-TN7HHBQW-CSB_R-XD.mjs.map +1 -0
- package/dist/chunk-VPADYNBD-BKlA28GJ.mjs +122 -0
- package/dist/chunk-VPADYNBD-BKlA28GJ.mjs.map +1 -0
- package/dist/chunk-W5DWRFSU-lCyWk0ph.mjs +11 -0
- package/dist/chunk-W5DWRFSU-lCyWk0ph.mjs.map +1 -0
- package/dist/chunk-WNH3HOQA-BCZUOjCJ.mjs +34 -0
- package/dist/chunk-WNH3HOQA-BCZUOjCJ.mjs.map +1 -0
- package/dist/chunk-XRFHFXFP-BGxzVZgK.mjs +16 -0
- package/dist/chunk-XRFHFXFP-BGxzVZgK.mjs.map +1 -0
- package/dist/chunk-YCLFEX4T-COc1AThz.mjs +77 -0
- package/dist/chunk-YCLFEX4T-COc1AThz.mjs.map +1 -0
- package/dist/clear-HKGFEOF6-CekN2x-O.mjs +28 -0
- package/dist/clear-HKGFEOF6-CekN2x-O.mjs.map +1 -0
- package/dist/column-XT6UFXNQ-DHENV9D2.mjs +143 -0
- package/dist/column-XT6UFXNQ-DHENV9D2.mjs.map +1 -0
- package/dist/comm-VV2LDX2J-ppxDJFkY.mjs +87 -0
- package/dist/comm-VV2LDX2J-ppxDJFkY.mjs.map +1 -0
- package/dist/cp-BISAAS7A-CMWayU4n.mjs +106 -0
- package/dist/cp-BISAAS7A-CMWayU4n.mjs.map +1 -0
- package/dist/cut-OKARJCCV-Bt8b58eI.mjs +119 -0
- package/dist/cut-OKARJCCV-Bt8b58eI.mjs.map +1 -0
- package/dist/date-UUUPW43J-B7T5OTZZ.mjs +188 -0
- package/dist/date-UUUPW43J-B7T5OTZZ.mjs.map +1 -0
- package/dist/diff-MWJFIG7X-DhnPc_5r.mjs +755 -0
- package/dist/diff-MWJFIG7X-DhnPc_5r.mjs.map +1 -0
- package/dist/dirname-MPHRFUTI-Dkb3S4OX.mjs +43 -0
- package/dist/dirname-MPHRFUTI-Dkb3S4OX.mjs.map +1 -0
- package/dist/{dist-DjfxlOWX.mjs → dist-C47GdlWY.mjs} +18 -93
- package/dist/{dist-DjfxlOWX.mjs.map → dist-C47GdlWY.mjs.map} +1 -1
- package/dist/{dist-DWcRd4Se.mjs → dist-CJL2zYbP.mjs} +4 -71
- package/dist/dist-CJL2zYbP.mjs.map +1 -0
- package/dist/dist-Ch53z2P3.mjs +3 -0
- package/dist/dist-CwR72_PS.mjs +1887 -0
- package/dist/dist-CwR72_PS.mjs.map +1 -0
- package/dist/du-572XNP42-ClP4jXB1.mjs +176 -0
- package/dist/du-572XNP42-ClP4jXB1.mjs.map +1 -0
- package/dist/echo-NDWZZHPO-CCp_-MxA.mjs +137 -0
- package/dist/echo-NDWZZHPO-CCp_-MxA.mjs.map +1 -0
- package/dist/env-36M5BO7M-CsP_aiWr.mjs +119 -0
- package/dist/env-36M5BO7M-CsP_aiWr.mjs.map +1 -0
- package/dist/expand-JSPG6VOP-B-YUvYpu.mjs +145 -0
- package/dist/expand-JSPG6VOP-B-YUvYpu.mjs.map +1 -0
- package/dist/expr-5JAACS4X-1TBq84gG.mjs +153 -0
- package/dist/expr-5JAACS4X-1TBq84gG.mjs.map +1 -0
- package/dist/file-IPZJC3FQ-DcZNOWyY.mjs +4201 -0
- package/dist/file-IPZJC3FQ-DcZNOWyY.mjs.map +1 -0
- package/dist/find-INTH3OLC-6p47KeeT.mjs +1332 -0
- package/dist/find-INTH3OLC-6p47KeeT.mjs.map +1 -0
- package/dist/fold-4TQNYMSW-C54bHzLd.mjs +138 -0
- package/dist/fold-4TQNYMSW-C54bHzLd.mjs.map +1 -0
- package/dist/grep-V3LQVMRQ-D99Bq7Kj.mjs +335 -0
- package/dist/grep-V3LQVMRQ-D99Bq7Kj.mjs.map +1 -0
- package/dist/gzip-O5ASJAFY-CZDRROqP.mjs +592 -0
- package/dist/gzip-O5ASJAFY-CZDRROqP.mjs.map +1 -0
- package/dist/head-442HYESI-D96RMdki.mjs +36 -0
- package/dist/head-442HYESI-D96RMdki.mjs.map +1 -0
- package/dist/help-HZ6M2CKN--DK8mY2L.mjs +123 -0
- package/dist/help-HZ6M2CKN--DK8mY2L.mjs.map +1 -0
- package/dist/history-WYYKSLSZ-ACNQVupn.mjs +48 -0
- package/dist/history-WYYKSLSZ-ACNQVupn.mjs.map +1 -0
- package/dist/hostname-C4HQXXUP-CXVVFkUK.mjs +24 -0
- package/dist/hostname-C4HQXXUP-CXVVFkUK.mjs.map +1 -0
- package/dist/html-to-markdown-JW4MSQZO-DQOxFIvF.mjs +15890 -0
- package/dist/html-to-markdown-JW4MSQZO-DQOxFIvF.mjs.map +1 -0
- package/dist/index.mjs +20 -18
- package/dist/index.mjs.map +1 -1
- package/dist/join-TBRGI3LQ-B8I9tkJ5.mjs +198 -0
- package/dist/join-TBRGI3LQ-B8I9tkJ5.mjs.map +1 -0
- package/dist/jq-4XLYLOS5-wFZYfsfJ.mjs +257 -0
- package/dist/jq-4XLYLOS5-wFZYfsfJ.mjs.map +1 -0
- package/dist/js-exec-N5KEZBH7-CgtG-I6s.mjs +333 -0
- package/dist/js-exec-N5KEZBH7-CgtG-I6s.mjs.map +1 -0
- package/dist/lib-D4GpdNNK.mjs +45 -0
- package/dist/lib-D4GpdNNK.mjs.map +1 -0
- package/dist/ln-4LGSXXGD-Dg0R9i5G.mjs +101 -0
- package/dist/ln-4LGSXXGD-Dg0R9i5G.mjs.map +1 -0
- package/dist/ls-ZJGQER7M-DLDSfI4x.mjs +1891 -0
- package/dist/ls-ZJGQER7M-DLDSfI4x.mjs.map +1 -0
- package/dist/lzma-CTMDi254.mjs +1135 -0
- package/dist/lzma-CTMDi254.mjs.map +1 -0
- package/dist/{maybe-auto-update-Ou7H6dXT.mjs → maybe-auto-update-B0kal2FM.mjs} +2 -2
- package/dist/{maybe-auto-update-Ou7H6dXT.mjs.map → maybe-auto-update-B0kal2FM.mjs.map} +1 -1
- package/dist/md5sum-SPU24VSG-DQc8sqXO.mjs +16 -0
- package/dist/md5sum-SPU24VSG-DQc8sqXO.mjs.map +1 -0
- package/dist/mkdir-MEPGZOB6-BjUKzhdL.mjs +58 -0
- package/dist/mkdir-MEPGZOB6-BjUKzhdL.mjs.map +1 -0
- package/dist/mv-W5BIQ646-CdSIyY-U.mjs +93 -0
- package/dist/mv-W5BIQ646-CdSIyY-U.mjs.map +1 -0
- package/dist/nl-WSDW7I4O-DmtCnyKU.mjs +208 -0
- package/dist/nl-WSDW7I4O-DmtCnyKU.mjs.map +1 -0
- package/dist/od-WOKFDJTP-DZ2nxQNJ.mjs +73 -0
- package/dist/od-WOKFDJTP-DZ2nxQNJ.mjs.map +1 -0
- package/dist/paste-7JC6S4DX-CtmM5Qy8.mjs +113 -0
- package/dist/paste-7JC6S4DX-CtmM5Qy8.mjs.map +1 -0
- package/dist/printf-TWGXF445-B7cTysaa.mjs +880 -0
- package/dist/printf-TWGXF445-B7cTysaa.mjs.map +1 -0
- package/dist/pwd-WE6EN5AV-CO8o2WQS.mjs +34 -0
- package/dist/pwd-WE6EN5AV-CO8o2WQS.mjs.map +1 -0
- package/dist/python3-POMOR4OA-CKy80mpF.mjs +299 -0
- package/dist/python3-POMOR4OA-CKy80mpF.mjs.map +1 -0
- package/dist/readlink-OPJF4DL5-Rc1Mz_Xx.mjs +76 -0
- package/dist/readlink-OPJF4DL5-Rc1Mz_Xx.mjs.map +1 -0
- package/dist/rev-5EHFX4EJ-3dd9vwHW.mjs +66 -0
- package/dist/rev-5EHFX4EJ-3dd9vwHW.mjs.map +1 -0
- package/dist/rg-S4FXYXWB-BbXVo6JX.mjs +1539 -0
- package/dist/rg-S4FXYXWB-BbXVo6JX.mjs.map +1 -0
- package/dist/rm-SSGETQVQ-Ch53Rmrr.mjs +81 -0
- package/dist/rm-SSGETQVQ-Ch53Rmrr.mjs.map +1 -0
- package/dist/rmdir-OC4ZLPYA-D3QCHlIB.mjs +132 -0
- package/dist/rmdir-OC4ZLPYA-D3QCHlIB.mjs.map +1 -0
- package/dist/sed-S5UIK574-DE1KeTk3.mjs +1722 -0
- package/dist/sed-S5UIK574-DE1KeTk3.mjs.map +1 -0
- package/dist/seq-M5EC7Q57-BHfGjQvK.mjs +85 -0
- package/dist/seq-M5EC7Q57-BHfGjQvK.mjs.map +1 -0
- package/dist/sha1sum-2PTOAFR6-DNjSNcYK.mjs +16 -0
- package/dist/sha1sum-2PTOAFR6-DNjSNcYK.mjs.map +1 -0
- package/dist/sha256sum-NS7D3IXX-BMaCKkT5.mjs +16 -0
- package/dist/sha256sum-NS7D3IXX-BMaCKkT5.mjs.map +1 -0
- package/dist/sleep-X22JJINO-Do5hEQQW.mjs +67 -0
- package/dist/sleep-X22JJINO-Do5hEQQW.mjs.map +1 -0
- package/dist/sort-SW2YEO5B-B7j1zw8k.mjs +320 -0
- package/dist/sort-SW2YEO5B-B7j1zw8k.mjs.map +1 -0
- package/dist/split-4KKZZXXE-h8GD4HP4.mjs +248 -0
- package/dist/split-4KKZZXXE-h8GD4HP4.mjs.map +1 -0
- package/dist/sqlite3-CGOEFJAO-DvzzghDg.mjs +2879 -0
- package/dist/sqlite3-CGOEFJAO-DvzzghDg.mjs.map +1 -0
- package/dist/stat-CD34IZ4P-B5ZOJh4J.mjs +65 -0
- package/dist/stat-CD34IZ4P-B5ZOJh4J.mjs.map +1 -0
- package/dist/strings-6WDHLGMX-DdiEdoL-.mjs +179 -0
- package/dist/strings-6WDHLGMX-DdiEdoL-.mjs.map +1 -0
- package/dist/tac-2STMMJYW-DPyeWM9R.mjs +53 -0
- package/dist/tac-2STMMJYW-DPyeWM9R.mjs.map +1 -0
- package/dist/tail-R4PCA2C4-CUfroNeu.mjs +37 -0
- package/dist/tail-R4PCA2C4-CUfroNeu.mjs.map +1 -0
- package/dist/tar-STHHZTZ6-DRf60e-G.mjs +2838 -0
- package/dist/tar-STHHZTZ6-DRf60e-G.mjs.map +1 -0
- package/dist/tee-YUZ2FKCJ-po_dfyc_.mjs +46 -0
- package/dist/tee-YUZ2FKCJ-po_dfyc_.mjs.map +1 -0
- package/dist/time-D4LNBSWX-DVWhAldK.mjs +112 -0
- package/dist/time-D4LNBSWX-DVWhAldK.mjs.map +1 -0
- package/dist/timeout-YDCRSLPQ-B_yntmXU.mjs +113 -0
- package/dist/timeout-YDCRSLPQ-B_yntmXU.mjs.map +1 -0
- package/dist/touch-UA33VN3N-oW1SBT1r.mjs +104 -0
- package/dist/touch-UA33VN3N-oW1SBT1r.mjs.map +1 -0
- package/dist/tr-36LHWFRQ-CTq3z6wq.mjs +167 -0
- package/dist/tr-36LHWFRQ-CTq3z6wq.mjs.map +1 -0
- package/dist/tree-YLD52CNT-CIozNsLQ.mjs +186 -0
- package/dist/tree-YLD52CNT-CIozNsLQ.mjs.map +1 -0
- package/dist/true-FHQXJXBE-DsJOznSp.mjs +31 -0
- package/dist/true-FHQXJXBE-DsJOznSp.mjs.map +1 -0
- package/dist/unexpand-CADSA4VO-Cq9DTcUg.mjs +155 -0
- package/dist/unexpand-CADSA4VO-Cq9DTcUg.mjs.map +1 -0
- package/dist/uniq-XSIZR6PB-D5lt-IXF.mjs +92 -0
- package/dist/uniq-XSIZR6PB-D5lt-IXF.mjs.map +1 -0
- package/dist/{version-n-JpPeUF.mjs → version-Dxl3y5p6.mjs} +2 -2
- package/dist/{version-n-JpPeUF.mjs.map → version-Dxl3y5p6.mjs.map} +1 -1
- package/dist/wc-LF7NU4LA-BFPabrwD.mjs +111 -0
- package/dist/wc-LF7NU4LA-BFPabrwD.mjs.map +1 -0
- package/dist/which-XEM24D5D-2LvlkpUo.mjs +62 -0
- package/dist/which-XEM24D5D-2LvlkpUo.mjs.map +1 -0
- package/dist/whoami-XMTX52VE-24Kwqrk6.mjs +24 -0
- package/dist/whoami-XMTX52VE-24Kwqrk6.mjs.map +1 -0
- package/dist/xan-Y6WF3IRG-DjKO96Pj.mjs +2832 -0
- package/dist/xan-Y6WF3IRG-DjKO96Pj.mjs.map +1 -0
- package/dist/xan-view-HDVKHFC2-DhDNVE_V.mjs +12 -0
- package/dist/xan-view-HDVKHFC2-DhDNVE_V.mjs.map +1 -0
- package/dist/xargs-MGZPH7AX-D2bIgrdg.mjs +112 -0
- package/dist/xargs-MGZPH7AX-D2bIgrdg.mjs.map +1 -0
- package/dist/yq-4QJW3EQG-XhB3aACo.mjs +8610 -0
- package/dist/yq-4QJW3EQG-XhB3aACo.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/dist-DWcRd4Se.mjs.map +0 -1
- package/dist/dist-DitNZUHA.mjs +0 -3
- package/dist/dist-vwoMCz6d.mjs +0 -775
- package/dist/dist-vwoMCz6d.mjs.map +0 -1
|
@@ -0,0 +1,1135 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import * as os from "node:os";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
import { createReadStream, createWriteStream } from "node:fs";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import * as assert from "node:assert";
|
|
8
|
+
import { Transform } from "node:stream";
|
|
9
|
+
import { EventEmitter } from "node:events";
|
|
10
|
+
import { pipeline } from "node:stream/promises";
|
|
11
|
+
//#region ../../node_modules/.pnpm/node-liblzma@2.2.0/node_modules/node-liblzma/lib/errors.js
|
|
12
|
+
/**
|
|
13
|
+
* node-liblzma - Node.js bindings for liblzma
|
|
14
|
+
* Copyright (C) Olivier Orabona <olivier.orabona@gmail.com>
|
|
15
|
+
*
|
|
16
|
+
* This program is free software: you can redistribute it and/or modify
|
|
17
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
18
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
19
|
+
* (at your option) any later version.
|
|
20
|
+
*
|
|
21
|
+
* This program is distributed in the hope that it will be useful,
|
|
22
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
23
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
24
|
+
* GNU General Public License for more details.
|
|
25
|
+
*
|
|
26
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
27
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Base class for all LZMA-related errors
|
|
31
|
+
*/
|
|
32
|
+
var LZMAError = class extends Error {
|
|
33
|
+
constructor(message, errno) {
|
|
34
|
+
super(message);
|
|
35
|
+
this.name = "LZMAError";
|
|
36
|
+
this.errno = errno;
|
|
37
|
+
this.code = errno;
|
|
38
|
+
Error.captureStackTrace(this, this.constructor);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Memory allocation error - thrown when LZMA cannot allocate required memory
|
|
43
|
+
*/
|
|
44
|
+
var LZMAMemoryError = class extends LZMAError {
|
|
45
|
+
constructor(errno) {
|
|
46
|
+
super("Cannot allocate memory", errno);
|
|
47
|
+
this.name = "LZMAMemoryError";
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Memory limit error - thrown when operation would exceed memory usage limit
|
|
52
|
+
*/
|
|
53
|
+
var LZMAMemoryLimitError = class extends LZMAError {
|
|
54
|
+
constructor(errno) {
|
|
55
|
+
super("Memory usage limit was reached", errno);
|
|
56
|
+
this.name = "LZMAMemoryLimitError";
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Format error - thrown when file format is not recognized
|
|
61
|
+
*/
|
|
62
|
+
var LZMAFormatError = class extends LZMAError {
|
|
63
|
+
constructor(errno) {
|
|
64
|
+
super("File format not recognized", errno);
|
|
65
|
+
this.name = "LZMAFormatError";
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Options error - thrown when invalid or unsupported options are provided
|
|
70
|
+
*/
|
|
71
|
+
var LZMAOptionsError = class extends LZMAError {
|
|
72
|
+
constructor(errno) {
|
|
73
|
+
super("Invalid or unsupported options", errno);
|
|
74
|
+
this.name = "LZMAOptionsError";
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Data error - thrown when compressed data is corrupt
|
|
79
|
+
*/
|
|
80
|
+
var LZMADataError = class extends LZMAError {
|
|
81
|
+
constructor(errno) {
|
|
82
|
+
super("Data is corrupt", errno);
|
|
83
|
+
this.name = "LZMADataError";
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Buffer error - thrown when no progress is possible (e.g., buffer too small)
|
|
88
|
+
*/
|
|
89
|
+
var LZMABufferError = class extends LZMAError {
|
|
90
|
+
constructor(errno) {
|
|
91
|
+
super("No progress is possible", errno);
|
|
92
|
+
this.name = "LZMABufferError";
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Programming error - thrown when there's an internal programming error
|
|
97
|
+
*/
|
|
98
|
+
var LZMAProgrammingError = class extends LZMAError {
|
|
99
|
+
constructor(errno) {
|
|
100
|
+
super("Programming error", errno);
|
|
101
|
+
this.name = "LZMAProgrammingError";
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Factory function to create appropriate error instance based on errno
|
|
106
|
+
*/
|
|
107
|
+
function createLZMAError(errno, message) {
|
|
108
|
+
const LZMA_MEM_ERROR = 5;
|
|
109
|
+
const LZMA_MEMLIMIT_ERROR = 6;
|
|
110
|
+
const LZMA_FORMAT_ERROR = 7;
|
|
111
|
+
const LZMA_OPTIONS_ERROR = 8;
|
|
112
|
+
const LZMA_DATA_ERROR = 9;
|
|
113
|
+
const LZMA_BUF_ERROR = 10;
|
|
114
|
+
const LZMA_PROG_ERROR = 11;
|
|
115
|
+
switch (errno) {
|
|
116
|
+
case LZMA_MEM_ERROR: return new LZMAMemoryError(errno);
|
|
117
|
+
case LZMA_MEMLIMIT_ERROR: return new LZMAMemoryLimitError(errno);
|
|
118
|
+
case LZMA_FORMAT_ERROR: return new LZMAFormatError(errno);
|
|
119
|
+
case LZMA_OPTIONS_ERROR: return new LZMAOptionsError(errno);
|
|
120
|
+
case LZMA_DATA_ERROR: return new LZMADataError(errno);
|
|
121
|
+
case LZMA_BUF_ERROR: return new LZMABufferError(errno);
|
|
122
|
+
case LZMA_PROG_ERROR: return new LZMAProgrammingError(errno);
|
|
123
|
+
default: return new LZMAError(message || getErrorMessage(errno), errno);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Get error message for a given errno
|
|
128
|
+
*/
|
|
129
|
+
function getErrorMessage(errno) {
|
|
130
|
+
const messages = [
|
|
131
|
+
"Operation completed successfully",
|
|
132
|
+
"End of stream was reached",
|
|
133
|
+
"Input stream has no integrity check",
|
|
134
|
+
"Cannot calculate the integrity check",
|
|
135
|
+
"Integrity check type is not available",
|
|
136
|
+
"Cannot allocate memory",
|
|
137
|
+
"Memory usage limit was reached",
|
|
138
|
+
"File format not recognized",
|
|
139
|
+
"Invalid or unsupported options",
|
|
140
|
+
"Data is corrupt",
|
|
141
|
+
"No progress is possible",
|
|
142
|
+
"Programming error"
|
|
143
|
+
];
|
|
144
|
+
if (errno < 0 || errno >= messages.length) return `Unknown LZMA error code: ${errno}`;
|
|
145
|
+
return messages[errno];
|
|
146
|
+
}
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region ../../node_modules/.pnpm/node-liblzma@2.2.0/node_modules/node-liblzma/lib/pool.js
|
|
149
|
+
/**
|
|
150
|
+
* node-liblzma - Node.js bindings for liblzma
|
|
151
|
+
* Copyright (C) Olivier Orabona <olivier.orabona@gmail.com>
|
|
152
|
+
*
|
|
153
|
+
* This program is free software: you can redistribute it and/or modify
|
|
154
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
155
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
156
|
+
* (at your option) any later version.
|
|
157
|
+
*
|
|
158
|
+
* This program is distributed in the hope that it will be useful,
|
|
159
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
160
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
161
|
+
* GNU General Public License for more details.
|
|
162
|
+
*
|
|
163
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
164
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
165
|
+
*/
|
|
166
|
+
/**
|
|
167
|
+
* LZMA Pool with concurrency control and event monitoring
|
|
168
|
+
*
|
|
169
|
+
* Provides rate limiting and backpressure for LZMA operations.
|
|
170
|
+
* Emits events for monitoring and metrics collection in production.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```typescript
|
|
174
|
+
* const pool = new LZMAPool(10); // Max 10 concurrent operations
|
|
175
|
+
*
|
|
176
|
+
* pool.on('metrics', (metrics) => {
|
|
177
|
+
* console.log(`Active: ${metrics.active}, Queued: ${metrics.queued}`);
|
|
178
|
+
* });
|
|
179
|
+
*
|
|
180
|
+
* const compressed = await pool.compress(buffer);
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* Events:
|
|
184
|
+
* - 'queue': Emitted when task added to queue
|
|
185
|
+
* - 'start': Emitted when task starts processing
|
|
186
|
+
* - 'complete': Emitted when task completes successfully
|
|
187
|
+
* - 'error-task': Emitted when task fails
|
|
188
|
+
* - 'metrics': Emitted after each state change with current metrics
|
|
189
|
+
*/
|
|
190
|
+
var LZMAPool = class extends EventEmitter {
|
|
191
|
+
/**
|
|
192
|
+
* Create a new LZMA pool
|
|
193
|
+
* @param maxConcurrent Maximum number of concurrent operations (default: 10)
|
|
194
|
+
*/
|
|
195
|
+
constructor(maxConcurrent = 10) {
|
|
196
|
+
super();
|
|
197
|
+
this.maxConcurrent = maxConcurrent;
|
|
198
|
+
this.queue = [];
|
|
199
|
+
this.metrics = {
|
|
200
|
+
active: 0,
|
|
201
|
+
queued: 0,
|
|
202
|
+
completed: 0,
|
|
203
|
+
failed: 0
|
|
204
|
+
};
|
|
205
|
+
if (maxConcurrent < 1) throw new RangeError("maxConcurrent must be at least 1");
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Compress data with automatic queue management
|
|
209
|
+
* @param data Buffer to compress
|
|
210
|
+
* @param opts LZMA compression options
|
|
211
|
+
* @returns Promise that resolves to compressed buffer
|
|
212
|
+
*/
|
|
213
|
+
async compress(data, opts) {
|
|
214
|
+
return this.enqueue(() => xzAsync(data, opts));
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Decompress data with automatic queue management
|
|
218
|
+
* @param data Compressed buffer to decompress
|
|
219
|
+
* @param opts LZMA decompression options
|
|
220
|
+
* @returns Promise that resolves to decompressed buffer
|
|
221
|
+
*/
|
|
222
|
+
async decompress(data, opts) {
|
|
223
|
+
return this.enqueue(() => unxzAsync(data, opts));
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Get current pool metrics
|
|
227
|
+
* @returns Copy of current metrics
|
|
228
|
+
*/
|
|
229
|
+
getMetrics() {
|
|
230
|
+
return { ...this.metrics };
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Get number of tasks waiting in queue
|
|
234
|
+
* @returns Queue length
|
|
235
|
+
*/
|
|
236
|
+
get queueLength() {
|
|
237
|
+
return this.queue.length;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Get number of currently active tasks
|
|
241
|
+
* @returns Active task count
|
|
242
|
+
*/
|
|
243
|
+
get activeCount() {
|
|
244
|
+
return this.metrics.active;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Check if pool is at maximum capacity
|
|
248
|
+
* @returns True if at capacity
|
|
249
|
+
*/
|
|
250
|
+
get isAtCapacity() {
|
|
251
|
+
return this.metrics.active >= this.maxConcurrent;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Enqueue a task for execution
|
|
255
|
+
* @param fn Task function returning Promise<Buffer>
|
|
256
|
+
* @returns Promise that resolves when task completes
|
|
257
|
+
*/
|
|
258
|
+
async enqueue(fn) {
|
|
259
|
+
return new Promise((resolve, reject) => {
|
|
260
|
+
this.queue.push({
|
|
261
|
+
fn,
|
|
262
|
+
resolve,
|
|
263
|
+
reject
|
|
264
|
+
});
|
|
265
|
+
this.metrics.queued = this.queue.length;
|
|
266
|
+
this.emit("queue", { ...this.metrics });
|
|
267
|
+
this.processQueue();
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Process tasks from queue respecting concurrency limit
|
|
272
|
+
*/
|
|
273
|
+
processQueue() {
|
|
274
|
+
if (this.metrics.active >= this.maxConcurrent || this.queue.length === 0) return;
|
|
275
|
+
const item = this.queue.shift();
|
|
276
|
+
/* c8 ignore next - should never happen because we check queue length before */
|
|
277
|
+
if (!item) return;
|
|
278
|
+
this.metrics.active++;
|
|
279
|
+
this.metrics.queued = this.queue.length;
|
|
280
|
+
this.emit("start", { ...this.metrics });
|
|
281
|
+
Promise.resolve().then(() => item.fn()).then((result) => {
|
|
282
|
+
this.metrics.completed++;
|
|
283
|
+
item.resolve(result);
|
|
284
|
+
this.emit("complete", { ...this.metrics });
|
|
285
|
+
}).catch((error) => {
|
|
286
|
+
this.metrics.failed++;
|
|
287
|
+
item.reject(error);
|
|
288
|
+
this.emit("error-task", error, { ...this.metrics });
|
|
289
|
+
}).finally(() => {
|
|
290
|
+
this.metrics.active--;
|
|
291
|
+
this.emit("metrics", { ...this.metrics });
|
|
292
|
+
this.processQueue();
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Wait for all active tasks to complete
|
|
297
|
+
* Does not process new tasks added while waiting
|
|
298
|
+
* @returns Promise that resolves when all active tasks are done
|
|
299
|
+
*/
|
|
300
|
+
async drain() {
|
|
301
|
+
if (this.metrics.active === 0) return Promise.resolve();
|
|
302
|
+
return new Promise((resolve) => {
|
|
303
|
+
const checkDrained = () => {
|
|
304
|
+
if (this.metrics.active === 0) {
|
|
305
|
+
this.off("metrics", checkDrained);
|
|
306
|
+
resolve();
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
this.on("metrics", checkDrained);
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Clear all pending tasks from the queue
|
|
314
|
+
* Active tasks will continue to run
|
|
315
|
+
* @returns Number of tasks removed from queue
|
|
316
|
+
*/
|
|
317
|
+
clearQueue() {
|
|
318
|
+
const cleared = this.queue.length;
|
|
319
|
+
const error = /* @__PURE__ */ new Error("Task cancelled: queue cleared");
|
|
320
|
+
for (const task of this.queue) task.reject(error);
|
|
321
|
+
this.queue = [];
|
|
322
|
+
this.metrics.queued = 0;
|
|
323
|
+
this.emit("metrics", { ...this.metrics });
|
|
324
|
+
return cleared;
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
//#endregion
|
|
328
|
+
//#region ../../node_modules/.pnpm/node-liblzma@2.2.0/node_modules/node-liblzma/lib/lzma.js
|
|
329
|
+
/**
|
|
330
|
+
* node-liblzma - Node.js bindings for liblzma
|
|
331
|
+
* Copyright (C) Olivier Orabona <olivier.orabona@gmail.com>
|
|
332
|
+
*
|
|
333
|
+
* This program is free software: you can redistribute it and/or modify
|
|
334
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
335
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
336
|
+
* (at your option) any later version.
|
|
337
|
+
*
|
|
338
|
+
* This program is distributed in the hope that it will be useful,
|
|
339
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
340
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
341
|
+
* GNU General Public License for more details.
|
|
342
|
+
*
|
|
343
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
344
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
345
|
+
*/
|
|
346
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
347
|
+
const __dirname = path.dirname(__filename);
|
|
348
|
+
const require = createRequire(import.meta.url);
|
|
349
|
+
const bindingPath = path.resolve(path.join(__dirname, ".."));
|
|
350
|
+
const liblzma = require("node-gyp-build")(bindingPath);
|
|
351
|
+
const maxThreads = os.cpus().length;
|
|
352
|
+
/**
|
|
353
|
+
* Integrity check types for XZ streams.
|
|
354
|
+
* Use CRC64 for best balance of speed and error detection.
|
|
355
|
+
* @example
|
|
356
|
+
* ```ts
|
|
357
|
+
* const compressor = createXz({ check: check.CRC64 });
|
|
358
|
+
* ```
|
|
359
|
+
*/
|
|
360
|
+
const check = {
|
|
361
|
+
NONE: liblzma.LZMA_CHECK_NONE,
|
|
362
|
+
CRC32: liblzma.LZMA_CHECK_CRC32,
|
|
363
|
+
CRC64: liblzma.LZMA_CHECK_CRC64,
|
|
364
|
+
SHA256: liblzma.LZMA_CHECK_SHA256
|
|
365
|
+
};
|
|
366
|
+
/**
|
|
367
|
+
* Compression preset flags.
|
|
368
|
+
* Can be combined with preset level using bitwise OR.
|
|
369
|
+
* @example
|
|
370
|
+
* ```ts
|
|
371
|
+
* const compressor = createXz({ preset: 6 | preset.EXTREME });
|
|
372
|
+
* ```
|
|
373
|
+
*/
|
|
374
|
+
const preset = {
|
|
375
|
+
/** Default compression level (6) */
|
|
376
|
+
DEFAULT: liblzma.LZMA_PRESET_DEFAULT,
|
|
377
|
+
/** Extreme mode flag - slower but better compression */
|
|
378
|
+
EXTREME: liblzma.LZMA_PRESET_EXTREME
|
|
379
|
+
};
|
|
380
|
+
/**
|
|
381
|
+
* Decoder flags for controlling decompression behavior.
|
|
382
|
+
* @example
|
|
383
|
+
* ```ts
|
|
384
|
+
* const decompressor = createUnxz({ flushFlag: flag.CONCATENATED });
|
|
385
|
+
* ```
|
|
386
|
+
*/
|
|
387
|
+
const flag = {
|
|
388
|
+
/** Tell decoder if input has no integrity check */
|
|
389
|
+
TELL_NO_CHECK: liblzma.LZMA_TELL_NO_CHECK,
|
|
390
|
+
/** Tell decoder if integrity check is unsupported */
|
|
391
|
+
TELL_UNSUPPORTED_CHECK: liblzma.LZMA_TELL_UNSUPPORTED_CHECK,
|
|
392
|
+
/** Tell decoder about any integrity check type */
|
|
393
|
+
TELL_ANY_CHECK: liblzma.LZMA_TELL_ANY_CHECK,
|
|
394
|
+
/** Allow concatenated XZ streams */
|
|
395
|
+
CONCATENATED: liblzma.LZMA_CONCATENATED
|
|
396
|
+
};
|
|
397
|
+
/**
|
|
398
|
+
* Compression filters for preprocessing data before LZMA2.
|
|
399
|
+
* BCJ filters improve compression for executable code.
|
|
400
|
+
* @example
|
|
401
|
+
* ```ts
|
|
402
|
+
* // Compress x86 executable with BCJ filter
|
|
403
|
+
* const compressor = createXz({ filters: [filter.X86, filter.LZMA2] });
|
|
404
|
+
* ```
|
|
405
|
+
*/
|
|
406
|
+
const filter = {
|
|
407
|
+
/** LZMA2 compression filter (required, must be last) */
|
|
408
|
+
LZMA2: liblzma.LZMA_FILTER_LZMA2,
|
|
409
|
+
/** BCJ filter for x86 executables */
|
|
410
|
+
X86: liblzma.LZMA_FILTER_X86,
|
|
411
|
+
/** BCJ filter for PowerPC executables */
|
|
412
|
+
POWERPC: liblzma.LZMA_FILTER_POWERPC,
|
|
413
|
+
/** BCJ filter for IA-64 executables */
|
|
414
|
+
IA64: liblzma.LZMA_FILTER_IA64,
|
|
415
|
+
/** BCJ filter for ARM executables */
|
|
416
|
+
ARM: liblzma.LZMA_FILTER_ARM,
|
|
417
|
+
/** BCJ filter for ARM-Thumb executables */
|
|
418
|
+
ARMTHUMB: liblzma.LZMA_FILTER_ARMTHUMB,
|
|
419
|
+
/** BCJ filter for SPARC executables */
|
|
420
|
+
SPARC: liblzma.LZMA_FILTER_SPARC
|
|
421
|
+
};
|
|
422
|
+
/* v8 ignore next */
|
|
423
|
+
/**
|
|
424
|
+
* Compression mode selection.
|
|
425
|
+
* FAST uses less memory, NORMAL provides better compression.
|
|
426
|
+
*/
|
|
427
|
+
const mode = {
|
|
428
|
+
/** Fast compression mode - less memory, faster */
|
|
429
|
+
FAST: liblzma.LZMA_MODE_FAST,
|
|
430
|
+
/** Normal compression mode - better ratio */
|
|
431
|
+
NORMAL: liblzma.LZMA_MODE_NORMAL
|
|
432
|
+
};
|
|
433
|
+
/* v8 ignore next 2 */
|
|
434
|
+
/**
|
|
435
|
+
* LZMA stream action constants.
|
|
436
|
+
* Control how the encoder/decoder processes input.
|
|
437
|
+
*/
|
|
438
|
+
const LZMAAction = {
|
|
439
|
+
/** Normal processing - continue encoding/decoding */
|
|
440
|
+
RUN: liblzma.LZMA_RUN,
|
|
441
|
+
/** Flush pending output synchronously */
|
|
442
|
+
SYNC_FLUSH: liblzma.LZMA_SYNC_FLUSH,
|
|
443
|
+
/** Flush and reset encoder state */
|
|
444
|
+
FULL_FLUSH: liblzma.LZMA_FULL_FLUSH,
|
|
445
|
+
/** Finish the stream - no more input */
|
|
446
|
+
FINISH: liblzma.LZMA_FINISH
|
|
447
|
+
};
|
|
448
|
+
/* v8 ignore next 2 */
|
|
449
|
+
/**
|
|
450
|
+
* LZMA operation status/return codes.
|
|
451
|
+
* Used to indicate the result of encoding/decoding operations.
|
|
452
|
+
*/
|
|
453
|
+
const LZMAStatus = {
|
|
454
|
+
OK: liblzma.LZMA_OK,
|
|
455
|
+
STREAM_END: liblzma.LZMA_STREAM_END,
|
|
456
|
+
NO_CHECK: liblzma.LZMA_NO_CHECK,
|
|
457
|
+
UNSUPPORTED_CHECK: liblzma.LZMA_UNSUPPORTED_CHECK,
|
|
458
|
+
GET_CHECK: liblzma.LZMA_GET_CHECK,
|
|
459
|
+
MEM_ERROR: liblzma.LZMA_MEM_ERROR,
|
|
460
|
+
MEMLIMIT_ERROR: liblzma.LZMA_MEMLIMIT_ERROR,
|
|
461
|
+
FORMAT_ERROR: liblzma.LZMA_FORMAT_ERROR,
|
|
462
|
+
OPTIONS_ERROR: liblzma.LZMA_OPTIONS_ERROR,
|
|
463
|
+
DATA_ERROR: liblzma.LZMA_DATA_ERROR,
|
|
464
|
+
BUF_ERROR: liblzma.LZMA_BUF_ERROR,
|
|
465
|
+
PROG_ERROR: liblzma.LZMA_PROG_ERROR
|
|
466
|
+
};
|
|
467
|
+
const LZMAFilter = {
|
|
468
|
+
...filter,
|
|
469
|
+
X86_ALT: liblzma.LZMA_FILTER_X86,
|
|
470
|
+
POWERPC_ALT: liblzma.LZMA_FILTER_POWERPC,
|
|
471
|
+
IA64_ALT: liblzma.LZMA_FILTER_IA64,
|
|
472
|
+
ARM_ALT: liblzma.LZMA_FILTER_ARM,
|
|
473
|
+
ARMTHUMB_ALT: liblzma.LZMA_FILTER_ARMTHUMB,
|
|
474
|
+
FILTERS_MAX: liblzma.LZMA_FILTERS_MAX
|
|
475
|
+
};
|
|
476
|
+
const LZMA_RUN = LZMAAction.RUN;
|
|
477
|
+
const LZMA_SYNC_FLUSH = LZMAAction.SYNC_FLUSH;
|
|
478
|
+
const LZMA_FULL_FLUSH = LZMAAction.FULL_FLUSH;
|
|
479
|
+
const LZMA_FINISH = LZMAAction.FINISH;
|
|
480
|
+
const LZMA_OK = LZMAStatus.OK;
|
|
481
|
+
const LZMA_STREAM_END = LZMAStatus.STREAM_END;
|
|
482
|
+
const LZMA_NO_CHECK = LZMAStatus.NO_CHECK;
|
|
483
|
+
const LZMA_UNSUPPORTED_CHECK = LZMAStatus.UNSUPPORTED_CHECK;
|
|
484
|
+
const LZMA_GET_CHECK = LZMAStatus.GET_CHECK;
|
|
485
|
+
const LZMA_MEM_ERROR = LZMAStatus.MEM_ERROR;
|
|
486
|
+
const LZMA_MEMLIMIT_ERROR = LZMAStatus.MEMLIMIT_ERROR;
|
|
487
|
+
const LZMA_FORMAT_ERROR = LZMAStatus.FORMAT_ERROR;
|
|
488
|
+
const LZMA_OPTIONS_ERROR = LZMAStatus.OPTIONS_ERROR;
|
|
489
|
+
const LZMA_DATA_ERROR = LZMAStatus.DATA_ERROR;
|
|
490
|
+
const LZMA_BUF_ERROR = LZMAStatus.BUF_ERROR;
|
|
491
|
+
const LZMA_PROG_ERROR = LZMAStatus.PROG_ERROR;
|
|
492
|
+
const LZMA_FILTER_X86 = LZMAFilter.X86_ALT;
|
|
493
|
+
const LZMA_FILTER_POWERPC = LZMAFilter.POWERPC_ALT;
|
|
494
|
+
const LZMA_FILTER_IA64 = LZMAFilter.IA64_ALT;
|
|
495
|
+
const LZMA_FILTER_ARM = LZMAFilter.ARM_ALT;
|
|
496
|
+
const LZMA_FILTER_ARMTHUMB = LZMAFilter.ARMTHUMB_ALT;
|
|
497
|
+
const LZMA_FILTERS_MAX = LZMAFilter.FILTERS_MAX;
|
|
498
|
+
/**
|
|
499
|
+
* Abstract base class for XZ compression/decompression streams.
|
|
500
|
+
* Extends Node.js Transform stream with LZMA2 encoding/decoding.
|
|
501
|
+
*
|
|
502
|
+
* @example
|
|
503
|
+
* ```ts
|
|
504
|
+
* // Use Xz or Unxz classes instead of XzStream directly
|
|
505
|
+
* const compressor = new Xz({ preset: 6 });
|
|
506
|
+
* readStream.pipe(compressor).pipe(writeStream);
|
|
507
|
+
* ```
|
|
508
|
+
*
|
|
509
|
+
* Emits `progress` event after each chunk with `{bytesRead, bytesWritten}` info.
|
|
510
|
+
*/
|
|
511
|
+
var XzStream = class extends Transform {
|
|
512
|
+
constructor(streamMode, opts = {}, options) {
|
|
513
|
+
super(options);
|
|
514
|
+
let clonedFilters;
|
|
515
|
+
if (opts.filters) {
|
|
516
|
+
if (!Array.isArray(opts.filters)) throw new Error("Filters need to be in an array!");
|
|
517
|
+
try {
|
|
518
|
+
clonedFilters = [...opts.filters];
|
|
519
|
+
} catch (_error) {
|
|
520
|
+
throw new Error("Filters need to be in an array!");
|
|
521
|
+
}
|
|
522
|
+
} else clonedFilters = [filter.LZMA2];
|
|
523
|
+
this._opts = {
|
|
524
|
+
check: opts.check ?? check.NONE,
|
|
525
|
+
preset: opts.preset ?? preset.DEFAULT,
|
|
526
|
+
filters: clonedFilters,
|
|
527
|
+
mode: opts.mode ?? mode.NORMAL,
|
|
528
|
+
threads: opts.threads ?? 1,
|
|
529
|
+
chunkSize: opts.chunkSize ?? liblzma.BUFSIZ,
|
|
530
|
+
flushFlag: opts.flushFlag ?? liblzma.LZMA_RUN
|
|
531
|
+
};
|
|
532
|
+
this._chunkSize = this._opts.chunkSize;
|
|
533
|
+
this._flushFlag = this._opts.flushFlag;
|
|
534
|
+
assert.ok(Array.isArray(this._opts.filters), "Filters need to be in an array!");
|
|
535
|
+
/* v8 ignore next 2 */
|
|
536
|
+
if (this._opts.filters.indexOf(filter.LZMA2) === -1) this._opts.filters.push(filter.LZMA2);
|
|
537
|
+
const lzma2Index = this._opts.filters.indexOf(filter.LZMA2);
|
|
538
|
+
if (lzma2Index !== -1 && lzma2Index !== this._opts.filters.length - 1) {
|
|
539
|
+
this._opts.filters.splice(lzma2Index, 1);
|
|
540
|
+
this._opts.filters.push(filter.LZMA2);
|
|
541
|
+
}
|
|
542
|
+
if (streamMode === liblzma.STREAM_ENCODE) {
|
|
543
|
+
/* c8 ignore start */
|
|
544
|
+
if (!liblzma.HAS_THREADS_SUPPORT) this._opts.threads = 1;
|
|
545
|
+
/* c8 ignore stop */
|
|
546
|
+
if (this._opts.threads === 0) this._opts.threads = maxThreads;
|
|
547
|
+
}
|
|
548
|
+
this.lzma = new liblzma.LZMA(streamMode, this._opts);
|
|
549
|
+
this._closed = false;
|
|
550
|
+
this._hadError = false;
|
|
551
|
+
this._offset = 0;
|
|
552
|
+
this._buffer = Buffer.alloc(this._chunkSize);
|
|
553
|
+
this._bytesRead = 0;
|
|
554
|
+
this._bytesWritten = 0;
|
|
555
|
+
/* v8 ignore next */
|
|
556
|
+
this.on("onerror", (errno) => {
|
|
557
|
+
this._hadError = true;
|
|
558
|
+
const error = this._createLZMAError(errno);
|
|
559
|
+
this.emit("error", error);
|
|
560
|
+
});
|
|
561
|
+
/* v8 ignore next */
|
|
562
|
+
this.once("end", () => this.close());
|
|
563
|
+
}
|
|
564
|
+
_createLZMAError(errno) {
|
|
565
|
+
return createLZMAError(errno);
|
|
566
|
+
}
|
|
567
|
+
/** Get total bytes read from input so far */
|
|
568
|
+
get bytesRead() {
|
|
569
|
+
return this._bytesRead;
|
|
570
|
+
}
|
|
571
|
+
/** Get total bytes written to output so far */
|
|
572
|
+
get bytesWritten() {
|
|
573
|
+
return this._bytesWritten;
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Emit a progress event with current bytesRead and bytesWritten
|
|
577
|
+
*/
|
|
578
|
+
_emitProgress() {
|
|
579
|
+
const info = {
|
|
580
|
+
bytesRead: this._bytesRead,
|
|
581
|
+
bytesWritten: this._bytesWritten
|
|
582
|
+
};
|
|
583
|
+
this.emit("progress", info);
|
|
584
|
+
}
|
|
585
|
+
_reallocateBuffer() {
|
|
586
|
+
this._offset = 0;
|
|
587
|
+
this._buffer = Buffer.alloc(this._chunkSize);
|
|
588
|
+
}
|
|
589
|
+
flush(kindOrCallback, callback) {
|
|
590
|
+
const ws = this._writableState;
|
|
591
|
+
let kind;
|
|
592
|
+
let cb;
|
|
593
|
+
/* v8 ignore next */
|
|
594
|
+
if (typeof kindOrCallback === "function" || typeof kindOrCallback === "undefined" && !callback) {
|
|
595
|
+
cb = kindOrCallback;
|
|
596
|
+
kind = liblzma.LZMA_SYNC_FLUSH;
|
|
597
|
+
} else {
|
|
598
|
+
kind = kindOrCallback;
|
|
599
|
+
cb = callback;
|
|
600
|
+
}
|
|
601
|
+
if (ws.ended) {
|
|
602
|
+
if (cb) process.nextTick(cb);
|
|
603
|
+
} else if (ws.ending) {
|
|
604
|
+
if (cb) this.once("end", cb);
|
|
605
|
+
} else if (ws.needDrain) this.once("drain", () => {
|
|
606
|
+
this.flush(cb);
|
|
607
|
+
});
|
|
608
|
+
else {
|
|
609
|
+
this._flushFlag = kind;
|
|
610
|
+
this.write(Buffer.alloc(0), "utf8", cb);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
close(callback) {
|
|
614
|
+
if (callback) process.nextTick(callback);
|
|
615
|
+
if (this._closed) return;
|
|
616
|
+
/* v8 ignore next */
|
|
617
|
+
this.lzma.close();
|
|
618
|
+
this._closed = true;
|
|
619
|
+
/* v8 ignore next */
|
|
620
|
+
process.nextTick(() => {
|
|
621
|
+
this.emit("close");
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
/* v8 ignore next */
|
|
625
|
+
_transform(chunk, _encoding, callback) {
|
|
626
|
+
const ws = this._writableState;
|
|
627
|
+
const last = (ws.ending || ws.ended) && (!chunk || ws.length === chunk.length);
|
|
628
|
+
if (chunk !== null && !(chunk instanceof Buffer)) {
|
|
629
|
+
callback(/* @__PURE__ */ new Error("invalid input"));
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
if (this._closed) {
|
|
633
|
+
callback(/* @__PURE__ */ new Error("lzma binding closed"));
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
if (chunk) this._bytesRead += chunk.length;
|
|
637
|
+
/* v8 ignore next */
|
|
638
|
+
let flushFlag;
|
|
639
|
+
if (last) flushFlag = liblzma.LZMA_FINISH;
|
|
640
|
+
else {
|
|
641
|
+
flushFlag = this._flushFlag;
|
|
642
|
+
if (chunk && chunk.length >= ws.length) this._flushFlag = this._opts.flushFlag;
|
|
643
|
+
}
|
|
644
|
+
/* v8 ignore next */
|
|
645
|
+
this._processChunk(chunk, flushFlag, callback);
|
|
646
|
+
}
|
|
647
|
+
_flush(callback) {
|
|
648
|
+
/* v8 ignore next 4 - Defensive check for double close scenario */
|
|
649
|
+
if (this._closed) {
|
|
650
|
+
process.nextTick(() => callback());
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
this._transform(Buffer.alloc(0), "utf8", callback);
|
|
654
|
+
}
|
|
655
|
+
_processChunk(chunk, flushFlag, cb) {
|
|
656
|
+
const async = typeof cb === "function";
|
|
657
|
+
assert.ok(!this._closed, "Stream closed!");
|
|
658
|
+
let availInBefore = chunk?.length;
|
|
659
|
+
let availOutBefore = this._chunkSize - this._offset;
|
|
660
|
+
let inOff = 0;
|
|
661
|
+
/* v8 ignore next 3 */
|
|
662
|
+
if (!async) {
|
|
663
|
+
const buffers = [];
|
|
664
|
+
let nread = 0;
|
|
665
|
+
let error = null;
|
|
666
|
+
/* v8 ignore next */
|
|
667
|
+
const callback = (errno, availInAfter, availOutAfter) => {
|
|
668
|
+
/* v8 ignore start */
|
|
669
|
+
if (this._hadError) return false;
|
|
670
|
+
if (errno !== liblzma.LZMA_OK && errno !== liblzma.LZMA_STREAM_END) {
|
|
671
|
+
this.emit("onerror", errno);
|
|
672
|
+
return false;
|
|
673
|
+
}
|
|
674
|
+
/* v8 ignore stop */
|
|
675
|
+
const used = availOutBefore - availOutAfter;
|
|
676
|
+
assert.ok(used >= 0, `More bytes after than before! Delta = ${used}`);
|
|
677
|
+
if (used > 0) {
|
|
678
|
+
const out = this._buffer.subarray(this._offset, this._offset + used);
|
|
679
|
+
this._offset += used;
|
|
680
|
+
buffers.push(out);
|
|
681
|
+
nread += used;
|
|
682
|
+
}
|
|
683
|
+
/* v8 ignore start */
|
|
684
|
+
if (availOutAfter === 0 || this._offset >= this._chunkSize) {
|
|
685
|
+
availOutBefore = this._chunkSize;
|
|
686
|
+
this._reallocateBuffer();
|
|
687
|
+
}
|
|
688
|
+
if (availOutAfter === 0 || availInAfter > 0) {
|
|
689
|
+
inOff += (availInBefore ?? 0) - availInAfter;
|
|
690
|
+
availInBefore = availInAfter;
|
|
691
|
+
return true;
|
|
692
|
+
}
|
|
693
|
+
/* v8 ignore stop */
|
|
694
|
+
return false;
|
|
695
|
+
};
|
|
696
|
+
/* v8 ignore start */
|
|
697
|
+
this.on("error", (e) => {
|
|
698
|
+
error = e;
|
|
699
|
+
});
|
|
700
|
+
/* v8 ignore stop */
|
|
701
|
+
/* v8 ignore next - processing loop entry */
|
|
702
|
+
while (true) {
|
|
703
|
+
const [status, availInAfter, availOutAfter] = this.lzma.codeSync(flushFlag, chunk, inOff, availInBefore, this._buffer, this._offset);
|
|
704
|
+
/* v8 ignore start */
|
|
705
|
+
if (this._hadError || !callback(status, availInAfter, availOutAfter)) break;
|
|
706
|
+
}
|
|
707
|
+
try {
|
|
708
|
+
/* v8 ignore start */
|
|
709
|
+
if (this._hadError) throw error ?? /* @__PURE__ */ new Error("Unknown LZMA error");
|
|
710
|
+
return Buffer.concat(buffers, nread);
|
|
711
|
+
} finally {
|
|
712
|
+
/* v8 ignore next - cleanup path */
|
|
713
|
+
this.close();
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
const callback = (errno, availInAfter, availOutAfter) => {
|
|
717
|
+
/* v8 ignore next 3 - error state handling is difficult to test */
|
|
718
|
+
if (this._hadError) return false;
|
|
719
|
+
/* v8 ignore next 5 - async error path handling */
|
|
720
|
+
if (errno !== liblzma.LZMA_OK && errno !== liblzma.LZMA_STREAM_END) {
|
|
721
|
+
this.emit("onerror", errno);
|
|
722
|
+
return false;
|
|
723
|
+
}
|
|
724
|
+
/* v8 ignore next */
|
|
725
|
+
const used = availOutBefore - availOutAfter;
|
|
726
|
+
assert.ok(used >= 0, `More bytes after than before! Delta = ${used}`);
|
|
727
|
+
if (used > 0) {
|
|
728
|
+
const out = this._buffer.subarray(this._offset, this._offset + used);
|
|
729
|
+
this._offset += used;
|
|
730
|
+
this._bytesWritten += used;
|
|
731
|
+
this.push(out);
|
|
732
|
+
this._emitProgress();
|
|
733
|
+
}
|
|
734
|
+
if (availOutAfter === 0 || this._offset >= this._chunkSize) {
|
|
735
|
+
availOutBefore = this._chunkSize;
|
|
736
|
+
this._reallocateBuffer();
|
|
737
|
+
}
|
|
738
|
+
if (availOutAfter === 0 || availInAfter > 0) {
|
|
739
|
+
/* v8 ignore next 2 - complex async processing continuation */
|
|
740
|
+
inOff += (availInBefore ?? 0) - availInAfter;
|
|
741
|
+
availInBefore = availInAfter;
|
|
742
|
+
this.lzma.code(flushFlag, chunk, inOff, availInBefore, this._buffer, this._offset, callback);
|
|
743
|
+
return false;
|
|
744
|
+
}
|
|
745
|
+
if (cb && !this._closed) try {
|
|
746
|
+
cb();
|
|
747
|
+
} catch (_error) {
|
|
748
|
+
this.emit("onerror", liblzma.LZMA_PROG_ERROR);
|
|
749
|
+
}
|
|
750
|
+
return false;
|
|
751
|
+
};
|
|
752
|
+
this.lzma.code(flushFlag, chunk, inOff, availInBefore, this._buffer, this._offset, callback);
|
|
753
|
+
}
|
|
754
|
+
};
|
|
755
|
+
/**
|
|
756
|
+
* XZ compression stream.
|
|
757
|
+
* Compresses data using LZMA2 algorithm.
|
|
758
|
+
*
|
|
759
|
+
* @example
|
|
760
|
+
* ```ts
|
|
761
|
+
* const compressor = new Xz({ preset: 6 });
|
|
762
|
+
* input.pipe(compressor).pipe(output);
|
|
763
|
+
* ```
|
|
764
|
+
*/
|
|
765
|
+
var Xz = class extends XzStream {
|
|
766
|
+
constructor(lzmaOptions, options) {
|
|
767
|
+
super(liblzma.STREAM_ENCODE, lzmaOptions, options);
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
/**
|
|
771
|
+
* XZ decompression stream.
|
|
772
|
+
* Decompresses data compressed with XZ/LZMA2.
|
|
773
|
+
*
|
|
774
|
+
* @example
|
|
775
|
+
* ```ts
|
|
776
|
+
* const decompressor = new Unxz();
|
|
777
|
+
* compressedInput.pipe(decompressor).pipe(output);
|
|
778
|
+
* ```
|
|
779
|
+
*/
|
|
780
|
+
var Unxz = class extends XzStream {
|
|
781
|
+
constructor(lzmaOptions, options) {
|
|
782
|
+
super(liblzma.STREAM_DECODE, lzmaOptions, options);
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
/* v8 ignore next */
|
|
786
|
+
/**
|
|
787
|
+
* Create a new XZ compression stream.
|
|
788
|
+
* @param lzmaOptions - LZMA compression options
|
|
789
|
+
* @param options - Node.js Transform stream options
|
|
790
|
+
* @returns New Xz compression stream
|
|
791
|
+
*
|
|
792
|
+
* @example
|
|
793
|
+
* ```ts
|
|
794
|
+
* const compressor = createXz({ preset: 9 });
|
|
795
|
+
* ```
|
|
796
|
+
*/
|
|
797
|
+
function createXz(lzmaOptions, options) {
|
|
798
|
+
return new Xz(lzmaOptions, options);
|
|
799
|
+
}
|
|
800
|
+
/* v8 ignore next */
|
|
801
|
+
/**
|
|
802
|
+
* Create a new XZ decompression stream.
|
|
803
|
+
* @param lzmaOptions - LZMA decompression options
|
|
804
|
+
* @param options - Node.js Transform stream options
|
|
805
|
+
* @returns New Unxz decompression stream
|
|
806
|
+
*
|
|
807
|
+
* @example
|
|
808
|
+
* ```ts
|
|
809
|
+
* const decompressor = createUnxz();
|
|
810
|
+
* ```
|
|
811
|
+
*/
|
|
812
|
+
function createUnxz(lzmaOptions, options) {
|
|
813
|
+
return new Unxz(lzmaOptions, options);
|
|
814
|
+
}
|
|
815
|
+
/* v8 ignore next */
|
|
816
|
+
/**
|
|
817
|
+
* Check if liblzma was built with threading support.
|
|
818
|
+
* @returns true if multi-threaded compression is available
|
|
819
|
+
*/
|
|
820
|
+
function hasThreads() {
|
|
821
|
+
return liblzma.HAS_THREADS_SUPPORT;
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* Check if a buffer contains XZ compressed data by examining magic bytes.
|
|
825
|
+
* @param buffer - Buffer to check (needs at least 6 bytes)
|
|
826
|
+
* @returns true if the buffer starts with XZ magic bytes
|
|
827
|
+
* @example
|
|
828
|
+
* ```ts
|
|
829
|
+
* const compressed = await xzAsync(Buffer.from('Hello'));
|
|
830
|
+
* console.log(isXZ(compressed)); // true
|
|
831
|
+
* console.log(isXZ(Buffer.from('Hello'))); // false
|
|
832
|
+
* ```
|
|
833
|
+
*/
|
|
834
|
+
function isXZ(buffer) {
|
|
835
|
+
return liblzma.isXZ(buffer);
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Get the runtime version of liblzma as a string.
|
|
839
|
+
* @returns Version string like "5.4.1"
|
|
840
|
+
* @example
|
|
841
|
+
* ```ts
|
|
842
|
+
* console.log(versionString()); // "5.4.1"
|
|
843
|
+
* ```
|
|
844
|
+
*/
|
|
845
|
+
function versionString() {
|
|
846
|
+
return liblzma.versionString();
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Get the runtime version of liblzma as a number.
|
|
850
|
+
* Format: MAJOR * 10000000 + MINOR * 10000 + PATCH * 10
|
|
851
|
+
* @returns Version number (e.g., 50040010 for 5.4.1)
|
|
852
|
+
* @example
|
|
853
|
+
* ```ts
|
|
854
|
+
* console.log(versionNumber()); // 50040010
|
|
855
|
+
* ```
|
|
856
|
+
*/
|
|
857
|
+
function versionNumber() {
|
|
858
|
+
return liblzma.versionNumber();
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* Get the memory usage estimate for encoding with a given preset.
|
|
862
|
+
* @param presetLevel - Compression preset (0-9, optionally OR'd with preset.EXTREME)
|
|
863
|
+
* @returns Memory usage in bytes, or 0 if preset is invalid
|
|
864
|
+
* @example
|
|
865
|
+
* ```ts
|
|
866
|
+
* console.log(easyEncoderMemusage(6)); // ~104857600 (100 MB)
|
|
867
|
+
* console.log(easyEncoderMemusage(9 | preset.EXTREME)); // ~712507392 (680 MB)
|
|
868
|
+
* ```
|
|
869
|
+
*/
|
|
870
|
+
function easyEncoderMemusage(presetLevel) {
|
|
871
|
+
return liblzma.easyEncoderMemusage(presetLevel);
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Get the memory usage estimate for decoding.
|
|
875
|
+
* @returns Memory usage in bytes for decoder initialization
|
|
876
|
+
* @example
|
|
877
|
+
* ```ts
|
|
878
|
+
* console.log(easyDecoderMemusage()); // ~18874368 (18 MB)
|
|
879
|
+
* ```
|
|
880
|
+
*/
|
|
881
|
+
function easyDecoderMemusage() {
|
|
882
|
+
return liblzma.easyDecoderMemusage();
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Parse the index from a complete XZ file buffer to get metadata.
|
|
886
|
+
* This allows you to know the uncompressed size before decompressing.
|
|
887
|
+
* @param buffer - Complete XZ file buffer
|
|
888
|
+
* @returns Object with file metadata
|
|
889
|
+
* @throws Error if buffer is not a valid XZ stream
|
|
890
|
+
* @example
|
|
891
|
+
* ```ts
|
|
892
|
+
* const compressed = await xzAsync(largeBuffer);
|
|
893
|
+
* const info = parseFileIndex(compressed);
|
|
894
|
+
* console.log(`Uncompressed: ${info.uncompressedSize}, Compressed: ${info.compressedSize}`);
|
|
895
|
+
* console.log(`Ratio: ${(info.compressedSize / info.uncompressedSize * 100).toFixed(1)}%`);
|
|
896
|
+
* ```
|
|
897
|
+
*/
|
|
898
|
+
function parseFileIndex(buffer) {
|
|
899
|
+
return liblzma.parseFileIndex(buffer);
|
|
900
|
+
}
|
|
901
|
+
/* v8 ignore next */
|
|
902
|
+
/**
|
|
903
|
+
* Human-readable error messages for LZMA status codes.
|
|
904
|
+
*/
|
|
905
|
+
var LZMAErrorMessage;
|
|
906
|
+
(function(LZMAErrorMessage) {
|
|
907
|
+
LZMAErrorMessage["SUCCESS"] = "Operation completed successfully";
|
|
908
|
+
LZMAErrorMessage["STREAM_END"] = "End of stream was reached";
|
|
909
|
+
LZMAErrorMessage["NO_CHECK"] = "Input stream has no integrity check";
|
|
910
|
+
LZMAErrorMessage["UNSUPPORTED_CHECK"] = "Cannot calculate the integrity check";
|
|
911
|
+
LZMAErrorMessage["GET_CHECK"] = "Integrity check type is not available";
|
|
912
|
+
LZMAErrorMessage["MEM_ERROR"] = "Cannot allocate memory";
|
|
913
|
+
LZMAErrorMessage["MEMLIMIT_ERROR"] = "Memory usage limit was reached";
|
|
914
|
+
LZMAErrorMessage["FORMAT_ERROR"] = "File format not recognized";
|
|
915
|
+
LZMAErrorMessage["OPTIONS_ERROR"] = "Invalid or unsupported options";
|
|
916
|
+
LZMAErrorMessage["DATA_ERROR"] = "Data is corrupt";
|
|
917
|
+
LZMAErrorMessage["BUF_ERROR"] = "No progress is possible";
|
|
918
|
+
LZMAErrorMessage["PROG_ERROR"] = "Programming error";
|
|
919
|
+
})(LZMAErrorMessage || (LZMAErrorMessage = {}));
|
|
920
|
+
/**
|
|
921
|
+
* Array of error messages indexed by LZMA status code.
|
|
922
|
+
* @deprecated Use LZMAErrorMessage enum instead
|
|
923
|
+
*/
|
|
924
|
+
const messages = [
|
|
925
|
+
LZMAErrorMessage.SUCCESS,
|
|
926
|
+
LZMAErrorMessage.STREAM_END,
|
|
927
|
+
LZMAErrorMessage.NO_CHECK,
|
|
928
|
+
LZMAErrorMessage.UNSUPPORTED_CHECK,
|
|
929
|
+
LZMAErrorMessage.GET_CHECK,
|
|
930
|
+
LZMAErrorMessage.MEM_ERROR,
|
|
931
|
+
LZMAErrorMessage.MEMLIMIT_ERROR,
|
|
932
|
+
LZMAErrorMessage.FORMAT_ERROR,
|
|
933
|
+
LZMAErrorMessage.OPTIONS_ERROR,
|
|
934
|
+
LZMAErrorMessage.DATA_ERROR,
|
|
935
|
+
LZMAErrorMessage.BUF_ERROR,
|
|
936
|
+
LZMAErrorMessage.PROG_ERROR
|
|
937
|
+
];
|
|
938
|
+
function unxz(buffer, optsOrCallback, callback) {
|
|
939
|
+
let opts;
|
|
940
|
+
let cb;
|
|
941
|
+
/* v8 ignore next - simple parameter parsing */
|
|
942
|
+
if (typeof optsOrCallback === "function") {
|
|
943
|
+
cb = optsOrCallback;
|
|
944
|
+
opts = {};
|
|
945
|
+
} else {
|
|
946
|
+
opts = optsOrCallback;
|
|
947
|
+
cb = callback;
|
|
948
|
+
}
|
|
949
|
+
xzBuffer(new Unxz(opts), buffer, cb);
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Decompress a buffer synchronously.
|
|
953
|
+
* @param buffer - Compressed data to decompress
|
|
954
|
+
* @param opts - LZMA decompression options
|
|
955
|
+
* @returns Decompressed data buffer
|
|
956
|
+
*
|
|
957
|
+
* @example
|
|
958
|
+
* ```ts
|
|
959
|
+
* const decompressed = unxzSync(compressedBuffer);
|
|
960
|
+
* ```
|
|
961
|
+
*/
|
|
962
|
+
function unxzSync(buffer, opts) {
|
|
963
|
+
return xzBufferSync(new Unxz(opts), buffer);
|
|
964
|
+
}
|
|
965
|
+
function xz(buffer, optsOrCallback, callback) {
|
|
966
|
+
let opts;
|
|
967
|
+
let cb;
|
|
968
|
+
/* v8 ignore next - simple parameter parsing */
|
|
969
|
+
if (typeof optsOrCallback === "function") {
|
|
970
|
+
cb = optsOrCallback;
|
|
971
|
+
opts = {};
|
|
972
|
+
} else {
|
|
973
|
+
opts = optsOrCallback;
|
|
974
|
+
cb = callback;
|
|
975
|
+
}
|
|
976
|
+
xzBuffer(new Xz(opts), buffer, cb);
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* Compress a buffer synchronously.
|
|
980
|
+
* @param buffer - Data to compress
|
|
981
|
+
* @param opts - LZMA compression options
|
|
982
|
+
* @returns Compressed data buffer
|
|
983
|
+
*
|
|
984
|
+
* @example
|
|
985
|
+
* ```ts
|
|
986
|
+
* const compressed = xzSync(data, { preset: 9 });
|
|
987
|
+
* ```
|
|
988
|
+
*/
|
|
989
|
+
function xzSync(buffer, opts) {
|
|
990
|
+
return xzBufferSync(new Xz(opts), buffer);
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Compress a buffer asynchronously using Promise.
|
|
994
|
+
* @param buffer - Data to compress
|
|
995
|
+
* @param opts - LZMA compression options
|
|
996
|
+
* @returns Promise resolving to compressed data buffer
|
|
997
|
+
*
|
|
998
|
+
* @example
|
|
999
|
+
* ```ts
|
|
1000
|
+
* const compressed = await xzAsync(data, { preset: 6 });
|
|
1001
|
+
* ```
|
|
1002
|
+
*/
|
|
1003
|
+
function xzAsync(buffer, opts) {
|
|
1004
|
+
return new Promise((resolve, reject) => {
|
|
1005
|
+
xz(buffer, opts || {}, (error, result) => {
|
|
1006
|
+
/* v8 ignore next 3 - error handling is tested in callback-based tests */
|
|
1007
|
+
if (error) reject(error);
|
|
1008
|
+
else resolve(result);
|
|
1009
|
+
});
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Decompress a buffer asynchronously using Promise.
|
|
1014
|
+
* @param buffer - Compressed data to decompress
|
|
1015
|
+
* @param opts - LZMA decompression options
|
|
1016
|
+
* @returns Promise resolving to decompressed data buffer
|
|
1017
|
+
*
|
|
1018
|
+
* @example
|
|
1019
|
+
* ```ts
|
|
1020
|
+
* const decompressed = await unxzAsync(compressedBuffer);
|
|
1021
|
+
* console.log(decompressed.toString());
|
|
1022
|
+
* ```
|
|
1023
|
+
*/
|
|
1024
|
+
function unxzAsync(buffer, opts) {
|
|
1025
|
+
return new Promise((resolve, reject) => {
|
|
1026
|
+
unxz(buffer, opts || {}, (error, result) => {
|
|
1027
|
+
/* v8 ignore next 2 - error handling is tested in callback-based tests */
|
|
1028
|
+
if (error) reject(error);
|
|
1029
|
+
else resolve(result);
|
|
1030
|
+
});
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
function xzBuffer(engine, buffer, callback) {
|
|
1034
|
+
const buffers = [];
|
|
1035
|
+
let nread = 0;
|
|
1036
|
+
const flow = () => {
|
|
1037
|
+
let chunk;
|
|
1038
|
+
while ((chunk = engine.read()) !== null) {
|
|
1039
|
+
buffers.push(chunk);
|
|
1040
|
+
nread += chunk.length;
|
|
1041
|
+
}
|
|
1042
|
+
engine.once("readable", flow);
|
|
1043
|
+
};
|
|
1044
|
+
const onEnd = () => {
|
|
1045
|
+
callback(null, Buffer.concat(buffers, nread));
|
|
1046
|
+
engine.close();
|
|
1047
|
+
};
|
|
1048
|
+
/* v8 ignore next 5 - error callback path */
|
|
1049
|
+
const onError = (err) => {
|
|
1050
|
+
engine.removeListener("end", onEnd);
|
|
1051
|
+
engine.removeListener("readable", flow);
|
|
1052
|
+
callback(err);
|
|
1053
|
+
};
|
|
1054
|
+
engine.on("error", onError);
|
|
1055
|
+
engine.on("end", onEnd);
|
|
1056
|
+
engine.end(buffer);
|
|
1057
|
+
flow();
|
|
1058
|
+
}
|
|
1059
|
+
function xzBufferSync(engine, buffer) {
|
|
1060
|
+
let buf;
|
|
1061
|
+
if (typeof buffer === "string") buf = Buffer.from(buffer);
|
|
1062
|
+
else if (buffer instanceof Buffer) buf = buffer;
|
|
1063
|
+
else throw new TypeError("Not a string or buffer");
|
|
1064
|
+
return engine._processChunk(buf, liblzma.LZMA_FINISH);
|
|
1065
|
+
}
|
|
1066
|
+
/**
|
|
1067
|
+
* Compress a file using XZ compression
|
|
1068
|
+
* @param inputPath Path to input file
|
|
1069
|
+
* @param outputPath Path to output compressed file
|
|
1070
|
+
* @param opts LZMA compression options
|
|
1071
|
+
* @returns Promise that resolves when compression is complete
|
|
1072
|
+
*/
|
|
1073
|
+
async function xzFile(inputPath, outputPath, opts) {
|
|
1074
|
+
const input = createReadStream(inputPath);
|
|
1075
|
+
const output = createWriteStream(outputPath);
|
|
1076
|
+
await pipeline(input, createXz(opts), output);
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Decompress an XZ compressed file
|
|
1080
|
+
* @param inputPath Path to compressed input file
|
|
1081
|
+
* @param outputPath Path to output decompressed file
|
|
1082
|
+
* @param opts LZMA decompression options
|
|
1083
|
+
* @returns Promise that resolves when decompression is complete
|
|
1084
|
+
*/
|
|
1085
|
+
async function unxzFile(inputPath, outputPath, opts) {
|
|
1086
|
+
const input = createReadStream(inputPath);
|
|
1087
|
+
const output = createWriteStream(outputPath);
|
|
1088
|
+
await pipeline(input, createUnxz(opts), output);
|
|
1089
|
+
}
|
|
1090
|
+
var lzma_default = {
|
|
1091
|
+
Xz,
|
|
1092
|
+
Unxz,
|
|
1093
|
+
XzStream,
|
|
1094
|
+
hasThreads,
|
|
1095
|
+
messages,
|
|
1096
|
+
check,
|
|
1097
|
+
preset,
|
|
1098
|
+
flag,
|
|
1099
|
+
filter,
|
|
1100
|
+
mode,
|
|
1101
|
+
createXz,
|
|
1102
|
+
createUnxz,
|
|
1103
|
+
unxz,
|
|
1104
|
+
unxzSync,
|
|
1105
|
+
xz,
|
|
1106
|
+
xzSync,
|
|
1107
|
+
xzAsync,
|
|
1108
|
+
unxzAsync,
|
|
1109
|
+
LZMA_RUN,
|
|
1110
|
+
LZMA_SYNC_FLUSH,
|
|
1111
|
+
LZMA_FULL_FLUSH,
|
|
1112
|
+
LZMA_FINISH,
|
|
1113
|
+
LZMA_OK,
|
|
1114
|
+
LZMA_STREAM_END,
|
|
1115
|
+
LZMA_NO_CHECK,
|
|
1116
|
+
LZMA_UNSUPPORTED_CHECK,
|
|
1117
|
+
LZMA_GET_CHECK,
|
|
1118
|
+
LZMA_MEM_ERROR,
|
|
1119
|
+
LZMA_MEMLIMIT_ERROR,
|
|
1120
|
+
LZMA_FORMAT_ERROR,
|
|
1121
|
+
LZMA_OPTIONS_ERROR,
|
|
1122
|
+
LZMA_DATA_ERROR,
|
|
1123
|
+
LZMA_BUF_ERROR,
|
|
1124
|
+
LZMA_PROG_ERROR,
|
|
1125
|
+
LZMA_FILTER_X86,
|
|
1126
|
+
LZMA_FILTER_POWERPC,
|
|
1127
|
+
LZMA_FILTER_IA64,
|
|
1128
|
+
LZMA_FILTER_ARM,
|
|
1129
|
+
LZMA_FILTER_ARMTHUMB,
|
|
1130
|
+
LZMA_FILTERS_MAX
|
|
1131
|
+
};
|
|
1132
|
+
//#endregion
|
|
1133
|
+
export { LZMAAction, LZMABufferError, LZMADataError, LZMAError, LZMAErrorMessage, LZMAFilter, LZMAFormatError, LZMAMemoryError, LZMAMemoryLimitError, LZMAOptionsError, LZMAPool, LZMAProgrammingError, LZMAStatus, LZMA_BUF_ERROR, LZMA_DATA_ERROR, LZMA_FILTERS_MAX, LZMA_FILTER_ARM, LZMA_FILTER_ARMTHUMB, LZMA_FILTER_IA64, LZMA_FILTER_POWERPC, LZMA_FILTER_X86, LZMA_FINISH, LZMA_FORMAT_ERROR, LZMA_FULL_FLUSH, LZMA_GET_CHECK, LZMA_MEMLIMIT_ERROR, LZMA_MEM_ERROR, LZMA_NO_CHECK, LZMA_OK, LZMA_OPTIONS_ERROR, LZMA_PROG_ERROR, LZMA_RUN, LZMA_STREAM_END, LZMA_SYNC_FLUSH, LZMA_UNSUPPORTED_CHECK, Unxz, Xz, XzStream, check, createUnxz, createXz, lzma_default as default, easyDecoderMemusage, easyEncoderMemusage, filter, flag, hasThreads, isXZ, messages, mode, parseFileIndex, preset, unxz, unxzAsync, unxzFile, unxzSync, versionNumber, versionString, xz, xzAsync, xzFile, xzSync };
|
|
1134
|
+
|
|
1135
|
+
//# sourceMappingURL=lzma-CTMDi254.mjs.map
|