@kayjs/kay 1.108.0 → 1.110.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/dist/eslint.js +2093 -3774
- package/editors/zed/extension.toml +2 -2
- package/llms/action-protection.md +1 -1
- package/llms/actions-from-islands.md +5 -5
- package/llms/actions-refused-fields.md +4 -4
- package/llms/api-from-islands.md +6 -6
- package/llms/browser-only.md +2 -2
- package/llms/cdn-caching.md +1 -1
- package/llms/checks.md +1 -1
- package/llms/code-lints.md +1 -2
- package/llms/component-library-conventions.md +1 -1
- package/llms/components.md +5 -5
- package/llms/deprecated-lints.md +2 -7
- package/llms/effects.md +1 -1
- package/llms/errors.md +2 -2
- package/llms/events.md +1 -1
- package/llms/guards.md +1 -1
- package/llms/head.md +1 -1
- package/llms/hooks.md +2 -2
- package/llms/images.md +1 -1
- package/llms/island-and-form-lints.md +4 -2
- package/llms/island-sources.md +1 -1
- package/llms/islands-state-to-ids.md +2 -2
- package/llms/islands.md +8 -4
- package/llms/lints.md +1 -1
- package/llms/live-values.md +4 -4
- package/llms/local-collections.md +1 -1
- package/llms/locales.md +1 -1
- package/llms/mcp.md +2 -2
- package/llms/metrics.md +1 -1
- package/llms/navigation-from-code.md +7 -7
- package/llms/navigation.md +4 -2
- package/llms/prerendering.md +1 -0
- package/llms/production.md +2 -2
- package/llms/project-new-and-add.md +1 -1
- package/llms/project.md +4 -4
- package/llms/proxy-and-security.md +1 -1
- package/llms/queues.md +1 -1
- package/llms/rate-limits.md +4 -4
- package/llms/rendering.md +1 -1
- package/llms/server-islands.md +2 -2
- package/llms/server.md +1 -1
- package/llms/stores.md +1 -1
- package/llms/styles-and-assets.md +1 -1
- package/llms/templates-elements-slots-snippets.md +2 -2
- package/llms/testing-mount.md +49 -0
- package/llms/testing.md +4 -45
- package/llms/upgrading-1-105-config.md +13 -13
- package/llms/upgrading-archive.md +64 -74
- package/llms/upgrading.md +92 -70
- package/llms/whats-new.md +24 -0
- package/llms.txt +5 -6
- package/package.json +6 -10
- package/src/build/route-sizes.ts +2 -3
- package/src/build/variants.ts +132 -18
- package/src/check/browser-global-reads.ts +2 -2
- package/src/check/config-objects.ts +1 -1
- package/src/check/diagnose.ts +0 -22
- package/src/check/env-types.ts +1 -1
- package/src/check/export-homes.ts +1 -1
- package/src/check/guards.ts +3 -3
- package/src/check/index.ts +2 -7
- package/src/check/moved-keys.ts +1 -1
- package/src/check/project.ts +6 -7
- package/src/check/schema-builders.ts +125 -26
- package/src/check/shadow-types.ts +0 -86
- package/src/commands/check.ts +2 -2
- package/src/commands/env.ts +25 -3
- package/src/commands/upgrade.ts +2 -1
- package/src/compiler/allow-comments.ts +38 -2
- package/src/compiler/ast.ts +21 -19
- package/src/compiler/browser.ts +2 -14
- package/src/compiler/class-items.ts +16 -0
- package/src/compiler/codegen.ts +10 -10
- package/src/compiler/deprecated-library.ts +0 -12
- package/src/compiler/deprecated-lints-1-106.ts +2 -2
- package/src/compiler/deprecated-lints.ts +3 -495
- package/src/compiler/deprecated-ui-props.ts +5 -5
- package/src/compiler/errors.ts +2 -2
- package/src/compiler/fence-checks.ts +2 -121
- package/src/compiler/hand-parts.ts +83 -0
- package/src/compiler/helper-imports.ts +2 -2
- package/src/compiler/image-attributes.ts +1 -3
- package/src/compiler/index.ts +23 -23
- package/src/compiler/island-arguments.ts +17 -95
- package/src/compiler/island-cause.ts +7 -7
- package/src/compiler/island-declaration.ts +2 -8
- package/src/compiler/island-lints.ts +19 -0
- package/src/compiler/island-marker.ts +3 -3
- package/src/compiler/island-problems.ts +25 -0
- package/src/compiler/items.ts +12 -0
- package/src/compiler/jsx-class.ts +1 -25
- package/src/compiler/jsx.ts +7 -6
- package/src/compiler/kay-exports.ts +0 -2
- package/src/compiler/link-flags.ts +9 -38
- package/src/compiler/lints.ts +10 -18
- package/src/compiler/markup.ts +33 -41
- package/src/compiler/module-signals.ts +2 -2
- package/src/compiler/names.ts +1 -1
- package/src/compiler/page-settings.ts +11 -0
- package/src/compiler/parser.ts +6 -8
- package/src/compiler/plan.ts +1 -3
- package/src/compiler/removed-lints.ts +90 -0
- package/src/compiler/rewrite.ts +3 -18
- package/src/compiler/script-server.ts +8 -3
- package/src/compiler/signal-from-prop.ts +141 -0
- package/src/compiler/template-reads.ts +16 -0
- package/src/compiler/validate.ts +3 -8
- package/src/config-loader.ts +14 -4
- package/src/config-resolve.ts +18 -142
- package/src/config-shape.ts +44 -34
- package/src/config.ts +10 -114
- package/src/dev/preload.ts +4 -1
- package/src/lsp/server.ts +4 -0
- package/src/migrate/markup.ts +4 -1
- package/src/runtime/action-call.ts +0 -8
- package/src/runtime/action-encode.ts +26 -0
- package/src/runtime/action-error.ts +3 -11
- package/src/runtime/action-protection.ts +2 -2
- package/src/runtime/action-run.ts +2 -27
- package/src/runtime/action-shared.ts +14 -37
- package/src/runtime/action-stream.ts +0 -1
- package/src/runtime/action.ts +1 -1
- package/src/runtime/call-result.ts +2 -10
- package/src/runtime/checks.ts +25 -13
- package/src/runtime/client.ts +7 -11
- package/src/runtime/core.ts +5 -23
- package/src/runtime/dom.ts +1 -1
- package/src/runtime/html.ts +1 -1
- package/src/runtime/i18n.client.ts +1 -4
- package/src/runtime/i18n.server.ts +1 -4
- package/src/runtime/i18n.ts +3 -3
- package/src/runtime/image.ts +2 -19
- package/src/runtime/index.ts +3 -3
- package/src/runtime/island.server.ts +56 -13
- package/src/runtime/live-resource.server.ts +0 -1
- package/src/runtime/live-value.server.ts +2 -2
- package/src/runtime/live-value.shared.ts +7 -20
- package/src/runtime/live.ts +1 -12
- package/src/runtime/local-types.ts +1 -11
- package/src/runtime/local.ts +4 -14
- package/src/runtime/navigate-api.ts +2 -5
- package/src/runtime/navigate.ts +9 -0
- package/src/runtime/navigation-state.ts +0 -12
- package/src/runtime/navigation.ts +5 -1
- package/src/runtime/page-swap.ts +8 -8
- package/src/runtime/persist.ts +11 -3
- package/src/runtime/persisted.ts +4 -30
- package/src/runtime/presence.ts +6 -7
- package/src/runtime/query-param.ts +20 -12
- package/src/runtime/reactive.ts +3 -1
- package/src/runtime/refuse.ts +3 -17
- package/src/runtime/store-base.ts +4 -6
- package/src/runtime/swap-fetch.ts +1 -1
- package/src/runtime/swap-flight.ts +10 -10
- package/src/runtime/swap-kept.ts +69 -29
- package/src/runtime/swap-morph.ts +49 -9
- package/src/runtime/text-hash.ts +17 -0
- package/src/runtime/uid.server.ts +6 -4
- package/src/runtime/values.ts +52 -23
- package/src/runtime/with-query.ts +9 -0
- package/src/server/action-hooks.ts +8 -8
- package/src/server/actions.ts +13 -14
- package/src/server/api-modules.ts +2 -3
- package/src/server/app-stages.ts +15 -33
- package/src/server/app.ts +10 -5
- package/src/server/auth-mails.ts +0 -2
- package/src/server/env-state.ts +40 -10
- package/src/server/flash.ts +1 -1
- package/src/server/guard-requirement.ts +4 -4
- package/src/server/image.ts +2 -2
- package/src/server/index.ts +0 -2
- package/src/server/job-context.ts +3 -3
- package/src/server/jobs-page.ts +1 -1
- package/src/server/jobs.ts +5 -9
- package/src/server/kept-exports.ts +0 -2
- package/src/server/kv.ts +11 -14
- package/src/server/library.ts +1 -3
- package/src/server/live.ts +2 -2
- package/src/server/mcp.ts +3 -9
- package/src/server/metrics.ts +2 -4
- package/src/server/page-settings.ts +10 -19
- package/src/server/prerender.ts +19 -2
- package/src/server/protection.ts +15 -18
- package/src/server/queue.ts +3 -6
- package/src/server/rate-limit.ts +0 -3
- package/src/server/render-document.ts +9 -7
- package/src/server/render.ts +1 -1
- package/src/server/routes.ts +7 -3
- package/src/server/scope.ts +3 -2
- package/src/server/session.ts +5 -6
- package/src/server/setup.ts +1 -1
- package/src/server/signals.ts +17 -7
- package/src/server/signed.ts +1 -3
- package/src/server/source.ts +20 -4
- package/src/server/speculation.ts +1 -1
- package/src/server/storage.ts +3 -8
- package/src/server/validate.ts +1 -1
- package/src/server/vitals.ts +1 -3
- package/src/server/work-scope.ts +2 -4
- package/src/server/work.ts +1 -1
- package/src/server/workflow.ts +1 -1
- package/src/test/index.ts +2 -1
- package/src/test/site-actions.ts +16 -6
- package/src/test/site-keys.ts +10 -15
- package/src/test/site-socket.ts +1 -2
- package/src/test/site-types.ts +0 -8
- package/types/build/route-sizes.d.ts.map +1 -1
- package/types/build/variants.d.ts +9 -1
- package/types/build/variants.d.ts.map +1 -1
- package/types/check/diagnose.d.ts.map +1 -1
- package/types/check/index.d.ts +1 -2
- package/types/check/index.d.ts.map +1 -1
- package/types/check/project.d.ts.map +1 -1
- package/types/check/schema-builders.d.ts.map +1 -1
- package/types/check/shadow-types.d.ts.map +1 -1
- package/types/commands/env.d.ts.map +1 -1
- package/types/commands/upgrade.d.ts.map +1 -1
- package/types/compiler/allow-comments.d.ts +2 -0
- package/types/compiler/allow-comments.d.ts.map +1 -1
- package/types/compiler/ast.d.ts +1 -2
- package/types/compiler/ast.d.ts.map +1 -1
- package/types/compiler/browser.d.ts.map +1 -1
- package/types/compiler/class-items.d.ts +7 -0
- package/types/compiler/class-items.d.ts.map +1 -0
- package/types/compiler/deprecated-library.d.ts.map +1 -1
- package/types/compiler/deprecated-lints-1-106.d.ts +2 -2
- package/types/compiler/deprecated-lints-1-106.d.ts.map +1 -1
- package/types/compiler/deprecated-lints.d.ts +2 -553
- package/types/compiler/deprecated-lints.d.ts.map +1 -1
- package/types/compiler/deprecated-ui-props.d.ts +1 -8
- package/types/compiler/deprecated-ui-props.d.ts.map +1 -1
- package/types/compiler/errors.d.ts +2 -2
- package/types/compiler/errors.d.ts.map +1 -1
- package/types/compiler/fence-checks.d.ts +0 -1
- package/types/compiler/fence-checks.d.ts.map +1 -1
- package/types/compiler/hand-parts.d.ts +10 -0
- package/types/compiler/hand-parts.d.ts.map +1 -0
- package/types/compiler/image-attributes.d.ts +0 -1
- package/types/compiler/image-attributes.d.ts.map +1 -1
- package/types/compiler/index.d.ts.map +1 -1
- package/types/compiler/island-arguments.d.ts +7 -11
- package/types/compiler/island-arguments.d.ts.map +1 -1
- package/types/compiler/island-cause.d.ts +1 -1
- package/types/compiler/island-cause.d.ts.map +1 -1
- package/types/compiler/island-declaration.d.ts +1 -3
- package/types/compiler/island-declaration.d.ts.map +1 -1
- package/types/compiler/island-lints.d.ts +17 -0
- package/types/compiler/island-lints.d.ts.map +1 -0
- package/types/compiler/island-problems.d.ts +7 -0
- package/types/compiler/island-problems.d.ts.map +1 -0
- package/types/compiler/items.d.ts +1 -0
- package/types/compiler/items.d.ts.map +1 -1
- package/types/compiler/jsx-class.d.ts +1 -2
- package/types/compiler/jsx-class.d.ts.map +1 -1
- package/types/compiler/jsx.d.ts.map +1 -1
- package/types/compiler/kay-exports.d.ts.map +1 -1
- package/types/compiler/link-flags.d.ts +0 -6
- package/types/compiler/link-flags.d.ts.map +1 -1
- package/types/compiler/lints.d.ts +21 -566
- package/types/compiler/lints.d.ts.map +1 -1
- package/types/compiler/markup.d.ts +1 -1
- package/types/compiler/markup.d.ts.map +1 -1
- package/types/compiler/module-signals.d.ts.map +1 -1
- package/types/compiler/names.d.ts.map +1 -1
- package/types/compiler/page-settings.d.ts +4 -0
- package/types/compiler/page-settings.d.ts.map +1 -1
- package/types/compiler/parser.d.ts.map +1 -1
- package/types/compiler/plan.d.ts.map +1 -1
- package/types/compiler/removed-lints.d.ts +3 -0
- package/types/compiler/removed-lints.d.ts.map +1 -0
- package/types/compiler/script-server.d.ts.map +1 -1
- package/types/compiler/signal-from-prop.d.ts +4 -0
- package/types/compiler/signal-from-prop.d.ts.map +1 -0
- package/types/compiler/template-reads.d.ts +1 -0
- package/types/compiler/template-reads.d.ts.map +1 -1
- package/types/compiler/validate.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-shape.d.ts +1 -1
- package/types/config-shape.d.ts.map +1 -1
- package/types/config.d.ts +5 -105
- package/types/config.d.ts.map +1 -1
- package/types/dev/preload.d.ts.map +1 -1
- package/types/lsp/server.d.ts.map +1 -1
- package/types/migrate/markup.d.ts.map +1 -1
- package/types/runtime/action-call.d.ts.map +1 -1
- package/types/runtime/action-encode.d.ts +1 -0
- package/types/runtime/action-encode.d.ts.map +1 -1
- package/types/runtime/action-error.d.ts +1 -2
- package/types/runtime/action-error.d.ts.map +1 -1
- package/types/runtime/action-run.d.ts.map +1 -1
- package/types/runtime/action-shared.d.ts +1 -27
- package/types/runtime/action-shared.d.ts.map +1 -1
- package/types/runtime/action-stream.d.ts.map +1 -1
- package/types/runtime/action.d.ts +1 -1
- package/types/runtime/action.d.ts.map +1 -1
- package/types/runtime/call-result.d.ts +0 -10
- package/types/runtime/call-result.d.ts.map +1 -1
- package/types/runtime/checks.d.ts +14 -11
- package/types/runtime/checks.d.ts.map +1 -1
- package/types/runtime/client.d.ts.map +1 -1
- package/types/runtime/core.d.ts +2 -20
- package/types/runtime/core.d.ts.map +1 -1
- package/types/runtime/dom.d.ts +1 -1
- package/types/runtime/dom.d.ts.map +1 -1
- package/types/runtime/html.d.ts +1 -1
- package/types/runtime/html.d.ts.map +1 -1
- package/types/runtime/i18n.client.d.ts +0 -1
- package/types/runtime/i18n.client.d.ts.map +1 -1
- package/types/runtime/i18n.d.ts +1 -1
- package/types/runtime/i18n.d.ts.map +1 -1
- package/types/runtime/i18n.server.d.ts +0 -1
- package/types/runtime/i18n.server.d.ts.map +1 -1
- package/types/runtime/image.d.ts.map +1 -1
- package/types/runtime/index.d.ts +3 -3
- 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/live-resource.server.d.ts.map +1 -1
- package/types/runtime/live-value.shared.d.ts +7 -15
- package/types/runtime/live-value.shared.d.ts.map +1 -1
- package/types/runtime/live.d.ts +0 -11
- package/types/runtime/live.d.ts.map +1 -1
- package/types/runtime/local-types.d.ts +0 -14
- package/types/runtime/local-types.d.ts.map +1 -1
- package/types/runtime/navigate-api.d.ts +0 -4
- package/types/runtime/navigate-api.d.ts.map +1 -1
- package/types/runtime/navigate.d.ts.map +1 -1
- package/types/runtime/navigation-state.d.ts +0 -4
- package/types/runtime/navigation-state.d.ts.map +1 -1
- package/types/runtime/navigation.d.ts +2 -0
- package/types/runtime/navigation.d.ts.map +1 -1
- package/types/runtime/page-swap.d.ts.map +1 -1
- package/types/runtime/persist.d.ts +1 -0
- package/types/runtime/persist.d.ts.map +1 -1
- package/types/runtime/persisted.d.ts +0 -15
- package/types/runtime/persisted.d.ts.map +1 -1
- package/types/runtime/presence.d.ts +0 -2
- package/types/runtime/presence.d.ts.map +1 -1
- package/types/runtime/query-param.d.ts.map +1 -1
- package/types/runtime/reactive.d.ts +2 -1
- package/types/runtime/reactive.d.ts.map +1 -1
- package/types/runtime/refuse.d.ts +0 -7
- package/types/runtime/refuse.d.ts.map +1 -1
- package/types/runtime/store-base.d.ts +1 -2
- package/types/runtime/store-base.d.ts.map +1 -1
- package/types/runtime/swap-flight.d.ts +1 -1
- package/types/runtime/swap-flight.d.ts.map +1 -1
- package/types/runtime/swap-kept.d.ts.map +1 -1
- package/types/runtime/swap-morph.d.ts.map +1 -1
- package/types/runtime/text-hash.d.ts +2 -0
- package/types/runtime/text-hash.d.ts.map +1 -0
- package/types/runtime/uid.server.d.ts.map +1 -1
- package/types/runtime/values.d.ts +6 -1
- package/types/runtime/values.d.ts.map +1 -1
- package/types/runtime/with-query.d.ts +2 -0
- package/types/runtime/with-query.d.ts.map +1 -1
- package/types/server/action-hooks.d.ts +4 -4
- package/types/server/action-hooks.d.ts.map +1 -1
- package/types/server/actions.d.ts.map +1 -1
- package/types/server/api-modules.d.ts +0 -1
- package/types/server/api-modules.d.ts.map +1 -1
- package/types/server/app-stages.d.ts +5 -13
- package/types/server/app-stages.d.ts.map +1 -1
- package/types/server/app.d.ts +3 -8
- package/types/server/app.d.ts.map +1 -1
- package/types/server/auth-mails.d.ts +0 -5
- package/types/server/auth-mails.d.ts.map +1 -1
- package/types/server/env-state.d.ts +1 -0
- package/types/server/env-state.d.ts.map +1 -1
- package/types/server/guard-requirement.d.ts +0 -1
- package/types/server/guard-requirement.d.ts.map +1 -1
- package/types/server/image.d.ts +0 -1
- package/types/server/image.d.ts.map +1 -1
- package/types/server/index.d.ts +0 -2
- package/types/server/index.d.ts.map +1 -1
- package/types/server/job-context.d.ts +1 -1
- package/types/server/job-context.d.ts.map +1 -1
- package/types/server/jobs.d.ts +0 -4
- package/types/server/jobs.d.ts.map +1 -1
- package/types/server/kept-exports.d.ts.map +1 -1
- package/types/server/kv.d.ts +4 -4
- package/types/server/kv.d.ts.map +1 -1
- package/types/server/library.d.ts +1 -3
- package/types/server/library.d.ts.map +1 -1
- package/types/server/mcp.d.ts +0 -1
- package/types/server/mcp.d.ts.map +1 -1
- package/types/server/metrics.d.ts +0 -5
- package/types/server/metrics.d.ts.map +1 -1
- package/types/server/page-settings.d.ts +3 -3
- package/types/server/page-settings.d.ts.map +1 -1
- package/types/server/prerender.d.ts.map +1 -1
- package/types/server/protection.d.ts +6 -6
- package/types/server/protection.d.ts.map +1 -1
- package/types/server/queue.d.ts +1 -3
- package/types/server/queue.d.ts.map +1 -1
- package/types/server/rate-limit.d.ts +0 -2
- package/types/server/rate-limit.d.ts.map +1 -1
- package/types/server/render-document.d.ts +1 -1
- package/types/server/render-document.d.ts.map +1 -1
- package/types/server/routes.d.ts +1 -1
- package/types/server/routes.d.ts.map +1 -1
- package/types/server/scope.d.ts.map +1 -1
- package/types/server/session.d.ts +1 -1
- package/types/server/session.d.ts.map +1 -1
- package/types/server/signals.d.ts.map +1 -1
- package/types/server/signed.d.ts +0 -2
- package/types/server/signed.d.ts.map +1 -1
- package/types/server/source.d.ts +1 -1
- package/types/server/source.d.ts.map +1 -1
- package/types/server/storage.d.ts +0 -4
- package/types/server/storage.d.ts.map +1 -1
- package/types/server/vitals.d.ts +0 -1
- package/types/server/vitals.d.ts.map +1 -1
- package/types/server/work-scope.d.ts +0 -2
- package/types/server/work-scope.d.ts.map +1 -1
- package/types/server/workflow.d.ts +1 -1
- package/types/server/workflow.d.ts.map +1 -1
- package/types/test/index.d.ts.map +1 -1
- package/types/test/site-actions.d.ts +1 -1
- package/types/test/site-actions.d.ts.map +1 -1
- package/types/test/site-keys.d.ts +1 -1
- package/types/test/site-keys.d.ts.map +1 -1
- package/types/test/site-socket.d.ts +1 -1
- package/types/test/site-socket.d.ts.map +1 -1
- package/types/test/site-types.d.ts +0 -8
- package/types/test/site-types.d.ts.map +1 -1
- package/llms/deprecated-lints-1-105-libraries.md +0 -32
- package/llms/deprecated-lints-1-105.md +0 -58
- package/src/check/action-readers.ts +0 -115
- package/src/check/action-type.ts +0 -44
- package/src/check/ai-language.ts +0 -56
- package/src/check/app-hooks.ts +0 -90
- package/src/check/auth-methods.ts +0 -85
- package/src/check/auth-rate-limits.ts +0 -99
- package/src/check/call-result.ts +0 -242
- package/src/check/client-keys.ts +0 -10
- package/src/check/cms-options.ts +0 -81
- package/src/check/config-groups.ts +0 -22
- package/src/check/config-switches.ts +0 -38
- package/src/check/context-import.ts +0 -51
- package/src/check/env-files.ts +0 -31
- package/src/check/format-duration.ts +0 -75
- package/src/check/guard-options.ts +0 -58
- package/src/check/handler-events.ts +0 -149
- package/src/check/hook-context.ts +0 -94
- package/src/check/hook-names.ts +0 -104
- package/src/check/i18n-keys.ts +0 -50
- package/src/check/images-keys.ts +0 -54
- package/src/check/job-shapes.ts +0 -273
- package/src/check/link-flag-tests.ts +0 -130
- package/src/check/live-api.ts +0 -137
- package/src/check/mail-api.ts +0 -67
- package/src/check/one-state-api.ts +0 -357
- package/src/check/pages-options.ts +0 -35
- package/src/check/rate-enforce.ts +0 -53
- package/src/check/refusal-calls.ts +0 -185
- package/src/check/retired-lints.ts +0 -49
- package/src/check/route-keys.ts +0 -166
- package/src/check/secret-keys.ts +0 -83
- package/src/check/socket-frames.ts +0 -102
- package/src/check/source-readers.ts +0 -257
- package/src/check/store-ms.ts +0 -72
- package/src/check/store-names.ts +0 -88
- package/src/check/test-helpers.ts +0 -98
- package/src/check/ttl-names.ts +0 -142
- package/src/compiler/deprecated-ai-labels.ts +0 -97
- package/src/compiler/deprecated-ai-links.ts +0 -63
- package/src/compiler/deprecated-allow.ts +0 -50
- package/src/compiler/deprecated-auth-lints.ts +0 -14
- package/src/compiler/deprecated-auth-signed.ts +0 -29
- package/src/compiler/deprecated-children.ts +0 -66
- package/src/compiler/deprecated-image.ts +0 -116
- package/src/compiler/deprecated-island.ts +0 -155
- package/src/compiler/deprecated-lints-1-105.ts +0 -41
- package/src/compiler/deprecated-page.ts +0 -125
- package/src/compiler/deprecated-parts.ts +0 -22
- package/src/compiler/deprecated-typed-lints.ts +0 -23
- package/src/compiler/deprecated-ui-callbacks.ts +0 -66
- package/src/compiler/deprecated-ui-input.ts +0 -97
- package/src/compiler/deprecated-ui-items.ts +0 -47
- package/src/compiler/old-parts.ts +0 -84
- package/src/runtime/mount.compat.ts +0 -8
- package/src/server/moved-exports.ts +0 -17
- package/types/check/action-readers.d.ts +0 -3
- package/types/check/action-readers.d.ts.map +0 -1
- package/types/check/action-type.d.ts +0 -3
- package/types/check/action-type.d.ts.map +0 -1
- package/types/check/ai-language.d.ts +0 -3
- package/types/check/ai-language.d.ts.map +0 -1
- package/types/check/app-hooks.d.ts +0 -3
- package/types/check/app-hooks.d.ts.map +0 -1
- package/types/check/auth-methods.d.ts +0 -3
- package/types/check/auth-methods.d.ts.map +0 -1
- package/types/check/auth-rate-limits.d.ts +0 -3
- package/types/check/auth-rate-limits.d.ts.map +0 -1
- package/types/check/call-result.d.ts +0 -7
- package/types/check/call-result.d.ts.map +0 -1
- package/types/check/client-keys.d.ts +0 -3
- package/types/check/client-keys.d.ts.map +0 -1
- package/types/check/cms-options.d.ts +0 -3
- package/types/check/cms-options.d.ts.map +0 -1
- package/types/check/config-groups.d.ts +0 -3
- package/types/check/config-groups.d.ts.map +0 -1
- package/types/check/config-switches.d.ts +0 -3
- package/types/check/config-switches.d.ts.map +0 -1
- package/types/check/context-import.d.ts +0 -3
- package/types/check/context-import.d.ts.map +0 -1
- package/types/check/env-files.d.ts +0 -3
- package/types/check/env-files.d.ts.map +0 -1
- package/types/check/format-duration.d.ts +0 -5
- package/types/check/format-duration.d.ts.map +0 -1
- package/types/check/guard-options.d.ts +0 -3
- package/types/check/guard-options.d.ts.map +0 -1
- package/types/check/handler-events.d.ts +0 -9
- package/types/check/handler-events.d.ts.map +0 -1
- package/types/check/hook-context.d.ts +0 -3
- package/types/check/hook-context.d.ts.map +0 -1
- package/types/check/hook-names.d.ts +0 -3
- package/types/check/hook-names.d.ts.map +0 -1
- package/types/check/i18n-keys.d.ts +0 -3
- package/types/check/i18n-keys.d.ts.map +0 -1
- package/types/check/images-keys.d.ts +0 -3
- package/types/check/images-keys.d.ts.map +0 -1
- package/types/check/job-shapes.d.ts +0 -6
- package/types/check/job-shapes.d.ts.map +0 -1
- package/types/check/link-flag-tests.d.ts +0 -4
- package/types/check/link-flag-tests.d.ts.map +0 -1
- package/types/check/live-api.d.ts +0 -3
- package/types/check/live-api.d.ts.map +0 -1
- package/types/check/mail-api.d.ts +0 -3
- package/types/check/mail-api.d.ts.map +0 -1
- package/types/check/one-state-api.d.ts +0 -9
- package/types/check/one-state-api.d.ts.map +0 -1
- package/types/check/pages-options.d.ts +0 -3
- package/types/check/pages-options.d.ts.map +0 -1
- package/types/check/rate-enforce.d.ts +0 -3
- package/types/check/rate-enforce.d.ts.map +0 -1
- package/types/check/refusal-calls.d.ts +0 -3
- package/types/check/refusal-calls.d.ts.map +0 -1
- package/types/check/retired-lints.d.ts +0 -3
- package/types/check/retired-lints.d.ts.map +0 -1
- package/types/check/route-keys.d.ts +0 -3
- package/types/check/route-keys.d.ts.map +0 -1
- package/types/check/secret-keys.d.ts +0 -3
- package/types/check/secret-keys.d.ts.map +0 -1
- package/types/check/socket-frames.d.ts +0 -3
- package/types/check/socket-frames.d.ts.map +0 -1
- package/types/check/source-readers.d.ts +0 -3
- package/types/check/source-readers.d.ts.map +0 -1
- package/types/check/store-ms.d.ts +0 -3
- package/types/check/store-ms.d.ts.map +0 -1
- package/types/check/store-names.d.ts +0 -3
- package/types/check/store-names.d.ts.map +0 -1
- package/types/check/test-helpers.d.ts +0 -3
- package/types/check/test-helpers.d.ts.map +0 -1
- package/types/check/ttl-names.d.ts +0 -3
- package/types/check/ttl-names.d.ts.map +0 -1
- package/types/compiler/deprecated-ai-labels.d.ts +0 -5
- package/types/compiler/deprecated-ai-labels.d.ts.map +0 -1
- package/types/compiler/deprecated-ai-links.d.ts +0 -5
- package/types/compiler/deprecated-ai-links.d.ts.map +0 -1
- package/types/compiler/deprecated-allow.d.ts +0 -5
- package/types/compiler/deprecated-allow.d.ts.map +0 -1
- package/types/compiler/deprecated-auth-lints.d.ts +0 -12
- package/types/compiler/deprecated-auth-lints.d.ts.map +0 -1
- package/types/compiler/deprecated-auth-signed.d.ts +0 -5
- package/types/compiler/deprecated-auth-signed.d.ts.map +0 -1
- package/types/compiler/deprecated-children.d.ts +0 -4
- package/types/compiler/deprecated-children.d.ts.map +0 -1
- package/types/compiler/deprecated-image.d.ts +0 -5
- package/types/compiler/deprecated-image.d.ts.map +0 -1
- package/types/compiler/deprecated-island.d.ts +0 -9
- package/types/compiler/deprecated-island.d.ts.map +0 -1
- package/types/compiler/deprecated-lints-1-105.d.ts +0 -39
- package/types/compiler/deprecated-lints-1-105.d.ts.map +0 -1
- package/types/compiler/deprecated-page.d.ts +0 -4
- package/types/compiler/deprecated-page.d.ts.map +0 -1
- package/types/compiler/deprecated-parts.d.ts +0 -3
- package/types/compiler/deprecated-parts.d.ts.map +0 -1
- package/types/compiler/deprecated-typed-lints.d.ts +0 -21
- package/types/compiler/deprecated-typed-lints.d.ts.map +0 -1
- package/types/compiler/deprecated-ui-callbacks.d.ts +0 -5
- package/types/compiler/deprecated-ui-callbacks.d.ts.map +0 -1
- package/types/compiler/deprecated-ui-input.d.ts +0 -5
- package/types/compiler/deprecated-ui-input.d.ts.map +0 -1
- package/types/compiler/deprecated-ui-items.d.ts +0 -5
- package/types/compiler/deprecated-ui-items.d.ts.map +0 -1
- package/types/compiler/old-parts.d.ts +0 -9
- package/types/compiler/old-parts.d.ts.map +0 -1
- package/types/runtime/mount.compat.d.ts +0 -7
- package/types/runtime/mount.compat.d.ts.map +0 -1
- package/types/server/moved-exports.d.ts +0 -12
- package/types/server/moved-exports.d.ts.map +0 -1
package/src/migrate/markup.ts
CHANGED
|
@@ -61,6 +61,9 @@ function hydrateOf(name: string, attribute: { type: string, value?: unknown } |
|
|
|
61
61
|
return name in HYDRATE ? { value: HYDRATE[name] } : undefined
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
// `client:only` is `render="client"`, the other directives a `hydrate` value.
|
|
65
|
+
const hydrateAttribute = (hydrate: string): string => hydrate === 'client' ? 'render="client"' : `hydrate="${hydrate}"`
|
|
66
|
+
|
|
64
67
|
export interface RawBlock {
|
|
65
68
|
tag: string
|
|
66
69
|
attributes: string
|
|
@@ -611,7 +614,7 @@ class Translator {
|
|
|
611
614
|
}
|
|
612
615
|
|
|
613
616
|
if (hydrate !== undefined)
|
|
614
|
-
attributes.push(
|
|
617
|
+
attributes.push(hydrateAttribute(hydrate))
|
|
615
618
|
|
|
616
619
|
// Several static classes left out of the shorthand join in one attribute.
|
|
617
620
|
const classes = attributes.filter(attribute => attribute.startsWith('class="'))
|
|
@@ -79,10 +79,6 @@ export function reviveActions(): void {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
function succeededOf(found: Outcome | undefined): { data: unknown } | undefined {
|
|
83
|
-
return found?.succeeded ? { data: found.data } : undefined
|
|
84
|
-
}
|
|
85
|
-
|
|
86
82
|
function statusOf(inFlight: number, found: Outcome | undefined, failed: object | undefined): LoadStatus {
|
|
87
83
|
if (inFlight > 0)
|
|
88
84
|
return 'loading'
|
|
@@ -205,12 +201,8 @@ export function callable(url: () => string): { call: (input: never, options?: Ca
|
|
|
205
201
|
...formHooks(url),
|
|
206
202
|
progress: read(progress),
|
|
207
203
|
form: read({ failed, error, validate }),
|
|
208
|
-
failed: read(failed),
|
|
209
|
-
succeeded: read(() => succeededOf(outcome())),
|
|
210
204
|
data: read(() => outcome()?.succeeded ? outcome()?.data : undefined),
|
|
211
205
|
status: read(() => statusOf(inFlight(), outcome(), failed())),
|
|
212
|
-
error: read(error),
|
|
213
|
-
validate: read(validate),
|
|
214
206
|
refused: read((error: unknown) => error instanceof ActionError && refusedAt.get(error) === url()),
|
|
215
207
|
track: read(track),
|
|
216
208
|
with: read((fields: Record<string, unknown>) => withFields(call, fields)),
|
|
@@ -15,6 +15,32 @@ export interface EncodedCall {
|
|
|
15
15
|
body: string | FormData
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
// A call of an action `with()` fixed fields of is made with them, over the ones it is given, as a form posting to its URL does: a field fixed to `null` or `undefined` is left out there, so the given one stays.
|
|
19
|
+
export function withFixed(input: unknown, fixed: Record<string, unknown> | undefined): unknown {
|
|
20
|
+
if (fixed === undefined)
|
|
21
|
+
return input
|
|
22
|
+
|
|
23
|
+
const set = Object.entries(fixed).filter(([name, value]) => name !== '__proto__' && value !== undefined && value !== null)
|
|
24
|
+
|
|
25
|
+
if (!(input instanceof FormData))
|
|
26
|
+
return { ...input as object | undefined, ...Object.fromEntries(set) }
|
|
27
|
+
|
|
28
|
+
const names = new Set(set.map(([name]) => name))
|
|
29
|
+
const copy = new FormData()
|
|
30
|
+
|
|
31
|
+
for (const [name, value] of input) {
|
|
32
|
+
if (!names.has(name))
|
|
33
|
+
copy.append(name, value)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
for (const [name, value] of set) {
|
|
37
|
+
for (const item of Array.isArray(value) ? value : [value])
|
|
38
|
+
copy.append(name, item instanceof Date ? item.toISOString() : String(item))
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return copy
|
|
42
|
+
}
|
|
43
|
+
|
|
18
44
|
// The encoding keeps numbers, booleans and Dates typed, which form fields would turn into strings; only a call carrying files needs multipart, whose boundary fetch writes.
|
|
19
45
|
export function encodeCall(input: unknown): EncodedCall {
|
|
20
46
|
// Sent as the form it is, for the server to read as a form post and answer as a call.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { Failure
|
|
1
|
+
import type { Failure } from './action-shared'
|
|
2
2
|
import { actionFailed, ApiError, messageOf } from './api-error'
|
|
3
|
-
import { KayError } from './kay-error'
|
|
4
3
|
|
|
5
4
|
export const FAILURE = Symbol.for('kay.failure')
|
|
6
5
|
|
|
@@ -8,7 +7,7 @@ export const FAILURE = Symbol.for('kay.failure')
|
|
|
8
7
|
export class ActionError<Data = unknown> extends ApiError<Data> {
|
|
9
8
|
override name = 'ActionError'
|
|
10
9
|
|
|
11
|
-
// `errors` holds a message per field the schema refused, `data` what the handler passed to `ctx.
|
|
10
|
+
// `errors` holds a message per field the schema refused, `data` what the handler passed to `ctx.deny`, undefined when the call was refused before it ran; `message` reads them, else the status and body.
|
|
12
11
|
constructor(status: number, readonly body: string, errors: Record<string, string> = {}, data?: Data, message = messageOf({ status, errors, data }, actionFailed(status))) {
|
|
13
12
|
super(status, message, data, errors)
|
|
14
13
|
}
|
|
@@ -24,14 +23,7 @@ export class ActionRedirectError extends ActionError {
|
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
// A call reads a success status as the handler's result, so a failure must not carry one.
|
|
29
|
-
if (!Number.isInteger(status) || status < 400 || status > 599)
|
|
30
|
-
throw new KayError('argument-invalid', `kay: ctx.deny takes an error status, from 400 to 599, not ${status}`)
|
|
31
|
-
|
|
32
|
-
return { [FAILURE]: true, status, data, errors }
|
|
33
|
-
}
|
|
34
|
-
|
|
26
|
+
// What a library's failed result is to an action: kayjs-auth's carries the mark, a status and its kind as `data`, so returning it refuses the call.
|
|
35
27
|
export function isFailure(value: unknown): value is Failure<unknown> {
|
|
36
28
|
return typeof value === 'object' && value !== null && FAILURE in value
|
|
37
29
|
}
|
|
@@ -28,7 +28,7 @@ export function workOf(protection: ResolvedProtection): { difficulty: number, ma
|
|
|
28
28
|
if (!Number.isInteger(difficulty) || difficulty < 1 || difficulty > 1e9)
|
|
29
29
|
throw new KayError('config-invalid', `kay: proofOfWork's difficulty is ${difficulty}; it takes a whole number from 1 to 1,000,000,000`)
|
|
30
30
|
|
|
31
|
-
return { difficulty, maxAge: durationSeconds(options.ttl ??
|
|
31
|
+
return { difficulty, maxAge: durationSeconds(options.ttl ?? DAY, 'proofOfWork.ttl') * 1000, pretend: options.pretend === true, store: options.store }
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
// `minTime` in milliseconds, read once it is set.
|
|
@@ -40,7 +40,7 @@ export function minTimeOf(protection: ResolvedProtection): { after: number, maxA
|
|
|
40
40
|
|
|
41
41
|
const options = typeof minTime === 'object' ? minTime : { after: minTime }
|
|
42
42
|
|
|
43
|
-
return { after: durationSeconds(options.after, 'minTime') * 1000, maxAge: durationSeconds(options.ttl ??
|
|
43
|
+
return { after: durationSeconds(options.after, 'minTime') * 1000, maxAge: durationSeconds(options.ttl ?? DAY, 'minTime.ttl') * 1000, pretend: options.pretend === true }
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export function honeypotField(protection: ResolvedProtection | undefined): string | undefined {
|
|
@@ -2,6 +2,7 @@ import type { Caller } from './action-owner'
|
|
|
2
2
|
import type { ActionStream, CallOptions, CallQueue, Outcome } from './action-shared'
|
|
3
3
|
import type { Duration } from './duration'
|
|
4
4
|
import type { ConnectionStatus } from './live'
|
|
5
|
+
import { withFixed } from './action-encode'
|
|
5
6
|
import { ActionError, ActionRedirectError } from './action-error'
|
|
6
7
|
import { networkFailures, superseding } from './action-marks'
|
|
7
8
|
import { refreshed, refreshedIn, refreshedUnlessFollowed } from './action-navigate'
|
|
@@ -147,32 +148,6 @@ async function hooked<Event>(hook: ((event: Event) => unknown) | undefined, even
|
|
|
147
148
|
}
|
|
148
149
|
}
|
|
149
150
|
|
|
150
|
-
// A call of an action `with()` fixed fields of is made with them, over the ones it is given, as a form posting to its URL does: a field fixed to `null` or `undefined` is left out there, so the given one stays.
|
|
151
|
-
function withFixed(input: unknown, fixed: Record<string, unknown> | undefined): unknown {
|
|
152
|
-
if (fixed === undefined)
|
|
153
|
-
return input
|
|
154
|
-
|
|
155
|
-
const set = Object.entries(fixed).filter(([name, value]) => name !== '__proto__' && value !== undefined && value !== null)
|
|
156
|
-
|
|
157
|
-
if (!(input instanceof FormData))
|
|
158
|
-
return { ...input as object | undefined, ...Object.fromEntries(set) }
|
|
159
|
-
|
|
160
|
-
const names = new Set(set.map(([name]) => name))
|
|
161
|
-
const copy = new FormData()
|
|
162
|
-
|
|
163
|
-
for (const [name, value] of input) {
|
|
164
|
-
if (!names.has(name))
|
|
165
|
-
copy.append(name, value)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
for (const [name, value] of set) {
|
|
169
|
-
for (const item of Array.isArray(value) ? value : [value])
|
|
170
|
-
copy.append(name, item instanceof Date ? item.toISOString() : String(item))
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return copy
|
|
174
|
-
}
|
|
175
|
-
|
|
176
151
|
// Refreshes what a call changed once it is done, started before the caller goes on, so a navigation it starts next supersedes the refresh rather than the other way round; a site with `navigation: false` shows a call's effects itself.
|
|
177
152
|
function refresher(options: CallOptions | undefined, caller: Caller, left: () => boolean): () => void {
|
|
178
153
|
return () => {
|
|
@@ -288,7 +263,7 @@ export async function run(host: Host, start: Start, lane: Lane, given: unknown,
|
|
|
288
263
|
|
|
289
264
|
const streamEnded = (status: ConnectionStatus) => {
|
|
290
265
|
if (status === 'done') {
|
|
291
|
-
host.called(page, { action: host.url(), succeeded: true, data: untrack((answer as ActionStream<unknown>).
|
|
266
|
+
host.called(page, { action: host.url(), succeeded: true, data: untrack((answer as ActionStream<unknown>).data) }, turn)
|
|
292
267
|
refreshPage()
|
|
293
268
|
}
|
|
294
269
|
|
|
@@ -16,9 +16,9 @@ export type { CallResult }
|
|
|
16
16
|
|
|
17
17
|
export const ACTION = Symbol.for('kay.action')
|
|
18
18
|
|
|
19
|
-
// Type only: what the handler returns on success, so a prop typed with it takes a handler that can also `ctx.
|
|
19
|
+
// Type only: what the handler returns on success, so a prop typed with it takes a handler that can also `ctx.deny`.
|
|
20
20
|
declare const RESULT: unique symbol
|
|
21
|
-
// Type only: what the handler passes to `ctx.
|
|
21
|
+
// Type only: what the handler passes to `ctx.deny`, so a page can type `action.form.failed()`.
|
|
22
22
|
declare const FAILED: unique symbol
|
|
23
23
|
// Type only: the honeypot field an action's forms render, which `kay check` then takes as one of their fields.
|
|
24
24
|
declare const HONEYPOT: unique symbol
|
|
@@ -26,9 +26,8 @@ declare const HONEYPOT: unique symbol
|
|
|
26
26
|
// Where rate limits count, shared by every process opening it: `sqliteRates` from `kay/server`, or one of an app's own.
|
|
27
27
|
export interface RateStore extends StoreBase {
|
|
28
28
|
// Counts `weight` more under `key`, one attempt unless given, opening a window of `window` when none is open: the count in it so far, this hit included, and when it closes, in ms since the epoch. A store of its own adds `weight` to the count, or a weighted limit, tokens say, refuses it.
|
|
29
|
-
// `window` is a `Duration
|
|
30
|
-
|
|
31
|
-
hit(key: string, window: Duration | number, weight?: number): MaybePromise<RateWindow>
|
|
29
|
+
// `window` is a `Duration`: `lengthMs(window)` from `kay` reads it.
|
|
30
|
+
hit: (key: string, window: Duration, weight?: number) => MaybePromise<RateWindow>
|
|
32
31
|
// The window open under `key` without counting an attempt, undefined when none is: what a limit counting only the posts that went through reads before the handler runs. A `limiter` derives it, with a hit of weight 0, for a store without it.
|
|
33
32
|
peek?: (key: string) => MaybePromise<RateWindow | undefined>
|
|
34
33
|
// Takes back one attempt `hit` counted under `key` in the window closing at `resetAt`, never below zero, and does nothing once that window is gone: how kay lets a call that started no work, such as kayjs-ai's resume of a reply it keeps, not spend the limit. A store without it simply keeps the attempt counted.
|
|
@@ -70,7 +69,7 @@ export type RateKeyContext = Pick<RequestContext, 'request' | 'locale' | 'cookie
|
|
|
70
69
|
export type RateKey = (ctx: RateKeyContext) => string | undefined | Promise<string | undefined>
|
|
71
70
|
|
|
72
71
|
export interface ActionRateLimit extends RateLimit {
|
|
73
|
-
// `'succeeded'` counts only the posts whose handler returned without `ctx.
|
|
72
|
+
// `'succeeded'` counts only the posts whose handler returned without `ctx.deny` or an error, so typos and a failing mail server lock no one out; every attempt counts unless given. Posts arriving together all read the count before any adds to it, so a burst may pass `max` by a few: pair it with a limit on every attempt.
|
|
74
73
|
count?: 'succeeded' | undefined
|
|
75
74
|
}
|
|
76
75
|
|
|
@@ -87,8 +86,6 @@ export interface MinTimeOptions {
|
|
|
87
86
|
after: Duration
|
|
88
87
|
// The most, past which a post is refused as sent from a page left open too long or a copied stamp: a day by default.
|
|
89
88
|
ttl?: Duration | undefined
|
|
90
|
-
/** @deprecated Written `ttl`; `deprecated-ttl-names` rewrites it. Removed in 1.108. */
|
|
91
|
-
maxAge?: Duration | undefined
|
|
92
89
|
// Answers a post sent too soon as if it went through, the handler never running, rather than refusing it.
|
|
93
90
|
pretend?: boolean | undefined
|
|
94
91
|
// Checks only a form the browser posts itself, without kay's script, leaving a page swap's post and a call to what checks those, such as a proof of work.
|
|
@@ -100,8 +97,6 @@ export interface ProofOfWorkOptions {
|
|
|
100
97
|
difficulty?: number | undefined
|
|
101
98
|
// How long a challenge stays good: a day by default.
|
|
102
99
|
ttl?: Duration | undefined
|
|
103
|
-
/** @deprecated Written `ttl`; `deprecated-ttl-names` rewrites it. Removed in 1.108. */
|
|
104
|
-
maxAge?: Duration | undefined
|
|
105
100
|
// Answers a wrong or replayed solution as if it went through, the handler never running, rather than refusing it.
|
|
106
101
|
pretend?: boolean | undefined
|
|
107
102
|
// Where the solutions already used are kept until their challenge expires: this process's memory by default, `sqliteRates(path)` to share them between the processes of a machine.
|
|
@@ -148,13 +143,11 @@ export interface ActionProtect<Field extends string = never> {
|
|
|
148
143
|
proofOfWork?: boolean | number | ProofOfWorkOptions | undefined
|
|
149
144
|
}
|
|
150
145
|
|
|
151
|
-
// What the hooks of an action are told of a run: the action's export name and its file relative to the directory the server runs from, the input the schema accepted
|
|
146
|
+
// What the hooks of an action are told of a run: the action's export name and its file relative to the directory the server runs from, and the input the schema accepted.
|
|
152
147
|
export interface ActionRun {
|
|
153
148
|
action: string
|
|
154
149
|
file: string
|
|
155
150
|
input: unknown
|
|
156
|
-
/** @deprecated Written `context`, which is the action's context with the hook's `ip`, `userAgent` and `userId`; `deprecated-hook-context` rewrites it. Removed in 1.108. */
|
|
157
|
-
ctx: ActionContext
|
|
158
151
|
}
|
|
159
152
|
|
|
160
153
|
// What an action's hooks are told as `context`: the action's own (`request`, `locals`, `cookies`, `params`, `locale`), with the hook's `ip`, `userAgent` and `userId`.
|
|
@@ -165,7 +158,7 @@ export interface ActionDone extends ActionRun {
|
|
|
165
158
|
result: unknown
|
|
166
159
|
}
|
|
167
160
|
|
|
168
|
-
// A run that did not go through, as the visitor is told: `status`, `message`, field `errors` and `data` are the failure shape (`
|
|
161
|
+
// A run that did not go through, as the visitor is told: `status`, `message`, field `errors` and `data` are the failure shape (`refuse()`, `ctx.deny`, a server error); `error` is what was thrown.
|
|
169
162
|
export interface ActionFailed extends ActionRun {
|
|
170
163
|
status: number
|
|
171
164
|
message: string
|
|
@@ -180,7 +173,7 @@ export interface ActionHooks {
|
|
|
180
173
|
beforeRun?: BeforeHook<ActionRun, never, ActionHookContext> | undefined
|
|
181
174
|
// Told after the handler returned, a redirect it threw included. A throw is reported and never fails the action.
|
|
182
175
|
onSuccess?: Hook<ActionDone, ActionHookContext> | undefined
|
|
183
|
-
// Told after the handler failed with `
|
|
176
|
+
// Told after the handler failed with `refuse()`, `ctx.deny()`, `ctx.notFound()` or an error. A redirect is no failure.
|
|
184
177
|
onError?: Hook<ActionFailed, ActionHookContext> | undefined
|
|
185
178
|
}
|
|
186
179
|
|
|
@@ -238,8 +231,6 @@ export interface ActionContext<Params extends Readonly<Record<string, unknown>>
|
|
|
238
231
|
// `errors` puts a message on a field of the schema, or on the form under `''`: `return ctx.deny(409, { errors: { email: 'Already taken' } })`, which `error email`, `aria-invalid`, `add.form.error('email')` and an `ActionError`'s `errors` follow as for a field the schema refused.
|
|
239
232
|
// It throws, so a statement ends the handler too; `return` types what `data` is for `action.form.failed()`.
|
|
240
233
|
deny: ActionDeny<Field>
|
|
241
|
-
/** @deprecated `return ctx.deny(status, { data, errors })`. Removed in 1.108; `deprecated-ctx-fail` rewrites it. */
|
|
242
|
-
fail: <const Data = undefined, const Status extends number = number>(status: Status & ErrorStatus<Status>, data?: Data, errors?: FieldErrors<Field>) => Failure<Data>
|
|
243
234
|
}
|
|
244
235
|
|
|
245
236
|
// `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.
|
|
@@ -248,8 +239,6 @@ export interface ActionDeny<Field extends string = string> {
|
|
|
248
239
|
<const Data = undefined, const Status extends number = number>(status: Status & ErrorStatus<Status>, options: DenyOptions<Data, Field>): Failure<Data>
|
|
249
240
|
// What a helper taking the guard's `deny` sees: an action's context passes as one.
|
|
250
241
|
<const Status extends number = number>(status?: Status & ErrorStatus<Status>, options?: DenyOptions<ErrorData>): never
|
|
251
|
-
/** @deprecated `deny(status, { message, data })`. Removed in 1.108; `deprecated-deny-call` rewrites it. */
|
|
252
|
-
(status: number, message: string, data?: unknown): never
|
|
253
242
|
}
|
|
254
243
|
|
|
255
244
|
// A message per field of the action's schema, and under `''` one for the whole form.
|
|
@@ -277,7 +266,7 @@ export type Answer<Output> = Output extends AsyncIterable<infer Value> ? ActionS
|
|
|
277
266
|
// What a plain form post reads back: the last value of an async iterable, which is undefined when it gave none.
|
|
278
267
|
export type Final<Output> = Output extends AsyncIterable<infer Value> ? Value | undefined : Output
|
|
279
268
|
|
|
280
|
-
// Unknown for an action of any output, so any action passes where `Action` is expected, and for one whose output names no `Failure`, so a handler that can `ctx.
|
|
269
|
+
// Unknown for an action of any output, so any action passes where `Action` is expected, and for one whose output names no `Failure`, so a handler that can `ctx.deny` passes where only its success output is typed.
|
|
281
270
|
export type FailureData<Output> = unknown extends Output ? unknown : [Extract<Output, Failure<unknown>>] extends [never] ? unknown : Output extends Failure<infer Data> ? Data : never
|
|
282
271
|
|
|
283
272
|
// What a page reads back through `action.form.failed()` after a plain form post failed.
|
|
@@ -289,14 +278,14 @@ export interface FormFailure<Input, Data, Honeypot extends string = never> {
|
|
|
289
278
|
values: Partial<Record<Extract<keyof Input, string>, string>>
|
|
290
279
|
// A message per field the schema refused or the honeypot caught, and under '' one for the whole form, as a rate limit's refusal.
|
|
291
280
|
errors: Partial<Record<Extract<keyof Input, string> | Honeypot | '', string>>
|
|
292
|
-
// What the handler passed to `ctx.
|
|
281
|
+
// What the handler passed to `ctx.deny`; undefined when the schema refused the input.
|
|
293
282
|
data?: Data
|
|
294
283
|
}
|
|
295
284
|
|
|
296
285
|
// Read off the phantom directly: `infer Output` through `Action` drops the `undefined` of a handler ending without a return.
|
|
297
286
|
export type ResultOf<Target> = Target extends { readonly [RESULT]?: infer Output } ? Output : never
|
|
298
287
|
|
|
299
|
-
// What the handler passes to `ctx.
|
|
288
|
+
// What the handler passes to `ctx.deny`, read off its phantom for the same reason.
|
|
300
289
|
export type FailuresOf<Target> = Target extends { readonly [FAILED]?: infer Data } ? Data : never
|
|
301
290
|
|
|
302
291
|
// The input an action's schema describes, as a form posts it or a call takes it.
|
|
@@ -304,7 +293,7 @@ export type InputOf<Target> = Target extends Action<infer Input, unknown> ? Inpu
|
|
|
304
293
|
|
|
305
294
|
export type FailureOf<Target> = Target extends Action<infer Input, unknown> ? FormFailure<Input, FailuresOf<Target>, Extract<HoneypotOf<Target>, string>> : never
|
|
306
295
|
|
|
307
|
-
// What a page reads back
|
|
296
|
+
// What a page reads back after a plain form post succeeded.
|
|
308
297
|
export interface FormSuccess<Output> {
|
|
309
298
|
// What the handler returned.
|
|
310
299
|
data: Output
|
|
@@ -409,8 +398,6 @@ export interface TrackedCall<Input, Result> extends Reader<Result extends { ok:
|
|
|
409
398
|
readonly data: () => (Result extends { ok: true, data: infer Data } ? Data : never) | undefined
|
|
410
399
|
// Called with `{ value, input }` when a call succeeds (for a stream, once it is open), `input` what the call was given; returns what stops it. Hooks given to `track()` run first.
|
|
411
400
|
onData: (listener: (event: { value: Result extends { ok: true, data: infer Data } ? Data : never, input: unknown }) => void) => () => void
|
|
412
|
-
/** @deprecated Write `onData`, which hands `value` where this hands `data`. Removed in 1.108.0; `deprecated-source-readers` rewrites it. */
|
|
413
|
-
onSuccess: (listener: (event: { data: Result extends { ok: true, data: infer Data } ? Data : never, input: unknown }) => void) => () => void
|
|
414
401
|
// Called with `{ error, input }` when a call fails, a refusal or no answer, not for an abort or a redirect; returns what stops it.
|
|
415
402
|
onError: (listener: (event: { error: ApiError, input: unknown }) => void) => () => void
|
|
416
403
|
}
|
|
@@ -445,16 +432,12 @@ export interface Action<Input = never, Output = unknown, Honeypot extends string
|
|
|
445
432
|
readonly onData: (listener: (event: { input: FormData }) => void) => () => void
|
|
446
433
|
readonly onError: (listener: (event: { error: ApiError, input: FormData }) => void) => () => void
|
|
447
434
|
// A handle for the calls of one island, one row or one button: `const save = add.track()`, then `await save(input)` resolves with `{ ok, data }` or the refusal, and `save.pending()` reads only its own calls.
|
|
448
|
-
// `track({ queue: 'latest' })` sets how the handle's own calls queue, in place of each call's `queue` option; `track({
|
|
435
|
+
// `track({ queue: 'latest' })` sets how the handle's own calls queue, in place of each call's `queue` option; `track({ onData, onError })` takes the callbacks of every call of the handle, which `onData()` and `onError()` of the handle add to.
|
|
449
436
|
readonly track: (options?: { queue?: CallQueue | undefined } & TrackHooks<Answer<Success<Output>>>) => TrackedCall<Input, CallResult<Answer<Success<Output>>, FailureData<Output>>>
|
|
450
437
|
// How much of the last call carrying files the browser sent, from 0 to 1, while it uploads; undefined otherwise: `progress(value={upload.progress()})`.
|
|
451
438
|
readonly progress: () => number | undefined
|
|
452
439
|
// What a form posting to this action shows: how the post the page renders for went, refused, and the message of each field. Apart from the call state above, which is the island's own calls.
|
|
453
440
|
readonly form: ActionForm<Input, Output, Honeypot>
|
|
454
|
-
/** @deprecated Write `form.failed()`, the readers a form shows are grouped under `form`. Removed in 1.108.0; `deprecated-action-readers` rewrites it. */
|
|
455
|
-
readonly failed: () => FormFailure<Input, FailureData<Output>, Honeypot> | undefined
|
|
456
|
-
/** @deprecated Write `data()`, which reads what the last success returned; `status() === 'ready'` tells whether there was one. Removed in 1.108.0; `deprecated-source-readers` rewrites it. */
|
|
457
|
-
readonly succeeded: () => FormSuccess<Final<Success<Output>>> | undefined
|
|
458
441
|
// What the last call, or the form post the page rendered for, returned; undefined before one succeeded and after a later one failed.
|
|
459
442
|
readonly data: () => Final<Success<Output>> | undefined
|
|
460
443
|
// `idle` before the first call, `loading` while one is in flight, then `ready` or `failed` by the last to settle, as on every source.
|
|
@@ -462,13 +445,7 @@ export interface Action<Input = never, Output = unknown, Honeypot extends string
|
|
|
462
445
|
// This action for a form to post with fixed fields, as hidden inputs would carry them: `form(action={move.with({ id, to: 2 })})`. They travel in the form's action URL, so the form needs no inputs for them and posts them with or without JavaScript.
|
|
463
446
|
// eslint-disable-next-line ts/method-signature-style
|
|
464
447
|
with(fields: Partial<Input>): Action<Input, Output, Honeypot>
|
|
465
|
-
|
|
466
|
-
// eslint-disable-next-line ts/method-signature-style
|
|
467
|
-
error(field?: Extract<keyof Input, string> | Honeypot | ''): string | undefined
|
|
468
|
-
/** @deprecated Write `form.validate(form, field)`. Removed in 1.108.0; `deprecated-action-readers` rewrites it. */
|
|
469
|
-
// eslint-disable-next-line ts/method-signature-style
|
|
470
|
-
validate(form: HTMLFormElement, field?: Extract<keyof Input, string>): Promise<boolean>
|
|
471
|
-
// Whether `error` is a call to this action the server refused, its `data` typed as the handler passes it to `ctx.fail`.
|
|
448
|
+
// Whether `error` is a call to this action the server refused, its `data` typed as the handler passes it to `ctx.deny`.
|
|
472
449
|
// eslint-disable-next-line ts/method-signature-style
|
|
473
450
|
refused(error: unknown): error is ActionError<FailureData<Output>>
|
|
474
451
|
readonly url: string
|
package/src/runtime/action.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { ACTION_PREFIX } from './wire'
|
|
|
16
16
|
export { actionStub, OUTCOME_SCRIPT, setRequestOutcome } from './action-call'
|
|
17
17
|
export { decodeCall, encodeCall, FILE_MARK, FORM_CALL, INPUT_PART } from './action-encode'
|
|
18
18
|
export type { EncodedCall } from './action-encode'
|
|
19
|
-
export { ActionError, ActionRedirectError,
|
|
19
|
+
export { ActionError, ActionRedirectError, isFailure } from './action-error'
|
|
20
20
|
export { carrySchema, collectForms, FORM_FIELD, formAction, formChecked, formDescribed, formError, formErrors, formHere, formInitial, formInitialChecked, formInvalid, formKey, formMarked, formProtection, formScope, formStart, formValue, issueScope, PAYLOAD_PARAM, postedChecked, postedValue, postedValues, protectionFields, setStamper, STAMP_FIELD } from './action-form'
|
|
21
21
|
export type { FieldName } from './action-form'
|
|
22
22
|
export { SETTLED } from './action-owner'
|
|
@@ -7,7 +7,7 @@ import { ownSignal, untrack } from './reactive'
|
|
|
7
7
|
// The mark a call's result carries (not enumerable), so a reader tells it from an answer shaped like one, such as an entry write's `{ ok: false, error, issues }`: `unwrapped` of kayjs-ui looks for it by name, and `CallResult` names it as an optional key, which is how a type tells a result from such an answer.
|
|
8
8
|
const RESULT: unique symbol = Symbol.for('kay.call-result')
|
|
9
9
|
|
|
10
|
-
// How a tracked call went, for an action and for a route alike: what it answered, or the refusal. `message` is the text to show; `errors` holds a message per field, the form-wide one under ''; `data` is what the handler passed to `ctx.
|
|
10
|
+
// How a tracked call went, for an action and for a route alike: what it answered, or the refusal. `message` is the text to show; `errors` holds a message per field, the form-wide one under ''; `data` is what the handler passed to `ctx.deny` for an action, the answer a route refused with for a route.
|
|
11
11
|
// A refusal carries them twice, flat on the result and as its `error`, the one place every other result keeps its failure: the `ApiError` itself (an `ActionError` for an action), so `orThrow()` and a `throw result.error` throw what the call threw.
|
|
12
12
|
export type CallResult<Data, Failed>
|
|
13
13
|
= | { ok: true, data: Data, error?: undefined, readonly [RESULT]?: true }
|
|
@@ -71,8 +71,6 @@ export function settling<Data>(throwing: Promise<Data>, refused: (error: unknown
|
|
|
71
71
|
export interface TrackHooks<Data> {
|
|
72
72
|
// A call succeeded, `value` what it answered; for a streaming action, once the stream is open.
|
|
73
73
|
onData?: ((event: { value: Data, input: unknown }) => void) | undefined
|
|
74
|
-
/** @deprecated Write `onData`, which hands `value` where this hands `data`. Removed in 1.108.0; `deprecated-source-readers` rewrites it. */
|
|
75
|
-
onSuccess?: ((event: { data: Data, input: unknown }) => void) | undefined
|
|
76
74
|
// A call failed, for a refusal and for no answer alike; not for an abort or a redirect.
|
|
77
75
|
onError?: ((event: { error: ApiError, input: unknown }) => void) | undefined
|
|
78
76
|
}
|
|
@@ -106,14 +104,10 @@ export function trackCalls<Args extends unknown[]>(
|
|
|
106
104
|
// An error that is no failure of the call, such as a redirect, which `status()`, `error()` and `retry()` leave alone (a retry would post a login or a checkout again).
|
|
107
105
|
aside?: (error: unknown) => boolean,
|
|
108
106
|
hooks?: TrackHooks<never>,
|
|
109
|
-
): ((...args: Args) => CallPromise<CallResult<unknown, unknown>>) & Reader<unknown, LoadStatus> & { settled: () => Promise<void> }
|
|
110
|
-
const successes = listenerSet<{ data: unknown, input: unknown }>()
|
|
107
|
+
): ((...args: Args) => CallPromise<CallResult<unknown, unknown>>) & Reader<unknown, LoadStatus> & { settled: () => Promise<void> } {
|
|
111
108
|
const answers = listenerSet<{ value: unknown, input: unknown }>()
|
|
112
109
|
const failures = listenerSet<{ error: ApiError, input: unknown }>()
|
|
113
110
|
|
|
114
|
-
if (hooks?.onSuccess)
|
|
115
|
-
successes.on(hooks.onSuccess as never)
|
|
116
|
-
|
|
117
111
|
if (hooks?.onData)
|
|
118
112
|
answers.on(hooks.onData as never)
|
|
119
113
|
|
|
@@ -147,7 +141,6 @@ export function trackCalls<Args extends unknown[]>(
|
|
|
147
141
|
setAnswer(data)
|
|
148
142
|
tell = () => {
|
|
149
143
|
answers.emit({ value: data, input: args[0] })
|
|
150
|
-
successes.emit({ data, input: args[0] })
|
|
151
144
|
}
|
|
152
145
|
|
|
153
146
|
return data
|
|
@@ -181,7 +174,6 @@ export function trackCalls<Args extends unknown[]>(
|
|
|
181
174
|
error,
|
|
182
175
|
data: answer,
|
|
183
176
|
onData: answers.on,
|
|
184
|
-
onSuccess: successes.on,
|
|
185
177
|
onError: failures.on,
|
|
186
178
|
settled: async () => idle.wait(untrack(inFlight)),
|
|
187
179
|
retry: () => {
|
package/src/runtime/checks.ts
CHANGED
|
@@ -8,8 +8,8 @@ import type { Component, JSX } from './jsx'
|
|
|
8
8
|
declare const ISLAND: unique symbol
|
|
9
9
|
declare const BINDABLE: unique symbol
|
|
10
10
|
|
|
11
|
-
// When an island hydrates: right away, once the browser is idle, once it scrolls near the viewport, on the first interaction inside it, or once a media query matches (`media(max-width: 40rem)`)
|
|
12
|
-
export type HydrateWhen = 'load' | 'idle' | 'visible' | 'interaction' | `media(${string})`
|
|
11
|
+
// When an island hydrates: right away, once the browser is idle, once it scrolls near the viewport, on the first interaction inside it, or once a media query matches (`media(max-width: 40rem)`).
|
|
12
|
+
export type HydrateWhen = 'load' | 'idle' | 'visible' | 'interaction' | `media(${string})`
|
|
13
13
|
|
|
14
14
|
// What an `if` renders its block on, its condition's type without the falsy values, `false` and `0` included as `NonNullable` keeps them.
|
|
15
15
|
export type Truthy<T> = Exclude<T, false | 0 | 0n | '' | null | undefined>
|
|
@@ -43,6 +43,17 @@ export type BoundValue<Tag, Key> = Key extends keyof PropsOfComponent<Tag> ? Mar
|
|
|
43
43
|
// Lets the checker tell islands from plain components.
|
|
44
44
|
export interface IslandBrand { readonly [ISLAND]: true }
|
|
45
45
|
|
|
46
|
+
declare const ASKED: unique symbol
|
|
47
|
+
|
|
48
|
+
// What an island lists in `island({ interactive })`, kept in its type so a use that turns none of those props on is known to render as plain markup, which takes a function.
|
|
49
|
+
export interface IslandAsked<Interactive extends Readonly<Record<string, boolean>>> { readonly [ASKED]: Interactive }
|
|
50
|
+
|
|
51
|
+
// The props that make a use an island whatever the component lists.
|
|
52
|
+
type IslandOptionKeys = 'hydrate' | 'persist' | 'render' | 'fallback'
|
|
53
|
+
|
|
54
|
+
// Whether a use naming these props turns none of the component's interactive ones on: a prop it may leave out is on by default, and a spread, which names nothing, may carry any.
|
|
55
|
+
type StaysPlain<Component, Used> = Component extends IslandAsked<infer Interactive> ? true extends Interactive[keyof Interactive] ? false : [Used & (keyof Interactive | IslandOptionKeys)] extends [never] ? true : false : false
|
|
56
|
+
|
|
46
57
|
// What an interactive component's default export is; only islands take `hydrate`.
|
|
47
58
|
// What a static parent passes an island besides its props: when it hydrates, and whether it lives on across navigations, `persist` keeping it by its component, `persist="key"` by a key of its own.
|
|
48
59
|
// `fallback` is the markup a client-only use shows on the server until the browser renders the island, written as an `@fallback` block: it reaches the island under a key of kay's own, so a component's `fallback` prop of another kind is its own.
|
|
@@ -54,7 +65,7 @@ export interface IslandOptions {
|
|
|
54
65
|
fallback?: JSX.Element | undefined
|
|
55
66
|
}
|
|
56
67
|
|
|
57
|
-
// What a component's `
|
|
68
|
+
// What a component's `island()` call asks of its parents: `hydrate` and `persist` as an `IslandOptions` does, and `interactive`, the props that make a use of it an island, each with the value it has when a use leaves it out. A use whose props turn none of them on, and that hands the island no function, renders as plain markup that ships no JavaScript.
|
|
58
69
|
export interface IslandAsks {
|
|
59
70
|
hydrate?: HydrateWhen | undefined
|
|
60
71
|
persist?: boolean | string | undefined
|
|
@@ -328,7 +339,8 @@ export type PlainIslandProp<Component, Value> = Component extends IslandBrand ?
|
|
|
328
339
|
export type SlotCall = (...args: any[]) => JSX.Element
|
|
329
340
|
|
|
330
341
|
// A function written in the attribute is checked apart from its value, which a wrapping call would stop a generic component from typing: `0` stands for the attribute.
|
|
331
|
-
|
|
342
|
+
// `Names` is the props the use writes, as an object type: a use turning no interactive prop of an island on is plain markup, which takes a function.
|
|
343
|
+
export type FunctionProp<Component, Names extends object = Record<string, unknown>> = Component extends IslandBrand ? true extends StaysPlain<Component, keyof Names> ? 0 : { kayLint: 'island-prop', kayAlways: true, kayError: Unsendable } : 0
|
|
332
344
|
|
|
333
345
|
// What `defer()` returns, a plain promise: an `await` block takes any promise, so nothing marks one.
|
|
334
346
|
export type Deferred<T> = Promise<T>
|
|
@@ -346,24 +358,23 @@ export interface AwaitProps<T> {
|
|
|
346
358
|
|
|
347
359
|
type PropsOf<Tag> = Tag extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[Tag] : Tag extends Component<infer Props> ? Props : Record<string, unknown>
|
|
348
360
|
|
|
361
|
+
// The `parts` object a component takes, of its own parts.
|
|
362
|
+
type PartsOf<Component> = Component extends (props: infer Props) => unknown ? 'parts' extends keyof Props ? NonNullable<Props['parts' & keyof Props]> : never : never
|
|
363
|
+
|
|
349
364
|
// What a part that is a call of this component takes, as the component types it: a string or an array for its root, or its `parts` object of its own parts.
|
|
350
|
-
export type PartClass<Component> = Component extends (props: infer Props) => unknown ? ('class' extends keyof Props ? Extract<NonNullable<Props['class' & keyof Props]>, string | readonly unknown[]> : never) |
|
|
365
|
+
export type PartClass<Component> = Component extends (props: infer Props) => unknown ? ('class' extends keyof Props ? Extract<NonNullable<Props['class' & keyof Props]>, string | readonly unknown[]> : never) | PartsOf<Component> : never
|
|
351
366
|
|
|
352
|
-
// The type of the part `Name` of a component, which a call of it receives from the part of the same name this component hands on: its
|
|
353
|
-
export type HandedPart<Component, Name extends string> =
|
|
367
|
+
// The type of the part `Name` of a component, which a call of it receives from the part of the same name this component hands on: its `parts` entry for it.
|
|
368
|
+
export type HandedPart<Component, Name extends string> = PartsOf<Component> extends infer Parts ? Parts extends object ? Name extends keyof Parts ? Parts[Name] : never : never : never
|
|
354
369
|
|
|
355
370
|
// What `part="root spinner"` checks of the called component: it names a part `Name`, or the call is refused.
|
|
356
371
|
export type HandsPart<Component, Name extends string> = 0 extends 1 & Component ? unknown : [HandedPart<Component, Name>] extends [never] ? { kayError: `The called component has no part ${Name}` } : unknown
|
|
357
372
|
|
|
358
|
-
// An object of classes by part name, `{ head: 'p-6' }`, told from a `{ name: condition }` object by its string values.
|
|
359
|
-
type PartsObject<Item> = 0 extends 1 & Item ? never : Item extends readonly unknown[] ? never : Item extends object ? [Extract<Item[keyof Item], string>] extends [never] ? never : Item : never
|
|
360
|
-
|
|
361
373
|
// A string known to be non-empty: a literal other than the empty string.
|
|
362
374
|
type NonEmpty<Item> = Item extends string ? string extends Item ? never : '' extends Item ? never : Item : never
|
|
363
375
|
|
|
364
376
|
// What a component call spreads for its `class`, merged from its shorthand, `class` and spreads: a `class` that is always a string when a non-empty literal takes part, else one that may be unset, as an optional property so `class?: string` takes it under `exactOptionalPropertyTypes` and a required `class: string` refuses it.
|
|
365
|
-
|
|
366
|
-
export type ComponentClass<List extends readonly unknown[]> = [PartsObject<List[number]>] extends [never] ? [{ [Index in keyof List]: NonEmpty<List[Index]> }[number]] extends [never] ? { class?: string } : { class: string } : { class: { kayError: 'A parts object cannot be merged with a shorthand or a spread: give the parts as their own attribute, parts={{ root: "mt-4", head: "p-6" }}' } }
|
|
377
|
+
export type ComponentClass<List extends readonly unknown[]> = [{ [Index in keyof List]: NonEmpty<List[Index]> }[number]] extends [never] ? { class?: string } : { class: string }
|
|
367
378
|
|
|
368
379
|
// What the template's control flow and dynamic tags read as in the code the type checker reads: a `for` block is called on the spot with a row of its list, so TypeScript narrows it where the browser build hands accessors.
|
|
369
380
|
export interface TemplateHelpers {
|
|
@@ -376,7 +387,8 @@ export interface TemplateHelpers {
|
|
|
376
387
|
componentClass: <const List extends readonly unknown[]>(list: List) => ComponentClass<List>
|
|
377
388
|
partClass: (props: unknown, part: string) => unknown
|
|
378
389
|
partHanded: (part: string, list: readonly unknown[]) => unknown
|
|
379
|
-
|
|
390
|
+
partProps: (read: () => readonly [list: readonly unknown[], written?: unknown]) => unknown
|
|
391
|
+
handParts: (list: readonly unknown[], written?: unknown) => unknown
|
|
380
392
|
omit: <Props extends object, Key extends keyof Props>(props: Props, ...keys: Key[]) => Omit<Props, Key>
|
|
381
393
|
head: (tags: { tag: string, props: Record<string, unknown> }[]) => void
|
|
382
394
|
Try: (props: { block: JSX.Element, failed?: JSX.Element }) => JSX.Element
|
package/src/runtime/client.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { reviveActionsIn } from './action-revive'
|
|
|
3
3
|
import { withBase } from './base'
|
|
4
4
|
import { skew } from './build'
|
|
5
5
|
import { dispatch, hydrate, render } from './dom'
|
|
6
|
+
import { liveProps } from './live-props'
|
|
6
7
|
import { HYDRATED, ISLAND } from './markers'
|
|
7
8
|
import { flush, recordSignals, reportError, root, setErrorReporter } from './reactive'
|
|
8
9
|
import { savesDataInBrowser } from './save-data'
|
|
@@ -225,10 +226,10 @@ async function hydrateIsland(registry: IslandRegistry, element: HTMLElement): Pr
|
|
|
225
226
|
return
|
|
226
227
|
}
|
|
227
228
|
|
|
228
|
-
let loaded: [Awaited<ReturnType<IslandRegistry[string]>>, Awaited<ReturnType<typeof staticSlots>>,
|
|
229
|
+
let loaded: [Awaited<ReturnType<IslandRegistry[string]>>, Awaited<ReturnType<typeof staticSlots>>, void | undefined]
|
|
229
230
|
|
|
230
231
|
try {
|
|
231
|
-
loaded = await Promise.all([load(), staticSlots(registry, element),
|
|
232
|
+
loaded = await Promise.all([load(), staticSlots(registry, element), reviveActionsIn(element.dataset.props)])
|
|
232
233
|
|
|
233
234
|
// What the server drew of its lazy components loads first, so the markup is claimed as it stands.
|
|
234
235
|
const drawn = (globalThis as { $kayLoadDrawn?: (island: HTMLElement) => Promise<void> }).$kayLoadDrawn
|
|
@@ -246,7 +247,7 @@ async function hydrateIsland(registry: IslandRegistry, element: HTMLElement): Pr
|
|
|
246
247
|
throw error
|
|
247
248
|
}
|
|
248
249
|
|
|
249
|
-
const [{ default: component }, slots
|
|
250
|
+
const [{ default: component }, slots] = loaded
|
|
250
251
|
|
|
251
252
|
// A page swap took it away while its chunk loaded: hydrated now, its effects would outlive it. One in a static slot its island hid hydrates as it shows it again.
|
|
252
253
|
if (!element.isConnected) {
|
|
@@ -256,7 +257,7 @@ async function hydrateIsland(registry: IslandRegistry, element: HTMLElement): Pr
|
|
|
256
257
|
}
|
|
257
258
|
|
|
258
259
|
const given = element.dataset.props === undefined ? {} : decodeServerValue(element.dataset.props) as Record<string, unknown>
|
|
259
|
-
const [props, update] =
|
|
260
|
+
const [props, update] = liveProps(given)
|
|
260
261
|
|
|
261
262
|
for (const [key, slot] of Object.entries(slots))
|
|
262
263
|
Object.defineProperty(props, key, { value: slot, enumerable: true, configurable: true })
|
|
@@ -267,8 +268,8 @@ async function hydrateIsland(registry: IslandRegistry, element: HTMLElement): Pr
|
|
|
267
268
|
|
|
268
269
|
const draw = () => render(() => withIds(ids, () => component(props)), element)
|
|
269
270
|
|
|
270
|
-
// A client-only island has no server markup to claim, only the fallback it renders over.
|
|
271
|
-
if (element.dataset.client !== undefined) {
|
|
271
|
+
// A client-only island has no server markup to claim, only the fallback it renders over, and so has one the build drew at the default query when the page is opened at another.
|
|
272
|
+
if (element.dataset.client !== undefined || (element.dataset.query !== undefined && location.search !== '')) {
|
|
272
273
|
renderOver(element, id, draw, false)
|
|
273
274
|
}
|
|
274
275
|
else {
|
|
@@ -316,11 +317,6 @@ async function hydrateIsland(registry: IslandRegistry, element: HTMLElement): Pr
|
|
|
316
317
|
element.dispatchEvent(new Event(HYDRATED))
|
|
317
318
|
}
|
|
318
319
|
|
|
319
|
-
// Its own chunk, which only a page holding a persistent island loads: the one kind of island the next page gives other props to.
|
|
320
|
-
async function livePropsOf(element: HTMLElement): Promise<typeof import('./live-props').liveProps | undefined> {
|
|
321
|
-
return element.dataset.persist === undefined ? undefined : (await import('./live-props')).liveProps
|
|
322
|
-
}
|
|
323
|
-
|
|
324
320
|
// The static slots a static parent gave the island, whose code only a page holding such an island loads.
|
|
325
321
|
async function staticSlots(registry: IslandRegistry, element: HTMLElement): Promise<Record<string, () => Node[]>> {
|
|
326
322
|
return element.dataset.slots === undefined ? {} : (await import('./static-slots')).islandSlots(element, root => void hydrateIslands(registry, root))
|