@vrowzer/vite-plugin 0.1.1 → 0.1.3

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.
Files changed (27) hide show
  1. package/README.md +77 -7
  2. package/dist/ide/assets/{css.worker-CTXDGAqi.js → css.worker-B3bjHA4E.js} +12 -12
  3. package/dist/ide/assets/{html.worker-DoEWTywB.js → html.worker-CdKyo4PJ.js} +15 -15
  4. package/dist/ide/assets/json.worker-Dv30RK47.js +58 -0
  5. package/dist/ide/assets/{ts.worker-CEDDf2SQ.js → ts.worker-BMQFrgtp.js} +43 -43
  6. package/dist/ide/{cssMode-Bx4pwP7t.js → cssMode-BjT8Ilz9.js} +6 -6
  7. package/dist/ide/{handlebars-niagtI6v.js → handlebars-D8oWedcX.js} +1 -1
  8. package/dist/ide/{html-vu3rIOlL.js → html-BtI1mgAb.js} +1 -1
  9. package/dist/ide/{htmlMode-DJyFRqKm.js → htmlMode-nJv21bwP.js} +6 -6
  10. package/dist/ide/ide.js +1018 -1013
  11. package/dist/ide/{javascript-BaiNOEh_.js → javascript-CsLyoDyq.js} +1 -1
  12. package/dist/ide/{jsonMode-DLQ0j1a3.js → jsonMode-Gp85lTwz.js} +26 -25
  13. package/dist/ide/{lspLanguageFeatures-CY50NMcK.js → lspLanguageFeatures-Bh3u5Duz.js} +4 -4
  14. package/dist/ide/{mdx-DhZSVASO.js → mdx-BXUwpKml.js} +1 -1
  15. package/dist/ide/{monaco.contribution-4V6BrQ5P.js → monaco.contribution-Df9Y1epv.js} +2 -2
  16. package/dist/ide/{toggleHighContrast-DzGcs4Kw.js → toggleHighContrast-BAyJBPWB.js} +11852 -11696
  17. package/dist/ide/{tsMode-D6r_-_rM.js → tsMode-DW5hjWiU.js} +4 -4
  18. package/dist/ide/{typescript-DM2pFj0X.js → typescript-DdUYzFye.js} +1 -1
  19. package/dist/ide/{workers-DRkYqOHL.js → workers-_EnUbIXZ.js} +1 -1
  20. package/dist/ide/{xml-DrNRTdma.js → xml-YkclMbCx.js} +1 -1
  21. package/dist/ide/{yaml-ck2FlP6B.js → yaml-nzDq4-PC.js} +1 -1
  22. package/dist/index.d.mts +7 -2
  23. package/dist/index.d.mts.map +1 -1
  24. package/dist/index.mjs +69 -27
  25. package/dist/index.mjs.map +1 -1
  26. package/package.json +12 -12
  27. package/dist/ide/assets/json.worker-C4xqSSAJ.js +0 -58
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["debug","MINIFIABLE_EXTENSIONS","debug","debug","debug","debug","nodeCreateRequire","debug","debug","debug"],"sources":["../src/auto-manifest.ts","../src/alias.ts","../src/env.ts","../src/ide.ts","../src/extract.ts","../src/options.ts","../src/prebundle.ts","../src/rolldown.ts","../src/server.ts","../src/virtual.ts","../src/manifest.ts","../src/index.ts"],"sourcesContent":["/**\n * Auto-manifest plugin for Vrowzer.\n *\n * When `auto: true`, this plugin:\n * 1. Auto-generates the vrowzer manifest in `configResolved`\n * 2. Caches results in `node_modules/.vrowzer-manifest/`\n * 3. Provides the manifest via `virtual:vrowzer-manifest` virtual module\n *\n * @module auto-manifest\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs'\nimport { extname, join, resolve } from 'node:path'\nimport { minifySync } from 'rolldown/utils'\nimport { createDebug } from 'obug'\nimport { generateManifest } from './manifest-generate.ts'\n\nimport type { Plugin, ResolvedConfig } from 'vite'\nimport type { ManifestResult } from './manifest-generate.ts'\nimport type { VrowzerManifestOptions } from './options.ts'\n\nconst debug = createDebug('vite-plugin-vrowzer:auto-manifest')\n\nconst VIRTUAL_MODULE_ID = 'virtual:vrowzer-manifest'\nconst RESOLVED_VIRTUAL_MODULE_ID = '\\0' + VIRTUAL_MODULE_ID\n\nconst CACHE_DIR_NAME = '.vrowzer-manifest'\nconst MANIFEST_FILENAME = 'manifest.json'\nconst HASH_FILENAME = '_hash'\n\nconst LOCKFILE_NAMES = ['pnpm-lock.yaml', 'package-lock.json', 'yarn.lock', 'bun.lock']\n\nconst MINIFIABLE_EXTENSIONS = new Set(['.js', '.mjs', '.cjs'])\n\n/**\n * Simple 32-bit string hash (same algorithm as unplugin-service-worker hash).\n */\nfunction hash(input: string): string {\n let h = 0\n for (let i = 0; i < input.length; i++) {\n const char = input.charCodeAt(i)\n h = (h << 5) - h + char\n h = h & h\n }\n return Math.abs(h).toString(36).slice(0, 8)\n}\n\n/**\n * Compute cache key from package.json dependencies, lockfile, and manifest options.\n */\nfunction computeCacheHash(root: string, manifestOptions?: VrowzerManifestOptions): string {\n const parts: string[] = []\n\n // Include sourceDir in cache key so changes to it invalidate the cache\n if (manifestOptions?.sourceDir) {\n parts.push(`sourceDir:${manifestOptions.sourceDir}`)\n }\n if (manifestOptions?.targets) {\n parts.push(`targets:${manifestOptions.targets.join(',')}`)\n }\n\n // Read package.json deps\n const pkgPath = join(root, 'package.json')\n if (existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))\n parts.push(JSON.stringify(pkg.dependencies || {}))\n parts.push(JSON.stringify(pkg.devDependencies || {}))\n } catch {\n // ignore\n }\n }\n\n // Read lockfile\n for (const lockfile of LOCKFILE_NAMES) {\n const lockPath = join(root, lockfile)\n if (existsSync(lockPath)) {\n try {\n parts.push(readFileSync(lockPath, 'utf-8'))\n } catch {\n // ignore\n }\n break\n }\n }\n\n return hash(parts.join('\\n'))\n}\n\nfunction getCacheDir(root: string): string {\n return resolve(root, 'node_modules', CACHE_DIR_NAME)\n}\n\nfunction readCachedHash(cacheDir: string): string | null {\n const hashPath = join(cacheDir, HASH_FILENAME)\n if (existsSync(hashPath)) {\n try {\n return readFileSync(hashPath, 'utf-8').trim()\n } catch {\n return null\n }\n }\n return null\n}\n\nfunction readCachedManifest(cacheDir: string): ManifestResult | null {\n const manifestPath = join(cacheDir, MANIFEST_FILENAME)\n if (existsSync(manifestPath)) {\n try {\n return JSON.parse(readFileSync(manifestPath, 'utf-8'))\n } catch {\n return null\n }\n }\n return null\n}\n\nfunction writeCache(cacheDir: string, manifest: ManifestResult, cacheHash: string): void {\n mkdirSync(cacheDir, { recursive: true })\n writeFileSync(join(cacheDir, MANIFEST_FILENAME), JSON.stringify(manifest, null, 2) + '\\n')\n writeFileSync(join(cacheDir, HASH_FILENAME), cacheHash + '\\n')\n}\n\n/**\n * Resolve manifest path references to actual file contents.\n * This is equivalent to what VrowzerManifest() does for manual manifests.\n */\nfunction resolveManifestContents(\n manifest: ManifestResult,\n manifestDir: string\n): Record<string, any> {\n function resolveFiles(\n files: Record<string, string> | undefined,\n minify: boolean\n ): Record<string, string> {\n if (!files) {\n return {}\n }\n const resolved: Record<string, string> = {}\n for (const [virtualPath, relPath] of Object.entries(files)) {\n try {\n let content = readFileSync(resolve(manifestDir, relPath), 'utf-8')\n if (minify && MINIFIABLE_EXTENSIONS.has(extname(virtualPath))) {\n const result = minifySync(virtualPath, content)\n if (result.code) {\n content = result.code\n }\n }\n resolved[virtualPath] = content\n } catch {\n debug('failed to read %s', relPath)\n }\n }\n return resolved\n }\n\n return {\n name: manifest.name,\n files: resolveFiles(manifest.files, false),\n nodeModules: resolveFiles(manifest.nodeModules, true),\n activeFile: manifest.activeFile\n }\n}\n\n/**\n * Create the auto-manifest plugin.\n *\n * This plugin is included in the `Vrowzer()` array when `auto: true`.\n */\nexport function autoManifestPlugin(manifestOptions?: VrowzerManifestOptions): Plugin {\n let sourceDir: string\n let manifest: ManifestResult | null = null\n\n return {\n name: 'vrowzer:auto-manifest',\n resolveId(id) {\n if (id === VIRTUAL_MODULE_ID) {\n return RESOLVED_VIRTUAL_MODULE_ID\n }\n },\n async configResolved(config: ResolvedConfig) {\n const root = config.root\n sourceDir = manifestOptions?.sourceDir ? resolve(root, manifestOptions.sourceDir) : root\n const pkgDir = manifestOptions?.pkgDir ? resolve(root, manifestOptions.pkgDir) : root\n\n const cacheDir = getCacheDir(root)\n const currentHash = computeCacheHash(pkgDir, manifestOptions)\n const cachedHash = readCachedHash(cacheDir)\n\n if (currentHash === cachedHash) {\n // Cache hit\n manifest = readCachedManifest(cacheDir)\n if (manifest) {\n debug('cache hit (hash: %s), using cached manifest', currentHash)\n return\n }\n }\n\n // Cache miss — generate manifest\n debug('cache miss (current: %s, cached: %s), generating manifest...', currentHash, cachedHash)\n\n manifest = await generateManifest(\n {\n pkgDir,\n sourceDir,\n ...(manifestOptions?.targets ? { targets: manifestOptions.targets } : {})\n },\n msg => debug(msg)\n )\n\n // Write cache\n writeCache(cacheDir, manifest, currentHash)\n debug('manifest cached to %s', cacheDir)\n },\n load(id) {\n if (id !== RESOLVED_VIRTUAL_MODULE_ID) {\n return\n }\n\n if (!manifest) {\n debug('no manifest available')\n return { code: 'export default {}', moduleType: 'js' }\n }\n\n // Resolve path references to actual file contents\n // Use the manifest dir (cache dir) as the base for path resolution,\n // but since paths in the manifest are relative to sourceDir (= projectRoot),\n // we use projectRoot as the base.\n const resolved = resolveManifestContents(manifest, sourceDir)\n\n debug(\n 'virtual module loaded: %s (%d files, %d nodeModules)',\n resolved.name,\n Object.keys(resolved.files).length,\n Object.keys(resolved.nodeModules || {}).length\n )\n\n return {\n code: `export default ${JSON.stringify(resolved)}`,\n moduleType: 'js'\n }\n }\n }\n}\n","/**\n * Node.js builtin → browser polyfill alias mappings.\n *\n * Shared between env.ts (host Vite config) and prebundle.ts (Worker config bundling).\n *\n * @module alias\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\n/**\n * Node.js builtin module → browser polyfill mapping.\n * Each entry maps both `node:xxx` and bare `xxx` specifiers.\n */\nconst NODE_POLYFILL_MAP: Record<string, string> = {\n events: '@vrowzer/node-polyfill/events',\n path: 'pathe',\n stream: 'readable-stream/lib/stream',\n buffer: 'buffer',\n dns: '@vrowzer/node-polyfill/dns',\n fs: '@vrowzer/fs',\n 'fs/promises': '@vrowzer/fs/promises',\n url: '@vrowzer/node-polyfill/url',\n readline: '@vrowzer/node-polyfill/readline',\n util: '@vrowzer/node-polyfill/util',\n perf_hooks: '@vrowzer/node-polyfill/perf_hooks',\n crypto: '@vrowzer/node-polyfill/crypto',\n tty: '@vrowzer/node-polyfill/tty',\n module: '@vrowzer/node-polyfill/module',\n os: '@vrowzer/node-polyfill/os',\n net: '@vrowzer/node-polyfill/net'\n}\n\n/**\n * Build a flat alias record from NODE_POLYFILL_MAP + additional aliases.\n * Generates both `node:xxx` and bare `xxx` entries for each builtin.\n *\n * @param extra - Additional alias entries to merge (e.g. `{ process: '...', 'process/': '...' }`)\n */\nexport function resolveAliases(extra?: Record<string, string>): Record<string, string> {\n const aliases: Record<string, string> = {}\n for (const [mod, polyfill] of Object.entries(NODE_POLYFILL_MAP)) {\n aliases[`node:${mod}`] = polyfill\n aliases[mod] = polyfill\n }\n if (extra) {\n Object.assign(aliases, extra)\n }\n return aliases\n}\n","/**\n * Environment plugin — Node.js polyfills, CORS headers, and Worker config\n * for browser/Worker environments.\n *\n * @module env\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { dirname, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { createDebug } from 'obug'\nimport { resolveAliases } from './alias.ts'\n\nimport type { Plugin } from 'vite'\nimport type { ResolvedVrowzerOptions } from './options.ts'\n\nconst debug = createDebug('vite-plugin-vrowzer:env')\n\n// Resolve picocolors browser version path.\n// picocolors doesn't export the browser file via package.json exports,\n// so we resolve its entry point and construct the path.\nconst picocolorsBrowser = resolve(\n dirname(fileURLToPath(import.meta.resolve('picocolors'))),\n 'picocolors.browser.js'\n)\n\nexport function envPlugin(_options: ResolvedVrowzerOptions): Plugin {\n return {\n name: 'vrowzer:env',\n // Rolldown native inject: inject `process` global for browser/Worker environments.\n // This replaces bare `process` references with an import from the polyfill.\n options(inputOptions) {\n inputOptions.transform ??= {}\n ;(inputOptions.transform as Record<string, unknown>).inject = {\n ...(((inputOptions.transform as Record<string, unknown>).inject as Record<\n string,\n string\n >) ?? {}),\n process: '@vrowzer/node-polyfill/process'\n }\n debug('options hook: inputOptions.transform.inject ', inputOptions.transform.inject)\n },\n config(_config, _env) {\n return {\n define: {\n 'import.meta.env.DEBUG': JSON.stringify(process.env.DEBUG || '')\n },\n resolve: {\n alias: resolveAliases({\n // process needs both bare and trailing-slash aliases\n // (`require('process/')` in readable-stream/lib/internal/streams/pipeline.js)\n 'node:process': '@vrowzer/node-polyfill/process',\n 'process/': '@vrowzer/node-polyfill/process',\n process: '@vrowzer/node-polyfill/process',\n // picocolors CJS → browser version (no ANSI codes in Worker/SW)\n picocolors: picocolorsBrowser\n })\n },\n worker: {\n format: 'es'\n },\n server: {\n headers: {\n 'Service-Worker-Allowed': '/',\n 'Cross-Origin-Opener-Policy': 'same-origin',\n 'Cross-Origin-Embedder-Policy': 'credentialless'\n }\n },\n preview: {\n headers: {\n 'Service-Worker-Allowed': '/',\n 'Cross-Origin-Opener-Policy': 'same-origin',\n 'Cross-Origin-Embedder-Policy': 'credentialless'\n }\n }\n }\n }\n }\n}\n","/**\n * Browser IDE plugin for Vrowzer.\n *\n * When `experimental.ide` is enabled, serves a pre-built browser IDE at `/__vrowzer__/`.\n * The IDE is a self-contained Vue app with Monaco Editor, File Explorer, and Preview,\n * bundled into dist/ide/ at build time.\n *\n * Phase 3: birpc WebSocket for file sync (write-back to local FS).\n *\n * @module ide\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { dirname, extname, join, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { createBirpc } from 'birpc'\nimport { createDebug } from 'obug'\nimport { WebSocketServer } from 'ws'\n\nimport type { IncomingMessage, ServerResponse } from 'node:http'\nimport type { Plugin, ViteDevServer } from 'vite'\nimport type { WebSocket } from 'ws'\nimport type { ResolvedVrowzerOptions } from './options.ts'\nimport type { ClientFunctions, ServerFunctions } from './ide/rpc.ts'\n\nconst debug = createDebug('vite-plugin-vrowzer:ide')\n\nconst IDE_BASE = '/__vrowzer__'\nconst IDE_CLIENT_PATH = `${IDE_BASE}/client.js`\n\n// Resolve path to dist/ide/ directory (pre-built IDE assets)\nconst __dir = dirname(fileURLToPath(import.meta.url))\nconst ideDistDir = resolve(__dir, __dir.endsWith('/dist') ? 'ide' : '../dist/ide')\n\nconst MIME_TYPES: Record<string, string> = {\n '.js': 'application/javascript',\n '.mjs': 'application/javascript',\n '.css': 'text/css',\n '.html': 'text/html',\n '.json': 'application/json',\n '.svg': 'image/svg+xml',\n '.png': 'image/png',\n '.woff': 'font/woff',\n '.woff2': 'font/woff2',\n '.ttf': 'font/ttf'\n}\n\nfunction generateIdeClientCode(\n basePath: string,\n rpcPort: number,\n devtoolsUrl: string | null\n): string {\n return `\nimport { Vrowzer } from 'vrowzer'\nimport manifest from 'virtual:vrowzer-manifest'\n\n// mountIde is loaded via script tag in HTML and exposed as global\nwindow.__vrowzer_ide_mount__({\n manifest,\n basePath: '${basePath}',\n Vrowzer,\n rpcPort: ${rpcPort},\n devtoolsUrl: ${devtoolsUrl ? `'${devtoolsUrl}'` : 'null'}\n})\n`\n}\n\nfunction generateIdeHtml(base: string, cssFile: string | null): string {\n const cssLink = cssFile\n ? `<link rel=\"stylesheet\" href=\"${base}${IDE_BASE.slice(1)}/dist/${cssFile}\" />`\n : ''\n\n return `<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Vrowzer IDE</title>\n ${cssLink}\n <style>\n * { margin: 0; padding: 0; box-sizing: border-box; }\n html, body, #app { height: 100%; }\n body { font-family: system-ui, -apple-system, sans-serif; overflow: hidden; }\n </style>\n</head>\n<body>\n <div id=\"app\"></div>\n <script type=\"module\" src=\"${base}${IDE_BASE.slice(1)}/dist/ide.js\"></script>\n <script type=\"module\" src=\"${base}${IDE_BASE.slice(1)}/client.js\"></script>\n</body>\n</html>`\n}\n\nfunction findAvailablePort(preferredPort?: number): Promise<number> {\n return new Promise((resolve, reject) => {\n const { createServer } = require('node:net') as typeof import('node:net')\n const server = createServer()\n const port = preferredPort ?? 7900\n server.listen(port, () => {\n server.close(() => resolve(port))\n })\n server.on('error', () => {\n // Port in use, try next\n server.close()\n const next = createServer()\n next.listen(0, () => {\n const addr = next.address()\n const p = typeof addr === 'object' && addr ? addr.port : 0\n next.close(() => resolve(p))\n })\n next.on('error', reject)\n })\n })\n}\n\nexport function idePlugin(options: ResolvedVrowzerOptions): Plugin {\n let viteBase = '/'\n let ideCssFile: string | null = null\n let rpcPort = 0\n let projectRoot = ''\n let sourceDir = ''\n let devtoolsUrl: string | null = null\n\n // Find the CSS file in dist/ide/\n if (existsSync(ideDistDir)) {\n try {\n const files = readdirSync(ideDistDir)\n ideCssFile = files.find(f => f.endsWith('.css')) ?? null\n } catch {\n // ignore\n }\n }\n\n return {\n name: 'vrowzer:ide',\n apply: 'serve',\n async configResolved(config) {\n viteBase = config.base || '/'\n projectRoot = config.root\n sourceDir = options.manifest?.sourceDir\n ? resolve(projectRoot, options.manifest.sourceDir)\n : projectRoot\n\n // Find available port for birpc WebSocket\n rpcPort = await findAvailablePort(options.ide.port)\n debug('RPC port:', rpcPort)\n\n // Detect DevTools plugin\n if (options.ide.devtools) {\n const hasDevTools = config.plugins.some((p: any) => p.name === 'vite:devtools:server')\n if (hasDevTools) {\n devtoolsUrl = '/.devtools/'\n debug('DevTools detected, URL:', devtoolsUrl)\n }\n }\n },\n resolveId(id) {\n if (id === IDE_CLIENT_PATH) {\n return id\n }\n },\n load(id) {\n if (id === IDE_CLIENT_PATH) {\n return generateIdeClientCode(options.basePath, rpcPort, devtoolsUrl)\n }\n },\n configureServer(server: ViteDevServer) {\n const ideUrl = `${IDE_BASE}/`\n\n // --- COEP headers for DevTools iframe ---\n // DevTools serves at /.devtools/, /.devtools-rolldown/, /.devtools-vite/, etc.\n if (devtoolsUrl) {\n server.middlewares.use((req: any, res: any, next: any) => {\n const url = req.url ?? ''\n if (url.startsWith('/.devtools')) {\n const originalWriteHead = res.writeHead.bind(res)\n res.writeHead = function (statusCode: number, ...args: any[]) {\n res.setHeader('Cross-Origin-Embedder-Policy', 'credentialless')\n res.setHeader('Cross-Origin-Opener-Policy', 'same-origin')\n return originalWriteHead(statusCode, ...args)\n } as typeof res.writeHead\n }\n next()\n })\n debug('COEP middleware added for /.devtools*')\n }\n\n // --- birpc WebSocket server ---\n const wss = new WebSocketServer({ port: rpcPort })\n debug('birpc WebSocket server listening on port', rpcPort)\n\n wss.on('connection', (ws: WebSocket) => {\n debug('IDE client connected')\n\n const rpc = createBirpc<ClientFunctions, ServerFunctions>(\n {\n async writeFile(path: string, content: string) {\n const absPath = resolve(sourceDir, path.startsWith('/') ? path.slice(1) : path)\n debug('writeFile:', absPath)\n writeFileSync(absPath, content, 'utf-8')\n }\n },\n {\n post: data => ws.send(data),\n on: handler => ws.on('message', handler),\n serialize: v => JSON.stringify(v),\n deserialize: v => JSON.parse(String(v))\n }\n )\n\n // Watch for file changes from external editors (chokidar via Vite's watcher)\n const watcher = server.watcher\n const onFileChange = (filePath: string) => {\n // Only notify for source files within sourceDir, not node_modules\n if (filePath.startsWith(sourceDir) && !filePath.includes('node_modules')) {\n const relPath = '/' + filePath.slice(sourceDir.length + 1).replace(/\\\\/g, '/')\n try {\n const content = readFileSync(filePath, 'utf-8')\n debug('external file change:', relPath)\n rpc.onFileChanged(relPath, content)\n } catch {\n // file might have been deleted\n }\n }\n }\n\n watcher.on('change', onFileChange)\n\n ws.on('close', () => {\n debug('IDE client disconnected')\n watcher.off('change', onFileChange)\n })\n })\n\n // Clean up WebSocket server when Vite server closes\n server.httpServer?.on('close', () => {\n wss.close()\n debug('birpc WebSocket server closed')\n })\n\n // Print IDE URL after server start\n server.httpServer?.once('listening', () => {\n const info = server.config.server\n const protocol = info.https ? 'https' : 'http'\n const host = typeof info.host === 'string' ? info.host : 'localhost'\n const port = info.port || 5173\n setTimeout(() => {\n server.config.logger.info(\n ` \\x1b[36m➜\\x1b[0m \\x1b[1mVrowzer IDE\\x1b[0m: \\x1b[36m${protocol}://${host}:${port}${ideUrl}\\x1b[0m`\n )\n }, 100)\n })\n\n // Serve IDE at /__vrowzer__/\n server.middlewares.use((req: IncomingMessage, res: ServerResponse, next: () => void) => {\n const url = req.url ?? ''\n\n // Serve IDE HTML\n if (url === IDE_BASE || url === ideUrl) {\n debug('serving IDE HTML')\n res.writeHead(200, {\n 'Content-Type': 'text/html; charset=utf-8',\n 'Cross-Origin-Opener-Policy': 'same-origin',\n 'Cross-Origin-Embedder-Policy': 'credentialless'\n })\n res.end(generateIdeHtml(viteBase, ideCssFile))\n return\n }\n\n // Serve IDE static assets from dist/ide/\n if (url.startsWith(`${IDE_BASE}/dist/`)) {\n const assetName = url.slice(`${IDE_BASE}/dist/`.length)\n const assetPath = join(ideDistDir, assetName)\n\n if (existsSync(assetPath)) {\n const ext = extname(assetName)\n const mime = MIME_TYPES[ext] || 'application/octet-stream'\n debug('serving IDE asset:', assetName)\n res.writeHead(200, {\n 'Content-Type': mime,\n 'Cross-Origin-Opener-Policy': 'same-origin',\n 'Cross-Origin-Embedder-Policy': 'credentialless',\n 'Cache-Control': 'no-cache'\n })\n res.end(readFileSync(assetPath))\n return\n }\n }\n\n next()\n })\n }\n }\n}\n","/**\n * Static analysis of vite.config.ts for Worker plugin extraction.\n *\n * Parses the user's vite.config.ts with OXC (via rolldown/experimental),\n * removes Vrowzer() calls and their imports,\n * and generates a Worker-compatible config source.\n *\n * @module extract\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { parseSync } from 'rolldown/utils'\nimport { createDebug } from 'obug'\n\nimport type {\n ArrayExpression,\n CallExpression,\n ExportDefaultDeclaration,\n Expression,\n ImportDeclaration,\n ObjectExpression,\n ObjectProperty,\n Program\n} from '@oxc-project/types'\n\nconst debug = createDebug('vite-plugin-vrowzer:extract')\n\nexport interface ExtractOptions {\n /** Resolved server origin to forward to the Worker config. */\n serverOrigin?: string | undefined\n /** Host-resolved forward-console options to forward to the Worker config. */\n serverForwardConsole?:\n | {\n enabled: boolean\n unhandledErrors: boolean\n logLevels: readonly string[]\n }\n | undefined\n}\n\nexport interface ExtractResult {\n code: string\n unsupported: string[]\n}\n\ninterface PluginCallInfo {\n calleeName: string\n importSource: string | null\n start: number\n end: number\n hasArgs: boolean\n}\n\ninterface ImportInfo {\n source: string\n localName: string\n importedName: string | null // null = default, '*' = namespace\n start: number\n end: number\n isTypeOnly: boolean\n}\n\n/**\n * Packages that should be excluded from Worker config.\n * These are host-only plugins that cannot run in Web Worker.\n */\nconst WORKER_EXCLUDED_SOURCES = [\n '@vrowzer/vite-plugin',\n '@vrowzer/vite-plugin/config',\n '@vitejs/devtools'\n]\n\n/**\n * Check if an import source should be excluded from Worker config.\n */\nexport function isWorkerExcludedImport(source: string): boolean {\n return WORKER_EXCLUDED_SOURCES.some(s => source === s || source.startsWith(`${s}/`))\n}\n\n/**\n * Check if an import source is from Vite (should be excluded from Worker config).\n */\nfunction isViteImport(source: string): boolean {\n return source === 'vite' || source.startsWith('vite/')\n}\n\n/**\n * Extract Worker config source from vite.config.ts.\n *\n * 1. Parse the source with OXC\n * 2. Collect all imports\n * 3. Find `export default defineConfig(...)` or `export default { ... }`\n * 4. Extract plugins array\n * 5. Remove Vrowzer() calls\n * 6. Generate Worker config source\n */\nexport function extractWorkerConfig(\n source: string,\n configPath: string,\n options: ExtractOptions = {}\n): ExtractResult {\n const unsupported: string[] = []\n\n const result = parseSync(configPath, source)\n const ast = result.program as Program\n\n // 1. Collect imports\n const imports = collectImports(ast)\n debug(\n 'imports',\n imports.map(i => `${i.localName} from ${i.source}`)\n )\n\n // 2. Find export default\n const exportDefault = ast.body.find(\n (n): n is ExportDefaultDeclaration => n.type === 'ExportDefaultDeclaration'\n )\n if (!exportDefault) {\n return { code: generateFallbackCode(), unsupported: ['no export default found'] }\n }\n\n // 3. Find the config object (unwrap defineConfig() if present)\n const configObj = unwrapDefineConfig(exportDefault.declaration as Expression)\n if (!configObj || configObj.type !== 'ObjectExpression') {\n return { code: generateFallbackCode(), unsupported: ['config is not an object expression'] }\n }\n\n // 4. Find plugins array\n const pluginsProp = (configObj as ObjectExpression).properties.find(\n (p): p is ObjectProperty =>\n p.type === 'Property' && p.key.type === 'Identifier' && p.key.name === 'plugins'\n )\n if (!pluginsProp || pluginsProp.value.type !== 'ArrayExpression') {\n return { code: generateFallbackCode(), unsupported: ['plugins is not an array'] }\n }\n\n const pluginsArray = pluginsProp.value as ArrayExpression\n\n // 5. Analyze each plugin element\n const pluginCalls: PluginCallInfo[] = []\n for (const element of pluginsArray.elements) {\n if (element === null) {\n continue\n }\n\n if (element.type === 'SpreadElement') {\n unsupported.push(`spread element: ${source.slice(element.start, element.end)}`)\n continue\n }\n\n const expr = element as Expression\n if (expr.type === 'CallExpression') {\n const info = analyzeCallExpression(expr as CallExpression, imports)\n if (info) {\n pluginCalls.push(info)\n } else {\n unsupported.push(`unanalyzable call: ${source.slice(expr.start, expr.end)}`)\n }\n } else if (expr.type === 'ConditionalExpression' || expr.type === 'LogicalExpression') {\n unsupported.push(`conditional plugin: ${source.slice(expr.start, expr.end)}`)\n } else {\n // Identifier or other - try to resolve\n unsupported.push(`non-call plugin: ${source.slice(expr.start, expr.end)}`)\n }\n }\n\n // 6. Filter out Vrowzer plugins\n const workerPlugins = pluginCalls.filter(p => {\n if (!p.importSource) {\n return true\n } // local function - keep\n return !isWorkerExcludedImport(p.importSource)\n })\n debug(\n 'workerPlugins',\n workerPlugins.map(p => p.calleeName)\n )\n\n // 7. Determine which imports are needed\n const neededImportSources = new Set<string>()\n const neededLocalNames = new Set<string>()\n for (const plugin of workerPlugins) {\n if (plugin.importSource) {\n neededImportSources.add(plugin.importSource)\n }\n neededLocalNames.add(plugin.calleeName)\n }\n\n // Collect imports needed for plugin arguments (scan argument source for identifiers)\n for (const plugin of workerPlugins) {\n if (plugin.hasArgs) {\n const argSource = source.slice(plugin.start, plugin.end)\n for (const imp of imports) {\n if (imp.isTypeOnly) {\n continue\n }\n if (isViteImport(imp.source)) {\n continue\n }\n if (isWorkerExcludedImport(imp.source)) {\n continue\n }\n // Check if the import's local name appears in the argument source\n if (argSource.includes(imp.localName)) {\n neededImportSources.add(imp.source)\n neededLocalNames.add(imp.localName)\n }\n }\n }\n }\n\n // 8. Also include imports for non-imported local function plugins\n // (functions defined in the config file itself need their dependency imports\n // and dependent variable declarations)\n const localPluginNames = workerPlugins.filter(p => !p.importSource).map(p => p.calleeName)\n if (localPluginNames.length > 0) {\n // Collect local function sources\n const localFuncSources: string[] = []\n for (const stmt of ast.body) {\n if (stmt.type === 'FunctionDeclaration' && stmt.id) {\n const funcName = (stmt.id as { name: string }).name\n if (localPluginNames.includes(funcName)) {\n localFuncSources.push(source.slice(stmt.start, stmt.end))\n }\n }\n }\n\n // Scan function bodies for import references\n for (const funcSource of localFuncSources) {\n for (const imp of imports) {\n if (imp.isTypeOnly) {\n continue\n }\n if (isViteImport(imp.source)) {\n continue\n }\n if (isWorkerExcludedImport(imp.source)) {\n continue\n }\n if (funcSource.includes(imp.localName)) {\n neededImportSources.add(imp.source)\n neededLocalNames.add(imp.localName)\n }\n }\n }\n\n // Find variable declarations referenced by local functions and their import deps\n for (const stmt of ast.body) {\n if (stmt.type !== 'VariableDeclaration') {\n continue\n }\n for (const decl of (stmt as any).declarations) {\n if (!decl.id?.name) {\n continue\n }\n const varName = decl.id.name as string\n if (localPluginNames.includes(varName)) {\n continue\n } // skip plugin fn declarations\n const isUsedByLocalFunc = localFuncSources.some(funcSrc => funcSrc.includes(varName))\n if (isUsedByLocalFunc) {\n // This variable is needed — scan its init for import references\n const varSource = source.slice(stmt.start, stmt.end)\n for (const imp of imports) {\n if (imp.isTypeOnly) {\n continue\n }\n if (isViteImport(imp.source)) {\n continue\n }\n if (isWorkerExcludedImport(imp.source)) {\n continue\n }\n if (varSource.includes(imp.localName)) {\n neededImportSources.add(imp.source)\n neededLocalNames.add(imp.localName)\n }\n }\n }\n }\n }\n }\n\n // 8b. Find top-level config properties to forward (define, etc.)\n const forwardedProps = extractForwardedProperties(source, configObj as ObjectExpression)\n extractInputProperties(source, configObj as ObjectExpression, forwardedProps, unsupported)\n const forwardedServerProps: string[] = []\n if (options.serverOrigin !== undefined) {\n forwardedServerProps.push(`origin: ${JSON.stringify(options.serverOrigin)}`)\n }\n if (options.serverForwardConsole !== undefined) {\n forwardedServerProps.push(`forwardConsole: ${JSON.stringify(options.serverForwardConsole)}`)\n }\n if (forwardedServerProps.length > 0) {\n forwardedProps.set('server', `{ ${forwardedServerProps.join(', ')} }`)\n }\n\n if (unsupported.length > 0) {\n debug('unsupported patterns', unsupported)\n }\n\n // 9. Generate Worker config source\n const code = generateWorkerSource(\n source,\n ast,\n imports,\n workerPlugins,\n neededImportSources,\n neededLocalNames,\n forwardedProps\n )\n\n return { code, unsupported }\n}\n\n/**\n * Config properties that should be forwarded to Worker config.\n * These are extracted as raw source code from the config object.\n */\nconst FORWARDED_PROPERTIES = ['define', 'html']\n\nfunction extractForwardedProperties(\n source: string,\n configObj: ObjectExpression\n): Map<string, string> {\n const props = new Map<string, string>()\n for (const p of configObj.properties) {\n if (p.type !== 'Property') {\n continue\n }\n const key = p.key.type === 'Identifier' ? p.key.name : null\n if (key && FORWARDED_PROPERTIES.includes(key)) {\n props.set(key, source.slice(p.value.start, p.value.end))\n }\n }\n return props\n}\n\nfunction extractInputProperties(\n source: string,\n configObj: ObjectExpression,\n forwardedProps: Map<string, string>,\n unsupported: string[]\n): void {\n let hasUnknownTopLevelInput = false\n for (const property of configObj.properties) {\n if (property.type === 'SpreadElement') {\n unsupported.push(`config spread element: ${source.slice(property.start, property.end)}`)\n hasUnknownTopLevelInput = true\n } else if (property.type === 'Property' && property.computed) {\n unsupported.push(`computed config key: ${source.slice(property.start, property.end)}`)\n hasUnknownTopLevelInput = true\n }\n }\n if (hasUnknownTopLevelInput) {\n return\n }\n\n const inputProp = findObjectProperty(configObj, 'input')\n if (inputProp) {\n if (isStaticInputOption(inputProp.value as Expression)) {\n forwardedProps.set('input', source.slice(inputProp.value.start, inputProp.value.end))\n } else {\n unsupported.push(\n `input is not an inline string, array, or record: ${source.slice(inputProp.value.start, inputProp.value.end)}`\n )\n }\n }\n\n const environmentsProp = findObjectProperty(configObj, 'environments')\n if (!environmentsProp) {\n return\n }\n\n const environmentsValue = unwrapStaticExpression(environmentsProp.value as Expression)\n if (environmentsValue.type !== 'ObjectExpression') {\n unsupported.push(\n `environments is not an inline object: ${source.slice(environmentsProp.value.start, environmentsProp.value.end)}`\n )\n return\n }\n\n const entries: string[] = []\n let hasUnknownEnvironment = false\n for (const environmentProp of environmentsValue.properties) {\n if (environmentProp.type === 'SpreadElement') {\n unsupported.push(\n `environment spread element: ${source.slice(environmentProp.start, environmentProp.end)}`\n )\n hasUnknownEnvironment = true\n continue\n }\n if (environmentProp.type !== 'Property') {\n continue\n }\n\n const environmentName = getStaticPropertyName(environmentProp)\n if (environmentName === null) {\n unsupported.push(\n `computed environment key: ${source.slice(environmentProp.start, environmentProp.end)}`\n )\n hasUnknownEnvironment = true\n continue\n }\n\n const environmentValue = unwrapStaticExpression(environmentProp.value as Expression)\n if (environmentValue.type !== 'ObjectExpression') {\n unsupported.push(\n `environment ${JSON.stringify(environmentName)} is not an inline object: ${source.slice(environmentProp.value.start, environmentProp.value.end)}`\n )\n continue\n }\n\n let hasUnknownEnvironmentInput = false\n for (const property of environmentValue.properties) {\n if (property.type === 'SpreadElement') {\n unsupported.push(\n `environment ${JSON.stringify(environmentName)} spread element: ${source.slice(property.start, property.end)}`\n )\n hasUnknownEnvironmentInput = true\n } else if (property.type === 'Property' && property.computed) {\n unsupported.push(\n `environment ${JSON.stringify(environmentName)} has a computed key: ${source.slice(property.start, property.end)}`\n )\n hasUnknownEnvironmentInput = true\n }\n }\n if (hasUnknownEnvironmentInput) {\n continue\n }\n\n const input = findObjectProperty(environmentValue, 'input')\n if (!input) {\n continue\n }\n if (!isStaticInputOption(input.value as Expression)) {\n unsupported.push(\n `environment ${JSON.stringify(environmentName)} input is not an inline string, array, or record: ${source.slice(input.value.start, input.value.end)}`\n )\n continue\n }\n\n entries.push(\n `${JSON.stringify(environmentName)}: { input: ${source.slice(input.value.start, input.value.end)} }`\n )\n }\n\n if (entries.length > 0 && !hasUnknownEnvironment) {\n forwardedProps.set('environments', `{ ${entries.join(', ')} }`)\n }\n}\n\nfunction findObjectProperty(object: ObjectExpression, name: string): ObjectProperty | undefined {\n for (let index = object.properties.length - 1; index >= 0; index--) {\n const property = object.properties[index]\n if (!property || property.type !== 'Property') {\n continue\n }\n if (!property.computed && getPropertyName(property) === name) {\n return property\n }\n }\n return undefined\n}\n\nfunction getStaticPropertyName(property: ObjectProperty): string | null {\n if (property.computed) {\n return null\n }\n return getPropertyName(property)\n}\n\nfunction getPropertyName(property: ObjectProperty): string | null {\n if (property.key.type === 'Identifier') {\n return property.key.name\n }\n if (property.key.type === 'Literal' && typeof property.key.value === 'string') {\n return property.key.value\n }\n return null\n}\n\nfunction unwrapStaticExpression(expression: Expression): Expression {\n let current = expression as Expression & {\n expression?: Expression\n }\n while (\n current.expression &&\n (current.type === 'ParenthesizedExpression' ||\n current.type === 'TSAsExpression' ||\n current.type === 'TSSatisfiesExpression' ||\n current.type === 'TSNonNullExpression')\n ) {\n current = current.expression as typeof current\n }\n return current\n}\n\nfunction isStaticInputOption(expression: Expression): boolean {\n const value = unwrapStaticExpression(expression)\n if (isStaticString(value)) {\n return true\n }\n if (value.type === 'ArrayExpression') {\n return value.elements.every(\n element =>\n element !== null &&\n element.type !== 'SpreadElement' &&\n isStaticString(element as Expression)\n )\n }\n if (value.type === 'ObjectExpression') {\n return value.properties.every(\n property =>\n property.type === 'Property' &&\n !property.computed &&\n isStaticString(property.value as Expression)\n )\n }\n return false\n}\n\nfunction isStaticString(expression: Expression): boolean {\n const value = unwrapStaticExpression(expression)\n return (\n (value.type === 'Literal' && typeof value.value === 'string') ||\n (value.type === 'TemplateLiteral' && value.expressions.length === 0)\n )\n}\n\nfunction collectImports(ast: Program): ImportInfo[] {\n const imports: ImportInfo[] = []\n for (const node of ast.body) {\n if (node.type !== 'ImportDeclaration') {\n continue\n }\n const decl = node as ImportDeclaration\n const source = decl.source.value\n const isTypeOnly = decl.importKind === 'type'\n\n for (const spec of decl.specifiers) {\n if (spec.type === 'ImportDefaultSpecifier') {\n imports.push({\n source,\n localName: spec.local.name,\n importedName: null,\n start: decl.start,\n end: decl.end,\n isTypeOnly\n })\n } else if (spec.type === 'ImportSpecifier') {\n const importedName =\n spec.imported.type === 'Identifier' ? spec.imported.name : spec.imported.value\n imports.push({\n source,\n localName: spec.local.name,\n importedName,\n start: decl.start,\n end: decl.end,\n isTypeOnly: isTypeOnly || spec.importKind === 'type'\n })\n } else if (spec.type === 'ImportNamespaceSpecifier') {\n imports.push({\n source,\n localName: spec.local.name,\n importedName: '*',\n start: decl.start,\n end: decl.end,\n isTypeOnly\n })\n }\n }\n }\n return imports\n}\n\nfunction unwrapDefineConfig(expr: Expression): Expression | null {\n if (expr.type === 'CallExpression') {\n const call = expr as CallExpression\n if (\n call.callee.type === 'Identifier' &&\n (call.callee as { name: string }).name === 'defineConfig'\n ) {\n return call.arguments[0] as Expression | null\n }\n }\n if (expr.type === 'ObjectExpression') {\n return expr\n }\n return null\n}\n\nfunction analyzeCallExpression(call: CallExpression, imports: ImportInfo[]): PluginCallInfo | null {\n let calleeName: string | null = null\n\n if (call.callee.type === 'Identifier') {\n calleeName = (call.callee as { name: string }).name\n }\n\n if (!calleeName) {\n return null\n }\n\n // Find matching import\n const matchingImport = imports.find(i => i.localName === calleeName && !i.isTypeOnly)\n\n return {\n calleeName,\n importSource: matchingImport?.source ?? null,\n start: call.start,\n end: call.end,\n hasArgs: call.arguments.length > 0\n }\n}\n\nfunction generateWorkerSource(\n source: string,\n ast: Program,\n imports: ImportInfo[],\n plugins: PluginCallInfo[],\n neededImportSources: Set<string>,\n neededLocalNames: Set<string>,\n forwardedProps: Map<string, string> = new Map()\n): string {\n const lines: string[] = []\n\n // Emit needed imports (excluding Vrowzer, Vite, type-only)\n const emittedSources = new Set<string>()\n for (const imp of imports) {\n if (imp.isTypeOnly) {\n continue\n }\n if (isViteImport(imp.source)) {\n continue\n }\n if (isWorkerExcludedImport(imp.source)) {\n continue\n }\n if (!neededImportSources.has(imp.source)) {\n continue\n }\n if (!neededLocalNames.has(imp.localName)) {\n continue\n }\n if (emittedSources.has(`${imp.source}:${imp.localName}`)) {\n continue\n }\n emittedSources.add(`${imp.source}:${imp.localName}`)\n\n // Group imports from the same source\n // For simplicity, emit individual import statements\n if (imp.importedName === null) {\n // default import\n lines.push(`import ${imp.localName} from '${imp.source}'`)\n } else if (imp.importedName === '*') {\n // namespace import\n lines.push(`import * as ${imp.localName} from '${imp.source}'`)\n } else if (imp.importedName === imp.localName) {\n lines.push(`import { ${imp.localName} } from '${imp.source}'`)\n } else {\n lines.push(`import { ${imp.importedName} as ${imp.localName} } from '${imp.source}'`)\n }\n }\n\n // Emit local function definitions and their dependent variable declarations\n const localPluginNames = plugins.filter(p => !p.importSource).map(p => p.calleeName)\n\n // Collect local function sources to scan for variable references\n const localFuncSources: string[] = []\n for (const stmt of ast.body) {\n if (stmt.type === 'FunctionDeclaration' && stmt.id) {\n const funcName = (stmt.id as { name: string }).name\n if (localPluginNames.includes(funcName)) {\n localFuncSources.push(source.slice(stmt.start, stmt.end))\n }\n }\n }\n\n // Find variable declarations referenced by local functions\n const emittedVarNames = new Set<string>()\n for (const stmt of ast.body) {\n if (stmt.type !== 'VariableDeclaration') {\n continue\n }\n for (const decl of (stmt as any).declarations) {\n if (!decl.id?.name) {\n continue\n }\n const varName = decl.id.name as string\n // Check if any local function references this variable\n const isUsedByLocalFunc = localFuncSources.some(funcSrc => funcSrc.includes(varName))\n if (isUsedByLocalFunc && !localPluginNames.includes(varName)) {\n if (!emittedVarNames.has(varName)) {\n emittedVarNames.add(varName)\n lines.push('')\n lines.push(source.slice(stmt.start, stmt.end))\n\n // Also include imports used by this variable declaration\n const varSource = source.slice(stmt.start, stmt.end)\n for (const imp of imports) {\n if (imp.isTypeOnly) {\n continue\n }\n if (isViteImport(imp.source)) {\n continue\n }\n if (isWorkerExcludedImport(imp.source)) {\n continue\n }\n if (varSource.includes(imp.localName)) {\n neededImportSources.add(imp.source)\n neededLocalNames.add(imp.localName)\n }\n }\n }\n break\n }\n }\n }\n\n // Emit local function definitions\n for (const stmt of ast.body) {\n if (stmt.type === 'FunctionDeclaration' && stmt.id) {\n const funcName = (stmt.id as { name: string }).name\n if (localPluginNames.includes(funcName)) {\n lines.push('')\n lines.push(source.slice(stmt.start, stmt.end))\n }\n }\n // Also handle variable declarations that define plugin functions\n if (stmt.type === 'VariableDeclaration') {\n for (const decl of (stmt as any).declarations) {\n if (decl.id?.name && localPluginNames.includes(decl.id.name)) {\n lines.push('')\n lines.push(source.slice(stmt.start, stmt.end))\n break\n }\n }\n }\n }\n\n // Generate plugins array\n lines.push('')\n lines.push('export default {')\n lines.push(' plugins: [')\n\n for (const plugin of plugins) {\n const callSource = source.slice(plugin.start, plugin.end)\n lines.push(` ${callSource},`)\n }\n\n lines.push(' ],')\n\n // Emit forwarded properties (define, etc.)\n for (const [key, value] of forwardedProps) {\n lines.push(` ${key}: ${value},`)\n }\n\n lines.push('}')\n\n return lines.join('\\n')\n}\n\nfunction generateFallbackCode(): string {\n return 'export default { plugins: [] }'\n}\n","/**\n * vite-plugin-vrowzer options\n *\n * @module options\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { fileURLToPath } from 'node:url'\n\nexport interface Alias {\n find: string | RegExp\n replacement: string\n}\n\nexport interface VrowzerManifestOptions {\n /**\n * Directory to scan for project source files (index.html, src/, public/).\n * When the host page and preview content are in different directories,\n * set this to the preview content directory.\n *\n * Resolved relative to Vite's project root.\n *\n * @default Vite project root\n */\n sourceDir?: string\n /**\n * Package directory for node_modules resolution.\n * Defaults to sourceDir.\n */\n pkgDir?: string\n /**\n * Package name(s) to include in nodeModules.\n * When specified, only these packages (+ their transitive deps) are included.\n * When omitted, all dependencies are included.\n */\n targets?: string[]\n}\n\nexport interface VrowzerIdeOptions {\n /**\n * Port for the birpc WebSocket server.\n * @default auto (find available port)\n */\n port?: number\n}\n\nexport interface VrowzerExperimentalOptions {\n /**\n * Enable browser IDE at `/__vrowzer__/`.\n *\n * When `true` or an options object, the plugin serves a browser-based IDE\n * with Monaco Editor, File Explorer, and Preview at `/__vrowzer__/`.\n *\n * @default false (disabled)\n */\n ide?: boolean | VrowzerIdeOptions\n /**\n * Enable Vite DevTools panel in IDE.\n *\n * Requires `@vitejs/devtools` to be installed and configured\n * in `vite.config.ts` (with injection plugin excluded).\n *\n * @default false\n */\n devtools?: boolean\n}\n\nexport interface VrowzerOptions {\n /**\n * Enable auto-generation of vrowzer manifest.\n *\n * When `true` (default), the plugin automatically generates the manifest from\n * the project's package.json dependencies in `configResolved`. The manifest is\n * cached in `node_modules/.vrowzer-manifest/` and provided via the\n * `virtual:vrowzer-manifest` virtual module.\n *\n * When `false`, use `VrowzerManifest()` plugin with a manually created\n * `vrowzer-manifest.json` file (e.g. via `gen:manifest`).\n *\n * @default true\n */\n auto?: boolean\n /**\n * Auto manifest generation options (used when auto: true).\n */\n manifest?: VrowzerManifestOptions\n /**\n * The base path for the preview system location, which is used to serve the preview files via service worker of Vrowzer.\n *\n * @default '/__preview__/'\n */\n basePath?: string\n /**\n * The scope for the service worker of Vrowzer, which determines the range of URLs that the service worker will control.\n *\n * @default '/' (the entire origin)\n */\n serviceWorkerScope?: string\n /**\n * The version of the service worker for Vrowzer, which can be used to manage updates and cache invalidation for the preview system.\n *\n * @default 'SERVICE_WORKER_VERSION'\n */\n serviceWorkerVersion?: string\n /**\n * Explicit Service Worker entry file path.\n * When specified, `unplugin-service-worker` will bundle this file directly\n * instead of scanning source code for `createSvcWorkerController()` calls.\n *\n * This is required when using a library-provided Service Worker (e.g. `vrowzer/service-worker`)\n * that is in `node_modules` and excluded from code scanning.\n *\n * @example 'vrowzer/service-worker'\n * @default Resolved path to 'vrowzer/service-worker' (node_modules/vrowzer/dist/service-worker.ts)\n */\n serviceWorkerEntry?: string\n /**\n * Worker-specific resolve settings (e.g. vendor aliases).\n * These are NOT added to the host Vite config (which would break host package resolution),\n * but are passed to the Worker's internal Vite dev server.\n *\n * @example { alias: [{ find: 'vue', replacement: '/vendor/vue.js' }] }\n * @default undefined\n */\n resolve?: { alias?: Alias[] }\n /**\n * Experimental features.\n */\n experimental?: VrowzerExperimentalOptions\n}\n\nexport interface ResolvedIdeOptions {\n enabled: boolean\n port: number | undefined\n devtools: boolean\n}\n\nexport interface ResolvedVrowzerOptions {\n auto: boolean\n manifest: VrowzerManifestOptions | undefined\n ide: ResolvedIdeOptions\n basePath: string\n serviceWorkerScope: string\n serviceWorkerVersion: string\n serviceWorkerEntry: string\n resolve: { alias?: Alias[] } | undefined\n}\n\nfunction resolveDefaultServiceWorkerEntry(): string {\n try {\n return fileURLToPath(import.meta.resolve('vrowzer/service-worker'))\n } catch {\n return ''\n }\n}\n\nexport function resolveOptions(options: VrowzerOptions): ResolvedVrowzerOptions {\n const ide = options.experimental?.ide\n return {\n auto: options.auto ?? true,\n manifest: options.manifest,\n ide: {\n enabled: !!ide,\n port: typeof ide === 'object' ? ide.port : undefined,\n devtools: options.experimental?.devtools ?? false\n },\n basePath: options.basePath ?? '/__preview__/',\n serviceWorkerScope: options.serviceWorkerScope ?? '/',\n serviceWorkerVersion: options.serviceWorkerVersion ?? 'SERVICE_WORKER_VERSION',\n serviceWorkerEntry: options.serviceWorkerEntry ?? resolveDefaultServiceWorkerEntry(),\n resolve: options.resolve\n }\n}\n","/**\n * Pre-bundle Worker config using rolldown.\n *\n * Takes the extracted Worker source from extract.ts and bundles it\n * into node_modules/.vrowzer/ for Worker consumption.\n *\n * @module prebundle\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { createRequire as nodeCreateRequire } from 'node:module'\nimport { rolldown } from 'rolldown'\nimport { createDebug } from 'obug'\nimport { resolveAliases } from './alias.ts'\n\nimport type { Plugin as RolldownPlugin } from 'rolldown'\n\nconst debug = createDebug('vite-plugin-vrowzer:prebundle')\n\nexport interface PrebundleOptions {\n /** Generated Worker config source code */\n workerSource: string\n /** Project root directory */\n root: string\n /** Directory of the original vite.config.ts (for resolving import.meta.dirname) */\n configDir: string\n}\n\nconst OUTPUT_DIR_NAME = '.vrowzer'\nconst BUNDLED_FILENAME = 'config.bundled.mjs'\n\n/**\n * Resolve the output directory path for prebundled Worker config.\n */\nexport function resolveOutputDir(root: string): string {\n return resolve(root, 'node_modules', OUTPUT_DIR_NAME)\n}\n\n/**\n * Remove the prebundle output directory.\n */\nexport function cleanOutputDir(root: string): void {\n const outputDir = resolveOutputDir(root)\n if (existsSync(outputDir)) {\n rmSync(outputDir, { recursive: true })\n debug('cleaned output dir:', outputDir)\n }\n}\n\n/**\n * Pre-bundle Worker config source using rolldown.\n *\n * @returns Absolute path to the bundled config file.\n */\nexport async function prebundleWorkerConfig(options: PrebundleOptions): Promise<string> {\n const { workerSource, root, configDir } = options\n const outputDir = resolveOutputDir(root)\n const bundledPath = resolve(outputDir, BUNDLED_FILENAME)\n\n debug('prebundling worker config...')\n\n // Ensure output directory exists\n mkdirSync(outputDir, { recursive: true })\n\n // Write temporary entry file (.mts for TypeScript support — rolldown handles TS natively)\n const entryPath = resolve(outputDir, '_entry.mts')\n writeFileSync(entryPath, workerSource)\n\n // Bundle with rolldown\n const bundle = await rolldown({\n input: entryPath,\n external: [new RegExp('^@vrowzer/'), 'assert', 'v8'],\n // Define process.env.NODE_ENV so plugin code doesn't need runtime process global\n transform: {\n define: {\n 'process.env.NODE_ENV': JSON.stringify('development'),\n global: 'globalThis'\n },\n inject: {\n process: '@vrowzer/node-polyfill/process'\n }\n },\n // Map Node.js builtins to browser polyfills and vite to vrowzer's shim.\n // These are resolved at prebundle time and the aliases appear as external\n // imports in the output (resolved by host Vite's resolve.alias at serve time).\n resolve: {\n alias: resolveAliases({\n // Only node:process is aliased here — bare `process` stays as-is.\n // Host Vite's @rollup/plugin-inject or resolve.alias handles it at serve time.\n 'node:process': '@vrowzer/node-polyfill/process'\n }),\n mainFields: ['module', 'main'],\n conditionNames: ['browser', 'import', 'default']\n },\n platform: 'neutral',\n plugins: [viteAliasPlugin(), inlineReadFileSyncPlugin(configDir), inlineCreateRequirePlugin()]\n })\n\n await bundle.write({\n format: 'esm',\n dir: outputDir,\n entryFileNames: BUNDLED_FILENAME,\n chunkFileNames: 'chunks/[name].mjs',\n minify: false\n })\n\n debug('prebundle complete:', bundledPath)\n\n return bundledPath\n}\n\n/**\n * Rolldown plugin to redirect `vite` imports to `@vrowzer/vite-dev-server/vite`.\n * Handles both exact `vite` and subpaths like `vite/internal`.\n */\nfunction viteAliasPlugin(): RolldownPlugin {\n const VITE_INTERNAL_ID = '\\0vrowzer:vite-internal-stub'\n return {\n name: 'vrowzer:vite-alias',\n resolveId(id) {\n if (id === 'vite') {\n return { id: '@vrowzer/vite-dev-server/vite', external: true }\n }\n // vite/internal is a Rolldown Vite 8 internal — stub it out\n if (id === 'vite/internal') {\n return { id: VITE_INTERNAL_ID, external: false }\n }\n if (id.startsWith('vite/')) {\n return { id: id.replace(/^vite\\//, '@vrowzer/vite-dev-server/vite/'), external: true }\n }\n },\n load(id) {\n if (id === VITE_INTERNAL_ID) {\n return 'export {}'\n }\n }\n }\n}\n\n/**\n * Rolldown plugin to inline `readFileSync(...)` calls at prebundle time.\n *\n * When the Worker config source contains `readFileSync(path, 'utf-8')`,\n * this plugin evaluates the call at prebundle time (Node.js) and replaces\n * it with the file content as a string literal. This is necessary because\n * Worker environments cannot access the host filesystem.\n *\n * Supported patterns:\n * readFileSync('literal/path', 'utf-8')\n * readFileSync(resolve(import.meta.dirname, 'path'), 'utf-8')\n */\nfunction inlineReadFileSyncPlugin(configDir: string): RolldownPlugin {\n // Match: readFileSync( <expr> , 'utf-8') or readFileSync( <expr> , \"utf-8\")\n // Uses [\\s\\S]+? to handle multiline expressions (e.g. resolve(dir, 'path') on separate lines)\n const RE = /readFileSync\\(\\s*([\\s\\S]+?)\\s*,\\s*['\"]utf-?8['\"]\\s*\\)/g\n\n return {\n name: 'vrowzer:inline-readFileSync',\n transform(code, id) {\n // Only process the entry file, not dependencies\n if (!id.includes('_entry.mt') && !id.includes('.vrowzer/')) {\n return\n }\n if (!code.includes('readFileSync')) {\n return\n }\n\n let modified = false\n const result = code.replace(RE, (match, pathExpr: string) => {\n const resolvedPath = tryEvalPathExpr(pathExpr.trim(), configDir)\n if (!resolvedPath) {\n debug('inlineReadFileSync: could not evaluate path expr:', pathExpr)\n return match\n }\n\n try {\n const content = readFileSync(resolvedPath, 'utf-8')\n modified = true\n debug('inlineReadFileSync: inlined', resolvedPath, `(${content.length} bytes)`)\n return JSON.stringify(content)\n } catch (e) {\n debug('inlineReadFileSync: failed to read:', resolvedPath, e)\n return match\n }\n })\n\n if (modified) {\n // Remove now-unused node:fs and node:path imports\n const cleaned = result\n .replace(/import\\s*\\{[^}]*readFileSync[^}]*\\}\\s*from\\s*['\"]node:fs['\"]\\s*;?\\n?/g, '')\n .replace(/import\\s*\\{[^}]*resolve[^}]*\\}\\s*from\\s*['\"]node:path['\"]\\s*;?\\n?/g, '')\n return { code: cleaned, map: null }\n }\n }\n }\n}\n\n/**\n * Try to evaluate a path expression to an absolute path string.\n */\nfunction tryEvalPathExpr(expr: string, configDir: string): string | null {\n // Case 1: Simple string literal\n const strMatch = expr.match(/^['\"](.+)['\"]$/)\n if (strMatch) {\n return resolve(configDir, strMatch[1]!)\n }\n\n // Case 2: resolve(import.meta.dirname, 'path') or resolve(__dirname, 'path')\n const resolveMatch = expr.match(\n /^resolve\\(\\s*(?:import\\.meta\\.dirname|__dirname)\\s*,\\s*['\"](.+)['\"]\\s*\\)$/\n )\n if (resolveMatch) {\n return resolve(configDir, resolveMatch[1]!)\n }\n\n return null\n}\n\n/**\n * Rolldown plugin to inline `createRequire(...)(\"pkg/path\")` calls at prebundle time.\n *\n * Some plugins (e.g. @sveltejs/vite-plugin-svelte) use `createRequire` at module\n * init time to load package.json files. This fails in Worker environments where\n * `require()` is not available. This plugin detects the pattern and replaces it\n * with the actual file content at prebundle time.\n */\nfunction inlineCreateRequirePlugin(): RolldownPlugin {\n // Match: createRequire(import.meta.url)(\"some/package.json\")\n const RE = /createRequire\\([^)]+\\)\\(\\s*['\"]([^'\"]+)['\"]\\s*\\)/g\n\n return {\n name: 'vrowzer:inline-createRequire',\n transform(code, id) {\n if (!code.includes('createRequire')) {\n return\n }\n\n let modified = false\n const result = code.replace(RE, (match, specifier: string) => {\n // Only inline JSON files (package.json etc.)\n if (!specifier.endsWith('.json')) {\n return match\n }\n\n try {\n // Resolve from the file that contains the createRequire call\n const req = nodeCreateRequire(id)\n const resolvedPath = req.resolve(specifier)\n const content = readFileSync(resolvedPath, 'utf-8')\n modified = true\n debug('inlineCreateRequire: inlined', specifier, 'from', id)\n return JSON.stringify(JSON.parse(content))\n } catch {\n debug('inlineCreateRequire: could not resolve', specifier, 'from', id)\n return match\n }\n })\n\n if (modified) {\n return { code: result, map: null }\n }\n }\n }\n}\n","/**\n * rolldown processing\n *\n * @module rolldown\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { copyFileSync, existsSync } from 'node:fs'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { createDebug } from 'obug'\n\nimport type { Plugin } from 'vite'\nimport type { ResolvedVrowzerOptions } from './options.ts'\n\nconst debug = createDebug('vite-plugin-vrowzer:rolldown')\n\n// Resolve @vrowzer/rolldown dist path for WASM/Worker file copying\nconst rolldownDistDir = path.resolve(\n path.dirname(fileURLToPath(import.meta.resolve('@vrowzer/rolldown/package.json'))),\n 'dist'\n)\ndebug('rolldownDistDir ', rolldownDistDir)\n\nexport function rolldownPlugin(_options: ResolvedVrowzerOptions): Plugin {\n let resolvedOutDir = ''\n\n return {\n name: 'vrowzer:rolldown',\n configResolved(config) {\n resolvedOutDir = path.resolve(config.root, config.build.outDir)\n },\n /**\n * Copy rolldown WASM binary and sub-worker for production builds.\n * Both the chunk and WASM/worker files end up in dist/assets/.\n */\n writeBundle() {\n const assetsDir = path.resolve(resolvedOutDir, 'assets')\n debug('copy-rolldown-wasm: assetsDir ', assetsDir)\n\n const wasmSrc = path.resolve(rolldownDistDir, 'rolldown-binding.wasm32-wasi.wasm')\n debug('copy-rolldown-wasm: wasmSrc ', wasmSrc)\n\n const workerSrc = path.resolve(rolldownDistDir, 'worker.js')\n debug('copy-rolldown-wasm: workerSrc ', workerSrc)\n\n if (existsSync(wasmSrc)) {\n copyFileSync(wasmSrc, path.resolve(assetsDir, 'rolldown-binding.wasm32-wasi.wasm'))\n }\n if (existsSync(workerSrc)) {\n copyFileSync(workerSrc, path.resolve(assetsDir, 'rolldown-worker.js'))\n }\n }\n }\n}\n","/**\n * server middleware\n *\n * @module server\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { createDebug } from 'obug'\n\nimport type { IncomingMessage, ServerResponse } from 'node:http'\nimport type { Plugin } from 'vite'\nimport type { ResolvedVrowzerOptions } from './options.ts'\n\nconst debug = createDebug('vite-plugin-vrowzer:server')\n\n/**\n * NOTE(kazupon):\n * Prevent Vite's SPA fallback from serving index.html for preview URL (e.g '/__preview__/') requests.\n * When service worker is not yet controlling the page (e.g. after hard reload),\n * preview requests bypass service worker and hit Vite directly.\n * Without this guard, Vite returns the main page HTML, causing recursive display.\n */\nfunction previewGuardMiddleware(previewBase: string = '/__preview__') {\n return (req: IncomingMessage, res: ServerResponse, next: () => void) => {\n debug('previewGuardMiddleware: previewBase ', previewBase, ' req.url ', req.url)\n\n if (req.url?.startsWith(previewBase)) {\n res.writeHead(503, {\n 'Content-Type': 'text/html',\n 'Retry-After': '1'\n })\n res.end(`<!doctype html><html><head><meta charset=\"utf-8\"><title>Preview</title></head><body>\n<script>setTimeout(() => location.reload(), 1000)</script>\n<p>Waiting for Service Worker...</p></body></html>`)\n return\n }\n\n next()\n }\n}\n\nexport function serverMiddlewarePlugin(options: ResolvedVrowzerOptions): Plugin {\n const middleware = previewGuardMiddleware(normalizeBasePath(options.basePath))\n return {\n name: 'vrowzer:server-middleware',\n configureServer(server) {\n server.middlewares.use(middleware)\n },\n configurePreviewServer(server) {\n server.middlewares.use(middleware)\n }\n }\n}\n\nfunction normalizeBasePath(basePath: string): string {\n debug('normalizeBasePath: basePath ', basePath)\n if (basePath.endsWith('/')) {\n return basePath.slice(0, -1)\n } else {\n return basePath\n }\n}\n","/**\n * Worker entry generation for vrowzer\n *\n * Generates source code for Worker entries that import vrowzer's factory functions\n * and the user's config to inject user plugins into Workers.\n *\n * @module virtual\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport type { Alias } from './options.ts'\n\nexport function generateWebWorkerEntry(configPath: string, resolve?: { alias?: Alias[] }): string {\n const resolveBlock = resolve\n ? `\\nconst workerResolve = ${JSON.stringify(resolve)}\\nObject.assign(resolved, { resolve: workerResolve })`\n : ''\n\n return `\nimport { initWebWorker } from 'vrowzer/web-worker-core'\nimport config from '${configPath}'\nconst resolved = config.default ?? config\n${resolveBlock}\ninitWebWorker(resolved)\n`\n}\n","/**\n * Vite plugin that transforms vrowzer-manifest.json imports.\n *\n * Replaces file path values with actual file contents so that\n * the imported manifest can be passed directly to Vrowzer.ready().\n *\n * Use the `?vrowzer` query suffix to trigger this plugin:\n * import manifest from './vrowzer-manifest.json?vrowzer'\n *\n * @module manifest\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { readFileSync } from 'node:fs'\nimport { dirname, extname, resolve } from 'node:path'\nimport { minifySync } from 'rolldown/utils'\nimport { createDebug } from 'obug'\n\nimport type { Plugin } from 'vite'\n\nconst MINIFIABLE_EXTENSIONS = new Set(['.js', '.mjs', '.cjs'])\n\nconst debug = createDebug('vite-plugin-vrowzer:manifest')\n\nfunction parseId(id: string): { filePath: string; isVrowzer: boolean } {\n try {\n const url = new URL(id, 'file://')\n return {\n filePath: url.pathname,\n isVrowzer: url.searchParams.has('vrowzer')\n }\n } catch {\n return { filePath: id, isVrowzer: false }\n }\n}\n\nexport function VrowzerManifest(): Plugin {\n return {\n name: 'vrowzer:manifest-loader',\n resolveId(id) {\n if (parseId(id).isVrowzer) {\n debug('resolveId:', id)\n return id\n }\n },\n load(id) {\n const { filePath, isVrowzer } = parseId(id)\n if (!isVrowzer) {\n return\n }\n debug('loading manifest:', filePath)\n\n const raw = readFileSync(filePath, 'utf-8')\n const manifest = JSON.parse(raw)\n const manifestDir = dirname(filePath)\n\n function resolveFiles(\n field: string,\n files: Record<string, string> | undefined,\n minify = false\n ): Record<string, string> {\n if (!files) {\n return {}\n }\n const resolved: Record<string, string> = {}\n for (const [virtualPath, relPath] of Object.entries(files)) {\n try {\n let content = readFileSync(resolve(manifestDir, relPath), 'utf-8')\n if (minify && MINIFIABLE_EXTENSIONS.has(extname(virtualPath))) {\n const result = minifySync(virtualPath, content)\n if (result.code) {\n content = result.code\n }\n }\n resolved[virtualPath] = content\n } catch (e) {\n debug('failed to read %s %s: %s', field, relPath, (e as Error).message)\n }\n }\n debug('%s: %d files resolved', field, Object.keys(resolved).length)\n return resolved\n }\n\n const result = {\n name: manifest.name,\n files: resolveFiles('files', manifest.files),\n vendor: resolveFiles('vendor', manifest.vendor, true),\n nodeModules: resolveFiles('nodeModules', manifest.nodeModules, true),\n activeFile: manifest.activeFile\n }\n\n debug(\n 'manifest loaded: %s (%d files, %d vendor, %d nodeModules)',\n result.name,\n Object.keys(result.files).length,\n Object.keys(result.vendor).length,\n Object.keys(result.nodeModules).length\n )\n\n return {\n code: `export default ${JSON.stringify(result)}`,\n moduleType: 'js'\n }\n }\n }\n}\n","/**\n * vite-plugin-vrowzer entry\n *\n * @module default\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { readFileSync } from 'node:fs'\nimport { dirname } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport * as injectModule from '@rollup/plugin-inject'\nimport ServiceWorker from '@vrowzer/unplugin-service-worker/vite'\nimport { createDebug } from 'obug'\nimport { autoManifestPlugin } from './auto-manifest.ts'\nimport { envPlugin } from './env.ts'\nimport { idePlugin } from './ide.ts'\nimport { extractWorkerConfig } from './extract.ts'\nimport { resolveOptions } from './options.ts'\nimport { cleanOutputDir, prebundleWorkerConfig } from './prebundle.ts'\nimport { rolldownPlugin } from './rolldown.ts'\nimport { serverMiddlewarePlugin } from './server.ts'\nimport { generateWebWorkerEntry } from './virtual.ts'\n\nimport type { Plugin, ResolvedConfig, UserConfig } from 'vite'\nimport type { RollupInjectOptions } from '@rollup/plugin-inject'\nimport type { VrowzerOptions } from './options.ts'\n\nconst debug = createDebug('vite-plugin-vrowzer:index')\nconst inject = injectModule.default as unknown as (\n options?: RollupInjectOptions\n) => Record<string, unknown>\n\nexport function Vrowzer(options: VrowzerOptions = {}): Plugin[] {\n const resolvedOptions = resolveOptions(options)\n const root = process.cwd()\n\n // Path to bundled Worker config (set by configResolved)\n let bundledConfigPath: string | null = null\n let isBuild = false\n\n function workerEntryTransform(code: string, id: string) {\n if (!bundledConfigPath) {\n return\n }\n const cleanId = id.split('?')[0]\n if (\n cleanId?.endsWith('web-worker.ts') &&\n !cleanId.endsWith('web-worker-core.ts') &&\n code.includes('initWebWorker()')\n ) {\n return { code: generateWebWorkerEntry(bundledConfigPath, resolvedOptions.resolve), map: null }\n }\n }\n\n const vrowzerConfigPlugin: Plugin = {\n name: 'vrowzer:config',\n resolveId(id) {\n if (id.startsWith('@vrowzer/')) {\n try {\n return fileURLToPath(import.meta.resolve(id))\n } catch {\n // Not resolvable from this plugin — let Vite handle it normally\n }\n }\n },\n config(): UserConfig {\n const workerPlugins: Plugin[] = [\n {\n name: 'vrowzer:worker-resolve',\n resolveId(id: string) {\n if (id.startsWith('@vrowzer/')) {\n try {\n return fileURLToPath(import.meta.resolve(id))\n } catch {\n // fallthrough\n }\n }\n }\n },\n {\n name: 'vrowzer:worker-process-inject',\n options(inputOptions: any) {\n inputOptions.transform ??= {}\n inputOptions.transform.inject = {\n ...inputOptions.transform.inject,\n process: '@vrowzer/node-polyfill/process'\n }\n }\n },\n {\n name: 'vrowzer:web-worker-config-inject',\n transform: workerEntryTransform\n }\n ]\n\n return {\n resolve: {\n alias: [{ find: /^vite$/, replacement: '@vrowzer/vite-dev-server/vite' }]\n },\n worker: {\n plugins: () => workerPlugins\n }\n }\n },\n async configResolved(config: ResolvedConfig) {\n isBuild = config.command === 'build'\n\n const viteConfigPath = config.configFile\n if (!viteConfigPath) {\n debug('no vite.config.ts found, skipping extraction')\n return\n }\n\n debug('extracting worker config from:', viteConfigPath)\n\n cleanOutputDir(config.root)\n\n const configDir = dirname(viteConfigPath)\n const viteConfigSource = readFileSync(viteConfigPath, 'utf-8')\n const { code: workerSource, unsupported } = extractWorkerConfig(\n viteConfigSource,\n viteConfigPath,\n {\n serverOrigin: config.server.origin,\n serverForwardConsole: config.server.forwardConsole\n }\n )\n\n if (unsupported.length > 0) {\n debug('unsupported patterns found:', unsupported)\n }\n\n debug('generated worker source:\\n', workerSource)\n\n bundledConfigPath = await prebundleWorkerConfig({\n workerSource,\n root: config.root,\n configDir\n })\n\n debug('bundled config path:', bundledConfigPath)\n },\n closeBundle() {\n if (isBuild && bundledConfigPath) {\n cleanOutputDir(root)\n debug('cleaned up prebundle output after build')\n }\n },\n transform(code: string, id: string) {\n return workerEntryTransform(code, id)\n }\n }\n\n const processInjectPlugin = {\n ...inject({\n process: '@vrowzer/node-polyfill/process',\n exclude: [/node_modules\\/\\.vite\\//, /node_modules\\/\\.vrowzer\\//]\n }),\n apply: 'serve'\n } as unknown as Plugin\n const serviceWorkerPlugin = ServiceWorker({\n serviceWorkerAllowed: '/',\n format: 'esm',\n ...(resolvedOptions.serviceWorkerEntry ? { entry: resolvedOptions.serviceWorkerEntry } : {})\n }) as unknown as Plugin\n\n const plugins: Plugin[] = [\n vrowzerConfigPlugin,\n serverMiddlewarePlugin(resolvedOptions),\n processInjectPlugin,\n envPlugin(resolvedOptions),\n rolldownPlugin(resolvedOptions),\n serviceWorkerPlugin\n ]\n\n // Auto-manifest plugin: generates manifest and provides virtual:vrowzer-manifest\n if (resolvedOptions.auto) {\n plugins.unshift(autoManifestPlugin(resolvedOptions.manifest))\n }\n\n // IDE plugin: serves browser IDE at /__vrowzer__/ (experimental)\n if (resolvedOptions.ide.enabled) {\n plugins.push(idePlugin(resolvedOptions))\n }\n\n return plugins\n}\n\nexport { VrowzerManifest } from './manifest.ts'\nexport { generateManifest } from './manifest-generate.ts'\nexport type {\n GenerateManifestOptions,\n ManifestResult,\n GenerateManifestLog\n} from './manifest-generate.ts'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAMA,UAAQ,YAAY,mCAAmC;AAE7D,MAAM,oBAAoB;AAC1B,MAAM,6BAA6B;AAEnC,MAAM,iBAAiB;AACvB,MAAM,oBAAoB;AAC1B,MAAM,gBAAgB;AAEtB,MAAM,iBAAiB;CAAC;CAAkB;CAAqB;CAAa;AAAU;AAEtF,MAAMC,0CAAwB,IAAI,IAAI;CAAC;CAAO;CAAQ;AAAM,CAAC;;;;AAK7D,SAAS,KAAK,OAAuB;CACnC,IAAI,IAAI;CACR,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,OAAO,MAAM,WAAW,CAAC;EAC/B,KAAK,KAAK,KAAK,IAAI;EACnB,IAAI,IAAI;CACV;CACA,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC;AAC5C;;;;AAKA,SAAS,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BAA+B,WAAW;GAGlD,MAAM,8BAA8B,YAAY;GAEhD,oBAAoB,MAAM,sBAAsB;IAC9C;IACA,MAAM,OAAO;IACb;GACF,CAAC;GAED,MAAM,wBAAwB,iBAAiB;EACjD;EACA,cAAc;GACZ,IAAI,WAAW,mBAAmB;IAChC,eAAe,IAAI;IACnB,MAAM,yCAAyC;GACjD;EACF;EACA,UAAU,MAAc,IAAY;GAClC,OAAO,qBAAqB,MAAM,EAAE;EACtC;CACF;CAEA,MAAM,sBAAsB;EAC1B,GAAG,OAAO;GACR,SAAS;GACT,SAAS,CAAC,0BAA0B,2BAA2B;EACjE,CAAC;EACD,OAAO;CACT;CACA,MAAM,sBAAsB,cAAc;EACxC,sBAAsB;EACtB,QAAQ;EACR,GAAI,gBAAgB,qBAAqB,EAAE,OAAO,gBAAgB,mBAAmB,IAAI,CAAC;CAC5F,CAAC;CAED,MAAM,UAAoB;EACxB;EACA,uBAAuB,eAAe;EACtC;EACA,UAAU,eAAe;EACzB,eAAe,eAAe;EAC9B;CACF;CAGA,IAAI,gBAAgB,MAClB,QAAQ,QAAQ,mBAAmB,gBAAgB,QAAQ,CAAC;CAI9D,IAAI,gBAAgB,IAAI,SACtB,QAAQ,KAAK,UAAU,eAAe,CAAC;CAGzC,OAAO;AACT"}
1
+ {"version":3,"file":"index.mjs","names":["debug","MINIFIABLE_EXTENSIONS","debug","debug","debug","debug","nodeCreateRequire","debug","debug","debug"],"sources":["../src/auto-manifest.ts","../src/alias.ts","../src/env.ts","../src/ide.ts","../src/extract.ts","../src/options.ts","../src/prebundle.ts","../src/rolldown.ts","../src/server.ts","../src/virtual.ts","../src/manifest.ts","../src/index.ts"],"sourcesContent":["/**\n * Auto-manifest plugin for Vrowzer.\n *\n * When `auto: true`, this plugin:\n * 1. Auto-generates the vrowzer manifest in `configResolved`\n * 2. Caches results in `node_modules/.vrowzer-manifest/`\n * 3. Provides the manifest via `virtual:vrowzer-manifest` virtual module\n *\n * @module auto-manifest\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs'\nimport { extname, join, resolve } from 'node:path'\nimport { minifySync } from 'rolldown/utils'\nimport { createDebug } from 'obug'\nimport { generateManifest } from './manifest-generate.ts'\n\nimport type { Plugin, ResolvedConfig } from 'vite'\nimport type { ManifestResult } from './manifest-generate.ts'\nimport type { VrowzerManifestOptions } from './options.ts'\n\nconst debug = createDebug('vite-plugin-vrowzer:auto-manifest')\n\nconst VIRTUAL_MODULE_ID = 'virtual:vrowzer-manifest'\nconst RESOLVED_VIRTUAL_MODULE_ID = '\\0' + VIRTUAL_MODULE_ID\n\nconst CACHE_DIR_NAME = '.vrowzer-manifest'\nconst MANIFEST_FILENAME = 'manifest.json'\nconst HASH_FILENAME = '_hash'\n\nconst LOCKFILE_NAMES = ['pnpm-lock.yaml', 'package-lock.json', 'yarn.lock', 'bun.lock']\n\nconst MINIFIABLE_EXTENSIONS = new Set(['.js', '.mjs', '.cjs'])\n\n/**\n * Simple 32-bit string hash (same algorithm as unplugin-service-worker hash).\n */\nfunction hash(input: string): string {\n let h = 0\n for (let i = 0; i < input.length; i++) {\n const char = input.charCodeAt(i)\n h = (h << 5) - h + char\n h = h & h\n }\n return Math.abs(h).toString(36).slice(0, 8)\n}\n\n/**\n * Compute cache key from package.json dependencies, lockfile, and manifest options.\n */\nfunction computeCacheHash(root: string, manifestOptions?: VrowzerManifestOptions): string {\n const parts: string[] = []\n\n // Include sourceDir in cache key so changes to it invalidate the cache\n if (manifestOptions?.sourceDir) {\n parts.push(`sourceDir:${manifestOptions.sourceDir}`)\n }\n if (manifestOptions?.targets) {\n parts.push(`targets:${manifestOptions.targets.join(',')}`)\n }\n\n // Read package.json deps\n const pkgPath = join(root, 'package.json')\n if (existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))\n parts.push(JSON.stringify(pkg.dependencies || {}))\n parts.push(JSON.stringify(pkg.devDependencies || {}))\n } catch {\n // ignore\n }\n }\n\n // Read lockfile\n for (const lockfile of LOCKFILE_NAMES) {\n const lockPath = join(root, lockfile)\n if (existsSync(lockPath)) {\n try {\n parts.push(readFileSync(lockPath, 'utf-8'))\n } catch {\n // ignore\n }\n break\n }\n }\n\n return hash(parts.join('\\n'))\n}\n\nfunction getCacheDir(root: string): string {\n return resolve(root, 'node_modules', CACHE_DIR_NAME)\n}\n\nfunction readCachedHash(cacheDir: string): string | null {\n const hashPath = join(cacheDir, HASH_FILENAME)\n if (existsSync(hashPath)) {\n try {\n return readFileSync(hashPath, 'utf-8').trim()\n } catch {\n return null\n }\n }\n return null\n}\n\nfunction readCachedManifest(cacheDir: string): ManifestResult | null {\n const manifestPath = join(cacheDir, MANIFEST_FILENAME)\n if (existsSync(manifestPath)) {\n try {\n return JSON.parse(readFileSync(manifestPath, 'utf-8'))\n } catch {\n return null\n }\n }\n return null\n}\n\nfunction writeCache(cacheDir: string, manifest: ManifestResult, cacheHash: string): void {\n mkdirSync(cacheDir, { recursive: true })\n writeFileSync(join(cacheDir, MANIFEST_FILENAME), JSON.stringify(manifest, null, 2) + '\\n')\n writeFileSync(join(cacheDir, HASH_FILENAME), cacheHash + '\\n')\n}\n\n/**\n * Resolve manifest path references to actual file contents.\n * This is equivalent to what VrowzerManifest() does for manual manifests.\n */\nfunction resolveManifestContents(\n manifest: ManifestResult,\n manifestDir: string\n): Record<string, any> {\n function resolveFiles(\n files: Record<string, string> | undefined,\n minify: boolean\n ): Record<string, string> {\n if (!files) {\n return {}\n }\n const resolved: Record<string, string> = {}\n for (const [virtualPath, relPath] of Object.entries(files)) {\n try {\n let content = readFileSync(resolve(manifestDir, relPath), 'utf-8')\n if (minify && MINIFIABLE_EXTENSIONS.has(extname(virtualPath))) {\n const result = minifySync(virtualPath, content)\n if (result.code) {\n content = result.code\n }\n }\n resolved[virtualPath] = content\n } catch {\n debug('failed to read %s', relPath)\n }\n }\n return resolved\n }\n\n return {\n name: manifest.name,\n files: resolveFiles(manifest.files, false),\n nodeModules: resolveFiles(manifest.nodeModules, true),\n activeFile: manifest.activeFile\n }\n}\n\n/**\n * Create the auto-manifest plugin.\n *\n * This plugin is included in the `Vrowzer()` array when `auto: true`.\n */\nexport function autoManifestPlugin(manifestOptions?: VrowzerManifestOptions): Plugin {\n let sourceDir: string\n let manifest: ManifestResult | null = null\n\n return {\n name: 'vrowzer:auto-manifest',\n resolveId(id) {\n if (id === VIRTUAL_MODULE_ID) {\n return RESOLVED_VIRTUAL_MODULE_ID\n }\n },\n async configResolved(config: ResolvedConfig) {\n const root = config.root\n sourceDir = manifestOptions?.sourceDir ? resolve(root, manifestOptions.sourceDir) : root\n const pkgDir = manifestOptions?.pkgDir ? resolve(root, manifestOptions.pkgDir) : root\n\n const cacheDir = getCacheDir(root)\n const currentHash = computeCacheHash(pkgDir, manifestOptions)\n const cachedHash = readCachedHash(cacheDir)\n\n if (currentHash === cachedHash) {\n // Cache hit\n manifest = readCachedManifest(cacheDir)\n if (manifest) {\n debug('cache hit (hash: %s), using cached manifest', currentHash)\n return\n }\n }\n\n // Cache miss — generate manifest\n debug('cache miss (current: %s, cached: %s), generating manifest...', currentHash, cachedHash)\n\n manifest = await generateManifest(\n {\n pkgDir,\n sourceDir,\n ...(manifestOptions?.targets ? { targets: manifestOptions.targets } : {})\n },\n msg => debug(msg)\n )\n\n // Write cache\n writeCache(cacheDir, manifest, currentHash)\n debug('manifest cached to %s', cacheDir)\n },\n load(id) {\n if (id !== RESOLVED_VIRTUAL_MODULE_ID) {\n return\n }\n\n if (!manifest) {\n debug('no manifest available')\n return { code: 'export default {}', moduleType: 'js' }\n }\n\n // Resolve path references to actual file contents\n // Use the manifest dir (cache dir) as the base for path resolution,\n // but since paths in the manifest are relative to sourceDir (= projectRoot),\n // we use projectRoot as the base.\n const resolved = resolveManifestContents(manifest, sourceDir)\n\n debug(\n 'virtual module loaded: %s (%d files, %d nodeModules)',\n resolved.name,\n Object.keys(resolved.files).length,\n Object.keys(resolved.nodeModules || {}).length\n )\n\n return {\n code: `export default ${JSON.stringify(resolved)}`,\n moduleType: 'js'\n }\n }\n }\n}\n","/**\n * Node.js builtin → browser polyfill alias mappings.\n *\n * Shared between env.ts (host Vite config) and prebundle.ts (Worker config bundling).\n *\n * @module alias\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\n/**\n * Node.js builtin module → browser polyfill mapping.\n * Each entry maps both `node:xxx` and bare `xxx` specifiers.\n */\nconst NODE_POLYFILL_MAP: Record<string, string> = {\n events: '@vrowzer/node-polyfill/events',\n path: 'pathe',\n stream: 'readable-stream/lib/stream',\n buffer: 'buffer',\n dns: '@vrowzer/node-polyfill/dns',\n fs: '@vrowzer/fs',\n 'fs/promises': '@vrowzer/fs/promises',\n url: '@vrowzer/node-polyfill/url',\n readline: '@vrowzer/node-polyfill/readline',\n util: '@vrowzer/node-polyfill/util',\n perf_hooks: '@vrowzer/node-polyfill/perf_hooks',\n crypto: '@vrowzer/node-polyfill/crypto',\n tty: '@vrowzer/node-polyfill/tty',\n module: '@vrowzer/node-polyfill/module',\n os: '@vrowzer/node-polyfill/os',\n net: '@vrowzer/node-polyfill/net'\n}\n\n/**\n * Build a flat alias record from NODE_POLYFILL_MAP + additional aliases.\n * Generates both `node:xxx` and bare `xxx` entries for each builtin.\n *\n * @param extra - Additional alias entries to merge (e.g. `{ process: '...', 'process/': '...' }`)\n */\nexport function resolveAliases(extra?: Record<string, string>): Record<string, string> {\n const aliases: Record<string, string> = {}\n for (const [mod, polyfill] of Object.entries(NODE_POLYFILL_MAP)) {\n aliases[`node:${mod}`] = polyfill\n aliases[mod] = polyfill\n }\n if (extra) {\n Object.assign(aliases, extra)\n }\n return aliases\n}\n","/**\n * Environment plugin — Node.js polyfills, CORS headers, and Worker config\n * for browser/Worker environments.\n *\n * @module env\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { dirname, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { createDebug } from 'obug'\nimport { resolveAliases } from './alias.ts'\n\nimport type { Plugin, ResolvedConfig } from 'vite'\nimport type { ResolvedVrowzerOptions } from './options.ts'\n\nconst debug = createDebug('vite-plugin-vrowzer:env')\nexport const VROWZER_PREVIEW_BASE_PATH_DEFINE = '__VROWZER_INTERNAL_PREVIEW_BASE_PATH__'\nexport const VROWZER_SERVICE_WORKER_SCOPE_DEFINE = '__VROWZER_INTERNAL_SERVICE_WORKER_SCOPE__'\nexport const VROWZER_SERVICE_WORKER_VERSION_DEFINE = '__VROWZER_INTERNAL_SERVICE_WORKER_VERSION__'\n\n// Resolve picocolors browser version path.\n// picocolors doesn't export the browser file via package.json exports,\n// so we resolve its entry point and construct the path.\nconst picocolorsBrowser = resolve(\n dirname(fileURLToPath(import.meta.resolve('picocolors'))),\n 'picocolors.browser.js'\n)\n\nexport function envPlugin(options: ResolvedVrowzerOptions): Plugin {\n const serializedBasePath = JSON.stringify(options.basePath)\n const serializedServiceWorkerScope = JSON.stringify(options.serviceWorkerScope)\n const serializedServiceWorkerVersion = JSON.stringify(options.serviceWorkerVersion)\n return {\n name: 'vrowzer:env',\n // Rolldown native inject: inject `process` global for browser/Worker environments.\n // This replaces bare `process` references with an import from the polyfill.\n options(inputOptions) {\n inputOptions.transform ??= {}\n ;(inputOptions.transform as Record<string, unknown>).inject = {\n ...(((inputOptions.transform as Record<string, unknown>).inject as Record<\n string,\n string\n >) ?? {}),\n process: '@vrowzer/node-polyfill/process'\n }\n debug('options hook: inputOptions.transform.inject ', inputOptions.transform.inject)\n },\n config(_config, _env) {\n return {\n define: {\n 'import.meta.env.DEBUG': JSON.stringify(process.env.DEBUG || ''),\n [VROWZER_PREVIEW_BASE_PATH_DEFINE]: serializedBasePath,\n [VROWZER_SERVICE_WORKER_SCOPE_DEFINE]: serializedServiceWorkerScope,\n [VROWZER_SERVICE_WORKER_VERSION_DEFINE]: serializedServiceWorkerVersion\n },\n resolve: {\n alias: resolveAliases({\n // process needs both bare and trailing-slash aliases\n // (`require('process/')` in readable-stream/lib/internal/streams/pipeline.js)\n 'node:process': '@vrowzer/node-polyfill/process',\n 'process/': '@vrowzer/node-polyfill/process',\n process: '@vrowzer/node-polyfill/process',\n // picocolors CJS → browser version (no ANSI codes in Worker/SW)\n picocolors: picocolorsBrowser\n })\n },\n worker: {\n format: 'es'\n },\n server: {\n headers: {\n 'Service-Worker-Allowed': options.serviceWorkerScope,\n 'Cross-Origin-Opener-Policy': 'same-origin',\n 'Cross-Origin-Embedder-Policy': 'credentialless'\n }\n },\n preview: {\n headers: {\n 'Service-Worker-Allowed': options.serviceWorkerScope,\n 'Cross-Origin-Opener-Policy': 'same-origin',\n 'Cross-Origin-Embedder-Policy': 'credentialless'\n }\n }\n }\n },\n configResolved(config: ResolvedConfig) {\n const resolvedBasePath = config.define?.[VROWZER_PREVIEW_BASE_PATH_DEFINE]\n if (resolvedBasePath !== serializedBasePath) {\n throw new Error(\n `Vrowzer reserved define ${VROWZER_PREVIEW_BASE_PATH_DEFINE} must be ${serializedBasePath}, received ${JSON.stringify(resolvedBasePath)}`\n )\n }\n\n const resolvedServiceWorkerScope = config.define?.[VROWZER_SERVICE_WORKER_SCOPE_DEFINE]\n if (resolvedServiceWorkerScope !== serializedServiceWorkerScope) {\n throw new Error(\n `Vrowzer reserved define ${VROWZER_SERVICE_WORKER_SCOPE_DEFINE} must be ${serializedServiceWorkerScope}, received ${JSON.stringify(resolvedServiceWorkerScope)}`\n )\n }\n\n const resolvedServiceWorkerVersion = config.define?.[VROWZER_SERVICE_WORKER_VERSION_DEFINE]\n if (resolvedServiceWorkerVersion !== serializedServiceWorkerVersion) {\n throw new Error(\n `Vrowzer reserved define ${VROWZER_SERVICE_WORKER_VERSION_DEFINE} must be ${serializedServiceWorkerVersion}, received ${JSON.stringify(resolvedServiceWorkerVersion)}`\n )\n }\n }\n }\n}\n","/**\n * Browser IDE plugin for Vrowzer.\n *\n * When `experimental.ide` is enabled, serves a pre-built browser IDE at `/__vrowzer__/`.\n * The IDE is a self-contained Vue app with Monaco Editor, File Explorer, and Preview,\n * bundled into dist/ide/ at build time.\n *\n * Phase 3: birpc WebSocket for file sync (write-back to local FS).\n *\n * @module ide\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { dirname, extname, join, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { createBirpc } from 'birpc'\nimport { createDebug } from 'obug'\nimport { WebSocketServer } from 'ws'\n\nimport type { IncomingMessage, ServerResponse } from 'node:http'\nimport type { Plugin, ViteDevServer } from 'vite'\nimport type { WebSocket } from 'ws'\nimport type { ResolvedVrowzerOptions } from './options.ts'\nimport type { ClientFunctions, ServerFunctions } from './ide/rpc.ts'\n\nconst debug = createDebug('vite-plugin-vrowzer:ide')\n\nconst IDE_BASE = '/__vrowzer__'\nconst IDE_CLIENT_PATH = `${IDE_BASE}/client.js`\n\n// Resolve path to dist/ide/ directory (pre-built IDE assets)\nconst __dir = dirname(fileURLToPath(import.meta.url))\nconst ideDistDir = resolve(__dir, __dir.endsWith('/dist') ? 'ide' : '../dist/ide')\n\nconst MIME_TYPES: Record<string, string> = {\n '.js': 'application/javascript',\n '.mjs': 'application/javascript',\n '.css': 'text/css',\n '.html': 'text/html',\n '.json': 'application/json',\n '.svg': 'image/svg+xml',\n '.png': 'image/png',\n '.woff': 'font/woff',\n '.woff2': 'font/woff2',\n '.ttf': 'font/ttf'\n}\n\nfunction generateIdeClientCode(\n basePath: string,\n rpcPort: number,\n devtoolsUrl: string | null\n): string {\n return `\nimport { Vrowzer } from 'vrowzer'\nimport manifest from 'virtual:vrowzer-manifest'\n\n// mountIde is loaded via script tag in HTML and exposed as global\nwindow.__vrowzer_ide_mount__({\n manifest,\n basePath: '${basePath}',\n Vrowzer,\n rpcPort: ${rpcPort},\n devtoolsUrl: ${devtoolsUrl ? `'${devtoolsUrl}'` : 'null'}\n})\n`\n}\n\nfunction generateIdeHtml(base: string, cssFile: string | null): string {\n const cssLink = cssFile\n ? `<link rel=\"stylesheet\" href=\"${base}${IDE_BASE.slice(1)}/dist/${cssFile}\" />`\n : ''\n\n return `<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Vrowzer IDE</title>\n ${cssLink}\n <style>\n * { margin: 0; padding: 0; box-sizing: border-box; }\n html, body, #app { height: 100%; }\n body { font-family: system-ui, -apple-system, sans-serif; overflow: hidden; }\n </style>\n</head>\n<body>\n <div id=\"app\"></div>\n <script type=\"module\" src=\"${base}${IDE_BASE.slice(1)}/dist/ide.js\"></script>\n <script type=\"module\" src=\"${base}${IDE_BASE.slice(1)}/client.js\"></script>\n</body>\n</html>`\n}\n\nfunction findAvailablePort(preferredPort?: number): Promise<number> {\n return new Promise((resolve, reject) => {\n const { createServer } = require('node:net') as typeof import('node:net')\n const server = createServer()\n const port = preferredPort ?? 7900\n server.listen(port, () => {\n server.close(() => resolve(port))\n })\n server.on('error', () => {\n // Port in use, try next\n server.close()\n const next = createServer()\n next.listen(0, () => {\n const addr = next.address()\n const p = typeof addr === 'object' && addr ? addr.port : 0\n next.close(() => resolve(p))\n })\n next.on('error', reject)\n })\n })\n}\n\nexport function idePlugin(options: ResolvedVrowzerOptions): Plugin {\n let viteBase = '/'\n let ideCssFile: string | null = null\n let rpcPort = 0\n let projectRoot = ''\n let sourceDir = ''\n let devtoolsUrl: string | null = null\n\n // Find the CSS file in dist/ide/\n if (existsSync(ideDistDir)) {\n try {\n const files = readdirSync(ideDistDir)\n ideCssFile = files.find(f => f.endsWith('.css')) ?? null\n } catch {\n // ignore\n }\n }\n\n return {\n name: 'vrowzer:ide',\n apply: 'serve',\n async configResolved(config) {\n viteBase = config.base || '/'\n projectRoot = config.root\n sourceDir = options.manifest?.sourceDir\n ? resolve(projectRoot, options.manifest.sourceDir)\n : projectRoot\n\n // Find available port for birpc WebSocket\n rpcPort = await findAvailablePort(options.ide.port)\n debug('RPC port:', rpcPort)\n\n // Detect DevTools plugin\n if (options.ide.devtools) {\n const hasDevTools = config.plugins.some((p: any) => p.name === 'vite:devtools:server')\n if (hasDevTools) {\n devtoolsUrl = '/.devtools/'\n debug('DevTools detected, URL:', devtoolsUrl)\n }\n }\n },\n resolveId(id) {\n if (id === IDE_CLIENT_PATH) {\n return id\n }\n },\n load(id) {\n if (id === IDE_CLIENT_PATH) {\n return generateIdeClientCode(options.basePath, rpcPort, devtoolsUrl)\n }\n },\n configureServer(server: ViteDevServer) {\n const ideUrl = `${IDE_BASE}/`\n\n // --- COEP headers for DevTools iframe ---\n // DevTools serves at /.devtools/, /.devtools-rolldown/, /.devtools-vite/, etc.\n if (devtoolsUrl) {\n server.middlewares.use((req: any, res: any, next: any) => {\n const url = req.url ?? ''\n if (url.startsWith('/.devtools')) {\n const originalWriteHead = res.writeHead.bind(res)\n res.writeHead = function (statusCode: number, ...args: any[]) {\n res.setHeader('Cross-Origin-Embedder-Policy', 'credentialless')\n res.setHeader('Cross-Origin-Opener-Policy', 'same-origin')\n return originalWriteHead(statusCode, ...args)\n } as typeof res.writeHead\n }\n next()\n })\n debug('COEP middleware added for /.devtools*')\n }\n\n // --- birpc WebSocket server ---\n const wss = new WebSocketServer({ port: rpcPort })\n debug('birpc WebSocket server listening on port', rpcPort)\n\n wss.on('connection', (ws: WebSocket) => {\n debug('IDE client connected')\n\n const rpc = createBirpc<ClientFunctions, ServerFunctions>(\n {\n async writeFile(path: string, content: string) {\n const absPath = resolve(sourceDir, path.startsWith('/') ? path.slice(1) : path)\n debug('writeFile:', absPath)\n writeFileSync(absPath, content, 'utf-8')\n }\n },\n {\n post: data => ws.send(data),\n on: handler => ws.on('message', handler),\n serialize: v => JSON.stringify(v),\n deserialize: v => JSON.parse(String(v))\n }\n )\n\n // Watch for file changes from external editors (chokidar via Vite's watcher)\n const watcher = server.watcher\n const onFileChange = (filePath: string) => {\n // Only notify for source files within sourceDir, not node_modules\n if (filePath.startsWith(sourceDir) && !filePath.includes('node_modules')) {\n const relPath = '/' + filePath.slice(sourceDir.length + 1).replace(/\\\\/g, '/')\n try {\n const content = readFileSync(filePath, 'utf-8')\n debug('external file change:', relPath)\n rpc.onFileChanged(relPath, content)\n } catch {\n // file might have been deleted\n }\n }\n }\n\n watcher.on('change', onFileChange)\n\n ws.on('close', () => {\n debug('IDE client disconnected')\n watcher.off('change', onFileChange)\n })\n })\n\n // Clean up WebSocket server when Vite server closes\n server.httpServer?.on('close', () => {\n wss.close()\n debug('birpc WebSocket server closed')\n })\n\n // Print IDE URL after server start\n server.httpServer?.once('listening', () => {\n const info = server.config.server\n const protocol = info.https ? 'https' : 'http'\n const host = typeof info.host === 'string' ? info.host : 'localhost'\n const port = info.port || 5173\n setTimeout(() => {\n server.config.logger.info(\n ` \\x1b[36m➜\\x1b[0m \\x1b[1mVrowzer IDE\\x1b[0m: \\x1b[36m${protocol}://${host}:${port}${ideUrl}\\x1b[0m`\n )\n }, 100)\n })\n\n // Serve IDE at /__vrowzer__/\n server.middlewares.use((req: IncomingMessage, res: ServerResponse, next: () => void) => {\n const url = req.url ?? ''\n\n // Serve IDE HTML\n if (url === IDE_BASE || url === ideUrl) {\n debug('serving IDE HTML')\n res.writeHead(200, {\n 'Content-Type': 'text/html; charset=utf-8',\n 'Cross-Origin-Opener-Policy': 'same-origin',\n 'Cross-Origin-Embedder-Policy': 'credentialless'\n })\n res.end(generateIdeHtml(viteBase, ideCssFile))\n return\n }\n\n // Serve IDE static assets from dist/ide/\n if (url.startsWith(`${IDE_BASE}/dist/`)) {\n const assetName = url.slice(`${IDE_BASE}/dist/`.length)\n const assetPath = join(ideDistDir, assetName)\n\n if (existsSync(assetPath)) {\n const ext = extname(assetName)\n const mime = MIME_TYPES[ext] || 'application/octet-stream'\n debug('serving IDE asset:', assetName)\n res.writeHead(200, {\n 'Content-Type': mime,\n 'Cross-Origin-Opener-Policy': 'same-origin',\n 'Cross-Origin-Embedder-Policy': 'credentialless',\n 'Cache-Control': 'no-cache'\n })\n res.end(readFileSync(assetPath))\n return\n }\n }\n\n next()\n })\n }\n }\n}\n","/**\n * Static analysis of vite.config.ts for Worker plugin extraction.\n *\n * Parses the user's vite.config.ts with OXC (via rolldown/experimental),\n * removes Vrowzer() calls and their imports,\n * and generates a Worker-compatible config source.\n *\n * @module extract\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { parseSync } from 'rolldown/utils'\nimport { createDebug } from 'obug'\n\nimport type {\n ArrayExpression,\n CallExpression,\n ExportDefaultDeclaration,\n Expression,\n ImportDeclaration,\n ObjectExpression,\n ObjectProperty,\n Program\n} from '@oxc-project/types'\n\nconst debug = createDebug('vite-plugin-vrowzer:extract')\n\nexport interface ExtractOptions {\n /** Resolved server origin to forward to the Worker config. */\n serverOrigin?: string | undefined\n /** Host-resolved forward-console options to forward to the Worker config. */\n serverForwardConsole?:\n | {\n enabled: boolean\n unhandledErrors: boolean\n logLevels: readonly string[]\n }\n | undefined\n}\n\nexport interface ExtractResult {\n code: string\n unsupported: string[]\n}\n\ninterface PluginCallInfo {\n calleeName: string\n importSource: string | null\n start: number\n end: number\n hasArgs: boolean\n}\n\ninterface ImportInfo {\n source: string\n localName: string\n importedName: string | null // null = default, '*' = namespace\n start: number\n end: number\n isTypeOnly: boolean\n}\n\n/**\n * Packages that should be excluded from Worker config.\n * These are host-only plugins that cannot run in Web Worker.\n */\nconst WORKER_EXCLUDED_SOURCES = [\n '@vrowzer/vite-plugin',\n '@vrowzer/vite-plugin/config',\n '@vitejs/devtools'\n]\n\n/**\n * Check if an import source should be excluded from Worker config.\n */\nexport function isWorkerExcludedImport(source: string): boolean {\n return WORKER_EXCLUDED_SOURCES.some(s => source === s || source.startsWith(`${s}/`))\n}\n\n/**\n * Check if an import source is from Vite (should be excluded from Worker config).\n */\nfunction isViteImport(source: string): boolean {\n return source === 'vite' || source.startsWith('vite/')\n}\n\n/**\n * Extract Worker config source from vite.config.ts.\n *\n * 1. Parse the source with OXC\n * 2. Collect all imports\n * 3. Find `export default defineConfig(...)` or `export default { ... }`\n * 4. Extract plugins array\n * 5. Remove Vrowzer() calls\n * 6. Generate Worker config source\n */\nexport function extractWorkerConfig(\n source: string,\n configPath: string,\n options: ExtractOptions = {}\n): ExtractResult {\n const unsupported: string[] = []\n\n const result = parseSync(configPath, source)\n const ast = result.program as Program\n\n // 1. Collect imports\n const imports = collectImports(ast)\n debug(\n 'imports',\n imports.map(i => `${i.localName} from ${i.source}`)\n )\n\n // 2. Find export default\n const exportDefault = ast.body.find(\n (n): n is ExportDefaultDeclaration => n.type === 'ExportDefaultDeclaration'\n )\n if (!exportDefault) {\n return { code: generateFallbackCode(), unsupported: ['no export default found'] }\n }\n\n // 3. Find the config object (unwrap defineConfig() if present)\n const configObj = unwrapDefineConfig(exportDefault.declaration as Expression)\n if (!configObj || configObj.type !== 'ObjectExpression') {\n return { code: generateFallbackCode(), unsupported: ['config is not an object expression'] }\n }\n\n // 4. Find plugins array\n const pluginsProp = (configObj as ObjectExpression).properties.find(\n (p): p is ObjectProperty =>\n p.type === 'Property' && p.key.type === 'Identifier' && p.key.name === 'plugins'\n )\n if (!pluginsProp || pluginsProp.value.type !== 'ArrayExpression') {\n return { code: generateFallbackCode(), unsupported: ['plugins is not an array'] }\n }\n\n const pluginsArray = pluginsProp.value as ArrayExpression\n\n // 5. Analyze each plugin element\n const pluginCalls: PluginCallInfo[] = []\n for (const element of pluginsArray.elements) {\n if (element === null) {\n continue\n }\n\n if (element.type === 'SpreadElement') {\n unsupported.push(`spread element: ${source.slice(element.start, element.end)}`)\n continue\n }\n\n const expr = element as Expression\n if (expr.type === 'CallExpression') {\n const info = analyzeCallExpression(expr as CallExpression, imports)\n if (info) {\n pluginCalls.push(info)\n } else {\n unsupported.push(`unanalyzable call: ${source.slice(expr.start, expr.end)}`)\n }\n } else if (expr.type === 'ConditionalExpression' || expr.type === 'LogicalExpression') {\n unsupported.push(`conditional plugin: ${source.slice(expr.start, expr.end)}`)\n } else {\n // Identifier or other - try to resolve\n unsupported.push(`non-call plugin: ${source.slice(expr.start, expr.end)}`)\n }\n }\n\n // 6. Filter out Vrowzer plugins\n const workerPlugins = pluginCalls.filter(p => {\n if (!p.importSource) {\n return true\n } // local function - keep\n return !isWorkerExcludedImport(p.importSource)\n })\n debug(\n 'workerPlugins',\n workerPlugins.map(p => p.calleeName)\n )\n\n // 7. Determine which imports are needed\n const neededImportSources = new Set<string>()\n const neededLocalNames = new Set<string>()\n for (const plugin of workerPlugins) {\n if (plugin.importSource) {\n neededImportSources.add(plugin.importSource)\n }\n neededLocalNames.add(plugin.calleeName)\n }\n\n // Collect imports needed for plugin arguments (scan argument source for identifiers)\n for (const plugin of workerPlugins) {\n if (plugin.hasArgs) {\n const argSource = source.slice(plugin.start, plugin.end)\n for (const imp of imports) {\n if (imp.isTypeOnly) {\n continue\n }\n if (isViteImport(imp.source)) {\n continue\n }\n if (isWorkerExcludedImport(imp.source)) {\n continue\n }\n // Check if the import's local name appears in the argument source\n if (argSource.includes(imp.localName)) {\n neededImportSources.add(imp.source)\n neededLocalNames.add(imp.localName)\n }\n }\n }\n }\n\n // 8. Also include imports for non-imported local function plugins\n // (functions defined in the config file itself need their dependency imports\n // and dependent variable declarations)\n const localPluginNames = workerPlugins.filter(p => !p.importSource).map(p => p.calleeName)\n if (localPluginNames.length > 0) {\n // Collect local function sources\n const localFuncSources: string[] = []\n for (const stmt of ast.body) {\n if (stmt.type === 'FunctionDeclaration' && stmt.id) {\n const funcName = (stmt.id as { name: string }).name\n if (localPluginNames.includes(funcName)) {\n localFuncSources.push(source.slice(stmt.start, stmt.end))\n }\n }\n }\n\n // Scan function bodies for import references\n for (const funcSource of localFuncSources) {\n for (const imp of imports) {\n if (imp.isTypeOnly) {\n continue\n }\n if (isViteImport(imp.source)) {\n continue\n }\n if (isWorkerExcludedImport(imp.source)) {\n continue\n }\n if (funcSource.includes(imp.localName)) {\n neededImportSources.add(imp.source)\n neededLocalNames.add(imp.localName)\n }\n }\n }\n\n // Find variable declarations referenced by local functions and their import deps\n for (const stmt of ast.body) {\n if (stmt.type !== 'VariableDeclaration') {\n continue\n }\n for (const decl of (stmt as any).declarations) {\n if (!decl.id?.name) {\n continue\n }\n const varName = decl.id.name as string\n if (localPluginNames.includes(varName)) {\n continue\n } // skip plugin fn declarations\n const isUsedByLocalFunc = localFuncSources.some(funcSrc => funcSrc.includes(varName))\n if (isUsedByLocalFunc) {\n // This variable is needed — scan its init for import references\n const varSource = source.slice(stmt.start, stmt.end)\n for (const imp of imports) {\n if (imp.isTypeOnly) {\n continue\n }\n if (isViteImport(imp.source)) {\n continue\n }\n if (isWorkerExcludedImport(imp.source)) {\n continue\n }\n if (varSource.includes(imp.localName)) {\n neededImportSources.add(imp.source)\n neededLocalNames.add(imp.localName)\n }\n }\n }\n }\n }\n }\n\n // 8b. Find top-level config properties to forward (define, etc.)\n const forwardedProps = extractForwardedProperties(source, configObj as ObjectExpression)\n extractInputProperties(source, configObj as ObjectExpression, forwardedProps, unsupported)\n const forwardedServerProps: string[] = []\n if (options.serverOrigin !== undefined) {\n forwardedServerProps.push(`origin: ${JSON.stringify(options.serverOrigin)}`)\n }\n if (options.serverForwardConsole !== undefined) {\n forwardedServerProps.push(`forwardConsole: ${JSON.stringify(options.serverForwardConsole)}`)\n }\n if (forwardedServerProps.length > 0) {\n forwardedProps.set('server', `{ ${forwardedServerProps.join(', ')} }`)\n }\n\n if (unsupported.length > 0) {\n debug('unsupported patterns', unsupported)\n }\n\n // 9. Generate Worker config source\n const code = generateWorkerSource(\n source,\n ast,\n imports,\n workerPlugins,\n neededImportSources,\n neededLocalNames,\n forwardedProps\n )\n\n return { code, unsupported }\n}\n\n/**\n * Config properties that should be forwarded to Worker config.\n * These are extracted as raw source code from the config object.\n */\nconst FORWARDED_PROPERTIES = ['define', 'html']\n\nfunction extractForwardedProperties(\n source: string,\n configObj: ObjectExpression\n): Map<string, string> {\n const props = new Map<string, string>()\n for (const p of configObj.properties) {\n if (p.type !== 'Property') {\n continue\n }\n const key = p.key.type === 'Identifier' ? p.key.name : null\n if (key && FORWARDED_PROPERTIES.includes(key)) {\n props.set(key, source.slice(p.value.start, p.value.end))\n }\n }\n return props\n}\n\nfunction extractInputProperties(\n source: string,\n configObj: ObjectExpression,\n forwardedProps: Map<string, string>,\n unsupported: string[]\n): void {\n let hasUnknownTopLevelInput = false\n for (const property of configObj.properties) {\n if (property.type === 'SpreadElement') {\n unsupported.push(`config spread element: ${source.slice(property.start, property.end)}`)\n hasUnknownTopLevelInput = true\n } else if (property.type === 'Property' && property.computed) {\n unsupported.push(`computed config key: ${source.slice(property.start, property.end)}`)\n hasUnknownTopLevelInput = true\n }\n }\n if (hasUnknownTopLevelInput) {\n return\n }\n\n const inputProp = findObjectProperty(configObj, 'input')\n if (inputProp) {\n if (isStaticInputOption(inputProp.value as Expression)) {\n forwardedProps.set('input', source.slice(inputProp.value.start, inputProp.value.end))\n } else {\n unsupported.push(\n `input is not an inline string, array, or record: ${source.slice(inputProp.value.start, inputProp.value.end)}`\n )\n }\n }\n\n const environmentsProp = findObjectProperty(configObj, 'environments')\n if (!environmentsProp) {\n return\n }\n\n const environmentsValue = unwrapStaticExpression(environmentsProp.value as Expression)\n if (environmentsValue.type !== 'ObjectExpression') {\n unsupported.push(\n `environments is not an inline object: ${source.slice(environmentsProp.value.start, environmentsProp.value.end)}`\n )\n return\n }\n\n const entries: string[] = []\n let hasUnknownEnvironment = false\n for (const environmentProp of environmentsValue.properties) {\n if (environmentProp.type === 'SpreadElement') {\n unsupported.push(\n `environment spread element: ${source.slice(environmentProp.start, environmentProp.end)}`\n )\n hasUnknownEnvironment = true\n continue\n }\n if (environmentProp.type !== 'Property') {\n continue\n }\n\n const environmentName = getStaticPropertyName(environmentProp)\n if (environmentName === null) {\n unsupported.push(\n `computed environment key: ${source.slice(environmentProp.start, environmentProp.end)}`\n )\n hasUnknownEnvironment = true\n continue\n }\n\n const environmentValue = unwrapStaticExpression(environmentProp.value as Expression)\n if (environmentValue.type !== 'ObjectExpression') {\n unsupported.push(\n `environment ${JSON.stringify(environmentName)} is not an inline object: ${source.slice(environmentProp.value.start, environmentProp.value.end)}`\n )\n continue\n }\n\n let hasUnknownEnvironmentInput = false\n for (const property of environmentValue.properties) {\n if (property.type === 'SpreadElement') {\n unsupported.push(\n `environment ${JSON.stringify(environmentName)} spread element: ${source.slice(property.start, property.end)}`\n )\n hasUnknownEnvironmentInput = true\n } else if (property.type === 'Property' && property.computed) {\n unsupported.push(\n `environment ${JSON.stringify(environmentName)} has a computed key: ${source.slice(property.start, property.end)}`\n )\n hasUnknownEnvironmentInput = true\n }\n }\n if (hasUnknownEnvironmentInput) {\n continue\n }\n\n const input = findObjectProperty(environmentValue, 'input')\n if (!input) {\n continue\n }\n if (!isStaticInputOption(input.value as Expression)) {\n unsupported.push(\n `environment ${JSON.stringify(environmentName)} input is not an inline string, array, or record: ${source.slice(input.value.start, input.value.end)}`\n )\n continue\n }\n\n entries.push(\n `${JSON.stringify(environmentName)}: { input: ${source.slice(input.value.start, input.value.end)} }`\n )\n }\n\n if (entries.length > 0 && !hasUnknownEnvironment) {\n forwardedProps.set('environments', `{ ${entries.join(', ')} }`)\n }\n}\n\nfunction findObjectProperty(object: ObjectExpression, name: string): ObjectProperty | undefined {\n for (let index = object.properties.length - 1; index >= 0; index--) {\n const property = object.properties[index]\n if (!property || property.type !== 'Property') {\n continue\n }\n if (!property.computed && getPropertyName(property) === name) {\n return property\n }\n }\n return undefined\n}\n\nfunction getStaticPropertyName(property: ObjectProperty): string | null {\n if (property.computed) {\n return null\n }\n return getPropertyName(property)\n}\n\nfunction getPropertyName(property: ObjectProperty): string | null {\n if (property.key.type === 'Identifier') {\n return property.key.name\n }\n if (property.key.type === 'Literal' && typeof property.key.value === 'string') {\n return property.key.value\n }\n return null\n}\n\nfunction unwrapStaticExpression(expression: Expression): Expression {\n let current = expression as Expression & {\n expression?: Expression\n }\n while (\n current.expression &&\n (current.type === 'ParenthesizedExpression' ||\n current.type === 'TSAsExpression' ||\n current.type === 'TSSatisfiesExpression' ||\n current.type === 'TSNonNullExpression')\n ) {\n current = current.expression as typeof current\n }\n return current\n}\n\nfunction isStaticInputOption(expression: Expression): boolean {\n const value = unwrapStaticExpression(expression)\n if (isStaticString(value)) {\n return true\n }\n if (value.type === 'ArrayExpression') {\n return value.elements.every(\n element =>\n element !== null &&\n element.type !== 'SpreadElement' &&\n isStaticString(element as Expression)\n )\n }\n if (value.type === 'ObjectExpression') {\n return value.properties.every(\n property =>\n property.type === 'Property' &&\n !property.computed &&\n isStaticString(property.value as Expression)\n )\n }\n return false\n}\n\nfunction isStaticString(expression: Expression): boolean {\n const value = unwrapStaticExpression(expression)\n return (\n (value.type === 'Literal' && typeof value.value === 'string') ||\n (value.type === 'TemplateLiteral' && value.expressions.length === 0)\n )\n}\n\nfunction collectImports(ast: Program): ImportInfo[] {\n const imports: ImportInfo[] = []\n for (const node of ast.body) {\n if (node.type !== 'ImportDeclaration') {\n continue\n }\n const decl = node as ImportDeclaration\n const source = decl.source.value\n const isTypeOnly = decl.importKind === 'type'\n\n for (const spec of decl.specifiers) {\n if (spec.type === 'ImportDefaultSpecifier') {\n imports.push({\n source,\n localName: spec.local.name,\n importedName: null,\n start: decl.start,\n end: decl.end,\n isTypeOnly\n })\n } else if (spec.type === 'ImportSpecifier') {\n const importedName =\n spec.imported.type === 'Identifier' ? spec.imported.name : spec.imported.value\n imports.push({\n source,\n localName: spec.local.name,\n importedName,\n start: decl.start,\n end: decl.end,\n isTypeOnly: isTypeOnly || spec.importKind === 'type'\n })\n } else if (spec.type === 'ImportNamespaceSpecifier') {\n imports.push({\n source,\n localName: spec.local.name,\n importedName: '*',\n start: decl.start,\n end: decl.end,\n isTypeOnly\n })\n }\n }\n }\n return imports\n}\n\nfunction unwrapDefineConfig(expr: Expression): Expression | null {\n if (expr.type === 'CallExpression') {\n const call = expr as CallExpression\n if (\n call.callee.type === 'Identifier' &&\n (call.callee as { name: string }).name === 'defineConfig'\n ) {\n return call.arguments[0] as Expression | null\n }\n }\n if (expr.type === 'ObjectExpression') {\n return expr\n }\n return null\n}\n\nfunction analyzeCallExpression(call: CallExpression, imports: ImportInfo[]): PluginCallInfo | null {\n let calleeName: string | null = null\n\n if (call.callee.type === 'Identifier') {\n calleeName = (call.callee as { name: string }).name\n }\n\n if (!calleeName) {\n return null\n }\n\n // Find matching import\n const matchingImport = imports.find(i => i.localName === calleeName && !i.isTypeOnly)\n\n return {\n calleeName,\n importSource: matchingImport?.source ?? null,\n start: call.start,\n end: call.end,\n hasArgs: call.arguments.length > 0\n }\n}\n\nfunction generateWorkerSource(\n source: string,\n ast: Program,\n imports: ImportInfo[],\n plugins: PluginCallInfo[],\n neededImportSources: Set<string>,\n neededLocalNames: Set<string>,\n forwardedProps: Map<string, string> = new Map()\n): string {\n const lines: string[] = []\n\n // Emit needed imports (excluding Vrowzer, Vite, type-only)\n const emittedSources = new Set<string>()\n for (const imp of imports) {\n if (imp.isTypeOnly) {\n continue\n }\n if (isViteImport(imp.source)) {\n continue\n }\n if (isWorkerExcludedImport(imp.source)) {\n continue\n }\n if (!neededImportSources.has(imp.source)) {\n continue\n }\n if (!neededLocalNames.has(imp.localName)) {\n continue\n }\n if (emittedSources.has(`${imp.source}:${imp.localName}`)) {\n continue\n }\n emittedSources.add(`${imp.source}:${imp.localName}`)\n\n // Group imports from the same source\n // For simplicity, emit individual import statements\n if (imp.importedName === null) {\n // default import\n lines.push(`import ${imp.localName} from '${imp.source}'`)\n } else if (imp.importedName === '*') {\n // namespace import\n lines.push(`import * as ${imp.localName} from '${imp.source}'`)\n } else if (imp.importedName === imp.localName) {\n lines.push(`import { ${imp.localName} } from '${imp.source}'`)\n } else {\n lines.push(`import { ${imp.importedName} as ${imp.localName} } from '${imp.source}'`)\n }\n }\n\n // Emit local function definitions and their dependent variable declarations\n const localPluginNames = plugins.filter(p => !p.importSource).map(p => p.calleeName)\n\n // Collect local function sources to scan for variable references\n const localFuncSources: string[] = []\n for (const stmt of ast.body) {\n if (stmt.type === 'FunctionDeclaration' && stmt.id) {\n const funcName = (stmt.id as { name: string }).name\n if (localPluginNames.includes(funcName)) {\n localFuncSources.push(source.slice(stmt.start, stmt.end))\n }\n }\n }\n\n // Find variable declarations referenced by local functions\n const emittedVarNames = new Set<string>()\n for (const stmt of ast.body) {\n if (stmt.type !== 'VariableDeclaration') {\n continue\n }\n for (const decl of (stmt as any).declarations) {\n if (!decl.id?.name) {\n continue\n }\n const varName = decl.id.name as string\n // Check if any local function references this variable\n const isUsedByLocalFunc = localFuncSources.some(funcSrc => funcSrc.includes(varName))\n if (isUsedByLocalFunc && !localPluginNames.includes(varName)) {\n if (!emittedVarNames.has(varName)) {\n emittedVarNames.add(varName)\n lines.push('')\n lines.push(source.slice(stmt.start, stmt.end))\n\n // Also include imports used by this variable declaration\n const varSource = source.slice(stmt.start, stmt.end)\n for (const imp of imports) {\n if (imp.isTypeOnly) {\n continue\n }\n if (isViteImport(imp.source)) {\n continue\n }\n if (isWorkerExcludedImport(imp.source)) {\n continue\n }\n if (varSource.includes(imp.localName)) {\n neededImportSources.add(imp.source)\n neededLocalNames.add(imp.localName)\n }\n }\n }\n break\n }\n }\n }\n\n // Emit local function definitions\n for (const stmt of ast.body) {\n if (stmt.type === 'FunctionDeclaration' && stmt.id) {\n const funcName = (stmt.id as { name: string }).name\n if (localPluginNames.includes(funcName)) {\n lines.push('')\n lines.push(source.slice(stmt.start, stmt.end))\n }\n }\n // Also handle variable declarations that define plugin functions\n if (stmt.type === 'VariableDeclaration') {\n for (const decl of (stmt as any).declarations) {\n if (decl.id?.name && localPluginNames.includes(decl.id.name)) {\n lines.push('')\n lines.push(source.slice(stmt.start, stmt.end))\n break\n }\n }\n }\n }\n\n // Generate plugins array\n lines.push('')\n lines.push('export default {')\n lines.push(' plugins: [')\n\n for (const plugin of plugins) {\n const callSource = source.slice(plugin.start, plugin.end)\n lines.push(` ${callSource},`)\n }\n\n lines.push(' ],')\n\n // Emit forwarded properties (define, etc.)\n for (const [key, value] of forwardedProps) {\n lines.push(` ${key}: ${value},`)\n }\n\n lines.push('}')\n\n return lines.join('\\n')\n}\n\nfunction generateFallbackCode(): string {\n return 'export default { plugins: [] }'\n}\n","/**\n * vite-plugin-vrowzer options\n *\n * @module options\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { fileURLToPath } from 'node:url'\n\nconst DEFAULT_BASE_PATH = '/__preview__/'\nconst DEFAULT_SERVICE_WORKER_VERSION = 'vrowzer-v1'\n\nexport interface Alias {\n find: string | RegExp\n replacement: string\n}\n\nexport interface VrowzerManifestOptions {\n /**\n * Directory to scan for project source files (index.html, src/, public/).\n * When the host page and preview content are in different directories,\n * set this to the preview content directory.\n *\n * Resolved relative to Vite's project root.\n *\n * @default Vite project root\n */\n sourceDir?: string\n /**\n * Package directory for node_modules resolution.\n * Defaults to sourceDir.\n */\n pkgDir?: string\n /**\n * Package name(s) to include in nodeModules.\n * When specified, only these packages (+ their transitive deps) are included.\n * When omitted, all dependencies are included.\n */\n targets?: string[]\n}\n\nexport interface VrowzerIdeOptions {\n /**\n * Port for the birpc WebSocket server.\n * @default auto (find available port)\n */\n port?: number\n}\n\nexport interface VrowzerExperimentalOptions {\n /**\n * Enable browser IDE at `/__vrowzer__/`.\n *\n * When `true` or an options object, the plugin serves a browser-based IDE\n * with Monaco Editor, File Explorer, and Preview at `/__vrowzer__/`.\n *\n * @default false (disabled)\n */\n ide?: boolean | VrowzerIdeOptions\n /**\n * Enable Vite DevTools panel in IDE.\n *\n * Requires `@vitejs/devtools` to be installed and configured\n * in `vite.config.ts` (with injection plugin excluded).\n *\n * @default false\n */\n devtools?: boolean\n}\n\nexport interface VrowzerOptions {\n /**\n * Enable auto-generation of vrowzer manifest.\n *\n * When `true` (default), the plugin automatically generates the manifest from\n * the project's package.json dependencies in `configResolved`. The manifest is\n * cached in `node_modules/.vrowzer-manifest/` and provided via the\n * `virtual:vrowzer-manifest` virtual module.\n *\n * When `false`, use `VrowzerManifest()` plugin with a manually created\n * `vrowzer-manifest.json` file (e.g. via `gen:manifest`).\n *\n * @default true\n */\n auto?: boolean\n /**\n * Auto manifest generation options (used when auto: true).\n */\n manifest?: VrowzerManifestOptions\n /**\n * The base path for the preview system location, which is used to serve the preview files via service worker of Vrowzer.\n * This is the source of truth for both the application and Service Worker bundles.\n *\n * @default '/__preview__/'\n */\n basePath?: string\n /**\n * The scope for the service worker of Vrowzer, which determines the range of URLs that\n * the service worker will control and the `Service-Worker-Allowed` response header.\n * The value is injected into the Vrowzer runtime, so its corresponding option can be\n * omitted. This registration scope is independent of the preview `basePath`.\n *\n * @default '/' (the entire origin)\n */\n serviceWorkerScope?: string\n /**\n * The version of the service worker for Vrowzer, which can be used to manage updates and cache invalidation for the preview system.\n * This is the source of truth for both the application and Service Worker bundles.\n *\n * @default 'vrowzer-v1'\n */\n serviceWorkerVersion?: string\n /**\n * Explicit Service Worker entry file path.\n * When specified, `unplugin-service-worker` will bundle this file directly\n * instead of scanning source code for `createSvcWorkerController()` calls.\n *\n * This is required when using a library-provided Service Worker (e.g. `vrowzer/service-worker`)\n * that is in `node_modules` and excluded from code scanning.\n *\n * @example 'vrowzer/service-worker'\n * @default Resolved path to 'vrowzer/service-worker' (node_modules/vrowzer/dist/service-worker.ts)\n */\n serviceWorkerEntry?: string\n /**\n * Worker-specific resolve settings (e.g. vendor aliases).\n * These are NOT added to the host Vite config (which would break host package resolution),\n * but are passed to the Worker's internal Vite dev server.\n *\n * @example { alias: [{ find: 'vue', replacement: '/vendor/vue.js' }] }\n * @default undefined\n */\n resolve?: { alias?: Alias[] }\n /**\n * Experimental features.\n */\n experimental?: VrowzerExperimentalOptions\n}\n\nexport interface ResolvedIdeOptions {\n enabled: boolean\n port: number | undefined\n devtools: boolean\n}\n\nexport interface ResolvedVrowzerOptions {\n auto: boolean\n manifest: VrowzerManifestOptions | undefined\n ide: ResolvedIdeOptions\n basePath: string\n serviceWorkerScope: string\n serviceWorkerVersion: string\n serviceWorkerEntry: string\n resolve: { alias?: Alias[] } | undefined\n}\n\nfunction resolveDefaultServiceWorkerEntry(): string {\n try {\n return fileURLToPath(import.meta.resolve('vrowzer/service-worker'))\n } catch {\n return ''\n }\n}\n\nfunction normalizeBasePath(basePath: string): string {\n if (\n basePath.length === 0 ||\n !basePath.startsWith('/') ||\n basePath.startsWith('//') ||\n basePath.includes('?') ||\n basePath.includes('#')\n ) {\n throw new TypeError(\n `Vrowzer basePath must be a non-root absolute pathname without a query or hash, received ${JSON.stringify(basePath)}`\n )\n }\n\n const pathname = basePath.replace(/\\/+$/, '')\n if (pathname.length === 0) {\n throw new TypeError('Vrowzer basePath must not be the origin root \"/\"')\n }\n\n return `${pathname}/`\n}\n\nexport function resolveOptions(options: VrowzerOptions): ResolvedVrowzerOptions {\n const ide = options.experimental?.ide\n return {\n auto: options.auto ?? true,\n manifest: options.manifest,\n ide: {\n enabled: !!ide,\n port: typeof ide === 'object' ? ide.port : undefined,\n devtools: options.experimental?.devtools ?? false\n },\n basePath: normalizeBasePath(options.basePath ?? DEFAULT_BASE_PATH),\n serviceWorkerScope: options.serviceWorkerScope ?? '/',\n serviceWorkerVersion: options.serviceWorkerVersion ?? DEFAULT_SERVICE_WORKER_VERSION,\n serviceWorkerEntry: options.serviceWorkerEntry ?? resolveDefaultServiceWorkerEntry(),\n resolve: options.resolve\n }\n}\n","/**\n * Pre-bundle Worker config using rolldown.\n *\n * Takes the extracted Worker source from extract.ts and bundles it\n * into node_modules/.vrowzer/ for Worker consumption.\n *\n * @module prebundle\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { createRequire as nodeCreateRequire } from 'node:module'\nimport { rolldown } from 'rolldown'\nimport { createDebug } from 'obug'\nimport { resolveAliases } from './alias.ts'\n\nimport type { Plugin as RolldownPlugin } from 'rolldown'\n\nconst debug = createDebug('vite-plugin-vrowzer:prebundle')\n\nexport interface PrebundleOptions {\n /** Generated Worker config source code */\n workerSource: string\n /** Project root directory */\n root: string\n /** Directory of the original vite.config.ts (for resolving import.meta.dirname) */\n configDir: string\n}\n\nconst OUTPUT_DIR_NAME = '.vrowzer'\nconst BUNDLED_FILENAME = 'config.bundled.mjs'\n\n/**\n * Resolve the output directory path for prebundled Worker config.\n */\nexport function resolveOutputDir(root: string): string {\n return resolve(root, 'node_modules', OUTPUT_DIR_NAME)\n}\n\n/**\n * Remove the prebundle output directory.\n */\nexport function cleanOutputDir(root: string): void {\n const outputDir = resolveOutputDir(root)\n if (existsSync(outputDir)) {\n rmSync(outputDir, { recursive: true })\n debug('cleaned output dir:', outputDir)\n }\n}\n\n/**\n * Pre-bundle Worker config source using rolldown.\n *\n * @returns Absolute path to the bundled config file.\n */\nexport async function prebundleWorkerConfig(options: PrebundleOptions): Promise<string> {\n const { workerSource, root, configDir } = options\n const outputDir = resolveOutputDir(root)\n const bundledPath = resolve(outputDir, BUNDLED_FILENAME)\n\n debug('prebundling worker config...')\n\n // Ensure output directory exists\n mkdirSync(outputDir, { recursive: true })\n\n // Write temporary entry file (.mts for TypeScript support — rolldown handles TS natively)\n const entryPath = resolve(outputDir, '_entry.mts')\n writeFileSync(entryPath, workerSource)\n\n // Bundle with rolldown\n const bundle = await rolldown({\n input: entryPath,\n external: [new RegExp('^@vrowzer/'), 'assert', 'v8'],\n // Define process.env.NODE_ENV so plugin code doesn't need runtime process global\n transform: {\n define: {\n 'process.env.NODE_ENV': JSON.stringify('development'),\n global: 'globalThis'\n },\n inject: {\n process: '@vrowzer/node-polyfill/process'\n }\n },\n // Map Node.js builtins to browser polyfills and vite to vrowzer's shim.\n // These are resolved at prebundle time and the aliases appear as external\n // imports in the output (resolved by host Vite's resolve.alias at serve time).\n resolve: {\n alias: resolveAliases({\n // Only node:process is aliased here — bare `process` stays as-is.\n // Host Vite's @rollup/plugin-inject or resolve.alias handles it at serve time.\n 'node:process': '@vrowzer/node-polyfill/process'\n }),\n mainFields: ['module', 'main'],\n conditionNames: ['browser', 'import', 'default']\n },\n platform: 'neutral',\n plugins: [viteAliasPlugin(), inlineReadFileSyncPlugin(configDir), inlineCreateRequirePlugin()]\n })\n\n await bundle.write({\n format: 'esm',\n dir: outputDir,\n entryFileNames: BUNDLED_FILENAME,\n chunkFileNames: 'chunks/[name].mjs',\n minify: false\n })\n\n debug('prebundle complete:', bundledPath)\n\n return bundledPath\n}\n\n/**\n * Rolldown plugin to redirect `vite` imports to `@vrowzer/vite-dev-server/vite`.\n * Handles both exact `vite` and subpaths like `vite/internal`.\n */\nfunction viteAliasPlugin(): RolldownPlugin {\n const VITE_INTERNAL_ID = '\\0vrowzer:vite-internal-stub'\n return {\n name: 'vrowzer:vite-alias',\n resolveId(id) {\n if (id === 'vite') {\n return { id: '@vrowzer/vite-dev-server/vite', external: true }\n }\n // vite/internal is a Rolldown Vite 8 internal — stub it out\n if (id === 'vite/internal') {\n return { id: VITE_INTERNAL_ID, external: false }\n }\n if (id.startsWith('vite/')) {\n return { id: id.replace(/^vite\\//, '@vrowzer/vite-dev-server/vite/'), external: true }\n }\n },\n load(id) {\n if (id === VITE_INTERNAL_ID) {\n return 'export {}'\n }\n }\n }\n}\n\n/**\n * Rolldown plugin to inline `readFileSync(...)` calls at prebundle time.\n *\n * When the Worker config source contains `readFileSync(path, 'utf-8')`,\n * this plugin evaluates the call at prebundle time (Node.js) and replaces\n * it with the file content as a string literal. This is necessary because\n * Worker environments cannot access the host filesystem.\n *\n * Supported patterns:\n * readFileSync('literal/path', 'utf-8')\n * readFileSync(resolve(import.meta.dirname, 'path'), 'utf-8')\n */\nfunction inlineReadFileSyncPlugin(configDir: string): RolldownPlugin {\n // Match: readFileSync( <expr> , 'utf-8') or readFileSync( <expr> , \"utf-8\")\n // Uses [\\s\\S]+? to handle multiline expressions (e.g. resolve(dir, 'path') on separate lines)\n const RE = /readFileSync\\(\\s*([\\s\\S]+?)\\s*,\\s*['\"]utf-?8['\"]\\s*\\)/g\n\n return {\n name: 'vrowzer:inline-readFileSync',\n transform(code, id) {\n // Only process the entry file, not dependencies\n if (!id.includes('_entry.mt') && !id.includes('.vrowzer/')) {\n return\n }\n if (!code.includes('readFileSync')) {\n return\n }\n\n let modified = false\n const result = code.replace(RE, (match, pathExpr: string) => {\n const resolvedPath = tryEvalPathExpr(pathExpr.trim(), configDir)\n if (!resolvedPath) {\n debug('inlineReadFileSync: could not evaluate path expr:', pathExpr)\n return match\n }\n\n try {\n const content = readFileSync(resolvedPath, 'utf-8')\n modified = true\n debug('inlineReadFileSync: inlined', resolvedPath, `(${content.length} bytes)`)\n return JSON.stringify(content)\n } catch (e) {\n debug('inlineReadFileSync: failed to read:', resolvedPath, e)\n return match\n }\n })\n\n if (modified) {\n // Remove now-unused node:fs and node:path imports\n const cleaned = result\n .replace(/import\\s*\\{[^}]*readFileSync[^}]*\\}\\s*from\\s*['\"]node:fs['\"]\\s*;?\\n?/g, '')\n .replace(/import\\s*\\{[^}]*resolve[^}]*\\}\\s*from\\s*['\"]node:path['\"]\\s*;?\\n?/g, '')\n return { code: cleaned, map: null }\n }\n }\n }\n}\n\n/**\n * Try to evaluate a path expression to an absolute path string.\n */\nfunction tryEvalPathExpr(expr: string, configDir: string): string | null {\n // Case 1: Simple string literal\n const strMatch = expr.match(/^['\"](.+)['\"]$/)\n if (strMatch) {\n return resolve(configDir, strMatch[1]!)\n }\n\n // Case 2: resolve(import.meta.dirname, 'path') or resolve(__dirname, 'path')\n const resolveMatch = expr.match(\n /^resolve\\(\\s*(?:import\\.meta\\.dirname|__dirname)\\s*,\\s*['\"](.+)['\"]\\s*\\)$/\n )\n if (resolveMatch) {\n return resolve(configDir, resolveMatch[1]!)\n }\n\n return null\n}\n\n/**\n * Rolldown plugin to inline `createRequire(...)(\"pkg/path\")` calls at prebundle time.\n *\n * Some plugins (e.g. @sveltejs/vite-plugin-svelte) use `createRequire` at module\n * init time to load package.json files. This fails in Worker environments where\n * `require()` is not available. This plugin detects the pattern and replaces it\n * with the actual file content at prebundle time.\n */\nfunction inlineCreateRequirePlugin(): RolldownPlugin {\n // Match: createRequire(import.meta.url)(\"some/package.json\")\n const RE = /createRequire\\([^)]+\\)\\(\\s*['\"]([^'\"]+)['\"]\\s*\\)/g\n\n return {\n name: 'vrowzer:inline-createRequire',\n transform(code, id) {\n if (!code.includes('createRequire')) {\n return\n }\n\n let modified = false\n const result = code.replace(RE, (match, specifier: string) => {\n // Only inline JSON files (package.json etc.)\n if (!specifier.endsWith('.json')) {\n return match\n }\n\n try {\n // Resolve from the file that contains the createRequire call\n const req = nodeCreateRequire(id)\n const resolvedPath = req.resolve(specifier)\n const content = readFileSync(resolvedPath, 'utf-8')\n modified = true\n debug('inlineCreateRequire: inlined', specifier, 'from', id)\n return JSON.stringify(JSON.parse(content))\n } catch {\n debug('inlineCreateRequire: could not resolve', specifier, 'from', id)\n return match\n }\n })\n\n if (modified) {\n return { code: result, map: null }\n }\n }\n }\n}\n","/**\n * rolldown processing\n *\n * @module rolldown\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { copyFileSync, existsSync } from 'node:fs'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { createDebug } from 'obug'\n\nimport type { Plugin } from 'vite'\nimport type { ResolvedVrowzerOptions } from './options.ts'\n\nconst debug = createDebug('vite-plugin-vrowzer:rolldown')\n\nexport function rewriteRolldownAssetUrls(code: string): string {\n return code.replace(\n /([\"'])\\.\\.\\/(rolldown-(?:binding\\.wasm32-wasi\\.wasm|worker\\.js)\\?__vrowzer_internal_asset=rolldown)\\1/g,\n '$1./$2$1'\n )\n}\n\nfunction renderRolldownAssetChunk(code: string): string | null {\n const rewritten = rewriteRolldownAssetUrls(code)\n return rewritten === code ? null : rewritten\n}\n\nexport function rolldownWorkerAssetPlugin(): Plugin {\n return {\n name: 'vrowzer:worker-rolldown-assets',\n renderChunk: renderRolldownAssetChunk\n }\n}\n\n// Resolve @vrowzer/rolldown dist path for WASM/Worker file copying\nconst rolldownDistDir = path.resolve(\n path.dirname(fileURLToPath(import.meta.resolve('@vrowzer/rolldown/package.json'))),\n 'dist'\n)\ndebug('rolldownDistDir ', rolldownDistDir)\n\nexport function rolldownPlugin(_options: ResolvedVrowzerOptions): Plugin {\n let resolvedAssetsDir = ''\n\n return {\n name: 'vrowzer:rolldown',\n configResolved(config) {\n resolvedAssetsDir = path.resolve(config.root, config.build.outDir, config.build.assetsDir)\n },\n renderChunk: renderRolldownAssetChunk,\n /**\n * Copy rolldown WASM binary and sub-worker for production builds.\n * The worker chunks and these files share the configured assets directory.\n */\n writeBundle() {\n debug('copy-rolldown-wasm: assetsDir ', resolvedAssetsDir)\n\n const wasmSrc = path.resolve(rolldownDistDir, 'rolldown-binding.wasm32-wasi.wasm')\n debug('copy-rolldown-wasm: wasmSrc ', wasmSrc)\n\n const workerSrc = path.resolve(rolldownDistDir, 'worker.js')\n debug('copy-rolldown-wasm: workerSrc ', workerSrc)\n\n if (existsSync(wasmSrc)) {\n copyFileSync(wasmSrc, path.resolve(resolvedAssetsDir, 'rolldown-binding.wasm32-wasi.wasm'))\n }\n if (existsSync(workerSrc)) {\n copyFileSync(workerSrc, path.resolve(resolvedAssetsDir, 'rolldown-worker.js'))\n }\n }\n }\n}\n","/**\n * server middleware\n *\n * @module server\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { createDebug } from 'obug'\n\nimport type { IncomingMessage, ServerResponse } from 'node:http'\nimport type { Plugin } from 'vite'\nimport type { ResolvedVrowzerOptions } from './options.ts'\n\nconst debug = createDebug('vite-plugin-vrowzer:server')\n\n/**\n * NOTE(kazupon):\n * Prevent Vite's SPA fallback from serving index.html for preview URL (e.g '/__preview__/') requests.\n * When service worker is not yet controlling the page (e.g. after hard reload),\n * preview requests bypass service worker and hit Vite directly.\n * Without this guard, Vite returns the main page HTML, causing recursive display.\n */\nfunction previewGuardMiddleware(previewBase: string) {\n const previewRoot = previewBase.slice(0, -1)\n return (req: IncomingMessage, res: ServerResponse, next: () => void) => {\n debug('previewGuardMiddleware: previewBase ', previewBase, ' req.url ', req.url)\n\n const pathname = req.url ? new URL(req.url, 'http://localhost').pathname : undefined\n if (pathname === previewRoot || pathname?.startsWith(previewBase)) {\n res.writeHead(503, {\n 'Content-Type': 'text/html',\n 'Retry-After': '1'\n })\n res.end(`<!doctype html><html><head><meta charset=\"utf-8\"><title>Preview</title></head><body>\n<script>setTimeout(() => location.reload(), 1000)</script>\n<p>Waiting for Service Worker...</p></body></html>`)\n return\n }\n\n next()\n }\n}\n\nexport function serverMiddlewarePlugin(options: ResolvedVrowzerOptions): Plugin {\n const middleware = previewGuardMiddleware(options.basePath)\n return {\n name: 'vrowzer:server-middleware',\n configureServer(server) {\n server.middlewares.use(middleware)\n },\n configurePreviewServer(server) {\n server.middlewares.use(middleware)\n }\n }\n}\n","/**\n * Worker entry generation for vrowzer\n *\n * Generates source code for Worker entries that import vrowzer's factory functions\n * and the user's config to inject user plugins into Workers.\n *\n * @module virtual\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport type { Alias } from './options.ts'\n\nexport function generateWebWorkerEntry(configPath: string, resolve?: { alias?: Alias[] }): string {\n const resolveBlock = resolve\n ? `\\nconst workerResolve = ${JSON.stringify(resolve)}\\nObject.assign(resolved, { resolve: workerResolve })`\n : ''\n\n return `\nimport { initWebWorker } from 'vrowzer/web-worker-core'\nimport config from '${configPath}'\nconst resolved = config.default ?? config\n${resolveBlock}\ninitWebWorker(resolved)\n`\n}\n","/**\n * Vite plugin that transforms vrowzer-manifest.json imports.\n *\n * Replaces file path values with actual file contents so that\n * the imported manifest can be passed directly to Vrowzer.ready().\n *\n * Use the `?vrowzer` query suffix to trigger this plugin:\n * import manifest from './vrowzer-manifest.json?vrowzer'\n *\n * @module manifest\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { readFileSync } from 'node:fs'\nimport { dirname, extname, resolve } from 'node:path'\nimport { minifySync } from 'rolldown/utils'\nimport { createDebug } from 'obug'\n\nimport type { Plugin } from 'vite'\n\nconst MINIFIABLE_EXTENSIONS = new Set(['.js', '.mjs', '.cjs'])\n\nconst debug = createDebug('vite-plugin-vrowzer:manifest')\n\nfunction parseId(id: string): { filePath: string; isVrowzer: boolean } {\n try {\n const url = new URL(id, 'file://')\n return {\n filePath: url.pathname,\n isVrowzer: url.searchParams.has('vrowzer')\n }\n } catch {\n return { filePath: id, isVrowzer: false }\n }\n}\n\nexport function VrowzerManifest(): Plugin {\n return {\n name: 'vrowzer:manifest-loader',\n resolveId(id) {\n if (parseId(id).isVrowzer) {\n debug('resolveId:', id)\n return id\n }\n },\n load(id) {\n const { filePath, isVrowzer } = parseId(id)\n if (!isVrowzer) {\n return\n }\n debug('loading manifest:', filePath)\n\n const raw = readFileSync(filePath, 'utf-8')\n const manifest = JSON.parse(raw)\n const manifestDir = dirname(filePath)\n\n function resolveFiles(\n field: string,\n files: Record<string, string> | undefined,\n minify = false\n ): Record<string, string> {\n if (!files) {\n return {}\n }\n const resolved: Record<string, string> = {}\n for (const [virtualPath, relPath] of Object.entries(files)) {\n try {\n let content = readFileSync(resolve(manifestDir, relPath), 'utf-8')\n if (minify && MINIFIABLE_EXTENSIONS.has(extname(virtualPath))) {\n const result = minifySync(virtualPath, content)\n if (result.code) {\n content = result.code\n }\n }\n resolved[virtualPath] = content\n } catch (e) {\n debug('failed to read %s %s: %s', field, relPath, (e as Error).message)\n }\n }\n debug('%s: %d files resolved', field, Object.keys(resolved).length)\n return resolved\n }\n\n const result = {\n name: manifest.name,\n files: resolveFiles('files', manifest.files),\n vendor: resolveFiles('vendor', manifest.vendor, true),\n nodeModules: resolveFiles('nodeModules', manifest.nodeModules, true),\n activeFile: manifest.activeFile\n }\n\n debug(\n 'manifest loaded: %s (%d files, %d vendor, %d nodeModules)',\n result.name,\n Object.keys(result.files).length,\n Object.keys(result.vendor).length,\n Object.keys(result.nodeModules).length\n )\n\n return {\n code: `export default ${JSON.stringify(result)}`,\n moduleType: 'js'\n }\n }\n }\n}\n","/**\n * vite-plugin-vrowzer entry\n *\n * @module default\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nimport { readFileSync } from 'node:fs'\nimport { dirname } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport * as injectModule from '@rollup/plugin-inject'\nimport ServiceWorker from '@vrowzer/unplugin-service-worker/vite'\nimport { createDebug } from 'obug'\nimport { autoManifestPlugin } from './auto-manifest.ts'\nimport { envPlugin } from './env.ts'\nimport { idePlugin } from './ide.ts'\nimport { extractWorkerConfig } from './extract.ts'\nimport { resolveOptions } from './options.ts'\nimport { cleanOutputDir, prebundleWorkerConfig } from './prebundle.ts'\nimport { rolldownPlugin, rolldownWorkerAssetPlugin } from './rolldown.ts'\nimport { serverMiddlewarePlugin } from './server.ts'\nimport { generateWebWorkerEntry } from './virtual.ts'\n\nimport type { Plugin, ResolvedConfig, UserConfig } from 'vite'\nimport type { RollupInjectOptions } from '@rollup/plugin-inject'\nimport type { VrowzerOptions } from './options.ts'\n\nconst debug = createDebug('vite-plugin-vrowzer:index')\nconst inject = injectModule.default as unknown as (\n options?: RollupInjectOptions\n) => Record<string, unknown>\n\nexport function Vrowzer(options: VrowzerOptions = {}): Plugin[] {\n const resolvedOptions = resolveOptions(options)\n const root = process.cwd()\n\n // Path to bundled Worker config (set by configResolved)\n let bundledConfigPath: string | null = null\n let isBuild = false\n\n function workerEntryTransform(code: string, id: string) {\n if (!bundledConfigPath) {\n return\n }\n const cleanId = id.split('?')[0]\n if (\n cleanId?.endsWith('web-worker.ts') &&\n !cleanId.endsWith('web-worker-core.ts') &&\n code.includes('initWebWorker()')\n ) {\n return { code: generateWebWorkerEntry(bundledConfigPath, resolvedOptions.resolve), map: null }\n }\n }\n\n const vrowzerConfigPlugin: Plugin = {\n name: 'vrowzer:config',\n resolveId(id) {\n if (id.startsWith('@vrowzer/')) {\n try {\n return fileURLToPath(import.meta.resolve(id))\n } catch {\n // Not resolvable from this plugin — let Vite handle it normally\n }\n }\n },\n config(): UserConfig {\n const workerPlugins: Plugin[] = [\n {\n name: 'vrowzer:worker-resolve',\n resolveId(id: string) {\n if (id.startsWith('@vrowzer/')) {\n try {\n return fileURLToPath(import.meta.resolve(id))\n } catch {\n // fallthrough\n }\n }\n }\n },\n {\n name: 'vrowzer:worker-process-inject',\n options(inputOptions: any) {\n inputOptions.transform ??= {}\n inputOptions.transform.inject = {\n ...inputOptions.transform.inject,\n process: '@vrowzer/node-polyfill/process'\n }\n }\n },\n {\n name: 'vrowzer:web-worker-config-inject',\n transform: workerEntryTransform\n },\n rolldownWorkerAssetPlugin()\n ]\n\n return {\n optimizeDeps: {\n exclude: ['@vrowzer/vite-dev-server']\n },\n resolve: {\n alias: [{ find: /^vite$/, replacement: '@vrowzer/vite-dev-server/vite' }]\n },\n worker: {\n plugins: () => workerPlugins\n }\n }\n },\n async configResolved(config: ResolvedConfig) {\n isBuild = config.command === 'build'\n\n const viteConfigPath = config.configFile\n if (!viteConfigPath) {\n debug('no vite.config.ts found, skipping extraction')\n return\n }\n\n debug('extracting worker config from:', viteConfigPath)\n\n cleanOutputDir(config.root)\n\n const configDir = dirname(viteConfigPath)\n const viteConfigSource = readFileSync(viteConfigPath, 'utf-8')\n const { code: workerSource, unsupported } = extractWorkerConfig(\n viteConfigSource,\n viteConfigPath,\n {\n serverOrigin: config.server.origin,\n serverForwardConsole: config.server.forwardConsole\n }\n )\n\n if (unsupported.length > 0) {\n debug('unsupported patterns found:', unsupported)\n }\n\n debug('generated worker source:\\n', workerSource)\n\n bundledConfigPath = await prebundleWorkerConfig({\n workerSource,\n root: config.root,\n configDir\n })\n\n debug('bundled config path:', bundledConfigPath)\n },\n closeBundle() {\n if (isBuild && bundledConfigPath) {\n cleanOutputDir(root)\n debug('cleaned up prebundle output after build')\n }\n },\n transform(code: string, id: string) {\n return workerEntryTransform(code, id)\n }\n }\n\n const processInjectPlugin = {\n ...inject({\n process: '@vrowzer/node-polyfill/process',\n exclude: [/node_modules\\/\\.vite\\//, /node_modules\\/\\.vrowzer\\//]\n }),\n apply: 'serve'\n } as unknown as Plugin\n const serviceWorkerPlugin = ServiceWorker({\n serviceWorkerAllowed: resolvedOptions.serviceWorkerScope,\n format: 'esm',\n ...(resolvedOptions.serviceWorkerEntry ? { entry: resolvedOptions.serviceWorkerEntry } : {})\n }) as unknown as Plugin\n\n const plugins: Plugin[] = [\n vrowzerConfigPlugin,\n serverMiddlewarePlugin(resolvedOptions),\n processInjectPlugin,\n envPlugin(resolvedOptions),\n rolldownPlugin(resolvedOptions),\n serviceWorkerPlugin\n ]\n\n // Auto-manifest plugin: generates manifest and provides virtual:vrowzer-manifest\n if (resolvedOptions.auto) {\n plugins.unshift(autoManifestPlugin(resolvedOptions.manifest))\n }\n\n // IDE plugin: serves browser IDE at /__vrowzer__/ (experimental)\n if (resolvedOptions.ide.enabled) {\n plugins.push(idePlugin(resolvedOptions))\n }\n\n return plugins\n}\n\nexport { VrowzerManifest } from './manifest.ts'\nexport { generateManifest } from './manifest-generate.ts'\nexport type {\n GenerateManifestOptions,\n ManifestResult,\n GenerateManifestLog\n} from './manifest-generate.ts'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAMA,UAAQ,YAAY,mCAAmC;AAE7D,MAAM,oBAAoB;AAC1B,MAAM,6BAA6B,OAAO;AAE1C,MAAM,iBAAiB;AACvB,MAAM,oBAAoB;AAC1B,MAAM,gBAAgB;AAEtB,MAAM,iBAAiB;CAAC;CAAkB;CAAqB;CAAa;AAAU;AAEtF,MAAMC,0CAAwB,IAAI,IAAI;CAAC;CAAO;CAAQ;AAAM,CAAC;;;;AAK7D,SAAS,KAAK,OAAuB;CACn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 @@
1
1
  {
2
2
  "name": "@vrowzer/vite-plugin",
3
3
  "description": "Vite plugin for vrowzer",
4
- "version": "0.1.1",
4
+ "version": "0.1.3",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -52,33 +52,33 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@rollup/plugin-inject": "^5.0.5",
55
+ "@vrowzer/fs": "0.1.3",
56
+ "@vrowzer/node-polyfill": "0.1.3",
57
+ "@vrowzer/rolldown": "0.1.3",
58
+ "@vrowzer/unplugin-service-worker": "0.1.3",
55
59
  "birpc": "^2.3.0",
56
60
  "buffer": "^6.0.3",
57
61
  "obug": "^2.1.1",
58
62
  "pathe": "^2.0.3",
59
63
  "picocolors": "^1.1.1",
60
64
  "readable-stream": "^4.7.0",
61
- "rolldown": "1.2.0",
62
- "ws": "^8.18.0",
63
- "@vrowzer/fs": "0.1.1",
64
- "@vrowzer/node-polyfill": "0.1.1",
65
- "@vrowzer/rolldown": "0.1.1",
66
- "@vrowzer/unplugin-service-worker": "0.1.1"
65
+ "rolldown": "1.2.5",
66
+ "ws": "^8.18.0"
67
67
  },
68
68
  "peerDependencies": {
69
- "vite": "npm:@voidzero-dev/vite-plus-core@0.2.6",
70
- "vrowzer": "0.1.1",
71
- "@vrowzer/vite-dev-server": "0.1.1"
69
+ "@vrowzer/vite-dev-server": "0.1.3",
70
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.3.0",
71
+ "vrowzer": "0.1.3"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@iconify-icons/vscode-icons": "^1.2.29",
75
75
  "@iconify/vue": "^5.0.0",
76
- "@oxc-project/types": "0.140.0",
76
+ "@oxc-project/types": "0.146.0",
77
77
  "@types/ws": "^8.18.0",
78
78
  "@vitejs/plugin-vue": "^6.0.5",
79
79
  "monaco-editor": "^0.55.1",
80
80
  "publint": "^0.3.18",
81
- "vite": "npm:@voidzero-dev/vite-plus-core@0.2.6",
81
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.3.0",
82
82
  "vue": "^3.5.31"
83
83
  },
84
84
  "scripts": {