@sixb/app 0.0.1

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.
@@ -0,0 +1,18 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/createCustomApp.ts", "../src/build.ts", "../src/codegen.ts", "../src/manifest.ts", "../src/metadata.ts", "../src/runtime.ts", "../src/scanner.ts", "../src/styles.ts", "../src/tailwind.ts"],
4
+ "sourcesContent": [
5
+ "import { watch } from \"node:fs\"\nimport { access, cp, mkdir, readFile, writeFile } from \"node:fs/promises\"\nimport { dirname, isAbsolute, join, normalize, relative, resolve } from \"node:path\"\nimport { pathToFileURL } from \"node:url\"\nimport type { AuthSessionAudience } from \"@sixb/core\"\nimport {\n type BuildAppResult,\n buildApp,\n prepareAppHtmlBundleEntry,\n restoreAppStaticUrls,\n} from \"./build\"\nimport { type BuiltInRouteManifestEntry, generateAppEntry, generateRouteManifest } from \"./codegen\"\nimport { renderCustomAppRuntimeScript } from \"./runtime\"\nimport { type PageRoute, scanPages } from \"./scanner\"\nimport { type CustomAppStylesheet, resolveCustomAppStylesheet } from \"./styles\"\nimport { createTailwindCssCompiler, type TailwindCssCompiler } from \"./tailwind\"\n\nexport interface CreateCustomAppOptions {\n rootDir: string\n appDir?: string\n generatedDir?: string\n publicDir?: string\n apiBaseUrl?: string\n audience?: AuthSessionAudience\n authEnabled?: boolean\n agentRoutes?: boolean\n}\n\nexport interface CustomAppDevOptions {\n host?: string\n port?: number\n}\n\nexport interface CustomAppBuildOptions {\n outdir?: string\n}\n\nexport interface CustomAppStartOptions {\n host?: string\n port?: number\n outdir?: string\n apiBaseUrl?: string\n audience?: AuthSessionAudience\n authEnabled?: boolean\n}\n\nexport interface CustomAppDevServer {\n host: string\n port: number\n url: string\n stop(): Promise<void>\n}\n\nexport interface CustomAppInstance {\n scanRoutes(): Promise<PageRoute[]>\n hasRoutes(): Promise<boolean>\n dev(options?: CustomAppDevOptions): Promise<CustomAppDevServer>\n build(options?: CustomAppBuildOptions): Promise<BuildAppResult>\n start(options?: CustomAppStartOptions): Promise<CustomAppDevServer>\n}\n\ntype BunServeRoutes = NonNullable<Parameters<typeof Bun.serve>[0][\"routes\"]>\ntype BunServeRoute = BunServeRoutes[string]\nconst packageRoot = resolve(import.meta.dir, \"..\")\nconst builtInAgentRouteModule = \"@sixb/app/agents\"\nconst builtInAgentRoutePaths = [\"/agents\", \"/agents/new/:agentId\", \"/agents/:threadId\"] as const\nconst builtInAgentRouteSourcePath = join(packageRoot, \"src\", \"agents.ts\")\nconst customAppManifestRoute = \"/app.webmanifest\"\nconst internalAppShellRoute = \"/__sixb/generated/app-shell\"\n\nexport async function createCustomApp(options: CreateCustomAppOptions): Promise<CustomAppInstance> {\n const rootDir = resolve(options.rootDir)\n const appDir = options.appDir ? resolve(rootDir, options.appDir) : resolve(rootDir, \"app\")\n const generatedDir = resolve(rootDir, options.generatedDir ?? join(\".sixb\", \"generated\"))\n const publicDir = options.publicDir\n ? resolve(rootDir, options.publicDir)\n : resolve(appDir, \"public\")\n const apiBaseUrl = options.apiBaseUrl\n const audience = options.audience ?? \"app\"\n const authEnabled = options.authEnabled ?? true\n const agentRoutesEnabled = options.agentRoutes ?? true\n\n async function scanRoutes(): Promise<PageRoute[]> {\n if (!(await pathExists(appDir))) {\n return []\n }\n\n return await scanPages(appDir)\n }\n\n let tailwindCompiler: TailwindCssCompiler | null = null\n let tailwindCompilerKey: string | null = null\n let builtInAgentCssCompiler: TailwindCssCompiler | null = null\n\n // `app/globals.css` is source. When it uses Tailwind, compile it to\n // `.sixb/generated/app.css` and bundle that; plain CSS bundles as-is. This\n // runs in both dev and build, so `sixb build` alone always produces fresh CSS.\n async function prepareStylesheet(stylesheet?: CustomAppStylesheet): Promise<CustomAppStylesheet> {\n stylesheet ??= await resolveCustomAppStylesheet({ appDir, generatedDir, rootDir })\n if (stylesheet.kind !== \"tailwind\") {\n return stylesheet\n }\n\n await compileAppTailwindStylesheet(stylesheet.sourcePath, stylesheet.outputPath)\n return stylesheet\n }\n\n async function compileAppTailwindStylesheet(\n inputPath: string,\n outputPath: string\n ): Promise<void> {\n const key = `${inputPath}\\0${outputPath}`\n if (tailwindCompilerKey !== key) {\n await tailwindCompiler?.stop()\n tailwindCompiler = createTailwindCssCompiler({\n inputPath,\n outputPath,\n // Scope Tailwind's automatic source detection to app/ so it never walks\n // vendor/ or unrelated trees; resolve the CLI from the project's deps.\n cwd: appDir,\n resolveFrom: rootDir,\n label: \"[SixbCustomApp]\",\n })\n tailwindCompilerKey = key\n }\n\n const compiler = tailwindCompiler\n if (!compiler) {\n throw new Error(\"[SixbCustomApp] Tailwind CSS compiler was not initialized\")\n }\n\n await compiler.compile()\n }\n\n async function prepareCombinedBuiltInAgentStylesheet(\n stylesheet: Extract<CustomAppStylesheet, { kind: \"tailwind\" }>\n ): Promise<string> {\n const inputPath = join(generatedDir, \"app.input.css\")\n const uiGlobalsPath = Bun.resolveSync(\"@sixb/ui/globals.css\", packageRoot)\n const agentUiGlobalsPath = Bun.resolveSync(\"@sixb/agent-ui/globals.css\", packageRoot)\n await writeFileIfChanged(\n inputPath,\n [\n `@import ${JSON.stringify(uiGlobalsPath)};`,\n `@source ${JSON.stringify(builtInAgentRouteSourcePath)};`,\n `@import ${JSON.stringify(stylesheet.sourcePath)};`,\n `@import ${JSON.stringify(agentUiGlobalsPath)};`,\n \"\",\n ].join(\"\\n\")\n )\n\n await compileAppTailwindStylesheet(inputPath, stylesheet.outputPath)\n return stylesheet.outputPath\n }\n\n async function prepareStylesheets(builtInRoutes: readonly BuiltInRouteManifestEntry[]): Promise<{\n stylesheetPath: string | null\n frameworkStylesheetPaths: readonly string[]\n }> {\n const stylesheet = await resolveCustomAppStylesheet({ appDir, generatedDir, rootDir })\n\n if (stylesheet.kind === \"tailwind\" && builtInRoutes.length > 0) {\n return {\n stylesheetPath: await prepareCombinedBuiltInAgentStylesheet(stylesheet),\n frameworkStylesheetPaths: [],\n }\n }\n\n const preparedStylesheet = await prepareStylesheet(stylesheet)\n const builtInAgentStylesheetPath = await prepareBuiltInAgentStylesheet(builtInRoutes)\n\n return {\n frameworkStylesheetPaths: builtInAgentStylesheetPath ? [builtInAgentStylesheetPath] : [],\n stylesheetPath:\n preparedStylesheet.kind === \"none\"\n ? null\n : preparedStylesheet.kind === \"static\"\n ? preparedStylesheet.path\n : preparedStylesheet.outputPath,\n }\n }\n\n async function prepareBuiltInAgentStylesheet(\n builtInRoutes: readonly BuiltInRouteManifestEntry[]\n ): Promise<string | null> {\n if (builtInRoutes.length === 0) {\n return null\n }\n\n const inputPath = join(generatedDir, \"agent-ui.input.css\")\n const outputPath = join(generatedDir, \"agent-ui.css\")\n const uiGlobalsPath = Bun.resolveSync(\"@sixb/ui/globals.css\", packageRoot)\n const agentUiGlobalsPath = Bun.resolveSync(\"@sixb/agent-ui/globals.css\", packageRoot)\n await writeFileIfChanged(\n inputPath,\n [\n `@import ${JSON.stringify(uiGlobalsPath)};`,\n `@source ${JSON.stringify(builtInAgentRouteSourcePath)};`,\n `@import ${JSON.stringify(agentUiGlobalsPath)};`,\n \"\",\n ].join(\"\\n\")\n )\n\n builtInAgentCssCompiler ??= createTailwindCssCompiler({\n inputPath,\n outputPath,\n cwd: packageRoot,\n resolveFrom: packageRoot,\n label: \"[SixbCustomApp]\",\n })\n await builtInAgentCssCompiler.compile()\n return outputPath\n }\n\n async function prepareGeneratedApp(): Promise<{\n htmlPath: string\n manifestPath: string\n routes: PageRoute[]\n }> {\n const routes = await scanRoutes()\n if (routes.length === 0) {\n throw new Error(`[SixbCustomApp] No app routes found in ${appDir}`)\n }\n\n const builtInRoutes = agentRoutesEnabled ? builtInAgentRoutesFor(routes) : []\n const stylesheets = await prepareStylesheets(builtInRoutes)\n await generateRouteManifest(routes, generatedDir, { builtInRoutes })\n const { htmlPath, manifestPath } = await generateAppEntry(rootDir, generatedDir, {\n apiBaseUrl,\n audience,\n authEnabled,\n appDir,\n publicDir,\n frameworkStylesheetPaths: stylesheets.frameworkStylesheetPaths,\n stylesheetPath: stylesheets.stylesheetPath,\n })\n return { htmlPath, manifestPath, routes }\n }\n\n return {\n async scanRoutes() {\n return await scanRoutes()\n },\n\n async hasRoutes() {\n const routes = await scanRoutes()\n return routes.length > 0\n },\n\n async dev(devOptions: CustomAppDevOptions = {}) {\n const host = devOptions.host ?? \"0.0.0.0\"\n const port = devOptions.port ?? 3001\n const { htmlPath, manifestPath } = await prepareGeneratedApp()\n let htmlImportVersion = 0\n let htmlBundle = await importHtmlBundle(htmlPath, htmlImportVersion)\n const publicRoutes = (await pathExists(publicDir)) ? await createPublicRoutes(publicDir) : {}\n let internalOrigin = \"\"\n const serveOptions = (bundle: Bun.HTMLBundle) =>\n ({\n port,\n hostname: host,\n development: true,\n routes: {\n ...publicRoutes,\n ...reservedSixbRoutes(),\n [customAppManifestRoute]: manifestRoute(manifestPath),\n [internalAppShellRoute]: htmlBundleRoute(bundle),\n \"/\": spaHtmlRoute(() => internalOrigin),\n \"/*\": spaHtmlRoute(() => internalOrigin),\n },\n }) as Parameters<typeof Bun.serve>[0]\n const server = Bun.serve(serveOptions(htmlBundle))\n internalOrigin = devServerInternalOrigin(host, server.port ?? port)\n\n // .ts/.tsx edits can change Tailwind's scanned classes and .css edits\n // change the stylesheet source, so both regenerate the entry and\n // recompile CSS. Debounced so a burst of saves builds once.\n let rebuildTimer: ReturnType<typeof setTimeout> | null = null\n let rebuildChain: Promise<void> = Promise.resolve()\n const enqueueRebuild = () => {\n rebuildChain = rebuildChain\n .then(async () => {\n const { htmlPath: nextHtmlPath } = await prepareGeneratedApp()\n htmlImportVersion++\n htmlBundle = await importHtmlBundle(nextHtmlPath, htmlImportVersion)\n server.reload(serveOptions(htmlBundle))\n })\n .catch((error) => {\n // Keep serving the last good build, but tell the user why styles\n // or routes are stale instead of failing silently.\n const message = error instanceof Error ? error.message : String(error)\n console.error(`[SixbCustomApp] Rebuild failed: ${message}`)\n })\n }\n const watcher = watch(appDir, { recursive: true }, (_eventType, filename) => {\n if (!filename) return\n if (!/\\.(ts|tsx|css)$/.test(String(filename))) return\n\n if (rebuildTimer) {\n clearTimeout(rebuildTimer)\n }\n rebuildTimer = setTimeout(() => {\n rebuildTimer = null\n enqueueRebuild()\n }, 80)\n })\n\n // An FSWatcher emits `error` as an event, and an unhandled one takes the whole dev process\n // down — the `.catch()` above only covers a failed rebuild. Losing file watching should cost\n // hot reload, not the server: keep serving the last good build and say so.\n watcher.on(\"error\", (error: unknown) => {\n const message = error instanceof Error ? error.message : String(error)\n console.error(\n `[SixbCustomApp] Stopped watching ${appDir}: ${message}. ` +\n \"Serving the last build; restart to resume hot reload.\"\n )\n })\n\n const displayHost = host === \"0.0.0.0\" ? \"localhost\" : host\n\n return {\n host,\n port,\n url: `http://${displayHost}:${port}`,\n async stop() {\n if (rebuildTimer) {\n clearTimeout(rebuildTimer)\n rebuildTimer = null\n }\n watcher.close()\n await rebuildChain\n await tailwindCompiler?.stop()\n await builtInAgentCssCompiler?.stop()\n server.stop(true)\n },\n }\n },\n\n async build(buildOptions: CustomAppBuildOptions = {}) {\n const outdir = resolve(rootDir, buildOptions.outdir ?? join(\".sixb\", \"dist\", \"app\"))\n const { htmlPath, manifestPath } = await prepareGeneratedApp()\n const result = await buildApp({\n entryPath: htmlPath,\n manifestPath,\n outdir,\n })\n\n if (result.success && (await pathExists(publicDir))) {\n await cp(publicDir, outdir, {\n recursive: true,\n force: true,\n filter: (source) => resolve(source) !== join(publicDir, \"app.webmanifest\"),\n })\n }\n\n return result\n },\n\n async start(startOptions: CustomAppStartOptions = {}) {\n const host = startOptions.host ?? \"0.0.0.0\"\n const port = startOptions.port ?? 3001\n const outdir = resolve(rootDir, startOptions.outdir ?? join(\".sixb\", \"dist\", \"app\"))\n const indexPath = join(outdir, \"index.html\")\n\n if (!(await pathExists(indexPath))) {\n throw new Error(`[SixbCustomApp] No built app found in ${outdir}`)\n }\n\n const indexHtml = injectRuntimeConfig(await Bun.file(indexPath).text(), {\n apiBaseUrl: startOptions.apiBaseUrl ?? apiBaseUrl,\n audience: startOptions.audience ?? audience,\n authEnabled: startOptions.authEnabled ?? authEnabled,\n })\n const server = Bun.serve({\n port,\n hostname: host,\n development: false,\n async fetch(req) {\n const url = new URL(req.url)\n if (isReservedSixbRoute(url.pathname)) {\n return notFoundResponse()\n }\n\n if (req.method !== \"GET\" && req.method !== \"HEAD\") {\n return notFoundResponse()\n }\n\n if (url.pathname === \"/\" || url.pathname === \"\") {\n return htmlResponse(req, indexHtml)\n }\n\n const resolvedPath = resolveStaticPath(outdir, url.pathname)\n if (!resolvedPath) {\n return notFoundResponse()\n }\n\n const directFile = Bun.file(resolvedPath)\n if (await directFile.exists()) {\n return fileResponse(req, directFile, staticAssetHeaders(url.pathname))\n }\n\n if (isAssetRequest(url.pathname)) {\n return notFoundResponse()\n }\n\n const htmlFile = Bun.file(`${resolvedPath}.html`)\n if (await htmlFile.exists()) {\n return fileResponse(req, htmlFile)\n }\n\n const nestedIndexFile = Bun.file(join(resolvedPath, \"index.html\"))\n if (await nestedIndexFile.exists()) {\n return fileResponse(req, nestedIndexFile)\n }\n\n return htmlResponse(req, indexHtml)\n },\n })\n\n const displayHost = host === \"0.0.0.0\" ? \"localhost\" : host\n\n return {\n host,\n port,\n url: `http://${displayHost}:${port}`,\n async stop() {\n server.stop(true)\n },\n }\n },\n }\n}\n\nasync function pathExists(path: string): Promise<boolean> {\n try {\n await access(path)\n return true\n } catch {\n return false\n }\n}\n\nfunction builtInAgentRoutesFor(routes: readonly PageRoute[]): BuiltInRouteManifestEntry[] {\n const projectRoutePaths = new Set(routes.map((route) => route.path))\n\n return builtInAgentRoutePaths\n .filter((path) => !projectRoutePaths.has(path))\n .map((path) => ({\n path,\n moduleSpecifier: builtInAgentRouteModule,\n }))\n}\n\nasync function writeFileIfChanged(path: string, content: string): Promise<void> {\n try {\n if ((await readFile(path, \"utf-8\")) === content) {\n return\n }\n } catch (error) {\n if (!isFileNotFoundError(error)) {\n throw error\n }\n }\n\n await mkdir(dirname(path), { recursive: true })\n await writeFile(path, content, \"utf-8\")\n}\n\nfunction isFileNotFoundError(error: unknown): boolean {\n return (\n error instanceof Error &&\n \"code\" in error &&\n (error as Error & { readonly code?: unknown }).code === \"ENOENT\"\n )\n}\n\nasync function createPublicRoutes(publicDir: string): Promise<BunServeRoutes> {\n const files = new Bun.Glob(\"**/*\").scan({\n cwd: publicDir,\n absolute: true,\n onlyFiles: true,\n })\n const routes: BunServeRoutes = {}\n\n for await (const filePath of files) {\n const routePath = `/${filePath\n .slice(publicDir.length + 1)\n .split(\"\\\\\")\n .join(\"/\")}`\n if (isReservedSixbRoute(routePath) || routePath === customAppManifestRoute) {\n continue\n }\n routes[routePath] = getHeadRoute((request) => filePathResponse(request, filePath))\n }\n\n return routes\n}\n\nfunction reservedSixbRoutes(): BunServeRoutes {\n const handler = () => notFoundResponse()\n return {\n \"/api\": allMethodsRoute(handler),\n \"/api/*\": allMethodsRoute(handler),\n \"/auth\": allMethodsRoute(handler),\n \"/auth/*\": allMethodsRoute(handler),\n \"/ws\": allMethodsRoute(handler),\n \"/ws/*\": allMethodsRoute(handler),\n \"/docs\": allMethodsRoute(handler),\n \"/docs/*\": allMethodsRoute(handler),\n }\n}\n\nfunction isReservedSixbRoute(pathname: string): boolean {\n return (\n pathname === \"/api\" ||\n pathname.startsWith(\"/api/\") ||\n pathname === \"/auth\" ||\n pathname.startsWith(\"/auth/\") ||\n pathname === \"/ws\" ||\n pathname.startsWith(\"/ws/\") ||\n pathname === \"/docs\" ||\n pathname.startsWith(\"/docs/\")\n )\n}\n\n// Static-asset extensions whose absence should 404 rather than fall back to the\n// SPA shell — otherwise the browser would receive HTML for a missing\n// script/style/image and fail with a confusing content-type error.\nconst ASSET_EXTENSIONS = new Set([\n \"js\",\n \"mjs\",\n \"cjs\",\n \"css\",\n \"map\",\n \"json\",\n \"wasm\",\n \"ico\",\n \"png\",\n \"jpg\",\n \"jpeg\",\n \"gif\",\n \"svg\",\n \"webp\",\n \"avif\",\n \"bmp\",\n \"woff\",\n \"woff2\",\n \"ttf\",\n \"otf\",\n \"eot\",\n \"mp4\",\n \"webm\",\n \"ogg\",\n \"mp3\",\n \"wav\",\n \"txt\",\n \"xml\",\n \"webmanifest\",\n \"pdf\",\n])\n\nfunction isAssetRequest(pathname: string): boolean {\n // Decode first: client routes can carry percent-encoded slashes (`%2F`) inside a\n // single path segment (e.g. an object id), so the raw pathname's \"last segment\"\n // is unreliable. Falling back to the SPA shell for these is the whole point.\n let decoded = pathname\n try {\n decoded = decodeURIComponent(pathname)\n } catch {\n // Keep the raw pathname when it isn't valid percent-encoding.\n }\n const lastSegment = decoded.split(/[\\\\/]+/).pop() ?? \"\"\n const dot = lastSegment.lastIndexOf(\".\")\n // No extension, a leading-dot file, or a trailing dot → not an asset request.\n if (dot <= 0 || dot === lastSegment.length - 1) return false\n return ASSET_EXTENSIONS.has(lastSegment.slice(dot + 1).toLowerCase())\n}\n\nfunction resolveStaticPath(appRoot: string, pathname: string): string | null {\n let decodedPath: string\n try {\n decodedPath = decodeURIComponent(pathname)\n } catch {\n return null\n }\n\n if (decodedPath.includes(\"\\0\")) return null\n const segments = decodedPath.split(/[\\\\/]+/)\n if (segments.includes(\"..\")) return null\n\n const normalizedPath = normalize(decodedPath).replace(/^[\\\\/]+/, \"\")\n const resolvedPath = resolve(appRoot, normalizedPath)\n const rel = relative(appRoot, resolvedPath)\n\n if (rel.startsWith(\"..\") || isAbsolute(rel)) return null\n return resolvedPath\n}\n\nfunction injectRuntimeConfig(\n html: string,\n config: {\n readonly apiBaseUrl?: string\n readonly audience: AuthSessionAudience\n readonly authEnabled: boolean\n }\n): string {\n if (!config.apiBaseUrl) {\n return html\n }\n\n const script = renderCustomAppRuntimeScript({\n api: { baseUrl: config.apiBaseUrl },\n auth: { audience: config.audience, enabled: config.authEnabled },\n })\n const existingRuntimeScript = /<script>window\\.__SIXB_RUNTIME__ = .*?;<\\/script>/\n if (existingRuntimeScript.test(html)) {\n return html.replace(existingRuntimeScript, script)\n }\n\n if (html.includes(\"</head>\")) {\n return html.replace(\"</head>\", ` ${script}\\n </head>`)\n }\n\n return `${script}\\n${html}`\n}\n\nfunction htmlResponse(request: Request, html: string): Response {\n return new Response(request.method === \"HEAD\" ? null : html, {\n headers: {\n \"content-type\": \"text/html; charset=utf-8\",\n \"cache-control\": \"no-store\",\n },\n })\n}\n\n// Bun.build emits content-hashed bundles named `chunk-<hash>.<ext>` (see buildApp).\n// Their contents can never change under the same URL, so they are safe to cache\n// forever — matching how Atlas serves its hashed assets. Files copied\n// from `public/` keep their names across deploys and stay uncached.\nconst IMMUTABLE_ASSET_PATTERN = /^chunk-[a-z0-9]+\\.(js|css|js\\.map|css\\.map)$/\n\nfunction staticAssetHeaders(pathname: string): Record<string, string> {\n if (pathname === customAppManifestRoute) {\n return {\n \"content-type\": \"application/manifest+json; charset=utf-8\",\n \"cache-control\": \"no-cache\",\n }\n }\n\n const lastSegment = pathname.split(\"/\").pop() ?? \"\"\n if (!IMMUTABLE_ASSET_PATTERN.test(lastSegment)) {\n return {}\n }\n\n return { \"cache-control\": \"public, max-age=31536000, immutable\" }\n}\n\nfunction fileResponse(\n request: Request,\n file: Bun.BunFile,\n headers: Record<string, string> = {}\n): Response {\n return new Response(request.method === \"HEAD\" ? null : file, { headers })\n}\n\nfunction filePathResponse(request: Request, path: string): Response {\n return fileResponse(request, Bun.file(path))\n}\n\nfunction notFoundResponse(): Response {\n return new Response(\"Not Found\", {\n status: 404,\n headers: {\n \"cache-control\": \"no-store\",\n },\n })\n}\n\nfunction getHeadRoute(handler: (request: Request) => Response | Promise<Response>): BunServeRoute {\n return {\n GET: handler,\n HEAD: handler,\n } as unknown as BunServeRoute\n}\n\nfunction allMethodsRoute(handler: (request: Request) => Response): BunServeRoute {\n return {\n GET: handler,\n HEAD: handler,\n POST: handler,\n PUT: handler,\n PATCH: handler,\n DELETE: handler,\n OPTIONS: handler,\n } as unknown as BunServeRoute\n}\n\nasync function importHtmlBundle(htmlPath: string, version: number): Promise<Bun.HTMLBundle> {\n const bundleEntryPath = await prepareAppHtmlBundleEntry(htmlPath)\n const url = pathToFileURL(bundleEntryPath)\n url.searchParams.set(\"v\", String(version))\n const htmlModule = (await import(url.href)) as { default: Bun.HTMLBundle }\n return htmlModule.default\n}\n\nfunction htmlBundleRoute(bundle: Bun.HTMLBundle): BunServeRoute {\n return {\n GET: bundle,\n HEAD: bundle,\n } as unknown as BunServeRoute\n}\n\nfunction manifestRoute(manifestPath: string): BunServeRoute {\n return getHeadRoute((request) =>\n fileResponse(request, Bun.file(manifestPath), staticAssetHeaders(customAppManifestRoute))\n )\n}\n\nfunction devServerInternalOrigin(host: string, port: number): string {\n if (host === \"0.0.0.0\") {\n return `http://127.0.0.1:${port}`\n }\n if (host === \"::\" || host === \"[::]\") {\n return `http://[::1]:${port}`\n }\n\n const urlHost = host.includes(\":\") && !host.startsWith(\"[\") ? `[${host}]` : host\n return `http://${urlHost}:${port}`\n}\n\nfunction spaHtmlRoute(internalOrigin: () => string): BunServeRoute {\n return getHeadRoute(async (request) => {\n const publicUrl = new URL(request.url)\n if (publicUrl.pathname !== \"/\" && isAssetRequest(publicUrl.pathname)) {\n return notFoundResponse()\n }\n\n const url = new URL(internalAppShellRoute, internalOrigin())\n url.search = publicUrl.search\n const requestHeaders = new Headers(request.headers)\n for (const header of [\n \"forwarded\",\n \"host\",\n \"x-forwarded-host\",\n \"x-forwarded-port\",\n \"x-forwarded-proto\",\n ]) {\n requestHeaders.delete(header)\n }\n const bundleResponse = await fetch(\n new Request(url, { method: request.method, headers: requestHeaders })\n )\n const responseHeaders = new Headers(bundleResponse.headers)\n responseHeaders.delete(\"content-length\")\n responseHeaders.delete(\"etag\")\n if (request.method === \"HEAD\") {\n return new Response(null, {\n status: bundleResponse.status,\n statusText: bundleResponse.statusText,\n headers: responseHeaders,\n })\n }\n\n return new Response(restoreAppStaticUrls(await bundleResponse.text()), {\n status: bundleResponse.status,\n statusText: bundleResponse.statusText,\n headers: responseHeaders,\n })\n })\n}\n",
6
+ "import { copyFile, mkdir, readFile, rename, rm, writeFile } from \"node:fs/promises\"\nimport { basename, dirname, join } from \"node:path\"\n\nconst STATIC_ASSET_ORIGIN = \"https://sixb-static.invalid\"\n\nexport interface BuildAppOptions {\n /** Path to the generated index.html entry point */\n entryPath: string\n /** Generated manifest copied to the stable `/app.webmanifest` output path. */\n manifestPath?: string\n /** Output directory, defaults to `.sixb/dist/app` */\n outdir?: string\n}\n\nexport interface BuildAppResult {\n success: boolean\n outdir: string\n logs?: string[]\n}\n\n/**\n * Builds the app using `Bun.build()` on the generated HTML entry point.\n * Outputs a production-ready static bundle.\n */\nexport async function buildApp(options: BuildAppOptions): Promise<BuildAppResult> {\n const outdir = options.outdir ?? join(process.cwd(), \".sixb\", \"dist\", \"app\")\n // The outdir is build-owned. Clear it so hashed chunks from previous builds\n // don't accumulate (and get served) forever.\n await rm(outdir, { recursive: true, force: true })\n await mkdir(outdir, { recursive: true })\n\n const bundleEntryPath = await prepareAppHtmlBundleEntry(options.entryPath)\n let result: Awaited<ReturnType<typeof Bun.build>>\n try {\n result = await Bun.build({\n entrypoints: [bundleEntryPath],\n outdir,\n target: \"browser\",\n conditions: [\"bun\"],\n publicPath: \"/\",\n minify: true,\n // React is bundled into this browser output, so without pinning NODE_ENV the production build\n // of a user's app ships React's development build: dev-only checks on every render, and the\n // warnings that go with them. This is also the only knob that selects the production JSX\n // runtime — an ambient NODE_ENV does not.\n define: { \"process.env.NODE_ENV\": '\"production\"' },\n sourcemap: \"external\",\n })\n } finally {\n await rm(bundleEntryPath, { force: true })\n }\n\n if (!result.success) {\n return {\n success: false,\n outdir,\n logs: result.logs.map(String),\n }\n }\n\n const bundleHtmlPath = join(outdir, basename(bundleEntryPath))\n await rename(bundleHtmlPath, join(outdir, \"index.html\"))\n await rewriteIndexAssetPaths(outdir)\n if (options.manifestPath) {\n await copyFile(options.manifestPath, join(outdir, \"app.webmanifest\"))\n }\n\n return { success: true, outdir }\n}\n\n// Bun's HTML bundler currently tries to resolve root-relative link assets from\n// the filesystem root. A temporary external origin keeps these stable URLs out\n// of the asset graph; dev responses and production output restore the originals.\nexport async function prepareAppHtmlBundleEntry(entryPath: string): Promise<string> {\n const html = await readFile(entryPath, \"utf-8\")\n const bundleHtml = html.replace(\n /(<link\\s+rel=[\"'](?:manifest|icon|apple-touch-icon)[\"']\\s+href=[\"'])(\\/[^\"']*)([\"'][^>]*>)/g,\n `$1${STATIC_ASSET_ORIGIN}$2$3`\n )\n const bundleEntryPath = join(dirname(entryPath), \"index.sixb-bundle.html\")\n await writeFile(bundleEntryPath, bundleHtml, \"utf-8\")\n return bundleEntryPath\n}\n\nexport function restoreAppStaticUrls(html: string): string {\n return html.replaceAll(STATIC_ASSET_ORIGIN, \"\")\n}\n\nasync function rewriteIndexAssetPaths(outdir: string): Promise<void> {\n const indexPath = join(outdir, \"index.html\")\n const originalHtml = await readFile(indexPath, \"utf-8\")\n const html = restoreAppStaticUrls(originalHtml)\n\n const rewritten = html.replace(\n /(href|src)=([\"'])((?!\\/|#|[a-zA-Z][a-zA-Z\\d+.-]*:)(?:\\.\\/)?[^\"'?#]+(?:[?#][^\"']*)?)\\2/g,\n (_match, attr: string, quote: string, url: string) => {\n const normalized = url.startsWith(\"./\") ? url.slice(2) : url\n return `${attr}=${quote}/${normalized}${quote}`\n }\n )\n\n if (rewritten !== originalHtml) {\n await writeFile(indexPath, rewritten, \"utf-8\")\n }\n}\n",
7
+ "import { access, mkdir, readFile, writeFile } from \"node:fs/promises\"\nimport { join, relative, resolve } from \"node:path\"\nimport type { AuthSessionAudience } from \"@sixb/core\"\nimport { renderAppManifest } from \"./manifest\"\nimport { resolveAppMetadata } from \"./metadata\"\nimport { renderCustomAppRuntimeScript } from \"./runtime\"\nimport type { PageRoute } from \"./scanner\"\n\nexport interface BuiltInRouteManifestEntry {\n readonly path: string\n readonly moduleSpecifier: string\n readonly exportName?: string\n}\n\nexport interface GenerateRouteManifestOptions {\n readonly builtInRoutes?: readonly BuiltInRouteManifestEntry[]\n}\n\n/**\n * Generates `.sixb/generated/routes.ts` with static route imports. Pages are\n * eager on purpose: project-specific apps bundle small, and a single bundle\n * (one JS file, one render-blocking CSS file) means no Suspense gap or\n * late-arriving styles when navigating — matching how Atlas routes.\n */\nexport async function generateRouteManifest(\n routes: PageRoute[],\n generatedDir: string,\n options: GenerateRouteManifestOptions = {}\n): Promise<string> {\n await mkdir(generatedDir, { recursive: true })\n\n const imports = routes\n .map((route, index) => {\n const rel = relativeTo(generatedDir, route.filePath)\n return `import Page${index} from ${JSON.stringify(rel)}`\n })\n .join(\"\\n\")\n const builtInRoutes = options.builtInRoutes ?? []\n const builtInImports = builtInRoutes\n .map((route, index) => {\n if (route.exportName) {\n return `import { ${route.exportName} as BuiltInPage${index} } from ${JSON.stringify(route.moduleSpecifier)}`\n }\n\n return `import BuiltInPage${index} from ${JSON.stringify(route.moduleSpecifier)}`\n })\n .join(\"\\n\")\n\n const entries = routes\n .map((route, index) => ` { path: ${JSON.stringify(route.path)}, component: Page${index} },`)\n .join(\"\\n\")\n const builtInEntries = builtInRoutes\n .map(\n (route, index) => ` { path: ${JSON.stringify(route.path)}, component: BuiltInPage${index} },`\n )\n .join(\"\\n\")\n const routeEntries = [entries, builtInEntries].filter(Boolean).join(\"\\n\")\n const importEntries = [imports, builtInImports].filter(Boolean).join(\"\\n\")\n\n const content = `${importEntries}\n\nexport const routes = [\n${routeEntries}\n]\n`\n\n const outPath = join(generatedDir, \"routes.ts\")\n await writeFileIfChanged(outPath, content)\n return outPath\n}\n\n/**\n * Generates the app entry files:\n * - `.sixb/generated/index.html` — HTML shell\n * - `.sixb/generated/main.tsx` — React entry with BrowserRouter\n * - `.sixb/generated/app.webmanifest` — installable app identity\n */\nexport async function generateAppEntry(\n projectRoot: string,\n generatedDir: string,\n options: {\n apiBaseUrl?: string\n audience?: AuthSessionAudience\n authEnabled?: boolean\n appDir?: string\n publicDir?: string\n /**\n * Stylesheet to import from the generated entry. `undefined` auto-detects\n * `app/globals.css` and imports it when it exists; `null` skips the import;\n * a path imports that file (e.g. compiled Tailwind output).\n */\n stylesheetPath?: string | null\n /** Framework-owned stylesheets imported before the app stylesheet. */\n frameworkStylesheetPaths?: readonly string[]\n } = {}\n): Promise<{ htmlPath: string; mainPath: string; manifestPath: string }> {\n await mkdir(generatedDir, { recursive: true })\n\n const appDir = options.appDir ? resolve(projectRoot, options.appDir) : join(projectRoot, \"app\")\n const publicDir = options.publicDir\n ? resolve(projectRoot, options.publicDir)\n : join(appDir, \"public\")\n const globalsCssPath = join(appDir, \"globals.css\")\n const layoutPath = join(appDir, \"layout.tsx\")\n const metadata = await resolveAppMetadata({ layoutPath, publicDir })\n const manifestPath = join(generatedDir, \"app.webmanifest\")\n await writeFileIfChanged(manifestPath, renderAppManifest(metadata))\n const layoutRel = relativeTo(generatedDir, layoutPath)\n const hasLayout = await fileExists(layoutPath)\n const stylesheetPath =\n options.stylesheetPath !== undefined\n ? options.stylesheetPath\n : (await fileExists(globalsCssPath))\n ? globalsCssPath\n : null\n const stylesheetPaths = [\n ...(options.frameworkStylesheetPaths ?? []),\n ...(stylesheetPath ? [stylesheetPath] : []),\n ]\n const globalsCssImport = stylesheetPaths\n .map((path) => `import ${JSON.stringify(relativeTo(generatedDir, path))}`)\n .join(\"\\n\")\n const layoutImport = hasLayout ? `import RootLayout from ${JSON.stringify(layoutRel)}\\n` : \"\"\n const layoutWrapperStart = hasLayout ? \"<RootLayout>\" : \"<>\"\n const layoutWrapperEnd = hasLayout ? \"</RootLayout>\" : \"</>\"\n const runtimeConfigScript = options.apiBaseUrl\n ? renderCustomAppRuntimeScript({\n api: { baseUrl: options.apiBaseUrl },\n auth: { audience: options.audience ?? \"app\", enabled: options.authEnabled ?? true },\n })\n : \"\"\n\n // Generate main.tsx\n const mainContent = `import React from \"react\"\nimport { createRoot, type Root } from \"react-dom/client\"\nimport { signOut } from \"@sixb/client\"\nimport { BrowserRouter, Routes, Route, matchPath, useNavigate, useLocation } from \"react-router-dom\"\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\"\nimport {\n configureSixbBrowserClient,\n isSixbApiError,\n readSixbBrowserRuntimeConfig,\n requireSixbBrowserAuthSession,\n} from \"@sixb/client/browser\"\nimport { routes } from \"./routes\"\n${globalsCssImport}\n${layoutImport}\n\ninterface CustomAppHotData {\n root?: Root\n queryClient?: QueryClient\n}\n\nconst runtimeConfig = readSixbBrowserRuntimeConfig({ audience: \"app\" })\nconst browserClient = configureSixbBrowserClient(runtimeConfig)\n\nif (import.meta.hot) {\n import.meta.hot.accept()\n import.meta.hot.dispose(() => {\n browserClient.dispose()\n })\n}\n\nconst authSession = runtimeConfig.auth.enabled\n ? await requireSixbBrowserAuthSession(runtimeConfig, browserClient)\n : null\nconst applicationAccessDenied =\n authSession?.authenticated === true && !authSession.applicationAccess.allowed\nconst canRenderApp =\n !runtimeConfig.auth.enabled ||\n (authSession?.authenticated === true && authSession.applicationAccess.allowed)\n\nconst queryClient = getQueryClient()\n\nfunction getRoot(): Root {\n const element = document.getElementById(\"root\")\n if (!element) {\n throw new Error(\"[SixbApp] Could not find the root element.\")\n }\n\n if (import.meta.hot) {\n const data = import.meta.hot.data as CustomAppHotData\n data.root ??= createRoot(element)\n return data.root\n }\n\n return createRoot(element)\n}\n\nfunction getQueryClient(): QueryClient {\n if (import.meta.hot) {\n const data = import.meta.hot.data as CustomAppHotData\n data.queryClient ??= createQueryClient()\n return data.queryClient\n }\n\n return createQueryClient()\n}\n\nfunction createQueryClient(): QueryClient {\n return new QueryClient({\n defaultOptions: {\n queries: {\n refetchOnWindowFocus: false,\n retry: 1,\n },\n },\n })\n}\n\nconst RESERVED_PATH_PREFIXES = [\"/api\", \"/auth\", \"/ws\", \"/docs\"]\n\nfunction isReservedPath(pathname: string) {\n return RESERVED_PATH_PREFIXES.some(\n (prefix) => pathname === prefix || pathname.startsWith(prefix + \"/\")\n )\n}\n\n// Makes plain same-origin <a href=\"/...\"> clicks navigate client-side, so app\n// authors get SPA navigation without remembering react-router's <Link>.\n// Deliberately conservative: anything unusual falls through to the browser.\nfunction InternalLinkInterceptor() {\n const navigate = useNavigate()\n\n React.useEffect(() => {\n function onClick(event: MouseEvent) {\n if (event.defaultPrevented) return\n if (event.button !== 0) return\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return\n\n const target = event.target\n if (!(target instanceof Element)) return\n const anchor = target.closest(\"a\")\n if (!(anchor instanceof HTMLAnchorElement)) return\n if (anchor.target && anchor.target !== \"_self\") return\n if (anchor.hasAttribute(\"download\")) return\n if (anchor.relList.contains(\"external\")) return\n if (!anchor.getAttribute(\"href\")) return\n\n const url = new URL(anchor.href, window.location.href)\n if (url.origin !== window.location.origin) return\n if (isReservedPath(url.pathname)) return\n // Only intercept destinations the app actually routes; anything else may\n // be a real server resource and keeps native navigation.\n if (!routes.some((route) => matchPath(route.path, url.pathname))) return\n // Same-document hash links keep native scroll behavior.\n if (\n url.hash &&\n url.pathname === window.location.pathname &&\n url.search === window.location.search\n ) {\n return\n }\n\n event.preventDefault()\n navigate(url.pathname + url.search + url.hash)\n }\n\n document.addEventListener(\"click\", onClick)\n return () => document.removeEventListener(\"click\", onClick)\n }, [navigate])\n\n return null\n}\n\n// Shared presentational fallback used by the not-found view and the error\n// boundary. Styled with @sixb/ui design tokens (var(--token)) so it adopts the\n// app's theme when those tokens are loaded, but every token has a hardcoded\n// fallback so it stays self-contained and readable when they are not. The\n// background/foreground pair is always set together so text stays legible\n// regardless of the surrounding app's background.\nfunction AppFallback({\n title,\n detail,\n showReload = true,\n action,\n}: {\n title: string\n detail: string\n showReload?: boolean\n action?: React.ReactNode\n}) {\n return (\n <div\n role=\"alert\"\n style={{\n minHeight: \"100dvh\",\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: \"1rem\",\n padding: \"2rem\",\n textAlign: \"center\",\n fontFamily:\n \"var(--font-sans, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif)\",\n background: \"var(--background, #ffffff)\",\n color: \"var(--foreground, #1f2933)\",\n }}\n >\n <h1 style={{ margin: 0, fontSize: \"1.5rem\", fontWeight: 600 }}>{title}</h1>\n <p style={{ margin: 0, maxWidth: \"32rem\", color: \"var(--muted-foreground, #52606d)\" }}>\n {detail}\n </p>\n <div style={{ display: \"flex\", gap: \"0.75rem\" }}>\n {action ?? (\n <>\n <a\n href=\"/\"\n style={{\n padding: \"0.5rem 1rem\",\n borderRadius: \"var(--radius, 0.5rem)\",\n background: \"var(--primary, #1f2933)\",\n color: \"var(--primary-foreground, #ffffff)\",\n textDecoration: \"none\",\n }}\n >\n Go home\n </a>\n {showReload ? (\n <button\n type=\"button\"\n onClick={() => window.location.reload()}\n style={{\n padding: \"0.5rem 1rem\",\n borderRadius: \"var(--radius, 0.5rem)\",\n border: \"1px solid var(--border, #cbd2d9)\",\n background: \"transparent\",\n color: \"inherit\",\n cursor: \"pointer\",\n }}\n >\n Reload\n </button>\n ) : null}\n </>\n )}\n </div>\n </div>\n )\n}\n\nfunction AccessDeniedView() {\n const [isSigningOut, setIsSigningOut] = React.useState(false)\n\n async function handleSignOut() {\n setIsSigningOut(true)\n try {\n await signOut({ throwOnError: true })\n window.location.reload()\n } catch {\n setIsSigningOut(false)\n }\n }\n\n return (\n <AppFallback\n title=\"Access required\"\n detail=\"Your account is signed in, but it does not have permission to access this app.\"\n showReload={false}\n action={\n <button\n type=\"button\"\n disabled={isSigningOut}\n onClick={handleSignOut}\n style={{\n padding: \"0.5rem 1rem\",\n borderRadius: \"var(--radius, 0.5rem)\",\n border: \"1px solid var(--border, #cbd2d9)\",\n background: \"transparent\",\n color: \"inherit\",\n cursor: isSigningOut ? \"default\" : \"pointer\",\n }}\n >\n {isSigningOut ? \"Signing out…\" : \"Sign out\"}\n </button>\n }\n />\n )\n}\n\n// The not-found view. Rendered both for unmatched client routes (the catch-all\n// route below) and for an expected 404 surfaced through a query. Apps will be\n// able to override this via app/not-found.tsx.\nfunction NotFoundView() {\n return (\n <AppFallback\n title=\"Not found\"\n detail=\"The page or resource you requested does not exist.\"\n showReload={false}\n />\n )\n}\n\n// Last-resort safety net so an uncaught render throw (a 404 surfaced through a\n// suspense/throwOnError query, a bug, a failed import) shows a fallback instead\n// of a blank page and a console error. A missing object is an expected state,\n// so a 404 reuses the not-found view rather than the generic crash screen.\n// Apps will be able to override this via app/error.tsx.\nfunction AppErrorFallback({ error }: { error: unknown }) {\n if (isSixbApiError(error) && error.status === 404) {\n return <NotFoundView />\n }\n return (\n <AppFallback\n title=\"Something went wrong\"\n detail={error instanceof Error ? error.message : String(error)}\n />\n )\n}\n\nclass AppErrorBoundary extends React.Component<\n { resetKey: string; children: React.ReactNode },\n { error: unknown }\n> {\n state: { error: unknown } = { error: null }\n\n static getDerivedStateFromError(error: unknown) {\n return { error }\n }\n\n componentDidCatch(error: unknown) {\n console.error(\"[SixbApp] Uncaught render error:\", error)\n }\n\n // Clear the error when the route changes so navigating away (or an in-app\n // link) recovers without a full reload.\n componentDidUpdate(prevProps: { resetKey: string }) {\n if (this.state.error !== null && prevProps.resetKey !== this.props.resetKey) {\n this.setState({ error: null })\n }\n }\n\n render() {\n if (this.state.error !== null) {\n return <AppErrorFallback error={this.state.error} />\n }\n return this.props.children\n }\n}\n\nfunction RoutedErrorBoundary({ children }: { children: React.ReactNode }) {\n const location = useLocation()\n return (\n <AppErrorBoundary resetKey={location.pathname + location.search}>{children}</AppErrorBoundary>\n )\n}\n\nfunction App() {\n return (\n <QueryClientProvider client={queryClient}>\n <BrowserRouter>\n <InternalLinkInterceptor />\n <RoutedErrorBoundary>\n ${layoutWrapperStart}\n <Routes>\n {routes.map((route) => (\n <Route key={route.path} path={route.path} element={<route.component />} />\n ))}\n <Route path=\"*\" element={<NotFoundView />} />\n </Routes>\n ${layoutWrapperEnd}\n </RoutedErrorBoundary>\n </BrowserRouter>\n </QueryClientProvider>\n )\n}\n\nif (canRenderApp) {\n getRoot().render(<App />)\n} else if (applicationAccessDenied) {\n getRoot().render(<AccessDeniedView />)\n}\n`\n\n const mainPath = join(generatedDir, \"main.tsx\")\n await writeFileIfChanged(mainPath, mainContent)\n\n // Generate index.html with static identity and only structural reset rules.\n // Apps own visual styling through app/globals.css.\n const metadataHead = renderMetadataHead(metadata)\n const htmlContent = `<!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, viewport-fit=cover\" />\n${metadataHead}\n ${runtimeConfigScript}\n <style>\n * {\n box-sizing: border-box;\n }\n html,\n body,\n #root {\n margin: 0;\n min-height: 100%;\n }\n body,\n #root {\n min-height: 100vh;\n min-height: 100dvh;\n }\n @media (display-mode: standalone) {\n html,\n body {\n overscroll-behavior: none;\n }\n }\n </style>\n </head>\n <body>\n <div id=\"root\"></div>\n <script type=\"module\" src=\"./main.tsx\"></script>\n </body>\n</html>\n`\n\n const htmlPath = join(generatedDir, \"index.html\")\n await writeFileIfChanged(htmlPath, htmlContent)\n\n return { htmlPath, mainPath, manifestPath }\n}\n\nfunction renderMetadataHead(metadata: Awaited<ReturnType<typeof resolveAppMetadata>>): string {\n const tags = [\n ` <title>${escapeHtmlText(metadata.title)}</title>`,\n ...(metadata.description\n ? [` <meta name=\"description\" content=\"${escapeHtmlAttribute(metadata.description)}\" />`]\n : []),\n ` <meta name=\"theme-color\" content=\"${escapeHtmlAttribute(metadata.themeColor)}\" />`,\n ' <link rel=\"manifest\" href=\"/app.webmanifest\" />',\n ...(metadata.favicon\n ? [` <link rel=\"icon\" href=\"${escapeHtmlAttribute(metadata.favicon)}\" />`]\n : []),\n ...(metadata.appleTouchIcon\n ? [` <link rel=\"apple-touch-icon\" href=\"${metadata.appleTouchIcon}\" />`]\n : []),\n ]\n return tags.join(\"\\n\")\n}\n\nfunction escapeHtmlText(value: string): string {\n return value.replaceAll(\"&\", \"&amp;\").replaceAll(\"<\", \"&lt;\").replaceAll(\">\", \"&gt;\")\n}\n\nfunction escapeHtmlAttribute(value: string): string {\n return escapeHtmlText(value).replaceAll('\"', \"&quot;\").replaceAll(\"'\", \"&#39;\")\n}\n\nasync function writeFileIfChanged(path: string, content: string): Promise<void> {\n try {\n if ((await readFile(path, \"utf-8\")) === content) {\n return\n }\n } catch (error) {\n if (!isFileNotFoundError(error)) {\n throw error\n }\n }\n\n await writeFile(path, content, \"utf-8\")\n}\n\nfunction isFileNotFoundError(error: unknown): boolean {\n return (\n error instanceof Error &&\n \"code\" in error &&\n (error as Error & { readonly code?: unknown }).code === \"ENOENT\"\n )\n}\n\nfunction relativeTo(from: string, to: string): string {\n let rel = relative(from, to)\n // Ensure it starts with ./ or ../\n if (!rel.startsWith(\".\")) rel = `./${rel}`\n return rel\n}\n\nasync function fileExists(path: string): Promise<boolean> {\n try {\n await access(path)\n return true\n } catch {\n return false\n }\n}\n",
8
+ "import type { ResolvedAppMetadata, ResolvedManifestIcon } from \"./metadata\"\n\ninterface CustomAppManifest {\n readonly id: \"/\"\n readonly name: string\n readonly description?: string\n readonly start_url: \"/\"\n readonly scope: \"/\"\n readonly display: \"standalone\"\n readonly theme_color: string\n readonly background_color: string\n readonly icons?: readonly ResolvedManifestIcon[]\n}\n\nexport function renderAppManifest(metadata: ResolvedAppMetadata): string {\n const manifest: CustomAppManifest = {\n id: \"/\",\n name: metadata.title,\n ...(metadata.description ? { description: metadata.description } : {}),\n start_url: \"/\",\n scope: \"/\",\n display: \"standalone\",\n theme_color: metadata.themeColor,\n background_color: metadata.backgroundColor,\n ...(metadata.icons.length > 0 ? { icons: metadata.icons } : {}),\n }\n\n return `${JSON.stringify(manifest, null, 2)}\\n`\n}\n",
9
+ "import { createHash } from \"node:crypto\"\nimport { readFile, stat } from \"node:fs/promises\"\nimport { createRequire } from \"node:module\"\nimport { extname, join } from \"node:path\"\nimport { pathToFileURL } from \"node:url\"\n\nexport interface AppMetadata {\n title?: string\n description?: string\n favicon?: string\n themeColor?: string\n backgroundColor?: string\n}\n\nexport interface ResolvedManifestIcon {\n readonly src: string\n readonly sizes?: string\n readonly type?: string\n readonly purpose?: \"any\" | \"maskable\"\n}\n\nexport interface ResolvedAppMetadata {\n readonly title: string\n readonly description?: string\n readonly favicon?: string\n readonly themeColor: string\n readonly backgroundColor: string\n readonly appleTouchIcon?: string\n readonly icons: readonly ResolvedManifestIcon[]\n}\n\nexport interface ResolveAppMetadataOptions {\n readonly layoutPath: string\n readonly publicDir: string\n}\n\nconst metadataRequire = createRequire(import.meta.url)\n\nconst metadataFields = [\n \"title\",\n \"description\",\n \"favicon\",\n \"themeColor\",\n \"backgroundColor\",\n] as const satisfies readonly (keyof AppMetadata)[]\n\n/** Loads, validates, defaults, and resolves all custom-app identity in one place. */\nexport async function resolveAppMetadata(\n options: ResolveAppMetadataOptions\n): Promise<ResolvedAppMetadata> {\n const configured = await loadConfiguredMetadata(options.layoutPath)\n validateMetadata(configured, options.layoutPath)\n\n const conventionalFaviconPath = join(options.publicDir, \"favicon.svg\")\n const favicon =\n configured.favicon ?? ((await fileExists(conventionalFaviconPath)) ? \"/favicon.svg\" : undefined)\n const themeColor = configured.themeColor ?? configured.backgroundColor ?? \"#ffffff\"\n const backgroundColor = configured.backgroundColor ?? themeColor\n const icons: ResolvedManifestIcon[] = []\n\n if (await fileExists(join(options.publicDir, \"icon-192.png\"))) {\n icons.push({\n src: \"/icon-192.png\",\n sizes: \"192x192\",\n type: \"image/png\",\n purpose: \"any\",\n })\n }\n if (await fileExists(join(options.publicDir, \"icon-512.png\"))) {\n icons.push({\n src: \"/icon-512.png\",\n sizes: \"512x512\",\n type: \"image/png\",\n purpose: \"any\",\n })\n }\n if (await fileExists(join(options.publicDir, \"icon-maskable-512.png\"))) {\n icons.push({\n src: \"/icon-maskable-512.png\",\n sizes: \"512x512\",\n type: \"image/png\",\n purpose: \"maskable\",\n })\n }\n\n const hasStandardIcon = icons.some((icon) => icon.purpose === \"any\")\n if (!hasStandardIcon && favicon) {\n const type = inferImageMimeType(favicon)\n if (type) {\n icons.push({\n src: favicon,\n ...(type === \"image/svg+xml\" ? { sizes: \"any\" } : {}),\n type,\n purpose: \"any\",\n })\n }\n }\n\n return {\n title: configured.title ?? \"Sixb\",\n ...(configured.description ? { description: configured.description } : {}),\n ...(favicon ? { favicon } : {}),\n themeColor,\n backgroundColor,\n ...((await fileExists(join(options.publicDir, \"apple-touch-icon.png\")))\n ? { appleTouchIcon: \"/apple-touch-icon.png\" }\n : {}),\n icons,\n }\n}\n\nasync function loadConfiguredMetadata(layoutPath: string): Promise<AppMetadata> {\n if (!(await fileExists(layoutPath))) {\n return {}\n }\n\n try {\n const sourceHash = createHash(\"sha256\")\n .update(await readFile(layoutPath))\n .digest(\"hex\")\n const url = pathToFileURL(layoutPath)\n // Bun currently canonicalizes file-URL query strings in its module cache.\n // Explicit invalidation makes the source fingerprint a reliable dev cache\n // buster while retaining a normal file URL and relative import behavior.\n delete metadataRequire.cache[metadataRequire.resolve(layoutPath)]\n url.searchParams.set(\"sixb-metadata\", sourceHash)\n const layoutModule = (await import(url.href)) as { readonly metadata?: unknown }\n\n if (layoutModule.metadata === undefined) {\n return {}\n }\n if (\n typeof layoutModule.metadata !== \"object\" ||\n layoutModule.metadata === null ||\n Array.isArray(layoutModule.metadata)\n ) {\n throw metadataError(layoutPath, \"the named metadata export must be an object\")\n }\n\n return layoutModule.metadata as AppMetadata\n } catch (error) {\n if (error instanceof Error && error.message.startsWith(\"[SixbCustomApp]\")) {\n throw error\n }\n\n const detail = error instanceof Error ? error.message : String(error)\n throw new Error(\n `[SixbCustomApp] Could not load metadata from ${layoutPath}: ${detail}. ` +\n \"App metadata is build-time configuration, so app/layout.tsx must be import-safe in Bun \" +\n \"and must not access window or document at module scope.\"\n )\n }\n}\n\nfunction validateMetadata(metadata: AppMetadata, layoutPath: string): void {\n for (const field of metadataFields) {\n const value = metadata[field]\n if (value !== undefined && (typeof value !== \"string\" || value.trim().length === 0)) {\n throw metadataError(layoutPath, `metadata.${field} must be a non-empty string when provided`)\n }\n }\n}\n\nfunction metadataError(layoutPath: string, detail: string): Error {\n return new Error(`[SixbCustomApp] Invalid app metadata in ${layoutPath}: ${detail}`)\n}\n\nfunction inferImageMimeType(url: string): string | undefined {\n if (url.startsWith(\"data:\")) {\n const match = /^data:(image\\/[a-z0-9.+-]+)/i.exec(url)\n return match?.[1]?.toLowerCase()\n }\n\n let pathname = url\n try {\n pathname = new URL(url, \"https://sixb.invalid\").pathname\n } catch {\n // Fall back to extension parsing on the configured value.\n }\n\n switch (extname(pathname).toLowerCase()) {\n case \".svg\":\n return \"image/svg+xml\"\n case \".png\":\n return \"image/png\"\n case \".ico\":\n return \"image/x-icon\"\n case \".jpg\":\n case \".jpeg\":\n return \"image/jpeg\"\n case \".webp\":\n return \"image/webp\"\n case \".avif\":\n return \"image/avif\"\n default:\n return undefined\n }\n}\n\nasync function fileExists(path: string): Promise<boolean> {\n try {\n return (await stat(path)).isFile()\n } catch {\n return false\n }\n}\n",
10
+ "import type { AuthSessionAudience } from \"@sixb/core\"\n\nexport interface CustomAppRuntimeConfig {\n readonly api: {\n readonly baseUrl: string\n }\n readonly auth: {\n readonly audience: AuthSessionAudience\n readonly enabled: boolean\n }\n}\n\nexport function renderCustomAppRuntimeScript(config: CustomAppRuntimeConfig): string {\n const safeConfig = JSON.stringify(config).replaceAll(\"<\", \"\\\\u003c\")\n return `<script>window.__SIXB_RUNTIME__ = ${safeConfig};</script>`\n}\n",
11
+ "import { readdir } from \"node:fs/promises\"\nimport { join, relative } from \"node:path\"\n\nexport interface PageRoute {\n /** React Router path, e.g. \"/\" or \"/remote/:id\" */\n path: string\n /** Absolute file path */\n filePath: string\n /** Relative path from the app directory, e.g. \"remote/[id]/page.tsx\" */\n relativePath: string\n}\n\n/**\n * Recursively scans an `app/` directory for `page.tsx`/`page.ts` files and\n * converts them to React Router route paths.\n *\n * - `app/page.tsx` -> `/`\n * - `app/about/page.tsx` -> `/about`\n * - `app/remote/[id]/page.tsx` -> `/remote/:id`\n * - Files starting with `_` are skipped.\n */\nexport async function scanPages(appDir: string): Promise<PageRoute[]> {\n const routes: PageRoute[] = []\n await walkDir(appDir, appDir, routes)\n routes.sort((a, b) => a.path.localeCompare(b.path))\n return routes\n}\n\nasync function walkDir(dir: string, appDir: string, routes: PageRoute[]): Promise<void> {\n let entries: import(\"node:fs\").Dirent[]\n try {\n entries = (await readdir(dir, { withFileTypes: true })) as import(\"node:fs\").Dirent[]\n } catch {\n return\n }\n\n for (const entry of entries) {\n const name = String(entry.name)\n if (name.startsWith(\"_\")) continue\n\n const fullPath = join(dir, name)\n\n if (entry.isDirectory()) {\n await walkDir(fullPath, appDir, routes)\n continue\n }\n\n if (!entry.isFile()) continue\n const isPageModule = name === \"page.tsx\" || name === \"page.ts\"\n if (!isPageModule) continue\n\n const relativePath = relative(appDir, fullPath)\n const routePath = filePathToRoutePath(relativePath)\n\n routes.push({\n path: routePath,\n filePath: fullPath,\n relativePath,\n })\n }\n}\n\nfunction filePathToRoutePath(filePath: string): string {\n // Remove extension\n let route = filePath.replace(/\\.(tsx|ts)$/, \"\")\n\n // Normalize path separators\n route = route.split(\"\\\\\").join(\"/\")\n\n // Convert [param] to :param\n route = route.replace(/\\[([^\\]]+)\\]/g, \":$1\")\n\n // Remove trailing /page\n if (route === \"page\") return \"/\"\n route = route.replace(/\\/page$/, \"\")\n\n // Ensure leading slash\n if (!route.startsWith(\"/\")) route = `/${route}`\n\n return route\n}\n",
12
+ "import { readFile } from \"node:fs/promises\"\nimport { join } from \"node:path\"\nimport { resolveTailwindCliEntry } from \"./tailwind\"\n\nexport type CustomAppStylesheet =\n /** No `app/globals.css` — the app ships no framework-managed stylesheet. */\n | { readonly kind: \"none\" }\n /** Plain handwritten CSS — bundled as-is, exactly as before. */\n | { readonly kind: \"static\"; readonly path: string }\n /** Tailwind source — compiled to `outputPath` before bundling. */\n | { readonly kind: \"tailwind\"; readonly sourcePath: string; readonly outputPath: string }\n\nexport interface ResolveCustomAppStylesheetInput {\n readonly appDir: string\n readonly generatedDir: string\n readonly rootDir: string\n}\n\n/**\n * Decides how `app/globals.css` participates in the build.\n *\n * `globals.css` is treated as Tailwind *source* when it uses Tailwind at-rules\n * (`@source`, `@theme`, ...) or imports a package stylesheet such as\n * `@sixb/ui/globals.css` — those need the Tailwind pipeline before they are\n * shippable. Plain CSS keeps the existing pass-through behavior, so apps that\n * never opted into Tailwind are unaffected.\n */\nexport async function resolveCustomAppStylesheet(\n input: ResolveCustomAppStylesheetInput\n): Promise<CustomAppStylesheet> {\n const sourcePath = join(input.appDir, \"globals.css\")\n\n let css: string\n try {\n css = await readFile(sourcePath, \"utf-8\")\n } catch {\n return { kind: \"none\" }\n }\n\n if (!usesTailwind(css)) {\n return { kind: \"static\", path: sourcePath }\n }\n\n if (!resolveTailwindCliEntry(input.rootDir)) {\n throw new Error(\n \"[SixbCustomApp] app/globals.css uses Tailwind features but '@tailwindcss/cli' is not installed. Install it with: bun add tailwindcss @tailwindcss/cli\"\n )\n }\n\n return {\n kind: \"tailwind\",\n sourcePath,\n outputPath: join(input.generatedDir, \"app.css\"),\n }\n}\n\nconst TAILWIND_AT_RULES =\n /@(?:tailwind|source|theme|plugin|config|utility|custom-variant|variant|apply)\\b/\n\nexport function usesTailwind(css: string): boolean {\n const stripped = css.replace(/\\/\\*[\\s\\S]*?\\*\\//g, \"\")\n\n if (TAILWIND_AT_RULES.test(stripped)) {\n return true\n }\n\n // A bare-specifier @import (e.g. `@import \"tailwindcss\"` or\n // `@import \"@sixb/ui/globals.css\"`) pulls in package CSS that the browser\n // bundler would inline without processing its Tailwind directives.\n for (const match of stripped.matchAll(/@import\\s+(?:url\\(\\s*)?[\"']([^\"']+)[\"']/g)) {\n const specifier = match[1]\n if (\n !specifier.startsWith(\".\") &&\n !specifier.startsWith(\"/\") &&\n !specifier.startsWith(\"#\") &&\n !/^(?:https?:|data:)/.test(specifier)\n ) {\n return true\n }\n }\n\n return false\n}\n",
13
+ "import { mkdir } from \"node:fs/promises\"\nimport { dirname, join } from \"node:path\"\n\nexport interface TailwindCssCompilerOptions {\n /** Tailwind source stylesheet. */\n inputPath: string\n /** Compiled CSS output path. */\n outputPath: string\n /**\n * Working directory for the Tailwind CLI. Tailwind v4's automatic source\n * detection scans from here, so keep it scoped to the directory that owns the\n * styles (e.g. `app/`) — never a repo root that may contain `vendor/` or\n * `node_modules/` siblings.\n */\n cwd?: string\n /**\n * Directory whose dependency tree is used to resolve `@tailwindcss/cli`.\n * Defaults to `cwd`. Pass the project root so the project's own Tailwind\n * version wins.\n */\n resolveFrom?: string\n /** Prefix for error messages, e.g. `[SixbAtlas]`. */\n label?: string\n /** Minify the compiled CSS. Off by default; bundlers usually minify later. */\n minify?: boolean\n /** Debounce for `schedule()` rebuilds, in milliseconds. */\n debounceMs?: number\n /**\n * Upper bound on one Tailwind build, in milliseconds. Defaults to 60s.\n *\n * A bound on a hang, not a performance budget: a wedged CLI otherwise held `sixb dev` open\n * forever, and `stop()` waited on it.\n */\n timeoutMs?: number\n /** Called when a `schedule()`d rebuild fails. Defaults to `console.error`. */\n onError?: (error: Error) => void\n}\n\nexport interface TailwindCssCompiler {\n /**\n * Compiles the stylesheet. Builds are serialized: a call made while another\n * build is running starts a fresh build after it, so the output always\n * reflects the sources as of the call. Throws with a labeled, actionable\n * error when the CLI is missing or compilation fails.\n */\n compile(): Promise<void>\n /**\n * Debounced `compile()` for watch flows. Coalesces bursts of file events;\n * errors go to `onError` instead of throwing.\n */\n schedule(): void\n /** Cancels pending rebuilds and waits for any in-flight build to settle. */\n stop(): Promise<void>\n}\n\n/**\n * Resolves the Tailwind v4 CLI entry point from a directory's dependency tree.\n * Returns null when `@tailwindcss/cli` is not installed there.\n */\nexport function resolveTailwindCliEntry(resolveFrom: string): string | null {\n try {\n const packageJsonPath = Bun.resolveSync(\"@tailwindcss/cli/package.json\", resolveFrom)\n return join(dirname(packageJsonPath), \"dist\", \"index.mjs\")\n } catch {\n return null\n }\n}\n\n/**\n * Shared Tailwind v4 CSS build pipeline used by the built-in UI (Atlas) and\n * custom apps. Owns CLI resolution, source-detection scoping,\n * debounced/queued rebuilds, error formatting, and watch lifecycle cleanup.\n */\nexport function createTailwindCssCompiler(\n options: TailwindCssCompilerOptions\n): TailwindCssCompiler {\n const cwd = options.cwd ?? dirname(options.inputPath)\n const resolveFrom = options.resolveFrom ?? cwd\n const label = options.label ?? \"[SixbTailwind]\"\n const debounceMs = options.debounceMs ?? 50\n const timeoutMs = options.timeoutMs ?? 60_000\n const onError = options.onError ?? ((error: Error) => console.error(`${label} ${error.message}`))\n\n let chain: Promise<void> = Promise.resolve()\n let timer: ReturnType<typeof setTimeout> | null = null\n let stopped = false\n let activeProcess: { kill: (signal?: number | NodeJS.Signals) => void } | null = null\n\n async function runCompile(): Promise<void> {\n // `compile()` queues this behind the current chain, so a `stop()` can land before the\n // child is ever spawned. Without this the build started anyway and there was nothing\n // for `stop()` to kill, so shutdown waited out the full timeout.\n if (stopped) return\n\n const cliEntry = resolveTailwindCliEntry(resolveFrom)\n if (!cliEntry) {\n throw new Error(\n `${label} Tailwind CSS build requires '@tailwindcss/cli'. Install it with: bun add tailwindcss @tailwindcss/cli`\n )\n }\n\n await mkdir(dirname(options.outputPath), { recursive: true })\n // The only await before the spawn, so the only other window a `stop()` can land in.\n if (stopped) return\n\n const args = [process.execPath, cliEntry, \"-i\", options.inputPath, \"-o\", options.outputPath]\n if (options.minify) {\n args.push(\"--minify\")\n }\n\n const proc = Bun.spawn(args, {\n cwd,\n stdout: \"ignore\",\n stderr: \"pipe\",\n })\n activeProcess = proc\n\n // Start draining stderr while the child runs rather than after it exits. Bun buffers\n // this pipe today, so reading afterwards does not block the child — measured, not\n // assumed — but that is Bun's choice and not something this code should depend on. The\n // catch keeps a stream torn down by `kill()` from surfacing as an unhandled rejection.\n const stderr = new Response(proc.stderr).text().catch(() => \"\")\n\n let timeout: ReturnType<typeof setTimeout> | undefined\n const timedOut = new Promise<\"timeout\">((resolve) => {\n timeout = setTimeout(() => resolve(\"timeout\"), timeoutMs)\n })\n\n try {\n const outcome = await Promise.race([proc.exited, timedOut])\n\n // `stop()` kills the child on purpose. Reporting that as a build failure would put\n // an error in the log for every shutdown that happened to catch a rebuild.\n if (stopped) return\n\n if (outcome === \"timeout\") {\n proc.kill(\"SIGKILL\")\n await proc.exited\n throw new Error(\n `${label} Tailwind CSS build did not finish within ${timeoutMs}ms and was killed. ` +\n `Check ${options.inputPath} and the sources Tailwind scans from ${cwd}.`\n )\n }\n\n if (outcome !== 0) {\n throw new Error(`${label} Tailwind CSS build failed: ${(await stderr).trim()}`)\n }\n } finally {\n clearTimeout(timeout)\n activeProcess = null\n }\n }\n\n function compile(): Promise<void> {\n stopped = false\n const build = chain.then(() => runCompile())\n // The chain itself swallows failures so one bad build doesn't poison every\n // later compile; callers still observe their own build's error.\n chain = build.then(\n () => {},\n () => {}\n )\n return build\n }\n\n return {\n compile,\n\n schedule() {\n if (stopped) return\n if (timer) {\n clearTimeout(timer)\n }\n\n timer = setTimeout(() => {\n timer = null\n compile().catch((error) => {\n onError(error instanceof Error ? error : new Error(String(error)))\n })\n }, debounceMs)\n },\n\n async stop() {\n stopped = true\n if (timer) {\n clearTimeout(timer)\n timer = null\n }\n // Kill rather than wait. A build in flight would otherwise hold shutdown for up to\n // the whole timeout, and the output it is writing is about to be discarded anyway.\n activeProcess?.kill(\"SIGKILL\")\n await chain\n },\n }\n}\n"
14
+ ],
15
+ "mappings": ";;AAAA;AACA,mBAAS,sBAAY,oBAAO,wBAAU;AACtC,oBAAS,8BAAqB,8BAAiB,sBAAU;AACzD,0BAAS;;;ACHT;AACA;AAEA,IAAM,sBAAsB;AAqB5B,eAAsB,QAAQ,CAAC,SAAmD;AAAA,EAChF,MAAM,SAAS,QAAQ,UAAU,KAAK,QAAQ,IAAI,GAAG,SAAS,QAAQ,KAAK;AAAA,EAG3E,MAAM,GAAG,QAAQ,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAAA,EACjD,MAAM,MAAM,QAAQ,EAAE,WAAW,KAAK,CAAC;AAAA,EAEvC,MAAM,kBAAkB,MA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IAAI,UAAU,aAAa,OAAO,eAAe,UAAU,QAAQ,GAAG;AAAA,MACpE,OAAO,iBAAiB;AAAA,IAC1B;AAAA,IAEA,MAAM,MAAM,IAAI,IAAI,uBAAuB,eAAe,CAAC;AAAA,IAC3D,IAAI,SAAS,UAAU;AAAA,IACvB,MAAM,iBAAiB,IAAI,QAAQ,QAAQ,OAAO;AAAA,IAClD,WAAW,UAAU;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,GAAG;AAAA,MACD,eAAe,OAAO,MAAM;AAAA,IAC9B;AAAA,IACA,MAAM,iBAAiB,MAAM,MAC3B,IAAI,QAAQ,KAAK,EAAE,QAAQ,QAAQ,QAAQ,SAAS,eAAe,CAAC,CACtE;AAAA,IACA,MAAM,kBAAkB,IAAI,QAAQ,eAAe,OAAO;AAAA,IAC1D,gBAAgB,OAAO,gBAAgB;AAAA,IACvC,gBAAgB,OAAO,MAAM;AAAA,IAC7B,IAAI,QAAQ,WAAW,QAAQ;AAAA,MAC7B,OAAO,IAAI,SAAS,MAAM;AAAA,QACxB,QAAQ,eAAe;AAAA,QACvB,YAAY,eAAe;AAAA,QAC3B,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAAA,IAEA,OAAO,IAAI,SAAS,qBAAqB,MAAM,eAAe,KAAK,CAAC,GAAG;AAAA,MACrE,QAAQ,eAAe;AAAA,MACvB,YAAY,eAAe;AAAA,MAC3B,SAAS;AAAA,IACX,CAAC;AAAA,GACF;AAAA;",
16
+ "debugId": "EF77EB82048A32D864756E2164756E21",
17
+ "names": []
18
+ }
@@ -0,0 +1,3 @@
1
+ import type { ResolvedAppMetadata } from "./metadata";
2
+ export declare function renderAppManifest(metadata: ResolvedAppMetadata): string;
3
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAwB,MAAM,YAAY,CAAA;AAc3E,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,MAAM,CAcvE"}
@@ -0,0 +1,29 @@
1
+ export interface AppMetadata {
2
+ title?: string;
3
+ description?: string;
4
+ favicon?: string;
5
+ themeColor?: string;
6
+ backgroundColor?: string;
7
+ }
8
+ export interface ResolvedManifestIcon {
9
+ readonly src: string;
10
+ readonly sizes?: string;
11
+ readonly type?: string;
12
+ readonly purpose?: "any" | "maskable";
13
+ }
14
+ export interface ResolvedAppMetadata {
15
+ readonly title: string;
16
+ readonly description?: string;
17
+ readonly favicon?: string;
18
+ readonly themeColor: string;
19
+ readonly backgroundColor: string;
20
+ readonly appleTouchIcon?: string;
21
+ readonly icons: readonly ResolvedManifestIcon[];
22
+ }
23
+ export interface ResolveAppMetadataOptions {
24
+ readonly layoutPath: string;
25
+ readonly publicDir: string;
26
+ }
27
+ /** Loads, validates, defaults, and resolves all custom-app identity in one place. */
28
+ export declare function resolveAppMetadata(options: ResolveAppMetadataOptions): Promise<ResolvedAppMetadata>;
29
+ //# sourceMappingURL=metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,GAAG,UAAU,CAAA;CACtC;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,KAAK,EAAE,SAAS,oBAAoB,EAAE,CAAA;CAChD;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAC3B;AAYD,qFAAqF;AACrF,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,mBAAmB,CAAC,CA4D9B"}
@@ -0,0 +1,12 @@
1
+ import type { AuthSessionAudience } from "@sixb/core";
2
+ export interface CustomAppRuntimeConfig {
3
+ readonly api: {
4
+ readonly baseUrl: string;
5
+ };
6
+ readonly auth: {
7
+ readonly audience: AuthSessionAudience;
8
+ readonly enabled: boolean;
9
+ };
10
+ }
11
+ export declare function renderCustomAppRuntimeScript(config: CustomAppRuntimeConfig): string;
12
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAErD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,GAAG,EAAE;QACZ,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KACzB,CAAA;IACD,QAAQ,CAAC,IAAI,EAAE;QACb,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAA;QACtC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;KAC1B,CAAA;CACF;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,CAGnF"}
@@ -0,0 +1,19 @@
1
+ export interface PageRoute {
2
+ /** React Router path, e.g. "/" or "/remote/:id" */
3
+ path: string;
4
+ /** Absolute file path */
5
+ filePath: string;
6
+ /** Relative path from the app directory, e.g. "remote/[id]/page.tsx" */
7
+ relativePath: string;
8
+ }
9
+ /**
10
+ * Recursively scans an `app/` directory for `page.tsx`/`page.ts` files and
11
+ * converts them to React Router route paths.
12
+ *
13
+ * - `app/page.tsx` -> `/`
14
+ * - `app/about/page.tsx` -> `/about`
15
+ * - `app/remote/[id]/page.tsx` -> `/remote/:id`
16
+ * - Files starting with `_` are skipped.
17
+ */
18
+ export declare function scanPages(appDir: string): Promise<PageRoute[]>;
19
+ //# sourceMappingURL=scanner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,SAAS;IACxB,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,wEAAwE;IACxE,YAAY,EAAE,MAAM,CAAA;CACrB;AAED;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAKpE"}
@@ -0,0 +1,33 @@
1
+ export type CustomAppStylesheet =
2
+ /** No `app/globals.css` — the app ships no framework-managed stylesheet. */
3
+ {
4
+ readonly kind: "none";
5
+ }
6
+ /** Plain handwritten CSS — bundled as-is, exactly as before. */
7
+ | {
8
+ readonly kind: "static";
9
+ readonly path: string;
10
+ }
11
+ /** Tailwind source — compiled to `outputPath` before bundling. */
12
+ | {
13
+ readonly kind: "tailwind";
14
+ readonly sourcePath: string;
15
+ readonly outputPath: string;
16
+ };
17
+ export interface ResolveCustomAppStylesheetInput {
18
+ readonly appDir: string;
19
+ readonly generatedDir: string;
20
+ readonly rootDir: string;
21
+ }
22
+ /**
23
+ * Decides how `app/globals.css` participates in the build.
24
+ *
25
+ * `globals.css` is treated as Tailwind *source* when it uses Tailwind at-rules
26
+ * (`@source`, `@theme`, ...) or imports a package stylesheet such as
27
+ * `@sixb/ui/globals.css` — those need the Tailwind pipeline before they are
28
+ * shippable. Plain CSS keeps the existing pass-through behavior, so apps that
29
+ * never opted into Tailwind are unaffected.
30
+ */
31
+ export declare function resolveCustomAppStylesheet(input: ResolveCustomAppStylesheetInput): Promise<CustomAppStylesheet>;
32
+ export declare function usesTailwind(css: string): boolean;
33
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,mBAAmB;AAC7B,4EAA4E;AAC1E;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AAC3B,gEAAgE;GAC9D;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AACpD,kEAAkE;GAChE;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAA;AAE3F,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;;;GAQG;AACH,wBAAsB,0BAA0B,CAC9C,KAAK,EAAE,+BAA+B,GACrC,OAAO,CAAC,mBAAmB,CAAC,CAyB9B;AAKD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAuBjD"}
@@ -0,0 +1,62 @@
1
+ export interface TailwindCssCompilerOptions {
2
+ /** Tailwind source stylesheet. */
3
+ inputPath: string;
4
+ /** Compiled CSS output path. */
5
+ outputPath: string;
6
+ /**
7
+ * Working directory for the Tailwind CLI. Tailwind v4's automatic source
8
+ * detection scans from here, so keep it scoped to the directory that owns the
9
+ * styles (e.g. `app/`) — never a repo root that may contain `vendor/` or
10
+ * `node_modules/` siblings.
11
+ */
12
+ cwd?: string;
13
+ /**
14
+ * Directory whose dependency tree is used to resolve `@tailwindcss/cli`.
15
+ * Defaults to `cwd`. Pass the project root so the project's own Tailwind
16
+ * version wins.
17
+ */
18
+ resolveFrom?: string;
19
+ /** Prefix for error messages, e.g. `[SixbAtlas]`. */
20
+ label?: string;
21
+ /** Minify the compiled CSS. Off by default; bundlers usually minify later. */
22
+ minify?: boolean;
23
+ /** Debounce for `schedule()` rebuilds, in milliseconds. */
24
+ debounceMs?: number;
25
+ /**
26
+ * Upper bound on one Tailwind build, in milliseconds. Defaults to 60s.
27
+ *
28
+ * A bound on a hang, not a performance budget: a wedged CLI otherwise held `sixb dev` open
29
+ * forever, and `stop()` waited on it.
30
+ */
31
+ timeoutMs?: number;
32
+ /** Called when a `schedule()`d rebuild fails. Defaults to `console.error`. */
33
+ onError?: (error: Error) => void;
34
+ }
35
+ export interface TailwindCssCompiler {
36
+ /**
37
+ * Compiles the stylesheet. Builds are serialized: a call made while another
38
+ * build is running starts a fresh build after it, so the output always
39
+ * reflects the sources as of the call. Throws with a labeled, actionable
40
+ * error when the CLI is missing or compilation fails.
41
+ */
42
+ compile(): Promise<void>;
43
+ /**
44
+ * Debounced `compile()` for watch flows. Coalesces bursts of file events;
45
+ * errors go to `onError` instead of throwing.
46
+ */
47
+ schedule(): void;
48
+ /** Cancels pending rebuilds and waits for any in-flight build to settle. */
49
+ stop(): Promise<void>;
50
+ }
51
+ /**
52
+ * Resolves the Tailwind v4 CLI entry point from a directory's dependency tree.
53
+ * Returns null when `@tailwindcss/cli` is not installed there.
54
+ */
55
+ export declare function resolveTailwindCliEntry(resolveFrom: string): string | null;
56
+ /**
57
+ * Shared Tailwind v4 CSS build pipeline used by the built-in UI (Atlas) and
58
+ * custom apps. Owns CLI resolution, source-detection scoping,
59
+ * debounced/queued rebuilds, error formatting, and watch lifecycle cleanup.
60
+ */
61
+ export declare function createTailwindCssCompiler(options: TailwindCssCompilerOptions): TailwindCssCompiler;
62
+ //# sourceMappingURL=tailwind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind.d.ts","sourceRoot":"","sources":["../src/tailwind.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,0BAA0B;IACzC,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAA;IACjB,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAA;IAClB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,8EAA8E;IAC9E,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;CACjC;AAED,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACxB;;;OAGG;IACH,QAAQ,IAAI,IAAI,CAAA;IAChB,4EAA4E;IAC5E,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACtB;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAO1E;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,0BAA0B,GAClC,mBAAmB,CAuHrB"}
@@ -0,0 +1,5 @@
1
+ // Written by scripts/build-package.ts, and published on purpose.
2
+ // Bun applies the nearest tsconfig paths map to every import it resolves, node_modules
3
+ // included. An empty map here keeps a consumer's aliases from sending a module in this
4
+ // directory back into a second copy of its own source.
5
+ { "compilerOptions": { "paths": {} } }
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@sixb/app",
3
+ "version": "0.0.1",
4
+ "description": "Custom app toolkit for Sixb projects — route scanning, dev serving, and production builds",
5
+ "keywords": [
6
+ "sixb",
7
+ "bun",
8
+ "react",
9
+ "router"
10
+ ],
11
+ "homepage": "https://sixb.ai",
12
+ "bugs": {
13
+ "url": "https://github.com/sixb-ai/sixb/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/sixb-ai/sixb.git",
18
+ "directory": "packages/app"
19
+ },
20
+ "author": "Sixb contributors",
21
+ "type": "module",
22
+ "main": "./dist/index.js",
23
+ "types": "./dist/index.d.ts",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "bun": "./src/index.ts",
28
+ "import": "./dist/index.js",
29
+ "default": "./dist/index.js"
30
+ },
31
+ "./agents": {
32
+ "types": "./dist/agents.d.ts",
33
+ "bun": "./src/agents.ts",
34
+ "import": "./dist/agents.js",
35
+ "default": "./dist/agents.js"
36
+ }
37
+ },
38
+ "scripts": {
39
+ "build": "bun ../../scripts/build-package.ts",
40
+ "typecheck": "tsc --noEmit",
41
+ "prepack": "bun run build"
42
+ },
43
+ "dependencies": {
44
+ "@sixb/agent-ui": "0.0.1",
45
+ "@sixb/core": "0.0.1",
46
+ "@sixb/ui": "0.0.1",
47
+ "@tailwindcss/cli": "^4.2.2",
48
+ "tailwindcss": "^4.1.18"
49
+ },
50
+ "peerDependencies": {
51
+ "@tanstack/react-query": "^5.0.0",
52
+ "react": "^18.0.0 || ^19.0.0",
53
+ "react-dom": "^18.0.0 || ^19.0.0",
54
+ "react-router-dom": "^7.0.0"
55
+ },
56
+ "devDependencies": {
57
+ "@types/bun": "latest",
58
+ "@types/react": "^19.0.0",
59
+ "typescript": "^5.7.0"
60
+ },
61
+ "license": "MIT",
62
+ "engines": {
63
+ "bun": ">=1.3.0"
64
+ },
65
+ "publishConfig": {
66
+ "access": "public"
67
+ },
68
+ "files": [
69
+ "dist",
70
+ "src",
71
+ "README.md",
72
+ "LICENSE"
73
+ ]
74
+ }
package/src/agents.ts ADDED
@@ -0,0 +1,23 @@
1
+ import { AgentChatPage, type AgentChatPageProps } from "@sixb/agent-ui/react-router"
2
+ import { createElement } from "react"
3
+
4
+ export {
5
+ AgentContextProvider,
6
+ AgentPanel,
7
+ type AgentPanelProps,
8
+ useAgentContext,
9
+ } from "@sixb/agent-ui"
10
+
11
+ export { agentContext } from "@sixb/core/agents/context"
12
+
13
+ export type AgentsPageProps = Omit<AgentChatPageProps, "routeBase">
14
+
15
+ export default function AgentsPage({ className, ...props }: AgentsPageProps) {
16
+ return createElement(AgentChatPage, {
17
+ ...props,
18
+ routeBase: "/agents",
19
+ className: className
20
+ ? `h-dvh min-h-dvh max-h-dvh overflow-hidden ${className}`
21
+ : "h-dvh min-h-dvh max-h-dvh overflow-hidden",
22
+ })
23
+ }