@camstack/system 1.0.4 → 1.0.6

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.
@@ -0,0 +1,1434 @@
1
+ const require_chunk = require("./chunk-Cek0wNdY.js");
2
+ const require_semver = require("./semver-D3n3E_fi.js");
3
+ //#region ../../node_modules/debug/src/common.js
4
+ var require_common = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
5
+ /**
6
+ * This is the common logic for both the Node.js and web browser
7
+ * implementations of `debug()`.
8
+ */
9
+ function setup(env) {
10
+ createDebug.debug = createDebug;
11
+ createDebug.default = createDebug;
12
+ createDebug.coerce = coerce;
13
+ createDebug.disable = disable;
14
+ createDebug.enable = enable;
15
+ createDebug.enabled = enabled;
16
+ createDebug.humanize = require_semver.require_ms();
17
+ createDebug.destroy = destroy;
18
+ Object.keys(env).forEach((key) => {
19
+ createDebug[key] = env[key];
20
+ });
21
+ /**
22
+ * The currently active debug mode names, and names to skip.
23
+ */
24
+ createDebug.names = [];
25
+ createDebug.skips = [];
26
+ /**
27
+ * Map of special "%n" handling functions, for the debug "format" argument.
28
+ *
29
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
30
+ */
31
+ createDebug.formatters = {};
32
+ /**
33
+ * Selects a color for a debug namespace
34
+ * @param {String} namespace The namespace string for the debug instance to be colored
35
+ * @return {Number|String} An ANSI color code for the given namespace
36
+ * @api private
37
+ */
38
+ function selectColor(namespace) {
39
+ let hash = 0;
40
+ for (let i = 0; i < namespace.length; i++) {
41
+ hash = (hash << 5) - hash + namespace.charCodeAt(i);
42
+ hash |= 0;
43
+ }
44
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
45
+ }
46
+ createDebug.selectColor = selectColor;
47
+ /**
48
+ * Create a debugger with the given `namespace`.
49
+ *
50
+ * @param {String} namespace
51
+ * @return {Function}
52
+ * @api public
53
+ */
54
+ function createDebug(namespace) {
55
+ let prevTime;
56
+ let enableOverride = null;
57
+ let namespacesCache;
58
+ let enabledCache;
59
+ function debug(...args) {
60
+ if (!debug.enabled) return;
61
+ const self = debug;
62
+ const curr = Number(/* @__PURE__ */ new Date());
63
+ self.diff = curr - (prevTime || curr);
64
+ self.prev = prevTime;
65
+ self.curr = curr;
66
+ prevTime = curr;
67
+ args[0] = createDebug.coerce(args[0]);
68
+ if (typeof args[0] !== "string") args.unshift("%O");
69
+ let index = 0;
70
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
71
+ if (match === "%%") return "%";
72
+ index++;
73
+ const formatter = createDebug.formatters[format];
74
+ if (typeof formatter === "function") {
75
+ const val = args[index];
76
+ match = formatter.call(self, val);
77
+ args.splice(index, 1);
78
+ index--;
79
+ }
80
+ return match;
81
+ });
82
+ createDebug.formatArgs.call(self, args);
83
+ (self.log || createDebug.log).apply(self, args);
84
+ }
85
+ debug.namespace = namespace;
86
+ debug.useColors = createDebug.useColors();
87
+ debug.color = createDebug.selectColor(namespace);
88
+ debug.extend = extend;
89
+ debug.destroy = createDebug.destroy;
90
+ Object.defineProperty(debug, "enabled", {
91
+ enumerable: true,
92
+ configurable: false,
93
+ get: () => {
94
+ if (enableOverride !== null) return enableOverride;
95
+ if (namespacesCache !== createDebug.namespaces) {
96
+ namespacesCache = createDebug.namespaces;
97
+ enabledCache = createDebug.enabled(namespace);
98
+ }
99
+ return enabledCache;
100
+ },
101
+ set: (v) => {
102
+ enableOverride = v;
103
+ }
104
+ });
105
+ if (typeof createDebug.init === "function") createDebug.init(debug);
106
+ return debug;
107
+ }
108
+ function extend(namespace, delimiter) {
109
+ const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
110
+ newDebug.log = this.log;
111
+ return newDebug;
112
+ }
113
+ /**
114
+ * Enables a debug mode by namespaces. This can include modes
115
+ * separated by a colon and wildcards.
116
+ *
117
+ * @param {String} namespaces
118
+ * @api public
119
+ */
120
+ function enable(namespaces) {
121
+ createDebug.save(namespaces);
122
+ createDebug.namespaces = namespaces;
123
+ createDebug.names = [];
124
+ createDebug.skips = [];
125
+ const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
126
+ for (const ns of split) if (ns[0] === "-") createDebug.skips.push(ns.slice(1));
127
+ else createDebug.names.push(ns);
128
+ }
129
+ /**
130
+ * Checks if the given string matches a namespace template, honoring
131
+ * asterisks as wildcards.
132
+ *
133
+ * @param {String} search
134
+ * @param {String} template
135
+ * @return {Boolean}
136
+ */
137
+ function matchesTemplate(search, template) {
138
+ let searchIndex = 0;
139
+ let templateIndex = 0;
140
+ let starIndex = -1;
141
+ let matchIndex = 0;
142
+ while (searchIndex < search.length) if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) if (template[templateIndex] === "*") {
143
+ starIndex = templateIndex;
144
+ matchIndex = searchIndex;
145
+ templateIndex++;
146
+ } else {
147
+ searchIndex++;
148
+ templateIndex++;
149
+ }
150
+ else if (starIndex !== -1) {
151
+ templateIndex = starIndex + 1;
152
+ matchIndex++;
153
+ searchIndex = matchIndex;
154
+ } else return false;
155
+ while (templateIndex < template.length && template[templateIndex] === "*") templateIndex++;
156
+ return templateIndex === template.length;
157
+ }
158
+ /**
159
+ * Disable debug output.
160
+ *
161
+ * @return {String} namespaces
162
+ * @api public
163
+ */
164
+ function disable() {
165
+ const namespaces = [...createDebug.names, ...createDebug.skips.map((namespace) => "-" + namespace)].join(",");
166
+ createDebug.enable("");
167
+ return namespaces;
168
+ }
169
+ /**
170
+ * Returns true if the given mode name is enabled, false otherwise.
171
+ *
172
+ * @param {String} name
173
+ * @return {Boolean}
174
+ * @api public
175
+ */
176
+ function enabled(name) {
177
+ for (const skip of createDebug.skips) if (matchesTemplate(name, skip)) return false;
178
+ for (const ns of createDebug.names) if (matchesTemplate(name, ns)) return true;
179
+ return false;
180
+ }
181
+ /**
182
+ * Coerce `val`.
183
+ *
184
+ * @param {Mixed} val
185
+ * @return {Mixed}
186
+ * @api private
187
+ */
188
+ function coerce(val) {
189
+ if (val instanceof Error) return val.stack || val.message;
190
+ return val;
191
+ }
192
+ /**
193
+ * XXX DO NOT USE. This is a temporary stub function.
194
+ * XXX It WILL be removed in the next major release.
195
+ */
196
+ function destroy() {
197
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
198
+ }
199
+ createDebug.enable(createDebug.load());
200
+ return createDebug;
201
+ }
202
+ module.exports = setup;
203
+ }));
204
+ //#endregion
205
+ //#region ../../node_modules/debug/src/browser.js
206
+ var require_browser = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
207
+ /**
208
+ * This is the web browser implementation of `debug()`.
209
+ */
210
+ exports.formatArgs = formatArgs;
211
+ exports.save = save;
212
+ exports.load = load;
213
+ exports.useColors = useColors;
214
+ exports.storage = localstorage();
215
+ exports.destroy = (() => {
216
+ let warned = false;
217
+ return () => {
218
+ if (!warned) {
219
+ warned = true;
220
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
221
+ }
222
+ };
223
+ })();
224
+ /**
225
+ * Colors.
226
+ */
227
+ exports.colors = [
228
+ "#0000CC",
229
+ "#0000FF",
230
+ "#0033CC",
231
+ "#0033FF",
232
+ "#0066CC",
233
+ "#0066FF",
234
+ "#0099CC",
235
+ "#0099FF",
236
+ "#00CC00",
237
+ "#00CC33",
238
+ "#00CC66",
239
+ "#00CC99",
240
+ "#00CCCC",
241
+ "#00CCFF",
242
+ "#3300CC",
243
+ "#3300FF",
244
+ "#3333CC",
245
+ "#3333FF",
246
+ "#3366CC",
247
+ "#3366FF",
248
+ "#3399CC",
249
+ "#3399FF",
250
+ "#33CC00",
251
+ "#33CC33",
252
+ "#33CC66",
253
+ "#33CC99",
254
+ "#33CCCC",
255
+ "#33CCFF",
256
+ "#6600CC",
257
+ "#6600FF",
258
+ "#6633CC",
259
+ "#6633FF",
260
+ "#66CC00",
261
+ "#66CC33",
262
+ "#9900CC",
263
+ "#9900FF",
264
+ "#9933CC",
265
+ "#9933FF",
266
+ "#99CC00",
267
+ "#99CC33",
268
+ "#CC0000",
269
+ "#CC0033",
270
+ "#CC0066",
271
+ "#CC0099",
272
+ "#CC00CC",
273
+ "#CC00FF",
274
+ "#CC3300",
275
+ "#CC3333",
276
+ "#CC3366",
277
+ "#CC3399",
278
+ "#CC33CC",
279
+ "#CC33FF",
280
+ "#CC6600",
281
+ "#CC6633",
282
+ "#CC9900",
283
+ "#CC9933",
284
+ "#CCCC00",
285
+ "#CCCC33",
286
+ "#FF0000",
287
+ "#FF0033",
288
+ "#FF0066",
289
+ "#FF0099",
290
+ "#FF00CC",
291
+ "#FF00FF",
292
+ "#FF3300",
293
+ "#FF3333",
294
+ "#FF3366",
295
+ "#FF3399",
296
+ "#FF33CC",
297
+ "#FF33FF",
298
+ "#FF6600",
299
+ "#FF6633",
300
+ "#FF9900",
301
+ "#FF9933",
302
+ "#FFCC00",
303
+ "#FFCC33"
304
+ ];
305
+ /**
306
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
307
+ * and the Firebug extension (any Firefox version) are known
308
+ * to support "%c" CSS customizations.
309
+ *
310
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
311
+ */
312
+ function useColors() {
313
+ if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) return true;
314
+ if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) return false;
315
+ let m;
316
+ return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
317
+ }
318
+ /**
319
+ * Colorize log arguments if enabled.
320
+ *
321
+ * @api public
322
+ */
323
+ function formatArgs(args) {
324
+ args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
325
+ if (!this.useColors) return;
326
+ const c = "color: " + this.color;
327
+ args.splice(1, 0, c, "color: inherit");
328
+ let index = 0;
329
+ let lastC = 0;
330
+ args[0].replace(/%[a-zA-Z%]/g, (match) => {
331
+ if (match === "%%") return;
332
+ index++;
333
+ if (match === "%c") lastC = index;
334
+ });
335
+ args.splice(lastC, 0, c);
336
+ }
337
+ /**
338
+ * Invokes `console.debug()` when available.
339
+ * No-op when `console.debug` is not a "function".
340
+ * If `console.debug` is not available, falls back
341
+ * to `console.log`.
342
+ *
343
+ * @api public
344
+ */
345
+ exports.log = console.debug || console.log || (() => {});
346
+ /**
347
+ * Save `namespaces`.
348
+ *
349
+ * @param {String} namespaces
350
+ * @api private
351
+ */
352
+ function save(namespaces) {
353
+ try {
354
+ if (namespaces) exports.storage.setItem("debug", namespaces);
355
+ else exports.storage.removeItem("debug");
356
+ } catch (error) {}
357
+ }
358
+ /**
359
+ * Load `namespaces`.
360
+ *
361
+ * @return {String} returns the previously persisted debug modes
362
+ * @api private
363
+ */
364
+ function load() {
365
+ let r;
366
+ try {
367
+ r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
368
+ } catch (error) {}
369
+ if (!r && typeof process !== "undefined" && "env" in process) r = process.env.DEBUG;
370
+ return r;
371
+ }
372
+ /**
373
+ * Localstorage attempts to return the localstorage.
374
+ *
375
+ * This is necessary because safari throws
376
+ * when a user disables cookies/localstorage
377
+ * and you attempt to access it.
378
+ *
379
+ * @return {LocalStorage}
380
+ * @api private
381
+ */
382
+ function localstorage() {
383
+ try {
384
+ return localStorage;
385
+ } catch (error) {}
386
+ }
387
+ module.exports = require_common()(exports);
388
+ var { formatters } = module.exports;
389
+ /**
390
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
391
+ */
392
+ formatters.j = function(v) {
393
+ try {
394
+ return JSON.stringify(v);
395
+ } catch (error) {
396
+ return "[UnexpectedJSONParseError]: " + error.message;
397
+ }
398
+ };
399
+ }));
400
+ //#endregion
401
+ //#region ../../node_modules/has-flag/index.js
402
+ var require_has_flag = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
403
+ module.exports = (flag, argv = process.argv) => {
404
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
405
+ const position = argv.indexOf(prefix + flag);
406
+ const terminatorPosition = argv.indexOf("--");
407
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
408
+ };
409
+ }));
410
+ //#endregion
411
+ //#region ../../node_modules/supports-color/index.js
412
+ var require_supports_color = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
413
+ var os = require("os");
414
+ var tty$1 = require("tty");
415
+ var hasFlag = require_has_flag();
416
+ var { env } = process;
417
+ var flagForceColor;
418
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) flagForceColor = 0;
419
+ else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) flagForceColor = 1;
420
+ function envForceColor() {
421
+ if ("FORCE_COLOR" in env) {
422
+ if (env.FORCE_COLOR === "true") return 1;
423
+ if (env.FORCE_COLOR === "false") return 0;
424
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
425
+ }
426
+ }
427
+ function translateLevel(level) {
428
+ if (level === 0) return false;
429
+ return {
430
+ level,
431
+ hasBasic: true,
432
+ has256: level >= 2,
433
+ has16m: level >= 3
434
+ };
435
+ }
436
+ function supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
437
+ const noFlagForceColor = envForceColor();
438
+ if (noFlagForceColor !== void 0) flagForceColor = noFlagForceColor;
439
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
440
+ if (forceColor === 0) return 0;
441
+ if (sniffFlags) {
442
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) return 3;
443
+ if (hasFlag("color=256")) return 2;
444
+ }
445
+ if (haveStream && !streamIsTTY && forceColor === void 0) return 0;
446
+ const min = forceColor || 0;
447
+ if (env.TERM === "dumb") return min;
448
+ if (process.platform === "win32") {
449
+ const osRelease = os.release().split(".");
450
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
451
+ return 1;
452
+ }
453
+ if ("CI" in env) {
454
+ if ([
455
+ "TRAVIS",
456
+ "CIRCLECI",
457
+ "APPVEYOR",
458
+ "GITLAB_CI",
459
+ "GITHUB_ACTIONS",
460
+ "BUILDKITE",
461
+ "DRONE"
462
+ ].some((sign) => sign in env) || env.CI_NAME === "codeship") return 1;
463
+ return min;
464
+ }
465
+ if ("TEAMCITY_VERSION" in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
466
+ if (env.COLORTERM === "truecolor") return 3;
467
+ if ("TERM_PROGRAM" in env) {
468
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
469
+ switch (env.TERM_PROGRAM) {
470
+ case "iTerm.app": return version >= 3 ? 3 : 2;
471
+ case "Apple_Terminal": return 2;
472
+ }
473
+ }
474
+ if (/-256(color)?$/i.test(env.TERM)) return 2;
475
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) return 1;
476
+ if ("COLORTERM" in env) return 1;
477
+ return min;
478
+ }
479
+ function getSupportLevel(stream, options = {}) {
480
+ return translateLevel(supportsColor(stream, {
481
+ streamIsTTY: stream && stream.isTTY,
482
+ ...options
483
+ }));
484
+ }
485
+ module.exports = {
486
+ supportsColor: getSupportLevel,
487
+ stdout: getSupportLevel({ isTTY: tty$1.isatty(1) }),
488
+ stderr: getSupportLevel({ isTTY: tty$1.isatty(2) })
489
+ };
490
+ }));
491
+ //#endregion
492
+ //#region ../../node_modules/debug/src/node.js
493
+ var require_node = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
494
+ /**
495
+ * Module dependencies.
496
+ */
497
+ var tty = require("tty");
498
+ var util$1 = require("util");
499
+ /**
500
+ * This is the Node.js implementation of `debug()`.
501
+ */
502
+ exports.init = init;
503
+ exports.log = log;
504
+ exports.formatArgs = formatArgs;
505
+ exports.save = save;
506
+ exports.load = load;
507
+ exports.useColors = useColors;
508
+ exports.destroy = util$1.deprecate(() => {}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
509
+ /**
510
+ * Colors.
511
+ */
512
+ exports.colors = [
513
+ 6,
514
+ 2,
515
+ 3,
516
+ 4,
517
+ 5,
518
+ 1
519
+ ];
520
+ try {
521
+ const supportsColor = require_supports_color();
522
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) exports.colors = [
523
+ 20,
524
+ 21,
525
+ 26,
526
+ 27,
527
+ 32,
528
+ 33,
529
+ 38,
530
+ 39,
531
+ 40,
532
+ 41,
533
+ 42,
534
+ 43,
535
+ 44,
536
+ 45,
537
+ 56,
538
+ 57,
539
+ 62,
540
+ 63,
541
+ 68,
542
+ 69,
543
+ 74,
544
+ 75,
545
+ 76,
546
+ 77,
547
+ 78,
548
+ 79,
549
+ 80,
550
+ 81,
551
+ 92,
552
+ 93,
553
+ 98,
554
+ 99,
555
+ 112,
556
+ 113,
557
+ 128,
558
+ 129,
559
+ 134,
560
+ 135,
561
+ 148,
562
+ 149,
563
+ 160,
564
+ 161,
565
+ 162,
566
+ 163,
567
+ 164,
568
+ 165,
569
+ 166,
570
+ 167,
571
+ 168,
572
+ 169,
573
+ 170,
574
+ 171,
575
+ 172,
576
+ 173,
577
+ 178,
578
+ 179,
579
+ 184,
580
+ 185,
581
+ 196,
582
+ 197,
583
+ 198,
584
+ 199,
585
+ 200,
586
+ 201,
587
+ 202,
588
+ 203,
589
+ 204,
590
+ 205,
591
+ 206,
592
+ 207,
593
+ 208,
594
+ 209,
595
+ 214,
596
+ 215,
597
+ 220,
598
+ 221
599
+ ];
600
+ } catch (error) {}
601
+ /**
602
+ * Build up the default `inspectOpts` object from the environment variables.
603
+ *
604
+ * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
605
+ */
606
+ exports.inspectOpts = Object.keys(process.env).filter((key) => {
607
+ return /^debug_/i.test(key);
608
+ }).reduce((obj, key) => {
609
+ const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
610
+ return k.toUpperCase();
611
+ });
612
+ let val = process.env[key];
613
+ if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
614
+ else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
615
+ else if (val === "null") val = null;
616
+ else val = Number(val);
617
+ obj[prop] = val;
618
+ return obj;
619
+ }, {});
620
+ /**
621
+ * Is stdout a TTY? Colored output is enabled when `true`.
622
+ */
623
+ function useColors() {
624
+ return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
625
+ }
626
+ /**
627
+ * Adds ANSI color escape codes if enabled.
628
+ *
629
+ * @api public
630
+ */
631
+ function formatArgs(args) {
632
+ const { namespace: name, useColors } = this;
633
+ if (useColors) {
634
+ const c = this.color;
635
+ const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
636
+ const prefix = ` ${colorCode};1m${name} \u001B[0m`;
637
+ args[0] = prefix + args[0].split("\n").join("\n" + prefix);
638
+ args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
639
+ } else args[0] = getDate() + name + " " + args[0];
640
+ }
641
+ function getDate() {
642
+ if (exports.inspectOpts.hideDate) return "";
643
+ return (/* @__PURE__ */ new Date()).toISOString() + " ";
644
+ }
645
+ /**
646
+ * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
647
+ */
648
+ function log(...args) {
649
+ return process.stderr.write(util$1.formatWithOptions(exports.inspectOpts, ...args) + "\n");
650
+ }
651
+ /**
652
+ * Save `namespaces`.
653
+ *
654
+ * @param {String} namespaces
655
+ * @api private
656
+ */
657
+ function save(namespaces) {
658
+ if (namespaces) process.env.DEBUG = namespaces;
659
+ else delete process.env.DEBUG;
660
+ }
661
+ /**
662
+ * Load `namespaces`.
663
+ *
664
+ * @return {String} returns the previously persisted debug modes
665
+ * @api private
666
+ */
667
+ function load() {
668
+ return process.env.DEBUG;
669
+ }
670
+ /**
671
+ * Init logic for `debug` instances.
672
+ *
673
+ * Create a new `inspectOpts` object in case `useColors` is set
674
+ * differently for a particular `debug` instance.
675
+ */
676
+ function init(debug) {
677
+ debug.inspectOpts = {};
678
+ const keys = Object.keys(exports.inspectOpts);
679
+ for (let i = 0; i < keys.length; i++) debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
680
+ }
681
+ module.exports = require_common()(exports);
682
+ var { formatters } = module.exports;
683
+ /**
684
+ * Map %o to `util.inspect()`, all on a single line.
685
+ */
686
+ formatters.o = function(v) {
687
+ this.inspectOpts.colors = this.useColors;
688
+ return util$1.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
689
+ };
690
+ /**
691
+ * Map %O to `util.inspect()`, allowing multiple lines if needed.
692
+ */
693
+ formatters.O = function(v) {
694
+ this.inspectOpts.colors = this.useColors;
695
+ return util$1.inspect(v, this.inspectOpts);
696
+ };
697
+ }));
698
+ //#endregion
699
+ //#region ../../node_modules/debug/src/index.js
700
+ var require_src = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
701
+ /**
702
+ * Detect Electron renderer / nwjs process, which is node, but we should
703
+ * treat as a browser.
704
+ */
705
+ if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) module.exports = require_browser();
706
+ else module.exports = require_node();
707
+ }));
708
+ //#endregion
709
+ //#region ../../node_modules/graceful-fs/polyfills.js
710
+ var require_polyfills = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
711
+ var constants = require("constants");
712
+ var origCwd = process.cwd;
713
+ var cwd = null;
714
+ var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
715
+ process.cwd = function() {
716
+ if (!cwd) cwd = origCwd.call(process);
717
+ return cwd;
718
+ };
719
+ try {
720
+ process.cwd();
721
+ } catch (er) {}
722
+ if (typeof process.chdir === "function") {
723
+ var chdir = process.chdir;
724
+ process.chdir = function(d) {
725
+ cwd = null;
726
+ chdir.call(process, d);
727
+ };
728
+ if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
729
+ }
730
+ module.exports = patch;
731
+ function patch(fs) {
732
+ if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) patchLchmod(fs);
733
+ if (!fs.lutimes) patchLutimes(fs);
734
+ fs.chown = chownFix(fs.chown);
735
+ fs.fchown = chownFix(fs.fchown);
736
+ fs.lchown = chownFix(fs.lchown);
737
+ fs.chmod = chmodFix(fs.chmod);
738
+ fs.fchmod = chmodFix(fs.fchmod);
739
+ fs.lchmod = chmodFix(fs.lchmod);
740
+ fs.chownSync = chownFixSync(fs.chownSync);
741
+ fs.fchownSync = chownFixSync(fs.fchownSync);
742
+ fs.lchownSync = chownFixSync(fs.lchownSync);
743
+ fs.chmodSync = chmodFixSync(fs.chmodSync);
744
+ fs.fchmodSync = chmodFixSync(fs.fchmodSync);
745
+ fs.lchmodSync = chmodFixSync(fs.lchmodSync);
746
+ fs.stat = statFix(fs.stat);
747
+ fs.fstat = statFix(fs.fstat);
748
+ fs.lstat = statFix(fs.lstat);
749
+ fs.statSync = statFixSync(fs.statSync);
750
+ fs.fstatSync = statFixSync(fs.fstatSync);
751
+ fs.lstatSync = statFixSync(fs.lstatSync);
752
+ if (fs.chmod && !fs.lchmod) {
753
+ fs.lchmod = function(path, mode, cb) {
754
+ if (cb) process.nextTick(cb);
755
+ };
756
+ fs.lchmodSync = function() {};
757
+ }
758
+ if (fs.chown && !fs.lchown) {
759
+ fs.lchown = function(path, uid, gid, cb) {
760
+ if (cb) process.nextTick(cb);
761
+ };
762
+ fs.lchownSync = function() {};
763
+ }
764
+ if (platform === "win32") fs.rename = typeof fs.rename !== "function" ? fs.rename : (function(fs$rename) {
765
+ function rename(from, to, cb) {
766
+ var start = Date.now();
767
+ var backoff = 0;
768
+ fs$rename(from, to, function CB(er) {
769
+ if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
770
+ setTimeout(function() {
771
+ fs.stat(to, function(stater, st) {
772
+ if (stater && stater.code === "ENOENT") fs$rename(from, to, CB);
773
+ else cb(er);
774
+ });
775
+ }, backoff);
776
+ if (backoff < 100) backoff += 10;
777
+ return;
778
+ }
779
+ if (cb) cb(er);
780
+ });
781
+ }
782
+ if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
783
+ return rename;
784
+ })(fs.rename);
785
+ fs.read = typeof fs.read !== "function" ? fs.read : (function(fs$read) {
786
+ function read(fd, buffer, offset, length, position, callback_) {
787
+ var callback;
788
+ if (callback_ && typeof callback_ === "function") {
789
+ var eagCounter = 0;
790
+ callback = function(er, _, __) {
791
+ if (er && er.code === "EAGAIN" && eagCounter < 10) {
792
+ eagCounter++;
793
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback);
794
+ }
795
+ callback_.apply(this, arguments);
796
+ };
797
+ }
798
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback);
799
+ }
800
+ if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
801
+ return read;
802
+ })(fs.read);
803
+ fs.readSync = typeof fs.readSync !== "function" ? fs.readSync : (function(fs$readSync) {
804
+ return function(fd, buffer, offset, length, position) {
805
+ var eagCounter = 0;
806
+ while (true) try {
807
+ return fs$readSync.call(fs, fd, buffer, offset, length, position);
808
+ } catch (er) {
809
+ if (er.code === "EAGAIN" && eagCounter < 10) {
810
+ eagCounter++;
811
+ continue;
812
+ }
813
+ throw er;
814
+ }
815
+ };
816
+ })(fs.readSync);
817
+ function patchLchmod(fs) {
818
+ fs.lchmod = function(path, mode, callback) {
819
+ fs.open(path, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
820
+ if (err) {
821
+ if (callback) callback(err);
822
+ return;
823
+ }
824
+ fs.fchmod(fd, mode, function(err) {
825
+ fs.close(fd, function(err2) {
826
+ if (callback) callback(err || err2);
827
+ });
828
+ });
829
+ });
830
+ };
831
+ fs.lchmodSync = function(path, mode) {
832
+ var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
833
+ var threw = true;
834
+ var ret;
835
+ try {
836
+ ret = fs.fchmodSync(fd, mode);
837
+ threw = false;
838
+ } finally {
839
+ if (threw) try {
840
+ fs.closeSync(fd);
841
+ } catch (er) {}
842
+ else fs.closeSync(fd);
843
+ }
844
+ return ret;
845
+ };
846
+ }
847
+ function patchLutimes(fs) {
848
+ if (constants.hasOwnProperty("O_SYMLINK") && fs.futimes) {
849
+ fs.lutimes = function(path, at, mt, cb) {
850
+ fs.open(path, constants.O_SYMLINK, function(er, fd) {
851
+ if (er) {
852
+ if (cb) cb(er);
853
+ return;
854
+ }
855
+ fs.futimes(fd, at, mt, function(er) {
856
+ fs.close(fd, function(er2) {
857
+ if (cb) cb(er || er2);
858
+ });
859
+ });
860
+ });
861
+ };
862
+ fs.lutimesSync = function(path, at, mt) {
863
+ var fd = fs.openSync(path, constants.O_SYMLINK);
864
+ var ret;
865
+ var threw = true;
866
+ try {
867
+ ret = fs.futimesSync(fd, at, mt);
868
+ threw = false;
869
+ } finally {
870
+ if (threw) try {
871
+ fs.closeSync(fd);
872
+ } catch (er) {}
873
+ else fs.closeSync(fd);
874
+ }
875
+ return ret;
876
+ };
877
+ } else if (fs.futimes) {
878
+ fs.lutimes = function(_a, _b, _c, cb) {
879
+ if (cb) process.nextTick(cb);
880
+ };
881
+ fs.lutimesSync = function() {};
882
+ }
883
+ }
884
+ function chmodFix(orig) {
885
+ if (!orig) return orig;
886
+ return function(target, mode, cb) {
887
+ return orig.call(fs, target, mode, function(er) {
888
+ if (chownErOk(er)) er = null;
889
+ if (cb) cb.apply(this, arguments);
890
+ });
891
+ };
892
+ }
893
+ function chmodFixSync(orig) {
894
+ if (!orig) return orig;
895
+ return function(target, mode) {
896
+ try {
897
+ return orig.call(fs, target, mode);
898
+ } catch (er) {
899
+ if (!chownErOk(er)) throw er;
900
+ }
901
+ };
902
+ }
903
+ function chownFix(orig) {
904
+ if (!orig) return orig;
905
+ return function(target, uid, gid, cb) {
906
+ return orig.call(fs, target, uid, gid, function(er) {
907
+ if (chownErOk(er)) er = null;
908
+ if (cb) cb.apply(this, arguments);
909
+ });
910
+ };
911
+ }
912
+ function chownFixSync(orig) {
913
+ if (!orig) return orig;
914
+ return function(target, uid, gid) {
915
+ try {
916
+ return orig.call(fs, target, uid, gid);
917
+ } catch (er) {
918
+ if (!chownErOk(er)) throw er;
919
+ }
920
+ };
921
+ }
922
+ function statFix(orig) {
923
+ if (!orig) return orig;
924
+ return function(target, options, cb) {
925
+ if (typeof options === "function") {
926
+ cb = options;
927
+ options = null;
928
+ }
929
+ function callback(er, stats) {
930
+ if (stats) {
931
+ if (stats.uid < 0) stats.uid += 4294967296;
932
+ if (stats.gid < 0) stats.gid += 4294967296;
933
+ }
934
+ if (cb) cb.apply(this, arguments);
935
+ }
936
+ return options ? orig.call(fs, target, options, callback) : orig.call(fs, target, callback);
937
+ };
938
+ }
939
+ function statFixSync(orig) {
940
+ if (!orig) return orig;
941
+ return function(target, options) {
942
+ var stats = options ? orig.call(fs, target, options) : orig.call(fs, target);
943
+ if (stats) {
944
+ if (stats.uid < 0) stats.uid += 4294967296;
945
+ if (stats.gid < 0) stats.gid += 4294967296;
946
+ }
947
+ return stats;
948
+ };
949
+ }
950
+ function chownErOk(er) {
951
+ if (!er) return true;
952
+ if (er.code === "ENOSYS") return true;
953
+ if (!process.getuid || process.getuid() !== 0) {
954
+ if (er.code === "EINVAL" || er.code === "EPERM") return true;
955
+ }
956
+ return false;
957
+ }
958
+ }
959
+ }));
960
+ //#endregion
961
+ //#region ../../node_modules/graceful-fs/legacy-streams.js
962
+ var require_legacy_streams = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
963
+ var Stream = require("stream").Stream;
964
+ module.exports = legacy;
965
+ function legacy(fs) {
966
+ return {
967
+ ReadStream,
968
+ WriteStream
969
+ };
970
+ function ReadStream(path, options) {
971
+ if (!(this instanceof ReadStream)) return new ReadStream(path, options);
972
+ Stream.call(this);
973
+ var self = this;
974
+ this.path = path;
975
+ this.fd = null;
976
+ this.readable = true;
977
+ this.paused = false;
978
+ this.flags = "r";
979
+ this.mode = 438;
980
+ this.bufferSize = 64 * 1024;
981
+ options = options || {};
982
+ var keys = Object.keys(options);
983
+ for (var index = 0, length = keys.length; index < length; index++) {
984
+ var key = keys[index];
985
+ this[key] = options[key];
986
+ }
987
+ if (this.encoding) this.setEncoding(this.encoding);
988
+ if (this.start !== void 0) {
989
+ if ("number" !== typeof this.start) throw TypeError("start must be a Number");
990
+ if (this.end === void 0) this.end = Infinity;
991
+ else if ("number" !== typeof this.end) throw TypeError("end must be a Number");
992
+ if (this.start > this.end) throw new Error("start must be <= end");
993
+ this.pos = this.start;
994
+ }
995
+ if (this.fd !== null) {
996
+ process.nextTick(function() {
997
+ self._read();
998
+ });
999
+ return;
1000
+ }
1001
+ fs.open(this.path, this.flags, this.mode, function(err, fd) {
1002
+ if (err) {
1003
+ self.emit("error", err);
1004
+ self.readable = false;
1005
+ return;
1006
+ }
1007
+ self.fd = fd;
1008
+ self.emit("open", fd);
1009
+ self._read();
1010
+ });
1011
+ }
1012
+ function WriteStream(path, options) {
1013
+ if (!(this instanceof WriteStream)) return new WriteStream(path, options);
1014
+ Stream.call(this);
1015
+ this.path = path;
1016
+ this.fd = null;
1017
+ this.writable = true;
1018
+ this.flags = "w";
1019
+ this.encoding = "binary";
1020
+ this.mode = 438;
1021
+ this.bytesWritten = 0;
1022
+ options = options || {};
1023
+ var keys = Object.keys(options);
1024
+ for (var index = 0, length = keys.length; index < length; index++) {
1025
+ var key = keys[index];
1026
+ this[key] = options[key];
1027
+ }
1028
+ if (this.start !== void 0) {
1029
+ if ("number" !== typeof this.start) throw TypeError("start must be a Number");
1030
+ if (this.start < 0) throw new Error("start must be >= zero");
1031
+ this.pos = this.start;
1032
+ }
1033
+ this.busy = false;
1034
+ this._queue = [];
1035
+ if (this.fd === null) {
1036
+ this._open = fs.open;
1037
+ this._queue.push([
1038
+ this._open,
1039
+ this.path,
1040
+ this.flags,
1041
+ this.mode,
1042
+ void 0
1043
+ ]);
1044
+ this.flush();
1045
+ }
1046
+ }
1047
+ }
1048
+ }));
1049
+ //#endregion
1050
+ //#region ../../node_modules/graceful-fs/clone.js
1051
+ var require_clone = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
1052
+ module.exports = clone;
1053
+ var getPrototypeOf = Object.getPrototypeOf || function(obj) {
1054
+ return obj.__proto__;
1055
+ };
1056
+ function clone(obj) {
1057
+ if (obj === null || typeof obj !== "object") return obj;
1058
+ if (obj instanceof Object) var copy = { __proto__: getPrototypeOf(obj) };
1059
+ else var copy = Object.create(null);
1060
+ Object.getOwnPropertyNames(obj).forEach(function(key) {
1061
+ Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
1062
+ });
1063
+ return copy;
1064
+ }
1065
+ }));
1066
+ //#endregion
1067
+ //#region ../../node_modules/graceful-fs/graceful-fs.js
1068
+ var require_graceful_fs = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
1069
+ var fs = require("fs");
1070
+ var polyfills = require_polyfills();
1071
+ var legacy = require_legacy_streams();
1072
+ var clone = require_clone();
1073
+ var util = require("util");
1074
+ /* istanbul ignore next - node 0.x polyfill */
1075
+ var gracefulQueue;
1076
+ var previousSymbol;
1077
+ /* istanbul ignore else - node 0.x polyfill */
1078
+ if (typeof Symbol === "function" && typeof Symbol.for === "function") {
1079
+ gracefulQueue = Symbol.for("graceful-fs.queue");
1080
+ previousSymbol = Symbol.for("graceful-fs.previous");
1081
+ } else {
1082
+ gracefulQueue = "___graceful-fs.queue";
1083
+ previousSymbol = "___graceful-fs.previous";
1084
+ }
1085
+ function noop() {}
1086
+ function publishQueue(context, queue) {
1087
+ Object.defineProperty(context, gracefulQueue, { get: function() {
1088
+ return queue;
1089
+ } });
1090
+ }
1091
+ var debug = noop;
1092
+ if (util.debuglog) debug = util.debuglog("gfs4");
1093
+ else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) debug = function() {
1094
+ var m = util.format.apply(util, arguments);
1095
+ m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
1096
+ console.error(m);
1097
+ };
1098
+ if (!fs[gracefulQueue]) {
1099
+ publishQueue(fs, global[gracefulQueue] || []);
1100
+ fs.close = (function(fs$close) {
1101
+ function close(fd, cb) {
1102
+ return fs$close.call(fs, fd, function(err) {
1103
+ if (!err) resetQueue();
1104
+ if (typeof cb === "function") cb.apply(this, arguments);
1105
+ });
1106
+ }
1107
+ Object.defineProperty(close, previousSymbol, { value: fs$close });
1108
+ return close;
1109
+ })(fs.close);
1110
+ fs.closeSync = (function(fs$closeSync) {
1111
+ function closeSync(fd) {
1112
+ fs$closeSync.apply(fs, arguments);
1113
+ resetQueue();
1114
+ }
1115
+ Object.defineProperty(closeSync, previousSymbol, { value: fs$closeSync });
1116
+ return closeSync;
1117
+ })(fs.closeSync);
1118
+ if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) process.on("exit", function() {
1119
+ debug(fs[gracefulQueue]);
1120
+ require("assert").equal(fs[gracefulQueue].length, 0);
1121
+ });
1122
+ }
1123
+ if (!global[gracefulQueue]) publishQueue(global, fs[gracefulQueue]);
1124
+ module.exports = patch(clone(fs));
1125
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
1126
+ module.exports = patch(fs);
1127
+ fs.__patched = true;
1128
+ }
1129
+ function patch(fs) {
1130
+ polyfills(fs);
1131
+ fs.gracefulify = patch;
1132
+ fs.createReadStream = createReadStream;
1133
+ fs.createWriteStream = createWriteStream;
1134
+ var fs$readFile = fs.readFile;
1135
+ fs.readFile = readFile;
1136
+ function readFile(path, options, cb) {
1137
+ if (typeof options === "function") cb = options, options = null;
1138
+ return go$readFile(path, options, cb);
1139
+ function go$readFile(path, options, cb, startTime) {
1140
+ return fs$readFile(path, options, function(err) {
1141
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
1142
+ go$readFile,
1143
+ [
1144
+ path,
1145
+ options,
1146
+ cb
1147
+ ],
1148
+ err,
1149
+ startTime || Date.now(),
1150
+ Date.now()
1151
+ ]);
1152
+ else if (typeof cb === "function") cb.apply(this, arguments);
1153
+ });
1154
+ }
1155
+ }
1156
+ var fs$writeFile = fs.writeFile;
1157
+ fs.writeFile = writeFile;
1158
+ function writeFile(path, data, options, cb) {
1159
+ if (typeof options === "function") cb = options, options = null;
1160
+ return go$writeFile(path, data, options, cb);
1161
+ function go$writeFile(path, data, options, cb, startTime) {
1162
+ return fs$writeFile(path, data, options, function(err) {
1163
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
1164
+ go$writeFile,
1165
+ [
1166
+ path,
1167
+ data,
1168
+ options,
1169
+ cb
1170
+ ],
1171
+ err,
1172
+ startTime || Date.now(),
1173
+ Date.now()
1174
+ ]);
1175
+ else if (typeof cb === "function") cb.apply(this, arguments);
1176
+ });
1177
+ }
1178
+ }
1179
+ var fs$appendFile = fs.appendFile;
1180
+ if (fs$appendFile) fs.appendFile = appendFile;
1181
+ function appendFile(path, data, options, cb) {
1182
+ if (typeof options === "function") cb = options, options = null;
1183
+ return go$appendFile(path, data, options, cb);
1184
+ function go$appendFile(path, data, options, cb, startTime) {
1185
+ return fs$appendFile(path, data, options, function(err) {
1186
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
1187
+ go$appendFile,
1188
+ [
1189
+ path,
1190
+ data,
1191
+ options,
1192
+ cb
1193
+ ],
1194
+ err,
1195
+ startTime || Date.now(),
1196
+ Date.now()
1197
+ ]);
1198
+ else if (typeof cb === "function") cb.apply(this, arguments);
1199
+ });
1200
+ }
1201
+ }
1202
+ var fs$copyFile = fs.copyFile;
1203
+ if (fs$copyFile) fs.copyFile = copyFile;
1204
+ function copyFile(src, dest, flags, cb) {
1205
+ if (typeof flags === "function") {
1206
+ cb = flags;
1207
+ flags = 0;
1208
+ }
1209
+ return go$copyFile(src, dest, flags, cb);
1210
+ function go$copyFile(src, dest, flags, cb, startTime) {
1211
+ return fs$copyFile(src, dest, flags, function(err) {
1212
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
1213
+ go$copyFile,
1214
+ [
1215
+ src,
1216
+ dest,
1217
+ flags,
1218
+ cb
1219
+ ],
1220
+ err,
1221
+ startTime || Date.now(),
1222
+ Date.now()
1223
+ ]);
1224
+ else if (typeof cb === "function") cb.apply(this, arguments);
1225
+ });
1226
+ }
1227
+ }
1228
+ var fs$readdir = fs.readdir;
1229
+ fs.readdir = readdir;
1230
+ var noReaddirOptionVersions = /^v[0-5]\./;
1231
+ function readdir(path, options, cb) {
1232
+ if (typeof options === "function") cb = options, options = null;
1233
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir(path, options, cb, startTime) {
1234
+ return fs$readdir(path, fs$readdirCallback(path, options, cb, startTime));
1235
+ } : function go$readdir(path, options, cb, startTime) {
1236
+ return fs$readdir(path, options, fs$readdirCallback(path, options, cb, startTime));
1237
+ };
1238
+ return go$readdir(path, options, cb);
1239
+ function fs$readdirCallback(path, options, cb, startTime) {
1240
+ return function(err, files) {
1241
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
1242
+ go$readdir,
1243
+ [
1244
+ path,
1245
+ options,
1246
+ cb
1247
+ ],
1248
+ err,
1249
+ startTime || Date.now(),
1250
+ Date.now()
1251
+ ]);
1252
+ else {
1253
+ if (files && files.sort) files.sort();
1254
+ if (typeof cb === "function") cb.call(this, err, files);
1255
+ }
1256
+ };
1257
+ }
1258
+ }
1259
+ if (process.version.substr(0, 4) === "v0.8") {
1260
+ var legStreams = legacy(fs);
1261
+ ReadStream = legStreams.ReadStream;
1262
+ WriteStream = legStreams.WriteStream;
1263
+ }
1264
+ var fs$ReadStream = fs.ReadStream;
1265
+ if (fs$ReadStream) {
1266
+ ReadStream.prototype = Object.create(fs$ReadStream.prototype);
1267
+ ReadStream.prototype.open = ReadStream$open;
1268
+ }
1269
+ var fs$WriteStream = fs.WriteStream;
1270
+ if (fs$WriteStream) {
1271
+ WriteStream.prototype = Object.create(fs$WriteStream.prototype);
1272
+ WriteStream.prototype.open = WriteStream$open;
1273
+ }
1274
+ Object.defineProperty(fs, "ReadStream", {
1275
+ get: function() {
1276
+ return ReadStream;
1277
+ },
1278
+ set: function(val) {
1279
+ ReadStream = val;
1280
+ },
1281
+ enumerable: true,
1282
+ configurable: true
1283
+ });
1284
+ Object.defineProperty(fs, "WriteStream", {
1285
+ get: function() {
1286
+ return WriteStream;
1287
+ },
1288
+ set: function(val) {
1289
+ WriteStream = val;
1290
+ },
1291
+ enumerable: true,
1292
+ configurable: true
1293
+ });
1294
+ var FileReadStream = ReadStream;
1295
+ Object.defineProperty(fs, "FileReadStream", {
1296
+ get: function() {
1297
+ return FileReadStream;
1298
+ },
1299
+ set: function(val) {
1300
+ FileReadStream = val;
1301
+ },
1302
+ enumerable: true,
1303
+ configurable: true
1304
+ });
1305
+ var FileWriteStream = WriteStream;
1306
+ Object.defineProperty(fs, "FileWriteStream", {
1307
+ get: function() {
1308
+ return FileWriteStream;
1309
+ },
1310
+ set: function(val) {
1311
+ FileWriteStream = val;
1312
+ },
1313
+ enumerable: true,
1314
+ configurable: true
1315
+ });
1316
+ function ReadStream(path, options) {
1317
+ if (this instanceof ReadStream) return fs$ReadStream.apply(this, arguments), this;
1318
+ else return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
1319
+ }
1320
+ function ReadStream$open() {
1321
+ var that = this;
1322
+ open(that.path, that.flags, that.mode, function(err, fd) {
1323
+ if (err) {
1324
+ if (that.autoClose) that.destroy();
1325
+ that.emit("error", err);
1326
+ } else {
1327
+ that.fd = fd;
1328
+ that.emit("open", fd);
1329
+ that.read();
1330
+ }
1331
+ });
1332
+ }
1333
+ function WriteStream(path, options) {
1334
+ if (this instanceof WriteStream) return fs$WriteStream.apply(this, arguments), this;
1335
+ else return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
1336
+ }
1337
+ function WriteStream$open() {
1338
+ var that = this;
1339
+ open(that.path, that.flags, that.mode, function(err, fd) {
1340
+ if (err) {
1341
+ that.destroy();
1342
+ that.emit("error", err);
1343
+ } else {
1344
+ that.fd = fd;
1345
+ that.emit("open", fd);
1346
+ }
1347
+ });
1348
+ }
1349
+ function createReadStream(path, options) {
1350
+ return new fs.ReadStream(path, options);
1351
+ }
1352
+ function createWriteStream(path, options) {
1353
+ return new fs.WriteStream(path, options);
1354
+ }
1355
+ var fs$open = fs.open;
1356
+ fs.open = open;
1357
+ function open(path, flags, mode, cb) {
1358
+ if (typeof mode === "function") cb = mode, mode = null;
1359
+ return go$open(path, flags, mode, cb);
1360
+ function go$open(path, flags, mode, cb, startTime) {
1361
+ return fs$open(path, flags, mode, function(err, fd) {
1362
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
1363
+ go$open,
1364
+ [
1365
+ path,
1366
+ flags,
1367
+ mode,
1368
+ cb
1369
+ ],
1370
+ err,
1371
+ startTime || Date.now(),
1372
+ Date.now()
1373
+ ]);
1374
+ else if (typeof cb === "function") cb.apply(this, arguments);
1375
+ });
1376
+ }
1377
+ }
1378
+ return fs;
1379
+ }
1380
+ function enqueue(elem) {
1381
+ debug("ENQUEUE", elem[0].name, elem[1]);
1382
+ fs[gracefulQueue].push(elem);
1383
+ retry();
1384
+ }
1385
+ var retryTimer;
1386
+ function resetQueue() {
1387
+ var now = Date.now();
1388
+ for (var i = 0; i < fs[gracefulQueue].length; ++i) if (fs[gracefulQueue][i].length > 2) {
1389
+ fs[gracefulQueue][i][3] = now;
1390
+ fs[gracefulQueue][i][4] = now;
1391
+ }
1392
+ retry();
1393
+ }
1394
+ function retry() {
1395
+ clearTimeout(retryTimer);
1396
+ retryTimer = void 0;
1397
+ if (fs[gracefulQueue].length === 0) return;
1398
+ var elem = fs[gracefulQueue].shift();
1399
+ var fn = elem[0];
1400
+ var args = elem[1];
1401
+ var err = elem[2];
1402
+ var startTime = elem[3];
1403
+ var lastTime = elem[4];
1404
+ if (startTime === void 0) {
1405
+ debug("RETRY", fn.name, args);
1406
+ fn.apply(null, args);
1407
+ } else if (Date.now() - startTime >= 6e4) {
1408
+ debug("TIMEOUT", fn.name, args);
1409
+ var cb = args.pop();
1410
+ if (typeof cb === "function") cb.call(null, err);
1411
+ } else {
1412
+ var sinceAttempt = Date.now() - lastTime;
1413
+ var sinceStart = Math.max(lastTime - startTime, 1);
1414
+ if (sinceAttempt >= Math.min(sinceStart * 1.2, 100)) {
1415
+ debug("RETRY", fn.name, args);
1416
+ fn.apply(null, args.concat([startTime]));
1417
+ } else fs[gracefulQueue].push(elem);
1418
+ }
1419
+ if (retryTimer === void 0) retryTimer = setTimeout(retry, 0);
1420
+ }
1421
+ }));
1422
+ //#endregion
1423
+ Object.defineProperty(exports, "require_graceful_fs", {
1424
+ enumerable: true,
1425
+ get: function() {
1426
+ return require_graceful_fs;
1427
+ }
1428
+ });
1429
+ Object.defineProperty(exports, "require_src", {
1430
+ enumerable: true,
1431
+ get: function() {
1432
+ return require_src;
1433
+ }
1434
+ });