@ecopages/core 0.6.1 → 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 +4 -1
- package/src/router/client/navigation-coordinator.d.ts +18 -0
- package/src/router/client/navigation-coordinator.js +14 -0
- 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
|
@@ -3,11 +3,15 @@
|
|
|
3
3
|
* Every integration renderer should extend this class
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
+
import { path } from '@ecopages/file-system/path';
|
|
6
7
|
import {} from '../../assets/asset-processing-service/index.js';
|
|
7
8
|
import { resolveAssetProcessingIntegration } from '../../assets/asset-processing-service/asset-processing-integration.js';
|
|
8
|
-
import {
|
|
9
|
+
import { getAssetDependencyKey } from '../../assets/asset-processing-service/asset-dependency-keys.js';
|
|
9
10
|
import { HtmlTransformerService } from '../../html/html-transformer.service.js';
|
|
11
|
+
import { fileSystem } from '@ecopages/file-system';
|
|
12
|
+
import { hasProductionServerModule } from '../../build/server/server-modules-manifest.js';
|
|
10
13
|
import { invariant } from '../../utils/invariant.js';
|
|
14
|
+
import { toRootRelativePath } from '../../utils/root-relative-path.js';
|
|
11
15
|
import { HttpError } from '../../errors/http-error.js';
|
|
12
16
|
import { DependencyResolverService } from '../page-loading/dependency-resolver.js';
|
|
13
17
|
import { PageModuleLoaderService } from '../page-loading/page-module-loader.js';
|
|
@@ -22,22 +26,22 @@ import { finalizeComponentRender, getComponentRenderContext, runWithComponentRen
|
|
|
22
26
|
import { createRenderSession } from './foreign-child/render-session.js';
|
|
23
27
|
import { RouteRenderOrchestrator, } from './route-pipeline/route-render-orchestrator.js';
|
|
24
28
|
import { buildRouteHtmlFinalization } from './route-pipeline/route-html-finalization.service.js';
|
|
25
|
-
import { createPageDependencyInstanceKey } from './page-browser-graph/route-instance-key.js';
|
|
26
|
-
import { mergePageBrowserGraphContributions } from './page-browser-graph/page-browser-graph-contribution.merge.js';
|
|
27
|
-
import { collectDependencyWatchPaths } from '../page-loading/file-scoped-dependency-components.js';
|
|
28
29
|
import { resolvePageDependenciesFromContext, } from '../page-loading/resolved-page-dependencies.js';
|
|
29
|
-
import { createGroupedGraphBuildPlanKey, } from './page-browser-graph/grouped-graph-build-plan.js';
|
|
30
|
-
import { createRouteGraphLookupKey } from './page-browser-graph/route-instance-key.js';
|
|
31
30
|
import { normalizeUnresolvedMarkerArtifactHtml } from './route-pipeline/marker-artifact.utils.js';
|
|
32
31
|
import { isMarkupNodeLike } from '../../eco/component-render-output.js';
|
|
33
32
|
import { getForeignSubtreeResolutionContextKey, getForeignSubtreeTokenPrefix, resolveOwningIntegrationRenderer, } from './foreign-child/owning-renderer-resolution.js';
|
|
33
|
+
import { keepsLastGoodOutput, showAssetFailure } from '../../assets/asset-processing-service/last-good-output.js';
|
|
34
34
|
import { ensureIntegrationRuntimeReady } from '../../build/app-build-manifest-runtime.js';
|
|
35
|
+
import { assignSsrPreloadScripts, CustomElementScriptPreloader, } from './custom-element-scripts/custom-element-script-preloader.js';
|
|
35
36
|
import { createQueuedRuntime, executeComponentRender, getQueuedRuntimeContext, resolveQueuedHtml, resolveStringQueuedHtml, } from './foreign-child/foreign-subtree-execution.service.js';
|
|
36
37
|
import { renderPageDocumentShell, } from './document-shell/document-shell-render.service.js';
|
|
37
38
|
import { resolveInnermostPageLayout, resolvePageLayoutComponents, resolveDocumentShellLayouts, } from './document-shell/layout-shell-props.service.js';
|
|
38
39
|
import { finalizeIslandComponentRender } from '../../islands/island-host.js';
|
|
40
|
+
import { requireAppRuntime } from '../../utils/app-runtime.js';
|
|
41
|
+
import { prepareAssetDependencies } from '../../assets/asset-processing-service/asset-processing.service.js';
|
|
42
|
+
import { isBundleableScript } from '../../assets/asset-processing-service/bundleable-script.js';
|
|
39
43
|
import { isProductionRuntime } from '../../utils/runtime.js';
|
|
40
|
-
import {
|
|
44
|
+
import { createLayoutChildrenNotRenderedHandler, } from './document-shell/layout-children-not-rendered-error.js';
|
|
41
45
|
const syntheticExplicitViewKeys = new WeakMap();
|
|
42
46
|
let nextSyntheticExplicitViewKey = 0;
|
|
43
47
|
/**
|
|
@@ -55,14 +59,6 @@ function getSyntheticExplicitViewKey(integrationName, view) {
|
|
|
55
59
|
}
|
|
56
60
|
return key;
|
|
57
61
|
}
|
|
58
|
-
function createPrebuiltRoutePreparationKey(input) {
|
|
59
|
-
return JSON.stringify([
|
|
60
|
-
input.file,
|
|
61
|
-
createPageDependencyInstanceKey({ params: input.params, query: input.query }),
|
|
62
|
-
input.skipStaticProps ?? false,
|
|
63
|
-
input.isRouteTemplate ?? false,
|
|
64
|
-
]);
|
|
65
|
-
}
|
|
66
62
|
export { selectHydrationIslandEntries, } from './ownership-graph/page-client-plan.js';
|
|
67
63
|
/**
|
|
68
64
|
* The IntegrationRenderer class is an abstract class that provides a base for rendering integration-specific components in the EcoPages framework.
|
|
@@ -74,15 +70,18 @@ export class IntegrationRenderer {
|
|
|
74
70
|
assetProcessingService;
|
|
75
71
|
assetProcessingIntegration;
|
|
76
72
|
htmlTransformer;
|
|
73
|
+
/** Reports a layout that rendered without its children by the current render mode. */
|
|
74
|
+
onLayoutChildrenNotRendered = (error) => createLayoutChildrenNotRenderedHandler({
|
|
75
|
+
staticGeneration: this.appConfig.appRuntime?.staticGenerationActive === true,
|
|
76
|
+
production: isProductionRuntime(),
|
|
77
|
+
})(error);
|
|
77
78
|
hmrManager;
|
|
78
79
|
resolvedIntegrationDependencies = [];
|
|
79
80
|
dependencyResolverService;
|
|
80
81
|
pageModuleLoaderService;
|
|
81
82
|
routeRenderOrchestrator;
|
|
82
83
|
integrationHooks;
|
|
83
|
-
|
|
84
|
-
prebuiltGroupedBuildPlans = new Map();
|
|
85
|
-
prebuiltPageClientBrowserAssets = new Map();
|
|
84
|
+
ssrScriptPreloader;
|
|
86
85
|
DOC_TYPE = '<!DOCTYPE html>';
|
|
87
86
|
getActiveHmrManager() {
|
|
88
87
|
return this.appConfig.appRuntime?.hmr ?? this.hmrManager;
|
|
@@ -104,109 +103,17 @@ export class IntegrationRenderer {
|
|
|
104
103
|
}
|
|
105
104
|
}
|
|
106
105
|
/**
|
|
107
|
-
*
|
|
108
|
-
*/
|
|
109
|
-
async prebuildProductionPageBrowserGraph(routeFile, options) {
|
|
110
|
-
await this.ensureIntegrationRuntimeActivated();
|
|
111
|
-
if (options?.groupedBuildPlan) {
|
|
112
|
-
const routeKey = createPrebuiltRoutePreparationKey({
|
|
113
|
-
file: routeFile,
|
|
114
|
-
params: options.params,
|
|
115
|
-
query: options.query,
|
|
116
|
-
skipStaticProps: options.skipStaticProps,
|
|
117
|
-
isRouteTemplate: options.isRouteTemplate,
|
|
118
|
-
});
|
|
119
|
-
this.prebuiltGroupedBuildPlans.set(routeKey, options.groupedBuildPlan);
|
|
120
|
-
const dependencyInstanceKey = createPageDependencyInstanceKey({
|
|
121
|
-
params: options.params,
|
|
122
|
-
query: options.query,
|
|
123
|
-
});
|
|
124
|
-
const routeLookupKey = createRouteGraphLookupKey(routeFile, dependencyInstanceKey);
|
|
125
|
-
const plannedInstance = options.groupedBuildPlan.instances.find((instance) => createRouteGraphLookupKey(instance.routeFile, instance.dependencyInstanceKey) === routeLookupKey &&
|
|
126
|
-
(instance.skipStaticProps ?? false) === (options.skipStaticProps ?? false) &&
|
|
127
|
-
(instance.isRouteTemplate ?? false) === (options.isRouteTemplate ?? false));
|
|
128
|
-
if (plannedInstance?.prebuiltPageClientBrowserAssets) {
|
|
129
|
-
this.prebuiltPageClientBrowserAssets.set(routeKey, plannedInstance);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (!options?.skipStaticProps) {
|
|
133
|
-
await this.resolvePageBrowserGraphForRoute(routeFile, options, options?.groupedBuildPlan);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
/** Returns the production app browser plan candidate for one route instance. */
|
|
137
|
-
getGroupedBuildPlanForRoute(routeOptions) {
|
|
138
|
-
const exactPlan = this.prebuiltGroupedBuildPlans.get(createPrebuiltRoutePreparationKey(routeOptions));
|
|
139
|
-
if (exactPlan)
|
|
140
|
-
return exactPlan;
|
|
141
|
-
const dependencyInstanceKey = createPageDependencyInstanceKey({ params: routeOptions.params });
|
|
142
|
-
for (const plan of this.prebuiltGroupedBuildPlans.values()) {
|
|
143
|
-
if (plan.instances.some((instance) => instance.routeFile === routeOptions.file &&
|
|
144
|
-
(instance.isRouteTemplate || instance.dependencyInstanceKey === dependencyInstanceKey))) {
|
|
145
|
-
return plan;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return undefined;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Builds one production grouped graph plan for the supplied static route instances.
|
|
106
|
+
* Plans the supplied production route instances without processing any of their assets.
|
|
152
107
|
*
|
|
153
108
|
* @remarks
|
|
154
|
-
* When `onRouteFailure` is provided, failed route instances are reported and
|
|
155
|
-
* route failure rejects the operation.
|
|
109
|
+
* When `onRouteFailure` is provided, failed route instances are reported and left out of the plan. Without it, a
|
|
110
|
+
* route failure rejects the operation. Returns nothing when no instance could be planned.
|
|
156
111
|
*/
|
|
157
|
-
async
|
|
112
|
+
async planProductionRoutes(instances, options) {
|
|
158
113
|
await this.ensureIntegrationRuntimeActivated();
|
|
159
|
-
|
|
160
|
-
this.prebuiltGroupedBuildPlans.clear();
|
|
161
|
-
this.prebuiltPageClientBrowserAssets.clear();
|
|
162
|
-
const builtInstances = (await Promise.all(instances.map(async (routeInstance) => {
|
|
114
|
+
const plannedRoutes = (await Promise.all(instances.map(async (routeInstance) => {
|
|
163
115
|
try {
|
|
164
|
-
|
|
165
|
-
file: routeInstance.routeFile,
|
|
166
|
-
params: routeInstance.params,
|
|
167
|
-
query: routeInstance.query,
|
|
168
|
-
skipStaticProps: routeInstance.skipStaticProps,
|
|
169
|
-
};
|
|
170
|
-
const resolvedInputs = await this.resolveRouteRenderInputs(routeOptions, {
|
|
171
|
-
skipMetadata: routeInstance.isRouteTemplate,
|
|
172
|
-
});
|
|
173
|
-
const graphPreparation = await this.routeRenderOrchestrator.prepareRouteGraphContext({
|
|
174
|
-
routeOptions,
|
|
175
|
-
resolvedInputs,
|
|
176
|
-
props: resolvedInputs.props,
|
|
177
|
-
renderer: this,
|
|
178
|
-
});
|
|
179
|
-
const { graphContext: context, resolvedPageDependencies, shellGraph, shellDependencyComponents, graph, } = graphPreparation;
|
|
180
|
-
const componentGraphs = {
|
|
181
|
-
shellGraph,
|
|
182
|
-
shellDependencyComponents,
|
|
183
|
-
graph,
|
|
184
|
-
ownershipValidated: true,
|
|
185
|
-
};
|
|
186
|
-
this.prepareGraphLazyClientDependencies(graph);
|
|
187
|
-
const pageClientPlan = collectPageClientPlanFromGraph(graph);
|
|
188
|
-
const pageClientBuildEntries = await this.collectAppBrowserClientBuildEntries(pageClientPlan);
|
|
189
|
-
const builtInstance = {
|
|
190
|
-
routeFile: routeInstance.routeFile,
|
|
191
|
-
dependencyInstanceKey: context.dependencyInstanceKey ?? '',
|
|
192
|
-
skipStaticProps: routeInstance.skipStaticProps,
|
|
193
|
-
isRouteTemplate: routeInstance.isRouteTemplate,
|
|
194
|
-
contribution: mergePageBrowserGraphContributions(await this.collectPageBrowserGraphContribution(context), resolvedPageDependencies?.contribution),
|
|
195
|
-
pageClientBuildEntries,
|
|
196
|
-
prebuiltPageClientBrowserAssets: {
|
|
197
|
-
processedAssets: [],
|
|
198
|
-
fallbackDependencies: [],
|
|
199
|
-
},
|
|
200
|
-
};
|
|
201
|
-
if (!routeInstance.skipStaticProps) {
|
|
202
|
-
this.prebuiltRoutePreparations.set(createPrebuiltRoutePreparationKey(routeOptions), {
|
|
203
|
-
resolvedInputs,
|
|
204
|
-
graphContext: context,
|
|
205
|
-
resolvedPageDependencies,
|
|
206
|
-
componentGraphs,
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
return builtInstance;
|
|
116
|
+
return await this.planRouteInstance(routeInstance);
|
|
210
117
|
}
|
|
211
118
|
catch (error) {
|
|
212
119
|
if (!options?.onRouteFailure)
|
|
@@ -214,34 +121,77 @@ export class IntegrationRenderer {
|
|
|
214
121
|
options.onRouteFailure(routeInstance, error);
|
|
215
122
|
return undefined;
|
|
216
123
|
}
|
|
217
|
-
}))).filter((
|
|
218
|
-
|
|
219
|
-
integrationName: this.name,
|
|
220
|
-
planKey: createGroupedGraphBuildPlanKey(this.name, builtInstances),
|
|
221
|
-
instances: builtInstances,
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
getPrebuiltRoutePreparation(routeOptions) {
|
|
225
|
-
if (routeOptions.pageModule || routeOptions.props || routeOptions.skipStaticProps) {
|
|
124
|
+
}))).filter((route) => route !== undefined);
|
|
125
|
+
if (plannedRoutes.length === 0)
|
|
226
126
|
return undefined;
|
|
127
|
+
const bundledScripts = new Map();
|
|
128
|
+
for (const script of plannedRoutes.flatMap((route) => route.bundledScripts)) {
|
|
129
|
+
bundledScripts.set(getAssetDependencyKey(script, this.appConfig.rootDir), script);
|
|
227
130
|
}
|
|
228
|
-
return
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
131
|
+
return {
|
|
132
|
+
plan: {
|
|
133
|
+
integrationName: this.name,
|
|
134
|
+
bundledScripts: [...bundledScripts.values()],
|
|
135
|
+
pageClientEntries: plannedRoutes.flatMap((route) => route.pageClientEntries),
|
|
136
|
+
},
|
|
137
|
+
prepare: async () => {
|
|
138
|
+
for (const { routeOptions, preparation } of plannedRoutes) {
|
|
139
|
+
await this.runInRenderSession(() => this.routeRenderOrchestrator.prepareRenderOptions(routeOptions, this, preparation));
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
preparations: plannedRoutes.map(({ instance, preparation }) => ({ instance, preparation })),
|
|
143
|
+
};
|
|
232
144
|
}
|
|
233
145
|
/**
|
|
234
|
-
*
|
|
146
|
+
* Plans one route instance without processing any of its assets.
|
|
235
147
|
*
|
|
236
148
|
* @remarks
|
|
237
|
-
*
|
|
238
|
-
*
|
|
149
|
+
* The scripts the route's render would bundle, from the shell, the page Dependencies, the Page Browser Graph
|
|
150
|
+
* dependencies and the components and scripts its contribution names, go to `bundledScripts`, prepared as asset
|
|
151
|
+
* processing prepares them.
|
|
239
152
|
*/
|
|
240
|
-
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
153
|
+
async planRouteInstance(routeInstance) {
|
|
154
|
+
const routeOptions = {
|
|
155
|
+
file: routeInstance.routeFile,
|
|
156
|
+
params: routeInstance.params,
|
|
157
|
+
query: routeInstance.query,
|
|
158
|
+
skipStaticProps: routeInstance.skipStaticProps,
|
|
159
|
+
};
|
|
160
|
+
const resolvedInputs = await this.resolveRouteRenderInputs(routeOptions, {
|
|
161
|
+
skipMetadata: routeInstance.isRouteTemplate,
|
|
162
|
+
});
|
|
163
|
+
const graphContext = await this.routeRenderOrchestrator.prepareRouteGraphContext({
|
|
164
|
+
routeOptions,
|
|
165
|
+
resolvedInputs,
|
|
166
|
+
props: resolvedInputs.props,
|
|
167
|
+
renderer: this,
|
|
168
|
+
planning: true,
|
|
169
|
+
});
|
|
170
|
+
this.prepareGraphLazyClientDependencies(graphContext.graph);
|
|
171
|
+
const pageClientEntries = await this.collectAppBrowserClientBuildEntries(collectPageClientPlanFromGraph(graphContext.graph));
|
|
172
|
+
const contribution = await this.integrationHooks.collectPageBrowserGraphContribution?.(graphContext.graphContext);
|
|
173
|
+
const integration = this.getAssetProcessingIntegration();
|
|
174
|
+
const bundledScripts = [
|
|
175
|
+
...this.dependencyResolverService.collectBundleableScripts(graphContext.shellDependencyComponents, this.name, true),
|
|
176
|
+
...this.dependencyResolverService.collectBundleableScripts(graphContext.pageDependencyNodes.map((node) => node.component), this.name, true),
|
|
177
|
+
...this.dependencyResolverService.collectBundleableScripts([...(contribution?.components ?? [])], this.name, false),
|
|
178
|
+
...prepareAssetDependencies([...(contribution?.dependencies ?? []), ...(contribution?.bundledScripts ?? [])], integration, this.appConfig.rootDir).filter(isBundleableScript),
|
|
179
|
+
];
|
|
180
|
+
return {
|
|
181
|
+
instance: routeInstance,
|
|
182
|
+
routeOptions,
|
|
183
|
+
preparation: { resolvedInputs, graphContext },
|
|
184
|
+
bundledScripts,
|
|
185
|
+
pageClientEntries,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
async runInRenderSession(run) {
|
|
189
|
+
const session = createRenderSession();
|
|
190
|
+
const { value } = await runWithComponentRenderContext({
|
|
191
|
+
currentIntegration: this.name,
|
|
192
|
+
renderState: { session },
|
|
193
|
+
}, run);
|
|
194
|
+
return value;
|
|
245
195
|
}
|
|
246
196
|
/**
|
|
247
197
|
* Loads one route module through the owning renderer's import path.
|
|
@@ -249,10 +199,13 @@ export class IntegrationRenderer {
|
|
|
249
199
|
* Request-time infrastructure may need page metadata such as cache strategy or
|
|
250
200
|
* middleware before full rendering starts. Exposing this narrow entrypoint lets
|
|
251
201
|
* those callers reuse integration-specific import setup instead of bypassing it
|
|
252
|
-
* with raw transpiler access.
|
|
202
|
+
* with raw transpiler access. A module that still exports `getStaticProps`,
|
|
203
|
+
* `getStaticPaths` or `getMetadata` fails here with an error that points to the codemod.
|
|
253
204
|
*/
|
|
254
205
|
async loadPageModule(file, options) {
|
|
255
|
-
|
|
206
|
+
const pageModule = await this.importPageFile(file, options);
|
|
207
|
+
this.pageModuleLoaderService.assertNoLegacyPageExports(file, pageModule);
|
|
208
|
+
return pageModule;
|
|
256
209
|
}
|
|
257
210
|
setHmrManager(hmrManager) {
|
|
258
211
|
this.hmrManager = hmrManager;
|
|
@@ -302,36 +255,6 @@ export class IntegrationRenderer {
|
|
|
302
255
|
const errorMessage = cause instanceof Error ? `${message}: ${cause.message}` : message;
|
|
303
256
|
return HttpError.InternalServerError(errorMessage, { cause });
|
|
304
257
|
}
|
|
305
|
-
async resolvePageBrowserGraphForFile(filePath) {
|
|
306
|
-
/**
|
|
307
|
-
* @remarks
|
|
308
|
-
* Integration renderers such as React still call this file-only entry point
|
|
309
|
-
* during explicit view rendering. Route-instance-aware callers should prefer
|
|
310
|
-
* `resolvePageBrowserGraphForRoute`.
|
|
311
|
-
*/
|
|
312
|
-
return this.resolvePageBrowserGraphForRoute(filePath);
|
|
313
|
-
}
|
|
314
|
-
async resolvePageBrowserGraphForRoute(filePath, routeOptions, groupedBuildPlan) {
|
|
315
|
-
const groupedPlan = groupedBuildPlan ??
|
|
316
|
-
this.getGroupedBuildPlanForRoute({
|
|
317
|
-
file: filePath,
|
|
318
|
-
params: routeOptions?.params,
|
|
319
|
-
query: routeOptions?.query,
|
|
320
|
-
});
|
|
321
|
-
const graphContext = await this.buildPageBrowserGraphContributionContext(filePath, routeOptions);
|
|
322
|
-
const resolvedPageDependencies = await this.resolvePageDependenciesForContext(graphContext, {
|
|
323
|
-
file: filePath,
|
|
324
|
-
params: routeOptions?.params,
|
|
325
|
-
query: routeOptions?.query,
|
|
326
|
-
});
|
|
327
|
-
return await this.routeRenderOrchestrator.resolveDeclaredPageBrowserGraph({
|
|
328
|
-
routeFile: filePath,
|
|
329
|
-
dependencyInstanceKey: graphContext.dependencyInstanceKey,
|
|
330
|
-
integrationName: this.name,
|
|
331
|
-
groupedBuildPlan: groupedPlan,
|
|
332
|
-
collectContribution: async () => mergePageBrowserGraphContributions(await this.collectPageBrowserGraphContribution(graphContext), resolvedPageDependencies?.contribution),
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
258
|
/**
|
|
336
259
|
* Renders a route page through optional layout and document shells.
|
|
337
260
|
*
|
|
@@ -353,6 +276,7 @@ export class IntegrationRenderer {
|
|
|
353
276
|
});
|
|
354
277
|
return renderPageDocumentShell({
|
|
355
278
|
renderComponentWithForeignChildren: (renderInput) => this.renderComponentWithForeignChildren(renderInput),
|
|
279
|
+
onLayoutChildrenNotRendered: this.onLayoutChildrenNotRendered,
|
|
356
280
|
}, { ...input, layouts, composeChildren }, this.DOC_TYPE);
|
|
357
281
|
}
|
|
358
282
|
serializeStringRenderChildren(children) {
|
|
@@ -442,9 +366,112 @@ export class IntegrationRenderer {
|
|
|
442
366
|
resolveDependencies: (components, options) => this.resolveDependencies(components, options),
|
|
443
367
|
resolveDependencyPath: (componentDir, pathUrl) => this.resolveDependencyPath(componentDir, pathUrl),
|
|
444
368
|
applyPendingLazyTriggers: (assets, configs) => this.dependencyResolverService.applyPendingLazyTriggers(assets, configs),
|
|
369
|
+
createSsrScriptPreloader: (init) => this.createSsrScriptPreloader(init),
|
|
445
370
|
})
|
|
446
371
|
: (hooks ?? {});
|
|
447
372
|
}
|
|
373
|
+
createSsrScriptPreloader(init) {
|
|
374
|
+
const declared = this.appConfig.integrations.find((integration) => integration.name === init.integrationName);
|
|
375
|
+
if (!declared?.ssrScriptPreload) {
|
|
376
|
+
throw new Error(`[ecopages] Integration "${init.integrationName}" builds a custom-element preloader but declares no ssrScriptPreload. Declare 'own' or 'own-and-foreign' on its plugin, or do not build the preloader.`);
|
|
377
|
+
}
|
|
378
|
+
this.ssrScriptPreloader = new CustomElementScriptPreloader({
|
|
379
|
+
...init,
|
|
380
|
+
integrations: this.appConfig.integrations,
|
|
381
|
+
preloadScopes: requireAppRuntime(this.appConfig).customElementSsrPreloadScopes,
|
|
382
|
+
resolveDependencyPath: (componentDir, pathUrl) => this.resolveDependencyPath(componentDir, pathUrl),
|
|
383
|
+
onPreloadFailure: (scriptPath, error) => this.handleSsrPreloadFailure(scriptPath, error),
|
|
384
|
+
});
|
|
385
|
+
return this.ssrScriptPreloader;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Decides what a script that fails to preload costs: the overlay in development, the build in static generation.
|
|
389
|
+
*
|
|
390
|
+
* @remarks
|
|
391
|
+
* Development keeps rendering the element without server rendering (see {@link keepsLastGoodOutput}). Static
|
|
392
|
+
* generation throws, so a build cannot exit 0 with elements that lack their server output. `ecopages start` only
|
|
393
|
+
* warns: it renders at request time, where throwing would turn one broken script into a failing page.
|
|
394
|
+
*
|
|
395
|
+
* @throws In static generation, naming the script and the cause.
|
|
396
|
+
*/
|
|
397
|
+
handleSsrPreloadFailure(scriptPath, error) {
|
|
398
|
+
if (keepsLastGoodOutput(this.appConfig)) {
|
|
399
|
+
showAssetFailure(this.appConfig, 'script', scriptPath, error);
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
if (requireAppRuntime(this.appConfig).staticGenerationActive) {
|
|
403
|
+
const cause = error instanceof Error ? error.message : String(error);
|
|
404
|
+
throw new Error(`Failed to preload the ssr script ${scriptPath}: ${cause}`, { cause: error });
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Evaluates the `ssr: true` scripts of the whole Page tree, each by the one preloader core assigns it to.
|
|
409
|
+
*
|
|
410
|
+
* @remarks
|
|
411
|
+
* The assignment is made once, over the Page, its Layouts, the Html template and the Page's dependency
|
|
412
|
+
* Components, so no Integration decides from the part of the tree its own hook sees. Every assigned Integration
|
|
413
|
+
* preloads its share, including one that owns no Component the Page renders itself: a Page another Integration
|
|
414
|
+
* owns can reach it through a Component whose Integration does not preload. An assigned Integration other than
|
|
415
|
+
* this one is activated first.
|
|
416
|
+
*/
|
|
417
|
+
assignPageSsrScripts(options) {
|
|
418
|
+
return assignSsrPreloadScripts([
|
|
419
|
+
options.Page,
|
|
420
|
+
options.Layout,
|
|
421
|
+
options.HtmlTemplate,
|
|
422
|
+
...(options.Layouts ?? []),
|
|
423
|
+
...(options.pageDependencyComponents ?? []),
|
|
424
|
+
], (componentDir, pathUrl) => this.resolveDependencyPath(componentDir, pathUrl), this.appConfig.integrations);
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Names the Integrations whose preloader evaluates an `ssr: true` script of this Page.
|
|
428
|
+
*
|
|
429
|
+
* @remarks
|
|
430
|
+
* Such an Integration takes part in the Page even when it owns none of its Components, as Lit does for an element
|
|
431
|
+
* declared on a Kita Component, so its global scripts, such as Lit's hydration support, reach the document.
|
|
432
|
+
*/
|
|
433
|
+
getPageSsrScriptIntegrationNames(options) {
|
|
434
|
+
return [...this.assignPageSsrScripts(options).keys()];
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Evaluates the `ssr: true` scripts of the whole Page tree, each by the one preloader core assigns it to.
|
|
438
|
+
*
|
|
439
|
+
* @remarks
|
|
440
|
+
* The assignment is made once, over the Page, its Layouts, the Html template and the Page's dependency
|
|
441
|
+
* Components, so no Integration decides from the part of the tree its own hook sees. Every assigned Integration
|
|
442
|
+
* preloads its share, including one that owns no Component the Page renders itself: a Page another Integration
|
|
443
|
+
* owns can reach it through a Component whose Integration does not preload. An assigned Integration other than
|
|
444
|
+
* this one is activated first.
|
|
445
|
+
*
|
|
446
|
+
* @returns The renderers of the assigned Integrations, which also render custom elements in the finished document.
|
|
447
|
+
*/
|
|
448
|
+
async preloadPageSsrScripts(options) {
|
|
449
|
+
const assignment = this.assignPageSsrScripts(options);
|
|
450
|
+
return await Promise.all(Array.from(assignment.keys(), async (integrationName) => {
|
|
451
|
+
if (integrationName === this.name) {
|
|
452
|
+
await this.preloadAssignedSsrScripts(assignment);
|
|
453
|
+
return this;
|
|
454
|
+
}
|
|
455
|
+
await ensureIntegrationRuntimeReady({ appConfig: this.appConfig, integrationName });
|
|
456
|
+
const renderer = this.appConfig.integrations
|
|
457
|
+
.find((entry) => entry.name === integrationName)
|
|
458
|
+
?.getRenderer();
|
|
459
|
+
await renderer?.preloadAssignedSsrScripts(assignment);
|
|
460
|
+
return renderer ?? this;
|
|
461
|
+
}));
|
|
462
|
+
}
|
|
463
|
+
/** Server-renders the custom elements this renderer's Integration registered in a finished document. */
|
|
464
|
+
async renderCustomElements(html) {
|
|
465
|
+
return (await this.integrationHooks.renderCustomElements?.(html)) ?? html;
|
|
466
|
+
}
|
|
467
|
+
/** Whether the hooks built a custom-element preloader for this renderer. */
|
|
468
|
+
get buildsSsrScriptPreloader() {
|
|
469
|
+
return this.ssrScriptPreloader !== undefined;
|
|
470
|
+
}
|
|
471
|
+
/** Evaluates the scripts of a render-wide assignment that belong to this renderer's preloader, if it has one. */
|
|
472
|
+
async preloadAssignedSsrScripts(assignment) {
|
|
473
|
+
await this.ssrScriptPreloader?.preloadAssigned(assignment);
|
|
474
|
+
}
|
|
448
475
|
/**
|
|
449
476
|
* Returns the HTML template component.
|
|
450
477
|
* It imports the HTML template from the specified path in the app configuration.
|
|
@@ -453,6 +480,8 @@ export class IntegrationRenderer {
|
|
|
453
480
|
*/
|
|
454
481
|
async getHtmlTemplate() {
|
|
455
482
|
const htmlTemplatePath = this.appConfig.absolutePaths.htmlTemplatePath;
|
|
483
|
+
const htmlTemplateKey = toRootRelativePath(this.appConfig.rootDir, htmlTemplatePath);
|
|
484
|
+
invariant(fileSystem.exists(htmlTemplatePath) || hasProductionServerModule(this.appConfig, htmlTemplatePath), `Missing Html template: expected ${htmlTemplateKey.replace(/\.[^./]+$/, '.<ext>')} but no such file exists. Add that file (for example ${htmlTemplateKey}) with the app's Html template as its default export.`);
|
|
456
485
|
try {
|
|
457
486
|
const { default: HtmlTemplate } = await this.importPageFile(htmlTemplatePath);
|
|
458
487
|
return HtmlTemplate;
|
|
@@ -489,23 +518,19 @@ export class IntegrationRenderer {
|
|
|
489
518
|
return this.dependencyResolverService.resolveDependencyPath(componentDir, pathUrl);
|
|
490
519
|
}
|
|
491
520
|
/**
|
|
492
|
-
* Collects the dependencies
|
|
493
|
-
*
|
|
521
|
+
* Collects the dependencies of the provided components.
|
|
522
|
+
*
|
|
523
|
+
* @remarks
|
|
524
|
+
* The result holds component assets only. Core places every Integration's global scripts on the Page, this
|
|
525
|
+
* Integration's included (see {@link resolveRouteDependencies}).
|
|
494
526
|
*
|
|
495
527
|
* @param components - The components to collect dependencies from.
|
|
496
528
|
*/
|
|
497
529
|
async resolveDependencies(components, options) {
|
|
498
|
-
|
|
499
|
-
return this.prependResolvedIntegrationDependencies(componentDeps);
|
|
500
|
-
}
|
|
501
|
-
prependResolvedIntegrationDependencies(componentDependencies) {
|
|
502
|
-
const integrationDependencies = getComponentRenderContext()?.renderState?.session
|
|
503
|
-
?.resolvedIntegrationDependencies ?? this.resolvedIntegrationDependencies;
|
|
504
|
-
return integrationDependencies.concat(componentDependencies);
|
|
530
|
+
return this.processComponentDependencies(components, options);
|
|
505
531
|
}
|
|
506
532
|
/**
|
|
507
|
-
* Processes component-specific dependencies
|
|
508
|
-
* Use this method when you need only the component's own assets.
|
|
533
|
+
* Processes component-specific dependencies.
|
|
509
534
|
*
|
|
510
535
|
* @param components - The components to collect dependencies from.
|
|
511
536
|
*/
|
|
@@ -538,10 +563,6 @@ export class IntegrationRenderer {
|
|
|
538
563
|
return this.integrationHooks.finalizeDocument?.(body, renderOptions) ?? body;
|
|
539
564
|
}
|
|
540
565
|
async resolveRouteRenderInputs(routeOptions, options) {
|
|
541
|
-
const prebuiltPreparation = this.getPrebuiltRoutePreparation(routeOptions);
|
|
542
|
-
if (prebuiltPreparation) {
|
|
543
|
-
return prebuiltPreparation.resolvedInputs;
|
|
544
|
-
}
|
|
545
566
|
const resolvedPageModule = await this.pageModuleLoaderService.resolvePageModule({
|
|
546
567
|
file: routeOptions.file,
|
|
547
568
|
pageModule: routeOptions.pageModule,
|
|
@@ -568,77 +589,19 @@ export class IntegrationRenderer {
|
|
|
568
589
|
integrationSpecificProps,
|
|
569
590
|
};
|
|
570
591
|
}
|
|
571
|
-
async buildPageBrowserGraphContributionContext(routeFile, routeOptions) {
|
|
572
|
-
if (!routeOptions?.pageModule) {
|
|
573
|
-
const prebuiltPreparation = this.prebuiltRoutePreparations.get(createPrebuiltRoutePreparationKey({
|
|
574
|
-
file: routeFile,
|
|
575
|
-
params: routeOptions?.params,
|
|
576
|
-
query: routeOptions?.query,
|
|
577
|
-
}));
|
|
578
|
-
if (prebuiltPreparation) {
|
|
579
|
-
return prebuiltPreparation.graphContext;
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
const { module: pageModule, ...resolvedPageModule } = await this.pageModuleLoaderService.resolvePageModule({
|
|
583
|
-
file: routeFile,
|
|
584
|
-
pageModule: routeOptions?.pageModule,
|
|
585
|
-
importPageFileFn: (targetFile) => this.importPageFile(targetFile),
|
|
586
|
-
});
|
|
587
|
-
const { props } = await this.pageModuleLoaderService.resolvePageData({
|
|
588
|
-
pageModule: resolvedPageModule,
|
|
589
|
-
routeOptions: {
|
|
590
|
-
file: routeFile,
|
|
591
|
-
params: routeOptions?.params,
|
|
592
|
-
query: routeOptions?.query,
|
|
593
|
-
},
|
|
594
|
-
});
|
|
595
|
-
return {
|
|
596
|
-
file: routeFile,
|
|
597
|
-
pageModule,
|
|
598
|
-
props,
|
|
599
|
-
params: routeOptions?.params,
|
|
600
|
-
query: routeOptions?.query,
|
|
601
|
-
dependencyInstanceKey: createPageDependencyInstanceKey({
|
|
602
|
-
params: routeOptions?.params,
|
|
603
|
-
query: routeOptions?.query,
|
|
604
|
-
}),
|
|
605
|
-
};
|
|
606
|
-
}
|
|
607
|
-
async resolvePageDependencies(context) {
|
|
608
|
-
return resolvePageDependenciesFromContext(context, this.name, (components, ownerFile) => this.resolvePageBrowserGraphContributionFromComponents(components, ownerFile));
|
|
609
|
-
}
|
|
610
592
|
async resolvePageDependencyContribution(input) {
|
|
611
|
-
|
|
612
|
-
}
|
|
613
|
-
async resolvePageDependenciesForRoute(context, routeOptions) {
|
|
614
|
-
const preparation = this.getPrebuiltRoutePreparation(routeOptions);
|
|
615
|
-
if (preparation) {
|
|
616
|
-
return preparation.resolvedPageDependencies;
|
|
617
|
-
}
|
|
618
|
-
return resolvePageDependenciesFromContext(context, this.name);
|
|
619
|
-
}
|
|
620
|
-
async resolvePageDependenciesForContext(context, routeOptions) {
|
|
621
|
-
const preparation = this.getPrebuiltRoutePreparation(routeOptions);
|
|
622
|
-
if (preparation) {
|
|
623
|
-
return preparation.resolvedPageDependencies;
|
|
624
|
-
}
|
|
625
|
-
return this.resolvePageDependencies(context);
|
|
626
|
-
}
|
|
627
|
-
async resolvePageBrowserGraphContributionFromComponents(components, ownerFile, preparedNodes) {
|
|
628
|
-
if (components.length === 0) {
|
|
593
|
+
if (input.nodes.length === 0) {
|
|
629
594
|
return undefined;
|
|
630
595
|
}
|
|
631
|
-
if (preparedNodes) {
|
|
632
|
-
return {
|
|
633
|
-
assets: await this.processComponentDependencies([...components], { preparedGraph: true }),
|
|
634
|
-
watchPaths: collectComponentGraphWatchPaths(preparedNodes, [ownerFile]),
|
|
635
|
-
};
|
|
636
|
-
}
|
|
637
596
|
return {
|
|
638
|
-
assets: await this.processComponentDependencies(
|
|
639
|
-
watchPaths:
|
|
597
|
+
assets: await this.processComponentDependencies(input.nodes.map((node) => node.component), { preparedGraph: true }),
|
|
598
|
+
watchPaths: collectComponentGraphWatchPaths(input.nodes, this.appConfig.rootDir, [input.ownerFile]),
|
|
640
599
|
};
|
|
641
600
|
}
|
|
601
|
+
async resolvePageDependenciesForRoute(context) {
|
|
602
|
+
return resolvePageDependenciesFromContext(context, this.name);
|
|
603
|
+
}
|
|
604
|
+
/** Resolves a route's component assets. */
|
|
642
605
|
async resolveRouteDependencies(input) {
|
|
643
606
|
return {
|
|
644
607
|
resolvedDependencies: await this.resolveDependencies(input.components, { preparedGraph: true }),
|
|
@@ -652,10 +615,11 @@ export class IntegrationRenderer {
|
|
|
652
615
|
* It imports the page file, collects dependencies, and prepares the render options.
|
|
653
616
|
*
|
|
654
617
|
* @param options - The route renderer options.
|
|
618
|
+
* @param planned - The preparation the production build planned for this route, which skips its data hooks.
|
|
655
619
|
* @returns The prepared render options.
|
|
656
620
|
*/
|
|
657
|
-
async prepareRenderOptions(options) {
|
|
658
|
-
const renderOptions = await this.routeRenderOrchestrator.prepareRenderOptions(options, this);
|
|
621
|
+
async prepareRenderOptions(options, planned) {
|
|
622
|
+
const renderOptions = await this.routeRenderOrchestrator.prepareRenderOptions(options, this, planned);
|
|
659
623
|
invariant(renderOptions.pagePackage !== undefined, 'Expected render preparation to produce a page package');
|
|
660
624
|
return renderOptions;
|
|
661
625
|
}
|
|
@@ -674,36 +638,25 @@ export class IntegrationRenderer {
|
|
|
674
638
|
* response-body errors.
|
|
675
639
|
*
|
|
676
640
|
* @param options Route renderer options.
|
|
641
|
+
* @param planned The preparation `planProductionRoutes` returned for this route, which static export passes so
|
|
642
|
+
* the route's data hooks run once per build. A remote render ignores it.
|
|
677
643
|
* @returns Rendered route body plus effective cache strategy.
|
|
678
644
|
*/
|
|
679
|
-
async execute(options) {
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
if (remoteResult) {
|
|
685
|
-
return remoteResult;
|
|
686
|
-
}
|
|
687
|
-
const session = createRenderSession(this.resolvedIntegrationDependencies);
|
|
688
|
-
const { value } = await runWithComponentRenderContext({
|
|
689
|
-
currentIntegration: this.name,
|
|
690
|
-
renderState: { session },
|
|
691
|
-
}, async () => {
|
|
692
|
-
const renderOptions = await this.prepareRenderOptions(options);
|
|
693
|
-
const renderState = getComponentRenderContext()?.renderState;
|
|
694
|
-
if (renderState) {
|
|
695
|
-
renderState.pageClientPlan = renderOptions.pageClientPlan;
|
|
696
|
-
renderState.preparedGraphComponents = renderOptions.preparedGraphComponents;
|
|
697
|
-
}
|
|
698
|
-
return this.routeRenderOrchestrator.executePrepared(renderOptions, this);
|
|
699
|
-
});
|
|
700
|
-
return value;
|
|
645
|
+
async execute(options, planned) {
|
|
646
|
+
await this.ensureIntegrationRuntimeActivated();
|
|
647
|
+
const remoteResult = await this.renderRemote(options);
|
|
648
|
+
if (remoteResult) {
|
|
649
|
+
return remoteResult;
|
|
701
650
|
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
651
|
+
return this.runInRenderSession(async () => {
|
|
652
|
+
const renderOptions = await this.prepareRenderOptions(options, planned);
|
|
653
|
+
const renderState = getComponentRenderContext()?.renderState;
|
|
654
|
+
if (renderState) {
|
|
655
|
+
renderState.pageClientPlan = renderOptions.pageClientPlan;
|
|
656
|
+
renderState.preparedGraphComponents = renderOptions.preparedGraphComponents;
|
|
705
657
|
}
|
|
706
|
-
|
|
658
|
+
return this.routeRenderOrchestrator.executePrepared(renderOptions, this);
|
|
659
|
+
});
|
|
707
660
|
}
|
|
708
661
|
async renderRemote(_options) {
|
|
709
662
|
return this.integrationHooks.renderRemote?.(_options);
|
|
@@ -720,7 +673,7 @@ export class IntegrationRenderer {
|
|
|
720
673
|
async renderExplicitView(view, props, ctx) {
|
|
721
674
|
if (ctx.partial) {
|
|
722
675
|
await this.ensureIntegrationRuntimeActivated();
|
|
723
|
-
const session = createRenderSession(
|
|
676
|
+
const session = createRenderSession();
|
|
724
677
|
const plan = collectPageClientPlan([{ component: view }], this.name);
|
|
725
678
|
const rendererCache = session.rendererCache;
|
|
726
679
|
const { value } = await runWithComponentRenderContext({
|
|
@@ -750,7 +703,9 @@ export class IntegrationRenderer {
|
|
|
750
703
|
async executeExplicitView(view, props, ctx = {}) {
|
|
751
704
|
const identity = getComponentIdentity(view);
|
|
752
705
|
return this.execute({
|
|
753
|
-
file: ctx.file ??
|
|
706
|
+
file: ctx.file ??
|
|
707
|
+
(identity?.file ? path.resolve(this.appConfig.rootDir, identity.file) : undefined) ??
|
|
708
|
+
getSyntheticExplicitViewKey(this.name, view),
|
|
754
709
|
pageModule: { default: view },
|
|
755
710
|
params: ctx.params,
|
|
756
711
|
query: ctx.query,
|
|
@@ -790,12 +745,31 @@ export class IntegrationRenderer {
|
|
|
790
745
|
async render(options) {
|
|
791
746
|
const renderRoute = () => this.renderRouteDocument(options);
|
|
792
747
|
try {
|
|
793
|
-
|
|
748
|
+
const assignedRenderers = await this.preloadPageSsrScripts(options);
|
|
749
|
+
const body = await (this.integrationHooks.renderRoute?.(options, renderRoute) ?? renderRoute());
|
|
750
|
+
return await this.renderAssignedCustomElements(body, assignedRenderers);
|
|
794
751
|
}
|
|
795
752
|
catch (error) {
|
|
796
753
|
throw this.createRenderError('Error rendering page', error);
|
|
797
754
|
}
|
|
798
755
|
}
|
|
756
|
+
/**
|
|
757
|
+
* Passes a finished string document through the renderers that were assigned `ssr: true` scripts, so the custom
|
|
758
|
+
* elements they registered are server-rendered in markup another Integration produced.
|
|
759
|
+
*
|
|
760
|
+
* @remarks
|
|
761
|
+
* A Page with no assigned script has no renderer here and pays nothing. Any other body is returned as it is.
|
|
762
|
+
*/
|
|
763
|
+
async renderAssignedCustomElements(body, renderers) {
|
|
764
|
+
if (typeof body !== 'string') {
|
|
765
|
+
return body;
|
|
766
|
+
}
|
|
767
|
+
let html = body;
|
|
768
|
+
for (const renderer of renderers) {
|
|
769
|
+
html = await renderer.renderCustomElements(html);
|
|
770
|
+
}
|
|
771
|
+
return html;
|
|
772
|
+
}
|
|
799
773
|
/**
|
|
800
774
|
* Renders the route document through the shared document shell.
|
|
801
775
|
*
|
|
@@ -952,9 +926,11 @@ export class IntegrationRenderer {
|
|
|
952
926
|
* @remarks
|
|
953
927
|
* The planning and merging live in `ownership-graph/page-client-browser-assets.ts`; this method
|
|
954
928
|
* supplies what only the renderer has: the owning renderers of other Integrations and its asset service.
|
|
929
|
+
* A route render passes `resolveFromAppBuild` to link the entries the app-wide browser build recorded; a plan
|
|
930
|
+
* contributed by another Integration's page does not.
|
|
955
931
|
*/
|
|
956
|
-
async buildPageClientBrowserAssets(plan,
|
|
957
|
-
const prebuilt =
|
|
932
|
+
async buildPageClientBrowserAssets(plan, resolveFromAppBuild = false) {
|
|
933
|
+
const prebuilt = resolveFromAppBuild ? await this.buildPrebuiltPageClientBrowserAssets(plan) : undefined;
|
|
958
934
|
if (prebuilt)
|
|
959
935
|
return prebuilt;
|
|
960
936
|
const buildAssetsHook = this.integrationHooks.buildIslandClientAssets;
|
|
@@ -979,62 +955,37 @@ export class IntegrationRenderer {
|
|
|
979
955
|
applyPendingLazyTriggers: (assets, configs) => this.dependencyResolverService.applyPendingLazyTriggers(assets, configs),
|
|
980
956
|
});
|
|
981
957
|
}
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
958
|
+
/**
|
|
959
|
+
* Resolves the page's island and lazy entries to the outputs the app-wide browser build recorded.
|
|
960
|
+
*
|
|
961
|
+
* @remarks
|
|
962
|
+
* Returns nothing outside a production build or start, or when a bundleable entry is not recorded, so the
|
|
963
|
+
* Integration builds the entries itself through asset processing, which fails once `ecopages start` sealed
|
|
964
|
+
* the ledger. Entries the app-wide build does not bundle are processed on their own.
|
|
965
|
+
*/
|
|
966
|
+
async buildPrebuiltPageClientBrowserAssets(plan) {
|
|
967
|
+
const ledger = requireAppRuntime(this.appConfig).processedAssets;
|
|
968
|
+
if (!ledger.hasBrowserBuild)
|
|
986
969
|
return undefined;
|
|
987
|
-
|
|
988
|
-
const
|
|
989
|
-
const
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
JSON.stringify(plannedEntries
|
|
994
|
-
.map((entry) => createAppBrowserClientEntryKey(entry.integrationName, entry.dependency))
|
|
995
|
-
.sort());
|
|
996
|
-
const prebuilt = hasMatchingEntries ? prebuiltInstance.prebuiltPageClientBrowserAssets : undefined;
|
|
997
|
-
if (!prebuilt) {
|
|
998
|
-
if (shouldRejectUnplannedProductionBrowserGraph(this.appConfig)) {
|
|
999
|
-
throw missingProductionBrowserGraphError(route.file, describeProductionBrowserGraphEntry(route.params));
|
|
970
|
+
const recordedAssets = [];
|
|
971
|
+
const unbundledGroups = new Map();
|
|
972
|
+
for (const { dependency, integrationName } of await this.collectAppBrowserClientBuildEntries(plan)) {
|
|
973
|
+
if (!isBundleableScript(dependency)) {
|
|
974
|
+
unbundledGroups.set(integrationName, [...(unbundledGroups.get(integrationName) ?? []), dependency]);
|
|
975
|
+
continue;
|
|
1000
976
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
const dependencies = fallbackGroups.get(integrationName) ?? [];
|
|
1006
|
-
dependencies.push(dependency);
|
|
1007
|
-
fallbackGroups.set(integrationName, dependencies);
|
|
977
|
+
const recorded = ledger.lookup(dependency);
|
|
978
|
+
if (!recorded)
|
|
979
|
+
return undefined;
|
|
980
|
+
recordedAssets.push(recorded);
|
|
1008
981
|
}
|
|
1009
|
-
const
|
|
1010
|
-
const processedAssets = [...
|
|
982
|
+
const unbundledAssets = (await Promise.all([...unbundledGroups].map(([integrationName, dependencies]) => this.assetProcessingService.processDependencies(dependencies, this.getAssetProcessingIntegration(integrationName))))).flat();
|
|
983
|
+
const processedAssets = [...recordedAssets, ...unbundledAssets];
|
|
1011
984
|
return {
|
|
1012
985
|
processedAssets,
|
|
1013
986
|
lazyTriggers: this.dependencyResolverService.applyPendingLazyTriggers(processedAssets, plan.lazyConfigs),
|
|
1014
987
|
};
|
|
1015
988
|
}
|
|
1016
|
-
async rejectUnplannedProductionPageClientGraph(plan, route) {
|
|
1017
|
-
if (!shouldRejectUnplannedProductionBrowserGraph(this.appConfig))
|
|
1018
|
-
return;
|
|
1019
|
-
const currentEntries = await this.collectAppBrowserClientBuildEntries(plan);
|
|
1020
|
-
if (currentEntries.length > 0 || this.integrationHooks.buildIslandClientAssets) {
|
|
1021
|
-
throw missingProductionBrowserGraphError(route.file, describeProductionBrowserGraphEntry(route.params));
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
resolvePrebuiltPageClientInstance(route) {
|
|
1025
|
-
const routeKey = createPrebuiltRoutePreparationKey(route);
|
|
1026
|
-
const exact = this.prebuiltPageClientBrowserAssets.get(routeKey);
|
|
1027
|
-
if (exact)
|
|
1028
|
-
return exact;
|
|
1029
|
-
const dependencyInstanceKey = createPageDependencyInstanceKey({ params: route.params });
|
|
1030
|
-
for (const instance of this.prebuiltPageClientBrowserAssets.values()) {
|
|
1031
|
-
if (instance.routeFile === route.file &&
|
|
1032
|
-
(instance.isRouteTemplate || instance.dependencyInstanceKey === dependencyInstanceKey)) {
|
|
1033
|
-
return instance;
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
return undefined;
|
|
1037
|
-
}
|
|
1038
989
|
async collectAppBrowserClientBuildEntries(plan) {
|
|
1039
990
|
const entries = [];
|
|
1040
991
|
const ownEntries = await this.integrationHooks.collectAppBrowserClientBuildEntries?.(plan);
|
|
@@ -1095,10 +1046,20 @@ export class IntegrationRenderer {
|
|
|
1095
1046
|
* the supported page-browser extension point for integrations.
|
|
1096
1047
|
*
|
|
1097
1048
|
* @param context - The route file path and already imported page module.
|
|
1098
|
-
* @returns
|
|
1049
|
+
* @returns The declared dependencies and watch paths, with the declaration's components and bundled scripts
|
|
1050
|
+
* processed into `assets`.
|
|
1099
1051
|
*/
|
|
1100
1052
|
async collectPageBrowserGraphContribution(context) {
|
|
1101
|
-
|
|
1053
|
+
const declaration = await this.integrationHooks.collectPageBrowserGraphContribution?.(context);
|
|
1054
|
+
if (!declaration)
|
|
1055
|
+
return undefined;
|
|
1056
|
+
const { components, bundledScripts, dependencies, watchPaths } = declaration;
|
|
1057
|
+
const componentAssets = components?.length ? await this.processComponentDependencies([...components]) : [];
|
|
1058
|
+
const scriptAssets = bundledScripts?.length
|
|
1059
|
+
? await this.assetProcessingService.processDependencies(bundledScripts, this.getAssetProcessingIntegration())
|
|
1060
|
+
: [];
|
|
1061
|
+
const assets = [...componentAssets, ...scriptAssets];
|
|
1062
|
+
return { dependencies, watchPaths, ...(assets.length > 0 ? { assets } : {}) };
|
|
1102
1063
|
}
|
|
1103
1064
|
/**
|
|
1104
1065
|
* Creates the per-render foreign-child runtime adopted by the shared component
|