forked from olcxjas-softworks/LarpixClient
update electron to v43
This commit is contained in:
parent
68ac0beedf
commit
fb6c8b6ee9
5385 changed files with 513060 additions and 123058 deletions
1
electron/node_modules/unzipper/.gitattributes
generated
vendored
Normal file
1
electron/node_modules/unzipper/.gitattributes
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
text eol=lf
|
||||
25
electron/node_modules/unzipper/LICENSE
generated
vendored
Normal file
25
electron/node_modules/unzipper/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
Copyright (c) 2012 - 2013 Near Infinity Corporation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
---
|
||||
|
||||
Commits in this fork are (c) Ziggy Jonsson (ziggy.jonsson.nyc@gmail.com)
|
||||
and fall under same licence structure as the original repo (MIT)
|
||||
397
electron/node_modules/unzipper/README.md
generated
vendored
Normal file
397
electron/node_modules/unzipper/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,397 @@
|
|||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[](https://zjonsson.github.io/node-unzipper/)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/unzipper.svg
|
||||
[npm-url]: https://npmjs.org/package/unzipper
|
||||
[travis-image]: https://api.travis-ci.org/ZJONSSON/node-unzipper.png?branch=master
|
||||
[travis-url]: https://travis-ci.org/ZJONSSON/node-unzipper?branch=master
|
||||
[downloads-image]: https://img.shields.io/npm/dm/unzipper.svg
|
||||
[downloads-url]: https://npmjs.org/package/unzipper
|
||||
[coverage-image]: https://3tjjj5abqi.execute-api.us-east-1.amazonaws.com/prod/node-unzipper/badge
|
||||
[coverage-url]: https://3tjjj5abqi.execute-api.us-east-1.amazonaws.com/prod/node-unzipper/url
|
||||
|
||||
# unzipper
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install unzipper
|
||||
```
|
||||
|
||||
## Open methods
|
||||
|
||||
The open methods allow random access to the underlying files of a zip archive, from disk or from the web, s3 or a custom source.
|
||||
|
||||
The open methods return a promise on the contents of the central directory of a zip file, with individual `files` listed in an array.
|
||||
|
||||
Each file record has the following methods, providing random access to the underlying files:
|
||||
* `stream([password])` - returns a stream of the unzipped content which can be piped to any destination
|
||||
* `buffer([password])` - returns a promise on the buffered content of the file.
|
||||
|
||||
If the file is encrypted you will have to supply a password to decrypt, otherwise you can leave blank.
|
||||
|
||||
Unlike `adm-zip` the Open methods will never read the entire zipfile into buffer.
|
||||
|
||||
The last argument to the `Open` methods is an optional `options` object where you can specify `tailSize` (default 80 bytes), i.e. how many bytes should we read at the end of the zipfile to locate the endOfCentralDirectory. This location can be variable depending on zip64 extensible data sector size. Additionally you can supply option `crx: true` which will check for a crx header and parse the file accordingly by shifting all file offsets by the length of the crx header.
|
||||
|
||||
|
||||
### Open.file([path], [options])
|
||||
|
||||
Returns a Promise to the central directory information with methods to extract individual files. `start` and `end` options are used to avoid reading the whole file.
|
||||
|
||||
Here is a simple example of opening up a zip file, printing out the directory information and then extracting the first file inside the zipfile to disk:
|
||||
```js
|
||||
async function main() {
|
||||
const directory = await unzipper.Open.file('path/to/archive.zip');
|
||||
console.log('directory', directory);
|
||||
return new Promise( (resolve, reject) => {
|
||||
directory.files[0]
|
||||
.stream()
|
||||
.pipe(fs.createWriteStream('firstFile'))
|
||||
.on('error',reject)
|
||||
.on('close',resolve)
|
||||
});
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
If you want to extract all files from the zip file, the directory object supplies an extract method. Here is a quick example:
|
||||
|
||||
```js
|
||||
async function main() {
|
||||
const directory = await unzipper.Open.file('path/to/archive.zip');
|
||||
await directory.extract({ path: '/path/to/destination' })
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Open.url([requestLibrary], [url | params], [options])
|
||||
|
||||
This function will return a Promise to the central directory information from a URL point to a zipfile. Range-headers are used to avoid reading the whole file. Unzipper does not ship with a request library so you will have to provide it as the first option.
|
||||
|
||||
Live Example: (extracts a tiny xml file from the middle of a 500MB zipfile)
|
||||
|
||||
```js
|
||||
const request = require('request');
|
||||
const unzipper = require('./unzip');
|
||||
|
||||
async function main() {
|
||||
const directory = await unzipper.Open.url(request,'http://www2.census.gov/geo/tiger/TIGER2015/ZCTA5/tl_2015_us_zcta510.zip');
|
||||
const file = directory.files.find(d => d.path === 'tl_2015_us_zcta510.shp.iso.xml');
|
||||
const content = await file.buffer();
|
||||
console.log(content.toString());
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
|
||||
This function takes a second parameter which can either be a string containing the `url` to request, or an `options` object to invoke the supplied `request` library with. This can be used when other request options are required, such as custom headers or authentication to a third party service.
|
||||
|
||||
```js
|
||||
const request = require('google-oauth-jwt').requestWithJWT();
|
||||
|
||||
const googleStorageOptions = {
|
||||
url: `https://www.googleapis.com/storage/v1/b/m-bucket-name/o/my-object-name`,
|
||||
qs: { alt: 'media' },
|
||||
jwt: {
|
||||
email: google.storage.credentials.client_email,
|
||||
key: google.storage.credentials.private_key,
|
||||
scopes: ['https://www.googleapis.com/auth/devstorage.read_only']
|
||||
}
|
||||
});
|
||||
|
||||
async function getFile(req, res, next) {
|
||||
const directory = await unzipper.Open.url(request, googleStorageOptions);
|
||||
const file = zip.files.find((file) => file.path === 'my-filename');
|
||||
return file.stream().pipe(res);
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
### Open.s3([aws-sdk], [params], [options])
|
||||
|
||||
This function will return a Promise to the central directory information from a zipfile on S3. Range-headers are used to avoid reading the whole file. Unzipper does not ship with with the aws-sdk so you have to provide an instantiated client as first arguments. The params object requires `Bucket` and `Key` to fetch the correct file.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
const unzipper = require('./unzip');
|
||||
const AWS = require('aws-sdk');
|
||||
const s3Client = AWS.S3(config);
|
||||
|
||||
async function main() {
|
||||
const directory = await unzipper.Open.s3(s3Client,{Bucket: 'unzipper', Key: 'archive.zip'});
|
||||
return new Promise( (resolve, reject) => {
|
||||
directory.files[0]
|
||||
.stream()
|
||||
.pipe(fs.createWriteStream('firstFile'))
|
||||
.on('error',reject)
|
||||
.on('close',resolve)
|
||||
});
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
|
||||
### Open.buffer(buffer, [options])
|
||||
|
||||
If you already have the zip file in-memory as a buffer, you can open the contents directly.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
// never use readFileSync - only used here to simplify the example
|
||||
const buffer = fs.readFileSync('path/to/arhive.zip');
|
||||
|
||||
async function main() {
|
||||
const directory = await unzipper.Open.buffer(buffer);
|
||||
console.log('directory',directory);
|
||||
// ...
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
|
||||
### Open.custom(source, [options])
|
||||
|
||||
This function can be used to provide a custom source implementation. The source parameter expects a `stream` and a `size` function to be implemented. The size function should return a `Promise` that resolves the total size of the file. The stream function should return a `Readable` stream according to the supplied offset and length parameters.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
// Custom source implementation for reading a zip file from Google Cloud Storage
|
||||
const { Storage } = require('@google-cloud/storage');
|
||||
|
||||
async function main() {
|
||||
const storage = new Storage();
|
||||
const bucket = storage.bucket('my-bucket');
|
||||
const zipFile = bucket.file('my-zip-file.zip');
|
||||
|
||||
const customSource = {
|
||||
stream: function(offset, length) {
|
||||
return zipFile.createReadStream({
|
||||
start: offset,
|
||||
end: length && offset + length
|
||||
})
|
||||
},
|
||||
size: async function() {
|
||||
const objMetadata = (await zipFile.getMetadata())[0];
|
||||
return objMetadata.size;
|
||||
}
|
||||
};
|
||||
|
||||
const directory = await unzipper.Open.custom(customSource);
|
||||
console.log('directory', directory);
|
||||
// ...
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
|
||||
### Open.[method].extract()
|
||||
|
||||
The directory object returned from `Open.[method]` provides an `extract` method which extracts all the files to a specified `path`, with an optional `concurrency` (default: 1).
|
||||
|
||||
Example (with concurrency of 5):
|
||||
|
||||
```js
|
||||
unzip.Open.file('path/to/archive.zip')
|
||||
.then(d => d.extract({path: '/extraction/path', concurrency: 5}));
|
||||
```
|
||||
|
||||
|
||||
Please note: Methods that use the Central Directory instead of parsing entire file can be found under [`Open`](#open)
|
||||
|
||||
Chrome extension files (.crx) are zipfiles with an [extra header](http://www.adambarth.com/experimental/crx/docs/crx.html) at the start of the file. Unzipper will parse .crx file with the streaming methods (`Parse` and `ParseOne`).
|
||||
|
||||
|
||||
## Streaming an entire zip file (legacy)
|
||||
|
||||
This library began as an active fork and drop-in replacement of the [node-unzip](https://github.com/EvanOxfeld/node-unzip) to address the following issues:
|
||||
* finish/close events are not always triggered, particular when the input stream is slower than the receivers
|
||||
* Any files are buffered into memory before passing on to entry
|
||||
|
||||
Originally the only way to use the library was to stream the entire zip file. This method is inefficient if you are only interested in selected files from the zip files. Additionally this method can be error prone since it relies on the local file headers which could be wrong.
|
||||
|
||||
The structure of this fork is similar to the original, but uses Promises and inherit guarantees provided by node streams to ensure low memory footprint and emits finish/close events at the end of processing. The new `Parser` will push any parsed `entries` downstream if you pipe from it, while still supporting the legacy `entry` event as well.
|
||||
|
||||
Breaking changes: The new `Parser` will not automatically drain entries if there are no listeners or pipes in place.
|
||||
|
||||
Unzipper provides simple APIs similar to [node-tar](https://github.com/isaacs/node-tar) for parsing and extracting zip files.
|
||||
There are no added compiled dependencies - inflation is handled by node.js's built in zlib support.
|
||||
|
||||
### Extract to a directory
|
||||
```js
|
||||
fs.createReadStream('path/to/archive.zip')
|
||||
.pipe(unzipper.Extract({ path: 'output/path' }));
|
||||
```
|
||||
|
||||
Extract emits the 'close' event once the zip's contents have been fully extracted to disk. `Extract` uses [fstream.Writer](https://www.npmjs.com/package/fstream) and therefore needs an absolute path to the destination directory. This directory will be automatically created if it doesn't already exist.
|
||||
|
||||
### Parse zip file contents
|
||||
|
||||
Process each zip file entry or pipe entries to another stream.
|
||||
|
||||
__Important__: If you do not intend to consume an entry stream's raw data, call autodrain() to dispose of the entry's
|
||||
contents. Otherwise the stream will halt. `.autodrain()` returns an empty stream that provides `error` and `finish` events.
|
||||
Additionally you can call `.autodrain().promise()` to get the promisified version of success or failure of the autodrain.
|
||||
|
||||
```js
|
||||
// If you want to handle autodrain errors you can either:
|
||||
entry.autodrain().catch(e => handleError);
|
||||
// or
|
||||
entry.autodrain().on('error' => handleError);
|
||||
```
|
||||
|
||||
Here is a quick example:
|
||||
|
||||
```js
|
||||
fs.createReadStream('path/to/archive.zip')
|
||||
.pipe(unzipper.Parse())
|
||||
.on('entry', function (entry) {
|
||||
const fileName = entry.path;
|
||||
const type = entry.type; // 'Directory' or 'File'
|
||||
const size = entry.vars.uncompressedSize; // There is also compressedSize;
|
||||
if (fileName === "this IS the file I'm looking for") {
|
||||
entry.pipe(fs.createWriteStream('output/path'));
|
||||
} else {
|
||||
entry.autodrain();
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
and the same example using async iterators:
|
||||
|
||||
```js
|
||||
const zip = fs.createReadStream('path/to/archive.zip').pipe(unzipper.Parse({forceStream: true}));
|
||||
for await (const entry of zip) {
|
||||
const fileName = entry.path;
|
||||
const type = entry.type; // 'Directory' or 'File'
|
||||
const size = entry.vars.uncompressedSize; // There is also compressedSize;
|
||||
if (fileName === "this IS the file I'm looking for") {
|
||||
entry.pipe(fs.createWriteStream('output/path'));
|
||||
} else {
|
||||
entry.autodrain();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parse zip by piping entries downstream
|
||||
|
||||
If you `pipe` from unzipper the downstream components will receive each `entry` for further processing. This allows for clean pipelines transforming zipfiles into unzipped data.
|
||||
|
||||
Example using `stream.Transform`:
|
||||
|
||||
```js
|
||||
fs.createReadStream('path/to/archive.zip')
|
||||
.pipe(unzipper.Parse())
|
||||
.pipe(stream.Transform({
|
||||
objectMode: true,
|
||||
transform: function(entry,e,cb) {
|
||||
const fileName = entry.path;
|
||||
const type = entry.type; // 'Directory' or 'File'
|
||||
const size = entry.vars.uncompressedSize; // There is also compressedSize;
|
||||
if (fileName === "this IS the file I'm looking for") {
|
||||
entry.pipe(fs.createWriteStream('output/path'))
|
||||
.on('close',cb);
|
||||
} else {
|
||||
entry.autodrain();
|
||||
cb();
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
```
|
||||
|
||||
Example using [etl](https://www.npmjs.com/package/etl):
|
||||
|
||||
```js
|
||||
fs.createReadStream('path/to/archive.zip')
|
||||
.pipe(unzipper.Parse())
|
||||
.pipe(etl.map(entry => {
|
||||
if (entry.path == "this IS the file I'm looking for")
|
||||
return entry
|
||||
.pipe(etl.toFile('output/path'))
|
||||
.promise();
|
||||
else
|
||||
entry.autodrain();
|
||||
}))
|
||||
|
||||
```
|
||||
|
||||
### Parse a single file and pipe contents
|
||||
|
||||
`unzipper.parseOne([regex])` is a convenience method that unzips only one file from the archive and pipes the contents down (not the entry itself). If no search criteria is specified, the first file in the archive will be unzipped. Otherwise, each filename will be compared to the criteria and the first one to match will be unzipped and piped down. If no file matches then the the stream will end without any content.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
fs.createReadStream('path/to/archive.zip')
|
||||
.pipe(unzipper.ParseOne())
|
||||
.pipe(fs.createWriteStream('firstFile.txt'));
|
||||
```
|
||||
|
||||
### Buffering the content of an entry into memory
|
||||
|
||||
While the recommended strategy of consuming the unzipped contents is using streams, it is sometimes convenient to be able to get the full buffered contents of each file . Each `entry` provides a `.buffer` function that consumes the entry by buffering the contents into memory and returning a promise to the complete buffer.
|
||||
|
||||
```js
|
||||
fs.createReadStream('path/to/archive.zip')
|
||||
.pipe(unzipper.Parse())
|
||||
.pipe(etl.map(async entry => {
|
||||
if (entry.path == "this IS the file I'm looking for") {
|
||||
const content = await entry.buffer();
|
||||
await fs.writeFile('output/path',content);
|
||||
}
|
||||
else {
|
||||
entry.autodrain();
|
||||
}
|
||||
}))
|
||||
```
|
||||
|
||||
### Parse.promise() syntax sugar
|
||||
|
||||
The parser emits `finish` and `error` events like any other stream. The parser additionally provides a promise wrapper around those two events to allow easy folding into existing Promise-based structures.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
fs.createReadStream('path/to/archive.zip')
|
||||
.pipe(unzipper.Parse())
|
||||
.on('entry', entry => entry.autodrain())
|
||||
.promise()
|
||||
.then( () => console.log('done'), e => console.log('error',e));
|
||||
```
|
||||
|
||||
### Parse zip created by DOS ZIP or Windows ZIP Folders
|
||||
|
||||
Archives created by legacy tools usually have filenames encoded with IBM PC (Windows OEM) character set.
|
||||
You can decode filenames with preferred character set:
|
||||
|
||||
```js
|
||||
const il = require('iconv-lite');
|
||||
fs.createReadStream('path/to/archive.zip')
|
||||
.pipe(unzipper.Parse())
|
||||
.on('entry', function (entry) {
|
||||
// if some legacy zip tool follow ZIP spec then this flag will be set
|
||||
const isUnicode = entry.props.flags.isUnicode;
|
||||
// decode "non-unicode" filename from OEM Cyrillic character set
|
||||
const fileName = isUnicode ? entry.path : il.decode(entry.props.pathBuffer, 'cp866');
|
||||
const type = entry.type; // 'Directory' or 'File'
|
||||
const size = entry.vars.uncompressedSize; // There is also compressedSize;
|
||||
if (fileName === "Текстовый файл.txt") {
|
||||
entry.pipe(fs.createWriteStream(fileName));
|
||||
} else {
|
||||
entry.autodrain();
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## Licenses
|
||||
See LICENCE
|
||||
29
electron/node_modules/unzipper/eslint.config.mjs
generated
vendored
Normal file
29
electron/node_modules/unzipper/eslint.config.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import globals from "globals";
|
||||
import pluginJs from "@eslint/js";
|
||||
|
||||
|
||||
export default [
|
||||
{
|
||||
rules:{
|
||||
"semi": 2,
|
||||
"no-multiple-empty-lines": 2,
|
||||
"no-multi-spaces": 2,
|
||||
"comma-spacing": 2,
|
||||
"prefer-const": 2,
|
||||
"no-trailing-spaces": 2,
|
||||
"no-var": 2,
|
||||
"indent": [
|
||||
"error",
|
||||
2,
|
||||
{
|
||||
"MemberExpression": 1,
|
||||
"SwitchCase": 1,
|
||||
"ignoredNodes": ["TemplateLiteral > *"]
|
||||
}
|
||||
],
|
||||
}
|
||||
},
|
||||
{files: ["**/*.js"], languageOptions: {sourceType: "script"}},
|
||||
{languageOptions: { globals: globals.node }},
|
||||
pluginJs.configs.recommended,
|
||||
];
|
||||
19
electron/node_modules/unzipper/lib/BufferStream.js
generated
vendored
Normal file
19
electron/node_modules/unzipper/lib/BufferStream.js
generated
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
const Stream = require('stream');
|
||||
|
||||
module.exports = function(entry) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
const chunks = [];
|
||||
const bufferStream = Stream.Transform()
|
||||
.on('finish', function() {
|
||||
resolve(Buffer.concat(chunks));
|
||||
})
|
||||
.on('error', reject);
|
||||
|
||||
bufferStream._transform = function(d, e, cb) {
|
||||
chunks.push(d);
|
||||
cb();
|
||||
};
|
||||
entry.on('error', reject)
|
||||
.pipe(bufferStream);
|
||||
});
|
||||
};
|
||||
94
electron/node_modules/unzipper/lib/Decrypt.js
generated
vendored
Normal file
94
electron/node_modules/unzipper/lib/Decrypt.js
generated
vendored
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
const Int64 = require("node-int64");
|
||||
let Stream = require("stream");
|
||||
|
||||
// Backwards compatibility for node versions < 8
|
||||
|
||||
if (!Stream.Writable || !Stream.Writable.prototype.destroy)
|
||||
Stream = require("readable-stream");
|
||||
|
||||
let table;
|
||||
|
||||
function generateTable() {
|
||||
const poly = 0xEDB88320;
|
||||
let c, n, k;
|
||||
table = [];
|
||||
for (n = 0; n < 256; n++) {
|
||||
c = n;
|
||||
for (k = 0; k < 8; k++) c = c & 1 ? poly ^ (c >>> 1) : (c = c >>> 1);
|
||||
table[n] = c >>> 0;
|
||||
}
|
||||
}
|
||||
|
||||
function crc(ch, crc) {
|
||||
if (!table) generateTable();
|
||||
|
||||
if (ch.charCodeAt) ch = ch.charCodeAt(0);
|
||||
|
||||
const l = (crc.readUInt32BE() >> 8) & 0xffffff;
|
||||
const r = table[(crc.readUInt32BE() ^ (ch >>> 0)) & 0xff];
|
||||
|
||||
return (l ^ r) >>> 0;
|
||||
}
|
||||
|
||||
function multiply(a, b) {
|
||||
const ah = (a >> 16) & 0xffff;
|
||||
const al = a & 0xffff;
|
||||
const bh = (b >> 16) & 0xffff;
|
||||
const bl = b & 0xffff;
|
||||
const high = (ah * bl + al * bh) & 0xffff;
|
||||
|
||||
return ((high << 16) >>> 0) + al * bl;
|
||||
}
|
||||
|
||||
function Decrypt() {
|
||||
if (!(this instanceof Decrypt)) return new Decrypt();
|
||||
|
||||
this.key0 = Buffer.allocUnsafe(4);
|
||||
this.key1 = Buffer.allocUnsafe(4);
|
||||
this.key2 = Buffer.allocUnsafe(4);
|
||||
|
||||
this.key0.writeUInt32BE(0x12345678, 0);
|
||||
this.key1.writeUInt32BE(0x23456789, 0);
|
||||
this.key2.writeUInt32BE(0x34567890, 0);
|
||||
}
|
||||
|
||||
Decrypt.prototype.update = function (h) {
|
||||
this.key0.writeUInt32BE(crc(h, this.key0));
|
||||
this.key1.writeUInt32BE(
|
||||
((this.key0.readUInt32BE() & 0xff & 0xFFFFFFFF) +
|
||||
this.key1.readUInt32BE()) >>> 0
|
||||
);
|
||||
const x = new Int64(
|
||||
(multiply(this.key1.readUInt32BE(), 134775813) + 1) & 0xFFFFFFFF
|
||||
);
|
||||
const b = Buffer.alloc(8);
|
||||
x.copy(b, 0);
|
||||
b.copy(this.key1, 0, 4, 8);
|
||||
this.key2.writeUInt32BE(
|
||||
crc(((this.key1.readUInt32BE() >> 24) & 0xff) >>> 0, this.key2)
|
||||
);
|
||||
};
|
||||
|
||||
Decrypt.prototype.decryptByte = function (c) {
|
||||
const k = (this.key2.readUInt32BE() | 2) >>> 0;
|
||||
c = c ^ ((multiply(k, (k ^ 1 >>> 0)) >> 8) & 0xff);
|
||||
this.update(c);
|
||||
|
||||
return c;
|
||||
};
|
||||
|
||||
Decrypt.prototype.stream = function () {
|
||||
const stream = Stream.Transform(),
|
||||
self = this;
|
||||
stream._transform = function (d, e, cb) {
|
||||
for (let i = 0; i < d.length; i++) {
|
||||
d[i] = self.decryptByte(d[i]);
|
||||
}
|
||||
this.push(d);
|
||||
cb();
|
||||
};
|
||||
|
||||
return stream;
|
||||
};
|
||||
|
||||
module.exports = Decrypt;
|
||||
14
electron/node_modules/unzipper/lib/NoopStream.js
generated
vendored
Normal file
14
electron/node_modules/unzipper/lib/NoopStream.js
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
const Stream = require('stream');
|
||||
const util = require('util');
|
||||
function NoopStream() {
|
||||
if (!(this instanceof NoopStream)) {
|
||||
return new NoopStream();
|
||||
}
|
||||
Stream.Transform.call(this);
|
||||
}
|
||||
|
||||
util.inherits(NoopStream, Stream.Transform);
|
||||
|
||||
NoopStream.prototype._transform = function(d, e, cb) { cb() ;};
|
||||
|
||||
module.exports = NoopStream;
|
||||
244
electron/node_modules/unzipper/lib/Open/directory.js
generated
vendored
Normal file
244
electron/node_modules/unzipper/lib/Open/directory.js
generated
vendored
Normal file
|
|
@ -0,0 +1,244 @@
|
|||
const PullStream = require('../PullStream');
|
||||
const unzip = require('./unzip');
|
||||
const BufferStream = require('../BufferStream');
|
||||
const parseExtraField = require('../parseExtraField');
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const parseDateTime = require('../parseDateTime');
|
||||
const parseBuffer = require('../parseBuffer');
|
||||
const Bluebird = require('bluebird');
|
||||
|
||||
const signature = Buffer.alloc(4);
|
||||
signature.writeUInt32LE(0x06054b50, 0);
|
||||
|
||||
function getCrxHeader(source) {
|
||||
const sourceStream = source.stream(0).pipe(PullStream());
|
||||
|
||||
return sourceStream.pull(4).then(function(data) {
|
||||
const signature = data.readUInt32LE(0);
|
||||
if (signature === 0x34327243) {
|
||||
let crxHeader;
|
||||
return sourceStream.pull(12).then(function(data) {
|
||||
crxHeader = parseBuffer.parse(data, [
|
||||
['version', 4],
|
||||
['pubKeyLength', 4],
|
||||
['signatureLength', 4],
|
||||
]);
|
||||
}).then(function() {
|
||||
return sourceStream.pull(crxHeader.pubKeyLength +crxHeader.signatureLength);
|
||||
}).then(function(data) {
|
||||
crxHeader.publicKey = data.slice(0, crxHeader.pubKeyLength);
|
||||
crxHeader.signature = data.slice(crxHeader.pubKeyLength);
|
||||
crxHeader.size = 16 + crxHeader.pubKeyLength +crxHeader.signatureLength;
|
||||
return crxHeader;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Zip64 File Format Notes: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
|
||||
function getZip64CentralDirectory(source, zip64CDL) {
|
||||
const d64loc = parseBuffer.parse(zip64CDL, [
|
||||
['signature', 4],
|
||||
['diskNumber', 4],
|
||||
['offsetToStartOfCentralDirectory', 8],
|
||||
['numberOfDisks', 4],
|
||||
]);
|
||||
|
||||
if (d64loc.signature != 0x07064b50) {
|
||||
throw new Error('invalid zip64 end of central dir locator signature (0x07064b50): 0x' + d64loc.signature.toString(16));
|
||||
}
|
||||
|
||||
const dir64 = PullStream();
|
||||
source.stream(d64loc.offsetToStartOfCentralDirectory).pipe(dir64);
|
||||
|
||||
return dir64.pull(56);
|
||||
}
|
||||
|
||||
// Zip64 File Format Notes: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
|
||||
function parseZip64DirRecord (dir64record) {
|
||||
const vars = parseBuffer.parse(dir64record, [
|
||||
['signature', 4],
|
||||
['sizeOfCentralDirectory', 8],
|
||||
['version', 2],
|
||||
['versionsNeededToExtract', 2],
|
||||
['diskNumber', 4],
|
||||
['diskStart', 4],
|
||||
['numberOfRecordsOnDisk', 8],
|
||||
['numberOfRecords', 8],
|
||||
['sizeOfCentralDirectory', 8],
|
||||
['offsetToStartOfCentralDirectory', 8],
|
||||
]);
|
||||
|
||||
if (vars.signature != 0x06064b50) {
|
||||
throw new Error('invalid zip64 end of central dir locator signature (0x06064b50): 0x0' + vars.signature.toString(16));
|
||||
}
|
||||
|
||||
return vars;
|
||||
}
|
||||
|
||||
module.exports = function centralDirectory(source, options) {
|
||||
const endDir = PullStream();
|
||||
const records = PullStream();
|
||||
const tailSize = (options && options.tailSize) || 80;
|
||||
let sourceSize,
|
||||
crxHeader,
|
||||
startOffset,
|
||||
vars;
|
||||
|
||||
if (options && options.crx)
|
||||
crxHeader = getCrxHeader(source);
|
||||
|
||||
return source.size()
|
||||
.then(function(size) {
|
||||
sourceSize = size;
|
||||
|
||||
source.stream(Math.max(0, size-tailSize))
|
||||
.on('error', function (error) { endDir.emit('error', error); })
|
||||
.pipe(endDir);
|
||||
|
||||
return endDir.pull(signature);
|
||||
})
|
||||
.then(function() {
|
||||
return Bluebird.props({directory: endDir.pull(22), crxHeader: crxHeader});
|
||||
})
|
||||
.then(function(d) {
|
||||
const data = d.directory;
|
||||
startOffset = d.crxHeader && d.crxHeader.size || 0;
|
||||
|
||||
vars = parseBuffer.parse(data, [
|
||||
['signature', 4],
|
||||
['diskNumber', 2],
|
||||
['diskStart', 2],
|
||||
['numberOfRecordsOnDisk', 2],
|
||||
['numberOfRecords', 2],
|
||||
['sizeOfCentralDirectory', 4],
|
||||
['offsetToStartOfCentralDirectory', 4],
|
||||
['commentLength', 2],
|
||||
]);
|
||||
|
||||
// Is this zip file using zip64 format? Use same check as Go:
|
||||
// https://github.com/golang/go/blob/master/src/archive/zip/reader.go#L503
|
||||
// For zip64 files, need to find zip64 central directory locator header to extract
|
||||
// relative offset for zip64 central directory record.
|
||||
if (vars.diskNumber == 0xffff || vars.numberOfRecords == 0xffff ||
|
||||
vars.offsetToStartOfCentralDirectory == 0xffffffff) {
|
||||
|
||||
// Offset to zip64 CDL is 20 bytes before normal CDR
|
||||
const zip64CDLSize = 20;
|
||||
const zip64CDLOffset = sourceSize - (tailSize - endDir.match + zip64CDLSize);
|
||||
const zip64CDLStream = PullStream();
|
||||
|
||||
source.stream(zip64CDLOffset).pipe(zip64CDLStream);
|
||||
|
||||
return zip64CDLStream.pull(zip64CDLSize)
|
||||
.then(function (d) { return getZip64CentralDirectory(source, d); })
|
||||
.then(function (dir64record) {
|
||||
vars = parseZip64DirRecord(dir64record);
|
||||
});
|
||||
} else {
|
||||
vars.offsetToStartOfCentralDirectory += startOffset;
|
||||
}
|
||||
})
|
||||
.then(function() {
|
||||
if (vars.commentLength) return endDir.pull(vars.commentLength).then(function(comment) {
|
||||
vars.comment = comment.toString('utf8');
|
||||
});
|
||||
})
|
||||
.then(function() {
|
||||
source.stream(vars.offsetToStartOfCentralDirectory).pipe(records);
|
||||
|
||||
vars.extract = function(opts) {
|
||||
if (!opts || !opts.path) throw new Error('PATH_MISSING');
|
||||
// make sure path is normalized before using it
|
||||
opts.path = path.resolve(path.normalize(opts.path));
|
||||
return vars.files.then(function(files) {
|
||||
return Bluebird.map(files, async function(entry) {
|
||||
// to avoid zip slip (writing outside of the destination), we resolve
|
||||
// the target path, and make sure it's nested in the intended
|
||||
// destination, or not extract it otherwise.
|
||||
const extractPath = path.join(opts.path, entry.path.replace(/\\/g, '/'));
|
||||
const rel = path.relative(opts.path, extractPath);
|
||||
if (rel === '' || rel.startsWith('..') || path.isAbsolute(rel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry.type == 'Directory') {
|
||||
await fs.ensureDir(extractPath);
|
||||
return;
|
||||
}
|
||||
|
||||
await fs.ensureDir(path.dirname(extractPath));
|
||||
|
||||
const writer = opts.getWriter ? opts.getWriter({path: extractPath}) : fs.createWriteStream(extractPath);
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
entry.stream(opts.password)
|
||||
.on('error', reject)
|
||||
.pipe(writer)
|
||||
.on('close', resolve)
|
||||
.on('error', reject);
|
||||
});
|
||||
}, { concurrency: opts.concurrency > 1 ? opts.concurrency : 1 });
|
||||
});
|
||||
};
|
||||
|
||||
vars.files = Bluebird.mapSeries(Array(vars.numberOfRecords), function() {
|
||||
return records.pull(46).then(function(data) {
|
||||
const vars = parseBuffer.parse(data, [
|
||||
['signature', 4],
|
||||
['versionMadeBy', 2],
|
||||
['versionsNeededToExtract', 2],
|
||||
['flags', 2],
|
||||
['compressionMethod', 2],
|
||||
['lastModifiedTime', 2],
|
||||
['lastModifiedDate', 2],
|
||||
['crc32', 4],
|
||||
['compressedSize', 4],
|
||||
['uncompressedSize', 4],
|
||||
['fileNameLength', 2],
|
||||
['extraFieldLength', 2],
|
||||
['fileCommentLength', 2],
|
||||
['diskNumber', 2],
|
||||
['internalFileAttributes', 2],
|
||||
['externalFileAttributes', 4],
|
||||
['offsetToLocalFileHeader', 4],
|
||||
]);
|
||||
|
||||
vars.offsetToLocalFileHeader += startOffset;
|
||||
vars.lastModifiedDateTime = parseDateTime(vars.lastModifiedDate, vars.lastModifiedTime);
|
||||
|
||||
return records.pull(vars.fileNameLength).then(function(fileNameBuffer) {
|
||||
vars.pathBuffer = fileNameBuffer;
|
||||
vars.path = fileNameBuffer.toString('utf8');
|
||||
vars.isUnicode = (vars.flags & 0x800) != 0;
|
||||
return records.pull(vars.extraFieldLength);
|
||||
})
|
||||
.then(function(extraField) {
|
||||
vars.extra = parseExtraField(extraField, vars);
|
||||
return records.pull(vars.fileCommentLength);
|
||||
})
|
||||
.then(function(comment) {
|
||||
vars.comment = comment;
|
||||
vars.type = (vars.uncompressedSize === 0 && /[/\\]$/.test(vars.path)) ? 'Directory' : 'File';
|
||||
const padding = options && options.padding || 1000;
|
||||
vars.stream = function(_password) {
|
||||
const totalSize = 30
|
||||
+ padding // add an extra buffer
|
||||
+ (vars.extraFieldLength || 0)
|
||||
+ (vars.fileNameLength || 0)
|
||||
+ vars.compressedSize;
|
||||
|
||||
return unzip(source, vars.offsetToLocalFileHeader, _password, vars, totalSize);
|
||||
};
|
||||
vars.buffer = function(_password) {
|
||||
return BufferStream(vars.stream(_password));
|
||||
};
|
||||
return vars;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return Bluebird.props(vars);
|
||||
});
|
||||
};
|
||||
141
electron/node_modules/unzipper/lib/Open/index.js
generated
vendored
Normal file
141
electron/node_modules/unzipper/lib/Open/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
const fs = require('graceful-fs');
|
||||
const directory = require('./directory');
|
||||
const Stream = require('stream');
|
||||
|
||||
module.exports = {
|
||||
buffer: function(buffer, options) {
|
||||
const source = {
|
||||
stream: function(offset, length) {
|
||||
const stream = Stream.PassThrough();
|
||||
const end = length ? offset + length : undefined;
|
||||
stream.end(buffer.slice(offset, end));
|
||||
return stream;
|
||||
},
|
||||
size: function() {
|
||||
return Promise.resolve(buffer.length);
|
||||
}
|
||||
};
|
||||
return directory(source, options);
|
||||
},
|
||||
file: function(filename, options) {
|
||||
const source = {
|
||||
stream: function(start, length) {
|
||||
const end = length ? start + length : undefined;
|
||||
return fs.createReadStream(filename, {start, end});
|
||||
},
|
||||
size: function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
fs.stat(filename, function(err, d) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
resolve(d.size);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
return directory(source, options);
|
||||
},
|
||||
|
||||
url: function(request, params, options) {
|
||||
if (typeof params === 'string')
|
||||
params = {url: params};
|
||||
if (!params.url)
|
||||
throw 'URL missing';
|
||||
params.headers = params.headers || {};
|
||||
|
||||
const source = {
|
||||
stream : function(offset, length) {
|
||||
const options = Object.create(params);
|
||||
const end = length ? offset + length : '';
|
||||
options.headers = Object.create(params.headers);
|
||||
options.headers.range = 'bytes='+offset+'-' + end;
|
||||
return request(options);
|
||||
},
|
||||
size: function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
const req = request(params);
|
||||
req.on('response', function(d) {
|
||||
req.abort();
|
||||
if (!d.headers['content-length'])
|
||||
reject(new Error('Missing content length header'));
|
||||
else
|
||||
resolve(d.headers['content-length']);
|
||||
}).on('error', reject);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return directory(source, options);
|
||||
},
|
||||
|
||||
s3 : function(client, params, options) {
|
||||
const source = {
|
||||
size: function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
client.headObject(params, function(err, d) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
resolve(d.ContentLength);
|
||||
});
|
||||
});
|
||||
},
|
||||
stream: function(offset, length) {
|
||||
const d = {};
|
||||
for (const key in params)
|
||||
d[key] = params[key];
|
||||
const end = length ? offset + length : '';
|
||||
d.Range = 'bytes='+offset+'-' + end;
|
||||
return client.getObject(d).createReadStream();
|
||||
}
|
||||
};
|
||||
|
||||
return directory(source, options);
|
||||
},
|
||||
s3_v3: function (client, params, options) {
|
||||
//@ts-ignore
|
||||
const { GetObjectCommand, HeadObjectCommand } = require('@aws-sdk/client-s3');
|
||||
const source = {
|
||||
size: async () => {
|
||||
const head = await client.send(
|
||||
new HeadObjectCommand({
|
||||
Bucket: params.Bucket,
|
||||
Key: params.Key,
|
||||
})
|
||||
);
|
||||
|
||||
if(!head.ContentLength) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return head.ContentLength;
|
||||
},
|
||||
stream: (offset, length) => {
|
||||
const stream = Stream.PassThrough();
|
||||
const end = length ? offset + length : "";
|
||||
client
|
||||
.send(
|
||||
new GetObjectCommand({
|
||||
Bucket: params.Bucket,
|
||||
Key: params.Key,
|
||||
Range: `bytes=${offset}-${end}`,
|
||||
})
|
||||
)
|
||||
.then((response) => {
|
||||
response.Body.pipe(stream);
|
||||
})
|
||||
.catch((error) => {
|
||||
stream.emit("error", error);
|
||||
});
|
||||
|
||||
return stream;
|
||||
},
|
||||
};
|
||||
|
||||
return directory(source, options);
|
||||
},
|
||||
custom: function(source, options) {
|
||||
return directory(source, options);
|
||||
}
|
||||
};
|
||||
120
electron/node_modules/unzipper/lib/Open/unzip.js
generated
vendored
Normal file
120
electron/node_modules/unzipper/lib/Open/unzip.js
generated
vendored
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
const Decrypt = require('../Decrypt');
|
||||
const PullStream = require('../PullStream');
|
||||
const Stream = require('stream');
|
||||
const zlib = require('zlib');
|
||||
const parseExtraField = require('../parseExtraField');
|
||||
const parseDateTime = require('../parseDateTime');
|
||||
const parseBuffer = require('../parseBuffer');
|
||||
|
||||
module.exports = function unzip(source, offset, _password, directoryVars, length) {
|
||||
const file = PullStream(),
|
||||
entry = Stream.PassThrough();
|
||||
|
||||
const req = source.stream(offset, length);
|
||||
req.pipe(file).on('error', function(e) {
|
||||
entry.emit('error', e);
|
||||
});
|
||||
|
||||
entry.vars = file.pull(30)
|
||||
.then(function(data) {
|
||||
let vars = parseBuffer.parse(data, [
|
||||
['signature', 4],
|
||||
['versionsNeededToExtract', 2],
|
||||
['flags', 2],
|
||||
['compressionMethod', 2],
|
||||
['lastModifiedTime', 2],
|
||||
['lastModifiedDate', 2],
|
||||
['crc32', 4],
|
||||
['compressedSize', 4],
|
||||
['uncompressedSize', 4],
|
||||
['fileNameLength', 2],
|
||||
['extraFieldLength', 2],
|
||||
]);
|
||||
|
||||
vars.lastModifiedDateTime = parseDateTime(vars.lastModifiedDate, vars.lastModifiedTime);
|
||||
|
||||
return file.pull(vars.fileNameLength)
|
||||
.then(function(fileName) {
|
||||
vars.fileName = fileName.toString('utf8');
|
||||
return file.pull(vars.extraFieldLength);
|
||||
})
|
||||
.then(function(extraField) {
|
||||
let checkEncryption;
|
||||
vars.extra = parseExtraField(extraField, vars);
|
||||
// Ignore logal file header vars if the directory vars are available
|
||||
if (directoryVars && directoryVars.compressedSize) vars = directoryVars;
|
||||
|
||||
if (vars.flags & 0x01) checkEncryption = file.pull(12)
|
||||
.then(function(header) {
|
||||
if (!_password)
|
||||
throw new Error('MISSING_PASSWORD');
|
||||
|
||||
const decrypt = Decrypt();
|
||||
|
||||
String(_password).split('').forEach(function(d) {
|
||||
decrypt.update(d);
|
||||
});
|
||||
|
||||
for (let i=0; i < header.length; i++)
|
||||
header[i] = decrypt.decryptByte(header[i]);
|
||||
|
||||
vars.decrypt = decrypt;
|
||||
vars.compressedSize -= 12;
|
||||
|
||||
const check = (vars.flags & 0x8) ? (vars.lastModifiedTime >> 8) & 0xff : (vars.crc32 >> 24) & 0xff;
|
||||
if (header[11] !== check)
|
||||
throw new Error('BAD_PASSWORD');
|
||||
|
||||
return vars;
|
||||
});
|
||||
|
||||
return Promise.resolve(checkEncryption)
|
||||
.then(function() {
|
||||
entry.emit('vars', vars);
|
||||
return vars;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
entry.vars.then(function(vars) {
|
||||
const fileSizeKnown = !(vars.flags & 0x08) || vars.compressedSize > 0;
|
||||
let eof;
|
||||
|
||||
const inflater = vars.compressionMethod ? zlib.createInflateRaw() : Stream.PassThrough();
|
||||
|
||||
if (fileSizeKnown) {
|
||||
entry.size = vars.uncompressedSize;
|
||||
eof = vars.compressedSize;
|
||||
} else {
|
||||
eof = Buffer.alloc(4);
|
||||
eof.writeUInt32LE(0x08074b50, 0);
|
||||
}
|
||||
|
||||
let stream = file.stream(eof);
|
||||
|
||||
if (vars.decrypt)
|
||||
stream = stream.pipe(vars.decrypt.stream());
|
||||
|
||||
stream
|
||||
.pipe(inflater)
|
||||
.on('error', function(err) { entry.emit('error', err);})
|
||||
.pipe(entry)
|
||||
.on('finish', function() {
|
||||
if(req.destroy)
|
||||
req.destroy();
|
||||
else if (req.abort)
|
||||
req.abort();
|
||||
else if (req.close)
|
||||
req.close();
|
||||
else if (req.push)
|
||||
req.push();
|
||||
else
|
||||
console.log('warning - unable to close stream');
|
||||
});
|
||||
})
|
||||
.catch(function(e) {
|
||||
entry.emit('error', e);
|
||||
});
|
||||
|
||||
return entry;
|
||||
};
|
||||
139
electron/node_modules/unzipper/lib/PullStream.js
generated
vendored
Normal file
139
electron/node_modules/unzipper/lib/PullStream.js
generated
vendored
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
const Stream = require('stream');
|
||||
const util = require('util');
|
||||
const strFunction = 'function';
|
||||
|
||||
function PullStream() {
|
||||
if (!(this instanceof PullStream))
|
||||
return new PullStream();
|
||||
|
||||
Stream.Duplex.call(this, {decodeStrings:false, objectMode:true});
|
||||
this.buffer = Buffer.from('');
|
||||
const self = this;
|
||||
self.on('finish', function() {
|
||||
self.finished = true;
|
||||
self.emit('chunk', false);
|
||||
});
|
||||
}
|
||||
|
||||
util.inherits(PullStream, Stream.Duplex);
|
||||
|
||||
PullStream.prototype._write = function(chunk, e, cb) {
|
||||
this.buffer = Buffer.concat([this.buffer, chunk]);
|
||||
this.cb = cb;
|
||||
this.emit('chunk');
|
||||
};
|
||||
|
||||
|
||||
// The `eof` parameter is interpreted as `file_length` if the type is number
|
||||
// otherwise (i.e. buffer) it is interpreted as a pattern signaling end of stream
|
||||
PullStream.prototype.stream = function(eof, includeEof) {
|
||||
const p = Stream.PassThrough();
|
||||
let done;
|
||||
const self= this;
|
||||
|
||||
function cb() {
|
||||
if (typeof self.cb === strFunction) {
|
||||
const callback = self.cb;
|
||||
self.cb = undefined;
|
||||
return callback();
|
||||
}
|
||||
}
|
||||
|
||||
function pull() {
|
||||
let packet;
|
||||
if (self.buffer && self.buffer.length) {
|
||||
if (typeof eof === 'number') {
|
||||
packet = self.buffer.slice(0, eof);
|
||||
self.buffer = self.buffer.slice(eof);
|
||||
eof -= packet.length;
|
||||
done = done || !eof;
|
||||
} else {
|
||||
let match = self.buffer.indexOf(eof);
|
||||
if (match !== -1) {
|
||||
// store signature match byte offset to allow us to reference
|
||||
// this for zip64 offset
|
||||
self.match = match;
|
||||
if (includeEof) match = match + eof.length;
|
||||
packet = self.buffer.slice(0, match);
|
||||
self.buffer = self.buffer.slice(match);
|
||||
done = true;
|
||||
} else {
|
||||
const len = self.buffer.length - eof.length;
|
||||
if (len <= 0) {
|
||||
cb();
|
||||
} else {
|
||||
packet = self.buffer.slice(0, len);
|
||||
self.buffer = self.buffer.slice(len);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (packet) p.write(packet, function() {
|
||||
if (self.buffer.length === 0 || (eof.length && self.buffer.length <= eof.length)) cb();
|
||||
});
|
||||
}
|
||||
|
||||
if (!done) {
|
||||
if (self.finished) {
|
||||
self.removeListener('chunk', pull);
|
||||
self.emit('error', new Error('FILE_ENDED'));
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
self.removeListener('chunk', pull);
|
||||
p.end();
|
||||
}
|
||||
}
|
||||
|
||||
self.on('chunk', pull);
|
||||
pull();
|
||||
return p;
|
||||
};
|
||||
|
||||
PullStream.prototype.pull = function(eof, includeEof) {
|
||||
if (eof === 0) return Promise.resolve('');
|
||||
|
||||
// If we already have the required data in buffer
|
||||
// we can resolve the request immediately
|
||||
if (!isNaN(eof) && this.buffer.length > eof) {
|
||||
const data = this.buffer.slice(0, eof);
|
||||
this.buffer = this.buffer.slice(eof);
|
||||
return Promise.resolve(data);
|
||||
}
|
||||
|
||||
// Otherwise we stream until we have it
|
||||
let buffer = Buffer.from('');
|
||||
const self = this;
|
||||
|
||||
const concatStream = new Stream.Transform();
|
||||
concatStream._transform = function(d, e, cb) {
|
||||
buffer = Buffer.concat([buffer, d]);
|
||||
cb();
|
||||
};
|
||||
|
||||
let rejectHandler;
|
||||
let pullStreamRejectHandler;
|
||||
return new Promise(function(resolve, reject) {
|
||||
rejectHandler = reject;
|
||||
pullStreamRejectHandler = function(e) {
|
||||
self.__emittedError = e;
|
||||
reject(e);
|
||||
};
|
||||
if (self.finished)
|
||||
return reject(new Error('FILE_ENDED'));
|
||||
self.once('error', pullStreamRejectHandler); // reject any errors from pullstream itself
|
||||
self.stream(eof, includeEof)
|
||||
.on('error', reject)
|
||||
.pipe(concatStream)
|
||||
.on('finish', function() {resolve(buffer);})
|
||||
.on('error', reject);
|
||||
})
|
||||
.finally(function() {
|
||||
self.removeListener('error', rejectHandler);
|
||||
self.removeListener('error', pullStreamRejectHandler);
|
||||
});
|
||||
};
|
||||
|
||||
PullStream.prototype._read = function(){};
|
||||
|
||||
module.exports = PullStream;
|
||||
63
electron/node_modules/unzipper/lib/extract.js
generated
vendored
Normal file
63
electron/node_modules/unzipper/lib/extract.js
generated
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
module.exports = Extract;
|
||||
|
||||
const Parse = require('./parse');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const stream = require('stream');
|
||||
const duplexer2 = require('duplexer2');
|
||||
|
||||
function Extract (opts) {
|
||||
// make sure path is normalized before using it
|
||||
opts.path = path.resolve(path.normalize(opts.path));
|
||||
|
||||
const parser = new Parse(opts);
|
||||
|
||||
const outStream = new stream.Writable({objectMode: true});
|
||||
outStream._write = async function(entry, encoding, cb) {
|
||||
|
||||
// to avoid zip slip (writing outside of the destination), we resolve
|
||||
// the target path, and make sure it's nested in the intended
|
||||
// destination, or not extract it otherwise.
|
||||
// NOTE: Need to normalize to forward slashes for UNIX OS's to properly
|
||||
// ignore the zip slipped file entirely
|
||||
const extractPath = path.join(opts.path, entry.path.replace(/\\/g, '/'));
|
||||
const rel = path.relative(opts.path, extractPath);
|
||||
if (rel === '' || rel.startsWith('..') || path.isAbsolute(rel)) {
|
||||
return cb();
|
||||
}
|
||||
|
||||
|
||||
if (entry.type == 'Directory') {
|
||||
await fs.ensureDir(extractPath);
|
||||
return cb();
|
||||
}
|
||||
|
||||
await fs.ensureDir(path.dirname(extractPath));
|
||||
|
||||
const writer = opts.getWriter ? opts.getWriter({path: extractPath}) : fs.createWriteStream(extractPath);
|
||||
|
||||
entry.pipe(writer)
|
||||
.on('error', cb)
|
||||
.on('close', cb);
|
||||
};
|
||||
|
||||
const extract = duplexer2(parser, outStream);
|
||||
parser.once('crx-header', function(crxHeader) {
|
||||
extract.crxHeader = crxHeader;
|
||||
});
|
||||
|
||||
parser
|
||||
.pipe(outStream)
|
||||
.on('finish', function() {
|
||||
extract.emit('close');
|
||||
});
|
||||
|
||||
extract.promise = function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
extract.on('close', resolve);
|
||||
extract.on('error', reject);
|
||||
});
|
||||
};
|
||||
|
||||
return extract;
|
||||
}
|
||||
288
electron/node_modules/unzipper/lib/parse.js
generated
vendored
Normal file
288
electron/node_modules/unzipper/lib/parse.js
generated
vendored
Normal file
|
|
@ -0,0 +1,288 @@
|
|||
const util = require('util');
|
||||
const zlib = require('zlib');
|
||||
const Stream = require('stream');
|
||||
const PullStream = require('./PullStream');
|
||||
const NoopStream = require('./NoopStream');
|
||||
const BufferStream = require('./BufferStream');
|
||||
const parseExtraField = require('./parseExtraField');
|
||||
const parseDateTime = require('./parseDateTime');
|
||||
const pipeline = Stream.pipeline;
|
||||
const parseBuffer = require('./parseBuffer');
|
||||
|
||||
const endDirectorySignature = Buffer.alloc(4);
|
||||
endDirectorySignature.writeUInt32LE(0x06054b50, 0);
|
||||
|
||||
function Parse(opts) {
|
||||
if (!(this instanceof Parse)) {
|
||||
return new Parse(opts);
|
||||
}
|
||||
const self = this;
|
||||
self._opts = opts || { verbose: false };
|
||||
|
||||
PullStream.call(self, self._opts);
|
||||
self.on('finish', function() {
|
||||
self.emit('end');
|
||||
self.emit('close');
|
||||
});
|
||||
self._readRecord().catch(function(e) {
|
||||
if (!self.__emittedError || self.__emittedError !== e)
|
||||
self.emit('error', e);
|
||||
});
|
||||
}
|
||||
|
||||
util.inherits(Parse, PullStream);
|
||||
|
||||
Parse.prototype._readRecord = function () {
|
||||
const self = this;
|
||||
|
||||
return self.pull(4).then(function(data) {
|
||||
if (data.length === 0)
|
||||
return;
|
||||
|
||||
const signature = data.readUInt32LE(0);
|
||||
|
||||
if (signature === 0x34327243) {
|
||||
return self._readCrxHeader();
|
||||
}
|
||||
if (signature === 0x04034b50) {
|
||||
return self._readFile();
|
||||
}
|
||||
else if (signature === 0x02014b50) {
|
||||
self.reachedCD = true;
|
||||
return self._readCentralDirectoryFileHeader();
|
||||
}
|
||||
else if (signature === 0x06054b50) {
|
||||
return self._readEndOfCentralDirectoryRecord();
|
||||
}
|
||||
else if (self.reachedCD) {
|
||||
// _readEndOfCentralDirectoryRecord expects the EOCD
|
||||
// signature to be consumed so set includeEof=true
|
||||
const includeEof = true;
|
||||
return self.pull(endDirectorySignature, includeEof).then(function() {
|
||||
return self._readEndOfCentralDirectoryRecord();
|
||||
});
|
||||
}
|
||||
else
|
||||
self.emit('error', new Error('invalid signature: 0x' + signature.toString(16)));
|
||||
}).then((function(loop) {
|
||||
if(loop) {
|
||||
return self._readRecord();
|
||||
}
|
||||
}));
|
||||
};
|
||||
|
||||
Parse.prototype._readCrxHeader = function() {
|
||||
const self = this;
|
||||
return self.pull(12).then(function(data) {
|
||||
self.crxHeader = parseBuffer.parse(data, [
|
||||
['version', 4],
|
||||
['pubKeyLength', 4],
|
||||
['signatureLength', 4],
|
||||
]);
|
||||
return self.pull(self.crxHeader.pubKeyLength + self.crxHeader.signatureLength);
|
||||
}).then(function(data) {
|
||||
self.crxHeader.publicKey = data.slice(0, self.crxHeader.pubKeyLength);
|
||||
self.crxHeader.signature = data.slice(self.crxHeader.pubKeyLength);
|
||||
self.emit('crx-header', self.crxHeader);
|
||||
return true;
|
||||
});
|
||||
};
|
||||
|
||||
Parse.prototype._readFile = function () {
|
||||
const self = this;
|
||||
return self.pull(26).then(function(data) {
|
||||
const vars = parseBuffer.parse(data, [
|
||||
['versionsNeededToExtract', 2],
|
||||
['flags', 2],
|
||||
['compressionMethod', 2],
|
||||
['lastModifiedTime', 2],
|
||||
['lastModifiedDate', 2],
|
||||
['crc32', 4],
|
||||
['compressedSize', 4],
|
||||
['uncompressedSize', 4],
|
||||
['fileNameLength', 2],
|
||||
['extraFieldLength', 2],
|
||||
]);
|
||||
|
||||
vars.lastModifiedDateTime = parseDateTime(vars.lastModifiedDate, vars.lastModifiedTime);
|
||||
|
||||
if (self.crxHeader) vars.crxHeader = self.crxHeader;
|
||||
|
||||
return self.pull(vars.fileNameLength).then(function(fileNameBuffer) {
|
||||
const fileName = fileNameBuffer.toString('utf8');
|
||||
const entry = Stream.PassThrough();
|
||||
let __autodraining = false;
|
||||
|
||||
entry.autodrain = function() {
|
||||
__autodraining = true;
|
||||
const draining = entry.pipe(NoopStream());
|
||||
draining.promise = function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
draining.on('finish', resolve);
|
||||
draining.on('error', reject);
|
||||
});
|
||||
};
|
||||
return draining;
|
||||
};
|
||||
|
||||
entry.buffer = function() {
|
||||
return BufferStream(entry);
|
||||
};
|
||||
|
||||
entry.path = fileName;
|
||||
entry.props = {};
|
||||
entry.props.path = fileName;
|
||||
entry.props.pathBuffer = fileNameBuffer;
|
||||
entry.props.flags = {
|
||||
"isUnicode": (vars.flags & 0x800) != 0
|
||||
};
|
||||
entry.type = (vars.uncompressedSize === 0 && /[/\\]$/.test(fileName)) ? 'Directory' : 'File';
|
||||
|
||||
if (self._opts.verbose) {
|
||||
if (entry.type === 'Directory') {
|
||||
console.log(' creating:', fileName);
|
||||
} else if (entry.type === 'File') {
|
||||
if (vars.compressionMethod === 0) {
|
||||
console.log(' extracting:', fileName);
|
||||
} else {
|
||||
console.log(' inflating:', fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self.pull(vars.extraFieldLength).then(function(extraField) {
|
||||
const extra = parseExtraField(extraField, vars);
|
||||
|
||||
entry.vars = vars;
|
||||
entry.extra = extra;
|
||||
|
||||
if (self._opts.forceStream) {
|
||||
self.push(entry);
|
||||
} else {
|
||||
self.emit('entry', entry);
|
||||
|
||||
if (self._readableState.pipesCount || (self._readableState.pipes && self._readableState.pipes.length))
|
||||
self.push(entry);
|
||||
}
|
||||
|
||||
if (self._opts.verbose)
|
||||
console.log({
|
||||
filename:fileName,
|
||||
vars: vars,
|
||||
extra: extra
|
||||
});
|
||||
|
||||
const fileSizeKnown = !(vars.flags & 0x08) || vars.compressedSize > 0;
|
||||
let eof;
|
||||
|
||||
entry.__autodraining = __autodraining; // expose __autodraining for test purposes
|
||||
const inflater = (vars.compressionMethod && !__autodraining) ? zlib.createInflateRaw() : Stream.PassThrough();
|
||||
|
||||
if (fileSizeKnown) {
|
||||
entry.size = vars.uncompressedSize;
|
||||
eof = vars.compressedSize;
|
||||
} else {
|
||||
eof = Buffer.alloc(4);
|
||||
eof.writeUInt32LE(0x08074b50, 0);
|
||||
}
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
pipeline(
|
||||
self.stream(eof),
|
||||
inflater,
|
||||
entry,
|
||||
function (err) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
return fileSizeKnown ? resolve(fileSizeKnown) : self._processDataDescriptor(entry).then(resolve).catch(reject);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Parse.prototype._processDataDescriptor = function (entry) {
|
||||
const self = this;
|
||||
return self.pull(16).then(function(data) {
|
||||
const vars = parseBuffer.parse(data, [
|
||||
['dataDescriptorSignature', 4],
|
||||
['crc32', 4],
|
||||
['compressedSize', 4],
|
||||
['uncompressedSize', 4],
|
||||
]);
|
||||
|
||||
entry.size = vars.uncompressedSize;
|
||||
return true;
|
||||
});
|
||||
};
|
||||
|
||||
Parse.prototype._readCentralDirectoryFileHeader = function () {
|
||||
const self = this;
|
||||
return self.pull(42).then(function(data) {
|
||||
const vars = parseBuffer.parse(data, [
|
||||
['versionMadeBy', 2],
|
||||
['versionsNeededToExtract', 2],
|
||||
['flags', 2],
|
||||
['compressionMethod', 2],
|
||||
['lastModifiedTime', 2],
|
||||
['lastModifiedDate', 2],
|
||||
['crc32', 4],
|
||||
['compressedSize', 4],
|
||||
['uncompressedSize', 4],
|
||||
['fileNameLength', 2],
|
||||
['extraFieldLength', 2],
|
||||
['fileCommentLength', 2],
|
||||
['diskNumber', 2],
|
||||
['internalFileAttributes', 2],
|
||||
['externalFileAttributes', 4],
|
||||
['offsetToLocalFileHeader', 4],
|
||||
]);
|
||||
|
||||
return self.pull(vars.fileNameLength).then(function(fileName) {
|
||||
vars.fileName = fileName.toString('utf8');
|
||||
return self.pull(vars.extraFieldLength);
|
||||
})
|
||||
.then(function() {
|
||||
return self.pull(vars.fileCommentLength);
|
||||
})
|
||||
.then(function() {
|
||||
return true;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Parse.prototype._readEndOfCentralDirectoryRecord = function() {
|
||||
const self = this;
|
||||
return self.pull(18).then(function(data) {
|
||||
|
||||
const vars = parseBuffer.parse(data, [
|
||||
['diskNumber', 2],
|
||||
['diskStart', 2],
|
||||
['numberOfRecordsOnDisk', 2],
|
||||
['numberOfRecords', 2],
|
||||
['sizeOfCentralDirectory', 4],
|
||||
['offsetToStartOfCentralDirectory', 4],
|
||||
['commentLength', 2],
|
||||
]);
|
||||
|
||||
return self.pull(vars.commentLength).then(function() {
|
||||
self.end();
|
||||
self.push(null);
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
Parse.prototype.promise = function() {
|
||||
const self = this;
|
||||
return new Promise(function(resolve, reject) {
|
||||
self.on('finish', resolve);
|
||||
self.on('error', reject);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = Parse;
|
||||
55
electron/node_modules/unzipper/lib/parseBuffer.js
generated
vendored
Normal file
55
electron/node_modules/unzipper/lib/parseBuffer.js
generated
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
const parseUIntLE = function(buffer, offset, size) {
|
||||
let result;
|
||||
switch(size) {
|
||||
case 1:
|
||||
result = buffer.readUInt8(offset);
|
||||
break;
|
||||
case 2:
|
||||
result = buffer.readUInt16LE(offset);
|
||||
break;
|
||||
case 4:
|
||||
result = buffer.readUInt32LE(offset);
|
||||
break;
|
||||
case 8:
|
||||
result = Number(buffer.readBigUInt64LE(offset));
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unsupported UInt LE size!');
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses sequential unsigned little endian numbers from the head of the passed buffer according to
|
||||
* the specified format passed. If the buffer is not large enough to satisfy the full format,
|
||||
* null values will be assigned to the remaining keys.
|
||||
* @param {*} buffer The buffer to sequentially extract numbers from.
|
||||
* @param {*} format Expected format to follow when extrcting values from the buffer. A list of list entries
|
||||
* with the following structure:
|
||||
* [
|
||||
* [
|
||||
* <key>, // Name of the key to assign the extracted number to.
|
||||
* <size> // The size in bytes of the number to extract. possible values are 1, 2, 4, 8.
|
||||
* ],
|
||||
* ...
|
||||
* ]
|
||||
* @returns An object with keys set to their associated extracted values.
|
||||
*/
|
||||
const parse = function(buffer, format) {
|
||||
const result = {};
|
||||
let offset = 0;
|
||||
for(const [key, size] of format) {
|
||||
if(buffer.length >= offset + size) {
|
||||
result[key] = parseUIntLE(buffer, offset, size);
|
||||
}
|
||||
else {
|
||||
result[key] = null;
|
||||
}
|
||||
offset += size;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
parse
|
||||
};
|
||||
13
electron/node_modules/unzipper/lib/parseDateTime.js
generated
vendored
Normal file
13
electron/node_modules/unzipper/lib/parseDateTime.js
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Dates in zip file entries are stored as DosDateTime
|
||||
// Spec is here: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-dosdatetimetofiletime
|
||||
|
||||
module.exports = function parseDateTime(date, time) {
|
||||
const day = date & 0x1F;
|
||||
const month = date >> 5 & 0x0F;
|
||||
const year = (date >> 9 & 0x7F) + 1980;
|
||||
const seconds = time ? (time & 0x1F) * 2 : 0;
|
||||
const minutes = time ? (time >> 5) & 0x3F : 0;
|
||||
const hours = time ? (time >> 11): 0;
|
||||
|
||||
return new Date(Date.UTC(year, month-1, day, hours, minutes, seconds));
|
||||
};
|
||||
40
electron/node_modules/unzipper/lib/parseExtraField.js
generated
vendored
Normal file
40
electron/node_modules/unzipper/lib/parseExtraField.js
generated
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
const parseBuffer = require('./parseBuffer');
|
||||
|
||||
module.exports = function(extraField, vars) {
|
||||
let extra;
|
||||
// Find the ZIP64 header, if present.
|
||||
while(!extra && extraField && extraField.length) {
|
||||
const candidateExtra = parseBuffer.parse(extraField, [
|
||||
['signature', 2],
|
||||
['partSize', 2],
|
||||
]);
|
||||
|
||||
if(candidateExtra.signature === 0x0001) {
|
||||
// parse buffer based on data in ZIP64 central directory; order is important!
|
||||
const fieldsToExpect = [];
|
||||
if (vars.uncompressedSize === 0xffffffff) fieldsToExpect.push(['uncompressedSize', 8]);
|
||||
if (vars.compressedSize === 0xffffffff) fieldsToExpect.push(['compressedSize', 8]);
|
||||
if (vars.offsetToLocalFileHeader === 0xffffffff) fieldsToExpect.push(['offsetToLocalFileHeader', 8]);
|
||||
|
||||
// slice off the 4 bytes for signature and partSize
|
||||
extra = parseBuffer.parse(extraField.slice(4), fieldsToExpect);
|
||||
} else {
|
||||
// Advance the buffer to the next part.
|
||||
// The total size of this part is the 4 byte header + partsize.
|
||||
extraField = extraField.slice(candidateExtra.partSize + 4);
|
||||
}
|
||||
}
|
||||
|
||||
extra = extra || {};
|
||||
|
||||
if (vars.compressedSize === 0xffffffff)
|
||||
vars.compressedSize = extra.compressedSize;
|
||||
|
||||
if (vars.uncompressedSize === 0xffffffff)
|
||||
vars.uncompressedSize= extra.uncompressedSize;
|
||||
|
||||
if (vars.offsetToLocalFileHeader === 0xffffffff)
|
||||
vars.offsetToLocalFileHeader = extra.offsetToLocalFileHeader;
|
||||
|
||||
return extra;
|
||||
};
|
||||
54
electron/node_modules/unzipper/lib/parseOne.js
generated
vendored
Normal file
54
electron/node_modules/unzipper/lib/parseOne.js
generated
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
const Stream = require('stream');
|
||||
const Parse = require('./parse');
|
||||
const duplexer2 = require('duplexer2');
|
||||
const BufferStream = require('./BufferStream');
|
||||
|
||||
function parseOne(match, opts) {
|
||||
const inStream = Stream.PassThrough({objectMode:true});
|
||||
const outStream = Stream.PassThrough();
|
||||
const transform = Stream.Transform({objectMode:true});
|
||||
const re = match instanceof RegExp ? match : (match && new RegExp(match));
|
||||
let found;
|
||||
|
||||
transform._transform = function(entry, e, cb) {
|
||||
if (found || (re && !re.exec(entry.path))) {
|
||||
entry.autodrain();
|
||||
return cb();
|
||||
} else {
|
||||
found = true;
|
||||
out.emit('entry', entry);
|
||||
entry.on('error', function(e) {
|
||||
outStream.emit('error', e);
|
||||
});
|
||||
entry.pipe(outStream)
|
||||
.on('error', function(err) {
|
||||
cb(err);
|
||||
})
|
||||
.on('finish', function(d) {
|
||||
cb(null, d);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
inStream.pipe(Parse(opts))
|
||||
.on('error', function(err) {
|
||||
outStream.emit('error', err);
|
||||
})
|
||||
.pipe(transform)
|
||||
.on('error', Object) // Silence error as its already addressed in transform
|
||||
.on('finish', function() {
|
||||
if (!found)
|
||||
outStream.emit('error', new Error('PATTERN_NOT_FOUND'));
|
||||
else
|
||||
outStream.end();
|
||||
});
|
||||
|
||||
const out = duplexer2(inStream, outStream);
|
||||
out.buffer = function() {
|
||||
return BufferStream(outStream);
|
||||
};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
module.exports = parseOne;
|
||||
15
electron/node_modules/unzipper/node_modules/fs-extra/LICENSE
generated
vendored
Normal file
15
electron/node_modules/unzipper/node_modules/fs-extra/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2011-2024 JP Richardson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
|
||||
(the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
|
||||
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
294
electron/node_modules/unzipper/node_modules/fs-extra/README.md
generated
vendored
Normal file
294
electron/node_modules/unzipper/node_modules/fs-extra/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,294 @@
|
|||
Node.js: fs-extra
|
||||
=================
|
||||
|
||||
`fs-extra` adds file system methods that aren't included in the native `fs` module and adds promise support to the `fs` methods. It also uses [`graceful-fs`](https://github.com/isaacs/node-graceful-fs) to prevent `EMFILE` errors. It should be a drop in replacement for `fs`.
|
||||
|
||||
[](https://www.npmjs.org/package/fs-extra)
|
||||
[](https://github.com/jprichardson/node-fs-extra/blob/master/LICENSE)
|
||||
[](https://github.com/jprichardson/node-fs-extra/actions/workflows/ci.yml?query=branch%3Amaster)
|
||||
[](https://www.npmjs.org/package/fs-extra)
|
||||
[](https://standardjs.com)
|
||||
|
||||
Why?
|
||||
----
|
||||
|
||||
I got tired of including `mkdirp`, `rimraf`, and `ncp` in most of my projects.
|
||||
|
||||
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
npm install fs-extra
|
||||
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
### CommonJS
|
||||
|
||||
`fs-extra` is a drop in replacement for native `fs`. All methods in `fs` are attached to `fs-extra`. All `fs` methods return promises if the callback isn't passed.
|
||||
|
||||
You don't ever need to include the original `fs` module again:
|
||||
|
||||
```js
|
||||
const fs = require('fs') // this is no longer necessary
|
||||
```
|
||||
|
||||
you can now do this:
|
||||
|
||||
```js
|
||||
const fs = require('fs-extra')
|
||||
```
|
||||
|
||||
or if you prefer to make it clear that you're using `fs-extra` and not `fs`, you may want
|
||||
to name your `fs` variable `fse` like so:
|
||||
|
||||
```js
|
||||
const fse = require('fs-extra')
|
||||
```
|
||||
|
||||
you can also keep both, but it's redundant:
|
||||
|
||||
```js
|
||||
const fs = require('fs')
|
||||
const fse = require('fs-extra')
|
||||
```
|
||||
|
||||
**NOTE:** The deprecated constants `fs.F_OK`, `fs.R_OK`, `fs.W_OK`, & `fs.X_OK` are not exported on Node.js v24.0.0+; please use their `fs.constants` equivalents.
|
||||
|
||||
### ESM
|
||||
|
||||
There is also an `fs-extra/esm` import, that supports both default and named exports. However, note that `fs` methods are not included in `fs-extra/esm`; you still need to import `fs` and/or `fs/promises` seperately:
|
||||
|
||||
```js
|
||||
import { readFileSync } from 'fs'
|
||||
import { readFile } from 'fs/promises'
|
||||
import { outputFile, outputFileSync } from 'fs-extra/esm'
|
||||
```
|
||||
|
||||
Default exports are supported:
|
||||
|
||||
```js
|
||||
import fs from 'fs'
|
||||
import fse from 'fs-extra/esm'
|
||||
// fse.readFileSync is not a function; must use fs.readFileSync
|
||||
```
|
||||
|
||||
but you probably want to just use regular `fs-extra` instead of `fs-extra/esm` for default exports:
|
||||
|
||||
```js
|
||||
import fs from 'fs-extra'
|
||||
// both fs and fs-extra methods are defined
|
||||
```
|
||||
|
||||
Sync vs Async vs Async/Await
|
||||
-------------
|
||||
Most methods are async by default. All async methods will return a promise if the callback isn't passed.
|
||||
|
||||
Sync methods on the other hand will throw if an error occurs.
|
||||
|
||||
Also Async/Await will throw an error if one occurs.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
const fs = require('fs-extra')
|
||||
|
||||
// Async with promises:
|
||||
fs.copy('/tmp/myfile', '/tmp/mynewfile')
|
||||
.then(() => console.log('success!'))
|
||||
.catch(err => console.error(err))
|
||||
|
||||
// Async with callbacks:
|
||||
fs.copy('/tmp/myfile', '/tmp/mynewfile', err => {
|
||||
if (err) return console.error(err)
|
||||
console.log('success!')
|
||||
})
|
||||
|
||||
// Sync:
|
||||
try {
|
||||
fs.copySync('/tmp/myfile', '/tmp/mynewfile')
|
||||
console.log('success!')
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
|
||||
// Async/Await:
|
||||
async function copyFiles () {
|
||||
try {
|
||||
await fs.copy('/tmp/myfile', '/tmp/mynewfile')
|
||||
console.log('success!')
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
}
|
||||
|
||||
copyFiles()
|
||||
```
|
||||
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
### Async
|
||||
|
||||
- [copy](docs/copy.md)
|
||||
- [emptyDir](docs/emptyDir.md)
|
||||
- [ensureFile](docs/ensureFile.md)
|
||||
- [ensureDir](docs/ensureDir.md)
|
||||
- [ensureLink](docs/ensureLink.md)
|
||||
- [ensureSymlink](docs/ensureSymlink.md)
|
||||
- [mkdirp](docs/ensureDir.md)
|
||||
- [mkdirs](docs/ensureDir.md)
|
||||
- [move](docs/move.md)
|
||||
- [outputFile](docs/outputFile.md)
|
||||
- [outputJson](docs/outputJson.md)
|
||||
- [pathExists](docs/pathExists.md)
|
||||
- [readJson](docs/readJson.md)
|
||||
- [remove](docs/remove.md)
|
||||
- [writeJson](docs/writeJson.md)
|
||||
|
||||
### Sync
|
||||
|
||||
- [copySync](docs/copy-sync.md)
|
||||
- [emptyDirSync](docs/emptyDir-sync.md)
|
||||
- [ensureFileSync](docs/ensureFile-sync.md)
|
||||
- [ensureDirSync](docs/ensureDir-sync.md)
|
||||
- [ensureLinkSync](docs/ensureLink-sync.md)
|
||||
- [ensureSymlinkSync](docs/ensureSymlink-sync.md)
|
||||
- [mkdirpSync](docs/ensureDir-sync.md)
|
||||
- [mkdirsSync](docs/ensureDir-sync.md)
|
||||
- [moveSync](docs/move-sync.md)
|
||||
- [outputFileSync](docs/outputFile-sync.md)
|
||||
- [outputJsonSync](docs/outputJson-sync.md)
|
||||
- [pathExistsSync](docs/pathExists-sync.md)
|
||||
- [readJsonSync](docs/readJson-sync.md)
|
||||
- [removeSync](docs/remove-sync.md)
|
||||
- [writeJsonSync](docs/writeJson-sync.md)
|
||||
|
||||
|
||||
**NOTE:** You can still use the native Node.js methods. They are promisified and copied over to `fs-extra`. See [notes on `fs.read()`, `fs.write()`, & `fs.writev()`](docs/fs-read-write-writev.md)
|
||||
|
||||
### What happened to `walk()` and `walkSync()`?
|
||||
|
||||
They were removed from `fs-extra` in v2.0.0. If you need the functionality, `walk` and `walkSync` are available as separate packages, [`klaw`](https://github.com/jprichardson/node-klaw) and [`klaw-sync`](https://github.com/manidlou/node-klaw-sync).
|
||||
|
||||
|
||||
Third Party
|
||||
-----------
|
||||
|
||||
### CLI
|
||||
|
||||
[fse-cli](https://www.npmjs.com/package/@atao60/fse-cli) allows you to run `fs-extra` from a console or from [npm](https://www.npmjs.com) scripts.
|
||||
|
||||
### TypeScript
|
||||
|
||||
If you like TypeScript, you can use `fs-extra` with it: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/fs-extra
|
||||
|
||||
|
||||
### File / Directory Watching
|
||||
|
||||
If you want to watch for changes to files or directories, then you should use [chokidar](https://github.com/paulmillr/chokidar).
|
||||
|
||||
### Obtain Filesystem (Devices, Partitions) Information
|
||||
|
||||
[fs-filesystem](https://github.com/arthurintelligence/node-fs-filesystem) allows you to read the state of the filesystem of the host on which it is run. It returns information about both the devices and the partitions (volumes) of the system.
|
||||
|
||||
### Misc.
|
||||
|
||||
- [fs-extra-debug](https://github.com/jdxcode/fs-extra-debug) - Send your fs-extra calls to [debug](https://npmjs.org/package/debug).
|
||||
- [mfs](https://github.com/cadorn/mfs) - Monitor your fs-extra calls.
|
||||
|
||||
|
||||
|
||||
Hacking on fs-extra
|
||||
-------------------
|
||||
|
||||
Wanna hack on `fs-extra`? Great! Your help is needed! [fs-extra is one of the most depended upon Node.js packages](http://nodei.co/npm/fs-extra.png?downloads=true&downloadRank=true&stars=true). This project
|
||||
uses [JavaScript Standard Style](https://github.com/feross/standard) - if the name or style choices bother you,
|
||||
you're gonna have to get over it :) If `standard` is good enough for `npm`, it's good enough for `fs-extra`.
|
||||
|
||||
[](https://github.com/feross/standard)
|
||||
|
||||
What's needed?
|
||||
- First, take a look at existing issues. Those are probably going to be where the priority lies.
|
||||
- More tests for edge cases. Specifically on different platforms. There can never be enough tests.
|
||||
- Improve test coverage.
|
||||
|
||||
Note: If you make any big changes, **you should definitely file an issue for discussion first.**
|
||||
|
||||
### Running the Test Suite
|
||||
|
||||
fs-extra contains hundreds of tests.
|
||||
|
||||
- `npm run lint`: runs the linter ([standard](http://standardjs.com/))
|
||||
- `npm run unit`: runs the unit tests
|
||||
- `npm run unit-esm`: runs tests for `fs-extra/esm` exports
|
||||
- `npm test`: runs the linter and all tests
|
||||
|
||||
When running unit tests, set the environment variable `CROSS_DEVICE_PATH` to the absolute path of an empty directory on another device (like a thumb drive) to enable cross-device move tests.
|
||||
|
||||
|
||||
### Windows
|
||||
|
||||
If you run the tests on the Windows and receive a lot of symbolic link `EPERM` permission errors, it's
|
||||
because on Windows you need elevated privilege to create symbolic links. You can add this to your Windows's
|
||||
account by following the instructions here: http://superuser.com/questions/104845/permission-to-make-symbolic-links-in-windows-7
|
||||
However, I didn't have much luck doing this.
|
||||
|
||||
Since I develop on Mac OS X, I use VMWare Fusion for Windows testing. I create a shared folder that I map to a drive on Windows.
|
||||
I open the `Node.js command prompt` and run as `Administrator`. I then map the network drive running the following command:
|
||||
|
||||
net use z: "\\vmware-host\Shared Folders"
|
||||
|
||||
I can then navigate to my `fs-extra` directory and run the tests.
|
||||
|
||||
|
||||
Naming
|
||||
------
|
||||
|
||||
I put a lot of thought into the naming of these functions. Inspired by @coolaj86's request. So he deserves much of the credit for raising the issue. See discussion(s) here:
|
||||
|
||||
* https://github.com/jprichardson/node-fs-extra/issues/2
|
||||
* https://github.com/flatiron/utile/issues/11
|
||||
* https://github.com/ryanmcgrath/wrench-js/issues/29
|
||||
* https://github.com/substack/node-mkdirp/issues/17
|
||||
|
||||
First, I believe that in as many cases as possible, the [Node.js naming schemes](http://nodejs.org/api/fs.html) should be chosen. However, there are problems with the Node.js own naming schemes.
|
||||
|
||||
For example, `fs.readFile()` and `fs.readdir()`: the **F** is capitalized in *File* and the **d** is not capitalized in *dir*. Perhaps a bit pedantic, but they should still be consistent. Also, Node.js has chosen a lot of POSIX naming schemes, which I believe is great. See: `fs.mkdir()`, `fs.rmdir()`, `fs.chown()`, etc.
|
||||
|
||||
We have a dilemma though. How do you consistently name methods that perform the following POSIX commands: `cp`, `cp -r`, `mkdir -p`, and `rm -rf`?
|
||||
|
||||
My perspective: when in doubt, err on the side of simplicity. A directory is just a hierarchical grouping of directories and files. Consider that for a moment. So when you want to copy it or remove it, in most cases you'll want to copy or remove all of its contents. When you want to create a directory, if the directory that it's suppose to be contained in does not exist, then in most cases you'll want to create that too.
|
||||
|
||||
So, if you want to remove a file or a directory regardless of whether it has contents, just call `fs.remove(path)`. If you want to copy a file or a directory whether it has contents, just call `fs.copy(source, destination)`. If you want to create a directory regardless of whether its parent directories exist, just call `fs.mkdirs(path)` or `fs.mkdirp(path)`.
|
||||
|
||||
|
||||
Credit
|
||||
------
|
||||
|
||||
`fs-extra` wouldn't be possible without using the modules from the following authors:
|
||||
|
||||
- [Isaac Shlueter](https://github.com/isaacs)
|
||||
- [Charlie McConnel](https://github.com/avianflu)
|
||||
- [James Halliday](https://github.com/substack)
|
||||
- [Andrew Kelley](https://github.com/andrewrk)
|
||||
|
||||
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Licensed under MIT
|
||||
|
||||
Copyright (c) 2011-2024 [JP Richardson](https://github.com/jprichardson)
|
||||
|
||||
[1]: http://nodejs.org/docs/latest/api/fs.html
|
||||
|
||||
|
||||
[jsonfile]: https://github.com/jprichardson/node-jsonfile
|
||||
171
electron/node_modules/unzipper/node_modules/fs-extra/lib/copy/copy-sync.js
generated
vendored
Normal file
171
electron/node_modules/unzipper/node_modules/fs-extra/lib/copy/copy-sync.js
generated
vendored
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
'use strict'
|
||||
|
||||
const fs = require('graceful-fs')
|
||||
const path = require('path')
|
||||
const mkdirsSync = require('../mkdirs').mkdirsSync
|
||||
const utimesMillisSync = require('../util/utimes').utimesMillisSync
|
||||
const stat = require('../util/stat')
|
||||
|
||||
function copySync (src, dest, opts) {
|
||||
if (typeof opts === 'function') {
|
||||
opts = { filter: opts }
|
||||
}
|
||||
|
||||
opts = opts || {}
|
||||
opts.clobber = 'clobber' in opts ? !!opts.clobber : true // default to true for now
|
||||
opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber // overwrite falls back to clobber
|
||||
|
||||
// Warn about using preserveTimestamps on 32-bit node
|
||||
if (opts.preserveTimestamps && process.arch === 'ia32') {
|
||||
process.emitWarning(
|
||||
'Using the preserveTimestamps option in 32-bit node is not recommended;\n\n' +
|
||||
'\tsee https://github.com/jprichardson/node-fs-extra/issues/269',
|
||||
'Warning', 'fs-extra-WARN0002'
|
||||
)
|
||||
}
|
||||
|
||||
const { srcStat, destStat } = stat.checkPathsSync(src, dest, 'copy', opts)
|
||||
stat.checkParentPathsSync(src, srcStat, dest, 'copy')
|
||||
if (opts.filter && !opts.filter(src, dest)) return
|
||||
const destParent = path.dirname(dest)
|
||||
if (!fs.existsSync(destParent)) mkdirsSync(destParent)
|
||||
return getStats(destStat, src, dest, opts)
|
||||
}
|
||||
|
||||
function getStats (destStat, src, dest, opts) {
|
||||
const statSync = opts.dereference ? fs.statSync : fs.lstatSync
|
||||
const srcStat = statSync(src)
|
||||
|
||||
if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts)
|
||||
else if (srcStat.isFile() ||
|
||||
srcStat.isCharacterDevice() ||
|
||||
srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts)
|
||||
else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts)
|
||||
else if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`)
|
||||
else if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`)
|
||||
throw new Error(`Unknown file: ${src}`)
|
||||
}
|
||||
|
||||
function onFile (srcStat, destStat, src, dest, opts) {
|
||||
if (!destStat) return copyFile(srcStat, src, dest, opts)
|
||||
return mayCopyFile(srcStat, src, dest, opts)
|
||||
}
|
||||
|
||||
function mayCopyFile (srcStat, src, dest, opts) {
|
||||
if (opts.overwrite) {
|
||||
fs.unlinkSync(dest)
|
||||
return copyFile(srcStat, src, dest, opts)
|
||||
} else if (opts.errorOnExist) {
|
||||
throw new Error(`'${dest}' already exists`)
|
||||
}
|
||||
}
|
||||
|
||||
function copyFile (srcStat, src, dest, opts) {
|
||||
fs.copyFileSync(src, dest)
|
||||
if (opts.preserveTimestamps) handleTimestamps(srcStat.mode, src, dest)
|
||||
return setDestMode(dest, srcStat.mode)
|
||||
}
|
||||
|
||||
function handleTimestamps (srcMode, src, dest) {
|
||||
// Make sure the file is writable before setting the timestamp
|
||||
// otherwise open fails with EPERM when invoked with 'r+'
|
||||
// (through utimes call)
|
||||
if (fileIsNotWritable(srcMode)) makeFileWritable(dest, srcMode)
|
||||
return setDestTimestamps(src, dest)
|
||||
}
|
||||
|
||||
function fileIsNotWritable (srcMode) {
|
||||
return (srcMode & 0o200) === 0
|
||||
}
|
||||
|
||||
function makeFileWritable (dest, srcMode) {
|
||||
return setDestMode(dest, srcMode | 0o200)
|
||||
}
|
||||
|
||||
function setDestMode (dest, srcMode) {
|
||||
return fs.chmodSync(dest, srcMode)
|
||||
}
|
||||
|
||||
function setDestTimestamps (src, dest) {
|
||||
// The initial srcStat.atime cannot be trusted
|
||||
// because it is modified by the read(2) system call
|
||||
// (See https://nodejs.org/api/fs.html#fs_stat_time_values)
|
||||
const updatedSrcStat = fs.statSync(src)
|
||||
return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime)
|
||||
}
|
||||
|
||||
function onDir (srcStat, destStat, src, dest, opts) {
|
||||
if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts)
|
||||
return copyDir(src, dest, opts)
|
||||
}
|
||||
|
||||
function mkDirAndCopy (srcMode, src, dest, opts) {
|
||||
fs.mkdirSync(dest)
|
||||
copyDir(src, dest, opts)
|
||||
return setDestMode(dest, srcMode)
|
||||
}
|
||||
|
||||
function copyDir (src, dest, opts) {
|
||||
const dir = fs.opendirSync(src)
|
||||
|
||||
try {
|
||||
let dirent
|
||||
|
||||
while ((dirent = dir.readSync()) !== null) {
|
||||
copyDirItem(dirent.name, src, dest, opts)
|
||||
}
|
||||
} finally {
|
||||
dir.closeSync()
|
||||
}
|
||||
}
|
||||
|
||||
function copyDirItem (item, src, dest, opts) {
|
||||
const srcItem = path.join(src, item)
|
||||
const destItem = path.join(dest, item)
|
||||
if (opts.filter && !opts.filter(srcItem, destItem)) return
|
||||
const { destStat } = stat.checkPathsSync(srcItem, destItem, 'copy', opts)
|
||||
return getStats(destStat, srcItem, destItem, opts)
|
||||
}
|
||||
|
||||
function onLink (destStat, src, dest, opts) {
|
||||
let resolvedSrc = fs.readlinkSync(src)
|
||||
if (opts.dereference) {
|
||||
resolvedSrc = path.resolve(process.cwd(), resolvedSrc)
|
||||
}
|
||||
|
||||
if (!destStat) {
|
||||
return fs.symlinkSync(resolvedSrc, dest)
|
||||
} else {
|
||||
let resolvedDest
|
||||
try {
|
||||
resolvedDest = fs.readlinkSync(dest)
|
||||
} catch (err) {
|
||||
// dest exists and is a regular file or directory,
|
||||
// Windows may throw UNKNOWN error. If dest already exists,
|
||||
// fs throws error anyway, so no need to guard against it here.
|
||||
if (err.code === 'EINVAL' || err.code === 'UNKNOWN') return fs.symlinkSync(resolvedSrc, dest)
|
||||
throw err
|
||||
}
|
||||
if (opts.dereference) {
|
||||
resolvedDest = path.resolve(process.cwd(), resolvedDest)
|
||||
}
|
||||
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
||||
throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
|
||||
}
|
||||
|
||||
// prevent copy if src is a subdir of dest since unlinking
|
||||
// dest in this case would result in removing src contents
|
||||
// and therefore a broken symlink would be created.
|
||||
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
||||
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
|
||||
}
|
||||
return copyLink(resolvedSrc, dest)
|
||||
}
|
||||
}
|
||||
|
||||
function copyLink (resolvedSrc, dest) {
|
||||
fs.unlinkSync(dest)
|
||||
return fs.symlinkSync(resolvedSrc, dest)
|
||||
}
|
||||
|
||||
module.exports = copySync
|
||||
182
electron/node_modules/unzipper/node_modules/fs-extra/lib/copy/copy.js
generated
vendored
Normal file
182
electron/node_modules/unzipper/node_modules/fs-extra/lib/copy/copy.js
generated
vendored
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
'use strict'
|
||||
|
||||
const fs = require('../fs')
|
||||
const path = require('path')
|
||||
const { mkdirs } = require('../mkdirs')
|
||||
const { pathExists } = require('../path-exists')
|
||||
const { utimesMillis } = require('../util/utimes')
|
||||
const stat = require('../util/stat')
|
||||
|
||||
async function copy (src, dest, opts = {}) {
|
||||
if (typeof opts === 'function') {
|
||||
opts = { filter: opts }
|
||||
}
|
||||
|
||||
opts.clobber = 'clobber' in opts ? !!opts.clobber : true // default to true for now
|
||||
opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber // overwrite falls back to clobber
|
||||
|
||||
// Warn about using preserveTimestamps on 32-bit node
|
||||
if (opts.preserveTimestamps && process.arch === 'ia32') {
|
||||
process.emitWarning(
|
||||
'Using the preserveTimestamps option in 32-bit node is not recommended;\n\n' +
|
||||
'\tsee https://github.com/jprichardson/node-fs-extra/issues/269',
|
||||
'Warning', 'fs-extra-WARN0001'
|
||||
)
|
||||
}
|
||||
|
||||
const { srcStat, destStat } = await stat.checkPaths(src, dest, 'copy', opts)
|
||||
|
||||
await stat.checkParentPaths(src, srcStat, dest, 'copy')
|
||||
|
||||
const include = await runFilter(src, dest, opts)
|
||||
|
||||
if (!include) return
|
||||
|
||||
// check if the parent of dest exists, and create it if it doesn't exist
|
||||
const destParent = path.dirname(dest)
|
||||
const dirExists = await pathExists(destParent)
|
||||
if (!dirExists) {
|
||||
await mkdirs(destParent)
|
||||
}
|
||||
|
||||
await getStatsAndPerformCopy(destStat, src, dest, opts)
|
||||
}
|
||||
|
||||
async function runFilter (src, dest, opts) {
|
||||
if (!opts.filter) return true
|
||||
return opts.filter(src, dest)
|
||||
}
|
||||
|
||||
async function getStatsAndPerformCopy (destStat, src, dest, opts) {
|
||||
const statFn = opts.dereference ? fs.stat : fs.lstat
|
||||
const srcStat = await statFn(src)
|
||||
|
||||
if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts)
|
||||
|
||||
if (
|
||||
srcStat.isFile() ||
|
||||
srcStat.isCharacterDevice() ||
|
||||
srcStat.isBlockDevice()
|
||||
) return onFile(srcStat, destStat, src, dest, opts)
|
||||
|
||||
if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts)
|
||||
if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`)
|
||||
if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`)
|
||||
throw new Error(`Unknown file: ${src}`)
|
||||
}
|
||||
|
||||
async function onFile (srcStat, destStat, src, dest, opts) {
|
||||
if (!destStat) return copyFile(srcStat, src, dest, opts)
|
||||
|
||||
if (opts.overwrite) {
|
||||
await fs.unlink(dest)
|
||||
return copyFile(srcStat, src, dest, opts)
|
||||
}
|
||||
if (opts.errorOnExist) {
|
||||
throw new Error(`'${dest}' already exists`)
|
||||
}
|
||||
}
|
||||
|
||||
async function copyFile (srcStat, src, dest, opts) {
|
||||
await fs.copyFile(src, dest)
|
||||
if (opts.preserveTimestamps) {
|
||||
// Make sure the file is writable before setting the timestamp
|
||||
// otherwise open fails with EPERM when invoked with 'r+'
|
||||
// (through utimes call)
|
||||
if (fileIsNotWritable(srcStat.mode)) {
|
||||
await makeFileWritable(dest, srcStat.mode)
|
||||
}
|
||||
|
||||
// Set timestamps and mode correspondingly
|
||||
|
||||
// Note that The initial srcStat.atime cannot be trusted
|
||||
// because it is modified by the read(2) system call
|
||||
// (See https://nodejs.org/api/fs.html#fs_stat_time_values)
|
||||
const updatedSrcStat = await fs.stat(src)
|
||||
await utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime)
|
||||
}
|
||||
|
||||
return fs.chmod(dest, srcStat.mode)
|
||||
}
|
||||
|
||||
function fileIsNotWritable (srcMode) {
|
||||
return (srcMode & 0o200) === 0
|
||||
}
|
||||
|
||||
function makeFileWritable (dest, srcMode) {
|
||||
return fs.chmod(dest, srcMode | 0o200)
|
||||
}
|
||||
|
||||
async function onDir (srcStat, destStat, src, dest, opts) {
|
||||
// the dest directory might not exist, create it
|
||||
if (!destStat) {
|
||||
await fs.mkdir(dest)
|
||||
}
|
||||
|
||||
const promises = []
|
||||
|
||||
// loop through the files in the current directory to copy everything
|
||||
for await (const item of await fs.opendir(src)) {
|
||||
const srcItem = path.join(src, item.name)
|
||||
const destItem = path.join(dest, item.name)
|
||||
|
||||
promises.push(
|
||||
runFilter(srcItem, destItem, opts).then(include => {
|
||||
if (include) {
|
||||
// only copy the item if it matches the filter function
|
||||
return stat.checkPaths(srcItem, destItem, 'copy', opts).then(({ destStat }) => {
|
||||
// If the item is a copyable file, `getStatsAndPerformCopy` will copy it
|
||||
// If the item is a directory, `getStatsAndPerformCopy` will call `onDir` recursively
|
||||
return getStatsAndPerformCopy(destStat, srcItem, destItem, opts)
|
||||
})
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
await Promise.all(promises)
|
||||
|
||||
if (!destStat) {
|
||||
await fs.chmod(dest, srcStat.mode)
|
||||
}
|
||||
}
|
||||
|
||||
async function onLink (destStat, src, dest, opts) {
|
||||
let resolvedSrc = await fs.readlink(src)
|
||||
if (opts.dereference) {
|
||||
resolvedSrc = path.resolve(process.cwd(), resolvedSrc)
|
||||
}
|
||||
if (!destStat) {
|
||||
return fs.symlink(resolvedSrc, dest)
|
||||
}
|
||||
|
||||
let resolvedDest = null
|
||||
try {
|
||||
resolvedDest = await fs.readlink(dest)
|
||||
} catch (e) {
|
||||
// dest exists and is a regular file or directory,
|
||||
// Windows may throw UNKNOWN error. If dest already exists,
|
||||
// fs throws error anyway, so no need to guard against it here.
|
||||
if (e.code === 'EINVAL' || e.code === 'UNKNOWN') return fs.symlink(resolvedSrc, dest)
|
||||
throw e
|
||||
}
|
||||
if (opts.dereference) {
|
||||
resolvedDest = path.resolve(process.cwd(), resolvedDest)
|
||||
}
|
||||
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
||||
throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
|
||||
}
|
||||
|
||||
// do not copy if src is a subdir of dest since unlinking
|
||||
// dest in this case would result in removing src contents
|
||||
// and therefore a broken symlink would be created.
|
||||
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
||||
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
|
||||
}
|
||||
|
||||
// copy the link
|
||||
await fs.unlink(dest)
|
||||
return fs.symlink(resolvedSrc, dest)
|
||||
}
|
||||
|
||||
module.exports = copy
|
||||
7
electron/node_modules/unzipper/node_modules/fs-extra/lib/copy/index.js
generated
vendored
Normal file
7
electron/node_modules/unzipper/node_modules/fs-extra/lib/copy/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
const u = require('universalify').fromPromise
|
||||
module.exports = {
|
||||
copy: u(require('./copy')),
|
||||
copySync: require('./copy-sync')
|
||||
}
|
||||
39
electron/node_modules/unzipper/node_modules/fs-extra/lib/empty/index.js
generated
vendored
Normal file
39
electron/node_modules/unzipper/node_modules/fs-extra/lib/empty/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
'use strict'
|
||||
|
||||
const u = require('universalify').fromPromise
|
||||
const fs = require('../fs')
|
||||
const path = require('path')
|
||||
const mkdir = require('../mkdirs')
|
||||
const remove = require('../remove')
|
||||
|
||||
const emptyDir = u(async function emptyDir (dir) {
|
||||
let items
|
||||
try {
|
||||
items = await fs.readdir(dir)
|
||||
} catch {
|
||||
return mkdir.mkdirs(dir)
|
||||
}
|
||||
|
||||
return Promise.all(items.map(item => remove.remove(path.join(dir, item))))
|
||||
})
|
||||
|
||||
function emptyDirSync (dir) {
|
||||
let items
|
||||
try {
|
||||
items = fs.readdirSync(dir)
|
||||
} catch {
|
||||
return mkdir.mkdirsSync(dir)
|
||||
}
|
||||
|
||||
items.forEach(item => {
|
||||
item = path.join(dir, item)
|
||||
remove.removeSync(item)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
emptyDirSync,
|
||||
emptydirSync: emptyDirSync,
|
||||
emptyDir,
|
||||
emptydir: emptyDir
|
||||
}
|
||||
66
electron/node_modules/unzipper/node_modules/fs-extra/lib/ensure/file.js
generated
vendored
Normal file
66
electron/node_modules/unzipper/node_modules/fs-extra/lib/ensure/file.js
generated
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
'use strict'
|
||||
|
||||
const u = require('universalify').fromPromise
|
||||
const path = require('path')
|
||||
const fs = require('../fs')
|
||||
const mkdir = require('../mkdirs')
|
||||
|
||||
async function createFile (file) {
|
||||
let stats
|
||||
try {
|
||||
stats = await fs.stat(file)
|
||||
} catch { }
|
||||
if (stats && stats.isFile()) return
|
||||
|
||||
const dir = path.dirname(file)
|
||||
|
||||
let dirStats = null
|
||||
try {
|
||||
dirStats = await fs.stat(dir)
|
||||
} catch (err) {
|
||||
// if the directory doesn't exist, make it
|
||||
if (err.code === 'ENOENT') {
|
||||
await mkdir.mkdirs(dir)
|
||||
await fs.writeFile(file, '')
|
||||
return
|
||||
} else {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
if (dirStats.isDirectory()) {
|
||||
await fs.writeFile(file, '')
|
||||
} else {
|
||||
// parent is not a directory
|
||||
// This is just to cause an internal ENOTDIR error to be thrown
|
||||
await fs.readdir(dir)
|
||||
}
|
||||
}
|
||||
|
||||
function createFileSync (file) {
|
||||
let stats
|
||||
try {
|
||||
stats = fs.statSync(file)
|
||||
} catch { }
|
||||
if (stats && stats.isFile()) return
|
||||
|
||||
const dir = path.dirname(file)
|
||||
try {
|
||||
if (!fs.statSync(dir).isDirectory()) {
|
||||
// parent is not a directory
|
||||
// This is just to cause an internal ENOTDIR error to be thrown
|
||||
fs.readdirSync(dir)
|
||||
}
|
||||
} catch (err) {
|
||||
// If the stat call above failed because the directory doesn't exist, create it
|
||||
if (err && err.code === 'ENOENT') mkdir.mkdirsSync(dir)
|
||||
else throw err
|
||||
}
|
||||
|
||||
fs.writeFileSync(file, '')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createFile: u(createFile),
|
||||
createFileSync
|
||||
}
|
||||
23
electron/node_modules/unzipper/node_modules/fs-extra/lib/ensure/index.js
generated
vendored
Normal file
23
electron/node_modules/unzipper/node_modules/fs-extra/lib/ensure/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
'use strict'
|
||||
|
||||
const { createFile, createFileSync } = require('./file')
|
||||
const { createLink, createLinkSync } = require('./link')
|
||||
const { createSymlink, createSymlinkSync } = require('./symlink')
|
||||
|
||||
module.exports = {
|
||||
// file
|
||||
createFile,
|
||||
createFileSync,
|
||||
ensureFile: createFile,
|
||||
ensureFileSync: createFileSync,
|
||||
// link
|
||||
createLink,
|
||||
createLinkSync,
|
||||
ensureLink: createLink,
|
||||
ensureLinkSync: createLinkSync,
|
||||
// symlink
|
||||
createSymlink,
|
||||
createSymlinkSync,
|
||||
ensureSymlink: createSymlink,
|
||||
ensureSymlinkSync: createSymlinkSync
|
||||
}
|
||||
64
electron/node_modules/unzipper/node_modules/fs-extra/lib/ensure/link.js
generated
vendored
Normal file
64
electron/node_modules/unzipper/node_modules/fs-extra/lib/ensure/link.js
generated
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
'use strict'
|
||||
|
||||
const u = require('universalify').fromPromise
|
||||
const path = require('path')
|
||||
const fs = require('../fs')
|
||||
const mkdir = require('../mkdirs')
|
||||
const { pathExists } = require('../path-exists')
|
||||
const { areIdentical } = require('../util/stat')
|
||||
|
||||
async function createLink (srcpath, dstpath) {
|
||||
let dstStat
|
||||
try {
|
||||
dstStat = await fs.lstat(dstpath)
|
||||
} catch {
|
||||
// ignore error
|
||||
}
|
||||
|
||||
let srcStat
|
||||
try {
|
||||
srcStat = await fs.lstat(srcpath)
|
||||
} catch (err) {
|
||||
err.message = err.message.replace('lstat', 'ensureLink')
|
||||
throw err
|
||||
}
|
||||
|
||||
if (dstStat && areIdentical(srcStat, dstStat)) return
|
||||
|
||||
const dir = path.dirname(dstpath)
|
||||
|
||||
const dirExists = await pathExists(dir)
|
||||
|
||||
if (!dirExists) {
|
||||
await mkdir.mkdirs(dir)
|
||||
}
|
||||
|
||||
await fs.link(srcpath, dstpath)
|
||||
}
|
||||
|
||||
function createLinkSync (srcpath, dstpath) {
|
||||
let dstStat
|
||||
try {
|
||||
dstStat = fs.lstatSync(dstpath)
|
||||
} catch {}
|
||||
|
||||
try {
|
||||
const srcStat = fs.lstatSync(srcpath)
|
||||
if (dstStat && areIdentical(srcStat, dstStat)) return
|
||||
} catch (err) {
|
||||
err.message = err.message.replace('lstat', 'ensureLink')
|
||||
throw err
|
||||
}
|
||||
|
||||
const dir = path.dirname(dstpath)
|
||||
const dirExists = fs.existsSync(dir)
|
||||
if (dirExists) return fs.linkSync(srcpath, dstpath)
|
||||
mkdir.mkdirsSync(dir)
|
||||
|
||||
return fs.linkSync(srcpath, dstpath)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createLink: u(createLink),
|
||||
createLinkSync
|
||||
}
|
||||
101
electron/node_modules/unzipper/node_modules/fs-extra/lib/ensure/symlink-paths.js
generated
vendored
Normal file
101
electron/node_modules/unzipper/node_modules/fs-extra/lib/ensure/symlink-paths.js
generated
vendored
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
const fs = require('../fs')
|
||||
const { pathExists } = require('../path-exists')
|
||||
|
||||
const u = require('universalify').fromPromise
|
||||
|
||||
/**
|
||||
* Function that returns two types of paths, one relative to symlink, and one
|
||||
* relative to the current working directory. Checks if path is absolute or
|
||||
* relative. If the path is relative, this function checks if the path is
|
||||
* relative to symlink or relative to current working directory. This is an
|
||||
* initiative to find a smarter `srcpath` to supply when building symlinks.
|
||||
* This allows you to determine which path to use out of one of three possible
|
||||
* types of source paths. The first is an absolute path. This is detected by
|
||||
* `path.isAbsolute()`. When an absolute path is provided, it is checked to
|
||||
* see if it exists. If it does it's used, if not an error is returned
|
||||
* (callback)/ thrown (sync). The other two options for `srcpath` are a
|
||||
* relative url. By default Node's `fs.symlink` works by creating a symlink
|
||||
* using `dstpath` and expects the `srcpath` to be relative to the newly
|
||||
* created symlink. If you provide a `srcpath` that does not exist on the file
|
||||
* system it results in a broken symlink. To minimize this, the function
|
||||
* checks to see if the 'relative to symlink' source file exists, and if it
|
||||
* does it will use it. If it does not, it checks if there's a file that
|
||||
* exists that is relative to the current working directory, if does its used.
|
||||
* This preserves the expectations of the original fs.symlink spec and adds
|
||||
* the ability to pass in `relative to current working direcotry` paths.
|
||||
*/
|
||||
|
||||
async function symlinkPaths (srcpath, dstpath) {
|
||||
if (path.isAbsolute(srcpath)) {
|
||||
try {
|
||||
await fs.lstat(srcpath)
|
||||
} catch (err) {
|
||||
err.message = err.message.replace('lstat', 'ensureSymlink')
|
||||
throw err
|
||||
}
|
||||
|
||||
return {
|
||||
toCwd: srcpath,
|
||||
toDst: srcpath
|
||||
}
|
||||
}
|
||||
|
||||
const dstdir = path.dirname(dstpath)
|
||||
const relativeToDst = path.join(dstdir, srcpath)
|
||||
|
||||
const exists = await pathExists(relativeToDst)
|
||||
if (exists) {
|
||||
return {
|
||||
toCwd: relativeToDst,
|
||||
toDst: srcpath
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await fs.lstat(srcpath)
|
||||
} catch (err) {
|
||||
err.message = err.message.replace('lstat', 'ensureSymlink')
|
||||
throw err
|
||||
}
|
||||
|
||||
return {
|
||||
toCwd: srcpath,
|
||||
toDst: path.relative(dstdir, srcpath)
|
||||
}
|
||||
}
|
||||
|
||||
function symlinkPathsSync (srcpath, dstpath) {
|
||||
if (path.isAbsolute(srcpath)) {
|
||||
const exists = fs.existsSync(srcpath)
|
||||
if (!exists) throw new Error('absolute srcpath does not exist')
|
||||
return {
|
||||
toCwd: srcpath,
|
||||
toDst: srcpath
|
||||
}
|
||||
}
|
||||
|
||||
const dstdir = path.dirname(dstpath)
|
||||
const relativeToDst = path.join(dstdir, srcpath)
|
||||
const exists = fs.existsSync(relativeToDst)
|
||||
if (exists) {
|
||||
return {
|
||||
toCwd: relativeToDst,
|
||||
toDst: srcpath
|
||||
}
|
||||
}
|
||||
|
||||
const srcExists = fs.existsSync(srcpath)
|
||||
if (!srcExists) throw new Error('relative srcpath does not exist')
|
||||
return {
|
||||
toCwd: srcpath,
|
||||
toDst: path.relative(dstdir, srcpath)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
symlinkPaths: u(symlinkPaths),
|
||||
symlinkPathsSync
|
||||
}
|
||||
34
electron/node_modules/unzipper/node_modules/fs-extra/lib/ensure/symlink-type.js
generated
vendored
Normal file
34
electron/node_modules/unzipper/node_modules/fs-extra/lib/ensure/symlink-type.js
generated
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
'use strict'
|
||||
|
||||
const fs = require('../fs')
|
||||
const u = require('universalify').fromPromise
|
||||
|
||||
async function symlinkType (srcpath, type) {
|
||||
if (type) return type
|
||||
|
||||
let stats
|
||||
try {
|
||||
stats = await fs.lstat(srcpath)
|
||||
} catch {
|
||||
return 'file'
|
||||
}
|
||||
|
||||
return (stats && stats.isDirectory()) ? 'dir' : 'file'
|
||||
}
|
||||
|
||||
function symlinkTypeSync (srcpath, type) {
|
||||
if (type) return type
|
||||
|
||||
let stats
|
||||
try {
|
||||
stats = fs.lstatSync(srcpath)
|
||||
} catch {
|
||||
return 'file'
|
||||
}
|
||||
return (stats && stats.isDirectory()) ? 'dir' : 'file'
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
symlinkType: u(symlinkType),
|
||||
symlinkTypeSync
|
||||
}
|
||||
67
electron/node_modules/unzipper/node_modules/fs-extra/lib/ensure/symlink.js
generated
vendored
Normal file
67
electron/node_modules/unzipper/node_modules/fs-extra/lib/ensure/symlink.js
generated
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
'use strict'
|
||||
|
||||
const u = require('universalify').fromPromise
|
||||
const path = require('path')
|
||||
const fs = require('../fs')
|
||||
|
||||
const { mkdirs, mkdirsSync } = require('../mkdirs')
|
||||
|
||||
const { symlinkPaths, symlinkPathsSync } = require('./symlink-paths')
|
||||
const { symlinkType, symlinkTypeSync } = require('./symlink-type')
|
||||
|
||||
const { pathExists } = require('../path-exists')
|
||||
|
||||
const { areIdentical } = require('../util/stat')
|
||||
|
||||
async function createSymlink (srcpath, dstpath, type) {
|
||||
let stats
|
||||
try {
|
||||
stats = await fs.lstat(dstpath)
|
||||
} catch { }
|
||||
|
||||
if (stats && stats.isSymbolicLink()) {
|
||||
const [srcStat, dstStat] = await Promise.all([
|
||||
fs.stat(srcpath),
|
||||
fs.stat(dstpath)
|
||||
])
|
||||
|
||||
if (areIdentical(srcStat, dstStat)) return
|
||||
}
|
||||
|
||||
const relative = await symlinkPaths(srcpath, dstpath)
|
||||
srcpath = relative.toDst
|
||||
const toType = await symlinkType(relative.toCwd, type)
|
||||
const dir = path.dirname(dstpath)
|
||||
|
||||
if (!(await pathExists(dir))) {
|
||||
await mkdirs(dir)
|
||||
}
|
||||
|
||||
return fs.symlink(srcpath, dstpath, toType)
|
||||
}
|
||||
|
||||
function createSymlinkSync (srcpath, dstpath, type) {
|
||||
let stats
|
||||
try {
|
||||
stats = fs.lstatSync(dstpath)
|
||||
} catch { }
|
||||
if (stats && stats.isSymbolicLink()) {
|
||||
const srcStat = fs.statSync(srcpath)
|
||||
const dstStat = fs.statSync(dstpath)
|
||||
if (areIdentical(srcStat, dstStat)) return
|
||||
}
|
||||
|
||||
const relative = symlinkPathsSync(srcpath, dstpath)
|
||||
srcpath = relative.toDst
|
||||
type = symlinkTypeSync(relative.toCwd, type)
|
||||
const dir = path.dirname(dstpath)
|
||||
const exists = fs.existsSync(dir)
|
||||
if (exists) return fs.symlinkSync(srcpath, dstpath, type)
|
||||
mkdirsSync(dir)
|
||||
return fs.symlinkSync(srcpath, dstpath, type)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createSymlink: u(createSymlink),
|
||||
createSymlinkSync
|
||||
}
|
||||
68
electron/node_modules/unzipper/node_modules/fs-extra/lib/esm.mjs
generated
vendored
Normal file
68
electron/node_modules/unzipper/node_modules/fs-extra/lib/esm.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import _copy from './copy/index.js'
|
||||
import _empty from './empty/index.js'
|
||||
import _ensure from './ensure/index.js'
|
||||
import _json from './json/index.js'
|
||||
import _mkdirs from './mkdirs/index.js'
|
||||
import _move from './move/index.js'
|
||||
import _outputFile from './output-file/index.js'
|
||||
import _pathExists from './path-exists/index.js'
|
||||
import _remove from './remove/index.js'
|
||||
|
||||
// NOTE: Only exports fs-extra's functions; fs functions must be imported from "node:fs" or "node:fs/promises"
|
||||
|
||||
export const copy = _copy.copy
|
||||
export const copySync = _copy.copySync
|
||||
export const emptyDirSync = _empty.emptyDirSync
|
||||
export const emptydirSync = _empty.emptydirSync
|
||||
export const emptyDir = _empty.emptyDir
|
||||
export const emptydir = _empty.emptydir
|
||||
export const createFile = _ensure.createFile
|
||||
export const createFileSync = _ensure.createFileSync
|
||||
export const ensureFile = _ensure.ensureFile
|
||||
export const ensureFileSync = _ensure.ensureFileSync
|
||||
export const createLink = _ensure.createLink
|
||||
export const createLinkSync = _ensure.createLinkSync
|
||||
export const ensureLink = _ensure.ensureLink
|
||||
export const ensureLinkSync = _ensure.ensureLinkSync
|
||||
export const createSymlink = _ensure.createSymlink
|
||||
export const createSymlinkSync = _ensure.createSymlinkSync
|
||||
export const ensureSymlink = _ensure.ensureSymlink
|
||||
export const ensureSymlinkSync = _ensure.ensureSymlinkSync
|
||||
export const readJson = _json.readJson
|
||||
export const readJSON = _json.readJSON
|
||||
export const readJsonSync = _json.readJsonSync
|
||||
export const readJSONSync = _json.readJSONSync
|
||||
export const writeJson = _json.writeJson
|
||||
export const writeJSON = _json.writeJSON
|
||||
export const writeJsonSync = _json.writeJsonSync
|
||||
export const writeJSONSync = _json.writeJSONSync
|
||||
export const outputJson = _json.outputJson
|
||||
export const outputJSON = _json.outputJSON
|
||||
export const outputJsonSync = _json.outputJsonSync
|
||||
export const outputJSONSync = _json.outputJSONSync
|
||||
export const mkdirs = _mkdirs.mkdirs
|
||||
export const mkdirsSync = _mkdirs.mkdirsSync
|
||||
export const mkdirp = _mkdirs.mkdirp
|
||||
export const mkdirpSync = _mkdirs.mkdirpSync
|
||||
export const ensureDir = _mkdirs.ensureDir
|
||||
export const ensureDirSync = _mkdirs.ensureDirSync
|
||||
export const move = _move.move
|
||||
export const moveSync = _move.moveSync
|
||||
export const outputFile = _outputFile.outputFile
|
||||
export const outputFileSync = _outputFile.outputFileSync
|
||||
export const pathExists = _pathExists.pathExists
|
||||
export const pathExistsSync = _pathExists.pathExistsSync
|
||||
export const remove = _remove.remove
|
||||
export const removeSync = _remove.removeSync
|
||||
|
||||
export default {
|
||||
..._copy,
|
||||
..._empty,
|
||||
..._ensure,
|
||||
..._json,
|
||||
..._mkdirs,
|
||||
..._move,
|
||||
..._outputFile,
|
||||
..._pathExists,
|
||||
..._remove
|
||||
}
|
||||
146
electron/node_modules/unzipper/node_modules/fs-extra/lib/fs/index.js
generated
vendored
Normal file
146
electron/node_modules/unzipper/node_modules/fs-extra/lib/fs/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
'use strict'
|
||||
// This is adapted from https://github.com/normalize/mz
|
||||
// Copyright (c) 2014-2016 Jonathan Ong me@jongleberry.com and Contributors
|
||||
const u = require('universalify').fromCallback
|
||||
const fs = require('graceful-fs')
|
||||
|
||||
const api = [
|
||||
'access',
|
||||
'appendFile',
|
||||
'chmod',
|
||||
'chown',
|
||||
'close',
|
||||
'copyFile',
|
||||
'cp',
|
||||
'fchmod',
|
||||
'fchown',
|
||||
'fdatasync',
|
||||
'fstat',
|
||||
'fsync',
|
||||
'ftruncate',
|
||||
'futimes',
|
||||
'glob',
|
||||
'lchmod',
|
||||
'lchown',
|
||||
'lutimes',
|
||||
'link',
|
||||
'lstat',
|
||||
'mkdir',
|
||||
'mkdtemp',
|
||||
'open',
|
||||
'opendir',
|
||||
'readdir',
|
||||
'readFile',
|
||||
'readlink',
|
||||
'realpath',
|
||||
'rename',
|
||||
'rm',
|
||||
'rmdir',
|
||||
'stat',
|
||||
'statfs',
|
||||
'symlink',
|
||||
'truncate',
|
||||
'unlink',
|
||||
'utimes',
|
||||
'writeFile'
|
||||
].filter(key => {
|
||||
// Some commands are not available on some systems. Ex:
|
||||
// fs.cp was added in Node.js v16.7.0
|
||||
// fs.statfs was added in Node v19.6.0, v18.15.0
|
||||
// fs.glob was added in Node.js v22.0.0
|
||||
// fs.lchown is not available on at least some Linux
|
||||
return typeof fs[key] === 'function'
|
||||
})
|
||||
|
||||
// Export cloned fs:
|
||||
Object.assign(exports, fs)
|
||||
|
||||
// Universalify async methods:
|
||||
api.forEach(method => {
|
||||
exports[method] = u(fs[method])
|
||||
})
|
||||
|
||||
// We differ from mz/fs in that we still ship the old, broken, fs.exists()
|
||||
// since we are a drop-in replacement for the native module
|
||||
exports.exists = function (filename, callback) {
|
||||
if (typeof callback === 'function') {
|
||||
return fs.exists(filename, callback)
|
||||
}
|
||||
return new Promise(resolve => {
|
||||
return fs.exists(filename, resolve)
|
||||
})
|
||||
}
|
||||
|
||||
// fs.read(), fs.write(), fs.readv(), & fs.writev() need special treatment due to multiple callback args
|
||||
|
||||
exports.read = function (fd, buffer, offset, length, position, callback) {
|
||||
if (typeof callback === 'function') {
|
||||
return fs.read(fd, buffer, offset, length, position, callback)
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer) => {
|
||||
if (err) return reject(err)
|
||||
resolve({ bytesRead, buffer })
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Function signature can be
|
||||
// fs.write(fd, buffer[, offset[, length[, position]]], callback)
|
||||
// OR
|
||||
// fs.write(fd, string[, position[, encoding]], callback)
|
||||
// We need to handle both cases, so we use ...args
|
||||
exports.write = function (fd, buffer, ...args) {
|
||||
if (typeof args[args.length - 1] === 'function') {
|
||||
return fs.write(fd, buffer, ...args)
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.write(fd, buffer, ...args, (err, bytesWritten, buffer) => {
|
||||
if (err) return reject(err)
|
||||
resolve({ bytesWritten, buffer })
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Function signature is
|
||||
// s.readv(fd, buffers[, position], callback)
|
||||
// We need to handle the optional arg, so we use ...args
|
||||
exports.readv = function (fd, buffers, ...args) {
|
||||
if (typeof args[args.length - 1] === 'function') {
|
||||
return fs.readv(fd, buffers, ...args)
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readv(fd, buffers, ...args, (err, bytesRead, buffers) => {
|
||||
if (err) return reject(err)
|
||||
resolve({ bytesRead, buffers })
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Function signature is
|
||||
// s.writev(fd, buffers[, position], callback)
|
||||
// We need to handle the optional arg, so we use ...args
|
||||
exports.writev = function (fd, buffers, ...args) {
|
||||
if (typeof args[args.length - 1] === 'function') {
|
||||
return fs.writev(fd, buffers, ...args)
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.writev(fd, buffers, ...args, (err, bytesWritten, buffers) => {
|
||||
if (err) return reject(err)
|
||||
resolve({ bytesWritten, buffers })
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// fs.realpath.native sometimes not available if fs is monkey-patched
|
||||
if (typeof fs.realpath.native === 'function') {
|
||||
exports.realpath.native = u(fs.realpath.native)
|
||||
} else {
|
||||
process.emitWarning(
|
||||
'fs.realpath.native is not a function. Is fs being monkey-patched?',
|
||||
'Warning', 'fs-extra-WARN0003'
|
||||
)
|
||||
}
|
||||
16
electron/node_modules/unzipper/node_modules/fs-extra/lib/index.js
generated
vendored
Normal file
16
electron/node_modules/unzipper/node_modules/fs-extra/lib/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
// Export promiseified graceful-fs:
|
||||
...require('./fs'),
|
||||
// Export extra methods:
|
||||
...require('./copy'),
|
||||
...require('./empty'),
|
||||
...require('./ensure'),
|
||||
...require('./json'),
|
||||
...require('./mkdirs'),
|
||||
...require('./move'),
|
||||
...require('./output-file'),
|
||||
...require('./path-exists'),
|
||||
...require('./remove')
|
||||
}
|
||||
16
electron/node_modules/unzipper/node_modules/fs-extra/lib/json/index.js
generated
vendored
Normal file
16
electron/node_modules/unzipper/node_modules/fs-extra/lib/json/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
'use strict'
|
||||
|
||||
const u = require('universalify').fromPromise
|
||||
const jsonFile = require('./jsonfile')
|
||||
|
||||
jsonFile.outputJson = u(require('./output-json'))
|
||||
jsonFile.outputJsonSync = require('./output-json-sync')
|
||||
// aliases
|
||||
jsonFile.outputJSON = jsonFile.outputJson
|
||||
jsonFile.outputJSONSync = jsonFile.outputJsonSync
|
||||
jsonFile.writeJSON = jsonFile.writeJson
|
||||
jsonFile.writeJSONSync = jsonFile.writeJsonSync
|
||||
jsonFile.readJSON = jsonFile.readJson
|
||||
jsonFile.readJSONSync = jsonFile.readJsonSync
|
||||
|
||||
module.exports = jsonFile
|
||||
11
electron/node_modules/unzipper/node_modules/fs-extra/lib/json/jsonfile.js
generated
vendored
Normal file
11
electron/node_modules/unzipper/node_modules/fs-extra/lib/json/jsonfile.js
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
'use strict'
|
||||
|
||||
const jsonFile = require('jsonfile')
|
||||
|
||||
module.exports = {
|
||||
// jsonfile exports
|
||||
readJson: jsonFile.readFile,
|
||||
readJsonSync: jsonFile.readFileSync,
|
||||
writeJson: jsonFile.writeFile,
|
||||
writeJsonSync: jsonFile.writeFileSync
|
||||
}
|
||||
12
electron/node_modules/unzipper/node_modules/fs-extra/lib/json/output-json-sync.js
generated
vendored
Normal file
12
electron/node_modules/unzipper/node_modules/fs-extra/lib/json/output-json-sync.js
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
'use strict'
|
||||
|
||||
const { stringify } = require('jsonfile/utils')
|
||||
const { outputFileSync } = require('../output-file')
|
||||
|
||||
function outputJsonSync (file, data, options) {
|
||||
const str = stringify(data, options)
|
||||
|
||||
outputFileSync(file, str, options)
|
||||
}
|
||||
|
||||
module.exports = outputJsonSync
|
||||
12
electron/node_modules/unzipper/node_modules/fs-extra/lib/json/output-json.js
generated
vendored
Normal file
12
electron/node_modules/unzipper/node_modules/fs-extra/lib/json/output-json.js
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
'use strict'
|
||||
|
||||
const { stringify } = require('jsonfile/utils')
|
||||
const { outputFile } = require('../output-file')
|
||||
|
||||
async function outputJson (file, data, options = {}) {
|
||||
const str = stringify(data, options)
|
||||
|
||||
await outputFile(file, str, options)
|
||||
}
|
||||
|
||||
module.exports = outputJson
|
||||
14
electron/node_modules/unzipper/node_modules/fs-extra/lib/mkdirs/index.js
generated
vendored
Normal file
14
electron/node_modules/unzipper/node_modules/fs-extra/lib/mkdirs/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
'use strict'
|
||||
const u = require('universalify').fromPromise
|
||||
const { makeDir: _makeDir, makeDirSync } = require('./make-dir')
|
||||
const makeDir = u(_makeDir)
|
||||
|
||||
module.exports = {
|
||||
mkdirs: makeDir,
|
||||
mkdirsSync: makeDirSync,
|
||||
// alias
|
||||
mkdirp: makeDir,
|
||||
mkdirpSync: makeDirSync,
|
||||
ensureDir: makeDir,
|
||||
ensureDirSync: makeDirSync
|
||||
}
|
||||
27
electron/node_modules/unzipper/node_modules/fs-extra/lib/mkdirs/make-dir.js
generated
vendored
Normal file
27
electron/node_modules/unzipper/node_modules/fs-extra/lib/mkdirs/make-dir.js
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
'use strict'
|
||||
const fs = require('../fs')
|
||||
const { checkPath } = require('./utils')
|
||||
|
||||
const getMode = options => {
|
||||
const defaults = { mode: 0o777 }
|
||||
if (typeof options === 'number') return options
|
||||
return ({ ...defaults, ...options }).mode
|
||||
}
|
||||
|
||||
module.exports.makeDir = async (dir, options) => {
|
||||
checkPath(dir)
|
||||
|
||||
return fs.mkdir(dir, {
|
||||
mode: getMode(options),
|
||||
recursive: true
|
||||
})
|
||||
}
|
||||
|
||||
module.exports.makeDirSync = (dir, options) => {
|
||||
checkPath(dir)
|
||||
|
||||
return fs.mkdirSync(dir, {
|
||||
mode: getMode(options),
|
||||
recursive: true
|
||||
})
|
||||
}
|
||||
21
electron/node_modules/unzipper/node_modules/fs-extra/lib/mkdirs/utils.js
generated
vendored
Normal file
21
electron/node_modules/unzipper/node_modules/fs-extra/lib/mkdirs/utils.js
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// Adapted from https://github.com/sindresorhus/make-dir
|
||||
// Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
'use strict'
|
||||
const path = require('path')
|
||||
|
||||
// https://github.com/nodejs/node/issues/8987
|
||||
// https://github.com/libuv/libuv/pull/1088
|
||||
module.exports.checkPath = function checkPath (pth) {
|
||||
if (process.platform === 'win32') {
|
||||
const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''))
|
||||
|
||||
if (pathHasInvalidWinCharacters) {
|
||||
const error = new Error(`Path contains invalid characters: ${pth}`)
|
||||
error.code = 'EINVAL'
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
7
electron/node_modules/unzipper/node_modules/fs-extra/lib/move/index.js
generated
vendored
Normal file
7
electron/node_modules/unzipper/node_modules/fs-extra/lib/move/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
const u = require('universalify').fromPromise
|
||||
module.exports = {
|
||||
move: u(require('./move')),
|
||||
moveSync: require('./move-sync')
|
||||
}
|
||||
55
electron/node_modules/unzipper/node_modules/fs-extra/lib/move/move-sync.js
generated
vendored
Normal file
55
electron/node_modules/unzipper/node_modules/fs-extra/lib/move/move-sync.js
generated
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
'use strict'
|
||||
|
||||
const fs = require('graceful-fs')
|
||||
const path = require('path')
|
||||
const copySync = require('../copy').copySync
|
||||
const removeSync = require('../remove').removeSync
|
||||
const mkdirpSync = require('../mkdirs').mkdirpSync
|
||||
const stat = require('../util/stat')
|
||||
|
||||
function moveSync (src, dest, opts) {
|
||||
opts = opts || {}
|
||||
const overwrite = opts.overwrite || opts.clobber || false
|
||||
|
||||
const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, 'move', opts)
|
||||
stat.checkParentPathsSync(src, srcStat, dest, 'move')
|
||||
if (!isParentRoot(dest)) mkdirpSync(path.dirname(dest))
|
||||
return doRename(src, dest, overwrite, isChangingCase)
|
||||
}
|
||||
|
||||
function isParentRoot (dest) {
|
||||
const parent = path.dirname(dest)
|
||||
const parsedPath = path.parse(parent)
|
||||
return parsedPath.root === parent
|
||||
}
|
||||
|
||||
function doRename (src, dest, overwrite, isChangingCase) {
|
||||
if (isChangingCase) return rename(src, dest, overwrite)
|
||||
if (overwrite) {
|
||||
removeSync(dest)
|
||||
return rename(src, dest, overwrite)
|
||||
}
|
||||
if (fs.existsSync(dest)) throw new Error('dest already exists.')
|
||||
return rename(src, dest, overwrite)
|
||||
}
|
||||
|
||||
function rename (src, dest, overwrite) {
|
||||
try {
|
||||
fs.renameSync(src, dest)
|
||||
} catch (err) {
|
||||
if (err.code !== 'EXDEV') throw err
|
||||
return moveAcrossDevice(src, dest, overwrite)
|
||||
}
|
||||
}
|
||||
|
||||
function moveAcrossDevice (src, dest, overwrite) {
|
||||
const opts = {
|
||||
overwrite,
|
||||
errorOnExist: true,
|
||||
preserveTimestamps: true
|
||||
}
|
||||
copySync(src, dest, opts)
|
||||
return removeSync(src)
|
||||
}
|
||||
|
||||
module.exports = moveSync
|
||||
59
electron/node_modules/unzipper/node_modules/fs-extra/lib/move/move.js
generated
vendored
Normal file
59
electron/node_modules/unzipper/node_modules/fs-extra/lib/move/move.js
generated
vendored
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
'use strict'
|
||||
|
||||
const fs = require('../fs')
|
||||
const path = require('path')
|
||||
const { copy } = require('../copy')
|
||||
const { remove } = require('../remove')
|
||||
const { mkdirp } = require('../mkdirs')
|
||||
const { pathExists } = require('../path-exists')
|
||||
const stat = require('../util/stat')
|
||||
|
||||
async function move (src, dest, opts = {}) {
|
||||
const overwrite = opts.overwrite || opts.clobber || false
|
||||
|
||||
const { srcStat, isChangingCase = false } = await stat.checkPaths(src, dest, 'move', opts)
|
||||
|
||||
await stat.checkParentPaths(src, srcStat, dest, 'move')
|
||||
|
||||
// If the parent of dest is not root, make sure it exists before proceeding
|
||||
const destParent = path.dirname(dest)
|
||||
const parsedParentPath = path.parse(destParent)
|
||||
if (parsedParentPath.root !== destParent) {
|
||||
await mkdirp(destParent)
|
||||
}
|
||||
|
||||
return doRename(src, dest, overwrite, isChangingCase)
|
||||
}
|
||||
|
||||
async function doRename (src, dest, overwrite, isChangingCase) {
|
||||
if (!isChangingCase) {
|
||||
if (overwrite) {
|
||||
await remove(dest)
|
||||
} else if (await pathExists(dest)) {
|
||||
throw new Error('dest already exists.')
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// Try w/ rename first, and try copy + remove if EXDEV
|
||||
await fs.rename(src, dest)
|
||||
} catch (err) {
|
||||
if (err.code !== 'EXDEV') {
|
||||
throw err
|
||||
}
|
||||
await moveAcrossDevice(src, dest, overwrite)
|
||||
}
|
||||
}
|
||||
|
||||
async function moveAcrossDevice (src, dest, overwrite) {
|
||||
const opts = {
|
||||
overwrite,
|
||||
errorOnExist: true,
|
||||
preserveTimestamps: true
|
||||
}
|
||||
|
||||
await copy(src, dest, opts)
|
||||
return remove(src)
|
||||
}
|
||||
|
||||
module.exports = move
|
||||
31
electron/node_modules/unzipper/node_modules/fs-extra/lib/output-file/index.js
generated
vendored
Normal file
31
electron/node_modules/unzipper/node_modules/fs-extra/lib/output-file/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
'use strict'
|
||||
|
||||
const u = require('universalify').fromPromise
|
||||
const fs = require('../fs')
|
||||
const path = require('path')
|
||||
const mkdir = require('../mkdirs')
|
||||
const pathExists = require('../path-exists').pathExists
|
||||
|
||||
async function outputFile (file, data, encoding = 'utf-8') {
|
||||
const dir = path.dirname(file)
|
||||
|
||||
if (!(await pathExists(dir))) {
|
||||
await mkdir.mkdirs(dir)
|
||||
}
|
||||
|
||||
return fs.writeFile(file, data, encoding)
|
||||
}
|
||||
|
||||
function outputFileSync (file, ...args) {
|
||||
const dir = path.dirname(file)
|
||||
if (!fs.existsSync(dir)) {
|
||||
mkdir.mkdirsSync(dir)
|
||||
}
|
||||
|
||||
fs.writeFileSync(file, ...args)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
outputFile: u(outputFile),
|
||||
outputFileSync
|
||||
}
|
||||
12
electron/node_modules/unzipper/node_modules/fs-extra/lib/path-exists/index.js
generated
vendored
Normal file
12
electron/node_modules/unzipper/node_modules/fs-extra/lib/path-exists/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
'use strict'
|
||||
const u = require('universalify').fromPromise
|
||||
const fs = require('../fs')
|
||||
|
||||
function pathExists (path) {
|
||||
return fs.access(path).then(() => true).catch(() => false)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
pathExists: u(pathExists),
|
||||
pathExistsSync: fs.existsSync
|
||||
}
|
||||
17
electron/node_modules/unzipper/node_modules/fs-extra/lib/remove/index.js
generated
vendored
Normal file
17
electron/node_modules/unzipper/node_modules/fs-extra/lib/remove/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
'use strict'
|
||||
|
||||
const fs = require('graceful-fs')
|
||||
const u = require('universalify').fromCallback
|
||||
|
||||
function remove (path, callback) {
|
||||
fs.rm(path, { recursive: true, force: true }, callback)
|
||||
}
|
||||
|
||||
function removeSync (path) {
|
||||
fs.rmSync(path, { recursive: true, force: true })
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
remove: u(remove),
|
||||
removeSync
|
||||
}
|
||||
159
electron/node_modules/unzipper/node_modules/fs-extra/lib/util/stat.js
generated
vendored
Normal file
159
electron/node_modules/unzipper/node_modules/fs-extra/lib/util/stat.js
generated
vendored
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
'use strict'
|
||||
|
||||
const fs = require('../fs')
|
||||
const path = require('path')
|
||||
const u = require('universalify').fromPromise
|
||||
|
||||
function getStats (src, dest, opts) {
|
||||
const statFunc = opts.dereference
|
||||
? (file) => fs.stat(file, { bigint: true })
|
||||
: (file) => fs.lstat(file, { bigint: true })
|
||||
return Promise.all([
|
||||
statFunc(src),
|
||||
statFunc(dest).catch(err => {
|
||||
if (err.code === 'ENOENT') return null
|
||||
throw err
|
||||
})
|
||||
]).then(([srcStat, destStat]) => ({ srcStat, destStat }))
|
||||
}
|
||||
|
||||
function getStatsSync (src, dest, opts) {
|
||||
let destStat
|
||||
const statFunc = opts.dereference
|
||||
? (file) => fs.statSync(file, { bigint: true })
|
||||
: (file) => fs.lstatSync(file, { bigint: true })
|
||||
const srcStat = statFunc(src)
|
||||
try {
|
||||
destStat = statFunc(dest)
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') return { srcStat, destStat: null }
|
||||
throw err
|
||||
}
|
||||
return { srcStat, destStat }
|
||||
}
|
||||
|
||||
async function checkPaths (src, dest, funcName, opts) {
|
||||
const { srcStat, destStat } = await getStats(src, dest, opts)
|
||||
if (destStat) {
|
||||
if (areIdentical(srcStat, destStat)) {
|
||||
const srcBaseName = path.basename(src)
|
||||
const destBaseName = path.basename(dest)
|
||||
if (funcName === 'move' &&
|
||||
srcBaseName !== destBaseName &&
|
||||
srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
|
||||
return { srcStat, destStat, isChangingCase: true }
|
||||
}
|
||||
throw new Error('Source and destination must not be the same.')
|
||||
}
|
||||
if (srcStat.isDirectory() && !destStat.isDirectory()) {
|
||||
throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`)
|
||||
}
|
||||
if (!srcStat.isDirectory() && destStat.isDirectory()) {
|
||||
throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`)
|
||||
}
|
||||
}
|
||||
|
||||
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
||||
throw new Error(errMsg(src, dest, funcName))
|
||||
}
|
||||
|
||||
return { srcStat, destStat }
|
||||
}
|
||||
|
||||
function checkPathsSync (src, dest, funcName, opts) {
|
||||
const { srcStat, destStat } = getStatsSync(src, dest, opts)
|
||||
|
||||
if (destStat) {
|
||||
if (areIdentical(srcStat, destStat)) {
|
||||
const srcBaseName = path.basename(src)
|
||||
const destBaseName = path.basename(dest)
|
||||
if (funcName === 'move' &&
|
||||
srcBaseName !== destBaseName &&
|
||||
srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
|
||||
return { srcStat, destStat, isChangingCase: true }
|
||||
}
|
||||
throw new Error('Source and destination must not be the same.')
|
||||
}
|
||||
if (srcStat.isDirectory() && !destStat.isDirectory()) {
|
||||
throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`)
|
||||
}
|
||||
if (!srcStat.isDirectory() && destStat.isDirectory()) {
|
||||
throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`)
|
||||
}
|
||||
}
|
||||
|
||||
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
||||
throw new Error(errMsg(src, dest, funcName))
|
||||
}
|
||||
return { srcStat, destStat }
|
||||
}
|
||||
|
||||
// recursively check if dest parent is a subdirectory of src.
|
||||
// It works for all file types including symlinks since it
|
||||
// checks the src and dest inodes. It starts from the deepest
|
||||
// parent and stops once it reaches the src parent or the root path.
|
||||
async function checkParentPaths (src, srcStat, dest, funcName) {
|
||||
const srcParent = path.resolve(path.dirname(src))
|
||||
const destParent = path.resolve(path.dirname(dest))
|
||||
if (destParent === srcParent || destParent === path.parse(destParent).root) return
|
||||
|
||||
let destStat
|
||||
try {
|
||||
destStat = await fs.stat(destParent, { bigint: true })
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') return
|
||||
throw err
|
||||
}
|
||||
|
||||
if (areIdentical(srcStat, destStat)) {
|
||||
throw new Error(errMsg(src, dest, funcName))
|
||||
}
|
||||
|
||||
return checkParentPaths(src, srcStat, destParent, funcName)
|
||||
}
|
||||
|
||||
function checkParentPathsSync (src, srcStat, dest, funcName) {
|
||||
const srcParent = path.resolve(path.dirname(src))
|
||||
const destParent = path.resolve(path.dirname(dest))
|
||||
if (destParent === srcParent || destParent === path.parse(destParent).root) return
|
||||
let destStat
|
||||
try {
|
||||
destStat = fs.statSync(destParent, { bigint: true })
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') return
|
||||
throw err
|
||||
}
|
||||
if (areIdentical(srcStat, destStat)) {
|
||||
throw new Error(errMsg(src, dest, funcName))
|
||||
}
|
||||
return checkParentPathsSync(src, srcStat, destParent, funcName)
|
||||
}
|
||||
|
||||
function areIdentical (srcStat, destStat) {
|
||||
// stat.dev can be 0n on windows when node version >= 22.x.x
|
||||
return destStat.ino !== undefined && destStat.dev !== undefined && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev
|
||||
}
|
||||
|
||||
// return true if dest is a subdir of src, otherwise false.
|
||||
// It only checks the path strings.
|
||||
function isSrcSubdir (src, dest) {
|
||||
const srcArr = path.resolve(src).split(path.sep).filter(i => i)
|
||||
const destArr = path.resolve(dest).split(path.sep).filter(i => i)
|
||||
return srcArr.every((cur, i) => destArr[i] === cur)
|
||||
}
|
||||
|
||||
function errMsg (src, dest, funcName) {
|
||||
return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
// checkPaths
|
||||
checkPaths: u(checkPaths),
|
||||
checkPathsSync,
|
||||
// checkParent
|
||||
checkParentPaths: u(checkParentPaths),
|
||||
checkParentPathsSync,
|
||||
// Misc
|
||||
isSrcSubdir,
|
||||
areIdentical
|
||||
}
|
||||
36
electron/node_modules/unzipper/node_modules/fs-extra/lib/util/utimes.js
generated
vendored
Normal file
36
electron/node_modules/unzipper/node_modules/fs-extra/lib/util/utimes.js
generated
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
'use strict'
|
||||
|
||||
const fs = require('../fs')
|
||||
const u = require('universalify').fromPromise
|
||||
|
||||
async function utimesMillis (path, atime, mtime) {
|
||||
// if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback)
|
||||
const fd = await fs.open(path, 'r+')
|
||||
|
||||
let closeErr = null
|
||||
|
||||
try {
|
||||
await fs.futimes(fd, atime, mtime)
|
||||
} finally {
|
||||
try {
|
||||
await fs.close(fd)
|
||||
} catch (e) {
|
||||
closeErr = e
|
||||
}
|
||||
}
|
||||
|
||||
if (closeErr) {
|
||||
throw closeErr
|
||||
}
|
||||
}
|
||||
|
||||
function utimesMillisSync (path, atime, mtime) {
|
||||
const fd = fs.openSync(path, 'r+')
|
||||
fs.futimesSync(fd, atime, mtime)
|
||||
return fs.closeSync(fd)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
utimesMillis: u(utimesMillis),
|
||||
utimesMillisSync
|
||||
}
|
||||
71
electron/node_modules/unzipper/node_modules/fs-extra/package.json
generated
vendored
Normal file
71
electron/node_modules/unzipper/node_modules/fs-extra/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
{
|
||||
"name": "fs-extra",
|
||||
"version": "11.3.1",
|
||||
"description": "fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as recursive mkdir, copy, and remove.",
|
||||
"engines": {
|
||||
"node": ">=14.14"
|
||||
},
|
||||
"homepage": "https://github.com/jprichardson/node-fs-extra",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jprichardson/node-fs-extra"
|
||||
},
|
||||
"keywords": [
|
||||
"fs",
|
||||
"file",
|
||||
"file system",
|
||||
"copy",
|
||||
"directory",
|
||||
"extra",
|
||||
"mkdirp",
|
||||
"mkdir",
|
||||
"mkdirs",
|
||||
"recursive",
|
||||
"json",
|
||||
"read",
|
||||
"write",
|
||||
"extra",
|
||||
"delete",
|
||||
"remove",
|
||||
"touch",
|
||||
"create",
|
||||
"text",
|
||||
"output",
|
||||
"move",
|
||||
"promise"
|
||||
],
|
||||
"author": "JP Richardson <jprichardson@gmail.com>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"graceful-fs": "^4.2.0",
|
||||
"jsonfile": "^6.0.1",
|
||||
"universalify": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"klaw": "^2.1.1",
|
||||
"klaw-sync": "^3.0.2",
|
||||
"minimist": "^1.1.1",
|
||||
"mocha": "^10.1.0",
|
||||
"nyc": "^15.0.0",
|
||||
"proxyquire": "^2.0.1",
|
||||
"read-dir-files": "^0.1.1",
|
||||
"standard": "^17.0.0"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"exports": {
|
||||
".": "./lib/index.js",
|
||||
"./esm": "./lib/esm.mjs"
|
||||
},
|
||||
"files": [
|
||||
"lib/",
|
||||
"!lib/**/__tests__/"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "standard",
|
||||
"test-find": "find ./lib/**/__tests__ -name *.test.js | xargs mocha",
|
||||
"test": "npm run lint && npm run unit && npm run unit-esm",
|
||||
"unit": "nyc node test.js",
|
||||
"unit-esm": "node test.mjs"
|
||||
},
|
||||
"sideEffects": false
|
||||
}
|
||||
15
electron/node_modules/unzipper/node_modules/jsonfile/LICENSE
generated
vendored
Normal file
15
electron/node_modules/unzipper/node_modules/jsonfile/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012-2015, JP Richardson <jprichardson@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
|
||||
(the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
|
||||
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
230
electron/node_modules/unzipper/node_modules/jsonfile/README.md
generated
vendored
Normal file
230
electron/node_modules/unzipper/node_modules/jsonfile/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,230 @@
|
|||
Node.js - jsonfile
|
||||
================
|
||||
|
||||
Easily read/write JSON files in Node.js. _Note: this module cannot be used in the browser._
|
||||
|
||||
[](https://www.npmjs.org/package/jsonfile)
|
||||
[](https://github.com/jprichardson/node-jsonfile/actions?query=branch%3Amaster)
|
||||
[](https://ci.appveyor.com/project/jprichardson/node-jsonfile/branch/master)
|
||||
|
||||
<a href="https://github.com/feross/standard"><img src="https://cdn.rawgit.com/feross/standard/master/sticker.svg" alt="Standard JavaScript" width="100"></a>
|
||||
|
||||
Why?
|
||||
----
|
||||
|
||||
Writing `JSON.stringify()` and then `fs.writeFile()` and `JSON.parse()` with `fs.readFile()` enclosed in `try/catch` blocks became annoying.
|
||||
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
npm install --save jsonfile
|
||||
|
||||
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
* [`readFile(filename, [options], callback)`](#readfilefilename-options-callback)
|
||||
* [`readFileSync(filename, [options])`](#readfilesyncfilename-options)
|
||||
* [`writeFile(filename, obj, [options], callback)`](#writefilefilename-obj-options-callback)
|
||||
* [`writeFileSync(filename, obj, [options])`](#writefilesyncfilename-obj-options)
|
||||
|
||||
----
|
||||
|
||||
### readFile(filename, [options], callback)
|
||||
|
||||
`options` (`object`, default `undefined`): Pass in any [`fs.readFile`](https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback) options or set `reviver` for a [JSON reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).
|
||||
- `throws` (`boolean`, default: `true`). If `JSON.parse` throws an error, pass this error to the callback.
|
||||
If `false`, returns `null` for the object.
|
||||
|
||||
|
||||
```js
|
||||
const jsonfile = require('jsonfile')
|
||||
const file = '/tmp/data.json'
|
||||
jsonfile.readFile(file, function (err, obj) {
|
||||
if (err) console.error(err)
|
||||
console.dir(obj)
|
||||
})
|
||||
```
|
||||
|
||||
You can also use this method with promises. The `readFile` method will return a promise if you do not pass a callback function.
|
||||
|
||||
```js
|
||||
const jsonfile = require('jsonfile')
|
||||
const file = '/tmp/data.json'
|
||||
jsonfile.readFile(file)
|
||||
.then(obj => console.dir(obj))
|
||||
.catch(error => console.error(error))
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
### readFileSync(filename, [options])
|
||||
|
||||
`options` (`object`, default `undefined`): Pass in any [`fs.readFileSync`](https://nodejs.org/api/fs.html#fs_fs_readfilesync_path_options) options or set `reviver` for a [JSON reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).
|
||||
- `throws` (`boolean`, default: `true`). If an error is encountered reading or parsing the file, throw the error. If `false`, returns `null` for the object.
|
||||
|
||||
```js
|
||||
const jsonfile = require('jsonfile')
|
||||
const file = '/tmp/data.json'
|
||||
|
||||
console.dir(jsonfile.readFileSync(file))
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
### writeFile(filename, obj, [options], callback)
|
||||
|
||||
`options`: Pass in any [`fs.writeFile`](https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback) options or set `replacer` for a [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). Can also pass in `spaces`, or override `EOL` string or set `finalEOL` flag as `false` to not save the file with `EOL` at the end.
|
||||
|
||||
|
||||
```js
|
||||
const jsonfile = require('jsonfile')
|
||||
|
||||
const file = '/tmp/data.json'
|
||||
const obj = { name: 'JP' }
|
||||
|
||||
jsonfile.writeFile(file, obj, function (err) {
|
||||
if (err) console.error(err)
|
||||
})
|
||||
```
|
||||
Or use with promises as follows:
|
||||
|
||||
```js
|
||||
const jsonfile = require('jsonfile')
|
||||
|
||||
const file = '/tmp/data.json'
|
||||
const obj = { name: 'JP' }
|
||||
|
||||
jsonfile.writeFile(file, obj)
|
||||
.then(res => {
|
||||
console.log('Write complete')
|
||||
})
|
||||
.catch(error => console.error(error))
|
||||
```
|
||||
|
||||
|
||||
**formatting with spaces:**
|
||||
|
||||
```js
|
||||
const jsonfile = require('jsonfile')
|
||||
|
||||
const file = '/tmp/data.json'
|
||||
const obj = { name: 'JP' }
|
||||
|
||||
jsonfile.writeFile(file, obj, { spaces: 2 }, function (err) {
|
||||
if (err) console.error(err)
|
||||
})
|
||||
```
|
||||
|
||||
**overriding EOL:**
|
||||
|
||||
```js
|
||||
const jsonfile = require('jsonfile')
|
||||
|
||||
const file = '/tmp/data.json'
|
||||
const obj = { name: 'JP' }
|
||||
|
||||
jsonfile.writeFile(file, obj, { spaces: 2, EOL: '\r\n' }, function (err) {
|
||||
if (err) console.error(err)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
**disabling the EOL at the end of file:**
|
||||
|
||||
```js
|
||||
const jsonfile = require('jsonfile')
|
||||
|
||||
const file = '/tmp/data.json'
|
||||
const obj = { name: 'JP' }
|
||||
|
||||
jsonfile.writeFile(file, obj, { spaces: 2, finalEOL: false }, function (err) {
|
||||
if (err) console.log(err)
|
||||
})
|
||||
```
|
||||
|
||||
**appending to an existing JSON file:**
|
||||
|
||||
You can use `fs.writeFile` option `{ flag: 'a' }` to achieve this.
|
||||
|
||||
```js
|
||||
const jsonfile = require('jsonfile')
|
||||
|
||||
const file = '/tmp/mayAlreadyExistedData.json'
|
||||
const obj = { name: 'JP' }
|
||||
|
||||
jsonfile.writeFile(file, obj, { flag: 'a' }, function (err) {
|
||||
if (err) console.error(err)
|
||||
})
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
### writeFileSync(filename, obj, [options])
|
||||
|
||||
`options`: Pass in any [`fs.writeFileSync`](https://nodejs.org/api/fs.html#fs_fs_writefilesync_file_data_options) options or set `replacer` for a [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). Can also pass in `spaces`, or override `EOL` string or set `finalEOL` flag as `false` to not save the file with `EOL` at the end.
|
||||
|
||||
```js
|
||||
const jsonfile = require('jsonfile')
|
||||
|
||||
const file = '/tmp/data.json'
|
||||
const obj = { name: 'JP' }
|
||||
|
||||
jsonfile.writeFileSync(file, obj)
|
||||
```
|
||||
|
||||
**formatting with spaces:**
|
||||
|
||||
```js
|
||||
const jsonfile = require('jsonfile')
|
||||
|
||||
const file = '/tmp/data.json'
|
||||
const obj = { name: 'JP' }
|
||||
|
||||
jsonfile.writeFileSync(file, obj, { spaces: 2 })
|
||||
```
|
||||
|
||||
**overriding EOL:**
|
||||
|
||||
```js
|
||||
const jsonfile = require('jsonfile')
|
||||
|
||||
const file = '/tmp/data.json'
|
||||
const obj = { name: 'JP' }
|
||||
|
||||
jsonfile.writeFileSync(file, obj, { spaces: 2, EOL: '\r\n' })
|
||||
```
|
||||
|
||||
**disabling the EOL at the end of file:**
|
||||
|
||||
```js
|
||||
const jsonfile = require('jsonfile')
|
||||
|
||||
const file = '/tmp/data.json'
|
||||
const obj = { name: 'JP' }
|
||||
|
||||
jsonfile.writeFileSync(file, obj, { spaces: 2, finalEOL: false })
|
||||
```
|
||||
|
||||
**appending to an existing JSON file:**
|
||||
|
||||
You can use `fs.writeFileSync` option `{ flag: 'a' }` to achieve this.
|
||||
|
||||
```js
|
||||
const jsonfile = require('jsonfile')
|
||||
|
||||
const file = '/tmp/mayAlreadyExistedData.json'
|
||||
const obj = { name: 'JP' }
|
||||
|
||||
jsonfile.writeFileSync(file, obj, { flag: 'a' })
|
||||
```
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
(MIT License)
|
||||
|
||||
Copyright 2012-2016, JP Richardson <jprichardson@gmail.com>
|
||||
88
electron/node_modules/unzipper/node_modules/jsonfile/index.js
generated
vendored
Normal file
88
electron/node_modules/unzipper/node_modules/jsonfile/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
let _fs
|
||||
try {
|
||||
_fs = require('graceful-fs')
|
||||
} catch (_) {
|
||||
_fs = require('fs')
|
||||
}
|
||||
const universalify = require('universalify')
|
||||
const { stringify, stripBom } = require('./utils')
|
||||
|
||||
async function _readFile (file, options = {}) {
|
||||
if (typeof options === 'string') {
|
||||
options = { encoding: options }
|
||||
}
|
||||
|
||||
const fs = options.fs || _fs
|
||||
|
||||
const shouldThrow = 'throws' in options ? options.throws : true
|
||||
|
||||
let data = await universalify.fromCallback(fs.readFile)(file, options)
|
||||
|
||||
data = stripBom(data)
|
||||
|
||||
let obj
|
||||
try {
|
||||
obj = JSON.parse(data, options ? options.reviver : null)
|
||||
} catch (err) {
|
||||
if (shouldThrow) {
|
||||
err.message = `${file}: ${err.message}`
|
||||
throw err
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
const readFile = universalify.fromPromise(_readFile)
|
||||
|
||||
function readFileSync (file, options = {}) {
|
||||
if (typeof options === 'string') {
|
||||
options = { encoding: options }
|
||||
}
|
||||
|
||||
const fs = options.fs || _fs
|
||||
|
||||
const shouldThrow = 'throws' in options ? options.throws : true
|
||||
|
||||
try {
|
||||
let content = fs.readFileSync(file, options)
|
||||
content = stripBom(content)
|
||||
return JSON.parse(content, options.reviver)
|
||||
} catch (err) {
|
||||
if (shouldThrow) {
|
||||
err.message = `${file}: ${err.message}`
|
||||
throw err
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function _writeFile (file, obj, options = {}) {
|
||||
const fs = options.fs || _fs
|
||||
|
||||
const str = stringify(obj, options)
|
||||
|
||||
await universalify.fromCallback(fs.writeFile)(file, str, options)
|
||||
}
|
||||
|
||||
const writeFile = universalify.fromPromise(_writeFile)
|
||||
|
||||
function writeFileSync (file, obj, options = {}) {
|
||||
const fs = options.fs || _fs
|
||||
|
||||
const str = stringify(obj, options)
|
||||
// not sure if fs.writeFileSync returns anything, but just in case
|
||||
return fs.writeFileSync(file, str, options)
|
||||
}
|
||||
|
||||
// NOTE: do not change this export format; required for ESM compat
|
||||
// see https://github.com/jprichardson/node-jsonfile/pull/162 for details
|
||||
module.exports = {
|
||||
readFile,
|
||||
readFileSync,
|
||||
writeFile,
|
||||
writeFileSync
|
||||
}
|
||||
40
electron/node_modules/unzipper/node_modules/jsonfile/package.json
generated
vendored
Normal file
40
electron/node_modules/unzipper/node_modules/jsonfile/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"name": "jsonfile",
|
||||
"version": "6.2.1",
|
||||
"description": "Easily read/write JSON files.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:jprichardson/node-jsonfile.git"
|
||||
},
|
||||
"keywords": [
|
||||
"read",
|
||||
"write",
|
||||
"file",
|
||||
"json",
|
||||
"fs",
|
||||
"fs-extra"
|
||||
],
|
||||
"author": "JP Richardson <jprichardson@gmail.com>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"universalify": "^2.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"graceful-fs": "^4.1.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "^8.2.0",
|
||||
"rimraf": "^2.4.0",
|
||||
"standard": "^16.0.1"
|
||||
},
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"index.js",
|
||||
"utils.js"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "standard",
|
||||
"test": "npm run lint && npm run unit",
|
||||
"unit": "mocha"
|
||||
}
|
||||
}
|
||||
18
electron/node_modules/unzipper/node_modules/jsonfile/utils.js
generated
vendored
Normal file
18
electron/node_modules/unzipper/node_modules/jsonfile/utils.js
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
function stringify (obj, { EOL = '\n', finalEOL = true, replacer = null, spaces } = {}) {
|
||||
const EOF = finalEOL ? EOL : ''
|
||||
const str = JSON.stringify(obj, replacer, spaces)
|
||||
|
||||
if (str === undefined) {
|
||||
throw new TypeError(`Converting ${typeof obj} value to JSON is not supported`)
|
||||
}
|
||||
|
||||
return str.replace(/\n/g, EOL) + EOF
|
||||
}
|
||||
|
||||
function stripBom (content) {
|
||||
// we do this because JSON.parse would convert it to a utf8 string if encoding wasn't specified
|
||||
if (Buffer.isBuffer(content)) content = content.toString('utf8')
|
||||
return content.replace(/^\uFEFF/, '')
|
||||
}
|
||||
|
||||
module.exports = { stringify, stripBom }
|
||||
62
electron/node_modules/unzipper/package.json
generated
vendored
Normal file
62
electron/node_modules/unzipper/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
{
|
||||
"name": "unzipper",
|
||||
"version": "0.12.5",
|
||||
"description": "Unzip cross-platform streaming API ",
|
||||
"author": "Ziggy Jonsson <ziggy.jonsson.nyc@gmail.com>",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Ziggy Jonsson",
|
||||
"email": "ziggy.jonsson.nyc@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Evan Oxfeld",
|
||||
"email": "eoxfeld@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Joe Ferner",
|
||||
"email": "joe.ferner@nearinfinity.com"
|
||||
}
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ZJONSSON/node-unzipper.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bluebird": "~3.7.2",
|
||||
"duplexer2": "~0.1.4",
|
||||
"fs-extra": "11.3.1",
|
||||
"graceful-fs": "^4.2.2",
|
||||
"node-int64": "^0.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.2.0",
|
||||
"aws-sdk": "^2.1636.0",
|
||||
"@aws-sdk/client-s3": "^3.0.0",
|
||||
"dirdiff": ">= 0.0.1 < 1",
|
||||
"eslint": "^9.2.0",
|
||||
"globals": "^15.2.0",
|
||||
"iconv-lite": "^0.4.24",
|
||||
"request": "^2.88.0",
|
||||
"stream-buffers": ">= 0.2.5 < 1",
|
||||
"tap": "^16.3.10",
|
||||
"temp": ">= 0.4.0 < 1"
|
||||
},
|
||||
"directories": {
|
||||
"example": "examples",
|
||||
"test": "test"
|
||||
},
|
||||
"keywords": [
|
||||
"zip",
|
||||
"unzip",
|
||||
"zlib",
|
||||
"uncompress",
|
||||
"archive",
|
||||
"stream",
|
||||
"extract"
|
||||
],
|
||||
"main": "unzip.js",
|
||||
"scripts": {
|
||||
"test": "npx tap test/*.js --coverage-report=html --lines=90 --functions=85 --statements=90 --branches=80 --reporter=dot"
|
||||
}
|
||||
}
|
||||
5
electron/node_modules/unzipper/unzip.js
generated
vendored
Normal file
5
electron/node_modules/unzipper/unzip.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
'use strict';
|
||||
exports.Parse = require('./lib/parse');
|
||||
exports.ParseOne = require('./lib/parseOne');
|
||||
exports.Extract = require('./lib/extract');
|
||||
exports.Open = require('./lib/Open');
|
||||
Loading…
Add table
Add a link
Reference in a new issue