@kubb/ui
Version:
User interface components and web dashboard for Kubb, providing a visual interface for managing and monitoring code generation.
1 lines • 9.94 kB
Source Map (JSON)
{"version":3,"file":"index.cjs","names":["z","__dirname","path","z","server: Server","Hono","OpenAPIHono","fs"],"sources":["../src/models/StatusSchema.ts","../package.json","../src/server.ts"],"sourcesContent":["import { z } from '@hono/zod-openapi'\n\nexport const statusSchema = z\n .object({\n name: z.string().optional(),\n percentages: z.record(z.string(), z.number()),\n executed: z.array(z.any()),\n })\n .openapi('Status')\n\nexport type StatusSchema = z.infer<typeof statusSchema>\n","{\n \"name\": \"@kubb/ui\",\n \"version\": \"4.0.0\",\n \"description\": \"User interface components and web dashboard for Kubb, providing a visual interface for managing and monitoring code generation.\",\n \"keywords\": [\n \"ui\",\n \"dashboard\",\n \"web-interface\",\n \"react\",\n \"tailwindcss\",\n \"hono\",\n \"typescript\",\n \"kubb\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/kubb-labs/kubb.git\",\n \"directory\": \"packages/ui\"\n },\n \"license\": \"MIT\",\n \"author\": \"stijnvanhulle\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.cts\",\n \"typesVersions\": {\n \"*\": {}\n },\n \"files\": [\n \"src\",\n \"static\",\n \"dist\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsdown && vite build\",\n \"clean\": \"npx rimraf ./dist\",\n \"lint\": \"bun biome lint .\",\n \"lint:fix\": \"bun biome lint --fix --unsafe .\",\n \"preview\": \"vite preview\",\n \"release\": \"pnpm publish --no-git-check\",\n \"release:canary\": \"bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check\",\n \"start\": \"vite & tsdown --watch\",\n \"test\": \"vitest --passWithNoTests\",\n \"typecheck\": \"tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false\"\n },\n \"dependencies\": {\n \"@hono/node-server\": \"^1.19.3\",\n \"@hono/zod-openapi\": \"0.19.2\",\n \"hono\": \"^4.9.8\",\n \"zod\": \"^3.25.76\"\n },\n \"devDependencies\": {\n \"@heroui/react\": \"^2.8.4\",\n \"@heroui/theme\": \"^2.4.22\",\n \"@heroui/use-theme\": \"^2.1.10\",\n \"@kubb/config-ts\": \"workspace:*\",\n \"@react-aria/visually-hidden\": \"^3.8.27\",\n \"@react-types/shared\": \"^3.32.0\",\n \"@tailwindcss/postcss\": \"^4.1.13\",\n \"@tanstack/react-query\": \"^5.89.0\",\n \"@types/node\": \"catalog:\",\n \"@types/react\": \"catalog:\",\n \"@types/react-dom\": \"catalog:\",\n \"@vitejs/plugin-react\": \"^5.0.3\",\n \"autoprefixer\": \"^10.4.21\",\n \"clsx\": \"^2.1.1\",\n \"framer-motion\": \"^12.23.15\",\n \"postcss\": \"^8.5.6\",\n \"react\": \"catalog:\",\n \"react-dom\": \"catalog:\",\n \"react-router-dom\": \"^7.9.1\",\n \"tailwind-variants\": \"^2.1.0\",\n \"tailwindcss\": \"^4.1.13\",\n \"tsdown\": \"catalog:\",\n \"typescript\": \"catalog:\",\n \"vite\": \"^7.1.6\",\n \"vite-tsconfig-paths\": \"^5.1.4\"\n },\n \"engines\": {\n \"node\": \">=20\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org/\"\n }\n}\n","import { OpenAPIHono, createRoute } from '@hono/zod-openapi'\nimport { serve } from '@hono/node-server'\nimport { cors } from 'hono/cors'\nimport type { AddressInfo, Server } from 'node:net'\nimport fs from 'node:fs'\nimport { Hono } from 'hono'\nimport { createServer } from 'node:http2'\nimport { z } from '@hono/zod-openapi'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { statusSchema } from './models/StatusSchema.ts'\n\nimport { version } from '../package.json'\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url))\nconst distPath = path.join(__dirname, '../static')\n\nconst statusRoute = createRoute({\n method: 'get',\n path: '/status',\n response: {},\n responses: {\n 200: {\n content: {\n 'application/json': {\n schema: statusSchema,\n },\n },\n description: 'Retrieve the status',\n },\n },\n})\n\nconst restartRoute = createRoute({\n method: 'post',\n path: '/restart',\n response: {},\n responses: {\n 200: {\n content: {\n 'application/json': {\n schema: z.object({}),\n },\n },\n description: 'Restart creation',\n },\n },\n})\n\nconst stopRoute = createRoute({\n method: 'post',\n path: '/stop',\n response: {},\n responses: {\n 200: {\n content: {\n 'application/json': {\n schema: z.object({}),\n },\n },\n description: 'Stop creation',\n },\n },\n})\n\ntype Meta = {\n name?: string\n percentages: Record<string, number>\n}\n\ntype Options = {\n getMeta: () => Meta\n restart: () => void\n stop: () => void\n}\n\nfunction findOpenPort(preferredPort: number): Promise<number> {\n return new Promise((resolve, reject) => {\n const server: Server = createServer()\n\n server.listen(preferredPort, () => {\n server.close(() => resolve(preferredPort)) // If port is free, use it\n })\n\n server.on('error', async (err: any) => {\n if (err.code === 'EADDRINUSE') {\n resolve(findOpenPort(preferredPort + 1)) // Try next port if in use\n } else {\n reject(err)\n }\n })\n })\n}\n\nexport async function startServer(options: Options, listeningListener?: (info: AddressInfo) => void) {\n const { stop, restart, getMeta } = options\n\n const app = new Hono()\n const api = new OpenAPIHono()\n\n api.use('*', cors())\n\n api.openapi(statusRoute, (c) => {\n const meta = getMeta()\n\n return c.json(\n {\n name: meta.name,\n percentages: meta.percentages,\n executed: [],\n },\n 200,\n )\n })\n\n api.openapi(stopRoute, (c) => {\n stop()\n\n return c.json({}, 200)\n })\n\n api.openapi(restartRoute, (c) => {\n restart()\n\n return c.json({}, 200)\n })\n\n api.doc('/doc', {\n openapi: '3.0.0',\n info: {\n version: version,\n title: 'Kubb ui',\n },\n })\n\n app.route('/api', api)\n\n // ✅ Serve static files manually (alternative to serveStatic)\n app.get('/*', async (c) => {\n const filePath = path.join(distPath, c.req.path) // Get requested file\n\n // If the file exists, serve it\n if (fs.existsSync(filePath) && fs.statSync(filePath).isFile()) {\n return new Response(fs.readFileSync(filePath) as unknown as ReadableStream, {\n headers: { 'Content-Type': getMimeType(filePath) },\n })\n }\n\n // Otherwise, return \"index.html\" for SPA routing\n return new Response(fs.readFileSync(path.join(distPath, 'index.html')) as unknown as ReadableStream, {\n headers: { 'Content-Type': 'text/html' },\n })\n })\n\n // ✅ MIME type helper function\n const getMimeType = (filePath: string) => {\n const ext = path.extname(filePath).toLowerCase()\n const mimeTypes: Record<string, string> = {\n '.html': 'text/html',\n '.js': 'text/javascript',\n '.css': 'text/css',\n '.json': 'application/json',\n '.png': 'image/png',\n '.jpg': 'image/jpeg',\n '.gif': 'image/gif',\n '.svg': 'image/svg+xml',\n '.ico': 'image/x-icon',\n }\n return mimeTypes[ext] || 'application/octet-stream'\n }\n\n const port = await findOpenPort(5822)\n\n return serve(\n {\n fetch: app.fetch,\n port,\n },\n listeningListener,\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAa,eAAeA,qBACzB,OAAO;CACN,MAAMA,qBAAE,QAAQ,CAAC,UAAU;CAC3B,aAAaA,qBAAE,OAAOA,qBAAE,QAAQ,EAAEA,qBAAE,QAAQ,CAAC;CAC7C,UAAUA,qBAAE,MAAMA,qBAAE,KAAK,CAAC;CAC3B,CAAC,CACD,QAAQ,SAAS;;;;cCNP;;;;ACYb,MAAMC,cAAYC,kBAAK,kFAAsC,CAAC;AAC9D,MAAM,WAAWA,kBAAK,KAAKD,aAAW,YAAY;AAElD,MAAM,kDAA0B;CAC9B,QAAQ;CACR,MAAM;CACN,UAAU,EAAE;CACZ,WAAW,EACT,KAAK;EACH,SAAS,EACP,oBAAoB,EAClB,QAAQ,cACT,EACF;EACD,aAAa;EACd,EACF;CACF,CAAC;AAEF,MAAM,mDAA2B;CAC/B,QAAQ;CACR,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