@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,65 @@
|
|
|
1
|
+
export {
|
|
2
|
+
createRouteActionHandler,
|
|
3
|
+
type RouteActionContext,
|
|
4
|
+
type RouteActionFn,
|
|
5
|
+
} from "./actions";
|
|
6
|
+
export {
|
|
7
|
+
type ApiRouteContext,
|
|
8
|
+
type ApiRouteHandler,
|
|
9
|
+
type ApiRouteModule,
|
|
10
|
+
type ApiRouteModules,
|
|
11
|
+
createApiRouteHandler,
|
|
12
|
+
} from "./api";
|
|
13
|
+
export { generateApiTypes, generateRouteTypes } from "./codegen";
|
|
14
|
+
export { contentMeta, renderMarkdown } from "./content";
|
|
15
|
+
export {
|
|
16
|
+
DEFER_MARKER,
|
|
17
|
+
DEFERRED,
|
|
18
|
+
type DeferOptions,
|
|
19
|
+
type Deferred,
|
|
20
|
+
defer,
|
|
21
|
+
deferAll,
|
|
22
|
+
deferMarkerKey,
|
|
23
|
+
deferResolveScript,
|
|
24
|
+
deferredRegistry,
|
|
25
|
+
extractDeferred,
|
|
26
|
+
isDeferred,
|
|
27
|
+
type LeafMapped,
|
|
28
|
+
materializeDeferred,
|
|
29
|
+
orderDeferred,
|
|
30
|
+
readDeferredRegistry,
|
|
31
|
+
resolveDeferred,
|
|
32
|
+
} from "./defer";
|
|
33
|
+
export {
|
|
34
|
+
createLoaderHandler,
|
|
35
|
+
isLoaderRequest,
|
|
36
|
+
LOADER_ENDPOINT,
|
|
37
|
+
type LoaderContext,
|
|
38
|
+
type PageModuleWithLoader,
|
|
39
|
+
type RouteLoaderFn,
|
|
40
|
+
runFileRouteLoader,
|
|
41
|
+
} from "./loader";
|
|
42
|
+
export { buildRouteManifest } from "./manifest";
|
|
43
|
+
export { matchAllFileRoutes, matchFileRoute, routePaths } from "./match";
|
|
44
|
+
export {
|
|
45
|
+
expandStaticRoutes,
|
|
46
|
+
type GenerateStaticParamsFn,
|
|
47
|
+
} from "./static-params";
|
|
48
|
+
export type {
|
|
49
|
+
ExtractParams,
|
|
50
|
+
GeneratedRoutes,
|
|
51
|
+
GeneratedSearch,
|
|
52
|
+
HasParams,
|
|
53
|
+
ParamsFor,
|
|
54
|
+
RouteParamsFor,
|
|
55
|
+
RoutePath,
|
|
56
|
+
SearchFor,
|
|
57
|
+
} from "./typed";
|
|
58
|
+
export {
|
|
59
|
+
href,
|
|
60
|
+
link,
|
|
61
|
+
pathFor,
|
|
62
|
+
relativePath,
|
|
63
|
+
route,
|
|
64
|
+
routePattern,
|
|
65
|
+
} from "./typed";
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route Loader Endpoint
|
|
3
|
+
* `/_server/loader?path=/users/42` — runs the matched page module's
|
|
4
|
+
* `loader` export and returns its data as JSON. Used by client-side
|
|
5
|
+
* navigation so loaders re-run without a full page load
|
|
6
|
+
*
|
|
7
|
+
* // src/routes/users/[id].tsx
|
|
8
|
+
* export const loader = async ({ params }) => fetchUser(params.id);
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { useRequestEvent as requestEvent } from "#server/modules/http";
|
|
12
|
+
import { loaderErrorBody } from "../errors";
|
|
13
|
+
import type { RouteManifest } from "../models";
|
|
14
|
+
import type { ApiRouteModules } from "./api";
|
|
15
|
+
import { extractDeferred } from "./defer";
|
|
16
|
+
import { matchFileRoute } from "./match";
|
|
17
|
+
|
|
18
|
+
export const LOADER_ENDPOINT = "/_server/loader";
|
|
19
|
+
|
|
20
|
+
export interface LoaderContext<S = Record<string, unknown>> {
|
|
21
|
+
request: Request;
|
|
22
|
+
params: Record<string, string>;
|
|
23
|
+
/**
|
|
24
|
+
* Parent loader data — when layouts export `loader`, the chain
|
|
25
|
+
* runs outermost→innermost and each receives the previous result
|
|
26
|
+
*/
|
|
27
|
+
parent?: unknown;
|
|
28
|
+
/** Middleware-written request state — `state.user`, `state.tenant` */
|
|
29
|
+
state: S;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type RouteLoaderFn = (ctx: LoaderContext) => unknown | Promise<unknown>;
|
|
33
|
+
|
|
34
|
+
export interface PageModuleWithLoader {
|
|
35
|
+
default?: unknown;
|
|
36
|
+
loader?: RouteLoaderFn;
|
|
37
|
+
/**
|
|
38
|
+
* Guard hook — runs before `loader`; return a Response to
|
|
39
|
+
* short-circuit (redirect, 401) or throw to abort the route
|
|
40
|
+
*/
|
|
41
|
+
beforeLoad?: (ctx: LoaderContext) => unknown | Response | Promise<unknown>;
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const isLoaderRequest = (request: Request): boolean =>
|
|
46
|
+
new URL(request.url).pathname === LOADER_ENDPOINT;
|
|
47
|
+
|
|
48
|
+
const loadModule = async (
|
|
49
|
+
modules: ApiRouteModules,
|
|
50
|
+
file: string,
|
|
51
|
+
): Promise<PageModuleWithLoader | undefined> => {
|
|
52
|
+
const entry = modules[file] ?? modules[`/${file}`];
|
|
53
|
+
if (!entry) return undefined;
|
|
54
|
+
return (await Promise.resolve(
|
|
55
|
+
typeof entry === "function" ? entry() : entry,
|
|
56
|
+
)) as PageModuleWithLoader;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Run the loader chain for a matched route — layout loaders run
|
|
61
|
+
* outermost→innermost first and each receives the previous result as
|
|
62
|
+
* `ctx.parent`; the page loader runs last and its result is returned
|
|
63
|
+
*/
|
|
64
|
+
export const runFileRouteLoader = async (
|
|
65
|
+
path: string,
|
|
66
|
+
manifest: RouteManifest,
|
|
67
|
+
modules: ApiRouteModules,
|
|
68
|
+
request: Request,
|
|
69
|
+
): Promise<unknown> => {
|
|
70
|
+
const pages = manifest.filter((r) => r.kind !== "api");
|
|
71
|
+
const match = matchFileRoute(path, pages);
|
|
72
|
+
if (!match) return undefined;
|
|
73
|
+
|
|
74
|
+
let parent: unknown;
|
|
75
|
+
const state = requestEvent()?.state ?? {};
|
|
76
|
+
for (const file of [...match.route.layouts, match.route.file]) {
|
|
77
|
+
const mod = await loadModule(modules, file);
|
|
78
|
+
if (!mod) continue;
|
|
79
|
+
if (mod.beforeLoad) {
|
|
80
|
+
const verdict = await mod.beforeLoad({
|
|
81
|
+
request,
|
|
82
|
+
params: match.params,
|
|
83
|
+
parent,
|
|
84
|
+
state,
|
|
85
|
+
});
|
|
86
|
+
if (verdict instanceof Response) throw verdict;
|
|
87
|
+
}
|
|
88
|
+
if (mod.loader) {
|
|
89
|
+
parent = await mod.loader({
|
|
90
|
+
request,
|
|
91
|
+
params: match.params,
|
|
92
|
+
parent,
|
|
93
|
+
state,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return parent;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const createLoaderHandler = (
|
|
101
|
+
manifest: RouteManifest,
|
|
102
|
+
modules: ApiRouteModules,
|
|
103
|
+
): ((request: Request) => Promise<Response>) => {
|
|
104
|
+
const pages = manifest.filter((r) => r.kind !== "api");
|
|
105
|
+
|
|
106
|
+
return async (request: Request): Promise<Response> => {
|
|
107
|
+
const url = new URL(request.url);
|
|
108
|
+
const path = url.searchParams.get("path") ?? "/";
|
|
109
|
+
const match = matchFileRoute(path, pages);
|
|
110
|
+
if (!match) {
|
|
111
|
+
return Response.json(
|
|
112
|
+
{ error: { code: "NOT_FOUND", message: `No route: ${path}` } },
|
|
113
|
+
{ status: 404 },
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Layout → page loader chain; a beforeLoad verdict short-circuits
|
|
118
|
+
try {
|
|
119
|
+
const data = await runFileRouteLoader(path, manifest, modules, request);
|
|
120
|
+
// Deferred leaves → markers + resolved values in `deferred`
|
|
121
|
+
const registry = new Map<string, Promise<unknown>>();
|
|
122
|
+
const marked = extractDeferred(data, registry);
|
|
123
|
+
const deferred: Record<string, unknown> = {};
|
|
124
|
+
for (const [k, p] of registry) deferred[k] = await p;
|
|
125
|
+
return Response.json({
|
|
126
|
+
data: marked ?? null,
|
|
127
|
+
...(Object.keys(deferred).length > 0 ? { deferred } : {}),
|
|
128
|
+
});
|
|
129
|
+
} catch (error) {
|
|
130
|
+
if (error instanceof Response) return error;
|
|
131
|
+
const body = loaderErrorBody(error);
|
|
132
|
+
return Response.json(
|
|
133
|
+
{ error: body },
|
|
134
|
+
{ status: body.code === "NOT_FOUND" ? 404 : 500 },
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
};
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route Manifest Builder
|
|
3
|
+
* Maps files inside routesDir to route entries using filesystem
|
|
4
|
+
* conventions — SolidStart/Nuxt style:
|
|
5
|
+
*
|
|
6
|
+
* src/routes/index.tsx → /
|
|
7
|
+
* src/routes/about.tsx → /about
|
|
8
|
+
* src/routes/users/[id].tsx → /users/:id
|
|
9
|
+
* src/routes/blog/[...slug].tsx → /blog/*slug (catch-all)
|
|
10
|
+
* src/routes/(mkt)/home.tsx → /home (pathless group)
|
|
11
|
+
* src/routes/users/[id]/edit.tsx → /users/:id/edit
|
|
12
|
+
*
|
|
13
|
+
* Non-route files: layout.tsx, error.tsx, loading.tsx, not-found.tsx,
|
|
14
|
+
* and anything starting with "_" or inside "_" directories.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { FileRoute, RouteManifest } from "../models";
|
|
18
|
+
|
|
19
|
+
const MODULE_EXT = /\.(tsx|ts|jsx|js|md|mdx)$/;
|
|
20
|
+
const CONTENT_EXT = /\.(md|mdx)$/;
|
|
21
|
+
const CATCH_ALL = /^\[\.\.\.(.+)\]$/;
|
|
22
|
+
const PARAM = /^\[(.+)\]$/;
|
|
23
|
+
const GROUP = /^\(.+\)$/;
|
|
24
|
+
const INTERCEPT = /^\(\.+\)(.+)$/;
|
|
25
|
+
const SLOT = /^@(.+)$/;
|
|
26
|
+
const PRIVATE = /^_/;
|
|
27
|
+
|
|
28
|
+
const CONVENTION_NAMES = new Set([
|
|
29
|
+
"layout",
|
|
30
|
+
"error",
|
|
31
|
+
"loading",
|
|
32
|
+
"not-found",
|
|
33
|
+
"middleware",
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
const normalize = (file: string): string => file.replace(/\\/g, "/");
|
|
37
|
+
|
|
38
|
+
const stripExt = (file: string): string => file.replace(MODULE_EXT, "");
|
|
39
|
+
|
|
40
|
+
const splitSegments = (relative: string): string[] =>
|
|
41
|
+
stripExt(normalize(relative)).split("/");
|
|
42
|
+
|
|
43
|
+
interface Segment {
|
|
44
|
+
/** url segment text, or param name when dynamic */
|
|
45
|
+
text: string;
|
|
46
|
+
kind: "static" | "param" | "splat";
|
|
47
|
+
/** group segments contribute no url text but can hold conventions */
|
|
48
|
+
group: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const parseSegment = (raw: string): Segment => {
|
|
52
|
+
// `(.)name` — intercepted route: contributes url text like a plain
|
|
53
|
+
// segment; the route is flagged intercepted for modal rendering
|
|
54
|
+
const intercepted = raw.match(INTERCEPT);
|
|
55
|
+
if (intercepted) {
|
|
56
|
+
return { text: intercepted[1] ?? raw, kind: "static", group: false };
|
|
57
|
+
}
|
|
58
|
+
// `@slot` — parallel-route dir: no url text (like a group) but the
|
|
59
|
+
// route records its slot name
|
|
60
|
+
if (SLOT.test(raw)) return { text: raw, kind: "static", group: true };
|
|
61
|
+
if (GROUP.test(raw)) return { text: "", kind: "static", group: true };
|
|
62
|
+
const splat = raw.match(CATCH_ALL);
|
|
63
|
+
if (splat) return { text: splat[1] ?? "all", kind: "splat", group: false };
|
|
64
|
+
const param = raw.match(PARAM);
|
|
65
|
+
if (param) return { text: param[1] ?? "", kind: "param", group: false };
|
|
66
|
+
return { text: raw, kind: "static", group: false };
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const API_SUFFIX = ".api";
|
|
70
|
+
|
|
71
|
+
const isRouteFile = (segments: Segment[], fileName: string): boolean => {
|
|
72
|
+
if (CONVENTION_NAMES.has(fileName)) return false;
|
|
73
|
+
return !segments.some((s) => PRIVATE.test(s.text)) && !PRIVATE.test(fileName);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/** Specificity — static beats param beats splat; longer paths tie-break later */
|
|
77
|
+
const scoreRoute = (segments: Segment[]): number =>
|
|
78
|
+
segments.reduce(
|
|
79
|
+
(score, seg) =>
|
|
80
|
+
score * 4 + (seg.kind === "static" ? 3 : seg.kind === "param" ? 2 : 1),
|
|
81
|
+
0,
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const dirSegments = (relative: string): string[] => {
|
|
85
|
+
const segs = normalize(relative).split("/");
|
|
86
|
+
segs.pop();
|
|
87
|
+
return segs;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const ancestorDirs = (relative: string, root: string): string[] => {
|
|
91
|
+
// "users/[id]/edit.tsx" → ["root/users/[id]", "root/users", "root"]
|
|
92
|
+
const dirs = dirSegments(relative);
|
|
93
|
+
const chain: string[] = [];
|
|
94
|
+
for (let i = dirs.length; i >= 0; i--) {
|
|
95
|
+
const dir = dirs.slice(0, i).join("/");
|
|
96
|
+
chain.push(dir ? `${root}/${dir}` : root);
|
|
97
|
+
}
|
|
98
|
+
return chain;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const conventionIndex = (files: string[]): Map<string, Map<string, string>> => {
|
|
102
|
+
// dir → convention name → file
|
|
103
|
+
const index = new Map<string, Map<string, string>>();
|
|
104
|
+
for (const file of files) {
|
|
105
|
+
const rel = normalize(file);
|
|
106
|
+
const name = stripExt(rel.split("/").pop() ?? "");
|
|
107
|
+
if (!CONVENTION_NAMES.has(name)) continue;
|
|
108
|
+
const dir = rel.replace(/\/[^/]*$/, "");
|
|
109
|
+
const entry = index.get(dir) ?? new Map<string, string>();
|
|
110
|
+
entry.set(name, file);
|
|
111
|
+
index.set(dir, entry);
|
|
112
|
+
}
|
|
113
|
+
return index;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const findConvention = (
|
|
117
|
+
index: Map<string, Map<string, string>>,
|
|
118
|
+
ancestors: string[],
|
|
119
|
+
name: string,
|
|
120
|
+
): string | undefined => {
|
|
121
|
+
for (const dir of ancestors) {
|
|
122
|
+
const found = index.get(dir)?.get(name);
|
|
123
|
+
if (found) return found;
|
|
124
|
+
}
|
|
125
|
+
return undefined;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const middlewareChain = (
|
|
129
|
+
index: Map<string, Map<string, string>>,
|
|
130
|
+
ancestors: string[],
|
|
131
|
+
): string[] => {
|
|
132
|
+
// every ancestor's _middleware applies — outermost → innermost
|
|
133
|
+
const chain: string[] = [];
|
|
134
|
+
for (const dir of [...ancestors].reverse()) {
|
|
135
|
+
const mw = index.get(dir)?.get("middleware");
|
|
136
|
+
if (mw) chain.push(mw);
|
|
137
|
+
}
|
|
138
|
+
return chain;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const layoutChain = (
|
|
142
|
+
index: Map<string, Map<string, string>>,
|
|
143
|
+
ancestors: string[],
|
|
144
|
+
): string[] => {
|
|
145
|
+
// ancestors are innermost → outermost; layouts render outermost first
|
|
146
|
+
const chain: string[] = [];
|
|
147
|
+
for (const dir of [...ancestors].reverse()) {
|
|
148
|
+
const layout = index.get(dir)?.get("layout");
|
|
149
|
+
if (layout) chain.push(layout);
|
|
150
|
+
}
|
|
151
|
+
return chain;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export const buildRouteManifest = (
|
|
155
|
+
files: string[],
|
|
156
|
+
routesDir = "src/routes",
|
|
157
|
+
): RouteManifest => {
|
|
158
|
+
const root = normalize(routesDir).replace(/\/$/, "");
|
|
159
|
+
const conventions = conventionIndex(files);
|
|
160
|
+
const routes: RouteManifest = [];
|
|
161
|
+
|
|
162
|
+
for (const file of files) {
|
|
163
|
+
const rel = normalize(file);
|
|
164
|
+
if (!rel.startsWith(`${root}/`)) continue;
|
|
165
|
+
const relPath = rel.slice(root.length + 1);
|
|
166
|
+
const segments = splitSegments(relPath).map(parseSegment);
|
|
167
|
+
const fileName = stripExt(relPath.split("/").pop() ?? "");
|
|
168
|
+
|
|
169
|
+
if (!isRouteFile(segments, fileName)) continue;
|
|
170
|
+
|
|
171
|
+
// "*.api.ts" files are API endpoints — path drops the .api suffix
|
|
172
|
+
const isApi = fileName.endsWith(API_SUFFIX);
|
|
173
|
+
// "*.md" pages render markdown content — `kind: "content"`
|
|
174
|
+
const isContent = CONTENT_EXT.test(rel);
|
|
175
|
+
const routeName = isApi ? fileName.slice(0, -API_SUFFIX.length) : fileName;
|
|
176
|
+
|
|
177
|
+
// "index" or "page" collapses to the directory path
|
|
178
|
+
const urlSegments =
|
|
179
|
+
routeName === "index" || routeName === "page"
|
|
180
|
+
? segments.slice(0, -1)
|
|
181
|
+
: [...segments.slice(0, -1), parseSegment(routeName)];
|
|
182
|
+
|
|
183
|
+
const params: string[] = [];
|
|
184
|
+
const parts: string[] = [];
|
|
185
|
+
for (const seg of urlSegments) {
|
|
186
|
+
if (seg.group) continue;
|
|
187
|
+
if (seg.kind === "param") {
|
|
188
|
+
params.push(seg.text);
|
|
189
|
+
parts.push(`:${seg.text}`);
|
|
190
|
+
} else if (seg.kind === "splat") {
|
|
191
|
+
params.push(seg.text);
|
|
192
|
+
parts.push(`*${seg.text}`);
|
|
193
|
+
} else {
|
|
194
|
+
parts.push(seg.text);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const ancestors = ancestorDirs(relPath, root); // innermost → root
|
|
199
|
+
const rawSegs = splitSegments(relPath);
|
|
200
|
+
const intercepted = rawSegs.some((s) => INTERCEPT.test(s));
|
|
201
|
+
const slotSeg = rawSegs.map((s) => s.match(SLOT)).find(Boolean)?.[1];
|
|
202
|
+
const route: FileRoute = {
|
|
203
|
+
path: `/${parts.join("/")}`.replace(/\/$/, "") || "/",
|
|
204
|
+
file,
|
|
205
|
+
...(intercepted ? { intercepted: true as const } : {}),
|
|
206
|
+
...(slotSeg ? { slot: slotSeg } : {}),
|
|
207
|
+
...(isApi ? { kind: "api" as const } : {}),
|
|
208
|
+
...(isContent ? { kind: "content" as const } : {}),
|
|
209
|
+
// API endpoints serve raw responses — page conventions don't apply
|
|
210
|
+
layouts: isApi ? [] : layoutChain(conventions, ancestors),
|
|
211
|
+
middleware: middlewareChain(conventions, ancestors),
|
|
212
|
+
params,
|
|
213
|
+
score: scoreRoute(urlSegments.filter((s) => !s.group)),
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
if (!isApi) {
|
|
217
|
+
const error = findConvention(conventions, ancestors, "error");
|
|
218
|
+
const loading = findConvention(conventions, ancestors, "loading");
|
|
219
|
+
const notFound = findConvention(conventions, ancestors, "not-found");
|
|
220
|
+
if (error) route.error = error;
|
|
221
|
+
if (loading) route.loading = loading;
|
|
222
|
+
if (notFound) route.notFound = notFound;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
routes.push(route);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return routes.sort((a, b) => b.score - a.score);
|
|
229
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route Matcher
|
|
3
|
+
* Matches a pathname against a FileRoute manifest — static segments
|
|
4
|
+
* must equal, ":param" takes one segment, "*splat" takes the rest
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { FileRoute, FileRouteMatch, RouteManifest } from "../models";
|
|
8
|
+
|
|
9
|
+
const matchRoute = (
|
|
10
|
+
pathname: string,
|
|
11
|
+
route: FileRoute,
|
|
12
|
+
): FileRouteMatch | null => {
|
|
13
|
+
const pattern = route.path.split("/").filter(Boolean);
|
|
14
|
+
const parts = pathname.split("/").filter(Boolean);
|
|
15
|
+
const params: Record<string, string> = {};
|
|
16
|
+
|
|
17
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
18
|
+
const seg = pattern[i];
|
|
19
|
+
if (seg === undefined) return null;
|
|
20
|
+
if (seg.startsWith("*")) {
|
|
21
|
+
params[seg.slice(1)] = parts.slice(i).join("/");
|
|
22
|
+
return { route, params };
|
|
23
|
+
}
|
|
24
|
+
const part = parts[i];
|
|
25
|
+
if (part === undefined) return null;
|
|
26
|
+
if (seg.startsWith(":")) {
|
|
27
|
+
params[seg.slice(1)] = decodeURIComponent(part);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (seg !== part) return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (parts.length !== pattern.length) return null;
|
|
34
|
+
return { route, params };
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Match a pathname to a route — manifest is expected pre-sorted by
|
|
39
|
+
* score (buildRouteManifest does this); falls back to the best match
|
|
40
|
+
*/
|
|
41
|
+
export const matchFileRoute = (
|
|
42
|
+
pathname: string,
|
|
43
|
+
manifest: RouteManifest,
|
|
44
|
+
kind: "page" | "api" = "page",
|
|
45
|
+
): FileRouteMatch | null => {
|
|
46
|
+
const clean = pathname.split("?")[0]?.replace(/\/+$/, "") || "/";
|
|
47
|
+
for (const route of manifest) {
|
|
48
|
+
if ((route.kind ?? "page") !== kind) continue;
|
|
49
|
+
const match = matchRoute(clean, route);
|
|
50
|
+
if (match) return match;
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Match all routes at a pathname — the default page (no slot) plus
|
|
57
|
+
* every `@slot` parallel route that also matches
|
|
58
|
+
*/
|
|
59
|
+
export const matchAllFileRoutes = (
|
|
60
|
+
pathname: string,
|
|
61
|
+
manifest: RouteManifest,
|
|
62
|
+
): FileRouteMatch[] => {
|
|
63
|
+
const clean = pathname.split("?")[0]?.replace(/\/+$/, "") || "/";
|
|
64
|
+
const out: FileRouteMatch[] = [];
|
|
65
|
+
for (const route of manifest) {
|
|
66
|
+
if ((route.kind ?? "page") !== "page") continue;
|
|
67
|
+
const match = matchRoute(clean, route);
|
|
68
|
+
if (match) out.push(match);
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/** Route paths for type generation — literal list used by typed routes */
|
|
74
|
+
export const routePaths = (manifest: RouteManifest): string[] =>
|
|
75
|
+
manifest.map((r) => r.path);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* generateStaticParams
|
|
3
|
+
* Route modules export `generateStaticParams` to enumerate dynamic
|
|
4
|
+
* segments for build-time prerendering (Next.js convention):
|
|
5
|
+
*
|
|
6
|
+
* // src/routes/users/[id].tsx
|
|
7
|
+
* export const generateStaticParams = () => [{ id: "1" }, { id: "2" }];
|
|
8
|
+
*
|
|
9
|
+
* expandStaticRoutes resolves those into concrete paths a prerender
|
|
10
|
+
* pass can visit
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { RouteManifest } from "../models";
|
|
14
|
+
import type { ApiRouteModules } from "./api";
|
|
15
|
+
|
|
16
|
+
export type GenerateStaticParamsFn = () =>
|
|
17
|
+
| Record<string, string>[]
|
|
18
|
+
| Promise<Record<string, string>[]>;
|
|
19
|
+
|
|
20
|
+
const substitute = (pattern: string, params: Record<string, string>) => {
|
|
21
|
+
let path = pattern;
|
|
22
|
+
for (const [key, value] of Object.entries(params)) {
|
|
23
|
+
path = path.replace(`:${key}`, value).replace(`*${key}`, value);
|
|
24
|
+
}
|
|
25
|
+
return path;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Expand route patterns into concrete paths — static segments pass
|
|
30
|
+
* through; param routes enumerate via generateStaticParams
|
|
31
|
+
*/
|
|
32
|
+
export const expandStaticRoutes = async (
|
|
33
|
+
manifest: RouteManifest,
|
|
34
|
+
modules: ApiRouteModules,
|
|
35
|
+
routes: string[] = [],
|
|
36
|
+
): Promise<string[]> => {
|
|
37
|
+
const out = new Set<string>(routes.filter((r) => !r.includes(":")));
|
|
38
|
+
|
|
39
|
+
for (const route of manifest) {
|
|
40
|
+
if (route.kind === "api") continue;
|
|
41
|
+
if (!route.path.includes(":") && !route.path.includes("*")) {
|
|
42
|
+
out.add(route.path);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const entry = modules[route.file] ?? modules[`/${route.file}`];
|
|
47
|
+
if (!entry) continue;
|
|
48
|
+
const mod = (await Promise.resolve(
|
|
49
|
+
typeof entry === "function" ? entry() : entry,
|
|
50
|
+
)) as { generateStaticParams?: GenerateStaticParamsFn };
|
|
51
|
+
if (!mod.generateStaticParams) continue;
|
|
52
|
+
|
|
53
|
+
for (const params of await mod.generateStaticParams()) {
|
|
54
|
+
out.add(substitute(route.path, params));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return [...out];
|
|
58
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed Routes
|
|
3
|
+
* Type-level param extraction + a `route()` helper — the generated
|
|
4
|
+
* `.solid/routes.d.ts` augments `GeneratedRoutes` so paths and params
|
|
5
|
+
* are fully typed (routeTree.gen equivalent, manifest-driven)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** Extract param names from a route pattern type: "/users/:id" → "id" */
|
|
9
|
+
export type ExtractParams<P extends string> =
|
|
10
|
+
P extends `${string}:${infer Tail}`
|
|
11
|
+
? Tail extends `${infer Name}/${infer Rest}`
|
|
12
|
+
? Name | ExtractParams<`/${Rest}`>
|
|
13
|
+
: Tail
|
|
14
|
+
: P extends `${string}*${infer Tail}`
|
|
15
|
+
? Tail extends `${infer Name}/${infer Rest}`
|
|
16
|
+
? Name | ExtractParams<`/${Rest}`>
|
|
17
|
+
: Tail
|
|
18
|
+
: never;
|
|
19
|
+
|
|
20
|
+
export type RouteParamsFor<P extends string> = [ExtractParams<P>] extends [
|
|
21
|
+
never,
|
|
22
|
+
]
|
|
23
|
+
? Record<string, never>
|
|
24
|
+
: Record<ExtractParams<P>, string>;
|
|
25
|
+
|
|
26
|
+
export type HasParams<P extends string> = [ExtractParams<P>] extends [never]
|
|
27
|
+
? false
|
|
28
|
+
: true;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Route tree — `solid generate` emits a declaration merging into this
|
|
32
|
+
* interface, mapping each path literal to its params object. Until
|
|
33
|
+
* generated it stays empty and every string is a valid RoutePath.
|
|
34
|
+
*/
|
|
35
|
+
export interface GeneratedRoutes {}
|
|
36
|
+
|
|
37
|
+
/** All known route paths — literal union after `solid generate` */
|
|
38
|
+
export type RoutePath = [keyof GeneratedRoutes] extends [never]
|
|
39
|
+
? string
|
|
40
|
+
: keyof GeneratedRoutes & string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Params for a path — the generated map wins; otherwise param names are
|
|
44
|
+
* extracted from the pattern literal at the type level
|
|
45
|
+
*/
|
|
46
|
+
export type ParamsFor<P extends string> = P extends keyof GeneratedRoutes
|
|
47
|
+
? GeneratedRoutes[P]
|
|
48
|
+
: RouteParamsFor<P>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Search-param shapes per route — augmentable like GeneratedRoutes;
|
|
52
|
+
* stays empty until `solid generate` (or user code) fills it
|
|
53
|
+
*/
|
|
54
|
+
export interface GeneratedSearch {}
|
|
55
|
+
|
|
56
|
+
export type SearchFor<P extends string> = P extends keyof GeneratedSearch
|
|
57
|
+
? GeneratedSearch[P]
|
|
58
|
+
: Record<string, string | number | boolean>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Build a concrete URL from a route pattern — typed against the
|
|
62
|
+
* generated manifest when present.
|
|
63
|
+
* pathFor("/users/:id", { id: "42" }) → "/users/42"
|
|
64
|
+
* pathFor("/blog/*slug", { slug: "a/b" }) → "/blog/a/b"
|
|
65
|
+
* pathFor("/search", {}, { q: "x" }) → "/search?q=x"
|
|
66
|
+
*/
|
|
67
|
+
export const pathFor = <P extends RoutePath>(
|
|
68
|
+
path: P,
|
|
69
|
+
params?: ParamsFor<P>,
|
|
70
|
+
search?: SearchFor<P>,
|
|
71
|
+
/** `#section` fragment — appended after the query string */
|
|
72
|
+
hash?: string,
|
|
73
|
+
): string => {
|
|
74
|
+
let url: string = path;
|
|
75
|
+
for (const [key, value] of Object.entries(params ?? {})) {
|
|
76
|
+
url = url.replace(`:${key}`, encodeURIComponent(String(value)));
|
|
77
|
+
url = url.replace(`*${key}`, String(value));
|
|
78
|
+
}
|
|
79
|
+
if (url.includes(":") || url.includes("*")) {
|
|
80
|
+
throw new Error(`[solid-framework] pathFor("${path}") missing params`);
|
|
81
|
+
}
|
|
82
|
+
if (search && Object.keys(search).length > 0) {
|
|
83
|
+
const query = new URLSearchParams(
|
|
84
|
+
Object.fromEntries(
|
|
85
|
+
Object.entries(search).map(([k, v]) => [k, String(v)]),
|
|
86
|
+
),
|
|
87
|
+
).toString();
|
|
88
|
+
url += `?${query}`;
|
|
89
|
+
}
|
|
90
|
+
if (hash) url += hash.startsWith("#") ? hash : `#${hash}`;
|
|
91
|
+
return url;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/** @deprecated renamed to pathFor — `route` collides with route concepts */
|
|
95
|
+
export const route = pathFor;
|
|
96
|
+
|
|
97
|
+
/** @deprecated renamed to pathFor */
|
|
98
|
+
export const href = pathFor;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Resolve a relative href against a base path — `relativePath("/a/b", "../c")`
|
|
102
|
+
* → "/a/c". Powers `link.relative()` for nested-route navigation.
|
|
103
|
+
*/
|
|
104
|
+
export const relativePath = (from: string, to: string): string => {
|
|
105
|
+
if (to.startsWith("/")) return to;
|
|
106
|
+
const base = from.endsWith("/")
|
|
107
|
+
? from
|
|
108
|
+
: from.slice(0, from.lastIndexOf("/") + 1);
|
|
109
|
+
const stack = base.split("/").filter(Boolean);
|
|
110
|
+
for (const seg of to.split("/")) {
|
|
111
|
+
if (seg === "..") stack.pop();
|
|
112
|
+
else if (seg !== "." && seg !== "") stack.push(seg);
|
|
113
|
+
}
|
|
114
|
+
return `/${stack.join("/")}`;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The route pattern itself, type-checked — `link.pattern("/users/:id")`
|
|
119
|
+
* returns "/users/:id" so templates stay typed to the manifest
|
|
120
|
+
*/
|
|
121
|
+
export const routePattern = <P extends RoutePath>(path: P): P => path;
|
|
122
|
+
|
|
123
|
+
/** `link(path, params, search)` + `link.relative` + `link.pattern` */
|
|
124
|
+
export const link = Object.assign(pathFor, {
|
|
125
|
+
relative: relativePath,
|
|
126
|
+
pattern: routePattern,
|
|
127
|
+
});
|