@kayjs/kay 1.108.0 → 1.110.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eslint.js +2093 -3774
- package/editors/zed/extension.toml +2 -2
- package/llms/action-protection.md +1 -1
- package/llms/actions-from-islands.md +5 -5
- package/llms/actions-refused-fields.md +4 -4
- package/llms/api-from-islands.md +6 -6
- package/llms/browser-only.md +2 -2
- package/llms/cdn-caching.md +1 -1
- package/llms/checks.md +1 -1
- package/llms/code-lints.md +1 -2
- package/llms/component-library-conventions.md +1 -1
- package/llms/components.md +5 -5
- package/llms/deprecated-lints.md +2 -7
- package/llms/effects.md +1 -1
- package/llms/errors.md +2 -2
- package/llms/events.md +1 -1
- package/llms/guards.md +1 -1
- package/llms/head.md +1 -1
- package/llms/hooks.md +2 -2
- package/llms/images.md +1 -1
- package/llms/island-and-form-lints.md +4 -2
- package/llms/island-sources.md +1 -1
- package/llms/islands-state-to-ids.md +2 -2
- package/llms/islands.md +8 -4
- package/llms/lints.md +1 -1
- package/llms/live-values.md +4 -4
- package/llms/local-collections.md +1 -1
- package/llms/locales.md +1 -1
- package/llms/mcp.md +2 -2
- package/llms/metrics.md +1 -1
- package/llms/navigation-from-code.md +7 -7
- package/llms/navigation.md +4 -2
- package/llms/prerendering.md +1 -0
- package/llms/production.md +2 -2
- package/llms/project-new-and-add.md +1 -1
- package/llms/project.md +4 -4
- package/llms/proxy-and-security.md +1 -1
- package/llms/queues.md +1 -1
- package/llms/rate-limits.md +4 -4
- package/llms/rendering.md +1 -1
- package/llms/server-islands.md +2 -2
- package/llms/server.md +1 -1
- package/llms/stores.md +1 -1
- package/llms/styles-and-assets.md +1 -1
- package/llms/templates-elements-slots-snippets.md +2 -2
- package/llms/testing-mount.md +49 -0
- package/llms/testing.md +4 -45
- package/llms/upgrading-1-105-config.md +13 -13
- package/llms/upgrading-archive.md +64 -74
- package/llms/upgrading.md +92 -70
- package/llms/whats-new.md +24 -0
- package/llms.txt +5 -6
- package/package.json +6 -10
- package/src/build/route-sizes.ts +2 -3
- package/src/build/variants.ts +132 -18
- package/src/check/browser-global-reads.ts +2 -2
- package/src/check/config-objects.ts +1 -1
- package/src/check/diagnose.ts +0 -22
- package/src/check/env-types.ts +1 -1
- package/src/check/export-homes.ts +1 -1
- package/src/check/guards.ts +3 -3
- package/src/check/index.ts +2 -7
- package/src/check/moved-keys.ts +1 -1
- package/src/check/project.ts +6 -7
- package/src/check/schema-builders.ts +125 -26
- package/src/check/shadow-types.ts +0 -86
- package/src/commands/check.ts +2 -2
- package/src/commands/env.ts +25 -3
- package/src/commands/upgrade.ts +2 -1
- package/src/compiler/allow-comments.ts +38 -2
- package/src/compiler/ast.ts +21 -19
- package/src/compiler/browser.ts +2 -14
- package/src/compiler/class-items.ts +16 -0
- package/src/compiler/codegen.ts +10 -10
- package/src/compiler/deprecated-library.ts +0 -12
- package/src/compiler/deprecated-lints-1-106.ts +2 -2
- package/src/compiler/deprecated-lints.ts +3 -495
- package/src/compiler/deprecated-ui-props.ts +5 -5
- package/src/compiler/errors.ts +2 -2
- package/src/compiler/fence-checks.ts +2 -121
- package/src/compiler/hand-parts.ts +83 -0
- package/src/compiler/helper-imports.ts +2 -2
- package/src/compiler/image-attributes.ts +1 -3
- package/src/compiler/index.ts +23 -23
- package/src/compiler/island-arguments.ts +17 -95
- package/src/compiler/island-cause.ts +7 -7
- package/src/compiler/island-declaration.ts +2 -8
- package/src/compiler/island-lints.ts +19 -0
- package/src/compiler/island-marker.ts +3 -3
- package/src/compiler/island-problems.ts +25 -0
- package/src/compiler/items.ts +12 -0
- package/src/compiler/jsx-class.ts +1 -25
- package/src/compiler/jsx.ts +7 -6
- package/src/compiler/kay-exports.ts +0 -2
- package/src/compiler/link-flags.ts +9 -38
- package/src/compiler/lints.ts +10 -18
- package/src/compiler/markup.ts +33 -41
- package/src/compiler/module-signals.ts +2 -2
- package/src/compiler/names.ts +1 -1
- package/src/compiler/page-settings.ts +11 -0
- package/src/compiler/parser.ts +6 -8
- package/src/compiler/plan.ts +1 -3
- package/src/compiler/removed-lints.ts +90 -0
- package/src/compiler/rewrite.ts +3 -18
- package/src/compiler/script-server.ts +8 -3
- package/src/compiler/signal-from-prop.ts +141 -0
- package/src/compiler/template-reads.ts +16 -0
- package/src/compiler/validate.ts +3 -8
- package/src/config-loader.ts +14 -4
- package/src/config-resolve.ts +18 -142
- package/src/config-shape.ts +44 -34
- package/src/config.ts +10 -114
- package/src/dev/preload.ts +4 -1
- package/src/lsp/server.ts +4 -0
- package/src/migrate/markup.ts +4 -1
- package/src/runtime/action-call.ts +0 -8
- package/src/runtime/action-encode.ts +26 -0
- package/src/runtime/action-error.ts +3 -11
- package/src/runtime/action-protection.ts +2 -2
- package/src/runtime/action-run.ts +2 -27
- package/src/runtime/action-shared.ts +14 -37
- package/src/runtime/action-stream.ts +0 -1
- package/src/runtime/action.ts +1 -1
- package/src/runtime/call-result.ts +2 -10
- package/src/runtime/checks.ts +25 -13
- package/src/runtime/client.ts +7 -11
- package/src/runtime/core.ts +5 -23
- package/src/runtime/dom.ts +1 -1
- package/src/runtime/html.ts +1 -1
- package/src/runtime/i18n.client.ts +1 -4
- package/src/runtime/i18n.server.ts +1 -4
- package/src/runtime/i18n.ts +3 -3
- package/src/runtime/image.ts +2 -19
- package/src/runtime/index.ts +3 -3
- package/src/runtime/island.server.ts +56 -13
- package/src/runtime/live-resource.server.ts +0 -1
- package/src/runtime/live-value.server.ts +2 -2
- package/src/runtime/live-value.shared.ts +7 -20
- package/src/runtime/live.ts +1 -12
- package/src/runtime/local-types.ts +1 -11
- package/src/runtime/local.ts +4 -14
- package/src/runtime/navigate-api.ts +2 -5
- package/src/runtime/navigate.ts +9 -0
- package/src/runtime/navigation-state.ts +0 -12
- package/src/runtime/navigation.ts +5 -1
- package/src/runtime/page-swap.ts +8 -8
- package/src/runtime/persist.ts +11 -3
- package/src/runtime/persisted.ts +4 -30
- package/src/runtime/presence.ts +6 -7
- package/src/runtime/query-param.ts +20 -12
- package/src/runtime/reactive.ts +3 -1
- package/src/runtime/refuse.ts +3 -17
- package/src/runtime/store-base.ts +4 -6
- package/src/runtime/swap-fetch.ts +1 -1
- package/src/runtime/swap-flight.ts +10 -10
- package/src/runtime/swap-kept.ts +69 -29
- package/src/runtime/swap-morph.ts +49 -9
- package/src/runtime/text-hash.ts +17 -0
- package/src/runtime/uid.server.ts +6 -4
- package/src/runtime/values.ts +52 -23
- package/src/runtime/with-query.ts +9 -0
- package/src/server/action-hooks.ts +8 -8
- package/src/server/actions.ts +13 -14
- package/src/server/api-modules.ts +2 -3
- package/src/server/app-stages.ts +15 -33
- package/src/server/app.ts +10 -5
- package/src/server/auth-mails.ts +0 -2
- package/src/server/env-state.ts +40 -10
- package/src/server/flash.ts +1 -1
- package/src/server/guard-requirement.ts +4 -4
- package/src/server/image.ts +2 -2
- package/src/server/index.ts +0 -2
- package/src/server/job-context.ts +3 -3
- package/src/server/jobs-page.ts +1 -1
- package/src/server/jobs.ts +5 -9
- package/src/server/kept-exports.ts +0 -2
- package/src/server/kv.ts +11 -14
- package/src/server/library.ts +1 -3
- package/src/server/live.ts +2 -2
- package/src/server/mcp.ts +3 -9
- package/src/server/metrics.ts +2 -4
- package/src/server/page-settings.ts +10 -19
- package/src/server/prerender.ts +19 -2
- package/src/server/protection.ts +15 -18
- package/src/server/queue.ts +3 -6
- package/src/server/rate-limit.ts +0 -3
- package/src/server/render-document.ts +9 -7
- package/src/server/render.ts +1 -1
- package/src/server/routes.ts +7 -3
- package/src/server/scope.ts +3 -2
- package/src/server/session.ts +5 -6
- package/src/server/setup.ts +1 -1
- package/src/server/signals.ts +17 -7
- package/src/server/signed.ts +1 -3
- package/src/server/source.ts +20 -4
- package/src/server/speculation.ts +1 -1
- package/src/server/storage.ts +3 -8
- package/src/server/validate.ts +1 -1
- package/src/server/vitals.ts +1 -3
- package/src/server/work-scope.ts +2 -4
- package/src/server/work.ts +1 -1
- package/src/server/workflow.ts +1 -1
- package/src/test/index.ts +2 -1
- package/src/test/site-actions.ts +16 -6
- package/src/test/site-keys.ts +10 -15
- package/src/test/site-socket.ts +1 -2
- package/src/test/site-types.ts +0 -8
- package/types/build/route-sizes.d.ts.map +1 -1
- package/types/build/variants.d.ts +9 -1
- package/types/build/variants.d.ts.map +1 -1
- package/types/check/diagnose.d.ts.map +1 -1
- package/types/check/index.d.ts +1 -2
- package/types/check/index.d.ts.map +1 -1
- package/types/check/project.d.ts.map +1 -1
- package/types/check/schema-builders.d.ts.map +1 -1
- package/types/check/shadow-types.d.ts.map +1 -1
- package/types/commands/env.d.ts.map +1 -1
- package/types/commands/upgrade.d.ts.map +1 -1
- package/types/compiler/allow-comments.d.ts +2 -0
- package/types/compiler/allow-comments.d.ts.map +1 -1
- package/types/compiler/ast.d.ts +1 -2
- package/types/compiler/ast.d.ts.map +1 -1
- package/types/compiler/browser.d.ts.map +1 -1
- package/types/compiler/class-items.d.ts +7 -0
- package/types/compiler/class-items.d.ts.map +1 -0
- package/types/compiler/deprecated-library.d.ts.map +1 -1
- package/types/compiler/deprecated-lints-1-106.d.ts +2 -2
- package/types/compiler/deprecated-lints-1-106.d.ts.map +1 -1
- package/types/compiler/deprecated-lints.d.ts +2 -553
- package/types/compiler/deprecated-lints.d.ts.map +1 -1
- package/types/compiler/deprecated-ui-props.d.ts +1 -8
- package/types/compiler/deprecated-ui-props.d.ts.map +1 -1
- package/types/compiler/errors.d.ts +2 -2
- package/types/compiler/errors.d.ts.map +1 -1
- package/types/compiler/fence-checks.d.ts +0 -1
- package/types/compiler/fence-checks.d.ts.map +1 -1
- package/types/compiler/hand-parts.d.ts +10 -0
- package/types/compiler/hand-parts.d.ts.map +1 -0
- package/types/compiler/image-attributes.d.ts +0 -1
- package/types/compiler/image-attributes.d.ts.map +1 -1
- package/types/compiler/index.d.ts.map +1 -1
- package/types/compiler/island-arguments.d.ts +7 -11
- package/types/compiler/island-arguments.d.ts.map +1 -1
- package/types/compiler/island-cause.d.ts +1 -1
- package/types/compiler/island-cause.d.ts.map +1 -1
- package/types/compiler/island-declaration.d.ts +1 -3
- package/types/compiler/island-declaration.d.ts.map +1 -1
- package/types/compiler/island-lints.d.ts +17 -0
- package/types/compiler/island-lints.d.ts.map +1 -0
- package/types/compiler/island-problems.d.ts +7 -0
- package/types/compiler/island-problems.d.ts.map +1 -0
- package/types/compiler/items.d.ts +1 -0
- package/types/compiler/items.d.ts.map +1 -1
- package/types/compiler/jsx-class.d.ts +1 -2
- package/types/compiler/jsx-class.d.ts.map +1 -1
- package/types/compiler/jsx.d.ts.map +1 -1
- package/types/compiler/kay-exports.d.ts.map +1 -1
- package/types/compiler/link-flags.d.ts +0 -6
- package/types/compiler/link-flags.d.ts.map +1 -1
- package/types/compiler/lints.d.ts +21 -566
- package/types/compiler/lints.d.ts.map +1 -1
- package/types/compiler/markup.d.ts +1 -1
- package/types/compiler/markup.d.ts.map +1 -1
- package/types/compiler/module-signals.d.ts.map +1 -1
- package/types/compiler/names.d.ts.map +1 -1
- package/types/compiler/page-settings.d.ts +4 -0
- package/types/compiler/page-settings.d.ts.map +1 -1
- package/types/compiler/parser.d.ts.map +1 -1
- package/types/compiler/plan.d.ts.map +1 -1
- package/types/compiler/removed-lints.d.ts +3 -0
- package/types/compiler/removed-lints.d.ts.map +1 -0
- package/types/compiler/script-server.d.ts.map +1 -1
- package/types/compiler/signal-from-prop.d.ts +4 -0
- package/types/compiler/signal-from-prop.d.ts.map +1 -0
- package/types/compiler/template-reads.d.ts +1 -0
- package/types/compiler/template-reads.d.ts.map +1 -1
- package/types/compiler/validate.d.ts.map +1 -1
- package/types/config-loader.d.ts.map +1 -1
- package/types/config-resolve.d.ts.map +1 -1
- package/types/config-shape.d.ts +1 -1
- package/types/config-shape.d.ts.map +1 -1
- package/types/config.d.ts +5 -105
- package/types/config.d.ts.map +1 -1
- package/types/dev/preload.d.ts.map +1 -1
- package/types/lsp/server.d.ts.map +1 -1
- package/types/migrate/markup.d.ts.map +1 -1
- package/types/runtime/action-call.d.ts.map +1 -1
- package/types/runtime/action-encode.d.ts +1 -0
- package/types/runtime/action-encode.d.ts.map +1 -1
- package/types/runtime/action-error.d.ts +1 -2
- package/types/runtime/action-error.d.ts.map +1 -1
- package/types/runtime/action-run.d.ts.map +1 -1
- package/types/runtime/action-shared.d.ts +1 -27
- package/types/runtime/action-shared.d.ts.map +1 -1
- package/types/runtime/action-stream.d.ts.map +1 -1
- package/types/runtime/action.d.ts +1 -1
- package/types/runtime/action.d.ts.map +1 -1
- package/types/runtime/call-result.d.ts +0 -10
- package/types/runtime/call-result.d.ts.map +1 -1
- package/types/runtime/checks.d.ts +14 -11
- package/types/runtime/checks.d.ts.map +1 -1
- package/types/runtime/client.d.ts.map +1 -1
- package/types/runtime/core.d.ts +2 -20
- package/types/runtime/core.d.ts.map +1 -1
- package/types/runtime/dom.d.ts +1 -1
- package/types/runtime/dom.d.ts.map +1 -1
- package/types/runtime/html.d.ts +1 -1
- package/types/runtime/html.d.ts.map +1 -1
- package/types/runtime/i18n.client.d.ts +0 -1
- package/types/runtime/i18n.client.d.ts.map +1 -1
- package/types/runtime/i18n.d.ts +1 -1
- package/types/runtime/i18n.d.ts.map +1 -1
- package/types/runtime/i18n.server.d.ts +0 -1
- package/types/runtime/i18n.server.d.ts.map +1 -1
- package/types/runtime/image.d.ts.map +1 -1
- package/types/runtime/index.d.ts +3 -3
- package/types/runtime/index.d.ts.map +1 -1
- package/types/runtime/island.server.d.ts +2 -0
- package/types/runtime/island.server.d.ts.map +1 -1
- package/types/runtime/live-resource.server.d.ts.map +1 -1
- package/types/runtime/live-value.shared.d.ts +7 -15
- package/types/runtime/live-value.shared.d.ts.map +1 -1
- package/types/runtime/live.d.ts +0 -11
- package/types/runtime/live.d.ts.map +1 -1
- package/types/runtime/local-types.d.ts +0 -14
- package/types/runtime/local-types.d.ts.map +1 -1
- package/types/runtime/navigate-api.d.ts +0 -4
- package/types/runtime/navigate-api.d.ts.map +1 -1
- package/types/runtime/navigate.d.ts.map +1 -1
- package/types/runtime/navigation-state.d.ts +0 -4
- package/types/runtime/navigation-state.d.ts.map +1 -1
- package/types/runtime/navigation.d.ts +2 -0
- package/types/runtime/navigation.d.ts.map +1 -1
- package/types/runtime/page-swap.d.ts.map +1 -1
- package/types/runtime/persist.d.ts +1 -0
- package/types/runtime/persist.d.ts.map +1 -1
- package/types/runtime/persisted.d.ts +0 -15
- package/types/runtime/persisted.d.ts.map +1 -1
- package/types/runtime/presence.d.ts +0 -2
- package/types/runtime/presence.d.ts.map +1 -1
- package/types/runtime/query-param.d.ts.map +1 -1
- package/types/runtime/reactive.d.ts +2 -1
- package/types/runtime/reactive.d.ts.map +1 -1
- package/types/runtime/refuse.d.ts +0 -7
- package/types/runtime/refuse.d.ts.map +1 -1
- package/types/runtime/store-base.d.ts +1 -2
- package/types/runtime/store-base.d.ts.map +1 -1
- package/types/runtime/swap-flight.d.ts +1 -1
- package/types/runtime/swap-flight.d.ts.map +1 -1
- package/types/runtime/swap-kept.d.ts.map +1 -1
- package/types/runtime/swap-morph.d.ts.map +1 -1
- package/types/runtime/text-hash.d.ts +2 -0
- package/types/runtime/text-hash.d.ts.map +1 -0
- package/types/runtime/uid.server.d.ts.map +1 -1
- package/types/runtime/values.d.ts +6 -1
- package/types/runtime/values.d.ts.map +1 -1
- package/types/runtime/with-query.d.ts +2 -0
- package/types/runtime/with-query.d.ts.map +1 -1
- package/types/server/action-hooks.d.ts +4 -4
- package/types/server/action-hooks.d.ts.map +1 -1
- package/types/server/actions.d.ts.map +1 -1
- package/types/server/api-modules.d.ts +0 -1
- package/types/server/api-modules.d.ts.map +1 -1
- package/types/server/app-stages.d.ts +5 -13
- package/types/server/app-stages.d.ts.map +1 -1
- package/types/server/app.d.ts +3 -8
- package/types/server/app.d.ts.map +1 -1
- package/types/server/auth-mails.d.ts +0 -5
- package/types/server/auth-mails.d.ts.map +1 -1
- package/types/server/env-state.d.ts +1 -0
- package/types/server/env-state.d.ts.map +1 -1
- package/types/server/guard-requirement.d.ts +0 -1
- package/types/server/guard-requirement.d.ts.map +1 -1
- package/types/server/image.d.ts +0 -1
- package/types/server/image.d.ts.map +1 -1
- package/types/server/index.d.ts +0 -2
- package/types/server/index.d.ts.map +1 -1
- package/types/server/job-context.d.ts +1 -1
- package/types/server/job-context.d.ts.map +1 -1
- package/types/server/jobs.d.ts +0 -4
- package/types/server/jobs.d.ts.map +1 -1
- package/types/server/kept-exports.d.ts.map +1 -1
- package/types/server/kv.d.ts +4 -4
- package/types/server/kv.d.ts.map +1 -1
- package/types/server/library.d.ts +1 -3
- package/types/server/library.d.ts.map +1 -1
- package/types/server/mcp.d.ts +0 -1
- package/types/server/mcp.d.ts.map +1 -1
- package/types/server/metrics.d.ts +0 -5
- package/types/server/metrics.d.ts.map +1 -1
- package/types/server/page-settings.d.ts +3 -3
- package/types/server/page-settings.d.ts.map +1 -1
- package/types/server/prerender.d.ts.map +1 -1
- package/types/server/protection.d.ts +6 -6
- package/types/server/protection.d.ts.map +1 -1
- package/types/server/queue.d.ts +1 -3
- package/types/server/queue.d.ts.map +1 -1
- package/types/server/rate-limit.d.ts +0 -2
- package/types/server/rate-limit.d.ts.map +1 -1
- package/types/server/render-document.d.ts +1 -1
- package/types/server/render-document.d.ts.map +1 -1
- package/types/server/routes.d.ts +1 -1
- package/types/server/routes.d.ts.map +1 -1
- package/types/server/scope.d.ts.map +1 -1
- package/types/server/session.d.ts +1 -1
- package/types/server/session.d.ts.map +1 -1
- package/types/server/signals.d.ts.map +1 -1
- package/types/server/signed.d.ts +0 -2
- package/types/server/signed.d.ts.map +1 -1
- package/types/server/source.d.ts +1 -1
- package/types/server/source.d.ts.map +1 -1
- package/types/server/storage.d.ts +0 -4
- package/types/server/storage.d.ts.map +1 -1
- package/types/server/vitals.d.ts +0 -1
- package/types/server/vitals.d.ts.map +1 -1
- package/types/server/work-scope.d.ts +0 -2
- package/types/server/work-scope.d.ts.map +1 -1
- package/types/server/workflow.d.ts +1 -1
- package/types/server/workflow.d.ts.map +1 -1
- package/types/test/index.d.ts.map +1 -1
- package/types/test/site-actions.d.ts +1 -1
- package/types/test/site-actions.d.ts.map +1 -1
- package/types/test/site-keys.d.ts +1 -1
- package/types/test/site-keys.d.ts.map +1 -1
- package/types/test/site-socket.d.ts +1 -1
- package/types/test/site-socket.d.ts.map +1 -1
- package/types/test/site-types.d.ts +0 -8
- package/types/test/site-types.d.ts.map +1 -1
- package/llms/deprecated-lints-1-105-libraries.md +0 -32
- package/llms/deprecated-lints-1-105.md +0 -58
- package/src/check/action-readers.ts +0 -115
- package/src/check/action-type.ts +0 -44
- package/src/check/ai-language.ts +0 -56
- package/src/check/app-hooks.ts +0 -90
- package/src/check/auth-methods.ts +0 -85
- package/src/check/auth-rate-limits.ts +0 -99
- package/src/check/call-result.ts +0 -242
- package/src/check/client-keys.ts +0 -10
- package/src/check/cms-options.ts +0 -81
- package/src/check/config-groups.ts +0 -22
- package/src/check/config-switches.ts +0 -38
- package/src/check/context-import.ts +0 -51
- package/src/check/env-files.ts +0 -31
- package/src/check/format-duration.ts +0 -75
- package/src/check/guard-options.ts +0 -58
- package/src/check/handler-events.ts +0 -149
- package/src/check/hook-context.ts +0 -94
- package/src/check/hook-names.ts +0 -104
- package/src/check/i18n-keys.ts +0 -50
- package/src/check/images-keys.ts +0 -54
- package/src/check/job-shapes.ts +0 -273
- package/src/check/link-flag-tests.ts +0 -130
- package/src/check/live-api.ts +0 -137
- package/src/check/mail-api.ts +0 -67
- package/src/check/one-state-api.ts +0 -357
- package/src/check/pages-options.ts +0 -35
- package/src/check/rate-enforce.ts +0 -53
- package/src/check/refusal-calls.ts +0 -185
- package/src/check/retired-lints.ts +0 -49
- package/src/check/route-keys.ts +0 -166
- package/src/check/secret-keys.ts +0 -83
- package/src/check/socket-frames.ts +0 -102
- package/src/check/source-readers.ts +0 -257
- package/src/check/store-ms.ts +0 -72
- package/src/check/store-names.ts +0 -88
- package/src/check/test-helpers.ts +0 -98
- package/src/check/ttl-names.ts +0 -142
- package/src/compiler/deprecated-ai-labels.ts +0 -97
- package/src/compiler/deprecated-ai-links.ts +0 -63
- package/src/compiler/deprecated-allow.ts +0 -50
- package/src/compiler/deprecated-auth-lints.ts +0 -14
- package/src/compiler/deprecated-auth-signed.ts +0 -29
- package/src/compiler/deprecated-children.ts +0 -66
- package/src/compiler/deprecated-image.ts +0 -116
- package/src/compiler/deprecated-island.ts +0 -155
- package/src/compiler/deprecated-lints-1-105.ts +0 -41
- package/src/compiler/deprecated-page.ts +0 -125
- package/src/compiler/deprecated-parts.ts +0 -22
- package/src/compiler/deprecated-typed-lints.ts +0 -23
- package/src/compiler/deprecated-ui-callbacks.ts +0 -66
- package/src/compiler/deprecated-ui-input.ts +0 -97
- package/src/compiler/deprecated-ui-items.ts +0 -47
- package/src/compiler/old-parts.ts +0 -84
- package/src/runtime/mount.compat.ts +0 -8
- package/src/server/moved-exports.ts +0 -17
- package/types/check/action-readers.d.ts +0 -3
- package/types/check/action-readers.d.ts.map +0 -1
- package/types/check/action-type.d.ts +0 -3
- package/types/check/action-type.d.ts.map +0 -1
- package/types/check/ai-language.d.ts +0 -3
- package/types/check/ai-language.d.ts.map +0 -1
- package/types/check/app-hooks.d.ts +0 -3
- package/types/check/app-hooks.d.ts.map +0 -1
- package/types/check/auth-methods.d.ts +0 -3
- package/types/check/auth-methods.d.ts.map +0 -1
- package/types/check/auth-rate-limits.d.ts +0 -3
- package/types/check/auth-rate-limits.d.ts.map +0 -1
- package/types/check/call-result.d.ts +0 -7
- package/types/check/call-result.d.ts.map +0 -1
- package/types/check/client-keys.d.ts +0 -3
- package/types/check/client-keys.d.ts.map +0 -1
- package/types/check/cms-options.d.ts +0 -3
- package/types/check/cms-options.d.ts.map +0 -1
- package/types/check/config-groups.d.ts +0 -3
- package/types/check/config-groups.d.ts.map +0 -1
- package/types/check/config-switches.d.ts +0 -3
- package/types/check/config-switches.d.ts.map +0 -1
- package/types/check/context-import.d.ts +0 -3
- package/types/check/context-import.d.ts.map +0 -1
- package/types/check/env-files.d.ts +0 -3
- package/types/check/env-files.d.ts.map +0 -1
- package/types/check/format-duration.d.ts +0 -5
- package/types/check/format-duration.d.ts.map +0 -1
- package/types/check/guard-options.d.ts +0 -3
- package/types/check/guard-options.d.ts.map +0 -1
- package/types/check/handler-events.d.ts +0 -9
- package/types/check/handler-events.d.ts.map +0 -1
- package/types/check/hook-context.d.ts +0 -3
- package/types/check/hook-context.d.ts.map +0 -1
- package/types/check/hook-names.d.ts +0 -3
- package/types/check/hook-names.d.ts.map +0 -1
- package/types/check/i18n-keys.d.ts +0 -3
- package/types/check/i18n-keys.d.ts.map +0 -1
- package/types/check/images-keys.d.ts +0 -3
- package/types/check/images-keys.d.ts.map +0 -1
- package/types/check/job-shapes.d.ts +0 -6
- package/types/check/job-shapes.d.ts.map +0 -1
- package/types/check/link-flag-tests.d.ts +0 -4
- package/types/check/link-flag-tests.d.ts.map +0 -1
- package/types/check/live-api.d.ts +0 -3
- package/types/check/live-api.d.ts.map +0 -1
- package/types/check/mail-api.d.ts +0 -3
- package/types/check/mail-api.d.ts.map +0 -1
- package/types/check/one-state-api.d.ts +0 -9
- package/types/check/one-state-api.d.ts.map +0 -1
- package/types/check/pages-options.d.ts +0 -3
- package/types/check/pages-options.d.ts.map +0 -1
- package/types/check/rate-enforce.d.ts +0 -3
- package/types/check/rate-enforce.d.ts.map +0 -1
- package/types/check/refusal-calls.d.ts +0 -3
- package/types/check/refusal-calls.d.ts.map +0 -1
- package/types/check/retired-lints.d.ts +0 -3
- package/types/check/retired-lints.d.ts.map +0 -1
- package/types/check/route-keys.d.ts +0 -3
- package/types/check/route-keys.d.ts.map +0 -1
- package/types/check/secret-keys.d.ts +0 -3
- package/types/check/secret-keys.d.ts.map +0 -1
- package/types/check/socket-frames.d.ts +0 -3
- package/types/check/socket-frames.d.ts.map +0 -1
- package/types/check/source-readers.d.ts +0 -3
- package/types/check/source-readers.d.ts.map +0 -1
- package/types/check/store-ms.d.ts +0 -3
- package/types/check/store-ms.d.ts.map +0 -1
- package/types/check/store-names.d.ts +0 -3
- package/types/check/store-names.d.ts.map +0 -1
- package/types/check/test-helpers.d.ts +0 -3
- package/types/check/test-helpers.d.ts.map +0 -1
- package/types/check/ttl-names.d.ts +0 -3
- package/types/check/ttl-names.d.ts.map +0 -1
- package/types/compiler/deprecated-ai-labels.d.ts +0 -5
- package/types/compiler/deprecated-ai-labels.d.ts.map +0 -1
- package/types/compiler/deprecated-ai-links.d.ts +0 -5
- package/types/compiler/deprecated-ai-links.d.ts.map +0 -1
- package/types/compiler/deprecated-allow.d.ts +0 -5
- package/types/compiler/deprecated-allow.d.ts.map +0 -1
- package/types/compiler/deprecated-auth-lints.d.ts +0 -12
- package/types/compiler/deprecated-auth-lints.d.ts.map +0 -1
- package/types/compiler/deprecated-auth-signed.d.ts +0 -5
- package/types/compiler/deprecated-auth-signed.d.ts.map +0 -1
- package/types/compiler/deprecated-children.d.ts +0 -4
- package/types/compiler/deprecated-children.d.ts.map +0 -1
- package/types/compiler/deprecated-image.d.ts +0 -5
- package/types/compiler/deprecated-image.d.ts.map +0 -1
- package/types/compiler/deprecated-island.d.ts +0 -9
- package/types/compiler/deprecated-island.d.ts.map +0 -1
- package/types/compiler/deprecated-lints-1-105.d.ts +0 -39
- package/types/compiler/deprecated-lints-1-105.d.ts.map +0 -1
- package/types/compiler/deprecated-page.d.ts +0 -4
- package/types/compiler/deprecated-page.d.ts.map +0 -1
- package/types/compiler/deprecated-parts.d.ts +0 -3
- package/types/compiler/deprecated-parts.d.ts.map +0 -1
- package/types/compiler/deprecated-typed-lints.d.ts +0 -21
- package/types/compiler/deprecated-typed-lints.d.ts.map +0 -1
- package/types/compiler/deprecated-ui-callbacks.d.ts +0 -5
- package/types/compiler/deprecated-ui-callbacks.d.ts.map +0 -1
- package/types/compiler/deprecated-ui-input.d.ts +0 -5
- package/types/compiler/deprecated-ui-input.d.ts.map +0 -1
- package/types/compiler/deprecated-ui-items.d.ts +0 -5
- package/types/compiler/deprecated-ui-items.d.ts.map +0 -1
- package/types/compiler/old-parts.d.ts +0 -9
- package/types/compiler/old-parts.d.ts.map +0 -1
- package/types/runtime/mount.compat.d.ts +0 -7
- package/types/runtime/mount.compat.d.ts.map +0 -1
- package/types/server/moved-exports.d.ts +0 -12
- package/types/server/moved-exports.d.ts.map +0 -1
package/src/check/live-api.ts
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import type { Node, Program } from '../compiler/estree'
|
|
3
|
-
import type { Edit } from './renamed-exports'
|
|
4
|
-
import { lintLevel } from '../compiler/lints'
|
|
5
|
-
import { unwrapped } from '../compiler/object-literal'
|
|
6
|
-
import { importedName, importsOf, walk } from './ast'
|
|
7
|
-
import { bindings, boundOnce } from './bindings'
|
|
8
|
-
import { scan } from './renamed-exports'
|
|
9
|
-
|
|
10
|
-
type Kind = 'plain' | 'key' | 'user' | 'unknown'
|
|
11
|
-
|
|
12
|
-
const LIVE_CALL = /\blive\s*[(<]/
|
|
13
|
-
const PROJECT_SOURCE = /^(?:[./#~]|@\/)/
|
|
14
|
-
const SPECIAL = /[$.*+?^{}()|[\]\\]/g
|
|
15
|
-
|
|
16
|
-
// What a declaration `live(initial, options)` is: a value per key given a function of it or `key: true`, per user given `user: true`, and unknown when the options are no object written there.
|
|
17
|
-
function kindOf(call: Node): Kind {
|
|
18
|
-
if (call.type !== 'CallExpression')
|
|
19
|
-
return 'unknown'
|
|
20
|
-
|
|
21
|
-
const [initial, options] = call.arguments
|
|
22
|
-
|
|
23
|
-
if (options !== undefined && options.type !== 'ObjectExpression')
|
|
24
|
-
return 'unknown'
|
|
25
|
-
|
|
26
|
-
const flag = (name: string) => options?.type === 'ObjectExpression' && options.properties.some(property => property.type === 'Property' && !property.computed && property.key.type === 'Identifier' && property.key.name === name && property.value.type === 'Literal' && property.value.value === true)
|
|
27
|
-
|
|
28
|
-
if (flag('user'))
|
|
29
|
-
return 'user'
|
|
30
|
-
|
|
31
|
-
return flag('key') || initial?.type === 'ArrowFunctionExpression' || initial?.type === 'FunctionExpression' ? 'key' : 'plain'
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// The live values a program declares, by the name they are bound to once.
|
|
35
|
-
function declared(ast: Program): Map<string, Kind> {
|
|
36
|
-
const names = bindings(ast)
|
|
37
|
-
const known = boundOnce(ast, names, 'live')
|
|
38
|
-
const kinds = new Map<string, Kind>()
|
|
39
|
-
|
|
40
|
-
walk(ast, (node) => {
|
|
41
|
-
if (node.type === 'VariableDeclarator' && node.id.type === 'Identifier' && node.init && known.has(node.id.name))
|
|
42
|
-
kinds.set(node.id.name, kindOf(unwrapped(node.init)))
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
return kinds
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// The text of an argument as the property of an options object: `{ key }` for an identifier of that name.
|
|
49
|
-
function property(name: string, argument: Node, text: string): string {
|
|
50
|
-
return argument.type === 'Identifier' && argument.name === name ? name : `${name}: ${text.slice(argument.start, argument.end)}`
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Whether the second argument of a `set` is the options of the new form, an object holding only `field`.
|
|
54
|
-
function isOptions(argument: Node, field: string): boolean {
|
|
55
|
-
return argument.type === 'ObjectExpression' && argument.properties.length === 1 && argument.properties[0]!.type === 'Property' && !argument.properties[0]!.computed && argument.properties[0]!.key.type === 'Identifier' && argument.properties[0]!.key.name === field
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// What live values and `presence` take since 1.105: `set(next, { key })` and `set(next, { user })` in place of `set(key, next)`, and `presence({ room, member })` in place of `presence(room, member)`.
|
|
59
|
-
// A value is known by a name the file binds once to a `live()` call from `kay`, or imports under the name of a declaration of the project that every file agrees on, as `kay check` reads no types; `presence` is the one imported from `kay`.
|
|
60
|
-
export async function liveApi(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
61
|
-
if (lintLevel('deprecated-live-api', options.lints) === 'allow')
|
|
62
|
-
return []
|
|
63
|
-
|
|
64
|
-
// The kinds each declared name is given across the project, so an import of it is known.
|
|
65
|
-
const everywhere = new Map<string, Set<Kind>>()
|
|
66
|
-
|
|
67
|
-
await scan(root, options, 'deprecated-live-api', LIVE_CALL, ({ parsed }) => {
|
|
68
|
-
for (const { ast } of parsed) {
|
|
69
|
-
for (const [name, kind] of declared(ast))
|
|
70
|
-
(everywhere.get(name) ?? everywhere.set(name, new Set()).get(name)!).add(kind)
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
// A file is read when it names a live value declared in the project, whatever else it holds, as `live` is written where it is declared.
|
|
75
|
-
const named = [...everywhere.keys()].map(name => name.replace(SPECIAL, String.raw`\$&`))
|
|
76
|
-
const needle = new RegExp(`\\b(?:live|presence${named.map(name => `|${name}`).join('')})\\b`)
|
|
77
|
-
|
|
78
|
-
return scan(root, options, 'deprecated-live-api', needle, ({ parsed, report }) => {
|
|
79
|
-
for (const { ast, base, text } of parsed) {
|
|
80
|
-
const receivers = declared(ast)
|
|
81
|
-
const names = bindings(ast)
|
|
82
|
-
|
|
83
|
-
for (const statement of ast.body) {
|
|
84
|
-
if (statement.type !== 'ImportDeclaration' || statement.importKind === 'type' || !PROJECT_SOURCE.test(statement.source.value))
|
|
85
|
-
continue
|
|
86
|
-
|
|
87
|
-
for (const specifier of statement.specifiers) {
|
|
88
|
-
const kinds = specifier.type === 'ImportSpecifier' && specifier.importKind !== 'type' ? everywhere.get(importedName(specifier)) : undefined
|
|
89
|
-
|
|
90
|
-
if (kinds?.size === 1 && names.get(specifier.local.name) === 1)
|
|
91
|
-
receivers.set(specifier.local.name, [...kinds][0]!)
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const presences = importsOf(ast, from => from === 'kay', 'presence').locals
|
|
96
|
-
|
|
97
|
-
walk(ast, (node) => {
|
|
98
|
-
if (node.type !== 'CallExpression' || node.arguments.some(argument => argument.type === 'SpreadElement'))
|
|
99
|
-
return
|
|
100
|
-
|
|
101
|
-
const { callee, arguments: args } = node
|
|
102
|
-
|
|
103
|
-
if (callee.type === 'MemberExpression' && !callee.computed && callee.object.type === 'Identifier' && callee.property.type === 'Identifier' && callee.property.name === 'set' && args.length === 2) {
|
|
104
|
-
const kind = receivers.get(callee.object.name)
|
|
105
|
-
|
|
106
|
-
if ((kind !== 'key' && kind !== 'user') || isOptions(args[1]!, kind))
|
|
107
|
-
return
|
|
108
|
-
|
|
109
|
-
const [first, second] = args as [Node, Node]
|
|
110
|
-
|
|
111
|
-
report(base + callee.property.start, base + callee.property.end, `\`${callee.object.name}.set(${kind}, next)\` of a live value per ${kind} is \`set(next, { ${kind} })\` since 1.105, as one \`set\` writes every live value; the old order works until 1.108`, `write \`set(next, { ${kind} })\``, first.type === 'SequenceExpression' || second.type === 'SequenceExpression' ? null : [{ start: base + first.start, end: base + second.end, text: `${text.slice(second.start, second.end)}, { ${property(kind, first, text)} }` }])
|
|
112
|
-
|
|
113
|
-
return
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (callee.type !== 'Identifier' || !presences.has(callee.name) || args.length === 0 || args[0]!.type === 'ObjectExpression')
|
|
117
|
-
return
|
|
118
|
-
|
|
119
|
-
const [room, member, extra] = args as [Node, Node | undefined, Node | undefined]
|
|
120
|
-
const parts = [property('room', room, text), ...member ? [property('member', member, text)] : []]
|
|
121
|
-
let fix: Edit[] | null = null
|
|
122
|
-
|
|
123
|
-
// A lone argument that is no string was the options of the old form, as `presence(options)`.
|
|
124
|
-
const written = args.length > 1 || room.type === 'Literal' || room.type === 'TemplateLiteral'
|
|
125
|
-
|
|
126
|
-
if (written && !args.some(argument => argument.type === 'SequenceExpression') && (extra === undefined || extra.type === 'ObjectExpression')) {
|
|
127
|
-
if (extra !== undefined && extra.properties.length > 0)
|
|
128
|
-
parts.push(text.slice(extra.properties[0]!.start, extra.properties.at(-1)!.end))
|
|
129
|
-
|
|
130
|
-
fix = [{ start: base + room.start, end: base + (extra ?? member ?? room).end, text: `{ ${parts.join(', ')} }` }]
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
report(base + callee.start, base + callee.end, '`presence(room, member)` is `presence({ room, member })` since 1.105, as every kay call with options takes one object; the old form works until 1.108', 'write `presence({ room, member })`', fix)
|
|
134
|
-
})
|
|
135
|
-
}
|
|
136
|
-
})
|
|
137
|
-
}
|
package/src/check/mail-api.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import { existsSync, readFileSync } from 'node:fs'
|
|
3
|
-
import { join } from 'node:path'
|
|
4
|
-
import { lintLevel } from '../compiler/lints'
|
|
5
|
-
import { importedName } from './ast'
|
|
6
|
-
import { scan } from './renamed-exports'
|
|
7
|
-
|
|
8
|
-
const MAIL_FORM = '@kayjs/mail/subscribe-form.kay'
|
|
9
|
-
const UI_FORM = '@kayjs/ui/subscribe-form.kay'
|
|
10
|
-
const SEND_NAMES = new Set(['send', 'enqueue', 'registeredMailer'])
|
|
11
|
-
const NEEDLE = /@kayjs\/mail/
|
|
12
|
-
|
|
13
|
-
// Whether the project's manifest lists kayjs-ui, which the moved form comes from.
|
|
14
|
-
function hasUi(root: string): boolean {
|
|
15
|
-
const manifest = join(root, 'package.json')
|
|
16
|
-
|
|
17
|
-
return existsSync(manifest) && readFileSync(manifest, 'utf8').includes('"@kayjs/ui"')
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// The old forms of kayjs-mail's API: its own `SubscribeForm`, which kayjs-ui's replaces since 1.105 (the same props, themed), and the `send`, `enqueue` and `registeredMailer` that reach the latest started site's mailer, `ctx.locals.mail` being the request's own.
|
|
21
|
-
export async function mailApi(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
22
|
-
const formLevel = lintLevel('deprecated-mail-form', options.lints)
|
|
23
|
-
const sendLevel = lintLevel('deprecated-mail-send', options.lints)
|
|
24
|
-
|
|
25
|
-
if (formLevel === 'allow' && sendLevel === 'allow')
|
|
26
|
-
return []
|
|
27
|
-
|
|
28
|
-
const ui = hasUi(root)
|
|
29
|
-
const found: CheckDiagnostic[] = []
|
|
30
|
-
|
|
31
|
-
if (formLevel !== 'allow') {
|
|
32
|
-
found.push(...await scan(root, options, 'deprecated-mail-form', NEEDLE, ({ parsed, report }) => {
|
|
33
|
-
for (const { ast, base } of parsed) {
|
|
34
|
-
for (const statement of ast.body) {
|
|
35
|
-
if (statement.type !== 'ImportDeclaration' || statement.source.value !== MAIL_FORM)
|
|
36
|
-
continue
|
|
37
|
-
|
|
38
|
-
const { start, end } = statement.source
|
|
39
|
-
|
|
40
|
-
report(base + start, base + end, `kayjs-mail's \`SubscribeForm\` is kayjs-ui's since 1.105, which takes the same props and reads the list's \`privacy\` from its action`, `import it from \`${UI_FORM}\``, [{ start: base + start, end: base + end, text: `'${UI_FORM}'` }], ui)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}))
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (sendLevel !== 'allow') {
|
|
47
|
-
found.push(...await scan(root, options, 'deprecated-mail-send', NEEDLE, ({ parsed, report }) => {
|
|
48
|
-
for (const { ast, base } of parsed) {
|
|
49
|
-
for (const statement of ast.body) {
|
|
50
|
-
if (statement.type !== 'ImportDeclaration' || statement.importKind === 'type' || statement.source.value !== '@kayjs/mail')
|
|
51
|
-
continue
|
|
52
|
-
|
|
53
|
-
for (const specifier of statement.specifiers) {
|
|
54
|
-
if (specifier.type !== 'ImportSpecifier' || specifier.importKind === 'type' || !SEND_NAMES.has(importedName(specifier)))
|
|
55
|
-
continue
|
|
56
|
-
|
|
57
|
-
const name = importedName(specifier)
|
|
58
|
-
|
|
59
|
-
report(base + specifier.start, base + specifier.end, name === 'registeredMailer' ? '`registeredMailer()` is gone since 1.105: it answered the latest site started, which is none of a request\'s' : `\`${name}()\` of kayjs-mail sends through the latest site started, which is none of a request's, since 1.105: \`ctx.locals.mail\` is the request's own`, 'write `ctx.locals.mail.send(...)` or `.enqueue(...)` in a page, an action or a guard, and the mailer of `src/mail.ts` in a job or a script', null)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}))
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return found
|
|
67
|
-
}
|
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import type { Node, NodeOfType, Program } from '../compiler/estree'
|
|
3
|
-
import type { LintName } from '../compiler/lints'
|
|
4
|
-
import type { Edit, Found } from './renamed-exports'
|
|
5
|
-
import { lintLevel } from '../compiler/lints'
|
|
6
|
-
import { importedName, importsOf, walk } from './ast'
|
|
7
|
-
import { mentions, scan } from './renamed-exports'
|
|
8
|
-
|
|
9
|
-
const FROM_KAY = (source: string) => source === 'kay'
|
|
10
|
-
const COMMENT = /\/[*/]/
|
|
11
|
-
const PERSISTED = /\bpersisted\b/
|
|
12
|
-
const NAVIGATE = /\bnavigate\b/
|
|
13
|
-
const NAVIGATION_HOOK = /\bon(?:Before)?Navigate\b/
|
|
14
|
-
const LISTEN = /\blisten\b/
|
|
15
|
-
const MOVED_SOURCE = /kay\/(?:mount|server)/
|
|
16
|
-
const TRAILING_COMMA = /,$/
|
|
17
|
-
|
|
18
|
-
// What a rewritten `queryParam` call keeps of the old call's third argument: its members, or the whole value spread when it is not a plain object.
|
|
19
|
-
function keptSettings(source: string, base: number, settings: Node | undefined, inner: string | undefined): string {
|
|
20
|
-
if (settings === undefined)
|
|
21
|
-
return ''
|
|
22
|
-
|
|
23
|
-
if (inner === undefined)
|
|
24
|
-
return `, ...${source.slice(base + settings.start, base + settings.end)}`
|
|
25
|
-
|
|
26
|
-
return inner === '' ? '' : `, ${inner}`
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function keyName(key: Node): unknown {
|
|
30
|
-
if (key.type === 'Identifier')
|
|
31
|
-
return key.name
|
|
32
|
-
|
|
33
|
-
return key.type === 'Literal' ? key.value : undefined
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
type Call = NodeOfType<'CallExpression'>
|
|
37
|
-
type ImportDeclaration = NodeOfType<'ImportDeclaration'>
|
|
38
|
-
|
|
39
|
-
// Whether `callee` is `name` imported from `kay` as written (`persisted`) or read off `import * as kay` (`kay.persisted`).
|
|
40
|
-
function calls(ast: Program, name: string): (callee: Node) => boolean {
|
|
41
|
-
const { locals, namespaces } = importsOf(ast, FROM_KAY, name)
|
|
42
|
-
|
|
43
|
-
return callee => callee.type === 'Identifier'
|
|
44
|
-
? locals.has(callee.name)
|
|
45
|
-
: callee.type === 'MemberExpression' && !callee.computed && callee.object.type === 'Identifier' && namespaces.has(callee.object.name) && callee.property.type === 'Identifier' && callee.property.name === name
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Whether `callee` is `<name>.<member>` of `name` imported from `kay`.
|
|
49
|
-
function entryCalls(ast: Program, name: string, member: string): (callee: Node) => boolean {
|
|
50
|
-
const { locals, namespaces } = importsOf(ast, FROM_KAY, name)
|
|
51
|
-
|
|
52
|
-
return callee => callee.type === 'MemberExpression' && !callee.computed && callee.property.type === 'Identifier' && callee.property.name === member
|
|
53
|
-
&& (callee.object.type === 'Identifier' ? locals.has(callee.object.name) : callee.object.type === 'MemberExpression' && !callee.object.computed && callee.object.object.type === 'Identifier' && namespaces.has(callee.object.object.name) && callee.object.property.type === 'Identifier' && callee.object.property.name === name)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Calls `visit` on each call whose callee `is` accepts.
|
|
57
|
-
function eachCall(ast: Program, is: (callee: Node) => boolean, visit: (call: Call) => void): void {
|
|
58
|
-
walk(ast, (node) => {
|
|
59
|
-
if (node.type === 'CallExpression' && is(node.callee))
|
|
60
|
-
visit(node)
|
|
61
|
-
})
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// How many identifiers named `name` the statements hold, imports left out: a rewrite of the calls alone would leave the others behind.
|
|
65
|
-
function reads(ast: Program, name: string): number {
|
|
66
|
-
let found = 0
|
|
67
|
-
|
|
68
|
-
for (const statement of ast.body) {
|
|
69
|
-
if (statement.type === 'ImportDeclaration')
|
|
70
|
-
continue
|
|
71
|
-
|
|
72
|
-
walk(statement, (node) => {
|
|
73
|
-
if (node.type === 'Identifier' && node.name === name)
|
|
74
|
-
found++
|
|
75
|
-
})
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return found
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// The import of `kay` that names `drops`, rebuilt without them and with `add`, which a file already importing it keeps as it is; a declaration of anything but plain named specifiers, an alias or a comment in the braces leaves it to the app (`null`).
|
|
82
|
-
function importEdits(ast: Program, base: number, source: string, drops: readonly string[], add: string): Edit[] | null {
|
|
83
|
-
const declaration = ast.body.find((statement): statement is ImportDeclaration => statement.type === 'ImportDeclaration' && FROM_KAY(statement.source.value) && statement.importKind !== 'type' && statement.specifiers.some(specifier => specifier.type === 'ImportSpecifier' && (drops.length === 0 || drops.includes(importedName(specifier)))))
|
|
84
|
-
|
|
85
|
-
if (!declaration || declaration.specifiers.some(specifier => specifier.type !== 'ImportSpecifier' || specifier.importKind === 'type' || specifier.local.name !== importedName(specifier)))
|
|
86
|
-
return null
|
|
87
|
-
|
|
88
|
-
const specifiers = declaration.specifiers as NodeOfType<'ImportSpecifier'>[]
|
|
89
|
-
const texts = specifiers.filter(specifier => !drops.includes(importedName(specifier))).map(specifier => source.slice(base + specifier.start, base + specifier.end))
|
|
90
|
-
const imported = ast.body.some(statement => statement.type === 'ImportDeclaration' && FROM_KAY(statement.source.value) && statement.importKind !== 'type' && statement.specifiers.some(specifier => specifier.type === 'ImportSpecifier' && importedName(specifier) === add))
|
|
91
|
-
const first = specifiers[0]!
|
|
92
|
-
const last = specifiers.at(-1)!
|
|
93
|
-
|
|
94
|
-
if (COMMENT.test(source.slice(base + first.start, base + last.end)))
|
|
95
|
-
return null
|
|
96
|
-
|
|
97
|
-
if (!imported)
|
|
98
|
-
texts.push(add)
|
|
99
|
-
|
|
100
|
-
if (texts.length === 0) {
|
|
101
|
-
const after = source[base + declaration.end] === '\n' ? 1 : 0
|
|
102
|
-
|
|
103
|
-
return [{ start: base + declaration.start, end: base + declaration.end + after, text: '' }]
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return [{ start: base + first.start, end: base + last.end, text: texts.join(', ') }]
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Runs `visit` over the parsed spans of the files whose text matches `needle`, when the lint is not allowed.
|
|
110
|
-
async function scanned(root: string, options: CheckOptions, lint: LintName, needle: RegExp, visit: (found: Found) => void): Promise<CheckDiagnostic[]> {
|
|
111
|
-
return lintLevel(lint, options.lints) === 'allow' ? [] : scan(root, options, lint, needle, visit)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// `persisted(name, value)`, a cookie since it began: `persisted.cookie(name, value)` names it, as `persisted.local()` and `persisted.session()` name theirs.
|
|
115
|
-
// A call with a `storage` option, which 1.105 no longer takes, is reported with no fix.
|
|
116
|
-
export async function persistedCall(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
117
|
-
return scanned(root, options, 'deprecated-persisted-call', PERSISTED, ({ parsed, report }) => {
|
|
118
|
-
for (const { ast, base } of parsed) {
|
|
119
|
-
eachCall(ast, calls(ast, 'persisted'), (call) => {
|
|
120
|
-
const settings = call.arguments[2]
|
|
121
|
-
const storage = settings?.type === 'ObjectExpression' && settings.properties.some(property => property.type === 'Property' && !property.computed && keyName(property.key) === 'storage')
|
|
122
|
-
|
|
123
|
-
report(base + call.callee.start, base + call.callee.end, storage ? '`storage` of `persisted()` is removed since 1.105: each storage has its own entry' : '`persisted()` keeps a cookie without saying so since 1.105: `persisted.cookie()` names it', storage ? 'call `persisted.local()`, `persisted.session()` or `queryParam()`, or `persisted.cookie()` for a cookie' : 'call `persisted.cookie()`', storage ? null : [{ start: base + call.callee.end, end: base + call.callee.end, text: '.cookie' }])
|
|
124
|
-
})
|
|
125
|
-
}
|
|
126
|
-
})
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const QUERY_MEMBER = /\.persisted\.query$/
|
|
130
|
-
|
|
131
|
-
// Whether `call` reads `persisted.query` off a namespace import (`kay.persisted.query`).
|
|
132
|
-
const spelled = (call: Call): boolean => call.callee.type === 'MemberExpression' && call.callee.object.type === 'MemberExpression'
|
|
133
|
-
|
|
134
|
-
// `persisted.query(name, value, options)`, the signal of a query param twice: `queryParam(name, { default: value, ...options })` is the one.
|
|
135
|
-
export async function persistedQuery(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
136
|
-
return scanned(root, options, 'deprecated-persisted-query', PERSISTED, ({ source, parsed, unparsed, report }) => {
|
|
137
|
-
for (const { ast, base } of parsed) {
|
|
138
|
-
const hits: Call[] = []
|
|
139
|
-
|
|
140
|
-
eachCall(ast, entryCalls(ast, 'persisted', 'query'), call => hits.push(call))
|
|
141
|
-
|
|
142
|
-
if (hits.length === 0)
|
|
143
|
-
continue
|
|
144
|
-
|
|
145
|
-
// `persisted` goes from the import when every use of it is such a call, and is kept otherwise.
|
|
146
|
-
const { locals } = importsOf(ast, FROM_KAY, 'persisted')
|
|
147
|
-
const others = [...locals].some(local => reads(ast, local) > hits.length || new RegExp(`\\b${local}\\b`).test(unparsed))
|
|
148
|
-
const named = hits.filter(call => !spelled(call))
|
|
149
|
-
const planned = hits.map(call => ({ call, own: queryEdits(source, base, call) }))
|
|
150
|
-
const everyFixable = planned.every(({ own }) => own !== null)
|
|
151
|
-
const imports = named.length === 0 ? [] : importEdits(ast, base, source, others || !everyFixable ? [] : ['persisted'], 'queryParam')
|
|
152
|
-
// Each diagnostic carries every call's rewrite and the import's, so the first fix applied does it all and the others overlap it.
|
|
153
|
-
const all = imports ? [...planned.flatMap(({ own }) => own ?? []), ...imports] : null
|
|
154
|
-
|
|
155
|
-
for (const { call, own } of planned)
|
|
156
|
-
report(base + call.callee.start, base + call.callee.end, '`persisted.query()` is deprecated since 1.105: `queryParam()` is the one signal of a query param', 'call `queryParam(name, { default })`', own && all ? all : null)
|
|
157
|
-
}
|
|
158
|
-
})
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// The edits that make `call`, a `persisted.query(name, value, options)`, a `queryParam(name, { default: value, ...options })`; `null` when the call cannot be rewritten without risk: a spread, a comment in it, or an `equals` option `queryParam` does not take.
|
|
162
|
-
function queryEdits(source: string, base: number, call: Call): Edit[] | null {
|
|
163
|
-
const [name, value, settings] = call.arguments
|
|
164
|
-
const plain = call.arguments.length >= 2 && call.arguments.length <= 3 && !call.arguments.some(argument => argument.type === 'SpreadElement')
|
|
165
|
-
const inner = settings?.type === 'ObjectExpression' && !settings.properties.some(property => property.type === 'SpreadElement') ? source.slice(base + settings.start + 1, base + settings.end - 1).trim().replace(TRAILING_COMMA, '') : undefined
|
|
166
|
-
const kept = keptSettings(source, base, settings, inner)
|
|
167
|
-
const text = plain ? `, { default: ${source.slice(base + value!.start, base + value!.end)}${kept} }` : undefined
|
|
168
|
-
const lost = plain && COMMENT.test(source.slice(base + name!.end, base + call.end))
|
|
169
|
-
const callee = spelled(call) ? `${source.slice(base + call.callee.start, base + call.callee.end).replace(QUERY_MEMBER, '')}.queryParam` : 'queryParam'
|
|
170
|
-
const equals = settings?.type === 'ObjectExpression' && settings.properties.some(property => property.type === 'Property' && keyName(property.key) === 'equals')
|
|
171
|
-
|
|
172
|
-
return plain && !lost && !equals ? [{ start: base + call.callee.start, end: base + call.callee.end, text: callee }, { start: base + name!.end, end: base + call.end - 1, text: text! }] : null
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// `navigate({ query })`, one name for two jobs: `navigate.query(changes)` changes the query of the current page, `navigate(href)` goes to another.
|
|
176
|
-
export async function navigateQuery(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
177
|
-
return scanned(root, options, 'deprecated-navigate-query', NAVIGATE, ({ source, parsed, report }) => {
|
|
178
|
-
for (const { ast, base } of parsed) {
|
|
179
|
-
eachCall(ast, calls(ast, 'navigate'), (call) => {
|
|
180
|
-
const [changes] = call.arguments
|
|
181
|
-
|
|
182
|
-
if (changes?.type !== 'ObjectExpression')
|
|
183
|
-
return
|
|
184
|
-
|
|
185
|
-
const [property] = changes.properties
|
|
186
|
-
const only = changes.properties.length === 1 && property?.type === 'Property' && !property.computed && !property.method && property.kind === 'init' && keyName(property.key) === 'query'
|
|
187
|
-
|
|
188
|
-
if (!only && !changes.properties.some(one => one.type === 'Property' && !one.computed && one.key.type === 'Identifier' && one.key.name === 'query'))
|
|
189
|
-
return
|
|
190
|
-
|
|
191
|
-
const text = only ? source.slice(base + property.value.start, base + property.value.end) : undefined
|
|
192
|
-
const lost = only && COMMENT.test(source.slice(base + changes.start, base + changes.end))
|
|
193
|
-
|
|
194
|
-
report(base + changes.start, base + changes.end, '`navigate({ query })` is deprecated since 1.105: `navigate.query()` changes the query, `navigate()` goes to a page', 'call `navigate.query(changes)`', only && !lost ? [{ start: base + call.callee.end, end: base + call.callee.end, text: '.query' }, { start: base + changes.start, end: base + changes.end, text: text! }] : null)
|
|
195
|
-
})
|
|
196
|
-
}
|
|
197
|
-
})
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const HOOKS = ['onBeforeNavigate', 'onNavigate'] as const
|
|
201
|
-
|
|
202
|
-
// `onNavigate(fn)` and `onBeforeNavigate(fn)`, hooks of the `navigation` source like the other sources' hooks: `navigation.onNavigate(fn)`.
|
|
203
|
-
// Moves the import too, unless a use of the name stays that is no call, or a `navigation` of the file's own stands in the way.
|
|
204
|
-
export async function navigationHooks(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
205
|
-
return scanned(root, options, 'deprecated-navigation-hooks', NAVIGATION_HOOK, ({ source, parsed, unparsed, report }) => {
|
|
206
|
-
for (const { ast, base } of parsed) {
|
|
207
|
-
const hits = HOOKS.flatMap(hook => [...importsOf(ast, FROM_KAY, hook).locals].map(local => ({ hook, local })))
|
|
208
|
-
|
|
209
|
-
if (hits.length === 0)
|
|
210
|
-
continue
|
|
211
|
-
|
|
212
|
-
const callees = new Set<Node>()
|
|
213
|
-
|
|
214
|
-
for (const { local } of hits)
|
|
215
|
-
eachCall(ast, callee => callee.type === 'Identifier' && callee.name === local, call => callees.add(call.callee))
|
|
216
|
-
|
|
217
|
-
const read = hits.reduce((total, { local }) => total + reads(ast, local), 0)
|
|
218
|
-
const text = parsed.map(one => one.ast)
|
|
219
|
-
const blocked = hits.some(({ hook, local }) => local !== hook) || read !== callees.size || hits.some(({ local }) => new RegExp(`\\b${local}\\b`).test(unparsed)) || (mentions(text, 'navigation') && !importsOf(ast, FROM_KAY, 'navigation').locals.has('navigation'))
|
|
220
|
-
const imports = blocked ? null : importEdits(ast, base, source, hits.map(({ hook }) => hook), 'navigation')
|
|
221
|
-
|
|
222
|
-
// Each diagnostic carries every call's rewrite and the import's, so the first fix applied does it all and the others overlap it.
|
|
223
|
-
const names = [...callees].filter(callee => callee.type === 'Identifier')
|
|
224
|
-
const all = imports ? [...names.map(callee => ({ start: base + callee.start, end: base + callee.end, text: `navigation.${callee.name}` })), ...imports] : null
|
|
225
|
-
|
|
226
|
-
for (const callee of names)
|
|
227
|
-
report(base + callee.start, base + callee.end, `\`${callee.name}()\` is deprecated since 1.105: the hooks of \`navigation\` are its methods`, `call \`navigation.${callee.name}()\``, all)
|
|
228
|
-
}
|
|
229
|
-
})
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// Whether `node` is `window`, `document` or a member read off one: `document.body`, `window.visualViewport`.
|
|
233
|
-
function globalTarget(node: Node): boolean {
|
|
234
|
-
if (node.type === 'Identifier')
|
|
235
|
-
return node.name === 'window' || node.name === 'document'
|
|
236
|
-
|
|
237
|
-
return node.type === 'MemberExpression' && !node.computed && globalTarget(node.object)
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// `listen(window, ...)`, a target read once: `listen(() => window, ...)` is the one form, which a `.ts` module runs on the server and a signal or a `ref` follows.
|
|
241
|
-
export async function listenTarget(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
242
|
-
return scanned(root, options, 'deprecated-listen-target', LISTEN, ({ parsed, report }) => {
|
|
243
|
-
for (const { ast, base } of parsed) {
|
|
244
|
-
eachCall(ast, calls(ast, 'listen'), (call) => {
|
|
245
|
-
const [target] = call.arguments
|
|
246
|
-
|
|
247
|
-
// Only a global read once is wrapped: any other identifier is a signal or a `ref` already, which `listen` follows as the function form, and a `.kay` file's compiler reads it for the target.
|
|
248
|
-
if (!target || !globalTarget(target))
|
|
249
|
-
return
|
|
250
|
-
|
|
251
|
-
report(base + target.start, base + target.end, '`listen()` with a target given as a value is deprecated since 1.105: a function returning it is the one form', 'write `() => target`', [{ start: base + target.start, end: base + target.start, text: '() => ' }])
|
|
252
|
-
})
|
|
253
|
-
}
|
|
254
|
-
})
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// Where an export lives, when the entry an app imported it from is no longer its home: the name, the entry it left and the one it is imported from now.
|
|
258
|
-
const MOVED: Record<string, Record<string, string>> = {
|
|
259
|
-
'kay/mount': { mount: 'kay', Mounted: 'kay' },
|
|
260
|
-
'kay/server': { s: 'kay', RateLimit: 'kay', RateLimitRefusal: 'kay', sqliteCache: 'kay/cache' },
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// A name imported from the entry that no longer owns it: each name has one home, `s` and `mount` in `kay`, `sqliteCache` in `kay/cache`.
|
|
264
|
-
// The fix takes the name out of the import and writes it as an import of its home, after it, keeping a `type` import and a `type` specifier as they were; an aliased import is rewritten the same.
|
|
265
|
-
export async function movedImports(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
266
|
-
return scanned(root, options, 'deprecated-import-path', MOVED_SOURCE, ({ source, parsed, report }) => {
|
|
267
|
-
for (const { ast, base } of parsed) {
|
|
268
|
-
for (const statement of ast.body) {
|
|
269
|
-
if (statement.type !== 'ImportDeclaration' || !Object.hasOwn(MOVED, statement.source.value))
|
|
270
|
-
continue
|
|
271
|
-
|
|
272
|
-
const homes = MOVED[statement.source.value]!
|
|
273
|
-
const moved = statement.specifiers.filter((specifier): specifier is NodeOfType<'ImportSpecifier'> => specifier.type === 'ImportSpecifier' && Object.hasOwn(homes, importedName(specifier)))
|
|
274
|
-
|
|
275
|
-
if (moved.length === 0)
|
|
276
|
-
continue
|
|
277
|
-
|
|
278
|
-
const left = statement.specifiers.filter(specifier => !moved.includes(specifier as never))
|
|
279
|
-
const plain = left.every(specifier => specifier.type === 'ImportSpecifier')
|
|
280
|
-
const lost = COMMENT.test(source.slice(base + statement.start, base + statement.end))
|
|
281
|
-
const edits: Edit[] | null = !plain || lost ? null : []
|
|
282
|
-
|
|
283
|
-
if (edits) {
|
|
284
|
-
const kind = statement.importKind === 'type' ? 'import type' : 'import'
|
|
285
|
-
const byHome = Map.groupBy(moved, specifier => homes[importedName(specifier)]!)
|
|
286
|
-
const added = [...byHome].map(([home, specifiers]) => `${kind} { ${specifiers.map(specifier => source.slice(base + specifier.start, base + specifier.end)).join(', ')} } from '${home}'`).join('\n')
|
|
287
|
-
const every = statement.specifiers as Node[]
|
|
288
|
-
const rest = left.length === 0 ? '' : `${source.slice(base + statement.start, base + every[0]!.start)}${left.map(specifier => source.slice(base + specifier.start, base + specifier.end)).join(', ')}${source.slice(base + every.at(-1)!.end, base + statement.end)}`
|
|
289
|
-
|
|
290
|
-
edits.push({ start: base + statement.start, end: base + statement.end, text: rest === '' ? added : `${rest}\n${added}` })
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
for (const specifier of moved)
|
|
294
|
-
report(base + specifier.start, base + specifier.end, `\`${importedName(specifier)}\` is exported from \`${homes[importedName(specifier)]}\`, its one home, since 1.105`, `import it from \`${homes[importedName(specifier)]}\``, edits)
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
})
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// What tells an island, as a function, what each DOM event of kay tells a plain script: a method of `navigation` for the swap's events, which a rewrite reaches, and for the others a hook that needs the action or the signal the code names.
|
|
301
|
-
const EVENT_HOOKS: Record<string, { hook: string, method?: string }> = {
|
|
302
|
-
'kay:navigate': { hook: '`navigation.onNavigate(fn)`', method: 'onNavigate' },
|
|
303
|
-
'kay:navigate-start': { hook: '`navigation.onStart(fn)`', method: 'onStart' },
|
|
304
|
-
'kay:navigate-error': { hook: '`navigation.onError(fn)`', method: 'onError' },
|
|
305
|
-
'kay:navigate-stall': { hook: '`navigation.onStall(fn)`', method: 'onStall' },
|
|
306
|
-
'kay:action-start': { hook: '`action.onStart(fn)`' },
|
|
307
|
-
'kay:action-success': { hook: '`action.onData(fn)`' },
|
|
308
|
-
'kay:action-error': { hook: '`action.onError(fn)`' },
|
|
309
|
-
'kay:consent': { hook: 'the `consent` signal' },
|
|
310
|
-
'kay:install': { hook: '`installPrompt.available()`' },
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
const KAY_EVENT = /kay:(?:navigate|action|consent|install)/
|
|
314
|
-
const NAVIGATION = /\bnavigation\b/
|
|
315
|
-
|
|
316
|
-
// `listen(() => document, 'kay:navigate', () => ...)`: a function written in place that takes no parameter, so nothing of the event the old form handed it is read.
|
|
317
|
-
function rewritable(call: Call, source: string, base: number): boolean {
|
|
318
|
-
const [target, , handler] = call.arguments
|
|
319
|
-
|
|
320
|
-
return call.arguments.length === 3 && (handler?.type === 'ArrowFunctionExpression' || handler?.type === 'FunctionExpression') && handler.params.length === 0
|
|
321
|
-
&& target?.type === 'ArrowFunctionExpression' && target.params.length === 0 && target.body.type === 'Identifier' && target.body.name === 'document'
|
|
322
|
-
&& !COMMENT.test(source.slice(base + call.start, base + call.end))
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
// `listen(() => document, 'kay:navigate', fn)` in an island, where a function hook says the same: `navigation.onNavigate(fn)`, `action.onStart(fn)`, the `consent` signal. A plain script keeps its listener, as it has no island to hook into.
|
|
326
|
-
// The swap's events are rewritten when the handler takes no parameter, as the hook hands an object of its own where the event handed `detail`; any other listener is reported with the hook to write.
|
|
327
|
-
export async function islandEvents(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
328
|
-
return scanned(root, options, 'deprecated-island-events', KAY_EVENT, ({ source, parsed, unparsed, report }) => {
|
|
329
|
-
for (const { ast, base } of parsed) {
|
|
330
|
-
const hits: { call: Call, event: string }[] = []
|
|
331
|
-
|
|
332
|
-
eachCall(ast, calls(ast, 'listen'), (call) => {
|
|
333
|
-
const [, type] = call.arguments
|
|
334
|
-
|
|
335
|
-
if (type?.type === 'Literal' && typeof type.value === 'string' && Object.hasOwn(EVENT_HOOKS, type.value))
|
|
336
|
-
hits.push({ call, event: type.value })
|
|
337
|
-
})
|
|
338
|
-
|
|
339
|
-
if (hits.length === 0)
|
|
340
|
-
continue
|
|
341
|
-
|
|
342
|
-
const fixable = hits.filter(({ call, event }) => EVENT_HOOKS[event]!.method !== undefined && rewritable(call, source, base))
|
|
343
|
-
const own = (mentions(parsed.map(one => one.ast), 'navigation') || NAVIGATION.test(unparsed)) && !importsOf(ast, FROM_KAY, 'navigation').locals.has('navigation')
|
|
344
|
-
// `listen` leaves the import when every use of it, in the other spans and the template too, is a call rewritten here; a call inside another's handler overlaps its edit, so none is rewritten.
|
|
345
|
-
const nested = fixable.some(({ call }) => fixable.some(other => other.call !== call && other.call.start >= call.start && other.call.end <= call.end))
|
|
346
|
-
const dropped = !LISTEN.test(unparsed) && parsed.every(one => one.ast === ast || reads(one.ast, 'listen') === 0) && reads(ast, 'listen') === fixable.length
|
|
347
|
-
const imports = own || nested || fixable.length === 0 ? null : importEdits(ast, base, source, dropped ? ['listen'] : [], 'navigation')
|
|
348
|
-
const all = imports ? [...fixable.map(({ call, event }) => ({ start: base + call.start, end: base + call.end, text: `navigation.${EVENT_HOOKS[event]!.method}(${source.slice(base + call.arguments[2]!.start, base + call.arguments[2]!.end)})` })), ...imports] : null
|
|
349
|
-
|
|
350
|
-
for (const { call, event } of hits) {
|
|
351
|
-
const { hook } = EVENT_HOOKS[event]!
|
|
352
|
-
|
|
353
|
-
report(base + call.callee.start, base + call.callee.end, `an island listening to \`${event}\` is deprecated since 1.105: ${hook} is the function hook, the event being for a plain script`, `use ${hook}`, fixable.some(one => one.call === call) ? all : null)
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
})
|
|
357
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import type { Property } from './regroup'
|
|
3
|
-
import { lintLevel } from '../compiler/lints'
|
|
4
|
-
import { CONFIG_KEYS } from '../config-shape'
|
|
5
|
-
import { configObjects, isProperty, propertyOf } from './config-objects'
|
|
6
|
-
import { nameOf, regrouped } from './regroup'
|
|
7
|
-
import { scan } from './renamed-exports'
|
|
8
|
-
|
|
9
|
-
const NEEDLE = /\b(?:pages|testSite)\b/
|
|
10
|
-
|
|
11
|
-
// The config keys written beside `root` in the options of `pages()` and `testSite()`, `config` since 1.105: the options are the project's own (`root`, `dev`, `prebuilt`, and a test site's `browser`, `headers` and the like) and the config they lay over `kay.config.ts` is one key, not a copy of the config's whole shape.
|
|
12
|
-
// The fix, from the first report of a call, moves the keys into a new `config` and offers none where the options spread, hold a computed key or have a `config` already.
|
|
13
|
-
export async function pagesOptions(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
14
|
-
if (lintLevel('deprecated-pages-options', options.lints) === 'allow')
|
|
15
|
-
return []
|
|
16
|
-
|
|
17
|
-
return scan(root, options, 'deprecated-pages-options', NEEDLE, ({ parsed, file, report }) => {
|
|
18
|
-
for (const { ast, base, text } of parsed) {
|
|
19
|
-
for (const { object, call, others } of configObjects(file, ast)) {
|
|
20
|
-
if (call === undefined)
|
|
21
|
-
continue
|
|
22
|
-
|
|
23
|
-
const old = object.properties.filter((property): property is Property => isProperty(property) && !property.computed && CONFIG_KEYS.has(nameOf(property)) && !others.includes(nameOf(property)))
|
|
24
|
-
|
|
25
|
-
if (old.length === 0)
|
|
26
|
-
continue
|
|
27
|
-
|
|
28
|
-
const fixed = propertyOf(object, 'config') === undefined ? regrouped(object, text, name => CONFIG_KEYS.has(name) && !others.includes(name) ? ['config', name] : undefined, true) : undefined
|
|
29
|
-
|
|
30
|
-
for (const [index, property] of old.entries())
|
|
31
|
-
report(base + property.start, base + property.end, `\`${nameOf(property)}\` beside the options of \`${call}()\` is deprecated since 1.105: the config is one key, \`config\``, `write \`config: { ${nameOf(property)} }\``, index === 0 && fixed !== undefined ? fixed.map(edit => ({ ...edit, start: base + edit.start, end: base + edit.end })) : null)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import type { Node, Program } from '../compiler/estree'
|
|
3
|
-
import { lintLevel } from '../compiler/lints'
|
|
4
|
-
import { importsOf, walk } from './ast'
|
|
5
|
-
import { scan } from './renamed-exports'
|
|
6
|
-
|
|
7
|
-
const NEEDLE = /\.enforce\b/
|
|
8
|
-
const FROM_SERVER = (source: string) => source === 'kay/server'
|
|
9
|
-
const HELP = 'write `check`, which refuses with a 429 as `enforce` did'
|
|
10
|
-
|
|
11
|
-
// `limit.enforce(ctx)` on what `rateLimit()` returns, `limit.check(ctx)` since 1.105: `limiter().enforce(key)` counts under a key and refuses nothing, so the one name kept two meanings.
|
|
12
|
-
// Found in the TypeScript files and `.kay` files of the project, on a name bound once to a call of `rateLimit` imported from `kay/server`, as `kay check` reads no types; the fix renames the method.
|
|
13
|
-
export async function rateEnforce(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
14
|
-
if (lintLevel('deprecated-rate-enforce', options.lints) === 'allow')
|
|
15
|
-
return []
|
|
16
|
-
|
|
17
|
-
return scan(root, options, 'deprecated-rate-enforce', NEEDLE, ({ parsed, report }) => {
|
|
18
|
-
for (const { ast, base } of parsed) {
|
|
19
|
-
const { locals, namespaces } = importsOf(ast, FROM_SERVER, 'rateLimit')
|
|
20
|
-
|
|
21
|
-
if (locals.size === 0 && namespaces.size === 0)
|
|
22
|
-
continue
|
|
23
|
-
|
|
24
|
-
const limits = limitNames(ast, locals, namespaces)
|
|
25
|
-
|
|
26
|
-
walk(ast, (node) => {
|
|
27
|
-
if (node.type !== 'MemberExpression' || node.computed || node.object.type !== 'Identifier' || node.property.type !== 'Identifier' || node.property.name !== 'enforce' || !limits.has(node.object.name))
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
report(base + node.property.start, base + node.property.end, '`enforce` of a `rateLimit()` limit is `check` since 1.105', HELP, [{ start: base + node.property.start, end: base + node.property.end, text: 'check' }])
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// The names a file binds once to `rateLimit(...)`, or `server.rateLimit(...)` of a namespace import.
|
|
37
|
-
function limitNames(ast: Program, locals: Set<string>, namespaces: Set<string>): Set<string> {
|
|
38
|
-
const bound = new Map<string, number>()
|
|
39
|
-
const limits = new Set<string>()
|
|
40
|
-
const isLimit = (init: Node): boolean => init.type === 'CallExpression' && ((init.callee.type === 'Identifier' && locals.has(init.callee.name)) || (init.callee.type === 'MemberExpression' && !init.callee.computed && init.callee.object.type === 'Identifier' && namespaces.has(init.callee.object.name) && init.callee.property.type === 'Identifier' && init.callee.property.name === 'rateLimit'))
|
|
41
|
-
|
|
42
|
-
walk(ast, (node) => {
|
|
43
|
-
if (node.type !== 'VariableDeclarator' || node.id.type !== 'Identifier')
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
bound.set(node.id.name, (bound.get(node.id.name) ?? 0) + 1)
|
|
47
|
-
|
|
48
|
-
if (node.init && isLimit(node.init))
|
|
49
|
-
limits.add(node.id.name)
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
return new Set([...limits].filter(name => bound.get(name) === 1))
|
|
53
|
-
}
|