alepha 0.13.1 → 0.13.2
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/README.md +1 -1
- package/dist/api-files/index.d.ts +28 -91
- package/dist/api-files/index.js +10 -755
- package/dist/api-files/index.js.map +1 -1
- package/dist/api-jobs/index.d.ts +46 -46
- package/dist/api-jobs/index.js +13 -13
- package/dist/api-jobs/index.js.map +1 -1
- package/dist/api-notifications/index.d.ts +129 -146
- package/dist/api-notifications/index.js +17 -39
- package/dist/api-notifications/index.js.map +1 -1
- package/dist/api-parameters/index.d.ts +21 -22
- package/dist/api-parameters/index.js +22 -22
- package/dist/api-parameters/index.js.map +1 -1
- package/dist/api-users/index.d.ts +223 -2000
- package/dist/api-users/index.js +914 -4787
- package/dist/api-users/index.js.map +1 -1
- package/dist/api-verifications/index.d.ts +96 -96
- package/dist/batch/index.d.ts +13 -13
- package/dist/batch/index.js +8 -8
- package/dist/batch/index.js.map +1 -1
- package/dist/bucket/index.d.ts +14 -14
- package/dist/bucket/index.js +12 -12
- package/dist/bucket/index.js.map +1 -1
- package/dist/cache/index.d.ts +11 -11
- package/dist/cache/index.js +9 -9
- package/dist/cache/index.js.map +1 -1
- package/dist/cli/index.d.ts +28 -26
- package/dist/cli/index.js +50 -13
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +19 -19
- package/dist/command/index.js +25 -25
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +218 -218
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +232 -232
- package/dist/core/index.js +218 -218
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +2113 -0
- package/dist/core/index.native.js.map +1 -0
- package/dist/datetime/index.d.ts +9 -9
- package/dist/datetime/index.js +7 -7
- package/dist/datetime/index.js.map +1 -1
- package/dist/email/index.d.ts +16 -16
- package/dist/email/index.js +9 -9
- package/dist/email/index.js.map +1 -1
- package/dist/file/index.js +1 -1
- package/dist/file/index.js.map +1 -1
- package/dist/lock/index.d.ts +9 -9
- package/dist/lock/index.js +8 -8
- package/dist/lock/index.js.map +1 -1
- package/dist/lock-redis/index.js +3 -66
- package/dist/lock-redis/index.js.map +1 -1
- package/dist/logger/index.d.ts +5 -5
- package/dist/logger/index.js +8 -8
- package/dist/logger/index.js.map +1 -1
- package/dist/orm/index.browser.js +114 -114
- package/dist/orm/index.browser.js.map +1 -1
- package/dist/orm/index.d.ts +218 -218
- package/dist/orm/index.js +46 -46
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/index.d.ts +29 -29
- package/dist/queue/index.js +20 -20
- package/dist/queue/index.js.map +1 -1
- package/dist/queue-redis/index.d.ts +2 -2
- package/dist/redis/index.d.ts +10 -10
- package/dist/retry/index.d.ts +19 -19
- package/dist/retry/index.js +7 -7
- package/dist/retry/index.js.map +1 -1
- package/dist/scheduler/index.d.ts +16 -16
- package/dist/scheduler/index.js +9 -9
- package/dist/scheduler/index.js.map +1 -1
- package/dist/security/index.d.ts +80 -80
- package/dist/security/index.js +32 -32
- package/dist/security/index.js.map +1 -1
- package/dist/server/index.browser.js +1 -1
- package/dist/server/index.browser.js.map +1 -1
- package/dist/server/index.d.ts +101 -101
- package/dist/server/index.js +16 -16
- package/dist/server/index.js.map +1 -1
- package/dist/server-auth/index.browser.js +4 -982
- package/dist/server-auth/index.browser.js.map +1 -1
- package/dist/server-auth/index.d.ts +204 -785
- package/dist/server-auth/index.js +47 -1239
- package/dist/server-auth/index.js.map +1 -1
- package/dist/server-cache/index.d.ts +10 -10
- package/dist/server-cache/index.js +2 -2
- package/dist/server-cache/index.js.map +1 -1
- package/dist/server-compress/index.d.ts +4 -4
- package/dist/server-compress/index.js +1 -1
- package/dist/server-compress/index.js.map +1 -1
- package/dist/server-cookies/index.browser.js +8 -8
- package/dist/server-cookies/index.browser.js.map +1 -1
- package/dist/server-cookies/index.d.ts +17 -17
- package/dist/server-cookies/index.js +10 -10
- package/dist/server-cookies/index.js.map +1 -1
- package/dist/server-cors/index.d.ts +17 -17
- package/dist/server-cors/index.js +9 -9
- package/dist/server-cors/index.js.map +1 -1
- package/dist/server-health/index.d.ts +19 -19
- package/dist/server-helmet/index.d.ts +1 -1
- package/dist/server-links/index.browser.js +12 -12
- package/dist/server-links/index.browser.js.map +1 -1
- package/dist/server-links/index.d.ts +59 -251
- package/dist/server-links/index.js +23 -502
- package/dist/server-links/index.js.map +1 -1
- package/dist/server-metrics/index.d.ts +4 -4
- package/dist/server-multipart/index.d.ts +2 -2
- package/dist/server-proxy/index.d.ts +12 -12
- package/dist/server-proxy/index.js +10 -10
- package/dist/server-proxy/index.js.map +1 -1
- package/dist/server-rate-limit/index.d.ts +22 -22
- package/dist/server-rate-limit/index.js +12 -12
- package/dist/server-rate-limit/index.js.map +1 -1
- package/dist/server-security/index.d.ts +22 -22
- package/dist/server-security/index.js +15 -15
- package/dist/server-security/index.js.map +1 -1
- package/dist/server-static/index.d.ts +14 -14
- package/dist/server-static/index.js +8 -8
- package/dist/server-static/index.js.map +1 -1
- package/dist/server-swagger/index.d.ts +25 -184
- package/dist/server-swagger/index.js +21 -724
- package/dist/server-swagger/index.js.map +1 -1
- package/dist/sms/index.d.ts +14 -14
- package/dist/sms/index.js +9 -9
- package/dist/sms/index.js.map +1 -1
- package/dist/thread/index.d.ts +11 -11
- package/dist/thread/index.js +17 -17
- package/dist/thread/index.js.map +1 -1
- package/dist/topic/index.d.ts +26 -26
- package/dist/topic/index.js +16 -16
- package/dist/topic/index.js.map +1 -1
- package/dist/topic-redis/index.d.ts +1 -1
- package/dist/vite/index.d.ts +3 -3
- package/dist/vite/index.js +8 -8
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.browser.js +11 -11
- package/dist/websocket/index.browser.js.map +1 -1
- package/dist/websocket/index.d.ts +58 -58
- package/dist/websocket/index.js +13 -13
- package/dist/websocket/index.js.map +1 -1
- package/package.json +113 -52
- package/src/api-files/services/FileService.ts +5 -7
- package/src/api-jobs/index.ts +1 -1
- package/src/api-jobs/{descriptors → primitives}/$job.ts +8 -8
- package/src/api-jobs/providers/JobProvider.ts +9 -9
- package/src/api-jobs/services/JobService.ts +5 -5
- package/src/api-notifications/index.ts +5 -15
- package/src/api-notifications/{descriptors → primitives}/$notification.ts +10 -10
- package/src/api-notifications/services/NotificationSenderService.ts +3 -3
- package/src/api-parameters/index.ts +1 -1
- package/src/api-parameters/{descriptors → primitives}/$config.ts +7 -12
- package/src/api-users/index.ts +1 -1
- package/src/api-users/{descriptors → primitives}/$userRealm.ts +8 -8
- package/src/api-users/providers/UserRealmProvider.ts +1 -1
- package/src/batch/index.ts +3 -3
- package/src/batch/{descriptors → primitives}/$batch.ts +13 -16
- package/src/bucket/index.ts +8 -8
- package/src/bucket/{descriptors → primitives}/$bucket.ts +8 -8
- package/src/bucket/providers/LocalFileStorageProvider.ts +3 -3
- package/src/cache/index.ts +4 -4
- package/src/cache/{descriptors → primitives}/$cache.ts +15 -15
- package/src/cli/apps/AlephaPackageBuilderCli.ts +24 -2
- package/src/cli/commands/DrizzleCommands.ts +6 -6
- package/src/cli/commands/VerifyCommands.ts +1 -1
- package/src/cli/commands/ViteCommands.ts +6 -1
- package/src/cli/services/ProjectUtils.ts +34 -3
- package/src/command/index.ts +5 -5
- package/src/command/{descriptors → primitives}/$command.ts +9 -12
- package/src/command/providers/CliProvider.ts +10 -10
- package/src/core/Alepha.ts +30 -33
- package/src/core/constants/KIND.ts +1 -1
- package/src/core/constants/OPTIONS.ts +1 -1
- package/src/core/helpers/{descriptor.ts → primitive.ts} +18 -18
- package/src/core/helpers/ref.ts +1 -1
- package/src/core/index.shared.ts +8 -8
- package/src/core/{descriptors → primitives}/$context.ts +5 -5
- package/src/core/{descriptors → primitives}/$hook.ts +4 -4
- package/src/core/{descriptors → primitives}/$inject.ts +2 -2
- package/src/core/{descriptors → primitives}/$module.ts +9 -9
- package/src/core/{descriptors → primitives}/$use.ts +2 -2
- package/src/core/providers/CodecManager.ts +1 -1
- package/src/core/providers/JsonSchemaCodec.ts +1 -1
- package/src/core/providers/StateManager.ts +2 -2
- package/src/datetime/index.ts +3 -3
- package/src/datetime/{descriptors → primitives}/$interval.ts +6 -6
- package/src/email/index.ts +4 -4
- package/src/email/{descriptors → primitives}/$email.ts +8 -8
- package/src/file/index.ts +1 -1
- package/src/lock/index.ts +3 -3
- package/src/lock/{descriptors → primitives}/$lock.ts +10 -10
- package/src/logger/index.ts +8 -8
- package/src/logger/{descriptors → primitives}/$logger.ts +2 -2
- package/src/logger/services/Logger.ts +1 -1
- package/src/orm/constants/PG_SYMBOLS.ts +2 -2
- package/src/orm/index.browser.ts +2 -2
- package/src/orm/index.ts +8 -8
- package/src/orm/{descriptors → primitives}/$entity.ts +11 -11
- package/src/orm/{descriptors → primitives}/$repository.ts +2 -2
- package/src/orm/{descriptors → primitives}/$sequence.ts +8 -8
- package/src/orm/{descriptors → primitives}/$transaction.ts +4 -4
- package/src/orm/providers/PostgresTypeProvider.ts +3 -3
- package/src/orm/providers/RepositoryProvider.ts +4 -4
- package/src/orm/providers/drivers/DatabaseProvider.ts +7 -7
- package/src/orm/services/ModelBuilder.ts +9 -9
- package/src/orm/services/PgRelationManager.ts +2 -2
- package/src/orm/services/PostgresModelBuilder.ts +5 -5
- package/src/orm/services/Repository.ts +7 -7
- package/src/orm/services/SqliteModelBuilder.ts +5 -5
- package/src/queue/index.ts +7 -7
- package/src/queue/{descriptors → primitives}/$consumer.ts +15 -15
- package/src/queue/{descriptors → primitives}/$queue.ts +12 -12
- package/src/queue/providers/WorkerProvider.ts +7 -7
- package/src/retry/index.ts +3 -3
- package/src/retry/{descriptors → primitives}/$retry.ts +14 -14
- package/src/scheduler/index.ts +3 -3
- package/src/scheduler/{descriptors → primitives}/$scheduler.ts +9 -9
- package/src/scheduler/providers/CronProvider.ts +1 -1
- package/src/security/index.ts +9 -9
- package/src/security/{descriptors → primitives}/$permission.ts +7 -7
- package/src/security/{descriptors → primitives}/$realm.ts +6 -12
- package/src/security/{descriptors → primitives}/$role.ts +12 -12
- package/src/security/{descriptors → primitives}/$serviceAccount.ts +8 -8
- package/src/server/index.browser.ts +1 -1
- package/src/server/index.ts +14 -14
- package/src/server/{descriptors → primitives}/$action.ts +13 -13
- package/src/server/{descriptors → primitives}/$route.ts +9 -9
- package/src/server/providers/NodeHttpServerProvider.ts +1 -1
- package/src/server/services/HttpClient.ts +1 -1
- package/src/server-auth/index.browser.ts +1 -1
- package/src/server-auth/index.ts +6 -6
- package/src/server-auth/{descriptors → primitives}/$auth.ts +10 -10
- package/src/server-auth/{descriptors → primitives}/$authCredentials.ts +4 -4
- package/src/server-auth/{descriptors → primitives}/$authGithub.ts +4 -4
- package/src/server-auth/{descriptors → primitives}/$authGoogle.ts +4 -4
- package/src/server-auth/providers/ServerAuthProvider.ts +4 -4
- package/src/server-cache/providers/ServerCacheProvider.ts +7 -7
- package/src/server-compress/providers/ServerCompressProvider.ts +3 -3
- package/src/server-cookies/index.browser.ts +2 -2
- package/src/server-cookies/index.ts +5 -5
- package/src/server-cookies/{descriptors → primitives}/$cookie.browser.ts +12 -12
- package/src/server-cookies/{descriptors → primitives}/$cookie.ts +13 -13
- package/src/server-cookies/providers/ServerCookiesProvider.ts +4 -4
- package/src/server-cookies/services/CookieParser.ts +1 -1
- package/src/server-cors/index.ts +3 -3
- package/src/server-cors/{descriptors → primitives}/$cors.ts +11 -13
- package/src/server-cors/providers/ServerCorsProvider.ts +5 -5
- package/src/server-links/index.browser.ts +5 -5
- package/src/server-links/index.ts +9 -9
- package/src/server-links/{descriptors → primitives}/$remote.ts +11 -11
- package/src/server-links/providers/LinkProvider.ts +7 -7
- package/src/server-links/providers/{RemoteDescriptorProvider.ts → RemotePrimitiveProvider.ts} +6 -6
- package/src/server-links/providers/ServerLinksProvider.ts +3 -3
- package/src/server-proxy/index.ts +3 -3
- package/src/server-proxy/{descriptors → primitives}/$proxy.ts +8 -8
- package/src/server-proxy/providers/ServerProxyProvider.ts +4 -4
- package/src/server-rate-limit/index.ts +6 -6
- package/src/server-rate-limit/{descriptors → primitives}/$rateLimit.ts +13 -13
- package/src/server-rate-limit/providers/ServerRateLimitProvider.ts +5 -5
- package/src/server-security/index.ts +3 -3
- package/src/server-security/{descriptors → primitives}/$basicAuth.ts +13 -13
- package/src/server-security/providers/ServerBasicAuthProvider.ts +5 -5
- package/src/server-security/providers/ServerSecurityProvider.ts +4 -4
- package/src/server-static/index.ts +3 -3
- package/src/server-static/{descriptors → primitives}/$serve.ts +8 -10
- package/src/server-static/providers/ServerStaticProvider.ts +6 -6
- package/src/server-swagger/index.ts +5 -5
- package/src/server-swagger/{descriptors → primitives}/$swagger.ts +9 -9
- package/src/server-swagger/providers/ServerSwaggerProvider.ts +11 -10
- package/src/sms/index.ts +4 -4
- package/src/sms/{descriptors → primitives}/$sms.ts +8 -8
- package/src/thread/index.ts +3 -3
- package/src/thread/{descriptors → primitives}/$thread.ts +13 -13
- package/src/thread/providers/ThreadProvider.ts +7 -9
- package/src/topic/index.ts +5 -5
- package/src/topic/{descriptors → primitives}/$subscriber.ts +14 -14
- package/src/topic/{descriptors → primitives}/$topic.ts +10 -10
- package/src/topic/providers/TopicProvider.ts +4 -4
- package/src/vite/tasks/copyAssets.ts +1 -1
- package/src/vite/tasks/generateSitemap.ts +3 -3
- package/src/vite/tasks/prerenderPages.ts +2 -2
- package/src/vite/tasks/runAlepha.ts +2 -2
- package/src/websocket/index.browser.ts +3 -3
- package/src/websocket/index.shared.ts +2 -2
- package/src/websocket/index.ts +4 -4
- package/src/websocket/interfaces/WebSocketInterfaces.ts +3 -3
- package/src/websocket/{descriptors → primitives}/$channel.ts +10 -10
- package/src/websocket/{descriptors → primitives}/$websocket.ts +8 -8
- package/src/websocket/providers/NodeWebSocketServerProvider.ts +7 -7
- package/src/websocket/providers/WebSocketServerProvider.ts +3 -3
- package/src/websocket/services/WebSocketClient.ts +5 -5
- package/src/api-notifications/providers/MemorySmsProvider.ts +0 -20
- package/src/api-notifications/providers/SmsProvider.ts +0 -8
- /package/src/core/{descriptors → primitives}/$atom.ts +0 -0
- /package/src/core/{descriptors → primitives}/$env.ts +0 -0
- /package/src/server-auth/{descriptors → primitives}/$authApple.ts +0 -0
- /package/src/server-links/{descriptors → primitives}/$client.ts +0 -0
package/dist/vite/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["path","match: RegExpExecArray | null","entries: BufferedLogEntry[]","path","_error","gzipCb","brotliCompress","brotliCompressCb","compressionTasks: Promise<void>[]","fs","gzip","plugins: any[]","compress: ViteCompressOptions | undefined","viteAnalyzer","viteBuildClientConfig: UserConfig","deps: Record<string, string>","plugins: any[]","viteAnalyzer","viteBuildServerConfig: UserConfig","result: vite.Rollup.RollupOutput | vite.Rollup.RollupOutput[]","externals: string[]","WARNING_COMMENT","urls: string[]","path","it: any","path","rootConfig: UserConfig","plugins: (Plugin | Promise<Plugin>)[] & { [OPTIONS]?: any }"],"sources":["../../src/vite/helpers/boot.ts","../../src/vite/helpers/createBufferedLogger.ts","../../src/vite/helpers/fileExists.ts","../../src/vite/helpers/importVite.ts","../../src/vite/plugins/viteCompress.ts","../../src/vite/tasks/buildClient.ts","../../src/vite/tasks/generateExternals.ts","../../src/vite/tasks/buildServer.ts","../../src/vite/helpers/importAlepha.ts","../../src/vite/tasks/copyAssets.ts","../../src/vite/tasks/generateCloudflare.ts","../../src/vite/tasks/generateDocker.ts","../../src/vite/tasks/generateSitemap.ts","../../src/vite/tasks/generateVercel.ts","../../src/vite/tasks/prerenderPages.ts","../../src/vite/tasks/runAlepha.ts","../../src/vite/plugins/viteAlephaBuild.ts","../../src/vite/plugins/viteAlephaDev.ts","../../src/vite/plugins/viteAlepha.ts","../../src/vite/index.ts"],"sourcesContent":["import { access, readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { AlephaError } from \"alepha\";\n\n/**\n * Remember:\n * At first, functions was inside alepha/vite package, but it's now used in alepha too.\n * For avoiding cli -> vite, all code moved here.\n */\n\n/**\n * Find browser/client entry file path.\n */\nconst getClientEntry = async (\n root = process.cwd(),\n): Promise<string | undefined> => {\n const indexPath = join(root, \"index.html\");\n try {\n const html = await readFile(indexPath, \"utf8\");\n return extractFirstModuleScriptSrc(html).replace(/\\\\/g, \"/\");\n } catch {\n return undefined;\n }\n};\n\n/**\n * Find server entry file path.\n */\nconst getServerEntry = async (\n root = process.cwd(),\n explicitEntry?: string,\n): Promise<string> => {\n if (explicitEntry) {\n const explicitPath = join(root, explicitEntry);\n try {\n await access(explicitPath);\n return explicitPath;\n } catch {\n throw new AlephaError(\n `Explicit server entry file \"${explicitEntry}\" not found.`,\n );\n }\n }\n\n const maybeEntry = [\n \"src/main.server.ts\",\n \"src/server-entry.ts\",\n \"src/main.server.tsx\",\n \"src/server-entry.tsx\",\n \"src/main.ts\",\n \"src/main.tsx\",\n ];\n\n for (const entry of maybeEntry) {\n try {\n const path = join(root, entry).replace(/\\\\/g, \"/\");\n await access(path);\n return path;\n } catch {\n // continue to next entry\n }\n }\n\n const clientEntry = await getClientEntry(root);\n if (clientEntry) {\n return clientEntry;\n }\n\n throw new AlephaError(\n `Could not find a server entry file. List of supported entry file: ${maybeEntry.join(\", \")}`,\n );\n};\n\n/**\n * Extract first module script src from HTML.\n */\nfunction extractFirstModuleScriptSrc(html: string): string {\n const scriptRegex = /<script\\b[^>]*>[\\s\\S]*?<\\/script>/gi;\n let match: RegExpExecArray | null = scriptRegex.exec(html);\n\n while (match) {\n const tag = match[0];\n\n // Check for type=\"module\"\n if (/type=[\"']module[\"']/i.test(tag)) {\n // Extract the src value\n const srcMatch = tag.match(/\\bsrc=[\"']([^\"']+)[\"']/i);\n const entry = srcMatch?.[1];\n if (entry) {\n if (entry.startsWith(\"/\")) {\n return entry.substring(1); // Remove leading slash\n }\n return entry;\n }\n }\n\n match = scriptRegex.exec(html);\n }\n\n throw new AlephaError(`No module script found in the provided HTML.`);\n}\n\nexport const boot = {\n getClientEntry,\n getServerEntry,\n};\n","import type { Logger } from \"vite\";\n\ninterface BufferedLogEntry {\n level: \"info\" | \"warn\" | \"error\";\n msg: string;\n timestamp: Date;\n}\n\nexport interface BufferedLogger extends Logger {\n /**\n * Flush all buffered log messages to console.\n * Call this on build failure to show what happened.\n */\n flush(): void;\n\n /**\n * Get all buffered log entries.\n */\n getEntries(): BufferedLogEntry[];\n\n /**\n * Clear all buffered entries without printing.\n */\n clear(): void;\n}\n\n/**\n * Creates a Vite logger that buffers all messages instead of printing them.\n * Useful for silent builds that only show output on failure.\n *\n * @example\n * ```ts\n * const logger = createBufferedLogger();\n * try {\n * await viteBuild({ customLogger: logger, logLevel: 'info' });\n * } catch (error) {\n * logger.flush(); // Print all buffered logs\n * throw error;\n * }\n * ```\n */\nexport function createBufferedLogger(): BufferedLogger {\n const entries: BufferedLogEntry[] = [];\n const loggedErrors = new WeakSet<Error>();\n const warnedMessages = new Set<string>();\n let hasWarned = false;\n\n const logger: BufferedLogger = {\n get hasWarned() {\n return hasWarned;\n },\n\n info(msg: string) {\n entries.push({ level: \"info\", msg, timestamp: new Date() });\n },\n\n warn(msg: string) {\n hasWarned = true;\n entries.push({ level: \"warn\", msg, timestamp: new Date() });\n },\n\n warnOnce(msg: string) {\n if (warnedMessages.has(msg)) {\n return;\n }\n warnedMessages.add(msg);\n hasWarned = true;\n entries.push({ level: \"warn\", msg, timestamp: new Date() });\n },\n\n error(msg: string, options?: { error?: Error | null }) {\n if (options?.error) {\n loggedErrors.add(options.error);\n }\n entries.push({ level: \"error\", msg, timestamp: new Date() });\n },\n\n clearScreen() {\n // No-op in buffered mode - we don't clear anything\n },\n\n hasErrorLogged(error: Error): boolean {\n return loggedErrors.has(error);\n },\n\n flush() {\n for (const entry of entries) {\n const prefix =\n entry.level === \"error\"\n ? \"\\x1b[31m✖\\x1b[0m\"\n : entry.level === \"warn\"\n ? \"\\x1b[33m⚠\\x1b[0m\"\n : \"\\x1b[36mℹ\\x1b[0m\";\n console.log(`${prefix} ${entry.msg}`);\n }\n },\n\n getEntries() {\n return [...entries];\n },\n\n clear() {\n entries.length = 0;\n warnedMessages.clear();\n hasWarned = false;\n },\n };\n\n return logger;\n}\n","import { access } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nexport const fileExists = async (path: string): Promise<boolean> => {\n return await access(join(process.cwd(), path))\n .then(() => true)\n .catch(() => false);\n};\n","import { createRequire } from \"node:module\";\nimport type * as vite from \"vite\";\n\nexport const importVite = async (): Promise<typeof vite> => {\n try {\n return createRequire(import.meta.url)(\"rolldown-vite\");\n } catch (_error) {\n try {\n return createRequire(import.meta.url)(\"vite\");\n } catch (_error) {\n throw new Error(\n \"Vite is not installed. Please install it with `npm install vite`.\",\n );\n }\n }\n};\n","import { promises as fs } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { promisify } from \"node:util\";\nimport {\n type BrotliOptions,\n brotliCompress as brotliCompressCb,\n gzip as gzipCb,\n type ZlibOptions,\n} from \"node:zlib\";\nimport type { Plugin } from \"vite\";\n\nconst gzipCompress = promisify(gzipCb);\nconst brotliCompress = promisify(brotliCompressCb);\n\nexport interface ViteCompressOptions {\n /**\n * If true, the plugin will not compress the files.\n *\n * @default false\n */\n disabled?: boolean;\n\n /**\n * If true, the plugin will compress the files using brotli.\n * Can also be an object with brotli options.\n *\n * @default true\n */\n brotli?: boolean | BrotliOptions;\n\n /**\n * If true, the plugin will compress the files using gzip.\n * Can also be an object with gzip options.\n *\n * @default true\n */\n gzip?: boolean | ZlibOptions;\n\n /**\n * A filter to determine which files to compress.\n * Can be a RegExp or a function that returns true for files to compress.\n *\n * @default /\\.(js|mjs|cjs|css|wasm|svg|html)$/\n */\n filter?: RegExp | ((fileName: string) => boolean);\n}\n\nexport function viteCompress(options: ViteCompressOptions = {}): Plugin {\n const { disabled = false, filter = /\\.(js|mjs|cjs|css|wasm|svg)$/ } = options;\n\n return {\n name: \"compress\",\n apply: \"build\",\n async writeBundle(outputOptions, bundle) {\n if (disabled) {\n return;\n }\n\n const now = Date.now();\n\n const outputDir = outputOptions.dir || resolve(process.cwd(), \"dist\");\n\n const files = Object.keys(bundle)\n .filter((fileName) => {\n // [feature]: filter\n if (typeof filter === \"function\") {\n return filter(fileName);\n }\n return filter.test(fileName);\n })\n .map((fileName) => ({\n fileName,\n filePath: join(outputDir, fileName),\n }));\n\n // Compress each file\n const compressionTasks: Promise<void>[] = [];\n\n for (const { filePath } of files) {\n compressionTasks.push(compressFile(options, filePath));\n }\n\n // Wait for all compression tasks to complete\n await Promise.all(compressionTasks);\n\n this.info(\n `Compressed ${files.length} file${files.length > 1 ? \"s\" : \"\"} in ${Date.now() - now}ms.`,\n );\n },\n };\n}\n\nexport async function compressFile(\n options: ViteCompressOptions = {},\n filePath: string,\n) {\n const { brotli = true, gzip = true } = options;\n\n const compressionTasks: Promise<void>[] = [];\n\n const fileContentPromise = fs.readFile(filePath);\n\n if (gzip) {\n const gzipOptions =\n typeof gzip === \"object\"\n ? gzip\n : {\n level: 9, // default gzip compression level\n };\n compressionTasks.push(\n fileContentPromise.then(async (content) => {\n const compressed = await gzipCompress(content, gzipOptions);\n await fs.writeFile(`${filePath}.gz`, compressed);\n }),\n );\n }\n\n if (brotli) {\n const brotliOptions = typeof brotli === \"object\" ? brotli : {};\n compressionTasks.push(\n fileContentPromise.then(async (content) => {\n const compressed = await brotliCompress(content, brotliOptions);\n await fs.writeFile(`${filePath}.br`, compressed);\n }),\n );\n }\n\n await Promise.all(compressionTasks);\n}\n","import type { UserConfig } from \"vite\";\nimport { analyzer as viteAnalyzer } from \"vite-bundle-analyzer\";\nimport { createBufferedLogger } from \"../helpers/createBufferedLogger.ts\";\nimport { importVite } from \"../helpers/importVite.ts\";\nimport {\n type ViteCompressOptions,\n viteCompress,\n} from \"../plugins/viteCompress.ts\";\n\nexport interface BuildClientOptions {\n /**\n * Output directory for client build.\n */\n dist: string;\n\n /**\n * If true, precompress assets using gzip and brotli compression.\n *\n * @default false\n */\n precompress?: ViteCompressOptions | boolean;\n\n /**\n * If true, prerender all static routes found in the $pages directory.\n *\n * @default false\n */\n prerender?: boolean;\n\n /**\n * Build a sitemap.xml file based on the $pages routes.\n */\n sitemap?: {\n hostname: string;\n };\n\n /**\n * Override Vite config options.\n */\n config?: UserConfig;\n\n /**\n * If true, generate build stats report.\n */\n stats?: boolean;\n\n /**\n * If true, suppress build output. Logs are buffered and only shown on failure.\n *\n * @default false\n */\n silent?: boolean;\n}\n\n/**\n * Build client-side bundle with Vite.\n *\n * This task compiles the browser/client code for production,\n * including code splitting, minification, and optional compression.\n */\nexport async function buildClient(opts: BuildClientOptions): Promise<void> {\n const { build: viteBuild, mergeConfig } = await importVite();\n const plugins: any[] = [];\n\n const compress: ViteCompressOptions | undefined = opts.precompress\n ? typeof opts.precompress === \"object\"\n ? opts.precompress\n : {}\n : undefined;\n\n if (opts.stats) {\n plugins.push(\n viteAnalyzer({\n analyzerMode: \"static\",\n }),\n );\n }\n\n if (opts.precompress && compress) {\n plugins.push(viteCompress(compress));\n }\n\n // Create buffered logger for silent mode\n const logger = opts.silent ? createBufferedLogger() : undefined;\n\n const viteBuildClientConfig: UserConfig = {\n mode: \"production\",\n logLevel: opts.silent ? \"silent\" : undefined,\n define: {\n \"process.env.NODE_ENV\": '\"production\"',\n },\n publicDir: \"public\",\n build: {\n chunkSizeWarningLimit: 1000,\n outDir: opts.dist,\n rollupOptions: {\n output: {\n entryFileNames: \"entry.[hash].js\",\n chunkFileNames: \"chunk.[hash].js\",\n assetFileNames: \"asset.[hash][extname]\",\n },\n },\n },\n esbuild: { legalComments: \"none\" },\n customLogger: logger,\n plugins,\n };\n\n try {\n await viteBuild(mergeConfig(viteBuildClientConfig, opts.config ?? {}));\n } catch (error) {\n // Flush buffered logs on failure so user can see what happened\n logger?.flush();\n throw error;\n }\n}\n","import { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport m from \"node:module\";\nimport { join } from \"node:path\";\n\nexport interface GenerateExternalsOptions {\n /**\n * Output directory for package.json.\n */\n distDir: string;\n\n /**\n * List of external package names.\n */\n externals: string[];\n}\n\n/**\n * Generate minimal package.json with pinned external dependencies.\n *\n * This task creates a package.json in the dist directory containing\n * only the external dependencies needed at runtime, with their versions\n * pinned to the currently installed versions.\n */\nexport async function generateExternals(\n opts: GenerateExternalsOptions,\n): Promise<void> {\n const require = m.createRequire(import.meta.filename);\n const deps: Record<string, string> = {};\n\n for (const dep of opts.externals) {\n try {\n const requirePath = require.resolve(dep);\n const pkgPath = `${requirePath.split(`node_modules/${dep}`)[0]}node_modules/${dep}/package.json`;\n const pkg = JSON.parse(await readFile(pkgPath, \"utf-8\"));\n deps[dep] = `^${pkg.version}`;\n } catch (_err) {\n console.warn(`[generateExternals] Cannot find '${dep}' in node_modules`);\n }\n }\n\n const minimalPkg = {\n type: \"module\",\n main: \"index.js\",\n dependencies: deps,\n };\n\n await mkdir(opts.distDir, { recursive: true });\n\n const target = join(opts.distDir, \"package.json\");\n await writeFile(target, JSON.stringify(minimalPkg, null, 2), \"utf-8\");\n}\n","import { readFile, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { AlephaError } from \"alepha\";\nimport type * as vite from \"vite\";\nimport type { UserConfig } from \"vite\";\nimport { analyzer as viteAnalyzer } from \"vite-bundle-analyzer\";\nimport { createBufferedLogger } from \"../helpers/createBufferedLogger.ts\";\nimport { importVite } from \"../helpers/importVite.ts\";\nimport { generateExternals } from \"./generateExternals.ts\";\n\nexport interface BuildServerOptions {\n /**\n * Path to the server entry file.\n */\n entry: string;\n\n /**\n * Output directory for server build.\n */\n distDir: string;\n\n /**\n * Optional client directory name (relative to distDir).\n * If provided, the client template will be embedded in the server output.\n */\n clientDir?: string;\n\n /**\n * Override Vite config options.\n */\n config?: UserConfig;\n\n /**\n * If true, generate build stats report.\n */\n stats?: boolean;\n\n /**\n * If true, suppress build output. Logs are buffered and only shown on failure.\n *\n * @default false\n */\n silent?: boolean;\n}\n\nexport interface BuildServerResult {\n /**\n * The filename of the built server entry (e.g., \"abc123.js\").\n */\n entryFile: string;\n}\n\n/**\n * Build server-side SSR bundle with Vite.\n *\n * This task compiles the server code for production,\n * generates the externals package.json, and creates\n * the dist/index.js entry wrapper.\n */\nexport async function buildServer(\n opts: BuildServerOptions,\n): Promise<BuildServerResult> {\n const { build: viteBuild, mergeConfig } = await importVite();\n const plugins: any[] = [];\n\n if (opts.stats) {\n plugins.push(\n viteAnalyzer({\n analyzerMode: \"static\",\n }),\n );\n }\n\n // Create buffered logger for silent mode\n const logger = opts.silent ? createBufferedLogger() : undefined;\n\n const viteBuildServerConfig: UserConfig = {\n mode: \"production\",\n logLevel: opts.silent ? \"silent\" : undefined,\n define: {\n \"process.env.NODE_ENV\": '\"production\"',\n },\n publicDir: false,\n ssr: {\n noExternal: true,\n },\n build: {\n ssr: opts.entry,\n outDir: `${opts.distDir}/server`,\n minify: true,\n chunkSizeWarningLimit: 10000,\n rollupOptions: {\n output: {\n entryFileNames: \"[hash].js\",\n chunkFileNames: \"[hash].js\",\n assetFileNames: \"[hash][extname]\",\n format: \"esm\",\n },\n },\n },\n esbuild: { legalComments: \"none\", keepNames: true },\n customLogger: logger,\n plugins,\n };\n\n let result: vite.Rollup.RollupOutput | vite.Rollup.RollupOutput[];\n try {\n result = (await viteBuild(\n mergeConfig(viteBuildServerConfig, opts.config || {}),\n )) as vite.Rollup.RollupOutput | vite.Rollup.RollupOutput[];\n } catch (error) {\n // Flush buffered logs on failure so user can see what happened\n logger?.flush();\n throw error;\n }\n\n // Extract resolved config to get externals\n const resolvedConfig = (result as any).resolvedConfig;\n const externals: string[] = resolvedConfig?.ssr?.external ?? [];\n\n // Generate package.json with externals\n await generateExternals({\n distDir: opts.distDir,\n externals,\n });\n\n const entryFile = extractEntryFromBundle(opts.entry, result);\n\n // Embed client template if client was built\n let template = \"\";\n if (opts.clientDir) {\n const index = await readFile(\n `${opts.distDir}/${opts.clientDir}/index.html`,\n \"utf-8\",\n );\n template = `process.env.REACT_SERVER_TEMPLATE ??= \\`${index.replace(/>\\s*</g, \"><\").trim()}\\`;\\n`;\n }\n\n const warning =\n \"// This file was automatically generated. DO NOT MODIFY.\" +\n \"\\n\" +\n \"// Changes to this file will be lost when the code is regenerated.\\n\";\n\n const forceProduction = \"process.env.NODE_ENV ??= 'production';\\n\";\n\n await writeFile(\n `${opts.distDir}/index.js`,\n `${warning}\\n${forceProduction}${template}\\nawait import('./server/${entryFile}');`.trim(),\n );\n\n return { entryFile };\n}\n\n/**\n * Extract entry filename from Vite build result.\n */\nfunction extractEntryFromBundle(\n entry: string,\n result:\n | vite.Rollup.RollupOutput\n | vite.Rollup.RollupOutput[]\n | vite.Rollup.RollupWatcher,\n): string {\n const entryFilePath = entry.startsWith(\"/\")\n ? entry\n : join(process.cwd(), entry);\n\n const rollupOutput = (\n Array.isArray(result) ? result[0] : result\n ) as vite.Rollup.RollupOutput;\n\n const entryFile = rollupOutput.output.find(\n (it) => \"facadeModuleId\" in it && it.facadeModuleId === entryFilePath,\n )?.fileName;\n\n if (!entryFile) {\n throw new AlephaError(\n `Could not find the entry file \"${entryFilePath}\" in the build output. Please check your entry file and try again.`,\n );\n }\n\n return entryFile;\n}\n","import { join } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { type Alepha, AlephaError } from \"alepha\";\nimport { importVite } from \"./importVite.ts\";\n\n/**\n * Import Alepha instance from a transpiled server entry file.\n */\nexport const importAlepha = async (\n entry: string,\n options?: {\n env: Record<string, string>;\n },\n): Promise<Alepha> => {\n if (global.__cli_alepha) {\n return global.__cli_alepha as Alepha;\n }\n\n const { loadEnv } = await importVite();\n\n const env = loadEnv(\"development\", process.cwd(), \"\");\n\n for (const key in env) {\n process.env[key] = env[key];\n }\n\n if (options?.env) {\n for (const key in options.env) {\n process.env[key] = options.env[key];\n }\n }\n\n process.env.ALEPHA_CLI_IMPORT = \"true\";\n process.env.LOG_LEVEL = \"error\";\n process.env.LOG_FORMAT = \"pretty\";\n process.env.NODE_ENV = \"production\";\n\n const entryFile = pathToFileURL(join(process.cwd(), entry)).href;\n const mod = await import(entryFile);\n\n // check if alepha is correctly exported\n if (mod.default) {\n return mod.default;\n }\n\n // else, try with global variable\n const alepha = global.__cli_alepha as Alepha | undefined;\n if (!alepha) {\n throw new AlephaError(\n \"Alepha instance not found. Ensure Alepha is initialized.\",\n );\n }\n\n return alepha;\n};\n","import { cp, mkdir } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { importAlepha } from \"../helpers/importAlepha.ts\";\n\nexport interface CopyAssetsOptions {\n /**\n * Entry point for the built Alepha application.\n */\n entry: string;\n\n /**\n * Output directory for copied assets.\n */\n distDir: string;\n}\n\n/**\n * Copy assets from Alepha packages to the build output directory.\n *\n * This task loads the built Alepha application, reads the\n * `alepha.build.assets` state to find packages with assets,\n * and copies their `/assets` directories to the build output.\n *\n * Used by modules like AlephaServerSwagger to distribute UI files.\n */\nexport async function copyAssets(opts: CopyAssetsOptions): Promise<void> {\n const root = process.cwd();\n const alepha = await importAlepha(opts.entry);\n const assets = alepha.state.get(\"alepha.build.assets\");\n\n if (!assets || assets.length === 0) {\n return;\n }\n\n const require = createRequire(join(root, opts.entry));\n const buildAssetsDir = join(root, `${opts.distDir}/assets`);\n await mkdir(buildAssetsDir).catch(() => null);\n\n for (const pkgName of assets ?? []) {\n const pkgDir = dirname(require.resolve(`${pkgName}/package.json`));\n const assetsPkgDir = resolve(pkgDir, \"assets\");\n await cp(assetsPkgDir, buildAssetsDir, { recursive: true });\n }\n}\n","import { writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nexport interface GenerateCloudflareOptions {\n /**\n * The directory where the build output is placed.\n *\n * @default \"dist\"\n */\n distDir?: string;\n}\n\nconst WARNING_COMMENT =\n \"// This file was automatically generated. DO NOT MODIFY.\\n\" +\n \"// Changes to this file will be lost when the code is regenerated.\\n\";\n\n/**\n * Generate Cloudflare Workers deployment configuration.\n *\n * This task creates:\n * - wrangler.jsonc with worker configuration\n * - worker.js entry point for Cloudflare Workers\n */\nexport async function generateCloudflare(\n opts: GenerateCloudflareOptions = {},\n): Promise<void> {\n const dist = opts.distDir ?? \"dist\";\n const root = process.cwd();\n\n // Get current directory name for worker name\n const parts = root.split(\"/\");\n const name = parts[parts.length - 1];\n\n const wrangler = {\n name: name,\n main: \"./worker.js\",\n compatibility_flags: [\"nodejs_compat\"],\n compatibility_date: \"2025-11-17\",\n };\n\n writeFileSync(\n join(root, dist, \"wrangler.jsonc\"),\n JSON.stringify(wrangler, null, 2),\n );\n\n const workerCode = `\nprocess.env.ALEPHA_SERVERLESS = \"true\";\n\nawait import(\"./index.js\");\n\nexport default {\n fetch: async (request, env, ctx) => {\n\n await __alepha.start();\n const ev = { req: request, res: undefined };\n await __alepha.events.emit(\"web:request\", ev);\n return ev.res;\n },\n};\n`.trim();\n\n writeFileSync(\n join(root, dist, \"worker.js\"),\n `${WARNING_COMMENT}\\n${workerCode}`.trim(),\n );\n}\n","import { cp, writeFile } from \"node:fs/promises\";\nimport { fileExists } from \"../helpers/fileExists.ts\";\n\nexport interface GenerateDockerOptions {\n /**\n * The directory where the build output is placed.\n *\n * @default \"dist\"\n */\n distDir?: string;\n\n /**\n * Docker image name to use in the Dockerfile.\n *\n * @default \"node:24-alpine\"\n */\n image?: string;\n\n /**\n * Command to run in the Docker container.\n *\n * @default \"node\"\n */\n command?: string;\n}\n\n/**\n * Generate Docker deployment configuration.\n *\n * This task creates:\n * - Dockerfile with configurable Node image\n * - Copies drizzle migrations if they exist\n */\nexport async function generateDocker(\n opts: GenerateDockerOptions = {},\n): Promise<void> {\n const distDir = opts.distDir ?? \"dist\";\n const image = opts.image ?? \"node:24-alpine\";\n const command = opts.command ?? \"node\";\n\n // Copy drizzle migrations if they exist\n const hasMigrations = await fileExists(\"drizzle\");\n if (hasMigrations) {\n await cp(\"drizzle\", `${distDir}/drizzle`, {\n recursive: true,\n });\n }\n\n const dockerfile = `# This file was automatically generated. DO NOT MODIFY.\n# Changes to this file will be lost when the code is regenerated.\nFROM ${image}\nWORKDIR /app\n\nCOPY . .\n\nCMD [\"${command}\", \"index.js\"]\n`;\n\n await writeFile(`${distDir}/Dockerfile`, dockerfile);\n}\n","import type { Alepha } from \"alepha\";\nimport { importAlepha } from \"../helpers/importAlepha.ts\";\n\nexport interface GenerateSitemapOptions {\n /**\n * Entry point for the built Alepha application.\n */\n entry: string;\n\n /**\n * Base URL for the sitemap (e.g., \"https://example.com\").\n */\n baseUrl: string;\n\n /**\n * Optional HTML template (for React SSR).\n */\n template?: string;\n}\n\n/**\n * Generate sitemap.xml from Alepha page descriptors.\n *\n * This task loads the built Alepha application,\n * queries all page descriptors, and generates a sitemap.xml\n * containing URLs for all accessible pages.\n */\nexport async function generateSitemap(\n opts: GenerateSitemapOptions,\n): Promise<string> {\n const alepha = await importAlepha(opts.entry, {\n env: opts.template\n ? {\n REACT_SERVER_TEMPLATE: opts.template,\n }\n : {},\n });\n\n if (!alepha.isConfigured()) {\n await alepha.events.emit(\"configure\", alepha);\n (alepha as any).configured = true;\n }\n\n return generateSitemapFromAlepha(alepha, opts.baseUrl);\n}\n\nfunction generateSitemapFromAlepha(alepha: Alepha, baseUrl: string): string {\n const pages = alepha.descriptors(\"page\") as any[];\n const urls: string[] = [];\n\n for (const page of pages) {\n const options = page.options;\n\n // Skip pages with children (parent pages that can't be rendered directly)\n if (options.children) {\n continue;\n }\n\n // Only include static pages or pages without parameters\n if (!options.schema?.params) {\n // Simple page without parameters\n const path = options.path || \"\";\n const url = `${baseUrl.replace(/\\/$/, \"\")}${path === \"\" ? \"/\" : path}`;\n urls.push(url);\n } else if (\n options.static &&\n typeof options.static === \"object\" &&\n options.static.entries\n ) {\n // Static page with predefined entries\n for (const entry of options.static.entries) {\n const path = buildPathFromParams(\n options.path || \"\",\n entry.params || {},\n );\n const url = `${baseUrl.replace(/\\/$/, \"\")}${path}`;\n urls.push(url);\n }\n }\n }\n\n return buildSitemapXml(urls);\n}\n\nfunction buildPathFromParams(\n pathPattern: string,\n params: Record<string, any>,\n): string {\n let path = pathPattern;\n\n for (const [key, value] of Object.entries(params)) {\n path = path.replace(`:${key}`, String(value));\n }\n\n return path || \"/\";\n}\n\nfunction buildSitemapXml(urls: string[]): string {\n const lastMod = new Date().toISOString().split(\"T\")[0];\n const urlEntries = urls\n .map(\n (url) =>\n ` <url>\\n <loc>${escapeXml(url)}</loc>\\n\\t\\t<lastmod>${lastMod}</lastmod>\\n </url>`,\n )\n .join(\"\\n\");\n\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n${urlEntries}\n</urlset>`;\n}\n\nfunction escapeXml(str: string): string {\n return str\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n","import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { importVite } from \"../helpers/importVite.ts\";\n\nexport interface GenerateVercelOptions {\n /**\n * The directory where the build output is placed.\n *\n * @default \"dist\"\n */\n distDir?: string;\n\n /**\n * The name of the client directory.\n *\n * @default \"public\"\n */\n clientDir?: string;\n\n /**\n * Vercel configuration options.\n */\n config?: VercelConfig;\n}\n\nexport interface VercelConfig {\n projectName?: string;\n orgId?: string;\n projectId?: string;\n config?: Record<string, any> & {\n crons?: Array<{\n path: string;\n schedule: string;\n }>;\n };\n}\n\nconst WARNING_COMMENT =\n \"// This file was automatically generated. DO NOT MODIFY.\\n\" +\n \"// Changes to this file will be lost when the code is regenerated.\\n\";\n\n/**\n * Generate Vercel deployment configuration.\n *\n * This task creates:\n * - vercel.json with route rewrites\n * - api/index.js entry point for Vercel serverless function\n * - .vercel/project.json if VERCEL_PROJECT_ID and VERCEL_ORG_ID are set\n */\nexport async function generateVercel(\n opts: GenerateVercelOptions = {},\n): Promise<void> {\n const distDir = opts.distDir ?? \"dist\";\n const clientDir = opts.clientDir ?? \"public\";\n const { loadEnv } = await importVite();\n\n const env = loadEnv(\"production\", process.cwd(), \"\");\n\n // Ensure the api directory exists\n if (!existsSync(`${distDir}/api`)) {\n mkdirSync(`${distDir}/api`);\n }\n\n // Add the only one entry point for Vercel\n writeFileSync(\n `${distDir}/api/index.js`,\n `${WARNING_COMMENT}\nimport \"../index.js\";\n\nexport default async function (req, res) {\n\\tawait __alepha.start();\n\\t__alepha.events.emit(\"node:request\", { req, res });\n}\n`,\n );\n\n // Always generate a vercel.json file\n writeFileSync(\n `${distDir}/vercel.json`,\n JSON.stringify(\n {\n ...opts?.config?.config,\n rewrites: [\n {\n source: \"/(.*)\",\n destination: \"/api/index.js\",\n },\n ],\n buildCommand: \"\",\n installCommand: \"\",\n outputDirectory: clientDir,\n },\n null,\n \" \",\n ),\n );\n\n // Generate .vercel/project.json if VERCEL_PROJECT_ID and VERCEL_ORG_ID are set\n const projectId = env.VERCEL_PROJECT_ID ?? opts.config?.projectId;\n const projectName = env.VERCEL_PROJECT_NAME ?? opts.config?.projectName;\n const orgId = env.VERCEL_ORG_ID ?? opts.config?.orgId;\n\n if (projectId && orgId) {\n try {\n mkdirSync(`${distDir}/.vercel`, { recursive: true });\n } catch (_e) {\n // Ignore error if directory already exists\n }\n\n writeFileSync(\n `${distDir}/.vercel/project.json`,\n JSON.stringify(\n {\n projectId,\n projectName,\n orgId,\n },\n null,\n \" \",\n ),\n );\n }\n\n // If /public does not exist, create an empty one to avoid Vercel errors\n if (!existsSync(`${distDir}/${clientDir}`)) {\n mkdirSync(`${distDir}/${clientDir}`, { recursive: true });\n writeFileSync(`${distDir}/${clientDir}/.keep`, \"\");\n }\n}\n","import { mkdir, writeFile } from \"node:fs/promises\";\nimport type { Alepha } from \"alepha\";\nimport { importAlepha } from \"../helpers/importAlepha.ts\";\nimport {\n compressFile,\n type ViteCompressOptions,\n} from \"../plugins/viteCompress.ts\";\n\nexport interface PrerenderPagesOptions {\n /**\n * Entry point for the built Alepha application.\n */\n entry: string;\n\n /**\n * Client dist directory for output files.\n */\n dist: string;\n\n /**\n * Optional compression options.\n */\n compress?: ViteCompressOptions | boolean;\n}\n\nexport interface PrerenderPagesResult {\n /**\n * Number of pages pre-rendered.\n */\n count: number;\n}\n\n/**\n * Pre-render static pages defined in the Alepha application.\n *\n * This task loads the built Alepha application, queries all page\n * descriptors with `static: true`, and generates static HTML files\n * for each page. Supports pages with parameterized routes via\n * `static.entries` configuration.\n */\nexport async function prerenderPages(\n opts: PrerenderPagesOptions,\n): Promise<PrerenderPagesResult> {\n const alepha = await importAlepha(opts.entry);\n\n const now = Date.now();\n\n if (!alepha.isConfigured()) {\n await alepha.events.emit(\"configure\", alepha);\n (alepha as any).configured = true;\n }\n\n return await prerenderFromAlepha(alepha, opts.dist, opts.compress);\n}\n\nasync function prerenderFromAlepha(\n alepha: Alepha,\n dist: string,\n compress?: ViteCompressOptions | boolean,\n): Promise<PrerenderPagesResult> {\n let count = 0;\n const pages = alepha.descriptors(\"page\") as any[];\n\n for (const page of pages) {\n const options = page.options;\n\n if (options.children) {\n continue;\n }\n\n if (!options.static) {\n continue;\n }\n\n const config = typeof options.static === \"object\" ? options.static : {};\n\n if (!options.schema?.params) {\n count += 1;\n await renderFile(page, {}, dist, compress);\n continue;\n }\n\n if (config.entries) {\n for (const entry of config.entries) {\n count += 1;\n await renderFile(page, entry, dist, compress);\n }\n }\n }\n\n return { count };\n}\n\nasync function renderFile(\n page: any,\n options: any,\n dist: string,\n compress?: ViteCompressOptions | boolean,\n) {\n const { html, state } = await page.render({\n html: true,\n ...options,\n });\n\n const pathname = state.url.pathname;\n const filepath = `${dist}${pathname === \"/\" ? \"/index\" : pathname}.html`;\n\n await mkdir(filepath.substring(0, filepath.lastIndexOf(\"/\")), {\n recursive: true,\n });\n\n await writeFile(filepath, html);\n\n if (compress) {\n await compressFile(typeof compress === \"object\" ? compress : {}, filepath);\n }\n}\n","import path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { Alepha, State } from \"alepha\";\nimport type { ResolvedConfig, ViteDevServer } from \"vite\";\nimport { importVite } from \"../helpers/importVite.ts\";\n\nexport interface AlephaRunnerOptions {\n /**\n * Path to the server entry file.\n */\n entry: string;\n\n /**\n * Enable debug logging.\n */\n debug?: boolean;\n}\n\nexport interface AlephaRunnerState {\n root: string;\n started: boolean;\n app?: Alepha;\n config?: ResolvedConfig;\n lock?: PromiseWithResolvers<void>;\n log: (...msg: string[]) => void;\n entry: string;\n onReload?: () => void;\n}\n\n/**\n * Create an Alepha runner for development.\n *\n * The runner manages the lifecycle of an Alepha application during\n * Vite dev server operation, handling start/stop/restart and HMR.\n */\nexport function createAlephaRunner(opts: AlephaRunnerOptions): AlephaRunner {\n const state: AlephaRunnerState = {\n root: process.cwd().replace(/\\\\/g, \"/\"),\n started: false,\n log: opts.debug ? (...msg: string[]) => console.log(...msg) : () => {},\n entry: opts.entry,\n onReload: () => {},\n };\n\n return new AlephaRunner(state);\n}\n\nexport class AlephaRunner {\n protected state: AlephaRunnerState;\n\n constructor(state: AlephaRunnerState) {\n this.state = state;\n }\n\n /**\n * Set resolved Vite config.\n */\n setConfig(config: ResolvedConfig): void {\n this.state.config = config;\n }\n\n /**\n * Check if SSR is enabled for the running app.\n */\n isSsrEnabled(): boolean {\n if (!this.state.app) return false;\n return (\n (this.state.app.state.get(\"alepha.react.server.ssr\" as keyof State) as\n | boolean\n | undefined) ?? false\n );\n }\n\n /**\n * Check if app is started.\n */\n get isStarted(): boolean {\n return this.state.started;\n }\n\n /**\n * Get the running Alepha app instance.\n */\n get app(): Alepha | undefined {\n return this.state.app;\n }\n\n /**\n * Start the Alepha application.\n */\n async start(server: ViteDevServer): Promise<void> {\n const { loadEnv } = await importVite();\n\n if (this.state.started) {\n await this.restart(server, true);\n return;\n }\n\n if (!this.state.config) {\n this.state.log(\"[DEBUG] No config - skip starting\");\n return;\n }\n\n this.state.onReload?.();\n\n this.state.log(\"[DEBUG] Starting Alepha app...\");\n\n this.state.started = false;\n this.state.app = undefined;\n\n const serverEntryPath = path.resolve(\n this.state.config.root,\n this.state.entry,\n );\n const fileUrl = pathToFileURL(`${serverEntryPath}`).href;\n const env = loadEnv(\"development\", this.state.config.root, \"\");\n const before = { ...process.env };\n\n for (const key in env) {\n process.env[key] = env[key];\n }\n\n process.env.NODE_ENV ??= \"development\";\n process.env.VITE_ALEPHA_DEV = \"true\";\n process.env.SERVER_HOST ??=\n typeof server.config.server.host === \"string\"\n ? server.config.server.host\n : \"localhost\";\n process.env.SERVER_PORT ??= String(server.config.server.port || \"5173\");\n\n try {\n const now = Date.now();\n await server.ssrLoadModule(fileUrl);\n this.state.log(`[DEBUG] Alepha app loaded in ${Date.now() - now}ms`);\n await new Promise((r) => setTimeout(r, 10));\n\n this.state.app = (globalThis as any).__alepha;\n if (!this.state.app) {\n this.state.log(\"[DEBUG] No app found - skip starting\");\n return;\n }\n\n this.state.app.state.set(\"alepha.node.server\" as any, server.httpServer);\n\n await this.state.app.start();\n this.state.started = true;\n\n process.env = { ...before };\n\n this.state.log(\"[DEBUG] Starting Done!\");\n } catch (e) {\n if (e instanceof Error) {\n let it: any = e;\n do {\n server.ssrFixStacktrace(it);\n it = it.cause;\n } while (it instanceof Error);\n\n server.ssrFixStacktrace(e);\n if (e.cause instanceof Error) {\n server.ssrFixStacktrace(e.cause);\n }\n this.state.app?.log?.error(\"App failed to start:\", e);\n this.state.app?.log?.info(\"Waiting for changes to restart...\");\n }\n this.state.log(\"[DEBUG] Alepha app start error\");\n this.state.started = false;\n }\n }\n\n /**\n * Stop the Alepha application.\n */\n async stop(): Promise<void> {\n if (this.state.app?.stop && this.state.started) {\n this.state.log(\"[DEBUG] Stopping Alepha app...\");\n await this.state.app.stop();\n this.state.started = false;\n this.state.log(\"[DEBUG] Stopping Done!\");\n } else {\n this.state.log(\"[DEBUG] Alepha app not started - skip stop\");\n }\n }\n\n /**\n * Restart the Alepha application.\n *\n * @returns true if the restart was skipped due to locking\n */\n async restart(server: ViteDevServer, invalidate?: boolean): Promise<boolean> {\n if (this.state.lock) {\n this.state.log(\"[DEBUG] STILL LOCKING\");\n return true;\n }\n\n this.state.log(\"[DEBUG] LOCK RESTART\");\n this.state.lock = Promise.withResolvers();\n\n const now = Date.now();\n this.state.log(\"[DEBUG] RESTART\");\n await this.stop();\n this.state.log(`[DEBUG] RESTART (stop) in ${Date.now() - now}ms`);\n\n if (invalidate) {\n server.moduleGraph.invalidateAll();\n }\n\n await this.start(server);\n this.state.log(`[DEBUG] RESTART OK in ${Date.now() - now}ms`);\n\n setTimeout(() => {\n this.state.log(\"[DEBUG] UNLOCK RESTART\");\n this.state.lock?.resolve();\n this.state.lock = undefined;\n }, 500);\n\n return false;\n }\n\n /**\n * Send reload event to client.\n */\n sendReload(server: ViteDevServer): void {\n server.ws.send({\n type: \"custom\",\n event: \"alepha:reload\",\n data: {},\n });\n }\n}\n\n/**\n * Check if a URL path is a Vite internal file.\n */\nexport function isViteInternalPath(pathname: string): boolean {\n const [path] = pathname.split(\"?\");\n\n // Vite internal files\n if (\n path.startsWith(\"/@\") ||\n path.startsWith(\"/src\") ||\n path.includes(\"/node_modules/\")\n ) {\n return true;\n }\n\n return false;\n}\n","import { readFile, unlink, writeFile } from \"node:fs/promises\";\nimport type { Plugin, UserConfig } from \"vite\";\nimport { boot } from \"../helpers/boot.ts\";\nimport { fileExists } from \"../helpers/fileExists.ts\";\nimport {\n type BuildClientOptions,\n buildClient,\n buildServer,\n copyAssets,\n type GenerateDockerOptions,\n generateCloudflare,\n generateDocker,\n generateSitemap,\n generateVercel,\n prerenderPages,\n type VercelConfig,\n} from \"../tasks/index.ts\";\n\nexport interface ViteAlephaBuildOptions {\n /**\n * Path to the entry file for the server build.\n * If empty, SSR build will be skipped.\n */\n serverEntry?: string | false;\n\n /**\n * Set false to skip the client build.\n * This is useful if you only want to build the server-side application.\n */\n client?: false | Partial<BuildClientOptions>;\n\n /**\n * If true, the build will be optimized for Vercel deployment.\n *\n * If `VERCEL_PROJECT_ID` and `VERCEL_ORG_ID` environment variables are set, .vercel will be generated with the correct configuration.\n *\n * @default false\n */\n vercel?: boolean | VercelConfig;\n\n /**\n * If true, the build will generate Cloudflare Workers configuration.\n *\n * @default false\n */\n cloudflare?: boolean;\n\n /**\n * If true, the build will be optimized for Docker deployment.\n * Additionally, it will generate a Dockerfile in the dist directory.\n */\n docker?: boolean | Omit<GenerateDockerOptions, \"distDir\">;\n\n /**\n * If true, build statistics will be printed after the build completes.\n */\n stats?: boolean;\n}\n\n/**\n * Build modes controlled by ALEPHA_BUILD_MODE environment variable:\n * - \"cli\": Skip plugin entirely, CLI handles all tasks\n * - \"client\": Only build client bundle\n * - \"server\": Only build server bundle\n * - undefined/other: Full build (default behavior)\n */\nexport type AlephaBuildMode = \"cli\" | \"client\" | \"server\";\n\n/**\n * Alepha build plugin for Vite.\n *\n * This plugin orchestrates the complete build process:\n * 1. Build client (if index.html exists)\n * 2. Build server (SSR)\n * 3. Copy assets from packages\n * 4. Pre-render static pages (if enabled)\n * 5. Generate sitemap (if enabled)\n * 6. Generate deployment config (Vercel/Cloudflare/Docker)\n *\n * Build mode can be controlled via ALEPHA_BUILD_MODE env var for CLI integration.\n */\nexport async function viteAlephaBuild(\n options: ViteAlephaBuildOptions = {},\n): Promise<Plugin> {\n const entry = options.serverEntry ?? (await boot.getServerEntry());\n const distDir = \"dist\";\n const clientDir = \"public\";\n\n let rootConfig: UserConfig = {};\n\n return {\n name: \"alepha-build\",\n apply: \"build\",\n config(config, ctx) {\n const buildMode = process.env.ALEPHA_BUILD_MODE as\n | AlephaBuildMode\n | undefined;\n\n // CLI mode: plugin does nothing, CLI handles everything\n if (buildMode === \"cli\") {\n return;\n }\n\n // For now, we run two separate builds: one for the client and one for the server\n // We distinguish them using an environment variable\n if (!process.env.VITE_DOUBLE_BUILD_DONE) {\n rootConfig = config;\n }\n\n if (ctx.isSsrBuild || !process.env.VITE_DOUBLE_BUILD_DONE) {\n // Server build, so we don't need the public directory\n config.publicDir = false;\n } else {\n // Client build, so we need the public directory\n config.publicDir = \"public\";\n }\n },\n async buildStart() {\n const buildMode = process.env.ALEPHA_BUILD_MODE as\n | AlephaBuildMode\n | undefined;\n\n // CLI mode: skip entirely\n if (buildMode === \"cli\") {\n return;\n }\n\n if (process.env.VITE_DOUBLE_BUILD_DONE === \"true\") {\n return;\n }\n\n process.env.VITE_DOUBLE_BUILD_DONE = \"true\";\n\n const hasClient =\n options.client !== false && (await fileExists(\"index.html\"));\n\n const buildClientOptions =\n typeof options.client === \"object\" ? options.client : {};\n\n const stats = options.stats ?? process.env.ALEPHA_BUILD_STATS === \"true\";\n\n // Client-only mode\n if (buildMode === \"client\") {\n if (hasClient) {\n await buildClient({\n ...buildClientOptions,\n config: rootConfig,\n dist: `${distDir}/${clientDir}`,\n stats,\n });\n }\n process.exit(0);\n }\n\n // Server-only mode\n if (buildMode === \"server\") {\n if (entry) {\n // Check if client was already built (template exists)\n let clientBuilt = false;\n try {\n await readFile(`${distDir}/${clientDir}/index.html`, \"utf-8\");\n clientBuilt = true;\n } catch {\n // No client build\n }\n\n await buildServer({\n config: {\n base: rootConfig.base || \"\",\n },\n entry,\n distDir,\n clientDir: clientBuilt ? clientDir : undefined,\n stats,\n });\n }\n process.exit(0);\n }\n\n // Full build mode (default)\n\n // Task 1: Build client\n if (hasClient) {\n await buildClient({\n ...buildClientOptions,\n config: rootConfig,\n dist: `${distDir}/${clientDir}`,\n stats,\n });\n }\n\n let template = \"\";\n if (hasClient) {\n // Load output index.html for template embedding\n template = await readFile(\n `${distDir}/${clientDir}/index.html`,\n \"utf-8\",\n );\n }\n\n // Task 2: Build server\n if (entry) {\n await buildServer({\n config: {\n base: rootConfig.base || \"\",\n },\n entry,\n distDir,\n clientDir: hasClient ? clientDir : undefined,\n stats,\n });\n\n // Server will handle index.html if both client & server are built\n if (hasClient && options.serverEntry !== false) {\n await unlink(`${distDir}/${clientDir}/index.html`);\n }\n\n // Task 3: Copy assets (swagger ui & others)\n await copyAssets({\n entry: `${distDir}/index.js`,\n distDir,\n });\n }\n\n // Task 4: Generate sitemap\n if (buildClientOptions.sitemap && entry) {\n await writeFile(\n `${distDir}/${clientDir}/sitemap.xml`,\n await generateSitemap({\n entry: `${distDir}/index.js`,\n baseUrl: buildClientOptions.sitemap.hostname,\n }),\n );\n }\n\n // Task 5: Pre-render static pages\n if (buildClientOptions.prerender && template) {\n await prerenderPages({\n dist: `${distDir}/${clientDir}`,\n entry: `${distDir}/index.js`,\n compress: buildClientOptions.precompress,\n });\n }\n\n // Task 6: Generate deployment configurations\n if (options.vercel) {\n const config =\n typeof options.vercel === \"boolean\" ? {} : options.vercel;\n await generateVercel({\n distDir,\n clientDir,\n config,\n });\n }\n\n if (options.cloudflare) {\n await generateCloudflare({\n distDir,\n });\n }\n\n if (options.docker) {\n const dockerOpts =\n typeof options.docker === \"boolean\" ? {} : options.docker;\n await generateDocker({\n distDir,\n ...dockerOpts,\n });\n }\n\n // Prevent the default build from running again\n process.exit(0);\n },\n };\n}\n","import type { Plugin, ResolvedConfig } from \"vite\";\nimport { boot } from \"../helpers/boot.ts\";\nimport { createAlephaRunner, isViteInternalPath } from \"../tasks/runAlepha.ts\";\n\nexport interface ViteAlephaDevOptions {\n /**\n * Path to the entry file for the server build.\n * If empty, plugin will be disabled.\n */\n serverEntry?: string | false;\n\n /**\n * If true, enables debug logging.\n *\n * @default false\n */\n debug?: boolean;\n}\n\n/**\n * Plug Alepha into Vite development server.\n *\n * This plugin manages the Alepha application lifecycle during development,\n * handling hot module replacement and request forwarding.\n */\nexport async function viteAlephaDev(\n options: ViteAlephaDevOptions = {},\n): Promise<Plugin> {\n let entry = options.serverEntry;\n if (!entry) {\n entry = await boot.getServerEntry();\n if (!entry) {\n return {\n name: \"alepha-dev\",\n apply: \"serve\",\n config() {},\n };\n }\n }\n\n const runner = createAlephaRunner({\n entry,\n debug: options.debug,\n });\n\n return {\n name: \"alepha-dev\",\n apply: \"serve\",\n configResolved(resolvedConfig: ResolvedConfig) {\n runner.setConfig(resolvedConfig);\n },\n async handleHotUpdate(ctx) {\n if (options.debug) {\n console.log(\"[DEBUG] HMR\", ctx.file);\n }\n\n if (ctx.file.includes(\"/.idea/\")) {\n return [];\n }\n\n const isServerOnly = !ctx.modules[0]?._clientModule;\n const isBrowserOnly = !ctx.modules[0]?._ssrModule;\n const isSsrEnabled = runner.isSsrEnabled();\n\n if (isBrowserOnly) {\n if (options.debug) {\n console.log(\n \"[DEBUG] HMR - browser only - no reason to reload server\",\n );\n }\n return;\n }\n\n const root = process.cwd().replace(/\\\\/g, \"/\");\n const invalidate = !ctx.file.startsWith(root);\n if (invalidate && options.debug) {\n console.log(\"[DEBUG] HMR - outside root - invalidate all\");\n }\n\n if (!isSsrEnabled && isServerOnly) {\n await runner.restart(ctx.server, invalidate);\n return [];\n }\n\n if (isSsrEnabled && ctx.modules[0]) {\n const skip = await runner.restart(ctx.server, invalidate);\n if (skip) {\n return [];\n }\n\n if (!runner.isStarted) {\n if (options.debug) {\n console.log(\"[DEBUG] HMR - abort due to app not started\");\n }\n return [];\n }\n\n if (isServerOnly && runner.isStarted) {\n runner.sendReload(ctx.server);\n return [];\n }\n }\n },\n async configureServer(server) {\n // Forward vite request to alepha server\n server.middlewares.use((req, res, next) => {\n if (\n runner.isStarted &&\n runner.app &&\n req.url &&\n !isViteInternalPath(req.url)\n ) {\n // Patch res.end to detect if alepha handled the request\n // If not, we call next() to let vite handle it (e.g. for static files)\n let ended = false;\n\n const writeHead = res.writeHead.bind(res);\n res.writeHead = (...args: any[]) => {\n ended = true;\n return writeHead(args[0], args[1], args[2]);\n };\n\n return runner.app.events\n .emit(\"node:request\" as any, { req, res })\n .then(() => {\n if (!ended) {\n next();\n }\n });\n }\n next();\n });\n\n server.config.logger.info = (msg: string) => {\n runner.app?.log?.info(msg.trim());\n };\n\n server.config.logger.clearScreen = () => {};\n\n await runner.start(server);\n },\n async closeBundle() {\n // Cleanup handled by runner\n },\n };\n}\n","import { createRequire } from \"node:module\";\nimport { OPTIONS } from \"alepha\";\nimport type { Plugin } from \"vite\";\nimport {\n type ViteAlephaBuildOptions,\n viteAlephaBuild,\n} from \"./viteAlephaBuild.ts\";\nimport { type ViteAlephaDevOptions, viteAlephaDev } from \"./viteAlephaDev.ts\";\n\nexport type ViteAlephaOptions = ViteAlephaDevOptions &\n ViteAlephaBuildOptions & {\n react?: false;\n };\n\nexport function viteAlepha(\n options: ViteAlephaOptions = {},\n): (Plugin | Promise<Plugin>)[] {\n if (process.env.NODE_ENV === \"test\") {\n return [];\n }\n\n const plugins: (Plugin | Promise<Plugin>)[] & { [OPTIONS]?: any } = [];\n\n if (options.react !== false) {\n try {\n const { default: viteReact } = createRequire(import.meta.url)(\n \"@vitejs/plugin-react\",\n );\n plugins.push(viteReact());\n } catch (e) {}\n }\n\n plugins.push(viteAlephaDev(options), viteAlephaBuild(options));\n plugins[OPTIONS] = options;\n\n return plugins;\n}\n","import type { Alepha } from \"alepha\";\n\n// Vite re-exports\nexport { defineConfig } from \"vite\";\n// Helpers (for advanced use)\nexport * from \"./helpers/boot.ts\";\nexport * from \"./helpers/createBufferedLogger.ts\";\n// Plugins (public API)\nexport * from \"./plugins/viteAlepha.ts\";\nexport * from \"./plugins/viteAlephaBuild.ts\";\nexport * from \"./plugins/viteAlephaDev.ts\";\nexport * from \"./plugins/viteCompress.ts\";\n// Tasks (for CLI integration)\nexport * from \"./tasks/index.ts\";\n\ndeclare global {\n var __cli_alepha: Alepha;\n}\n\n/**\n * Plugin vite for Alepha framework.\n *\n * This module provides Vite plugins and configurations to integrate Alepha applications with Vite's build and development processes.\n *\n * @example\n * ```ts\n * import { defineConfig } from \"vite\";\n * import { viteAlepha } from \"alepha/vite\";\n *\n * export default defineConfig({\n * plugins: [viteAlepha()],\n * // other Vite configurations...\n * });\n * ```\n *\n * @module alepha.vite\n */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAaA,MAAM,iBAAiB,OACrB,OAAO,QAAQ,KAAK,KACY;CAChC,MAAM,YAAY,KAAK,MAAM,aAAa;AAC1C,KAAI;AAEF,SAAO,4BADM,MAAM,SAAS,WAAW,OAAO,CACN,CAAC,Q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,OAAO,MAAM,OAAO;;EAE5B,MAAM,cAAc;EAGrB;;;;;AClIH,SAAgB,WACd,UAA6B,EAAE,EACD;AAC9B,KAAI,QAAQ,IAAI,aAAa,OAC3B,QAAO,EAAE;CAGX,MAAMC,UAA8D,EAAE;AAEtE,KAAI,QAAQ,UAAU,MACpB,KAAI;EACF,MAAM,EAAE,SAAS,cAAc,cAAc,OAAO,KAAK,IAAI,CAC3D,uBACD;AACD,UAAQ,KAAK,WAAW,CAAC;UAClB,GAAG;AAGd,SAAQ,KAAK,cAAc,QAAQ,EAAE,gBAAgB,QAAQ,CAAC;AAC9D,SAAQ,WAAW;AAEnB,QAAO"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["path","match: RegExpExecArray | null","entries: BufferedLogEntry[]","path","_error","gzipCb","brotliCompress","brotliCompressCb","compressionTasks: Promise<void>[]","fs","gzip","plugins: any[]","compress: ViteCompressOptions | undefined","viteAnalyzer","viteBuildClientConfig: UserConfig","deps: Record<string, string>","plugins: any[]","viteAnalyzer","viteBuildServerConfig: UserConfig","result: vite.Rollup.RollupOutput | vite.Rollup.RollupOutput[]","externals: string[]","WARNING_COMMENT","urls: string[]","path","it: any","path","rootConfig: UserConfig","plugins: (Plugin | Promise<Plugin>)[] & { [OPTIONS]?: any }"],"sources":["../../src/vite/helpers/boot.ts","../../src/vite/helpers/createBufferedLogger.ts","../../src/vite/helpers/fileExists.ts","../../src/vite/helpers/importVite.ts","../../src/vite/plugins/viteCompress.ts","../../src/vite/tasks/buildClient.ts","../../src/vite/tasks/generateExternals.ts","../../src/vite/tasks/buildServer.ts","../../src/vite/helpers/importAlepha.ts","../../src/vite/tasks/copyAssets.ts","../../src/vite/tasks/generateCloudflare.ts","../../src/vite/tasks/generateDocker.ts","../../src/vite/tasks/generateSitemap.ts","../../src/vite/tasks/generateVercel.ts","../../src/vite/tasks/prerenderPages.ts","../../src/vite/tasks/runAlepha.ts","../../src/vite/plugins/viteAlephaBuild.ts","../../src/vite/plugins/viteAlephaDev.ts","../../src/vite/plugins/viteAlepha.ts","../../src/vite/index.ts"],"sourcesContent":["import { access, readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { AlephaError } from \"alepha\";\n\n/**\n * Remember:\n * At first, functions was inside alepha/vite package, but it's now used in alepha too.\n * For avoiding cli -> vite, all code moved here.\n */\n\n/**\n * Find browser/client entry file path.\n */\nconst getClientEntry = async (\n root = process.cwd(),\n): Promise<string | undefined> => {\n const indexPath = join(root, \"index.html\");\n try {\n const html = await readFile(indexPath, \"utf8\");\n return extractFirstModuleScriptSrc(html).replace(/\\\\/g, \"/\");\n } catch {\n return undefined;\n }\n};\n\n/**\n * Find server entry file path.\n */\nconst getServerEntry = async (\n root = process.cwd(),\n explicitEntry?: string,\n): Promise<string> => {\n if (explicitEntry) {\n const explicitPath = join(root, explicitEntry);\n try {\n await access(explicitPath);\n return explicitPath;\n } catch {\n throw new AlephaError(\n `Explicit server entry file \"${explicitEntry}\" not found.`,\n );\n }\n }\n\n const maybeEntry = [\n \"src/main.server.ts\",\n \"src/server-entry.ts\",\n \"src/main.server.tsx\",\n \"src/server-entry.tsx\",\n \"src/main.ts\",\n \"src/main.tsx\",\n ];\n\n for (const entry of maybeEntry) {\n try {\n const path = join(root, entry).replace(/\\\\/g, \"/\");\n await access(path);\n return path;\n } catch {\n // continue to next entry\n }\n }\n\n const clientEntry = await getClientEntry(root);\n if (clientEntry) {\n return clientEntry;\n }\n\n throw new AlephaError(\n `Could not find a server entry file. List of supported entry file: ${maybeEntry.join(\", \")}`,\n );\n};\n\n/**\n * Extract first module script src from HTML.\n */\nfunction extractFirstModuleScriptSrc(html: string): string {\n const scriptRegex = /<script\\b[^>]*>[\\s\\S]*?<\\/script>/gi;\n let match: RegExpExecArray | null = scriptRegex.exec(html);\n\n while (match) {\n const tag = match[0];\n\n // Check for type=\"module\"\n if (/type=[\"']module[\"']/i.test(tag)) {\n // Extract the src value\n const srcMatch = tag.match(/\\bsrc=[\"']([^\"']+)[\"']/i);\n const entry = srcMatch?.[1];\n if (entry) {\n if (entry.startsWith(\"/\")) {\n return entry.substring(1); // Remove leading slash\n }\n return entry;\n }\n }\n\n match = scriptRegex.exec(html);\n }\n\n throw new AlephaError(`No module script found in the provided HTML.`);\n}\n\nexport const boot = {\n getClientEntry,\n getServerEntry,\n};\n","import type { Logger } from \"vite\";\n\ninterface BufferedLogEntry {\n level: \"info\" | \"warn\" | \"error\";\n msg: string;\n timestamp: Date;\n}\n\nexport interface BufferedLogger extends Logger {\n /**\n * Flush all buffered log messages to console.\n * Call this on build failure to show what happened.\n */\n flush(): void;\n\n /**\n * Get all buffered log entries.\n */\n getEntries(): BufferedLogEntry[];\n\n /**\n * Clear all buffered entries without printing.\n */\n clear(): void;\n}\n\n/**\n * Creates a Vite logger that buffers all messages instead of printing them.\n * Useful for silent builds that only show output on failure.\n *\n * @example\n * ```ts\n * const logger = createBufferedLogger();\n * try {\n * await viteBuild({ customLogger: logger, logLevel: 'info' });\n * } catch (error) {\n * logger.flush(); // Print all buffered logs\n * throw error;\n * }\n * ```\n */\nexport function createBufferedLogger(): BufferedLogger {\n const entries: BufferedLogEntry[] = [];\n const loggedErrors = new WeakSet<Error>();\n const warnedMessages = new Set<string>();\n let hasWarned = false;\n\n const logger: BufferedLogger = {\n get hasWarned() {\n return hasWarned;\n },\n\n info(msg: string) {\n entries.push({ level: \"info\", msg, timestamp: new Date() });\n },\n\n warn(msg: string) {\n hasWarned = true;\n entries.push({ level: \"warn\", msg, timestamp: new Date() });\n },\n\n warnOnce(msg: string) {\n if (warnedMessages.has(msg)) {\n return;\n }\n warnedMessages.add(msg);\n hasWarned = true;\n entries.push({ level: \"warn\", msg, timestamp: new Date() });\n },\n\n error(msg: string, options?: { error?: Error | null }) {\n if (options?.error) {\n loggedErrors.add(options.error);\n }\n entries.push({ level: \"error\", msg, timestamp: new Date() });\n },\n\n clearScreen() {\n // No-op in buffered mode - we don't clear anything\n },\n\n hasErrorLogged(error: Error): boolean {\n return loggedErrors.has(error);\n },\n\n flush() {\n for (const entry of entries) {\n const prefix =\n entry.level === \"error\"\n ? \"\\x1b[31m✖\\x1b[0m\"\n : entry.level === \"warn\"\n ? \"\\x1b[33m⚠\\x1b[0m\"\n : \"\\x1b[36mℹ\\x1b[0m\";\n console.log(`${prefix} ${entry.msg}`);\n }\n },\n\n getEntries() {\n return [...entries];\n },\n\n clear() {\n entries.length = 0;\n warnedMessages.clear();\n hasWarned = false;\n },\n };\n\n return logger;\n}\n","import { access } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nexport const fileExists = async (path: string): Promise<boolean> => {\n return await access(join(process.cwd(), path))\n .then(() => true)\n .catch(() => false);\n};\n","import { createRequire } from \"node:module\";\nimport type * as vite from \"vite\";\n\nexport const importVite = async (): Promise<typeof vite> => {\n try {\n return createRequire(import.meta.url)(\"rolldown-vite\");\n } catch (_error) {\n try {\n return createRequire(import.meta.url)(\"vite\");\n } catch (_error) {\n throw new Error(\n \"Vite is not installed. Please install it with `npm install vite`.\",\n );\n }\n }\n};\n","import { promises as fs } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { promisify } from \"node:util\";\nimport {\n type BrotliOptions,\n brotliCompress as brotliCompressCb,\n gzip as gzipCb,\n type ZlibOptions,\n} from \"node:zlib\";\nimport type { Plugin } from \"vite\";\n\nconst gzipCompress = promisify(gzipCb);\nconst brotliCompress = promisify(brotliCompressCb);\n\nexport interface ViteCompressOptions {\n /**\n * If true, the plugin will not compress the files.\n *\n * @default false\n */\n disabled?: boolean;\n\n /**\n * If true, the plugin will compress the files using brotli.\n * Can also be an object with brotli options.\n *\n * @default true\n */\n brotli?: boolean | BrotliOptions;\n\n /**\n * If true, the plugin will compress the files using gzip.\n * Can also be an object with gzip options.\n *\n * @default true\n */\n gzip?: boolean | ZlibOptions;\n\n /**\n * A filter to determine which files to compress.\n * Can be a RegExp or a function that returns true for files to compress.\n *\n * @default /\\.(js|mjs|cjs|css|wasm|svg|html)$/\n */\n filter?: RegExp | ((fileName: string) => boolean);\n}\n\nexport function viteCompress(options: ViteCompressOptions = {}): Plugin {\n const { disabled = false, filter = /\\.(js|mjs|cjs|css|wasm|svg)$/ } = options;\n\n return {\n name: \"compress\",\n apply: \"build\",\n async writeBundle(outputOptions, bundle) {\n if (disabled) {\n return;\n }\n\n const now = Date.now();\n\n const outputDir = outputOptions.dir || resolve(process.cwd(), \"dist\");\n\n const files = Object.keys(bundle)\n .filter((fileName) => {\n // [feature]: filter\n if (typeof filter === \"function\") {\n return filter(fileName);\n }\n return filter.test(fileName);\n })\n .map((fileName) => ({\n fileName,\n filePath: join(outputDir, fileName),\n }));\n\n // Compress each file\n const compressionTasks: Promise<void>[] = [];\n\n for (const { filePath } of files) {\n compressionTasks.push(compressFile(options, filePath));\n }\n\n // Wait for all compression tasks to complete\n await Promise.all(compressionTasks);\n\n this.info(\n `Compressed ${files.length} file${files.length > 1 ? \"s\" : \"\"} in ${Date.now() - now}ms.`,\n );\n },\n };\n}\n\nexport async function compressFile(\n options: ViteCompressOptions = {},\n filePath: string,\n) {\n const { brotli = true, gzip = true } = options;\n\n const compressionTasks: Promise<void>[] = [];\n\n const fileContentPromise = fs.readFile(filePath);\n\n if (gzip) {\n const gzipOptions =\n typeof gzip === \"object\"\n ? gzip\n : {\n level: 9, // default gzip compression level\n };\n compressionTasks.push(\n fileContentPromise.then(async (content) => {\n const compressed = await gzipCompress(content, gzipOptions);\n await fs.writeFile(`${filePath}.gz`, compressed);\n }),\n );\n }\n\n if (brotli) {\n const brotliOptions = typeof brotli === \"object\" ? brotli : {};\n compressionTasks.push(\n fileContentPromise.then(async (content) => {\n const compressed = await brotliCompress(content, brotliOptions);\n await fs.writeFile(`${filePath}.br`, compressed);\n }),\n );\n }\n\n await Promise.all(compressionTasks);\n}\n","import type { UserConfig } from \"vite\";\nimport { analyzer as viteAnalyzer } from \"vite-bundle-analyzer\";\nimport { createBufferedLogger } from \"../helpers/createBufferedLogger.ts\";\nimport { importVite } from \"../helpers/importVite.ts\";\nimport {\n type ViteCompressOptions,\n viteCompress,\n} from \"../plugins/viteCompress.ts\";\n\nexport interface BuildClientOptions {\n /**\n * Output directory for client build.\n */\n dist: string;\n\n /**\n * If true, precompress assets using gzip and brotli compression.\n *\n * @default false\n */\n precompress?: ViteCompressOptions | boolean;\n\n /**\n * If true, prerender all static routes found in the $pages directory.\n *\n * @default false\n */\n prerender?: boolean;\n\n /**\n * Build a sitemap.xml file based on the $pages routes.\n */\n sitemap?: {\n hostname: string;\n };\n\n /**\n * Override Vite config options.\n */\n config?: UserConfig;\n\n /**\n * If true, generate build stats report.\n */\n stats?: boolean;\n\n /**\n * If true, suppress build output. Logs are buffered and only shown on failure.\n *\n * @default false\n */\n silent?: boolean;\n}\n\n/**\n * Build client-side bundle with Vite.\n *\n * This task compiles the browser/client code for production,\n * including code splitting, minification, and optional compression.\n */\nexport async function buildClient(opts: BuildClientOptions): Promise<void> {\n const { build: viteBuild, mergeConfig } = await importVite();\n const plugins: any[] = [];\n\n const compress: ViteCompressOptions | undefined = opts.precompress\n ? typeof opts.precompress === \"object\"\n ? opts.precompress\n : {}\n : undefined;\n\n if (opts.stats) {\n plugins.push(\n viteAnalyzer({\n analyzerMode: \"static\",\n }),\n );\n }\n\n if (opts.precompress && compress) {\n plugins.push(viteCompress(compress));\n }\n\n // Create buffered logger for silent mode\n const logger = opts.silent ? createBufferedLogger() : undefined;\n\n const viteBuildClientConfig: UserConfig = {\n mode: \"production\",\n logLevel: opts.silent ? \"silent\" : undefined,\n define: {\n \"process.env.NODE_ENV\": '\"production\"',\n },\n publicDir: \"public\",\n build: {\n chunkSizeWarningLimit: 1000,\n outDir: opts.dist,\n rollupOptions: {\n output: {\n entryFileNames: \"entry.[hash].js\",\n chunkFileNames: \"chunk.[hash].js\",\n assetFileNames: \"asset.[hash][extname]\",\n },\n },\n },\n esbuild: { legalComments: \"none\" },\n customLogger: logger,\n plugins,\n };\n\n try {\n await viteBuild(mergeConfig(viteBuildClientConfig, opts.config ?? {}));\n } catch (error) {\n // Flush buffered logs on failure so user can see what happened\n logger?.flush();\n throw error;\n }\n}\n","import { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport m from \"node:module\";\nimport { join } from \"node:path\";\n\nexport interface GenerateExternalsOptions {\n /**\n * Output directory for package.json.\n */\n distDir: string;\n\n /**\n * List of external package names.\n */\n externals: string[];\n}\n\n/**\n * Generate minimal package.json with pinned external dependencies.\n *\n * This task creates a package.json in the dist directory containing\n * only the external dependencies needed at runtime, with their versions\n * pinned to the currently installed versions.\n */\nexport async function generateExternals(\n opts: GenerateExternalsOptions,\n): Promise<void> {\n const require = m.createRequire(import.meta.filename);\n const deps: Record<string, string> = {};\n\n for (const dep of opts.externals) {\n try {\n const requirePath = require.resolve(dep);\n const pkgPath = `${requirePath.split(`node_modules/${dep}`)[0]}node_modules/${dep}/package.json`;\n const pkg = JSON.parse(await readFile(pkgPath, \"utf-8\"));\n deps[dep] = `^${pkg.version}`;\n } catch (_err) {\n console.warn(`[generateExternals] Cannot find '${dep}' in node_modules`);\n }\n }\n\n const minimalPkg = {\n type: \"module\",\n main: \"index.js\",\n dependencies: deps,\n };\n\n await mkdir(opts.distDir, { recursive: true });\n\n const target = join(opts.distDir, \"package.json\");\n await writeFile(target, JSON.stringify(minimalPkg, null, 2), \"utf-8\");\n}\n","import { readFile, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { AlephaError } from \"alepha\";\nimport type * as vite from \"vite\";\nimport type { UserConfig } from \"vite\";\nimport { analyzer as viteAnalyzer } from \"vite-bundle-analyzer\";\nimport { createBufferedLogger } from \"../helpers/createBufferedLogger.ts\";\nimport { importVite } from \"../helpers/importVite.ts\";\nimport { generateExternals } from \"./generateExternals.ts\";\n\nexport interface BuildServerOptions {\n /**\n * Path to the server entry file.\n */\n entry: string;\n\n /**\n * Output directory for server build.\n */\n distDir: string;\n\n /**\n * Optional client directory name (relative to distDir).\n * If provided, the client template will be embedded in the server output.\n */\n clientDir?: string;\n\n /**\n * Override Vite config options.\n */\n config?: UserConfig;\n\n /**\n * If true, generate build stats report.\n */\n stats?: boolean;\n\n /**\n * If true, suppress build output. Logs are buffered and only shown on failure.\n *\n * @default false\n */\n silent?: boolean;\n}\n\nexport interface BuildServerResult {\n /**\n * The filename of the built server entry (e.g., \"abc123.js\").\n */\n entryFile: string;\n}\n\n/**\n * Build server-side SSR bundle with Vite.\n *\n * This task compiles the server code for production,\n * generates the externals package.json, and creates\n * the dist/index.js entry wrapper.\n */\nexport async function buildServer(\n opts: BuildServerOptions,\n): Promise<BuildServerResult> {\n const { build: viteBuild, mergeConfig } = await importVite();\n const plugins: any[] = [];\n\n if (opts.stats) {\n plugins.push(\n viteAnalyzer({\n analyzerMode: \"static\",\n }),\n );\n }\n\n // Create buffered logger for silent mode\n const logger = opts.silent ? createBufferedLogger() : undefined;\n\n const viteBuildServerConfig: UserConfig = {\n mode: \"production\",\n logLevel: opts.silent ? \"silent\" : undefined,\n define: {\n \"process.env.NODE_ENV\": '\"production\"',\n },\n publicDir: false,\n ssr: {\n noExternal: true,\n },\n build: {\n ssr: opts.entry,\n outDir: `${opts.distDir}/server`,\n minify: true,\n chunkSizeWarningLimit: 10000,\n rollupOptions: {\n output: {\n entryFileNames: \"[hash].js\",\n chunkFileNames: \"[hash].js\",\n assetFileNames: \"[hash][extname]\",\n format: \"esm\",\n },\n },\n },\n esbuild: { legalComments: \"none\", keepNames: true },\n customLogger: logger,\n plugins,\n };\n\n let result: vite.Rollup.RollupOutput | vite.Rollup.RollupOutput[];\n try {\n result = (await viteBuild(\n mergeConfig(viteBuildServerConfig, opts.config || {}),\n )) as vite.Rollup.RollupOutput | vite.Rollup.RollupOutput[];\n } catch (error) {\n // Flush buffered logs on failure so user can see what happened\n logger?.flush();\n throw error;\n }\n\n // Extract resolved config to get externals\n const resolvedConfig = (result as any).resolvedConfig;\n const externals: string[] = resolvedConfig?.ssr?.external ?? [];\n\n // Generate package.json with externals\n await generateExternals({\n distDir: opts.distDir,\n externals,\n });\n\n const entryFile = extractEntryFromBundle(opts.entry, result);\n\n // Embed client template if client was built\n let template = \"\";\n if (opts.clientDir) {\n const index = await readFile(\n `${opts.distDir}/${opts.clientDir}/index.html`,\n \"utf-8\",\n );\n template = `process.env.REACT_SERVER_TEMPLATE ??= \\`${index.replace(/>\\s*</g, \"><\").trim()}\\`;\\n`;\n }\n\n const warning =\n \"// This file was automatically generated. DO NOT MODIFY.\" +\n \"\\n\" +\n \"// Changes to this file will be lost when the code is regenerated.\\n\";\n\n const forceProduction = \"process.env.NODE_ENV ??= 'production';\\n\";\n\n await writeFile(\n `${opts.distDir}/index.js`,\n `${warning}\\n${forceProduction}${template}\\nawait import('./server/${entryFile}');`.trim(),\n );\n\n return { entryFile };\n}\n\n/**\n * Extract entry filename from Vite build result.\n */\nfunction extractEntryFromBundle(\n entry: string,\n result:\n | vite.Rollup.RollupOutput\n | vite.Rollup.RollupOutput[]\n | vite.Rollup.RollupWatcher,\n): string {\n const entryFilePath = entry.startsWith(\"/\")\n ? entry\n : join(process.cwd(), entry);\n\n const rollupOutput = (\n Array.isArray(result) ? result[0] : result\n ) as vite.Rollup.RollupOutput;\n\n const entryFile = rollupOutput.output.find(\n (it) => \"facadeModuleId\" in it && it.facadeModuleId === entryFilePath,\n )?.fileName;\n\n if (!entryFile) {\n throw new AlephaError(\n `Could not find the entry file \"${entryFilePath}\" in the build output. Please check your entry file and try again.`,\n );\n }\n\n return entryFile;\n}\n","import { join } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { type Alepha, AlephaError } from \"alepha\";\nimport { importVite } from \"./importVite.ts\";\n\n/**\n * Import Alepha instance from a transpiled server entry file.\n */\nexport const importAlepha = async (\n entry: string,\n options?: {\n env: Record<string, string>;\n },\n): Promise<Alepha> => {\n if (global.__cli_alepha) {\n return global.__cli_alepha as Alepha;\n }\n\n const { loadEnv } = await importVite();\n\n const env = loadEnv(\"development\", process.cwd(), \"\");\n\n for (const key in env) {\n process.env[key] = env[key];\n }\n\n if (options?.env) {\n for (const key in options.env) {\n process.env[key] = options.env[key];\n }\n }\n\n process.env.ALEPHA_CLI_IMPORT = \"true\";\n process.env.LOG_LEVEL = \"error\";\n process.env.LOG_FORMAT = \"pretty\";\n process.env.NODE_ENV = \"production\";\n\n const entryFile = pathToFileURL(join(process.cwd(), entry)).href;\n const mod = await import(entryFile);\n\n // check if alepha is correctly exported\n if (mod.default) {\n return mod.default;\n }\n\n // else, try with global variable\n const alepha = global.__cli_alepha as Alepha | undefined;\n if (!alepha) {\n throw new AlephaError(\n \"Alepha instance not found. Ensure Alepha is initialized.\",\n );\n }\n\n return alepha;\n};\n","import { cp, mkdir } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { importAlepha } from \"../helpers/importAlepha.ts\";\n\nexport interface CopyAssetsOptions {\n /**\n * Entry point for the built Alepha application.\n */\n entry: string;\n\n /**\n * Output directory for copied assets.\n */\n distDir: string;\n}\n\n/**\n * Copy assets from Alepha packages to the build output directory.\n *\n * This task loads the built Alepha application, reads the\n * `alepha.build.assets` state to find packages with assets,\n * and copies their `/assets` directories to the build output.\n *\n * Used by modules like AlephaServerSwagger to distribute UI files.\n */\nexport async function copyAssets(opts: CopyAssetsOptions): Promise<void> {\n const root = process.cwd();\n const alepha = await importAlepha(opts.entry);\n const assets = alepha.store.get(\"alepha.build.assets\");\n\n if (!assets || assets.length === 0) {\n return;\n }\n\n const require = createRequire(join(root, opts.entry));\n const buildAssetsDir = join(root, `${opts.distDir}/assets`);\n await mkdir(buildAssetsDir).catch(() => null);\n\n for (const pkgName of assets ?? []) {\n const pkgDir = dirname(require.resolve(`${pkgName}/package.json`));\n const assetsPkgDir = resolve(pkgDir, \"assets\");\n await cp(assetsPkgDir, buildAssetsDir, { recursive: true });\n }\n}\n","import { writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nexport interface GenerateCloudflareOptions {\n /**\n * The directory where the build output is placed.\n *\n * @default \"dist\"\n */\n distDir?: string;\n}\n\nconst WARNING_COMMENT =\n \"// This file was automatically generated. DO NOT MODIFY.\\n\" +\n \"// Changes to this file will be lost when the code is regenerated.\\n\";\n\n/**\n * Generate Cloudflare Workers deployment configuration.\n *\n * This task creates:\n * - wrangler.jsonc with worker configuration\n * - worker.js entry point for Cloudflare Workers\n */\nexport async function generateCloudflare(\n opts: GenerateCloudflareOptions = {},\n): Promise<void> {\n const dist = opts.distDir ?? \"dist\";\n const root = process.cwd();\n\n // Get current directory name for worker name\n const parts = root.split(\"/\");\n const name = parts[parts.length - 1];\n\n const wrangler = {\n name: name,\n main: \"./worker.js\",\n compatibility_flags: [\"nodejs_compat\"],\n compatibility_date: \"2025-11-17\",\n };\n\n writeFileSync(\n join(root, dist, \"wrangler.jsonc\"),\n JSON.stringify(wrangler, null, 2),\n );\n\n const workerCode = `\nprocess.env.ALEPHA_SERVERLESS = \"true\";\n\nawait import(\"./index.js\");\n\nexport default {\n fetch: async (request, env, ctx) => {\n\n await __alepha.start();\n const ev = { req: request, res: undefined };\n await __alepha.events.emit(\"web:request\", ev);\n return ev.res;\n },\n};\n`.trim();\n\n writeFileSync(\n join(root, dist, \"worker.js\"),\n `${WARNING_COMMENT}\\n${workerCode}`.trim(),\n );\n}\n","import { cp, writeFile } from \"node:fs/promises\";\nimport { fileExists } from \"../helpers/fileExists.ts\";\n\nexport interface GenerateDockerOptions {\n /**\n * The directory where the build output is placed.\n *\n * @default \"dist\"\n */\n distDir?: string;\n\n /**\n * Docker image name to use in the Dockerfile.\n *\n * @default \"node:24-alpine\"\n */\n image?: string;\n\n /**\n * Command to run in the Docker container.\n *\n * @default \"node\"\n */\n command?: string;\n}\n\n/**\n * Generate Docker deployment configuration.\n *\n * This task creates:\n * - Dockerfile with configurable Node image\n * - Copies drizzle migrations if they exist\n */\nexport async function generateDocker(\n opts: GenerateDockerOptions = {},\n): Promise<void> {\n const distDir = opts.distDir ?? \"dist\";\n const image = opts.image ?? \"node:24-alpine\";\n const command = opts.command ?? \"node\";\n\n // Copy drizzle migrations if they exist\n const hasMigrations = await fileExists(\"drizzle\");\n if (hasMigrations) {\n await cp(\"drizzle\", `${distDir}/drizzle`, {\n recursive: true,\n });\n }\n\n const dockerfile = `# This file was automatically generated. DO NOT MODIFY.\n# Changes to this file will be lost when the code is regenerated.\nFROM ${image}\nWORKDIR /app\n\nCOPY . .\n\nCMD [\"${command}\", \"index.js\"]\n`;\n\n await writeFile(`${distDir}/Dockerfile`, dockerfile);\n}\n","import type { Alepha } from \"alepha\";\nimport { importAlepha } from \"../helpers/importAlepha.ts\";\n\nexport interface GenerateSitemapOptions {\n /**\n * Entry point for the built Alepha application.\n */\n entry: string;\n\n /**\n * Base URL for the sitemap (e.g., \"https://example.com\").\n */\n baseUrl: string;\n\n /**\n * Optional HTML template (for React SSR).\n */\n template?: string;\n}\n\n/**\n * Generate sitemap.xml from Alepha page primitives.\n *\n * This task loads the built Alepha application,\n * queries all page primitives, and generates a sitemap.xml\n * containing URLs for all accessible pages.\n */\nexport async function generateSitemap(\n opts: GenerateSitemapOptions,\n): Promise<string> {\n const alepha = await importAlepha(opts.entry, {\n env: opts.template\n ? {\n REACT_SERVER_TEMPLATE: opts.template,\n }\n : {},\n });\n\n if (!alepha.isConfigured()) {\n await alepha.events.emit(\"configure\", alepha);\n (alepha as any).configured = true;\n }\n\n return generateSitemapFromAlepha(alepha, opts.baseUrl);\n}\n\nfunction generateSitemapFromAlepha(alepha: Alepha, baseUrl: string): string {\n const pages = alepha.primitives(\"page\") as any[];\n const urls: string[] = [];\n\n for (const page of pages) {\n const options = page.options;\n\n // Skip pages with children (parent pages that can't be rendered directly)\n if (options.children) {\n continue;\n }\n\n // Only include static pages or pages without parameters\n if (!options.schema?.params) {\n // Simple page without parameters\n const path = options.path || \"\";\n const url = `${baseUrl.replace(/\\/$/, \"\")}${path === \"\" ? \"/\" : path}`;\n urls.push(url);\n } else if (\n options.static &&\n typeof options.static === \"object\" &&\n options.static.entries\n ) {\n // Static page with predefined entries\n for (const entry of options.static.entries) {\n const path = buildPathFromParams(\n options.path || \"\",\n entry.params || {},\n );\n const url = `${baseUrl.replace(/\\/$/, \"\")}${path}`;\n urls.push(url);\n }\n }\n }\n\n return buildSitemapXml(urls);\n}\n\nfunction buildPathFromParams(\n pathPattern: string,\n params: Record<string, any>,\n): string {\n let path = pathPattern;\n\n for (const [key, value] of Object.entries(params)) {\n path = path.replace(`:${key}`, String(value));\n }\n\n return path || \"/\";\n}\n\nfunction buildSitemapXml(urls: string[]): string {\n const lastMod = new Date().toISOString().split(\"T\")[0];\n const urlEntries = urls\n .map(\n (url) =>\n ` <url>\\n <loc>${escapeXml(url)}</loc>\\n\\t\\t<lastmod>${lastMod}</lastmod>\\n </url>`,\n )\n .join(\"\\n\");\n\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n${urlEntries}\n</urlset>`;\n}\n\nfunction escapeXml(str: string): string {\n return str\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n","import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { importVite } from \"../helpers/importVite.ts\";\n\nexport interface GenerateVercelOptions {\n /**\n * The directory where the build output is placed.\n *\n * @default \"dist\"\n */\n distDir?: string;\n\n /**\n * The name of the client directory.\n *\n * @default \"public\"\n */\n clientDir?: string;\n\n /**\n * Vercel configuration options.\n */\n config?: VercelConfig;\n}\n\nexport interface VercelConfig {\n projectName?: string;\n orgId?: string;\n projectId?: string;\n config?: Record<string, any> & {\n crons?: Array<{\n path: string;\n schedule: string;\n }>;\n };\n}\n\nconst WARNING_COMMENT =\n \"// This file was automatically generated. DO NOT MODIFY.\\n\" +\n \"// Changes to this file will be lost when the code is regenerated.\\n\";\n\n/**\n * Generate Vercel deployment configuration.\n *\n * This task creates:\n * - vercel.json with route rewrites\n * - api/index.js entry point for Vercel serverless function\n * - .vercel/project.json if VERCEL_PROJECT_ID and VERCEL_ORG_ID are set\n */\nexport async function generateVercel(\n opts: GenerateVercelOptions = {},\n): Promise<void> {\n const distDir = opts.distDir ?? \"dist\";\n const clientDir = opts.clientDir ?? \"public\";\n const { loadEnv } = await importVite();\n\n const env = loadEnv(\"production\", process.cwd(), \"\");\n\n // Ensure the api directory exists\n if (!existsSync(`${distDir}/api`)) {\n mkdirSync(`${distDir}/api`);\n }\n\n // Add the only one entry point for Vercel\n writeFileSync(\n `${distDir}/api/index.js`,\n `${WARNING_COMMENT}\nimport \"../index.js\";\n\nexport default async function (req, res) {\n\\tawait __alepha.start();\n\\t__alepha.events.emit(\"node:request\", { req, res });\n}\n`,\n );\n\n // Always generate a vercel.json file\n writeFileSync(\n `${distDir}/vercel.json`,\n JSON.stringify(\n {\n ...opts?.config?.config,\n rewrites: [\n {\n source: \"/(.*)\",\n destination: \"/api/index.js\",\n },\n ],\n buildCommand: \"\",\n installCommand: \"\",\n outputDirectory: clientDir,\n },\n null,\n \" \",\n ),\n );\n\n // Generate .vercel/project.json if VERCEL_PROJECT_ID and VERCEL_ORG_ID are set\n const projectId = env.VERCEL_PROJECT_ID ?? opts.config?.projectId;\n const projectName = env.VERCEL_PROJECT_NAME ?? opts.config?.projectName;\n const orgId = env.VERCEL_ORG_ID ?? opts.config?.orgId;\n\n if (projectId && orgId) {\n try {\n mkdirSync(`${distDir}/.vercel`, { recursive: true });\n } catch (_e) {\n // Ignore error if directory already exists\n }\n\n writeFileSync(\n `${distDir}/.vercel/project.json`,\n JSON.stringify(\n {\n projectId,\n projectName,\n orgId,\n },\n null,\n \" \",\n ),\n );\n }\n\n // If /public does not exist, create an empty one to avoid Vercel errors\n if (!existsSync(`${distDir}/${clientDir}`)) {\n mkdirSync(`${distDir}/${clientDir}`, { recursive: true });\n writeFileSync(`${distDir}/${clientDir}/.keep`, \"\");\n }\n}\n","import { mkdir, writeFile } from \"node:fs/promises\";\nimport type { Alepha } from \"alepha\";\nimport { importAlepha } from \"../helpers/importAlepha.ts\";\nimport {\n compressFile,\n type ViteCompressOptions,\n} from \"../plugins/viteCompress.ts\";\n\nexport interface PrerenderPagesOptions {\n /**\n * Entry point for the built Alepha application.\n */\n entry: string;\n\n /**\n * Client dist directory for output files.\n */\n dist: string;\n\n /**\n * Optional compression options.\n */\n compress?: ViteCompressOptions | boolean;\n}\n\nexport interface PrerenderPagesResult {\n /**\n * Number of pages pre-rendered.\n */\n count: number;\n}\n\n/**\n * Pre-render static pages defined in the Alepha application.\n *\n * This task loads the built Alepha application, queries all page\n * primitives with `static: true`, and generates static HTML files\n * for each page. Supports pages with parameterized routes via\n * `static.entries` configuration.\n */\nexport async function prerenderPages(\n opts: PrerenderPagesOptions,\n): Promise<PrerenderPagesResult> {\n const alepha = await importAlepha(opts.entry);\n\n const now = Date.now();\n\n if (!alepha.isConfigured()) {\n await alepha.events.emit(\"configure\", alepha);\n (alepha as any).configured = true;\n }\n\n return await prerenderFromAlepha(alepha, opts.dist, opts.compress);\n}\n\nasync function prerenderFromAlepha(\n alepha: Alepha,\n dist: string,\n compress?: ViteCompressOptions | boolean,\n): Promise<PrerenderPagesResult> {\n let count = 0;\n const pages = alepha.primitives(\"page\") as any[];\n\n for (const page of pages) {\n const options = page.options;\n\n if (options.children) {\n continue;\n }\n\n if (!options.static) {\n continue;\n }\n\n const config = typeof options.static === \"object\" ? options.static : {};\n\n if (!options.schema?.params) {\n count += 1;\n await renderFile(page, {}, dist, compress);\n continue;\n }\n\n if (config.entries) {\n for (const entry of config.entries) {\n count += 1;\n await renderFile(page, entry, dist, compress);\n }\n }\n }\n\n return { count };\n}\n\nasync function renderFile(\n page: any,\n options: any,\n dist: string,\n compress?: ViteCompressOptions | boolean,\n) {\n const { html, state } = await page.render({\n html: true,\n ...options,\n });\n\n const pathname = state.url.pathname;\n const filepath = `${dist}${pathname === \"/\" ? \"/index\" : pathname}.html`;\n\n await mkdir(filepath.substring(0, filepath.lastIndexOf(\"/\")), {\n recursive: true,\n });\n\n await writeFile(filepath, html);\n\n if (compress) {\n await compressFile(typeof compress === \"object\" ? compress : {}, filepath);\n }\n}\n","import path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { Alepha, State } from \"alepha\";\nimport type { ResolvedConfig, ViteDevServer } from \"vite\";\nimport { importVite } from \"../helpers/importVite.ts\";\n\nexport interface AlephaRunnerOptions {\n /**\n * Path to the server entry file.\n */\n entry: string;\n\n /**\n * Enable debug logging.\n */\n debug?: boolean;\n}\n\nexport interface AlephaRunnerState {\n root: string;\n started: boolean;\n app?: Alepha;\n config?: ResolvedConfig;\n lock?: PromiseWithResolvers<void>;\n log: (...msg: string[]) => void;\n entry: string;\n onReload?: () => void;\n}\n\n/**\n * Create an Alepha runner for development.\n *\n * The runner manages the lifecycle of an Alepha application during\n * Vite dev server operation, handling start/stop/restart and HMR.\n */\nexport function createAlephaRunner(opts: AlephaRunnerOptions): AlephaRunner {\n const state: AlephaRunnerState = {\n root: process.cwd().replace(/\\\\/g, \"/\"),\n started: false,\n log: opts.debug ? (...msg: string[]) => console.log(...msg) : () => {},\n entry: opts.entry,\n onReload: () => {},\n };\n\n return new AlephaRunner(state);\n}\n\nexport class AlephaRunner {\n protected state: AlephaRunnerState;\n\n constructor(state: AlephaRunnerState) {\n this.state = state;\n }\n\n /**\n * Set resolved Vite config.\n */\n setConfig(config: ResolvedConfig): void {\n this.state.config = config;\n }\n\n /**\n * Check if SSR is enabled for the running app.\n */\n isSsrEnabled(): boolean {\n if (!this.state.app) return false;\n return (\n (this.state.app.store.get(\"alepha.react.server.ssr\" as keyof State) as\n | boolean\n | undefined) ?? false\n );\n }\n\n /**\n * Check if app is started.\n */\n get isStarted(): boolean {\n return this.state.started;\n }\n\n /**\n * Get the running Alepha app instance.\n */\n get app(): Alepha | undefined {\n return this.state.app;\n }\n\n /**\n * Start the Alepha application.\n */\n async start(server: ViteDevServer): Promise<void> {\n const { loadEnv } = await importVite();\n\n if (this.state.started) {\n await this.restart(server, true);\n return;\n }\n\n if (!this.state.config) {\n this.state.log(\"[DEBUG] No config - skip starting\");\n return;\n }\n\n this.state.onReload?.();\n\n this.state.log(\"[DEBUG] Starting Alepha app...\");\n\n this.state.started = false;\n this.state.app = undefined;\n\n const serverEntryPath = path.resolve(\n this.state.config.root,\n this.state.entry,\n );\n const fileUrl = pathToFileURL(`${serverEntryPath}`).href;\n const env = loadEnv(\"development\", this.state.config.root, \"\");\n const before = { ...process.env };\n\n for (const key in env) {\n process.env[key] = env[key];\n }\n\n process.env.NODE_ENV ??= \"development\";\n process.env.VITE_ALEPHA_DEV = \"true\";\n process.env.SERVER_HOST ??=\n typeof server.config.server.host === \"string\"\n ? server.config.server.host\n : \"localhost\";\n process.env.SERVER_PORT ??= String(server.config.server.port || \"5173\");\n\n try {\n const now = Date.now();\n await server.ssrLoadModule(fileUrl);\n this.state.log(`[DEBUG] Alepha app loaded in ${Date.now() - now}ms`);\n await new Promise((r) => setTimeout(r, 10));\n\n this.state.app = (globalThis as any).__alepha;\n if (!this.state.app) {\n this.state.log(\"[DEBUG] No app found - skip starting\");\n return;\n }\n\n this.state.app.store.set(\"alepha.node.server\" as any, server.httpServer);\n\n await this.state.app.start();\n this.state.started = true;\n\n process.env = { ...before };\n\n this.state.log(\"[DEBUG] Starting Done!\");\n } catch (e) {\n if (e instanceof Error) {\n let it: any = e;\n do {\n server.ssrFixStacktrace(it);\n it = it.cause;\n } while (it instanceof Error);\n\n server.ssrFixStacktrace(e);\n if (e.cause instanceof Error) {\n server.ssrFixStacktrace(e.cause);\n }\n this.state.app?.log?.error(\"App failed to start:\", e);\n this.state.app?.log?.info(\"Waiting for changes to restart...\");\n }\n this.state.log(\"[DEBUG] Alepha app start error\");\n this.state.started = false;\n }\n }\n\n /**\n * Stop the Alepha application.\n */\n async stop(): Promise<void> {\n if (this.state.app?.stop && this.state.started) {\n this.state.log(\"[DEBUG] Stopping Alepha app...\");\n await this.state.app.stop();\n this.state.started = false;\n this.state.log(\"[DEBUG] Stopping Done!\");\n } else {\n this.state.log(\"[DEBUG] Alepha app not started - skip stop\");\n }\n }\n\n /**\n * Restart the Alepha application.\n *\n * @returns true if the restart was skipped due to locking\n */\n async restart(server: ViteDevServer, invalidate?: boolean): Promise<boolean> {\n if (this.state.lock) {\n this.state.log(\"[DEBUG] STILL LOCKING\");\n return true;\n }\n\n this.state.log(\"[DEBUG] LOCK RESTART\");\n this.state.lock = Promise.withResolvers();\n\n const now = Date.now();\n this.state.log(\"[DEBUG] RESTART\");\n await this.stop();\n this.state.log(`[DEBUG] RESTART (stop) in ${Date.now() - now}ms`);\n\n if (invalidate) {\n server.moduleGraph.invalidateAll();\n }\n\n await this.start(server);\n this.state.log(`[DEBUG] RESTART OK in ${Date.now() - now}ms`);\n\n setTimeout(() => {\n this.state.log(\"[DEBUG] UNLOCK RESTART\");\n this.state.lock?.resolve();\n this.state.lock = undefined;\n }, 500);\n\n return false;\n }\n\n /**\n * Send reload event to client.\n */\n sendReload(server: ViteDevServer): void {\n server.ws.send({\n type: \"custom\",\n event: \"alepha:reload\",\n data: {},\n });\n }\n}\n\n/**\n * Check if a URL path is a Vite internal file.\n */\nexport function isViteInternalPath(pathname: string): boolean {\n const [path] = pathname.split(\"?\");\n\n // Vite internal files\n if (\n path.startsWith(\"/@\") ||\n path.startsWith(\"/src\") ||\n path.includes(\"/node_modules/\")\n ) {\n return true;\n }\n\n return false;\n}\n","import { readFile, unlink, writeFile } from \"node:fs/promises\";\nimport type { Plugin, UserConfig } from \"vite\";\nimport { boot } from \"../helpers/boot.ts\";\nimport { fileExists } from \"../helpers/fileExists.ts\";\nimport {\n type BuildClientOptions,\n buildClient,\n buildServer,\n copyAssets,\n type GenerateDockerOptions,\n generateCloudflare,\n generateDocker,\n generateSitemap,\n generateVercel,\n prerenderPages,\n type VercelConfig,\n} from \"../tasks/index.ts\";\n\nexport interface ViteAlephaBuildOptions {\n /**\n * Path to the entry file for the server build.\n * If empty, SSR build will be skipped.\n */\n serverEntry?: string | false;\n\n /**\n * Set false to skip the client build.\n * This is useful if you only want to build the server-side application.\n */\n client?: false | Partial<BuildClientOptions>;\n\n /**\n * If true, the build will be optimized for Vercel deployment.\n *\n * If `VERCEL_PROJECT_ID` and `VERCEL_ORG_ID` environment variables are set, .vercel will be generated with the correct configuration.\n *\n * @default false\n */\n vercel?: boolean | VercelConfig;\n\n /**\n * If true, the build will generate Cloudflare Workers configuration.\n *\n * @default false\n */\n cloudflare?: boolean;\n\n /**\n * If true, the build will be optimized for Docker deployment.\n * Additionally, it will generate a Dockerfile in the dist directory.\n */\n docker?: boolean | Omit<GenerateDockerOptions, \"distDir\">;\n\n /**\n * If true, build statistics will be printed after the build completes.\n */\n stats?: boolean;\n}\n\n/**\n * Build modes controlled by ALEPHA_BUILD_MODE environment variable:\n * - \"cli\": Skip plugin entirely, CLI handles all tasks\n * - \"client\": Only build client bundle\n * - \"server\": Only build server bundle\n * - undefined/other: Full build (default behavior)\n */\nexport type AlephaBuildMode = \"cli\" | \"client\" | \"server\";\n\n/**\n * Alepha build plugin for Vite.\n *\n * This plugin orchestrates the complete build process:\n * 1. Build client (if index.html exists)\n * 2. Build server (SSR)\n * 3. Copy assets from packages\n * 4. Pre-render static pages (if enabled)\n * 5. Generate sitemap (if enabled)\n * 6. Generate deployment config (Vercel/Cloudflare/Docker)\n *\n * Build mode can be controlled via ALEPHA_BUILD_MODE env var for CLI integration.\n */\nexport async function viteAlephaBuild(\n options: ViteAlephaBuildOptions = {},\n): Promise<Plugin> {\n const entry = options.serverEntry ?? (await boot.getServerEntry());\n const distDir = \"dist\";\n const clientDir = \"public\";\n\n let rootConfig: UserConfig = {};\n\n return {\n name: \"alepha-build\",\n apply: \"build\",\n config(config, ctx) {\n const buildMode = process.env.ALEPHA_BUILD_MODE as\n | AlephaBuildMode\n | undefined;\n\n // CLI mode: plugin does nothing, CLI handles everything\n if (buildMode === \"cli\") {\n return;\n }\n\n // For now, we run two separate builds: one for the client and one for the server\n // We distinguish them using an environment variable\n if (!process.env.VITE_DOUBLE_BUILD_DONE) {\n rootConfig = config;\n }\n\n if (ctx.isSsrBuild || !process.env.VITE_DOUBLE_BUILD_DONE) {\n // Server build, so we don't need the public directory\n config.publicDir = false;\n } else {\n // Client build, so we need the public directory\n config.publicDir = \"public\";\n }\n },\n async buildStart() {\n const buildMode = process.env.ALEPHA_BUILD_MODE as\n | AlephaBuildMode\n | undefined;\n\n // CLI mode: skip entirely\n if (buildMode === \"cli\") {\n return;\n }\n\n if (process.env.VITE_DOUBLE_BUILD_DONE === \"true\") {\n return;\n }\n\n process.env.VITE_DOUBLE_BUILD_DONE = \"true\";\n\n const hasClient =\n options.client !== false && (await fileExists(\"index.html\"));\n\n const buildClientOptions =\n typeof options.client === \"object\" ? options.client : {};\n\n const stats = options.stats ?? process.env.ALEPHA_BUILD_STATS === \"true\";\n\n // Client-only mode\n if (buildMode === \"client\") {\n if (hasClient) {\n await buildClient({\n ...buildClientOptions,\n config: rootConfig,\n dist: `${distDir}/${clientDir}`,\n stats,\n });\n }\n process.exit(0);\n }\n\n // Server-only mode\n if (buildMode === \"server\") {\n if (entry) {\n // Check if client was already built (template exists)\n let clientBuilt = false;\n try {\n await readFile(`${distDir}/${clientDir}/index.html`, \"utf-8\");\n clientBuilt = true;\n } catch {\n // No client build\n }\n\n await buildServer({\n config: {\n base: rootConfig.base || \"\",\n },\n entry,\n distDir,\n clientDir: clientBuilt ? clientDir : undefined,\n stats,\n });\n }\n process.exit(0);\n }\n\n // Full build mode (default)\n\n // Task 1: Build client\n if (hasClient) {\n await buildClient({\n ...buildClientOptions,\n config: rootConfig,\n dist: `${distDir}/${clientDir}`,\n stats,\n });\n }\n\n let template = \"\";\n if (hasClient) {\n // Load output index.html for template embedding\n template = await readFile(\n `${distDir}/${clientDir}/index.html`,\n \"utf-8\",\n );\n }\n\n // Task 2: Build server\n if (entry) {\n await buildServer({\n config: {\n base: rootConfig.base || \"\",\n },\n entry,\n distDir,\n clientDir: hasClient ? clientDir : undefined,\n stats,\n });\n\n // Server will handle index.html if both client & server are built\n if (hasClient && options.serverEntry !== false) {\n await unlink(`${distDir}/${clientDir}/index.html`);\n }\n\n // Task 3: Copy assets (swagger ui & others)\n await copyAssets({\n entry: `${distDir}/index.js`,\n distDir,\n });\n }\n\n // Task 4: Generate sitemap\n if (buildClientOptions.sitemap && entry) {\n await writeFile(\n `${distDir}/${clientDir}/sitemap.xml`,\n await generateSitemap({\n entry: `${distDir}/index.js`,\n baseUrl: buildClientOptions.sitemap.hostname,\n }),\n );\n }\n\n // Task 5: Pre-render static pages\n if (buildClientOptions.prerender && template) {\n await prerenderPages({\n dist: `${distDir}/${clientDir}`,\n entry: `${distDir}/index.js`,\n compress: buildClientOptions.precompress,\n });\n }\n\n // Task 6: Generate deployment configurations\n if (options.vercel) {\n const config =\n typeof options.vercel === \"boolean\" ? {} : options.vercel;\n await generateVercel({\n distDir,\n clientDir,\n config,\n });\n }\n\n if (options.cloudflare) {\n await generateCloudflare({\n distDir,\n });\n }\n\n if (options.docker) {\n const dockerOpts =\n typeof options.docker === \"boolean\" ? {} : options.docker;\n await generateDocker({\n distDir,\n ...dockerOpts,\n });\n }\n\n // Prevent the default build from running again\n process.exit(0);\n },\n };\n}\n","import type { Plugin, ResolvedConfig } from \"vite\";\nimport { boot } from \"../helpers/boot.ts\";\nimport { createAlephaRunner, isViteInternalPath } from \"../tasks/runAlepha.ts\";\n\nexport interface ViteAlephaDevOptions {\n /**\n * Path to the entry file for the server build.\n * If empty, plugin will be disabled.\n */\n serverEntry?: string | false;\n\n /**\n * If true, enables debug logging.\n *\n * @default false\n */\n debug?: boolean;\n}\n\n/**\n * Plug Alepha into Vite development server.\n *\n * This plugin manages the Alepha application lifecycle during development,\n * handling hot module replacement and request forwarding.\n */\nexport async function viteAlephaDev(\n options: ViteAlephaDevOptions = {},\n): Promise<Plugin> {\n let entry = options.serverEntry;\n if (!entry) {\n entry = await boot.getServerEntry();\n if (!entry) {\n return {\n name: \"alepha-dev\",\n apply: \"serve\",\n config() {},\n };\n }\n }\n\n const runner = createAlephaRunner({\n entry,\n debug: options.debug,\n });\n\n return {\n name: \"alepha-dev\",\n apply: \"serve\",\n configResolved(resolvedConfig: ResolvedConfig) {\n runner.setConfig(resolvedConfig);\n },\n async handleHotUpdate(ctx) {\n if (options.debug) {\n console.log(\"[DEBUG] HMR\", ctx.file);\n }\n\n if (ctx.file.includes(\"/.idea/\")) {\n return [];\n }\n\n const isServerOnly = !ctx.modules[0]?._clientModule;\n const isBrowserOnly = !ctx.modules[0]?._ssrModule;\n const isSsrEnabled = runner.isSsrEnabled();\n\n if (isBrowserOnly) {\n if (options.debug) {\n console.log(\n \"[DEBUG] HMR - browser only - no reason to reload server\",\n );\n }\n return;\n }\n\n const root = process.cwd().replace(/\\\\/g, \"/\");\n const invalidate = !ctx.file.startsWith(root);\n if (invalidate && options.debug) {\n console.log(\"[DEBUG] HMR - outside root - invalidate all\");\n }\n\n if (!isSsrEnabled && isServerOnly) {\n await runner.restart(ctx.server, invalidate);\n return [];\n }\n\n if (isSsrEnabled && ctx.modules[0]) {\n const skip = await runner.restart(ctx.server, invalidate);\n if (skip) {\n return [];\n }\n\n if (!runner.isStarted) {\n if (options.debug) {\n console.log(\"[DEBUG] HMR - abort due to app not started\");\n }\n return [];\n }\n\n if (isServerOnly && runner.isStarted) {\n runner.sendReload(ctx.server);\n return [];\n }\n }\n },\n async configureServer(server) {\n // Forward vite request to alepha server\n server.middlewares.use((req, res, next) => {\n if (\n runner.isStarted &&\n runner.app &&\n req.url &&\n !isViteInternalPath(req.url)\n ) {\n // Patch res.end to detect if alepha handled the request\n // If not, we call next() to let vite handle it (e.g. for static files)\n let ended = false;\n\n const writeHead = res.writeHead.bind(res);\n res.writeHead = (...args: any[]) => {\n ended = true;\n return writeHead(args[0], args[1], args[2]);\n };\n\n return runner.app.events\n .emit(\"node:request\" as any, { req, res })\n .then(() => {\n if (!ended) {\n next();\n }\n });\n }\n next();\n });\n\n server.config.logger.info = (msg: string) => {\n runner.app?.log?.info(msg.trim());\n };\n\n server.config.logger.clearScreen = () => {};\n\n await runner.start(server);\n },\n async closeBundle() {\n // Cleanup handled by runner\n },\n };\n}\n","import { createRequire } from \"node:module\";\nimport { OPTIONS } from \"alepha\";\nimport type { Plugin } from \"vite\";\nimport {\n type ViteAlephaBuildOptions,\n viteAlephaBuild,\n} from \"./viteAlephaBuild.ts\";\nimport { type ViteAlephaDevOptions, viteAlephaDev } from \"./viteAlephaDev.ts\";\n\nexport type ViteAlephaOptions = ViteAlephaDevOptions &\n ViteAlephaBuildOptions & {\n react?: false;\n };\n\nexport function viteAlepha(\n options: ViteAlephaOptions = {},\n): (Plugin | Promise<Plugin>)[] {\n if (process.env.NODE_ENV === \"test\") {\n return [];\n }\n\n const plugins: (Plugin | Promise<Plugin>)[] & { [OPTIONS]?: any } = [];\n\n if (options.react !== false) {\n try {\n const { default: viteReact } = createRequire(import.meta.url)(\n \"@vitejs/plugin-react\",\n );\n plugins.push(viteReact());\n } catch (e) {}\n }\n\n plugins.push(viteAlephaDev(options), viteAlephaBuild(options));\n plugins[OPTIONS] = options;\n\n return plugins;\n}\n","import type { Alepha } from \"alepha\";\n\n// Vite re-exports\nexport { defineConfig } from \"vite\";\n// Helpers (for advanced use)\nexport * from \"./helpers/boot.ts\";\nexport * from \"./helpers/createBufferedLogger.ts\";\n// Plugins (public API)\nexport * from \"./plugins/viteAlepha.ts\";\nexport * from \"./plugins/viteAlephaBuild.ts\";\nexport * from \"./plugins/viteAlephaDev.ts\";\nexport * from \"./plugins/viteCompress.ts\";\n// Tasks (for CLI integration)\nexport * from \"./tasks/index.ts\";\n\ndeclare global {\n var __cli_alepha: Alepha;\n}\n\n/**\n * Plugin vite for Alepha framework.\n *\n * This module provides Vite plugins and configurations to integrate Alepha applications with Vite's build and development processes.\n *\n * @example\n * ```ts\n * import { defineConfig } from \"vite\";\n * import { viteAlepha } from \"alepha/vite\";\n *\n * export default defineConfig({\n * plugins: [viteAlepha()],\n * // other Vite configurations...\n * });\n * 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K;MAAK,CAAC,CACzC,WAAW;AACV,UAAI,CAAC,MACH,OAAM;OAER;;AAEN,UAAM;KACN;AAEF,UAAO,OAAO,OAAO,QAAQ,QAAgB;AAC3C,WAAO,KAAK,KAAK,KAAK,IAAI,MAAM,CAAC;;AAGnC,UAAO,OAAO,OAAO,oBAAoB;AAEzC,SAAM,OAAO,MAAM,OAAO;;EAE5B,MAAM,cAAc;EAGrB;;;;;AClIH,SAAgB,WACd,UAA6B,EAAE,EACD;AAC9B,KAAI,QAAQ,IAAI,aAAa,OAC3B,QAAO,EAAE;CAGX,MAAMC,UAA8D,EAAE;AAEtE,KAAI,QAAQ,UAAU,MACpB,KAAI;EACF,MAAM,EAAE,SAAS,cAAc,cAAc,OAAO,KAAK,IAAI,CAC3D,uBACD;AACD,UAAQ,KAAK,WAAW,CAAC;UAClB,GAAG;AAGd,SAAQ,KAAK,cAAc,QAAQ,EAAE,gBAAgB,QAAQ,CAAC;AAC9D,SAAQ,WAAW;AAEnB,QAAO"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { $env, $inject, $module, Alepha, AlephaError,
|
|
1
|
+
import { $env, $inject, $module, Alepha, AlephaError, KIND, Primitive, TypeBoxValue, createPrimitive, t } from "alepha";
|
|
2
2
|
import { $topic, AlephaTopic } from "alepha/topic";
|
|
3
3
|
import { $logger } from "alepha/logger";
|
|
4
4
|
|
|
5
|
-
//#region src/websocket/
|
|
5
|
+
//#region src/websocket/primitives/$channel.ts
|
|
6
6
|
/**
|
|
7
7
|
* Defines a WebSocket channel with specified client and server message schemas.
|
|
8
8
|
*
|
|
@@ -66,10 +66,10 @@ import { $logger } from "alepha/logger";
|
|
|
66
66
|
* ```
|
|
67
67
|
*/
|
|
68
68
|
const $channel = (options) => {
|
|
69
|
-
return
|
|
69
|
+
return createPrimitive(ChannelPrimitive, options);
|
|
70
70
|
};
|
|
71
|
-
var
|
|
72
|
-
$channel[KIND] =
|
|
71
|
+
var ChannelPrimitive = class extends Primitive {};
|
|
72
|
+
$channel[KIND] = ChannelPrimitive;
|
|
73
73
|
|
|
74
74
|
//#endregion
|
|
75
75
|
//#region src/websocket/providers/WebSocketServerProvider.ts
|
|
@@ -82,7 +82,7 @@ $channel[KIND] = ChannelDescriptor;
|
|
|
82
82
|
var WebSocketServerProvider = class {};
|
|
83
83
|
|
|
84
84
|
//#endregion
|
|
85
|
-
//#region src/websocket/
|
|
85
|
+
//#region src/websocket/primitives/$websocket.ts
|
|
86
86
|
/**
|
|
87
87
|
* Defines a WebSocket server endpoint for a specific channel.
|
|
88
88
|
*
|
|
@@ -125,9 +125,9 @@ var WebSocketServerProvider = class {};
|
|
|
125
125
|
* ```
|
|
126
126
|
*/
|
|
127
127
|
const $websocket = (options) => {
|
|
128
|
-
return
|
|
128
|
+
return createPrimitive(WebSocketPrimitive, options);
|
|
129
129
|
};
|
|
130
|
-
var
|
|
130
|
+
var WebSocketPrimitive = class extends Primitive {
|
|
131
131
|
webSocketServerProvider = $inject(WebSocketServerProvider);
|
|
132
132
|
onInit() {
|
|
133
133
|
this.webSocketServerProvider.registerEndpoint(this.options);
|
|
@@ -164,7 +164,7 @@ var WebSocketDescriptor = class extends Descriptor {
|
|
|
164
164
|
await this.webSocketServerProvider.emit(this.options.channel.options.path, options);
|
|
165
165
|
}
|
|
166
166
|
};
|
|
167
|
-
$websocket[KIND] =
|
|
167
|
+
$websocket[KIND] = WebSocketPrimitive;
|
|
168
168
|
|
|
169
169
|
//#endregion
|
|
170
170
|
//#region src/websocket/services/WebSocketClient.ts
|
|
@@ -789,7 +789,7 @@ var WebSocketTopicService = class {
|
|
|
789
789
|
//#region src/websocket/index.browser.ts
|
|
790
790
|
const AlephaWebSocket = $module({
|
|
791
791
|
name: "alepha.websocket",
|
|
792
|
-
|
|
792
|
+
primitives: [$channel, $websocket],
|
|
793
793
|
services: [WebSocketClient],
|
|
794
794
|
register: (alepha) => {
|
|
795
795
|
alepha.with(AlephaTopic);
|
|
@@ -798,5 +798,5 @@ const AlephaWebSocket = $module({
|
|
|
798
798
|
});
|
|
799
799
|
|
|
800
800
|
//#endregion
|
|
801
|
-
export { $channel, $websocket, AlephaWebSocket,
|
|
801
|
+
export { $channel, $websocket, AlephaWebSocket, ChannelPrimitive, RoomManager, WebSocketChannelConnection, WebSocketClient, WebSocketConnectionError, WebSocketError, WebSocketPrimitive, WebSocketServerProvider, WebSocketState, WebSocketTopicService, WebSocketValidationError };
|
|
802
802
|
//# sourceMappingURL=index.browser.js.map
|