@ecopages/core 0.6.1 → 0.7.1
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 +18 -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
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
/** Shared attribute used to keep DOM elements across page navigations. */
|
|
2
2
|
export const ECO_PERSIST_ATTRIBUTE = 'data-eco-persist';
|
|
3
|
+
/**
|
|
4
|
+
* Marks a head script as an Integration's global script, such as Lit's hydration support.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* A client navigation loads the marked scripts of the next document before it imports that Page's modules or swaps
|
|
8
|
+
* its markup, so a Component the Page imports finds the global hook it relies on already in place.
|
|
9
|
+
*/
|
|
10
|
+
export const ECO_GLOBAL_SCRIPT_ATTRIBUTE = 'data-eco-global-script';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inserts the incoming document's global scripts into the live head and waits until each has run.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* A router calls this before it imports the next Page's modules or swaps its markup. The shared head commit starts
|
|
6
|
+
* the other head scripts after the swap, which is too late for a script that installs a hook a Component module
|
|
7
|
+
* reads while it evaluates, such as Lit's hydration support. A script the live head already holds, by navigation
|
|
8
|
+
* script identity, is not inserted again, but a navigation waits for one this function inserted that is still
|
|
9
|
+
* loading, and a script that failed to load is removed so the next navigation tries it again. Scripts keep document order, and a module script's `load` event fires
|
|
10
|
+
* after the module and its imports have evaluated.
|
|
11
|
+
*
|
|
12
|
+
* @returns `false` when a script failed to load, so the caller can fall back to a document navigation.
|
|
13
|
+
*/
|
|
14
|
+
export declare function loadNavigationGlobalScripts(newDocument: Document): Promise<boolean>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ECO_GLOBAL_SCRIPT_ATTRIBUTE } from '../navigation-attributes.js';
|
|
2
|
+
import { isNonExecutableHeadScript } from './classification.js';
|
|
3
|
+
import { getNavigationScriptIdentity } from './identity.js';
|
|
4
|
+
/**
|
|
5
|
+
* Loads the global scripts of an incoming document that the live document lacks.
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
/** The load of each script this module inserted, so a later navigation waits on one still running. */
|
|
9
|
+
const pendingLoads = new WeakMap();
|
|
10
|
+
function whenSettled(script) {
|
|
11
|
+
const load = new Promise((resolve) => {
|
|
12
|
+
script.addEventListener('load', () => resolve(true), { once: true });
|
|
13
|
+
script.addEventListener('error', () => resolve(false), { once: true });
|
|
14
|
+
}).then((loaded) => {
|
|
15
|
+
if (!loaded)
|
|
16
|
+
script.remove();
|
|
17
|
+
return loaded;
|
|
18
|
+
});
|
|
19
|
+
pendingLoads.set(script, load);
|
|
20
|
+
return load;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Inserts the incoming document's global scripts into the live head and waits until each has run.
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* A router calls this before it imports the next Page's modules or swaps its markup. The shared head commit starts
|
|
27
|
+
* the other head scripts after the swap, which is too late for a script that installs a hook a Component module
|
|
28
|
+
* reads while it evaluates, such as Lit's hydration support. A script the live head already holds, by navigation
|
|
29
|
+
* script identity, is not inserted again, but a navigation waits for one this function inserted that is still
|
|
30
|
+
* loading, and a script that failed to load is removed so the next navigation tries it again. Scripts keep document order, and a module script's `load` event fires
|
|
31
|
+
* after the module and its imports have evaluated.
|
|
32
|
+
*
|
|
33
|
+
* @returns `false` when a script failed to load, so the caller can fall back to a document navigation.
|
|
34
|
+
*/
|
|
35
|
+
export async function loadNavigationGlobalScripts(newDocument) {
|
|
36
|
+
const live = new Map(Array.from(document.head.querySelectorAll('script'), (script) => [
|
|
37
|
+
getNavigationScriptIdentity(script).key,
|
|
38
|
+
script,
|
|
39
|
+
]));
|
|
40
|
+
const settled = [];
|
|
41
|
+
for (const incoming of newDocument.head.querySelectorAll(`script[${ECO_GLOBAL_SCRIPT_ATTRIBUTE}]`)) {
|
|
42
|
+
const identity = getNavigationScriptIdentity(incoming);
|
|
43
|
+
if (isNonExecutableHeadScript(incoming) || !identity.key)
|
|
44
|
+
continue;
|
|
45
|
+
const existing = live.get(identity.key);
|
|
46
|
+
if (existing) {
|
|
47
|
+
const loading = pendingLoads.get(existing);
|
|
48
|
+
if (loading)
|
|
49
|
+
settled.push(loading);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const script = document.createElement('script');
|
|
53
|
+
for (const attribute of incoming.attributes) {
|
|
54
|
+
script.setAttribute(attribute.name, attribute.name === 'src' && identity.src ? identity.src : attribute.value);
|
|
55
|
+
}
|
|
56
|
+
script.textContent = incoming.textContent;
|
|
57
|
+
if (script.hasAttribute('src')) {
|
|
58
|
+
script.async = false;
|
|
59
|
+
settled.push(whenSettled(script));
|
|
60
|
+
}
|
|
61
|
+
live.set(identity.key, script);
|
|
62
|
+
document.head.appendChild(script);
|
|
63
|
+
}
|
|
64
|
+
return (await Promise.all(settled)).every(Boolean);
|
|
65
|
+
}
|
|
@@ -2,3 +2,4 @@ export { isNonExecutableHeadScript, isRerunScript, shouldPersistExecutableInline
|
|
|
2
2
|
export { getNavigationScriptIdentity, type NavigationScriptIdentity } from './identity.js';
|
|
3
3
|
export { RERUN_SRC_ATTR, type RerunScriptCallback } from './registry.js';
|
|
4
4
|
export { collectRerunScripts, toRerunScriptActivation, type PendingRerunScript } from './rerun-queue.js';
|
|
5
|
+
export { loadNavigationGlobalScripts } from './global-scripts.js';
|
|
@@ -2,3 +2,4 @@ export { isNonExecutableHeadScript, isRerunScript, shouldPersistExecutableInline
|
|
|
2
2
|
export { getNavigationScriptIdentity } from './identity.js';
|
|
3
3
|
export { RERUN_SRC_ATTR } from './registry.js';
|
|
4
4
|
export { collectRerunScripts, toRerunScriptActivation } from './rerun-queue.js';
|
|
5
|
+
export { loadNavigationGlobalScripts } from './global-scripts.js';
|
package/src/client.d.ts
CHANGED
|
@@ -11,5 +11,5 @@ export { collectRerunScripts, type PendingRerunScript, toRerunScriptActivation,
|
|
|
11
11
|
export { type EcoPendingNavigationIntent, getAnchorFromNavigationEvent, isStaticAssetHref, recoverPendingNavigationHref, } from './router/client/link-intent.js';
|
|
12
12
|
export { getLinkNavigationDecision, getNavigableHrefFromClick, isSamePageHashNavigationHref, isSamePageHref, shouldPrefetchLink, } from './router/client/link-navigation-policy.js';
|
|
13
13
|
export { ECO_DOCUMENT_OWNER_ATTRIBUTE, type EcoNavigationDirection, type EcoNavigationOwner, type EcoNavigationRequest, type EcoNavigationRuntime, type EcoNavigationTransaction, type EcoReloadRequest, getEcoDocumentOwner, getEcoNavigationRuntime, } from './router/client/navigation-coordinator.js';
|
|
14
|
-
export { ECO_NAVIGATION_LIFECYCLE_EVENTS, type EcoNavigationEvent } from './router/client/navigation-lifecycle.js';
|
|
15
|
-
export { activatePreparedNavigationScripts, activateScriptsInOrder, cacheNavigationHtml, clearNavigationHtmlCache, commitNavigationPage, decideQueuedNavigationReplay, ECO_PERSIST_ATTRIBUTE, fetchNavigationPage, getCachedNavigationHtml, invalidateNavigationHtml, type NavigationHeadUpdate, parseNavigationDocument, prepareNavigationHead, type ScriptActivation, } from './router/client/navigation-pipeline.js';
|
|
14
|
+
export { ECO_NAVIGATION_LIFECYCLE_EVENTS, schedulePageLoad, type EcoNavigationEvent, } from './router/client/navigation-lifecycle.js';
|
|
15
|
+
export { activatePreparedNavigationScripts, activateScriptsInOrder, cacheNavigationHtml, clearNavigationHtmlCache, commitNavigationPage, decideQueuedNavigationReplay, ECO_PERSIST_ATTRIBUTE, fetchNavigationPage, getCachedNavigationHtml, invalidateNavigationHtml, loadNavigationGlobalScripts, type NavigationHeadUpdate, parseNavigationDocument, prepareNavigationHead, type ScriptActivation, } from './router/client/navigation-pipeline.js';
|
package/src/client.js
CHANGED
|
@@ -11,5 +11,5 @@ export { collectRerunScripts, toRerunScriptActivation, } from './client/navigati
|
|
|
11
11
|
export { getAnchorFromNavigationEvent, isStaticAssetHref, recoverPendingNavigationHref, } from './router/client/link-intent.js';
|
|
12
12
|
export { getLinkNavigationDecision, getNavigableHrefFromClick, isSamePageHashNavigationHref, isSamePageHref, shouldPrefetchLink, } from './router/client/link-navigation-policy.js';
|
|
13
13
|
export { ECO_DOCUMENT_OWNER_ATTRIBUTE, getEcoDocumentOwner, getEcoNavigationRuntime, } from './router/client/navigation-coordinator.js';
|
|
14
|
-
export { ECO_NAVIGATION_LIFECYCLE_EVENTS } from './router/client/navigation-lifecycle.js';
|
|
15
|
-
export { activatePreparedNavigationScripts, activateScriptsInOrder, cacheNavigationHtml, clearNavigationHtmlCache, commitNavigationPage, decideQueuedNavigationReplay, ECO_PERSIST_ATTRIBUTE, fetchNavigationPage, getCachedNavigationHtml, invalidateNavigationHtml, parseNavigationDocument, prepareNavigationHead, } from './router/client/navigation-pipeline.js';
|
|
14
|
+
export { ECO_NAVIGATION_LIFECYCLE_EVENTS, schedulePageLoad, } from './router/client/navigation-lifecycle.js';
|
|
15
|
+
export { activatePreparedNavigationScripts, activateScriptsInOrder, cacheNavigationHtml, clearNavigationHtmlCache, commitNavigationPage, decideQueuedNavigationReplay, ECO_PERSIST_ATTRIBUTE, fetchNavigationPage, getCachedNavigationHtml, invalidateNavigationHtml, loadNavigationGlobalScripts, parseNavigationDocument, prepareNavigationHead, } from './router/client/navigation-pipeline.js';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ProcessedAssetLedger } from '../../assets/asset-processing-service/processed-asset-ledger.js';
|
|
2
|
+
import { ProcessedStylesheetCache } from '../../assets/asset-processing-service/processors/stylesheet/processed-stylesheet-cache.js';
|
|
1
3
|
import { BuildInputDependencyIndex } from '../../build/cache/build-input-dependency-index.js';
|
|
2
4
|
import { BuildQueue } from '../../build/runtime/build-queue.js';
|
|
3
5
|
import { SessionPageBrowserGraphCache } from '../../route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js';
|
|
@@ -12,6 +14,7 @@ import type { HtmlPageWarningState } from '../../html-pages/html-page-warning-st
|
|
|
12
14
|
import type { HtmlPageModuleScriptState } from '../../html-pages/html-page-module-scripts.js';
|
|
13
15
|
import type { CustomElementScriptPreloadScopeState } from '../../route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.js';
|
|
14
16
|
import type { DevelopmentInvalidationService } from '../../dev/invalidation/development-invalidation.service.js';
|
|
17
|
+
import type { DevelopmentStylesheetService } from '../../dev/stylesheets/development-stylesheet.service.js';
|
|
15
18
|
import type { PageCacheService } from '../../page-cache/page-cache-service.js';
|
|
16
19
|
import type { IHmrManager } from '../../types/contracts.js';
|
|
17
20
|
export { requireAppRuntime } from '../../utils/app-runtime.js';
|
|
@@ -28,6 +31,24 @@ export declare class ServerInvalidationState {
|
|
|
28
31
|
currentGeneration(): number;
|
|
29
32
|
advance(): void;
|
|
30
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* When an activation resolves each Integration's global scripts (`integrationDependencies`).
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* - `activation`: right after a successful `setup()`, in dev, `ecopages start` and request-only `app.fetch()`.
|
|
39
|
+
* - `browser-build`: never at activation. A production export (`ecopages build`, `ecopages preview`) and the Lit
|
|
40
|
+
* static-render worker resolve them through `resolveIntegrationDependencies()` once their app-wide browser build is
|
|
41
|
+
* known, so no global script is bundled on its own into `dist/client`.
|
|
42
|
+
*/
|
|
43
|
+
export type GlobalScriptResolution = 'activation' | 'browser-build';
|
|
44
|
+
/** Options fixed when the {@link AppRuntime} is created. */
|
|
45
|
+
export interface AppRuntimeOptions {
|
|
46
|
+
/**
|
|
47
|
+
* @defaultValue `'browser-build'` when the process runs `ecopages build` or `ecopages preview` without
|
|
48
|
+
* `--serve-only`, otherwise `'activation'`.
|
|
49
|
+
*/
|
|
50
|
+
globalScriptResolution?: GlobalScriptResolution;
|
|
51
|
+
}
|
|
31
52
|
/**
|
|
32
53
|
* Per-app state assembled once for a finalized config.
|
|
33
54
|
*
|
|
@@ -35,7 +56,8 @@ export declare class ServerInvalidationState {
|
|
|
35
56
|
* `origin` starts as `baseUrl` and updates when the runtime binds its listening origin. `hmr` stays
|
|
36
57
|
* `null` until a watch-mode dev session creates an HMR manager, and resets to `null` when dev resources
|
|
37
58
|
* are disposed. `developmentInvalidation` stays `null` until development services need it, then the
|
|
38
|
-
* watcher and HMR manager share that instance. `
|
|
59
|
+
* watcher and HMR manager share that instance. `developmentStylesheets` stays `null` until the watcher or the dev
|
|
60
|
+
* transform server needs it. `pageCache` stays `null` until the server adapter stores one.
|
|
39
61
|
*/
|
|
40
62
|
export interface AppRuntime {
|
|
41
63
|
buildAdapter: BuildAdapter;
|
|
@@ -46,10 +68,16 @@ export interface AppRuntime {
|
|
|
46
68
|
pageBrowserGraphSession: SessionPageBrowserGraphCache;
|
|
47
69
|
serverInvalidation: ServerInvalidationState;
|
|
48
70
|
developmentInvalidation: DevelopmentInvalidationService | null;
|
|
71
|
+
developmentStylesheets: DevelopmentStylesheetService | null;
|
|
49
72
|
moduleLoader: AppModuleLoaderContract;
|
|
50
73
|
routeModuleBuildCaches: Map<string, RouteModuleBuildCache>;
|
|
51
74
|
pageCache: PageCacheService | null;
|
|
52
75
|
integrationActivations: Map<string, Promise<void>>;
|
|
76
|
+
/**
|
|
77
|
+
* Fixed for the runtime's lifetime, so the first activation, whichever caller starts it, follows the strategy of
|
|
78
|
+
* the whole run.
|
|
79
|
+
*/
|
|
80
|
+
readonly globalScriptResolution: GlobalScriptResolution;
|
|
53
81
|
runtimeAssetsPrepared: boolean;
|
|
54
82
|
hmrAttachedToIntegrations: boolean;
|
|
55
83
|
/**
|
|
@@ -67,10 +95,22 @@ export interface AppRuntime {
|
|
|
67
95
|
origin: string;
|
|
68
96
|
hmr: IHmrManager | null;
|
|
69
97
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
98
|
+
* Processed and bundled dependencies of the production build, by dependency key, shared by every
|
|
99
|
+
* asset-processing service.
|
|
100
|
+
*
|
|
101
|
+
* @remarks
|
|
102
|
+
* The app-wide browser build records each script it bundles here, and asset processing each dependency it
|
|
103
|
+
* processes. `ecopages build` writes it to `dist/server/processed-assets.json`; `ecopages start` restores and
|
|
104
|
+
* seals it, so rendering serves every dependency from `dist/` and never compiles or writes.
|
|
105
|
+
*/
|
|
106
|
+
processedAssets: ProcessedAssetLedger;
|
|
107
|
+
/** The stylesheets the app's Processor produced, shared by every path that processes one. */
|
|
108
|
+
processedStylesheets: ProcessedStylesheetCache;
|
|
109
|
+
/**
|
|
110
|
+
* True while static generation (`ecopages build`) runs. An asset that cannot be processed then
|
|
111
|
+
* fails the build.
|
|
72
112
|
*/
|
|
73
|
-
|
|
113
|
+
staticGenerationActive: boolean;
|
|
74
114
|
}
|
|
75
115
|
/**
|
|
76
116
|
* Builds the one {@link AppRuntime} for `appConfig` and stores it on the config.
|
|
@@ -83,4 +123,4 @@ export interface AppRuntime {
|
|
|
83
123
|
*
|
|
84
124
|
* @throws When the config was not assembled by finalization.
|
|
85
125
|
*/
|
|
86
|
-
export declare function createAppRuntime(appConfig: EcoPagesAppConfig): AppRuntime;
|
|
126
|
+
export declare function createAppRuntime(appConfig: EcoPagesAppConfig, options?: AppRuntimeOptions): AppRuntime;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ProcessedAssetLedger } from '../../assets/asset-processing-service/processed-asset-ledger.js';
|
|
2
|
+
import { ProcessedStylesheetCache } from '../../assets/asset-processing-service/processors/stylesheet/processed-stylesheet-cache.js';
|
|
1
3
|
import { createBuildAdapter } from '../../build/build-adapter.js';
|
|
2
4
|
import { sealAppBuildManifest } from '../../build/app-build-manifest-runtime.js';
|
|
3
5
|
import { BuildInputDependencyIndex, seedProcessorWatchPaths } from '../../build/cache/build-input-dependency-index.js';
|
|
@@ -8,7 +10,9 @@ import { createHtmlPageWarningState } from '../../html-pages/html-page-warning-s
|
|
|
8
10
|
import { createHtmlPageModuleScriptState } from '../../html-pages/html-page-module-scripts.js';
|
|
9
11
|
import { SessionPageBrowserGraphCache } from '../../route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js';
|
|
10
12
|
import { AppModuleLoader } from '../../build/server/app-module-loader.service.js';
|
|
13
|
+
import { getRuntimeArgv } from '../../utils/runtime.js';
|
|
11
14
|
import { MISSING_APP_RUNTIME } from '../../utils/app-runtime.js';
|
|
15
|
+
import { isProductionExport, resolveEntryCommand } from '../../utils/parse-cli-args.js';
|
|
12
16
|
export { requireAppRuntime } from '../../utils/app-runtime.js';
|
|
13
17
|
/**
|
|
14
18
|
* The counter bumped when server modules are marked stale.
|
|
@@ -37,7 +41,7 @@ export class ServerInvalidationState {
|
|
|
37
41
|
*
|
|
38
42
|
* @throws When the config was not assembled by finalization.
|
|
39
43
|
*/
|
|
40
|
-
export function createAppRuntime(appConfig) {
|
|
44
|
+
export function createAppRuntime(appConfig, options = {}) {
|
|
41
45
|
if (appConfig.appRuntime) {
|
|
42
46
|
return appConfig.appRuntime;
|
|
43
47
|
}
|
|
@@ -57,10 +61,13 @@ export function createAppRuntime(appConfig) {
|
|
|
57
61
|
pageBrowserGraphSession: new SessionPageBrowserGraphCache(buildInputIndex),
|
|
58
62
|
serverInvalidation: new ServerInvalidationState(),
|
|
59
63
|
developmentInvalidation: null,
|
|
64
|
+
developmentStylesheets: null,
|
|
60
65
|
moduleLoader: new AppModuleLoader(appConfig),
|
|
61
66
|
routeModuleBuildCaches: new Map(),
|
|
62
67
|
pageCache: null,
|
|
63
68
|
integrationActivations: new Map(),
|
|
69
|
+
globalScriptResolution: options.globalScriptResolution ??
|
|
70
|
+
(isProductionExport(resolveEntryCommand(getRuntimeArgv())) ? 'browser-build' : 'activation'),
|
|
64
71
|
runtimeAssetsPrepared: false,
|
|
65
72
|
hmrAttachedToIntegrations: false,
|
|
66
73
|
productionBuildId: null,
|
|
@@ -70,7 +77,9 @@ export function createAppRuntime(appConfig) {
|
|
|
70
77
|
requestPipelineMetrics: createRequestPipelineMetricsState(),
|
|
71
78
|
origin: appConfig.baseUrl,
|
|
72
79
|
hmr: null,
|
|
73
|
-
|
|
80
|
+
processedAssets: new ProcessedAssetLedger(appConfig.rootDir),
|
|
81
|
+
processedStylesheets: new ProcessedStylesheetCache(),
|
|
82
|
+
staticGenerationActive: false,
|
|
74
83
|
};
|
|
75
84
|
appConfig.appRuntime = runtime;
|
|
76
85
|
try {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import path from '
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
2
|
import { getEcopagesEnv } from '../../env.js';
|
|
3
3
|
import { isPathInside } from '../../utils/path-containment.js';
|
|
4
4
|
import { fileSystem } from '@ecopages/file-system';
|
|
@@ -9,9 +9,11 @@ import { HtmlPagesPlugin } from '../../html-pages/html-pages.plugin.js';
|
|
|
9
9
|
import { invariant } from '../../utils/invariant.js';
|
|
10
10
|
import { ENDPOINT_FILE_EXTENSIONS, findEndpointFileExtension } from '../../utils/endpoint-file-extensions.js';
|
|
11
11
|
import { DEFAULT_ECOPAGES_DIST_DIR, DEFAULT_ECOPAGES_HOSTNAME, DEFAULT_ECOPAGES_PORT, DEFAULT_ECOPAGES_WORK_DIR, } from '../../constants.js';
|
|
12
|
+
import { assertResponseHeaderRules } from '../../adapters/shared/http/response-headers.js';
|
|
12
13
|
import { collectConfigModuleFiles } from '../config-module-files.js';
|
|
13
14
|
import { DEFAULT_ECO_CONFIG_FILENAME, resolveUserConfigRootDir } from '../resolve-eco-config-path.js';
|
|
14
15
|
import { listProductionServerModuleKeysFromDist } from '../../build/server/server-modules-manifest.js';
|
|
16
|
+
import { findStylesheetProcessor } from '../../plugins/stylesheet-kinds.js';
|
|
15
17
|
import { toRootRelativePath } from '../../utils/root-relative-path.js';
|
|
16
18
|
import { CLIENT_OUTPUT_DIR, SERVER_BUNDLE_DIR } from '../../utils/resolve-entry-file.js';
|
|
17
19
|
const finalizedPluginInstances = new WeakSet();
|
|
@@ -47,7 +49,7 @@ function resolveEmittedConfigRootDir(rootDir, configFilePath, distDirName, cwd)
|
|
|
47
49
|
if (path.basename(serverDir) === SERVER_BUNDLE_DIR) {
|
|
48
50
|
const emittedDistDir = path.dirname(serverDir);
|
|
49
51
|
const normalizedDistDir = path.normalize(distDirName);
|
|
50
|
-
const distSegments = normalizedDistDir.split(/
|
|
52
|
+
const distSegments = normalizedDistDir.split('/').filter((segment) => segment !== '' && segment !== '.');
|
|
51
53
|
const deployRoot = path.resolve(emittedDistDir, ...distSegments.map(() => '..'));
|
|
52
54
|
if (path.resolve(deployRoot, distDirName) === emittedDistDir) {
|
|
53
55
|
return deployRoot;
|
|
@@ -256,11 +258,15 @@ export async function finalizeEcoPagesConfig(userConfig, options = {}) {
|
|
|
256
258
|
for (const plugin of pluginInstances)
|
|
257
259
|
finalizedPluginInstances.add(plugin);
|
|
258
260
|
try {
|
|
259
|
-
const cwd = options.cwd ??
|
|
261
|
+
const cwd = options.cwd ?? path.cwd();
|
|
260
262
|
const directories = resolveDirectories(userConfig);
|
|
261
263
|
let rootDir = resolveUserConfigRootDir(userConfig.rootDir, cwd);
|
|
262
|
-
const configFilePath = options.configFilePath
|
|
264
|
+
const configFilePath = options.configFilePath
|
|
265
|
+
? path.resolve(cwd, options.configFilePath)
|
|
266
|
+
: path.join(rootDir, DEFAULT_ECO_CONFIG_FILENAME);
|
|
263
267
|
rootDir = resolveEmittedConfigRootDir(rootDir, configFilePath, directories.distDir, cwd);
|
|
268
|
+
if (userConfig.headers !== undefined)
|
|
269
|
+
assertResponseHeaderRules(userConfig.headers);
|
|
264
270
|
const integrations = withHtmlPagesIntegration(userConfig.integrations ?? []);
|
|
265
271
|
const partialConfig = {
|
|
266
272
|
baseUrl: resolveBaseUrl(userConfig.baseUrl),
|
|
@@ -280,14 +286,16 @@ export async function finalizeEcoPagesConfig(userConfig, options = {}) {
|
|
|
280
286
|
additionalWatchPaths: userConfig.additionalWatchPaths ?? [],
|
|
281
287
|
devPrewarmPaths: userConfig.devPrewarmPaths ?? [],
|
|
282
288
|
serverFiles: userConfig.serverFiles,
|
|
289
|
+
headers: userConfig.headers,
|
|
283
290
|
cache: userConfig.cache,
|
|
284
291
|
devToolbar: userConfig.devToolbar,
|
|
285
292
|
};
|
|
293
|
+
findStylesheetProcessor(partialConfig.processors.values());
|
|
286
294
|
const config = {
|
|
287
295
|
...partialConfig,
|
|
288
296
|
absolutePaths: createAbsolutePaths(partialConfig, configFilePath, await resolveConfigModuleFiles(configFilePath, options.configFilePath !== undefined, rootDir, partialConfig.distDir)),
|
|
289
297
|
};
|
|
290
|
-
createAppRuntime(config);
|
|
298
|
+
createAppRuntime(config, { globalScriptResolution: options.globalScriptResolution });
|
|
291
299
|
return config;
|
|
292
300
|
}
|
|
293
301
|
catch (error) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import path from '
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
2
|
import { fileSystem } from '@ecopages/file-system';
|
|
3
3
|
import { rolldown } from 'rolldown';
|
|
4
4
|
import { appLogger } from '../global/app-logger.js';
|
|
5
|
+
import { fromRolldownModuleId } from '../build/rolldown/rolldown-module-id.js';
|
|
5
6
|
import { isPathStrictlyInside } from '../utils/path-containment.js';
|
|
6
7
|
const SCRIPT_MODULE_PATTERN = /\.(?:[cm]?[jt]sx?|json)$/;
|
|
7
8
|
function toProjectPath(id, realRoot, root) {
|
|
8
|
-
if (!path.isAbsolute(id) || id.split(
|
|
9
|
+
if (!path.isAbsolute(id) || id.split('/').includes('node_modules')) {
|
|
9
10
|
return undefined;
|
|
10
11
|
}
|
|
11
12
|
const relativePath = path.relative(realRoot, id);
|
|
@@ -36,9 +37,12 @@ export async function collectConfigModuleFiles(configFilePath, rootDir) {
|
|
|
36
37
|
cwd: root,
|
|
37
38
|
platform: 'node',
|
|
38
39
|
logLevel: 'silent',
|
|
39
|
-
external: (
|
|
40
|
-
id
|
|
41
|
-
|
|
40
|
+
external: (rolldownId, _importer, isResolved) => {
|
|
41
|
+
const id = fromRolldownModuleId(rolldownId);
|
|
42
|
+
return (isResolved &&
|
|
43
|
+
id !== realConfigFile &&
|
|
44
|
+
(!SCRIPT_MODULE_PATTERN.test(id) || !toProjectPath(id, realRoot, root)));
|
|
45
|
+
},
|
|
42
46
|
plugins: [
|
|
43
47
|
{
|
|
44
48
|
name: 'ecopages-config-module-files',
|
|
@@ -47,7 +51,7 @@ export async function collectConfigModuleFiles(configFilePath, rootDir) {
|
|
|
47
51
|
return resolved ?? { id: source, external: true };
|
|
48
52
|
},
|
|
49
53
|
moduleParsed(moduleInfo) {
|
|
50
|
-
const projectPath = toProjectPath(moduleInfo.id, realRoot, root);
|
|
54
|
+
const projectPath = toProjectPath(fromRolldownModuleId(moduleInfo.id), realRoot, root);
|
|
51
55
|
if (projectPath)
|
|
52
56
|
moduleFiles.add(projectPath);
|
|
53
57
|
},
|
package/src/config/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export { finalizeEcoPagesConfig } from './assembly/finalize-config.js';
|
|
|
4
4
|
export { resolveEcoConfigPath, resolveEmittedEcoConfigPath, resolveUserConfigRootDir, DEFAULT_ECO_CONFIG_FILENAME, ECOPAGES_CONFIG_FILE_ENV, } from './resolve-eco-config-path.js';
|
|
5
5
|
export { assertProductionConfigIdentity, resolveProductionServerEntry, resolveProductionDistDir, } from '../build/server-bundle-deploy-manifest.js';
|
|
6
6
|
export { assertProductionDistComplete } from '../build/production-dist-complete.js';
|
|
7
|
-
export type { EcoPagesUserConfig, EcoPagesUserConfigFactory, LoadedEcoPagesUserConfig, LoadEcoPagesConfigOptions, } from './user-config-types.js';
|
|
7
|
+
export type { EcoPagesUserConfig, EcoPagesUserConfigFactory, LoadedEcoPagesUserConfig, LoadEcoPagesConfigOptions, ResponseHeaderRule, } from './user-config-types.js';
|
|
8
|
+
export type { GlobalScriptResolution } from './assembly/app-runtime.js';
|
|
@@ -2,6 +2,7 @@ import type { EcoBuildPlugin } from '../build/contracts/build-types.js';
|
|
|
2
2
|
import type { AppRuntime } from './assembly/app-runtime.js';
|
|
3
3
|
import type { AnyIntegrationPlugin } from '../plugins/integration-plugin.js';
|
|
4
4
|
import type { Processor } from '../plugins/processor.js';
|
|
5
|
+
import type { ResponseHeaderRule } from './user-config-types.js';
|
|
5
6
|
import type { CacheConfig, ComponentRenderInput, EcoComponent, PageMetadataProps, SitemapConfig } from '../types/contracts.js';
|
|
6
7
|
/** Internal render input carrying route-resolved dependency roots. */
|
|
7
8
|
export type InternalComponentRenderInput = ComponentRenderInput & {
|
|
@@ -109,6 +110,8 @@ export type EcoPagesAppConfig = {
|
|
|
109
110
|
* before the server reports that it is listening; core reads the list once, after that.
|
|
110
111
|
*/
|
|
111
112
|
devPrewarmPaths?: string[];
|
|
113
|
+
/** Response headers from the user's `headers` option, validated at finalization. */
|
|
114
|
+
headers?: ResponseHeaderRule[];
|
|
112
115
|
/**
|
|
113
116
|
* @default { title: 'Ecopages', description: 'Ecopages' }
|
|
114
117
|
*/
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import path from '
|
|
2
|
-
import { pathToFileURL } from 'node:url';
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
3
2
|
import { finalizeEcoPagesConfig } from './assembly/finalize-config.js';
|
|
4
3
|
import { resolveEcoConfigPath, resolveEcoConfigPathFromServerBundle } from './resolve-eco-config-path.js';
|
|
5
4
|
import { getProductionServerBundleDir } from '../utils/server-bundle-context.js';
|
|
6
5
|
const moduleLoadCache = new Map();
|
|
7
6
|
function resolveLoaderCwd(cwd) {
|
|
8
|
-
return path.resolve(cwd ??
|
|
7
|
+
return path.resolve(cwd ?? path.cwd());
|
|
9
8
|
}
|
|
10
9
|
async function importEcoConfigModule(configFilePath) {
|
|
11
|
-
const moduleUrl =
|
|
10
|
+
const moduleUrl = path.toFileUrl(configFilePath).href;
|
|
12
11
|
const configModule = await import(/* @vite-ignore */ moduleUrl);
|
|
13
12
|
return configModule.default ?? configModule;
|
|
14
13
|
}
|
|
@@ -77,5 +76,9 @@ async function loadEcoPagesConfigWithBundleDir(options, serverBundleDir) {
|
|
|
77
76
|
: resolveEcoConfigPath({ ...options, cwd });
|
|
78
77
|
const exported = await loadConfigModule(configFilePath);
|
|
79
78
|
const userConfig = materializeUserConfig(exported, configFilePath);
|
|
80
|
-
return await finalizeEcoPagesConfig(
|
|
79
|
+
return await finalizeEcoPagesConfig(options.directories ? { ...userConfig, ...options.directories } : userConfig, {
|
|
80
|
+
configFilePath,
|
|
81
|
+
cwd,
|
|
82
|
+
globalScriptResolution: options.globalScriptResolution,
|
|
83
|
+
});
|
|
81
84
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import path from '
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
2
|
import { getEcopagesEnv } from '../env.js';
|
|
3
3
|
import { fileSystem } from '@ecopages/file-system';
|
|
4
4
|
import { SERVER_BUNDLE_DIR } from '../utils/resolve-entry-file.js';
|
|
@@ -14,7 +14,7 @@ export const ECOPAGES_CONFIG_FILE_ENV = 'ECOPAGES_CONFIG_FILE';
|
|
|
14
14
|
* and production loads of `dist/server/eco.config.mjs` share one rule.
|
|
15
15
|
* `path.resolve` keeps an explicit absolute `rootDir` unchanged.
|
|
16
16
|
*/
|
|
17
|
-
export function resolveUserConfigRootDir(rootDir, cwd =
|
|
17
|
+
export function resolveUserConfigRootDir(rootDir, cwd = path.cwd()) {
|
|
18
18
|
return path.resolve(cwd, rootDir ?? '.');
|
|
19
19
|
}
|
|
20
20
|
/** Resolves the emitted production config of one build output directory without consulting source overrides. */
|
|
@@ -48,7 +48,7 @@ export function resolveEcoConfigPathFromServerBundle(options, serverBundleDir) {
|
|
|
48
48
|
return resolvedPath;
|
|
49
49
|
}
|
|
50
50
|
function resolveEcoConfigPathWithServerBundleDir(options, serverBundleDir) {
|
|
51
|
-
const cwd = options.cwd ??
|
|
51
|
+
const cwd = options.cwd ?? path.cwd();
|
|
52
52
|
const required = options.required ?? true;
|
|
53
53
|
const explicitPath = options.configFile || getEcopagesEnv(ECOPAGES_CONFIG_FILE_ENV);
|
|
54
54
|
if (explicitPath) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import path from '
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
2
|
import { fileSystem } from '@ecopages/file-system';
|
|
3
3
|
import { createServerBuildRequest } from '../build/runtime/build-request-policy.js';
|
|
4
4
|
import { buildOrThrow } from '../build/runtime/build-queue.js';
|
|
@@ -4,6 +4,19 @@ import type { AnyProcessor } from '../plugins/processor.js';
|
|
|
4
4
|
import type { CacheConfig } from '../page-cache/cache.types.js';
|
|
5
5
|
import type { EcoPagesAppConfig, RobotsPreference } from '../config/internal-types.js';
|
|
6
6
|
import type { PageMetadataProps, SitemapConfig } from '../types/contracts.js';
|
|
7
|
+
import type { GlobalScriptResolution } from './assembly/app-runtime.js';
|
|
8
|
+
/**
|
|
9
|
+
* Extra response headers for the requests a `source` pattern matches.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* `source` is a URL pathname pattern that starts with `/`: `*` matches any characters except `/`, `**` matches
|
|
13
|
+
* any characters including `/`, and everything else is literal. `/**` matches every path, `/assets/*` the files
|
|
14
|
+
* directly in `/assets/`, and `/**\/*.wasm` every `.wasm` file.
|
|
15
|
+
*/
|
|
16
|
+
export type ResponseHeaderRule = {
|
|
17
|
+
source: string;
|
|
18
|
+
headers: Record<string, string>;
|
|
19
|
+
};
|
|
7
20
|
/**
|
|
8
21
|
* Author-owned Ecopages configuration declared in `eco.config.ts`.
|
|
9
22
|
*
|
|
@@ -108,6 +121,22 @@ export type EcoPagesUserConfig = {
|
|
|
108
121
|
* URL route paths to prewarm in the background when the development server starts.
|
|
109
122
|
*/
|
|
110
123
|
devPrewarmPaths?: string[];
|
|
124
|
+
/**
|
|
125
|
+
* Headers added to every response the server sends: rendered pages, explicit routes and endpoints, and files
|
|
126
|
+
* from `public/` and `dist/client`, under `ecopages dev`, `start` and `preview`.
|
|
127
|
+
*
|
|
128
|
+
* @remarks
|
|
129
|
+
* Rules apply in order. A header here replaces one of the same name set by the framework or a handler.
|
|
130
|
+
* A static export carries no headers; configure them on the host.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* headers: [
|
|
135
|
+
* { source: '/**', headers: { 'Cross-Origin-Opener-Policy': 'same-origin', 'Cross-Origin-Embedder-Policy': 'require-corp' } },
|
|
136
|
+
* ]
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
headers?: ResponseHeaderRule[];
|
|
111
140
|
/**
|
|
112
141
|
* Default fallback HTML `<head>` metadata (title, description, OpenGraph tags) applied across all pages.
|
|
113
142
|
*/
|
|
@@ -121,7 +150,7 @@ export type EcoPagesUserConfig = {
|
|
|
121
150
|
*/
|
|
122
151
|
processors?: AnyProcessor[];
|
|
123
152
|
/**
|
|
124
|
-
*
|
|
153
|
+
* Build plugins, in the `EcoBuildPlugin` contract, that load or transform modules in every build.
|
|
125
154
|
*/
|
|
126
155
|
loaders?: EcoBuildPlugin[];
|
|
127
156
|
/**
|
|
@@ -152,8 +181,32 @@ export type FinalizeEcoPagesConfigOptions = {
|
|
|
152
181
|
* @default process.cwd()
|
|
153
182
|
*/
|
|
154
183
|
cwd?: string;
|
|
184
|
+
/**
|
|
185
|
+
* When the runtime's activations resolve Integration global scripts.
|
|
186
|
+
*
|
|
187
|
+
* @remarks
|
|
188
|
+
* The default follows the process command, `'browser-build'` for a production export. A process that runs a
|
|
189
|
+
* production export without that command, such as a test or the Lit static-render worker, passes
|
|
190
|
+
* `'browser-build'`.
|
|
191
|
+
*
|
|
192
|
+
* @defaultValue `'browser-build'` for a production export command, otherwise `'activation'`.
|
|
193
|
+
*/
|
|
194
|
+
globalScriptResolution?: GlobalScriptResolution;
|
|
155
195
|
};
|
|
156
196
|
export type LoadEcoPagesConfigOptions = {
|
|
157
197
|
configFile?: string;
|
|
158
198
|
cwd?: string;
|
|
199
|
+
/** See {@link FinalizeEcoPagesConfigOptions.globalScriptResolution}. */
|
|
200
|
+
globalScriptResolution?: GlobalScriptResolution;
|
|
201
|
+
/**
|
|
202
|
+
* Output and work directories that replace the config's `distDir` and `workDir`.
|
|
203
|
+
*
|
|
204
|
+
* @remarks
|
|
205
|
+
* A worker that renders for a build in progress, such as the Lit static-render worker, passes the directories
|
|
206
|
+
* of that build, which may differ from the configured ones.
|
|
207
|
+
*/
|
|
208
|
+
directories?: {
|
|
209
|
+
distDir: string;
|
|
210
|
+
workDir: string;
|
|
211
|
+
};
|
|
159
212
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Entry that `ecopages types` runs: it loads `eco.config.ts` and sets the processors up, so they write the
|
|
3
|
-
* types for their virtual modules (such as `ecopages:images` and `ecopages:content/*`), then
|
|
3
|
+
* types for their virtual modules (such as `ecopages:images` and `ecopages:content/*`), then declares the CSS
|
|
4
|
+
* Modules of the app, then exits.
|
|
4
5
|
*
|
|
5
6
|
* @remarks
|
|
6
7
|
* Config finalization runs no processor code, so the types come from each processor's `setup()`, with
|
|
@@ -9,10 +10,12 @@
|
|
|
9
10
|
*
|
|
10
11
|
* @module
|
|
11
12
|
*/
|
|
13
|
+
import { writeCssModuleDeclarations } from '../assets/asset-processing-service/processors/stylesheet/css-module-types.js';
|
|
12
14
|
import { setupAppRuntimePlugins } from '../build/build-adapter.js';
|
|
13
15
|
import { appLogger } from '../global/app-logger.js';
|
|
14
16
|
import { loadEcoPagesConfig } from './load-eco-config.js';
|
|
15
17
|
const appConfig = await loadEcoPagesConfig();
|
|
16
18
|
await setupAppRuntimePlugins({ appConfig });
|
|
19
|
+
await writeCssModuleDeclarations(appConfig);
|
|
17
20
|
appLogger.info('Wrote the generated types for the virtual modules in eco.config.ts.');
|
|
18
21
|
process.exit(0);
|
package/src/css-imports.d.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A CSS Module's default export maps each local class name to its scoped name, followed by the names it composes.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* It is declared before `*.css` because TypeScript picks the first of two patterns that match a specifier with
|
|
6
|
+
* the same prefix, and `x.module.css` matches both.
|
|
7
|
+
*/
|
|
8
|
+
declare module '*.module.css' {
|
|
9
|
+
const classes: { readonly [key: string]: string };
|
|
10
|
+
export default classes;
|
|
11
|
+
}
|
|
12
|
+
|
|
1
13
|
declare module '*.css' {
|
|
2
14
|
const styles: string;
|
|
3
15
|
export default styles;
|
package/src/declarations.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ type EcoIslandRuntime = {
|
|
|
15
15
|
type EcoPageData = {
|
|
16
16
|
module: string;
|
|
17
17
|
props: Record<string, unknown>;
|
|
18
|
+
/** Set by a react-router navigation to the document it fetched; absent otherwise. */
|
|
19
|
+
document?: Document;
|
|
18
20
|
};
|
|
19
21
|
type EcoPagesWindowRuntime = {
|
|
20
22
|
hmrHandlers?: Record<string, HMRHandler>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import path from '
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
2
|
import { getNodeEnvironment } from '../env.js';
|
|
3
3
|
import { getDevEnvFileNames } from './development-restart.js';
|
|
4
4
|
/** Returns whether `filePath` is a supported project-level dotenv file. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import path from '
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
2
|
import { getNodeEnvironment, isEcopagesEnvEnabled } from '../env.js';
|
|
3
3
|
import { DEFAULT_ECOPAGES_DIST_DIR, DEFAULT_ECOPAGES_WORK_DIR } from '../constants.js';
|
|
4
4
|
import { createProjectWatcherIgnorePredicate } from '../watchers/project-watcher-ignore.js';
|