@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/src/config.ts
CHANGED
|
@@ -310,7 +310,7 @@ export interface EndpointsConfig {
|
|
|
310
310
|
api?: string | undefined
|
|
311
311
|
// Where the OpenAPI document is served, `/api/openapi.json` under the API prefix by default; its reference page is set in `openapi.reference`.
|
|
312
312
|
openapi?: string | undefined
|
|
313
|
-
// Where the MCP endpoint is served, `/_kay/mcp` by default. `/mcp`, where it was served before 1.105,
|
|
313
|
+
// Where the MCP endpoint is served, `/_kay/mcp` by default. `/mcp`, where it was served before 1.105, is answered in place until 2.0 when this is not set.
|
|
314
314
|
mcp?: string | undefined
|
|
315
315
|
// Where the health check is served, `/_kay/health` by default.
|
|
316
316
|
health?: string | undefined
|
|
@@ -439,6 +439,17 @@ export interface ManifestConfig {
|
|
|
439
439
|
maskable?: string | undefined
|
|
440
440
|
// The pages a launcher offers from the app's icon.
|
|
441
441
|
shortcuts?: ManifestShortcut[] | undefined
|
|
442
|
+
// Lists the installed app among the apps a device's share sheet offers, the shared title, text, link and files posted to an action.
|
|
443
|
+
shareTarget?: ManifestShareTarget | undefined
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
export interface ManifestShareTarget {
|
|
447
|
+
// Where a share is posted: an action as `'src/routes/share.kay#receive'`, the page file relative to the root and the exported action's name, or a path of the site (`'/share'`) for a route of your own taking a POST. The action reads `title`, `text`, `url` and `files`, whichever the sharing app sent, all optional.
|
|
448
|
+
action: string
|
|
449
|
+
// The kinds of file the app takes, as MIME types or extensions (`['image/*', '.pdf']`); with some the share is posted as `multipart/form-data` and the action reads them as `files`, without any only text and a link are shared.
|
|
450
|
+
files?: string[] | undefined
|
|
451
|
+
// The field each part of a share is posted as, `title`, `text`, `url` and `files` by default.
|
|
452
|
+
params?: { title?: string | undefined, text?: string | undefined, url?: string | undefined, files?: string | undefined } | undefined
|
|
442
453
|
}
|
|
443
454
|
|
|
444
455
|
export interface ManifestShortcut {
|
|
@@ -626,8 +637,10 @@ export interface KayExtension<Server extends PluginInput = AnyElysia> {
|
|
|
626
637
|
appFiles?: Record<string, string> | undefined
|
|
627
638
|
// The server plugin named by the module that exports it, `{ path: './src/auth', export: 'auth' }` for `export const auth` (`default` by default): imported only as `pages()` builds the app, and baked into an executable `kay build --compile` makes, which a path built at run time inside a library could not be. The export is the plugin, a function building it, or an object carrying it as `plugin`, as a library's `authCore` result does. `kay check` types the locals off the module itself, and off the extension's `Server` argument when it has one; used beside `server`, the module wins. A path is relative to the project root. `prepare` runs with the export before the plugin is taken from it, for a library to hand the app's module what the extension was given; a throw stops the server.
|
|
628
639
|
serverModule?: { path: string, export?: string | undefined, prepare?: ((exported: unknown) => void | Promise<void>) | undefined } | undefined
|
|
629
|
-
// Config laid under the app's `kay.config.ts`: objects merged key by key, arrays joined with the extension's items first, any other value the app sets winning. Bun plugins the library's files need go in its `plugins`.
|
|
630
|
-
config?: Omit<
|
|
640
|
+
// Config laid under the app's `kay.config.ts`: objects merged key by key, arrays joined with the extension's items first, any other value the app sets winning. Bun plugins the library's files need go in its `plugins`. It takes what `kay.config.ts` does, the keys of before 1.105 included (`fonts`, `favicon`, `observe`...), which work until 1.108 under `deprecated-config-groups`.
|
|
641
|
+
config?: Omit<ConfigInput, 'extensions'> | undefined
|
|
642
|
+
// A module whose default export is `defineUi({ ... })`, written as `src/ui.ts` is (string and object literals only), absolute or relative to the project root: the parts and variants it sets for components, the app's own or a library's, reach every app listing the extension, under the app's own `src/ui.ts`. A part or a variant value the app sets replaces the extension's, and a later extension's replaces an earlier one's. Names and relative specifiers resolve from the app's `src/`.
|
|
643
|
+
ui?: string | undefined
|
|
631
644
|
// A directory of `.kay` pages, layouts and guards laid over the app's routes under `prefix`, the root by default: a file of the app at the same path replaces the library's.
|
|
632
645
|
// Its directories are absolute, as a library gives them from `import.meta.dir`, or relative to the project root.
|
|
633
646
|
routes?: { dir: string, prefix?: string | undefined } | undefined
|
|
@@ -782,7 +795,10 @@ type CaseVariant<Key, Known> = { [Name in keyof Known & string]: Lowercase<Name>
|
|
|
782
795
|
type Misspelled<Key, Known> = [CaseVariant<Key, Known>] extends [never] ? 'unknown option' : `unknown option, did you mean \`${CaseVariant<Key, Known> & string}\`?`
|
|
783
796
|
|
|
784
797
|
// A symbol key is no option a config names, and an object a library returns may carry one, as `pgData()`'s `Symbol.asyncDispose` does.
|
|
785
|
-
type UnknownKeys<Given, Known> = Given extends object ? { [Key in Exclude<keyof Given,
|
|
798
|
+
type UnknownKeys<Given, Known> = Given extends object ? { [Key in Exclude<keyof Given, AllKeys<Known> | symbol>]: Misspelled<Key, Known> } : unknown
|
|
799
|
+
|
|
800
|
+
// The keys of every member of a union of object shapes (`{ env } | { file }`), where `keyof` keeps only the keys they share, none for that one.
|
|
801
|
+
type AllKeys<Known> = Known extends unknown ? keyof Known : never
|
|
786
802
|
|
|
787
803
|
type Method = (...args: never[]) => unknown
|
|
788
804
|
|
package/src/content/markdown.ts
CHANGED
|
@@ -102,8 +102,7 @@ export const LOADED_HTML: SanitizeOptions = { ...MARKDOWN_KEPT, relativeUrls: tr
|
|
|
102
102
|
const LOADED: SanitizeOptions = { ...LOADED_HTML, attributes: { ...MARKDOWN_KEPT.attributes, h1: ['id'], h2: ['id'], h3: ['id'], h4: ['id'], h5: ['id'], h6: ['id'], code: ['class'] } }
|
|
103
103
|
// A link the sanitizer wrote that stays on the site: its `href` names no http(s) URL.
|
|
104
104
|
const OWN_LINK = /<a href="((?!https?:\/\/)[^"]*)" rel="nofollow ugc">/gi
|
|
105
|
-
// The only
|
|
106
|
-
const CODE_CLASS = /<code class="(?!language-[\w+#.-]+")[^"]*">/g
|
|
105
|
+
// The only id kept on a heading: a slug in its shape, so a loader's text cannot pick a camelCase global name (the sanitizer keeps no class on a code block but its language).
|
|
107
106
|
const HEADING_ID = /<(h[1-6]) id="(?![\p{Ll}\p{N}][\p{Ll}\p{N}_-]*")[^"]*"/gu
|
|
108
107
|
// The private characters standing for a component's placeholder while the sanitizer, which reads no tag name with a hyphen, goes over the rest.
|
|
109
108
|
const HELD_PLACEHOLDER = /\uE010(\d+)\uE011|\uE012(\d+)\uE011|\uE013/g
|
|
@@ -241,7 +240,7 @@ export function countWords(html: string): number {
|
|
|
241
240
|
function sanitizedComponents(html: string): string {
|
|
242
241
|
const held = html.replace(PRIVATE_CHARS, char => `&#${char.codePointAt(0)};`).replace(PLACEHOLDER_TAG, (_, selfClosing: string | undefined, opening: string | undefined) => heldPlaceholder(selfClosing, opening))
|
|
243
242
|
|
|
244
|
-
return withoutInnerRel(sanitizedMarkdown(held, LOADED, false).replace(
|
|
243
|
+
return withoutInnerRel(sanitizedMarkdown(held, LOADED, false).replace(HEADING_ID, '<$1').replace(HELD_PLACEHOLDER, (_, selfClosing: string | undefined, opening: string | undefined) => restoredPlaceholder(selfClosing, opening)))
|
|
245
244
|
}
|
|
246
245
|
|
|
247
246
|
// The sanitizer marks every link as a user's; a link to the site or to a heading is the entry's own, so only one leaving the site keeps its `rel`.
|
package/src/content/validate.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TSchema } from 'elysia'
|
|
2
2
|
import type { RawEntry } from './load'
|
|
3
3
|
import type { ComponentSegment, Segment } from './markdown'
|
|
4
|
-
import { errorText } from '../
|
|
4
|
+
import { errorText } from '../runtime/field-errors'
|
|
5
5
|
import { compiledCheck, dottedPath, fieldOf, refusals, unescaped } from '../server/schema-check'
|
|
6
6
|
import { entryRefusal, kayWord } from '../server/words'
|
|
7
7
|
import { humanize } from './humanize'
|
package/src/generate-resource.ts
CHANGED
|
@@ -33,14 +33,14 @@ interface TypeDescription {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// The range of a 4-byte column, which a bare integer schema would let a post exceed.
|
|
36
|
-
const INT4 = '{
|
|
36
|
+
const INT4 = '{ min: -2147483648, max: 2147483647 }'
|
|
37
37
|
|
|
38
38
|
const TYPES: Record<FieldType, TypeDescription> = {
|
|
39
|
-
string: { column: 'f.varchar(200)', schema: 's.
|
|
40
|
-
text: { column: 'f.text()', schema: 's.
|
|
41
|
-
int: { column: 'f.integer()', schema: `s.
|
|
42
|
-
float: { column: 'f.doublePrecision()', schema: 's.
|
|
43
|
-
boolean: { column: 'f.boolean().default(false)', schema: 's.
|
|
39
|
+
string: { column: 'f.varchar(200)', schema: 's.string({ min: 1, max: 200 })', sample: '\'First\'', posted: '\'First\'', shown: 'First' },
|
|
40
|
+
text: { column: 'f.text()', schema: 's.string({ min: 1, max: 10_000 })', sample: '\'Some text\'', posted: '\'Some text\'', shown: 'Some text' },
|
|
41
|
+
int: { column: 'f.integer()', schema: `s.int(${INT4})`, sample: '42', posted: '\'42\'', shown: '42' },
|
|
42
|
+
float: { column: 'f.doublePrecision()', schema: 's.number()', sample: '4.25', posted: '\'4.25\'', shown: '4.25' },
|
|
43
|
+
boolean: { column: 'f.boolean().default(false)', schema: 's.boolean()', sample: 'true', posted: '\'on\'', shown: 'true' },
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
const ALIASES: Record<string, FieldType> = { string: 'string', text: 'text', int: 'int', integer: 'int', float: 'float', number: 'float', boolean: 'boolean', bool: 'boolean' }
|
|
@@ -170,19 +170,19 @@ const fields = {
|
|
|
170
170
|
${schemas}
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
export const create = action(
|
|
173
|
+
export const create = action(fields, async (input, ctx) => {
|
|
174
174
|
await db.repo(${names.pascal}).write.insertOne(input)
|
|
175
175
|
|
|
176
176
|
return ctx.redirect('${list}')
|
|
177
177
|
})
|
|
178
178
|
|
|
179
|
-
export const update = action(
|
|
179
|
+
export const update = action({ id: s.int(${INT4}), ...fields }, async ({ id, ...values }, ctx) => {
|
|
180
180
|
await db.repo(${names.pascal}).write.updateOne(values, { id })
|
|
181
181
|
|
|
182
182
|
return ctx.redirect('${list}')
|
|
183
183
|
})
|
|
184
184
|
|
|
185
|
-
export const remove = action(
|
|
185
|
+
export const remove = action({ id: s.int(${INT4}) }, async ({ id }, ctx) => {
|
|
186
186
|
await db.repo(${names.pascal}).write.deleteOne({ id })
|
|
187
187
|
|
|
188
188
|
return ctx.redirect('${list}')
|
package/src/generate.ts
CHANGED
|
@@ -21,7 +21,7 @@ const WORD_BREAK = /[-_]+/g
|
|
|
21
21
|
// Words an action cannot be exported as, or that its own file already names: the `action` and `s` it calls, `title` its handler reads.
|
|
22
22
|
const RESERVED = new Set(['action', 's', 'title', 'await', 'break', 'case', 'catch', 'class', 'const', 'continue', 'debugger', 'default', 'delete', 'do', 'else', 'enum', 'export', 'extends', 'false', 'finally', 'for', 'function', 'if', 'import', 'in', 'instanceof', 'let', 'new', 'null', 'return', 'static', 'super', 'switch', 'this', 'throw', 'true', 'try', 'typeof', 'var', 'void', 'while', 'with', 'yield', 'implements', 'interface', 'package', 'private', 'protected', 'public', 'eval', 'arguments'])
|
|
23
23
|
// The action added to an `_actions.kay`, or printed for the author to add when the file holds more than a server fence.
|
|
24
|
-
const ACTION_BODY = (name: string) => `export const ${name} = action(\n
|
|
24
|
+
const ACTION_BODY = (name: string) => `export const ${name} = action(\n { title: s.string({ min: 1, max: 200 }) },\n ({ title }) => title,\n)\n`
|
|
25
25
|
const LINE_BREAK = /\r?\n/
|
|
26
26
|
const LINE_BREAKS = /\r?\n/g
|
|
27
27
|
const TABLES_FILE = 'src/db/tables.ts'
|
package/src/mcp/guards.ts
CHANGED
package/src/mcp/tools.ts
CHANGED
|
@@ -216,7 +216,7 @@ function tools(root: string, write: boolean): Tool[] {
|
|
|
216
216
|
return []
|
|
217
217
|
|
|
218
218
|
if (typeof value !== 'number' || !Number.isInteger(value))
|
|
219
|
-
throw new
|
|
219
|
+
throw new TypeError(`${name} takes a whole number of pixels`)
|
|
220
220
|
|
|
221
221
|
return [`--${name}=${value}`]
|
|
222
222
|
})
|
package/src/migrate/content.ts
CHANGED
|
@@ -5,11 +5,11 @@ import { parseProgram, positionOf } from '../compiler/estree'
|
|
|
5
5
|
// An Astro content config, `defineCollection` with a zod schema, as kay's: `collection(folder, { schema })` with the schema in `s`.
|
|
6
6
|
|
|
7
7
|
// zod's types and the `s` builder each becomes, for those that take their arguments the same way.
|
|
8
|
-
const SAME: Record<string, string> = { string: '
|
|
9
|
-
// zod's string checks and the `s.
|
|
10
|
-
const STRING_CHECKS: Record<string, string> = { min: '
|
|
8
|
+
const SAME: Record<string, string> = { string: 'string', number: 'number', boolean: 'boolean', date: 'date', literal: 'literal' }
|
|
9
|
+
// zod's string checks and the `s.string` option each becomes.
|
|
10
|
+
const STRING_CHECKS: Record<string, string> = { min: 'min', max: 'max', email: 'format', url: 'format', regex: 'pattern' }
|
|
11
11
|
const LEADING_DOT_SLASH = /^\.\//
|
|
12
|
-
const NUMBER_CHECKS: Record<string, string> = { min: '
|
|
12
|
+
const NUMBER_CHECKS: Record<string, string> = { min: 'min', max: 'max', gte: 'min', lte: 'max' }
|
|
13
13
|
const CHECKS_BY_KIND = new Map([['string', STRING_CHECKS], ['number', NUMBER_CHECKS]])
|
|
14
14
|
|
|
15
15
|
class SchemaTranslator {
|
|
@@ -39,7 +39,7 @@ class SchemaTranslator {
|
|
|
39
39
|
|
|
40
40
|
// The schema helper Astro passes, `schema: ({ image }) => z.object(...)`.
|
|
41
41
|
if (current.type === 'CallExpression' && current.callee.type === 'Identifier' && current.callee.name === 'image')
|
|
42
|
-
return
|
|
42
|
+
return this.image(chain, node)
|
|
43
43
|
|
|
44
44
|
const base = chain.shift()
|
|
45
45
|
|
|
@@ -48,74 +48,80 @@ class SchemaTranslator {
|
|
|
48
48
|
|
|
49
49
|
const kind = base.callee.property.name
|
|
50
50
|
const args = base.arguments
|
|
51
|
-
|
|
52
|
-
let integer = false
|
|
53
|
-
const options: string[] = []
|
|
54
|
-
const checks = CHECKS_BY_KIND.get(kind)
|
|
55
|
-
const rest: CallExpression[] = []
|
|
56
|
-
|
|
57
|
-
for (const call of chain) {
|
|
58
|
-
const name = call.callee.type === 'MemberExpression' && call.callee.property.type === 'Identifier' ? call.callee.property.name : ''
|
|
59
|
-
const option = checks?.[name]
|
|
51
|
+
const { options, integer, rest } = this.chain(kind, chain)
|
|
60
52
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
else if (option === 'pattern' && call.arguments[0]?.type === 'Literal' && 'regex' in call.arguments[0])
|
|
64
|
-
options.push(`pattern: ${JSON.stringify((call.arguments[0] as { regex: { pattern: string } }).regex.pattern)}`)
|
|
65
|
-
else if (option !== undefined && call.arguments[0])
|
|
66
|
-
options.push(`${option}: ${this.text(call.arguments[0])}`)
|
|
67
|
-
else if (kind === 'number' && name === 'int')
|
|
68
|
-
integer = true
|
|
69
|
-
else
|
|
70
|
-
rest.push(call)
|
|
71
|
-
}
|
|
53
|
+
if (rest[0])
|
|
54
|
+
return this.untranslated(node, `.${methodName(rest[0])}() has no \`s\` counterpart kay migrate knows`)
|
|
72
55
|
|
|
73
56
|
if (kind === 'object' && args[0]?.type === 'ObjectExpression') {
|
|
74
57
|
const fields = args[0].properties.map(property => isPlain(property) ? `${this.text(property.key)}: ${this.schema(property.value)}` : this.untranslated(property, 'a spread in an object schema'))
|
|
75
58
|
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
else if (kind === 'array' && args[0]) {
|
|
79
|
-
built = `s.Array(${this.schema(args[0])}${options.length > 0 ? `, { ${options.join(', ')} }` : ''})`
|
|
59
|
+
return this.call('s.object', [`{ ${fields.join(', ')} }`], options)
|
|
80
60
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
61
|
+
|
|
62
|
+
if (kind === 'array' && args[0])
|
|
63
|
+
return this.call('s.list', [this.schema(args[0])], options)
|
|
64
|
+
|
|
65
|
+
if (kind === 'enum' && args[0]?.type === 'ArrayExpression')
|
|
66
|
+
return this.call('s.enum', [this.text(args[0])], options)
|
|
67
|
+
|
|
68
|
+
if (kind === 'union' && args[0]?.type === 'ArrayExpression')
|
|
69
|
+
return this.call('s.union', [`[${args[0].elements.map(element => element ? this.schema(element) : '').join(', ')}]`], options)
|
|
70
|
+
|
|
71
|
+
if (kind === 'coerce' || !(kind in SAME))
|
|
88
72
|
return this.untranslated(node, `z.${kind} has no \`s\` counterpart kay migrate knows`)
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
const builder = integer ? 's.Integer' : `s.${SAME[kind]}`
|
|
92
73
|
|
|
93
|
-
|
|
94
|
-
|
|
74
|
+
return this.call(integer ? 's.int' : `s.${SAME[kind]}`, args.map(arg => this.text(arg)), options)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// The `image()` helper: a string, whatever follows it in the chain.
|
|
78
|
+
private image(chain: CallExpression[], node: Node): string {
|
|
79
|
+
const { options, rest } = this.chain('image', chain)
|
|
95
80
|
|
|
96
|
-
return this.
|
|
81
|
+
return rest[0] ? this.untranslated(node, `.${methodName(rest[0])}() has no \`s\` counterpart kay migrate knows`) : this.call('s.string', [], options)
|
|
97
82
|
}
|
|
98
83
|
|
|
99
|
-
|
|
100
|
-
|
|
84
|
+
// `s.string({ min: 1 })`: the builder, its arguments, then the options when there are any.
|
|
85
|
+
private call(builder: string, args: string[], options: string[]): string {
|
|
86
|
+
return `${builder}(${[...args, ...options.length > 0 ? [`{ ${options.join(', ')} }`] : []].join(', ')})`
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// The calls after a zod type: the checks that are options of the builder, `.optional()` and `.default()`, and what has no counterpart.
|
|
90
|
+
private chain(kind: string, chain: CallExpression[]): { options: string[], integer: boolean, rest: CallExpression[] } {
|
|
91
|
+
const checks = CHECKS_BY_KIND.get(kind)
|
|
92
|
+
const options: string[] = []
|
|
93
|
+
const rest: CallExpression[] = []
|
|
94
|
+
let integer = false
|
|
101
95
|
|
|
102
|
-
for (const call of
|
|
103
|
-
const name = call
|
|
96
|
+
for (const call of chain) {
|
|
97
|
+
const name = methodName(call)
|
|
98
|
+
const option = checks?.[name]
|
|
99
|
+
const first = call.arguments[0]
|
|
104
100
|
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
else if (
|
|
108
|
-
|
|
109
|
-
else if (
|
|
110
|
-
|
|
101
|
+
if (option === 'format')
|
|
102
|
+
options.push(`format: '${name === 'url' ? 'uri' : 'email'}'`)
|
|
103
|
+
else if (option === 'pattern' && first?.type === 'Literal' && 'regex' in first)
|
|
104
|
+
options.push(`pattern: ${JSON.stringify((first as { regex: { pattern: string } }).regex.pattern)}`)
|
|
105
|
+
else if (option !== undefined && first)
|
|
106
|
+
options.push(`${option}: ${this.text(first)}`)
|
|
107
|
+
else if (kind === 'number' && name === 'int')
|
|
108
|
+
integer = true
|
|
109
|
+
else if (name === 'optional' || name === 'nullish')
|
|
110
|
+
options.push('optional: true')
|
|
111
|
+
else if (name === 'default' && first)
|
|
112
|
+
options.push(`default: ${this.text(first)}`)
|
|
111
113
|
else
|
|
112
|
-
|
|
114
|
+
rest.push(call)
|
|
113
115
|
}
|
|
114
116
|
|
|
115
|
-
return
|
|
117
|
+
return { options, integer, rest }
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
120
|
|
|
121
|
+
function methodName(call: CallExpression): string {
|
|
122
|
+
return call.callee.type === 'MemberExpression' && call.callee.property.type === 'Identifier' ? call.callee.property.name : ''
|
|
123
|
+
}
|
|
124
|
+
|
|
119
125
|
function literalKey(key: Node): string | undefined {
|
|
120
126
|
if (key.type === 'Identifier')
|
|
121
127
|
return key.name
|
|
@@ -235,7 +241,7 @@ function collectionsOf(object: ObjectExpression, declared: Map<string, CallExpre
|
|
|
235
241
|
if (folder === undefined)
|
|
236
242
|
notes.push({ line: positionOf(source, call.start).line, message: `the collection ${name} uses a loader other than \`glob({ base })\`: kay reads a folder of files, so give it the folder` })
|
|
237
243
|
|
|
238
|
-
result.push(`export const ${name} = collection('${folder ?? `content/${name}`}', {\n schema: ${schema ? translator.schema(schema) : 's.
|
|
244
|
+
result.push(`export const ${name} = collection('${folder ?? `content/${name}`}', {\n schema: ${schema ? translator.schema(schema) : 's.object({})'},\n})`)
|
|
239
245
|
}
|
|
240
246
|
|
|
241
247
|
return result
|
package/src/new.ts
CHANGED
|
@@ -227,13 +227,17 @@ async function librariesDryRun(files: Record<string, string>, libraries: readonl
|
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
+
// The range a new project pins kay to: a 1.x minor may break, so it takes patches only (`~`), and from 2.0.0 a breaking change is a major, so it takes minors too (`^`).
|
|
231
|
+
export function kayRange(version: string): string {
|
|
232
|
+
return Number.parseInt(version, 10) >= 2 ? `^${version}` : `~${version}`
|
|
233
|
+
}
|
|
234
|
+
|
|
230
235
|
// Every file of a project with these features in `dir`, named after it; run from a checkout of kay, packs it into `dir/vendor` for the project to depend on.
|
|
231
236
|
export async function projectFiles(dir: string, features: ReadonlySet<Feature>, kayDependency?: string | undefined, settings: ConfigSettings = {}, host?: Host, runner?: string): Promise<Record<string, string>> {
|
|
232
237
|
const has = holds(features)
|
|
233
238
|
const name = packageName(basename(resolve(dir)))
|
|
234
239
|
const kay = await Bun.file(join(KAY_ROOT, 'package.json')).json() as { name: string, version: string, dependencies: Record<string, string>, devDependencies: Record<string, string>, peerDependencies: Record<string, string> }
|
|
235
|
-
|
|
236
|
-
const dependency = kayDependency ?? (existsSync(join(KAY_ROOT, '.git')) ? await packKay(join(dir, 'vendor')) : `npm:${kay.name}@~${kay.version}`)
|
|
240
|
+
const dependency = kayDependency ?? (existsSync(join(KAY_ROOT, '.git')) ? await packKay(join(dir, 'vendor')) : `npm:${kay.name}@${kayRange(kay.version)}`)
|
|
237
241
|
const scripts = {
|
|
238
242
|
'dev': 'kay dev',
|
|
239
243
|
...has('server') ? { build: 'kay build', compile: 'kay build --compile server', start: 'kay start' } : { build: 'kay build --static' },
|
|
@@ -242,9 +242,9 @@ export interface ActionContext<Params extends Readonly<Record<string, unknown>>
|
|
|
242
242
|
fail: <const Data = undefined, const Status extends number = number>(status: Status & ErrorStatus<Status>, data?: Data, errors?: FieldErrors<Field>) => Failure<Data>
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
// `ctx.deny` of an action: a refusal with `data` or `errors` is typed as a `Failure`, one with
|
|
245
|
+
// `ctx.deny` of an action: a refusal with a `message`, `data` or `errors` is typed as a `Failure`, one with no options is `never`, so it narrows what follows as a guard's does.
|
|
246
246
|
export interface ActionDeny<Field extends string = string> {
|
|
247
|
-
<const Status extends number = number>(status?: Status & ErrorStatus<Status>, options?: { message?:
|
|
247
|
+
<const Status extends number = number>(status?: Status & ErrorStatus<Status>, options?: { message?: undefined, errors?: undefined, data?: undefined }): never
|
|
248
248
|
<const Data = undefined, const Status extends number = number>(status: Status & ErrorStatus<Status>, options: DenyOptions<Data, Field>): Failure<Data>
|
|
249
249
|
// What a helper taking the guard's `deny` sees: an action's context passes as one.
|
|
250
250
|
<const Status extends number = number>(status?: Status & ErrorStatus<Status>, options?: DenyOptions<ErrorData>): never
|
package/src/runtime/action.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { t } from 'elysia'
|
|
2
2
|
import type { ActionContext, ActionProtection, Answer, Called, CallOptions, OutputSchema, ServerAction, Settled, Success } from './action-shared'
|
|
3
3
|
import type { RouteParams } from './checks'
|
|
4
|
-
import type { Schema, Static } from './schema'
|
|
4
|
+
import type { Schema, StandardAs, Static } from './schema'
|
|
5
|
+
import type { ObjectOf, SchemaShape } from './schema-record'
|
|
6
|
+
import type { StandardSchema } from './standard-schema'
|
|
5
7
|
import { callable } from './action-call'
|
|
6
8
|
import { minTimeOf, resolveProtection, workOf } from './action-protection'
|
|
7
9
|
import { ACTION, isAction } from './action-shared'
|
|
8
10
|
import { durationSeconds } from './duration'
|
|
9
11
|
import { KayError } from './kay-error'
|
|
12
|
+
import { isSchema, schemaOf } from './schema-record'
|
|
13
|
+
import { isStandardSchema } from './standard-schema'
|
|
10
14
|
import { ACTION_PREFIX } from './wire'
|
|
11
15
|
|
|
12
16
|
export { actionStub, OUTCOME_SCRIPT, setRequestOutcome } from './action-call'
|
|
@@ -42,15 +46,27 @@ const emptySchema = () => ({ [Symbol.for('TypeBox.Kind')]: 'Object', type: 'obje
|
|
|
42
46
|
|
|
43
47
|
// `action` as `kay check` reads it in a page's server fence, whose `ctx.params` are those of the page's route: not something to write.
|
|
44
48
|
export interface ActionFor<Params extends Readonly<Record<string, unknown>>, Guarded extends object = object> {
|
|
49
|
+
<const Honeypot extends string = never, Output = never, Shape extends OutputSchema = OutputSchema>(options: ActionProtection<Honeypot, Success<Settled<Output>>, Shape> & { input?: undefined }, handler: (ctx: ActionContext<Params, string, Guarded>, ctxAfterEmptyInput: ActionContext<Params, string, Guarded>) => Output | Promise<Output>): NoInputAction<Settled<Output>, Honeypot>
|
|
50
|
+
<Spec extends Schema, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(options: ActionProtection<Honeypot, Success<Settled<Output>>, Shape> & { input: Spec }, handler: (input: Static<Spec>, ctx: ActionContext<Params, Extract<keyof Static<Spec>, string>, Guarded>) => Output | Promise<Output>): ServerAction<Spec, Settled<Output>, Honeypot>
|
|
51
|
+
<Validator extends StandardSchema, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(options: ActionProtection<Honeypot, Success<Settled<Output>>, Shape> & { input: Validator }, handler: (input: Static<StandardAs<Validator>>, ctx: ActionContext<Params, Extract<keyof Static<StandardAs<Validator>>, string>, Guarded>) => Output | Promise<Output>): ServerAction<StandardAs<Validator>, Settled<Output>, Honeypot>
|
|
52
|
+
<const Fields extends SchemaShape, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(options: ActionProtection<Honeypot, Success<Settled<Output>>, Shape> & { input: Fields }, handler: (input: Static<ObjectOf<Fields>>, ctx: ActionContext<Params, Extract<keyof Static<ObjectOf<Fields>>, string>, Guarded>) => Output | Promise<Output>): ServerAction<ObjectOf<Fields>, Settled<Output>, Honeypot>
|
|
45
53
|
<Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(handler: (ctx: ActionContext<Params, string, Guarded>) => Output | Promise<Output>, protection?: ActionProtection<Honeypot, Success<Settled<Output>>, Shape>): NoInputAction<Settled<Output>, Honeypot>
|
|
46
54
|
<Spec extends Schema, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(schema: Spec, handler: (input: Static<Spec>, ctx: ActionContext<Params, Extract<keyof Static<Spec>, string>, Guarded>) => Output | Promise<Output>, protection?: ActionProtection<Honeypot, Success<Settled<Output>>, Shape>): ServerAction<Spec, Settled<Output>, Honeypot>
|
|
55
|
+
<const Fields extends SchemaShape, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(fields: Fields, handler: (input: Static<ObjectOf<Fields>>, ctx: ActionContext<Params, Extract<keyof Static<ObjectOf<Fields>>, string>, Guarded>) => Output | Promise<Output>, protection?: ActionProtection<Honeypot, Success<Settled<Output>>, Shape>): ServerAction<ObjectOf<Fields>, Settled<Output>, Honeypot>
|
|
47
56
|
}
|
|
48
57
|
|
|
49
|
-
// Declares a server action in a page's `--- server` fence:
|
|
50
|
-
// Without
|
|
58
|
+
// Declares a server action in a page's `--- server` fence: the options come first, as an API route's do, `input` a plain record of fields or any schema that kay checks the post against before `handler` runs.
|
|
59
|
+
// Without an `input` the action takes no input, as with an empty object schema, and its handler gets the context alone.
|
|
60
|
+
// The form before 1.107, `action(schema, handler, options)`, works until 2.0: the `deprecated-action-options` lint rewrites it.
|
|
51
61
|
// kept: free, it registers a route answering a POST, which the page's own render never runs, and a kept page is refreshed after the first request that can write.
|
|
62
|
+
// A handler of two parameters is the form before 1.107, `action({}, (input, ctx) => ...)`, handed the empty input first: its second is the context, as the first of one taking the context alone is.
|
|
63
|
+
export function action<const Honeypot extends string = never, Output = never, Shape extends OutputSchema = OutputSchema>(options: ActionProtection<Honeypot, Success<Settled<Output>>, Shape> & { input?: undefined }, handler: (ctx: ActionContext, ctxAfterEmptyInput: ActionContext) => Output | Promise<Output>): NoInputAction<Settled<Output>, Honeypot>
|
|
64
|
+
export function action<Spec extends Schema, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(options: ActionProtection<Honeypot, Success<Settled<Output>>, Shape> & { input: Spec }, handler: (input: Static<Spec>, ctx: ActionContext<RouteParams, Extract<keyof Static<Spec>, string>>) => Output | Promise<Output>): ServerAction<Spec, Settled<Output>, Honeypot>
|
|
65
|
+
export function action<Validator extends StandardSchema, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(options: ActionProtection<Honeypot, Success<Settled<Output>>, Shape> & { input: Validator }, handler: (input: Static<StandardAs<Validator>>, ctx: ActionContext<RouteParams, Extract<keyof Static<StandardAs<Validator>>, string>>) => Output | Promise<Output>): ServerAction<StandardAs<Validator>, Settled<Output>, Honeypot>
|
|
66
|
+
export function action<const Fields extends SchemaShape, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(options: ActionProtection<Honeypot, Success<Settled<Output>>, Shape> & { input: Fields }, handler: (input: Static<ObjectOf<Fields>>, ctx: ActionContext<RouteParams, Extract<keyof Static<ObjectOf<Fields>>, string>>) => Output | Promise<Output>): ServerAction<ObjectOf<Fields>, Settled<Output>, Honeypot>
|
|
52
67
|
export function action<Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(handler: (ctx: ActionContext) => Output | Promise<Output>, protection?: ActionProtection<Honeypot, Success<Settled<Output>>, Shape>): NoInputAction<Settled<Output>, Honeypot>
|
|
53
68
|
export function action<Spec extends Schema, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(schema: Spec, handler: (input: Static<Spec>, ctx: ActionContext<RouteParams, Extract<keyof Static<Spec>, string>>) => Output | Promise<Output>, protection?: ActionProtection<Honeypot, Success<Settled<Output>>, Shape>): ServerAction<Spec, Settled<Output>, Honeypot>
|
|
69
|
+
export function action<const Fields extends SchemaShape, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(fields: Fields, handler: (input: Static<ObjectOf<Fields>>, ctx: ActionContext<RouteParams, Extract<keyof Static<ObjectOf<Fields>>, string>>) => Output | Promise<Output>, protection?: ActionProtection<Honeypot, Success<Settled<Output>>, Shape>): ServerAction<ObjectOf<Fields>, Settled<Output>, Honeypot>
|
|
54
70
|
export function action(first: unknown, second?: unknown, third?: ActionProtection<string>): unknown {
|
|
55
71
|
if (typeof first === 'function') {
|
|
56
72
|
const handler = first as (ctx: ActionContext) => unknown
|
|
@@ -58,7 +74,38 @@ export function action(first: unknown, second?: unknown, third?: ActionProtectio
|
|
|
58
74
|
return declare(emptySchema(), (_input, ctx) => handler(ctx), second as ActionProtection<string> | undefined)
|
|
59
75
|
}
|
|
60
76
|
|
|
61
|
-
|
|
77
|
+
if (third === undefined && isOptions(first)) {
|
|
78
|
+
const { input, ...options } = first as { input?: Schema | SchemaShape }
|
|
79
|
+
const handler = second as (...args: unknown[]) => unknown
|
|
80
|
+
|
|
81
|
+
// Without an `input` the handler takes the context alone, though an empty record before 1.107 gave it `(input, ctx)`.
|
|
82
|
+
return declare(input === undefined ? emptySchema() : schemaOf(input), input === undefined && handler.length < 2 ? (_input, ctx) => handler(ctx) : handler, options)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return declare(schemaOf(first as Schema | SchemaShape), second as (input: unknown, ctx: ActionContext) => unknown, third)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Whether the first argument is the options of the form since 1.107, not the schema or the record of fields of the form before: an object that names an `input` which is a record or an object schema, or names no field at all.
|
|
89
|
+
function isOptions(first: unknown): boolean {
|
|
90
|
+
if (typeof first !== 'object' || first === null || isSchema(first) || isStandardSchema(first))
|
|
91
|
+
return false
|
|
92
|
+
|
|
93
|
+
const entries = Object.entries(first)
|
|
94
|
+
|
|
95
|
+
if ('input' in first) {
|
|
96
|
+
const { input } = first
|
|
97
|
+
|
|
98
|
+
// An `input` that is a schema or a record is options; so is one left undefined. A legacy record holding a field called `input` has a schema beside it, which options never do.
|
|
99
|
+
if (input === undefined)
|
|
100
|
+
return true
|
|
101
|
+
|
|
102
|
+
if (typeof input !== 'object' || input === null)
|
|
103
|
+
return false
|
|
104
|
+
|
|
105
|
+
return !entries.some(([name, value]) => name !== 'input' && (isSchema(value) || isStandardSchema(value)))
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return !entries.some(([, value]) => isSchema(value) || isStandardSchema(value))
|
|
62
109
|
}
|
|
63
110
|
|
|
64
111
|
export function declare(schema: Schema, handler: (input: unknown, ctx: ActionContext) => unknown, options: ActionProtection<string> | undefined): ServerAction<Schema, unknown> {
|
package/src/runtime/client.ts
CHANGED
|
@@ -229,6 +229,12 @@ async function hydrateIsland(registry: IslandRegistry, element: HTMLElement): Pr
|
|
|
229
229
|
|
|
230
230
|
try {
|
|
231
231
|
loaded = await Promise.all([load(), staticSlots(registry, element), livePropsOf(element), reviveActionsIn(element.dataset.props)])
|
|
232
|
+
|
|
233
|
+
// What the server drew of its lazy components loads first, so the markup is claimed as it stands.
|
|
234
|
+
const drawn = (globalThis as { $kayLoadDrawn?: (island: HTMLElement) => Promise<void> }).$kayLoadDrawn
|
|
235
|
+
|
|
236
|
+
if (drawn !== undefined)
|
|
237
|
+
await drawn(element)
|
|
232
238
|
}
|
|
233
239
|
catch (error) {
|
|
234
240
|
// A chunk that failed to load is dropped like a missing one.
|
|
@@ -355,6 +361,10 @@ async function hotSwap(registry: IslandRegistry, swap: HotSwap): Promise<boolean
|
|
|
355
361
|
const chunk = withBase(chunks[0]!)
|
|
356
362
|
|
|
357
363
|
if (!document.querySelector(`${ISLAND}[data-component="${CSS.escape(id)}"]`)) {
|
|
364
|
+
// An island's code an island loaded lazily is not in the page as an island of its own, and keeps the version it loaded: only a reload brings the new one.
|
|
365
|
+
if ((globalThis as { $kayLazyLoaded?: boolean }).$kayLazyLoaded === true)
|
|
366
|
+
return false
|
|
367
|
+
|
|
358
368
|
// Not on this page: a later one rendering it loads the new chunk, unless that would bring code the page runs again.
|
|
359
369
|
if (fits(chunks))
|
|
360
370
|
registry[id] = async () => import(chunk) as ReturnType<IslandRegistry[string]>
|