vite
Version:
Native-ESM powered web dev build tool
1,528 lines (1,512 loc) • 1.33 MB
JavaScript
import { a as __toCommonJS, i as __require, n as __esmMin, o as __toDynamicImportESM, r as __export, s as __toESM, t as __commonJSMin } from "./chunk.js";
import { A as OPTIMIZABLE_ENTRY_RE, C as ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR, D as JS_TYPES_RE, E as FS_PREFIX, F as defaultAllowedOrigins, I as loopbackHosts, L as wildcardHosts, M as SPECIAL_QUERY_RE, N as VERSION, O as KNOWN_ASSET_TYPES, P as VITE_PACKAGE_DIR, R as require_picocolors, S as ENV_PUBLIC_PATH, T as ESBUILD_BASELINE_WIDELY_AVAILABLE_TARGET, _ as DEFAULT_SERVER_CONDITIONS, a as CLIENT_ENTRY, b as DEV_PROD_CONDITION, c as DEFAULT_ASSETS_INLINE_LIMIT, d as DEFAULT_CLIENT_MAIN_FIELDS, f as DEFAULT_CONFIG_FILES, g as DEFAULT_PREVIEW_PORT, h as DEFAULT_EXTERNAL_CONDITIONS, i as CLIENT_DIR, j as ROLLUP_HOOKS, k as METADATA_FILENAME, l as DEFAULT_ASSETS_RE, m as DEFAULT_EXTENSIONS, n as createLogger, o as CLIENT_PUBLIC_PATH, p as DEFAULT_DEV_PORT, r as printServerUrls, s as CSS_LANGS_RE, t as LogLevels, u as DEFAULT_CLIENT_CONDITIONS, v as DEFAULT_SERVER_MAIN_FIELDS, w as ERR_OPTIMIZE_DEPS_PROCESSING_ERROR, x as ENV_ENTRY, y as DEP_VERSION_RE } from "./logger.js";
import { builtinModules, createRequire } from "node:module";
import { parseAst, parseAstAsync } from "rollup/parseAst";
import * as fs$1 from "node:fs";
import fs, { existsSync, promises, readFileSync } from "node:fs";
import path, { basename, dirname, extname, isAbsolute, join, normalize, posix, relative, resolve, sep } from "node:path";
import fsp, { constants } from "node:fs/promises";
import { URL as URL$1, fileURLToPath, pathToFileURL } from "node:url";
import { format, formatWithOptions, inspect, promisify, stripVTControlCharacters } from "node:util";
import { performance as performance$1 } from "node:perf_hooks";
import crypto from "node:crypto";
import picomatch from "picomatch";
import esbuild, { build, formatMessages, transform } from "esbuild";
import os from "node:os";
import net from "node:net";
import childProcess, { exec, execFile, execSync } from "node:child_process";
import { promises as promises$1 } from "node:dns";
import { isatty } from "node:tty";
import path$1, { basename as basename$1, dirname as dirname$1, extname as extname$1, isAbsolute as isAbsolute$1, join as join$1, posix as posix$1, relative as relative$1, resolve as resolve$1, sep as sep$1, win32 } from "path";
import { existsSync as existsSync$1, readFileSync as readFileSync$1, readdirSync, statSync } from "fs";
import { fdir } from "fdir";
import { gzip } from "node:zlib";
import readline from "node:readline";
import { createRequire as createRequire$1 } from "module";
import { MessageChannel, Worker } from "node:worker_threads";
import isModuleSyncConditionEnabled from "#module-sync-enabled";
import assert from "node:assert";
import process$1 from "node:process";
import v8 from "node:v8";
import { escapePath, glob, globSync, isDynamicPattern } from "tinyglobby";
import { Buffer as Buffer$1 } from "node:buffer";
import { EventEmitter } from "node:events";
import { STATUS_CODES, createServer, get } from "node:http";
import { createServer as createServer$1, get as get$1 } from "node:https";
import { ESModulesEvaluator, ModuleRunner, createNodeImportMeta } from "vite/module-runner";
import zlib from "zlib";
import * as qs from "node:querystring";
//#region src/shared/constants.ts
/**
* Prefix for resolved Ids that are not valid browser import specifiers
*/
const VALID_ID_PREFIX = `/@id/`;
/**
* Plugins that use 'virtual modules' (e.g. for helper functions), prefix the
* module ID with `\0`, a convention from the rollup ecosystem.
* This prevents other plugins from trying to process the id (like node resolution),
* and core features like sourcemaps can use this info to differentiate between
* virtual modules and regular files.
* `\0` is not a permitted char in import URLs so we have to replace them during
* import analysis. The id will be decoded back before entering the plugins pipeline.
* These encoded virtual ids are also prefixed by the VALID_ID_PREFIX, so virtual
* modules in the browser end up encoded as `/@id/__x00__{id}`
*/
const NULL_BYTE_PLACEHOLDER = `__x00__`;
let SOURCEMAPPING_URL = "sourceMa";
SOURCEMAPPING_URL += "ppingURL";
const MODULE_RUNNER_SOURCEMAPPING_SOURCE = "//# sourceMappingSource=vite-generated";
const ERR_OUTDATED_OPTIMIZED_DEP = "ERR_OUTDATED_OPTIMIZED_DEP";
//#endregion
//#region src/shared/utils.ts
const isWindows = typeof process !== "undefined" && process.platform === "win32";
/**
* Prepend `/@id/` and replace null byte so the id is URL-safe.
* This is prepended to resolved ids that are not valid browser
* import specifiers by the importAnalysis plugin.
*/
function wrapId(id) {
return id.startsWith(VALID_ID_PREFIX) ? id : VALID_ID_PREFIX + id.replace("\0", NULL_BYTE_PLACEHOLDER);
}
/**
* Undo {@link wrapId}'s `/@id/` and null byte replacements.
*/
function unwrapId(id) {
return id.startsWith(VALID_ID_PREFIX) ? id.slice(VALID_ID_PREFIX.length).replace(NULL_BYTE_PLACEHOLDER, "\0") : id;
}
const windowsSlashRE = /\\/g;
function slash(p) {
return p.replace(windowsSlashRE, "/");
}
const postfixRE = /[?#].*$/;
function cleanUrl(url$3) {
return url$3.replace(postfixRE, "");
}
function splitFileAndPostfix(path$13) {
const file = cleanUrl(path$13);
return {
file,
postfix: path$13.slice(file.length)
};
}
function withTrailingSlash(path$13) {
if (path$13[path$13.length - 1] !== "/") return `${path$13}/`;
return path$13;
}
function promiseWithResolvers() {
let resolve$4;
let reject;
return {
promise: new Promise((_resolve, _reject) => {
resolve$4 = _resolve;
reject = _reject;
}),
resolve: resolve$4,
reject
};
}
//#endregion
//#region src/module-runner/importMetaResolver.ts
const customizationHookNamespace = "vite-module-runner:import-meta-resolve/v1/";
const customizationHooksModule = `
export async function resolve(specifier, context, nextResolve) {
if (specifier.startsWith(${JSON.stringify(customizationHookNamespace)})) {
const data = specifier.slice(${JSON.stringify(customizationHookNamespace)}.length)
const [parsedSpecifier, parsedImporter] = JSON.parse(data)
specifier = parsedSpecifier
context.parentURL = parsedImporter
}
return nextResolve(specifier, context)
}
`;
function customizationHookResolve(specifier, context, nextResolve) {
if (specifier.startsWith(customizationHookNamespace)) {
const data = specifier.slice(42);
const [parsedSpecifier, parsedImporter] = JSON.parse(data);
specifier = parsedSpecifier;
context.parentURL = parsedImporter;
}
return nextResolve(specifier, context);
}
async function createImportMetaResolver() {
let module$1;
try {
module$1 = (await import("node:module")).Module;
} catch {
return;
}
if (!module$1) return;
if (module$1.registerHooks) {
module$1.registerHooks({ resolve: customizationHookResolve });
return importMetaResolveWithCustomHook;
}
if (!module$1.register) return;
try {
const hookModuleContent = `data:text/javascript,${encodeURI(customizationHooksModule)}`;
module$1.register(hookModuleContent);
} catch (e$1) {
if ("code" in e$1 && e$1.code === "ERR_NETWORK_IMPORT_DISALLOWED") return;
throw e$1;
}
return importMetaResolveWithCustomHook;
}
function importMetaResolveWithCustomHook(specifier, importer) {
return import.meta.resolve(`${customizationHookNamespace}${JSON.stringify([specifier, importer])}`);
}
const importMetaResolveWithCustomHookString = `
(() => {
const resolve = 'resolve'
return (specifier, importer) =>
import.meta[resolve](
\`${customizationHookNamespace}\${JSON.stringify([specifier, importer])}\`,
)
})()
`;
//#endregion
//#region ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
var comma = ",".charCodeAt(0);
var semicolon = ";".charCodeAt(0);
var chars$1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var intToChar = new Uint8Array(64);
var charToInt = new Uint8Array(128);
for (let i$1 = 0; i$1 < chars$1.length; i$1++) {
const c = chars$1.charCodeAt(i$1);
intToChar[i$1] = c;
charToInt[c] = i$1;
}
function decodeInteger(reader, relative$3) {
let value$1 = 0;
let shift = 0;
let integer = 0;
do {
integer = charToInt[reader.next()];
value$1 |= (integer & 31) << shift;
shift += 5;
} while (integer & 32);
const shouldNegate = value$1 & 1;
value$1 >>>= 1;
if (shouldNegate) value$1 = -2147483648 | -value$1;
return relative$3 + value$1;
}
function encodeInteger(builder, num, relative$3) {
let delta = num - relative$3;
delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
do {
let clamped = delta & 31;
delta >>>= 5;
if (delta > 0) clamped |= 32;
builder.write(intToChar[clamped]);
} while (delta > 0);
return num;
}
function hasMoreVlq(reader, max) {
if (reader.pos >= max) return false;
return reader.peek() !== comma;
}
var bufLength = 1024 * 16;
var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? { decode(buf) {
return Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength).toString();
} } : { decode(buf) {
let out = "";
for (let i$1 = 0; i$1 < buf.length; i$1++) out += String.fromCharCode(buf[i$1]);
return out;
} };
var StringWriter = class {
constructor() {
this.pos = 0;
this.out = "";
this.buffer = new Uint8Array(bufLength);
}
write(v) {
const { buffer } = this;
buffer[this.pos++] = v;
if (this.pos === bufLength) {
this.out += td.decode(buffer);
this.pos = 0;
}
}
flush() {
const { buffer, out, pos } = this;
return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
}
};
var StringReader = class {
constructor(buffer) {
this.pos = 0;
this.buffer = buffer;
}
next() {
return this.buffer.charCodeAt(this.pos++);
}
peek() {
return this.buffer.charCodeAt(this.pos);
}
indexOf(char) {
const { buffer, pos } = this;
const idx = buffer.indexOf(char, pos);
return idx === -1 ? buffer.length : idx;
}
};
function decode(mappings) {
const { length } = mappings;
const reader = new StringReader(mappings);
const decoded = [];
let genColumn = 0;
let sourcesIndex = 0;
let sourceLine = 0;
let sourceColumn = 0;
let namesIndex = 0;
do {
const semi = reader.indexOf(";");
const line = [];
let sorted = true;
let lastCol = 0;
genColumn = 0;
while (reader.pos < semi) {
let seg;
genColumn = decodeInteger(reader, genColumn);
if (genColumn < lastCol) sorted = false;
lastCol = genColumn;
if (hasMoreVlq(reader, semi)) {
sourcesIndex = decodeInteger(reader, sourcesIndex);
sourceLine = decodeInteger(reader, sourceLine);
sourceColumn = decodeInteger(reader, sourceColumn);
if (hasMoreVlq(reader, semi)) {
namesIndex = decodeInteger(reader, namesIndex);
seg = [
genColumn,
sourcesIndex,
sourceLine,
sourceColumn,
namesIndex
];
} else seg = [
genColumn,
sourcesIndex,
sourceLine,
sourceColumn
];
} else seg = [genColumn];
line.push(seg);
reader.pos++;
}
if (!sorted) sort(line);
decoded.push(line);
reader.pos = semi + 1;
} while (reader.pos <= length);
return decoded;
}
function sort(line) {
line.sort(sortComparator$1);
}
function sortComparator$1(a, b) {
return a[0] - b[0];
}
function encode$1(decoded) {
const writer = new StringWriter();
let sourcesIndex = 0;
let sourceLine = 0;
let sourceColumn = 0;
let namesIndex = 0;
for (let i$1 = 0; i$1 < decoded.length; i$1++) {
const line = decoded[i$1];
if (i$1 > 0) writer.write(semicolon);
if (line.length === 0) continue;
let genColumn = 0;
for (let j = 0; j < line.length; j++) {
const segment = line[j];
if (j > 0) writer.write(comma);
genColumn = encodeInteger(writer, segment[0], genColumn);
if (segment.length === 1) continue;
sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
sourceLine = encodeInteger(writer, segment[2], sourceLine);
sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
if (segment.length === 4) continue;
namesIndex = encodeInteger(writer, segment[4], namesIndex);
}
}
return writer.flush();
}
//#endregion
//#region ../../node_modules/.pnpm/@jridgewell+resolve-uri@3.1.2/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs
const schemeRegex = /^[\w+.-]+:\/\//;
/**
* Matches the parts of a URL:
* 1. Scheme, including ":", guaranteed.
* 2. User/password, including "@", optional.
* 3. Host, guaranteed.
* 4. Port, including ":", optional.
* 5. Path, including "/", optional.
* 6. Query, including "?", optional.
* 7. Hash, including "#", optional.
*/
const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
/**
* File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start
* with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).
*
* 1. Host, optional.
* 2. Path, which may include "/", guaranteed.
* 3. Query, including "?", optional.
* 4. Hash, including "#", optional.
*/
const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
function isAbsoluteUrl(input) {
return schemeRegex.test(input);
}
function isSchemeRelativeUrl(input) {
return input.startsWith("//");
}
function isAbsolutePath(input) {
return input.startsWith("/");
}
function isFileUrl(input) {
return input.startsWith("file:");
}
function isRelative(input) {
return /^[.?#]/.test(input);
}
function parseAbsoluteUrl(input) {
const match = urlRegex.exec(input);
return makeUrl(match[1], match[2] || "", match[3], match[4] || "", match[5] || "/", match[6] || "", match[7] || "");
}
function parseFileUrl(input) {
const match = fileRegex.exec(input);
const path$13 = match[2];
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path$13) ? path$13 : "/" + path$13, match[3] || "", match[4] || "");
}
function makeUrl(scheme, user, host, port, path$13, query, hash$1) {
return {
scheme,
user,
host,
port,
path: path$13,
query,
hash: hash$1,
type: 7
};
}
function parseUrl$3(input) {
if (isSchemeRelativeUrl(input)) {
const url$4 = parseAbsoluteUrl("http:" + input);
url$4.scheme = "";
url$4.type = 6;
return url$4;
}
if (isAbsolutePath(input)) {
const url$4 = parseAbsoluteUrl("http://foo.com" + input);
url$4.scheme = "";
url$4.host = "";
url$4.type = 5;
return url$4;
}
if (isFileUrl(input)) return parseFileUrl(input);
if (isAbsoluteUrl(input)) return parseAbsoluteUrl(input);
const url$3 = parseAbsoluteUrl("http://foo.com/" + input);
url$3.scheme = "";
url$3.host = "";
url$3.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
return url$3;
}
function stripPathFilename(path$13) {
if (path$13.endsWith("/..")) return path$13;
const index = path$13.lastIndexOf("/");
return path$13.slice(0, index + 1);
}
function mergePaths(url$3, base) {
normalizePath$4(base, base.type);
if (url$3.path === "/") url$3.path = base.path;
else url$3.path = stripPathFilename(base.path) + url$3.path;
}
/**
* The path can have empty directories "//", unneeded parents "foo/..", or current directory
* "foo/.". We need to normalize to a standard representation.
*/
function normalizePath$4(url$3, type) {
const rel = type <= 4;
const pieces = url$3.path.split("/");
let pointer = 1;
let positive = 0;
let addTrailingSlash = false;
for (let i$1 = 1; i$1 < pieces.length; i$1++) {
const piece = pieces[i$1];
if (!piece) {
addTrailingSlash = true;
continue;
}
addTrailingSlash = false;
if (piece === ".") continue;
if (piece === "..") {
if (positive) {
addTrailingSlash = true;
positive--;
pointer--;
} else if (rel) pieces[pointer++] = piece;
continue;
}
pieces[pointer++] = piece;
positive++;
}
let path$13 = "";
for (let i$1 = 1; i$1 < pointer; i$1++) path$13 += "/" + pieces[i$1];
if (!path$13 || addTrailingSlash && !path$13.endsWith("/..")) path$13 += "/";
url$3.path = path$13;
}
/**
* Attempts to resolve `input` URL/path relative to `base`.
*/
function resolve$3(input, base) {
if (!input && !base) return "";
const url$3 = parseUrl$3(input);
let inputType = url$3.type;
if (base && inputType !== 7) {
const baseUrl = parseUrl$3(base);
const baseType = baseUrl.type;
switch (inputType) {
case 1: url$3.hash = baseUrl.hash;
case 2: url$3.query = baseUrl.query;
case 3:
case 4: mergePaths(url$3, baseUrl);
case 5:
url$3.user = baseUrl.user;
url$3.host = baseUrl.host;
url$3.port = baseUrl.port;
case 6: url$3.scheme = baseUrl.scheme;
}
if (baseType > inputType) inputType = baseType;
}
normalizePath$4(url$3, inputType);
const queryHash = url$3.query + url$3.hash;
switch (inputType) {
case 2:
case 3: return queryHash;
case 4: {
const path$13 = url$3.path.slice(1);
if (!path$13) return queryHash || ".";
if (isRelative(base || input) && !isRelative(path$13)) return "./" + path$13 + queryHash;
return path$13 + queryHash;
}
case 5: return url$3.path + queryHash;
default: return url$3.scheme + "//" + url$3.user + url$3.host + url$3.port + url$3.path + queryHash;
}
}
//#endregion
//#region ../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs
function stripFilename(path$13) {
if (!path$13) return "";
const index = path$13.lastIndexOf("/");
return path$13.slice(0, index + 1);
}
function resolver(mapUrl, sourceRoot) {
const from = stripFilename(mapUrl);
const prefix = sourceRoot ? sourceRoot + "/" : "";
return (source) => resolve$3(prefix + (source || ""), from);
}
var COLUMN$1 = 0;
var SOURCES_INDEX$1 = 1;
var SOURCE_LINE$1 = 2;
var SOURCE_COLUMN$1 = 3;
var NAMES_INDEX$1 = 4;
function maybeSort(mappings, owned) {
const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
if (unsortedIndex === mappings.length) return mappings;
if (!owned) mappings = mappings.slice();
for (let i$1 = unsortedIndex; i$1 < mappings.length; i$1 = nextUnsortedSegmentLine(mappings, i$1 + 1)) mappings[i$1] = sortSegments(mappings[i$1], owned);
return mappings;
}
function nextUnsortedSegmentLine(mappings, start) {
for (let i$1 = start; i$1 < mappings.length; i$1++) if (!isSorted(mappings[i$1])) return i$1;
return mappings.length;
}
function isSorted(line) {
for (let j = 1; j < line.length; j++) if (line[j][COLUMN$1] < line[j - 1][COLUMN$1]) return false;
return true;
}
function sortSegments(line, owned) {
if (!owned) line = line.slice();
return line.sort(sortComparator);
}
function sortComparator(a, b) {
return a[COLUMN$1] - b[COLUMN$1];
}
var found = false;
function binarySearch(haystack, needle, low, high) {
while (low <= high) {
const mid = low + (high - low >> 1);
const cmp = haystack[mid][COLUMN$1] - needle;
if (cmp === 0) {
found = true;
return mid;
}
if (cmp < 0) low = mid + 1;
else high = mid - 1;
}
found = false;
return low - 1;
}
function upperBound(haystack, needle, index) {
for (let i$1 = index + 1; i$1 < haystack.length; index = i$1++) if (haystack[i$1][COLUMN$1] !== needle) break;
return index;
}
function lowerBound(haystack, needle, index) {
for (let i$1 = index - 1; i$1 >= 0; index = i$1--) if (haystack[i$1][COLUMN$1] !== needle) break;
return index;
}
function memoizedState() {
return {
lastKey: -1,
lastNeedle: -1,
lastIndex: -1
};
}
function memoizedBinarySearch(haystack, needle, state, key) {
const { lastKey, lastNeedle, lastIndex } = state;
let low = 0;
let high = haystack.length - 1;
if (key === lastKey) {
if (needle === lastNeedle) {
found = lastIndex !== -1 && haystack[lastIndex][COLUMN$1] === needle;
return lastIndex;
}
if (needle >= lastNeedle) low = lastIndex === -1 ? 0 : lastIndex;
else high = lastIndex;
}
state.lastKey = key;
state.lastNeedle = needle;
return state.lastIndex = binarySearch(haystack, needle, low, high);
}
function parse$14(map$1) {
return typeof map$1 === "string" ? JSON.parse(map$1) : map$1;
}
var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
var LEAST_UPPER_BOUND = -1;
var GREATEST_LOWER_BOUND = 1;
var TraceMap = class {
constructor(map$1, mapUrl) {
const isString$1 = typeof map$1 === "string";
if (!isString$1 && map$1._decodedMemo) return map$1;
const parsed = parse$14(map$1);
const { version: version$2, file, names, sourceRoot, sources, sourcesContent } = parsed;
this.version = version$2;
this.file = file;
this.names = names || [];
this.sourceRoot = sourceRoot;
this.sources = sources;
this.sourcesContent = sourcesContent;
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
const resolve$4 = resolver(mapUrl, sourceRoot);
this.resolvedSources = sources.map(resolve$4);
const { mappings } = parsed;
if (typeof mappings === "string") {
this._encoded = mappings;
this._decoded = void 0;
} else if (Array.isArray(mappings)) {
this._encoded = void 0;
this._decoded = maybeSort(mappings, isString$1);
} else if (parsed.sections) throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);
else throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
this._decodedMemo = memoizedState();
this._bySources = void 0;
this._bySourceMemos = void 0;
}
};
function cast$1(map$1) {
return map$1;
}
function encodedMappings(map$1) {
var _a, _b;
return (_b = (_a = cast$1(map$1))._encoded) != null ? _b : _a._encoded = encode$1(cast$1(map$1)._decoded);
}
function decodedMappings(map$1) {
var _a;
return (_a = cast$1(map$1))._decoded || (_a._decoded = decode(cast$1(map$1)._encoded));
}
function traceSegment(map$1, line, column) {
const decoded = decodedMappings(map$1);
if (line >= decoded.length) return null;
const segments = decoded[line];
const index = traceSegmentInternal(segments, cast$1(map$1)._decodedMemo, line, column, GREATEST_LOWER_BOUND);
return index === -1 ? null : segments[index];
}
function originalPositionFor(map$1, needle) {
let { line, column, bias } = needle;
line--;
if (line < 0) throw new Error(LINE_GTR_ZERO);
if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
const decoded = decodedMappings(map$1);
if (line >= decoded.length) return OMapping(null, null, null, null);
const segments = decoded[line];
const index = traceSegmentInternal(segments, cast$1(map$1)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
if (index === -1) return OMapping(null, null, null, null);
const segment = segments[index];
if (segment.length === 1) return OMapping(null, null, null, null);
const { names, resolvedSources } = map$1;
return OMapping(resolvedSources[segment[SOURCES_INDEX$1]], segment[SOURCE_LINE$1] + 1, segment[SOURCE_COLUMN$1], segment.length === 5 ? names[segment[NAMES_INDEX$1]] : null);
}
function decodedMap(map$1) {
return clone(map$1, decodedMappings(map$1));
}
function encodedMap(map$1) {
return clone(map$1, encodedMappings(map$1));
}
function clone(map$1, mappings) {
return {
version: map$1.version,
file: map$1.file,
names: map$1.names,
sourceRoot: map$1.sourceRoot,
sources: map$1.sources,
sourcesContent: map$1.sourcesContent,
mappings,
ignoreList: map$1.ignoreList || map$1.x_google_ignoreList
};
}
function OMapping(source, line, column, name) {
return {
source,
line,
column,
name
};
}
function traceSegmentInternal(segments, memo, line, column, bias) {
let index = memoizedBinarySearch(segments, column, memo, line);
if (found) index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
else if (bias === LEAST_UPPER_BOUND) index++;
if (index === -1 || index === segments.length) return -1;
return index;
}
//#endregion
//#region ../../node_modules/.pnpm/@jridgewell+gen-mapping@0.3.12/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs
var SetArray = class {
constructor() {
this._indexes = { __proto__: null };
this.array = [];
}
};
function cast(set) {
return set;
}
function get$2(setarr, key) {
return cast(setarr)._indexes[key];
}
function put(setarr, key) {
const index = get$2(setarr, key);
if (index !== void 0) return index;
const { array, _indexes: indexes } = cast(setarr);
return indexes[key] = array.push(key) - 1;
}
function remove(setarr, key) {
const index = get$2(setarr, key);
if (index === void 0) return;
const { array, _indexes: indexes } = cast(setarr);
for (let i$1 = index + 1; i$1 < array.length; i$1++) {
const k = array[i$1];
array[i$1 - 1] = k;
indexes[k]--;
}
indexes[key] = void 0;
array.pop();
}
var COLUMN = 0;
var SOURCES_INDEX = 1;
var SOURCE_LINE = 2;
var SOURCE_COLUMN = 3;
var NAMES_INDEX = 4;
var NO_NAME = -1;
var GenMapping = class {
constructor({ file, sourceRoot } = {}) {
this._names = new SetArray();
this._sources = new SetArray();
this._sourcesContent = [];
this._mappings = [];
this.file = file;
this.sourceRoot = sourceRoot;
this._ignoreList = new SetArray();
}
};
function cast2(map$1) {
return map$1;
}
var maybeAddSegment = (map$1, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => {
return addSegmentInternal(true, map$1, genLine, genColumn, source, sourceLine, sourceColumn, name, content);
};
function setSourceContent(map$1, source, content) {
const { _sources: sources, _sourcesContent: sourcesContent } = cast2(map$1);
const index = put(sources, source);
sourcesContent[index] = content;
}
function setIgnore(map$1, source, ignore = true) {
const { _sources: sources, _sourcesContent: sourcesContent, _ignoreList: ignoreList } = cast2(map$1);
const index = put(sources, source);
if (index === sourcesContent.length) sourcesContent[index] = null;
if (ignore) put(ignoreList, index);
else remove(ignoreList, index);
}
function toDecodedMap(map$1) {
const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, _ignoreList: ignoreList } = cast2(map$1);
removeEmptyFinalLines(mappings);
return {
version: 3,
file: map$1.file || void 0,
names: names.array,
sourceRoot: map$1.sourceRoot || void 0,
sources: sources.array,
sourcesContent,
mappings,
ignoreList: ignoreList.array
};
}
function toEncodedMap(map$1) {
const decoded = toDecodedMap(map$1);
return Object.assign({}, decoded, { mappings: encode$1(decoded.mappings) });
}
function addSegmentInternal(skipable, map$1, genLine, genColumn, source, sourceLine, sourceColumn, name, content) {
const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names } = cast2(map$1);
const line = getIndex(mappings, genLine);
const index = getColumnIndex(line, genColumn);
if (!source) {
if (skipable && skipSourceless(line, index)) return;
return insert(line, index, [genColumn]);
}
assert$2(sourceLine);
assert$2(sourceColumn);
const sourcesIndex = put(sources, source);
const namesIndex = name ? put(names, name) : NO_NAME;
if (sourcesIndex === sourcesContent.length) sourcesContent[sourcesIndex] = content != null ? content : null;
if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) return;
return insert(line, index, name ? [
genColumn,
sourcesIndex,
sourceLine,
sourceColumn,
namesIndex
] : [
genColumn,
sourcesIndex,
sourceLine,
sourceColumn
]);
}
function assert$2(_val) {}
function getIndex(arr, index) {
for (let i$1 = arr.length; i$1 <= index; i$1++) arr[i$1] = [];
return arr[index];
}
function getColumnIndex(line, genColumn) {
let index = line.length;
for (let i$1 = index - 1; i$1 >= 0; index = i$1--) if (genColumn >= line[i$1][COLUMN]) break;
return index;
}
function insert(array, index, value$1) {
for (let i$1 = array.length; i$1 > index; i$1--) array[i$1] = array[i$1 - 1];
array[index] = value$1;
}
function removeEmptyFinalLines(mappings) {
const { length } = mappings;
let len = length;
for (let i$1 = len - 1; i$1 >= 0; len = i$1, i$1--) if (mappings[i$1].length > 0) break;
if (len < length) mappings.length = len;
}
function skipSourceless(line, index) {
if (index === 0) return true;
return line[index - 1].length === 1;
}
function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex) {
if (index === 0) return false;
const prev = line[index - 1];
if (prev.length === 1) return false;
return sourcesIndex === prev[SOURCES_INDEX] && sourceLine === prev[SOURCE_LINE] && sourceColumn === prev[SOURCE_COLUMN] && namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME);
}
//#endregion
//#region ../../node_modules/.pnpm/@jridgewell+remapping@2.3.5/node_modules/@jridgewell/remapping/dist/remapping.mjs
var SOURCELESS_MAPPING = /* @__PURE__ */ SegmentObject("", -1, -1, "", null, false);
var EMPTY_SOURCES = [];
function SegmentObject(source, line, column, name, content, ignore) {
return {
source,
line,
column,
name,
content,
ignore
};
}
function Source(map$1, sources, source, content, ignore) {
return {
map: map$1,
sources,
source,
content,
ignore
};
}
function MapSource(map$1, sources) {
return Source(map$1, sources, "", null, false);
}
function OriginalSource(source, content, ignore) {
return Source(null, EMPTY_SOURCES, source, content, ignore);
}
function traceMappings(tree) {
const gen = new GenMapping({ file: tree.map.file });
const { sources: rootSources, map: map$1 } = tree;
const rootNames = map$1.names;
const rootMappings = decodedMappings(map$1);
for (let i$1 = 0; i$1 < rootMappings.length; i$1++) {
const segments = rootMappings[i$1];
for (let j = 0; j < segments.length; j++) {
const segment = segments[j];
const genCol = segment[0];
let traced = SOURCELESS_MAPPING;
if (segment.length !== 1) {
const source2 = rootSources[segment[1]];
traced = originalPositionFor$1(source2, segment[2], segment[3], segment.length === 5 ? rootNames[segment[4]] : "");
if (traced == null) continue;
}
const { column, line, name, content, source, ignore } = traced;
maybeAddSegment(gen, i$1, genCol, source, line, column, name);
if (source && content != null) setSourceContent(gen, source, content);
if (ignore) setIgnore(gen, source, true);
}
}
return gen;
}
function originalPositionFor$1(source, line, column, name) {
if (!source.map) return SegmentObject(source.source, line, column, name, source.content, source.ignore);
const segment = traceSegment(source.map, line, column);
if (segment == null) return null;
if (segment.length === 1) return SOURCELESS_MAPPING;
return originalPositionFor$1(source.sources[segment[1]], segment[2], segment[3], segment.length === 5 ? source.map.names[segment[4]] : name);
}
function asArray(value$1) {
if (Array.isArray(value$1)) return value$1;
return [value$1];
}
function buildSourceMapTree(input, loader$1) {
const maps = asArray(input).map((m) => new TraceMap(m, ""));
const map$1 = maps.pop();
for (let i$1 = 0; i$1 < maps.length; i$1++) if (maps[i$1].sources.length > 1) throw new Error(`Transformation map ${i$1} must have exactly one source file.
Did you specify these with the most recent transformation maps first?`);
let tree = build$2(map$1, loader$1, "", 0);
for (let i$1 = maps.length - 1; i$1 >= 0; i$1--) tree = MapSource(maps[i$1], [tree]);
return tree;
}
function build$2(map$1, loader$1, importer, importerDepth) {
const { resolvedSources, sourcesContent, ignoreList } = map$1;
const depth = importerDepth + 1;
return MapSource(map$1, resolvedSources.map((sourceFile, i$1) => {
const ctx = {
importer,
depth,
source: sourceFile || "",
content: void 0,
ignore: void 0
};
const sourceMap = loader$1(ctx.source, ctx);
const { source, content, ignore } = ctx;
if (sourceMap) return build$2(new TraceMap(sourceMap, source), loader$1, source, depth);
return OriginalSource(source, content !== void 0 ? content : sourcesContent ? sourcesContent[i$1] : null, ignore !== void 0 ? ignore : ignoreList ? ignoreList.includes(i$1) : false);
}));
}
var SourceMap$1 = class {
constructor(map$1, options$1) {
const out = options$1.decodedMappings ? toDecodedMap(map$1) : toEncodedMap(map$1);
this.version = out.version;
this.file = out.file;
this.mappings = out.mappings;
this.names = out.names;
this.ignoreList = out.ignoreList;
this.sourceRoot = out.sourceRoot;
this.sources = out.sources;
if (!options$1.excludeContent) this.sourcesContent = out.sourcesContent;
}
toString() {
return JSON.stringify(this);
}
};
function remapping(input, loader$1, options$1) {
const opts = typeof options$1 === "object" ? options$1 : {
excludeContent: !!options$1,
decodedMappings: false
};
return new SourceMap$1(traceMappings(buildSourceMapTree(input, loader$1)), opts);
}
//#endregion
//#region ../../node_modules/.pnpm/obug@1.0.2_ms@2.1.3/node_modules/obug/dist/core.js
function coerce(value$1) {
if (value$1 instanceof Error) return value$1.stack || value$1.message;
return value$1;
}
function selectColor(colors$36, namespace) {
let hash$1 = 0;
for (let i$1 = 0; i$1 < namespace.length; i$1++) {
hash$1 = (hash$1 << 5) - hash$1 + namespace.charCodeAt(i$1);
hash$1 |= 0;
}
return colors$36[Math.abs(hash$1) % colors$36.length];
}
function matchesTemplate(search, template) {
let searchIndex = 0;
let templateIndex = 0;
let starIndex = -1;
let matchIndex = 0;
while (searchIndex < search.length) if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) if (template[templateIndex] === "*") {
starIndex = templateIndex;
matchIndex = searchIndex;
templateIndex++;
} else {
searchIndex++;
templateIndex++;
}
else if (starIndex !== -1) {
templateIndex = starIndex + 1;
matchIndex++;
searchIndex = matchIndex;
} else return false;
while (templateIndex < template.length && template[templateIndex] === "*") templateIndex++;
return templateIndex === template.length;
}
function humanize(value$1) {
if (value$1 >= 1e3) return `${(value$1 / 1e3).toFixed(1)}s`;
return `${value$1}ms`;
}
function setup(useColors$1, colors$36, log$3, load$2, save$1, formatArgs$1, init$2) {
const createDebug$1 = (namespace) => {
let prevTime;
let enableOverride;
let namespacesCache;
let enabledCache;
const debug$18 = (...args) => {
if (!debug$18.enabled) return;
const curr = Date.now();
debug$18.diff = curr - (prevTime || curr);
debug$18.prev = prevTime;
debug$18.curr = curr;
prevTime = curr;
args[0] = coerce(args[0]);
if (typeof args[0] !== "string") args.unshift("%O");
let index = 0;
args[0] = args[0].replace(/%([a-z%])/gi, (match, format$3) => {
if (match === "%%") return "%";
index++;
const formatter = createDebug$1.formatters[format$3];
if (typeof formatter === "function") {
const value$1 = args[index];
match = formatter.call(debug$18, value$1);
args.splice(index, 1);
index--;
}
return match;
});
createDebug$1.formatArgs.call(debug$18, args);
(debug$18.log || createDebug$1.log).apply(debug$18, args);
};
function extend(namespace$1, delimiter = ":") {
const newDebug = createDebug$1(this.namespace + delimiter + namespace$1);
newDebug.log = this.log;
return newDebug;
}
debug$18.namespace = namespace;
debug$18.useColors = useColors$1;
debug$18.color = selectColor(colors$36, namespace);
debug$18.extend = extend;
debug$18.log = log$3;
Object.defineProperty(debug$18, "enabled", {
enumerable: true,
configurable: false,
get: () => {
if (enableOverride != null) return enableOverride;
if (namespacesCache !== createDebug$1.namespaces) {
namespacesCache = createDebug$1.namespaces;
enabledCache = createDebug$1.enabled(namespace);
}
return enabledCache;
},
set: (v) => {
enableOverride = v;
}
});
init$2 && init$2(debug$18);
return debug$18;
};
function enable(namespaces) {
save$1(namespaces);
createDebug$1.namespaces = namespaces;
createDebug$1.names = [];
createDebug$1.skips = [];
const split = namespaces.trim().replace(/\s+/g, ",").split(",").filter(Boolean);
for (const ns of split) if (ns[0] === "-") createDebug$1.skips.push(ns.slice(1));
else createDebug$1.names.push(ns);
}
function disable() {
const namespaces = [...createDebug$1.names, ...createDebug$1.skips.map((namespace) => `-${namespace}`)].join(",");
createDebug$1.enable("");
return namespaces;
}
function enabled(name) {
for (const skip of createDebug$1.skips) if (matchesTemplate(name, skip)) return false;
for (const ns of createDebug$1.names) if (matchesTemplate(name, ns)) return true;
return false;
}
createDebug$1.namespaces = "";
createDebug$1.formatters = {};
createDebug$1.enable = enable;
createDebug$1.disable = disable;
createDebug$1.enabled = enabled;
createDebug$1.names = [];
createDebug$1.skips = [];
createDebug$1.selectColor = (ns) => selectColor(colors$36, ns);
createDebug$1.formatArgs = formatArgs$1;
createDebug$1.log = log$3;
createDebug$1.enable(load$2());
return createDebug$1;
}
var init_core = __esmMin((() => {}));
//#endregion
//#region ../../node_modules/.pnpm/obug@1.0.2_ms@2.1.3/node_modules/obug/dist/node.js
var node_exports = /* @__PURE__ */ __export({
createDebug: () => createDebug,
default: () => node_default,
formatArgs: () => formatArgs,
log: () => log$2,
"module.exports": () => createDebug
});
function log$2(...args) {
process.stderr.write(`${formatWithOptions(inspectOpts, ...args)}\n`);
}
function load$1() {
return process.env.DEBUG || "";
}
function save(namespaces) {
if (namespaces) process.env.DEBUG = namespaces;
else delete process.env.DEBUG;
}
function useColors() {
return "colors" in inspectOpts ? Boolean(inspectOpts.colors) : isatty(process.stderr.fd);
}
function formatArgs(args) {
const { namespace: name, useColors: useColors$1 } = this;
if (useColors$1) {
const c = this.color;
const colorCode = `\u001B[3${c < 8 ? c : `8;5;${c}`}`;
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
args[0] = prefix + args[0].split("\n").join(`\n${prefix}`);
args.push(`${colorCode}m+${humanize$1(this.diff)}\u001B[0m`);
} else args[0] = `${getDate()}${name} ${args[0]}`;
}
function getDate() {
if (inspectOpts.hideDate) return "";
return `${(/* @__PURE__ */ new Date()).toISOString()} `;
}
function init$1(debug$18) {
debug$18.inspectOpts = Object.assign({}, inspectOpts);
}
var require$1, colors$35, inspectOpts, humanize$1, createDebug, node_default;
var init_node = __esmMin((() => {
init_core();
require$1 = createRequire(import.meta.url);
colors$35 = process.stderr.getColorDepth && process.stderr.getColorDepth() > 2 ? [
20,
21,
26,
27,
32,
33,
38,
39,
40,
41,
42,
43,
44,
45,
56,
57,
62,
63,
68,
69,
74,
75,
76,
77,
78,
79,
80,
81,
92,
93,
98,
99,
112,
113,
128,
129,
134,
135,
148,
149,
160,
161,
162,
163,
164,
165,
166,
167,
168,
169,
170,
171,
172,
173,
178,
179,
184,
185,
196,
197,
198,
199,
200,
201,
202,
203,
204,
205,
206,
207,
208,
209,
214,
215,
220,
221
] : [
6,
2,
3,
4,
5,
1
];
inspectOpts = Object.keys(process.env).filter((key) => {
return /^debug_/i.test(key);
}).reduce((obj, key) => {
const prop = key.slice(6).toLowerCase().replace(/_([a-z])/g, (_, k) => k.toUpperCase());
let value$1 = process.env[key];
if (value$1 === "null") value$1 = null;
else if (/^yes|on|true|enabled$/i.test(value$1)) value$1 = true;
else if (/^no|off|false|disabled$/i.test(value$1)) value$1 = false;
else value$1 = Number(value$1);
obj[prop] = value$1;
return obj;
}, {});
;
try {
humanize$1 = require$1("ms");
} catch (_unused) {
humanize$1 = humanize;
}
createDebug = setup(useColors(), colors$35, log$2, load$1, save, formatArgs, init$1);
createDebug.inspectOpts = inspectOpts;
createDebug.formatters.o = function(v) {
this.inspectOpts.colors = this.useColors;
return inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
};
createDebug.formatters.O = function(v) {
this.inspectOpts.colors = this.useColors;
return inspect(v, this.inspectOpts);
};
node_default = createDebug;
createDebug.default = createDebug;
createDebug.debug = createDebug;
}));
//#endregion
//#region ../../node_modules/.pnpm/estree-walker@2.0.2/node_modules/estree-walker/dist/esm/estree-walker.js
/** @typedef { import('estree').BaseNode} BaseNode */
/** @typedef {{
skip: () => void;
remove: () => void;
replace: (node: BaseNode) => void;
}} WalkerContext */
var WalkerBase$1 = class {
constructor() {
/** @type {boolean} */
this.should_skip = false;
/** @type {boolean} */
this.should_remove = false;
/** @type {BaseNode | null} */
this.replacement = null;
/** @type {WalkerContext} */
this.context = {
skip: () => this.should_skip = true,
remove: () => this.should_remove = true,
replace: (node) => this.replacement = node
};
}
/**
*
* @param {any} parent
* @param {string} prop
* @param {number} index
* @param {BaseNode} node
*/
replace(parent, prop, index, node) {
if (parent) if (index !== null) parent[prop][index] = node;
else parent[prop] = node;
}
/**
*
* @param {any} parent
* @param {string} prop
* @param {number} index
*/
remove(parent, prop, index) {
if (parent) if (index !== null) parent[prop].splice(index, 1);
else delete parent[prop];
}
};
/** @typedef { import('estree').BaseNode} BaseNode */
/** @typedef { import('./walker.js').WalkerContext} WalkerContext */
/** @typedef {(
* this: WalkerContext,
* node: BaseNode,
* parent: BaseNode,
* key: string,
* index: number
* ) => void} SyncHandler */
var SyncWalker$1 = class extends WalkerBase$1 {
/**
*
* @param {SyncHandler} enter
* @param {SyncHandler} leave
*/
constructor(enter, leave) {
super();
/** @type {SyncHandler} */
this.enter = enter;
/** @type {SyncHandler} */
this.leave = leave;
}
/**
*
* @param {BaseNode} node
* @param {BaseNode} parent
* @param {string} [prop]
* @param {number} [index]
* @returns {BaseNode}
*/
visit(node, parent, prop, index) {
if (node) {
if (this.enter) {
const _should_skip = this.should_skip;
const _should_remove = this.should_remove;
const _replacement = this.replacement;
this.should_skip = false;
this.should_remove = false;
this.replacement = null;
this.enter.call(this.context, node, parent, prop, index);
if (this.replacement) {
node = this.replacement;
this.replace(parent, prop, index, node);
}
if (this.should_remove) this.remove(parent, prop, index);
const skipped = this.should_skip;
const removed = this.should_remove;
this.should_skip = _should_skip;
this.should_remove = _should_remove;
this.replacement = _replacement;
if (skipped) return node;
if (removed) return null;
}
for (const key in node) {
const value$1 = node[key];
if (typeof value$1 !== "object") continue;
else if (Array.isArray(value$1)) {
for (let i$1 = 0; i$1 < value$1.length; i$1 += 1) if (value$1[i$1] !== null && typeof value$1[i$1].type === "string") {
if (!this.visit(value$1[i$1], node, key, i$1)) i$1--;
}
} else if (value$1 !== null && typeof value$1.type === "string") this.visit(value$1, node, key, null);
}
if (this.leave) {
const _replacement = this.replacement;
const _should_remove = this.should_remove;
this.replacement = null;
this.should_remove = false;
this.leave.call(this.context, node, parent, prop, index);
if (this.replacement) {
node = this.replacement;
this.replace(parent, prop, index, node);
}
if (this.should_remove) this.remove(parent, prop, index);
const removed = this.should_remove;
this.replacement = _replacement;
this.should_remove = _should_remove;
if (removed) return null;
}
}
return node;
}
};
/** @typedef { import('estree').BaseNode} BaseNode */
/** @typedef { import('./sync.js').SyncHandler} SyncHandler */
/** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
/**
*
* @param {BaseNode} ast
* @param {{
* enter?: SyncHandler
* leave?: SyncHandler
* }} walker
* @returns {BaseNode}
*/
function walk$2(ast, { enter, leave }) {
return new SyncWalker$1(enter, leave).visit(ast, null);
}
//#endregion
//#region ../../node_modules/.pnpm/@rollup+pluginutils@5.3.0_rollup@4.43.0/node_modules/@rollup/pluginutils/dist/es/index.js
const extractors = {
ArrayPattern(names, param) {
for (const element of param.elements) if (element) extractors[element.type](names, element);
},
AssignmentPattern(names, param) {
extractors[param.left.type](names, param.left);
},
Identifier(names, param) {
names.push(param.name);
},
MemberExpression() {},
ObjectPattern(names, param) {
for (const prop of param.properties) if (prop.type === "RestElement") extractors.RestElement(names, prop);
else extractors[prop.value.type](names, prop.value);
},
RestElement(names, param) {
extractors[param.argument.type](names, param.argument);
}
};
const extractAssignedNames = function extractAssignedNames$1(param) {
const names = [];
extractors[param.type](names, param);
return names;
};
const blockDeclarations = {
const: true,
let: true
};
var Scope = class {
constructor(options$1 = {}) {
this.parent = options$1.parent;
this.isBlockScope = !!options$1.block;
this.declarations = Object.create(null);
if (options$1.params) options$1.params.forEach((param) => {
extractAssignedNames(param).forEach((name) => {
this.declarations[name] = true;
});
});
}
addDeclaration(node, isBlockDeclaration, isVar) {
if (!isBlockDeclaration && this.isBlockScope) this.parent.addDeclaration(node, isBlockDeclaration, isVar);
else if (node.id) extractAssignedNames(node.id).forEach((name) => {
this.declarations[name] = true;
});
}
contains(name) {
return this.declarations[name] || (this.parent ? this.parent.contains(name) : false);
}
};
const attachScopes = function attachScopes$1(ast, propertyName = "scope") {
let scope = new Scope();
walk$2(ast, {
enter(n$2, parent) {
const node = n$2;
if (/(?:Function|Class)Declaration/.test(node.type)) scope.addDeclaration(node, false, false);
if (node.type === "VariableDeclaration") {
const { kind } = node;
const isBlockDeclaration = blockDeclarations[kind];
node.declarations.forEach((declaration) => {
scope.addDeclaration(declaration, isBlockDeclaration, true);
});
}
let newScope;
if (node.type.includes("Function")) {
const func = node;
newScope = new Scope({
parent: scope,
block: false,
params: func.params
});
if (func.type === "FunctionExpression" && func.id) newScope.addDeclaration(func, false, false);
}
if (/For(?:In|Of)?Statement/.test(node.type)) newScope = new Scope({
parent: scope,
block: true
});
if (node.type === "BlockStatement" && !parent.type.includes("Function")) newScope = new Scope({
parent: scope,
block: true
});
if (node.type === "CatchClause") newScope = new Scope({
parent: scope,
params: node.param ? [node.param] : [],
block: true
});
if (newScope) {
Object.defineProperty(node, propertyName, {
value: newScope,
configurable: true
});
scope = newScope;
}
},
leave(n$2) {
if (n$2[propertyName]) scope = scope.parent;
}
});
return scope;
};
function isArray(arg) {
return Array.isArray(arg);
}
function ensureArray(thing) {
if (isArray(thing)) return thing;
if (thing == null) return [];
return [thing];
}
const normalizePathRegExp = new RegExp(`\\${win32.sep}`, "g");
const normalizePath$3 = function normalizePath$5(filename) {
return filename.replace(normalizePathRegExp, posix$1.sep);
};
function getMatcherString$1(id, resolutionBase) {
if (resolutionBase === false || isAbsolute$1(id) || id.startsWith("**")) return normalizePath$3(id);
const basePath = normalizePath$3(resolve$1(resolutionBase || "")).replace(/[-^$*+?.()|[\]{}]/g, "\\$&");
return posix$1.join(basePath, normalizePath$3(id));
}
const createFilter$2 = function createFilter$3(include, exclude, options$1) {
const resolutionBase = options$1 && options$1.resolve;
const getMatcher = (id) => id instanceof RegExp ? id : { test: (what) => {
return picomatch(getMatcherString$1(id, resolutionBase), { dot: true })(what);
} };
const includeMatchers = ensureArray(include).map(getMatcher);
const excludeMatchers = ensureArray(exclude).map(getMatcher);
if (!includeMatchers.length && !excludeMatchers.length) return (id) => typeof id === "string" && !id.includes("\0");
return function result(id) {
if (typeof id !== "string") return false;
if (id.includes("\0")) return false;
const pathId = normalizePath$3(id);
for (let i$1 = 0; i$1 < excludeMatchers.length; ++i$1) {
const matcher = excludeMatchers[i$1];
if (matcher instanceof RegExp) matcher.lastIndex = 0;
if (matcher.test(pathId)) return false;
}
for (let i$1 = 0; i$1 < includeMatchers.length; ++i$1) {
const matcher = includeMatchers[i$1];
if (matcher instanceof RegExp) matcher.lastIndex = 0;
if (matcher.test(pathId)) return true;
}
return !includeMatchers.length;
};
};
const forbiddenIdentifiers = new Set(`break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError