storybook
Version:
Storybook: Develop, document, and test UI components in isolation
1,129 lines (1,111 loc) • 359 kB
JavaScript
import CJS_COMPAT_NODE_URL_yr66iw5gef from 'node:url';
import CJS_COMPAT_NODE_PATH_yr66iw5gef from 'node:path';
import CJS_COMPAT_NODE_MODULE_yr66iw5gef from "node:module";
var __filename = CJS_COMPAT_NODE_URL_yr66iw5gef.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_yr66iw5gef.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_yr66iw5gef.createRequire(import.meta.url);
// ------------------------------------------------------------
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
// ------------------------------------------------------------
import {
StatusTypeIdMismatchError
} from "../_node-chunks/chunk-DMPGFWI4.js";
import {
debounce,
getErrorLevel,
isTelemetryEnabled,
mapStaticDir,
parseStaticDir,
sendTelemetryError,
useStatics,
withTelemetry
} from "../_node-chunks/chunk-6KX7N5UF.js";
import "../_node-chunks/chunk-COZFRL72.js";
import {
detectPnp
} from "../_node-chunks/chunk-5UYX4ZF6.js";
import {
StorybookError
} from "../_node-chunks/chunk-LJRKMWYC.js";
import {
telemetry
} from "../_node-chunks/chunk-7KESMTGS.js";
import "../_node-chunks/chunk-CMI5GRPA.js";
import {
optionalEnvToBoolean,
require_cross_spawn,
resolveImport,
supportedExtensions,
userOrAutoTitleFromSpecifier
} from "../_node-chunks/chunk-QZJSO2TW.js";
import "../_node-chunks/chunk-4FAPWW5I.js";
import "../_node-chunks/chunk-4X3VTYIW.js";
import {
require_pretty_hrtime
} from "../_node-chunks/chunk-VUIYVJKC.js";
import "../_node-chunks/chunk-N54KYQ6P.js";
import "../_node-chunks/chunk-S3DQCJWT.js";
import {
invariant,
up2 as up
} from "../_node-chunks/chunk-2IIRK2OT.js";
import {
importModule,
resolvePackageDir
} from "../_node-chunks/chunk-Q6B5LJGA.js";
import "../_node-chunks/chunk-FMYFRXPU.js";
import {
dirname,
join,
relative,
resolve
} from "../_node-chunks/chunk-VBZIULNK.js";
import "../_node-chunks/chunk-F2RDEFFH.js";
import {
slash
} from "../_node-chunks/chunk-GVOXGNOU.js";
import {
require_dist
} from "../_node-chunks/chunk-76KIYDRU.js";
import {
require_lib,
require_src
} from "../_node-chunks/chunk-MZL4HRPC.js";
import {
require_picocolors
} from "../_node-chunks/chunk-RZ2YFNVH.js";
import {
__commonJS,
__require,
__toESM
} from "../_node-chunks/chunk-J4VC4I2M.js";
// ../node_modules/tsconfig-paths/lib/filesystem.js
var require_filesystem = __commonJS({
"../node_modules/tsconfig-paths/lib/filesystem.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: !0 });
exports.removeExtension = exports.fileExistsAsync = exports.readJsonFromDiskAsync = exports.readJsonFromDiskSync = exports.fileExistsSync = void 0;
var fs6 = __require("fs");
function fileExistsSync(path3) {
if (!fs6.existsSync(path3))
return !1;
try {
var stats = fs6.statSync(path3);
return stats.isFile();
} catch {
return !1;
}
}
exports.fileExistsSync = fileExistsSync;
function readJsonFromDiskSync(packageJsonPath) {
if (fs6.existsSync(packageJsonPath))
return __require(packageJsonPath);
}
exports.readJsonFromDiskSync = readJsonFromDiskSync;
function readJsonFromDiskAsync(path3, callback) {
fs6.readFile(path3, "utf8", function(err, result) {
if (err || !result)
return callback();
var json = JSON.parse(result);
return callback(void 0, json);
});
}
exports.readJsonFromDiskAsync = readJsonFromDiskAsync;
function fileExistsAsync(path22, callback2) {
fs6.stat(path22, function(err, stats) {
if (err)
return callback2(void 0, !1);
callback2(void 0, stats ? stats.isFile() : !1);
});
}
exports.fileExistsAsync = fileExistsAsync;
function removeExtension(path3) {
return path3.substring(0, path3.lastIndexOf(".")) || path3;
}
exports.removeExtension = removeExtension;
}
});
// ../node_modules/tsconfig-paths/lib/mapping-entry.js
var require_mapping_entry = __commonJS({
"../node_modules/tsconfig-paths/lib/mapping-entry.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: !0 });
exports.getAbsoluteMappingEntries = void 0;
var path3 = __require("path");
function getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll) {
for (var sortedKeys = sortByLongestPrefix(Object.keys(paths)), absolutePaths = [], _i = 0, sortedKeys_1 = sortedKeys; _i < sortedKeys_1.length; _i++) {
var key = sortedKeys_1[_i];
absolutePaths.push({
pattern: key,
paths: paths[key].map(function(pathToResolve) {
return path3.resolve(absoluteBaseUrl, pathToResolve);
})
});
}
return !paths["*"] && addMatchAll && absolutePaths.push({
pattern: "*",
paths: ["".concat(absoluteBaseUrl.replace(/\/$/, ""), "/*")]
}), absolutePaths;
}
exports.getAbsoluteMappingEntries = getAbsoluteMappingEntries;
function sortByLongestPrefix(arr) {
return arr.concat().sort(function(a, b) {
return getPrefixLength(b) - getPrefixLength(a);
});
}
function getPrefixLength(pattern) {
var prefixLength = pattern.indexOf("*");
return pattern.substr(0, prefixLength).length;
}
}
});
// ../node_modules/tsconfig-paths/lib/try-path.js
var require_try_path = __commonJS({
"../node_modules/tsconfig-paths/lib/try-path.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: !0 });
exports.exhaustiveTypeException = exports.getStrippedPath = exports.getPathsToTry = void 0;
var path3 = __require("path"), path_1 = __require("path"), filesystem_1 = require_filesystem();
function getPathsToTry(extensions, absolutePathMappings, requestedModule) {
if (!(!absolutePathMappings || !requestedModule || requestedModule[0] === ".")) {
for (var pathsToTry = [], _i = 0, absolutePathMappings_1 = absolutePathMappings; _i < absolutePathMappings_1.length; _i++) {
var entry = absolutePathMappings_1[_i], starMatch = entry.pattern === requestedModule ? "" : matchStar(entry.pattern, requestedModule);
if (starMatch !== void 0)
for (var _loop_1 = function(physicalPathPattern2) {
var physicalPath = physicalPathPattern2.replace("*", starMatch);
pathsToTry.push({ type: "file", path: physicalPath }), pathsToTry.push.apply(pathsToTry, extensions.map(function(e) {
return { type: "extension", path: physicalPath + e };
})), pathsToTry.push({
type: "package",
path: path3.join(physicalPath, "/package.json")
});
var indexPath = path3.join(physicalPath, "/index");
pathsToTry.push.apply(pathsToTry, extensions.map(function(e) {
return { type: "index", path: indexPath + e };
}));
}, _a = 0, _b = entry.paths; _a < _b.length; _a++) {
var physicalPathPattern = _b[_a];
_loop_1(physicalPathPattern);
}
}
return pathsToTry.length === 0 ? void 0 : pathsToTry;
}
}
exports.getPathsToTry = getPathsToTry;
function getStrippedPath(tryPath) {
return tryPath.type === "index" ? (0, path_1.dirname)(tryPath.path) : tryPath.type === "file" ? tryPath.path : tryPath.type === "extension" ? (0, filesystem_1.removeExtension)(tryPath.path) : tryPath.type === "package" ? tryPath.path : exhaustiveTypeException(tryPath.type);
}
exports.getStrippedPath = getStrippedPath;
function exhaustiveTypeException(check) {
throw new Error("Unknown type ".concat(check));
}
exports.exhaustiveTypeException = exhaustiveTypeException;
function matchStar(pattern, search) {
if (!(search.length < pattern.length)) {
if (pattern === "*")
return search;
var star = pattern.indexOf("*");
if (star !== -1) {
var part1 = pattern.substring(0, star), part2 = pattern.substring(star + 1);
if (search.substr(0, star) === part1 && search.substr(search.length - part2.length) === part2)
return search.substr(star, search.length - part2.length);
}
}
}
}
});
// ../node_modules/tsconfig-paths/lib/match-path-sync.js
var require_match_path_sync = __commonJS({
"../node_modules/tsconfig-paths/lib/match-path-sync.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: !0 });
exports.matchFromAbsolutePaths = exports.createMatchPath = void 0;
var path3 = __require("path"), Filesystem = require_filesystem(), MappingEntry = require_mapping_entry(), TryPath = require_try_path();
function createMatchPath2(absoluteBaseUrl, paths, mainFields, addMatchAll) {
mainFields === void 0 && (mainFields = ["main"]), addMatchAll === void 0 && (addMatchAll = !0);
var absolutePaths = MappingEntry.getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll);
return function(requestedModule, readJson, fileExists2, extensions) {
return matchFromAbsolutePaths(absolutePaths, requestedModule, readJson, fileExists2, extensions, mainFields);
};
}
exports.createMatchPath = createMatchPath2;
function matchFromAbsolutePaths(absolutePathMappings, requestedModule, readJson, fileExists2, extensions, mainFields) {
readJson === void 0 && (readJson = Filesystem.readJsonFromDiskSync), fileExists2 === void 0 && (fileExists2 = Filesystem.fileExistsSync), extensions === void 0 && (extensions = Object.keys(__require.extensions)), mainFields === void 0 && (mainFields = ["main"]);
var tryPaths = TryPath.getPathsToTry(extensions, absolutePathMappings, requestedModule);
if (tryPaths)
return findFirstExistingPath(tryPaths, readJson, fileExists2, mainFields);
}
exports.matchFromAbsolutePaths = matchFromAbsolutePaths;
function findFirstExistingMainFieldMappedFile(packageJson, mainFields, packageJsonPath, fileExists2) {
for (var index = 0; index < mainFields.length; index++) {
var mainFieldSelector = mainFields[index], candidateMapping = typeof mainFieldSelector == "string" ? packageJson[mainFieldSelector] : mainFieldSelector.reduce(function(obj, key) {
return obj[key];
}, packageJson);
if (candidateMapping && typeof candidateMapping == "string") {
var candidateFilePath = path3.join(path3.dirname(packageJsonPath), candidateMapping);
if (fileExists2(candidateFilePath))
return candidateFilePath;
}
}
}
function findFirstExistingPath(tryPaths, readJson, fileExists2, mainFields) {
readJson === void 0 && (readJson = Filesystem.readJsonFromDiskSync), mainFields === void 0 && (mainFields = ["main"]);
for (var _i = 0, tryPaths_1 = tryPaths; _i < tryPaths_1.length; _i++) {
var tryPath = tryPaths_1[_i];
if (tryPath.type === "file" || tryPath.type === "extension" || tryPath.type === "index") {
if (fileExists2(tryPath.path))
return TryPath.getStrippedPath(tryPath);
} else if (tryPath.type === "package") {
var packageJson = readJson(tryPath.path);
if (packageJson) {
var mainFieldMappedFile = findFirstExistingMainFieldMappedFile(packageJson, mainFields, tryPath.path, fileExists2);
if (mainFieldMappedFile)
return mainFieldMappedFile;
}
} else
TryPath.exhaustiveTypeException(tryPath.type);
}
}
}
});
// ../node_modules/tsconfig-paths/lib/match-path-async.js
var require_match_path_async = __commonJS({
"../node_modules/tsconfig-paths/lib/match-path-async.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: !0 });
exports.matchFromAbsolutePathsAsync = exports.createMatchPathAsync = void 0;
var path3 = __require("path"), TryPath = require_try_path(), MappingEntry = require_mapping_entry(), Filesystem = require_filesystem();
function createMatchPathAsync(absoluteBaseUrl, paths, mainFields, addMatchAll) {
mainFields === void 0 && (mainFields = ["main"]), addMatchAll === void 0 && (addMatchAll = !0);
var absolutePaths = MappingEntry.getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll);
return function(requestedModule, readJson, fileExists2, extensions, callback) {
return matchFromAbsolutePathsAsync(absolutePaths, requestedModule, readJson, fileExists2, extensions, callback, mainFields);
};
}
exports.createMatchPathAsync = createMatchPathAsync;
function matchFromAbsolutePathsAsync(absolutePathMappings, requestedModule, readJson, fileExists2, extensions, callback, mainFields) {
readJson === void 0 && (readJson = Filesystem.readJsonFromDiskAsync), fileExists2 === void 0 && (fileExists2 = Filesystem.fileExistsAsync), extensions === void 0 && (extensions = Object.keys(__require.extensions)), mainFields === void 0 && (mainFields = ["main"]);
var tryPaths = TryPath.getPathsToTry(extensions, absolutePathMappings, requestedModule);
if (!tryPaths)
return callback();
findFirstExistingPath(tryPaths, readJson, fileExists2, callback, 0, mainFields);
}
exports.matchFromAbsolutePathsAsync = matchFromAbsolutePathsAsync;
function findFirstExistingMainFieldMappedFile(packageJson, mainFields, packageJsonPath, fileExistsAsync, doneCallback, index) {
if (index === void 0 && (index = 0), index >= mainFields.length)
return doneCallback(void 0, void 0);
var tryNext = function() {
return findFirstExistingMainFieldMappedFile(packageJson, mainFields, packageJsonPath, fileExistsAsync, doneCallback, index + 1);
}, mainFieldSelector = mainFields[index], mainFieldMapping = typeof mainFieldSelector == "string" ? packageJson[mainFieldSelector] : mainFieldSelector.reduce(function(obj, key) {
return obj[key];
}, packageJson);
if (typeof mainFieldMapping != "string")
return tryNext();
var mappedFilePath = path3.join(path3.dirname(packageJsonPath), mainFieldMapping);
fileExistsAsync(mappedFilePath, function(err, exists) {
return err ? doneCallback(err) : exists ? doneCallback(void 0, mappedFilePath) : tryNext();
});
}
function findFirstExistingPath(tryPaths, readJson, fileExists2, doneCallback, index, mainFields) {
index === void 0 && (index = 0), mainFields === void 0 && (mainFields = ["main"]);
var tryPath = tryPaths[index];
tryPath.type === "file" || tryPath.type === "extension" || tryPath.type === "index" ? fileExists2(tryPath.path, function(err, exists) {
return err ? doneCallback(err) : exists ? doneCallback(void 0, TryPath.getStrippedPath(tryPath)) : index === tryPaths.length - 1 ? doneCallback() : findFirstExistingPath(tryPaths, readJson, fileExists2, doneCallback, index + 1, mainFields);
}) : tryPath.type === "package" ? readJson(tryPath.path, function(err, packageJson) {
return err ? doneCallback(err) : packageJson ? findFirstExistingMainFieldMappedFile(packageJson, mainFields, tryPath.path, fileExists2, function(mainFieldErr, mainFieldMappedFile) {
return mainFieldErr ? doneCallback(mainFieldErr) : mainFieldMappedFile ? doneCallback(void 0, mainFieldMappedFile) : findFirstExistingPath(tryPaths, readJson, fileExists2, doneCallback, index + 1, mainFields);
}) : findFirstExistingPath(tryPaths, readJson, fileExists2, doneCallback, index + 1, mainFields);
}) : TryPath.exhaustiveTypeException(tryPath.type);
}
}
});
// ../node_modules/strip-bom/index.js
var require_strip_bom = __commonJS({
"../node_modules/strip-bom/index.js"(exports, module) {
"use strict";
module.exports = (x) => {
if (typeof x != "string")
throw new TypeError("Expected a string, got " + typeof x);
return x.charCodeAt(0) === 65279 ? x.slice(1) : x;
};
}
});
// ../node_modules/tsconfig-paths/lib/tsconfig-loader.js
var require_tsconfig_loader = __commonJS({
"../node_modules/tsconfig-paths/lib/tsconfig-loader.js"(exports) {
"use strict";
var __assign = exports && exports.__assign || function() {
return __assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
}
return t;
}, __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: !0 });
exports.loadTsconfig = exports.walkForTsConfig = exports.tsConfigLoader = void 0;
var path3 = __require("path"), fs6 = __require("fs"), JSON5 = require_lib(), StripBom = require_strip_bom();
function tsConfigLoader(_a) {
var getEnv = _a.getEnv, cwd = _a.cwd, _b = _a.loadSync, loadSync = _b === void 0 ? loadSyncDefault : _b, TS_NODE_PROJECT = getEnv("TS_NODE_PROJECT"), TS_NODE_BASEURL = getEnv("TS_NODE_BASEURL"), loadResult = loadSync(cwd, TS_NODE_PROJECT, TS_NODE_BASEURL);
return loadResult;
}
exports.tsConfigLoader = tsConfigLoader;
function loadSyncDefault(cwd, filename, baseUrl) {
var configPath = resolveConfigPath(cwd, filename);
if (!configPath)
return {
tsConfigPath: void 0,
baseUrl: void 0,
paths: void 0
};
var config = loadTsconfig(configPath);
return {
tsConfigPath: configPath,
baseUrl: baseUrl || config && config.compilerOptions && config.compilerOptions.baseUrl,
paths: config && config.compilerOptions && config.compilerOptions.paths
};
}
function resolveConfigPath(cwd, filename) {
if (filename) {
var absolutePath = fs6.lstatSync(filename).isDirectory() ? path3.resolve(filename, "./tsconfig.json") : path3.resolve(cwd, filename);
return absolutePath;
}
if (fs6.statSync(cwd).isFile())
return path3.resolve(cwd);
var configAbsolutePath = walkForTsConfig(cwd);
return configAbsolutePath ? path3.resolve(configAbsolutePath) : void 0;
}
function walkForTsConfig(directory, readdirSync2) {
readdirSync2 === void 0 && (readdirSync2 = fs6.readdirSync);
for (var files = readdirSync2(directory), filesToCheck = ["tsconfig.json", "jsconfig.json"], _i = 0, filesToCheck_1 = filesToCheck; _i < filesToCheck_1.length; _i++) {
var fileToCheck = filesToCheck_1[_i];
if (files.indexOf(fileToCheck) !== -1)
return path3.join(directory, fileToCheck);
}
var parentDirectory = path3.dirname(directory);
if (directory !== parentDirectory)
return walkForTsConfig(parentDirectory, readdirSync2);
}
exports.walkForTsConfig = walkForTsConfig;
function loadTsconfig(configFilePath, existsSync3, readFileSync) {
if (existsSync3 === void 0 && (existsSync3 = fs6.existsSync), readFileSync === void 0 && (readFileSync = function(filename) {
return fs6.readFileSync(filename, "utf8");
}), !!existsSync3(configFilePath)) {
var configString = readFileSync(configFilePath), cleanedJson = StripBom(configString), config;
try {
config = JSON5.parse(cleanedJson);
} catch (e) {
throw new Error("".concat(configFilePath, " is malformed ").concat(e.message));
}
var extendedConfig = config.extends;
if (extendedConfig) {
var base = void 0;
return Array.isArray(extendedConfig) ? base = extendedConfig.reduce(function(currBase, extendedConfigElement) {
return mergeTsconfigs(currBase, loadTsconfigFromExtends(configFilePath, extendedConfigElement, existsSync3, readFileSync));
}, {}) : base = loadTsconfigFromExtends(configFilePath, extendedConfig, existsSync3, readFileSync), mergeTsconfigs(base, config);
}
return config;
}
}
exports.loadTsconfig = loadTsconfig;
function loadTsconfigFromExtends(configFilePath, extendedConfigValue, existsSync3, readFileSync) {
var _a;
typeof extendedConfigValue == "string" && extendedConfigValue.indexOf(".json") === -1 && (extendedConfigValue += ".json");
var currentDir = path3.dirname(configFilePath), extendedConfigPath = path3.join(currentDir, extendedConfigValue);
extendedConfigValue.indexOf("/") !== -1 && extendedConfigValue.indexOf(".") !== -1 && !existsSync3(extendedConfigPath) && (extendedConfigPath = path3.join(currentDir, "node_modules", extendedConfigValue));
var config = loadTsconfig(extendedConfigPath, existsSync3, readFileSync) || {};
if (!((_a = config.compilerOptions) === null || _a === void 0) && _a.baseUrl) {
var extendsDir = path3.dirname(extendedConfigValue);
config.compilerOptions.baseUrl = path3.join(extendsDir, config.compilerOptions.baseUrl);
}
return config;
}
function mergeTsconfigs(base, config) {
return base = base || {}, config = config || {}, __assign(__assign(__assign({}, base), config), { compilerOptions: __assign(__assign({}, base.compilerOptions), config.compilerOptions) });
}
}
});
// ../node_modules/tsconfig-paths/lib/config-loader.js
var require_config_loader = __commonJS({
"../node_modules/tsconfig-paths/lib/config-loader.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: !0 });
exports.configLoader = exports.loadConfig = void 0;
var TsConfigLoader2 = require_tsconfig_loader(), path3 = __require("path");
function loadConfig3(cwd) {
return cwd === void 0 && (cwd = process.cwd()), configLoader({ cwd });
}
exports.loadConfig = loadConfig3;
function configLoader(_a) {
var cwd = _a.cwd, explicitParams = _a.explicitParams, _b = _a.tsConfigLoader, tsConfigLoader = _b === void 0 ? TsConfigLoader2.tsConfigLoader : _b;
if (explicitParams) {
var absoluteBaseUrl = path3.isAbsolute(explicitParams.baseUrl) ? explicitParams.baseUrl : path3.join(cwd, explicitParams.baseUrl);
return {
resultType: "success",
configFileAbsolutePath: "",
baseUrl: explicitParams.baseUrl,
absoluteBaseUrl,
paths: explicitParams.paths,
mainFields: explicitParams.mainFields,
addMatchAll: explicitParams.addMatchAll
};
}
var loadResult = tsConfigLoader({
cwd,
getEnv: function(key) {
return process.env[key];
}
});
return loadResult.tsConfigPath ? {
resultType: "success",
configFileAbsolutePath: loadResult.tsConfigPath,
baseUrl: loadResult.baseUrl,
absoluteBaseUrl: path3.resolve(path3.dirname(loadResult.tsConfigPath), loadResult.baseUrl || ""),
paths: loadResult.paths || {},
addMatchAll: loadResult.baseUrl !== void 0
} : {
resultType: "failed",
message: "Couldn't find tsconfig.json"
};
}
exports.configLoader = configLoader;
}
});
// ../node_modules/minimist/index.js
var require_minimist = __commonJS({
"../node_modules/minimist/index.js"(exports, module) {
"use strict";
function hasKey(obj, keys) {
var o = obj;
keys.slice(0, -1).forEach(function(key2) {
o = o[key2] || {};
});
var key = keys[keys.length - 1];
return key in o;
}
function isNumber(x) {
return typeof x == "number" || /^0x[0-9a-f]+$/i.test(x) ? !0 : /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
}
function isConstructorOrProto(obj, key) {
return key === "constructor" && typeof obj[key] == "function" || key === "__proto__";
}
module.exports = function(args, opts) {
opts || (opts = {});
var flags = {
bools: {},
strings: {},
unknownFn: null
};
typeof opts.unknown == "function" && (flags.unknownFn = opts.unknown), typeof opts.boolean == "boolean" && opts.boolean ? flags.allBools = !0 : [].concat(opts.boolean).filter(Boolean).forEach(function(key2) {
flags.bools[key2] = !0;
});
var aliases = {};
function aliasIsBoolean(key2) {
return aliases[key2].some(function(x) {
return flags.bools[x];
});
}
Object.keys(opts.alias || {}).forEach(function(key2) {
aliases[key2] = [].concat(opts.alias[key2]), aliases[key2].forEach(function(x) {
aliases[x] = [key2].concat(aliases[key2].filter(function(y) {
return x !== y;
}));
});
}), [].concat(opts.string).filter(Boolean).forEach(function(key2) {
flags.strings[key2] = !0, aliases[key2] && [].concat(aliases[key2]).forEach(function(k) {
flags.strings[k] = !0;
});
});
var defaults = opts.default || {}, argv = { _: [] };
function argDefined(key2, arg2) {
return flags.allBools && /^--[^=]+$/.test(arg2) || flags.strings[key2] || flags.bools[key2] || aliases[key2];
}
function setKey(obj, keys, value2) {
for (var o = obj, i2 = 0; i2 < keys.length - 1; i2++) {
var key2 = keys[i2];
if (isConstructorOrProto(o, key2))
return;
o[key2] === void 0 && (o[key2] = {}), (o[key2] === Object.prototype || o[key2] === Number.prototype || o[key2] === String.prototype) && (o[key2] = {}), o[key2] === Array.prototype && (o[key2] = []), o = o[key2];
}
var lastKey = keys[keys.length - 1];
isConstructorOrProto(o, lastKey) || ((o === Object.prototype || o === Number.prototype || o === String.prototype) && (o = {}), o === Array.prototype && (o = []), o[lastKey] === void 0 || flags.bools[lastKey] || typeof o[lastKey] == "boolean" ? o[lastKey] = value2 : Array.isArray(o[lastKey]) ? o[lastKey].push(value2) : o[lastKey] = [o[lastKey], value2]);
}
function setArg(key2, val, arg2) {
if (!(arg2 && flags.unknownFn && !argDefined(key2, arg2) && flags.unknownFn(arg2) === !1)) {
var value2 = !flags.strings[key2] && isNumber(val) ? Number(val) : val;
setKey(argv, key2.split("."), value2), (aliases[key2] || []).forEach(function(x) {
setKey(argv, x.split("."), value2);
});
}
}
Object.keys(flags.bools).forEach(function(key2) {
setArg(key2, defaults[key2] === void 0 ? !1 : defaults[key2]);
});
var notFlags = [];
args.indexOf("--") !== -1 && (notFlags = args.slice(args.indexOf("--") + 1), args = args.slice(0, args.indexOf("--")));
for (var i = 0; i < args.length; i++) {
var arg = args[i], key, next;
if (/^--.+=/.test(arg)) {
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
key = m[1];
var value = m[2];
flags.bools[key] && (value = value !== "false"), setArg(key, value, arg);
} else if (/^--no-.+/.test(arg))
key = arg.match(/^--no-(.+)/)[1], setArg(key, !1, arg);
else if (/^--.+/.test(arg))
key = arg.match(/^--(.+)/)[1], next = args[i + 1], next !== void 0 && !/^(-|--)[^-]/.test(next) && !flags.bools[key] && !flags.allBools && (!aliases[key] || !aliasIsBoolean(key)) ? (setArg(key, next, arg), i += 1) : /^(true|false)$/.test(next) ? (setArg(key, next === "true", arg), i += 1) : setArg(key, flags.strings[key] ? "" : !0, arg);
else if (/^-[^-]+/.test(arg)) {
for (var letters = arg.slice(1, -1).split(""), broken = !1, j = 0; j < letters.length; j++) {
if (next = arg.slice(j + 2), next === "-") {
setArg(letters[j], next, arg);
continue;
}
if (/[A-Za-z]/.test(letters[j]) && next[0] === "=") {
setArg(letters[j], next.slice(1), arg), broken = !0;
break;
}
if (/[A-Za-z]/.test(letters[j]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
setArg(letters[j], next, arg), broken = !0;
break;
}
if (letters[j + 1] && letters[j + 1].match(/\W/)) {
setArg(letters[j], arg.slice(j + 2), arg), broken = !0;
break;
} else
setArg(letters[j], flags.strings[letters[j]] ? "" : !0, arg);
}
key = arg.slice(-1)[0], !broken && key !== "-" && (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && !flags.bools[key] && (!aliases[key] || !aliasIsBoolean(key)) ? (setArg(key, args[i + 1], arg), i += 1) : args[i + 1] && /^(true|false)$/.test(args[i + 1]) ? (setArg(key, args[i + 1] === "true", arg), i += 1) : setArg(key, flags.strings[key] ? "" : !0, arg));
} else if ((!flags.unknownFn || flags.unknownFn(arg) !== !1) && argv._.push(flags.strings._ || !isNumber(arg) ? arg : Number(arg)), opts.stopEarly) {
argv._.push.apply(argv._, args.slice(i + 1));
break;
}
}
return Object.keys(defaults).forEach(function(k) {
hasKey(argv, k.split(".")) || (setKey(argv, k.split("."), defaults[k]), (aliases[k] || []).forEach(function(x) {
setKey(argv, x.split("."), defaults[k]);
}));
}), opts["--"] ? argv["--"] = notFlags.slice() : notFlags.forEach(function(k) {
argv._.push(k);
}), argv;
};
}
});
// ../node_modules/tsconfig-paths/lib/register.js
var require_register = __commonJS({
"../node_modules/tsconfig-paths/lib/register.js"(exports) {
"use strict";
var __spreadArray = exports && exports.__spreadArray || function(to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++)
(ar || !(i in from)) && (ar || (ar = Array.prototype.slice.call(from, 0, i)), ar[i] = from[i]);
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: !0 });
exports.register = void 0;
var match_path_sync_1 = require_match_path_sync(), config_loader_1 = require_config_loader(), noOp = function() {
};
function getCoreModules(builtinModules) {
builtinModules = builtinModules || [
"assert",
"buffer",
"child_process",
"cluster",
"crypto",
"dgram",
"dns",
"domain",
"events",
"fs",
"http",
"https",
"net",
"os",
"path",
"punycode",
"querystring",
"readline",
"stream",
"string_decoder",
"tls",
"tty",
"url",
"util",
"v8",
"vm",
"zlib"
];
for (var coreModules = {}, _i = 0, builtinModules_1 = builtinModules; _i < builtinModules_1.length; _i++) {
var module_1 = builtinModules_1[_i];
coreModules[module_1] = !0;
}
return coreModules;
}
function register(params) {
var cwd, explicitParams;
if (params)
cwd = params.cwd, (params.baseUrl || params.paths) && (explicitParams = params);
else {
var minimist = require_minimist(), argv = minimist(process.argv.slice(2), {
// eslint-disable-next-line id-denylist
string: ["project"],
alias: {
project: ["P"]
}
});
cwd = argv.project;
}
var configLoaderResult = (0, config_loader_1.configLoader)({
cwd: cwd ?? process.cwd(),
explicitParams
});
if (configLoaderResult.resultType === "failed")
return console.warn("".concat(configLoaderResult.message, ". tsconfig-paths will be skipped")), noOp;
var matchPath = (0, match_path_sync_1.createMatchPath)(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths, configLoaderResult.mainFields, configLoaderResult.addMatchAll), Module = __require("module"), originalResolveFilename = Module._resolveFilename, coreModules = getCoreModules(Module.builtinModules);
return Module._resolveFilename = function(request, _parent) {
var isCoreModule = coreModules.hasOwnProperty(request);
if (!isCoreModule) {
var found = matchPath(request);
if (found) {
var modifiedArguments = __spreadArray([found], [].slice.call(arguments, 1), !0);
return originalResolveFilename.apply(this, modifiedArguments);
}
}
return originalResolveFilename.apply(this, arguments);
}, function() {
Module._resolveFilename = originalResolveFilename;
};
}
exports.register = register;
}
});
// ../node_modules/tsconfig-paths/lib/index.js
var require_lib2 = __commonJS({
"../node_modules/tsconfig-paths/lib/index.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: !0 });
exports.loadConfig = exports.register = exports.matchFromAbsolutePathsAsync = exports.createMatchPathAsync = exports.matchFromAbsolutePaths = exports.createMatchPath = void 0;
var match_path_sync_1 = require_match_path_sync();
Object.defineProperty(exports, "createMatchPath", { enumerable: !0, get: function() {
return match_path_sync_1.createMatchPath;
} });
Object.defineProperty(exports, "matchFromAbsolutePaths", { enumerable: !0, get: function() {
return match_path_sync_1.matchFromAbsolutePaths;
} });
var match_path_async_1 = require_match_path_async();
Object.defineProperty(exports, "createMatchPathAsync", { enumerable: !0, get: function() {
return match_path_async_1.createMatchPathAsync;
} });
Object.defineProperty(exports, "matchFromAbsolutePathsAsync", { enumerable: !0, get: function() {
return match_path_async_1.matchFromAbsolutePathsAsync;
} });
var register_1 = require_register();
Object.defineProperty(exports, "register", { enumerable: !0, get: function() {
return register_1.register;
} });
var config_loader_1 = require_config_loader();
Object.defineProperty(exports, "loadConfig", { enumerable: !0, get: function() {
return config_loader_1.loadConfig;
} });
}
});
// ../node_modules/@discoveryjs/json-ext/package.json
var require_package = __commonJS({
"../node_modules/@discoveryjs/json-ext/package.json"(exports, module) {
module.exports = {
name: "@discoveryjs/json-ext",
version: "0.5.7",
description: "A set of utilities that extend the use of JSON",
keywords: [
"json",
"utils",
"stream",
"async",
"promise",
"stringify",
"info"
],
author: "Roman Dvornov <rdvornov@gmail.com> (https://github.com/lahmatiy)",
license: "MIT",
repository: "discoveryjs/json-ext",
main: "./src/index",
browser: {
"./src/stringify-stream.js": "./src/stringify-stream-browser.js",
"./src/text-decoder.js": "./src/text-decoder-browser.js",
"./src/version.js": "./dist/version.js"
},
types: "./index.d.ts",
scripts: {
test: "mocha --reporter progress",
lint: "eslint src test",
"lint-and-test": "npm run lint && npm test",
build: "rollup --config",
"test:all": "npm run test:src && npm run test:dist",
"test:src": "npm test",
"test:dist": "cross-env MODE=dist npm test && cross-env MODE=dist-min npm test",
"build-and-test": "npm run build && npm run test:dist",
coverage: "c8 --reporter=lcovonly npm test",
prepublishOnly: "npm run lint && npm test && npm run build-and-test"
},
devDependencies: {
"@rollup/plugin-commonjs": "^15.1.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
c8: "^7.10.0",
chalk: "^4.1.0",
"cross-env": "^7.0.3",
eslint: "^8.10.0",
mocha: "^8.4.0",
rollup: "^2.28.2",
"rollup-plugin-terser": "^7.0.2"
},
engines: {
node: ">=10.0.0"
},
files: [
"dist",
"src",
"index.d.ts"
]
};
}
});
// ../node_modules/@discoveryjs/json-ext/src/version.js
var require_version = __commonJS({
"../node_modules/@discoveryjs/json-ext/src/version.js"(exports, module) {
module.exports = require_package().version;
}
});
// ../node_modules/@discoveryjs/json-ext/src/utils.js
var require_utils = __commonJS({
"../node_modules/@discoveryjs/json-ext/src/utils.js"(exports, module) {
var escapableCharCodeSubstitution = {
// JSON Single Character Escape Sequences
8: "\\b",
9: "\\t",
10: "\\n",
12: "\\f",
13: "\\r",
34: '\\"',
92: "\\\\"
};
function isLeadingSurrogate(code) {
return code >= 55296 && code <= 56319;
}
function isTrailingSurrogate(code) {
return code >= 56320 && code <= 57343;
}
function isReadableStream(value) {
return typeof value.pipe == "function" && typeof value._read == "function" && typeof value._readableState == "object" && value._readableState !== null;
}
function replaceValue(holder, key, value, replacer) {
switch (value && typeof value.toJSON == "function" && (value = value.toJSON()), replacer !== null && (value = replacer.call(holder, String(key), value)), typeof value) {
case "function":
case "symbol":
value = void 0;
break;
case "object":
if (value !== null) {
let cls = value.constructor;
(cls === String || cls === Number || cls === Boolean) && (value = value.valueOf());
}
break;
}
return value;
}
function getTypeNative(value) {
return value === null || typeof value != "object" ? 1 : Array.isArray(value) ? 3 : 2;
}
function getTypeAsync(value) {
return value === null || typeof value != "object" ? 1 : typeof value.then == "function" ? 4 : isReadableStream(value) ? value._readableState.objectMode ? 6 : 5 : Array.isArray(value) ? 3 : 2;
}
function normalizeReplacer(replacer) {
return typeof replacer == "function" ? replacer : Array.isArray(replacer) ? [...new Set(
replacer.map((item) => {
let cls = item && item.constructor;
return cls === String || cls === Number ? String(item) : null;
}).filter((item) => typeof item == "string")
)] : null;
}
function normalizeSpace(space) {
return typeof space == "number" ? !Number.isFinite(space) || space < 1 ? !1 : " ".repeat(Math.min(space, 10)) : typeof space == "string" && space.slice(0, 10) || !1;
}
module.exports = {
escapableCharCodeSubstitution,
isLeadingSurrogate,
isTrailingSurrogate,
type: {
PRIMITIVE: 1,
PROMISE: 4,
ARRAY: 3,
OBJECT: 2,
STRING_STREAM: 5,
OBJECT_STREAM: 6
},
isReadableStream,
replaceValue,
getTypeNative,
getTypeAsync,
normalizeReplacer,
normalizeSpace
};
}
});
// ../node_modules/@discoveryjs/json-ext/src/stringify-info.js
var require_stringify_info = __commonJS({
"../node_modules/@discoveryjs/json-ext/src/stringify-info.js"(exports, module) {
var {
normalizeReplacer,
normalizeSpace,
replaceValue,
getTypeNative,
getTypeAsync,
isLeadingSurrogate,
isTrailingSurrogate,
escapableCharCodeSubstitution,
type: {
PRIMITIVE,
OBJECT,
ARRAY,
PROMISE,
STRING_STREAM,
OBJECT_STREAM
}
} = require_utils(), charLength2048 = Array.from({ length: 2048 }).map((_, code) => escapableCharCodeSubstitution.hasOwnProperty(code) ? 2 : code < 32 ? 6 : code < 128 ? 1 : 2);
function stringLength(str) {
let len = 0, prevLeadingSurrogate = !1;
for (let i = 0; i < str.length; i++) {
let code = str.charCodeAt(i);
if (code < 2048)
len += charLength2048[code];
else if (isLeadingSurrogate(code)) {
len += 6, prevLeadingSurrogate = !0;
continue;
} else isTrailingSurrogate(code) ? len = prevLeadingSurrogate ? len - 2 : len + 6 : len += 3;
prevLeadingSurrogate = !1;
}
return len + 2;
}
function primitiveLength(value) {
switch (typeof value) {
case "string":
return stringLength(value);
case "number":
return Number.isFinite(value) ? String(value).length : 4;
case "boolean":
return value ? 4 : 5;
case "undefined":
case "object":
return 4;
/* null */
default:
return 0;
}
}
function spaceLength(space) {
return space = normalizeSpace(space), typeof space == "string" ? space.length : 0;
}
module.exports = function(value, replacer, space, options) {
function walk(holder, key, value2) {
if (stop)
return;
value2 = replaceValue(holder, key, value2, replacer);
let type = getType(value2);
if (type !== PRIMITIVE && stack.has(value2)) {
circular.add(value2), length += 4, options.continueOnCircular || (stop = !0);
return;
}
switch (type) {
case PRIMITIVE:
value2 !== void 0 || Array.isArray(holder) ? length += primitiveLength(value2) : holder === root && (length += 9);
break;
case OBJECT: {
if (visited.has(value2)) {
duplicate.add(value2), length += visited.get(value2);
break;
}
let valueLength = length, entries = 0;
length += 2, stack.add(value2);
for (let key2 in value2)
if (hasOwnProperty.call(value2, key2) && (allowlist === null || allowlist.has(key2))) {
let prevLength = length;
walk(value2, key2, value2[key2]), prevLength !== length && (length += stringLength(key2) + 1, entries++);
}
entries > 1 && (length += entries - 1), stack.delete(value2), space > 0 && entries > 0 && (length += (1 + (stack.size + 1) * space + 1) * entries, length += 1 + stack.size * space), visited.set(value2, length - valueLength);
break;
}
case ARRAY: {
if (visited.has(value2)) {
duplicate.add(value2), length += visited.get(value2);
break;
}
let valueLength = length;
length += 2, stack.add(value2);
for (let i = 0; i < value2.length; i++)
walk(value2, i, value2[i]);
value2.length > 1 && (length += value2.length - 1), stack.delete(value2), space > 0 && value2.length > 0 && (length += (1 + (stack.size + 1) * space) * value2.length, length += 1 + stack.size * space), visited.set(value2, length - valueLength);
break;
}
case PROMISE:
case STRING_STREAM:
async.add(value2);
break;
case OBJECT_STREAM:
length += 2, async.add(value2);
break;
}
}
let allowlist = null;
replacer = normalizeReplacer(replacer), Array.isArray(replacer) && (allowlist = new Set(replacer), replacer = null), space = spaceLength(space), options = options || {};
let visited = /* @__PURE__ */ new Map(), stack = /* @__PURE__ */ new Set(), duplicate = /* @__PURE__ */ new Set(), circular = /* @__PURE__ */ new Set(), async = /* @__PURE__ */ new Set(), getType = options.async ? getTypeAsync : getTypeNative, root = { "": value }, stop = !1, length = 0;
return walk(root, "", value), {
minLength: isNaN(length) ? 1 / 0 : length,
circular: [...circular],
duplicate: [...duplicate],
async: [...async]
};
};
}
});
// ../node_modules/@discoveryjs/json-ext/src/stringify-stream.js
var require_stringify_stream = __commonJS({
"../node_modules/@discoveryjs/json-ext/src/stringify-stream.js"(exports, module) {
var { Readable } = __require("stream"), {
normalizeReplacer,
normalizeSpace,
replaceValue,
getTypeAsync,
type: {
PRIMITIVE,
OBJECT,
ARRAY,
PROMISE,
STRING_STREAM,
OBJECT_STREAM
}
} = require_utils(), noop = () => {
}, hasOwnProperty2 = Object.prototype.hasOwnProperty, wellformedStringStringify = JSON.stringify("\uD800") === '"\\ud800"' ? JSON.stringify : (s) => JSON.stringify(s).replace(
new RegExp("\\p{Surrogate}", "gu"),
(m) => `\\u${m.charCodeAt(0).toString(16)}`
);
function push() {
this.push(this._stack.value), this.popStack();
}
function pushPrimitive(value) {
switch (typeof value) {
case "string":
this.push(this.encodeString(value));
break;
case "number":
this.push(Number.isFinite(value) ? this.encodeNumber(value) : "null");
break;
case "boolean":
this.push(value ? "true" : "false");
break;
case "undefined":
case "object":
this.push("null");
break;
default:
this.destroy(new TypeError(`Do not know how to serialize a ${value.constructor && value.constructor.name || typeof value}`));
}
}
function processObjectEntry(key) {
let current = this._stack;
current.first ? this.push(",") : current.first = !0, this.space ? this.push(`
${this.space.repeat(this._depth)}${this.encodeString(key)}: `) : this.push(this.encodeString(key) + ":");
}
function processObject() {
let current = this._stack;
if (current.index === current.keys.length) {
this.space && current.first ? this.push(`
${this.space.repeat(this._depth - 1)}}`) : this.push("}"), this.popStack();
return;
}
let key = current.keys[current.index];
this.processValue(current.value, key, current.value[key], processObjectEntry), current.index++;
}
function processArrayItem(index) {
index !== 0 && this.push(","), this.space && this.push(`
${this.space.repeat(this._depth)}`);
}
function processArray() {
let current = this._stack;
if (current.index === current.value.length) {
this.space && current.index > 0 ? this.push(`
${this.space.repeat(this._depth - 1)}]`) : this.push("]"), this.popStack();
return;
}
this.processValue(current.value, current.index, current.value[current.index], processArrayItem), current.index++;
}
function createStreamReader(fn) {
return function() {
let current = this._stack, data = current.value.read(this._readSize);
data !== null ? (current.first = !1, fn.call(this, data, current)) : current.first && !current.value._readableState.reading || current.ended ? this.popStack() : (current.first = !0, current.awaiting = !0);
};
}
var processReadableObject = createStreamReader(function(data, current) {
this.processValue(current.value, current.index, data, processArrayItem), current.index++;
}), processReadableString = createStreamReader(function(data) {
this.push(data);
}), JsonStringifyStream = class extends Readable {
constructor(value, replacer, space) {
if (super({
autoDestroy: !0
}), this.getKeys = Object.keys, this.replacer = normalizeReplacer(replacer), Array.isArray(this.replacer)) {
let allowlist = this.replacer;
this.getKeys = (value2) => allowlist.filter((key) => hasOwnProperty2.call(value2, key)), this.replacer = null;
}
this.space = normalizeSpace(space), this._depth = 0, this.error = null, this._processing = !1, this._ended = !1, this._readSize = 0, this._buffer = "", this._stack = null, this._visited = /* @__PURE__ */ new WeakSet(), this.pushStack({
handler: () => {
this.popStack(), this.processValue({ "": value }, "", value, noop);
}
});
}
encodeString(value) {
return /[^\x20-\uD799]|[\x22\x5c]/.test(value) ? wellformedStringStringify(value) : '"' + value + '"';
}
encodeNumber(value) {
return value;
}
processValue(holder, key, value, callback) {
value = replaceValue(holder, key, value, this.replacer);
let type = getTypeAsync(value);
switch (type) {
case PRIMITIVE:
(callback !== processObjectEntry || value !== void 0) && (callback.call(this, key), pushPrimitive.call(this, value));
break;
case OBJECT:
if (callback.call(this, key), this._visited.has(value))
return this.destroy(new TypeError("Converting circular structure to JSON"));
this._visited.add(value), this._depth++, this.push("{"), this.pushStack({
handler: processObject,
value,
index: 0,
first: !1,
keys: this.getKeys(value)
});
break;
case ARRAY:
if (callback.call(this, key), this._visited.has(value))
return this.destroy(new TypeError("Converting circular structure to JSON"));
this._visited.add(value), this.push("["), this.pushStack({
handler: processArray,
value,
index: 0
}), this._depth++;
break;
case PROMISE:
this.pushStack({
handler: noop,
awaiting: !0
}), Promise.resolve(value).then((resolved) => {
this.popStack(), this.processValue(holder, key, resolved, callback), this.processStack();
}).catch((error) => {
this.destroy(error);
});
break;
case STRING_STREAM:
case OBJECT_STREAM:
if (callback.call(this, key), value.readableEnded || value._readableState.endEmitted)
return this.destroy(new Error("Readable Stream has ended before it was serialized. All stream data have been lost"));
if (valu