@rushstack/zipsync 0.2.13 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +41 -0
- package/CHANGELOG.md +13 -1
- package/bin/zipsync +1 -1
- package/lib-esm/cli/ZipSyncCommandLineParser.js +93 -0
- package/lib-esm/cli/ZipSyncCommandLineParser.js.map +1 -0
- package/lib-esm/compress.js +115 -0
- package/lib-esm/compress.js.map +1 -0
- package/lib-esm/crc32.js +32 -0
- package/lib-esm/crc32.js.map +1 -0
- package/lib-esm/fs.js +48 -0
- package/lib-esm/fs.js.map +1 -0
- package/lib-esm/hash.js +39 -0
- package/lib-esm/hash.js.map +1 -0
- package/lib-esm/index.js +5 -0
- package/lib-esm/index.js.map +1 -0
- package/lib-esm/pack.js +379 -0
- package/lib-esm/pack.js.map +1 -0
- package/lib-esm/packWorker.js +58 -0
- package/lib-esm/packWorker.js.map +1 -0
- package/lib-esm/packWorkerAsync.js +43 -0
- package/lib-esm/packWorkerAsync.js.map +1 -0
- package/lib-esm/perf.js +49 -0
- package/lib-esm/perf.js.map +1 -0
- package/lib-esm/start.js +17 -0
- package/lib-esm/start.js.map +1 -0
- package/lib-esm/unpack.js +334 -0
- package/lib-esm/unpack.js.map +1 -0
- package/lib-esm/unpackWorker.js +54 -0
- package/lib-esm/unpackWorker.js.map +1 -0
- package/lib-esm/unpackWorkerAsync.js +43 -0
- package/lib-esm/unpackWorkerAsync.js.map +1 -0
- package/lib-esm/zipSyncUtils.js +6 -0
- package/lib-esm/zipSyncUtils.js.map +1 -0
- package/lib-esm/zipUtils.js +292 -0
- package/lib-esm/zipUtils.js.map +1 -0
- package/package.json +33 -6
- /package/{lib → lib-commonjs}/cli/ZipSyncCommandLineParser.js +0 -0
- /package/{lib → lib-commonjs}/cli/ZipSyncCommandLineParser.js.map +0 -0
- /package/{lib → lib-commonjs}/compress.js +0 -0
- /package/{lib → lib-commonjs}/compress.js.map +0 -0
- /package/{lib → lib-commonjs}/crc32.js +0 -0
- /package/{lib → lib-commonjs}/crc32.js.map +0 -0
- /package/{lib → lib-commonjs}/fs.js +0 -0
- /package/{lib → lib-commonjs}/fs.js.map +0 -0
- /package/{lib → lib-commonjs}/hash.js +0 -0
- /package/{lib → lib-commonjs}/hash.js.map +0 -0
- /package/{lib → lib-commonjs}/index.js +0 -0
- /package/{lib → lib-commonjs}/index.js.map +0 -0
- /package/{lib → lib-commonjs}/pack.js +0 -0
- /package/{lib → lib-commonjs}/pack.js.map +0 -0
- /package/{lib → lib-commonjs}/packWorker.js +0 -0
- /package/{lib → lib-commonjs}/packWorker.js.map +0 -0
- /package/{lib → lib-commonjs}/packWorkerAsync.js +0 -0
- /package/{lib → lib-commonjs}/packWorkerAsync.js.map +0 -0
- /package/{lib → lib-commonjs}/perf.js +0 -0
- /package/{lib → lib-commonjs}/perf.js.map +0 -0
- /package/{lib → lib-commonjs}/start.js +0 -0
- /package/{lib → lib-commonjs}/start.js.map +0 -0
- /package/{lib → lib-commonjs}/unpack.js +0 -0
- /package/{lib → lib-commonjs}/unpack.js.map +0 -0
- /package/{lib → lib-commonjs}/unpackWorker.js +0 -0
- /package/{lib → lib-commonjs}/unpackWorker.js.map +0 -0
- /package/{lib → lib-commonjs}/unpackWorkerAsync.js +0 -0
- /package/{lib → lib-commonjs}/unpackWorkerAsync.js.map +0 -0
- /package/{lib → lib-commonjs}/zipSyncUtils.js +0 -0
- /package/{lib → lib-commonjs}/zipSyncUtils.js.map +0 -0
- /package/{lib → lib-commonjs}/zipUtils.js +0 -0
- /package/{lib → lib-commonjs}/zipUtils.js.map +0 -0
- /package/{lib → lib-dts}/cli/ZipSyncCommandLineParser.d.ts +0 -0
- /package/{lib → lib-dts}/cli/ZipSyncCommandLineParser.d.ts.map +0 -0
- /package/{lib → lib-dts}/compress.d.ts +0 -0
- /package/{lib → lib-dts}/compress.d.ts.map +0 -0
- /package/{lib → lib-dts}/crc32.d.ts +0 -0
- /package/{lib → lib-dts}/crc32.d.ts.map +0 -0
- /package/{lib → lib-dts}/fs.d.ts +0 -0
- /package/{lib → lib-dts}/fs.d.ts.map +0 -0
- /package/{lib → lib-dts}/hash.d.ts +0 -0
- /package/{lib → lib-dts}/hash.d.ts.map +0 -0
- /package/{lib → lib-dts}/index.d.ts +0 -0
- /package/{lib → lib-dts}/index.d.ts.map +0 -0
- /package/{lib → lib-dts}/pack.d.ts +0 -0
- /package/{lib → lib-dts}/pack.d.ts.map +0 -0
- /package/{lib → lib-dts}/packWorker.d.ts +0 -0
- /package/{lib → lib-dts}/packWorker.d.ts.map +0 -0
- /package/{lib → lib-dts}/packWorkerAsync.d.ts +0 -0
- /package/{lib → lib-dts}/packWorkerAsync.d.ts.map +0 -0
- /package/{lib → lib-dts}/perf.d.ts +0 -0
- /package/{lib → lib-dts}/perf.d.ts.map +0 -0
- /package/{lib → lib-dts}/start.d.ts +0 -0
- /package/{lib → lib-dts}/start.d.ts.map +0 -0
- /package/{lib → lib-dts}/unpack.d.ts +0 -0
- /package/{lib → lib-dts}/unpack.d.ts.map +0 -0
- /package/{lib → lib-dts}/unpackWorker.d.ts +0 -0
- /package/{lib → lib-dts}/unpackWorker.d.ts.map +0 -0
- /package/{lib → lib-dts}/unpackWorkerAsync.d.ts +0 -0
- /package/{lib → lib-dts}/unpackWorkerAsync.d.ts.map +0 -0
- /package/{lib → lib-dts}/zipSyncUtils.d.ts +0 -0
- /package/{lib → lib-dts}/zipSyncUtils.d.ts.map +0 -0
- /package/{lib → lib-dts}/zipUtils.d.ts +0 -0
- /package/{lib → lib-dts}/zipUtils.d.ts.map +0 -0
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/zipsync",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.3.0",
|
|
6
|
+
"tag": "@rushstack/zipsync_v0.3.0",
|
|
7
|
+
"date": "Thu, 19 Feb 2026 00:04:53 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Normalize package layout. CommonJS is now under `lib-commonjs`, DTS is now under `lib-dts`, and ESM is now under `lib-esm`. Imports to `lib` still work as before, handled by the `\"exports\"` field in `package.json`."
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"dependency": [
|
|
15
|
+
{
|
|
16
|
+
"comment": "Updating dependency \"@rushstack/terminal\" to `0.22.0`"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"comment": "Updating dependency \"@rushstack/ts-command-line\" to `5.3.0`"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"comment": "Updating dependency \"@rushstack/lookup-by-path\" to `0.9.0`"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"comment": "Updating dependency \"@rushstack/heft\" to `1.2.0`"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"version": "0.2.14",
|
|
32
|
+
"tag": "@rushstack/zipsync_v0.2.14",
|
|
33
|
+
"date": "Sat, 07 Feb 2026 01:13:26 GMT",
|
|
34
|
+
"comments": {
|
|
35
|
+
"dependency": [
|
|
36
|
+
{
|
|
37
|
+
"comment": "Updating dependency \"@rushstack/lookup-by-path\" to `0.8.16`"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"comment": "Updating dependency \"@rushstack/heft\" to `1.1.14`"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
},
|
|
4
45
|
{
|
|
5
46
|
"version": "0.2.13",
|
|
6
47
|
"tag": "@rushstack/zipsync_v0.2.13",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
# Change Log - @rushstack/zipsync
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 19 Feb 2026 00:04:53 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.3.0
|
|
6
|
+
Thu, 19 Feb 2026 00:04:53 GMT
|
|
7
|
+
|
|
8
|
+
### Minor changes
|
|
9
|
+
|
|
10
|
+
- Normalize package layout. CommonJS is now under `lib-commonjs`, DTS is now under `lib-dts`, and ESM is now under `lib-esm`. Imports to `lib` still work as before, handled by the `"exports"` field in `package.json`.
|
|
11
|
+
|
|
12
|
+
## 0.2.14
|
|
13
|
+
Sat, 07 Feb 2026 01:13:26 GMT
|
|
14
|
+
|
|
15
|
+
_Version update only_
|
|
4
16
|
|
|
5
17
|
## 0.2.13
|
|
6
18
|
Wed, 04 Feb 2026 20:42:47 GMT
|
package/bin/zipsync
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
require('../lib/start.js');
|
|
2
|
+
require('../lib-commonjs/start.js');
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import { CommandLineParser } from '@rushstack/ts-command-line/lib/providers/CommandLineParser';
|
|
4
|
+
import { pack, unpack } from '../index';
|
|
5
|
+
export class ZipSyncCommandLineParser extends CommandLineParser {
|
|
6
|
+
constructor(terminalProvider, terminal) {
|
|
7
|
+
super({
|
|
8
|
+
toolFilename: 'zipsync',
|
|
9
|
+
toolDescription: ''
|
|
10
|
+
});
|
|
11
|
+
this._terminal = terminal;
|
|
12
|
+
this._terminalProvider = terminalProvider;
|
|
13
|
+
this._debugParameter = this.defineFlagParameter({
|
|
14
|
+
parameterLongName: '--debug',
|
|
15
|
+
parameterShortName: '-d',
|
|
16
|
+
description: 'Show the full call stack if an error occurs while executing the tool'
|
|
17
|
+
});
|
|
18
|
+
this._verboseParameter = this.defineFlagParameter({
|
|
19
|
+
parameterLongName: '--verbose',
|
|
20
|
+
parameterShortName: '-v',
|
|
21
|
+
description: 'Show verbose output'
|
|
22
|
+
});
|
|
23
|
+
this._modeParameter = this.defineChoiceParameter({
|
|
24
|
+
parameterLongName: '--mode',
|
|
25
|
+
parameterShortName: '-m',
|
|
26
|
+
description: 'The mode of operation: "pack" to create a zip archive, or "unpack" to extract files from a zip archive',
|
|
27
|
+
alternatives: ['pack', 'unpack'],
|
|
28
|
+
required: true
|
|
29
|
+
});
|
|
30
|
+
this._archivePathParameter = this.defineStringParameter({
|
|
31
|
+
parameterLongName: '--archive-path',
|
|
32
|
+
parameterShortName: '-a',
|
|
33
|
+
description: 'Zip file path',
|
|
34
|
+
argumentName: 'ARCHIVE_PATH',
|
|
35
|
+
required: true
|
|
36
|
+
});
|
|
37
|
+
this._targetDirectoriesParameter = this.defineStringListParameter({
|
|
38
|
+
parameterLongName: '--target-directory',
|
|
39
|
+
parameterShortName: '-t',
|
|
40
|
+
description: 'Target directories to pack or unpack',
|
|
41
|
+
argumentName: 'TARGET_DIRECTORIES',
|
|
42
|
+
required: true
|
|
43
|
+
});
|
|
44
|
+
this._baseDirParameter = this.defineStringParameter({
|
|
45
|
+
parameterLongName: '--base-dir',
|
|
46
|
+
parameterShortName: '-b',
|
|
47
|
+
description: 'Base directory for relative paths within the archive',
|
|
48
|
+
argumentName: 'BASE_DIR',
|
|
49
|
+
required: true
|
|
50
|
+
});
|
|
51
|
+
this._compressionParameter = this.defineChoiceParameter({
|
|
52
|
+
parameterLongName: '--compression',
|
|
53
|
+
parameterShortName: '-z',
|
|
54
|
+
description: 'Compression strategy when packing. "deflate" and "zlib" attempts compression for every file (keeps only if smaller); "auto" first skips likely-compressed types before attempting "deflate" compression; "store" disables compression.',
|
|
55
|
+
alternatives: ['store', 'deflate', 'zstd', 'auto'],
|
|
56
|
+
required: true
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async onExecuteAsync() {
|
|
60
|
+
if (this._debugParameter.value) {
|
|
61
|
+
// eslint-disable-next-line no-debugger
|
|
62
|
+
debugger;
|
|
63
|
+
this._terminalProvider.debugEnabled = true;
|
|
64
|
+
this._terminalProvider.verboseEnabled = true;
|
|
65
|
+
}
|
|
66
|
+
if (this._verboseParameter.value) {
|
|
67
|
+
this._terminalProvider.verboseEnabled = true;
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
if (this._modeParameter.value === 'pack') {
|
|
71
|
+
pack({
|
|
72
|
+
terminal: this._terminal,
|
|
73
|
+
archivePath: this._archivePathParameter.value,
|
|
74
|
+
targetDirectories: this._targetDirectoriesParameter.values,
|
|
75
|
+
baseDir: this._baseDirParameter.value,
|
|
76
|
+
compression: this._compressionParameter.value
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
else if (this._modeParameter.value === 'unpack') {
|
|
80
|
+
unpack({
|
|
81
|
+
terminal: this._terminal,
|
|
82
|
+
archivePath: this._archivePathParameter.value,
|
|
83
|
+
targetDirectories: this._targetDirectoriesParameter.values,
|
|
84
|
+
baseDir: this._baseDirParameter.value
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
this._terminal.writeErrorLine('\n' + error.stack);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=ZipSyncCommandLineParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZipSyncCommandLineParser.js","sourceRoot":"","sources":["../../src/cli/ZipSyncCommandLineParser.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4DAA4D,CAAC;AAW/F,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,OAAO,wBAAyB,SAAQ,iBAAiB;IAW7D,YAAmB,gBAAyC,EAAE,QAAmB;QAC/E,KAAK,CAAC;YACJ,YAAY,EAAE,SAAS;YACvB,eAAe,EAAE,EAAE;SACpB,CAAC,CAA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iB,EAAE,IAAI,CAAC,2BAA2B,CAAC,MAAM;oBAC1D,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC,KAAK;iBACtC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { CommandLineParser } from '@rushstack/ts-command-line/lib/providers/CommandLineParser';\nimport type {\n CommandLineFlagParameter,\n IRequiredCommandLineStringParameter,\n IRequiredCommandLineChoiceParameter,\n CommandLineStringListParameter\n} from '@rushstack/ts-command-line/lib/index';\nimport type { ConsoleTerminalProvider } from '@rushstack/terminal/lib/ConsoleTerminalProvider';\nimport type { ITerminal } from '@rushstack/terminal/lib/ITerminal';\n\nimport type { IZipSyncMode, ZipSyncOptionCompression } from '../zipSyncUtils';\nimport { pack, unpack } from '../index';\n\nexport class ZipSyncCommandLineParser extends CommandLineParser {\n private readonly _debugParameter: CommandLineFlagParameter;\n private readonly _verboseParameter: CommandLineFlagParameter;\n private readonly _modeParameter: IRequiredCommandLineChoiceParameter<IZipSyncMode>;\n private readonly _archivePathParameter: IRequiredCommandLineStringParameter;\n private readonly _baseDirParameter: IRequiredCommandLineStringParameter;\n private readonly _targetDirectoriesParameter: CommandLineStringListParameter;\n private readonly _compressionParameter: IRequiredCommandLineChoiceParameter<ZipSyncOptionCompression>;\n private readonly _terminal: ITerminal;\n private readonly _terminalProvider: ConsoleTerminalProvider;\n\n public constructor(terminalProvider: ConsoleTerminalProvider, terminal: ITerminal) {\n super({\n toolFilename: 'zipsync',\n toolDescription: ''\n });\n\n this._terminal = terminal;\n this._terminalProvider = terminalProvider;\n\n this._debugParameter = this.defineFlagParameter({\n parameterLongName: '--debug',\n parameterShortName: '-d',\n description: 'Show the full call stack if an error occurs while executing the tool'\n });\n\n this._verboseParameter = this.defineFlagParameter({\n parameterLongName: '--verbose',\n parameterShortName: '-v',\n description: 'Show verbose output'\n });\n\n this._modeParameter = this.defineChoiceParameter<IZipSyncMode>({\n parameterLongName: '--mode',\n parameterShortName: '-m',\n description:\n 'The mode of operation: \"pack\" to create a zip archive, or \"unpack\" to extract files from a zip archive',\n alternatives: ['pack', 'unpack'],\n required: true\n });\n\n this._archivePathParameter = this.defineStringParameter({\n parameterLongName: '--archive-path',\n parameterShortName: '-a',\n description: 'Zip file path',\n argumentName: 'ARCHIVE_PATH',\n required: true\n });\n\n this._targetDirectoriesParameter = this.defineStringListParameter({\n parameterLongName: '--target-directory',\n parameterShortName: '-t',\n description: 'Target directories to pack or unpack',\n argumentName: 'TARGET_DIRECTORIES',\n required: true\n });\n\n this._baseDirParameter = this.defineStringParameter({\n parameterLongName: '--base-dir',\n parameterShortName: '-b',\n description: 'Base directory for relative paths within the archive',\n argumentName: 'BASE_DIR',\n required: true\n });\n\n this._compressionParameter = this.defineChoiceParameter<ZipSyncOptionCompression>({\n parameterLongName: '--compression',\n parameterShortName: '-z',\n description:\n 'Compression strategy when packing. \"deflate\" and \"zlib\" attempts compression for every file (keeps only if smaller); \"auto\" first skips likely-compressed types before attempting \"deflate\" compression; \"store\" disables compression.',\n alternatives: ['store', 'deflate', 'zstd', 'auto'],\n required: true\n });\n }\n\n protected override async onExecuteAsync(): Promise<void> {\n if (this._debugParameter.value) {\n // eslint-disable-next-line no-debugger\n debugger;\n this._terminalProvider.debugEnabled = true;\n this._terminalProvider.verboseEnabled = true;\n }\n if (this._verboseParameter.value) {\n this._terminalProvider.verboseEnabled = true;\n }\n try {\n if (this._modeParameter.value === 'pack') {\n pack({\n terminal: this._terminal,\n archivePath: this._archivePathParameter.value,\n targetDirectories: this._targetDirectoriesParameter.values,\n baseDir: this._baseDirParameter.value,\n compression: this._compressionParameter.value\n });\n } else if (this._modeParameter.value === 'unpack') {\n unpack({\n terminal: this._terminal,\n archivePath: this._archivePathParameter.value,\n targetDirectories: this._targetDirectoriesParameter.values,\n baseDir: this._baseDirParameter.value\n });\n }\n } catch (error) {\n this._terminal.writeErrorLine('\\n' + error.stack);\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import zlib from 'node:zlib';
|
|
4
|
+
const kError = (() => {
|
|
5
|
+
// Create an instance of Deflate so that we can get our hands on the internal error symbol
|
|
6
|
+
// It isn't exported.
|
|
7
|
+
const reference = zlib.createDeflateRaw();
|
|
8
|
+
const kErrorResult = Object.getOwnPropertySymbols(reference).find((x) => x.toString().includes('kError'));
|
|
9
|
+
if (kErrorResult === undefined) {
|
|
10
|
+
throw new Error('Unable to find the internal error symbol in node:zlib');
|
|
11
|
+
}
|
|
12
|
+
reference.close();
|
|
13
|
+
return kErrorResult;
|
|
14
|
+
// Casting `symbol` to the exact symbol of this definition
|
|
15
|
+
})();
|
|
16
|
+
export function createIncrementalZlib(outputBuffer, handleOutputChunk, mode) {
|
|
17
|
+
// The zlib constructors all allocate a buffer of size chunkSize using Buffer.allocUnsafe
|
|
18
|
+
// We want to ensure that that invocation doesn't allocate a buffer.
|
|
19
|
+
// Unfortunately the minimum value of `chunkSize` to the constructor is non-zero
|
|
20
|
+
let compressor;
|
|
21
|
+
const savedAllocUnsafe = Buffer.allocUnsafe;
|
|
22
|
+
try {
|
|
23
|
+
//@ts-expect-error
|
|
24
|
+
Buffer.allocUnsafe = () => outputBuffer;
|
|
25
|
+
switch (mode) {
|
|
26
|
+
case 'inflate':
|
|
27
|
+
compressor = zlib.createInflateRaw({
|
|
28
|
+
chunkSize: outputBuffer.byteLength
|
|
29
|
+
});
|
|
30
|
+
break;
|
|
31
|
+
case 'deflate':
|
|
32
|
+
compressor = zlib.createDeflateRaw({
|
|
33
|
+
chunkSize: outputBuffer.byteLength,
|
|
34
|
+
level: zlib.constants.Z_BEST_COMPRESSION
|
|
35
|
+
});
|
|
36
|
+
break;
|
|
37
|
+
case 'zstd-compress':
|
|
38
|
+
// available in Node 22.15+
|
|
39
|
+
compressor = zlib.createZstdCompress({
|
|
40
|
+
chunkSize: outputBuffer.byteLength
|
|
41
|
+
});
|
|
42
|
+
break;
|
|
43
|
+
case 'zstd-decompress':
|
|
44
|
+
// available in Node 22.15+
|
|
45
|
+
compressor = zlib.createZstdDecompress({
|
|
46
|
+
chunkSize: outputBuffer.byteLength
|
|
47
|
+
});
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
// Unsupported mode (types currently restrict to 'deflate' | 'inflate')
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
Buffer.allocUnsafe = savedAllocUnsafe;
|
|
56
|
+
}
|
|
57
|
+
if (!compressor) {
|
|
58
|
+
throw new Error('Failed to create zlib instance');
|
|
59
|
+
}
|
|
60
|
+
const handle = compressor._handle;
|
|
61
|
+
return {
|
|
62
|
+
[Symbol.dispose]: () => {
|
|
63
|
+
if (compressor._handle) {
|
|
64
|
+
compressor._handle.close();
|
|
65
|
+
compressor._handle = undefined;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
update: function processInputChunk(inputBuffer) {
|
|
69
|
+
let error;
|
|
70
|
+
// Directive to the compressor on reaching the end of the current input buffer
|
|
71
|
+
// Default value is to expect more data
|
|
72
|
+
let flushFlag = compressor._defaultFlushFlag;
|
|
73
|
+
let bytesInInputBuffer = inputBuffer.byteLength;
|
|
74
|
+
if (bytesInInputBuffer <= 0) {
|
|
75
|
+
// Ensure the value is non-negative
|
|
76
|
+
// We will call the compressor one last time with 0 bytes of input
|
|
77
|
+
bytesInInputBuffer = 0;
|
|
78
|
+
// Tell the compressor to flush anything in its internal buffer and write any needed trailer.
|
|
79
|
+
flushFlag = compressor._finishFlushFlag;
|
|
80
|
+
}
|
|
81
|
+
let availInBefore = bytesInInputBuffer;
|
|
82
|
+
let inOff = 0;
|
|
83
|
+
let availOutAfter = 0;
|
|
84
|
+
let availInAfter;
|
|
85
|
+
const state = compressor._writeState;
|
|
86
|
+
do {
|
|
87
|
+
handle.writeSync(flushFlag, inputBuffer, // in
|
|
88
|
+
inOff, // in_off
|
|
89
|
+
availInBefore, // in_len
|
|
90
|
+
outputBuffer, // out
|
|
91
|
+
0, // out_off
|
|
92
|
+
outputBuffer.byteLength // out_len
|
|
93
|
+
);
|
|
94
|
+
if (error) {
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
else if (compressor[kError]) {
|
|
98
|
+
throw compressor[kError];
|
|
99
|
+
}
|
|
100
|
+
availOutAfter = state[0];
|
|
101
|
+
availInAfter = state[1];
|
|
102
|
+
const inDelta = availInBefore - availInAfter;
|
|
103
|
+
const have = outputBuffer.byteLength - availOutAfter;
|
|
104
|
+
if (have > 0) {
|
|
105
|
+
handleOutputChunk(outputBuffer, have);
|
|
106
|
+
}
|
|
107
|
+
// These values get reset if we have new data,
|
|
108
|
+
// so we can update them even if we're done
|
|
109
|
+
inOff += inDelta;
|
|
110
|
+
availInBefore = availInAfter;
|
|
111
|
+
} while (availOutAfter === 0);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=compress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compress.js","sourceRoot":"","sources":["../src/compress.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAG3D,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,MAAM,MAAM,GAAkB,CAAC,GAAG,EAAE;IAClC,0FAA0F;IAC1F,qBAAqB;IACrB,MAAM,SAAS,GAAiB,IAAI,CAAC,gBAAgB,EAAE,CAAC;IACxD,MAAM,YAAY,GAAuB,MAAM,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,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S;gBACxB,YAAY,EAAE,MAAM;gBACpB,CAAC,EAAE,UAAU;gBACb,YAAY,CAAC,UAAU,CAAC,UAAU;iBACnC,CAAC;gBAEF,IAAI,KAAK,EAAE,CAAC;oBACV,MAAM,KAAK,CAAC;gBACd,CAAC;qBAAM,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;oBAC9B,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;gBAC3B,CAAC;gBAED,aAAa,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBACzB,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBAExB,MAAM,OAAO,GAAW,aAAa,GAAG,YAAY,CAAC;gBAErD,MAAM,IAAI,GAAW,YAAY,CAAC,UAAU,GAAG,aAAa,CAAC;gBAC7D,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;oBACb,iBAAiB,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;gBACxC,CAAC;gBAED,8CAA8C;gBAC9C,2CAA2C;gBAC3C,KAAK,IAAI,OAAO,CAAC;gBACjB,aAAa,GAAG,YAAY,CAAC;YAC/B,CAAC,QAAQ,aAAa,KAAK,CAAC,EAAE;QAChC,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { Transform } from 'node:stream';\nimport zlib from 'node:zlib';\n\ntype OutputChunkHandler = (chunk: Uint8Array, lengthBytes: number) => void;\n\nconst kError: unique symbol = (() => {\n // Create an instance of Deflate so that we can get our hands on the internal error symbol\n // It isn't exported.\n const reference: zlib.Deflate = zlib.createDeflateRaw();\n const kErrorResult: symbol | undefined = Object.getOwnPropertySymbols(reference).find((x) =>\n x.toString().includes('kError')\n );\n if (kErrorResult === undefined) {\n throw new Error('Unable to find the internal error symbol in node:zlib');\n }\n reference.close();\n return kErrorResult;\n // Casting `symbol` to the exact symbol of this definition\n})() as typeof kError;\n\n/**\n * Internal members of all Zlib compressors.\n * Needed to\n */\ninterface IZlibInternals {\n /**\n * The native binding to Zlib.\n */\n _handle: IHandle | undefined;\n /**\n * The flush flag passed to each call other than the last one for this implementation.\n * Varies by compressor.\n */\n _defaultFlushFlag: number;\n /**\n * The flush flag passed to the final call for this implementation.\n * Varies by compressor.\n */\n _finishFlushFlag: number;\n /**\n * The number of bytes read from the input and written to the output.\n */\n _writeState: [number, number];\n /**\n * The internal error state\n */\n [kError]: Error | undefined;\n}\n\ntype Compressor = Transform & IZlibInternals;\n\ninterface IHandle {\n /**\n * Closes the handle and releases resources.\n * Ensure that this is always invoked.\n */\n close(): void;\n /**\n * Compresses up to `inLen` bytes from `chunk` starting at `inOff`.\n * Writes up to `outLen` bytes to `output` starting at `outOff`.\n * @param flushFlag - The flush flag to the compressor implementation. Defines the behavior when reaching the end of the input.\n * @param chunk - The buffer containing the data to be compressed\n * @param inOff - The offset in bytes to start reading from `chunk`\n * @param inLen - The maximum number of bytes to read from `chunk`\n * @param output - The buffer to write the compressed data to\n * @param outOff - The offset in bytes to start writing to `output` at\n * @param outLen - The maximum number of bytes to write to `output`.\n */\n writeSync(\n flushFlag: number,\n chunk: Uint8Array,\n inOff: number,\n inLen: number,\n output: Uint8Array,\n outOff: number,\n outLen: number\n ): void;\n}\n\nexport type IIncrementalZlib = Disposable & {\n update: (inputBuffer: Uint8Array) => void;\n};\n\n// zstd is available in Node 22+\ntype IExtendedZlib = typeof zlib & {\n createZstdCompress: (options?: zlib.ZlibOptions) => Transform;\n createZstdDecompress: (options?: zlib.ZlibOptions) => Transform;\n};\n\nexport type IncrementalZlibMode = 'deflate' | 'inflate' | 'zstd-compress' | 'zstd-decompress';\n\nexport function createIncrementalZlib(\n outputBuffer: Uint8Array,\n handleOutputChunk: OutputChunkHandler,\n mode: IncrementalZlibMode\n): IIncrementalZlib {\n // The zlib constructors all allocate a buffer of size chunkSize using Buffer.allocUnsafe\n // We want to ensure that that invocation doesn't allocate a buffer.\n // Unfortunately the minimum value of `chunkSize` to the constructor is non-zero\n\n let compressor: Compressor | undefined;\n\n const savedAllocUnsafe: typeof Buffer.allocUnsafe = Buffer.allocUnsafe;\n\n try {\n //@ts-expect-error\n Buffer.allocUnsafe = () => outputBuffer;\n switch (mode) {\n case 'inflate':\n compressor = zlib.createInflateRaw({\n chunkSize: outputBuffer.byteLength\n }) as unknown as Transform & IZlibInternals;\n break;\n case 'deflate':\n compressor = zlib.createDeflateRaw({\n chunkSize: outputBuffer.byteLength,\n level: zlib.constants.Z_BEST_COMPRESSION\n }) as unknown as Transform & IZlibInternals;\n break;\n case 'zstd-compress':\n // available in Node 22.15+\n compressor = (zlib as IExtendedZlib).createZstdCompress({\n chunkSize: outputBuffer.byteLength\n }) as unknown as Transform & IZlibInternals;\n break;\n case 'zstd-decompress':\n // available in Node 22.15+\n compressor = (zlib as IExtendedZlib).createZstdDecompress({\n chunkSize: outputBuffer.byteLength\n }) as unknown as Transform & IZlibInternals;\n break;\n default:\n // Unsupported mode (types currently restrict to 'deflate' | 'inflate')\n break;\n }\n } finally {\n Buffer.allocUnsafe = savedAllocUnsafe;\n }\n\n if (!compressor) {\n throw new Error('Failed to create zlib instance');\n }\n\n const handle: IHandle = compressor._handle!;\n\n return {\n [Symbol.dispose]: () => {\n if (compressor._handle) {\n compressor._handle.close();\n compressor._handle = undefined;\n }\n },\n update: function processInputChunk(inputBuffer: Uint8Array): void {\n let error: Error | undefined;\n\n // Directive to the compressor on reaching the end of the current input buffer\n // Default value is to expect more data\n let flushFlag: number = compressor._defaultFlushFlag;\n\n let bytesInInputBuffer: number = inputBuffer.byteLength;\n\n if (bytesInInputBuffer <= 0) {\n // Ensure the value is non-negative\n // We will call the compressor one last time with 0 bytes of input\n bytesInInputBuffer = 0;\n // Tell the compressor to flush anything in its internal buffer and write any needed trailer.\n flushFlag = compressor._finishFlushFlag;\n }\n\n let availInBefore: number = bytesInInputBuffer;\n let inOff: number = 0;\n let availOutAfter: number = 0;\n let availInAfter: number | undefined;\n\n const state: [number, number] = compressor._writeState;\n\n do {\n handle.writeSync(\n flushFlag,\n inputBuffer, // in\n inOff, // in_off\n availInBefore, // in_len\n outputBuffer, // out\n 0, // out_off\n outputBuffer.byteLength // out_len\n );\n\n if (error) {\n throw error;\n } else if (compressor[kError]) {\n throw compressor[kError];\n }\n\n availOutAfter = state[0];\n availInAfter = state[1];\n\n const inDelta: number = availInBefore - availInAfter;\n\n const have: number = outputBuffer.byteLength - availOutAfter;\n if (have > 0) {\n handleOutputChunk(outputBuffer, have);\n }\n\n // These values get reset if we have new data,\n // so we can update them even if we're done\n inOff += inDelta;\n availInBefore = availInAfter;\n } while (availOutAfter === 0);\n }\n };\n}\n"]}
|
package/lib-esm/crc32.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
var _a;
|
|
4
|
+
import * as zlib from 'node:zlib';
|
|
5
|
+
let crcTable;
|
|
6
|
+
function initCrcTable() {
|
|
7
|
+
if (crcTable) {
|
|
8
|
+
return crcTable;
|
|
9
|
+
}
|
|
10
|
+
crcTable = new Uint32Array(256);
|
|
11
|
+
for (let i = 0; i < 256; i++) {
|
|
12
|
+
let crcEntry = i;
|
|
13
|
+
for (let j = 0; j < 8; j++) {
|
|
14
|
+
// eslint-disable-next-line no-bitwise
|
|
15
|
+
crcEntry = crcEntry & 1 ? 0xedb88320 ^ (crcEntry >>> 1) : crcEntry >>> 1;
|
|
16
|
+
}
|
|
17
|
+
crcTable[i] = crcEntry;
|
|
18
|
+
}
|
|
19
|
+
return crcTable;
|
|
20
|
+
}
|
|
21
|
+
export function fallbackCrc32(data, value = 0) {
|
|
22
|
+
const table = initCrcTable();
|
|
23
|
+
value = (value ^ 0xffffffff) >>> 0;
|
|
24
|
+
for (let i = 0; i < data.length; i++) {
|
|
25
|
+
// eslint-disable-next-line no-bitwise
|
|
26
|
+
value = table[(value ^ data[i]) & 0xff] ^ (value >>> 8);
|
|
27
|
+
}
|
|
28
|
+
value = (value ^ 0xffffffff) >>> 0;
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
export const crc32Builder = (_a = zlib.crc32) !== null && _a !== void 0 ? _a : fallbackCrc32;
|
|
32
|
+
//# sourceMappingURL=crc32.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crc32.js","sourceRoot":"","sources":["../src/crc32.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;;AAE3D,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,IAAI,QAAiC,CAAC;AAEtC,SAAS,YAAY;IACnB,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,QAAQ,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC,CAAC;IAChC,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,QAAQ,GAAW,CAAC,CAAC;QACzB,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACnC,sCAAsC;YACtC,QAAQ,GAAG,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC;QAC3E,CAAC;QACD,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC;IACzB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAA6B,EAAE,QAAgB,CAAC;IAC5E,MAAM,KAAK,GAAgB,YAAY,EAAE,CAAC;IAC1C,KAAK,GAAG,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAEnC,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7C,sCAAsC;QACtC,KAAK,GAAG,KAAK,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,GAAG,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GACvB,MAAA,IAAI,CAAC,KAAK,mCAAI,aAAa,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as zlib from 'node:zlib';\n\nlet crcTable: Uint32Array | undefined;\n\nfunction initCrcTable(): Uint32Array {\n if (crcTable) {\n return crcTable;\n }\n\n crcTable = new Uint32Array(256);\n for (let i: number = 0; i < 256; i++) {\n let crcEntry: number = i;\n for (let j: number = 0; j < 8; j++) {\n // eslint-disable-next-line no-bitwise\n crcEntry = crcEntry & 1 ? 0xedb88320 ^ (crcEntry >>> 1) : crcEntry >>> 1;\n }\n crcTable[i] = crcEntry;\n }\n return crcTable;\n}\n\nexport function fallbackCrc32(data: Buffer<ArrayBufferLike>, value: number = 0): number {\n const table: Uint32Array = initCrcTable();\n value = (value ^ 0xffffffff) >>> 0;\n\n for (let i: number = 0; i < data.length; i++) {\n // eslint-disable-next-line no-bitwise\n value = table[(value ^ data[i]) & 0xff] ^ (value >>> 8);\n }\n\n value = (value ^ 0xffffffff) >>> 0;\n return value;\n}\n\nexport const crc32Builder: (data: Buffer<ArrayBufferLike>, value?: number) => number =\n zlib.crc32 ?? fallbackCrc32;\n"]}
|
package/lib-esm/fs.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
var _a;
|
|
4
|
+
import { default as fs } from 'node:fs';
|
|
5
|
+
export const DISPOSE_SYMBOL = (_a = Symbol.dispose) !== null && _a !== void 0 ? _a : Symbol.for('Symbol.dispose');
|
|
6
|
+
export function getDisposableFileHandle(path, openMode) {
|
|
7
|
+
const result = {
|
|
8
|
+
fd: fs.openSync(path, openMode),
|
|
9
|
+
[DISPOSE_SYMBOL]: () => {
|
|
10
|
+
if (!isNaN(result.fd)) {
|
|
11
|
+
fs.closeSync(result.fd);
|
|
12
|
+
result.fd = NaN;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
export function rmdirSync(dirPath) {
|
|
19
|
+
try {
|
|
20
|
+
fs.rmdirSync(dirPath);
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
if (e.code === 'ENOENT' || e.code === 'ENOTDIR') {
|
|
25
|
+
// Not found, ignore
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
throw e;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
export function unlinkSync(filePath) {
|
|
34
|
+
try {
|
|
35
|
+
fs.unlinkSync(filePath);
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
if (e && e.code === 'ENOENT') {
|
|
40
|
+
// Not found, ignore
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
throw e;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=fs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;;AAE3D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CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { default as fs, type OpenMode } from 'node:fs';\n\ninterface IInternalDisposableFileHandle extends Disposable {\n fd: number;\n}\n\nexport interface IDisposableFileHandle extends IInternalDisposableFileHandle {\n readonly fd: number;\n}\n\nexport const DISPOSE_SYMBOL: typeof Symbol.dispose = Symbol.dispose ?? Symbol.for('Symbol.dispose');\n\nexport function getDisposableFileHandle(path: string, openMode: OpenMode): IDisposableFileHandle {\n const result: IInternalDisposableFileHandle = {\n fd: fs.openSync(path, openMode),\n [DISPOSE_SYMBOL]: () => {\n if (!isNaN(result.fd)) {\n fs.closeSync(result.fd);\n result.fd = NaN;\n }\n }\n };\n\n return result;\n}\n\nexport function rmdirSync(dirPath: string): boolean {\n try {\n fs.rmdirSync(dirPath);\n return true;\n } catch (e) {\n if ((e as NodeJS.ErrnoException).code === 'ENOENT' || (e as NodeJS.ErrnoException).code === 'ENOTDIR') {\n // Not found, ignore\n } else {\n throw e;\n }\n }\n return false;\n}\n\nexport function unlinkSync(filePath: string): boolean {\n try {\n fs.unlinkSync(filePath);\n return true;\n } catch (e) {\n if (e && (e as NodeJS.ErrnoException).code === 'ENOENT') {\n // Not found, ignore\n } else {\n throw e;\n }\n }\n return false;\n}\n"]}
|
package/lib-esm/hash.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import { readSync, fstatSync } from 'node:fs';
|
|
4
|
+
import { createHash } from 'node:crypto';
|
|
5
|
+
const buffer = Buffer.allocUnsafeSlow(1 << 24);
|
|
6
|
+
export function computeFileHash(fd) {
|
|
7
|
+
try {
|
|
8
|
+
const hash = createHash('sha1');
|
|
9
|
+
let totalBytesRead = 0;
|
|
10
|
+
let bytesRead;
|
|
11
|
+
do {
|
|
12
|
+
bytesRead = readSync(fd, buffer, 0, buffer.length, -1);
|
|
13
|
+
if (bytesRead <= 0) {
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
totalBytesRead += bytesRead;
|
|
17
|
+
hash.update(buffer.subarray(0, bytesRead));
|
|
18
|
+
} while (bytesRead > 0);
|
|
19
|
+
if (totalBytesRead === 0) {
|
|
20
|
+
// Sometimes directories get treated as empty files
|
|
21
|
+
const stat = fstatSync(fd);
|
|
22
|
+
if (!stat.isFile()) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return hash.digest('hex');
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
// There is a bug in node-core-library where it doesn't handle if the operation was on a file descriptor
|
|
30
|
+
if (err.code === 'EISDIR' || err.code === 'ENOENT' || err.code === 'ENOTDIR') {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function calculateSHA1(data) {
|
|
37
|
+
return createHash('sha1').update(data).digest('hex');
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAc,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAa,MAAM,aAAa,CAAC;AAEpD,MAAM,MAAM,GAAW,MAAM,CAAC,eAAe,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAEvD,MAAM,UAAU,eAAe,CAAC,EAAU;IACxC,IAAI,CAAC;QACH,MAAM,IAAI,GAAS,UAAU,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,cAAc,GAAW,CAAC,CAAC;QAC/B,IAAI,SAAiB,CAAC;QACtB,GAAG,CAAC;YACF,SAAS,GAAG,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;YACvD,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;gBACnB,MAAM;YACR,CAAC;YACD,cAAc,IAAI,SAAS,CAAC;YAC5B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;QAC7C,CAAC,QAAQ,SAAS,GAAG,CAAC,EAAE;QACxB,IAAI,cAAc,KAAK,CAAC,EAAE,CAAC;YACzB,mDAAmD;YACnD,MAAM,IAAI,GAAU,SAAS,CAAC,EAAE,CAAC,CAAC;YAClC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;gBACnB,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,wGAAwG;QACxG,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC7E,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACvD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { readSync, fstatSync, type Stats } from 'node:fs';\nimport { createHash, type Hash } from 'node:crypto';\n\nconst buffer: Buffer = Buffer.allocUnsafeSlow(1 << 24);\n\nexport function computeFileHash(fd: number): string | false {\n try {\n const hash: Hash = createHash('sha1');\n let totalBytesRead: number = 0;\n let bytesRead: number;\n do {\n bytesRead = readSync(fd, buffer, 0, buffer.length, -1);\n if (bytesRead <= 0) {\n break;\n }\n totalBytesRead += bytesRead;\n hash.update(buffer.subarray(0, bytesRead));\n } while (bytesRead > 0);\n if (totalBytesRead === 0) {\n // Sometimes directories get treated as empty files\n const stat: Stats = fstatSync(fd);\n if (!stat.isFile()) {\n return false;\n }\n }\n\n return hash.digest('hex');\n } catch (err) {\n // There is a bug in node-core-library where it doesn't handle if the operation was on a file descriptor\n if (err.code === 'EISDIR' || err.code === 'ENOENT' || err.code === 'ENOTDIR') {\n return false;\n }\n throw err;\n }\n}\n\nexport function calculateSHA1(data: Buffer): string {\n return createHash('sha1').update(data).digest('hex');\n}\n"]}
|
package/lib-esm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAE,IAAI,EAAqD,MAAM,QAAQ,CAAC;AACjF,OAAO,EAAE,MAAM,EAAyD,MAAM,UAAU,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nexport { pack, type IZipSyncPackResult, type IZipSyncPackOptions } from './pack';\nexport { unpack, type IZipSyncUnpackResult, type IZipSyncUnpackOptions } from './unpack';\n"]}
|