7zip-native 0.0.8 → 0.0.12
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 +46 -14
- package/bench/compare.mts +25 -11
- package/bench/folder-concurrency.mts +5 -12
- package/bench/multiprocess-extract.cjs +334 -0
- package/dist/index.cjs +215 -110
- 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 +217 -112
- package/native/addon.cpp +1399 -71
- package/package.json +4 -2
- 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/Alloc.o +0 -0
- package/vendor/7zip/CPP/7zip/Bundles/Format7zF/_o/DeflateDecoder.o +0 -0
- package/vendor/7zip/CPP/7zip/Compress/DeflateDecoder.cpp +15 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "7zip-native",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "Native 7zip bindings for Node.js",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"type": "module",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"dist/",
|
|
31
31
|
"prebuilds/",
|
|
32
32
|
"native/",
|
|
33
|
+
"patches/",
|
|
33
34
|
"scripts/",
|
|
34
35
|
"vendor/7zip/",
|
|
35
36
|
"binding.gyp",
|
|
@@ -59,7 +60,8 @@
|
|
|
59
60
|
"benchmark": "node --experimental-strip-types bench/benchmark.mts",
|
|
60
61
|
"benchmark:concurrency": "node --experimental-strip-types bench/concurrency.mts",
|
|
61
62
|
"benchmark:folder-concurrency": "node --experimental-strip-types bench/folder-concurrency.mts",
|
|
62
|
-
"benchmark:compare": "node --experimental-strip-types bench/compare.mts"
|
|
63
|
+
"benchmark:compare": "node --experimental-strip-types bench/compare.mts",
|
|
64
|
+
"benchmark:multiprocess": "node bench/multiprocess-extract.cjs"
|
|
63
65
|
},
|
|
64
66
|
"keywords": [
|
|
65
67
|
"7zip",
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
diff --git a/CPP/7zip/Archive/Archive2.def b/CPP/7zip/Archive/Archive2.def
|
|
2
|
+
index 5abe81d..b96cb34 100644
|
|
3
|
+
--- a/CPP/7zip/Archive/Archive2.def
|
|
4
|
+
+++ b/CPP/7zip/Archive/Archive2.def
|
|
5
|
+
@@ -3,6 +3,7 @@ EXPORTS
|
|
6
|
+
GetHandlerProperty PRIVATE
|
|
7
|
+
GetNumberOfFormats PRIVATE
|
|
8
|
+
GetHandlerProperty2 PRIVATE
|
|
9
|
+
GetIsArc PRIVATE
|
|
10
|
+
+ SetDeflateInputBufferSize PRIVATE
|
|
11
|
+
|
|
12
|
+
GetNumberOfMethods PRIVATE
|
|
13
|
+
GetMethodProperty PRIVATE
|
|
14
|
+
diff --git a/CPP/7zip/Compress/DeflateDecoder.cpp b/CPP/7zip/Compress/DeflateDecoder.cpp
|
|
15
|
+
index 7993176..5f3d9d4 100644
|
|
16
|
+
--- a/CPP/7zip/Compress/DeflateDecoder.cpp
|
|
17
|
+
+++ b/CPP/7zip/Compress/DeflateDecoder.cpp
|
|
18
|
+
@@ -3,6 +3,20 @@
|
|
19
|
+
|
|
20
|
+
#include "DeflateDecoder.h"
|
|
21
|
+
|
|
22
|
+
+namespace {
|
|
23
|
+
+
|
|
24
|
+
+thread_local UInt32 g_deflateInputBufferSize = 1 << 15;
|
|
25
|
+
+
|
|
26
|
+
+}
|
|
27
|
+
+
|
|
28
|
+
+STDAPI SetDeflateInputBufferSize(UInt32 bufferSize)
|
|
29
|
+
+{
|
|
30
|
+
+ if (bufferSize < (1 << 12) || bufferSize > (1 << 21))
|
|
31
|
+
+ return E_INVALIDARG;
|
|
32
|
+
+ g_deflateInputBufferSize = bufferSize;
|
|
33
|
+
+ return S_OK;
|
|
34
|
+
+}
|
|
35
|
+
+
|
|
36
|
+
namespace NCompress {
|
|
37
|
+
namespace NDeflate {
|
|
38
|
+
namespace NDecoder {
|
|
39
|
+
@@ -153,7 +167,7 @@ HRESULT CCoder::InitInStream(bool needInit)
|
|
40
|
+
// for HDD-Windows:
|
|
41
|
+
// (1 << 15) - best for reading only prefetch
|
|
42
|
+
// (1 << 22) - best for real reading / writing
|
|
43
|
+
- if (!m_InBitStream.Create(1 << 20))
|
|
44
|
+
+ if (!m_InBitStream.Create(g_deflateInputBufferSize))
|
|
45
|
+
return E_OUTOFMEMORY;
|
|
46
|
+
m_InBitStream.Init();
|
|
47
|
+
_needInitInStream = false;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/scripts/build-native.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {spawn} from 'node:child_process';
|
|
2
|
-
import { copyFile, mkdir, rm } from 'node:fs/promises';
|
|
2
|
+
import { copyFile, mkdir, readFile, rm } from 'node:fs/promises';
|
|
3
3
|
import {createRequire} from 'node:module';
|
|
4
4
|
import {availableParallelism} from 'node:os';
|
|
5
5
|
import { join, resolve } from 'node:path';
|
|
6
6
|
import {fileURLToPath} from 'node:url';
|
|
7
7
|
|
|
8
8
|
const root = resolve(fileURLToPath(new URL('..', import.meta.url)));
|
|
9
|
+
const upstreamDirectory = join(root, 'vendor', '7zip');
|
|
9
10
|
const bundleDirectory = join(root, 'vendor', '7zip', 'CPP', '7zip', 'Bundles', 'Format7zF');
|
|
10
11
|
const releaseDirectory = join(root, 'build', 'Release');
|
|
11
12
|
const targetArch = process.env.BUILD_ARCH || process.arch;
|
|
@@ -14,6 +15,9 @@ const engineName = process.platform === 'win32'
|
|
|
14
15
|
? '7z.dll'
|
|
15
16
|
: process.platform === 'darwin' ? 'lib7z.dylib' : '7z.so';
|
|
16
17
|
const require = createRequire(import.meta.url);
|
|
18
|
+
const patchPath = join(root, 'patches', 'deflate-input-buffer-size.patch');
|
|
19
|
+
const deflateSourcePath = join(upstreamDirectory, 'CPP', '7zip', 'Compress', 'DeflateDecoder.cpp');
|
|
20
|
+
const archiveExportsPath = join(upstreamDirectory, 'CPP', '7zip', 'Archive', 'Archive2.def');
|
|
17
21
|
|
|
18
22
|
function run(command, args, cwd, env = process.env)
|
|
19
23
|
{
|
|
@@ -33,6 +37,21 @@ function run(command, args, cwd, env = process.env)
|
|
|
33
37
|
});
|
|
34
38
|
}
|
|
35
39
|
|
|
40
|
+
const deflateSource = await readFile(deflateSourcePath, 'utf8');
|
|
41
|
+
const archiveExports = await readFile(archiveExportsPath, 'utf8');
|
|
42
|
+
if(deflateSource.includes('SetDeflateInputBufferSize'))
|
|
43
|
+
{
|
|
44
|
+
if(!archiveExports.includes('SetDeflateInputBufferSize'))
|
|
45
|
+
{
|
|
46
|
+
throw new Error('The Deflate buffer patch is only partially applied; restore vendor/7zip and rebuild');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else
|
|
50
|
+
{
|
|
51
|
+
await run('git', ['-C', upstreamDirectory, 'apply', '--check', patchPath], root);
|
|
52
|
+
await run('git', ['-C', upstreamDirectory, 'apply', patchPath], root);
|
|
53
|
+
}
|
|
54
|
+
|
|
36
55
|
if(process.platform === 'win32')
|
|
37
56
|
{
|
|
38
57
|
const upstreamArch = targetArch === 'ia32' ? 'x86' : targetArch;
|
|
@@ -46,6 +65,8 @@ else
|
|
|
46
65
|
'-f',
|
|
47
66
|
'makefile.gcc',
|
|
48
67
|
`-j${process.env.BUILD_JOBS ?? Math.min(availableParallelism(), 2)}`,
|
|
68
|
+
// Avoid 2 MiB aligned allocations that Electron's allocator traps on.
|
|
69
|
+
'CFLAGS_BASE2=-DZ7_NO_MADVISE',
|
|
49
70
|
];
|
|
50
71
|
const buildEnv = {...process.env};
|
|
51
72
|
if(targetArch === 'ia32')
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -4,6 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
#include "DeflateDecoder.h"
|
|
6
6
|
|
|
7
|
+
namespace {
|
|
8
|
+
|
|
9
|
+
thread_local UInt32 g_deflateInputBufferSize = 1 << 15;
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
STDAPI SetDeflateInputBufferSize(UInt32 bufferSize)
|
|
14
|
+
{
|
|
15
|
+
if (bufferSize < (1 << 12) || bufferSize > (1 << 21))
|
|
16
|
+
return E_INVALIDARG;
|
|
17
|
+
g_deflateInputBufferSize = bufferSize;
|
|
18
|
+
return S_OK;
|
|
19
|
+
}
|
|
20
|
+
|
|
7
21
|
namespace NCompress {
|
|
8
22
|
namespace NDeflate {
|
|
9
23
|
namespace NDecoder {
|
|
@@ -153,7 +167,7 @@ HRESULT CCoder::InitInStream(bool needInit)
|
|
|
153
167
|
// for HDD-Windows:
|
|
154
168
|
// (1 << 15) - best for reading only prefetch
|
|
155
169
|
// (1 << 22) - best for real reading / writing
|
|
156
|
-
if (!m_InBitStream.Create(
|
|
170
|
+
if (!m_InBitStream.Create(g_deflateInputBufferSize))
|
|
157
171
|
return E_OUTOFMEMORY;
|
|
158
172
|
m_InBitStream.Init();
|
|
159
173
|
_needInitInStream = false;
|