@kayjs/kay 1.105.0 → 1.107.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/README.md +2 -2
- package/dist/eslint.js +777 -210
- package/editors/zed/extension.toml +2 -2
- package/llms/action-protection.md +2 -2
- package/llms/actions-from-islands.md +2 -2
- package/llms/actions-refused-fields.md +22 -0
- package/llms/actions.md +24 -41
- package/llms/analytics.md +1 -1
- package/llms/api-from-islands.md +1 -1
- package/llms/api-routes.md +6 -6
- package/llms/browser-only.md +1 -1
- package/llms/check-and-tools.md +1 -1
- package/llms/code-lints.md +2 -2
- package/llms/compiler-api.md +1 -1
- package/llms/component-libraries.md +1 -0
- package/llms/components.md +1 -1
- package/llms/content-cms.md +1 -1
- package/llms/content-markdown-to-caching.md +1 -1
- package/llms/content-preview.md +2 -2
- package/llms/content.md +21 -21
- package/llms/deprecated-lints-1-105-libraries.md +2 -0
- package/llms/deprecated-lints-1-105.md +3 -3
- package/llms/deprecated-lints.md +4 -4
- package/llms/dev-tool.md +2 -2
- package/llms/environment.md +22 -22
- package/llms/files.md +5 -5
- package/llms/island-and-form-lints.md +1 -0
- package/llms/islands-state-to-ids.md +2 -1
- package/llms/islands.md +10 -1
- package/llms/local-collections.md +2 -2
- package/llms/mcp.md +2 -1
- package/llms/navigation-from-code.md +1 -1
- package/llms/notifications.md +4 -2
- package/llms/project-new-and-add.md +1 -1
- package/llms/project.md +3 -3
- package/llms/rate-limits.md +1 -1
- package/llms/recipes.md +16 -16
- package/llms/rooms.md +4 -4
- package/llms/routing-endpoints-and-base.md +1 -1
- package/llms/routing.md +5 -5
- package/llms/schemas.md +14 -7
- package/llms/server.md +7 -7
- package/llms/site.md +9 -9
- package/llms/sitemap-search-fonts.md +2 -0
- package/llms/styles-and-assets.md +2 -1
- package/llms/templates-elements-slots-snippets.md +2 -2
- package/llms/testing-browser.md +20 -0
- package/llms/testing.md +1 -1
- package/llms/upgrading-1-105-config.md +2 -2
- package/llms/upgrading.md +37 -4
- package/llms/whats-new-archive.md +35 -66
- package/llms/whats-new.md +47 -28
- package/llms.txt +1 -1
- package/package.json +24 -11
- package/src/add.ts +1 -1
- package/src/build/class-table.ts +2 -2
- package/src/build/client.ts +27 -30
- package/src/build/entry-files.ts +19 -0
- package/src/build/lazy-components.ts +130 -0
- package/src/build/lazy-manifest.ts +56 -0
- package/src/build/lazy-stubs.ts +31 -0
- package/src/build/plugin.ts +16 -11
- package/src/build/runtime-chunk.ts +1 -1
- package/src/build/styles.ts +3 -3
- package/src/build/transform.ts +19 -7
- package/src/build/ui-layers.ts +30 -0
- package/src/build/ui.ts +108 -11
- package/src/build/variants.ts +125 -46
- package/src/build/worker-bundle.ts +6 -0
- package/src/check/action-options.ts +56 -0
- package/src/check/boot.ts +22 -1
- package/src/check/call-result.ts +242 -0
- package/src/check/config-objects.ts +17 -2
- package/src/check/diagnose.ts +22 -0
- package/src/check/handler-events.ts +149 -0
- package/src/check/index.ts +6 -2
- package/src/check/link-flag-tests.ts +130 -0
- package/src/check/project.ts +4 -3
- package/src/check/refusal-calls.ts +2 -2
- package/src/check/regroup.ts +5 -3
- package/src/check/renamed-packages.ts +58 -14
- package/src/check/schema-builders.ts +256 -0
- package/src/check/schema-json.ts +226 -0
- package/src/check/secret-keys.ts +15 -2
- package/src/check/shadow-types.ts +13 -9
- package/src/check/template-hints.ts +1 -1
- package/src/check/tool-labels.ts +11 -9
- package/src/check/ui-types.ts +4 -3
- package/src/check/ui.ts +14 -11
- package/src/commands/env-declare.ts +18 -6
- package/src/commands/routes.ts +1 -1
- package/src/compiler/a11y.ts +8 -1
- package/src/compiler/ast.ts +1 -1
- package/src/compiler/bound-props.ts +1 -1
- package/src/compiler/codegen.ts +13 -23
- package/src/compiler/deprecated-lints-1-105.ts +41 -0
- package/src/compiler/deprecated-lints-1-106.ts +14 -0
- package/src/compiler/deprecated-lints-1-107.ts +14 -0
- package/src/compiler/deprecated-lints.ts +17 -60
- package/src/compiler/deprecated-typed-lints.ts +23 -0
- package/src/compiler/dom-here.ts +72 -0
- package/src/compiler/dom.ts +23 -23
- package/src/compiler/fence-checks.ts +12 -11
- package/src/compiler/field-described.ts +2 -2
- package/src/compiler/helper-imports.ts +1 -1
- package/src/compiler/html-fields.ts +92 -0
- package/src/compiler/html-initial.ts +5 -3
- package/src/compiler/html.ts +14 -31
- package/src/compiler/import-edits.ts +15 -0
- package/src/compiler/index.ts +10 -3
- package/src/compiler/island-declaration.ts +15 -0
- package/src/compiler/items.ts +5 -5
- package/src/compiler/kay-exports.ts +1 -0
- package/src/compiler/lazy-imports.ts +357 -0
- package/src/compiler/link-flags.ts +6 -5
- package/src/compiler/lints.ts +12 -12
- package/src/compiler/parser.ts +2 -2
- package/src/compiler/rest-omits.ts +15 -0
- package/src/compiler/route-lints.ts +2 -0
- package/src/compiler/schema-lints.ts +13 -0
- package/src/compiler/script-server.ts +6 -3
- package/src/config-loader.ts +10 -2
- package/src/config-resolve.ts +3 -1
- package/src/config-shape.ts +2 -2
- package/src/config.ts +20 -4
- package/src/content/markdown.ts +2 -3
- package/src/content/validate.ts +1 -1
- package/src/generate-resource.ts +9 -9
- package/src/generate.ts +1 -1
- package/src/mcp/guards.ts +1 -1
- package/src/mcp/tools.ts +1 -1
- package/src/migrate/content.ts +61 -55
- package/src/new.ts +6 -2
- package/src/runtime/action-shared.ts +2 -2
- package/src/runtime/action.ts +51 -4
- package/src/runtime/client.ts +10 -0
- package/src/runtime/dom-lazy.ts +276 -0
- package/src/runtime/field-errors.ts +58 -0
- package/src/runtime/field-refusal.ts +179 -0
- package/src/runtime/form-types.ts +99 -0
- package/src/runtime/form.ts +25 -9
- package/src/runtime/html.ts +42 -6
- package/src/runtime/index.ts +2 -0
- package/src/runtime/island.server.ts +36 -2
- package/src/runtime/markdown-autolink.ts +69 -0
- package/src/runtime/markdown-render.client.ts +39 -3
- package/src/runtime/markdown.client.ts +6 -3
- package/src/runtime/markdown.server.ts +6 -3
- package/src/runtime/markdown.ts +125 -1
- package/src/runtime/navigate-api.ts +10 -5
- package/src/runtime/persist.ts +7 -7
- package/src/runtime/query-param.ts +1 -1
- package/src/runtime/reactive.ts +14 -0
- package/src/runtime/sanitize.ts +3 -1
- package/src/runtime/schema-record.ts +32 -0
- package/src/runtime/schema.client.ts +101 -14
- package/src/runtime/schema.ts +328 -26
- package/src/runtime/standard-schema.ts +32 -0
- package/src/runtime/swap-focus.ts +59 -11
- package/src/runtime/validate-run.client.ts +179 -0
- package/src/runtime/validate.client.ts +11 -0
- package/src/runtime/validate.ts +4 -137
- package/src/server/action-module.ts +16 -0
- package/src/server/actions.ts +54 -57
- package/src/server/answer.ts +102 -0
- package/src/server/api-input.ts +166 -0
- package/src/server/api-modules.ts +1 -1
- package/src/server/api.ts +12 -32
- package/src/server/app-stages.ts +38 -26
- package/src/server/app.ts +5 -2
- package/src/server/client.ts +2 -0
- package/src/server/dev-ui.ts +2 -2
- package/src/server/dev.ts +7 -9
- package/src/server/env-state.ts +1 -1
- package/src/server/env.ts +11 -3
- package/src/server/favicon.ts +47 -1
- package/src/server/file-limit.ts +7 -1
- package/src/server/forms.ts +1 -1
- package/src/server/host-allowlist.ts +7 -7
- package/src/server/image-metadata-bmff.ts +1 -1
- package/src/server/index.ts +2 -0
- package/src/server/kay-routes.ts +221 -0
- package/src/server/kay-server.ts +228 -0
- package/src/server/kept-exports.ts +1 -0
- package/src/server/kept-pages.ts +3 -3
- package/src/server/library.ts +2 -2
- package/src/server/mcp.ts +14 -13
- package/src/server/notifications.ts +4 -2
- package/src/server/offline.ts +24 -7
- package/src/server/openapi.ts +12 -3
- package/src/server/phases.ts +249 -0
- package/src/server/protection.ts +6 -6
- package/src/server/proxy-key.ts +8 -8
- package/src/server/push-settings.ts +16 -2
- package/src/server/push.ts +12 -4
- package/src/server/query.ts +17 -31
- package/src/server/receive.ts +43 -0
- package/src/server/render-document.ts +13 -3
- package/src/server/render.ts +1 -1
- package/src/server/request-context.ts +137 -0
- package/src/server/schema-check.ts +1 -1
- package/src/server/scope.ts +20 -13
- package/src/server/signals.ts +4 -4
- package/src/server/socket.ts +19 -47
- package/src/server/stream.ts +1 -1
- package/src/server/validate.ts +346 -0
- package/src/template-ws.ts +1 -1
- package/src/test/a11y-dom.ts +70 -0
- package/src/test/html-snapshot.ts +103 -0
- package/src/test/index.ts +2 -1
- package/src/test/mount.ts +14 -3
- package/src/test/page-checks.ts +12 -0
- package/src/test/screenshot-match.ts +2 -2
- package/src/test/shared-modules.ts +27 -5
- package/src/test/site-types.ts +5 -1
- package/types/build/class-table.d.ts +1 -1
- package/types/build/class-table.d.ts.map +1 -1
- package/types/build/client.d.ts +3 -2
- package/types/build/client.d.ts.map +1 -1
- package/types/build/entry-files.d.ts +4 -0
- package/types/build/entry-files.d.ts.map +1 -0
- package/types/build/lazy-components.d.ts +6 -0
- package/types/build/lazy-components.d.ts.map +1 -0
- package/types/build/lazy-manifest.d.ts +19 -0
- package/types/build/lazy-manifest.d.ts.map +1 -0
- package/types/build/lazy-stubs.d.ts +5 -0
- package/types/build/lazy-stubs.d.ts.map +1 -0
- package/types/build/plugin.d.ts +1 -0
- package/types/build/plugin.d.ts.map +1 -1
- package/types/build/transform.d.ts +4 -1
- package/types/build/transform.d.ts.map +1 -1
- package/types/build/ui-layers.d.ts +5 -0
- package/types/build/ui-layers.d.ts.map +1 -0
- package/types/build/ui.d.ts +7 -0
- package/types/build/ui.d.ts.map +1 -1
- package/types/build/variants.d.ts +1 -1
- package/types/build/variants.d.ts.map +1 -1
- package/types/build/worker-bundle.d.ts +1 -0
- package/types/build/worker-bundle.d.ts.map +1 -1
- package/types/check/action-options.d.ts +3 -0
- package/types/check/action-options.d.ts.map +1 -0
- package/types/check/boot.d.ts.map +1 -1
- package/types/check/call-result.d.ts +7 -0
- package/types/check/call-result.d.ts.map +1 -0
- package/types/check/config-objects.d.ts.map +1 -1
- package/types/check/diagnose.d.ts.map +1 -1
- package/types/check/handler-events.d.ts +9 -0
- package/types/check/handler-events.d.ts.map +1 -0
- package/types/check/index.d.ts +1 -0
- package/types/check/index.d.ts.map +1 -1
- package/types/check/link-flag-tests.d.ts +4 -0
- package/types/check/link-flag-tests.d.ts.map +1 -0
- package/types/check/project.d.ts.map +1 -1
- package/types/check/regroup.d.ts +1 -1
- package/types/check/regroup.d.ts.map +1 -1
- package/types/check/renamed-packages.d.ts +1 -0
- package/types/check/renamed-packages.d.ts.map +1 -1
- package/types/check/schema-builders.d.ts +3 -0
- package/types/check/schema-builders.d.ts.map +1 -0
- package/types/check/schema-json.d.ts +3 -0
- package/types/check/schema-json.d.ts.map +1 -0
- package/types/check/secret-keys.d.ts.map +1 -1
- package/types/check/shadow-types.d.ts.map +1 -1
- package/types/check/template-hints.d.ts +1 -0
- package/types/check/template-hints.d.ts.map +1 -1
- package/types/check/tool-labels.d.ts.map +1 -1
- package/types/check/ui-types.d.ts.map +1 -1
- package/types/check/ui.d.ts.map +1 -1
- package/types/commands/env-declare.d.ts.map +1 -1
- package/types/compiler/a11y.d.ts.map +1 -1
- package/types/compiler/bound-props.d.ts +1 -0
- package/types/compiler/bound-props.d.ts.map +1 -1
- package/types/compiler/codegen.d.ts +3 -0
- package/types/compiler/codegen.d.ts.map +1 -1
- package/types/compiler/deprecated-lints-1-105.d.ts +39 -0
- package/types/compiler/deprecated-lints-1-105.d.ts.map +1 -0
- package/types/compiler/deprecated-lints-1-106.d.ts +12 -0
- package/types/compiler/deprecated-lints-1-106.d.ts.map +1 -0
- package/types/compiler/deprecated-lints-1-107.d.ts +12 -0
- package/types/compiler/deprecated-lints-1-107.d.ts.map +1 -0
- package/types/compiler/deprecated-lints.d.ts +41 -22
- package/types/compiler/deprecated-lints.d.ts.map +1 -1
- package/types/compiler/deprecated-typed-lints.d.ts +21 -0
- package/types/compiler/deprecated-typed-lints.d.ts.map +1 -0
- package/types/compiler/dom-here.d.ts +14 -0
- package/types/compiler/dom-here.d.ts.map +1 -0
- package/types/compiler/dom.d.ts +1 -0
- package/types/compiler/dom.d.ts.map +1 -1
- package/types/compiler/fence-checks.d.ts.map +1 -1
- package/types/compiler/field-described.d.ts +1 -1
- package/types/compiler/field-described.d.ts.map +1 -1
- package/types/compiler/html-fields.d.ts +19 -0
- package/types/compiler/html-fields.d.ts.map +1 -0
- package/types/compiler/html-initial.d.ts +3 -2
- package/types/compiler/html-initial.d.ts.map +1 -1
- package/types/compiler/html.d.ts.map +1 -1
- package/types/compiler/import-edits.d.ts +1 -0
- package/types/compiler/import-edits.d.ts.map +1 -1
- package/types/compiler/index.d.ts +3 -0
- package/types/compiler/index.d.ts.map +1 -1
- package/types/compiler/island-declaration.d.ts +5 -0
- package/types/compiler/island-declaration.d.ts.map +1 -1
- package/types/compiler/items.d.ts +4 -1
- package/types/compiler/items.d.ts.map +1 -1
- package/types/compiler/kay-exports.d.ts.map +1 -1
- package/types/compiler/lazy-imports.d.ts +33 -0
- package/types/compiler/lazy-imports.d.ts.map +1 -0
- package/types/compiler/link-flags.d.ts +6 -0
- package/types/compiler/link-flags.d.ts.map +1 -1
- package/types/compiler/lints.d.ts +61 -34
- package/types/compiler/lints.d.ts.map +1 -1
- package/types/compiler/rest-omits.d.ts +4 -0
- package/types/compiler/rest-omits.d.ts.map +1 -0
- package/types/compiler/route-lints.d.ts +8 -0
- package/types/compiler/route-lints.d.ts.map +1 -1
- package/types/compiler/schema-lints.d.ts +11 -0
- package/types/compiler/schema-lints.d.ts.map +1 -0
- package/types/compiler/script-server.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.d.ts +15 -2
- package/types/config.d.ts.map +1 -1
- package/types/content/markdown.d.ts.map +1 -1
- package/types/migrate/content.d.ts.map +1 -1
- package/types/new.d.ts +1 -0
- package/types/new.d.ts.map +1 -1
- package/types/runtime/action-shared.d.ts +1 -1
- package/types/runtime/action-shared.d.ts.map +1 -1
- package/types/runtime/action.d.ts +29 -1
- package/types/runtime/action.d.ts.map +1 -1
- package/types/runtime/client.d.ts.map +1 -1
- package/types/runtime/dom-lazy.d.ts +6 -0
- package/types/runtime/dom-lazy.d.ts.map +1 -0
- package/types/runtime/field-errors.d.ts +4 -0
- package/types/runtime/field-errors.d.ts.map +1 -0
- package/types/runtime/field-refusal.d.ts +37 -0
- package/types/runtime/field-refusal.d.ts.map +1 -0
- package/types/runtime/form-types.d.ts +6 -0
- package/types/runtime/form-types.d.ts.map +1 -0
- package/types/runtime/form.d.ts +4 -2
- package/types/runtime/form.d.ts.map +1 -1
- package/types/runtime/html.d.ts +3 -0
- package/types/runtime/html.d.ts.map +1 -1
- package/types/runtime/index.d.ts +2 -0
- 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/markdown-autolink.d.ts +11 -0
- package/types/runtime/markdown-autolink.d.ts.map +1 -0
- package/types/runtime/markdown-render.client.d.ts +2 -1
- package/types/runtime/markdown-render.client.d.ts.map +1 -1
- package/types/runtime/markdown.client.d.ts +3 -1
- package/types/runtime/markdown.client.d.ts.map +1 -1
- package/types/runtime/markdown.d.ts +11 -0
- package/types/runtime/markdown.d.ts.map +1 -1
- package/types/runtime/markdown.server.d.ts +3 -1
- package/types/runtime/markdown.server.d.ts.map +1 -1
- package/types/runtime/navigate-api.d.ts +1 -1
- package/types/runtime/navigate-api.d.ts.map +1 -1
- package/types/runtime/persist.d.ts +2 -2
- package/types/runtime/persist.d.ts.map +1 -1
- package/types/runtime/reactive.d.ts +3 -0
- package/types/runtime/reactive.d.ts.map +1 -1
- package/types/runtime/sanitize.d.ts.map +1 -1
- package/types/runtime/schema-record.d.ts +9 -0
- package/types/runtime/schema-record.d.ts.map +1 -0
- package/types/runtime/schema.client.d.ts.map +1 -1
- package/types/runtime/schema.d.ts +99 -10
- package/types/runtime/schema.d.ts.map +1 -1
- package/types/runtime/standard-schema.d.ts +37 -0
- package/types/runtime/standard-schema.d.ts.map +1 -0
- package/types/runtime/swap-focus.d.ts.map +1 -1
- package/types/runtime/validate-run.client.d.ts +4 -0
- package/types/runtime/validate-run.client.d.ts.map +1 -0
- package/types/runtime/validate.client.d.ts +4 -0
- package/types/runtime/validate.client.d.ts.map +1 -0
- package/types/runtime/validate.d.ts +1 -21
- package/types/runtime/validate.d.ts.map +1 -1
- package/types/server/action-module.d.ts +2 -0
- package/types/server/action-module.d.ts.map +1 -0
- package/types/server/actions.d.ts +1 -0
- package/types/server/actions.d.ts.map +1 -1
- package/types/server/answer.d.ts +6 -0
- package/types/server/answer.d.ts.map +1 -0
- package/types/server/api-input.d.ts +19 -0
- package/types/server/api-input.d.ts.map +1 -0
- package/types/server/api.d.ts.map +1 -1
- package/types/server/app-stages.d.ts +7 -3
- package/types/server/app-stages.d.ts.map +1 -1
- package/types/server/app.d.ts +2 -0
- package/types/server/app.d.ts.map +1 -1
- package/types/server/client.d.ts +1 -0
- package/types/server/client.d.ts.map +1 -1
- package/types/server/dev.d.ts +1 -1
- package/types/server/dev.d.ts.map +1 -1
- package/types/server/env-state.d.ts.map +1 -1
- package/types/server/env.d.ts +5 -1
- package/types/server/env.d.ts.map +1 -1
- package/types/server/favicon.d.ts +3 -1
- package/types/server/favicon.d.ts.map +1 -1
- package/types/server/file-limit.d.ts.map +1 -1
- package/types/server/host-allowlist.d.ts +3 -3
- package/types/server/host-allowlist.d.ts.map +1 -1
- package/types/server/index.d.ts +2 -0
- package/types/server/index.d.ts.map +1 -1
- package/types/server/kay-routes.d.ts +47 -0
- package/types/server/kay-routes.d.ts.map +1 -0
- package/types/server/kay-server.d.ts +25 -0
- package/types/server/kay-server.d.ts.map +1 -0
- package/types/server/kept-exports.d.ts.map +1 -1
- package/types/server/kept-pages.d.ts +1 -1
- package/types/server/kept-pages.d.ts.map +1 -1
- package/types/server/library.d.ts +2 -1
- package/types/server/library.d.ts.map +1 -1
- package/types/server/mcp.d.ts +1 -1
- package/types/server/mcp.d.ts.map +1 -1
- package/types/server/notifications.d.ts +2 -1
- package/types/server/notifications.d.ts.map +1 -1
- package/types/server/offline.d.ts.map +1 -1
- package/types/server/openapi.d.ts.map +1 -1
- package/types/server/phases.d.ts +36 -0
- package/types/server/phases.d.ts.map +1 -0
- package/types/server/protection.d.ts +3 -2
- package/types/server/protection.d.ts.map +1 -1
- package/types/server/proxy-key.d.ts +3 -3
- package/types/server/proxy-key.d.ts.map +1 -1
- package/types/server/push-settings.d.ts +1 -1
- package/types/server/push-settings.d.ts.map +1 -1
- package/types/server/push.d.ts +1 -0
- package/types/server/push.d.ts.map +1 -1
- package/types/server/query.d.ts.map +1 -1
- package/types/server/receive.d.ts +9 -0
- package/types/server/receive.d.ts.map +1 -0
- package/types/server/render-document.d.ts.map +1 -1
- package/types/server/request-context.d.ts +29 -0
- package/types/server/request-context.d.ts.map +1 -0
- package/types/server/schema-check.d.ts +1 -0
- package/types/server/schema-check.d.ts.map +1 -1
- package/types/server/scope.d.ts +1 -1
- package/types/server/scope.d.ts.map +1 -1
- package/types/server/socket.d.ts +3 -5
- package/types/server/socket.d.ts.map +1 -1
- package/types/server/validate.d.ts +26 -0
- package/types/server/validate.d.ts.map +1 -0
- package/types/test/a11y-dom.d.ts +20 -0
- package/types/test/a11y-dom.d.ts.map +1 -0
- package/types/test/html-snapshot.d.ts +4 -0
- package/types/test/html-snapshot.d.ts.map +1 -0
- package/types/test/index.d.ts.map +1 -1
- package/types/test/mount.d.ts +3 -0
- package/types/test/mount.d.ts.map +1 -1
- package/types/test/page-checks.d.ts +6 -0
- package/types/test/page-checks.d.ts.map +1 -0
- package/types/test/screenshot-match.d.ts +1 -1
- package/types/test/screenshot-match.d.ts.map +1 -1
- package/types/test/shared-modules.d.ts.map +1 -1
- package/types/test/site-types.d.ts +3 -1
- package/types/test/site-types.d.ts.map +1 -1
- package/src/check/schema-type.ts +0 -9
- package/src/compiler/deprecated-script-fence.ts +0 -26
- package/src/server/field-errors.ts +0 -136
- package/types/check/schema-type.d.ts +0 -3
- package/types/check/schema-type.d.ts.map +0 -1
- package/types/compiler/deprecated-script-fence.d.ts +0 -3
- package/types/compiler/deprecated-script-fence.d.ts.map +0 -1
- package/types/server/field-errors.d.ts +0 -6
- package/types/server/field-errors.d.ts.map +0 -1
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import type { Server } from 'bun'
|
|
2
|
+
import type { Elysia } from 'elysia'
|
|
3
|
+
import type { Compiled, RouteEnv, RouteRecord } from './kay-routes'
|
|
4
|
+
import type { PipelineOptions } from './phases'
|
|
5
|
+
import type { ReceiveServer } from './receive'
|
|
6
|
+
import { compileRecord, extractParams, isDynamic, RouteIndex, slashed } from './kay-routes'
|
|
7
|
+
import { emptyPhases, Pipeline } from './phases'
|
|
8
|
+
import { requestUrl } from './request-url'
|
|
9
|
+
|
|
10
|
+
// What answers a request no record of the table serves: the Elysia app kay still routes the rest through.
|
|
11
|
+
export type Fallback = (request: Request, server: ReceiveServer) => Response | Promise<Response>
|
|
12
|
+
|
|
13
|
+
type Handler = (request: Request, server: ReceiveServer) => Promise<Response>
|
|
14
|
+
type BunRoutes = Record<string, Record<string, Handler | Response>>
|
|
15
|
+
|
|
16
|
+
export interface KayServerOptions extends PipelineOptions {
|
|
17
|
+
env: RouteEnv
|
|
18
|
+
fallback?: Fallback | undefined
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'HEAD']
|
|
22
|
+
|
|
23
|
+
// The methods Bun is handed a record for: a GET record answers HEAD too, an ALL one every method.
|
|
24
|
+
function askedBy(method: string): string[] {
|
|
25
|
+
if (method === 'ALL')
|
|
26
|
+
return METHODS
|
|
27
|
+
|
|
28
|
+
return method === 'GET' ? ['GET', 'HEAD'] : [method]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// kay's own server: the route table compiled into the `routes` `Bun.serve` matches, and `fetch` for what that router leaves, with the fixed phases around both and the fallback app answering what no record serves.
|
|
32
|
+
export class KayServer {
|
|
33
|
+
readonly pipeline: Pipeline
|
|
34
|
+
readonly records: RouteRecord[] = []
|
|
35
|
+
fallback: Fallback | undefined
|
|
36
|
+
readonly #env: RouteEnv
|
|
37
|
+
#built: { routes: BunRoutes, index: RouteIndex } | undefined
|
|
38
|
+
|
|
39
|
+
constructor(options: KayServerOptions) {
|
|
40
|
+
this.pipeline = new Pipeline(emptyPhases(), options)
|
|
41
|
+
this.#env = options.env
|
|
42
|
+
this.fallback = options.fallback
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Adds a record to the table; the routes compile again from the next read.
|
|
46
|
+
add(...records: RouteRecord[]): void {
|
|
47
|
+
this.records.push(...records)
|
|
48
|
+
this.#built = undefined
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// What to hand `Bun.serve({ routes })`.
|
|
52
|
+
get routes(): BunRoutes {
|
|
53
|
+
return this.#build().routes
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Answers a request the router did not send to a record: a rewritten one, a request with no server, or one whose path is the fallback's.
|
|
57
|
+
async fetch(request: Request, server?: ReceiveServer): Promise<Response> {
|
|
58
|
+
const received = await this.#receive(request, server)
|
|
59
|
+
|
|
60
|
+
if (received instanceof Response)
|
|
61
|
+
return received
|
|
62
|
+
|
|
63
|
+
const hit = this.#build().index.match(received.method, requestUrl(received).pathname)
|
|
64
|
+
|
|
65
|
+
return hit === undefined ? this.#fallback(received, server) : this.#answer(hit.compiled, hit.params, received)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
#build(): { routes: BunRoutes, index: RouteIndex } {
|
|
69
|
+
if (this.#built !== undefined)
|
|
70
|
+
return this.#built
|
|
71
|
+
|
|
72
|
+
const compiled = this.records.flatMap(record => compileRecord(record, this.#env))
|
|
73
|
+
const routes: BunRoutes = {}
|
|
74
|
+
|
|
75
|
+
for (const entry of compiled) {
|
|
76
|
+
const methods = routes[entry.path] ??= {}
|
|
77
|
+
const asked = askedBy(entry.record.method)
|
|
78
|
+
const staticAnswer = !entry.redirect && this.pipeline.empty ? entry.record.static : undefined
|
|
79
|
+
|
|
80
|
+
for (const method of asked) {
|
|
81
|
+
// The first record of a path and method keeps it.
|
|
82
|
+
if (methods[method] === undefined)
|
|
83
|
+
methods[method] = staticAnswer !== undefined && method === 'GET' ? staticAnswer : async (request, server) => this.#serve(entry, request, server)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return this.#built = { routes, index: new RouteIndex(compiled) }
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// `receive`, its answer or the failure of a step taken through the phases that follow it, as any failure is.
|
|
91
|
+
async #receive(request: Request, server: ReceiveServer): Promise<Request | Response> {
|
|
92
|
+
try {
|
|
93
|
+
const received = this.pipeline.receive(request, server)
|
|
94
|
+
|
|
95
|
+
return received instanceof Response ? await this.pipeline.settle(request, received) : received
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
return this.pipeline.failed(request, error)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// A request Bun's router sent to a record: received first, and handed on to the table's own match when `receive` rewrote it.
|
|
103
|
+
async #serve(entry: Compiled, request: Request, server: ReceiveServer): Promise<Response> {
|
|
104
|
+
const received = await this.#receive(request, server)
|
|
105
|
+
|
|
106
|
+
if (received instanceof Response)
|
|
107
|
+
return received
|
|
108
|
+
|
|
109
|
+
if (received !== request)
|
|
110
|
+
return this.fetch(received, server)
|
|
111
|
+
|
|
112
|
+
const params = isDynamic(entry.path) ? extractParams(entry.segments, requestUrl(received).pathname) : {}
|
|
113
|
+
|
|
114
|
+
// A path the router took for the record, which its own reading of the params refuses, is the fallback's.
|
|
115
|
+
return params === null ? this.#fallback(received, server) : this.#answer(entry, params, received)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async #answer(entry: Compiled, params: Record<string, string> | undefined, request: Request): Promise<Response> {
|
|
119
|
+
if (entry.redirect) {
|
|
120
|
+
const { pathname, search } = requestUrl(request)
|
|
121
|
+
|
|
122
|
+
return this.pipeline.settle(request, new Response(null, { status: 308, headers: { location: slashed(pathname, search) } }))
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return this.pipeline.serve(entry.record.static === undefined || entry.record.handle !== undefined ? entry.record : { ...entry.record, handle: () => entry.record.static!.clone() }, params, request)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async #fallback(request: Request, server: ReceiveServer): Promise<Response> {
|
|
129
|
+
if (this.fallback === undefined)
|
|
130
|
+
return this.pipeline.settle(request, new Response('Not Found\n', { status: 404, headers: { 'content-type': 'text/plain; charset=utf-8' } }))
|
|
131
|
+
|
|
132
|
+
return this.pipeline.settle(request, await this.fallback(request, server))
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// The routes Elysia handed Bun with the table's laid over them, each method of a path the table serves taken from it and the others left to Elysia.
|
|
137
|
+
function withTable(elysia: Record<string, unknown> | undefined, table: BunRoutes): Record<string, unknown> {
|
|
138
|
+
const merged: Record<string, unknown> = { ...elysia }
|
|
139
|
+
|
|
140
|
+
for (const [path, methods] of Object.entries(table)) {
|
|
141
|
+
const held = merged[path]
|
|
142
|
+
|
|
143
|
+
merged[path] = typeof held === 'object' && held !== null && Object.getPrototypeOf(held) === Object.prototype ? { ...held, ...methods } : methods
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return merged
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const INSTALLED = Symbol.for('kay.server.installed')
|
|
150
|
+
|
|
151
|
+
type Reload = Server<unknown>['reload']
|
|
152
|
+
|
|
153
|
+
// What a server holds once kay is in front of it: the table it serves now, which a later run of the app (`kay dev` restarts it on the same server) takes over.
|
|
154
|
+
interface Front {
|
|
155
|
+
kay: KayServer
|
|
156
|
+
// What the app last handed the server, laid over again when a later run's table takes over.
|
|
157
|
+
options?: Parameters<Reload>[0]
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
interface Installable extends Server<unknown> {
|
|
161
|
+
[INSTALLED]?: Front
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// The `reload` of the server is its prototype's, which the patch shadows: it is lifted for the call, then put back.
|
|
165
|
+
function lifted(server: Installable, options: Parameters<Reload>[0]): void {
|
|
166
|
+
delete (server as { reload?: Reload }).reload
|
|
167
|
+
|
|
168
|
+
try {
|
|
169
|
+
server.reload(options)
|
|
170
|
+
}
|
|
171
|
+
finally {
|
|
172
|
+
server.reload = patched as Reload
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Hands Bun what the app gave, with the table's routes laid over its own and a `fetch` that reads the table from the server at each request, so a reload of an earlier run never leaves a request to a table that has no fallback.
|
|
177
|
+
function lay(server: Installable, front: Front, options: Parameters<Reload>[0]): void {
|
|
178
|
+
const { fetch: elysia } = options as { fetch?: ((request: Request, server: ReceiveServer) => Response | Promise<Response>) | undefined }
|
|
179
|
+
|
|
180
|
+
front.kay.fallback = elysia && (async request => elysia(request, server))
|
|
181
|
+
lifted(server, { ...options, fetch: async (request: Request, bun: ReceiveServer) => server[INSTALLED]!.kay.fetch(request, bun ?? server), routes: withTable(options.routes, front.kay.routes) as never })
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// What the server's `reload` is once kay is in front: the app's `fetch` becomes the fallback of the table's, and its routes are laid under the table's. It is a function of the module, not of one run of the app, so it keeps no run's app or table alive; a wrapper of the server (`kay dev` hands each run one) calls it on the server itself, so `this` is the server whatever object the app holds.
|
|
185
|
+
function patched(this: Installable, options: Parameters<Reload>[0]): void {
|
|
186
|
+
// Elysia also reloads a server with the server itself, which holds what it already serves.
|
|
187
|
+
if (typeof (options as { stop?: unknown }).stop === 'function')
|
|
188
|
+
return lifted(this, options)
|
|
189
|
+
|
|
190
|
+
const front = this[INSTALLED]!
|
|
191
|
+
|
|
192
|
+
front.options = options
|
|
193
|
+
lay(this, front, options)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Puts kay's server in front of the Elysia app once it listens: Bun is handed `kay.fetch`, with the app's own `fetch` as its fallback, and the routes the table compiled to, beside the ones Elysia hands it.
|
|
197
|
+
// Elysia hands Bun its `fetch` and routes in a `reload` when it has loaded its modules, a microtask after it starts listening, and recompiles `app.fetch` by then, so the `reload` of the running server is where both are taken over.
|
|
198
|
+
// Elysia also hands Bun a handler for each of its routes, which Bun calls without `fetch`, so the answer would skip `respond` and `after`: once a step of either is set, Elysia's own router serves them through `fetch` instead. With none set, which is the case until the slices moving the response work onto the phases land, the app is served exactly as before.
|
|
199
|
+
export function serveThrough(app: Elysia, kay: KayServer): void {
|
|
200
|
+
app.onStart((root) => {
|
|
201
|
+
const server = root.server as Installable | null | undefined
|
|
202
|
+
|
|
203
|
+
if (server === null || server === undefined)
|
|
204
|
+
return
|
|
205
|
+
|
|
206
|
+
const { respond, after } = kay.pipeline.phases
|
|
207
|
+
|
|
208
|
+
if (respond.length > 0 || after.length > 0)
|
|
209
|
+
root.config.systemRouter = false
|
|
210
|
+
|
|
211
|
+
const held = server[INSTALLED]
|
|
212
|
+
|
|
213
|
+
if (held !== undefined) {
|
|
214
|
+
// The table of the new run takes the server over, its routes laid under Bun again, and no table of an earlier run keeps the app of a later one.
|
|
215
|
+
kay.fallback = held.kay.fallback
|
|
216
|
+
held.kay.fallback = undefined
|
|
217
|
+
held.kay = kay
|
|
218
|
+
|
|
219
|
+
if (held.options !== undefined)
|
|
220
|
+
lay(server, held, held.options)
|
|
221
|
+
|
|
222
|
+
return
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
server[INSTALLED] = { kay }
|
|
226
|
+
server.reload = patched as Reload
|
|
227
|
+
})
|
|
228
|
+
}
|
package/src/server/kept-pages.ts
CHANGED
|
@@ -39,18 +39,18 @@ function withoutTrailingSlashes(path: string): string {
|
|
|
39
39
|
// A request that is not a GET, a HEAD or an OPTIONS can change what a page renders, an action as much as a route of the app, once a route answers it: one to no route, and kay's own routes in `own` (the MCP endpoint among them, whose tool calls reach the app's actions and count there), write nothing, so no visitor can force a page to render again by sending them.
|
|
40
40
|
// Counted when its route is matched and again as its response is made, so a visit between the two is checked once more, and the visit that follows the response sees the finished write; one a guard or the validation refuses (a 400, 401, 403, 405, 413, 415, 422 or 429) is counted by neither, so no visitor can make a page render again by sending those.
|
|
41
41
|
// The end count is a `mapResponse` and an `afterResponse`, never an `afterHandle` or `onError`, which would change how an API module answers; called before any route is added, as a hook reaches only the routes added after it.
|
|
42
|
-
export function countWrites(app: Elysia, own: string[] = []): Writes {
|
|
42
|
+
export function countWrites(app: Elysia, own: () => string[] = () => []): Writes {
|
|
43
43
|
let done = 0
|
|
44
44
|
let active = 0
|
|
45
45
|
const writes: Writes = { get count() {
|
|
46
46
|
// A write in flight counts half a step, so a visit during it is checked once more after it, and a refused one leaves the count where it was.
|
|
47
47
|
return active > 0 ? done + 0.5 : done
|
|
48
48
|
} }
|
|
49
|
-
const kay = new Set(
|
|
49
|
+
const kay = new Set(KAY_ROUTES)
|
|
50
50
|
const started = new WeakSet<Request>()
|
|
51
51
|
|
|
52
52
|
app.onTransform({ as: 'global' }, ({ request }) => {
|
|
53
|
-
if (request.method !== 'GET' && request.method !== 'HEAD' && request.method !== 'OPTIONS' && !kay.has(withoutTrailingSlashes(pathOf(request.url)))) {
|
|
53
|
+
if (request.method !== 'GET' && request.method !== 'HEAD' && request.method !== 'OPTIONS' && !kay.has(withoutTrailingSlashes(pathOf(request.url))) && !own().includes(withoutTrailingSlashes(pathOf(request.url)))) {
|
|
54
54
|
started.add(request)
|
|
55
55
|
active++
|
|
56
56
|
}
|
package/src/server/library.ts
CHANGED
|
@@ -42,7 +42,9 @@ export type { DenyOptions, RefuseOptions } from '../runtime/refuse'
|
|
|
42
42
|
export { refuse } from '../runtime/refuse'
|
|
43
43
|
export { safeCode } from '../runtime/safe-code'
|
|
44
44
|
export { isUrlAttribute, UNSAFE_ATTRIBUTE, UNSAFE_TAGS } from '../runtime/sanitize'
|
|
45
|
+
export { DEFAULT_MAX_ITEMS } from '../runtime/schema'
|
|
45
46
|
export type { Schema, Static } from '../runtime/schema'
|
|
47
|
+
export { DEFAULT_MAX_LENGTH } from '../runtime/schema-bounds'
|
|
46
48
|
export { configuredSite, setSite } from '../runtime/site'
|
|
47
49
|
export { openSqlite } from '../runtime/sqlite.server'
|
|
48
50
|
export { parseEvents } from '../runtime/sse'
|
|
@@ -105,8 +107,6 @@ export { sha256 } from './sha256'
|
|
|
105
107
|
export { stoppers } from './signals'
|
|
106
108
|
export { appSecrets, keyedDigest } from './stamp'
|
|
107
109
|
export type { MissingTranslations } from './translations'
|
|
108
|
-
// Deprecated since 1.103: `Schema`, kay's own name for it.
|
|
109
|
-
export type { TSchema } from 'elysia'
|
|
110
110
|
|
|
111
111
|
type Translations = typeof import('./translations')
|
|
112
112
|
type Drafts = typeof import('./message-drafts')
|
package/src/server/mcp.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { configuredSite } from '../runtime/site'
|
|
|
16
16
|
import { FAILURE_HEADER, PAGE_HEADER, REDIRECT_HEADER } from '../runtime/swap'
|
|
17
17
|
import { decodeServerValue, encodeValue } from '../runtime/wire'
|
|
18
18
|
import { boundToPage } from './actions'
|
|
19
|
-
import {
|
|
19
|
+
import { RESOURCE_METADATA } from './api-modules'
|
|
20
20
|
import { isCrossSite, postedFrom, unadmittedCrossSite } from './cross-site'
|
|
21
21
|
import { answeredAsPage, currentRequest } from './log'
|
|
22
22
|
import { bearsMcpKey } from './mcp-key'
|
|
@@ -176,7 +176,7 @@ function toolOf(path: string, method: string, operation: Operation, id: string,
|
|
|
176
176
|
const init: RequestInit = { method: method.toUpperCase(), headers: { accept: 'application/json' } }
|
|
177
177
|
|
|
178
178
|
if (action) {
|
|
179
|
-
init.headers = { 'accept': 'application/json', 'content-type': 'application/json', 'x-kay-action': '1' }
|
|
179
|
+
init.headers = { 'accept': 'application/json', 'content-type': 'application/json', 'x-kay-action': '1', 'x-kay-tool': '1' }
|
|
180
180
|
init.body = encodeValue(args)
|
|
181
181
|
}
|
|
182
182
|
else if (!NO_BODY.has(method) && operation.requestBody) {
|
|
@@ -403,6 +403,8 @@ export interface McpOptions {
|
|
|
403
403
|
metadataPaths: string[]
|
|
404
404
|
// Where the endpoint is served, `/mcp` by default.
|
|
405
405
|
path: string
|
|
406
|
+
// The path before 1.105, answered as `path` is until 2.0, for an app that did not move the endpoint and serves nothing there.
|
|
407
|
+
former?: string | undefined
|
|
406
408
|
// The requests a client may send it in a window, or undefined for no limit.
|
|
407
409
|
rateLimit: RateWindowMs | undefined
|
|
408
410
|
// Sent as `instructions` of `initialize`, from `mcp.instructions`.
|
|
@@ -566,7 +568,7 @@ function serveResourceMetadata(app: Elysia, name: string, paths: string[], endpo
|
|
|
566
568
|
}
|
|
567
569
|
}
|
|
568
570
|
|
|
569
|
-
// Serves the tools of `document` at
|
|
571
|
+
// Serves the tools of `document` at its path over Streamable HTTP: one JSON-RPC message per POST, answered with JSON; `former`, where it was before 1.105, answers POST in place until 2.0.
|
|
570
572
|
export function serveMcp(app: Elysia, document: Schema, options: McpOptions): void {
|
|
571
573
|
const calls = new AsyncLocalStorage<CallContext>()
|
|
572
574
|
const build = () => {
|
|
@@ -587,7 +589,7 @@ export function serveMcp(app: Elysia, document: Schema, options: McpOptions): vo
|
|
|
587
589
|
}
|
|
588
590
|
const notAllowed = () => new Response(null, { status: 405, headers: { allow: 'POST' } })
|
|
589
591
|
|
|
590
|
-
|
|
592
|
+
const answer = async (served: { request: Request, server: Server | null }) => {
|
|
591
593
|
const { request, server } = served
|
|
592
594
|
|
|
593
595
|
// A browser page of another site posting here would act with the visitor's cookies.
|
|
@@ -637,18 +639,17 @@ export function serveMcp(app: Elysia, document: Schema, options: McpOptions): vo
|
|
|
637
639
|
status = 401
|
|
638
640
|
|
|
639
641
|
return new Response(JSON.stringify(reply), { status, headers })
|
|
640
|
-
}
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
app.post(options.path, answer, { parse: 'none' })
|
|
641
645
|
app.get(options.path, notAllowed)
|
|
642
646
|
app.delete(options.path, notAllowed)
|
|
643
|
-
serveResourceMetadata(app, options.title, options.metadataPaths, options.path)
|
|
644
|
-
}
|
|
645
647
|
|
|
646
|
-
//
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
})
|
|
648
|
+
// Only the POST is taken at the former path, so a catch-all or parameter route of the app keeps its GET and DELETE.
|
|
649
|
+
if (options.former !== undefined)
|
|
650
|
+
app.post(options.former, answer, { parse: 'none' })
|
|
651
|
+
|
|
652
|
+
serveResourceMetadata(app, options.title, options.metadataPaths, options.path)
|
|
652
653
|
}
|
|
653
654
|
|
|
654
655
|
// An action a library offers a model: what the model reads of it, and the call it makes.
|
|
@@ -63,6 +63,8 @@ export interface NotifyOptions {
|
|
|
63
63
|
ttl?: Duration | undefined
|
|
64
64
|
// `false` keeps the notification in the inbox alone, without the push a person who opted in would get with `push()` listed.
|
|
65
65
|
push?: boolean | undefined
|
|
66
|
+
// `false` leaves the installed app's badge alone: the push otherwise carries the person's unread count, which the worker shows as the app badge.
|
|
67
|
+
badge?: boolean | undefined
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
export const MAX_TITLE = 200
|
|
@@ -278,7 +280,7 @@ function changed(user: string): void {
|
|
|
278
280
|
|
|
279
281
|
// Puts a notification in a person's inbox, which the `Bell` of kayjs-ui shows with its unread count and updates in every open tab. `user` is the id kayjs-auth, or whatever names the request's user, gives.
|
|
280
282
|
// The store is the app's `store.notifications`, which `sqliteData` and `pgData` fill; with none it is this process's memory. A notification is dropped after `ttl`, 90 days by default.
|
|
281
|
-
export async function notify(user: string, { title, url, ttl, push }: NotifyOptions): Promise<Notification> {
|
|
283
|
+
export async function notify(user: string, { title, url, ttl, push, badge }: NotifyOptions): Promise<Notification> {
|
|
282
284
|
const id = checkedUser(user)
|
|
283
285
|
const text = typeof title === 'string' ? title.replaceAll('\0', '').trim() : ''
|
|
284
286
|
|
|
@@ -297,7 +299,7 @@ export async function notify(user: string, { title, url, ttl, push }: NotifyOpti
|
|
|
297
299
|
changed(id)
|
|
298
300
|
|
|
299
301
|
if (push !== false)
|
|
300
|
-
pushAlongside(id, { title: text, url: link })
|
|
302
|
+
pushAlongside(id, { title: text, url: link }, badge === false ? undefined : async () => notificationStore().unread(id, Date.now()))
|
|
301
303
|
|
|
302
304
|
return { id: note.id, title: note.title, ...link === undefined ? {} : { url: link }, createdAt: new Date(createdAt), read: false }
|
|
303
305
|
}
|
package/src/server/offline.ts
CHANGED
|
@@ -30,7 +30,7 @@ const BACKSLASH = /\\/g
|
|
|
30
30
|
// A rule of the fonts' stylesheet naming its file and the range of characters it holds.
|
|
31
31
|
const FACE_RANGE = /url\("([^"]+)"\)[^}]*?unicode-range:([^;}]+)/g
|
|
32
32
|
// Bumped whenever the worker's own code changes, so every site installs it again.
|
|
33
|
-
const WORKER_VERSION =
|
|
33
|
+
const WORKER_VERSION = 9
|
|
34
34
|
// Past this many pages kept by default, the boot says to list the ones worth it.
|
|
35
35
|
const MANY_PAGES = 100
|
|
36
36
|
|
|
@@ -195,14 +195,31 @@ self.addEventListener('push', (event) => {
|
|
|
195
195
|
}
|
|
196
196
|
catch {}
|
|
197
197
|
|
|
198
|
-
event.waitUntil(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
198
|
+
event.waitUntil(Promise.all([
|
|
199
|
+
self.registration.showNotification(typeof data.title === 'string' && data.title !== '' ? data.title : location.hostname, {
|
|
200
|
+
body: typeof data.body === 'string' ? data.body : undefined,
|
|
201
|
+
tag: typeof data.tag === 'string' ? data.tag : undefined,
|
|
202
|
+
icon: typeof data.icon === 'string' ? linkOf(data.icon) : undefined,
|
|
203
|
+
data: { url: typeof data.url === 'string' ? linkOf(data.url) : linkOf('/') },
|
|
204
|
+
}),
|
|
205
|
+
badge(data.badge),
|
|
206
|
+
]))
|
|
204
207
|
})
|
|
205
208
|
|
|
209
|
+
// The app badge a push carries the unread count of: a count sets it, 0 clears it, and a browser without the Badging API leaves it.
|
|
210
|
+
async function badge(count) {
|
|
211
|
+
if (!Number.isSafeInteger(count) || count < 0)
|
|
212
|
+
return
|
|
213
|
+
|
|
214
|
+
try {
|
|
215
|
+
if (count > 0 && self.navigator.setAppBadge)
|
|
216
|
+
await self.navigator.setAppBadge(count)
|
|
217
|
+
else if (count === 0 && self.navigator.clearAppBadge)
|
|
218
|
+
await self.navigator.clearAppBadge()
|
|
219
|
+
}
|
|
220
|
+
catch {}
|
|
221
|
+
}
|
|
222
|
+
|
|
206
223
|
self.addEventListener('notificationclick', (event) => {
|
|
207
224
|
event.notification.close()
|
|
208
225
|
|
package/src/server/openapi.ts
CHANGED
|
@@ -7,7 +7,9 @@ import type { ServedPaths } from './served-paths'
|
|
|
7
7
|
import { posix } from 'node:path'
|
|
8
8
|
import { NON_ROOT_TRAILING_SLASH } from '../runtime/base'
|
|
9
9
|
import { escape } from '../runtime/escape'
|
|
10
|
+
import { jsonSchemaOf } from '../runtime/standard-schema'
|
|
10
11
|
import { inLocale, passGuards } from './actions'
|
|
12
|
+
import { declaredInputs } from './api-input'
|
|
11
13
|
import { API_PREFIX, KAY_PREFIX, openApiPaths, referenced } from './api-modules'
|
|
12
14
|
import { sharedContext } from './render'
|
|
13
15
|
import { apiRoutePath } from './routes'
|
|
@@ -208,7 +210,7 @@ export function openApiDocument(modules: MountedApi[], options: { title: string,
|
|
|
208
210
|
for (const module of modules) {
|
|
209
211
|
for (const route of module.instance.routes) {
|
|
210
212
|
const method = route.method.toUpperCase()
|
|
211
|
-
const hooks = route.hooks as Record<string, unknown> & { detail?: { summary?: string, description?: string, tags?: string[], deprecated?: boolean, hide?: boolean, operationId?: string, tool?: boolean | string | ActionTool } }
|
|
213
|
+
const hooks = { ...route.hooks as object, ...Object.fromEntries(Object.entries(declaredInputs(route.hooks)).map(([input, schema]) => [input, described(schema)])) } as Record<string, unknown> & { detail?: { summary?: string, description?: string, tags?: string[], deprecated?: boolean, hide?: boolean, operationId?: string, tool?: boolean | string | ActionTool } }
|
|
212
214
|
|
|
213
215
|
if ((!METHODS.has(method) && method !== 'ALL') || hooks.detail?.hide === true)
|
|
214
216
|
continue
|
|
@@ -361,7 +363,7 @@ function withRefusal(answers: Record<string, Schema>, hooks: Record<string, unkn
|
|
|
361
363
|
|
|
362
364
|
// A schema under the type it goes as: raw bytes as such, text as text, anything else as `fallback`.
|
|
363
365
|
function content(schema: unknown, fallback: string): Record<string, { schema: unknown }> {
|
|
364
|
-
const plain = schemaOf(schema) as Schema
|
|
366
|
+
const plain = schemaOf(described(schema)) as Schema
|
|
365
367
|
let type = fallback
|
|
366
368
|
|
|
367
369
|
if (plain.format === 'binary')
|
|
@@ -372,7 +374,14 @@ function content(schema: unknown, fallback: string): Record<string, { schema: un
|
|
|
372
374
|
return { [type]: { schema: plain } }
|
|
373
375
|
}
|
|
374
376
|
|
|
375
|
-
|
|
377
|
+
// What a schema describes as JSON Schema: itself, or what a Standard Schema validator says of its input, none for one that cannot.
|
|
378
|
+
function described(schema: unknown): unknown {
|
|
379
|
+
return typeof schema === 'object' && schema !== null ? jsonSchemaOf(schema) ?? {} : schema
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function holdsFile(given: unknown): boolean {
|
|
383
|
+
const schema = described(given)
|
|
384
|
+
|
|
376
385
|
if (typeof schema !== 'object' || schema === null)
|
|
377
386
|
return false
|
|
378
387
|
|