@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
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { Collection } from '../content'
|
|
2
|
-
import type { PageSettings } from '../runtime'
|
|
2
|
+
import type { PageSeo, PageSettings } from '../runtime'
|
|
3
3
|
import { KayError } from '../compiler/errors'
|
|
4
4
|
import { SEO_SETTINGS } from '../compiler/page-settings'
|
|
5
5
|
import { isRouteOf } from '../content/claims'
|
|
6
6
|
import { registeredCollections } from '../content/edit-registry'
|
|
7
7
|
import { durationSeconds } from '../runtime/duration'
|
|
8
8
|
|
|
9
|
-
// A setting of a page module: its key of `export const page`, those of `seo` read from there
|
|
10
|
-
export function pageSetting(module: object, name: keyof PageSettings): unknown {
|
|
9
|
+
// A setting of a page module: its key of `export const page`, those of `seo` read from there.
|
|
10
|
+
export function pageSetting(module: object, name: keyof PageSettings | keyof PageSeo): unknown {
|
|
11
11
|
const page = (module as { page?: PageSettings }).page
|
|
12
12
|
|
|
13
|
-
return SEO_SETTINGS.includes(name) ? (
|
|
13
|
+
return SEO_SETTINGS.includes(name) ? (page?.seo as Record<string, unknown> | undefined)?.[name] : page?.[name as keyof PageSettings]
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
// A text of a page's `seo` group, as it is written.
|
|
@@ -61,7 +61,7 @@ function cacheOf(file: string, cache: NonNullable<PageSettings['cache']>): { ttl
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
// A setting along a route's modules, layouts outermost first and the page last: the innermost that sets it wins, so a page may undo what its layouts say.
|
|
64
|
-
export function chainSetting(modules: object[], name: keyof PageSettings): unknown {
|
|
64
|
+
export function chainSetting(modules: object[], name: keyof PageSettings | keyof PageSeo): unknown {
|
|
65
65
|
for (let index = modules.length - 1; index >= 0; index--) {
|
|
66
66
|
const value = pageSetting(modules[index]!, name)
|
|
67
67
|
|
|
@@ -72,25 +72,16 @@ export function chainSetting(modules: object[], name: keyof PageSettings): unkno
|
|
|
72
72
|
return undefined
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
// A page's lifetime and `cache-control` along its route: the `cache` of the innermost module that sets one
|
|
75
|
+
// A page's lifetime and `cache-control` along its route: the `cache` of the innermost module that sets one.
|
|
76
76
|
export function chainCache(file: string, modules: object[]): { ttl: unknown, cacheControl: unknown } {
|
|
77
|
-
let ttl: unknown
|
|
78
|
-
let cacheControl: unknown
|
|
79
|
-
|
|
80
77
|
for (let index = modules.length - 1; index >= 0; index--) {
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
if (page?.cache !== undefined) {
|
|
84
|
-
const given = cacheOf(file, page.cache)
|
|
85
|
-
|
|
86
|
-
return { ttl: ttl ?? given.ttl, cacheControl: cacheControl ?? given.cacheControl }
|
|
87
|
-
}
|
|
78
|
+
const cache = (modules[index] as { page?: PageSettings }).page?.cache
|
|
88
79
|
|
|
89
|
-
|
|
90
|
-
|
|
80
|
+
if (cache !== undefined)
|
|
81
|
+
return cacheOf(file, cache)
|
|
91
82
|
}
|
|
92
83
|
|
|
93
|
-
return { ttl, cacheControl }
|
|
84
|
+
return { ttl: undefined, cacheControl: undefined }
|
|
94
85
|
}
|
|
95
86
|
|
|
96
87
|
interface PageRoute {
|
package/src/server/prerender.ts
CHANGED
|
@@ -46,6 +46,23 @@ import { setupPages } from './setup'
|
|
|
46
46
|
import { STAMP_HOLE } from './stamp'
|
|
47
47
|
|
|
48
48
|
const PARTS = new Intl.ListFormat('en-GB')
|
|
49
|
+
// An island the render marked as reading the query, whose markup is the default query's.
|
|
50
|
+
const QUERY_ISLAND = /<slot data-component="[^"]*" data-props=(?:"[^"]*"|'[^']*')[^>]*? data-query[ >]/g
|
|
51
|
+
|
|
52
|
+
// What the page reads with `live: true` in its own render, which the build runs once.
|
|
53
|
+
function warnUnfollowed(path: string, keys: string[] | undefined): void {
|
|
54
|
+
if (keys !== undefined)
|
|
55
|
+
kayLog('warn', `${path} reads ${keys.slice(0, 5).map(key => `'${key}'`).join(', ')}${keys.length > 5 ? ' and more' : ''} with \`live: true\` in its own render, which the build runs once: what the page shows of it itself goes stale and only its server islands follow, so drop \`prerender\` from \`export const page\` if the page shows it`)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// A page kept on its own reads no query, so only one asked for can hold such an island.
|
|
59
|
+
function warnQueryIslands(path: string, html: string, auto: boolean): void {
|
|
60
|
+
const count = auto ? 0 : [...html.matchAll(QUERY_ISLAND)].length
|
|
61
|
+
|
|
62
|
+
if (count > 0)
|
|
63
|
+
kayLog('warn', `${path} holds ${count === 1 ? 'an island' : `${count} islands`} reading a query param, drawn here at the default query: the browser draws ${count === 1 ? 'it' : 'them'} again when the page is opened with a query, so the markup before that, and with no JavaScript, is the default's`)
|
|
64
|
+
}
|
|
65
|
+
|
|
49
66
|
const LINE_BREAK = /[\r\n]/
|
|
50
67
|
const KAY_IMPORT = /\bfrom\s+['"]([^'"]+\.kay)['"]/g
|
|
51
68
|
// The pages of a route rendering at once: a render waiting on a database, a CMS or a file lets the next ones run, while each page is still judged and written in turn, as one at a time would. Bounded, so the build holds no more pages than this.
|
|
@@ -390,8 +407,8 @@ export async function prerenderPages(project: Project, client: ClientBuild, opti
|
|
|
390
407
|
if (islands.includes('defer') && client.entry === undefined)
|
|
391
408
|
throw new KayError('export-server-render', `kay: it defers a server island, which kay's browser entry fetches, and with no island and \`navigation: false\` the build has none; mark it \`server\` to render it inline instead`)
|
|
392
409
|
|
|
393
|
-
|
|
394
|
-
|
|
410
|
+
warnUnfollowed(copy.path, unfollowed?.keys)
|
|
411
|
+
warnQueryIslands(copy.path, html, auto)
|
|
395
412
|
|
|
396
413
|
const name = `${copy.key === '/' ? 'index' : copy.key.slice(1)}.html`
|
|
397
414
|
const taken = reserved.get(name) ?? paths.get(name)
|
package/src/server/protection.ts
CHANGED
|
@@ -239,7 +239,7 @@ export function sqliteRates(path: string): SyncRates {
|
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
// Answered at once, as a store reading SQLite needs no promise.
|
|
242
|
-
export interface SyncRates { hit: (key: string, window: Duration
|
|
242
|
+
export interface SyncRates { hit: (key: string, window: Duration, weight?: number) => RateWindow, peek: (key: string) => RateWindow | undefined, refund: (key: string, resetAt: number) => void, reset: (key: string) => void }
|
|
243
243
|
type OpenRates = SyncRates & { close: () => void }
|
|
244
244
|
|
|
245
245
|
function openRates(path: string): OpenRates {
|
|
@@ -312,7 +312,7 @@ export interface Limiter {
|
|
|
312
312
|
peek: (key: string) => Promise<RateWindow | undefined>
|
|
313
313
|
// Forgets the window under `key`. A store with no `reset` has the count taken off with a hit of the negative weight, which leaves an empty window open.
|
|
314
314
|
reset: (key: string) => Promise<void>
|
|
315
|
-
// Counts an attempt under `key` and answers the seconds to wait once the count is past `max`, else undefined; it answers and refuses nothing. Not `rateLimit().
|
|
315
|
+
// Counts an attempt under `key` and answers the seconds to wait once the count is past `max`, else undefined; it answers and refuses nothing. Not `rateLimit().check(ctx)`, which takes a guard's context and denies with 429.
|
|
316
316
|
enforce: (key: string, weight?: number) => Promise<number | undefined>
|
|
317
317
|
// Takes back one attempt `hit` counted in the window closing at `resetAt`; false when the store has no `refund`.
|
|
318
318
|
refund: (key: string, resetAt: number) => Promise<boolean>
|
|
@@ -349,7 +349,7 @@ export function makeLimiter({ name, max, ms, store: given, failure, memory }: {
|
|
|
349
349
|
return standIn.rates
|
|
350
350
|
}
|
|
351
351
|
const keyed = (key: string) => `${name}\n${key}`
|
|
352
|
-
const hitIn = async (used: RateStore, key: string, weight?: number) => used.hit(keyed(key), lengthFor(
|
|
352
|
+
const hitIn = async (used: RateStore, key: string, weight?: number) => used.hit(keyed(key), lengthFor(ms), weight)
|
|
353
353
|
|
|
354
354
|
const peek = async (key: string): Promise<RateWindow | undefined> => {
|
|
355
355
|
const used = store()
|
|
@@ -357,7 +357,7 @@ export function makeLimiter({ name, max, ms, store: given, failure, memory }: {
|
|
|
357
357
|
if (used.peek)
|
|
358
358
|
return used.peek(keyed(key))
|
|
359
359
|
|
|
360
|
-
const window = await used.hit(keyed(key), lengthFor(
|
|
360
|
+
const window = await used.hit(keyed(key), lengthFor(ms), 0)
|
|
361
361
|
|
|
362
362
|
return window.count > 0 ? window : undefined
|
|
363
363
|
}
|
|
@@ -381,10 +381,10 @@ export function makeLimiter({ name, max, ms, store: given, failure, memory }: {
|
|
|
381
381
|
return
|
|
382
382
|
|
|
383
383
|
// The window may have closed between the two calls, which a hit of minus the count would open at a negative count.
|
|
384
|
-
const left = await used.hit(keyed(key), lengthFor(
|
|
384
|
+
const left = await used.hit(keyed(key), lengthFor(ms), -window.count)
|
|
385
385
|
|
|
386
386
|
if (left.count < 0)
|
|
387
|
-
await used.hit(keyed(key), lengthFor(
|
|
387
|
+
await used.hit(keyed(key), lengthFor(ms), -left.count)
|
|
388
388
|
},
|
|
389
389
|
enforce: async (key, weight) => waitFor(await hitIn(store(), key, weight), max),
|
|
390
390
|
refund: async (key, resetAt) => {
|
|
@@ -715,7 +715,7 @@ export function ratesFor(name: string, given?: RateStore): RateStore {
|
|
|
715
715
|
|
|
716
716
|
// What a store falls back on, answering at once.
|
|
717
717
|
export interface FallbackMemory {
|
|
718
|
-
hit: (key: string,
|
|
718
|
+
hit: (key: string, window: Duration, weight?: number) => RateWindow
|
|
719
719
|
peek: (key: string) => RateWindow | undefined
|
|
720
720
|
refund?: ((key: string, resetAt: number) => void) | undefined
|
|
721
721
|
reset?: ((key: string) => void) | undefined
|
|
@@ -730,7 +730,7 @@ export function ratesFallingBack<Store extends RateStore>(name: string, store: S
|
|
|
730
730
|
|
|
731
731
|
// Each method is read off the store on each call, so one replaced on it later, as a test spies on it, is the one called.
|
|
732
732
|
return {
|
|
733
|
-
hit: async (key, window, weight) => answered(name, store, (...args: [string, Duration
|
|
733
|
+
hit: async (key, window, weight) => answered(name, store, (...args: [string, Duration, number | undefined]): ReturnType<RateStore['hit']> => store.hit(...args), [key, lengthFor(lengthMs(window)), weight], () => memory.hit(key, lengthFor(lengthMs(window)), weight)),
|
|
734
734
|
...peek && { peek: async key => answered(name, store, store.peek ?? peek, [key], () => memory.peek(key)) },
|
|
735
735
|
// Taken back in memory too, where the attempt was counted if the store failed then; memory only takes it off a window closing at that same `resetAt`.
|
|
736
736
|
...refund && { refund: async (key, resetAt) => {
|
|
@@ -854,15 +854,12 @@ export function rateKey(address: string): string {
|
|
|
854
854
|
return `${groups.slice(0, 4).map(group => group.replace(LEADING_ZEROS, '')).join(':')}::/64`
|
|
855
855
|
}
|
|
856
856
|
|
|
857
|
-
// `true` is one proxy in front
|
|
858
|
-
function proxyOf(setting: ProxyConfig |
|
|
857
|
+
// `true` is one proxy in front, the short form of `{ hops: 1 }`.
|
|
858
|
+
function proxyOf(setting: ProxyConfig | boolean | undefined): ProxyConfig | undefined {
|
|
859
859
|
if (setting === false)
|
|
860
860
|
return undefined
|
|
861
861
|
|
|
862
|
-
|
|
863
|
-
return { hops: 1 }
|
|
864
|
-
|
|
865
|
-
return typeof setting === 'number' ? { hops: setting } : setting
|
|
862
|
+
return setting === true ? { hops: 1 } : setting
|
|
866
863
|
}
|
|
867
864
|
|
|
868
865
|
// The server that received `request`, once the app read it.
|
|
@@ -871,7 +868,7 @@ export function requestServer(request: Request): Server<unknown> | undefined {
|
|
|
871
868
|
}
|
|
872
869
|
|
|
873
870
|
// Refuses a `proxy` setting that names no proxy, so the boot can before any build starts.
|
|
874
|
-
export function checkProxy(setting: ProxyConfig |
|
|
871
|
+
export function checkProxy(setting: ProxyConfig | boolean | undefined): ProxyConfig | undefined {
|
|
875
872
|
const proxy = proxyOf(setting)
|
|
876
873
|
|
|
877
874
|
if (!proxy)
|
|
@@ -904,7 +901,7 @@ export function checkProxy(setting: ProxyConfig | number | boolean | undefined):
|
|
|
904
901
|
|
|
905
902
|
// Records the app's proxy settings on each request it gets, for `clientAddress` to read them wherever it is called from.
|
|
906
903
|
// In production a `proxy` left out is one proxy in front, read from private addresses only: a server there is behind one far more often than it faces visitors, and `false` says it is not.
|
|
907
|
-
export function trustProxy(setting: ProxyConfig |
|
|
904
|
+
export function trustProxy(setting: ProxyConfig | boolean | undefined): ReceiveStep {
|
|
908
905
|
const proxy = checkProxy(setting) ?? (setting === undefined && process.env.NODE_ENV === 'production' ? INFERRED_PROXY : undefined)
|
|
909
906
|
|
|
910
907
|
return (request, server) => {
|
|
@@ -921,12 +918,12 @@ export function trustProxy(setting: ProxyConfig | number | boolean | undefined):
|
|
|
921
918
|
|
|
922
919
|
// The socket's address, unless it is a proxy on this machine or network the app's `proxy` setting trusts: then the client's address as that proxy passed it on.
|
|
923
920
|
// `proxy` stands in for the app's setting, for a plain Elysia app that `pages()` does not serve.
|
|
924
|
-
export function clientAddress(request: Request, server: Server<unknown> | null | undefined, setting?: ProxyConfig |
|
|
921
|
+
export function clientAddress(request: Request, server: Server<unknown> | null | undefined, setting?: ProxyConfig | boolean): string {
|
|
925
922
|
return knownAddress(request, server, setting) ?? 'unknown'
|
|
926
923
|
}
|
|
927
924
|
|
|
928
925
|
// `clientAddress`, or undefined for a request with no socket address and none a trusted proxy forwarded, which `clientAddress` counts as the one client `unknown`.
|
|
929
|
-
export function knownAddress(request: Request, server: Server<unknown> | null | undefined, setting?: ProxyConfig |
|
|
926
|
+
export function knownAddress(request: Request, server: Server<unknown> | null | undefined, setting?: ProxyConfig | boolean): string | undefined {
|
|
930
927
|
const proxy = proxyOf(setting)
|
|
931
928
|
const record = recordOf(request)
|
|
932
929
|
const address = rewrittenAddress(request) ?? (server ?? record?.server)?.requestIP(request)?.address
|
package/src/server/queue.ts
CHANGED
|
@@ -113,8 +113,6 @@ export interface QueueOptions<Payload> {
|
|
|
113
113
|
concurrency?: number | undefined
|
|
114
114
|
// How long a run may take: past it, the run counts as failed, its signal aborts and its worker is freed, and another process takes a job its dead process held as lost. 10 minutes by default, the name a schedule's limit has too.
|
|
115
115
|
timeout?: Duration | undefined
|
|
116
|
-
/** @deprecated `timeout`, the one name of a job's time limit. Removed in 1.108; `deprecated-job-options` rewrites it. */
|
|
117
|
-
lostAfter?: Duration | undefined
|
|
118
116
|
// `false` runs nothing: the queue starts no worker, so a job needing an optional service is switched by its setting, `enabled: url !== undefined`, as a schedule is. A job enqueued meanwhile waits in the store for a process that runs the queue.
|
|
119
117
|
enabled?: boolean | undefined
|
|
120
118
|
// The longest an idle queue waits between looks at the store, 10 seconds by default.
|
|
@@ -468,17 +466,16 @@ export function defaultJobStore(): JobStore {
|
|
|
468
466
|
// A queue of jobs the server runs in the background, each surviving a restart: `enqueue` from an action, `app.use(queue)` in the server to run them.
|
|
469
467
|
// A run that throws is retried later, waiting `backoff` then twice as long each time, until `attempts` runs failed: it is then kept as failed, logged and handed to `onError`.
|
|
470
468
|
export function queue<Payload, Progress = unknown>(name: string, handler: (payload: Payload, ctx: JobContext<Progress>) => unknown, options: QueueOptions<Payload> = {}): Queue<Payload, Progress> {
|
|
471
|
-
|
|
472
|
-
return jobQueue<Payload, Progress>(name, (payload, ctx) => (handler as (payload: Payload, ctx: JobContext<Progress>, job: JobRef<Progress>) => unknown)(payload, ctx, ctx.job), options).queued
|
|
469
|
+
return jobQueue<Payload, Progress>(name, handler, options).queued
|
|
473
470
|
}
|
|
474
471
|
|
|
475
472
|
const REMOVED_OPTIONS = { onFailed: '`onError`, which also gets `id` and `attempts`', keepFailed: '`failedTtl`' }
|
|
476
473
|
|
|
477
474
|
// `queue` for `workflow`: its handler also gets the hold of its run, and the admin it returns is what the workflow wakes its own queue and attaches its calls with.
|
|
478
|
-
export function jobQueue<Payload, Progress = unknown>(name: string, handler: (payload: Payload, ctx: JobContext<Progress
|
|
475
|
+
export function jobQueue<Payload, Progress = unknown>(name: string, handler: (payload: Payload, ctx: JobContext<Progress>, run: RunHold) => unknown, options: QueueOptions<Payload> = {}, kind: 'queue' | 'workflow' = 'queue'): { queued: Queue<Payload, Progress>, admin: QueueAdmin } {
|
|
479
476
|
const attempts = options.attempts ?? DEFAULT_ATTEMPTS
|
|
480
477
|
const backoff = durationSeconds(options.backoff ?? DEFAULT_BACKOFF, `queue('${name}')'s backoff`) * 1000
|
|
481
|
-
const lostAfter = durationSeconds(options.timeout ??
|
|
478
|
+
const lostAfter = durationSeconds(options.timeout ?? DEFAULT_LOST_AFTER, `queue('${name}')'s timeout`) * 1000
|
|
482
479
|
const concurrency = options.concurrency ?? 1
|
|
483
480
|
const idlePoll = durationSeconds(options.idlePoll ?? DEFAULT_IDLE_POLL, `queue('${name}')'s idlePoll`) * 1000
|
|
484
481
|
const keepFailed = options.failedTtl === false ? undefined : durationSeconds(options.failedTtl ?? DEFAULT_KEEP_FAILED, `queue('${name}')'s failedTtl`) * 1000
|
package/src/server/rate-limit.ts
CHANGED
|
@@ -16,8 +16,6 @@ export interface RateLimiter extends RateLimit {
|
|
|
16
16
|
count: (from: Request | string, server?: Server<unknown> | null, weight?: number) => Promise<RateWindow & { wait: number | undefined }>
|
|
17
17
|
// For a guard: takes its `ctx`, counts the request under the limit's `key` or the client's address and, once over the limit, sets `Retry-After` and denies with 429, `message` (a text or a function of the seconds to wait) in place of kay's.
|
|
18
18
|
check: (ctx: Pick<GuardContext, 'request' | 'headers' | 'deny' | 'locale' | 'cookies' | 'locals'>, message?: string | ((wait: number) => string)) => Promise<void>
|
|
19
|
-
/** @deprecated `check(ctx, message?)`, as `limiter().enforce(key)` counts under a key and refuses nothing. Removed in 1.108; `deprecated-rate-enforce` rewrites it. */
|
|
20
|
-
enforce: (ctx: Pick<GuardContext, 'request' | 'headers' | 'deny' | 'locale' | 'cookies' | 'locals'>, message?: string | ((wait: number) => string)) => Promise<void>
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
// A limit for a guard, an API route or a library, counted as an action's `rateLimit` is: `max` attempts from one client every `window`, under `name`, which limits sharing it count together.
|
|
@@ -53,7 +51,6 @@ export function rateLimit(name: string, limit: RateLimit): RateLimiter {
|
|
|
53
51
|
...limit,
|
|
54
52
|
count,
|
|
55
53
|
hit: async (from, server, weight) => (await count(from, server, weight)).wait,
|
|
56
|
-
enforce: async (ctx, message) => limiter.check(ctx, message),
|
|
57
54
|
check: async (ctx, message) => {
|
|
58
55
|
const { request } = ctx
|
|
59
56
|
const key = await actionKey(name, limiter, request, clientAddress(request, undefined), () => ({ request, locale: ctx.locale, cookies: ctx.cookies, locals: ctx.locals }))
|
|
@@ -21,7 +21,7 @@ import { collectHead, head as setHead } from '../runtime/head'
|
|
|
21
21
|
import { child, component, html, newServerIslands, withinComponent, withServerIslands } from '../runtime/html'
|
|
22
22
|
import { localePath, textDirection } from '../runtime/i18n'
|
|
23
23
|
import { DEFAULT_MAX_DENSITY, RESOLVED_META } from '../runtime/image'
|
|
24
|
-
import { unrevivableAction } from '../runtime/island.server'
|
|
24
|
+
import { inLayout, unrevivableAction } from '../runtime/island.server'
|
|
25
25
|
import { resourcesUsed, resourcesWanted, withSeeds } from '../runtime/live-resource.server'
|
|
26
26
|
import { localeState } from '../runtime/locale-state'
|
|
27
27
|
import { kayLog } from '../runtime/log'
|
|
@@ -163,7 +163,7 @@ function outcomeScript(outcome: Outcome | null): string {
|
|
|
163
163
|
text = encodeValue(outcome.succeeded ? outcome : { ...outcome, values: {} })
|
|
164
164
|
}
|
|
165
165
|
catch (error) {
|
|
166
|
-
kayLog('warn', `what ${outcome.action} ${outcome.succeeded ? 'returned' : 'passed to ctx.
|
|
166
|
+
kayLog('warn', `what ${outcome.action} ${outcome.succeeded ? 'returned' : 'passed to ctx.deny'} cannot reach the page's islands: ${unsendable(error) ?? String(error)}`)
|
|
167
167
|
|
|
168
168
|
return ''
|
|
169
169
|
}
|
|
@@ -359,10 +359,12 @@ function registerSeo(module: PageModule): void {
|
|
|
359
359
|
|
|
360
360
|
// The page inside its layouts, each through `component`, so what a layout provides reaches its page.
|
|
361
361
|
// A layout's named slot is read off its page: reading one renders the page first, once, which hands the layout the blocks it wrote.
|
|
362
|
-
export function viewOf(modules: PageModule[], data: Record<string, unknown>[], entry?: HeadTag[]): () => unknown {
|
|
362
|
+
export function viewOf(modules: PageModule[], data: Record<string, unknown>[], entry?: HeadTag[], files?: readonly string[]): () => unknown {
|
|
363
363
|
const page = modules.length - 1
|
|
364
364
|
const chain = newFillChain(modules.length)
|
|
365
365
|
const declared = modules.map(module => module.slots)
|
|
366
|
+
// The layout a module renders as, for the islands it draws to carry it: none for the page.
|
|
367
|
+
const layoutOf = (index: number) => index < page && files?.[index] !== undefined ? projectPath(files[index]) : undefined
|
|
366
368
|
|
|
367
369
|
// Set after its layouts' heads and before its own, which each replace what the entry gave.
|
|
368
370
|
let view = () => {
|
|
@@ -373,7 +375,7 @@ export function viewOf(modules: PageModule[], data: Record<string, unknown>[], e
|
|
|
373
375
|
|
|
374
376
|
registerSeo(modules[page]!)
|
|
375
377
|
|
|
376
|
-
return component(modules[page]!.default, data[page]!)
|
|
378
|
+
return inLayout(undefined, () => component(modules[page]!.default, data[page]!))
|
|
377
379
|
}
|
|
378
380
|
|
|
379
381
|
for (let index = page - 1; index >= 0; index--) {
|
|
@@ -400,14 +402,14 @@ export function viewOf(modules: PageModule[], data: Record<string, unknown>[], e
|
|
|
400
402
|
|
|
401
403
|
const found = filledBy(chain, declared, index, name)
|
|
402
404
|
|
|
403
|
-
return found && withinComponent(modules[found.at]!.default, found.block)
|
|
405
|
+
return found && inLayout(layoutOf(found.at), () => withinComponent(modules[found.at]!.default, found.block))
|
|
404
406
|
} })
|
|
405
407
|
}
|
|
406
408
|
|
|
407
409
|
chain.at = index
|
|
408
410
|
registerSeo(modules[index]!)
|
|
409
411
|
|
|
410
|
-
return component(modules[index]!.default, props)
|
|
412
|
+
return inLayout(layoutOf(index), () => component(modules[index]!.default, props))
|
|
411
413
|
}
|
|
412
414
|
}
|
|
413
415
|
|
|
@@ -451,7 +453,7 @@ function seedBlocks(deferred: PendingBlock[], seeds: ReadonlyMap<string, Seed>):
|
|
|
451
453
|
}
|
|
452
454
|
|
|
453
455
|
function documentOf(files: string[], modules: PageModule[], data: Record<string, unknown>[], client: ClientBuild, rendering: Rendering, options: RenderOptions, rules: QueryRules | undefined, entry?: HeadTag[]): string | Pieced | ReadableStream<Uint8Array> {
|
|
454
|
-
const view = viewOf(modules, data, entry)
|
|
456
|
+
const view = viewOf(modules, data, entry, files)
|
|
455
457
|
const chunks = islandChunks(client)
|
|
456
458
|
// A prerendered page holds each server island between marks the server splits it at.
|
|
457
459
|
const scan = options.prerendering ? Object.assign(newServerIslands(true), { awaits: options.awaits }) : undefined
|
package/src/server/render.ts
CHANGED
|
@@ -664,7 +664,7 @@ export async function renderServerIslands(route: ServedRoute, context: RequestCo
|
|
|
664
664
|
}
|
|
665
665
|
}, () => rendering.headers.append('vary', 'cookie'), rules)
|
|
666
666
|
const chunks = islandChunks(client)
|
|
667
|
-
const { deferred, islands: shell } = inScope(() => withServerIslands(islands, () => renderStatic(viewOf(page.modules, page.data), undefined, chunks)))
|
|
667
|
+
const { deferred, islands: shell } = inScope(() => withServerIslands(islands, () => renderStatic(viewOf(page.modules, page.data, undefined, page.files), undefined, chunks)))
|
|
668
668
|
const unrevivable = unrevivableAction(shell, client)
|
|
669
669
|
|
|
670
670
|
if (unrevivable)
|
package/src/server/routes.ts
CHANGED
|
@@ -74,7 +74,7 @@ export interface Route {
|
|
|
74
74
|
special: SpecialPages
|
|
75
75
|
// `_guard.ts` files covering the page and its actions, outermost first.
|
|
76
76
|
guards: GuardFile[]
|
|
77
|
-
// No guard is asked of it on a site with `
|
|
77
|
+
// No guard is asked of it on a site with `guards.default` closed: it sets `guards: false`, or a library serves it.
|
|
78
78
|
open?: true | undefined
|
|
79
79
|
// The extension giving the editor serves it: one of its own screens, which renders no editor over it in edit mode.
|
|
80
80
|
editorOwn?: true | undefined
|
|
@@ -240,12 +240,13 @@ export function servedPaths(routes: Route[]): Set<string> {
|
|
|
240
240
|
return new Set(routes.flatMap(route => patternShapes(route.pattern)))
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
// Every file the reach walk meets while scanning the routes
|
|
243
|
+
// Every file the reach walk meets while scanning the routes, the fallback pages and the endpoints, with what it reads of each, for `kay build` to record.
|
|
244
244
|
export async function contextReadsOf(routesDir: string, mounts: RouteMount[]): Promise<ContextReads> {
|
|
245
245
|
const reads: ContextReads = { keys: new Map(), edges: new Map(), recorded: false }
|
|
246
246
|
|
|
247
247
|
await scanRoutes(routesDir, mounts, reads)
|
|
248
248
|
await specialPagesOf(routeTrees(routesDir, mounts), '', reads)
|
|
249
|
+
await scanEndpoints(routesDir, mounts, reads)
|
|
249
250
|
|
|
250
251
|
return reads
|
|
251
252
|
}
|
|
@@ -299,7 +300,10 @@ export async function scanRoutes(routesDir: string, mounts: RouteMount[] = [], r
|
|
|
299
300
|
}
|
|
300
301
|
|
|
301
302
|
// The app's endpoint files, then each mounted library's that the app has none of at the same path.
|
|
302
|
-
|
|
303
|
+
// Their guards place the special pages' layouts, so what the pages reach is open first, as a lookup of special pages opens it.
|
|
304
|
+
export async function scanEndpoints(routesDir: string, mounts: RouteMount[] = [], reads?: ContextReads): Promise<Endpoint[]> {
|
|
305
|
+
await openReaches(mounts, reads, false)
|
|
306
|
+
|
|
303
307
|
const trees = routeTrees(routesDir, mounts)
|
|
304
308
|
const endpoints: Endpoint[] = []
|
|
305
309
|
const read: LayoutsRead = new Map()
|
package/src/server/scope.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { LoadScope, ServerScope } from '../runtime/reactive'
|
|
|
4
4
|
import { AsyncLocalStorage } from 'node:async_hooks'
|
|
5
5
|
import { setRequestOutcome } from '../runtime/action'
|
|
6
6
|
import { setEndedEntryNote } from '../runtime/ended-entry'
|
|
7
|
+
import { noteQuery } from '../runtime/island.server'
|
|
7
8
|
import { readParam } from '../runtime/query-param'
|
|
8
9
|
import { setRequestCookieScope, setServerScope } from '../runtime/reactive'
|
|
9
10
|
import { setCurrentUrl } from '../runtime/with-query'
|
|
@@ -51,7 +52,7 @@ export function inServerScope<T>(request: Request, report: (error: unknown) => v
|
|
|
51
52
|
|
|
52
53
|
const url = requestUrl(request)
|
|
53
54
|
|
|
54
|
-
return store.run({ request, values: new WeakMap(), cookie, param: name => readParam(rules, name, url.searchParams), report, path: url.pathname }, run)
|
|
55
|
+
return store.run({ request, values: new WeakMap(), cookie, param: name => readParam(rules, name, url.searchParams), read: noteQuery, report, path: url.pathname }, run)
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
// The request the render being run answers.
|
|
@@ -63,7 +64,7 @@ const outcomes = new AsyncLocalStorage<() => Outcome | null>()
|
|
|
63
64
|
|
|
64
65
|
setRequestOutcome(() => outcomes.getStore()?.())
|
|
65
66
|
|
|
66
|
-
// Answers a request whose form post, if any, `read` gives: an action's `form.failed()` and `
|
|
67
|
+
// Answers a request whose form post, if any, `read` gives: an action's `form.failed()` and `data()` read it in its loads and templates alike.
|
|
67
68
|
export function withOutcome<T>(read: () => Outcome | null, run: () => T): T {
|
|
68
69
|
return outcomes.run(read, run)
|
|
69
70
|
}
|
package/src/server/session.ts
CHANGED
|
@@ -41,9 +41,8 @@ export type DeletableSessionStore = SessionStore & { deleteWhere: (match: Sessio
|
|
|
41
41
|
// Where sessions live when the cookie only carries their id; each method may answer synchronously or with a promise.
|
|
42
42
|
export interface SessionStore extends StoreBase {
|
|
43
43
|
get: (id: string) => MaybePromise<SessionData | undefined>
|
|
44
|
-
// Past `maxAge` the store may forget the session: a `Duration
|
|
45
|
-
|
|
46
|
-
set(id: string, data: SessionData, maxAge: Duration | number): MaybePromise<void>
|
|
44
|
+
// Past `maxAge` the store may forget the session: a `Duration`; `lengthMs(maxAge)` from `kay` reads it.
|
|
45
|
+
set: (id: string, data: SessionData, maxAge: Duration) => MaybePromise<void>
|
|
47
46
|
delete: (id: string) => MaybePromise<void>
|
|
48
47
|
// Deletes every session whose data `match` returns true for, such as a person's once they asked to be erased or their password changed, resolving with how many went.
|
|
49
48
|
deleteWhere?: ((match: (data: SessionData) => boolean) => MaybePromise<number>) | undefined
|
|
@@ -422,7 +421,7 @@ class RequestSession<Data extends object> implements Session<Data> {
|
|
|
422
421
|
|
|
423
422
|
if (store) {
|
|
424
423
|
this.id ??= nodeCrypto().randomBytes(32).toString('base64url')
|
|
425
|
-
await store.set(this.id, this.data, lengthFor(
|
|
424
|
+
await store.set(this.id, this.data, lengthFor(maxAge * 1000))
|
|
426
425
|
sealed = { id: this.id, issued: now, started, ...this.own }
|
|
427
426
|
}
|
|
428
427
|
|
|
@@ -526,8 +525,8 @@ function opened(value: string, keys: Buffer[], name: string): { sealed: Sealed,
|
|
|
526
525
|
}
|
|
527
526
|
}
|
|
528
527
|
|
|
529
|
-
// The `maxAge` a store is given, a `Duration
|
|
530
|
-
function storeMs(maxAge: Duration
|
|
528
|
+
// The `maxAge` a store is given, a `Duration`: one that is not would store a session that never expires, or none.
|
|
529
|
+
function storeMs(maxAge: Duration): number {
|
|
531
530
|
return lengthMs(maxAge, 'a session store\'s maxAge')
|
|
532
531
|
}
|
|
533
532
|
|
package/src/server/setup.ts
CHANGED
|
@@ -126,7 +126,7 @@ async function setupWith<Claimed>(project: Project, loadClient: () => Promise<Cl
|
|
|
126
126
|
|
|
127
127
|
await source.prepare(root, config.librarySettings, mode.prebuilt ? paths.output : undefined)
|
|
128
128
|
// Scanned beside the routes, which the refusals before the build need.
|
|
129
|
-
const scanning = Promise.all([publicFiles(paths.public), source.endpoints(
|
|
129
|
+
const scanning = Promise.all([publicFiles(paths.public), source.endpoints(project, mounts)])
|
|
130
130
|
|
|
131
131
|
void Promise.allSettled([scanning])
|
|
132
132
|
|
package/src/server/signals.ts
CHANGED
|
@@ -71,6 +71,12 @@ export class Denied {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
// The text form `deny(403, 'text')` went in 1.109: a string where the options go is a mistake to name, not a refusal with no message.
|
|
75
|
+
function refuseText(options: unknown): void {
|
|
76
|
+
if (typeof options === 'string')
|
|
77
|
+
throw new KayError('argument-invalid', 'kay: ctx.deny takes a status and `{ message, errors, data }`: write `ctx.deny(403, { message: \'text\' })`')
|
|
78
|
+
}
|
|
79
|
+
|
|
74
80
|
// What `ctx.redirect`, `ctx.notFound` and `ctx.deny` do in every kind of context: a read is redirected with 302, a post with 303.
|
|
75
81
|
export function stoppers(request: Request): Pick<RequestContext, 'redirect' | 'notFound' | 'deny'> {
|
|
76
82
|
const status = request.method === 'GET' || request.method === 'HEAD' ? 302 : 303
|
|
@@ -82,24 +88,28 @@ export function stoppers(request: Request): Pick<RequestContext, 'redirect' | 'n
|
|
|
82
88
|
notFound: () => {
|
|
83
89
|
throw new NotFound()
|
|
84
90
|
},
|
|
85
|
-
deny: (code
|
|
86
|
-
|
|
91
|
+
deny: (code?: number, options?: DenyOptions<ErrorData>) => {
|
|
92
|
+
refuseText(options)
|
|
93
|
+
|
|
94
|
+
throw new Denied(code ?? 403, options?.message, options?.data, options?.errors as Record<string, string> | undefined)
|
|
87
95
|
},
|
|
88
96
|
}
|
|
89
97
|
}
|
|
90
98
|
|
|
91
|
-
// `ctx.deny(status, { message, errors, data })` in an action fails the post
|
|
99
|
+
// `ctx.deny(status, { message, errors, data })` in an action fails the post, a form re-rendered with the message, the fields and `data`, a call throwing an `ActionError`. A deny with no options stops as a guard's does.
|
|
92
100
|
export function actionStoppers(request: Request): Pick<RequestContext, 'redirect' | 'notFound' | 'deny'> {
|
|
93
101
|
const { deny: stop, ...rest } = stoppers(request)
|
|
94
102
|
|
|
95
|
-
const deny = (status = 403, second?:
|
|
96
|
-
|
|
97
|
-
return stop(status, second as string, data)
|
|
103
|
+
const deny = (status = 403, second?: DenyOptions<ErrorData>): never => {
|
|
104
|
+
refuseText(second)
|
|
98
105
|
|
|
99
106
|
if (second === undefined || ((second.message === undefined || second.message === '') && second.data === undefined && Object.keys(second.errors ?? {}).length === 0))
|
|
100
107
|
return stop(status)
|
|
101
108
|
|
|
102
|
-
|
|
109
|
+
if (!Number.isInteger(status) || status < 400 || status > 599)
|
|
110
|
+
throw new KayError('argument-invalid', `kay: ctx.deny takes an error status, from 400 to 599, not ${status}`)
|
|
111
|
+
|
|
112
|
+
// A text `data` with no `message` is the form's message; one with only data or fields has none.
|
|
103
113
|
throw new RefusedError({ status, message: second.message ?? (typeof second.data === 'string' ? second.data : ''), errors: (second.errors ?? {}) as Record<string, string>, data: second.data })
|
|
104
114
|
}
|
|
105
115
|
|
package/src/server/signed.ts
CHANGED
|
@@ -6,8 +6,6 @@ import { signedText, signText, useScriptSecret } from './stamp'
|
|
|
6
6
|
export interface SignOptions {
|
|
7
7
|
// How long the signature stays valid: `'1h'` when left out.
|
|
8
8
|
ttl?: Duration | undefined
|
|
9
|
-
/** @deprecated Written `ttl`; `deprecated-ttl-names` rewrites it. Removed in 1.108. */
|
|
10
|
-
maxAge?: Duration | undefined
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
const DEFAULT_TTL = '1h'
|
|
@@ -36,7 +34,7 @@ export const signed = {
|
|
|
36
34
|
sign(use: string, value: string, options: SignOptions = {}): string {
|
|
37
35
|
checked(use, value)
|
|
38
36
|
|
|
39
|
-
const seconds = durationSeconds(options.ttl ??
|
|
37
|
+
const seconds = durationSeconds(options.ttl ?? DEFAULT_TTL, 'signed.sign()\'s ttl')
|
|
40
38
|
|
|
41
39
|
if (seconds > MAX_SECONDS)
|
|
42
40
|
throw new KayError('argument-invalid', 'kay: signed.sign()\'s ttl is at most 1 year (\'52w\')')
|
package/src/server/source.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { Mode, Project } from '../project'
|
|
|
3
3
|
import type { ApiModule } from './api-modules'
|
|
4
4
|
import type { Bundle } from './bundle'
|
|
5
5
|
import type { ClientBuild } from './client'
|
|
6
|
+
import type { ContextReads } from './context-record'
|
|
6
7
|
import type { Endpoint, Route, RouteMount, SpecialPages } from './routes'
|
|
7
8
|
import type { ToolOutputs } from './tool-outputs'
|
|
8
9
|
import { existsSync } from 'node:fs'
|
|
@@ -38,7 +39,7 @@ export interface ProjectSource {
|
|
|
38
39
|
routes: (project: Pick<Project, 'root' | 'mode' | 'paths'>, mounts: RouteMount[]) => Promise<Route[]>
|
|
39
40
|
fallback: (project: Pick<Project, 'root' | 'mode' | 'paths'>, mounts: RouteMount[]) => Promise<SpecialPages>
|
|
40
41
|
api: (root: string, config: Pick<KayConfig, 'dirs' | 'extensions' | 'endpoints'>) => Promise<ApiModule[]>
|
|
41
|
-
endpoints: (
|
|
42
|
+
endpoints: (project: Pick<Project, 'root' | 'mode' | 'paths'>, mounts: RouteMount[]) => Promise<Endpoint[]>
|
|
42
43
|
// The file names under `src/plugins`: an executable holds the ones it was built with.
|
|
43
44
|
plugins: (root: string) => string[]
|
|
44
45
|
// The paths under `src/jobs`, held as `plugins` is.
|
|
@@ -56,6 +57,21 @@ export interface ProjectSource {
|
|
|
56
57
|
toolOutputs: (root: string, output: string) => ToolOutputs
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
// Read once per project, as the routes, the fallback pages and the endpoints each scan from it.
|
|
61
|
+
const records = new WeakMap<Project['paths'], Promise<ContextReads | undefined>>()
|
|
62
|
+
|
|
63
|
+
async function recordOf({ root, mode, paths }: Pick<Project, 'root' | 'mode' | 'paths'>): Promise<ContextReads | undefined> {
|
|
64
|
+
if (!mode.prebuilt)
|
|
65
|
+
return undefined
|
|
66
|
+
|
|
67
|
+
let held = records.get(paths)
|
|
68
|
+
|
|
69
|
+
if (held === undefined)
|
|
70
|
+
records.set(paths, held = readContextRecord(paths.output, root))
|
|
71
|
+
|
|
72
|
+
return held
|
|
73
|
+
}
|
|
74
|
+
|
|
59
75
|
const DISK: ProjectSource = {
|
|
60
76
|
embedded: false,
|
|
61
77
|
mode: options => modeOf(options),
|
|
@@ -94,11 +110,11 @@ const DISK: ProjectSource = {
|
|
|
94
110
|
await (await import('./loader')).registerLoader(root, settings)
|
|
95
111
|
},
|
|
96
112
|
has: file => existsSync(file),
|
|
97
|
-
routes: async (
|
|
98
|
-
fallback: async (
|
|
113
|
+
routes: async (project, mounts) => scanRoutes(project.paths.routes, mounts, await recordOf(project)),
|
|
114
|
+
fallback: async (project, mounts) => specialPagesOf(routeTrees(project.paths.routes, mounts), '', await recordOf(project)),
|
|
99
115
|
// Imported as it is asked for, as the API modules' actions read the locales, which read this.
|
|
100
116
|
api: async (root, config) => (await import('./api-modules')).projectApi(root, config),
|
|
101
|
-
endpoints: async (
|
|
117
|
+
endpoints: async (project, mounts) => scanEndpoints(project.paths.routes, mounts, await recordOf(project)),
|
|
102
118
|
plugins: root => pluginFiles(root),
|
|
103
119
|
jobs: root => jobFiles(root),
|
|
104
120
|
extensionCatalogs: (_, files) => files.filter(file => existsSync(file)),
|
|
@@ -51,7 +51,7 @@ export function prefetchMeta(prefetch: Prefetch = 'moderate'): string {
|
|
|
51
51
|
|
|
52
52
|
// Never kay's own routes or the API, as the page swap leaves them too, nor a download or a link search engines are told not to follow, as a sign-out link often is.
|
|
53
53
|
function rules(eagerness: Exclude<Prefetch, false>, nearest: boolean, base = '', apiPath = '/api'): string {
|
|
54
|
-
const where = { and: [{ href_matches: `${base}/*` }, { not: { href_matches: `${base}/_kay/*` } }, { not: { href_matches: `${base}${apiPath}/*` } }, { not: { href_matches: `${base}${apiPath}` } }, { not: { selector_matches:
|
|
54
|
+
const where = { and: [{ href_matches: `${base}/*` }, { not: { href_matches: `${base}/_kay/*` } }, { not: { href_matches: `${base}${apiPath}/*` } }, { not: { href_matches: `${base}${apiPath}` } }, { not: { selector_matches: `${nearest ? `${OPTED_OUT}, ` : ''}[download], [rel~=nofollow]` } }] }
|
|
55
55
|
|
|
56
56
|
return `<script type="speculationrules">${JSON.stringify({ prefetch: [{ source: 'document', where, eagerness }] })}</script>`
|
|
57
57
|
}
|
package/src/server/storage.ts
CHANGED
|
@@ -68,8 +68,6 @@ export interface PutOptions {
|
|
|
68
68
|
export interface UrlOptions {
|
|
69
69
|
// How long a link to a private file stays valid, an hour by default; it is rounded up so pages rendered minutes apart give the same link, which the browser keeps cached.
|
|
70
70
|
ttl?: Duration | undefined
|
|
71
|
-
/** @deprecated Written `ttl`; `deprecated-ttl-names` rewrites it. Removed in 1.108. */
|
|
72
|
-
maxAge?: Duration | undefined
|
|
73
71
|
}
|
|
74
72
|
|
|
75
73
|
const DEFAULT_DIR = 'data/files'
|
|
@@ -100,11 +98,8 @@ let current: { store: FileStore | undefined, cacheDir: string | undefined, varia
|
|
|
100
98
|
let defaultStore: FileStore | undefined
|
|
101
99
|
|
|
102
100
|
// Files in a directory of this machine, `data/files` by default, relative to where the server runs: `diskFiles({ dir, onWrite, onDelete })`, as `s3Files` and `memoryFiles` take their options.
|
|
103
|
-
export function diskFiles(options
|
|
104
|
-
|
|
105
|
-
export function diskFiles(dir: string, hooks?: FileHooks): FileStore
|
|
106
|
-
export function diskFiles(first: string | (FileHooks & { dir?: string | undefined }) = {}, second: FileHooks = {}): FileStore {
|
|
107
|
-
const { dir = DEFAULT_DIR, ...hooks } = typeof first === 'string' ? { dir: first, ...second } : first
|
|
101
|
+
export function diskFiles(options: FileHooks & { dir?: string | undefined } = {}): FileStore {
|
|
102
|
+
const { dir = DEFAULT_DIR, ...hooks } = options
|
|
108
103
|
const path = (key: string) => join(resolve(dir), key)
|
|
109
104
|
|
|
110
105
|
return {
|
|
@@ -403,7 +398,7 @@ export const files = {
|
|
|
403
398
|
|
|
404
399
|
readScriptSecret()
|
|
405
400
|
|
|
406
|
-
const seconds = durationSeconds(options.ttl ??
|
|
401
|
+
const seconds = durationSeconds(options.ttl ?? DEFAULT_EXPIRES, 'files.url()\'s ttl')
|
|
407
402
|
const step = Math.min(EXPIRY_STEP, seconds)
|
|
408
403
|
const until = Math.ceil((Date.now() / 1000 + seconds) / step) * step
|
|
409
404
|
|
package/src/server/validate.ts
CHANGED
|
@@ -162,7 +162,7 @@ function readText(schema: unknown, value: unknown, form: boolean, trim: boolean)
|
|
|
162
162
|
const { properties, required = [] } = (isNode(schema) ? schema : {}) as { properties?: Record<string, Node>, required?: string[] }
|
|
163
163
|
|
|
164
164
|
for (const [name, field] of Object.entries(properties ?? {})) {
|
|
165
|
-
// A blank list is the empty one, as `
|
|
165
|
+
// A blank list is the empty one, as `queryParam` writes it, never one blank item; a blank optional field with a default is left out, so the default fills in.
|
|
166
166
|
if (form && input[name] === '' && field.type === 'array')
|
|
167
167
|
input[name] = []
|
|
168
168
|
else if (form && input[name] === '' && field.default !== undefined && !required.includes(name))
|