@vrowzer/vite-plugin 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +290 -0
  3. package/dist/ide/assets/css.worker-uWEFNxvl.js +89 -0
  4. package/dist/ide/assets/html.worker-1tLoAl5Z.js +502 -0
  5. package/dist/ide/assets/json.worker-CL3sVQd6.js +58 -0
  6. package/dist/ide/assets/ts.worker-BFpNHPy5.js +67719 -0
  7. package/dist/ide/css-CPSW8DVZ.js +286 -0
  8. package/dist/ide/cssMode-B5DtFEwy.js +65 -0
  9. package/dist/ide/graphql-BteLL2CG.js +176 -0
  10. package/dist/ide/handlebars-BcqMM6pa.js +412 -0
  11. package/dist/ide/html-CxO5OaJl.js +333 -0
  12. package/dist/ide/htmlMode-DxpUG2jm.js +74 -0
  13. package/dist/ide/ide.css +2 -0
  14. package/dist/ide/ide.js +5523 -0
  15. package/dist/ide/javascript-CvtLx4_Z.js +21 -0
  16. package/dist/ide/jsonMode-LVtiYWKr.js +449 -0
  17. package/dist/ide/less-BubkcFWW.js +244 -0
  18. package/dist/ide/lspLanguageFeatures-BDyekQt2.js +1455 -0
  19. package/dist/ide/markdown-DPB5N4OB.js +264 -0
  20. package/dist/ide/mdx-Sun87_nd.js +329 -0
  21. package/dist/ide/monaco.contribution-DVj8eGe_.js +116 -0
  22. package/dist/ide/pug-BONHZNEg.js +302 -0
  23. package/dist/ide/scss-0r6NeK1P.js +419 -0
  24. package/dist/ide/shell-Vh_eZpea.js +225 -0
  25. package/dist/ide/toggleHighContrast-DI4ZeqFk.js +113328 -0
  26. package/dist/ide/tsMode-BKTkt1bt.js +567 -0
  27. package/dist/ide/typescript-CHC4VYBW.js +257 -0
  28. package/dist/ide/workers-IG_hD8Jy.js +47 -0
  29. package/dist/ide/xml-C0QFzMaz.js +130 -0
  30. package/dist/ide/yaml-o-RP7lYY.js +223 -0
  31. package/dist/index.d.mts +138 -0
  32. package/dist/index.d.mts.map +1 -0
  33. package/dist/index.mjs +1335 -0
  34. package/dist/index.mjs.map +1 -0
  35. package/dist/manifest-generate.d.mts +89 -0
  36. package/dist/manifest-generate.d.mts.map +1 -0
  37. package/dist/manifest-generate.mjs +438 -0
  38. package/dist/manifest-generate.mjs.map +1 -0
  39. package/package.json +88 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["debug","MINIFIABLE_EXTENSIONS","parts: string[]","resolved: Record<string, string>","sourceDir: string","manifest: ManifestResult | null","NODE_POLYFILL_MAP: Record<string, string>","aliases: Record<string, string>","debug","debug","MIME_TYPES: Record<string, string>","resolve","ideCssFile: string | null","devtoolsUrl: string | null","path","debug","unsupported: string[]","pluginCalls: PluginCallInfo[]","localFuncSources: string[]","imports: ImportInfo[]","calleeName: string | null","lines: string[]","debug","nodeCreateRequire","debug","debug","resolve","debug","resolved: Record<string, string>","result","bundledConfigPath: string | null","plugins: Plugin[]","workerPlugins: Plugin[]"],"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/experimental'\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 { createRequire } from 'node:module'\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 use createRequire to find the package and construct the path.\nconst _require = createRequire(import.meta.url)\nconst picocolorsBrowser = resolve(dirname(_require.resolve('picocolors')), 'picocolors.browser.js')\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/experimental'\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\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- reserved for future options (e.g. pluginOverrides)\nexport interface ExtractOptions {}\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 if (unsupported.length > 0) {\n debug('unsupported patterns', unsupported)\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 // 9. Generate Worker config source\n const code = generateWorkerSource(\n source,\n ast,\n imports,\n workerPlugins,\n neededImportSources,\n neededLocalNames\n )\n\n return { code, unsupported }\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): 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 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/experimental'\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 inject 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 { VrowzerOptions } from './options.ts'\n\nconst debug = createDebug('vite-plugin-vrowzer:index')\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\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 plugins: Plugin[] = [\n vrowzerConfigPlugin,\n serverMiddlewarePlugin(resolvedOptions),\n {\n // @ts-expect-error -- FIXME\n ...inject({\n process: '@vrowzer/node-polyfill/process',\n exclude: [/node_modules\\/\\.vite\\//, /node_modules\\/\\.vrowzer\\//]\n }),\n apply: 'serve'\n } as Plugin,\n envPlugin(resolvedOptions),\n rolldownPlugin(resolvedOptions),\n // @ts-expect-error -- Plugin type mismatch from duplicate vite installations (esbuild version diff)\n ServiceWorker({\n serviceWorkerAllowed: '/',\n format: 'esm',\n ...(resolvedOptions.serviceWorkerEntry ? { entry: resolvedOptions.serviceWorkerEntry } : {})\n })\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,oCAAoC;AAE9D,MAAM,oBAAoB;AAC1B,MAAM,6BAA6B,OAAO;AAE1C,MAAM,iBAAiB;AACvB,MAAM,oBAAoB;AAC1B,MAAM,gBAAgB;AAEtB,MAAM,iBAAiB;CAAC;CAAkB;CAAqB;CAAa;CAAW;AAEvF,MAAMC,0BAAwB,IAAI,IAAI;CAAC;CAAO;CAAQ;CAAO,CAAC;;;;AAK9D,SAAS,KAAK,OAAuB;CACnC,IAAI,IAAI;AACR,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,OAAO,MAAM,WAAW,EAAE;AAChC,OAAK,KAAK,KAAK,IAAI;AACnB,MAAI,IAAI;;AAEV,QAAO,K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AGpD,UAAU,MAAc,IAAY;AAClC,WAAO,qBAAqB,MAAM,GAAG;;GAExC;EAIC,uBAAuB,gBAAgB;EACvC;GAEE,GAAG,OAAO;IACR,SAAS;IACT,SAAS,CAAC,0BAA0B,4BAA4B;IACjE,CAAC;GACF,OAAO;GACR;EACD,UAAU,gBAAgB;EAC1B,eAAe,gBAAgB;EAE/B,cAAc;GACZ,sBAAsB;GACtB,QAAQ;GACR,GAAI,gBAAgB,qBAAqB,EAAE,OAAO,gBAAgB,oBAAoB,GAAG,EAAE;GAC5F,CAAC;EACH;AAGD,KAAI,gBAAgB,KAClB,SAAQ,QAAQ,mBAAmB,gBAAgB,SAAS,CAAC;AAI/D,KAAI,gBAAgB,IAAI,QACtB,SAAQ,KAAK,UAAU,gBAAgB,CAAC;AAG1C,QAAO"}
