@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
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import type { Edit } from './renamed-exports'
|
|
3
|
-
import { basename } from 'node:path'
|
|
4
|
-
import { lintLevel } from '../compiler/lints'
|
|
5
|
-
import { constBindings, exportedObject, keyName, objectOf } from '../compiler/object-literal'
|
|
6
|
-
import { featureProperties } from './config-objects'
|
|
7
|
-
import { renamedCallOptions } from './renamed-call-options'
|
|
8
|
-
import { scan } from './renamed-exports'
|
|
9
|
-
|
|
10
|
-
const GUARD = /\bguard\b|\brequireGuards\b/
|
|
11
|
-
const FROM_SERVER = (source: string) => source === 'kay/server' || source === '@kayjs/kay/server'
|
|
12
|
-
|
|
13
|
-
// `guard` in `vitals({ guard })`, in the `jobs` and `images` of kay.config.ts: `guards` since 1.105, the one name of a guard option; and `requireGuards`, `guards: { default }` since 1.105.
|
|
14
|
-
export async function guardOptions(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
15
|
-
if (lintLevel('deprecated-guard-option', options.lints) === 'allow')
|
|
16
|
-
return []
|
|
17
|
-
|
|
18
|
-
const calls = await renamedCallOptions(root, options, { lint: 'deprecated-guard-option', needle: GUARD, from: FROM_SERVER, calls: { vitals: 0 }, renames: [['guard', 'guards']], since: '1.105', of: '`vitals()`' })
|
|
19
|
-
|
|
20
|
-
const config = await scan(root, options, 'deprecated-guard-option', GUARD, ({ file, parsed, report }) => {
|
|
21
|
-
if (basename(file) !== 'kay.config.ts')
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
for (const { ast, base } of parsed) {
|
|
25
|
-
const bindings = constBindings(ast)
|
|
26
|
-
const exported = exportedObject(ast, bindings)
|
|
27
|
-
|
|
28
|
-
const own = (exported?.properties ?? []).filter((one): one is Extract<typeof one, { type: 'Property' }> => one.type === 'Property')
|
|
29
|
-
const required = own.find(one => keyName(one) === 'requireGuards')
|
|
30
|
-
|
|
31
|
-
if (required) {
|
|
32
|
-
const { value } = required
|
|
33
|
-
const taken = own.some(one => keyName(one) === 'guards')
|
|
34
|
-
const known = value.type === 'Literal' && typeof value.value === 'boolean'
|
|
35
|
-
const edits: Edit[] | null = taken || !known || required.shorthand || required.computed ? null : [{ start: base + required.start, end: base + required.end, text: `guards: { default: '${value.value ? 'closed' : 'open'}' }` }]
|
|
36
|
-
|
|
37
|
-
report(base + required.start, base + required.end, '`requireGuards` is deprecated since 1.105: `guards: { default }` says what a route no guard covers comes to', 'write `guards: { default: \'closed\' }` for `true` and `\'open\'` for `false`', edits)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const features = exported === undefined ? [] : [...featureProperties(exported, bindings, 'ops', 'jobs').map(feature => ({ name: 'jobs', feature })), ...featureProperties(exported, bindings, 'assets', 'images').map(feature => ({ name: 'images', feature }))]
|
|
41
|
-
|
|
42
|
-
for (const { name, feature } of features) {
|
|
43
|
-
const section = objectOf(feature.value, bindings)
|
|
44
|
-
const properties = (section?.properties ?? []).filter((one): one is Extract<typeof one, { type: 'Property' }> => one.type === 'Property')
|
|
45
|
-
const old = properties.find(one => keyName(one) === 'guard')
|
|
46
|
-
|
|
47
|
-
if (!old)
|
|
48
|
-
continue
|
|
49
|
-
|
|
50
|
-
const edits: Edit[] | null = properties.some(one => keyName(one) === 'guards') || old.computed ? null : [old.shorthand ? { start: base + old.start, end: base + old.end, text: 'guards: guard' } : { start: base + old.key.start, end: base + old.key.end, text: 'guards' }]
|
|
51
|
-
|
|
52
|
-
report(base + old.start, base + old.end, `\`guard\` of \`${name}\` is deprecated since 1.105: the option is \`guards\``, 'write `guards`', edits)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
return [...calls, ...config]
|
|
58
|
-
}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import type { Fix, Span } from '../compiler/ast'
|
|
2
|
-
import { attributeNamed } from './template-hints'
|
|
3
|
-
|
|
4
|
-
// `Type '(next: boolean) => void' is not assignable to type '(event: { checked: boolean; }) => unknown'.` and the incompatible parameter that follows.
|
|
5
|
-
const EVENT_CALLBACK = /^Type '([\s\S]+?)' is not assignable to type '\(event: \{ ([\s\S]*?) \}\) => unknown'\.\n\s+Types of parameters '[^']*' and 'event' are incompatible\.\n([\s\S]*)$/
|
|
6
|
-
const PARAMETER_TYPE = /(?:to type|from type) '([\s\S]*?)'(?:\.|:)/
|
|
7
|
-
const FIELD = /^(\w+)\??:/
|
|
8
|
-
const CALLBACK_NAME = /^on[A-Z]\w*$/
|
|
9
|
-
const HANDLER_NAME = /^[A-Z_$][\w$]*(?:\??\.[A-Z_$][\w$]*)*$/i
|
|
10
|
-
// An object literal type or a named type, which no old argument was apart from a `File`: the handler may be written for the event already.
|
|
11
|
-
const OBJECT_TYPE = /^(?:\{|object\b|(?!File\b)[A-Z])/
|
|
12
|
-
const COMPONENT = /^([A-Z][\w$]*)(?:[.#][^\s(]*)?\(/
|
|
13
|
-
const NAME_AT = /^[\w$]+/
|
|
14
|
-
const EVENT_WORD = /\bevent\b/
|
|
15
|
-
const ELEMENT = /^[a-z.#][^\s(]*\(/
|
|
16
|
-
|
|
17
|
-
// What an old-form lint of the type check reports.
|
|
18
|
-
export interface OldFormLint {
|
|
19
|
-
message: string
|
|
20
|
-
help: string
|
|
21
|
-
span: Span
|
|
22
|
-
fixes?: Fix[]
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// The segments of a type's text between its top-level `separator`s.
|
|
26
|
-
function splitTop(text: string, separator: string): string[] {
|
|
27
|
-
const parts: string[] = []
|
|
28
|
-
let depth = 0
|
|
29
|
-
let from = 0
|
|
30
|
-
|
|
31
|
-
for (const [index, char] of [...text].entries()) {
|
|
32
|
-
if ('{([<'.includes(char)) {
|
|
33
|
-
depth++
|
|
34
|
-
}
|
|
35
|
-
else if ('})]'.includes(char) || (char === '>' && text[index - 1] !== '=')) {
|
|
36
|
-
depth--
|
|
37
|
-
}
|
|
38
|
-
else if (char === separator && depth === 0) {
|
|
39
|
-
parts.push(text.slice(from, index))
|
|
40
|
-
from = index + 1
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
parts.push(text.slice(from))
|
|
45
|
-
|
|
46
|
-
return parts.map(part => part.trim()).filter(part => part !== '')
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// How many parameters a function type written as `(a: A, b: B) => R` takes, 1 for any other type, as a signal's `Setter<T>` takes one.
|
|
50
|
-
function parameterCount(type: string): number {
|
|
51
|
-
if (!type.startsWith('('))
|
|
52
|
-
return 1
|
|
53
|
-
|
|
54
|
-
let depth = 0
|
|
55
|
-
|
|
56
|
-
for (const [index, char] of [...type].entries()) {
|
|
57
|
-
if (char === '(')
|
|
58
|
-
depth++
|
|
59
|
-
else if (char === ')' && --depth === 0)
|
|
60
|
-
return splitTop(type.slice(1, index), ',').length
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return 1
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Whether the first parameter of a function type written as `(a: A, b: B) => R` is typed as an object, a literal or a named type.
|
|
67
|
-
function takesObject(type: string): boolean {
|
|
68
|
-
if (!type.startsWith('('))
|
|
69
|
-
return false
|
|
70
|
-
|
|
71
|
-
const first = splitTop(type.slice(1), ',')[0] ?? ''
|
|
72
|
-
|
|
73
|
-
// A destructured parameter takes an object whatever its type is called.
|
|
74
|
-
if (first.startsWith('{'))
|
|
75
|
-
return true
|
|
76
|
-
|
|
77
|
-
const colon = first.indexOf(':')
|
|
78
|
-
|
|
79
|
-
return colon !== -1 && OBJECT_TYPE.test(first.slice(colon + 1).trim())
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// The component an attribute is written on, read off its line or, for an attribute on a line of its own, the line above it that opens the call.
|
|
83
|
-
function componentAt(source: string, at: number): string | undefined {
|
|
84
|
-
const lineEnd = source.indexOf('\n', at)
|
|
85
|
-
const [own, ...above] = source.slice(0, lineEnd === -1 ? source.length : lineEnd).split('\n').toReversed()
|
|
86
|
-
const opened = COMPONENT.exec(own!.trimStart())
|
|
87
|
-
|
|
88
|
-
if (opened !== null)
|
|
89
|
-
return opened[1]
|
|
90
|
-
|
|
91
|
-
if (ELEMENT.test(own!.trimStart()))
|
|
92
|
-
return undefined
|
|
93
|
-
|
|
94
|
-
const indent = own!.length - own!.trimStart().length
|
|
95
|
-
|
|
96
|
-
for (const line of above) {
|
|
97
|
-
const trimmed = line.trimStart()
|
|
98
|
-
|
|
99
|
-
if (trimmed !== '' && line.length - trimmed.length < indent)
|
|
100
|
-
return COMPONENT.exec(trimmed)?.[1]
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return undefined
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// A callback a component of a kayjs library takes as one event object since 1.105, given a function written for its positional arguments: the handler of `onValueChange={query.set}`, `onCheckedChange={toggle}` or `onFiles={upload}`.
|
|
107
|
-
// The fix wraps a handler written as a name, `event => query.set(event.value)`, passing the fields the handler took, first ones first. It is applied where the handler's parameter is no object, which the old arguments were; a handler taking an object may be written for the event already, so its fix is offered.
|
|
108
|
-
export function handlerEventLint(message: string, source: string, span: Span | undefined): OldFormLint | undefined {
|
|
109
|
-
const found = EVENT_CALLBACK.exec(message)
|
|
110
|
-
|
|
111
|
-
if (found === null || span === undefined)
|
|
112
|
-
return undefined
|
|
113
|
-
|
|
114
|
-
const name = NAME_AT.exec(source.slice(span.start))?.[0]
|
|
115
|
-
|
|
116
|
-
if (name === undefined || !CALLBACK_NAME.test(name))
|
|
117
|
-
return undefined
|
|
118
|
-
|
|
119
|
-
const component = componentAt(source, span.start)
|
|
120
|
-
|
|
121
|
-
if (component === undefined || !new RegExp(`^import\\b[^\\n]*\\b${component}\\b[^\\n]*from\\s+['"]@kayjs/`, 'm').test(source))
|
|
122
|
-
return undefined
|
|
123
|
-
|
|
124
|
-
const [, handlerType, eventFields, rest] = found
|
|
125
|
-
const fields = splitTop(eventFields!, ';').flatMap(segment => FIELD.exec(segment)?.[1] ?? [])
|
|
126
|
-
|
|
127
|
-
if (fields.length === 0)
|
|
128
|
-
return undefined
|
|
129
|
-
|
|
130
|
-
const object = takesObject(handlerType!) || PARAMETER_TYPE.exec(rest!)?.[1]?.startsWith('{') === true
|
|
131
|
-
const taken = fields.slice(0, Math.max(1, Math.min(parameterCount(handlerType!), fields.length)))
|
|
132
|
-
const attribute = attributeNamed(source, { start: span.start, end: source.length }, name)
|
|
133
|
-
const value = attribute === undefined ? undefined : source.slice(attribute.start + name.length + 1, attribute.end)
|
|
134
|
-
const inner = value?.startsWith('{') && value.endsWith('}') ? value.slice(1, -1).trim() : undefined
|
|
135
|
-
const handler = inner !== undefined && HANDLER_NAME.test(inner) && !EVENT_WORD.test(inner) ? inner : undefined
|
|
136
|
-
const written = `event => ${handler}(${taken.map(field => `event.${field}`).join(', ')})`
|
|
137
|
-
const report = {
|
|
138
|
-
message: `\`${name}\` on \`${component}\` takes one event object since 1.105, \`{ ${fields.join(', ')} }\`, where it took ${fields.map(field => `\`${field}\``).join(', ')} as ${fields.length === 1 ? 'its argument' : 'arguments'}`,
|
|
139
|
-
help: handler === undefined ? 'take the event object, `({ value }) => ...`, and read the fields from it' : `write \`${name}={${written}}\``,
|
|
140
|
-
span,
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (handler === undefined || attribute === undefined)
|
|
144
|
-
return report
|
|
145
|
-
|
|
146
|
-
const start = attribute.start + name.length + 1 + value!.indexOf(handler)
|
|
147
|
-
|
|
148
|
-
return { ...report, fixes: [{ title: `Write \`${name}={${written}}\``, safe: !object, edits: [{ start, end: start + handler.length, text: written }] }] }
|
|
149
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import type { Node, NodeOfType } from '../compiler/estree'
|
|
3
|
-
import type { Edit } from './renamed-exports'
|
|
4
|
-
import { lintLevel } from '../compiler/lints'
|
|
5
|
-
import { keyName } from '../compiler/object-literal'
|
|
6
|
-
import { importsOf, walk } from './ast'
|
|
7
|
-
import { configObjects, isProperty, propertiesOf } from './config-objects'
|
|
8
|
-
import { scan } from './renamed-exports'
|
|
9
|
-
|
|
10
|
-
type ObjectExpression = NodeOfType<'ObjectExpression'>
|
|
11
|
-
|
|
12
|
-
const NEEDLE = /\bctx\b/
|
|
13
|
-
const HOOKS = ['beforeRun', 'onSuccess', 'onError']
|
|
14
|
-
const FROM_KAY = (source: string): boolean => source === 'kay' || source === 'kay/server'
|
|
15
|
-
|
|
16
|
-
type Hook = NodeOfType<'ArrowFunctionExpression'> | NodeOfType<'FunctionExpression'>
|
|
17
|
-
|
|
18
|
-
// The `ctx` an action hook reads off its event, `context` since 1.105: the one field every hook event carries, which holds the action's own context besides who asks.
|
|
19
|
-
// A hook is the function written under `beforeRun`, `onSuccess` or `onError` in the `actions` of the config or the options of an `action()` call; the fix renames what a destructured parameter or a member read of the event names, and offers none where the name is given a default or the event is used another way.
|
|
20
|
-
function hookEdits(hook: Hook, base: number): { start: number, end: number, edits: Edit[] | null }[] {
|
|
21
|
-
const [event] = hook.params
|
|
22
|
-
const found: { start: number, end: number, edits: Edit[] | null }[] = []
|
|
23
|
-
|
|
24
|
-
if (event?.type === 'ObjectPattern') {
|
|
25
|
-
for (const property of event.properties) {
|
|
26
|
-
if (property.type !== 'Property' || property.computed || keyName(property) !== 'ctx')
|
|
27
|
-
continue
|
|
28
|
-
|
|
29
|
-
const value = property.value
|
|
30
|
-
const renamed = property.shorthand ? { start: base + property.start, end: base + property.end, text: 'context: ctx' } : { start: base + property.key.start, end: base + property.key.end, text: 'context' }
|
|
31
|
-
const edits: Edit[] | null = property.shorthand && value.type !== 'Identifier' ? null : [renamed]
|
|
32
|
-
|
|
33
|
-
found.push({ start: base + property.start, end: base + property.end, edits })
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return found
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (event?.type !== 'Identifier' || hook.body === null || hook.body === undefined)
|
|
40
|
-
return found
|
|
41
|
-
|
|
42
|
-
walk(hook.body, (node) => {
|
|
43
|
-
if (node.type === 'MemberExpression' && !node.computed && node.object.type === 'Identifier' && node.object.name === event.name && node.property.type === 'Identifier' && node.property.name === 'ctx')
|
|
44
|
-
found.push({ start: base + node.property.start, end: base + node.property.end, edits: [{ start: base + node.property.start, end: base + node.property.end, text: 'context' }] })
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
return found
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const isHook = (node: Node): node is Hook => node.type === 'ArrowFunctionExpression' || node.type === 'FunctionExpression'
|
|
51
|
-
|
|
52
|
-
// The hook functions an object of action hooks holds.
|
|
53
|
-
function hooksOf(object: ObjectExpression): Hook[] {
|
|
54
|
-
return HOOKS.flatMap(name => propertiesOf(object, name)).flatMap(property => isProperty(property) && isHook(property.value) ? [property.value] : [])
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export async function hookContext(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
58
|
-
if (lintLevel('deprecated-hook-context', options.lints) === 'allow')
|
|
59
|
-
return []
|
|
60
|
-
|
|
61
|
-
return scan(root, options, 'deprecated-hook-context', NEEDLE, ({ file, parsed, report }) => {
|
|
62
|
-
for (const { ast, base } of parsed) {
|
|
63
|
-
const objects: ObjectExpression[] = []
|
|
64
|
-
|
|
65
|
-
for (const { object } of configObjects(file, ast)) {
|
|
66
|
-
const [actions] = propertiesOf(object, 'actions')
|
|
67
|
-
|
|
68
|
-
if (actions?.value.type === 'ObjectExpression')
|
|
69
|
-
objects.push(actions.value)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const { locals, namespaces } = importsOf(ast, FROM_KAY, 'action')
|
|
73
|
-
|
|
74
|
-
if (locals.size > 0 || namespaces.size > 0) {
|
|
75
|
-
walk(ast, (node) => {
|
|
76
|
-
if (node.type !== 'CallExpression')
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
const callee = node.callee
|
|
80
|
-
const called = callee.type === 'Identifier' ? locals.has(callee.name) : callee.type === 'MemberExpression' && !callee.computed && callee.object.type === 'Identifier' && namespaces.has(callee.object.name) && callee.property.type === 'Identifier' && callee.property.name === 'action'
|
|
81
|
-
const last = node.arguments.at(-1)
|
|
82
|
-
|
|
83
|
-
if (called && last?.type === 'ObjectExpression')
|
|
84
|
-
objects.push(last)
|
|
85
|
-
})
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
for (const hook of objects.flatMap(hooksOf)) {
|
|
89
|
-
for (const { start, end, edits } of hookEdits(hook, base))
|
|
90
|
-
report(start, end, '`ctx` of an action hook\'s event is deprecated since 1.105: every hook event carries one `context`, which holds the action\'s own context beside who asks', 'read `context`', edits)
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
}
|
package/src/check/hook-names.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import type { Node, NodeOfType } from '../compiler/estree'
|
|
3
|
-
import { lintLevel } from '../compiler/lints'
|
|
4
|
-
import { keyName } from '../compiler/object-literal'
|
|
5
|
-
import { renamePackages } from '../package-names'
|
|
6
|
-
import { importsOf, walk } from './ast'
|
|
7
|
-
import { scan } from './renamed-exports'
|
|
8
|
-
|
|
9
|
-
type ObjectNode = NodeOfType<'ObjectExpression'>
|
|
10
|
-
type Property = Extract<ObjectNode['properties'][number], { type: 'Property' }>
|
|
11
|
-
|
|
12
|
-
interface Library {
|
|
13
|
-
// The package whose imports the calls come from.
|
|
14
|
-
package: string
|
|
15
|
-
// The functions of the package that take hooks in their options.
|
|
16
|
-
calls: readonly string[]
|
|
17
|
-
// The options of kayjs-mail's lists are read off any `.list()` call in a file importing the package.
|
|
18
|
-
lists?: boolean
|
|
19
|
-
// `cms({ collections: { posts: { onSave } } })` sets the same hooks per collection.
|
|
20
|
-
collections?: boolean
|
|
21
|
-
hooks: Readonly<Record<string, string>>
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const LIBRARIES: readonly Library[] = [
|
|
25
|
-
{ package: '@kayjs/auth', calls: ['auth', 'authCore'], hooks: { onSignUp: 'afterSignUp' } },
|
|
26
|
-
{ package: '@kayjs/mail', calls: ['mail', 'mailer', 'contactForm'], lists: true, hooks: { onSend: 'afterSend', onSuppress: 'afterSuppress', onSubscribe: 'afterSubscribe', onConfirm: 'afterConfirm', onUnsubscribe: 'afterUnsubscribe', onBroadcast: 'afterBroadcast' } },
|
|
27
|
-
{ package: '@kayjs/cms', calls: ['cms'], collections: true, hooks: { onSave: 'afterSave', onUpload: 'afterUpload' } },
|
|
28
|
-
{ package: '@kayjs/ai', calls: ['ai', 'ask', 'speak', 'embed', 'transcribe', 'describeImage'], hooks: { onStep: 'afterStep', onToolCall: 'afterToolCall', onSuccess: 'afterRequest' } },
|
|
29
|
-
]
|
|
30
|
-
|
|
31
|
-
const NEEDLE = /\b(?:onSignUp|onSend|onSuppress|onSubscribe|onConfirm|onUnsubscribe|onBroadcast|onSave|onUpload|onStep|onToolCall|onSuccess)\b/
|
|
32
|
-
const HELP = 'write the `after` name: a hook that is told what happened is `after<Verb>`, one that may refuse or change it `before<Verb>`'
|
|
33
|
-
|
|
34
|
-
// A server hook of kayjs-auth, -mail, -cms or -ai under its name before 1.105, when the ones that observe became `after<Verb>`: `onSignUp` is `afterSignUp`, `onSend` and `onSuppress` of the mailer and `onSend` of `contactForm()` are `afterSend` and `afterSuppress`, a list's `onSubscribe`, `onConfirm`, `onUnsubscribe` and `onBroadcast` follow, `onSave` and `onUpload` of `cms()` (and of each collection) are `afterSave` and `afterUpload`, and `onStep`, `onToolCall` and `onSuccess` of kayjs-ai are `afterStep`, `afterToolCall` and `afterRequest`; `onError` and `onEvent` keep their names.
|
|
35
|
-
// Found in the options object written in a call of the library's function imported from it, and in the `hooks` object of kayjs-auth's `src/auth.ts`; the fix renames the key, a bare `{ onSave }` becoming `afterSave: onSave`, and offers none where the object spreads another or already writes the new name.
|
|
36
|
-
export async function hookNames(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
37
|
-
if (lintLevel('deprecated-hook-names', options.lints) === 'allow')
|
|
38
|
-
return []
|
|
39
|
-
|
|
40
|
-
return scan(root, options, 'deprecated-hook-names', NEEDLE, ({ parsed, report }) => {
|
|
41
|
-
for (const { ast, base } of parsed) {
|
|
42
|
-
for (const library of LIBRARIES) {
|
|
43
|
-
const from = (source: string) => renamePackages(source) === library.package
|
|
44
|
-
const found = library.calls.map(name => ({ name, ...importsOf(ast, from, name) }))
|
|
45
|
-
const imported = ast.body.some(statement => statement.type === 'ImportDeclaration' && statement.importKind !== 'type' && from(statement.source.value))
|
|
46
|
-
|
|
47
|
-
if (!imported && library.package !== '@kayjs/auth')
|
|
48
|
-
continue
|
|
49
|
-
|
|
50
|
-
const isCall = (callee: Node): boolean => found.some(({ name, locals, namespaces }) => callee.type === 'Identifier'
|
|
51
|
-
? locals.has(callee.name)
|
|
52
|
-
: callee.type === 'MemberExpression' && !callee.computed && callee.object.type === 'Identifier' && namespaces.has(callee.object.name) && callee.property.type === 'Identifier' && callee.property.name === name)
|
|
53
|
-
const isList = (callee: Node): boolean => library.lists === true && imported && callee.type === 'MemberExpression' && !callee.computed && callee.property.type === 'Identifier' && callee.property.name === 'list'
|
|
54
|
-
|
|
55
|
-
const check = (object: ObjectNode): void => {
|
|
56
|
-
const properties = object.properties.filter((property): property is Property => property.type === 'Property')
|
|
57
|
-
const spread = object.properties.some(property => property.type === 'SpreadElement')
|
|
58
|
-
const keys = new Set(properties.filter(property => !property.computed).map(property => keyName(property)))
|
|
59
|
-
|
|
60
|
-
for (const property of properties) {
|
|
61
|
-
const old = property.computed ? undefined : keyName(property)
|
|
62
|
-
const name = old === undefined ? undefined : library.hooks[old]
|
|
63
|
-
|
|
64
|
-
if (old === undefined || name === undefined)
|
|
65
|
-
continue
|
|
66
|
-
|
|
67
|
-
const fixable = !spread && !keys.has(name)
|
|
68
|
-
const text = property.shorthand ? `${name}: ${old}` : name
|
|
69
|
-
const edit = property.shorthand ? { start: base + property.start, end: base + property.end, text } : { start: base + property.key.start, end: base + property.key.end, text }
|
|
70
|
-
|
|
71
|
-
report(base + property.start, base + property.end, `\`${old}\` is \`${name}\` since 1.105: a server hook that is told what happened is \`after<Verb>\``, HELP, fixable ? [edit] : null)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (!library.collections)
|
|
75
|
-
return
|
|
76
|
-
|
|
77
|
-
const collections = properties.find(property => !property.computed && keyName(property) === 'collections')?.value
|
|
78
|
-
|
|
79
|
-
if (collections?.type !== 'ObjectExpression')
|
|
80
|
-
return
|
|
81
|
-
|
|
82
|
-
for (const each of collections.properties) {
|
|
83
|
-
if (each.type === 'Property' && each.value.type === 'ObjectExpression')
|
|
84
|
-
check(each.value)
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
walk(ast, (node) => {
|
|
89
|
-
if (node.type === 'CallExpression' && (isCall(node.callee) || isList(node.callee))) {
|
|
90
|
-
for (const argument of node.arguments) {
|
|
91
|
-
if (argument.type === 'ObjectExpression')
|
|
92
|
-
check(argument)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (library.package === '@kayjs/auth' && node.type === 'VariableDeclarator' && node.id.type === 'Identifier' && node.id.name === 'hooks' && node.init?.type === 'ObjectExpression')
|
|
99
|
-
check(node.init)
|
|
100
|
-
})
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
})
|
|
104
|
-
}
|
package/src/check/i18n-keys.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import type { Edit } from './renamed-exports'
|
|
3
|
-
import { lintLevel } from '../compiler/lints'
|
|
4
|
-
import { configObjects, propertyOf } from './config-objects'
|
|
5
|
-
import { scan } from './renamed-exports'
|
|
6
|
-
|
|
7
|
-
const NEEDLE = /\b(?:defaultLocale|prefixDefault|domains)\b/
|
|
8
|
-
|
|
9
|
-
// The keys `defaultLocale`, `prefixDefault` and `domains` of `i18n` in the config, which are `default` and `mode` since 1.105: `mode: 'always'` for `prefixDefault: true`, `mode: { domains }` for `domains`.
|
|
10
|
-
// The fix renames or rewrites one key where the object is written in place and `default` and `mode` are not yet there, and offers none for `domains` together with `prefixDefault`, a `prefixDefault` that is no literal, or a key written as a method or a getter.
|
|
11
|
-
export async function i18nKeys(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
12
|
-
if (lintLevel('deprecated-i18n-keys', options.lints) === 'allow')
|
|
13
|
-
return []
|
|
14
|
-
|
|
15
|
-
return scan(root, options, 'deprecated-i18n-keys', NEEDLE, ({ file, parsed, report }) => {
|
|
16
|
-
for (const { ast, base, text } of parsed) {
|
|
17
|
-
for (const { object, call } of configObjects(file, ast)) {
|
|
18
|
-
const i18n = call === undefined ? propertyOf(object, 'i18n') : undefined
|
|
19
|
-
const group = i18n?.value.type === 'ObjectExpression' ? i18n.value : undefined
|
|
20
|
-
|
|
21
|
-
if (group === undefined)
|
|
22
|
-
continue
|
|
23
|
-
|
|
24
|
-
const plain = group.properties.flatMap(property => property.type === 'Property' && !property.computed && !property.method && property.kind === 'init' ? [property] : [])
|
|
25
|
-
const named = (name: string) => plain.find(property => property.key.type === 'Identifier' ? property.key.name === name : property.key.type === 'Literal' && property.key.value === name)
|
|
26
|
-
const [defaultLocale, prefixDefault, domains] = [named('defaultLocale'), named('prefixDefault'), named('domains')]
|
|
27
|
-
const spread = group.properties.some(property => property.type !== 'Property')
|
|
28
|
-
|
|
29
|
-
if (defaultLocale !== undefined) {
|
|
30
|
-
const edits: Edit[] | null = spread || named('default') !== undefined ? null : [defaultLocale.shorthand ? { start: base + defaultLocale.start, end: base + defaultLocale.end, text: 'default: defaultLocale' } : { start: base + defaultLocale.key.start, end: base + defaultLocale.key.end, text: 'default' }]
|
|
31
|
-
|
|
32
|
-
report(base + defaultLocale.start, base + defaultLocale.end, '`i18n.defaultLocale` is `i18n.default` since 1.105', 'write `default`', edits)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (prefixDefault !== undefined) {
|
|
36
|
-
const { value } = prefixDefault
|
|
37
|
-
const free = !spread && named('mode') === undefined && domains === undefined && value.type === 'Literal' && value.value === true
|
|
38
|
-
|
|
39
|
-
report(base + prefixDefault.start, base + prefixDefault.end, '`i18n.prefixDefault` is `i18n.mode: \'always\'` since 1.105', 'write `mode: \'always\'`', free && !prefixDefault.shorthand ? [{ start: base + prefixDefault.start, end: base + prefixDefault.end, text: 'mode: \'always\'' }] : null)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (domains !== undefined) {
|
|
43
|
-
const free = !spread && named('mode') === undefined && prefixDefault === undefined
|
|
44
|
-
|
|
45
|
-
report(base + domains.start, base + domains.end, '`i18n.domains` is `i18n.mode: { domains }` since 1.105', 'write `mode: { domains }`', free ? [{ start: base + domains.start, end: base + domains.end, text: domains.shorthand ? 'mode: { domains }' : `mode: { domains: ${text.slice(domains.value.start, domains.value.end)} }` }] : null)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
}
|
package/src/check/images-keys.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import { basename } from 'node:path'
|
|
3
|
-
import { lintLevel } from '../compiler/lints'
|
|
4
|
-
import { constBindings, exportedObject, objectOf } from '../compiler/object-literal'
|
|
5
|
-
import { featureProperties } from './config-objects'
|
|
6
|
-
import { nameOf, regrouped } from './regroup'
|
|
7
|
-
import { scan } from './renamed-exports'
|
|
8
|
-
|
|
9
|
-
const NEEDLE = /\bimages\b/
|
|
10
|
-
const HELP = 'group the key, `remote: { maxSize, timeout }`, `formats: { quality, webp, avif }`, `limits: { variants, queue }`'
|
|
11
|
-
|
|
12
|
-
// Each flat key of `images` before 1.105 and the group and part it became.
|
|
13
|
-
const MOVED: Record<string, [string, string]> = {
|
|
14
|
-
remoteMaxSize: ['remote', 'maxSize'],
|
|
15
|
-
remoteTimeout: ['remote', 'timeout'],
|
|
16
|
-
maxVariants: ['limits', 'variants'],
|
|
17
|
-
queue: ['limits', 'queue'],
|
|
18
|
-
quality: ['formats', 'quality'],
|
|
19
|
-
webp: ['formats', 'webp'],
|
|
20
|
-
avif: ['formats', 'avif'],
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const movedTo = (name: string): [string, string] | undefined => Object.hasOwn(MOVED, name) ? MOVED[name] : undefined
|
|
24
|
-
|
|
25
|
-
// The flat keys of `images` in kay.config.ts, grouped since 1.105: `remote: { hosts, maxSize, timeout }`, `formats: { quality, webp, avif }`, `limits: { variants, queue }`.
|
|
26
|
-
// The fix, from the first report of an object, moves only those keys and offers none where the object spreads, holds a computed or shorthand key, names a part twice or already has the group.
|
|
27
|
-
export async function imagesKeys(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
28
|
-
if (lintLevel('deprecated-images-keys', options.lints) === 'allow')
|
|
29
|
-
return []
|
|
30
|
-
|
|
31
|
-
return scan(root, options, 'deprecated-images-keys', NEEDLE, ({ file, parsed, report }) => {
|
|
32
|
-
if (basename(file) !== 'kay.config.ts')
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
for (const { ast, base, text } of parsed) {
|
|
36
|
-
const bindings = constBindings(ast)
|
|
37
|
-
const exported = exportedObject(ast, bindings)
|
|
38
|
-
|
|
39
|
-
for (const images of exported === undefined ? [] : featureProperties(exported, bindings, 'assets', 'images')) {
|
|
40
|
-
const object = objectOf(images.value, bindings)
|
|
41
|
-
const old = object?.properties.filter(property => property.type === 'Property' && !property.computed && movedTo(nameOf(property)) !== undefined) ?? []
|
|
42
|
-
|
|
43
|
-
if (object === undefined || old.length === 0)
|
|
44
|
-
continue
|
|
45
|
-
|
|
46
|
-
// A bound object lives elsewhere in the file, so its keys are found and not rewritten from here.
|
|
47
|
-
const fixed = images.value === object ? regrouped(object, text, movedTo) : undefined
|
|
48
|
-
|
|
49
|
-
for (const [index, property] of old.entries())
|
|
50
|
-
report(base + property.start, base + property.end, `\`images.${nameOf(property)}\` is grouped since 1.105`, HELP, index === 0 && fixed !== undefined ? fixed.map(edit => ({ ...edit, start: base + edit.start, end: base + edit.end })) : null)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
}
|