gorsee 0.2.3 → 0.2.5
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 +261 -213
- package/dist-pkg/ai/artifact-lifecycle.d.ts +25 -0
- package/dist-pkg/ai/artifact-lifecycle.js +98 -0
- package/dist-pkg/ai/bridge.d.ts +26 -0
- package/dist-pkg/ai/bridge.js +82 -0
- package/dist-pkg/ai/bundle.d.ts +46 -0
- package/dist-pkg/ai/bundle.js +247 -0
- package/dist-pkg/ai/contracts.d.ts +1 -0
- package/dist-pkg/ai/contracts.js +1 -0
- package/dist-pkg/ai/ide.d.ts +37 -0
- package/dist-pkg/ai/ide.js +56 -0
- package/dist-pkg/ai/index.d.ts +85 -0
- package/dist-pkg/ai/index.js +267 -0
- package/dist-pkg/ai/json.d.ts +6 -0
- package/dist-pkg/ai/json.js +14 -0
- package/dist-pkg/ai/mcp.d.ts +28 -0
- package/dist-pkg/ai/mcp.js +152 -0
- package/dist-pkg/ai/session-pack.d.ts +28 -0
- package/dist-pkg/ai/session-pack.js +57 -0
- package/dist-pkg/ai/store.d.ts +67 -0
- package/dist-pkg/ai/store.js +174 -0
- package/dist-pkg/ai/summary.d.ts +57 -0
- package/dist-pkg/ai/summary.js +148 -0
- package/dist-pkg/ai/watch.d.ts +15 -0
- package/dist-pkg/ai/watch.js +66 -0
- package/dist-pkg/auth/action-tokens.d.ts +50 -0
- package/dist-pkg/auth/action-tokens.js +79 -0
- package/dist-pkg/auth/index.d.ts +70 -0
- package/dist-pkg/auth/index.js +199 -0
- package/dist-pkg/auth/redis-session-store.d.ts +7 -0
- package/dist-pkg/auth/redis-session-store.js +42 -0
- package/dist-pkg/auth/signing.d.ts +4 -0
- package/dist-pkg/auth/signing.js +33 -0
- package/dist-pkg/auth/sqlite-session-store.d.ts +12 -0
- package/dist-pkg/auth/sqlite-session-store.js +83 -0
- package/dist-pkg/auth/store-utils.d.ts +2 -0
- package/dist-pkg/auth/store-utils.js +20 -0
- package/dist-pkg/bin/gorsee.js +2 -0
- package/dist-pkg/build/backends/experimental-rolldown.d.ts +6 -0
- package/dist-pkg/build/backends/experimental-rolldown.js +9 -0
- package/dist-pkg/build/backends/register.d.ts +7 -0
- package/dist-pkg/build/backends/register.js +24 -0
- package/dist-pkg/build/backends/rolldown.d.ts +16 -0
- package/dist-pkg/build/backends/rolldown.js +176 -0
- package/dist-pkg/build/client-backend.d.ts +31 -0
- package/dist-pkg/build/client-backend.js +97 -0
- package/dist-pkg/build/client.d.ts +12 -0
- package/dist-pkg/build/client.js +93 -0
- package/dist-pkg/build/css-modules.d.ts +10 -0
- package/dist-pkg/build/css-modules.js +51 -0
- package/dist-pkg/build/devalue-parse.d.ts +1 -0
- package/dist-pkg/build/devalue-parse.js +1 -0
- package/dist-pkg/build/diagnostics.d.ts +20 -0
- package/dist-pkg/build/diagnostics.js +35 -0
- package/dist-pkg/build/fixtures.d.ts +7 -0
- package/dist-pkg/build/fixtures.js +60 -0
- package/dist-pkg/build/framework-imports.d.ts +4 -0
- package/dist-pkg/build/framework-imports.js +58 -0
- package/dist-pkg/build/init.d.ts +1 -0
- package/dist-pkg/build/init.js +6 -0
- package/dist-pkg/build/manifest.d.ts +3 -0
- package/dist-pkg/build/manifest.js +23 -0
- package/dist-pkg/build/parity.d.ts +32 -0
- package/dist-pkg/build/parity.js +71 -0
- package/dist-pkg/build/plugin.d.ts +11 -0
- package/dist-pkg/build/plugin.js +8 -0
- package/dist-pkg/build/readiness.d.ts +11 -0
- package/dist-pkg/build/readiness.js +18 -0
- package/dist-pkg/build/route-client-transform.d.ts +17 -0
- package/dist-pkg/build/route-client-transform.js +48 -0
- package/dist-pkg/build/route-metadata.d.ts +6 -0
- package/dist-pkg/build/route-metadata.js +8 -0
- package/dist-pkg/build/rpc-transform.d.ts +1 -0
- package/dist-pkg/build/rpc-transform.js +44 -0
- package/dist-pkg/build/server-bundle.d.ts +4 -0
- package/dist-pkg/build/server-bundle.js +261 -0
- package/dist-pkg/build/server-strip.d.ts +2 -0
- package/dist-pkg/build/server-strip.js +32 -0
- package/dist-pkg/build/ssg.d.ts +12 -0
- package/dist-pkg/build/ssg.js +36 -0
- package/dist-pkg/cli/bun-plugin.d.ts +2 -0
- package/dist-pkg/cli/bun-plugin.js +14 -0
- package/dist-pkg/cli/canonical-import-rewrite.d.ts +18 -0
- package/dist-pkg/cli/canonical-import-rewrite.js +94 -0
- package/dist-pkg/cli/canonical-imports.d.ts +8 -0
- package/dist-pkg/cli/canonical-imports.js +131 -0
- package/dist-pkg/cli/check-ast.d.ts +20 -0
- package/dist-pkg/cli/check-ast.js +126 -0
- package/dist-pkg/cli/cmd-ai.d.ts +4 -0
- package/dist-pkg/cli/cmd-ai.js +290 -0
- package/dist-pkg/cli/cmd-build.d.ts +12 -0
- package/dist-pkg/cli/cmd-build.js +198 -0
- package/dist-pkg/cli/cmd-check.d.ts +25 -0
- package/dist-pkg/cli/cmd-check.js +573 -0
- package/dist-pkg/cli/cmd-create.d.ts +6 -0
- package/dist-pkg/cli/cmd-create.js +600 -0
- package/dist-pkg/cli/cmd-deploy.d.ts +6 -0
- package/dist-pkg/cli/cmd-deploy.js +381 -0
- package/dist-pkg/cli/cmd-dev.d.ts +5 -0
- package/dist-pkg/cli/cmd-dev.js +5 -0
- package/dist-pkg/cli/cmd-docs.d.ts +50 -0
- package/dist-pkg/cli/cmd-docs.js +122 -0
- package/dist-pkg/cli/cmd-generate.d.ts +12 -0
- package/dist-pkg/cli/cmd-generate.js +320 -0
- package/dist-pkg/cli/cmd-migrate.d.ts +7 -0
- package/dist-pkg/cli/cmd-migrate.js +42 -0
- package/dist-pkg/cli/cmd-routes.d.ts +6 -0
- package/dist-pkg/cli/cmd-routes.js +24 -0
- package/dist-pkg/cli/cmd-start.d.ts +13 -0
- package/dist-pkg/cli/cmd-start.js +32 -0
- package/dist-pkg/cli/cmd-test.d.ts +20 -0
- package/dist-pkg/cli/cmd-test.js +103 -0
- package/dist-pkg/cli/cmd-typegen.d.ts +7 -0
- package/dist-pkg/cli/cmd-typegen.js +66 -0
- package/dist-pkg/cli/cmd-upgrade.d.ts +38 -0
- package/dist-pkg/cli/cmd-upgrade.js +232 -0
- package/dist-pkg/cli/context.d.ts +4 -0
- package/dist-pkg/cli/context.js +4 -0
- package/dist-pkg/cli/framework-md.d.ts +1 -0
- package/dist-pkg/cli/framework-md.js +391 -0
- package/dist-pkg/cli/index.d.ts +6 -0
- package/dist-pkg/cli/index.js +106 -0
- package/dist-pkg/cli/release-version.d.ts +2 -0
- package/dist-pkg/cli/release-version.js +33 -0
- package/dist-pkg/client.d.ts +16 -0
- package/dist-pkg/client.js +71 -0
- package/dist-pkg/compat.d.ts +1 -0
- package/dist-pkg/compat.js +1 -0
- package/dist-pkg/compiler/analysis-backend.d.ts +20 -0
- package/dist-pkg/compiler/analysis-backend.js +164 -0
- package/dist-pkg/compiler/backends/experimental-oxc.d.ts +6 -0
- package/dist-pkg/compiler/backends/experimental-oxc.js +9 -0
- package/dist-pkg/compiler/backends/oxc.d.ts +16 -0
- package/dist-pkg/compiler/backends/oxc.js +198 -0
- package/dist-pkg/compiler/backends/register.d.ts +7 -0
- package/dist-pkg/compiler/backends/register.js +22 -0
- package/dist-pkg/compiler/fixtures.d.ts +2 -0
- package/dist-pkg/compiler/fixtures.js +118 -0
- package/dist-pkg/compiler/init.d.ts +1 -0
- package/dist-pkg/compiler/init.js +6 -0
- package/dist-pkg/compiler/module-analysis.d.ts +13 -0
- package/dist-pkg/compiler/module-analysis.js +50 -0
- package/dist-pkg/compiler/parity.d.ts +35 -0
- package/dist-pkg/compiler/parity.js +89 -0
- package/dist-pkg/compiler/readiness.d.ts +11 -0
- package/dist-pkg/compiler/readiness.js +18 -0
- package/dist-pkg/compiler/route-facts.d.ts +34 -0
- package/dist-pkg/compiler/route-facts.js +75 -0
- package/dist-pkg/content/index.d.ts +27 -0
- package/dist-pkg/content/index.js +287 -0
- package/dist-pkg/db/index.d.ts +3 -0
- package/dist-pkg/db/index.js +6 -0
- package/dist-pkg/db/migrate.d.ts +7 -0
- package/dist-pkg/db/migrate.js +53 -0
- package/dist-pkg/db/postgres.d.ts +29 -0
- package/dist-pkg/db/postgres.js +59 -0
- package/dist-pkg/db/sqlite.d.ts +10 -0
- package/dist-pkg/db/sqlite.js +22 -0
- package/dist-pkg/deploy/cloudflare.d.ts +8 -0
- package/{src/deploy/cloudflare.ts → dist-pkg/deploy/cloudflare.js} +24 -26
- package/dist-pkg/deploy/conformance.d.ts +21 -0
- package/dist-pkg/deploy/conformance.js +98 -0
- package/dist-pkg/deploy/dockerfile.d.ts +3 -0
- package/{src/deploy/dockerfile.ts → dist-pkg/deploy/dockerfile.js} +8 -10
- package/dist-pkg/deploy/fly.d.ts +3 -0
- package/{src/deploy/fly.ts → dist-pkg/deploy/fly.js} +11 -12
- package/dist-pkg/deploy/index.d.ts +6 -0
- package/dist-pkg/deploy/index.js +26 -0
- package/dist-pkg/deploy/netlify.d.ts +2 -0
- package/{src/deploy/netlify.ts → dist-pkg/deploy/netlify.js} +17 -11
- package/dist-pkg/deploy/runtime.d.ts +2 -0
- package/dist-pkg/deploy/runtime.js +3 -0
- package/dist-pkg/deploy/vercel.d.ts +22 -0
- package/dist-pkg/deploy/vercel.js +53 -0
- package/dist-pkg/dev/error-overlay.d.ts +1 -0
- package/{src/dev/error-overlay.ts → dist-pkg/dev/error-overlay.js} +13 -23
- package/dist-pkg/dev/hmr.d.ts +30 -0
- package/dist-pkg/dev/hmr.js +86 -0
- package/dist-pkg/dev/partial-handler.d.ts +9 -0
- package/dist-pkg/dev/partial-handler.js +24 -0
- package/dist-pkg/dev/request-handler.d.ts +30 -0
- package/dist-pkg/dev/request-handler.js +67 -0
- package/dist-pkg/dev/watcher.d.ts +6 -0
- package/dist-pkg/dev/watcher.js +34 -0
- package/dist-pkg/dev.d.ts +11 -0
- package/dist-pkg/dev.js +268 -0
- package/dist-pkg/env/index.d.ts +3 -0
- package/dist-pkg/env/index.js +57 -0
- package/dist-pkg/errors/catalog.d.ts +9 -0
- package/{src/errors/catalog.ts → dist-pkg/errors/catalog.js} +8 -24
- package/dist-pkg/errors/formatter.d.ts +22 -0
- package/dist-pkg/errors/formatter.js +43 -0
- package/dist-pkg/errors/index.d.ts +2 -0
- package/dist-pkg/errors/index.js +2 -0
- package/dist-pkg/forms/action.d.ts +15 -0
- package/dist-pkg/forms/action.js +20 -0
- package/dist-pkg/forms/index.d.ts +4 -0
- package/dist-pkg/forms/index.js +12 -0
- package/dist-pkg/i18n/index.d.ts +61 -0
- package/dist-pkg/i18n/index.js +147 -0
- package/dist-pkg/index-client.d.ts +1 -0
- package/dist-pkg/index-client.js +1 -0
- package/dist-pkg/index.d.ts +32 -0
- package/dist-pkg/index.js +79 -0
- package/dist-pkg/jsx-runtime-client.d.ts +8 -0
- package/dist-pkg/jsx-runtime-client.js +1 -0
- package/dist-pkg/jsx-runtime.d.ts +13 -0
- package/dist-pkg/jsx-runtime.js +5 -0
- package/dist-pkg/jsx-types-html.d.ts +221 -0
- package/dist-pkg/jsx-types-html.js +0 -0
- package/dist-pkg/log/index.d.ts +8 -0
- package/dist-pkg/log/index.js +55 -0
- package/dist-pkg/plugins/drizzle.d.ts +16 -0
- package/dist-pkg/plugins/drizzle.js +50 -0
- package/dist-pkg/plugins/index.d.ts +62 -0
- package/dist-pkg/plugins/index.js +147 -0
- package/dist-pkg/plugins/lucia.d.ts +26 -0
- package/dist-pkg/plugins/lucia.js +63 -0
- package/dist-pkg/plugins/prisma.d.ts +14 -0
- package/dist-pkg/plugins/prisma.js +57 -0
- package/dist-pkg/plugins/resend.d.ts +21 -0
- package/dist-pkg/plugins/resend.js +45 -0
- package/dist-pkg/plugins/s3.d.ts +18 -0
- package/dist-pkg/plugins/s3.js +63 -0
- package/dist-pkg/plugins/stripe.d.ts +32 -0
- package/dist-pkg/plugins/stripe.js +69 -0
- package/dist-pkg/plugins/tailwind.d.ts +15 -0
- package/dist-pkg/plugins/tailwind.js +58 -0
- package/dist-pkg/prod.d.ts +21 -0
- package/dist-pkg/prod.js +347 -0
- package/dist-pkg/reactive/computed.d.ts +3 -0
- package/dist-pkg/reactive/computed.js +15 -0
- package/dist-pkg/reactive/data.d.ts +25 -0
- package/dist-pkg/reactive/data.js +56 -0
- package/dist-pkg/reactive/diagnostics.d.ts +100 -0
- package/dist-pkg/reactive/diagnostics.js +363 -0
- package/dist-pkg/reactive/effect.d.ts +3 -0
- package/dist-pkg/reactive/effect.js +6 -0
- package/dist-pkg/reactive/index.d.ts +9 -0
- package/dist-pkg/reactive/index.js +18 -0
- package/dist-pkg/reactive/live.d.ts +15 -0
- package/dist-pkg/reactive/live.js +58 -0
- package/dist-pkg/reactive/optimistic.d.ts +20 -0
- package/dist-pkg/reactive/optimistic.js +54 -0
- package/dist-pkg/reactive/resource.d.ts +25 -0
- package/dist-pkg/reactive/resource.js +97 -0
- package/dist-pkg/reactive/signal.d.ts +4 -0
- package/dist-pkg/reactive/signal.js +17 -0
- package/dist-pkg/reactive/store.d.ts +6 -0
- package/dist-pkg/reactive/store.js +19 -0
- package/dist-pkg/router/index.d.ts +2 -0
- package/dist-pkg/router/index.js +2 -0
- package/dist-pkg/router/matcher.d.ts +7 -0
- package/dist-pkg/router/matcher.js +40 -0
- package/dist-pkg/router/scanner.d.ts +14 -0
- package/dist-pkg/router/scanner.js +141 -0
- package/dist-pkg/routes/index.d.ts +1 -0
- package/dist-pkg/routes/index.js +10 -0
- package/dist-pkg/runtime/app-config.d.ts +26 -0
- package/dist-pkg/runtime/app-config.js +69 -0
- package/dist-pkg/runtime/client.d.ts +3 -0
- package/dist-pkg/runtime/client.js +31 -0
- package/dist-pkg/runtime/devtools.d.ts +64 -0
- package/dist-pkg/runtime/devtools.js +132 -0
- package/dist-pkg/runtime/error-boundary.d.ts +6 -0
- package/dist-pkg/runtime/error-boundary.js +17 -0
- package/dist-pkg/runtime/event-replay.d.ts +3 -0
- package/{src/runtime/event-replay.ts → dist-pkg/runtime/event-replay.js} +7 -22
- package/dist-pkg/runtime/event-source.d.ts +7 -0
- package/dist-pkg/runtime/event-source.js +24 -0
- package/dist-pkg/runtime/form.d.ts +24 -0
- package/dist-pkg/runtime/form.js +59 -0
- package/dist-pkg/runtime/head.d.ts +7 -0
- package/dist-pkg/runtime/head.js +90 -0
- package/dist-pkg/runtime/html-escape.d.ts +7 -0
- package/dist-pkg/runtime/html-escape.js +39 -0
- package/dist-pkg/runtime/hydration.d.ts +15 -0
- package/dist-pkg/runtime/hydration.js +103 -0
- package/dist-pkg/runtime/image.d.ts +49 -0
- package/dist-pkg/runtime/image.js +144 -0
- package/dist-pkg/runtime/index.d.ts +17 -0
- package/dist-pkg/runtime/index.js +59 -0
- package/dist-pkg/runtime/island-hydrator.d.ts +12 -0
- package/dist-pkg/runtime/island-hydrator.js +49 -0
- package/dist-pkg/runtime/island.d.ts +19 -0
- package/dist-pkg/runtime/island.js +36 -0
- package/dist-pkg/runtime/jsx-runtime.d.ts +12 -0
- package/dist-pkg/runtime/jsx-runtime.js +173 -0
- package/dist-pkg/runtime/link.d.ts +16 -0
- package/dist-pkg/runtime/link.js +47 -0
- package/dist-pkg/runtime/project.d.ts +37 -0
- package/dist-pkg/runtime/project.js +36 -0
- package/dist-pkg/runtime/renderable.d.ts +6 -0
- package/dist-pkg/runtime/renderable.js +0 -0
- package/dist-pkg/runtime/router.d.ts +47 -0
- package/dist-pkg/runtime/router.js +476 -0
- package/dist-pkg/runtime/server.d.ts +8 -0
- package/dist-pkg/runtime/server.js +71 -0
- package/dist-pkg/runtime/stream.d.ts +29 -0
- package/dist-pkg/runtime/stream.js +106 -0
- package/dist-pkg/runtime/suspense.d.ts +6 -0
- package/dist-pkg/runtime/suspense.js +16 -0
- package/dist-pkg/runtime/typed-routes.d.ts +24 -0
- package/dist-pkg/runtime/typed-routes.js +77 -0
- package/dist-pkg/runtime/validated-form.d.ts +40 -0
- package/dist-pkg/runtime/validated-form.js +120 -0
- package/dist-pkg/security/cors.d.ts +10 -0
- package/dist-pkg/security/cors.js +56 -0
- package/dist-pkg/security/csrf.d.ts +9 -0
- package/dist-pkg/security/csrf.js +53 -0
- package/dist-pkg/security/headers.d.ts +11 -0
- package/dist-pkg/security/headers.js +31 -0
- package/dist-pkg/security/index.d.ts +5 -0
- package/dist-pkg/security/index.js +5 -0
- package/dist-pkg/security/rate-limit.d.ts +10 -0
- package/dist-pkg/security/rate-limit.js +49 -0
- package/dist-pkg/security/redis-rate-limit.d.ts +14 -0
- package/dist-pkg/security/redis-rate-limit.js +23 -0
- package/dist-pkg/server/action.d.ts +21 -0
- package/dist-pkg/server/action.js +64 -0
- package/dist-pkg/server/cache-utils.d.ts +2 -0
- package/dist-pkg/server/cache-utils.js +26 -0
- package/dist-pkg/server/cache.d.ts +33 -0
- package/dist-pkg/server/cache.js +236 -0
- package/dist-pkg/server/compress.d.ts +2 -0
- package/dist-pkg/server/compress.js +49 -0
- package/dist-pkg/server/endpoint-execution.d.ts +28 -0
- package/dist-pkg/server/endpoint-execution.js +37 -0
- package/dist-pkg/server/etag.d.ts +3 -0
- package/dist-pkg/server/etag.js +18 -0
- package/dist-pkg/server/guard.d.ts +16 -0
- package/dist-pkg/server/guard.js +45 -0
- package/dist-pkg/server/html-shell.d.ts +12 -0
- package/dist-pkg/server/html-shell.js +52 -0
- package/dist-pkg/server/index.d.ts +36 -0
- package/dist-pkg/server/index.js +170 -0
- package/dist-pkg/server/jobs.d.ts +41 -0
- package/dist-pkg/server/jobs.js +81 -0
- package/dist-pkg/server/manifest.d.ts +19 -0
- package/dist-pkg/server/manifest.js +36 -0
- package/dist-pkg/server/middleware.d.ts +39 -0
- package/dist-pkg/server/middleware.js +122 -0
- package/dist-pkg/server/mime.d.ts +1 -0
- package/{src/server/mime.ts → dist-pkg/server/mime.js} +6 -17
- package/dist-pkg/server/not-found.d.ts +6 -0
- package/dist-pkg/server/not-found.js +24 -0
- package/dist-pkg/server/page-render.d.ts +29 -0
- package/dist-pkg/server/page-render.js +67 -0
- package/dist-pkg/server/partial-navigation.d.ts +4 -0
- package/dist-pkg/server/partial-navigation.js +16 -0
- package/dist-pkg/server/pipe.d.ts +9 -0
- package/dist-pkg/server/pipe.js +32 -0
- package/dist-pkg/server/redis-cache-store.d.ts +10 -0
- package/dist-pkg/server/redis-cache-store.js +73 -0
- package/dist-pkg/server/redis-client.d.ts +37 -0
- package/dist-pkg/server/redis-client.js +37 -0
- package/dist-pkg/server/request-policy.d.ts +55 -0
- package/dist-pkg/server/request-policy.js +216 -0
- package/dist-pkg/server/request-preflight.d.ts +23 -0
- package/dist-pkg/server/request-preflight.js +45 -0
- package/dist-pkg/server/request-security-policy.d.ts +17 -0
- package/dist-pkg/server/request-security-policy.js +34 -0
- package/dist-pkg/server/request-surface.d.ts +8 -0
- package/dist-pkg/server/request-surface.js +19 -0
- package/dist-pkg/server/route-request.d.ts +31 -0
- package/dist-pkg/server/route-request.js +112 -0
- package/dist-pkg/server/route-response.d.ts +22 -0
- package/dist-pkg/server/route-response.js +58 -0
- package/dist-pkg/server/rpc-hash.d.ts +2 -0
- package/dist-pkg/server/rpc-hash.js +7 -0
- package/dist-pkg/server/rpc-protocol.d.ts +22 -0
- package/dist-pkg/server/rpc-protocol.js +28 -0
- package/dist-pkg/server/rpc-utils.d.ts +2 -0
- package/dist-pkg/server/rpc-utils.js +26 -0
- package/dist-pkg/server/rpc.d.ts +20 -0
- package/dist-pkg/server/rpc.js +147 -0
- package/dist-pkg/server/runtime-dispatch.d.ts +19 -0
- package/dist-pkg/server/runtime-dispatch.js +67 -0
- package/dist-pkg/server/server-execution.d.ts +22 -0
- package/dist-pkg/server/server-execution.js +53 -0
- package/dist-pkg/server/sqlite-cache-store.d.ts +13 -0
- package/dist-pkg/server/sqlite-cache-store.js +88 -0
- package/dist-pkg/server/sse.d.ts +9 -0
- package/dist-pkg/server/sse.js +34 -0
- package/dist-pkg/server/static-file.d.ts +9 -0
- package/dist-pkg/server/static-file.js +43 -0
- package/dist-pkg/server/ws.d.ts +18 -0
- package/dist-pkg/server/ws.js +40 -0
- package/dist-pkg/server-entry.d.ts +19 -0
- package/dist-pkg/server-entry.js +93 -0
- package/dist-pkg/testing/index.d.ts +98 -0
- package/dist-pkg/testing/index.js +254 -0
- package/dist-pkg/types/index.d.ts +4 -0
- package/dist-pkg/types/index.js +4 -0
- package/dist-pkg/types/safe-html.d.ts +7 -0
- package/dist-pkg/types/safe-html.js +19 -0
- package/dist-pkg/types/safe-sql.d.ts +8 -0
- package/dist-pkg/types/safe-sql.js +14 -0
- package/dist-pkg/types/safe-url.d.ts +7 -0
- package/dist-pkg/types/safe-url.js +20 -0
- package/dist-pkg/types/user-input.d.ts +9 -0
- package/dist-pkg/types/user-input.js +3 -0
- package/dist-pkg/unsafe/index.d.ts +12 -0
- package/dist-pkg/unsafe/index.js +6 -0
- package/package.json +102 -44
- package/bin/gorsee.js +0 -14
- package/src/auth/index.ts +0 -178
- package/src/auth/redis-session-store.ts +0 -46
- package/src/auth/sqlite-session-store.ts +0 -98
- package/src/auth/store-utils.ts +0 -21
- package/src/build/client.ts +0 -139
- package/src/build/css-modules.ts +0 -69
- package/src/build/devalue-parse.ts +0 -2
- package/src/build/manifest.ts +0 -34
- package/src/build/route-metadata.ts +0 -12
- package/src/build/rpc-transform.ts +0 -62
- package/src/build/server-strip.ts +0 -87
- package/src/build/ssg.ts +0 -70
- package/src/cli/bun-plugin.ts +0 -58
- package/src/cli/cmd-build.ts +0 -153
- package/src/cli/cmd-check.ts +0 -239
- package/src/cli/cmd-create.ts +0 -328
- package/src/cli/cmd-deploy.ts +0 -149
- package/src/cli/cmd-dev.ts +0 -13
- package/src/cli/cmd-docs.ts +0 -152
- package/src/cli/cmd-generate.ts +0 -155
- package/src/cli/cmd-migrate.ts +0 -53
- package/src/cli/cmd-routes.ts +0 -36
- package/src/cli/cmd-start.ts +0 -30
- package/src/cli/cmd-test.ts +0 -129
- package/src/cli/cmd-typegen.ts +0 -93
- package/src/cli/cmd-upgrade.ts +0 -143
- package/src/cli/context.ts +0 -12
- package/src/cli/framework-md.ts +0 -223
- package/src/cli/index.ts +0 -107
- package/src/client.ts +0 -26
- package/src/db/index.ts +0 -2
- package/src/db/migrate.ts +0 -89
- package/src/db/sqlite.ts +0 -40
- package/src/deploy/index.ts +0 -31
- package/src/deploy/vercel.ts +0 -94
- package/src/dev/hmr.ts +0 -31
- package/src/dev/partial-handler.ts +0 -52
- package/src/dev/request-handler.ts +0 -127
- package/src/dev/watcher.ts +0 -48
- package/src/dev.ts +0 -208
- package/src/env/index.ts +0 -74
- package/src/errors/formatter.ts +0 -63
- package/src/errors/index.ts +0 -2
- package/src/i18n/index.ts +0 -72
- package/src/index-client.ts +0 -4
- package/src/index.ts +0 -43
- package/src/jsx-runtime-client.ts +0 -13
- package/src/jsx-runtime.ts +0 -20
- package/src/jsx-types-html.ts +0 -242
- package/src/log/index.ts +0 -44
- package/src/plugins/drizzle.ts +0 -84
- package/src/plugins/index.ts +0 -86
- package/src/plugins/lucia.ts +0 -111
- package/src/plugins/prisma.ts +0 -85
- package/src/plugins/resend.ts +0 -78
- package/src/plugins/s3.ts +0 -102
- package/src/plugins/stripe.ts +0 -133
- package/src/plugins/tailwind.ts +0 -92
- package/src/prod.ts +0 -252
- package/src/reactive/computed.ts +0 -7
- package/src/reactive/effect.ts +0 -7
- package/src/reactive/index.ts +0 -7
- package/src/reactive/live.ts +0 -97
- package/src/reactive/optimistic.ts +0 -83
- package/src/reactive/resource.ts +0 -138
- package/src/reactive/signal.ts +0 -20
- package/src/reactive/store.ts +0 -36
- package/src/router/index.ts +0 -2
- package/src/router/matcher.ts +0 -53
- package/src/router/scanner.ts +0 -206
- package/src/runtime/client.ts +0 -28
- package/src/runtime/error-boundary.ts +0 -35
- package/src/runtime/form.ts +0 -49
- package/src/runtime/head.ts +0 -113
- package/src/runtime/html-escape.ts +0 -30
- package/src/runtime/hydration.ts +0 -95
- package/src/runtime/image.ts +0 -48
- package/src/runtime/index.ts +0 -12
- package/src/runtime/island-hydrator.ts +0 -84
- package/src/runtime/island.ts +0 -88
- package/src/runtime/jsx-runtime.ts +0 -167
- package/src/runtime/link.ts +0 -45
- package/src/runtime/project.ts +0 -73
- package/src/runtime/router.ts +0 -224
- package/src/runtime/server.ts +0 -102
- package/src/runtime/stream.ts +0 -182
- package/src/runtime/suspense.ts +0 -37
- package/src/runtime/typed-routes.ts +0 -26
- package/src/runtime/validated-form.ts +0 -106
- package/src/security/cors.ts +0 -80
- package/src/security/csrf.ts +0 -85
- package/src/security/headers.ts +0 -50
- package/src/security/index.ts +0 -4
- package/src/security/rate-limit.ts +0 -80
- package/src/server/action.ts +0 -48
- package/src/server/cache-utils.ts +0 -23
- package/src/server/cache.ts +0 -125
- package/src/server/compress.ts +0 -60
- package/src/server/etag.ts +0 -23
- package/src/server/guard.ts +0 -69
- package/src/server/html-shell.ts +0 -69
- package/src/server/index.ts +0 -57
- package/src/server/manifest.ts +0 -36
- package/src/server/middleware.ts +0 -159
- package/src/server/not-found.ts +0 -35
- package/src/server/page-render.ts +0 -123
- package/src/server/pipe.ts +0 -46
- package/src/server/redis-cache-store.ts +0 -87
- package/src/server/redis-client.ts +0 -71
- package/src/server/request-preflight.ts +0 -45
- package/src/server/route-request.ts +0 -72
- package/src/server/rpc-hash.ts +0 -17
- package/src/server/rpc-utils.ts +0 -27
- package/src/server/rpc.ts +0 -177
- package/src/server/sqlite-cache-store.ts +0 -109
- package/src/server/sse.ts +0 -96
- package/src/server/static-file.ts +0 -63
- package/src/server/ws.ts +0 -56
- package/src/server-entry.ts +0 -36
- package/src/testing/index.ts +0 -74
- package/src/types/index.ts +0 -4
- package/src/types/safe-html.ts +0 -32
- package/src/types/safe-sql.ts +0 -28
- package/src/types/safe-url.ts +0 -40
- package/src/types/user-input.ts +0 -12
- package/src/unsafe/index.ts +0 -18
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { verifySignedValue, signValue } from "./signing.js";
|
|
2
|
+
export { createNamespacedSessionStore } from "./store-utils.js";
|
|
3
|
+
export { createRedisSessionStore } from "./redis-session-store.js";
|
|
4
|
+
export { createSQLiteSessionStore } from "./sqlite-session-store.js";
|
|
5
|
+
export {
|
|
6
|
+
createAuthActionTokenManager,
|
|
7
|
+
createMemoryAuthActionTokenStore
|
|
8
|
+
} from "./action-tokens.js";
|
|
9
|
+
function composeMiddlewares(...middlewares) {
|
|
10
|
+
return async (ctx, next) => {
|
|
11
|
+
let index = -1;
|
|
12
|
+
const dispatch = async (position) => {
|
|
13
|
+
if (position <= index)
|
|
14
|
+
throw Error("Middleware chain re-entry is not allowed.");
|
|
15
|
+
index = position;
|
|
16
|
+
const middleware = middlewares[position];
|
|
17
|
+
if (!middleware)
|
|
18
|
+
return next();
|
|
19
|
+
return middleware(ctx, () => dispatch(position + 1));
|
|
20
|
+
};
|
|
21
|
+
return dispatch(0);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export function createMemorySessionStore() {
|
|
25
|
+
const sessions = new Map;
|
|
26
|
+
return {
|
|
27
|
+
get: (id) => sessions.get(id),
|
|
28
|
+
set: (id, session) => {
|
|
29
|
+
sessions.set(id, session);
|
|
30
|
+
},
|
|
31
|
+
delete: (id) => {
|
|
32
|
+
sessions.delete(id);
|
|
33
|
+
},
|
|
34
|
+
entries: () => sessions.entries()
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const defaultSessionStore = createMemorySessionStore();
|
|
38
|
+
async function pruneExpired(store) {
|
|
39
|
+
const now = Date.now(), entries = await store.entries();
|
|
40
|
+
for await (const [id, session] of entries)
|
|
41
|
+
if (session.expiresAt <= now)
|
|
42
|
+
await store.delete(id);
|
|
43
|
+
}
|
|
44
|
+
function resolveConfig(config) {
|
|
45
|
+
return {
|
|
46
|
+
secret: config.secret,
|
|
47
|
+
cookieName: config.cookieName ?? "gorsee_session",
|
|
48
|
+
maxAge: config.maxAge ?? 86400,
|
|
49
|
+
loginPath: config.loginPath ?? "/login",
|
|
50
|
+
store: config.store ?? defaultSessionStore,
|
|
51
|
+
events: config.events,
|
|
52
|
+
permissionResolver: config.permissionResolver
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function getSessionRole(session) {
|
|
56
|
+
const role = session?.data?.role;
|
|
57
|
+
return typeof role === "string" ? role : null;
|
|
58
|
+
}
|
|
59
|
+
function getSessionPermissions(session) {
|
|
60
|
+
const permissions = session?.data?.permissions;
|
|
61
|
+
return Array.isArray(permissions) ? permissions.filter((value) => typeof value === "string") : [];
|
|
62
|
+
}
|
|
63
|
+
export function sessionHasRole(session, role) {
|
|
64
|
+
return getSessionRole(session) === role;
|
|
65
|
+
}
|
|
66
|
+
export async function sessionHasPermission(session, permission, resolver) {
|
|
67
|
+
if (!session)
|
|
68
|
+
return !1;
|
|
69
|
+
if (getSessionPermissions(session).includes(permission))
|
|
70
|
+
return !0;
|
|
71
|
+
if (!resolver)
|
|
72
|
+
return !1;
|
|
73
|
+
return resolver(session, permission);
|
|
74
|
+
}
|
|
75
|
+
export function createAuth(config) {
|
|
76
|
+
const cfg = resolveConfig(config), middleware = async (ctx, next) => {
|
|
77
|
+
const cookie = ctx.cookies.get(cfg.cookieName);
|
|
78
|
+
if (cookie) {
|
|
79
|
+
const sessionId = await verifySignedValue(cookie, cfg.secret);
|
|
80
|
+
if (sessionId) {
|
|
81
|
+
const session = await cfg.store.get(sessionId);
|
|
82
|
+
if (session && session.expiresAt > Date.now())
|
|
83
|
+
ctx.locals.session = session;
|
|
84
|
+
else if (session) {
|
|
85
|
+
await cfg.store.delete(sessionId);
|
|
86
|
+
await cfg.events?.({
|
|
87
|
+
type: "expired-session",
|
|
88
|
+
sessionId: session.id,
|
|
89
|
+
userId: session.userId
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
} else
|
|
93
|
+
await cfg.events?.({ type: "invalid-cookie", cookieName: cfg.cookieName });
|
|
94
|
+
}
|
|
95
|
+
return next();
|
|
96
|
+
}, requireAuth = async (ctx, next) => {
|
|
97
|
+
if (!ctx.locals.session)
|
|
98
|
+
return ctx.redirect(cfg.loginPath);
|
|
99
|
+
return next();
|
|
100
|
+
}, requireRole = (role) => async (ctx, next) => {
|
|
101
|
+
if (!sessionHasRole(getSession(ctx), role))
|
|
102
|
+
return new Response("Forbidden", { status: 403 });
|
|
103
|
+
return next();
|
|
104
|
+
}, requirePermission = (permission) => async (ctx, next) => {
|
|
105
|
+
if (!await sessionHasPermission(getSession(ctx), permission, cfg.permissionResolver))
|
|
106
|
+
return new Response("Forbidden", { status: 403 });
|
|
107
|
+
return next();
|
|
108
|
+
}, protect = (...middlewares) => composeMiddlewares(middleware, requireAuth, ...middlewares), protectRole = (role, ...middlewares) => protect(requireRole(role), ...middlewares), protectPermission = (permission, ...middlewares) => protect(requirePermission(permission), ...middlewares);
|
|
109
|
+
async function login(ctx, userId, data = {}) {
|
|
110
|
+
await pruneExpired(cfg.store);
|
|
111
|
+
const id = crypto.randomUUID(), session = {
|
|
112
|
+
id,
|
|
113
|
+
userId,
|
|
114
|
+
data,
|
|
115
|
+
expiresAt: Date.now() + cfg.maxAge * 1000
|
|
116
|
+
};
|
|
117
|
+
await cfg.store.set(id, session);
|
|
118
|
+
ctx.locals.session = session;
|
|
119
|
+
const signed = await signValue(id, cfg.secret), isProduction = !1;
|
|
120
|
+
ctx.setCookie(cfg.cookieName, signed, {
|
|
121
|
+
maxAge: cfg.maxAge,
|
|
122
|
+
httpOnly: !0,
|
|
123
|
+
secure: isProduction,
|
|
124
|
+
sameSite: "Lax",
|
|
125
|
+
path: "/"
|
|
126
|
+
});
|
|
127
|
+
await cfg.events?.({
|
|
128
|
+
type: "login",
|
|
129
|
+
sessionId: session.id,
|
|
130
|
+
userId: session.userId,
|
|
131
|
+
expiresAt: session.expiresAt
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
async function rotateSession(ctx, data) {
|
|
135
|
+
const current = getSession(ctx);
|
|
136
|
+
if (!current)
|
|
137
|
+
throw Error("Cannot rotate session without an authenticated session.");
|
|
138
|
+
await cfg.store.delete(current.id);
|
|
139
|
+
await pruneExpired(cfg.store);
|
|
140
|
+
const nextSession = {
|
|
141
|
+
id: crypto.randomUUID(),
|
|
142
|
+
userId: current.userId,
|
|
143
|
+
data: data ?? current.data,
|
|
144
|
+
expiresAt: Date.now() + cfg.maxAge * 1000
|
|
145
|
+
};
|
|
146
|
+
await cfg.store.set(nextSession.id, nextSession);
|
|
147
|
+
ctx.locals.session = nextSession;
|
|
148
|
+
const signed = await signValue(nextSession.id, cfg.secret), isProduction = !1;
|
|
149
|
+
ctx.setCookie(cfg.cookieName, signed, {
|
|
150
|
+
maxAge: cfg.maxAge,
|
|
151
|
+
httpOnly: !0,
|
|
152
|
+
secure: isProduction,
|
|
153
|
+
sameSite: "Lax",
|
|
154
|
+
path: "/"
|
|
155
|
+
});
|
|
156
|
+
await cfg.events?.({
|
|
157
|
+
type: "rotate",
|
|
158
|
+
previousSessionId: current.id,
|
|
159
|
+
sessionId: nextSession.id,
|
|
160
|
+
userId: nextSession.userId,
|
|
161
|
+
expiresAt: nextSession.expiresAt
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
async function logout(ctx) {
|
|
165
|
+
const session = ctx.locals.session;
|
|
166
|
+
if (session) {
|
|
167
|
+
await cfg.store.delete(session.id);
|
|
168
|
+
ctx.locals.session = void 0;
|
|
169
|
+
await cfg.events?.({
|
|
170
|
+
type: "logout",
|
|
171
|
+
sessionId: session.id,
|
|
172
|
+
userId: session.userId
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
ctx.deleteCookie(cfg.cookieName);
|
|
176
|
+
}
|
|
177
|
+
function getSession(ctx) {
|
|
178
|
+
return ctx.locals.session ?? null;
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
middleware,
|
|
182
|
+
requireAuth,
|
|
183
|
+
requireRole,
|
|
184
|
+
requirePermission,
|
|
185
|
+
protect,
|
|
186
|
+
protectRole,
|
|
187
|
+
protectPermission,
|
|
188
|
+
login,
|
|
189
|
+
rotateSession,
|
|
190
|
+
logout,
|
|
191
|
+
getSession,
|
|
192
|
+
hasRole(ctx, role) {
|
|
193
|
+
return sessionHasRole(getSession(ctx), role);
|
|
194
|
+
},
|
|
195
|
+
hasPermission(ctx, permission) {
|
|
196
|
+
return sessionHasPermission(getSession(ctx), permission, cfg.permissionResolver);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SessionStore } from "./index.js";
|
|
2
|
+
import { type RedisLikeClient } from "../server/redis-client.js";
|
|
3
|
+
interface RedisSessionStoreOptions {
|
|
4
|
+
prefix?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function createRedisSessionStore(client: RedisLikeClient, options?: RedisSessionStoreOptions): SessionStore;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { buildRedisKey, stripRedisPrefix } from "../server/redis-client.js";
|
|
2
|
+
export function createRedisSessionStore(client, options = {}) {
|
|
3
|
+
const prefix = options.prefix ?? "gorsee:session";
|
|
4
|
+
return {
|
|
5
|
+
async get(id) {
|
|
6
|
+
const raw = await client.get(buildRedisKey(prefix, id));
|
|
7
|
+
if (!raw)
|
|
8
|
+
return;
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(raw).session;
|
|
11
|
+
} catch {
|
|
12
|
+
await client.del(buildRedisKey(prefix, id));
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
async set(id, session) {
|
|
17
|
+
const key = buildRedisKey(prefix, id);
|
|
18
|
+
await client.set(key, JSON.stringify({ session }));
|
|
19
|
+
const ttlSeconds = Math.max(1, Math.ceil((session.expiresAt - Date.now()) / 1000));
|
|
20
|
+
if (client.expire)
|
|
21
|
+
await client.expire(key, ttlSeconds);
|
|
22
|
+
},
|
|
23
|
+
async delete(id) {
|
|
24
|
+
await client.del(buildRedisKey(prefix, id));
|
|
25
|
+
},
|
|
26
|
+
async entries() {
|
|
27
|
+
const keys = await client.keys(`${prefix}:*`), sessions = [];
|
|
28
|
+
for (const key of keys) {
|
|
29
|
+
const raw = await client.get(key);
|
|
30
|
+
if (!raw)
|
|
31
|
+
continue;
|
|
32
|
+
try {
|
|
33
|
+
const payload = JSON.parse(raw);
|
|
34
|
+
sessions.push([stripRedisPrefix(prefix, key), payload.session]);
|
|
35
|
+
} catch {
|
|
36
|
+
await client.del(key);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return sessions;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function signValue(value: string, secret: string): Promise<string>;
|
|
2
|
+
export declare function verifySignedValue(signed: string, secret: string): Promise<string | null>;
|
|
3
|
+
export declare function encodeBase64Url(value: string): string;
|
|
4
|
+
export declare function decodeBase64Url(value: string): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { timingSafeEqual } from "node:crypto";
|
|
2
|
+
let cachedKey = null, cachedSecret = "";
|
|
3
|
+
async function getSigningKey(secret) {
|
|
4
|
+
if (cachedKey && cachedSecret === secret)
|
|
5
|
+
return cachedKey;
|
|
6
|
+
const enc = new TextEncoder;
|
|
7
|
+
cachedKey = await crypto.subtle.importKey("raw", enc.encode(secret), { name: "HMAC", hash: "SHA-256" }, !1, ["sign", "verify"]);
|
|
8
|
+
cachedSecret = secret;
|
|
9
|
+
return cachedKey;
|
|
10
|
+
}
|
|
11
|
+
export async function signValue(value, secret) {
|
|
12
|
+
const key = await getSigningKey(secret), enc = new TextEncoder, signature = await crypto.subtle.sign("HMAC", key, enc.encode(value)), sigHex = Array.from(new Uint8Array(signature)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
13
|
+
return `${value}.${sigHex}`;
|
|
14
|
+
}
|
|
15
|
+
export async function verifySignedValue(signed, secret) {
|
|
16
|
+
const dotIndex = signed.lastIndexOf(".");
|
|
17
|
+
if (dotIndex === -1)
|
|
18
|
+
return null;
|
|
19
|
+
const value = signed.slice(0, dotIndex), expected = await signValue(value, secret);
|
|
20
|
+
if (expected.length !== signed.length)
|
|
21
|
+
return null;
|
|
22
|
+
const a = Buffer.from(expected), b = Buffer.from(signed);
|
|
23
|
+
if (!timingSafeEqual(a, b))
|
|
24
|
+
return null;
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
export function encodeBase64Url(value) {
|
|
28
|
+
return Buffer.from(value, "utf-8").toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
29
|
+
}
|
|
30
|
+
export function decodeBase64Url(value) {
|
|
31
|
+
const normalized = value.replace(/-/g, "+").replace(/_/g, "/"), padding = normalized.length % 4 === 0 ? "" : "=".repeat(4 - normalized.length % 4);
|
|
32
|
+
return Buffer.from(`${normalized}${padding}`, "base64").toString("utf-8");
|
|
33
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SessionStore } from "./index.js";
|
|
2
|
+
interface SQLiteSessionStoreOptions {
|
|
3
|
+
pruneExpiredOnInit?: boolean;
|
|
4
|
+
pruneExpiredOnGet?: boolean;
|
|
5
|
+
pruneExpiredOnSet?: boolean;
|
|
6
|
+
pruneExpiredOnEntries?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function createSQLiteSessionStore(path?: string, options?: SQLiteSessionStoreOptions): SessionStore & {
|
|
9
|
+
close(): void;
|
|
10
|
+
deleteExpired(now?: number): number;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Database } from "bun:sqlite";
|
|
2
|
+
function ensureSessionTable(sqlite) {
|
|
3
|
+
sqlite.run(`
|
|
4
|
+
CREATE TABLE IF NOT EXISTS gorsee_sessions (
|
|
5
|
+
id TEXT PRIMARY KEY,
|
|
6
|
+
payload TEXT NOT NULL,
|
|
7
|
+
expires_at INTEGER NOT NULL
|
|
8
|
+
)
|
|
9
|
+
`);
|
|
10
|
+
sqlite.run("CREATE INDEX IF NOT EXISTS idx_gorsee_sessions_expires_at ON gorsee_sessions (expires_at)");
|
|
11
|
+
}
|
|
12
|
+
function pruneExpiredRows(sqlite, now = Date.now()) {
|
|
13
|
+
return sqlite.prepare("DELETE FROM gorsee_sessions WHERE expires_at <= ?1").run(now).changes ?? 0;
|
|
14
|
+
}
|
|
15
|
+
function parseStoredSession(sqlite, id, payload, expiresAt) {
|
|
16
|
+
try {
|
|
17
|
+
return {
|
|
18
|
+
...JSON.parse(payload),
|
|
19
|
+
expiresAt
|
|
20
|
+
};
|
|
21
|
+
} catch {
|
|
22
|
+
sqlite.prepare("DELETE FROM gorsee_sessions WHERE id = ?1").run(id);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function createSQLiteSessionStore(path = ":memory:", options = {}) {
|
|
27
|
+
const sqlite = new Database(path);
|
|
28
|
+
sqlite.run("PRAGMA journal_mode=WAL;");
|
|
29
|
+
ensureSessionTable(sqlite);
|
|
30
|
+
const {
|
|
31
|
+
pruneExpiredOnInit = !0,
|
|
32
|
+
pruneExpiredOnGet = !0,
|
|
33
|
+
pruneExpiredOnSet = !0,
|
|
34
|
+
pruneExpiredOnEntries = !0
|
|
35
|
+
} = options;
|
|
36
|
+
if (pruneExpiredOnInit)
|
|
37
|
+
pruneExpiredRows(sqlite);
|
|
38
|
+
return {
|
|
39
|
+
async get(id) {
|
|
40
|
+
if (pruneExpiredOnGet)
|
|
41
|
+
pruneExpiredRows(sqlite);
|
|
42
|
+
const row = sqlite.prepare("SELECT payload, expires_at FROM gorsee_sessions WHERE id = ?1").get(id);
|
|
43
|
+
if (!row)
|
|
44
|
+
return;
|
|
45
|
+
return parseStoredSession(sqlite, id, row.payload, row.expires_at);
|
|
46
|
+
},
|
|
47
|
+
async set(id, session) {
|
|
48
|
+
if (pruneExpiredOnSet)
|
|
49
|
+
pruneExpiredRows(sqlite);
|
|
50
|
+
sqlite.prepare(`
|
|
51
|
+
INSERT INTO gorsee_sessions (id, payload, expires_at)
|
|
52
|
+
VALUES (?1, ?2, ?3)
|
|
53
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
54
|
+
payload = excluded.payload,
|
|
55
|
+
expires_at = excluded.expires_at
|
|
56
|
+
`).run(id, JSON.stringify({
|
|
57
|
+
id: session.id,
|
|
58
|
+
userId: session.userId,
|
|
59
|
+
data: session.data
|
|
60
|
+
}), session.expiresAt);
|
|
61
|
+
},
|
|
62
|
+
async delete(id) {
|
|
63
|
+
sqlite.prepare("DELETE FROM gorsee_sessions WHERE id = ?1").run(id);
|
|
64
|
+
},
|
|
65
|
+
async entries() {
|
|
66
|
+
if (pruneExpiredOnEntries)
|
|
67
|
+
pruneExpiredRows(sqlite);
|
|
68
|
+
const rows = sqlite.prepare("SELECT id, payload, expires_at FROM gorsee_sessions").all(), sessions = [];
|
|
69
|
+
for (const row of rows) {
|
|
70
|
+
const session = parseStoredSession(sqlite, row.id, row.payload, row.expires_at);
|
|
71
|
+
if (session)
|
|
72
|
+
sessions.push([row.id, session]);
|
|
73
|
+
}
|
|
74
|
+
return sessions;
|
|
75
|
+
},
|
|
76
|
+
deleteExpired(now = Date.now()) {
|
|
77
|
+
return pruneExpiredRows(sqlite, now);
|
|
78
|
+
},
|
|
79
|
+
close() {
|
|
80
|
+
sqlite.close();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function createNamespacedSessionStore(store, namespace) {
|
|
2
|
+
const prefix = `${namespace}:`;
|
|
3
|
+
return {
|
|
4
|
+
get: (id) => store.get(prefix + id),
|
|
5
|
+
set: async (id, session) => {
|
|
6
|
+
await store.set(prefix + id, { ...session, id });
|
|
7
|
+
},
|
|
8
|
+
delete: async (id) => {
|
|
9
|
+
await store.delete(prefix + id);
|
|
10
|
+
},
|
|
11
|
+
entries: async function* () {
|
|
12
|
+
const entries = await store.entries();
|
|
13
|
+
for await (const [id, session] of entries) {
|
|
14
|
+
if (!id.startsWith(prefix))
|
|
15
|
+
continue;
|
|
16
|
+
yield [id.slice(prefix.length), { ...session, id: id.slice(prefix.length) }];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ClientBuildBackend } from "../client-backend.js";
|
|
2
|
+
export declare const EXPERIMENTAL_ROLLDOWN_BACKEND_NAME = "experimental-rolldown";
|
|
3
|
+
export interface ExperimentalRolldownBackendOptions {
|
|
4
|
+
fallback: ClientBuildBackend;
|
|
5
|
+
}
|
|
6
|
+
export declare function createExperimentalRolldownClientBuildBackend(options: ExperimentalRolldownBackendOptions): ClientBuildBackend;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const EXPERIMENTAL_ROLLDOWN_BACKEND_NAME = "experimental-rolldown";
|
|
2
|
+
export function createExperimentalRolldownClientBuildBackend(options) {
|
|
3
|
+
return {
|
|
4
|
+
name: EXPERIMENTAL_ROLLDOWN_BACKEND_NAME,
|
|
5
|
+
async build(buildOptions) {
|
|
6
|
+
return options.fallback.build(buildOptions);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ClientBuildBackend } from "../client-backend.js";
|
|
2
|
+
export interface RegisterBuiltInBuildBackendsOptions {
|
|
3
|
+
includeExperimentalRolldown?: boolean;
|
|
4
|
+
includeRolldown?: boolean;
|
|
5
|
+
fallbackBackend?: ClientBuildBackend;
|
|
6
|
+
}
|
|
7
|
+
export declare function registerBuiltInBuildBackends(options?: RegisterBuiltInBuildBackendsOptions): string[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createBunClientBuildBackend,
|
|
3
|
+
registerClientBuildBackend
|
|
4
|
+
} from "../client-backend.js";
|
|
5
|
+
import {
|
|
6
|
+
createExperimentalRolldownClientBuildBackend,
|
|
7
|
+
EXPERIMENTAL_ROLLDOWN_BACKEND_NAME
|
|
8
|
+
} from "./experimental-rolldown.js";
|
|
9
|
+
import {
|
|
10
|
+
createRolldownClientBuildBackend,
|
|
11
|
+
ROLLDOWN_BACKEND_NAME
|
|
12
|
+
} from "./rolldown.js";
|
|
13
|
+
export function registerBuiltInBuildBackends(options = {}) {
|
|
14
|
+
const registered = [], fallbackBackend = options.fallbackBackend ?? createBunClientBuildBackend();
|
|
15
|
+
if (options.includeExperimentalRolldown) {
|
|
16
|
+
registerClientBuildBackend(createExperimentalRolldownClientBuildBackend({ fallback: fallbackBackend }));
|
|
17
|
+
registered.push(EXPERIMENTAL_ROLLDOWN_BACKEND_NAME);
|
|
18
|
+
}
|
|
19
|
+
if (options.includeRolldown) {
|
|
20
|
+
registerClientBuildBackend(createRolldownClientBuildBackend({ fallback: fallbackBackend }));
|
|
21
|
+
registered.push(ROLLDOWN_BACKEND_NAME);
|
|
22
|
+
}
|
|
23
|
+
return registered;
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ClientBuildBackend } from "../client-backend.js";
|
|
2
|
+
export declare const ROLLDOWN_BACKEND_NAME = "rolldown";
|
|
3
|
+
export declare const ROLLDOWN_PACKAGE = "rolldown";
|
|
4
|
+
export interface RolldownBackendState {
|
|
5
|
+
backend: typeof ROLLDOWN_BACKEND_NAME;
|
|
6
|
+
packageName: typeof ROLLDOWN_PACKAGE;
|
|
7
|
+
implementation: "rolldown";
|
|
8
|
+
available: true;
|
|
9
|
+
fallbackBackend: string;
|
|
10
|
+
reason: null;
|
|
11
|
+
}
|
|
12
|
+
export interface RolldownBackendOptions {
|
|
13
|
+
fallback: ClientBuildBackend;
|
|
14
|
+
}
|
|
15
|
+
export declare function createRolldownClientBuildBackend(options: RolldownBackendOptions): ClientBuildBackend;
|
|
16
|
+
export declare function getRolldownBackendState(options: RolldownBackendOptions): RolldownBackendState;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { readdir, readFile, rename } from "node:fs/promises";
|
|
2
|
+
import { dirname, extname, resolve, sep } from "node:path";
|
|
3
|
+
import { build } from "rolldown";
|
|
4
|
+
import ts from "typescript";
|
|
5
|
+
import { normalizeClientBuildLog } from "../diagnostics.js";
|
|
6
|
+
import { resolveBuildPluginsForTarget } from "../plugin.js";
|
|
7
|
+
import {
|
|
8
|
+
collectCssModule,
|
|
9
|
+
renderCssModuleExports,
|
|
10
|
+
transformCssModuleSource
|
|
11
|
+
} from "../css-modules.js";
|
|
12
|
+
import {
|
|
13
|
+
applyRouteClientTransforms,
|
|
14
|
+
SERVER_ONLY_MODULES,
|
|
15
|
+
SERVER_STUB_MODULES
|
|
16
|
+
} from "../route-client-transform.js";
|
|
17
|
+
export const ROLLDOWN_BACKEND_NAME = "rolldown", ROLLDOWN_PACKAGE = "rolldown";
|
|
18
|
+
const EMPTY_NAMESPACE = "\x00gorsee-empty:", STUB_NAMESPACE = "\x00gorsee-stub:", CSS_MODULE_NAMESPACE = "\x00gorsee-css-module:", CSS_MODULE_IMPORT_PREFIX = "gorsee:css-module:";
|
|
19
|
+
export function createRolldownClientBuildBackend(options) {
|
|
20
|
+
return {
|
|
21
|
+
name: ROLLDOWN_BACKEND_NAME,
|
|
22
|
+
async build(buildOptions) {
|
|
23
|
+
try {
|
|
24
|
+
const namedInput = Object.fromEntries(buildOptions.entrypoints.map((entrypoint) => [
|
|
25
|
+
resolveRolldownEntryName(entrypoint),
|
|
26
|
+
resolve(entrypoint)
|
|
27
|
+
]));
|
|
28
|
+
await build({
|
|
29
|
+
input: namedInput,
|
|
30
|
+
platform: "browser",
|
|
31
|
+
plugins: createRolldownPlugins(buildOptions),
|
|
32
|
+
output: {
|
|
33
|
+
dir: resolve(buildOptions.outdir),
|
|
34
|
+
format: "esm",
|
|
35
|
+
sourcemap: buildOptions.sourcemap,
|
|
36
|
+
minify: buildOptions.minify ? { compress: !0, mangle: !0 } : !1,
|
|
37
|
+
entryFileNames: "[name].js",
|
|
38
|
+
chunkFileNames: "chunks/[name].js"
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
await normalizeRolldownChunkPaths(buildOptions.outdir);
|
|
42
|
+
return {
|
|
43
|
+
success: !0,
|
|
44
|
+
logs: []
|
|
45
|
+
};
|
|
46
|
+
} catch (error) {
|
|
47
|
+
return {
|
|
48
|
+
success: !1,
|
|
49
|
+
logs: [extractRolldownDiagnostic(error)]
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
async function normalizeRolldownChunkPaths(outdir) {
|
|
56
|
+
const chunkDir = resolve(outdir, "chunks"), entries = await readdir(chunkDir, { withFileTypes: !0 }).catch(() => []);
|
|
57
|
+
for (const entry of entries) {
|
|
58
|
+
if (!entry.isFile())
|
|
59
|
+
continue;
|
|
60
|
+
if (!entry.name.endsWith(".js"))
|
|
61
|
+
continue;
|
|
62
|
+
const normalizedName = entry.name.replace(/\.[a-f0-9]{8}(?=\.js$)/, "");
|
|
63
|
+
if (normalizedName === entry.name)
|
|
64
|
+
continue;
|
|
65
|
+
await rename(resolve(chunkDir, entry.name), resolve(chunkDir, normalizedName));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export function getRolldownBackendState(options) {
|
|
69
|
+
return {
|
|
70
|
+
backend: ROLLDOWN_BACKEND_NAME,
|
|
71
|
+
packageName: ROLLDOWN_PACKAGE,
|
|
72
|
+
implementation: "rolldown",
|
|
73
|
+
available: !0,
|
|
74
|
+
fallbackBackend: options.fallback.name,
|
|
75
|
+
reason: null
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function createRolldownPlugins(options) {
|
|
79
|
+
const cssModuleIds = new Map;
|
|
80
|
+
let cssModuleCounter = 0;
|
|
81
|
+
function registerCssModulePath(filePath) {
|
|
82
|
+
const id = String(cssModuleCounter++);
|
|
83
|
+
cssModuleIds.set(id, filePath);
|
|
84
|
+
return id;
|
|
85
|
+
}
|
|
86
|
+
function resolveCssModulePath(id) {
|
|
87
|
+
const filePath = cssModuleIds.get(id);
|
|
88
|
+
if (!filePath)
|
|
89
|
+
throw Error(`Unknown rolldown CSS module id: ${id}`);
|
|
90
|
+
return filePath;
|
|
91
|
+
}
|
|
92
|
+
function rewriteCssModuleImports(source, importer) {
|
|
93
|
+
return source.replace(/(["'])([^"']+\.module\.css)\1/g, (_match, quote, specifier) => {
|
|
94
|
+
const filePath = resolve(dirname(importer), specifier), id = registerCssModulePath(filePath);
|
|
95
|
+
return `${quote}${CSS_MODULE_IMPORT_PREFIX}${id}${quote}`;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return [
|
|
99
|
+
{
|
|
100
|
+
name: "gorsee-rolldown-resolve",
|
|
101
|
+
resolveId(source, importer) {
|
|
102
|
+
if (source.startsWith("gorsee:route:"))
|
|
103
|
+
return source.slice(13);
|
|
104
|
+
if (source.startsWith(CSS_MODULE_IMPORT_PREFIX))
|
|
105
|
+
return `${CSS_MODULE_NAMESPACE}${source.slice(CSS_MODULE_IMPORT_PREFIX.length)}`;
|
|
106
|
+
if (source === "react/jsx-runtime")
|
|
107
|
+
return options.frameworkResolve("gorsee/jsx-runtime") ?? source;
|
|
108
|
+
if (source === "react/jsx-dev-runtime")
|
|
109
|
+
return options.frameworkResolve("gorsee/jsx-dev-runtime") ?? source;
|
|
110
|
+
const frameworkImport = options.frameworkResolve(source);
|
|
111
|
+
if (frameworkImport)
|
|
112
|
+
return frameworkImport;
|
|
113
|
+
if (SERVER_ONLY_MODULES.includes(source))
|
|
114
|
+
return `${EMPTY_NAMESPACE}${source}`;
|
|
115
|
+
if (source in SERVER_STUB_MODULES)
|
|
116
|
+
return `${STUB_NAMESPACE}${source}`;
|
|
117
|
+
return null;
|
|
118
|
+
},
|
|
119
|
+
async load(id) {
|
|
120
|
+
if (id.startsWith(EMPTY_NAMESPACE))
|
|
121
|
+
return "export default {}";
|
|
122
|
+
if (id.startsWith(STUB_NAMESPACE))
|
|
123
|
+
return SERVER_STUB_MODULES[id.slice(STUB_NAMESPACE.length)] ?? "export default {}";
|
|
124
|
+
if (id.startsWith(CSS_MODULE_NAMESPACE)) {
|
|
125
|
+
const filePath = resolveCssModulePath(id.slice(CSS_MODULE_NAMESPACE.length)), source = await readFile(filePath, "utf8"), { css, classMap } = transformCssModuleSource(filePath, source);
|
|
126
|
+
collectCssModule(css);
|
|
127
|
+
return renderCssModuleExports(classMap);
|
|
128
|
+
}
|
|
129
|
+
if (isLoadableSourceModule(id)) {
|
|
130
|
+
const source = await readFile(id, "utf8"), rewritten = rewriteCssModuleImports(source, id);
|
|
131
|
+
if (/[/\\]routes[/\\].*\.[jt]sx?$/.test(id))
|
|
132
|
+
return transpileSourceModule(applyRouteClientTransforms(rewritten, id).source, id);
|
|
133
|
+
return transpileSourceModule(rewritten, id);
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
...resolveBuildPluginsForTarget(options.plugins, "rolldown")
|
|
139
|
+
];
|
|
140
|
+
}
|
|
141
|
+
function isLoadableSourceModule(id) {
|
|
142
|
+
return /\.(?:[cm]?[jt]sx?)$/.test(id) && !id.includes("/node_modules/");
|
|
143
|
+
}
|
|
144
|
+
function transpileSourceModule(source, filePath) {
|
|
145
|
+
const extension = extname(filePath), jsx = extension === ".tsx" || extension === ".jsx" ? ts.JsxEmit.ReactJSX : ts.JsxEmit.Preserve;
|
|
146
|
+
return ts.transpileModule(source, {
|
|
147
|
+
compilerOptions: {
|
|
148
|
+
module: ts.ModuleKind.ESNext,
|
|
149
|
+
target: ts.ScriptTarget.ES2022,
|
|
150
|
+
jsx,
|
|
151
|
+
jsxImportSource: "gorsee"
|
|
152
|
+
},
|
|
153
|
+
fileName: filePath
|
|
154
|
+
}).outputText;
|
|
155
|
+
}
|
|
156
|
+
function resolveRolldownEntryName(entrypoint) {
|
|
157
|
+
const normalized = resolve(entrypoint), marker = `${sep}.gorsee${sep}entries${sep}`, index = normalized.indexOf(marker);
|
|
158
|
+
if (index >= 0)
|
|
159
|
+
return normalized.slice(index + marker.length).replace(/\.[cm]?[jt]sx?$/, "");
|
|
160
|
+
return normalized.split(sep).at(-1)?.replace(/\.[cm]?[jt]sx?$/, "") ?? "entry";
|
|
161
|
+
}
|
|
162
|
+
function extractRolldownDiagnostic(error) {
|
|
163
|
+
const shape = error, message = typeof shape?.message === "string" ? shape.message : error instanceof Error ? error.message : String(error), file = typeof shape?.id === "string" ? shape.id : typeof shape?.filename === "string" ? shape.filename : typeof shape?.loc?.file === "string" ? shape.loc.file : void 0, detail = typeof shape?.frame === "string" ? shape.frame : shape?.cause instanceof Error ? shape.cause.message : void 0;
|
|
164
|
+
return normalizeClientBuildLog({
|
|
165
|
+
message,
|
|
166
|
+
file,
|
|
167
|
+
plugin: typeof shape?.plugin === "string" ? shape.plugin : void 0,
|
|
168
|
+
detail,
|
|
169
|
+
code: typeof shape?.code === "string" ? shape.code : void 0
|
|
170
|
+
}, {
|
|
171
|
+
backend: ROLLDOWN_BACKEND_NAME,
|
|
172
|
+
phase: "bundle",
|
|
173
|
+
severity: "error",
|
|
174
|
+
code: "ROLLDOWN_BUILD_FAILURE"
|
|
175
|
+
});
|
|
176
|
+
}
|