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
package/src/auth/index.ts
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
// Built-in session-based auth with HMAC-signed cookies
|
|
2
|
-
|
|
3
|
-
import { timingSafeEqual } from "node:crypto"
|
|
4
|
-
import type { Context, MiddlewareFn } from "../server/middleware.ts"
|
|
5
|
-
export { createNamespacedSessionStore } from "./store-utils.ts"
|
|
6
|
-
export { createRedisSessionStore } from "./redis-session-store.ts"
|
|
7
|
-
export { createSQLiteSessionStore } from "./sqlite-session-store.ts"
|
|
8
|
-
|
|
9
|
-
export interface AuthConfig {
|
|
10
|
-
secret: string
|
|
11
|
-
cookieName?: string
|
|
12
|
-
maxAge?: number
|
|
13
|
-
loginPath?: string
|
|
14
|
-
store?: SessionStore
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface Session {
|
|
18
|
-
id: string
|
|
19
|
-
userId: string
|
|
20
|
-
data: Record<string, unknown>
|
|
21
|
-
expiresAt: number
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
type Awaitable<T> = T | Promise<T>
|
|
25
|
-
|
|
26
|
-
export interface SessionStore {
|
|
27
|
-
get(id: string): Awaitable<Session | undefined>
|
|
28
|
-
set(id: string, session: Session): Awaitable<void>
|
|
29
|
-
delete(id: string): Awaitable<void>
|
|
30
|
-
entries(): Awaitable<Iterable<[string, Session]> | AsyncIterable<[string, Session]>>
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function createMemorySessionStore(): SessionStore {
|
|
34
|
-
const sessions = new Map<string, Session>()
|
|
35
|
-
return {
|
|
36
|
-
get: (id) => sessions.get(id),
|
|
37
|
-
set: (id, session) => { sessions.set(id, session) },
|
|
38
|
-
delete: (id) => { sessions.delete(id) },
|
|
39
|
-
entries: () => sessions.entries(),
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const defaultSessionStore = createMemorySessionStore()
|
|
44
|
-
|
|
45
|
-
let cachedKey: CryptoKey | null = null
|
|
46
|
-
let cachedSecret = ""
|
|
47
|
-
|
|
48
|
-
async function getSigningKey(secret: string): Promise<CryptoKey> {
|
|
49
|
-
if (cachedKey && cachedSecret === secret) return cachedKey
|
|
50
|
-
const enc = new TextEncoder()
|
|
51
|
-
cachedKey = await crypto.subtle.importKey(
|
|
52
|
-
"raw",
|
|
53
|
-
enc.encode(secret),
|
|
54
|
-
{ name: "HMAC", hash: "SHA-256" },
|
|
55
|
-
false,
|
|
56
|
-
["sign", "verify"],
|
|
57
|
-
)
|
|
58
|
-
cachedSecret = secret
|
|
59
|
-
return cachedKey
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async function sign(value: string, secret: string): Promise<string> {
|
|
63
|
-
const key = await getSigningKey(secret)
|
|
64
|
-
const enc = new TextEncoder()
|
|
65
|
-
const signature = await crypto.subtle.sign("HMAC", key, enc.encode(value))
|
|
66
|
-
const sigHex = Array.from(new Uint8Array(signature))
|
|
67
|
-
.map((b) => b.toString(16).padStart(2, "0"))
|
|
68
|
-
.join("")
|
|
69
|
-
return `${value}.${sigHex}`
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async function verify(
|
|
73
|
-
signed: string,
|
|
74
|
-
secret: string,
|
|
75
|
-
): Promise<string | null> {
|
|
76
|
-
const dotIndex = signed.lastIndexOf(".")
|
|
77
|
-
if (dotIndex === -1) return null
|
|
78
|
-
const value = signed.slice(0, dotIndex)
|
|
79
|
-
const expected = await sign(value, secret)
|
|
80
|
-
// Constant-time comparison to prevent timing attacks
|
|
81
|
-
if (expected.length !== signed.length) return null
|
|
82
|
-
const a = Buffer.from(expected)
|
|
83
|
-
const b = Buffer.from(signed)
|
|
84
|
-
if (!timingSafeEqual(a, b)) return null
|
|
85
|
-
return value
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async function pruneExpired(store: SessionStore): Promise<void> {
|
|
89
|
-
const now = Date.now()
|
|
90
|
-
const entries = await store.entries()
|
|
91
|
-
for await (const [id, session] of entries) {
|
|
92
|
-
if (session.expiresAt <= now) await store.delete(id)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function resolveConfig(config: AuthConfig) {
|
|
97
|
-
return {
|
|
98
|
-
secret: config.secret,
|
|
99
|
-
cookieName: config.cookieName ?? "gorsee_session",
|
|
100
|
-
maxAge: config.maxAge ?? 86400,
|
|
101
|
-
loginPath: config.loginPath ?? "/login",
|
|
102
|
-
store: config.store ?? defaultSessionStore,
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function createAuth(config: AuthConfig): {
|
|
107
|
-
middleware: MiddlewareFn
|
|
108
|
-
requireAuth: MiddlewareFn
|
|
109
|
-
login: (ctx: Context, userId: string, data?: Record<string, unknown>) => Promise<void>
|
|
110
|
-
logout: (ctx: Context) => Promise<void>
|
|
111
|
-
getSession: (ctx: Context) => Session | null
|
|
112
|
-
} {
|
|
113
|
-
const cfg = resolveConfig(config)
|
|
114
|
-
|
|
115
|
-
const middleware: MiddlewareFn = async (ctx, next) => {
|
|
116
|
-
const cookie = ctx.cookies.get(cfg.cookieName)
|
|
117
|
-
if (cookie) {
|
|
118
|
-
const sessionId = await verify(cookie, cfg.secret)
|
|
119
|
-
if (sessionId) {
|
|
120
|
-
const session = await cfg.store.get(sessionId)
|
|
121
|
-
if (session && session.expiresAt > Date.now()) {
|
|
122
|
-
ctx.locals.session = session
|
|
123
|
-
} else if (session) {
|
|
124
|
-
await cfg.store.delete(sessionId)
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return next()
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const requireAuth: MiddlewareFn = async (ctx, next) => {
|
|
132
|
-
if (!ctx.locals.session) {
|
|
133
|
-
return ctx.redirect(cfg.loginPath)
|
|
134
|
-
}
|
|
135
|
-
return next()
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
async function login(
|
|
139
|
-
ctx: Context,
|
|
140
|
-
userId: string,
|
|
141
|
-
data: Record<string, unknown> = {},
|
|
142
|
-
): Promise<void> {
|
|
143
|
-
await pruneExpired(cfg.store)
|
|
144
|
-
const id = crypto.randomUUID()
|
|
145
|
-
const session: Session = {
|
|
146
|
-
id,
|
|
147
|
-
userId,
|
|
148
|
-
data,
|
|
149
|
-
expiresAt: Date.now() + cfg.maxAge * 1000,
|
|
150
|
-
}
|
|
151
|
-
await cfg.store.set(id, session)
|
|
152
|
-
ctx.locals.session = session
|
|
153
|
-
const signed = await sign(id, cfg.secret)
|
|
154
|
-
const isProduction = process.env.NODE_ENV === "production"
|
|
155
|
-
ctx.setCookie(cfg.cookieName, signed, {
|
|
156
|
-
maxAge: cfg.maxAge,
|
|
157
|
-
httpOnly: true,
|
|
158
|
-
secure: isProduction,
|
|
159
|
-
sameSite: "Lax",
|
|
160
|
-
path: "/",
|
|
161
|
-
})
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
async function logout(ctx: Context): Promise<void> {
|
|
165
|
-
const session = ctx.locals.session as Session | undefined
|
|
166
|
-
if (session) {
|
|
167
|
-
await cfg.store.delete(session.id)
|
|
168
|
-
ctx.locals.session = undefined
|
|
169
|
-
}
|
|
170
|
-
ctx.deleteCookie(cfg.cookieName)
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function getSession(ctx: Context): Session | null {
|
|
174
|
-
return (ctx.locals.session as Session) ?? null
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return { middleware, requireAuth, login, logout, getSession }
|
|
178
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { Session, SessionStore } from "./index.ts"
|
|
2
|
-
import { buildRedisKey, stripRedisPrefix, type RedisLikeClient } from "../server/redis-client.ts"
|
|
3
|
-
|
|
4
|
-
interface RedisSessionStoreOptions {
|
|
5
|
-
prefix?: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface StoredSessionPayload {
|
|
9
|
-
session: Session
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function createRedisSessionStore(
|
|
13
|
-
client: RedisLikeClient,
|
|
14
|
-
options: RedisSessionStoreOptions = {},
|
|
15
|
-
): SessionStore {
|
|
16
|
-
const prefix = options.prefix ?? "gorsee:session"
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
async get(id) {
|
|
20
|
-
const raw = await client.get(buildRedisKey(prefix, id))
|
|
21
|
-
if (!raw) return undefined
|
|
22
|
-
const payload = JSON.parse(raw) as StoredSessionPayload
|
|
23
|
-
return payload.session
|
|
24
|
-
},
|
|
25
|
-
async set(id, session) {
|
|
26
|
-
const key = buildRedisKey(prefix, id)
|
|
27
|
-
await client.set(key, JSON.stringify({ session } satisfies StoredSessionPayload))
|
|
28
|
-
const ttlSeconds = Math.max(1, Math.ceil((session.expiresAt - Date.now()) / 1000))
|
|
29
|
-
if (client.expire) await client.expire(key, ttlSeconds)
|
|
30
|
-
},
|
|
31
|
-
async delete(id) {
|
|
32
|
-
await client.del(buildRedisKey(prefix, id))
|
|
33
|
-
},
|
|
34
|
-
async entries() {
|
|
35
|
-
const keys = await client.keys(`${prefix}:*`)
|
|
36
|
-
const sessions: Array<[string, Session]> = []
|
|
37
|
-
for (const key of keys) {
|
|
38
|
-
const raw = await client.get(key)
|
|
39
|
-
if (!raw) continue
|
|
40
|
-
const payload = JSON.parse(raw) as StoredSessionPayload
|
|
41
|
-
sessions.push([stripRedisPrefix(prefix, key), payload.session])
|
|
42
|
-
}
|
|
43
|
-
return sessions
|
|
44
|
-
},
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { Database } from "bun:sqlite"
|
|
2
|
-
import type { Session, SessionStore } from "./index.ts"
|
|
3
|
-
|
|
4
|
-
interface SQLiteSessionStoreOptions {
|
|
5
|
-
pruneExpiredOnInit?: boolean
|
|
6
|
-
pruneExpiredOnGet?: boolean
|
|
7
|
-
pruneExpiredOnSet?: boolean
|
|
8
|
-
pruneExpiredOnEntries?: boolean
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function ensureSessionTable(sqlite: Database): void {
|
|
12
|
-
sqlite.run(`
|
|
13
|
-
CREATE TABLE IF NOT EXISTS gorsee_sessions (
|
|
14
|
-
id TEXT PRIMARY KEY,
|
|
15
|
-
payload TEXT NOT NULL,
|
|
16
|
-
expires_at INTEGER NOT NULL
|
|
17
|
-
)
|
|
18
|
-
`)
|
|
19
|
-
sqlite.run("CREATE INDEX IF NOT EXISTS idx_gorsee_sessions_expires_at ON gorsee_sessions (expires_at)")
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function pruneExpiredRows(sqlite: Database, now: number = Date.now()): number {
|
|
23
|
-
const result = sqlite.prepare("DELETE FROM gorsee_sessions WHERE expires_at <= ?1").run(now)
|
|
24
|
-
return (result as { changes?: number }).changes ?? 0
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function createSQLiteSessionStore(
|
|
28
|
-
path = ":memory:",
|
|
29
|
-
options: SQLiteSessionStoreOptions = {},
|
|
30
|
-
): SessionStore & { close(): void; deleteExpired(now?: number): number } {
|
|
31
|
-
const sqlite = new Database(path)
|
|
32
|
-
sqlite.run("PRAGMA journal_mode=WAL;")
|
|
33
|
-
ensureSessionTable(sqlite)
|
|
34
|
-
const {
|
|
35
|
-
pruneExpiredOnInit = true,
|
|
36
|
-
pruneExpiredOnGet = true,
|
|
37
|
-
pruneExpiredOnSet = true,
|
|
38
|
-
pruneExpiredOnEntries = true,
|
|
39
|
-
} = options
|
|
40
|
-
|
|
41
|
-
if (pruneExpiredOnInit) pruneExpiredRows(sqlite)
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
async get(id) {
|
|
45
|
-
if (pruneExpiredOnGet) pruneExpiredRows(sqlite)
|
|
46
|
-
const row = sqlite
|
|
47
|
-
.prepare("SELECT payload, expires_at FROM gorsee_sessions WHERE id = ?1")
|
|
48
|
-
.get(id) as { payload: string; expires_at: number } | null
|
|
49
|
-
if (!row) return undefined
|
|
50
|
-
return {
|
|
51
|
-
...(JSON.parse(row.payload) as Omit<Session, "expiresAt">),
|
|
52
|
-
expiresAt: row.expires_at,
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
async set(id, session) {
|
|
56
|
-
if (pruneExpiredOnSet) pruneExpiredRows(sqlite)
|
|
57
|
-
sqlite.prepare(`
|
|
58
|
-
INSERT INTO gorsee_sessions (id, payload, expires_at)
|
|
59
|
-
VALUES (?1, ?2, ?3)
|
|
60
|
-
ON CONFLICT(id) DO UPDATE SET
|
|
61
|
-
payload = excluded.payload,
|
|
62
|
-
expires_at = excluded.expires_at
|
|
63
|
-
`).run(
|
|
64
|
-
id,
|
|
65
|
-
JSON.stringify({
|
|
66
|
-
id: session.id,
|
|
67
|
-
userId: session.userId,
|
|
68
|
-
data: session.data,
|
|
69
|
-
}),
|
|
70
|
-
session.expiresAt,
|
|
71
|
-
)
|
|
72
|
-
},
|
|
73
|
-
async delete(id) {
|
|
74
|
-
sqlite.prepare("DELETE FROM gorsee_sessions WHERE id = ?1").run(id)
|
|
75
|
-
},
|
|
76
|
-
async entries() {
|
|
77
|
-
if (pruneExpiredOnEntries) pruneExpiredRows(sqlite)
|
|
78
|
-
const rows = sqlite.prepare("SELECT id, payload, expires_at FROM gorsee_sessions").all() as Array<{
|
|
79
|
-
id: string
|
|
80
|
-
payload: string
|
|
81
|
-
expires_at: number
|
|
82
|
-
}>
|
|
83
|
-
return rows.map((row) => [
|
|
84
|
-
row.id,
|
|
85
|
-
{
|
|
86
|
-
...(JSON.parse(row.payload) as Omit<Session, "expiresAt">),
|
|
87
|
-
expiresAt: row.expires_at,
|
|
88
|
-
},
|
|
89
|
-
] as [string, Session])
|
|
90
|
-
},
|
|
91
|
-
deleteExpired(now = Date.now()) {
|
|
92
|
-
return pruneExpiredRows(sqlite, now)
|
|
93
|
-
},
|
|
94
|
-
close() {
|
|
95
|
-
sqlite.close()
|
|
96
|
-
},
|
|
97
|
-
}
|
|
98
|
-
}
|
package/src/auth/store-utils.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Session, SessionStore } from "./index.ts"
|
|
2
|
-
|
|
3
|
-
export function createNamespacedSessionStore(store: SessionStore, namespace: string): SessionStore {
|
|
4
|
-
const prefix = `${namespace}:`
|
|
5
|
-
return {
|
|
6
|
-
get: (id) => store.get(prefix + id),
|
|
7
|
-
set: async (id, session) => {
|
|
8
|
-
await store.set(prefix + id, { ...session, id })
|
|
9
|
-
},
|
|
10
|
-
delete: async (id) => {
|
|
11
|
-
await store.delete(prefix + id)
|
|
12
|
-
},
|
|
13
|
-
entries: async function* () {
|
|
14
|
-
const entries = await store.entries()
|
|
15
|
-
for await (const [id, session] of entries) {
|
|
16
|
-
if (!id.startsWith(prefix)) continue
|
|
17
|
-
yield [id.slice(prefix.length), { ...(session as Session), id: id.slice(prefix.length) }] as [string, Session]
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
}
|
|
21
|
-
}
|
package/src/build/client.ts
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
// Client bundle builder -- uses Bun.build() to create browser-ready JS per route
|
|
2
|
-
|
|
3
|
-
import { join, resolve, relative, dirname } from "node:path"
|
|
4
|
-
import { mkdir, rm } from "node:fs/promises"
|
|
5
|
-
import { serverStripPlugin } from "./server-strip.ts"
|
|
6
|
-
import { cssModulesPlugin, getCollectedCSS, resetCollectedCSS } from "./css-modules.ts"
|
|
7
|
-
import type { Route } from "../router/scanner.ts"
|
|
8
|
-
|
|
9
|
-
const FRAMEWORK_ROOT = resolve(import.meta.dir, "..")
|
|
10
|
-
const CLIENT_JSX_RUNTIME = resolve(FRAMEWORK_ROOT, "jsx-runtime-client.ts")
|
|
11
|
-
|
|
12
|
-
const GORSEE_CLIENT_RESOLVE: Record<string, string> = {
|
|
13
|
-
"gorsee": resolve(FRAMEWORK_ROOT, "index-client.ts"),
|
|
14
|
-
"gorsee/client": resolve(FRAMEWORK_ROOT, "client.ts"),
|
|
15
|
-
"gorsee/reactive": resolve(FRAMEWORK_ROOT, "reactive/index.ts"),
|
|
16
|
-
"gorsee/types": resolve(FRAMEWORK_ROOT, "types/index.ts"),
|
|
17
|
-
"gorsee/runtime": resolve(FRAMEWORK_ROOT, "runtime/index.ts"),
|
|
18
|
-
"gorsee/unsafe": resolve(FRAMEWORK_ROOT, "unsafe/index.ts"),
|
|
19
|
-
"gorsee/jsx-runtime": CLIENT_JSX_RUNTIME,
|
|
20
|
-
"gorsee/jsx-dev-runtime": CLIENT_JSX_RUNTIME,
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function routeToEntryName(route: Route, cwd: string): string {
|
|
24
|
-
const rel = relative(join(cwd, "routes"), route.filePath)
|
|
25
|
-
return rel.replace(/\.(tsx?|jsx?)$/, "").replace(/[\[\]]/g, "_")
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function toImportSpecifier(fromFile: string, toFile: string): string {
|
|
29
|
-
const rel = relative(dirname(fromFile), toFile).replace(/\\/g, "/")
|
|
30
|
-
return rel.startsWith(".") ? rel : `./${rel}`
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function generateEntryCode(routeFile: string, entryPath: string, hydrateImport: string, routerImport: string): string {
|
|
34
|
-
const hydrateSpecifier = toImportSpecifier(entryPath, hydrateImport)
|
|
35
|
-
const routerSpecifier = toImportSpecifier(entryPath, routerImport)
|
|
36
|
-
|
|
37
|
-
return `
|
|
38
|
-
import Component from "gorsee:route:${routeFile}";
|
|
39
|
-
import { hydrate } from "${hydrateSpecifier}";
|
|
40
|
-
import { initRouter } from "${routerSpecifier}";
|
|
41
|
-
var container = document.getElementById("app");
|
|
42
|
-
var dataEl = document.getElementById("__GORSEE_DATA__");
|
|
43
|
-
var data = dataEl ? JSON.parse(dataEl.textContent) : {};
|
|
44
|
-
var params = window.__GORSEE_PARAMS__ || {};
|
|
45
|
-
hydrate(function() { return Component({ data: data, params: params }); }, container);
|
|
46
|
-
initRouter();
|
|
47
|
-
`
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface BuildResult {
|
|
51
|
-
entryMap: Map<string, string> // routePath → client JS path (relative to outdir)
|
|
52
|
-
cssModules?: string // collected CSS from .module.css files
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface BuildOptions {
|
|
56
|
-
minify?: boolean
|
|
57
|
-
sourcemap?: boolean
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export async function buildClientBundles(
|
|
61
|
-
routes: Route[],
|
|
62
|
-
cwd: string,
|
|
63
|
-
options?: BuildOptions,
|
|
64
|
-
): Promise<BuildResult> {
|
|
65
|
-
const outDir = join(cwd, ".gorsee", "client")
|
|
66
|
-
await rm(outDir, { recursive: true, force: true })
|
|
67
|
-
await mkdir(outDir, { recursive: true })
|
|
68
|
-
|
|
69
|
-
const entryDir = join(cwd, ".gorsee", "entries")
|
|
70
|
-
await rm(entryDir, { recursive: true, force: true })
|
|
71
|
-
await mkdir(entryDir, { recursive: true })
|
|
72
|
-
|
|
73
|
-
const entryMap = new Map<string, string>()
|
|
74
|
-
const pageRoutes = routes.filter((r) => !r.filePath.includes("/api/"))
|
|
75
|
-
if (pageRoutes.length === 0) return { entryMap }
|
|
76
|
-
|
|
77
|
-
resetCollectedCSS()
|
|
78
|
-
|
|
79
|
-
const entrypoints: string[] = []
|
|
80
|
-
|
|
81
|
-
for (const route of pageRoutes) {
|
|
82
|
-
const name = routeToEntryName(route, cwd)
|
|
83
|
-
const entryPath = join(entryDir, `${name}.ts`)
|
|
84
|
-
const clientModule = resolve(FRAMEWORK_ROOT, "runtime/client.ts")
|
|
85
|
-
const routerModule = resolve(FRAMEWORK_ROOT, "runtime/router.ts")
|
|
86
|
-
const code = generateEntryCode(route.filePath, entryPath, clientModule, routerModule)
|
|
87
|
-
await Bun.write(entryPath, code)
|
|
88
|
-
entrypoints.push(entryPath)
|
|
89
|
-
entryMap.set(route.path, `${name}.js`)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const result = await Bun.build({
|
|
93
|
-
entrypoints,
|
|
94
|
-
outdir: outDir,
|
|
95
|
-
target: "browser",
|
|
96
|
-
format: "esm",
|
|
97
|
-
minify: options?.minify ?? false,
|
|
98
|
-
sourcemap: options?.sourcemap ? "external" : "none",
|
|
99
|
-
splitting: true,
|
|
100
|
-
jsx: {
|
|
101
|
-
runtime: "automatic",
|
|
102
|
-
importSource: "gorsee",
|
|
103
|
-
development: true,
|
|
104
|
-
},
|
|
105
|
-
plugins: [
|
|
106
|
-
{
|
|
107
|
-
name: "gorsee-client-resolve",
|
|
108
|
-
setup(build) {
|
|
109
|
-
build.onResolve({ filter: /^gorsee:route:/ }, (args) => ({
|
|
110
|
-
path: args.path.slice("gorsee:route:".length),
|
|
111
|
-
}))
|
|
112
|
-
|
|
113
|
-
build.onResolve({ filter: /^gorsee(\/.*)?$/ }, (args) => {
|
|
114
|
-
const mapped = GORSEE_CLIENT_RESOLVE[args.path]
|
|
115
|
-
if (mapped) return { path: mapped }
|
|
116
|
-
return undefined
|
|
117
|
-
})
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
serverStripPlugin,
|
|
121
|
-
cssModulesPlugin,
|
|
122
|
-
],
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
if (!result.success) {
|
|
126
|
-
for (const log of result.logs) {
|
|
127
|
-
console.error("[build]", log.message)
|
|
128
|
-
}
|
|
129
|
-
throw new Error("Client build failed")
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Write collected CSS modules output
|
|
133
|
-
const cssModules = getCollectedCSS()
|
|
134
|
-
if (cssModules) {
|
|
135
|
-
await Bun.write(join(outDir, "modules.css"), cssModules)
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return { entryMap, cssModules }
|
|
139
|
-
}
|
package/src/build/css-modules.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// CSS Modules plugin for Bun.build
|
|
2
|
-
// Transforms .module.css imports to scoped class names
|
|
3
|
-
// Input: import styles from "./button.module.css"
|
|
4
|
-
// Output: styles = { container: "button_container_a1b2c" }
|
|
5
|
-
|
|
6
|
-
import type { BunPlugin } from "bun"
|
|
7
|
-
import { createHash } from "node:crypto"
|
|
8
|
-
import { readFile } from "node:fs/promises"
|
|
9
|
-
import { basename, join, dirname } from "node:path"
|
|
10
|
-
|
|
11
|
-
function hashClassName(filePath: string, className: string): string {
|
|
12
|
-
const hash = createHash("md5")
|
|
13
|
-
.update(filePath + className)
|
|
14
|
-
.digest("hex")
|
|
15
|
-
.slice(0, 5)
|
|
16
|
-
const base = basename(filePath, ".module.css")
|
|
17
|
-
return `${base}_${className}_${hash}`
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function transformCSS(filePath: string, source: string): { css: string; classMap: Record<string, string> } {
|
|
21
|
-
const classMap: Record<string, string> = {}
|
|
22
|
-
|
|
23
|
-
const css = source.replace(/\.([a-zA-Z_][\w-]*)/g, (match, className) => {
|
|
24
|
-
// Don't transform pseudo-classes and pseudo-elements
|
|
25
|
-
if (match.startsWith("::") || match.startsWith(":.")) return match
|
|
26
|
-
const scoped = hashClassName(filePath, className)
|
|
27
|
-
classMap[className] = scoped
|
|
28
|
-
return `.${scoped}`
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
return { css, classMap }
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Collected CSS from all modules (used during build)
|
|
35
|
-
const collectedCSS: string[] = []
|
|
36
|
-
|
|
37
|
-
export function getCollectedCSS(): string {
|
|
38
|
-
return collectedCSS.join("\n")
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function resetCollectedCSS(): void {
|
|
42
|
-
collectedCSS.length = 0
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export const cssModulesPlugin: BunPlugin = {
|
|
46
|
-
name: "gorsee-css-modules",
|
|
47
|
-
setup(build) {
|
|
48
|
-
build.onResolve({ filter: /\.module\.css$/ }, (args) => ({
|
|
49
|
-
path: join(dirname(args.importer), args.path),
|
|
50
|
-
namespace: "css-module",
|
|
51
|
-
}))
|
|
52
|
-
|
|
53
|
-
build.onLoad({ filter: /.*/, namespace: "css-module" }, async (args) => {
|
|
54
|
-
const source = await readFile(args.path, "utf-8")
|
|
55
|
-
const { css, classMap } = transformCSS(args.path, source)
|
|
56
|
-
|
|
57
|
-
collectedCSS.push(css)
|
|
58
|
-
|
|
59
|
-
const exports = Object.entries(classMap)
|
|
60
|
-
.map(([k, v]) => ` "${k}": "${v}"`)
|
|
61
|
-
.join(",\n")
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
contents: `export default {\n${exports}\n};`,
|
|
65
|
-
loader: "js",
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
},
|
|
69
|
-
}
|
package/src/build/manifest.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { Route } from "../router/scanner.ts"
|
|
2
|
-
import { inspectRouteBuildMetadata } from "./route-metadata.ts"
|
|
3
|
-
import type { BuildManifest } from "../server/manifest.ts"
|
|
4
|
-
|
|
5
|
-
export async function createBuildManifest(
|
|
6
|
-
routes: Route[],
|
|
7
|
-
entryMap: Map<string, string>,
|
|
8
|
-
hashMap: Map<string, string>,
|
|
9
|
-
prerenderedPaths: Iterable<string> = [],
|
|
10
|
-
): Promise<BuildManifest> {
|
|
11
|
-
const prerendered = new Set(prerenderedPaths)
|
|
12
|
-
const manifest: BuildManifest = {
|
|
13
|
-
routes: {},
|
|
14
|
-
chunks: [],
|
|
15
|
-
prerendered: [...prerendered],
|
|
16
|
-
buildTime: new Date().toISOString(),
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
for (const route of routes) {
|
|
20
|
-
const metadata = await inspectRouteBuildMetadata(route)
|
|
21
|
-
const jsRel = entryMap.get(route.path)
|
|
22
|
-
manifest.routes[route.path] = {
|
|
23
|
-
js: jsRel ? hashMap.get(jsRel) : undefined,
|
|
24
|
-
hasLoader: metadata.hasLoader,
|
|
25
|
-
prerendered: prerendered.has(route.path) || undefined,
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
for (const hashed of hashMap.values()) {
|
|
30
|
-
if (hashed.includes("chunk-")) manifest.chunks.push(hashed)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return manifest
|
|
34
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Route } from "../router/scanner.ts"
|
|
2
|
-
|
|
3
|
-
export interface RouteBuildMetadata {
|
|
4
|
-
hasLoader: boolean
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export async function inspectRouteBuildMetadata(route: Route): Promise<RouteBuildMetadata> {
|
|
8
|
-
const source = await Bun.file(route.filePath).text()
|
|
9
|
-
return {
|
|
10
|
-
hasLoader: /export\s+(async\s+)?function\s+loader\b/.test(source),
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
// RPC transform plugin for client bundles
|
|
2
|
-
// Replaces server() calls with fetch-based RPC stubs
|
|
3
|
-
// server(async (args) => { ... }) → async (args) => fetch("/_rpc/hash", ...)
|
|
4
|
-
|
|
5
|
-
import { hashRPC } from "../server/rpc-hash.ts"
|
|
6
|
-
|
|
7
|
-
const DEVALUE_PARSE_MODULE = new URL("./devalue-parse.ts", import.meta.url).pathname
|
|
8
|
-
|
|
9
|
-
// Strip TypeScript type annotations from function args: "count: number, name: string" → "count, name"
|
|
10
|
-
function stripTypeAnnotations(args: string): string {
|
|
11
|
-
return args.split(",").map((arg) => {
|
|
12
|
-
const trimmed = arg.trim()
|
|
13
|
-
// Handle destructuring, rest params, defaults — just strip ": Type" suffix
|
|
14
|
-
return trimmed.replace(/\s*:\s*[^,=]+$/, "").replace(/\s*:\s*[^,=]+(?=\s*=)/, "")
|
|
15
|
-
}).join(", ")
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function transformServerCalls(source: string, filePath: string): string {
|
|
19
|
-
// Match server( followed by async/function — not inside strings
|
|
20
|
-
const matches = [...source.matchAll(/\bserver\s*\(\s*(?=async\s|function\s)/g)]
|
|
21
|
-
if (matches.length === 0) return source
|
|
22
|
-
|
|
23
|
-
// Process in reverse order to preserve indices
|
|
24
|
-
let result = source
|
|
25
|
-
for (let i = matches.length - 1; i >= 0; i--) {
|
|
26
|
-
const match = matches[i]!
|
|
27
|
-
const start = match.index!
|
|
28
|
-
const id = hashRPC(filePath, i)
|
|
29
|
-
|
|
30
|
-
// Find the matching closing paren for server(...)
|
|
31
|
-
let depth = 0
|
|
32
|
-
let end = start
|
|
33
|
-
for (let j = start; j < source.length; j++) {
|
|
34
|
-
if (source[j] === "(") depth++
|
|
35
|
-
else if (source[j] === ")") {
|
|
36
|
-
depth--
|
|
37
|
-
if (depth === 0) { end = j + 1; break }
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const inner = source.slice(start + match[0].length, end - 1)
|
|
42
|
-
const argsMatch = inner.match(/^(async\s+)?(?:\(([^)]*)\)|(\w+))\s*=>/)
|
|
43
|
-
const rawArgs = argsMatch ? (argsMatch[2] ?? argsMatch[3] ?? "") : ""
|
|
44
|
-
const args = rawArgs ? stripTypeAnnotations(rawArgs) : "...args"
|
|
45
|
-
|
|
46
|
-
const stub = `(async (${args}) => {
|
|
47
|
-
const res = await fetch("/api/_rpc/${id}", {
|
|
48
|
-
method: "POST",
|
|
49
|
-
headers: { "Content-Type": "application/json" },
|
|
50
|
-
body: JSON.stringify([${args}])
|
|
51
|
-
});
|
|
52
|
-
if (!res.ok) throw new Error("RPC failed: " + res.status);
|
|
53
|
-
return __gorseeDevalParse(await res.text());
|
|
54
|
-
})`
|
|
55
|
-
|
|
56
|
-
result = result.slice(0, start) + stub + result.slice(end)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Add devalue parse import at top
|
|
60
|
-
return `import { parse as __gorseeDevalParse } from "${DEVALUE_PARSE_MODULE}";\n` + result
|
|
61
|
-
}
|
|
62
|
-
|