@ecopages/core 0.2.0-beta.3 → 0.2.0-beta.30
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
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileSystem } from "@ecopages/file-system";
|
|
3
|
+
import {
|
|
4
|
+
removeStaleHmrEntrypointOutput,
|
|
5
|
+
resolveHmrEntrypointOutputPaths
|
|
6
|
+
} from "../../../hmr/hmr-entrypoint-output.js";
|
|
7
|
+
class HmrEntrypointRegistrar {
|
|
8
|
+
options;
|
|
9
|
+
inFlight = /* @__PURE__ */ new Map();
|
|
10
|
+
registered = /* @__PURE__ */ new Map();
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.options = options;
|
|
13
|
+
}
|
|
14
|
+
getRegistered() {
|
|
15
|
+
return this.registered;
|
|
16
|
+
}
|
|
17
|
+
getWatchedFiles() {
|
|
18
|
+
const watchedFiles = /* @__PURE__ */ new Map();
|
|
19
|
+
for (const [sourcePath, entrypoint] of this.registered) {
|
|
20
|
+
watchedFiles.set(sourcePath, entrypoint.outputUrl);
|
|
21
|
+
}
|
|
22
|
+
return watchedFiles;
|
|
23
|
+
}
|
|
24
|
+
clearRegistration(entrypointPath) {
|
|
25
|
+
this.registered.delete(path.resolve(entrypointPath));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Registers an already-materialized HMR entrypoint without running the emit hook.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Cold dev batches build entrypoints in grouped Rolldown passes and then seed
|
|
32
|
+
* the registrar so the first SSR can resolve the artifact without rebuilding.
|
|
33
|
+
* The source path is committed verbatim so `getResolvedScriptOutput()` and the
|
|
34
|
+
* file watcher see it as a regular watched entrypoint.
|
|
35
|
+
*/
|
|
36
|
+
seedResolvedEntrypoint(resolved) {
|
|
37
|
+
this.registered.set(path.resolve(resolved.sourcePath), {
|
|
38
|
+
sourcePath: resolved.sourcePath,
|
|
39
|
+
outputPath: resolved.outputPath,
|
|
40
|
+
outputUrl: resolved.outputUrl
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
clearAll() {
|
|
44
|
+
this.inFlight.clear();
|
|
45
|
+
this.registered.clear();
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Registers a single source entrypoint and returns its verified HMR artifact.
|
|
49
|
+
*
|
|
50
|
+
* Concurrent requests for the same normalized entrypoint share the same in-flight promise.
|
|
51
|
+
*/
|
|
52
|
+
async registerEntrypoint(entrypointPath, registrationOptions) {
|
|
53
|
+
const normalizedEntrypoint = path.resolve(entrypointPath);
|
|
54
|
+
const existing = this.registered.get(normalizedEntrypoint);
|
|
55
|
+
if (existing && fileSystem.exists(existing.outputPath)) {
|
|
56
|
+
return existing;
|
|
57
|
+
}
|
|
58
|
+
const existingRegistration = this.inFlight.get(normalizedEntrypoint);
|
|
59
|
+
if (existingRegistration) {
|
|
60
|
+
return await existingRegistration;
|
|
61
|
+
}
|
|
62
|
+
const registration = this.registerEntrypointInternal(normalizedEntrypoint, registrationOptions);
|
|
63
|
+
this.inFlight.set(normalizedEntrypoint, registration);
|
|
64
|
+
try {
|
|
65
|
+
return await registration;
|
|
66
|
+
} catch (error) {
|
|
67
|
+
this.options.clearFailedRegistration?.(normalizedEntrypoint);
|
|
68
|
+
this.registered.delete(normalizedEntrypoint);
|
|
69
|
+
throw error;
|
|
70
|
+
} finally {
|
|
71
|
+
if (this.inFlight.get(normalizedEntrypoint) === registration) {
|
|
72
|
+
this.inFlight.delete(normalizedEntrypoint);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async registerEntrypointInternal(entrypointPath, registrationOptions) {
|
|
77
|
+
const previous = this.registered.get(entrypointPath);
|
|
78
|
+
const { outputPath, outputUrl } = resolveHmrEntrypointOutputPaths(
|
|
79
|
+
this.options.srcDir,
|
|
80
|
+
this.options.distDir,
|
|
81
|
+
entrypointPath
|
|
82
|
+
);
|
|
83
|
+
removeStaleHmrEntrypointOutput(outputPath, "HMR");
|
|
84
|
+
try {
|
|
85
|
+
await registrationOptions.emit(entrypointPath, outputPath);
|
|
86
|
+
if (!fileSystem.exists(outputPath)) {
|
|
87
|
+
throw registrationOptions.getMissingOutputError(entrypointPath, outputPath);
|
|
88
|
+
}
|
|
89
|
+
const resolved = {
|
|
90
|
+
sourcePath: entrypointPath,
|
|
91
|
+
outputPath,
|
|
92
|
+
outputUrl
|
|
93
|
+
};
|
|
94
|
+
this.registered.set(entrypointPath, resolved);
|
|
95
|
+
return resolved;
|
|
96
|
+
} catch (error) {
|
|
97
|
+
if (previous && fileSystem.exists(previous.outputPath)) {
|
|
98
|
+
this.registered.set(entrypointPath, previous);
|
|
99
|
+
}
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
HmrEntrypointRegistrar
|
|
106
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IHmrManager } from '
|
|
1
|
+
import type { IHmrManager } from '../../../types/public-types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Returns whether a response is HTML and therefore eligible for development HMR
|
|
4
4
|
* runtime injection.
|
|
@@ -11,7 +11,7 @@ export declare function isHtmlResponse(response: Response): boolean;
|
|
|
11
11
|
* responses flow through different layers, but both need identical injection
|
|
12
12
|
* behavior in watch mode.
|
|
13
13
|
*/
|
|
14
|
-
export declare function shouldInjectHmrHtmlResponse(watch: boolean, hmrManager?: Pick<IHmrManager, 'isEnabled'
|
|
14
|
+
export declare function shouldInjectHmrHtmlResponse(watch: boolean, hmrManager?: Pick<IHmrManager, 'isEnabled'>, hostOwnsDevClient?: boolean): boolean;
|
|
15
15
|
/**
|
|
16
16
|
* Injects the development HMR runtime script into an HTML response if it is not
|
|
17
17
|
* already present.
|
|
@@ -4,7 +4,10 @@ function isHtmlResponse(response) {
|
|
|
4
4
|
const contentType = response.headers.get("Content-Type");
|
|
5
5
|
return contentType !== null && contentType.startsWith("text/html");
|
|
6
6
|
}
|
|
7
|
-
function shouldInjectHmrHtmlResponse(watch, hmrManager) {
|
|
7
|
+
function shouldInjectHmrHtmlResponse(watch, hmrManager, hostOwnsDevClient = false) {
|
|
8
|
+
if (hostOwnsDevClient) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
8
11
|
return watch && hmrManager?.isEnabled() === true;
|
|
9
12
|
}
|
|
10
13
|
async function injectHmrRuntimeIntoHtmlResponse(response) {
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { type ResolvedHmrEntrypoint } from '../../../hmr/hmr-entrypoint-output.js';
|
|
3
|
+
import type { DefaultHmrContext, EcoPagesAppConfig, IHmrManager, IClientBridge } from '../../../types/internal-types.js';
|
|
4
|
+
import { type HmrStrategy } from '../../../hmr/hmr-strategy.js';
|
|
5
|
+
import { DevelopmentInvalidationService } from '../../../services/invalidation/development-invalidation.service.js';
|
|
6
|
+
import type { ClientBridgeEvent, HmrFileChangeOptions } from '../../../types/public-types.js';
|
|
7
|
+
import { HmrEntrypointRegistrar } from './hmr-entrypoint-registrar.js';
|
|
8
|
+
import { BrowserBundleService } from '../../../services/assets/browser-bundle.service.js';
|
|
9
|
+
import { type EntrypointDependencyGraph } from '../../../services/runtime-state/entrypoint-dependency-graph.service.js';
|
|
10
|
+
import type { ServerModuleTranspiler } from '../../../services/module-loading/server-module-transpiler.service.js';
|
|
11
|
+
type HandleFileChangeOptions = HmrFileChangeOptions;
|
|
12
|
+
type SharedHmrManagerParams = {
|
|
13
|
+
appConfig: EcoPagesAppConfig;
|
|
14
|
+
bridge: IClientBridge;
|
|
15
|
+
};
|
|
16
|
+
export declare abstract class SharedHmrManager implements IHmrManager {
|
|
17
|
+
readonly appConfig: EcoPagesAppConfig;
|
|
18
|
+
protected readonly bridge: IClientBridge;
|
|
19
|
+
protected watchers: Map<string, fs.FSWatcher>;
|
|
20
|
+
protected distDir: string;
|
|
21
|
+
protected enabled: boolean;
|
|
22
|
+
protected strategies: HmrStrategy[];
|
|
23
|
+
protected readonly entrypointRegistrar: HmrEntrypointRegistrar;
|
|
24
|
+
protected readonly browserBundleService: BrowserBundleService;
|
|
25
|
+
protected readonly invalidationService: DevelopmentInvalidationService;
|
|
26
|
+
protected readonly entrypointDependencyGraph: EntrypointDependencyGraph;
|
|
27
|
+
protected readonly serverModuleTranspiler: ServerModuleTranspiler;
|
|
28
|
+
private runtimeBuildPromise;
|
|
29
|
+
private runtimeReady;
|
|
30
|
+
constructor({ appConfig, bridge }: SharedHmrManagerParams);
|
|
31
|
+
protected abstract createEntrypointDependencyGraph(existingEntrypointDependencyGraph: EntrypointDependencyGraph): EntrypointDependencyGraph;
|
|
32
|
+
protected shouldSkipMissingFileChange(_filePath: string): boolean;
|
|
33
|
+
protected onRuntimeBundleFailure(error: unknown): void;
|
|
34
|
+
protected ensureDistDir(): void;
|
|
35
|
+
protected shouldJsStrategyProcessEntrypoint(entrypointPath: string): boolean;
|
|
36
|
+
protected initializeStrategies(): void;
|
|
37
|
+
registerStrategy(strategy: HmrStrategy): void;
|
|
38
|
+
setEnabled(enabled: boolean): void;
|
|
39
|
+
isEnabled(): boolean;
|
|
40
|
+
isRuntimeReady(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Builds the browser HMR runtime once per manager session and reuses the in-flight build for concurrent callers.
|
|
43
|
+
*/
|
|
44
|
+
ensureRuntimeReady(): Promise<boolean>;
|
|
45
|
+
buildRuntime(): Promise<void>;
|
|
46
|
+
getRuntimePath(): string;
|
|
47
|
+
private buildRuntimeInternal;
|
|
48
|
+
broadcast(event: ClientBridgeEvent): void;
|
|
49
|
+
handleFileChange(filePath: string, options?: HandleFileChangeOptions): Promise<void>;
|
|
50
|
+
private getStrategiesByPriority;
|
|
51
|
+
private selectChangeStrategy;
|
|
52
|
+
private selectEntrypointEmitter;
|
|
53
|
+
protected createUnownedEntrypointError(entrypointPath: string): Error;
|
|
54
|
+
/**
|
|
55
|
+
* Materializes one integration-owned page entrypoint during cold registration.
|
|
56
|
+
*
|
|
57
|
+
* @remarks
|
|
58
|
+
* Registration uses {@link HmrStrategy.canEmitEntrypoint} / {@link HmrStrategy.emitEntrypoint},
|
|
59
|
+
* not {@link HmrStrategy.matches} / {@link HmrStrategy.process}. File-change handling stays
|
|
60
|
+
* on `handleFileChange()`.
|
|
61
|
+
*/
|
|
62
|
+
emitIntegrationEntrypoint(entrypointPath: string, outputPath: string): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Runs server invalidation and integration hooks before rebuilding a registered script entrypoint.
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* Browser-only `*.script.ts` entrypoints skip server module invalidation and bypass-cache
|
|
68
|
+
* import; only integration change handlers and the downstream strategy rebuild run.
|
|
69
|
+
*/
|
|
70
|
+
private prepareRegisteredScriptChange;
|
|
71
|
+
getOutputUrl(entrypointPath: string): string | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Registers an already-materialized HMR entrypoint without rebuilding it.
|
|
74
|
+
*
|
|
75
|
+
* @remarks
|
|
76
|
+
* Cold dev batches build grouped Rolldown passes up front and then seed the
|
|
77
|
+
* registrar so the first SSR resolves the artifact from disk. The entrypoint
|
|
78
|
+
* is also added to the watched files so subsequent source edits still rebuild.
|
|
79
|
+
*/
|
|
80
|
+
seedResolvedEntrypoint(resolved: ResolvedHmrEntrypoint): void;
|
|
81
|
+
/**
|
|
82
|
+
* Returns the emitted HMR script output when the entrypoint is already registered
|
|
83
|
+
* and its browser bundle exists on disk.
|
|
84
|
+
*
|
|
85
|
+
* @remarks
|
|
86
|
+
* Disk artifacts alone are not enough: a fresh dev session must still register
|
|
87
|
+
* the entrypoint so file watchers can rebuild it on change.
|
|
88
|
+
*/
|
|
89
|
+
getResolvedScriptOutput(entrypointPath: string): ResolvedHmrEntrypoint | undefined;
|
|
90
|
+
getWatchedFiles(): Map<string, string>;
|
|
91
|
+
tryHandleAssetRequest(request: Request): Response | null;
|
|
92
|
+
getDistDir(): string;
|
|
93
|
+
getDefaultContext(): DefaultHmrContext;
|
|
94
|
+
stop(): void;
|
|
95
|
+
protected clearFailedEntrypointRegistration(entrypointPath: string): void;
|
|
96
|
+
registerEntrypoint(entrypointPath: string): Promise<string>;
|
|
97
|
+
registerScriptEntrypoint(entrypointPath: string): Promise<ResolvedHmrEntrypoint>;
|
|
98
|
+
protected emitScriptEntrypoint(entrypointPath: string, outputPath: string): Promise<void>;
|
|
99
|
+
[Symbol.dispose](): void;
|
|
100
|
+
}
|
|
101
|
+
export {};
|
|
@@ -0,0 +1,432 @@
|
|
|
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 {
|
|
6
|
+
removeStaleHmrEntrypointOutput,
|
|
7
|
+
isRegisteredScriptEntrypoint,
|
|
8
|
+
isBrowserOnlyRegisteredScriptEntrypoint
|
|
9
|
+
} from "../../../hmr/hmr-entrypoint-output.js";
|
|
10
|
+
import { requireBuildRuntime } from "../../../build/runtime/build-runtime.js";
|
|
11
|
+
import { fileSystem } from "@ecopages/file-system";
|
|
12
|
+
import { HmrStrategyType } from "../../../hmr/hmr-strategy.js";
|
|
13
|
+
import { DefaultHmrStrategy } from "../../../hmr/strategies/default-hmr-strategy.js";
|
|
14
|
+
import { JsHmrStrategy } from "../../../hmr/strategies/js-hmr-strategy.js";
|
|
15
|
+
import { ServerRenderedTemplateHmrStrategy } from "../../../hmr/strategies/server-rendered-template-hmr-strategy.js";
|
|
16
|
+
import { DevelopmentInvalidationService } from "../../../services/invalidation/development-invalidation.service.js";
|
|
17
|
+
import { appLogger } from "../../../global/app-logger.js";
|
|
18
|
+
import { HmrEntrypointRegistrar } from "./hmr-entrypoint-registrar.js";
|
|
19
|
+
import { BrowserBundleService } from "../../../services/assets/browser-bundle.service.js";
|
|
20
|
+
import { getAppServerModuleTranspiler } from "../../../services/module-loading/app-server-module-transpiler.service.js";
|
|
21
|
+
import {
|
|
22
|
+
getAppEntrypointDependencyGraph,
|
|
23
|
+
setAppEntrypointDependencyGraph
|
|
24
|
+
} from "../../../services/runtime-state/entrypoint-dependency-graph.service.js";
|
|
25
|
+
import { resolveInternalExecutionDir, resolveInternalWorkDir } from "../../../utils/resolve-work-dir.js";
|
|
26
|
+
class SharedHmrManager {
|
|
27
|
+
appConfig;
|
|
28
|
+
bridge;
|
|
29
|
+
watchers = /* @__PURE__ */ new Map();
|
|
30
|
+
distDir;
|
|
31
|
+
enabled = false;
|
|
32
|
+
strategies = [];
|
|
33
|
+
entrypointRegistrar;
|
|
34
|
+
browserBundleService;
|
|
35
|
+
invalidationService;
|
|
36
|
+
entrypointDependencyGraph;
|
|
37
|
+
serverModuleTranspiler;
|
|
38
|
+
runtimeBuildPromise = null;
|
|
39
|
+
runtimeReady = false;
|
|
40
|
+
constructor({ appConfig, bridge }) {
|
|
41
|
+
this.appConfig = appConfig;
|
|
42
|
+
this.bridge = bridge;
|
|
43
|
+
this.distDir = path.join(resolveInternalWorkDir(this.appConfig), RESOLVED_ASSETS_DIR, "_hmr");
|
|
44
|
+
this.entrypointRegistrar = new HmrEntrypointRegistrar({
|
|
45
|
+
srcDir: this.appConfig.absolutePaths.srcDir,
|
|
46
|
+
distDir: this.distDir,
|
|
47
|
+
clearFailedRegistration: (entrypointPath) => this.clearFailedEntrypointRegistration(entrypointPath)
|
|
48
|
+
});
|
|
49
|
+
this.browserBundleService = new BrowserBundleService(appConfig);
|
|
50
|
+
this.invalidationService = new DevelopmentInvalidationService(appConfig);
|
|
51
|
+
this.entrypointDependencyGraph = this.createEntrypointDependencyGraph(
|
|
52
|
+
getAppEntrypointDependencyGraph(appConfig)
|
|
53
|
+
);
|
|
54
|
+
setAppEntrypointDependencyGraph(this.appConfig, this.entrypointDependencyGraph);
|
|
55
|
+
this.serverModuleTranspiler = getAppServerModuleTranspiler(this.appConfig);
|
|
56
|
+
this.ensureDistDir();
|
|
57
|
+
this.initializeStrategies();
|
|
58
|
+
}
|
|
59
|
+
shouldSkipMissingFileChange(_filePath) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
onRuntimeBundleFailure(error) {
|
|
63
|
+
appLogger.error("[HMR] Failed to build runtime script:", error);
|
|
64
|
+
}
|
|
65
|
+
ensureDistDir() {
|
|
66
|
+
fileSystem.ensureDir(this.distDir);
|
|
67
|
+
}
|
|
68
|
+
shouldJsStrategyProcessEntrypoint(entrypointPath) {
|
|
69
|
+
return !this.strategies.some((strategy) => {
|
|
70
|
+
if (strategy.type !== HmrStrategyType.INTEGRATION || strategy.priority <= HmrStrategyType.SCRIPT) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
return strategy.matches(entrypointPath);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
appLogger.error(error);
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
initializeStrategies() {
|
|
82
|
+
const jsContext = {
|
|
83
|
+
getWatchedFiles: () => this.entrypointRegistrar.getWatchedFiles(),
|
|
84
|
+
getDistDir: () => this.distDir,
|
|
85
|
+
getSrcDir: () => this.appConfig.absolutePaths.srcDir,
|
|
86
|
+
getPagesDir: () => this.appConfig.absolutePaths.pagesDir,
|
|
87
|
+
getLayoutsDir: () => this.appConfig.absolutePaths.layoutsDir,
|
|
88
|
+
getTemplateExtensions: () => this.appConfig.templatesExt,
|
|
89
|
+
getBrowserBundleService: () => this.browserBundleService,
|
|
90
|
+
getEntrypointDependencyGraph: () => this.entrypointDependencyGraph,
|
|
91
|
+
shouldProcessEntrypoint: (entrypointPath) => this.shouldJsStrategyProcessEntrypoint(entrypointPath)
|
|
92
|
+
};
|
|
93
|
+
this.strategies = [
|
|
94
|
+
new JsHmrStrategy(jsContext),
|
|
95
|
+
new ServerRenderedTemplateHmrStrategy(this.invalidationService),
|
|
96
|
+
new DefaultHmrStrategy()
|
|
97
|
+
];
|
|
98
|
+
}
|
|
99
|
+
registerStrategy(strategy) {
|
|
100
|
+
this.strategies.push(strategy);
|
|
101
|
+
}
|
|
102
|
+
setEnabled(enabled) {
|
|
103
|
+
this.enabled = enabled;
|
|
104
|
+
}
|
|
105
|
+
isEnabled() {
|
|
106
|
+
return this.enabled;
|
|
107
|
+
}
|
|
108
|
+
isRuntimeReady() {
|
|
109
|
+
return this.runtimeReady && fileSystem.exists(this.getRuntimePath());
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Builds the browser HMR runtime once per manager session and reuses the in-flight build for concurrent callers.
|
|
113
|
+
*/
|
|
114
|
+
async ensureRuntimeReady() {
|
|
115
|
+
if (this.runtimeReady) {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
if (this.runtimeBuildPromise) {
|
|
119
|
+
return this.runtimeBuildPromise;
|
|
120
|
+
}
|
|
121
|
+
this.runtimeBuildPromise = this.buildRuntimeInternal();
|
|
122
|
+
try {
|
|
123
|
+
const ready = await this.runtimeBuildPromise;
|
|
124
|
+
this.runtimeReady = ready;
|
|
125
|
+
return ready;
|
|
126
|
+
} finally {
|
|
127
|
+
this.runtimeBuildPromise = null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async buildRuntime() {
|
|
131
|
+
await this.ensureRuntimeReady();
|
|
132
|
+
}
|
|
133
|
+
getRuntimePath() {
|
|
134
|
+
return path.join(this.distDir, "_hmr_runtime.js");
|
|
135
|
+
}
|
|
136
|
+
async buildRuntimeInternal() {
|
|
137
|
+
const runtimeSource = fileURLToPath(import.meta.resolve("@ecopages/core/hmr/client/hmr-runtime"));
|
|
138
|
+
const runtimePath = this.getRuntimePath();
|
|
139
|
+
removeStaleHmrEntrypointOutput(runtimePath, "HMR");
|
|
140
|
+
try {
|
|
141
|
+
const result = await this.browserBundleService.bundle({
|
|
142
|
+
profile: "hmr-runtime",
|
|
143
|
+
entrypoints: [runtimeSource],
|
|
144
|
+
outdir: this.distDir,
|
|
145
|
+
naming: "_hmr_runtime.js",
|
|
146
|
+
minify: false
|
|
147
|
+
});
|
|
148
|
+
if (!result.success) {
|
|
149
|
+
this.onRuntimeBundleFailure(result.logs);
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
const emittedRuntime = result.outputs.find(
|
|
153
|
+
(output) => path.resolve(output.path) === path.resolve(runtimePath)
|
|
154
|
+
);
|
|
155
|
+
if (!emittedRuntime || !fileSystem.exists(runtimePath)) {
|
|
156
|
+
this.onRuntimeBundleFailure(
|
|
157
|
+
new Error(`[HMR] Runtime bundle missing expected output at ${runtimePath}`)
|
|
158
|
+
);
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
return true;
|
|
162
|
+
} catch (error) {
|
|
163
|
+
this.onRuntimeBundleFailure(error);
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
broadcast(event) {
|
|
168
|
+
appLogger.debug(
|
|
169
|
+
`[HMR] Broadcasting ${event.type} event, path=${event.path || "all"}, subscribers=${this.bridge.subscriberCount}`
|
|
170
|
+
);
|
|
171
|
+
this.bridge.broadcast(event);
|
|
172
|
+
}
|
|
173
|
+
async handleFileChange(filePath, options = {}) {
|
|
174
|
+
const resolvedFilePath = path.resolve(filePath);
|
|
175
|
+
if (this.shouldSkipMissingFileChange(filePath) && !fileSystem.exists(filePath)) {
|
|
176
|
+
appLogger.debug(`[${this.constructor.name}] Skipping missing file change: ${filePath}`);
|
|
177
|
+
this.clearFailedEntrypointRegistration(filePath);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (isRegisteredScriptEntrypoint(this.entrypointRegistrar.getRegistered(), resolvedFilePath)) {
|
|
181
|
+
await this.prepareRegisteredScriptChange(resolvedFilePath);
|
|
182
|
+
}
|
|
183
|
+
const shouldBroadcast = options.broadcast ?? true;
|
|
184
|
+
const strategy = this.selectChangeStrategy(filePath);
|
|
185
|
+
if (!strategy) {
|
|
186
|
+
appLogger.warn(`[HMR] No strategy found for ${filePath}`);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
appLogger.debug(`[${this.constructor.name}] Selected strategy: ${strategy.constructor.name}`);
|
|
190
|
+
const action = await strategy.process(filePath);
|
|
191
|
+
if (shouldBroadcast && action.type === "broadcast" && action.events) {
|
|
192
|
+
if (this.bridge.subscriberCount === 0) {
|
|
193
|
+
appLogger.debug(
|
|
194
|
+
`[${this.constructor.name}] Deferring HMR client broadcast for ${filePath} until a subscriber connects`
|
|
195
|
+
);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
for (const event of action.events) {
|
|
199
|
+
const graphIdentities = event.graphIdentities ?? options.graphIdentities;
|
|
200
|
+
this.broadcast(graphIdentities === void 0 ? event : { ...event, graphIdentities });
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
getStrategiesByPriority() {
|
|
205
|
+
return [...this.strategies].sort((left, right) => right.priority - left.priority);
|
|
206
|
+
}
|
|
207
|
+
selectChangeStrategy(filePath) {
|
|
208
|
+
return this.getStrategiesByPriority().find((candidate) => {
|
|
209
|
+
try {
|
|
210
|
+
return candidate.matches(filePath);
|
|
211
|
+
} catch (error) {
|
|
212
|
+
appLogger.error(error);
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
selectEntrypointEmitter(entrypointPath) {
|
|
218
|
+
return this.getStrategiesByPriority().find((candidate) => {
|
|
219
|
+
if (candidate.type !== HmrStrategyType.INTEGRATION) {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
try {
|
|
223
|
+
return candidate.canEmitEntrypoint(entrypointPath);
|
|
224
|
+
} catch (error) {
|
|
225
|
+
appLogger.error(error);
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
createUnownedEntrypointError(entrypointPath) {
|
|
231
|
+
return new Error(
|
|
232
|
+
`[HMR] No integration owns entrypoint ${entrypointPath}. Page entrypoints must be emitted by their owning integration.`
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Materializes one integration-owned page entrypoint during cold registration.
|
|
237
|
+
*
|
|
238
|
+
* @remarks
|
|
239
|
+
* Registration uses {@link HmrStrategy.canEmitEntrypoint} / {@link HmrStrategy.emitEntrypoint},
|
|
240
|
+
* not {@link HmrStrategy.matches} / {@link HmrStrategy.process}. File-change handling stays
|
|
241
|
+
* on `handleFileChange()`.
|
|
242
|
+
*/
|
|
243
|
+
async emitIntegrationEntrypoint(entrypointPath, outputPath) {
|
|
244
|
+
const emitter = this.selectEntrypointEmitter(entrypointPath);
|
|
245
|
+
if (!emitter) {
|
|
246
|
+
throw this.createUnownedEntrypointError(entrypointPath);
|
|
247
|
+
}
|
|
248
|
+
appLogger.debug(`[${this.constructor.name}] Selected entrypoint emitter: ${emitter.constructor.name}`);
|
|
249
|
+
await emitter.emitEntrypoint(entrypointPath, outputPath);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Runs server invalidation and integration hooks before rebuilding a registered script entrypoint.
|
|
253
|
+
*
|
|
254
|
+
* @remarks
|
|
255
|
+
* Browser-only `*.script.ts` entrypoints skip server module invalidation and bypass-cache
|
|
256
|
+
* import; only integration change handlers and the downstream strategy rebuild run.
|
|
257
|
+
*/
|
|
258
|
+
async prepareRegisteredScriptChange(filePath) {
|
|
259
|
+
const isBrowserOnlyRegisteredScript = isBrowserOnlyRegisteredScriptEntrypoint(filePath);
|
|
260
|
+
if (!isBrowserOnlyRegisteredScript) {
|
|
261
|
+
this.invalidationService.invalidateServerModules([filePath]);
|
|
262
|
+
}
|
|
263
|
+
const handlers = this.appConfig.runtime?.registeredScriptEntrypointChangeHandlers ?? [];
|
|
264
|
+
for (const handler of handlers) {
|
|
265
|
+
try {
|
|
266
|
+
await handler(filePath);
|
|
267
|
+
} catch (error) {
|
|
268
|
+
const message = error instanceof Error ? error.message : `Failed to handle registered script entrypoint change for ${filePath}: ${String(error)}`;
|
|
269
|
+
this.broadcast({ type: "error", message });
|
|
270
|
+
throw error;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (isBrowserOnlyRegisteredScript) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const appModuleLoader = this.appConfig.runtime?.appModuleLoader;
|
|
277
|
+
if (!appModuleLoader) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
await appModuleLoader.importModule({
|
|
281
|
+
filePath,
|
|
282
|
+
rootDir: this.appConfig.rootDir,
|
|
283
|
+
outdir: path.join(resolveInternalExecutionDir(this.appConfig), ".server-modules"),
|
|
284
|
+
externalPackages: true,
|
|
285
|
+
bypassCache: true
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
getOutputUrl(entrypointPath) {
|
|
289
|
+
return this.entrypointRegistrar.getRegistered().get(path.resolve(entrypointPath))?.outputUrl;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Registers an already-materialized HMR entrypoint without rebuilding it.
|
|
293
|
+
*
|
|
294
|
+
* @remarks
|
|
295
|
+
* Cold dev batches build grouped Rolldown passes up front and then seed the
|
|
296
|
+
* registrar so the first SSR resolves the artifact from disk. The entrypoint
|
|
297
|
+
* is also added to the watched files so subsequent source edits still rebuild.
|
|
298
|
+
*/
|
|
299
|
+
seedResolvedEntrypoint(resolved) {
|
|
300
|
+
this.entrypointRegistrar.seedResolvedEntrypoint(resolved);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Returns the emitted HMR script output when the entrypoint is already registered
|
|
304
|
+
* and its browser bundle exists on disk.
|
|
305
|
+
*
|
|
306
|
+
* @remarks
|
|
307
|
+
* Disk artifacts alone are not enough: a fresh dev session must still register
|
|
308
|
+
* the entrypoint so file watchers can rebuild it on change.
|
|
309
|
+
*/
|
|
310
|
+
getResolvedScriptOutput(entrypointPath) {
|
|
311
|
+
const normalizedEntrypoint = path.resolve(entrypointPath);
|
|
312
|
+
const registered = this.entrypointRegistrar.getRegistered().get(normalizedEntrypoint);
|
|
313
|
+
if (!registered || !fileSystem.exists(registered.outputPath)) {
|
|
314
|
+
return void 0;
|
|
315
|
+
}
|
|
316
|
+
return registered;
|
|
317
|
+
}
|
|
318
|
+
getWatchedFiles() {
|
|
319
|
+
return this.entrypointRegistrar.getWatchedFiles();
|
|
320
|
+
}
|
|
321
|
+
tryHandleAssetRequest(request) {
|
|
322
|
+
const url = new URL(request.url);
|
|
323
|
+
if (url.pathname === "/_hmr_runtime.js") {
|
|
324
|
+
const runtimePath = this.getRuntimePath();
|
|
325
|
+
if (fileSystem.exists(runtimePath)) {
|
|
326
|
+
return new Response(fileSystem.readFileAsBuffer(runtimePath), {
|
|
327
|
+
headers: {
|
|
328
|
+
"Content-Type": "application/javascript",
|
|
329
|
+
"Cache-Control": "no-store, must-revalidate"
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
if (url.pathname.startsWith("/assets/_hmr/")) {
|
|
335
|
+
const relativePath = url.pathname.slice("/assets/_hmr/".length);
|
|
336
|
+
const assetPath = path.join(this.distDir, relativePath);
|
|
337
|
+
if (fileSystem.exists(assetPath)) {
|
|
338
|
+
return new Response(fileSystem.readFileAsBuffer(assetPath), {
|
|
339
|
+
headers: {
|
|
340
|
+
"Content-Type": "application/javascript",
|
|
341
|
+
"Cache-Control": "no-store, must-revalidate"
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
348
|
+
getDistDir() {
|
|
349
|
+
return this.distDir;
|
|
350
|
+
}
|
|
351
|
+
getDefaultContext() {
|
|
352
|
+
return {
|
|
353
|
+
getWatchedFiles: () => this.entrypointRegistrar.getWatchedFiles(),
|
|
354
|
+
getDistDir: () => this.distDir,
|
|
355
|
+
getSrcDir: () => this.appConfig.absolutePaths.srcDir,
|
|
356
|
+
getLayoutsDir: () => this.appConfig.absolutePaths.layoutsDir,
|
|
357
|
+
getPagesDir: () => this.appConfig.absolutePaths.pagesDir,
|
|
358
|
+
getBuildExecutor: () => requireBuildRuntime(this.appConfig).getProfile("browser-hmr"),
|
|
359
|
+
getBrowserBundleService: () => this.browserBundleService,
|
|
360
|
+
getEntrypointDependencyGraph: () => this.entrypointDependencyGraph,
|
|
361
|
+
seedResolvedEntrypoint: (resolved) => this.seedResolvedEntrypoint(resolved),
|
|
362
|
+
importServerModule: async (filePath) => await this.serverModuleTranspiler.importModule({
|
|
363
|
+
filePath,
|
|
364
|
+
outdir: path.join(resolveInternalExecutionDir(this.appConfig), ".server-modules"),
|
|
365
|
+
externalPackages: true
|
|
366
|
+
})
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
stop() {
|
|
370
|
+
this.runtimeReady = false;
|
|
371
|
+
this.entrypointRegistrar.clearAll();
|
|
372
|
+
for (const watcher of this.watchers.values()) {
|
|
373
|
+
watcher.close();
|
|
374
|
+
}
|
|
375
|
+
this.watchers.clear();
|
|
376
|
+
this.entrypointDependencyGraph.reset();
|
|
377
|
+
}
|
|
378
|
+
clearFailedEntrypointRegistration(entrypointPath) {
|
|
379
|
+
this.entrypointRegistrar.clearRegistration(entrypointPath);
|
|
380
|
+
this.entrypointDependencyGraph.clearEntrypointDependencies(entrypointPath);
|
|
381
|
+
}
|
|
382
|
+
async registerEntrypoint(entrypointPath) {
|
|
383
|
+
const resolved = await this.entrypointRegistrar.registerEntrypoint(entrypointPath, {
|
|
384
|
+
emit: async (normalizedEntrypoint, outputPath) => await this.emitIntegrationEntrypoint(normalizedEntrypoint, outputPath),
|
|
385
|
+
getMissingOutputError: (normalizedEntrypoint, outputPath) => new Error(
|
|
386
|
+
`[HMR] Integration failed to emit entrypoint ${normalizedEntrypoint} to ${outputPath}. Page entrypoints must be produced by their owning integration.`
|
|
387
|
+
)
|
|
388
|
+
});
|
|
389
|
+
return resolved.outputUrl;
|
|
390
|
+
}
|
|
391
|
+
async registerScriptEntrypoint(entrypointPath) {
|
|
392
|
+
return await this.entrypointRegistrar.registerEntrypoint(entrypointPath, {
|
|
393
|
+
emit: async (normalizedEntrypoint, outputPath) => await this.emitScriptEntrypoint(normalizedEntrypoint, outputPath),
|
|
394
|
+
getMissingOutputError: (normalizedEntrypoint, outputPath) => new Error(`[HMR] Failed to register script entrypoint: ${normalizedEntrypoint} to ${outputPath}`)
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
async emitScriptEntrypoint(entrypointPath, outputPath) {
|
|
398
|
+
const naming = path.relative(this.distDir, outputPath).split(path.sep).join("/");
|
|
399
|
+
const buildResult = await this.browserBundleService.bundle({
|
|
400
|
+
profile: "hmr-entrypoint",
|
|
401
|
+
entrypoints: [entrypointPath],
|
|
402
|
+
outdir: this.distDir,
|
|
403
|
+
naming,
|
|
404
|
+
minify: false
|
|
405
|
+
});
|
|
406
|
+
if (!buildResult.success) {
|
|
407
|
+
throw new Error(
|
|
408
|
+
`[HMR] Generic script entrypoint build failed for ${entrypointPath}: ${JSON.stringify(buildResult.logs)}`
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
if (!fileSystem.exists(outputPath) && buildResult.outputs.length > 0) {
|
|
412
|
+
const resolvedOutputPath = path.resolve(outputPath);
|
|
413
|
+
const emittedOutput = buildResult.outputs.find((output) => path.resolve(output.path) === resolvedOutputPath)?.path ?? buildResult.outputs.find((output) => path.basename(output.path) === path.basename(outputPath))?.path;
|
|
414
|
+
if (emittedOutput && fileSystem.exists(emittedOutput)) {
|
|
415
|
+
fileSystem.ensureDir(path.dirname(outputPath));
|
|
416
|
+
if (path.resolve(emittedOutput) !== resolvedOutputPath) {
|
|
417
|
+
fileSystem.copyFile(emittedOutput, outputPath);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
const entrypointDependencies = buildResult.dependencyGraph?.entrypoints?.[entrypointPath];
|
|
422
|
+
if (entrypointDependencies) {
|
|
423
|
+
this.entrypointDependencyGraph.setEntrypointDependencies(entrypointPath, entrypointDependencies);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
[Symbol.dispose]() {
|
|
427
|
+
this.stop();
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
export {
|
|
431
|
+
SharedHmrManager
|
|
432
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SchemaValidationService } from '../../../services/validation/schema-validation-service.js';
|
|
2
|
+
import type { ApiHandler, CacheInvalidator, ErrorHandler, RenderContext } from '../../../types/public-types.js';
|
|
3
|
+
export type ApiRequestPipelineOptions = {
|
|
4
|
+
schemaValidator: SchemaValidationService;
|
|
5
|
+
getRenderContext: () => RenderContext;
|
|
6
|
+
getCacheService: () => CacheInvalidator | null;
|
|
7
|
+
};
|
|
8
|
+
export declare class ApiRequestPipeline<TRequest extends Request = Request, TServer = unknown> {
|
|
9
|
+
private readonly schemaValidator;
|
|
10
|
+
private readonly getRenderContext;
|
|
11
|
+
private readonly getCacheService;
|
|
12
|
+
constructor(options: ApiRequestPipelineOptions);
|
|
13
|
+
match(request: TRequest, apiHandlers: ApiHandler<string, TRequest, TServer>[]): {
|
|
14
|
+
routeConfig: ApiHandler<string, TRequest, TServer>;
|
|
15
|
+
params: Record<string, string | string[]>;
|
|
16
|
+
} | null;
|
|
17
|
+
tryHandle(request: TRequest, apiHandlers: ApiHandler<string, TRequest, TServer>[], serverInstance: TServer | undefined, errorHandler?: ErrorHandler<TRequest, TServer>): Promise<Response | null>;
|
|
18
|
+
execute(request: TRequest, params: Record<string, string | string[]>, routeConfig: ApiHandler<string, TRequest, TServer>, serverInstance: TServer | undefined, errorHandler?: ErrorHandler<TRequest, TServer>): Promise<Response>;
|
|
19
|
+
private createContext;
|
|
20
|
+
private normalizeParams;
|
|
21
|
+
private applyRequestSchema;
|
|
22
|
+
private runMiddlewareChain;
|
|
23
|
+
}
|