@ecopages/core 0.6.0 → 0.7.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 +8 -143
- package/package.json +16 -3
- package/src/adapters/node/dev-session.js +2 -1
- package/src/adapters/node/node-client-bridge.d.ts +5 -7
- package/src/adapters/node/node-client-bridge.js +4 -14
- package/src/adapters/node/server-adapter.d.ts +4 -2
- package/src/adapters/node/server-adapter.js +13 -12
- package/src/adapters/shared/hmr/client-bridge.d.ts +25 -0
- package/src/adapters/shared/hmr/client-bridge.js +35 -0
- package/src/adapters/shared/hmr/dev-transform-entrypoint-registry.js +1 -1
- package/src/adapters/shared/hmr/hmr-manager.d.ts +9 -2
- package/src/adapters/shared/hmr/hmr-manager.js +36 -6
- package/src/adapters/shared/http/dist-file-handler.js +3 -7
- package/src/adapters/shared/http/response-headers.d.ts +29 -0
- package/src/adapters/shared/http/response-headers.js +89 -0
- package/src/adapters/shared/runtime/copy-runtime-public-dir.js +1 -1
- package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +3 -2
- package/src/adapters/shared/runtime/runtime-server-lifecycle.js +4 -3
- package/src/adapters/shared/runtime/server-request-pipeline.js +4 -4
- package/src/adapters/shared/runtime/server-static-builder.d.ts +19 -8
- package/src/adapters/shared/runtime/server-static-builder.js +23 -4
- package/src/adapters/shared/ws/node-http-websocket-upgrades.d.ts +1 -1
- package/src/adapters/shared/ws/node-http-websocket-upgrades.js +23 -16
- package/src/assets/app-browser-client-build.d.ts +5 -12
- package/src/assets/app-browser-client-build.js +121 -336
- package/src/assets/asset-processing-service/app-browser-client-bundle.d.ts +4 -0
- package/src/assets/asset-processing-service/app-browser-client-bundle.js +6 -0
- package/src/assets/asset-processing-service/asset-dependency-keys.d.ts +28 -8
- package/src/assets/asset-processing-service/asset-dependency-keys.js +104 -29
- package/src/assets/asset-processing-service/asset-processing.service.d.ts +60 -2
- package/src/assets/asset-processing-service/asset-processing.service.js +189 -58
- package/src/assets/asset-processing-service/bundleable-script.d.ts +3 -0
- package/src/assets/asset-processing-service/bundleable-script.js +4 -0
- package/src/assets/asset-processing-service/grouped-content-bundles.d.ts +2 -2
- package/src/assets/asset-processing-service/grouped-content-bundles.js +5 -10
- package/src/assets/asset-processing-service/index.d.ts +0 -3
- package/src/assets/asset-processing-service/index.js +0 -3
- package/src/assets/asset-processing-service/last-good-output.d.ts +21 -0
- package/src/assets/asset-processing-service/last-good-output.js +32 -0
- package/src/assets/asset-processing-service/page-package.js +1 -4
- package/src/assets/asset-processing-service/processed-asset-ledger.d.ts +63 -0
- package/src/assets/asset-processing-service/processed-asset-ledger.js +101 -0
- package/src/assets/asset-processing-service/processors/base/base-processor.js +1 -1
- package/src/assets/asset-processing-service/processors/base/base-script-processor.js +1 -1
- package/src/assets/asset-processing-service/processors/script/content-script.processor.d.ts +24 -0
- package/src/assets/asset-processing-service/processors/script/content-script.processor.js +59 -4
- package/src/assets/asset-processing-service/processors/script/file-script.processor.d.ts +8 -4
- package/src/assets/asset-processing-service/processors/script/file-script.processor.js +18 -6
- package/src/assets/asset-processing-service/processors/script/node-module-script.processor.js +2 -3
- package/src/assets/asset-processing-service/processors/stylesheet/app-stylesheet-imports.d.ts +34 -0
- package/src/assets/asset-processing-service/processors/stylesheet/app-stylesheet-imports.js +115 -0
- package/src/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +2 -2
- package/src/assets/asset-processing-service/processors/stylesheet/css-module-types.d.ts +39 -0
- package/src/assets/asset-processing-service/processors/stylesheet/css-module-types.js +150 -0
- package/src/assets/asset-processing-service/processors/stylesheet/css-scanner.d.ts +84 -0
- package/src/assets/asset-processing-service/processors/stylesheet/css-scanner.js +379 -0
- package/src/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +16 -0
- package/src/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +50 -24
- package/src/assets/asset-processing-service/processors/stylesheet/import-order.d.ts +33 -0
- package/src/assets/asset-processing-service/processors/stylesheet/import-order.js +67 -0
- package/src/assets/asset-processing-service/processors/stylesheet/package-stylesheet.d.ts +44 -0
- package/src/assets/asset-processing-service/processors/stylesheet/package-stylesheet.js +149 -0
- package/src/assets/asset-processing-service/processors/stylesheet/processed-stylesheet-cache.d.ts +31 -0
- package/src/assets/asset-processing-service/processors/stylesheet/processed-stylesheet-cache.js +59 -0
- package/src/assets/asset-processing-service/processors/stylesheet/source-relative-stylesheet.d.ts +20 -0
- package/src/assets/asset-processing-service/processors/stylesheet/source-relative-stylesheet.js +51 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-failure.d.ts +2 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-failure.js +5 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-module.d.ts +37 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-module.js +48 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.d.ts +25 -1
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.js +56 -15
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-warnings.d.ts +9 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-warnings.js +21 -0
- package/src/assets/browser-asset-output.js +1 -1
- package/src/assets/hashed-browser-asset.js +1 -1
- package/src/assets/{browser-runtime-asset-page-cache.d.ts → page-script-page-cache.d.ts} +3 -3
- package/src/assets/{browser-runtime-asset-page-cache.js → page-script-page-cache.js} +3 -3
- package/src/build/app-build-manifest-runtime.d.ts +23 -11
- package/src/build/app-build-manifest-runtime.js +52 -13
- package/src/build/browser/jsx-ownership-plugins.d.ts +4 -1
- package/src/build/browser/jsx-ownership-plugins.js +6 -0
- package/src/build/build-adapter.d.ts +1 -1
- package/src/build/build-adapter.js +1 -1
- package/src/build/build-graph.d.ts +4 -2
- package/src/build/build-graph.js +12 -46
- package/src/build/cache/build-input-dependency-index.d.ts +0 -19
- package/src/build/cache/build-input-dependency-index.js +1 -34
- package/src/build/cache/pages-unified-graph-build.js +7 -43
- package/src/build/cache/server-module-entries.d.ts +1 -1
- package/src/build/cache/server-module-entries.js +9 -9
- package/src/build/contracts/build-contracts.d.ts +59 -12
- package/src/build/contracts/build-manifest.d.ts +3 -6
- package/src/build/contracts/build-manifest.js +2 -12
- package/src/build/contracts/content-virtual-modules.js +1 -3
- package/src/build/copy-server-files.js +1 -1
- package/src/build/preserve-import-meta-transform.d.ts +3 -1
- package/src/build/preserve-import-meta-transform.js +7 -4
- package/src/build/production-asset-ledger.d.ts +36 -0
- package/src/build/production-asset-ledger.js +104 -0
- package/src/build/production-dist-complete.js +12 -13
- package/src/build/production-route-list.js +1 -1
- package/src/build/rolldown/app-package-declarations.js +1 -1
- package/src/build/rolldown/entry-module-closures.d.ts +5 -1
- package/src/build/rolldown/entry-module-closures.js +21 -8
- package/src/build/rolldown/rolldown-adapter-helpers.d.ts +19 -8
- package/src/build/rolldown/rolldown-adapter-helpers.js +82 -45
- package/src/build/rolldown/rolldown-build-adapter.js +10 -13
- package/src/build/rolldown/rolldown-module-id.d.ts +18 -0
- package/src/build/rolldown/rolldown-module-id.js +29 -0
- package/src/build/rolldown/rolldown-plugin-bridge.d.ts +24 -60
- package/src/build/rolldown/rolldown-plugin-bridge.js +201 -373
- package/src/build/rolldown/stylesheet-module-plugin.d.ts +34 -0
- package/src/build/rolldown/stylesheet-module-plugin.js +160 -0
- package/src/build/rolldown/worker-entries-plugin.d.ts +13 -0
- package/src/build/rolldown/worker-entries-plugin.js +57 -0
- package/src/build/runtime/build-environment-options.js +13 -3
- package/src/build/runtime/build-request-identity.js +1 -1
- package/src/build/runtime/build-request-policy.d.ts +7 -12
- package/src/build/runtime/build-request-policy.js +63 -17
- package/src/build/server/imported-view-plugin.d.ts +1 -0
- package/src/build/server/imported-view-plugin.js +6 -4
- package/src/build/server/page-module-import.service.d.ts +1 -2
- package/src/build/server/page-module-import.service.js +4 -6
- package/src/build/server/resolve-static-view.js +3 -2
- package/src/build/server/route-module-build-cache-registry.js +1 -1
- package/src/build/server/route-module-build-cache.store.js +1 -1
- package/src/build/server/route-module-build-manifest.js +1 -1
- package/src/build/server/route-module-dependency-hasher.d.ts +1 -1
- package/src/build/server/route-module-dependency-hasher.js +2 -2
- package/src/build/server/server-modules-manifest.d.ts +3 -5
- package/src/build/server/server-modules-manifest.js +6 -21
- package/src/build/server/view-module.d.ts +12 -0
- package/src/build/server/view-module.js +23 -0
- package/src/build/server/view-reference.d.ts +16 -5
- package/src/build/server/view-reference.js +25 -14
- package/src/build/server-bundle-deploy-manifest.d.ts +1 -1
- package/src/build/server-bundle-deploy-manifest.js +2 -2
- package/src/build/server-bundle-publication.d.ts +7 -1
- package/src/build/server-bundle-publication.js +11 -4
- package/src/build/server-module.js +1 -1
- package/src/build/worker-urls.d.ts +60 -0
- package/src/build/worker-urls.js +197 -0
- package/src/build.d.ts +7 -5
- package/src/build.js +7 -5
- package/src/cache/module-parse-cache.js +2 -2
- package/src/client/navigation-attributes.d.ts +8 -0
- package/src/client/navigation-attributes.js +8 -0
- package/src/client/navigation-scripts/global-scripts.d.ts +14 -0
- package/src/client/navigation-scripts/global-scripts.js +65 -0
- package/src/client/navigation-scripts/index.d.ts +1 -0
- package/src/client/navigation-scripts/index.js +1 -0
- package/src/client.d.ts +2 -2
- package/src/client.js +2 -2
- package/src/config/assembly/app-runtime.d.ts +45 -5
- package/src/config/assembly/app-runtime.js +11 -2
- package/src/config/assembly/finalize-config.js +13 -5
- package/src/config/config-module-files.js +10 -6
- package/src/config/index.d.ts +2 -1
- package/src/config/internal-types.d.ts +3 -0
- package/src/config/load-eco-config.js +8 -5
- package/src/config/resolve-eco-config-path.js +3 -3
- package/src/config/server-config-bundle.js +1 -1
- package/src/config/user-config-types.d.ts +54 -1
- package/src/config/write-types.js +4 -1
- package/src/css-imports.d.ts +12 -0
- package/src/declarations.d.ts +2 -0
- package/src/dev/development-restart-watch-paths.js +1 -1
- package/src/dev/development-restart.js +1 -1
- package/src/dev/invalidation/development-invalidation.service.d.ts +6 -1
- package/src/dev/invalidation/development-invalidation.service.js +18 -2
- package/src/dev/stylesheets/development-stylesheet.service.d.ts +149 -0
- package/src/dev/stylesheets/development-stylesheet.service.js +350 -0
- package/src/dev/transform-server/dev-transform-bundler.d.ts +12 -3
- package/src/dev/transform-server/dev-transform-bundler.js +32 -21
- package/src/dev/transform-server/dev-transform-externalize-plugin.d.ts +3 -5
- package/src/dev/transform-server/dev-transform-externalize-plugin.js +8 -9
- package/src/dev/transform-server/dev-transform-import-rewriter.d.ts +15 -2
- package/src/dev/transform-server/dev-transform-import-rewriter.js +204 -35
- package/src/dev/transform-server/dev-transform-install-stamp.d.ts +17 -0
- package/src/dev/transform-server/dev-transform-install-stamp.js +79 -0
- package/src/dev/transform-server/dev-transform-server.d.ts +38 -2
- package/src/dev/transform-server/dev-transform-server.js +96 -33
- package/src/dev/transform-server/dev-transform-url.d.ts +4 -2
- package/src/dev/transform-server/dev-transform-url.js +13 -12
- package/src/dev/transform-server/dev-transform-vendor-registry.d.ts +178 -21
- package/src/dev/transform-server/dev-transform-vendor-registry.js +675 -99
- package/src/dev/transform-server/index.d.ts +1 -1
- package/src/dev-toolbar/dev-toolbar-package.js +4 -4
- package/src/eco/component-render-output.d.ts +6 -1
- package/src/eco/component-render-output.js +32 -7
- package/src/eco/discovered-dependencies.d.ts +30 -11
- package/src/eco/discovered-dependencies.js +25 -13
- package/src/eco/discovered-dependency-paths.d.ts +36 -0
- package/src/eco/discovered-dependency-paths.js +58 -0
- package/src/eco/eco.browser.js +8 -12
- package/src/eco/eco.js +0 -30
- package/src/eco/mdx-page-metadata.d.ts +14 -0
- package/src/eco/mdx-page-metadata.js +15 -0
- package/src/eco/page-layout-normalization.d.ts +6 -2
- package/src/eco/page-layout-normalization.js +9 -6
- package/src/env.js +17 -0
- package/src/hmr/client/hmr-runtime.js +14 -13
- package/src/hmr/dev-client-runtime.d.ts +5 -2
- package/src/hmr/dev-client-runtime.js +14 -4
- package/src/hmr/hmr-entrypoint-output.js +1 -1
- package/src/hmr/hmr-strategy.d.ts +2 -2
- package/src/hmr/hmr-strategy.js +2 -2
- package/src/hmr/strategies/js-hmr-strategy.d.ts +4 -1
- package/src/hmr/strategies/js-hmr-strategy.js +7 -6
- package/src/hmr/strategies/template-source-hmr-strategy.d.ts +25 -0
- package/src/hmr/strategies/template-source-hmr-strategy.js +36 -0
- package/src/html-pages/html-page-module-scripts.d.ts +2 -1
- package/src/html-pages/html-page-module-scripts.js +37 -14
- package/src/html-pages/html-page-module.js +1 -1
- package/src/html-pages/html-page-renderer.js +7 -6
- package/src/html-pages/html-page-template.d.ts +0 -5
- package/src/html-pages/html-page-template.js +3 -15
- package/src/html-pages/html-pages.plugin.js +2 -2
- package/src/integration.d.ts +8 -6
- package/src/integration.js +5 -3
- package/src/page-cache/html-page-cache-dependency-index.js +1 -1
- package/src/page-cache/page-cache-service.js +1 -1
- package/src/plugins/alias-resolver-plugin.d.ts +7 -0
- package/src/plugins/alias-resolver-plugin.js +16 -6
- package/src/plugins/component-import-discovery.d.ts +178 -7
- package/src/plugins/component-import-discovery.js +696 -112
- package/src/plugins/eco-component-meta-plugin.d.ts +47 -6
- package/src/plugins/eco-component-meta-plugin.js +227 -59
- package/src/plugins/foreign-jsx-override-plugin.d.ts +14 -1
- package/src/plugins/foreign-jsx-override-plugin.js +18 -8
- package/src/plugins/integration-plugin.d.ts +47 -11
- package/src/plugins/integration-plugin.js +57 -8
- package/src/plugins/processor.d.ts +72 -7
- package/src/plugins/processor.js +44 -9
- package/src/plugins/stylesheet-kinds.d.ts +57 -0
- package/src/plugins/stylesheet-kinds.js +114 -0
- package/src/plugins/tsconfig-import-resolver.d.ts +49 -3
- package/src/plugins/tsconfig-import-resolver.js +120 -6
- package/src/processor-contract.d.ts +66 -0
- package/src/processor-contract.js +389 -0
- package/src/processor.d.ts +6 -1
- package/src/processor.js +6 -1
- package/src/route-renderer/error-pages/default-error-pages.d.ts +1 -0
- package/src/route-renderer/error-pages/default-error-pages.js +27 -7
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.d.ts +8 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.js +12 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts +77 -24
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js +97 -32
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js +1 -1
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +9 -0
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +16 -2
- package/src/route-renderer/orchestration/document-shell/layout-children-not-rendered-error.d.ts +35 -0
- package/src/route-renderer/orchestration/document-shell/layout-children-not-rendered-error.js +53 -0
- package/src/route-renderer/orchestration/foreign-child/render-session.d.ts +4 -8
- package/src/route-renderer/orchestration/foreign-child/render-session.js +2 -5
- package/src/route-renderer/orchestration/integration-renderer.d.ts +171 -64
- package/src/route-renderer/orchestration/integration-renderer.js +293 -332
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.d.ts +8 -5
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.js +27 -25
- package/src/route-renderer/orchestration/ownership-graph/component-graph.d.ts +0 -6
- package/src/route-renderer/orchestration/page-browser-graph/global-injector-assets.service.js +3 -3
- package/src/route-renderer/orchestration/page-browser-graph/grouped-graph-build-plan.d.ts +12 -25
- package/src/route-renderer/orchestration/page-browser-graph/grouped-graph-build-plan.js +1 -14
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +0 -16
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +1 -87
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.d.ts +8 -16
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +25 -271
- package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.d.ts +0 -24
- package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.js +0 -67
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.d.ts +28 -15
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +63 -41
- package/src/route-renderer/page-loading/component-dependency-collection.d.ts +4 -1
- package/src/route-renderer/page-loading/component-dependency-collection.js +51 -15
- package/src/route-renderer/page-loading/dependency-resolver.d.ts +10 -0
- package/src/route-renderer/page-loading/dependency-resolver.js +27 -6
- package/src/route-renderer/page-loading/file-scoped-dependency-components.d.ts +4 -2
- package/src/route-renderer/page-loading/file-scoped-dependency-components.js +22 -17
- package/src/route-renderer/page-loading/lazy-entry-collection.d.ts +5 -0
- package/src/route-renderer/page-loading/lazy-entry-collection.js +6 -4
- package/src/route-renderer/page-loading/page-dependency-bundling.d.ts +5 -2
- package/src/route-renderer/page-loading/page-dependency-bundling.js +15 -31
- package/src/route-renderer/page-loading/page-module-loader.d.ts +13 -2
- package/src/route-renderer/page-loading/page-module-loader.js +23 -5
- package/src/route-renderer/route-renderer.d.ts +1 -1
- package/src/router/client/navigation-commit.d.ts +2 -0
- package/src/router/client/navigation-commit.js +20 -3
- package/src/router/client/navigation-coordinator.d.ts +18 -0
- package/src/router/client/navigation-coordinator.js +14 -0
- package/src/router/client/navigation-head-order.fixture.css +3 -0
- package/src/router/client/navigation-head.d.ts +2 -1
- package/src/router/client/navigation-head.fixture.css +3 -0
- package/src/router/client/navigation-head.js +222 -39
- package/src/router/client/navigation-lifecycle.d.ts +8 -1
- package/src/router/client/navigation-lifecycle.js +6 -3
- package/src/router/client/navigation-pipeline.d.ts +1 -0
- package/src/router/client/navigation-pipeline.js +1 -0
- package/src/router/server/route-registry.d.ts +3 -2
- package/src/router/server/route-registry.js +6 -5
- package/src/static-site-generator/production-page-browser-graph-prebuild.d.ts +30 -18
- package/src/static-site-generator/production-page-browser-graph-prebuild.js +82 -143
- package/src/static-site-generator/static-site-generator.d.ts +37 -4
- package/src/static-site-generator/static-site-generator.js +99 -51
- package/src/types/asset-types.d.ts +19 -1
- package/src/types/build-types.d.ts +53 -35
- package/src/types/component-identity.d.ts +8 -0
- package/src/types/contracts.d.ts +69 -21
- package/src/types/dev-transform-types.d.ts +33 -6
- package/src/types/eco-api-types.d.ts +13 -18
- package/src/types/integration-types.d.ts +1 -1
- package/src/types/public-types.d.ts +1 -1
- package/src/utils/additional-watch-paths.js +3 -5
- package/src/utils/entry-command-flags.d.ts +23 -0
- package/src/utils/entry-command-flags.js +24 -0
- package/src/utils/package-path.d.ts +42 -0
- package/src/utils/package-path.js +114 -0
- package/src/utils/parse-cli-args.d.ts +18 -1
- package/src/utils/parse-cli-args.js +54 -37
- package/src/utils/path-containment.js +3 -10
- package/src/utils/resolve-work-dir.js +2 -2
- package/src/utils/root-relative-path.js +2 -2
- package/src/utils/server-bundle-context.d.ts +5 -0
- package/src/utils/server-bundle-context.js +7 -1
- package/src/utils/server-utils.module.js +1 -1
- package/src/watchers/project-watcher-ignore.js +3 -3
- package/src/watchers/project-watcher.d.ts +14 -2
- package/src/watchers/project-watcher.js +37 -6
- package/src/watchers/workspace-package-watch-roots.js +2 -2
- package/src/assets/app-browser-client-manifest.d.ts +0 -66
- package/src/assets/app-browser-client-manifest.js +0 -260
- package/src/assets/asset-processing-service/asset-package-role.d.ts +0 -2
- package/src/assets/asset-processing-service/asset-package-role.js +0 -3
- package/src/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +0 -58
- package/src/assets/asset-processing-service/browser-runtime-asset.factory.js +0 -61
- package/src/assets/asset-processing-service/browser-runtime-entry-resolution.d.ts +0 -79
- package/src/assets/asset-processing-service/browser-runtime-entry-resolution.js +0 -200
- package/src/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +0 -24
- package/src/assets/asset-processing-service/browser-runtime-entry.factory.js +0 -67
- package/src/build/browser/browser-runtime-manifest.d.ts +0 -35
- package/src/build/browser/browser-runtime-manifest.js +0 -65
- package/src/build/browser/browser-runtime-plugin-helpers.d.ts +0 -14
- package/src/build/browser/browser-runtime-plugin-helpers.js +0 -21
- package/src/build/browser/browser-runtime-plugin.d.ts +0 -54
- package/src/build/browser/browser-runtime-plugin.js +0 -76
- package/src/build/rolldown/server-side-css-shim-plugin.d.ts +0 -28
- package/src/build/rolldown/server-side-css-shim-plugin.js +0 -59
- package/src/dev/transform-server/dev-transform-module-kind.d.ts +0 -13
- package/src/dev/transform-server/dev-transform-module-kind.js +0 -17
- package/src/dev/transform-server/dev-transform-runtime-specifiers.d.ts +0 -5
- package/src/dev/transform-server/dev-transform-runtime-specifiers.js +0 -16
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts +0 -15
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js +0 -65
- package/src/route-renderer/orchestration/page-browser-graph/missing-production-browser-graph.d.ts +0 -21
- package/src/route-renderer/orchestration/page-browser-graph/missing-production-browser-graph.js +0 -31
package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts
CHANGED
|
@@ -12,21 +12,39 @@ export declare const CUSTOM_ELEMENT_SSR_PRELOAD_CACHE_SCOPES: {
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function isExpectedCustomElementSsrPreloadError(error: unknown): boolean;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Which `ssr: true` Component scripts an Integration's custom-element preloader evaluates.
|
|
16
|
+
*
|
|
17
|
+
* - `'own'`: the scripts of its own Components.
|
|
18
|
+
* - `'own-and-foreign'`: also the scripts of Components whose Integration does not preload, such as Kita, React or
|
|
19
|
+
* a plain module.
|
|
20
|
+
*/
|
|
21
|
+
export type SsrScriptPreload = 'own' | 'own-and-foreign';
|
|
22
|
+
/** An Integration as the ssr script assignment reads it. */
|
|
23
|
+
export type SsrScriptPreloadDeclaration = {
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly ssrScriptPreload?: SsrScriptPreload;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The `ssr: true` Component scripts of one render, by the Integration whose preloader evaluates each.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* An Integration with no entry evaluates none. A script appears under one Integration only.
|
|
16
32
|
*/
|
|
17
|
-
export
|
|
33
|
+
export type SsrScriptAssignment = ReadonlyMap<string, readonly string[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Assigns the `dependencies.scripts` paths marked `ssr: true` in a Component tree, each to one Integration's
|
|
36
|
+
* preloader.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* Every `ssr: true` script is evaluated by exactly one preloader, so a second copy of an element's module graph,
|
|
40
|
+
* such as Radiant's, never loads beside the owner's. The whole tree is walked, since an owned Component can sit under
|
|
41
|
+
* a foreign one, and the assignment is made once over all of it: a script declared by Components of two Integrations
|
|
42
|
+
* is not decided separately by each hook, which would see only part of the tree.
|
|
43
|
+
*/
|
|
44
|
+
export declare function assignSsrPreloadScripts(components: ReadonlyArray<CustomElementSsrPreloadComponent | undefined>, resolveDependencyPath: (componentDir: string, sourcePath: string) => string, integrations: readonly SsrScriptPreloadDeclaration[]): SsrScriptAssignment;
|
|
18
45
|
export interface CustomElementScriptPreloaderOptions {
|
|
19
46
|
cacheScope: string;
|
|
20
47
|
preloadScopes: Map<string, CustomElementScriptPreloadScopeState>;
|
|
21
|
-
enabled?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* When true, only lazy script entries with `ssr: true` are preloaded.
|
|
24
|
-
*
|
|
25
|
-
* @remarks
|
|
26
|
-
* Lit keeps this enabled so eager `ssr: true` scripts are not evaluated in an
|
|
27
|
-
* isolated module graph that would register incompatible custom elements.
|
|
28
|
-
*/
|
|
29
|
-
requireLazyScriptEntry?: boolean;
|
|
30
48
|
resolveDependencyPath: (componentDir: string, sourcePath: string) => string;
|
|
31
49
|
/**
|
|
32
50
|
* Evaluates one script for the custom-element registry named by `registryKey`.
|
|
@@ -36,43 +54,78 @@ export interface CustomElementScriptPreloaderOptions {
|
|
|
36
54
|
* asset imports are loaded by the same server loaders as page modules.
|
|
37
55
|
*/
|
|
38
56
|
importServerModule: (scriptPath: string, registryKey: string) => Promise<unknown>;
|
|
57
|
+
/** The Integration this preloader evaluates scripts for. */
|
|
58
|
+
integrationName: string;
|
|
39
59
|
/**
|
|
40
|
-
*
|
|
60
|
+
* The app's Integrations, in config order.
|
|
41
61
|
*
|
|
42
62
|
* @remarks
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* `
|
|
46
|
-
* Ecopages JSX still walks nested components so it can find owned Radiant
|
|
47
|
-
* hosts deeper in the graph.
|
|
63
|
+
* Each one's `ssrScriptPreload` decides which preloader a script is assigned to, so the preloader evaluates only
|
|
64
|
+
* the scripts assigned to `integrationName`. Core builds a preloader from its Integration's declaration, see
|
|
65
|
+
* `createSsrScriptPreloader` in the renderer hook options.
|
|
48
66
|
*/
|
|
49
|
-
|
|
67
|
+
integrations: readonly SsrScriptPreloadDeclaration[];
|
|
50
68
|
logLabel?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Called with the error of a script that failed to preload, except one that only needs the browser.
|
|
71
|
+
*
|
|
72
|
+
* @remarks
|
|
73
|
+
* The preloader itself only warns and leaves the element without server rendering. Core uses this to show the
|
|
74
|
+
* failure in the development overlay. A failed script is not evaluated again until it is invalidated or
|
|
75
|
+
* `clearFailedCustomElementScriptPreloads` runs.
|
|
76
|
+
*
|
|
77
|
+
* @throws Whatever the callback throws fails the render that reached the script; core throws in static generation.
|
|
78
|
+
*/
|
|
79
|
+
onPreloadFailure?: (scriptPath: string, error: unknown) => void;
|
|
51
80
|
}
|
|
81
|
+
/** What a renderer supplies to build its preloader; core adds the rest from the Integration's declaration. */
|
|
82
|
+
export type SsrScriptPreloaderInit = Pick<CustomElementScriptPreloaderOptions, 'cacheScope' | 'importServerModule' | 'integrationName' | 'logLabel'>;
|
|
52
83
|
/**
|
|
53
|
-
* Preloads `dependencies.scripts` entries marked `ssr: true` before SSR.
|
|
84
|
+
* Preloads the `dependencies.scripts` entries marked `ssr: true` that core assigns to one Integration, before SSR.
|
|
54
85
|
*
|
|
55
86
|
* @remarks
|
|
56
87
|
* `lazy` controls browser delivery only; `ssr: true` opts into server evaluation
|
|
57
88
|
* for both eager and lazy script entries. State is keyed by `cacheScope` so
|
|
58
89
|
* concurrent renders and dev invalidation share one deduplicated import cache.
|
|
90
|
+
*
|
|
91
|
+
* A Page render hands each preloader the scripts of one assignment over the whole Page tree
|
|
92
|
+
* ({@link CustomElementScriptPreloader.preloadScripts}). A render with no Page, such as a partial view, assigns over
|
|
93
|
+
* the Component it receives ({@link CustomElementScriptPreloader.preloadSsrScripts}). Both skip a script that another
|
|
94
|
+
* Integration's preloader already evaluated for the same registry, so the two paths never load a second copy.
|
|
59
95
|
*/
|
|
60
96
|
export declare class CustomElementScriptPreloader {
|
|
61
97
|
private readonly cacheScope;
|
|
62
98
|
private readonly preloadScopes;
|
|
63
|
-
private readonly enabled;
|
|
64
|
-
private readonly requireLazyScriptEntry;
|
|
65
99
|
private readonly resolveDependencyPath;
|
|
66
100
|
private readonly importServerModule;
|
|
67
|
-
private readonly
|
|
101
|
+
private readonly integrationName;
|
|
102
|
+
private readonly integrations;
|
|
68
103
|
private readonly logLabel;
|
|
69
|
-
|
|
104
|
+
private readonly onPreloadFailure?;
|
|
105
|
+
constructor({ cacheScope, preloadScopes, resolveDependencyPath, importServerModule, integrationName, integrations, logLabel, onPreloadFailure, }: CustomElementScriptPreloaderOptions);
|
|
70
106
|
invalidateScript(scriptPath: string): void;
|
|
71
107
|
isExpectedSsrPreloadError(error: unknown): boolean;
|
|
108
|
+
/** The scripts assigned to this preloader's Integration over the given Component trees. */
|
|
72
109
|
collectSsrPreloadScripts(components: Array<CustomElementSsrPreloadComponent | undefined>): string[];
|
|
73
110
|
/**
|
|
74
|
-
* Preloads
|
|
111
|
+
* Preloads the scripts a render-wide assignment gives this preloader's Integration.
|
|
112
|
+
*/
|
|
113
|
+
preloadAssigned(assignment: SsrScriptAssignment | undefined): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Assigns over the given Component trees and preloads this Integration's share, for a render with no Page.
|
|
75
116
|
*/
|
|
76
117
|
preloadSsrScripts(components: Array<CustomElementSsrPreloadComponent | undefined>): Promise<void>;
|
|
118
|
+
/**
|
|
119
|
+
* Preloads SSR-eligible scripts to register custom elements before render.
|
|
120
|
+
*/
|
|
121
|
+
preloadScripts(scripts: readonly string[]): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* Whether another preloader's scope has the script for this registry, loaded, failed or in flight.
|
|
124
|
+
*
|
|
125
|
+
* @remarks
|
|
126
|
+
* A second evaluation would define the same elements twice, so the first preloader to reach a script keeps it.
|
|
127
|
+
*/
|
|
128
|
+
private isClaimedByOtherScope;
|
|
129
|
+
private reportFailure;
|
|
77
130
|
private preloadOneScript;
|
|
78
131
|
}
|
package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getComponentIdentity, getComponentOwner } from '../../../eco/component-identity.js';
|
|
2
|
-
import path from '
|
|
2
|
+
import { path } from '@ecopages/file-system/path';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
4
|
import { isEcopagesEnvEnabled } from '../../../env.js';
|
|
5
5
|
import { getCustomElementScriptPreloadScopeState, invalidateCustomElementScriptPreload, } from './custom-element-script-preload-invalidation.js';
|
|
@@ -27,26 +27,45 @@ export function isExpectedCustomElementSsrPreloadError(error) {
|
|
|
27
27
|
errorMessage.includes('document is not defined') ||
|
|
28
28
|
errorMessage.includes('navigator is not defined'));
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Picks the one preloader that evaluates a script, from the Integrations of the Components that declare it.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* A preloading Integration that owns a declaring Component wins, the first in config order when several do. Otherwise
|
|
35
|
+
* the first `'own-and-foreign'` Integration claims it. With none, the script is not evaluated on the server.
|
|
36
|
+
*/
|
|
37
|
+
function assignSsrScript(declaringOwners, integrations) {
|
|
38
|
+
const owner = integrations.find((integration) => integration.ssrScriptPreload && declaringOwners.has(integration.name));
|
|
39
|
+
return (owner ?? integrations.find((integration) => integration.ssrScriptPreload === 'own-and-foreign'))?.name;
|
|
40
|
+
}
|
|
41
|
+
function recordSsrScriptOwner(config, ownersByScript, resolveDependencyPath) {
|
|
42
|
+
const componentFile = getComponentIdentity(config)?.file;
|
|
31
43
|
if (!componentFile) {
|
|
32
44
|
return;
|
|
33
45
|
}
|
|
34
|
-
const
|
|
46
|
+
const owner = getComponentOwner(config);
|
|
35
47
|
for (const script of config.dependencies?.scripts ?? []) {
|
|
36
48
|
if (typeof script === 'string' || script.ssr !== true || !script.src) {
|
|
37
49
|
continue;
|
|
38
50
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
51
|
+
const scriptPath = resolveDependencyPath(path.dirname(componentFile), script.src);
|
|
52
|
+
const owners = ownersByScript.get(scriptPath) ?? new Set();
|
|
53
|
+
owners.add(owner);
|
|
54
|
+
ownersByScript.set(scriptPath, owners);
|
|
43
55
|
}
|
|
44
56
|
}
|
|
45
57
|
/**
|
|
46
|
-
*
|
|
58
|
+
* Assigns the `dependencies.scripts` paths marked `ssr: true` in a Component tree, each to one Integration's
|
|
59
|
+
* preloader.
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* Every `ssr: true` script is evaluated by exactly one preloader, so a second copy of an element's module graph,
|
|
63
|
+
* such as Radiant's, never loads beside the owner's. The whole tree is walked, since an owned Component can sit under
|
|
64
|
+
* a foreign one, and the assignment is made once over all of it: a script declared by Components of two Integrations
|
|
65
|
+
* is not decided separately by each hook, which would see only part of the tree.
|
|
47
66
|
*/
|
|
48
|
-
export function
|
|
49
|
-
const
|
|
67
|
+
export function assignSsrPreloadScripts(components, resolveDependencyPath, integrations) {
|
|
68
|
+
const ownersByScript = new Map();
|
|
50
69
|
const visitedConfigs = new Set();
|
|
51
70
|
const collect = (component) => {
|
|
52
71
|
const config = component?.config;
|
|
@@ -54,13 +73,7 @@ export function collectCustomElementSsrPreloadScripts(components, resolveDepende
|
|
|
54
73
|
return;
|
|
55
74
|
}
|
|
56
75
|
visitedConfigs.add(config);
|
|
57
|
-
|
|
58
|
-
const integration = getComponentOwner(config);
|
|
59
|
-
const ownsScripts = !collectForIntegration || integration === collectForIntegration;
|
|
60
|
-
const componentFile = ownsScripts ? identity?.file : undefined;
|
|
61
|
-
if (ownsScripts) {
|
|
62
|
-
collectSsrScriptsFromConfig(config, scriptPaths, resolveDependencyPath, componentFile, requireLazyScriptEntry);
|
|
63
|
-
}
|
|
76
|
+
recordSsrScriptOwner(config, ownersByScript, resolveDependencyPath);
|
|
64
77
|
for (const layout of config.layouts ?? []) {
|
|
65
78
|
collect(layout);
|
|
66
79
|
}
|
|
@@ -71,34 +84,49 @@ export function collectCustomElementSsrPreloadScripts(components, resolveDepende
|
|
|
71
84
|
for (const component of components) {
|
|
72
85
|
collect(component);
|
|
73
86
|
}
|
|
74
|
-
|
|
87
|
+
const scriptsByIntegration = new Map();
|
|
88
|
+
for (const [scriptPath, owners] of ownersByScript) {
|
|
89
|
+
const integrationName = assignSsrScript(owners, integrations);
|
|
90
|
+
if (integrationName === undefined) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const scripts = scriptsByIntegration.get(integrationName) ?? [];
|
|
94
|
+
scripts.push(scriptPath);
|
|
95
|
+
scriptsByIntegration.set(integrationName, scripts);
|
|
96
|
+
}
|
|
97
|
+
return scriptsByIntegration;
|
|
75
98
|
}
|
|
76
99
|
/**
|
|
77
|
-
* Preloads `dependencies.scripts` entries marked `ssr: true` before SSR.
|
|
100
|
+
* Preloads the `dependencies.scripts` entries marked `ssr: true` that core assigns to one Integration, before SSR.
|
|
78
101
|
*
|
|
79
102
|
* @remarks
|
|
80
103
|
* `lazy` controls browser delivery only; `ssr: true` opts into server evaluation
|
|
81
104
|
* for both eager and lazy script entries. State is keyed by `cacheScope` so
|
|
82
105
|
* concurrent renders and dev invalidation share one deduplicated import cache.
|
|
106
|
+
*
|
|
107
|
+
* A Page render hands each preloader the scripts of one assignment over the whole Page tree
|
|
108
|
+
* ({@link CustomElementScriptPreloader.preloadScripts}). A render with no Page, such as a partial view, assigns over
|
|
109
|
+
* the Component it receives ({@link CustomElementScriptPreloader.preloadSsrScripts}). Both skip a script that another
|
|
110
|
+
* Integration's preloader already evaluated for the same registry, so the two paths never load a second copy.
|
|
83
111
|
*/
|
|
84
112
|
export class CustomElementScriptPreloader {
|
|
85
113
|
cacheScope;
|
|
86
114
|
preloadScopes;
|
|
87
|
-
enabled;
|
|
88
|
-
requireLazyScriptEntry;
|
|
89
115
|
resolveDependencyPath;
|
|
90
116
|
importServerModule;
|
|
91
|
-
|
|
117
|
+
integrationName;
|
|
118
|
+
integrations;
|
|
92
119
|
logLabel;
|
|
93
|
-
|
|
120
|
+
onPreloadFailure;
|
|
121
|
+
constructor({ cacheScope, preloadScopes, resolveDependencyPath, importServerModule, integrationName, integrations, logLabel = 'ecopages', onPreloadFailure, }) {
|
|
94
122
|
this.cacheScope = cacheScope;
|
|
95
123
|
this.preloadScopes = preloadScopes;
|
|
96
|
-
this.enabled = enabled;
|
|
97
|
-
this.requireLazyScriptEntry = requireLazyScriptEntry;
|
|
98
124
|
this.resolveDependencyPath = resolveDependencyPath;
|
|
99
125
|
this.importServerModule = importServerModule;
|
|
100
|
-
this.
|
|
126
|
+
this.integrationName = integrationName;
|
|
127
|
+
this.integrations = integrations;
|
|
101
128
|
this.logLabel = logLabel;
|
|
129
|
+
this.onPreloadFailure = onPreloadFailure;
|
|
102
130
|
}
|
|
103
131
|
invalidateScript(scriptPath) {
|
|
104
132
|
invalidateCustomElementScriptPreload(this.preloadScopes, scriptPath, this.cacheScope);
|
|
@@ -106,16 +134,28 @@ export class CustomElementScriptPreloader {
|
|
|
106
134
|
isExpectedSsrPreloadError(error) {
|
|
107
135
|
return isExpectedCustomElementSsrPreloadError(error);
|
|
108
136
|
}
|
|
137
|
+
/** The scripts assigned to this preloader's Integration over the given Component trees. */
|
|
109
138
|
collectSsrPreloadScripts(components) {
|
|
110
|
-
return
|
|
139
|
+
return [
|
|
140
|
+
...(assignSsrPreloadScripts(components, this.resolveDependencyPath, this.integrations).get(this.integrationName) ?? []),
|
|
141
|
+
];
|
|
111
142
|
}
|
|
112
143
|
/**
|
|
113
|
-
* Preloads
|
|
144
|
+
* Preloads the scripts a render-wide assignment gives this preloader's Integration.
|
|
145
|
+
*/
|
|
146
|
+
async preloadAssigned(assignment) {
|
|
147
|
+
await this.preloadScripts(assignment?.get(this.integrationName) ?? []);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Assigns over the given Component trees and preloads this Integration's share, for a render with no Page.
|
|
114
151
|
*/
|
|
115
152
|
async preloadSsrScripts(components) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
153
|
+
await this.preloadScripts(this.collectSsrPreloadScripts(components));
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Preloads SSR-eligible scripts to register custom elements before render.
|
|
157
|
+
*/
|
|
158
|
+
async preloadScripts(scripts) {
|
|
119
159
|
const scopeState = getCustomElementScriptPreloadScopeState(this.preloadScopes, this.cacheScope);
|
|
120
160
|
const registry = globalThis.customElements;
|
|
121
161
|
if (scopeState.activeRegistry !== registry) {
|
|
@@ -124,16 +164,40 @@ export class CustomElementScriptPreloader {
|
|
|
124
164
|
scopeState.inFlightImports.clear();
|
|
125
165
|
scopeState.activeRegistry = registry;
|
|
126
166
|
}
|
|
127
|
-
const scripts = this.collectSsrPreloadScripts(components);
|
|
128
167
|
if (scripts.length === 0) {
|
|
129
168
|
return;
|
|
130
169
|
}
|
|
131
170
|
await Promise.all(scripts.map((scriptPath) => this.preloadOneScript(scriptPath, scopeState, registry)));
|
|
132
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* Whether another preloader's scope has the script for this registry, loaded, failed or in flight.
|
|
174
|
+
*
|
|
175
|
+
* @remarks
|
|
176
|
+
* A second evaluation would define the same elements twice, so the first preloader to reach a script keeps it.
|
|
177
|
+
*/
|
|
178
|
+
isClaimedByOtherScope(scriptPath, registry) {
|
|
179
|
+
for (const [scope, state] of this.preloadScopes) {
|
|
180
|
+
if (scope !== this.cacheScope &&
|
|
181
|
+
state.activeRegistry === registry &&
|
|
182
|
+
(state.preloadedScripts.has(scriptPath) ||
|
|
183
|
+
state.preloadFailedScripts.has(scriptPath) ||
|
|
184
|
+
state.inFlightImports.has(scriptPath))) {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
reportFailure(scriptPath, error) {
|
|
191
|
+
if (!this.isExpectedSsrPreloadError(error))
|
|
192
|
+
this.onPreloadFailure?.(scriptPath, error);
|
|
193
|
+
}
|
|
133
194
|
async preloadOneScript(scriptPath, scopeState, registry) {
|
|
134
195
|
if (scopeState.preloadedScripts.has(scriptPath) || scopeState.preloadFailedScripts.has(scriptPath)) {
|
|
135
196
|
return;
|
|
136
197
|
}
|
|
198
|
+
if (!scopeState.inFlightImports.has(scriptPath) && this.isClaimedByOtherScope(scriptPath, registry)) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
137
201
|
let inFlight = scopeState.inFlightImports.get(scriptPath);
|
|
138
202
|
if (inFlight) {
|
|
139
203
|
await inFlight;
|
|
@@ -146,6 +210,7 @@ export class CustomElementScriptPreloader {
|
|
|
146
210
|
}
|
|
147
211
|
catch (error) {
|
|
148
212
|
scopeState.preloadFailedScripts.add(scriptPath);
|
|
213
|
+
this.reportFailure(scriptPath, error);
|
|
149
214
|
if (this.isExpectedSsrPreloadError(error)) {
|
|
150
215
|
if (isEcopagesEnvEnabled('ECOPAGES_DEBUG')) {
|
|
151
216
|
console.warn(`[ecopages][${this.logLabel}] Skipping SSR preload for browser-only script: ${scriptPath}`);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BaseIntegrationContext, ComponentRenderResult, EcoComponent, PageMetadataProps } from '../../../types/contracts.js';
|
|
2
2
|
import type { InternalComponentRenderInput } from '../../../config/internal-types.js';
|
|
3
|
+
import { type LayoutChildrenNotRenderedHandler } from './layout-children-not-rendered-error.js';
|
|
3
4
|
export type DocumentShellLayoutInput = {
|
|
4
5
|
component: EcoComponent;
|
|
5
6
|
props?: Record<string, unknown>;
|
|
@@ -10,6 +11,8 @@ export type DocumentShellComposeChildrenContext = {
|
|
|
10
11
|
layouts: DocumentShellLayoutInput[];
|
|
11
12
|
rendererCache: BaseIntegrationContext['rendererCache'];
|
|
12
13
|
renderComponentWithForeignChildren: DocumentShellRenderDependencies['renderComponentWithForeignChildren'];
|
|
14
|
+
/** Reports a layout that rendered without its children. Throws when omitted. */
|
|
15
|
+
onLayoutChildrenNotRendered?: LayoutChildrenNotRenderedHandler;
|
|
13
16
|
};
|
|
14
17
|
export type DocumentShellComposeChildrenResult = {
|
|
15
18
|
/** Serialized or element children passed to the HTML template shell. */
|
|
@@ -52,9 +55,15 @@ export type DocumentShellPageRenderInput = {
|
|
|
52
55
|
};
|
|
53
56
|
export type DocumentShellRenderDependencies = {
|
|
54
57
|
renderComponentWithForeignChildren(input: InternalComponentRenderInput): Promise<ComponentRenderResult>;
|
|
58
|
+
/** Reports a layout that rendered without its children. Throws when omitted. */
|
|
59
|
+
onLayoutChildrenNotRendered?: LayoutChildrenNotRenderedHandler;
|
|
55
60
|
};
|
|
56
61
|
/**
|
|
57
62
|
* Default sequential string-child composition for document shell layers.
|
|
63
|
+
*
|
|
64
|
+
* @remarks
|
|
65
|
+
* A layout whose output does not contain its children goes to `onLayoutChildrenNotRendered`, which throws by
|
|
66
|
+
* default; when the handler returns, the layout's output is kept as it is.
|
|
58
67
|
*/
|
|
59
68
|
export declare function composeSequentialLayoutChildren(context: DocumentShellComposeChildrenContext, primaryHtml: string): Promise<DocumentShellComposeChildrenResult>;
|
|
60
69
|
/**
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { getComponentRenderContext } from '../../../eco/component-render-context.js';
|
|
2
|
+
import { LayoutChildrenNotRenderedError, } from './layout-children-not-rendered-error.js';
|
|
2
3
|
function resolveDocumentShellLayouts(input) {
|
|
3
4
|
if (input.layouts && input.layouts.length > 0) {
|
|
4
5
|
return input.layouts;
|
|
5
6
|
}
|
|
6
7
|
return input.layout ? [input.layout] : [];
|
|
7
8
|
}
|
|
9
|
+
/** Marks where a layout's `children` start, so composition can tell whether the layout rendered them. */
|
|
10
|
+
const LAYOUT_CHILDREN_MARKER = '<!--eco-layout-children-->';
|
|
8
11
|
/**
|
|
9
12
|
* Default sequential string-child composition for document shell layers.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* A layout whose output does not contain its children goes to `onLayoutChildrenNotRendered`, which throws by
|
|
16
|
+
* default; when the handler returns, the layout's output is kept as it is.
|
|
10
17
|
*/
|
|
11
18
|
export async function composeSequentialLayoutChildren(context, primaryHtml) {
|
|
12
19
|
let children = primaryHtml;
|
|
@@ -14,10 +21,16 @@ export async function composeSequentialLayoutChildren(context, primaryHtml) {
|
|
|
14
21
|
const layoutRender = await context.renderComponentWithForeignChildren({
|
|
15
22
|
component: layout.component,
|
|
16
23
|
props: layout.props ?? {},
|
|
17
|
-
children
|
|
24
|
+
children: `${LAYOUT_CHILDREN_MARKER}${children}`,
|
|
18
25
|
integrationContext: { rendererCache: context.rendererCache },
|
|
19
26
|
});
|
|
20
|
-
|
|
27
|
+
if (!layoutRender.html.includes(LAYOUT_CHILDREN_MARKER)) {
|
|
28
|
+
const error = LayoutChildrenNotRenderedError.forLayout(layout.component, context.primaryComponent);
|
|
29
|
+
if (!context.onLayoutChildrenNotRendered)
|
|
30
|
+
throw error;
|
|
31
|
+
context.onLayoutChildrenNotRendered(error);
|
|
32
|
+
}
|
|
33
|
+
children = layoutRender.html.replaceAll(LAYOUT_CHILDREN_MARKER, '');
|
|
21
34
|
}
|
|
22
35
|
return { children };
|
|
23
36
|
}
|
|
@@ -37,6 +50,7 @@ export async function composeDocumentShell(dependencies, input) {
|
|
|
37
50
|
layouts,
|
|
38
51
|
rendererCache,
|
|
39
52
|
renderComponentWithForeignChildren: dependencies.renderComponentWithForeignChildren,
|
|
53
|
+
onLayoutChildrenNotRendered: dependencies.onLayoutChildrenNotRendered,
|
|
40
54
|
};
|
|
41
55
|
let children;
|
|
42
56
|
if (input.composeChildren) {
|
package/src/route-renderer/orchestration/document-shell/layout-children-not-rendered-error.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { EcoComponent } from '../../../types/contracts.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reports a Layout that rendered without rendering the page it wraps.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* `eco.page({ layout })` types a layout with `LayoutProps`, but a function with fewer parameters is still
|
|
7
|
+
* assignable, so layout composition checks that each tier rendered its `children`. A
|
|
8
|
+
* {@link LayoutChildrenNotRenderedHandler} decides whether the render throws it.
|
|
9
|
+
*/
|
|
10
|
+
export declare class LayoutChildrenNotRenderedError extends Error {
|
|
11
|
+
name: string;
|
|
12
|
+
constructor(layoutName: string, file: string);
|
|
13
|
+
/**
|
|
14
|
+
* Names a layout for the error.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* An `eco.layout()` result is named after its file, since the factory's wrapper has no binding name. A plain
|
|
18
|
+
* function carries no file, so it is named by its function name and located by the page that uses it.
|
|
19
|
+
*/
|
|
20
|
+
static forLayout(layout: EcoComponent, page: EcoComponent): LayoutChildrenNotRenderedError;
|
|
21
|
+
}
|
|
22
|
+
/** Receives a layout that rendered without its page; it throws, logs or ignores it by render mode. */
|
|
23
|
+
export type LayoutChildrenNotRenderedHandler = (error: LayoutChildrenNotRenderedError) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Chooses how a render reports a layout that dropped its children.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* Static build output fails, so `ecopages build` stops. A development request-time render logs a warning and
|
|
29
|
+
* returns the HTML, and a production request-time render returns it silently: a layout may render a sign-in
|
|
30
|
+
* gate instead of the page on purpose, which must not turn into a 500 or one log line per request.
|
|
31
|
+
*/
|
|
32
|
+
export declare function createLayoutChildrenNotRenderedHandler(mode: {
|
|
33
|
+
staticGeneration: boolean;
|
|
34
|
+
production: boolean;
|
|
35
|
+
}): LayoutChildrenNotRenderedHandler;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
|
+
import { getComponentIdentity } from '../../../eco/component-identity.js';
|
|
3
|
+
import { appLogger } from '../../../global/app-logger.js';
|
|
4
|
+
/**
|
|
5
|
+
* Reports a Layout that rendered without rendering the page it wraps.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* `eco.page({ layout })` types a layout with `LayoutProps`, but a function with fewer parameters is still
|
|
9
|
+
* assignable, so layout composition checks that each tier rendered its `children`. A
|
|
10
|
+
* {@link LayoutChildrenNotRenderedHandler} decides whether the render throws it.
|
|
11
|
+
*/
|
|
12
|
+
export class LayoutChildrenNotRenderedError extends Error {
|
|
13
|
+
name = 'LayoutChildrenNotRenderedError';
|
|
14
|
+
constructor(layoutName, file) {
|
|
15
|
+
super(`[ecopages] Layout ${layoutName} (${file}) did not render its children`);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Names a layout for the error.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* An `eco.layout()` result is named after its file, since the factory's wrapper has no binding name. A plain
|
|
22
|
+
* function carries no file, so it is named by its function name and located by the page that uses it.
|
|
23
|
+
*/
|
|
24
|
+
static forLayout(layout, page) {
|
|
25
|
+
const layoutFile = getComponentIdentity(layout)?.file;
|
|
26
|
+
if (layoutFile) {
|
|
27
|
+
const fileName = path.basename(layoutFile);
|
|
28
|
+
return new LayoutChildrenNotRenderedError(fileName.replace(/\..*$/, ''), layoutFile);
|
|
29
|
+
}
|
|
30
|
+
const functionName = typeof layout === 'function' ? layout.name : '';
|
|
31
|
+
const layoutName = layout.displayName || functionName || 'anonymous';
|
|
32
|
+
return new LayoutChildrenNotRenderedError(layoutName, getComponentIdentity(page)?.file ?? 'unknown page');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Chooses how a render reports a layout that dropped its children.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* Static build output fails, so `ecopages build` stops. A development request-time render logs a warning and
|
|
40
|
+
* returns the HTML, and a production request-time render returns it silently: a layout may render a sign-in
|
|
41
|
+
* gate instead of the page on purpose, which must not turn into a 500 or one log line per request.
|
|
42
|
+
*/
|
|
43
|
+
export function createLayoutChildrenNotRenderedHandler(mode) {
|
|
44
|
+
if (mode.staticGeneration) {
|
|
45
|
+
return (error) => {
|
|
46
|
+
throw error;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (mode.production) {
|
|
50
|
+
return () => { };
|
|
51
|
+
}
|
|
52
|
+
return (error) => appLogger.warn(error.message);
|
|
53
|
+
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import type { ProcessedAsset } from '../../../assets/asset-processing-service/assets.types.js';
|
|
2
1
|
import type { PageClientPlan } from '../ownership-graph/page-client-plan.js';
|
|
3
2
|
/**
|
|
4
3
|
* Mutable state for one route or view render.
|
|
5
4
|
*
|
|
6
5
|
* @remarks
|
|
7
6
|
* Integration renderers are cached per Integration. This session keeps one
|
|
8
|
-
* render's
|
|
9
|
-
*
|
|
7
|
+
* render's foreign-renderer cache from leaking into another render on the same
|
|
8
|
+
* instance.
|
|
10
9
|
*/
|
|
11
10
|
export type RenderSession = {
|
|
12
|
-
resolvedIntegrationDependencies: ProcessedAsset[];
|
|
13
11
|
rendererCache: Map<string, unknown>;
|
|
14
12
|
};
|
|
15
13
|
/** Renderer-owned state attached to an active Eco component render context. */
|
|
@@ -18,7 +16,5 @@ export type RouteRenderContextState = {
|
|
|
18
16
|
preparedGraphComponents?: ReadonlyMap<string, boolean>;
|
|
19
17
|
session?: RenderSession;
|
|
20
18
|
};
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
*/
|
|
24
|
-
export declare function createRenderSession(resolvedIntegrationDependencies?: ProcessedAsset[]): RenderSession;
|
|
19
|
+
/** Starts an empty render session. */
|
|
20
|
+
export declare function createRenderSession(): RenderSession;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
export function createRenderSession(resolvedIntegrationDependencies = []) {
|
|
1
|
+
/** Starts an empty render session. */
|
|
2
|
+
export function createRenderSession() {
|
|
5
3
|
return {
|
|
6
|
-
resolvedIntegrationDependencies: [...resolvedIntegrationDependencies],
|
|
7
4
|
rendererCache: new Map(),
|
|
8
5
|
};
|
|
9
6
|
}
|