@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
package/llms/rooms.md
CHANGED
|
@@ -14,7 +14,7 @@ const chats = rooms<{ from: string, text: string }, string>()
|
|
|
14
14
|
|
|
15
15
|
export default api()
|
|
16
16
|
.ws('/:room', {
|
|
17
|
-
body: s.
|
|
17
|
+
body: s.object({ text: s.string() }),
|
|
18
18
|
response: chats.response,
|
|
19
19
|
open(ws) {
|
|
20
20
|
chats.join(ws, ws.data.params.room, ws.data.user.name)
|
|
@@ -70,9 +70,9 @@ const sendBoard = games.coalesce(async room => ({
|
|
|
70
70
|
|
|
71
71
|
export default api()
|
|
72
72
|
.ws('/:room', {
|
|
73
|
-
body: s.
|
|
74
|
-
s.
|
|
75
|
-
s.
|
|
73
|
+
body: s.union([
|
|
74
|
+
s.object({ type: s.literal('say'), text: s.string() }),
|
|
75
|
+
s.object({ type: s.literal('play'), cell: s.int() }),
|
|
76
76
|
]),
|
|
77
77
|
response: games.response,
|
|
78
78
|
open(ws) {
|
|
@@ -31,7 +31,7 @@ export function GET({ params }: EndpointContext) {
|
|
|
31
31
|
import type { EndpointContext } from 'kay'
|
|
32
32
|
import { s } from 'kay'
|
|
33
33
|
|
|
34
|
-
export const page = { rateLimit: { max: 60, window: '1m' }, maxSize: '1mb', query: s.
|
|
34
|
+
export const page = { rateLimit: { max: 60, window: '1m' }, maxSize: '1mb', query: s.object({ test: s.boolean({ optional: true }) }) }
|
|
35
35
|
|
|
36
36
|
export async function POST({ request, query }: EndpointContext) {
|
|
37
37
|
await handleEvent(await request.json(), query.test === true)
|
package/llms/routing.md
CHANGED
|
@@ -25,7 +25,7 @@ The `query` key of `page` is the schema `ctx.query` is read against, so `ctx.que
|
|
|
25
25
|
--- server
|
|
26
26
|
import { s } from 'kay'
|
|
27
27
|
|
|
28
|
-
export const page = { query: s.
|
|
28
|
+
export const page = { query: s.object({ q: s.string(), page: s.int({ optional: true }) }) }
|
|
29
29
|
|
|
30
30
|
const { q, page: current } = ctx.query
|
|
31
31
|
---
|
|
@@ -62,7 +62,7 @@ a(href={route('/blog/:page?', { page: 2 }, { query: { q: 'kay' }, hash: 'top' })
|
|
|
62
62
|
--- server
|
|
63
63
|
import { localPath, s } from 'kay'
|
|
64
64
|
|
|
65
|
-
export const page = { query: s.
|
|
65
|
+
export const page = { query: s.object({ next: s.string({ optional: true }) }) }
|
|
66
66
|
|
|
67
67
|
if (ctx.params.id === 'latest') ctx.redirect(localPath(ctx.query.next, '/todos/42'))
|
|
68
68
|
if (ctx.params.id === 'secret') ctx.deny(403, { message: 'Members only' })
|
|
@@ -257,12 +257,12 @@ export default (value: string) =>
|
|
|
257
257
|
The fence's `ctx`:
|
|
258
258
|
|
|
259
259
|
- `ctx.params`, typed from the file name, `ctx.url`, `ctx.request`
|
|
260
|
-
- `ctx.query`, the search params, read against the schema the page sets as the `query` key of `page`: `export const page = { query: s.
|
|
260
|
+
- `ctx.query`, the search params, read against the schema the page sets as the `query` key of `page`: `export const page = { query: s.object({ q: s.string(), page: s.int({ optional: true }) }) }` types `ctx.query.page` as a `number | undefined`.
|
|
261
261
|
- Each is read as a form field is (a number from decimal text, a list from a repeated name, `true` from `on`), one left out takes its `default`, and a query the schema refuses renders `_error.kay` with status 400, once the guards let the request through.
|
|
262
|
-
- A field with `lenient: true` in its options (`period: s.
|
|
262
|
+
- A field with `lenient: true` in its options (`period: s.enum(['24h', '7d'], { default: '24h', lenient: true })`) reads a value its schema refuses, a stale link's, as its default, or leaves it out when it has none, and `ctx.query` is typed by the real schema (`'24h' | '7d'`); a field without it, or a refused one with no default and required, still answers 400, and an island's `queryParam` already reads a refused value as its default.
|
|
263
263
|
- A layout declares the params it reads the same way, in its own `page`, and the pages under it do not repeat the schema: `ctx.query` is read once against every `query` of the route's layouts and its page merged, so a layout and its page see the same typed values.
|
|
264
264
|
- A layout's `ctx.query` is typed by the layouts above it and its own, a page's by every layout above it and its own.
|
|
265
|
-
- A name two of them declare is accepted when their schemas are the same, and refused when they differ: `kay check` reports it on the later file for schemas written inline as `s.
|
|
265
|
+
- A name two of them declare is accepted when their schemas are the same, and refused when they differ: `kay check` reports it on the later file for schemas written inline as `s.object({ ... })`, and the render fails for any other. The merged schema takes its object keywords, such as `additionalProperties`, from the innermost file.
|
|
266
266
|
- A page with `layouts: false` reads none of the dropped layouts' params. `query` on a special page is reported, "Only a page or a layout declares its query".
|
|
267
267
|
- Without a schema each name reads as its text, a repeated one as a list, typed `unknown`; the raw text is `ctx.url.searchParams`.
|
|
268
268
|
- An island reads and writes one param the same way with `queryParam` (see islands).
|
package/llms/schemas.md
CHANGED
|
@@ -11,7 +11,7 @@ A shape the server validates and an island types is written once, as a schema in
|
|
|
11
11
|
import type { Static } from 'kay'
|
|
12
12
|
import { s } from 'kay'
|
|
13
13
|
|
|
14
|
-
export const choice = s.
|
|
14
|
+
export const choice = s.union([s.literal('smash'), s.literal('pass')])
|
|
15
15
|
export type Choice = Static<typeof choice>
|
|
16
16
|
```
|
|
17
17
|
|
|
@@ -22,7 +22,7 @@ An API module, a server fence and an `_actions.kay` import the schema; an island
|
|
|
22
22
|
import { action, s } from 'kay'
|
|
23
23
|
import { choice } from '../schemas'
|
|
24
24
|
|
|
25
|
-
export const castVerdict = action(
|
|
25
|
+
export const castVerdict = action({ choice }, input => input.choice)
|
|
26
26
|
---
|
|
27
27
|
```
|
|
28
28
|
|
|
@@ -42,11 +42,18 @@ const { initial } = props<{ initial: Choice }>()
|
|
|
42
42
|
|
|
43
43
|
### Schemas
|
|
44
44
|
|
|
45
|
-
- `s` from `kay` is
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
45
|
+
- `s` from `kay` is kay's own schema builder, over TypeBox so a schema stays JSON Schema data for OpenAPI, MCP and the form rules, under a name that leaves `t` to translations: lowercase builders with short options, there to save an import in server fences and server modules, `defineEnv` and API modules included.
|
|
46
|
+
- The builders: `s.string({ min, max, pattern })`, `s.email()`, `s.url()`, `s.slug()`, `s.int({ min, max })`, `s.number({ min, max })`, `s.boolean()`, `s.date()` (read as a `Date`), `s.enum(values)` or `s.enum(record)` (a record gives its keys), `s.literal(value)`, `s.union([a, b])`, `s.object(shape)`, `s.record(value)`, `s.list(item, { min, max })`, `s.file({ type, minSize, maxSize })`, `s.files()`, `s.secret()` and `s.public(field)` (the last two for `defineEnv`).
|
|
47
|
+
- Every builder takes the same field options: `optional: true` (the field may be left out, typed `T | undefined`), `default`, `error` (a text, or a function called in the request's locale), `label`, `description` and `example`. Any other option is a JSON Schema keyword, kept as written.
|
|
48
|
+
- Strict by default: a string is at most 10,000 characters, a list at most 1,000 items and a file size is `'2mb'`, `'600kb'` or bytes, each unless the options give another; `s.object` marks its shape closed, and `s.object(shape, { extra: 'strip' })` leaves it open. What a closed shape does with a key it lacks depends on who reads it: kay refuses it in an action's input, an API route's body, a socket message, `defineEnv`, collection frontmatter and a JSON Schema check by `ask` (a form post drops the fields the schema does not name); a response is read by Elysia, which drops it; the search params of a page or an API route and a request's headers are dropped whatever the shape says, and an API route's `cookie` schema ignores the cookies it does not name, as a third party sets some.
|
|
49
|
+
- A plain record of schemas is the object schema wherever a schema is taken: `action({ title: s.string() }, handler)` and `defineEnv({ PORT: s.int({ default: 3000 }) })`, so `s.object()` is rarely written. A record is strict as `s.object` is, and kay's own form fields (the honeypot, the stamp) are not its keys.
|
|
50
|
+
- Any Standard Schema validator (Zod 4.2+, ArkType 2.1.28+, Valibot) is accepted where a schema is: an action's `input` (typed by its output type) and an API route's `body`, `query`, `params`, `headers` and `cookie`. kay validates through `~standard.validate`, and reads constraints, OpenAPI and MCP from `~standard.jsonSchema.input({ target: 'draft-2020-12' })`; one without it still validates, but a form shows no constraints, a text source (a form, a query) is not read as numbers and booleans, and OpenAPI and MCP show an open schema; `kay check` names a hand-written or valibot one in those positions (`schema-without-json-schema`).
|
|
51
|
+
- `validate(schema, value, { source, locale })` from `kay/server` reads a value as its `source` says (`'form'`, `'query'`, `'params'` and `'env'` text is read as numbers, booleans and lists; `'json'` never is, and a form's or a query's text loses its surrounding spaces unless `trim: false`, as an API route reads it) and answers `{ value }` or, when `'errors' in result`, `{ errors: [{ path, key, params, message }], status: 422 }`: `path` is dotted (`tags.0`), `key` a `kay.invalid.*` message, `message` its text in the locale. `error` on a field is a text, a function, or a record by rule (`{ min, max, pattern, format, required, type, default }`). Nothing depends on `NODE_ENV`.
|
|
52
|
+
- The PascalCase builders of 1.x, `s.String`, `s.Object`, `s.Optional(field)`, `s.UnionEnum`, `s.UnionKeys`, `s.Numeric` and the rest, are Elysia's under their old names and work until 2.0: `kay upgrade` rewrites them (`deprecated-schema-builders`). A schema built with Elysia's `t` is still a `Schema`.
|
|
53
|
+
- `Schema` from `kay` is the type of what `s` builds, and what `action`, `defineEnv`, `collection`, an API route's `query` and a library's schema option take: name it in a signature, never TypeBox's `TSchema`. `Static<typeof schema>` reads the TypeScript type. Elysia and TypeBox are implementation details of kay: `s` has no door to TypeBox's own builders, and a schema it builds is JSON Schema data.
|
|
54
|
+
- The browser has no Elysia, which reads `Bun`: there `s.object(...)` and the rest build the plain JSON Schema of the field, a few lines each, so a module shared by the server and an island may build its schemas as it loads. The builders are a few small functions in the chunk of an island that imports a module building schemas as it loads; a module it imports as a type costs nothing. The PascalCase builders, deprecated, build a schema that accepts anything there.
|
|
55
|
+
- An island validates with the same schema: `validate(schema, value, { source })` from `kay` is the browser's `validate`, answering the same `{ value }` or `{ errors, status: 422 }`, worded in the page's locale (a `locale` option is the server's). Its code is a chunk of its own that the first call loads, so a page's eager JS does not grow and a page whose islands never call it never fetches it. A form is read as text (`'form'`), JSON as it is, defaults fill in, an unknown key is refused as on the server, and a Standard Schema validator is called as it is. A date stays the text it was given, and a file is checked by the server alone, which reads its bytes.
|
|
56
|
+
- An island may also read a schema's type alone: `import type { Choice } from '../schemas'`, or `import type { choice } from '../schemas'` for `Static<typeof choice>`, is erased from the browser build.
|
|
50
57
|
- `Static<typeof schema>` and `InputOf<typeof action>` are types from `kay` and cost the browser nothing.
|
|
51
58
|
- A module holding a value an island needs, a list of choices to draw as buttons, exports it apart from the schema, in a module with no `s`.
|
|
52
59
|
- A schema shared by API modules, server fences and `_actions.kay` lives in a `.ts` module of `src/`, `src/schemas.ts` or a folder of them, imported by its path from each.
|
package/llms/server.md
CHANGED
|
@@ -53,9 +53,9 @@ Mount it from `src/plugins/session.ts` (`export default sessions`, see above), o
|
|
|
53
53
|
--- server
|
|
54
54
|
import { s, action } from 'kay'
|
|
55
55
|
|
|
56
|
-
const credentials = s.
|
|
57
|
-
email: s.
|
|
58
|
-
password: s.
|
|
56
|
+
const credentials = s.object({
|
|
57
|
+
email: s.string({ max: 254 }),
|
|
58
|
+
password: s.string(),
|
|
59
59
|
})
|
|
60
60
|
|
|
61
61
|
export const signIn = action(credentials, async (input, ctx) => {
|
|
@@ -95,10 +95,10 @@ export const signOut = action(async ctx => {
|
|
|
95
95
|
--- server
|
|
96
96
|
import { s, action } from 'kay'
|
|
97
97
|
|
|
98
|
-
const credentials = s.
|
|
99
|
-
email: s.
|
|
100
|
-
password: s.
|
|
101
|
-
remember: s.
|
|
98
|
+
const credentials = s.object({
|
|
99
|
+
email: s.string({ max: 254 }),
|
|
100
|
+
password: s.string(),
|
|
101
|
+
remember: s.boolean({ optional: true }),
|
|
102
102
|
})
|
|
103
103
|
|
|
104
104
|
export const signIn = action(credentials, async (input, ctx) => {
|
package/llms/site.md
CHANGED
|
@@ -37,7 +37,7 @@ import { s } from 'kay'
|
|
|
37
37
|
import { collection } from 'kay/content'
|
|
38
38
|
|
|
39
39
|
export const posts = collection('content/posts', {
|
|
40
|
-
schema: s.
|
|
40
|
+
schema: s.object({ title: s.string(), date: s.date() }),
|
|
41
41
|
})
|
|
42
42
|
```
|
|
43
43
|
|
|
@@ -120,7 +120,7 @@ A page's server fence exports an action, and `form(action={comment})` posts to i
|
|
|
120
120
|
import { s, action } from 'kay'
|
|
121
121
|
|
|
122
122
|
export const comment = action(
|
|
123
|
-
|
|
123
|
+
{ text: s.string({ min: 10, max: 2000 }) },
|
|
124
124
|
async ({ text }) => text.trim(),
|
|
125
125
|
)
|
|
126
126
|
---
|
|
@@ -195,10 +195,10 @@ import { s } from 'kay'
|
|
|
195
195
|
import { collection } from 'kay/content'
|
|
196
196
|
|
|
197
197
|
export const posts = collection('content/posts', {
|
|
198
|
-
schema: s.
|
|
199
|
-
title: s.
|
|
200
|
-
date: s.
|
|
201
|
-
tags: s.
|
|
198
|
+
schema: s.object({
|
|
199
|
+
title: s.string(),
|
|
200
|
+
date: s.date(),
|
|
201
|
+
tags: s.list(s.string(), { default: [] }),
|
|
202
202
|
}),
|
|
203
203
|
})
|
|
204
204
|
```
|
|
@@ -329,9 +329,9 @@ import { s, action } from 'kay'
|
|
|
329
329
|
import { checkComment } from '../comment'
|
|
330
330
|
import CommentForm from '../components/comment-form.kay'
|
|
331
331
|
|
|
332
|
-
const newComment = s.
|
|
333
|
-
name: s.
|
|
334
|
-
text: s.
|
|
332
|
+
const newComment = s.object({
|
|
333
|
+
name: s.string({ max: 100 }),
|
|
334
|
+
text: s.string({ max: 2000 }),
|
|
335
335
|
})
|
|
336
336
|
|
|
337
337
|
export const comment = action(newComment, (input, ctx) => {
|
|
@@ -139,6 +139,7 @@ export default defineConfig({
|
|
|
139
139
|
scope: '/',
|
|
140
140
|
maskable: 'src/favicon-maskable.png',
|
|
141
141
|
shortcuts: [{ name: 'New note', url: '/notes/new' }],
|
|
142
|
+
shareTarget: { action: 'src/routes/share.kay#receive', files: ['image/*'] },
|
|
142
143
|
},
|
|
143
144
|
},
|
|
144
145
|
seo: { name: 'Example' },
|
|
@@ -151,6 +152,7 @@ export default defineConfig({
|
|
|
151
152
|
- `startUrl` is the page the installed app opens, `scope` by default, else `/`, and `scope` the paths it keeps in its window.
|
|
152
153
|
- `startUrl`, `scope` and each shortcut's `url` (`name`, `shortName`, `description`) are paths of the site, put under `base`.
|
|
153
154
|
- One not starting with a single `/`, or a start page or shortcut outside `scope`, which browsers would ignore, stops the server as it boots.
|
|
155
|
+
- `shareTarget` lists the installed app in the share sheet of a device (Chromium browsers, as an installed app): the shared title, text, link and files are posted to `action`, written as the page file and the action's export name (`'src/routes/share.kay#receive'`), or a path of the site (`'/share'`) for a route of your own taking a POST. The action reads `title`, `text`, `url` and `files`, each optional, as any action reads a form: `s.Object({ title: s.Optional(s.String()), url: s.Optional(s.String()), files: s.Optional(s.Files({ maxSize: '5mb' })) })`, and answers with `ctx.redirect('/saved')` to show the person where the share went. `files` lists the kinds taken (`['image/*', '.pdf']`), which posts `multipart/form-data` and lists them in the manifest; without it only text and a link are shared, urlencoded. `params` renames the fields (`{ url: 'link' }`). The action sits under `base` and, like a shortcut, must lie inside `scope` when one is set, `/_kay/action/` included, or the server stops as it boots. A share arrives as a navigation the device starts, sent with no `Origin` and `Sec-Fetch-Site` `none` or `same-origin`, which an action's cross-site check lets through. Android apps often put the link in `text`, so read both. A page file that is no page or layout of the app, or an export that is no action of it, stops the server as it boots, naming the reference.
|
|
154
156
|
- `maskable` names a square image whose subject sits inside the middle 80%, which a launcher may crop to a circle or a squircle.
|
|
155
157
|
- kay serves `maskable` as `/icon-maskable-192.png` and `/icon-maskable-512.png`, listed in the manifest with `purpose: "maskable"`, as it serves the favicon.
|
|
156
158
|
|
|
@@ -113,6 +113,7 @@ export default defineUi({
|
|
|
113
113
|
- `defineUi` is typed from the components `kay check` writes to `.kay/types/kay-ui.d.ts`: each key completes, and a part, a variant or a value the component lacks fails `bun run check`.
|
|
114
114
|
- A variant or value the component's recipe lacks is added to it, with the classes the entry gives: `Badge(tone="brand")` above is valid, and the generated types take `brand` into `tone`'s union (a union written beside the recipe is replaced), so the editor completes it and `bun run check` accepts it. The recipe's `defaults` stay. A boolean, a numeric key and a variant of its own work as in a recipe; a component with no recipe, a generic one, an island and one whose props carry an index signature take added variants too.
|
|
115
115
|
- The component must have parts or a recipe. `kay check` reports an unknown component, part, a value a template passes that neither the recipe nor `src/ui.ts` declares (a type error), a page, a layout or a server-fenced file, two keys naming one component, a class that is not a plain string and a file with no default export. The dev server rebuilds when `src/ui.ts` changes.
|
|
116
|
+
- An extension's `ui` file restyles components in every app listing it ([component libraries](component-libraries.md)); `src/ui.ts` follows no import or spread.
|
|
116
117
|
|
|
117
118
|
### Serve a file at a fixed path
|
|
118
119
|
|
|
@@ -155,7 +156,7 @@ p {result()}
|
|
|
155
156
|
|
|
156
157
|
### Link or inline the stylesheets
|
|
157
158
|
|
|
158
|
-
In production a page writes its stylesheets into its head as `style` elements while together they compress under about 14 KB, so
|
|
159
|
+
In production a page writes its stylesheets into its head as `style` elements while together they compress under about 14 KB, so first paint waits for no request, and above it links a cut copy without the rules of components it never renders. `client.inlineStyles` forces one way:
|
|
159
160
|
|
|
160
161
|
```ts
|
|
161
162
|
import { defineConfig } from 'kay/server'
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
- Bound to anything else, a computed string, a template literal with values in it or a name typed as a string literal included, `kay check` and the editor report it unless the value is a `SafeHtml`, which `sanitizeHtml(markup)` and `trustHtml(markup)` from `kay` return; at runtime an `innerHTML` string nothing vouched for is dropped, even past a cast (`srcdoc` is a check-time rule only).
|
|
50
50
|
- `sanitizeHtml` is for markup a user wrote: it keeps `p`, `br`, `hr`, `b`, `strong`, `i`, `em`, `u`, `s`, `del`, `ins`, `small`, `sub`, `sup`, `code`, `pre`, `blockquote`, `h1` to `h6`, `ul`, `ol`, `li` and `a`, balanced and without attributes, a link's `href` kept when it is an http(s), `mailto:` or site URL and given `rel="nofollow ugc"`.
|
|
51
51
|
- It drops other tags, keeping their text, and `script`, `style`, `iframe`, `svg` and comments whole, and gives the same result on the server and in an island.
|
|
52
|
-
- A second argument keeps more: `sanitizeHtml(html, { tags: ['img', 'table', 'thead', 'tbody', 'tr', 'th', 'td'], attributes: { img: ['src', 'alt', 'title'] } })` keeps images and tables, a URL, such as an `href`, a `src`, a `poster` or each one of a `srcset`, only when it is an http(s), `mailto:` or site URL; `relativeUrls: true` also keeps one with no scheme, `./a.png` or `page?x=1`.
|
|
52
|
+
- A second argument keeps more: `sanitizeHtml(html, { tags: ['img', 'table', 'thead', 'tbody', 'tr', 'th', 'td'], attributes: { img: ['src', 'alt', 'title'] } })` keeps images and tables (`code: ['class']` keeps only a `language-*` class on `code`), a URL, such as an `href`, a `src`, a `poster` or each one of a `srcset`, only when it is an http(s), `mailto:` or site URL; `relativeUrls: true` also keeps one with no scheme, `./a.png` or `page?x=1`.
|
|
53
53
|
- A link in the result that leaves the site, another origin than the app's, opens in a new tab like a template's: `target="_blank"`, `rel="nofollow ugc noopener"` and `data-new-tab`, nothing under `client: { links: { outside: 'same-tab' } }`, nor for a link that keeps a `target` the options let it write. A kept `target` other than `_self` adds `noopener` to its `rel`.
|
|
54
54
|
- Markup fetched from elsewhere, such as a feed's body, passes the address it came from as `base`: `sanitizeHtml(body, { base: article.url, tags: ['img'], attributes: { img: ['src'] } })` resolves every kept URL (`href`, `src`, each of a `srcset`, `//host` ones too) as a browser would and drops one that does not resolve to an http(s) or `mailto:` URL, so a link to the base's own site counts as leaving yours. A `base` that is no absolute http(s) URL drops every relative URL; `base` replaces `relativeUrls`.
|
|
55
55
|
- `lazyImages: true` writes `loading="lazy"` on every kept `img` with no `loading` of its own, even when `attributes` does not list `loading`; an `img` that keeps a `loading` keeps it as written.
|
|
@@ -140,6 +140,6 @@ List(items={todos})
|
|
|
140
140
|
- It is scoped as a template `const` is: the lines after it at its indentation and their children see it, its own lines included, so it can call itself for a tree, and a later snippet can call an earlier one; an `@name` block after it among a component's children does not see it. Above its declaration or outside its block the name is unknown, and `kay check` reports it.
|
|
141
141
|
- A name another snippet, an import, a script const, a prop or a loop variable already holds is reported at the snippet, and assigning one is refused.
|
|
142
142
|
- It can hold components, a bare `slot` of the component declaring it, `if`, `for`, `await`, `match` and other snippets, and is a plain function, so `List(row={feature})` passes it where a prop takes a function, which the component renders with `slot row(item, i)`.
|
|
143
|
-
- An `error` or `pending` line in a snippet follows the form the snippet is rendered in while it renders, as one in a component does, unless the form it is declared in is around it, which it keeps reading. In an island
|
|
143
|
+
- An `error` or `pending` line in a snippet follows the form the snippet is rendered in while it renders, as one in a component does, unless the form it is declared in is around it, which it keeps reading. In an island the snippet, like the children a component is given, takes the form it is called in once, as it is called, so a line inside an `await` block or an `if` shown later reads the same form, and a snippet declared outside the form works as one declared inside; call it in the form's own markup, `{note()}` or inside a larger expression. A component an `await` or an `if` of the snippet shows later reads no form: put the line in the snippet itself. `add.form.error('title')` and `add.pending()` take the action from anywhere.
|
|
144
144
|
- A static component passing one to an island is the `island-prop` error, as it is for a `@row(item)` block.
|
|
145
145
|
- Markup used by several files is a component; a snippet is for one file.
|
package/llms/testing-browser.md
CHANGED
|
@@ -31,6 +31,26 @@ const page = await site.open('/account', { cookies: cookie })
|
|
|
31
31
|
expect(await page.path()).toBe('/account')
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
+
### Check accessibility and snapshot HTML without a browser
|
|
35
|
+
|
|
36
|
+
A visited page (`site.visit`, `site.submit`) and a component from `mountComponent` have `a11y(selector?)` and `matchHtml(name)` too, with no Chrome:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
const page = await site.visit('/pricing')
|
|
40
|
+
|
|
41
|
+
expect(await page.a11y()).toEqual([])
|
|
42
|
+
await page.matchHtml('pricing')
|
|
43
|
+
|
|
44
|
+
const { a11y } = await mountComponent(Menu, { items })
|
|
45
|
+
|
|
46
|
+
expect(await a11y()).toEqual([])
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- `a11y` runs the same axe-core as the browser page's and resolves with the same violations, in a happy-dom document of its own: a visit's scripts never run, and what needs a browser's layout (`color-contrast`, `target-size`, `scrollable-region-focusable`) is left to `page.a11y()` of `site.open`. A mounted component checks its own element, so the rules about a whole page (a heading, a landmark, the title) do not apply to it.
|
|
50
|
+
- It needs `axe-core` (`kay new` adds it) and, for a visit, `@happy-dom/global-registrator`, which `mountComponent` needs already; a test fails naming the `bun add -d` command when one is missing.
|
|
51
|
+
- `matchHtml(name)` compares the HTML with the baseline `__html__/<test file>/<name>.html` beside the test file, written when there is none and rewritten by `KAY_UPDATE_SNAPSHOTS=1 bun test`, a `CI` run failing for a missing one; a difference writes `<name>.actual.html` beside it and names the first line that differs.
|
|
52
|
+
- The snapshot is normalised, so it holds the page and not the build: comments (hydration markers) are left out, the hash in a built file's name (`app-4n8x3k2m.css`) and in a `?v=` is `HASH`, a `nonce` is `NONCE`, the stamp of a `minTime` form is `STAMP`, and each tag or run of text is one indented line, `script`, `style`, `pre` and `textarea` kept as written.
|
|
53
|
+
|
|
34
54
|
## Reference
|
|
35
55
|
|
|
36
56
|
### Browser tests
|
package/llms/testing.md
CHANGED
|
@@ -198,7 +198,7 @@ it('shows why a todo was refused', async () => {
|
|
|
198
198
|
- `testSite({ config: { proxy: { key: { secret: 'secret' } } } })` of an app setting `proxy.key` turns the key check on for that site alone, with no `KAY_PROXY_KEY` written to `process.env` (`config` takes `mcp.token` too, as literals; `proxyKey` and `mcpKey` work until 1.108): `fetch`, `visit`, `call`, `mcp` and `socket` send the key in the header `proxy.key.header` names, a call's own header of that name wins (`{ headers: { 'x-upstream-key': 'wrong' } }`), and `''` sends none, so `await site.fetch('/', { headers: { 'x-upstream-key': '' } })` reads the 403. The key is trimmed, must not be blank, and it throws with `dev: true` or `browser` (whose `open()` sends no key).
|
|
199
199
|
- A project setting no `site`, nor `SITE_URL`, is served as `http://localhost`, so a page reading `siteUrl()` or `siteOrigin()` renders as it does in production.
|
|
200
200
|
- `site.submit(action, fields, { from })` posts a form without JavaScript, as multipart with any `File` among its fields, and follows it back to its page, or reads the page a refused post renders.
|
|
201
|
-
- An action declared with no input takes `{}` or no fields: `site.submit(forget, {}, { from })`, with no empty `s.
|
|
201
|
+
- An action declared with no input takes `{}` or no fields: `site.submit(forget, {}, { from })`, with no empty `s.object({})` given for the type's sake.
|
|
202
202
|
- `from` may be a page `visit` or `submit` resolved with instead of a path: the post goes where its form posts, from the URL the browser shows it at.
|
|
203
203
|
- A path as `from` is visited first, so a `workChallenge` field of the form on that page is solved as it is for a page: one extra GET per submit.
|
|
204
204
|
- So `site.submit(add, fields, { from: refused })` posts again from the page a refused post answered, as a visitor fixing the form does.
|
|
@@ -6,7 +6,7 @@ What 1.105 changed in kay.config.ts, the hooks, the stores and the guards of fea
|
|
|
6
6
|
|
|
7
7
|
### Secrets are one shape
|
|
8
8
|
|
|
9
|
-
`deprecated-secret-keys` (`kay check --fix`) renames `mcp: { key }` to `mcp: { token }` and writes `proxy: { key: 'x-upstream-key' }` as `proxy: { key: { header: 'x-upstream-key' } }`; the old keys work until 1.108. The loaded `KayConfig` has `mcp.token` and `proxy.key` as `{ header, secret? }` only, so code reading `config.mcp.key` or a string `config.proxy.key` reads the new fields. A secret is a string, `{ env: 'NAME' }` or `{ file: 'path' }`. One behaviour changes with the rename: `mcp.key: { file }` read `KAY_MCP_KEY` first, and `mcp.token: { file }` reads the file alone (`token: true` still reads the environment). `testSite({ mcpKey, proxyKey })` still work until 1.108 and `kay check` reports them:
|
|
9
|
+
`deprecated-secret-keys` (`kay check --fix`) renames `mcp: { key }` to `mcp: { token }` and writes `proxy: { key: 'x-upstream-key' }` as `proxy: { key: { header: 'x-upstream-key' } }`; the old keys work until 1.108. The loaded `KayConfig` has `mcp.token` and `proxy.key` as `{ header, secret? }` only, so code reading `config.mcp.key` or a string `config.proxy.key` reads the new fields. A secret is a string, `{ env: 'NAME' }` or `{ file: 'path' }`. One behaviour changes with the rename: `mcp.key: { file }` read `KAY_MCP_KEY` first, and `mcp.token: { file }` reads the file alone (`token: true` still reads the environment). `testSite({ mcpKey, proxyKey })` still work until 1.108 and `kay check` reports them: `kay check --fix` moves them into `config: { mcp: { token }, proxy: { key: { header, secret } } }`, `proxyKey` where the app's config names the header and no `config` is written yet, and the rest is by hand. The `config` of a `KayExtension` takes the keys of before 1.105 (`fonts`, `favicon`, `observe`...) as `kay.config.ts` does, until 1.108 under `deprecated-config-groups`.
|
|
10
10
|
|
|
11
11
|
### `links`, `offline` and `search` are keys of `client`
|
|
12
12
|
|
|
@@ -14,7 +14,7 @@ What 1.105 changed in kay.config.ts, the hooks, the stores and the guards of fea
|
|
|
14
14
|
|
|
15
15
|
### Every route the config moves is a key of `endpoints`, and `mcp` and `metrics` are under `/_kay`
|
|
16
16
|
|
|
17
|
-
`serve.apiPrefix` is `endpoints.api`, and the `path` of `openapi`, `mcp`, `health`, `metrics` and `jobs` is `endpoints.openapi`, `.mcp`, `.health`, `.metrics` and `.jobs`; `openapi.referencePath` is `openapi: { reference: { path } }`. `deprecated-route-keys` (`kay check --fix`) rewrites them, the old keys work until 1.108, and the loaded `KayConfig` no longer has them (read `config.endpoints?.api` for `config.serve?.apiPrefix`). The defaults move: the MCP endpoint is `/_kay/mcp` and the metrics `/_kay/metrics`, where they were `/mcp` and `/metrics`. An app that did not set the path keeps the old URL answering until 1.108, `/mcp`
|
|
17
|
+
`serve.apiPrefix` is `endpoints.api`, and the `path` of `openapi`, `mcp`, `health`, `metrics` and `jobs` is `endpoints.openapi`, `.mcp`, `.health`, `.metrics` and `.jobs`; `openapi.referencePath` is `openapi: { reference: { path } }`. `deprecated-route-keys` (`kay check --fix`) rewrites them, the old keys work until 1.108, and the loaded `KayConfig` no longer has them (read `config.endpoints?.api` for `config.serve?.apiPrefix`). The defaults move: the MCP endpoint is `/_kay/mcp` and the metrics `/_kay/metrics`, where they were `/mcp` and `/metrics`. An app that did not set the path keeps the old URL answering: `/metrics` answers as well until 1.108, and `/mcp` answers the MCP endpoint in place (not redirected) until 2.0, unless the app serves something there; point MCP clients and the metrics collector at the new path, or set `endpoints: { mcp: '/mcp', metrics: '/metrics' }` to keep them. The OAuth resource an MCP client signed in for is the endpoint's URL, so a client that registered for `/mcp` signs in again for `/_kay/mcp`.
|
|
18
18
|
|
|
19
19
|
### `defineContext` from `kay/server`, `env` is `envFiles`
|
|
20
20
|
|
package/llms/upgrading.md
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
# Upgrading
|
|
2
2
|
|
|
3
|
-
What each
|
|
3
|
+
What each release breaks, and what an app changes to move to it. kay and its libraries share one version, so one section covers them all; a patch breaks nothing, and a version missing here broke nothing. Through 1.x a breaking change ships in a minor; from 2.0.0 it ships in a major, and a minor or a patch breaks nothing.
|
|
4
|
+
|
|
5
|
+
## 1.107.0
|
|
6
|
+
|
|
7
|
+
### `TSchema` is gone from `kay/library`
|
|
8
|
+
|
|
9
|
+
Import `Schema` from `kay/library` instead, kay's own name for what `s` builds; `kay upgrade` on 1.106 rewrote the import and its uses. The `deprecated-schema-type` lint is gone with it.
|
|
10
|
+
|
|
11
|
+
### `--- script` opening a file is an error
|
|
12
|
+
|
|
13
|
+
A file opens its script with `---`; `--- script` is only for a script that follows a `--- server`, `--- module` or `--- style` fence. The `deprecated-script-fence` lint is gone, and `--- script` first in a file is a `fence-invalid` error whose safe fix `kay check --fix` applies.
|
|
14
|
+
|
|
15
|
+
### `action({ input, ...options }, handler)`
|
|
16
|
+
|
|
17
|
+
An action takes its options first, with its input in them, as an API route does: `action({ input: { title: s.string() }, maxSize: '1mb' }, handler)`. `action(schema, handler, options)` and `action(handler, options)` work until 2.0; `kay upgrade` rewrites them (`deprecated-action-options`).
|
|
18
|
+
|
|
19
|
+
### One validation for every input
|
|
20
|
+
|
|
21
|
+
Actions, API routes, sockets and `defineEnv` read their input through one `validate(schema, value, { source })`. Text sources (a form, a query, path params, the environment) are read as the numbers, booleans and lists they spell, and a JSON body never is: an action called from an island, a socket message and an API route's JSON body that sent `'3'` for an int, or `'true'` for a boolean, are refused where Elysia's schemas let them by. An object refuses a key its shape lacks in JSON (`extra: 'strip'` drops it, as `s.Object` of the old builders still does); a query, the headers and the cookies of a request still drop theirs. A form post drops the fields the schema does not name (a named submit button, a widget), as a browser sends controls the app does not own. `validate` answers `{ errors: [{ path, key, params, message }], status: 422 }` worded in the request's locale and independent of `NODE_ENV`; an action's or API route's answer still carries `errors` as a `{ field: message }` map. An API route's refusal reaches an `onError` as an error with code `VALIDATION` whose `all` lists `path`, `message` and `summary`. No lint can find the app that sends such a key or such a JSON value, as it depends on what a request carries.
|
|
22
|
+
|
|
23
|
+
## 1.106.0
|
|
24
|
+
|
|
25
|
+
### `s` is kay's own builder, in lowercase
|
|
26
|
+
|
|
27
|
+
`s.string({ min, max })`, `s.int()`, `s.enum()`, `s.object()` and the rest replace the PascalCase builders of Elysia, each taking the same field options (`optional: true`, `default`, `error`, `label`, `description`, `example`); `s.Optional(field)` is `optional: true` in the field's options, `s.UnionEnum` and `s.UnionKeys` are `s.enum`, `s.Numeric` is `s.number`, and `s.typebox` is gone: `s` builds a schema of its own, over TypeBox, and a schema built with Elysia's `t` is still taken. The old names work until 2.0, and `kay upgrade` rewrites them (`deprecated-schema-builders`, [schemas](schemas.md#schemas)). A file size of a file field is `'2mb'`, never `'2m'`. Two things differ in the new builders, which the fix does not hide: `s.object` refuses a key its shape lacks, where `s.Object` let it by (`{ extra: 'strip' }` keeps the old way; see [schemas](schemas.md#schemas) for where it refuses), and `s.list` is at most 1,000 items unless `max` says more. An unknown key of a query, the headers or the cookies is dropped, whatever the schema says, as a link or a proxy adds some; `s.Object` of a collection's frontmatter now refuses a key its shape lacks, so an entry with an extra key fails the build until the schema says `{ extra: 'strip' }`. An `action` or a `defineEnv` takes the record of fields where it took `s.Object({ ... })`, and the fix writes it.
|
|
28
|
+
### `@kaynooo/eslint` 8
|
|
29
|
+
|
|
30
|
+
kay and `kay new` use `@kaynooo/eslint` 8, which has no formatters (Prettier, oxfmt and dprint, about 30 MB, are no longer installed): run `bun add -d @kaynooo/eslint@^8`, and drop a `formatters` option from `eslint.config.ts` if it sets one. `kay fmt` formats as before.
|
|
31
|
+
### `sanitizeHtml` keeps only `language-*` classes on `code`
|
|
32
|
+
|
|
33
|
+
A call with `attributes: { code: ['class'] }` now keeps a `code` element's class only when it is `language-` and a language name (`language-ts`, `language-c++`); any other class is dropped. Style the element by its parent or by `[class^='language-']` instead of a class of your own on `code`.
|
|
4
34
|
|
|
5
35
|
## 1.105.0
|
|
6
36
|
|
|
@@ -19,7 +49,11 @@ Every group lists with `list`, reads with `get`, writes with `create` and `updat
|
|
|
19
49
|
|
|
20
50
|
### An island's call answers a result
|
|
21
51
|
|
|
22
|
-
`await add(input)` and `await call(api, '/path')` from an island resolved with the data and threw `ActionError` or `ApiError` for a refusal. They resolve `{ ok: true, data }` or `{ ok: false, status, message, errors, data, error }` now, and throw for no visitor's mistake: a refusal, a handler that threw, a network failure and a timeout (status 0) are results; an abort and a redirect still reject. `kay check`
|
|
52
|
+
`await add(input)` and `await call(api, '/path')` from an island resolved with the data and threw `ActionError` or `ApiError` for a refusal. They resolve `{ ok: true, data }` or `{ ok: false, status, message, errors, data, error }` now, and throw for no visitor's mistake: a refusal, a handler that threw, a network failure and a timeout (status 0) are results; an abort and a redirect still reject. `kay check` reports where the old result is used as the data (`deprecated-call-result`, `deny`): `kay check --fix` writes `.orThrow()` after a call written on an imported name whose answer nothing reads `ok`, `data` or `error` of, and offers it otherwise. Write `const { ok, data } = await add(input)`, or append `.orThrow()` to keep the throwing style: `const id = await add(input).orThrow()` resolves the data and throws what the call threw (an `ActionError`, or an `ApiError` of status 0 for a call with no answer). A `try` around a call whose `catch` shows the refusal now never runs: read `result.error`, `result.message` or `add.form.error('field')`. A call awaited with its result left out (`await add(input)` in a `try` to know it failed) needs `.orThrow()` or a look at `result.ok`. `track()` handles answer the same, a call with no answer included. A call awaited with its result left out has no read to find and stays by hand. kayjs-ui's `attempt` and `toast.promise` take a call's result as they took what it threw, and `site.call` of a test site is unchanged.
|
|
53
|
+
|
|
54
|
+
### A callback of a library component takes one event object
|
|
55
|
+
|
|
56
|
+
A function handed by name to a callback of a kayjs-ui, kayjs-ai or kayjs-cms component (`onValueChange={query.set}`, `onChange={toggle}` with `toggle(on: boolean)`, `onFiles={upload}`) was called with the value and now gets `{ value }`, `{ checked }` or `{ files }`, so it fails the type check, and would be handed the event where it took the value. `deprecated-callback-handler` (`deny`) names it: `kay check --fix` writes `onChange={event => toggle(event.checked)}`, passing the fields the handler took, first ones first. A handler whose parameter is typed as an object is rewritten by an unsafe fix, which `kay upgrade` leaves to you, as it may take the event already; an arrow function is reported with no fix.
|
|
23
57
|
|
|
24
58
|
### An action's form readers sit under `form`
|
|
25
59
|
|
|
@@ -31,13 +65,12 @@ kayjs-auth's sixty `*Result` aliases (`PasswordSignInResult`, `RevokeTokenResult
|
|
|
31
65
|
|
|
32
66
|
### A refusal is one call
|
|
33
67
|
|
|
34
|
-
`ctx.deny(status, { message, errors, data })` refuses in a guard, a page, an action and an endpoint, and `refuse(status, { message, errors, data })` throws the same from anywhere; `deprecated-deny-call`, `deprecated-ctx-fail` and `deprecated-refuse-call` (`kay check --fix`) rewrite `deny(403, 'text', data)`, `return ctx.fail(status, data, errors)` and `refuse('text', { status, errors, data })`, which work until 1.108. In an action, `ctx.deny(status, { data, errors })` fails the post as `ctx.fail` did (the page again with the fields, an `ActionError` for a call), while a
|
|
68
|
+
`ctx.deny(status, { message, errors, data })` refuses in a guard, a page, an action and an endpoint, and `refuse(status, { message, errors, data })` throws the same from anywhere; `deprecated-deny-call`, `deprecated-ctx-fail` and `deprecated-refuse-call` (`kay check --fix`) rewrite `deny(403, 'text', data)`, `return ctx.fail(status, data, errors)` and `refuse('text', { status, errors, data })`, which work until 1.108. In an action, `ctx.deny(status, { message, data, errors })` fails the post as `ctx.fail` did (the page again with the message and the fields, an `ActionError` for a call), while a deny with no options stops with plain text as `deny(status, 'text')` did; a helper called in a handler with its `ctx`, such as a guard's or `limit.check(ctx)`, therefore fails the form with its message now; the fixer writes a `ctx.fail('text')` text as `message`. The argument checks of `webPush.send`, `rooms`, `signed` and notifications throw a `KayError` with code `argument-invalid`, not a `RangeError` or `TypeError`.
|
|
35
69
|
|
|
36
70
|
### A top-level `const` follows the prop or signal it reads
|
|
37
71
|
|
|
38
72
|
In the browser, `const last = items.length - 1` or `const twice = count() * 2` at the top of a script was computed once and now follows what it reads, so a `memo(() => ...)` or a function written for it can go. A `const` that meant the first value of a prop is written `// kay-allow once-read-prop: why` (`kay check` asks for it as before), and of a signal `untrack(() => count())`; it cannot be assigned. Nothing to rewrite otherwise.
|
|
39
73
|
|
|
40
|
-
`ctx.deny(status, { message, errors, data })` refuses in a guard, a page, an action and an endpoint, and `refuse(status, { message, errors, data })` throws the same from anywhere; `deprecated-deny-call`, `deprecated-ctx-fail` and `deprecated-refuse-call` (`kay check --fix`) rewrite `deny(403, 'text', data)`, `return ctx.fail(status, data, errors)` and `refuse('text', { status, errors, data })`, which work until 1.108. In an action, `ctx.deny(status, { data, errors })` fails the post as `ctx.fail` did (the page again with the fields, an `ActionError` for a call), while a refusal of a message alone stops with plain text as `deny(status, 'text')` did, so a guard run with an action's context refuses the same way; the fixer writes a `ctx.fail('text')` text as `data`, which an action takes as the form's message. The argument checks of `webPush.send`, `rooms`, `signed`, notifications and the helpers that also run in an island (`route()`, `every()`, `shortcut()`, `presence()`, `local()`, `navigate()`, `persisted`, `sanitizeHtml`) throw a `KayError` with code `argument-invalid`, not a `RangeError` or `TypeError`.
|
|
41
74
|
### Eight mistakes that ship a broken page refuse
|
|
42
75
|
|
|
43
76
|
`unreturned-fail`, `brace-in-attribute`, `signal-set-call`, `constant-signal`, `literal-tag`, `positional-key`, `unkeyed-rows` and `once-read-prop` were warnings and are now `deny`: `kay check` reports each as an error, so the `check` script of an app fails on one it still has. `kay check --fix` applies the fixes of `unreturned-fail`, `brace-in-attribute`, `signal-set-call` and `positional-key`; for the others write what the lint's message says, or `// kay-allow <lint> -- why` where the form is meant. `lints: { 'constant-signal': 'warn' }` in kay.config.ts brings one back to a warning.
|