@ecopages/core 0.2.0-beta.3 → 0.2.0-beta.31
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 +38 -9
- package/package.json +241 -30
- package/src/adapters/README.md +6 -2
- package/src/adapters/abstract/application-adapter.d.ts +123 -6
- package/src/adapters/abstract/application-adapter.js +151 -1
- package/src/adapters/abstract/segment-path-matcher.d.ts +6 -0
- package/src/adapters/abstract/segment-path-matcher.js +149 -0
- package/src/adapters/abstract/server-adapter.d.ts +16 -2
- package/src/adapters/abstract/ws-pattern-matcher.d.ts +12 -0
- package/src/adapters/abstract/ws-pattern-matcher.js +30 -0
- package/src/adapters/bun/bun-user-websocket-lifecycle.d.ts +22 -0
- package/src/adapters/bun/bun-user-websocket-lifecycle.js +96 -0
- package/src/adapters/bun/client-bridge.d.ts +1 -0
- package/src/adapters/bun/client-bridge.js +3 -0
- package/src/adapters/bun/create-app.d.ts +9 -6
- package/src/adapters/bun/create-app.js +76 -45
- package/src/adapters/bun/hmr-manager.d.ts +1 -1
- package/src/adapters/bun/hmr-manager.js +1 -1
- package/src/adapters/bun/index.d.ts +1 -1
- package/src/adapters/bun/index.js +25 -2
- package/src/adapters/bun/runtime-host.d.ts +1 -1
- package/src/adapters/bun/runtime-host.js +1 -1
- package/src/adapters/bun/server-adapter.d.ts +92 -41
- package/src/adapters/bun/server-adapter.js +256 -117
- package/src/adapters/bun/static-preview-host.d.ts +1 -1
- package/src/adapters/bun/static-preview-host.js +25 -20
- package/src/adapters/create-app.d.ts +13 -11
- package/src/adapters/create-app.js +2 -51
- package/src/adapters/index.d.ts +2 -2
- package/src/adapters/index.js +26 -4
- package/src/adapters/node/create-app.d.ts +8 -3
- package/src/adapters/node/create-app.js +61 -13
- package/src/adapters/node/node-client-bridge.d.ts +1 -0
- package/src/adapters/node/node-client-bridge.js +3 -0
- package/src/adapters/node/node-hmr-manager.d.ts +1 -1
- package/src/adapters/node/node-hmr-manager.js +1 -1
- package/src/adapters/node/runtime-host.d.ts +1 -1
- package/src/adapters/node/runtime-host.js +1 -1
- package/src/adapters/node/server-adapter-dependencies.js +4 -0
- package/src/adapters/node/server-adapter.d.ts +64 -23
- package/src/adapters/node/server-adapter.js +169 -142
- package/src/adapters/node/static-content-server.d.ts +1 -0
- package/src/adapters/node/static-content-server.js +10 -2
- package/src/adapters/node/static-preview-host.d.ts +1 -1
- package/src/adapters/node/static-preview-host.js +27 -12
- package/src/adapters/shared/{hmr-entrypoint-registrar.d.ts → hmr/hmr-entrypoint-registrar.d.ts} +31 -30
- package/src/adapters/shared/hmr/hmr-entrypoint-registrar.js +106 -0
- package/src/adapters/shared/{hmr-html-response.d.ts → hmr/hmr-html-response.d.ts} +2 -2
- package/src/adapters/shared/{hmr-html-response.js → hmr/hmr-html-response.js} +4 -1
- package/src/adapters/shared/hmr/shared-hmr-manager.d.ts +101 -0
- package/src/adapters/shared/hmr/shared-hmr-manager.js +432 -0
- package/src/adapters/shared/http/api-request-pipeline.d.ts +23 -0
- package/src/adapters/shared/http/api-request-pipeline.js +129 -0
- package/src/adapters/shared/{api-response.d.ts → http/api-response.d.ts} +1 -1
- package/src/adapters/shared/{api-response.js → http/api-response.js} +6 -23
- package/src/adapters/shared/http/create-body-response.d.ts +12 -0
- package/src/adapters/shared/http/create-body-response.js +23 -0
- package/src/adapters/shared/http/define-api-handler.d.ts +90 -0
- package/src/adapters/shared/http/define-api-handler.js +63 -0
- package/src/adapters/shared/{explicit-static-render-preparation.d.ts → http/explicit-static-render-preparation.d.ts} +3 -3
- package/src/adapters/shared/{explicit-static-route-matcher.d.ts → http/explicit-static-route-matcher.d.ts} +3 -9
- package/src/adapters/shared/{explicit-static-route-matcher.js → http/explicit-static-route-matcher.js} +3 -38
- package/src/adapters/shared/{file-route-middleware-pipeline.d.ts → http/file-route-middleware-pipeline.d.ts} +2 -2
- package/src/adapters/shared/{file-route-middleware-pipeline.js → http/file-route-middleware-pipeline.js} +10 -22
- package/src/adapters/shared/{fs-server-response-factory.d.ts → http/fs-server-response-factory.d.ts} +7 -2
- package/src/adapters/shared/{fs-server-response-factory.js → http/fs-server-response-factory.js} +22 -2
- package/src/adapters/shared/{fs-server-response-matcher.d.ts → http/fs-server-response-matcher.d.ts} +25 -5
- package/src/adapters/shared/{fs-server-response-matcher.js → http/fs-server-response-matcher.js} +109 -27
- package/src/adapters/shared/http/run-middleware-chain.d.ts +5 -0
- package/src/adapters/shared/http/run-middleware-chain.js +17 -0
- package/src/adapters/shared/{application-adapter.d.ts → runtime/application-adapter.d.ts} +2 -2
- package/src/adapters/shared/{application-adapter.js → runtime/application-adapter.js} +1 -1
- package/src/adapters/shared/runtime/copy-runtime-public-dir.d.ts +6 -0
- package/src/adapters/shared/runtime/copy-runtime-public-dir.js +24 -0
- package/src/adapters/shared/runtime/port-manager.d.ts +116 -0
- package/src/adapters/shared/runtime/port-manager.js +196 -0
- package/src/adapters/shared/{render-context.d.ts → runtime/render-context.d.ts} +2 -2
- package/src/adapters/shared/{render-context.js → runtime/render-context.js} +8 -17
- package/src/adapters/shared/{runtime-app-bootstrap.d.ts → runtime/runtime-app-bootstrap.d.ts} +4 -3
- package/src/adapters/shared/{runtime-app-bootstrap.js → runtime/runtime-app-bootstrap.js} +4 -7
- package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +46 -0
- package/src/adapters/shared/runtime/runtime-server-lifecycle.js +57 -0
- package/src/adapters/shared/{server-adapter.d.ts → runtime/server-adapter.d.ts} +23 -49
- package/src/adapters/shared/runtime/server-adapter.js +226 -0
- package/src/adapters/shared/{server-route-handler.d.ts → runtime/server-route-handler.d.ts} +6 -33
- package/src/adapters/shared/{server-route-handler.js → runtime/server-route-handler.js} +5 -43
- package/src/adapters/shared/{server-static-builder.d.ts → runtime/server-static-builder.d.ts} +27 -35
- package/src/adapters/shared/runtime/server-static-builder.js +191 -0
- package/src/adapters/shared/{static-preview-host.d.ts → runtime/static-preview-host.d.ts} +6 -1
- package/src/adapters/shared/ws/node-http-websocket-upgrades.d.ts +21 -0
- package/src/adapters/shared/ws/node-http-websocket-upgrades.js +100 -0
- package/src/adapters/shared/ws/websocket-lifecycle.d.ts +24 -0
- package/src/adapters/shared/ws/websocket-lifecycle.js +55 -0
- package/src/build/README.md +140 -31
- package/src/build/app-build-manifest-runtime.d.ts +39 -0
- package/src/build/app-build-manifest-runtime.js +124 -0
- package/src/build/{browser-runtime-plugin.d.ts → browser/browser-runtime-plugin.d.ts} +1 -1
- package/src/build/{browser-runtime-plugin.js → browser/browser-runtime-plugin.js} +1 -1
- package/src/build/browser/jsx-ownership-plugins.d.ts +24 -0
- package/src/build/browser/jsx-ownership-plugins.js +41 -0
- package/src/build/browser/lit-static-render-worker-context.d.ts +2 -0
- package/src/build/browser/lit-static-render-worker-context.js +6 -0
- package/src/build/build-adapter.d.ts +29 -334
- package/src/build/build-adapter.js +32 -133
- package/src/build/cache/build-input-fingerprint.d.ts +28 -0
- package/src/build/cache/build-input-fingerprint.js +31 -0
- package/src/build/cache/cache-constants.d.ts +4 -0
- package/src/build/cache/cache-constants.js +6 -0
- package/src/build/cache/cache-keys.d.ts +22 -0
- package/src/build/cache/cache-keys.js +63 -0
- package/src/build/cache/dev-browser-script-cache.d.ts +34 -0
- package/src/build/cache/dev-browser-script-cache.js +90 -0
- package/src/build/cache/pages-unified-graph-build.d.ts +31 -0
- package/src/build/cache/pages-unified-graph-build.js +198 -0
- package/src/build/cache/production-build-cache.d.ts +20 -0
- package/src/build/cache/production-build-cache.js +63 -0
- package/src/build/cache/server-entry-build-cache.d.ts +43 -0
- package/src/build/cache/server-entry-build-cache.js +165 -0
- package/src/build/contracts/build-contracts.d.ts +96 -0
- package/src/build/contracts/build-manifest.d.ts +90 -0
- package/src/build/{build-manifest.js → contracts/build-manifest.js} +2 -2
- package/src/build/contracts/build-types.js +0 -0
- package/src/build/{rolldown-adapter-helpers.d.ts → rolldown/rolldown-adapter-helpers.d.ts} +23 -9
- package/src/build/{rolldown-adapter-helpers.js → rolldown/rolldown-adapter-helpers.js} +99 -13
- package/src/build/{rolldown-build-adapter.d.ts → rolldown/rolldown-build-adapter.d.ts} +3 -7
- package/src/build/{rolldown-build-adapter.js → rolldown/rolldown-build-adapter.js} +3 -3
- package/src/build/rolldown/rolldown-build-invocation-metrics.d.ts +12 -0
- package/src/build/rolldown/rolldown-build-invocation-metrics.js +43 -0
- package/src/build/{rolldown-plugin-bridge.d.ts → rolldown/rolldown-plugin-bridge.d.ts} +16 -2
- package/src/build/{rolldown-plugin-bridge.js → rolldown/rolldown-plugin-bridge.js} +21 -6
- package/src/build/rolldown/rolldown-source-transform-pass.d.ts +15 -0
- package/src/build/rolldown/rolldown-source-transform-pass.js +61 -0
- package/src/build/rolldown/runtime-build-output-normalizer.d.ts +10 -0
- package/src/build/rolldown/runtime-build-output-normalizer.js +201 -0
- package/src/build/runtime/build-profile-options.d.ts +7 -0
- package/src/build/runtime/build-profile-options.js +37 -0
- package/src/build/runtime/build-request-identity.d.ts +17 -0
- package/src/build/runtime/build-request-identity.js +54 -0
- package/src/build/runtime/build-request-policy.d.ts +59 -0
- package/src/build/runtime/build-request-policy.js +46 -0
- package/src/build/runtime/build-runtime.d.ts +28 -0
- package/src/build/runtime/build-runtime.js +65 -0
- package/src/build/runtime/deduping-build-executor.d.ts +21 -0
- package/src/build/runtime/deduping-build-executor.js +34 -0
- package/src/build/runtime/parallel-build-executor.d.ts +21 -0
- package/src/build/runtime/parallel-build-executor.js +52 -0
- package/src/build/{serialized-build-executor.d.ts → runtime/serialized-build-executor.d.ts} +1 -1
- package/src/client/navigation-scripts/classification.d.ts +16 -0
- package/src/client/navigation-scripts/classification.js +41 -0
- package/src/client/navigation-scripts/index.d.ts +3 -0
- package/src/client/navigation-scripts/index.js +23 -0
- package/src/client/navigation-scripts/navigation-scripts.test.browser.js +65 -0
- package/src/client/navigation-scripts/registry.d.ts +11 -0
- package/src/client/navigation-scripts/registry.js +12 -0
- package/src/client/navigation-scripts/rerun-queue.d.ts +37 -0
- package/src/client/navigation-scripts/rerun-queue.js +73 -0
- package/src/client/scroll.d.ts +17 -0
- package/src/client/scroll.js +25 -0
- package/src/client/scroll.test.browser.js +37 -0
- package/src/client/view-transitions.d.ts +16 -0
- package/src/client/view-transitions.js +63 -0
- package/src/config/config-builder.d.ts +25 -10
- package/src/config/config-builder.js +53 -11
- package/src/config/constants.d.ts +1 -0
- package/src/config/constants.js +2 -1
- package/src/dev/client-bridge-registry.d.ts +5 -0
- package/src/dev/client-bridge-registry.js +15 -0
- package/src/dev/dev-client-ownership.d.ts +7 -0
- package/src/dev/dev-client-ownership.js +6 -0
- package/src/dev/hmr-manager-registry.d.ts +8 -0
- package/src/dev/hmr-manager-registry.js +15 -0
- package/src/dev/host-runtime.d.ts +3 -0
- package/src/dev/host-runtime.js +7 -0
- package/src/dev/runtime-server-started-message.d.ts +2 -0
- package/src/dev/runtime-server-started-message.js +6 -0
- package/src/diagnostics/request-build-dedupe.d.ts +18 -0
- package/src/diagnostics/request-build-dedupe.js +33 -0
- package/src/diagnostics/startup-trace.d.ts +72 -0
- package/src/diagnostics/startup-trace.js +253 -0
- package/src/eco/README.md +11 -0
- package/src/eco/eco-declared-component.d.ts +14 -0
- package/src/eco/eco-declared-component.js +16 -0
- package/src/eco/eco.browser.js +5 -6
- package/src/eco/eco.js +7 -8
- package/src/eco/eco.types.d.ts +14 -3
- package/src/eco/eco.utils.d.ts +1 -1
- package/src/eco/eco.utils.js +1 -1
- package/src/eco/page-layout-normalization.d.ts +21 -0
- package/src/eco/page-layout-normalization.js +59 -0
- package/src/env.d.ts +2 -0
- package/src/errors/index.d.ts +1 -0
- package/src/errors/index.js +7 -1
- package/src/errors/undeclared-component-dependency-error.d.ts +11 -0
- package/src/errors/undeclared-component-dependency-error.js +17 -0
- package/src/hmr/client/hmr-runtime.js +7 -4
- package/src/hmr/hmr-entrypoint-output.d.ts +49 -0
- package/src/hmr/hmr-entrypoint-output.js +60 -0
- package/src/hmr/hmr-file-change-prep.d.ts +10 -0
- package/src/hmr/hmr-file-change-prep.js +17 -0
- package/src/hmr/hmr-strategy.d.ts +15 -0
- package/src/hmr/hmr-strategy.js +19 -0
- package/src/hmr/strategies/js-hmr-strategy.d.ts +3 -5
- package/src/hmr/strategies/js-hmr-strategy.js +72 -19
- package/src/hmr/strategies/server-rendered-template-hmr-strategy.d.ts +17 -0
- package/src/hmr/strategies/server-rendered-template-hmr-strategy.js +29 -0
- package/src/index.d.ts +2 -1
- package/src/index.js +28 -2
- package/src/integrations/ghtml/ghtml-renderer.d.ts +2 -6
- package/src/integrations/ghtml/ghtml-renderer.js +2 -51
- package/src/integrations/ghtml/ghtml.plugin.d.ts +3 -16
- package/src/integrations/ghtml/ghtml.plugin.js +7 -14
- package/src/plugins/alias-resolver-cache.d.ts +6 -9
- package/src/plugins/alias-resolver-plugin.d.ts +3 -3
- package/src/plugins/alias-resolver-plugin.js +38 -51
- package/src/plugins/define-integration.d.ts +26 -0
- package/src/plugins/define-integration.js +19 -0
- package/src/plugins/eco-component-meta-plugin.d.ts +1 -1
- package/src/plugins/eco-component-meta-plugin.js +5 -8
- package/src/plugins/foreign-jsx-override-plugin.d.ts +1 -1
- package/src/plugins/foreign-jsx-override-plugin.js +4 -6
- package/src/plugins/integration-plugin.d.ts +43 -14
- package/src/plugins/integration-plugin.js +18 -5
- package/src/plugins/jsx-import-source.utils.d.ts +8 -0
- package/src/plugins/jsx-import-source.utils.js +26 -0
- package/src/plugins/processor.d.ts +61 -12
- package/src/plugins/processor.js +24 -5
- package/src/plugins/source-transform.d.ts +32 -1
- package/src/plugins/source-transform.js +23 -1
- package/src/plugins/tsconfig-import-resolver.d.ts +18 -0
- package/src/plugins/tsconfig-import-resolver.js +159 -0
- package/src/route-renderer/GRAPH.md +26 -32
- package/src/route-renderer/README.md +38 -31
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +107 -0
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +148 -0
- package/src/route-renderer/orchestration/document-shell/layout-shell-props.service.d.ts +20 -0
- package/src/route-renderer/orchestration/document-shell/layout-shell-props.service.js +31 -0
- package/src/route-renderer/orchestration/{component-render-context.d.ts → foreign-child/component-render-context.d.ts} +8 -15
- package/src/route-renderer/orchestration/{component-render-context.js → foreign-child/component-render-context.js} +4 -2
- package/src/route-renderer/orchestration/{render-output.utils.d.ts → foreign-child/foreign-child-output.utils.d.ts} +17 -7
- package/src/route-renderer/orchestration/{render-output.utils.js → foreign-child/foreign-child-output.utils.js} +35 -26
- package/src/route-renderer/orchestration/{foreign-subtree-execution.service.d.ts → foreign-child/foreign-subtree-execution.service.d.ts} +64 -34
- package/src/route-renderer/orchestration/{foreign-subtree-execution.service.js → foreign-child/foreign-subtree-execution.service.js} +170 -37
- package/src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.d.ts +19 -0
- package/src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.js +35 -0
- package/src/route-renderer/orchestration/integration-renderer.d.ts +24 -143
- package/src/route-renderer/orchestration/integration-renderer.js +163 -402
- package/src/route-renderer/orchestration/integration-renderer.test-fixtures.d.ts +75 -0
- package/src/route-renderer/orchestration/integration-renderer.test-fixtures.js +177 -0
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.d.ts +10 -0
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.js +143 -0
- package/src/route-renderer/orchestration/ownership-graph/component-graph.d.ts +34 -0
- package/src/route-renderer/orchestration/ownership-graph/component-graph.js +96 -0
- package/src/route-renderer/orchestration/{ownership-validation.service.d.ts → ownership-graph/ownership-validation.service.d.ts} +7 -2
- package/src/route-renderer/orchestration/{ownership-validation.service.js → ownership-graph/ownership-validation.service.js} +30 -3
- package/src/route-renderer/orchestration/page-browser-graph/global-injector-assets.service.d.ts +7 -0
- package/src/route-renderer/orchestration/page-browser-graph/global-injector-assets.service.js +32 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-contribution.loader.d.ts +9 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-contribution.loader.js +7 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.d.ts +12 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.js +29 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +106 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +436 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.d.ts +31 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +229 -0
- package/src/route-renderer/orchestration/{processed-asset-dedupe.d.ts → page-browser-graph/processed-asset-dedupe.d.ts} +1 -1
- package/src/route-renderer/orchestration/route-pipeline/integration-route-render-adapter.d.ts +31 -0
- package/src/route-renderer/orchestration/route-pipeline/integration-route-render-adapter.js +25 -0
- package/src/route-renderer/orchestration/route-pipeline/marker-artifact.utils.d.ts +6 -0
- package/src/route-renderer/orchestration/route-pipeline/marker-artifact.utils.js +27 -0
- package/src/route-renderer/orchestration/route-pipeline/robots-meta.contribution.d.ts +15 -0
- package/src/route-renderer/orchestration/route-pipeline/robots-meta.contribution.js +36 -0
- package/src/route-renderer/orchestration/route-pipeline/route-html-finalization.service.d.ts +20 -0
- package/src/route-renderer/orchestration/route-pipeline/route-html-finalization.service.js +24 -0
- package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.builder.d.ts +25 -0
- package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.builder.js +49 -0
- package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.utils.d.ts +4 -0
- package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.utils.js +33 -0
- package/src/route-renderer/orchestration/{route-render-orchestrator.d.ts → route-pipeline/route-render-orchestrator.d.ts} +13 -53
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +162 -0
- package/src/route-renderer/orchestration/string-markup-renderer.d.ts +14 -0
- package/src/route-renderer/orchestration/string-markup-renderer.js +55 -0
- package/src/route-renderer/page-loading/component-dependency-collection.js +5 -2
- package/src/route-renderer/page-loading/ecopages-virtual-imports.d.ts +6 -0
- package/src/route-renderer/page-loading/ecopages-virtual-imports.js +7 -2
- package/src/route-renderer/page-loading/module-declaration-aggregation.js +4 -0
- package/src/router/client/link-intent.d.ts +11 -21
- package/src/router/client/link-intent.js +10 -0
- package/src/router/client/link-intent.test.browser.js +12 -1
- package/src/router/client/link-navigation-policy.d.ts +45 -0
- package/src/router/client/link-navigation-policy.js +101 -0
- package/src/router/client/link-navigation-policy.test.browser.d.ts +1 -0
- package/src/router/client/link-navigation-policy.test.browser.js +92 -0
- package/src/router/client/navigation-coordinator.d.ts +1 -1
- package/src/router/client/navigation-coordinator.js +12 -2
- package/src/services/assets/asset-processing-service/asset-dependency-keys.d.ts +13 -0
- package/src/services/assets/asset-processing-service/asset-dependency-keys.js +3 -0
- package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +6 -1
- package/src/services/assets/asset-processing-service/asset-processing.service.js +44 -5
- package/src/services/assets/asset-processing-service/assets.types.d.ts +1 -1
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +2 -1
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +1 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.d.ts +52 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.js +78 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +4 -2
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +28 -13
- package/src/services/assets/asset-processing-service/finalize-processed-asset.d.ts +3 -0
- package/src/services/assets/asset-processing-service/finalize-processed-asset.js +7 -0
- package/src/services/assets/asset-processing-service/grouped-content-bundles.d.ts +2 -1
- package/src/services/assets/asset-processing-service/grouped-content-bundles.js +38 -12
- package/src/services/assets/asset-processing-service/index.d.ts +2 -0
- package/src/services/assets/asset-processing-service/index.js +2 -0
- package/src/services/assets/asset-processing-service/inline-content-script-body.d.ts +11 -0
- package/src/services/assets/asset-processing-service/inline-content-script-body.js +17 -0
- package/src/services/assets/asset-processing-service/materialize-content-script-asset.d.ts +9 -0
- package/src/services/assets/asset-processing-service/materialize-content-script-asset.js +18 -0
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +0 -2
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +2 -15
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +8 -0
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +73 -68
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +0 -1
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +18 -15
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +17 -3
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +0 -3
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +2 -31
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +0 -3
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +2 -30
- package/src/services/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.d.ts +2 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.js +43 -0
- package/src/services/assets/asset-processing-service/resolve-integration-plugin.d.ts +4 -0
- package/src/services/assets/asset-processing-service/resolve-integration-plugin.js +17 -0
- package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.d.ts +0 -1
- package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.js +5 -10
- package/src/services/assets/browser-bundle.service.d.ts +28 -30
- package/src/services/assets/browser-bundle.service.js +28 -19
- package/src/services/html/html-transformer.service.d.ts +1 -1
- package/src/services/html/html-transformer.service.js +5 -5
- package/src/services/invalidation/development-invalidation.service.d.ts +25 -2
- package/src/services/invalidation/development-invalidation.service.js +64 -11
- package/src/services/module-loading/README.md +49 -0
- package/src/services/module-loading/app-server-module-transpiler.service.d.ts +8 -0
- package/src/services/module-loading/app-server-module-transpiler.service.js +3 -21
- package/src/services/module-loading/page-module-import.service.d.ts +6 -2
- package/src/services/module-loading/page-module-import.service.js +110 -47
- package/src/services/module-loading/route-module-build-cache-registry.d.ts +24 -0
- package/src/services/module-loading/route-module-build-cache-registry.js +37 -0
- package/src/services/module-loading/route-module-build-cache.d.ts +4 -0
- package/src/services/module-loading/route-module-build-cache.js +38 -0
- package/src/services/module-loading/route-module-build-cache.store.d.ts +57 -0
- package/src/services/module-loading/route-module-build-cache.store.js +207 -0
- package/src/services/module-loading/route-module-build-manifest.d.ts +54 -0
- package/src/services/module-loading/route-module-build-manifest.js +85 -0
- package/src/services/module-loading/route-module-dependency-hasher.d.ts +81 -0
- package/src/services/module-loading/route-module-dependency-hasher.js +122 -0
- package/src/services/module-loading/server-module-transpiler.service.d.ts +1 -1
- package/src/services/module-loading/server-module-transpiler.service.js +1 -1
- package/src/services/validation/schema-validation-service.d.ts +1 -4
- package/src/services/validation/schema-validation-service.js +12 -13
- package/src/services/validation/standard-schema.types.d.ts +9 -62
- package/src/services/validation/validate-standard-schema.d.ts +7 -0
- package/src/services/validation/validate-standard-schema.js +14 -0
- package/src/static-site-generator/README.md +41 -0
- package/src/static-site-generator/production-page-browser-graph-prebuild.d.ts +28 -0
- package/src/static-site-generator/production-page-browser-graph-prebuild.js +22 -0
- package/src/static-site-generator/sitemap-routes.d.ts +14 -0
- package/src/static-site-generator/sitemap-routes.js +31 -0
- package/src/static-site-generator/sitemap.d.ts +15 -0
- package/src/static-site-generator/sitemap.js +33 -0
- package/src/static-site-generator/static-build-invalidation.d.ts +10 -0
- package/src/static-site-generator/static-build-invalidation.js +59 -0
- package/src/static-site-generator/static-export-context.d.ts +30 -0
- package/src/static-site-generator/static-export-context.js +0 -0
- package/src/static-site-generator/static-site-generator.d.ts +43 -25
- package/src/static-site-generator/static-site-generator.js +381 -106
- package/src/types/internal-types.d.ts +39 -13
- package/src/types/public-types.d.ts +289 -52
- package/src/utils/ecopages-route-info.d.ts +26 -0
- package/src/utils/ecopages-route-info.js +26 -0
- package/src/utils/html-escaping.d.ts +7 -0
- package/src/utils/html-escaping.js +5 -1
- package/src/utils/parse-cli-args.d.ts +2 -0
- package/src/utils/parse-cli-args.js +6 -0
- package/src/utils/path-pattern.d.ts +23 -0
- package/src/utils/path-pattern.js +27 -0
- package/src/utils/server-utils.module.d.ts +3 -2
- package/src/utils/server-utils.module.js +5 -6
- package/src/utils/static-file-extensions.d.ts +12 -0
- package/src/utils/static-file-extensions.js +48 -0
- package/src/watchers/project-watcher-ignore.d.ts +11 -0
- package/src/watchers/project-watcher-ignore.js +16 -0
- package/src/watchers/project-watcher.d.ts +29 -6
- package/src/watchers/project-watcher.js +146 -34
- package/src/watchers/project-watcher.test-helpers.js +5 -5
- package/src/adapters/shared/define-api-handler.d.ts +0 -25
- package/src/adapters/shared/define-api-handler.js +0 -15
- package/src/adapters/shared/hmr-entrypoint-registrar.js +0 -87
- package/src/adapters/shared/server-adapter.js +0 -436
- package/src/adapters/shared/server-static-builder.js +0 -162
- package/src/adapters/shared/shared-hmr-manager.d.ts +0 -59
- package/src/adapters/shared/shared-hmr-manager.js +0 -241
- package/src/build/build-manifest.d.ts +0 -33
- package/src/build/rolldown-dev-build-adapter.d.ts +0 -82
- package/src/build/rolldown-dev-build-adapter.js +0 -166
- package/src/build/runtime-build-executor.d.ts +0 -21
- package/src/build/runtime-build-executor.js +0 -19
- package/src/build/runtime-build-output-normalizer.d.ts +0 -3
- package/src/build/runtime-build-output-normalizer.js +0 -111
- package/src/hmr/hmr.postcss.test.e2e.js +0 -31
- package/src/hmr/hmr.test.e2e.js +0 -43
- package/src/route-renderer/orchestration/declared-ownership-graph.d.ts +0 -18
- package/src/route-renderer/orchestration/declared-ownership-graph.js +0 -34
- package/src/route-renderer/orchestration/ownership-planning.service.d.ts +0 -24
- package/src/route-renderer/orchestration/ownership-planning.service.js +0 -63
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.d.ts +0 -91
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.js +0 -170
- package/src/route-renderer/orchestration/route-render-orchestrator.js +0 -577
- package/src/route-renderer/orchestration/template-serialization.d.ts +0 -38
- package/src/route-renderer/orchestration/template-serialization.js +0 -45
- /package/src/adapters/shared/{explicit-static-render-preparation.js → http/explicit-static-render-preparation.js} +0 -0
- /package/src/adapters/shared/{runtime-host.d.ts → runtime/runtime-host.d.ts} +0 -0
- /package/src/adapters/shared/{runtime-host.js → runtime/runtime-host.js} +0 -0
- /package/src/adapters/shared/{static-preview-host.js → runtime/static-preview-host.js} +0 -0
- /package/src/build/{browser-runtime-manifest.d.ts → browser/browser-runtime-manifest.d.ts} +0 -0
- /package/src/build/{browser-runtime-manifest.js → browser/browser-runtime-manifest.js} +0 -0
- /package/src/build/{browser-runtime-plugin-helpers.d.ts → browser/browser-runtime-plugin-helpers.d.ts} +0 -0
- /package/src/build/{browser-runtime-plugin-helpers.js → browser/browser-runtime-plugin-helpers.js} +0 -0
- /package/src/build/{build-types.js → contracts/build-contracts.js} +0 -0
- /package/src/build/{build-types.d.ts → contracts/build-types.d.ts} +0 -0
- /package/src/build/{server-side-css-shim-plugin.d.ts → rolldown/server-side-css-shim-plugin.d.ts} +0 -0
- /package/src/build/{server-side-css-shim-plugin.js → rolldown/server-side-css-shim-plugin.js} +0 -0
- /package/src/build/{serialized-build-executor.js → runtime/serialized-build-executor.js} +0 -0
- /package/src/{hmr/hmr.postcss.test.e2e.d.ts → client/navigation-scripts/navigation-scripts.test.browser.d.ts} +0 -0
- /package/src/{hmr/hmr.test.e2e.d.ts → client/scroll.test.browser.d.ts} +0 -0
- /package/src/route-renderer/orchestration/{processed-asset-dedupe.js → page-browser-graph/processed-asset-dedupe.js} +0 -0
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { fileSystem } from "@ecopages/file-system";
|
|
3
|
-
import { DEFAULT_ECOPAGES_HOSTNAME, DEFAULT_ECOPAGES_PORT } from "../../config/constants.js";
|
|
4
|
-
import { StaticContentServer } from "../../dev/sc-server.js";
|
|
5
|
-
import { appLogger } from "../../global/app-logger.js";
|
|
6
|
-
import { getAppBuildAdapter } from "../../build/build-adapter.js";
|
|
7
|
-
import { resolveEntryFile, SERVER_BUNDLE_DIR, SERVER_BUNDLE_FILENAME } from "../../utils/resolve-entry-file.js";
|
|
8
|
-
class ServerStaticBuilder {
|
|
9
|
-
appConfig;
|
|
10
|
-
staticSiteGenerator;
|
|
11
|
-
serveOptions;
|
|
12
|
-
apiHandlers;
|
|
13
|
-
logger;
|
|
14
|
-
previewServerFactory;
|
|
15
|
-
entryFile;
|
|
16
|
-
constructor({
|
|
17
|
-
appConfig,
|
|
18
|
-
staticSiteGenerator,
|
|
19
|
-
serveOptions,
|
|
20
|
-
apiHandlers,
|
|
21
|
-
logger,
|
|
22
|
-
previewServerFactory,
|
|
23
|
-
entryFile
|
|
24
|
-
}) {
|
|
25
|
-
this.appConfig = appConfig;
|
|
26
|
-
this.staticSiteGenerator = staticSiteGenerator;
|
|
27
|
-
this.serveOptions = serveOptions;
|
|
28
|
-
this.apiHandlers = apiHandlers ?? [];
|
|
29
|
-
this.logger = logger ?? appLogger;
|
|
30
|
-
this.previewServerFactory = previewServerFactory ?? StaticContentServer;
|
|
31
|
-
this.entryFile = resolveEntryFile({ entryFile });
|
|
32
|
-
}
|
|
33
|
-
warnApiHandlersUnavailableInStaticMode() {
|
|
34
|
-
if (this.apiHandlers.length === 0) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const uniqueHandlers = Array.from(
|
|
38
|
-
new Set(this.apiHandlers.map((handler) => `${handler.method} ${handler.path}`))
|
|
39
|
-
);
|
|
40
|
-
const visibleHandlers = uniqueHandlers.slice(0, 5).join(", ");
|
|
41
|
-
const remainingCount = uniqueHandlers.length - Math.min(uniqueHandlers.length, 5);
|
|
42
|
-
const summary = remainingCount > 0 ? `${visibleHandlers}, +${remainingCount} more` : visibleHandlers;
|
|
43
|
-
this.logger.warn(
|
|
44
|
-
"Registered API endpoints are not available in static build or preview modes because no server runtime is started. They are excluded from the generated output.\n",
|
|
45
|
-
`\u27A4 ${summary}`
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
prepareExportDirectory() {
|
|
49
|
-
const exportDir = this.appConfig.absolutePaths?.distDir ?? path.join(this.appConfig.rootDir, this.appConfig.distDir);
|
|
50
|
-
fileSystem.ensureDir(exportDir, true);
|
|
51
|
-
const srcPublicDir = path.join(
|
|
52
|
-
this.appConfig.rootDir,
|
|
53
|
-
this.appConfig.srcDir ?? "src",
|
|
54
|
-
this.appConfig.publicDir ?? "public"
|
|
55
|
-
);
|
|
56
|
-
if (fileSystem.exists(srcPublicDir)) {
|
|
57
|
-
fileSystem.copyDir(srcPublicDir, exportDir);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
async refreshRuntimeAssets() {
|
|
61
|
-
for (const processor of this.appConfig.processors.values()) {
|
|
62
|
-
await processor.setup();
|
|
63
|
-
}
|
|
64
|
-
for (const integration of this.appConfig.integrations) {
|
|
65
|
-
await integration.setup();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Bundles the server entry file for production use.
|
|
70
|
-
*
|
|
71
|
-
* @remarks
|
|
72
|
-
* When the project has API endpoints, the entry file must be bundled
|
|
73
|
-
* into a single JS file so the production server can start without
|
|
74
|
-
* on-the-fly TypeScript transpilation. The bundle is output to
|
|
75
|
-
* `dist/{SERVER_BUNDLE_DIR}/{SERVER_BUNDLE_FILENAME}` and used by
|
|
76
|
-
* `ecopages start` in production.
|
|
77
|
-
*
|
|
78
|
-
* Package imports remain external so native addons and runtime-owned
|
|
79
|
-
* dependencies continue to load through the app's installed
|
|
80
|
-
* `node_modules` tree. Only the app entry graph is bundled.
|
|
81
|
-
*
|
|
82
|
-
* Skips silently when no API endpoints are registered (static-only site).
|
|
83
|
-
* Throws if the build adapter is unavailable, is owned by a host
|
|
84
|
-
* runtime, or bundling fails.
|
|
85
|
-
*
|
|
86
|
-
* @throws If the build adapter is unavailable, is host-owned, or bundling fails.
|
|
87
|
-
*/
|
|
88
|
-
async bundleServerEntry() {
|
|
89
|
-
if (this.apiHandlers.length === 0) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const buildAdapter = getAppBuildAdapter(this.appConfig);
|
|
93
|
-
if (buildAdapter.ownership === "vite-host") {
|
|
94
|
-
throw new Error(
|
|
95
|
-
'Cannot bundle the server entry file: build ownership is "vite-host". The host runtime is expected to produce its own server bundle.'
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
const entryPath = path.isAbsolute(this.entryFile) ? this.entryFile : path.join(this.appConfig.rootDir, this.entryFile);
|
|
99
|
-
if (!fileSystem.exists(entryPath)) {
|
|
100
|
-
throw new Error(
|
|
101
|
-
`Cannot bundle server entry: file "${this.entryFile}" not found in "${this.appConfig.rootDir}".`
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
const distDir = this.appConfig.absolutePaths?.distDir ?? path.join(this.appConfig.rootDir, this.appConfig.distDir);
|
|
105
|
-
const serverOutdir = path.join(distDir, SERVER_BUNDLE_DIR);
|
|
106
|
-
this.logger.info("Bundling server entry file...");
|
|
107
|
-
const result = await buildAdapter.build({
|
|
108
|
-
entrypoints: [entryPath],
|
|
109
|
-
outdir: serverOutdir,
|
|
110
|
-
naming: SERVER_BUNDLE_FILENAME,
|
|
111
|
-
target: "node",
|
|
112
|
-
format: "esm",
|
|
113
|
-
sourcemap: "hidden",
|
|
114
|
-
externalPackages: true,
|
|
115
|
-
root: this.appConfig.rootDir
|
|
116
|
-
});
|
|
117
|
-
if (!result.success) {
|
|
118
|
-
const errorMessages = result.logs.map((log) => log.message).join("\n");
|
|
119
|
-
throw new Error(`Failed to bundle server entry file:
|
|
120
|
-
${errorMessages}`);
|
|
121
|
-
}
|
|
122
|
-
this.logger.info("Server entry file bundled successfully");
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Generates a static build of the site for deployment.
|
|
126
|
-
* @param options.preview - If true, starts a preview server after build
|
|
127
|
-
* @param dependencies.router - The initialized router
|
|
128
|
-
* @param dependencies.routeRendererFactory - The route renderer factory
|
|
129
|
-
* @param dependencies.staticRoutes - Explicit static routes registered via app.static()
|
|
130
|
-
*/
|
|
131
|
-
async build(options, dependencies) {
|
|
132
|
-
const { preview = false, baseUrl: explicitBaseUrl } = options ?? {};
|
|
133
|
-
const baseUrl = explicitBaseUrl ?? `http://${this.serveOptions.hostname || DEFAULT_ECOPAGES_HOSTNAME}:${this.serveOptions.port || DEFAULT_ECOPAGES_PORT}`;
|
|
134
|
-
this.warnApiHandlersUnavailableInStaticMode();
|
|
135
|
-
this.prepareExportDirectory();
|
|
136
|
-
await this.refreshRuntimeAssets();
|
|
137
|
-
await this.bundleServerEntry();
|
|
138
|
-
await this.staticSiteGenerator.run({
|
|
139
|
-
router: dependencies.router,
|
|
140
|
-
baseUrl,
|
|
141
|
-
routeRendererFactory: dependencies.routeRendererFactory,
|
|
142
|
-
staticRoutes: dependencies.staticRoutes
|
|
143
|
-
});
|
|
144
|
-
if (!preview) {
|
|
145
|
-
this.logger.info("Build completed");
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const previewPort = this.serveOptions.port || DEFAULT_ECOPAGES_PORT;
|
|
149
|
-
const { server } = this.previewServerFactory.createServer({
|
|
150
|
-
appConfig: this.appConfig,
|
|
151
|
-
options: { port: Number(previewPort) }
|
|
152
|
-
});
|
|
153
|
-
if (server?.port) {
|
|
154
|
-
this.logger.info(`Preview running at http://localhost:${server.port}`);
|
|
155
|
-
} else {
|
|
156
|
-
this.logger.error("Failed to start preview server");
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
export {
|
|
161
|
-
ServerStaticBuilder
|
|
162
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import type { DefaultHmrContext, EcoPagesAppConfig, IHmrManager, IClientBridge } from '../../types/internal-types.js';
|
|
3
|
-
import type { EcoBuildPlugin } from '../../build/build-types.js';
|
|
4
|
-
import { type HmrStrategy } from '../../hmr/hmr-strategy.js';
|
|
5
|
-
import type { ClientBridgeEvent } from '../../types/public-types.js';
|
|
6
|
-
import { HmrEntrypointRegistrar } from './hmr-entrypoint-registrar.js';
|
|
7
|
-
import { BrowserBundleService } from '../../services/assets/browser-bundle.service.js';
|
|
8
|
-
import { type EntrypointDependencyGraph } from '../../services/runtime-state/entrypoint-dependency-graph.service.js';
|
|
9
|
-
import type { ServerModuleTranspiler } from '../../services/module-loading/server-module-transpiler.service.js';
|
|
10
|
-
type HandleFileChangeOptions = {
|
|
11
|
-
broadcast?: boolean;
|
|
12
|
-
};
|
|
13
|
-
type SharedHmrManagerParams = {
|
|
14
|
-
appConfig: EcoPagesAppConfig;
|
|
15
|
-
bridge: IClientBridge;
|
|
16
|
-
registrationTimeoutMs?: number;
|
|
17
|
-
};
|
|
18
|
-
export declare abstract class SharedHmrManager implements IHmrManager {
|
|
19
|
-
readonly appConfig: EcoPagesAppConfig;
|
|
20
|
-
protected readonly bridge: IClientBridge;
|
|
21
|
-
protected watchers: Map<string, fs.FSWatcher>;
|
|
22
|
-
protected watchedFiles: Map<string, string>;
|
|
23
|
-
protected entrypointRegistrations: Map<string, Promise<string>>;
|
|
24
|
-
protected distDir: string;
|
|
25
|
-
protected plugins: EcoBuildPlugin[];
|
|
26
|
-
protected enabled: boolean;
|
|
27
|
-
protected strategies: HmrStrategy[];
|
|
28
|
-
protected readonly entrypointRegistrar: HmrEntrypointRegistrar;
|
|
29
|
-
protected readonly browserBundleService: BrowserBundleService;
|
|
30
|
-
protected readonly entrypointDependencyGraph: EntrypointDependencyGraph;
|
|
31
|
-
protected readonly serverModuleTranspiler: ServerModuleTranspiler;
|
|
32
|
-
constructor({ appConfig, bridge, registrationTimeoutMs }: SharedHmrManagerParams);
|
|
33
|
-
protected abstract createEntrypointDependencyGraph(existingEntrypointDependencyGraph: EntrypointDependencyGraph): EntrypointDependencyGraph;
|
|
34
|
-
protected shouldSkipMissingFileChange(_filePath: string): boolean;
|
|
35
|
-
protected onRuntimeBundleFailure(error: unknown): void;
|
|
36
|
-
protected ensureDistDir(): void;
|
|
37
|
-
protected shouldJsStrategyProcessEntrypoint(entrypointPath: string): boolean;
|
|
38
|
-
protected initializeStrategies(): void;
|
|
39
|
-
registerStrategy(strategy: HmrStrategy): void;
|
|
40
|
-
setPlugins(plugins: EcoBuildPlugin[]): void;
|
|
41
|
-
setEnabled(enabled: boolean): void;
|
|
42
|
-
isEnabled(): boolean;
|
|
43
|
-
buildRuntime(): Promise<void>;
|
|
44
|
-
getRuntimePath(): string;
|
|
45
|
-
broadcast(event: ClientBridgeEvent): void;
|
|
46
|
-
handleFileChange(filePath: string, options?: HandleFileChangeOptions): Promise<void>;
|
|
47
|
-
getOutputUrl(entrypointPath: string): string | undefined;
|
|
48
|
-
getWatchedFiles(): Map<string, string>;
|
|
49
|
-
getDistDir(): string;
|
|
50
|
-
getPlugins(): EcoBuildPlugin[];
|
|
51
|
-
getDefaultContext(): DefaultHmrContext;
|
|
52
|
-
protected clearFailedEntrypointRegistration(entrypointPath: string): void;
|
|
53
|
-
registerEntrypoint(entrypointPath: string): Promise<string>;
|
|
54
|
-
registerScriptEntrypoint(entrypointPath: string): Promise<string>;
|
|
55
|
-
protected emitStrictEntrypoint(entrypointPath: string): Promise<void>;
|
|
56
|
-
protected emitScriptEntrypoint(entrypointPath: string, outputPath: string): Promise<void>;
|
|
57
|
-
stop(): void;
|
|
58
|
-
}
|
|
59
|
-
export {};
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { RESOLVED_ASSETS_DIR } from "../../config/constants.js";
|
|
5
|
-
import { getAppBuildExecutor } from "../../build/build-adapter.js";
|
|
6
|
-
import { fileSystem } from "@ecopages/file-system";
|
|
7
|
-
import { HmrStrategyType } from "../../hmr/hmr-strategy.js";
|
|
8
|
-
import { DefaultHmrStrategy } from "../../hmr/strategies/default-hmr-strategy.js";
|
|
9
|
-
import { JsHmrStrategy } from "../../hmr/strategies/js-hmr-strategy.js";
|
|
10
|
-
import { appLogger } from "../../global/app-logger.js";
|
|
11
|
-
import { HmrEntrypointRegistrar } from "./hmr-entrypoint-registrar.js";
|
|
12
|
-
import { BrowserBundleService } from "../../services/assets/browser-bundle.service.js";
|
|
13
|
-
import { getAppServerModuleTranspiler } from "../../services/module-loading/app-server-module-transpiler.service.js";
|
|
14
|
-
import {
|
|
15
|
-
getAppEntrypointDependencyGraph,
|
|
16
|
-
setAppEntrypointDependencyGraph
|
|
17
|
-
} from "../../services/runtime-state/entrypoint-dependency-graph.service.js";
|
|
18
|
-
import { resolveInternalExecutionDir, resolveInternalWorkDir } from "../../utils/resolve-work-dir.js";
|
|
19
|
-
class SharedHmrManager {
|
|
20
|
-
appConfig;
|
|
21
|
-
bridge;
|
|
22
|
-
watchers = /* @__PURE__ */ new Map();
|
|
23
|
-
watchedFiles = /* @__PURE__ */ new Map();
|
|
24
|
-
entrypointRegistrations = /* @__PURE__ */ new Map();
|
|
25
|
-
distDir;
|
|
26
|
-
plugins = [];
|
|
27
|
-
enabled = true;
|
|
28
|
-
strategies = [];
|
|
29
|
-
entrypointRegistrar;
|
|
30
|
-
browserBundleService;
|
|
31
|
-
entrypointDependencyGraph;
|
|
32
|
-
serverModuleTranspiler;
|
|
33
|
-
constructor({ appConfig, bridge, registrationTimeoutMs = 4e3 }) {
|
|
34
|
-
this.appConfig = appConfig;
|
|
35
|
-
this.bridge = bridge;
|
|
36
|
-
this.distDir = path.join(resolveInternalWorkDir(this.appConfig), RESOLVED_ASSETS_DIR, "_hmr");
|
|
37
|
-
this.entrypointRegistrar = new HmrEntrypointRegistrar({
|
|
38
|
-
srcDir: this.appConfig.absolutePaths.srcDir,
|
|
39
|
-
distDir: this.distDir,
|
|
40
|
-
entrypointRegistrations: this.entrypointRegistrations,
|
|
41
|
-
watchedFiles: this.watchedFiles,
|
|
42
|
-
clearFailedRegistration: (entrypointPath) => this.clearFailedEntrypointRegistration(entrypointPath),
|
|
43
|
-
registrationTimeoutMs
|
|
44
|
-
});
|
|
45
|
-
this.browserBundleService = new BrowserBundleService(appConfig);
|
|
46
|
-
this.entrypointDependencyGraph = this.createEntrypointDependencyGraph(
|
|
47
|
-
getAppEntrypointDependencyGraph(appConfig)
|
|
48
|
-
);
|
|
49
|
-
setAppEntrypointDependencyGraph(this.appConfig, this.entrypointDependencyGraph);
|
|
50
|
-
this.serverModuleTranspiler = getAppServerModuleTranspiler(this.appConfig);
|
|
51
|
-
this.ensureDistDir();
|
|
52
|
-
this.initializeStrategies();
|
|
53
|
-
}
|
|
54
|
-
shouldSkipMissingFileChange(_filePath) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
onRuntimeBundleFailure(error) {
|
|
58
|
-
appLogger.error("[HMR] Failed to build runtime script:", error);
|
|
59
|
-
}
|
|
60
|
-
ensureDistDir() {
|
|
61
|
-
fileSystem.ensureDir(this.distDir);
|
|
62
|
-
}
|
|
63
|
-
shouldJsStrategyProcessEntrypoint(entrypointPath) {
|
|
64
|
-
return !this.strategies.some((strategy) => {
|
|
65
|
-
if (strategy.type !== HmrStrategyType.INTEGRATION || strategy.priority <= HmrStrategyType.SCRIPT) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
try {
|
|
69
|
-
return strategy.matches(entrypointPath);
|
|
70
|
-
} catch (error) {
|
|
71
|
-
appLogger.error(error);
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
initializeStrategies() {
|
|
77
|
-
const jsContext = {
|
|
78
|
-
getWatchedFiles: () => this.watchedFiles,
|
|
79
|
-
getDistDir: () => this.distDir,
|
|
80
|
-
getPlugins: () => this.plugins,
|
|
81
|
-
getSrcDir: () => this.appConfig.absolutePaths.srcDir,
|
|
82
|
-
getPagesDir: () => this.appConfig.absolutePaths.pagesDir,
|
|
83
|
-
getLayoutsDir: () => this.appConfig.absolutePaths.layoutsDir,
|
|
84
|
-
getTemplateExtensions: () => this.appConfig.templatesExt,
|
|
85
|
-
getBrowserBundleService: () => this.browserBundleService,
|
|
86
|
-
getEntrypointDependencyGraph: () => this.entrypointDependencyGraph,
|
|
87
|
-
shouldProcessEntrypoint: (entrypointPath) => this.shouldJsStrategyProcessEntrypoint(entrypointPath)
|
|
88
|
-
};
|
|
89
|
-
this.strategies = [new JsHmrStrategy(jsContext), new DefaultHmrStrategy()];
|
|
90
|
-
}
|
|
91
|
-
registerStrategy(strategy) {
|
|
92
|
-
this.strategies.push(strategy);
|
|
93
|
-
}
|
|
94
|
-
setPlugins(plugins) {
|
|
95
|
-
this.plugins = [...plugins];
|
|
96
|
-
}
|
|
97
|
-
setEnabled(enabled) {
|
|
98
|
-
this.enabled = enabled;
|
|
99
|
-
}
|
|
100
|
-
isEnabled() {
|
|
101
|
-
return this.enabled;
|
|
102
|
-
}
|
|
103
|
-
async buildRuntime() {
|
|
104
|
-
const runtimeSource = fileURLToPath(import.meta.resolve("@ecopages/core/hmr/client/hmr-runtime"));
|
|
105
|
-
try {
|
|
106
|
-
const result = await this.browserBundleService.bundle({
|
|
107
|
-
profile: "hmr-runtime",
|
|
108
|
-
entrypoints: [runtimeSource],
|
|
109
|
-
outdir: this.distDir,
|
|
110
|
-
naming: "_hmr_runtime.js",
|
|
111
|
-
minify: false,
|
|
112
|
-
plugins: this.plugins
|
|
113
|
-
});
|
|
114
|
-
if (!result.success) {
|
|
115
|
-
this.onRuntimeBundleFailure(result.logs);
|
|
116
|
-
}
|
|
117
|
-
} catch (error) {
|
|
118
|
-
this.onRuntimeBundleFailure(error);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
getRuntimePath() {
|
|
122
|
-
return path.join(this.distDir, "_hmr_runtime.js");
|
|
123
|
-
}
|
|
124
|
-
broadcast(event) {
|
|
125
|
-
appLogger.debug(
|
|
126
|
-
`[HMR] Broadcasting ${event.type} event, path=${event.path || "all"}, subscribers=${this.bridge.subscriberCount}`
|
|
127
|
-
);
|
|
128
|
-
this.bridge.broadcast(event);
|
|
129
|
-
}
|
|
130
|
-
async handleFileChange(filePath, options = {}) {
|
|
131
|
-
if (this.shouldSkipMissingFileChange(filePath) && !fileSystem.exists(filePath)) {
|
|
132
|
-
appLogger.debug(`[${this.constructor.name}] Skipping missing file change: ${filePath}`);
|
|
133
|
-
this.clearFailedEntrypointRegistration(filePath);
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
const sorted = [...this.strategies].sort((a, b) => b.priority - a.priority);
|
|
137
|
-
const strategy = sorted.find((candidate) => {
|
|
138
|
-
try {
|
|
139
|
-
return candidate.matches(filePath);
|
|
140
|
-
} catch (error) {
|
|
141
|
-
appLogger.error(error);
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
if (!strategy) {
|
|
146
|
-
appLogger.warn(`[HMR] No strategy found for ${filePath}`);
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
appLogger.debug(`[${this.constructor.name}] Selected strategy: ${strategy.constructor.name}`);
|
|
150
|
-
const action = await strategy.process(filePath);
|
|
151
|
-
const shouldBroadcast = options.broadcast ?? true;
|
|
152
|
-
if (shouldBroadcast && action.type === "broadcast" && action.events) {
|
|
153
|
-
for (const event of action.events) {
|
|
154
|
-
this.broadcast(event);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
getOutputUrl(entrypointPath) {
|
|
159
|
-
return this.watchedFiles.get(entrypointPath);
|
|
160
|
-
}
|
|
161
|
-
getWatchedFiles() {
|
|
162
|
-
return this.watchedFiles;
|
|
163
|
-
}
|
|
164
|
-
getDistDir() {
|
|
165
|
-
return this.distDir;
|
|
166
|
-
}
|
|
167
|
-
getPlugins() {
|
|
168
|
-
return this.plugins;
|
|
169
|
-
}
|
|
170
|
-
getDefaultContext() {
|
|
171
|
-
return {
|
|
172
|
-
getWatchedFiles: () => this.watchedFiles,
|
|
173
|
-
getDistDir: () => this.distDir,
|
|
174
|
-
getPlugins: () => this.plugins,
|
|
175
|
-
getSrcDir: () => this.appConfig.absolutePaths.srcDir,
|
|
176
|
-
getLayoutsDir: () => this.appConfig.absolutePaths.layoutsDir,
|
|
177
|
-
getPagesDir: () => this.appConfig.absolutePaths.pagesDir,
|
|
178
|
-
getBuildExecutor: () => getAppBuildExecutor(this.appConfig),
|
|
179
|
-
getBrowserBundleService: () => this.browserBundleService,
|
|
180
|
-
getEntrypointDependencyGraph: () => this.entrypointDependencyGraph,
|
|
181
|
-
importServerModule: async (filePath) => await this.serverModuleTranspiler.importModule({
|
|
182
|
-
filePath,
|
|
183
|
-
outdir: path.join(resolveInternalExecutionDir(this.appConfig), ".server-modules"),
|
|
184
|
-
externalPackages: true
|
|
185
|
-
})
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
clearFailedEntrypointRegistration(entrypointPath) {
|
|
189
|
-
this.watchedFiles.delete(entrypointPath);
|
|
190
|
-
this.entrypointDependencyGraph.clearEntrypointDependencies(entrypointPath);
|
|
191
|
-
}
|
|
192
|
-
async registerEntrypoint(entrypointPath) {
|
|
193
|
-
return await this.entrypointRegistrar.registerEntrypoint(entrypointPath, {
|
|
194
|
-
emit: async (normalizedEntrypoint) => await this.emitStrictEntrypoint(normalizedEntrypoint),
|
|
195
|
-
getMissingOutputError: (normalizedEntrypoint, outputPath) => new Error(
|
|
196
|
-
`[HMR] Integration failed to emit entrypoint ${normalizedEntrypoint} to ${outputPath}. Page entrypoints must be produced by their owning integration.`
|
|
197
|
-
)
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
async registerScriptEntrypoint(entrypointPath) {
|
|
201
|
-
return await this.entrypointRegistrar.registerEntrypoint(entrypointPath, {
|
|
202
|
-
emit: async (normalizedEntrypoint, outputPath) => await this.emitScriptEntrypoint(normalizedEntrypoint, outputPath),
|
|
203
|
-
getMissingOutputError: (normalizedEntrypoint) => new Error(`[HMR] Failed to register script entrypoint: ${normalizedEntrypoint}`)
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
async emitStrictEntrypoint(entrypointPath) {
|
|
207
|
-
await this.handleFileChange(entrypointPath, { broadcast: false });
|
|
208
|
-
}
|
|
209
|
-
async emitScriptEntrypoint(entrypointPath, outputPath) {
|
|
210
|
-
const naming = path.relative(this.distDir, outputPath).split(path.sep).join("/");
|
|
211
|
-
const buildResult = await this.browserBundleService.bundle({
|
|
212
|
-
profile: "hmr-entrypoint",
|
|
213
|
-
entrypoints: [entrypointPath],
|
|
214
|
-
outdir: this.distDir,
|
|
215
|
-
naming,
|
|
216
|
-
minify: false,
|
|
217
|
-
plugins: this.plugins
|
|
218
|
-
});
|
|
219
|
-
if (!buildResult.success) {
|
|
220
|
-
appLogger.error(`[HMR] Generic script entrypoint build failed for ${entrypointPath}:`, buildResult.logs);
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
const entrypointDependencies = buildResult.dependencyGraph?.entrypoints?.[entrypointPath];
|
|
224
|
-
if (entrypointDependencies) {
|
|
225
|
-
this.entrypointDependencyGraph.setEntrypointDependencies(entrypointPath, entrypointDependencies);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
stop() {
|
|
229
|
-
this.entrypointRegistrations.clear();
|
|
230
|
-
for (const watcher of this.watchers.values()) {
|
|
231
|
-
watcher.close();
|
|
232
|
-
}
|
|
233
|
-
this.watchers.clear();
|
|
234
|
-
this.watchedFiles.clear();
|
|
235
|
-
this.entrypointDependencyGraph.reset();
|
|
236
|
-
this.plugins = [];
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
export {
|
|
240
|
-
SharedHmrManager
|
|
241
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { EcoBuildPlugin } from './build-types.js';
|
|
2
|
-
import { type BrowserRuntimeManifest } from './browser-runtime-manifest.js';
|
|
3
|
-
export interface AppBuildManifest {
|
|
4
|
-
loaderPlugins: EcoBuildPlugin[];
|
|
5
|
-
runtimePlugins: EcoBuildPlugin[];
|
|
6
|
-
browserBundlePlugins: EcoBuildPlugin[];
|
|
7
|
-
browserRuntimeManifest: BrowserRuntimeManifest;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Merges plugin lists while preserving first-registration precedence by name.
|
|
11
|
-
*
|
|
12
|
-
* @remarks
|
|
13
|
-
* Build manifests treat plugin names as stable identities. The first plugin
|
|
14
|
-
* with a given name wins so config-time assembly stays deterministic across
|
|
15
|
-
* loader, runtime, and browser buckets.
|
|
16
|
-
*/
|
|
17
|
-
export declare function mergeEcoBuildPlugins(...pluginLists: Array<EcoBuildPlugin[] | undefined>): EcoBuildPlugin[];
|
|
18
|
-
/**
|
|
19
|
-
* Creates one app-owned build manifest from the supplied plugin buckets.
|
|
20
|
-
*/
|
|
21
|
-
export declare function createAppBuildManifest(input?: Partial<AppBuildManifest>): AppBuildManifest;
|
|
22
|
-
/**
|
|
23
|
-
* Returns the shared browser runtime asset manifest sealed into the app build manifest.
|
|
24
|
-
*/
|
|
25
|
-
export declare function getBrowserRuntimeManifest(manifest: AppBuildManifest): BrowserRuntimeManifest;
|
|
26
|
-
/**
|
|
27
|
-
* Returns the plugin list used for server-oriented builds.
|
|
28
|
-
*/
|
|
29
|
-
export declare function getServerBuildPlugins(manifest: AppBuildManifest): EcoBuildPlugin[];
|
|
30
|
-
/**
|
|
31
|
-
* Returns the plugin list used for browser-oriented builds.
|
|
32
|
-
*/
|
|
33
|
-
export declare function getBrowserBuildPlugins(manifest: AppBuildManifest): EcoBuildPlugin[];
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DevEngine-backed build adapter for cached incremental rebuilds.
|
|
3
|
-
*
|
|
4
|
-
* @remarks
|
|
5
|
-
* Wraps Rolldown's experimental `DevEngine` to provide cached incremental
|
|
6
|
-
* rebuilds. Unlike the standard `RolldownBuildAdapter` which creates a new
|
|
7
|
-
* bundler for every build, this adapter keeps a `DevEngine` instance alive
|
|
8
|
-
* and reuses the internal module graph, resolver cache, and transform cache
|
|
9
|
-
* across builds.
|
|
10
|
-
*
|
|
11
|
-
* The adapter is designed for the HMR rebuild path where the same entrypoints
|
|
12
|
-
* are rebuilt repeatedly with small changes. For one-off production builds,
|
|
13
|
-
* use `RolldownBuildAdapter` instead.
|
|
14
|
-
*
|
|
15
|
-
* The first build creates the engine and runs it. Subsequent builds with the
|
|
16
|
-
* same plugin/target/format triple reuse the cached engine and call
|
|
17
|
-
* `triggerFullBuild()`. The cache key incorporates the context root, plugin
|
|
18
|
-
* names, target, and format; when any of those change, the cached engine is
|
|
19
|
-
* closed and a new one is created.
|
|
20
|
-
*
|
|
21
|
-
* Call `close()` to release the cached engine and free resources.
|
|
22
|
-
*
|
|
23
|
-
* @module
|
|
24
|
-
*/
|
|
25
|
-
import type { BuildAdapter, BuildOptions, BuildResult, BuildTranspileOptions, BuildTranspileProfile } from './build-adapter.js';
|
|
26
|
-
/**
|
|
27
|
-
* Build adapter backed by Rolldown's DevEngine for cached incremental rebuilds.
|
|
28
|
-
*/
|
|
29
|
-
export declare class RolldownDevBuildAdapter implements BuildAdapter {
|
|
30
|
-
/**
|
|
31
|
-
* `'rolldown-dev'` (not `'rolldown'`) so {@link getBuildAdapterOwnership}
|
|
32
|
-
* round-trips correctly and `createBuildAdapter({ ownership })` can
|
|
33
|
-
* re-select this class.
|
|
34
|
-
*/
|
|
35
|
-
readonly ownership: "rolldown-dev";
|
|
36
|
-
private cachedEngine;
|
|
37
|
-
private engineInstanceCount;
|
|
38
|
-
private readonly pendingBuilds;
|
|
39
|
-
private readonly appRootRequireCache;
|
|
40
|
-
/**
|
|
41
|
-
* Stable key over the inputs that affect the engine configuration.
|
|
42
|
-
* Plugin order is intentionally not part of the key: two plugin
|
|
43
|
-
* sets with the same names are interchangeable for caching.
|
|
44
|
-
*/
|
|
45
|
-
private getCacheKey;
|
|
46
|
-
/**
|
|
47
|
-
* Returns the cached engine, creating a new one when the cache
|
|
48
|
-
* key changes. On a cache miss the prior engine is closed and
|
|
49
|
-
* {@link engineInstanceCount} is incremented.
|
|
50
|
-
*/
|
|
51
|
-
private getOrCreateEngine;
|
|
52
|
-
/**
|
|
53
|
-
* Triggers a build on the cached engine and returns the next
|
|
54
|
-
* `RolldownOutput` delivered to `onOutput`.
|
|
55
|
-
*
|
|
56
|
-
* First call after engine creation invokes `engine.run`; subsequent
|
|
57
|
-
* calls invoke `engine.triggerFullBuild` and reuse the cached
|
|
58
|
-
* module graph, resolver, and transform caches.
|
|
59
|
-
*
|
|
60
|
-
* If the trigger itself throws, the queued build is removed so
|
|
61
|
-
* the next `build()` does not consume a stale slot.
|
|
62
|
-
*/
|
|
63
|
-
private runBuild;
|
|
64
|
-
/** Throws on error; see {@link build} for the no-throw variant. */
|
|
65
|
-
buildOrThrow(options: BuildOptions): Promise<BuildResult>;
|
|
66
|
-
build(options: BuildOptions): Promise<BuildResult>;
|
|
67
|
-
resolve(importPath: string, rootDir: string): string;
|
|
68
|
-
getTranspileOptions(profile: BuildTranspileProfile): BuildTranspileOptions;
|
|
69
|
-
/**
|
|
70
|
-
* Closes the cached DevEngine and rejects any in-flight builds
|
|
71
|
-
* with `'DevBuildAdapter closed'`.
|
|
72
|
-
*
|
|
73
|
-
* @remarks
|
|
74
|
-
* Not on the {@link BuildAdapter} interface, so it is only
|
|
75
|
-
* reachable through the concrete class. The adapter is meant to
|
|
76
|
-
* live for the process lifetime; this is for explicit teardown.
|
|
77
|
-
*/
|
|
78
|
-
close(): Promise<void>;
|
|
79
|
-
/** Test-only: number of engines created over the adapter's lifetime. */
|
|
80
|
-
getEngineInstanceCountForTests(): number;
|
|
81
|
-
}
|
|
82
|
-
export declare function createRolldownDevBuildAdapter(): RolldownDevBuildAdapter;
|