@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
package/src/build/client.ts
CHANGED
|
@@ -30,13 +30,16 @@ import { ASSET_PREFIX, clientDir, DEV_MAPS_DIR, MAPS_DIR, outputDir } from './as
|
|
|
30
30
|
import { AWAIT_ALERT_FILE } from './await-alert'
|
|
31
31
|
import { pruneNodes, pruneUtilityLayer } from './class-rules'
|
|
32
32
|
import { buildClassTable, mergesAtRuntime } from './class-table'
|
|
33
|
+
import { entryFile, KAY_OUTPUT, lazyEntryKey } from './entry-files'
|
|
33
34
|
import { CSS_FILE, findKayFiles, findProjectFiles, forgetSources, inWalkScope, keepSources, liftSources, readSource, readSourcePaths, readText, writeIfChanged } from './files'
|
|
34
35
|
import { Increments, realPaths, sameEntries } from './increments'
|
|
35
36
|
import { keepBundleMapCached, pruneKeptMaps } from './kept-maps'
|
|
36
37
|
import { hoistLayerOrder } from './layer-order'
|
|
38
|
+
import { eagerKeys, lazyKey } from './lazy-components'
|
|
39
|
+
import { noteLazy, staticClosure } from './lazy-manifest'
|
|
40
|
+
import { foldStubs, inRounds } from './lazy-stubs'
|
|
37
41
|
import { fileWords, importEdges, libraryOf, reachedFrom, reachingAny } from './libraries'
|
|
38
42
|
import { packagesOf } from './licenses'
|
|
39
|
-
import { throughLinks } from './links'
|
|
40
43
|
import { isPageFile, pageDirs } from './page-dirs'
|
|
41
44
|
import { kay } from './plugin'
|
|
42
45
|
import { unusedLibraryClasses } from './prune'
|
|
@@ -54,7 +57,7 @@ import { styleImports, withoutStyles, writeComponentStylesheets } from './styles
|
|
|
54
57
|
import { mergingSupports } from './supports'
|
|
55
58
|
import { warnBuiltThemeVariables } from './theme-vars'
|
|
56
59
|
import { analyzeKayCached, KayCompileError, keepAnalyses } from './transform'
|
|
57
|
-
import {
|
|
60
|
+
import { uiFilesOf, uiLayerClasses, uiPathsOf } from './ui'
|
|
58
61
|
import { kayFiles, variantFile, VariantIndex } from './variants'
|
|
59
62
|
|
|
60
63
|
export interface ClientOptions extends Pick<KayConfig, ClientBuildKey> {
|
|
@@ -91,6 +94,7 @@ type Outputs = Record<string, MetafileOutput>
|
|
|
91
94
|
|
|
92
95
|
const LEADING_DOT_SLASH = /^\.\//
|
|
93
96
|
const JS_OUTPUT = /\.js$/
|
|
97
|
+
|
|
94
98
|
const COMPILES_WASM = /\bWebAssembly\./
|
|
95
99
|
const STARTS_WORKER = /\bnew\s+(?:Shared)?Worker\(/
|
|
96
100
|
const OBJECT_URL = /\bcreateObjectURL\(/
|
|
@@ -215,7 +219,8 @@ export function clientSession(root: string, options: ClientOptions, settings: Se
|
|
|
215
219
|
|
|
216
220
|
const classTableText = JSON.stringify([classTable, islandTable])
|
|
217
221
|
// `src/ui.ts` is written into the components it restyles, none of which imports it, so no chunk lists it among its inputs.
|
|
218
|
-
|
|
222
|
+
|
|
223
|
+
const islandsAgain = !previous || !sameEntries(previous.sources.islands, sources.islands) || files.some(file => previous.islandInputs.has(file) || uiPathsOf(realRoot).includes(file) || file === join(realRoot, AWAIT_ALERT_FILE)) || previous.classTable !== classTableText || (!options.hot && (previous.sources.actionForms !== sources.actionForms || previous.sources.actionProps !== sources.actionProps))
|
|
219
224
|
const stylesAgain = !previous || await increments!.stylesChanged(previous, sources, texts)
|
|
220
225
|
|
|
221
226
|
if (previous && islandsAgain)
|
|
@@ -428,7 +433,7 @@ async function writeClasses(root: string, classes: Set<string>): Promise<void> {
|
|
|
428
433
|
const file = projectPaths(root).classes
|
|
429
434
|
|
|
430
435
|
await writeIfChanged(join(dirname(file), '.gitignore'), '*\n!/scratch/\n!/scratch/**\n')
|
|
431
|
-
await writeIfChanged(file, [...classes].sort().join('\n'))
|
|
436
|
+
await writeIfChanged(file, [...new Set([...classes, ...uiLayerClasses(root)])].sort().join('\n'))
|
|
432
437
|
}
|
|
433
438
|
|
|
434
439
|
// The table of Tailwind classes a later one overrides, from every word of the components and of the other files an app writes markup in; none when the app has no Tailwind.
|
|
@@ -483,15 +488,15 @@ export async function islandClassTableOf(root: string, sources: Pick<ClientSourc
|
|
|
483
488
|
const bundled = await reachedFrom([...entries], edges)
|
|
484
489
|
const renderers = new Set([...shorthand.keys(), ...(await markupFiles(root, sources)).filter(file => RENDERING_FILE.test(file))])
|
|
485
490
|
const outside = [...renderers].filter(file => !bundled.has(realpathSync(file)))
|
|
486
|
-
const ui = join(root, UI_FILE)
|
|
487
491
|
// `src/ui.ts` is written into the components it restyles, none of which imports it.
|
|
488
492
|
const reaching = await reachingAny(outside.map(file => realpathSync(file)), entries, edges)
|
|
489
493
|
const reachingOutside = outside.filter(file => reaching.has(realpathSync(file)))
|
|
490
494
|
const alert = join(root, AWAIT_ALERT_FILE)
|
|
491
|
-
const
|
|
495
|
+
const uiFiles = uiFilesOf(root)
|
|
496
|
+
const written = [...bundled, ...uiFiles, ...existsSync(alert) ? [alert] : [], ...reachingOutside]
|
|
492
497
|
|
|
493
498
|
// The browser merges classes only where a component writes a class that is not a literal, a spread or a part; two literals side by side were resolved while compiling.
|
|
494
|
-
if (!written.some(file => mergesAtRuntime(file)))
|
|
499
|
+
if (!written.some(file => mergesAtRuntime(file, uiFiles)))
|
|
495
500
|
return undefined
|
|
496
501
|
|
|
497
502
|
const words = new Set(written.flatMap(file => fileWords(file)))
|
|
@@ -500,7 +505,14 @@ export async function islandClassTableOf(root: string, sources: Pick<ClientSourc
|
|
|
500
505
|
}
|
|
501
506
|
|
|
502
507
|
// `inputs` holds the modules of each chunk, `maps` the source maps written.
|
|
503
|
-
|
|
508
|
+
interface Bundled { manifest: Omit<ClientManifest, 'styles'>, inputs: ChunkInputs, maps: string[] }
|
|
509
|
+
|
|
510
|
+
async function bundleIslands(root: string, islands: Map<string, string>, files: string[], actionForms: boolean, actionProps: boolean, options: ClientOptions, classTable?: ClassTable, islandTable?: ClassTable): Promise<Bundled> {
|
|
511
|
+
return inRounds(async last => bundleRound(root, islands, files, actionForms, actionProps, options, last, classTable, islandTable))
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// One build of the islands, which `foldStubs` ends when lazy components that do not pay were left.
|
|
515
|
+
async function bundleRound(root: string, islands: Map<string, string>, files: string[], actionForms: boolean, actionProps: boolean, options: ClientOptions, last: boolean, classTable?: ClassTable, islandTable?: ClassTable): Promise<Bundled> {
|
|
504
516
|
const navigation = options.client?.navigation ?? true
|
|
505
517
|
|
|
506
518
|
if (islands.size === 0 && !navigation)
|
|
@@ -561,7 +573,7 @@ async function bundleIslands(root: string, islands: Map<string, string>, files:
|
|
|
561
573
|
|
|
562
574
|
// Without the registry in the boot, each island is an entry point of its own.
|
|
563
575
|
const islandFiles = options.hot ? [] : [...entries.values()]
|
|
564
|
-
const chunk = await runtimeChunk(entryFile, { plugins: plugins(), define, external, islands: islandFiles, cache: { file: join(projectPaths(root).cache, `runtime-search-${options.hot ? 'dev' : 'build'}.json`), key: `${JSON.stringify([options.librarySettings, options.inspect, options.client?.navigation, trees, islandFiles])}\0${await Bun.file(bootFile).text()}` } })
|
|
576
|
+
const chunk = await runtimeChunk(entryFile, { plugins: plugins(), define, external, islands: islandFiles, cache: { file: join(projectPaths(root).cache, `runtime-search-${options.hot ? 'dev' : 'build'}.json`), key: `${JSON.stringify([options.librarySettings, options.inspect, options.client?.navigation, trees, islandFiles, eagerKeys()])}\0${await Bun.file(bootFile).text()}` } })
|
|
565
577
|
|
|
566
578
|
// In development the entry keeps its own code, the islands it imports by their hashed names included: the runtime's chunk then stays as it was through an edit of an island, which swaps in alone.
|
|
567
579
|
// A second entry point importing the runtime alone has Bun give it that chunk of its own, which it would otherwise merge into the entry's.
|
|
@@ -591,6 +603,8 @@ async function bundleIslands(root: string, islands: Map<string, string>, files:
|
|
|
591
603
|
// A production page posting forms and holding no island loads navigation alone, from a build of its own: in the islands' build it would move the navigation code out of their runtime's chunk, adding a file to every page. A static export has no server to post to, and an app rendering no such form has no page loading it.
|
|
592
604
|
const [build, nav] = await Promise.all([Bun.build({ ...config, outdir: clientDir(root) }), navigation && actionForms && !options.hot && options.exported !== true ? bundleNavigation(root, options, { ...config, plugins: plugins() }) : undefined])
|
|
593
605
|
|
|
606
|
+
await foldStubs(build, nav, last, lazyEntryKey(root, new Set(islands.values())))
|
|
607
|
+
|
|
594
608
|
if (!build.success) {
|
|
595
609
|
await refuseBuiltinImports(root, build.logs, islands.values(), config)
|
|
596
610
|
|
|
@@ -789,6 +803,10 @@ export function islandManifest(root: string, outputs: Outputs, islands: Map<stri
|
|
|
789
803
|
|
|
790
804
|
const file = entryFile(root, meta.entryPoint, files)
|
|
791
805
|
|
|
806
|
+
// A `.kay` entry, an island or not, is a component another island may load lazily, which the page preloads when its server drew it.
|
|
807
|
+
if (KAY_OUTPUT.test(meta.entryPoint))
|
|
808
|
+
noteLazy(manifest, lazyKey(root, resolve(variantFile(meta.entryPoint))), meta.entryPoint, [...closure(output)].map(assetUrl))
|
|
809
|
+
|
|
792
810
|
// Any other entry point is the entry, or a chunk some code imports dynamically, loaded when it asks for it.
|
|
793
811
|
if (file === undefined)
|
|
794
812
|
continue
|
|
@@ -818,20 +836,6 @@ export function islandManifest(root: string, outputs: Outputs, islands: Map<stri
|
|
|
818
836
|
return manifest
|
|
819
837
|
}
|
|
820
838
|
|
|
821
|
-
// Every chunk a chunk needs before it can run, itself included.
|
|
822
|
-
function staticClosure(outputs: Outputs, output: string, seen = new Set<string>()): Set<string> {
|
|
823
|
-
if (seen.has(output))
|
|
824
|
-
return seen
|
|
825
|
-
|
|
826
|
-
seen.add(output)
|
|
827
|
-
for (const imported of outputs[output]?.imports ?? []) {
|
|
828
|
-
if (imported.kind === 'import-statement')
|
|
829
|
-
staticClosure(outputs, imported.path, seen)
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
return seen
|
|
833
|
-
}
|
|
834
|
-
|
|
835
839
|
// The URL a page loads an entry by, and the chunks it imports statically, which the page preloads.
|
|
836
840
|
function entryChunks(root: string, outputs: Outputs, entry: string): { entry: string, imports: string[] } | undefined {
|
|
837
841
|
const entries = new Set([entry])
|
|
@@ -852,13 +856,6 @@ function islandPath(root: string, input: string): string {
|
|
|
852
856
|
return relative(root, resolve(input)).replaceAll('\\', '/')
|
|
853
857
|
}
|
|
854
858
|
|
|
855
|
-
// Bun names entry points relative to the working directory, not the root: from a library holding a test app, its layout and the app's share a path.
|
|
856
|
-
function entryFile(root: string, entryPoint: string, files: Set<string>): string | undefined {
|
|
857
|
-
const point = resolve(variantFile(entryPoint))
|
|
858
|
-
|
|
859
|
-
return [point, throughLinks(root, point)].find(file => files.has(file))
|
|
860
|
-
}
|
|
861
|
-
|
|
862
859
|
function assetUrl(output: string): string {
|
|
863
860
|
return `${ASSET_PREFIX}${output.replace(LEADING_DOT_SLASH, '')}`
|
|
864
861
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { resolve } from 'node:path'
|
|
2
|
+
import { lazyKey } from './lazy-components'
|
|
3
|
+
import { throughLinks } from './links'
|
|
4
|
+
import { variantFile } from './variants'
|
|
5
|
+
|
|
6
|
+
export const KAY_OUTPUT = /\.kay(?:\?uses=[^?]*)?$/
|
|
7
|
+
|
|
8
|
+
// Bun names entry points relative to the working directory, not the root: from a library holding a test app, its layout and the app's share a path.
|
|
9
|
+
// The file among `files` a build's entry point stands for, a variant or a link followed.
|
|
10
|
+
export function entryFile(root: string, entryPoint: string, files: Set<string>): string | undefined {
|
|
11
|
+
const point = resolve(variantFile(entryPoint))
|
|
12
|
+
|
|
13
|
+
return [point, throughLinks(root, point)].find(file => files.has(file))
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// The lazy key of an entry point that is a component and no island.
|
|
17
|
+
export function lazyEntryKey(root: string, islandFiles: Set<string>): (entryPoint: string) => string | undefined {
|
|
18
|
+
return entryPoint => KAY_OUTPUT.test(entryPoint) && entryFile(root, entryPoint, islandFiles) === undefined ? lazyKey(root, resolve(variantFile(entryPoint))) : undefined
|
|
19
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { ImportedComponent, ImportedComponents } from '../compiler/lazy-imports'
|
|
2
|
+
import type { ImportBinding } from '../compiler/script-shared'
|
|
3
|
+
import { readFileSync, realpathSync, statSync } from 'node:fs'
|
|
4
|
+
import { basename, relative } from 'node:path'
|
|
5
|
+
import { deferredProps, eagerReach, lazyImports } from '../compiler/lazy-imports'
|
|
6
|
+
import { parseKay } from '../compiler/parser'
|
|
7
|
+
import { resolveFrom } from './files'
|
|
8
|
+
import { fences } from './libraries'
|
|
9
|
+
|
|
10
|
+
// A default import of a `.kay` module, as a script writes it on a line of its own.
|
|
11
|
+
const KAY_IMPORT = /^[ \t]*import\s+([\w$]+)\s+from\s*(['"])([^'"]+\.kay)\2/gm
|
|
12
|
+
|
|
13
|
+
interface Facts {
|
|
14
|
+
// The own stamp of the module and of each module its answer reads: the facts are read again once any changes.
|
|
15
|
+
stamps: Map<string, string>
|
|
16
|
+
deferred: string[]
|
|
17
|
+
size: number
|
|
18
|
+
// The paths of the components the module loads with it, which a module importing it does not need a chunk for.
|
|
19
|
+
reach: string[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// What a key may not hold, as the page writes keys apart by a space inside an attribute.
|
|
23
|
+
const UNSAFE_KEY = /[^\w.-]/g
|
|
24
|
+
|
|
25
|
+
const known = new Map<string, Facts>()
|
|
26
|
+
|
|
27
|
+
function stampOf(path: string): string | undefined {
|
|
28
|
+
const stats = statSync(path, { throwIfNoEntry: false })
|
|
29
|
+
|
|
30
|
+
return stats ? `${stats.mtimeMs}-${stats.size}` : undefined
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function importsOf(source: string): ImportBinding[] {
|
|
34
|
+
return [...fences(source).matchAll(KAY_IMPORT)].map(([line, local, , specifier]) => ({ local: local!, imported: 'default', source: specifier!, typeOnly: false, span: { start: 0, end: 0 }, declaration: { start: source.indexOf(line), end: source.indexOf(line) + line.trimEnd().length } }))
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// The props a component draws only where a branch may not render, which hold when each module it passes a block to says the same of that block: a wrapper of a dialog defers what the dialog does.
|
|
38
|
+
function factsOf(path: string, visiting: ReadonlySet<string>): Facts | undefined {
|
|
39
|
+
const stamp = stampOf(path)
|
|
40
|
+
|
|
41
|
+
if (stamp === undefined || visiting.has(path))
|
|
42
|
+
return undefined
|
|
43
|
+
|
|
44
|
+
const kept = known.get(path)
|
|
45
|
+
|
|
46
|
+
if (kept && [...kept.stamps].every(([module, expected]) => stampOf(module) === expected))
|
|
47
|
+
return kept
|
|
48
|
+
|
|
49
|
+
const source = readFileSync(path, 'utf8')
|
|
50
|
+
const stamps = new Map([[path, stamp]])
|
|
51
|
+
const inside = new Set([...visiting, path])
|
|
52
|
+
const file = parseKay(source)
|
|
53
|
+
const imports = importsOf(source)
|
|
54
|
+
const children: Record<string, ImportedComponent> = {}
|
|
55
|
+
|
|
56
|
+
for (const { source: specifier } of imports) {
|
|
57
|
+
const found = resolveFrom(specifier, path)
|
|
58
|
+
const facts = found === undefined ? undefined : factsOf(found, inside)
|
|
59
|
+
|
|
60
|
+
for (const [module, other] of facts?.stamps ?? [])
|
|
61
|
+
stamps.set(module, other)
|
|
62
|
+
|
|
63
|
+
if (found !== undefined && facts !== undefined)
|
|
64
|
+
children[specifier] = { key: found, deferred: facts.deferred, size: facts.size, reach: facts.reach }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const deferred = deferredProps(file, imports, specifier => children[specifier])
|
|
68
|
+
const reach = eagerReach(imports, children, lazyImports(file, imports, children))
|
|
69
|
+
const facts = { stamps, deferred, size: source.length, reach }
|
|
70
|
+
|
|
71
|
+
known.set(path, facts)
|
|
72
|
+
|
|
73
|
+
return facts
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// What names a lazy component's chunk to the page that draws it and to the build's manifest: the file's name and a hash of its path from the root, the same wherever it is read from.
|
|
77
|
+
export function lazyKey(root: string, path: string): string {
|
|
78
|
+
const name = basename(path, '.kay').replaceAll(UNSAFE_KEY, '_')
|
|
79
|
+
|
|
80
|
+
return `${name}-${Bun.hash(relative(realOf(root), realOf(path)).replaceAll('\\', '/')).toString(36).slice(0, 6)}`
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// The components whose lazy chunk the build found to be a stub, which then load with the code drawing them.
|
|
84
|
+
const eager = new Set<string>()
|
|
85
|
+
|
|
86
|
+
// Marks components as loading with their importers; whether any was not marked already.
|
|
87
|
+
export function keepEager(keys: Iterable<string>): boolean {
|
|
88
|
+
const before = eager.size
|
|
89
|
+
|
|
90
|
+
for (const key of keys)
|
|
91
|
+
eager.add(key)
|
|
92
|
+
|
|
93
|
+
return eager.size > before
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// The keys marked so far, which a cache of what depends on the imports the islands make has to key on.
|
|
97
|
+
export function eagerKeys(): string[] {
|
|
98
|
+
return [...eager].sort()
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Its path with the links resolved, or as it is when no file is there.
|
|
102
|
+
function realOf(path: string): string {
|
|
103
|
+
try {
|
|
104
|
+
return realpathSync(path)
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return path
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// The `.kay` components a file imports that its templates may draw lazily: each with the key naming its chunk (its path from the root) and the props it draws only inside a branch that may not render.
|
|
112
|
+
export function importedComponents(file: string, source: string, root: string): ImportedComponents {
|
|
113
|
+
const found: Record<string, ImportedComponent> = {}
|
|
114
|
+
const self = realOf(file)
|
|
115
|
+
|
|
116
|
+
for (const { source: specifier } of importsOf(source)) {
|
|
117
|
+
const path = resolveFrom(specifier, file)
|
|
118
|
+
|
|
119
|
+
// A component drawing itself stays eager whatever its import is written as: its module is the one loading, so a chunk would only make its nested draws late.
|
|
120
|
+
if (path !== undefined && realOf(path) === self)
|
|
121
|
+
continue
|
|
122
|
+
|
|
123
|
+
const facts = path === undefined ? undefined : factsOf(path, new Set())
|
|
124
|
+
|
|
125
|
+
if (path !== undefined && facts !== undefined)
|
|
126
|
+
found[specifier] = { key: lazyKey(root, path), deferred: facts.deferred, size: eager.has(lazyKey(root, path)) ? 0 : facts.size, reach: facts.reach.map(other => lazyKey(root, other)) }
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return found
|
|
130
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
type Outputs = Record<string, { imports: { kind: string, path: string }[] }>
|
|
2
|
+
|
|
3
|
+
// A component's chunk by its key; two files that hash to one key would load each other's code, so that is refused.
|
|
4
|
+
export function noteLazy(manifest: { lazies?: Record<string, string[]> | undefined }, key: string, file: string, chunks: string[]): void {
|
|
5
|
+
const lazies = manifest.lazies ??= {}
|
|
6
|
+
|
|
7
|
+
if (lazies[key] !== undefined && lazies[key].join() !== chunks.join())
|
|
8
|
+
throw new Error(`${file} and another component share the lazy key ${key}: rename one of the files`)
|
|
9
|
+
|
|
10
|
+
lazies[key] = chunks
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Every chunk a chunk needs before it can run, itself included.
|
|
14
|
+
export function staticClosure(outputs: Outputs, output: string, seen = new Set<string>()): Set<string> {
|
|
15
|
+
if (seen.has(output))
|
|
16
|
+
return seen
|
|
17
|
+
|
|
18
|
+
seen.add(output)
|
|
19
|
+
for (const imported of outputs[output]?.imports ?? []) {
|
|
20
|
+
if (imported.kind === 'import-statement')
|
|
21
|
+
staticClosure(outputs, imported.path, seen)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return seen
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type Entries = Record<string, { entryPoint?: string | undefined, inputs?: Record<string, { bytesInOutput?: number | undefined }> | undefined }>
|
|
28
|
+
|
|
29
|
+
// What the lazy runtime and a request cost a page, minified: the lazy chunks of a build holding less than this between them leave a page heavier than the code they keep off it.
|
|
30
|
+
const LAZY_PAYOFF = 6000
|
|
31
|
+
|
|
32
|
+
// The keys of the lazy components that do not pay: a chunk that is only a stub, its code sitting in chunks the islands load up front, or all of them when the chunks with code of their own weigh less than `LAZY_PAYOFF` together. The build runs again with these imports eager.
|
|
33
|
+
export function stubKeys(outputs: Entries, keyOf: (entryPoint: string) => string | undefined): string[] {
|
|
34
|
+
const stubs: string[] = []
|
|
35
|
+
const held: string[] = []
|
|
36
|
+
let bytes = 0
|
|
37
|
+
|
|
38
|
+
for (const meta of Object.values(outputs)) {
|
|
39
|
+
const key = meta.entryPoint === undefined ? undefined : keyOf(meta.entryPoint)
|
|
40
|
+
|
|
41
|
+
if (key === undefined)
|
|
42
|
+
continue
|
|
43
|
+
|
|
44
|
+
const own = Object.values(meta.inputs ?? {}).reduce((sum, input) => sum + (input.bytesInOutput ?? 0), 0)
|
|
45
|
+
|
|
46
|
+
if (own === 0) {
|
|
47
|
+
stubs.push(key)
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
held.push(key)
|
|
51
|
+
bytes += own
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return bytes < LAZY_PAYOFF ? [...stubs, ...held] : stubs
|
|
56
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { rm } from 'node:fs/promises'
|
|
2
|
+
import { keepEager } from './lazy-components'
|
|
3
|
+
import { stubKeys } from './lazy-manifest'
|
|
4
|
+
|
|
5
|
+
// The last round builds whatever it finds.
|
|
6
|
+
const ROUNDS = 3
|
|
7
|
+
|
|
8
|
+
class Folded extends Error {}
|
|
9
|
+
|
|
10
|
+
// Marks the lazy components of the build that do not pay (see `stubKeys`) to load with the code drawing them, and ends the round, its files removed, when there were some: what the runtime chunk holds follows the imports the islands make, so the build is searched and run again.
|
|
11
|
+
export async function foldStubs(build: Bun.BuildOutput, nav: { build: Bun.BuildOutput } | undefined, last: boolean, keyOf: (entryPoint: string) => string | undefined): Promise<void> {
|
|
12
|
+
if (last || !build.success || !keepEager(stubKeys(build.metafile!.outputs, keyOf)))
|
|
13
|
+
return
|
|
14
|
+
|
|
15
|
+
await Promise.all([build, nav?.build].flatMap(each => each?.outputs ?? []).map(async output => rm(output.path, { force: true })))
|
|
16
|
+
|
|
17
|
+
throw new Folded()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Runs a build, again when a round folded stubs; the run is told when it is the last.
|
|
21
|
+
export async function inRounds<T>(run: (last: boolean) => Promise<T>): Promise<T> {
|
|
22
|
+
for (let round = 0; ; round++) {
|
|
23
|
+
try {
|
|
24
|
+
return await run(round === ROUNDS - 1)
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (!(error instanceof Folded))
|
|
28
|
+
throw error
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
package/src/build/plugin.ts
CHANGED
|
@@ -22,6 +22,7 @@ import { liveIds } from './live-ids'
|
|
|
22
22
|
import { withLocaleLinks } from './navigation-locale'
|
|
23
23
|
import { embeddedMapTail } from './sourcemap'
|
|
24
24
|
import { embeddedMapCached, transformKayCached } from './transform'
|
|
25
|
+
import { uiLayerPathsOf } from './ui'
|
|
25
26
|
import { specializedSource, USES_QUERY, VariantIndex } from './variants'
|
|
26
27
|
|
|
27
28
|
export interface KayPluginOptions {
|
|
@@ -47,6 +48,8 @@ export interface KayPluginOptions {
|
|
|
47
48
|
inspect?: boolean | undefined
|
|
48
49
|
// The classes a later Tailwind class overrides, with which an island's literal classes resolve while compiling.
|
|
49
50
|
classTable?: ClassTable | undefined
|
|
51
|
+
// False draws every component at once: the bundle of a component mounted by a test, which has no server markup to claim and nothing to wait for.
|
|
52
|
+
lazy?: boolean | undefined
|
|
50
53
|
// A browser build's API trees, whose modules islands get as stubs, and the modules it leaves to the page, which a worker's bundle takes as the islands do.
|
|
51
54
|
api?: RouteMount[] | undefined
|
|
52
55
|
external?: string[] | undefined
|
|
@@ -85,13 +88,13 @@ const WORKER_BUNDLE = join(import.meta.dir, 'worker-bundle.ts')
|
|
|
85
88
|
const bundledWorkers = new Map<string, { result: WorkerResult, stamp: string }>()
|
|
86
89
|
|
|
87
90
|
// Serves a component as the variant its `?uses=` names: resolved from the importer, loaded specialized to its features.
|
|
88
|
-
function variantHooks(build: Bun.PluginBuilder, load: (file: string, twin: boolean, features: ReadonlySet<string>) => Promise<Bun.OnLoadResult>): void {
|
|
91
|
+
function variantHooks(build: Bun.PluginBuilder, load: (file: string, twin: boolean, features: ReadonlySet<string>, written?: ReadonlySet<string>) => Promise<Bun.OnLoadResult>): void {
|
|
89
92
|
build.onResolve({ filter: USES_QUERY }, ({ path, importer }) => {
|
|
90
|
-
const
|
|
91
|
-
const base = path.slice(0, path.length -
|
|
93
|
+
const query = USES_SUFFIX.exec(path)![0]
|
|
94
|
+
const base = path.slice(0, path.length - query.length)
|
|
92
95
|
|
|
93
96
|
try {
|
|
94
|
-
return { path: `${Bun.resolveSync(base, dirname(withoutTwin(importer.replace(USES_SUFFIX, ''))))}
|
|
97
|
+
return { path: `${Bun.resolveSync(base, dirname(withoutTwin(importer.replace(USES_SUFFIX, ''))))}${query}`, namespace: VARIANT_NAMESPACE }
|
|
95
98
|
}
|
|
96
99
|
catch {
|
|
97
100
|
// The normal resolver names what is wrong with the specifier.
|
|
@@ -99,9 +102,10 @@ function variantHooks(build: Bun.PluginBuilder, load: (file: string, twin: boole
|
|
|
99
102
|
}
|
|
100
103
|
})
|
|
101
104
|
build.onLoad({ filter: USES_QUERY, namespace: VARIANT_NAMESPACE }, async ({ path }) => {
|
|
102
|
-
const features = USES_QUERY.exec(path)!
|
|
105
|
+
const [, features, written] = USES_QUERY.exec(path)!
|
|
106
|
+
const query = USES_SUFFIX.exec(path)![0]
|
|
103
107
|
|
|
104
|
-
return load(path.slice(0, path.length -
|
|
108
|
+
return load(path.slice(0, path.length - query.length), false, new Set(features!.split('-').filter(Boolean)), written === undefined ? undefined : new Set(written.split('-').filter(Boolean)))
|
|
105
109
|
})
|
|
106
110
|
}
|
|
107
111
|
|
|
@@ -163,11 +167,12 @@ export function kayPlugin(options: KayPluginOptions, workers: string[]): BunPlug
|
|
|
163
167
|
const dist = clientDir(root)
|
|
164
168
|
|
|
165
169
|
const bundleWorker = async (path: string): Promise<string> => {
|
|
166
|
-
const
|
|
170
|
+
const layers = uiLayerPathsOf(root)
|
|
171
|
+
const bundle: WorkerBundle = { entry: path, outdir: join(dist, 'assets'), minify: config.minify ?? false, define: config.define ?? {}, options: { ...options, root, anchor: undefined, anchored: undefined, variants: undefined }, workers: [...workers, path], uiLayers: layers }
|
|
167
172
|
const key = JSON.stringify(bundle)
|
|
168
173
|
const kept = bundledWorkers.get(key)
|
|
169
174
|
|
|
170
|
-
if (kept !== undefined && kept.result.outputs.every(output => existsSync(output)) && stampOf(kept.result.inputs) === kept.stamp)
|
|
175
|
+
if (kept !== undefined && kept.result.outputs.every(output => existsSync(output)) && stampOf([...kept.result.inputs, ...layers]) === kept.stamp)
|
|
171
176
|
return kept.result.name
|
|
172
177
|
|
|
173
178
|
const started = Date.now()
|
|
@@ -193,7 +198,7 @@ export function kayPlugin(options: KayPluginOptions, workers: string[]): BunPlug
|
|
|
193
198
|
|
|
194
199
|
// A file written while the bundle ran may not be the one it read.
|
|
195
200
|
if (!result.ships && result.inputs.every(input => (statSync(input, { throwIfNoEntry: false })?.mtimeMs ?? 0) < started))
|
|
196
|
-
bundledWorkers.set(key, { result, stamp: stampOf(result.inputs) })
|
|
201
|
+
bundledWorkers.set(key, { result, stamp: stampOf([...result.inputs, ...layers]) })
|
|
197
202
|
|
|
198
203
|
return result.name
|
|
199
204
|
}
|
|
@@ -256,11 +261,11 @@ export function kayPlugin(options: KayPluginOptions, workers: string[]): BunPlug
|
|
|
256
261
|
const pointed = async (contents: string, loader: Bun.JavaScriptLoader = 'ts') => options.direct === true ? directImports(contents, loader) : contents
|
|
257
262
|
|
|
258
263
|
// A twin's frames show its namespace and the whole path, where a file's show its path from where the build ran.
|
|
259
|
-
const load = async (file: string, twin = false, features?: ReadonlySet<string>) => {
|
|
264
|
+
const load = async (file: string, twin = false, features?: ReadonlySet<string>, written?: ReadonlySet<string>) => {
|
|
260
265
|
const original = await Bun.file(withoutTwin(file)).text()
|
|
261
266
|
const source = features === undefined ? original : specializedSource(original, features, withoutTwin(file))
|
|
262
267
|
|
|
263
|
-
const compiled = await transformKayCached(source, file, { target, hydratable: options.hydratable ?? true, root: options.root, pages: options.pages, cacheDir: options.cacheDir, inspect: options.inspect, classTable: options.classTable, variant: features === undefined ? undefined : [...features].sort().join('.') })
|
|
268
|
+
const compiled = await transformKayCached(source, file, { target, hydratable: options.hydratable ?? true, root: options.root, pages: options.pages, cacheDir: options.cacheDir, inspect: options.inspect, classTable: options.classTable, lazy: options.lazy, variant: features === undefined ? undefined : `${[...features].sort().join('.')}${written === undefined ? '' : `~${[...written].sort().join('.')}`}`, writtenProps: written })
|
|
264
269
|
const code = target === 'dom' ? await variantIndex.variantImports(compiled, withoutTwin(file), original) : compiled
|
|
265
270
|
const contents = await pointed(await shippingFiles(expandGlobs(code, withoutTwin(file), root, 'ts'), withoutTwin(file), 'ts'))
|
|
266
271
|
|
|
@@ -28,7 +28,7 @@ const KAY_SPECIFIER = /^kay(?:\/|$)/
|
|
|
28
28
|
// Lazy modules whose imports of the runtime stay with them rather than join the chunk a page loads: the code reviving an action, which only a page passing an island one loads, carries the action runtime along, the code posting an action call, which the first call loads, and the reader of a streaming action's answer, whose `ended()`, `onData()` and `retry()` a page with no such action does not carry.
|
|
29
29
|
const STANDALONE = new Set([resolve(RUNTIME_DIR, 'action-reviver.ts'), resolve(RUNTIME_DIR, 'action-stream.ts'), resolve(RUNTIME_DIR, 'action-post.ts')])
|
|
30
30
|
// Entries of the runtime that bundle a package, or that few pages use, which stay in the chunks of the islands importing them rather than weigh on every page: the `for`, `await` and `try` blocks, the spread and the localizing of the links an island writes, which most islands do without.
|
|
31
|
-
const OWN_CHUNK = new Set(['kay/markdown', 'kay/internal/title', 'kay/dom-loop', 'kay/dom-await', 'kay/dom-try', 'kay/dom-spread', 'kay/i18n-links'])
|
|
31
|
+
const OWN_CHUNK = new Set(['kay/markdown', 'kay/internal/title', 'kay/dom-loop', 'kay/dom-await', 'kay/dom-try', 'kay/dom-spread', 'kay/dom-lazy', 'kay/i18n-links'])
|
|
32
32
|
const RELATIVE = /^\.\.?\//
|
|
33
33
|
const EXTENSIONS = ['.ts', '.tsx', '/index.ts']
|
|
34
34
|
const ALL = '*'
|
package/src/build/styles.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { globbedFiles } from './glob'
|
|
|
18
18
|
import { importsOf, libraryOf } from './libraries'
|
|
19
19
|
import { outOfStore, throughLinks } from './links'
|
|
20
20
|
import { recipeLifter } from './recipe-classes'
|
|
21
|
-
import {
|
|
21
|
+
import { uiEntryOf, uiFilesOf } from './ui'
|
|
22
22
|
|
|
23
23
|
const ABSOLUTE_URL = /^\//
|
|
24
24
|
const FONT_FILE = /\.(?:woff2?|ttf|otf)(?:[?#].*)?$/i
|
|
@@ -273,8 +273,8 @@ export function styleImports(root: string, libraries: KayLibrary[] = [], loaded?
|
|
|
273
273
|
server ? serverAssets(source.slice(server.start, server.end), path, 'ts') : undefined,
|
|
274
274
|
])
|
|
275
275
|
|
|
276
|
-
// A component `src/ui.ts` restyles has the classes written there, which the page using it keeps the rules of.
|
|
277
|
-
const restyled = uiEntryOf(root, path) === undefined ? '' : importing(note(path,
|
|
276
|
+
// A component `src/ui.ts` or an extension's `ui` file restyles has the classes written there, which the page using it keeps the rules of.
|
|
277
|
+
const restyled = uiEntryOf(root, path) === undefined ? '' : importing(note(path, uiFilesOf(root)))
|
|
278
278
|
|
|
279
279
|
// A component with an `await` may draw the app's `await-failed.kay`, which the compiler imports, so its styles go to the page too.
|
|
280
280
|
const alert = AWAIT_LINE.test(source) ? awaitAlertOf(root, path) : undefined
|
package/src/build/transform.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Diagnostic, SourceMap } from '../compiler'
|
|
2
2
|
import type { ErrorName } from '../compiler/errors'
|
|
3
3
|
import type { IslandCause } from '../compiler/island-cause'
|
|
4
|
+
import type { ImportedComponents } from '../compiler/lazy-imports'
|
|
4
5
|
import type { LintLevels } from '../compiler/lints'
|
|
5
6
|
import type { ImportedSignals } from '../compiler/module-signals'
|
|
6
7
|
import type { ClassTable } from '../runtime/class-table'
|
|
@@ -17,6 +18,7 @@ import { projectPaths } from '../project'
|
|
|
17
18
|
import { awaitAlertOf } from './await-alert'
|
|
18
19
|
import { countCache, pruneCache, readCacheEntry, writeCacheEntry } from './cache'
|
|
19
20
|
import { compilerFingerprint } from './fingerprint'
|
|
21
|
+
import { importedComponents } from './lazy-components'
|
|
20
22
|
import { throughLinks } from './links'
|
|
21
23
|
import { namedRefresh } from './named-refresh'
|
|
22
24
|
import { isPageFile, realpathOrSelf } from './page-dirs'
|
|
@@ -61,8 +63,12 @@ export interface TransformOptions {
|
|
|
61
63
|
classTable?: ClassTable | undefined
|
|
62
64
|
// The features of a component its importer's call sites use, as `variants.ts` reads them: part of the cache key, as the source it was specialized from is the same file's.
|
|
63
65
|
variant?: string | undefined
|
|
66
|
+
// The props the call sites of a variant write, when it knows them all: the component leaves the others out of the rest it forwards.
|
|
67
|
+
writtenProps?: ReadonlySet<string> | undefined
|
|
64
68
|
// The server's build of an app with Tailwind, which merges a shorthand beside a static `class` while rendering; set by `transformKayCached` from the app's stylesheets.
|
|
65
69
|
classMerge?: boolean | undefined
|
|
70
|
+
// False keeps every component's import eager.
|
|
71
|
+
lazy?: boolean | undefined
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
interface Compiled {
|
|
@@ -100,8 +106,8 @@ export class KayCompileError extends Error {
|
|
|
100
106
|
}
|
|
101
107
|
|
|
102
108
|
// .kay source to TypeScript building HTML strings on the server and DOM nodes in the browser; Bun strips the types when it loads the result.
|
|
103
|
-
export function transformKay(source: string, filename: string, options: TransformOptions, signals?: ImportedSignals): string {
|
|
104
|
-
const { code, map } = compile(source, filename, options, signals)
|
|
109
|
+
export function transformKay(source: string, filename: string, options: TransformOptions, signals?: ImportedSignals, components?: ImportedComponents): string {
|
|
110
|
+
const { code, map } = compile(source, filename, options, signals, components)
|
|
105
111
|
|
|
106
112
|
registerSourceMap(filename, { source, tsx: code, map }, options.target === 'dom')
|
|
107
113
|
|
|
@@ -121,9 +127,10 @@ export async function transformKayCached(original: string, filename: string, giv
|
|
|
121
127
|
|
|
122
128
|
// Read once: it is part of the cache key and, on a miss, what the compile reads too.
|
|
123
129
|
const signals = importedSignals(withoutTwin(filename), source)
|
|
130
|
+
const components = componentsOf(source, filename, options)
|
|
124
131
|
const hydratable = options.hydratable ?? false
|
|
125
132
|
const root = options.root ?? process.cwd()
|
|
126
|
-
const entry = cacheEntry(options.cacheDir, filename, `${options.target}${hydratable ? '-hydratable' : ''}${options.inspect === true ? '-inspect' : ''}${options.variant === undefined ? '' : `-uses-${Bun.hash(options.variant).toString(36)}`}`, `${options.target}\0${hydratable}\0${options.pages?.join(',')}\0${options.clientOnly === true}\0${options.inspect === true}\0${tableFingerprint(options.classTable)}\0${classMerge === true}\0${root}\0${throughLinks(root, filename)}\0${uiKeyOf(root, withoutTwin(filename))}\0${JSON.stringify(awaitAlertOf(root))}\0${JSON.stringify(signals)}\0${options.target === 'ssr' && namedRefresh(withoutTwin(filename), root)}\0${source}`)
|
|
133
|
+
const entry = cacheEntry(options.cacheDir, filename, `${options.target}${hydratable ? '-hydratable' : ''}${options.inspect === true ? '-inspect' : ''}${options.variant === undefined ? '' : `-uses-${Bun.hash(options.variant).toString(36)}`}`, `${options.target}\0${hydratable}\0${options.pages?.join(',')}\0${options.clientOnly === true}\0${options.inspect === true}\0${tableFingerprint(options.classTable)}\0${classMerge === true}\0${root}\0${throughLinks(root, filename)}\0${uiKeyOf(root, withoutTwin(filename))}\0${JSON.stringify(awaitAlertOf(root))}\0${JSON.stringify(signals)}\0${JSON.stringify(components)}\0${options.target === 'ssr' && namedRefresh(withoutTwin(filename), root)}\0${source}`)
|
|
127
134
|
const cached = await readCacheEntry<string>(entry)
|
|
128
135
|
|
|
129
136
|
countCache('components', cached !== undefined)
|
|
@@ -132,7 +139,7 @@ export async function transformKayCached(original: string, filename: string, giv
|
|
|
132
139
|
if (cached !== undefined) {
|
|
133
140
|
if (!hasSourceMapOf(filename, source, cached, options.target === 'dom')) {
|
|
134
141
|
registerSourceMap(filename, () => {
|
|
135
|
-
const { code, map } = compile(source, filename, options, signals)
|
|
142
|
+
const { code, map } = compile(source, filename, options, signals, components)
|
|
136
143
|
|
|
137
144
|
return { source, tsx: code, map }
|
|
138
145
|
}, options.target === 'dom')
|
|
@@ -141,7 +148,7 @@ export async function transformKayCached(original: string, filename: string, giv
|
|
|
141
148
|
return cached
|
|
142
149
|
}
|
|
143
150
|
|
|
144
|
-
const code = transformKay(source, filename, options, signals)
|
|
151
|
+
const code = transformKay(source, filename, options, signals, components)
|
|
145
152
|
|
|
146
153
|
await writeCacheEntry(entry, code)
|
|
147
154
|
|
|
@@ -245,8 +252,13 @@ export function cacheEntry(cacheDir: string, filename: string, kind: string, inp
|
|
|
245
252
|
}
|
|
246
253
|
}
|
|
247
254
|
|
|
255
|
+
// The imported components a file may draw lazily: for the browser's build and the server's hydratable one, the only two that split them.
|
|
256
|
+
function componentsOf(source: string, filename: string, options: TransformOptions) {
|
|
257
|
+
return options.lazy !== false && (options.target === 'dom' || options.hydratable === true) ? importedComponents(withoutTwin(filename), source, options.root ?? process.cwd()) : undefined
|
|
258
|
+
}
|
|
259
|
+
|
|
248
260
|
// `filename` may name a static component's `?island` twin, the build of it that renders inside islands.
|
|
249
|
-
function compile(source: string, filename: string, options: TransformOptions, signals = importedSignals(withoutTwin(filename), source)): Compiled {
|
|
261
|
+
function compile(source: string, filename: string, options: TransformOptions, signals = importedSignals(withoutTwin(filename), source), components = componentsOf(source, filename, options)): Compiled {
|
|
250
262
|
const server = options.target === 'ssr'
|
|
251
263
|
const file = withoutTwin(filename)
|
|
252
264
|
const isTwin = file !== filename
|
|
@@ -254,7 +266,7 @@ function compile(source: string, filename: string, options: TransformOptions, si
|
|
|
254
266
|
const root = options.root ?? process.cwd()
|
|
255
267
|
// A page of the routes directory, whose root `@failed` fills a layout outlet rather than being a component's own block.
|
|
256
268
|
const page = isPageFile(file, options.pages ?? [projectPaths(root).routes]) ? true : undefined
|
|
257
|
-
const { tsx, map, diagnostics } = compileKay(source, throughLinks(root, file), { root: options.root, page, includeServer: server, output: server ? 'html' : 'dom', hydratable, twinBuild: isTwin, clientOnly: options.clientOnly, inspect: options.inspect, classTable: options.target === 'dom' ? options.classTable : undefined, classMerge: server ? options.classMerge : undefined, awaitAlert: awaitAlertOf(root, file), importedSignals: signals, namedRefresh: server && namedRefresh(file, root), ui: uiEntryOf(options.root ?? process.cwd(), file) })
|
|
269
|
+
const { tsx, map, diagnostics } = compileKay(source, throughLinks(root, file), { root: options.root, page, includeServer: server, output: server ? 'html' : 'dom', hydratable, twinBuild: isTwin, clientOnly: options.clientOnly, inspect: options.inspect, classTable: options.target === 'dom' ? options.classTable : undefined, classMerge: server ? options.classMerge : undefined, awaitAlert: awaitAlertOf(root, file), importedSignals: signals, components, namedRefresh: server && namedRefresh(file, root), ui: uiEntryOf(options.root ?? process.cwd(), file), writtenProps: options.writtenProps })
|
|
258
270
|
|
|
259
271
|
if (diagnostics.length > 0)
|
|
260
272
|
throw new KayCompileError(diagnostics.map(diagnostic => ({ ...diagnostic, file, source })))
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { realpathSync } from 'node:fs'
|
|
2
|
+
import { resolve } from 'node:path'
|
|
3
|
+
|
|
4
|
+
// The files extensions contribute `defineUi` entries from, by project root, in the order of the config; set as the config loads. Kept apart from `ui.ts`, which reads them with the compiler, so the config loader a compiled server runs stays free of it.
|
|
5
|
+
const layerFiles = new Map<string, string[]>()
|
|
6
|
+
|
|
7
|
+
// A project's root as the layers are filed under it: through a symlink or not, it is one project.
|
|
8
|
+
function rootKey(root: string): string {
|
|
9
|
+
try {
|
|
10
|
+
return realpathSync(root)
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return resolve(root)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// The files of the layers of a project, in config order.
|
|
18
|
+
export function layerFilesOf(root: string): string[] {
|
|
19
|
+
return layerFiles.get(rootKey(root)) ?? []
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Records the `ui` files of the extensions for a project: absolute, or relative to its root.
|
|
23
|
+
export function setUiLayers(root: string, extensions: readonly { ui?: string | undefined }[] | undefined): void {
|
|
24
|
+
const files = (extensions ?? []).flatMap(({ ui }) => ui === undefined ? [] : [resolve(root, ui)])
|
|
25
|
+
|
|
26
|
+
if (files.length === 0)
|
|
27
|
+
layerFiles.delete(rootKey(root))
|
|
28
|
+
else
|
|
29
|
+
layerFiles.set(rootKey(root), files)
|
|
30
|
+
}
|