@ecopages/core 0.2.0-alpha.1 → 0.2.0-alpha.11
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/CHANGELOG.md +16 -64
- package/README.md +210 -13
- package/package.json +88 -62
- package/src/adapters/README.md +39 -0
- package/src/adapters/abstract/application-adapter.d.ts +28 -2
- package/src/adapters/abstract/application-adapter.js +14 -2
- package/src/adapters/abstract/router-adapter.d.ts +1 -1
- package/src/adapters/abstract/server-adapter.d.ts +2 -2
- package/src/adapters/bun/client-bridge.d.ts +1 -1
- package/src/adapters/bun/create-app.d.ts +4 -12
- package/src/adapters/bun/create-app.js +4 -5
- package/src/adapters/bun/hmr-manager.d.ts +80 -21
- package/src/adapters/bun/hmr-manager.js +163 -56
- package/src/adapters/bun/index.d.ts +2 -3
- package/src/adapters/bun/index.js +3 -3
- package/src/adapters/bun/server-adapter.d.ts +5 -5
- package/src/adapters/bun/server-adapter.js +40 -34
- package/src/adapters/bun/server-lifecycle.d.ts +28 -17
- package/src/adapters/bun/server-lifecycle.js +34 -62
- package/src/{create-app.d.ts → adapters/create-app.d.ts} +9 -6
- package/src/{create-app.js → adapters/create-app.js} +4 -4
- package/src/adapters/index.d.ts +2 -6
- package/src/adapters/index.js +2 -8
- package/src/adapters/node/create-app.d.ts +6 -9
- package/src/adapters/node/create-app.js +12 -6
- package/src/adapters/node/node-client-bridge.d.ts +1 -1
- package/src/adapters/node/node-hmr-manager.d.ts +89 -18
- package/src/adapters/node/node-hmr-manager.js +180 -89
- package/src/adapters/node/server-adapter.d.ts +4 -33
- package/src/adapters/node/server-adapter.js +39 -100
- package/src/adapters/node/static-content-server.d.ts +37 -1
- package/src/adapters/node/static-content-server.js +29 -1
- package/src/adapters/shared/application-adapter.d.ts +1 -1
- package/src/{define-api-handler.d.ts → adapters/shared/define-api-handler.d.ts} +1 -1
- package/src/adapters/shared/explicit-static-route-matcher.d.ts +2 -2
- package/src/adapters/shared/explicit-static-route-matcher.js +4 -1
- package/src/adapters/shared/file-route-middleware-pipeline.d.ts +1 -1
- package/src/adapters/shared/file-route-middleware-pipeline.js +1 -0
- package/src/adapters/shared/fs-server-response-factory.d.ts +2 -2
- package/src/adapters/shared/fs-server-response-factory.js +1 -1
- package/src/adapters/shared/fs-server-response-matcher.d.ts +9 -5
- package/src/adapters/shared/fs-server-response-matcher.js +13 -8
- package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +55 -0
- package/src/adapters/shared/hmr-entrypoint-registrar.js +87 -0
- package/src/adapters/shared/hmr-html-response.d.ts +22 -0
- package/src/adapters/shared/hmr-html-response.js +32 -0
- package/src/adapters/shared/render-context.d.ts +2 -1
- package/src/adapters/shared/render-context.js +6 -3
- package/src/adapters/shared/runtime-bootstrap.d.ts +38 -0
- package/src/adapters/shared/runtime-bootstrap.js +43 -0
- package/src/adapters/shared/server-adapter.d.ts +13 -3
- package/src/adapters/shared/server-adapter.js +42 -5
- package/src/adapters/shared/server-route-handler.d.ts +4 -4
- package/src/adapters/shared/server-route-handler.js +6 -15
- package/src/adapters/shared/server-static-builder.d.ts +38 -6
- package/src/adapters/shared/server-static-builder.js +64 -10
- package/src/build/README.md +107 -0
- package/src/build/build-adapter.d.ts +160 -3
- package/src/build/build-adapter.js +494 -16
- package/src/build/build-manifest.d.ts +27 -0
- package/src/build/build-manifest.js +30 -0
- package/src/build/dev-build-coordinator.d.ts +72 -0
- package/src/build/dev-build-coordinator.js +154 -0
- package/src/build/esbuild-build-adapter.d.ts +15 -6
- package/src/build/esbuild-build-adapter.js +189 -74
- package/src/build/runtime-build-executor.d.ts +14 -0
- package/src/build/runtime-build-executor.js +22 -0
- package/src/build/runtime-specifier-alias-plugin.d.ts +15 -0
- package/src/build/runtime-specifier-alias-plugin.js +35 -0
- package/src/build/runtime-specifier-aliases.d.ts +5 -0
- package/src/build/runtime-specifier-aliases.js +95 -0
- package/src/config/README.md +36 -0
- package/src/config/config-builder.d.ts +52 -18
- package/src/config/config-builder.js +258 -48
- package/src/{constants.d.ts → config/constants.d.ts} +13 -0
- package/src/{constants.js → config/constants.js} +4 -0
- package/src/declarations.d.ts +19 -14
- package/src/dev/sc-server.d.ts +1 -1
- package/src/dev/sc-server.js +1 -1
- package/src/eco/README.md +70 -16
- package/src/eco/component-render-context.d.ts +2 -2
- package/src/eco/component-render-context.js +33 -16
- package/src/eco/eco.browser.d.ts +2 -0
- package/src/eco/eco.browser.js +83 -0
- package/src/eco/eco.js +91 -16
- package/src/eco/eco.types.d.ts +12 -4
- package/src/eco/eco.utils.d.ts +1 -1
- package/src/eco/global-injector-map.d.ts +1 -1
- package/src/eco/lazy-injector-map.d.ts +1 -1
- package/src/hmr/README.md +26 -0
- package/src/hmr/client/hmr-runtime.d.ts +1 -6
- package/src/hmr/client/hmr-runtime.js +30 -7
- package/src/hmr/hmr-strategy.d.ts +8 -7
- package/src/hmr/hmr-strategy.js +22 -7
- package/src/hmr/hmr.postcss.test.e2e.d.ts +1 -0
- package/src/hmr/hmr.postcss.test.e2e.js +31 -0
- package/src/hmr/hmr.test.e2e.js +26 -33
- package/src/hmr/strategies/default-hmr-strategy.d.ts +2 -2
- package/src/hmr/strategies/default-hmr-strategy.js +1 -1
- package/src/hmr/strategies/js-hmr-strategy.d.ts +46 -43
- package/src/hmr/strategies/js-hmr-strategy.js +72 -73
- package/src/index.browser.d.ts +2 -2
- package/src/index.browser.js +1 -1
- package/src/index.d.ts +4 -3
- package/src/index.js +16 -5
- package/src/integrations/ghtml/ghtml-renderer.d.ts +2 -2
- package/src/integrations/ghtml/ghtml-renderer.js +3 -1
- package/src/integrations/ghtml/ghtml.plugin.d.ts +2 -2
- package/src/integrations/ghtml/ghtml.plugin.js +2 -2
- package/src/plugins/README.md +35 -0
- package/src/plugins/alias-resolver-plugin.js +17 -3
- package/src/plugins/eco-component-meta-plugin.d.ts +14 -1
- package/src/plugins/eco-component-meta-plugin.js +27 -21
- package/src/plugins/integration-plugin.d.ts +48 -9
- package/src/plugins/integration-plugin.js +39 -2
- package/src/plugins/processor.d.ts +15 -2
- package/src/plugins/processor.js +16 -2
- package/src/plugins/runtime-capability.d.ts +9 -0
- package/src/plugins/source-transform.d.ts +46 -0
- package/src/plugins/source-transform.js +71 -0
- package/src/route-renderer/GRAPH.md +18 -22
- package/src/route-renderer/README.md +15 -26
- package/src/route-renderer/{component-graph-executor.d.ts → component-graph/component-graph-executor.d.ts} +3 -2
- package/src/route-renderer/{component-graph-executor.js → component-graph/component-graph-executor.js} +2 -3
- package/src/route-renderer/{component-graph.d.ts → component-graph/component-graph.d.ts} +13 -2
- package/src/route-renderer/{component-graph.js → component-graph/component-graph.js} +26 -4
- package/src/route-renderer/component-graph/component-reference.d.ts +11 -0
- package/src/route-renderer/component-graph/component-reference.js +39 -0
- package/src/route-renderer/{marker-graph-resolver.d.ts → component-graph/marker-graph-resolver.d.ts} +9 -6
- package/src/route-renderer/{marker-graph-resolver.js → component-graph/marker-graph-resolver.js} +36 -12
- package/src/route-renderer/{integration-renderer.d.ts → orchestration/integration-renderer.d.ts} +65 -13
- package/src/route-renderer/{integration-renderer.js → orchestration/integration-renderer.js} +206 -30
- package/src/route-renderer/{render-execution.service.d.ts → orchestration/render-execution.service.d.ts} +42 -6
- package/src/route-renderer/orchestration/render-execution.service.js +191 -0
- package/src/route-renderer/{render-preparation.service.d.ts → orchestration/render-preparation.service.d.ts} +13 -4
- package/src/route-renderer/{render-preparation.service.js → orchestration/render-preparation.service.js} +95 -5
- package/src/route-renderer/{dependency-resolver.d.ts → page-loading/dependency-resolver.d.ts} +15 -4
- package/src/route-renderer/{dependency-resolver.js → page-loading/dependency-resolver.js} +18 -4
- package/src/route-renderer/page-loading/page-module-loader.d.ts +89 -0
- package/src/route-renderer/{page-module-loader.js → page-loading/page-module-loader.js} +38 -14
- package/src/route-renderer/route-renderer.d.ts +41 -4
- package/src/route-renderer/route-renderer.js +32 -3
- package/src/router/README.md +97 -0
- package/src/router/client/link-intent.d.ts +53 -0
- package/src/router/client/link-intent.js +34 -0
- package/src/router/client/link-intent.test.browser.d.ts +1 -0
- package/src/router/client/link-intent.test.browser.js +43 -0
- package/src/router/client/navigation-coordinator.d.ts +149 -0
- package/src/router/client/navigation-coordinator.js +215 -0
- package/src/router/{fs-router-scanner.d.ts → server/fs-router-scanner.d.ts} +3 -3
- package/src/router/{fs-router-scanner.js → server/fs-router-scanner.js} +8 -7
- package/src/router/{fs-router.d.ts → server/fs-router.d.ts} +1 -1
- package/src/router/{fs-router.js → server/fs-router.js} +1 -1
- package/src/services/README.md +29 -0
- package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +120 -0
- package/src/services/{asset-processing-service → assets/asset-processing-service}/asset-processing.service.js +91 -10
- package/src/services/{asset-processing-service → assets/asset-processing-service}/asset.factory.d.ts +1 -1
- package/src/services/{asset-processing-service → assets/asset-processing-service}/asset.factory.js +2 -2
- package/src/services/{asset-processing-service → assets/asset-processing-service}/assets.types.d.ts +2 -1
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +55 -0
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +48 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +20 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +41 -0
- package/src/services/assets/asset-processing-service/index.d.ts +5 -0
- package/src/services/assets/asset-processing-service/index.js +5 -0
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.interface.d.ts +2 -2
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.registry.d.ts +2 -2
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-processor.d.ts +1 -1
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-processor.js +9 -4
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-script-processor.d.ts +5 -4
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-script-processor.js +15 -23
- package/src/services/assets/asset-processing-service/processors/index.d.ts +5 -0
- package/src/services/assets/asset-processing-service/processors/index.js +5 -0
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/content-script.processor.d.ts +2 -2
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/content-script.processor.js +1 -1
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/file-script.processor.d.ts +4 -3
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/file-script.processor.js +16 -4
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/node-module-script.processor.d.ts +3 -3
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/node-module-script.processor.js +6 -5
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/content-stylesheet.processor.d.ts +2 -2
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/content-stylesheet.processor.js +1 -1
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/file-stylesheet.processor.d.ts +2 -2
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/file-stylesheet.processor.js +5 -2
- package/src/services/assets/browser-bundle.service.d.ts +32 -0
- package/src/services/assets/browser-bundle.service.js +33 -0
- package/src/services/{page-request-cache-coordinator.service.d.ts → cache/page-request-cache-coordinator.service.d.ts} +2 -2
- package/src/services/{page-request-cache-coordinator.service.js → cache/page-request-cache-coordinator.service.js} +3 -1
- package/src/services/html/html-rewriter-provider.service.d.ts +37 -0
- package/src/services/html/html-rewriter-provider.service.js +68 -0
- package/src/services/html/html-transformer.service.d.ts +77 -0
- package/src/services/html/html-transformer.service.js +215 -0
- package/src/services/invalidation/development-invalidation.service.d.ts +74 -0
- package/src/services/invalidation/development-invalidation.service.js +190 -0
- package/src/services/module-loading/app-module-loader.service.d.ts +25 -0
- package/src/services/module-loading/app-module-loader.service.js +31 -0
- package/src/services/module-loading/app-server-module-transpiler.service.d.ts +24 -0
- package/src/services/module-loading/app-server-module-transpiler.service.js +109 -0
- package/src/services/module-loading/host-module-loader-registry.d.ts +4 -0
- package/src/services/module-loading/host-module-loader-registry.js +15 -0
- package/src/services/module-loading/module-loading-types.d.ts +2 -0
- package/src/services/module-loading/node-bootstrap-plugin.d.ts +22 -0
- package/src/services/module-loading/node-bootstrap-plugin.js +179 -0
- package/src/services/module-loading/page-module-import.service.d.ts +75 -0
- package/src/services/module-loading/page-module-import.service.js +161 -0
- package/src/services/module-loading/server-module-transpiler.service.d.ts +72 -0
- package/src/services/module-loading/server-module-transpiler.service.js +64 -0
- package/src/services/runtime-state/dev-graph.service.d.ts +118 -0
- package/src/services/runtime-state/dev-graph.service.js +162 -0
- package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +41 -0
- package/src/services/runtime-state/entrypoint-dependency-graph.service.js +85 -0
- package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +69 -0
- package/src/services/runtime-state/runtime-specifier-registry.service.js +37 -0
- package/src/services/runtime-state/server-invalidation-state.service.d.ts +26 -0
- package/src/services/runtime-state/server-invalidation-state.service.js +35 -0
- package/src/services/{schema-validation-service.d.ts → validation/schema-validation-service.d.ts} +1 -1
- package/src/static-site-generator/README.md +26 -0
- package/src/static-site-generator/static-site-generator.d.ts +55 -3
- package/src/static-site-generator/static-site-generator.js +86 -5
- package/src/{internal-types.d.ts → types/internal-types.d.ts} +53 -22
- package/src/types/internal-types.js +0 -0
- package/src/{public-types.d.ts → types/public-types.d.ts} +73 -17
- package/src/types/public-types.js +0 -0
- package/src/utils/locals-utils.d.ts +1 -1
- package/src/utils/parse-cli-args.d.ts +4 -1
- package/src/utils/parse-cli-args.js +16 -1
- package/src/utils/resolve-work-dir.d.ts +11 -0
- package/src/utils/resolve-work-dir.js +31 -0
- package/src/watchers/project-watcher.d.ts +40 -24
- package/src/watchers/project-watcher.js +105 -68
- package/src/watchers/project-watcher.test-helpers.d.ts +2 -2
- package/src/watchers/project-watcher.test-helpers.js +1 -0
- package/src/adapters/abstract/application-adapter.ts +0 -337
- package/src/adapters/abstract/router-adapter.ts +0 -30
- package/src/adapters/abstract/server-adapter.ts +0 -79
- package/src/adapters/bun/client-bridge.ts +0 -62
- package/src/adapters/bun/create-app.ts +0 -189
- package/src/adapters/bun/define-api-handler.d.ts +0 -61
- package/src/adapters/bun/define-api-handler.ts +0 -114
- package/src/adapters/bun/hmr-manager.ts +0 -281
- package/src/adapters/bun/index.ts +0 -3
- package/src/adapters/bun/server-adapter.ts +0 -492
- package/src/adapters/bun/server-lifecycle.ts +0 -154
- package/src/adapters/index.ts +0 -6
- package/src/adapters/node/create-app.ts +0 -179
- package/src/adapters/node/index.d.ts +0 -4
- package/src/adapters/node/index.js +0 -8
- package/src/adapters/node/index.ts +0 -9
- package/src/adapters/node/node-client-bridge.ts +0 -79
- package/src/adapters/node/node-hmr-manager.ts +0 -271
- package/src/adapters/node/server-adapter.ts +0 -561
- package/src/adapters/node/static-content-server.ts +0 -203
- package/src/adapters/shared/api-response.ts +0 -104
- package/src/adapters/shared/application-adapter.ts +0 -199
- package/src/adapters/shared/explicit-static-route-matcher.ts +0 -134
- package/src/adapters/shared/file-route-middleware-pipeline.ts +0 -123
- package/src/adapters/shared/fs-server-response-factory.ts +0 -118
- package/src/adapters/shared/fs-server-response-matcher.ts +0 -198
- package/src/adapters/shared/render-context.ts +0 -105
- package/src/adapters/shared/server-adapter.ts +0 -442
- package/src/adapters/shared/server-route-handler.ts +0 -166
- package/src/adapters/shared/server-static-builder.ts +0 -82
- package/src/build/build-adapter.ts +0 -132
- package/src/build/build-types.ts +0 -83
- package/src/build/esbuild-build-adapter.ts +0 -510
- package/src/config/config-builder.ts +0 -474
- package/src/constants.ts +0 -39
- package/src/create-app.ts +0 -87
- package/src/define-api-handler.js +0 -15
- package/src/define-api-handler.ts +0 -66
- package/src/dev/sc-server.ts +0 -143
- package/src/eco/component-render-context.ts +0 -202
- package/src/eco/eco.ts +0 -221
- package/src/eco/eco.types.ts +0 -202
- package/src/eco/eco.utils.ts +0 -89
- package/src/eco/global-injector-map.ts +0 -112
- package/src/eco/lazy-injector-map.ts +0 -120
- package/src/eco/module-dependencies.ts +0 -75
- package/src/errors/http-error.ts +0 -72
- package/src/errors/index.ts +0 -2
- package/src/errors/locals-access-error.ts +0 -7
- package/src/global/app-logger.ts +0 -4
- package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-have-HMR-script-injected-in-page-1.png +0 -0
- package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-load-fixture-app-page-1.png +0 -0
- package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-WebSocket-Connection-should-connect-to-correct-HMR-endpoint-1.png +0 -0
- package/src/hmr/client/hmr-runtime.ts +0 -121
- package/src/hmr/hmr-strategy.ts +0 -172
- package/src/hmr/hmr.test.e2e.ts +0 -75
- package/src/hmr/strategies/default-hmr-strategy.ts +0 -60
- package/src/hmr/strategies/js-hmr-strategy.ts +0 -308
- package/src/index.browser.ts +0 -3
- package/src/index.ts +0 -5
- package/src/integrations/ghtml/ghtml-renderer.ts +0 -93
- package/src/integrations/ghtml/ghtml.plugin.ts +0 -32
- package/src/internal-types.ts +0 -212
- package/src/plugins/alias-resolver-plugin.ts +0 -45
- package/src/plugins/eco-component-meta-plugin.ts +0 -474
- package/src/plugins/integration-plugin.ts +0 -184
- package/src/plugins/processor.ts +0 -220
- package/src/public-types.ts +0 -1255
- package/src/route-renderer/component-graph-executor.ts +0 -84
- package/src/route-renderer/component-graph.ts +0 -159
- package/src/route-renderer/component-marker.ts +0 -117
- package/src/route-renderer/dependency-resolver.ts +0 -596
- package/src/route-renderer/html-post-processing.service.d.ts +0 -40
- package/src/route-renderer/html-post-processing.service.js +0 -86
- package/src/route-renderer/html-post-processing.service.ts +0 -103
- package/src/route-renderer/integration-renderer.ts +0 -696
- package/src/route-renderer/marker-graph-resolver.ts +0 -153
- package/src/route-renderer/page-module-loader.d.ts +0 -61
- package/src/route-renderer/page-module-loader.ts +0 -153
- package/src/route-renderer/render-execution.service.js +0 -91
- package/src/route-renderer/render-execution.service.ts +0 -158
- package/src/route-renderer/render-preparation.service.ts +0 -358
- package/src/route-renderer/route-renderer.ts +0 -80
- package/src/router/fs-router-scanner.ts +0 -217
- package/src/router/fs-router.ts +0 -122
- package/src/services/asset-processing-service/asset-processing.service.d.ts +0 -41
- package/src/services/asset-processing-service/asset-processing.service.ts +0 -306
- package/src/services/asset-processing-service/asset.factory.ts +0 -105
- package/src/services/asset-processing-service/assets.types.ts +0 -112
- package/src/services/asset-processing-service/index.d.ts +0 -3
- package/src/services/asset-processing-service/index.js +0 -3
- package/src/services/asset-processing-service/index.ts +0 -3
- package/src/services/asset-processing-service/processor.interface.ts +0 -27
- package/src/services/asset-processing-service/processor.registry.ts +0 -18
- package/src/services/asset-processing-service/processors/base/base-processor.ts +0 -76
- package/src/services/asset-processing-service/processors/base/base-script-processor.ts +0 -105
- package/src/services/asset-processing-service/processors/index.d.ts +0 -5
- package/src/services/asset-processing-service/processors/index.js +0 -5
- package/src/services/asset-processing-service/processors/index.ts +0 -5
- package/src/services/asset-processing-service/processors/script/content-script.processor.ts +0 -66
- package/src/services/asset-processing-service/processors/script/file-script.processor.ts +0 -88
- package/src/services/asset-processing-service/processors/script/node-module-script.processor.ts +0 -84
- package/src/services/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +0 -27
- package/src/services/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +0 -77
- package/src/services/cache/cache.types.ts +0 -126
- package/src/services/cache/index.ts +0 -18
- package/src/services/cache/memory-cache-store.ts +0 -130
- package/src/services/cache/page-cache-service.ts +0 -202
- package/src/services/html-transformer.service.d.ts +0 -50
- package/src/services/html-transformer.service.js +0 -163
- package/src/services/html-transformer.service.ts +0 -217
- package/src/services/page-module-import.service.d.ts +0 -37
- package/src/services/page-module-import.service.js +0 -88
- package/src/services/page-module-import.service.ts +0 -129
- package/src/services/page-request-cache-coordinator.service.ts +0 -128
- package/src/services/schema-validation-service.ts +0 -204
- package/src/services/validation/standard-schema.types.ts +0 -68
- package/src/static-site-generator/static-site-generator.ts +0 -359
- package/src/utils/css.d.ts +0 -1
- package/src/utils/css.js +0 -7
- package/src/utils/css.ts +0 -5
- package/src/utils/deep-merge.ts +0 -47
- package/src/utils/hash.ts +0 -5
- package/src/utils/html.ts +0 -1
- package/src/utils/invariant.ts +0 -15
- package/src/utils/locals-utils.ts +0 -37
- package/src/utils/parse-cli-args.ts +0 -83
- package/src/utils/path-utils.module.ts +0 -14
- package/src/utils/runtime.ts +0 -44
- package/src/utils/server-utils.module.ts +0 -67
- package/src/watchers/project-watcher.test-helpers.ts +0 -40
- package/src/watchers/project-watcher.ts +0 -306
- /package/src/adapters/{bun → shared}/define-api-handler.js +0 -0
- /package/src/{internal-types.js → plugins/runtime-capability.js} +0 -0
- /package/src/route-renderer/{component-marker.d.ts → component-graph/component-marker.d.ts} +0 -0
- /package/src/route-renderer/{component-marker.js → component-graph/component-marker.js} +0 -0
- /package/src/services/{asset-processing-service → assets/asset-processing-service}/assets.types.js +0 -0
- /package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.interface.js +0 -0
- /package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.registry.js +0 -0
- /package/src/{public-types.js → services/module-loading/module-loading-types.js} +0 -0
- /package/src/services/{schema-validation-service.js → validation/schema-validation-service.js} +0 -0
|
@@ -1,24 +1,60 @@
|
|
|
1
1
|
import { type Server as NodeHttpServer } from 'node:http';
|
|
2
|
-
import type { EcoPagesAppConfig } from '../../internal-types.js';
|
|
2
|
+
import type { EcoPagesAppConfig } from '../../types/internal-types.js';
|
|
3
3
|
type NodeStaticContentServerOptions = {
|
|
4
4
|
hostname?: string;
|
|
5
5
|
port?: number;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Serves prebuilt static Ecopages output through Node's HTTP server.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* This server is used by the Node preview/build path once the app has already
|
|
12
|
+
* emitted its static output. It intentionally stays small: path sanitization,
|
|
13
|
+
* content-type selection, optional gzip serving, and 404 handling.
|
|
14
|
+
*/
|
|
7
15
|
export declare class NodeStaticContentServer {
|
|
8
16
|
private readonly appConfig;
|
|
9
17
|
private readonly options;
|
|
10
18
|
private server;
|
|
19
|
+
/**
|
|
20
|
+
* Creates the Node static-content server for one built app output directory.
|
|
21
|
+
*/
|
|
11
22
|
constructor({ appConfig, options }: {
|
|
12
23
|
appConfig: EcoPagesAppConfig;
|
|
13
24
|
options?: NodeStaticContentServerOptions;
|
|
14
25
|
});
|
|
26
|
+
/**
|
|
27
|
+
* Returns whether the given content type should be served from a pre-gzipped
|
|
28
|
+
* companion file when available.
|
|
29
|
+
*/
|
|
15
30
|
private shouldServeGzip;
|
|
31
|
+
/**
|
|
32
|
+
* Normalizes a request pathname and rejects directory traversal attempts.
|
|
33
|
+
*/
|
|
16
34
|
private sanitizePath;
|
|
35
|
+
/**
|
|
36
|
+
* Writes one HTTP response with the provided headers and optional body.
|
|
37
|
+
*/
|
|
17
38
|
private sendResponse;
|
|
39
|
+
/**
|
|
40
|
+
* Serves the generated 404 page when present, or a plain-text fallback.
|
|
41
|
+
*/
|
|
18
42
|
private sendNotFoundPage;
|
|
43
|
+
/**
|
|
44
|
+
* Serves one concrete file path, honoring gzip and HEAD semantics.
|
|
45
|
+
*/
|
|
19
46
|
private serveFile;
|
|
47
|
+
/**
|
|
48
|
+
* Handles one incoming Node HTTP request against the built static output tree.
|
|
49
|
+
*/
|
|
20
50
|
private handleRequest;
|
|
51
|
+
/**
|
|
52
|
+
* Starts the static preview server.
|
|
53
|
+
*/
|
|
21
54
|
start(): Promise<NodeHttpServer>;
|
|
55
|
+
/**
|
|
56
|
+
* Stops the static preview server and optionally closes active connections.
|
|
57
|
+
*/
|
|
22
58
|
stop(force?: boolean): Promise<void>;
|
|
23
59
|
}
|
|
24
60
|
export {};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { createServer } from "node:http";
|
|
2
2
|
import { extname, join, normalize, sep } from "node:path";
|
|
3
|
-
import { DEFAULT_ECOPAGES_HOSTNAME, DEFAULT_ECOPAGES_PORT, STATUS_MESSAGE } from "../../constants.js";
|
|
3
|
+
import { DEFAULT_ECOPAGES_HOSTNAME, DEFAULT_ECOPAGES_PORT, STATUS_MESSAGE } from "../../config/constants.js";
|
|
4
4
|
import { fileSystem } from "@ecopages/file-system";
|
|
5
5
|
import { ServerUtils } from "../../utils/server-utils.module.js";
|
|
6
6
|
class NodeStaticContentServer {
|
|
7
7
|
appConfig;
|
|
8
8
|
options;
|
|
9
9
|
server = null;
|
|
10
|
+
/**
|
|
11
|
+
* Creates the Node static-content server for one built app output directory.
|
|
12
|
+
*/
|
|
10
13
|
constructor({ appConfig, options }) {
|
|
11
14
|
this.appConfig = appConfig;
|
|
12
15
|
this.options = {
|
|
@@ -14,9 +17,16 @@ class NodeStaticContentServer {
|
|
|
14
17
|
port: options?.port ?? DEFAULT_ECOPAGES_PORT
|
|
15
18
|
};
|
|
16
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns whether the given content type should be served from a pre-gzipped
|
|
22
|
+
* companion file when available.
|
|
23
|
+
*/
|
|
17
24
|
shouldServeGzip(contentType) {
|
|
18
25
|
return ["text/javascript", "text/css"].includes(contentType);
|
|
19
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Normalizes a request pathname and rejects directory traversal attempts.
|
|
29
|
+
*/
|
|
20
30
|
sanitizePath(pathname) {
|
|
21
31
|
const withoutLeadingSlash = pathname.replace(/^\/+/, "");
|
|
22
32
|
const normalizedPath = normalize(withoutLeadingSlash);
|
|
@@ -25,6 +35,9 @@ class NodeStaticContentServer {
|
|
|
25
35
|
}
|
|
26
36
|
return normalizedPath;
|
|
27
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Writes one HTTP response with the provided headers and optional body.
|
|
40
|
+
*/
|
|
28
41
|
sendResponse(res, status, headers, body) {
|
|
29
42
|
res.statusCode = status;
|
|
30
43
|
for (const [key, value] of Object.entries(headers)) {
|
|
@@ -36,6 +49,9 @@ class NodeStaticContentServer {
|
|
|
36
49
|
}
|
|
37
50
|
res.end(body);
|
|
38
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Serves the generated 404 page when present, or a plain-text fallback.
|
|
54
|
+
*/
|
|
39
55
|
sendNotFoundPage(req, res) {
|
|
40
56
|
const error404TemplatePath = join(this.appConfig.absolutePaths.distDir, "404.html");
|
|
41
57
|
const isHead = (req.method ?? "GET").toUpperCase() === "HEAD";
|
|
@@ -51,6 +67,9 @@ class NodeStaticContentServer {
|
|
|
51
67
|
const file = fileSystem.readFileAsBuffer(error404TemplatePath);
|
|
52
68
|
this.sendResponse(res, 404, { "Content-Type": "text/html" }, isHead ? void 0 : file);
|
|
53
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Serves one concrete file path, honoring gzip and HEAD semantics.
|
|
72
|
+
*/
|
|
54
73
|
serveFile(req, res, filePath, status = 200) {
|
|
55
74
|
const contentType = ServerUtils.getContentType(extname(filePath));
|
|
56
75
|
const acceptsGzip = req.headers["accept-encoding"]?.includes("gzip");
|
|
@@ -79,6 +98,9 @@ class NodeStaticContentServer {
|
|
|
79
98
|
const file = fileSystem.readFileAsBuffer(filePath);
|
|
80
99
|
this.sendResponse(res, status, { "Content-Type": contentType }, isHead ? void 0 : file);
|
|
81
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Handles one incoming Node HTTP request against the built static output tree.
|
|
103
|
+
*/
|
|
82
104
|
handleRequest(req, res) {
|
|
83
105
|
const method = (req.method ?? "GET").toUpperCase();
|
|
84
106
|
const isHead = method === "HEAD";
|
|
@@ -129,6 +151,9 @@ class NodeStaticContentServer {
|
|
|
129
151
|
}
|
|
130
152
|
this.sendNotFoundPage(req, res);
|
|
131
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Starts the static preview server.
|
|
156
|
+
*/
|
|
132
157
|
async start() {
|
|
133
158
|
if (this.server) {
|
|
134
159
|
return this.server;
|
|
@@ -141,6 +166,9 @@ class NodeStaticContentServer {
|
|
|
141
166
|
});
|
|
142
167
|
return this.server;
|
|
143
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Stops the static preview server and optionally closes active connections.
|
|
171
|
+
*/
|
|
144
172
|
async stop(force = true) {
|
|
145
173
|
if (!this.server) {
|
|
146
174
|
return;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApiHandler, ApiHandlerContext, Middleware, RouteGroupBuilder, RouteOptions } from '../../public-types.js';
|
|
1
|
+
import type { ApiHandler, ApiHandlerContext, Middleware, RouteGroupBuilder, RouteOptions } from '../../types/public-types.js';
|
|
2
2
|
import { AbstractApplicationAdapter, type ApplicationAdapterOptions, type RouteGroupDefinition, type RouteHandler } from '../abstract/application-adapter.js';
|
|
3
3
|
export declare abstract class SharedApplicationAdapter<TOptions extends ApplicationAdapterOptions = ApplicationAdapterOptions, TServer = any, TRequest extends Request = Request> extends AbstractApplicationAdapter<TOptions, TServer, TRequest> {
|
|
4
4
|
protected register<P extends string, TContext extends ApiHandlerContext<TRequest, TServer> = ApiHandlerContext<TRequest, TServer>>(path: P, method: ApiHandler['method'], handler: RouteHandler<TRequest, TServer, TContext>, options?: RouteOptions<TRequest, TServer, TContext>): this;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApiHandler, ApiHandlerContext, Middleware, RouteSchema, TypedGroupHandlerContext } from '
|
|
1
|
+
import type { ApiHandler, ApiHandlerContext, Middleware, RouteSchema, TypedGroupHandlerContext } from '../../types/public-types.js';
|
|
2
2
|
type UniversalContext = ApiHandlerContext<Request, unknown>;
|
|
3
3
|
type SchemaHandlerContext<TSchema extends RouteSchema | undefined, TContext extends UniversalContext> = TSchema extends RouteSchema ? TypedGroupHandlerContext<TSchema, TContext> : TContext;
|
|
4
4
|
export declare function defineApiHandler<TPath extends string, TSchema extends RouteSchema | undefined = undefined, TContext extends UniversalContext = UniversalContext>(handler: Omit<ApiHandler<TPath, Request, unknown>, 'handler' | 'middleware' | 'schema'> & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { EcoPagesAppConfig } from '../../internal-types.js';
|
|
2
|
-
import type { StaticRoute } from '../../public-types.js';
|
|
1
|
+
import type { EcoPagesAppConfig } from '../../types/internal-types.js';
|
|
2
|
+
import type { StaticRoute } from '../../types/public-types.js';
|
|
3
3
|
import type { RouteRendererFactory } from '../../route-renderer/route-renderer.js';
|
|
4
4
|
export declare const EXPLICIT_STATIC_ROUTE_MATCHER_ERRORS: {
|
|
5
5
|
readonly missingIntegration: (routePath: string) => string;
|
|
@@ -3,6 +3,9 @@ const EXPLICIT_STATIC_ROUTE_MATCHER_ERRORS = {
|
|
|
3
3
|
missingIntegration: (routePath) => `View at ${routePath} is missing __eco.integration. Ensure it's defined with eco.page() and exported as default.`,
|
|
4
4
|
noRendererForIntegration: (integrationName) => `No renderer found for integration: ${integrationName}`
|
|
5
5
|
};
|
|
6
|
+
function getViewIntegrationName(view) {
|
|
7
|
+
return view.config?.integration ?? view.config?.__eco?.integration;
|
|
8
|
+
}
|
|
6
9
|
class ExplicitStaticRouteMatcher {
|
|
7
10
|
appConfig;
|
|
8
11
|
routeRendererFactory;
|
|
@@ -71,7 +74,7 @@ class ExplicitStaticRouteMatcher {
|
|
|
71
74
|
try {
|
|
72
75
|
const mod = await route.loader();
|
|
73
76
|
const view = mod.default;
|
|
74
|
-
const integrationName = view
|
|
77
|
+
const integrationName = getViewIntegrationName(view);
|
|
75
78
|
if (!integrationName) {
|
|
76
79
|
throw new Error(EXPLICIT_STATIC_ROUTE_MATCHER_ERRORS.missingIntegration(route.path));
|
|
77
80
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Middleware, ApiHandlerContext, RequestLocals } from '../../public-types.js';
|
|
1
|
+
import type { Middleware, ApiHandlerContext, RequestLocals } from '../../types/public-types.js';
|
|
2
2
|
import type { PageCacheService } from '../../services/cache/page-cache-service.js';
|
|
3
3
|
export declare const FILE_ROUTE_MIDDLEWARE_PIPELINE_ERRORS: {
|
|
4
4
|
readonly CTX_RENDER_UNAVAILABLE: "[ecopages] ctx.render is not available in file-route middleware";
|
|
@@ -7,6 +7,7 @@ const FILE_ROUTE_MIDDLEWARE_PIPELINE_ERRORS = {
|
|
|
7
7
|
middlewareRequiresDynamic: (filePath) => `[ecopages] Page middleware requires cache: 'dynamic'. Page: ${filePath}`
|
|
8
8
|
};
|
|
9
9
|
class FileRouteMiddlewarePipeline {
|
|
10
|
+
cacheService;
|
|
10
11
|
constructor(cacheService) {
|
|
11
12
|
this.cacheService = cacheService;
|
|
12
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { EcoPagesAppConfig, FileSystemServerOptions } from '../../internal-types.js';
|
|
2
|
-
import type { RouteRendererBody } from '../../public-types.js';
|
|
1
|
+
import type { EcoPagesAppConfig, FileSystemServerOptions } from '../../types/internal-types.js';
|
|
2
|
+
import type { RouteRendererBody } from '../../types/public-types.js';
|
|
3
3
|
import type { RouteRendererFactory } from '../../route-renderer/route-renderer.js';
|
|
4
4
|
export declare class FileSystemServerResponseFactory {
|
|
5
5
|
private appConfig;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { MatchResult } from '../../internal-types.js';
|
|
1
|
+
import type { EcoPagesAppConfig, MatchResult } from '../../types/internal-types.js';
|
|
2
2
|
import type { RouteRendererFactory } from '../../route-renderer/route-renderer.js';
|
|
3
|
-
import type { FSRouter } from '../../router/fs-router.js';
|
|
3
|
+
import type { FSRouter } from '../../router/server/fs-router.js';
|
|
4
4
|
import type { PageCacheService } from '../../services/cache/page-cache-service.js';
|
|
5
5
|
import type { CacheStrategy } from '../../services/cache/cache.types.js';
|
|
6
6
|
import type { FileSystemServerResponseFactory } from './fs-server-response-factory.js';
|
|
@@ -9,6 +9,7 @@ export declare const FILE_SYSTEM_RESPONSE_MATCHER_ERRORS: {
|
|
|
9
9
|
readonly noTranspiledOutputForPageModule: (filePath: string) => string;
|
|
10
10
|
};
|
|
11
11
|
export interface FileSystemResponseMatcherOptions {
|
|
12
|
+
appConfig: EcoPagesAppConfig;
|
|
12
13
|
router: FSRouter;
|
|
13
14
|
routeRendererFactory: RouteRendererFactory;
|
|
14
15
|
fileSystemResponseFactory: FileSystemServerResponseFactory;
|
|
@@ -26,13 +27,14 @@ export interface FileSystemResponseMatcherOptions {
|
|
|
26
27
|
* error translation.
|
|
27
28
|
*/
|
|
28
29
|
export declare class FileSystemResponseMatcher {
|
|
30
|
+
private appConfig;
|
|
29
31
|
private router;
|
|
30
32
|
private routeRendererFactory;
|
|
31
33
|
private fileSystemResponseFactory;
|
|
32
|
-
private
|
|
34
|
+
private serverModuleTranspiler;
|
|
33
35
|
private pageRequestCacheCoordinator;
|
|
34
36
|
private fileRouteMiddlewarePipeline;
|
|
35
|
-
constructor({ router, routeRendererFactory, fileSystemResponseFactory, cacheService, defaultCacheStrategy, }: FileSystemResponseMatcherOptions);
|
|
37
|
+
constructor({ appConfig, router, routeRendererFactory, fileSystemResponseFactory, cacheService, defaultCacheStrategy, }: FileSystemResponseMatcherOptions);
|
|
36
38
|
/**
|
|
37
39
|
* Resolves unmatched paths either as static asset requests or as the custom
|
|
38
40
|
* not-found page.
|
|
@@ -58,7 +60,9 @@ export declare class FileSystemResponseMatcher {
|
|
|
58
60
|
*
|
|
59
61
|
* The matcher needs access to page-level metadata such as `cache` and
|
|
60
62
|
* `middleware` before full rendering starts, so it uses the shared module
|
|
61
|
-
* import service directly rather than going through route rendering.
|
|
63
|
+
* import service directly rather than going through route rendering. The
|
|
64
|
+
* app config is injected explicitly so build ownership stays at the adapter
|
|
65
|
+
* boundary instead of leaking through nested router collaborators.
|
|
62
66
|
*
|
|
63
67
|
* @param filePath Absolute page module path.
|
|
64
68
|
* @returns Imported page module.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { appLogger } from "../../global/app-logger.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { PageRequestCacheCoordinator } from "../../services/cache/page-request-cache-coordinator.service.js";
|
|
4
|
+
import { getAppServerModuleTranspiler } from "../../services/module-loading/app-server-module-transpiler.service.js";
|
|
5
|
+
import { resolveInternalExecutionDir } from "../../utils/resolve-work-dir.js";
|
|
5
6
|
import { ServerUtils } from "../../utils/server-utils.module.js";
|
|
6
7
|
import { FileRouteMiddlewarePipeline } from "./file-route-middleware-pipeline.js";
|
|
7
8
|
import { LocalsAccessError } from "../../errors/locals-access-error.js";
|
|
@@ -11,23 +12,26 @@ const FILE_SYSTEM_RESPONSE_MATCHER_ERRORS = {
|
|
|
11
12
|
noTranspiledOutputForPageModule: (filePath) => `No transpiled output generated for page module: ${filePath}`
|
|
12
13
|
};
|
|
13
14
|
class FileSystemResponseMatcher {
|
|
15
|
+
appConfig;
|
|
14
16
|
router;
|
|
15
17
|
routeRendererFactory;
|
|
16
18
|
fileSystemResponseFactory;
|
|
17
|
-
|
|
19
|
+
serverModuleTranspiler;
|
|
18
20
|
pageRequestCacheCoordinator;
|
|
19
21
|
fileRouteMiddlewarePipeline;
|
|
20
22
|
constructor({
|
|
23
|
+
appConfig,
|
|
21
24
|
router,
|
|
22
25
|
routeRendererFactory,
|
|
23
26
|
fileSystemResponseFactory,
|
|
24
27
|
cacheService = null,
|
|
25
28
|
defaultCacheStrategy = "static"
|
|
26
29
|
}) {
|
|
30
|
+
this.appConfig = appConfig;
|
|
27
31
|
this.router = router;
|
|
28
32
|
this.routeRendererFactory = routeRendererFactory;
|
|
29
33
|
this.fileSystemResponseFactory = fileSystemResponseFactory;
|
|
30
|
-
this.
|
|
34
|
+
this.serverModuleTranspiler = getAppServerModuleTranspiler(appConfig);
|
|
31
35
|
this.pageRequestCacheCoordinator = new PageRequestCacheCoordinator(cacheService, defaultCacheStrategy);
|
|
32
36
|
this.fileRouteMiddlewarePipeline = new FileRouteMiddlewarePipeline(cacheService);
|
|
33
37
|
}
|
|
@@ -128,16 +132,17 @@ class FileSystemResponseMatcher {
|
|
|
128
132
|
*
|
|
129
133
|
* The matcher needs access to page-level metadata such as `cache` and
|
|
130
134
|
* `middleware` before full rendering starts, so it uses the shared module
|
|
131
|
-
* import service directly rather than going through route rendering.
|
|
135
|
+
* import service directly rather than going through route rendering. The
|
|
136
|
+
* app config is injected explicitly so build ownership stays at the adapter
|
|
137
|
+
* boundary instead of leaking through nested router collaborators.
|
|
132
138
|
*
|
|
133
139
|
* @param filePath Absolute page module path.
|
|
134
140
|
* @returns Imported page module.
|
|
135
141
|
*/
|
|
136
142
|
async importPageModule(filePath) {
|
|
137
|
-
return this.
|
|
143
|
+
return this.serverModuleTranspiler.importModule({
|
|
138
144
|
filePath,
|
|
139
|
-
|
|
140
|
-
outdir: path.join(this.router.assetPrefix, ".server-modules-meta"),
|
|
145
|
+
outdir: path.join(resolveInternalExecutionDir(this.appConfig), ".server-modules-meta"),
|
|
141
146
|
transpileErrorMessage: FILE_SYSTEM_RESPONSE_MATCHER_ERRORS.transpilePageModuleFailed,
|
|
142
147
|
noOutputMessage: FILE_SYSTEM_RESPONSE_MATCHER_ERRORS.noTranspiledOutputForPageModule
|
|
143
148
|
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared runtime state used while registering HMR-owned entrypoints.
|
|
3
|
+
*/
|
|
4
|
+
export interface HmrEntrypointRegistrarOptions {
|
|
5
|
+
/** Absolute source directory used to derive the emitted HMR path. */
|
|
6
|
+
srcDir: string;
|
|
7
|
+
/** Absolute distribution directory where HMR outputs are written. */
|
|
8
|
+
distDir: string;
|
|
9
|
+
/** In-flight registrations keyed by normalized absolute entrypoint path. */
|
|
10
|
+
entrypointRegistrations: Map<string, Promise<string>>;
|
|
11
|
+
/** Stable entrypoint-to-output mapping retained once an entrypoint is registered. */
|
|
12
|
+
watchedFiles: Map<string, string>;
|
|
13
|
+
/** Runtime-specific cleanup invoked when an entrypoint registration fails. */
|
|
14
|
+
clearFailedRegistration?: (entrypointPath: string) => void;
|
|
15
|
+
/** Development-only guardrail for integrations that never finish producing output. */
|
|
16
|
+
registrationTimeoutMs: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Runtime-specific hooks required to materialize a single HMR entrypoint.
|
|
20
|
+
*/
|
|
21
|
+
export interface HmrEntrypointRegistrationOptions {
|
|
22
|
+
/**
|
|
23
|
+
* Emits the browser-consumable HMR artifact for an entrypoint.
|
|
24
|
+
*/
|
|
25
|
+
emit(entrypointPath: string, outputPath: string): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Creates the runtime-specific error raised when the emit hook completes without producing output.
|
|
28
|
+
*/
|
|
29
|
+
getMissingOutputError(entrypointPath: string, outputPath: string): Error;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Coordinates the shared HMR entrypoint registration lifecycle for both Node and Bun managers.
|
|
33
|
+
*
|
|
34
|
+
* The registrar owns the cross-runtime policy: normalize entrypoint identities, dedupe concurrent
|
|
35
|
+
* registrations, derive the emitted `_hmr` output path, clear stale output before rebuilding, and
|
|
36
|
+
* apply the development timeout that prevents unresolved registrations from hanging navigation.
|
|
37
|
+
* Runtime-specific managers remain responsible for the actual emit step and any cleanup outside
|
|
38
|
+
* this shared registration flow.
|
|
39
|
+
*/
|
|
40
|
+
export declare class HmrEntrypointRegistrar {
|
|
41
|
+
private readonly options;
|
|
42
|
+
constructor(options: HmrEntrypointRegistrarOptions);
|
|
43
|
+
/**
|
|
44
|
+
* Registers a single source entrypoint and returns the browser URL for its emitted HMR module.
|
|
45
|
+
*
|
|
46
|
+
* Concurrent requests for the same normalized entrypoint share the same in-flight promise so the
|
|
47
|
+
* integration only builds once per registration cycle.
|
|
48
|
+
*/
|
|
49
|
+
registerEntrypoint(entrypointPath: string, registrationOptions: HmrEntrypointRegistrationOptions): Promise<string>;
|
|
50
|
+
private registerEntrypointInternal;
|
|
51
|
+
private awaitEntrypointRegistration;
|
|
52
|
+
private getEntrypointOutput;
|
|
53
|
+
private removeStaleEntrypointOutput;
|
|
54
|
+
private encodeDynamicSegments;
|
|
55
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileSystem } from "@ecopages/file-system";
|
|
3
|
+
import { appLogger } from "../../global/app-logger.js";
|
|
4
|
+
import { RESOLVED_ASSETS_DIR } from "../../config/constants.js";
|
|
5
|
+
class HmrEntrypointRegistrar {
|
|
6
|
+
options;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.options = options;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Registers a single source entrypoint and returns the browser URL for its emitted HMR module.
|
|
12
|
+
*
|
|
13
|
+
* Concurrent requests for the same normalized entrypoint share the same in-flight promise so the
|
|
14
|
+
* integration only builds once per registration cycle.
|
|
15
|
+
*/
|
|
16
|
+
async registerEntrypoint(entrypointPath, registrationOptions) {
|
|
17
|
+
const normalizedEntrypoint = path.resolve(entrypointPath);
|
|
18
|
+
const existingRegistration = this.options.entrypointRegistrations.get(normalizedEntrypoint);
|
|
19
|
+
if (existingRegistration) {
|
|
20
|
+
return await this.awaitEntrypointRegistration(existingRegistration, normalizedEntrypoint);
|
|
21
|
+
}
|
|
22
|
+
const registration = this.registerEntrypointInternal(normalizedEntrypoint, registrationOptions);
|
|
23
|
+
this.options.entrypointRegistrations.set(normalizedEntrypoint, registration);
|
|
24
|
+
try {
|
|
25
|
+
return await this.awaitEntrypointRegistration(registration, normalizedEntrypoint);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
this.options.clearFailedRegistration?.(normalizedEntrypoint);
|
|
28
|
+
throw error;
|
|
29
|
+
} finally {
|
|
30
|
+
this.options.entrypointRegistrations.delete(normalizedEntrypoint);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async registerEntrypointInternal(entrypointPath, registrationOptions) {
|
|
34
|
+
if (this.options.watchedFiles.has(entrypointPath)) {
|
|
35
|
+
return this.options.watchedFiles.get(entrypointPath);
|
|
36
|
+
}
|
|
37
|
+
const { outputPath, outputUrl } = this.getEntrypointOutput(entrypointPath);
|
|
38
|
+
this.options.watchedFiles.set(entrypointPath, outputUrl);
|
|
39
|
+
this.removeStaleEntrypointOutput(outputPath);
|
|
40
|
+
await registrationOptions.emit(entrypointPath, outputPath);
|
|
41
|
+
if (!fileSystem.exists(outputPath)) {
|
|
42
|
+
throw registrationOptions.getMissingOutputError(entrypointPath, outputPath);
|
|
43
|
+
}
|
|
44
|
+
return outputUrl;
|
|
45
|
+
}
|
|
46
|
+
async awaitEntrypointRegistration(registration, entrypointPath) {
|
|
47
|
+
if (process.env.NODE_ENV !== "development") {
|
|
48
|
+
return await registration;
|
|
49
|
+
}
|
|
50
|
+
return await Promise.race([
|
|
51
|
+
registration,
|
|
52
|
+
new Promise((_, reject) => {
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
reject(new Error(`[HMR] Timed out registering entrypoint: ${entrypointPath}`));
|
|
55
|
+
}, this.options.registrationTimeoutMs);
|
|
56
|
+
})
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
getEntrypointOutput(entrypointPath) {
|
|
60
|
+
const relativePath = path.relative(this.options.srcDir, entrypointPath);
|
|
61
|
+
const relativePathJs = relativePath.replace(/\.(tsx?|jsx?|mdx?)$/, ".js");
|
|
62
|
+
const encodedPathJs = this.encodeDynamicSegments(relativePathJs);
|
|
63
|
+
const urlPath = encodedPathJs.split(path.sep).join("/");
|
|
64
|
+
return {
|
|
65
|
+
outputUrl: `/${path.join(RESOLVED_ASSETS_DIR, "_hmr", urlPath)}`,
|
|
66
|
+
outputPath: path.join(this.options.distDir, urlPath)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
removeStaleEntrypointOutput(outputPath) {
|
|
70
|
+
if (!fileSystem.exists(outputPath)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
fileSystem.remove(outputPath);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
appLogger.warn(
|
|
77
|
+
`[HMR] Failed to remove stale entrypoint output ${outputPath}: ${error instanceof Error ? error.message : String(error)}`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
encodeDynamicSegments(filepath) {
|
|
82
|
+
return filepath.replace(/\[([^\]]+)\]/g, "_$1_");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export {
|
|
86
|
+
HmrEntrypointRegistrar
|
|
87
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { IHmrManager } from '../../types/public-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns whether a response is HTML and therefore eligible for development HMR
|
|
4
|
+
* runtime injection.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isHtmlResponse(response: Response): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Returns whether HTML responses should receive the HMR runtime bootstrap.
|
|
9
|
+
*
|
|
10
|
+
* This is shared because filesystem page responses and adapter-level HTML
|
|
11
|
+
* responses flow through different layers, but both need identical injection
|
|
12
|
+
* behavior in watch mode.
|
|
13
|
+
*/
|
|
14
|
+
export declare function shouldInjectHmrHtmlResponse(watch: boolean, hmrManager?: Pick<IHmrManager, 'isEnabled'>): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Injects the development HMR runtime script into an HTML response if it is not
|
|
17
|
+
* already present.
|
|
18
|
+
*
|
|
19
|
+
* The check is intentionally idempotent because an HTML response can pass
|
|
20
|
+
* through more than one development-layer wrapper before reaching the client.
|
|
21
|
+
*/
|
|
22
|
+
export declare function injectHmrRuntimeIntoHtmlResponse(response: Response): Promise<Response>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const HMR_RUNTIME_IMPORT = "import '/_hmr_runtime.js'";
|
|
2
|
+
const HMR_RUNTIME_SCRIPT = `<script type="module">${HMR_RUNTIME_IMPORT};<\/script>`;
|
|
3
|
+
function isHtmlResponse(response) {
|
|
4
|
+
const contentType = response.headers.get("Content-Type");
|
|
5
|
+
return contentType !== null && contentType.startsWith("text/html");
|
|
6
|
+
}
|
|
7
|
+
function shouldInjectHmrHtmlResponse(watch, hmrManager) {
|
|
8
|
+
return watch && hmrManager?.isEnabled() === true;
|
|
9
|
+
}
|
|
10
|
+
async function injectHmrRuntimeIntoHtmlResponse(response) {
|
|
11
|
+
const html = await response.text();
|
|
12
|
+
if (html.includes(HMR_RUNTIME_IMPORT)) {
|
|
13
|
+
return new Response(html, {
|
|
14
|
+
status: response.status,
|
|
15
|
+
statusText: response.statusText,
|
|
16
|
+
headers: response.headers
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const updatedHtml = html.replace(/<\/html>/i, `${HMR_RUNTIME_SCRIPT}</html>`);
|
|
20
|
+
const headers = new Headers(response.headers);
|
|
21
|
+
headers.delete("Content-Length");
|
|
22
|
+
return new Response(updatedHtml, {
|
|
23
|
+
status: response.status,
|
|
24
|
+
statusText: response.statusText,
|
|
25
|
+
headers
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
injectHmrRuntimeIntoHtmlResponse,
|
|
30
|
+
isHtmlResponse,
|
|
31
|
+
shouldInjectHmrHtmlResponse
|
|
32
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { RenderContext } from '../../public-types.js';
|
|
1
|
+
import type { RenderContext } from '../../types/public-types.js';
|
|
2
2
|
import type { IntegrationPlugin } from '../../plugins/integration-plugin.js';
|
|
3
3
|
export interface CreateRenderContextOptions {
|
|
4
4
|
integrations: IntegrationPlugin[];
|
|
5
|
+
rendererModules?: unknown;
|
|
5
6
|
}
|
|
6
7
|
/**
|
|
7
8
|
* Creates a render context for route handlers.
|
|
@@ -15,12 +15,14 @@ function createRenderContext(options) {
|
|
|
15
15
|
);
|
|
16
16
|
const integration = integrations.find((i) => i.name === integrationName);
|
|
17
17
|
invariant(!!integration, `No integration found for: ${integrationName}`);
|
|
18
|
-
return integration.initializeRenderer(
|
|
18
|
+
return integration.initializeRenderer({
|
|
19
|
+
rendererModules: options.rendererModules
|
|
20
|
+
});
|
|
19
21
|
};
|
|
20
|
-
|
|
22
|
+
const renderContext = {
|
|
21
23
|
async render(view, props, renderOptions) {
|
|
22
24
|
const locals = this?.locals;
|
|
23
|
-
const mergedProps = mergePropsWithLocals(props, locals);
|
|
25
|
+
const mergedProps = mergePropsWithLocals(props ?? {}, locals);
|
|
24
26
|
const renderer = getRendererForView(view);
|
|
25
27
|
const ctx = {
|
|
26
28
|
partial: false,
|
|
@@ -63,6 +65,7 @@ function createRenderContext(options) {
|
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
67
|
};
|
|
68
|
+
return renderContext;
|
|
66
69
|
}
|
|
67
70
|
export {
|
|
68
71
|
createRenderContext
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type BuildExecutor } from '../../build/build-adapter.js';
|
|
2
|
+
import type { EcoBuildPlugin } from '../../build/build-types.js';
|
|
3
|
+
import type { EcoPagesAppConfig, IClientBridge, IHmrManager } from '../../types/internal-types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Installs and returns the app-owned runtime build executor used by adapter
|
|
6
|
+
* startup and follow-up runtime work.
|
|
7
|
+
*/
|
|
8
|
+
export declare function installSharedRuntimeBuildExecutor(appConfig: EcoPagesAppConfig, options: {
|
|
9
|
+
development: boolean;
|
|
10
|
+
}): BuildExecutor;
|
|
11
|
+
/**
|
|
12
|
+
* Copies app public assets into dist and ensures the resolved assets directory
|
|
13
|
+
* exists before request handling begins.
|
|
14
|
+
*/
|
|
15
|
+
export declare function prepareSharedRuntimePublicDir(appConfig: EcoPagesAppConfig): void;
|
|
16
|
+
/**
|
|
17
|
+
* Runs runtime plugin setup against app-owned config/runtime state and optional
|
|
18
|
+
* host plugin registration hooks.
|
|
19
|
+
*/
|
|
20
|
+
export declare function initializeSharedRuntimePlugins(options: {
|
|
21
|
+
appConfig: EcoPagesAppConfig;
|
|
22
|
+
runtimeOrigin: string;
|
|
23
|
+
hmrManager?: IHmrManager;
|
|
24
|
+
onRuntimePlugin?: (plugin: unknown) => void;
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Starts shared project watching for runtime adapters.
|
|
28
|
+
*/
|
|
29
|
+
export declare function startSharedProjectWatching(options: {
|
|
30
|
+
appConfig: EcoPagesAppConfig;
|
|
31
|
+
refreshRouterRoutesCallback: () => Promise<void>;
|
|
32
|
+
hmrManager: IHmrManager;
|
|
33
|
+
bridge: IClientBridge;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Binds a runtime HMR manager to app-owned plugin and integration state.
|
|
37
|
+
*/
|
|
38
|
+
export declare function bindSharedRuntimeHmrManager(appConfig: EcoPagesAppConfig, hmrManager: IHmrManager): EcoBuildPlugin[];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileSystem } from "@ecopages/file-system";
|
|
3
|
+
import { getAppBrowserBuildPlugins, setupAppRuntimePlugins } from "../../build/build-adapter.js";
|
|
4
|
+
import { installAppRuntimeBuildExecutor } from "../../build/runtime-build-executor.js";
|
|
5
|
+
import { RESOLVED_ASSETS_DIR } from "../../config/constants.js";
|
|
6
|
+
import { ProjectWatcher } from "../../watchers/project-watcher.js";
|
|
7
|
+
function installSharedRuntimeBuildExecutor(appConfig, options) {
|
|
8
|
+
return installAppRuntimeBuildExecutor(appConfig, options);
|
|
9
|
+
}
|
|
10
|
+
function prepareSharedRuntimePublicDir(appConfig) {
|
|
11
|
+
const srcPublicDir = path.join(appConfig.rootDir, appConfig.srcDir, appConfig.publicDir);
|
|
12
|
+
if (fileSystem.exists(srcPublicDir)) {
|
|
13
|
+
fileSystem.copyDir(srcPublicDir, path.join(appConfig.rootDir, appConfig.distDir));
|
|
14
|
+
}
|
|
15
|
+
fileSystem.ensureDir(path.join(appConfig.absolutePaths.distDir, RESOLVED_ASSETS_DIR));
|
|
16
|
+
}
|
|
17
|
+
async function initializeSharedRuntimePlugins(options) {
|
|
18
|
+
await setupAppRuntimePlugins(options);
|
|
19
|
+
}
|
|
20
|
+
async function startSharedProjectWatching(options) {
|
|
21
|
+
const watcher = new ProjectWatcher({
|
|
22
|
+
config: options.appConfig,
|
|
23
|
+
refreshRouterRoutesCallback: options.refreshRouterRoutesCallback,
|
|
24
|
+
hmrManager: options.hmrManager,
|
|
25
|
+
bridge: options.bridge
|
|
26
|
+
});
|
|
27
|
+
await watcher.createWatcherSubscription();
|
|
28
|
+
}
|
|
29
|
+
function bindSharedRuntimeHmrManager(appConfig, hmrManager) {
|
|
30
|
+
const browserBuildPlugins = getAppBrowserBuildPlugins(appConfig);
|
|
31
|
+
hmrManager.setPlugins(browserBuildPlugins);
|
|
32
|
+
for (const integration of appConfig.integrations) {
|
|
33
|
+
integration.setHmrManager(hmrManager);
|
|
34
|
+
}
|
|
35
|
+
return browserBuildPlugins;
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
bindSharedRuntimeHmrManager,
|
|
39
|
+
initializeSharedRuntimePlugins,
|
|
40
|
+
installSharedRuntimeBuildExecutor,
|
|
41
|
+
prepareSharedRuntimePublicDir,
|
|
42
|
+
startSharedProjectWatching
|
|
43
|
+
};
|