@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,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-Function Batching
|
|
3
|
+
* Collects client calls made within the same microtask into a single
|
|
4
|
+
* POST `/_server/batch` — the SvelteKit `query.batch()` equivalent
|
|
5
|
+
*
|
|
6
|
+
* const fn = createServerFn({ id: "users.list", batch: true })
|
|
7
|
+
* .handler(...)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { ServerFnErrorPayload } from "#server/types";
|
|
11
|
+
import { deserialize, serialize } from "../../domain/operations/serialize";
|
|
12
|
+
import { runValidator } from "./create-server-fn";
|
|
13
|
+
import { getServerFn } from "./registry";
|
|
14
|
+
|
|
15
|
+
export const SERVER_FN_BATCH = "/_server/batch";
|
|
16
|
+
|
|
17
|
+
export const isBatchRequest = (request: Request): boolean =>
|
|
18
|
+
new URL(request.url).pathname === SERVER_FN_BATCH &&
|
|
19
|
+
request.method === "POST";
|
|
20
|
+
|
|
21
|
+
interface BatchCall {
|
|
22
|
+
id: string;
|
|
23
|
+
input?: unknown;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const createBatchHandler = (): ((
|
|
27
|
+
request: Request,
|
|
28
|
+
) => Promise<Response>) => {
|
|
29
|
+
return async (request: Request): Promise<Response> => {
|
|
30
|
+
let calls: BatchCall[];
|
|
31
|
+
try {
|
|
32
|
+
const body = (await request.json()) as { calls?: BatchCall[] };
|
|
33
|
+
calls = body.calls ?? [];
|
|
34
|
+
} catch {
|
|
35
|
+
return Response.json(
|
|
36
|
+
{ error: { code: "BAD_REQUEST", message: "Invalid batch body" } },
|
|
37
|
+
{ status: 400 },
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const results = await Promise.all(
|
|
42
|
+
calls.map(async (call) => {
|
|
43
|
+
const descriptor = getServerFn(call.id);
|
|
44
|
+
if (!descriptor) {
|
|
45
|
+
return {
|
|
46
|
+
error: {
|
|
47
|
+
code: "NOT_FOUND",
|
|
48
|
+
message: `Unknown server function: ${call.id}`,
|
|
49
|
+
} satisfies ServerFnErrorPayload,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const data = runValidator(
|
|
54
|
+
descriptor.validator,
|
|
55
|
+
deserialize((call.input ?? null) as never),
|
|
56
|
+
);
|
|
57
|
+
const result = await descriptor.handler({
|
|
58
|
+
data,
|
|
59
|
+
context: { request, params: {} },
|
|
60
|
+
});
|
|
61
|
+
return { result: serialize(result) };
|
|
62
|
+
} catch (error) {
|
|
63
|
+
return {
|
|
64
|
+
error: {
|
|
65
|
+
code: "INTERNAL_ERROR",
|
|
66
|
+
message:
|
|
67
|
+
error instanceof Error ? error.message : "batch call failed",
|
|
68
|
+
} satisfies ServerFnErrorPayload,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
return Response.json({ results });
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// ---- client-side batcher ----
|
|
79
|
+
|
|
80
|
+
interface Pending {
|
|
81
|
+
id: string;
|
|
82
|
+
input: unknown;
|
|
83
|
+
resolve: (v: unknown) => void;
|
|
84
|
+
reject: (e: unknown) => void;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
let queue: Pending[] = [];
|
|
88
|
+
let flushing = false;
|
|
89
|
+
|
|
90
|
+
const flush = async (baseUrl: string, fetchFn: typeof fetch): Promise<void> => {
|
|
91
|
+
const pending = queue;
|
|
92
|
+
queue = [];
|
|
93
|
+
flushing = false;
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
const response = await fetchFn(`${baseUrl}${SERVER_FN_BATCH}`, {
|
|
97
|
+
method: "POST",
|
|
98
|
+
headers: { "Content-Type": "application/json" },
|
|
99
|
+
body: JSON.stringify({
|
|
100
|
+
calls: pending.map((p) => ({ id: p.id, input: serialize(p.input) })),
|
|
101
|
+
}),
|
|
102
|
+
});
|
|
103
|
+
const body = (await response.json()) as {
|
|
104
|
+
results?: Array<{ result?: unknown; error?: { message?: string } }>;
|
|
105
|
+
};
|
|
106
|
+
const results = body.results ?? [];
|
|
107
|
+
pending.forEach((p, i) => {
|
|
108
|
+
const r = results[i];
|
|
109
|
+
if (r?.error) p.reject(new Error(r.error.message ?? "batch failed"));
|
|
110
|
+
else p.resolve(deserialize((r?.result ?? null) as never));
|
|
111
|
+
});
|
|
112
|
+
} catch (error) {
|
|
113
|
+
for (const p of pending) p.reject(error);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/** Enqueue a call — flushed into one POST at microtask end */
|
|
118
|
+
export const callBatched = <T>(
|
|
119
|
+
baseUrl: string,
|
|
120
|
+
fetchFn: typeof fetch,
|
|
121
|
+
id: string,
|
|
122
|
+
input: unknown,
|
|
123
|
+
): Promise<T> =>
|
|
124
|
+
new Promise<T>((resolve, reject) => {
|
|
125
|
+
queue.push({
|
|
126
|
+
id,
|
|
127
|
+
input,
|
|
128
|
+
resolve: resolve as (v: unknown) => void,
|
|
129
|
+
reject,
|
|
130
|
+
});
|
|
131
|
+
if (!flushing) {
|
|
132
|
+
flushing = true;
|
|
133
|
+
queueMicrotask(() => void flush(baseUrl, fetchFn));
|
|
134
|
+
}
|
|
135
|
+
});
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createServerFn
|
|
3
|
+
* Type-safe RPC — call server code from the client like a local function
|
|
4
|
+
*
|
|
5
|
+
* On the server the handler executes directly. On the client the call is
|
|
6
|
+
* dispatched over HTTP to `/_server/fn/<id>` and the result is deserialized.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { isServer } from "solid-js/web";
|
|
10
|
+
import {
|
|
11
|
+
deserialize,
|
|
12
|
+
serialize,
|
|
13
|
+
} from "#server/modules/server-functions/domain/operations/serialize";
|
|
14
|
+
import {
|
|
15
|
+
NDJSON_CONTENT_TYPE,
|
|
16
|
+
readStreamResponse,
|
|
17
|
+
} from "#server/modules/server-functions/domain/operations/stream";
|
|
18
|
+
import { ServerFnError } from "#server/shared/errors";
|
|
19
|
+
import type {
|
|
20
|
+
ServerFnContext,
|
|
21
|
+
ServerFnDescriptor,
|
|
22
|
+
ServerFnHandler,
|
|
23
|
+
ServerFnMethod,
|
|
24
|
+
ServerFnMiddleware,
|
|
25
|
+
ServerFnValidator,
|
|
26
|
+
} from "#server/types";
|
|
27
|
+
import { callBatched } from "./batch";
|
|
28
|
+
import { registerServerFn } from "./registry";
|
|
29
|
+
import { registerSchedule } from "./scheduler";
|
|
30
|
+
|
|
31
|
+
export interface CreateServerFnOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Stable, unique id shared between client and server bundles.
|
|
34
|
+
* Convention: "<domain>.<action>", e.g. "users.list".
|
|
35
|
+
* Optional — the vite plugin injects a deterministic id when absent.
|
|
36
|
+
*/
|
|
37
|
+
id?: string;
|
|
38
|
+
method?: ServerFnMethod;
|
|
39
|
+
/**
|
|
40
|
+
* Batch calls — calls made within the same microtask travel in a
|
|
41
|
+
* single POST /_server/batch (the query.batch() equivalent)
|
|
42
|
+
*/
|
|
43
|
+
batch?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Cron schedule — registers the fn for periodic execution when
|
|
46
|
+
* startScheduler() runs (5-field cron, minute granularity)
|
|
47
|
+
*/
|
|
48
|
+
schedule?: string;
|
|
49
|
+
/** Custom endpoint base — defaults to the framework convention */
|
|
50
|
+
baseUrl?: string;
|
|
51
|
+
fetch?: typeof fetch;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface ServerFnBuilder<TInput = undefined> {
|
|
55
|
+
validator<TNext>(validator: ServerFnValidator<TNext>): ServerFnBuilder<TNext>;
|
|
56
|
+
/**
|
|
57
|
+
* Composable middleware — runs after validation, before the handler.
|
|
58
|
+
* Return a Response to short-circuit, an object to merge into
|
|
59
|
+
* `context` (auth user, db handle), or nothing.
|
|
60
|
+
*/
|
|
61
|
+
middleware(
|
|
62
|
+
mw: ServerFnMiddleware | ServerFnMiddleware[],
|
|
63
|
+
): ServerFnBuilder<TInput>;
|
|
64
|
+
/**
|
|
65
|
+
* Client-side middleware — runs before the remote fetch. Return
|
|
66
|
+
* `{ headers: {...} }` to merge request headers (auth tokens),
|
|
67
|
+
* a Response to short-circuit, or other keys into context.
|
|
68
|
+
*/
|
|
69
|
+
client(
|
|
70
|
+
mw: ServerFnMiddleware | ServerFnMiddleware[],
|
|
71
|
+
): ServerFnBuilder<TInput>;
|
|
72
|
+
handler<TOutput>(
|
|
73
|
+
handler: ServerFnHandler<TInput, TOutput>,
|
|
74
|
+
): ServerFn<TInput, TOutput>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type ServerFn<TInput, TOutput> = [TInput] extends [undefined]
|
|
78
|
+
? (input?: TInput) => Promise<TOutput>
|
|
79
|
+
: (input: TInput) => Promise<TOutput>;
|
|
80
|
+
|
|
81
|
+
export const SERVER_FN_BASE = "/_server/fn";
|
|
82
|
+
|
|
83
|
+
export const runValidator = <TInput>(
|
|
84
|
+
validator: ServerFnValidator<TInput> | undefined,
|
|
85
|
+
input: unknown,
|
|
86
|
+
): TInput => {
|
|
87
|
+
if (!validator) return input as TInput;
|
|
88
|
+
|
|
89
|
+
if (typeof validator === "function") {
|
|
90
|
+
return validator(input);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const result = validator["~standard"].validate(input) as
|
|
94
|
+
| { value?: TInput; issues?: unknown }
|
|
95
|
+
| Promise<{ value?: TInput; issues?: unknown }>;
|
|
96
|
+
if (result instanceof Promise) {
|
|
97
|
+
throw new Error(
|
|
98
|
+
"[solid-framework] async standard-schema validators are not supported in createServerFn; validate inside the handler",
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
if (result.issues) {
|
|
102
|
+
throw new ServerFnError({
|
|
103
|
+
code: "VALIDATION_ERROR",
|
|
104
|
+
message: "Invalid server function input",
|
|
105
|
+
data: result.issues,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return result.value as TInput;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Run a descriptor's middleware chain — returns a short-circuit
|
|
113
|
+
* Response or mutates `context` with merged middleware results
|
|
114
|
+
*/
|
|
115
|
+
export const runMiddleware = async (
|
|
116
|
+
middleware: ServerFnMiddleware[] | undefined,
|
|
117
|
+
data: unknown,
|
|
118
|
+
context: ServerFnContext,
|
|
119
|
+
): Promise<Response | undefined> => {
|
|
120
|
+
for (const mw of middleware ?? []) {
|
|
121
|
+
const r = await mw({ data, context });
|
|
122
|
+
if (r instanceof Response) return r;
|
|
123
|
+
if (r && typeof r === "object") Object.assign(context, r);
|
|
124
|
+
}
|
|
125
|
+
return undefined;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const callRemote = async <TInput, TOutput>(
|
|
129
|
+
options: CreateServerFnOptions & { id: string },
|
|
130
|
+
input: TInput,
|
|
131
|
+
clientMw?: ServerFnMiddleware[],
|
|
132
|
+
): Promise<TOutput> => {
|
|
133
|
+
const fetchFn = options.fetch ?? fetch;
|
|
134
|
+
const method = options.method ?? "POST";
|
|
135
|
+
const base = (options.baseUrl ?? "") + SERVER_FN_BASE;
|
|
136
|
+
const url = `${base}/${encodeURIComponent(options.id)}`;
|
|
137
|
+
|
|
138
|
+
// Client middleware — headers/auth hooks before the remote call
|
|
139
|
+
const extraHeaders: Record<string, string> = {};
|
|
140
|
+
if (clientMw?.length) {
|
|
141
|
+
const context: ServerFnContext = {
|
|
142
|
+
request: new Request(url, { method }),
|
|
143
|
+
params: {},
|
|
144
|
+
};
|
|
145
|
+
for (const mw of clientMw) {
|
|
146
|
+
const r = await mw({ data: input, context });
|
|
147
|
+
if (r instanceof Response) return r as TOutput;
|
|
148
|
+
if (r && typeof r === "object") {
|
|
149
|
+
const { headers, ...rest } = r;
|
|
150
|
+
if (headers && typeof headers === "object") {
|
|
151
|
+
Object.assign(extraHeaders, headers);
|
|
152
|
+
}
|
|
153
|
+
Object.assign(context, rest);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const response =
|
|
159
|
+
method === "GET"
|
|
160
|
+
? await fetchFn(
|
|
161
|
+
`${url}?input=${encodeURIComponent(JSON.stringify(serialize(input ?? null)))}`,
|
|
162
|
+
{ headers: extraHeaders },
|
|
163
|
+
)
|
|
164
|
+
: await fetchFn(url, {
|
|
165
|
+
method: "POST",
|
|
166
|
+
headers: {
|
|
167
|
+
"Content-Type": "application/json",
|
|
168
|
+
...extraHeaders,
|
|
169
|
+
},
|
|
170
|
+
body: JSON.stringify({ input: serialize(input ?? null) }),
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// Streamed results (ReadableStream / AsyncIterable from the handler)
|
|
174
|
+
// arrive as NDJSON frames — re-materialize as an async iterable
|
|
175
|
+
const contentType = response.headers.get("Content-Type") ?? "";
|
|
176
|
+
if (contentType.includes(NDJSON_CONTENT_TYPE)) {
|
|
177
|
+
return readStreamResponse(response) as TOutput;
|
|
178
|
+
}
|
|
179
|
+
if (!response.headers.get("Content-Type")?.includes("application/json")) {
|
|
180
|
+
return response as unknown as TOutput;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const body = (await response.json()) as {
|
|
184
|
+
result?: Parameters<typeof deserialize>[0];
|
|
185
|
+
error?: { code?: string; message?: string; data?: unknown };
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
if (!response.ok || body.error) {
|
|
189
|
+
throw ServerFnError.fromJson(
|
|
190
|
+
body.error ?? { message: response.statusText },
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
return deserialize(body.result ?? null) as TOutput;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export const createServerFn = (
|
|
197
|
+
options: CreateServerFnOptions,
|
|
198
|
+
): ServerFnBuilder<undefined> => {
|
|
199
|
+
let validator: ServerFnValidator<unknown> | undefined;
|
|
200
|
+
const middleware: ServerFnMiddleware[] = [];
|
|
201
|
+
const clientMw: ServerFnMiddleware[] = [];
|
|
202
|
+
|
|
203
|
+
const builder: ServerFnBuilder<never> = {
|
|
204
|
+
validator<TNext>(next: ServerFnValidator<TNext>) {
|
|
205
|
+
validator = next as ServerFnValidator<unknown>;
|
|
206
|
+
return builder as unknown as ServerFnBuilder<TNext>;
|
|
207
|
+
},
|
|
208
|
+
middleware(mw: ServerFnMiddleware | ServerFnMiddleware[]) {
|
|
209
|
+
middleware.push(...(Array.isArray(mw) ? mw : [mw]));
|
|
210
|
+
return builder;
|
|
211
|
+
},
|
|
212
|
+
client(mw: ServerFnMiddleware | ServerFnMiddleware[]) {
|
|
213
|
+
clientMw.push(...(Array.isArray(mw) ? mw : [mw]));
|
|
214
|
+
return builder;
|
|
215
|
+
},
|
|
216
|
+
handler<TOutput>(handler: ServerFnHandler<never, TOutput>) {
|
|
217
|
+
// Explicit id wins; otherwise hash the handler source so dev and
|
|
218
|
+
// prod resolve identically when the vite transform did not run
|
|
219
|
+
const resolved =
|
|
220
|
+
options.id ??
|
|
221
|
+
`fn_${String(handler).length.toString(36)}_${String(handler)
|
|
222
|
+
.split("")
|
|
223
|
+
.reduce((a, c) => (a * 31 + c.charCodeAt(0)) | 0, 7)
|
|
224
|
+
.toString(36)}`;
|
|
225
|
+
const resolvedOptions = { ...options, id: resolved };
|
|
226
|
+
const descriptor: ServerFnDescriptor<never, TOutput> = {
|
|
227
|
+
id: resolved,
|
|
228
|
+
method: options.method ?? "POST",
|
|
229
|
+
validator: validator as ServerFnValidator<never>,
|
|
230
|
+
middleware: middleware.length ? middleware : undefined,
|
|
231
|
+
handler,
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
if (isServer) {
|
|
235
|
+
registerServerFn(descriptor);
|
|
236
|
+
if (options.schedule) registerSchedule(resolved, options.schedule);
|
|
237
|
+
return (async (input: never) => {
|
|
238
|
+
const data = runValidator(descriptor.validator, input);
|
|
239
|
+
const context: ServerFnContext = {
|
|
240
|
+
request: new Request("http://localhost"),
|
|
241
|
+
params: {},
|
|
242
|
+
};
|
|
243
|
+
const short = await runMiddleware(
|
|
244
|
+
descriptor.middleware,
|
|
245
|
+
data,
|
|
246
|
+
context,
|
|
247
|
+
);
|
|
248
|
+
if (short) return short as TOutput;
|
|
249
|
+
return handler({ data, context });
|
|
250
|
+
}) as ServerFn<never, TOutput>;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return (async (input: never) => {
|
|
254
|
+
if (options.batch) {
|
|
255
|
+
return callBatched<TOutput>(
|
|
256
|
+
options.baseUrl ?? "",
|
|
257
|
+
options.fetch ?? fetch,
|
|
258
|
+
resolved,
|
|
259
|
+
input,
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
return callRemote<never, TOutput>(
|
|
263
|
+
resolvedOptions,
|
|
264
|
+
input,
|
|
265
|
+
clientMw.length ? clientMw : undefined,
|
|
266
|
+
);
|
|
267
|
+
}) as ServerFn<never, TOutput>;
|
|
268
|
+
},
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
return builder as unknown as ServerFnBuilder<undefined>;
|
|
272
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Same-origin guard for `/_server/fn` (and other `/_server/*` endpoints)
|
|
3
|
+
*
|
|
4
|
+
* Server functions are same-origin RPC endpoints — they must not be callable
|
|
5
|
+
* cross-site. The check mirrors TanStack Start's CSRF middleware:
|
|
6
|
+
*
|
|
7
|
+
* 1. `Sec-Fetch-Site` — allows same-origin / same-site / none, rejects
|
|
8
|
+
* cross-site
|
|
9
|
+
* 2. `Origin` / `Referer` — compared against the request URL origin
|
|
10
|
+
* 3. No fetch metadata at all — rejected unless `allowNoFetchMetadata`
|
|
11
|
+
* (non-browser clients like curl send none of these headers)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export interface ServerFnCsrfOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Extra origins allowed to call server functions when the deployment
|
|
17
|
+
* serves the API under a different public origin (e.g. api.example.com)
|
|
18
|
+
*/
|
|
19
|
+
origin?: string | string[];
|
|
20
|
+
/**
|
|
21
|
+
* Allow requests without Sec-Fetch-Site / Origin / Referer headers.
|
|
22
|
+
* Enable only when another layer guarantees same-origin calls.
|
|
23
|
+
*/
|
|
24
|
+
allowNoFetchMetadata?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const SAFE_FETCH_SITES = new Set(["same-origin", "same-site", "none"]);
|
|
28
|
+
|
|
29
|
+
const originOf = (value: string): string | undefined => {
|
|
30
|
+
try {
|
|
31
|
+
return new URL(value).origin;
|
|
32
|
+
} catch {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const isSameOriginRequest = (
|
|
38
|
+
request: Request,
|
|
39
|
+
options: ServerFnCsrfOptions = {},
|
|
40
|
+
): boolean => {
|
|
41
|
+
const requestOrigin = new URL(request.url).origin;
|
|
42
|
+
const extra = options.origin ?? [];
|
|
43
|
+
const allowed = new Set<string>([requestOrigin]);
|
|
44
|
+
for (const o of Array.isArray(extra) ? extra : [extra]) {
|
|
45
|
+
const parsed = originOf(o);
|
|
46
|
+
if (parsed) allowed.add(parsed);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const fetchSite = request.headers.get("Sec-Fetch-Site");
|
|
50
|
+
if (fetchSite !== null) {
|
|
51
|
+
return SAFE_FETCH_SITES.has(fetchSite.toLowerCase());
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const origin = request.headers.get("Origin");
|
|
55
|
+
if (origin !== null) {
|
|
56
|
+
const parsed = originOf(origin);
|
|
57
|
+
return parsed !== undefined && allowed.has(parsed);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const referer = request.headers.get("Referer");
|
|
61
|
+
if (referer !== null) {
|
|
62
|
+
const parsed = originOf(referer);
|
|
63
|
+
return parsed !== undefined && allowed.has(parsed);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return options.allowNoFetchMetadata === true;
|
|
67
|
+
};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live Queries
|
|
3
|
+
* `defineLiveQuery` registers an async-iterable source served as
|
|
4
|
+
* Server-Sent Events at `/_server/live/<id>`; `useLiveQuery`
|
|
5
|
+
* subscribes on the client — the SvelteKit `query.live` equivalent
|
|
6
|
+
*
|
|
7
|
+
* // src/fns/clock.live.ts
|
|
8
|
+
* export const clock = defineLiveQuery({ id: "clock" })
|
|
9
|
+
* .handler(async function* () {
|
|
10
|
+
* while (true) { yield Date.now(); await sleep(1000); }
|
|
11
|
+
* });
|
|
12
|
+
*
|
|
13
|
+
* // component
|
|
14
|
+
* const time = useLiveQuery(clock); // accessor — latest value
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { createEffect, createSignal, onCleanup } from "solid-js";
|
|
18
|
+
import { isServer } from "solid-js/web";
|
|
19
|
+
import {
|
|
20
|
+
defineEventStream,
|
|
21
|
+
type SseEmit,
|
|
22
|
+
} from "../../../realtime/domain/operations/sse";
|
|
23
|
+
import { deserialize, serialize } from "../../domain/operations/serialize";
|
|
24
|
+
|
|
25
|
+
export const LIVE_ENDPOINT = "/_server/live";
|
|
26
|
+
|
|
27
|
+
type LiveSource = (ctx: { request: Request }) => AsyncIterable<unknown>;
|
|
28
|
+
|
|
29
|
+
const registry = new Map<string, LiveSource>();
|
|
30
|
+
/** Open SSE emitters per query id — revalidateLiveQuery pushes to them */
|
|
31
|
+
const emitters = new Map<string, Set<SseEmit>>();
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Replay buffers — last N data events per query id; EventSource
|
|
35
|
+
* reconnects send `Last-Event-ID`, so missed frames replay before
|
|
36
|
+
* live ones (instantdb-style resume)
|
|
37
|
+
*/
|
|
38
|
+
const REPLAY_LIMIT = 50;
|
|
39
|
+
const replays = new Map<string, { id: number; data: unknown }[]>();
|
|
40
|
+
const seq = new Map<string, number>();
|
|
41
|
+
|
|
42
|
+
const bufferEvent = (id: string, data: unknown): string => {
|
|
43
|
+
const n = (seq.get(id) ?? 0) + 1;
|
|
44
|
+
seq.set(id, n);
|
|
45
|
+
const buf = replays.get(id) ?? [];
|
|
46
|
+
buf.push({ id: n, data });
|
|
47
|
+
if (buf.length > REPLAY_LIMIT) buf.shift();
|
|
48
|
+
replays.set(id, buf);
|
|
49
|
+
return String(n);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Push a "revalidate" event to every open connection of a live query —
|
|
54
|
+
* call after a mutation (action/server-fn) so subscribers re-subscribe
|
|
55
|
+
* and receive fresh data
|
|
56
|
+
*/
|
|
57
|
+
export const revalidateLiveQuery = (id: string): void => {
|
|
58
|
+
for (const emit of emitters.get(id) ?? []) emit({}, "revalidate");
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const isLiveRequest = (request: Request): boolean =>
|
|
62
|
+
new URL(request.url).pathname.startsWith(`${LIVE_ENDPOINT}/`);
|
|
63
|
+
|
|
64
|
+
export const createLiveQueryHandler = (): ((request: Request) => Response) => {
|
|
65
|
+
return (request: Request): Response => {
|
|
66
|
+
const id = decodeURIComponent(
|
|
67
|
+
new URL(request.url).pathname.slice(LIVE_ENDPOINT.length + 1),
|
|
68
|
+
);
|
|
69
|
+
const source = registry.get(id);
|
|
70
|
+
if (!source) {
|
|
71
|
+
return Response.json(
|
|
72
|
+
{ error: { code: "NOT_FOUND", message: `Unknown live query: ${id}` } },
|
|
73
|
+
{ status: 404 },
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
const iterable = source({ request });
|
|
77
|
+
return defineEventStream((emit: SseEmit, req: Request) => {
|
|
78
|
+
let cancelled = false;
|
|
79
|
+
const set = emitters.get(id) ?? new Set<SseEmit>();
|
|
80
|
+
set.add(emit);
|
|
81
|
+
emitters.set(id, set);
|
|
82
|
+
// Resume — replay buffered events past the client's Last-Event-ID
|
|
83
|
+
const last = Number(req.headers.get("last-event-id") ?? 0);
|
|
84
|
+
if (last > 0) {
|
|
85
|
+
for (const e of replays.get(id) ?? []) {
|
|
86
|
+
if (e.id > last) emit(e.data, "data", String(e.id));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
void (async () => {
|
|
90
|
+
try {
|
|
91
|
+
for await (const value of iterable) {
|
|
92
|
+
if (cancelled || req.signal.aborted) break;
|
|
93
|
+
const serialized = serialize(value);
|
|
94
|
+
const eventId = bufferEvent(id, serialized);
|
|
95
|
+
emit(serialized, "data", eventId);
|
|
96
|
+
}
|
|
97
|
+
// finite sources signal completion — consumers may close
|
|
98
|
+
if (!cancelled && !req.signal.aborted) emit({}, "done");
|
|
99
|
+
} catch (error) {
|
|
100
|
+
emit(
|
|
101
|
+
{ e: error instanceof Error ? error.message : "live query failed" },
|
|
102
|
+
"error",
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
})();
|
|
106
|
+
return () => {
|
|
107
|
+
cancelled = true;
|
|
108
|
+
set.delete(emit);
|
|
109
|
+
};
|
|
110
|
+
})(request);
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export interface LiveQueryDescriptor<T> {
|
|
115
|
+
id: string;
|
|
116
|
+
source: LiveSource;
|
|
117
|
+
/** marker for typing */
|
|
118
|
+
readonly __type?: T;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface LiveQueryBuilder {
|
|
122
|
+
handler<T>(source: () => AsyncIterable<T>): LiveQueryDescriptor<T>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export const defineLiveQuery = (options: {
|
|
126
|
+
id?: string;
|
|
127
|
+
}): LiveQueryBuilder => ({
|
|
128
|
+
handler<T>(source: () => AsyncIterable<T>) {
|
|
129
|
+
const id =
|
|
130
|
+
options.id ??
|
|
131
|
+
`live_${String(source).length.toString(36)}_${String(source)
|
|
132
|
+
.split("")
|
|
133
|
+
.reduce((a, c) => (a * 31 + c.charCodeAt(0)) | 0, 7)
|
|
134
|
+
.toString(36)}`;
|
|
135
|
+
const descriptor: LiveQueryDescriptor<T> = {
|
|
136
|
+
id,
|
|
137
|
+
source: () => source(),
|
|
138
|
+
};
|
|
139
|
+
if (isServer) registry.set(id, () => source());
|
|
140
|
+
return descriptor;
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
/** Client hook — subscribe to a live query, returns latest value */
|
|
145
|
+
export const useLiveQuery = <T>(
|
|
146
|
+
query: LiveQueryDescriptor<T>,
|
|
147
|
+
options: { baseUrl?: string } = {},
|
|
148
|
+
): (() => T | undefined) => {
|
|
149
|
+
const [data, setData] = createSignal<T>();
|
|
150
|
+
const [epoch, setEpoch] = createSignal(0);
|
|
151
|
+
|
|
152
|
+
if (!isServer && typeof EventSource !== "undefined") {
|
|
153
|
+
// epoch bumps on "revalidate" — a fresh EventSource reconnects
|
|
154
|
+
// and the source regenerates current data
|
|
155
|
+
createEffect(() => {
|
|
156
|
+
epoch();
|
|
157
|
+
const url = `${options.baseUrl ?? ""}${LIVE_ENDPOINT}/${encodeURIComponent(query.id)}`;
|
|
158
|
+
const es = new EventSource(url);
|
|
159
|
+
es.addEventListener("data", (event) => {
|
|
160
|
+
const parsed = JSON.parse(
|
|
161
|
+
(event as MessageEvent).data as string,
|
|
162
|
+
) as never;
|
|
163
|
+
setData(() => deserialize(parsed) as T);
|
|
164
|
+
});
|
|
165
|
+
// finite sources close after "done"; live sources stay connected
|
|
166
|
+
es.addEventListener("done", () => es.close());
|
|
167
|
+
es.addEventListener("revalidate", () => setEpoch((e) => e + 1));
|
|
168
|
+
onCleanup(() => es.close());
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return data;
|
|
172
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server Function Registry
|
|
3
|
+
* Server-side registry mapping function ids to descriptors
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ServerFnDescriptor } from "#server/types";
|
|
7
|
+
|
|
8
|
+
const registry = new Map<string, ServerFnDescriptor>();
|
|
9
|
+
|
|
10
|
+
export const registerServerFn = <TInput, TOutput>(
|
|
11
|
+
descriptor: ServerFnDescriptor<TInput, TOutput>,
|
|
12
|
+
): ServerFnDescriptor<TInput, TOutput> => {
|
|
13
|
+
registry.set(descriptor.id, descriptor as ServerFnDescriptor);
|
|
14
|
+
return descriptor;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const getServerFn = (id: string): ServerFnDescriptor | undefined =>
|
|
18
|
+
registry.get(id);
|
|
19
|
+
|
|
20
|
+
export const listServerFnIds = (): string[] => [...registry.keys()];
|
|
21
|
+
|
|
22
|
+
export const clearServerFnRegistry = (): void => registry.clear();
|