@kayjs/kay 1.105.0 → 1.107.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 +2 -2
- package/dist/eslint.js +777 -210
- package/editors/zed/extension.toml +2 -2
- package/llms/action-protection.md +2 -2
- package/llms/actions-from-islands.md +2 -2
- package/llms/actions-refused-fields.md +22 -0
- package/llms/actions.md +24 -41
- package/llms/analytics.md +1 -1
- package/llms/api-from-islands.md +1 -1
- package/llms/api-routes.md +6 -6
- package/llms/browser-only.md +1 -1
- package/llms/check-and-tools.md +1 -1
- package/llms/code-lints.md +2 -2
- package/llms/compiler-api.md +1 -1
- package/llms/component-libraries.md +1 -0
- package/llms/components.md +1 -1
- package/llms/content-cms.md +1 -1
- package/llms/content-markdown-to-caching.md +1 -1
- package/llms/content-preview.md +2 -2
- package/llms/content.md +21 -21
- package/llms/deprecated-lints-1-105-libraries.md +2 -0
- package/llms/deprecated-lints-1-105.md +3 -3
- package/llms/deprecated-lints.md +4 -4
- package/llms/dev-tool.md +2 -2
- package/llms/environment.md +22 -22
- package/llms/files.md +5 -5
- package/llms/island-and-form-lints.md +1 -0
- package/llms/islands-state-to-ids.md +2 -1
- package/llms/islands.md +10 -1
- package/llms/local-collections.md +2 -2
- package/llms/mcp.md +2 -1
- package/llms/navigation-from-code.md +1 -1
- package/llms/notifications.md +4 -2
- package/llms/project-new-and-add.md +1 -1
- package/llms/project.md +3 -3
- package/llms/rate-limits.md +1 -1
- package/llms/recipes.md +16 -16
- package/llms/rooms.md +4 -4
- package/llms/routing-endpoints-and-base.md +1 -1
- package/llms/routing.md +5 -5
- package/llms/schemas.md +14 -7
- package/llms/server.md +7 -7
- package/llms/site.md +9 -9
- package/llms/sitemap-search-fonts.md +2 -0
- package/llms/styles-and-assets.md +2 -1
- package/llms/templates-elements-slots-snippets.md +2 -2
- package/llms/testing-browser.md +20 -0
- package/llms/testing.md +1 -1
- package/llms/upgrading-1-105-config.md +2 -2
- package/llms/upgrading.md +37 -4
- package/llms/whats-new-archive.md +35 -66
- package/llms/whats-new.md +47 -28
- package/llms.txt +1 -1
- package/package.json +24 -11
- package/src/add.ts +1 -1
- package/src/build/class-table.ts +2 -2
- package/src/build/client.ts +27 -30
- package/src/build/entry-files.ts +19 -0
- package/src/build/lazy-components.ts +130 -0
- package/src/build/lazy-manifest.ts +56 -0
- package/src/build/lazy-stubs.ts +31 -0
- package/src/build/plugin.ts +16 -11
- package/src/build/runtime-chunk.ts +1 -1
- package/src/build/styles.ts +3 -3
- package/src/build/transform.ts +19 -7
- package/src/build/ui-layers.ts +30 -0
- package/src/build/ui.ts +108 -11
- package/src/build/variants.ts +125 -46
- package/src/build/worker-bundle.ts +6 -0
- package/src/check/action-options.ts +56 -0
- package/src/check/boot.ts +22 -1
- package/src/check/call-result.ts +242 -0
- package/src/check/config-objects.ts +17 -2
- package/src/check/diagnose.ts +22 -0
- package/src/check/handler-events.ts +149 -0
- package/src/check/index.ts +6 -2
- package/src/check/link-flag-tests.ts +130 -0
- package/src/check/project.ts +4 -3
- package/src/check/refusal-calls.ts +2 -2
- package/src/check/regroup.ts +5 -3
- package/src/check/renamed-packages.ts +58 -14
- package/src/check/schema-builders.ts +256 -0
- package/src/check/schema-json.ts +226 -0
- package/src/check/secret-keys.ts +15 -2
- package/src/check/shadow-types.ts +13 -9
- package/src/check/template-hints.ts +1 -1
- package/src/check/tool-labels.ts +11 -9
- package/src/check/ui-types.ts +4 -3
- package/src/check/ui.ts +14 -11
- package/src/commands/env-declare.ts +18 -6
- package/src/commands/routes.ts +1 -1
- package/src/compiler/a11y.ts +8 -1
- package/src/compiler/ast.ts +1 -1
- package/src/compiler/bound-props.ts +1 -1
- package/src/compiler/codegen.ts +13 -23
- package/src/compiler/deprecated-lints-1-105.ts +41 -0
- package/src/compiler/deprecated-lints-1-106.ts +14 -0
- package/src/compiler/deprecated-lints-1-107.ts +14 -0
- package/src/compiler/deprecated-lints.ts +17 -60
- package/src/compiler/deprecated-typed-lints.ts +23 -0
- package/src/compiler/dom-here.ts +72 -0
- package/src/compiler/dom.ts +23 -23
- package/src/compiler/fence-checks.ts +12 -11
- package/src/compiler/field-described.ts +2 -2
- package/src/compiler/helper-imports.ts +1 -1
- package/src/compiler/html-fields.ts +92 -0
- package/src/compiler/html-initial.ts +5 -3
- package/src/compiler/html.ts +14 -31
- package/src/compiler/import-edits.ts +15 -0
- package/src/compiler/index.ts +10 -3
- package/src/compiler/island-declaration.ts +15 -0
- package/src/compiler/items.ts +5 -5
- package/src/compiler/kay-exports.ts +1 -0
- package/src/compiler/lazy-imports.ts +357 -0
- package/src/compiler/link-flags.ts +6 -5
- package/src/compiler/lints.ts +12 -12
- package/src/compiler/parser.ts +2 -2
- package/src/compiler/rest-omits.ts +15 -0
- package/src/compiler/route-lints.ts +2 -0
- package/src/compiler/schema-lints.ts +13 -0
- package/src/compiler/script-server.ts +6 -3
- package/src/config-loader.ts +10 -2
- package/src/config-resolve.ts +3 -1
- package/src/config-shape.ts +2 -2
- package/src/config.ts +20 -4
- package/src/content/markdown.ts +2 -3
- package/src/content/validate.ts +1 -1
- package/src/generate-resource.ts +9 -9
- package/src/generate.ts +1 -1
- package/src/mcp/guards.ts +1 -1
- package/src/mcp/tools.ts +1 -1
- package/src/migrate/content.ts +61 -55
- package/src/new.ts +6 -2
- package/src/runtime/action-shared.ts +2 -2
- package/src/runtime/action.ts +51 -4
- package/src/runtime/client.ts +10 -0
- package/src/runtime/dom-lazy.ts +276 -0
- package/src/runtime/field-errors.ts +58 -0
- package/src/runtime/field-refusal.ts +179 -0
- package/src/runtime/form-types.ts +99 -0
- package/src/runtime/form.ts +25 -9
- package/src/runtime/html.ts +42 -6
- package/src/runtime/index.ts +2 -0
- package/src/runtime/island.server.ts +36 -2
- package/src/runtime/markdown-autolink.ts +69 -0
- package/src/runtime/markdown-render.client.ts +39 -3
- package/src/runtime/markdown.client.ts +6 -3
- package/src/runtime/markdown.server.ts +6 -3
- package/src/runtime/markdown.ts +125 -1
- package/src/runtime/navigate-api.ts +10 -5
- package/src/runtime/persist.ts +7 -7
- package/src/runtime/query-param.ts +1 -1
- package/src/runtime/reactive.ts +14 -0
- package/src/runtime/sanitize.ts +3 -1
- package/src/runtime/schema-record.ts +32 -0
- package/src/runtime/schema.client.ts +101 -14
- package/src/runtime/schema.ts +328 -26
- package/src/runtime/standard-schema.ts +32 -0
- package/src/runtime/swap-focus.ts +59 -11
- package/src/runtime/validate-run.client.ts +179 -0
- package/src/runtime/validate.client.ts +11 -0
- package/src/runtime/validate.ts +4 -137
- package/src/server/action-module.ts +16 -0
- package/src/server/actions.ts +54 -57
- package/src/server/answer.ts +102 -0
- package/src/server/api-input.ts +166 -0
- package/src/server/api-modules.ts +1 -1
- package/src/server/api.ts +12 -32
- package/src/server/app-stages.ts +38 -26
- package/src/server/app.ts +5 -2
- package/src/server/client.ts +2 -0
- package/src/server/dev-ui.ts +2 -2
- package/src/server/dev.ts +7 -9
- package/src/server/env-state.ts +1 -1
- package/src/server/env.ts +11 -3
- package/src/server/favicon.ts +47 -1
- package/src/server/file-limit.ts +7 -1
- package/src/server/forms.ts +1 -1
- package/src/server/host-allowlist.ts +7 -7
- package/src/server/image-metadata-bmff.ts +1 -1
- package/src/server/index.ts +2 -0
- package/src/server/kay-routes.ts +221 -0
- package/src/server/kay-server.ts +228 -0
- package/src/server/kept-exports.ts +1 -0
- package/src/server/kept-pages.ts +3 -3
- package/src/server/library.ts +2 -2
- package/src/server/mcp.ts +14 -13
- package/src/server/notifications.ts +4 -2
- package/src/server/offline.ts +24 -7
- package/src/server/openapi.ts +12 -3
- package/src/server/phases.ts +249 -0
- package/src/server/protection.ts +6 -6
- package/src/server/proxy-key.ts +8 -8
- package/src/server/push-settings.ts +16 -2
- package/src/server/push.ts +12 -4
- package/src/server/query.ts +17 -31
- package/src/server/receive.ts +43 -0
- package/src/server/render-document.ts +13 -3
- package/src/server/render.ts +1 -1
- package/src/server/request-context.ts +137 -0
- package/src/server/schema-check.ts +1 -1
- package/src/server/scope.ts +20 -13
- package/src/server/signals.ts +4 -4
- package/src/server/socket.ts +19 -47
- package/src/server/stream.ts +1 -1
- package/src/server/validate.ts +346 -0
- package/src/template-ws.ts +1 -1
- package/src/test/a11y-dom.ts +70 -0
- package/src/test/html-snapshot.ts +103 -0
- package/src/test/index.ts +2 -1
- package/src/test/mount.ts +14 -3
- package/src/test/page-checks.ts +12 -0
- package/src/test/screenshot-match.ts +2 -2
- package/src/test/shared-modules.ts +27 -5
- package/src/test/site-types.ts +5 -1
- package/types/build/class-table.d.ts +1 -1
- package/types/build/class-table.d.ts.map +1 -1
- package/types/build/client.d.ts +3 -2
- package/types/build/client.d.ts.map +1 -1
- package/types/build/entry-files.d.ts +4 -0
- package/types/build/entry-files.d.ts.map +1 -0
- package/types/build/lazy-components.d.ts +6 -0
- package/types/build/lazy-components.d.ts.map +1 -0
- package/types/build/lazy-manifest.d.ts +19 -0
- package/types/build/lazy-manifest.d.ts.map +1 -0
- package/types/build/lazy-stubs.d.ts +5 -0
- package/types/build/lazy-stubs.d.ts.map +1 -0
- package/types/build/plugin.d.ts +1 -0
- package/types/build/plugin.d.ts.map +1 -1
- package/types/build/transform.d.ts +4 -1
- package/types/build/transform.d.ts.map +1 -1
- package/types/build/ui-layers.d.ts +5 -0
- package/types/build/ui-layers.d.ts.map +1 -0
- package/types/build/ui.d.ts +7 -0
- package/types/build/ui.d.ts.map +1 -1
- package/types/build/variants.d.ts +1 -1
- package/types/build/variants.d.ts.map +1 -1
- package/types/build/worker-bundle.d.ts +1 -0
- package/types/build/worker-bundle.d.ts.map +1 -1
- package/types/check/action-options.d.ts +3 -0
- package/types/check/action-options.d.ts.map +1 -0
- package/types/check/boot.d.ts.map +1 -1
- package/types/check/call-result.d.ts +7 -0
- package/types/check/call-result.d.ts.map +1 -0
- package/types/check/config-objects.d.ts.map +1 -1
- package/types/check/diagnose.d.ts.map +1 -1
- package/types/check/handler-events.d.ts +9 -0
- package/types/check/handler-events.d.ts.map +1 -0
- package/types/check/index.d.ts +1 -0
- package/types/check/index.d.ts.map +1 -1
- package/types/check/link-flag-tests.d.ts +4 -0
- package/types/check/link-flag-tests.d.ts.map +1 -0
- package/types/check/project.d.ts.map +1 -1
- package/types/check/regroup.d.ts +1 -1
- package/types/check/regroup.d.ts.map +1 -1
- package/types/check/renamed-packages.d.ts +1 -0
- package/types/check/renamed-packages.d.ts.map +1 -1
- package/types/check/schema-builders.d.ts +3 -0
- package/types/check/schema-builders.d.ts.map +1 -0
- package/types/check/schema-json.d.ts +3 -0
- package/types/check/schema-json.d.ts.map +1 -0
- package/types/check/secret-keys.d.ts.map +1 -1
- package/types/check/shadow-types.d.ts.map +1 -1
- package/types/check/template-hints.d.ts +1 -0
- package/types/check/template-hints.d.ts.map +1 -1
- package/types/check/tool-labels.d.ts.map +1 -1
- package/types/check/ui-types.d.ts.map +1 -1
- package/types/check/ui.d.ts.map +1 -1
- package/types/commands/env-declare.d.ts.map +1 -1
- package/types/compiler/a11y.d.ts.map +1 -1
- package/types/compiler/bound-props.d.ts +1 -0
- package/types/compiler/bound-props.d.ts.map +1 -1
- package/types/compiler/codegen.d.ts +3 -0
- package/types/compiler/codegen.d.ts.map +1 -1
- package/types/compiler/deprecated-lints-1-105.d.ts +39 -0
- package/types/compiler/deprecated-lints-1-105.d.ts.map +1 -0
- package/types/compiler/deprecated-lints-1-106.d.ts +12 -0
- package/types/compiler/deprecated-lints-1-106.d.ts.map +1 -0
- package/types/compiler/deprecated-lints-1-107.d.ts +12 -0
- package/types/compiler/deprecated-lints-1-107.d.ts.map +1 -0
- package/types/compiler/deprecated-lints.d.ts +41 -22
- package/types/compiler/deprecated-lints.d.ts.map +1 -1
- package/types/compiler/deprecated-typed-lints.d.ts +21 -0
- package/types/compiler/deprecated-typed-lints.d.ts.map +1 -0
- package/types/compiler/dom-here.d.ts +14 -0
- package/types/compiler/dom-here.d.ts.map +1 -0
- package/types/compiler/dom.d.ts +1 -0
- package/types/compiler/dom.d.ts.map +1 -1
- package/types/compiler/fence-checks.d.ts.map +1 -1
- package/types/compiler/field-described.d.ts +1 -1
- package/types/compiler/field-described.d.ts.map +1 -1
- package/types/compiler/html-fields.d.ts +19 -0
- package/types/compiler/html-fields.d.ts.map +1 -0
- package/types/compiler/html-initial.d.ts +3 -2
- package/types/compiler/html-initial.d.ts.map +1 -1
- package/types/compiler/html.d.ts.map +1 -1
- package/types/compiler/import-edits.d.ts +1 -0
- package/types/compiler/import-edits.d.ts.map +1 -1
- package/types/compiler/index.d.ts +3 -0
- package/types/compiler/index.d.ts.map +1 -1
- package/types/compiler/island-declaration.d.ts +5 -0
- package/types/compiler/island-declaration.d.ts.map +1 -1
- package/types/compiler/items.d.ts +4 -1
- package/types/compiler/items.d.ts.map +1 -1
- package/types/compiler/kay-exports.d.ts.map +1 -1
- package/types/compiler/lazy-imports.d.ts +33 -0
- package/types/compiler/lazy-imports.d.ts.map +1 -0
- package/types/compiler/link-flags.d.ts +6 -0
- package/types/compiler/link-flags.d.ts.map +1 -1
- package/types/compiler/lints.d.ts +61 -34
- package/types/compiler/lints.d.ts.map +1 -1
- package/types/compiler/rest-omits.d.ts +4 -0
- package/types/compiler/rest-omits.d.ts.map +1 -0
- package/types/compiler/route-lints.d.ts +8 -0
- package/types/compiler/route-lints.d.ts.map +1 -1
- package/types/compiler/schema-lints.d.ts +11 -0
- package/types/compiler/schema-lints.d.ts.map +1 -0
- package/types/compiler/script-server.d.ts.map +1 -1
- package/types/config-loader.d.ts.map +1 -1
- package/types/config-resolve.d.ts.map +1 -1
- package/types/config.d.ts +15 -2
- package/types/config.d.ts.map +1 -1
- package/types/content/markdown.d.ts.map +1 -1
- package/types/migrate/content.d.ts.map +1 -1
- package/types/new.d.ts +1 -0
- package/types/new.d.ts.map +1 -1
- package/types/runtime/action-shared.d.ts +1 -1
- package/types/runtime/action-shared.d.ts.map +1 -1
- package/types/runtime/action.d.ts +29 -1
- package/types/runtime/action.d.ts.map +1 -1
- package/types/runtime/client.d.ts.map +1 -1
- package/types/runtime/dom-lazy.d.ts +6 -0
- package/types/runtime/dom-lazy.d.ts.map +1 -0
- package/types/runtime/field-errors.d.ts +4 -0
- package/types/runtime/field-errors.d.ts.map +1 -0
- package/types/runtime/field-refusal.d.ts +37 -0
- package/types/runtime/field-refusal.d.ts.map +1 -0
- package/types/runtime/form-types.d.ts +6 -0
- package/types/runtime/form-types.d.ts.map +1 -0
- package/types/runtime/form.d.ts +4 -2
- package/types/runtime/form.d.ts.map +1 -1
- package/types/runtime/html.d.ts +3 -0
- package/types/runtime/html.d.ts.map +1 -1
- package/types/runtime/index.d.ts +2 -0
- package/types/runtime/index.d.ts.map +1 -1
- package/types/runtime/island.server.d.ts +2 -0
- package/types/runtime/island.server.d.ts.map +1 -1
- package/types/runtime/markdown-autolink.d.ts +11 -0
- package/types/runtime/markdown-autolink.d.ts.map +1 -0
- package/types/runtime/markdown-render.client.d.ts +2 -1
- package/types/runtime/markdown-render.client.d.ts.map +1 -1
- package/types/runtime/markdown.client.d.ts +3 -1
- package/types/runtime/markdown.client.d.ts.map +1 -1
- package/types/runtime/markdown.d.ts +11 -0
- package/types/runtime/markdown.d.ts.map +1 -1
- package/types/runtime/markdown.server.d.ts +3 -1
- package/types/runtime/markdown.server.d.ts.map +1 -1
- package/types/runtime/navigate-api.d.ts +1 -1
- package/types/runtime/navigate-api.d.ts.map +1 -1
- package/types/runtime/persist.d.ts +2 -2
- package/types/runtime/persist.d.ts.map +1 -1
- package/types/runtime/reactive.d.ts +3 -0
- package/types/runtime/reactive.d.ts.map +1 -1
- package/types/runtime/sanitize.d.ts.map +1 -1
- package/types/runtime/schema-record.d.ts +9 -0
- package/types/runtime/schema-record.d.ts.map +1 -0
- package/types/runtime/schema.client.d.ts.map +1 -1
- package/types/runtime/schema.d.ts +99 -10
- package/types/runtime/schema.d.ts.map +1 -1
- package/types/runtime/standard-schema.d.ts +37 -0
- package/types/runtime/standard-schema.d.ts.map +1 -0
- package/types/runtime/swap-focus.d.ts.map +1 -1
- package/types/runtime/validate-run.client.d.ts +4 -0
- package/types/runtime/validate-run.client.d.ts.map +1 -0
- package/types/runtime/validate.client.d.ts +4 -0
- package/types/runtime/validate.client.d.ts.map +1 -0
- package/types/runtime/validate.d.ts +1 -21
- package/types/runtime/validate.d.ts.map +1 -1
- package/types/server/action-module.d.ts +2 -0
- package/types/server/action-module.d.ts.map +1 -0
- package/types/server/actions.d.ts +1 -0
- package/types/server/actions.d.ts.map +1 -1
- package/types/server/answer.d.ts +6 -0
- package/types/server/answer.d.ts.map +1 -0
- package/types/server/api-input.d.ts +19 -0
- package/types/server/api-input.d.ts.map +1 -0
- package/types/server/api.d.ts.map +1 -1
- package/types/server/app-stages.d.ts +7 -3
- package/types/server/app-stages.d.ts.map +1 -1
- package/types/server/app.d.ts +2 -0
- package/types/server/app.d.ts.map +1 -1
- package/types/server/client.d.ts +1 -0
- package/types/server/client.d.ts.map +1 -1
- package/types/server/dev.d.ts +1 -1
- package/types/server/dev.d.ts.map +1 -1
- package/types/server/env-state.d.ts.map +1 -1
- package/types/server/env.d.ts +5 -1
- package/types/server/env.d.ts.map +1 -1
- package/types/server/favicon.d.ts +3 -1
- package/types/server/favicon.d.ts.map +1 -1
- package/types/server/file-limit.d.ts.map +1 -1
- package/types/server/host-allowlist.d.ts +3 -3
- package/types/server/host-allowlist.d.ts.map +1 -1
- package/types/server/index.d.ts +2 -0
- package/types/server/index.d.ts.map +1 -1
- package/types/server/kay-routes.d.ts +47 -0
- package/types/server/kay-routes.d.ts.map +1 -0
- package/types/server/kay-server.d.ts +25 -0
- package/types/server/kay-server.d.ts.map +1 -0
- package/types/server/kept-exports.d.ts.map +1 -1
- package/types/server/kept-pages.d.ts +1 -1
- package/types/server/kept-pages.d.ts.map +1 -1
- package/types/server/library.d.ts +2 -1
- package/types/server/library.d.ts.map +1 -1
- package/types/server/mcp.d.ts +1 -1
- package/types/server/mcp.d.ts.map +1 -1
- package/types/server/notifications.d.ts +2 -1
- package/types/server/notifications.d.ts.map +1 -1
- package/types/server/offline.d.ts.map +1 -1
- package/types/server/openapi.d.ts.map +1 -1
- package/types/server/phases.d.ts +36 -0
- package/types/server/phases.d.ts.map +1 -0
- package/types/server/protection.d.ts +3 -2
- package/types/server/protection.d.ts.map +1 -1
- package/types/server/proxy-key.d.ts +3 -3
- package/types/server/proxy-key.d.ts.map +1 -1
- package/types/server/push-settings.d.ts +1 -1
- package/types/server/push-settings.d.ts.map +1 -1
- package/types/server/push.d.ts +1 -0
- package/types/server/push.d.ts.map +1 -1
- package/types/server/query.d.ts.map +1 -1
- package/types/server/receive.d.ts +9 -0
- package/types/server/receive.d.ts.map +1 -0
- package/types/server/render-document.d.ts.map +1 -1
- package/types/server/request-context.d.ts +29 -0
- package/types/server/request-context.d.ts.map +1 -0
- package/types/server/schema-check.d.ts +1 -0
- package/types/server/schema-check.d.ts.map +1 -1
- package/types/server/scope.d.ts +1 -1
- package/types/server/scope.d.ts.map +1 -1
- package/types/server/socket.d.ts +3 -5
- package/types/server/socket.d.ts.map +1 -1
- package/types/server/validate.d.ts +26 -0
- package/types/server/validate.d.ts.map +1 -0
- package/types/test/a11y-dom.d.ts +20 -0
- package/types/test/a11y-dom.d.ts.map +1 -0
- package/types/test/html-snapshot.d.ts +4 -0
- package/types/test/html-snapshot.d.ts.map +1 -0
- package/types/test/index.d.ts.map +1 -1
- package/types/test/mount.d.ts +3 -0
- package/types/test/mount.d.ts.map +1 -1
- package/types/test/page-checks.d.ts +6 -0
- package/types/test/page-checks.d.ts.map +1 -0
- package/types/test/screenshot-match.d.ts +1 -1
- package/types/test/screenshot-match.d.ts.map +1 -1
- package/types/test/shared-modules.d.ts.map +1 -1
- package/types/test/site-types.d.ts +3 -1
- package/types/test/site-types.d.ts.map +1 -1
- package/src/check/schema-type.ts +0 -9
- package/src/compiler/deprecated-script-fence.ts +0 -26
- package/src/server/field-errors.ts +0 -136
- package/types/check/schema-type.d.ts +0 -3
- package/types/check/schema-type.d.ts.map +0 -1
- package/types/compiler/deprecated-script-fence.d.ts +0 -3
- package/types/compiler/deprecated-script-fence.d.ts.map +0 -1
- package/types/server/field-errors.d.ts +0 -6
- package/types/server/field-errors.d.ts.map +0 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { RouteRecord } from './kay-routes'
|
|
2
|
+
import { AsyncLocalStorage } from 'node:async_hooks'
|
|
3
|
+
import { requestCookies } from './cookies'
|
|
4
|
+
import { requestUrl } from './request-url'
|
|
5
|
+
import { Denied } from './signals'
|
|
6
|
+
|
|
7
|
+
// What a handler writes to the answer: the status and the headers, folded into the Response once, at the end. It is apart from `headers`, which reads the request.
|
|
8
|
+
export interface ResponseSet {
|
|
9
|
+
status: number | undefined
|
|
10
|
+
headers: Headers
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type Params = Record<string, string>
|
|
14
|
+
type Fields = Record<string, string | string[]>
|
|
15
|
+
|
|
16
|
+
function addField(fields: Record<string, unknown>, key: string, value: unknown): void {
|
|
17
|
+
const held = fields[key]
|
|
18
|
+
|
|
19
|
+
if (held === undefined)
|
|
20
|
+
fields[key] = value
|
|
21
|
+
else
|
|
22
|
+
fields[key] = Array.isArray(held) ? [...held, value] : [held, value]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// The query as an object, a name given twice holding both values; a name such as `__proto__` is a key like any other.
|
|
26
|
+
function queryOf(url: URL): Fields {
|
|
27
|
+
const fields: Fields = Object.create(null) as Fields
|
|
28
|
+
|
|
29
|
+
for (const [key, value] of url.searchParams)
|
|
30
|
+
addField(fields, key, value)
|
|
31
|
+
|
|
32
|
+
return fields
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// What the body holds as its type says: JSON parsed, a form read into fields (a file kept as a File), text as it is, any other body as bytes, and none as undefined.
|
|
36
|
+
async function readBody(request: Request): Promise<unknown> {
|
|
37
|
+
if (request.body === null)
|
|
38
|
+
return undefined
|
|
39
|
+
|
|
40
|
+
const type = request.headers.get('content-type') ?? ''
|
|
41
|
+
|
|
42
|
+
if (type.startsWith('application/json') || type.includes('+json')) {
|
|
43
|
+
try {
|
|
44
|
+
return await request.json()
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
throw new Denied(400, 'The body is not valid JSON')
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (type.startsWith('application/x-www-form-urlencoded') || type.startsWith('multipart/form-data')) {
|
|
52
|
+
const fields: Record<string, unknown> = Object.create(null) as Record<string, unknown>
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
for (const [key, value] of (await request.formData()).entries())
|
|
56
|
+
addField(fields, key, value)
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
throw new Denied(400, 'The body is not a valid form')
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return fields
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return type.startsWith('text/') ? request.text() : request.arrayBuffer()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// The one context of a request kay answers from its table, whatever the route kind: what it reads of the request is parsed on first read, once.
|
|
69
|
+
export class RequestContext {
|
|
70
|
+
readonly request: Request
|
|
71
|
+
// The route's params, decoded once from the path, empty while `malformed`.
|
|
72
|
+
readonly params: Params
|
|
73
|
+
// Whether a param held an escape that does not decode, which the `input` phase refuses with a 400.
|
|
74
|
+
readonly malformed: boolean
|
|
75
|
+
readonly locale: string | undefined
|
|
76
|
+
readonly route: RouteRecord | undefined
|
|
77
|
+
// What the phases before the handler hand on, such as a plugin's or a guard's values.
|
|
78
|
+
readonly locals: Record<string, unknown> = Object.create(null) as Record<string, unknown>
|
|
79
|
+
#query: Fields | undefined
|
|
80
|
+
#body: Promise<unknown> | undefined
|
|
81
|
+
#set: ResponseSet | undefined
|
|
82
|
+
|
|
83
|
+
constructor(request: Request, route: RouteRecord | undefined, params: Params | undefined, locale?: string) {
|
|
84
|
+
this.request = request
|
|
85
|
+
this.route = route
|
|
86
|
+
this.malformed = params === undefined
|
|
87
|
+
this.params = params ?? {}
|
|
88
|
+
this.locale = locale ?? route?.locale
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
get url(): URL {
|
|
92
|
+
return requestUrl(this.request)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
get method(): string {
|
|
96
|
+
return this.request.method
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// The request's headers; the answer's are written through `set`.
|
|
100
|
+
get headers(): Headers {
|
|
101
|
+
return this.request.headers
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
get query(): Fields {
|
|
105
|
+
return this.#query ??= queryOf(this.url)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
get cookies(): Pick<Bun.CookieMap, 'get' | 'has'> {
|
|
109
|
+
return requestCookies(this.request)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// The parsed body, a promise as reading it waits for the bytes; a malformed one refuses with a 400 when it is read.
|
|
113
|
+
get body(): Promise<unknown> {
|
|
114
|
+
return this.#body ??= readBody(this.request)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Made when the handler first writes to it, so a route that sets nothing allocates nothing.
|
|
118
|
+
get set(): ResponseSet {
|
|
119
|
+
return this.#set ??= { status: undefined, headers: new Headers() }
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// The answer's status and headers a handler set, if it set any.
|
|
123
|
+
get written(): ResponseSet | undefined {
|
|
124
|
+
return this.#set
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const scopes = new AsyncLocalStorage<RequestContext>()
|
|
129
|
+
|
|
130
|
+
// The context of the request kay is answering in this async context, a handler running after a macrotask included.
|
|
131
|
+
export function requestContext(): RequestContext | undefined {
|
|
132
|
+
return scopes.getStore()
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function inContext<T>(context: RequestContext, run: () => T): T {
|
|
136
|
+
return scopes.run(context, run)
|
|
137
|
+
}
|
|
@@ -40,7 +40,7 @@ export function refusals(check: TypeCheck<TSchema>, value: unknown, keyOf: (poin
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// A block of a `blocks()` list that fails is reported by the fields of its own type, as the union of all the types would only say the item is not valid; a block naming no declared type keeps the union's error.
|
|
43
|
-
function* withoutBlockUnions(issues: Iterable<ValueError>): Generator<ValueError> {
|
|
43
|
+
export function* withoutBlockUnions(issues: Iterable<ValueError>): Generator<ValueError> {
|
|
44
44
|
for (const issue of issues) {
|
|
45
45
|
const own = variantOf(issue)
|
|
46
46
|
|
package/src/server/scope.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Outcome } from '../runtime/action'
|
|
2
2
|
import type { QueryRules } from '../runtime/query-param'
|
|
3
|
-
import type { ServerScope } from '../runtime/reactive'
|
|
3
|
+
import type { LoadScope, ServerScope } from '../runtime/reactive'
|
|
4
4
|
import { AsyncLocalStorage } from 'node:async_hooks'
|
|
5
5
|
import { setRequestOutcome } from '../runtime/action'
|
|
6
6
|
import { setEndedEntryNote } from '../runtime/ended-entry'
|
|
7
7
|
import { readParam } from '../runtime/query-param'
|
|
8
|
-
import { setServerScope } from '../runtime/reactive'
|
|
8
|
+
import { setRequestCookieScope, setServerScope } from '../runtime/reactive'
|
|
9
9
|
import { setCurrentUrl } from '../runtime/with-query'
|
|
10
10
|
import { requestCookies } from './cookies'
|
|
11
11
|
import { requestUrl } from './request-url'
|
|
@@ -17,30 +17,37 @@ const store = new AsyncLocalStorage<ServerScope>()
|
|
|
17
17
|
|
|
18
18
|
setServerScope(() => store.getStore())
|
|
19
19
|
|
|
20
|
-
// The page a load answers, which runs before the render's scope is made.
|
|
21
|
-
const
|
|
20
|
+
// The page a load answers and the cookies it reads, which runs before the render's scope is made.
|
|
21
|
+
const loads = new AsyncLocalStorage<{ url: URL, scope: LoadScope }>()
|
|
22
22
|
|
|
23
|
-
setCurrentUrl(() =>
|
|
23
|
+
setCurrentUrl(() => loads.getStore()?.url ?? (store.getStore()?.request === undefined ? undefined : requestUrl(store.getStore()!.request!)))
|
|
24
|
+
setRequestCookieScope(() => loads.getStore()?.scope)
|
|
24
25
|
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
// `cookieRead` runs once the load read a cookie, the page then depending on it.
|
|
27
|
+
// Runs a page's or a layout's load, which reads the page it answers through `withQuery`, and a persisted cookie signal through the request's cookies, as the render reads them.
|
|
28
|
+
export function inLoad<T>(url: URL, request: Request, cookieRead: () => void, run: () => T): T {
|
|
29
|
+
return loads.run({ url, scope: { cookie: cookieReader(request, cookieRead) } }, run)
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
export function inServerScope<T>(request: Request, report: (error: unknown) => void, run: () => T, cookieRead?: () => void, rules?: QueryRules): T {
|
|
32
|
+
// Reads the request's cookies on the first call, which makes the page depend on them, then `first` runs.
|
|
33
|
+
function cookieReader(request: Request, first?: () => void): (name: string) => string | undefined {
|
|
33
34
|
let cookies: ReturnType<typeof requestCookies> | undefined
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
return (name) => {
|
|
36
37
|
if (!cookies) {
|
|
37
38
|
cookies = requestCookies(request)
|
|
38
39
|
personal.add(request)
|
|
39
|
-
|
|
40
|
+
first?.()
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
return cookies.get(name) ?? undefined
|
|
43
44
|
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Renders for `request`: a module's signals keep what this render writes to itself, persisted signals read its cookies and query, `queryParam` its query by the page's `rules`, and a `try` block reports what it caught.
|
|
48
|
+
// `cookieRead` runs once a persisted signal read a cookie, the page then depending on it.
|
|
49
|
+
export function inServerScope<T>(request: Request, report: (error: unknown) => void, run: () => T, cookieRead?: () => void, rules?: QueryRules): T {
|
|
50
|
+
const cookie = cookieReader(request, () => cookieRead?.())
|
|
44
51
|
|
|
45
52
|
const url = requestUrl(request)
|
|
46
53
|
|
package/src/server/signals.ts
CHANGED
|
@@ -88,16 +88,16 @@ export function stoppers(request: Request): Pick<RequestContext, 'redirect' | 'n
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
// `ctx.deny(status, { errors, data })` in an action fails the post as `ctx.fail` does, a form re-rendered with the fields and `data`, a call throwing an `ActionError`. A
|
|
91
|
+
// `ctx.deny(status, { message, errors, data })` in an action fails the post as `ctx.fail` does, a form re-rendered with the message, the fields and `data`, a call throwing an `ActionError`. A deny with no options, or the old text form, stops as a guard's does.
|
|
92
92
|
export function actionStoppers(request: Request): Pick<RequestContext, 'redirect' | 'notFound' | 'deny'> {
|
|
93
93
|
const { deny: stop, ...rest } = stoppers(request)
|
|
94
94
|
|
|
95
95
|
const deny = (status = 403, second?: string | DenyOptions<ErrorData>, data?: ErrorData): never => {
|
|
96
|
-
if (typeof second === 'string' || status < 400 || status > 599)
|
|
96
|
+
if (typeof second === 'string' || !Number.isInteger(status) || status < 400 || status > 599)
|
|
97
97
|
return stop(status, second as string, data)
|
|
98
98
|
|
|
99
|
-
if (second === undefined || (second.data === undefined && Object.keys(second.errors ?? {}).length === 0))
|
|
100
|
-
return stop(status
|
|
99
|
+
if (second === undefined || ((second.message === undefined || second.message === '') && second.data === undefined && Object.keys(second.errors ?? {}).length === 0))
|
|
100
|
+
return stop(status)
|
|
101
101
|
|
|
102
102
|
// A text `data` with no `message` is the form's message, as `ctx.fail` made it; one with only data or fields has no form message, as `ctx.fail` had none.
|
|
103
103
|
throw new RefusedError({ status, message: second.message ?? (typeof second.data === 'string' ? second.data : ''), errors: (second.errors ?? {}) as Record<string, string>, data: second.data })
|
package/src/server/socket.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Elysia } from 'elysia'
|
|
2
|
-
import {
|
|
2
|
+
import type { Issue } from './validate'
|
|
3
3
|
import { ElysiaWS } from 'elysia/ws'
|
|
4
4
|
import { underKayDev } from '../build/assets'
|
|
5
5
|
import { KayError } from '../compiler/errors'
|
|
6
6
|
import { kayLog } from '../runtime/log'
|
|
7
|
-
import { refusedFields } from './field-errors'
|
|
8
7
|
import { bindReply } from './rooms'
|
|
8
|
+
import { isRefusal, messagesOf, validate } from './validate'
|
|
9
9
|
import { kayWord } from './words'
|
|
10
10
|
import { admissionOf, frameGuard } from './ws-limits'
|
|
11
11
|
|
|
@@ -27,7 +27,7 @@ export interface SocketRoute {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
type Peer = ElysiaWS
|
|
30
|
-
type Checked = { value: unknown } | { refused:
|
|
30
|
+
type Checked = { value: unknown } | { refused: Issue[] } | Promise<{ value: unknown } | { refused: Issue[] }>
|
|
31
31
|
|
|
32
32
|
interface Replying {
|
|
33
33
|
validator?: { provider?: string, Check?: (value: unknown) => boolean, schema?: { '~standard': { validate: (value: unknown) => unknown } } }
|
|
@@ -154,7 +154,7 @@ export async function adopt(ws: ElysiaWS, route: SocketRoute): Promise<ElysiaWS>
|
|
|
154
154
|
const checked = route.check === undefined ? undefined : await route.check(decoded.value)
|
|
155
155
|
|
|
156
156
|
if (checked && 'refused' in checked) {
|
|
157
|
-
socket.send(refusal('kay.socket.invalid',
|
|
157
|
+
socket.send(refusal('kay.socket.invalid', messagesOf(checked.refused)))
|
|
158
158
|
|
|
159
159
|
return undefined
|
|
160
160
|
}
|
|
@@ -249,62 +249,34 @@ interface BodyCheck {
|
|
|
249
249
|
check: NonNullable<SocketRoute['check']>
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
// The `body` of a websocket route as an HTTP route's: a message
|
|
253
|
-
// Elysia's validation is left out of the route and done here,
|
|
252
|
+
// The `body` of a websocket route as an HTTP route's: a message is a JSON value, read as the schema types it, and one the schema refuses is answered with the fields it names.
|
|
253
|
+
// Elysia's validation is left out of the route and done here, by `validate`.
|
|
254
254
|
export function socketBody(app: Elysia, body: unknown, name: () => string): BodyCheck | undefined {
|
|
255
255
|
if (body === undefined)
|
|
256
256
|
return undefined
|
|
257
257
|
|
|
258
|
-
const { definitions } = app as unknown as { definitions: {
|
|
259
|
-
const
|
|
258
|
+
const { definitions } = app as unknown as { definitions: { type: Record<string, unknown> } }
|
|
259
|
+
const schema = typeof body === 'string' ? definitions.type[body] : body
|
|
260
260
|
|
|
261
|
-
if (
|
|
261
|
+
if (typeof schema !== 'object' || schema === null)
|
|
262
262
|
return undefined
|
|
263
263
|
|
|
264
264
|
let loggedAt = 0
|
|
265
265
|
|
|
266
|
-
// Under `kay dev` only, and at most once a second per route: the sender is told which fields, the developer which route, in quotes as what a client sent may hold control codes.
|
|
267
|
-
const refuse = (refused: ValidationError): { refused: ValidationError, schema: unknown } => {
|
|
268
|
-
if (underKayDev() && performance.now() - loggedAt >= 1000) {
|
|
269
|
-
loggedAt = performance.now()
|
|
270
|
-
kayLog('warn', `the websocket route ${JSON.stringify(name())} refused a message of its body: ${JSON.stringify(refused.all[0]?.summary ?? 'it does not match')}`)
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
return { refused, schema: body }
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
if (validator.provider === 'standard') {
|
|
277
|
-
return {
|
|
278
|
-
check: async (value) => {
|
|
279
|
-
const result = await (validator as unknown as { schema: { '~standard': { validate: (value: unknown) => Promise<{ issues?: never[], value?: unknown }> | { issues?: never[], value?: unknown } } } }).schema['~standard'].validate(value)
|
|
280
|
-
|
|
281
|
-
return result.issues ? refuse(new ValidationError('message', validator, value, false, result.issues as never)) : { value: result.value }
|
|
282
|
-
},
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
266
|
return {
|
|
287
|
-
check: (value) => {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
// A structure the cleaner cannot walk is refused as a failed check is, never passed on unstripped.
|
|
291
|
-
try {
|
|
292
|
-
cleaned = validator.Clean?.(value) ?? value
|
|
293
|
-
}
|
|
294
|
-
catch {
|
|
295
|
-
return refuse(new ValidationError('message', validator, value))
|
|
296
|
-
}
|
|
267
|
+
check: async (value) => {
|
|
268
|
+
const result = await validate(schema, value, { source: 'json' })
|
|
297
269
|
|
|
298
|
-
if (
|
|
299
|
-
return
|
|
270
|
+
if (!isRefusal(result))
|
|
271
|
+
return { value: result.value }
|
|
300
272
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
// A transform that refuses the value is a refused message too.
|
|
306
|
-
return refuse(new ValidationError('message', validator, cleaned))
|
|
273
|
+
// Under `kay dev` only, and at most once a second per route: the sender is told which fields, the developer which route, in quotes as what a client sent may hold control codes.
|
|
274
|
+
if (underKayDev() && performance.now() - loggedAt >= 1000) {
|
|
275
|
+
loggedAt = performance.now()
|
|
276
|
+
kayLog('warn', `the websocket route ${JSON.stringify(name())} refused a message of its body: ${JSON.stringify(result.errors[0]?.message ?? 'it does not match')}`)
|
|
307
277
|
}
|
|
278
|
+
|
|
279
|
+
return { refused: result.errors }
|
|
308
280
|
},
|
|
309
281
|
}
|
|
310
282
|
}
|
package/src/server/stream.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { SWAP_SCRIPT } from './swap'
|
|
|
18
18
|
import { workScript } from './work'
|
|
19
19
|
|
|
20
20
|
const encoder = new TextEncoder()
|
|
21
|
-
const EMPTY: Rendered = { html: '', islands: { used: new Set(), eager: new Set(), immediate: new Set(), waiting: new Set(), lazy: 0, count: 0, messages: new Set() }, deferred: [] }
|
|
21
|
+
const EMPTY: Rendered = { html: '', islands: { used: new Set(), eager: new Set(), immediate: new Set(), waiting: new Set(), lazy: 0, count: 0, messages: new Set(), lazies: new Set() }, deferred: [] }
|
|
22
22
|
|
|
23
23
|
export interface Rendered {
|
|
24
24
|
html: string
|