@ecopages/core 0.2.0-alpha.1 → 0.2.0-alpha.10
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 +13 -70
- package/README.md +213 -12
- package/package.json +50 -18
- package/src/adapters/README.md +39 -0
- package/src/adapters/bun/hmr-manager.d.ts +77 -18
- package/src/adapters/bun/hmr-manager.js +159 -52
- package/src/adapters/bun/index.d.ts +1 -2
- package/src/adapters/bun/index.js +1 -1
- package/src/adapters/bun/server-adapter.js +35 -30
- package/src/adapters/bun/server-lifecycle.d.ts +24 -13
- package/src/adapters/bun/server-lifecycle.js +32 -60
- package/src/adapters/index.d.ts +1 -1
- package/src/adapters/index.js +1 -1
- package/src/adapters/node/bootstrap-dependency-resolver.d.ts +44 -0
- package/src/adapters/node/bootstrap-dependency-resolver.js +172 -0
- package/src/adapters/node/index.d.ts +2 -0
- package/src/adapters/node/index.js +3 -0
- package/src/adapters/node/node-hmr-manager.d.ts +87 -16
- package/src/adapters/node/node-hmr-manager.js +179 -88
- package/src/adapters/node/runtime-adapter.d.ts +46 -0
- package/src/adapters/node/runtime-adapter.js +306 -0
- package/src/adapters/node/server-adapter.d.ts +2 -31
- package/src/adapters/node/server-adapter.js +31 -93
- package/src/adapters/node/static-content-server.d.ts +36 -0
- package/src/adapters/node/static-content-server.js +28 -0
- package/src/adapters/node/write-runtime-manifest.d.ts +26 -0
- package/src/adapters/node/write-runtime-manifest.js +12 -0
- package/src/{define-api-handler.d.ts → adapters/shared/define-api-handler.d.ts} +1 -1
- package/src/adapters/shared/explicit-static-route-matcher.js +4 -1
- package/src/adapters/shared/file-route-middleware-pipeline.js +1 -0
- 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.js +3 -2
- 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 +12 -2
- package/src/adapters/shared/server-adapter.js +37 -4
- package/src/adapters/shared/server-route-handler.d.ts +1 -1
- package/src/adapters/shared/server-route-handler.js +4 -13
- package/src/adapters/shared/server-static-builder.d.ts +35 -3
- package/src/adapters/shared/server-static-builder.js +59 -6
- package/src/build/README.md +101 -0
- package/src/build/build-adapter.d.ts +114 -2
- package/src/build/build-adapter.js +119 -5
- 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 +74 -0
- package/src/build/dev-build-coordinator.js +161 -0
- package/src/build/esbuild-build-adapter.d.ts +9 -6
- package/src/build/esbuild-build-adapter.js +103 -71
- package/src/build/runtime-build-executor.d.ts +13 -0
- package/src/build/runtime-build-executor.js +20 -0
- package/src/build/runtime-specifier-alias-plugin.d.ts +15 -0
- package/src/build/runtime-specifier-alias-plugin.js +31 -0
- package/src/config/README.md +33 -0
- package/src/config/config-builder.d.ts +28 -17
- package/src/config/config-builder.js +221 -48
- package/src/constants.d.ts +13 -0
- package/src/constants.js +4 -0
- package/src/declarations.d.ts +18 -13
- package/src/eco/README.md +70 -16
- package/src/eco/component-render-context.d.ts +1 -1
- package/src/eco/component-render-context.js +26 -16
- package/src/eco/eco.js +16 -12
- package/src/eco/eco.types.d.ts +12 -4
- 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.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/js-hmr-strategy.d.ts +45 -42
- package/src/hmr/strategies/js-hmr-strategy.js +70 -71
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -1
- package/src/integrations/ghtml/ghtml-renderer.d.ts +1 -1
- package/src/integrations/ghtml/ghtml-renderer.js +3 -1
- package/src/internal-types.d.ts +39 -18
- package/src/plugins/README.md +34 -0
- package/src/plugins/alias-resolver-plugin.js +17 -3
- package/src/plugins/eco-component-meta-plugin.d.ts +2 -0
- package/src/plugins/eco-component-meta-plugin.js +1 -1
- package/src/plugins/integration-plugin.d.ts +38 -4
- package/src/plugins/integration-plugin.js +34 -1
- package/src/plugins/processor.d.ts +14 -1
- package/src/plugins/processor.js +15 -1
- package/src/plugins/runtime-capability.d.ts +9 -0
- package/src/public-types.d.ts +65 -10
- package/src/route-renderer/GRAPH.md +16 -20
- package/src/route-renderer/README.md +8 -21
- package/src/route-renderer/component-graph/component-reference.d.ts +10 -0
- package/src/route-renderer/component-graph/component-reference.js +19 -0
- package/src/route-renderer/{marker-graph-resolver.d.ts → component-graph/marker-graph-resolver.d.ts} +6 -5
- package/src/route-renderer/{marker-graph-resolver.js → component-graph/marker-graph-resolver.js} +10 -8
- package/src/route-renderer/{integration-renderer.d.ts → orchestration/integration-renderer.d.ts} +45 -12
- package/src/route-renderer/{integration-renderer.js → orchestration/integration-renderer.js} +79 -16
- package/src/route-renderer/{render-execution.service.d.ts → orchestration/render-execution.service.d.ts} +39 -5
- package/src/route-renderer/{render-execution.service.js → orchestration/render-execution.service.js} +58 -28
- 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} +92 -3
- 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 +87 -0
- package/src/route-renderer/{page-module-loader.js → page-loading/page-module-loader.js} +36 -14
- package/src/route-renderer/route-renderer.d.ts +36 -1
- package/src/route-renderer/route-renderer.js +19 -0
- package/src/router/README.md +26 -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 +88 -7
- 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/assets.types.js +0 -0
- 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/{asset-processing-service → assets/asset-processing-service}/index.d.ts +2 -0
- package/src/services/{asset-processing-service → assets/asset-processing-service}/index.js +2 -0
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.interface.d.ts +1 -1
- 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 +3 -2
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-script-processor.js +14 -22
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/file-script.processor.d.ts +1 -1
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/file-script.processor.js +2 -2
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/node-module-script.processor.js +5 -4
- package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/file-stylesheet.processor.js +4 -1
- 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 +65 -0
- package/src/services/html/html-transformer.service.d.ts +77 -0
- package/src/services/html/html-transformer.service.js +221 -0
- package/src/services/invalidation/development-invalidation.service.d.ts +74 -0
- package/src/services/invalidation/development-invalidation.service.js +189 -0
- package/src/services/module-loading/app-server-module-transpiler.service.d.ts +16 -0
- package/src/services/module-loading/app-server-module-transpiler.service.js +34 -0
- package/src/services/module-loading/page-module-import.service.d.ts +71 -0
- package/src/services/module-loading/page-module-import.service.js +132 -0
- package/src/services/module-loading/server-loader.service.d.ts +96 -0
- package/src/services/module-loading/server-loader.service.js +32 -0
- package/src/services/module-loading/server-module-transpiler.service.d.ts +69 -0
- package/src/services/module-loading/server-module-transpiler.service.js +61 -0
- package/src/services/runtime-manifest/node-runtime-manifest.service.d.ts +35 -0
- package/src/services/runtime-manifest/node-runtime-manifest.service.js +60 -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 +53 -1
- package/src/static-site-generator/static-site-generator.js +86 -5
- 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 +37 -21
- package/src/watchers/project-watcher.js +109 -66
- 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.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.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.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.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.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/{services/asset-processing-service/assets.types.js → plugins/runtime-capability.js} +0 -0
- /package/src/route-renderer/{component-graph-executor.d.ts → component-graph/component-graph-executor.d.ts} +0 -0
- /package/src/route-renderer/{component-graph-executor.js → component-graph/component-graph-executor.js} +0 -0
- /package/src/route-renderer/{component-graph.d.ts → component-graph/component-graph.d.ts} +0 -0
- /package/src/route-renderer/{component-graph.js → component-graph/component-graph.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}/asset.factory.d.ts +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.d.ts +0 -0
- /package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.registry.js +0 -0
- /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/index.d.ts +0 -0
- /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/index.js +0 -0
- /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/content-script.processor.d.ts +0 -0
- /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/content-script.processor.js +0 -0
- /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/node-module-script.processor.d.ts +0 -0
- /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/content-stylesheet.processor.d.ts +0 -0
- /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/content-stylesheet.processor.js +0 -0
- /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/file-stylesheet.processor.d.ts +0 -0
- /package/src/services/{schema-validation-service.js → validation/schema-validation-service.js} +0 -0
|
@@ -2,13 +2,13 @@ import path from "node:path";
|
|
|
2
2
|
import { fileSystem } from "@ecopages/file-system";
|
|
3
3
|
import { HmrStrategy, HmrStrategyType } from "../hmr-strategy";
|
|
4
4
|
import { appLogger } from "../../global/app-logger";
|
|
5
|
-
import { defaultBuildAdapter } from "../../build/build-adapter.js";
|
|
6
5
|
class JsHmrStrategy extends HmrStrategy {
|
|
6
|
+
type = HmrStrategyType.SCRIPT;
|
|
7
|
+
context;
|
|
7
8
|
constructor(context) {
|
|
8
9
|
super();
|
|
9
10
|
this.context = context;
|
|
10
11
|
}
|
|
11
|
-
type = HmrStrategyType.SCRIPT;
|
|
12
12
|
/**
|
|
13
13
|
* Determines if the file is a JS/TS file that could affect registered entrypoints.
|
|
14
14
|
*
|
|
@@ -23,10 +23,25 @@ class JsHmrStrategy extends HmrStrategy {
|
|
|
23
23
|
const watchedFiles = this.context.getWatchedFiles();
|
|
24
24
|
const isJsTs = /\.(ts|tsx|js|jsx)$/.test(filePath);
|
|
25
25
|
const isInSrc = filePath.startsWith(this.context.getSrcDir());
|
|
26
|
+
const isRouteTemplate = filePath.startsWith(this.context.getPagesDir()) || filePath.startsWith(this.context.getLayoutsDir());
|
|
27
|
+
const isIntegrationTemplate = isRouteTemplate && this.context.getTemplateExtensions().some((extension) => filePath.endsWith(extension));
|
|
26
28
|
if (watchedFiles.size === 0) {
|
|
27
29
|
return false;
|
|
28
30
|
}
|
|
29
|
-
|
|
31
|
+
if (!isJsTs || !isInSrc) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (isIntegrationTemplate) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if (watchedFiles.has(filePath)) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
const entrypointDependencyGraph = this.context.getEntrypointDependencyGraph();
|
|
41
|
+
if (entrypointDependencyGraph.supportsSelectiveInvalidation()) {
|
|
42
|
+
return entrypointDependencyGraph.getDependencyEntrypoints(filePath).size > 0;
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
30
45
|
}
|
|
31
46
|
/**
|
|
32
47
|
* Processes a file change by rebuilding affected entrypoints.
|
|
@@ -36,6 +51,8 @@ class JsHmrStrategy extends HmrStrategy {
|
|
|
36
51
|
* @remarks
|
|
37
52
|
* If runtime-specific dependency graph hooks are unavailable, this strategy
|
|
38
53
|
* falls back to rebuilding all watched entrypoints.
|
|
54
|
+
* When multiple entrypoints are impacted they are bundled in a single esbuild
|
|
55
|
+
* invocation to share AST parsing and chunk deduplication.
|
|
39
56
|
* @returns Action to broadcast update events
|
|
40
57
|
*/
|
|
41
58
|
async process(filePath) {
|
|
@@ -45,24 +62,37 @@ class JsHmrStrategy extends HmrStrategy {
|
|
|
45
62
|
appLogger.debug(`[JsHmrStrategy] No watched files to rebuild`);
|
|
46
63
|
return { type: "none" };
|
|
47
64
|
}
|
|
48
|
-
const
|
|
49
|
-
let reloadRequired = false;
|
|
50
|
-
const dependencyHits = this.context.getDependencyEntrypoints?.(filePath) ?? /* @__PURE__ */ new Set();
|
|
65
|
+
const dependencyHits = this.context.getEntrypointDependencyGraph().getDependencyEntrypoints(filePath);
|
|
51
66
|
const hasDependencyHit = dependencyHits.size > 0;
|
|
52
67
|
const impactedEntrypoints = hasDependencyHit ? Array.from(dependencyHits).filter((entrypoint) => watchedFiles.has(entrypoint)) : Array.from(watchedFiles.keys());
|
|
68
|
+
const buildableEntrypoints = impactedEntrypoints.filter(
|
|
69
|
+
(entrypoint) => this.context.shouldProcessEntrypoint?.(entrypoint) ?? true
|
|
70
|
+
);
|
|
53
71
|
if (!hasDependencyHit) {
|
|
54
72
|
appLogger.debug("[JsHmrStrategy] Dependency graph miss, rebuilding all watched entrypoints");
|
|
55
73
|
}
|
|
56
|
-
|
|
74
|
+
if (buildableEntrypoints.length === 0) {
|
|
75
|
+
return { type: "none" };
|
|
76
|
+
}
|
|
77
|
+
const buildResult = await this.bundleEntrypoints(buildableEntrypoints);
|
|
78
|
+
if (!buildResult.success) {
|
|
79
|
+
return { type: "none" };
|
|
80
|
+
}
|
|
81
|
+
const updates = [];
|
|
82
|
+
let reloadRequired = false;
|
|
83
|
+
for (const entrypoint of buildableEntrypoints) {
|
|
57
84
|
const outputUrl = watchedFiles.get(entrypoint);
|
|
58
|
-
if (!outputUrl)
|
|
59
|
-
|
|
85
|
+
if (!outputUrl) continue;
|
|
86
|
+
if (buildResult.dependencies) {
|
|
87
|
+
const entrypointDeps = buildResult.dependencies.get(path.resolve(entrypoint)) ?? [];
|
|
88
|
+
this.context.getEntrypointDependencyGraph().setEntrypointDependencies(entrypoint, entrypointDeps);
|
|
60
89
|
}
|
|
61
|
-
const
|
|
90
|
+
const srcDir = this.context.getSrcDir();
|
|
91
|
+
const relativePath = path.relative(srcDir, entrypoint);
|
|
92
|
+
const relativePathJs = relativePath.replace(/\.(tsx?|jsx?|mdx?)$/, ".js");
|
|
93
|
+
const outputPath = path.join(this.context.getDistDir(), relativePathJs);
|
|
94
|
+
const result = await this.processOutput(outputPath, outputUrl);
|
|
62
95
|
if (result.success) {
|
|
63
|
-
if (result.dependencies && this.context.setEntrypointDependencies) {
|
|
64
|
-
this.context.setEntrypointDependencies(entrypoint, result.dependencies);
|
|
65
|
-
}
|
|
66
96
|
updates.push(outputUrl);
|
|
67
97
|
if (result.requiresReload) {
|
|
68
98
|
reloadRequired = true;
|
|
@@ -74,18 +104,14 @@ class JsHmrStrategy extends HmrStrategy {
|
|
|
74
104
|
appLogger.debug(`[JsHmrStrategy] Full reload required (no HMR accept found)`);
|
|
75
105
|
return {
|
|
76
106
|
type: "broadcast",
|
|
77
|
-
events: [
|
|
78
|
-
{
|
|
79
|
-
type: "reload"
|
|
80
|
-
}
|
|
81
|
-
]
|
|
107
|
+
events: [{ type: "reload" }]
|
|
82
108
|
};
|
|
83
109
|
}
|
|
84
110
|
return {
|
|
85
111
|
type: "broadcast",
|
|
86
|
-
events: updates.map((
|
|
112
|
+
events: updates.map((p) => ({
|
|
87
113
|
type: "update",
|
|
88
|
-
path:
|
|
114
|
+
path: p,
|
|
89
115
|
timestamp: Date.now()
|
|
90
116
|
}))
|
|
91
117
|
};
|
|
@@ -93,44 +119,40 @@ class JsHmrStrategy extends HmrStrategy {
|
|
|
93
119
|
return { type: "none" };
|
|
94
120
|
}
|
|
95
121
|
/**
|
|
96
|
-
* Bundles
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* @param outputUrl - URL path for the bundled file
|
|
100
|
-
* @returns True if bundling was successful
|
|
122
|
+
* Bundles one or more entrypoints in a single esbuild invocation.
|
|
123
|
+
* Uses the source directory as the output base so that the directory structure
|
|
124
|
+
* is preserved under the HMR dist folder.
|
|
101
125
|
*/
|
|
102
|
-
async
|
|
126
|
+
async bundleEntrypoints(entrypoints) {
|
|
103
127
|
try {
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const outputPath = path.join(this.context.getDistDir(), relativePathJs);
|
|
108
|
-
const result = await defaultBuildAdapter.build({
|
|
109
|
-
entrypoints: [entrypointPath],
|
|
128
|
+
const result = await this.context.getBrowserBundleService().bundle({
|
|
129
|
+
profile: "hmr-entrypoint",
|
|
130
|
+
entrypoints,
|
|
110
131
|
outdir: this.context.getDistDir(),
|
|
111
|
-
|
|
112
|
-
|
|
132
|
+
outbase: this.context.getSrcDir(),
|
|
133
|
+
naming: "[dir]/[name]",
|
|
113
134
|
plugins: this.context.getPlugins(),
|
|
114
|
-
minify: false
|
|
115
|
-
external: ["react", "react-dom"]
|
|
135
|
+
minify: false
|
|
116
136
|
});
|
|
117
137
|
if (!result.success) {
|
|
118
|
-
appLogger.error(
|
|
119
|
-
return { success: false
|
|
138
|
+
appLogger.error("[JsHmrStrategy] Batched build failed:", result.logs);
|
|
139
|
+
return { success: false };
|
|
120
140
|
}
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
141
|
+
const dependencies = /* @__PURE__ */ new Map();
|
|
142
|
+
if (result.dependencyGraph?.entrypoints) {
|
|
143
|
+
for (const [entrypoint, deps] of Object.entries(result.dependencyGraph.entrypoints)) {
|
|
144
|
+
dependencies.set(path.resolve(entrypoint), deps);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return { success: true, dependencies };
|
|
127
148
|
} catch (error) {
|
|
128
|
-
appLogger.error(
|
|
129
|
-
return { success: false
|
|
149
|
+
appLogger.error("[JsHmrStrategy] Error in batched build:", error);
|
|
150
|
+
return { success: false };
|
|
130
151
|
}
|
|
131
152
|
}
|
|
132
153
|
/**
|
|
133
|
-
* Processes bundled output
|
|
154
|
+
* Processes bundled output and determines whether the browser can hot-accept
|
|
155
|
+
* the update or must fall back to a full reload.
|
|
134
156
|
*
|
|
135
157
|
* @param filepath - Path to the bundled output file
|
|
136
158
|
* @param url - URL path for the bundled file
|
|
@@ -138,12 +160,10 @@ class JsHmrStrategy extends HmrStrategy {
|
|
|
138
160
|
*/
|
|
139
161
|
async processOutput(filepath, url) {
|
|
140
162
|
try {
|
|
141
|
-
|
|
163
|
+
const code = await fileSystem.readFile(filepath);
|
|
142
164
|
if (code.includes("/* [ecopages] hmr */")) {
|
|
143
165
|
return { success: true, requiresReload: !code.includes("import.meta.hot.accept") };
|
|
144
166
|
}
|
|
145
|
-
code = this.replaceBareSpecifiers(code);
|
|
146
|
-
await fileSystem.writeAsync(filepath, code);
|
|
147
167
|
appLogger.debug(`[JsHmrStrategy] Processed ${url}`);
|
|
148
168
|
const hasHmrAccept = code.includes("import.meta.hot.accept");
|
|
149
169
|
return { success: true, requiresReload: !hasHmrAccept };
|
|
@@ -152,27 +172,6 @@ class JsHmrStrategy extends HmrStrategy {
|
|
|
152
172
|
return { success: false, requiresReload: false };
|
|
153
173
|
}
|
|
154
174
|
}
|
|
155
|
-
/**
|
|
156
|
-
* Replaces bare specifiers with vendor URLs.
|
|
157
|
-
*
|
|
158
|
-
* Handles both static imports and dynamic imports.
|
|
159
|
-
*
|
|
160
|
-
* @param code - The bundled code to transform
|
|
161
|
-
* @returns The transformed code with vendor URLs
|
|
162
|
-
*/
|
|
163
|
-
replaceBareSpecifiers(code) {
|
|
164
|
-
const specifierMap = this.context.getSpecifierMap();
|
|
165
|
-
if (specifierMap.size === 0) {
|
|
166
|
-
return code;
|
|
167
|
-
}
|
|
168
|
-
let result = code;
|
|
169
|
-
for (const [bareSpec, vendorUrl] of specifierMap.entries()) {
|
|
170
|
-
const escaped = bareSpec.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
171
|
-
result = result.replace(new RegExp(`from\\s*["']${escaped}["']`, "g"), `from "${vendorUrl}"`);
|
|
172
|
-
result = result.replace(new RegExp(`import\\(["']${escaped}["']\\)`, "g"), `import("${vendorUrl}")`);
|
|
173
|
-
}
|
|
174
|
-
return result;
|
|
175
|
-
}
|
|
176
175
|
}
|
|
177
176
|
export {
|
|
178
177
|
JsHmrStrategy
|
package/src/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export type * from './public-types.js';
|
|
|
2
2
|
export type * from './eco/eco.types.js';
|
|
3
3
|
export { eco } from './eco/eco.js';
|
|
4
4
|
export { EcopagesApp, createApp, type EcopagesAppOptions } from './create-app.js';
|
|
5
|
-
export { defineApiHandler, defineGroupHandler, type GroupHandler } from './define-api-handler.js';
|
|
5
|
+
export { defineApiHandler, defineGroupHandler, type GroupHandler } from './adapters/shared/define-api-handler.js';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { eco } from "./eco/eco.js";
|
|
2
2
|
import { EcopagesApp, createApp } from "./create-app.js";
|
|
3
|
-
import { defineApiHandler, defineGroupHandler } from "./define-api-handler.js";
|
|
3
|
+
import { defineApiHandler, defineGroupHandler } from "./adapters/shared/define-api-handler.js";
|
|
4
4
|
export {
|
|
5
5
|
EcopagesApp,
|
|
6
6
|
createApp,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
5
|
import type { EcoComponent, EcoPagesElement, IntegrationRendererRenderOptions, RouteRendererBody } from '../../public-types.js';
|
|
6
|
-
import { IntegrationRenderer, type RenderToResponseContext } from '../../route-renderer/integration-renderer.js';
|
|
6
|
+
import { IntegrationRenderer, type RenderToResponseContext } from '../../route-renderer/orchestration/integration-renderer.js';
|
|
7
7
|
/**
|
|
8
8
|
* A renderer for the ghtml integration.
|
|
9
9
|
* It renders a page using the HtmlTemplate and Page components.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
IntegrationRenderer
|
|
3
|
+
} from "../../route-renderer/orchestration/integration-renderer.js";
|
|
2
4
|
import { GHTML_PLUGIN_NAME } from "./ghtml.plugin.js";
|
|
3
5
|
class GhtmlRenderer extends IntegrationRenderer {
|
|
4
6
|
name = GHTML_PLUGIN_NAME;
|
package/src/internal-types.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type { EcoBuildPlugin } from './build/build-types.js';
|
|
2
|
+
import type { AppBuildManifest } from './build/build-manifest.js';
|
|
3
|
+
import type { BuildAdapter, BuildExecutor } from './build/build-adapter.js';
|
|
2
4
|
import type { IntegrationPlugin } from './plugins/integration-plugin.js';
|
|
3
5
|
import type { Processor } from './plugins/processor.js';
|
|
4
6
|
import type { PageMetadataProps } from './public-types.js';
|
|
5
|
-
import type { FSRouter } from './router/fs-router.js';
|
|
7
|
+
import type { FSRouter } from './router/server/fs-router.js';
|
|
6
8
|
import type { CacheConfig } from './services/cache/cache.types.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
seo: string;
|
|
14
|
-
};
|
|
9
|
+
import type { DevGraphService } from './services/runtime-state/dev-graph.service.js';
|
|
10
|
+
import type { EntrypointDependencyGraph } from './services/runtime-state/entrypoint-dependency-graph.service.js';
|
|
11
|
+
import type { NodeRuntimeManifest } from './services/runtime-manifest/node-runtime-manifest.service.js';
|
|
12
|
+
import type { RuntimeSpecifierRegistry } from './services/runtime-state/runtime-specifier-registry.service.js';
|
|
13
|
+
import type { ServerInvalidationState } from './services/runtime-state/server-invalidation-state.service.js';
|
|
14
|
+
import type { ServerModuleTranspiler } from './services/module-loading/server-module-transpiler.service.js';
|
|
15
15
|
export interface RobotsPreference {
|
|
16
16
|
/**
|
|
17
17
|
* The user agent
|
|
@@ -58,20 +58,22 @@ export type EcoPagesAppConfig = {
|
|
|
58
58
|
* @default "layouts"
|
|
59
59
|
*/
|
|
60
60
|
layoutsDir: string;
|
|
61
|
-
/**
|
|
62
|
-
* The templates used for the pages
|
|
63
|
-
* @default "{head: 'head.kita.tsx', html: 'html.kita.tsx', seo: 'seo.kita.tsx'}"
|
|
64
|
-
*/
|
|
65
|
-
includesTemplates: IncludesTemplates;
|
|
66
|
-
/** Error 404 page
|
|
67
|
-
* @default "404.kita.tsx"
|
|
68
|
-
*/
|
|
69
|
-
error404Template: string;
|
|
70
61
|
/**
|
|
71
62
|
* The directory where the output will be located
|
|
72
63
|
* @default "dist"
|
|
73
64
|
*/
|
|
74
65
|
distDir: string;
|
|
66
|
+
/**
|
|
67
|
+
* The directory where internal runtime and build artifacts are stored.
|
|
68
|
+
*
|
|
69
|
+
* @remarks
|
|
70
|
+
* This directory is not intended for deployment. It owns transpiled server
|
|
71
|
+
* modules, runtime manifests, and processor caches so `distDir` can remain a
|
|
72
|
+
* clean export tree.
|
|
73
|
+
*
|
|
74
|
+
* @default ".eco"
|
|
75
|
+
*/
|
|
76
|
+
workDir: string;
|
|
75
77
|
/**
|
|
76
78
|
* The templates extensions based on the integrations
|
|
77
79
|
*/
|
|
@@ -106,6 +108,7 @@ export type EcoPagesAppConfig = {
|
|
|
106
108
|
config: string;
|
|
107
109
|
componentsDir: string;
|
|
108
110
|
distDir: string;
|
|
111
|
+
workDir: string;
|
|
109
112
|
includesDir: string;
|
|
110
113
|
layoutsDir: string;
|
|
111
114
|
pagesDir: string;
|
|
@@ -128,6 +131,24 @@ export type EcoPagesAppConfig = {
|
|
|
128
131
|
* @default { store: 'memory', defaultStrategy: 'static', enabled: true }
|
|
129
132
|
*/
|
|
130
133
|
cache?: CacheConfig;
|
|
134
|
+
/**
|
|
135
|
+
* Runtime-owned services attached after config construction.
|
|
136
|
+
*
|
|
137
|
+
* These values are internal implementation details used to thread per-app
|
|
138
|
+
* executors and similar runtime state through the system without relying on
|
|
139
|
+
* process-global registries.
|
|
140
|
+
*/
|
|
141
|
+
runtime?: {
|
|
142
|
+
buildAdapter?: BuildAdapter;
|
|
143
|
+
buildManifest?: AppBuildManifest;
|
|
144
|
+
buildExecutor?: BuildExecutor;
|
|
145
|
+
devGraphService?: DevGraphService;
|
|
146
|
+
entrypointDependencyGraph?: EntrypointDependencyGraph;
|
|
147
|
+
nodeRuntimeManifest?: NodeRuntimeManifest;
|
|
148
|
+
runtimeSpecifierRegistry?: RuntimeSpecifierRegistry;
|
|
149
|
+
serverInvalidationState?: ServerInvalidationState;
|
|
150
|
+
serverModuleTranspiler?: ServerModuleTranspiler;
|
|
151
|
+
};
|
|
131
152
|
/**
|
|
132
153
|
* Experimental features.
|
|
133
154
|
*/
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Plugin Contracts
|
|
2
|
+
|
|
3
|
+
This directory contains the authoring contracts for Ecopages integrations, processors, and related plugin-facing runtime declarations.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
The plugin layer defines what packages are allowed to declare about themselves, while core retains orchestration ownership.
|
|
8
|
+
|
|
9
|
+
These contracts are responsible for:
|
|
10
|
+
|
|
11
|
+
- integration registration and lifecycle hooks
|
|
12
|
+
- processor registration and asset capability declaration
|
|
13
|
+
- runtime capability declaration and validation input
|
|
14
|
+
- shared build-plugin bridge types used by integrations and processors
|
|
15
|
+
|
|
16
|
+
## Main Files
|
|
17
|
+
|
|
18
|
+
- `integration-plugin.ts`: framework-semantics contract for render integrations
|
|
19
|
+
- `processor.ts`: asset-transformation contract for processors
|
|
20
|
+
- `runtime-capability.ts`: runtime compatibility declaration types
|
|
21
|
+
- `eco-component-meta-plugin.ts`: shared metadata transform used by core loading/build paths
|
|
22
|
+
|
|
23
|
+
## Ownership Rules
|
|
24
|
+
|
|
25
|
+
- Integrations own rendering semantics, hydration behavior, and integration-specific HMR strategy.
|
|
26
|
+
- Processors own asset semantics, cache ownership, and processor-specific watch behavior.
|
|
27
|
+
- Core owns lifecycle ordering, startup orchestration, and manifest assembly.
|
|
28
|
+
|
|
29
|
+
## Lifecycle Summary
|
|
30
|
+
|
|
31
|
+
1. Config build validates and prepares plugin contributions.
|
|
32
|
+
2. Core seals the app-owned build manifest.
|
|
33
|
+
3. Runtime startup calls runtime-only setup hooks.
|
|
34
|
+
4. Request-time rendering and development invalidation reuse those finalized contracts.
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
const RESOLVABLE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mdx", ".css", ".scss", ".sass", ".less"];
|
|
4
4
|
function findResolvablePath(candidate) {
|
|
5
5
|
if (path.extname(candidate)) {
|
|
6
|
-
|
|
6
|
+
if (existsSync(candidate)) {
|
|
7
|
+
return candidate;
|
|
8
|
+
}
|
|
7
9
|
}
|
|
8
10
|
for (const extension of RESOLVABLE_EXTENSIONS) {
|
|
9
11
|
const fileCandidate = `${candidate}${extension}`;
|
|
@@ -19,6 +21,18 @@ function findResolvablePath(candidate) {
|
|
|
19
21
|
}
|
|
20
22
|
return void 0;
|
|
21
23
|
}
|
|
24
|
+
function resolveAliasedBarrelTarget(resolvedPath) {
|
|
25
|
+
if (!path.basename(resolvedPath).startsWith("index.")) {
|
|
26
|
+
return resolvedPath;
|
|
27
|
+
}
|
|
28
|
+
const source = readFileSync(resolvedPath, "utf8").trim();
|
|
29
|
+
const match = source.match(/^export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?$/);
|
|
30
|
+
if (!match?.[1]?.startsWith(".")) {
|
|
31
|
+
return resolvedPath;
|
|
32
|
+
}
|
|
33
|
+
const target = findResolvablePath(path.resolve(path.dirname(resolvedPath), match[1]));
|
|
34
|
+
return target ?? resolvedPath;
|
|
35
|
+
}
|
|
22
36
|
function createAliasResolverPlugin(srcDir) {
|
|
23
37
|
return {
|
|
24
38
|
name: "ecopages-alias-resolver",
|
|
@@ -27,7 +41,7 @@ function createAliasResolverPlugin(srcDir) {
|
|
|
27
41
|
const candidate = path.join(srcDir, args.path.slice(2));
|
|
28
42
|
const resolved = findResolvablePath(candidate);
|
|
29
43
|
if (resolved) {
|
|
30
|
-
return { path: resolved };
|
|
44
|
+
return { path: resolveAliasedBarrelTarget(resolved) };
|
|
31
45
|
}
|
|
32
46
|
return {};
|
|
33
47
|
});
|
|
@@ -47,6 +47,8 @@ export interface EcoComponentDirPluginOptions {
|
|
|
47
47
|
* Supported patterns:
|
|
48
48
|
* - `eco.page({ ... })` - Page component declarations
|
|
49
49
|
* - `eco.component({ ... })` - Reusable component declarations
|
|
50
|
+
* - `eco.html({ ... })` - HTML shell declarations
|
|
51
|
+
* - `eco.layout({ ... })` - Layout declarations
|
|
50
52
|
* - `Component.config = { ... }` - Config assignment pattern
|
|
51
53
|
* - `config: { ... }` - Config property in object literals
|
|
52
54
|
* - `export const config = { ... }` - Exported config declarations
|
|
@@ -70,7 +70,7 @@ function findInjectionPoints(node, insertions, injection, isInsideEcoComponent =
|
|
|
70
70
|
if (callee?.type === "MemberExpression" || callee?.type === "StaticMemberExpression") {
|
|
71
71
|
const obj = callee.object;
|
|
72
72
|
const prop = callee.property;
|
|
73
|
-
if (obj?.type === "Identifier" && obj?.name === "eco" && (prop?.name === "page" || prop?.name === "component")) {
|
|
73
|
+
if (obj?.type === "Identifier" && obj?.name === "eco" && (prop?.name === "page" || prop?.name === "component" || prop?.name === "html" || prop?.name === "layout")) {
|
|
74
74
|
const args = n.arguments;
|
|
75
75
|
const firstArg = args?.[0];
|
|
76
76
|
if (firstArg?.type === "ObjectExpression") {
|
|
@@ -2,9 +2,11 @@ import type { EcoBuildPlugin } from '../build/build-types';
|
|
|
2
2
|
import type { EcoPagesAppConfig, IHmrManager } from '../internal-types';
|
|
3
3
|
import type { HmrStrategy } from '../hmr/hmr-strategy';
|
|
4
4
|
import type { EcoComponent, EcoPagesElement } from '../public-types';
|
|
5
|
-
import type { IntegrationRenderer } from '../route-renderer/integration-renderer';
|
|
6
|
-
import { AssetProcessingService } from '../services/asset-processing-service/asset-processing.service';
|
|
7
|
-
import type { AssetDefinition, ProcessedAsset } from '../services/asset-processing-service/assets.types';
|
|
5
|
+
import type { IntegrationRenderer } from '../route-renderer/orchestration/integration-renderer';
|
|
6
|
+
import { AssetProcessingService } from '../services/assets/asset-processing-service/asset-processing.service';
|
|
7
|
+
import type { AssetDefinition, ProcessedAsset } from '../services/assets/asset-processing-service/assets.types';
|
|
8
|
+
import type { RuntimeCapabilityDeclaration } from './runtime-capability.js';
|
|
9
|
+
export type { RuntimeCapabilityDeclaration, RuntimeCapabilityTag } from './runtime-capability.js';
|
|
8
10
|
export declare const INTEGRATION_PLUGIN_ERRORS: {
|
|
9
11
|
readonly NOT_INITIALIZED_WITH_APP_CONFIG: "Plugin not initialized with app config";
|
|
10
12
|
readonly NOT_INITIALIZED_WITH_ASSET_SERVICE: "Plugin not initialized with asset dependency service";
|
|
@@ -31,6 +33,11 @@ export interface IntegrationPluginConfig {
|
|
|
31
33
|
* @default 'render'
|
|
32
34
|
*/
|
|
33
35
|
staticBuildStep?: 'render' | 'fetch';
|
|
36
|
+
/**
|
|
37
|
+
* Declares runtime-specific requirements that must be satisfied before the
|
|
38
|
+
* app can start with this integration enabled.
|
|
39
|
+
*/
|
|
40
|
+
runtimeCapability?: RuntimeCapabilityDeclaration;
|
|
34
41
|
}
|
|
35
42
|
/**
|
|
36
43
|
* Metadata used by integration-owned boundary policy.
|
|
@@ -54,6 +61,7 @@ export declare abstract class IntegrationPlugin<C = EcoPagesElement> {
|
|
|
54
61
|
readonly extensions: string[];
|
|
55
62
|
abstract renderer: RendererClass<C>;
|
|
56
63
|
readonly staticBuildStep: 'render' | 'fetch';
|
|
64
|
+
readonly runtimeCapability?: RuntimeCapabilityDeclaration;
|
|
57
65
|
protected integrationDependencies: AssetDefinition[];
|
|
58
66
|
protected resolvedIntegrationDependencies: ProcessedAsset[];
|
|
59
67
|
protected options?: Record<string, unknown>;
|
|
@@ -80,6 +88,20 @@ export declare abstract class IntegrationPlugin<C = EcoPagesElement> {
|
|
|
80
88
|
* ```
|
|
81
89
|
*/
|
|
82
90
|
getHmrStrategy?(): HmrStrategy | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Returns bare-specifier mappings that should be registered in the active
|
|
93
|
+
* runtime specifier registry.
|
|
94
|
+
*
|
|
95
|
+
* @remarks
|
|
96
|
+
* Override this when the integration owns browser runtime bundles that must
|
|
97
|
+
* be addressable from client-side imports through stable bare specifiers.
|
|
98
|
+
*
|
|
99
|
+
* Today these mappings are consumed by the development runtime and browser
|
|
100
|
+
* bundle aliasing path. They are intentionally generic enough to grow into a
|
|
101
|
+
* broader import-map-style facility later without moving framework-specific
|
|
102
|
+
* map contents into core.
|
|
103
|
+
*/
|
|
104
|
+
getRuntimeSpecifierMap(): Record<string, string>;
|
|
83
105
|
setHmrManager(hmrManager: IHmrManager): void;
|
|
84
106
|
initializeAssetDefinitionService(): void;
|
|
85
107
|
getResolvedIntegrationDependencies(): ProcessedAsset[];
|
|
@@ -96,7 +118,19 @@ export declare abstract class IntegrationPlugin<C = EcoPagesElement> {
|
|
|
96
118
|
* @returns `true` when the boundary should be deferred; otherwise `false`.
|
|
97
119
|
*/
|
|
98
120
|
shouldDeferComponentBoundary(_input: ComponentBoundaryPolicyInput): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Prepares build-facing contributions before the app build manifest is sealed.
|
|
123
|
+
*
|
|
124
|
+
* @remarks
|
|
125
|
+
* Override this when an integration needs to materialize runtime/build plugin
|
|
126
|
+
* declarations ahead of runtime startup. Keep runtime-only side effects out of
|
|
127
|
+
* this hook; they belong in `setup()`.
|
|
128
|
+
*/
|
|
129
|
+
prepareBuildContributions(): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Performs runtime-only integration setup after config build has already
|
|
132
|
+
* sealed manifest contributions.
|
|
133
|
+
*/
|
|
99
134
|
setup(): Promise<void>;
|
|
100
135
|
teardown(): Promise<void>;
|
|
101
136
|
}
|
|
102
|
-
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssetProcessingService } from "../services/asset-processing-service/asset-processing.service";
|
|
1
|
+
import { AssetProcessingService } from "../services/assets/asset-processing-service/asset-processing.service";
|
|
2
2
|
const INTEGRATION_PLUGIN_ERRORS = {
|
|
3
3
|
NOT_INITIALIZED_WITH_APP_CONFIG: "Plugin not initialized with app config",
|
|
4
4
|
NOT_INITIALIZED_WITH_ASSET_SERVICE: "Plugin not initialized with asset dependency service"
|
|
@@ -7,6 +7,7 @@ class IntegrationPlugin {
|
|
|
7
7
|
name;
|
|
8
8
|
extensions;
|
|
9
9
|
staticBuildStep;
|
|
10
|
+
runtimeCapability;
|
|
10
11
|
integrationDependencies;
|
|
11
12
|
resolvedIntegrationDependencies = [];
|
|
12
13
|
options;
|
|
@@ -21,6 +22,7 @@ class IntegrationPlugin {
|
|
|
21
22
|
this.extensions = config.extensions;
|
|
22
23
|
this.integrationDependencies = config.integrationDependencies || [];
|
|
23
24
|
this.staticBuildStep = config.staticBuildStep || "render";
|
|
25
|
+
this.runtimeCapability = config.runtimeCapability;
|
|
24
26
|
}
|
|
25
27
|
setConfig(appConfig) {
|
|
26
28
|
this.appConfig = appConfig;
|
|
@@ -29,8 +31,25 @@ class IntegrationPlugin {
|
|
|
29
31
|
setRuntimeOrigin(runtimeOrigin) {
|
|
30
32
|
this.runtimeOrigin = runtimeOrigin;
|
|
31
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns bare-specifier mappings that should be registered in the active
|
|
36
|
+
* runtime specifier registry.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* Override this when the integration owns browser runtime bundles that must
|
|
40
|
+
* be addressable from client-side imports through stable bare specifiers.
|
|
41
|
+
*
|
|
42
|
+
* Today these mappings are consumed by the development runtime and browser
|
|
43
|
+
* bundle aliasing path. They are intentionally generic enough to grow into a
|
|
44
|
+
* broader import-map-style facility later without moving framework-specific
|
|
45
|
+
* map contents into core.
|
|
46
|
+
*/
|
|
47
|
+
getRuntimeSpecifierMap() {
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
32
50
|
setHmrManager(hmrManager) {
|
|
33
51
|
this.hmrManager = hmrManager;
|
|
52
|
+
hmrManager.registerSpecifierMap(this.getRuntimeSpecifierMap());
|
|
34
53
|
const strategy = this.getHmrStrategy?.();
|
|
35
54
|
if (strategy) {
|
|
36
55
|
hmrManager.registerStrategy(strategy);
|
|
@@ -82,6 +101,20 @@ class IntegrationPlugin {
|
|
|
82
101
|
shouldDeferComponentBoundary(_input) {
|
|
83
102
|
return false;
|
|
84
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Prepares build-facing contributions before the app build manifest is sealed.
|
|
106
|
+
*
|
|
107
|
+
* @remarks
|
|
108
|
+
* Override this when an integration needs to materialize runtime/build plugin
|
|
109
|
+
* declarations ahead of runtime startup. Keep runtime-only side effects out of
|
|
110
|
+
* this hook; they belong in `setup()`.
|
|
111
|
+
*/
|
|
112
|
+
async prepareBuildContributions() {
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Performs runtime-only integration setup after config build has already
|
|
116
|
+
* sealed manifest contributions.
|
|
117
|
+
*/
|
|
85
118
|
async setup() {
|
|
86
119
|
if (this.integrationDependencies.length === 0) return;
|
|
87
120
|
if (!this.assetProcessingService) throw new Error(INTEGRATION_PLUGIN_ERRORS.NOT_INITIALIZED_WITH_ASSET_SERVICE);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { EcoBuildPlugin } from '../build/build-types.js';
|
|
2
2
|
import type { EcoPagesAppConfig, IClientBridge } from '../internal-types';
|
|
3
|
-
import type { AssetDefinition } from '../services/asset-processing-service';
|
|
3
|
+
import type { AssetDefinition } from '../services/assets/asset-processing-service';
|
|
4
|
+
import type { RuntimeCapabilityDeclaration } from './runtime-capability.js';
|
|
5
|
+
export type { RuntimeCapabilityDeclaration, RuntimeCapabilityTag } from './runtime-capability.js';
|
|
4
6
|
export declare const PROCESSOR_ERRORS: {
|
|
5
7
|
readonly CACHE_DIRECTORY_NOT_SET: "Cache directory not set in context";
|
|
6
8
|
};
|
|
@@ -38,6 +40,7 @@ export interface ProcessorConfig<TOptions = Record<string, unknown>> {
|
|
|
38
40
|
options?: TOptions;
|
|
39
41
|
watch?: ProcessorWatchConfig;
|
|
40
42
|
capabilities?: ProcessorAssetCapability[];
|
|
43
|
+
runtimeCapability?: RuntimeCapabilityDeclaration;
|
|
41
44
|
}
|
|
42
45
|
export interface ProcessorContext {
|
|
43
46
|
config: EcoPagesAppConfig;
|
|
@@ -59,12 +62,22 @@ export declare abstract class Processor<TOptions = Record<string, unknown>> {
|
|
|
59
62
|
protected options?: TOptions;
|
|
60
63
|
protected watchConfig?: ProcessorWatchConfig;
|
|
61
64
|
protected capabilities: ProcessorAssetCapability[];
|
|
65
|
+
readonly runtimeCapability?: RuntimeCapabilityDeclaration;
|
|
62
66
|
/** Plugins that are only used during the build process */
|
|
63
67
|
abstract buildPlugins?: EcoBuildPlugin[];
|
|
64
68
|
/** Plugins that are used during runtime for file processing */
|
|
65
69
|
abstract plugins?: EcoBuildPlugin[];
|
|
66
70
|
constructor(config: ProcessorConfig<TOptions>);
|
|
67
71
|
setContext(appConfig: EcoPagesAppConfig): void;
|
|
72
|
+
/**
|
|
73
|
+
* Prepares build-facing processor contributions before config finalization.
|
|
74
|
+
*
|
|
75
|
+
* @remarks
|
|
76
|
+
* Override this when a processor must compute runtime/build plugins or other
|
|
77
|
+
* manifest-owned state before startup. Runtime-only work such as cache
|
|
78
|
+
* warming or watcher registration should stay in `setup()`.
|
|
79
|
+
*/
|
|
80
|
+
prepareBuildContributions(): Promise<void>;
|
|
68
81
|
abstract setup(): Promise<void>;
|
|
69
82
|
abstract teardown(): Promise<void>;
|
|
70
83
|
abstract process(input: unknown, filePath?: string): Promise<unknown>;
|