@llui/vite-plugin 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cross-file-resolver.d.ts +1 -1
- package/dist/cross-file-resolver.d.ts.map +1 -1
- package/dist/cross-file-resolver.js +1 -1
- package/dist/cross-file-resolver.js.map +1 -1
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +141 -3
- package/dist/index.js.map +1 -1
- package/dist/transform.d.ts +1 -3
- package/dist/transform.d.ts.map +1 -1
- package/dist/transform.js +1 -8
- package/dist/transform.js.map +1 -1
- package/package.json +6 -2
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,WAAW,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,IAAI,OAAO,EAAkB,MAAM,SAAS,CAAA;AACnG,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,qBAAqB,GAGtB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,8BAA8B,EAC9B,wCAAwC,GAEzC,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B;;;;;;;;;;;;;;;;;;GAkBG;AACH,KAAK,UAAU,qBAAqB,CAClC,MAAc,EACd,QAAgB,EAChB,aAGiF;IAEjF,8DAA8D;IAC9D,sEAAsE;IACtE,I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` we use in the MCP-status\n// handler. Avoids a heavy `node:http` import at the top of the file.\ninterface ServerResponseLike {\n statusCode: number\n setHeader(name: string, value: string): void\n end(body?: string): void\n}\nimport MagicString from 'magic-string'\nimport { existsSync, readFileSync, writeFileSync, watch as fsWatch, type FSWatcher } from 'node:fs'\nimport { readFile } from 'node:fs/promises'\nimport { dirname, relative, resolve } from 'node:path'\nimport { createRequire } from 'node:module'\nimport { spawn, type ChildProcess } from 'node:child_process'\nimport {\n transformLlui,\n transformUseClientSsr,\n hasUseClientDirective,\n type ExternalTypeSources,\n type PreExtractedSchemas,\n} from './transform.js'\nimport {\n findTypeSource,\n readComponentTypeArgNames,\n extractMsgAnnotationsCrossFile,\n extractDiscriminatedUnionSchemaCrossFile,\n type ResolveContext,\n} from './cross-file-resolver.js'\nimport ts from 'typescript'\n\n/**\n * Pre-resolution step run before `transformLlui`. Scans the source for\n * `component<State, Msg, Effect>(...)` calls; for each type argument that\n * is an identifier (the common case), walks imports and re-exports to\n * find the source file declaring that alias. The result is plumbed into\n * `transformLlui` so the schema/annotation extractors operate on the\n * declaring file's source instead of silently returning `null` when the\n * type lives in a separate file.\n *\n * Returns `undefined` (no external sources) when:\n * - No `component<...>()` call is in the file\n * - No type arguments are identifiers we can chase\n * - All type arguments are declared locally (the resolver returns the\n * same source we already have, so external sources are redundant)\n *\n * `resolveModule` comes from Rollup's `this.resolve()`; we wrap it to\n * return the absolute id (or null when unresolved) and read the source\n * via `fs/promises.readFile`.\n */\nasync function preResolveTypeSources(\n source: string,\n filePath: string,\n rollupResolve: (\n spec: string,\n importer: string,\n ) => Promise<{ id: string; external?: boolean | 'absolute' | 'relative' } | null>,\n): Promise<ExternalTypeSources | undefined> {\n // Cheap filter: nothing to resolve unless the file contains a\n // component<...>() call. Avoids parsing every TS file in the project.\n if (!/\\bcomponent\\s*</.test(source)) return undefined\n\n // Find the first component<...>() call and read its type arg names.\n // Multiple component() calls in one file would each technically need\n // their own type-arg lookup; we resolve based on the first call and\n // accept the (rare) edge case where two component() calls in one file\n // use different non-local Msg types. The lint rule catches divergence.\n const sf = ts.createSourceFile(filePath, source, ts.ScriptTarget.Latest, true)\n const args = findFirstComponentTypeArgs(sf)\n if (!args) return undefined\n\n const ctx: ResolveContext = {\n resolveModule: async (spec, importer) => {\n const result = await rollupResolve(spec, importer)\n if (!result || result.external) return null\n // Rollup ids can include query/hash suffixes for virtual modules;\n // strip those so fs.readFile sees a real path. Also skip files\n // outside our control (node_modules) — we don't want to follow\n // imports into third-party packages just to scrape types.\n const idStripped = result.id.split('?')[0]?.split('#')[0]\n if (!idStripped) return null\n if (idStripped.includes('/node_modules/')) return null\n return idStripped\n },\n readSource: async (p) => {\n return await readFile(p, 'utf8')\n },\n }\n\n // Helper to resolve one type-arg name into an external source if it\n // isn't declared locally (or if the resolver chases through imports).\n const resolve = async (\n typeName: string | null,\n ): Promise<{ source: string; typeName: string } | undefined> => {\n if (!typeName) return undefined\n const found = await findTypeSource(typeName, source, filePath, ctx)\n if (!found) return undefined\n // If the alias was declared locally, the existing extractor path\n // already handles it — no need to populate external sources.\n if (found.filePath === filePath) return undefined\n return { source: found.source, typeName: found.localName }\n }\n\n const [state, msg, effect] = await Promise.all([\n resolve(args.state),\n resolve(args.msg),\n resolve(args.effect),\n ])\n\n if (!state && !msg && !effect) return undefined\n return { state, msg, effect }\n}\n\n/**\n * Cross-file + composition-aware schema extraction. The extractors\n * follow imports/re-exports AND walk into TypeReferences inside Msg /\n * Effect unions, so a developer who organises types as\n * `type Msg = ImportedFoo | { type: 'extra' }` gets every variant in\n * `__msgAnnotations` and `__msgSchema`. Without this step the\n * file-local sync extractors would silently emit half-annotations\n * (only the inline TypeLiteral members) — the worst kind of failure\n * mode because the build appears to succeed.\n *\n * Returns `undefined` (no pre-extraction) when there's no\n * `component()` call to resolve types for.\n */\nasync function preExtractCompositional(\n source: string,\n filePath: string,\n rollupResolve: (\n spec: string,\n importer: string,\n ) => Promise<{ id: string; external?: boolean | 'absolute' | 'relative' } | null>,\n): Promise<PreExtractedSchemas | undefined> {\n if (!/\\bcomponent\\s*</.test(source)) return undefined\n const sf = ts.createSourceFile(filePath, source, ts.ScriptTarget.Latest, true)\n const args = findFirstComponentTypeArgs(sf)\n if (!args) return undefined\n // No identifier type args at all → nothing for the resolver to chase.\n if (!args.msg && !args.effect && !args.state) return undefined\n\n const ctx: ResolveContext = {\n resolveModule: async (spec, importer) => {\n const result = await rollupResolve(spec, importer)\n if (!result || result.external) return null\n const idStripped = result.id.split('?')[0]?.split('#')[0]\n if (!idStripped) return null\n if (idStripped.includes('/node_modules/')) return null\n return idStripped\n },\n readSource: async (p) => readFile(p, 'utf8'),\n }\n\n const [msgAnnotations, msgSchema, effectSchema] = await Promise.all([\n args.msg\n ? extractMsgAnnotationsCrossFile(source, args.msg, filePath, ctx)\n : Promise.resolve(null),\n args.msg\n ? extractDiscriminatedUnionSchemaCrossFile(source, args.msg, filePath, ctx)\n : Promise.resolve(null),\n args.effect\n ? extractDiscriminatedUnionSchemaCrossFile(source, args.effect, filePath, ctx)\n : Promise.resolve(null),\n ])\n\n // Only return a populated payload when we actually extracted\n // something useful. Returning `undefined` lets transformLlui fall\n // back to its file-local extractors, which is the right behavior\n // for the (rare) case where every type the resolver sees is\n // unreachable.\n if (msgAnnotations === null && msgSchema === null && effectSchema === null) return undefined\n\n // Note: state schema isn't a discriminated union, so composition\n // doesn't apply. We leave state on the simpler `typeSources` path\n // (already plumbed through preResolveTypeSources) which the\n // file-local `extractStateSchema` consumes.\n const out: PreExtractedSchemas = {}\n if (msgAnnotations !== null) out.msgAnnotations = msgAnnotations\n if (msgSchema !== null) out.msgSchema = msgSchema\n if (effectSchema !== null) out.effectSchema = effectSchema\n return out\n}\n\nfunction findFirstComponentTypeArgs(\n sf: ts.SourceFile,\n): { state: string | null; msg: string | null; effect: string | null } | null {\n let result: ReturnType<typeof readComponentTypeArgNames> | null = null\n const visit = (node: ts.Node): boolean => {\n if (result) return true\n if (\n ts.isCallExpression(node) &&\n ts.isIdentifier(node.expression) &&\n node.expression.text === 'component' &&\n node.typeArguments\n ) {\n result = readComponentTypeArgNames(node)\n return true\n }\n let stopped = false\n ts.forEachChild(node, (child) => {\n if (stopped) return\n if (visit(child)) stopped = true\n })\n return stopped\n }\n ts.forEachChild(sf, (child) => {\n visit(child)\n })\n return result\n}\n\n/**\n * Locate the workspace root so we share the MCP active marker file\n * with @llui/mcp regardless of which subdirectory the dev server runs in.\n * Mirrors `findWorkspaceRoot` from @llui/mcp — duplicated to avoid a\n * vite-plugin → mcp dependency cycle. The contract must stay in sync.\n */\nfunction findWorkspaceRoot(start: string = process.cwd()): string {\n let dir = resolve(start)\n let lastPackageJson: string | null = null\n while (true) {\n if (existsSync(resolve(dir, 'pnpm-workspace.yaml'))) return dir\n if (existsSync(resolve(dir, '.git'))) return dir\n if (existsSync(resolve(dir, 'package.json'))) lastPackageJson = dir\n const parent = dirname(dir)\n if (parent === dir) return lastPackageJson ?? start\n dir = parent\n }\n}\n\nexport interface LluiPluginOptions {\n /**\n * Port for the MCP debug bridge. In dev mode, the runtime relay connects\n * to `ws://127.0.0.1:<port>` so an external `llui-mcp` server can forward\n * tool calls into the running app.\n *\n * When omitted, the plugin checks whether `@llui/mcp` is resolvable from\n * the Vite project root. If yes → defaults to `5200`. If no → stays\n * disabled. This means installing `@llui/mcp` (+ starting its server)\n * Just Works without an explicit config entry. Pass an explicit `false`\n * to opt out even when `@llui/mcp` is installed; pass a number to use\n * a non-default port. When enabled but the MCP server isn't running,\n * the plugin returns 404 from its discovery endpoint and the browser\n * silently skips the connection — no retry noise.\n */\n mcpPort?: number | false\n\n /**\n * Emit `[llui]`-prefixed `console.info` logs for every transformed\n * component file — state-path bit assignments, mask injections, and\n * helper compile/bail counts. Useful when diagnosing why a binding\n * isn't gated the way you expect, or why a call fell back from\n * template-clone to `elSplit`. Off by default.\n */\n verbose?: boolean\n\n /**\n * Enables two things together when set:\n *\n * 1. Emits schemas + binding descriptors in prod builds so the\n * @llui/agent runtime has metadata to advertise over its WS hello\n * frame (see agent spec §7.4).\n * 2. Auto-mounts `@llui/agent/server`'s router at `/agent/*` and its\n * WS upgrade handler at `/agent/ws` on the Vite dev server — so\n * plain `vite dev` has working agent endpoints with no extra\n * server.ts wiring. Requires `@llui/agent` installed; if it isn't,\n * the plugin warns and skips dev mounting (prod emission still\n * works from Plan 3b).\n *\n * Pass `true` for defaults (random signing key per dev session;\n * `identityResolver` returns `'dev-user'`). Pass an object to customize.\n * Default `false` — metadata is dev-only, no agent endpoints.\n */\n agent?: boolean | AgentPluginConfig\n}\n\n/**\n * Reserved for future agent-server config. Empty today — opaque tokens\n * (post-0.0.35) need no signing key, and the dev server hard-codes the\n * identity resolver to `'dev-user'`. The shape is kept so callers can\n * pass `agent: { ... }` and we can grow options without churning the\n * public type.\n */\nexport type AgentPluginConfig = Record<string, never>\n\n/**\n * Does `@llui/mcp` resolve from `root`'s node_modules? Uses\n * `require.resolve` so monorepo workspaces and hoisted installs both\n * work. Catches failures silently — the only consequence is that we\n * leave `mcpPort` disabled, which is the safe default.\n */\nfunction hasMcpPackage(root: string): boolean {\n try {\n const req = createRequire(resolve(root, 'package.json'))\n req.resolve('@llui/mcp/package.json')\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Resolve the path to the llui-mcp CLI entry. Reads `bin.llui-mcp`\n * from @llui/mcp's package.json and joins it against the package\n * directory. Returns null if @llui/mcp isn't resolvable.\n */\nfunction resolveMcpCliPath(root: string): string | null {\n try {\n const req = createRequire(resolve(root, 'package.json'))\n const pkgJsonPath = req.resolve('@llui/mcp/package.json')\n const pkgJson = JSON.parse(readFileSync(pkgJsonPath, 'utf8')) as {\n bin?: string | Record<string, string>\n }\n const binEntry = typeof pkgJson.bin === 'string' ? pkgJson.bin : pkgJson.bin?.['llui-mcp']\n if (!binEntry) return null\n return resolve(dirname(pkgJsonPath), binEntry)\n } catch {\n return null\n }\n}\n\ntype AgentServerInstance = {\n router: (req: Request) => Promise<Response | null>\n wsUpgrade: (\n req: import('http').IncomingMessage,\n socket: import('stream').Duplex,\n head: Buffer,\n ) => void\n}\n\n/**\n * Dynamically load @llui/agent/server relative to the app root and\n * construct an agent server instance. Returns null if @llui/agent isn't\n * installed — the plugin degrades to \"prod schema emission only\" mode.\n */\nasync function loadAgentServer(\n appRoot: string,\n _cfg: AgentPluginConfig,\n): Promise<AgentServerInstance | null> {\n let serverModule: {\n createLluiAgentServer: (opts: {\n identityResolver?: (req: Request) => Promise<string | null>\n }) => AgentServerInstance\n }\n try {\n // Walk up from the app root to find node_modules/@llui/agent. Works\n // for both pnpm workspace and regular npm installs. Direct file-system\n // walk avoids \"exports\" / \"subpath './package.json'\" gymnastics that\n // require.resolve and Node's module resolver disagree on.\n const pkgDir = findPackageDir(appRoot, '@llui/agent')\n if (!pkgDir) throw new Error('not found in any ancestor node_modules')\n const pkg = JSON.parse(readFileSync(resolve(pkgDir, 'package.json'), 'utf8')) as {\n exports?: Record<string, { import?: string } | string>\n }\n const serverExport = pkg.exports?.['./server']\n const rel = typeof serverExport === 'string' ? serverExport : serverExport?.import\n if (!rel) throw new Error('missing ./server export in package.json')\n const modUrl = new URL(`file://${resolve(pkgDir, rel)}`).href\n serverModule = (await import(modUrl)) as typeof serverModule\n } catch (e) {\n console.warn(\n '[llui] agent: true is set but `@llui/agent` could not be loaded: ' +\n (e instanceof Error ? e.message : String(e)),\n )\n return null\n }\n\n // The pre-0.0.35 agent server required an HMAC signingKey for JWT\n // tokens. The opaque-token rewrite removed that option; the dev\n // server here just calls the factory with no auth config — the\n // in-memory token store is the source of truth.\n return serverModule.createLluiAgentServer({\n identityResolver: async () => 'dev-user',\n })\n}\n\n/**\n * Register the agent middleware + WS upgrade on the Vite dev server.\n * Must be called synchronously from configureServer so registration\n * happens BEFORE Vite installs its catch-all SPA fallback.\n */\nfunction registerAgentMiddleware(server: ViteDevServer, agent: AgentServerInstance): void {\n // Connect-style middleware. Vite's middleware chain runs in order, so\n // synchronous registration during configureServer places us ahead of\n // Vite's catch-all fallback.\n //\n // Dual-path: handle the canonical `/agent/*` (every project) AND\n // `/cdn-cgi/agent/*` (defensive — Cloudflare's `@cloudflare/vite-plugin`\n // routes everything except `/cdn-cgi/*` to the worker, which means\n // canonical `/agent/*` paths are shadowed in cloudflare-vite projects).\n // The cdn-cgi prefix is stripped before forwarding so the agent\n // server's router sees its own canonical paths regardless of which\n // public URL the client used. This matches the dual-path strategy\n // used for `/__llui_mcp_status`.\n server.middlewares.use((req, res, next) => {\n const url = req.url ?? '/'\n let stripped: string | null = null\n if (url.startsWith('/agent/') || url === '/agent') stripped = url\n else if (url.startsWith('/cdn-cgi/agent/') || url === '/cdn-cgi/agent') {\n stripped = url.slice('/cdn-cgi'.length)\n }\n if (stripped === null) {\n next()\n return\n }\n // Rewrite the request URL in-place so handleAgentRequest's path\n // matching sees `/agent/*`. Connect middleware can mutate req.url\n // for downstream handlers; we own the request from here.\n req.url = stripped\n void handleAgentRequest(req, res, agent.router).catch((e) => {\n console.error('[llui] agent middleware error:', e)\n next(e)\n })\n })\n\n // WS upgrade: only /agent/ws goes to the agent. Vite's own HMR upgrade\n // uses a different path and runs as a separate listener on the same\n // event, so this filter keeps both coexisting. Same dual-path\n // accommodation as the HTTP middleware — the WS-upgrade path doesn't\n // actually matter to most cloudflare setups (the worker handles WS\n // upgrades natively), but keeping the parity simplifies the mental\n // model for ops.\n server.httpServer?.on('upgrade', (req, socket, head) => {\n const url = new URL(req.url ?? '/', 'http://localhost')\n if (url.pathname === '/agent/ws' || url.pathname === '/cdn-cgi/agent/ws') {\n agent.wsUpgrade(req, socket, head)\n }\n })\n\n console.info(\n '[llui] agent dev endpoints active: POST /agent/mint, WS /agent/ws, LAP /agent/lap/v1/* (also reachable under /cdn-cgi/agent/* for cloudflare-vite parity)',\n )\n}\n\n/**\n * Walk up from `start` looking for `node_modules/<pkgName>`. Returns the\n * absolute path to the package directory, or null if not found.\n */\nfunction findPackageDir(start: string, pkgName: string): string | null {\n let dir = resolve(start)\n while (true) {\n const candidate = resolve(dir, 'node_modules', pkgName)\n if (existsSync(resolve(candidate, 'package.json'))) return candidate\n const parent = dirname(dir)\n if (parent === dir) return null\n dir = parent\n }\n}\n\n/** Convert a Node http req → Web Request, call router, write the response. */\nasync function handleAgentRequest(\n req: import('http').IncomingMessage,\n res: import('http').ServerResponse,\n router: (req: Request) => Promise<Response | null>,\n): Promise<void> {\n const method = req.method ?? 'GET'\n const url = req.url ?? '/'\n const headers: Record<string, string> = {}\n for (const [k, v] of Object.entries(req.headers)) {\n if (v === undefined) continue\n headers[k] = Array.isArray(v) ? v.join(', ') : v\n }\n let body: BodyInit | undefined\n if (!['GET', 'HEAD'].includes(method)) {\n const chunks: Buffer[] = []\n for await (const chunk of req) chunks.push(chunk as Buffer)\n if (chunks.length > 0) body = new Uint8Array(Buffer.concat(chunks))\n }\n const origin = `http://${req.headers.host ?? 'localhost'}`\n const webReq = new Request(`${origin}${url}`, { method, headers, body })\n const webRes = await router(webReq)\n if (!webRes) {\n res.statusCode = 404\n res.end()\n return\n }\n res.statusCode = webRes.status\n webRes.headers.forEach((v, k) => res.setHeader(k, v))\n const buf = Buffer.from(await webRes.arrayBuffer())\n res.end(buf)\n}\n\nexport default function llui(options: LluiPluginOptions = {}): Plugin {\n let devMode = false\n // `mcpPort` + `mcpMode` are resolved lazily in `configResolved` so we\n // can check for @llui/mcp in the consuming project's node_modules.\n // - `options.mcpPort === false` → disabled\n // - explicit number → wire-only (user manages the server)\n // - undefined + @llui/mcp found → spawn (plugin starts llui-mcp --http)\n // - undefined + no @llui/mcp → disabled\n let mcpPort: number | null = null\n let mcpMode: 'disabled' | 'wire' | 'spawn' = 'disabled'\n let mcpCliPath: string | null = null\n let mcpChild: ChildProcess | null = null\n const verbose = options.verbose === true\n const agent = options.agent ?? false\n const agentConfig: AgentPluginConfig = typeof agent === 'object' ? agent : {}\n // Agent server instance — loaded in configResolved (async), registered\n // in configureServer (sync). Null until loaded, or if @llui/agent isn't\n // installed.\n let agentServer: {\n router: (req: Request) => Promise<Response | null>\n wsUpgrade: (\n req: import('http').IncomingMessage,\n socket: import('stream').Duplex,\n head: Buffer,\n ) => void\n } | null = null\n\n // File-based handshake with @llui/mcp. The MCP server writes a marker\n // file when its bridge starts; we watch it and send a Vite HMR custom\n // event so the browser can call __lluiConnect() automatically — without\n // retry spam, regardless of whether MCP or Vite started first.\n const activeFilePath = resolve(findWorkspaceRoot(), 'node_modules/.cache/llui-mcp/active.json')\n let mcpWatcher: FSWatcher | null = null\n let dirWatcher: FSWatcher | null = null\n // Cached once Vite's HTTP server emits `listening`. `stampDevUrl()`\n // uses this to write the URL into the marker file — either immediately\n // (if MCP already started and wrote one) or later when the marker\n // appears via the directory watcher (MCP-starts-after-Vite path).\n let cachedDevUrl: string | null = null\n\n function readMcpMarker(): { port: number; devUrl?: string } | null {\n try {\n if (!existsSync(activeFilePath)) return null\n const data = JSON.parse(readFileSync(activeFilePath, 'utf8')) as {\n port?: number\n devUrl?: string\n }\n if (typeof data.port !== 'number') return null\n return { port: data.port, ...(data.devUrl ? { devUrl: data.devUrl } : {}) }\n } catch {\n return null\n }\n }\n\n /**\n * Idempotently write `cachedDevUrl` into the marker file. No-op if the\n * URL hasn't been captured yet (Vite hasn't emitted `listening`) or if\n * the marker file doesn't exist (MCP hasn't started yet). Covers both\n * orderings — the listening hook calls this after caching, and the\n * directory watcher calls it when the marker appears later.\n */\n function stampDevUrl(): void {\n if (cachedDevUrl === null) return\n if (!existsSync(activeFilePath)) return\n try {\n const marker = JSON.parse(readFileSync(activeFilePath, 'utf8')) as Record<string, unknown>\n if (marker.devUrl === cachedDevUrl) return\n marker.devUrl = cachedDevUrl\n writeFileSync(activeFilePath, JSON.stringify(marker))\n } catch {\n // Best-effort — failure to update the marker should not crash Vite\n }\n }\n\n function notifyMcpReady(server: ViteDevServer): void {\n const marker = readMcpMarker()\n if (marker === null) return\n server.ws.send({ type: 'custom', event: 'llui:mcp-ready', data: marker })\n }\n\n function notifyMcpOffline(server: ViteDevServer): void {\n server.ws.send({ type: 'custom', event: 'llui:mcp-offline', data: {} })\n }\n\n return {\n name: 'llui',\n enforce: 'pre',\n\n async configResolved(config) {\n devMode = config.command === 'serve' || config.mode === 'development'\n // Load @llui/agent here (async) so we can register middleware\n // synchronously in configureServer — which must happen BEFORE Vite\n // installs its catch-all SPA/fallback middleware.\n if (agent && devMode) {\n agentServer = await loadAgentServer(config.root, agentConfig)\n }\n if (options.mcpPort === false) {\n mcpMode = 'disabled'\n mcpPort = null\n } else if (typeof options.mcpPort === 'number') {\n mcpMode = 'wire'\n mcpPort = options.mcpPort\n } else if (hasMcpPackage(config.root)) {\n mcpCliPath = resolveMcpCliPath(config.root)\n if (mcpCliPath) {\n mcpMode = 'spawn'\n mcpPort = 5200\n } else {\n mcpMode = 'wire'\n mcpPort = 5200\n }\n } else {\n mcpMode = 'disabled'\n mcpPort = null\n }\n },\n\n configureServer(server) {\n // Agent dev endpoints — runs regardless of mcp state. Must be before\n // any early-returns below. Registration is synchronous because\n // agentServer was preloaded in configResolved.\n if (agentServer) {\n registerAgentMiddleware(server, agentServer)\n }\n\n if (mcpPort === null) {\n // #3 diagnostic: MCP server is running but the plugin is opted\n // out. Users in this state usually don't realize the mismatch —\n // loud-and-early log saves the \"why isn't my MCP attached\" hunt.\n if (existsSync(activeFilePath)) {\n console.warn(\n `[llui] @llui/mcp server is running (marker at ${activeFilePath}) ` +\n `but the Vite plugin is opted out (mcpPort: false, or @llui/mcp ` +\n `isn't a dep of this project). Add \\`llui({ mcpPort: 5200 })\\` ` +\n `to vite.config to wire them up, or remove the marker file and ` +\n `stop the MCP server if the mismatch was unintended.`,\n )\n }\n return\n }\n\n // Spawn mode: plugin launches llui-mcp as a child process so\n // `pnpm dev` handles the whole stack. Skip spawning when a marker\n // already exists — something (usually a separate llui-mcp process\n // started before Vite) is already listening. The existing wire\n // behavior takes over from there.\n if (mcpMode === 'spawn' && mcpCliPath !== null && !existsSync(activeFilePath)) {\n mcpChild = spawn(process.execPath, [mcpCliPath, '--http', String(mcpPort)], {\n stdio: ['ignore', 'pipe', 'pipe'],\n env: { ...process.env, LLUI_MCP_PORT: String(mcpPort) },\n })\n mcpChild.stdout?.on('data', (buf: Buffer) => {\n process.stdout.write(`[mcp] ${buf.toString()}`)\n })\n mcpChild.stderr?.on('data', (buf: Buffer) => {\n process.stderr.write(`[mcp] ${buf.toString()}`)\n })\n mcpChild.on('exit', (code) => {\n if (code !== 0 && code !== null) {\n console.warn(`[llui] @llui/mcp child exited with code ${code}`)\n }\n mcpChild = null\n })\n const killChild = (): void => {\n if (mcpChild && !mcpChild.killed) mcpChild.kill('SIGTERM')\n }\n server.httpServer?.on('close', killChild)\n process.once('exit', killChild)\n }\n\n // HTTP endpoint: the browser fetches this on load to discover the\n // current MCP port. Avoids the race where HMR events sent before\n // the import.meta.hot listener registers get dropped — and lets\n // the browser connect to the actual port (which may differ from\n // the compile-time default if MCP was started with LLUI_MCP_PORT).\n //\n // Two paths register the same handler:\n // * `/__llui_mcp_status` — canonical, served from any Vite\n // project.\n // * `/cdn-cgi/llui_mcp_status` — fallback for projects that\n // bundle `@cloudflare/vite-plugin`. The cloudflare plugin\n // intercepts every HTTP request in `configureServer` and\n // routes it to the worker, except `/cdn-cgi/*` which it\n // explicitly lets through. Without this fallback, MCP\n // auto-discovery silently fails under workerd.\n const mcpStatusHandler = (_req: unknown, res: ServerResponseLike): void => {\n const marker = readMcpMarker()\n if (marker === null) {\n res.statusCode = 404\n res.end()\n return\n }\n res.statusCode = 200\n res.setHeader('content-type', 'application/json')\n res.end(JSON.stringify({ port: marker.port }))\n }\n server.middlewares.use('/__llui_mcp_status', mcpStatusHandler)\n server.middlewares.use('/cdn-cgi/llui_mcp_status', mcpStatusHandler)\n\n // Watch the marker file for create/delete. fs.watch on the parent\n // directory catches both events; the file itself may not exist\n // when we start watching.\n const dir = dirname(activeFilePath)\n try {\n // Watch the parent directory for the marker file appearing/disappearing\n const watchDir = (): void => {\n if (!existsSync(dir)) return\n dirWatcher = fsWatch(dir, (_event, filename) => {\n if (filename !== 'active.json') return\n if (existsSync(activeFilePath)) {\n // Stamp BEFORE notifying so the `llui:mcp-ready` payload\n // carries the cached devUrl. This is the MCP-after-Vite\n // path: listening already fired and cached the URL; the\n // marker is only now appearing.\n stampDevUrl()\n notifyMcpReady(server)\n } else {\n notifyMcpOffline(server)\n }\n })\n }\n if (existsSync(dir)) {\n watchDir()\n } else {\n // Parent directory doesn't exist yet — poll for it briefly\n const poll = setInterval(() => {\n if (existsSync(dir)) {\n clearInterval(poll)\n watchDir()\n }\n }, 1000)\n // Clean up the poller if vite shuts down before MCP starts\n server.httpServer?.on('close', () => clearInterval(poll))\n }\n } catch {\n // fs.watch can fail on some filesystems — degrade silently\n }\n\n // Re-send the ready event when a new HMR client connects, in case\n // the page loads while MCP is already running.\n server.ws.on('connection', () => {\n if (existsSync(activeFilePath)) notifyMcpReady(server)\n })\n\n server.httpServer?.on('close', () => {\n mcpWatcher?.close()\n dirWatcher?.close()\n mcpWatcher = null\n dirWatcher = null\n })\n\n // Once Vite's HTTP server is listening, cache our dev URL and stamp\n // it into the marker file. Two orderings are possible:\n // (a) MCP started FIRST → marker exists now → stampDevUrl() writes\n // it, and we broadcast llui:mcp-ready so the browser picks up\n // the devUrl without relying on an incidental fs.watch tick\n // (which can miss on NFS/SMB).\n // (b) MCP will start LATER → marker doesn't exist yet → stamp is a\n // no-op. When MCP eventually writes the marker, the directory\n // watcher fires, calls stampDevUrl(), and notifies.\n server.httpServer?.once('listening', () => {\n const address = server.httpServer?.address()\n if (!address || typeof address !== 'object') return\n const host =\n address.address === '::' || address.address === '0.0.0.0' ? 'localhost' : address.address\n cachedDevUrl = `http://${host}:${address.port}`\n stampDevUrl()\n // Broadcast after stamping so the payload carries devUrl. Only\n // fires in case (a) — notifyMcpReady no-ops when the marker is\n // absent.\n notifyMcpReady(server)\n })\n\n // ── Agent dev endpoints ──────────────────────────────────────\n // When `agent: true` (or `agent: {...}`), auto-mount /agent/* on\n // the Vite dev server so `pnpm dev` has working agent endpoints.\n // Users with a custom server.ts (SSR apps) mount createLluiAgentServer\n // themselves — configureServer also fires in middleware mode, but\n // there server.httpServer is null so the upgrade hook is a no-op.\n },\n\n async transform(code, id, options) {\n if (!id.endsWith('.ts') && !id.endsWith('.tsx')) return\n\n // `'use client'` directive — SSR builds replace the module with a\n // stub so top-level imports and side effects never run on the\n // server. Client builds pass through to the normal transform; the\n // directive is effectively a no-op on the client.\n if (options?.ssr && hasUseClientDirective(code)) {\n const result = transformUseClientSsr(code, id)\n if (result) {\n const cwd = process.cwd()\n const rel = relative(cwd, id)\n const display = rel.startsWith('..') ? id : rel\n for (const warning of result.warnings) {\n this.warn(`${display}: ${warning}`)\n }\n return { code: result.output, map: { mappings: '' } }\n }\n }\n\n // Pre-resolve cross-file type sources for any `component<S, M, E>()`\n // call in this file. The extractors look for `type Msg = ...` etc.\n // in a single source string; if the user keeps `Msg` in a sibling\n // file, the local extraction returns null and the plugin emits no\n // annotations. Pre-resolution chases imports and re-exports to\n // find the declaring file, so the schema/annotation extractors run\n // against the right source. See cross-file-resolver.ts.\n //\n // `this.resolve` may be undefined in test harnesses that call the\n // hook directly without going through Rollup; in that case skip\n // pre-resolution and the local extractors handle whatever's in\n // the source string.\n const resolverAvailable = typeof this.resolve === 'function'\n const [typeSources, preExtracted] = resolverAvailable\n ? await Promise.all([\n preResolveTypeSources(code, id, this.resolve.bind(this)),\n // Cross-file + composition-aware extraction. Replaces the\n // file-local sync extractors when active. Without this step\n // a `type Msg = ImportedFoo | { type: 'extra' }`\n // composition would only see the inline `'extra'` variant\n // and silently emit half-annotations.\n preExtractCompositional(code, id, this.resolve.bind(this)),\n ])\n : [undefined, undefined]\n\n const result = transformLlui(\n code,\n id,\n devMode,\n Boolean(agent),\n mcpPort,\n verbose,\n typeSources,\n preExtracted,\n )\n if (!result) return undefined\n\n // Apply per-statement edits via MagicString for accurate source maps.\n // Untouched statements keep their original positions.\n const s = new MagicString(code)\n for (const edit of result.edits) {\n if (edit.start === edit.end) {\n // Insert at position — appendRight for middle, append for end-of-file\n if (edit.start === code.length) s.append(edit.replacement)\n else s.appendRight(edit.start, edit.replacement)\n } else {\n s.overwrite(edit.start, edit.end, edit.replacement)\n }\n }\n\n return {\n code: s.toString(),\n map: s.generateMap({ source: id, includeContent: true, hires: true }),\n }\n },\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,WAAW,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,IAAI,OAAO,EAAkB,MAAM,SAAS,CAAA;AACnG,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,4BAA4B,EAC5B,uBAAuB,GAGxB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAEzD,0DAA0D;AAC1D,+DAA+D;AAC/D,qDAAqD;AACrD,4BAA4B,CAAC,oBAAoB,CAAC,CAAA;AAClD,uBAAuB,CAAC,eAAe,CAAC,CAAA;AACxC,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,8BAA8B,EAC9B,wCAAwC,GAEzC,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B;;;;;;;;;;;;;;;;;;GAkBG;AACH,KAAK,UAAU,qBAAqB,CAClC,MAAc,EAC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,EAAE,CAAC;gBACtB,IAAI,CAAC,KAAK,CACR,0EAA0E;oBACxE,iEAAiE;oBACjE,yEAAyE;oBACzE,wEAAwE;oBACxE,4EAA4E;oBAC5E,0DAA0D;oBAC1D,yCAAyC,CAC5C,CAAA;YACH,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import type { Plugin, ViteDevServer } from 'vite'\n\n// Minimal subset of `http.ServerResponse` we use in the MCP-status\n// handler. Avoids a heavy `node:http` import at the top of the file.\ninterface ServerResponseLike {\n statusCode: number\n setHeader(name: string, value: string): void\n end(body?: string): void\n}\nimport MagicString from 'magic-string'\nimport { existsSync, readFileSync, writeFileSync, watch as fsWatch, type FSWatcher } from 'node:fs'\nimport { readFile } from 'node:fs/promises'\nimport { dirname, relative, resolve } from 'node:path'\nimport { createRequire } from 'node:module'\nimport { spawn, type ChildProcess } from 'node:child_process'\nimport {\n transformLlui,\n crossFileAccessorPaths,\n registerIntrospectionFactory,\n registerDevtoolsFactory,\n type ExternalTypeSources,\n type PreExtractedSchemas,\n} from '@llui/compiler'\nimport { transformUseClientSsr, hasUseClientDirective } from '@llui/compiler-ssr'\nimport { introspectionFactory } from '@llui/compiler-introspection'\nimport { devtoolsFactory } from '@llui/compiler-devtools'\n\n// Register opt-in module factories at plugin-import time.\n// @llui/compiler doesn't depend on its sibling packages (would\n// create a workspace cycle), so the host wires them.\nregisterIntrospectionFactory(introspectionFactory)\nregisterDevtoolsFactory(devtoolsFactory)\nimport {\n findTypeSource,\n readComponentTypeArgNames,\n extractMsgAnnotationsCrossFile,\n extractDiscriminatedUnionSchemaCrossFile,\n type ResolveContext,\n} from '@llui/compiler'\nimport ts from 'typescript'\n\n/**\n * Pre-resolution step run before `transformLlui`. Scans the source for\n * `component<State, Msg, Effect>(...)` calls; for each type argument that\n * is an identifier (the common case), walks imports and re-exports to\n * find the source file declaring that alias. The result is plumbed into\n * `transformLlui` so the schema/annotation extractors operate on the\n * declaring file's source instead of silently returning `null` when the\n * type lives in a separate file.\n *\n * Returns `undefined` (no external sources) when:\n * - No `component<...>()` call is in the file\n * - No type arguments are identifiers we can chase\n * - All type arguments are declared locally (the resolver returns the\n * same source we already have, so external sources are redundant)\n *\n * `resolveModule` comes from Rollup's `this.resolve()`; we wrap it to\n * return the absolute id (or null when unresolved) and read the source\n * via `fs/promises.readFile`.\n */\nasync function preResolveTypeSources(\n source: string,\n filePath: string,\n rollupResolve: (\n spec: string,\n importer: string,\n ) => Promise<{ id: string; external?: boolean | 'absolute' | 'relative' } | null>,\n): Promise<ExternalTypeSources | undefined> {\n // Cheap filter: nothing to resolve unless the file contains a\n // component<...>() call. Avoids parsing every TS file in the project.\n if (!/\\bcomponent\\s*</.test(source)) return undefined\n\n // Find the first component<...>() call and read its type arg names.\n // Multiple component() calls in one file would each technically need\n // their own type-arg lookup; we resolve based on the first call and\n // accept the (rare) edge case where two component() calls in one file\n // use different non-local Msg types. The lint rule catches divergence.\n const sf = ts.createSourceFile(filePath, source, ts.ScriptTarget.Latest, true)\n const args = findFirstComponentTypeArgs(sf)\n if (!args) return undefined\n\n const ctx: ResolveContext = {\n resolveModule: async (spec, importer) => {\n const result = await rollupResolve(spec, importer)\n if (!result || result.external) return null\n // Rollup ids can include query/hash suffixes for virtual modules;\n // strip those so fs.readFile sees a real path. Also skip files\n // outside our control (node_modules) — we don't want to follow\n // imports into third-party packages just to scrape types.\n const idStripped = result.id.split('?')[0]?.split('#')[0]\n if (!idStripped) return null\n if (idStripped.includes('/node_modules/')) return null\n return idStripped\n },\n readSource: async (p) => {\n return await readFile(p, 'utf8')\n },\n }\n\n // Helper to resolve one type-arg name into an external source if it\n // isn't declared locally (or if the resolver chases through imports).\n const resolve = async (\n typeName: string | null,\n ): Promise<{ source: string; typeName: string } | undefined> => {\n if (!typeName) return undefined\n const found = await findTypeSource(typeName, source, filePath, ctx)\n if (!found) return undefined\n // If the alias was declared locally, the existing extractor path\n // already handles it — no need to populate external sources.\n if (found.filePath === filePath) return undefined\n return { source: found.source, typeName: found.localName }\n }\n\n const [state, msg, effect] = await Promise.all([\n resolve(args.state),\n resolve(args.msg),\n resolve(args.effect),\n ])\n\n if (!state && !msg && !effect) return undefined\n return { state, msg, effect }\n}\n\n/**\n * Cross-file + composition-aware schema extraction. The extractors\n * follow imports/re-exports AND walk into TypeReferences inside Msg /\n * Effect unions, so a developer who organises types as\n * `type Msg = ImportedFoo | { type: 'extra' }` gets every variant in\n * `__msgAnnotations` and `__msgSchema`. Without this step the\n * file-local sync extractors would silently emit half-annotations\n * (only the inline TypeLiteral members) — the worst kind of failure\n * mode because the build appears to succeed.\n *\n * Returns `undefined` (no pre-extraction) when there's no\n * `component()` call to resolve types for.\n */\nasync function preExtractCompositional(\n source: string,\n filePath: string,\n rollupResolve: (\n spec: string,\n importer: string,\n ) => Promise<{ id: string; external?: boolean | 'absolute' | 'relative' } | null>,\n): Promise<PreExtractedSchemas | undefined> {\n if (!/\\bcomponent\\s*</.test(source)) return undefined\n const sf = ts.createSourceFile(filePath, source, ts.ScriptTarget.Latest, true)\n const args = findFirstComponentTypeArgs(sf)\n if (!args) return undefined\n // No identifier type args at all → nothing for the resolver to chase.\n if (!args.msg && !args.effect && !args.state) return undefined\n\n const ctx: ResolveContext = {\n resolveModule: async (spec, importer) => {\n const result = await rollupResolve(spec, importer)\n if (!result || result.external) return null\n const idStripped = result.id.split('?')[0]?.split('#')[0]\n if (!idStripped) return null\n if (idStripped.includes('/node_modules/')) return null\n return idStripped\n },\n readSource: async (p) => readFile(p, 'utf8'),\n }\n\n const [msgAnnotations, msgSchema, effectSchema] = await Promise.all([\n args.msg\n ? extractMsgAnnotationsCrossFile(source, args.msg, filePath, ctx)\n : Promise.resolve(null),\n args.msg\n ? extractDiscriminatedUnionSchemaCrossFile(source, args.msg, filePath, ctx)\n : Promise.resolve(null),\n args.effect\n ? extractDiscriminatedUnionSchemaCrossFile(source, args.effect, filePath, ctx)\n : Promise.resolve(null),\n ])\n\n // Only return a populated payload when we actually extracted\n // something useful. Returning `undefined` lets transformLlui fall\n // back to its file-local extractors, which is the right behavior\n // for the (rare) case where every type the resolver sees is\n // unreachable.\n if (msgAnnotations === null && msgSchema === null && effectSchema === null) return undefined\n\n // Note: state schema isn't a discriminated union, so composition\n // doesn't apply. We leave state on the simpler `typeSources` path\n // (already plumbed through preResolveTypeSources) which the\n // file-local `extractStateSchema` consumes.\n const out: PreExtractedSchemas = {}\n if (msgAnnotations !== null) out.msgAnnotations = msgAnnotations\n if (msgSchema !== null) out.msgSchema = msgSchema\n if (effectSchema !== null) out.effectSchema = effectSchema\n return out\n}\n\nfunction findFirstComponentTypeArgs(\n sf: ts.SourceFile,\n): { state: string | null; msg: string | null; effect: string | null } | null {\n let result: ReturnType<typeof readComponentTypeArgNames> | null = null\n const visit = (node: ts.Node): boolean => {\n if (result) return true\n if (\n ts.isCallExpression(node) &&\n ts.isIdentifier(node.expression) &&\n node.expression.text === 'component' &&\n node.typeArguments\n ) {\n result = readComponentTypeArgNames(node)\n return true\n }\n let stopped = false\n ts.forEachChild(node, (child) => {\n if (stopped) return\n if (visit(child)) stopped = true\n })\n return stopped\n }\n ts.forEachChild(sf, (child) => {\n visit(child)\n })\n return result\n}\n\n/**\n * Locate the workspace root so we share the MCP active marker file\n * with @llui/mcp regardless of which subdirectory the dev server runs in.\n * Mirrors `findWorkspaceRoot` from @llui/mcp — duplicated to avoid a\n * vite-plugin → mcp dependency cycle. The contract must stay in sync.\n */\nfunction findWorkspaceRoot(start: string = process.cwd()): string {\n let dir = resolve(start)\n let lastPackageJson: string | null = null\n while (true) {\n if (existsSync(resolve(dir, 'pnpm-workspace.yaml'))) return dir\n if (existsSync(resolve(dir, '.git'))) return dir\n if (existsSync(resolve(dir, 'package.json'))) lastPackageJson = dir\n const parent = dirname(dir)\n if (parent === dir) return lastPackageJson ?? start\n dir = parent\n }\n}\n\nexport interface LluiPluginOptions {\n /**\n * Port for the MCP debug bridge. In dev mode, the runtime relay connects\n * to `ws://127.0.0.1:<port>` so an external `llui-mcp` server can forward\n * tool calls into the running app.\n *\n * When omitted, the plugin checks whether `@llui/mcp` is resolvable from\n * the Vite project root. If yes → defaults to `5200`. If no → stays\n * disabled. This means installing `@llui/mcp` (+ starting its server)\n * Just Works without an explicit config entry. Pass an explicit `false`\n * to opt out even when `@llui/mcp` is installed; pass a number to use\n * a non-default port. When enabled but the MCP server isn't running,\n * the plugin returns 404 from its discovery endpoint and the browser\n * silently skips the connection — no retry noise.\n */\n mcpPort?: number | false\n\n /**\n * Emit `[llui]`-prefixed `console.info` logs for every transformed\n * component file — state-path bit assignments, mask injections, and\n * helper compile/bail counts. Useful when diagnosing why a binding\n * isn't gated the way you expect, or why a call fell back from\n * template-clone to `elSplit`. Off by default.\n */\n verbose?: boolean\n\n /**\n * Enables two things together when set:\n *\n * 1. Emits schemas + binding descriptors in prod builds so the\n * @llui/agent runtime has metadata to advertise over its WS hello\n * frame (see agent spec §7.4).\n * 2. Auto-mounts `@llui/agent/server`'s router at `/agent/*` and its\n * WS upgrade handler at `/agent/ws` on the Vite dev server — so\n * plain `vite dev` has working agent endpoints with no extra\n * server.ts wiring. Requires `@llui/agent` installed; if it isn't,\n * the plugin warns and skips dev mounting (prod emission still\n * works from Plan 3b).\n *\n * Pass `true` for defaults (random signing key per dev session;\n * `identityResolver` returns `'dev-user'`). Pass an object to customize.\n * Default `false` — metadata is dev-only, no agent endpoints.\n */\n agent?: boolean | AgentPluginConfig\n\n /**\n * Opt-in cross-file accessor walking (v2c pipeline integration of v2b's\n * cross-file walker). When enabled, the plugin builds a `ts.Program`\n * over the project at `configResolved` and feeds each `transform` call\n * the cross-file paths read through in-repo view-helpers — replacing\n * the v0.x sentinel-`show()` workaround for helpers in sibling files.\n *\n * Prototype-grade caveats:\n * - The Program builds once at startup; it does NOT refresh on file\n * change. HMR-edited files see stale cross-file edges until the\n * next dev-server restart. (v2c's module decomposition lands the\n * proper incremental Program; this is the v2b pipeline-integration\n * deferral.)\n * - The Program covers `.ts` / `.tsx` files reachable from the Vite\n * project root's `tsconfig.json`. Out-of-project imports are not\n * followed; manifest-driven library helpers cover those in\n * `@llui/cli publish-deps` (v2c, deferred).\n * - The walker emits `llui/opaque-view-call` diagnostics for helpers\n * it can't classify; in dev these surface as Vite warnings. Set\n * `crossFile: 'silent'` to suppress the diagnostics while still\n * getting the path merging.\n *\n * Default `false` — preserves pre-v2c per-file behavior. Enable\n * explicitly to opt in to the cross-file resolution.\n */\n crossFile?: boolean | 'silent'\n}\n\n/**\n * Reserved for future agent-server config. Empty today — opaque tokens\n * (post-0.0.35) need no signing key, and the dev server hard-codes the\n * identity resolver to `'dev-user'`. The shape is kept so callers can\n * pass `agent: { ... }` and we can grow options without churning the\n * public type.\n */\nexport type AgentPluginConfig = Record<string, never>\n\n/**\n * Does `@llui/mcp` resolve from `root`'s node_modules? Uses\n * `require.resolve` so monorepo workspaces and hoisted installs both\n * work. Catches failures silently — the only consequence is that we\n * leave `mcpPort` disabled, which is the safe default.\n */\nfunction hasMcpPackage(root: string): boolean {\n try {\n const req = createRequire(resolve(root, 'package.json'))\n req.resolve('@llui/mcp/package.json')\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Resolve the path to the llui-mcp CLI entry. Reads `bin.llui-mcp`\n * from @llui/mcp's package.json and joins it against the package\n * directory. Returns null if @llui/mcp isn't resolvable.\n */\nfunction resolveMcpCliPath(root: string): string | null {\n try {\n const req = createRequire(resolve(root, 'package.json'))\n const pkgJsonPath = req.resolve('@llui/mcp/package.json')\n const pkgJson = JSON.parse(readFileSync(pkgJsonPath, 'utf8')) as {\n bin?: string | Record<string, string>\n }\n const binEntry = typeof pkgJson.bin === 'string' ? pkgJson.bin : pkgJson.bin?.['llui-mcp']\n if (!binEntry) return null\n return resolve(dirname(pkgJsonPath), binEntry)\n } catch {\n return null\n }\n}\n\ntype AgentServerInstance = {\n router: (req: Request) => Promise<Response | null>\n wsUpgrade: (\n req: import('http').IncomingMessage,\n socket: import('stream').Duplex,\n head: Buffer,\n ) => void\n}\n\n/**\n * Dynamically load @llui/agent/server relative to the app root and\n * construct an agent server instance. Returns null if @llui/agent isn't\n * installed — the plugin degrades to \"prod schema emission only\" mode.\n */\nasync function loadAgentServer(\n appRoot: string,\n _cfg: AgentPluginConfig,\n): Promise<AgentServerInstance | null> {\n let serverModule: {\n createLluiAgentServer: (opts: {\n identityResolver?: (req: Request) => Promise<string | null>\n }) => AgentServerInstance\n }\n try {\n // Walk up from the app root to find node_modules/@llui/agent. Works\n // for both pnpm workspace and regular npm installs. Direct file-system\n // walk avoids \"exports\" / \"subpath './package.json'\" gymnastics that\n // require.resolve and Node's module resolver disagree on.\n const pkgDir = findPackageDir(appRoot, '@llui/agent')\n if (!pkgDir) throw new Error('not found in any ancestor node_modules')\n const pkg = JSON.parse(readFileSync(resolve(pkgDir, 'package.json'), 'utf8')) as {\n exports?: Record<string, { import?: string } | string>\n }\n const serverExport = pkg.exports?.['./server']\n const rel = typeof serverExport === 'string' ? serverExport : serverExport?.import\n if (!rel) throw new Error('missing ./server export in package.json')\n const modUrl = new URL(`file://${resolve(pkgDir, rel)}`).href\n serverModule = (await import(modUrl)) as typeof serverModule\n } catch (e) {\n console.warn(\n '[llui] agent: true is set but `@llui/agent` could not be loaded: ' +\n (e instanceof Error ? e.message : String(e)),\n )\n return null\n }\n\n // The pre-0.0.35 agent server required an HMAC signingKey for JWT\n // tokens. The opaque-token rewrite removed that option; the dev\n // server here just calls the factory with no auth config — the\n // in-memory token store is the source of truth.\n return serverModule.createLluiAgentServer({\n identityResolver: async () => 'dev-user',\n })\n}\n\n/**\n * Register the agent middleware + WS upgrade on the Vite dev server.\n * Must be called synchronously from configureServer so registration\n * happens BEFORE Vite installs its catch-all SPA fallback.\n */\nfunction registerAgentMiddleware(server: ViteDevServer, agent: AgentServerInstance): void {\n // Connect-style middleware. Vite's middleware chain runs in order, so\n // synchronous registration during configureServer places us ahead of\n // Vite's catch-all fallback.\n //\n // Dual-path: handle the canonical `/agent/*` (every project) AND\n // `/cdn-cgi/agent/*` (defensive — Cloudflare's `@cloudflare/vite-plugin`\n // routes everything except `/cdn-cgi/*` to the worker, which means\n // canonical `/agent/*` paths are shadowed in cloudflare-vite projects).\n // The cdn-cgi prefix is stripped before forwarding so the agent\n // server's router sees its own canonical paths regardless of which\n // public URL the client used. This matches the dual-path strategy\n // used for `/__llui_mcp_status`.\n server.middlewares.use((req, res, next) => {\n const url = req.url ?? '/'\n let stripped: string | null = null\n if (url.startsWith('/agent/') || url === '/agent') stripped = url\n else if (url.startsWith('/cdn-cgi/agent/') || url === '/cdn-cgi/agent') {\n stripped = url.slice('/cdn-cgi'.length)\n }\n if (stripped === null) {\n next()\n return\n }\n // Rewrite the request URL in-place so handleAgentRequest's path\n // matching sees `/agent/*`. Connect middleware can mutate req.url\n // for downstream handlers; we own the request from here.\n req.url = stripped\n void handleAgentRequest(req, res, agent.router).catch((e) => {\n console.error('[llui] agent middleware error:', e)\n next(e)\n })\n })\n\n // WS upgrade: only /agent/ws goes to the agent. Vite's own HMR upgrade\n // uses a different path and runs as a separate listener on the same\n // event, so this filter keeps both coexisting. Same dual-path\n // accommodation as the HTTP middleware — the WS-upgrade path doesn't\n // actually matter to most cloudflare setups (the worker handles WS\n // upgrades natively), but keeping the parity simplifies the mental\n // model for ops.\n server.httpServer?.on('upgrade', (req, socket, head) => {\n const url = new URL(req.url ?? '/', 'http://localhost')\n if (url.pathname === '/agent/ws' || url.pathname === '/cdn-cgi/agent/ws') {\n agent.wsUpgrade(req, socket, head)\n }\n })\n\n console.info(\n '[llui] agent dev endpoints active: POST /agent/mint, WS /agent/ws, LAP /agent/lap/v1/* (also reachable under /cdn-cgi/agent/* for cloudflare-vite parity)',\n )\n}\n\n/**\n * Walk up from `start` looking for `node_modules/<pkgName>`. Returns the\n * absolute path to the package directory, or null if not found.\n */\nfunction findPackageDir(start: string, pkgName: string): string | null {\n let dir = resolve(start)\n while (true) {\n const candidate = resolve(dir, 'node_modules', pkgName)\n if (existsSync(resolve(candidate, 'package.json'))) return candidate\n const parent = dirname(dir)\n if (parent === dir) return null\n dir = parent\n }\n}\n\n/** Convert a Node http req → Web Request, call router, write the response. */\nasync function handleAgentRequest(\n req: import('http').IncomingMessage,\n res: import('http').ServerResponse,\n router: (req: Request) => Promise<Response | null>,\n): Promise<void> {\n const method = req.method ?? 'GET'\n const url = req.url ?? '/'\n const headers: Record<string, string> = {}\n for (const [k, v] of Object.entries(req.headers)) {\n if (v === undefined) continue\n headers[k] = Array.isArray(v) ? v.join(', ') : v\n }\n let body: BodyInit | undefined\n if (!['GET', 'HEAD'].includes(method)) {\n const chunks: Buffer[] = []\n for await (const chunk of req) chunks.push(chunk as Buffer)\n if (chunks.length > 0) body = new Uint8Array(Buffer.concat(chunks))\n }\n const origin = `http://${req.headers.host ?? 'localhost'}`\n const webReq = new Request(`${origin}${url}`, { method, headers, body })\n const webRes = await router(webReq)\n if (!webRes) {\n res.statusCode = 404\n res.end()\n return\n }\n res.statusCode = webRes.status\n webRes.headers.forEach((v, k) => res.setHeader(k, v))\n const buf = Buffer.from(await webRes.arrayBuffer())\n res.end(buf)\n}\n\n/**\n * Build the cross-file `ts.Program` for v2c pipeline integration. Scans\n * the project root's `tsconfig.json` (or a sensible default) to collect\n * rootNames. Returns null if no tsconfig is reachable — caller falls\n * back to per-file path collection silently.\n *\n * Prototype: builds once, never refreshes. v2c's incremental program is\n * the natural upgrade.\n */\nasync function buildCrossFileProgram(root: string): Promise<import('typescript').Program | null> {\n try {\n const ts = (await import('typescript')).default\n const tsconfigPath = ts.findConfigFile(root, ts.sys.fileExists, 'tsconfig.json')\n if (!tsconfigPath) return null\n const parsed = ts.getParsedCommandLineOfConfigFile(tsconfigPath, undefined, {\n ...ts.sys,\n onUnRecoverableConfigFileDiagnostic: () => {},\n })\n if (!parsed) return null\n const program = ts.createProgram({\n rootNames: parsed.fileNames,\n options: { ...parsed.options, noEmit: true, skipLibCheck: true },\n })\n return program\n } catch {\n return null\n }\n}\n\nexport default function llui(options: LluiPluginOptions = {}): Plugin {\n let devMode = false\n // `mcpPort` + `mcpMode` are resolved lazily in `configResolved` so we\n // can check for @llui/mcp in the consuming project's node_modules.\n // - `options.mcpPort === false` → disabled\n // - explicit number → wire-only (user manages the server)\n // - undefined + @llui/mcp found → spawn (plugin starts llui-mcp --http)\n // - undefined + no @llui/mcp → disabled\n let mcpPort: number | null = null\n let mcpMode: 'disabled' | 'wire' | 'spawn' = 'disabled'\n let mcpCliPath: string | null = null\n let mcpChild: ChildProcess | null = null\n const verbose = options.verbose === true\n const agent = options.agent ?? false\n const crossFileMode: false | true | 'silent' = options.crossFile ?? false\n // The Program is built lazily on first transform when crossFile is\n // enabled; cached afterwards for reuse. ts.Program is immutable —\n // file changes are not reflected without a rebuild (documented above).\n let crossFileProgram: import('typescript').Program | null = null\n let crossFileProgramInit = false\n let crossFileRoot = process.cwd()\n const agentConfig: AgentPluginConfig = typeof agent === 'object' ? agent : {}\n // Agent server instance — loaded in configResolved (async), registered\n // in configureServer (sync). Null until loaded, or if @llui/agent isn't\n // installed.\n let agentServer: {\n router: (req: Request) => Promise<Response | null>\n wsUpgrade: (\n req: import('http').IncomingMessage,\n socket: import('stream').Duplex,\n head: Buffer,\n ) => void\n } | null = null\n\n // File-based handshake with @llui/mcp. The MCP server writes a marker\n // file when its bridge starts; we watch it and send a Vite HMR custom\n // event so the browser can call __lluiConnect() automatically — without\n // retry spam, regardless of whether MCP or Vite started first.\n const activeFilePath = resolve(findWorkspaceRoot(), 'node_modules/.cache/llui-mcp/active.json')\n let mcpWatcher: FSWatcher | null = null\n let dirWatcher: FSWatcher | null = null\n // Cached once Vite's HTTP server emits `listening`. `stampDevUrl()`\n // uses this to write the URL into the marker file — either immediately\n // (if MCP already started and wrote one) or later when the marker\n // appears via the directory watcher (MCP-starts-after-Vite path).\n let cachedDevUrl: string | null = null\n\n function readMcpMarker(): { port: number; devUrl?: string } | null {\n try {\n if (!existsSync(activeFilePath)) return null\n const data = JSON.parse(readFileSync(activeFilePath, 'utf8')) as {\n port?: number\n devUrl?: string\n }\n if (typeof data.port !== 'number') return null\n return { port: data.port, ...(data.devUrl ? { devUrl: data.devUrl } : {}) }\n } catch {\n return null\n }\n }\n\n /**\n * Idempotently write `cachedDevUrl` into the marker file. No-op if the\n * URL hasn't been captured yet (Vite hasn't emitted `listening`) or if\n * the marker file doesn't exist (MCP hasn't started yet). Covers both\n * orderings — the listening hook calls this after caching, and the\n * directory watcher calls it when the marker appears later.\n */\n function stampDevUrl(): void {\n if (cachedDevUrl === null) return\n if (!existsSync(activeFilePath)) return\n try {\n const marker = JSON.parse(readFileSync(activeFilePath, 'utf8')) as Record<string, unknown>\n if (marker.devUrl === cachedDevUrl) return\n marker.devUrl = cachedDevUrl\n writeFileSync(activeFilePath, JSON.stringify(marker))\n } catch {\n // Best-effort — failure to update the marker should not crash Vite\n }\n }\n\n function notifyMcpReady(server: ViteDevServer): void {\n const marker = readMcpMarker()\n if (marker === null) return\n server.ws.send({ type: 'custom', event: 'llui:mcp-ready', data: marker })\n }\n\n function notifyMcpOffline(server: ViteDevServer): void {\n server.ws.send({ type: 'custom', event: 'llui:mcp-offline', data: {} })\n }\n\n return {\n name: 'llui',\n enforce: 'pre',\n\n async configResolved(config) {\n devMode = config.command === 'serve' || config.mode === 'development'\n crossFileRoot = config.root\n // Load @llui/agent here (async) so we can register middleware\n // synchronously in configureServer — which must happen BEFORE Vite\n // installs its catch-all SPA/fallback middleware.\n if (agent && devMode) {\n agentServer = await loadAgentServer(config.root, agentConfig)\n }\n if (options.mcpPort === false) {\n mcpMode = 'disabled'\n mcpPort = null\n } else if (typeof options.mcpPort === 'number') {\n mcpMode = 'wire'\n mcpPort = options.mcpPort\n } else if (hasMcpPackage(config.root)) {\n mcpCliPath = resolveMcpCliPath(config.root)\n if (mcpCliPath) {\n mcpMode = 'spawn'\n mcpPort = 5200\n } else {\n mcpMode = 'wire'\n mcpPort = 5200\n }\n } else {\n mcpMode = 'disabled'\n mcpPort = null\n }\n },\n\n configureServer(server) {\n // Agent dev endpoints — runs regardless of mcp state. Must be before\n // any early-returns below. Registration is synchronous because\n // agentServer was preloaded in configResolved.\n if (agentServer) {\n registerAgentMiddleware(server, agentServer)\n }\n\n if (mcpPort === null) {\n // #3 diagnostic: MCP server is running but the plugin is opted\n // out. Users in this state usually don't realize the mismatch —\n // loud-and-early log saves the \"why isn't my MCP attached\" hunt.\n if (existsSync(activeFilePath)) {\n console.warn(\n `[llui] @llui/mcp server is running (marker at ${activeFilePath}) ` +\n `but the Vite plugin is opted out (mcpPort: false, or @llui/mcp ` +\n `isn't a dep of this project). Add \\`llui({ mcpPort: 5200 })\\` ` +\n `to vite.config to wire them up, or remove the marker file and ` +\n `stop the MCP server if the mismatch was unintended.`,\n )\n }\n return\n }\n\n // Spawn mode: plugin launches llui-mcp as a child process so\n // `pnpm dev` handles the whole stack. Skip spawning when a marker\n // already exists — something (usually a separate llui-mcp process\n // started before Vite) is already listening. The existing wire\n // behavior takes over from there.\n if (mcpMode === 'spawn' && mcpCliPath !== null && !existsSync(activeFilePath)) {\n mcpChild = spawn(process.execPath, [mcpCliPath, '--http', String(mcpPort)], {\n stdio: ['ignore', 'pipe', 'pipe'],\n env: { ...process.env, LLUI_MCP_PORT: String(mcpPort) },\n })\n mcpChild.stdout?.on('data', (buf: Buffer) => {\n process.stdout.write(`[mcp] ${buf.toString()}`)\n })\n mcpChild.stderr?.on('data', (buf: Buffer) => {\n process.stderr.write(`[mcp] ${buf.toString()}`)\n })\n mcpChild.on('exit', (code) => {\n if (code !== 0 && code !== null) {\n console.warn(`[llui] @llui/mcp child exited with code ${code}`)\n }\n mcpChild = null\n })\n const killChild = (): void => {\n if (mcpChild && !mcpChild.killed) mcpChild.kill('SIGTERM')\n }\n server.httpServer?.on('close', killChild)\n process.once('exit', killChild)\n }\n\n // HTTP endpoint: the browser fetches this on load to discover the\n // current MCP port. Avoids the race where HMR events sent before\n // the import.meta.hot listener registers get dropped — and lets\n // the browser connect to the actual port (which may differ from\n // the compile-time default if MCP was started with LLUI_MCP_PORT).\n //\n // Two paths register the same handler:\n // * `/__llui_mcp_status` — canonical, served from any Vite\n // project.\n // * `/cdn-cgi/llui_mcp_status` — fallback for projects that\n // bundle `@cloudflare/vite-plugin`. The cloudflare plugin\n // intercepts every HTTP request in `configureServer` and\n // routes it to the worker, except `/cdn-cgi/*` which it\n // explicitly lets through. Without this fallback, MCP\n // auto-discovery silently fails under workerd.\n const mcpStatusHandler = (_req: unknown, res: ServerResponseLike): void => {\n const marker = readMcpMarker()\n if (marker === null) {\n res.statusCode = 404\n res.end()\n return\n }\n res.statusCode = 200\n res.setHeader('content-type', 'application/json')\n res.end(JSON.stringify({ port: marker.port }))\n }\n server.middlewares.use('/__llui_mcp_status', mcpStatusHandler)\n server.middlewares.use('/cdn-cgi/llui_mcp_status', mcpStatusHandler)\n\n // Watch the marker file for create/delete. fs.watch on the parent\n // directory catches both events; the file itself may not exist\n // when we start watching.\n const dir = dirname(activeFilePath)\n try {\n // Watch the parent directory for the marker file appearing/disappearing\n const watchDir = (): void => {\n if (!existsSync(dir)) return\n dirWatcher = fsWatch(dir, (_event, filename) => {\n if (filename !== 'active.json') return\n if (existsSync(activeFilePath)) {\n // Stamp BEFORE notifying so the `llui:mcp-ready` payload\n // carries the cached devUrl. This is the MCP-after-Vite\n // path: listening already fired and cached the URL; the\n // marker is only now appearing.\n stampDevUrl()\n notifyMcpReady(server)\n } else {\n notifyMcpOffline(server)\n }\n })\n }\n if (existsSync(dir)) {\n watchDir()\n } else {\n // Parent directory doesn't exist yet — poll for it briefly\n const poll = setInterval(() => {\n if (existsSync(dir)) {\n clearInterval(poll)\n watchDir()\n }\n }, 1000)\n // Clean up the poller if vite shuts down before MCP starts\n server.httpServer?.on('close', () => clearInterval(poll))\n }\n } catch {\n // fs.watch can fail on some filesystems — degrade silently\n }\n\n // Re-send the ready event when a new HMR client connects, in case\n // the page loads while MCP is already running.\n server.ws.on('connection', () => {\n if (existsSync(activeFilePath)) notifyMcpReady(server)\n })\n\n server.httpServer?.on('close', () => {\n mcpWatcher?.close()\n dirWatcher?.close()\n mcpWatcher = null\n dirWatcher = null\n })\n\n // Once Vite's HTTP server is listening, cache our dev URL and stamp\n // it into the marker file. Two orderings are possible:\n // (a) MCP started FIRST → marker exists now → stampDevUrl() writes\n // it, and we broadcast llui:mcp-ready so the browser picks up\n // the devUrl without relying on an incidental fs.watch tick\n // (which can miss on NFS/SMB).\n // (b) MCP will start LATER → marker doesn't exist yet → stamp is a\n // no-op. When MCP eventually writes the marker, the directory\n // watcher fires, calls stampDevUrl(), and notifies.\n server.httpServer?.once('listening', () => {\n const address = server.httpServer?.address()\n if (!address || typeof address !== 'object') return\n const host =\n address.address === '::' || address.address === '0.0.0.0' ? 'localhost' : address.address\n cachedDevUrl = `http://${host}:${address.port}`\n stampDevUrl()\n // Broadcast after stamping so the payload carries devUrl. Only\n // fires in case (a) — notifyMcpReady no-ops when the marker is\n // absent.\n notifyMcpReady(server)\n })\n\n // ── Agent dev endpoints ──────────────────────────────────────\n // When `agent: true` (or `agent: {...}`), auto-mount /agent/* on\n // the Vite dev server so `pnpm dev` has working agent endpoints.\n // Users with a custom server.ts (SSR apps) mount createLluiAgentServer\n // themselves — configureServer also fires in middleware mode, but\n // there server.httpServer is null so the upgrade hook is a no-op.\n },\n\n async transform(code, id, options) {\n if (!id.endsWith('.ts') && !id.endsWith('.tsx')) return\n\n // `'use client'` directive — SSR builds replace the module with a\n // stub so top-level imports and side effects never run on the\n // server. Client builds pass through to the normal transform; the\n // directive is effectively a no-op on the client.\n if (options?.ssr && hasUseClientDirective(code)) {\n const result = transformUseClientSsr(code, id)\n if (result) {\n const cwd = process.cwd()\n const rel = relative(cwd, id)\n const display = rel.startsWith('..') ? id : rel\n for (const warning of result.warnings) {\n this.warn(`${display}: ${warning}`)\n }\n return { code: result.output, map: { mappings: '' } }\n }\n }\n\n // Pre-resolve cross-file type sources for any `component<S, M, E>()`\n // call in this file. The extractors look for `type Msg = ...` etc.\n // in a single source string; if the user keeps `Msg` in a sibling\n // file, the local extraction returns null and the plugin emits no\n // annotations. Pre-resolution chases imports and re-exports to\n // find the declaring file, so the schema/annotation extractors run\n // against the right source. See cross-file-resolver.ts.\n //\n // `this.resolve` may be undefined in test harnesses that call the\n // hook directly without going through Rollup; in that case skip\n // pre-resolution and the local extractors handle whatever's in\n // the source string.\n const resolverAvailable = typeof this.resolve === 'function'\n const [typeSources, preExtracted] = resolverAvailable\n ? await Promise.all([\n preResolveTypeSources(code, id, this.resolve.bind(this)),\n // Cross-file + composition-aware extraction. Replaces the\n // file-local sync extractors when active. Without this step\n // a `type Msg = ImportedFoo | { type: 'extra' }`\n // composition would only see the inline `'extra'` variant\n // and silently emit half-annotations.\n preExtractCompositional(code, id, this.resolve.bind(this)),\n ])\n : [undefined, undefined]\n\n // Cross-file path resolution (v2c pipeline integration). When\n // enabled, the plugin reuses a shared `ts.Program` across all\n // transform calls and asks the engine for the union of paths read\n // through in-repo view-helpers. Builds the Program on first call.\n let crossFilePaths: ReadonlySet<string> | undefined\n if (crossFileMode !== false) {\n if (!crossFileProgramInit) {\n crossFileProgramInit = true\n crossFileProgram = await buildCrossFileProgram(crossFileRoot)\n }\n if (crossFileProgram) {\n const sf = crossFileProgram.getSourceFile(id)\n if (sf) {\n try {\n crossFilePaths = crossFileAccessorPaths(crossFileProgram, sf)\n } catch (err) {\n if (crossFileMode !== 'silent') {\n this.warn(\n `[llui] cross-file walker failed on ${id}: ${(err as Error).message}. ` +\n `Falling back to per-file path collection.`,\n )\n }\n }\n }\n }\n }\n\n const result = transformLlui(\n code,\n id,\n devMode,\n Boolean(agent),\n mcpPort,\n verbose,\n typeSources,\n preExtracted,\n crossFilePaths,\n )\n if (!result) return undefined\n\n // Surface compiler diagnostics to Rollup. Severity 'error' fails\n // the transform (and the build); 'warning' / 'info' report\n // non-fatally. Locations are 1-based for Rollup.\n for (const diag of result.diagnostics) {\n const loc = {\n file: diag.location.file,\n line: diag.location.range.start.line + 1,\n column: diag.location.range.start.column,\n }\n const formatted = `[${diag.id}] ${diag.message}`\n if (diag.severity === 'error') {\n this.error({ message: formatted, loc })\n } else if (diag.severity === 'warning') {\n this.warn({ message: formatted, loc })\n } else if (verbose) {\n console.info(`[llui] ${formatted}`)\n }\n }\n\n // Apply per-statement edits via MagicString for accurate source maps.\n // Untouched statements keep their original positions.\n const s = new MagicString(code)\n for (const edit of result.edits) {\n if (edit.start === edit.end) {\n // Insert at position — appendRight for middle, append for end-of-file\n if (edit.start === code.length) s.append(edit.replacement)\n else s.appendRight(edit.start, edit.replacement)\n } else {\n s.overwrite(edit.start, edit.end, edit.replacement)\n }\n }\n\n return {\n code: s.toString(),\n map: s.generateMap({ source: id, includeContent: true, hires: true }),\n }\n },\n\n // Build-time integrity check (v2a §2.4; shared.md §20.12). Every\n // compiled component carries `__lluiCompilerEmitted: 1`; we scan the\n // final bundle for that literal text. Zero occurrences in a production\n // build means the project routed its TS through some other pipeline\n // and the runtime would silently degrade to FULL_MASK — fail closed.\n //\n // Dev mode skips the check: dev users have HMR + warnings to find\n // misconfiguration interactively. SSR builds also skip — the SSR\n // pass may emit a stub module bundle that legitimately contains no\n // components.\n generateBundle(opts, bundle) {\n if (devMode) return\n if (opts.dir === undefined && opts.file === undefined) return\n // The `ssr` flag on the output options is the cleanest signal for\n // SSR builds; rollup adds it when Vite's build.ssr is set.\n if ((opts as { ssr?: boolean }).ssr) return\n let markerCount = 0\n for (const chunk of Object.values(bundle)) {\n if (chunk.type !== 'chunk') continue\n // Count literal occurrences of the marker. `__lluiCompilerEmitted`\n // is unique enough that false positives from user source are\n // implausible.\n let from = 0\n const code = chunk.code\n while (true) {\n const i = code.indexOf('__lluiCompilerEmitted', from)\n if (i < 0) break\n markerCount++\n from = i + '__lluiCompilerEmitted'.length\n }\n }\n if (markerCount === 0) {\n this.error(\n '[llui] integrity check failed: no compiled `component()` calls found in ' +\n 'this bundle. Either the project has no LLui components (remove ' +\n '`@llui/vite-plugin` from vite.config.ts), or the plugin order is wrong ' +\n 'and another transform is consuming TS before `@llui/vite-plugin` runs ' +\n \"(check `enforce: 'pre'`). The check looks for the `__lluiCompilerEmitted` \" +\n 'property the compiler injects into every component. See ' +\n 'docs/proposals/v2-compiler/v2a.md §2.4.',\n )\n }\n },\n }\n}\n"]}
|
package/dist/transform.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import { extractMsgSchema, extractEffectSchema } from '
|
|
3
|
-
import { extractMsgAnnotations } from './msg-annotations.js';
|
|
4
|
-
import { extractStateSchema } from './state-schema.js';
|
|
2
|
+
import { extractMsgSchema, extractEffectSchema, extractMsgAnnotations, extractStateSchema } from '@llui/compiler';
|
|
5
3
|
/**
|
|
6
4
|
* Transform a source file containing @llui/dom imports.
|
|
7
5
|
* Returns the transformed source or null if no transformation needed.
|
package/dist/transform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAC3B,OAAO,EAKL,gBAAgB,EAChB,mBAAmB,EAInB,qBAAqB,EAErB,kBAAkB,EAMnB,MAAM,gBAAgB,CAAA;AA8NvB;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5C,GAAG,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CA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C,cAAc,GAAG,MAAM,GAAG,IAAI,CAcrF;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CASzF;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC,GAChE,MAAM,CAYR"}
|
package/dist/transform.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import { collectDeps } from '
|
|
3
|
-
import { resolveLocalConstInitializer, resolveAccessorBody, isMemoCallWithArrowArg, } from './accessor-resolver.js';
|
|
4
|
-
import { extractMsgSchema, extractEffectSchema, isRichField, } from './msg-schema.js';
|
|
5
|
-
import { extractMsgAnnotations } from './msg-annotations.js';
|
|
6
|
-
import { extractStateSchema } from './state-schema.js';
|
|
7
|
-
import { computeSchemaHash } from './schema-hash.js';
|
|
8
|
-
import { tagDispatchHandlers, injectScopeVariantRegistrations } from './binding-descriptors.js';
|
|
9
|
-
import { compilerCache } from './compiler-cache.js';
|
|
2
|
+
import { collectDeps, resolveLocalConstInitializer, resolveAccessorBody, isMemoCallWithArrowArg, extractMsgSchema, extractEffectSchema, isRichField, extractMsgAnnotations, extractStateSchema, computeSchemaHash, tagDispatchHandlers, injectScopeVariantRegistrations, compilerCache, } from '@llui/compiler';
|
|
10
3
|
function createMaskLiteral(f, mask) {
|
|
11
4
|
if (mask >= 0)
|
|
12
5
|
return f.createNumericLiteral(mask);
|