@studiometa/foehn-vite-plugin 0.9.0 → 0.10.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/README.md +4 -0
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,6 +52,10 @@ foehn({
|
|
|
52
52
|
|
|
53
53
|
The plugin enables Vite's native manifest generation (`build.manifest: true`). The manifest is written to `.vite/manifest.json` in the output directory.
|
|
54
54
|
|
|
55
|
+
### Build Base
|
|
56
|
+
|
|
57
|
+
In a build, the plugin sets Vite's `base` to `'./'`, so the chunks of a dynamic `import()` and their `modulepreload` hints load from the URL of the bundle, under the theme. A `base` set in `vite.config.js` wins.
|
|
58
|
+
|
|
55
59
|
### Hot Reload
|
|
56
60
|
|
|
57
61
|
During development, the plugin writes a `hot` file inside `outDir` containing the dev server URL. It creates `outDir` when needed, so the dev server works before the first build. `ViteManifest::fromTheme()` reads the same file to detect dev mode and inject the Vite client script. If you change `hotFile`, pass the same name as the second argument of `fromTheme()`. The plugin removes the file when the dev server stops, also on Ctrl+C, and at the end of a build.
|
package/dist/index.js
CHANGED
|
@@ -231,11 +231,12 @@ function foehn(options) {
|
|
|
231
231
|
return [{
|
|
232
232
|
name: "foehn",
|
|
233
233
|
enforce: "pre",
|
|
234
|
-
async config(userConfig) {
|
|
234
|
+
async config(userConfig, { command }) {
|
|
235
235
|
const entries = await resolveGlobPatterns(resolvedOptions.input, resolvedOptions.themeDir);
|
|
236
236
|
const ddevConfig = await detectDdev(resolvedOptions.themeDir);
|
|
237
237
|
const proxyTarget = ddevConfig ? getDdevSiteUrl(ddevConfig) : void 0;
|
|
238
238
|
return {
|
|
239
|
+
base: userConfig.base ?? (command === "build" ? "./" : void 0),
|
|
239
240
|
build: {
|
|
240
241
|
manifest: true,
|
|
241
242
|
outDir,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/options.ts","../src/utils/glob.ts","../src/utils/ddev.ts","../src/utils/hot.ts","../src/utils/browser-log.ts","../src/plugin.ts"],"sourcesContent":["/**\n * Options for the Føhn Vite plugin.\n */\nexport interface FoehnPluginOptions {\n /**\n * Glob patterns for entry points.\n * @example [\"src/js/app.js\", \"src/css/app.css\"]\n */\n input: string | string[];\n\n /**\n * Files to watch for full reload.\n * @default [\"templates/**\\/*.twig\"]\n */\n reload?: string | string[];\n\n /**\n * Output directory for built assets.\n * @default \"dist\"\n */\n outDir?: string;\n\n /**\n * Theme directory context.\n * @default process.cwd()\n */\n themeDir?: string;\n\n /**\n * Name of the hot file generated during development, written inside\n * `outDir`. Pass the same name to `ViteManifest::fromTheme()` when you\n * change it.\n * @default \"hot\"\n */\n hotFile?: string;\n}\n\n/**\n * Resolved options with all defaults applied.\n */\nexport interface ResolvedFoehnPluginOptions {\n input: string[];\n reload: string[];\n outDir: string;\n themeDir: string;\n hotFile: string;\n}\n\n/**\n * Default values for optional options.\n */\nexport const defaultOptions: Omit<ResolvedFoehnPluginOptions, \"input\"> = {\n reload: [\"templates/**/*.twig\"],\n outDir: \"dist\",\n themeDir: process.cwd(),\n hotFile: \"hot\",\n};\n\n/**\n * Normalize and resolve plugin options.\n */\nexport function resolveOptions(options: FoehnPluginOptions): ResolvedFoehnPluginOptions {\n const input = Array.isArray(options.input) ? options.input : [options.input];\n\n const reload = options.reload\n ? Array.isArray(options.reload)\n ? options.reload\n : [options.reload]\n : defaultOptions.reload;\n\n return {\n input,\n reload,\n outDir: options.outDir ?? defaultOptions.outDir,\n themeDir: options.themeDir ?? defaultOptions.themeDir,\n hotFile: options.hotFile ?? defaultOptions.hotFile,\n };\n}\n","import fastGlob from \"fast-glob\";\nimport { resolve, relative } from \"node:path\";\n\n/**\n * Resolve glob patterns to absolute file paths.\n */\nexport async function resolveGlobPatterns(\n patterns: string[],\n cwd: string,\n): Promise<Record<string, string>> {\n const entries: Record<string, string> = {};\n\n for (const pattern of patterns) {\n // Check if pattern contains glob characters\n if (pattern.includes(\"*\") || pattern.includes(\"?\") || pattern.includes(\"{\")) {\n const files = await fastGlob(pattern, { cwd, absolute: true });\n for (const file of files) {\n const relativePath = relative(cwd, file);\n // Remove extension for entry name\n const name = relativePath.replace(/\\.[^/.]+$/, \"\");\n entries[name] = file;\n }\n } else {\n // Direct file path\n const absolutePath = resolve(cwd, pattern);\n const name = pattern.replace(/\\.[^/.]+$/, \"\");\n entries[name] = absolutePath;\n }\n }\n\n return entries;\n}\n","import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\n\n/**\n * DDEV project configuration structure.\n */\nexport interface DdevConfig {\n name: string;\n router_http_port?: string;\n router_https_port?: string;\n}\n\n/**\n * Detect DDEV configuration from the project root.\n * Returns null if no DDEV config is found.\n */\nexport async function detectDdev(projectRoot: string): Promise<DdevConfig | null> {\n const configPath = resolve(projectRoot, \".ddev/config.yaml\");\n\n try {\n const content = await readFile(configPath, \"utf-8\");\n return parseDdevConfig(content);\n } catch {\n return null;\n }\n}\n\n/**\n * Parse DDEV YAML config (simple parser, no dependency needed).\n */\nfunction parseDdevConfig(content: string): DdevConfig {\n const lines = content.split(\"\\n\");\n const config: Record<string, string> = {};\n\n for (const line of lines) {\n const match = line.match(/^(\\w+):\\s*(.+)$/);\n if (match) {\n const key = match[1];\n let value = match[2].trim();\n // Remove quotes if present\n if (\n (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n value = value.slice(1, -1);\n }\n config[key] = value;\n }\n }\n\n return {\n name: config.name ?? \"unknown\",\n router_http_port: config.router_http_port,\n router_https_port: config.router_https_port,\n };\n}\n\n/**\n * Get the DDEV site URL for proxy configuration.\n */\nexport function getDdevSiteUrl(config: DdevConfig): string {\n const port = config.router_https_port ?? \"443\";\n const portSuffix = port === \"443\" ? \"\" : `:${port}`;\n return `https://${config.name}.ddev.site${portSuffix}`;\n}\n","import { rmSync } from \"node:fs\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\n/**\n * Write the hot file with the dev server URL.\n * The PHP side reads this file to detect dev mode and inject the Vite client.\n * The directory is created when it does not exist yet, so the dev server works\n * before the first build.\n */\nexport async function writeHotFile(hotPath: string, serverUrl: string): Promise<void> {\n await mkdir(dirname(hotPath), { recursive: true });\n await writeFile(hotPath, serverUrl, \"utf-8\");\n}\n\n/**\n * Remove the hot file when the dev server stops. Synchronous, so it is done\n * before a process that is exiting goes away. A missing file is not an error.\n */\nexport function removeHotFile(hotPath: string): void {\n rmSync(hotPath, { force: true });\n}\n","import { appendFileSync, mkdirSync, renameSync, rmSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\n/**\n * The browser log: the console errors and the uncaught errors of the pages the dev\n * server serves, one JSON object per line, for `wp foehn errors --browser`.\n *\n * The file has a cap, as the PHP error log does. When the next entry would make it\n * larger than `MAX_BYTES`, it becomes `browser-errors.1.jsonl`, the previous\n * `browser-errors.1.jsonl` becomes `browser-errors.2.jsonl`, and the oldest file is\n * deleted. So the log never holds more than `MAX_FILES` files of `MAX_BYTES`.\n */\nexport const BROWSER_LOG = \"browser-errors\";\n\nexport const MAX_BYTES = 256 * 1024;\n\nexport const MAX_FILES = 3;\n\n/** The characters of a message the entry keeps. */\nconst MAX_MESSAGE = 2000;\n\n/** The frames of the project's own code the entry keeps. */\nconst MAX_OWN_FRAMES = 8;\n\n/**\n * What the Vite client sends on `vite:forward-console` (Vite 8 `server.forwardConsole`).\n */\nexport type ForwardConsolePayload =\n | {\n type: \"error\" | \"unhandled-rejection\";\n data: { name: string; message: string; stack?: string };\n }\n | { type: \"log\"; data: { level: string; message: string } };\n\n/**\n * A place in a source file of the project, relative to the Vite root.\n */\nexport interface SourcePosition {\n file: string;\n line: number;\n}\n\n/**\n * Finds the source file and line of a position in a module the browser loaded, or\n * `null` when the module is not the project's own code (a dependency, another\n * origin, an unknown URL).\n */\nexport type FrameResolver = (\n url: string,\n line: number,\n column: number,\n) => Promise<SourcePosition | null>;\n\n/**\n * One entry of the browser log. The fields are the ones `wp foehn errors` prints.\n */\nexport interface BrowserEntry {\n time: string;\n level: \"error\" | \"rejection\" | \"console\";\n class: string;\n message: string;\n file: string | null;\n line: number | null;\n stack: string[];\n}\n\n/**\n * The entry of one forwarded event.\n *\n * An uncaught error or an unhandled rejection gives the frames of the project's own\n * code, mapped back to the source, then the number of other frames. A console call\n * has no stack.\n */\nexport async function browserEntry(\n payload: ForwardConsolePayload,\n resolve: FrameResolver,\n now: Date = new Date(),\n): Promise<BrowserEntry> {\n const time = now.toISOString().replace(/\\.\\d+Z$/, \"Z\");\n\n if (payload.type === \"log\") {\n return {\n time,\n level: \"console\",\n class: `console.${payload.data.level}`,\n message: shorten(payload.data.message),\n file: null,\n line: null,\n stack: [],\n };\n }\n\n const own: string[] = [];\n let first: SourcePosition | null = null;\n let others = 0;\n\n for (const frame of parseStack(payload.data.stack ?? \"\")) {\n const position =\n own.length < MAX_OWN_FRAMES ? await resolve(frame.url, frame.line, frame.column) : null;\n\n if (position === null) {\n others++;\n continue;\n }\n\n first ??= position;\n own.push(`${position.file}:${position.line}${frame.fn === \"\" ? \"\" : ` ${frame.fn}()`}`);\n }\n\n if (others > 0) {\n own.push(`+${others} other ${others === 1 ? \"frame\" : \"frames\"}`);\n }\n\n return {\n time,\n level: payload.type === \"error\" ? \"error\" : \"rejection\",\n class: shorten(payload.data.name),\n message: shorten(payload.data.message),\n file: first?.file ?? null,\n line: first?.line ?? null,\n stack: own,\n };\n}\n\n/**\n * The frames of a stack, as Chromium (`at fn (url:line:column)`) and Firefox or\n * Safari (`fn@url:line:column`) write them. Other lines, such as the message, are\n * skipped.\n */\nexport function parseStack(\n stack: string,\n): Array<{ fn: string; url: string; line: number; column: number }> {\n const frames = [];\n\n for (const text of stack.split(\"\\n\")) {\n const match =\n /^\\s*at\\s+(?:(.*?)\\s+\\()?(.+?):(\\d+):(\\d+)\\)?\\s*$/.exec(text) ??\n /^\\s*(.*?)@(.+?):(\\d+):(\\d+)\\s*$/.exec(text);\n\n if (match) {\n frames.push({\n fn: match[1] ?? \"\",\n url: match[2],\n line: Number(match[3]),\n column: Number(match[4]),\n });\n }\n }\n\n return frames;\n}\n\n/**\n * Add an entry at the end of the log in `directory`. Synchronous, so two events\n * never rotate the files at the same time.\n */\nexport function appendBrowserEntry(directory: string, entry: BrowserEntry): void {\n const line = `${JSON.stringify(entry)}\\n`;\n const file = logFile(directory, 0);\n\n mkdirSync(directory, { recursive: true });\n\n const size = statSync(file, { throwIfNoEntry: false })?.size ?? 0;\n\n if (size > 0 && size + Buffer.byteLength(line) > MAX_BYTES) {\n rmSync(logFile(directory, MAX_FILES - 1), { force: true });\n\n for (let index = MAX_FILES - 2; index >= 0; index--) {\n if (statSync(logFile(directory, index), { throwIfNoEntry: false })) {\n renameSync(logFile(directory, index), logFile(directory, index + 1));\n }\n }\n }\n\n appendFileSync(file, line, \"utf-8\");\n}\n\n/**\n * The path of one file of the log: `browser-errors.jsonl`, then\n * `browser-errors.1.jsonl` and `browser-errors.2.jsonl`.\n */\nexport function logFile(directory: string, index: number): string {\n return join(directory, `${BROWSER_LOG}${index === 0 ? \"\" : `.${index}`}.jsonl`);\n}\n\nfunction shorten(text: string): string {\n return text.length > MAX_MESSAGE ? `${text.slice(0, MAX_MESSAGE)}…` : text;\n}\n","import { statSync } from \"node:fs\";\nimport type { IncomingMessage } from \"node:http\";\nimport type { AddressInfo } from \"node:net\";\nimport { constants } from \"node:os\";\nimport { isAbsolute, join, relative, resolve } from \"node:path\";\nimport { originalPositionFor, TraceMap, type SourceMapInput } from \"@jridgewell/trace-mapping\";\nimport type { DevEnvironment, Plugin, ResolvedConfig, ViteDevServer } from \"vite\";\nimport type { FoehnPluginOptions, ResolvedFoehnPluginOptions } from \"./options.js\";\nimport { resolveOptions } from \"./options.js\";\nimport {\n resolveGlobPatterns,\n detectDdev,\n getDdevSiteUrl,\n writeHotFile,\n removeHotFile,\n appendBrowserEntry,\n browserEntry,\n type ForwardConsolePayload,\n type SourcePosition,\n} from \"./utils/index.js\";\n\n/**\n * The origins Vite allows by default (`defaultAllowedOrigins`, exported by Vite\n * 6.0.9 and later only).\n */\nconst LOCALHOST_ORIGINS = /^https?:\\/\\/(?:(?:[^:]+\\.)?localhost|127\\.0\\.0\\.1|\\[::1\\])(?::\\d+)?$/;\n\n/** Signals that end the process without Vite closing the server first. */\nconst EXIT_SIGNALS = [\"SIGINT\", \"SIGHUP\"] as const;\n\n/**\n * Creates the Føhn Vite plugin.\n */\nexport function foehn(options: FoehnPluginOptions): Plugin[] {\n const resolvedOptions = resolveOptions(options);\n const outDir = resolve(resolvedOptions.themeDir, resolvedOptions.outDir);\n // Inside the build output, where `ViteManifest` looks for it.\n const hotPath = resolve(outDir, resolvedOptions.hotFile);\n let config: ResolvedConfig;\n\n const mainPlugin: Plugin = {\n name: \"foehn\",\n enforce: \"pre\",\n\n async config(userConfig) {\n const entries = await resolveGlobPatterns(\n resolvedOptions.input,\n resolvedOptions.themeDir,\n );\n\n // Detect DDEV for proxy configuration\n const ddevConfig = await detectDdev(resolvedOptions.themeDir);\n const proxyTarget = ddevConfig ? getDdevSiteUrl(ddevConfig) : undefined;\n\n return {\n build: {\n manifest: true,\n outDir,\n rollupOptions: {\n input: entries,\n },\n },\n server: {\n // Vite 8 turns it on only when it runs inside a coding agent. On,\n // the page sends its console errors and uncaught errors to the\n // server, which writes them to the browser log for any agent.\n forwardConsole: userConfig.server?.forwardConsole ?? true,\n // A page opened on the DDEV URL loads `/@vite/client` from the dev\n // server, which Vite allows only for localhost pages by default.\n cors:\n userConfig.server?.cors ??\n (proxyTarget\n ? { origin: [LOCALHOST_ORIGINS, new URL(proxyTarget).origin] }\n : undefined),\n proxy: proxyTarget\n ? {\n // Vite answers what it can serve, DDEV the rest\n \"/\": {\n target: proxyTarget,\n changeOrigin: true,\n secure: false,\n bypass: (req) =>\n isServedByVite(req, config) ? req.url : undefined,\n },\n }\n : undefined,\n },\n };\n },\n\n configResolved(resolvedConfig) {\n config = resolvedConfig;\n },\n\n configureServer(server: ViteDevServer) {\n // Beside the hot file, where `wp foehn errors --browser` reads it\n const client = server.environments.client;\n client.hot.on(\"vite:forward-console\", (payload: ForwardConsolePayload) => {\n browserEntry(payload, (url, line, column) =>\n findSource(client, config.root, url, line, column),\n )\n .then((entry) => appendBrowserEntry(outDir, entry))\n .catch((error: Error) =>\n config.logger.warn(\n `[foehn] Cannot write the browser log: ${error.message}`,\n ),\n );\n });\n\n const httpServer = server.httpServer;\n if (!httpServer) {\n return;\n }\n\n // Write hot file when server starts, with the address it listens on\n httpServer.once(\"listening\", async () => {\n const address = httpServer.address();\n if (typeof address === \"object\" && address) {\n await writeHotFile(hotPath, getServerUrl(address, config));\n }\n });\n\n // Vite closes the server on SIGTERM only. Ctrl+C (SIGINT) and a\n // closed terminal (SIGHUP) kill the process, and a hot file left\n // behind points every WordPress page at a dead server.\n const onSignal = (signal: NodeJS.Signals) => {\n removeHotFile(hotPath);\n process.exit(128 + constants.signals[signal]);\n };\n for (const signal of EXIT_SIGNALS) {\n process.on(signal, onSignal);\n }\n\n // Remove hot file when server closes\n httpServer.on(\"close\", () => {\n removeHotFile(hotPath);\n for (const signal of EXIT_SIGNALS) {\n process.off(signal, onSignal);\n }\n });\n },\n\n buildEnd() {\n // Ensure hot file is removed after build\n if (config.command === \"build\") {\n removeHotFile(hotPath);\n }\n },\n };\n\n // Separate plugin for file watching (full reload)\n const reloadPlugin = createReloadPlugin(resolvedOptions);\n\n return [mainPlugin, reloadPlugin];\n}\n\n/**\n * Creates a plugin that watches files for full reload.\n */\nfunction createReloadPlugin(options: ResolvedFoehnPluginOptions): Plugin {\n return {\n name: \"foehn:reload\",\n\n configureServer(server: ViteDevServer) {\n // Watch files for full reload\n for (const pattern of options.reload) {\n const fullPattern = resolve(options.themeDir, pattern);\n server.watcher.add(fullPattern);\n }\n\n server.watcher.on(\"change\", (file) => {\n // Check if the changed file matches any reload pattern\n const shouldReload = options.reload.some((pattern) => {\n const fullPattern = resolve(options.themeDir, pattern);\n return matchPattern(file, fullPattern);\n });\n\n if (shouldReload) {\n server.ws.send({ type: \"full-reload\" });\n }\n });\n },\n };\n}\n\n/**\n * Simple pattern matching for file paths.\n */\nfunction matchPattern(file: string, pattern: string): boolean {\n // Convert glob pattern to regex\n const regexPattern = pattern\n .replace(/\\*\\*/g, \"<<<GLOBSTAR>>>\")\n .replace(/\\*/g, \"[^/]*\")\n .replace(/<<<GLOBSTAR>>>/g, \".*\")\n .replace(/\\?/g, \".\");\n\n return new RegExp(`^${regexPattern}$`).test(file);\n}\n\n/**\n * Whether the dev server answers a request itself: its internal routes\n * (`/@vite/client`, `/@fs/`, `/@id/`, `/__open-in-editor`), dependencies, the\n * HMR ping, and every file under the root or the public directory, whatever\n * the query (`?import`, `?direct`, `?v=`).\n */\nfunction isServedByVite(req: IncomingMessage, config: ResolvedConfig): boolean {\n if (req.headers.accept === \"text/x-vite-ping\") {\n return true;\n }\n\n let path: string;\n try {\n path = decodeURIComponent((req.url ?? \"/\").split(/[?#]/)[0]);\n } catch {\n // A malformed URL is not a module, let WordPress answer it\n return false;\n }\n\n if (path.startsWith(\"/@\") || path.startsWith(\"/__\") || path.startsWith(\"/node_modules/\")) {\n return true;\n }\n\n return [config.root, config.publicDir].some(\n (dir) => dir !== \"\" && statSync(join(dir, path), { throwIfNoEntry: false })?.isFile(),\n );\n}\n\n/**\n * The place in the project's source of a position in a module the browser loaded:\n * the module's file relative to the Vite root, and the line mapped back through\n * the module's source map (TypeScript, JSX and Vue change the line numbers).\n * `null` for a module of a dependency, a URL of another server, or a module the\n * dev server has not served.\n */\nasync function findSource(\n environment: DevEnvironment,\n root: string,\n url: string,\n line: number,\n column: number,\n): Promise<SourcePosition | null> {\n let path: string;\n try {\n // With the query: a Vue block (`?vue&type=script`) is a module of its own.\n // Vite drops the `?t=` of a hot update and the `?import` itself.\n const parsed = new URL(url);\n path = decodeURIComponent(parsed.pathname) + parsed.search;\n } catch {\n return null;\n }\n\n const module = await environment.moduleGraph.getModuleByUrl(path);\n const file = module?.file ? relative(root, module.file) : \"\";\n\n if (file === \"\" || file.startsWith(\"..\") || isAbsolute(file) || file.includes(\"node_modules\")) {\n return null;\n }\n\n const map = module?.transformResult?.map;\n\n if (map && map.mappings !== \"\") {\n const original = originalPositionFor(new TraceMap(map as SourceMapInput), {\n line,\n column: Math.max(column - 1, 0),\n });\n\n if (original.line !== null) {\n return { file, line: original.line };\n }\n }\n\n return { file, line };\n}\n\n/**\n * Get the URL a browser reaches the dev server at.\n */\nfunction getServerUrl(address: AddressInfo, config: ResolvedConfig): string {\n const protocol = config.server.https ? \"https\" : \"http\";\n const host = [\"::\", \"0.0.0.0\", \"::1\", \"127.0.0.1\"].includes(address.address)\n ? \"localhost\"\n : address.family === \"IPv6\"\n ? `[${address.address}]`\n : address.address;\n return `${protocol}://${host}:${address.port}`;\n}\n"],"mappings":";;;;;;;;;;AAmDA,IAAa,iBAA4D;CACrE,QAAQ,CAAC,qBAAqB;CAC9B,QAAQ;CACR,UAAU,QAAQ,IAAI;CACtB,SAAS;AACb;;;;AAKA,SAAgB,eAAe,SAAyD;CASpF,OAAO;EACH,OATU,MAAM,QAAQ,QAAQ,KAAK,IAAI,QAAQ,QAAQ,CAAC,QAAQ,KAAK;EAUvE,QARW,QAAQ,SACjB,MAAM,QAAQ,QAAQ,MAAM,IACxB,QAAQ,SACR,CAAC,QAAQ,MAAM,IACnB,eAAe;EAKjB,QAAQ,QAAQ,UAAU,eAAe;EACzC,UAAU,QAAQ,YAAY,eAAe;EAC7C,SAAS,QAAQ,WAAW,eAAe;CAC/C;AACJ;;;;;;ACvEA,eAAsB,oBAClB,UACA,KAC+B;CAC/B,MAAM,UAAkC,CAAC;CAEzC,KAAK,MAAM,WAAW,UAElB,IAAI,QAAQ,SAAS,GAAG,KAAK,QAAQ,SAAS,GAAG,KAAK,QAAQ,SAAS,GAAG,GAAG;EACzE,MAAM,QAA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AQ,QAAQ,KACpB,QAAQ,QACa,GAAG,QAAQ;AAC5C"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/options.ts","../src/utils/glob.ts","../src/utils/ddev.ts","../src/utils/hot.ts","../src/utils/browser-log.ts","../src/plugin.ts"],"sourcesContent":["/**\n * Options for the Føhn Vite plugin.\n */\nexport interface FoehnPluginOptions {\n /**\n * Glob patterns for entry points.\n * @example [\"src/js/app.js\", \"src/css/app.css\"]\n */\n input: string | string[];\n\n /**\n * Files to watch for full reload.\n * @default [\"templates/**\\/*.twig\"]\n */\n reload?: string | string[];\n\n /**\n * Output directory for built assets.\n * @default \"dist\"\n */\n outDir?: string;\n\n /**\n * Theme directory context.\n * @default process.cwd()\n */\n themeDir?: string;\n\n /**\n * Name of the hot file generated during development, written inside\n * `outDir`. Pass the same name to `ViteManifest::fromTheme()` when you\n * change it.\n * @default \"hot\"\n */\n hotFile?: string;\n}\n\n/**\n * Resolved options with all defaults applied.\n */\nexport interface ResolvedFoehnPluginOptions {\n input: string[];\n reload: string[];\n outDir: string;\n themeDir: string;\n hotFile: string;\n}\n\n/**\n * Default values for optional options.\n */\nexport const defaultOptions: Omit<ResolvedFoehnPluginOptions, \"input\"> = {\n reload: [\"templates/**/*.twig\"],\n outDir: \"dist\",\n themeDir: process.cwd(),\n hotFile: \"hot\",\n};\n\n/**\n * Normalize and resolve plugin options.\n */\nexport function resolveOptions(options: FoehnPluginOptions): ResolvedFoehnPluginOptions {\n const input = Array.isArray(options.input) ? options.input : [options.input];\n\n const reload = options.reload\n ? Array.isArray(options.reload)\n ? options.reload\n : [options.reload]\n : defaultOptions.reload;\n\n return {\n input,\n reload,\n outDir: options.outDir ?? defaultOptions.outDir,\n themeDir: options.themeDir ?? defaultOptions.themeDir,\n hotFile: options.hotFile ?? defaultOptions.hotFile,\n };\n}\n","import fastGlob from \"fast-glob\";\nimport { resolve, relative } from \"node:path\";\n\n/**\n * Resolve glob patterns to absolute file paths.\n */\nexport async function resolveGlobPatterns(\n patterns: string[],\n cwd: string,\n): Promise<Record<string, string>> {\n const entries: Record<string, string> = {};\n\n for (const pattern of patterns) {\n // Check if pattern contains glob characters\n if (pattern.includes(\"*\") || pattern.includes(\"?\") || pattern.includes(\"{\")) {\n const files = await fastGlob(pattern, { cwd, absolute: true });\n for (const file of files) {\n const relativePath = relative(cwd, file);\n // Remove extension for entry name\n const name = relativePath.replace(/\\.[^/.]+$/, \"\");\n entries[name] = file;\n }\n } else {\n // Direct file path\n const absolutePath = resolve(cwd, pattern);\n const name = pattern.replace(/\\.[^/.]+$/, \"\");\n entries[name] = absolutePath;\n }\n }\n\n return entries;\n}\n","import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\n\n/**\n * DDEV project configuration structure.\n */\nexport interface DdevConfig {\n name: string;\n router_http_port?: string;\n router_https_port?: string;\n}\n\n/**\n * Detect DDEV configuration from the project root.\n * Returns null if no DDEV config is found.\n */\nexport async function detectDdev(projectRoot: string): Promise<DdevConfig | null> {\n const configPath = resolve(projectRoot, \".ddev/config.yaml\");\n\n try {\n const content = await readFile(configPath, \"utf-8\");\n return parseDdevConfig(content);\n } catch {\n return null;\n }\n}\n\n/**\n * Parse DDEV YAML config (simple parser, no dependency needed).\n */\nfunction parseDdevConfig(content: string): DdevConfig {\n const lines = content.split(\"\\n\");\n const config: Record<string, string> = {};\n\n for (const line of lines) {\n const match = line.match(/^(\\w+):\\s*(.+)$/);\n if (match) {\n const key = match[1];\n let value = match[2].trim();\n // Remove quotes if present\n if (\n (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n value = value.slice(1, -1);\n }\n config[key] = value;\n }\n }\n\n return {\n name: config.name ?? \"unknown\",\n router_http_port: config.router_http_port,\n router_https_port: config.router_https_port,\n };\n}\n\n/**\n * Get the DDEV site URL for proxy configuration.\n */\nexport function getDdevSiteUrl(config: DdevConfig): string {\n const port = config.router_https_port ?? \"443\";\n const portSuffix = port === \"443\" ? \"\" : `:${port}`;\n return `https://${config.name}.ddev.site${portSuffix}`;\n}\n","import { rmSync } from \"node:fs\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\n/**\n * Write the hot file with the dev server URL.\n * The PHP side reads this file to detect dev mode and inject the Vite client.\n * The directory is created when it does not exist yet, so the dev server works\n * before the first build.\n */\nexport async function writeHotFile(hotPath: string, serverUrl: string): Promise<void> {\n await mkdir(dirname(hotPath), { recursive: true });\n await writeFile(hotPath, serverUrl, \"utf-8\");\n}\n\n/**\n * Remove the hot file when the dev server stops. Synchronous, so it is done\n * before a process that is exiting goes away. A missing file is not an error.\n */\nexport function removeHotFile(hotPath: string): void {\n rmSync(hotPath, { force: true });\n}\n","import { appendFileSync, mkdirSync, renameSync, rmSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\n/**\n * The browser log: the console errors and the uncaught errors of the pages the dev\n * server serves, one JSON object per line, for `wp foehn errors --browser`.\n *\n * The file has a cap, as the PHP error log does. When the next entry would make it\n * larger than `MAX_BYTES`, it becomes `browser-errors.1.jsonl`, the previous\n * `browser-errors.1.jsonl` becomes `browser-errors.2.jsonl`, and the oldest file is\n * deleted. So the log never holds more than `MAX_FILES` files of `MAX_BYTES`.\n */\nexport const BROWSER_LOG = \"browser-errors\";\n\nexport const MAX_BYTES = 256 * 1024;\n\nexport const MAX_FILES = 3;\n\n/** The characters of a message the entry keeps. */\nconst MAX_MESSAGE = 2000;\n\n/** The frames of the project's own code the entry keeps. */\nconst MAX_OWN_FRAMES = 8;\n\n/**\n * What the Vite client sends on `vite:forward-console` (Vite 8 `server.forwardConsole`).\n */\nexport type ForwardConsolePayload =\n | {\n type: \"error\" | \"unhandled-rejection\";\n data: { name: string; message: string; stack?: string };\n }\n | { type: \"log\"; data: { level: string; message: string } };\n\n/**\n * A place in a source file of the project, relative to the Vite root.\n */\nexport interface SourcePosition {\n file: string;\n line: number;\n}\n\n/**\n * Finds the source file and line of a position in a module the browser loaded, or\n * `null` when the module is not the project's own code (a dependency, another\n * origin, an unknown URL).\n */\nexport type FrameResolver = (\n url: string,\n line: number,\n column: number,\n) => Promise<SourcePosition | null>;\n\n/**\n * One entry of the browser log. The fields are the ones `wp foehn errors` prints.\n */\nexport interface BrowserEntry {\n time: string;\n level: \"error\" | \"rejection\" | \"console\";\n class: string;\n message: string;\n file: string | null;\n line: number | null;\n stack: string[];\n}\n\n/**\n * The entry of one forwarded event.\n *\n * An uncaught error or an unhandled rejection gives the frames of the project's own\n * code, mapped back to the source, then the number of other frames. A console call\n * has no stack.\n */\nexport async function browserEntry(\n payload: ForwardConsolePayload,\n resolve: FrameResolver,\n now: Date = new Date(),\n): Promise<BrowserEntry> {\n const time = now.toISOString().replace(/\\.\\d+Z$/, \"Z\");\n\n if (payload.type === \"log\") {\n return {\n time,\n level: \"console\",\n class: `console.${payload.data.level}`,\n message: shorten(payload.data.message),\n file: null,\n line: null,\n stack: [],\n };\n }\n\n const own: string[] = [];\n let first: SourcePosition | null = null;\n let others = 0;\n\n for (const frame of parseStack(payload.data.stack ?? \"\")) {\n const position =\n own.length < MAX_OWN_FRAMES ? await resolve(frame.url, frame.line, frame.column) : null;\n\n if (position === null) {\n others++;\n continue;\n }\n\n first ??= position;\n own.push(`${position.file}:${position.line}${frame.fn === \"\" ? \"\" : ` ${frame.fn}()`}`);\n }\n\n if (others > 0) {\n own.push(`+${others} other ${others === 1 ? \"frame\" : \"frames\"}`);\n }\n\n return {\n time,\n level: payload.type === \"error\" ? \"error\" : \"rejection\",\n class: shorten(payload.data.name),\n message: shorten(payload.data.message),\n file: first?.file ?? null,\n line: first?.line ?? null,\n stack: own,\n };\n}\n\n/**\n * The frames of a stack, as Chromium (`at fn (url:line:column)`) and Firefox or\n * Safari (`fn@url:line:column`) write them. Other lines, such as the message, are\n * skipped.\n */\nexport function parseStack(\n stack: string,\n): Array<{ fn: string; url: string; line: number; column: number }> {\n const frames = [];\n\n for (const text of stack.split(\"\\n\")) {\n const match =\n /^\\s*at\\s+(?:(.*?)\\s+\\()?(.+?):(\\d+):(\\d+)\\)?\\s*$/.exec(text) ??\n /^\\s*(.*?)@(.+?):(\\d+):(\\d+)\\s*$/.exec(text);\n\n if (match) {\n frames.push({\n fn: match[1] ?? \"\",\n url: match[2],\n line: Number(match[3]),\n column: Number(match[4]),\n });\n }\n }\n\n return frames;\n}\n\n/**\n * Add an entry at the end of the log in `directory`. Synchronous, so two events\n * never rotate the files at the same time.\n */\nexport function appendBrowserEntry(directory: string, entry: BrowserEntry): void {\n const line = `${JSON.stringify(entry)}\\n`;\n const file = logFile(directory, 0);\n\n mkdirSync(directory, { recursive: true });\n\n const size = statSync(file, { throwIfNoEntry: false })?.size ?? 0;\n\n if (size > 0 && size + Buffer.byteLength(line) > MAX_BYTES) {\n rmSync(logFile(directory, MAX_FILES - 1), { force: true });\n\n for (let index = MAX_FILES - 2; index >= 0; index--) {\n if (statSync(logFile(directory, index), { throwIfNoEntry: false })) {\n renameSync(logFile(directory, index), logFile(directory, index + 1));\n }\n }\n }\n\n appendFileSync(file, line, \"utf-8\");\n}\n\n/**\n * The path of one file of the log: `browser-errors.jsonl`, then\n * `browser-errors.1.jsonl` and `browser-errors.2.jsonl`.\n */\nexport function logFile(directory: string, index: number): string {\n return join(directory, `${BROWSER_LOG}${index === 0 ? \"\" : `.${index}`}.jsonl`);\n}\n\nfunction shorten(text: string): string {\n return text.length > MAX_MESSAGE ? `${text.slice(0, MAX_MESSAGE)}…` : text;\n}\n","import { statSync } from \"node:fs\";\nimport type { IncomingMessage } from \"node:http\";\nimport type { AddressInfo } from \"node:net\";\nimport { constants } from \"node:os\";\nimport { isAbsolute, join, relative, resolve } from \"node:path\";\nimport { originalPositionFor, TraceMap, type SourceMapInput } from \"@jridgewell/trace-mapping\";\nimport type { DevEnvironment, Plugin, ResolvedConfig, ViteDevServer } from \"vite\";\nimport type { FoehnPluginOptions, ResolvedFoehnPluginOptions } from \"./options.js\";\nimport { resolveOptions } from \"./options.js\";\nimport {\n resolveGlobPatterns,\n detectDdev,\n getDdevSiteUrl,\n writeHotFile,\n removeHotFile,\n appendBrowserEntry,\n browserEntry,\n type ForwardConsolePayload,\n type SourcePosition,\n} from \"./utils/index.js\";\n\n/**\n * The origins Vite allows by default (`defaultAllowedOrigins`, exported by Vite\n * 6.0.9 and later only).\n */\nconst LOCALHOST_ORIGINS = /^https?:\\/\\/(?:(?:[^:]+\\.)?localhost|127\\.0\\.0\\.1|\\[::1\\])(?::\\d+)?$/;\n\n/** Signals that end the process without Vite closing the server first. */\nconst EXIT_SIGNALS = [\"SIGINT\", \"SIGHUP\"] as const;\n\n/**\n * Creates the Føhn Vite plugin.\n */\nexport function foehn(options: FoehnPluginOptions): Plugin[] {\n const resolvedOptions = resolveOptions(options);\n const outDir = resolve(resolvedOptions.themeDir, resolvedOptions.outDir);\n // Inside the build output, where `ViteManifest` looks for it.\n const hotPath = resolve(outDir, resolvedOptions.hotFile);\n let config: ResolvedConfig;\n\n const mainPlugin: Plugin = {\n name: \"foehn\",\n enforce: \"pre\",\n\n async config(userConfig, { command }) {\n const entries = await resolveGlobPatterns(\n resolvedOptions.input,\n resolvedOptions.themeDir,\n );\n\n // Detect DDEV for proxy configuration\n const ddevConfig = await detectDdev(resolvedOptions.themeDir);\n const proxyTarget = ddevConfig ? getDdevSiteUrl(ddevConfig) : undefined;\n\n return {\n // WordPress serves the build from the theme, not from the site root. A\n // relative base makes Vite load the chunks of a dynamic import, and their\n // `modulepreload` hints, from the URL of the bundle that imports them.\n // `ViteManifest` builds the URLs of the entries itself.\n base: userConfig.base ?? (command === \"build\" ? \"./\" : undefined),\n build: {\n manifest: true,\n outDir,\n rollupOptions: {\n input: entries,\n },\n },\n server: {\n // Vite 8 turns it on only when it runs inside a coding agent. On,\n // the page sends its console errors and uncaught errors to the\n // server, which writes them to the browser log for any agent.\n forwardConsole: userConfig.server?.forwardConsole ?? true,\n // A page opened on the DDEV URL loads `/@vite/client` from the dev\n // server, which Vite allows only for localhost pages by default.\n cors:\n userConfig.server?.cors ??\n (proxyTarget\n ? { origin: [LOCALHOST_ORIGINS, new URL(proxyTarget).origin] }\n : undefined),\n proxy: proxyTarget\n ? {\n // Vite answers what it can serve, DDEV the rest\n \"/\": {\n target: proxyTarget,\n changeOrigin: true,\n secure: false,\n bypass: (req) =>\n isServedByVite(req, config) ? req.url : undefined,\n },\n }\n : undefined,\n },\n };\n },\n\n configResolved(resolvedConfig) {\n config = resolvedConfig;\n },\n\n configureServer(server: ViteDevServer) {\n // Beside the hot file, where `wp foehn errors --browser` reads it\n const client = server.environments.client;\n client.hot.on(\"vite:forward-console\", (payload: ForwardConsolePayload) => {\n browserEntry(payload, (url, line, column) =>\n findSource(client, config.root, url, line, column),\n )\n .then((entry) => appendBrowserEntry(outDir, entry))\n .catch((error: Error) =>\n config.logger.warn(\n `[foehn] Cannot write the browser log: ${error.message}`,\n ),\n );\n });\n\n const httpServer = server.httpServer;\n if (!httpServer) {\n return;\n }\n\n // Write hot file when server starts, with the address it listens on\n httpServer.once(\"listening\", async () => {\n const address = httpServer.address();\n if (typeof address === \"object\" && address) {\n await writeHotFile(hotPath, getServerUrl(address, config));\n }\n });\n\n // Vite closes the server on SIGTERM only. Ctrl+C (SIGINT) and a\n // closed terminal (SIGHUP) kill the process, and a hot file left\n // behind points every WordPress page at a dead server.\n const onSignal = (signal: NodeJS.Signals) => {\n removeHotFile(hotPath);\n process.exit(128 + constants.signals[signal]);\n };\n for (const signal of EXIT_SIGNALS) {\n process.on(signal, onSignal);\n }\n\n // Remove hot file when server closes\n httpServer.on(\"close\", () => {\n removeHotFile(hotPath);\n for (const signal of EXIT_SIGNALS) {\n process.off(signal, onSignal);\n }\n });\n },\n\n buildEnd() {\n // Ensure hot file is removed after build\n if (config.command === \"build\") {\n removeHotFile(hotPath);\n }\n },\n };\n\n // Separate plugin for file watching (full reload)\n const reloadPlugin = createReloadPlugin(resolvedOptions);\n\n return [mainPlugin, reloadPlugin];\n}\n\n/**\n * Creates a plugin that watches files for full reload.\n */\nfunction createReloadPlugin(options: ResolvedFoehnPluginOptions): Plugin {\n return {\n name: \"foehn:reload\",\n\n configureServer(server: ViteDevServer) {\n // Watch files for full reload\n for (const pattern of options.reload) {\n const fullPattern = resolve(options.themeDir, pattern);\n server.watcher.add(fullPattern);\n }\n\n server.watcher.on(\"change\", (file) => {\n // Check if the changed file matches any reload pattern\n const shouldReload = options.reload.some((pattern) => {\n const fullPattern = resolve(options.themeDir, pattern);\n return matchPattern(file, fullPattern);\n });\n\n if (shouldReload) {\n server.ws.send({ type: \"full-reload\" });\n }\n });\n },\n };\n}\n\n/**\n * Simple pattern matching for file paths.\n */\nfunction matchPattern(file: string, pattern: string): boolean {\n // Convert glob pattern to regex\n const regexPattern = pattern\n .replace(/\\*\\*/g, \"<<<GLOBSTAR>>>\")\n .replace(/\\*/g, \"[^/]*\")\n .replace(/<<<GLOBSTAR>>>/g, \".*\")\n .replace(/\\?/g, \".\");\n\n return new RegExp(`^${regexPattern}$`).test(file);\n}\n\n/**\n * Whether the dev server answers a request itself: its internal routes\n * (`/@vite/client`, `/@fs/`, `/@id/`, `/__open-in-editor`), dependencies, the\n * HMR ping, and every file under the root or the public directory, whatever\n * the query (`?import`, `?direct`, `?v=`).\n */\nfunction isServedByVite(req: IncomingMessage, config: ResolvedConfig): boolean {\n if (req.headers.accept === \"text/x-vite-ping\") {\n return true;\n }\n\n let path: string;\n try {\n path = decodeURIComponent((req.url ?? \"/\").split(/[?#]/)[0]);\n } catch {\n // A malformed URL is not a module, let WordPress answer it\n return false;\n }\n\n if (path.startsWith(\"/@\") || path.startsWith(\"/__\") || path.startsWith(\"/node_modules/\")) {\n return true;\n }\n\n return [config.root, config.publicDir].some(\n (dir) => dir !== \"\" && statSync(join(dir, path), { throwIfNoEntry: false })?.isFile(),\n );\n}\n\n/**\n * The place in the project's source of a position in a module the browser loaded:\n * the module's file relative to the Vite root, and the line mapped back through\n * the module's source map (TypeScript, JSX and Vue change the line numbers).\n * `null` for a module of a dependency, a URL of another server, or a module the\n * dev server has not served.\n */\nasync function findSource(\n environment: DevEnvironment,\n root: string,\n url: string,\n line: number,\n column: number,\n): Promise<SourcePosition | null> {\n let path: string;\n try {\n // With the query: a Vue block (`?vue&type=script`) is a module of its own.\n // Vite drops the `?t=` of a hot update and the `?import` itself.\n const parsed = new URL(url);\n path = decodeURIComponent(parsed.pathname) + parsed.search;\n } catch {\n return null;\n }\n\n const module = await environment.moduleGraph.getModuleByUrl(path);\n const file = module?.file ? relative(root, module.file) : \"\";\n\n if (file === \"\" || file.startsWith(\"..\") || isAbsolute(file) || file.includes(\"node_modules\")) {\n return null;\n }\n\n const map = module?.transformResult?.map;\n\n if (map && map.mappings !== \"\") {\n const original = originalPositionFor(new TraceMap(map as SourceMapInput), {\n line,\n column: Math.max(column - 1, 0),\n });\n\n if (original.line !== null) {\n return { file, line: original.line };\n }\n }\n\n return { file, line };\n}\n\n/**\n * Get the URL a browser reaches the dev server at.\n */\nfunction getServerUrl(address: AddressInfo, config: ResolvedConfig): string {\n const protocol = config.server.https ? \"https\" : \"http\";\n const host = [\"::\", \"0.0.0.0\", \"::1\", \"127.0.0.1\"].includes(address.address)\n ? \"localhost\"\n : address.family === \"IPv6\"\n ? `[${address.address}]`\n : address.address;\n return `${protocol}://${host}:${address.port}`;\n}\n"],"mappings":";;;;;;;;;;AAmDA,IAAa,iBAA4D;CACrE,QAAQ,CAAC,qBAAqB;CAC9B,QAAQ;CACR,UAAU,QAAQ,IAAI;CACtB,SAAS;AACb;;;;AAKA,SAAgB,eAAe,SAAyD;CASpF,OAAO;EACH,OATU,MAAM,QAAQ,QAAQ,KAAK,IAAI,QAAQ,QAAQ,CAAC,QAAQ,KAAK;EAUvE,QARW,QAAQ,SACjB,MAAM,QAAQ,QAAQ,MAAM,IACxB,QAAQ,SACR,CAAC,QAAQ,MAAM,IACnB,eAAe;EAKjB,QAAQ,QAAQ,UAAU,eAAe;EACzC,UAAU,QAAQ,YAAY,eAAe;EAC7C,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