@storybook/builder-vite 10.2.0-alpha.1 → 10.2.0-alpha.2
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.
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_ju9fqam8r2 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ju9fqam8r2 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ju9fqam8r2 from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ju9fqam8r2.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ju9fqam8r2.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ju9fqam8r2.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -32,7 +32,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
32
32
|
mod
|
|
33
33
|
));
|
|
34
34
|
|
|
35
|
-
//
|
|
35
|
+
// ../../../node_modules/pathe/dist/shared/pathe.ff20891b.mjs
|
|
36
36
|
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
37
37
|
function normalizeWindowsPath(input = "") {
|
|
38
38
|
return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_ju9fqam8r2 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ju9fqam8r2 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ju9fqam8r2 from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ju9fqam8r2.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ju9fqam8r2.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ju9fqam8r2.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -16,11 +16,11 @@ import {
|
|
|
16
16
|
normalize,
|
|
17
17
|
relative,
|
|
18
18
|
resolve
|
|
19
|
-
} from "./_node-chunks/chunk-
|
|
19
|
+
} from "./_node-chunks/chunk-33HTNIVD.js";
|
|
20
20
|
|
|
21
|
-
//
|
|
21
|
+
// ../../../node_modules/picocolors/picocolors.js
|
|
22
22
|
var require_picocolors = __commonJS({
|
|
23
|
-
"
|
|
23
|
+
"../../../node_modules/picocolors/picocolors.js"(exports, module) {
|
|
24
24
|
var p = process || {}, argv = p.argv || [], env2 = p.env || {}, isColorSupported = !(env2.NO_COLOR || argv.includes("--no-color")) && (!!env2.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env2.TERM !== "dumb" || !!env2.CI), formatter = (open, close, replace = open) => (input) => {
|
|
25
25
|
let string = "" + input, index = string.indexOf(close, open.length);
|
|
26
26
|
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
@@ -82,9 +82,9 @@ var require_picocolors = __commonJS({
|
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
-
//
|
|
85
|
+
// ../../../node_modules/balanced-match/index.js
|
|
86
86
|
var require_balanced_match = __commonJS({
|
|
87
|
-
"
|
|
87
|
+
"../../../node_modules/balanced-match/index.js"(exports, module) {
|
|
88
88
|
"use strict";
|
|
89
89
|
module.exports = balanced;
|
|
90
90
|
function balanced(a, b, str) {
|
|
@@ -117,9 +117,9 @@ var require_balanced_match = __commonJS({
|
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
-
//
|
|
120
|
+
// ../../../node_modules/brace-expansion/index.js
|
|
121
121
|
var require_brace_expansion = __commonJS({
|
|
122
|
-
"
|
|
122
|
+
"../../../node_modules/brace-expansion/index.js"(exports, module) {
|
|
123
123
|
var balanced = require_balanced_match();
|
|
124
124
|
module.exports = expandTop;
|
|
125
125
|
var escSlash = "\0SLASH" + Math.random() + "\0", escOpen = "\0OPEN" + Math.random() + "\0", escClose = "\0CLOSE" + Math.random() + "\0", escComma = "\0COMMA" + Math.random() + "\0", escPeriod = "\0PERIOD" + Math.random() + "\0";
|
|
@@ -170,7 +170,7 @@ var require_brace_expansion = __commonJS({
|
|
|
170
170
|
else {
|
|
171
171
|
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body), isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body), isSequence = isNumericSequence || isAlphaSequence, isOptions = m.body.indexOf(",") >= 0;
|
|
172
172
|
if (!isSequence && !isOptions)
|
|
173
|
-
return m.post.match(
|
|
173
|
+
return m.post.match(/,.*\}/) ? (str = m.pre + "{" + m.body + escClose + m.post, expand2(str)) : [str];
|
|
174
174
|
var n2;
|
|
175
175
|
if (isSequence)
|
|
176
176
|
n2 = m.body.split(/\.\./);
|
|
@@ -293,7 +293,7 @@ import {
|
|
|
293
293
|
} from "storybook/internal/common";
|
|
294
294
|
import { globalsNameReferenceMap } from "storybook/internal/preview/globals";
|
|
295
295
|
|
|
296
|
-
//
|
|
296
|
+
// ../../../node_modules/es-module-lexer/dist/lexer.js
|
|
297
297
|
var ImportType;
|
|
298
298
|
(function(A2) {
|
|
299
299
|
A2[A2.Static = 1] = "Static", A2[A2.Dynamic = 2] = "Dynamic", A2[A2.ImportMeta = 3] = "ImportMeta", A2[A2.StaticSourcePhase = 4] = "StaticSourcePhase", A2[A2.DynamicSourcePhase = 5] = "DynamicSourcePhase", A2[A2.StaticDeferPhase = 6] = "StaticDeferPhase", A2[A2.DynamicDeferPhase = 7] = "DynamicDeferPhase";
|
|
@@ -342,7 +342,7 @@ var C, E = () => {
|
|
|
342
342
|
C = A2;
|
|
343
343
|
}));
|
|
344
344
|
|
|
345
|
-
//
|
|
345
|
+
// ../../../node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
346
346
|
var comma = 44, semicolon = 59, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", intToChar = new Uint8Array(64), charToInt = new Uint8Array(128);
|
|
347
347
|
for (let i = 0; i < chars.length; i++) {
|
|
348
348
|
let c = chars.charCodeAt(i);
|
|
@@ -395,7 +395,7 @@ function encode(decoded) {
|
|
|
395
395
|
return writer.flush();
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
-
//
|
|
398
|
+
// ../../../node_modules/magic-string/dist/magic-string.es.mjs
|
|
399
399
|
var BitSet = class _BitSet {
|
|
400
400
|
constructor(arg) {
|
|
401
401
|
this.bits = arg instanceof _BitSet ? arg.bits.slice() : [];
|
|
@@ -1040,7 +1040,7 @@ import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
|
1040
1040
|
// ../../core/src/shared/utils/module.ts
|
|
1041
1041
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
1042
1042
|
|
|
1043
|
-
//
|
|
1043
|
+
// ../../../node_modules/exsolve/dist/index.mjs
|
|
1044
1044
|
import assert from "node:assert";
|
|
1045
1045
|
import v8 from "node:v8";
|
|
1046
1046
|
import { format, inspect } from "node:util";
|
|
@@ -1169,7 +1169,7 @@ var importMetaResolve = (...args) => typeof import.meta.resolve != "function" &&
|
|
|
1169
1169
|
"importMetaResolve from within Storybook is being used in a Vitest test, but it shouldn't be. Please report this at https://github.com/storybookjs/storybook/issues/new?template=bug_report.yml"
|
|
1170
1170
|
), pathToFileURL(args[0]).href) : import.meta.resolve(...args);
|
|
1171
1171
|
|
|
1172
|
-
//
|
|
1172
|
+
// ../../../node_modules/knitwork/dist/index.mjs
|
|
1173
1173
|
function genString(input, options = {}) {
|
|
1174
1174
|
let str = JSON.stringify(input);
|
|
1175
1175
|
return options.singleQuotes ? `'${escapeString(str).slice(1, -1)}'` : str;
|
|
@@ -1308,10 +1308,10 @@ import { dedent } from "ts-dedent";
|
|
|
1308
1308
|
import { isAbsolute as isAbsolute2, join as join2 } from "node:path";
|
|
1309
1309
|
import { commonGlobOptions, normalizeStories } from "storybook/internal/common";
|
|
1310
1310
|
|
|
1311
|
-
//
|
|
1311
|
+
// ../../../node_modules/glob/node_modules/minimatch/dist/esm/index.js
|
|
1312
1312
|
var import_brace_expansion = __toESM(require_brace_expansion(), 1);
|
|
1313
1313
|
|
|
1314
|
-
//
|
|
1314
|
+
// ../../../node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.js
|
|
1315
1315
|
var assertValidPattern = (pattern) => {
|
|
1316
1316
|
if (typeof pattern != "string")
|
|
1317
1317
|
throw new TypeError("invalid pattern");
|
|
@@ -1319,7 +1319,7 @@ var assertValidPattern = (pattern) => {
|
|
|
1319
1319
|
throw new TypeError("pattern is too long");
|
|
1320
1320
|
};
|
|
1321
1321
|
|
|
1322
|
-
//
|
|
1322
|
+
// ../../../node_modules/glob/node_modules/minimatch/dist/esm/brace-expressions.js
|
|
1323
1323
|
var posixClasses = {
|
|
1324
1324
|
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", !0],
|
|
1325
1325
|
"[:alpha:]": ["\\p{L}\\p{Nl}", !0],
|
|
@@ -1389,10 +1389,10 @@ var posixClasses = {
|
|
|
1389
1389
|
return [ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs, uflag, endPos - pos, !0];
|
|
1390
1390
|
};
|
|
1391
1391
|
|
|
1392
|
-
//
|
|
1392
|
+
// ../../../node_modules/glob/node_modules/minimatch/dist/esm/unescape.js
|
|
1393
1393
|
var unescape2 = (s, { windowsPathsNoEscape = !1 } = {}) => windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
|
|
1394
1394
|
|
|
1395
|
-
//
|
|
1395
|
+
// ../../../node_modules/glob/node_modules/minimatch/dist/esm/ast.js
|
|
1396
1396
|
var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), isExtglobType = (c) => types.has(c), startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))", startNoDot = "(?!\\.)", addPatternStart = /* @__PURE__ */ new Set(["[", "."]), justDots = /* @__PURE__ */ new Set(["..", "."]), reSpecials = new Set("().*{}+?[]^$\\!"), regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), qmark = "[^/]", star = qmark + "*?", starNoEmpty = qmark + "+?", AST = class _AST {
|
|
1397
1397
|
type;
|
|
1398
1398
|
#root;
|
|
@@ -1728,10 +1728,10 @@ var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), isExtglobType =
|
|
|
1728
1728
|
}
|
|
1729
1729
|
};
|
|
1730
1730
|
|
|
1731
|
-
//
|
|
1731
|
+
// ../../../node_modules/glob/node_modules/minimatch/dist/esm/escape.js
|
|
1732
1732
|
var escape = (s, { windowsPathsNoEscape = !1 } = {}) => windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
|
1733
1733
|
|
|
1734
|
-
//
|
|
1734
|
+
// ../../../node_modules/glob/node_modules/minimatch/dist/esm/index.js
|
|
1735
1735
|
var minimatch = (p, pattern, options = {}) => (assertValidPattern(pattern), !options.nocomment && pattern.charAt(0) === "#" ? !1 : new Minimatch(pattern, options).match(p)), starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/, starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2), starDotExtTestDot = (ext2) => (f) => f.endsWith(ext2), starDotExtTestNocase = (ext2) => (ext2 = ext2.toLowerCase(), (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext2)), starDotExtTestNocaseDot = (ext2) => (ext2 = ext2.toLowerCase(), (f) => f.toLowerCase().endsWith(ext2)), starDotStarRE = /^\*+\.\*+$/, starDotStarTest = (f) => !f.startsWith(".") && f.includes("."), starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes("."), dotStarRE = /^\.\*+$/, dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith("."), starRE = /^\*+$/, starTest = (f) => f.length !== 0 && !f.startsWith("."), starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..", qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/, qmarksTestNocase = ([$0, ext2 = ""]) => {
|
|
1736
1736
|
let noext = qmarksTestNoExt([$0]);
|
|
1737
1737
|
return ext2 ? (ext2 = ext2.toLowerCase(), (f) => noext(f) && f.toLowerCase().endsWith(ext2)) : noext;
|
|
@@ -2153,10 +2153,10 @@ minimatch.Minimatch = Minimatch;
|
|
|
2153
2153
|
minimatch.escape = escape;
|
|
2154
2154
|
minimatch.unescape = unescape2;
|
|
2155
2155
|
|
|
2156
|
-
//
|
|
2156
|
+
// ../../../node_modules/glob/dist/esm/glob.js
|
|
2157
2157
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
2158
2158
|
|
|
2159
|
-
//
|
|
2159
|
+
// ../../../node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js
|
|
2160
2160
|
var perf = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date, warned2 = /* @__PURE__ */ new Set(), PROCESS = typeof process == "object" && process ? process : {}, emitWarning = (msg, type, code, fn) => {
|
|
2161
2161
|
typeof PROCESS.emitWarning == "function" ? PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
|
|
2162
2162
|
}, AC = globalThis.AbortController, AS = globalThis.AbortSignal;
|
|
@@ -2216,13 +2216,14 @@ var shouldWarn = (code) => !warned2.has(code), TYPE = Symbol("type"), isPosInt =
|
|
|
2216
2216
|
return this.heap[--this.length];
|
|
2217
2217
|
}
|
|
2218
2218
|
}, LRUCache = class _LRUCache {
|
|
2219
|
-
// options
|
|
2219
|
+
// properties coming in from the options of these, only max and maxSize
|
|
2220
|
+
// really *need* to be protected. The rest can be modified, as they just
|
|
2221
|
+
// set defaults for various methods.
|
|
2220
2222
|
#max;
|
|
2221
2223
|
#maxSize;
|
|
2222
2224
|
#dispose;
|
|
2223
2225
|
#disposeAfter;
|
|
2224
2226
|
#fetchMethod;
|
|
2225
|
-
#memoMethod;
|
|
2226
2227
|
/**
|
|
2227
2228
|
* {@link LRUCache.OptionsBase.ttl}
|
|
2228
2229
|
*/
|
|
@@ -2368,9 +2369,6 @@ var shouldWarn = (code) => !warned2.has(code), TYPE = Symbol("type"), isPosInt =
|
|
|
2368
2369
|
get fetchMethod() {
|
|
2369
2370
|
return this.#fetchMethod;
|
|
2370
2371
|
}
|
|
2371
|
-
get memoMethod() {
|
|
2372
|
-
return this.#memoMethod;
|
|
2373
|
-
}
|
|
2374
2372
|
/**
|
|
2375
2373
|
* {@link LRUCache.OptionsBase.dispose} (read-only)
|
|
2376
2374
|
*/
|
|
@@ -2384,7 +2382,7 @@ var shouldWarn = (code) => !warned2.has(code), TYPE = Symbol("type"), isPosInt =
|
|
|
2384
2382
|
return this.#disposeAfter;
|
|
2385
2383
|
}
|
|
2386
2384
|
constructor(options) {
|
|
2387
|
-
let { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod,
|
|
2385
|
+
let { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort } = options;
|
|
2388
2386
|
if (max !== 0 && !isPosInt(max))
|
|
2389
2387
|
throw new TypeError("max option must be a nonnegative integer");
|
|
2390
2388
|
let UintArray = max ? getUintArray(max) : Array;
|
|
@@ -2396,9 +2394,7 @@ var shouldWarn = (code) => !warned2.has(code), TYPE = Symbol("type"), isPosInt =
|
|
|
2396
2394
|
if (typeof this.sizeCalculation != "function")
|
|
2397
2395
|
throw new TypeError("sizeCalculation set to non-function");
|
|
2398
2396
|
}
|
|
2399
|
-
if (
|
|
2400
|
-
throw new TypeError("memoMethod must be a function if defined");
|
|
2401
|
-
if (this.#memoMethod = memoMethod, fetchMethod !== void 0 && typeof fetchMethod != "function")
|
|
2397
|
+
if (fetchMethod !== void 0 && typeof fetchMethod != "function")
|
|
2402
2398
|
throw new TypeError("fetchMethod must be a function if specified");
|
|
2403
2399
|
if (this.#fetchMethod = fetchMethod, this.#hasFetchMethod = !!fetchMethod, this.#keyMap = /* @__PURE__ */ new Map(), this.#keyList = new Array(max).fill(void 0), this.#valList = new Array(max).fill(void 0), this.#next = new UintArray(max), this.#prev = new UintArray(max), this.#head = 0, this.#tail = 0, this.#free = Stack.create(max), this.#size = 0, this.#calculatedSize = 0, typeof dispose == "function" && (this.#dispose = dispose), typeof disposeAfter == "function" ? (this.#disposeAfter = disposeAfter, this.#disposed = []) : (this.#disposeAfter = void 0, this.#disposed = void 0), this.#hasDispose = !!this.#dispose, this.#hasDisposeAfter = !!this.#disposeAfter, this.noDisposeOnSet = !!noDisposeOnSet, this.noUpdateTTL = !!noUpdateTTL, this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection, this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection, this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort, this.ignoreFetchAbort = !!ignoreFetchAbort, this.maxEntrySize !== 0) {
|
|
2404
2400
|
if (this.#maxSize !== 0 && !isPosInt(this.#maxSize))
|
|
@@ -2420,8 +2416,7 @@ var shouldWarn = (code) => !warned2.has(code), TYPE = Symbol("type"), isPosInt =
|
|
|
2420
2416
|
}
|
|
2421
2417
|
}
|
|
2422
2418
|
/**
|
|
2423
|
-
* Return the
|
|
2424
|
-
* returns `0`. Returns `Infinity` if item is in cache without a defined TTL.
|
|
2419
|
+
* Return the remaining TTL time for a given entry key
|
|
2425
2420
|
*/
|
|
2426
2421
|
getRemainingTTL(key) {
|
|
2427
2422
|
return this.#keyMap.has(key) ? 1 / 0 : 0;
|
|
@@ -2431,7 +2426,7 @@ var shouldWarn = (code) => !warned2.has(code), TYPE = Symbol("type"), isPosInt =
|
|
|
2431
2426
|
this.#ttls = ttls, this.#starts = starts, this.#setItemTTL = (index, ttl, start2 = perf.now()) => {
|
|
2432
2427
|
if (starts[index] = ttl !== 0 ? start2 : 0, ttls[index] = ttl, ttl !== 0 && this.ttlAutopurge) {
|
|
2433
2428
|
let t = setTimeout(() => {
|
|
2434
|
-
this.#isStale(index) && this
|
|
2429
|
+
this.#isStale(index) && this.delete(this.#keyList[index]);
|
|
2435
2430
|
}, ttl + 1);
|
|
2436
2431
|
t.unref && t.unref();
|
|
2437
2432
|
}
|
|
@@ -2592,14 +2587,13 @@ var shouldWarn = (code) => !warned2.has(code), TYPE = Symbol("type"), isPosInt =
|
|
|
2592
2587
|
return this.entries();
|
|
2593
2588
|
}
|
|
2594
2589
|
/**
|
|
2595
|
-
* A String value that is used in the creation of the default string
|
|
2596
|
-
*
|
|
2597
|
-
* `Object.prototype.toString`.
|
|
2590
|
+
* A String value that is used in the creation of the default string description of an object.
|
|
2591
|
+
* Called by the built-in method Object.prototype.toString.
|
|
2598
2592
|
*/
|
|
2599
2593
|
[Symbol.toStringTag] = "LRUCache";
|
|
2600
2594
|
/**
|
|
2601
2595
|
* Find a value for which the supplied fn method returns a truthy value,
|
|
2602
|
-
* similar to
|
|
2596
|
+
* similar to Array.find(). fn is called as fn(value, key, cache).
|
|
2603
2597
|
*/
|
|
2604
2598
|
find(fn, getOptions = {}) {
|
|
2605
2599
|
for (let i of this.#indexes()) {
|
|
@@ -2609,15 +2603,10 @@ var shouldWarn = (code) => !warned2.has(code), TYPE = Symbol("type"), isPosInt =
|
|
|
2609
2603
|
}
|
|
2610
2604
|
}
|
|
2611
2605
|
/**
|
|
2612
|
-
* Call the supplied function on each item in the cache, in order from
|
|
2613
|
-
* recently used to least recently used.
|
|
2614
|
-
*
|
|
2615
|
-
*
|
|
2616
|
-
*
|
|
2617
|
-
* If `thisp` is provided, function will be called in the `this`-context of
|
|
2618
|
-
* the provided object, or the cache if no `thisp` object is provided.
|
|
2619
|
-
*
|
|
2620
|
-
* Does not update age or recenty of use, or iterate over stale values.
|
|
2606
|
+
* Call the supplied function on each item in the cache, in order from
|
|
2607
|
+
* most recently used to least recently used. fn is called as
|
|
2608
|
+
* fn(value, key, cache). Does not update age or recenty of use.
|
|
2609
|
+
* Does not iterate over stale values.
|
|
2621
2610
|
*/
|
|
2622
2611
|
forEach(fn, thisp = this) {
|
|
2623
2612
|
for (let i of this.#indexes()) {
|
|
@@ -2642,20 +2631,14 @@ var shouldWarn = (code) => !warned2.has(code), TYPE = Symbol("type"), isPosInt =
|
|
|
2642
2631
|
purgeStale() {
|
|
2643
2632
|
let deleted = !1;
|
|
2644
2633
|
for (let i of this.#rindexes({ allowStale: !0 }))
|
|
2645
|
-
this.#isStale(i) && (this
|
|
2634
|
+
this.#isStale(i) && (this.delete(this.#keyList[i]), deleted = !0);
|
|
2646
2635
|
return deleted;
|
|
2647
2636
|
}
|
|
2648
2637
|
/**
|
|
2649
2638
|
* Get the extended info about a given entry, to get its value, size, and
|
|
2650
|
-
* TTL info simultaneously.
|
|
2651
|
-
*
|
|
2652
|
-
*
|
|
2653
|
-
* serialization, the `start` value is always the current timestamp, and the
|
|
2654
|
-
* `ttl` is a calculated remaining time to live (negative if expired).
|
|
2655
|
-
*
|
|
2656
|
-
* Always returns stale values, if their info is found in the cache, so be
|
|
2657
|
-
* sure to check for expirations (ie, a negative {@link LRUCache.Entry#ttl})
|
|
2658
|
-
* if relevant.
|
|
2639
|
+
* TTL info simultaneously. Like {@link LRUCache#dump}, but just for a
|
|
2640
|
+
* single key. Always returns stale values, if their info is found in the
|
|
2641
|
+
* cache, so be sure to check for expired TTLs if relevant.
|
|
2659
2642
|
*/
|
|
2660
2643
|
info(key) {
|
|
2661
2644
|
let i = this.#keyMap.get(key);
|
|
@@ -2676,16 +2659,7 @@ var shouldWarn = (code) => !warned2.has(code), TYPE = Symbol("type"), isPosInt =
|
|
|
2676
2659
|
}
|
|
2677
2660
|
/**
|
|
2678
2661
|
* Return an array of [key, {@link LRUCache.Entry}] tuples which can be
|
|
2679
|
-
* passed to
|
|
2680
|
-
*
|
|
2681
|
-
* The `start` fields are calculated relative to a portable `Date.now()`
|
|
2682
|
-
* timestamp, even if `performance.now()` is available.
|
|
2683
|
-
*
|
|
2684
|
-
* Stale entries are always included in the `dump`, even if
|
|
2685
|
-
* {@link LRUCache.OptionsBase.allowStale} is false.
|
|
2686
|
-
*
|
|
2687
|
-
* Note: this returns an actual array, not a generator, so it can be more
|
|
2688
|
-
* easily passed around.
|
|
2662
|
+
* passed to cache.load()
|
|
2689
2663
|
*/
|
|
2690
2664
|
dump() {
|
|
2691
2665
|
let arr = [];
|
|
@@ -2705,12 +2679,8 @@ var shouldWarn = (code) => !warned2.has(code), TYPE = Symbol("type"), isPosInt =
|
|
|
2705
2679
|
}
|
|
2706
2680
|
/**
|
|
2707
2681
|
* Reset the cache and load in the items in entries in the order listed.
|
|
2708
|
-
*
|
|
2709
|
-
*
|
|
2710
|
-
* not used in both caches.
|
|
2711
|
-
*
|
|
2712
|
-
* The `start` fields are assumed to be calculated relative to a portable
|
|
2713
|
-
* `Date.now()` timestamp, even if `performance.now()` is available.
|
|
2682
|
+
* Note that the shape of the resulting cache may be different if the
|
|
2683
|
+
* same options are not used in both caches.
|
|
2714
2684
|
*/
|
|
2715
2685
|
load(arr) {
|
|
2716
2686
|
this.clear();
|
|
@@ -2727,37 +2697,13 @@ var shouldWarn = (code) => !warned2.has(code), TYPE = Symbol("type"), isPosInt =
|
|
|
2727
2697
|
*
|
|
2728
2698
|
* Note: if `undefined` is specified as a value, this is an alias for
|
|
2729
2699
|
* {@link LRUCache#delete}
|
|
2730
|
-
*
|
|
2731
|
-
* Fields on the {@link LRUCache.SetOptions} options param will override
|
|
2732
|
-
* their corresponding values in the constructor options for the scope
|
|
2733
|
-
* of this single `set()` operation.
|
|
2734
|
-
*
|
|
2735
|
-
* If `start` is provided, then that will set the effective start
|
|
2736
|
-
* time for the TTL calculation. Note that this must be a previous
|
|
2737
|
-
* value of `performance.now()` if supported, or a previous value of
|
|
2738
|
-
* `Date.now()` if not.
|
|
2739
|
-
*
|
|
2740
|
-
* Options object may also include `size`, which will prevent
|
|
2741
|
-
* calling the `sizeCalculation` function and just use the specified
|
|
2742
|
-
* number if it is a positive integer, and `noDisposeOnSet` which
|
|
2743
|
-
* will prevent calling a `dispose` function in the case of
|
|
2744
|
-
* overwrites.
|
|
2745
|
-
*
|
|
2746
|
-
* If the `size` (or return value of `sizeCalculation`) for a given
|
|
2747
|
-
* entry is greater than `maxEntrySize`, then the item will not be
|
|
2748
|
-
* added to the cache.
|
|
2749
|
-
*
|
|
2750
|
-
* Will update the recency of the entry.
|
|
2751
|
-
*
|
|
2752
|
-
* If the value is `undefined`, then this is an alias for
|
|
2753
|
-
* `cache.delete(key)`. `undefined` is never stored in the cache.
|
|
2754
2700
|
*/
|
|
2755
2701
|
set(k, v, setOptions = {}) {
|
|
2756
2702
|
if (v === void 0)
|
|
2757
2703
|
return this.delete(k), this;
|
|
2758
2704
|
let { ttl = this.ttl, start: start2, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status } = setOptions, { noUpdateTTL = this.noUpdateTTL } = setOptions, size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation);
|
|
2759
2705
|
if (this.maxEntrySize && size > this.maxEntrySize)
|
|
2760
|
-
return status && (status.set = "miss", status.maxEntrySizeExceeded = !0), this
|
|
2706
|
+
return status && (status.set = "miss", status.maxEntrySizeExceeded = !0), this.delete(k), this;
|
|
2761
2707
|
let index = this.#size === 0 ? void 0 : this.#keyMap.get(k);
|
|
2762
2708
|
if (index === void 0)
|
|
2763
2709
|
index = this.#size === 0 ? this.#tail : this.#free.length !== 0 ? this.#free.pop() : this.#size === this.#max ? this.#evict(!1) : this.#size, this.#keyList[index] = k, this.#valList[index] = v, this.#keyMap.set(k, index), this.#next[this.#tail] = index, this.#prev[index] = this.#tail, this.#tail = index, this.#size++, this.#addItemSize(index, size, status), status && (status.set = "add"), noUpdateTTL = !1;
|
|
@@ -2815,14 +2761,6 @@ var shouldWarn = (code) => !warned2.has(code), TYPE = Symbol("type"), isPosInt =
|
|
|
2815
2761
|
* Will return false if the item is stale, even though it is technically
|
|
2816
2762
|
* in the cache.
|
|
2817
2763
|
*
|
|
2818
|
-
* Check if a key is in the cache, without updating the recency of
|
|
2819
|
-
* use. Age is updated if {@link LRUCache.OptionsBase.updateAgeOnHas} is set
|
|
2820
|
-
* to `true` in either the options or the constructor.
|
|
2821
|
-
*
|
|
2822
|
-
* Will return `false` if the item is stale, even though it is technically in
|
|
2823
|
-
* the cache. The difference can be determined (if it matters) by using a
|
|
2824
|
-
* `status` argument, and inspecting the `has` field.
|
|
2825
|
-
*
|
|
2826
2764
|
* Will not update item age unless
|
|
2827
2765
|
* {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
|
|
2828
2766
|
*/
|
|
@@ -2869,10 +2807,10 @@ var shouldWarn = (code) => !warned2.has(code), TYPE = Symbol("type"), isPosInt =
|
|
|
2869
2807
|
if (options.status && (aborted && !updateCache ? (options.status.fetchAborted = !0, options.status.fetchError = ac.signal.reason, ignoreAbort && (options.status.fetchAbortIgnored = !0)) : options.status.fetchResolved = !0), aborted && !ignoreAbort && !updateCache)
|
|
2870
2808
|
return fetchFail(ac.signal.reason);
|
|
2871
2809
|
let bf2 = p;
|
|
2872
|
-
return this.#valList[index] === p && (v2 === void 0 ? bf2.__staleWhileFetching ? this.#valList[index] = bf2.__staleWhileFetching : this
|
|
2810
|
+
return this.#valList[index] === p && (v2 === void 0 ? bf2.__staleWhileFetching ? this.#valList[index] = bf2.__staleWhileFetching : this.delete(k) : (options.status && (options.status.fetchUpdated = !0), this.set(k, v2, fetchOpts.options))), v2;
|
|
2873
2811
|
}, eb = (er) => (options.status && (options.status.fetchRejected = !0, options.status.fetchError = er), fetchFail(er)), fetchFail = (er) => {
|
|
2874
2812
|
let { aborted } = ac.signal, allowStaleAborted = aborted && options.allowStaleOnFetchAbort, allowStale = allowStaleAborted || options.allowStaleOnFetchRejection, noDelete = allowStale || options.noDeleteOnFetchRejection, bf2 = p;
|
|
2875
|
-
if (this.#valList[index] === p && (!noDelete || bf2.__staleWhileFetching === void 0 ? this
|
|
2813
|
+
if (this.#valList[index] === p && (!noDelete || bf2.__staleWhileFetching === void 0 ? this.delete(k) : allowStaleAborted || (this.#valList[index] = bf2.__staleWhileFetching)), allowStale)
|
|
2876
2814
|
return options.status && bf2.__staleWhileFetching !== void 0 && (options.status.returnedStale = !0), bf2.__staleWhileFetching;
|
|
2877
2815
|
if (bf2.__returned === bf2)
|
|
2878
2816
|
throw er;
|
|
@@ -2958,25 +2896,6 @@ var shouldWarn = (code) => !warned2.has(code), TYPE = Symbol("type"), isPosInt =
|
|
|
2958
2896
|
return status && (status.fetch = isStale ? "stale" : "refresh", staleVal && isStale && (status.returnedStale = !0)), staleVal ? p.__staleWhileFetching : p.__returned = p;
|
|
2959
2897
|
}
|
|
2960
2898
|
}
|
|
2961
|
-
async forceFetch(k, fetchOptions = {}) {
|
|
2962
|
-
let v = await this.fetch(k, fetchOptions);
|
|
2963
|
-
if (v === void 0)
|
|
2964
|
-
throw new Error("fetch() returned undefined");
|
|
2965
|
-
return v;
|
|
2966
|
-
}
|
|
2967
|
-
memo(k, memoOptions = {}) {
|
|
2968
|
-
let memoMethod = this.#memoMethod;
|
|
2969
|
-
if (!memoMethod)
|
|
2970
|
-
throw new Error("no memoMethod provided to constructor");
|
|
2971
|
-
let { context, forceRefresh, ...options } = memoOptions, v = this.get(k, options);
|
|
2972
|
-
if (!forceRefresh && v !== void 0)
|
|
2973
|
-
return v;
|
|
2974
|
-
let vv = memoMethod(k, v, {
|
|
2975
|
-
options,
|
|
2976
|
-
context
|
|
2977
|
-
});
|
|
2978
|
-
return this.set(k, vv, options), vv;
|
|
2979
|
-
}
|
|
2980
2899
|
/**
|
|
2981
2900
|
* Return a value from the cache. Will update the recency of the cache
|
|
2982
2901
|
* entry found.
|
|
@@ -2987,7 +2906,7 @@ var shouldWarn = (code) => !warned2.has(code), TYPE = Symbol("type"), isPosInt =
|
|
|
2987
2906
|
let { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status } = getOptions, index = this.#keyMap.get(k);
|
|
2988
2907
|
if (index !== void 0) {
|
|
2989
2908
|
let value = this.#valList[index], fetching = this.#isBackgroundFetch(value);
|
|
2990
|
-
return status && this.#statusTTL(status, index), this.#isStale(index) ? (status && (status.get = "stale"), fetching ? (status && allowStale && value.__staleWhileFetching !== void 0 && (status.returnedStale = !0), allowStale ? value.__staleWhileFetching : void 0) : (noDeleteOnStaleGet || this
|
|
2909
|
+
return status && this.#statusTTL(status, index), this.#isStale(index) ? (status && (status.get = "stale"), fetching ? (status && allowStale && value.__staleWhileFetching !== void 0 && (status.returnedStale = !0), allowStale ? value.__staleWhileFetching : void 0) : (noDeleteOnStaleGet || this.delete(k), status && allowStale && (status.returnedStale = !0), allowStale ? value : void 0)) : (status && (status.get = "hit"), fetching ? value.__staleWhileFetching : (this.#moveToTail(index), updateAgeOnGet && this.#updateItemAge(index), value));
|
|
2991
2910
|
} else status && (status.get = "miss");
|
|
2992
2911
|
}
|
|
2993
2912
|
#connect(p, n2) {
|
|
@@ -2998,23 +2917,19 @@ var shouldWarn = (code) => !warned2.has(code), TYPE = Symbol("type"), isPosInt =
|
|
|
2998
2917
|
}
|
|
2999
2918
|
/**
|
|
3000
2919
|
* Deletes a key out of the cache.
|
|
3001
|
-
*
|
|
3002
2920
|
* Returns true if the key was deleted, false otherwise.
|
|
3003
2921
|
*/
|
|
3004
2922
|
delete(k) {
|
|
3005
|
-
return this.#delete(k, "delete");
|
|
3006
|
-
}
|
|
3007
|
-
#delete(k, reason) {
|
|
3008
2923
|
let deleted = !1;
|
|
3009
2924
|
if (this.#size !== 0) {
|
|
3010
2925
|
let index = this.#keyMap.get(k);
|
|
3011
2926
|
if (index !== void 0)
|
|
3012
2927
|
if (deleted = !0, this.#size === 1)
|
|
3013
|
-
this
|
|
2928
|
+
this.clear();
|
|
3014
2929
|
else {
|
|
3015
2930
|
this.#removeItemSize(index);
|
|
3016
2931
|
let v = this.#valList[index];
|
|
3017
|
-
if (this.#isBackgroundFetch(v) ? v.__abortController.abort(new Error("deleted")) : (this.#hasDispose || this.#hasDisposeAfter) && (this.#hasDispose && this.#dispose?.(v, k,
|
|
2932
|
+
if (this.#isBackgroundFetch(v) ? v.__abortController.abort(new Error("deleted")) : (this.#hasDispose || this.#hasDisposeAfter) && (this.#hasDispose && this.#dispose?.(v, k, "delete"), this.#hasDisposeAfter && this.#disposed?.push([v, k, "delete"])), this.#keyMap.delete(k), this.#keyList[index] = void 0, this.#valList[index] = void 0, index === this.#tail)
|
|
3018
2933
|
this.#tail = this.#prev[index];
|
|
3019
2934
|
else if (index === this.#head)
|
|
3020
2935
|
this.#head = this.#next[index];
|
|
@@ -3038,16 +2953,13 @@ var shouldWarn = (code) => !warned2.has(code), TYPE = Symbol("type"), isPosInt =
|
|
|
3038
2953
|
* Clear the cache entirely, throwing away all values.
|
|
3039
2954
|
*/
|
|
3040
2955
|
clear() {
|
|
3041
|
-
return this.#clear("delete");
|
|
3042
|
-
}
|
|
3043
|
-
#clear(reason) {
|
|
3044
2956
|
for (let index of this.#rindexes({ allowStale: !0 })) {
|
|
3045
2957
|
let v = this.#valList[index];
|
|
3046
2958
|
if (this.#isBackgroundFetch(v))
|
|
3047
2959
|
v.__abortController.abort(new Error("deleted"));
|
|
3048
2960
|
else {
|
|
3049
2961
|
let k = this.#keyList[index];
|
|
3050
|
-
this.#hasDispose && this.#dispose?.(v, k,
|
|
2962
|
+
this.#hasDispose && this.#dispose?.(v, k, "delete"), this.#hasDisposeAfter && this.#disposed?.push([v, k, "delete"]);
|
|
3051
2963
|
}
|
|
3052
2964
|
}
|
|
3053
2965
|
if (this.#keyMap.clear(), this.#valList.fill(void 0), this.#keyList.fill(void 0), this.#ttls && this.#starts && (this.#ttls.fill(0), this.#starts.fill(0)), this.#sizes && this.#sizes.fill(0), this.#head = 0, this.#tail = 0, this.#free.length = 0, this.#calculatedSize = 0, this.#size = 0, this.#hasDisposeAfter && this.#disposed) {
|
|
@@ -3058,14 +2970,14 @@ var shouldWarn = (code) => !warned2.has(code), TYPE = Symbol("type"), isPosInt =
|
|
|
3058
2970
|
}
|
|
3059
2971
|
};
|
|
3060
2972
|
|
|
3061
|
-
//
|
|
2973
|
+
// ../../../node_modules/path-scurry/dist/esm/index.js
|
|
3062
2974
|
import { posix, win32 } from "node:path";
|
|
3063
2975
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
3064
2976
|
import { lstatSync, readdir as readdirCB, readdirSync, readlinkSync, realpathSync as rps } from "fs";
|
|
3065
2977
|
import * as actualFS from "node:fs";
|
|
3066
2978
|
import { lstat, readdir, readlink, realpath } from "node:fs/promises";
|
|
3067
2979
|
|
|
3068
|
-
//
|
|
2980
|
+
// ../../../node_modules/path-scurry/node_modules/minipass/dist/esm/index.js
|
|
3069
2981
|
import { EventEmitter } from "node:events";
|
|
3070
2982
|
import Stream from "node:stream";
|
|
3071
2983
|
import { StringDecoder } from "node:string_decoder";
|
|
@@ -3624,7 +3536,7 @@ s.pipe !== Stream.Writable.prototype.pipe, isWritable = (s) => !!s && typeof s =
|
|
|
3624
3536
|
}
|
|
3625
3537
|
};
|
|
3626
3538
|
|
|
3627
|
-
//
|
|
3539
|
+
// ../../../node_modules/path-scurry/dist/esm/index.js
|
|
3628
3540
|
var realpathSync = rps.native, defaultFS = {
|
|
3629
3541
|
lstatSync,
|
|
3630
3542
|
readdir: readdirCB,
|
|
@@ -4918,7 +4830,7 @@ var realpathSync = rps.native, defaultFS = {
|
|
|
4918
4830
|
}
|
|
4919
4831
|
}, Path = process.platform === "win32" ? PathWin32 : PathPosix, PathScurry = process.platform === "win32" ? PathScurryWin32 : process.platform === "darwin" ? PathScurryDarwin : PathScurryPosix;
|
|
4920
4832
|
|
|
4921
|
-
//
|
|
4833
|
+
// ../../../node_modules/glob/dist/esm/pattern.js
|
|
4922
4834
|
var isPatternList = (pl) => pl.length >= 1, isGlobList = (gl) => gl.length >= 1, Pattern = class _Pattern {
|
|
4923
4835
|
#patternList;
|
|
4924
4836
|
#globList;
|
|
@@ -5047,7 +4959,566 @@ var isPatternList = (pl) => pl.length >= 1, isGlobList = (gl) => gl.length >= 1,
|
|
|
5047
4959
|
}
|
|
5048
4960
|
};
|
|
5049
4961
|
|
|
5050
|
-
//
|
|
4962
|
+
// ../../../node_modules/glob/node_modules/minipass/dist/esm/index.js
|
|
4963
|
+
import { EventEmitter as EventEmitter2 } from "node:events";
|
|
4964
|
+
import Stream2 from "node:stream";
|
|
4965
|
+
import { StringDecoder as StringDecoder2 } from "node:string_decoder";
|
|
4966
|
+
var proc2 = typeof process == "object" && process ? process : {
|
|
4967
|
+
stdout: null,
|
|
4968
|
+
stderr: null
|
|
4969
|
+
}, isStream2 = (s) => !!s && typeof s == "object" && (s instanceof Minipass2 || s instanceof Stream2 || isReadable2(s) || isWritable2(s)), isReadable2 = (s) => !!s && typeof s == "object" && s instanceof EventEmitter2 && typeof s.pipe == "function" && // node core Writable streams have a pipe() method, but it throws
|
|
4970
|
+
s.pipe !== Stream2.Writable.prototype.pipe, isWritable2 = (s) => !!s && typeof s == "object" && s instanceof EventEmitter2 && typeof s.write == "function" && typeof s.end == "function", EOF2 = Symbol("EOF"), MAYBE_EMIT_END2 = Symbol("maybeEmitEnd"), EMITTED_END2 = Symbol("emittedEnd"), EMITTING_END2 = Symbol("emittingEnd"), EMITTED_ERROR2 = Symbol("emittedError"), CLOSED2 = Symbol("closed"), READ2 = Symbol("read"), FLUSH2 = Symbol("flush"), FLUSHCHUNK2 = Symbol("flushChunk"), ENCODING2 = Symbol("encoding"), DECODER2 = Symbol("decoder"), FLOWING2 = Symbol("flowing"), PAUSED2 = Symbol("paused"), RESUME2 = Symbol("resume"), BUFFER2 = Symbol("buffer"), PIPES2 = Symbol("pipes"), BUFFERLENGTH2 = Symbol("bufferLength"), BUFFERPUSH2 = Symbol("bufferPush"), BUFFERSHIFT2 = Symbol("bufferShift"), OBJECTMODE2 = Symbol("objectMode"), DESTROYED2 = Symbol("destroyed"), ERROR2 = Symbol("error"), EMITDATA2 = Symbol("emitData"), EMITEND3 = Symbol("emitEnd"), EMITEND22 = Symbol("emitEnd2"), ASYNC2 = Symbol("async"), ABORT2 = Symbol("abort"), ABORTED2 = Symbol("aborted"), SIGNAL2 = Symbol("signal"), DATALISTENERS2 = Symbol("dataListeners"), DISCARDED2 = Symbol("discarded"), defer2 = (fn) => Promise.resolve().then(fn), nodefer2 = (fn) => fn(), isEndish2 = (ev) => ev === "end" || ev === "finish" || ev === "prefinish", isArrayBufferLike2 = (b) => b instanceof ArrayBuffer || !!b && typeof b == "object" && b.constructor && b.constructor.name === "ArrayBuffer" && b.byteLength >= 0, isArrayBufferView2 = (b) => !Buffer.isBuffer(b) && ArrayBuffer.isView(b), Pipe2 = class {
|
|
4971
|
+
src;
|
|
4972
|
+
dest;
|
|
4973
|
+
opts;
|
|
4974
|
+
ondrain;
|
|
4975
|
+
constructor(src, dest, opts) {
|
|
4976
|
+
this.src = src, this.dest = dest, this.opts = opts, this.ondrain = () => src[RESUME2](), this.dest.on("drain", this.ondrain);
|
|
4977
|
+
}
|
|
4978
|
+
unpipe() {
|
|
4979
|
+
this.dest.removeListener("drain", this.ondrain);
|
|
4980
|
+
}
|
|
4981
|
+
// only here for the prototype
|
|
4982
|
+
/* c8 ignore start */
|
|
4983
|
+
proxyErrors(_er) {
|
|
4984
|
+
}
|
|
4985
|
+
/* c8 ignore stop */
|
|
4986
|
+
end() {
|
|
4987
|
+
this.unpipe(), this.opts.end && this.dest.end();
|
|
4988
|
+
}
|
|
4989
|
+
}, PipeProxyErrors2 = class extends Pipe2 {
|
|
4990
|
+
unpipe() {
|
|
4991
|
+
this.src.removeListener("error", this.proxyErrors), super.unpipe();
|
|
4992
|
+
}
|
|
4993
|
+
constructor(src, dest, opts) {
|
|
4994
|
+
super(src, dest, opts), this.proxyErrors = (er) => dest.emit("error", er), src.on("error", this.proxyErrors);
|
|
4995
|
+
}
|
|
4996
|
+
}, isObjectModeOptions2 = (o) => !!o.objectMode, isEncodingOptions2 = (o) => !o.objectMode && !!o.encoding && o.encoding !== "buffer", Minipass2 = class extends EventEmitter2 {
|
|
4997
|
+
[FLOWING2] = !1;
|
|
4998
|
+
[PAUSED2] = !1;
|
|
4999
|
+
[PIPES2] = [];
|
|
5000
|
+
[BUFFER2] = [];
|
|
5001
|
+
[OBJECTMODE2];
|
|
5002
|
+
[ENCODING2];
|
|
5003
|
+
[ASYNC2];
|
|
5004
|
+
[DECODER2];
|
|
5005
|
+
[EOF2] = !1;
|
|
5006
|
+
[EMITTED_END2] = !1;
|
|
5007
|
+
[EMITTING_END2] = !1;
|
|
5008
|
+
[CLOSED2] = !1;
|
|
5009
|
+
[EMITTED_ERROR2] = null;
|
|
5010
|
+
[BUFFERLENGTH2] = 0;
|
|
5011
|
+
[DESTROYED2] = !1;
|
|
5012
|
+
[SIGNAL2];
|
|
5013
|
+
[ABORTED2] = !1;
|
|
5014
|
+
[DATALISTENERS2] = 0;
|
|
5015
|
+
[DISCARDED2] = !1;
|
|
5016
|
+
/**
|
|
5017
|
+
* true if the stream can be written
|
|
5018
|
+
*/
|
|
5019
|
+
writable = !0;
|
|
5020
|
+
/**
|
|
5021
|
+
* true if the stream can be read
|
|
5022
|
+
*/
|
|
5023
|
+
readable = !0;
|
|
5024
|
+
/**
|
|
5025
|
+
* If `RType` is Buffer, then options do not need to be provided.
|
|
5026
|
+
* Otherwise, an options object must be provided to specify either
|
|
5027
|
+
* {@link Minipass.SharedOptions.objectMode} or
|
|
5028
|
+
* {@link Minipass.SharedOptions.encoding}, as appropriate.
|
|
5029
|
+
*/
|
|
5030
|
+
constructor(...args) {
|
|
5031
|
+
let options = args[0] || {};
|
|
5032
|
+
if (super(), options.objectMode && typeof options.encoding == "string")
|
|
5033
|
+
throw new TypeError("Encoding and objectMode may not be used together");
|
|
5034
|
+
isObjectModeOptions2(options) ? (this[OBJECTMODE2] = !0, this[ENCODING2] = null) : isEncodingOptions2(options) ? (this[ENCODING2] = options.encoding, this[OBJECTMODE2] = !1) : (this[OBJECTMODE2] = !1, this[ENCODING2] = null), this[ASYNC2] = !!options.async, this[DECODER2] = this[ENCODING2] ? new StringDecoder2(this[ENCODING2]) : null, options && options.debugExposeBuffer === !0 && Object.defineProperty(this, "buffer", { get: () => this[BUFFER2] }), options && options.debugExposePipes === !0 && Object.defineProperty(this, "pipes", { get: () => this[PIPES2] });
|
|
5035
|
+
let { signal } = options;
|
|
5036
|
+
signal && (this[SIGNAL2] = signal, signal.aborted ? this[ABORT2]() : signal.addEventListener("abort", () => this[ABORT2]()));
|
|
5037
|
+
}
|
|
5038
|
+
/**
|
|
5039
|
+
* The amount of data stored in the buffer waiting to be read.
|
|
5040
|
+
*
|
|
5041
|
+
* For Buffer strings, this will be the total byte length.
|
|
5042
|
+
* For string encoding streams, this will be the string character length,
|
|
5043
|
+
* according to JavaScript's `string.length` logic.
|
|
5044
|
+
* For objectMode streams, this is a count of the items waiting to be
|
|
5045
|
+
* emitted.
|
|
5046
|
+
*/
|
|
5047
|
+
get bufferLength() {
|
|
5048
|
+
return this[BUFFERLENGTH2];
|
|
5049
|
+
}
|
|
5050
|
+
/**
|
|
5051
|
+
* The `BufferEncoding` currently in use, or `null`
|
|
5052
|
+
*/
|
|
5053
|
+
get encoding() {
|
|
5054
|
+
return this[ENCODING2];
|
|
5055
|
+
}
|
|
5056
|
+
/**
|
|
5057
|
+
* @deprecated - This is a read only property
|
|
5058
|
+
*/
|
|
5059
|
+
set encoding(_enc) {
|
|
5060
|
+
throw new Error("Encoding must be set at instantiation time");
|
|
5061
|
+
}
|
|
5062
|
+
/**
|
|
5063
|
+
* @deprecated - Encoding may only be set at instantiation time
|
|
5064
|
+
*/
|
|
5065
|
+
setEncoding(_enc) {
|
|
5066
|
+
throw new Error("Encoding must be set at instantiation time");
|
|
5067
|
+
}
|
|
5068
|
+
/**
|
|
5069
|
+
* True if this is an objectMode stream
|
|
5070
|
+
*/
|
|
5071
|
+
get objectMode() {
|
|
5072
|
+
return this[OBJECTMODE2];
|
|
5073
|
+
}
|
|
5074
|
+
/**
|
|
5075
|
+
* @deprecated - This is a read-only property
|
|
5076
|
+
*/
|
|
5077
|
+
set objectMode(_om) {
|
|
5078
|
+
throw new Error("objectMode must be set at instantiation time");
|
|
5079
|
+
}
|
|
5080
|
+
/**
|
|
5081
|
+
* true if this is an async stream
|
|
5082
|
+
*/
|
|
5083
|
+
get async() {
|
|
5084
|
+
return this[ASYNC2];
|
|
5085
|
+
}
|
|
5086
|
+
/**
|
|
5087
|
+
* Set to true to make this stream async.
|
|
5088
|
+
*
|
|
5089
|
+
* Once set, it cannot be unset, as this would potentially cause incorrect
|
|
5090
|
+
* behavior. Ie, a sync stream can be made async, but an async stream
|
|
5091
|
+
* cannot be safely made sync.
|
|
5092
|
+
*/
|
|
5093
|
+
set async(a) {
|
|
5094
|
+
this[ASYNC2] = this[ASYNC2] || !!a;
|
|
5095
|
+
}
|
|
5096
|
+
// drop everything and get out of the flow completely
|
|
5097
|
+
[ABORT2]() {
|
|
5098
|
+
this[ABORTED2] = !0, this.emit("abort", this[SIGNAL2]?.reason), this.destroy(this[SIGNAL2]?.reason);
|
|
5099
|
+
}
|
|
5100
|
+
/**
|
|
5101
|
+
* True if the stream has been aborted.
|
|
5102
|
+
*/
|
|
5103
|
+
get aborted() {
|
|
5104
|
+
return this[ABORTED2];
|
|
5105
|
+
}
|
|
5106
|
+
/**
|
|
5107
|
+
* No-op setter. Stream aborted status is set via the AbortSignal provided
|
|
5108
|
+
* in the constructor options.
|
|
5109
|
+
*/
|
|
5110
|
+
set aborted(_) {
|
|
5111
|
+
}
|
|
5112
|
+
write(chunk, encoding, cb) {
|
|
5113
|
+
if (this[ABORTED2])
|
|
5114
|
+
return !1;
|
|
5115
|
+
if (this[EOF2])
|
|
5116
|
+
throw new Error("write after end");
|
|
5117
|
+
if (this[DESTROYED2])
|
|
5118
|
+
return this.emit("error", Object.assign(new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), !0;
|
|
5119
|
+
typeof encoding == "function" && (cb = encoding, encoding = "utf8"), encoding || (encoding = "utf8");
|
|
5120
|
+
let fn = this[ASYNC2] ? defer2 : nodefer2;
|
|
5121
|
+
if (!this[OBJECTMODE2] && !Buffer.isBuffer(chunk)) {
|
|
5122
|
+
if (isArrayBufferView2(chunk))
|
|
5123
|
+
chunk = Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength);
|
|
5124
|
+
else if (isArrayBufferLike2(chunk))
|
|
5125
|
+
chunk = Buffer.from(chunk);
|
|
5126
|
+
else if (typeof chunk != "string")
|
|
5127
|
+
throw new Error("Non-contiguous data written to non-objectMode stream");
|
|
5128
|
+
}
|
|
5129
|
+
return this[OBJECTMODE2] ? (this[FLOWING2] && this[BUFFERLENGTH2] !== 0 && this[FLUSH2](!0), this[FLOWING2] ? this.emit("data", chunk) : this[BUFFERPUSH2](chunk), this[BUFFERLENGTH2] !== 0 && this.emit("readable"), cb && fn(cb), this[FLOWING2]) : chunk.length ? (typeof chunk == "string" && // unless it is a string already ready for us to use
|
|
5130
|
+
!(encoding === this[ENCODING2] && !this[DECODER2]?.lastNeed) && (chunk = Buffer.from(chunk, encoding)), Buffer.isBuffer(chunk) && this[ENCODING2] && (chunk = this[DECODER2].write(chunk)), this[FLOWING2] && this[BUFFERLENGTH2] !== 0 && this[FLUSH2](!0), this[FLOWING2] ? this.emit("data", chunk) : this[BUFFERPUSH2](chunk), this[BUFFERLENGTH2] !== 0 && this.emit("readable"), cb && fn(cb), this[FLOWING2]) : (this[BUFFERLENGTH2] !== 0 && this.emit("readable"), cb && fn(cb), this[FLOWING2]);
|
|
5131
|
+
}
|
|
5132
|
+
/**
|
|
5133
|
+
* Low-level explicit read method.
|
|
5134
|
+
*
|
|
5135
|
+
* In objectMode, the argument is ignored, and one item is returned if
|
|
5136
|
+
* available.
|
|
5137
|
+
*
|
|
5138
|
+
* `n` is the number of bytes (or in the case of encoding streams,
|
|
5139
|
+
* characters) to consume. If `n` is not provided, then the entire buffer
|
|
5140
|
+
* is returned, or `null` is returned if no data is available.
|
|
5141
|
+
*
|
|
5142
|
+
* If `n` is greater that the amount of data in the internal buffer,
|
|
5143
|
+
* then `null` is returned.
|
|
5144
|
+
*/
|
|
5145
|
+
read(n2) {
|
|
5146
|
+
if (this[DESTROYED2])
|
|
5147
|
+
return null;
|
|
5148
|
+
if (this[DISCARDED2] = !1, this[BUFFERLENGTH2] === 0 || n2 === 0 || n2 && n2 > this[BUFFERLENGTH2])
|
|
5149
|
+
return this[MAYBE_EMIT_END2](), null;
|
|
5150
|
+
this[OBJECTMODE2] && (n2 = null), this[BUFFER2].length > 1 && !this[OBJECTMODE2] && (this[BUFFER2] = [
|
|
5151
|
+
this[ENCODING2] ? this[BUFFER2].join("") : Buffer.concat(this[BUFFER2], this[BUFFERLENGTH2])
|
|
5152
|
+
]);
|
|
5153
|
+
let ret = this[READ2](n2 || null, this[BUFFER2][0]);
|
|
5154
|
+
return this[MAYBE_EMIT_END2](), ret;
|
|
5155
|
+
}
|
|
5156
|
+
[READ2](n2, chunk) {
|
|
5157
|
+
if (this[OBJECTMODE2])
|
|
5158
|
+
this[BUFFERSHIFT2]();
|
|
5159
|
+
else {
|
|
5160
|
+
let c = chunk;
|
|
5161
|
+
n2 === c.length || n2 === null ? this[BUFFERSHIFT2]() : typeof c == "string" ? (this[BUFFER2][0] = c.slice(n2), chunk = c.slice(0, n2), this[BUFFERLENGTH2] -= n2) : (this[BUFFER2][0] = c.subarray(n2), chunk = c.subarray(0, n2), this[BUFFERLENGTH2] -= n2);
|
|
5162
|
+
}
|
|
5163
|
+
return this.emit("data", chunk), !this[BUFFER2].length && !this[EOF2] && this.emit("drain"), chunk;
|
|
5164
|
+
}
|
|
5165
|
+
end(chunk, encoding, cb) {
|
|
5166
|
+
return typeof chunk == "function" && (cb = chunk, chunk = void 0), typeof encoding == "function" && (cb = encoding, encoding = "utf8"), chunk !== void 0 && this.write(chunk, encoding), cb && this.once("end", cb), this[EOF2] = !0, this.writable = !1, (this[FLOWING2] || !this[PAUSED2]) && this[MAYBE_EMIT_END2](), this;
|
|
5167
|
+
}
|
|
5168
|
+
// don't let the internal resume be overwritten
|
|
5169
|
+
[RESUME2]() {
|
|
5170
|
+
this[DESTROYED2] || (!this[DATALISTENERS2] && !this[PIPES2].length && (this[DISCARDED2] = !0), this[PAUSED2] = !1, this[FLOWING2] = !0, this.emit("resume"), this[BUFFER2].length ? this[FLUSH2]() : this[EOF2] ? this[MAYBE_EMIT_END2]() : this.emit("drain"));
|
|
5171
|
+
}
|
|
5172
|
+
/**
|
|
5173
|
+
* Resume the stream if it is currently in a paused state
|
|
5174
|
+
*
|
|
5175
|
+
* If called when there are no pipe destinations or `data` event listeners,
|
|
5176
|
+
* this will place the stream in a "discarded" state, where all data will
|
|
5177
|
+
* be thrown away. The discarded state is removed if a pipe destination or
|
|
5178
|
+
* data handler is added, if pause() is called, or if any synchronous or
|
|
5179
|
+
* asynchronous iteration is started.
|
|
5180
|
+
*/
|
|
5181
|
+
resume() {
|
|
5182
|
+
return this[RESUME2]();
|
|
5183
|
+
}
|
|
5184
|
+
/**
|
|
5185
|
+
* Pause the stream
|
|
5186
|
+
*/
|
|
5187
|
+
pause() {
|
|
5188
|
+
this[FLOWING2] = !1, this[PAUSED2] = !0, this[DISCARDED2] = !1;
|
|
5189
|
+
}
|
|
5190
|
+
/**
|
|
5191
|
+
* true if the stream has been forcibly destroyed
|
|
5192
|
+
*/
|
|
5193
|
+
get destroyed() {
|
|
5194
|
+
return this[DESTROYED2];
|
|
5195
|
+
}
|
|
5196
|
+
/**
|
|
5197
|
+
* true if the stream is currently in a flowing state, meaning that
|
|
5198
|
+
* any writes will be immediately emitted.
|
|
5199
|
+
*/
|
|
5200
|
+
get flowing() {
|
|
5201
|
+
return this[FLOWING2];
|
|
5202
|
+
}
|
|
5203
|
+
/**
|
|
5204
|
+
* true if the stream is currently in a paused state
|
|
5205
|
+
*/
|
|
5206
|
+
get paused() {
|
|
5207
|
+
return this[PAUSED2];
|
|
5208
|
+
}
|
|
5209
|
+
[BUFFERPUSH2](chunk) {
|
|
5210
|
+
this[OBJECTMODE2] ? this[BUFFERLENGTH2] += 1 : this[BUFFERLENGTH2] += chunk.length, this[BUFFER2].push(chunk);
|
|
5211
|
+
}
|
|
5212
|
+
[BUFFERSHIFT2]() {
|
|
5213
|
+
return this[OBJECTMODE2] ? this[BUFFERLENGTH2] -= 1 : this[BUFFERLENGTH2] -= this[BUFFER2][0].length, this[BUFFER2].shift();
|
|
5214
|
+
}
|
|
5215
|
+
[FLUSH2](noDrain = !1) {
|
|
5216
|
+
do
|
|
5217
|
+
;
|
|
5218
|
+
while (this[FLUSHCHUNK2](this[BUFFERSHIFT2]()) && this[BUFFER2].length);
|
|
5219
|
+
!noDrain && !this[BUFFER2].length && !this[EOF2] && this.emit("drain");
|
|
5220
|
+
}
|
|
5221
|
+
[FLUSHCHUNK2](chunk) {
|
|
5222
|
+
return this.emit("data", chunk), this[FLOWING2];
|
|
5223
|
+
}
|
|
5224
|
+
/**
|
|
5225
|
+
* Pipe all data emitted by this stream into the destination provided.
|
|
5226
|
+
*
|
|
5227
|
+
* Triggers the flow of data.
|
|
5228
|
+
*/
|
|
5229
|
+
pipe(dest, opts) {
|
|
5230
|
+
if (this[DESTROYED2])
|
|
5231
|
+
return dest;
|
|
5232
|
+
this[DISCARDED2] = !1;
|
|
5233
|
+
let ended = this[EMITTED_END2];
|
|
5234
|
+
return opts = opts || {}, dest === proc2.stdout || dest === proc2.stderr ? opts.end = !1 : opts.end = opts.end !== !1, opts.proxyErrors = !!opts.proxyErrors, ended ? opts.end && dest.end() : (this[PIPES2].push(opts.proxyErrors ? new PipeProxyErrors2(this, dest, opts) : new Pipe2(this, dest, opts)), this[ASYNC2] ? defer2(() => this[RESUME2]()) : this[RESUME2]()), dest;
|
|
5235
|
+
}
|
|
5236
|
+
/**
|
|
5237
|
+
* Fully unhook a piped destination stream.
|
|
5238
|
+
*
|
|
5239
|
+
* If the destination stream was the only consumer of this stream (ie,
|
|
5240
|
+
* there are no other piped destinations or `'data'` event listeners)
|
|
5241
|
+
* then the flow of data will stop until there is another consumer or
|
|
5242
|
+
* {@link Minipass#resume} is explicitly called.
|
|
5243
|
+
*/
|
|
5244
|
+
unpipe(dest) {
|
|
5245
|
+
let p = this[PIPES2].find((p2) => p2.dest === dest);
|
|
5246
|
+
p && (this[PIPES2].length === 1 ? (this[FLOWING2] && this[DATALISTENERS2] === 0 && (this[FLOWING2] = !1), this[PIPES2] = []) : this[PIPES2].splice(this[PIPES2].indexOf(p), 1), p.unpipe());
|
|
5247
|
+
}
|
|
5248
|
+
/**
|
|
5249
|
+
* Alias for {@link Minipass#on}
|
|
5250
|
+
*/
|
|
5251
|
+
addListener(ev, handler) {
|
|
5252
|
+
return this.on(ev, handler);
|
|
5253
|
+
}
|
|
5254
|
+
/**
|
|
5255
|
+
* Mostly identical to `EventEmitter.on`, with the following
|
|
5256
|
+
* behavior differences to prevent data loss and unnecessary hangs:
|
|
5257
|
+
*
|
|
5258
|
+
* - Adding a 'data' event handler will trigger the flow of data
|
|
5259
|
+
*
|
|
5260
|
+
* - Adding a 'readable' event handler when there is data waiting to be read
|
|
5261
|
+
* will cause 'readable' to be emitted immediately.
|
|
5262
|
+
*
|
|
5263
|
+
* - Adding an 'endish' event handler ('end', 'finish', etc.) which has
|
|
5264
|
+
* already passed will cause the event to be emitted immediately and all
|
|
5265
|
+
* handlers removed.
|
|
5266
|
+
*
|
|
5267
|
+
* - Adding an 'error' event handler after an error has been emitted will
|
|
5268
|
+
* cause the event to be re-emitted immediately with the error previously
|
|
5269
|
+
* raised.
|
|
5270
|
+
*/
|
|
5271
|
+
on(ev, handler) {
|
|
5272
|
+
let ret = super.on(ev, handler);
|
|
5273
|
+
if (ev === "data")
|
|
5274
|
+
this[DISCARDED2] = !1, this[DATALISTENERS2]++, !this[PIPES2].length && !this[FLOWING2] && this[RESUME2]();
|
|
5275
|
+
else if (ev === "readable" && this[BUFFERLENGTH2] !== 0)
|
|
5276
|
+
super.emit("readable");
|
|
5277
|
+
else if (isEndish2(ev) && this[EMITTED_END2])
|
|
5278
|
+
super.emit(ev), this.removeAllListeners(ev);
|
|
5279
|
+
else if (ev === "error" && this[EMITTED_ERROR2]) {
|
|
5280
|
+
let h = handler;
|
|
5281
|
+
this[ASYNC2] ? defer2(() => h.call(this, this[EMITTED_ERROR2])) : h.call(this, this[EMITTED_ERROR2]);
|
|
5282
|
+
}
|
|
5283
|
+
return ret;
|
|
5284
|
+
}
|
|
5285
|
+
/**
|
|
5286
|
+
* Alias for {@link Minipass#off}
|
|
5287
|
+
*/
|
|
5288
|
+
removeListener(ev, handler) {
|
|
5289
|
+
return this.off(ev, handler);
|
|
5290
|
+
}
|
|
5291
|
+
/**
|
|
5292
|
+
* Mostly identical to `EventEmitter.off`
|
|
5293
|
+
*
|
|
5294
|
+
* If a 'data' event handler is removed, and it was the last consumer
|
|
5295
|
+
* (ie, there are no pipe destinations or other 'data' event listeners),
|
|
5296
|
+
* then the flow of data will stop until there is another consumer or
|
|
5297
|
+
* {@link Minipass#resume} is explicitly called.
|
|
5298
|
+
*/
|
|
5299
|
+
off(ev, handler) {
|
|
5300
|
+
let ret = super.off(ev, handler);
|
|
5301
|
+
return ev === "data" && (this[DATALISTENERS2] = this.listeners("data").length, this[DATALISTENERS2] === 0 && !this[DISCARDED2] && !this[PIPES2].length && (this[FLOWING2] = !1)), ret;
|
|
5302
|
+
}
|
|
5303
|
+
/**
|
|
5304
|
+
* Mostly identical to `EventEmitter.removeAllListeners`
|
|
5305
|
+
*
|
|
5306
|
+
* If all 'data' event handlers are removed, and they were the last consumer
|
|
5307
|
+
* (ie, there are no pipe destinations), then the flow of data will stop
|
|
5308
|
+
* until there is another consumer or {@link Minipass#resume} is explicitly
|
|
5309
|
+
* called.
|
|
5310
|
+
*/
|
|
5311
|
+
removeAllListeners(ev) {
|
|
5312
|
+
let ret = super.removeAllListeners(ev);
|
|
5313
|
+
return (ev === "data" || ev === void 0) && (this[DATALISTENERS2] = 0, !this[DISCARDED2] && !this[PIPES2].length && (this[FLOWING2] = !1)), ret;
|
|
5314
|
+
}
|
|
5315
|
+
/**
|
|
5316
|
+
* true if the 'end' event has been emitted
|
|
5317
|
+
*/
|
|
5318
|
+
get emittedEnd() {
|
|
5319
|
+
return this[EMITTED_END2];
|
|
5320
|
+
}
|
|
5321
|
+
[MAYBE_EMIT_END2]() {
|
|
5322
|
+
!this[EMITTING_END2] && !this[EMITTED_END2] && !this[DESTROYED2] && this[BUFFER2].length === 0 && this[EOF2] && (this[EMITTING_END2] = !0, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[CLOSED2] && this.emit("close"), this[EMITTING_END2] = !1);
|
|
5323
|
+
}
|
|
5324
|
+
/**
|
|
5325
|
+
* Mostly identical to `EventEmitter.emit`, with the following
|
|
5326
|
+
* behavior differences to prevent data loss and unnecessary hangs:
|
|
5327
|
+
*
|
|
5328
|
+
* If the stream has been destroyed, and the event is something other
|
|
5329
|
+
* than 'close' or 'error', then `false` is returned and no handlers
|
|
5330
|
+
* are called.
|
|
5331
|
+
*
|
|
5332
|
+
* If the event is 'end', and has already been emitted, then the event
|
|
5333
|
+
* is ignored. If the stream is in a paused or non-flowing state, then
|
|
5334
|
+
* the event will be deferred until data flow resumes. If the stream is
|
|
5335
|
+
* async, then handlers will be called on the next tick rather than
|
|
5336
|
+
* immediately.
|
|
5337
|
+
*
|
|
5338
|
+
* If the event is 'close', and 'end' has not yet been emitted, then
|
|
5339
|
+
* the event will be deferred until after 'end' is emitted.
|
|
5340
|
+
*
|
|
5341
|
+
* If the event is 'error', and an AbortSignal was provided for the stream,
|
|
5342
|
+
* and there are no listeners, then the event is ignored, matching the
|
|
5343
|
+
* behavior of node core streams in the presense of an AbortSignal.
|
|
5344
|
+
*
|
|
5345
|
+
* If the event is 'finish' or 'prefinish', then all listeners will be
|
|
5346
|
+
* removed after emitting the event, to prevent double-firing.
|
|
5347
|
+
*/
|
|
5348
|
+
emit(ev, ...args) {
|
|
5349
|
+
let data = args[0];
|
|
5350
|
+
if (ev !== "error" && ev !== "close" && ev !== DESTROYED2 && this[DESTROYED2])
|
|
5351
|
+
return !1;
|
|
5352
|
+
if (ev === "data")
|
|
5353
|
+
return !this[OBJECTMODE2] && !data ? !1 : this[ASYNC2] ? (defer2(() => this[EMITDATA2](data)), !0) : this[EMITDATA2](data);
|
|
5354
|
+
if (ev === "end")
|
|
5355
|
+
return this[EMITEND3]();
|
|
5356
|
+
if (ev === "close") {
|
|
5357
|
+
if (this[CLOSED2] = !0, !this[EMITTED_END2] && !this[DESTROYED2])
|
|
5358
|
+
return !1;
|
|
5359
|
+
let ret2 = super.emit("close");
|
|
5360
|
+
return this.removeAllListeners("close"), ret2;
|
|
5361
|
+
} else if (ev === "error") {
|
|
5362
|
+
this[EMITTED_ERROR2] = data, super.emit(ERROR2, data);
|
|
5363
|
+
let ret2 = !this[SIGNAL2] || this.listeners("error").length ? super.emit("error", data) : !1;
|
|
5364
|
+
return this[MAYBE_EMIT_END2](), ret2;
|
|
5365
|
+
} else if (ev === "resume") {
|
|
5366
|
+
let ret2 = super.emit("resume");
|
|
5367
|
+
return this[MAYBE_EMIT_END2](), ret2;
|
|
5368
|
+
} else if (ev === "finish" || ev === "prefinish") {
|
|
5369
|
+
let ret2 = super.emit(ev);
|
|
5370
|
+
return this.removeAllListeners(ev), ret2;
|
|
5371
|
+
}
|
|
5372
|
+
let ret = super.emit(ev, ...args);
|
|
5373
|
+
return this[MAYBE_EMIT_END2](), ret;
|
|
5374
|
+
}
|
|
5375
|
+
[EMITDATA2](data) {
|
|
5376
|
+
for (let p of this[PIPES2])
|
|
5377
|
+
p.dest.write(data) === !1 && this.pause();
|
|
5378
|
+
let ret = this[DISCARDED2] ? !1 : super.emit("data", data);
|
|
5379
|
+
return this[MAYBE_EMIT_END2](), ret;
|
|
5380
|
+
}
|
|
5381
|
+
[EMITEND3]() {
|
|
5382
|
+
return this[EMITTED_END2] ? !1 : (this[EMITTED_END2] = !0, this.readable = !1, this[ASYNC2] ? (defer2(() => this[EMITEND22]()), !0) : this[EMITEND22]());
|
|
5383
|
+
}
|
|
5384
|
+
[EMITEND22]() {
|
|
5385
|
+
if (this[DECODER2]) {
|
|
5386
|
+
let data = this[DECODER2].end();
|
|
5387
|
+
if (data) {
|
|
5388
|
+
for (let p of this[PIPES2])
|
|
5389
|
+
p.dest.write(data);
|
|
5390
|
+
this[DISCARDED2] || super.emit("data", data);
|
|
5391
|
+
}
|
|
5392
|
+
}
|
|
5393
|
+
for (let p of this[PIPES2])
|
|
5394
|
+
p.end();
|
|
5395
|
+
let ret = super.emit("end");
|
|
5396
|
+
return this.removeAllListeners("end"), ret;
|
|
5397
|
+
}
|
|
5398
|
+
/**
|
|
5399
|
+
* Return a Promise that resolves to an array of all emitted data once
|
|
5400
|
+
* the stream ends.
|
|
5401
|
+
*/
|
|
5402
|
+
async collect() {
|
|
5403
|
+
let buf = Object.assign([], {
|
|
5404
|
+
dataLength: 0
|
|
5405
|
+
});
|
|
5406
|
+
this[OBJECTMODE2] || (buf.dataLength = 0);
|
|
5407
|
+
let p = this.promise();
|
|
5408
|
+
return this.on("data", (c) => {
|
|
5409
|
+
buf.push(c), this[OBJECTMODE2] || (buf.dataLength += c.length);
|
|
5410
|
+
}), await p, buf;
|
|
5411
|
+
}
|
|
5412
|
+
/**
|
|
5413
|
+
* Return a Promise that resolves to the concatenation of all emitted data
|
|
5414
|
+
* once the stream ends.
|
|
5415
|
+
*
|
|
5416
|
+
* Not allowed on objectMode streams.
|
|
5417
|
+
*/
|
|
5418
|
+
async concat() {
|
|
5419
|
+
if (this[OBJECTMODE2])
|
|
5420
|
+
throw new Error("cannot concat in objectMode");
|
|
5421
|
+
let buf = await this.collect();
|
|
5422
|
+
return this[ENCODING2] ? buf.join("") : Buffer.concat(buf, buf.dataLength);
|
|
5423
|
+
}
|
|
5424
|
+
/**
|
|
5425
|
+
* Return a void Promise that resolves once the stream ends.
|
|
5426
|
+
*/
|
|
5427
|
+
async promise() {
|
|
5428
|
+
return new Promise((resolve4, reject) => {
|
|
5429
|
+
this.on(DESTROYED2, () => reject(new Error("stream destroyed"))), this.on("error", (er) => reject(er)), this.on("end", () => resolve4());
|
|
5430
|
+
});
|
|
5431
|
+
}
|
|
5432
|
+
/**
|
|
5433
|
+
* Asynchronous `for await of` iteration.
|
|
5434
|
+
*
|
|
5435
|
+
* This will continue emitting all chunks until the stream terminates.
|
|
5436
|
+
*/
|
|
5437
|
+
[Symbol.asyncIterator]() {
|
|
5438
|
+
this[DISCARDED2] = !1;
|
|
5439
|
+
let stopped = !1, stop = async () => (this.pause(), stopped = !0, { value: void 0, done: !0 });
|
|
5440
|
+
return {
|
|
5441
|
+
next: () => {
|
|
5442
|
+
if (stopped)
|
|
5443
|
+
return stop();
|
|
5444
|
+
let res = this.read();
|
|
5445
|
+
if (res !== null)
|
|
5446
|
+
return Promise.resolve({ done: !1, value: res });
|
|
5447
|
+
if (this[EOF2])
|
|
5448
|
+
return stop();
|
|
5449
|
+
let resolve4, reject, onerr = (er) => {
|
|
5450
|
+
this.off("data", ondata), this.off("end", onend), this.off(DESTROYED2, ondestroy), stop(), reject(er);
|
|
5451
|
+
}, ondata = (value) => {
|
|
5452
|
+
this.off("error", onerr), this.off("end", onend), this.off(DESTROYED2, ondestroy), this.pause(), resolve4({ value, done: !!this[EOF2] });
|
|
5453
|
+
}, onend = () => {
|
|
5454
|
+
this.off("error", onerr), this.off("data", ondata), this.off(DESTROYED2, ondestroy), stop(), resolve4({ done: !0, value: void 0 });
|
|
5455
|
+
}, ondestroy = () => onerr(new Error("stream destroyed"));
|
|
5456
|
+
return new Promise((res2, rej) => {
|
|
5457
|
+
reject = rej, resolve4 = res2, this.once(DESTROYED2, ondestroy), this.once("error", onerr), this.once("end", onend), this.once("data", ondata);
|
|
5458
|
+
});
|
|
5459
|
+
},
|
|
5460
|
+
throw: stop,
|
|
5461
|
+
return: stop,
|
|
5462
|
+
[Symbol.asyncIterator]() {
|
|
5463
|
+
return this;
|
|
5464
|
+
}
|
|
5465
|
+
};
|
|
5466
|
+
}
|
|
5467
|
+
/**
|
|
5468
|
+
* Synchronous `for of` iteration.
|
|
5469
|
+
*
|
|
5470
|
+
* The iteration will terminate when the internal buffer runs out, even
|
|
5471
|
+
* if the stream has not yet terminated.
|
|
5472
|
+
*/
|
|
5473
|
+
[Symbol.iterator]() {
|
|
5474
|
+
this[DISCARDED2] = !1;
|
|
5475
|
+
let stopped = !1, stop = () => (this.pause(), this.off(ERROR2, stop), this.off(DESTROYED2, stop), this.off("end", stop), stopped = !0, { done: !0, value: void 0 }), next = () => {
|
|
5476
|
+
if (stopped)
|
|
5477
|
+
return stop();
|
|
5478
|
+
let value = this.read();
|
|
5479
|
+
return value === null ? stop() : { done: !1, value };
|
|
5480
|
+
};
|
|
5481
|
+
return this.once("end", stop), this.once(ERROR2, stop), this.once(DESTROYED2, stop), {
|
|
5482
|
+
next,
|
|
5483
|
+
throw: stop,
|
|
5484
|
+
return: stop,
|
|
5485
|
+
[Symbol.iterator]() {
|
|
5486
|
+
return this;
|
|
5487
|
+
}
|
|
5488
|
+
};
|
|
5489
|
+
}
|
|
5490
|
+
/**
|
|
5491
|
+
* Destroy a stream, preventing it from being used for any further purpose.
|
|
5492
|
+
*
|
|
5493
|
+
* If the stream has a `close()` method, then it will be called on
|
|
5494
|
+
* destruction.
|
|
5495
|
+
*
|
|
5496
|
+
* After destruction, any attempt to write data, read data, or emit most
|
|
5497
|
+
* events will be ignored.
|
|
5498
|
+
*
|
|
5499
|
+
* If an error argument is provided, then it will be emitted in an
|
|
5500
|
+
* 'error' event.
|
|
5501
|
+
*/
|
|
5502
|
+
destroy(er) {
|
|
5503
|
+
if (this[DESTROYED2])
|
|
5504
|
+
return er ? this.emit("error", er) : this.emit(DESTROYED2), this;
|
|
5505
|
+
this[DESTROYED2] = !0, this[DISCARDED2] = !0, this[BUFFER2].length = 0, this[BUFFERLENGTH2] = 0;
|
|
5506
|
+
let wc = this;
|
|
5507
|
+
return typeof wc.close == "function" && !this[CLOSED2] && wc.close(), er ? this.emit("error", er) : this.emit(DESTROYED2), this;
|
|
5508
|
+
}
|
|
5509
|
+
/**
|
|
5510
|
+
* Alias for {@link isStream}
|
|
5511
|
+
*
|
|
5512
|
+
* Former export location, maintained for backwards compatibility.
|
|
5513
|
+
*
|
|
5514
|
+
* @deprecated
|
|
5515
|
+
*/
|
|
5516
|
+
static get isStream() {
|
|
5517
|
+
return isStream2;
|
|
5518
|
+
}
|
|
5519
|
+
};
|
|
5520
|
+
|
|
5521
|
+
// ../../../node_modules/glob/dist/esm/ignore.js
|
|
5051
5522
|
var defaultPlatform2 = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux", Ignore = class {
|
|
5052
5523
|
relative;
|
|
5053
5524
|
relativeChildren;
|
|
@@ -5104,7 +5575,7 @@ var defaultPlatform2 = typeof process == "object" && process && typeof process.p
|
|
|
5104
5575
|
}
|
|
5105
5576
|
};
|
|
5106
5577
|
|
|
5107
|
-
//
|
|
5578
|
+
// ../../../node_modules/glob/dist/esm/processor.js
|
|
5108
5579
|
var HasWalkedCache = class _HasWalkedCache {
|
|
5109
5580
|
store;
|
|
5110
5581
|
constructor(store = /* @__PURE__ */ new Map()) {
|
|
@@ -5247,7 +5718,7 @@ var HasWalkedCache = class _HasWalkedCache {
|
|
|
5247
5718
|
}
|
|
5248
5719
|
};
|
|
5249
5720
|
|
|
5250
|
-
//
|
|
5721
|
+
// ../../../node_modules/glob/dist/esm/walker.js
|
|
5251
5722
|
var makeIgnore = (ignore, opts) => typeof ignore == "string" ? new Ignore([ignore], opts) : Array.isArray(ignore) ? new Ignore(ignore, opts) : ignore, GlobUtil = class {
|
|
5252
5723
|
path;
|
|
5253
5724
|
patterns;
|
|
@@ -5456,7 +5927,7 @@ var makeIgnore = (ignore, opts) => typeof ignore == "string" ? new Ignore([ignor
|
|
|
5456
5927
|
}, GlobStream = class extends GlobUtil {
|
|
5457
5928
|
results;
|
|
5458
5929
|
constructor(patterns, path2, opts) {
|
|
5459
|
-
super(patterns, path2, opts), this.results = new
|
|
5930
|
+
super(patterns, path2, opts), this.results = new Minipass2({
|
|
5460
5931
|
signal: this.signal,
|
|
5461
5932
|
objectMode: !0
|
|
5462
5933
|
}), this.results.on("drain", () => this.resume()), this.results.on("resume", () => this.resume());
|
|
@@ -5475,7 +5946,7 @@ var makeIgnore = (ignore, opts) => typeof ignore == "string" ? new Ignore([ignor
|
|
|
5475
5946
|
}
|
|
5476
5947
|
};
|
|
5477
5948
|
|
|
5478
|
-
//
|
|
5949
|
+
// ../../../node_modules/glob/dist/esm/glob.js
|
|
5479
5950
|
var defaultPlatform3 = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux", Glob = class {
|
|
5480
5951
|
absolute;
|
|
5481
5952
|
cwd;
|
|
@@ -5628,7 +6099,7 @@ var defaultPlatform3 = typeof process == "object" && process && typeof process.p
|
|
|
5628
6099
|
}
|
|
5629
6100
|
};
|
|
5630
6101
|
|
|
5631
|
-
//
|
|
6102
|
+
// ../../../node_modules/glob/dist/esm/has-magic.js
|
|
5632
6103
|
var hasMagic = (pattern, options = {}) => {
|
|
5633
6104
|
Array.isArray(pattern) || (pattern = [pattern]);
|
|
5634
6105
|
for (let p of pattern)
|
|
@@ -5637,7 +6108,7 @@ var hasMagic = (pattern, options = {}) => {
|
|
|
5637
6108
|
return !1;
|
|
5638
6109
|
};
|
|
5639
6110
|
|
|
5640
|
-
//
|
|
6111
|
+
// ../../../node_modules/glob/dist/esm/index.js
|
|
5641
6112
|
function globStreamSync(pattern, options = {}) {
|
|
5642
6113
|
return new Glob(pattern, options).streamSync();
|
|
5643
6114
|
}
|
|
@@ -5680,7 +6151,7 @@ var streamSync = globStreamSync, stream = Object.assign(globStream, { sync: glob
|
|
|
5680
6151
|
});
|
|
5681
6152
|
glob.glob = glob;
|
|
5682
6153
|
|
|
5683
|
-
//
|
|
6154
|
+
// ../../../node_modules/slash/index.js
|
|
5684
6155
|
function slash(path2) {
|
|
5685
6156
|
return path2.startsWith("\\\\?\\") ? path2 : path2.replace(/\\/g, "/");
|
|
5686
6157
|
}
|
|
@@ -5729,7 +6200,7 @@ import { getFrameworkName, loadPreviewOrConfigFile } from "storybook/internal/co
|
|
|
5729
6200
|
import { STORY_HOT_UPDATED } from "storybook/internal/core-events";
|
|
5730
6201
|
import { isCsfFactoryPreview, readConfig } from "storybook/internal/csf-tools";
|
|
5731
6202
|
|
|
5732
|
-
//
|
|
6203
|
+
// ../../../node_modules/pathe/dist/utils.mjs
|
|
5733
6204
|
var normalizedAliasSymbol = Symbol.for("pathe:normalizedAlias");
|
|
5734
6205
|
var FILENAME_RE = /(^|[/\\])([^/\\]+?)(?=(\.[^.]+)?$)/;
|
|
5735
6206
|
function filename(path2) {
|
|
@@ -5962,12 +6433,12 @@ import { existsSync as existsSync3 } from "node:fs";
|
|
|
5962
6433
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
5963
6434
|
import { dirname as dirname4, join as join6 } from "node:path";
|
|
5964
6435
|
|
|
5965
|
-
//
|
|
6436
|
+
// ../../../node_modules/empathic/package.mjs
|
|
5966
6437
|
import { env } from "node:process";
|
|
5967
6438
|
import { dirname as dirname3, join as join5 } from "node:path";
|
|
5968
6439
|
import { existsSync as existsSync2, mkdirSync } from "node:fs";
|
|
5969
6440
|
|
|
5970
|
-
//
|
|
6441
|
+
// ../../../node_modules/empathic/access.mjs
|
|
5971
6442
|
import { accessSync, constants } from "node:fs";
|
|
5972
6443
|
function ok(path2, mode) {
|
|
5973
6444
|
try {
|
|
@@ -5980,20 +6451,20 @@ function writable(path2) {
|
|
|
5980
6451
|
return ok(path2, constants.W_OK);
|
|
5981
6452
|
}
|
|
5982
6453
|
|
|
5983
|
-
//
|
|
6454
|
+
// ../../../node_modules/empathic/find.mjs
|
|
5984
6455
|
import { join as join4 } from "node:path";
|
|
5985
6456
|
import { existsSync, statSync } from "node:fs";
|
|
5986
6457
|
|
|
5987
|
-
//
|
|
6458
|
+
// ../../../node_modules/empathic/walk.mjs
|
|
5988
6459
|
import { dirname as dirname2 } from "node:path";
|
|
5989
6460
|
|
|
5990
|
-
//
|
|
6461
|
+
// ../../../node_modules/empathic/resolve.mjs
|
|
5991
6462
|
import { isAbsolute as isAbsolute3, join as join3, resolve as resolve2 } from "node:path";
|
|
5992
6463
|
function absolute(input, root) {
|
|
5993
6464
|
return isAbsolute3(input) ? input : resolve2(root || ".", input);
|
|
5994
6465
|
}
|
|
5995
6466
|
|
|
5996
|
-
//
|
|
6467
|
+
// ../../../node_modules/empathic/walk.mjs
|
|
5997
6468
|
function up(base, options) {
|
|
5998
6469
|
let { last, cwd } = options || {}, tmp = absolute(base, cwd), root = absolute(last || "/", cwd), prev, arr = [];
|
|
5999
6470
|
for (; prev !== root && (arr.push(tmp), tmp = dirname2(prev = tmp), tmp !== prev); )
|
|
@@ -6001,14 +6472,14 @@ function up(base, options) {
|
|
|
6001
6472
|
return arr;
|
|
6002
6473
|
}
|
|
6003
6474
|
|
|
6004
|
-
//
|
|
6475
|
+
// ../../../node_modules/empathic/find.mjs
|
|
6005
6476
|
function up2(name, options) {
|
|
6006
6477
|
let dir, tmp, start2 = options && options.cwd || "";
|
|
6007
6478
|
for (dir of up(start2, options))
|
|
6008
6479
|
if (tmp = join4(dir, name), existsSync(tmp)) return tmp;
|
|
6009
6480
|
}
|
|
6010
6481
|
|
|
6011
|
-
//
|
|
6482
|
+
// ../../../node_modules/empathic/package.mjs
|
|
6012
6483
|
function up3(options) {
|
|
6013
6484
|
return up2("package.json", options);
|
|
6014
6485
|
}
|
package/dist/preset.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_ju9fqam8r2 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ju9fqam8r2 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ju9fqam8r2 from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ju9fqam8r2.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ju9fqam8r2.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ju9fqam8r2.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
normalize
|
|
14
|
-
} from "./_node-chunks/chunk-
|
|
14
|
+
} from "./_node-chunks/chunk-33HTNIVD.js";
|
|
15
15
|
|
|
16
16
|
// src/preset.ts
|
|
17
17
|
import { findConfigFile } from "storybook/internal/common";
|
|
@@ -22,7 +22,7 @@ import { join } from "node:path";
|
|
|
22
22
|
import { fileURLToPath } from "node:url";
|
|
23
23
|
import { resolvePackageDir } from "storybook/internal/common";
|
|
24
24
|
|
|
25
|
-
//
|
|
25
|
+
// ../../../node_modules/@rolldown/pluginutils/dist/index.js
|
|
26
26
|
function exactRegex(str, flags) {
|
|
27
27
|
return new RegExp(`^${escapeRegex(str)}$`, flags);
|
|
28
28
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/builder-vite",
|
|
3
|
-
"version": "10.2.0-alpha.
|
|
3
|
+
"version": "10.2.0-alpha.2",
|
|
4
4
|
"description": "A Storybook builder to dev and build with Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -45,12 +45,8 @@
|
|
|
45
45
|
"preset.js",
|
|
46
46
|
"!src/**/*"
|
|
47
47
|
],
|
|
48
|
-
"scripts": {
|
|
49
|
-
"check": "jiti ../../../scripts/check/check-package.ts",
|
|
50
|
-
"prep": "jiti ../../../scripts/build/build-package.ts"
|
|
51
|
-
},
|
|
52
48
|
"dependencies": {
|
|
53
|
-
"@storybook/csf-plugin": "10.2.0-alpha.
|
|
49
|
+
"@storybook/csf-plugin": "10.2.0-alpha.2",
|
|
54
50
|
"@vitest/mocker": "3.2.4",
|
|
55
51
|
"ts-dedent": "^2.0.0"
|
|
56
52
|
},
|
|
@@ -66,7 +62,7 @@
|
|
|
66
62
|
"vite": "^7.0.4"
|
|
67
63
|
},
|
|
68
64
|
"peerDependencies": {
|
|
69
|
-
"storybook": "^10.2.0-alpha.
|
|
65
|
+
"storybook": "^10.2.0-alpha.2",
|
|
70
66
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
71
67
|
},
|
|
72
68
|
"publishConfig": {
|