@builderbot/provider-web-whatsapp 1.0.31-alpha.0 → 1.0.33-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,15 +1,20 @@
1
1
  'use strict';
2
2
 
3
3
  var bot = require('@builderbot/bot');
4
- var fs = require('fs');
4
+ var require$$0$3 = require('fs');
5
5
  var promises = require('fs/promises');
6
6
  var require$$1 = require('path');
7
7
  var os = require('os');
8
8
  var whatsappWeb_js = require('whatsapp-web.js');
9
+ var require$$0$1 = require('constants');
10
+ var require$$0$2 = require('stream');
11
+ var require$$4 = require('util');
12
+ var require$$5 = require('assert');
9
13
  require('http');
10
14
  require('https');
11
- var require$$0$2 = require('stream');
12
- var require$$0$1 = require('zlib');
15
+ var require$$0$4 = require('zlib');
16
+
17
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
13
18
 
14
19
  function getDefaultExportFromCjs (x) {
15
20
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -10925,6 +10930,2445 @@ var mimeDb = require$$0;
10925
10930
 
10926
10931
  var mime = /*@__PURE__*/getDefaultExportFromCjs(mimeTypes);
10927
10932
 
10933
+ var fs$h = {};
10934
+
10935
+ var universalify$1 = {};
10936
+
10937
+ universalify$1.fromCallback = function (fn) {
10938
+ return Object.defineProperty(function (...args) {
10939
+ if (typeof args[args.length - 1] === 'function') fn.apply(this, args);
10940
+ else {
10941
+ return new Promise((resolve, reject) => {
10942
+ args.push((err, res) => (err != null) ? reject(err) : resolve(res));
10943
+ fn.apply(this, args);
10944
+ })
10945
+ }
10946
+ }, 'name', { value: fn.name })
10947
+ };
10948
+
10949
+ universalify$1.fromPromise = function (fn) {
10950
+ return Object.defineProperty(function (...args) {
10951
+ const cb = args[args.length - 1];
10952
+ if (typeof cb !== 'function') return fn.apply(this, args)
10953
+ else {
10954
+ args.pop();
10955
+ fn.apply(this, args).then(r => cb(null, r), cb);
10956
+ }
10957
+ }, 'name', { value: fn.name })
10958
+ };
10959
+
10960
+ var constants = require$$0$1;
10961
+
10962
+ var origCwd = process.cwd;
10963
+ var cwd = null;
10964
+
10965
+ var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
10966
+
10967
+ process.cwd = function() {
10968
+ if (!cwd)
10969
+ cwd = origCwd.call(process);
10970
+ return cwd
10971
+ };
10972
+ try {
10973
+ process.cwd();
10974
+ } catch (er) {}
10975
+
10976
+ // This check is needed until node.js 12 is required
10977
+ if (typeof process.chdir === 'function') {
10978
+ var chdir = process.chdir;
10979
+ process.chdir = function (d) {
10980
+ cwd = null;
10981
+ chdir.call(process, d);
10982
+ };
10983
+ if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
10984
+ }
10985
+
10986
+ var polyfills$1 = patch$1;
10987
+
10988
+ function patch$1 (fs) {
10989
+ // (re-)implement some things that are known busted or missing.
10990
+
10991
+ // lchmod, broken prior to 0.6.2
10992
+ // back-port the fix here.
10993
+ if (constants.hasOwnProperty('O_SYMLINK') &&
10994
+ process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
10995
+ patchLchmod(fs);
10996
+ }
10997
+
10998
+ // lutimes implementation, or no-op
10999
+ if (!fs.lutimes) {
11000
+ patchLutimes(fs);
11001
+ }
11002
+
11003
+ // https://github.com/isaacs/node-graceful-fs/issues/4
11004
+ // Chown should not fail on einval or eperm if non-root.
11005
+ // It should not fail on enosys ever, as this just indicates
11006
+ // that a fs doesn't support the intended operation.
11007
+
11008
+ fs.chown = chownFix(fs.chown);
11009
+ fs.fchown = chownFix(fs.fchown);
11010
+ fs.lchown = chownFix(fs.lchown);
11011
+
11012
+ fs.chmod = chmodFix(fs.chmod);
11013
+ fs.fchmod = chmodFix(fs.fchmod);
11014
+ fs.lchmod = chmodFix(fs.lchmod);
11015
+
11016
+ fs.chownSync = chownFixSync(fs.chownSync);
11017
+ fs.fchownSync = chownFixSync(fs.fchownSync);
11018
+ fs.lchownSync = chownFixSync(fs.lchownSync);
11019
+
11020
+ fs.chmodSync = chmodFixSync(fs.chmodSync);
11021
+ fs.fchmodSync = chmodFixSync(fs.fchmodSync);
11022
+ fs.lchmodSync = chmodFixSync(fs.lchmodSync);
11023
+
11024
+ fs.stat = statFix(fs.stat);
11025
+ fs.fstat = statFix(fs.fstat);
11026
+ fs.lstat = statFix(fs.lstat);
11027
+
11028
+ fs.statSync = statFixSync(fs.statSync);
11029
+ fs.fstatSync = statFixSync(fs.fstatSync);
11030
+ fs.lstatSync = statFixSync(fs.lstatSync);
11031
+
11032
+ // if lchmod/lchown do not exist, then make them no-ops
11033
+ if (fs.chmod && !fs.lchmod) {
11034
+ fs.lchmod = function (path, mode, cb) {
11035
+ if (cb) process.nextTick(cb);
11036
+ };
11037
+ fs.lchmodSync = function () {};
11038
+ }
11039
+ if (fs.chown && !fs.lchown) {
11040
+ fs.lchown = function (path, uid, gid, cb) {
11041
+ if (cb) process.nextTick(cb);
11042
+ };
11043
+ fs.lchownSync = function () {};
11044
+ }
11045
+
11046
+ // on Windows, A/V software can lock the directory, causing this
11047
+ // to fail with an EACCES or EPERM if the directory contains newly
11048
+ // created files. Try again on failure, for up to 60 seconds.
11049
+
11050
+ // Set the timeout this long because some Windows Anti-Virus, such as Parity
11051
+ // bit9, may lock files for up to a minute, causing npm package install
11052
+ // failures. Also, take care to yield the scheduler. Windows scheduling gives
11053
+ // CPU to a busy looping process, which can cause the program causing the lock
11054
+ // contention to be starved of CPU by node, so the contention doesn't resolve.
11055
+ if (platform === "win32") {
11056
+ fs.rename = typeof fs.rename !== 'function' ? fs.rename
11057
+ : (function (fs$rename) {
11058
+ function rename (from, to, cb) {
11059
+ var start = Date.now();
11060
+ var backoff = 0;
11061
+ fs$rename(from, to, function CB (er) {
11062
+ if (er
11063
+ && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY")
11064
+ && Date.now() - start < 60000) {
11065
+ setTimeout(function() {
11066
+ fs.stat(to, function (stater, st) {
11067
+ if (stater && stater.code === "ENOENT")
11068
+ fs$rename(from, to, CB);
11069
+ else
11070
+ cb(er);
11071
+ });
11072
+ }, backoff);
11073
+ if (backoff < 100)
11074
+ backoff += 10;
11075
+ return;
11076
+ }
11077
+ if (cb) cb(er);
11078
+ });
11079
+ }
11080
+ if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
11081
+ return rename
11082
+ })(fs.rename);
11083
+ }
11084
+
11085
+ // if read() returns EAGAIN, then just try it again.
11086
+ fs.read = typeof fs.read !== 'function' ? fs.read
11087
+ : (function (fs$read) {
11088
+ function read (fd, buffer, offset, length, position, callback_) {
11089
+ var callback;
11090
+ if (callback_ && typeof callback_ === 'function') {
11091
+ var eagCounter = 0;
11092
+ callback = function (er, _, __) {
11093
+ if (er && er.code === 'EAGAIN' && eagCounter < 10) {
11094
+ eagCounter ++;
11095
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback)
11096
+ }
11097
+ callback_.apply(this, arguments);
11098
+ };
11099
+ }
11100
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback)
11101
+ }
11102
+
11103
+ // This ensures `util.promisify` works as it does for native `fs.read`.
11104
+ if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
11105
+ return read
11106
+ })(fs.read);
11107
+
11108
+ fs.readSync = typeof fs.readSync !== 'function' ? fs.readSync
11109
+ : (function (fs$readSync) { return function (fd, buffer, offset, length, position) {
11110
+ var eagCounter = 0;
11111
+ while (true) {
11112
+ try {
11113
+ return fs$readSync.call(fs, fd, buffer, offset, length, position)
11114
+ } catch (er) {
11115
+ if (er.code === 'EAGAIN' && eagCounter < 10) {
11116
+ eagCounter ++;
11117
+ continue
11118
+ }
11119
+ throw er
11120
+ }
11121
+ }
11122
+ }})(fs.readSync);
11123
+
11124
+ function patchLchmod (fs) {
11125
+ fs.lchmod = function (path, mode, callback) {
11126
+ fs.open( path
11127
+ , constants.O_WRONLY | constants.O_SYMLINK
11128
+ , mode
11129
+ , function (err, fd) {
11130
+ if (err) {
11131
+ if (callback) callback(err);
11132
+ return
11133
+ }
11134
+ // prefer to return the chmod error, if one occurs,
11135
+ // but still try to close, and report closing errors if they occur.
11136
+ fs.fchmod(fd, mode, function (err) {
11137
+ fs.close(fd, function(err2) {
11138
+ if (callback) callback(err || err2);
11139
+ });
11140
+ });
11141
+ });
11142
+ };
11143
+
11144
+ fs.lchmodSync = function (path, mode) {
11145
+ var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
11146
+
11147
+ // prefer to return the chmod error, if one occurs,
11148
+ // but still try to close, and report closing errors if they occur.
11149
+ var threw = true;
11150
+ var ret;
11151
+ try {
11152
+ ret = fs.fchmodSync(fd, mode);
11153
+ threw = false;
11154
+ } finally {
11155
+ if (threw) {
11156
+ try {
11157
+ fs.closeSync(fd);
11158
+ } catch (er) {}
11159
+ } else {
11160
+ fs.closeSync(fd);
11161
+ }
11162
+ }
11163
+ return ret
11164
+ };
11165
+ }
11166
+
11167
+ function patchLutimes (fs) {
11168
+ if (constants.hasOwnProperty("O_SYMLINK") && fs.futimes) {
11169
+ fs.lutimes = function (path, at, mt, cb) {
11170
+ fs.open(path, constants.O_SYMLINK, function (er, fd) {
11171
+ if (er) {
11172
+ if (cb) cb(er);
11173
+ return
11174
+ }
11175
+ fs.futimes(fd, at, mt, function (er) {
11176
+ fs.close(fd, function (er2) {
11177
+ if (cb) cb(er || er2);
11178
+ });
11179
+ });
11180
+ });
11181
+ };
11182
+
11183
+ fs.lutimesSync = function (path, at, mt) {
11184
+ var fd = fs.openSync(path, constants.O_SYMLINK);
11185
+ var ret;
11186
+ var threw = true;
11187
+ try {
11188
+ ret = fs.futimesSync(fd, at, mt);
11189
+ threw = false;
11190
+ } finally {
11191
+ if (threw) {
11192
+ try {
11193
+ fs.closeSync(fd);
11194
+ } catch (er) {}
11195
+ } else {
11196
+ fs.closeSync(fd);
11197
+ }
11198
+ }
11199
+ return ret
11200
+ };
11201
+
11202
+ } else if (fs.futimes) {
11203
+ fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb); };
11204
+ fs.lutimesSync = function () {};
11205
+ }
11206
+ }
11207
+
11208
+ function chmodFix (orig) {
11209
+ if (!orig) return orig
11210
+ return function (target, mode, cb) {
11211
+ return orig.call(fs, target, mode, function (er) {
11212
+ if (chownErOk(er)) er = null;
11213
+ if (cb) cb.apply(this, arguments);
11214
+ })
11215
+ }
11216
+ }
11217
+
11218
+ function chmodFixSync (orig) {
11219
+ if (!orig) return orig
11220
+ return function (target, mode) {
11221
+ try {
11222
+ return orig.call(fs, target, mode)
11223
+ } catch (er) {
11224
+ if (!chownErOk(er)) throw er
11225
+ }
11226
+ }
11227
+ }
11228
+
11229
+
11230
+ function chownFix (orig) {
11231
+ if (!orig) return orig
11232
+ return function (target, uid, gid, cb) {
11233
+ return orig.call(fs, target, uid, gid, function (er) {
11234
+ if (chownErOk(er)) er = null;
11235
+ if (cb) cb.apply(this, arguments);
11236
+ })
11237
+ }
11238
+ }
11239
+
11240
+ function chownFixSync (orig) {
11241
+ if (!orig) return orig
11242
+ return function (target, uid, gid) {
11243
+ try {
11244
+ return orig.call(fs, target, uid, gid)
11245
+ } catch (er) {
11246
+ if (!chownErOk(er)) throw er
11247
+ }
11248
+ }
11249
+ }
11250
+
11251
+ function statFix (orig) {
11252
+ if (!orig) return orig
11253
+ // Older versions of Node erroneously returned signed integers for
11254
+ // uid + gid.
11255
+ return function (target, options, cb) {
11256
+ if (typeof options === 'function') {
11257
+ cb = options;
11258
+ options = null;
11259
+ }
11260
+ function callback (er, stats) {
11261
+ if (stats) {
11262
+ if (stats.uid < 0) stats.uid += 0x100000000;
11263
+ if (stats.gid < 0) stats.gid += 0x100000000;
11264
+ }
11265
+ if (cb) cb.apply(this, arguments);
11266
+ }
11267
+ return options ? orig.call(fs, target, options, callback)
11268
+ : orig.call(fs, target, callback)
11269
+ }
11270
+ }
11271
+
11272
+ function statFixSync (orig) {
11273
+ if (!orig) return orig
11274
+ // Older versions of Node erroneously returned signed integers for
11275
+ // uid + gid.
11276
+ return function (target, options) {
11277
+ var stats = options ? orig.call(fs, target, options)
11278
+ : orig.call(fs, target);
11279
+ if (stats) {
11280
+ if (stats.uid < 0) stats.uid += 0x100000000;
11281
+ if (stats.gid < 0) stats.gid += 0x100000000;
11282
+ }
11283
+ return stats;
11284
+ }
11285
+ }
11286
+
11287
+ // ENOSYS means that the fs doesn't support the op. Just ignore
11288
+ // that, because it doesn't matter.
11289
+ //
11290
+ // if there's no getuid, or if getuid() is something other
11291
+ // than 0, and the error is EINVAL or EPERM, then just ignore
11292
+ // it.
11293
+ //
11294
+ // This specific case is a silent failure in cp, install, tar,
11295
+ // and most other unix tools that manage permissions.
11296
+ //
11297
+ // When running as root, or if other types of errors are
11298
+ // encountered, then it's strict.
11299
+ function chownErOk (er) {
11300
+ if (!er)
11301
+ return true
11302
+
11303
+ if (er.code === "ENOSYS")
11304
+ return true
11305
+
11306
+ var nonroot = !process.getuid || process.getuid() !== 0;
11307
+ if (nonroot) {
11308
+ if (er.code === "EINVAL" || er.code === "EPERM")
11309
+ return true
11310
+ }
11311
+
11312
+ return false
11313
+ }
11314
+ }
11315
+
11316
+ var Stream = require$$0$2.Stream;
11317
+
11318
+ var legacyStreams = legacy$1;
11319
+
11320
+ function legacy$1 (fs) {
11321
+ return {
11322
+ ReadStream: ReadStream,
11323
+ WriteStream: WriteStream
11324
+ }
11325
+
11326
+ function ReadStream (path, options) {
11327
+ if (!(this instanceof ReadStream)) return new ReadStream(path, options);
11328
+
11329
+ Stream.call(this);
11330
+
11331
+ var self = this;
11332
+
11333
+ this.path = path;
11334
+ this.fd = null;
11335
+ this.readable = true;
11336
+ this.paused = false;
11337
+
11338
+ this.flags = 'r';
11339
+ this.mode = 438; /*=0666*/
11340
+ this.bufferSize = 64 * 1024;
11341
+
11342
+ options = options || {};
11343
+
11344
+ // Mixin options into this
11345
+ var keys = Object.keys(options);
11346
+ for (var index = 0, length = keys.length; index < length; index++) {
11347
+ var key = keys[index];
11348
+ this[key] = options[key];
11349
+ }
11350
+
11351
+ if (this.encoding) this.setEncoding(this.encoding);
11352
+
11353
+ if (this.start !== undefined) {
11354
+ if ('number' !== typeof this.start) {
11355
+ throw TypeError('start must be a Number');
11356
+ }
11357
+ if (this.end === undefined) {
11358
+ this.end = Infinity;
11359
+ } else if ('number' !== typeof this.end) {
11360
+ throw TypeError('end must be a Number');
11361
+ }
11362
+
11363
+ if (this.start > this.end) {
11364
+ throw new Error('start must be <= end');
11365
+ }
11366
+
11367
+ this.pos = this.start;
11368
+ }
11369
+
11370
+ if (this.fd !== null) {
11371
+ process.nextTick(function() {
11372
+ self._read();
11373
+ });
11374
+ return;
11375
+ }
11376
+
11377
+ fs.open(this.path, this.flags, this.mode, function (err, fd) {
11378
+ if (err) {
11379
+ self.emit('error', err);
11380
+ self.readable = false;
11381
+ return;
11382
+ }
11383
+
11384
+ self.fd = fd;
11385
+ self.emit('open', fd);
11386
+ self._read();
11387
+ });
11388
+ }
11389
+
11390
+ function WriteStream (path, options) {
11391
+ if (!(this instanceof WriteStream)) return new WriteStream(path, options);
11392
+
11393
+ Stream.call(this);
11394
+
11395
+ this.path = path;
11396
+ this.fd = null;
11397
+ this.writable = true;
11398
+
11399
+ this.flags = 'w';
11400
+ this.encoding = 'binary';
11401
+ this.mode = 438; /*=0666*/
11402
+ this.bytesWritten = 0;
11403
+
11404
+ options = options || {};
11405
+
11406
+ // Mixin options into this
11407
+ var keys = Object.keys(options);
11408
+ for (var index = 0, length = keys.length; index < length; index++) {
11409
+ var key = keys[index];
11410
+ this[key] = options[key];
11411
+ }
11412
+
11413
+ if (this.start !== undefined) {
11414
+ if ('number' !== typeof this.start) {
11415
+ throw TypeError('start must be a Number');
11416
+ }
11417
+ if (this.start < 0) {
11418
+ throw new Error('start must be >= zero');
11419
+ }
11420
+
11421
+ this.pos = this.start;
11422
+ }
11423
+
11424
+ this.busy = false;
11425
+ this._queue = [];
11426
+
11427
+ if (this.fd === null) {
11428
+ this._open = fs.open;
11429
+ this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);
11430
+ this.flush();
11431
+ }
11432
+ }
11433
+ }
11434
+
11435
+ var clone_1 = clone$1;
11436
+
11437
+ var getPrototypeOf = Object.getPrototypeOf || function (obj) {
11438
+ return obj.__proto__
11439
+ };
11440
+
11441
+ function clone$1 (obj) {
11442
+ if (obj === null || typeof obj !== 'object')
11443
+ return obj
11444
+
11445
+ if (obj instanceof Object)
11446
+ var copy = { __proto__: getPrototypeOf(obj) };
11447
+ else
11448
+ var copy = Object.create(null);
11449
+
11450
+ Object.getOwnPropertyNames(obj).forEach(function (key) {
11451
+ Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
11452
+ });
11453
+
11454
+ return copy
11455
+ }
11456
+
11457
+ var fs$g = require$$0$3;
11458
+ var polyfills = polyfills$1;
11459
+ var legacy = legacyStreams;
11460
+ var clone = clone_1;
11461
+
11462
+ var util = require$$4;
11463
+
11464
+ /* istanbul ignore next - node 0.x polyfill */
11465
+ var gracefulQueue;
11466
+ var previousSymbol;
11467
+
11468
+ /* istanbul ignore else - node 0.x polyfill */
11469
+ if (typeof Symbol === 'function' && typeof Symbol.for === 'function') {
11470
+ gracefulQueue = Symbol.for('graceful-fs.queue');
11471
+ // This is used in testing by future versions
11472
+ previousSymbol = Symbol.for('graceful-fs.previous');
11473
+ } else {
11474
+ gracefulQueue = '___graceful-fs.queue';
11475
+ previousSymbol = '___graceful-fs.previous';
11476
+ }
11477
+
11478
+ function noop () {}
11479
+
11480
+ function publishQueue(context, queue) {
11481
+ Object.defineProperty(context, gracefulQueue, {
11482
+ get: function() {
11483
+ return queue
11484
+ }
11485
+ });
11486
+ }
11487
+
11488
+ var debug = noop;
11489
+ if (util.debuglog)
11490
+ debug = util.debuglog('gfs4');
11491
+ else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ''))
11492
+ debug = function() {
11493
+ var m = util.format.apply(util, arguments);
11494
+ m = 'GFS4: ' + m.split(/\n/).join('\nGFS4: ');
11495
+ console.error(m);
11496
+ };
11497
+
11498
+ // Once time initialization
11499
+ if (!fs$g[gracefulQueue]) {
11500
+ // This queue can be shared by multiple loaded instances
11501
+ var queue = commonjsGlobal[gracefulQueue] || [];
11502
+ publishQueue(fs$g, queue);
11503
+
11504
+ // Patch fs.close/closeSync to shared queue version, because we need
11505
+ // to retry() whenever a close happens *anywhere* in the program.
11506
+ // This is essential when multiple graceful-fs instances are
11507
+ // in play at the same time.
11508
+ fs$g.close = (function (fs$close) {
11509
+ function close (fd, cb) {
11510
+ return fs$close.call(fs$g, fd, function (err) {
11511
+ // This function uses the graceful-fs shared queue
11512
+ if (!err) {
11513
+ resetQueue();
11514
+ }
11515
+
11516
+ if (typeof cb === 'function')
11517
+ cb.apply(this, arguments);
11518
+ })
11519
+ }
11520
+
11521
+ Object.defineProperty(close, previousSymbol, {
11522
+ value: fs$close
11523
+ });
11524
+ return close
11525
+ })(fs$g.close);
11526
+
11527
+ fs$g.closeSync = (function (fs$closeSync) {
11528
+ function closeSync (fd) {
11529
+ // This function uses the graceful-fs shared queue
11530
+ fs$closeSync.apply(fs$g, arguments);
11531
+ resetQueue();
11532
+ }
11533
+
11534
+ Object.defineProperty(closeSync, previousSymbol, {
11535
+ value: fs$closeSync
11536
+ });
11537
+ return closeSync
11538
+ })(fs$g.closeSync);
11539
+
11540
+ if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) {
11541
+ process.on('exit', function() {
11542
+ debug(fs$g[gracefulQueue]);
11543
+ require$$5.equal(fs$g[gracefulQueue].length, 0);
11544
+ });
11545
+ }
11546
+ }
11547
+
11548
+ if (!commonjsGlobal[gracefulQueue]) {
11549
+ publishQueue(commonjsGlobal, fs$g[gracefulQueue]);
11550
+ }
11551
+
11552
+ var gracefulFs = patch(clone(fs$g));
11553
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs$g.__patched) {
11554
+ gracefulFs = patch(fs$g);
11555
+ fs$g.__patched = true;
11556
+ }
11557
+
11558
+ function patch (fs) {
11559
+ // Everything that references the open() function needs to be in here
11560
+ polyfills(fs);
11561
+ fs.gracefulify = patch;
11562
+
11563
+ fs.createReadStream = createReadStream;
11564
+ fs.createWriteStream = createWriteStream;
11565
+ var fs$readFile = fs.readFile;
11566
+ fs.readFile = readFile;
11567
+ function readFile (path, options, cb) {
11568
+ if (typeof options === 'function')
11569
+ cb = options, options = null;
11570
+
11571
+ return go$readFile(path, options, cb)
11572
+
11573
+ function go$readFile (path, options, cb, startTime) {
11574
+ return fs$readFile(path, options, function (err) {
11575
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
11576
+ enqueue([go$readFile, [path, options, cb], err, startTime || Date.now(), Date.now()]);
11577
+ else {
11578
+ if (typeof cb === 'function')
11579
+ cb.apply(this, arguments);
11580
+ }
11581
+ })
11582
+ }
11583
+ }
11584
+
11585
+ var fs$writeFile = fs.writeFile;
11586
+ fs.writeFile = writeFile;
11587
+ function writeFile (path, data, options, cb) {
11588
+ if (typeof options === 'function')
11589
+ cb = options, options = null;
11590
+
11591
+ return go$writeFile(path, data, options, cb)
11592
+
11593
+ function go$writeFile (path, data, options, cb, startTime) {
11594
+ return fs$writeFile(path, data, options, function (err) {
11595
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
11596
+ enqueue([go$writeFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()]);
11597
+ else {
11598
+ if (typeof cb === 'function')
11599
+ cb.apply(this, arguments);
11600
+ }
11601
+ })
11602
+ }
11603
+ }
11604
+
11605
+ var fs$appendFile = fs.appendFile;
11606
+ if (fs$appendFile)
11607
+ fs.appendFile = appendFile;
11608
+ function appendFile (path, data, options, cb) {
11609
+ if (typeof options === 'function')
11610
+ cb = options, options = null;
11611
+
11612
+ return go$appendFile(path, data, options, cb)
11613
+
11614
+ function go$appendFile (path, data, options, cb, startTime) {
11615
+ return fs$appendFile(path, data, options, function (err) {
11616
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
11617
+ enqueue([go$appendFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()]);
11618
+ else {
11619
+ if (typeof cb === 'function')
11620
+ cb.apply(this, arguments);
11621
+ }
11622
+ })
11623
+ }
11624
+ }
11625
+
11626
+ var fs$copyFile = fs.copyFile;
11627
+ if (fs$copyFile)
11628
+ fs.copyFile = copyFile;
11629
+ function copyFile (src, dest, flags, cb) {
11630
+ if (typeof flags === 'function') {
11631
+ cb = flags;
11632
+ flags = 0;
11633
+ }
11634
+ return go$copyFile(src, dest, flags, cb)
11635
+
11636
+ function go$copyFile (src, dest, flags, cb, startTime) {
11637
+ return fs$copyFile(src, dest, flags, function (err) {
11638
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
11639
+ enqueue([go$copyFile, [src, dest, flags, cb], err, startTime || Date.now(), Date.now()]);
11640
+ else {
11641
+ if (typeof cb === 'function')
11642
+ cb.apply(this, arguments);
11643
+ }
11644
+ })
11645
+ }
11646
+ }
11647
+
11648
+ var fs$readdir = fs.readdir;
11649
+ fs.readdir = readdir;
11650
+ var noReaddirOptionVersions = /^v[0-5]\./;
11651
+ function readdir (path, options, cb) {
11652
+ if (typeof options === 'function')
11653
+ cb = options, options = null;
11654
+
11655
+ var go$readdir = noReaddirOptionVersions.test(process.version)
11656
+ ? function go$readdir (path, options, cb, startTime) {
11657
+ return fs$readdir(path, fs$readdirCallback(
11658
+ path, options, cb, startTime
11659
+ ))
11660
+ }
11661
+ : function go$readdir (path, options, cb, startTime) {
11662
+ return fs$readdir(path, options, fs$readdirCallback(
11663
+ path, options, cb, startTime
11664
+ ))
11665
+ };
11666
+
11667
+ return go$readdir(path, options, cb)
11668
+
11669
+ function fs$readdirCallback (path, options, cb, startTime) {
11670
+ return function (err, files) {
11671
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
11672
+ enqueue([
11673
+ go$readdir,
11674
+ [path, options, cb],
11675
+ err,
11676
+ startTime || Date.now(),
11677
+ Date.now()
11678
+ ]);
11679
+ else {
11680
+ if (files && files.sort)
11681
+ files.sort();
11682
+
11683
+ if (typeof cb === 'function')
11684
+ cb.call(this, err, files);
11685
+ }
11686
+ }
11687
+ }
11688
+ }
11689
+
11690
+ if (process.version.substr(0, 4) === 'v0.8') {
11691
+ var legStreams = legacy(fs);
11692
+ ReadStream = legStreams.ReadStream;
11693
+ WriteStream = legStreams.WriteStream;
11694
+ }
11695
+
11696
+ var fs$ReadStream = fs.ReadStream;
11697
+ if (fs$ReadStream) {
11698
+ ReadStream.prototype = Object.create(fs$ReadStream.prototype);
11699
+ ReadStream.prototype.open = ReadStream$open;
11700
+ }
11701
+
11702
+ var fs$WriteStream = fs.WriteStream;
11703
+ if (fs$WriteStream) {
11704
+ WriteStream.prototype = Object.create(fs$WriteStream.prototype);
11705
+ WriteStream.prototype.open = WriteStream$open;
11706
+ }
11707
+
11708
+ Object.defineProperty(fs, 'ReadStream', {
11709
+ get: function () {
11710
+ return ReadStream
11711
+ },
11712
+ set: function (val) {
11713
+ ReadStream = val;
11714
+ },
11715
+ enumerable: true,
11716
+ configurable: true
11717
+ });
11718
+ Object.defineProperty(fs, 'WriteStream', {
11719
+ get: function () {
11720
+ return WriteStream
11721
+ },
11722
+ set: function (val) {
11723
+ WriteStream = val;
11724
+ },
11725
+ enumerable: true,
11726
+ configurable: true
11727
+ });
11728
+
11729
+ // legacy names
11730
+ var FileReadStream = ReadStream;
11731
+ Object.defineProperty(fs, 'FileReadStream', {
11732
+ get: function () {
11733
+ return FileReadStream
11734
+ },
11735
+ set: function (val) {
11736
+ FileReadStream = val;
11737
+ },
11738
+ enumerable: true,
11739
+ configurable: true
11740
+ });
11741
+ var FileWriteStream = WriteStream;
11742
+ Object.defineProperty(fs, 'FileWriteStream', {
11743
+ get: function () {
11744
+ return FileWriteStream
11745
+ },
11746
+ set: function (val) {
11747
+ FileWriteStream = val;
11748
+ },
11749
+ enumerable: true,
11750
+ configurable: true
11751
+ });
11752
+
11753
+ function ReadStream (path, options) {
11754
+ if (this instanceof ReadStream)
11755
+ return fs$ReadStream.apply(this, arguments), this
11756
+ else
11757
+ return ReadStream.apply(Object.create(ReadStream.prototype), arguments)
11758
+ }
11759
+
11760
+ function ReadStream$open () {
11761
+ var that = this;
11762
+ open(that.path, that.flags, that.mode, function (err, fd) {
11763
+ if (err) {
11764
+ if (that.autoClose)
11765
+ that.destroy();
11766
+
11767
+ that.emit('error', err);
11768
+ } else {
11769
+ that.fd = fd;
11770
+ that.emit('open', fd);
11771
+ that.read();
11772
+ }
11773
+ });
11774
+ }
11775
+
11776
+ function WriteStream (path, options) {
11777
+ if (this instanceof WriteStream)
11778
+ return fs$WriteStream.apply(this, arguments), this
11779
+ else
11780
+ return WriteStream.apply(Object.create(WriteStream.prototype), arguments)
11781
+ }
11782
+
11783
+ function WriteStream$open () {
11784
+ var that = this;
11785
+ open(that.path, that.flags, that.mode, function (err, fd) {
11786
+ if (err) {
11787
+ that.destroy();
11788
+ that.emit('error', err);
11789
+ } else {
11790
+ that.fd = fd;
11791
+ that.emit('open', fd);
11792
+ }
11793
+ });
11794
+ }
11795
+
11796
+ function createReadStream (path, options) {
11797
+ return new fs.ReadStream(path, options)
11798
+ }
11799
+
11800
+ function createWriteStream (path, options) {
11801
+ return new fs.WriteStream(path, options)
11802
+ }
11803
+
11804
+ var fs$open = fs.open;
11805
+ fs.open = open;
11806
+ function open (path, flags, mode, cb) {
11807
+ if (typeof mode === 'function')
11808
+ cb = mode, mode = null;
11809
+
11810
+ return go$open(path, flags, mode, cb)
11811
+
11812
+ function go$open (path, flags, mode, cb, startTime) {
11813
+ return fs$open(path, flags, mode, function (err, fd) {
11814
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
11815
+ enqueue([go$open, [path, flags, mode, cb], err, startTime || Date.now(), Date.now()]);
11816
+ else {
11817
+ if (typeof cb === 'function')
11818
+ cb.apply(this, arguments);
11819
+ }
11820
+ })
11821
+ }
11822
+ }
11823
+
11824
+ return fs
11825
+ }
11826
+
11827
+ function enqueue (elem) {
11828
+ debug('ENQUEUE', elem[0].name, elem[1]);
11829
+ fs$g[gracefulQueue].push(elem);
11830
+ retry();
11831
+ }
11832
+
11833
+ // keep track of the timeout between retry() calls
11834
+ var retryTimer;
11835
+
11836
+ // reset the startTime and lastTime to now
11837
+ // this resets the start of the 60 second overall timeout as well as the
11838
+ // delay between attempts so that we'll retry these jobs sooner
11839
+ function resetQueue () {
11840
+ var now = Date.now();
11841
+ for (var i = 0; i < fs$g[gracefulQueue].length; ++i) {
11842
+ // entries that are only a length of 2 are from an older version, don't
11843
+ // bother modifying those since they'll be retried anyway.
11844
+ if (fs$g[gracefulQueue][i].length > 2) {
11845
+ fs$g[gracefulQueue][i][3] = now; // startTime
11846
+ fs$g[gracefulQueue][i][4] = now; // lastTime
11847
+ }
11848
+ }
11849
+ // call retry to make sure we're actively processing the queue
11850
+ retry();
11851
+ }
11852
+
11853
+ function retry () {
11854
+ // clear the timer and remove it to help prevent unintended concurrency
11855
+ clearTimeout(retryTimer);
11856
+ retryTimer = undefined;
11857
+
11858
+ if (fs$g[gracefulQueue].length === 0)
11859
+ return
11860
+
11861
+ var elem = fs$g[gracefulQueue].shift();
11862
+ var fn = elem[0];
11863
+ var args = elem[1];
11864
+ // these items may be unset if they were added by an older graceful-fs
11865
+ var err = elem[2];
11866
+ var startTime = elem[3];
11867
+ var lastTime = elem[4];
11868
+
11869
+ // if we don't have a startTime we have no way of knowing if we've waited
11870
+ // long enough, so go ahead and retry this item now
11871
+ if (startTime === undefined) {
11872
+ debug('RETRY', fn.name, args);
11873
+ fn.apply(null, args);
11874
+ } else if (Date.now() - startTime >= 60000) {
11875
+ // it's been more than 60 seconds total, bail now
11876
+ debug('TIMEOUT', fn.name, args);
11877
+ var cb = args.pop();
11878
+ if (typeof cb === 'function')
11879
+ cb.call(null, err);
11880
+ } else {
11881
+ // the amount of time between the last attempt and right now
11882
+ var sinceAttempt = Date.now() - lastTime;
11883
+ // the amount of time between when we first tried, and when we last tried
11884
+ // rounded up to at least 1
11885
+ var sinceStart = Math.max(lastTime - startTime, 1);
11886
+ // backoff. wait longer than the total time we've been retrying, but only
11887
+ // up to a maximum of 100ms
11888
+ var desiredDelay = Math.min(sinceStart * 1.2, 100);
11889
+ // it's been long enough since the last retry, do it again
11890
+ if (sinceAttempt >= desiredDelay) {
11891
+ debug('RETRY', fn.name, args);
11892
+ fn.apply(null, args.concat([startTime]));
11893
+ } else {
11894
+ // if we can't do this job yet, push it to the end of the queue
11895
+ // and let the next iteration check again
11896
+ fs$g[gracefulQueue].push(elem);
11897
+ }
11898
+ }
11899
+
11900
+ // schedule our next run if one isn't already scheduled
11901
+ if (retryTimer === undefined) {
11902
+ retryTimer = setTimeout(retry, 0);
11903
+ }
11904
+ }
11905
+
11906
+ (function (exports) {
11907
+ // This is adapted from https://github.com/normalize/mz
11908
+ // Copyright (c) 2014-2016 Jonathan Ong me@jongleberry.com and Contributors
11909
+ const u = universalify$1.fromCallback;
11910
+ const fs = gracefulFs;
11911
+
11912
+ const api = [
11913
+ 'access',
11914
+ 'appendFile',
11915
+ 'chmod',
11916
+ 'chown',
11917
+ 'close',
11918
+ 'copyFile',
11919
+ 'fchmod',
11920
+ 'fchown',
11921
+ 'fdatasync',
11922
+ 'fstat',
11923
+ 'fsync',
11924
+ 'ftruncate',
11925
+ 'futimes',
11926
+ 'lchmod',
11927
+ 'lchown',
11928
+ 'link',
11929
+ 'lstat',
11930
+ 'mkdir',
11931
+ 'mkdtemp',
11932
+ 'open',
11933
+ 'opendir',
11934
+ 'readdir',
11935
+ 'readFile',
11936
+ 'readlink',
11937
+ 'realpath',
11938
+ 'rename',
11939
+ 'rm',
11940
+ 'rmdir',
11941
+ 'stat',
11942
+ 'symlink',
11943
+ 'truncate',
11944
+ 'unlink',
11945
+ 'utimes',
11946
+ 'writeFile'
11947
+ ].filter(key => {
11948
+ // Some commands are not available on some systems. Ex:
11949
+ // fs.cp was added in Node.js v16.7.0
11950
+ // fs.lchown is not available on at least some Linux
11951
+ return typeof fs[key] === 'function'
11952
+ });
11953
+
11954
+ // Export cloned fs:
11955
+ Object.assign(exports, fs);
11956
+
11957
+ // Universalify async methods:
11958
+ api.forEach(method => {
11959
+ exports[method] = u(fs[method]);
11960
+ });
11961
+
11962
+ // We differ from mz/fs in that we still ship the old, broken, fs.exists()
11963
+ // since we are a drop-in replacement for the native module
11964
+ exports.exists = function (filename, callback) {
11965
+ if (typeof callback === 'function') {
11966
+ return fs.exists(filename, callback)
11967
+ }
11968
+ return new Promise(resolve => {
11969
+ return fs.exists(filename, resolve)
11970
+ })
11971
+ };
11972
+
11973
+ // fs.read(), fs.write(), fs.readv(), & fs.writev() need special treatment due to multiple callback args
11974
+
11975
+ exports.read = function (fd, buffer, offset, length, position, callback) {
11976
+ if (typeof callback === 'function') {
11977
+ return fs.read(fd, buffer, offset, length, position, callback)
11978
+ }
11979
+ return new Promise((resolve, reject) => {
11980
+ fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer) => {
11981
+ if (err) return reject(err)
11982
+ resolve({ bytesRead, buffer });
11983
+ });
11984
+ })
11985
+ };
11986
+
11987
+ // Function signature can be
11988
+ // fs.write(fd, buffer[, offset[, length[, position]]], callback)
11989
+ // OR
11990
+ // fs.write(fd, string[, position[, encoding]], callback)
11991
+ // We need to handle both cases, so we use ...args
11992
+ exports.write = function (fd, buffer, ...args) {
11993
+ if (typeof args[args.length - 1] === 'function') {
11994
+ return fs.write(fd, buffer, ...args)
11995
+ }
11996
+
11997
+ return new Promise((resolve, reject) => {
11998
+ fs.write(fd, buffer, ...args, (err, bytesWritten, buffer) => {
11999
+ if (err) return reject(err)
12000
+ resolve({ bytesWritten, buffer });
12001
+ });
12002
+ })
12003
+ };
12004
+
12005
+ // Function signature is
12006
+ // s.readv(fd, buffers[, position], callback)
12007
+ // We need to handle the optional arg, so we use ...args
12008
+ exports.readv = function (fd, buffers, ...args) {
12009
+ if (typeof args[args.length - 1] === 'function') {
12010
+ return fs.readv(fd, buffers, ...args)
12011
+ }
12012
+
12013
+ return new Promise((resolve, reject) => {
12014
+ fs.readv(fd, buffers, ...args, (err, bytesRead, buffers) => {
12015
+ if (err) return reject(err)
12016
+ resolve({ bytesRead, buffers });
12017
+ });
12018
+ })
12019
+ };
12020
+
12021
+ // Function signature is
12022
+ // s.writev(fd, buffers[, position], callback)
12023
+ // We need to handle the optional arg, so we use ...args
12024
+ exports.writev = function (fd, buffers, ...args) {
12025
+ if (typeof args[args.length - 1] === 'function') {
12026
+ return fs.writev(fd, buffers, ...args)
12027
+ }
12028
+
12029
+ return new Promise((resolve, reject) => {
12030
+ fs.writev(fd, buffers, ...args, (err, bytesWritten, buffers) => {
12031
+ if (err) return reject(err)
12032
+ resolve({ bytesWritten, buffers });
12033
+ });
12034
+ })
12035
+ };
12036
+
12037
+ // fs.realpath.native sometimes not available if fs is monkey-patched
12038
+ if (typeof fs.realpath.native === 'function') {
12039
+ exports.realpath.native = u(fs.realpath.native);
12040
+ } else {
12041
+ process.emitWarning(
12042
+ 'fs.realpath.native is not a function. Is fs being monkey-patched?',
12043
+ 'Warning', 'fs-extra-WARN0003'
12044
+ );
12045
+ }
12046
+ } (fs$h));
12047
+
12048
+ var makeDir$1 = {};
12049
+
12050
+ var utils$1 = {};
12051
+
12052
+ const path$b = require$$1;
12053
+
12054
+ // https://github.com/nodejs/node/issues/8987
12055
+ // https://github.com/libuv/libuv/pull/1088
12056
+ utils$1.checkPath = function checkPath (pth) {
12057
+ if (process.platform === 'win32') {
12058
+ const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path$b.parse(pth).root, ''));
12059
+
12060
+ if (pathHasInvalidWinCharacters) {
12061
+ const error = new Error(`Path contains invalid characters: ${pth}`);
12062
+ error.code = 'EINVAL';
12063
+ throw error
12064
+ }
12065
+ }
12066
+ };
12067
+
12068
+ const fs$f = fs$h;
12069
+ const { checkPath } = utils$1;
12070
+
12071
+ const getMode = options => {
12072
+ const defaults = { mode: 0o777 };
12073
+ if (typeof options === 'number') return options
12074
+ return ({ ...defaults, ...options }).mode
12075
+ };
12076
+
12077
+ makeDir$1.makeDir = async (dir, options) => {
12078
+ checkPath(dir);
12079
+
12080
+ return fs$f.mkdir(dir, {
12081
+ mode: getMode(options),
12082
+ recursive: true
12083
+ })
12084
+ };
12085
+
12086
+ makeDir$1.makeDirSync = (dir, options) => {
12087
+ checkPath(dir);
12088
+
12089
+ return fs$f.mkdirSync(dir, {
12090
+ mode: getMode(options),
12091
+ recursive: true
12092
+ })
12093
+ };
12094
+
12095
+ const u$e = universalify$1.fromPromise;
12096
+ const { makeDir: _makeDir, makeDirSync } = makeDir$1;
12097
+ const makeDir = u$e(_makeDir);
12098
+
12099
+ var mkdirs$2 = {
12100
+ mkdirs: makeDir,
12101
+ mkdirsSync: makeDirSync,
12102
+ // alias
12103
+ mkdirp: makeDir,
12104
+ mkdirpSync: makeDirSync,
12105
+ ensureDir: makeDir,
12106
+ ensureDirSync: makeDirSync
12107
+ };
12108
+
12109
+ const u$d = universalify$1.fromPromise;
12110
+ const fs$e = fs$h;
12111
+
12112
+ function pathExists$6 (path) {
12113
+ return fs$e.access(path).then(() => true).catch(() => false)
12114
+ }
12115
+
12116
+ var pathExists_1 = {
12117
+ pathExists: u$d(pathExists$6),
12118
+ pathExistsSync: fs$e.existsSync
12119
+ };
12120
+
12121
+ const fs$d = fs$h;
12122
+ const u$c = universalify$1.fromPromise;
12123
+
12124
+ async function utimesMillis$1 (path, atime, mtime) {
12125
+ // if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback)
12126
+ const fd = await fs$d.open(path, 'r+');
12127
+
12128
+ let closeErr = null;
12129
+
12130
+ try {
12131
+ await fs$d.futimes(fd, atime, mtime);
12132
+ } finally {
12133
+ try {
12134
+ await fs$d.close(fd);
12135
+ } catch (e) {
12136
+ closeErr = e;
12137
+ }
12138
+ }
12139
+
12140
+ if (closeErr) {
12141
+ throw closeErr
12142
+ }
12143
+ }
12144
+
12145
+ function utimesMillisSync$1 (path, atime, mtime) {
12146
+ const fd = fs$d.openSync(path, 'r+');
12147
+ fs$d.futimesSync(fd, atime, mtime);
12148
+ return fs$d.closeSync(fd)
12149
+ }
12150
+
12151
+ var utimes = {
12152
+ utimesMillis: u$c(utimesMillis$1),
12153
+ utimesMillisSync: utimesMillisSync$1
12154
+ };
12155
+
12156
+ const fs$c = fs$h;
12157
+ const path$a = require$$1;
12158
+ const u$b = universalify$1.fromPromise;
12159
+
12160
+ function getStats$1 (src, dest, opts) {
12161
+ const statFunc = opts.dereference
12162
+ ? (file) => fs$c.stat(file, { bigint: true })
12163
+ : (file) => fs$c.lstat(file, { bigint: true });
12164
+ return Promise.all([
12165
+ statFunc(src),
12166
+ statFunc(dest).catch(err => {
12167
+ if (err.code === 'ENOENT') return null
12168
+ throw err
12169
+ })
12170
+ ]).then(([srcStat, destStat]) => ({ srcStat, destStat }))
12171
+ }
12172
+
12173
+ function getStatsSync (src, dest, opts) {
12174
+ let destStat;
12175
+ const statFunc = opts.dereference
12176
+ ? (file) => fs$c.statSync(file, { bigint: true })
12177
+ : (file) => fs$c.lstatSync(file, { bigint: true });
12178
+ const srcStat = statFunc(src);
12179
+ try {
12180
+ destStat = statFunc(dest);
12181
+ } catch (err) {
12182
+ if (err.code === 'ENOENT') return { srcStat, destStat: null }
12183
+ throw err
12184
+ }
12185
+ return { srcStat, destStat }
12186
+ }
12187
+
12188
+ async function checkPaths (src, dest, funcName, opts) {
12189
+ const { srcStat, destStat } = await getStats$1(src, dest, opts);
12190
+ if (destStat) {
12191
+ if (areIdentical$2(srcStat, destStat)) {
12192
+ const srcBaseName = path$a.basename(src);
12193
+ const destBaseName = path$a.basename(dest);
12194
+ if (funcName === 'move' &&
12195
+ srcBaseName !== destBaseName &&
12196
+ srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
12197
+ return { srcStat, destStat, isChangingCase: true }
12198
+ }
12199
+ throw new Error('Source and destination must not be the same.')
12200
+ }
12201
+ if (srcStat.isDirectory() && !destStat.isDirectory()) {
12202
+ throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`)
12203
+ }
12204
+ if (!srcStat.isDirectory() && destStat.isDirectory()) {
12205
+ throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`)
12206
+ }
12207
+ }
12208
+
12209
+ if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
12210
+ throw new Error(errMsg(src, dest, funcName))
12211
+ }
12212
+
12213
+ return { srcStat, destStat }
12214
+ }
12215
+
12216
+ function checkPathsSync (src, dest, funcName, opts) {
12217
+ const { srcStat, destStat } = getStatsSync(src, dest, opts);
12218
+
12219
+ if (destStat) {
12220
+ if (areIdentical$2(srcStat, destStat)) {
12221
+ const srcBaseName = path$a.basename(src);
12222
+ const destBaseName = path$a.basename(dest);
12223
+ if (funcName === 'move' &&
12224
+ srcBaseName !== destBaseName &&
12225
+ srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
12226
+ return { srcStat, destStat, isChangingCase: true }
12227
+ }
12228
+ throw new Error('Source and destination must not be the same.')
12229
+ }
12230
+ if (srcStat.isDirectory() && !destStat.isDirectory()) {
12231
+ throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`)
12232
+ }
12233
+ if (!srcStat.isDirectory() && destStat.isDirectory()) {
12234
+ throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`)
12235
+ }
12236
+ }
12237
+
12238
+ if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
12239
+ throw new Error(errMsg(src, dest, funcName))
12240
+ }
12241
+ return { srcStat, destStat }
12242
+ }
12243
+
12244
+ // recursively check if dest parent is a subdirectory of src.
12245
+ // It works for all file types including symlinks since it
12246
+ // checks the src and dest inodes. It starts from the deepest
12247
+ // parent and stops once it reaches the src parent or the root path.
12248
+ async function checkParentPaths (src, srcStat, dest, funcName) {
12249
+ const srcParent = path$a.resolve(path$a.dirname(src));
12250
+ const destParent = path$a.resolve(path$a.dirname(dest));
12251
+ if (destParent === srcParent || destParent === path$a.parse(destParent).root) return
12252
+
12253
+ let destStat;
12254
+ try {
12255
+ destStat = await fs$c.stat(destParent, { bigint: true });
12256
+ } catch (err) {
12257
+ if (err.code === 'ENOENT') return
12258
+ throw err
12259
+ }
12260
+
12261
+ if (areIdentical$2(srcStat, destStat)) {
12262
+ throw new Error(errMsg(src, dest, funcName))
12263
+ }
12264
+
12265
+ return checkParentPaths(src, srcStat, destParent, funcName)
12266
+ }
12267
+
12268
+ function checkParentPathsSync (src, srcStat, dest, funcName) {
12269
+ const srcParent = path$a.resolve(path$a.dirname(src));
12270
+ const destParent = path$a.resolve(path$a.dirname(dest));
12271
+ if (destParent === srcParent || destParent === path$a.parse(destParent).root) return
12272
+ let destStat;
12273
+ try {
12274
+ destStat = fs$c.statSync(destParent, { bigint: true });
12275
+ } catch (err) {
12276
+ if (err.code === 'ENOENT') return
12277
+ throw err
12278
+ }
12279
+ if (areIdentical$2(srcStat, destStat)) {
12280
+ throw new Error(errMsg(src, dest, funcName))
12281
+ }
12282
+ return checkParentPathsSync(src, srcStat, destParent, funcName)
12283
+ }
12284
+
12285
+ function areIdentical$2 (srcStat, destStat) {
12286
+ return destStat.ino && destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev
12287
+ }
12288
+
12289
+ // return true if dest is a subdir of src, otherwise false.
12290
+ // It only checks the path strings.
12291
+ function isSrcSubdir (src, dest) {
12292
+ const srcArr = path$a.resolve(src).split(path$a.sep).filter(i => i);
12293
+ const destArr = path$a.resolve(dest).split(path$a.sep).filter(i => i);
12294
+ return srcArr.every((cur, i) => destArr[i] === cur)
12295
+ }
12296
+
12297
+ function errMsg (src, dest, funcName) {
12298
+ return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`
12299
+ }
12300
+
12301
+ var stat$4 = {
12302
+ // checkPaths
12303
+ checkPaths: u$b(checkPaths),
12304
+ checkPathsSync,
12305
+ // checkParent
12306
+ checkParentPaths: u$b(checkParentPaths),
12307
+ checkParentPathsSync,
12308
+ // Misc
12309
+ isSrcSubdir,
12310
+ areIdentical: areIdentical$2
12311
+ };
12312
+
12313
+ const fs$b = fs$h;
12314
+ const path$9 = require$$1;
12315
+ const { mkdirs: mkdirs$1 } = mkdirs$2;
12316
+ const { pathExists: pathExists$5 } = pathExists_1;
12317
+ const { utimesMillis } = utimes;
12318
+ const stat$3 = stat$4;
12319
+
12320
+ async function copy$2 (src, dest, opts = {}) {
12321
+ if (typeof opts === 'function') {
12322
+ opts = { filter: opts };
12323
+ }
12324
+
12325
+ opts.clobber = 'clobber' in opts ? !!opts.clobber : true; // default to true for now
12326
+ opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber; // overwrite falls back to clobber
12327
+
12328
+ // Warn about using preserveTimestamps on 32-bit node
12329
+ if (opts.preserveTimestamps && process.arch === 'ia32') {
12330
+ process.emitWarning(
12331
+ 'Using the preserveTimestamps option in 32-bit node is not recommended;\n\n' +
12332
+ '\tsee https://github.com/jprichardson/node-fs-extra/issues/269',
12333
+ 'Warning', 'fs-extra-WARN0001'
12334
+ );
12335
+ }
12336
+
12337
+ const { srcStat, destStat } = await stat$3.checkPaths(src, dest, 'copy', opts);
12338
+
12339
+ await stat$3.checkParentPaths(src, srcStat, dest, 'copy');
12340
+
12341
+ const include = await runFilter(src, dest, opts);
12342
+
12343
+ if (!include) return
12344
+
12345
+ // check if the parent of dest exists, and create it if it doesn't exist
12346
+ const destParent = path$9.dirname(dest);
12347
+ const dirExists = await pathExists$5(destParent);
12348
+ if (!dirExists) {
12349
+ await mkdirs$1(destParent);
12350
+ }
12351
+
12352
+ await getStatsAndPerformCopy(destStat, src, dest, opts);
12353
+ }
12354
+
12355
+ async function runFilter (src, dest, opts) {
12356
+ if (!opts.filter) return true
12357
+ return opts.filter(src, dest)
12358
+ }
12359
+
12360
+ async function getStatsAndPerformCopy (destStat, src, dest, opts) {
12361
+ const statFn = opts.dereference ? fs$b.stat : fs$b.lstat;
12362
+ const srcStat = await statFn(src);
12363
+
12364
+ if (srcStat.isDirectory()) return onDir$1(srcStat, destStat, src, dest, opts)
12365
+
12366
+ if (
12367
+ srcStat.isFile() ||
12368
+ srcStat.isCharacterDevice() ||
12369
+ srcStat.isBlockDevice()
12370
+ ) return onFile$1(srcStat, destStat, src, dest, opts)
12371
+
12372
+ if (srcStat.isSymbolicLink()) return onLink$1(destStat, src, dest, opts)
12373
+ if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`)
12374
+ if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`)
12375
+ throw new Error(`Unknown file: ${src}`)
12376
+ }
12377
+
12378
+ async function onFile$1 (srcStat, destStat, src, dest, opts) {
12379
+ if (!destStat) return copyFile$1(srcStat, src, dest, opts)
12380
+
12381
+ if (opts.overwrite) {
12382
+ await fs$b.unlink(dest);
12383
+ return copyFile$1(srcStat, src, dest, opts)
12384
+ }
12385
+ if (opts.errorOnExist) {
12386
+ throw new Error(`'${dest}' already exists`)
12387
+ }
12388
+ }
12389
+
12390
+ async function copyFile$1 (srcStat, src, dest, opts) {
12391
+ await fs$b.copyFile(src, dest);
12392
+ if (opts.preserveTimestamps) {
12393
+ // Make sure the file is writable before setting the timestamp
12394
+ // otherwise open fails with EPERM when invoked with 'r+'
12395
+ // (through utimes call)
12396
+ if (fileIsNotWritable$1(srcStat.mode)) {
12397
+ await makeFileWritable$1(dest, srcStat.mode);
12398
+ }
12399
+
12400
+ // Set timestamps and mode correspondingly
12401
+
12402
+ // Note that The initial srcStat.atime cannot be trusted
12403
+ // because it is modified by the read(2) system call
12404
+ // (See https://nodejs.org/api/fs.html#fs_stat_time_values)
12405
+ const updatedSrcStat = await fs$b.stat(src);
12406
+ await utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
12407
+ }
12408
+
12409
+ return fs$b.chmod(dest, srcStat.mode)
12410
+ }
12411
+
12412
+ function fileIsNotWritable$1 (srcMode) {
12413
+ return (srcMode & 0o200) === 0
12414
+ }
12415
+
12416
+ function makeFileWritable$1 (dest, srcMode) {
12417
+ return fs$b.chmod(dest, srcMode | 0o200)
12418
+ }
12419
+
12420
+ async function onDir$1 (srcStat, destStat, src, dest, opts) {
12421
+ // the dest directory might not exist, create it
12422
+ if (!destStat) {
12423
+ await fs$b.mkdir(dest);
12424
+ }
12425
+
12426
+ const items = await fs$b.readdir(src);
12427
+
12428
+ // loop through the files in the current directory to copy everything
12429
+ await Promise.all(items.map(async item => {
12430
+ const srcItem = path$9.join(src, item);
12431
+ const destItem = path$9.join(dest, item);
12432
+
12433
+ // skip the item if it is matches by the filter function
12434
+ const include = await runFilter(srcItem, destItem, opts);
12435
+ if (!include) return
12436
+
12437
+ const { destStat } = await stat$3.checkPaths(srcItem, destItem, 'copy', opts);
12438
+
12439
+ // If the item is a copyable file, `getStatsAndPerformCopy` will copy it
12440
+ // If the item is a directory, `getStatsAndPerformCopy` will call `onDir` recursively
12441
+ return getStatsAndPerformCopy(destStat, srcItem, destItem, opts)
12442
+ }));
12443
+
12444
+ if (!destStat) {
12445
+ await fs$b.chmod(dest, srcStat.mode);
12446
+ }
12447
+ }
12448
+
12449
+ async function onLink$1 (destStat, src, dest, opts) {
12450
+ let resolvedSrc = await fs$b.readlink(src);
12451
+ if (opts.dereference) {
12452
+ resolvedSrc = path$9.resolve(process.cwd(), resolvedSrc);
12453
+ }
12454
+ if (!destStat) {
12455
+ return fs$b.symlink(resolvedSrc, dest)
12456
+ }
12457
+
12458
+ let resolvedDest = null;
12459
+ try {
12460
+ resolvedDest = await fs$b.readlink(dest);
12461
+ } catch (e) {
12462
+ // dest exists and is a regular file or directory,
12463
+ // Windows may throw UNKNOWN error. If dest already exists,
12464
+ // fs throws error anyway, so no need to guard against it here.
12465
+ if (e.code === 'EINVAL' || e.code === 'UNKNOWN') return fs$b.symlink(resolvedSrc, dest)
12466
+ throw e
12467
+ }
12468
+ if (opts.dereference) {
12469
+ resolvedDest = path$9.resolve(process.cwd(), resolvedDest);
12470
+ }
12471
+ if (stat$3.isSrcSubdir(resolvedSrc, resolvedDest)) {
12472
+ throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
12473
+ }
12474
+
12475
+ // do not copy if src is a subdir of dest since unlinking
12476
+ // dest in this case would result in removing src contents
12477
+ // and therefore a broken symlink would be created.
12478
+ if (stat$3.isSrcSubdir(resolvedDest, resolvedSrc)) {
12479
+ throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
12480
+ }
12481
+
12482
+ // copy the link
12483
+ await fs$b.unlink(dest);
12484
+ return fs$b.symlink(resolvedSrc, dest)
12485
+ }
12486
+
12487
+ var copy_1 = copy$2;
12488
+
12489
+ const fs$a = gracefulFs;
12490
+ const path$8 = require$$1;
12491
+ const mkdirsSync$1 = mkdirs$2.mkdirsSync;
12492
+ const utimesMillisSync = utimes.utimesMillisSync;
12493
+ const stat$2 = stat$4;
12494
+
12495
+ function copySync$1 (src, dest, opts) {
12496
+ if (typeof opts === 'function') {
12497
+ opts = { filter: opts };
12498
+ }
12499
+
12500
+ opts = opts || {};
12501
+ opts.clobber = 'clobber' in opts ? !!opts.clobber : true; // default to true for now
12502
+ opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber; // overwrite falls back to clobber
12503
+
12504
+ // Warn about using preserveTimestamps on 32-bit node
12505
+ if (opts.preserveTimestamps && process.arch === 'ia32') {
12506
+ process.emitWarning(
12507
+ 'Using the preserveTimestamps option in 32-bit node is not recommended;\n\n' +
12508
+ '\tsee https://github.com/jprichardson/node-fs-extra/issues/269',
12509
+ 'Warning', 'fs-extra-WARN0002'
12510
+ );
12511
+ }
12512
+
12513
+ const { srcStat, destStat } = stat$2.checkPathsSync(src, dest, 'copy', opts);
12514
+ stat$2.checkParentPathsSync(src, srcStat, dest, 'copy');
12515
+ if (opts.filter && !opts.filter(src, dest)) return
12516
+ const destParent = path$8.dirname(dest);
12517
+ if (!fs$a.existsSync(destParent)) mkdirsSync$1(destParent);
12518
+ return getStats(destStat, src, dest, opts)
12519
+ }
12520
+
12521
+ function getStats (destStat, src, dest, opts) {
12522
+ const statSync = opts.dereference ? fs$a.statSync : fs$a.lstatSync;
12523
+ const srcStat = statSync(src);
12524
+
12525
+ if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts)
12526
+ else if (srcStat.isFile() ||
12527
+ srcStat.isCharacterDevice() ||
12528
+ srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts)
12529
+ else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts)
12530
+ else if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`)
12531
+ else if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`)
12532
+ throw new Error(`Unknown file: ${src}`)
12533
+ }
12534
+
12535
+ function onFile (srcStat, destStat, src, dest, opts) {
12536
+ if (!destStat) return copyFile(srcStat, src, dest, opts)
12537
+ return mayCopyFile(srcStat, src, dest, opts)
12538
+ }
12539
+
12540
+ function mayCopyFile (srcStat, src, dest, opts) {
12541
+ if (opts.overwrite) {
12542
+ fs$a.unlinkSync(dest);
12543
+ return copyFile(srcStat, src, dest, opts)
12544
+ } else if (opts.errorOnExist) {
12545
+ throw new Error(`'${dest}' already exists`)
12546
+ }
12547
+ }
12548
+
12549
+ function copyFile (srcStat, src, dest, opts) {
12550
+ fs$a.copyFileSync(src, dest);
12551
+ if (opts.preserveTimestamps) handleTimestamps(srcStat.mode, src, dest);
12552
+ return setDestMode(dest, srcStat.mode)
12553
+ }
12554
+
12555
+ function handleTimestamps (srcMode, src, dest) {
12556
+ // Make sure the file is writable before setting the timestamp
12557
+ // otherwise open fails with EPERM when invoked with 'r+'
12558
+ // (through utimes call)
12559
+ if (fileIsNotWritable(srcMode)) makeFileWritable(dest, srcMode);
12560
+ return setDestTimestamps(src, dest)
12561
+ }
12562
+
12563
+ function fileIsNotWritable (srcMode) {
12564
+ return (srcMode & 0o200) === 0
12565
+ }
12566
+
12567
+ function makeFileWritable (dest, srcMode) {
12568
+ return setDestMode(dest, srcMode | 0o200)
12569
+ }
12570
+
12571
+ function setDestMode (dest, srcMode) {
12572
+ return fs$a.chmodSync(dest, srcMode)
12573
+ }
12574
+
12575
+ function setDestTimestamps (src, dest) {
12576
+ // The initial srcStat.atime cannot be trusted
12577
+ // because it is modified by the read(2) system call
12578
+ // (See https://nodejs.org/api/fs.html#fs_stat_time_values)
12579
+ const updatedSrcStat = fs$a.statSync(src);
12580
+ return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime)
12581
+ }
12582
+
12583
+ function onDir (srcStat, destStat, src, dest, opts) {
12584
+ if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts)
12585
+ return copyDir(src, dest, opts)
12586
+ }
12587
+
12588
+ function mkDirAndCopy (srcMode, src, dest, opts) {
12589
+ fs$a.mkdirSync(dest);
12590
+ copyDir(src, dest, opts);
12591
+ return setDestMode(dest, srcMode)
12592
+ }
12593
+
12594
+ function copyDir (src, dest, opts) {
12595
+ fs$a.readdirSync(src).forEach(item => copyDirItem(item, src, dest, opts));
12596
+ }
12597
+
12598
+ function copyDirItem (item, src, dest, opts) {
12599
+ const srcItem = path$8.join(src, item);
12600
+ const destItem = path$8.join(dest, item);
12601
+ if (opts.filter && !opts.filter(srcItem, destItem)) return
12602
+ const { destStat } = stat$2.checkPathsSync(srcItem, destItem, 'copy', opts);
12603
+ return getStats(destStat, srcItem, destItem, opts)
12604
+ }
12605
+
12606
+ function onLink (destStat, src, dest, opts) {
12607
+ let resolvedSrc = fs$a.readlinkSync(src);
12608
+ if (opts.dereference) {
12609
+ resolvedSrc = path$8.resolve(process.cwd(), resolvedSrc);
12610
+ }
12611
+
12612
+ if (!destStat) {
12613
+ return fs$a.symlinkSync(resolvedSrc, dest)
12614
+ } else {
12615
+ let resolvedDest;
12616
+ try {
12617
+ resolvedDest = fs$a.readlinkSync(dest);
12618
+ } catch (err) {
12619
+ // dest exists and is a regular file or directory,
12620
+ // Windows may throw UNKNOWN error. If dest already exists,
12621
+ // fs throws error anyway, so no need to guard against it here.
12622
+ if (err.code === 'EINVAL' || err.code === 'UNKNOWN') return fs$a.symlinkSync(resolvedSrc, dest)
12623
+ throw err
12624
+ }
12625
+ if (opts.dereference) {
12626
+ resolvedDest = path$8.resolve(process.cwd(), resolvedDest);
12627
+ }
12628
+ if (stat$2.isSrcSubdir(resolvedSrc, resolvedDest)) {
12629
+ throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
12630
+ }
12631
+
12632
+ // prevent copy if src is a subdir of dest since unlinking
12633
+ // dest in this case would result in removing src contents
12634
+ // and therefore a broken symlink would be created.
12635
+ if (stat$2.isSrcSubdir(resolvedDest, resolvedSrc)) {
12636
+ throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
12637
+ }
12638
+ return copyLink(resolvedSrc, dest)
12639
+ }
12640
+ }
12641
+
12642
+ function copyLink (resolvedSrc, dest) {
12643
+ fs$a.unlinkSync(dest);
12644
+ return fs$a.symlinkSync(resolvedSrc, dest)
12645
+ }
12646
+
12647
+ var copySync_1 = copySync$1;
12648
+
12649
+ const u$a = universalify$1.fromPromise;
12650
+ var copy$1 = {
12651
+ copy: u$a(copy_1),
12652
+ copySync: copySync_1
12653
+ };
12654
+
12655
+ const fs$9 = gracefulFs;
12656
+ const u$9 = universalify$1.fromCallback;
12657
+
12658
+ function remove$2 (path, callback) {
12659
+ fs$9.rm(path, { recursive: true, force: true }, callback);
12660
+ }
12661
+
12662
+ function removeSync$1 (path) {
12663
+ fs$9.rmSync(path, { recursive: true, force: true });
12664
+ }
12665
+
12666
+ var remove_1 = {
12667
+ remove: u$9(remove$2),
12668
+ removeSync: removeSync$1
12669
+ };
12670
+
12671
+ const u$8 = universalify$1.fromPromise;
12672
+ const fs$8 = fs$h;
12673
+ const path$7 = require$$1;
12674
+ const mkdir$3 = mkdirs$2;
12675
+ const remove$1 = remove_1;
12676
+
12677
+ const emptyDir = u$8(async function emptyDir (dir) {
12678
+ let items;
12679
+ try {
12680
+ items = await fs$8.readdir(dir);
12681
+ } catch {
12682
+ return mkdir$3.mkdirs(dir)
12683
+ }
12684
+
12685
+ return Promise.all(items.map(item => remove$1.remove(path$7.join(dir, item))))
12686
+ });
12687
+
12688
+ function emptyDirSync (dir) {
12689
+ let items;
12690
+ try {
12691
+ items = fs$8.readdirSync(dir);
12692
+ } catch {
12693
+ return mkdir$3.mkdirsSync(dir)
12694
+ }
12695
+
12696
+ items.forEach(item => {
12697
+ item = path$7.join(dir, item);
12698
+ remove$1.removeSync(item);
12699
+ });
12700
+ }
12701
+
12702
+ var empty = {
12703
+ emptyDirSync,
12704
+ emptydirSync: emptyDirSync,
12705
+ emptyDir,
12706
+ emptydir: emptyDir
12707
+ };
12708
+
12709
+ const u$7 = universalify$1.fromPromise;
12710
+ const path$6 = require$$1;
12711
+ const fs$7 = fs$h;
12712
+ const mkdir$2 = mkdirs$2;
12713
+
12714
+ async function createFile$1 (file) {
12715
+ let stats;
12716
+ try {
12717
+ stats = await fs$7.stat(file);
12718
+ } catch { }
12719
+ if (stats && stats.isFile()) return
12720
+
12721
+ const dir = path$6.dirname(file);
12722
+
12723
+ let dirStats = null;
12724
+ try {
12725
+ dirStats = await fs$7.stat(dir);
12726
+ } catch (err) {
12727
+ // if the directory doesn't exist, make it
12728
+ if (err.code === 'ENOENT') {
12729
+ await mkdir$2.mkdirs(dir);
12730
+ await fs$7.writeFile(file, '');
12731
+ return
12732
+ } else {
12733
+ throw err
12734
+ }
12735
+ }
12736
+
12737
+ if (dirStats.isDirectory()) {
12738
+ await fs$7.writeFile(file, '');
12739
+ } else {
12740
+ // parent is not a directory
12741
+ // This is just to cause an internal ENOTDIR error to be thrown
12742
+ await fs$7.readdir(dir);
12743
+ }
12744
+ }
12745
+
12746
+ function createFileSync$1 (file) {
12747
+ let stats;
12748
+ try {
12749
+ stats = fs$7.statSync(file);
12750
+ } catch { }
12751
+ if (stats && stats.isFile()) return
12752
+
12753
+ const dir = path$6.dirname(file);
12754
+ try {
12755
+ if (!fs$7.statSync(dir).isDirectory()) {
12756
+ // parent is not a directory
12757
+ // This is just to cause an internal ENOTDIR error to be thrown
12758
+ fs$7.readdirSync(dir);
12759
+ }
12760
+ } catch (err) {
12761
+ // If the stat call above failed because the directory doesn't exist, create it
12762
+ if (err && err.code === 'ENOENT') mkdir$2.mkdirsSync(dir);
12763
+ else throw err
12764
+ }
12765
+
12766
+ fs$7.writeFileSync(file, '');
12767
+ }
12768
+
12769
+ var file = {
12770
+ createFile: u$7(createFile$1),
12771
+ createFileSync: createFileSync$1
12772
+ };
12773
+
12774
+ const u$6 = universalify$1.fromPromise;
12775
+ const path$5 = require$$1;
12776
+ const fs$6 = fs$h;
12777
+ const mkdir$1 = mkdirs$2;
12778
+ const { pathExists: pathExists$4 } = pathExists_1;
12779
+ const { areIdentical: areIdentical$1 } = stat$4;
12780
+
12781
+ async function createLink$1 (srcpath, dstpath) {
12782
+ let dstStat;
12783
+ try {
12784
+ dstStat = await fs$6.lstat(dstpath);
12785
+ } catch {
12786
+ // ignore error
12787
+ }
12788
+
12789
+ let srcStat;
12790
+ try {
12791
+ srcStat = await fs$6.lstat(srcpath);
12792
+ } catch (err) {
12793
+ err.message = err.message.replace('lstat', 'ensureLink');
12794
+ throw err
12795
+ }
12796
+
12797
+ if (dstStat && areIdentical$1(srcStat, dstStat)) return
12798
+
12799
+ const dir = path$5.dirname(dstpath);
12800
+
12801
+ const dirExists = await pathExists$4(dir);
12802
+
12803
+ if (!dirExists) {
12804
+ await mkdir$1.mkdirs(dir);
12805
+ }
12806
+
12807
+ await fs$6.link(srcpath, dstpath);
12808
+ }
12809
+
12810
+ function createLinkSync$1 (srcpath, dstpath) {
12811
+ let dstStat;
12812
+ try {
12813
+ dstStat = fs$6.lstatSync(dstpath);
12814
+ } catch {}
12815
+
12816
+ try {
12817
+ const srcStat = fs$6.lstatSync(srcpath);
12818
+ if (dstStat && areIdentical$1(srcStat, dstStat)) return
12819
+ } catch (err) {
12820
+ err.message = err.message.replace('lstat', 'ensureLink');
12821
+ throw err
12822
+ }
12823
+
12824
+ const dir = path$5.dirname(dstpath);
12825
+ const dirExists = fs$6.existsSync(dir);
12826
+ if (dirExists) return fs$6.linkSync(srcpath, dstpath)
12827
+ mkdir$1.mkdirsSync(dir);
12828
+
12829
+ return fs$6.linkSync(srcpath, dstpath)
12830
+ }
12831
+
12832
+ var link = {
12833
+ createLink: u$6(createLink$1),
12834
+ createLinkSync: createLinkSync$1
12835
+ };
12836
+
12837
+ const path$4 = require$$1;
12838
+ const fs$5 = fs$h;
12839
+ const { pathExists: pathExists$3 } = pathExists_1;
12840
+
12841
+ const u$5 = universalify$1.fromPromise;
12842
+
12843
+ /**
12844
+ * Function that returns two types of paths, one relative to symlink, and one
12845
+ * relative to the current working directory. Checks if path is absolute or
12846
+ * relative. If the path is relative, this function checks if the path is
12847
+ * relative to symlink or relative to current working directory. This is an
12848
+ * initiative to find a smarter `srcpath` to supply when building symlinks.
12849
+ * This allows you to determine which path to use out of one of three possible
12850
+ * types of source paths. The first is an absolute path. This is detected by
12851
+ * `path.isAbsolute()`. When an absolute path is provided, it is checked to
12852
+ * see if it exists. If it does it's used, if not an error is returned
12853
+ * (callback)/ thrown (sync). The other two options for `srcpath` are a
12854
+ * relative url. By default Node's `fs.symlink` works by creating a symlink
12855
+ * using `dstpath` and expects the `srcpath` to be relative to the newly
12856
+ * created symlink. If you provide a `srcpath` that does not exist on the file
12857
+ * system it results in a broken symlink. To minimize this, the function
12858
+ * checks to see if the 'relative to symlink' source file exists, and if it
12859
+ * does it will use it. If it does not, it checks if there's a file that
12860
+ * exists that is relative to the current working directory, if does its used.
12861
+ * This preserves the expectations of the original fs.symlink spec and adds
12862
+ * the ability to pass in `relative to current working direcotry` paths.
12863
+ */
12864
+
12865
+ async function symlinkPaths$1 (srcpath, dstpath) {
12866
+ if (path$4.isAbsolute(srcpath)) {
12867
+ try {
12868
+ await fs$5.lstat(srcpath);
12869
+ } catch (err) {
12870
+ err.message = err.message.replace('lstat', 'ensureSymlink');
12871
+ throw err
12872
+ }
12873
+
12874
+ return {
12875
+ toCwd: srcpath,
12876
+ toDst: srcpath
12877
+ }
12878
+ }
12879
+
12880
+ const dstdir = path$4.dirname(dstpath);
12881
+ const relativeToDst = path$4.join(dstdir, srcpath);
12882
+
12883
+ const exists = await pathExists$3(relativeToDst);
12884
+ if (exists) {
12885
+ return {
12886
+ toCwd: relativeToDst,
12887
+ toDst: srcpath
12888
+ }
12889
+ }
12890
+
12891
+ try {
12892
+ await fs$5.lstat(srcpath);
12893
+ } catch (err) {
12894
+ err.message = err.message.replace('lstat', 'ensureSymlink');
12895
+ throw err
12896
+ }
12897
+
12898
+ return {
12899
+ toCwd: srcpath,
12900
+ toDst: path$4.relative(dstdir, srcpath)
12901
+ }
12902
+ }
12903
+
12904
+ function symlinkPathsSync$1 (srcpath, dstpath) {
12905
+ if (path$4.isAbsolute(srcpath)) {
12906
+ const exists = fs$5.existsSync(srcpath);
12907
+ if (!exists) throw new Error('absolute srcpath does not exist')
12908
+ return {
12909
+ toCwd: srcpath,
12910
+ toDst: srcpath
12911
+ }
12912
+ }
12913
+
12914
+ const dstdir = path$4.dirname(dstpath);
12915
+ const relativeToDst = path$4.join(dstdir, srcpath);
12916
+ const exists = fs$5.existsSync(relativeToDst);
12917
+ if (exists) {
12918
+ return {
12919
+ toCwd: relativeToDst,
12920
+ toDst: srcpath
12921
+ }
12922
+ }
12923
+
12924
+ const srcExists = fs$5.existsSync(srcpath);
12925
+ if (!srcExists) throw new Error('relative srcpath does not exist')
12926
+ return {
12927
+ toCwd: srcpath,
12928
+ toDst: path$4.relative(dstdir, srcpath)
12929
+ }
12930
+ }
12931
+
12932
+ var symlinkPaths_1 = {
12933
+ symlinkPaths: u$5(symlinkPaths$1),
12934
+ symlinkPathsSync: symlinkPathsSync$1
12935
+ };
12936
+
12937
+ const fs$4 = fs$h;
12938
+ const u$4 = universalify$1.fromPromise;
12939
+
12940
+ async function symlinkType$1 (srcpath, type) {
12941
+ if (type) return type
12942
+
12943
+ let stats;
12944
+ try {
12945
+ stats = await fs$4.lstat(srcpath);
12946
+ } catch {
12947
+ return 'file'
12948
+ }
12949
+
12950
+ return (stats && stats.isDirectory()) ? 'dir' : 'file'
12951
+ }
12952
+
12953
+ function symlinkTypeSync$1 (srcpath, type) {
12954
+ if (type) return type
12955
+
12956
+ let stats;
12957
+ try {
12958
+ stats = fs$4.lstatSync(srcpath);
12959
+ } catch {
12960
+ return 'file'
12961
+ }
12962
+ return (stats && stats.isDirectory()) ? 'dir' : 'file'
12963
+ }
12964
+
12965
+ var symlinkType_1 = {
12966
+ symlinkType: u$4(symlinkType$1),
12967
+ symlinkTypeSync: symlinkTypeSync$1
12968
+ };
12969
+
12970
+ const u$3 = universalify$1.fromPromise;
12971
+ const path$3 = require$$1;
12972
+ const fs$3 = fs$h;
12973
+
12974
+ const { mkdirs, mkdirsSync } = mkdirs$2;
12975
+
12976
+ const { symlinkPaths, symlinkPathsSync } = symlinkPaths_1;
12977
+ const { symlinkType, symlinkTypeSync } = symlinkType_1;
12978
+
12979
+ const { pathExists: pathExists$2 } = pathExists_1;
12980
+
12981
+ const { areIdentical } = stat$4;
12982
+
12983
+ async function createSymlink$1 (srcpath, dstpath, type) {
12984
+ let stats;
12985
+ try {
12986
+ stats = await fs$3.lstat(dstpath);
12987
+ } catch { }
12988
+
12989
+ if (stats && stats.isSymbolicLink()) {
12990
+ const [srcStat, dstStat] = await Promise.all([
12991
+ fs$3.stat(srcpath),
12992
+ fs$3.stat(dstpath)
12993
+ ]);
12994
+
12995
+ if (areIdentical(srcStat, dstStat)) return
12996
+ }
12997
+
12998
+ const relative = await symlinkPaths(srcpath, dstpath);
12999
+ srcpath = relative.toDst;
13000
+ const toType = await symlinkType(relative.toCwd, type);
13001
+ const dir = path$3.dirname(dstpath);
13002
+
13003
+ if (!(await pathExists$2(dir))) {
13004
+ await mkdirs(dir);
13005
+ }
13006
+
13007
+ return fs$3.symlink(srcpath, dstpath, toType)
13008
+ }
13009
+
13010
+ function createSymlinkSync$1 (srcpath, dstpath, type) {
13011
+ let stats;
13012
+ try {
13013
+ stats = fs$3.lstatSync(dstpath);
13014
+ } catch { }
13015
+ if (stats && stats.isSymbolicLink()) {
13016
+ const srcStat = fs$3.statSync(srcpath);
13017
+ const dstStat = fs$3.statSync(dstpath);
13018
+ if (areIdentical(srcStat, dstStat)) return
13019
+ }
13020
+
13021
+ const relative = symlinkPathsSync(srcpath, dstpath);
13022
+ srcpath = relative.toDst;
13023
+ type = symlinkTypeSync(relative.toCwd, type);
13024
+ const dir = path$3.dirname(dstpath);
13025
+ const exists = fs$3.existsSync(dir);
13026
+ if (exists) return fs$3.symlinkSync(srcpath, dstpath, type)
13027
+ mkdirsSync(dir);
13028
+ return fs$3.symlinkSync(srcpath, dstpath, type)
13029
+ }
13030
+
13031
+ var symlink = {
13032
+ createSymlink: u$3(createSymlink$1),
13033
+ createSymlinkSync: createSymlinkSync$1
13034
+ };
13035
+
13036
+ const { createFile, createFileSync } = file;
13037
+ const { createLink, createLinkSync } = link;
13038
+ const { createSymlink, createSymlinkSync } = symlink;
13039
+
13040
+ var ensure = {
13041
+ // file
13042
+ createFile,
13043
+ createFileSync,
13044
+ ensureFile: createFile,
13045
+ ensureFileSync: createFileSync,
13046
+ // link
13047
+ createLink,
13048
+ createLinkSync,
13049
+ ensureLink: createLink,
13050
+ ensureLinkSync: createLinkSync,
13051
+ // symlink
13052
+ createSymlink,
13053
+ createSymlinkSync,
13054
+ ensureSymlink: createSymlink,
13055
+ ensureSymlinkSync: createSymlinkSync
13056
+ };
13057
+
13058
+ function stringify$3 (obj, { EOL = '\n', finalEOL = true, replacer = null, spaces } = {}) {
13059
+ const EOF = finalEOL ? EOL : '';
13060
+ const str = JSON.stringify(obj, replacer, spaces);
13061
+
13062
+ return str.replace(/\n/g, EOL) + EOF
13063
+ }
13064
+
13065
+ function stripBom$1 (content) {
13066
+ // we do this because JSON.parse would convert it to a utf8 string if encoding wasn't specified
13067
+ if (Buffer.isBuffer(content)) content = content.toString('utf8');
13068
+ return content.replace(/^\uFEFF/, '')
13069
+ }
13070
+
13071
+ var utils = { stringify: stringify$3, stripBom: stripBom$1 };
13072
+
13073
+ let _fs;
13074
+ try {
13075
+ _fs = gracefulFs;
13076
+ } catch (_) {
13077
+ _fs = require$$0$3;
13078
+ }
13079
+ const universalify = universalify$1;
13080
+ const { stringify: stringify$2, stripBom } = utils;
13081
+
13082
+ async function _readFile (file, options = {}) {
13083
+ if (typeof options === 'string') {
13084
+ options = { encoding: options };
13085
+ }
13086
+
13087
+ const fs = options.fs || _fs;
13088
+
13089
+ const shouldThrow = 'throws' in options ? options.throws : true;
13090
+
13091
+ let data = await universalify.fromCallback(fs.readFile)(file, options);
13092
+
13093
+ data = stripBom(data);
13094
+
13095
+ let obj;
13096
+ try {
13097
+ obj = JSON.parse(data, options ? options.reviver : null);
13098
+ } catch (err) {
13099
+ if (shouldThrow) {
13100
+ err.message = `${file}: ${err.message}`;
13101
+ throw err
13102
+ } else {
13103
+ return null
13104
+ }
13105
+ }
13106
+
13107
+ return obj
13108
+ }
13109
+
13110
+ const readFile = universalify.fromPromise(_readFile);
13111
+
13112
+ function readFileSync (file, options = {}) {
13113
+ if (typeof options === 'string') {
13114
+ options = { encoding: options };
13115
+ }
13116
+
13117
+ const fs = options.fs || _fs;
13118
+
13119
+ const shouldThrow = 'throws' in options ? options.throws : true;
13120
+
13121
+ try {
13122
+ let content = fs.readFileSync(file, options);
13123
+ content = stripBom(content);
13124
+ return JSON.parse(content, options.reviver)
13125
+ } catch (err) {
13126
+ if (shouldThrow) {
13127
+ err.message = `${file}: ${err.message}`;
13128
+ throw err
13129
+ } else {
13130
+ return null
13131
+ }
13132
+ }
13133
+ }
13134
+
13135
+ async function _writeFile (file, obj, options = {}) {
13136
+ const fs = options.fs || _fs;
13137
+
13138
+ const str = stringify$2(obj, options);
13139
+
13140
+ await universalify.fromCallback(fs.writeFile)(file, str, options);
13141
+ }
13142
+
13143
+ const writeFile = universalify.fromPromise(_writeFile);
13144
+
13145
+ function writeFileSync (file, obj, options = {}) {
13146
+ const fs = options.fs || _fs;
13147
+
13148
+ const str = stringify$2(obj, options);
13149
+ // not sure if fs.writeFileSync returns anything, but just in case
13150
+ return fs.writeFileSync(file, str, options)
13151
+ }
13152
+
13153
+ const jsonfile$1 = {
13154
+ readFile,
13155
+ readFileSync,
13156
+ writeFile,
13157
+ writeFileSync
13158
+ };
13159
+
13160
+ var jsonfile_1 = jsonfile$1;
13161
+
13162
+ const jsonFile$1 = jsonfile_1;
13163
+
13164
+ var jsonfile = {
13165
+ // jsonfile exports
13166
+ readJson: jsonFile$1.readFile,
13167
+ readJsonSync: jsonFile$1.readFileSync,
13168
+ writeJson: jsonFile$1.writeFile,
13169
+ writeJsonSync: jsonFile$1.writeFileSync
13170
+ };
13171
+
13172
+ const u$2 = universalify$1.fromPromise;
13173
+ const fs$2 = fs$h;
13174
+ const path$2 = require$$1;
13175
+ const mkdir = mkdirs$2;
13176
+ const pathExists$1 = pathExists_1.pathExists;
13177
+
13178
+ async function outputFile$1 (file, data, encoding = 'utf-8') {
13179
+ const dir = path$2.dirname(file);
13180
+
13181
+ if (!(await pathExists$1(dir))) {
13182
+ await mkdir.mkdirs(dir);
13183
+ }
13184
+
13185
+ return fs$2.writeFile(file, data, encoding)
13186
+ }
13187
+
13188
+ function outputFileSync$1 (file, ...args) {
13189
+ const dir = path$2.dirname(file);
13190
+ if (!fs$2.existsSync(dir)) {
13191
+ mkdir.mkdirsSync(dir);
13192
+ }
13193
+
13194
+ fs$2.writeFileSync(file, ...args);
13195
+ }
13196
+
13197
+ var outputFile_1 = {
13198
+ outputFile: u$2(outputFile$1),
13199
+ outputFileSync: outputFileSync$1
13200
+ };
13201
+
13202
+ const { stringify: stringify$1 } = utils;
13203
+ const { outputFile } = outputFile_1;
13204
+
13205
+ async function outputJson (file, data, options = {}) {
13206
+ const str = stringify$1(data, options);
13207
+
13208
+ await outputFile(file, str, options);
13209
+ }
13210
+
13211
+ var outputJson_1 = outputJson;
13212
+
13213
+ const { stringify } = utils;
13214
+ const { outputFileSync } = outputFile_1;
13215
+
13216
+ function outputJsonSync (file, data, options) {
13217
+ const str = stringify(data, options);
13218
+
13219
+ outputFileSync(file, str, options);
13220
+ }
13221
+
13222
+ var outputJsonSync_1 = outputJsonSync;
13223
+
13224
+ const u$1 = universalify$1.fromPromise;
13225
+ const jsonFile = jsonfile;
13226
+
13227
+ jsonFile.outputJson = u$1(outputJson_1);
13228
+ jsonFile.outputJsonSync = outputJsonSync_1;
13229
+ // aliases
13230
+ jsonFile.outputJSON = jsonFile.outputJson;
13231
+ jsonFile.outputJSONSync = jsonFile.outputJsonSync;
13232
+ jsonFile.writeJSON = jsonFile.writeJson;
13233
+ jsonFile.writeJSONSync = jsonFile.writeJsonSync;
13234
+ jsonFile.readJSON = jsonFile.readJson;
13235
+ jsonFile.readJSONSync = jsonFile.readJsonSync;
13236
+
13237
+ var json = jsonFile;
13238
+
13239
+ const fs$1 = fs$h;
13240
+ const path$1 = require$$1;
13241
+ const { copy } = copy$1;
13242
+ const { remove } = remove_1;
13243
+ const { mkdirp } = mkdirs$2;
13244
+ const { pathExists } = pathExists_1;
13245
+ const stat$1 = stat$4;
13246
+
13247
+ async function move$1 (src, dest, opts = {}) {
13248
+ const overwrite = opts.overwrite || opts.clobber || false;
13249
+
13250
+ const { srcStat, isChangingCase = false } = await stat$1.checkPaths(src, dest, 'move', opts);
13251
+
13252
+ await stat$1.checkParentPaths(src, srcStat, dest, 'move');
13253
+
13254
+ // If the parent of dest is not root, make sure it exists before proceeding
13255
+ const destParent = path$1.dirname(dest);
13256
+ const parsedParentPath = path$1.parse(destParent);
13257
+ if (parsedParentPath.root !== destParent) {
13258
+ await mkdirp(destParent);
13259
+ }
13260
+
13261
+ return doRename$1(src, dest, overwrite, isChangingCase)
13262
+ }
13263
+
13264
+ async function doRename$1 (src, dest, overwrite, isChangingCase) {
13265
+ if (!isChangingCase) {
13266
+ if (overwrite) {
13267
+ await remove(dest);
13268
+ } else if (await pathExists(dest)) {
13269
+ throw new Error('dest already exists.')
13270
+ }
13271
+ }
13272
+
13273
+ try {
13274
+ // Try w/ rename first, and try copy + remove if EXDEV
13275
+ await fs$1.rename(src, dest);
13276
+ } catch (err) {
13277
+ if (err.code !== 'EXDEV') {
13278
+ throw err
13279
+ }
13280
+ await moveAcrossDevice$1(src, dest, overwrite);
13281
+ }
13282
+ }
13283
+
13284
+ async function moveAcrossDevice$1 (src, dest, overwrite) {
13285
+ const opts = {
13286
+ overwrite,
13287
+ errorOnExist: true,
13288
+ preserveTimestamps: true
13289
+ };
13290
+
13291
+ await copy(src, dest, opts);
13292
+ return remove(src)
13293
+ }
13294
+
13295
+ var move_1 = move$1;
13296
+
13297
+ const fs = gracefulFs;
13298
+ const path = require$$1;
13299
+ const copySync = copy$1.copySync;
13300
+ const removeSync = remove_1.removeSync;
13301
+ const mkdirpSync = mkdirs$2.mkdirpSync;
13302
+ const stat = stat$4;
13303
+
13304
+ function moveSync (src, dest, opts) {
13305
+ opts = opts || {};
13306
+ const overwrite = opts.overwrite || opts.clobber || false;
13307
+
13308
+ const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, 'move', opts);
13309
+ stat.checkParentPathsSync(src, srcStat, dest, 'move');
13310
+ if (!isParentRoot(dest)) mkdirpSync(path.dirname(dest));
13311
+ return doRename(src, dest, overwrite, isChangingCase)
13312
+ }
13313
+
13314
+ function isParentRoot (dest) {
13315
+ const parent = path.dirname(dest);
13316
+ const parsedPath = path.parse(parent);
13317
+ return parsedPath.root === parent
13318
+ }
13319
+
13320
+ function doRename (src, dest, overwrite, isChangingCase) {
13321
+ if (isChangingCase) return rename(src, dest, overwrite)
13322
+ if (overwrite) {
13323
+ removeSync(dest);
13324
+ return rename(src, dest, overwrite)
13325
+ }
13326
+ if (fs.existsSync(dest)) throw new Error('dest already exists.')
13327
+ return rename(src, dest, overwrite)
13328
+ }
13329
+
13330
+ function rename (src, dest, overwrite) {
13331
+ try {
13332
+ fs.renameSync(src, dest);
13333
+ } catch (err) {
13334
+ if (err.code !== 'EXDEV') throw err
13335
+ return moveAcrossDevice(src, dest, overwrite)
13336
+ }
13337
+ }
13338
+
13339
+ function moveAcrossDevice (src, dest, overwrite) {
13340
+ const opts = {
13341
+ overwrite,
13342
+ errorOnExist: true,
13343
+ preserveTimestamps: true
13344
+ };
13345
+ copySync(src, dest, opts);
13346
+ return removeSync(src)
13347
+ }
13348
+
13349
+ var moveSync_1 = moveSync;
13350
+
13351
+ const u = universalify$1.fromPromise;
13352
+ var move = {
13353
+ move: u(move_1),
13354
+ moveSync: moveSync_1
13355
+ };
13356
+
13357
+ var lib = {
13358
+ // Export promiseified graceful-fs:
13359
+ ...fs$h,
13360
+ // Export extra methods:
13361
+ ...copy$1,
13362
+ ...empty,
13363
+ ...ensure,
13364
+ ...json,
13365
+ ...mkdirs$2,
13366
+ ...move,
13367
+ ...outputFile_1,
13368
+ ...pathExists_1,
13369
+ ...remove_1
13370
+ };
13371
+
10928
13372
  function pushBits(arr, n, value) {
10929
13373
  for (var bit = 1 << (n - 1); bit; bit = bit >>> 1) {
10930
13374
  arr.push(bit & value ? 1 : 0);
@@ -11811,7 +14255,7 @@ crc32$1.exports = crc32;
11811
14255
 
11812
14256
  var crc32Exports = crc32$1.exports;
11813
14257
 
11814
- var zlib = require$$0$1;
14258
+ var zlib = require$$0$4;
11815
14259
 
11816
14260
  var crc32 = crc32Exports;
11817
14261
 
@@ -12253,6 +14697,13 @@ var qr = {
12253
14697
  svgObject: svg_object
12254
14698
  };
12255
14699
 
14700
+ const emptyDirSessions = async (pathBase) => new Promise((resolve, reject) => {
14701
+ lib.emptyDir(pathBase, (err) => {
14702
+ if (err)
14703
+ reject(err);
14704
+ resolve(true);
14705
+ });
14706
+ });
12256
14707
  const wwebGetChromeExecutablePath = () => {
12257
14708
  const myPlatform = os.platform();
12258
14709
  switch (myPlatform) {
@@ -12272,9 +14723,9 @@ const wwebGetWindowsChromeExecutablePath = () => {
12272
14723
  const programFiles86Path = process.env['ProgramFiles(x86)'] || '';
12273
14724
  const pathProgramFiles86Path = require$$1.join(programFiles86Path, 'Google', 'Chrome', 'Application', 'chrome.exe');
12274
14725
  const pathProgramFiles64Path = require$$1.join(programFilesPath, 'Google', 'Chrome', 'Application', 'chrome.exe');
12275
- if (fs.existsSync(pathProgramFiles86Path))
14726
+ if (require$$0$3.existsSync(pathProgramFiles86Path))
12276
14727
  return pathProgramFiles86Path;
12277
- if (fs.existsSync(pathProgramFiles64Path))
14728
+ if (require$$0$3.existsSync(pathProgramFiles64Path))
12278
14729
  return pathProgramFiles64Path;
12279
14730
  return '';
12280
14731
  };
@@ -12287,7 +14738,7 @@ const wwebGenerateImage = async (base64, name = 'qr.png') => {
12287
14738
  const PATH_QR = `${process.cwd()}/${name}`;
12288
14739
  const qr_svg = qr.image(base64, { type: 'png', margin: 4 });
12289
14740
  const writeFilePromise = () => new Promise((resolve, reject) => {
12290
- const file = qr_svg.pipe(fs.createWriteStream(PATH_QR));
14741
+ const file = qr_svg.pipe(require$$0$3.createWriteStream(PATH_QR));
12291
14742
  file.on('finish', () => resolve(true));
12292
14743
  file.on('error', reject);
12293
14744
  });
@@ -12297,7 +14748,7 @@ const wwebGenerateImage = async (base64, name = 'qr.png') => {
12297
14748
  const wwebDeleteTokens = (session) => {
12298
14749
  try {
12299
14750
  const pathTokens = require$$1.join(process.cwd(), session);
12300
- fs.unlinkSync(pathTokens);
14751
+ emptyDirSessions(pathTokens);
12301
14752
  console.log('Tokens clean..');
12302
14753
  }
12303
14754
  catch (e) {
@@ -12323,7 +14774,7 @@ class WebWhatsappProvider extends bot.ProviderClass {
12323
14774
  this.indexHome = (req, res) => {
12324
14775
  const botName = req[this.idBotName];
12325
14776
  const qrPath = require$$1.join(process.cwd(), `${botName}.qr.png`);
12326
- const fileStream = fs.createReadStream(qrPath);
14777
+ const fileStream = require$$0$3.createReadStream(qrPath);
12327
14778
  res.writeHead(200, { 'Content-Type': 'image/png' });
12328
14779
  fileStream.pipe(res);
12329
14780
  };
@@ -12452,7 +14903,7 @@ class WebWhatsappProvider extends bot.ProviderClass {
12452
14903
  * @returns
12453
14904
  */
12454
14905
  this.sendImage = async (number, filePath, caption) => {
12455
- const base64 = fs.readFileSync(filePath, { encoding: 'base64' });
14906
+ const base64 = require$$0$3.readFileSync(filePath, { encoding: 'base64' });
12456
14907
  const mimeType = mime.lookup(filePath);
12457
14908
  const media = new whatsappWeb_js.MessageMedia(`${mimeType}`, base64);
12458
14909
  return this.vendor.sendMessage(number, media, { caption });
@@ -12465,7 +14916,7 @@ class WebWhatsappProvider extends bot.ProviderClass {
12465
14916
  * @returns
12466
14917
  */
12467
14918
  this.sendAudio = async (number, filePath, caption) => {
12468
- const base64 = fs.readFileSync(filePath, { encoding: 'base64' });
14919
+ const base64 = require$$0$3.readFileSync(filePath, { encoding: 'base64' });
12469
14920
  const mimeType = mime.lookup(filePath);
12470
14921
  const media = new whatsappWeb_js.MessageMedia(`${mimeType}`, base64);
12471
14922
  return this.vendor.sendMessage(number, media, { caption });
@@ -12478,7 +14929,7 @@ class WebWhatsappProvider extends bot.ProviderClass {
12478
14929
  * @returns
12479
14930
  */
12480
14931
  this.sendVideo = async (number, filePath, caption) => {
12481
- const base64 = fs.readFileSync(filePath, { encoding: 'base64' });
14932
+ const base64 = require$$0$3.readFileSync(filePath, { encoding: 'base64' });
12482
14933
  const mimeType = mime.lookup(filePath);
12483
14934
  const media = new whatsappWeb_js.MessageMedia(`${mimeType}`, base64);
12484
14935
  return this.vendor.sendMessage(number, media, {
@@ -12494,7 +14945,7 @@ class WebWhatsappProvider extends bot.ProviderClass {
12494
14945
  * @returns
12495
14946
  */
12496
14947
  this.sendFile = async (number, filePath, caption) => {
12497
- const base64 = fs.readFileSync(filePath, { encoding: 'base64' });
14948
+ const base64 = require$$0$3.readFileSync(filePath, { encoding: 'base64' });
12498
14949
  const mimeType = mime.lookup(filePath);
12499
14950
  const filename = require$$1.basename(filePath);
12500
14951
  const media = new whatsappWeb_js.MessageMedia(`${mimeType}`, base64, filename);