From f8080f56db3bfe988283120cbaa30fb97b565cbd Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sun, 13 Oct 2024 14:03:56 -0500 Subject: [PATCH] conversion to esm --- .github/workflows/nodejs.yml | 34 +- .github/workflows/npmpublish.yml | 4 +- .github/workflows/npmpublish.yml.save | 30 + .prettierignore | 3 + CHANGELOG.md | 18 +- CONTRIBUTING.md | 14 +- README.md | 2 +- lib/archivers/archive-entry.js | 22 +- lib/archivers/archive-output-stream.js | 178 +- lib/archivers/zip/constants.js | 169 +- lib/archivers/zip/general-purpose-bit.js | 76 +- lib/archivers/zip/unix-stat.js | 72 +- lib/archivers/zip/util.js | 64 +- lib/archivers/zip/zip-archive-entry.js | 744 ++++---- .../zip/zip-archive-output-stream.js | 734 ++++---- lib/compress-commons.js | 24 +- lib/util/index.js | 27 +- package-lock.json | 1527 ++--------------- package.json | 10 +- renovate.json | 6 +- test/archive-output-stream.js | 26 +- test/commons.js | 9 +- test/general-purpose-bit.js | 109 +- test/helpers/index.js | 114 +- test/zip-archive-entry.js | 320 ++-- test/zip-archive-output-stream.js | 175 +- 26 files changed, 1487 insertions(+), 3024 deletions(-) create mode 100644 .github/workflows/npmpublish.yml.save create mode 100644 .prettierignore diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index acb9a176..95a91e34 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -14,22 +14,22 @@ jobs: strategy: matrix: - node-version: [14.x, 16.x, 18.x, 20.x] + node-version: [18.x, 20.x] steps: - - uses: actions/checkout@v4.2.1 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4.0.4 - with: - node-version: ${{ matrix.node-version }} - - name: npm install and test - run: | - npm ci - npm test - env: - CI: true - - name: Archive production artifacts - uses: actions/upload-artifact@v4 - with: - name: tmp-zip-node-v${{ matrix.node-version }} - path: tmp/*.zip + - uses: actions/checkout@v4.2.1 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4.0.4 + with: + node-version: ${{ matrix.node-version }} + - name: npm install and test + run: | + npm ci + npm test + env: + CI: true + - name: Archive production artifacts + uses: actions/upload-artifact@v4 + with: + name: tmp-zip-node-v${{ matrix.node-version }} + path: tmp/*.zip diff --git a/.github/workflows/npmpublish.yml b/.github/workflows/npmpublish.yml index 8f531f0f..2edfb950 100644 --- a/.github/workflows/npmpublish.yml +++ b/.github/workflows/npmpublish.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@v4.2.1 - uses: actions/setup-node@v4.0.4 with: - node-version: 16 + node-version: 20 - run: npm ci - run: npm test @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v4.2.1 - uses: actions/setup-node@v4.0.4 with: - node-version: 16 + node-version: 20 registry-url: https://registry.npmjs.org/ - run: npm ci - run: npm publish diff --git a/.github/workflows/npmpublish.yml.save b/.github/workflows/npmpublish.yml.save new file mode 100644 index 00000000..2edfb950 --- /dev/null +++ b/.github/workflows/npmpublish.yml.save @@ -0,0 +1,30 @@ +name: Node Publish Package + +on: + release: + types: [published] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.2.1 + - uses: actions/setup-node@v4.0.4 + with: + node-version: 20 + - run: npm ci + - run: npm test + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.2.1 + - uses: actions/setup-node@v4.0.4 + with: + node-version: 20 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..1b8ac889 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +# Ignore artifacts: +build +coverage diff --git a/CHANGELOG.md b/CHANGELOG.md index c1400d97..ec5b81a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,12 +12,12 @@ **5.0.0** — _September 2, 2023_ — [Diff](https://github.com/archiverjs/node-compress-commons/compare/4.1.2...5.0.0) - **4.1.2** — _September 2, 2023_ — [Diff](https://github.com/archiverjs/node-compress-commons/compare/4.1.1...4.1.2) **4.1.1** — _May 30th, 2021_ — [Diff](https://github.com/archiverjs/node-compress-commons/compare/4.1.0...4.1.1) ### Maintenance + - Bump mocha from 8.2.1 to 8.4.0 (#70) - Bump crc32-stream from 4.0.1 to 4.0.2 (#59) - Bump y18n from 4.0.0 to 4.0.1 (#69) @@ -36,17 +36,17 @@ **4.0.1** — _July 20, 2020_ — [Diff](https://github.com/archiverjs/node-compress-commons/compare/4.0.0...4.0.1) -* Bump crc32-stream from 3.0.1 to 4.0.0 (#43) @dependabot +- Bump crc32-stream from 3.0.1 to 4.0.0 (#43) @dependabot **4.0.0** — _July 18, 2020_ — [Diff](https://github.com/archiverjs/node-compress-commons/compare/3.0.0...4.0.0) -* Bump mocha from 5.2.0 to 8.0.1 (#36) @dependabot -* Bump readable-stream from 2.3.7 to 3.6.0 (#39) @dependabot -* Bump actions/setup-node from v1 to v2.1.0 (#41) @dependabot -* Bump rimraf from 2.7.1 to 3.0.2 (#38) @dependabot -* Bump mkdirp from 0.5.5 to 1.0.4 (#37) @dependabot -* Bump actions/checkout from v1 to v2.3.1 (#40) @dependabot -* remove support for node < 10 (#42) @ctalkington +- Bump mocha from 5.2.0 to 8.0.1 (#36) @dependabot +- Bump readable-stream from 2.3.7 to 3.6.0 (#39) @dependabot +- Bump actions/setup-node from v1 to v2.1.0 (#41) @dependabot +- Bump rimraf from 2.7.1 to 3.0.2 (#38) @dependabot +- Bump mkdirp from 0.5.5 to 1.0.4 (#37) @dependabot +- Bump actions/checkout from v1 to v2.3.1 (#40) @dependabot +- remove support for node < 10 (#42) @ctalkington **3.0.0** — _April 14, 2020_ — [Diff](https://github.com/archiverjs/node-compress-commons/compare/2.1.1...3.0.0) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eca68a45..629a8f29 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,13 +2,13 @@ #### Code Style Guide -* code should be indented with 2 spaces -* single quotes should be used where feasible -* commas should be followed by a single space (function params, etc) -* variable declaration should include `var`, [no multiple declarations](http://benalman.com/news/2012/05/multiple-var-statements-javascript/) +- code should be indented with 2 spaces +- single quotes should be used where feasible +- commas should be followed by a single space (function params, etc) +- variable declaration should include `var`, [no multiple declarations](http://benalman.com/news/2012/05/multiple-var-statements-javascript/) #### Tests -* tests should be added to the nodeunit configs in `tests/` -* tests can be run with `npm test` -* see existing tests for guidance \ No newline at end of file +- tests should be added to the nodeunit configs in `tests/` +- tests can be run with `npm test` +- see existing tests for guidance diff --git a/README.md b/README.md index 6a74ce14..19d7ee93 100644 --- a/README.md +++ b/README.md @@ -22,4 +22,4 @@ You can also use `npm install https://github.com/archiverjs/node-compress-common Concept inspired by [Apache Commons Compress](http://commons.apache.org/proper/commons-compress/)™. -Some logic derived from [Apache Commons Compress](http://commons.apache.org/proper/commons-compress/)™ and [OpenJDK 7](http://openjdk.java.net/). \ No newline at end of file +Some logic derived from [Apache Commons Compress](http://commons.apache.org/proper/commons-compress/)™ and [OpenJDK 7](http://openjdk.java.net/). diff --git a/lib/archivers/archive-entry.js b/lib/archivers/archive-entry.js index 86bc5988..f245a334 100644 --- a/lib/archivers/archive-entry.js +++ b/lib/archivers/archive-entry.js @@ -1,16 +1,6 @@ -/** - * node-compress-commons - * - * Copyright (c) 2014 Chris Talkington, contributors. - * Licensed under the MIT license. - * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT - */ -var ArchiveEntry = module.exports = function() {}; - -ArchiveEntry.prototype.getName = function() {}; - -ArchiveEntry.prototype.getSize = function() {}; - -ArchiveEntry.prototype.getLastModifiedDate = function() {}; - -ArchiveEntry.prototype.isDirectory = function() {}; \ No newline at end of file +export default class ArchiveEntry { + getName() {} + getSize() {} + getLastModifiedDate() {} + isDirectory() {} +} diff --git a/lib/archivers/archive-output-stream.js b/lib/archivers/archive-output-stream.js index d349b5e6..3aaec771 100644 --- a/lib/archivers/archive-output-stream.js +++ b/lib/archivers/archive-output-stream.js @@ -1,118 +1,98 @@ -/** - * node-compress-commons - * - * Copyright (c) 2014 Chris Talkington, contributors. - * Licensed under the MIT license. - * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT - */ -var inherits = require('util').inherits; -var isStream = require('is-stream'); -var Transform = require('readable-stream').Transform; - -var ArchiveEntry = require('./archive-entry'); -var util = require('../util'); - -var ArchiveOutputStream = module.exports = function(options) { - if (!(this instanceof ArchiveOutputStream)) { - return new ArchiveOutputStream(options); +import { inherits } from "util"; +import { isStream } from "is-stream"; +import { Transform } from "readable-stream"; +import ArchiveEntry from "./archive-entry.js"; +import { normalizeInputSource } from "../util/index.js"; + +export default class ArchiveOutputStream extends Transform { + constructor(options) { + super(options); + + this.offset = 0; + this._archive = { + finish: false, + finished: false, + processing: false, + }; } - Transform.call(this, options); - - this.offset = 0; - this._archive = { - finish: false, - finished: false, - processing: false - }; -}; - -inherits(ArchiveOutputStream, Transform); - -ArchiveOutputStream.prototype._appendBuffer = function(zae, source, callback) { - // scaffold only -}; - -ArchiveOutputStream.prototype._appendStream = function(zae, source, callback) { - // scaffold only -}; - -ArchiveOutputStream.prototype._emitErrorCallback = function(err) { - if (err) { - this.emit('error', err); + _appendBuffer(zae, source, callback) { + // scaffold only } -}; - -ArchiveOutputStream.prototype._finish = function(ae) { - // scaffold only -}; -ArchiveOutputStream.prototype._normalizeEntry = function(ae) { - // scaffold only -}; - -ArchiveOutputStream.prototype._transform = function(chunk, encoding, callback) { - callback(null, chunk); -}; + _appendStream(zae, source, callback) { + // scaffold only + } -ArchiveOutputStream.prototype.entry = function(ae, source, callback) { - source = source || null; + _emitErrorCallback = function (err) { + if (err) { + this.emit("error", err); + } + }; - if (typeof callback !== 'function') { - callback = this._emitErrorCallback.bind(this); + _finish(ae) { + // scaffold only } - if (!(ae instanceof ArchiveEntry)) { - callback(new Error('not a valid instance of ArchiveEntry')); - return; + _normalizeEntry(ae) { + // scaffold only } - if (this._archive.finish || this._archive.finished) { - callback(new Error('unacceptable entry after finish')); - return; + _transform(chunk, encoding, callback) { + callback(null, chunk); } - if (this._archive.processing) { - callback(new Error('already processing an entry')); - return; + entry(ae, source, callback) { + source = source || null; + if (typeof callback !== "function") { + callback = this._emitErrorCallback.bind(this); + } + if (!(ae instanceof ArchiveEntry)) { + callback(new Error("not a valid instance of ArchiveEntry")); + return; + } + if (this._archive.finish || this._archive.finished) { + callback(new Error("unacceptable entry after finish")); + return; + } + if (this._archive.processing) { + callback(new Error("already processing an entry")); + return; + } + this._archive.processing = true; + this._normalizeEntry(ae); + this._entry = ae; + source = normalizeInputSource(source); + if (Buffer.isBuffer(source)) { + this._appendBuffer(ae, source, callback); + } else if (isStream(source)) { + this._appendStream(ae, source, callback); + } else { + this._archive.processing = false; + callback( + new Error("input source must be valid Stream or Buffer instance"), + ); + return; + } + return this; } - this._archive.processing = true; - this._normalizeEntry(ae); - this._entry = ae; - - source = util.normalizeInputSource(source); - - if (Buffer.isBuffer(source)) { - this._appendBuffer(ae, source, callback); - } else if (isStream(source)) { - this._appendStream(ae, source, callback); - } else { - this._archive.processing = false; - callback(new Error('input source must be valid Stream or Buffer instance')); - return; + finish() { + if (this._archive.processing) { + this._archive.finish = true; + return; + } + this._finish(); } - return this; -}; - -ArchiveOutputStream.prototype.finish = function() { - if (this._archive.processing) { - this._archive.finish = true; - return; + getBytesWritten() { + return this.offset; } - this._finish(); -}; - -ArchiveOutputStream.prototype.getBytesWritten = function() { - return this.offset; -}; - -ArchiveOutputStream.prototype.write = function(chunk, cb) { - if (chunk) { - this.offset += chunk.length; + write(chunk, cb) { + if (chunk) { + this.offset += chunk.length; + } + return super.write(chunk, cb); } - - return Transform.prototype.write.call(this, chunk, cb); -}; \ No newline at end of file +} diff --git a/lib/archivers/zip/constants.js b/lib/archivers/zip/constants.js index c30b3250..f901a6f8 100644 --- a/lib/archivers/zip/constants.js +++ b/lib/archivers/zip/constants.js @@ -1,71 +1,100 @@ -/** - * node-compress-commons - * - * Copyright (c) 2014 Chris Talkington, contributors. - * Licensed under the MIT license. - * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT - */ -module.exports = { - WORD: 4, - DWORD: 8, - EMPTY: Buffer.alloc(0), - - SHORT: 2, - SHORT_MASK: 0xffff, - SHORT_SHIFT: 16, - SHORT_ZERO: Buffer.from(Array(2)), - LONG: 4, - LONG_ZERO: Buffer.from(Array(4)), - - MIN_VERSION_INITIAL: 10, - MIN_VERSION_DATA_DESCRIPTOR: 20, - MIN_VERSION_ZIP64: 45, - VERSION_MADEBY: 45, - - METHOD_STORED: 0, - METHOD_DEFLATED: 8, - - PLATFORM_UNIX: 3, - PLATFORM_FAT: 0, - - SIG_LFH: 0x04034b50, - SIG_DD: 0x08074b50, - SIG_CFH: 0x02014b50, - SIG_EOCD: 0x06054b50, - SIG_ZIP64_EOCD: 0x06064B50, - SIG_ZIP64_EOCD_LOC: 0x07064B50, - - ZIP64_MAGIC_SHORT: 0xffff, - ZIP64_MAGIC: 0xffffffff, - ZIP64_EXTRA_ID: 0x0001, - - ZLIB_NO_COMPRESSION: 0, - ZLIB_BEST_SPEED: 1, - ZLIB_BEST_COMPRESSION: 9, - ZLIB_DEFAULT_COMPRESSION: -1, - - MODE_MASK: 0xFFF, - DEFAULT_FILE_MODE: 33188, // 010644 = -rw-r--r-- = S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH - DEFAULT_DIR_MODE: 16877, // 040755 = drwxr-xr-x = S_IFDIR | S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH - - EXT_FILE_ATTR_DIR: 1106051088, // 010173200020 = drwxr-xr-x = (((S_IFDIR | 0755) << 16) | S_DOS_D) - EXT_FILE_ATTR_FILE: 2175008800, // 020151000040 = -rw-r--r-- = (((S_IFREG | 0644) << 16) | S_DOS_A) >>> 0 - - // Unix file types - S_IFMT: 61440, // 0170000 type of file mask - S_IFIFO: 4096, // 010000 named pipe (fifo) - S_IFCHR: 8192, // 020000 character special - S_IFDIR: 16384, // 040000 directory - S_IFBLK: 24576, // 060000 block special - S_IFREG: 32768, // 0100000 regular - S_IFLNK: 40960, // 0120000 symbolic link - S_IFSOCK: 49152, // 0140000 socket - - // DOS file type flags - S_DOS_A: 32, // 040 Archive - S_DOS_D: 16, // 020 Directory - S_DOS_V: 8, // 010 Volume - S_DOS_S: 4, // 04 System - S_DOS_H: 2, // 02 Hidden - S_DOS_R: 1 // 01 Read Only +export const WORD = 4; +export const DWORD = 8; +export const EMPTY = Buffer.alloc(0); +export const SHORT = 2; +export const SHORT_MASK = 0xffff; +export const SHORT_SHIFT = 16; +export const SHORT_ZERO = Buffer.from(Array(2)); +export const LONG = 4; +export const LONG_ZERO = Buffer.from(Array(4)); +export const MIN_VERSION_INITIAL = 10; +export const MIN_VERSION_DATA_DESCRIPTOR = 20; +export const MIN_VERSION_ZIP64 = 45; +export const VERSION_MADEBY = 45; +export const METHOD_STORED = 0; +export const METHOD_DEFLATED = 8; +export const PLATFORM_UNIX = 3; +export const PLATFORM_FAT = 0; +export const SIG_LFH = 0x04034b50; +export const SIG_DD = 0x08074b50; +export const SIG_CFH = 0x02014b50; +export const SIG_EOCD = 0x06054b50; +export const SIG_ZIP64_EOCD = 0x06064b50; +export const SIG_ZIP64_EOCD_LOC = 0x07064b50; +export const ZIP64_MAGIC_SHORT = 0xffff; +export const ZIP64_MAGIC = 0xffffffff; +export const ZIP64_EXTRA_ID = 0x0001; +export const ZLIB_NO_COMPRESSION = 0; +export const ZLIB_BEST_SPEED = 1; +export const ZLIB_BEST_COMPRESSION = 9; +export const ZLIB_DEFAULT_COMPRESSION = -1; +export const MODE_MASK = 0xfff; +export const DEFAULT_FILE_MODE = 33188; +export const DEFAULT_DIR_MODE = 16877; +export const EXT_FILE_ATTR_DIR = 1106051088; +export const EXT_FILE_ATTR_FILE = 2175008800; +export const S_IFMT = 61440; +export const S_IFIFO = 4096; +export const S_IFCHR = 8192; +export const S_IFDIR = 16384; +export const S_IFBLK = 24576; +export const S_IFREG = 32768; +export const S_IFLNK = 40960; +export const S_IFSOCK = 49152; +export const S_DOS_A = 32; +export const S_DOS_D = 16; +export const S_DOS_V = 8; +export const S_DOS_S = 4; +export const S_DOS_H = 2; +export const S_DOS_R = 1; // 01 Read Only +export default { + WORD, + DWORD, + EMPTY, + SHORT, + SHORT_MASK, + SHORT_SHIFT, + SHORT_ZERO, + LONG, + LONG_ZERO, + MIN_VERSION_INITIAL, + MIN_VERSION_DATA_DESCRIPTOR, + MIN_VERSION_ZIP64, + VERSION_MADEBY, + METHOD_STORED, + METHOD_DEFLATED, + PLATFORM_UNIX, + PLATFORM_FAT, + SIG_LFH, + SIG_DD, + SIG_CFH, + SIG_EOCD, + SIG_ZIP64_EOCD, + SIG_ZIP64_EOCD_LOC, + ZIP64_MAGIC_SHORT, + ZIP64_MAGIC, + ZIP64_EXTRA_ID, + ZLIB_NO_COMPRESSION, + ZLIB_BEST_SPEED, + ZLIB_BEST_COMPRESSION, + ZLIB_DEFAULT_COMPRESSION, + MODE_MASK, + DEFAULT_FILE_MODE, + DEFAULT_DIR_MODE, + EXT_FILE_ATTR_DIR, + EXT_FILE_ATTR_FILE, + S_IFMT, + S_IFIFO, + S_IFCHR, + S_IFDIR, + S_IFBLK, + S_IFREG, + S_IFLNK, + S_IFSOCK, + S_DOS_A, + S_DOS_D, + S_DOS_V, + S_DOS_S, + S_DOS_H, + S_DOS_R, }; diff --git a/lib/archivers/zip/general-purpose-bit.js b/lib/archivers/zip/general-purpose-bit.js index 62703996..20b87ae3 100644 --- a/lib/archivers/zip/general-purpose-bit.js +++ b/lib/archivers/zip/general-purpose-bit.js @@ -1,101 +1,79 @@ -/** - * node-compress-commons - * - * Copyright (c) 2014 Chris Talkington, contributors. - * Licensed under the MIT license. - * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT - */ -var zipUtil = require('./util'); - +import zipUtil from "./util.js"; var DATA_DESCRIPTOR_FLAG = 1 << 3; var ENCRYPTION_FLAG = 1 << 0; var NUMBER_OF_SHANNON_FANO_TREES_FLAG = 1 << 2; var SLIDING_DICTIONARY_SIZE_FLAG = 1 << 1; var STRONG_ENCRYPTION_FLAG = 1 << 6; var UFT8_NAMES_FLAG = 1 << 11; - -var GeneralPurposeBit = module.exports = function() { +var GeneralPurposeBit = function () { if (!(this instanceof GeneralPurposeBit)) { return new GeneralPurposeBit(); } - this.descriptor = false; this.encryption = false; this.utf8 = false; this.numberOfShannonFanoTrees = 0; this.strongEncryption = false; this.slidingDictionarySize = 0; - return this; }; - -GeneralPurposeBit.prototype.encode = function() { +GeneralPurposeBit.prototype.encode = function () { return zipUtil.getShortBytes( (this.descriptor ? DATA_DESCRIPTOR_FLAG : 0) | - (this.utf8 ? UFT8_NAMES_FLAG : 0) | - (this.encryption ? ENCRYPTION_FLAG : 0) | - (this.strongEncryption ? STRONG_ENCRYPTION_FLAG : 0) + (this.utf8 ? UFT8_NAMES_FLAG : 0) | + (this.encryption ? ENCRYPTION_FLAG : 0) | + (this.strongEncryption ? STRONG_ENCRYPTION_FLAG : 0), ); }; - -GeneralPurposeBit.prototype.parse = function(buf, offset) { +GeneralPurposeBit.prototype.parse = function (buf, offset) { var flag = zipUtil.getShortBytesValue(buf, offset); var gbp = new GeneralPurposeBit(); - gbp.useDataDescriptor((flag & DATA_DESCRIPTOR_FLAG) !== 0); gbp.useUTF8ForNames((flag & UFT8_NAMES_FLAG) !== 0); gbp.useStrongEncryption((flag & STRONG_ENCRYPTION_FLAG) !== 0); gbp.useEncryption((flag & ENCRYPTION_FLAG) !== 0); - gbp.setSlidingDictionarySize((flag & SLIDING_DICTIONARY_SIZE_FLAG) !== 0 ? 8192 : 4096); - gbp.setNumberOfShannonFanoTrees((flag & NUMBER_OF_SHANNON_FANO_TREES_FLAG) !== 0 ? 3 : 2); - + gbp.setSlidingDictionarySize( + (flag & SLIDING_DICTIONARY_SIZE_FLAG) !== 0 ? 8192 : 4096, + ); + gbp.setNumberOfShannonFanoTrees( + (flag & NUMBER_OF_SHANNON_FANO_TREES_FLAG) !== 0 ? 3 : 2, + ); return gbp; }; - -GeneralPurposeBit.prototype.setNumberOfShannonFanoTrees = function(n) { +GeneralPurposeBit.prototype.setNumberOfShannonFanoTrees = function (n) { this.numberOfShannonFanoTrees = n; }; - -GeneralPurposeBit.prototype.getNumberOfShannonFanoTrees = function() { +GeneralPurposeBit.prototype.getNumberOfShannonFanoTrees = function () { return this.numberOfShannonFanoTrees; }; - -GeneralPurposeBit.prototype.setSlidingDictionarySize = function(n) { +GeneralPurposeBit.prototype.setSlidingDictionarySize = function (n) { this.slidingDictionarySize = n; }; - -GeneralPurposeBit.prototype.getSlidingDictionarySize = function() { +GeneralPurposeBit.prototype.getSlidingDictionarySize = function () { return this.slidingDictionarySize; }; - -GeneralPurposeBit.prototype.useDataDescriptor = function(b) { +GeneralPurposeBit.prototype.useDataDescriptor = function (b) { this.descriptor = b; }; - -GeneralPurposeBit.prototype.usesDataDescriptor = function() { +GeneralPurposeBit.prototype.usesDataDescriptor = function () { return this.descriptor; }; - -GeneralPurposeBit.prototype.useEncryption = function(b) { +GeneralPurposeBit.prototype.useEncryption = function (b) { this.encryption = b; }; - -GeneralPurposeBit.prototype.usesEncryption = function() { +GeneralPurposeBit.prototype.usesEncryption = function () { return this.encryption; }; - -GeneralPurposeBit.prototype.useStrongEncryption = function(b) { +GeneralPurposeBit.prototype.useStrongEncryption = function (b) { this.strongEncryption = b; }; - -GeneralPurposeBit.prototype.usesStrongEncryption = function() { +GeneralPurposeBit.prototype.usesStrongEncryption = function () { return this.strongEncryption; }; - -GeneralPurposeBit.prototype.useUTF8ForNames = function(b) { +GeneralPurposeBit.prototype.useUTF8ForNames = function (b) { this.utf8 = b; }; - -GeneralPurposeBit.prototype.usesUTF8ForNames = function() { +GeneralPurposeBit.prototype.usesUTF8ForNames = function () { return this.utf8; -}; \ No newline at end of file +}; +export default GeneralPurposeBit; diff --git a/lib/archivers/zip/unix-stat.js b/lib/archivers/zip/unix-stat.js index 1326cd1d..896a89d9 100644 --- a/lib/archivers/zip/unix-stat.js +++ b/lib/archivers/zip/unix-stat.js @@ -1,53 +1,19 @@ -/** - * node-compress-commons - * - * Copyright (c) 2014 Chris Talkington, contributors. - * Licensed under the MIT license. - * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT - */ -module.exports = { - /** - * Bits used for permissions (and sticky bit) - */ - PERM_MASK: 4095, // 07777 - - /** - * Bits used to indicate the filesystem object type. - */ - FILE_TYPE_FLAG: 61440, // 0170000 - - /** - * Indicates symbolic links. - */ - LINK_FLAG: 40960, // 0120000 - - /** - * Indicates plain files. - */ - FILE_FLAG: 32768, // 0100000 - - /** - * Indicates directories. - */ - DIR_FLAG: 16384, // 040000 - - // ---------------------------------------------------------- - // somewhat arbitrary choices that are quite common for shared - // installations - // ----------------------------------------------------------- - - /** - * Default permissions for symbolic links. - */ - DEFAULT_LINK_PERM: 511, // 0777 - - /** - * Default permissions for directories. - */ - DEFAULT_DIR_PERM: 493, // 0755 - - /** - * Default permissions for plain files. - */ - DEFAULT_FILE_PERM: 420 // 0644 -}; \ No newline at end of file +export const PERM_MASK = 4095; +export const FILE_TYPE_FLAG = 61440; +export const LINK_FLAG = 40960; +export const FILE_FLAG = 32768; +export const DIR_FLAG = 16384; +export const DEFAULT_LINK_PERM = 511; +export const DEFAULT_DIR_PERM = 493; +export const DEFAULT_FILE_PERM = 420; // 0644 + +export default { + PERM_MASK, + FILE_TYPE_FLAG, + LINK_FLAG, + FILE_FLAG, + DIR_FLAG, + DEFAULT_LINK_PERM, + DEFAULT_DIR_PERM, + DEFAULT_FILE_PERM, +}; diff --git a/lib/archivers/zip/util.js b/lib/archivers/zip/util.js index 22055ae5..7b018140 100644 --- a/lib/archivers/zip/util.js +++ b/lib/archivers/zip/util.js @@ -5,70 +5,68 @@ * Licensed under the MIT license. * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT */ -var util = module.exports = {}; - -util.dateToDos = function(d, forceLocalTime) { +var util = {}; +util.dateToDos = function (d, forceLocalTime) { forceLocalTime = forceLocalTime || false; - var year = forceLocalTime ? d.getFullYear() : d.getUTCFullYear(); - if (year < 1980) { return 2162688; // 1980-1-1 00:00:00 } else if (year >= 2044) { return 2141175677; // 2043-12-31 23:59:58 } - var val = { year: year, month: forceLocalTime ? d.getMonth() : d.getUTCMonth(), date: forceLocalTime ? d.getDate() : d.getUTCDate(), hours: forceLocalTime ? d.getHours() : d.getUTCHours(), minutes: forceLocalTime ? d.getMinutes() : d.getUTCMinutes(), - seconds: forceLocalTime ? d.getSeconds() : d.getUTCSeconds() + seconds: forceLocalTime ? d.getSeconds() : d.getUTCSeconds(), }; - - return ((val.year - 1980) << 25) | ((val.month + 1) << 21) | (val.date << 16) | - (val.hours << 11) | (val.minutes << 5) | (val.seconds / 2); + return ( + ((val.year - 1980) << 25) | + ((val.month + 1) << 21) | + (val.date << 16) | + (val.hours << 11) | + (val.minutes << 5) | + (val.seconds / 2) + ); }; - -util.dosToDate = function(dos) { - return new Date(((dos >> 25) & 0x7f) + 1980, ((dos >> 21) & 0x0f) - 1, (dos >> 16) & 0x1f, (dos >> 11) & 0x1f, (dos >> 5) & 0x3f, (dos & 0x1f) << 1); +util.dosToDate = function (dos) { + return new Date( + ((dos >> 25) & 0x7f) + 1980, + ((dos >> 21) & 0x0f) - 1, + (dos >> 16) & 0x1f, + (dos >> 11) & 0x1f, + (dos >> 5) & 0x3f, + (dos & 0x1f) << 1, + ); }; - -util.fromDosTime = function(buf) { +util.fromDosTime = function (buf) { return util.dosToDate(buf.readUInt32LE(0)); }; - -util.getEightBytes = function(v) { +util.getEightBytes = function (v) { var buf = Buffer.alloc(8); buf.writeUInt32LE(v % 0x0100000000, 0); buf.writeUInt32LE((v / 0x0100000000) | 0, 4); - return buf; }; - -util.getShortBytes = function(v) { +util.getShortBytes = function (v) { var buf = Buffer.alloc(2); - buf.writeUInt16LE((v & 0xFFFF) >>> 0, 0); - + buf.writeUInt16LE((v & 0xffff) >>> 0, 0); return buf; }; - -util.getShortBytesValue = function(buf, offset) { +util.getShortBytesValue = function (buf, offset) { return buf.readUInt16LE(offset); }; - -util.getLongBytes = function(v) { +util.getLongBytes = function (v) { var buf = Buffer.alloc(4); - buf.writeUInt32LE((v & 0xFFFFFFFF) >>> 0, 0); - + buf.writeUInt32LE((v & 0xffffffff) >>> 0, 0); return buf; }; - -util.getLongBytesValue = function(buf, offset) { +util.getLongBytesValue = function (buf, offset) { return buf.readUInt32LE(offset); }; - -util.toDosTime = function(d) { +util.toDosTime = function (d) { return util.getLongBytes(util.dateToDos(d)); -}; \ No newline at end of file +}; +export default util; diff --git a/lib/archivers/zip/zip-archive-entry.js b/lib/archivers/zip/zip-archive-entry.js index c53ad0ad..8655bb41 100644 --- a/lib/archivers/zip/zip-archive-entry.js +++ b/lib/archivers/zip/zip-archive-entry.js @@ -1,413 +1,379 @@ -/** - * node-compress-commons - * - * Copyright (c) 2014 Chris Talkington, contributors. - * Licensed under the MIT license. - * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT - */ -var inherits = require('util').inherits; -var normalizePath = require('normalize-path'); - -var ArchiveEntry = require('../archive-entry'); -var GeneralPurposeBit = require('./general-purpose-bit'); -var UnixStat = require('./unix-stat'); - -var constants = require('./constants'); -var zipUtil = require('./util'); - -var ZipArchiveEntry = module.exports = function(name) { - if (!(this instanceof ZipArchiveEntry)) { - return new ZipArchiveEntry(name); +import { inherits } from "util"; +import normalizePath from "normalize-path"; +import ArchiveEntry from "../archive-entry.js"; +import GeneralPurposeBit from "./general-purpose-bit.js"; +import UnixStat from "./unix-stat.js"; +import { + EMPTY, + MIN_VERSION_INITIAL, + MODE_MASK, + PLATFORM_FAT, + PLATFORM_UNIX, + S_DOS_A, + S_DOS_D, + S_IFDIR, + S_IFREG, + SHORT_SHIFT, + ZIP64_MAGIC, +} from "./constants.js"; +import { dateToDos, dosToDate } from "./util.js"; + +export default class ZipArchiveEntry extends ArchiveEntry { + constructor(name) { + super(); + this.platform = PLATFORM_FAT; + this.method = -1; + this.name = null; + this.size = 0; + this.csize = 0; + this.gpb = new GeneralPurposeBit(); + this.crc = 0; + this.time = -1; + this.minver = MIN_VERSION_INITIAL; + this.mode = -1; + this.extra = null; + this.exattr = 0; + this.inattr = 0; + this.comment = null; + if (name) { + this.setName(name); + } } - ArchiveEntry.call(this); - - this.platform = constants.PLATFORM_FAT; - this.method = -1; - - this.name = null; - this.size = 0; - this.csize = 0; - this.gpb = new GeneralPurposeBit(); - this.crc = 0; - this.time = -1; - - this.minver = constants.MIN_VERSION_INITIAL; - this.mode = -1; - this.extra = null; - this.exattr = 0; - this.inattr = 0; - this.comment = null; - - if (name) { - this.setName(name); + /** + * Returns the extra fields related to the entry. + * + * @returns {Buffer} + */ + getCentralDirectoryExtra() { + return this.getExtra(); } -}; - -inherits(ZipArchiveEntry, ArchiveEntry); - -/** - * Returns the extra fields related to the entry. - * - * @returns {Buffer} - */ -ZipArchiveEntry.prototype.getCentralDirectoryExtra = function() { - return this.getExtra(); -}; - -/** - * Returns the comment set for the entry. - * - * @returns {string} - */ -ZipArchiveEntry.prototype.getComment = function() { - return this.comment !== null ? this.comment : ''; -}; - -/** - * Returns the compressed size of the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getCompressedSize = function() { - return this.csize; -}; - -/** - * Returns the CRC32 digest for the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getCrc = function() { - return this.crc; -}; - -/** - * Returns the external file attributes for the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getExternalAttributes = function() { - return this.exattr; -}; - -/** - * Returns the extra fields related to the entry. - * - * @returns {Buffer} - */ -ZipArchiveEntry.prototype.getExtra = function() { - return this.extra !== null ? this.extra : constants.EMPTY; -}; - -/** - * Returns the general purpose bits related to the entry. - * - * @returns {GeneralPurposeBit} - */ -ZipArchiveEntry.prototype.getGeneralPurposeBit = function() { - return this.gpb; -}; - -/** - * Returns the internal file attributes for the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getInternalAttributes = function() { - return this.inattr; -}; - -/** - * Returns the last modified date of the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getLastModifiedDate = function() { - return this.getTime(); -}; -/** - * Returns the extra fields related to the entry. - * - * @returns {Buffer} - */ -ZipArchiveEntry.prototype.getLocalFileDataExtra = function() { - return this.getExtra(); -}; - -/** - * Returns the compression method used on the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getMethod = function() { - return this.method; -}; - -/** - * Returns the filename of the entry. - * - * @returns {string} - */ -ZipArchiveEntry.prototype.getName = function() { - return this.name; -}; - -/** - * Returns the platform on which the entry was made. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getPlatform = function() { - return this.platform; -}; - -/** - * Returns the size of the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getSize = function() { - return this.size; -}; - -/** - * Returns a date object representing the last modified date of the entry. - * - * @returns {number|Date} - */ -ZipArchiveEntry.prototype.getTime = function() { - return this.time !== -1 ? zipUtil.dosToDate(this.time) : -1; -}; - -/** - * Returns the DOS timestamp for the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getTimeDos = function() { - return this.time !== -1 ? this.time : 0; -}; - -/** - * Returns the UNIX file permissions for the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getUnixMode = function() { - return this.platform !== constants.PLATFORM_UNIX ? 0 : ((this.getExternalAttributes() >> constants.SHORT_SHIFT) & constants.SHORT_MASK); -}; - -/** - * Returns the version of ZIP needed to extract the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getVersionNeededToExtract = function() { - return this.minver; -}; - -/** - * Sets the comment of the entry. - * - * @param comment - */ -ZipArchiveEntry.prototype.setComment = function(comment) { - if (Buffer.byteLength(comment) !== comment.length) { - this.getGeneralPurposeBit().useUTF8ForNames(true); + /** + * Returns the comment set for the entry. + * + * @returns {string} + */ + getComment() { + return this.comment !== null ? this.comment : ""; } - this.comment = comment; -}; - -/** - * Sets the compressed size of the entry. - * - * @param size - */ -ZipArchiveEntry.prototype.setCompressedSize = function(size) { - if (size < 0) { - throw new Error('invalid entry compressed size'); + /** + * Returns the compressed size of the entry. + * + * @returns {number} + */ + getCompressedSize() { + return this.csize; } - this.csize = size; -}; - -/** - * Sets the checksum of the entry. - * - * @param crc - */ -ZipArchiveEntry.prototype.setCrc = function(crc) { - if (crc < 0) { - throw new Error('invalid entry crc32'); + /** + * Returns the CRC32 digest for the entry. + * + * @returns {number} + */ + getCrc() { + return this.crc; } - this.crc = crc; -}; - -/** - * Sets the external file attributes of the entry. - * - * @param attr - */ -ZipArchiveEntry.prototype.setExternalAttributes = function(attr) { - this.exattr = attr >>> 0; -}; - -/** - * Sets the extra fields related to the entry. - * - * @param extra - */ -ZipArchiveEntry.prototype.setExtra = function(extra) { - this.extra = extra; -}; - -/** - * Sets the general purpose bits related to the entry. - * - * @param gpb - */ -ZipArchiveEntry.prototype.setGeneralPurposeBit = function(gpb) { - if (!(gpb instanceof GeneralPurposeBit)) { - throw new Error('invalid entry GeneralPurposeBit'); + /** + * Returns the external file attributes for the entry. + * + * @returns {number} + */ + getExternalAttributes = function () { + return this.exattr; + }; + + /** + * Returns the extra fields related to the entry. + * + * @returns {Buffer} + */ + getExtra() { + return this.extra !== null ? this.extra : EMPTY; } - this.gpb = gpb; -}; - -/** - * Sets the internal file attributes of the entry. - * - * @param attr - */ -ZipArchiveEntry.prototype.setInternalAttributes = function(attr) { - this.inattr = attr; -}; - -/** - * Sets the compression method of the entry. - * - * @param method - */ -ZipArchiveEntry.prototype.setMethod = function(method) { - if (method < 0) { - throw new Error('invalid entry compression method'); + /** + * Returns the general purpose bits related to the entry. + * + * @returns {GeneralPurposeBit} + */ + getGeneralPurposeBit() { + return this.gpb; } - this.method = method; -}; - -/** - * Sets the name of the entry. - * - * @param name - * @param prependSlash - */ -ZipArchiveEntry.prototype.setName = function(name, prependSlash = false) { - name = normalizePath(name, false) - .replace(/^\w+:/, '') - .replace(/^(\.\.\/|\/)+/, ''); - - if (prependSlash) { - name = `/${name}`; + /** + * Returns the internal file attributes for the entry. + * + * @returns {number} + */ + getInternalAttributes() { + return this.inattr; } - if (Buffer.byteLength(name) !== name.length) { - this.getGeneralPurposeBit().useUTF8ForNames(true); + /** + * Returns the last modified date of the entry. + * + * @returns {number} + */ + getLastModifiedDate() { + return this.getTime(); } - this.name = name; -}; - -/** - * Sets the platform on which the entry was made. - * - * @param platform - */ -ZipArchiveEntry.prototype.setPlatform = function(platform) { - this.platform = platform; -}; - -/** - * Sets the size of the entry. - * - * @param size - */ -ZipArchiveEntry.prototype.setSize = function(size) { - if (size < 0) { - throw new Error('invalid entry size'); + /** + * Returns the extra fields related to the entry. + * + * @returns {Buffer} + */ + getLocalFileDataExtra() { + return this.getExtra(); } - this.size = size; -}; - -/** - * Sets the time of the entry. - * - * @param time - * @param forceLocalTime - */ -ZipArchiveEntry.prototype.setTime = function(time, forceLocalTime) { - if (!(time instanceof Date)) { - throw new Error('invalid entry time'); + /** + * Returns the compression method used on the entry. + * + * @returns {number} + */ + getMethod() { + return this.method; } - this.time = zipUtil.dateToDos(time, forceLocalTime); -}; - -/** - * Sets the UNIX file permissions for the entry. - * - * @param mode - */ -ZipArchiveEntry.prototype.setUnixMode = function(mode) { - mode |= this.isDirectory() ? constants.S_IFDIR : constants.S_IFREG; - - var extattr = 0; - extattr |= (mode << constants.SHORT_SHIFT) | (this.isDirectory() ? constants.S_DOS_D : constants.S_DOS_A); - - this.setExternalAttributes(extattr); - this.mode = mode & constants.MODE_MASK; - this.platform = constants.PLATFORM_UNIX; -}; - -/** - * Sets the version of ZIP needed to extract this entry. - * - * @param minver - */ -ZipArchiveEntry.prototype.setVersionNeededToExtract = function(minver) { - this.minver = minver; -}; - -/** - * Returns true if this entry represents a directory. - * - * @returns {boolean} - */ -ZipArchiveEntry.prototype.isDirectory = function() { - return this.getName().slice(-1) === '/'; -}; + /** + * Returns the filename of the entry. + * + * @returns {string} + */ + getName() { + return this.name; + } -/** - * Returns true if this entry represents a unix symlink, - * in which case the entry's content contains the target path - * for the symlink. - * - * @returns {boolean} - */ -ZipArchiveEntry.prototype.isUnixSymlink = function() { - return (this.getUnixMode() & UnixStat.FILE_TYPE_FLAG) === UnixStat.LINK_FLAG; -}; + /** + * Returns the platform on which the entry was made. + * + * @returns {number} + */ + getPlatform() { + return this.platform; + } + /** + * Returns the size of the entry. + * + * @returns {number} + */ + getSize() { + return this.size; + } + /** + * Returns a date object representing the last modified date of the entry. + * + * @returns {number|Date} + */ + getTime() { + return this.time !== -1 ? dosToDate(this.time) : -1; + } + /** + * Returns the DOS timestamp for the entry. + * + * @returns {number} + */ + getTimeDos() { + return this.time !== -1 ? this.time : 0; + } + /** + * Returns the UNIX file permissions for the entry. + * + * @returns {number} + */ + getUnixMode() { + return this.platform !== PLATFORM_UNIX + ? 0 + : (this.getExternalAttributes() >> SHORT_SHIFT) & SHORT_MASK; + } + /** + * Returns the version of ZIP needed to extract the entry. + * + * @returns {number} + */ + getVersionNeededToExtract() { + return this.minver; + } + /** + * Sets the comment of the entry. + * + * @param comment + */ + setComment(comment) { + if (Buffer.byteLength(comment) !== comment.length) { + this.getGeneralPurposeBit().useUTF8ForNames(true); + } + this.comment = comment; + } + /** + * Sets the compressed size of the entry. + * + * @param size + */ + setCompressedSize(size) { + if (size < 0) { + throw new Error("invalid entry compressed size"); + } + this.csize = size; + } + /** + * Sets the checksum of the entry. + * + * @param crc + */ + setCrc(crc) { + if (crc < 0) { + throw new Error("invalid entry crc32"); + } + this.crc = crc; + } + /** + * Sets the external file attributes of the entry. + * + * @param attr + */ + setExternalAttributes(attr) { + this.exattr = attr >>> 0; + } + /** + * Sets the extra fields related to the entry. + * + * @param extra + */ + setExtra(extra) { + this.extra = extra; + } + /** + * Sets the general purpose bits related to the entry. + * + * @param gpb + */ + setGeneralPurposeBit(gpb) { + if (!(gpb instanceof GeneralPurposeBit)) { + throw new Error("invalid entry GeneralPurposeBit"); + } + this.gpb = gpb; + } + /** + * Sets the internal file attributes of the entry. + * + * @param attr + */ + setInternalAttributes(attr) { + this.inattr = attr; + } + /** + * Sets the compression method of the entry. + * + * @param method + */ + setMethod(method) { + if (method < 0) { + throw new Error("invalid entry compression method"); + } + this.method = method; + } + /** + * Sets the name of the entry. + * + * @param name + * @param prependSlash + */ + setName(name, prependSlash = false) { + name = normalizePath(name, false) + .replace(/^\w+:/, "") + .replace(/^(\.\.\/|\/)+/, ""); + if (prependSlash) { + name = `/${name}`; + } + if (Buffer.byteLength(name) !== name.length) { + this.getGeneralPurposeBit().useUTF8ForNames(true); + } + this.name = name; + } + /** + * Sets the platform on which the entry was made. + * + * @param platform + */ + setPlatform(platform) { + this.platform = platform; + } + /** + * Sets the size of the entry. + * + * @param size + */ + setSize(size) { + if (size < 0) { + throw new Error("invalid entry size"); + } + this.size = size; + } + /** + * Sets the time of the entry. + * + * @param time + * @param forceLocalTime + */ + setTime(time, forceLocalTime) { + if (!(time instanceof Date)) { + throw new Error("invalid entry time"); + } + this.time = dateToDos(time, forceLocalTime); + } + /** + * Sets the UNIX file permissions for the entry. + * + * @param mode + */ + setUnixMode(mode) { + mode |= this.isDirectory() ? S_IFDIR : S_IFREG; + var extattr = 0; + extattr |= (mode << SHORT_SHIFT) | (this.isDirectory() ? S_DOS_D : S_DOS_A); + this.setExternalAttributes(extattr); + this.mode = mode & MODE_MASK; + this.platform = PLATFORM_UNIX; + } + /** + * Sets the version of ZIP needed to extract this entry. + * + * @param minver + */ + setVersionNeededToExtract(minver) { + this.minver = minver; + } + /** + * Returns true if this entry represents a directory. + * + * @returns {boolean} + */ + isDirectory() { + return this.getName().slice(-1) === "/"; + } + /** + * Returns true if this entry represents a unix symlink, + * in which case the entry's content contains the target path + * for the symlink. + * + * @returns {boolean} + */ + isUnixSymlink() { + return ( + (this.getUnixMode() & UnixStat.FILE_TYPE_FLAG) === UnixStat.LINK_FLAG + ); + } -/** - * Returns true if this entry is using the ZIP64 extension of ZIP. - * - * @returns {boolean} - */ -ZipArchiveEntry.prototype.isZip64 = function() { - return this.csize > constants.ZIP64_MAGIC || this.size > constants.ZIP64_MAGIC; -}; + /** + * Returns true if this entry is using the ZIP64 extension of ZIP. + * + * @returns {boolean} + */ + isZip64() { + return this.csize > ZIP64_MAGIC || this.size > ZIP64_MAGIC; + } +} diff --git a/lib/archivers/zip/zip-archive-output-stream.js b/lib/archivers/zip/zip-archive-output-stream.js index f56cea93..35d1c42f 100644 --- a/lib/archivers/zip/zip-archive-output-stream.js +++ b/lib/archivers/zip/zip-archive-output-stream.js @@ -1,437 +1,357 @@ -/** - * node-compress-commons - * - * Copyright (c) 2014 Chris Talkington, contributors. - * Licensed under the MIT license. - * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT - */ -var inherits = require('util').inherits; -var crc32 = require('crc-32'); -var {CRC32Stream} = require('crc32-stream'); -var {DeflateCRC32Stream} = require('crc32-stream'); - -var ArchiveOutputStream = require('../archive-output-stream'); -var ZipArchiveEntry = require('./zip-archive-entry'); -var GeneralPurposeBit = require('./general-purpose-bit'); - -var constants = require('./constants'); -var util = require('../../util'); -var zipUtil = require('./util'); - -var ZipArchiveOutputStream = module.exports = function(options) { - if (!(this instanceof ZipArchiveOutputStream)) { - return new ZipArchiveOutputStream(options); - } - - options = this.options = this._defaults(options); - - ArchiveOutputStream.call(this, options); - - this._entry = null; - this._entries = []; - this._archive = { - centralLength: 0, - centralOffset: 0, - comment: '', - finish: false, - finished: false, - processing: false, - forceZip64: options.forceZip64, - forceLocalTime: options.forceLocalTime - }; -}; - -inherits(ZipArchiveOutputStream, ArchiveOutputStream); - -ZipArchiveOutputStream.prototype._afterAppend = function(ae) { - this._entries.push(ae); - - if (ae.getGeneralPurposeBit().usesDataDescriptor()) { - this._writeDataDescriptor(ae); - } - - this._archive.processing = false; - this._entry = null; - - if (this._archive.finish && !this._archive.finished) { - this._finish(); - } -}; - -ZipArchiveOutputStream.prototype._appendBuffer = function(ae, source, callback) { - if (source.length === 0) { - ae.setMethod(constants.METHOD_STORED); - } - - var method = ae.getMethod(); - - if (method === constants.METHOD_STORED) { - ae.setSize(source.length); - ae.setCompressedSize(source.length); - ae.setCrc(crc32.buf(source) >>> 0); - } - - this._writeLocalFileHeader(ae); - - if (method === constants.METHOD_STORED) { - this.write(source); - this._afterAppend(ae); - callback(null, ae); - return; - } else if (method === constants.METHOD_DEFLATED) { - this._smartStream(ae, callback).end(source); - return; - } else { - callback(new Error('compression method ' + method + ' not implemented')); - return; - } -}; - -ZipArchiveOutputStream.prototype._appendStream = function(ae, source, callback) { - ae.getGeneralPurposeBit().useDataDescriptor(true); - ae.setVersionNeededToExtract(constants.MIN_VERSION_DATA_DESCRIPTOR); - - this._writeLocalFileHeader(ae); - - var smart = this._smartStream(ae, callback); - source.once('error', function(err) { - smart.emit('error', err); - smart.end(); - }) - source.pipe(smart); -}; - -ZipArchiveOutputStream.prototype._defaults = function(o) { - if (typeof o !== 'object') { - o = {}; - } - - if (typeof o.zlib !== 'object') { - o.zlib = {}; - } - - if (typeof o.zlib.level !== 'number') { - o.zlib.level = constants.ZLIB_BEST_SPEED; +import { inherits } from "util"; +import crc32 from "crc-32"; +import { CRC32Stream, DeflateCRC32Stream } from "crc32-stream"; +import ArchiveOutputStream from "../archive-output-stream.js"; +import ZipArchiveEntry from "./zip-archive-entry.js"; +import GeneralPurposeBit from "./general-purpose-bit.js"; +import constants from "./constants.js"; +import util from "../../util/index.js"; +import zipUtil from "./util.js"; + +export default class ZipArchiveOutputStream extends ArchiveOutputStream { + constructor(options) { + options = this.options = this._defaults(options); + super(options); + this._entry = null; + this._entries = []; + this._archive = { + centralLength: 0, + centralOffset: 0, + comment: "", + finish: false, + finished: false, + processing: false, + forceZip64: options.forceZip64, + forceLocalTime: options.forceLocalTime, + }; } - o.forceZip64 = !!o.forceZip64; - o.forceLocalTime = !!o.forceLocalTime; - - return o; -}; - -ZipArchiveOutputStream.prototype._finish = function() { - this._archive.centralOffset = this.offset; - - this._entries.forEach(function(ae) { - this._writeCentralFileHeader(ae); - }.bind(this)); - - this._archive.centralLength = this.offset - this._archive.centralOffset; - - if (this.isZip64()) { - this._writeCentralDirectoryZip64(); + _afterAppend(ae) { + this._entries.push(ae); + if (ae.getGeneralPurposeBit().usesDataDescriptor()) { + this._writeDataDescriptor(ae); + } + this._archive.processing = false; + this._entry = null; + if (this._archive.finish && !this._archive.finished) { + this._finish(); + } } - this._writeCentralDirectoryEnd(); - - this._archive.processing = false; - this._archive.finish = true; - this._archive.finished = true; - this.end(); -}; - -ZipArchiveOutputStream.prototype._normalizeEntry = function(ae) { - if (ae.getMethod() === -1) { - ae.setMethod(constants.METHOD_DEFLATED); + _appendBuffer(ae, source, callback) { + if (source.length === 0) { + ae.setMethod(constants.METHOD_STORED); + } + var method = ae.getMethod(); + if (method === constants.METHOD_STORED) { + ae.setSize(source.length); + ae.setCompressedSize(source.length); + ae.setCrc(crc32.buf(source) >>> 0); + } + this._writeLocalFileHeader(ae); + if (method === constants.METHOD_STORED) { + this.write(source); + this._afterAppend(ae); + callback(null, ae); + return; + } else if (method === constants.METHOD_DEFLATED) { + this._smartStream(ae, callback).end(source); + return; + } else { + callback(new Error("compression method " + method + " not implemented")); + return; + } } - if (ae.getMethod() === constants.METHOD_DEFLATED) { + _appendStream(ae, source, callback) { ae.getGeneralPurposeBit().useDataDescriptor(true); ae.setVersionNeededToExtract(constants.MIN_VERSION_DATA_DESCRIPTOR); + this._writeLocalFileHeader(ae); + var smart = this._smartStream(ae, callback); + source.once("error", function (err) { + smart.emit("error", err); + smart.end(); + }); + source.pipe(smart); } - if (ae.getTime() === -1) { - ae.setTime(new Date(), this._archive.forceLocalTime); - } - - ae._offsets = { - file: 0, - data: 0, - contents: 0, + _defaults = function (o) { + if (typeof o !== "object") { + o = {}; + } + if (typeof o.zlib !== "object") { + o.zlib = {}; + } + if (typeof o.zlib.level !== "number") { + o.zlib.level = constants.ZLIB_BEST_SPEED; + } + o.forceZip64 = !!o.forceZip64; + o.forceLocalTime = !!o.forceLocalTime; + return o; }; -}; - -ZipArchiveOutputStream.prototype._smartStream = function(ae, callback) { - var deflate = ae.getMethod() === constants.METHOD_DEFLATED; - var process = deflate ? new DeflateCRC32Stream(this.options.zlib) : new CRC32Stream(); - var error = null; - function handleStuff() { - var digest = process.digest().readUInt32BE(0); - ae.setCrc(digest); - ae.setSize(process.size()); - ae.setCompressedSize(process.size(true)); - this._afterAppend(ae); - callback(error, ae); + _finish() { + this._archive.centralOffset = this.offset; + this._entries.forEach( + function (ae) { + this._writeCentralFileHeader(ae); + }.bind(this), + ); + this._archive.centralLength = this.offset - this._archive.centralOffset; + if (this.isZip64()) { + this._writeCentralDirectoryZip64(); + } + this._writeCentralDirectoryEnd(); + this._archive.processing = false; + this._archive.finish = true; + this._archive.finished = true; + this.end(); } - process.once('end', handleStuff.bind(this)); - process.once('error', function(err) { - error = err; - }); - - process.pipe(this, { end: false }); - - return process; -}; - -ZipArchiveOutputStream.prototype._writeCentralDirectoryEnd = function() { - var records = this._entries.length; - var size = this._archive.centralLength; - var offset = this._archive.centralOffset; - - if (this.isZip64()) { - records = constants.ZIP64_MAGIC_SHORT; - size = constants.ZIP64_MAGIC; - offset = constants.ZIP64_MAGIC; + _normalizeEntry(ae) { + if (ae.getMethod() === -1) { + ae.setMethod(constants.METHOD_DEFLATED); + } + if (ae.getMethod() === constants.METHOD_DEFLATED) { + ae.getGeneralPurposeBit().useDataDescriptor(true); + ae.setVersionNeededToExtract(constants.MIN_VERSION_DATA_DESCRIPTOR); + } + if (ae.getTime() === -1) { + ae.setTime(new Date(), this._archive.forceLocalTime); + } + ae._offsets = { + file: 0, + data: 0, + contents: 0, + }; } - // signature - this.write(zipUtil.getLongBytes(constants.SIG_EOCD)); - - // disk numbers - this.write(constants.SHORT_ZERO); - this.write(constants.SHORT_ZERO); - - // number of entries - this.write(zipUtil.getShortBytes(records)); - this.write(zipUtil.getShortBytes(records)); - - // length and location of CD - this.write(zipUtil.getLongBytes(size)); - this.write(zipUtil.getLongBytes(offset)); - - // archive comment - var comment = this.getComment(); - var commentLength = Buffer.byteLength(comment); - this.write(zipUtil.getShortBytes(commentLength)); - this.write(comment); -}; - -ZipArchiveOutputStream.prototype._writeCentralDirectoryZip64 = function() { - // signature - this.write(zipUtil.getLongBytes(constants.SIG_ZIP64_EOCD)); - - // size of the ZIP64 EOCD record - this.write(zipUtil.getEightBytes(44)); - - // version made by - this.write(zipUtil.getShortBytes(constants.MIN_VERSION_ZIP64)); - - // version to extract - this.write(zipUtil.getShortBytes(constants.MIN_VERSION_ZIP64)); - - // disk numbers - this.write(constants.LONG_ZERO); - this.write(constants.LONG_ZERO); - - // number of entries - this.write(zipUtil.getEightBytes(this._entries.length)); - this.write(zipUtil.getEightBytes(this._entries.length)); - - // length and location of CD - this.write(zipUtil.getEightBytes(this._archive.centralLength)); - this.write(zipUtil.getEightBytes(this._archive.centralOffset)); - - // extensible data sector - // not implemented at this time - - // end of central directory locator - this.write(zipUtil.getLongBytes(constants.SIG_ZIP64_EOCD_LOC)); - - // disk number holding the ZIP64 EOCD record - this.write(constants.LONG_ZERO); - - // relative offset of the ZIP64 EOCD record - this.write(zipUtil.getEightBytes(this._archive.centralOffset + this._archive.centralLength)); - - // total number of disks - this.write(zipUtil.getLongBytes(1)); -}; - -ZipArchiveOutputStream.prototype._writeCentralFileHeader = function(ae) { - var gpb = ae.getGeneralPurposeBit(); - var method = ae.getMethod(); - var fileOffset = ae._offsets.file; - - var size = ae.getSize(); - var compressedSize = ae.getCompressedSize(); - - if (ae.isZip64() || fileOffset > constants.ZIP64_MAGIC) { - size = constants.ZIP64_MAGIC; - compressedSize = constants.ZIP64_MAGIC; - fileOffset = constants.ZIP64_MAGIC; - - ae.setVersionNeededToExtract(constants.MIN_VERSION_ZIP64); - - var extraBuf = Buffer.concat([ - zipUtil.getShortBytes(constants.ZIP64_EXTRA_ID), - zipUtil.getShortBytes(24), - zipUtil.getEightBytes(ae.getSize()), - zipUtil.getEightBytes(ae.getCompressedSize()), - zipUtil.getEightBytes(ae._offsets.file) - ], 28); - - ae.setExtra(extraBuf); + _smartStream(ae, callback) { + var deflate = ae.getMethod() === constants.METHOD_DEFLATED; + var process = deflate + ? new DeflateCRC32Stream(this.options.zlib) + : new CRC32Stream(); + var error = null; + function handleStuff() { + var digest = process.digest().readUInt32BE(0); + ae.setCrc(digest); + ae.setSize(process.size()); + ae.setCompressedSize(process.size(true)); + this._afterAppend(ae); + callback(error, ae); + } + process.once("end", handleStuff.bind(this)); + process.once("error", function (err) { + error = err; + }); + process.pipe(this, { end: false }); + return process; } - // signature - this.write(zipUtil.getLongBytes(constants.SIG_CFH)); - - // version made by - this.write(zipUtil.getShortBytes((ae.getPlatform() << 8) | constants.VERSION_MADEBY)); - - // version to extract and general bit flag - this.write(zipUtil.getShortBytes(ae.getVersionNeededToExtract())); - this.write(gpb.encode()); - - // compression method - this.write(zipUtil.getShortBytes(method)); - - // datetime - this.write(zipUtil.getLongBytes(ae.getTimeDos())); - - // crc32 checksum - this.write(zipUtil.getLongBytes(ae.getCrc())); - - // sizes - this.write(zipUtil.getLongBytes(compressedSize)); - this.write(zipUtil.getLongBytes(size)); - - var name = ae.getName(); - var comment = ae.getComment(); - var extra = ae.getCentralDirectoryExtra(); - - if (gpb.usesUTF8ForNames()) { - name = Buffer.from(name); - comment = Buffer.from(comment); + _writeCentralDirectoryEnd() { + var records = this._entries.length; + var size = this._archive.centralLength; + var offset = this._archive.centralOffset; + if (this.isZip64()) { + records = constants.ZIP64_MAGIC_SHORT; + size = constants.ZIP64_MAGIC; + offset = constants.ZIP64_MAGIC; + } + // signature + this.write(zipUtil.getLongBytes(constants.SIG_EOCD)); + // disk numbers + this.write(constants.SHORT_ZERO); + this.write(constants.SHORT_ZERO); + // number of entries + this.write(zipUtil.getShortBytes(records)); + this.write(zipUtil.getShortBytes(records)); + // length and location of CD + this.write(zipUtil.getLongBytes(size)); + this.write(zipUtil.getLongBytes(offset)); + // archive comment + var comment = this.getComment(); + var commentLength = Buffer.byteLength(comment); + this.write(zipUtil.getShortBytes(commentLength)); + this.write(comment); } - // name length - this.write(zipUtil.getShortBytes(name.length)); - - // extra length - this.write(zipUtil.getShortBytes(extra.length)); - - // comments length - this.write(zipUtil.getShortBytes(comment.length)); - - // disk number start - this.write(constants.SHORT_ZERO); - - // internal attributes - this.write(zipUtil.getShortBytes(ae.getInternalAttributes())); - - // external attributes - this.write(zipUtil.getLongBytes(ae.getExternalAttributes())); - - // relative offset of LFH - this.write(zipUtil.getLongBytes(fileOffset)); - - // name - this.write(name); - - // extra - this.write(extra); - - // comment - this.write(comment); -}; - -ZipArchiveOutputStream.prototype._writeDataDescriptor = function(ae) { - // signature - this.write(zipUtil.getLongBytes(constants.SIG_DD)); - - // crc32 checksum - this.write(zipUtil.getLongBytes(ae.getCrc())); - - // sizes - if (ae.isZip64()) { - this.write(zipUtil.getEightBytes(ae.getCompressedSize())); - this.write(zipUtil.getEightBytes(ae.getSize())); - } else { - this.write(zipUtil.getLongBytes(ae.getCompressedSize())); - this.write(zipUtil.getLongBytes(ae.getSize())); - } -}; - -ZipArchiveOutputStream.prototype._writeLocalFileHeader = function(ae) { - var gpb = ae.getGeneralPurposeBit(); - var method = ae.getMethod(); - var name = ae.getName(); - var extra = ae.getLocalFileDataExtra(); - - if (ae.isZip64()) { - gpb.useDataDescriptor(true); - ae.setVersionNeededToExtract(constants.MIN_VERSION_ZIP64); - } - - if (gpb.usesUTF8ForNames()) { - name = Buffer.from(name); - } - - ae._offsets.file = this.offset; - - // signature - this.write(zipUtil.getLongBytes(constants.SIG_LFH)); - - // version to extract and general bit flag - this.write(zipUtil.getShortBytes(ae.getVersionNeededToExtract())); - this.write(gpb.encode()); - - // compression method - this.write(zipUtil.getShortBytes(method)); - - // datetime - this.write(zipUtil.getLongBytes(ae.getTimeDos())); - - ae._offsets.data = this.offset; - - // crc32 checksum and sizes - if (gpb.usesDataDescriptor()) { + _writeCentralDirectoryZip64() { + // signature + this.write(zipUtil.getLongBytes(constants.SIG_ZIP64_EOCD)); + // size of the ZIP64 EOCD record + this.write(zipUtil.getEightBytes(44)); + // version made by + this.write(zipUtil.getShortBytes(constants.MIN_VERSION_ZIP64)); + // version to extract + this.write(zipUtil.getShortBytes(constants.MIN_VERSION_ZIP64)); + // disk numbers this.write(constants.LONG_ZERO); this.write(constants.LONG_ZERO); + // number of entries + this.write(zipUtil.getEightBytes(this._entries.length)); + this.write(zipUtil.getEightBytes(this._entries.length)); + // length and location of CD + this.write(zipUtil.getEightBytes(this._archive.centralLength)); + this.write(zipUtil.getEightBytes(this._archive.centralOffset)); + // extensible data sector + // not implemented at this time + // end of central directory locator + this.write(zipUtil.getLongBytes(constants.SIG_ZIP64_EOCD_LOC)); + // disk number holding the ZIP64 EOCD record this.write(constants.LONG_ZERO); - } else { - this.write(zipUtil.getLongBytes(ae.getCrc())); - this.write(zipUtil.getLongBytes(ae.getCompressedSize())); - this.write(zipUtil.getLongBytes(ae.getSize())); + // relative offset of the ZIP64 EOCD record + this.write( + zipUtil.getEightBytes( + this._archive.centralOffset + this._archive.centralLength, + ), + ); + // total number of disks + this.write(zipUtil.getLongBytes(1)); } - // name length - this.write(zipUtil.getShortBytes(name.length)); - - // extra length - this.write(zipUtil.getShortBytes(extra.length)); - - // name - this.write(name); + _writeCentralFileHeader(ae) { + var gpb = ae.getGeneralPurposeBit(); + var method = ae.getMethod(); + var fileOffset = ae._offsets.file; + var size = ae.getSize(); + var compressedSize = ae.getCompressedSize(); + if (ae.isZip64() || fileOffset > constants.ZIP64_MAGIC) { + size = constants.ZIP64_MAGIC; + compressedSize = constants.ZIP64_MAGIC; + fileOffset = constants.ZIP64_MAGIC; + ae.setVersionNeededToExtract(constants.MIN_VERSION_ZIP64); + var extraBuf = Buffer.concat( + [ + zipUtil.getShortBytes(constants.ZIP64_EXTRA_ID), + zipUtil.getShortBytes(24), + zipUtil.getEightBytes(ae.getSize()), + zipUtil.getEightBytes(ae.getCompressedSize()), + zipUtil.getEightBytes(ae._offsets.file), + ], + 28, + ); + ae.setExtra(extraBuf); + } + // signature + this.write(zipUtil.getLongBytes(constants.SIG_CFH)); + // version made by + this.write( + zipUtil.getShortBytes((ae.getPlatform() << 8) | constants.VERSION_MADEBY), + ); + // version to extract and general bit flag + this.write(zipUtil.getShortBytes(ae.getVersionNeededToExtract())); + this.write(gpb.encode()); + // compression method + this.write(zipUtil.getShortBytes(method)); + // datetime + this.write(zipUtil.getLongBytes(ae.getTimeDos())); + // crc32 checksum + this.write(zipUtil.getLongBytes(ae.getCrc())); + // sizes + this.write(zipUtil.getLongBytes(compressedSize)); + this.write(zipUtil.getLongBytes(size)); + var name = ae.getName(); + var comment = ae.getComment(); + var extra = ae.getCentralDirectoryExtra(); + if (gpb.usesUTF8ForNames()) { + name = Buffer.from(name); + comment = Buffer.from(comment); + } + // name length + this.write(zipUtil.getShortBytes(name.length)); + // extra length + this.write(zipUtil.getShortBytes(extra.length)); + // comments length + this.write(zipUtil.getShortBytes(comment.length)); + // disk number start + this.write(constants.SHORT_ZERO); + // internal attributes + this.write(zipUtil.getShortBytes(ae.getInternalAttributes())); + // external attributes + this.write(zipUtil.getLongBytes(ae.getExternalAttributes())); + // relative offset of LFH + this.write(zipUtil.getLongBytes(fileOffset)); + // name + this.write(name); + // extra + this.write(extra); + // comment + this.write(comment); + } - // extra - this.write(extra); + _writeDataDescriptor(ae) { + // signature + this.write(zipUtil.getLongBytes(constants.SIG_DD)); + // crc32 checksum + this.write(zipUtil.getLongBytes(ae.getCrc())); + // sizes + if (ae.isZip64()) { + this.write(zipUtil.getEightBytes(ae.getCompressedSize())); + this.write(zipUtil.getEightBytes(ae.getSize())); + } else { + this.write(zipUtil.getLongBytes(ae.getCompressedSize())); + this.write(zipUtil.getLongBytes(ae.getSize())); + } + } - ae._offsets.contents = this.offset; -}; + _writeLocalFileHeader(ae) { + var gpb = ae.getGeneralPurposeBit(); + var method = ae.getMethod(); + var name = ae.getName(); + var extra = ae.getLocalFileDataExtra(); + if (ae.isZip64()) { + gpb.useDataDescriptor(true); + ae.setVersionNeededToExtract(constants.MIN_VERSION_ZIP64); + } + if (gpb.usesUTF8ForNames()) { + name = Buffer.from(name); + } + ae._offsets.file = this.offset; + // signature + this.write(zipUtil.getLongBytes(constants.SIG_LFH)); + // version to extract and general bit flag + this.write(zipUtil.getShortBytes(ae.getVersionNeededToExtract())); + this.write(gpb.encode()); + // compression method + this.write(zipUtil.getShortBytes(method)); + // datetime + this.write(zipUtil.getLongBytes(ae.getTimeDos())); + ae._offsets.data = this.offset; + // crc32 checksum and sizes + if (gpb.usesDataDescriptor()) { + this.write(constants.LONG_ZERO); + this.write(constants.LONG_ZERO); + this.write(constants.LONG_ZERO); + } else { + this.write(zipUtil.getLongBytes(ae.getCrc())); + this.write(zipUtil.getLongBytes(ae.getCompressedSize())); + this.write(zipUtil.getLongBytes(ae.getSize())); + } + // name length + this.write(zipUtil.getShortBytes(name.length)); + // extra length + this.write(zipUtil.getShortBytes(extra.length)); + // name + this.write(name); + // extra + this.write(extra); + ae._offsets.contents = this.offset; + } -ZipArchiveOutputStream.prototype.getComment = function(comment) { - return this._archive.comment !== null ? this._archive.comment : ''; -}; + getComment(comment) { + return this._archive.comment !== null ? this._archive.comment : ""; + } -ZipArchiveOutputStream.prototype.isZip64 = function() { - return this._archive.forceZip64 || this._entries.length > constants.ZIP64_MAGIC_SHORT || this._archive.centralLength > constants.ZIP64_MAGIC || this._archive.centralOffset > constants.ZIP64_MAGIC; -}; + isZip64() { + return ( + this._archive.forceZip64 || + this._entries.length > constants.ZIP64_MAGIC_SHORT || + this._archive.centralLength > constants.ZIP64_MAGIC || + this._archive.centralOffset > constants.ZIP64_MAGIC + ); + } -ZipArchiveOutputStream.prototype.setComment = function(comment) { - this._archive.comment = comment; -}; + setComment(comment) { + this._archive.comment = comment; + } +} diff --git a/lib/compress-commons.js b/lib/compress-commons.js index ef3bc1db..37a01a7b 100644 --- a/lib/compress-commons.js +++ b/lib/compress-commons.js @@ -1,13 +1,11 @@ -/** - * node-compress-commons - * - * Copyright (c) 2014 Chris Talkington, contributors. - * Licensed under the MIT license. - * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT - */ -module.exports = { - ArchiveEntry: require('./archivers/archive-entry'), - ZipArchiveEntry: require('./archivers/zip/zip-archive-entry'), - ArchiveOutputStream: require('./archivers/archive-output-stream'), - ZipArchiveOutputStream: require('./archivers/zip/zip-archive-output-stream') -}; \ No newline at end of file +import ArchiveEntry from "./archivers/archive-entry.js"; +import ZipArchiveEntry from "./archivers/zip/zip-archive-entry.js"; +import ArchiveOutputStream from "./archivers/archive-output-stream.js"; +import ZipArchiveOutputStream from "./archivers/zip/zip-archive-output-stream.js"; + +export default { + ArchiveEntry, + ZipArchiveEntry, + ArchiveOutputStream, + ZipArchiveOutputStream, +}; diff --git a/lib/util/index.js b/lib/util/index.js index 0fcc60f9..0c8a6289 100644 --- a/lib/util/index.js +++ b/lib/util/index.js @@ -1,27 +1,20 @@ -/** - * node-compress-commons - * - * Copyright (c) 2014 Chris Talkington, contributors. - * Licensed under the MIT license. - * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT - */ -var Stream = require('stream').Stream; -var PassThrough = require('readable-stream').PassThrough; -var isStream = require('is-stream'); +import { Stream } from "stream"; +import { PassThrough } from "readable-stream"; +import { isStream } from "is-stream"; -var util = module.exports = {}; - -util.normalizeInputSource = function(source) { +export function normalizeInputSource(source) { if (source === null) { return Buffer.alloc(0); - } else if (typeof source === 'string') { + } else if (typeof source === "string") { return Buffer.from(source); } else if (isStream(source) && !source._readableState) { var normalized = new PassThrough(); source.pipe(normalized); - return normalized; } - return source; -}; \ No newline at end of file +} + +export default { + normalizeInputSource, +}; diff --git a/package-lock.json b/package-lock.json index 44237e97..26940e47 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,7 +1,7 @@ { "name": "compress-commons", "version": "6.0.2", - "lockfileVersion": 2, + "lockfileVersion": 3, "requires": true, "packages": { "": { @@ -10,8 +10,8 @@ "license": "MIT", "dependencies": { "crc-32": "^1.2.0", - "crc32-stream": "^6.0.0", - "is-stream": "^2.0.1", + "crc32-stream": "^7.0.0", + "is-stream": "^3.0.0", "normalize-path": "^3.0.0", "readable-stream": "^4.0.0" }, @@ -19,10 +19,11 @@ "chai": "4.5.0", "mkdirp": "3.0.1", "mocha": "10.7.3", + "prettier": "3.3.3", "rimraf": "5.0.10" }, "engines": { - "node": ">= 14" + "node": ">=18" } }, "node_modules/@isaacs/cliui": { @@ -42,6 +43,18 @@ "node": ">=12" } }, + "node_modules/@isaacs/cliui/node_modules/ansi-regex": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, "node_modules/@isaacs/cliui/node_modules/ansi-styles": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", @@ -54,6 +67,44 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/@isaacs/cliui/node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true + }, + "node_modules/@isaacs/cliui/node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@isaacs/cliui/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", @@ -102,15 +153,12 @@ } }, "node_modules/ansi-regex": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true, "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" + "node": ">=8" } }, "node_modules/ansi-styles": { @@ -129,9 +177,9 @@ } }, "node_modules/anymatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", - "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", "dev": true, "dependencies": { "normalize-path": "^3.0.0", @@ -157,9 +205,9 @@ } }, "node_modules/balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, "node_modules/base64-js": { @@ -182,12 +230,15 @@ ] }, "node_modules/binary-extensions": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", "dev": true, "engines": { "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/brace-expansion": { @@ -241,9 +292,9 @@ } }, "node_modules/camelcase": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", - "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", "dev": true, "engines": { "node": ">=10" @@ -271,9 +322,9 @@ } }, "node_modules/chalk": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", - "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, "dependencies": { "ansi-styles": "^4.1.0", @@ -311,16 +362,10 @@ } }, "node_modules/chokidar": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", - "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - ], "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", @@ -333,6 +378,9 @@ "engines": { "node": ">= 8.10.0" }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, "optionalDependencies": { "fsevents": "~2.3.2" } @@ -348,41 +396,6 @@ "wrap-ansi": "^7.0.0" } }, - "node_modules/cliui/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui/node_modules/string-width": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", - "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui/node_modules/strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -413,15 +426,15 @@ } }, "node_modules/crc32-stream": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-6.0.0.tgz", - "integrity": "sha512-piICUB6ei4IlTv1+653yq5+KoqfBYmj9bw6LqXoOneTMDXk5nM1qt12mFW1caG3LlJXEKW1Bp0WggEmIfQB34g==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-7.0.0.tgz", + "integrity": "sha512-AmoDf2Lqvp3Eyq9LQszEcIMqPVNogMQHgSN1NbV70S+8NbDstYKW61ujNrmjiCgNpJHNpZ4bnOuC3yD6SUo7Vg==", "dependencies": { "crc-32": "^1.2.0", "readable-stream": "^4.0.0" }, "engines": { - "node": ">= 14" + "node": ">=18" } }, "node_modules/cross-spawn": { @@ -468,9 +481,9 @@ } }, "node_modules/deep-eql": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", - "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.4.tgz", + "integrity": "sha512-SUwdGfqdKOwxCPeVYjwSyRpJ7Z+fhpwIAtmCUdZIWZ/YP5R9WAsyuSgpLVDi9bjWoN2LXHNss/dk3urXtdQxGg==", "dev": true, "dependencies": { "type-detect": "^4.0.0" @@ -501,9 +514,9 @@ "dev": true }, "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", "dev": true, "engines": { "node": ">=6" @@ -575,9 +588,9 @@ } }, "node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", + "integrity": "sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==", "dev": true, "dependencies": { "cross-spawn": "^7.0.0", @@ -593,13 +606,13 @@ "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "dev": true, "hasInstallScript": true, "optional": true, @@ -632,6 +645,7 @@ "version": "8.1.0", "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "deprecated": "Glob versions prior to v9 are no longer supported", "dev": true, "dependencies": { "fs.realpath": "^1.0.0", @@ -699,7 +713,8 @@ "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", "dev": true, "dependencies": { "once": "^1.3.0", @@ -727,7 +742,7 @@ "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true, "engines": { "node": ">=0.10.0" @@ -743,9 +758,9 @@ } }, "node_modules/is-glob": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", - "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "dev": true, "dependencies": { "is-extglob": "^2.1.1" @@ -773,11 +788,11 @@ } }, "node_modules/is-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", + "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", "engines": { - "node": ">=8" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -798,20 +813,17 @@ "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, "node_modules/jackspeak": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.2.3.tgz", - "integrity": "sha512-htOzIMPbpLid/Gq9/zaz9SfExABxqRe1sSCdxntlO/aMD6u0issZQiY25n2GKQUtJ02j7z5sfptlAOMpWWOmvw==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", "dev": true, "dependencies": { "@isaacs/cliui": "^8.0.2" }, - "engines": { - "node": ">=14" - }, "funding": { "url": "https://github.com/sponsors/isaacs" }, @@ -863,22 +875,19 @@ } }, "node_modules/loupe": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", - "integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==", + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz", + "integrity": "sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==", "dev": true, "dependencies": { - "get-func-name": "^2.0.0" + "get-func-name": "^2.0.1" } }, "node_modules/lru-cache": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.0.tgz", - "integrity": "sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==", - "dev": true, - "engines": { - "node": "14 || >=16.14" - } + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true }, "node_modules/minimatch": { "version": "5.1.6", @@ -968,7 +977,7 @@ "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, "dependencies": { "wrappy": "1" @@ -1054,9 +1063,9 @@ } }, "node_modules/picomatch": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", - "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true, "engines": { "node": ">=8.6" @@ -1065,6 +1074,21 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/prettier": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", @@ -1112,7 +1136,7 @@ "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", "dev": true, "engines": { "node": ">=0.10.0" @@ -1238,20 +1262,17 @@ } }, "node_modules/string-width": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", - "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, "dependencies": { - "eastasianwidth": "^0.2.0", - "emoji-regex": "^9.2.2", - "strip-ansi": "^7.0.1" + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" }, "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">=8" } }, "node_modules/string-width-cjs": { @@ -1269,16 +1290,7 @@ "node": ">=8" } }, - "node_modules/string-width-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/string-width-cjs/node_modules/strip-ansi": { + "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", @@ -1290,27 +1302,6 @@ "node": ">=8" } }, - "node_modules/string-width/node_modules/emoji-regex": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "dev": true - }, - "node_modules/strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, "node_modules/strip-ansi-cjs": { "name": "strip-ansi", "version": "6.0.1", @@ -1324,15 +1315,6 @@ "node": ">=8" } }, - "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", @@ -1437,80 +1419,10 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi/node_modules/string-width": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", - "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi/node_modules/strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, "node_modules/y18n": { @@ -1564,41 +1476,6 @@ "node": ">=10" } }, - "node_modules/yargs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/string-width": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", - "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", @@ -1611,1105 +1488,5 @@ "url": "https://github.com/sponsors/sindresorhus" } } - }, - "dependencies": { - "@isaacs/cliui": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", - "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", - "dev": true, - "requires": { - "string-width": "^5.1.2", - "string-width-cjs": "npm:string-width@^4.2.0", - "strip-ansi": "^7.0.1", - "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", - "wrap-ansi": "^8.1.0", - "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", - "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", - "dev": true - }, - "wrap-ansi": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", - "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", - "dev": true, - "requires": { - "ansi-styles": "^6.1.0", - "string-width": "^5.0.1", - "strip-ansi": "^7.0.1" - } - } - } - }, - "@pkgjs/parseargs": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", - "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", - "dev": true, - "optional": true - }, - "abort-controller": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", - "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", - "requires": { - "event-target-shim": "^5.0.0" - } - }, - "ansi-colors": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", - "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", - "dev": true - }, - "ansi-regex": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", - "dev": true - }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "anymatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", - "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", - "dev": true, - "requires": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - } - }, - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - }, - "assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", - "dev": true - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" - }, - "binary-extensions": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", - "dev": true - }, - "brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0" - } - }, - "braces": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", - "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", - "dev": true, - "requires": { - "fill-range": "^7.1.1" - } - }, - "browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true - }, - "buffer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "requires": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, - "camelcase": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", - "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==", - "dev": true - }, - "chai": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.5.0.tgz", - "integrity": "sha512-RITGBfijLkBddZvnn8jdqoTypxvqbOLYQkGGxXzeFjVHvudaPw0HNFD9x928/eUwYWd2dPCugVqspGALTZZQKw==", - "dev": true, - "requires": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.3", - "deep-eql": "^4.1.3", - "get-func-name": "^2.0.2", - "loupe": "^2.3.6", - "pathval": "^1.1.1", - "type-detect": "^4.1.0" - } - }, - "chalk": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", - "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "dependencies": { - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "check-error": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", - "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==", - "dev": true, - "requires": { - "get-func-name": "^2.0.2" - } - }, - "chokidar": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", - "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", - "dev": true, - "requires": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "fsevents": "~2.3.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - } - }, - "cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "dev": true, - "requires": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "string-width": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", - "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - } - }, - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.0" - } - } - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "crc-32": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", - "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==" - }, - "crc32-stream": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-6.0.0.tgz", - "integrity": "sha512-piICUB6ei4IlTv1+653yq5+KoqfBYmj9bw6LqXoOneTMDXk5nM1qt12mFW1caG3LlJXEKW1Bp0WggEmIfQB34g==", - "requires": { - "crc-32": "^1.2.0", - "readable-stream": "^4.0.0" - } - }, - "cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "requires": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - } - }, - "debug": { - "version": "4.3.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", - "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", - "dev": true, - "requires": { - "ms": "^2.1.3" - } - }, - "decamelize": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", - "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", - "dev": true - }, - "deep-eql": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", - "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", - "dev": true, - "requires": { - "type-detect": "^4.0.0" - } - }, - "diff": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", - "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", - "dev": true - }, - "eastasianwidth": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", - "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", - "dev": true - }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "dev": true - }, - "escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true - }, - "event-target-shim": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", - "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==" - }, - "events": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", - "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==" - }, - "fill-range": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", - "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", - "dev": true, - "requires": { - "to-regex-range": "^5.0.1" - } - }, - "find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "requires": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - } - }, - "flat": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", - "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", - "dev": true - }, - "foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", - "dev": true, - "requires": { - "cross-spawn": "^7.0.0", - "signal-exit": "^4.0.1" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "optional": true - }, - "get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true - }, - "get-func-name": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", - "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", - "dev": true - }, - "glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" - } - }, - "glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "requires": { - "is-glob": "^4.0.1" - } - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", - "dev": true - }, - "ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "requires": { - "binary-extensions": "^2.0.0" - } - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "is-glob": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", - "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", - "dev": true, - "requires": { - "is-extglob": "^2.1.1" - } - }, - "is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true - }, - "is-plain-obj": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", - "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", - "dev": true - }, - "is-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==" - }, - "is-unicode-supported": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", - "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", - "dev": true - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true - }, - "jackspeak": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.2.3.tgz", - "integrity": "sha512-htOzIMPbpLid/Gq9/zaz9SfExABxqRe1sSCdxntlO/aMD6u0issZQiY25n2GKQUtJ02j7z5sfptlAOMpWWOmvw==", - "dev": true, - "requires": { - "@isaacs/cliui": "^8.0.2", - "@pkgjs/parseargs": "^0.11.0" - } - }, - "js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, - "requires": { - "argparse": "^2.0.1" - } - }, - "locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "requires": { - "p-locate": "^5.0.0" - } - }, - "log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", - "dev": true, - "requires": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" - } - }, - "loupe": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", - "integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==", - "dev": true, - "requires": { - "get-func-name": "^2.0.0" - } - }, - "lru-cache": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.0.tgz", - "integrity": "sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==", - "dev": true - }, - "minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", - "dev": true, - "requires": { - "brace-expansion": "^2.0.1" - } - }, - "minipass": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", - "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", - "dev": true - }, - "mkdirp": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz", - "integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==", - "dev": true - }, - "mocha": { - "version": "10.7.3", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.7.3.tgz", - "integrity": "sha512-uQWxAu44wwiACGqjbPYmjo7Lg8sFrS3dQe7PP2FQI+woptP4vZXSMcfMyFL/e1yFEeEpV4RtyTpZROOKmxis+A==", - "dev": true, - "requires": { - "ansi-colors": "^4.1.3", - "browser-stdout": "^1.3.1", - "chokidar": "^3.5.3", - "debug": "^4.3.5", - "diff": "^5.2.0", - "escape-string-regexp": "^4.0.0", - "find-up": "^5.0.0", - "glob": "^8.1.0", - "he": "^1.2.0", - "js-yaml": "^4.1.0", - "log-symbols": "^4.1.0", - "minimatch": "^5.1.6", - "ms": "^2.1.3", - "serialize-javascript": "^6.0.2", - "strip-json-comments": "^3.1.1", - "supports-color": "^8.1.1", - "workerpool": "^6.5.1", - "yargs": "^16.2.0", - "yargs-parser": "^20.2.9", - "yargs-unparser": "^2.0.0" - } - }, - "ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true - }, - "normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "requires": { - "yocto-queue": "^0.1.0" - } - }, - "p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, - "requires": { - "p-limit": "^3.0.2" - } - }, - "package-json-from-dist": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", - "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", - "dev": true - }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - }, - "path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true - }, - "path-scurry": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", - "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", - "dev": true, - "requires": { - "lru-cache": "^10.2.0", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" - } - }, - "pathval": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", - "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", - "dev": true - }, - "picomatch": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", - "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", - "dev": true - }, - "process": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==" - }, - "randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "dev": true, - "requires": { - "safe-buffer": "^5.1.0" - } - }, - "readable-stream": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz", - "integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==", - "requires": { - "abort-controller": "^3.0.0", - "buffer": "^6.0.3", - "events": "^3.3.0", - "process": "^0.11.10", - "string_decoder": "^1.3.0" - } - }, - "readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "requires": { - "picomatch": "^2.2.1" - } - }, - "require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", - "dev": true - }, - "rimraf": { - "version": "5.0.10", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.10.tgz", - "integrity": "sha512-l0OE8wL34P4nJH/H2ffoaniAokM2qSmrtXHmlpvYr5AVVX8msAyW0l8NVJFDxlSK4u3Uh/f41cQheDVdnYijwQ==", - "dev": true, - "requires": { - "glob": "^10.3.7" - }, - "dependencies": { - "glob": { - "version": "10.4.5", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", - "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", - "dev": true, - "requires": { - "foreground-child": "^3.1.0", - "jackspeak": "^3.1.2", - "minimatch": "^9.0.4", - "minipass": "^7.1.2", - "package-json-from-dist": "^1.0.0", - "path-scurry": "^1.11.1" - } - }, - "minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", - "dev": true, - "requires": { - "brace-expansion": "^2.0.1" - } - } - } - }, - "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" - }, - "serialize-javascript": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", - "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", - "dev": true, - "requires": { - "randombytes": "^2.1.0" - } - }, - "shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "requires": { - "shebang-regex": "^3.0.0" - } - }, - "shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true - }, - "signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true - }, - "string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "requires": { - "safe-buffer": "~5.2.0" - } - }, - "string-width": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", - "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", - "dev": true, - "requires": { - "eastasianwidth": "^0.2.0", - "emoji-regex": "^9.2.2", - "strip-ansi": "^7.0.1" - }, - "dependencies": { - "emoji-regex": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "dev": true - } - } - }, - "string-width-cjs": { - "version": "npm:string-width@4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - } - } - }, - "strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, - "requires": { - "ansi-regex": "^6.0.1" - } - }, - "strip-ansi-cjs": { - "version": "npm:strip-ansi@6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - } - } - }, - "strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true - }, - "supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "requires": { - "is-number": "^7.0.0" - } - }, - "type-detect": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.1.0.tgz", - "integrity": "sha512-Acylog8/luQ8L7il+geoSxhEkazvkslg7PSNKOX59mbB9cOveP5aq9h74Y7YU8yDpJwetzQQrfIwtf4Wp4LKcw==", - "dev": true - }, - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - }, - "workerpool": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", - "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==", - "dev": true - }, - "wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "string-width": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", - "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - } - }, - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.0" - } - } - } - }, - "wrap-ansi-cjs": { - "version": "npm:wrap-ansi@7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, - "strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - } - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true - }, - "yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", - "dev": true, - "requires": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.0", - "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "string-width": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", - "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - } - }, - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.0" - } - } - } - }, - "yargs-parser": { - "version": "20.2.9", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", - "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", - "dev": true - }, - "yargs-unparser": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", - "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", - "dev": true, - "requires": { - "camelcase": "^6.0.0", - "decamelize": "^4.0.0", - "flat": "^5.0.2", - "is-plain-obj": "^2.1.0" - } - }, - "yocto-queue": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", - "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", - "dev": true - } } } diff --git a/package.json b/package.json index b06ef1d6..d09d199d 100644 --- a/package.json +++ b/package.json @@ -15,20 +15,21 @@ "url": "https://github.com/archiverjs/node-compress-commons/issues" }, "license": "MIT", - "main": "lib/compress-commons.js", + "type": "module", + "exports": "./lib/compress-commons.js", "files": [ "lib" ], "engines": { - "node": ">= 14" + "node": ">=18" }, "scripts": { "test": "mocha --reporter dot" }, "dependencies": { "crc-32": "^1.2.0", - "crc32-stream": "^6.0.0", - "is-stream": "^2.0.1", + "crc32-stream": "^7.0.0", + "is-stream": "^3.0.0", "normalize-path": "^3.0.0", "readable-stream": "^4.0.0" }, @@ -36,6 +37,7 @@ "chai": "4.5.0", "mkdirp": "3.0.1", "mocha": "10.7.3", + "prettier": "3.3.3", "rimraf": "5.0.10" }, "keywords": [ diff --git a/renovate.json b/renovate.json index eaade136..6c1db837 100644 --- a/renovate.json +++ b/renovate.json @@ -1,10 +1,6 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "config:base", - "schedule:daily", - ":pinDevDependencies" - ], + "extends": ["config:base", "schedule:daily", ":pinDevDependencies"], "timezone": "America/Chicago", "labels": ["dependencies"], "packageRules": [ diff --git a/test/archive-output-stream.js b/test/archive-output-stream.js index 29a27b13..f13dcb1b 100644 --- a/test/archive-output-stream.js +++ b/test/archive-output-stream.js @@ -1,18 +1,8 @@ -/*global before,describe,it */ -var fs = require('fs'); -var assert = require('chai').assert; -var mkdir = require('mkdirp'); - -var helpers = require('./helpers'); - -var commons = require('../lib/compress-commons'); - -var testBuffer = helpers.binaryBuffer(1024 * 16); - -describe('ArchiveOutputStream', function() { - - describe('#entry', function() { - - }); - -}); \ No newline at end of file +import fs from "fs"; +import { assert } from "chai"; +import { binaryBuffer } from "./helpers/index.js"; + +var testBuffer = binaryBuffer(1024 * 16); +describe("ArchiveOutputStream", function () { + describe("#entry", function () {}); +}); diff --git a/test/commons.js b/test/commons.js index 99bbd7d8..13a5b82c 100644 --- a/test/commons.js +++ b/test/commons.js @@ -1,10 +1,7 @@ +import { assert } from "chai"; /*global before,describe,it */ -var assert = require('chai').assert; -var commons = require('../lib/compress-commons'); - -describe('commons', function() { +describe("commons", function () { // it('will do something some day', function(){ // }); - -}); \ No newline at end of file +}); diff --git a/test/general-purpose-bit.js b/test/general-purpose-bit.js index eb87590b..7a427115 100644 --- a/test/general-purpose-bit.js +++ b/test/general-purpose-bit.js @@ -1,98 +1,55 @@ +import { assert } from "chai"; +import GeneralPurposeBit from "../lib/archivers/zip/general-purpose-bit.js"; /*global before,describe,it */ -var assert = require('chai').assert; -var GeneralPurposeBit = require('../lib/archivers/zip/general-purpose-bit'); var gpb; - -describe('GeneralPurposeBit', function() { - - beforeEach(function() { +describe("GeneralPurposeBit", function () { + beforeEach(function () { gpb = new GeneralPurposeBit(); }); - - describe('#encode', function() { - it('should return a Buffer', function(){ + describe("#encode", function () { + it("should return a Buffer", function () { gpb.useDataDescriptor(); assert.ok(Buffer.isBuffer(gpb.encode())); }); }); - - describe('#parse', function() { - it.skip('should be tested', function() { - - }); + describe("#parse", function () { + it.skip("should be tested", function () {}); }); - - describe('#setNumberOfShannonFanoTrees', function() { - it.skip('should be tested', function() { - - }); + describe("#setNumberOfShannonFanoTrees", function () { + it.skip("should be tested", function () {}); }); - - describe('#getNumberOfShannonFanoTrees', function() { - it.skip('should be tested', function() { - - }); + describe("#getNumberOfShannonFanoTrees", function () { + it.skip("should be tested", function () {}); }); - - describe('#setSlidingDictionarySize', function() { - it.skip('should be tested', function() { - - }); + describe("#setSlidingDictionarySize", function () { + it.skip("should be tested", function () {}); }); - - describe('#getSlidingDictionarySize', function() { - it.skip('should be tested', function() { - - }); + describe("#getSlidingDictionarySize", function () { + it.skip("should be tested", function () {}); }); - - describe('#useDataDescriptor', function() { - it.skip('should be tested', function() { - - }); + describe("#useDataDescriptor", function () { + it.skip("should be tested", function () {}); }); - - describe('#usesDataDescriptor', function() { - it.skip('should be tested', function() { - - }); + describe("#usesDataDescriptor", function () { + it.skip("should be tested", function () {}); }); - - describe('#useEncryption', function() { - it.skip('should be tested', function() { - - }); + describe("#useEncryption", function () { + it.skip("should be tested", function () {}); }); - - describe('#usesEncryption', function() { - it.skip('should be tested', function() { - - }); + describe("#usesEncryption", function () { + it.skip("should be tested", function () {}); }); - - describe('#useStrongEncryption', function() { - it.skip('should be tested', function() { - - }); + describe("#useStrongEncryption", function () { + it.skip("should be tested", function () {}); }); - - describe('#usesStrongEncryption', function() { - it.skip('should be tested', function() { - - }); + describe("#usesStrongEncryption", function () { + it.skip("should be tested", function () {}); }); - - describe('#useUTF8ForNames', function() { - it.skip('should be tested', function() { - - }); + describe("#useUTF8ForNames", function () { + it.skip("should be tested", function () {}); }); - - describe('#usesUTF8ForNames', function() { - it.skip('should be tested', function() { - - }); + describe("#usesUTF8ForNames", function () { + it.skip("should be tested", function () {}); }); - -}); \ No newline at end of file +}); diff --git a/test/helpers/index.js b/test/helpers/index.js index c4eb5514..9c23f52c 100644 --- a/test/helpers/index.js +++ b/test/helpers/index.js @@ -1,87 +1,67 @@ -var crypto = require('crypto'); -var fs = require('fs'); -var inherits = require('util').inherits; - -var Stream = require('stream').Stream; -var Readable = require('readable-stream').Readable; -var Writable = require('readable-stream').Writable; - -function binaryBuffer(n) { +import crypto from "crypto"; +import { WriteStream } from "fs"; +import { inherits } from "util"; +import { Stream } from "stream"; +import { Readable } from "readable-stream"; +import { Writable } from "readable-stream"; + +export function binaryBuffer(n) { var buffer = Buffer.alloc(n); - for (var i = 0; i < n; i++) { - buffer.writeUInt8(i&255, i); + buffer.writeUInt8(i & 255, i); } - return buffer; } -module.exports.binaryBuffer = binaryBuffer; - -function BinaryStream(size, options) { - Readable.call(this, options); - - var buf = Buffer.alloc(size); - - for (var i = 0; i < size; i++) { - buf.writeUInt8(i&255, i); +export class BinaryStream extends Readable { + constructor(size, options) { + super(options); + var buf = Buffer.alloc(size); + for (var i = 0; i < size; i++) { + buf.writeUInt8(i & 255, i); + } + this.push(buf); + this.push(null); } - this.push(buf); - this.push(null); + _read(size) {} } -inherits(BinaryStream, Readable); - -BinaryStream.prototype._read = function(size) {}; - -module.exports.BinaryStream = BinaryStream; +export class DeadEndStream extends Writable { + constructor(options) { + super(options); + } -function DeadEndStream(options) { - Writable.call(this, options); + _write(chuck, encoding, callback) { + callback(); + } } -inherits(DeadEndStream, Writable); - -DeadEndStream.prototype._write = function(chuck, encoding, callback) { - callback(); -}; - -module.exports.DeadEndStream = DeadEndStream; - -function fileBuffer(filepath) { +export function fileBuffer(filepath) { return fs.readFileSync(filepath); } -module.exports.fileBuffer = fileBuffer; - -function UnBufferedStream() { - this.readable = true; -} - -inherits(UnBufferedStream, Stream); - -module.exports.UnBufferedStream = UnBufferedStream; - -function WriteHashStream(path, options) { - fs.WriteStream.call(this, path, options); - - this.hash = crypto.createHash('sha1'); - this.digest = null; - - this.on('close', function() { - this.digest = this.hash.digest('hex'); - }); +export class UnBufferedStream extends Stream { + constructor() { + super(); + this.readable = true; + } } -inherits(WriteHashStream, fs.WriteStream); - -WriteHashStream.prototype.write = function(chunk) { - if (chunk) { - this.hash.update(chunk); +export class WriteHashStream extends WriteStream { + constructor(path, options) { + super(path, options); + this.hash = crypto.createHash("sha1"); + this.digest = null; + this.on("close", function () { + this.digest = this.hash.digest("hex"); + }); } - return fs.WriteStream.prototype.write.call(this, chunk); -}; - -module.exports.WriteHashStream = WriteHashStream; \ No newline at end of file + write(chunk) { + if (chunk) { + this.hash.update(chunk); + } + return super.write(chunk); + } +} diff --git a/test/zip-archive-entry.js b/test/zip-archive-entry.js index 5b18d0f3..3b5c0247 100644 --- a/test/zip-archive-entry.js +++ b/test/zip-archive-entry.js @@ -1,319 +1,253 @@ +import { assert } from "chai"; +import { ZipArchiveEntry } from "../lib/compress-commons.js"; +import GeneralPurposeBit from "../lib/archivers/zip/general-purpose-bit.js"; +import UnixStat from "../lib/archivers/zip/unix-stat.js"; /*global before,describe,it */ -var assert = require('chai').assert; - -var commons = require('../lib/compress-commons'); -var ZipArchiveEntry = commons.ZipArchiveEntry; -var GeneralPurposeBit = require('../lib/archivers/zip/general-purpose-bit'); -var UnixStat = require('../lib/archivers/zip/unix-stat'); var entry; // Jan 03 2013 14:26:38 GMT var testDate = new Date(Date.UTC(2013, 0, 3, 14, 26, 38, 0)); - -describe('ZipArchiveEntry', function() { - - beforeEach(function() { - entry = new ZipArchiveEntry('file.txt'); +describe("ZipArchiveEntry", function () { + beforeEach(function () { + entry = new ZipArchiveEntry("file.txt"); }); - // Getters - describe('#getCentralDirectoryExtra', function() { - it.skip('should be tested', function() { - - }); + describe("#getCentralDirectoryExtra", function () { + it.skip("should be tested", function () {}); }); - - describe('#getComment', function() { - it('should return the comment', function() { - entry.setComment('file comment'); - assert.equal(entry.getComment(), 'file comment'); + describe("#getComment", function () { + it("should return the comment", function () { + entry.setComment("file comment"); + assert.equal(entry.getComment(), "file comment"); }); }); - - describe('#getCompressedSize', function() { - it('should return the compressed size', function() { + describe("#getCompressedSize", function () { + it("should return the compressed size", function () { entry.csize = 10; assert.equal(entry.getCompressedSize(), 10); }); }); - - describe('#getCrc', function() { - it('should return the CRC32', function() { + describe("#getCrc", function () { + it("should return the CRC32", function () { entry.crc = 585446183; assert.equal(entry.getCrc(), 585446183); }); }); - - describe('#getExternalAttributes', function() { - it('should return the external attributes', function() { + describe("#getExternalAttributes", function () { + it("should return the external attributes", function () { entry.exattr = 2180972576; assert.equal(entry.getExternalAttributes(), 2180972576); }); }); - - describe('#getExtra', function() { - it.skip('should be tested', function() { - - }); + describe("#getExtra", function () { + it.skip("should be tested", function () {}); }); - - describe('#getGeneralPurposeBit', function() { - it('should return the general purpose bit flag', function() { + describe("#getGeneralPurposeBit", function () { + it("should return the general purpose bit flag", function () { var gpb = new GeneralPurposeBit(); gpb.useDataDescriptor(true); entry.gpb = gpb; assert.equal(entry.getGeneralPurposeBit(), gpb); }); }); - - describe('#getInternalAttributes', function() { - it('should return the internal attributes', function() { + describe("#getInternalAttributes", function () { + it("should return the internal attributes", function () { entry.inattr = 2180972576; assert.equal(entry.getInternalAttributes(), 2180972576); }); }); - - describe('#getLastModifiedDate', function() { - it.skip('should be tested', function() { - - }); + describe("#getLastModifiedDate", function () { + it.skip("should be tested", function () {}); }); - - describe('#getLocalFileDataExtra', function() { - it.skip('should be tested', function() { - - }); + describe("#getLocalFileDataExtra", function () { + it.skip("should be tested", function () {}); }); - - describe('#getMethod', function() { - it('should return the compression method', function() { + describe("#getMethod", function () { + it("should return the compression method", function () { entry.method = 0; assert.equal(entry.getMethod(), 0); }); }); - - describe('#getName', function() { - it('should return the name', function() { - entry.name = 'file.txt'; - assert.equal(entry.getName(), 'file.txt'); + describe("#getName", function () { + it("should return the name", function () { + entry.name = "file.txt"; + assert.equal(entry.getName(), "file.txt"); }); }); - - describe('#getPlatform', function() { - it('should return the platform', function() { + describe("#getPlatform", function () { + it("should return the platform", function () { entry.platform = 3; assert.equal(entry.getPlatform(), 3); }); }); - - describe('#getSize', function() { - it('should return the size', function() { + describe("#getSize", function () { + it("should return the size", function () { entry.size = 25; assert.equal(entry.getSize(), 25); }); }); - - describe('#getTime', function() { - it('should return a Date object', function() { + describe("#getTime", function () { + it("should return a Date object", function () { entry.time = 1109607251; - assert.typeOf(entry.getTime(), 'Date'); + assert.typeOf(entry.getTime(), "Date"); }); }); - - describe('#getTimeDos', function() { - it('should return a number', function() { + describe("#getTimeDos", function () { + it("should return a number", function () { entry.time = 1109607251; - assert.typeOf(entry.getTimeDos(), 'number'); + assert.typeOf(entry.getTimeDos(), "number"); }); }); - - describe('#getUnixMode', function() { - it('should return the unix filemode', function() { + describe("#getUnixMode", function () { + it("should return the unix filemode", function () { entry.mode = 0777; entry.exattr = 2180972576; entry.platform = 3; assert.equal(entry.getUnixMode(), 0100777); }); - - it('should set proper external attributes for an unix directory', function () { - entry = new ZipArchiveEntry('directory/'); + it("should set proper external attributes for an unix directory", function () { + entry = new ZipArchiveEntry("directory/"); entry.setUnixMode(0777); - assert.ok(entry.getPlatform(), 3); assert.ok(entry.isDirectory()); - var exattr = entry.getExternalAttributes() >> 16; assert.equal(exattr & 040000, 040000); }); }); - - describe('#getVersionNeededToExtract', function() { - it.skip('should be tested', function() { - - }); + describe("#getVersionNeededToExtract", function () { + it.skip("should be tested", function () {}); }); - // Setters - describe('#setComment', function() { - it('should set internal variable', function() { - entry.setComment('file comment'); - assert.propertyVal(entry, 'comment', 'file comment'); + describe("#setComment", function () { + it("should set internal variable", function () { + entry.setComment("file comment"); + assert.propertyVal(entry, "comment", "file comment"); }); - - it('should set utf8 bit when receiving strings byte count != string length', function() { - entry.setComment('ÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝàáâãäçèéêëìíîïñòóôõöùúûüýÿ'); + it("should set utf8 bit when receiving strings byte count != string length", function () { + entry.setComment("ÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝàáâãäçèéêëìíîïñòóôõöùúûüýÿ"); assert.ok(entry.getGeneralPurposeBit().usesUTF8ForNames()); }); }); - - describe('#setCompressedSize', function() { - it('should set internal variable', function() { + describe("#setCompressedSize", function () { + it("should set internal variable", function () { entry.setCompressedSize(10); - assert.propertyVal(entry, 'csize', 10); + assert.propertyVal(entry, "csize", 10); }); }); - - describe('#setCrc', function() { - it('should set internal variable', function() { + describe("#setCrc", function () { + it("should set internal variable", function () { entry.setCrc(585446183); - assert.propertyVal(entry, 'crc', 585446183); + assert.propertyVal(entry, "crc", 585446183); }); }); - - describe('#setExternalAttributes', function() { - it('should set internal variable', function() { + describe("#setExternalAttributes", function () { + it("should set internal variable", function () { entry.setExternalAttributes(2180972576); - assert.propertyVal(entry, 'exattr', 2180972576); + assert.propertyVal(entry, "exattr", 2180972576); }); }); - - describe('#setExtra', function() { - it.skip('should be tested', function() { - - }); + describe("#setExtra", function () { + it.skip("should be tested", function () {}); }); - - describe('#setGeneralPurposeBit', function() { - it('should set internal variable', function() { + describe("#setGeneralPurposeBit", function () { + it("should set internal variable", function () { var gpb = new GeneralPurposeBit(); gpb.useDataDescriptor(true); entry.setGeneralPurposeBit(gpb); - assert.propertyVal(entry, 'gpb', gpb); + assert.propertyVal(entry, "gpb", gpb); }); }); - - describe('#setInternalAttributes', function() { - it('should set internal variable', function() { + describe("#setInternalAttributes", function () { + it("should set internal variable", function () { entry.setInternalAttributes(2180972576); - assert.propertyVal(entry, 'inattr', 2180972576); + assert.propertyVal(entry, "inattr", 2180972576); }); }); - - describe('#setMethod', function() { - it('should set internal variable', function() { + describe("#setMethod", function () { + it("should set internal variable", function () { entry.setMethod(8); - assert.propertyVal(entry, 'method', 8); + assert.propertyVal(entry, "method", 8); }); }); - - describe('#setName', function() { - it('should set internal variable', function() { - entry.setName('file.txt'); - assert.propertyVal(entry, 'name', 'file.txt'); + describe("#setName", function () { + it("should set internal variable", function () { + entry.setName("file.txt"); + assert.propertyVal(entry, "name", "file.txt"); }); - - it('should allow setting prefix of / at the beginning of path', function() { - entry.setName('file.txt', true); - assert.propertyVal(entry, 'name', '/file.txt'); + it("should allow setting prefix of / at the beginning of path", function () { + entry.setName("file.txt", true); + assert.propertyVal(entry, "name", "/file.txt"); }); - - it('should allow ./ at the beginning of path', function() { - entry.setName('./file.txt'); - assert.propertyVal(entry, 'name', './file.txt'); + it("should allow ./ at the beginning of path", function () { + entry.setName("./file.txt"); + assert.propertyVal(entry, "name", "./file.txt"); }); - - it('should clean windows style paths', function() { - entry.setName('\\windows\\file.txt'); - assert.propertyVal(entry, 'name', 'windows/file.txt'); - - entry.setName('c:\\this\\path\\file.txt'); - assert.propertyVal(entry, 'name', 'this/path/file.txt'); - - entry.setName('\\\\server\\share\\'); - assert.propertyVal(entry, 'name', 'server/share/'); + it("should clean windows style paths", function () { + entry.setName("\\windows\\file.txt"); + assert.propertyVal(entry, "name", "windows/file.txt"); + entry.setName("c:\\this\\path\\file.txt"); + assert.propertyVal(entry, "name", "this/path/file.txt"); + entry.setName("\\\\server\\share\\"); + assert.propertyVal(entry, "name", "server/share/"); }); - - it('should clean multiple forward slashes at beginning of path', function() { - entry.setName('//forward/file.txt'); - assert.propertyVal(entry, 'name', 'forward/file.txt'); + it("should clean multiple forward slashes at beginning of path", function () { + entry.setName("//forward/file.txt"); + assert.propertyVal(entry, "name", "forward/file.txt"); }); - - it('should set utf8 bit when receiving strings byte count != string length', function() { - entry.setName('ÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝàáâãäçèéêëìíîïñòóôõöùúûüýÿ.txt'); + it("should set utf8 bit when receiving strings byte count != string length", function () { + entry.setName("ÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝàáâãäçèéêëìíîïñòóôõöùúûüýÿ.txt"); assert.ok(entry.getGeneralPurposeBit().usesUTF8ForNames()); }); }); - - describe('#setPlatform', function() { - it('should set internal variable', function() { + describe("#setPlatform", function () { + it("should set internal variable", function () { entry.setPlatform(3); - assert.propertyVal(entry, 'platform', 3); + assert.propertyVal(entry, "platform", 3); }); }); - - describe('#setSize', function() { - it('should set internal variable', function() { + describe("#setSize", function () { + it("should set internal variable", function () { entry.setSize(15); - assert.propertyVal(entry, 'size', 15); + assert.propertyVal(entry, "size", 15); }); }); - - describe('#setTime', function() { - it('should set internal variable', function() { + describe("#setTime", function () { + it("should set internal variable", function () { entry.setTime(testDate); - assert.propertyVal(entry, 'time', 1109619539); + assert.propertyVal(entry, "time", 1109619539); }); }); - - describe('#setUnixMode', function() { - it('should set internal variables', function() { + describe("#setUnixMode", function () { + it("should set internal variables", function () { entry.setUnixMode(0777); - assert.propertyVal(entry, 'exattr', 2180972576); - assert.propertyVal(entry, 'mode', 0777); + assert.propertyVal(entry, "exattr", 2180972576); + assert.propertyVal(entry, "mode", 0777); assert.equal(entry.getUnixMode(), 0100777); - }); - - it('should also preserve filetype information', function() { + it("should also preserve filetype information", function () { entry.setUnixMode(0120755); - assert.propertyVal(entry, 'exattr', 2716663840); - assert.propertyVal(entry, 'mode', 0755); + assert.propertyVal(entry, "exattr", 2716663840); + assert.propertyVal(entry, "mode", 0755); assert.equal(entry.getUnixMode(), 0120755); }); }); - - describe('#setVersionNeededToExtract', function() { - it.skip('should be tested', function() { - - }); + describe("#setVersionNeededToExtract", function () { + it.skip("should be tested", function () {}); }); - // Others - describe('#isDirectory', function() { - it('should return a boolean based on name of entry', function() { + describe("#isDirectory", function () { + it("should return a boolean based on name of entry", function () { assert.notOk(entry.isDirectory()); - entry.setName('some/directory/'); + entry.setName("some/directory/"); assert.ok(entry.isDirectory()); }); }); - - describe('#isUnixSymlink', function() { - it('should return a boolean if the entry is a symlink', function() { - entry.setUnixMode(UnixStat.LINK_FLAG); - assert.ok(entry.isUnixSymlink()); - - entry.setUnixMode(UnixStat.LINK_FLAG | UnixStat.DIR_FLAG); - assert.notOk(entry.isUnixSymlink()); - }); + describe("#isUnixSymlink", function () { + it("should return a boolean if the entry is a symlink", function () { + entry.setUnixMode(UnixStat.LINK_FLAG); + assert.ok(entry.isUnixSymlink()); + entry.setUnixMode(UnixStat.LINK_FLAG | UnixStat.DIR_FLAG); + assert.notOk(entry.isUnixSymlink()); + }); }); }); diff --git a/test/zip-archive-output-stream.js b/test/zip-archive-output-stream.js index 1c1ca8c1..9ca08c19 100644 --- a/test/zip-archive-output-stream.js +++ b/test/zip-archive-output-stream.js @@ -1,147 +1,126 @@ -/*global before,describe,it */ -var fs = require('fs'); -var stream = require('stream'); -var assert = require('chai').assert; -var mkdir = require('mkdirp'); -var Readable = require('readable-stream').Readable; - -var helpers = require('./helpers'); -var WriteHashStream = helpers.WriteHashStream; -var testBuffer = helpers.binaryBuffer(1024 * 16); -var testDate = new Date('Jan 03 2013 14:26:38 GMT'); - -var commons = require('../lib/compress-commons'); -var ZipArchiveEntry = commons.ZipArchiveEntry; -var ZipArchiveOutputStream = commons.ZipArchiveOutputStream; - -describe('ZipArchiveOutputStream', function() { - - before(function() { - mkdir.sync('tmp'); +import { createReadStream } from "fs"; +import { Stream } from "stream"; +import { assert } from "chai"; +import mkdir from "mkdirp"; +import { Readable } from "readable-stream"; +import { WriteHashStream, binaryBuffer } from "./helpers/index.js"; +import { + ZipArchiveEntry, + ZipArchiveOutputStream, +} from "../lib/compress-commons.js"; + +var testBuffer = binaryBuffer(1024 * 16); +var testDate = new Date("Jan 03 2013 14:26:38 GMT"); + +describe("ZipArchiveOutputStream", function () { + before(function () { + mkdir.sync("tmp"); }); - - describe('#entry', function() { - it('should append Buffer sources', function(done) { + describe("#entry", function () { + it("should append Buffer sources", function (done) { var archive = new ZipArchiveOutputStream(); - var testStream = new WriteHashStream('tmp/zip-buffer.zip'); - var entry = new ZipArchiveEntry('buffer.txt'); - - testStream.on('close', function() { + var testStream = new WriteHashStream("tmp/zip-buffer.zip"); + var entry = new ZipArchiveEntry("buffer.txt"); + testStream.on("close", function () { done(); }); - archive.pipe(testStream); - archive.entry(entry, testBuffer).finish(); }); - - it('should append Stream sources', function(done) { + it("should append Stream sources", function (done) { var archive = new ZipArchiveOutputStream(); - var testStream = new WriteHashStream('tmp/zip-stream.zip'); - var entry = new ZipArchiveEntry('stream.txt'); - - testStream.on('close', function() { + var testStream = new WriteHashStream("tmp/zip-stream.zip"); + var entry = new ZipArchiveEntry("stream.txt"); + testStream.on("close", function () { done(); }); - archive.pipe(testStream); - - archive.entry(entry, fs.createReadStream('test/fixtures/test.txt')).finish(); + archive + .entry(entry, fs.createReadStream("test/fixtures/test.txt")) + .finish(); }); - - it('should append Stream-like sources', function(done) { + it("should append Stream-like sources", function (done) { var archive = new ZipArchiveOutputStream(); - var testStream = new WriteHashStream('tmp/zip-stream-like.zip'); - var entry = new ZipArchiveEntry('stream-like.txt'); - - testStream.on('close', function() { + var testStream = new WriteHashStream("tmp/zip-stream-like.zip"); + var entry = new ZipArchiveEntry("stream-like.txt"); + testStream.on("close", function () { done(); }); - archive.pipe(testStream); - - archive.entry(entry, Readable.from(['test'])).finish(); + archive.entry(entry, Readable.from(["test"])).finish(); }); - - it('should stop streaming on Stream error', function(done) { + it("should stop streaming on Stream error", function (done) { var archive = new ZipArchiveOutputStream(); - var testStream = new WriteHashStream('tmp/zip-stream.zip'); - var entry = new ZipArchiveEntry('stream.txt'); - + var testStream = new WriteHashStream("tmp/zip-stream.zip"); + var entry = new ZipArchiveEntry("stream.txt"); var callbackError = null; var callbackCalls = 0; - - testStream.on('close', function() { - assert.equal(callbackError.message, 'something went wrong'); + testStream.on("close", function () { + assert.equal(callbackError.message, "something went wrong"); assert.equal(callbackCalls, 1); done(); }); - archive.pipe(testStream); - var file = new stream.Transform(); - archive.entry(entry, file, function(err) { + archive.entry(entry, file, function (err) { callbackCalls += 1; callbackError = err; }); archive.finish(); - - process.nextTick(function() { - file.emit('error', new Error('something went wrong')); - }) + process.nextTick(function () { + file.emit("error", new Error("something went wrong")); + }); }); - - it('should append multiple sources', function(done) { + it("should append multiple sources", function (done) { var archive = new ZipArchiveOutputStream(); - var testStream = new WriteHashStream('tmp/zip-multiple.zip'); - - var entry = new ZipArchiveEntry('string.txt'); - var entry2 = new ZipArchiveEntry('buffer.txt'); - var entry3 = new ZipArchiveEntry('stream.txt'); - var entry4 = new ZipArchiveEntry('stream-store.png'); + var testStream = new WriteHashStream("tmp/zip-multiple.zip"); + var entry = new ZipArchiveEntry("string.txt"); + var entry2 = new ZipArchiveEntry("buffer.txt"); + var entry3 = new ZipArchiveEntry("stream.txt"); + var entry4 = new ZipArchiveEntry("stream-store.png"); entry4.setMethod(0); - var entry5 = new ZipArchiveEntry('buffer-store.txt') - entry5.setMethod(0) - - testStream.on('close', function() { + var entry5 = new ZipArchiveEntry("buffer-store.txt"); + entry5.setMethod(0); + testStream.on("close", function () { done(); }); - archive.pipe(testStream); - - archive.entry(entry, 'string', function(err) { + archive.entry(entry, "string", function (err) { if (err) throw err; - archive.entry(entry2, testBuffer, function(err) { + archive.entry(entry2, testBuffer, function (err) { if (err) throw err; - archive.entry(entry3, fs.createReadStream('test/fixtures/test.txt'), function(err) { - if (err) throw err; - archive.entry(entry4, fs.createReadStream('test/fixtures/image.png'), function(err) { + archive.entry( + entry3, + fs.createReadStream("test/fixtures/test.txt"), + function (err) { if (err) throw err; - archive.entry(entry5, testBuffer, function(err) { - if (err) throw err; - archive.finish(); - }); - }); - }); + archive.entry( + entry4, + fs.createReadStream("test/fixtures/image.png"), + function (err) { + if (err) throw err; + archive.entry(entry5, testBuffer, function (err) { + if (err) throw err; + archive.finish(); + }); + }, + ); + }, + ); }); }); }); - - it('should force ZIP64', function(done) { + it("should force ZIP64", function (done) { var archive = new ZipArchiveOutputStream({ - forceZip64: true + forceZip64: true, }); - var testStream = new WriteHashStream('tmp/zip-stream64.zip'); - var entry = new ZipArchiveEntry('stream.txt'); - - testStream.on('close', function() { + var testStream = new WriteHashStream("tmp/zip-stream64.zip"); + var entry = new ZipArchiveEntry("stream.txt"); + testStream.on("close", function () { done(); }); - archive.pipe(testStream); - - archive.entry(entry, fs.createReadStream('test/fixtures/test.txt')).finish(); + archive.entry(entry, createReadStream("test/fixtures/test.txt")).finish(); }); }); - });