@wrikka/solid-framework 0.0.0-stage → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -3
- package/dist/vite.d.ts +661 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +10 -0
- package/dist/vite.js.map +1 -0
- package/package.json +247 -5
- package/src/actions/index.ts +5 -0
- package/src/actions/modules/action/adapters/http/handler.ts +80 -0
- package/src/actions/modules/action/application/index.ts +1 -0
- package/src/actions/modules/action/application/usecases/create-action.ts +92 -0
- package/src/actions/modules/action/application/usecases/index.ts +2 -0
- package/src/actions/modules/action/application/usecases/registry.ts +20 -0
- package/src/actions/modules/action/index.ts +2 -0
- package/src/actions/presentation/index.ts +1 -0
- package/src/actions/presentation/useSubmission.ts +46 -0
- package/src/actions/types/index.ts +35 -0
- package/src/app/index.ts +126 -0
- package/src/app/modules/ai/domain/operations/handler.ts +46 -0
- package/src/app/modules/ai/domain/operations/llms.ts +54 -0
- package/src/app/modules/ai/domain/operations/mcp.ts +134 -0
- package/src/app/modules/ai/index.ts +3 -0
- package/src/app/modules/api-docs/domain/operations/openapi.ts +113 -0
- package/src/app/modules/api-docs/index.ts +1 -0
- package/src/app/modules/app-def/index.ts +225 -0
- package/src/app/modules/auth/application/usecases/auth.ts +161 -0
- package/src/app/modules/auth/application/usecases/oauth.ts +105 -0
- package/src/app/modules/auth/index.ts +2 -0
- package/src/app/modules/cache/adapters/edge-kv.ts +55 -0
- package/src/app/modules/cache/adapters/fs.ts +58 -0
- package/src/app/modules/cache/adapters/memory.ts +13 -0
- package/src/app/modules/cache/domain/operations/tags.ts +114 -0
- package/src/app/modules/cache/index.ts +7 -0
- package/src/app/modules/cache/ports/store.ts +14 -0
- package/src/app/modules/config/domain/index.ts +1 -0
- package/src/app/modules/config/domain/models/config.ts +72 -0
- package/src/app/modules/config/domain/models/index.ts +1 -0
- package/src/app/modules/config/index.ts +1 -0
- package/src/app/modules/content/domain/operations/collection.ts +109 -0
- package/src/app/modules/content/index.ts +8 -0
- package/src/app/modules/content/presentation/Markdown.tsx +78 -0
- package/src/app/modules/conventions/domain/index.ts +1 -0
- package/src/app/modules/conventions/domain/operations/index.ts +1 -0
- package/src/app/modules/conventions/domain/operations/scan.ts +73 -0
- package/src/app/modules/conventions/index.ts +1 -0
- package/src/app/modules/db/application/usecases/db.ts +49 -0
- package/src/app/modules/db/index.ts +1 -0
- package/src/app/modules/deploy/adapters/aws-lambda.ts +54 -0
- package/src/app/modules/deploy/adapters/bun.ts +15 -0
- package/src/app/modules/deploy/adapters/cloudflare.ts +15 -0
- package/src/app/modules/deploy/adapters/deno.ts +15 -0
- package/src/app/modules/deploy/adapters/netlify.ts +18 -0
- package/src/app/modules/deploy/adapters/node.ts +63 -0
- package/src/app/modules/deploy/adapters/vercel.ts +22 -0
- package/src/app/modules/deploy/domain/models/preset.ts +38 -0
- package/src/app/modules/deploy/domain/operations/presets.ts +92 -0
- package/src/app/modules/deploy/index.ts +9 -0
- package/src/app/modules/draft/domain/operations/draft-mode.ts +125 -0
- package/src/app/modules/draft/index.ts +1 -0
- package/src/app/modules/env/domain/operations/create-env.ts +156 -0
- package/src/app/modules/env/index.ts +1 -0
- package/src/app/modules/file-routes/application/usecases/api-client.ts +120 -0
- package/src/app/modules/file-routes/domain/errors.ts +61 -0
- package/src/app/modules/file-routes/domain/index.ts +63 -0
- package/src/app/modules/file-routes/domain/models/index.ts +1 -0
- package/src/app/modules/file-routes/domain/models/route.ts +38 -0
- package/src/app/modules/file-routes/domain/operations/actions.ts +107 -0
- package/src/app/modules/file-routes/domain/operations/api.ts +87 -0
- package/src/app/modules/file-routes/domain/operations/codegen.ts +76 -0
- package/src/app/modules/file-routes/domain/operations/content.ts +61 -0
- package/src/app/modules/file-routes/domain/operations/defer.ts +245 -0
- package/src/app/modules/file-routes/domain/operations/index.ts +65 -0
- package/src/app/modules/file-routes/domain/operations/loader.ts +138 -0
- package/src/app/modules/file-routes/domain/operations/manifest.ts +229 -0
- package/src/app/modules/file-routes/domain/operations/match.ts +75 -0
- package/src/app/modules/file-routes/domain/operations/static-params.ts +58 -0
- package/src/app/modules/file-routes/domain/operations/typed.ts +127 -0
- package/src/app/modules/file-routes/index.ts +143 -0
- package/src/app/modules/file-routes/presentation/DevtoolsOverlay.tsx +234 -0
- package/src/app/modules/file-routes/presentation/FileRoutes.ts +254 -0
- package/src/app/modules/file-routes/presentation/Form.tsx +122 -0
- package/src/app/modules/file-routes/presentation/Link.tsx +132 -0
- package/src/app/modules/file-routes/presentation/ServerComponent.tsx +100 -0
- package/src/app/modules/file-routes/presentation/content-page.tsx +26 -0
- package/src/app/modules/file-routes/presentation/dev-events.ts +112 -0
- package/src/app/modules/file-routes/presentation/index.ts +98 -0
- package/src/app/modules/file-routes/presentation/loader-cache.ts +96 -0
- package/src/app/modules/file-routes/presentation/loader-data.ts +207 -0
- package/src/app/modules/file-routes/presentation/location.ts +217 -0
- package/src/app/modules/file-routes/presentation/normalize-route.ts +155 -0
- package/src/app/modules/file-routes/presentation/page-tree.ts +211 -0
- package/src/app/modules/file-routes/presentation/route-contexts.ts +89 -0
- package/src/app/modules/file-routes/presentation/route-def.ts +154 -0
- package/src/app/modules/file-routes/presentation/route-fallbacks.ts +66 -0
- package/src/app/modules/file-routes/presentation/route-modules.ts +138 -0
- package/src/app/modules/file-routes/presentation/slot.tsx +43 -0
- package/src/app/modules/file-routes/presentation/status.ts +13 -0
- package/src/app/modules/file-routes/presentation/use-action.ts +81 -0
- package/src/app/modules/file-routes/presentation/use-optimistic.ts +50 -0
- package/src/app/modules/file-routes/presentation/use-preload.ts +38 -0
- package/src/app/modules/file-routes/presentation/use-route.ts +254 -0
- package/src/app/modules/flash/domain/operations/flash.ts +70 -0
- package/src/app/modules/flash/index.ts +1 -0
- package/src/app/modules/fonts/domain/operations/font.ts +91 -0
- package/src/app/modules/fonts/index.ts +1 -0
- package/src/app/modules/i18n/domain/operations/i18n-middleware.ts +76 -0
- package/src/app/modules/i18n/domain/operations/locale.ts +39 -0
- package/src/app/modules/i18n/index.ts +3 -0
- package/src/app/modules/i18n/presentation/use-locale.ts +16 -0
- package/src/app/modules/middleware/domain/operations/request-id.ts +33 -0
- package/src/app/modules/middleware/domain/operations/run.ts +29 -0
- package/src/app/modules/middleware/index.ts +7 -0
- package/src/app/modules/route-rules/domain/index.ts +1 -0
- package/src/app/modules/route-rules/domain/operations/ab-variant.ts +58 -0
- package/src/app/modules/route-rules/domain/operations/index.ts +4 -0
- package/src/app/modules/route-rules/domain/operations/match.ts +51 -0
- package/src/app/modules/route-rules/domain/operations/rate-limit.ts +63 -0
- package/src/app/modules/route-rules/domain/operations/security.ts +67 -0
- package/src/app/modules/route-rules/index.ts +1 -0
- package/src/app/modules/runtime-config/application/index.ts +1 -0
- package/src/app/modules/runtime-config/application/usecases/index.ts +1 -0
- package/src/app/modules/runtime-config/application/usecases/runtime-config.ts +42 -0
- package/src/app/modules/runtime-config/index.ts +1 -0
- package/src/app/modules/seo/domain/operations/og.ts +66 -0
- package/src/app/modules/seo/domain/operations/site.ts +106 -0
- package/src/app/modules/seo/index.ts +2 -0
- package/src/app/modules/server-entry/application/index.ts +1 -0
- package/src/app/modules/server-entry/application/usecases/create-app-server.ts +205 -0
- package/src/app/modules/server-entry/application/usecases/devtools-handler.ts +31 -0
- package/src/app/modules/server-entry/application/usecases/image-handler.ts +38 -0
- package/src/app/modules/server-entry/application/usecases/index.ts +3 -0
- package/src/app/modules/server-entry/application/usecases/ops-handler.ts +55 -0
- package/src/app/modules/server-entry/application/usecases/prerender-cache.ts +59 -0
- package/src/app/modules/server-entry/application/usecases/route-render.ts +276 -0
- package/src/app/modules/server-entry/application/usecases/routed-entry.ts +194 -0
- package/src/app/modules/server-entry/application/usecases/static-handler.ts +20 -0
- package/src/app/modules/server-entry/application/usecases/zone-handler.ts +37 -0
- package/src/app/modules/server-entry/index.ts +1 -0
- package/src/app/modules/session/index.ts +77 -0
- package/src/app/modules/static/domain/operations/serve.ts +88 -0
- package/src/app/modules/static/index.ts +1 -0
- package/src/app/presentation/App.tsx +34 -0
- package/src/app/presentation/define-config.ts +11 -0
- package/src/app/presentation/index.ts +3 -0
- package/src/app/presentation/providers.ts +80 -0
- package/src/app/types/index.ts +273 -0
- package/src/assets/adapters/sharp.ts +83 -0
- package/src/assets/index.ts +6 -0
- package/src/assets/modules/assets/domain/index.ts +1 -0
- package/src/assets/modules/assets/domain/operations/image.ts +67 -0
- package/src/assets/modules/assets/domain/operations/index.ts +2 -0
- package/src/assets/modules/assets/domain/operations/manifest.ts +29 -0
- package/src/assets/modules/assets/index.ts +1 -0
- package/src/assets/presentation/Image.tsx +90 -0
- package/src/assets/presentation/index.ts +1 -0
- package/src/assets/types/index.ts +21 -0
- package/src/cli/bin.ts +8 -0
- package/src/cli/commands.ts +145 -0
- package/src/cli/doctor.ts +111 -0
- package/src/cli/index.ts +3 -0
- package/src/cli/infra.ts +38 -0
- package/src/cli/migrate.ts +119 -0
- package/src/cli/nav.ts +164 -0
- package/src/cli/ops.ts +135 -0
- package/src/cli/routes.ts +240 -0
- package/src/cli/scaffold.ts +217 -0
- package/src/devtools/App.tsx +14 -0
- package/src/devtools/adapters/connector.ts +23 -0
- package/src/devtools/adapters/index.ts +4 -0
- package/src/devtools/index.ts +26 -0
- package/src/devtools/modules/component-inspector/application/index.ts +4 -0
- package/src/devtools/modules/component-inspector/application/usecases/component-inspector.ts +67 -0
- package/src/devtools/modules/component-inspector/application/usecases/index.ts +5 -0
- package/src/devtools/modules/component-inspector/application/usecases/useComponentInspector.ts +52 -0
- package/src/devtools/modules/component-inspector/domain/events/component-events.ts +37 -0
- package/src/devtools/modules/component-inspector/domain/events/index.ts +4 -0
- package/src/devtools/modules/component-inspector/domain/index.ts +7 -0
- package/src/devtools/modules/component-inspector/domain/models/component-node.ts +30 -0
- package/src/devtools/modules/component-inspector/domain/models/component-tree.ts +20 -0
- package/src/devtools/modules/component-inspector/domain/models/index.ts +5 -0
- package/src/devtools/modules/component-inspector/domain/operations/component-operations.ts +63 -0
- package/src/devtools/modules/component-inspector/domain/operations/index.ts +4 -0
- package/src/devtools/modules/component-inspector/index.ts +7 -0
- package/src/devtools/modules/devtools/application/index.ts +4 -0
- package/src/devtools/modules/devtools/application/usecases/devtools.ts +60 -0
- package/src/devtools/modules/devtools/application/usecases/index.ts +5 -0
- package/src/devtools/modules/devtools/application/usecases/useDevtools.ts +47 -0
- package/src/devtools/modules/devtools/domain/events/devtools-events.ts +56 -0
- package/src/devtools/modules/devtools/domain/events/index.ts +4 -0
- package/src/devtools/modules/devtools/domain/index.ts +8 -0
- package/src/devtools/modules/devtools/domain/models/devtools-state.ts +15 -0
- package/src/devtools/modules/devtools/domain/models/index.ts +4 -0
- package/src/devtools/modules/devtools/domain/operations/devtools-operations.ts +27 -0
- package/src/devtools/modules/devtools/domain/operations/index.ts +4 -0
- package/src/devtools/modules/devtools/domain/validators/devtools-validators.ts +36 -0
- package/src/devtools/modules/devtools/domain/validators/index.ts +4 -0
- package/src/devtools/modules/devtools/index.ts +7 -0
- package/src/devtools/modules/devtools/ports/connector.ts +10 -0
- package/src/devtools/modules/devtools/ports/index.ts +4 -0
- package/src/devtools/modules/timeline/application/index.ts +4 -0
- package/src/devtools/modules/timeline/application/usecases/index.ts +5 -0
- package/src/devtools/modules/timeline/application/usecases/timeline.ts +61 -0
- package/src/devtools/modules/timeline/application/usecases/useTimeline.ts +37 -0
- package/src/devtools/modules/timeline/domain/events/index.ts +4 -0
- package/src/devtools/modules/timeline/domain/events/timeline-events.ts +34 -0
- package/src/devtools/modules/timeline/domain/index.ts +7 -0
- package/src/devtools/modules/timeline/domain/models/index.ts +4 -0
- package/src/devtools/modules/timeline/domain/models/timeline-event.ts +27 -0
- package/src/devtools/modules/timeline/domain/operations/index.ts +4 -0
- package/src/devtools/modules/timeline/domain/operations/timeline-operations.ts +28 -0
- package/src/devtools/modules/timeline/index.ts +7 -0
- package/src/devtools/presentation/DevtoolsPanel.tsx +80 -0
- package/src/devtools/presentation/components/ComponentTreeView.tsx +79 -0
- package/src/devtools/presentation/components/StateInspector.tsx +70 -0
- package/src/devtools/presentation/components/TimelineView.tsx +52 -0
- package/src/devtools/presentation/components/index.ts +7 -0
- package/src/devtools/presentation/composables/index.ts +7 -0
- package/src/devtools/presentation/composables/useComponentInspector.ts +52 -0
- package/src/devtools/presentation/index.ts +5 -0
- package/src/devtools/shared/errors/index.ts +23 -0
- package/src/devtools/shared/index.ts +7 -0
- package/src/devtools/shared/types/index.ts +6 -0
- package/src/devtools/shared/types/option.ts +58 -0
- package/src/devtools/shared/types/result.ts +53 -0
- package/src/devtools/shared/utils/index.ts +32 -0
- package/src/devtools/style.css +2 -0
- package/src/head/index.ts +5 -0
- package/src/head/modules/head/application/index.ts +1 -0
- package/src/head/modules/head/application/usecases/head-manager.ts +68 -0
- package/src/head/modules/head/application/usecases/index.ts +1 -0
- package/src/head/modules/head/domain/index.ts +3 -0
- package/src/head/modules/head/domain/models/head-tag.ts +73 -0
- package/src/head/modules/head/domain/models/index.ts +1 -0
- package/src/head/modules/head/domain/operations/dedupe.ts +18 -0
- package/src/head/modules/head/domain/operations/index.ts +2 -0
- package/src/head/modules/head/domain/operations/render-tags.ts +43 -0
- package/src/head/modules/head/domain/validators/index.ts +12 -0
- package/src/head/modules/head/index.ts +3 -0
- package/src/head/modules/head/ports/index.ts +11 -0
- package/src/head/presentation/HeadProvider.tsx +42 -0
- package/src/head/presentation/Tags.tsx +90 -0
- package/src/head/presentation/head-context.ts +11 -0
- package/src/head/presentation/index.ts +3 -0
- package/src/head/presentation/useHead.ts +77 -0
- package/src/head/shared/index.ts +1 -0
- package/src/head/shared/types/index.ts +5 -0
- package/src/head/types/index.ts +47 -0
- package/src/hooks/adapters/config/constants.ts +12 -0
- package/src/hooks/adapters/config/index.ts +48 -0
- package/src/hooks/adapters/index.ts +13 -0
- package/src/hooks/adapters/monaco/index.ts +96 -0
- package/src/hooks/adapters/qr/index.ts +65 -0
- package/src/hooks/index.ts +21 -0
- package/src/hooks/modules/array/application/index.ts +2 -0
- package/src/hooks/modules/array/application/usecases/index.ts +123 -0
- package/src/hooks/modules/array/domain/events/index.ts +5 -0
- package/src/hooks/modules/array/domain/index.ts +3 -0
- package/src/hooks/modules/array/domain/models/index.ts +2 -0
- package/src/hooks/modules/array/domain/operations/create.ts +10 -0
- package/src/hooks/modules/array/domain/operations/index.ts +31 -0
- package/src/hooks/modules/array/domain/operations/modify.ts +61 -0
- package/src/hooks/modules/array/domain/operations/query.ts +36 -0
- package/src/hooks/modules/array/domain/validators/index.ts +5 -0
- package/src/hooks/modules/array/index.ts +5 -0
- package/src/hooks/modules/array/types/index.ts +9 -0
- package/src/hooks/modules/counter/application/index.ts +12 -0
- package/src/hooks/modules/counter/application/usecases/index.ts +156 -0
- package/src/hooks/modules/counter/domain/events/index.ts +6 -0
- package/src/hooks/modules/counter/domain/index.ts +21 -0
- package/src/hooks/modules/counter/domain/models/index.ts +2 -0
- package/src/hooks/modules/counter/domain/operations/calculate.ts +22 -0
- package/src/hooks/modules/counter/domain/operations/create.ts +22 -0
- package/src/hooks/modules/counter/domain/operations/index.ts +25 -0
- package/src/hooks/modules/counter/domain/operations/modify.ts +78 -0
- package/src/hooks/modules/counter/domain/operations/query.ts +38 -0
- package/src/hooks/modules/counter/domain/operations/validate.ts +58 -0
- package/src/hooks/modules/counter/domain/validators/counter-validators.ts +19 -0
- package/src/hooks/modules/counter/domain/validators/index.ts +2 -0
- package/src/hooks/modules/counter/index.ts +6 -0
- package/src/hooks/modules/counter/ports/index.ts +7 -0
- package/src/hooks/modules/counter/types/index.ts +13 -0
- package/src/hooks/modules/editor/application/index.ts +6 -0
- package/src/hooks/modules/editor/application/useCodeEditor.ts +81 -0
- package/src/hooks/modules/editor/domain/events/editor-events.ts +16 -0
- package/src/hooks/modules/editor/domain/events/index.ts +6 -0
- package/src/hooks/modules/editor/domain/index.ts +7 -0
- package/src/hooks/modules/editor/domain/models/editor.ts +16 -0
- package/src/hooks/modules/editor/domain/models/index.ts +6 -0
- package/src/hooks/modules/editor/domain/validators/index.ts +34 -0
- package/src/hooks/modules/editor/index.ts +8 -0
- package/src/hooks/modules/editor/types/index.ts +34 -0
- package/src/hooks/modules/sensor/application/index.ts +2 -0
- package/src/hooks/modules/sensor/application/usecases/index.ts +25 -0
- package/src/hooks/modules/sensor/domain/events/index.ts +12 -0
- package/src/hooks/modules/sensor/domain/index.ts +10 -0
- package/src/hooks/modules/sensor/domain/models/index.ts +7 -0
- package/src/hooks/modules/sensor/domain/operations/gamepad.ts +16 -0
- package/src/hooks/modules/sensor/domain/operations/index.ts +12 -0
- package/src/hooks/modules/sensor/domain/operations/motion.ts +10 -0
- package/src/hooks/modules/sensor/domain/operations/orientation.ts +10 -0
- package/src/hooks/modules/sensor/domain/validators/index.ts +2 -0
- package/src/hooks/modules/sensor/index.ts +10 -0
- package/src/hooks/modules/sensor/ports/index.ts +8 -0
- package/src/hooks/modules/sensor/types/index.ts +29 -0
- package/src/hooks/modules/storage/application/index.ts +2 -0
- package/src/hooks/modules/storage/application/usecases/index.ts +18 -0
- package/src/hooks/modules/storage/domain/events/index.ts +5 -0
- package/src/hooks/modules/storage/domain/index.ts +6 -0
- package/src/hooks/modules/storage/domain/models/index.ts +6 -0
- package/src/hooks/modules/storage/domain/models/storage.ts +11 -0
- package/src/hooks/modules/storage/domain/operations/index.ts +8 -0
- package/src/hooks/modules/storage/domain/operations/serialize.ts +22 -0
- package/src/hooks/modules/storage/domain/operations/validate.ts +7 -0
- package/src/hooks/modules/storage/domain/validators/index.ts +2 -0
- package/src/hooks/modules/storage/index.ts +6 -0
- package/src/hooks/modules/storage/ports/index.ts +7 -0
- package/src/hooks/modules/storage/types/index.ts +6 -0
- package/src/hooks/modules/time/application/index.ts +2 -0
- package/src/hooks/modules/time/application/usecases/index.ts +5 -0
- package/src/hooks/modules/time/application/usecases/use-debounce.ts +10 -0
- package/src/hooks/modules/time/application/usecases/use-interval.ts +10 -0
- package/src/hooks/modules/time/application/usecases/use-throttle.ts +10 -0
- package/src/hooks/modules/time/application/usecases/use-timeout.ts +10 -0
- package/src/hooks/modules/time/domain/events/index.ts +6 -0
- package/src/hooks/modules/time/domain/index.ts +12 -0
- package/src/hooks/modules/time/domain/models/index.ts +6 -0
- package/src/hooks/modules/time/domain/models/time.ts +16 -0
- package/src/hooks/modules/time/domain/operations/calculate.ts +8 -0
- package/src/hooks/modules/time/domain/operations/index.ts +11 -0
- package/src/hooks/modules/time/domain/operations/validate.ts +11 -0
- package/src/hooks/modules/time/domain/validators/index.ts +2 -0
- package/src/hooks/modules/time/index.ts +5 -0
- package/src/hooks/modules/time/ports/index.ts +9 -0
- package/src/hooks/modules/time/types/index.ts +18 -0
- package/src/hooks/modules/toggle/application/index.ts +2 -0
- package/src/hooks/modules/toggle/application/usecases/index.ts +48 -0
- package/src/hooks/modules/toggle/domain/events/index.ts +4 -0
- package/src/hooks/modules/toggle/domain/index.ts +11 -0
- package/src/hooks/modules/toggle/domain/models/index.ts +7 -0
- package/src/hooks/modules/toggle/domain/operations/create.ts +11 -0
- package/src/hooks/modules/toggle/domain/operations/index.ts +12 -0
- package/src/hooks/modules/toggle/domain/operations/modify.ts +18 -0
- package/src/hooks/modules/toggle/domain/operations/query.ts +9 -0
- package/src/hooks/modules/toggle/domain/validators/index.ts +2 -0
- package/src/hooks/modules/toggle/index.ts +6 -0
- package/src/hooks/modules/toggle/ports/index.ts +5 -0
- package/src/hooks/modules/toggle/types/index.ts +9 -0
- package/src/hooks/presentation/index.ts +2 -0
- package/src/hooks/presentation/solid/animation/index.ts +11 -0
- package/src/hooks/presentation/solid/animation/useElapsedTime.ts +75 -0
- package/src/hooks/presentation/solid/animation/useInterval.ts +68 -0
- package/src/hooks/presentation/solid/animation/useIntervalFn.ts +54 -0
- package/src/hooks/presentation/solid/animation/useNow.ts +57 -0
- package/src/hooks/presentation/solid/animation/useRafFn.ts +57 -0
- package/src/hooks/presentation/solid/animation/useTimeout.ts +55 -0
- package/src/hooks/presentation/solid/animation/useTimeoutFn.ts +55 -0
- package/src/hooks/presentation/solid/animation/useTimestamp.ts +61 -0
- package/src/hooks/presentation/solid/animation/useTransition.ts +87 -0
- package/src/hooks/presentation/solid/array/index.ts +14 -0
- package/src/hooks/presentation/solid/array/useArrayConcat.ts +18 -0
- package/src/hooks/presentation/solid/array/useArrayEvery.ts +8 -0
- package/src/hooks/presentation/solid/array/useArrayFilter.ts +8 -0
- package/src/hooks/presentation/solid/array/useArrayFind.ts +8 -0
- package/src/hooks/presentation/solid/array/useArrayIncludes.ts +8 -0
- package/src/hooks/presentation/solid/array/useArrayMap.ts +8 -0
- package/src/hooks/presentation/solid/array/useArrayPop.ts +18 -0
- package/src/hooks/presentation/solid/array/useArrayPush.ts +15 -0
- package/src/hooks/presentation/solid/array/useArrayReduce.ts +9 -0
- package/src/hooks/presentation/solid/array/useArrayShift.ts +18 -0
- package/src/hooks/presentation/solid/array/useArraySome.ts +8 -0
- package/src/hooks/presentation/solid/array/useArraySort.ts +12 -0
- package/src/hooks/presentation/solid/browser/index.ts +35 -0
- package/src/hooks/presentation/solid/browser/useBarcode.ts +15 -0
- package/src/hooks/presentation/solid/browser/useBattery.ts +37 -0
- package/src/hooks/presentation/solid/browser/useBeacon.ts +4 -0
- package/src/hooks/presentation/solid/browser/useBluetooth.ts +15 -0
- package/src/hooks/presentation/solid/browser/useClipboard.ts +17 -0
- package/src/hooks/presentation/solid/browser/useClipboardAdvanced.ts +54 -0
- package/src/hooks/presentation/solid/browser/useConnection.ts +22 -0
- package/src/hooks/presentation/solid/browser/useCredential.ts +18 -0
- package/src/hooks/presentation/solid/browser/useDisplayMedia.ts +24 -0
- package/src/hooks/presentation/solid/browser/useFaceDetection.ts +20 -0
- package/src/hooks/presentation/solid/browser/useFullscreen.ts +33 -0
- package/src/hooks/presentation/solid/browser/useGeolocation.ts +64 -0
- package/src/hooks/presentation/solid/browser/useLocalStorage.ts +11 -0
- package/src/hooks/presentation/solid/browser/useMediaDevices.ts +24 -0
- package/src/hooks/presentation/solid/browser/useMemory.ts +9 -0
- package/src/hooks/presentation/solid/browser/useNetwork.ts +43 -0
- package/src/hooks/presentation/solid/browser/useNotification.ts +21 -0
- package/src/hooks/presentation/solid/browser/usePayment.ts +17 -0
- package/src/hooks/presentation/solid/browser/usePerformance.ts +13 -0
- package/src/hooks/presentation/solid/browser/usePush.ts +12 -0
- package/src/hooks/presentation/solid/browser/useQrCode.ts +11 -0
- package/src/hooks/presentation/solid/browser/useScreenOrientation.ts +37 -0
- package/src/hooks/presentation/solid/browser/useServiceWorker.ts +29 -0
- package/src/hooks/presentation/solid/browser/useSessionStorage.ts +11 -0
- package/src/hooks/presentation/solid/browser/useShare.ts +12 -0
- package/src/hooks/presentation/solid/browser/useSpeechRecognition.ts +71 -0
- package/src/hooks/presentation/solid/browser/useSpeechSynthesis.ts +54 -0
- package/src/hooks/presentation/solid/browser/useStorage.ts +22 -0
- package/src/hooks/presentation/solid/browser/useTextDetection.ts +20 -0
- package/src/hooks/presentation/solid/browser/useUsb.ts +15 -0
- package/src/hooks/presentation/solid/browser/useUserMedia.ts +24 -0
- package/src/hooks/presentation/solid/browser/useVibration.ts +12 -0
- package/src/hooks/presentation/solid/browser/useWakeLock.ts +29 -0
- package/src/hooks/presentation/solid/browser/useWebAuthn.ts +35 -0
- package/src/hooks/presentation/solid/elements/index.ts +51 -0
- package/src/hooks/presentation/solid/elements/useActive.ts +33 -0
- package/src/hooks/presentation/solid/elements/useAudio.ts +82 -0
- package/src/hooks/presentation/solid/elements/useBreakpoints.ts +56 -0
- package/src/hooks/presentation/solid/elements/useCanvas.ts +43 -0
- package/src/hooks/presentation/solid/elements/useClick.ts +49 -0
- package/src/hooks/presentation/solid/elements/useDrag.ts +56 -0
- package/src/hooks/presentation/solid/elements/useDraggable.ts +57 -0
- package/src/hooks/presentation/solid/elements/useDraggableHandle.ts +92 -0
- package/src/hooks/presentation/solid/elements/useDrop.ts +54 -0
- package/src/hooks/presentation/solid/elements/useDropZone.ts +67 -0
- package/src/hooks/presentation/solid/elements/useElementBounding.ts +52 -0
- package/src/hooks/presentation/solid/elements/useElementSize.ts +30 -0
- package/src/hooks/presentation/solid/elements/useElementVisibility.ts +33 -0
- package/src/hooks/presentation/solid/elements/useFileDialog.ts +33 -0
- package/src/hooks/presentation/solid/elements/useFileInput.ts +20 -0
- package/src/hooks/presentation/solid/elements/useFocus.ts +49 -0
- package/src/hooks/presentation/solid/elements/useHover.ts +33 -0
- package/src/hooks/presentation/solid/elements/useImagePreview.ts +27 -0
- package/src/hooks/presentation/solid/elements/useImageUpload.ts +66 -0
- package/src/hooks/presentation/solid/elements/useInfiniteScroll.ts +52 -0
- package/src/hooks/presentation/solid/elements/useIntersectionAdvanced.ts +43 -0
- package/src/hooks/presentation/solid/elements/useIntersectionObserver.ts +40 -0
- package/src/hooks/presentation/solid/elements/useLayout.ts +47 -0
- package/src/hooks/presentation/solid/elements/useLongPress.ts +54 -0
- package/src/hooks/presentation/solid/elements/useMagicKeys.ts +60 -0
- package/src/hooks/presentation/solid/elements/useMediaQuery.ts +24 -0
- package/src/hooks/presentation/solid/elements/useModal.ts +24 -0
- package/src/hooks/presentation/solid/elements/useMouse.ts +51 -0
- package/src/hooks/presentation/solid/elements/useMutationObserver.ts +38 -0
- package/src/hooks/presentation/solid/elements/useOnClickOutside.ts +25 -0
- package/src/hooks/presentation/solid/elements/useOnKeyStroke.ts +33 -0
- package/src/hooks/presentation/solid/elements/useParallax.ts +34 -0
- package/src/hooks/presentation/solid/elements/usePerformanceObserver.ts +30 -0
- package/src/hooks/presentation/solid/elements/usePinch.ts +61 -0
- package/src/hooks/presentation/solid/elements/usePopover.ts +54 -0
- package/src/hooks/presentation/solid/elements/useResize.ts +34 -0
- package/src/hooks/presentation/solid/elements/useResizeObserver.ts +42 -0
- package/src/hooks/presentation/solid/elements/useRotate.ts +42 -0
- package/src/hooks/presentation/solid/elements/useScroll.ts +97 -0
- package/src/hooks/presentation/solid/elements/useScrollTo.ts +30 -0
- package/src/hooks/presentation/solid/elements/useSortable.ts +22 -0
- package/src/hooks/presentation/solid/elements/useSplitter.ts +61 -0
- package/src/hooks/presentation/solid/elements/useSticky.ts +33 -0
- package/src/hooks/presentation/solid/elements/useSvg.ts +31 -0
- package/src/hooks/presentation/solid/elements/useSwipe.ts +87 -0
- package/src/hooks/presentation/solid/elements/useTabs.ts +44 -0
- package/src/hooks/presentation/solid/elements/useTooltip.ts +57 -0
- package/src/hooks/presentation/solid/elements/useVideo.ts +83 -0
- package/src/hooks/presentation/solid/elements/useVirtualList.ts +43 -0
- package/src/hooks/presentation/solid/elements/useWebgl.ts +36 -0
- package/src/hooks/presentation/solid/index.ts +11 -0
- package/src/hooks/presentation/solid/math/index.ts +10 -0
- package/src/hooks/presentation/solid/math/useAbs.ts +9 -0
- package/src/hooks/presentation/solid/math/useCeil.ts +9 -0
- package/src/hooks/presentation/solid/math/useClamp.ts +24 -0
- package/src/hooks/presentation/solid/math/useExp.ts +9 -0
- package/src/hooks/presentation/solid/math/useFloor.ts +9 -0
- package/src/hooks/presentation/solid/math/useLog.ts +21 -0
- package/src/hooks/presentation/solid/math/useMath.ts +3 -0
- package/src/hooks/presentation/solid/math/useOffset.ts +20 -0
- package/src/hooks/presentation/solid/math/usePow.ts +16 -0
- package/src/hooks/presentation/solid/math/useRound.ts +24 -0
- package/src/hooks/presentation/solid/math/useSign.ts +9 -0
- package/src/hooks/presentation/solid/math/useSqrt.ts +9 -0
- package/src/hooks/presentation/solid/network/index.ts +5 -0
- package/src/hooks/presentation/solid/network/useEventSource.ts +87 -0
- package/src/hooks/presentation/solid/network/useFetch.ts +187 -0
- package/src/hooks/presentation/solid/network/useWebSocket.ts +120 -0
- package/src/hooks/presentation/solid/sensors/index.ts +21 -0
- package/src/hooks/presentation/solid/sensors/useAbsoluteOrientation.ts +41 -0
- package/src/hooks/presentation/solid/sensors/useAccelerometer.ts +39 -0
- package/src/hooks/presentation/solid/sensors/useAmbientLight.ts +35 -0
- package/src/hooks/presentation/solid/sensors/useDeviceMotion.ts +50 -0
- package/src/hooks/presentation/solid/sensors/useDeviceOrientation.ts +38 -0
- package/src/hooks/presentation/solid/sensors/useGamepad.ts +52 -0
- package/src/hooks/presentation/solid/sensors/useGamepadRumble.ts +28 -0
- package/src/hooks/presentation/solid/sensors/useGravity.ts +39 -0
- package/src/hooks/presentation/solid/sensors/useGyroscope.ts +39 -0
- package/src/hooks/presentation/solid/sensors/useHID.ts +19 -0
- package/src/hooks/presentation/solid/sensors/useLinearAcceleration.ts +41 -0
- package/src/hooks/presentation/solid/sensors/useMagnetometer.ts +39 -0
- package/src/hooks/presentation/solid/sensors/useMotion.ts +31 -0
- package/src/hooks/presentation/solid/sensors/useNFC.ts +19 -0
- package/src/hooks/presentation/solid/sensors/usePressure.ts +35 -0
- package/src/hooks/presentation/solid/sensors/useProximity.ts +38 -0
- package/src/hooks/presentation/solid/sensors/useRelativeOrientation.ts +41 -0
- package/src/hooks/presentation/solid/sensors/useSerial.ts +18 -0
- package/src/hooks/presentation/solid/sensors/useShake.ts +54 -0
- package/src/hooks/presentation/solid/sensors/useTilt.ts +31 -0
- package/src/hooks/presentation/solid/state/createSharedComposable.ts +24 -0
- package/src/hooks/presentation/solid/state/index.ts +14 -0
- package/src/hooks/presentation/solid/state/reactivity.ts +43 -0
- package/src/hooks/presentation/solid/state/refDebounced.ts +27 -0
- package/src/hooks/presentation/solid/state/refThrottled.ts +39 -0
- package/src/hooks/presentation/solid/state/syncRef.ts +24 -0
- package/src/hooks/presentation/solid/state/toRef.ts +18 -0
- package/src/hooks/presentation/solid/state/useArray.ts +55 -0
- package/src/hooks/presentation/solid/state/useCounter.ts +24 -0
- package/src/hooks/presentation/solid/state/useToggle.ts +20 -0
- package/src/hooks/presentation/solid/time/index.ts +6 -0
- package/src/hooks/presentation/solid/time/useDebounceFn.ts +18 -0
- package/src/hooks/presentation/solid/time/useInterval.ts +44 -0
- package/src/hooks/presentation/solid/time/useThrottleFn.ts +30 -0
- package/src/hooks/presentation/solid/time/useTimeout.ts +37 -0
- package/src/hooks/presentation/solid/time/watchDebounced.ts +19 -0
- package/src/hooks/presentation/solid/time/watchPausable.ts +29 -0
- package/src/hooks/presentation/solid/time/whenever.ts +13 -0
- package/src/hooks/presentation/solid/utilities/index.ts +8 -0
- package/src/hooks/presentation/solid/utilities/useArrayEvery.ts +8 -0
- package/src/hooks/presentation/solid/utilities/useArrayFilter.ts +11 -0
- package/src/hooks/presentation/solid/utilities/useArrayFind.ts +8 -0
- package/src/hooks/presentation/solid/utilities/useArrayIncludes.ts +8 -0
- package/src/hooks/presentation/solid/utilities/useArrayMap.ts +8 -0
- package/src/hooks/presentation/solid/utilities/useArrayReduce.ts +9 -0
- package/src/hooks/presentation/solid/utilities/useArraySome.ts +8 -0
- package/src/hooks/presentation/solid/utilities/useArraySort.ts +12 -0
- package/src/hooks/presentation/solid/utilities/useClamp.ts +24 -0
- package/src/hooks/presentation/solid/utilities/useDebounce.ts +32 -0
- package/src/hooks/presentation/solid/utilities/useEventBus.ts +57 -0
- package/src/hooks/presentation/solid/utilities/useMemoize.ts +15 -0
- package/src/hooks/presentation/solid/utilities/useOffset.ts +20 -0
- package/src/hooks/presentation/solid/utilities/useRound.ts +24 -0
- package/src/hooks/presentation/solid/utilities/useSorted.ts +12 -0
- package/src/hooks/presentation/solid/utilities/useThrottle.ts +44 -0
- package/src/hooks/presentation/solid/utilities/useToNumber.ts +11 -0
- package/src/hooks/presentation/solid/utilities/useToString.ts +10 -0
- package/src/hooks/realtime/use-sse.ts +70 -0
- package/src/hooks/shared/constants/index.ts +4 -0
- package/src/hooks/shared/errors/index.ts +1 -0
- package/src/hooks/shared/errors/validation-error.ts +28 -0
- package/src/hooks/shared/index.ts +8 -0
- package/src/hooks/shared/types/index.ts +17 -0
- package/src/hooks/shared/types/option.ts +17 -0
- package/src/hooks/shared/types/result.ts +34 -0
- package/src/hooks/shared/types/utilities.ts +102 -0
- package/src/hooks/shared/utils/identity.ts +2 -0
- package/src/hooks/shared/utils/index.ts +4 -0
- package/src/hooks/shared/utils/logger.ts +69 -0
- package/src/hooks/shared/utils/pipe.ts +5 -0
- package/src/hooks/shared/utils/result.ts +9 -0
- package/src/hooks/test/counter.test.ts +25 -0
- package/src/index.ts +16 -0
- package/src/internal.ts +61 -0
- package/src/query/adapters/devtools/index.ts +29 -0
- package/src/query/adapters/persistence/index.ts +62 -0
- package/src/query/adapters/solid/index.ts +10 -0
- package/src/query/adapters/solid/solid-query-context.ts +29 -0
- package/src/query/adapters/solid/solid-query-empty-result.ts +34 -0
- package/src/query/adapters/solid/solid-query-options.ts +52 -0
- package/src/query/adapters/solid/solid-query-use-infinite.ts +228 -0
- package/src/query/adapters/solid/solid-query-use-mutation.ts +54 -0
- package/src/query/adapters/solid/solid-query-use-query.ts +75 -0
- package/src/query/adapters/solid/solid.test.ts +53 -0
- package/src/query/adapters/validation/index.ts +20 -0
- package/src/query/index.test.ts +203 -0
- package/src/query/index.ts +4 -0
- package/src/query/modules/query/application/usecases/query-client-data.ts +29 -0
- package/src/query/modules/query/application/usecases/query-client-helpers.ts +49 -0
- package/src/query/modules/query/application/usecases/query-client-infinite.ts +39 -0
- package/src/query/modules/query/application/usecases/query-client.ts +251 -0
- package/src/query/modules/query/domain/models/mutation-cache.ts +115 -0
- package/src/query/modules/query/domain/models/mutation.ts +207 -0
- package/src/query/modules/query/domain/models/query-cache.ts +119 -0
- package/src/query/modules/query/domain/models/query-environment.ts +16 -0
- package/src/query/modules/query/domain/models/query-observer.ts +162 -0
- package/src/query/modules/query/domain/models/query-operations.ts +76 -0
- package/src/query/modules/query/domain/models/query.ts +239 -0
- package/src/query/modules/query/domain/operations/index.ts +76 -0
- package/src/query/modules/query/index.ts +9 -0
- package/src/query/modules/query/ports/index.ts +53 -0
- package/src/query/modules/query/types/index.ts +239 -0
- package/src/query/shared/index.ts +48 -0
- package/src/render/adapters/index.ts +1 -0
- package/src/render/adapters/solid-web/hydration.ts +35 -0
- package/src/render/adapters/solid-web/index.ts +3 -0
- package/src/render/adapters/solid-web/renderer.ts +20 -0
- package/src/render/index.ts +7 -0
- package/src/render/modules/render/application/index.ts +1 -0
- package/src/render/modules/render/application/usecases/index.ts +4 -0
- package/src/render/modules/render/application/usecases/remote-island.ts +46 -0
- package/src/render/modules/render/application/usecases/render-page.ts +86 -0
- package/src/render/modules/render/application/usecases/render-shell.ts +56 -0
- package/src/render/modules/render/application/usecases/stream-page.ts +159 -0
- package/src/render/modules/render/domain/index.ts +3 -0
- package/src/render/modules/render/domain/models/context.ts +34 -0
- package/src/render/modules/render/domain/models/document.ts +26 -0
- package/src/render/modules/render/domain/models/index.ts +2 -0
- package/src/render/modules/render/domain/operations/document.ts +58 -0
- package/src/render/modules/render/domain/operations/hydration.ts +58 -0
- package/src/render/modules/render/domain/operations/index.ts +3 -0
- package/src/render/modules/render/domain/operations/rsc.ts +53 -0
- package/src/render/modules/render/domain/validators/index.ts +11 -0
- package/src/render/modules/render/index.ts +3 -0
- package/src/render/modules/render/ports/index.ts +17 -0
- package/src/render/presentation/ClientComponent.tsx +42 -0
- package/src/render/presentation/Document.tsx +45 -0
- package/src/render/presentation/Island.tsx +146 -0
- package/src/render/presentation/RemoteIsland.tsx +68 -0
- package/src/render/presentation/entries.ts +83 -0
- package/src/render/presentation/index.ts +5 -0
- package/src/render/shared/index.ts +2 -0
- package/src/render/shared/types/index.ts +9 -0
- package/src/render/shared/utils/index.ts +1 -0
- package/src/render/shared/utils/result.ts +30 -0
- package/src/render/types/index.ts +58 -0
- package/src/router/adapters/index.ts +1 -0
- package/src/router/adapters/solid-start/index.ts +42 -0
- package/src/router/cli/bundle-analyzer.ts +142 -0
- package/src/router/cli/index.ts +3 -0
- package/src/router/cli/migration-cli.ts +217 -0
- package/src/router/cli/route-generator-config.ts +109 -0
- package/src/router/cli/route-generator-templates.ts +117 -0
- package/src/router/cli/route-generator-types.ts +9 -0
- package/src/router/cli/route-generator-utils.ts +40 -0
- package/src/router/cli/route-generator.ts +64 -0
- package/src/router/index.test.ts +7 -0
- package/src/router/index.ts +21 -0
- package/src/router/modules/navigation/application/index.ts +1 -0
- package/src/router/modules/navigation/application/usecases.ts +42 -0
- package/src/router/modules/navigation/domain/index.ts +2 -0
- package/src/router/modules/navigation/domain/models.ts +44 -0
- package/src/router/modules/navigation/domain/operations.ts +28 -0
- package/src/router/modules/navigation/index.ts +3 -0
- package/src/router/modules/navigation/types/index.ts +15 -0
- package/src/router/modules/route-cache/application/usecases/index.ts +74 -0
- package/src/router/modules/route-cache/domain/models/index.ts +63 -0
- package/src/router/modules/route-cache/domain/operations/cache-evict.ts +104 -0
- package/src/router/modules/route-cache/domain/operations/cache-invalidate.ts +101 -0
- package/src/router/modules/route-cache/domain/operations/cache-read.ts +74 -0
- package/src/router/modules/route-cache/domain/operations/cache-write.ts +62 -0
- package/src/router/modules/route-cache/domain/operations/index.ts +4 -0
- package/src/router/modules/route-cache/domain/validators/index.ts +25 -0
- package/src/router/modules/route-cache/index.ts +8 -0
- package/src/router/modules/route-cache/ports/index.ts +20 -0
- package/src/router/modules/route-cache/types/index.ts +8 -0
- package/src/router/modules/route-error-tracking/application/usecases/index.ts +182 -0
- package/src/router/modules/route-error-tracking/domain/index.ts +5 -0
- package/src/router/modules/route-error-tracking/domain/models/index.ts +130 -0
- package/src/router/modules/route-error-tracking/domain/operations/error-cleanup.ts +50 -0
- package/src/router/modules/route-error-tracking/domain/operations/error-queries.ts +103 -0
- package/src/router/modules/route-error-tracking/domain/operations/error-recording.ts +112 -0
- package/src/router/modules/route-error-tracking/domain/operations/error-reporting.ts +55 -0
- package/src/router/modules/route-error-tracking/domain/operations/index.ts +4 -0
- package/src/router/modules/route-error-tracking/domain/validators/index.ts +46 -0
- package/src/router/modules/route-error-tracking/index.ts +8 -0
- package/src/router/modules/route-error-tracking/ports/index.ts +20 -0
- package/src/router/modules/route-error-tracking/types/index.ts +6 -0
- package/src/router/modules/route-feature-flags/application/usecases/index.ts +159 -0
- package/src/router/modules/route-feature-flags/domain/index.ts +5 -0
- package/src/router/modules/route-feature-flags/domain/models/index.ts +102 -0
- package/src/router/modules/route-feature-flags/domain/operations/feature-flag-audit.ts +37 -0
- package/src/router/modules/route-feature-flags/domain/operations/feature-flag-conditions.ts +52 -0
- package/src/router/modules/route-feature-flags/domain/operations/feature-flag-flags.ts +205 -0
- package/src/router/modules/route-feature-flags/domain/operations/feature-flag-routes.ts +54 -0
- package/src/router/modules/route-feature-flags/domain/operations/feature-flag-segments.ts +22 -0
- package/src/router/modules/route-feature-flags/domain/operations/feature-flag-statistics.ts +22 -0
- package/src/router/modules/route-feature-flags/domain/operations/index.ts +6 -0
- package/src/router/modules/route-feature-flags/domain/validators/index.ts +40 -0
- package/src/router/modules/route-feature-flags/index.ts +8 -0
- package/src/router/modules/route-feature-flags/ports/index.ts +23 -0
- package/src/router/modules/route-feature-flags/types/index.ts +7 -0
- package/src/router/modules/route-i18n/application/usecases/index.ts +81 -0
- package/src/router/modules/route-i18n/domain/models/index.ts +85 -0
- package/src/router/modules/route-i18n/domain/operations/index.ts +201 -0
- package/src/router/modules/route-i18n/domain/validators/index.ts +43 -0
- package/src/router/modules/route-i18n/index.ts +8 -0
- package/src/router/modules/route-i18n/ports/index.ts +20 -0
- package/src/router/modules/route-i18n/types/index.ts +7 -0
- package/src/router/modules/route-navigation-timeline/application/usecases/index.ts +182 -0
- package/src/router/modules/route-navigation-timeline/domain/index.ts +5 -0
- package/src/router/modules/route-navigation-timeline/domain/models/index.ts +143 -0
- package/src/router/modules/route-navigation-timeline/domain/operations/index.ts +177 -0
- package/src/router/modules/route-navigation-timeline/domain/validators/index.ts +19 -0
- package/src/router/modules/route-navigation-timeline/index.ts +8 -0
- package/src/router/modules/route-navigation-timeline/ports/index.ts +30 -0
- package/src/router/modules/route-navigation-timeline/types/index.ts +5 -0
- package/src/router/modules/route-performance/application/usecases/index.ts +166 -0
- package/src/router/modules/route-performance/domain/models/index.ts +96 -0
- package/src/router/modules/route-performance/domain/operations/index.ts +5 -0
- package/src/router/modules/route-performance/domain/operations/performance-cleanup.ts +29 -0
- package/src/router/modules/route-performance/domain/operations/performance-queries.ts +91 -0
- package/src/router/modules/route-performance/domain/operations/performance-recording.ts +151 -0
- package/src/router/modules/route-performance/domain/operations/performance-reporting.ts +32 -0
- package/src/router/modules/route-performance/domain/operations/performance-tracking.ts +75 -0
- package/src/router/modules/route-performance/domain/validators/index.ts +55 -0
- package/src/router/modules/route-performance/index.ts +8 -0
- package/src/router/modules/route-performance/ports/index.ts +25 -0
- package/src/router/modules/route-performance/types/index.ts +6 -0
- package/src/router/modules/route-security/application/usecases/index.ts +153 -0
- package/src/router/modules/route-security/domain/models/index.ts +216 -0
- package/src/router/modules/route-security/domain/operations/index.ts +165 -0
- package/src/router/modules/route-security/domain/validators/index.ts +32 -0
- package/src/router/modules/route-security/index.ts +8 -0
- package/src/router/modules/route-security/ports/index.ts +31 -0
- package/src/router/modules/route-security/types/index.ts +11 -0
- package/src/router/modules/route-testing/application/usecases/index.ts +131 -0
- package/src/router/modules/route-testing/domain/models/index.ts +217 -0
- package/src/router/modules/route-testing/domain/operations/contract-testing-operations.ts +239 -0
- package/src/router/modules/route-testing/domain/operations/e2e-testing-operations.ts +167 -0
- package/src/router/modules/route-testing/domain/operations/index.ts +3 -0
- package/src/router/modules/route-testing/domain/operations/route-testing-core.ts +48 -0
- package/src/router/modules/route-testing/domain/validators/index.ts +34 -0
- package/src/router/modules/route-testing/index.ts +8 -0
- package/src/router/modules/route-testing/ports/index.ts +21 -0
- package/src/router/modules/route-testing/types/index.ts +13 -0
- package/src/router/modules/routing/application/index.ts +7 -0
- package/src/router/modules/routing/application/usecases.ts +49 -0
- package/src/router/modules/routing/domain/ab-testing.ts +86 -0
- package/src/router/modules/routing/domain/analytics.ts +88 -0
- package/src/router/modules/routing/domain/caching-evict.ts +104 -0
- package/src/router/modules/routing/domain/caching-invalidate.ts +101 -0
- package/src/router/modules/routing/domain/caching-read.ts +74 -0
- package/src/router/modules/routing/domain/caching-state.ts +38 -0
- package/src/router/modules/routing/domain/caching-types.ts +38 -0
- package/src/router/modules/routing/domain/caching-write.ts +62 -0
- package/src/router/modules/routing/domain/caching.ts +6 -0
- package/src/router/modules/routing/domain/code-splitting.ts +226 -0
- package/src/router/modules/routing/domain/contract-factory.ts +37 -0
- package/src/router/modules/routing/domain/contract-testing.ts +13 -0
- package/src/router/modules/routing/domain/contract-types.ts +32 -0
- package/src/router/modules/routing/domain/contract-validator.ts +246 -0
- package/src/router/modules/routing/domain/dynamic-imports.ts +67 -0
- package/src/router/modules/routing/domain/e2e-testing.ts +267 -0
- package/src/router/modules/routing/domain/error-boundaries.ts +54 -0
- package/src/router/modules/routing/domain/error-tracking.ts +277 -0
- package/src/router/modules/routing/domain/feature-flags.ts +255 -0
- package/src/router/modules/routing/domain/guards.ts +104 -0
- package/src/router/modules/routing/domain/i18n.ts +230 -0
- package/src/router/modules/routing/domain/index.ts +30 -0
- package/src/router/modules/routing/domain/interactive-docs-advanced-sections.ts +164 -0
- package/src/router/modules/routing/domain/interactive-docs-core-sections.ts +198 -0
- package/src/router/modules/routing/domain/interactive-docs.ts +154 -0
- package/src/router/modules/routing/domain/isr.ts +35 -0
- package/src/router/modules/routing/domain/middleware.ts +79 -0
- package/src/router/modules/routing/domain/models.ts +95 -0
- package/src/router/modules/routing/domain/navigation-timeline.ts +243 -0
- package/src/router/modules/routing/domain/operations.ts +36 -0
- package/src/router/modules/routing/domain/optimized-matcher.ts +75 -0
- package/src/router/modules/routing/domain/performance-alert-manager.ts +28 -0
- package/src/router/modules/routing/domain/performance-monitoring.ts +287 -0
- package/src/router/modules/routing/domain/performance-report.ts +29 -0
- package/src/router/modules/routing/domain/performance-types.ts +19 -0
- package/src/router/modules/routing/domain/predictive-preloading.ts +296 -0
- package/src/router/modules/routing/domain/rbac.ts +219 -0
- package/src/router/modules/routing/domain/resource-routes.ts +64 -0
- package/src/router/modules/routing/domain/route-autocomplete.ts +176 -0
- package/src/router/modules/routing/domain/route-groups.ts +63 -0
- package/src/router/modules/routing/domain/security-scanner.ts +225 -0
- package/src/router/modules/routing/domain/server-actions.ts +71 -0
- package/src/router/modules/routing/domain/testing.ts +80 -0
- package/src/router/modules/routing/domain/type-safe-links.ts +72 -0
- package/src/router/modules/routing/domain/validators.ts +23 -0
- package/src/router/modules/routing/index.ts +4 -0
- package/src/router/modules/routing/ports/index.ts +1 -0
- package/src/router/modules/routing/ports/router-port.ts +15 -0
- package/src/router/modules/routing/types/index.ts +14 -0
- package/src/router/modules/routing-core/application/usecases/index.ts +49 -0
- package/src/router/modules/routing-core/domain/models/index.ts +95 -0
- package/src/router/modules/routing-core/domain/operations/index.ts +36 -0
- package/src/router/modules/routing-core/domain/validators/index.ts +28 -0
- package/src/router/modules/routing-core/index.ts +8 -0
- package/src/router/modules/routing-core/ports/index.ts +16 -0
- package/src/router/modules/routing-core/types/index.ts +25 -0
- package/src/router/presentation/index.ts +1 -0
- package/src/router/presentation/solid/components/index.ts +1 -0
- package/src/router/presentation/solid/components/route-visualizer-details.tsx +37 -0
- package/src/router/presentation/solid/components/route-visualizer-helpers.ts +56 -0
- package/src/router/presentation/solid/components/route-visualizer-tree.tsx +99 -0
- package/src/router/presentation/solid/components/route-visualizer-types.ts +41 -0
- package/src/router/presentation/solid/components/route-visualizer.tsx +110 -0
- package/src/router/presentation/solid/components/router.ts +82 -0
- package/src/router/presentation/solid/devtools/index.ts +2 -0
- package/src/router/presentation/solid/devtools/router-devtools-panel.tsx +141 -0
- package/src/router/presentation/solid/devtools/router-inspector.ts +54 -0
- package/src/router/presentation/solid/hmr.ts +77 -0
- package/src/router/presentation/solid/index.ts +7 -0
- package/src/router/presentation/solid/lazy-loading.ts +111 -0
- package/src/router/presentation/solid/preloading.ts +81 -0
- package/src/router/presentation/solid/route-state.ts +58 -0
- package/src/router/presentation/solid/signals/index.ts +2 -0
- package/src/router/presentation/solid/signals/route-state.ts +39 -0
- package/src/router/presentation/solid/signals/search-params.ts +31 -0
- package/src/router/shared/constants/index.ts +6 -0
- package/src/router/shared/errors/enhanced-errors.ts +94 -0
- package/src/router/shared/errors/index.ts +30 -0
- package/src/router/shared/index.ts +4 -0
- package/src/router/shared/types/either.ts +55 -0
- package/src/router/shared/types/index.ts +5 -0
- package/src/router/shared/types/option.ts +20 -0
- package/src/router/shared/types/result.ts +34 -0
- package/src/router/shared/types/route-inference.ts +49 -0
- package/src/router/shared/types/routing.ts +31 -0
- package/src/router/shared/utils/index.ts +3 -0
- package/src/router/shared/utils/path.ts +43 -0
- package/src/router/shared/utils/result.ts +5 -0
- package/src/router/shared/utils/time-condition.ts +53 -0
- package/src/router/vite-plugin/index.ts +2 -0
- package/src/router/vite-plugin/vite-plugin-core.ts +79 -0
- package/src/router/vite-plugin/vite-plugin-options-advanced.ts +127 -0
- package/src/router/vite-plugin/vite-plugin-options-features.ts +117 -0
- package/src/router/vite-plugin/vite-plugin-options-routing.ts +70 -0
- package/src/router/vite-plugin/vite-plugin-options.ts +23 -0
- package/src/server/adapters/index.ts +2 -0
- package/src/server/adapters/platforms.ts +79 -0
- package/src/server/adapters/web-server/index.ts +281 -0
- package/src/server/index.ts +13 -0
- package/src/server/modules/http/domain/operations/cookies.ts +151 -0
- package/src/server/modules/http/domain/operations/metrics.ts +103 -0
- package/src/server/modules/http/domain/operations/request-context.ts +36 -0
- package/src/server/modules/http/domain/operations/session-store.ts +98 -0
- package/src/server/modules/http/index.ts +15 -0
- package/src/server/modules/loaders/application/index.ts +1 -0
- package/src/server/modules/loaders/application/usecases/create-route-loader.ts +88 -0
- package/src/server/modules/loaders/application/usecases/dehydrate.ts +21 -0
- package/src/server/modules/loaders/application/usecases/index.ts +2 -0
- package/src/server/modules/loaders/index.ts +1 -0
- package/src/server/modules/realtime/domain/operations/channels.ts +241 -0
- package/src/server/modules/realtime/domain/operations/sse.ts +63 -0
- package/src/server/modules/realtime/index.ts +2 -0
- package/src/server/modules/server-functions/adapters/http/handler.ts +128 -0
- package/src/server/modules/server-functions/application/index.ts +1 -0
- package/src/server/modules/server-functions/application/usecases/batch.ts +135 -0
- package/src/server/modules/server-functions/application/usecases/create-server-fn.ts +272 -0
- package/src/server/modules/server-functions/application/usecases/csrf.ts +67 -0
- package/src/server/modules/server-functions/application/usecases/index.ts +6 -0
- package/src/server/modules/server-functions/application/usecases/live.ts +172 -0
- package/src/server/modules/server-functions/application/usecases/registry.ts +22 -0
- package/src/server/modules/server-functions/application/usecases/scheduler.ts +115 -0
- package/src/server/modules/server-functions/domain/index.ts +24 -0
- package/src/server/modules/server-functions/domain/models/execution-result.ts +18 -0
- package/src/server/modules/server-functions/domain/models/index.ts +1 -0
- package/src/server/modules/server-functions/domain/operations/result.ts +61 -0
- package/src/server/modules/server-functions/domain/operations/serialize.ts +134 -0
- package/src/server/modules/server-functions/domain/operations/stream.ts +107 -0
- package/src/server/modules/server-functions/index.ts +3 -0
- package/src/server/modules/server-only/index.ts +30 -0
- package/src/server/node.ts +10 -0
- package/src/server/shared/errors/index.ts +1 -0
- package/src/server/shared/errors/server-fn-error.ts +27 -0
- package/src/server/shared/index.ts +2 -0
- package/src/server/shared/types/index.ts +5 -0
- package/src/server/types/index.ts +65 -0
- package/src/stores/adapters/analytics/index.ts +5 -0
- package/src/stores/adapters/analytics/monitoring.ts +164 -0
- package/src/stores/adapters/devtools/index.ts +80 -0
- package/src/stores/adapters/persistence/index.ts +5 -0
- package/src/stores/adapters/persistence/versioning.ts +142 -0
- package/src/stores/adapters/router/index.ts +144 -0
- package/src/stores/adapters/storage/index.ts +6 -0
- package/src/stores/adapters/storage/indexed-db.ts +83 -0
- package/src/stores/adapters/storage/local-storage.ts +44 -0
- package/src/stores/adapters/storage/session-storage.ts +44 -0
- package/src/stores/adapters/sync/index.ts +5 -0
- package/src/stores/adapters/sync/tab-sync.ts +148 -0
- package/src/stores/adapters/validation/arktype-validator.ts +32 -0
- package/src/stores/adapters/validation/error-handling.ts +27 -0
- package/src/stores/adapters/validation/index.ts +61 -0
- package/src/stores/adapters/validation/schemas/api-schemas.ts +30 -0
- package/src/stores/adapters/validation/schemas/common-schemas.ts +32 -0
- package/src/stores/adapters/validation/schemas/config-schemas.ts +22 -0
- package/src/stores/adapters/validation/schemas/constraint-schemas.ts +34 -0
- package/src/stores/adapters/validation/schemas/ecommerce-schemas.ts +43 -0
- package/src/stores/adapters/validation/schemas/form-schemas.ts +27 -0
- package/src/stores/adapters/validation/schemas/primitive-schemas.ts +9 -0
- package/src/stores/adapters/validation/schemas/store-schemas.ts +52 -0
- package/src/stores/adapters/validation/schemas.ts +11 -0
- package/src/stores/index.ts +13 -0
- package/src/stores/modules/query/index.ts +24 -0
- package/src/stores/modules/query/mutation-state.ts +33 -0
- package/src/stores/modules/query/mutation-store.ts +59 -0
- package/src/stores/modules/query/query-builder.ts +25 -0
- package/src/stores/modules/query/query-cache.ts +65 -0
- package/src/stores/modules/query/query-manager.ts +103 -0
- package/src/stores/modules/query/query-state.ts +39 -0
- package/src/stores/modules/query/query-store.ts +81 -0
- package/src/stores/modules/store/application/usecases/index.ts +217 -0
- package/src/stores/modules/store/domain/models/index.ts +38 -0
- package/src/stores/modules/store/domain/operations/actions.ts +120 -0
- package/src/stores/modules/store/domain/operations/composition.ts +205 -0
- package/src/stores/modules/store/domain/operations/derived-operations.ts +21 -0
- package/src/stores/modules/store/domain/operations/diffing.ts +272 -0
- package/src/stores/modules/store/domain/operations/event-bus.ts +255 -0
- package/src/stores/modules/store/domain/operations/history-operations.ts +101 -0
- package/src/stores/modules/store/domain/operations/hydration.ts +159 -0
- package/src/stores/modules/store/domain/operations/immutable.ts +173 -0
- package/src/stores/modules/store/domain/operations/index.ts +21 -0
- package/src/stores/modules/store/domain/operations/middleware.ts +193 -0
- package/src/stores/modules/store/domain/operations/mutations.ts +14 -0
- package/src/stores/modules/store/domain/operations/normalization.ts +195 -0
- package/src/stores/modules/store/domain/operations/optimistic.ts +171 -0
- package/src/stores/modules/store/domain/operations/persistence-operations.ts +26 -0
- package/src/stores/modules/store/domain/operations/queries.ts +296 -0
- package/src/stores/modules/store/domain/operations/selectors.ts +112 -0
- package/src/stores/modules/store/domain/operations/store-operations.ts +52 -0
- package/src/stores/modules/store/domain/operations/time-machine.ts +240 -0
- package/src/stores/modules/store/domain/operations/transactions.ts +198 -0
- package/src/stores/modules/store/domain/validators/action-validators.ts +20 -0
- package/src/stores/modules/store/domain/validators/history-validators.ts +19 -0
- package/src/stores/modules/store/domain/validators/index.ts +7 -0
- package/src/stores/modules/store/domain/validators/persistence-validators.ts +23 -0
- package/src/stores/modules/store/domain/validators/store-validators.ts +41 -0
- package/src/stores/modules/store/index.ts +9 -0
- package/src/stores/modules/store/ports/index.ts +104 -0
- package/src/stores/modules/store/types/index.ts +35 -0
- package/src/stores/shared/constants/index.ts +50 -0
- package/src/stores/shared/errors/index.ts +122 -0
- package/src/stores/shared/index.ts +7 -0
- package/src/stores/shared/schema-generator.ts +262 -0
- package/src/stores/shared/types/index.ts +147 -0
- package/src/testing/index.ts +90 -0
- package/src/vite/auto-imports.ts +65 -0
- package/src/vite/client.d.ts +25 -0
- package/src/vite/dev-middleware.ts +142 -0
- package/src/vite/index.ts +9 -0
- package/src/vite/plugin.ts +277 -0
- package/src/vite/prerender.ts +72 -0
- package/src/vite/server-fn-ids.ts +52 -0
- package/src/vite/types/index.ts +24 -0
- package/src/vite/virtual-modules.ts +68 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js adapter — wraps the framework fetch handler in a `node:http`
|
|
3
|
+
* server. Loaded lazily so edge bundles never touch `node:http`.
|
|
4
|
+
*
|
|
5
|
+
* const server = toNodeServer(handler, { port: 3000 });
|
|
6
|
+
* await server.start();
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { NodeServerHandle } from "../domain/models/preset";
|
|
10
|
+
|
|
11
|
+
export const toNodeServer = (
|
|
12
|
+
handler: (request: Request) => Promise<Response>,
|
|
13
|
+
options: { port?: number } = {},
|
|
14
|
+
): NodeServerHandle => {
|
|
15
|
+
const port = options.port ?? Number(process.env.PORT ?? 3000);
|
|
16
|
+
|
|
17
|
+
let server: import("node:http").Server | undefined;
|
|
18
|
+
|
|
19
|
+
const start = async () => {
|
|
20
|
+
const { createServer } = await import("node:http");
|
|
21
|
+
server = createServer((req, res) => {
|
|
22
|
+
const chunks: Buffer[] = [];
|
|
23
|
+
req.on("data", (chunk: Buffer) => chunks.push(chunk));
|
|
24
|
+
req.on("end", async () => {
|
|
25
|
+
try {
|
|
26
|
+
const host = req.headers.host ?? "localhost";
|
|
27
|
+
const method = req.method ?? "GET";
|
|
28
|
+
const headers = new Headers();
|
|
29
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
30
|
+
if (value !== undefined)
|
|
31
|
+
headers.set(key, Array.isArray(value) ? value.join(", ") : value);
|
|
32
|
+
}
|
|
33
|
+
const response = await handler(
|
|
34
|
+
new Request(`http://${host}${req.url ?? "/"}`, {
|
|
35
|
+
method,
|
|
36
|
+
headers,
|
|
37
|
+
body:
|
|
38
|
+
method !== "GET" && method !== "HEAD"
|
|
39
|
+
? Buffer.concat(chunks)
|
|
40
|
+
: undefined,
|
|
41
|
+
} as RequestInit),
|
|
42
|
+
);
|
|
43
|
+
res.statusCode = response.status;
|
|
44
|
+
response.headers.forEach((value, key) => {
|
|
45
|
+
res.setHeader(key, value);
|
|
46
|
+
});
|
|
47
|
+
res.end(Buffer.from(await response.arrayBuffer()));
|
|
48
|
+
} catch {
|
|
49
|
+
res.statusCode = 500;
|
|
50
|
+
res.end("Internal Server Error");
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
server.listen(port);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const stop = () =>
|
|
58
|
+
new Promise<void>((resolve) =>
|
|
59
|
+
server ? server.close(() => resolve()) : resolve(),
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return { start, stop };
|
|
63
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vercel / edge-function adapter
|
|
3
|
+
*
|
|
4
|
+
* Vercel functions dispatch on exported HTTP method handlers, so the
|
|
5
|
+
* preset re-exports the framework fetch handler under every method:
|
|
6
|
+
*
|
|
7
|
+
* export const { GET, POST } = toVercelHandler(handler);
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { MethodHandlers } from "../domain/models/preset";
|
|
11
|
+
|
|
12
|
+
export const toVercelHandler = (
|
|
13
|
+
handler: (request: Request) => Promise<Response>,
|
|
14
|
+
): MethodHandlers => ({
|
|
15
|
+
GET: handler,
|
|
16
|
+
POST: handler,
|
|
17
|
+
PUT: handler,
|
|
18
|
+
PATCH: handler,
|
|
19
|
+
DELETE: handler,
|
|
20
|
+
HEAD: handler,
|
|
21
|
+
OPTIONS: handler,
|
|
22
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deploy preset types — the framework handler is a web-standard
|
|
3
|
+
* `(request: Request) => Promise<Response>`, so presets only adapt the
|
|
4
|
+
* export shape each platform expects
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export type DeployPreset =
|
|
8
|
+
| "node"
|
|
9
|
+
| "bun"
|
|
10
|
+
| "deno"
|
|
11
|
+
| "cloudflare"
|
|
12
|
+
| "netlify"
|
|
13
|
+
| "vercel"
|
|
14
|
+
| "aws-lambda";
|
|
15
|
+
|
|
16
|
+
export interface WorkerEntry<Env = unknown, Ctx = unknown> {
|
|
17
|
+
fetch: (request: Request, env: Env, ctx: Ctx) => Promise<Response>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface MethodHandlers {
|
|
21
|
+
GET: (request: Request) => Promise<Response>;
|
|
22
|
+
POST: (request: Request) => Promise<Response>;
|
|
23
|
+
PUT: (request: Request) => Promise<Response>;
|
|
24
|
+
PATCH: (request: Request) => Promise<Response>;
|
|
25
|
+
DELETE: (request: Request) => Promise<Response>;
|
|
26
|
+
HEAD: (request: Request) => Promise<Response>;
|
|
27
|
+
OPTIONS: (request: Request) => Promise<Response>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface NodeServerHandle {
|
|
31
|
+
start: () => Promise<void>;
|
|
32
|
+
stop: () => Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface BunServeOptions {
|
|
36
|
+
fetch: (request: Request) => Promise<Response>;
|
|
37
|
+
port: number;
|
|
38
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* resolveDeployEntry — pick the export shape a hosting platform expects
|
|
3
|
+
*
|
|
4
|
+
* The framework handler is always `(request) => Promise<Response>`; each
|
|
5
|
+
* preset only adapts that contract:
|
|
6
|
+
*
|
|
7
|
+
* "node" → NodeServerHandle (start/stop around node:http)
|
|
8
|
+
* "bun" → Bun.serve options
|
|
9
|
+
* "cloudflare" → Worker `export default { fetch }`
|
|
10
|
+
* "vercel" → named HTTP method handlers
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
type LambdaHttpEvent,
|
|
15
|
+
type LambdaHttpResult,
|
|
16
|
+
toLambdaHandler,
|
|
17
|
+
} from "../../adapters/aws-lambda";
|
|
18
|
+
import { toBunServeOptions } from "../../adapters/bun";
|
|
19
|
+
import { toWorkerEntry } from "../../adapters/cloudflare";
|
|
20
|
+
import { toDenoServeOptions } from "../../adapters/deno";
|
|
21
|
+
import { type NetlifyContext, toNetlifyHandler } from "../../adapters/netlify";
|
|
22
|
+
import { toNodeServer } from "../../adapters/node";
|
|
23
|
+
import { toVercelHandler } from "../../adapters/vercel";
|
|
24
|
+
import type {
|
|
25
|
+
BunServeOptions,
|
|
26
|
+
DeployPreset,
|
|
27
|
+
MethodHandlers,
|
|
28
|
+
NodeServerHandle,
|
|
29
|
+
WorkerEntry,
|
|
30
|
+
} from "../models/preset";
|
|
31
|
+
|
|
32
|
+
export interface DeployOptions {
|
|
33
|
+
port?: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function resolveDeployEntry(
|
|
37
|
+
preset: "node",
|
|
38
|
+
handler: (request: Request) => Promise<Response>,
|
|
39
|
+
options?: DeployOptions,
|
|
40
|
+
): NodeServerHandle;
|
|
41
|
+
export function resolveDeployEntry(
|
|
42
|
+
preset: "bun",
|
|
43
|
+
handler: (request: Request) => Promise<Response>,
|
|
44
|
+
options?: DeployOptions,
|
|
45
|
+
): BunServeOptions;
|
|
46
|
+
export function resolveDeployEntry(
|
|
47
|
+
preset: "cloudflare",
|
|
48
|
+
handler: (request: Request) => Promise<Response>,
|
|
49
|
+
options?: DeployOptions,
|
|
50
|
+
): WorkerEntry;
|
|
51
|
+
export function resolveDeployEntry(
|
|
52
|
+
preset: "vercel",
|
|
53
|
+
handler: (request: Request) => Promise<Response>,
|
|
54
|
+
options?: DeployOptions,
|
|
55
|
+
): MethodHandlers;
|
|
56
|
+
export function resolveDeployEntry(
|
|
57
|
+
preset: "deno",
|
|
58
|
+
handler: (request: Request) => Promise<Response>,
|
|
59
|
+
options?: DeployOptions,
|
|
60
|
+
): BunServeOptions;
|
|
61
|
+
export function resolveDeployEntry(
|
|
62
|
+
preset: "netlify",
|
|
63
|
+
handler: (request: Request) => Promise<Response>,
|
|
64
|
+
options?: DeployOptions,
|
|
65
|
+
): (request: Request, context: NetlifyContext) => Promise<Response>;
|
|
66
|
+
export function resolveDeployEntry(
|
|
67
|
+
preset: "aws-lambda",
|
|
68
|
+
handler: (request: Request) => Promise<Response>,
|
|
69
|
+
options?: DeployOptions,
|
|
70
|
+
): (event: LambdaHttpEvent) => Promise<LambdaHttpResult>;
|
|
71
|
+
export function resolveDeployEntry(
|
|
72
|
+
preset: DeployPreset,
|
|
73
|
+
handler: (request: Request) => Promise<Response>,
|
|
74
|
+
options: DeployOptions = {},
|
|
75
|
+
) {
|
|
76
|
+
switch (preset) {
|
|
77
|
+
case "node":
|
|
78
|
+
return toNodeServer(handler, options);
|
|
79
|
+
case "bun":
|
|
80
|
+
return toBunServeOptions(handler, options);
|
|
81
|
+
case "deno":
|
|
82
|
+
return toDenoServeOptions(handler, options);
|
|
83
|
+
case "cloudflare":
|
|
84
|
+
return toWorkerEntry(handler);
|
|
85
|
+
case "netlify":
|
|
86
|
+
return toNetlifyHandler(handler);
|
|
87
|
+
case "vercel":
|
|
88
|
+
return toVercelHandler(handler);
|
|
89
|
+
case "aws-lambda":
|
|
90
|
+
return toLambdaHandler(handler);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./adapters/aws-lambda";
|
|
2
|
+
export * from "./adapters/bun";
|
|
3
|
+
export * from "./adapters/cloudflare";
|
|
4
|
+
export * from "./adapters/deno";
|
|
5
|
+
export * from "./adapters/netlify";
|
|
6
|
+
export * from "./adapters/node";
|
|
7
|
+
export * from "./adapters/vercel";
|
|
8
|
+
export * from "./domain/models/preset";
|
|
9
|
+
export * from "./domain/operations/presets";
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Draft Mode — bypass prerender/ISR cache for previewing edits.
|
|
3
|
+
* The cookie is HMAC-signed with `secret` (+expiry) so it can't be
|
|
4
|
+
* forged without knowing the token:
|
|
5
|
+
*
|
|
6
|
+
* // config.middleware
|
|
7
|
+
* draftMode({ secret: "preview-secret" })
|
|
8
|
+
*
|
|
9
|
+
* Enable: /posts?__draft=preview-secret → signed cookie, clean redirect
|
|
10
|
+
* Disable: /posts?__draft=0 → clears cookie
|
|
11
|
+
* While active, state.draft = true and cached pages are skipped.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { redirect } from "#app/modules/middleware";
|
|
15
|
+
import type { AppMiddleware } from "#app/types";
|
|
16
|
+
|
|
17
|
+
export const DRAFT_COOKIE = "__draft";
|
|
18
|
+
export const DRAFT_STATE = "draft";
|
|
19
|
+
|
|
20
|
+
export interface DraftModeOptions {
|
|
21
|
+
/** Required token to enable — also signs the cookie; omit for dev-only plain cookie */
|
|
22
|
+
secret?: string;
|
|
23
|
+
/** Cookie name — default "__draft" */
|
|
24
|
+
cookie?: string;
|
|
25
|
+
/** Cookie lifetime seconds — default 3600 */
|
|
26
|
+
ttl?: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const b64 = (buf: ArrayBuffer): string =>
|
|
30
|
+
btoa(String.fromCharCode(...new Uint8Array(buf)))
|
|
31
|
+
.replaceAll("+", "-")
|
|
32
|
+
.replaceAll("/", "_")
|
|
33
|
+
.replaceAll("=", "");
|
|
34
|
+
|
|
35
|
+
const sign = async (payload: string, secret: string): Promise<string> => {
|
|
36
|
+
const key = await crypto.subtle.importKey(
|
|
37
|
+
"raw",
|
|
38
|
+
new TextEncoder().encode(secret),
|
|
39
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
40
|
+
false,
|
|
41
|
+
["sign", "verify"],
|
|
42
|
+
);
|
|
43
|
+
return b64(
|
|
44
|
+
await crypto.subtle.sign("HMAC", key, new TextEncoder().encode(payload)),
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const timingSafeEq = (a: string, b: string): boolean => {
|
|
49
|
+
if (a.length !== b.length) return false;
|
|
50
|
+
let diff = 0;
|
|
51
|
+
for (let i = 0; i < a.length; i++) diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
52
|
+
return diff === 0;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const draftMode = (options: DraftModeOptions = {}): AppMiddleware => {
|
|
56
|
+
const name = options.cookie ?? DRAFT_COOKIE;
|
|
57
|
+
const ttl = options.ttl ?? 3600;
|
|
58
|
+
return async (ctx) => {
|
|
59
|
+
const param = ctx.url.searchParams.get(DRAFT_COOKIE);
|
|
60
|
+
if (param === "0") {
|
|
61
|
+
// Disable — strip the param and expire the cookie
|
|
62
|
+
const clean = new URL(ctx.url);
|
|
63
|
+
clean.searchParams.delete(DRAFT_COOKIE);
|
|
64
|
+
const res = redirect(clean.pathname + clean.search);
|
|
65
|
+
res.headers.append(
|
|
66
|
+
"Set-Cookie",
|
|
67
|
+
`${name}=; Path=/; Max-Age=0; HttpOnly; SameSite=Lax`,
|
|
68
|
+
);
|
|
69
|
+
return res;
|
|
70
|
+
}
|
|
71
|
+
if (param !== null) {
|
|
72
|
+
if (
|
|
73
|
+
options.secret !== undefined &&
|
|
74
|
+
!timingSafeEq(param, options.secret)
|
|
75
|
+
) {
|
|
76
|
+
return new Response("invalid draft secret", { status: 401 });
|
|
77
|
+
}
|
|
78
|
+
// Enable — signed cookie when a secret is configured
|
|
79
|
+
const clean = new URL(ctx.url);
|
|
80
|
+
clean.searchParams.delete(DRAFT_COOKIE);
|
|
81
|
+
const res = redirect(clean.pathname + clean.search);
|
|
82
|
+
const value = options.secret
|
|
83
|
+
? await (async () => {
|
|
84
|
+
const exp = Math.floor(Date.now() / 1000) + ttl;
|
|
85
|
+
const payload = `1.${exp}`;
|
|
86
|
+
return `${payload}.${await sign(payload, options.secret as string)}`;
|
|
87
|
+
})()
|
|
88
|
+
: "1";
|
|
89
|
+
res.headers.append(
|
|
90
|
+
"Set-Cookie",
|
|
91
|
+
`${name}=${value}; Path=/; HttpOnly; SameSite=Lax; Max-Age=${ttl}`,
|
|
92
|
+
);
|
|
93
|
+
return res;
|
|
94
|
+
}
|
|
95
|
+
const raw = ctx.request.headers
|
|
96
|
+
.get("cookie")
|
|
97
|
+
?.match(new RegExp(`(?:^|;\\s*)${name}=([^;]+)`))?.[1];
|
|
98
|
+
if (raw) {
|
|
99
|
+
if (options.secret) {
|
|
100
|
+
const parts = raw.split(".");
|
|
101
|
+
if (parts.length === 3) {
|
|
102
|
+
const [v, expS, sig] = parts;
|
|
103
|
+
const payload = `${v}.${expS}`;
|
|
104
|
+
const expected = await sign(payload, options.secret);
|
|
105
|
+
const expired = Number(expS) < Date.now() / 1000;
|
|
106
|
+
if (
|
|
107
|
+
v === "1" &&
|
|
108
|
+
!expired &&
|
|
109
|
+
sig.length === expected.length &&
|
|
110
|
+
timingSafeEq(sig, expected)
|
|
111
|
+
) {
|
|
112
|
+
ctx.state[DRAFT_STATE] = true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
} else if (raw === "1") {
|
|
116
|
+
ctx.state[DRAFT_STATE] = true;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return undefined;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/** Read draft state inside loaders/middleware */
|
|
124
|
+
export const isDraft = (state: Record<string, unknown>): boolean =>
|
|
125
|
+
state[DRAFT_STATE] === true;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./domain/operations/draft-mode";
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed Environment
|
|
3
|
+
* Validate process.env / import.meta.env once at startup — server
|
|
4
|
+
* vars never leak to the client (they throw when read on the client),
|
|
5
|
+
* public vars are the PUBLIC_*-prefixed set (Nuxt runtimeConfig /
|
|
6
|
+
* Next NEXT_PUBLIC equivalent)
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export interface EnvField<T> {
|
|
10
|
+
parse: (raw: string | undefined) => T;
|
|
11
|
+
optional?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const env = {
|
|
15
|
+
string: (opts?: { default?: string }): EnvField<string> => ({
|
|
16
|
+
optional: opts?.default !== undefined,
|
|
17
|
+
parse: (raw) => {
|
|
18
|
+
if (raw === undefined || raw === "") {
|
|
19
|
+
if (opts?.default !== undefined) return opts.default;
|
|
20
|
+
throw new Error("required");
|
|
21
|
+
}
|
|
22
|
+
return raw;
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
number: (opts?: { default?: number }): EnvField<number> => ({
|
|
26
|
+
optional: opts?.default !== undefined,
|
|
27
|
+
parse: (raw) => {
|
|
28
|
+
if (raw === undefined || raw === "") {
|
|
29
|
+
if (opts?.default !== undefined) return opts.default;
|
|
30
|
+
throw new Error("required");
|
|
31
|
+
}
|
|
32
|
+
const n = Number(raw);
|
|
33
|
+
if (Number.isNaN(n)) throw new Error("not a number");
|
|
34
|
+
return n;
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
boolean: (): EnvField<boolean> => ({
|
|
38
|
+
optional: true,
|
|
39
|
+
parse: (raw) => raw === "true" || raw === "1",
|
|
40
|
+
}),
|
|
41
|
+
url: (): EnvField<string> => ({
|
|
42
|
+
parse: (raw) => {
|
|
43
|
+
if (!raw) throw new Error("required");
|
|
44
|
+
return new URL(raw).toString();
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
type Parsed<F extends Record<string, AnyEnvField<unknown>>> = {
|
|
50
|
+
[K in keyof F]: F[K] extends EnvField<infer T>
|
|
51
|
+
? T
|
|
52
|
+
: F[K] extends SchemaField<infer T>
|
|
53
|
+
? T
|
|
54
|
+
: never;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export interface CreateEnvOptions<
|
|
58
|
+
S extends Record<string, AnyEnvField<unknown>>,
|
|
59
|
+
P extends Record<string, AnyEnvField<unknown>>,
|
|
60
|
+
> {
|
|
61
|
+
server?: S;
|
|
62
|
+
public?: P;
|
|
63
|
+
/** Env source — defaults to process.env / import.meta.env */
|
|
64
|
+
source?: Record<string, string | undefined>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const isClient = (): boolean =>
|
|
68
|
+
typeof window !== "undefined" && typeof document !== "undefined";
|
|
69
|
+
|
|
70
|
+
/** Arktype-compatible validator — `{ assert(data): T }` */
|
|
71
|
+
export interface SchemaField<T> {
|
|
72
|
+
assert: (raw: string | undefined) => T;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type AnyEnvField<T> = EnvField<T> | SchemaField<T>;
|
|
76
|
+
|
|
77
|
+
const parseField = <T>(field: AnyEnvField<T>, raw: string | undefined): T =>
|
|
78
|
+
"parse" in field ? field.parse(raw) : field.assert(raw);
|
|
79
|
+
|
|
80
|
+
export const createEnv = <
|
|
81
|
+
S extends Record<string, AnyEnvField<unknown>>,
|
|
82
|
+
P extends Record<string, AnyEnvField<unknown>>,
|
|
83
|
+
>(
|
|
84
|
+
options: CreateEnvOptions<S, P>,
|
|
85
|
+
): Parsed<S> & Parsed<P> => {
|
|
86
|
+
const source =
|
|
87
|
+
options.source ??
|
|
88
|
+
({
|
|
89
|
+
...(typeof process !== "undefined" ? process.env : {}),
|
|
90
|
+
// Vite client bundles expose PUBLIC_* via import.meta.env
|
|
91
|
+
...(typeof import.meta !== "undefined"
|
|
92
|
+
? (import.meta as { env?: Record<string, string | undefined> }).env
|
|
93
|
+
: {}),
|
|
94
|
+
} as Record<string, string | undefined>);
|
|
95
|
+
|
|
96
|
+
const result: Record<string, unknown> = {};
|
|
97
|
+
const errors: string[] = [];
|
|
98
|
+
|
|
99
|
+
for (const [group, fields] of [
|
|
100
|
+
["server", options.server ?? {}],
|
|
101
|
+
["public", options.public ?? {}],
|
|
102
|
+
] as const) {
|
|
103
|
+
for (const [name, field] of Object.entries(
|
|
104
|
+
fields as Record<string, AnyEnvField<unknown>>,
|
|
105
|
+
)) {
|
|
106
|
+
try {
|
|
107
|
+
result[name] = parseField(field, source[name]);
|
|
108
|
+
} catch {
|
|
109
|
+
errors.push(`${name} (${group})`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (errors.length > 0) {
|
|
115
|
+
throw new Error(
|
|
116
|
+
`[solid-framework] invalid environment: ${errors.join(", ")}`,
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Server vars throw when read in the browser bundle
|
|
121
|
+
if (isClient()) {
|
|
122
|
+
for (const name of Object.keys(options.server ?? {})) {
|
|
123
|
+
Object.defineProperty(result, name, {
|
|
124
|
+
get() {
|
|
125
|
+
throw new Error(
|
|
126
|
+
`[solid-framework] server env "${name}" is not available on the client`,
|
|
127
|
+
);
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return result as Parsed<S> & Parsed<P>;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/** Alias — `defineEnv({ server: {SECRET: env.string()}, public: {...} })` */
|
|
137
|
+
export const defineEnv = createEnv;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Public-only view of a createEnv result — safe in client bundles;
|
|
141
|
+
* returns just the listed `public` group keys, typed:
|
|
142
|
+
*
|
|
143
|
+
* const e = createEnv({ public: { PUBLIC_API: env.string() } });
|
|
144
|
+
* const pub = usePublicEnv(e, ["PUBLIC_API"]); // {PUBLIC_API: string}
|
|
145
|
+
*/
|
|
146
|
+
export const usePublicEnv = <
|
|
147
|
+
T extends Record<string, unknown>,
|
|
148
|
+
K extends keyof T,
|
|
149
|
+
>(
|
|
150
|
+
created: T,
|
|
151
|
+
keys: readonly K[],
|
|
152
|
+
): Pick<T, K> => {
|
|
153
|
+
const out = {} as Pick<T, K>;
|
|
154
|
+
for (const k of keys) out[k] = created[k];
|
|
155
|
+
return out;
|
|
156
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./domain/operations/create-env";
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed API Client
|
|
3
|
+
* Runtime client for `.api.ts` routes — paths and methods are typed
|
|
4
|
+
* from the manifest; `solid generate` emits the ApiPaths union so
|
|
5
|
+
* callers get autocomplete + param checking:
|
|
6
|
+
*
|
|
7
|
+
* const api = createApiClient<{ "/users/[id]": { GET: User } }>();
|
|
8
|
+
* const user = await api.get("/users/[id]", { params: { id: "1" } });
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export type ApiMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Api Error — thrown by `client.json()` on non-2xx responses;
|
|
15
|
+
* `body` carries the parsed `{error}` envelope when present
|
|
16
|
+
*/
|
|
17
|
+
export class ApiError extends Error {
|
|
18
|
+
readonly status: number;
|
|
19
|
+
readonly code: string;
|
|
20
|
+
readonly body: unknown;
|
|
21
|
+
constructor(status: number, body: unknown) {
|
|
22
|
+
const env = body as { error?: { code?: string; message?: string } } | null;
|
|
23
|
+
super(env?.error?.message ?? `api request failed: ${status}`);
|
|
24
|
+
this.name = "ApiError";
|
|
25
|
+
this.status = status;
|
|
26
|
+
this.code = env?.error?.code ?? "API_ERROR";
|
|
27
|
+
this.body = body;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const isApiError = (error: unknown): error is ApiError =>
|
|
32
|
+
error instanceof ApiError;
|
|
33
|
+
|
|
34
|
+
/** Augmented by `.solid/api.d.ts` (solid generate) — path → methods map */
|
|
35
|
+
// biome-ignore lint/suspicious/noEmptyInterface: declaration-merged by generated api.d.ts — must stay an interface
|
|
36
|
+
export interface GeneratedApiPaths {}
|
|
37
|
+
|
|
38
|
+
type ParamsOf<Path extends string> =
|
|
39
|
+
Path extends `${string}[${infer Param}]${infer Rest}`
|
|
40
|
+
? { [K in Param]: string } & ParamsOf<Rest>
|
|
41
|
+
: Record<never, never>;
|
|
42
|
+
|
|
43
|
+
type MethodsOf<TPaths, Path extends keyof TPaths & string> = keyof TPaths[Path];
|
|
44
|
+
|
|
45
|
+
export interface ApiCallOptions<Path extends string> {
|
|
46
|
+
params?: ParamsOf<Path>;
|
|
47
|
+
search?: Record<string, string | number | boolean | undefined>;
|
|
48
|
+
headers?: Record<string, string>;
|
|
49
|
+
body?: unknown;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface ApiClient<TPaths> {
|
|
53
|
+
call<Path extends keyof TPaths & string>(
|
|
54
|
+
method: MethodsOf<TPaths, Path> & ApiMethod,
|
|
55
|
+
path: Path,
|
|
56
|
+
options?: ApiCallOptions<Path>,
|
|
57
|
+
): Promise<Response>;
|
|
58
|
+
get<Path extends keyof TPaths & string>(
|
|
59
|
+
path: Path,
|
|
60
|
+
options?: ApiCallOptions<Path>,
|
|
61
|
+
): Promise<Response>;
|
|
62
|
+
post<Path extends keyof TPaths & string>(
|
|
63
|
+
path: Path,
|
|
64
|
+
options?: ApiCallOptions<Path>,
|
|
65
|
+
): Promise<Response>;
|
|
66
|
+
json<Path extends keyof TPaths & string>(
|
|
67
|
+
method: MethodsOf<TPaths, Path> & ApiMethod,
|
|
68
|
+
path: Path,
|
|
69
|
+
options?: ApiCallOptions<Path>,
|
|
70
|
+
): Promise<unknown>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const fillParams = (path: string, params?: Record<string, string>): string =>
|
|
74
|
+
path.replace(/\[(\w+)\]/g, (_, key) =>
|
|
75
|
+
encodeURIComponent(params?.[key] ?? ""),
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
export const createApiClient = <
|
|
79
|
+
TPaths = GeneratedApiPaths extends { [K in never]: never }
|
|
80
|
+
? Record<string, Record<string, unknown>>
|
|
81
|
+
: GeneratedApiPaths,
|
|
82
|
+
>(
|
|
83
|
+
options: { baseUrl?: string; fetch?: typeof fetch } = {},
|
|
84
|
+
): ApiClient<TPaths> => {
|
|
85
|
+
const fetchFn = options.fetch ?? fetch;
|
|
86
|
+
const base = options.baseUrl ?? "";
|
|
87
|
+
|
|
88
|
+
const call = async <Path extends string>(
|
|
89
|
+
method: ApiMethod,
|
|
90
|
+
path: Path,
|
|
91
|
+
opts?: ApiCallOptions<Path>,
|
|
92
|
+
): Promise<Response> => {
|
|
93
|
+
const url = new URL(`${base}${fillParams(path, opts?.params)}`, "http://x");
|
|
94
|
+
for (const [k, v] of Object.entries(opts?.search ?? {})) {
|
|
95
|
+
if (v !== undefined) url.searchParams.set(k, String(v));
|
|
96
|
+
}
|
|
97
|
+
return fetchFn(url.pathname + url.search, {
|
|
98
|
+
method,
|
|
99
|
+
headers: {
|
|
100
|
+
...(opts?.body !== undefined
|
|
101
|
+
? { "Content-Type": "application/json" }
|
|
102
|
+
: {}),
|
|
103
|
+
...opts?.headers,
|
|
104
|
+
},
|
|
105
|
+
body: opts?.body !== undefined ? JSON.stringify(opts.body) : undefined,
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
call: (method, path, opts) => call(method, path, opts),
|
|
111
|
+
get: (path, opts) => call("GET", path, opts),
|
|
112
|
+
post: (path, opts) => call("POST", path, opts),
|
|
113
|
+
json: async (method, path, opts) => {
|
|
114
|
+
const response = await call(method, path, opts);
|
|
115
|
+
const body = await response.json().catch(() => null);
|
|
116
|
+
if (!response.ok) throw new ApiError(response.status, body);
|
|
117
|
+
return body;
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route Errors
|
|
3
|
+
* notFound() throws a typed error the render pipeline translates
|
|
4
|
+
* into a 404 status + the nearest not-found convention module
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export class NotFoundError extends Error {
|
|
8
|
+
readonly code = "NOT_FOUND" as const;
|
|
9
|
+
constructor(message = "Not Found") {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "NotFoundError";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const notFound = (message = "Not Found"): never => {
|
|
16
|
+
throw new NotFoundError(message);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const isNotFoundError = (error: unknown): error is NotFoundError =>
|
|
20
|
+
error instanceof NotFoundError ||
|
|
21
|
+
(typeof error === "object" &&
|
|
22
|
+
error !== null &&
|
|
23
|
+
(error as { code?: string }).code === "NOT_FOUND");
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Loader Error — thrown by the client loader path when the endpoint
|
|
27
|
+
* (or SSR chain) fails; carries a serialized code + status so
|
|
28
|
+
* error.tsx boundaries can branch on it
|
|
29
|
+
*/
|
|
30
|
+
export class LoaderError extends Error {
|
|
31
|
+
readonly code: string;
|
|
32
|
+
readonly status: number;
|
|
33
|
+
constructor(code: string, message: string, status = 500) {
|
|
34
|
+
super(message);
|
|
35
|
+
this.name = "LoaderError";
|
|
36
|
+
this.code = code;
|
|
37
|
+
this.status = status;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const isLoaderError = (error: unknown): error is LoaderError =>
|
|
42
|
+
error instanceof LoaderError ||
|
|
43
|
+
(typeof error === "object" &&
|
|
44
|
+
error !== null &&
|
|
45
|
+
(error as { code?: string }).code === "LOADER_ERROR");
|
|
46
|
+
|
|
47
|
+
/** Serialize an unknown error into the loader error envelope */
|
|
48
|
+
export const loaderErrorBody = (
|
|
49
|
+
error: unknown,
|
|
50
|
+
): { code: string; message: string } => {
|
|
51
|
+
if (isNotFoundError(error)) {
|
|
52
|
+
return { code: "NOT_FOUND", message: error.message };
|
|
53
|
+
}
|
|
54
|
+
if (isLoaderError(error)) {
|
|
55
|
+
return { code: error.code, message: error.message };
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
code: "LOADER_ERROR",
|
|
59
|
+
message: error instanceof Error ? error.message : "Loader failed",
|
|
60
|
+
};
|
|
61
|
+
};
|