@@ -0,0 +1,89 @@
1
+ //#region src/manifest-generate.d.ts
2
+ /**
3
+ * Core logic for generating vrowzer-manifest.json.
4
+ *
5
+ * Shared between `scripts/generate-manifest.ts` (CLI) and
6
+ * the `Vrowzer()` plugin (auto-generation mode).
7
+ *
8
+ * @module manifest-generate
9
+ */
10
+ type PackageJson = {
11
+ name: string;
12
+ type?: string;
13
+ exports?: Record<string, any> | string;
14
+ dependencies?: Record<string, string>;
15
+ devDependencies?: Record<string, string>;
16
+ files?: string[];
17
+ };
18
+ interface GenerateManifestOptions {
19
+ /**
20
+ * Directory containing the target package.json (for node_modules resolution)
21
+ */
22
+ pkgDir: string;
23
+ /**
24
+ * Directory to scan for project source files. Defaults to pkgDir.
25
+ */
26
+ sourceDir?: string;
27
+ /**
28
+ * Package name(s) to include in nodeModules. When omitted, all dependencies are included.
29
+ */
30
+ targets?: string[];
31
+ /**
32
+ * When true, include devDependencies in dependency collection (default: false).
33
+ * Used by CLI for fixture projects where runtime deps may be in devDependencies.
34
+ */
35
+ includeDevDependencies?: boolean;
36
+ /**
37
+ * Override manifest name. Defaults to package.json name.
38
+ */
39
+ name?: string;
40
+ /**
41
+ * Default file to open in editor
42
+ */
43
+ activeFile?: string;
44
+ }
45
+ interface ManifestResult {
46
+ name: string;
47
+ files: Record<string, string>;
48
+ nodeModules?: Record<string, string>;
49
+ activeFile?: string;
50
+ }
51
+ declare function readPackageJson(dir: string): Promise<PackageJson>;
52
+ declare function shouldIncludeFile(filePath: string): boolean;
53
+ declare function shouldExcludeDir(dirName: string): boolean;
54
+ /**
55
+ * Recursively walk a directory and collect files.
56
+ * Follows symlinks but records logical paths.
57
+ */
58
+ declare function walkDir(dir: string, files?: string[]): Promise<string[]>;
59
+ /**
60
+ * Walk a package directory, respecting its package.json "files" field if present.
61
+ */
62
+ declare function walkPackageFiles(pkgDir: string): Promise<string[]>;
63
+ declare function resolvePackageDir(dep: string, fromDir: string): Promise<string | null>;
64
+ declare function collectDependencies(pkgDir: string, visited: Set<string>, isRoot?: boolean): Promise<string[]>;
65
+ declare function collectProjectFiles(projectDir: string): Promise<Record<string, string>>;
66
+ declare function detectActiveFile(files: Record<string, string>): string | undefined;
67
+ declare function isCjsPackage(pkg: PackageJson): boolean;
68
+ declare function extractExportEntries(pkg: PackageJson, conditions?: string[]): Record<string, string>;
69
+ declare function subpathToEntryName(pkgName: string, subpath: string): string;
70
+ interface CjsBundleResult {
71
+ nodeModulesEntries: Record<string, string>;
72
+ }
73
+ declare function bundleCjsPackages(cjsPackages: {
74
+ pkgName: string;
75
+ pkg: PackageJson;
76
+ }[], sourceDir: string, nodeModulesRoot: string): Promise<CjsBundleResult>;
77
+ interface GenerateManifestLog {
78
+ (message: string): void;
79
+ }
80
+ /**
81
+ * Generate a vrowzer manifest from a project directory.
82
+ *
83
+ * This is the main entry point for manifest generation, used by both
84
+ * the CLI script and the Vrowzer plugin's auto-generation mode.
85
+ */
86
+ declare function generateManifest(options: GenerateManifestOptions, log?: GenerateManifestLog): Promise<ManifestResult>;
87
+ //#endregion
88
+ export { GenerateManifestLog, GenerateManifestOptions, ManifestResult, PackageJson, bundleCjsPackages, collectDependencies, collectProjectFiles, detectActiveFile, extractExportEntries, generateManifest, isCjsPackage, readPackageJson, resolvePackageDir, shouldExcludeDir, shouldIncludeFile, subpathToEntryName, walkDir, walkPackageFiles };
89
+ //# sourceMappingURL=manifest-generate.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-generate.d.mts","names":[],"sources":["../src/manifest-generate.ts"],"sourcesContent":[],"mappings":";;AAoBA;;;;;AASA;AA4BA;AAgFsB,KArHV,WAAA,GAqHyB;EAerB,IAAA,EAAA,MAAA;EA2BA,IAAA,CAAA,EAAA,MAAA;EAQM,OAAA,CAAA,EApKV,MAoKiB,CAAA,MAAqC,EAAA,GAAA,CAAO,GAAA,MAAA;EAoCnD,YAAA,CAAA,EAvML,MAuMqB,CAAA,MAAA,EAAkB,MAAA,CAAA;EAoClC,eAAA,CAAA,EA1OF,MA0OmB,CAAA,MAAgC,EAAA,MAAO,CAAA;EA6BxD,KAAA,CAAA,EAAA,MAAA,EAAA;AAgCtB,CAAA;AA+CgB,UAlVC,uBAAA,CAkVuB;EAiBxB;AAkBhB;AAuCA;EAQU,MAAA,EAAA,MAAA;EAIY;;;EAInB,SAAA,CAAA,EAAA,MAAA;EAAO;AAwIV;AAUA;EACW,OAAA,CAAA,EAAA,MAAA,EAAA;EACJ;;;;;;;;;;;;;;UApiBU,cAAA;;SAER;gBACO;;;iBA6EM,eAAA,eAA8B,QAAQ;iBAe5C,iBAAA;iBA2BA,gBAAA;;;;;iBAQM,OAAA,iCAA4C;;;;iBAoC5C,gBAAA,kBAAkC;iBAoClC,iBAAA,gCAAiD;iBA6BjD,mBAAA,0BAEX,gCAER;iBA4BmB,mBAAA,sBAAyC,QAAQ;iBA+CvD,gBAAA,QAAwB;iBAiBxB,YAAA,MAAkB;iBAkBlB,oBAAA,MACT,qCAEJ;iBAoCa,kBAAA;UAQN,eAAA;sBACY;;iBAGA,iBAAA;;OACiB;kDAGpC,QAAQ;UAwIM,mBAAA;;;;;;;;;iBAUK,gBAAA,UACX,+BACJ,sBACJ,QAAQ"}