@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,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route Status Context
|
|
3
|
+
* The render pipeline provides a mutable status slot; FileRoutes
|
|
4
|
+
* writes 404/500 into it so the HTTP response gets the right code
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { createContext } from "solid-js";
|
|
8
|
+
|
|
9
|
+
export interface RouteStatus {
|
|
10
|
+
status: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const RouteStatusContext = createContext<RouteStatus>();
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useAction — submit FormData to the current route's `action` export
|
|
3
|
+
* POSTs to the current URL; the server dispatches to the matched
|
|
4
|
+
* route's action and returns its Response (JSON or redirect)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { createSignal, onCleanup } from "solid-js";
|
|
8
|
+
import { isServer } from "solid-js/web";
|
|
9
|
+
import { readHydrationPayload } from "#render/modules/render/domain";
|
|
10
|
+
import { timedDevEvent } from "./dev-events";
|
|
11
|
+
import { useLocation } from "./location";
|
|
12
|
+
|
|
13
|
+
export interface UseAction<T = unknown> {
|
|
14
|
+
/** Submit a FormData (or a form element) to the route action */
|
|
15
|
+
submit: (form: FormData | HTMLFormElement) => Promise<T | undefined>;
|
|
16
|
+
pending: () => boolean;
|
|
17
|
+
result: () => T | undefined;
|
|
18
|
+
error: () => unknown;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const useAction = <T = unknown>(path?: string): UseAction<T> => {
|
|
22
|
+
const location = useLocation();
|
|
23
|
+
const [pending, setPending] = createSignal(false);
|
|
24
|
+
const [result, setResult] = createSignal<T>();
|
|
25
|
+
const [error, setError] = createSignal<unknown>();
|
|
26
|
+
let alive = true;
|
|
27
|
+
onCleanup(() => {
|
|
28
|
+
alive = false;
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const submit = async (input: FormData | HTMLFormElement) => {
|
|
32
|
+
if (isServer) return undefined;
|
|
33
|
+
const form = input instanceof HTMLFormElement ? new FormData(input) : input;
|
|
34
|
+
// <Form replace> — history replace on redirect follow
|
|
35
|
+
const replace = form.get("__replace") === "1";
|
|
36
|
+
form.delete("__replace");
|
|
37
|
+
setPending(true);
|
|
38
|
+
setError(undefined);
|
|
39
|
+
const target = path ?? location.pathname();
|
|
40
|
+
try {
|
|
41
|
+
const response = await timedDevEvent("action", target, () =>
|
|
42
|
+
fetch(target, {
|
|
43
|
+
method: "POST",
|
|
44
|
+
headers: { "x-sf-flight": target },
|
|
45
|
+
body: form,
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
48
|
+
if (response.redirected) {
|
|
49
|
+
location.navigate(new URL(response.url).pathname, { replace });
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
const data = (await response.json()) as T & {
|
|
53
|
+
__flight?: {
|
|
54
|
+
data?: unknown;
|
|
55
|
+
deferred?: Record<string, unknown>;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
// Single-flight — loader data rides the mutation response;
|
|
59
|
+
// write it into the hydration payload and re-run the loader
|
|
60
|
+
const flight = data?.__flight;
|
|
61
|
+
if (flight && "data" in flight) {
|
|
62
|
+
const payload = readHydrationPayload();
|
|
63
|
+
payload.loaders[target] = flight.data;
|
|
64
|
+
if (flight.deferred) {
|
|
65
|
+
payload.deferred = { ...payload.deferred, ...flight.deferred };
|
|
66
|
+
}
|
|
67
|
+
location.refresh();
|
|
68
|
+
delete data.__flight;
|
|
69
|
+
}
|
|
70
|
+
if (alive) setResult(() => data as T);
|
|
71
|
+
return data as T;
|
|
72
|
+
} catch (e) {
|
|
73
|
+
if (alive) setError(e);
|
|
74
|
+
return undefined;
|
|
75
|
+
} finally {
|
|
76
|
+
if (alive) setPending(false);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return { submit, pending, result, error };
|
|
81
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useOptimistic — show a pending value while an action/server call
|
|
3
|
+
* is in flight; falls back to the committed value on settle:
|
|
4
|
+
*
|
|
5
|
+
* const { value, pending, optimistic } = useOptimistic(() => count());
|
|
6
|
+
* // in a submit handler:
|
|
7
|
+
* await optimistic(count() + 1, () => save(count() + 1));
|
|
8
|
+
*
|
|
9
|
+
* `value()` returns the optimistic value while pending, the committed
|
|
10
|
+
* value otherwise.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { type Accessor, createSignal } from "solid-js";
|
|
14
|
+
|
|
15
|
+
export interface Optimistic<T> {
|
|
16
|
+
/** Committed or optimistic value */
|
|
17
|
+
value: Accessor<T>;
|
|
18
|
+
pending: Accessor<boolean>;
|
|
19
|
+
/** Rejection from the last commit — cleared on the next optimistic call */
|
|
20
|
+
error: Accessor<unknown>;
|
|
21
|
+
/**
|
|
22
|
+
* Apply `next` optimistically, run `commit`, then clear — the
|
|
23
|
+
* committed source is expected to update during/after commit; a
|
|
24
|
+
* rejected commit is exposed via `error` (the error is swallowed)
|
|
25
|
+
*/
|
|
26
|
+
optimistic: (next: T, commit: () => Promise<unknown>) => Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const useOptimistic = <T>(committed: Accessor<T>): Optimistic<T> => {
|
|
30
|
+
const [pending, setPending] = createSignal(false);
|
|
31
|
+
const [error, setError] = createSignal<unknown>();
|
|
32
|
+
const [optimisticValue, setOptimisticValue] = createSignal<T>();
|
|
33
|
+
return {
|
|
34
|
+
value: () => (pending() ? (optimisticValue() as T) : committed()),
|
|
35
|
+
pending,
|
|
36
|
+
error,
|
|
37
|
+
optimistic: async (next, commit) => {
|
|
38
|
+
setOptimisticValue(() => next);
|
|
39
|
+
setPending(true);
|
|
40
|
+
setError(undefined);
|
|
41
|
+
try {
|
|
42
|
+
await commit();
|
|
43
|
+
} catch (e) {
|
|
44
|
+
setError(() => e);
|
|
45
|
+
} finally {
|
|
46
|
+
setPending(false);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* usePreloadRoute — preload a route's module (and `/_server/loader`
|
|
3
|
+
* data on the client) on pointer intent. Returns props to spread on
|
|
4
|
+
* a link or an imperative `preload()`:
|
|
5
|
+
*
|
|
6
|
+
* const preload = usePreloadRoute("/blog");
|
|
7
|
+
* <a {...preload.props} href="/blog">…</a>
|
|
8
|
+
* preload.now();
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { usePrefetch } from "./Link";
|
|
12
|
+
|
|
13
|
+
export interface PreloadRoute {
|
|
14
|
+
/** Props for hover/focus intent prefetching */
|
|
15
|
+
props: { onPointerEnter: () => void; onFocus: () => void };
|
|
16
|
+
/** Preload immediately */
|
|
17
|
+
now: () => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const usePreloadRoute = (path: string): PreloadRoute => {
|
|
21
|
+
const prefetch = usePrefetch();
|
|
22
|
+
let done = false;
|
|
23
|
+
const run = () => {
|
|
24
|
+
if (done) return;
|
|
25
|
+
done = true;
|
|
26
|
+
prefetch?.(path);
|
|
27
|
+
// Warm the loader endpoint too — renders are instant on nav
|
|
28
|
+
if (typeof fetch !== "undefined") {
|
|
29
|
+
void fetch(`/_server/loader?path=${encodeURIComponent(path)}`).catch(
|
|
30
|
+
() => {},
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
props: { onPointerEnter: run, onFocus: run },
|
|
36
|
+
now: run,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `useRoute()` — the one route hook. Replaces the useParams/useLoaderData/
|
|
3
|
+
* useNavigate/useSearchParams/useRequestState/useLoaderRetry set with a
|
|
4
|
+
* single accessor object:
|
|
5
|
+
*
|
|
6
|
+
* const r = useRoute<User>();
|
|
7
|
+
* r.data()?.name // loader data
|
|
8
|
+
* r.params.id // route params
|
|
9
|
+
* r.search.page // search params
|
|
10
|
+
* r.state("user") // middleware/request state bag
|
|
11
|
+
* r.retry() // re-run loader after error
|
|
12
|
+
* r.navigate("/x") // client nav
|
|
13
|
+
* r.path // current pathname
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
type Accessor,
|
|
18
|
+
createEffect,
|
|
19
|
+
createRoot,
|
|
20
|
+
on,
|
|
21
|
+
useContext,
|
|
22
|
+
} from "solid-js";
|
|
23
|
+
import type { LeafMapped } from "../domain/operations/defer";
|
|
24
|
+
import {
|
|
25
|
+
link,
|
|
26
|
+
type ParamsFor,
|
|
27
|
+
type RoutePath,
|
|
28
|
+
type SearchFor,
|
|
29
|
+
} from "../domain/operations/typed";
|
|
30
|
+
import { type DevEvent, navEvents } from "./dev-events";
|
|
31
|
+
import { PrefetchContext } from "./Link";
|
|
32
|
+
import { clearLoaderCache } from "./loader-cache";
|
|
33
|
+
import { useLoaderRetry, useRouteData } from "./loader-data";
|
|
34
|
+
import {
|
|
35
|
+
type AppLocation,
|
|
36
|
+
useLocation,
|
|
37
|
+
useNavigate,
|
|
38
|
+
useParams,
|
|
39
|
+
useRequestState,
|
|
40
|
+
useSearchParams,
|
|
41
|
+
} from "./location";
|
|
42
|
+
import { RouteActionsContext, RouteMetaContext } from "./route-contexts";
|
|
43
|
+
import { useAction } from "./use-action";
|
|
44
|
+
|
|
45
|
+
export interface UseRoute<
|
|
46
|
+
D = unknown,
|
|
47
|
+
P = Record<string, string>,
|
|
48
|
+
S = Record<string, unknown>,
|
|
49
|
+
Q = Record<string, string>,
|
|
50
|
+
> {
|
|
51
|
+
/** Loader data accessor — `r.data()` reactive (deferred leaves resolved) */
|
|
52
|
+
data: Accessor<LeafMapped<D> | undefined>;
|
|
53
|
+
/** Route params — `r.params.id` */
|
|
54
|
+
params: P;
|
|
55
|
+
/** Search/query — `r.search.page`; typed via `page({ search })` */
|
|
56
|
+
search: Q;
|
|
57
|
+
/** Middleware/request state bag — `r.state.user` */
|
|
58
|
+
state: S;
|
|
59
|
+
/** Current pathname */
|
|
60
|
+
path: string;
|
|
61
|
+
location: AppLocation;
|
|
62
|
+
navigate: ReturnType<typeof useNavigate>;
|
|
63
|
+
/** Re-run the loader (after an error boundary) */
|
|
64
|
+
retry: (() => void) | undefined;
|
|
65
|
+
/** Warm a route's module + loader ahead of navigation */
|
|
66
|
+
preload: (path: string) => void;
|
|
67
|
+
/** Route metadata from `page({ meta })` */
|
|
68
|
+
meta: Record<string, unknown>;
|
|
69
|
+
/** Call a named `page({ actions })` entry — `r.submit("save", {x:1})` */
|
|
70
|
+
submit: (
|
|
71
|
+
name: string,
|
|
72
|
+
fields?: Record<string, unknown> | FormData,
|
|
73
|
+
) => Promise<unknown>;
|
|
74
|
+
/** Serializable {path, params, search, data} — share/debug */
|
|
75
|
+
snapshot: () => {
|
|
76
|
+
path: string;
|
|
77
|
+
params: unknown;
|
|
78
|
+
search: unknown;
|
|
79
|
+
data: unknown;
|
|
80
|
+
};
|
|
81
|
+
/** Clear loader cache then re-run the loader chain */
|
|
82
|
+
revalidate: () => void;
|
|
83
|
+
/** Bump the route version — re-run loaders without cache clear */
|
|
84
|
+
refresh: () => void;
|
|
85
|
+
/** Previous pathname — `r.prev()` for back UX */
|
|
86
|
+
prev: () => string | undefined;
|
|
87
|
+
/** Merge a patch into the current query — `r.searchWith({page: 2})` */
|
|
88
|
+
searchWith: (patch: Record<string, string | number | boolean>) => string;
|
|
89
|
+
/** Active check — `r.is("/users")` or prefix match `r.is("/users", true)` */
|
|
90
|
+
is: (path: string, prefix?: boolean) => boolean;
|
|
91
|
+
/** Current full path + query — for "copy link" UI */
|
|
92
|
+
share: () => string;
|
|
93
|
+
/** Reactive parsed query record — `r.query().page` */
|
|
94
|
+
query: Accessor<Record<string, string>>;
|
|
95
|
+
/** Back navigation — goes to `prev()` or `fallback` */
|
|
96
|
+
back: (fallback?: string) => void;
|
|
97
|
+
/** Shallow state — modal/drawer state in the history entry */
|
|
98
|
+
historyState: Accessor<Record<string, unknown>>;
|
|
99
|
+
pushState: (url: string, state: Record<string, unknown>) => void;
|
|
100
|
+
replaceState: (state: Record<string, unknown>) => void;
|
|
101
|
+
/** Single typed param accessor — `r.param("id")` */
|
|
102
|
+
param: <K extends keyof P>(name: K) => string | undefined;
|
|
103
|
+
/** Resolves once on the next location change — nav/redirect awaits */
|
|
104
|
+
wait: () => Promise<void>;
|
|
105
|
+
/** Runs `cb` once when the location changes away — form/draft cleanup */
|
|
106
|
+
onLeave: (cb: () => void) => void;
|
|
107
|
+
/** True while a navigation is being applied — loading bars */
|
|
108
|
+
navigating: Accessor<boolean>;
|
|
109
|
+
/**
|
|
110
|
+
* Typed href — `r.to("/users/[id]", { id: "1" }, { tab: "t" })`
|
|
111
|
+
* (same resolution as `link()`; literal-checked when
|
|
112
|
+
* `.solid/routes.d.ts` is generated)
|
|
113
|
+
*/
|
|
114
|
+
to: <R extends RoutePath>(
|
|
115
|
+
path: R,
|
|
116
|
+
params?: ParamsFor<R>,
|
|
117
|
+
search?: SearchFor<R>,
|
|
118
|
+
) => string;
|
|
119
|
+
/**
|
|
120
|
+
* AbortSignal aborted when the route unloads — pass to `fetch`
|
|
121
|
+
* and listeners so they cancel on navigation
|
|
122
|
+
*/
|
|
123
|
+
signal: AbortSignal;
|
|
124
|
+
/** Named `page({ actions })` keys — for rendering submit buttons */
|
|
125
|
+
actions: string[];
|
|
126
|
+
/** Reactive navigate-type dev events — history/debug UI */
|
|
127
|
+
navEvents: Accessor<DevEvent[]>;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const useRoute = <
|
|
131
|
+
D = unknown,
|
|
132
|
+
P extends string | Record<string, string> = Record<string, string>,
|
|
133
|
+
S extends Record<string, unknown> = Record<string, unknown>,
|
|
134
|
+
Q = Record<string, string>,
|
|
135
|
+
>(): UseRoute<D, P extends string ? never : P, S, Q> => {
|
|
136
|
+
const data = useRouteData<D>();
|
|
137
|
+
const params = useParams<P>() as P extends string ? never : P;
|
|
138
|
+
const search = useSearchParams<Q>();
|
|
139
|
+
const state = useRequestState() as S;
|
|
140
|
+
const location = useLocation();
|
|
141
|
+
const navigate = useNavigate();
|
|
142
|
+
const retry = useLoaderRetry();
|
|
143
|
+
const prefetch = useContext(PrefetchContext);
|
|
144
|
+
const meta = useContext(RouteMetaContext);
|
|
145
|
+
const actionNames = useContext(RouteActionsContext);
|
|
146
|
+
const action = useAction();
|
|
147
|
+
// Aborted when the location changes away — caller passes it to
|
|
148
|
+
// fetch()/listeners for automatic cleanup
|
|
149
|
+
const signalCtl = new AbortController();
|
|
150
|
+
createRoot((dispose) => {
|
|
151
|
+
createEffect(
|
|
152
|
+
on(
|
|
153
|
+
() => `${location.pathname()}${location.search()}`,
|
|
154
|
+
() => {
|
|
155
|
+
dispose();
|
|
156
|
+
signalCtl.abort();
|
|
157
|
+
},
|
|
158
|
+
{ defer: true },
|
|
159
|
+
),
|
|
160
|
+
);
|
|
161
|
+
});
|
|
162
|
+
return {
|
|
163
|
+
data,
|
|
164
|
+
params,
|
|
165
|
+
search,
|
|
166
|
+
state,
|
|
167
|
+
get path() {
|
|
168
|
+
return location.pathname();
|
|
169
|
+
},
|
|
170
|
+
location,
|
|
171
|
+
navigate,
|
|
172
|
+
retry,
|
|
173
|
+
preload: (path: string) => prefetch?.(path),
|
|
174
|
+
meta,
|
|
175
|
+
submit: (name: string, fields?: Record<string, unknown> | FormData) => {
|
|
176
|
+
const form = fields instanceof FormData ? fields : new FormData();
|
|
177
|
+
if (!(fields instanceof FormData) && fields) {
|
|
178
|
+
for (const [k, v] of Object.entries(fields)) {
|
|
179
|
+
form.set(k, String(v));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
form.set("__action", name);
|
|
183
|
+
return action.submit(form);
|
|
184
|
+
},
|
|
185
|
+
snapshot: () => ({
|
|
186
|
+
path: location.pathname(),
|
|
187
|
+
params,
|
|
188
|
+
search,
|
|
189
|
+
data: data(),
|
|
190
|
+
}),
|
|
191
|
+
revalidate: () => {
|
|
192
|
+
clearLoaderCache();
|
|
193
|
+
(retry ?? location.refresh)();
|
|
194
|
+
},
|
|
195
|
+
refresh: location.refresh,
|
|
196
|
+
prev: () => location.prev(),
|
|
197
|
+
searchWith: (patch) => {
|
|
198
|
+
const q = new URLSearchParams(location.search());
|
|
199
|
+
for (const [k, v] of Object.entries(patch)) q.set(k, String(v));
|
|
200
|
+
return `${location.pathname()}?${q}`;
|
|
201
|
+
},
|
|
202
|
+
is: (path, prefix) =>
|
|
203
|
+
prefix
|
|
204
|
+
? location.pathname().startsWith(path)
|
|
205
|
+
: location.pathname() === path,
|
|
206
|
+
share: () => `${location.pathname()}${location.search()}`,
|
|
207
|
+
query: () =>
|
|
208
|
+
Object.fromEntries(new URLSearchParams(location.search()).entries()),
|
|
209
|
+
back: (fallback = "/") =>
|
|
210
|
+
location.navigate(location.prev() ?? fallback, { replace: true }),
|
|
211
|
+
historyState: location.state,
|
|
212
|
+
pushState: location.pushState,
|
|
213
|
+
replaceState: location.replaceState,
|
|
214
|
+
param: (name) => (params as Record<string, string>)[name as string],
|
|
215
|
+
navigating: location.navigating,
|
|
216
|
+
onLeave: (cb) => {
|
|
217
|
+
createRoot((dispose) => {
|
|
218
|
+
createEffect(
|
|
219
|
+
on(
|
|
220
|
+
() => `${location.pathname()}${location.search()}`,
|
|
221
|
+
() => {
|
|
222
|
+
dispose();
|
|
223
|
+
cb();
|
|
224
|
+
},
|
|
225
|
+
{ defer: true },
|
|
226
|
+
),
|
|
227
|
+
);
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
to: (path, p, q) => link(path, p, q),
|
|
231
|
+
get signal() {
|
|
232
|
+
return signalCtl.signal;
|
|
233
|
+
},
|
|
234
|
+
get actions() {
|
|
235
|
+
return actionNames;
|
|
236
|
+
},
|
|
237
|
+
navEvents,
|
|
238
|
+
wait: () =>
|
|
239
|
+
new Promise<void>((resolve) => {
|
|
240
|
+
createRoot((dispose) => {
|
|
241
|
+
createEffect(
|
|
242
|
+
on(
|
|
243
|
+
() => `${location.pathname()}${location.search()}`,
|
|
244
|
+
() => {
|
|
245
|
+
dispose();
|
|
246
|
+
resolve();
|
|
247
|
+
},
|
|
248
|
+
{ defer: true },
|
|
249
|
+
),
|
|
250
|
+
);
|
|
251
|
+
});
|
|
252
|
+
}),
|
|
253
|
+
};
|
|
254
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flash — one-time message across a redirect (toast pattern):
|
|
3
|
+
*
|
|
4
|
+
* // in an action, before redirecting:
|
|
5
|
+
* const res = redirect("/dashboard");
|
|
6
|
+
* setFlash(res.headers, { kind: "success", text: "Saved" });
|
|
7
|
+
* return res;
|
|
8
|
+
*
|
|
9
|
+
* // in the target page loader:
|
|
10
|
+
* const flash = readFlash(ctx.request, ctx.headers?); → {kind,text}
|
|
11
|
+
* // and in components:
|
|
12
|
+
* const flash = useFlash();
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { useRouteState } from "#app/modules/file-routes/presentation/location";
|
|
16
|
+
import type { AppMiddleware } from "#app/types";
|
|
17
|
+
import {
|
|
18
|
+
deleteCookie,
|
|
19
|
+
getCookie,
|
|
20
|
+
setCookie,
|
|
21
|
+
} from "#server/modules/http/domain/operations/cookies";
|
|
22
|
+
|
|
23
|
+
export const FLASH_COOKIE = "__flash";
|
|
24
|
+
|
|
25
|
+
/** Queue a one-time flash payload on a (redirect) response */
|
|
26
|
+
export const setFlash = (headers: Headers, data: unknown): void => {
|
|
27
|
+
setCookie(headers, FLASH_COOKIE, encodeURIComponent(JSON.stringify(data)), {
|
|
28
|
+
httpOnly: true,
|
|
29
|
+
sameSite: "lax",
|
|
30
|
+
path: "/",
|
|
31
|
+
// short-lived — it should be consumed on the next request
|
|
32
|
+
maxAge: 60,
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Read + clear the flash for this request — `headers` (the response)
|
|
38
|
+
* gets a Max-Age=0 so the cookie self-destructs after being read
|
|
39
|
+
*/
|
|
40
|
+
export const readFlash = <T = unknown>(
|
|
41
|
+
request: Request,
|
|
42
|
+
responseHeaders?: Headers,
|
|
43
|
+
): T | null => {
|
|
44
|
+
const raw = getCookie(request, FLASH_COOKIE);
|
|
45
|
+
if (raw === undefined) return null;
|
|
46
|
+
if (responseHeaders)
|
|
47
|
+
deleteCookie(responseHeaders, FLASH_COOKIE, { path: "/" });
|
|
48
|
+
try {
|
|
49
|
+
return JSON.parse(decodeURIComponent(raw)) as T;
|
|
50
|
+
} catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Middleware — moves the flash cookie into `state.flash` (serialized
|
|
57
|
+
* into the hydration payload, so components can read it). The cookie
|
|
58
|
+
* is short-lived (60s) so it self-expires after one navigation
|
|
59
|
+
*/
|
|
60
|
+
export const flashMiddleware = (): AppMiddleware => {
|
|
61
|
+
return async (ctx) => {
|
|
62
|
+
const value = readFlash(ctx.request);
|
|
63
|
+
if (value !== null) ctx.state.flash = value;
|
|
64
|
+
return undefined;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/** Read the flashed payload in components — from route state/hydration */
|
|
69
|
+
export const useFlash = <T = unknown>(): T | null =>
|
|
70
|
+
(useRouteState<{ flash?: T | null }>().flash ?? null) as T | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./domain/operations/flash";
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fonts — `defineFont()` produces head tags for self-hosted or
|
|
3
|
+
* Google fonts: preload link + stylesheet link + @font-face style.
|
|
4
|
+
*
|
|
5
|
+
* const inter = defineFont({
|
|
6
|
+
* family: "Inter",
|
|
7
|
+
* src: "/fonts/inter.woff2", // self-hosted
|
|
8
|
+
* weight: "400 700",
|
|
9
|
+
* });
|
|
10
|
+
* const gfont = defineFont({
|
|
11
|
+
* google: { family: "Inter", weights: [400, 700] },
|
|
12
|
+
* });
|
|
13
|
+
* useHead(...inter.head);
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { createHeadTag, linkTag } from "#head/modules/head/domain";
|
|
17
|
+
|
|
18
|
+
export interface FontDef {
|
|
19
|
+
/** Self-hosted: font file URL(s) under public/ */
|
|
20
|
+
src?: string | string[];
|
|
21
|
+
/** Google Fonts shortcut — generates css2 link, no self-host */
|
|
22
|
+
google?: { family: string; weights?: number[]; display?: string };
|
|
23
|
+
/** Family name (required with src; optional override for google) */
|
|
24
|
+
family?: string;
|
|
25
|
+
weight?: string | number;
|
|
26
|
+
style?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface DefinedFont {
|
|
30
|
+
/** CSS family name to reference in stylesheets */
|
|
31
|
+
family: string;
|
|
32
|
+
/** HeadTag[] — spread into useHead() */
|
|
33
|
+
head: ReturnType<typeof createHeadTag>[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const defineFont = (def: FontDef): DefinedFont => {
|
|
37
|
+
const family = def.family ?? def.google?.family ?? "sans";
|
|
38
|
+
const head: DefinedFont["head"] = [];
|
|
39
|
+
|
|
40
|
+
if (def.google) {
|
|
41
|
+
const weights = (def.google.weights ?? [400]).sort().join(";");
|
|
42
|
+
const display = def.google.display ?? "swap";
|
|
43
|
+
head.push(
|
|
44
|
+
linkTag({ rel: "preconnect", href: "https://fonts.googleapis.com" }),
|
|
45
|
+
createHeadTag("link", {
|
|
46
|
+
rel: "preconnect",
|
|
47
|
+
href: "https://fonts.gstatic.com",
|
|
48
|
+
crossorigin: "anonymous",
|
|
49
|
+
}),
|
|
50
|
+
linkTag({
|
|
51
|
+
rel: "stylesheet",
|
|
52
|
+
href: `https://fonts.googleapis.com/css2?family=${encodeURIComponent(def.google.family)}:wght@${weights}&display=${display}`,
|
|
53
|
+
}),
|
|
54
|
+
);
|
|
55
|
+
return { family, head };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const files = [def.src ?? []].flat();
|
|
59
|
+
for (const src of files) {
|
|
60
|
+
head.push(
|
|
61
|
+
createHeadTag("link", {
|
|
62
|
+
rel: "preload",
|
|
63
|
+
href: src,
|
|
64
|
+
as: "font",
|
|
65
|
+
type: `font/${src.split(".").pop()}`,
|
|
66
|
+
crossorigin: "anonymous",
|
|
67
|
+
}),
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
head.push(
|
|
71
|
+
createHeadTag(
|
|
72
|
+
"style",
|
|
73
|
+
{},
|
|
74
|
+
files
|
|
75
|
+
.map(
|
|
76
|
+
(src) =>
|
|
77
|
+
`@font-face{font-family:"${family}";src:url("${src}") format("${
|
|
78
|
+
src.endsWith("woff2")
|
|
79
|
+
? "woff2"
|
|
80
|
+
: src.endsWith("woff")
|
|
81
|
+
? "woff"
|
|
82
|
+
: "truetype"
|
|
83
|
+
}");${def.weight !== undefined ? `font-weight:${def.weight};` : ""}${
|
|
84
|
+
def.style ? `font-style:${def.style};` : ""
|
|
85
|
+
}font-display:swap;}`,
|
|
86
|
+
)
|
|
87
|
+
.join("\n"),
|
|
88
|
+
),
|
|
89
|
+
);
|
|
90
|
+
return { family, head };
|
|
91
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./domain/operations/font";
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* i18n Middleware
|
|
3
|
+
* Detects the request locale → state.locale: path prefix first,
|
|
4
|
+
* then Accept-Language, then the default. With `redirect: true`
|
|
5
|
+
* unprefixed non-default hits 302 to the localized path (the
|
|
6
|
+
* nuxt-i18n detectBrowserLanguage equivalent):
|
|
7
|
+
*
|
|
8
|
+
* middleware: [i18nMiddleware({ locales: ["en","th"], defaultLocale: "en" })]
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { AppMiddleware } from "#app/types";
|
|
12
|
+
import type { I18nConfig } from "./locale";
|
|
13
|
+
import { stripLocale } from "./locale";
|
|
14
|
+
|
|
15
|
+
export interface I18nMiddlewareOptions extends I18nConfig {
|
|
16
|
+
/** Redirect unprefixed urls to the detected locale — default false */
|
|
17
|
+
redirect?: boolean;
|
|
18
|
+
/** Cookie persisting the user's choice — read before Accept-Language */
|
|
19
|
+
cookie?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const fromAcceptLanguage = (
|
|
23
|
+
header: string,
|
|
24
|
+
locales: string[],
|
|
25
|
+
): string | undefined => {
|
|
26
|
+
for (const part of header.split(",")) {
|
|
27
|
+
const tag = part.split(";")[0].trim().toLowerCase();
|
|
28
|
+
const base = tag.split("-")[0];
|
|
29
|
+
const hit = locales.find(
|
|
30
|
+
(l) => l.toLowerCase() === tag || l.toLowerCase() === base,
|
|
31
|
+
);
|
|
32
|
+
if (hit) return hit;
|
|
33
|
+
}
|
|
34
|
+
return undefined;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const i18nMiddleware = (
|
|
38
|
+
options: I18nMiddlewareOptions,
|
|
39
|
+
): AppMiddleware => {
|
|
40
|
+
const locales = options.locales.map((l) => l.toLowerCase());
|
|
41
|
+
return async (ctx) => {
|
|
42
|
+
const path = stripLocale(ctx.url.pathname, options);
|
|
43
|
+
// Explicit prefix wins
|
|
44
|
+
let locale = path.locale;
|
|
45
|
+
if (
|
|
46
|
+
path.locale === options.defaultLocale &&
|
|
47
|
+
path.path === ctx.url.pathname
|
|
48
|
+
) {
|
|
49
|
+
// No prefix — cookie → Accept-Language → default
|
|
50
|
+
const cookie = options.cookie
|
|
51
|
+
? ctx.request.headers
|
|
52
|
+
.get("cookie")
|
|
53
|
+
?.match(new RegExp(`${options.cookie}=([^;]+)`))?.[1]
|
|
54
|
+
: undefined;
|
|
55
|
+
locale =
|
|
56
|
+
(cookie && locales.includes(cookie.toLowerCase())
|
|
57
|
+
? cookie
|
|
58
|
+
: undefined) ??
|
|
59
|
+
fromAcceptLanguage(
|
|
60
|
+
ctx.request.headers.get("accept-language") ?? "",
|
|
61
|
+
options.locales,
|
|
62
|
+
) ??
|
|
63
|
+
options.defaultLocale;
|
|
64
|
+
if (options.redirect && locale !== options.defaultLocale) {
|
|
65
|
+
return new Response(null, {
|
|
66
|
+
status: 302,
|
|
67
|
+
headers: {
|
|
68
|
+
Location: `/${locale}${ctx.url.pathname === "/" ? "" : ctx.url.pathname}${ctx.url.search}`,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
ctx.state.locale = locale;
|
|
74
|
+
return undefined;
|
|
75
|
+
};
|
|
76
|
+
};
|