@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
package/README.md
CHANGED
|
@@ -11,143 +11,9 @@ Ecopages is an extensible static site generator (SSG) that runs on Node. It embr
|
|
|
11
11
|
- **Framework agnostic**: First-class support for KitaJS, Lit, React, and MDX via official integration plugins.
|
|
12
12
|
- **Extensible**: Hook into the build process with custom processors or rendering integrations.
|
|
13
13
|
|
|
14
|
-
##
|
|
15
|
-
|
|
16
|
-
Projects load shared ambient types through `@ecopages/core/declarations`. This entry references `src/css-imports.d.ts`, which keeps the wildcard CSS declaration in a standalone ambient file so side-effect CSS imports typecheck without per-project declarations.
|
|
17
|
-
|
|
18
|
-
The current core package is organized around app-owned runtime state and explicit service boundaries.
|
|
19
|
-
|
|
20
|
-
The important ownership rules are:
|
|
21
|
-
|
|
22
|
-
- Core runtime mode and `ECOPAGES_*` settings are read through `src/env.ts`. Its typed accessors define the supported variable names, parse `true` and `1` as enabled and `false` and `0` as disabled, and provide the runtime-mode helpers used by core, integrations and Processors. The user-facing settings are documented in the [CLI reference](../ecopages/README.md#environment--runtime-options).
|
|
23
|
-
|
|
24
|
-
- Every `loadEcoPagesConfig()` call imports the config module through the module cache, then finalizes a distinct app config and `AppRuntime`. Build state, HTML Page warnings, custom-element preload scopes, and request-pipeline metrics stay with that runtime; pure memo caches remain shared. Each runtime keeps the one build queue finalization created.
|
|
25
|
-
- Build requests declare server or browser environment independently of scheduling. Integrations and Processors contribute one environment-selected plugin list; config rejects duplicate names within an environment. Core's own transforms preserve source locations and the bridge composes chained maps. See [Build Layer](src/build/README.md) and [Plugin Contracts](src/plugins/README.md) for migration.
|
|
26
|
-
- Component identity attribution is one build plugin, shared by server, browser, and HMR compilation paths: after a lexical `eco.` gate, it uses Oxc to wrap supported factory options with `bindComponentIdentity()`, which factories retain as `config.identity`.
|
|
27
|
-
- Component ownership follows `config.integration`, then `config.identity.integration`, then the inherited owner through the exported `getComponentOwner()` helper. Integration plugins opt into page-owned asset bundling with `bundlesPageDependencies`; React and Ecopages JSX enable it. Bundling only combines consecutive eligible assets so custom-attribute files keep their declared order.
|
|
28
|
-
- Direct local Eco Component imports (including named `export { X } from` barrels) and relative side-effect CSS imports supply Dependencies by default through the shared transform and existing collector; explicit asset declarations override inference, and inferred styles stay keyed by identity until collection. Eco owns the component render context used by its factories. See [eco](src/eco/README.md) and [Plugin Contracts](src/plugins/README.md).
|
|
29
|
-
- Server DOM constructors (`HTMLElement`, `customElements`, `document`) are installed once per process from Integration `serverDom` contributors: complete surfaces first, then repairs. The result does not depend on Integration order in the config or on which Page is requested first. See [Plugin Contracts](src/plugins/README.md).
|
|
30
|
-
- Every Integration shares one renderer and the app-owned `AssetProcessingService` across route renders, explicit views, and foreign-child handoffs. Integration-owned asset processing calls pass their owning Integration so its optional dependency-preparation hook can run; one service cache covers grouped and ungrouped processor results. Route preparation records one component graph for ownership validation, dependencies, client assets, and dev cache paths; a development render fails on a component outside it. Dependency collection uses the service to turn declared assets into runtime-ready output instead of treating a missing service as an empty asset set. Route preparation builds each Page Package once; component renders return HTML and attributes only and add no assets. Route renders keep Integration dependencies and foreign-renderer caches in per-render sessions, with async context storage isolating concurrent renders. See [Route Renderer](src/route-renderer/README.md).
|
|
31
|
-
- Custom Integrations can create a renderer with `createIntegrationRenderer()` and opt into component, page-graph, document-shell props and composition, foreign-child, route lifecycle, grouped island assets, and finalization hooks without rebuilding the route pipeline. Hook factories receive app-owned renderer options plus helpers for Integration-wide dependencies, dependency paths, and pending lazy triggers. Core handles queued-child resolution and island-host finalization around component hooks. See [Custom Integration](../../apps/docs/src/content/docs/plugins/custom-integration.mdx).
|
|
32
|
-
- Browser bundling and server module loading are separate paths. SSR-enabled lazy scripts execute on the server before rendering and in the browser only on their configured trigger.
|
|
33
|
-
- The Project Watcher uses `@ecopages/file-system` recursive subscriptions, batches file and directory events, sends matching Processors one `onChanges` notification for each non-restart file batch, and dispatches every HMR-eligible path once per debounce window. Directory-only Pages batches refresh routes without Processor or HMR notifications. It activates linked package roots only when a recorded build input uses them, and retries a failed activation when additional inputs arrive during registration. Sustained edits are scheduled no later than one second after the first; processing is serialized and startup fails if the filesystem subscription is not ready within 30 seconds. See [Project Watcher](src/watchers/README.md).
|
|
34
|
-
- Development Page prewarm renders run in the background without delaying server readiness. App configuration declares `devPrewarmPaths`; Processors append the pathnames they own to that list from `setup()`, which finishes before the server reports that it is listening. A path that fails to render is skipped and logged at debug level. See [Runtime Adapters](src/adapters/README.md) and [Plugin Contracts](src/plugins/README.md).
|
|
35
|
-
- Watch-mode resources belong to one `DevSession`, including the watcher, HMR manager, client bridge, Page prewarm, and Dev Toolbar. `EcopagesApp` shares one readiness promise across concurrent startup and request-only calls; after `stop()`, `start()` and `fetch()` initialize a fresh server adapter.
|
|
36
|
-
- App shutdown tears down Integration runtime resources, including a Lit static-export worker if one is still running. Serving does not start that worker. See [Runtime Adapters](src/adapters/README.md).
|
|
37
|
-
- HMR and invalidation use shared graph-aware services instead of runtime-specific ad hoc wiring. One Development Invalidation service belongs to each `AppRuntime` and is shared by its Project Watcher and HMR manager. Editing a `source` module used by both a server route and a browser entrypoint reloads the browser so server-rendered markup and the island refresh together.
|
|
38
|
-
- Browser and React navigation use one core-owned document commit pipeline; each router supplies its page swap and scroll handling while core coordinates fetch/cache/parse, head reconciliation, script activation, view transitions, and lifecycle events. Head reconciliation avoids rewriting unchanged resolved link URLs, stages new stylesheets without applying them to the outgoing page, and preserves the destination order of uniquely keyed CSS by staging replacements when retained stylesheets need to change order; it requests a full document navigation if a replacement fails or retained CSS changes order while a retained style or stylesheet is persisted. A later navigation supersedes cleanup from earlier transitions, including when it skips animation; a failed or uncommitted page swap clears transition names. Browser-router always morphs the incoming body, keeping nodes with matching persistence keys attached when their ancestor structure remains compatible; during rerun refresh, custom-element descendants on that path also stay in place when their markup remains structurally compatible. Superseded stylesheet waits settle when a later page removes their staged links. For rerun scripts matched by relative `src` (without an explicit script id or HTML `id`), core keeps identity stable across pages with different `<base>` URLs while loading external modules from the incoming page's resolved URL. See [Router Layer](src/router/README.md).
|
|
39
|
-
- `serveDistFile()` handles runtime static fallbacks and preview through the app's `RuntimeHost`, serving only `dist/client/` with real-path containment, HEAD and 405 responses, gzip negotiation, ETags, conditional 304s, and the shared cache policy. The private `dist/server/` output is a sibling of the served directory. `immutable` applies only to outputs the build recorded as content-hashed; HTML stays revalidated. See [Runtime Adapters](src/adapters/README.md).
|
|
40
|
-
- The build adapter returns each build's plugin-recorded inputs by module alongside source-module closures, and passes an explicit recorder to Rolldown plugin hooks. Cache owners bind only the paths read by their entry closure, so development invalidates affected Page Browser Graphs, HTML entries, route modules, and browser entrypoints. Grouped browser scripts merge external modules, compatible plugin instances, and non-conflicting define values within their build group, disable splitting when any entry opts out, resolve by the path or name the caller passed (and the bundler's facade when that spelling differs), and cache only complete groups with matching dependency sets. Static production export combines grouped Page entries and HTML module scripts in compatible app-wide browser build groups, saves their route associations in the server manifest, and lets `ecopages start` restore listed route assets before SSR requests. Non-exact route templates also get a parameter-free plan without running route data hooks, Dynamic Pages that declare `staticPaths` get a per-entry plan, and so does every `app.static` route instance. Later params reuse a planned graph when grouped browser dependencies and page-client entries match. After `ecopages start` restores the manifest, a request whose graph is not listed is an error that names the route and the missing entry; it is never built. Entry-specific plugins with a `bundleGroupKey` retain their own configuration inside the shared build, while entries with different bundle options keep separate requests. In-process Page caches also track reachable generated artifacts. On-demand page-cache path invalidation removes query and development runtime variants of the pathname and releases their build-input bindings. See [Build Layer](src/build/README.md), [Page Cache](src/page-cache/README.md), and [Asset Processing](src/assets/README.md).
|
|
41
|
-
|
|
42
|
-
### Bootstrap And Runtime Ownership
|
|
43
|
-
|
|
44
|
-
```mermaid
|
|
45
|
-
flowchart TD
|
|
46
|
-
A[eco.config.ts] --> B[defineConfig / loadEcoPagesConfig]
|
|
47
|
-
B --> C[Config finalization]
|
|
48
|
-
C --> D[App build adapter]
|
|
49
|
-
C --> E[App build manifest]
|
|
50
|
-
C --> F[App build queue]
|
|
51
|
-
C --> G[AppRuntime]
|
|
52
|
-
D --> F
|
|
53
|
-
F --> I[PageModuleImportService]
|
|
54
|
-
F --> J[BrowserBundleService]
|
|
55
|
-
I --> K[EcopagesApp]
|
|
56
|
-
K --> L[NodeServerAdapter]
|
|
57
|
-
L --> M[Node HTTP host]
|
|
58
|
-
L --> N[ServerRequestPipeline]
|
|
59
|
-
L --> O[DevSession in watch mode]
|
|
60
|
-
O --> P[Project Watcher and HmrManager]
|
|
61
|
-
E --> J
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### Development Invalidation And HMR Flow
|
|
65
|
-
|
|
66
|
-
```mermaid
|
|
67
|
-
flowchart TD
|
|
68
|
-
A[File changes] --> B[ProjectWatcher debounce window]
|
|
69
|
-
B --> C[applyDevFileChanges]
|
|
70
|
-
C --> D{Change kinds}
|
|
71
|
-
D -->|Route, recorded input, or server source| E[Mark server modules dirty]
|
|
72
|
-
D -->|Additional watch| E
|
|
73
|
-
D -->|Config, dotenv or linked package| R[Restart dev process]
|
|
74
|
-
E --> N[Notify processors]
|
|
75
|
-
N --> F[One browser update]
|
|
76
|
-
D -->|Public asset| F
|
|
77
|
-
D -->|Processor-owned asset| G[Notify processor only]
|
|
78
|
-
D -->|HMR-eligible file batch| H[Core HMR manager]
|
|
79
|
-
H --> I[Strategy selection]
|
|
80
|
-
I --> J[Core JsHmrStrategy]
|
|
81
|
-
I --> K[Integration strategy e.g. ReactHmrStrategy]
|
|
82
|
-
J --> L[BrowserBundleService]
|
|
83
|
-
K --> L
|
|
84
|
-
K --> M[importServerModule]
|
|
85
|
-
M --> N[AppModuleLoader]
|
|
86
|
-
L --> O[Updated browser bundle]
|
|
87
|
-
O --> P[Client bridge broadcast]
|
|
88
|
-
```
|
|
14
|
+
## Architecture
|
|
89
15
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
### Practical Summary
|
|
93
|
-
|
|
94
|
-
- Config finalization seeds one app-owned `AppRuntime` (build adapter, build manifest, build queue, build-input index, and module caches); the HMR manager records the imports of each served browser module in that build-input index. Server startup refreshes the build queue.
|
|
95
|
-
- `BrowserBundleService` is the shared browser build seam used by HMR and asset-oriented browser output paths; callers choose the `build` or `hmr` scheduling lane explicitly.
|
|
96
|
-
- `AppModuleLoader` is created once per app runtime and supplies the app root and shared build queue for server-side source loading, including HMR metadata imports.
|
|
97
|
-
- `RouteRegistry` gives exact and dynamic Pages priority over catch-alls, selects the most specific matching catch-all prefix, and shares segment matching and one-time URL decoding with API, explicit, and WebSocket routes.
|
|
98
|
-
- Browser runtime package entries resolve from the application root with ESM import conditions, so framework-local packages cannot shadow app dependencies.
|
|
99
|
-
- `createApp()` resolves config and CLI mode once, then returns the concrete `EcopagesApp`, which owns route registration and the Node HTTP server lifecycle.
|
|
100
|
-
- One bundled adapter builds the app with Rolldown. Preserved server-module names stay flat and use a stable digest when deep package-store paths need shortening.
|
|
101
|
-
|
|
102
|
-
## Source Layering
|
|
103
|
-
|
|
104
|
-
Core source moves from shared foundations through app assembly. A lower layer may import within its own layer or from an earlier layer; it must not import a later layer.
|
|
105
|
-
|
|
106
|
-
| Layer | Folders and files |
|
|
107
|
-
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
108
|
-
| Foundation | `types/`, `constants.ts`, `env.ts`, `browser-env.ts`, `errors/`, `global/`, `utils/`, `html/`, `client/`, `islands/`, `validation/` |
|
|
109
|
-
| Contracts | `plugins/`, `eco/` |
|
|
110
|
-
| Build | `build/`, `assets/`, `cache/`, `diagnostics/` |
|
|
111
|
-
| Rendering | `router/`, `route-renderer/`, `html-pages/`, `page-cache/`, `static-site-generator/` |
|
|
112
|
-
| Development and HMR | `dev/`, `watchers/`, `dev-toolbar/`, `hmr/` |
|
|
113
|
-
| Application assembly | `adapters/`, `config/`, `index.ts`, `index.browser.ts`, `integration.ts`, `processor.ts`, `build.ts`, `client.ts` |
|
|
114
|
-
|
|
115
|
-
The guard in `scripts/check-portability.ts` checks runtime module references inside `packages/core/src`, including `import()`, `require()`, and resolver calls. Inline `type` modifiers count when TypeScript preserves their side-effect imports under `verbatimModuleSyntax`; explicit `import type` and `export type` declarations are erased and excluded. Test files and fixtures are excluded too. Existing upward references are listed in `scripts/core-layering-allowlist.json` with the issue that removes each edge. The allowlist only shrinks: the check fails for an unlisted upward reference and for an entry whose reference has gone away.
|
|
116
|
-
|
|
117
|
-
## Documentation Map
|
|
118
|
-
|
|
119
|
-
Use this package README as the top-level map, then drill into the focused subsystem READMEs:
|
|
120
|
-
|
|
121
|
-
- `src/config/README.md`: config loading, assembly, and app-owned runtime/build state
|
|
122
|
-
- `src/types/README.md`: public, internal, and per-app runtime contracts
|
|
123
|
-
- `src/errors/README.md`, `src/global/README.md`, `src/utils/README.md`, and `src/client/README.md`: shared Foundation modules, including path containment, markup escaping, entity decoding, regex escaping, SHA-256 content hashes (`contentHash` from `@ecopages/core/build`), and production server-bundle context
|
|
124
|
-
- `src/cache/README.md`: Build-layer module parse cache
|
|
125
|
-
- `src/diagnostics/README.md`: per-app request-pipeline metrics and the startup trace
|
|
126
|
-
- `src/plugins/README.md`: integration and processor authoring contracts
|
|
127
|
-
- `src/build/README.md`: build adapter, app-scoped server module loading, shared `.server` browser import guard, per-module production output for shared SSR dependencies, development build coordination, standalone Node server packaging and its deploy layout
|
|
128
|
-
- `src/page-cache/README.md`: HTML cache strategies, ISR, and source-aware invalidation
|
|
129
|
-
- `src/assets/README.md`: shared asset processing and browser build coordination
|
|
130
|
-
- `src/validation/README.md`: request validation with Standard Schema
|
|
131
|
-
- `src/html/README.md`: streaming HTML rewriting, per-render document contributions, source parsing, and escaped asset tags
|
|
132
|
-
- `src/adapters/README.md`: Node HTTP host and shared adapter boundaries
|
|
133
|
-
- `src/dev/README.md`: development invalidation, dev transform server, in-memory on-demand vendor bundles, and client delivery (including workspace-package `@fs` URLs)
|
|
134
|
-
- `src/watchers/README.md`: recursive filesystem subscriptions with bounded readiness and scheduled debounce batches, external build-input and linked-package watching, batched `applyDevFileChanges`, and restart invalidation
|
|
135
|
-
- `src/dev/invalidation/README.md`: file-change classification and dirty-marking for bounded watcher batches
|
|
136
|
-
- `src/hmr/README.md`: HMR strategy, update-layer ownership, and build error presentation
|
|
137
|
-
- `src/dev-toolbar/README.md`: toolbar enablement, custom clients, and build error event contract
|
|
138
|
-
- `src/router/README.md`: route discovery (Pages and `*.api.{ts,tsx,js,jsx}` endpoint files), matching, browser navigation coordination, persistence-aware body morphing, and the shared client navigation pipeline
|
|
139
|
-
- `src/route-renderer/README.md`: rendering orchestration, semantic error pages, dependency resolution, and HTML cache source paths
|
|
140
|
-
- `src/static-site-generator/README.md`: static build execution, collected Page render failures, and sitemap eligibility from successful route-render metadata
|
|
141
|
-
- `src/eco/README.md`: `eco` authoring APIs for pages, layouts, and components, including the `LayoutOptions` type contract
|
|
142
|
-
- `src/html-pages/README.md`: built-in `.html` Filesystem Routes, Html shell, and head reconciliation
|
|
143
|
-
|
|
144
|
-
The intended reading order is:
|
|
145
|
-
|
|
146
|
-
1. this file for the big-picture architecture
|
|
147
|
-
2. `src/config/README.md` for config and lifecycle ownership
|
|
148
|
-
3. `src/plugins/README.md` and `src/build/README.md` for contribution contracts
|
|
149
|
-
4. `src/page-cache/README.md`, `src/assets/README.md`, `src/validation/README.md`, `src/html/README.md`, and `src/adapters/README.md` for runtime execution
|
|
150
|
-
5. `src/router/README.md` and `src/route-renderer/README.md` for request-time flow
|
|
16
|
+
How core works inside (config and `AppRuntime`, the build, rendering, the dev server and HMR) is described in the [developer pages](../../apps/docs/src/content/dev), served at `/dev` on the docs site. Start with the [overview](../../apps/docs/src/content/dev/index.mdx).
|
|
151
17
|
|
|
152
18
|
## Installation
|
|
153
19
|
|
|
@@ -170,8 +36,7 @@ import { defineConfig } from '@ecopages/core/config';
|
|
|
170
36
|
import { ecopagesJsxPlugin } from '@ecopages/ecopages-jsx';
|
|
171
37
|
|
|
172
38
|
export default defineConfig({
|
|
173
|
-
|
|
174
|
-
baseUrl: process.env.ECOPAGES_BASE_URL ?? 'http://localhost:3000',
|
|
39
|
+
baseUrl: 'https://example.com',
|
|
175
40
|
defaultMetadata: {
|
|
176
41
|
title: 'My Ecopages Site',
|
|
177
42
|
description: 'Built with Ecopages',
|
|
@@ -217,7 +82,7 @@ Plain `.html` files in `src/pages/` are HTML Pages and need no Integration: `src
|
|
|
217
82
|
|
|
218
83
|
### 4. Reusable Components
|
|
219
84
|
|
|
220
|
-
Define components with `eco.component()`
|
|
85
|
+
A component's imported stylesheet is injected only when a Page uses it, plain function or not. Define components with `eco.component()` when they also need scripts, `modules`, stylesheet attributes, an `integration` override, or rendering by another Integration:
|
|
221
86
|
|
|
222
87
|
```tsx
|
|
223
88
|
import { eco } from '@ecopages/core';
|
|
@@ -296,7 +161,7 @@ export const GET = defineGet({
|
|
|
296
161
|
});
|
|
297
162
|
```
|
|
298
163
|
|
|
299
|
-
The file's rules (405 and `Allow`, load errors, `app.ts` routes on the same URL) are in the [Endpoint Files docs](https://ecopages.app/docs/server/endpoint-files); the
|
|
164
|
+
The file's rules (405 and `Allow`, load errors, `app.ts` routes on the same URL) are in the [Endpoint Files docs](https://ecopages.app/docs/server/endpoint-files); the internals are on the [Routing](../../apps/docs/src/content/dev/routing.mdx) developer page. A build of an app with an endpoint file publishes the server bundle (`dist/server/`), emits server modules, then checks each file's exports, even when nothing else registers a handler, so `ecopages start` serves it.
|
|
300
165
|
|
|
301
166
|
### 6. Error pages
|
|
302
167
|
|
|
@@ -310,7 +175,7 @@ app.notFound(NotFoundView);
|
|
|
310
175
|
app.serverError(ServerErrorView);
|
|
311
176
|
```
|
|
312
177
|
|
|
313
|
-
Import a view and pass it to `ctx.render`, `ctx.renderPartial`, `app.static()`, or an error-page helper.
|
|
178
|
+
Import a view and pass it to `ctx.render`, `ctx.renderPartial`, `app.static()`, or an error-page helper. The default export of an Integration-owned file becomes a view reference: development loads it through the app module loader so a save reloads without a restart, and production reads the module `ecopages build` wrote to `dist/server/`. A file without a default export, such as a file of named plain components, imports as itself. A full explicit view renders through the same route pipeline as a filesystem Page, including its layouts, default metadata, robots meta, and page client plan. Props passed to the render are available to the view's `metadata`.
|
|
314
179
|
|
|
315
180
|
When no custom page is configured, built-in HTML defaults are served instead.
|
|
316
181
|
|
|
@@ -353,7 +218,7 @@ Use these entrypoints when building an Ecopages app:
|
|
|
353
218
|
- `@ecopages/core/create-app`
|
|
354
219
|
- `@ecopages/core/config`
|
|
355
220
|
- `@ecopages/core/errors`
|
|
356
|
-
- `@ecopages/core/declarations` (types only)
|
|
221
|
+
- `@ecopages/core/declarations` (types only; also declares side-effect CSS imports, so they typecheck without per-project declarations)
|
|
357
222
|
- `@ecopages/core/env` (types only)
|
|
358
223
|
|
|
359
224
|
### Integration Authoring
|
|
@@ -362,7 +227,7 @@ Use `@ecopages/core/integration` for Integration contracts, render hooks, and sh
|
|
|
362
227
|
|
|
363
228
|
### Processor Authoring
|
|
364
229
|
|
|
365
|
-
Use `@ecopages/core/processor` for Processor contracts and generated-asset helpers.
|
|
230
|
+
Use `@ecopages/core/processor` for Processor contracts and generated-asset helpers. A stylesheet Processor runs the cases of `stylesheetProcessorContract` from `@ecopages/core/processor/contract` in its tests.
|
|
366
231
|
|
|
367
232
|
### Build Extensions
|
|
368
233
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecopages/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Core package for Ecopages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecopages",
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
"ssg"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": "^24.22.0 || >=26.0.0"
|
|
13
|
+
},
|
|
11
14
|
"main": "./src/index.js",
|
|
12
15
|
"type": "module",
|
|
13
16
|
"publishConfig": {
|
|
@@ -21,7 +24,7 @@
|
|
|
21
24
|
},
|
|
22
25
|
"dependencies": {
|
|
23
26
|
"@clack/prompts": "^1.7.0",
|
|
24
|
-
"@ecopages/file-system": "0.
|
|
27
|
+
"@ecopages/file-system": "0.7.0",
|
|
25
28
|
"@ecopages/logger": "^0.2.3",
|
|
26
29
|
"@ecopages/scripts-injector": "^0.1.5",
|
|
27
30
|
"@jridgewell/remapping": "^2.3.5",
|
|
@@ -34,7 +37,7 @@
|
|
|
34
37
|
"ws": "^8.20.1"
|
|
35
38
|
},
|
|
36
39
|
"peerDependencies": {
|
|
37
|
-
"@ecopages/dev-toolbar": "0.
|
|
40
|
+
"@ecopages/dev-toolbar": "0.7.0"
|
|
38
41
|
},
|
|
39
42
|
"peerDependenciesMeta": {
|
|
40
43
|
"@ecopages/dev-toolbar": {
|
|
@@ -63,6 +66,11 @@
|
|
|
63
66
|
"types": "./src/processor.d.ts",
|
|
64
67
|
"default": "./src/processor.js"
|
|
65
68
|
},
|
|
69
|
+
"./processor/contract": {
|
|
70
|
+
"import": "./src/processor-contract.js",
|
|
71
|
+
"types": "./src/processor-contract.d.ts",
|
|
72
|
+
"default": "./src/processor-contract.js"
|
|
73
|
+
},
|
|
66
74
|
"./build": {
|
|
67
75
|
"import": "./src/build.js",
|
|
68
76
|
"types": "./src/build.d.ts",
|
|
@@ -120,6 +128,11 @@
|
|
|
120
128
|
"types": "./src/processor.d.ts",
|
|
121
129
|
"default": "./src/processor.js"
|
|
122
130
|
},
|
|
131
|
+
"./processor/contract.ts": {
|
|
132
|
+
"import": "./src/processor-contract.js",
|
|
133
|
+
"types": "./src/processor-contract.d.ts",
|
|
134
|
+
"default": "./src/processor-contract.js"
|
|
135
|
+
},
|
|
123
136
|
"./build.ts": {
|
|
124
137
|
"import": "./src/build.js",
|
|
125
138
|
"types": "./src/build.d.ts",
|
|
@@ -26,7 +26,7 @@ export async function disposeDevWebSocketServer(websocketServer) {
|
|
|
26
26
|
*/
|
|
27
27
|
export class DevSession {
|
|
28
28
|
options;
|
|
29
|
-
bridge
|
|
29
|
+
bridge;
|
|
30
30
|
hmrManager;
|
|
31
31
|
websocketServer = new WebSocketServer({ noServer: true });
|
|
32
32
|
prewarmAbort = new AbortController();
|
|
@@ -35,6 +35,7 @@ export class DevSession {
|
|
|
35
35
|
disposePromise;
|
|
36
36
|
constructor(options) {
|
|
37
37
|
this.options = options;
|
|
38
|
+
this.bridge = new NodeClientBridge(options.appConfig.absolutePaths);
|
|
38
39
|
this.hmrManager = new HmrManager({ appConfig: options.appConfig, bridge: this.bridge });
|
|
39
40
|
}
|
|
40
41
|
async start() {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { WebSocket } from 'ws';
|
|
2
|
-
import type { ClientBridgeEvent
|
|
3
|
-
|
|
2
|
+
import type { ClientBridgeEvent } from '../../types/contracts.js';
|
|
3
|
+
import type { SourceRelativeStylesheetDirs } from '../../assets/asset-processing-service/processors/stylesheet/source-relative-stylesheet.js';
|
|
4
|
+
import { ClientBridge } from '../shared/hmr/client-bridge.js';
|
|
5
|
+
export declare class NodeClientBridge extends ClientBridge {
|
|
4
6
|
private subscribers;
|
|
5
7
|
private heartbeatTimer;
|
|
6
|
-
constructor();
|
|
8
|
+
constructor(stylesheetDirs: SourceRelativeStylesheetDirs);
|
|
7
9
|
/**
|
|
8
10
|
* Pings all open subscribers and removes any that are no longer in OPEN state.
|
|
9
11
|
* This prevents a slow memory leak caused by zombie connections that never
|
|
@@ -13,10 +15,6 @@ export declare class NodeClientBridge implements IClientBridge {
|
|
|
13
15
|
subscribe(ws: WebSocket): void;
|
|
14
16
|
unsubscribe(ws: WebSocket): void;
|
|
15
17
|
broadcast(event: ClientBridgeEvent): void;
|
|
16
|
-
reload(): void;
|
|
17
|
-
cssUpdate(path: string): void;
|
|
18
|
-
update(path: string): void;
|
|
19
|
-
error(message: string): void;
|
|
20
18
|
get subscriberCount(): number;
|
|
21
19
|
/**
|
|
22
20
|
* Stops the heartbeat timer and clears all subscribers.
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { ClientBridge } from '../shared/hmr/client-bridge.js';
|
|
1
2
|
const HEARTBEAT_INTERVAL_MS = 30_000;
|
|
2
|
-
export class NodeClientBridge {
|
|
3
|
+
export class NodeClientBridge extends ClientBridge {
|
|
3
4
|
subscribers = new Set();
|
|
4
5
|
heartbeatTimer = null;
|
|
5
|
-
constructor() {
|
|
6
|
+
constructor(stylesheetDirs) {
|
|
7
|
+
super(stylesheetDirs);
|
|
6
8
|
this.heartbeatTimer = setInterval(() => this.sweep(), HEARTBEAT_INTERVAL_MS);
|
|
7
9
|
/* Allow the process to exit even if the timer is still active */
|
|
8
10
|
this.heartbeatTimer.unref?.();
|
|
@@ -35,18 +37,6 @@ export class NodeClientBridge {
|
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
|
-
reload() {
|
|
39
|
-
this.broadcast({ type: 'reload' });
|
|
40
|
-
}
|
|
41
|
-
cssUpdate(path) {
|
|
42
|
-
this.broadcast({ type: 'css-update', path, timestamp: Date.now() });
|
|
43
|
-
}
|
|
44
|
-
update(path) {
|
|
45
|
-
this.broadcast({ type: 'update', path, timestamp: Date.now() });
|
|
46
|
-
}
|
|
47
|
-
error(message) {
|
|
48
|
-
this.broadcast({ type: 'error', message });
|
|
49
|
-
}
|
|
50
40
|
get subscriberCount() {
|
|
51
41
|
return this.subscribers.size;
|
|
52
42
|
}
|
|
@@ -113,8 +113,10 @@ export declare class NodeServerAdapter {
|
|
|
113
113
|
*
|
|
114
114
|
* @remarks
|
|
115
115
|
* Such a start checks that `dist/` is complete, restores Processors from the emitted
|
|
116
|
-
* server-modules map instead of calling `setup()`, and
|
|
117
|
-
*
|
|
116
|
+
* server-modules map instead of calling `setup()`, restores and seals the asset ledger before any
|
|
117
|
+
* Integration processes a dependency, and leaves `dist/` untouched: the build already copied the
|
|
118
|
+
* public directory and processed every asset, and the deploy may hold no sources. Any other start
|
|
119
|
+
* restores no ledger, so a source edited after the build is never served from stale outputs.
|
|
118
120
|
*/
|
|
119
121
|
private startsFromCompleteDist;
|
|
120
122
|
private initializeResources;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {} from 'node:http';
|
|
2
|
-
import path from '
|
|
2
|
+
import { path } from '@ecopages/file-system/path';
|
|
3
3
|
import { fileSystem } from '@ecopages/file-system';
|
|
4
4
|
import { setupAppRuntimeIntegrations, setupAppRuntimePlugins } from '../../build/build-adapter.js';
|
|
5
5
|
import { appLogger } from '../../global/app-logger.js';
|
|
6
6
|
import { attachNodeHttpWebSocketUpgrades } from '../shared/ws/node-http-websocket-upgrades.js';
|
|
7
7
|
import { StaticSiteGenerator } from '../../static-site-generator/static-site-generator.js';
|
|
8
8
|
import { ServerRequestPipeline } from '../shared/runtime/server-request-pipeline.js';
|
|
9
|
-
import { runWithBuildInputIndex } from '../../build/cache/build-input-dependency-index.js';
|
|
10
9
|
import { ServerStaticBuilder } from '../shared/runtime/server-static-builder.js';
|
|
11
10
|
import { DEFAULT_ECOPAGES_HOSTNAME, DEFAULT_ECOPAGES_PORT } from '../../constants.js';
|
|
12
11
|
import { disposeDevResources, prepareRuntimePublicDir } from '../shared/runtime/runtime-server-lifecycle.js';
|
|
13
12
|
import { resolveServeRuntimeOrigin } from '../shared/runtime/runtime-app-bootstrap.js';
|
|
14
13
|
import { bindRuntimeServer } from '../shared/runtime/bind-runtime-server.js';
|
|
15
14
|
import { serveDistFile } from '../shared/http/dist-file-handler.js';
|
|
15
|
+
import { applyResponseHeaders } from '../shared/http/response-headers.js';
|
|
16
16
|
import { DevSession } from './dev-session.js';
|
|
17
|
-
import {
|
|
17
|
+
import { restoreProductionBrowserBuild } from '../../static-site-generator/production-page-browser-graph-prebuild.js';
|
|
18
18
|
import { assertProductionDistComplete } from '../../build/production-dist-complete.js';
|
|
19
19
|
import { requireProductionServerModules } from '../../build/server/server-modules-manifest.js';
|
|
20
20
|
import { isProductionRuntime } from '../../env.js';
|
|
@@ -83,7 +83,7 @@ export class NodeServerAdapter {
|
|
|
83
83
|
runtime: this.runtime,
|
|
84
84
|
watch: this.options.watch,
|
|
85
85
|
runInRequestBuildScope: this.options.watch
|
|
86
|
-
? (operation) => this.runtime.buildQueue.withRequestScope(
|
|
86
|
+
? (operation) => this.runtime.buildQueue.withRequestScope(operation)
|
|
87
87
|
: undefined,
|
|
88
88
|
});
|
|
89
89
|
this.runtimeAssetSetup = options.runtimeAssetSetup ?? 'start';
|
|
@@ -141,8 +141,10 @@ export class NodeServerAdapter {
|
|
|
141
141
|
*
|
|
142
142
|
* @remarks
|
|
143
143
|
* Such a start checks that `dist/` is complete, restores Processors from the emitted
|
|
144
|
-
* server-modules map instead of calling `setup()`, and
|
|
145
|
-
*
|
|
144
|
+
* server-modules map instead of calling `setup()`, restores and seals the asset ledger before any
|
|
145
|
+
* Integration processes a dependency, and leaves `dist/` untouched: the build already copied the
|
|
146
|
+
* public directory and processed every asset, and the deploy may hold no sources. Any other start
|
|
147
|
+
* restores no ledger, so a source edited after the build is never served from stale outputs.
|
|
146
148
|
*/
|
|
147
149
|
startsFromCompleteDist() {
|
|
148
150
|
return this.runtimeAssetSetup === 'start' && this.requireCompleteDist && isProductionRuntime();
|
|
@@ -167,6 +169,7 @@ export class NodeServerAdapter {
|
|
|
167
169
|
if (fromCompleteDist) {
|
|
168
170
|
assertProductionDistComplete(this.appConfig.rootDir, this.appConfig.distDir);
|
|
169
171
|
requireProductionServerModules(this.appConfig);
|
|
172
|
+
await restoreProductionBrowserBuild(this.appConfig, { seal: true });
|
|
170
173
|
}
|
|
171
174
|
await setupAppRuntimePlugins({
|
|
172
175
|
appConfig: this.appConfig,
|
|
@@ -229,11 +232,11 @@ export class NodeServerAdapter {
|
|
|
229
232
|
serveOptions: {
|
|
230
233
|
hostname: String(this.serveOptions.hostname || DEFAULT_ECOPAGES_HOSTNAME),
|
|
231
234
|
port: Number(this.serveOptions.port ?? DEFAULT_ECOPAGES_PORT),
|
|
232
|
-
handleRequest: (request) => serveDistFile(request, {
|
|
235
|
+
handleRequest: async (request) => applyResponseHeaders(await serveDistFile(request, {
|
|
233
236
|
distDir: this.appConfig.absolutePaths.distDir,
|
|
234
237
|
watchMode: false,
|
|
235
238
|
resolveExportedPages: true,
|
|
236
|
-
}),
|
|
239
|
+
}), request, this.appConfig.headers),
|
|
237
240
|
},
|
|
238
241
|
allowPortFallback: this.allowPortFallback,
|
|
239
242
|
usePortManager: true,
|
|
@@ -348,10 +351,10 @@ export class NodeServerAdapter {
|
|
|
348
351
|
if (waitForReadiness) {
|
|
349
352
|
await this.requestReadiness;
|
|
350
353
|
}
|
|
351
|
-
return await this.requestPipeline.handleSharedRequest(request, context);
|
|
354
|
+
return applyResponseHeaders(await this.requestPipeline.handleSharedRequest(request, context), request, this.appConfig.headers);
|
|
352
355
|
}
|
|
353
356
|
catch (error) {
|
|
354
|
-
return await this.requestPipeline.handleUnexpectedRequestError(error, request, context);
|
|
357
|
+
return applyResponseHeaders(await this.requestPipeline.handleUnexpectedRequestError(error, request, context), request, this.appConfig.headers);
|
|
355
358
|
}
|
|
356
359
|
}
|
|
357
360
|
/**
|
|
@@ -400,8 +403,6 @@ export class NodeServerAdapter {
|
|
|
400
403
|
if (this.startsFromCompleteDist()) {
|
|
401
404
|
requireProductionServerModules(this.appConfig);
|
|
402
405
|
}
|
|
403
|
-
const { routeRendererFactory } = this.requestPipeline.getStaticBuildContext();
|
|
404
|
-
await prebuildProductionPageBrowserGraphsFromManifest(this.appConfig, routeRendererFactory);
|
|
405
406
|
}
|
|
406
407
|
attachNodeHttpWebSocketUpgrades(server, {
|
|
407
408
|
runtimeOrigin: this.runtime.origin,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type SourceRelativeStylesheetDirs } from '../../../assets/asset-processing-service/processors/stylesheet/source-relative-stylesheet.js';
|
|
2
|
+
import type { ClientBridgeEvent, IClientBridge } from '../../../types/contracts.js';
|
|
3
|
+
/**
|
|
4
|
+
* The events every client bridge sends, over the transport a subclass provides.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* An adapter's bridge implements only `broadcast` and `subscriberCount`, so the rules for each event, such as the exact
|
|
8
|
+
* href a `css-update` carries, are the same whatever the transport.
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class ClientBridge implements IClientBridge {
|
|
11
|
+
private readonly stylesheetDirs;
|
|
12
|
+
constructor(stylesheetDirs: SourceRelativeStylesheetDirs);
|
|
13
|
+
abstract broadcast(event: ClientBridgeEvent): void;
|
|
14
|
+
abstract get subscriberCount(): number;
|
|
15
|
+
reload(): void;
|
|
16
|
+
/**
|
|
17
|
+
* @remarks
|
|
18
|
+
* Sends the exact href `sourceFile` was delivered at ({@link sourceRelativeStylesheetHref}), so the browser refreshes
|
|
19
|
+
* that one link. A stylesheet with no such href, such as one outside `srcDir` written under a content hash, sends
|
|
20
|
+
* nothing.
|
|
21
|
+
*/
|
|
22
|
+
cssUpdate(sourceFile: string): void;
|
|
23
|
+
update(path: string): void;
|
|
24
|
+
error(message: string): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { sourceRelativeStylesheetHref, } from '../../../assets/asset-processing-service/processors/stylesheet/source-relative-stylesheet.js';
|
|
2
|
+
/**
|
|
3
|
+
* The events every client bridge sends, over the transport a subclass provides.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* An adapter's bridge implements only `broadcast` and `subscriberCount`, so the rules for each event, such as the exact
|
|
7
|
+
* href a `css-update` carries, are the same whatever the transport.
|
|
8
|
+
*/
|
|
9
|
+
export class ClientBridge {
|
|
10
|
+
stylesheetDirs;
|
|
11
|
+
constructor(stylesheetDirs) {
|
|
12
|
+
this.stylesheetDirs = stylesheetDirs;
|
|
13
|
+
}
|
|
14
|
+
reload() {
|
|
15
|
+
this.broadcast({ type: 'reload' });
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @remarks
|
|
19
|
+
* Sends the exact href `sourceFile` was delivered at ({@link sourceRelativeStylesheetHref}), so the browser refreshes
|
|
20
|
+
* that one link. A stylesheet with no such href, such as one outside `srcDir` written under a content hash, sends
|
|
21
|
+
* nothing.
|
|
22
|
+
*/
|
|
23
|
+
cssUpdate(sourceFile) {
|
|
24
|
+
const href = sourceRelativeStylesheetHref(this.stylesheetDirs, sourceFile);
|
|
25
|
+
if (!href)
|
|
26
|
+
return;
|
|
27
|
+
this.broadcast({ type: 'css-update', path: href, timestamp: Date.now() });
|
|
28
|
+
}
|
|
29
|
+
update(path) {
|
|
30
|
+
this.broadcast({ type: 'update', path, timestamp: Date.now() });
|
|
31
|
+
}
|
|
32
|
+
error(message) {
|
|
33
|
+
this.broadcast({ type: 'error', message });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -32,6 +32,8 @@ export declare class HmrManager implements IHmrManager {
|
|
|
32
32
|
* request the way a dev-transform failure is.
|
|
33
33
|
*/
|
|
34
34
|
private readonly fileChangeErrors;
|
|
35
|
+
/** Build errors found while answering a request, by the file that failed, until the next file change. */
|
|
36
|
+
private readonly requestBuildErrors;
|
|
35
37
|
protected readonly entrypointRegistry: DevTransformEntrypointRegistry;
|
|
36
38
|
protected readonly browserBundleService: BrowserBundleService;
|
|
37
39
|
protected readonly invalidationService: DevelopmentInvalidationService;
|
|
@@ -42,6 +44,7 @@ export declare class HmrManager implements IHmrManager {
|
|
|
42
44
|
private readonly runtimeBuilds;
|
|
43
45
|
private readonly readyRuntimes;
|
|
44
46
|
protected readonly devTransformServer: DevTransformServer;
|
|
47
|
+
private stylesheetKinds?;
|
|
45
48
|
constructor({ appConfig, bridge }: HmrManagerParams);
|
|
46
49
|
/**
|
|
47
50
|
* Reacts to a failed HMR runtime bundle.
|
|
@@ -74,7 +77,10 @@ export declare class HmrManager implements IHmrManager {
|
|
|
74
77
|
*/
|
|
75
78
|
injectDevClientRuntimes(response: Response): Promise<Response>;
|
|
76
79
|
broadcast(event: ClientBridgeEvent): void;
|
|
80
|
+
reportBuildError(source: string, message: string): void;
|
|
77
81
|
handleFileChanges(filePaths: string[], options?: HmrFileChangeOptions): Promise<void>;
|
|
82
|
+
/** The errors of the stylesheets that fail to process, which the development stylesheet service keeps. */
|
|
83
|
+
private stylesheetFailures;
|
|
78
84
|
private processFileChange;
|
|
79
85
|
/**
|
|
80
86
|
* @remarks
|
|
@@ -106,8 +112,8 @@ export declare class HmrManager implements IHmrManager {
|
|
|
106
112
|
getWatchedFiles(): Map<string, string>;
|
|
107
113
|
getRegisteredEntrypoints(): ReadonlyMap<string, ResolvedHmrEntrypoint>;
|
|
108
114
|
/**
|
|
109
|
-
* Sends a browser that just connected the build errors of modules that still fail to transpile,
|
|
110
|
-
* changed files whose last processing failed.
|
|
115
|
+
* Sends a browser that just connected the build errors of modules that still fail to transpile, of
|
|
116
|
+
* changed files whose last processing failed, and of assets a request failed to build.
|
|
111
117
|
*
|
|
112
118
|
* @remarks
|
|
113
119
|
* A build error is broadcast while the failing module is served, which can happen before the page's HMR
|
|
@@ -123,6 +129,7 @@ export declare class HmrManager implements IHmrManager {
|
|
|
123
129
|
stop(): void;
|
|
124
130
|
protected clearFailedEntrypointRegistration(entrypointPath: string): void;
|
|
125
131
|
registerEntrypoint(entrypointPath: string): Promise<string>;
|
|
132
|
+
rewriteModuleImports(code: string, importerPath: string): Promise<string>;
|
|
126
133
|
registerScriptEntrypoint(entrypointPath: string): Promise<ResolvedHmrEntrypoint>;
|
|
127
134
|
private registerDevTransformEntrypoint;
|
|
128
135
|
[Symbol.dispose](): void;
|