UNPKG

vite

Version:

Native-ESM powered web dev build tool

1,428 lines (1,424 loc) 1.32 MB
import { Module, builtinModules, createRequire } from "node:module"; import { parseAst, parseAstAsync } from "rolldown/parseAst"; import { esmExternalRequirePlugin, esmExternalRequirePlugin as esmExternalRequirePlugin$1 } from "rolldown/plugins"; import { TsconfigCache, Visitor, minify, minifySync, parse, parseSync, transformSync } from "rolldown/utils"; import * as fs$2 from "node:fs"; import fs, { existsSync, 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, parseEnv, promisify, stripVTControlCharacters } from "node:util"; import { performance as performance$1 } from "node:perf_hooks"; import crypto from "node:crypto"; import pm from "picomatch"; import { MessageChannel, Worker } from "node:worker_threads"; import { VERSION as rolldownVersion, rolldown } from "rolldown"; import os from "node:os"; import net from "node:net"; import childProcess, { exec, execFile, execSync } from "node:child_process"; import { promises } from "node:dns"; import { isatty } from "node:tty"; import path$1, { isAbsolute as isAbsolute$1, join as join$1, posix as posix$1, resolve as resolve$1, win32 } from "path"; import { exactRegex, makeIdFiltersToMatchWithQuery, prefixRegex, withFilter } from "rolldown/filter"; import { dev, oxcRuntimePlugin, resolveTsconfig, scan, viteAliasPlugin, viteBuildImportAnalysisPlugin, viteDynamicImportVarsPlugin, viteImportGlobPlugin, viteJsonPlugin, viteLoadFallbackPlugin, viteManifestPlugin, viteModulePreloadPolyfillPlugin, viteReporterPlugin, viteResolvePlugin, viteTransformPlugin, viteWebWorkerPostPlugin } from "rolldown/experimental"; import readline from "node:readline"; import isModuleSyncConditionEnabled from "#module-sync-enabled"; import { escapePath, glob, globSync, isDynamicPattern } from "tinyglobby"; import assert from "node:assert"; import process$1 from "node:process"; import v8 from "node:v8"; 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 { readdirSync, statSync } from "fs"; import { ESModulesEvaluator, ModuleRunner, createNodeImportMeta } from "vite/module-runner"; import { Buffer as Buffer$1 } from "node:buffer"; import zlib from "zlib"; import * as qs from "node:querystring"; import { setTimeout as setTimeout$1 } from "node:timers/promises"; //#region \0rolldown/runtime.js var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __esmMin = (fn, res, err) => () => { if (err) throw err[0]; try { return fn && (res = fn(fn = 0)), res; } catch (e) { throw err = [e], e; } }; var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports); var __exportAll = (all, no_symbols) => { let target = {}; for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" }); return target; }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { key = keys[i]; if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: ((k) => from[k]).bind(null, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod); var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))(); //#endregion //#region ../../node_modules/.pnpm/@voidzero-dev+vite-task-client@0.2.0/node_modules/@voidzero-dev/vite-task-client/src/index.js /** * @typedef {{ tracked?: boolean }} GetEnvOptions */ /** * @typedef {string | { prefix: string }} GetEnvsQuery */ /** * Methods exposed by the napi addon. Keep this shape in sync with the * `RunnerClient` returned by `load()` in * `crates/vite_task_client_napi/src/lib.rs` — any new method added there * needs a matching entry here, and vice versa. * * @type {{ * ignoreInput: (path: string) => void, * ignoreOutput: (path: string) => void, * disableCache: () => void, * getEnv: (name: string, options?: GetEnvOptions) => string | undefined, * getEnvs: (query: GetEnvsQuery, options?: GetEnvOptions) => Record<string, string>, * } | null | undefined} */ let addon; function load$1() { if (addon !== void 0) return addon; try { const path = process.env["VP_RUN_NODE_CLIENT_PATH"]; if (path) { addon = createRequire(import.meta.url)(path).load(); return addon; } } catch {} addon = null; return addon; } /** * Tell the runner to ignore reads under `path` when inferring cache inputs. * * No-op when not running inside a runner. * * @param {string} path * @returns {void} */ function ignoreInput(path) { load$1()?.ignoreInput(path); } /** * Tell the runner to ignore writes under `path` when inferring cache outputs. * * No-op when not running inside a runner. * * @param {string} path * @returns {void} */ function ignoreOutput(path) { load$1()?.ignoreOutput(path); } /** * Tell the runner not to cache this run. * * No-op when not running inside a runner. * * @returns {void} */ function disableCache() { load$1()?.disableCache(); } /** * Ask the runner for the value of the env var `name` and return it, or * `undefined` when the runner has no such env. * * With `tracked: true` (the default) the runner records `name` as a * dependency, so a change to its value invalidates this run's cache entry. * * Has no effect on `process.env`; the caller decides what to do with the * returned value. Returns `undefined` when not running inside a runner. * * @param {string} name * @param {{ tracked?: boolean }} [options] * @returns {string | undefined} */ function getEnv(name, options) { const a = load$1(); if (!a) return void 0; return a.getEnv(name, options); } /** * Ask the runner for matching envs and return the match-set as a plain object. * * Pass a glob string (e.g. `VITE_*`) to use glob matching, or pass * `{ prefix: 'VITE_' }` to match env names by literal prefix. * * With `tracked: true` (the default) the runner records the pattern as a * dependency, so adding, removing, or changing a matching env invalidates * this run's cache entry. * * Has no effect on `process.env`; the caller decides what to do with the * returned values. Returns an empty object when not running inside a runner. * * @param {GetEnvsQuery} query * @param {GetEnvOptions} [options] * @returns {Record<string, string>} */ function getEnvs(query, options) { const a = load$1(); if (!a) return {}; return a.getEnvs(query, options); } //#endregion //#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => { let p = process || {}, argv = p.argv || [], env = p.env || {}; let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI); let formatter = (open, close, replace = open) => (input) => { let string = "" + input, index = string.indexOf(close, open.length); return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close; }; let replaceClose = (string, close, replace, index) => { let result = "", cursor = 0; do { result += string.substring(cursor, index) + replace; cursor = index + close.length; index = string.indexOf(close, cursor); } while (~index); return result + string.substring(cursor); }; let createColors = (enabled = isColorSupported) => { let f = enabled ? formatter : () => String; return { isColorSupported: enabled, reset: f("\x1B[0m", "\x1B[0m"), bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"), dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"), italic: f("\x1B[3m", "\x1B[23m"), underline: f("\x1B[4m", "\x1B[24m"), inverse: f("\x1B[7m", "\x1B[27m"), hidden: f("\x1B[8m", "\x1B[28m"), strikethrough: f("\x1B[9m", "\x1B[29m"), black: f("\x1B[30m", "\x1B[39m"), red: f("\x1B[31m", "\x1B[39m"), green: f("\x1B[32m", "\x1B[39m"), yellow: f("\x1B[33m", "\x1B[39m"), blue: f("\x1B[34m", "\x1B[39m"), magenta: f("\x1B[35m", "\x1B[39m"), cyan: f("\x1B[36m", "\x1B[39m"), white: f("\x1B[37m", "\x1B[39m"), gray: f("\x1B[90m", "\x1B[39m"), bgBlack: f("\x1B[40m", "\x1B[49m"), bgRed: f("\x1B[41m", "\x1B[49m"), bgGreen: f("\x1B[42m", "\x1B[49m"), bgYellow: f("\x1B[43m", "\x1B[49m"), bgBlue: f("\x1B[44m", "\x1B[49m"), bgMagenta: f("\x1B[45m", "\x1B[49m"), bgCyan: f("\x1B[46m", "\x1B[49m"), bgWhite: f("\x1B[47m", "\x1B[49m"), blackBright: f("\x1B[90m", "\x1B[39m"), redBright: f("\x1B[91m", "\x1B[39m"), greenBright: f("\x1B[92m", "\x1B[39m"), yellowBright: f("\x1B[93m", "\x1B[39m"), blueBright: f("\x1B[94m", "\x1B[39m"), magentaBright: f("\x1B[95m", "\x1B[39m"), cyanBright: f("\x1B[96m", "\x1B[39m"), whiteBright: f("\x1B[97m", "\x1B[39m"), bgBlackBright: f("\x1B[100m", "\x1B[49m"), bgRedBright: f("\x1B[101m", "\x1B[49m"), bgGreenBright: f("\x1B[102m", "\x1B[49m"), bgYellowBright: f("\x1B[103m", "\x1B[49m"), bgBlueBright: f("\x1B[104m", "\x1B[49m"), bgMagentaBright: f("\x1B[105m", "\x1B[49m"), bgCyanBright: f("\x1B[106m", "\x1B[49m"), bgWhiteBright: f("\x1B[107m", "\x1B[49m") }; }; module.exports = createColors(); module.exports.createColors = createColors; })); //#endregion //#region ../../node_modules/.pnpm/fresh-import@0.2.1/node_modules/fresh-import/dist/index.js const instanceId = Math.random().toString(36).slice(2); const relativeImportRE = /^\.{1,2}(?:\/|\\)/; function escapeRegExp(value) { return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); } /** * The tracking query name `fresh-import-<instance>`, where `<instance>` is a * random value unique to this loaded module instance. Any two instances (even * two copies of the same build loaded into the same process) get distinct * names, so each hook only recognizes the imports it tagged itself. */ function buildQueryName() { return `fresh-import-${instanceId}`; } /** * Build the regex that matches the tracking query `?<name>=<id>,<context>` * (or the `&<name>=...` form). */ function buildQueryRE(queryName) { return new RegExp(`(?:\\?|&)${escapeRegExp(queryName)}=(\\d+),([^&]+)(?:&|$)`); } /** * Build the tracking query `?<name>=<id>,<context>` that `collect` appends to * the entry specifier. `id` cache-busts the import (a distinct URL forces a * fresh evaluation) and `context` tags the import graph so the resolve hook can * attribute resolved dependencies back to the originating collect. */ function formatTrackingQuery(queryName, id, context) { return `?${queryName}=${id},${context}`; } /** * Shared body of the resolve hook for both the on-thread and off-thread * importers. Given an already-resolved `result`, decides whether it is a tracked * relative file dependency; if so, reports it via `onDependency` and tags the * URL so the query propagates to its own dependencies. * * The sync/async difference between the two hooks lives entirely in the caller * (which awaits `nextResolve` or not); this function performs no I/O. `result` * is mutated in place and returned. */ function trackResolved(specifier, context, result, queryName, queryRE, onDependency) { const isRelativeImport = relativeImportRE.test(specifier); if (result.format === "builtin" || !isRelativeImport) return result; if (!context.parentURL || queryRE.test(result.url) || !result.url.startsWith("file:")) return result; const m = queryRE.exec(context.parentURL); if (m) { const [, id, contextFile] = m; onDependency(contextFile, result.url); result.url = result.url.replace(/(\?)|$/, (_n, n1) => `?${queryName}=${id},${contextFile}${n1 === "?" ? "&" : ""}`); } return result; } var loader_default = "data:text/javascript,Math.random().toString(36).slice(2);%0Aconst relativeImportRE = /^\\.{1,2}(%3F:\\/|\\\\)/;%0Afunction escapeRegExp(value) {%0A%09return value.replace(/[.*+%3F^${}()|[\\]\\\\]/g, \"\\\\$&\");%0A}%0A/**%0A* Build the regex that matches the tracking query `%3F<name>=<id>,<context>`%0A* (or the `&<name>=...` form).%0A*/%0Afunction buildQueryRE(queryName) {%0A%09return new RegExp(`(%3F:\\\\%3F|&)${escapeRegExp(queryName)}=(\\\\d+),([^&]+)(%3F:&|$)`);%0A}%0A/**%0A* Shared body of the resolve hook for both the on-thread and off-thread%0A* importers. Given an already-resolved `result`, decides whether it is a tracked%0A* relative file dependency; if so, reports it via `onDependency` and tags the%0A* URL so the query propagates to its own dependencies.%0A*%0A* The sync/async difference between the two hooks lives entirely in the caller%0A* (which awaits `nextResolve` or not); this function performs no I/O. `result`%0A* is mutated in place and returned.%0A*/%0Afunction trackResolved(specifier, context, result, queryName, queryRE, onDependency) {%0A%09const isRelativeImport = relativeImportRE.test(specifier);%0A%09if (result.format === \"builtin\" || !isRelativeImport) return result;%0A%09if (!context.parentURL || queryRE.test(result.url) || !result.url.startsWith(\"file:\")) return result;%0A%09const m = queryRE.exec(context.parentURL);%0A%09if (m) {%0A%09%09const [, id, contextFile] = m;%0A%09%09onDependency(contextFile, result.url);%0A%09%09result.url = result.url.replace(/(\\%3F)|$/, (_n, n1) => `%3F${queryName}=${id},${contextFile}${n1 === \"%3F\" %3F \"&\" : \"\"}`);%0A%09}%0A%09return result;%0A}%0A//%23endregion%0A//%23region src/off-thread/loader.ts%0Alet port;%0Alet queryName;%0Alet queryRE;%0Aconst initialize = async (data) => {%0A%09port = data.port;%0A%09queryName = data.queryName;%0A%09queryRE = buildQueryRE(queryName);%0A};%0Aconst resolve = async (specifier, context, nextResolve) => {%0A%09return trackResolved(specifier, context, await nextResolve(specifier, context), queryName, queryRE, (ctx, url) => {%0A%09%09port.postMessage({%0A%09%09%09context: ctx,%0A%09%09%09url%0A%09%09});%0A%09});%0A};%0A//%23endregion%0Aexport { initialize, resolve };%0A"; let nextId$1 = 0; /** * Off-thread importer: registers an ESM loader in a worker thread via * `Module.register` and receives tracked dependencies over a `MessagePort`. * Used on Node versions without `Module.registerHooks`. */ function createOffThreadImporter() { const queryName = buildQueryName(); const { port1, port2 } = new MessageChannel(); Module.register(loader_default, { data: { port: port2, queryName }, transferList: [port2] }); port1.unref(); return { async collect(specifier) { const id = nextId$1++; const depsList = /* @__PURE__ */ new Set(); const onMessage = (e) => { if (e.context === specifier) depsList.add(e.url); }; port1.on("message", onMessage); port1.unref(); try { const result = await import(specifier + formatTrackingQuery(queryName, id, specifier)); await new Promise((resolve) => setImmediate(resolve)); return { result, dependencies: [...depsList].filter((url) => url.startsWith("file:")).map((url) => fileURLToPath(url)) }; } finally { port1.off("message", onMessage); } } }; } let nextId = 0; /** * On-thread importer: registers synchronous resolution hooks via * `Module.registerHooks` (Node 22.15+/23.5+). */ function createOnThreadImporter() { const registry = /* @__PURE__ */ new Map(); const queryName = buildQueryName(); const queryRE = buildQueryRE(queryName); const resolve = (specifier, context, nextResolve) => { return trackResolved(specifier, context, nextResolve(specifier, context), queryName, queryRE, (ctx, url) => { registry.get(ctx)?.add(url); }); }; Module.registerHooks({ resolve }); return { async collect(specifier) { const id = nextId++; const depsList = /* @__PURE__ */ new Set(); registry.set(specifier, depsList); try { return { result: await import(specifier + formatTrackingQuery(queryName, id, specifier)), dependencies: [...depsList].filter((url) => url.startsWith("file:")).map((url) => fileURLToPath(url)) }; } finally { registry.delete(specifier); } } }; } /** * Create the importer best suited to the current runtime, or `undefined` if it * provides neither module-hook API. */ function createImporter() { if (Module.registerHooks) return createOnThreadImporter(); if (Module.register) return createOffThreadImporter(); } let importer; let initialized = false; /** * Import an ESM entry in its own fresh module graph (separate from Node's module * cache and from other concurrent imports) and report the dependency files it * pulled in. * * Each call re-evaluates the entry in a fresh graph; concurrent calls stay * isolated from one another. Only statically-imported relative dependencies are * tracked, not dynamic imports. * * Returns `undefined` on runtimes that provide neither `Module.registerHooks` * nor `Module.register`. */ function freshImport(specifier) { if (!initialized) { importer = createImporter(); initialized = true; } return importer?.collect(specifier); } //#endregion //#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) { return url.replace(postfixRE, ""); } function splitFileAndPostfix(path) { const file = cleanUrl(path); return { file, postfix: path.slice(file.length) }; } function withTrailingSlash(path) { if (path[path.length - 1] !== "/") return `${path}/`; return path; } function promiseWithResolvers() { let resolve; let reject; return { promise: new Promise((_resolve, _reject) => { resolve = _resolve; reject = _reject; }), resolve, 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); } let isHookRegistered = false; function createImportMetaResolver() { if (isHookRegistered) return importMetaResolveWithCustomHook; let module; try { module = typeof process !== "undefined" ? process.getBuiltinModule("node:module").Module : void 0; } catch { return; } if (!module) return; if (module.registerHooks) { module.registerHooks({ resolve: customizationHookResolve }); isHookRegistered = true; return importMetaResolveWithCustomHook; } if (!module.register) return; try { const hookModuleContent = `data:text/javascript,${encodeURI(customizationHooksModule)}`; module.register(hookModuleContent); } catch (e) { if ("code" in e && e.code === "ERR_NETWORK_IMPORT_DISALLOWED") return; throw e; } isHookRegistered = true; 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 src/node/constants.ts const { version } = JSON.parse(readFileSync(new URL("../../package.json", new URL("../../../src/node/constants.ts", import.meta.url))).toString()); const ROLLUP_HOOKS = [ "options", "buildStart", "buildEnd", "renderStart", "renderError", "renderChunk", "writeBundle", "generateBundle", "banner", "footer", "augmentChunkHash", "outputOptions", "intro", "outro", "closeBundle", "closeWatcher", "load", "moduleParsed", "watchChange", "resolveDynamicImport", "resolveId", "transform", "onLog" ]; const VERSION = version; const DEFAULT_MAIN_FIELDS = [ "browser", "module", "jsnext:main", "jsnext" ]; const DEFAULT_CLIENT_MAIN_FIELDS = Object.freeze(DEFAULT_MAIN_FIELDS); const DEFAULT_SERVER_MAIN_FIELDS = Object.freeze(DEFAULT_MAIN_FIELDS.filter((f) => f !== "browser")); /** * A special condition that would be replaced with production or development * depending on NODE_ENV env variable */ const DEV_PROD_CONDITION = `development|production`; const DEFAULT_CONDITIONS$1 = [ "module", "browser", "node", DEV_PROD_CONDITION ]; const DEFAULT_CLIENT_CONDITIONS = Object.freeze(DEFAULT_CONDITIONS$1.filter((c) => c !== "node")); const DEFAULT_SERVER_CONDITIONS = Object.freeze(DEFAULT_CONDITIONS$1.filter((c) => c !== "browser")); const DEFAULT_EXTERNAL_CONDITIONS = Object.freeze(["node", "module-sync"]); const DEFAULT_EXTENSIONS = [ ".mjs", ".js", ".mts", ".ts", ".jsx", ".tsx", ".json" ]; /** * The browser versions that are included in the Baseline Widely Available on 2025-05-01. * * This value would be bumped on each major release of Vite. * * The value is generated by `pnpm generate-target` script. */ const ESBUILD_BASELINE_WIDELY_AVAILABLE_TARGET = [ "chrome111", "edge111", "firefox114", "safari16.4", "ios16.4" ]; const DEFAULT_CONFIG_FILES = [ "vite.config.js", "vite.config.mjs", "vite.config.ts", "vite.config.cjs", "vite.config.mts", "vite.config.cts" ]; const JS_TYPES_RE = /\.(?:j|t)sx?$|\.mjs$/; const CSS_LANGS_RE = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/; const OPTIMIZABLE_ENTRY_RE = /\.[cm]?[jt]s$/; const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/; /** * Prefix for resolved fs paths, since windows paths may not be valid as URLs. */ const FS_PREFIX = `/@fs/`; const CLIENT_PUBLIC_PATH = `/@vite/client`; const ENV_PUBLIC_PATH = `/@vite/env`; const VITE_PACKAGE_DIR = resolve(fileURLToPath(new URL("../../../src/node/constants.ts", import.meta.url)), "../../.."); const CLIENT_ENTRY = resolve(VITE_PACKAGE_DIR, "dist/client/client.mjs"); const ENV_ENTRY = resolve(VITE_PACKAGE_DIR, "dist/client/env.mjs"); const CLIENT_DIR = path.dirname(CLIENT_ENTRY); const KNOWN_ASSET_TYPES = [ "apng", "bmp", "png", "jpe?g", "jfif", "pjpeg", "pjp", "gif", "svg", "ico", "webp", "avif", "cur", "jxl", "mp4", "webm", "ogg", "mp3", "wav", "flac", "aac", "opus", "mov", "m4a", "vtt", "woff2?", "eot", "ttf", "otf", "webmanifest", "pdf", "txt" ]; const DEFAULT_ASSETS_RE = new RegExp(`\\.(` + KNOWN_ASSET_TYPES.join("|") + `)(\\?.*)?$`, "i"); const DEP_VERSION_RE = /[?&](v=[\w.-]+)\b/; const loopbackHosts = /* @__PURE__ */ new Set([ "localhost", "127.0.0.1", "::1", "0000:0000:0000:0000:0000:0000:0000:0001" ]); const wildcardHosts = /* @__PURE__ */ new Set([ "0.0.0.0", "::", "0000:0000:0000:0000:0000:0000:0000:0000" ]); const DEFAULT_DEV_PORT = 5173; const DEFAULT_PREVIEW_PORT = 4173; const DEFAULT_ASSETS_INLINE_LIMIT = 4096; const defaultAllowedOrigins = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/; const METADATA_FILENAME = "_metadata.json"; const ERR_OPTIMIZE_DEPS_PROCESSING_ERROR = "ERR_OPTIMIZE_DEPS_PROCESSING_ERROR"; const ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR = "ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR"; //#endregion //#region ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs var comma$1 = ",".charCodeAt(0); var semicolon = ";".charCodeAt(0); var chars$1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; var intToChar$1 = /* @__PURE__ */ new Uint8Array(64); var charToInt$1 = /* @__PURE__ */ new Uint8Array(128); for (let i = 0; i < chars$1.length; i++) { const c = chars$1.charCodeAt(i); intToChar$1[i] = c; charToInt$1[c] = i; } function decodeInteger$1(reader, relative) { let value = 0; let shift = 0; let integer = 0; do { integer = charToInt$1[reader.next()]; value |= (integer & 31) << shift; shift += 5; } while (integer & 32); const shouldNegate = value & 1; value >>>= 1; if (shouldNegate) value = -2147483648 | -value; return relative + value; } function encodeInteger(builder, num, relative) { let delta = num - relative; delta = delta < 0 ? -delta << 1 | 1 : delta << 1; do { let clamped = delta & 31; delta >>>= 5; if (delta > 0) clamped |= 32; builder.write(intToChar$1[clamped]); } while (delta > 0); return num; } function hasMoreVlq$1(reader, max) { if (reader.pos >= max) return false; return reader.peek() !== comma$1; } 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 = 0; i < buf.length; i++) out += String.fromCharCode(buf[i]); 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$1 = 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$1(mappings) { const { length } = mappings; const reader = new StringReader$1(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$1(reader, genColumn); if (genColumn < lastCol) sorted = false; lastCol = genColumn; if (hasMoreVlq$1(reader, semi)) { sourcesIndex = decodeInteger$1(reader, sourcesIndex); sourceLine = decodeInteger$1(reader, sourceLine); sourceColumn = decodeInteger$1(reader, sourceColumn); if (hasMoreVlq$1(reader, semi)) { namesIndex = decodeInteger$1(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$1(line); decoded.push(line); reader.pos = semi + 1; } while (reader.pos <= length); return decoded; } function sort$1(line) { line.sort(sortComparator$2); } function sortComparator$2(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 = 0; i < decoded.length; i++) { const line = decoded[i]; if (i > 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$1); 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 = match[2]; return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path) ? path : "/" + path, match[3] || "", match[4] || ""); } function makeUrl(scheme, user, host, port, path, query, hash) { return { scheme, user, host, port, path, query, hash, type: 7 }; } function parseUrl(input) { if (isSchemeRelativeUrl(input)) { const url = parseAbsoluteUrl("http:" + input); url.scheme = ""; url.type = 6; return url; } if (isAbsolutePath(input)) { const url = parseAbsoluteUrl("http://foo.com" + input); url.scheme = ""; url.host = ""; url.type = 5; return url; } if (isFileUrl(input)) return parseFileUrl(input); if (isAbsoluteUrl(input)) return parseAbsoluteUrl(input); const url = parseAbsoluteUrl("http://foo.com/" + input); url.scheme = ""; url.host = ""; url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1; return url; } function stripPathFilename(path) { if (path.endsWith("/..")) return path; const index = path.lastIndexOf("/"); return path.slice(0, index + 1); } function mergePaths(url, base) { normalizePath$2(base, base.type); if (url.path === "/") url.path = base.path; else url.path = stripPathFilename(base.path) + url.path; } /** * The path can have empty directories "//", unneeded parents "foo/..", or current directory * "foo/.". We need to normalize to a standard representation. */ function normalizePath$2(url, type) { const rel = type <= 4; const pieces = url.path.split("/"); let pointer = 1; let positive = 0; let addTrailingSlash = false; for (let i = 1; i < pieces.length; i++) { const piece = pieces[i]; 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 = ""; for (let i = 1; i < pointer; i++) path += "/" + pieces[i]; if (!path || addTrailingSlash && !path.endsWith("/..")) path += "/"; url.path = path; } /** * Attempts to resolve `input` URL/path relative to `base`. */ function resolve$4(input, base) { if (!input && !base) return ""; const url = parseUrl(input); let inputType = url.type; if (base && inputType !== 7) { const baseUrl = parseUrl(base); const baseType = baseUrl.type; switch (inputType) { case 1: url.hash = baseUrl.hash; case 2: url.query = baseUrl.query; case 3: case 4: mergePaths(url, baseUrl); case 5: url.user = baseUrl.user; url.host = baseUrl.host; url.port = baseUrl.port; case 6: url.scheme = baseUrl.scheme; } if (baseType > inputType) inputType = baseType; } normalizePath$2(url, inputType); const queryHash = url.query + url.hash; switch (inputType) { case 2: case 3: return queryHash; case 4: { const path = url.path.slice(1); if (!path) return queryHash || "."; if (isRelative(base || input) && !isRelative(path)) return "./" + path + queryHash; return path + queryHash; } case 5: return url.path + queryHash; default: return url.scheme + "//" + url.user + url.host + url.port + url.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) { if (!path) return ""; const index = path.lastIndexOf("/"); return path.slice(0, index + 1); } function resolver(mapUrl, sourceRoot) { const from = stripFilename(mapUrl); const prefix = sourceRoot ? sourceRoot + "/" : ""; return (source) => resolve$4(prefix + (source || ""), from); } var COLUMN$2 = 0; var SOURCES_INDEX$2 = 1; var SOURCE_LINE$2 = 2; var SOURCE_COLUMN$2 = 3; var NAMES_INDEX$2 = 4; function maybeSort(mappings, owned) { const unsortedIndex = nextUnsortedSegmentLine(mappings, 0); if (unsortedIndex === mappings.length) return mappings; if (!owned) mappings = mappings.slice(); for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) mappings[i] = sortSegments(mappings[i], owned); return mappings; } function nextUnsortedSegmentLine(mappings, start) { for (let i = start; i < mappings.length; i++) if (!isSorted(mappings[i])) return i; return mappings.length; } function isSorted(line) { for (let j = 1; j < line.length; j++) if (line[j][COLUMN$2] < line[j - 1][COLUMN$2]) return false; return true; } function sortSegments(line, owned) { if (!owned) line = line.slice(); return line.sort(sortComparator$1); } function sortComparator$1(a, b) { return a[COLUMN$2] - b[COLUMN$2]; } var found$1 = false; function binarySearch$1(haystack, needle, low, high) { while (low <= high) { const mid = low + (high - low >> 1); const cmp = haystack[mid][COLUMN$2] - needle; if (cmp === 0) { found$1 = true; return mid; } if (cmp < 0) low = mid + 1; else high = mid - 1; } found$1 = false; return low - 1; } function upperBound$1(haystack, needle, index) { for (let i = index + 1; i < haystack.length; index = i++) if (haystack[i][COLUMN$2] !== needle) break; return index; } function lowerBound$1(haystack, needle, index) { for (let i = index - 1; i >= 0; index = i--) if (haystack[i][COLUMN$2] !== needle) break; return index; } function memoizedState$1() { return { lastKey: -1, lastNeedle: -1, lastIndex: -1 }; } function memoizedBinarySearch$1(haystack, needle, state, key) { const { lastKey, lastNeedle, lastIndex } = state; let low = 0; let high = haystack.length - 1; if (key === lastKey) { if (needle === lastNeedle) { found$1 = lastIndex !== -1 && haystack[lastIndex][COLUMN$2] === needle; return lastIndex; } if (needle >= lastNeedle) low = lastIndex === -1 ? 0 : lastIndex; else high = lastIndex; } state.lastKey = key; state.lastNeedle = needle; return state.lastIndex = binarySearch$1(haystack, needle, low, high); } function parse$3(map) { return typeof map === "string" ? JSON.parse(map) : map; } var LINE_GTR_ZERO$1 = "`line` must be greater than 0 (lines start at line 1)"; var COL_GTR_EQ_ZERO$1 = "`column` must be greater than or equal to 0 (columns start at column 0)"; var TraceMap = class { constructor(map, mapUrl) { const isString = typeof map === "string"; if (!isString && map._decodedMemo) return map; const parsed = parse$3(map); const { version, file, names, sourceRoot, sources, sourcesContent } = parsed; this.version = version; 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 = resolver(mapUrl, sourceRoot); this.resolvedSources = sources.map(resolve); 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); } 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$1(); this._bySources = void 0; this._bySourceMemos = void 0; } }; function cast$2(map) { return map; } function decodedMappings$1(map) { var _a; return (_a = cast$2(map))._decoded || (_a._decoded = decode$1(cast$2(map)._encoded)); } function traceSegment(map, line, column) { const decoded = decodedMappings$1(map); if (line >= decoded.length) return null; const segments = decoded[line]; const index = traceSegmentInternal$1(segments, cast$2(map)._decodedMemo, line, column, 1); return index === -1 ? null : segments[index]; } function originalPositionFor$2(map, needle) { let { line, column, bias } = needle; line--; if (line < 0) throw new Error(LINE_GTR_ZERO$1); if (column < 0) throw new Error(COL_GTR_EQ_ZERO$1); const decoded = decodedMappings$1(map); if (line >= decoded.length) return OMapping$1(null, null, null, null); const segments = decoded[line]; const index = traceSegmentInternal$1(segments, cast$2(map)._decodedMemo, line, column, bias || 1); if (index === -1) return OMapping$1(null, null, null, null); const segment = segments[index]; if (segment.length === 1) return OMapping$1(null, null, null, null); const { names, resolvedSources } = map; return OMapping$1(resolvedSources[segment[SOURCES_INDEX$2]], segment[SOURCE_LINE$2] + 1, segment[SOURCE_COLUMN$2], segment.length === 5 ? names[segment[NAMES_INDEX$2]] : null); } function OMapping$1(source, line, column, name) { return { source, line, column, name }; } function traceSegmentInternal$1(segments, memo, line, column, bias) { let index = memoizedBinarySearch$1(segments, column, memo, line); if (found$1) index = (bias === -1 ? upperBound$1 : lowerBound$1)(segments, column, index); else if (bias === -1) index++; if (index === -1 || index === segments.length) return -1; return index; } //#endregion //#region ../../node_modules/.pnpm/@jridgewell+gen-mapping@0.3.13/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs var SetArray = class { constructor() { this._indexes = { __proto__: null }; this.array = []; } }; function cast$1(set) { return set; } function get$2(setarr, key) { return cast$1(setarr)._indexes[key]; } function put(setarr, key) { const index = get$2(setarr, key); if (index !== void 0) return index; const { array, _indexes: indexes } = cast$1(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$1(setarr); for (let i = index + 1; i < array.length; i++) { const k = array[i]; array[i - 1] = k; indexes[k]--; } indexes[key] = void 0; array.pop(); } var COLUMN$1 = 0; var SOURCES_INDEX$1 = 1; var SOURCE_LINE$1 = 2; var SOURCE_COLUMN$1 = 3; var NAMES_INDEX$1 = 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) { return map; } var maybeAddSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => { return addSegmentInternal(true, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content); }; function setSourceContent(map, source, content) { const { _sources: sources, _sourcesContent: sourcesContent } = cast2(map); const index = put(sources, source); sourcesContent[index] = content; } function setIgnore(map, source, ignore = true) { const { _sources: sources, _sourcesContent: sourcesContent, _ignoreList: ignoreList } = cast2(map); const index = put(sources, source); if (index === sourcesContent.length) sourcesContent[index] = null; if (ignore) put(ignoreList, index); else remove(ignoreList, index); } function toDecodedMap(map) { const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, _ignoreList: ignoreList } = cast2(map); removeEmptyFinalLines(mappings); return { version: 3, file: map.file || void 0, names: names.array, sourceRoot: map.sourceRoot || void 0, sources: sources.array, sourcesContent, mappings, ignoreList: ignoreList.array }; } function toEncodedMap(map) { const decoded = toDecodedMap(map); return Object.assign({}, decoded, { mappings: encode$1(decoded.mappings) }); } function addSegmentInternal(skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) { const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names } = cast2(map); const line = getIndex(mappings, genLine); const index = getColumnIndex(line, genColumn); if (!source) { if (skipable && skipSourceless(line, index)) return; return insert(line, index, [genColumn]); } 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 getIndex(arr, index) { for (let i = arr.length; i <= index; i++) arr[i] = []; return arr[index]; } function getColumnIndex(line, genColumn) { let index = line.length; for (let i = index - 1; i >= 0; index = i--) if (genColumn >= line[i][COLUMN$1]) break; return index; } function insert(array, index, value) { for (let i = array.length; i > index; i--) array[i] = array[i - 1]; array[index] = value; } function removeEmptyFinalLines(mappings) { const { length } = mappings; let len = length; for (let i = len - 1; i >= 0; len = i, i--) if (mappings[i].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$1] && sourceLine === prev[SOURCE_LINE$1] && sourceColumn === prev[SOURCE_COLUMN$1] && namesIndex === (prev.length === 5 ? prev[NAMES_INDEX$1] : 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, sources, source, content, ignore) { return { map, sources, source, content, ignore }; } function MapSource(map, sources) { return Source(map, 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 } = tree; const rootNames = map.names; const rootMappings = decodedMappings$1(map); for (let i = 0; i < rootMappings.length; i++) { const segments = rootMappings[i]; 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, 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) { if (Array.isArray(value)) return value; return [value]; } function buildSourceMapTree(input, loader) { const maps = asArray(input).map((m) => new TraceMap(m, "")); const map = maps.pop(); for (let i = 0; i < maps.length; i++) if (maps[i].sources.length > 1) throw new Error(`Transformation map ${i} must have exactly one source file. Did you specify these with the most recent transformation maps first?`); let tree = build$1(map, loader, "", 0); for (let i = maps.length - 1; i >= 0; i--) tree = MapSource(maps[i], [tree]); return tree; } function build$1(map, loader, importer, importerDepth) { const { resolvedSources, sourcesContent, ignoreList } = map; const depth = importerDepth + 1; return MapSource(map, resolvedSources.map((sourceFile, i) => { const ctx = { importer, depth, source: sourceFile || "", content: void 0, ignore: void 0 }; const sourceMap = loader(ctx.source, ctx); const { source, content, ignore } = ctx; if (sourceMap) return build$1(new TraceMap(sourceMap, source), loader, source, depth); return OriginalSource(source, content !== void 0 ? content : sourcesContent ? sourcesContent[i] : null, ignore !== void 0 ? ignore : ignoreList ? ignoreList.includes(i) : false); })); } var SourceMap$1 = class { constructor(map, options) { const out = options.decodedMappings ? toDecodedMap(map) : toEncodedMap(map); 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.excludeContent) this.sourcesContent = out.sourcesContent; } toString() { return JSON.stringify(this); } }; function r