@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/compiler/errors.ts
CHANGED
|
@@ -138,7 +138,7 @@ export const ERRORS = {
|
|
|
138
138
|
},
|
|
139
139
|
'client-route-fence': {
|
|
140
140
|
group: 'compile',
|
|
141
|
-
summary: 'A page, layout or special page declaring `island({ render: \'client\' })
|
|
141
|
+
summary: 'A page, layout or special page declaring `island({ render: \'client\' })`: they render on the server.',
|
|
142
142
|
fix: { file: 'llms/islands.md', heading: 'Islands' },
|
|
143
143
|
},
|
|
144
144
|
'server-import-in-island': {
|
|
@@ -228,7 +228,7 @@ export const ERRORS = {
|
|
|
228
228
|
},
|
|
229
229
|
'locales-invalid': {
|
|
230
230
|
group: 'build',
|
|
231
|
-
summary: 'An `i18n` config that does not hold together: no locales, a tag that is none, a default outside the locales,
|
|
231
|
+
summary: 'An `i18n` config that does not hold together: no locales, a tag that is none, a default outside the locales, `paths` naming a page that does not exist, a catalog that exports no messages or not as `defineMessages`, or `writeDraftMessages` given a locale the config does not translate.',
|
|
232
232
|
fix: { file: 'llms/locales.md', heading: 'Configuring locales' },
|
|
233
233
|
},
|
|
234
234
|
'font-invalid': {
|
|
@@ -508,125 +508,6 @@ export function asyncReplies(fence: ParsedFence): Diagnostic[] {
|
|
|
508
508
|
return diagnostics
|
|
509
509
|
}
|
|
510
510
|
|
|
511
|
-
// The name an action handler reads `fail` by: `ctx.fail` for a `ctx` parameter, `fail` for a destructured one.
|
|
512
|
-
function failReader(ctx: Node | undefined): ((call: NodeOfType<'CallExpression'>) => boolean) | undefined {
|
|
513
|
-
if (ctx?.type === 'Identifier') {
|
|
514
|
-
const name = ctx.name
|
|
515
|
-
|
|
516
|
-
return call => call.callee.type === 'MemberExpression' && !call.callee.computed && call.callee.object.type === 'Identifier' && call.callee.object.name === name && call.callee.property.type === 'Identifier' && call.callee.property.name === 'fail'
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
if (ctx?.type !== 'ObjectPattern')
|
|
520
|
-
return undefined
|
|
521
|
-
|
|
522
|
-
for (const property of ctx.properties) {
|
|
523
|
-
if (isPlainProperty(property) && !property.computed && property.key.type === 'Identifier' && property.key.name === 'fail' && property.value.type === 'Identifier') {
|
|
524
|
-
const local = property.value.name
|
|
525
|
-
|
|
526
|
-
return call => call.callee.type === 'Identifier' && call.callee.name === local
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
return undefined
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
// The `fail` calls an expression statement drops: the call itself, awaited, or on either side of `&&`, `||`, `??` and a ternary.
|
|
534
|
-
function droppedFails(node: Node, reads: (call: NodeOfType<'CallExpression'>) => boolean): NodeOfType<'CallExpression'>[] {
|
|
535
|
-
if (node.type === 'CallExpression')
|
|
536
|
-
return reads(node) ? [node] : []
|
|
537
|
-
|
|
538
|
-
if (node.type === 'AwaitExpression')
|
|
539
|
-
return droppedFails(node.argument, reads)
|
|
540
|
-
|
|
541
|
-
if (node.type === 'LogicalExpression')
|
|
542
|
-
return [...droppedFails(node.left, reads), ...droppedFails(node.right, reads)]
|
|
543
|
-
|
|
544
|
-
if (node.type === 'ConditionalExpression')
|
|
545
|
-
return [...droppedFails(node.consequent, reads), ...droppedFails(node.alternate, reads)]
|
|
546
|
-
|
|
547
|
-
return node.type === 'ParenthesizedExpression' || node.type === 'TSNonNullExpression' ? droppedFails(node.expression, reads) : []
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
// The names `action` is called by: the one `kay` exports, as imported or not yet, and the aliases imported from it; none when another module's or a local one takes the name.
|
|
551
|
-
function actionNames(fence: ParsedFence): Set<string> {
|
|
552
|
-
const names = new Set(['action'])
|
|
553
|
-
|
|
554
|
-
for (const node of fence.ast.body) {
|
|
555
|
-
if (node.type === 'ImportDeclaration') {
|
|
556
|
-
for (const specifier of node.specifiers) {
|
|
557
|
-
const name = specifier.type === 'ImportSpecifier' ? specifier.imported : undefined
|
|
558
|
-
const imported = name?.type === 'Identifier' ? name.name : name?.value
|
|
559
|
-
|
|
560
|
-
if (node.source.value === 'kay' && imported === 'action')
|
|
561
|
-
names.add(specifier.local.name)
|
|
562
|
-
else if (specifier.local.name === 'action')
|
|
563
|
-
names.delete('action')
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
else if ((node.type === 'FunctionDeclaration' && node.id?.name === 'action') || (node.type === 'VariableDeclaration' && node.declarations.some(declaration => patternNames(declaration.id).includes('action')))) {
|
|
567
|
-
names.delete('action')
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
return names
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
// A `ctx.fail(...)` statement in an action's handler: `fail` returns the failure, where `deny`, `notFound` and `redirect` throw, so a statement not returned does nothing and the handler carries on.
|
|
575
|
-
export function unreturnedFails(fence: ParsedFence): Diagnostic[] {
|
|
576
|
-
if (!fence.code.includes('fail(') || !fence.code.includes('action'))
|
|
577
|
-
return []
|
|
578
|
-
|
|
579
|
-
const diagnostics: Diagnostic[] = []
|
|
580
|
-
const names = actionNames(fence)
|
|
581
|
-
const seen = new Set<number>()
|
|
582
|
-
|
|
583
|
-
eachNode(fence.ast, (node) => {
|
|
584
|
-
if (node.type !== 'CallExpression' || node.callee.type !== 'Identifier' || !names.has(node.callee.name))
|
|
585
|
-
return
|
|
586
|
-
|
|
587
|
-
const handler = node.arguments.findIndex(argument => argument.type === 'ArrowFunctionExpression' || argument.type === 'FunctionExpression')
|
|
588
|
-
const fn = node.arguments[handler]
|
|
589
|
-
|
|
590
|
-
if (!fn || !isFunction(fn) || !fn.body || fn.body.type !== 'BlockStatement')
|
|
591
|
-
return
|
|
592
|
-
|
|
593
|
-
const reads = failReader(fn.params[handler === 0 ? 0 : 1])
|
|
594
|
-
|
|
595
|
-
if (!reads)
|
|
596
|
-
return
|
|
597
|
-
|
|
598
|
-
eachNode(fn.body, (inner) => {
|
|
599
|
-
if (isFunction(inner))
|
|
600
|
-
return false
|
|
601
|
-
|
|
602
|
-
if (inner.type === 'ExpressionStatement') {
|
|
603
|
-
const { expression } = inner
|
|
604
|
-
const awaited = expression.type === 'AwaitExpression' ? expression.argument : expression
|
|
605
|
-
const direct = awaited.type === 'CallExpression' ? awaited : undefined
|
|
606
|
-
|
|
607
|
-
for (const call of droppedFails(inner.expression, reads)) {
|
|
608
|
-
if (seen.has(call.start))
|
|
609
|
-
continue
|
|
610
|
-
|
|
611
|
-
seen.add(call.start)
|
|
612
|
-
diagnostics.push({
|
|
613
|
-
...fence.shift(call),
|
|
614
|
-
code: 'unreturned-fail',
|
|
615
|
-
message: 'This `fail()` is not returned, so it does nothing and the handler carries on',
|
|
616
|
-
note: '`fail` returns the failure the action answers with, where `deny`, `notFound` and `redirect` throw',
|
|
617
|
-
help: 'write `return ctx.fail(...)`',
|
|
618
|
-
fixes: call === direct ? [{ title: 'Return it', edits: [{ start: fence.offset + inner.start, end: fence.offset + inner.start, text: 'return ' }], safe: true }] : [],
|
|
619
|
-
})
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
return true
|
|
624
|
-
})
|
|
625
|
-
})
|
|
626
|
-
|
|
627
|
-
return diagnostics
|
|
628
|
-
}
|
|
629
|
-
|
|
630
511
|
// A destructured prop read into a top-level `const` or `let` that a function or the template reads later: the declaration runs once, when the component is created, so the value keeps the prop's first value after the parent changes it.
|
|
631
512
|
// A prop read as the test of a condition, as an argument of a call or `new`, as a write target or inside a class is left alone: those choose or build something once, and a name declared again anywhere in the script is left alone too.
|
|
632
513
|
export function onceReadProps(fence: ParsedFence, props: PropsDeclaration | undefined, templateNames: readonly string[]): Diagnostic[] {
|
|
@@ -756,7 +637,7 @@ export function missingCaptchas(fence: ParsedFence): Diagnostic[] {
|
|
|
756
637
|
// The checks a plain module takes, parsed only when one of them may find something.
|
|
757
638
|
// A module the browser bundle reaches (`browser`) is checked for the names the browser's entries lack as well.
|
|
758
639
|
export function moduleChecks(source: string, browser = false): Diagnostic[] {
|
|
759
|
-
if (!CSS_BINDING.test(source) && !(browser && source.includes('kay/cache')) && !(source.includes(AI_PACKAGE) && source.includes('async')) && !source.includes('redirect(') && !
|
|
640
|
+
if (!CSS_BINDING.test(source) && !(browser && source.includes('kay/cache')) && !(source.includes(AI_PACKAGE) && source.includes('async')) && !source.includes('redirect(') && !CAPTCHA_CALLS.keys().some(name => source.includes(name)))
|
|
760
641
|
return []
|
|
761
642
|
|
|
762
643
|
const whole = { start: 0, end: source.length }
|
|
@@ -775,5 +656,5 @@ export function moduleChecks(source: string, browser = false): Diagnostic[] {
|
|
|
775
656
|
}
|
|
776
657
|
|
|
777
658
|
function checksOf(module: ParsedFence, browser: boolean): Diagnostic[] {
|
|
778
|
-
return [...cssImportsWithoutText(module), ...asyncReplies(module), ...openRedirects(module), ...missingCaptchas(module), ...
|
|
659
|
+
return [...cssImportsWithoutText(module), ...asyncReplies(module), ...openRedirects(module), ...missingCaptchas(module), ...browser ? serverOnlyImports(module) : []]
|
|
779
660
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Attribute, ElementNode, NamedAttribute, PartFacts } from './ast'
|
|
2
|
+
import type { ClassItem } from './class-items'
|
|
3
|
+
import type { CodeBuilder } from './mapping'
|
|
4
|
+
import { handedParts, partsOf } from './ast'
|
|
5
|
+
import { helperName } from './markup'
|
|
6
|
+
import { PROPS } from './names'
|
|
7
|
+
|
|
8
|
+
type ExpressionAttribute = Extract<NamedAttribute, { kind: 'expression' }>
|
|
9
|
+
|
|
10
|
+
// The `parts` a component call writes and the spreads, whose `parts` a call handing parts on lays under its own, as the called component would otherwise lose them to the hand-off.
|
|
11
|
+
export function writtenParts(element: ElementNode, source: string): Attribute[] {
|
|
12
|
+
const hand = element.attributes.find((one): one is ExpressionAttribute => one.kind === 'expression' && source.slice(one.name.start, one.name.end) === 'parts')
|
|
13
|
+
|
|
14
|
+
return [...element.attributes.filter(one => one.kind === 'spread'), hand].filter(attribute => attribute !== undefined)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Whether a component call hands a part of this component on without being handed parts itself: it writes its `class` and `parts` as one source, `partProps`.
|
|
18
|
+
export function writesTogether(element: ElementNode, source: string, facts: PartFacts | undefined): boolean {
|
|
19
|
+
return element.component && partsOf(element, source, facts).length > 0 && handedParts(element, source, facts).length === 0
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// What a part handed on to a component adds to the class list: its recipe's classes and the caller's entry for it, which `partHanded` makes the part's value.
|
|
23
|
+
export function handedItem(b: CodeBuilder, part: string, recipe: readonly (() => void)[]): ClassItem {
|
|
24
|
+
return {
|
|
25
|
+
emit: () => {
|
|
26
|
+
b.add(`${helperName('partHanded')}(${JSON.stringify(part)}, [`)
|
|
27
|
+
|
|
28
|
+
for (const emit of recipe) {
|
|
29
|
+
emit()
|
|
30
|
+
b.add(', ')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
b.add(`${helperName('partClass')}(${PROPS}, ${JSON.stringify(part)})])`)
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// What opens the list of classes of an element: an array, or on a component call the helper merging it, which is `handParts` for the `parts` of a call handing parts on and `partProps` for the `class` and `parts` of a call written as one source.
|
|
39
|
+
export function openClassList(b: CodeBuilder, component: boolean, handing: readonly Attribute[] | undefined, together: boolean): void {
|
|
40
|
+
if (together) {
|
|
41
|
+
b.add(`${helperName('partProps')}(() => [[`)
|
|
42
|
+
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
b.add(component ? `${helperName(handing ? 'handParts' : 'componentClass')}([` : '[')
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// What closes the `handParts` of a call: the `parts` it writes, the spreads' under them.
|
|
50
|
+
export function closeHandParts(b: CodeBuilder, component: boolean, written: readonly Attribute[] | undefined, together: boolean): void {
|
|
51
|
+
b.add(component && !written && !together ? '])' : ']')
|
|
52
|
+
|
|
53
|
+
const given = written?.filter(attribute => attribute.kind === 'expression' || attribute.kind === 'spread') ?? []
|
|
54
|
+
const emit = (attribute: (typeof given)[number]) => {
|
|
55
|
+
if (attribute.kind === 'spread')
|
|
56
|
+
b.add('((').addSource(attribute.expression).add(') as unknown as { parts?: unknown }).parts')
|
|
57
|
+
else if (attribute.kind === 'expression')
|
|
58
|
+
b.add('(').addSource(attribute.expression).add(')')
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (given.length === 1) {
|
|
62
|
+
b.add(', ')
|
|
63
|
+
emit(given[0]!)
|
|
64
|
+
}
|
|
65
|
+
else if (given.length > 1) {
|
|
66
|
+
b.add(', { ')
|
|
67
|
+
|
|
68
|
+
for (const [index, attribute] of given.entries()) {
|
|
69
|
+
b.add(index === 0 ? '...' : ', ...')
|
|
70
|
+
emit(attribute)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
b.add(' }')
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (written)
|
|
77
|
+
b.add(together ? '])' : ')')
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Whether an attribute of a call handing parts on is one it writes itself, as `parts`: the `parts` and the spreads.
|
|
81
|
+
export function handsEntry(element: ElementNode, source: string, attribute: NamedAttribute, hands: boolean): boolean {
|
|
82
|
+
return hands && writtenParts(element, source).includes(attribute)
|
|
83
|
+
}
|
|
@@ -2,10 +2,10 @@ import type { AwaitAlert } from './names'
|
|
|
2
2
|
import { helperName } from './markup'
|
|
3
3
|
|
|
4
4
|
// The `kay/html` helpers static server output calls, each imported under a `Kay` name.
|
|
5
|
-
const HTML_HELPERS = ['attempt', 'attribute', 'checkedMarkup', 'child', 'className', 'component', 'componentClass', 'currentPage', 'dynamic', 'element', 'errorParagraph', 'fieldDescribed', 'formConstraints', 'formKey', 'formOptions', 'formType', 'head', 'html', 'imageAttributes', 'innerMarkup', 'leadingNewline', 'linkHref', 'localHref', 'loop', 'memo', 'merge', 'nonEmptyAttribute', 'omit', 'outsideLink', 'partClass', 'partHanded', '
|
|
5
|
+
const HTML_HELPERS = ['attempt', 'attribute', 'checkedMarkup', 'child', 'className', 'component', 'componentClass', 'currentPage', 'dynamic', 'element', 'errorParagraph', 'fieldDescribed', 'formConstraints', 'formKey', 'formOptions', 'formType', 'handParts', 'head', 'html', 'imageAttributes', 'innerMarkup', 'leadingNewline', 'linkHref', 'localHref', 'loop', 'memo', 'merge', 'nonEmptyAttribute', 'omit', 'outsideLink', 'partClass', 'partHanded', 'partProps', 'raw', 'rawData', 'rawTyped', 'refillOptions', 'schemaFill', 'selectOptions', 'serverIsland', 'show', 'spreadAttributes', 'spreadWith', 'style', 'untrack']
|
|
6
6
|
|
|
7
7
|
// The `kay/dom` helpers browser output calls, each imported under a `Kay` name.
|
|
8
|
-
const DOM_HELPERS = ['append', 'attribute', 'branches', 'checkedMarkup', 'choose', 'close', 'component', 'componentClass', 'effect', 'errorParagraph', 'fragment', 'holdSubmits', 'insert', 'listen', 'listenSubmit', 'listenSubmitWith', 'listenWith', 'markers', 'memo', 'merge', 'omit', 'outside', 'part', 'partClass', 'partHanded', '
|
|
8
|
+
const DOM_HELPERS = ['append', 'attribute', 'branches', 'checkedMarkup', 'choose', 'close', 'component', 'componentClass', 'effect', 'errorParagraph', 'fragment', 'handParts', 'holdSubmits', 'insert', 'listen', 'listenSubmit', 'listenSubmitWith', 'listenWith', 'markers', 'memo', 'merge', 'omit', 'outside', 'part', 'partClass', 'partHanded', 'partProps', 'property', 'ref', 'setClass', 'setStyle', 'spreadAttributes', 'spreadWith', 'template', 'text', 'transition', 'untrack']
|
|
9
9
|
// The helpers in modules of their own, as their runtimes weigh on a page whose islands use none of them: the module of each is only loaded by a page with an island that compiles to it.
|
|
10
10
|
const APART = [['kay/dom-loop', ['loop', 'rowKey']], ['kay/dom-await', ['awaited']], ['kay/dom-try', ['attempt']], ['kay/dom-spread', ['dynamic', 'spread']], ['kay/dom-image', ['image']], ['kay/pending', ['pendingCall']]] as const
|
|
11
11
|
|
|
@@ -29,8 +29,6 @@ export interface ImageOptionAttributes {
|
|
|
29
29
|
|
|
30
30
|
// What an `img` with an imported `src` takes beside `sizes`, `width` and `height`: the shape it is cut to, the quality of its variants, and whether it shows its color until it loads. Read by the source and never written.
|
|
31
31
|
export const IMAGE_OPTIONS = new Set(['aspect', 'quality', 'placeholder'])
|
|
32
|
-
// The attribute an `img` read before 1.105 for leaving out the color it shows until it loads, `placeholder={false}` since.
|
|
33
|
-
export const NO_PLACEHOLDER = 'no-placeholder'
|
|
34
32
|
|
|
35
33
|
// The attributes an `img` with an imported `src` takes besides `sizes`, and whether it shows its color until it loads.
|
|
36
34
|
export function imageOptions(element: ElementNode, source: Source): { options: ImageOptionAttributes, colour: boolean } {
|
|
@@ -38,7 +36,7 @@ export function imageOptions(element: ElementNode, source: Source): { options: I
|
|
|
38
36
|
const options = { aspect: find('aspect'), quality: find('quality'), placeholder: find('placeholder') }
|
|
39
37
|
const written = (name: string) => element.attributes.some(attribute => attribute.kind !== 'spread' && source(attribute.name) === name)
|
|
40
38
|
|
|
41
|
-
return { options, colour: !written('style') && !
|
|
39
|
+
return { options, colour: !written('style') && !placeholderOff(options.placeholder, source) }
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
// Whether the attribute is `placeholder={false}`, the one form kay reads while compiling, so the server leaves the color out.
|
package/src/compiler/index.ts
CHANGED
|
@@ -15,17 +15,13 @@ import { actionOf, drawIcons, elementsIn, INTERACTIVE_ATTRIBUTE, SERVER_IN_ISLAN
|
|
|
15
15
|
import { browserReads } from './browser'
|
|
16
16
|
import { wrapActionButtons } from './button-forms'
|
|
17
17
|
import { generate, isInteractive, islandCause, lineOf } from './codegen'
|
|
18
|
-
import {
|
|
19
|
-
import { deprecatedChildrenProp } from './deprecated-children'
|
|
20
|
-
import { deprecatedIslandAttributes, deprecatedIslandForms, islandProblems } from './deprecated-island'
|
|
21
|
-
import { deprecatedPageSettings } from './deprecated-page'
|
|
22
|
-
import { deprecatedPartsClass } from './deprecated-parts'
|
|
23
|
-
import { asyncReplies, cssImportsWithoutText, missingCaptchas, onceReadProps, separatePageSettings, serverOnlyImports, unboundedFields, unreturnedFails } from './fence-checks'
|
|
18
|
+
import { asyncReplies, cssImportsWithoutText, missingCaptchas, onceReadProps, separatePageSettings, serverOnlyImports, unboundedFields } from './fence-checks'
|
|
24
19
|
import { openRedirects } from './fence-redirects'
|
|
25
20
|
import { cwd, scopeStorage } from './host'
|
|
26
|
-
import { ignoredIslandExport,
|
|
21
|
+
import { ignoredIslandExport, islandMessages, withAlertKeys } from './island-arguments'
|
|
27
22
|
import { describeCause } from './island-cause'
|
|
28
23
|
import { markerMismatch } from './island-marker'
|
|
24
|
+
import { islandProblems } from './island-problems'
|
|
29
25
|
import { lazyImportsOf } from './lazy-imports'
|
|
30
26
|
import { linkFlags } from './link-flags'
|
|
31
27
|
import { applyLints, templateLints } from './lints'
|
|
@@ -38,8 +34,9 @@ import { scopeAttribute } from './scoped-style'
|
|
|
38
34
|
import { analyzeScript, analyzeServer } from './script'
|
|
39
35
|
import { serialAwaits } from './serial-awaits'
|
|
40
36
|
import { serverImportReads } from './server-imports'
|
|
37
|
+
import { signalFromProps } from './signal-from-prop'
|
|
41
38
|
import { STATUS_PAGE_FILES } from './status-pages'
|
|
42
|
-
import { outerReads, templateWords } from './template-reads'
|
|
39
|
+
import { outerReads, templateWords, templateWrites } from './template-reads'
|
|
43
40
|
import { ISLAND_TWIN } from './twin'
|
|
44
41
|
import { unownedEffects } from './unowned-effects'
|
|
45
42
|
import { validate } from './validate'
|
|
@@ -83,7 +80,7 @@ export interface CompileOptions {
|
|
|
83
80
|
twinBuild?: boolean | undefined
|
|
84
81
|
// The props the component's call sites write, when all are known: the `...rest` of its props leaves out only these of the ones it declares.
|
|
85
82
|
writtenProps?: ReadonlySet<string> | undefined
|
|
86
|
-
// Whether the file is a page of a routes directory (`isPageFile`), which nothing renders inside an island, so a page without a server fence reads its loops as static as the build does, is refused
|
|
83
|
+
// Whether the file is a page of a routes directory (`isPageFile`), which nothing renders inside an island, so a page without a server fence reads its loops as static as the build does, is refused `island()`, and is no island by its pin; `false` says it is a component, where a root `@block` is refused.
|
|
87
84
|
page?: boolean | undefined
|
|
88
85
|
// Whether the file is known to be a component, which has no `--- server` fence: a library checked on its own has pages no routes directory names, so only a caller knowing its routes says so.
|
|
89
86
|
component?: boolean | undefined
|
|
@@ -91,7 +88,7 @@ export interface CompileOptions {
|
|
|
91
88
|
lints?: LintLevels | undefined
|
|
92
89
|
// Type checking only: the types alone, for a file whose problems nothing reads, so the ones only `kay check` reports are not looked for.
|
|
93
90
|
typesOnly?: boolean | undefined
|
|
94
|
-
// Renders in the browser only, as
|
|
91
|
+
// Renders in the browser only, as `island({ render: 'client' })` does: set when a package the component imports cannot load on the server.
|
|
95
92
|
clientOnly?: boolean | undefined
|
|
96
93
|
// Type-checking a static component only islands render: its children render inline with it, so the props it passes them are not serialized.
|
|
97
94
|
insideIsland?: boolean | undefined
|
|
@@ -182,9 +179,9 @@ function browserCause(file: KayFile, script: ScriptAnalysis, value: ReturnType<t
|
|
|
182
179
|
return value === undefined || binding === undefined ? undefined : { kind: value.kind, name: value.local, span: binding.span, line: lineOf(file.source, binding.span.start) }
|
|
183
180
|
}
|
|
184
181
|
|
|
185
|
-
// The cause with the props the component's `island`
|
|
182
|
+
// The cause with the props the component's `island()` lists as making a use interactive, when it lists some: a client-only component and one following a live or persisted value are islands in every use.
|
|
186
183
|
function withInteractive(cause: IslandCause | undefined, script: ScriptAnalysis): IslandCause | undefined {
|
|
187
|
-
const interactive =
|
|
184
|
+
const interactive = script.island?.interactive
|
|
188
185
|
|
|
189
186
|
return cause !== undefined && interactive !== undefined && cause.kind !== 'client' && cause.kind !== 'live' && cause.kind !== 'persisted' ? { ...cause, interactive } : cause
|
|
190
187
|
}
|
|
@@ -204,12 +201,12 @@ function staticPin(span: Span, cause: IslandCause): Diagnostic {
|
|
|
204
201
|
return { ...span, code: 'static-pin', message: `This component is declared \`island({ render: 'static' })\`, and is an island: ${describeCause(cause)}`, note: 'it needs the browser, so it hydrates there', help: 'take that out of the component, or declare it `island()`' }
|
|
205
202
|
}
|
|
206
203
|
|
|
207
|
-
// A page without a server fence that is an island for a handler, a `kay` value or a live or persisted import: a page renders once, so a component should hold what needs the browser.
|
|
208
|
-
function
|
|
204
|
+
// A page without a server fence that is an island for a handler, a `kay` value or a live or persisted import: a page renders once, so a component should hold what needs the browser.
|
|
205
|
+
function pageIsland(page: boolean, route: boolean, client: boolean, check: boolean | undefined, raw: IslandCause | undefined, cause: IslandCause | undefined): Diagnostic[] {
|
|
209
206
|
if (!page || route || client || check !== true || raw === undefined || cause === undefined)
|
|
210
207
|
return []
|
|
211
208
|
|
|
212
|
-
return [{ ...raw.span, code: '
|
|
209
|
+
return [{ ...raw.span, code: 'page-island', checkOnly: true, message: `A page is never an island, and this one is for ${describeCause(cause)}`, note: 'a page renders once on the server, so nothing in it should run in the browser', help: 'move what needs the browser into a component of its own and render it from the page' }]
|
|
213
210
|
}
|
|
214
211
|
|
|
215
212
|
// What the server fence declares for the template: its data and its exports, which the script reads as declared rather than as kay values to import.
|
|
@@ -219,9 +216,9 @@ function serverNames(server: ServerAnalysis | undefined): string[] | undefined {
|
|
|
219
216
|
|
|
220
217
|
// What a component's script and template say of its role in the browser, from one analysis.
|
|
221
218
|
interface Role {
|
|
222
|
-
// A
|
|
219
|
+
// A client-only component or an interactive one, an island whatever its file.
|
|
223
220
|
always: boolean
|
|
224
|
-
//
|
|
221
|
+
// An `island()` pin: an island unless the file is a page, a layout or a special page, which is never one by its pin.
|
|
225
222
|
pinned: boolean
|
|
226
223
|
// It imports a live or persisted value, which makes a file that is not a layout, a special page or one with a server fence an island.
|
|
227
224
|
live: boolean
|
|
@@ -263,7 +260,7 @@ function roleOf(original: string, imported: ImportedSignals | undefined, page: b
|
|
|
263
260
|
}
|
|
264
261
|
|
|
265
262
|
// Whether a component renders as an island of its own, as compileKay decides it, without generating its code.
|
|
266
|
-
// `page` says the file is a page of the routes directory (`isPageFile`), which its
|
|
263
|
+
// `page` says the file is a page of the routes directory (`isPageFile`), which its `island()` declaration does not make an island.
|
|
267
264
|
export function rendersAsIsland(original: string, imported?: ImportedSignals, page = false): boolean {
|
|
268
265
|
const { always, live, pinned, server } = roleOf(original, imported, page)
|
|
269
266
|
|
|
@@ -291,7 +288,7 @@ export function onceReadChecks(original: string): Diagnostic[] {
|
|
|
291
288
|
const server = analyzeServer(source, file.server)
|
|
292
289
|
const script = analyzeScript(source, file.script, serverNames(server), file.module)
|
|
293
290
|
|
|
294
|
-
return script.fence ? onceReadProps(script.fence, script.props, templateWords(file)) : []
|
|
291
|
+
return script.fence ? [...onceReadProps(script.fence, script.props, templateWords(file)), ...signalFromProps(script.fence, script.props, templateWrites(file))] : []
|
|
295
292
|
}
|
|
296
293
|
|
|
297
294
|
const FAILED_FUNCTION = /^function KayFailed\(/m
|
|
@@ -356,7 +353,7 @@ export function compileKay(original: string, filename: string, options: CompileO
|
|
|
356
353
|
...coded(server ? separatePageSettings(source, server) : [], 'page-settings-invalid'),
|
|
357
354
|
...validate(file, script, server, generateOptions),
|
|
358
355
|
...coded(unparsed ? [] : found.diagnostics, 'signal-misuse'),
|
|
359
|
-
...
|
|
356
|
+
...pageIsland(pageFile, routeFile, client, options.check, rawCause, cause),
|
|
360
357
|
...coded(pin?.kind === 'static' && cause !== undefined && rawCause !== undefined && !routeFile && island !== undefined ? [staticPin(rawCause.span, { ...cause, interactive: undefined })] : [], 'static-pin'),
|
|
361
358
|
]
|
|
362
359
|
|
|
@@ -369,6 +366,9 @@ export function compileKay(original: string, filename: string, options: CompileO
|
|
|
369
366
|
// Type checking only, so a page still runs while it is fixed, and fails there in development naming the same fixes.
|
|
370
367
|
const serverData = server?.data.map(data => data.name) ?? []
|
|
371
368
|
|
|
369
|
+
// The `island` export of the `--- module` fence read before 1.109 is an error in every output, as it declares nothing now.
|
|
370
|
+
diagnostics.push(...ignoredIslandExport(script))
|
|
371
|
+
|
|
372
372
|
if (checked && !client)
|
|
373
373
|
diagnostics.push(...coded(browserReads(file, island !== undefined, serverData, routeFile), 'browser-only-read'), ...coded(serverImportReads(file, script, server, island !== undefined), 'server-import-in-island'))
|
|
374
374
|
|
|
@@ -379,12 +379,12 @@ export function compileKay(original: string, filename: string, options: CompileO
|
|
|
379
379
|
const broken = diagnostics.some(diagnostic => !diagnostic.checkOnly)
|
|
380
380
|
|
|
381
381
|
if (checked) {
|
|
382
|
-
const fenceLints = [script.fence, script.moduleFence, server?.fence].flatMap(fence => fence ? [...cssImportsWithoutText(fence), ...asyncReplies(fence), ...openRedirects(fence), ...missingCaptchas(fence)
|
|
382
|
+
const fenceLints = [script.fence, script.moduleFence, server?.fence].flatMap(fence => fence ? [...cssImportsWithoutText(fence), ...asyncReplies(fence), ...openRedirects(fence), ...missingCaptchas(fence)] : [])
|
|
383
383
|
// The script runs in the browser as an island's and in a component only islands render.
|
|
384
384
|
const browserScript = (island !== undefined || options.insideIsland === true) && !routeFile ? scriptFences(script) : []
|
|
385
385
|
const unusedLints = broken ? [] : [...unreadNames(source, file.template, script, server, found.findings), ...constantSignals(source, [file.script, file.module], found.findings)]
|
|
386
386
|
|
|
387
|
-
diagnostics.push(...unboundedFields(server), ...fenceLints, ...serialAwaits(server), ...browserScript.flatMap(fence => serverOnlyImports(fence)), ...browserScript.includes(script.fence!) ? onceReadProps(script.fence!, script.props, templateWords(file))
|
|
387
|
+
diagnostics.push(...unboundedFields(server), ...fenceLints, ...serialAwaits(server), ...browserScript.flatMap(fence => serverOnlyImports(fence)), ...browserScript.includes(script.fence!) ? [...onceReadProps(script.fence!, script.props, templateWords(file)), ...signalFromProps(script.fence!, script.props, templateWrites(file))] : [], ...unusedLints, ...templateLints(file), ...linkFlags(file))
|
|
388
388
|
}
|
|
389
389
|
|
|
390
390
|
if (checked && pin !== undefined)
|
|
@@ -537,7 +537,7 @@ function takeBlock(file: KayFile, filename: string, options: CompileOptions, scr
|
|
|
537
537
|
const at = file.source.slice(block.start, block.end).search(new RegExp(`(?<![\\w$])${name.replaceAll('$', '\\$')}(?![\\w$])`, 'g'))
|
|
538
538
|
const start = at < 0 ? block.name.start : block.start + at
|
|
539
539
|
|
|
540
|
-
file.diagnostics.push({ start, end: at < 0 ? block.name.end : start + name.length, code: 'fallback-invalid', message: `\`@${which}\` of ${which === 'failed' ? 'a' : 'a
|
|
540
|
+
file.diagnostics.push({ start, end: at < 0 ? block.name.end : start + name.length, code: 'fallback-invalid', message: `\`@${which}\` of ${which === 'failed' ? 'a' : 'a client-only'} component reads \`${name}\`, which the server does not have`, note: 'the server renders it without running the script', help: 'write static markup, or import what it needs' })
|
|
541
541
|
}
|
|
542
542
|
|
|
543
543
|
return { code: compiled.tsx.replace(FALLBACK_COMPONENT, which === 'failed' ? 'function KayFailed(' : 'function KayFallback('), classes: compiled.classes }
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Diagnostic
|
|
1
|
+
import type { Diagnostic } from './ast'
|
|
2
|
+
import type { IslandDeclaration } from './island-declaration'
|
|
2
3
|
import type { AwaitAlert } from './names'
|
|
3
4
|
import type { ScriptAnalysis } from './script'
|
|
4
5
|
import { AWAIT_FAILED_KEY } from '../runtime/await-failed'
|
|
@@ -21,109 +22,22 @@ export function withAlertKeys(source: string, alert: AwaitAlert | undefined): st
|
|
|
21
22
|
return alert === undefined || (!AWAIT_LINE.test(source) && !KAY_IMPORT.test(source)) ? source : `${source}\n${alert.keys.map(key => `t('${key}')`).join(' ')}`
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
//
|
|
25
|
-
export function
|
|
26
|
-
const fence = script.moduleFence
|
|
27
|
-
|
|
28
|
-
for (const statement of fence?.ast.body ?? []) {
|
|
29
|
-
if (statement.type !== 'ExportNamedDeclaration')
|
|
30
|
-
continue
|
|
31
|
-
|
|
32
|
-
if (statement.declaration?.type === 'VariableDeclaration' && statement.declaration.declarations.some(declarator => declarator.id.type === 'Identifier' && declarator.id.name === 'island'))
|
|
33
|
-
return { form: 'const', span: fence!.shift(statement) }
|
|
34
|
-
|
|
35
|
-
if (statement.specifiers.some(specifier => specifier.exported.type === 'Identifier' ? specifier.exported.name === 'island' : specifier.exported.value === 'island'))
|
|
36
|
-
return { form: 'listed', span: fence!.shift(statement) }
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return undefined
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// The problem with an `island` export nothing reads: one written any other way than `export const island`, or on a component that is no island.
|
|
43
|
-
export function ignoredIslandExport(script: ScriptAnalysis, isIsland: boolean): Diagnostic[] {
|
|
44
|
-
const asked = islandExport(script)
|
|
45
|
-
|
|
46
|
-
if (asked !== undefined && script.island !== undefined)
|
|
47
|
-
return [{ ...asked.span, code: 'fence-invalid', message: 'The component declares `island()` already, so its `island` export is not read', help: 'move what it says into the `island()` call and drop the export' }]
|
|
48
|
-
|
|
49
|
-
if (asked?.form === 'listed')
|
|
50
|
-
return [{ ...asked.span, code: 'fence-invalid', message: 'Only `export const island = { hydrate, persist, interactive }` is read as what the component asks of its parents', help: 'write it as that declaration' }]
|
|
51
|
-
|
|
52
|
-
return asked && !isIsland ? [{ ...asked.span, code: 'fence-invalid', message: 'This component is no island, so nothing reads its `island` export', help: 'write `island()`, or drop the export' }] : []
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// The `hydrate` the exported `island` asks for, when it is written as a string.
|
|
56
|
-
export function exportedHydrate(script: ScriptAnalysis): string | undefined {
|
|
57
|
-
if (script.island !== undefined)
|
|
58
|
-
return script.island.hydrate
|
|
59
|
-
|
|
25
|
+
// An `island` exported by the `--- module` fence, which nothing reads: a component says what it asks of its parents with `island({ hydrate, persist, interactive })` in its script.
|
|
26
|
+
export function ignoredIslandExport(script: ScriptAnalysis): Diagnostic[] {
|
|
60
27
|
for (const statement of script.moduleFence?.ast.body ?? []) {
|
|
61
|
-
|
|
62
|
-
const init = declaration?.init?.type === 'TSAsExpression' ? declaration.init.expression : declaration?.init
|
|
63
|
-
const property = init?.type === 'ObjectExpression' ? init.properties.find(each => each.type === 'Property' && each.key.type === 'Identifier' && each.key.name === 'hydrate') : undefined
|
|
64
|
-
|
|
65
|
-
if (property?.type === 'Property' && property.value.type === 'Literal' && typeof property.value.value === 'string')
|
|
66
|
-
return property.value.value
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return undefined
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// The `interactive` of the exported `island`, `{ prop: whether it is on when a use leaves it out }`, read where it is written as an object of booleans.
|
|
73
|
-
export function interactiveProps(script: ScriptAnalysis): Record<string, boolean> | undefined {
|
|
74
|
-
if (script.island !== undefined)
|
|
75
|
-
return script.island.interactive
|
|
76
|
-
|
|
77
|
-
for (const statement of script.moduleFence?.ast.body ?? []) {
|
|
78
|
-
const declaration = statement.type === 'ExportNamedDeclaration' && statement.declaration?.type === 'VariableDeclaration' ? statement.declaration.declarations.find(each => each.id.type === 'Identifier' && each.id.name === 'island') : undefined
|
|
79
|
-
const init = declaration?.init?.type === 'TSAsExpression' ? declaration.init.expression : declaration?.init
|
|
80
|
-
const property = init?.type === 'ObjectExpression' ? init.properties.find(each => each.type === 'Property' && each.key.type === 'Identifier' && each.key.name === 'interactive') : undefined
|
|
81
|
-
const given = property?.type === 'Property' ? property.value : undefined
|
|
82
|
-
const value = given?.type === 'TSAsExpression' ? given.expression : given
|
|
83
|
-
|
|
84
|
-
if (value?.type !== 'ObjectExpression')
|
|
28
|
+
if (statement.type !== 'ExportNamedDeclaration')
|
|
85
29
|
continue
|
|
86
30
|
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
for (const each of value.properties) {
|
|
90
|
-
if (each.type === 'Property' && each.key.type === 'Identifier' && each.value.type === 'Literal' && typeof each.value.value === 'boolean')
|
|
91
|
-
props[each.key.name] = each.value.value
|
|
92
|
-
}
|
|
31
|
+
const named = statement.declaration?.type === 'VariableDeclaration' && statement.declaration.declarations.some(declarator => declarator.id.type === 'Identifier' && declarator.id.name === 'island')
|
|
32
|
+
const listed = statement.specifiers.some(specifier => specifier.exported.type === 'Identifier' ? specifier.exported.name === 'island' : specifier.exported.value === 'island')
|
|
93
33
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return undefined
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// The problem with an `interactive` that is no object of booleans written in place, which the compiler could not read and the runtime would take as it is.
|
|
101
|
-
export function malformedInteractive(script: ScriptAnalysis): Diagnostic[] {
|
|
102
|
-
for (const statement of script.moduleFence?.ast.body ?? []) {
|
|
103
|
-
const declaration = statement.type === 'ExportNamedDeclaration' && statement.declaration?.type === 'VariableDeclaration' ? statement.declaration.declarations.find(each => each.id.type === 'Identifier' && each.id.name === 'island') : undefined
|
|
104
|
-
const init = declaration?.init?.type === 'TSAsExpression' ? declaration.init.expression : declaration?.init
|
|
105
|
-
const property = init?.type === 'ObjectExpression' ? init.properties.find(each => each.type === 'Property' && each.key.type === 'Identifier' && each.key.name === 'interactive') : undefined
|
|
106
|
-
|
|
107
|
-
if (property?.type === 'Property' && interactiveProps(script) === undefined)
|
|
108
|
-
return [{ ...script.moduleFence!.shift(property), code: 'fence-invalid', message: '`interactive` is read only as an object of booleans written in place, each prop with whether it is on when a use leaves it out', help: 'write `interactive: { sortable: true, selectable: false }`' }]
|
|
109
|
-
|
|
110
|
-
if (property?.type === 'Property' && property.value.type === 'ObjectExpression' && property.value.properties.some(each => each.type !== 'Property' || each.key.type !== 'Identifier' || each.value.type !== 'Literal' || typeof each.value.value !== 'boolean'))
|
|
111
|
-
return [{ ...script.moduleFence!.shift(property), code: 'fence-invalid', message: 'Every prop of `interactive` must be a name given `true` or `false`', help: 'write `interactive: { sortable: true, selectable: false }`' }]
|
|
34
|
+
if (named || listed)
|
|
35
|
+
return [{ ...script.moduleFence!.shift(statement), code: 'fence-invalid', message: 'A component declares `island({ hydrate, persist, interactive })` first in its script, and its `--- module` fence exports no `island`', help: 'write the call at the top of the script and drop the export' }]
|
|
112
36
|
}
|
|
113
37
|
|
|
114
38
|
return []
|
|
115
39
|
}
|
|
116
40
|
|
|
117
|
-
// Whether the `--- module` fence has `export const island = { hydrate, persist }`: what the component asks of every parent that uses it.
|
|
118
|
-
export function exportsIslandOptions(script: ScriptAnalysis): boolean {
|
|
119
|
-
return script.island === undefined ? islandExport(script)?.form === 'const' : script.island.asks !== undefined
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// What the generated module hands `island()` of what the component asks of its parents: the `island` its `--- module` fence exports, or the object its `island()` call says.
|
|
123
|
-
export function asksOf(script: ScriptAnalysis): string {
|
|
124
|
-
return script.island?.asks ?? 'island'
|
|
125
|
-
}
|
|
126
|
-
|
|
127
41
|
// The message keys an island's source names, as the third argument to `island()`, with the flag of a lone button's form when it writes one, or nothing for an island naming none; the live values it imports go last.
|
|
128
42
|
// Under `kay dev` the cause goes last, as the `data-why` the dev tool shows. A component exporting `island` passes it last of all.
|
|
129
43
|
export function islandMessages(source: string, client = false, lives: string[] = [], cause?: string, fallback = false, options: string | false = false, wrapsButtons = false): string {
|
|
@@ -143,3 +57,11 @@ export function islandMessages(source: string, client = false, lives: string[] =
|
|
|
143
57
|
|
|
144
58
|
return keys.length > 0 ? `, ${JSON.stringify(keys)}` : ''
|
|
145
59
|
}
|
|
60
|
+
|
|
61
|
+
// The export of an island that lists `interactive` props, its type keeping the list, so a use turning none of them on, which renders as markup, can be handed a function; unchanged for a component that is an island in every use.
|
|
62
|
+
export function islandExport(expression: string, island: IslandDeclaration | undefined, options: { client?: boolean | undefined, lives?: string[] | undefined }): string {
|
|
63
|
+
if (island?.interactive === undefined || options.client || (options.lives?.length ?? 0) > 0 || island.hydrate !== undefined || island.persist !== undefined)
|
|
64
|
+
return `\nexport default ${expression}\n`
|
|
65
|
+
|
|
66
|
+
return `\nimport type { IslandAsked as KayIslandAsked } from 'kay'\nconst KayIslandExport = ${expression}\nexport default KayIslandExport as typeof KayIslandExport & KayIslandAsked<${JSON.stringify(island.interactive)}>\n`
|
|
67
|
+
}
|
|
@@ -5,7 +5,7 @@ export type IslandCauseKind = 'client' | 'island' | 'attribute' | 'value' | 'liv
|
|
|
5
5
|
|
|
6
6
|
export interface IslandCause {
|
|
7
7
|
kind: IslandCauseKind
|
|
8
|
-
// The attribute (`onClick`, `bind:value`, `ref`), the `kay` value (`signal`) or the live value;
|
|
8
|
+
// The attribute (`onClick`, `bind:value`, `ref`), the `kay` value (`signal`) or the live value; `island()` for the declaration.
|
|
9
9
|
name: string
|
|
10
10
|
// Where it is in the file, which the editor reveals.
|
|
11
11
|
span: Span
|
|
@@ -13,7 +13,7 @@ export interface IslandCause {
|
|
|
13
13
|
line: number
|
|
14
14
|
// The `kay` value's module, as `kay`.
|
|
15
15
|
source?: string | undefined
|
|
16
|
-
// The props the component's `island`
|
|
16
|
+
// The props the component's `island()` call says make a use interactive, each with whether it is on when left out: a use turning none on renders no island.
|
|
17
17
|
interactive?: Readonly<Record<string, boolean>> | undefined
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -32,9 +32,9 @@ function staticUse(interactive: Readonly<Record<string, boolean>>): string {
|
|
|
32
32
|
function causeText(cause: IslandCause): string {
|
|
33
33
|
switch (cause.kind) {
|
|
34
34
|
case 'client':
|
|
35
|
-
return
|
|
35
|
+
return 'an `island({ render: \'client\' })` declaration'
|
|
36
36
|
case 'island':
|
|
37
|
-
return
|
|
37
|
+
return 'an `island()` declaration'
|
|
38
38
|
case 'attribute':
|
|
39
39
|
return `\`${cause.name}\`, line ${cause.line}`
|
|
40
40
|
case 'value':
|
|
@@ -48,8 +48,8 @@ function causeText(cause: IslandCause): string {
|
|
|
48
48
|
|
|
49
49
|
// What the cause is, in a few words.
|
|
50
50
|
export const CAUSE_KINDS: Record<IslandCauseKind, string> = {
|
|
51
|
-
client: 'an `island({ render: \'client\' })` declaration
|
|
52
|
-
island: 'an `island()` declaration
|
|
51
|
+
client: 'an `island({ render: \'client\' })` declaration: the component renders in the browser only',
|
|
52
|
+
island: 'an `island()` declaration: the author declared the component an island',
|
|
53
53
|
attribute: 'an `on*`, `bind:` or `ref` attribute: the browser handles it',
|
|
54
54
|
value: 'a `kay` value of the browser, such as `signal` or `effect`, that its script uses',
|
|
55
55
|
live: 'a live value its script imports: the browser follows it',
|
|
@@ -57,4 +57,4 @@ export const CAUSE_KINDS: Record<IslandCauseKind, string> = {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
// The rule, as `kay explain island` says it.
|
|
60
|
-
export const ISLAND_RULE = 'A component is an island when it needs the browser: an `on*`, `bind:` or `ref` in its template, a browser value of `kay` in its script, a live or persisted value it imports, or an `island()` declaration
|
|
60
|
+
export const ISLAND_RULE = 'A component is an island when it needs the browser: an `on*`, `bind:` or `ref` in its template, a browser value of `kay` in its script, a live or persisted value it imports, or an `island()` declaration; what an island renders is part of it. A static component that passes an island a function or a block taking parameters is an `island-prop` error, and is made an island by `island()`. A component whose `island({ interactive })` lists `interactive` props is an island only in a use that turns one on: any other use renders as markup with no script.'
|