@kayjs/kay 1.107.0 → 1.109.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 +1875 -3815
- 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-libraries.md +1 -1
- package/llms/component-library-conventions.md +1 -1
- package/llms/components.md +4 -4
- package/llms/deprecated-lints.md +1 -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 +2 -1
- package/llms/island-sources.md +1 -1
- package/llms/islands-state-to-ids.md +2 -2
- package/llms/islands.md +5 -3
- package/llms/lints.md +1 -1
- package/llms/live-values.md +3 -3
- 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 +6 -6
- 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/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 +42 -82
- package/llms/upgrading.md +92 -58
- package/llms/whats-new-archive.md +36 -1
- package/llms/whats-new.md +18 -39
- package/llms.txt +6 -7
- package/package.json +6 -10
- package/src/build/client.ts +7 -6
- package/src/build/icon-slots.ts +140 -0
- package/src/build/libraries.ts +24 -2
- package/src/build/plugin.ts +10 -0
- package/src/build/route-sizes.ts +2 -3
- package/src/build/runtime-chunk.ts +2 -2
- package/src/build/source-files.ts +8 -3
- package/src/build/variants.ts +90 -1
- 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/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 +4 -9
- package/src/check/renamed-packages.ts +3 -63
- package/src/check/shadow-types.ts +4 -104
- package/src/commands/check.ts +2 -2
- package/src/commands/env.ts +25 -3
- package/src/compiler/ast.ts +18 -16
- package/src/compiler/browser.ts +2 -14
- package/src/compiler/class-items.ts +16 -0
- package/src/compiler/codegen.ts +8 -8
- package/src/compiler/dead-code.ts +22 -0
- package/src/compiler/deprecated-library.ts +0 -12
- package/src/compiler/deprecated-lints.ts +4 -505
- package/src/compiler/deprecated-ui-props.ts +5 -5
- package/src/compiler/dom-property.ts +23 -0
- package/src/compiler/dom.ts +15 -15
- package/src/compiler/errors.ts +2 -2
- package/src/compiler/fence-checks.ts +2 -121
- package/src/compiler/hand-parts.ts +55 -0
- package/src/compiler/helper-imports.ts +2 -2
- package/src/compiler/image-attributes.ts +1 -3
- package/src/compiler/index.ts +20 -21
- package/src/compiler/island-arguments.ts +8 -95
- package/src/compiler/island-cause.ts +7 -7
- package/src/compiler/island-declaration.ts +2 -8
- package/src/compiler/island-lints.ts +12 -0
- package/src/compiler/island-marker.ts +3 -3
- package/src/compiler/island-problems.ts +25 -0
- package/src/compiler/jsx-class.ts +1 -25
- package/src/compiler/jsx.ts +2 -2
- package/src/compiler/kay-exports.ts +0 -2
- package/src/compiler/link-flags.ts +9 -38
- package/src/compiler/lints.ts +7 -14
- package/src/compiler/markup.ts +23 -26
- 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/rewrite.ts +3 -18
- package/src/compiler/script-server.ts +8 -3
- 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/package-names.ts +1 -1
- package/src/runtime/action-call.ts +39 -335
- 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 +332 -0
- 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 +11 -11
- package/src/runtime/client.ts +2 -2
- 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/index.ts +2 -2
- package/src/runtime/island.server.ts +18 -5
- 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/navigation-state.ts +0 -12
- package/src/runtime/page-swap.ts +6 -6
- 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/values.ts +40 -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 +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/client.d.ts +1 -1
- package/types/build/client.d.ts.map +1 -1
- package/types/build/icon-slots.d.ts +7 -0
- package/types/build/icon-slots.d.ts.map +1 -0
- package/types/build/libraries.d.ts +2 -0
- package/types/build/libraries.d.ts.map +1 -1
- package/types/build/plugin.d.ts +1 -0
- package/types/build/plugin.d.ts.map +1 -1
- package/types/build/route-sizes.d.ts.map +1 -1
- package/types/build/source-files.d.ts.map +1 -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/renamed-packages.d.ts +0 -3
- package/types/check/renamed-packages.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/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/dead-code.d.ts +9 -0
- package/types/compiler/dead-code.d.ts.map +1 -0
- package/types/compiler/deprecated-library.d.ts.map +1 -1
- package/types/compiler/deprecated-lints.d.ts +0 -560
- 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/dom-property.d.ts +9 -0
- package/types/compiler/dom-property.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/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 +7 -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 +2 -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 +10 -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/jsx-class.d.ts +1 -2
- package/types/compiler/jsx-class.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 +11 -572
- 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/script-server.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 +23 -0
- package/types/runtime/action-run.d.ts.map +1 -0
- 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 +6 -9
- package/types/runtime/checks.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/index.d.ts +2 -2
- package/types/runtime/index.d.ts.map +1 -1
- package/types/runtime/island.server.d.ts +1 -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/navigation-state.d.ts +0 -4
- package/types/runtime/navigation-state.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/values.d.ts +2 -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/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
|
@@ -5,7 +5,7 @@ export type IslandCauseKind = 'client' | 'island' | 'attribute' | 'value' | 'liv
|
|
|
5
5
|
|
|
6
6
|
export interface IslandCause {
|
|
7
7
|
kind: IslandCauseKind
|
|
8
|
-
// The attribute (`onClick`, `bind:value`, `ref`), the `kay` value (`signal`) or the live value;
|
|
8
|
+
// The attribute (`onClick`, `bind:value`, `ref`), the `kay` value (`signal`) or the live value; `island()` for the declaration.
|
|
9
9
|
name: string
|
|
10
10
|
// Where it is in the file, which the editor reveals.
|
|
11
11
|
span: Span
|
|
@@ -13,7 +13,7 @@ export interface IslandCause {
|
|
|
13
13
|
line: number
|
|
14
14
|
// The `kay` value's module, as `kay`.
|
|
15
15
|
source?: string | undefined
|
|
16
|
-
// The props the component's `island`
|
|
16
|
+
// The props the component's `island()` call says make a use interactive, each with whether it is on when left out: a use turning none on renders no island.
|
|
17
17
|
interactive?: Readonly<Record<string, boolean>> | undefined
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -32,9 +32,9 @@ function staticUse(interactive: Readonly<Record<string, boolean>>): string {
|
|
|
32
32
|
function causeText(cause: IslandCause): string {
|
|
33
33
|
switch (cause.kind) {
|
|
34
34
|
case 'client':
|
|
35
|
-
return
|
|
35
|
+
return 'an `island({ render: \'client\' })` declaration'
|
|
36
36
|
case 'island':
|
|
37
|
-
return
|
|
37
|
+
return 'an `island()` declaration'
|
|
38
38
|
case 'attribute':
|
|
39
39
|
return `\`${cause.name}\`, line ${cause.line}`
|
|
40
40
|
case 'value':
|
|
@@ -48,8 +48,8 @@ function causeText(cause: IslandCause): string {
|
|
|
48
48
|
|
|
49
49
|
// What the cause is, in a few words.
|
|
50
50
|
export const CAUSE_KINDS: Record<IslandCauseKind, string> = {
|
|
51
|
-
client: 'an `island({ render: \'client\' })` declaration
|
|
52
|
-
island: 'an `island()` declaration
|
|
51
|
+
client: 'an `island({ render: \'client\' })` declaration: the component renders in the browser only',
|
|
52
|
+
island: 'an `island()` declaration: the author declared the component an island',
|
|
53
53
|
attribute: 'an `on*`, `bind:` or `ref` attribute: the browser handles it',
|
|
54
54
|
value: 'a `kay` value of the browser, such as `signal` or `effect`, that its script uses',
|
|
55
55
|
live: 'a live value its script imports: the browser follows it',
|
|
@@ -57,4 +57,4 @@ export const CAUSE_KINDS: Record<IslandCauseKind, string> = {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
// The rule, as `kay explain island` says it.
|
|
60
|
-
export const ISLAND_RULE = 'A component is an island when it needs the browser: an `on*`, `bind:` or `ref` in its template, a browser value of `kay` in its script, a live or persisted value it imports, or an `island()` declaration
|
|
60
|
+
export const ISLAND_RULE = 'A component is an island when it needs the browser: an `on*`, `bind:` or `ref` in its template, a browser value of `kay` in its script, a live or persisted value it imports, or an `island()` declaration; what an island renders is part of it. A static component that passes an island a function or a block taking parameters is an `island-prop` error, and is made an island by `island()`. A component whose `island({ interactive })` lists `interactive` props is an island only in a use that turns one on: any other use renders as markup with no script.'
|
|
@@ -164,16 +164,10 @@ export function declaredIsland(source: string, script: Span): IslandDeclaration
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
// The role the
|
|
168
|
-
export function rolesOf(source: string, script: Span | undefined
|
|
167
|
+
// The role the `island()` call gives the component, which `client` and `pin` of the parsed file carry.
|
|
168
|
+
export function rolesOf(source: string, script: Span | undefined): { island: IslandDeclaration | undefined, client: Span | undefined, pin: (Span & { kind: 'island' | 'static' }) | undefined } {
|
|
169
169
|
const island = script === undefined ? undefined : declaredIsland(source, script)
|
|
170
170
|
|
|
171
|
-
if (fence?.word === 'client')
|
|
172
|
-
return { island, client: fence, pin: undefined }
|
|
173
|
-
|
|
174
|
-
if (fence?.word === 'island' || fence?.word === 'static')
|
|
175
|
-
return { island, client: undefined, pin: { kind: fence.word, start: fence.start, end: fence.end } }
|
|
176
|
-
|
|
177
171
|
if (island === undefined)
|
|
178
172
|
return { island, client: undefined, pin: undefined }
|
|
179
173
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Lint } from './lints'
|
|
2
|
+
|
|
3
|
+
// The lints of the `islands` group that sit apart from the rest, with the other lints in `LINTS`.
|
|
4
|
+
export const ISLAND_LINTS = {
|
|
5
|
+
'page-island': {
|
|
6
|
+
level: 'deny',
|
|
7
|
+
group: 'islands',
|
|
8
|
+
summary: 'A page without a `--- server` fence that needs the browser: an `on*`, `bind:` or `ref` in it, a browser value of `kay` such as `signal`, or a live or persisted import. A page renders once on the server and is never an island, so what needs the browser belongs in a component the page renders. Found in the pages of the project, at the thing that makes the page an island; a layout or a page with a `--- server` fence is not reported. It has no fix: moving the code into a component is not an edit that is safe to apply.',
|
|
9
|
+
wrong: '---\nimport { signal } from \'kay\'\n\nconst count = signal(0)\n---\nbutton(onClick={() => count.set(count() + 1)}) {count()}',
|
|
10
|
+
right: '---\nimport Counter from \'../components/counter.kay\'\n---\nCounter',
|
|
11
|
+
},
|
|
12
|
+
} as const satisfies Record<string, Lint>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Diagnostic, Fix, KayFile } from './ast'
|
|
2
|
-
import { eolOf
|
|
2
|
+
import { eolOf } from './island-problems'
|
|
3
3
|
|
|
4
4
|
const STATIC_RENDER = /render\s*:\s*(['"])static\1\s*,?\s*/
|
|
5
5
|
const EMPTY_SETTINGS = /\(\s*\{\s*\}\s*\)/
|
|
@@ -11,8 +11,8 @@ export function islandFence(file: KayFile): Fix | undefined {
|
|
|
11
11
|
if (file.server !== undefined || file.client !== undefined || file.pin?.kind === 'island')
|
|
12
12
|
return undefined
|
|
13
13
|
|
|
14
|
-
if (file.pin !== undefined)
|
|
15
|
-
return { title, edits:
|
|
14
|
+
if (file.pin !== undefined && file.island !== undefined)
|
|
15
|
+
return { title, edits: [{ start: file.island.span.start, end: file.island.span.end, text: file.source.slice(file.island.span.start, file.island.span.end).replace(STATIC_RENDER, '').replace(EMPTY_SETTINGS, '()') }] }
|
|
16
16
|
|
|
17
17
|
if (file.scriptLine === undefined || file.script === undefined)
|
|
18
18
|
return { title, edits: [{ start: 0, end: 0, text: ['---', 'island()', '---', ''].join(eolOf(file.source)) }] }
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Diagnostic, KayFile } from './ast'
|
|
2
|
+
import { declaredIsland } from './island-declaration'
|
|
3
|
+
|
|
4
|
+
const MEDIA_HYDRATE = /^media\(\s*\S.*\)$/s
|
|
5
|
+
|
|
6
|
+
// What is wrong with a static `hydrate` value on a use: `client` is `render="client"` since 1.105, and `media(...)` needs a query.
|
|
7
|
+
export function hydrateProblem(text: string): [message: string, details: { help: string }] | undefined {
|
|
8
|
+
if (text === 'client')
|
|
9
|
+
return ['`hydrate="client"` is `render="client"`', { help: 'write `render="client"` to render the component in the browser only' }]
|
|
10
|
+
|
|
11
|
+
if (text.startsWith('media(') && !MEDIA_HYDRATE.test(text))
|
|
12
|
+
return ['`hydrate="media(...)"` needs a media query', { help: 'write the query in the brackets: `hydrate="media(max-width: 40rem)"`' }]
|
|
13
|
+
|
|
14
|
+
return undefined
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// The line ending a file writes, which what a fix inserts follows.
|
|
18
|
+
export const eolOf = (source: string): string => source.includes('\r\n') ? '\r\n' : '\n'
|
|
19
|
+
|
|
20
|
+
// An `island()` call in a `--- module` fence, which declares nothing there: the call belongs to the component's script.
|
|
21
|
+
export function islandProblems(file: KayFile): Diagnostic[] {
|
|
22
|
+
const declared = file.module === undefined ? undefined : declaredIsland(file.source, file.module)
|
|
23
|
+
|
|
24
|
+
return declared === undefined ? [] : [{ ...declared.span, code: 'fence-invalid', message: '`island()` goes in the component\'s script, not its `--- module` fence', help: 'move it to the top of the script fence' }]
|
|
25
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ElementNode, NamedAttribute } from './ast'
|
|
2
2
|
import type { CodeBuilder } from './mapping'
|
|
3
3
|
import type { ClassMerge } from './plan'
|
|
4
4
|
import { helperName } from './markup'
|
|
5
|
-
import { oldPartsClass } from './old-parts'
|
|
6
5
|
import { shorthandClass } from './plan'
|
|
7
6
|
|
|
8
7
|
// What wraps a merged class list: an array on an element, the class of `componentClass` on a component, or its spread when the merge can be empty.
|
|
@@ -83,26 +82,3 @@ export function addMergedClass(b: CodeBuilder, element: ElementNode, { attribute
|
|
|
83
82
|
|
|
84
83
|
b.add(close)
|
|
85
84
|
}
|
|
86
|
-
|
|
87
|
-
// The `class` of a component call that is its `parts` before 1.105, written as the `parts` prop, left out when a `parts` is written beside it, which the type check reads alone. Whether the attribute is that `class`.
|
|
88
|
-
export function addOldParts(b: CodeBuilder, element: ElementNode, src: string, attribute: Attribute): boolean {
|
|
89
|
-
const old = oldPartsClass(element, src)
|
|
90
|
-
|
|
91
|
-
if (old === undefined)
|
|
92
|
-
return false
|
|
93
|
-
|
|
94
|
-
const hand = element.attributes.find((one): one is Extract<NamedAttribute, { kind: 'expression' }> => one.kind === 'expression' && src.slice(one.name.start, one.name.end) === 'parts')
|
|
95
|
-
|
|
96
|
-
if (attribute === old) {
|
|
97
|
-
b.add(' ').wrap(old.name, () => b.add('parts')).add('={')
|
|
98
|
-
|
|
99
|
-
if (hand === undefined)
|
|
100
|
-
b.addSource(old.expression)
|
|
101
|
-
else
|
|
102
|
-
b.add('{ ...(').addSource(hand.expression).add('), ...(').addSource(old.expression).add(') }')
|
|
103
|
-
|
|
104
|
-
b.add('}')
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return attribute === old || attribute === hand
|
|
108
|
-
}
|
package/src/compiler/jsx.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { Sites } from './rewrite-types'
|
|
|
5
5
|
import { bindsOwnProp, failedBlockOf, handedParts, isSlot, partAttribute, serverIslandOf } from './ast'
|
|
6
6
|
import { isFunctionAt, sentParts } from './expression'
|
|
7
7
|
import { addConstValue, addKeyParameters, addRowItem, contentOf, rowKeying, slotValue } from './items'
|
|
8
|
-
import { addMergedClass,
|
|
8
|
+
import { addMergedClass, addShorthandClass, quoteAttribute } from './jsx-class'
|
|
9
9
|
import { addFieldName, addInheritedName, addWrittenField } from './jsx-field'
|
|
10
10
|
import { DYNAMIC_TAG } from './mapping'
|
|
11
11
|
import { addBindWrite, bindRead, helperName, RAW_ELEMENTS } from './markup'
|
|
@@ -679,7 +679,7 @@ export class JsxTemplate {
|
|
|
679
679
|
const part = partAttribute(element, this.src)
|
|
680
680
|
|
|
681
681
|
for (const attribute of element.attributes) {
|
|
682
|
-
if (
|
|
682
|
+
if ((merge.shorthand || merge.last) && attribute === merge.attribute)
|
|
683
683
|
continue
|
|
684
684
|
|
|
685
685
|
// Not a prop of the element or the component: it names a part, whose class the component's own `class` type takes.
|
|
@@ -51,10 +51,8 @@ export const KAY_ROLES: Readonly<Record<string, KayRole>> = {
|
|
|
51
51
|
mount: 'browser',
|
|
52
52
|
navigate: 'browser',
|
|
53
53
|
navigation: 'browser',
|
|
54
|
-
onBeforeNavigate: 'browser',
|
|
55
54
|
onCleanup: 'browser',
|
|
56
55
|
onMount: 'browser',
|
|
57
|
-
onNavigate: 'browser',
|
|
58
56
|
online: 'browser',
|
|
59
57
|
optimistic: 'browser',
|
|
60
58
|
pageVisible: 'browser',
|
|
@@ -3,13 +3,6 @@ import type { Lint } from './lints'
|
|
|
3
3
|
import { editDistance } from './aria'
|
|
4
4
|
import { elementsIn } from './ast'
|
|
5
5
|
|
|
6
|
-
export interface Renamed {
|
|
7
|
-
name: string
|
|
8
|
-
value: string
|
|
9
|
-
// What a `false` value of the old name becomes, for a flag that was off by that word.
|
|
10
|
-
off?: string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
6
|
// The lint of this file, with the other lints in `LINTS`.
|
|
14
7
|
export const LINK_LINTS = {
|
|
15
8
|
'unknown-link-flag': {
|
|
@@ -24,13 +17,8 @@ export const LINK_LINTS = {
|
|
|
24
17
|
// The attributes a link, or an element around links, takes to say how the swap follows it, named as the options of `navigate()` are: `scroll`, `transition`, `prefetch`, and `reload` for a full load.
|
|
25
18
|
const FLAGS = new Set(['data-scroll', 'data-transition', 'data-prefetch', 'data-reload'])
|
|
26
19
|
|
|
27
|
-
// The names before 1.105
|
|
28
|
-
|
|
29
|
-
'data-keep-scroll': { name: 'data-scroll', value: 'keep', off: 'top' },
|
|
30
|
-
'data-no-transition': { name: 'data-transition', value: 'false' },
|
|
31
|
-
'data-no-prefetch': { name: 'data-prefetch', value: 'false' },
|
|
32
|
-
}
|
|
33
|
-
const NEARBY = [...FLAGS, ...Object.keys(OLD_LINK_FLAGS)]
|
|
20
|
+
// The names before 1.105, which nothing reads any more: a link using one would follow as a plain link, a sign-out link prefetched included.
|
|
21
|
+
const REMOVED: Record<string, string> = { 'data-keep-scroll': 'data-scroll="keep"', 'data-no-transition': 'data-transition="false"', 'data-no-prefetch': 'data-prefetch="false"' }
|
|
34
22
|
|
|
35
23
|
// The name an attribute is written with, none for a spread or a `{name}` shorthand.
|
|
36
24
|
function nameOf(attribute: Attribute): Span | undefined {
|
|
@@ -41,7 +29,7 @@ function nameOf(attribute: Attribute): Span | undefined {
|
|
|
41
29
|
function nearest(name: string): string | undefined {
|
|
42
30
|
const word = name.slice(5)
|
|
43
31
|
|
|
44
|
-
return
|
|
32
|
+
return [...FLAGS].find((flag) => {
|
|
45
33
|
const meant = flag.slice(5)
|
|
46
34
|
|
|
47
35
|
return !word.startsWith(meant) && (editDistance(word, meant) <= 1 || swapped(word, meant))
|
|
@@ -55,7 +43,7 @@ function swapped(a: string, b: string): boolean {
|
|
|
55
43
|
return a.length === b.length && at >= 0 && a[at] === b[at + 1] && a[at + 1] === b[at] && a.slice(at + 2) === b.slice(at + 2)
|
|
56
44
|
}
|
|
57
45
|
|
|
58
|
-
// The navigation flags of links, on an element or on a component call that forwards them to its link:
|
|
46
|
+
// The navigation flags of links, on an element or on a component call that forwards them to its link: a `data-` name that is only a misspelling of one of the family is `unknown-link-flag`, as it would do nothing and no type knows a `data-` attribute.
|
|
59
47
|
export function linkFlags(file: KayFile): Diagnostic[] {
|
|
60
48
|
const found: Diagnostic[] = []
|
|
61
49
|
|
|
@@ -67,10 +55,10 @@ export function linkFlags(file: KayFile): Diagnostic[] {
|
|
|
67
55
|
continue
|
|
68
56
|
|
|
69
57
|
const name = file.source.slice(at.start, at.end)
|
|
70
|
-
const
|
|
58
|
+
const removed = REMOVED[name]
|
|
71
59
|
|
|
72
|
-
if (
|
|
73
|
-
found.push(
|
|
60
|
+
if (removed !== undefined) {
|
|
61
|
+
found.push({ ...at, code: 'unknown-link-flag', message: `\`${name}\` is no navigation flag of a link any more`, note: 'nothing reads it since 1.109, so the link follows as a plain one', help: `write \`${removed}\``, checkOnly: true })
|
|
74
62
|
|
|
75
63
|
continue
|
|
76
64
|
}
|
|
@@ -80,28 +68,11 @@ export function linkFlags(file: KayFile): Diagnostic[] {
|
|
|
80
68
|
if (meant === undefined)
|
|
81
69
|
continue
|
|
82
70
|
|
|
83
|
-
const
|
|
84
|
-
const to = renamed === undefined ? meant : `${renamed.name}="${renamed.value}"`
|
|
85
|
-
// An old name written with a value keeps that value after the name, so writing `name="value"` there would leave two: that case gets the help alone.
|
|
86
|
-
const fixes = renamed !== undefined && attribute.kind !== 'boolean' ? [] : [{ title: `Write \`${to}\``, safe: false, edits: [{ ...at, text: to }] }]
|
|
71
|
+
const fixes = [{ title: `Write \`${meant}\``, safe: false, edits: [{ ...at, text: meant }] }]
|
|
87
72
|
|
|
88
|
-
found.push({ ...at, code: 'unknown-link-flag', message: `\`${name}\` is no navigation flag of a link`, note: 'a link is followed with `data-scroll`, `data-transition`, `data-prefetch` and `data-reload`, and this name does nothing', help: `did you mean \`${
|
|
73
|
+
found.push({ ...at, code: 'unknown-link-flag', message: `\`${name}\` is no navigation flag of a link`, note: 'a link is followed with `data-scroll`, `data-transition`, `data-prefetch` and `data-reload`, and this name does nothing', help: `did you mean \`${meant}\`?`, fixes, checkOnly: true })
|
|
89
74
|
}
|
|
90
75
|
}
|
|
91
76
|
|
|
92
77
|
return found
|
|
93
78
|
}
|
|
94
|
-
|
|
95
|
-
function oldFlag(source: string, attribute: Attribute, at: Span, name: string, old: Renamed): Diagnostic {
|
|
96
|
-
const base = { ...at, code: 'deprecated-link-flags', checkOnly: true, message: `\`${name}\` is \`${old.name}="${old.value}"\`, deprecated since 1.105`, help: `write \`${old.name}="${old.value}"\`, named as the option of \`navigate()\`` }
|
|
97
|
-
|
|
98
|
-
if (attribute.kind === 'expression') {
|
|
99
|
-
// The keep flag's value is read as before, but the new name types its words, so the rename is not safe; the other two were set by being present, which no value of the new name says.
|
|
100
|
-
return old.off === undefined ? base : { ...base, fixes: [{ title: `Write \`${old.name}\``, safe: false, edits: [{ ...at, text: old.name }] }] }
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const written = old.off !== undefined && attribute.kind === 'static' && attribute.text === 'false' ? old.off : old.value
|
|
104
|
-
const end = attribute.kind === 'static' ? attribute.value.end + ('"\''.includes(source[attribute.value.end] ?? '') ? 1 : 0) : at.end
|
|
105
|
-
|
|
106
|
-
return { ...base, fixes: [{ title: `Write \`${old.name}="${written}"\``, safe: true, edits: [{ start: at.start, end, text: `${old.name}="${written}"` }] }] }
|
|
107
|
-
}
|
package/src/compiler/lints.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { AllowRules } from './allow-comments'
|
|
2
2
|
import type { Diagnostic, ElementNode, ForNode, KayFile, TextChunk } from './ast'
|
|
3
|
-
import type { RetiredLint } from './deprecated-allow'
|
|
4
3
|
import type { Scope } from './template-scopes'
|
|
5
4
|
import { accessibilityLints, MARKUP_LINTS } from './a11y'
|
|
6
5
|
import { allowComments, honoured, refusedComments } from './allow-comments'
|
|
7
6
|
import { keyedByPosition, walkNodes } from './ast'
|
|
8
|
-
import { RETIRED_LINTS } from './deprecated-allow'
|
|
9
7
|
import { DEPRECATED_LINTS } from './deprecated-lints'
|
|
10
8
|
import { I18N_LINTS } from './i18n-lints'
|
|
9
|
+
import { ISLAND_LINTS } from './island-lints'
|
|
11
10
|
import { positionAt } from './mapping'
|
|
12
11
|
import { VOID_ELEMENTS } from './markup'
|
|
13
12
|
import { nestingLints } from './nesting'
|
|
@@ -312,13 +311,6 @@ export const LINTS = {
|
|
|
312
311
|
wrong: '--- server\nimport { ask } from \'@kayjs/ai\'\nimport { action, s } from \'kay\'\n\nexport const reply = action(s.object({ messages: s.list(s.string()) }), async ({ messages }) => ask(messages))\n---\np x',
|
|
313
312
|
right: '--- server\nimport { ask } from \'@kayjs/ai\'\nimport { action, s } from \'kay\'\n\nexport const reply = action(s.object({ messages: s.list(s.string()) }), ({ messages }) => ask(messages))\n---\np x',
|
|
314
313
|
},
|
|
315
|
-
'unreturned-fail': {
|
|
316
|
-
level: 'deny',
|
|
317
|
-
group: 'code',
|
|
318
|
-
summary: 'A `ctx.fail(...)` statement in an action\'s handler (or `fail(...)` destructured from the context) that is not returned: `fail` returns the failure the action answers with, where `deny`, `notFound` and `redirect` throw, so the statement does nothing and the handler carries on. An arrow function with an expression body already returns, and a nested function is left alone. The fix prepends `return`. Found in `.kay` fences and `.ts` modules alike.',
|
|
319
|
-
wrong: '--- server\nexport const rename = action(s.object({ name: s.string() }), ({ name }, ctx) => {\n if (name === \'admin\')\n ctx.fail(409, \'That name is taken\')\n\n return name\n})\n---\np x',
|
|
320
|
-
right: '--- server\nexport const rename = action(s.object({ name: s.string() }), ({ name }, ctx) => {\n if (name === \'admin\')\n return ctx.fail(409, \'That name is taken\')\n\n return name\n})\n---\np x',
|
|
321
|
-
},
|
|
322
314
|
'missing-captcha': {
|
|
323
315
|
level: 'warn',
|
|
324
316
|
group: 'forms',
|
|
@@ -372,7 +364,7 @@ export const LINTS = {
|
|
|
372
364
|
'once-read-prop': {
|
|
373
365
|
level: 'deny',
|
|
374
366
|
group: 'code',
|
|
375
|
-
summary: 'A destructured prop read into a top-level `let`, a destructured `const`, one that awaits or a declaration nested in a block, that a function or the template reads later, in a component that runs in the browser: the declaration runs once, when the component is created, so the value keeps the prop\'s first value after the parent changes it. A top-level `const` naming one value (`const last = items.length - 1`) is computed by a memo and follows the prop, so it is no case. A prop read as the test of an `if` or a ternary, as an argument of a call or `new`, as a write target or in a class, one inside `signal(...)`, `persisted(...)` or `posted...(...)`, `id ?? uid()`, a callback prop (`onChange`) and a prop named `initial*` or `default*` are choices made once and left alone; for another, compute the value where it is used or in a `memo`, or allow it with `// kay-allow once-read-prop: why the first value is meant`.',
|
|
367
|
+
summary: 'A destructured prop read into a top-level `let`, a destructured `const`, one that awaits or a declaration nested in a block, that a function or the template reads later, in a component that runs in the browser: the declaration runs once, when the component is created, so the value keeps the prop\'s first value after the parent changes it. A top-level `const` naming one value (`const last = items.length - 1`) is computed by a memo and follows the prop, so it is no case. A prop read as the test of an `if` or a ternary, as an argument of a call or `new`, as a write target or in a class, one inside `signal(...)`, `persisted.cookie(...)` or `posted...(...)`, `id ?? uid()`, a callback prop (`onChange`) and a prop named `initial*` or `default*` are choices made once and left alone; for another, compute the value where it is used or in a `memo`, or allow it with `// kay-allow once-read-prop: why the first value is meant`.',
|
|
376
368
|
wrong: '---\nimport { signal } from \'kay\'\n\nconst { items } = props<{ items: string[] }>()\nlet last = items.length - 1\nconst open = signal(false)\n---\nbutton(onClick={() => open = !open()}) {last}',
|
|
377
369
|
right: '---\nimport { memo, signal } from \'kay\'\n\nconst { items } = props<{ items: string[] }>()\nconst last = memo(() => items.length - 1)\nconst open = signal(false)\n---\nbutton(onClick={() => open = !open()}) {last()}',
|
|
378
370
|
},
|
|
@@ -432,10 +424,11 @@ export const LINTS = {
|
|
|
432
424
|
'island-marker': {
|
|
433
425
|
level: 'deny',
|
|
434
426
|
group: 'islands',
|
|
435
|
-
summary: 'An `island()` declaration
|
|
427
|
+
summary: 'An `island()` declaration on a page, a layout or a special page: they render on the server and are never islands. Move what needs the browser to a component of its own.',
|
|
436
428
|
wrong: '--- server\nconst title = \'Home\'\n--- script\nisland()\n---\nh1 {title}',
|
|
437
429
|
right: '--- server\nconst title = \'Home\'\n---\nh1 {title}',
|
|
438
430
|
},
|
|
431
|
+
...ISLAND_LINTS,
|
|
439
432
|
'island-prop': {
|
|
440
433
|
level: 'deny',
|
|
441
434
|
group: 'islands',
|
|
@@ -618,7 +611,7 @@ export const LINTS = {
|
|
|
618
611
|
group: 'seo',
|
|
619
612
|
site: true,
|
|
620
613
|
summary: 'A prerendered page that no other page links to and the sitemap does not list, which a crawler cannot find. Reported by `kay build` on a site with `site` set when every page of the app is prerendered, as a page of the app rendered per request may link to anything (the pages a library mounts link within the library and do not count); the home page, a locale\'s root, `noindex` pages and pages behind a guard are left out.',
|
|
621
|
-
wrong: '--- server\nexport const page = { prerender: true, sitemap: false }\n---\nh1 Spring sale',
|
|
614
|
+
wrong: '--- server\nexport const page = { prerender: true, seo: { sitemap: false } }\n---\nh1 Spring sale',
|
|
622
615
|
right: '--- server\nexport const page = { prerender: true }\n---\nh1 Spring sale',
|
|
623
616
|
},
|
|
624
617
|
'broken-canonical': {
|
|
@@ -694,7 +687,7 @@ export type LintName = keyof typeof LINTS
|
|
|
694
687
|
|
|
695
688
|
// `satisfied` is set by kay from the extensions' `satisfies`, never written in `kay.config.ts`: the lints an extension answers for a place it fills in by itself.
|
|
696
689
|
// `comments` is no lint's level: it sets what a `// kay-allow` comment must hold to count.
|
|
697
|
-
export type LintLevels = Partial<Record<LintName | LintGroup
|
|
690
|
+
export type LintLevels = Partial<Record<LintName | LintGroup, LintLevel>> & { satisfied?: LintName[] | undefined, comments?: AllowRules | undefined }
|
|
698
691
|
|
|
699
692
|
export const LEVELS: ReadonlySet<string> = new Set<LintLevel>(['allow', 'warn', 'deny'])
|
|
700
693
|
|
|
@@ -783,7 +776,7 @@ export function applyLints(diagnostics: Diagnostic[], source: string, levels: Li
|
|
|
783
776
|
}
|
|
784
777
|
|
|
785
778
|
function unknownLints(source: string): Diagnostic[] {
|
|
786
|
-
return allowComments(source).flatMap(comment => comment.names.filter(({ name }) => !isLint(name)
|
|
779
|
+
return allowComments(source).flatMap(comment => comment.names.filter(({ name }) => !isLint(name)).map(({ name, start }): Diagnostic => ({ start, end: start + name.length, code: 'unknown-lint', message: `Unknown lint \`${name}\``, help: `the lints are ${Object.keys(LINTS).map(lint => `\`${lint}\``).join(', ')}`, checkOnly: true })))
|
|
787
780
|
}
|
|
788
781
|
|
|
789
782
|
// The template's own lints: what it can say from the markup alone.
|
package/src/compiler/markup.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ClassTable } from '../runtime/class-table'
|
|
2
2
|
import type { Attribute, ElementNode, ErrorMessages, FormField, NamedAttribute, Node, SlotNode, SnippetNode, Span, TemplateFacts, TextNode } from './ast'
|
|
3
|
+
import type { ClassItem } from './class-items'
|
|
3
4
|
import type { FormInfo } from './form-info'
|
|
4
5
|
import type { ImageOptionAttributes } from './image-attributes'
|
|
5
6
|
import type { CodeBuilder } from './mapping'
|
|
@@ -9,13 +10,14 @@ import { PART_END, PART_START } from '../runtime/markers'
|
|
|
9
10
|
import { URL_ATTRIBUTES } from '../runtime/url-attributes'
|
|
10
11
|
import { actionOf, bindsOwnProp, componentAction, describedByOf, FIELD_ATTRIBUTE, formFieldOf, handedParts, modifiersOf, partAttribute, partNames, partsOf, sectionOf, uiHasVariants, uiPartClasses } from './ast'
|
|
11
12
|
import { addBoundWrites, calledByBinds, changeOf } from './bound-props'
|
|
13
|
+
import { joinTexts } from './class-items'
|
|
12
14
|
import { addHandler } from './event-modifiers'
|
|
13
15
|
import { decodeEntities, isFunctionAt } from './expression'
|
|
14
|
-
import {
|
|
16
|
+
import { closeHandParts, handsEntry, openClassList, writtenParts } from './hand-parts'
|
|
17
|
+
import { IMAGE_OPTIONS, imageDefaults as imageDefaultsOf, imageOptions, placeholderOff, writeImageArguments } from './image-attributes'
|
|
15
18
|
import { contentOf } from './items'
|
|
16
19
|
import { controlId, fieldAttribute, inheritedAttributes, inheritedField } from './markup-fields'
|
|
17
20
|
import { PROPS } from './names'
|
|
18
|
-
import { oldPartsEntry } from './old-parts'
|
|
19
21
|
import { addGroupChecked, bindingOf, classMergeOf, formDefaultsOf, groupValue, shapeOf, shorthandClass, staticAttributeText, valueBoundBy, writesAttribute } from './plan'
|
|
20
22
|
import { bindEvent } from './validate'
|
|
21
23
|
|
|
@@ -252,7 +254,7 @@ export abstract class TemplateWriter {
|
|
|
252
254
|
continue
|
|
253
255
|
|
|
254
256
|
// Read below with the image's source, and never written.
|
|
255
|
-
if (name === 'img' &&
|
|
257
|
+
if (name === 'img' && IMAGE_OPTIONS.has(attributeName))
|
|
256
258
|
continue
|
|
257
259
|
|
|
258
260
|
// Read by `currentLink` on the server, and never written, a repeat of it included.
|
|
@@ -512,15 +514,15 @@ export abstract class TemplateWriter {
|
|
|
512
514
|
continue
|
|
513
515
|
}
|
|
514
516
|
|
|
515
|
-
// The `
|
|
516
|
-
if (
|
|
517
|
+
// The `parts` and spreads of a call handing parts on are written with its own.
|
|
518
|
+
if (handsEntry(element, this.src, attribute, element.component && parts.length > 0))
|
|
517
519
|
continue
|
|
518
520
|
|
|
519
521
|
const name = this.source(attribute.name)
|
|
520
522
|
|
|
521
|
-
if (element.name === 'img' &&
|
|
523
|
+
if (element.name === 'img' && IMAGE_OPTIONS.has(name)) {
|
|
522
524
|
// Takes the color a spread brings off the image, which the attributes after it cannot unset.
|
|
523
|
-
if (
|
|
525
|
+
if (placeholderOff(attribute, span => this.source(span)))
|
|
524
526
|
entry('style', () => b.add('undefined'), false)
|
|
525
527
|
|
|
526
528
|
continue
|
|
@@ -553,8 +555,14 @@ export abstract class TemplateWriter {
|
|
|
553
555
|
if (element.name === 'img' && ownStyle !== undefined && element.attributes.lastIndexOf(ownStyle) < lastSpread)
|
|
554
556
|
namedEntry(ownStyle, 'style')
|
|
555
557
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
+
// A call that hands a part on always holds parts in its list, which carry the classes as their root: its `class` is the one a spread would bring, left off.
|
|
559
|
+
const hands = element.component && handedParts(element, this.src, this.facts.parts).length > 0
|
|
560
|
+
|
|
561
|
+
if (hands ? spreads : mergedClass)
|
|
562
|
+
entry('class', () => hands ? b.add('undefined') : this.mergedClass(element, classAttribute, spreads), !hands)
|
|
563
|
+
|
|
564
|
+
if (element.component && parts.length > 0)
|
|
565
|
+
entry('parts', () => this.mergedClass(element, classAttribute, spreads, writtenParts(element, this.src)), true)
|
|
558
566
|
|
|
559
567
|
if (!keepOpen)
|
|
560
568
|
close()
|
|
@@ -688,8 +696,8 @@ export abstract class TemplateWriter {
|
|
|
688
696
|
this.b.add(`, { ${defaults.map(([name, value]) => `${JSON.stringify(name)}: ${JSON.stringify(value)}`).join(', ')} }`)
|
|
689
697
|
}
|
|
690
698
|
|
|
691
|
-
// `class` as written: the shorthand alone or merged with a static attribute is a string; with an expression or spreads, an array of every source, which a component gets merged into one string, as its `class?: string` prop takes it.
|
|
692
|
-
protected mergedClass(element: ElementNode, classAttribute: NamedAttribute | undefined, spreads: boolean): void {
|
|
699
|
+
// `class` as written: the shorthand alone or merged with a static attribute is a string; with an expression or spreads, an array of every source, which a component gets merged into one string, as its `class?: string` prop takes it. With `handing`, the `parts` a component call that hands parts on gets in its place, laid over the `parts` it writes.
|
|
700
|
+
protected mergedClass(element: ElementNode, classAttribute: NamedAttribute | undefined, spreads: boolean, handing?: readonly Attribute[]): void {
|
|
693
701
|
const { b } = this
|
|
694
702
|
const shorthand = element.classes.length > 0 ? this.shorthand(element) : undefined
|
|
695
703
|
const parts = partsOf(element, this.src, this.facts.parts)
|
|
@@ -703,7 +711,7 @@ export abstract class TemplateWriter {
|
|
|
703
711
|
}
|
|
704
712
|
|
|
705
713
|
// A literal is kept as text, so the ones side by side resolve together.
|
|
706
|
-
const items:
|
|
714
|
+
const items: ClassItem[] = []
|
|
707
715
|
|
|
708
716
|
if (shorthand !== undefined)
|
|
709
717
|
items.push({ text: shorthand })
|
|
@@ -736,20 +744,9 @@ export abstract class TemplateWriter {
|
|
|
736
744
|
for (const part of parts)
|
|
737
745
|
items.push(...this.recipeItem(part).map(emit => ({ emit })), { emit: () => b.add(`${helperName('partClass')}(${PROPS}, ${JSON.stringify(part)})`) })
|
|
738
746
|
|
|
739
|
-
const written = this.classTable === undefined
|
|
740
|
-
? items
|
|
741
|
-
: items.reduce<typeof items>((merged, item) => {
|
|
742
|
-
const last = merged.at(-1)
|
|
743
|
-
|
|
744
|
-
if ('text' in item && last !== undefined && 'text' in last)
|
|
745
|
-
merged[merged.length - 1] = { text: this.joinLiterals([last.text, item.text]) }
|
|
746
|
-
else
|
|
747
|
-
merged.push(item)
|
|
748
|
-
|
|
749
|
-
return merged
|
|
750
|
-
}, [])
|
|
747
|
+
const written = this.classTable === undefined ? items : joinTexts(items, texts => this.joinLiterals(texts))
|
|
751
748
|
|
|
752
|
-
b
|
|
749
|
+
openClassList(b, element.component, parts.length > 0, handing)
|
|
753
750
|
for (const [index, item] of written.entries()) {
|
|
754
751
|
if (index > 0)
|
|
755
752
|
b.add(', ')
|
|
@@ -759,7 +756,7 @@ export abstract class TemplateWriter {
|
|
|
759
756
|
else
|
|
760
757
|
item.emit()
|
|
761
758
|
}
|
|
762
|
-
b
|
|
759
|
+
closeHandParts(b, element.component, handing)
|
|
763
760
|
}
|
|
764
761
|
|
|
765
762
|
// What a component receives as `children` or a slot: a lone line of text as its string or values, as JSX passes it, anything else rendered.
|
|
@@ -12,7 +12,7 @@ const NAMES_KAY = /["']kay["']/
|
|
|
12
12
|
const EXPORT = /\bexport\b/
|
|
13
13
|
|
|
14
14
|
// The entries `persisted` carries, one per storage.
|
|
15
|
-
export const PERSISTED_ENTRIES = new Set(['cookie', 'local', 'session'
|
|
15
|
+
export const PERSISTED_ENTRIES = new Set(['cookie', 'local', 'session'])
|
|
16
16
|
|
|
17
17
|
// The names a module exports as `export const name = signal(...)`, or `persisted`, `linked`, `queryParam`, `memo`, `debounced`, `throttled` or `live`, called as imported from `kay`: what a component importing them writes by assigning, and reads by calling.
|
|
18
18
|
export function moduleSignals(source: string, jsx = false): Record<string, SignalKind> {
|
|
@@ -56,7 +56,7 @@ function allTypes(specifiers: Node[]): boolean {
|
|
|
56
56
|
return specifiers.length > 0 && specifiers.every(specifier => (specifier.type === 'ImportSpecifier' && specifier.importKind === 'type') || (specifier.type === 'ExportSpecifier' && specifier.exportKind === 'type'))
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
// The local name a call's callee makes a signal by: `signal` of `signal(...)`, and `persisted` of `persisted.local(...)`, `.session`,
|
|
59
|
+
// The local name a call's callee makes a signal by: `signal` of `signal(...)`, and `persisted` of `persisted.local(...)`, `.session`, and `.cookie`, which make one.
|
|
60
60
|
function madeBy(callee: Node, persisted: Set<string>): string | undefined {
|
|
61
61
|
if (callee.type === 'Identifier')
|
|
62
62
|
return callee.name
|
package/src/compiler/names.ts
CHANGED
|
@@ -36,7 +36,7 @@ export function defaultName(index: number): string {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
// What the editor leaves out of completions: the names above a completion can reach, and what the generated code imports or declares.
|
|
39
|
-
export const GENERATED_NAME = new RegExp(`^(?:${[PROPS, VALUES, CURRENT, 'kayEvent', 'kayMatched', 'kayAwaited', 'kayEach'].join('|')}|${DEFAULT_PREFIX}\\d+|Kay(?:Default|LoopFor|StaticFor|Show|Omit|ComponentClass|PartClass|PartsClass|PartOf|HandedPart|Dynamic|TemplateHelpers|Island|IslandBrand|HydrateWhen|Href|Html|ComputedHtml|Field|FormValues|FormError|Prop|PlainProp|FunctionProp|PromotedProp|PromotedFunctionProp|HandsPart|Children|Row|List|Truthy|Unmatched|Keyed|Radio|Writable|WriteTo|UpdateTo|WriteBack|UpdateBack|Bound|Bindable|Handed|PageContext|PrerenderedContext|PageSettings|QueryOf|PageData|JSX|FormAction|RegisterActions|ActionStub|ReviveActions|UseHead|Await|Awaited|Try))$`)
|
|
39
|
+
export const GENERATED_NAME = new RegExp(`^(?:${[PROPS, VALUES, CURRENT, 'kayEvent', 'kayMatched', 'kayAwaited', 'kayEach'].join('|')}|${DEFAULT_PREFIX}\\d+|Kay(?:Default|LoopFor|StaticFor|Show|Omit|ComponentClass|PartClass|PartsClass|HandParts|PartOf|HandedPart|Dynamic|TemplateHelpers|Island|IslandBrand|HydrateWhen|Href|Html|ComputedHtml|Field|FormValues|FormError|Prop|PlainProp|FunctionProp|PromotedProp|PromotedFunctionProp|HandsPart|Children|Row|List|Truthy|Unmatched|Keyed|Radio|Writable|WriteTo|UpdateTo|WriteBack|UpdateBack|Bound|Bindable|Handed|PageContext|PrerenderedContext|PageSettings|QueryOf|PageData|JSX|FormAction|RegisterActions|ActionStub|ReviveActions|UseHead|Await|Awaited|Try))$`)
|
|
40
40
|
|
|
41
41
|
// The app's `src/await-failed.kay`, and the message keys it words.
|
|
42
42
|
export interface AwaitAlert {
|
|
@@ -5,6 +5,17 @@ export const PAGE = 'page'
|
|
|
5
5
|
// The settings that moved from `page` into its `seo` group in 1.105.
|
|
6
6
|
export const SEO_SETTINGS: readonly string[] = ['noindex', 'sitemap', 'lastmod', 'search', 'feed']
|
|
7
7
|
|
|
8
|
+
// The report for a key `page` held before 1.105 and no longer reads, which fails the build naming where it is written now.
|
|
9
|
+
export function movedSettingReport(key: string): { message: string, help: string } | undefined {
|
|
10
|
+
if (SEO_SETTINGS.includes(key))
|
|
11
|
+
return { message: `\`${key}\` is a setting of \`seo\`, not of \`page\`, since 1.105`, help: `write \`page = { seo: { ${key}: ... } }\`` }
|
|
12
|
+
|
|
13
|
+
if (key === 'ttl' || key === 'cacheControl')
|
|
14
|
+
return { message: `\`${key}\` is \`cache\` since 1.105, which sets the lifetime and the \`cache-control\` of the page in one place`, help: 'write `cache: \'1h\'`, `cache: { browser, shared, swr }`, `cache: \'private\'` or `cache: false`' }
|
|
15
|
+
|
|
16
|
+
return undefined
|
|
17
|
+
}
|
|
18
|
+
|
|
8
19
|
// The report for a `guards` or `layouts` setting the server cannot read, shared by the compiler and `kay check` so both say it alike.
|
|
9
20
|
export function unreadSettingReport(key: string): { message: string, help: string } {
|
|
10
21
|
return {
|
package/src/compiler/parser.ts
CHANGED
|
@@ -5,10 +5,8 @@ import { ifAlias } from './if-alias'
|
|
|
5
5
|
import { rolesOf, spelledOutFirstFence } from './island-declaration'
|
|
6
6
|
import { Scanner } from './scanner'
|
|
7
7
|
|
|
8
|
-
// `--- server`, `---
|
|
8
|
+
// `--- server`, `--- script`, `--- module`, `--- style`, or `--- <T extends Row>` making the component generic, its type parameters in the third or fourth group: `--- script <T>` takes both.
|
|
9
9
|
const FENCE = /---(?:([ \t]*)([a-z]+)(?:[ \t]+<(.*)>)?|[ \t]*<(.*)>)?[ \t]*\r?\n/diy
|
|
10
|
-
// The names a script fence takes beside none: `client` renders in the browser only, `island` and `static` pin the role.
|
|
11
|
-
const SCRIPT_FENCES: ReadonlySet<string> = new Set(['client', 'script', 'island', 'static'])
|
|
12
10
|
const CLOSING_FENCE = /^---(?:[ \t]*$|[ \t]*[a-z<])/gm
|
|
13
11
|
const BARE_LINE = /^---[ \t]*$/
|
|
14
12
|
const CLOSING_LINE = /---[ \t]*(?=\r?\n|$)/y
|
|
@@ -103,7 +101,7 @@ export function parseKay(source: string): KayFile {
|
|
|
103
101
|
// The bare `---` closing a named fence while no script fence is open yet, which a later bare `---` was meant to be the script fence of.
|
|
104
102
|
let bareClosing: Span | undefined
|
|
105
103
|
|
|
106
|
-
// Fences come first, in any order: `---` or `--- script` holds the component script, `---
|
|
104
|
+
// Fences come first, in any order: `---` or `--- script` holds the component script, `--- server` the code that runs on the server only, `--- module` the module-level code, which exports values.
|
|
107
105
|
// A labeled fence line also closes the fence before it, so `--- server` code can run straight into `--- script`.
|
|
108
106
|
while (true) {
|
|
109
107
|
BLANK_LINES.lastIndex = templateStart
|
|
@@ -114,7 +112,7 @@ export function parseKay(source: string): KayFile {
|
|
|
114
112
|
if (!fence)
|
|
115
113
|
break
|
|
116
114
|
|
|
117
|
-
const kind = fence[2] === undefined
|
|
115
|
+
const kind = fence[2] === undefined ? 'script' : fence[2]
|
|
118
116
|
const spaced = fence[1] !== ''
|
|
119
117
|
const bodyStart = fence.index + fence[0].length
|
|
120
118
|
|
|
@@ -134,7 +132,7 @@ export function parseKay(source: string): KayFile {
|
|
|
134
132
|
}
|
|
135
133
|
|
|
136
134
|
if (!spaced || (kind !== 'script' && kind !== 'server' && kind !== 'module' && kind !== 'style')) {
|
|
137
|
-
diagnostics.push({ start: fence.index, end: bodyStart - 1, code: 'fence-invalid', message: `Unknown fence \`${fence[0].trim()}\``, help: 'use `---` or `--- script` for the component script,
|
|
135
|
+
diagnostics.push({ start: fence.index, end: bodyStart - 1, code: 'fence-invalid', message: `Unknown fence \`${fence[0].trim()}\``, help: 'use `---` or `--- script` for the component script, `island({ render, hydrate, persist })` first in it to declare its role, `--- server` for server code, `--- module` for module-level code that exports values, or `--- style` for CSS scoped to the component' })
|
|
138
136
|
}
|
|
139
137
|
else if (fences[kind]) {
|
|
140
138
|
diagnostics.push({ start: fence.index, end: bodyStart - 1, code: 'fence-invalid', message: `A file has one ${kind === 'script' ? 'script' : `\`--- ${kind}\``} fence` })
|
|
@@ -162,7 +160,7 @@ export function parseKay(source: string): KayFile {
|
|
|
162
160
|
}
|
|
163
161
|
}
|
|
164
162
|
|
|
165
|
-
const { island, client, pin } = rolesOf(source, fences.script
|
|
163
|
+
const { island, client, pin } = rolesOf(source, fences.script)
|
|
166
164
|
|
|
167
165
|
const parser = new TemplateParser(source, templateStart, diagnostics)
|
|
168
166
|
const template = parser.parseTemplate()
|
|
@@ -181,7 +179,7 @@ function explainSecondFence(source: string, closing: Span, diagnostics: Diagnost
|
|
|
181
179
|
if (!stray)
|
|
182
180
|
return
|
|
183
181
|
|
|
184
|
-
stray.help = 'a second fence takes a name once a `--- server` or `--- module` fence is there: write the one closing it as `--- script`
|
|
182
|
+
stray.help = 'a second fence takes a name once a `--- server` or `--- module` fence is there: write the one closing it as `--- script`'
|
|
185
183
|
stray.fixes = [{ title: 'Name the script fence', edits: [{ start: closing.start, end: closing.end, text: '--- script' }], safe: true }]
|
|
186
184
|
}
|
|
187
185
|
|
package/src/compiler/plan.ts
CHANGED
|
@@ -3,7 +3,6 @@ import type { CodeBuilder } from './mapping'
|
|
|
3
3
|
import type { PlannedAttribute } from './markup'
|
|
4
4
|
import { actionOf, FIELD_ATTRIBUTE, FIELD_ELEMENTS, UNCHECKED_TYPES, UNREQUIRABLE_TYPES } from './ast'
|
|
5
5
|
import { decodeEntities } from './expression'
|
|
6
|
-
import { oldPartsClass } from './old-parts'
|
|
7
6
|
|
|
8
7
|
// Whether a group (the signal of a `bind:group`, a string for radios or an array for checkboxes) holds a value, as the checked state of the box reads it.
|
|
9
8
|
export const GROUP_HAS = '((kayGroup: unknown, kayValue: string) => Array.isArray(kayGroup) ? kayGroup.includes(kayValue) : kayGroup === kayValue)'
|
|
@@ -126,8 +125,7 @@ export interface ClassMerge {
|
|
|
126
125
|
}
|
|
127
126
|
|
|
128
127
|
export function classMergeOf(element: ElementNode, src: string): ClassMerge {
|
|
129
|
-
const
|
|
130
|
-
const attribute = element.attributes.find((candidate): candidate is NamedAttribute => candidate.kind !== 'spread' && candidate !== old && src.slice(candidate.name.start, candidate.name.end) === 'class')
|
|
128
|
+
const attribute = element.attributes.find((candidate): candidate is NamedAttribute => candidate.kind !== 'spread' && src.slice(candidate.name.start, candidate.name.end) === 'class')
|
|
131
129
|
const spreads = element.attributes.some(candidate => candidate.kind === 'spread')
|
|
132
130
|
const shorthand = element.classes.length > 0 ? { start: element.classes[0]!.start, end: element.classes.at(-1)!.end } : undefined
|
|
133
131
|
|