@rohal12/twee-ts 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/twee-ts.js +47 -32
- package/dist/bin/twee-ts.js.map +1 -1
- package/dist/{diagnostic-text-BRddVulf.cjs → diagnostic-text-Bj-UQ0Jl.cjs} +4283 -3739
- package/dist/diagnostic-text-Bj-UQ0Jl.cjs.map +1 -0
- package/dist/{diagnostic-text-CebYCTPQ.js → diagnostic-text-DMVZfBh9.js} +4260 -3770
- package/dist/diagnostic-text-DMVZfBh9.js.map +1 -0
- package/dist/index.cjs +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +3 -3
- package/dist/{lint-VayZI_jp.js → lint-BkpfLGuP.js} +3 -3
- package/dist/{lint-VayZI_jp.js.map → lint-BkpfLGuP.js.map} +1 -1
- package/dist/plugins/rollup.cjs +9 -4
- package/dist/plugins/rollup.cjs.map +1 -1
- package/dist/plugins/rollup.d.cts +6 -0
- package/dist/plugins/rollup.d.ts +6 -0
- package/dist/plugins/rollup.js +9 -4
- package/dist/plugins/rollup.js.map +1 -1
- package/dist/plugins/vite.cjs +453 -154
- package/dist/plugins/vite.cjs.map +1 -1
- package/dist/plugins/vite.js +453 -154
- package/dist/plugins/vite.js.map +1 -1
- package/dist/{watch-targets-C0Anuw17.cjs → watch-targets-BrEYmUwU.cjs} +84 -16
- package/dist/watch-targets-BrEYmUwU.cjs.map +1 -0
- package/dist/{watch-targets-BI7jYrwa.js → watch-targets-DzvPyWDo.js} +79 -17
- package/dist/watch-targets-DzvPyWDo.js.map +1 -0
- package/package.json +2 -2
- package/dist/diagnostic-text-BRddVulf.cjs.map +0 -1
- package/dist/diagnostic-text-CebYCTPQ.js.map +0 -1
- package/dist/watch-targets-BI7jYrwa.js.map +0 -1
- package/dist/watch-targets-C0Anuw17.cjs.map +0 -1
package/dist/plugins/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","names":["tokTypes","viteVersion"],"sources":["../../src/plugins/vite-glob.ts","../../src/plugins/vite-entry.ts","../../src/plugins/vite-dev.ts","../../src/plugins/vite.ts"],"sourcesContent":["/**\n * The folders an entry's `import.meta.glob()` calls read. Vite replaces each call with the files that match it\n * when it bundles, so the bundle names those files and nothing else: a file added later that matches is in no\n * bundle's module list. To bundle again when the files a glob selects change, the plugin reads each call itself,\n * just before Vite's own import-glob transform does, and notes the folder below which it can match (its scope).\n *\n * A scope is a superset of what the glob matches: a file added to it or removed from it may not match (a negated\n * pattern, a name the wildcards leave out), which only bundles again for nothing. The calls are read with acorn as Vite reads them: patterns are\n * string literals, template literals without expressions, or arrays of those; `base` and `exhaustive` are literal\n * options. A call written otherwise is one Vite rejects, and the bundle fails before its scope matters.\n *\n * Code that is a module is read whole, so only real calls count. Code that is not (yet) one, as a plugin may hand\n * on a component file or TypeScript it transforms later, is read the way Vite's import-glob reads every module:\n * each `import.meta.glob(` in the text, with TypeScript type arguments allowed, is read on its own as a call.\n * Text in a comment or a string that reads as a call then adds a scope too, which only costs a bundle for nothing.\n */\nimport { readdirSync, statSync } from 'node:fs';\nimport { basename, dirname, isAbsolute, join, posix, resolve } from 'node:path';\nimport type { AnyNode, Expression, ObjectExpression, Options, SpreadElement } from 'acorn';\nimport { tokTypes } from 'acorn';\nimport { AcornParser, trySyntax } from '../js-syntax.js';\nimport { isRecord, pushAll } from '../util.js';\nimport { canonicalPath, fileKey, isViteConfigTemp, keyWithin, toPosix } from './paths.js';\nimport { missingImportFolders } from './watch-targets.js';\n\n/**\n * Where a glob can match:\n * - `dir`: the folder below which it can (forward slashes);\n * - `deep`: whether it also matches in the folders below `dir`, or only among `dir`'s own files;\n * - `dot`: whether it may match a name that starts with a dot, which Vite's import-glob gives no wildcard unless\n * the call is `exhaustive` or the pattern spells the dot;\n * - `exhaustive`: the call's option, which also lets a match pass through `node_modules`;\n * - `suffix`: the literal end of the pattern's last segment (`.js` of `*.js`), lower-cased, which every file it\n * matches ends with (in any case, as a case-insensitive glob matches).\n */\nexport interface GlobScope {\n readonly dir: string;\n readonly deep: boolean;\n readonly dot: boolean;\n readonly exhaustive: boolean;\n readonly suffix: string;\n}\n\n/** One `import.meta.glob()` call: its patterns as written, and the options that decide where they match. */\nexport interface GlobCall {\n readonly patterns: readonly string[];\n readonly base: string | undefined;\n readonly exhaustive: boolean;\n}\n\n/** A module, as the bundler hands it to a plugin's transform hook (the entry build's code is a module). */\nconst MODULE_OPTIONS: Readonly<Options> = { ecmaVersion: 'latest', sourceType: 'module', allowHashBang: true };\n\n/** Whether `code` may hold a glob call, as Vite's import-glob filters the modules it reads. */\nfunction mayHoldGlob(code: string): boolean {\n return code.includes('import.meta.glob');\n}\n\nfunction isNode(value: unknown): value is AnyNode {\n return isRecord(value) && typeof value['type'] === 'string';\n}\n\n/** Every node below `root`, `root` first, in source order. */\nfunction* nodesOf(root: AnyNode): Generator<AnyNode> {\n const stack: unknown[] = [root];\n for (let value = stack.pop(); value !== undefined; value = stack.pop()) {\n if (isNode(value)) yield value;\n const children: readonly unknown[] = Array.isArray(value) ? value : isNode(value) ? Object.values(value) : [];\n pushAll(stack, children.toReversed());\n }\n}\n\n/** Whether `node` is the callee `import.meta.glob`. */\nfunction isGlobCallee(node: Expression | AnyNode): boolean {\n return (\n node.type === 'MemberExpression' &&\n !node.computed &&\n node.property.type === 'Identifier' &&\n node.property.name === 'glob' &&\n node.object.type === 'MetaProperty' &&\n node.object.meta.name === 'import' &&\n node.object.property.name === 'meta'\n );\n}\n\n/** The string a pattern argument spells: a string literal, or a template literal without expressions. */\nfunction stringOf(node: Expression | SpreadElement | null): string | undefined {\n if (node === null) return undefined;\n if (node.type === 'Literal') return typeof node.value === 'string' ? node.value : undefined;\n if (node.type === 'TemplateLiteral' && node.expressions.length === 0) return node.quasis[0]?.value.raw;\n return undefined;\n}\n\n/** The literal value of the option `name` of a call's options object. */\nfunction optionOf(options: ObjectExpression | undefined, name: string): unknown {\n for (const property of options?.properties ?? []) {\n if (property.type !== 'Property' || property.computed || property.value.type !== 'Literal') continue;\n const { key } = property;\n const keyName = key.type === 'Identifier' ? key.name : key.type === 'Literal' ? key.value : undefined;\n if (keyName === name) return property.value.value;\n }\n return undefined;\n}\n\n/** The call a glob call's arguments make. */\nfunction callOf(args: readonly (Expression | SpreadElement)[]): GlobCall {\n const [first, second] = args;\n const patterns = (first === undefined ? [] : first.type === 'ArrayExpression' ? first.elements : [first])\n .map(stringOf)\n .filter((pattern) => pattern !== undefined);\n const options = second?.type === 'ObjectExpression' ? second : undefined;\n const base = optionOf(options, 'base');\n return {\n patterns,\n base: typeof base === 'string' ? base : undefined,\n exhaustive: optionOf(options, 'exhaustive') === true,\n };\n}\n\n/** Where Vite's import-glob finds a call in a module's text: the callee, any TypeScript type arguments, `(`. */\nconst GLOB_CALL_START = /\\bimport\\.meta\\.glob(?:<\\w+>)?\\s*\\(/g;\n\n/**\n * The end (offset just past it) of the argument list that opens at `paren`, as acorn's tokenizer reads the text from\n * there: past strings, template literals, regular expressions and comments that hold parentheses. Undefined when the\n * list does not close, or the text cannot be tokenized.\n */\nfunction argumentsEnd(code: string, paren: number): number | undefined {\n const read = trySyntax(() => {\n let depth = 0;\n for (const token of AcornParser.tokenizer(code.slice(paren), MODULE_OPTIONS)) {\n if (token.type === tokTypes.parenL) depth += 1;\n else if (token.type === tokTypes.parenR) depth -= 1;\n if (depth === 0) return paren + token.end;\n }\n return undefined;\n });\n return read.ok ? read.value : undefined;\n}\n\n/** `text` read as one expression, which must take all of it; undefined when acorn reads it otherwise. */\nfunction wholeExpression(text: string, options: Readonly<Options>): AnyNode | undefined {\n const read = trySyntax(() => AcornParser.parseExpressionAt(text, 0, options));\n return read.ok && read.value.end === text.length ? read.value : undefined;\n}\n\n/**\n * The call whose callee starts at `start` and whose argument list opens at `paren`, read on its own, up to the end\n * of its argument list: as a call expression, or, with type arguments between the two (which JavaScript reads as\n * comparisons), as its argument list in parentheses. Undefined when acorn reads neither.\n */\nfunction callAt(code: string, start: number, paren: number): GlobCall | undefined {\n const end = argumentsEnd(code, paren);\n if (end === undefined) return undefined;\n const call = wholeExpression(code.slice(start, end), MODULE_OPTIONS);\n if (call?.type === 'CallExpression' && isGlobCallee(call.callee)) return callOf(call.arguments);\n const list = wholeExpression(code.slice(paren, end), { ...MODULE_OPTIONS, preserveParens: true });\n if (list?.type !== 'ParenthesizedExpression') return undefined;\n const { expression } = list;\n return callOf(expression.type === 'SequenceExpression' ? expression.expressions : [expression]);\n}\n\n/** The glob calls of a module's code, and where each call is that could not be read (by offset). */\nexport interface GlobReading {\n readonly calls: readonly GlobCall[];\n readonly unreadable: readonly number[];\n}\n\n/** The glob calls of a module's code: read whole when it is a module, else each call on its own. */\nexport function globCalls(code: string): GlobReading {\n const parsed = trySyntax(() => AcornParser.parse(code, MODULE_OPTIONS));\n if (parsed.ok) {\n const calls = [...nodesOf(parsed.value)].flatMap((node) =>\n node.type === 'CallExpression' && isGlobCallee(node.callee) ? [callOf(node.arguments)] : [],\n );\n return { calls, unreadable: [] };\n }\n const calls: GlobCall[] = [];\n const unreadable: number[] = [];\n for (const match of code.matchAll(GLOB_CALL_START)) {\n const call = callAt(code, match.index, match.index + match[0].length - 1);\n if (call === undefined) unreadable.push(match.index);\n else calls.push(call);\n }\n return { calls, unreadable };\n}\n\n/** Where `offset` is in `code`, as `line:column`, both from 1. */\nfunction lineColumn(code: string, offset: number): string {\n const lines = code.slice(0, offset).split('\\n');\n return `${String(lines.length)}:${String((lines.at(-1)?.length ?? 0) + 1)}`;\n}\n\n/** Characters that make a segment of a pattern match more than its own name (picomatch's, and its escape). */\nconst MAGIC = /[*?[\\]{}()!+@\\\\]/;\n\n/** The characters at the end of a segment after its last MAGIC one. */\nconst LITERAL_END = /[^*?[\\]{}()!+@\\\\]*$/;\n\n/** Whether a pattern's segments may match a name starting with a dot, which a wildcard alone never does. */\nfunction namesDot(segments: readonly string[]): boolean {\n return segments.some((segment) => segment !== '..' && /(?:^|[{,])\\./.test(segment));\n}\n\n/**\n * The scope of the pattern `rest` below an absolute folder `dir` (as the file system spells it, so nothing in it\n * is taken for a wildcard): the folder its leading plain segments name (`..` included), whether the segments after\n * those reach below it, and the literal end of its last segment.\n */\nfunction scopeOf(dir: string, rest: string, exhaustive: boolean): GlobScope {\n const segments = posix.normalize(rest).split('/');\n const magic = segments.findIndex((segment) => MAGIC.test(segment));\n const plain = magic === -1 ? segments.slice(0, -1) : segments.slice(0, magic);\n const below = segments.slice(plain.length);\n return {\n dir: toPosix(plain.reduce((folder, segment) => resolve(folder, segment), dir)),\n deep: below.length > 1 || below.some((segment) => segment.includes('**')),\n dot: exhaustive || namesDot(below),\n exhaustive,\n suffix: (LITERAL_END.exec(below.at(-1) ?? '')?.[0] ?? '').toLowerCase(),\n };\n}\n\n/** How a plugin hook resolves an import, as Vite's import-glob resolves a pattern that is not a path. */\nexport type GlobResolver = (pattern: string) => Promise<string | undefined>;\n\n/**\n * The scopes of the patterns of `call`, made in the module `importer` (a file path, or undefined for a virtual\n * module) under `root`, as Vite's import-glob places them: `/` from the root, `./` and `../` from the importer's\n * folder or the `base` option, `**` from the root, and anything else (an alias, a `#` import) as the resolver\n * resolves it. A negated pattern only takes files away, and has none.\n */\nexport async function scopesOf(\n call: GlobCall,\n importer: string | undefined,\n root: string,\n resolver: GlobResolver,\n): Promise<GlobScope[]> {\n const folder = importer === undefined ? root : dirname(importer);\n const from =\n call.base === undefined ? folder : call.base.startsWith('/') ? join(root, call.base) : resolve(folder, call.base);\n const scopes: GlobScope[] = [];\n for (const pattern of call.patterns) {\n if (pattern.startsWith('!')) continue;\n if (pattern.startsWith('/')) scopes.push(scopeOf(root, pattern.slice(1), call.exhaustive));\n else if (pattern.startsWith('./') || pattern.startsWith('../'))\n scopes.push(scopeOf(from, pattern, call.exhaustive));\n else if (pattern.startsWith('**')) scopes.push(scopeOf(root, pattern, call.exhaustive));\n else {\n const resolved = await resolver(pattern);\n if (resolved === undefined || !isAbsolute(resolved)) continue;\n // The resolver turns the pattern's leading part into a path and keeps the rest; the part the two share at\n // the end is the pattern's own (as Vite's globSafeResolvedPath reads it).\n const spelled = toPosix(resolved);\n let shared = 0;\n while (shared < Math.min(spelled.length, pattern.length) && spelled.at(-1 - shared) === pattern.at(-1 - shared)) {\n shared += 1;\n }\n const cut = spelled.lastIndexOf('/', spelled.length - shared);\n scopes.push(scopeOf(spelled.slice(0, Math.max(cut, 0)) || '/', spelled.slice(cut + 1), call.exhaustive));\n }\n }\n return scopes;\n}\n\n/** A key that is the same for two equal scopes. */\nexport function scopeId(scope: GlobScope): string {\n return JSON.stringify([scope.dir, scope.deep, scope.dot, scope.exhaustive, scope.suffix]);\n}\n\n/**\n * Whether an entry named `name` of a folder in the scope may be matched, or, for a folder, lead to a match. The\n * temporary copies Vite makes of a config file never are: they come and go with every entry build.\n */\nfunction admits(scope: GlobScope, name: string, isDir: boolean): boolean {\n if ((name.startsWith('.') && !scope.dot) || isViteConfigTemp(name)) return false;\n if (isDir) return scope.deep && (scope.exhaustive || name !== 'node_modules');\n return name.toLowerCase().endsWith(scope.suffix);\n}\n\n/** What was in a scope when it was read (see readScope). */\nexport interface ScopeContents {\n /**\n * A string that changes when a file the glob may match is added to the scope, removed from it or renamed in it,\n * or a linked folder in it is retargeted, and stays the same otherwise.\n */\n readonly listing: string;\n /** The folders a deep scope reaches through links, by real path (forward slashes). */\n readonly linked: readonly string[];\n}\n\n/** The real path (forward slashes) of the folder the link at `path` leads to; undefined for a link to anything else. */\nfunction linkedFolder(path: string): string | undefined {\n try {\n return statSync(path).isDirectory() ? canonicalPath(path) : undefined;\n } catch {\n return undefined; // A dangling link.\n }\n}\n\n/**\n * What is in a scope: the files of its folder that `admits` lets through, and for a deep scope the folders below\n * it and theirs. A link to a folder is followed, as Vite's import-glob follows it, and listed with its target, so\n * retargeting it shows; a folder already listed (a link back to a folder above, or a second link to one) is not\n * listed again, as Vite's crawler does not crawl it again. A link to a file is listed as a file. A scope whose folder\n * does not exist (yet) lists as missing.\n */\nexport function readScope(scope: GlobScope): ScopeContents {\n const entries: string[] = [];\n const linked = new Set<string>();\n const visited = new Set<string>();\n const list = (dir: string, prefix: string): boolean => {\n let found;\n try {\n found = readdirSync(dir, { withFileTypes: true });\n } catch {\n return false;\n }\n visited.add(fileKey(dir));\n for (const entry of found.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))) {\n const path = `${prefix}${entry.name}`;\n const target = entry.isSymbolicLink() ? linkedFolder(join(dir, entry.name)) : undefined;\n const isDir = entry.isDirectory() || target !== undefined;\n if (!admits(scope, entry.name, isDir)) continue;\n entries.push(target === undefined ? `${isDir ? 'd' : 'f'}:${path}` : `l:${path}>${target}`);\n if (target !== undefined) {\n if (visited.has(fileKey(target))) continue;\n linked.add(target);\n }\n if (isDir) list(join(dir, entry.name), `${path}/`);\n }\n return true;\n };\n const listing = list(scope.dir, '') ? entries.join('\\n') : '\\0missing';\n return { listing, linked: [...linked] };\n}\n\n/** What is in a scope, as readScope lists it. */\nexport function scopeListing(scope: GlobScope): string {\n return readScope(scope).listing;\n}\n\n/**\n * Whether adding or removing the file (or folder, `isDir`) at `path` may change what the glob of `scope` matches:\n * it is in the scope, or in one of the folders it reaches through links (`linked`, see readScope), and `admits`\n * lets it through, or it is one of those folders itself. Folders are compared by identity key, so one is\n * recognised however the path spells it, through a link or not.\n */\nexport function scopeAdmits(scope: GlobScope, path: string, isDir: boolean, linked: readonly string[]): boolean {\n const folders = [scope.dir, ...(scope.deep ? linked : [])].map(fileKey);\n if (folders.includes(fileKey(path))) return true;\n const parent = fileKey(dirname(path));\n return (scope.deep ? keyWithin(parent, folders) : parent === folders[0]) && admits(scope, basename(path), isDir);\n}\n\n/**\n * The folders a watcher watches for `scopes`: each scope's folder, or, for one that does not exist, the nearest\n * folder above it that does, where creating it shows; and the folders a deep scope reaches through links, which a\n * watcher of the scope's folder may not follow.\n */\nexport function scopeWatchTargets(scopes: Iterable<GlobScope>): string[] {\n return [\n ...new Set(\n [...scopes].flatMap((scope) => [\n toPosix(missingImportFolders([scope.dir])[0] ?? scope.dir),\n ...readScope(scope).linked,\n ]),\n ),\n ];\n}\n\n/**\n * The part of a plugin's transform hook context the glob reading uses: resolving an import, and warning.\n */\ninterface GlobHookContext {\n resolve(\n source: string,\n importer?: string,\n options?: { custom?: Record<string, unknown> },\n ): Promise<{ readonly id: string } | null>;\n warn(message: string): void;\n}\n\n/**\n * The file `pattern` (an alias or a `#` import, not a path) resolves to from `importer`, asked as Vite's\n * import-glob asks; undefined when it resolves to none, or the resolver fails (Vite's import-glob then reports\n * the pattern itself).\n */\nasync function resolveGlob(context: GlobHookContext, pattern: string, importer: string): Promise<string | undefined> {\n const isSubImportsPattern = pattern.startsWith('#') && pattern.includes('*');\n try {\n const resolved = await context.resolve(pattern, importer, {\n custom: { 'vite:import-glob': { isSubImportsPattern } },\n });\n return resolved?.id.replace(/[?#].*$/s, '');\n } catch {\n return undefined;\n }\n}\n\n/**\n * The scopes of the glob calls in a module's code, read in a plugin's transform hook, whose `context` resolves an\n * alias or `#` pattern as Vite's import-glob would; a call acorn cannot read is reported with a warning and has\n * none.\n */\nexport async function moduleGlobScopes(\n context: GlobHookContext,\n code: string,\n id: string,\n root: string,\n): Promise<GlobScope[]> {\n if (!mayHoldGlob(code)) return [];\n const { calls, unreadable } = globCalls(code);\n if (unreadable.length > 0) {\n const where = unreadable.map((offset) => lineColumn(code, offset)).join(', ');\n context.warn(\n `twee-ts could not read the import.meta.glob() call at ${where} of ${id}; ` +\n 'files added to its folders are bundled the next time something else changes.',\n );\n }\n const file = id.replace(/[?#].*$/s, '');\n const importer = isAbsolute(file) && !id.startsWith('\\0') ? file : undefined;\n const resolver: GlobResolver = (pattern) => resolveGlob(context, pattern, id);\n const scopes = await Promise.all(calls.map((call) => scopesOf(call, importer, root, resolver)));\n return scopes.flat();\n}\n","/**\n * Bundling the Vite plugin's `entry` into one script and one stylesheet for the\n * story. In a build, the plugin bundles the entry inside the user's build when\n * it can (see entryInputSettings), and otherwise, and always in dev, with a\n * build of its own: bundleEntry() below, which replays the user's configuration.\n */\nimport { existsSync, statSync } from 'node:fs';\nimport { dirname, isAbsolute, join, resolve, win32 } from 'node:path';\nimport { build, createIdResolver, loadConfigFromFile, mergeConfig } from 'vite';\nimport type {\n BuildEnvironmentOptions,\n ConfigEnv,\n InlineConfig,\n LogLevel,\n Logger,\n Plugin,\n RenderBuiltAssetUrl,\n ResolvedConfig,\n UserConfig,\n} from 'vite';\nimport type { InlineSource } from '../types.js';\nimport { toPosix } from './paths.js';\nimport { moduleGlobScopes } from './vite-glob.js';\nimport type { GlobScope } from './vite-glob.js';\nimport { isRecord } from '../util.js';\n\n/** The plugin's name, which is also how the entry build tells it from the user's other plugins. */\nexport const PLUGIN_NAME = 'twee-ts';\n\n/** Passage names the bundled entry takes inside the story. */\nconst ENTRY_SCRIPT_NAME = 'twee-ts-entry.js';\nconst ENTRY_STYLE_NAME = 'twee-ts-entry.css';\n\n/** How the name of the entry's input starts when the plugin bundles it inside the user's build. */\nexport const ENTRY_INPUT_NAME = 'twee-ts-entry';\n\n/** Which Vite command a configuration is evaluated for. */\nexport type ViteCommand = ConfigEnv['command'];\n\n/**\n * The bundled entry: its script, its stylesheet, the files it was built from\n * (forward-slash paths: its modules and the files its plugins watch), and any\n * files the bundler still emits separately (by output file name).\n */\nexport interface EntryBundle {\n readonly script: string;\n readonly style: string;\n readonly files: ReadonlySet<string>;\n readonly assets: ReadonlyMap<string, string | Uint8Array>;\n}\n\n/** The error for a file the entry emits under a name the build (or another story's entry) already writes. */\nexport function entryCollisionMessage(fileName: string): string {\n return `twee-ts: the entry emits ${fileName}, a file the build already writes; rename one of them.`;\n}\n\n/** The entry's script and stylesheet as inline sources of the story (none without an entry). */\nexport function entrySources(entry: EntryBundle | undefined): InlineSource[] {\n if (entry === undefined) return [];\n return [\n // The leading `;` ends an unterminated statement of the script passage before it, which would otherwise take\n // the entry's opening parenthesis as a call.\n { filename: ENTRY_SCRIPT_NAME, content: `;${entry.script}` },\n ...(entry.style === '' ? [] : [{ filename: ENTRY_STYLE_NAME, content: entry.style }]),\n ];\n}\n\n/** The parts of a Vite output bundle item this plugin reads. */\nexport type BundleItem =\n | {\n readonly type: 'chunk';\n readonly code: string;\n readonly isEntry: boolean;\n readonly name: string;\n readonly moduleIds: readonly string[];\n }\n | {\n readonly type: 'asset';\n readonly source: string | Uint8Array;\n /** The source files the bundler made the asset from (the bundler's own stylesheet names no file). */\n readonly originalFileNames?: readonly string[] | undefined;\n };\n\n/** The bundler options of a build (Rolldown's, under Vite 8). */\ntype BundlerOptions = NonNullable<BuildEnvironmentOptions['rolldownOptions']>;\n\n/** The bundler's `output` option: one output's options or several. */\ntype OutputOption = BundlerOptions['output'];\n\n/** One output's options. */\ntype OutputOptions = Exclude<NonNullable<OutputOption>, readonly unknown[]>;\n\n/**\n * The output options of the entry's bundle: one IIFE script, and assets under\n * their own names, so a build writes them where the dev server serves them.\n */\nconst ENTRY_OUTPUT = {\n format: 'iife',\n entryFileNames: ENTRY_SCRIPT_NAME,\n assetFileNames: '[name][extname]',\n} as const satisfies OutputOptions;\n\n/**\n * The output options of the entry's bundle given the user's `output` option:\n * the user's own when it is one object, with the entry's format and file names\n * on top. An array of outputs describes the user's own files; none of them\n * applies to the entry.\n */\nexport function entryOutput(userOutput: OutputOption): OutputOptions {\n return userOutput === undefined || Array.isArray(userOutput)\n ? { ...ENTRY_OUTPUT }\n : { ...userOutput, ...ENTRY_OUTPUT };\n}\n\n/**\n * Settings that make every font and image the entry uses inline as a data URL,\n * and its CSS one stylesheet, so the story stays one file; only an import marked\n * `?no-inline` is still emitted separately.\n */\nconst ONE_FILE = { cssCodeSplit: false, assetsInlineLimit: (): boolean => true } as const;\n\n/**\n * What `import.meta.url` stands for in the entry's script, given the story's output file name. The script runs\n * as a classic script inside the story page, where `import.meta` does not exist (the bundler leaves `{}.url`, so\n * `new URL(asset, import.meta.url)` and Vite's worker URLs throw `Invalid URL`). The files the build writes\n * besides the story, such as an asset marked `?no-inline`, are found from the output folder the story is below,\n * so the base is the story page's URL, taken up one level for each folder of a nested `outputFilename`.\n */\nfunction entryDefine(outputFilename: string): { readonly 'import.meta.url': string } {\n const depth = folderDepth(outputFilename);\n const base =\n depth === 0 ? 'document.baseURI' : `new URL(${JSON.stringify('../'.repeat(depth))}, document.baseURI).href`;\n return { 'import.meta.url': base };\n}\n\n/** How many folders deep `outputFilename` puts the story below the output folder. */\nfunction folderDepth(outputFilename: string): number {\n return outputFilename.split('/').length - 1;\n}\n\n/**\n * The `experimental.renderBuiltUrl` of a build that bundles the entry, given the build's `base`, the story's\n * `outputFilename` and the configuration's own `renderBuiltUrl` (`user`, which decides first), or `user` itself\n * when nothing changes. With a relative `base` (`''` or `'./'`), Vite makes the URL of a file the build writes\n * besides the story (an asset marked `?no-inline`, a worker) relative to the script or stylesheet that names it.\n * The story page holds both inline, so such a URL resolves against the page, which a nested `outputFilename` puts\n * below the output folder the files are written to. For the entry's script, the URL is then resolved at run time\n * against the output folder, as `import.meta.url` is (see `entryDefine`); in its stylesheet, it is a path up from\n * the page. Every stylesheet of such a build is the entry's: the build bundles nothing else.\n */\nexport function entryRenderBuiltUrl(\n base: string | undefined,\n outputFilename: string,\n user: RenderBuiltAssetUrl | undefined,\n): RenderBuiltAssetUrl | undefined {\n const depth = folderDepth(outputFilename);\n if ((base !== '' && base !== './') || depth === 0) return user;\n const outputFolder = entryDefine(outputFilename)['import.meta.url'];\n return (filename, type) => {\n const own = user?.(filename, type);\n if (own !== undefined) return own;\n // As Vite writes a file name into a URL.\n const path = filename.replaceAll('%', '%25');\n if (type.hostType === 'js' && type.hostId === ENTRY_SCRIPT_NAME) {\n return { runtime: `new URL(${JSON.stringify(path)}, ${outputFolder}).href` };\n }\n return type.hostType === 'css' ? `${'../'.repeat(depth)}${path}` : undefined;\n };\n}\n\n/**\n * Build settings that bundle the entry inside the user's build, as its only\n * input, under `inputName`, which tells the plugin instance it is its own, and\n * what the bundled script needs to run in the story (`define`).\n */\nexport function entryInputSettings(\n inputName: string,\n entryPath: string,\n userOutput: OutputOption,\n outputFilename: string,\n): { readonly build: BuildEnvironmentOptions; readonly define: Record<string, string> } {\n return {\n build: { ...ONE_FILE, rolldownOptions: { input: { [inputName]: entryPath }, output: entryOutput(userOutput) } },\n define: entryDefine(outputFilename),\n };\n}\n\n/** Removes a trailing source-map comment that points at a file (a data: URL map stays). */\nfunction dropFileSourceMapComment(code: string): string {\n return code\n .replace(/\\n?\\/\\/# sourceMappingURL=(?!data:)\\S*\\s*$/, '')\n .replace(/\\n?\\/\\*# sourceMappingURL=(?!data:)[^*]*\\*\\/\\s*$/, '');\n}\n\n/** A module id or watched file as a forward-slash file path, without a query or hash (like Vite's cleanUrl). */\nexport function fileOfId(id: string): string {\n return toPosix(id.replace(/[?#].*$/s, ''));\n}\n\n/** Removes a file from a bundle, which bundlers hand plugins as a plain object keyed by file name. */\nexport function removeFromBundle(bundle: Record<string, unknown>, fileName: string): void {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete -- the bundle object is the bundler's API.\n delete bundle[fileName];\n}\n\n/**\n * Whether an asset is a file the entry imported as a URL (`theme.css?url`), not the stylesheet the bundler made\n * of the entry's CSS. The bundler names the files an asset came from; for its own stylesheet that is a bare\n * output name (`style.css`), for an imported file the file's path.\n */\nfunction isImportedFile(item: Extract<BundleItem, { type: 'asset' }>): boolean {\n return (item.originalFileNames ?? []).some((name) => isAbsolute(name) || win32.isAbsolute(name));\n}\n\n/**\n * Takes the entry out of a bundle: its entry chunk (the one named `inputName`,\n * when the entry is one input of the user's build; the only one, from the\n * entry's own build), every stylesheet it made of the entry's CSS (a CSS file imported as a URL stays an asset), and the map files, which the story\n * cannot ship. The chunk is found by its input's name, not by its module's\n * path, which the bundler may spell another way (a root reached through a\n * link is read by its real path). Anything else the bundler emitted for it\n * stays in the bundle, so a build writes it next to the HTML, and is also\n * returned, so the dev server can serve it.\n */\nexport function takeEntryFromBundle(bundle: Record<string, BundleItem>, inputName?: string): EntryBundle {\n let script = '';\n const files = new Set<string>();\n const assets = new Map<string, string | Uint8Array>();\n const styles: string[] = [];\n for (const [fileName, item] of Object.entries(bundle)) {\n if (item.type === 'chunk') {\n if (!item.isEntry || (inputName !== undefined && item.name !== inputName)) continue;\n script = dropFileSourceMapComment(item.code);\n for (const id of item.moduleIds) if (!id.startsWith('\\0')) files.add(fileOfId(id));\n removeFromBundle(bundle, fileName);\n } else if (fileName.endsWith('.css') && !isImportedFile(item)) {\n const css = typeof item.source === 'string' ? item.source : new TextDecoder().decode(item.source);\n styles.push(dropFileSourceMapComment(css));\n removeFromBundle(bundle, fileName);\n } else if (fileName.endsWith('.map')) {\n removeFromBundle(bundle, fileName);\n } else {\n assets.set(fileName, item.source);\n }\n }\n return { script, style: styles.join('\\n'), files, assets };\n}\n\n/**\n * The entry build's logger: its warnings go to the outer logger; its progress\n * lines and its own \"build failed\" line are dropped, because the plugin\n * reports a failed bundle itself. (The progress lines Vite 8 prints itself are\n * kept quiet by the entry build's log level; see bundleEntry.)\n */\nfunction entryBuildLogger(outer: Logger): Logger {\n return {\n info: () => {\n // Progress lines are dropped.\n },\n warn: (message, options) => {\n outer.warn(message, options);\n },\n warnOnce: (message, options) => {\n outer.warnOnce(message, options);\n },\n error: () => {\n // The plugin reports a failed bundle itself.\n },\n clearScreen: () => {\n // The outer screen is not the entry build's to clear.\n },\n hasErrorLogged: () => false,\n get hasWarned() {\n return outer.hasWarned;\n },\n };\n}\n\n/**\n * The entry build's log level: no progress lines (Vite 8 prints those itself\n * at `info`), and no more than the outer build or server shows.\n */\nexport function entryBuildLogLevel(outer: LogLevel | undefined): LogLevel {\n return outer === undefined || outer === 'info' ? 'warn' : outer;\n}\n\n/**\n * Top-level keys of the user's configuration the entry build doesn't take, and\n * why. Everything else (define, resolve, css, json, esbuild/oxc, env options,\n * base, assetsInclude, worker, build options, environments, experimental and\n * the rest) comes across as the user gave it, so the entry bundles the same in\n * dev as in a build.\n */\nexport const ENTRY_BUILD_EXCLUDED_KEYS: Readonly<Record<string, string>> = {\n configFile: 'the entry build is given the loaded config file itself',\n plugins: 'replaced by the same plugins without twee-ts, plus the entry build’s own',\n root: 'set to the resolved root',\n mode: 'set to the resolved mode',\n logLevel: 'set so the entry build prints no progress lines',\n customLogger: 'the entry build reports through the outer logger',\n clearScreen: 'the entry build never clears the screen',\n publicDir: 'set to the outer build’s resolved public directory, which the entry build resolves from but never copies',\n server: 'configures the dev server, not a build',\n preview: 'configures the preview server, not a build',\n builder: 'would build every environment instead of the entry',\n devtools: 'starts Vite’s devtools integration, which belongs to the outer server or build',\n};\n\n/** The user's configuration without the keys the entry build doesn't take. */\nfunction withoutExcludedKeys(config: UserConfig): UserConfig {\n const copy: UserConfig = { ...config };\n for (const key of Object.keys(ENTRY_BUILD_EXCLUDED_KEYS)) Reflect.deleteProperty(copy, key);\n return copy;\n}\n\n/** A plugin option (nested arrays, promises, falsy entries) as one flat list. */\nasync function flattenPlugins(option: unknown): Promise<unknown[]> {\n const value: unknown = await option;\n if (Array.isArray(value)) return (await Promise.all(value.map(flattenPlugins))).flat();\n return value ? [value] : [];\n}\n\nfunction isPlugin(value: unknown): value is Plugin {\n return isRecord(value) && typeof value['name'] === 'string';\n}\n\n/** The handler of a plugin hook in function or object form. */\nfunction hookHandler(hook: unknown): unknown {\n return isRecord(hook) ? hook['handler'] : hook;\n}\n\n/** A hook with its handler replaced, keeping the object form's order and other fields. */\nfunction withHandler(hook: unknown, handler: (this: unknown, ...args: unknown[]) => unknown): unknown {\n return isRecord(hook) ? { ...hook, handler } : handler;\n}\n\n/**\n * Whether Vite applies `plugin` for `command`: as Vite reads `apply`, with\n * the configuration and environment the plugin would see.\n */\nfunction appliesTo(plugin: Plugin, command: ViteCommand, config: UserConfig, env: ConfigEnv): boolean {\n const { apply } = plugin;\n if (apply === undefined) return true;\n if (typeof apply === 'function') return apply({ ...config, mode: env.mode }, env);\n return apply === command;\n}\n\n/**\n * `plugin` as the entry build runs it: without `apply` (already decided by\n * appliesTo), and, for the dev command, with its `config`, `configEnvironment`\n * and `configResolved` hooks seeing the dev command, as the dev server's\n * instance of the plugin sees it. The plugin object itself is left untouched.\n */\nfunction asEntryBuildPlugin(plugin: Plugin, command: ViteCommand): Plugin {\n const overrides = new Map<PropertyKey, unknown>([['apply', undefined]]);\n if (command === 'serve') {\n const devEnv = (env: unknown): unknown => Object.assign({}, env, { command, isSsrBuild: false });\n const wrap = (name: 'config' | 'configEnvironment' | 'configResolved', patch: (args: unknown[]) => unknown[]) => {\n const hook: unknown = plugin[name];\n const handler = hookHandler(hook);\n if (typeof handler !== 'function') return;\n overrides.set(\n name,\n withHandler(hook, function (this: unknown, ...args: unknown[]): unknown {\n return Reflect.apply(handler, this, patch(args));\n }),\n );\n };\n wrap('config', ([config, env]) => [config, devEnv(env)]);\n wrap('configEnvironment', ([name, config, env]) => [name, config, devEnv(env)]);\n wrap('configResolved', ([config]) => [\n isRecord(config) ? withOverrides(config, new Map([['command', command]])) : config,\n ]);\n }\n return pluginWith(plugin, overrides);\n}\n\n/**\n * A copy of `plugin` with some properties of its own reading differently; the plugin itself is left untouched. The\n * copy has the plugin's prototype (a class's methods and getters) and each of its own properties as they are\n * defined (a getter stays a getter), so a frozen plugin, or one whose hooks are getters, is copied as well: a Proxy\n * may not answer differently for a property a frozen object defines. The copy stands in for the plugin wherever\n * the plugin list has it.\n */\nexport function pluginWith(plugin: Plugin, overrides: ReadonlyMap<PropertyKey, unknown>): Plugin {\n const copy: Plugin = { ...plugin };\n // Between the copy and the plugin's prototype, the overridden properties as plain writable ones: Vite clones a\n // plugin by assigning its own properties to an object of the same prototype, which fails for a property that\n // prototype has only a getter for (a class whose hook is a getter).\n const layer = {};\n Object.setPrototypeOf(layer, Reflect.getPrototypeOf(plugin));\n for (const [key, value] of overrides) {\n Object.defineProperty(layer, key, { value, writable: true, enumerable: false, configurable: true });\n }\n Object.setPrototypeOf(copy, layer);\n for (const key of Reflect.ownKeys(plugin)) {\n const descriptor = Object.getOwnPropertyDescriptor(plugin, key);\n if (descriptor !== undefined && !overrides.has(key)) Object.defineProperty(copy, key, descriptor);\n }\n for (const [key, value] of overrides) {\n Object.defineProperty(copy, key, { value, writable: true, enumerable: true, configurable: true });\n }\n return copy;\n}\n\n/** `target` with some properties reading differently; the object itself is left untouched. */\nfunction withOverrides<T extends object>(target: T, overrides: ReadonlyMap<PropertyKey, unknown>): T {\n return new Proxy(target, {\n get(object, key, receiver) {\n const value: unknown = overrides.has(key) ? overrides.get(key) : Reflect.get(object, key, receiver);\n return value;\n },\n });\n}\n\n/**\n * Build settings that make the entry the build's one input and its bundle one\n * script and one stylesheet held in memory, whatever the user's build settings\n * say; for the dev command also unminified, with an inline source map. Settings\n * that would build something else (`lib`, `ssr`) or write files are dropped.\n */\nfunction entryBuildSettings(\n userBuild: BuildEnvironmentOptions | undefined,\n entryPath: string,\n command: ViteCommand,\n): BuildEnvironmentOptions {\n // A user config may still use the old name, which Vite 8 accepts for `rolldownOptions`.\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- read so it can be replaced.\n const { lib: _lib, ssr: _ssr, rollupOptions, rolldownOptions, ...rest } = { ...userBuild };\n const { input: _input, output, ...bundler }: BundlerOptions = rolldownOptions ?? rollupOptions ?? {};\n return {\n ...rest,\n ...ONE_FILE,\n write: false,\n watch: null,\n emptyOutDir: false,\n copyPublicDir: false,\n ...(command === 'serve' ? { minify: false, sourcemap: 'inline' } : {}),\n rolldownOptions: { ...bundler, input: entryPath, output: entryOutput(output) },\n };\n}\n\n/**\n * Applies entryBuildSettings last, after every config hook, in the\n * configuration and in the client environment's own options (which the build\n * reads), so no setting from the user or a plugin makes the entry build build\n * or write anything else.\n */\nfunction entryBuildEnforcer(entryPath: string, command: ViteCommand, outputFilename: string): Plugin {\n return {\n name: `${PLUGIN_NAME}:entry-build`,\n enforce: 'post',\n config: {\n order: 'post',\n handler(config) {\n config.build = entryBuildSettings(config.build, entryPath, command);\n config.define = { ...config.define, ...entryDefine(outputFilename) };\n const renderBuiltUrl = entryRenderBuiltUrl(config.base, outputFilename, config.experimental?.renderBuiltUrl);\n if (renderBuiltUrl !== undefined) config.experimental = { ...config.experimental, renderBuiltUrl };\n },\n },\n configEnvironment: {\n order: 'post',\n handler(name, config) {\n if (name !== 'client') return;\n config.build = entryBuildSettings(config.build, entryPath, command);\n config.define = { ...config.define, ...entryDefine(outputFilename) };\n },\n },\n };\n}\n\n/** Build-phase plugin hooks that may call `this.addWatchFile`. */\nconst WATCH_FILE_HOOKS = [\n 'buildStart',\n 'resolveId',\n 'resolveDynamicImport',\n 'load',\n 'transform',\n 'moduleParsed',\n 'buildEnd',\n] as const;\n\n/** A plugin context whose `addWatchFile` also passes the file to `record`. */\nfunction recordingContext(context: object, record: (file: string) => void): object {\n return new Proxy(context, {\n get(target, key) {\n const value: unknown = Reflect.get(target, key, target);\n if (typeof value !== 'function') return value;\n if (key !== 'addWatchFile') {\n const bound: unknown = value.bind(target);\n return bound;\n }\n return (id: unknown): unknown => {\n if (typeof id === 'string' && !id.startsWith('\\0')) record(fileOfId(resolve(id)));\n return Reflect.apply(value, target, [id]);\n };\n },\n });\n}\n\n/**\n * `plugin` with hooks that pass the file of each of its `addWatchFile` calls to `record`. The\n * original stays untouched, so a plugin object shared across entry builds\n * never collects wrappers. A plugin without such hooks (a built-in one, for\n * instance) is returned as it is.\n */\nfunction recordingPlugin(plugin: Plugin, record: (file: string) => void): Plugin {\n const overrides = new Map<PropertyKey, unknown>();\n for (const name of WATCH_FILE_HOOKS) {\n const hook = plugin[name];\n const handler = hookHandler(hook);\n if (typeof handler !== 'function') continue;\n overrides.set(\n name,\n withHandler(hook, function (this: unknown, ...args: unknown[]): unknown {\n const context = typeof this === 'object' && this !== null ? recordingContext(this, record) : this;\n return Reflect.apply(handler, context, args);\n }),\n );\n }\n return overrides.size === 0 ? plugin : pluginWith(plugin, overrides);\n}\n\nconst isFile = (path: string): boolean => statSync(path, { throwIfNoEntry: false })?.isFile() === true;\n\n/** A resolver Vite makes for plugins (see keptPath). */\ntype IdResolver = ReturnType<typeof createIdResolver>;\n\n/** The part of a plugin hook's context the import spellings use: the environment the hook runs in. */\nexport interface ImportHookContext {\n readonly environment: Parameters<IdResolver>[0];\n}\n\n/** How an import is resolved with its links kept (see keptPath), one resolver per configuration. */\nconst keptResolvers = new WeakMap<ResolvedConfig, IdResolver>();\n\n/**\n * Makes keptPath resolve with a new resolver for `config`: Vite's resolver remembers what it found, which a build of\n * `vite build --watch` must not take from the one before.\n */\nexport function forgetKeptResolver(config: ResolvedConfig): void {\n keptResolvers.delete(config);\n}\n\n/**\n * The file `source`, imported by `importer`, reaches as Vite's resolver finds it, with the links on the way kept\n * (`resolve.preserveSymlinks`): the path through a linked file, folder or package folder, which the module's own\n * (real) path never shows. It follows every spelling Vite's resolver reads: relative and absolute paths, the root's\n * `/`, missing extensions, a folder's index, `resolve.alias`, bare package names, a package's subpaths and exports,\n * `#` subpath imports and `resolve.tsconfigPaths`. Undefined for an import it resolves to no file (a virtual module,\n * an external one, one it cannot resolve), or when resolving fails, which the bundle itself then reports.\n */\nasync function keptPath(\n context: ImportHookContext,\n source: string,\n importer: string | undefined,\n): Promise<string | undefined> {\n const { environment } = context;\n let resolver = keptResolvers.get(environment.config);\n if (resolver === undefined) {\n resolver = createIdResolver(environment.config, { preserveSymlinks: true });\n keptResolvers.set(environment.config, resolver);\n }\n try {\n const id = await resolver(environment, source, importer);\n return id === undefined || id.startsWith('\\0') ? undefined : fileOfId(id);\n } catch {\n return undefined;\n }\n}\n\n/**\n * The paths an import of `source` by `importer` is written as, absolute and with forward slashes, when it is written\n * as a path: relative to the importer, or absolute; also when that reaches nothing yet, so creating it shows. None for\n * a bare name or an alias. An absolute path that starts with `/` is read as Vite reads it: from the root first, unless\n * it already names a path inside the root, and as a path of the file system when that is where it reaches a file.\n */\nfunction writtenPaths(source: string, importer: string | undefined, root: string): string[] {\n const from = importer === undefined ? undefined : fileOfId(importer);\n if (isAbsolute(source)) {\n const file = fileOfId(source);\n const fromRoot =\n /^[/\\\\]/.test(source) && !file.startsWith(`${toPosix(root).replace(/\\/$/, '')}/`) && !existsSync(file)\n ? [fileOfId(join(root, source))]\n : [];\n return [...fromRoot, file];\n }\n return from !== undefined && isAbsolute(from) && /^\\.\\.?(?:[/\\\\]|$)/.test(source)\n ? [fileOfId(resolve(dirname(from), source))]\n : [];\n}\n\n/**\n * Every path an import of `source` by `importer` is spelled as (see writtenPaths), and the path Vite's resolver\n * reaches the file by, links kept (`kept`, see keptPath). A caller then sees a link on the way that is retargeted,\n * which the file's own path never shows. Nothing for an import from a virtual module, or of one.\n */\nexport async function importSpellings(\n context: ImportHookContext,\n source: string,\n importer: string | undefined,\n root: string,\n): Promise<{ readonly spellings: readonly string[]; readonly kept: string | undefined }> {\n if (source.startsWith('\\0') || (importer?.startsWith('\\0') ?? false)) return { spellings: [], kept: undefined };\n const written = writtenPaths(source, importer, root);\n // A path written to a file that is there is the one Vite's resolver takes, links and all; only an import written\n // otherwise (a bare name, an alias, a missing extension, a folder) is resolved, which halves the work of a graph\n // of relative imports.\n const resolved = written.find(isFile) ?? (await keptPath(context, source, importer));\n const kept = resolved !== undefined && isAbsolute(resolved) ? resolved : undefined;\n return { spellings: [...new Set([...written, ...(kept === undefined ? [] : [kept])])], kept };\n}\n\n/**\n * What a caller of bundleEntry learns as the entry build runs, filled in also when the build fails (the files of a\n * failed bundle are the ones whose fixing bundles it again):\n * - `watchFiles`: the files the build's plugins add with `addWatchFile`, and the modules of its graph;\n * - `onWatchFile`: each file (or folder) a plugin adds with `addWatchFile`, as it adds it, which is before it\n * reads what it watches;\n * - `onLoad`: each module's file, just before the build reads it;\n * - `onResolve`: each import's path as authored (see recordWatchFiles);\n * - `onGlob`: the scope of each `import.meta.glob()` pattern of a module, just before Vite reads the files it\n * matches (see vite-glob.ts).\n */\nexport interface EntryBuildObserver {\n readonly watchFiles?: Set<string>;\n readonly onWatchFile?: (file: string) => void;\n readonly onLoad?: (file: string) => void;\n readonly onResolve?: (authored: string) => void;\n readonly onGlob?: (scope: GlobScope) => void;\n}\n\n/**\n * Collects the files the entry build's plugins add with `addWatchFile`. These\n * are not modules of the bundle: Vite's CSS plugin adds the stylesheets pulled\n * in by `@import` and the files `url()` points at this way. The build runs on\n * recording stand-ins of its plugins, made in the bundler's `options` hook,\n * which sees the final plugin list, including the plugins Vite resolves per\n * environment (`applyToEnvironment`) after `configResolved`.\n */\nfunction recordWatchFiles(files: Set<string>, root: string, observer: EntryBuildObserver): Plugin {\n const { onLoad, onResolve, onGlob, onWatchFile } = observer;\n const record = (file: string): void => {\n files.add(file);\n onWatchFile?.(file);\n };\n return {\n name: `${PLUGIN_NAME}:record-watch-files`,\n // Called for each module just before its file is read, so a caller can note the file's state as the\n // bundle is about to see it. It reads nothing itself: the module is loaded as usual.\n load: {\n order: 'pre',\n handler(id) {\n const file = fileOfId(id);\n if (!isAbsolute(file) || id.startsWith('\\0')) return null;\n onLoad?.(file);\n // A plugin may resolve a module to a path through a link (or `resolve.preserveSymlinks` keep it), which\n // is then the module's own spelling.\n onResolve?.(file);\n return null;\n },\n },\n // Where each import is spelled, before the bundler follows a link to its target (see importSpellings): a\n // caller then sees a link that is retargeted, which the target's own path never shows. It resolves nothing\n // for the bundle: the import is resolved as usual.\n resolveId: {\n order: 'pre',\n async handler(source, importer) {\n if (onResolve === undefined) return null;\n for (const spelled of (await importSpellings(this, source, importer, root)).spellings) onResolve(spelled);\n return null;\n },\n },\n // The scopes of the module's glob calls. This plugin is the last of the user's, so it sees each module as\n // Vite's import-glob, which runs next, does; it transforms nothing itself.\n transform: {\n filter: { code: 'import.meta.glob' },\n async handler(code, id) {\n if (onGlob === undefined) return null;\n for (const scope of await moduleGlobScopes(this, code, id, root)) onGlob(scope);\n return null;\n },\n },\n // Every module of the graph, also one the bundle renders no code of (a module\n // whose constant the bundler inlined), which the chunk's module list leaves out.\n buildEnd() {\n for (const id of this.getModuleIds()) {\n const file = fileOfId(id);\n if (isAbsolute(file)) files.add(file);\n }\n },\n options: {\n order: 'post',\n async handler(inputOptions) {\n // Vite passes its resolved plugins, which are all plugin objects; anything else is left out, as\n // the user's plugin list is read (see userEntryConfig()).\n const plugins = (await flattenPlugins(inputOptions.plugins))\n .filter(isPlugin)\n .map((p) => recordingPlugin(p, record));\n return { ...inputOptions, plugins };\n },\n },\n };\n}\n\n/** The `worker` options of a configuration. */\ntype WorkerOptions = NonNullable<UserConfig['worker']>;\n\n/**\n * `worker` with `plugin()` after its own `worker.plugins`, which Vite calls for each worker build (nested ones\n * too); the user's plugins come first, in their order, whether given as a function or as the list older Vite\n * versions took.\n */\nexport function withWorkerPlugin(worker: UserConfig['worker'], plugin: () => Plugin): WorkerOptions {\n const own = worker?.plugins;\n // Typed as a function only, but Vite still reads a list (with a warning), which is kept as one item: Vite flattens\n // the list a function returns.\n return { ...worker, plugins: () => [typeof own === 'function' ? own() : own, plugin()] };\n}\n\n/**\n * The user's own configuration as Vite evaluated it for the outer server or\n * build, but for `command`: the config file (when there is one) evaluated\n * again for that command and mode, with what was passed to `createServer()` or\n * `build()` (or the CLI flags) on top, as Vite merges them.\n */\nasync function userConfigFor(config: ResolvedConfig, env: ConfigEnv): Promise<UserConfig> {\n const inline: InlineConfig = config.inlineConfig;\n if (!config.configFile) return inline;\n const loaded = await loadConfigFromFile(\n env,\n config.configFile,\n config.root,\n entryBuildLogLevel(config.logLevel),\n entryBuildLogger(config.logger),\n inline.configLoader,\n );\n return loaded === null ? inline : mergeConfig(loaded.config, inline);\n}\n\n/**\n * Bundles the entry with a Vite build of its own, from the user's own\n * configuration, evaluated for `command`: the config file's function and each\n * plugin's `apply` see that command, and so do the `config`, `configEnvironment`\n * and `configResolved` hooks of the user's plugins. Every setting comes across\n * but those ENTRY_BUILD_EXCLUDED_KEYS lists and the build settings\n * entryBuildSettings decides. twee-ts itself (every instance) is left out.\n */\nexport async function bundleEntry(\n config: ResolvedConfig,\n entryPath: string,\n command: ViteCommand,\n outputFilename: string,\n observer: EntryBuildObserver = {},\n): Promise<EntryBundle> {\n const watchFiles = observer.watchFiles ?? new Set<string>();\n const env: ConfigEnv = { command, mode: config.mode, isSsrBuild: false, isPreview: false };\n const user = await userConfigFor(config, env);\n const plugins = (await flattenPlugins(user.plugins))\n .filter(isPlugin)\n .filter((plugin) => plugin.name !== PLUGIN_NAME && appliesTo(plugin, command, user, env))\n .map((plugin) => asEntryBuildPlugin(plugin, command));\n const inline: InlineConfig = {\n ...withoutExcludedKeys(user),\n configFile: false,\n root: config.root,\n mode: config.mode,\n logLevel: entryBuildLogLevel(config.logLevel),\n customLogger: entryBuildLogger(config.logger),\n clearScreen: false,\n // Public files stay resolvable (`/logo.svg`, base rewriting); `copyPublicDir: false` keeps them uncopied.\n publicDir: config.publicDir || false,\n plugins: [\n ...plugins,\n entryBuildEnforcer(entryPath, command, outputFilename),\n recordWatchFiles(watchFiles, config.root, observer),\n ],\n // A worker the entry starts is bundled by a build nested in this one, with the plugins of `worker.plugins`:\n // its modules, globs and import spellings are the entry's too (#424).\n worker: withWorkerPlugin(user.worker, () => recordWatchFiles(watchFiles, config.root, observer)),\n };\n // One output, as entryBuildSettings sets it, and no watcher (`watch: null`).\n const [result] = [await build(inline)].flat();\n if (result === undefined || !('output' in result)) throw new Error('twee-ts: the entry build returned no bundle.');\n const bundle: Record<string, BundleItem> = Object.fromEntries(result.output.map((item) => [item.fileName, item]));\n const entry = takeEntryFromBundle(bundle);\n return { ...entry, files: new Set([...entry.files, ...watchFiles]) };\n}\n","/**\n * The Vite plugin in the dev server: compiles the story (and bundles the\n * entry) at start and after every change to a file it was built from, serves\n * it at the base URL with Vite's client added, and reports errors to Vite's\n * overlay.\n */\nimport type { IncomingMessage, ServerResponse } from 'node:http';\nimport { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { basename, dirname, join, resolve } from 'node:path';\nimport { stripVTControlCharacters } from 'node:util';\nimport type { Connect, ErrorPayload, ResolvedConfig, ViteDevServer } from 'vite';\nimport type { FileCacheEntry, OutputMode } from '../types.js';\nimport { getFilenames, outputPaths } from '../filesystem.js';\nimport { sha256Hex } from '../format-cache.js';\nimport type { BuildOutputs } from '../filesystem.js';\nimport { mediaTypeFromFilename, normalizedFileExt } from '../media-types.js';\nimport { viteWaitingPage } from '../html-structure.js';\nimport { compileStory, fatalError } from './diagnostics.js';\nimport type { ResolvedPluginOptions } from './options.js';\nimport { canonicalPath, fileKey, isViteConfigTemp, keyWithin, toPosix } from './paths.js';\nimport { bundleEntry, entryCollisionMessage, entrySources, PLUGIN_NAME } from './vite-entry.js';\nimport type { EntryBundle } from './vite-entry.js';\nimport { readScope, scopeAdmits, scopeId, scopeWatchTargets } from './vite-glob.js';\nimport type { GlobScope, ScopeContents } from './vite-glob.js';\nimport { missingImportFolders } from './watch-targets.js';\n\n/** What the dev server needs from the plugin. */\nexport interface DevStoryOptions {\n readonly options: ResolvedPluginOptions;\n readonly cache: Map<string, FileCacheEntry>;\n /** What builds with this config write, which is never a source. */\n readonly outputs: (config: ResolvedConfig) => BuildOutputs;\n /** Adds Vite's client to the story's HTML. */\n readonly injectClient: (html: string, base: string) => string;\n}\n\n/** How long after a change the story is compiled, so saves landing together compile once. */\nconst DEBOUNCE_MS = 50;\n\n/**\n * How long a file the watcher was asked to add may take to be listed as watched, and how long after that its\n * watch may still miss an edit (macOS FSEvents starts reporting a moment after the watch is set up); see\n * `recheckOnceWatched` in setUpDevStory.\n */\nconst WATCH_LISTED_TIMEOUT_MS = 10_000;\nconst WATCH_START_MS = 500;\n\n/** Resolves after `ms`, without keeping the process alive. */\nfunction delay(ms: number): Promise<void> {\n return new Promise((done) => setTimeout(done, ms).unref());\n}\n\n/**\n * The paths under the base URL the story is served at: the output file name,\n * and, as a static host serves it, the folder of an `index.html`.\n */\nexport function storyPaths(outputFilename: string): string[] {\n const index = 'index.html';\n return outputFilename === index || outputFilename.endsWith(`/${index}`)\n ? [outputFilename, outputFilename.slice(0, -index.length)]\n : [outputFilename];\n}\n\n/**\n * `path` (a decoded URL path below the base, with no leading slash) as one spelling: a backslash is a slash, as in\n * an http URL, a `.` segment is dropped and a `..` segment drops the one before it, as the URL standard resolves\n * them (a last `.` or `..` leaves a trailing slash), and empty segments (`a//b`) are dropped, as Vite's file\n * middlewares and static hosts drop them. A `..` never leaves the base.\n */\nfunction oneSpelling(path: string): string {\n const segments = path.replaceAll('\\\\', '/').split('/');\n const kept: string[] = [];\n segments.forEach((segment, at) => {\n const last = at === segments.length - 1;\n if (segment === '..') kept.pop();\n if (segment !== '' && segment !== '.' && segment !== '..') kept.push(segment);\n else if (last) kept.push('');\n });\n return kept.join('/');\n}\n\n/**\n * A request URL's path below `base`, decoded, without query or hash, and with its dot segments, empty segments and\n * backslashes resolved (see oneSpelling), so that every spelling of the story's path is the story (#401); undefined\n * when the path is outside the base or is not a valid percent-encoding.\n */\nexport function pathBelowBase(url: string, base: string): string | undefined {\n const raw = url.replace(/[?#].*$/s, '');\n let path;\n let decodedBase;\n try {\n path = decodeURIComponent(raw);\n decodedBase = decodeURIComponent(base);\n } catch {\n return undefined;\n }\n return path.startsWith(decodedBase) ? oneSpelling(path.slice(decodedBase.length)) : undefined;\n}\n\n/** The reload message for a rebuilt story: limited to the story's pages unless Vite's client could not match them. */\nexport function reloadPayload(base: string, outputFilename: string): { type: 'full-reload'; path?: string } {\n let decoded: string;\n try {\n decoded = decodeURI(base);\n } catch {\n return { type: 'full-reload' };\n }\n return decoded === base ? { type: 'full-reload', path: `/${outputFilename}` } : { type: 'full-reload' };\n}\n\n/** The media type of the story as each output mode writes it. */\nconst OUTPUT_MEDIA_TYPES: Readonly<Record<OutputMode, string>> = {\n html: 'text/html; charset=utf-8',\n 'twine2-archive': 'text/html; charset=utf-8',\n 'twine1-archive': 'text/html; charset=utf-8',\n twee3: 'text/plain; charset=utf-8',\n twee1: 'text/plain; charset=utf-8',\n json: 'application/json; charset=utf-8',\n};\n\n/** Served until the first successful compile, so the overlay has a page to appear on. */\nfunction waitingPage(base: string): string {\n return viteWaitingPage(`${base}@vite/client`);\n}\n\nfunction toOverlayError(e: unknown): ErrorPayload['err'] {\n const error = fatalError(e);\n return {\n // Bundler messages carry terminal colour codes; the overlay would show them raw.\n message: stripVTControlCharacters(error.message),\n stack: '',\n plugin: PLUGIN_NAME,\n ...(error.id ? { id: error.id } : {}),\n ...(error.loc ? { loc: error.loc } : {}),\n };\n}\n\n/**\n * Media types of the files a bundle emits that Tweego's table of story media does not have: a browser\n * refuses a worker or stylesheet served as `application/octet-stream`.\n */\nconst BUNDLE_MEDIA_TYPES: ReadonlyMap<string, string> = new Map([\n ['js', 'text/javascript'],\n ['mjs', 'text/javascript'],\n ['css', 'text/css'],\n ['json', 'application/json'],\n ['map', 'application/json'],\n ['wasm', 'application/wasm'],\n ['html', 'text/html; charset=utf-8'],\n ['txt', 'text/plain; charset=utf-8'],\n]);\n\n/** The media type the dev server gives an asset of the entry's bundle. */\nfunction assetMediaType(path: string): string {\n return BUNDLE_MEDIA_TYPES.get(normalizedFileExt(path)) ?? mediaTypeFromFilename(path);\n}\n\n/**\n * What a change to a file alters: modification time, change time (which an in-place edit that restores the\n * modification time still moves, as the loader's file signature relies on), size and inode (a file replaced by a\n * new one).\n */\nfunction fileState(file: string): string | undefined {\n try {\n const stat = statSync(file);\n return `${stat.mtimeMs}:${stat.ctimeMs}:${stat.size}:${stat.ino}`;\n } catch {\n return undefined; // Missing: it counts as gone.\n }\n}\n\n/**\n * What is in the folder `folder`, at any depth: the name and state (see fileState) of each file and folder in it,\n * links to folders not followed. A file added, removed, renamed or changed anywhere in it changes this, as it\n * makes the bundler's own watcher (`vite build --watch`) build again for a folder a plugin watches. undefined when\n * `folder` is not a folder.\n */\nfunction folderState(folder: string): string | undefined {\n if (statSync(folder, { throwIfNoEntry: false })?.isDirectory() !== true) return undefined;\n let names: string[];\n try {\n names = readdirSync(folder, { recursive: true, encoding: 'utf8' });\n } catch {\n return undefined;\n }\n return names\n .sort()\n .map((name) => `${name}\\0${fileState(join(folder, name)) ?? ''}`)\n .join('\\0');\n}\n\n/**\n * A module's file as the bundle was about to read it: its state (see fileState) and the hash of its content.\n * Taken just before the bundler reads the file, so a write in between makes the file differ from it afterwards.\n */\ninterface FileRead {\n readonly state: string;\n readonly hash: string;\n}\n\n/** `file` as it is now, as a FileRead; undefined when it can't be read. */\nfunction fileRead(file: string): FileRead | undefined {\n const state = fileState(file);\n if (state === undefined) return undefined;\n try {\n return { state, hash: sha256Hex(readFileSync(file)) };\n } catch {\n return undefined;\n }\n}\n\n/**\n * Files by their identity key (see fileKey), each with the path it is read and\n * watched at (its canonical path).\n */\ntype TrackedFiles = ReadonlyMap<string, string>;\n\n/** `paths` as TrackedFiles. */\nfunction tracked(paths: Iterable<string>): TrackedFiles {\n return new Map([...paths].map((path) => [fileKey(path), canonicalPath(path)]));\n}\n\n/**\n * The key of the file `authored` reaches, when it reaches it through a link (somewhere along the path, or\n * at the end of it): the one case where the file's own path says nothing of a change of target.\n * undefined for a path with no link in it, and for one that reaches nothing.\n */\nfunction linkKey(authored: string): string | undefined {\n if (!existsSync(authored)) return undefined;\n return canonicalPath(authored) === toPosix(resolve(authored)) ? undefined : fileKey(authored);\n}\n\n/** The state of each of `files`, by key, for telling later which changed (see filesChanged). */\nfunction fileStates(files: TrackedFiles): Map<string, string> {\n const states = new Map<string, string>();\n for (const [key, path] of files) {\n const state = fileState(path);\n if (state !== undefined) states.set(key, state);\n }\n return states;\n}\n\n/**\n * The states to compare later changes with, for the files a bundle was made from: each file as it was just\n * before the bundle read it (`observed`, noted as each module loads), else as it was before the bundle began\n * (`before`, for a file known from the last bundle), else as it is now. An edit while the bundle was made\n * then differs from the recorded state afterwards, and the next request makes the bundle again.\n */\nfunction settledStates(\n files: TrackedFiles,\n observed: ReadonlyMap<string, string>,\n before: ReadonlyMap<string, string>,\n): Map<string, string> {\n const states = new Map<string, string>();\n for (const [key, path] of files) {\n const state = observed.get(key) ?? before.get(key) ?? fileState(path);\n if (state !== undefined) states.set(key, state);\n }\n return states;\n}\n\n/** The keys of the files added, removed or changed between two `fileStates` results. */\nfunction filesChanged(before: ReadonlyMap<string, string>, after: ReadonlyMap<string, string>): Set<string> {\n const changed = new Set<string>();\n for (const [file, state] of after) if (before.get(file) !== state) changed.add(file);\n for (const file of before.keys()) if (!after.has(file)) changed.add(file);\n return changed;\n}\n\n/**\n * A walk of the story's inputs (see storyInputFiles): its files, and what it depended on: the outputs it left out,\n * what each named input was, and the state (see fileState) of each folder it listed, just before it listed it.\n */\ninterface InputWalk {\n readonly outputs: BuildOutputs;\n readonly named: string;\n readonly folders: ReadonlyMap<string, string | undefined>;\n readonly files: readonly { readonly key: string; readonly path: string; readonly link: boolean }[];\n}\n\n/**\n * The names of Vite's middlewares that answer a request with a file: from the public folder, the module\n * transform, the files of the root and the file system, and the HTML fallback.\n */\nconst VITE_FILE_MIDDLEWARES: ReadonlySet<string> = new Set([\n 'viteServePublicMiddleware',\n 'viteTriggerLazyBundlingMiddleware',\n 'viteMemoryFilesMiddleware',\n 'viteTransformMiddleware',\n 'viteServeRawFsMiddleware',\n 'viteServeStaticMiddleware',\n 'viteHtmlFallbackMiddleware',\n 'viteIndexHtmlMiddleware',\n]);\n\n/**\n * Installs the story's route (see setUpDevStory) among `middlewares`, as the plugin's post hook does: after Vite's\n * checks of a request (host, CORS, proxy, base), so they apply to the story as to any page, and before the first\n * of its middlewares that serve files. A build writes the story and the entry's assets over a public file of the\n * same name, and a static host serves nothing else at their paths, so the dev server must not answer them with a\n * file from the public folder or the root (#339). Appended when none of those middlewares is there.\n */\nexport function installStoryRoute(middlewares: Connect.Server, route: Connect.NextHandleFunction): void {\n const at = middlewares.stack.findIndex(\n ({ handle }) => typeof handle === 'function' && VITE_FILE_MIDDLEWARES.has(handle.name),\n );\n if (at === -1) middlewares.use(route);\n else middlewares.stack.splice(at, 0, { route: '', handle: route });\n}\n\ninterface DevInstance {\n /** The URL paths (below the base) of the instance's story page. */\n readonly paths: readonly string[];\n readonly assets: () => ReadonlyMap<string, string | Uint8Array> | undefined;\n}\n\n/** The story and assets each story instance of a dev server serves, so instances can see each other's names. */\nconst devInstances = new WeakMap<ViteDevServer, Set<DevInstance>>();\n\n/** The error for a story page whose URL another story or an entry asset of the same dev server also claims. */\nfunction storyCollisionMessage(path: string): string {\n return `twee-ts: more than one generated file is served at ${path || '/'} (another story or an entry asset); set a distinct outputFilename.`;\n}\n\nfunction sameBytes(a: string | Uint8Array, b: string | Uint8Array): boolean {\n return Buffer.from(a).equals(Buffer.from(b));\n}\n\n/**\n * Sets up the story in `server`: the first compile, the watcher, and a\n * middleware that notes each request's URL before Vite's own middlewares\n * rewrite it. Resolves, after the first compile, to the middleware that serves\n * the story and the entry's assets, for installStoryRoute.\n */\nexport async function setUpDevStory(server: ViteDevServer, dev: DevStoryOptions): Promise<Connect.NextHandleFunction> {\n const { options, cache } = dev;\n const config = server.config;\n const { base } = config;\n const paths = storyPaths(options.outputFilename);\n const { inputs, excluded: excludedGlob } = options;\n const entryPath = options.entry;\n // Files and folders are compared by identity key (see paths.ts); the inputs are watched as given.\n const root = fileKey(config.root);\n // A source folder may be a symbolic link that is retargeted while the server runs, so its identity is read\n // when it is needed, never kept from startup.\n const inputKeys = (): string[] => inputs.map(fileKey);\n\n // What a build writes, which `vite build` may have left inside a source folder:\n // the story, chunks and assets, and the copies of the public files.\n let outputs = dev.outputs(config);\n let output = outputPaths(outputs);\n const excluded = (file: string): boolean => excludedGlob(file) || output.isOutput(file, inputs);\n server.watcher.add([...inputs]);\n\n const outputMode: OutputMode = options.compile().outputMode ?? 'html';\n let html = '';\n let lastError: ErrorPayload['err'] | undefined;\n let entry: EntryBundle | undefined; // last good bundle\n // The assets of the bundle the page in `html` was compiled with (#360). A later bundle can succeed while the\n // story fails to compile; then the page still served refers to the files of the bundle before it, so those are\n // the files served until a story compiles with the new one.\n let servedAssets: EntryBundle['assets'] | undefined;\n const instances = devInstances.get(server) ?? new Set<DevInstance>();\n devInstances.set(server, instances);\n const self: DevInstance = { paths, assets: () => servedAssets };\n instances.add(self);\n const fail = (res: ServerResponse, message: string): void => {\n config.logger.error(`[twee-ts] ${message}`);\n res.statusCode = 500;\n res.setHeader('Content-Type', 'text/plain; charset=utf-8');\n res.end(message);\n };\n let entryStale = true; // bundle again on the next rebuild\n // The files the entry was last bundled from, and their states then, kept while a\n // later bundle fails, so that fixing one of them (inside the root or not) bundles it again.\n let entryFiles: TrackedFiles = new Map();\n let entryStates = new Map<string, string>();\n // Where the entry and its imports are spelled when that reaches a file through a link, with the key of\n // the file each reached when the bundle read it: retargeting a link changes the key, not the target.\n let entryLinks = new Map<string, string>();\n // Folders where an import the last failed bundle could not resolve would be created (its nearest existing\n // folder), by key; they are among entryFiles, whose state changes when a file is created in one.\n let entryMissingFolders: string[] = [];\n // The scope of each glob pattern of the entry's modules (see vite-glob.ts), by scopeId, and what was in each\n // when the bundle read it (with the folders it reached through links): a file added, removed or renamed there\n // may change what the glob selects. Kept, as entryFiles are, while a later bundle fails.\n let entryGlobs = new Map<string, GlobScope>();\n let globStates = new Map<string, ScopeContents>();\n // Each folder a plugin of the entry build watches (`this.addWatchFile` on a folder, #393), by key, with its path\n // and what was in it (see folderState) when the plugin added it, which is before it read the folder: a file added,\n // removed, renamed or changed in it bundles the entry again, as `vite build --watch` builds again. Kept, as\n // entryFiles are, while a later bundle fails.\n let entryFolders = new Map<string, { readonly path: string; readonly state: string }>();\n // Each module of the last good bundle as it read it, by key: a watcher event for one that is still byte for byte\n // and state for state what the bundle read reports a change the bundle already has (#343). Kept only with a\n // watcher; the catch-up compares states alone.\n let entryReads = new Map<string, FileRead>();\n const readsModules = config.server.watch !== null;\n // Files outside the root the watcher was asked to add for the entry, by key; Vite watches the root itself.\n const watchedForEntry = new Map<string, string>();\n let queue: Promise<void> = Promise.resolve();\n let pending = new Set<string>();\n let timer: ReturnType<typeof setTimeout> | undefined;\n let closed = false;\n // The input files as the last compile found them, to tell whether the watcher\n // missed a change (see catchUp).\n let compiledInputs = new Map<string, string>();\n let catchingUp: Promise<void> | undefined;\n\n // Stops this server's rebuilds when it closes, on close() and restart() alike;\n // no rebuild may start after that, including one whose timer is still pending\n // in middleware mode. Vite closes each server's own watcher then. closeBundle\n // can't tell: it runs for the whole plugin instance, which a restarted server\n // (the plugin passed inline keeps its instance) or a build may share.\n const closeWatcher = server.watcher.close.bind(server.watcher);\n server.watcher.close = async () => {\n closed = true;\n clearTimeout(timer);\n pending.clear();\n return closeWatcher();\n };\n\n // What each named input is, by identity and kind: a link to one retargeted, or a file replaced by a folder,\n // changes it.\n const namedInputs = (): string =>\n inputs\n .map((input) => {\n const stat = statSync(input, { throwIfNoEntry: false });\n const kind = stat === undefined ? 'none' : stat.isFile() ? 'file' : stat.isDirectory() ? 'folder' : 'other';\n return `${fileKey(input)}\\0${kind}`;\n })\n .join('\\0');\n\n // The story's input files as the last walk of the inputs found them, and what that walk depended on.\n let inputWalk: InputWalk | undefined;\n\n const walkInputs = (): InputWalk => {\n const named = namedInputs();\n const folders = new Map<string, string | undefined>();\n const found = getFilenames(inputs, outputs, [], 'source', (folder) => folders.set(folder, fileState(folder)));\n const files = found.files\n .filter((file) => !excludedGlob(file.path))\n .map((file) => ({ key: file.key, path: resolve(file.path), link: file.link === true }));\n return { outputs, named, folders, files };\n };\n\n // The state of each input file of the story, by key. Unless `walk` asks for a new walk of the inputs, the files\n // of the last one are taken while no folder it listed, no named input and no output changed since (#371): a\n // request with nothing changed then costs one look at each folder and file, and identifies no file (but one\n // reached through a link, whose target may have moved).\n const storyInputFiles = (walk: boolean): Map<string, string> => {\n const last = inputWalk;\n const current =\n last !== undefined &&\n !walk &&\n last.outputs === outputs &&\n last.named === namedInputs() &&\n [...last.folders].every(([folder, state]) => fileState(folder) === state);\n const used = current ? last : walkInputs();\n inputWalk = used;\n const states = new Map<string, string>();\n for (const { key, path, link } of used.files) {\n const state = fileState(path);\n if (state !== undefined) states.set(link ? fileKey(path) : key, state);\n }\n return states;\n };\n\n // Whether a change to `file` may change the entry's bundle: after a good bundle,\n // one of the files it was built from (its modules and the files its plugins\n // watch, such as CSS @imports and url() targets); while there is none, or the\n // last one failed, also anything in the project, so that creating a missing\n // import brings it back.\n const touchesEntry = (key: string): boolean =>\n entryPath !== undefined && (entryFiles.has(key) || (entryStale && keyWithin(key, [root, ...entryMissingFolders])));\n\n // Whether a link the entry is spelled through now reaches another file (or none) than the bundle read.\n const linkMoved = (): boolean => [...entryLinks].some(([spelled, key]) => linkKey(spelled) !== key);\n\n // Whether what is in the scope of one of the entry's globs differs from what the bundle read there.\n const globsChanged = (): boolean =>\n [...entryGlobs].some(([id, scope]) => readScope(scope).listing !== globStates.get(id)?.listing);\n\n // Whether what is in a folder the entry build's plugins watch differs from what was there when they added it.\n const foldersChanged = (): boolean =>\n [...entryFolders.values()].some(({ path, state }) => folderState(path) !== state);\n\n // Whether `path` is a folder the entry build's plugins watch, or is in one (at any depth).\n const inWatchedFolder = (path: string): boolean => {\n if (entryPath === undefined || entryFolders.size === 0) return false;\n const folders = [...entryFolders.keys()];\n // The folder above, by identity: a link in a watched folder is in it, wherever its target lies.\n return keyWithin(fileKey(path), folders) || keyWithin(fileKey(dirname(path)), folders);\n };\n\n // Whether adding or removing the file or folder at `path` may change what one of the entry's globs selects.\n const inGlobScope = (path: string, isDir: boolean): boolean =>\n [...entryGlobs].some(([id, scope]) => scopeAdmits(scope, path, isDir, globStates.get(id)?.linked ?? []));\n\n // What the watcher watches for the entry: its files, and the folders of its globs (or the nearest above each\n // that exists, where creating it shows).\n const entryWatchTargets = (): TrackedFiles =>\n new Map([...entryFiles, ...tracked(scopeWatchTargets(entryGlobs.values()))]);\n\n // Watches the entry's files outside the root, and stops watching those it no longer uses.\n const watchEntryFiles = (files: TrackedFiles): void => {\n const added = [...files].filter(\n ([key]) => !keyWithin(key, [root]) && !keyWithin(key, inputKeys()) && !watchedForEntry.has(key),\n );\n const dropped = [...watchedForEntry].filter(([key]) => !files.has(key));\n for (const [key] of dropped) watchedForEntry.delete(key);\n for (const [key, path] of added) watchedForEntry.set(key, path);\n if (dropped.length > 0) server.watcher.unwatch(dropped.map(([, path]) => path));\n if (added.length > 0) {\n server.watcher.add(added.map(([, path]) => path));\n recheckOnceWatched(new Map(added)).catch(keepQueueAlive);\n }\n };\n\n const isListed = (path: string): boolean => {\n const watched: Readonly<Record<string, readonly string[] | undefined>> = server.watcher.getWatched();\n return watched[dirname(path)]?.includes(basename(path)) ?? false;\n };\n\n // The watcher sets up a file it is asked to add some time later, and raises no event for an edit made\n // before that (on macOS, FSEvents starts reporting a moment later still). Once it lists the files, and a\n // moment after, their states are compared with the bundle's, and a change counts as one it reported.\n const recheckOnceWatched = async (files: TrackedFiles): Promise<void> => {\n if (config.server.watch === null) return; // No watcher: the catch-up before serving sees every change.\n const deadline = Date.now() + WATCH_LISTED_TIMEOUT_MS;\n while (!closed && Date.now() < deadline && ![...files.values()].every(isListed)) await delay(DEBOUNCE_MS);\n await delay(WATCH_START_MS);\n if (closed) return;\n // In the queue, so the states are those of the last bundle, not of one under way.\n queue = queue\n .then(() => {\n const own = new Map([...files].filter(([key]) => entryFiles.has(key)));\n const now = fileStates(own);\n const then = new Map([...entryStates].filter(([key]) => own.has(key)));\n for (const key of filesChanged(then, now)) if (watchedForEntry.has(key)) noteChange(key);\n // A glob's folder: what is in it, against what the bundle read there.\n const [folder] = [...files.keys()].filter((key) => !own.has(key) && watchedForEntry.has(key));\n if (folder !== undefined && globsChanged()) noteChange(folder);\n // A folder a plugin watches: what is in it, against what was there when the plugin added it.\n const [watched] = [...files.keys()].filter((key) => entryFolders.has(key) && watchedForEntry.has(key));\n if (watched !== undefined && foldersChanged()) noteChange(watched);\n })\n .catch(keepQueueAlive);\n await queue;\n };\n\n const bundle = async (): Promise<void> => {\n if (entryPath === undefined) return;\n entryStale = true;\n const spelled = new Map<string, string>(); // authored path → key, of each link the bundle went through\n const authoredPaths = new Set<string>(); // every import path as authored\n const watchFiles = new Set<string>(); // what the bundle's plugins watch, and its modules\n const noteSpelling = (authored: string): void => {\n authoredPaths.add(authored);\n const key = linkKey(authored);\n if (key !== undefined && !spelled.has(authored)) spelled.set(authored, key);\n };\n noteSpelling(entryPath);\n if (entry === undefined) {\n // No good bundle yet, so the configured entry is the one file known to matter: watch it\n // (it may lie outside the root) and note its state, so that fixing it bundles again.\n entryFiles = tracked([entryPath]);\n entryStates = fileStates(entryFiles);\n watchEntryFiles(entryWatchTargets());\n }\n // The scopes of the globs this bundle reads, each with what was in it just before Vite read it (so a file\n // added while the bundle is made differs from it afterwards), and what was in the known ones before it began.\n const globs = new Map<string, GlobScope>();\n const globsRead = new Map<string, ScopeContents>();\n const globsBefore = new Map([...entryGlobs].map(([id, scope]) => [id, readScope(scope)]));\n // The folders this bundle's plugins watch, each with what was in it when the plugin added it.\n const folders = new Map<string, { readonly path: string; readonly state: string }>();\n // The files known so far, as they are before the bundle begins, and each module as it is just before\n // the bundle reads it: a file edited while the bundle is made then differs from what is recorded\n // afterwards, which is what the catch-up looks for.\n const before = fileStates(entryFiles);\n const observed = new Map<string, string>();\n const loaded = new Map<string, string>(); // key → path of each module the bundle loaded\n const reads = new Map<string, FileRead>();\n let next: EntryBundle;\n try {\n next = await bundleEntry(config, entryPath, 'serve', options.outputFilename, {\n watchFiles,\n onWatchFile: (file) => {\n const key = fileKey(file);\n if (folders.has(key)) return;\n const path = canonicalPath(file);\n const state = folderState(path);\n if (state !== undefined) folders.set(key, { path, state });\n },\n onLoad: (file) => {\n const key = fileKey(file);\n const read = readsModules ? fileRead(canonicalPath(file)) : undefined;\n const state = read?.state ?? fileState(canonicalPath(file));\n if (state !== undefined && !observed.has(key)) observed.set(key, state);\n if (read !== undefined && !reads.has(key)) reads.set(key, read);\n if (!loaded.has(key)) loaded.set(key, canonicalPath(file));\n },\n onResolve: noteSpelling,\n onGlob: (scope) => {\n const id = scopeId(scope);\n if (globs.has(id)) return;\n globs.set(id, scope);\n globsRead.set(id, readScope(scope));\n },\n });\n } catch (error) {\n // The modules the failed bundle loaded, and the files its plugins watch, are inputs too: fixing an\n // imported one must bundle again. So is the place of an import it could not resolve: creating it must.\n const missing = missingImportFolders(authoredPaths);\n entryMissingFolders = missing.map(fileKey);\n entryFiles = new Map([...entryFiles, ...loaded, ...tracked(watchFiles), ...tracked(missing)]);\n entryStates = settledStates(entryFiles, observed, before);\n entryLinks = new Map([...entryLinks, ...spelled]);\n entryGlobs = new Map([...entryGlobs, ...globs]);\n globStates = new Map([...globsBefore, ...globsRead]);\n entryFolders = new Map([...entryFolders, ...folders]);\n watchEntryFiles(entryWatchTargets());\n throw error;\n }\n entry = next;\n entryStale = false;\n entryFiles = tracked(next.files);\n entryStates = settledStates(entryFiles, observed, before);\n entryLinks = spelled;\n entryMissingFolders = [];\n entryGlobs = globs;\n globStates = globsRead;\n entryFolders = folders;\n entryReads = reads;\n watchEntryFiles(entryWatchTargets());\n };\n\n // Whether the change reported for `key` is one the last good bundle already read (#343): a module of it, not a\n // story input, that is now as it was, state and content, when the bundle read it. A request catches up with a\n // change before the watcher reports it; the late event then needs no bundle, compile or reload. Comparing the\n // content as well tells a real save from it on a file system whose coarse timestamps leave the state unchanged;\n // a file touched or saved unchanged after the bundle read it has another state, and is bundled again as before.\n // So is a change in a folder a plugin of the bundle watches, while what is in the folder is still what the plugin\n // found there (#393).\n const alreadyRead = (key: string): boolean => {\n const read = entryReads.get(key);\n const path = entryFiles.get(key);\n if (entryStale || keyWithin(key, inputKeys())) return false;\n if (read === undefined && !entryFiles.has(key) && keyWithin(key, [...entryFolders.keys()]))\n return !foldersChanged();\n if (read === undefined || path === undefined) return false;\n const now = fileRead(path);\n return now?.state === read.state && now.hash === read.hash;\n };\n\n // `initial`: the compile at server start. No page is open yet, and Vite would\n // hold a full-reload for the first page that connects and reload it once.\n const rebuild = async (changed: ReadonlySet<string>, initial = false): Promise<void> => {\n if (closed) return;\n try {\n const unread = [...changed].filter((key) => !alreadyRead(key));\n const regrouped = linkMoved() || globsChanged() || foldersChanged();\n if (changed.size > 0 && unread.length === 0 && !regrouped) return;\n outputs = dev.outputs(config);\n output = outputPaths(outputs);\n // Taken before the compile reads anything, so a file written during it\n // still counts as changed afterwards.\n compiledInputs = storyInputFiles(true);\n // The compile cache trusts modification times, which a quick save may leave\n // unchanged (coarse file-system timestamps); forget the files that changed.\n for (const key of [...cache.keys()]) if (changed.has(fileKey(key))) cache.delete(key);\n if (entryStale || regrouped || unread.some(touchesEntry)) await bundle();\n const story = await compileStory(options.compile(entrySources(entry)), outputs, cache);\n for (const warning of story.warnings) config.logger.warn(`[twee-ts] ${warning}`);\n // Only a playable page can run the client; other outputs are served as compiled.\n html = outputMode === 'html' ? dev.injectClient(story.output, base) : story.output;\n servedAssets = entry?.assets;\n lastError = undefined;\n // A path tells the client to reload only the pages showing the story. Vite's client compares it with the\n // decoded page path and the base as configured, so under a base that has percent-encoded characters\n // (spaces, non-ASCII) the comparison never matches; then every page reloads instead.\n if (!initial) server.ws.send(reloadPayload(base, options.outputFilename));\n } catch (e) {\n lastError = toOverlayError(e);\n config.logger.error(`[twee-ts] ${lastError.message}`);\n server.ws.send({ type: 'error', err: lastError });\n }\n };\n\n // rebuild() reports its own errors; this catches a failure while reporting,\n // so one bad report doesn't stop every later rebuild.\n const keepQueueAlive = (e: unknown): void => {\n try {\n config.logger.error(`[twee-ts] ${fatalError(e).message}`);\n } catch {\n // Nothing left to report with.\n }\n };\n\n // A change to a file the story or the entry is made from: compiled with the others that land with it.\n const noteChange = (changed: string): void => {\n if (closed) return;\n pending.add(changed);\n clearTimeout(timer);\n timer = setTimeout(() => {\n const files = pending;\n pending = new Set();\n queue = queue.then(() => rebuild(files)).catch(keepQueueAlive);\n }, DEBOUNCE_MS);\n };\n\n await rebuild(new Set(), true);\n\n server.watcher.on('all', (event, path) => {\n // Loading the config for the entry build writes and deletes one of these;\n // reacting to it would bundle again, and again.\n if (isViteConfigTemp(path)) return;\n const changed = fileKey(path);\n // A file or folder added to or removed from a glob's scope may change what the glob selects; anything\n // in a folder a plugin of the entry build watches, or that folder itself (also one that did not exist yet),\n // may change what the plugin reads.\n const isDir = event === 'addDir' || event === 'unlinkDir';\n const regrouped =\n (event !== 'change' && inGlobScope(path, isDir)) ||\n inWatchedFolder(path) ||\n (isDir && entryPath !== undefined && entryFiles.has(changed));\n if (event !== 'add' && event !== 'change' && event !== 'unlink' && !regrouped) return;\n if (!regrouped && (!keyWithin(changed, inputKeys()) || excluded(path)) && !touchesEntry(changed) && !linkMoved()) {\n return;\n }\n noteChange(changed);\n });\n\n // The watcher can miss changes, or be off (`server.watch: null`). When a folder\n // is deleted and created again in quick succession (as `git rebase` does),\n // chokidar stops watching the folder, so a file added to it later raises no\n // event; under Deno it also loses the files created with it, so their later\n // edits raise none either. Before the story is served, this waits for any\n // compile under way, compares the story's input files and the entry's files\n // with what the last compile and bundle read, and compiles again first if\n // they differ. It also takes the events the watcher already reported and that\n // still wait out the debounce, so that a response never comes before the\n // rebuild one of them asks for (#436); an event for a change the bundle\n // already has asks for none (see rebuild).\n const catchUp = (): Promise<void> => {\n catchingUp ??= (async () => {\n // The debounce can fire while a rebuild runs and chain the rebuild an earlier event asked for after it: wait for\n // the queue as it is when the last one settles, not as it was when the request came (#442).\n for (let waited = queue; ; waited = queue) {\n await waited;\n if (queue === waited) break;\n }\n const changed = filesChanged(compiledInputs, storyInputFiles(false));\n for (const file of filesChanged(entryStates, fileStates(entryFiles))) changed.add(file);\n if (changed.size === 0 && pending.size === 0 && !linkMoved() && !globsChanged() && !foldersChanged()) return;\n // Changes the watcher did report, still waiting out the debounce, go into the same compile.\n for (const file of pending) changed.add(file);\n pending = new Set();\n clearTimeout(timer);\n queue = queue.then(() => rebuild(changed)).catch(keepQueueAlive);\n await queue;\n })().finally(() => {\n catchingUp = undefined;\n });\n return catchingUp;\n };\n\n server.ws.on('connection', () => {\n if (lastError) server.ws.send({ type: 'error', err: lastError });\n });\n\n // Vite's base middleware strips the base from a request's URL before the\n // plugin's own middleware sees it, and only when the URL is below the base;\n // the URL as the request came in tells which.\n const requestUrls = new WeakMap<IncomingMessage, string>();\n server.middlewares.use((req, _res, next) => {\n requestUrls.set(req, String(req.url));\n next();\n });\n\n const send = (req: IncomingMessage, res: ServerResponse, type: string, body: string | Uint8Array): void => {\n // `server.headers`, as Vite sends them with the pages it serves itself.\n for (const [name, value] of Object.entries({ ...config.server.headers })) {\n if (typeof value === 'string' || typeof value === 'number') res.setHeader(name, value);\n else if (Array.isArray(value)) res.setHeader(name, value.map(String));\n }\n res.statusCode = 200;\n res.setHeader('Content-Type', type);\n res.setHeader('Content-Length', typeof body === 'string' ? Buffer.byteLength(body) : body.byteLength);\n // A page from the dev server is always checked again, as Vite serves its own.\n res.setHeader('Cache-Control', 'no-cache');\n res.end(req.method === 'HEAD' ? undefined : body);\n };\n\n return (req, res, next) => {\n if (req.method !== 'GET' && req.method !== 'HEAD') {\n next();\n return;\n }\n // Undefined for a request the middleware above never saw, which is then left alone.\n const path = pathBelowBase(String(requestUrls.get(req)), base);\n if (path === undefined) {\n next();\n return;\n }\n const others = [...instances].filter((other) => other !== self);\n // A path another instance claims for its story, or (for a story) emits as an asset, is not served by plugin\n // order: the production build rejects both.\n const mine = paths.includes(path);\n if (\n (mine || servedAssets?.has(path) === true) &&\n others.some((other) => other.paths.includes(path) || (mine && other.assets()?.has(path) === true))\n ) {\n fail(res, storyCollisionMessage(path));\n return;\n }\n if (paths.includes(path)) {\n catchUp().then(() => {\n if (html) send(req, res, OUTPUT_MEDIA_TYPES[outputMode], html);\n else send(req, res, 'text/html; charset=utf-8', waitingPage(base));\n }, next);\n return;\n }\n // Files the entry's bundle still emits separately, where the build writes them.\n const asset = servedAssets?.get(path);\n if (asset === undefined) {\n next();\n return;\n }\n // Another instance emitting the same name with other bytes: the production build rejects that, and the dev\n // server must not pick one by plugin order.\n for (const other of others) {\n const theirs = other.assets()?.get(path);\n if (theirs !== undefined && !sameBytes(theirs, asset)) {\n fail(res, entryCollisionMessage(path));\n return;\n }\n }\n send(req, res, assetMediaType(path), asset);\n };\n}\n","/**\n * Ready-made Vite plugin for twee-ts.\n *\n * Compiles Twee sources into the story HTML. With `entry`, Vite also bundles a\n * script, and the CSS it imports, into the story as its Story JavaScript and\n * Story Stylesheet.\n *\n * In dev the compiled HTML is served at the base URL with Vite's client added.\n * Every change to a source, the head file, a module or a file the entry was\n * bundled from recompiles it and reloads the page, and errors appear in Vite's\n * overlay (see vite-dev.ts). A build emits the story with the configured file\n * name, in the client environment only.\n */\nimport { relative, resolve } from 'node:path';\nimport { version as viteVersion } from 'vite';\nimport type { BuildEnvironmentOptions, Plugin, ResolvedConfig, UserConfig } from 'vite';\nimport type { FileCacheEntry } from '../types.js';\nimport { compileStory, fatalError } from './diagnostics.js';\nimport type { CompiledStory } from './diagnostics.js';\nimport { getFilenames, outputPaths } from '../filesystem.js';\nimport type { BuildOutputs, OutputPaths } from '../filesystem.js';\nimport { insertViteClient } from '../html-structure.js';\nimport { isSameOrInside } from '../path-identity.js';\nimport { checkViteVersion, resolvePluginOptions } from './options.js';\nimport type { SharedPluginOptions } from './options.js';\nimport { canonicalPath, createOutputRecord, fileKey, outputLocations, toPosix } from './paths.js';\nimport type { OutputLocation } from './paths.js';\nimport { installStoryRoute, setUpDevStory } from './vite-dev.js';\nimport {\n bundleEntry,\n ENTRY_INPUT_NAME,\n entryInputSettings,\n entryRenderBuiltUrl,\n entryCollisionMessage,\n entrySources,\n fileOfId,\n forgetKeptResolver,\n importSpellings,\n PLUGIN_NAME,\n pluginWith,\n removeFromBundle,\n takeEntryFromBundle,\n withWorkerPlugin,\n} from './vite-entry.js';\nimport type { BundleItem, EntryBundle, ImportHookContext } from './vite-entry.js';\nimport { moduleGlobScopes, readScope, scopeAdmits, scopeId, scopeWatchTargets } from './vite-glob.js';\nimport type { GlobScope } from './vite-glob.js';\nimport { importWatchTargets, watchTargets } from './watch-targets.js';\nimport { isRecord } from '../util.js';\n\nexport type { PluginCompileOptions } from './options.js';\n\nexport interface TweeTsVitePluginOptions extends SharedPluginOptions {\n /**\n * A JS or TS file, relative to the working directory. Vite bundles it and\n * everything it imports into one self-contained script that becomes the\n * story's Story JavaScript; CSS it imports becomes the Story Stylesheet.\n */\n entry?: string | undefined;\n}\n\n/**\n * A build input that stands in when the user's config names none, so Vite does\n * not look for an index.html (whose page would replace the story). Its empty\n * chunk is dropped from the output.\n */\nconst EMPTY_INPUT = 'virtual:twee-ts-empty-input';\nconst RESOLVED_EMPTY_INPUT = '\\0' + EMPTY_INPUT;\n\n/** The environment the story belongs to: the browser's. */\nconst CLIENT = 'client';\n\n/** Vite's plugin that bundles workers, and keeps their bundles between the builds of `vite build --watch`. */\nconst VITE_WORKER_PLUGIN = 'vite:worker';\n\n/** The plugin instances created so far, which numbers each instance's entry input. */\nlet instances = 0;\n\n/** The bundler options of build settings: `rolldownOptions`, or the older name Vite 8 still reads. */\nfunction bundlerOptionsOf(build: unknown): Readonly<Record<string, unknown>> | undefined {\n if (!isRecord(build)) return undefined;\n const options = build['rolldownOptions'] ?? build['rollupOptions'];\n return isRecord(options) ? options : undefined;\n}\n\n/**\n * Whether a config (or an environment's options) names what the build builds:\n * a bundler input, Vite 8's top-level `input`, a library entry or an SSR entry.\n */\nfunction namesInput(config: object): boolean {\n const build: unknown = Reflect.get(config, 'build');\n return (\n Reflect.get(config, 'input') !== undefined ||\n bundlerOptionsOf(build)?.['input'] !== undefined ||\n (isRecord(build) && (Boolean(build['lib']) || Boolean(build['ssr'])))\n );\n}\n\n/** Build settings naming one input. */\nfunction inputOnly(input: string): BuildEnvironmentOptions {\n return { rolldownOptions: { input } };\n}\n\n/**\n * Where a build with this config writes: each output's folder, the bundler's\n * `output.dir` or else `build.outDir`, or the bundler's `output.file`. Vite\n * resolves an `output.dir` against the root when it empties the folder and\n * copies the public files into it, while the bundler resolves it against the\n * working directory when it writes; both count.\n */\nfunction configOutputLocations(config: ResolvedConfig): OutputLocation[] {\n const outDir = resolve(config.root, config.build.outDir);\n const option = bundlerOptionsOf(config.build)?.['output'];\n const outputs: unknown[] = option === undefined ? [{}] : Array.isArray(option) ? option : [option];\n return outputs.flatMap((output) => {\n const [location] = outputLocations(output);\n if (location === undefined) return [{ dir: outDir }];\n if (location.dir === undefined) return [location];\n return [{ dir: resolve(location.dir) }, { dir: resolve(config.root, location.dir) }];\n });\n}\n\n/**\n * Every path a build with this config writes, as far as the config tells: each\n * output's folder (see configOutputLocations), the story in it, and the copies\n * of the public files Vite puts there. The plugin adds the files each bundle\n * writes as it builds (see createOutputRecord).\n */\nfunction configOutputs(config: ResolvedConfig, outputFilename: string): BuildOutputs {\n const record = createOutputRecord(outputFilename);\n const publicFiles =\n config.build.copyPublicDir && config.publicDir\n ? getFilenames([config.publicDir]).filenames.map((file) => relative(config.publicDir, resolve(file)))\n : [];\n for (const location of configOutputLocations(config)) {\n record.addLocation(location);\n record.addFiles(location, publicFiles);\n }\n return record.outputs();\n}\n\n/** Both builds' outputs together. */\nfunction mergeOutputs(a: BuildOutputs, b: BuildOutputs): BuildOutputs {\n return {\n files: [...a.files, ...b.files],\n stories: [...(a.stories ?? []), ...(b.stories ?? [])],\n dirs: [...a.dirs, ...b.dirs],\n };\n}\n\n/** Adds Vite's client to the page, first in its head, so reloads and the error overlay reach it. */\nfunction injectViteClient(html: string, base: string): string {\n return insertViteClient(html, `${base}@vite/client`);\n}\n\n/**\n * What `vite build --watch` is told to watch for the entry's globs: each glob's folder (or the nearest one above it\n * that exists), by real path, as the bundler's watcher reports it. A folder that holds a build output is left out,\n * since the watcher would report what the build writes there and rebuild for ever: a file added to it is bundled\n * with the next build something else starts.\n */\nfunction globWatchTargets(scopes: Iterable<GlobScope>, outputs: OutputPaths): string[] {\n return scopeWatchTargets(scopes)\n .map(canonicalPath)\n .filter((folder) => !outputs.holds(folder));\n}\n\n/** Whether a resolved config is a build of the client, the only build that carries the story. */\nfunction isStoryBuild(config: ResolvedConfig): boolean {\n return config.command === 'build' && !config.build.ssr;\n}\n\n/** An import as written: its importer and its source. */\nfunction importKey(importer: string | undefined, source: string): string {\n return `${importer ?? ''}\\0${source}`;\n}\n\n/** Whether a plugin is Vite's own (its resolver, alias and the rest) or one of twee-ts's. */\nfunction isOwnPlugin(plugin: Plugin): boolean {\n return (\n plugin.name === 'alias' ||\n plugin.name.startsWith('vite:') ||\n plugin.name.startsWith('builtin:') ||\n plugin.name === PLUGIN_NAME ||\n plugin.name.startsWith(`${PLUGIN_NAME}:`)\n );\n}\n\n/**\n * A copy of `plugin` (see pluginWith) with a `resolveId` hook that passes each import it resolves (see importKey) to\n * `claim`. A plugin without a `resolveId` hook in JavaScript is returned as it is.\n */\nfunction claimingPlugin(plugin: Plugin, claim: (key: string) => void): Plugin {\n const hook = plugin.resolveId;\n const handler: unknown = typeof hook === 'function' ? hook : hook?.handler;\n if (typeof handler !== 'function') return plugin;\n const claiming = async function (this: unknown, ...args: unknown[]): Promise<unknown> {\n const result: unknown = await Reflect.apply(handler, this, args);\n const [source, importer] = args;\n if (result !== null && result !== undefined && typeof source === 'string') {\n claim(importKey(typeof importer === 'string' ? importer : undefined, source));\n }\n return result;\n };\n return pluginWith(\n plugin,\n new Map([['resolveId', typeof hook === 'function' ? claiming : { ...hook, handler: claiming }]]),\n );\n}\n\n/** The part of a build hook's context that registering watch targets uses. */\ntype WatchHookContext = ImportHookContext & {\n readonly environment: { readonly config: ResolvedConfig };\n addWatchFile(id: string): void;\n};\n\nexport function tweeTsPlugin(options: TweeTsVitePluginOptions): Plugin {\n checkViteVersion(viteVersion);\n const resolved = resolvePluginOptions('vite', options);\n const { outputFilename, entry: entryPath } = resolved;\n instances += 1;\n // The name of this instance's entry input, when it bundles the entry inside the user's build.\n const entryInput = `${ENTRY_INPUT_NAME}-${instances}`;\n const cache = new Map<string, FileCacheEntry>();\n // The entry bundled by a build of its own, for each build (by environment) that\n // couldn't bundle it inside itself.\n const ownBuilds = new WeakMap<object, EntryBundle>();\n // The files this plugin's builds write, and their output folders, as each bundle\n // reports them. A source folder may hold any of them; none is a source.\n const record = createOutputRecord(outputFilename);\n // Everything the builds and the dev server leave out: what the config says a\n // build writes, and what the builds so far wrote.\n const allOutputs = (config: ResolvedConfig): BuildOutputs =>\n mergeOutputs(configOutputs(config, outputFilename), record.outputs());\n\n /**\n * The build settings this instance adds to a client build: none when the\n * user's config names an input (the entry is then bundled by a build of its\n * own); else, with an entry, the entry as the only input (unless the user's\n * output is an array, which the entry's IIFE can't use); else the stand-in\n * input.\n */\n const inputSettings = (\n config: Readonly<UserConfig>,\n ): { build: BuildEnvironmentOptions; define?: Record<string, string> } | undefined => {\n if (namesInput(config)) return undefined;\n if (entryPath === undefined) return { build: inputOnly(EMPTY_INPUT) };\n const output = config.build?.rolldownOptions?.output;\n if (Array.isArray(output)) return { build: inputOnly(EMPTY_INPUT) };\n return entryInputSettings(entryInput, entryPath, output, outputFilename);\n };\n\n /** Whether this instance's entry is an input of the build with this config. */\n const bundlesEntryInside = (config: ResolvedConfig): boolean => {\n const input = bundlerOptionsOf(config.build)?.['input'];\n return isRecord(input) && Object.hasOwn(input, entryInput);\n };\n\n /** The resolved config of the build a hook runs in: its environment's, so builds sharing the instance keep apart. */\n const configOf = (context: { readonly environment: { readonly config: ResolvedConfig } }): ResolvedConfig =>\n context.environment.config;\n\n // What builds with each config write, as `vite build --watch` leaves them out of its watch targets; taken once per\n // build (see buildStart), and once per nested worker build, whose config is its own.\n let watchOutputs = new WeakMap<ResolvedConfig, OutputPaths>();\n // Each file (by real path) an import has reached in the builds of `vite build --watch`, by the import as written:\n // its importer and its source. Not by the path it reaches the file through, which a retarget may change too (a\n // package's `exports`, a folder's index of another extension).\n const keptTargets = new Map<string, Set<string>>();\n // The imports one of the user's plugins resolved itself (see importKey), in `vite build --watch`: their module is\n // the plugin's choice, which no link changes.\n const claimed = new Set<string>();\n const outputsOf = (config: ResolvedConfig): OutputPaths => {\n const known = watchOutputs.get(config);\n if (known !== undefined) return known;\n const outputs = outputPaths(allOutputs(config));\n watchOutputs.set(config, outputs);\n return outputs;\n };\n\n /**\n * `vite build --watch` with the entry bundled inside the build: the bundler watches each module by its real path,\n * so the links an import of the entry's graph goes through (or the folder where an import that reaches nothing\n * would be created) are registered here, as the import is resolved (see importWatchTargets).\n */\n const registerImport = async (context: WatchHookContext, source: string, importer: string | undefined) => {\n const config = configOf(context);\n const { spellings, kept } = await importSpellings(context, source, importer, config.root);\n for (const target of importWatchTargets(spellings, outputsOf(config))) context.addWatchFile(target);\n return kept;\n };\n\n /** Likewise, each glob's folder: Vite's import-glob reads the files a glob matches, and registers no folder. */\n const registerGlobs = async (\n context: WatchHookContext & Parameters<typeof moduleGlobScopes>[0],\n code: string,\n id: string,\n ) => {\n const config = configOf(context);\n const scopes = await moduleGlobScopes(context, code, id, config.root);\n for (const target of globWatchTargets(scopes, outputsOf(config))) context.addWatchFile(target);\n return scopes;\n };\n\n // The globs of the entry's workers in `vite build --watch`, by scopeId, each with the modules that call it.\n const workerGlobs = new Map<string, { readonly scope: GlobScope; readonly importers: Set<string> }>();\n let warnedWorkerCache = false;\n\n /**\n * `vite build --watch` keeps each worker's bundle until a file it read changes, and a file added to the folder of\n * one of its globs is none of those. When `file` is added to (or removed from) the scope of a worker's glob, the\n * bundles of the workers whose modules call the glob are let go, through Vite's own worker plugin, as an edit of\n * those modules would; the build that follows bundles them again (#424).\n */\n const releaseWorkerGlobs = async (context: WatchHookContext, file: string): Promise<void> => {\n const importers = [...workerGlobs.values()]\n .filter(({ scope }) => {\n // The folders the glob reaches through links as they are now: one linked in since is in its scope too.\n const { linked } = readScope(scope);\n return scopeAdmits(scope, file, false, linked) || scopeAdmits(scope, file, true, linked);\n })\n .flatMap(({ importers: modules }) => [...modules]);\n if (importers.length === 0) return;\n const hook = configOf(context).plugins.find((plugin) => plugin.name === VITE_WORKER_PLUGIN)?.watchChange;\n const handler: unknown = typeof hook === 'function' ? hook : hook?.handler;\n if (typeof handler !== 'function') {\n if (!warnedWorkerCache) {\n warnedWorkerCache = true;\n configOf(context).logger.warn(\n `[twee-ts] This Vite version has no ${VITE_WORKER_PLUGIN} plugin with a watchChange hook, through which ` +\n \"twee-ts has Vite bundle a worker again: a file added to the folder of a worker's import.meta.glob() is \" +\n \"bundled when one of the worker's modules changes.\",\n );\n }\n return;\n }\n for (const module of importers) await Reflect.apply(handler, context, [module, { event: 'update' }]);\n };\n\n /**\n * The same registrations in each build of a worker the entry starts, which Vite bundles nested in the entry's\n * build with the plugins of `worker.plugins` (#424). What a worker build registers is watched by the outer build.\n */\n const workerWatcher = (): Plugin => ({\n name: `${PLUGIN_NAME}:worker-watch`,\n resolveId: {\n order: 'pre',\n async handler(source, importer) {\n await registerImport(this, source, importer);\n return undefined;\n },\n },\n transform: {\n filter: { code: 'import.meta.glob' },\n async handler(code, id) {\n for (const scope of await registerGlobs(this, code, id)) {\n const key = scopeId(scope);\n const known = workerGlobs.get(key) ?? { scope, importers: new Set<string>() };\n known.importers.add(fileOfId(id));\n workerGlobs.set(key, known);\n }\n },\n },\n });\n\n return {\n name: PLUGIN_NAME,\n\n // The story belongs to the client build. A server or worker\n // environment a framework adds builds no copy of it.\n applyToEnvironment: (environment) => environment.name === CLIENT,\n\n // A build that bundles the entry inside itself finds the files it writes besides the story\n // from the output folder (see entryRenderBuiltUrl). Its input is the client environment's, which\n // configEnvironment below sets unless the config names one.\n config: {\n order: 'post',\n handler(config, env) {\n const client = config.environments?.[CLIENT] ?? {};\n if (env.command !== 'build' || entryPath === undefined || namesInput(config) || namesInput(client)) return;\n const renderBuiltUrl = entryRenderBuiltUrl(config.base, outputFilename, config.experimental?.renderBuiltUrl);\n if (renderBuiltUrl !== undefined) config.experimental = { ...config.experimental, renderBuiltUrl };\n // `vite build --watch`: the entry's workers register what they read too.\n if (config.build?.watch) config.worker = withWorkerPlugin(config.worker, workerWatcher);\n },\n },\n\n // The input of the client environment only.\n configEnvironment(name, environmentConfig, env) {\n if (name !== CLIENT || env.command !== 'build') return undefined;\n return inputSettings(environmentConfig);\n },\n\n configResolved(config) {\n if (entryPath === undefined) return;\n // `vite build --watch` with the entry inside the build: note the imports the user's plugins resolve (see\n // resolveId below). Vite builds each environment's plugins from this list after this hook.\n if (config.command === 'build' && config.build.watch && bundlesEntryInside(config)) {\n config.plugins.forEach((plugin, at) => {\n if (!isOwnPlugin(plugin))\n Reflect.set(\n config.plugins,\n at,\n claimingPlugin(plugin, (key) => claimed.add(key)),\n );\n });\n }\n if (resolved.inputs.some((input) => isSameOrInside(entryPath, input))) {\n config.logger.warn(\n `[twee-ts] The entry ${toPosix(entryPath)} is inside the story sources (${resolved.sources.join(', ')}). ` +\n 'twee-ts also loads the .js and .css files it finds in source folders, unbundled, as Story JavaScript ' +\n \"and Story Stylesheet; keep the entry's folder out of `sources`.\",\n );\n }\n },\n\n // `vite build --watch` rebuilds for the files the build registers. The story's\n // inputs are read in generateBundle, outside the module graph, so they are\n // registered here; the dev server watches them itself (vite-dev.ts). An entry\n // the build can't bundle inside itself is bundled here, by a build of its own,\n // whose files are registered too.\n async buildStart() {\n const config = configOf(this);\n if (!isStoryBuild(config)) return;\n watchOutputs = new WeakMap();\n forgetKeptResolver(config);\n if (this.meta.watchMode) {\n const outputs = outputPaths(allOutputs(config));\n // By real path: the bundler's watcher reports real paths (macOS FSEvents reports nothing else).\n for (const target of watchTargets(resolved.inputs, resolved.excluded, outputs, 'real')) {\n this.addWatchFile(target);\n }\n }\n if (entryPath === undefined || bundlesEntryInside(config)) return;\n // What the entry build read is registered whether it succeeds or fails: a failed bundle is\n // recovered by fixing one of these files, which no other input of the build includes.\n const watched = new Set<string>();\n const authored = new Set<string>([entryPath]);\n const globs: GlobScope[] = [];\n const registerEntryInputs = (): void => {\n if (!this.meta.watchMode) return;\n for (const file of watched) this.addWatchFile(canonicalPath(file));\n const outputs = outputPaths(allOutputs(config));\n for (const target of importWatchTargets(authored, outputs)) this.addWatchFile(target);\n for (const target of globWatchTargets(globs, outputs)) this.addWatchFile(target);\n };\n watched.add(entryPath);\n let bundle: EntryBundle;\n try {\n bundle = await bundleEntry(config, entryPath, 'build', outputFilename, {\n watchFiles: watched,\n onLoad: (file) => watched.add(file),\n onResolve: (spelling) => authored.add(spelling),\n onGlob: (scope) => globs.push(scope),\n });\n } catch (e) {\n registerEntryInputs();\n return this.error(fatalError(e));\n }\n ownBuilds.set(this.environment, bundle);\n for (const file of bundle.files) watched.add(file);\n registerEntryInputs();\n return undefined;\n },\n\n // The compile cache trusts modification times, which a quick save may leave\n // unchanged (coarse file-system timestamps); forget a file that changed.\n async watchChange(id, change) {\n const changed = fileKey(id);\n for (const key of [...cache.keys()]) if (fileKey(key) === changed) cache.delete(key);\n if (change.event !== 'update') await releaseWorkerGlobs(this, id);\n },\n\n // `vite build --watch` with the entry bundled inside the build: Vite's import-glob reads the files a glob\n // matches when it bundles, and registers none of the folders it read, so a file added to one starts no\n // build. Each glob's folder is registered here, as the module comes past on its way to the import-glob.\n transform: {\n filter: { code: 'import.meta.glob' },\n async handler(code, id) {\n const config = configOf(this);\n if (!this.meta.watchMode || !isStoryBuild(config) || !bundlesEntryInside(config)) return;\n await registerGlobs(this, code, id);\n },\n },\n\n // Before the other plugins, which would resolve the import first: see registerImport.\n resolveId: {\n order: 'pre',\n async handler(id, importer, options) {\n if (id === EMPTY_INPUT) return RESOLVED_EMPTY_INPUT;\n const config = configOf(this);\n if (!this.meta.watchMode || !isStoryBuild(config) || !bundlesEntryInside(config)) return undefined;\n const kept = await registerImport(this, id, importer);\n // Vite's resolver keeps what an import resolved to for the builds that follow, also after a link on the\n // way is retargeted: the module it gives is then the old target. Each file the import reached is known;\n // when Vite's answer is one of those that it no longer reaches, the module is the one it reaches now, as a\n // new build would find (#320).\n if (kept === undefined) return undefined;\n const now = canonicalPath(kept);\n const written = importKey(importer, id);\n const targets = keptTargets.get(written) ?? new Set<string>();\n keptTargets.set(written, targets.add(now));\n if (targets.size < 2) return undefined;\n claimed.delete(written);\n const resolved = await this.resolve(id, importer, { ...options, skipSelf: true });\n // A plugin of the user's that resolved the import decided the module itself: it is left as it chose.\n if (claimed.has(written)) return undefined;\n if (resolved === null || resolved.external === true || resolved.external === 'absolute') return undefined;\n const file = canonicalPath(fileOfId(resolved.id));\n if (file === now || !targets.has(file)) return undefined;\n return { ...resolved, id: `${now}${/[?#].*$/s.exec(resolved.id)?.[0] ?? ''}` };\n },\n },\n\n load(id) {\n // A statement app builds keep (they drop unused exports), so the bundler\n // doesn't warn about an empty chunk. The chunk is removed from the output.\n return id === RESOLVED_EMPTY_INPUT ? 'globalThis.tweeTsEmptyInput = true;' : undefined;\n },\n\n generateBundle: {\n order: 'post',\n async handler(outputOptions, bundle) {\n const config = configOf(this);\n if (!isStoryBuild(config)) return;\n for (const [fileName, item] of Object.entries(bundle)) {\n if (item.type === 'chunk' && item.facadeModuleId === RESOLVED_EMPTY_INPUT) removeFromBundle(bundle, fileName);\n }\n if (Object.hasOwn(bundle, outputFilename)) {\n return this.error(\n `twee-ts: the build already writes a file named ${outputFilename} (another input or plugin emits it); ` +\n \"set the plugin's outputFilename to another name.\",\n );\n }\n let entry: EntryBundle | undefined;\n if (entryPath !== undefined) {\n const items: Record<string, BundleItem> = bundle;\n entry = bundlesEntryInside(config) ? takeEntryFromBundle(items, entryInput) : ownBuilds.get(this.environment);\n if (!bundlesEntryInside(config)) {\n for (const [fileName, source] of entry?.assets ?? []) {\n if (Object.hasOwn(bundle, fileName)) {\n return this.error(entryCollisionMessage(fileName));\n }\n this.emitFile({ type: 'asset', fileName, source });\n }\n }\n }\n // Where this output writes the story and the bundle, should the bundler's own\n // settings differ from what the config said. Nothing a build writes is a source.\n record.addLocation(outputOptions);\n record.addFiles(outputOptions, [...Object.keys(bundle), ...(entry?.assets.keys() ?? [])]);\n let story: CompiledStory;\n try {\n story = await compileStory(resolved.compile(entrySources(entry)), allOutputs(config), cache, true);\n } catch (e) {\n return this.error(fatalError(e));\n }\n for (const warning of story.warnings) this.warn(warning);\n this.emitFile({ type: 'asset', fileName: outputFilename, source: story.output });\n return undefined;\n },\n },\n\n async configureServer(server) {\n const route = await setUpDevStory(server, {\n options: resolved,\n cache,\n outputs: allOutputs,\n injectClient: injectViteClient,\n });\n // Installed once Vite's internal middlewares are, between its request checks and its file serving.\n return () => {\n installStoryRoute(server.middlewares, route);\n };\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAM,iBAAoC;CAAE,aAAa;CAAU,YAAY;CAAU,eAAe;AAAK;;AAG7G,SAAS,YAAY,MAAuB;CAC1C,OAAO,KAAK,SAAS,kBAAkB;AACzC;AAEA,SAAS,OAAO,OAAkC;CAChD,OAAO,SAAS,KAAK,KAAK,OAAO,MAAM,YAAY;AACrD;;AAGA,UAAU,QAAQ,MAAmC;CACnD,MAAM,QAAmB,CAAC,IAAI;CAC9B,KAAK,IAAI,QAAQ,MAAM,IAAI,GAAG,UAAU,KAAA,GAAW,QAAQ,MAAM,IAAI,GAAG;EACtE,IAAI,OAAO,KAAK,GAAG,MAAM;EACzB,MAAM,WAA+B,MAAM,QAAQ,KAAK,IAAI,QAAQ,OAAO,KAAK,IAAI,OAAO,OAAO,KAAK,IAAI,CAAC;EAC5G,QAAQ,OAAO,SAAS,WAAW,CAAC;CACtC;AACF;;AAGA,SAAS,aAAa,MAAqC;CACzD,OACE,KAAK,SAAS,sBACd,CAAC,KAAK,YACN,KAAK,SAAS,SAAS,gBACvB,KAAK,SAAS,SAAS,UACvB,KAAK,OAAO,SAAS,kBACrB,KAAK,OAAO,KAAK,SAAS,YAC1B,KAAK,OAAO,SAAS,SAAS;AAElC;;AAGA,SAAS,SAAS,MAA6D;CAC7E,IAAI,SAAS,MAAM,OAAO,KAAA;CAC1B,IAAI,KAAK,SAAS,WAAW,OAAO,OAAO,KAAK,UAAU,WAAW,KAAK,QAAQ,KAAA;CAClF,IAAI,KAAK,SAAS,qBAAqB,KAAK,YAAY,WAAW,GAAG,OAAO,KAAK,OAAO,EAAE,EAAE,MAAM;AAErG;;AAGA,SAAS,SAAS,SAAuC,MAAuB;CAC9E,KAAK,MAAM,YAAY,SAAS,cAAc,CAAC,GAAG;EAChD,IAAI,SAAS,SAAS,cAAc,SAAS,YAAY,S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,UAAU,KAAK,KAAK,OAAO;IACvD,KAAK,SAAS;KAAE,MAAM;KAAS,UAAU;KAAgB,QAAQ,MAAM;IAAO,CAAC;GAEjF;EACF;EAEA,MAAM,gBAAgB,QAAQ;GAC5B,MAAM,QAAQ,MAAM,cAAc,QAAQ;IACxC,SAAS;IACT;IACA,SAAS;IACT,cAAc;GAChB,CAAC;GAED,aAAa;IACX,kBAAkB,OAAO,aAAa,KAAK;GAC7C;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"vite.js","names":["tokTypes","viteVersion"],"sources":["../../src/plugins/vite-glob.ts","../../src/plugins/vite-entry.ts","../../src/plugins/vite-dev.ts","../../src/plugins/vite-public.ts","../../src/plugins/vite.ts"],"sourcesContent":["/**\n * The folders an entry's `import.meta.glob()` calls read. Vite replaces each call with the files that match it\n * when it bundles, so the bundle names those files and nothing else: a file added later that matches is in no\n * bundle's module list. To bundle again when the files a glob selects change, the plugin reads each call itself,\n * just before Vite's own import-glob transform does, and notes the folder below which it can match (its scope).\n *\n * A scope is a superset of what the glob matches: a file added to it or removed from it may not match (a negated\n * pattern, a name the wildcards leave out), which only bundles again for nothing. The calls are read with acorn as Vite reads them: patterns are\n * string literals, template literals without expressions, or arrays of those. Options are static literal data,\n * including computed keys and repeated members; expressions outside that subset are diagnosed, never evaluated.\n *\n * Code that is a module is read whole, so only real calls count. Code that is not (yet) one, as a plugin may hand\n * on a component file or TypeScript it transforms later, is read the way Vite's import-glob reads every module:\n * each `import.meta.glob(` in the text, with TypeScript type arguments allowed, is read on its own as a call.\n * Text in a comment or a string that reads as a call then adds a scope too, which only costs a bundle for nothing.\n */\nimport { readdirSync, statSync } from 'node:fs';\nimport { basename, dirname, isAbsolute, join, posix, resolve } from 'node:path';\nimport type { AnyNode, Expression, Options, SpreadElement } from 'acorn';\nimport { tokTypes } from 'acorn';\nimport { AcornParser, javaScriptNodes, trySyntax } from '../js-syntax.js';\nimport { lineColumnFinder } from '../js-chars.js';\nimport { isRecord } from '../util.js';\nimport { canonicalPath, fileKey, isViteConfigTemp, keyWithin, toPosix } from './paths.js';\nimport { missingImportFolders } from './watch-targets.js';\n\n/**\n * Where a glob can match:\n * - `dir`: the folder below which it can (forward slashes);\n * - `deep`: whether it also matches in the folders below `dir`, or only among `dir`'s own files;\n * - `dot`: whether it may match a name that starts with a dot, which Vite's import-glob gives no wildcard unless\n * the call is `exhaustive` or the pattern spells the dot;\n * - `exhaustive`: the call's option, which also lets a match pass through `node_modules`;\n * - `suffix`: the literal end of the pattern's last segment (`.js` of `*.js`), lower-cased, which every file it\n * matches ends with (in any case, as a case-insensitive glob matches).\n */\nexport interface GlobScope {\n readonly dir: string;\n readonly deep: boolean;\n readonly dot: boolean;\n readonly exhaustive: boolean;\n readonly suffix: string;\n}\n\n/** One `import.meta.glob()` call: its patterns as written, and the options that decide where they match. */\nexport interface GlobCall {\n readonly patterns: readonly string[];\n readonly base: string | undefined;\n readonly exhaustive: boolean;\n}\n\n/** A module, as the bundler hands it to a plugin's transform hook (the entry build's code is a module). */\nconst MODULE_OPTIONS: Readonly<Options> = { ecmaVersion: 'latest', sourceType: 'module', allowHashBang: true };\n\n/** Whether `code` may hold a glob call, as Vite's import-glob filters the modules it reads. */\nfunction mayHoldGlob(code: string): boolean {\n return code.includes('import.meta.glob');\n}\n\n/** Whether `node` is the callee `import.meta.glob`. */\nfunction isGlobCallee(node: Expression | AnyNode): boolean {\n return (\n node.type === 'MemberExpression' &&\n !node.computed &&\n node.property.type === 'Identifier' &&\n node.property.name === 'glob' &&\n node.object.type === 'MetaProperty' &&\n node.object.meta.name === 'import' &&\n node.object.property.name === 'meta'\n );\n}\n\n/** The string a pattern argument spells: a string literal, or a template literal without expressions. */\nfunction stringOf(node: Expression | SpreadElement | null): string | undefined {\n if (node === null) return undefined;\n if (node.type === 'Literal') return typeof node.value === 'string' ? node.value : undefined;\n if (node.type === 'TemplateLiteral' && node.expressions.length === 0) return node.quasis[0]?.value.raw;\n return undefined;\n}\n\n/** An expression outside the static data subset: never run it or guess the folder it selects. */\nconst UNREADABLE = Symbol('unreadable');\n\n/** Static option data, with JavaScript's cooked strings, computed keys and last-member precedence. */\nfunction staticValue(node: Expression, depth = 0): unknown {\n if (depth > 100) return UNREADABLE;\n switch (node.type) {\n case 'Literal':\n return node.regex === undefined && node.bigint === undefined ? node.value : UNREADABLE;\n case 'TemplateLiteral':\n return node.expressions.length === 0 ? (node.quasis[0]?.value.cooked ?? UNREADABLE) : UNREADABLE;\n case 'UnaryExpression': {\n const value = staticValue(node.argument, depth + 1);\n if (value === UNREADABLE) return UNREADABLE;\n if (node.operator === '!') return !value;\n if (typeof value === 'number') {\n if (node.operator === '-') return -value;\n if (node.operator === '+') return value;\n }\n return UNREADABLE;\n }\n case 'ArrayExpression': {\n const values: unknown[] = [];\n for (const element of node.elements) {\n if (element === null || element.type === 'SpreadElement') return UNREADABLE;\n const value = staticValue(element, depth + 1);\n if (value === UNREADABLE) return UNREADABLE;\n values.push(value);\n }\n return values;\n }\n case 'ObjectExpression': {\n const entries = new Map<string, unknown>();\n for (const property of node.properties) {\n if (property.type === 'SpreadElement') return UNREADABLE;\n if (property.kind !== 'init' || property.method || property.shorthand) return UNREADABLE;\n // Vite's native build reader does not resolve computed template keys as its JS reader does.\n if (property.computed && property.key.type !== 'Literal') return UNREADABLE;\n const key =\n !property.computed && property.key.type === 'Identifier'\n ? property.key.name\n : staticValue(property.key, depth + 1);\n const value = staticValue(property.value, depth + 1);\n if (depth === 0 && key === 'exhaustive' && property.value.type !== 'Literal') return UNREADABLE;\n // A non-computed __proto__ changes inheritance in JavaScript; do not treat it as ordinary data.\n if (\n (key !== null && typeof key !== 'string' && typeof key !== 'number' && typeof key !== 'boolean') ||\n value === UNREADABLE ||\n (!property.computed && key === '__proto__')\n )\n return UNREADABLE;\n entries.set(String(key), value);\n }\n return Object.fromEntries(entries);\n }\n default:\n return UNREADABLE;\n }\n}\n\n/** The call a glob call's arguments make. */\nfunction callOf(args: readonly (Expression | SpreadElement)[]): GlobCall | undefined {\n const [first, second] = args;\n const patterns = (first === undefined ? [] : first.type === 'ArrayExpression' ? first.elements : [first])\n .map(stringOf)\n .filter((pattern) => pattern !== undefined);\n const options = second === undefined ? {} : second.type === 'SpreadElement' ? UNREADABLE : staticValue(second);\n if (options === UNREADABLE) return undefined;\n const base = isRecord(options) ? options['base'] : undefined;\n return {\n patterns,\n base: typeof base === 'string' ? base : undefined,\n exhaustive: isRecord(options) && options['exhaustive'] === true,\n };\n}\n\n/** Where Vite's import-glob finds a call in a module's text: the callee, any TypeScript type arguments, `(`. */\nconst GLOB_CALL_START = /\\bimport\\.meta\\.glob(?:<\\w+>)?\\s*\\(/g;\n\n/** Shared character allowance for tokenization and expression parsing across every recovery candidate. */\ninterface RecoveryBudget {\n remaining: number;\n}\n\n/**\n * The end (offset just past it) of the argument list that opens at `paren`, as acorn's tokenizer reads the text from\n * there: past strings, template literals, regular expressions and comments that hold parentheses. Undefined when the\n * list does not close, or the text cannot be tokenized.\n */\nfunction argumentsEnd(code: string, paren: number, budget: RecoveryBudget): number | undefined {\n // An empty tokenizer starts in the same expression context as `(`. Set its input/offset without Acorn's\n // startPos constructor path, which searches the source prefix for a line start even with locations disabled.\n const tokenizer = Object.assign(AcornParser.tokenizer('', MODULE_OPTIONS), { input: code, pos: paren });\n const read = trySyntax(() => {\n let depth = 0;\n for (;;) {\n const from = tokenizer.pos;\n let token;\n try {\n token = tokenizer.getToken();\n } finally {\n // A failed token may search the entire suffix without advancing pos (an unclosed comment or\n // Unicode escape). Invalid template tokens can recover from that same escape search. Charge the\n // whole suffix in either case; cursor movement covers ordinary tokens, whitespace and comments.\n const searched = token === undefined || token.type === tokTypes.invalidTemplate ? code.length : tokenizer.pos;\n budget.remaining -= Math.max(1, searched - from);\n }\n if (budget.remaining < 0 || token.type === tokTypes.eof) return undefined;\n if (token.type === tokTypes.parenL) depth += 1;\n else if (token.type === tokTypes.parenR) depth -= 1;\n if (depth === 0) return token.end;\n }\n });\n return read.ok ? read.value : undefined;\n}\n\n/** `text` read as one expression, which must take all of it; undefined when acorn reads it otherwise. */\nfunction wholeExpression(text: string, options: Readonly<Options>): AnyNode | undefined {\n const read = trySyntax(() => AcornParser.parseExpressionAt(text, 0, options));\n return read.ok && read.value.end === text.length ? read.value : undefined;\n}\n\n/**\n * The call whose callee starts at `start` and whose argument list opens at `paren`, read on its own, up to the end\n * of its argument list: as a call expression, or, with type arguments between the two (which JavaScript reads as\n * comparisons), as its argument list in parentheses. Undefined when acorn reads neither.\n */\nfunction callAt(code: string, start: number, paren: number, budget: RecoveryBudget): GlobCall | undefined {\n const end = argumentsEnd(code, paren, budget);\n if (end === undefined) return undefined;\n // Both expression reads and their slices are covered, including nested apparent calls with closing parens.\n budget.remaining -= end - start + end - paren;\n if (budget.remaining < 0) return undefined;\n const call = wholeExpression(code.slice(start, end), MODULE_OPTIONS);\n if (call?.type === 'CallExpression' && isGlobCallee(call.callee)) return callOf(call.arguments);\n const list = wholeExpression(code.slice(paren, end), { ...MODULE_OPTIONS, preserveParens: true });\n if (list?.type !== 'ParenthesizedExpression') return undefined;\n const { expression } = list;\n return callOf(expression.type === 'SequenceExpression' ? expression.expressions : [expression]);\n}\n\n/** The glob calls of a module's code, and where each call is that could not be read (by offset). */\nexport interface GlobReading {\n readonly calls: readonly GlobCall[];\n readonly unreadable: readonly number[];\n /** Recovery stopped before reading all candidates because their aggregate work exceeded the allowance. */\n readonly recoveryLimited?: true;\n}\n\n/** The glob calls of a module's code: read whole when it is a module, else each call on its own. */\nexport function globCalls(code: string): GlobReading {\n const parsed = trySyntax(() => AcornParser.parse(code, MODULE_OPTIONS));\n if (parsed.ok) {\n const calls: GlobCall[] = [];\n const unreadable: number[] = [];\n for (const node of javaScriptNodes(parsed.value)) {\n if (node.type !== 'CallExpression' || !isGlobCallee(node.callee)) continue;\n const call = callOf(node.arguments);\n if (call === undefined) unreadable.push(node.start);\n else calls.push(call);\n }\n return { calls, unreadable };\n }\n const calls: GlobCall[] = [];\n const unreadable: number[] = [];\n // Ordinary disjoint calls take a few passes over their own text. Overlapping or malformed candidates may\n // spend at most sixteen source lengths, plus the final token, regardless of how many apparent calls occur.\n const budget: RecoveryBudget = { remaining: code.length * 16 };\n for (const match of code.matchAll(GLOB_CALL_START)) {\n const call = callAt(code, match.index, match.index + match[0].length - 1, budget);\n if (call === undefined) unreadable.push(match.index);\n else calls.push(call);\n if (budget.remaining < 0) return { calls, unreadable, recoveryLimited: true };\n }\n return { calls, unreadable };\n}\n\n/** Characters that make a segment of a pattern match more than its own name (picomatch's, and its escape). */\nconst MAGIC = /[*?[\\]{}()!+@\\\\]/;\n\n/** The characters after the last MAGIC one, found without retrying each literal prefix as a regex start. */\nfunction literalEnd(segment: string): string {\n let start = segment.length;\n while (start > 0 && !MAGIC.test(segment.charAt(start - 1))) start -= 1;\n return segment.slice(start).toLowerCase();\n}\n\n/** Whether a pattern's segments may match a name starting with a dot, which a wildcard alone never does. */\nfunction namesDot(segments: readonly string[]): boolean {\n return segments.some((segment) => segment !== '..' && /(?:^|[{,])\\./.test(segment));\n}\n\n/**\n * The scope of the pattern `rest` below an absolute folder `dir` (as the file system spells it, so nothing in it\n * is taken for a wildcard): the folder its leading plain segments name (`..` included), whether the segments after\n * those reach below it, and the literal end of its last segment.\n */\nfunction scopeOf(dir: string, rest: string, exhaustive: boolean): GlobScope {\n const segments = posix.normalize(rest).split('/');\n const magic = segments.findIndex((segment) => MAGIC.test(segment));\n const plain = magic === -1 ? segments.slice(0, -1) : segments.slice(0, magic);\n const below = segments.slice(plain.length);\n return {\n dir: toPosix(plain.reduce((folder, segment) => resolve(folder, segment), dir)),\n deep: below.length > 1 || below.some((segment) => segment.includes('**')),\n dot: exhaustive || namesDot(below),\n exhaustive,\n suffix: literalEnd(below.at(-1) ?? ''),\n };\n}\n\n/** How a plugin hook resolves an import, as Vite's import-glob resolves a pattern that is not a path. */\nexport type GlobResolver = (pattern: string) => Promise<string | undefined>;\n\n/**\n * The scopes of the patterns of `call`, made in the module `importer` (a file path, or undefined for a virtual\n * module) under `root`, as Vite's import-glob places them: `/` from the root, `./` and `../` from the importer's\n * folder or the `base` option, `**` from the root, and anything else (an alias, a `#` import) as the resolver\n * resolves it. A negated pattern only takes files away, and has none.\n */\nexport async function scopesOf(\n call: GlobCall,\n importer: string | undefined,\n root: string,\n resolver: GlobResolver,\n): Promise<GlobScope[]> {\n const folder = importer === undefined ? root : dirname(importer);\n const from =\n call.base === undefined ? folder : call.base.startsWith('/') ? join(root, call.base) : resolve(folder, call.base);\n const scopes: GlobScope[] = [];\n for (const pattern of call.patterns) {\n if (pattern.startsWith('!')) continue;\n if (pattern.startsWith('/')) scopes.push(scopeOf(root, pattern.slice(1), call.exhaustive));\n else if (pattern.startsWith('./') || pattern.startsWith('../'))\n scopes.push(scopeOf(from, pattern, call.exhaustive));\n else if (pattern.startsWith('**')) scopes.push(scopeOf(root, pattern, call.exhaustive));\n else {\n const resolved = await resolver(pattern);\n if (resolved === undefined || !isAbsolute(resolved)) continue;\n // The resolver turns the pattern's leading part into a path and keeps the rest; the part the two share at\n // the end is the pattern's own (as Vite's globSafeResolvedPath reads it).\n const spelled = toPosix(resolved);\n let shared = 0;\n while (shared < Math.min(spelled.length, pattern.length) && spelled.at(-1 - shared) === pattern.at(-1 - shared)) {\n shared += 1;\n }\n const cut = spelled.lastIndexOf('/', spelled.length - shared);\n scopes.push(scopeOf(spelled.slice(0, Math.max(cut, 0)) || '/', spelled.slice(cut + 1), call.exhaustive));\n }\n }\n return scopes;\n}\n\n/** A key that is the same for two equal scopes. */\nexport function scopeId(scope: GlobScope): string {\n return JSON.stringify([scope.dir, scope.deep, scope.dot, scope.exhaustive, scope.suffix]);\n}\n\n/**\n * Whether an entry named `name` of a folder in the scope may be matched, or, for a folder, lead to a match. The\n * temporary copies Vite makes of a config file never are: they come and go with every entry build.\n */\nfunction admits(scope: GlobScope, name: string, isDir: boolean): boolean {\n if ((name.startsWith('.') && !scope.dot) || isViteConfigTemp(name)) return false;\n if (isDir) return scope.deep && (scope.exhaustive || name !== 'node_modules');\n return name.toLowerCase().endsWith(scope.suffix);\n}\n\n/** What was in a scope when it was read (see readScope). */\nexport interface ScopeContents {\n /**\n * A string that changes when a file the glob may match is added to the scope, removed from it or renamed in it,\n * or a linked folder in it is retargeted, and stays the same otherwise.\n */\n readonly listing: string;\n /** The folders a deep scope reaches through links, by real path (forward slashes). */\n readonly linked: readonly string[];\n}\n\n/** The real path (forward slashes) of the folder the link at `path` leads to; undefined for a link to anything else. */\nfunction linkedFolder(path: string): string | undefined {\n try {\n return statSync(path).isDirectory() ? canonicalPath(path) : undefined;\n } catch {\n return undefined; // A dangling link.\n }\n}\n\n/**\n * What is in a scope: the files of its folder that `admits` lets through, and for a deep scope the folders below\n * it and theirs. A link to a folder is followed, as Vite's import-glob follows it, and listed with its target, so\n * retargeting it shows; a folder already listed (a link back to a folder above, or a second link to one) is not\n * listed again, as Vite's crawler does not crawl it again. A link to a file is listed as a file. A scope whose folder\n * does not exist (yet) lists as missing.\n */\nexport function readScope(scope: GlobScope): ScopeContents {\n const entries: string[] = [];\n const linked = new Set<string>();\n const visited = new Set<string>();\n const list = (dir: string, prefix: string): boolean => {\n let found;\n try {\n found = readdirSync(dir, { withFileTypes: true });\n } catch {\n return false;\n }\n visited.add(fileKey(dir));\n for (const entry of found.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))) {\n const path = `${prefix}${entry.name}`;\n const target = entry.isSymbolicLink() ? linkedFolder(join(dir, entry.name)) : undefined;\n const isDir = entry.isDirectory() || target !== undefined;\n if (!admits(scope, entry.name, isDir)) continue;\n entries.push(target === undefined ? `${isDir ? 'd' : 'f'}:${path}` : `l:${path}>${target}`);\n if (target !== undefined) {\n if (visited.has(fileKey(target))) continue;\n linked.add(target);\n }\n if (isDir) list(join(dir, entry.name), `${path}/`);\n }\n return true;\n };\n const listing = list(scope.dir, '') ? entries.join('\\n') : '\\0missing';\n return { listing, linked: [...linked] };\n}\n\n/** What is in a scope, as readScope lists it. */\nexport function scopeListing(scope: GlobScope): string {\n return readScope(scope).listing;\n}\n\n/**\n * Whether adding or removing the file (or folder, `isDir`) at `path` may change what the glob of `scope` matches:\n * it is in the scope, or in one of the folders it reaches through links (`linked`, see readScope), and `admits`\n * lets it through, or it is one of those folders itself. Folders are compared by identity key, so one is\n * recognised however the path spells it, through a link or not.\n */\nexport function scopeAdmits(scope: GlobScope, path: string, isDir: boolean, linked: readonly string[]): boolean {\n const folders = [scope.dir, ...(scope.deep ? linked : [])].map(fileKey);\n if (folders.includes(fileKey(path))) return true;\n const parent = fileKey(dirname(path));\n return (scope.deep ? keyWithin(parent, folders) : parent === folders[0]) && admits(scope, basename(path), isDir);\n}\n\n/**\n * The folders a watcher watches for `scopes`: each scope's folder, or, for one that does not exist, the nearest\n * folder above it that does, where creating it shows; and the folders a deep scope reaches through links, which a\n * watcher of the scope's folder may not follow.\n */\nexport function scopeWatchTargets(scopes: Iterable<GlobScope>): string[] {\n return [\n ...new Set(\n [...scopes].flatMap((scope) => [\n toPosix(missingImportFolders([scope.dir])[0] ?? scope.dir),\n ...readScope(scope).linked,\n ]),\n ),\n ];\n}\n\n/**\n * The part of a plugin's transform hook context the glob reading uses: resolving an import, and warning.\n */\ninterface GlobHookContext {\n resolve(\n source: string,\n importer?: string,\n options?: { custom?: Record<string, unknown> },\n ): Promise<{ readonly id: string } | null>;\n warn(message: string): void;\n}\n\n/**\n * The file `pattern` (an alias or a `#` import, not a path) resolves to from `importer`, asked as Vite's\n * import-glob asks; undefined when it resolves to none, or the resolver fails (Vite's import-glob then reports\n * the pattern itself).\n */\nasync function resolveGlob(context: GlobHookContext, pattern: string, importer: string): Promise<string | undefined> {\n const isSubImportsPattern = pattern.startsWith('#') && pattern.includes('*');\n try {\n const resolved = await context.resolve(pattern, importer, {\n custom: { 'vite:import-glob': { isSubImportsPattern } },\n });\n // This is a glob pattern, not a module URL: ? is a wildcard and # is a literal path character.\n // Vite passes the resolved pattern intact to globSafeResolvedPath too.\n return resolved?.id;\n } catch {\n return undefined;\n }\n}\n\n/**\n * The scopes of the glob calls in a module's code, read in a plugin's transform hook, whose `context` resolves an\n * alias or `#` pattern as Vite's import-glob would; a call acorn cannot read is reported with a warning and has\n * none.\n */\nexport async function moduleGlobScopes(\n context: GlobHookContext,\n code: string,\n id: string,\n root: string,\n): Promise<GlobScope[]> {\n if (!mayHoldGlob(code)) return [];\n const { calls, unreadable, recoveryLimited } = globCalls(code);\n if (unreadable.length > 0) {\n const locate = lineColumnFinder(code);\n const where = unreadable\n .map((offset) => {\n const { line, column } = locate(offset);\n return `${String(line)}:${String(column)}`;\n })\n .join(', ');\n context.warn(\n `twee-ts could not read the import.meta.glob() call at ${where} of ${id}; ` +\n (recoveryLimited === true ? 'recovery work limit reached; remaining calls were not read; ' : '') +\n 'files added to its folders are bundled the next time something else changes.',\n );\n }\n const file = id.replace(/[?#].*$/s, '');\n const importer = isAbsolute(file) && !id.startsWith('\\0') ? file : undefined;\n const resolver: GlobResolver = (pattern) => resolveGlob(context, pattern, id);\n const scopes = await Promise.all(calls.map((call) => scopesOf(call, importer, root, resolver)));\n return scopes.flat();\n}\n","/**\n * Bundling the Vite plugin's `entry` into one script and one stylesheet for the\n * story. In a build, the plugin bundles the entry inside the user's build when\n * it can (see entryInputSettings), and otherwise, and always in dev, with a\n * build of its own: bundleEntry() below, which replays the user's configuration.\n */\nimport { existsSync, statSync } from 'node:fs';\nimport { findPackageJSON } from 'node:module';\nimport { dirname, isAbsolute, join, resolve, win32 } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { build, createIdResolver, loadConfigFromFile, mergeConfig } from 'vite';\nimport type {\n BuildEnvironmentOptions,\n ConfigEnv,\n InlineConfig,\n LogLevel,\n Logger,\n Plugin,\n RenderBuiltAssetUrl,\n ResolvedConfig,\n UserConfig,\n} from 'vite';\nimport type { InlineSource } from '../types.js';\nimport { toPosix } from './paths.js';\nimport { moduleGlobScopes } from './vite-glob.js';\nimport type { GlobScope } from './vite-glob.js';\nimport { isRecord } from '../util.js';\nimport { cssContexts, javaScriptContexts } from '../code-context.js';\n\n/** The plugin's name, which is also how the entry build tells it from the user's other plugins. */\nexport const PLUGIN_NAME = 'twee-ts';\n\n/** Passage names the bundled entry takes inside the story. */\nconst ENTRY_SCRIPT_NAME = 'twee-ts-entry.js';\nconst ENTRY_STYLE_NAME = 'twee-ts-entry.css';\n\n/** How the name of the entry's input starts when the plugin bundles it inside the user's build. */\nexport const ENTRY_INPUT_NAME = 'twee-ts-entry';\n\n/** Which Vite command a configuration is evaluated for. */\nexport type ViteCommand = ConfigEnv['command'];\n\n/**\n * The bundled entry: its script, its stylesheet, the files it was built from\n * (forward-slash paths: its modules and the files its plugins watch), and any\n * files the bundler still emits separately (by output file name).\n */\nexport interface EntryBundle {\n readonly script: string;\n readonly style: string;\n readonly files: ReadonlySet<string>;\n readonly assets: ReadonlyMap<string, string | Uint8Array>;\n}\n\n/** The error for a file the entry emits under a name the build (or another story's entry) already writes. */\nexport function entryCollisionMessage(fileName: string): string {\n return `twee-ts: the entry emits ${fileName}, a file the build already writes; rename one of them.`;\n}\n\n/** The entry's script and stylesheet as inline sources of the story (none without an entry). */\nexport function entrySources(entry: EntryBundle | undefined): InlineSource[] {\n if (entry === undefined) return [];\n return [\n // The leading `;` ends an unterminated statement of the script passage before it, which would otherwise take\n // the entry's opening parenthesis as a call.\n { filename: ENTRY_SCRIPT_NAME, content: `;${entry.script}` },\n ...(entry.style === '' ? [] : [{ filename: ENTRY_STYLE_NAME, content: entry.style }]),\n ];\n}\n\n/** The parts of a Vite output bundle item this plugin reads. */\nexport type BundleItem =\n | {\n readonly type: 'chunk';\n readonly code: string;\n readonly isEntry: boolean;\n readonly name: string;\n readonly moduleIds: readonly string[];\n }\n | {\n readonly type: 'asset';\n readonly source: string | Uint8Array;\n /** The source files the bundler made the asset from (the bundler's own stylesheet names no file). */\n readonly originalFileNames?: readonly string[] | undefined;\n };\n\n/** The bundler options of a build (Rolldown's, under Vite 8). */\ntype BundlerOptions = NonNullable<BuildEnvironmentOptions['rolldownOptions']>;\n\n/** The bundler's `output` option: one output's options or several. */\ntype OutputOption = BundlerOptions['output'];\n\n/** One output's options. */\ntype OutputOptions = Exclude<NonNullable<OutputOption>, readonly unknown[]>;\n\n/**\n * The output options of the entry's bundle: one IIFE script, and assets under\n * their own names, so a build writes them where the dev server serves them.\n */\nconst ENTRY_OUTPUT = {\n format: 'iife',\n entryFileNames: ENTRY_SCRIPT_NAME,\n assetFileNames: '[name][extname]',\n} as const satisfies OutputOptions;\n\n/**\n * The output options of the entry's bundle given the user's `output` option:\n * the user's own when it is one object, with the entry's format and file names\n * on top. An array of outputs describes the user's own files; none of them\n * applies to the entry.\n */\nexport function entryOutput(userOutput: OutputOption): OutputOptions {\n return userOutput === undefined || Array.isArray(userOutput)\n ? { ...ENTRY_OUTPUT }\n : { ...userOutput, ...ENTRY_OUTPUT };\n}\n\n/**\n * Settings that make every font and image the entry uses inline as a data URL,\n * and its CSS one stylesheet, so the story stays one file; only an import marked\n * `?no-inline` is still emitted separately.\n */\nconst ONE_FILE = { cssCodeSplit: false, assetsInlineLimit: (): boolean => true } as const;\n\n/**\n * What `import.meta.url` stands for in the entry's script, given the story's output file name. The script runs\n * as a classic script inside the story page, where `import.meta` does not exist (the bundler leaves `{}.url`, so\n * `new URL(asset, import.meta.url)` and Vite's worker URLs throw `Invalid URL`). The files the build writes\n * besides the story, such as an asset marked `?no-inline`, are found from the output folder the story is below,\n * so the base is the story page's URL, taken up one level for each folder of a nested `outputFilename`.\n */\nfunction entryDefine(outputFilename: string): { readonly 'import.meta.url': string } {\n const depth = folderDepth(outputFilename);\n const base =\n depth === 0 ? 'document.baseURI' : `new URL(${JSON.stringify('../'.repeat(depth))}, document.baseURI).href`;\n return { 'import.meta.url': base };\n}\n\n/** How many folders deep `outputFilename` puts the story below the output folder. */\nfunction folderDepth(outputFilename: string): number {\n return outputFilename.split('/').length - 1;\n}\n\n/**\n * The `experimental.renderBuiltUrl` of a build that bundles the entry, given the build's `base`, the story's\n * `outputFilename` and the configuration's own `renderBuiltUrl` (`user`, which decides first), or `user` itself\n * when nothing changes. With a relative `base` (`''` or `'./'`), Vite makes the URL of a file the build writes\n * besides the story (an asset marked `?no-inline`, a worker) relative to the script or stylesheet that names it.\n * The story page holds both inline, so such a URL resolves against the page, which a nested `outputFilename` puts\n * below the output folder the files are written to. For the entry's script, the URL is then resolved at run time\n * against the output folder, as `import.meta.url` is (see `entryDefine`); in its stylesheet, it is a path up from\n * the page. Every stylesheet of such a build is the entry's: the build bundles nothing else.\n */\nexport function entryRenderBuiltUrl(\n base: string | undefined,\n outputFilename: string,\n user: RenderBuiltAssetUrl | undefined,\n): RenderBuiltAssetUrl | undefined {\n const depth = folderDepth(outputFilename);\n if ((base !== '' && base !== './') || depth === 0) return user;\n const outputFolder = entryDefine(outputFilename)['import.meta.url'];\n return (filename, type) => {\n const own = user?.(filename, type);\n if (own !== undefined) return own;\n // As Vite writes a file name into a URL.\n const path = filename.replaceAll('%', '%25');\n if (type.hostType === 'js' && type.hostId === ENTRY_SCRIPT_NAME) {\n return { runtime: `new URL(${JSON.stringify(path)}, ${outputFolder}).href` };\n }\n return type.hostType === 'css' ? `${'../'.repeat(depth)}${path}` : undefined;\n };\n}\n\n/**\n * Build settings that bundle the entry inside the user's build, as its only\n * input, under `inputName`, which tells the plugin instance it is its own, and\n * what the bundled script needs to run in the story (`define`).\n */\nexport function entryInputSettings(\n inputName: string,\n entryPath: string,\n userOutput: OutputOption,\n outputFilename: string,\n): { readonly build: BuildEnvironmentOptions; readonly define: Record<string, string> } {\n return {\n build: { ...ONE_FILE, rolldownOptions: { input: { [inputName]: entryPath }, output: entryOutput(userOutput) } },\n define: entryDefine(outputFilename),\n };\n}\n\n/** Removes a trailing source-map comment that points at a file (a data: URL map stays). */\nfunction dropFileSourceMapComment(code: string, language: 'js' | 'css'): string {\n const end = code.trimEnd().length;\n const start = Math.max(\n language === 'js' ? code.lastIndexOf('//# sourceMappingURL=', end) : -1,\n code.lastIndexOf('/*# sourceMappingURL=', end),\n );\n if (start === -1) return code;\n const candidate = code.slice(start, end);\n if (!/^(?:\\/\\/# sourceMappingURL=(?!data:)\\S*|\\/\\*# sourceMappingURL=(?!data:)[^*]*\\*\\/)$/u.test(candidate)) {\n return code;\n }\n // The whole candidate must be a comment, starting here: directive text inside a literal or another comment\n // is data. Extending the range one character left distinguishes an opener from text inside an older comment.\n const ranges = [\n { start, end },\n { start: Math.max(0, start - 1), end },\n ];\n const [at, before] = language === 'js' ? javaScriptContexts(code, ranges) : cssContexts(code, ranges);\n const kind = at?.context.kind;\n if (kind !== 'line-comment' && kind !== 'block-comment' && kind !== 'comment') return code;\n if (start > 0 && before?.context.kind === kind) return code;\n return code.slice(0, code[start - 1] === '\\n' ? start - 1 : start);\n}\n\n/** A module id or watched file as a forward-slash file path, without a query or hash (like Vite's cleanUrl). */\nexport function fileOfId(id: string): string {\n return toPosix(id.replace(/[?#].*$/s, ''));\n}\n\n/** Removes a file from a bundle, which bundlers hand plugins as a plain object keyed by file name. */\nexport function removeFromBundle(bundle: Record<string, unknown>, fileName: string): void {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete -- the bundle object is the bundler's API.\n delete bundle[fileName];\n}\n\n/**\n * Whether an asset is a file the entry imported as a URL (`theme.css?url`), not the stylesheet the bundler made\n * of the entry's CSS. The bundler names the files an asset came from; for its own stylesheet that is a bare\n * output name (`style.css`), for an imported file the file's path.\n */\nfunction isImportedFile(item: Extract<BundleItem, { type: 'asset' }>): boolean {\n return (item.originalFileNames ?? []).some((name) => isAbsolute(name) || win32.isAbsolute(name));\n}\n\n/**\n * Takes the entry out of a bundle: its entry chunk (the one named `inputName`,\n * when the entry is one input of the user's build; the only one, from the\n * entry's own build), every stylesheet it made of the entry's CSS (a CSS file imported as a URL stays an asset), and the map files, which the story\n * cannot ship. The chunk is found by its input's name, not by its module's\n * path, which the bundler may spell another way (a root reached through a\n * link is read by its real path). Anything else the bundler emitted for it\n * stays in the bundle, so a build writes it next to the HTML, and is also\n * returned, so the dev server can serve it.\n */\nexport function takeEntryFromBundle(bundle: Record<string, BundleItem>, inputName?: string): EntryBundle {\n let script = '';\n const files = new Set<string>();\n const assets = new Map<string, string | Uint8Array>();\n const styles: string[] = [];\n for (const [fileName, item] of Object.entries(bundle)) {\n if (item.type === 'chunk') {\n if (!item.isEntry || (inputName !== undefined && item.name !== inputName)) continue;\n script = dropFileSourceMapComment(item.code, 'js');\n for (const id of item.moduleIds) if (!id.startsWith('\\0')) files.add(fileOfId(id));\n removeFromBundle(bundle, fileName);\n } else if (fileName.endsWith('.css') && !isImportedFile(item)) {\n const css = typeof item.source === 'string' ? item.source : new TextDecoder().decode(item.source);\n styles.push(dropFileSourceMapComment(css, 'css'));\n removeFromBundle(bundle, fileName);\n } else if (fileName.endsWith('.map') && (item.originalFileNames?.length ?? 0) === 0) {\n // Generated source maps have no originating resource; an imported .map has one, relative or absolute.\n removeFromBundle(bundle, fileName);\n } else {\n assets.set(fileName, item.source);\n }\n }\n return { script, style: styles.join('\\n'), files, assets };\n}\n\n/**\n * The entry build's logger: its warnings go to the outer logger; its progress\n * lines and its own \"build failed\" line are dropped, because the plugin\n * reports a failed bundle itself. (The progress lines Vite 8 prints itself are\n * kept quiet by the entry build's log level; see bundleEntry.)\n */\nfunction entryBuildLogger(outer: Logger): Logger {\n return {\n info: () => {\n // Progress lines are dropped.\n },\n warn: (message, options) => {\n outer.warn(message, options);\n },\n warnOnce: (message, options) => {\n outer.warnOnce(message, options);\n },\n error: () => {\n // The plugin reports a failed bundle itself.\n },\n clearScreen: () => {\n // The outer screen is not the entry build's to clear.\n },\n hasErrorLogged: () => false,\n get hasWarned() {\n return outer.hasWarned;\n },\n };\n}\n\n/**\n * The entry build's log level: no progress lines (Vite 8 prints those itself\n * at `info`), and no more than the outer build or server shows.\n */\nexport function entryBuildLogLevel(outer: LogLevel | undefined): LogLevel {\n return outer === undefined || outer === 'info' ? 'warn' : outer;\n}\n\n/**\n * Top-level keys of the user's configuration the entry build doesn't take, and\n * why. Everything else (define, resolve, css, json, esbuild/oxc, env options,\n * base, assetsInclude, worker, build options, environments, experimental and\n * the rest) comes across as the user gave it, so the entry bundles the same in\n * dev as in a build.\n */\nexport const ENTRY_BUILD_EXCLUDED_KEYS: Readonly<Record<string, string>> = {\n configFile: 'the entry build is given the loaded config file itself',\n plugins: 'replaced by the same plugins without twee-ts, plus the entry build’s own',\n root: 'set to the resolved root',\n mode: 'set to the resolved mode',\n logLevel: 'set so the entry build prints no progress lines',\n customLogger: 'the entry build reports through the outer logger',\n clearScreen: 'the entry build never clears the screen',\n publicDir: 'set to the outer build’s resolved public directory, which the entry build resolves from but never copies',\n server: 'configures the dev server, not a build',\n preview: 'configures the preview server, not a build',\n builder: 'would build every environment instead of the entry',\n devtools: 'starts Vite’s devtools integration, which belongs to the outer server or build',\n};\n\n/** The user's configuration without the keys the entry build doesn't take. */\nfunction withoutExcludedKeys(config: UserConfig): UserConfig {\n const copy: UserConfig = { ...config };\n for (const key of Object.keys(ENTRY_BUILD_EXCLUDED_KEYS)) Reflect.deleteProperty(copy, key);\n return copy;\n}\n\n/** A plugin option (nested arrays, promises, falsy entries) as one flat list. */\nasync function flattenPlugins(option: unknown): Promise<unknown[]> {\n const value: unknown = await option;\n if (Array.isArray(value)) return (await Promise.all(value.map(flattenPlugins))).flat();\n return value ? [value] : [];\n}\n\nfunction isPlugin(value: unknown): value is Plugin {\n return isRecord(value) && typeof value['name'] === 'string';\n}\n\n/** The handler of a plugin hook in function or object form. */\nfunction hookHandler(hook: unknown): unknown {\n return isRecord(hook) ? hook['handler'] : hook;\n}\n\n/** A hook with its handler replaced, keeping the object form's order and other fields. */\nfunction withHandler(hook: unknown, handler: (this: unknown, ...args: unknown[]) => unknown): unknown {\n return isRecord(hook) ? { ...hook, handler } : handler;\n}\n\n/**\n * Whether Vite applies `plugin` for `command`: as Vite reads `apply`, with\n * the configuration and environment the plugin would see.\n */\nfunction appliesTo(plugin: Plugin, command: ViteCommand, config: UserConfig, env: ConfigEnv): boolean {\n const { apply } = plugin;\n if (apply === undefined) return true;\n if (typeof apply === 'function') return apply({ ...config, mode: env.mode }, env);\n return apply === command;\n}\n\n/**\n * `plugin` as the entry build runs it: without `apply` (already decided by\n * appliesTo), and, for the dev command, with its `config`, `configEnvironment`\n * and `configResolved` hooks, environment selection and hook contexts seeing\n * the dev command. Vite's own build plugins still see build. The plugin object itself is left untouched.\n */\nfunction asEntryBuildPlugin(\n plugin: Plugin,\n command: ViteCommand,\n views: { readonly configs: WeakMap<object, object>; readonly environments: WeakMap<object, object> },\n): Plugin {\n const overrides = new Map<PropertyKey, unknown>([['apply', undefined]]);\n if (command === 'serve') {\n const devEnv = (env: unknown): unknown => Object.assign({}, env, { command, isSsrBuild: false });\n const devConfig = (config: unknown): unknown => {\n if (!isRecord(config)) return config;\n let view = views.configs.get(config);\n if (view === undefined) {\n view = withOverrides(config, new Map([['command', command]]));\n views.configs.set(config, view);\n }\n return view;\n };\n const devEnvironment = (environment: unknown): unknown => {\n if (!isRecord(environment)) return environment;\n const known = views.environments.get(environment);\n if (known !== undefined) return known;\n const overrides = new Map<PropertyKey, unknown>([['config', devConfig(environment['config'])]]);\n const topLevel = environment['getTopLevelConfig'];\n if (typeof topLevel === 'function') {\n overrides.set('getTopLevelConfig', () => devConfig(Reflect.apply(topLevel, environment, [])));\n }\n const view = withOverrides(environment, overrides);\n views.environments.set(environment, view);\n return view;\n };\n const devContext = (context: unknown): unknown => {\n if (!isRecord(context) || context['environment'] === undefined) return context;\n const environment = devEnvironment(context['environment']);\n return new Proxy(context, {\n get(target, key) {\n if (key === 'environment') return environment;\n const value: unknown = Reflect.get(target, key, target);\n const bound: unknown = typeof value === 'function' ? value.bind(target) : value;\n return bound;\n },\n });\n };\n const wrap = (name: PropertyKey, patch: (args: unknown[]) => unknown[] = (args) => args) => {\n const hook: unknown = Reflect.get(plugin, name);\n const handler = hookHandler(hook);\n if (typeof handler !== 'function') return;\n overrides.set(\n name,\n withHandler(hook, function (this: unknown, ...args: unknown[]): unknown {\n return Reflect.apply(handler, devContext(this), patch(args));\n }),\n );\n };\n // Include inherited hooks and getters as well as own hooks, retaining hook object metadata. This covers\n // every user hook context without an allowlist that leaves a new Vite/Rolldown hook with build semantics.\n const keys = new Set<PropertyKey>();\n for (\n let object: object | null = plugin;\n object !== null && object !== Object.prototype;\n object = Reflect.getPrototypeOf(object)\n ) {\n for (const key of Reflect.ownKeys(object)) keys.add(key);\n }\n for (const key of keys) if (key !== 'constructor' && key !== 'apply' && key !== 'applyToEnvironment') wrap(key);\n wrap('config', ([config, env]) => [config, devEnv(env)]);\n wrap('configEnvironment', ([name, config, env]) => [name, config, devEnv(env)]);\n wrap('configResolved', ([config]) => [devConfig(config)]);\n const select = plugin.applyToEnvironment;\n if (select !== undefined) {\n overrides.set('applyToEnvironment', async function (this: unknown, environment: unknown): Promise<unknown> {\n const result: unknown = await Reflect.apply(select, this, [devEnvironment(environment)]);\n if (result === true || !result) return result;\n return (await flattenPlugins(result))\n .filter(isPlugin)\n .map((selected) => asEntryBuildPlugin(selected, command, views));\n });\n }\n }\n return pluginWith(plugin, overrides);\n}\n\n/**\n * A copy of `plugin` with some properties of its own reading differently; the plugin itself is left untouched. The\n * copy has the plugin's prototype (a class's methods and getters) and each of its own properties as they are\n * defined (a getter stays a getter), so a frozen plugin, or one whose hooks are getters, is copied as well: a Proxy\n * may not answer differently for a property a frozen object defines. The copy stands in for the plugin wherever\n * the plugin list has it.\n */\nexport function pluginWith(plugin: Plugin, overrides: ReadonlyMap<PropertyKey, unknown>): Plugin {\n const copy: Plugin = { ...plugin };\n // Between the copy and the plugin's prototype, the overridden properties as plain writable ones: Vite clones a\n // plugin by assigning its own properties to an object of the same prototype, which fails for a property that\n // prototype has only a getter for (a class whose hook is a getter).\n const layer = {};\n Object.setPrototypeOf(layer, Reflect.getPrototypeOf(plugin));\n for (const [key, value] of overrides) {\n Object.defineProperty(layer, key, { value, writable: true, enumerable: false, configurable: true });\n }\n Object.setPrototypeOf(copy, layer);\n for (const key of Reflect.ownKeys(plugin)) {\n const descriptor = Object.getOwnPropertyDescriptor(plugin, key);\n if (descriptor !== undefined && !overrides.has(key)) Object.defineProperty(copy, key, descriptor);\n }\n for (const [key, value] of overrides) {\n Object.defineProperty(copy, key, { value, writable: true, enumerable: true, configurable: true });\n }\n return copy;\n}\n\n/** `target` with some properties reading differently; the object itself is left untouched. */\nfunction withOverrides<T extends object>(target: T, overrides: ReadonlyMap<PropertyKey, unknown>): T {\n return new Proxy(target, {\n get(object, key, receiver) {\n const value: unknown = overrides.has(key) ? overrides.get(key) : Reflect.get(object, key, receiver);\n return value;\n },\n });\n}\n\n/**\n * Build settings that make the entry the build's one input and its bundle one\n * script and one stylesheet held in memory, whatever the user's build settings\n * say; for the dev command also unminified, with an inline source map. Settings\n * that would build something else (`lib`, `ssr`) or write files are dropped.\n */\nfunction entryBuildSettings(\n userBuild: BuildEnvironmentOptions | undefined,\n entryPath: string,\n command: ViteCommand,\n): BuildEnvironmentOptions {\n // A user config may still use the old name, which Vite 8 accepts for `rolldownOptions`.\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- read so it can be replaced.\n const { lib: _lib, ssr: _ssr, rollupOptions, rolldownOptions, ...rest } = { ...userBuild };\n const { input: _input, output, ...bundler }: BundlerOptions = rolldownOptions ?? rollupOptions ?? {};\n return {\n ...rest,\n ...ONE_FILE,\n write: false,\n watch: null,\n emptyOutDir: false,\n copyPublicDir: false,\n ...(command === 'serve' ? { minify: false, sourcemap: 'inline' } : {}),\n rolldownOptions: { ...bundler, input: entryPath, output: entryOutput(output) },\n };\n}\n\n/**\n * Applies entryBuildSettings last, after every config hook, in the\n * configuration and in the client environment's own options (which the build\n * reads), so no setting from the user or a plugin makes the entry build build\n * or write anything else.\n */\nfunction entryBuildEnforcer(entryPath: string, command: ViteCommand, outputFilename: string): Plugin {\n return {\n name: `${PLUGIN_NAME}:entry-build`,\n enforce: 'post',\n config: {\n order: 'post',\n handler(config) {\n config.build = entryBuildSettings(config.build, entryPath, command);\n config.define = { ...config.define, ...entryDefine(outputFilename) };\n const renderBuiltUrl = entryRenderBuiltUrl(config.base, outputFilename, config.experimental?.renderBuiltUrl);\n if (renderBuiltUrl !== undefined) config.experimental = { ...config.experimental, renderBuiltUrl };\n },\n },\n configEnvironment: {\n order: 'post',\n handler(name, config) {\n if (name !== 'client') return;\n config.build = entryBuildSettings(config.build, entryPath, command);\n config.define = { ...config.define, ...entryDefine(outputFilename) };\n },\n },\n };\n}\n\n/** Plugin hooks that may read an entry input and register it with `this.addWatchFile` before the story is emitted. */\nconst WATCH_FILE_HOOKS = [\n 'buildStart',\n 'resolveId',\n 'resolveDynamicImport',\n 'load',\n 'transform',\n 'moduleParsed',\n 'buildEnd',\n 'renderStart',\n 'renderChunk',\n 'augmentChunkHash',\n 'generateBundle',\n] as const;\n\n/** A plugin context whose `addWatchFile` also passes the file to `record`. */\nfunction recordingContext(context: object, record: (file: string) => void): object {\n return new Proxy(context, {\n get(target, key) {\n const value: unknown = Reflect.get(target, key, target);\n if (typeof value !== 'function') return value;\n if (key !== 'addWatchFile') {\n const bound: unknown = value.bind(target);\n return bound;\n }\n return (id: unknown): unknown => {\n if (typeof id === 'string' && !id.startsWith('\\0')) record(resolve(id));\n return Reflect.apply(value, target, [id]);\n };\n },\n });\n}\n\n/**\n * `plugin` with hooks that pass the file of each of its `addWatchFile` calls to `record`. The\n * original stays untouched, so a plugin object shared across entry builds\n * never collects wrappers. A plugin without such hooks (a built-in one, for\n * instance) is returned as it is.\n */\nfunction recordingPlugin(\n plugin: Plugin,\n recordFor: (hook: (typeof WATCH_FILE_HOOKS)[number], args: readonly unknown[]) => (file: string) => void,\n): Plugin {\n const overrides = new Map<PropertyKey, unknown>();\n for (const name of WATCH_FILE_HOOKS) {\n const hook = plugin[name];\n const handler = hookHandler(hook);\n if (typeof handler !== 'function') continue;\n overrides.set(\n name,\n withHandler(hook, function (this: unknown, ...args: unknown[]): unknown {\n const record = recordFor(name, args);\n const context = typeof this === 'object' && this !== null ? recordingContext(this, record) : this;\n return Reflect.apply(handler, context, args);\n }),\n );\n }\n return overrides.size === 0 ? plugin : pluginWith(plugin, overrides);\n}\n\nconst isFile = (path: string): boolean => statSync(path, { throwIfNoEntry: false })?.isFile() === true;\n\n/** A resolver Vite makes for plugins (see keptPath). */\ntype IdResolver = ReturnType<typeof createIdResolver>;\n\n/** The part of a plugin hook's context the import spellings use: the environment the hook runs in. */\nexport interface ImportHookContext {\n readonly environment: Parameters<IdResolver>[0];\n}\n\n/** How an import is resolved with its links kept (see keptPath), one resolver per configuration. */\nconst keptResolvers = new WeakMap<ResolvedConfig, IdResolver>();\n\n/**\n * Makes keptPath resolve with a new resolver for `config`: Vite's resolver remembers what it found, which a build of\n * `vite build --watch` must not take from the one before.\n */\nexport function forgetKeptResolver(config: ResolvedConfig): void {\n keptResolvers.delete(config);\n}\n\n/**\n * The file `source`, imported by `importer`, reaches as Vite's resolver finds it, with the links on the way kept\n * (`resolve.preserveSymlinks`): the path through a linked file, folder or package folder, which the module's own\n * (real) path never shows. It follows every spelling Vite's resolver reads: relative and absolute paths, the root's\n * `/`, missing extensions, a folder's index, `resolve.alias`, bare package names, a package's subpaths and exports,\n * `#` subpath imports and `resolve.tsconfigPaths`. Undefined for an import it resolves to no file (a virtual module,\n * an external one, one it cannot resolve), or when resolving fails, which the bundle itself then reports.\n */\nasync function keptPath(\n context: ImportHookContext,\n source: string,\n importer: string | undefined,\n): Promise<string | undefined> {\n const { environment } = context;\n let resolver = keptResolvers.get(environment.config);\n if (resolver === undefined) {\n resolver = createIdResolver(environment.config, { preserveSymlinks: true });\n keptResolvers.set(environment.config, resolver);\n }\n try {\n const id = await resolver(environment, source, importer);\n return id === undefined || id.startsWith('\\0') ? undefined : fileOfId(id);\n } catch {\n return undefined;\n }\n}\n\n/**\n * The paths an import of `source` by `importer` is written as, absolute and with forward slashes, when it is written\n * as a path: relative to the importer, or absolute; also when that reaches nothing yet, so creating it shows. None for\n * a bare name or an alias. An absolute path that starts with `/` is read as Vite reads it: from the root first, unless\n * it already names a path inside the root, and as a path of the file system when that is where it reaches a file.\n */\nfunction writtenPaths(source: string, importer: string | undefined, root: string): string[] {\n const from = importer === undefined ? undefined : fileOfId(importer);\n if (isAbsolute(source)) {\n const file = fileOfId(source);\n const fromRoot =\n /^[/\\\\]/.test(source) && !file.startsWith(`${toPosix(root).replace(/\\/$/, '')}/`) && !existsSync(file)\n ? [fileOfId(join(root, source))]\n : [];\n return [...fromRoot, file];\n }\n return from !== undefined && isAbsolute(from) && /^\\.\\.?(?:[/\\\\]|$)/.test(source)\n ? [fileOfId(resolve(dirname(from), source))]\n : [];\n}\n\n/**\n * Package locations Node's upward node_modules search can use for an unresolved bare import. These are recovery\n * inputs only: Vite still decides aliases, exports and the actual module. Watching the package itself sees a\n * restored manifest, export target or nested subpath without watching every installed package recursively.\n */\nfunction missingPackagePaths(source: string, importer: string | undefined): string[] {\n if (\n importer === undefined ||\n !isAbsolute(fileOfId(importer)) ||\n source === '' ||\n /^[./\\\\#\\0]/.test(source) ||\n source.includes(':')\n )\n return [];\n const parts = source.split('/');\n const name = parts.slice(0, source.startsWith('@') ? 2 : 1).join('/');\n const paths: string[] = [];\n for (let folder = dirname(fileOfId(importer)); ; folder = dirname(folder)) {\n if (toPosix(folder).split('/').at(-1) !== 'node_modules') paths.push(toPosix(join(folder, 'node_modules', name)));\n if (dirname(folder) === folder) break;\n }\n return paths;\n}\n\n/**\n * A package can import itself through its exports without living in node_modules. Node can locate its manifest\n * even when the export target is missing. Track the package's own file listing as a recovery scope, excluding\n * node_modules; recording the whole folder as a watch file would scan all of its installed dependencies too.\n * The node_modules candidates above remain necessary for packages that have no manifest yet.\n */\nfunction missingPackageScope(\n source: string,\n importer: string | undefined,\n candidates: readonly string[],\n): GlobScope | undefined {\n if (importer === undefined || candidates.length === 0) return undefined;\n let manifest: string | undefined;\n try {\n manifest = findPackageJSON(source, pathToFileURL(fileOfId(importer)));\n } catch {\n return undefined; // No package metadata yet, or unreadable metadata: Vite diagnoses the import itself.\n }\n if (manifest === undefined) return undefined;\n const dir = toPosix(dirname(manifest));\n return candidates.includes(dir) ? undefined : { dir, deep: true, dot: true, exhaustive: false, suffix: '' };\n}\n\n/**\n * Every path an import of `source` by `importer` is spelled as (see writtenPaths), and the path Vite's resolver\n * reaches the file by, links kept (`kept`, see keptPath). A caller then sees a link on the way that is retargeted,\n * which the file's own path never shows. Nothing for an import from a virtual module, or of one.\n */\nexport async function importSpellings(\n context: ImportHookContext,\n source: string,\n importer: string | undefined,\n root: string,\n): Promise<{ readonly spellings: readonly string[]; readonly kept: string | undefined }> {\n if (source.startsWith('\\0') || (importer?.startsWith('\\0') ?? false)) return { spellings: [], kept: undefined };\n const written = writtenPaths(source, importer, root);\n // A path written to a file that is there is the one Vite's resolver takes, links and all; only an import written\n // otherwise (a bare name, an alias, a missing extension, a folder) is resolved, which halves the work of a graph\n // of relative imports.\n const resolved = written.find(isFile) ?? (await keptPath(context, source, importer));\n const kept = resolved !== undefined && isAbsolute(resolved) ? resolved : undefined;\n return { spellings: [...new Set([...written, ...(kept === undefined ? [] : [kept])])], kept };\n}\n\n/**\n * What a caller of bundleEntry learns as the entry build runs, filled in also when the build fails (the files of a\n * failed bundle are the ones whose fixing bundles it again):\n * - `watchFiles`: the files the build's plugins add with `addWatchFile`, and the modules of its graph;\n * - `onWatchFile`: each file (or folder) a plugin adds with `addWatchFile`, as it adds it, which is before it\n * reads what it watches;\n * - `onLoad`: each module's file, just before the build reads it;\n * - `onResolve`: each import's path as authored (see recordWatchFiles);\n * - `onGlob`: the scope of each `import.meta.glob()` pattern of a module, just before Vite reads the files it\n * matches (see vite-glob.ts).\n */\nexport interface EntryBuildObserver {\n readonly watchFiles?: Set<string>;\n readonly onWatchFile?: (file: string) => void;\n readonly onLoad?: (file: string) => void;\n readonly onResolve?: (authored: string) => void;\n readonly onGlob?: (scope: GlobScope) => void;\n}\n\n/**\n * Collects the files the entry build's plugins add with `addWatchFile`. These\n * are not modules of the bundle: Vite's CSS plugin adds the stylesheets pulled\n * in by `@import` and the files `url()` points at this way. The build runs on\n * recording stand-ins of its plugins, made in the bundler's `options` hook,\n * which sees the final plugin list, including the plugins Vite resolves per\n * environment (`applyToEnvironment`) after `configResolved`.\n */\nexport function recordWatchFiles(\n files: Set<string> | undefined,\n root: string,\n observer: EntryBuildObserver = {},\n): { readonly plugin: Plugin; readonly inputs: () => ReadonlySet<string> } {\n const { onLoad, onResolve, onGlob, onWatchFile } = observer;\n // Keep watches of cached modules, but release those of a module the current graph no longer uses.\n // A watch registered by a build or rendering hook belongs to that build rather than to a module.\n const watches = new Map<string | undefined, Set<string>>();\n const touched = new Set<string>();\n let modules = new Set<string>();\n let started = false;\n const record = (file: string): void => {\n files?.add(file);\n onWatchFile?.(file);\n };\n const recordFor = (hook: (typeof WATCH_FILE_HOOKS)[number], args: readonly unknown[]): ((file: string) => void) => {\n if (hook === 'buildStart' && !started) {\n started = true;\n touched.clear();\n watches.delete(undefined);\n }\n const owner =\n hook === 'transform' || hook === 'resolveId' || hook === 'resolveDynamicImport'\n ? args[1]\n : hook === 'load'\n ? args[0]\n : hook === 'moduleParsed' && isRecord(args[0])\n ? args[0]['id']\n : undefined;\n const id = typeof owner === 'string' ? owner : undefined;\n if (id !== undefined && (hook === 'load' || hook === 'transform') && !touched.has(id)) {\n touched.add(id);\n watches.delete(id);\n }\n return (file) => {\n record(file);\n const owned = watches.get(id) ?? new Set<string>();\n watches.set(id, owned.add(file));\n };\n };\n const plugin: Plugin = {\n name: `${PLUGIN_NAME}:record-watch-files`,\n buildStart() {\n // Advance even when no other plugin has a buildStart hook.\n recordFor('buildStart', []);\n },\n // Called for each module just before its file is read, so a caller can note the file's state as the\n // bundle is about to see it. It reads nothing itself: the module is loaded as usual.\n load: {\n order: 'pre',\n handler(id) {\n const file = fileOfId(id);\n if (!isAbsolute(file) || id.startsWith('\\0')) return null;\n onLoad?.(file);\n // A plugin may resolve a module to a path through a link (or `resolve.preserveSymlinks` keep it), which\n // is then the module's own spelling.\n onResolve?.(file);\n return null;\n },\n },\n // Where each import is spelled, before the bundler follows a link to its target (see importSpellings): a\n // caller then sees a link that is retargeted, which the target's own path never shows. It resolves nothing\n // for the bundle: the import is resolved as usual.\n resolveId: {\n order: 'pre',\n async handler(source, importer) {\n if (onResolve === undefined) return null;\n const { spellings, kept } = await importSpellings(this, source, importer, root);\n for (const spelled of spellings) onResolve(spelled);\n // Missing packages have no resolved spelling yet. Keep their search locations as recovery inputs,\n // without treating a whole ancestor of node_modules as a missing relative import's watch folder.\n if (kept === undefined && spellings.length === 0) {\n const candidates = missingPackagePaths(source, importer);\n for (const path of candidates) record(path);\n const scope = missingPackageScope(source, importer, candidates);\n if (scope !== undefined) {\n record(join(scope.dir, 'package.json'));\n onGlob?.(scope);\n }\n }\n return null;\n },\n },\n // The scopes of the module's glob calls. This plugin is the last of the user's, so it sees each module as\n // Vite's import-glob, which runs next, does; it transforms nothing itself.\n transform: {\n filter: { code: 'import.meta.glob' },\n async handler(code, id) {\n if (onGlob === undefined) return null;\n for (const scope of await moduleGlobScopes(this, code, id, root)) onGlob(scope);\n return null;\n },\n },\n // Every module of the graph, also one the bundle renders no code of (a module\n // whose constant the bundler inlined), which the chunk's module list leaves out.\n buildEnd() {\n modules = new Set(this.getModuleIds());\n started = false;\n for (const owner of watches.keys()) if (owner !== undefined && !modules.has(owner)) watches.delete(owner);\n for (const id of modules) {\n const file = fileOfId(id);\n if (isAbsolute(file)) files?.add(file);\n }\n },\n options: {\n order: 'post',\n async handler(inputOptions) {\n // Vite passes its resolved plugins, which are all plugin objects; anything else is left out, as\n // the user's plugin list is read (see userEntryConfig()).\n const plugins = (await flattenPlugins(inputOptions.plugins))\n .filter(isPlugin)\n .map((p) => recordingPlugin(p, recordFor));\n return { ...inputOptions, plugins };\n },\n },\n };\n return {\n plugin,\n inputs: () => {\n const current = new Set(\n [...modules]\n .filter((id) => !id.startsWith('\\0'))\n .map(fileOfId)\n .filter(isAbsolute),\n );\n for (const [owner, watched] of watches) {\n if (owner === undefined || modules.has(owner)) for (const file of watched) current.add(file);\n }\n return current;\n },\n };\n}\n\n/** The `worker` options of a configuration. */\ntype WorkerOptions = NonNullable<UserConfig['worker']>;\n\n/**\n * `worker` with `plugin()` after its own `worker.plugins`, which Vite calls for each worker build (nested ones\n * too); the user's plugins come first, in their order, whether given as a function or as the list older Vite\n * versions took.\n */\nexport function withWorkerPlugin(worker: UserConfig['worker'], plugin: () => Plugin): WorkerOptions {\n const own = worker?.plugins;\n // Typed as a function only, but Vite still reads a list (with a warning), which is kept as one item: Vite flattens\n // the list a function returns.\n return { ...worker, plugins: () => [typeof own === 'function' ? own() : own, plugin()] };\n}\n\n/**\n * The user's own configuration as Vite evaluated it for the outer server or\n * build, but for `command`: the config file (when there is one) evaluated\n * again for that command and mode, with what was passed to `createServer()` or\n * `build()` (or the CLI flags) on top, as Vite merges them.\n */\nasync function userConfigFor(config: ResolvedConfig, env: ConfigEnv): Promise<UserConfig> {\n const inline: InlineConfig = config.inlineConfig;\n if (!config.configFile) return inline;\n const loaded = await loadConfigFromFile(\n env,\n config.configFile,\n config.root,\n entryBuildLogLevel(config.logLevel),\n entryBuildLogger(config.logger),\n inline.configLoader,\n );\n return loaded === null ? inline : mergeConfig(loaded.config, inline);\n}\n\n/**\n * Bundles the entry with a Vite build of its own, from the user's own\n * configuration, evaluated for `command`: the config file's function and each\n * plugin's `apply` see that command, and so do the `config`, `configEnvironment`\n * and `configResolved` hooks of the user's plugins. Every setting comes across\n * but those ENTRY_BUILD_EXCLUDED_KEYS lists and the build settings\n * entryBuildSettings decides. twee-ts itself (every instance) is left out.\n */\nexport async function bundleEntry(\n config: ResolvedConfig,\n entryPath: string,\n command: ViteCommand,\n outputFilename: string,\n observer: EntryBuildObserver = {},\n): Promise<EntryBundle> {\n const watchFiles = observer.watchFiles ?? new Set<string>();\n const env: ConfigEnv = { command, mode: config.mode, isSsrBuild: false, isPreview: false };\n const user = await userConfigFor(config, env);\n const views = { configs: new WeakMap<object, object>(), environments: new WeakMap<object, object>() };\n const entryPlugins = async (option: unknown): Promise<Plugin[]> =>\n (await flattenPlugins(option))\n .filter(isPlugin)\n .filter((plugin) => plugin.name !== PLUGIN_NAME && appliesTo(plugin, command, user, env))\n .map((plugin) => asEntryBuildPlugin(plugin, command, views));\n const plugins = await entryPlugins(user.plugins);\n const workerPlugins = user.worker?.plugins;\n const inline: InlineConfig = {\n ...withoutExcludedKeys(user),\n configFile: false,\n root: config.root,\n mode: config.mode,\n logLevel: entryBuildLogLevel(config.logLevel),\n customLogger: entryBuildLogger(config.logger),\n clearScreen: false,\n // Public files stay resolvable (`/logo.svg`, base rewriting); `copyPublicDir: false` keeps them uncopied.\n publicDir: config.publicDir || false,\n plugins: [\n ...plugins,\n entryBuildEnforcer(entryPath, command, outputFilename),\n recordWatchFiles(watchFiles, config.root, observer).plugin,\n ],\n // A worker the entry starts is bundled by a build nested in this one, with the plugins of `worker.plugins`:\n // its modules, globs and import spellings are the entry's too (#424).\n worker: withWorkerPlugin(\n {\n ...user.worker,\n plugins: () => [entryPlugins(typeof workerPlugins === 'function' ? workerPlugins() : workerPlugins)],\n },\n () => recordWatchFiles(watchFiles, config.root, observer).plugin,\n ),\n };\n // One output, as entryBuildSettings sets it, and no watcher (`watch: null`).\n const [result] = [await build(inline)].flat();\n if (result === undefined || !('output' in result)) throw new Error('twee-ts: the entry build returned no bundle.');\n const bundle: Record<string, BundleItem> = Object.fromEntries(result.output.map((item) => [item.fileName, item]));\n const entry = takeEntryFromBundle(bundle);\n return { ...entry, files: new Set([...entry.files, ...watchFiles]) };\n}\n","/**\n * The Vite plugin in the dev server: compiles the story (and bundles the\n * entry) at start and after every change to a file it was built from, serves\n * it at the base URL with Vite's client added, and reports errors to Vite's\n * overlay.\n */\nimport type { IncomingMessage, ServerResponse } from 'node:http';\nimport { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';\nimport { basename, dirname, join, resolve } from 'node:path';\nimport { stripVTControlCharacters } from 'node:util';\nimport type { Connect, ErrorPayload, ResolvedConfig, ViteDevServer } from 'vite';\nimport type { FileCacheEntry, OutputMode } from '../types.js';\nimport { getFilenames, outputPaths } from '../filesystem.js';\nimport { identify } from '../path-identity.js';\nimport { sha256Hex } from '../format-cache.js';\nimport type { BuildOutputs } from '../filesystem.js';\nimport { mediaTypeFromFilename, normalizedFileExt } from '../media-types.js';\nimport { viteWaitingPage } from '../html-structure.js';\nimport { compileStory, fatalError } from './diagnostics.js';\nimport type { ResolvedPluginOptions } from './options.js';\nimport { canonicalPath, fileKey, isViteConfigTemp, keyWithin, toPosix } from './paths.js';\nimport { bundleEntry, entryCollisionMessage, entrySources, PLUGIN_NAME } from './vite-entry.js';\nimport type { EntryBundle } from './vite-entry.js';\nimport { readScope, scopeAdmits, scopeId, scopeWatchTargets } from './vite-glob.js';\nimport type { GlobScope, ScopeContents } from './vite-glob.js';\nimport { missingImportFolders } from './watch-targets.js';\n\n/** What the dev server needs from the plugin. */\nexport interface DevStoryOptions {\n readonly options: ResolvedPluginOptions;\n readonly cache: Map<string, FileCacheEntry>;\n /** What builds with this config write, which is never a source. */\n readonly outputs: (config: ResolvedConfig) => BuildOutputs;\n /** Adds Vite's client to the story's HTML. */\n readonly injectClient: (html: string, base: string) => string;\n}\n\n/** How long after a change the story is compiled, so saves landing together compile once. */\nconst DEBOUNCE_MS = 50;\n\n/**\n * How long a file the watcher was asked to add may take to be listed as watched, and how long after that its\n * watch may still miss an edit (macOS FSEvents starts reporting a moment after the watch is set up); see\n * `recheckOnceWatched` in setUpDevStory.\n */\nconst WATCH_LISTED_TIMEOUT_MS = 10_000;\nconst WATCH_START_MS = 500;\n\n/** Resolves after `ms`, without keeping the process alive. */\nfunction delay(ms: number): Promise<void> {\n return new Promise((done) => setTimeout(done, ms).unref());\n}\n\n/**\n * The paths under the base URL the story is served at: the output file name,\n * and, as a static host serves it, the folder of an `index.html`.\n */\nexport function storyPaths(outputFilename: string): string[] {\n const index = 'index.html';\n return outputFilename === index || outputFilename.endsWith(`/${index}`)\n ? [outputFilename, outputFilename.slice(0, -index.length)]\n : [outputFilename];\n}\n\n/**\n * `path` (a decoded URL path below the base, with no leading slash) as one spelling: a backslash is a slash, as in\n * an http URL, a `.` segment is dropped and a `..` segment drops the one before it, as the URL standard resolves\n * them (a last `.` or `..` leaves a trailing slash), and empty segments (`a//b`) are dropped, as Vite's file\n * middlewares and static hosts drop them. A `..` never leaves the base.\n */\nfunction oneSpelling(path: string): string {\n const segments = path.replaceAll('\\\\', '/').split('/');\n const kept: string[] = [];\n segments.forEach((segment, at) => {\n const last = at === segments.length - 1;\n if (segment === '..') kept.pop();\n if (segment !== '' && segment !== '.' && segment !== '..') kept.push(segment);\n else if (last) kept.push('');\n });\n return kept.join('/');\n}\n\n/**\n * A request URL's path below `base`, decoded, without query or hash, and with its dot segments, empty segments and\n * backslashes resolved (see oneSpelling), so that every spelling of the story's path is the story (#401); undefined\n * when the path is outside the base or is not a valid percent-encoding.\n */\nexport function pathBelowBase(url: string, base: string): string | undefined {\n const raw = url.replace(/[?#].*$/s, '');\n let path;\n let decodedBase;\n try {\n path = decodeURIComponent(raw);\n decodedBase = decodeURIComponent(base);\n } catch {\n return undefined;\n }\n return path.startsWith(decodedBase) ? oneSpelling(path.slice(decodedBase.length)) : undefined;\n}\n\n/** The reload message for a rebuilt story: limited to the story's pages unless Vite's client could not match them. */\nexport function reloadPayload(base: string, outputFilename: string): { type: 'full-reload'; path?: string } {\n let decoded: string;\n try {\n decoded = decodeURI(base);\n } catch {\n return { type: 'full-reload' };\n }\n return decoded === base ? { type: 'full-reload', path: `/${outputFilename}` } : { type: 'full-reload' };\n}\n\n/** The media type of the story as each output mode writes it. */\nconst OUTPUT_MEDIA_TYPES: Readonly<Record<OutputMode, string>> = {\n html: 'text/html; charset=utf-8',\n 'twine2-archive': 'text/html; charset=utf-8',\n 'twine1-archive': 'text/html; charset=utf-8',\n twee3: 'text/plain; charset=utf-8',\n twee1: 'text/plain; charset=utf-8',\n json: 'application/json; charset=utf-8',\n};\n\n/** Served until the first successful compile, so the overlay has a page to appear on. */\nfunction waitingPage(base: string): string {\n return viteWaitingPage(`${base}@vite/client`);\n}\n\nfunction toOverlayError(e: unknown): ErrorPayload['err'] {\n const error = fatalError(e);\n return {\n // Bundler messages carry terminal colour codes; the overlay would show them raw.\n message: stripVTControlCharacters(error.message),\n stack: '',\n plugin: PLUGIN_NAME,\n ...(error.id ? { id: error.id } : {}),\n ...(error.loc ? { loc: error.loc } : {}),\n };\n}\n\n/**\n * Media types of the files a bundle emits that Tweego's table of story media does not have: a browser\n * refuses a worker or stylesheet served as `application/octet-stream`.\n */\nconst BUNDLE_MEDIA_TYPES: ReadonlyMap<string, string> = new Map([\n ['js', 'text/javascript'],\n ['mjs', 'text/javascript'],\n ['css', 'text/css'],\n ['json', 'application/json'],\n ['map', 'application/json'],\n ['wasm', 'application/wasm'],\n ['html', 'text/html; charset=utf-8'],\n ['txt', 'text/plain; charset=utf-8'],\n]);\n\n/** The media type the dev server gives an asset of the entry's bundle. */\nfunction assetMediaType(path: string): string {\n return BUNDLE_MEDIA_TYPES.get(normalizedFileExt(path)) ?? mediaTypeFromFilename(path);\n}\n\n/**\n * What a change to a file alters: modification time, change time (which an in-place edit that restores the\n * modification time still moves, as the loader's file signature relies on), size and inode (a file replaced by a\n * new one).\n */\nfunction fileState(file: string): string | undefined {\n try {\n const stat = statSync(file);\n return `${stat.mtimeMs}:${stat.ctimeMs}:${stat.size}:${stat.ino}`;\n } catch {\n return undefined; // Missing: it counts as gone.\n }\n}\n\n/**\n * What is in the folder `folder`, at any depth: the name and state (see fileState) of each file and folder in it,\n * links to folders not followed. A file added, removed, renamed or changed anywhere in it changes this, as it\n * makes the bundler's own watcher (`vite build --watch`) build again for a folder a plugin watches. undefined when\n * `folder` is not a folder.\n */\nfunction folderState(folder: string): string | undefined {\n let names: string[];\n try {\n if (statSync(folder, { throwIfNoEntry: false })?.isDirectory() !== true) return undefined;\n names = readdirSync(folder, { recursive: true, encoding: 'utf8' });\n } catch {\n return undefined;\n }\n return names\n .sort()\n .map((name) => `${name}\\0${fileState(join(folder, name)) ?? ''}`)\n .join('\\0');\n}\n\n/**\n * A module's file as the bundle was about to read it: its state (see fileState) and the hash of its content.\n * Taken just before the bundler reads the file, so a write in between makes the file differ from it afterwards.\n */\ninterface FileRead {\n readonly state: string;\n readonly hash: string;\n}\n\n/** `file` as it is now, as a FileRead; undefined when it can't be read. */\nfunction fileRead(file: string): FileRead | undefined {\n const state = fileState(file);\n if (state === undefined) return undefined;\n try {\n return { state, hash: sha256Hex(readFileSync(file)) };\n } catch {\n return undefined;\n }\n}\n\n/**\n * Files by their identity key (see fileKey), each with the path it is read and\n * watched at (its canonical path).\n */\ntype TrackedFiles = ReadonlyMap<string, string>;\n\n/** `paths` as TrackedFiles. */\nfunction tracked(paths: Iterable<string>): TrackedFiles {\n return new Map([...paths].map((path) => [fileKey(path), canonicalPath(path)]));\n}\n\n/** A native identity key and every parent above it, without identifying any path again. */\nfunction* keyParents(key: string): Generator<string> {\n for (let current = key; ;) {\n yield current;\n const parent = dirname(current);\n if (parent === current) return;\n current = parent;\n }\n}\n\n/**\n * The key of the file `authored` reaches, when it reaches it through a link (somewhere along the path, or\n * at the end of it): the one case where the file's own path says nothing of a change of target.\n * undefined for a path with no link in it, and for one that reaches nothing.\n */\nfunction linkKey(authored: string): string | undefined {\n if (!existsSync(authored)) return undefined;\n return canonicalPath(authored) === toPosix(resolve(authored)) ? undefined : fileKey(authored);\n}\n\n/** The state of each of `files`, by key, for telling later which changed (see filesChanged). */\nfunction fileStates(files: TrackedFiles): Map<string, string> {\n const states = new Map<string, string>();\n for (const [key, path] of files) {\n const state = fileState(path);\n if (state !== undefined) states.set(key, state);\n }\n return states;\n}\n\n/**\n * The states to compare later changes with, for the files a bundle was made from: each file as it was just\n * before the bundle read it (`observed`, noted as each module loads), else as it was before the bundle began\n * (`before`, for a file known from the last bundle), else as it is now. An edit while the bundle was made\n * then differs from the recorded state afterwards, and the next request makes the bundle again.\n */\nfunction settledStates(\n files: TrackedFiles,\n observed: ReadonlyMap<string, string>,\n before: ReadonlyMap<string, string>,\n): Map<string, string> {\n const states = new Map<string, string>();\n for (const [key, path] of files) {\n const state = observed.get(key) ?? before.get(key) ?? fileState(path);\n if (state !== undefined) states.set(key, state);\n }\n return states;\n}\n\n/** The keys of the files added, removed or changed between two `fileStates` results. */\nfunction filesChanged(before: ReadonlyMap<string, string>, after: ReadonlyMap<string, string>): Set<string> {\n const changed = new Set<string>();\n for (const [file, state] of after) if (before.get(file) !== state) changed.add(file);\n for (const file of before.keys()) if (!after.has(file)) changed.add(file);\n return changed;\n}\n\n/**\n * A walk of the story's inputs (see storyInputFiles): its files, and what it depended on: the outputs it left out,\n * what each named input was, and the state (see fileState) of each folder it listed, just before it listed it.\n */\ninterface InputWalk {\n readonly outputs: BuildOutputs;\n readonly named: string;\n readonly folders: ReadonlyMap<string, string | undefined>;\n readonly files: readonly { readonly key: string; readonly path: string; readonly link: boolean }[];\n}\n\n/**\n * The names of Vite's middlewares that answer a request with a file: from the public folder, the module\n * transform, the files of the root and the file system, and the HTML fallback.\n */\nconst VITE_FILE_MIDDLEWARES: ReadonlySet<string> = new Set([\n 'viteServePublicMiddleware',\n 'viteTriggerLazyBundlingMiddleware',\n 'viteMemoryFilesMiddleware',\n 'viteTransformMiddleware',\n 'viteServeRawFsMiddleware',\n 'viteServeStaticMiddleware',\n 'viteHtmlFallbackMiddleware',\n 'viteIndexHtmlMiddleware',\n]);\n\n/**\n * Installs the story's route (see setUpDevStory) among `middlewares`, as the plugin's post hook does: after Vite's\n * checks of a request (host, CORS, proxy, base), so they apply to the story as to any page, and before the first\n * of its middlewares that serve files. A build writes the story and the entry's assets over a public file of the\n * same name, and a static host serves nothing else at their paths, so the dev server must not answer them with a\n * file from the public folder or the root (#339). Appended when none of those middlewares is there.\n */\nexport function installStoryRoute(middlewares: Connect.Server, route: Connect.NextHandleFunction): void {\n const at = middlewares.stack.findIndex(\n ({ handle }) => typeof handle === 'function' && VITE_FILE_MIDDLEWARES.has(handle.name),\n );\n if (at === -1) middlewares.use(route);\n else middlewares.stack.splice(at, 0, { route: '', handle: route });\n}\n\ninterface DevInstance {\n /** The URL paths (below the base) of the instance's story page. */\n readonly paths: readonly string[];\n readonly assets: () => ReadonlyMap<string, string | Uint8Array> | undefined;\n readonly catchUp: () => Promise<void>;\n /** Dynamic identities of sources, head and modules, including retargeted links. */\n readonly inputKeys: () => readonly string[];\n readonly entryWatches: TrackedFiles;\n}\n\n/** The instances and entry watches of each server; the watcher is shared by every story (#517). */\nconst devServers = new WeakMap<\n ViteDevServer,\n {\n readonly instances: Set<DevInstance>;\n readonly watched: Map<string, string>;\n readonly released: Map<string, string>;\n }\n>();\n\n/** The error for a story page whose URL another story or an entry asset of the same dev server also claims. */\nfunction storyCollisionMessage(path: string): string {\n return `twee-ts: more than one generated file is served at ${path || '/'} (another story or an entry asset); set a distinct outputFilename.`;\n}\n\nfunction sameBytes(a: string | Uint8Array, b: string | Uint8Array): boolean {\n return Buffer.from(a).equals(Buffer.from(b));\n}\n\n/**\n * Sets up the story in `server`: the first compile, the watcher, and a\n * middleware that notes each request's URL before Vite's own middlewares\n * rewrite it. Resolves, after the first compile, to the middleware that serves\n * the story and the entry's assets, for installStoryRoute.\n */\nexport async function setUpDevStory(server: ViteDevServer, dev: DevStoryOptions): Promise<Connect.NextHandleFunction> {\n const { options, cache } = dev;\n const config = server.config;\n const { base } = config;\n const paths = storyPaths(options.outputFilename);\n const { inputs, excluded: excludedGlob } = options;\n const entryPath = options.entry;\n // Files and folders are compared by identity key (see paths.ts); the inputs are watched as given.\n const root = fileKey(config.root);\n // A source folder may be a symbolic link that is retargeted while the server runs, so its identity is read\n // when it is needed, never kept from startup.\n const inputKeys = (): string[] => inputs.map(fileKey);\n\n // What a build writes, which `vite build` may have left inside a source folder:\n // the story, chunks and assets, and the copies of the public files.\n let outputs = dev.outputs(config);\n let output = outputPaths(outputs);\n const excluded = (file: string): boolean => excludedGlob(file) || output.isOutput(file, inputs);\n server.watcher.add([...inputs]);\n\n const outputMode: OutputMode = options.compile().outputMode ?? 'html';\n let html = '';\n let lastError: ErrorPayload['err'] | undefined;\n let entry: EntryBundle | undefined; // last good bundle\n // The assets of the bundle the page in `html` was compiled with (#360). A later bundle can succeed while the\n // story fails to compile; then the page still served refers to the files of the bundle before it, so those are\n // the files served until a story compiles with the new one.\n let servedAssets: EntryBundle['assets'] | undefined;\n const state = devServers.get(server) ?? {\n instances: new Set<DevInstance>(),\n watched: new Map<string, string>(),\n released: new Map<string, string>(),\n };\n devServers.set(server, state);\n const { instances, watched, released } = state;\n // Desired entry watches for this story; `watched` holds the server's actual registrations.\n const watchedForEntry = new Map<string, string>();\n const self: DevInstance = {\n paths,\n assets: () => servedAssets,\n catchUp: () => catchUp(),\n inputKeys,\n entryWatches: watchedForEntry,\n };\n instances.add(self);\n const fail = (res: ServerResponse, message: string): void => {\n config.logger.error(`[twee-ts] ${message}`);\n res.statusCode = 500;\n res.setHeader('Content-Type', 'text/plain; charset=utf-8');\n res.end(message);\n };\n let entryStale = true; // bundle again on the next rebuild\n // The files the entry was last bundled from, and their states then, kept while a\n // later bundle fails, so that fixing one of them (inside the root or not) bundles it again.\n let entryFiles: TrackedFiles = new Map();\n let entryStates = new Map<string, string>();\n // Where the entry and its imports are spelled when that reaches a file through a link, with the key of\n // the file each reached when the bundle read it: retargeting a link changes the key, not the target.\n let entryLinks = new Map<string, string>();\n // Folders where an import the last failed bundle could not resolve would be created (its nearest existing\n // folder), by key; they are among entryFiles, whose state changes when a file is created in one.\n let entryMissingFolders: string[] = [];\n // The scope of each glob pattern of the entry's modules (see vite-glob.ts), by scopeId, and what was in each\n // when the bundle read it (with the folders it reached through links): a file added, removed or renamed there\n // may change what the glob selects. Kept, as entryFiles are, while a later bundle fails.\n let entryGlobs = new Map<string, GlobScope>();\n let globStates = new Map<string, ScopeContents>();\n // Each folder a plugin of the entry build watches (`this.addWatchFile` on a folder, #393), by key, with its path\n // and what was in it (see folderState) when the plugin added it, which is before it read the folder: a file added,\n // removed, renamed or changed in it bundles the entry again, as `vite build --watch` builds again. Kept, as\n // entryFiles are, while a later bundle fails.\n let entryFolders = new Map<string, { readonly path: string; readonly state: string }>();\n // Each module of the last good bundle as it read it, by key: a watcher event for one that is still byte for byte\n // and state for state what the bundle read reports a change the bundle already has (#343). Kept only with a\n // watcher; the catch-up compares states alone.\n let entryReads = new Map<string, FileRead>();\n const readsModules = config.server.watch !== null;\n let queue: Promise<void> = Promise.resolve();\n let pending = new Set<string>();\n let timer: ReturnType<typeof setTimeout> | undefined;\n let closed = false;\n // The input files as the last compile found them, to tell whether the watcher\n // missed a change (see catchUp).\n let compiledInputs = new Map<string, string>();\n let compiledInputNames: string | undefined;\n let catchingUp: Promise<void> | undefined;\n\n // Stops this server's rebuilds when it closes, on close() and restart() alike;\n // no rebuild may start after that, including one whose timer is still pending\n // in middleware mode. Vite closes each server's own watcher then. closeBundle\n // can't tell: it runs for the whole plugin instance, which a restarted server\n // (the plugin passed inline keeps its instance) or a build may share.\n const closeWatcher = server.watcher.close.bind(server.watcher);\n server.watcher.close = async () => {\n closed = true;\n clearTimeout(timer);\n pending.clear();\n return closeWatcher();\n };\n\n // What each named input is, by identity and kind: a link to one retargeted, or a file replaced by a folder,\n // changes it. A failed probe is a stable state too: the compiler reports its cause during rebuild, and a\n // change from missing to unreadable (with no file in either walk) still needs that rebuild.\n const namedInputs = (): string =>\n inputs\n .map((input) => {\n let kind: string;\n try {\n const stat = statSync(input, { throwIfNoEntry: false });\n kind = stat === undefined ? 'none' : stat.isFile() ? 'file' : stat.isDirectory() ? 'folder' : 'other';\n } catch (error) {\n kind = `failed:${String(error)}`;\n }\n return `${fileKey(input)}\\0${kind}`;\n })\n .join('\\0');\n\n // The story's input files as the last walk of the inputs found them, and what that walk depended on.\n let inputWalk: InputWalk | undefined;\n\n const walkInputs = (): InputWalk => {\n const named = namedInputs();\n const folders = new Map<string, string | undefined>();\n const found = getFilenames(inputs, outputs, [], 'source', (folder) => folders.set(folder, fileState(folder)));\n const files = found.files\n .filter((file) => !excludedGlob(file.path))\n .map((file) => ({ key: file.key, path: identify(file.path).absolute, link: file.link === true }));\n return { outputs, named, folders, files };\n };\n\n // The state of each input file of the story, by key. Unless `walk` asks for a new walk of the inputs, the files\n // of the last one are taken while no folder it listed, no named input and no output changed since (#371): a\n // request with nothing changed then costs one look at each folder and file, and identifies no file (but one\n // reached through a link, whose target may have moved).\n const storyInputFiles = (walk: boolean): Map<string, string> => {\n const last = inputWalk;\n const current =\n last !== undefined &&\n !walk &&\n last.outputs === outputs &&\n last.named === namedInputs() &&\n [...last.folders].every(([folder, state]) => fileState(folder) === state);\n const used = current ? last : walkInputs();\n inputWalk = used;\n const states = new Map<string, string>();\n for (const { key, path, link } of used.files) {\n const state = fileState(path);\n if (state !== undefined) states.set(link ? fileKey(path) : key, state);\n }\n return states;\n };\n\n // Whether a change to `file` may change the entry's bundle: after a good bundle,\n // one of the files it was built from (its modules and the files its plugins\n // watch, such as CSS @imports and url() targets); while there is none, or the\n // last one failed, also anything in the project, so that creating a missing\n // import brings it back.\n const touchesEntry = (key: string): boolean =>\n entryPath !== undefined && (entryFiles.has(key) || (entryStale && keyWithin(key, [root, ...entryMissingFolders])));\n\n // Whether a link the entry is spelled through now reaches another file (or none) than the bundle read.\n const linkMoved = (): boolean => [...entryLinks].some(([spelled, key]) => linkKey(spelled) !== key);\n\n // Whether what is in the scope of one of the entry's globs differs from what the bundle read there.\n const globsChanged = (): boolean =>\n [...entryGlobs].some(([id, scope]) => readScope(scope).listing !== globStates.get(id)?.listing);\n\n // Whether what is in a folder the entry build's plugins watch differs from what was there when they added it.\n const foldersChanged = (): boolean =>\n [...entryFolders.values()].some(({ path, state }) => folderState(path) !== state);\n\n // Whether `path` is a folder the entry build's plugins watch, or is in one (at any depth).\n const inWatchedFolder = (path: string): boolean => {\n if (entryPath === undefined || entryFolders.size === 0) return false;\n const folders = [...entryFolders.keys()];\n // The folder above, by identity: a link in a watched folder is in it, wherever its target lies.\n return keyWithin(fileKey(path), folders) || keyWithin(fileKey(dirname(path)), folders);\n };\n\n // Whether adding or removing the file or folder at `path` may change what one of the entry's globs selects.\n const inGlobScope = (path: string, isDir: boolean): boolean =>\n [...entryGlobs].some(([id, scope]) => scopeAdmits(scope, path, isDir, globStates.get(id)?.linked ?? []));\n\n // What the watcher watches for the entry: its files, and the folders of its globs (or the nearest above each\n // that exists, where creating it shows).\n const entryWatchTargets = (): TrackedFiles =>\n new Map([...entryFiles, ...tracked(scopeWatchTargets(entryGlobs.values()))]);\n\n // Watches entry targets outside the root, releasing them only when no story needs them. Unwatching a folder\n // also ignores its descendants, and unwatching a file under another watched folder suppresses that file's\n // events, so overlapping registrations must survive too. Retained targets are reconsidered on every release.\n const watchEntryFiles = (files: TrackedFiles): void => {\n const added = [...files].filter(\n ([key]) => !keyWithin(key, [root]) && !keyWithin(key, inputKeys()) && !watchedForEntry.has(key),\n );\n for (const key of watchedForEntry.keys()) if (!files.has(key)) watchedForEntry.delete(key);\n for (const [key, path] of added) {\n watchedForEntry.set(key, path);\n watched.set(key, path);\n }\n const owners = new Set([\n root,\n ...[...instances].flatMap((instance) => [...instance.inputKeys(), ...instance.entryWatches.keys()]),\n ]);\n // Index ancestors instead of comparing every registered target with every dependency.\n const aboveOwners = new Set([...owners].flatMap((key) => [...keyParents(key)]));\n const needed = (key: string): boolean =>\n aboveOwners.has(key) || [...keyParents(key)].some((parent) => owners.has(parent));\n const dropped = [...watched].filter(([key]) => !needed(key));\n for (const [key, path] of dropped) {\n watched.delete(key);\n released.set(key, path);\n }\n // Chokidar retains ignores for an unwatched path (and its descendants). Re-adding only a child does not\n // clear a released parent's ignore, nor does adding a parent clear a released child's ignore. Restore all\n // overlapping registrations; this mirrors the watcher's retained ignores until they are cleared or it closes.\n const restored = [...released].filter(([key]) => needed(key));\n for (const [key, path] of restored) {\n released.delete(key);\n watched.set(key, path);\n }\n if (dropped.length > 0) server.watcher.unwatch(dropped.map(([, path]) => path));\n const registrations = new Map([...restored, ...added]);\n if (registrations.size > 0) server.watcher.add([...registrations.values()]);\n if (added.length > 0) recheckOnceWatched(new Map(added)).catch(keepQueueAlive);\n };\n\n const isListed = (path: string): boolean => {\n const watched: Readonly<Record<string, readonly string[] | undefined>> = server.watcher.getWatched();\n return watched[dirname(path)]?.includes(basename(path)) ?? false;\n };\n\n // The watcher sets up a file it is asked to add some time later, and raises no event for an edit made\n // before that (on macOS, FSEvents starts reporting a moment later still). Once it lists the files, and a\n // moment after, their states are compared with the bundle's, and a change counts as one it reported.\n const recheckOnceWatched = async (files: TrackedFiles): Promise<void> => {\n if (config.server.watch === null) return; // No watcher: the catch-up before serving sees every change.\n const deadline = Date.now() + WATCH_LISTED_TIMEOUT_MS;\n while (!closed && Date.now() < deadline && ![...files.values()].every(isListed)) await delay(DEBOUNCE_MS);\n await delay(WATCH_START_MS);\n if (closed) return;\n // In the queue, so the states are those of the last bundle, not of one under way.\n queue = queue\n .then(() => {\n const own = new Map([...files].filter(([key]) => entryFiles.has(key)));\n const now = fileStates(own);\n const then = new Map([...entryStates].filter(([key]) => own.has(key)));\n for (const key of filesChanged(then, now)) if (watchedForEntry.has(key)) noteChange(key);\n // A glob's folder: what is in it, against what the bundle read there.\n const [folder] = [...files.keys()].filter((key) => !own.has(key) && watchedForEntry.has(key));\n if (folder !== undefined && globsChanged()) noteChange(folder);\n // A folder a plugin watches: what is in it, against what was there when the plugin added it.\n const [watched] = [...files.keys()].filter((key) => entryFolders.has(key) && watchedForEntry.has(key));\n if (watched !== undefined && foldersChanged()) noteChange(watched);\n })\n .catch(keepQueueAlive);\n await queue;\n };\n\n const bundle = async (): Promise<void> => {\n if (entryPath === undefined) return;\n entryStale = true;\n const spelled = new Map<string, string>(); // authored path → key, of each link the bundle went through\n const authoredPaths = new Set<string>(); // every import path as authored\n const watchFiles = new Set<string>(); // what the bundle's plugins watch, and its modules\n const noteSpelling = (authored: string): void => {\n authoredPaths.add(authored);\n const key = linkKey(authored);\n if (key !== undefined && !spelled.has(authored)) spelled.set(authored, key);\n };\n noteSpelling(entryPath);\n if (entry === undefined) {\n // No good bundle yet, so the configured entry is the one file known to matter: watch it\n // (it may lie outside the root) and note its state, so that fixing it bundles again.\n entryFiles = tracked([entryPath]);\n entryStates = fileStates(entryFiles);\n watchEntryFiles(entryWatchTargets());\n }\n // The scopes of the globs this bundle reads, each with what was in it just before Vite read it (so a file\n // added while the bundle is made differs from it afterwards), and what was in the known ones before it began.\n const globs = new Map<string, GlobScope>();\n const globsRead = new Map<string, ScopeContents>();\n const globsBefore = new Map([...entryGlobs].map(([id, scope]) => [id, readScope(scope)]));\n // The folders this bundle's plugins watch, each with what was in it when the plugin added it.\n const folders = new Map<string, { readonly path: string; readonly state: string }>();\n // The files known so far, as they are before the bundle begins, and each module as it is just before\n // the bundle reads it: a file edited while the bundle is made then differs from what is recorded\n // afterwards, which is what the catch-up looks for.\n const before = fileStates(entryFiles);\n const observed = new Map<string, string>();\n const loaded = new Map<string, string>(); // key → path of each module the bundle loaded\n const reads = new Map<string, FileRead>();\n let next: EntryBundle;\n try {\n next = await bundleEntry(config, entryPath, 'serve', options.outputFilename, {\n watchFiles,\n onWatchFile: (file) => {\n const key = fileKey(file);\n if (folders.has(key)) return;\n const path = canonicalPath(file);\n const state = folderState(path);\n if (state !== undefined) folders.set(key, { path, state });\n },\n onLoad: (file) => {\n const key = fileKey(file);\n const read = readsModules ? fileRead(canonicalPath(file)) : undefined;\n const state = read?.state ?? fileState(canonicalPath(file));\n if (state !== undefined && !observed.has(key)) observed.set(key, state);\n if (read !== undefined && !reads.has(key)) reads.set(key, read);\n if (!loaded.has(key)) loaded.set(key, canonicalPath(file));\n },\n onResolve: noteSpelling,\n onGlob: (scope) => {\n const id = scopeId(scope);\n if (globs.has(id)) return;\n globs.set(id, scope);\n globsRead.set(id, readScope(scope));\n },\n });\n } catch (error) {\n // The modules the failed bundle loaded, and the files its plugins watch, are inputs too: fixing an\n // imported one must bundle again. So is the place of an import it could not resolve: creating it must.\n const missing = missingImportFolders(authoredPaths);\n entryMissingFolders = missing.map(fileKey);\n entryFiles = new Map([...entryFiles, ...loaded, ...tracked(watchFiles), ...tracked(missing)]);\n entryStates = settledStates(entryFiles, observed, before);\n entryLinks = new Map([...entryLinks, ...spelled]);\n entryGlobs = new Map([...entryGlobs, ...globs]);\n globStates = new Map([...globsBefore, ...globsRead]);\n entryFolders = new Map([...entryFolders, ...folders]);\n watchEntryFiles(entryWatchTargets());\n throw error;\n }\n entry = next;\n entryStale = false;\n entryFiles = tracked(next.files);\n entryStates = settledStates(entryFiles, observed, before);\n entryLinks = spelled;\n entryMissingFolders = [];\n entryGlobs = globs;\n globStates = globsRead;\n entryFolders = folders;\n entryReads = reads;\n };\n\n // Whether the change reported for `key` is one the last good bundle already read (#343): a module of it, not a\n // story input, that is now as it was, state and content, when the bundle read it. A request catches up with a\n // change before the watcher reports it; the late event then needs no bundle, compile or reload. Comparing the\n // content as well tells a real save from it on a file system whose coarse timestamps leave the state unchanged;\n // a file touched or saved unchanged after the bundle read it has another state, and is bundled again as before.\n // So is a change in a folder a plugin of the bundle watches, while what is in the folder is still what the plugin\n // found there (#393).\n const alreadyRead = (key: string): boolean => {\n const read = entryReads.get(key);\n const path = entryFiles.get(key);\n if (entryStale || keyWithin(key, inputKeys())) return false;\n if (read === undefined && !entryFiles.has(key) && keyWithin(key, [...entryFolders.keys()]))\n return !foldersChanged();\n if (read === undefined || path === undefined) return false;\n const now = fileRead(path);\n return now?.state === read.state && now.hash === read.hash;\n };\n\n // `initial`: the compile at server start. No page is open yet, and Vite would\n // hold a full-reload for the first page that connects and reload it once.\n const rebuild = async (changed: ReadonlySet<string>, initial = false): Promise<void> => {\n if (closed) return;\n try {\n const unread = [...changed].filter((key) => !alreadyRead(key));\n const regrouped = linkMoved() || globsChanged() || foldersChanged();\n if (changed.size > 0 && unread.length === 0 && !regrouped) return;\n outputs = dev.outputs(config);\n output = outputPaths(outputs);\n // Taken before the compile reads anything, so a file written during it\n // still counts as changed afterwards.\n compiledInputs = storyInputFiles(true);\n compiledInputNames = inputWalk?.named;\n // The compile cache trusts modification times, which a quick save may leave\n // unchanged (coarse file-system timestamps); forget the files that changed.\n for (const key of [...cache.keys()]) if (changed.has(fileKey(key))) cache.delete(key);\n if (entryStale || regrouped || unread.some(touchesEntry)) await bundle();\n // Input-only stories can release a retained target too, by retargeting a named input link.\n watchEntryFiles(entryWatchTargets());\n const story = await compileStory(options.compile(entrySources(entry)), outputs, cache);\n for (const warning of story.warnings) config.logger.warn(`[twee-ts] ${warning}`);\n // Only a playable page can run the client; other outputs are served as compiled.\n html = outputMode === 'html' ? dev.injectClient(story.output, base) : story.output;\n servedAssets = entry?.assets;\n lastError = undefined;\n // A path tells the client to reload only the pages showing the story. Vite's client compares it with the\n // decoded page path and the base as configured, so under a base that has percent-encoded characters\n // (spaces, non-ASCII) the comparison never matches; then every page reloads instead.\n if (!initial) server.ws.send(reloadPayload(base, options.outputFilename));\n } catch (e) {\n lastError = toOverlayError(e);\n config.logger.error(`[twee-ts] ${lastError.message}`);\n server.ws.send({ type: 'error', err: lastError });\n }\n };\n\n // rebuild() reports its own errors; this catches a failure while reporting,\n // so one bad report doesn't stop every later rebuild.\n const keepQueueAlive = (e: unknown): void => {\n try {\n config.logger.error(`[twee-ts] ${fatalError(e).message}`);\n } catch {\n // Nothing left to report with.\n }\n };\n\n // A change to a file the story or the entry is made from: compiled with the others that land with it.\n const noteChange = (changed: string): void => {\n if (closed) return;\n pending.add(changed);\n clearTimeout(timer);\n timer = setTimeout(() => {\n const files = pending;\n pending = new Set();\n queue = queue.then(() => rebuild(files)).catch(keepQueueAlive);\n }, DEBOUNCE_MS);\n };\n\n await rebuild(new Set(), true);\n\n server.watcher.on('all', (event, path) => {\n // Loading the config for the entry build writes and deletes one of these;\n // reacting to it would bundle again, and again.\n if (isViteConfigTemp(path)) return;\n const changed = fileKey(path);\n // A file or folder added to or removed from a glob's scope may change what the glob selects; anything\n // in a folder a plugin of the entry build watches, or that folder itself (also one that did not exist yet),\n // may change what the plugin reads.\n const isDir = event === 'addDir' || event === 'unlinkDir';\n const regrouped =\n (event !== 'change' && inGlobScope(path, isDir)) ||\n inWatchedFolder(path) ||\n (isDir && entryPath !== undefined && entryFiles.has(changed));\n if (event !== 'add' && event !== 'change' && event !== 'unlink' && !regrouped) return;\n if (!regrouped && (!keyWithin(changed, inputKeys()) || excluded(path)) && !touchesEntry(changed) && !linkMoved()) {\n return;\n }\n noteChange(changed);\n });\n\n // The watcher can miss changes, or be off (`server.watch: null`). When a folder\n // is deleted and created again in quick succession (as `git rebase` does),\n // chokidar stops watching the folder, so a file added to it later raises no\n // event; under Deno it also loses the files created with it, so their later\n // edits raise none either. Before the story is served, this waits for any\n // compile under way, compares the story's input files and the entry's files\n // with what the last compile and bundle read, and compiles again first if\n // they differ. It also takes the events the watcher already reported and that\n // still wait out the debounce, so that a response never comes before the\n // rebuild one of them asks for (#436); an event for a change the bundle\n // already has asks for none (see rebuild).\n const catchUp = (): Promise<void> => {\n catchingUp ??= (async () => {\n // The debounce can fire while a rebuild runs and chain the rebuild an earlier event asked for after it: wait for\n // the queue as it is when the last one settles, not as it was when the request came (#442).\n for (let waited = queue; ; waited = queue) {\n await waited;\n if (queue === waited) break;\n }\n const changed = filesChanged(compiledInputs, storyInputFiles(false));\n if (compiledInputNames !== inputWalk?.named) for (const input of inputs) changed.add(fileKey(input));\n for (const file of filesChanged(entryStates, fileStates(entryFiles))) changed.add(file);\n if (changed.size === 0 && pending.size === 0 && !linkMoved() && !globsChanged() && !foldersChanged()) return;\n // Changes the watcher did report, still waiting out the debounce, go into the same compile.\n for (const file of pending) changed.add(file);\n pending = new Set();\n clearTimeout(timer);\n queue = queue.then(() => rebuild(changed)).catch(keepQueueAlive);\n await queue;\n })().finally(() => {\n catchingUp = undefined;\n });\n return catchingUp;\n };\n\n server.ws.on('connection', () => {\n if (lastError) server.ws.send({ type: 'error', err: lastError });\n });\n\n // Vite's base middleware strips the base from a request's URL before the\n // plugin's own middleware sees it, and only when the URL is below the base;\n // the URL as the request came in tells which.\n const requestUrls = new WeakMap<IncomingMessage, string>();\n server.middlewares.use((req, _res, next) => {\n requestUrls.set(req, String(req.url));\n next();\n });\n\n const send = (req: IncomingMessage, res: ServerResponse, type: string, body: string | Uint8Array): void => {\n // `server.headers`, as Vite sends them with the pages it serves itself.\n for (const [name, value] of Object.entries({ ...config.server.headers })) {\n if (typeof value === 'string' || typeof value === 'number') res.setHeader(name, value);\n else if (Array.isArray(value)) res.setHeader(name, value.map(String));\n }\n res.statusCode = 200;\n res.setHeader('Content-Type', type);\n res.setHeader('Content-Length', typeof body === 'string' ? Buffer.byteLength(body) : body.byteLength);\n // A page from the dev server is always checked again, as Vite serves its own.\n res.setHeader('Cache-Control', 'no-cache');\n res.end(req.method === 'HEAD' ? undefined : body);\n };\n\n return (req, res, next) => {\n if (req.method !== 'GET' && req.method !== 'HEAD') {\n next();\n return;\n }\n // Undefined for a request the middleware above never saw, which is then left alone.\n const path = pathBelowBase(String(requestUrls.get(req)), base);\n if (path === undefined) {\n next();\n return;\n }\n const mine = paths.includes(path);\n if (!mine && servedAssets?.has(path) !== true) {\n next();\n return;\n }\n // Any entry edit can introduce or remove a competing resource. Refresh every instance for a story request\n // before deciding ownership. Asset-only requests keep the assets of the last served story (#360).\n const refresh = [...instances].some((instance) => instance.paths.includes(path))\n ? Promise.all([...instances].map((instance) => instance.catchUp()))\n : Promise.resolve();\n refresh.then(() => {\n const others = [...instances].filter((other) => other !== self);\n if (\n (mine || servedAssets?.has(path) === true) &&\n others.some(\n (other) =>\n other.paths.includes(path) || (mine && paths.some((storyPath) => other.assets()?.has(storyPath) === true)),\n )\n ) {\n fail(res, storyCollisionMessage(path));\n return;\n }\n if (mine) {\n if (paths.some((storyPath) => servedAssets?.has(storyPath) === true)) {\n fail(res, storyCollisionMessage(path));\n return;\n }\n if (html) send(req, res, OUTPUT_MEDIA_TYPES[outputMode], html);\n else send(req, res, 'text/html; charset=utf-8', waitingPage(base));\n return;\n }\n // Files the entry's bundle still emits separately, where the build writes them.\n const asset = servedAssets?.get(path);\n if (asset === undefined) {\n next();\n return;\n }\n // Another instance emitting the same name with other bytes: the production build rejects that, and the dev\n // server must not pick one by plugin order.\n for (const other of others) {\n const theirs = other.assets()?.get(path);\n if (theirs !== undefined && !sameBytes(theirs, asset)) {\n fail(res, entryCollisionMessage(path));\n return;\n }\n }\n send(req, res, assetMediaType(path), asset);\n }, next);\n };\n}\n","/** Inventory public copies by their destination names, following directory links as Vite's copyDir does. */\nimport { existsSync, readdirSync, statSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport { fileKey } from './paths.js';\n\nexport function publicFiles(publicDir: string): string[] {\n if (!existsSync(publicDir)) return [];\n const files: string[] = [];\n const ancestors = new Set<string>();\n const walk = (folder: string): void => {\n const key = fileKey(folder);\n // Vite cannot copy a cycle, but dev also reads this inventory and must terminate. Track only ancestors:\n // separate aliases of the same folder produce separate copies, each of which discovery must exclude.\n if (ancestors.has(key)) return;\n ancestors.add(key);\n for (const name of readdirSync(folder)) {\n const path = resolve(folder, name);\n // Dangling and looping links have no copy to exclude. They must not prevent dev from serving the story.\n if (!existsSync(path)) continue;\n if (statSync(path).isDirectory()) walk(path);\n else files.push(relative(publicDir, path));\n }\n ancestors.delete(key);\n };\n walk(publicDir);\n return files;\n}\n","/**\n * Ready-made Vite plugin for twee-ts.\n *\n * Compiles Twee sources into the story HTML. With `entry`, Vite also bundles a\n * script, and the CSS it imports, into the story as its Story JavaScript and\n * Story Stylesheet.\n *\n * In dev the compiled HTML is served at the base URL with Vite's client added.\n * Every change to a source, the head file, a module or a file the entry was\n * bundled from recompiles it and reloads the page, and errors appear in Vite's\n * overlay (see vite-dev.ts). A build emits the story with the configured file\n * name, in the client environment only.\n */\nimport { resolve } from 'node:path';\nimport { version as viteVersion } from 'vite';\nimport type { BuildEnvironmentOptions, Plugin, ResolvedConfig, UserConfig } from 'vite';\nimport type { FileCacheEntry } from '../types.js';\nimport { recordOwnOutput } from '../atomic-write.js';\nimport { compileStory, fatalError } from './diagnostics.js';\nimport type { CompiledStory } from './diagnostics.js';\nimport { outputPaths } from '../filesystem.js';\nimport type { BuildOutputs, OutputPaths } from '../filesystem.js';\nimport { insertViteClient } from '../html-structure.js';\nimport { isSameOrInside } from '../path-identity.js';\nimport { checkViteVersion, resolvePluginOptions } from './options.js';\nimport type { SharedPluginOptions } from './options.js';\nimport { canonicalPath, createOutputRecord, emittedFilePath, fileKey, outputLocations, toPosix } from './paths.js';\nimport type { OutputLocation, OutputRecord } from './paths.js';\nimport { installStoryRoute, setUpDevStory } from './vite-dev.js';\nimport { publicFiles } from './vite-public.js';\nimport {\n bundleEntry,\n ENTRY_INPUT_NAME,\n entryInputSettings,\n entryRenderBuiltUrl,\n entryCollisionMessage,\n entrySources,\n fileOfId,\n forgetKeptResolver,\n importSpellings,\n PLUGIN_NAME,\n pluginWith,\n removeFromBundle,\n recordWatchFiles,\n takeEntryFromBundle,\n withWorkerPlugin,\n} from './vite-entry.js';\nimport type { BundleItem, EntryBundle, ImportHookContext } from './vite-entry.js';\nimport { moduleGlobScopes, readScope, scopeAdmits, scopeId, scopeWatchTargets } from './vite-glob.js';\nimport type { GlobScope } from './vite-glob.js';\nimport { importWatchTargets, watchTargets } from './watch-targets.js';\nimport { isRecord } from '../util.js';\n\nexport type { PluginCompileOptions } from './options.js';\n\nexport interface TweeTsVitePluginOptions extends SharedPluginOptions {\n /**\n * A JS or TS file, relative to the working directory. Vite bundles it and\n * everything it imports into one self-contained script that becomes the\n * story's Story JavaScript; CSS it imports becomes the Story Stylesheet.\n */\n entry?: string | undefined;\n}\n\n/**\n * A build input that stands in when the user's config names none, so Vite does\n * not look for an index.html (whose page would replace the story). Its empty\n * chunk is dropped from the output.\n */\nconst EMPTY_INPUT = 'virtual:twee-ts-empty-input';\nconst RESOLVED_EMPTY_INPUT = '\\0' + EMPTY_INPUT;\n\n/** The environment the story belongs to: the browser's. */\nconst CLIENT = 'client';\n\n/** Vite's plugin that bundles workers, and keeps their bundles between the builds of `vite build --watch`. */\nconst VITE_WORKER_PLUGIN = 'vite:worker';\n\n/** The plugin instances created so far, which numbers each instance's entry input. */\nlet instances = 0;\n\n/** The bundler options of build settings: `rolldownOptions`, or the older name Vite 8 still reads. */\nfunction bundlerOptionsOf(build: unknown): Readonly<Record<string, unknown>> | undefined {\n if (!isRecord(build)) return undefined;\n const options = build['rolldownOptions'] ?? build['rollupOptions'];\n return isRecord(options) ? options : undefined;\n}\n\n/**\n * Whether a config (or an environment's options) names what the build builds:\n * a bundler input, Vite 8's top-level `input`, a library entry or an SSR entry.\n */\nfunction namesInput(config: object): boolean {\n const build: unknown = Reflect.get(config, 'build');\n return (\n Reflect.get(config, 'input') !== undefined ||\n bundlerOptionsOf(build)?.['input'] !== undefined ||\n (isRecord(build) && (Boolean(build['lib']) || Boolean(build['ssr'])))\n );\n}\n\n/** Build settings naming one input. */\nfunction inputOnly(input: string): BuildEnvironmentOptions {\n return { rolldownOptions: { input } };\n}\n\n/**\n * Where a build with this config writes: each output's folder, the bundler's\n * `output.dir` or else `build.outDir`, or the bundler's `output.file`. Vite\n * resolves an `output.dir` against the root when it empties the folder and\n * copies the public files into it, while the bundler resolves it against the\n * working directory when it writes; both count.\n */\nfunction configOutputLocations(config: ResolvedConfig): OutputLocation[] {\n const outDir = resolve(config.root, config.build.outDir);\n const option = bundlerOptionsOf(config.build)?.['output'];\n const outputs: unknown[] = option === undefined ? [{}] : Array.isArray(option) ? option : [option];\n return outputs.flatMap((output) => {\n const [location] = outputLocations(output);\n if (location === undefined) return [{ dir: outDir }];\n if (location.dir === undefined) return [location];\n return [{ dir: resolve(location.dir) }, { dir: resolve(config.root, location.dir) }];\n });\n}\n\n/**\n * Every path a build with this config writes, as far as the config tells: each\n * output's folder (see configOutputLocations), the story in it, and the copies\n * of the public files Vite puts there. The plugin adds the files each bundle\n * writes as it builds (see createOutputRecord). A build passes its persistent\n * record so public copies remain excluded after a file is removed or a link is retargeted.\n */\nfunction configOutputs(config: ResolvedConfig, record: OutputRecord): BuildOutputs {\n const copiedFiles = config.build.copyPublicDir && config.publicDir ? publicFiles(config.publicDir) : [];\n for (const location of configOutputLocations(config)) {\n record.addLocation(location);\n record.addFiles(location, copiedFiles);\n }\n return record.outputs();\n}\n\n/** Both builds' outputs together. */\nfunction mergeOutputs(a: BuildOutputs, b: BuildOutputs): BuildOutputs {\n return {\n files: [...a.files, ...b.files],\n stories: [...(a.stories ?? []), ...(b.stories ?? [])],\n dirs: [...a.dirs, ...b.dirs],\n };\n}\n\n/** Adds Vite's client to the page, first in its head, so reloads and the error overlay reach it. */\nfunction injectViteClient(html: string, base: string): string {\n return insertViteClient(html, `${base}@vite/client`);\n}\n\n/**\n * What `vite build --watch` is told to watch for the entry's globs: each glob's folder (or the nearest one above it\n * that exists), by real path, as the bundler's watcher reports it. A folder that holds a build output is left out,\n * since the watcher would report what the build writes there and rebuild for ever: a file added to it is bundled\n * with the next build something else starts.\n */\nfunction globWatchTargets(scopes: Iterable<GlobScope>, outputs: OutputPaths): string[] {\n return scopeWatchTargets(scopes)\n .map(canonicalPath)\n .filter((folder) => !outputs.holds(folder));\n}\n\n/** Whether a resolved config is a build of the client, the only build that carries the story. */\nfunction isStoryBuild(config: ResolvedConfig): boolean {\n return config.command === 'build' && !config.build.ssr;\n}\n\n/** An import as written: its importer and its source. */\nfunction importKey(importer: string | undefined, source: string): string {\n return `${importer ?? ''}\\0${source}`;\n}\n\n/** Whether a plugin is Vite's own (its resolver, alias and the rest) or one of twee-ts's. */\nfunction isOwnPlugin(plugin: Plugin): boolean {\n return (\n plugin.name === 'alias' ||\n plugin.name.startsWith('vite:') ||\n plugin.name.startsWith('builtin:') ||\n plugin.name === PLUGIN_NAME ||\n plugin.name.startsWith(`${PLUGIN_NAME}:`)\n );\n}\n\n/**\n * A copy of `plugin` (see pluginWith) with a `resolveId` hook that passes each import it resolves (see importKey) to\n * `claim`. A plugin without a `resolveId` hook in JavaScript is returned as it is.\n */\nfunction claimingPlugin(plugin: Plugin, claim: (key: string) => void): Plugin {\n const hook = plugin.resolveId;\n const handler: unknown = typeof hook === 'function' ? hook : hook?.handler;\n if (typeof handler !== 'function') return plugin;\n const claiming = async function (this: unknown, ...args: unknown[]): Promise<unknown> {\n const result: unknown = await Reflect.apply(handler, this, args);\n const [source, importer] = args;\n if (result !== null && result !== undefined && typeof source === 'string') {\n claim(importKey(typeof importer === 'string' ? importer : undefined, source));\n }\n return result;\n };\n return pluginWith(\n plugin,\n new Map([['resolveId', typeof hook === 'function' ? claiming : { ...hook, handler: claiming }]]),\n );\n}\n\n/** The part of a build hook's context that registering watch targets uses. */\ntype WatchHookContext = ImportHookContext & {\n readonly environment: { readonly config: ResolvedConfig };\n addWatchFile(id: string): void;\n};\n\nexport function tweeTsPlugin(options: TweeTsVitePluginOptions): Plugin {\n checkViteVersion(viteVersion);\n const resolved = resolvePluginOptions('vite', options);\n const { outputFilename, entry: entryPath } = resolved;\n instances += 1;\n // The name of this instance's entry input, when it bundles the entry inside the user's build.\n const entryInput = `${ENTRY_INPUT_NAME}-${instances}`;\n const cache = new Map<string, FileCacheEntry>();\n // The entry bundled by a build of its own, for each build (by environment) that\n // couldn't bundle it inside itself.\n const ownBuilds = new WeakMap<object, EntryBundle>();\n const entryInputs = new WeakMap<ResolvedConfig, () => ReadonlySet<string>>();\n // The files this plugin's builds write, and their output folders, as each bundle\n // reports them. A source folder may hold any of them; none is a source.\n const record = createOutputRecord(outputFilename);\n // Everything the builds and the dev server leave out: what the config says a\n // build writes, and what the builds so far wrote.\n const allOutputs = (config: ResolvedConfig): BuildOutputs =>\n mergeOutputs(configOutputs(config, createOutputRecord(outputFilename)), record.outputs());\n\n /**\n * The build settings this instance adds to a client build: none when the\n * user's config names an input (the entry is then bundled by a build of its\n * own); else, with an entry, the entry as the only input (unless the user's\n * output is an array, which the entry's IIFE can't use); else the stand-in\n * input.\n */\n const inputSettings = (\n config: Readonly<UserConfig>,\n ): { build: BuildEnvironmentOptions; define?: Record<string, string> } | undefined => {\n if (namesInput(config)) return undefined;\n if (entryPath === undefined) return { build: inputOnly(EMPTY_INPUT) };\n const output = config.build?.rolldownOptions?.output;\n if (Array.isArray(output)) return { build: inputOnly(EMPTY_INPUT) };\n return entryInputSettings(entryInput, entryPath, output, outputFilename);\n };\n\n /** Whether this instance's entry is an input of the build with this config. */\n const bundlesEntryInside = (config: { readonly build: unknown }): boolean => {\n const input = bundlerOptionsOf(config.build)?.['input'];\n return isRecord(input) && Object.hasOwn(input, entryInput);\n };\n\n /** The resolved config of the build a hook runs in: its environment's, so builds sharing the instance keep apart. */\n const configOf = (context: { readonly environment: { readonly config: ResolvedConfig } }): ResolvedConfig =>\n context.environment.config;\n\n // What builds with each config write, as `vite build --watch` leaves them out of its watch targets; taken once per\n // build (see buildStart), and once per nested worker build, whose config is its own.\n let watchOutputs = new WeakMap<ResolvedConfig, OutputPaths>();\n // Each file (by real path) an import has reached in the builds of `vite build --watch`, by the import as written:\n // its importer and its source. Not by the path it reaches the file through, which a retarget may change too (a\n // package's `exports`, a folder's index of another extension).\n const keptTargets = new Map<string, Set<string>>();\n // The imports one of the user's plugins resolved itself (see importKey), in `vite build --watch`: their module is\n // the plugin's choice, which no link changes.\n const claimed = new Set<string>();\n const outputsOf = (config: ResolvedConfig): OutputPaths => {\n const known = watchOutputs.get(config);\n if (known !== undefined) return known;\n const outputs = outputPaths(allOutputs(config));\n watchOutputs.set(config, outputs);\n return outputs;\n };\n\n /**\n * `vite build --watch` with the entry bundled inside the build: the bundler watches each module by its real path,\n * so the links an import of the entry's graph goes through (or the folder where an import that reaches nothing\n * would be created) are registered here, as the import is resolved (see importWatchTargets).\n */\n const registerImport = async (context: WatchHookContext, source: string, importer: string | undefined) => {\n const config = configOf(context);\n const { spellings, kept } = await importSpellings(context, source, importer, config.root);\n for (const target of importWatchTargets(spellings, outputsOf(config))) context.addWatchFile(target);\n return kept;\n };\n\n /** Likewise, each glob's folder: Vite's import-glob reads the files a glob matches, and registers no folder. */\n const registerGlobs = async (\n context: WatchHookContext & Parameters<typeof moduleGlobScopes>[0],\n code: string,\n id: string,\n ) => {\n const config = configOf(context);\n const scopes = await moduleGlobScopes(context, code, id, config.root);\n for (const target of globWatchTargets(scopes, outputsOf(config))) context.addWatchFile(target);\n return scopes;\n };\n\n // The globs of the entry's workers in `vite build --watch`, by scopeId, each with the modules that call it.\n const workerGlobs = new Map<string, { readonly scope: GlobScope; readonly importers: Set<string> }>();\n let warnedWorkerCache = false;\n\n /**\n * `vite build --watch` keeps each worker's bundle until a file it read changes, and a file added to the folder of\n * one of its globs is none of those. When `file` is added to (or removed from) the scope of a worker's glob, the\n * bundles of the workers whose modules call the glob are let go, through Vite's own worker plugin, as an edit of\n * those modules would; the build that follows bundles them again (#424).\n */\n const releaseWorkerGlobs = async (context: WatchHookContext, file: string): Promise<void> => {\n const importers = [...workerGlobs.values()]\n .filter(({ scope }) => {\n // The folders the glob reaches through links as they are now: one linked in since is in its scope too.\n const { linked } = readScope(scope);\n return scopeAdmits(scope, file, false, linked) || scopeAdmits(scope, file, true, linked);\n })\n .flatMap(({ importers: modules }) => [...modules]);\n if (importers.length === 0) return;\n const hook = configOf(context).plugins.find((plugin) => plugin.name === VITE_WORKER_PLUGIN)?.watchChange;\n const handler: unknown = typeof hook === 'function' ? hook : hook?.handler;\n if (typeof handler !== 'function') {\n if (!warnedWorkerCache) {\n warnedWorkerCache = true;\n configOf(context).logger.warn(\n `[twee-ts] This Vite version has no ${VITE_WORKER_PLUGIN} plugin with a watchChange hook, through which ` +\n \"twee-ts has Vite bundle a worker again: a file added to the folder of a worker's import.meta.glob() is \" +\n \"bundled when one of the worker's modules changes.\",\n );\n }\n return;\n }\n for (const module of importers) await Reflect.apply(handler, context, [module, { event: 'update' }]);\n };\n\n /**\n * The same registrations in each build of a worker the entry starts, which Vite bundles nested in the entry's\n * build with the plugins of `worker.plugins` (#424). What a worker build registers is watched by the outer build.\n */\n const workerWatcher = (): Plugin => ({\n name: `${PLUGIN_NAME}:worker-watch`,\n resolveId: {\n order: 'pre',\n async handler(source, importer) {\n await registerImport(this, source, importer);\n return undefined;\n },\n },\n transform: {\n filter: { code: 'import.meta.glob' },\n async handler(code, id) {\n for (const scope of await registerGlobs(this, code, id)) {\n const key = scopeId(scope);\n const known = workerGlobs.get(key) ?? { scope, importers: new Set<string>() };\n known.importers.add(fileOfId(id));\n workerGlobs.set(key, known);\n }\n },\n },\n });\n\n return {\n name: PLUGIN_NAME,\n\n // The story belongs to the client build. A server or worker\n // environment a framework adds builds no copy of it.\n applyToEnvironment: (environment) => environment.name === CLIENT,\n\n // A build that bundles the entry inside itself finds the files it writes besides the story\n // from the output folder (see entryRenderBuiltUrl). Its input is the client environment's, which\n // configEnvironment below sets unless the config names one.\n config: {\n order: 'post',\n handler(config, env) {\n const client = config.environments?.[CLIENT] ?? {};\n if (env.command !== 'build' || entryPath === undefined || namesInput(config) || namesInput(client)) return;\n const renderBuiltUrl = entryRenderBuiltUrl(config.base, outputFilename, config.experimental?.renderBuiltUrl);\n if (renderBuiltUrl !== undefined) config.experimental = { ...config.experimental, renderBuiltUrl };\n // `vite build --watch`: the entry's workers register what they read too.\n if (config.build?.watch) config.worker = withWorkerPlugin(config.worker, workerWatcher);\n },\n },\n\n // The input of the client environment only.\n configEnvironment(name, environmentConfig, env) {\n if (name !== CLIENT || env.command !== 'build') return undefined;\n return inputSettings(environmentConfig);\n },\n\n configResolved(config) {\n if (entryPath === undefined) return;\n if (\n config.command === 'build' &&\n (bundlesEntryInside(config) || bundlesEntryInside({ build: config.environments[CLIENT]?.build }))\n ) {\n const recorder = recordWatchFiles(undefined, config.root);\n entryInputs.set(config, recorder.inputs);\n // The final plugin list includes environment-selected plugins. Record their addWatchFile calls,\n // as the separate entry build does, before any module or stylesheet is read.\n Reflect.set(\n config.plugins,\n config.plugins.length,\n pluginWith(\n recorder.plugin,\n new Map([['applyToEnvironment', (environment: { name: string }) => environment.name === CLIENT]]),\n ),\n );\n }\n // `vite build --watch` with the entry inside the build: note the imports the user's plugins resolve (see\n // resolveId below). Vite builds each environment's plugins from this list after this hook.\n if (config.command === 'build' && config.build.watch && bundlesEntryInside(config)) {\n config.plugins.forEach((plugin, at) => {\n if (!isOwnPlugin(plugin))\n Reflect.set(\n config.plugins,\n at,\n claimingPlugin(plugin, (key) => claimed.add(key)),\n );\n });\n }\n if (resolved.inputs.some((input) => isSameOrInside(entryPath, input))) {\n config.logger.warn(\n `[twee-ts] The entry ${toPosix(entryPath)} is inside the story sources (${resolved.sources.join(', ')}). ` +\n 'twee-ts also loads the .js and .css files it finds in source folders, unbundled, as Story JavaScript ' +\n \"and Story Stylesheet; keep the entry's folder out of `sources`.\",\n );\n }\n },\n\n // `vite build --watch` rebuilds for the files the build registers. The story's\n // inputs are read in generateBundle, outside the module graph, so they are\n // registered here; the dev server watches them itself (vite-dev.ts). An entry\n // the build can't bundle inside itself is bundled here, by a build of its own,\n // whose files are registered too.\n async buildStart() {\n const config = configOf(this);\n if (!isStoryBuild(config)) return;\n watchOutputs = new WeakMap();\n forgetKeptResolver(config);\n if (this.meta.watchMode) {\n const outputs = outputPaths(allOutputs(config), 'snapshot');\n // By real path: the bundler's watcher reports real paths (macOS FSEvents reports nothing else).\n for (const target of watchTargets(resolved.inputs, resolved.excluded, outputs, 'real')) {\n this.addWatchFile(target);\n }\n }\n if (entryPath === undefined || bundlesEntryInside(config)) return;\n // What the entry build read is registered whether it succeeds or fails: a failed bundle is\n // recovered by fixing one of these files, which no other input of the build includes.\n const watched = new Set<string>();\n const authored = new Set<string>([entryPath]);\n const globs: GlobScope[] = [];\n const registerEntryInputs = (): void => {\n if (!this.meta.watchMode) return;\n for (const file of watched) this.addWatchFile(canonicalPath(file));\n const outputs = outputPaths(allOutputs(config), 'snapshot');\n for (const target of importWatchTargets(authored, outputs)) this.addWatchFile(target);\n for (const target of globWatchTargets(globs, outputs)) this.addWatchFile(target);\n };\n watched.add(entryPath);\n let bundle: EntryBundle;\n try {\n bundle = await bundleEntry(config, entryPath, 'build', outputFilename, {\n watchFiles: watched,\n onLoad: (file) => watched.add(file),\n onResolve: (spelling) => authored.add(spelling),\n onGlob: (scope) => globs.push(scope),\n });\n } catch (e) {\n registerEntryInputs();\n return this.error(fatalError(e));\n }\n ownBuilds.set(this.environment, bundle);\n for (const file of bundle.files) watched.add(file);\n registerEntryInputs();\n return undefined;\n },\n\n // The compile cache trusts modification times, which a quick save may leave\n // unchanged (coarse file-system timestamps); forget a file that changed.\n async watchChange(id, change) {\n const changed = fileKey(id);\n for (const key of [...cache.keys()]) if (fileKey(key) === changed) cache.delete(key);\n if (change.event !== 'update') await releaseWorkerGlobs(this, id);\n },\n\n // `vite build --watch` with the entry bundled inside the build: Vite's import-glob reads the files a glob\n // matches when it bundles, and registers none of the folders it read, so a file added to one starts no\n // build. Each glob's folder is registered here, as the module comes past on its way to the import-glob.\n transform: {\n filter: { code: 'import.meta.glob' },\n async handler(code, id) {\n const config = configOf(this);\n if (!this.meta.watchMode || !isStoryBuild(config) || !bundlesEntryInside(config)) return;\n await registerGlobs(this, code, id);\n },\n },\n\n // Before the other plugins, which would resolve the import first: see registerImport.\n resolveId: {\n order: 'pre',\n async handler(id, importer, options) {\n if (id === EMPTY_INPUT) return RESOLVED_EMPTY_INPUT;\n const config = configOf(this);\n if (!this.meta.watchMode || !isStoryBuild(config) || !bundlesEntryInside(config)) return undefined;\n const kept = await registerImport(this, id, importer);\n // Vite's resolver keeps what an import resolved to for the builds that follow, also after a link on the\n // way is retargeted: the module it gives is then the old target. Each file the import reached is known;\n // when Vite's answer is one of those that it no longer reaches, the module is the one it reaches now, as a\n // new build would find (#320).\n if (kept === undefined) return undefined;\n const now = canonicalPath(kept);\n const written = importKey(importer, id);\n const targets = keptTargets.get(written) ?? new Set<string>();\n keptTargets.set(written, targets.add(now));\n if (targets.size < 2) return undefined;\n claimed.delete(written);\n const resolved = await this.resolve(id, importer, { ...options, skipSelf: true });\n // A plugin of the user's that resolved the import decided the module itself: it is left as it chose.\n if (claimed.has(written)) return undefined;\n if (resolved === null || resolved.external === true || resolved.external === 'absolute') return undefined;\n const file = canonicalPath(fileOfId(resolved.id));\n if (file === now || !targets.has(file)) return undefined;\n return { ...resolved, id: `${now}${/[?#].*$/s.exec(resolved.id)?.[0] ?? ''}` };\n },\n },\n\n load(id) {\n // A statement app builds keep (they drop unused exports), so the bundler\n // doesn't warn about an empty chunk. The chunk is removed from the output.\n return id === RESOLVED_EMPTY_INPUT ? 'globalThis.tweeTsEmptyInput = true;' : undefined;\n },\n\n generateBundle: {\n order: 'post',\n async handler(outputOptions, bundle) {\n const config = configOf(this);\n if (!isStoryBuild(config)) return;\n for (const [fileName, item] of Object.entries(bundle)) {\n if (item.type === 'chunk' && item.facadeModuleId === RESOLVED_EMPTY_INPUT) removeFromBundle(bundle, fileName);\n }\n if (Object.hasOwn(bundle, outputFilename)) {\n return this.error(\n `twee-ts: the build already writes a file named ${outputFilename} (another input or plugin emits it); ` +\n \"set the plugin's outputFilename to another name.\",\n );\n }\n let entry: EntryBundle | undefined;\n if (entryPath !== undefined) {\n const items: Record<string, BundleItem> = bundle;\n entry = bundlesEntryInside(config) ? takeEntryFromBundle(items, entryInput) : ownBuilds.get(this.environment);\n if (!bundlesEntryInside(config)) {\n for (const [fileName, source] of entry?.assets ?? []) {\n if (fileName === outputFilename || Object.hasOwn(bundle, fileName)) {\n return this.error(entryCollisionMessage(fileName));\n }\n this.emitFile({ type: 'asset', fileName, source });\n }\n }\n }\n // Where this output writes the story and the bundle, should the bundler's own\n // settings differ from what the config said. Nothing a build writes is a source.\n record.addLocation(outputOptions);\n record.addFiles(outputOptions, [...Object.keys(bundle), ...(entry?.assets.keys() ?? [])]);\n let story: CompiledStory;\n try {\n // Chunk moduleIds omit tree-shaken modules; CSS and worker plugins also read files registered only\n // with addWatchFile. Protect all of them, including the entry itself, from the story's write.\n const entryFiles =\n entryPath === undefined\n ? []\n : [\n entryPath,\n ...(entry?.files ?? []),\n ...(entryInputs.get(this.environment.getTopLevelConfig())?.() ?? []),\n ].filter((id) => !id.startsWith('\\0'));\n story = await compileStory(\n resolved.compile(entrySources(entry)),\n configOutputs(config, record),\n cache,\n true,\n entryFiles,\n );\n } catch (e) {\n return this.error(fatalError(e));\n }\n for (const warning of story.warnings) this.warn(warning);\n this.emitFile({ type: 'asset', fileName: outputFilename, source: story.output });\n return undefined;\n },\n },\n\n writeBundle(outputOptions, bundle) {\n const story = bundle[outputFilename];\n const path = emittedFilePath(outputOptions, outputFilename);\n // Vite writes the asset itself, so record its bytes only after the write. This also recognises markless\n // output modes and HTML with arbitrary filenames on subsequent builds, without trusting edited files.\n if (story?.type === 'asset' && path !== undefined) recordOwnOutput(path, story.source);\n },\n\n async configureServer(server) {\n const route = await setUpDevStory(server, {\n options: resolved,\n cache,\n outputs: allOutputs,\n injectClient: injectViteClient,\n });\n // Installed once Vite's internal middlewares are, between its request checks and its file serving.\n return () => {\n installStoryRoute(server.middlewares, route);\n };\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,MAAM,iBAAoC;CAAE,aAAa;CAAU,YAAY;CAAU,eAAe;AAAK;;AAG7G,SAAS,YAAY,MAAuB;CAC1C,OAAO,KAAK,SAAS,kBAAkB;AACzC;;AAGA,SAAS,aAAa,MAAqC;CACzD,OACE,KAAK,SAAS,sBACd,CAAC,KAAK,YACN,KAAK,SAAS,SAAS,gBACvB,KAAK,SAAS,SAAS,UACvB,KAAK,OAAO,SAAS,kBACrB,KAAK,OAAO,KAAK,SAAS,YAC1B,KAAK,OAAO,SAAS,SAAS;AAElC;;AAGA,SAAS,SAAS,MAA6D;CAC7E,IAAI,SAAS,MAAM,OAAO,KAAA;CAC1B,IAAI,KAAK,SAAS,WAAW,OAAO,OAAO,KAAK,UAAU,WAAW,KAAK,QAAQ,KAAA;CAClF,IAAI,KAAK,SAAS,qBAAqB,KAAK,YAAY,WAAW,GAAG,OAAO,KA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