alepha 0.21.2 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/api/audits/index.browser.js.map +1 -1
- package/dist/api/audits/index.d.ts +393 -403
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/audits/index.js +25 -56
- package/dist/api/audits/index.js.map +1 -1
- package/dist/api/files/index.browser.js +31 -1
- package/dist/api/files/index.browser.js.map +1 -1
- package/dist/api/files/index.d.ts +313 -208
- package/dist/api/files/index.d.ts.map +1 -1
- package/dist/api/files/index.js +152 -42
- package/dist/api/files/index.js.map +1 -1
- package/dist/api/jobs/index.browser.js +2 -2
- package/dist/api/jobs/index.browser.js.map +1 -1
- package/dist/api/jobs/index.d.ts +282 -285
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/jobs/index.js +39 -33
- package/dist/api/jobs/index.js.map +1 -1
- package/dist/api/keys/index.d.ts +217 -222
- package/dist/api/keys/index.d.ts.map +1 -1
- package/dist/api/keys/index.js.map +1 -1
- package/dist/api/notifications/index.browser.js.map +1 -1
- package/dist/api/notifications/index.d.ts +188 -195
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/notifications/index.js.map +1 -1
- package/dist/api/oauth/index.d.ts +71 -76
- package/dist/api/oauth/index.d.ts.map +1 -1
- package/dist/api/oauth/index.js.map +1 -1
- package/dist/api/organizations/index.browser.js.map +1 -1
- package/dist/api/organizations/index.d.ts +104 -109
- package/dist/api/organizations/index.d.ts.map +1 -1
- package/dist/api/organizations/index.js.map +1 -1
- package/dist/api/parameters/index.browser.js +43 -16
- package/dist/api/parameters/index.browser.js.map +1 -1
- package/dist/api/parameters/index.d.ts +488 -344
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/parameters/index.js +175 -35
- package/dist/api/parameters/index.js.map +1 -1
- package/dist/api/payments/index.d.ts +396 -402
- package/dist/api/payments/index.d.ts.map +1 -1
- package/dist/api/payments/index.js.map +1 -1
- package/dist/api/subscriptions/index.d.ts +644 -652
- package/dist/api/subscriptions/index.d.ts.map +1 -1
- package/dist/api/subscriptions/index.js +1 -1
- package/dist/api/subscriptions/index.js.map +1 -1
- package/dist/api/users/index.browser.js +7 -0
- package/dist/api/users/index.browser.js.map +1 -1
- package/dist/api/users/index.d.ts +1106 -1005
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +307 -64
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.browser.js.map +1 -1
- package/dist/api/verifications/index.d.ts +137 -143
- package/dist/api/verifications/index.d.ts.map +1 -1
- package/dist/api/verifications/index.js.map +1 -1
- package/dist/background/index.d.ts +95 -0
- package/dist/background/index.d.ts.map +1 -0
- package/dist/background/index.js +121 -0
- package/dist/background/index.js.map +1 -0
- package/dist/background/index.workerd.js +110 -0
- package/dist/background/index.workerd.js.map +1 -0
- package/dist/batch/index.d.ts +5 -7
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/batch/index.js.map +1 -1
- package/dist/bin/index.js.map +1 -1
- package/dist/bucket/index.d.ts +76 -54
- package/dist/bucket/index.d.ts.map +1 -1
- package/dist/bucket/index.js +58 -11
- package/dist/bucket/index.js.map +1 -1
- package/dist/bucket/index.workerd.js +200 -5
- package/dist/bucket/index.workerd.js.map +1 -1
- package/dist/cache/core/index.d.ts +7 -10
- package/dist/cache/core/index.d.ts.map +1 -1
- package/dist/cache/core/index.js.map +1 -1
- package/dist/cache/core/index.workerd.js.map +1 -1
- package/dist/cache/database/index.d.ts +22 -26
- package/dist/cache/database/index.d.ts.map +1 -1
- package/dist/cache/database/index.js.map +1 -1
- package/dist/cache/redis/index.d.ts +4 -7
- package/dist/cache/redis/index.d.ts.map +1 -1
- package/dist/cache/redis/index.js.map +1 -1
- package/dist/captcha/index.d.ts +3 -6
- package/dist/captcha/index.d.ts.map +1 -1
- package/dist/captcha/index.js.map +1 -1
- package/dist/cli/config/index.d.ts.map +1 -1
- package/dist/cli/config/index.js.map +1 -1
- package/dist/cli/core/index.d.ts +458 -249
- package/dist/cli/core/index.d.ts.map +1 -1
- package/dist/cli/core/index.js +372 -660
- package/dist/cli/core/index.js.map +1 -1
- package/dist/cli/devtools/index.d.ts +3 -5
- package/dist/cli/devtools/index.d.ts.map +1 -1
- package/dist/cli/devtools/index.js.map +1 -1
- package/dist/cli/i18n/index.d.ts +20 -17
- package/dist/cli/i18n/index.d.ts.map +1 -1
- package/dist/cli/i18n/index.js +45 -11
- package/dist/cli/i18n/index.js.map +1 -1
- package/dist/cli/platform/index.d.ts +126 -1342
- package/dist/cli/platform/index.d.ts.map +1 -1
- package/dist/cli/platform/index.js +136 -2374
- package/dist/cli/platform/index.js.map +1 -1
- package/dist/cli/platform-lib/index.d.ts +1472 -0
- package/dist/cli/platform-lib/index.d.ts.map +1 -0
- package/dist/cli/platform-lib/index.js +2660 -0
- package/dist/cli/platform-lib/index.js.map +1 -0
- package/dist/cli/vendor/index.d.ts +17 -21
- package/dist/cli/vendor/index.d.ts.map +1 -1
- package/dist/cli/vendor/index.js.map +1 -1
- package/dist/command/index.d.ts +20 -19
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +39 -10
- package/dist/command/index.js.map +1 -1
- package/dist/{containers → container}/core/index.d.ts +13 -15
- package/dist/container/core/index.d.ts.map +1 -0
- package/dist/{containers → container}/core/index.js +23 -14
- package/dist/container/core/index.js.map +1 -0
- package/dist/{containers → container}/core/index.workerd.js +37 -22
- package/dist/container/core/index.workerd.js.map +1 -0
- package/dist/core/index.browser.js +27 -1
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +48 -24
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +27 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +27 -1
- package/dist/core/index.native.js.map +1 -1
- package/dist/core/index.workerd.js +27 -1
- package/dist/core/index.workerd.js.map +1 -1
- package/dist/crypto/index.browser.js.map +1 -1
- package/dist/crypto/index.d.ts +5 -8
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/crypto/index.js.map +1 -1
- package/dist/datetime/index.d.ts +3 -4
- package/dist/datetime/index.d.ts.map +1 -1
- package/dist/datetime/index.js.map +1 -1
- package/dist/email/brevo/index.d.ts +2 -4
- package/dist/email/brevo/index.d.ts.map +1 -1
- package/dist/email/brevo/index.js.map +1 -1
- package/dist/email/cloudflare/index.d.ts +20 -7
- package/dist/email/cloudflare/index.d.ts.map +1 -1
- package/dist/email/cloudflare/index.js +46 -9
- package/dist/email/cloudflare/index.js.map +1 -1
- package/dist/email/core/index.d.ts +6 -9
- package/dist/email/core/index.d.ts.map +1 -1
- package/dist/email/core/index.js.map +1 -1
- package/dist/email/core/index.workerd.js.map +1 -1
- package/dist/email/smtp/index.d.ts +10 -13
- package/dist/email/smtp/index.d.ts.map +1 -1
- package/dist/email/smtp/index.js +107 -32
- package/dist/email/smtp/index.js.map +1 -1
- package/dist/fake/index.d.ts +1 -2
- package/dist/fake/index.d.ts.map +1 -1
- package/dist/fake/index.js.map +1 -1
- package/dist/lock/core/index.d.ts +9 -14
- package/dist/lock/core/index.d.ts.map +1 -1
- package/dist/lock/core/index.js.map +1 -1
- package/dist/lock/redis/index.d.ts +2 -4
- package/dist/lock/redis/index.d.ts.map +1 -1
- package/dist/lock/redis/index.js.map +1 -1
- package/dist/logger/index.d.ts +105 -76
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +196 -174
- package/dist/logger/index.js.map +1 -1
- package/dist/mcp/index.d.ts +25 -20
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +23 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/orm/core/index.browser.js.map +1 -1
- package/dist/orm/core/index.bun.js +19 -1
- package/dist/orm/core/index.bun.js.map +1 -1
- package/dist/orm/core/index.d.ts +76 -62
- package/dist/orm/core/index.d.ts.map +1 -1
- package/dist/orm/core/index.js +20 -2
- package/dist/orm/core/index.js.map +1 -1
- package/dist/orm/postgres/index.bun.js.map +1 -1
- package/dist/orm/postgres/index.d.ts +28 -20
- package/dist/orm/postgres/index.d.ts.map +1 -1
- package/dist/orm/postgres/index.js.map +1 -1
- package/dist/queue/core/index.d.ts +12 -15
- package/dist/queue/core/index.d.ts.map +1 -1
- package/dist/queue/core/index.js.map +1 -1
- package/dist/queue/core/index.workerd.js.map +1 -1
- package/dist/queue/redis/index.d.ts +3 -5
- package/dist/queue/redis/index.d.ts.map +1 -1
- package/dist/queue/redis/index.js.map +1 -1
- package/dist/react/auth/index.browser.js +9 -2
- package/dist/react/auth/index.browser.js.map +1 -1
- package/dist/react/auth/index.d.ts +14 -9
- package/dist/react/auth/index.d.ts.map +1 -1
- package/dist/react/auth/index.js +9 -2
- package/dist/react/auth/index.js.map +1 -1
- package/dist/react/core/index.d.ts +7 -8
- package/dist/react/core/index.d.ts.map +1 -1
- package/dist/react/core/index.js +6 -3
- package/dist/react/core/index.js.map +1 -1
- package/dist/react/form/index.d.ts +2 -5
- package/dist/react/form/index.d.ts.map +1 -1
- package/dist/react/form/index.js +16 -15
- package/dist/react/form/index.js.map +1 -1
- package/dist/react/head/index.browser.js.map +1 -1
- package/dist/react/head/index.d.ts +2 -4
- package/dist/react/head/index.d.ts.map +1 -1
- package/dist/react/head/index.js.map +1 -1
- package/dist/react/i18n/index.d.ts +90 -11
- package/dist/react/i18n/index.d.ts.map +1 -1
- package/dist/react/i18n/index.js +147 -11
- package/dist/react/i18n/index.js.map +1 -1
- package/dist/react/intro/index.d.ts +1 -2
- package/dist/react/intro/index.d.ts.map +1 -1
- package/dist/react/intro/index.js +2 -2
- package/dist/react/intro/index.js.map +1 -1
- package/dist/react/router/index.browser.js +193 -24
- package/dist/react/router/index.browser.js.map +1 -1
- package/dist/react/router/index.d.ts +434 -222
- package/dist/react/router/index.d.ts.map +1 -1
- package/dist/react/router/index.js +249 -35
- package/dist/react/router/index.js.map +1 -1
- package/dist/react/sitemap/index.browser.js +35 -0
- package/dist/react/sitemap/index.browser.js.map +1 -0
- package/dist/react/sitemap/index.d.ts +92 -0
- package/dist/react/sitemap/index.d.ts.map +1 -0
- package/dist/react/sitemap/index.js +131 -0
- package/dist/react/sitemap/index.js.map +1 -0
- package/dist/react/testing/index.d.ts +1 -2
- package/dist/react/testing/index.d.ts.map +1 -1
- package/dist/react/testing/index.js +16 -17
- package/dist/react/testing/index.js.map +1 -1
- package/dist/react/ui/index.d.ts +20 -25
- package/dist/react/ui/index.d.ts.map +1 -1
- package/dist/react/ui/index.js.map +1 -1
- package/dist/redis/index.bun.js.map +1 -1
- package/dist/redis/index.d.ts +17 -19
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/redis/index.js.map +1 -1
- package/dist/retry/index.d.ts +2 -4
- package/dist/retry/index.d.ts.map +1 -1
- package/dist/retry/index.js.map +1 -1
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js.map +1 -1
- package/dist/scheduler/index.d.ts +10 -13
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/scheduler/index.js.map +1 -1
- package/dist/scheduler/index.workerd.js.map +1 -1
- package/dist/security/index.browser.js.map +1 -1
- package/dist/security/index.d.ts +45 -48
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.browser.js.map +1 -1
- package/dist/server/auth/index.d.ts +272 -173
- package/dist/server/auth/index.d.ts.map +1 -1
- package/dist/server/auth/index.js +1608 -15
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cookies/index.browser.js.map +1 -1
- package/dist/server/cookies/index.d.ts +20 -7
- package/dist/server/cookies/index.d.ts.map +1 -1
- package/dist/server/cookies/index.js +22 -3
- package/dist/server/cookies/index.js.map +1 -1
- package/dist/server/core/index.browser.js.map +1 -1
- package/dist/server/core/index.d.ts +106 -73
- package/dist/server/core/index.d.ts.map +1 -1
- package/dist/server/core/index.js +44 -0
- package/dist/server/core/index.js.map +1 -1
- package/dist/server/cors/index.d.ts +11 -14
- package/dist/server/cors/index.d.ts.map +1 -1
- package/dist/server/cors/index.js.map +1 -1
- package/dist/server/etag/index.d.ts +6 -9
- package/dist/server/etag/index.d.ts.map +1 -1
- package/dist/server/etag/index.js.map +1 -1
- package/dist/server/health/index.d.ts +18 -21
- package/dist/server/health/index.d.ts.map +1 -1
- package/dist/server/health/index.js.map +1 -1
- package/dist/server/links/index.browser.js +2 -0
- package/dist/server/links/index.browser.js.map +1 -1
- package/dist/server/links/index.d.ts +63 -67
- package/dist/server/links/index.d.ts.map +1 -1
- package/dist/server/links/index.js +2 -0
- package/dist/server/links/index.js.map +1 -1
- package/dist/server/metrics/index.d.ts +5 -7
- package/dist/server/metrics/index.d.ts.map +1 -1
- package/dist/server/metrics/index.js.map +1 -1
- package/dist/server/proxy/index.d.ts +3 -5
- package/dist/server/proxy/index.d.ts.map +1 -1
- package/dist/server/proxy/index.js.map +1 -1
- package/dist/server/rate-limit/index.d.ts +10 -13
- package/dist/server/rate-limit/index.d.ts.map +1 -1
- package/dist/server/rate-limit/index.js.map +1 -1
- package/dist/server/static/index.d.ts +3 -5
- package/dist/server/static/index.d.ts.map +1 -1
- package/dist/server/static/index.js.map +1 -1
- package/dist/server/swagger/index.d.ts +5 -8
- package/dist/server/swagger/index.d.ts.map +1 -1
- package/dist/server/swagger/index.js.map +1 -1
- package/dist/sms/index.d.ts +3 -5
- package/dist/sms/index.d.ts.map +1 -1
- package/dist/sms/index.js.map +1 -1
- package/dist/system/index.browser.js.map +1 -1
- package/dist/system/index.d.ts +2 -4
- package/dist/system/index.d.ts.map +1 -1
- package/dist/system/index.js.map +1 -1
- package/dist/system/index.workerd.js.map +1 -1
- package/dist/topic/core/index.d.ts +4 -6
- package/dist/topic/core/index.d.ts.map +1 -1
- package/dist/topic/core/index.js.map +1 -1
- package/dist/topic/redis/index.d.ts +5 -8
- package/dist/topic/redis/index.d.ts.map +1 -1
- package/dist/topic/redis/index.js.map +1 -1
- package/package.json +59 -23
- package/src/api/audits/__tests__/AuditService.spec.ts +18 -110
- package/src/api/audits/controllers/AdminAuditController.ts +14 -0
- package/src/api/audits/services/AuditService.ts +21 -88
- package/src/api/files/__tests__/FileService.spec.ts +207 -2
- package/src/api/files/index.ts +3 -0
- package/src/api/files/schemas/fileCreatorSummarySchema.ts +22 -0
- package/src/api/files/schemas/fileResourceSchema.ts +10 -1
- package/src/api/files/services/FileService.ts +170 -72
- package/src/api/jobs/__tests__/$job.spec.ts +24 -1
- package/src/api/jobs/index.ts +4 -3
- package/src/api/jobs/primitives/$job.ts +7 -3
- package/src/api/jobs/providers/DirectJobDispatcher.ts +17 -36
- package/src/api/jobs/providers/JobProvider.ts +53 -24
- package/src/api/jobs/schemas/jobConfigAtom.ts +1 -1
- package/src/api/jobs/schemas/jobExecutionResourceSchema.ts +4 -1
- package/src/api/keys/schemas/adminApiKeyResourceSchema.ts +3 -1
- package/src/api/parameters/__tests__/$parameter.spec.ts +19 -2
- package/src/api/parameters/audits/ParameterAudits.ts +17 -0
- package/src/api/parameters/controllers/AdminParameterController.ts +95 -19
- package/src/api/parameters/index.ts +3 -0
- package/src/api/parameters/schemas/activateParameterBodySchema.ts +3 -3
- package/src/api/parameters/schemas/createParameterVersionBodySchema.ts +3 -2
- package/src/api/parameters/schemas/parameterCreatorSummarySchema.ts +25 -0
- package/src/api/parameters/schemas/parameterResponseSchema.ts +5 -0
- package/src/api/parameters/schemas/rollbackParameterBodySchema.ts +4 -2
- package/src/api/parameters/services/ParameterProvider.ts +69 -6
- package/src/api/subscriptions/jobs/SubscriptionJobs.ts +1 -1
- package/src/api/users/__tests__/AdminSessionController.spec.ts +37 -0
- package/src/api/users/audits/SessionAudits.ts +33 -0
- package/src/api/users/audits/UserAudits.ts +19 -43
- package/src/api/users/controllers/AdminUserController.ts +66 -1
- package/src/api/users/controllers/RealmController.ts +1 -0
- package/src/api/users/entities/sessions.ts +6 -0
- package/src/api/users/entities/users.ts +2 -0
- package/src/api/users/index.ts +9 -1
- package/src/api/users/primitives/$realm.ts +29 -0
- package/src/api/users/providers/RealmProvider.ts +15 -0
- package/src/api/users/schemas/realmConfigSchema.ts +14 -0
- package/src/api/users/schemas/sessionResourceSchema.ts +16 -0
- package/src/api/users/schemas/updateUserSchema.ts +1 -8
- package/src/api/users/schemas/userQuerySchema.ts +7 -0
- package/src/api/users/services/CredentialService.ts +15 -6
- package/src/api/users/services/IdentityService.ts +2 -1
- package/src/api/users/services/RegistrationService.ts +2 -1
- package/src/api/users/services/SessionCrudService.ts +19 -2
- package/src/api/users/services/SessionService.ts +39 -19
- package/src/api/users/services/UserService.ts +106 -8
- package/src/background/__tests__/BackgroundTaskProvider.spec.ts +96 -0
- package/src/background/index.ts +37 -0
- package/src/background/index.workerd.ts +28 -0
- package/src/background/providers/BackgroundTaskProvider.ts +70 -0
- package/src/background/providers/WorkerdBackgroundTaskProvider.ts +43 -0
- package/src/bucket/__tests__/$bucket.spec.ts +18 -0
- package/src/bucket/__tests__/LocalFileStorageProvider.spec.ts +5 -0
- package/src/bucket/__tests__/MemoryFileStorageProvider.spec.ts +5 -0
- package/src/bucket/__tests__/NodeS3BucketProvider.spec.ts +23 -4
- package/src/bucket/__tests__/shared.ts +30 -0
- package/src/bucket/index.ts +5 -5
- package/src/bucket/index.workerd.ts +11 -4
- package/src/bucket/primitives/$bucket.ts +27 -0
- package/src/bucket/providers/FileStorageProvider.ts +13 -0
- package/src/bucket/providers/LocalFileStorageProvider.ts +17 -1
- package/src/bucket/providers/MemoryFileStorageProvider.ts +7 -0
- package/src/bucket/providers/{CloudflareR2Provider.ts → R2FileStorageProvider.ts} +10 -1
- package/src/bucket/providers/{NodeS3BucketProvider.ts → S3FileStorageProvider.ts} +27 -5
- package/src/cli/core/__tests__/BuildDockerTask.spec.ts +25 -1
- package/src/cli/core/__tests__/init.spec.ts +0 -219
- package/src/cli/core/atoms/buildOptions.ts +0 -12
- package/src/cli/core/commands/__tests__/BuildCommand.spec.ts +43 -0
- package/src/cli/core/commands/build.ts +105 -37
- package/src/cli/core/commands/init.ts +0 -12
- package/src/cli/core/commands/pack.ts +133 -0
- package/src/cli/core/index.ts +3 -3
- package/src/cli/core/providers/ViteDevServerProvider.ts +40 -16
- package/src/cli/core/services/PackageManagerUtils.ts +0 -16
- package/src/cli/core/services/ProjectScaffolder.ts +29 -291
- package/src/cli/core/tasks/BuildCloudflareTask.ts +382 -56
- package/src/cli/core/tasks/BuildDockerTask.ts +33 -3
- package/src/cli/core/tasks/BuildPrerenderTask.ts +44 -7
- package/src/cli/core/tasks/BuildTask.ts +34 -0
- package/src/cli/core/templates/apiIndexTs.ts +1 -22
- package/src/cli/core/templates/mainCss.ts +0 -1
- package/src/cli/core/templates/webAppRouterTs.ts +0 -99
- package/src/cli/core/templates/webIndexTs.ts +1 -22
- package/src/cli/i18n/__tests__/I18nCheckService.spec.ts +48 -0
- package/src/cli/i18n/services/I18nCheckService.ts +65 -11
- package/src/cli/platform/__tests__/SecretsCommand.spec.ts +5 -3
- package/src/cli/platform/commands/SecretsCommand.ts +8 -6
- package/src/cli/platform/commands/platform.ts +192 -46
- package/src/cli/platform/index.ts +12 -52
- package/src/cli/{platform → platform-lib}/__tests__/CloudflareAdapter.spec.ts +426 -169
- package/src/cli/{platform → platform-lib}/__tests__/NamingService.spec.ts +91 -4
- package/src/cli/{platform → platform-lib}/__tests__/VercelAdapter.spec.ts +56 -85
- package/src/cli/{platform → platform-lib}/adapters/CloudflareAdapter.ts +519 -190
- package/src/cli/{platform → platform-lib}/adapters/PlatformAdapter.ts +62 -35
- package/src/cli/{platform → platform-lib}/adapters/VercelAdapter.ts +6 -10
- package/src/cli/{platform → platform-lib}/atoms/platformOptions.ts +34 -1
- package/src/cli/platform-lib/index.ts +67 -0
- package/src/cli/platform-lib/services/NamingService.ts +136 -0
- package/src/cli/{platform → platform-lib}/services/PlatformInspector.ts +60 -13
- package/src/cli/{platform → platform-lib}/services/PlatformOrchestrator.ts +54 -43
- package/src/cli/{platform → platform-lib}/services/WranglerApi.ts +4 -2
- package/src/command/__tests__/Runner.spec.ts +20 -0
- package/src/command/helpers/EnvUtils.ts +19 -3
- package/src/command/helpers/Runner.ts +12 -2
- package/src/command/providers/CliProvider.ts +34 -1
- package/src/{containers → container}/core/__tests__/$container.spec.ts +5 -5
- package/src/{containers → container}/core/index.ts +4 -4
- package/src/{containers → container}/core/index.workerd.ts +19 -3
- package/src/{containers → container}/core/primitives/$container.ts +1 -1
- package/src/{containers → container}/core/providers/CloudflareContainerProvider.ts +17 -19
- package/src/{containers → container}/core/providers/ContainerProvider.ts +16 -2
- package/src/{containers → container}/core/providers/MockContainerProvider.ts +1 -1
- package/src/core/Alepha.ts +49 -1
- package/src/core/__tests__/$env.spec.ts +42 -0
- package/src/core/__tests__/dump.spec.ts +47 -0
- package/src/email/cloudflare/__tests__/CloudflareEmailProvider.spec.ts +42 -10
- package/src/email/cloudflare/index.ts +14 -5
- package/src/email/cloudflare/providers/CloudflareEmailProvider.ts +54 -9
- package/src/logger/__tests__/Logger.spec.ts +55 -0
- package/src/logger/index.ts +13 -0
- package/src/logger/services/Logger.ts +31 -1
- package/src/mcp/__tests__/McpServerProvider.spec.ts +71 -0
- package/src/mcp/providers/McpServerProvider.ts +55 -0
- package/src/orm/__tests__/orm-showcase-tests.ts +27 -0
- package/src/orm/__tests__/orm-showcase.spec.ts +12 -0
- package/src/orm/core/interfaces/PgQuery.ts +4 -1
- package/src/orm/core/services/Repository.ts +27 -11
- package/src/react/auth/hooks/useAuth.ts +10 -5
- package/src/react/core/__tests__/useQuery.browser.spec.tsx +25 -0
- package/src/react/core/hooks/useAction.ts +14 -3
- package/src/react/core/hooks/useQuery.ts +24 -4
- package/src/react/form/__tests__/FormModel-submit-loading.spec.ts +71 -0
- package/src/react/form/__tests__/form-submitting-reactive.browser.spec.tsx +96 -0
- package/src/react/form/services/FormModel.ts +57 -39
- package/src/react/i18n/__tests__/I18nProvider.spec.ts +89 -0
- package/src/react/i18n/__tests__/locale-routing.spec.ts +107 -0
- package/src/react/i18n/components/Translate.tsx +47 -0
- package/src/react/i18n/index.ts +2 -0
- package/src/react/i18n/providers/I18nProvider.ts +171 -12
- package/src/react/intro/components/GettingStartedAdminSlide.tsx +2 -2
- package/src/react/router/__tests__/$page.spec.tsx +3 -2
- package/src/react/router/__tests__/RouterLocaleProvider.spec.ts +127 -0
- package/src/react/router/__tests__/page-can.spec.ts +18 -13
- package/src/react/router/hooks/useQueryParams.ts +114 -14
- package/src/react/router/index.browser.ts +4 -0
- package/src/react/router/index.shared.ts +1 -0
- package/src/react/router/index.ts +9 -0
- package/src/react/router/primitives/$page.ts +85 -4
- package/src/react/router/providers/ReactBrowserRouterProvider.ts +18 -8
- package/src/react/router/providers/ReactPageProvider.ts +12 -1
- package/src/react/router/providers/ReactServerProvider.ts +96 -14
- package/src/react/router/providers/RootComponentsProvider.ts +13 -0
- package/src/react/router/providers/RouterLocaleProvider.ts +125 -0
- package/src/react/router/providers/__tests__/RootComponentsProvider.spec.ts +15 -0
- package/src/react/router/providers/__tests__/rootComponents.ssr.browser.spec.tsx +67 -0
- package/src/react/sitemap/__tests__/$sitemap.spec.ts +131 -0
- package/src/react/sitemap/index.browser.ts +21 -0
- package/src/react/sitemap/index.ts +25 -0
- package/src/react/sitemap/primitives/$sitemap.browser.ts +26 -0
- package/src/react/sitemap/primitives/$sitemap.ts +196 -0
- package/src/react/ui/services/SchemaControl.ts +3 -4
- package/src/server/auth/__tests__/appleClientSecret.spec.ts +34 -0
- package/src/server/auth/__tests__/authFederationClient.spec.ts +40 -0
- package/src/server/auth/__tests__/federationAssertion.spec.ts +146 -0
- package/src/server/auth/__tests__/federationRedirectReplay.spec.ts +44 -0
- package/src/server/auth/helpers/appleClientSecret.ts +24 -0
- package/src/server/auth/helpers/federationAssertion.ts +74 -0
- package/src/server/auth/helpers/jtiReplayGuard.ts +41 -0
- package/src/server/auth/helpers/safeRedirectPath.ts +19 -0
- package/src/server/auth/index.ts +4 -0
- package/src/server/auth/primitives/$authFederationBroker.ts +273 -0
- package/src/server/auth/primitives/$authFederationClient.ts +89 -0
- package/src/server/auth/providers/ServerAuthProvider.ts +18 -4
- package/src/server/cookies/__tests__/ServerCookiesProvider.spec.ts +70 -0
- package/src/server/cookies/providers/ServerCookiesProvider.ts +23 -3
- package/src/server/core/interfaces/ServerRequest.ts +8 -0
- package/src/server/core/primitives/$route.ts +27 -0
- package/src/server/core/providers/ServerMultipartProvider.ts +19 -0
- package/src/server/links/providers/LinkProvider.ts +10 -0
- package/dist/containers/core/index.d.ts.map +0 -1
- package/dist/containers/core/index.js.map +0 -1
- package/dist/containers/core/index.workerd.js.map +0 -1
- package/src/cli/core/tasks/BuildSitemapTask.ts +0 -130
- package/src/cli/core/templates/componentsJsonTs.ts +0 -39
- package/src/cli/core/templates/saasAdminLayoutTsx.ts +0 -77
- package/src/cli/core/templates/saasAdminPagesTsx.ts +0 -26
- package/src/cli/core/templates/saasAuthLayoutTsx.ts +0 -22
- package/src/cli/core/templates/saasAuthPagesTsx.ts +0 -62
- package/src/cli/core/templates/saasRealmProviderTs.ts +0 -52
- package/src/cli/platform/services/NamingService.ts +0 -54
- /package/dist/orm/core/{chunk-o8xxKEmq.js → chunk-B4FMCO8f.js} +0 -0
- /package/dist/react/testing/{chunk-6Ep1yQYe.js → chunk-BpyX8vjI.js} +0 -0
- /package/src/cli/{platform → platform-lib}/__tests__/GitHubSecretStore.spec.ts +0 -0
- /package/src/cli/{platform → platform-lib}/__tests__/PlatformCacheProvider.spec.ts +0 -0
- /package/src/cli/{platform → platform-lib}/__tests__/PlatformInspector.spec.ts +0 -0
- /package/src/cli/{platform → platform-lib}/__tests__/PlatformOrchestrator.spec.ts +0 -0
- /package/src/cli/{platform → platform-lib}/__tests__/SecretFilterService.spec.ts +0 -0
- /package/src/cli/{platform → platform-lib}/__tests__/detectResources.spec.ts +0 -0
- /package/src/cli/{platform → platform-lib}/providers/GitHubSecretStore.ts +0 -0
- /package/src/cli/{platform → platform-lib}/providers/MemorySecretStore.ts +0 -0
- /package/src/cli/{platform → platform-lib}/providers/PlatformCacheProvider.ts +0 -0
- /package/src/cli/{platform → platform-lib}/providers/SecretStoreProvider.ts +0 -0
- /package/src/cli/{platform → platform-lib}/schemas/cloudflare.ts +0 -0
- /package/src/cli/{platform → platform-lib}/schemas/platform.ts +0 -0
- /package/src/cli/{platform → platform-lib}/schemas/vercel.ts +0 -0
- /package/src/cli/{platform → platform-lib}/services/CloudflareApi.ts +0 -0
- /package/src/cli/{platform → platform-lib}/services/SecretFilterService.ts +0 -0
- /package/src/cli/{platform → platform-lib}/services/VercelApi.ts +0 -0
- /package/src/cli/{platform → platform-lib}/services/VercelCli.ts +0 -0
- /package/src/{containers → container}/core/interfaces/ContainerOptions.ts +0 -0
- /package/src/{containers → container}/core/providers/NodeContainerProvider.ts +0 -0
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import * as _$alepha from "alepha";
|
|
2
1
|
import { Static } from "alepha";
|
|
3
|
-
import * as _$typebox from "typebox";
|
|
4
2
|
|
|
5
3
|
//#region ../../src/cli/devtools/atoms/devtoolsOptions.d.ts
|
|
6
4
|
/**
|
|
@@ -8,13 +6,13 @@ import * as _$typebox from "typebox";
|
|
|
8
6
|
*
|
|
9
7
|
* Filled from the `devtools` section of `alepha.config.ts`.
|
|
10
8
|
*/
|
|
11
|
-
declare const devtoolsOptions:
|
|
9
|
+
declare const devtoolsOptions: import("alepha").Atom<import("typebox").TOptional<import("typebox").TObject<{
|
|
12
10
|
/**
|
|
13
11
|
* Hide the floating devtools button in the browser.
|
|
14
12
|
*
|
|
15
13
|
* The devtools UI is still accessible at `/__devtools/`.
|
|
16
14
|
*/
|
|
17
|
-
hideButton:
|
|
15
|
+
hideButton: import("typebox").TOptional<import("typebox").TBoolean>;
|
|
18
16
|
}>>, "alepha.cli.devtools.options">;
|
|
19
17
|
/**
|
|
20
18
|
* Type for devtools options.
|
|
@@ -40,7 +38,7 @@ type DevtoolsOptions = Static<typeof devtoolsOptions.schema>;
|
|
|
40
38
|
*
|
|
41
39
|
* @module alepha.devtools.plugin
|
|
42
40
|
*/
|
|
43
|
-
declare const AlephaCliDevtoolsPlugin:
|
|
41
|
+
declare const AlephaCliDevtoolsPlugin: import("alepha").Service<import("alepha").Module>;
|
|
44
42
|
declare const devtools: (options?: DevtoolsOptions) => () => void;
|
|
45
43
|
//#endregion
|
|
46
44
|
export { AlephaCliDevtoolsPlugin, DevtoolsOptions, devtools, devtoolsOptions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/cli/devtools/atoms/devtoolsOptions.ts","../../../src/cli/devtools/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/cli/devtools/atoms/devtoolsOptions.ts","../../../src/cli/devtools/index.ts"],"mappings":";;;;;AAOA;;;cAAa,eAAA,mBAAe,IAAA,mBAAA,SAAA,mBAAA,OAAA;EAAA;;;;;;;;AAkB5B;;KAAY,eAAA,GAAkB,MAAM,QAAQ,eAAA,CAAgB,MAAA;;;;;AAlB5D;;;;;;;;;;;;AAkBA;;;;cCuFa,uBAAA,mBAAuB,OAAA,kBAAA,MAAA;AAAA,cAkFvB,QAAA,GAAY,OAA6B,GAApB,eAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cli/devtools/atoms/devtoolsOptions.ts","../../../src/cli/devtools/index.ts"],"sourcesContent":["import { $atom, type Static, t } from \"alepha\";\n\n/**\n * Devtools configuration atom.\n *\n * Filled from the `devtools` section of `alepha.config.ts`.\n */\nexport const devtoolsOptions = $atom({\n name: \"alepha.cli.devtools.options\",\n description: \"Devtools plugin configuration\",\n schema: t.optional(\n t.object({\n /**\n * Hide the floating devtools button in the browser.\n *\n * The devtools UI is still accessible at `/__devtools/`.\n */\n hideButton: t.optional(t.boolean({ default: false })),\n }),\n ),\n});\n\n/**\n * Type for devtools options.\n */\nexport type DevtoolsOptions = Static<typeof devtoolsOptions.schema>;\n","import { readFile } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\nimport { $context, $module, AlephaError } from \"alepha\";\nimport { ViteDevServerProvider } from \"alepha/cli\";\nimport {\n type DevtoolsOptions,\n devtoolsOptions,\n} from \"./atoms/devtoolsOptions.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nconst DEVTOOLS_OVERLAY_SCRIPT = `\n(function () {\n if (window.__alepha_devtools_injected) return;\n window.__alepha_devtools_injected = true;\n\n const STORAGE_KEY = \"alepha-devtools-open\";\n\n // Button\n const btn = document.createElement(\"button\");\n btn.id = \"alepha-devtools-btn\";\n btn.innerHTML = \\`<svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z\"/><path d=\"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1Z\"/></svg>\\`;\n Object.assign(btn.style, {\n position: \"fixed\", bottom: \"16px\", left: \"16px\", zIndex: \"99998\",\n width: \"36px\", height: \"36px\", borderRadius: \"50%\",\n background: \"rgba(255,255,255,0.85)\", color: \"#3f3f46\",\n border: \"none\", backdropFilter: \"blur(8px)\", WebkitBackdropFilter: \"blur(8px)\",\n cursor: \"pointer\", display: \"flex\", alignItems: \"center\", justifyContent: \"center\",\n boxShadow: \"0 1px 2px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.08)\",\n transition: \"transform 0.2s ease, box-shadow 0.2s ease\",\n padding: \"0\", fontSize: \"0\",\n });\n btn.addEventListener(\"mouseenter\", () => {\n btn.style.transform = \"translateY(-1px) rotate(45deg)\";\n btn.style.boxShadow = \"0 2px 4px rgba(0,0,0,0.08), 0 8px 20px rgba(0,0,0,0.12)\";\n });\n btn.addEventListener(\"mouseleave\", () => {\n btn.style.transform = \"translateY(0) rotate(0deg)\";\n btn.style.boxShadow = \"0 1px 2px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.08)\";\n });\n\n // Overlay\n const overlay = document.createElement(\"div\");\n overlay.id = \"alepha-devtools-overlay\";\n Object.assign(overlay.style, {\n position: \"fixed\", inset: \"0\", zIndex: \"99999\",\n background: \"rgba(0,0,0,0.6)\", backdropFilter: \"blur(2px)\",\n display: \"none\", alignItems: \"center\", justifyContent: \"center\",\n });\n\n // Panel\n const panel = document.createElement(\"div\");\n Object.assign(panel.style, {\n width: \"90vw\", height: \"85vh\", maxWidth: \"1400px\",\n borderRadius: \"12px\", overflow: \"hidden\",\n boxShadow: \"0 8px 32px rgba(0,0,0,0.5)\",\n border: \"1px solid #2a2a4a\",\n });\n\n const iframe = document.createElement(\"iframe\");\n iframe.style.cssText = \"width:100%;height:100%;border:none;\";\n\n panel.appendChild(iframe);\n overlay.appendChild(panel);\n document.body.appendChild(btn);\n document.body.appendChild(overlay);\n\n function open() {\n if (!iframe.src) iframe.src = \"/__devtools/\";\n overlay.style.display = \"flex\";\n btn.style.display = \"none\";\n sessionStorage.setItem(STORAGE_KEY, \"1\");\n }\n\n function close() {\n overlay.style.display = \"none\";\n btn.style.display = \"flex\";\n sessionStorage.removeItem(STORAGE_KEY);\n }\n\n btn.addEventListener(\"click\", open);\n overlay.addEventListener(\"click\", (e) => {\n if (e.target === overlay) close();\n });\n document.addEventListener(\"keydown\", (e) => {\n if (e.key === \"Escape\" && overlay.style.display === \"flex\") close();\n });\n\n // Restore state after HMR\n if (sessionStorage.getItem(STORAGE_KEY)) open();\n})();\n`;\n\n/**\n * CLI plugin that integrates @alepha/devtools into the Vite dev server.\n *\n * This module is intentionally lightweight — it does NOT statically import\n * `@alepha/devtools` (which pulls in `alepha/react` and `.tsx` files).\n * Instead, it lazy-loads devtools via Vite's SSR module loader at runtime.\n *\n * Usage in `alepha.config.ts`:\n * ```ts\n * import { devtools } from \"alepha/cli/devtools\";\n *\n * export default defineConfig({\n * plugins: [devtools()],\n * });\n * ```\n *\n * @module alepha.devtools.plugin\n */\nexport const AlephaCliDevtoolsPlugin = $module({\n name: \"alepha.cli.plugins.devtools\",\n atoms: [devtoolsOptions],\n register: (alepha) => {\n const vite = alepha.inject(ViteDevServerProvider) as ViteDevServerProvider;\n\n const require = createRequire(import.meta.url);\n const pkgPath = require.resolve(\"@alepha/devtools/package.json\");\n const assetsPath = join(dirname(pkgPath), \"assets/ui\");\n\n process.env.VITE_ALEPHA_DEVTOOLS = \"true\";\n\n vite.addVitePlugin({\n name: \"alepha-devtools\",\n configureServer: (server) => {\n // Reload endpoint\n server.middlewares.use((req, res, next) => {\n if (req.url !== \"/__devtools/api/reload\" || req.method !== \"POST\") {\n return next();\n }\n\n vite.reload();\n res.writeHead(200, { \"content-type\": \"application/json\" });\n res.end(JSON.stringify({ ok: true }));\n });\n\n // Serve devtools HTML\n server.middlewares.use(async (req, res, next) => {\n const url = req.url || \"/\";\n\n if (\n !url.startsWith(\"/__devtools\") ||\n !req.headers.accept?.includes(\"text/html\")\n ) {\n return next();\n }\n\n const indexPath = join(assetsPath, \"index.html\");\n\n try {\n let html = await readFile(indexPath, \"utf-8\");\n html = html.replace(\n \"<head>\",\n `<head><script type=\"module\" src=\"/@vite/client\"></script>`,\n );\n\n res.writeHead(200, { \"content-type\": \"text/html\" });\n res.end(html);\n } catch {\n next();\n }\n });\n },\n transformIndexHtml: () => {\n const options = alepha.store.get(devtoolsOptions);\n if (options?.hideButton) return [];\n\n return [\n {\n tag: \"script\",\n attrs: { type: \"module\" },\n children: DEVTOOLS_OVERLAY_SCRIPT,\n injectTo: \"head\",\n },\n ];\n },\n });\n\n vite.onAlephaLoaded(async (appAlepha, server) => {\n try {\n const mod = await server.ssrLoadModule(\"@alepha/devtools\");\n appAlepha.with(mod.AlephaDevtools);\n } catch (err) {\n throw new AlephaError(\n \"Failed to load @alepha/devtools. Make sure the package is installed\",\n { cause: err },\n );\n }\n });\n },\n});\n\nexport const devtools = (options: DevtoolsOptions = {}) => {\n return () => {\n const { alepha } = $context();\n alepha.with(AlephaCliDevtoolsPlugin).set(devtoolsOptions, options);\n };\n};\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./atoms/devtoolsOptions.ts\";\n"],"mappings":";;;;;;;;;;;AAOA,MAAa,kBAAkB,MAAM;CACnC,MAAM;CACN,aAAa;CACb,QAAQ,EAAE,SACR,EAAE,OAAO;;;;;;AAMP,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,OAAO,CAAC,CAAC,EACtD,CAAC,CACH;CACF,CAAC;;;ACRF,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoGhC,MAAa,0BAA0B,QAAQ;CAC7C,MAAM;CACN,OAAO,CAAC,gBAAgB;CACxB,WAAW,WAAW;EACpB,MAAM,OAAO,OAAO,OAAO,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KAAK;CACzD,aAAa;EACX,MAAM,EAAE,WAAW,UAAU;EAC7B,OAAO,KAAK,wBAAwB,CAAC,IAAI,iBAAiB,QAAQ"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cli/devtools/atoms/devtoolsOptions.ts","../../../src/cli/devtools/index.ts"],"sourcesContent":["import { $atom, type Static, t } from \"alepha\";\n\n/**\n * Devtools configuration atom.\n *\n * Filled from the `devtools` section of `alepha.config.ts`.\n */\nexport const devtoolsOptions = $atom({\n name: \"alepha.cli.devtools.options\",\n description: \"Devtools plugin configuration\",\n schema: t.optional(\n t.object({\n /**\n * Hide the floating devtools button in the browser.\n *\n * The devtools UI is still accessible at `/__devtools/`.\n */\n hideButton: t.optional(t.boolean({ default: false })),\n }),\n ),\n});\n\n/**\n * Type for devtools options.\n */\nexport type DevtoolsOptions = Static<typeof devtoolsOptions.schema>;\n","import { readFile } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\nimport { $context, $module, AlephaError } from \"alepha\";\nimport { ViteDevServerProvider } from \"alepha/cli\";\nimport {\n type DevtoolsOptions,\n devtoolsOptions,\n} from \"./atoms/devtoolsOptions.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nconst DEVTOOLS_OVERLAY_SCRIPT = `\n(function () {\n if (window.__alepha_devtools_injected) return;\n window.__alepha_devtools_injected = true;\n\n const STORAGE_KEY = \"alepha-devtools-open\";\n\n // Button\n const btn = document.createElement(\"button\");\n btn.id = \"alepha-devtools-btn\";\n btn.innerHTML = \\`<svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z\"/><path d=\"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1Z\"/></svg>\\`;\n Object.assign(btn.style, {\n position: \"fixed\", bottom: \"16px\", left: \"16px\", zIndex: \"99998\",\n width: \"36px\", height: \"36px\", borderRadius: \"50%\",\n background: \"rgba(255,255,255,0.85)\", color: \"#3f3f46\",\n border: \"none\", backdropFilter: \"blur(8px)\", WebkitBackdropFilter: \"blur(8px)\",\n cursor: \"pointer\", display: \"flex\", alignItems: \"center\", justifyContent: \"center\",\n boxShadow: \"0 1px 2px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.08)\",\n transition: \"transform 0.2s ease, box-shadow 0.2s ease\",\n padding: \"0\", fontSize: \"0\",\n });\n btn.addEventListener(\"mouseenter\", () => {\n btn.style.transform = \"translateY(-1px) rotate(45deg)\";\n btn.style.boxShadow = \"0 2px 4px rgba(0,0,0,0.08), 0 8px 20px rgba(0,0,0,0.12)\";\n });\n btn.addEventListener(\"mouseleave\", () => {\n btn.style.transform = \"translateY(0) rotate(0deg)\";\n btn.style.boxShadow = \"0 1px 2px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.08)\";\n });\n\n // Overlay\n const overlay = document.createElement(\"div\");\n overlay.id = \"alepha-devtools-overlay\";\n Object.assign(overlay.style, {\n position: \"fixed\", inset: \"0\", zIndex: \"99999\",\n background: \"rgba(0,0,0,0.6)\", backdropFilter: \"blur(2px)\",\n display: \"none\", alignItems: \"center\", justifyContent: \"center\",\n });\n\n // Panel\n const panel = document.createElement(\"div\");\n Object.assign(panel.style, {\n width: \"90vw\", height: \"85vh\", maxWidth: \"1400px\",\n borderRadius: \"12px\", overflow: \"hidden\",\n boxShadow: \"0 8px 32px rgba(0,0,0,0.5)\",\n border: \"1px solid #2a2a4a\",\n });\n\n const iframe = document.createElement(\"iframe\");\n iframe.style.cssText = \"width:100%;height:100%;border:none;\";\n\n panel.appendChild(iframe);\n overlay.appendChild(panel);\n document.body.appendChild(btn);\n document.body.appendChild(overlay);\n\n function open() {\n if (!iframe.src) iframe.src = \"/__devtools/\";\n overlay.style.display = \"flex\";\n btn.style.display = \"none\";\n sessionStorage.setItem(STORAGE_KEY, \"1\");\n }\n\n function close() {\n overlay.style.display = \"none\";\n btn.style.display = \"flex\";\n sessionStorage.removeItem(STORAGE_KEY);\n }\n\n btn.addEventListener(\"click\", open);\n overlay.addEventListener(\"click\", (e) => {\n if (e.target === overlay) close();\n });\n document.addEventListener(\"keydown\", (e) => {\n if (e.key === \"Escape\" && overlay.style.display === \"flex\") close();\n });\n\n // Restore state after HMR\n if (sessionStorage.getItem(STORAGE_KEY)) open();\n})();\n`;\n\n/**\n * CLI plugin that integrates @alepha/devtools into the Vite dev server.\n *\n * This module is intentionally lightweight — it does NOT statically import\n * `@alepha/devtools` (which pulls in `alepha/react` and `.tsx` files).\n * Instead, it lazy-loads devtools via Vite's SSR module loader at runtime.\n *\n * Usage in `alepha.config.ts`:\n * ```ts\n * import { devtools } from \"alepha/cli/devtools\";\n *\n * export default defineConfig({\n * plugins: [devtools()],\n * });\n * ```\n *\n * @module alepha.devtools.plugin\n */\nexport const AlephaCliDevtoolsPlugin = $module({\n name: \"alepha.cli.plugins.devtools\",\n atoms: [devtoolsOptions],\n register: (alepha) => {\n const vite = alepha.inject(ViteDevServerProvider) as ViteDevServerProvider;\n\n const require = createRequire(import.meta.url);\n const pkgPath = require.resolve(\"@alepha/devtools/package.json\");\n const assetsPath = join(dirname(pkgPath), \"assets/ui\");\n\n process.env.VITE_ALEPHA_DEVTOOLS = \"true\";\n\n vite.addVitePlugin({\n name: \"alepha-devtools\",\n configureServer: (server) => {\n // Reload endpoint\n server.middlewares.use((req, res, next) => {\n if (req.url !== \"/__devtools/api/reload\" || req.method !== \"POST\") {\n return next();\n }\n\n vite.reload();\n res.writeHead(200, { \"content-type\": \"application/json\" });\n res.end(JSON.stringify({ ok: true }));\n });\n\n // Serve devtools HTML\n server.middlewares.use(async (req, res, next) => {\n const url = req.url || \"/\";\n\n if (\n !url.startsWith(\"/__devtools\") ||\n !req.headers.accept?.includes(\"text/html\")\n ) {\n return next();\n }\n\n const indexPath = join(assetsPath, \"index.html\");\n\n try {\n let html = await readFile(indexPath, \"utf-8\");\n html = html.replace(\n \"<head>\",\n `<head><script type=\"module\" src=\"/@vite/client\"></script>`,\n );\n\n res.writeHead(200, { \"content-type\": \"text/html\" });\n res.end(html);\n } catch {\n next();\n }\n });\n },\n transformIndexHtml: () => {\n const options = alepha.store.get(devtoolsOptions);\n if (options?.hideButton) return [];\n\n return [\n {\n tag: \"script\",\n attrs: { type: \"module\" },\n children: DEVTOOLS_OVERLAY_SCRIPT,\n injectTo: \"head\",\n },\n ];\n },\n });\n\n vite.onAlephaLoaded(async (appAlepha, server) => {\n try {\n const mod = await server.ssrLoadModule(\"@alepha/devtools\");\n appAlepha.with(mod.AlephaDevtools);\n } catch (err) {\n throw new AlephaError(\n \"Failed to load @alepha/devtools. Make sure the package is installed\",\n { cause: err },\n );\n }\n });\n },\n});\n\nexport const devtools = (options: DevtoolsOptions = {}) => {\n return () => {\n const { alepha } = $context();\n alepha.with(AlephaCliDevtoolsPlugin).set(devtoolsOptions, options);\n };\n};\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./atoms/devtoolsOptions.ts\";\n"],"mappings":";;;;;;;;;;;AAOA,MAAa,kBAAkB,MAAM;CACnC,MAAM;CACN,aAAa;CACb,QAAQ,EAAE,SACR,EAAE,OAAO;;;;;;AAMP,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,MAAM,CAAC,CAAC,EACtD,CAAC,CACH;AACF,CAAC;;;ACRD,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoGhC,MAAa,0BAA0B,QAAQ;CAC7C,MAAM;CACN,OAAO,CAAC,eAAe;CACvB,WAAW,WAAW;EACpB,MAAM,OAAO,OAAO,OAAO,qBAAqB;EAIhD,MAAM,aAAa,KAAK,QAFR,cAAc,OAAO,KAAK,GACpB,EAAE,QAAQ,+BACM,CAAC,GAAG,WAAW;EAErD,QAAQ,IAAI,uBAAuB;EAEnC,KAAK,cAAc;GACjB,MAAM;GACN,kBAAkB,WAAW;IAE3B,OAAO,YAAY,KAAK,KAAK,KAAK,SAAS;KACzC,IAAI,IAAI,QAAQ,4BAA4B,IAAI,WAAW,QACzD,OAAO,KAAK;KAGd,KAAK,OAAO;KACZ,IAAI,UAAU,KAAK,EAAE,gBAAgB,mBAAmB,CAAC;KACzD,IAAI,IAAI,KAAK,UAAU,EAAE,IAAI,KAAK,CAAC,CAAC;IACtC,CAAC;IAGD,OAAO,YAAY,IAAI,OAAO,KAAK,KAAK,SAAS;KAG/C,IACE,EAHU,IAAI,OAAO,KAGhB,WAAW,aAAa,KAC7B,CAAC,IAAI,QAAQ,QAAQ,SAAS,WAAW,GAEzC,OAAO,KAAK;KAGd,MAAM,YAAY,KAAK,YAAY,YAAY;KAE/C,IAAI;MACF,IAAI,OAAO,MAAM,SAAS,WAAW,OAAO;MAC5C,OAAO,KAAK,QACV,UACA,4DACF;MAEA,IAAI,UAAU,KAAK,EAAE,gBAAgB,YAAY,CAAC;MAClD,IAAI,IAAI,IAAI;KACd,QAAQ;MACN,KAAK;KACP;IACF,CAAC;GACH;GACA,0BAA0B;IAExB,IADgB,OAAO,MAAM,IAAI,eACvB,GAAG,YAAY,OAAO,CAAC;IAEjC,OAAO,CACL;KACE,KAAK;KACL,OAAO,EAAE,MAAM,SAAS;KACxB,UAAU;KACV,UAAU;IACZ,CACF;GACF;EACF,CAAC;EAED,KAAK,eAAe,OAAO,WAAW,WAAW;GAC/C,IAAI;IACF,MAAM,MAAM,MAAM,OAAO,cAAc,kBAAkB;IACzD,UAAU,KAAK,IAAI,cAAc;GACnC,SAAS,KAAK;IACZ,MAAM,IAAI,YACR,uEACA,EAAE,OAAO,IAAI,CACf;GACF;EACF,CAAC;CACH;AACF,CAAC;AAED,MAAa,YAAY,UAA2B,CAAC,MAAM;CACzD,aAAa;EACX,MAAM,EAAE,WAAW,SAAS;EAC5B,OAAO,KAAK,uBAAuB,EAAE,IAAI,iBAAiB,OAAO;CACnE;AACF"}
|
package/dist/cli/i18n/index.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import * as _$alepha from "alepha";
|
|
2
1
|
import { Static } from "alepha";
|
|
3
|
-
import * as _$alepha_command0 from "alepha/command";
|
|
4
|
-
import * as _$alepha_logger0 from "alepha/logger";
|
|
5
2
|
import { ConsoleColorProvider } from "alepha/logger";
|
|
6
3
|
import { FileSystemProvider } from "alepha/system";
|
|
7
|
-
import * as _$typebox from "typebox";
|
|
8
4
|
|
|
9
5
|
//#region ../../src/cli/i18n/atoms/i18nOptions.d.ts
|
|
10
6
|
/**
|
|
@@ -13,14 +9,14 @@ import * as _$typebox from "typebox";
|
|
|
13
9
|
* Filled from the `i18n` plugin in `alepha.config.ts`.
|
|
14
10
|
* Read by `I18nCommand` to drive `alepha i18n check`.
|
|
15
11
|
*/
|
|
16
|
-
declare const i18nOptions:
|
|
12
|
+
declare const i18nOptions: import("alepha").Atom<import("typebox").TOptional<import("typebox").TObject<{
|
|
17
13
|
/**
|
|
18
14
|
* Directories (relative to the project root) to scan both for
|
|
19
15
|
* `$dictionary(...)` declarations and for translation key usage.
|
|
20
16
|
*
|
|
21
17
|
* @default ["src"]
|
|
22
18
|
*/
|
|
23
|
-
scan:
|
|
19
|
+
scan: import("typebox").TOptional<import("typebox").TArray<import("typebox").TString>>;
|
|
24
20
|
/**
|
|
25
21
|
* Key prefixes that are constructed at runtime (e.g. via template
|
|
26
22
|
* literals like `` tr(`archive.type.${kind}`) ``). Every key
|
|
@@ -32,7 +28,7 @@ declare const i18nOptions: _$alepha.Atom<_$typebox.TOptional<_$typebox.TObject<{
|
|
|
32
28
|
*
|
|
33
29
|
* @default []
|
|
34
30
|
*/
|
|
35
|
-
dynamicPrefixes:
|
|
31
|
+
dynamicPrefixes: import("typebox").TOptional<import("typebox").TArray<import("typebox").TString>>;
|
|
36
32
|
/**
|
|
37
33
|
* Additional path substrings (matched against the full file
|
|
38
34
|
* path) that should be excluded from the scan, on top of the
|
|
@@ -41,7 +37,7 @@ declare const i18nOptions: _$alepha.Atom<_$typebox.TOptional<_$typebox.TObject<{
|
|
|
41
37
|
*
|
|
42
38
|
* @default []
|
|
43
39
|
*/
|
|
44
|
-
exclude:
|
|
40
|
+
exclude: import("typebox").TOptional<import("typebox").TArray<import("typebox").TString>>;
|
|
45
41
|
}>>, "alepha.cli.i18n.options">;
|
|
46
42
|
/**
|
|
47
43
|
* Type for i18n options.
|
|
@@ -73,18 +69,25 @@ declare class I18nCheckService {
|
|
|
73
69
|
* Find unused translation keys.
|
|
74
70
|
*
|
|
75
71
|
* Discovery is fully static: we walk `scan` dirs, identify files
|
|
76
|
-
* that import `$dictionary` (matched via the literal substring)
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* exempted.
|
|
72
|
+
* that import `$dictionary` (matched via the literal substring) plus
|
|
73
|
+
* any per-language files they lazily `import(...)`, extract every
|
|
74
|
+
* `"a.b.c": ...` property key declared across them, then grep the
|
|
75
|
+
* remaining source files for a quoted-literal occurrence of each key.
|
|
76
|
+
* Anything matching a `dynamicPrefixes` entry is exempted.
|
|
81
77
|
*/
|
|
82
78
|
check(options: I18nCheckOptions): Promise<I18nCheckResult>;
|
|
79
|
+
/**
|
|
80
|
+
* Resolve a relative `import("…")` specifier from `fromFile` to an absolute
|
|
81
|
+
* path that was actually scanned. Returns `undefined` for bare/package
|
|
82
|
+
* specifiers or targets outside the scan set. Extensionless specifiers are
|
|
83
|
+
* probed against each supported source extension.
|
|
84
|
+
*/
|
|
85
|
+
protected resolveImport(fromFile: string, spec: string, files: Map<string, string>): string | undefined;
|
|
83
86
|
}
|
|
84
87
|
//#endregion
|
|
85
88
|
//#region ../../src/cli/i18n/commands/I18nCommand.d.ts
|
|
86
89
|
declare class I18nCommand {
|
|
87
|
-
protected readonly log:
|
|
90
|
+
protected readonly log: import("alepha/logger").Logger;
|
|
88
91
|
protected readonly options: Readonly<{
|
|
89
92
|
scan?: string[] | undefined;
|
|
90
93
|
dynamicPrefixes?: string[] | undefined;
|
|
@@ -97,8 +100,8 @@ declare class I18nCommand {
|
|
|
97
100
|
dynamicPrefixes: string[];
|
|
98
101
|
exclude: string[];
|
|
99
102
|
};
|
|
100
|
-
protected readonly check:
|
|
101
|
-
readonly i18n:
|
|
103
|
+
protected readonly check: import("alepha/command").CommandPrimitive<import("typebox").TObject<import("typebox").TProperties>, import("typebox").TSchema, import("typebox").TObject<import("typebox").TProperties>>;
|
|
104
|
+
readonly i18n: import("alepha/command").CommandPrimitive<import("typebox").TObject<import("typebox").TProperties>, import("typebox").TSchema, import("typebox").TObject<import("typebox").TProperties>>;
|
|
102
105
|
}
|
|
103
106
|
//#endregion
|
|
104
107
|
//#region ../../src/cli/i18n/index.d.ts
|
|
@@ -129,7 +132,7 @@ declare class I18nCommand {
|
|
|
129
132
|
* });
|
|
130
133
|
* ```
|
|
131
134
|
*/
|
|
132
|
-
declare const AlephaCliI18nPlugin:
|
|
135
|
+
declare const AlephaCliI18nPlugin: import("alepha").Service<import("alepha").Module>;
|
|
133
136
|
declare const i18n: (options?: I18nOptions) => () => void;
|
|
134
137
|
//#endregion
|
|
135
138
|
export { AlephaCliI18nPlugin, I18nCheckOptions, I18nCheckResult, I18nCheckService, I18nCommand, I18nOptions, i18n, i18nOptions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/cli/i18n/atoms/i18nOptions.ts","../../../src/cli/i18n/services/I18nCheckService.ts","../../../src/cli/i18n/commands/I18nCommand.ts","../../../src/cli/i18n/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/cli/i18n/atoms/i18nOptions.ts","../../../src/cli/i18n/services/I18nCheckService.ts","../../../src/cli/i18n/commands/I18nCommand.ts","../../../src/cli/i18n/index.ts"],"mappings":";;;;;;;;;AAQA;;cAAa,WAAA,mBAAW,IAAA,mBAAA,SAAA,mBAAA,OAAA;EAqCtB;;;;;;;;;;;;;;;;;;;EAKqB;;;;;;;AAAmC;;;;ACG1D;;KDHY,WAAA,GAAc,MAAM,QAAQ,WAAA,CAAY,MAAA;;;UCGnC,gBAAA;EACf,IAAA;EACA,IAAA;EACA,eAAA;EACA,OAAA;AAAA;AAAA,UAGe,eAAA;EDff;ECiBA,SAAA;EDtDsB;ECwDtB,UAAA;;EAEA,YAAA;;EAEA,eAAA;;EAEA,MAAA;AAAA;AAAA,cAGW,gBAAA;EAAA,mBACQ,EAAA,EAAE,kBAAA;;;;;;ADxBvB;;;;;ECoCQ,KAAA,CAAM,OAAA,EAAS,gBAAA,GAAmB,OAAA,CAAQ,eAAA;EDpCE;;AAAM;;;;EAAN,UCoIxC,aAAA,CACR,QAAA,UACA,IAAA,UACA,KAAA,EAAO,GAAA;AAAA;;;cCnLE,WAAA;EAAA,mBACQ,GAAA,0BAAG,MAAA;EAAA,mBACH,OAAA,EAAO,QAAA;;;;;qBACP,YAAA,EAAY,gBAAA;EAAA,mBACZ,KAAA,EAAK,oBAAA;EAAA,UAEd,cAAA;;;;;qBAQS,KAAA,2BAAK,gBAAA,mBAAA,OAAA,mBAAA,WAAA,qBAAA,OAAA,oBAAA,OAAA,mBAAA,WAAA;EAAA,SAoDR,IAAA,2BAAI,gBAAA,mBAAA,OAAA,mBAAA,WAAA,qBAAA,OAAA,oBAAA,OAAA,mBAAA,WAAA;AAAA;;;;;;;AFhEtB;;;;;;;;;;;;;;;;;;;;;AA0CA;;cGhBa,mBAAA,mBAAmB,OAAA,kBAAA,MAAA;AAAA,cAMnB,IAAA,GAAQ,OAAyB,GAAhB,WAAgB"}
|
package/dist/cli/i18n/index.js
CHANGED
|
@@ -80,17 +80,31 @@ const KEY_DECLARATION_RE = /"([\w-]+(?:\.[\w-]+)+)"\s*:/g;
|
|
|
80
80
|
* dictionary tucked away in an unusual location.
|
|
81
81
|
*/
|
|
82
82
|
const DICTIONARY_MARKER = "$dictionary";
|
|
83
|
+
/**
|
|
84
|
+
* Captures the module specifier of a lazily-imported dictionary, i.e. the
|
|
85
|
+
* `"./fr.ts"` in `$dictionary({ lazy: () => import("./fr.ts") })`. Apps
|
|
86
|
+
* commonly split each language into its own file so a session only ships the
|
|
87
|
+
* active locale — those key files carry no `$dictionary` marker, so without
|
|
88
|
+
* this the keys would be invisible to the check.
|
|
89
|
+
*
|
|
90
|
+
* `[^{}]*?` keeps the match inside the `$dictionary` call's own object literal
|
|
91
|
+
* (it stops at the first brace), so unrelated lazy imports in the same file —
|
|
92
|
+
* e.g. a sibling `$page({ lazy: () => import("./Page.tsx") })` or a
|
|
93
|
+
* `$dictionary` whose `lazy` returns an inline `({ default: {…} })` object —
|
|
94
|
+
* are never mistaken for dictionary key files.
|
|
95
|
+
*/
|
|
96
|
+
const DICTIONARY_LAZY_IMPORT_RE = /\$dictionary\s*\(\s*\{[^{}]*?import\s*\(\s*["']([^"']+)["']/g;
|
|
83
97
|
var I18nCheckService = class {
|
|
84
98
|
fs = $inject(FileSystemProvider);
|
|
85
99
|
/**
|
|
86
100
|
* Find unused translation keys.
|
|
87
101
|
*
|
|
88
102
|
* Discovery is fully static: we walk `scan` dirs, identify files
|
|
89
|
-
* that import `$dictionary` (matched via the literal substring)
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* exempted.
|
|
103
|
+
* that import `$dictionary` (matched via the literal substring) plus
|
|
104
|
+
* any per-language files they lazily `import(...)`, extract every
|
|
105
|
+
* `"a.b.c": ...` property key declared across them, then grep the
|
|
106
|
+
* remaining source files for a quoted-literal occurrence of each key.
|
|
107
|
+
* Anything matching a `dynamicPrefixes` entry is exempted.
|
|
94
108
|
*/
|
|
95
109
|
async check(options) {
|
|
96
110
|
const { root, scan, dynamicPrefixes, exclude } = options;
|
|
@@ -111,18 +125,26 @@ var I18nCheckService = class {
|
|
|
111
125
|
allFiles.push(abs);
|
|
112
126
|
}
|
|
113
127
|
}
|
|
114
|
-
const dictionaryFiles = [];
|
|
115
|
-
const allKeys = /* @__PURE__ */ new Set();
|
|
116
128
|
const fileContents = /* @__PURE__ */ new Map();
|
|
117
|
-
for (const file of allFiles)
|
|
118
|
-
|
|
119
|
-
|
|
129
|
+
for (const file of allFiles) fileContents.set(file, (await this.fs.readFile(file)).toString("utf8"));
|
|
130
|
+
const dictionarySet = /* @__PURE__ */ new Set();
|
|
131
|
+
for (const [file, text] of fileContents) {
|
|
120
132
|
if (!text.includes(DICTIONARY_MARKER)) continue;
|
|
133
|
+
dictionarySet.add(file);
|
|
134
|
+
for (const m of text.matchAll(DICTIONARY_LAZY_IMPORT_RE)) {
|
|
135
|
+
const target = this.resolveImport(file, m[1], fileContents);
|
|
136
|
+
if (target) dictionarySet.add(target);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const dictionaryFiles = [];
|
|
140
|
+
const allKeys = /* @__PURE__ */ new Set();
|
|
141
|
+
for (const file of dictionarySet) {
|
|
142
|
+
const text = fileContents.get(file);
|
|
143
|
+
if (!text) continue;
|
|
121
144
|
const before = allKeys.size;
|
|
122
145
|
for (const m of text.matchAll(KEY_DECLARATION_RE)) allKeys.add(m[1]);
|
|
123
146
|
if (allKeys.size > before) dictionaryFiles.push(file);
|
|
124
147
|
}
|
|
125
|
-
const dictionarySet = new Set(dictionaryFiles);
|
|
126
148
|
const corpusParts = [];
|
|
127
149
|
let scannedFiles = 0;
|
|
128
150
|
for (const [file, text] of fileContents) {
|
|
@@ -149,6 +171,18 @@ var I18nCheckService = class {
|
|
|
149
171
|
unused: unused.sort()
|
|
150
172
|
};
|
|
151
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Resolve a relative `import("…")` specifier from `fromFile` to an absolute
|
|
176
|
+
* path that was actually scanned. Returns `undefined` for bare/package
|
|
177
|
+
* specifiers or targets outside the scan set. Extensionless specifiers are
|
|
178
|
+
* probed against each supported source extension.
|
|
179
|
+
*/
|
|
180
|
+
resolveImport(fromFile, spec, files) {
|
|
181
|
+
if (!spec.startsWith(".")) return void 0;
|
|
182
|
+
const base = this.fs.join(fromFile, "..", spec);
|
|
183
|
+
if (files.has(base)) return base;
|
|
184
|
+
for (const ext of SCAN_EXTS) if (files.has(base + ext)) return base + ext;
|
|
185
|
+
}
|
|
152
186
|
};
|
|
153
187
|
//#endregion
|
|
154
188
|
//#region ../../src/cli/i18n/commands/I18nCommand.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cli/i18n/atoms/i18nOptions.ts","../../../src/cli/i18n/services/I18nCheckService.ts","../../../src/cli/i18n/commands/I18nCommand.ts","../../../src/cli/i18n/index.ts"],"sourcesContent":["import { $atom, type Static, t } from \"alepha\";\n\n/**\n * i18n CLI configuration atom.\n *\n * Filled from the `i18n` plugin in `alepha.config.ts`.\n * Read by `I18nCommand` to drive `alepha i18n check`.\n */\nexport const i18nOptions = $atom({\n name: \"alepha.cli.i18n.options\",\n description: \"i18n unused-key check configuration\",\n schema: t.optional(\n t.object({\n /**\n * Directories (relative to the project root) to scan both for\n * `$dictionary(...)` declarations and for translation key usage.\n *\n * @default [\"src\"]\n */\n scan: t.optional(t.array(t.text())),\n\n /**\n * Key prefixes that are constructed at runtime (e.g. via template\n * literals like `` tr(`archive.type.${kind}`) ``). Every key\n * starting with one of these prefixes is exempted from the\n * unused check.\n *\n * Keep this list short and audit it when a feature is removed —\n * a stale prefix here means dead keys can hide.\n *\n * @default []\n */\n dynamicPrefixes: t.optional(t.array(t.text())),\n\n /**\n * Additional path substrings (matched against the full file\n * path) that should be excluded from the scan, on top of the\n * defaults (`node_modules`, `dist`, `__tests__`, `.spec.*`,\n * `.test.*`, `.alepha`).\n *\n * @default []\n */\n exclude: t.optional(t.array(t.text())),\n }),\n ),\n});\n\n/**\n * Type for i18n options.\n */\nexport type I18nOptions = Static<typeof i18nOptions.schema>;\n","import { $inject } from \"alepha\";\nimport { FileSystemProvider } from \"alepha/system\";\n\n/**\n * File extensions considered when scanning for dictionaries / usage.\n */\nconst SCAN_EXTS = [\".ts\", \".tsx\", \".mts\", \".cts\"];\n\n/**\n * Built-in path substrings that are always excluded from scanning.\n */\nconst DEFAULT_EXCLUDES = [\n \"/node_modules/\",\n \"/dist/\",\n \"/__tests__/\",\n \"/.alepha/\",\n \".spec.ts\",\n \".spec.tsx\",\n \".test.ts\",\n \".test.tsx\",\n];\n\n/**\n * Matches a quoted dotted property key on the left-hand side of a\n * dictionary entry: `\"some.dotted.key\":`. The \"at least one dot\"\n * requirement rules out unrelated quoted strings (e.g. JSON literals\n * inside helper text).\n */\nconst KEY_DECLARATION_RE = /\"([\\w-]+(?:\\.[\\w-]+)+)\"\\s*:/g;\n\n/**\n * Heuristic for spotting files that declare a dictionary. Conservative\n * by design — we'd rather scan a few unrelated files than miss a\n * dictionary tucked away in an unusual location.\n */\nconst DICTIONARY_MARKER = \"$dictionary\";\n\nexport interface I18nCheckOptions {\n root: string;\n scan: string[];\n dynamicPrefixes: string[];\n exclude: string[];\n}\n\nexport interface I18nCheckResult {\n /** Total number of keys discovered across all dictionary files. */\n totalKeys: number;\n /** Number of keys exempted via `dynamicPrefixes`. */\n exemptKeys: number;\n /** Number of source files scanned for references. */\n scannedFiles: number;\n /** Dictionary files that contributed keys. */\n dictionaryFiles: string[];\n /** Keys that have no quoted-literal reference anywhere in the scan. */\n unused: string[];\n}\n\nexport class I18nCheckService {\n protected readonly fs = $inject(FileSystemProvider);\n\n /**\n * Find unused translation keys.\n *\n * Discovery is fully static: we walk `scan` dirs, identify files\n * that import `$dictionary` (matched via the literal substring),\n * extract every `\"a.b.c\": ...` property key declared in them, then\n * grep the remaining source files for a quoted-literal occurrence\n * of each key. Anything matching a `dynamicPrefixes` entry is\n * exempted.\n */\n async check(options: I18nCheckOptions): Promise<I18nCheckResult> {\n const { root, scan, dynamicPrefixes, exclude } = options;\n const excludes = [...DEFAULT_EXCLUDES, ...exclude];\n\n const allFiles: string[] = [];\n for (const dir of scan) {\n const absDir = this.fs.join(root, dir);\n let entries: string[];\n try {\n entries = await this.fs.ls(absDir, { recursive: true });\n } catch {\n // Missing scan dir is silently skipped — config carries\n // optional paths (e.g. .vendor/**) that may not exist locally.\n continue;\n }\n for (const rel of entries) {\n const abs = this.fs.join(absDir, rel);\n if (!SCAN_EXTS.some((ext) => abs.endsWith(ext))) continue;\n if (excludes.some((sub) => abs.includes(sub))) continue;\n allFiles.push(abs);\n }\n }\n\n const dictionaryFiles: string[] = [];\n const allKeys = new Set<string>();\n const fileContents = new Map<string, string>();\n\n for (const file of allFiles) {\n const text = (await this.fs.readFile(file)).toString(\"utf8\");\n fileContents.set(file, text);\n if (!text.includes(DICTIONARY_MARKER)) continue;\n const before = allKeys.size;\n for (const m of text.matchAll(KEY_DECLARATION_RE)) {\n allKeys.add(m[1]);\n }\n if (allKeys.size > before) dictionaryFiles.push(file);\n }\n\n // Concatenate every non-dictionary file into one corpus so each\n // key is tested with a single regex run rather than O(files × keys).\n const dictionarySet = new Set(dictionaryFiles);\n const corpusParts: string[] = [];\n let scannedFiles = 0;\n for (const [file, text] of fileContents) {\n if (dictionarySet.has(file)) continue;\n corpusParts.push(text);\n scannedFiles++;\n }\n const corpus = corpusParts.join(\"\\n\");\n\n let exemptKeys = 0;\n const unused: string[] = [];\n for (const key of allKeys) {\n if (dynamicPrefixes.some((p) => key.startsWith(p))) {\n exemptKeys++;\n continue;\n }\n const literal = key.replace(/[.\\\\]/g, (c) => `\\\\${c}`);\n // Key must appear as a quoted string literal — `\"...\"`, `'...'`,\n // or `` `...` ``. Quotes on both sides rule out accidental\n // substring hits in longer keys.\n const re = new RegExp(`[\"'\\`]${literal}[\"'\\`]`);\n if (!re.test(corpus)) unused.push(key);\n }\n\n return {\n totalKeys: allKeys.size,\n exemptKeys,\n scannedFiles,\n dictionaryFiles,\n unused: unused.sort(),\n };\n }\n}\n","import { $inject, $state } from \"alepha\";\nimport { $command } from \"alepha/command\";\nimport { $logger, ConsoleColorProvider } from \"alepha/logger\";\nimport { i18nOptions } from \"../atoms/i18nOptions.ts\";\nimport { I18nCheckService } from \"../services/I18nCheckService.ts\";\n\nexport class I18nCommand {\n protected readonly log = $logger();\n protected readonly options = $state(i18nOptions);\n protected readonly checkService = $inject(I18nCheckService);\n protected readonly color = $inject(ConsoleColorProvider);\n\n protected resolveOptions() {\n return {\n scan: this.options?.scan ?? [\"src\"],\n dynamicPrefixes: this.options?.dynamicPrefixes ?? [],\n exclude: this.options?.exclude ?? [],\n };\n }\n\n protected readonly check = $command({\n name: \"check\",\n description: \"Report translation keys with no quoted-literal reference\",\n handler: async ({ root }) => {\n const opts = this.resolveOptions();\n const c = this.color;\n\n const result = await this.checkService.check({ root, ...opts });\n\n if (result.totalKeys === 0) {\n process.stdout.write(\n `\\n${c.set(\"ORANGE\", \"warn\")} No translation keys found. ` +\n `Did the dictionary location change? ` +\n `Searched: ${opts.scan.join(\", \")}\\n\\n`,\n );\n process.exit(2);\n }\n\n process.stdout.write(\n `\\nChecked ${c.set(\"CYAN\", String(result.totalKeys))} keys across ` +\n `${c.set(\"CYAN\", String(result.scannedFiles))} files ` +\n `(${result.dictionaryFiles.length} dictionary ` +\n `${result.dictionaryFiles.length === 1 ? \"file\" : \"files\"}).\\n`,\n );\n if (result.exemptKeys > 0) {\n process.stdout.write(\n ` exempt (dynamic prefixes): ${result.exemptKeys}\\n`,\n );\n }\n\n if (result.unused.length === 0) {\n process.stdout.write(\n `\\n${c.set(\"GREEN\", \"✓\")} All translations are referenced.\\n\\n`,\n );\n return;\n }\n\n process.stdout.write(\n `\\n${c.set(\"RED\", \"✗\")} Unused translations (${result.unused.length}):\\n`,\n );\n for (const k of result.unused) {\n process.stdout.write(` ${c.set(\"DIM\", \"-\")} ${k}\\n`);\n }\n process.stdout.write(\n `\\nEither delete the key from its dictionary, or add its prefix to ` +\n `${c.set(\"CYAN\", \"dynamicPrefixes\")} in alepha.config.ts ` +\n `if it's constructed at runtime.\\n\\n`,\n );\n process.exit(1);\n },\n });\n\n public readonly i18n = $command({\n name: \"i18n\",\n description: \"Internationalization tooling\",\n children: [this.check],\n handler: async ({ help }) => {\n help();\n },\n });\n}\n","import { $context, $module } from \"alepha\";\nimport { type I18nOptions, i18nOptions } from \"./atoms/i18nOptions.ts\";\nimport { I18nCommand } from \"./commands/I18nCommand.ts\";\nimport { I18nCheckService } from \"./services/I18nCheckService.ts\";\n\n// ---------------------------------------------------------------------------\n\n/**\n * CLI plugin for finding unused translation keys.\n *\n * Statically scans the project for `$dictionary(...)` calls, extracts\n * every declared key, and reports the ones that have no quoted-literal\n * reference anywhere else in the source tree. Designed to be wired\n * into `yarn v` (or any verify pipeline) so dead i18n entries can't\n * pile up unnoticed when a feature is removed.\n *\n * Commands:\n * - `alepha i18n check` — report unused translation keys\n *\n * Configuration in `alepha.config.ts`:\n *\n * ```typescript\n * import { i18n } from \"alepha/cli/i18n\";\n *\n * export default defineConfig({\n * plugins: [\n * i18n({\n * scan: [\"src\", \".vendor/@alepha/ui\"],\n * dynamicPrefixes: [\"archive.type.\", \"petitions.filter.\"],\n * }),\n * ],\n * });\n * ```\n */\nexport const AlephaCliI18nPlugin = $module({\n name: \"alepha.cli.plugins.i18n\",\n atoms: [i18nOptions],\n services: [I18nCommand, I18nCheckService],\n});\n\nexport const i18n = (options: I18nOptions = {}) => {\n return () => {\n const { alepha } = $context();\n alepha.with(AlephaCliI18nPlugin).set(i18nOptions, options);\n };\n};\n\n// ---------------------------------------------------------------------------\n\nexport * from \"./atoms/i18nOptions.ts\";\nexport * from \"./commands/I18nCommand.ts\";\nexport * from \"./services/I18nCheckService.ts\";\n"],"mappings":";;;;;;;;;;;AAQA,MAAa,cAAc,MAAM;CAC/B,MAAM;CACN,aAAa;CACb,QAAQ,EAAE,SACR,EAAE,OAAO;;;;;;;EAOP,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;;;;;;;;;;;;EAanC,iBAAiB,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;;;;;;;;;EAU9C,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;EACvC,CAAC,CACH;CACF,CAAC;;;;;;ACvCF,MAAM,YAAY;CAAC;CAAO;CAAQ;CAAQ;CAAO;;;;AAKjD,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;AAQD,MAAM,qBAAqB;;;;;;AAO3B,MAAM,oBAAoB;AAsB1B,IAAa,mBAAb,MAA8B;CAC5B,KAAwB,QAAQ,mBAAmB;;;;;;;;;;;CAYnD,MAAM,MAAM,SAAqD;EAC/D,MAAM,EAAE,MAAM,MAAM,iBAAiB,YAAY;EACjD,MAAM,WAAW,CAAC,GAAG,kBAAkB,GAAG,QAAQ;EAElD,MAAM,WAAqB,EAAE;EAC7B,KAAK,MAAM,OAAO,MAAM;GACtB,MAAM,SAAS,KAAK,GAAG,K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b,KAAK,EAAE,IAAI,OAAO,IAAI,CAAC,wBAAwB,OAAO,OAAO,OAAO,MACrE;GACD,KAAK,MAAM,KAAK,OAAO,QACrB,QAAQ,OAAO,MAAM,KAAK,EAAE,IAAI,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI;GAEvD,QAAQ,OAAO,MACb,qEACK,EAAE,IAAI,QAAQ,kBAAkB,CAAC,0DAEvC;GACD,QAAQ,KAAK,EAAE;;EAElB,CAAC;CAEF,OAAuB,SAAS;EAC9B,MAAM;EACN,aAAa;EACb,UAAU,CAAC,KAAK,MAAM;EACtB,SAAS,OAAO,EAAE,WAAW;GAC3B,MAAM;;EAET,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC7CJ,MAAa,sBAAsB,QAAQ;CACzC,MAAM;CACN,OAAO,CAAC,YAAY;CACpB,UAAU,CAAC,aAAa,iBAAiB;CAC1C,CAAC;AAEF,MAAa,QAAQ,UAAuB,EAAE,KAAK;CACjD,aAAa;EACX,MAAM,EAAE,WAAW,UAAU;EAC7B,OAAO,KAAK,oBAAoB,CAAC,IAAI,aAAa,QAAQ"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cli/i18n/atoms/i18nOptions.ts","../../../src/cli/i18n/services/I18nCheckService.ts","../../../src/cli/i18n/commands/I18nCommand.ts","../../../src/cli/i18n/index.ts"],"sourcesContent":["import { $atom, type Static, t } from \"alepha\";\n\n/**\n * i18n CLI configuration atom.\n *\n * Filled from the `i18n` plugin in `alepha.config.ts`.\n * Read by `I18nCommand` to drive `alepha i18n check`.\n */\nexport const i18nOptions = $atom({\n name: \"alepha.cli.i18n.options\",\n description: \"i18n unused-key check configuration\",\n schema: t.optional(\n t.object({\n /**\n * Directories (relative to the project root) to scan both for\n * `$dictionary(...)` declarations and for translation key usage.\n *\n * @default [\"src\"]\n */\n scan: t.optional(t.array(t.text())),\n\n /**\n * Key prefixes that are constructed at runtime (e.g. via template\n * literals like `` tr(`archive.type.${kind}`) ``). Every key\n * starting with one of these prefixes is exempted from the\n * unused check.\n *\n * Keep this list short and audit it when a feature is removed —\n * a stale prefix here means dead keys can hide.\n *\n * @default []\n */\n dynamicPrefixes: t.optional(t.array(t.text())),\n\n /**\n * Additional path substrings (matched against the full file\n * path) that should be excluded from the scan, on top of the\n * defaults (`node_modules`, `dist`, `__tests__`, `.spec.*`,\n * `.test.*`, `.alepha`).\n *\n * @default []\n */\n exclude: t.optional(t.array(t.text())),\n }),\n ),\n});\n\n/**\n * Type for i18n options.\n */\nexport type I18nOptions = Static<typeof i18nOptions.schema>;\n","import { $inject } from \"alepha\";\nimport { FileSystemProvider } from \"alepha/system\";\n\n/**\n * File extensions considered when scanning for dictionaries / usage.\n */\nconst SCAN_EXTS = [\".ts\", \".tsx\", \".mts\", \".cts\"];\n\n/**\n * Built-in path substrings that are always excluded from scanning.\n */\nconst DEFAULT_EXCLUDES = [\n \"/node_modules/\",\n \"/dist/\",\n \"/__tests__/\",\n \"/.alepha/\",\n \".spec.ts\",\n \".spec.tsx\",\n \".test.ts\",\n \".test.tsx\",\n];\n\n/**\n * Matches a quoted dotted property key on the left-hand side of a\n * dictionary entry: `\"some.dotted.key\":`. The \"at least one dot\"\n * requirement rules out unrelated quoted strings (e.g. JSON literals\n * inside helper text).\n */\nconst KEY_DECLARATION_RE = /\"([\\w-]+(?:\\.[\\w-]+)+)\"\\s*:/g;\n\n/**\n * Heuristic for spotting files that declare a dictionary. Conservative\n * by design — we'd rather scan a few unrelated files than miss a\n * dictionary tucked away in an unusual location.\n */\nconst DICTIONARY_MARKER = \"$dictionary\";\n\n/**\n * Captures the module specifier of a lazily-imported dictionary, i.e. the\n * `\"./fr.ts\"` in `$dictionary({ lazy: () => import(\"./fr.ts\") })`. Apps\n * commonly split each language into its own file so a session only ships the\n * active locale — those key files carry no `$dictionary` marker, so without\n * this the keys would be invisible to the check.\n *\n * `[^{}]*?` keeps the match inside the `$dictionary` call's own object literal\n * (it stops at the first brace), so unrelated lazy imports in the same file —\n * e.g. a sibling `$page({ lazy: () => import(\"./Page.tsx\") })` or a\n * `$dictionary` whose `lazy` returns an inline `({ default: {…} })` object —\n * are never mistaken for dictionary key files.\n */\nconst DICTIONARY_LAZY_IMPORT_RE =\n /\\$dictionary\\s*\\(\\s*\\{[^{}]*?import\\s*\\(\\s*[\"']([^\"']+)[\"']/g;\n\nexport interface I18nCheckOptions {\n root: string;\n scan: string[];\n dynamicPrefixes: string[];\n exclude: string[];\n}\n\nexport interface I18nCheckResult {\n /** Total number of keys discovered across all dictionary files. */\n totalKeys: number;\n /** Number of keys exempted via `dynamicPrefixes`. */\n exemptKeys: number;\n /** Number of source files scanned for references. */\n scannedFiles: number;\n /** Dictionary files that contributed keys. */\n dictionaryFiles: string[];\n /** Keys that have no quoted-literal reference anywhere in the scan. */\n unused: string[];\n}\n\nexport class I18nCheckService {\n protected readonly fs = $inject(FileSystemProvider);\n\n /**\n * Find unused translation keys.\n *\n * Discovery is fully static: we walk `scan` dirs, identify files\n * that import `$dictionary` (matched via the literal substring) plus\n * any per-language files they lazily `import(...)`, extract every\n * `\"a.b.c\": ...` property key declared across them, then grep the\n * remaining source files for a quoted-literal occurrence of each key.\n * Anything matching a `dynamicPrefixes` entry is exempted.\n */\n async check(options: I18nCheckOptions): Promise<I18nCheckResult> {\n const { root, scan, dynamicPrefixes, exclude } = options;\n const excludes = [...DEFAULT_EXCLUDES, ...exclude];\n\n const allFiles: string[] = [];\n for (const dir of scan) {\n const absDir = this.fs.join(root, dir);\n let entries: string[];\n try {\n entries = await this.fs.ls(absDir, { recursive: true });\n } catch {\n // Missing scan dir is silently skipped — config carries\n // optional paths (e.g. .vendor/**) that may not exist locally.\n continue;\n }\n for (const rel of entries) {\n const abs = this.fs.join(absDir, rel);\n if (!SCAN_EXTS.some((ext) => abs.endsWith(ext))) continue;\n if (excludes.some((sub) => abs.includes(sub))) continue;\n allFiles.push(abs);\n }\n }\n\n const fileContents = new Map<string, string>();\n for (const file of allFiles) {\n fileContents.set(file, (await this.fs.readFile(file)).toString(\"utf8\"));\n }\n\n // A file is a dictionary if it declares `$dictionary` OR it is the target\n // of a `$dictionary({ lazy: () => import(\"…\") })` (the split per-language\n // key files, which carry no marker of their own). Resolving the lazy\n // targets first lets their keys be extracted below and keeps them out of\n // the usage corpus (their `\"key\": \"value\"` lines aren't references).\n const dictionarySet = new Set<string>();\n for (const [file, text] of fileContents) {\n if (!text.includes(DICTIONARY_MARKER)) continue;\n dictionarySet.add(file);\n for (const m of text.matchAll(DICTIONARY_LAZY_IMPORT_RE)) {\n const target = this.resolveImport(file, m[1], fileContents);\n if (target) dictionarySet.add(target);\n }\n }\n\n const dictionaryFiles: string[] = [];\n const allKeys = new Set<string>();\n for (const file of dictionarySet) {\n const text = fileContents.get(file);\n if (!text) continue;\n const before = allKeys.size;\n for (const m of text.matchAll(KEY_DECLARATION_RE)) {\n allKeys.add(m[1]);\n }\n if (allKeys.size > before) dictionaryFiles.push(file);\n }\n\n // Concatenate every non-dictionary file into one corpus so each\n // key is tested with a single regex run rather than O(files × keys).\n const corpusParts: string[] = [];\n let scannedFiles = 0;\n for (const [file, text] of fileContents) {\n if (dictionarySet.has(file)) continue;\n corpusParts.push(text);\n scannedFiles++;\n }\n const corpus = corpusParts.join(\"\\n\");\n\n let exemptKeys = 0;\n const unused: string[] = [];\n for (const key of allKeys) {\n if (dynamicPrefixes.some((p) => key.startsWith(p))) {\n exemptKeys++;\n continue;\n }\n const literal = key.replace(/[.\\\\]/g, (c) => `\\\\${c}`);\n // Key must appear as a quoted string literal — `\"...\"`, `'...'`,\n // or `` `...` ``. Quotes on both sides rule out accidental\n // substring hits in longer keys.\n const re = new RegExp(`[\"'\\`]${literal}[\"'\\`]`);\n if (!re.test(corpus)) unused.push(key);\n }\n\n return {\n totalKeys: allKeys.size,\n exemptKeys,\n scannedFiles,\n dictionaryFiles,\n unused: unused.sort(),\n };\n }\n\n /**\n * Resolve a relative `import(\"…\")` specifier from `fromFile` to an absolute\n * path that was actually scanned. Returns `undefined` for bare/package\n * specifiers or targets outside the scan set. Extensionless specifiers are\n * probed against each supported source extension.\n */\n protected resolveImport(\n fromFile: string,\n spec: string,\n files: Map<string, string>,\n ): string | undefined {\n if (!spec.startsWith(\".\")) return undefined;\n // `join(file, \"..\", spec)` drops the filename then applies the relative\n // specifier — i.e. resolves against `fromFile`'s directory.\n const base = this.fs.join(fromFile, \"..\", spec);\n if (files.has(base)) return base;\n for (const ext of SCAN_EXTS) {\n if (files.has(base + ext)) return base + ext;\n }\n return undefined;\n }\n}\n","import { $inject, $state } from \"alepha\";\nimport { $command } from \"alepha/command\";\nimport { $logger, ConsoleColorProvider } from \"alepha/logger\";\nimport { i18nOptions } from \"../atoms/i18nOptions.ts\";\nimport { I18nCheckService } from \"../services/I18nCheckService.ts\";\n\nexport class I18nCommand {\n protected readonly log = $logger();\n protected readonly options = $state(i18nOptions);\n protected readonly checkService = $inject(I18nCheckService);\n protected readonly color = $inject(ConsoleColorProvider);\n\n protected resolveOptions() {\n return {\n scan: this.options?.scan ?? [\"src\"],\n dynamicPrefixes: this.options?.dynamicPrefixes ?? [],\n exclude: this.options?.exclude ?? [],\n };\n }\n\n protected readonly check = $command({\n name: \"check\",\n description: \"Report translation keys with no quoted-literal reference\",\n handler: async ({ root }) => {\n const opts = this.resolveOptions();\n const c = this.color;\n\n const result = await this.checkService.check({ root, ...opts });\n\n if (result.totalKeys === 0) {\n process.stdout.write(\n `\\n${c.set(\"ORANGE\", \"warn\")} No translation keys found. ` +\n `Did the dictionary location change? ` +\n `Searched: ${opts.scan.join(\", \")}\\n\\n`,\n );\n process.exit(2);\n }\n\n process.stdout.write(\n `\\nChecked ${c.set(\"CYAN\", String(result.totalKeys))} keys across ` +\n `${c.set(\"CYAN\", String(result.scannedFiles))} files ` +\n `(${result.dictionaryFiles.length} dictionary ` +\n `${result.dictionaryFiles.length === 1 ? \"file\" : \"files\"}).\\n`,\n );\n if (result.exemptKeys > 0) {\n process.stdout.write(\n ` exempt (dynamic prefixes): ${result.exemptKeys}\\n`,\n );\n }\n\n if (result.unused.length === 0) {\n process.stdout.write(\n `\\n${c.set(\"GREEN\", \"✓\")} All translations are referenced.\\n\\n`,\n );\n return;\n }\n\n process.stdout.write(\n `\\n${c.set(\"RED\", \"✗\")} Unused translations (${result.unused.length}):\\n`,\n );\n for (const k of result.unused) {\n process.stdout.write(` ${c.set(\"DIM\", \"-\")} ${k}\\n`);\n }\n process.stdout.write(\n `\\nEither delete the key from its dictionary, or add its prefix to ` +\n `${c.set(\"CYAN\", \"dynamicPrefixes\")} in alepha.config.ts ` +\n `if it's constructed at runtime.\\n\\n`,\n );\n process.exit(1);\n },\n });\n\n public readonly i18n = $command({\n name: \"i18n\",\n description: \"Internationalization tooling\",\n children: [this.check],\n handler: async ({ help }) => {\n help();\n },\n });\n}\n","import { $context, $module } from \"alepha\";\nimport { type I18nOptions, i18nOptions } from \"./atoms/i18nOptions.ts\";\nimport { I18nCommand } from \"./commands/I18nCommand.ts\";\nimport { I18nCheckService } from \"./services/I18nCheckService.ts\";\n\n// ---------------------------------------------------------------------------\n\n/**\n * CLI plugin for finding unused translation keys.\n *\n * Statically scans the project for `$dictionary(...)` calls, extracts\n * every declared key, and reports the ones that have no quoted-literal\n * reference anywhere else in the source tree. Designed to be wired\n * into `yarn v` (or any verify pipeline) so dead i18n entries can't\n * pile up unnoticed when a feature is removed.\n *\n * Commands:\n * - `alepha i18n check` — report unused translation keys\n *\n * Configuration in `alepha.config.ts`:\n *\n * ```typescript\n * import { i18n } from \"alepha/cli/i18n\";\n *\n * export default defineConfig({\n * plugins: [\n * i18n({\n * scan: [\"src\", \".vendor/@alepha/ui\"],\n * dynamicPrefixes: [\"archive.type.\", \"petitions.filter.\"],\n * }),\n * ],\n * });\n * ```\n */\nexport const AlephaCliI18nPlugin = $module({\n name: \"alepha.cli.plugins.i18n\",\n atoms: [i18nOptions],\n services: [I18nCommand, I18nCheckService],\n});\n\nexport const i18n = (options: I18nOptions = {}) => {\n return () => {\n const { alepha } = $context();\n alepha.with(AlephaCliI18nPlugin).set(i18nOptions, options);\n };\n};\n\n// ---------------------------------------------------------------------------\n\nexport * from \"./atoms/i18nOptions.ts\";\nexport * from \"./commands/I18nCommand.ts\";\nexport * from \"./services/I18nCheckService.ts\";\n"],"mappings":";;;;;;;;;;;AAQA,MAAa,cAAc,MAAM;CAC/B,MAAM;CACN,aAAa;CACb,QAAQ,EAAE,SACR,EAAE,OAAO;;;;;;;EAOP,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;;;;;;;;;;;;EAalC,iBAAiB,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;;;;;;;;;EAU7C,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;CACvC,CAAC,CACH;AACF,CAAC;;;;;;ACvCD,MAAM,YAAY;CAAC;CAAO;CAAQ;CAAQ;AAAM;;;;AAKhD,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;AAQA,MAAM,qBAAqB;;;;;;AAO3B,MAAM,oBAAoB;;;;;;;;;;;;;;AAe1B,MAAM,4BACJ;AAsBF,IAAa,mBAAb,MAA8B;CAC5B,KAAwB,QAAQ,kBAAkB;;;;;;;;;;;CAYlD,MAAM,MAAM,SAAqD;EAC/D,MAAM,EAAE,MAAM,MAAM,iBAAiB,YAAY;EACjD,MAAM,WAAW,CAAC,GAAG,kBAAkB,GAAG,OAAO;EAEjD,MAAM,WAAqB,CAAC;EAC5B,KAAK,MAAM,OAAO,MAAM;GACtB,MAAM,SAAS,KAAK,GAAG,KAAK,MAAM,GAAG;GACrC,IAAI;GACJ,IAAI;IACF,UAAU,MAAM,KAAK,GAAG,GAAG,QAAQ,EAAE,WAAW,KAAK,CAAC;GACxD,QAAQ;IAGN;GACF;GACA,KAAK,MAAM,OAAO,SAAS;IACzB,MAAM,MAAM,KAAK,GAAG,KAAK,QAAQ,GAAG;IACpC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