@ecopages/core 0.2.0-alpha.6 → 0.2.0-alpha.8
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 +31 -0
- package/package.json +212 -92
- package/src/adapters/abstract/application-adapter.d.ts +168 -0
- package/src/adapters/abstract/application-adapter.js +109 -0
- package/src/adapters/abstract/router-adapter.d.ts +26 -0
- package/src/adapters/abstract/router-adapter.js +5 -0
- package/src/adapters/abstract/server-adapter.d.ts +69 -0
- package/src/adapters/abstract/server-adapter.js +15 -0
- package/src/adapters/bun/client-bridge.d.ts +34 -0
- package/src/adapters/bun/client-bridge.js +48 -0
- package/src/adapters/bun/create-app.d.ts +60 -0
- package/src/adapters/bun/create-app.js +117 -0
- package/src/adapters/bun/hmr-manager.d.ts +143 -0
- package/src/adapters/bun/hmr-manager.js +334 -0
- package/src/adapters/bun/index.d.ts +2 -0
- package/src/adapters/bun/index.js +8 -0
- package/src/adapters/bun/server-adapter.d.ts +155 -0
- package/src/adapters/bun/server-adapter.js +373 -0
- package/src/adapters/bun/server-lifecycle.d.ts +63 -0
- package/src/adapters/bun/server-lifecycle.js +92 -0
- package/src/adapters/index.d.ts +6 -0
- package/src/adapters/index.js +14 -0
- 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/create-app.d.ts +21 -0
- package/src/adapters/node/create-app.js +143 -0
- package/src/adapters/node/index.d.ts +6 -0
- package/src/adapters/node/index.js +11 -0
- package/src/adapters/node/node-client-bridge.d.ts +26 -0
- package/src/adapters/node/node-client-bridge.js +66 -0
- package/src/adapters/node/node-hmr-manager.d.ts +133 -0
- package/src/adapters/node/node-hmr-manager.js +312 -0
- 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 +161 -0
- package/src/adapters/node/server-adapter.js +358 -0
- package/src/adapters/node/static-content-server.d.ts +60 -0
- package/src/adapters/node/static-content-server.js +194 -0
- package/src/adapters/node/write-runtime-manifest.d.ts +26 -0
- package/src/adapters/node/write-runtime-manifest.js +12 -0
- package/src/adapters/shared/api-response.d.ts +52 -0
- package/src/adapters/shared/api-response.js +96 -0
- package/src/adapters/shared/application-adapter.d.ts +18 -0
- package/src/adapters/shared/application-adapter.js +90 -0
- package/src/adapters/shared/define-api-handler.d.ts +25 -0
- package/src/adapters/shared/define-api-handler.js +15 -0
- package/src/adapters/shared/explicit-static-route-matcher.d.ts +38 -0
- package/src/adapters/shared/explicit-static-route-matcher.js +103 -0
- package/src/adapters/shared/file-route-middleware-pipeline.d.ts +65 -0
- package/src/adapters/shared/file-route-middleware-pipeline.js +99 -0
- package/src/adapters/shared/fs-server-response-factory.d.ts +19 -0
- package/src/adapters/shared/fs-server-response-factory.js +97 -0
- package/src/adapters/shared/fs-server-response-matcher.d.ts +75 -0
- package/src/adapters/shared/fs-server-response-matcher.js +160 -0
- 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 +14 -0
- package/src/adapters/shared/render-context.js +70 -0
- 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 +97 -0
- package/src/adapters/shared/server-adapter.js +386 -0
- package/src/adapters/shared/server-route-handler.d.ts +89 -0
- package/src/adapters/shared/server-route-handler.js +111 -0
- package/src/adapters/shared/server-static-builder.d.ts +70 -0
- package/src/adapters/shared/server-static-builder.js +99 -0
- package/src/build/build-adapter.d.ts +186 -0
- package/src/build/build-adapter.js +168 -0
- package/src/build/build-manifest.d.ts +27 -0
- package/src/build/build-manifest.js +30 -0
- package/src/build/build-types.d.ts +57 -0
- package/src/build/build-types.js +0 -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 +72 -0
- package/src/build/esbuild-build-adapter.js +422 -0
- 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/config-builder.d.ts +238 -0
- package/src/config/config-builder.js +565 -0
- package/src/constants.d.ts +45 -0
- package/src/constants.js +25 -0
- package/src/create-app.d.ts +17 -0
- package/src/create-app.js +66 -0
- package/src/dev/sc-server.d.ts +30 -0
- package/src/dev/sc-server.js +111 -0
- package/src/eco/component-render-context.d.ts +105 -0
- package/src/eco/component-render-context.js +87 -0
- package/src/eco/eco.d.ts +9 -0
- package/src/eco/eco.js +114 -0
- package/src/eco/eco.types.d.ts +178 -0
- package/src/eco/eco.types.js +0 -0
- package/src/eco/eco.utils.d.ts +40 -0
- package/src/eco/eco.utils.js +40 -0
- package/src/eco/global-injector-map.d.ts +16 -0
- package/src/eco/global-injector-map.js +80 -0
- package/src/eco/lazy-injector-map.d.ts +8 -0
- package/src/eco/lazy-injector-map.js +70 -0
- package/src/eco/module-dependencies.d.ts +18 -0
- package/src/eco/module-dependencies.js +49 -0
- package/src/errors/http-error.d.ts +31 -0
- package/src/errors/http-error.js +50 -0
- package/src/errors/index.d.ts +2 -0
- package/src/errors/index.js +4 -0
- package/src/errors/locals-access-error.d.ts +4 -0
- package/src/errors/locals-access-error.js +9 -0
- package/src/global/app-logger.d.ts +2 -0
- package/src/global/app-logger.js +6 -0
- package/src/hmr/client/hmr-runtime.d.ts +5 -0
- package/src/hmr/client/hmr-runtime.js +109 -0
- package/src/hmr/hmr-strategy.d.ts +159 -0
- package/src/hmr/hmr-strategy.js +29 -0
- 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.d.ts +1 -0
- package/src/hmr/hmr.test.e2e.js +43 -0
- package/src/hmr/strategies/default-hmr-strategy.d.ts +43 -0
- package/src/hmr/strategies/default-hmr-strategy.js +34 -0
- package/src/hmr/strategies/js-hmr-strategy.d.ts +139 -0
- package/src/hmr/strategies/js-hmr-strategy.js +178 -0
- package/src/index.browser.d.ts +3 -0
- package/src/index.browser.js +4 -0
- package/src/index.d.ts +5 -0
- package/src/index.js +10 -0
- package/src/integrations/ghtml/ghtml-renderer.d.ts +15 -0
- package/src/integrations/ghtml/ghtml-renderer.js +62 -0
- package/src/integrations/ghtml/ghtml.plugin.d.ts +20 -0
- package/src/integrations/ghtml/ghtml.plugin.js +21 -0
- package/src/internal-types.d.ts +221 -0
- package/src/internal-types.js +0 -0
- package/src/plugins/alias-resolver-plugin.d.ts +2 -0
- package/src/plugins/alias-resolver-plugin.js +53 -0
- package/src/plugins/eco-component-meta-plugin.d.ts +97 -0
- package/src/plugins/eco-component-meta-plugin.js +157 -0
- package/src/plugins/integration-plugin.d.ts +136 -0
- package/src/plugins/integration-plugin.js +133 -0
- package/src/plugins/processor.d.ts +95 -0
- package/src/plugins/processor.js +136 -0
- package/src/plugins/runtime-capability.d.ts +9 -0
- package/src/plugins/runtime-capability.js +0 -0
- package/src/public-types.d.ts +1149 -0
- package/src/public-types.js +0 -0
- package/src/route-renderer/component-graph/component-graph-executor.d.ts +32 -0
- package/src/route-renderer/component-graph/component-graph-executor.js +31 -0
- package/src/route-renderer/component-graph/component-graph.d.ts +42 -0
- package/src/route-renderer/component-graph/component-graph.js +72 -0
- package/src/route-renderer/component-graph/component-marker.d.ts +52 -0
- package/src/route-renderer/component-graph/component-marker.js +46 -0
- 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/component-graph/marker-graph-resolver.d.ts +77 -0
- package/src/route-renderer/component-graph/marker-graph-resolver.js +95 -0
- package/src/route-renderer/orchestration/integration-renderer.d.ts +372 -0
- package/src/route-renderer/orchestration/integration-renderer.js +589 -0
- package/src/route-renderer/orchestration/render-execution.service.d.ts +103 -0
- package/src/route-renderer/orchestration/render-execution.service.js +121 -0
- package/src/route-renderer/orchestration/render-preparation.service.d.ts +121 -0
- package/src/route-renderer/orchestration/render-preparation.service.js +332 -0
- package/src/route-renderer/page-loading/dependency-resolver.d.ts +35 -0
- package/src/route-renderer/page-loading/dependency-resolver.js +442 -0
- package/src/route-renderer/page-loading/page-module-loader.d.ts +87 -0
- package/src/route-renderer/page-loading/page-module-loader.js +124 -0
- package/src/route-renderer/route-renderer.d.ts +61 -0
- package/src/route-renderer/route-renderer.js +87 -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/server/fs-router-scanner.d.ts +41 -0
- package/src/router/server/fs-router-scanner.js +156 -0
- package/src/router/server/fs-router.d.ts +26 -0
- package/src/router/server/fs-router.js +100 -0
- package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +120 -0
- package/src/services/assets/asset-processing-service/asset-processing.service.js +331 -0
- package/src/services/assets/asset-processing-service/asset.factory.d.ts +17 -0
- package/src/services/assets/asset-processing-service/asset.factory.js +82 -0
- package/src/services/assets/asset-processing-service/assets.types.d.ts +89 -0
- 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/assets/asset-processing-service/index.d.ts +5 -0
- package/src/services/assets/asset-processing-service/index.js +5 -0
- package/src/services/assets/asset-processing-service/processor.interface.d.ts +22 -0
- package/src/services/assets/asset-processing-service/processor.interface.js +6 -0
- package/src/services/assets/asset-processing-service/processor.registry.d.ts +8 -0
- package/src/services/assets/asset-processing-service/processor.registry.js +15 -0
- package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +24 -0
- package/src/services/assets/asset-processing-service/processors/base/base-processor.js +64 -0
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +17 -0
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +72 -0
- 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/assets/asset-processing-service/processors/script/content-script.processor.d.ts +5 -0
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +57 -0
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +8 -0
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +76 -0
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.d.ts +7 -0
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +75 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +5 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +25 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +9 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +66 -0
- package/src/services/assets/browser-bundle.service.d.ts +32 -0
- package/src/services/assets/browser-bundle.service.js +33 -0
- package/src/services/cache/cache.types.d.ts +107 -0
- package/src/services/cache/cache.types.js +0 -0
- package/src/services/cache/index.d.ts +7 -0
- package/src/services/cache/index.js +7 -0
- package/src/services/cache/memory-cache-store.d.ts +42 -0
- package/src/services/cache/memory-cache-store.js +98 -0
- package/src/services/cache/page-cache-service.d.ts +70 -0
- package/src/services/cache/page-cache-service.js +152 -0
- package/src/services/cache/page-request-cache-coordinator.service.d.ts +75 -0
- package/src/services/cache/page-request-cache-coordinator.service.js +109 -0
- 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/validation/schema-validation-service.d.ts +122 -0
- package/src/services/validation/schema-validation-service.js +101 -0
- package/src/services/validation/standard-schema.types.d.ts +65 -0
- package/src/services/validation/standard-schema.types.js +0 -0
- package/src/static-site-generator/static-site-generator.d.ts +109 -0
- package/src/static-site-generator/static-site-generator.js +353 -0
- package/src/utils/css.d.ts +1 -0
- package/src/utils/css.js +7 -0
- package/src/utils/deep-merge.d.ts +14 -0
- package/src/utils/deep-merge.js +32 -0
- package/src/utils/hash.d.ts +1 -0
- package/src/utils/hash.js +7 -0
- package/src/utils/html.d.ts +1 -0
- package/src/utils/html.js +4 -0
- package/src/utils/invariant.d.ts +5 -0
- package/src/utils/invariant.js +11 -0
- package/src/utils/locals-utils.d.ts +15 -0
- package/src/utils/locals-utils.js +24 -0
- package/src/utils/parse-cli-args.d.ts +24 -0
- package/src/utils/parse-cli-args.js +47 -0
- package/src/utils/path-utils.module.d.ts +5 -0
- package/src/utils/path-utils.module.js +14 -0
- package/src/utils/resolve-work-dir.d.ts +11 -0
- package/src/utils/resolve-work-dir.js +31 -0
- package/src/utils/runtime.d.ts +11 -0
- package/src/utils/runtime.js +40 -0
- package/src/utils/server-utils.module.d.ts +19 -0
- package/src/utils/server-utils.module.js +56 -0
- package/src/watchers/project-watcher.d.ts +136 -0
- package/src/watchers/project-watcher.js +281 -0
- package/src/watchers/project-watcher.test-helpers.d.ts +4 -0
- package/src/watchers/project-watcher.test-helpers.js +52 -0
- package/src/adapters/bun/hmr-manager.test.ts +0 -267
- package/src/adapters/node/bootstrap-dependency-resolver.test.ts +0 -282
- package/src/adapters/node/node-client-bridge.test.ts +0 -198
- package/src/adapters/node/node-hmr-manager.test.ts +0 -322
- package/src/adapters/node/runtime-adapter.test.ts +0 -868
- package/src/adapters/node/static-content-server.test.ts +0 -60
- package/src/adapters/shared/api-response.test.ts +0 -97
- package/src/adapters/shared/explicit-static-route-matcher.test.ts +0 -381
- package/src/adapters/shared/file-route-middleware-pipeline.test.ts +0 -90
- package/src/adapters/shared/fs-server-response-factory.test.ts +0 -187
- package/src/adapters/shared/fs-server-response-matcher.test.ts +0 -286
- package/src/adapters/shared/hmr-manager.contract.test.ts +0 -196
- package/src/adapters/shared/hmr-manager.dispatch.test.ts +0 -220
- package/src/adapters/shared/render-context.test.ts +0 -146
- package/src/adapters/shared/server-adapter.test.ts +0 -77
- package/src/adapters/shared/server-route-handler.test.ts +0 -110
- package/src/adapters/shared/server-static-builder.test.ts +0 -316
- package/src/build/build-adapter-serialization.test.ts +0 -268
- package/src/build/build-adapter.test.ts +0 -815
- package/src/build/runtime-specifier-alias-plugin.test.ts +0 -43
- package/src/config/config-builder.test.ts +0 -410
- package/src/eco/eco.test.ts +0 -678
- package/src/eco/eco.utils.test.ts +0 -124
- package/src/eco/global-injector-map.test.ts +0 -42
- package/src/eco/lazy-injector-map.test.ts +0 -66
- package/src/eco/module-dependencies.test.ts +0 -30
- package/src/errors/http-error.test.ts +0 -134
- package/src/global/utils.test.ts +0 -12
- 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/hmr-strategy.test.ts +0 -124
- package/src/hmr/strategies/js-hmr-strategy.test.ts +0 -335
- package/src/integrations/ghtml/ghtml-renderer.test.ts +0 -63
- package/src/plugins/alias-resolver-plugin.test.ts +0 -41
- package/src/plugins/eco-component-meta-plugin.test.ts +0 -380
- package/src/plugins/integration-plugin.test.ts +0 -111
- package/src/plugins/processor.test.ts +0 -148
- package/src/route-renderer/component-graph/component-graph-executor.test.ts +0 -41
- package/src/route-renderer/component-graph/component-graph.test.ts +0 -63
- package/src/route-renderer/component-graph/component-marker.test.ts +0 -73
- package/src/route-renderer/component-graph/marker-graph-resolver.test.ts +0 -135
- package/src/route-renderer/orchestration/integration-renderer.test.ts +0 -936
- package/src/route-renderer/orchestration/render-execution.service.test.ts +0 -97
- package/src/route-renderer/orchestration/render-preparation.service.test.ts +0 -235
- package/src/route-renderer/page-loading/dependency-resolver.test.ts +0 -345
- package/src/route-renderer/page-loading/page-module-loader.test.ts +0 -96
- package/src/router/client/navigation-coordinator.test.ts +0 -237
- package/src/router/server/fs-router-scanner.test.ts +0 -83
- package/src/router/server/fs-router.test.ts +0 -214
- package/src/services/assets/asset-processing-service/asset-processing.service.test.ts +0 -385
- package/src/services/assets/asset-processing-service/asset.factory.test.ts +0 -63
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.test.ts +0 -72
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.test.ts +0 -67
- package/src/services/assets/asset-processing-service/processors/base/base-processor.test.ts +0 -59
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.test.ts +0 -286
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.test.ts +0 -227
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.test.ts +0 -199
- package/src/services/assets/browser-bundle.service.test.ts +0 -36
- package/src/services/cache/memory-cache-store.test.ts +0 -225
- package/src/services/cache/page-cache-service.test.ts +0 -175
- package/src/services/cache/page-request-cache-coordinator.service.test.ts +0 -79
- package/src/services/html/html-rewriter-provider.service.test.ts +0 -183
- package/src/services/html/html-transformer.service.test.ts +0 -378
- package/src/services/invalidation/development-invalidation.service.test.ts +0 -77
- package/src/services/module-loading/page-module-import.service.test.ts +0 -253
- package/src/services/module-loading/server-loader.service.test.ts +0 -161
- package/src/services/module-loading/server-module-transpiler.service.test.ts +0 -115
- package/src/services/runtime-manifest/node-runtime-manifest.service.test.ts +0 -95
- package/src/services/validation/schema-validation-service.test.ts +0 -223
- package/src/static-site-generator/static-site-generator.test.ts +0 -307
- package/src/utils/deep-merge.test.ts +0 -114
- package/src/utils/invariant.test.ts +0 -22
- package/src/utils/path-utils.test.ts +0 -15
- package/src/utils/server-utils.test.ts +0 -38
- package/src/watchers/project-watcher.integration.test.ts +0 -337
- package/src/watchers/project-watcher.test.ts +0 -678
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_ECOPAGES_DIST_DIR,
|
|
4
|
+
DEFAULT_ECOPAGES_HOSTNAME,
|
|
5
|
+
DEFAULT_ECOPAGES_PORT,
|
|
6
|
+
DEFAULT_ECOPAGES_WORK_DIR
|
|
7
|
+
} from "../constants.js";
|
|
8
|
+
import {
|
|
9
|
+
collectConfiguredAppBuildManifestContributions,
|
|
10
|
+
createBuildAdapter,
|
|
11
|
+
getAppServerBuildPlugins,
|
|
12
|
+
setAppBuildAdapter,
|
|
13
|
+
setAppBuildExecutor,
|
|
14
|
+
updateAppBuildManifest
|
|
15
|
+
} from "../build/build-adapter.js";
|
|
16
|
+
import { createAppBuildExecutor } from "../build/dev-build-coordinator.js";
|
|
17
|
+
import { GHTML_PLUGIN_NAME, ghtmlPlugin } from "../integrations/ghtml/ghtml.plugin.js";
|
|
18
|
+
import { createEcoComponentMetaPlugin } from "../plugins/eco-component-meta-plugin.js";
|
|
19
|
+
import {
|
|
20
|
+
NoopEntrypointDependencyGraph,
|
|
21
|
+
setAppEntrypointDependencyGraph
|
|
22
|
+
} from "../services/runtime-state/entrypoint-dependency-graph.service.js";
|
|
23
|
+
import {
|
|
24
|
+
createNodeRuntimeManifest,
|
|
25
|
+
setAppNodeRuntimeManifest
|
|
26
|
+
} from "../services/runtime-manifest/node-runtime-manifest.service.js";
|
|
27
|
+
import {
|
|
28
|
+
InMemoryRuntimeSpecifierRegistry,
|
|
29
|
+
setAppRuntimeSpecifierRegistry
|
|
30
|
+
} from "../services/runtime-state/runtime-specifier-registry.service.js";
|
|
31
|
+
import {
|
|
32
|
+
CounterServerInvalidationState,
|
|
33
|
+
setAppServerInvalidationState
|
|
34
|
+
} from "../services/runtime-state/server-invalidation-state.service.js";
|
|
35
|
+
import { invariant } from "../utils/invariant.js";
|
|
36
|
+
import { appLogger } from "../global/app-logger.js";
|
|
37
|
+
import { fileSystem } from "@ecopages/file-system";
|
|
38
|
+
const CONFIG_BUILDER_ERRORS = {
|
|
39
|
+
DUPLICATE_INTEGRATION_NAMES: "Integrations names must be unique",
|
|
40
|
+
DUPLICATE_INTEGRATION_EXTENSIONS: "Integrations extensions must be unique",
|
|
41
|
+
MIXED_JSX_ENGINES: "Both kitajs and react integrations are enabled. Use per-file JSX import source/pragma consistently (e.g. `/** @jsxImportSource react */` for React files and `/** @jsxImportSource @kitajs/html */` for Kita files).",
|
|
42
|
+
duplicateProcessorName: (name) => `Processor with name "${name}" already exists`,
|
|
43
|
+
duplicateLoaderName: (name) => `Loader with name "${name}" already exists`,
|
|
44
|
+
duplicateSemanticTemplate: (kind, matches) => `Multiple ${kind} templates found: ${matches.join(", ")}`,
|
|
45
|
+
incompatibleRuntimeCapability: (kind, name, runtime, reason) => `Cannot enable ${kind} "${name}" on ${runtime}: ${reason}`,
|
|
46
|
+
unsupportedRuntimeVersion: (kind, name, runtime, current, min) => `Cannot enable ${kind} "${name}" on ${runtime} ${current}: requires runtime version ${min} or newer`,
|
|
47
|
+
invalidRuntimeVersion: (kind, name, version) => `Cannot validate ${kind} "${name}" runtimeCapability.minRuntimeVersion "${version}" because it is not a dot-separated numeric version`
|
|
48
|
+
};
|
|
49
|
+
class ConfigBuilder {
|
|
50
|
+
config = {
|
|
51
|
+
baseUrl: "",
|
|
52
|
+
rootDir: ".",
|
|
53
|
+
srcDir: "src",
|
|
54
|
+
pagesDir: "pages",
|
|
55
|
+
includesDir: "includes",
|
|
56
|
+
componentsDir: "components",
|
|
57
|
+
layoutsDir: "layouts",
|
|
58
|
+
publicDir: "public",
|
|
59
|
+
robotsTxt: {
|
|
60
|
+
preferences: {
|
|
61
|
+
"*": []
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
integrations: [],
|
|
65
|
+
integrationsDependencies: [],
|
|
66
|
+
distDir: DEFAULT_ECOPAGES_DIST_DIR,
|
|
67
|
+
defaultMetadata: {
|
|
68
|
+
title: "Ecopages",
|
|
69
|
+
description: "This is a static site generated with Ecopages"
|
|
70
|
+
},
|
|
71
|
+
additionalWatchPaths: [],
|
|
72
|
+
templatesExt: [],
|
|
73
|
+
absolutePaths: {
|
|
74
|
+
config: "",
|
|
75
|
+
componentsDir: "",
|
|
76
|
+
distDir: "",
|
|
77
|
+
workDir: "",
|
|
78
|
+
includesDir: "",
|
|
79
|
+
layoutsDir: "",
|
|
80
|
+
pagesDir: "",
|
|
81
|
+
projectDir: "",
|
|
82
|
+
publicDir: "",
|
|
83
|
+
srcDir: "",
|
|
84
|
+
htmlTemplatePath: "",
|
|
85
|
+
error404TemplatePath: ""
|
|
86
|
+
},
|
|
87
|
+
processors: /* @__PURE__ */ new Map(),
|
|
88
|
+
loaders: /* @__PURE__ */ new Map(),
|
|
89
|
+
workDir: DEFAULT_ECOPAGES_WORK_DIR
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Sets the base URL for the application.
|
|
93
|
+
* This URL is used as the root URL for all pages and assets.
|
|
94
|
+
*
|
|
95
|
+
* @param baseUrl - The base URL for the application (e.g., 'https://example.com')
|
|
96
|
+
* @returns The ConfigBuilder instance for method chaining
|
|
97
|
+
*/
|
|
98
|
+
setBaseUrl(baseUrl) {
|
|
99
|
+
this.config.baseUrl = baseUrl;
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Sets the root directory of the project.
|
|
104
|
+
* This is the base directory from which all other paths are resolved.
|
|
105
|
+
*
|
|
106
|
+
* @param rootDir - The root directory path
|
|
107
|
+
* @returns The ConfigBuilder instance for method chaining
|
|
108
|
+
*/
|
|
109
|
+
setRootDir(rootDir) {
|
|
110
|
+
this.config.rootDir = rootDir;
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Sets the source directory relative to the root directory.
|
|
115
|
+
* This directory contains all the source files for the application.
|
|
116
|
+
*
|
|
117
|
+
* @param srcDir - The source directory name (default: 'src')
|
|
118
|
+
* @returns The ConfigBuilder instance for method chaining
|
|
119
|
+
*/
|
|
120
|
+
setSrcDir(srcDir) {
|
|
121
|
+
this.config.srcDir = srcDir;
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Sets the pages directory relative to the source directory.
|
|
126
|
+
* This directory contains all the page files for the application.
|
|
127
|
+
*
|
|
128
|
+
* @param pagesDir - The pages directory name (default: 'pages')
|
|
129
|
+
* @returns The ConfigBuilder instance for method chaining
|
|
130
|
+
*/
|
|
131
|
+
setPagesDir(pagesDir) {
|
|
132
|
+
this.config.pagesDir = pagesDir;
|
|
133
|
+
return this;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Sets the includes directory relative to the source directory.
|
|
137
|
+
* This directory contains template includes and partials.
|
|
138
|
+
*
|
|
139
|
+
* @param includesDir - The includes directory name (default: 'includes')
|
|
140
|
+
* @returns The ConfigBuilder instance for method chaining
|
|
141
|
+
*/
|
|
142
|
+
setIncludesDir(includesDir) {
|
|
143
|
+
this.config.includesDir = includesDir;
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Sets the components directory relative to the source directory.
|
|
148
|
+
* This directory contains reusable components.
|
|
149
|
+
*
|
|
150
|
+
* @param componentsDir - The components directory name (default: 'components')
|
|
151
|
+
* @returns The ConfigBuilder instance for method chaining
|
|
152
|
+
*/
|
|
153
|
+
setComponentsDir(componentsDir) {
|
|
154
|
+
this.config.componentsDir = componentsDir;
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Sets the layouts directory relative to the source directory.
|
|
159
|
+
* This directory contains layout templates.
|
|
160
|
+
*
|
|
161
|
+
* @param layoutsDir - The layouts directory name (default: 'layouts')
|
|
162
|
+
* @returns The ConfigBuilder instance for method chaining
|
|
163
|
+
*/
|
|
164
|
+
setLayoutsDir(layoutsDir) {
|
|
165
|
+
this.config.layoutsDir = layoutsDir;
|
|
166
|
+
return this;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Sets the public directory relative to the source directory.
|
|
170
|
+
* This directory contains static assets that should be served as-is.
|
|
171
|
+
*
|
|
172
|
+
* @param publicDir - The public directory name (default: 'public')
|
|
173
|
+
* @returns The ConfigBuilder instance for method chaining
|
|
174
|
+
*/
|
|
175
|
+
setPublicDir(publicDir) {
|
|
176
|
+
this.config.publicDir = publicDir;
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Sets the robots.txt configuration.
|
|
181
|
+
* This determines which paths are allowed/disallowed for search engines.
|
|
182
|
+
*
|
|
183
|
+
* @param robotsTxt - The robots.txt configuration object
|
|
184
|
+
* @returns The ConfigBuilder instance for method chaining
|
|
185
|
+
*/
|
|
186
|
+
setRobotsTxt(robotsTxt) {
|
|
187
|
+
this.config.robotsTxt = robotsTxt;
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Sets the integration plugins to use.
|
|
192
|
+
* These plugins provide additional functionality to the application.
|
|
193
|
+
*
|
|
194
|
+
* @param integrations - An array of integration plugins
|
|
195
|
+
* @returns The ConfigBuilder instance for method chaining
|
|
196
|
+
*/
|
|
197
|
+
setIntegrations(integrations) {
|
|
198
|
+
this.config.integrations = integrations;
|
|
199
|
+
return this;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Sets the output directory for the built application.
|
|
203
|
+
*
|
|
204
|
+
* @param distDir - The distribution directory name (default: 'dist')
|
|
205
|
+
* @returns The ConfigBuilder instance for method chaining
|
|
206
|
+
*/
|
|
207
|
+
setDistDir(distDir) {
|
|
208
|
+
this.config.distDir = distDir;
|
|
209
|
+
return this;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Sets the internal work directory for runtime-only artifacts.
|
|
213
|
+
*
|
|
214
|
+
* @remarks
|
|
215
|
+
* Use this when deployable output should stay clean while Ecopages still
|
|
216
|
+
* needs a separate workspace for server transpilation caches, runtime
|
|
217
|
+
* manifests, and other internal build products.
|
|
218
|
+
*
|
|
219
|
+
* @param workDir - The internal work directory name
|
|
220
|
+
* @returns The ConfigBuilder instance for method chaining
|
|
221
|
+
*/
|
|
222
|
+
setWorkDir(workDir) {
|
|
223
|
+
this.config.workDir = workDir;
|
|
224
|
+
return this;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Sets the default metadata for pages.
|
|
228
|
+
* This is used when a page doesn't specify its own metadata.
|
|
229
|
+
*
|
|
230
|
+
* @param defaultMetadata - The default metadata object
|
|
231
|
+
* @returns The ConfigBuilder instance for method chaining
|
|
232
|
+
*/
|
|
233
|
+
setDefaultMetadata(defaultMetadata) {
|
|
234
|
+
this.config.defaultMetadata = {
|
|
235
|
+
...this.config.defaultMetadata,
|
|
236
|
+
...defaultMetadata
|
|
237
|
+
};
|
|
238
|
+
return this;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Sets additional paths to watch for changes during development.
|
|
242
|
+
*
|
|
243
|
+
* @param additionalWatchPaths - An array of additional paths to watch
|
|
244
|
+
* @returns The ConfigBuilder instance for method chaining
|
|
245
|
+
*/
|
|
246
|
+
setAdditionalWatchPaths(additionalWatchPaths) {
|
|
247
|
+
this.config.additionalWatchPaths = additionalWatchPaths;
|
|
248
|
+
return this;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Sets the processors to use for the application.
|
|
252
|
+
* This replaces any existing processors.
|
|
253
|
+
*
|
|
254
|
+
* @param processors - An array of processors
|
|
255
|
+
* @returns The ConfigBuilder instance for method chaining
|
|
256
|
+
*/
|
|
257
|
+
setProcessors(processors) {
|
|
258
|
+
this.config.processors.clear();
|
|
259
|
+
for (const processor of processors) {
|
|
260
|
+
this.addProcessor(processor);
|
|
261
|
+
}
|
|
262
|
+
return this;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Adds a processor to the application.
|
|
266
|
+
*
|
|
267
|
+
* @param processor - The processor to add
|
|
268
|
+
* @returns The ConfigBuilder instance for method chaining
|
|
269
|
+
* @throws Error if a processor with the same name already exists
|
|
270
|
+
*/
|
|
271
|
+
addProcessor(processor) {
|
|
272
|
+
if (this.config.processors.has(processor.name)) {
|
|
273
|
+
throw new Error(CONFIG_BUILDER_ERRORS.duplicateProcessorName(processor.name));
|
|
274
|
+
}
|
|
275
|
+
this.config.processors.set(processor.name, processor);
|
|
276
|
+
return this;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Sets the loaders to use for the application.
|
|
280
|
+
* This replaces any existing loaders.
|
|
281
|
+
*
|
|
282
|
+
* @param loaders - An array of build plugins to use as loaders
|
|
283
|
+
* @returns The ConfigBuilder instance for method chaining
|
|
284
|
+
*/
|
|
285
|
+
setLoaders(loaders) {
|
|
286
|
+
this.config.loaders.clear();
|
|
287
|
+
for (const loader of loaders) {
|
|
288
|
+
this.addLoader(loader.name, loader);
|
|
289
|
+
}
|
|
290
|
+
return this;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Adds a loader to the application.
|
|
294
|
+
*
|
|
295
|
+
* @param name - The name of the loader
|
|
296
|
+
* @param loader - The build plugin to use as a loader
|
|
297
|
+
* @returns The ConfigBuilder instance for method chaining
|
|
298
|
+
* @throws Error if a loader with the same name already exists
|
|
299
|
+
*/
|
|
300
|
+
addLoader(name, loader) {
|
|
301
|
+
if (this.config.loaders.has(name)) {
|
|
302
|
+
throw new Error(CONFIG_BUILDER_ERRORS.duplicateLoaderName(name));
|
|
303
|
+
}
|
|
304
|
+
this.config.loaders.set(name, loader);
|
|
305
|
+
return this;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Sets the cache configuration for ISR and page caching.
|
|
309
|
+
*
|
|
310
|
+
* @param cacheConfig - The cache configuration object
|
|
311
|
+
* @returns The ConfigBuilder instance for method chaining
|
|
312
|
+
*/
|
|
313
|
+
setCacheConfig(cacheConfig) {
|
|
314
|
+
this.config.cache = cacheConfig;
|
|
315
|
+
return this;
|
|
316
|
+
}
|
|
317
|
+
setExperimental(experimental) {
|
|
318
|
+
this.config.experimental = experimental;
|
|
319
|
+
return this;
|
|
320
|
+
}
|
|
321
|
+
createAbsolutePaths(config) {
|
|
322
|
+
const { srcDir, componentsDir, includesDir, layoutsDir, pagesDir, publicDir, distDir, workDir } = config;
|
|
323
|
+
const projectDir = config.rootDir;
|
|
324
|
+
const absoluteSrcDir = path.resolve(projectDir, srcDir);
|
|
325
|
+
const absoluteDistDir = path.resolve(projectDir, distDir);
|
|
326
|
+
const absoluteWorkDir = path.resolve(projectDir, workDir);
|
|
327
|
+
const absoluteIncludesDir = path.join(absoluteSrcDir, includesDir);
|
|
328
|
+
const absolutePagesDir = path.join(absoluteSrcDir, pagesDir);
|
|
329
|
+
this.config.absolutePaths = {
|
|
330
|
+
config: path.join(projectDir, "eco.config.ts"),
|
|
331
|
+
projectDir,
|
|
332
|
+
srcDir: absoluteSrcDir,
|
|
333
|
+
distDir: absoluteDistDir,
|
|
334
|
+
workDir: absoluteWorkDir,
|
|
335
|
+
componentsDir: path.join(absoluteSrcDir, componentsDir),
|
|
336
|
+
includesDir: absoluteIncludesDir,
|
|
337
|
+
layoutsDir: path.join(absoluteSrcDir, layoutsDir),
|
|
338
|
+
pagesDir: absolutePagesDir,
|
|
339
|
+
publicDir: path.join(absoluteSrcDir, publicDir),
|
|
340
|
+
htmlTemplatePath: this.resolveSemanticTemplatePath({
|
|
341
|
+
dirPath: absoluteIncludesDir,
|
|
342
|
+
basename: "html"
|
|
343
|
+
}),
|
|
344
|
+
error404TemplatePath: this.resolveSemanticTemplatePath({
|
|
345
|
+
dirPath: absolutePagesDir,
|
|
346
|
+
basename: "404"
|
|
347
|
+
})
|
|
348
|
+
};
|
|
349
|
+
return this;
|
|
350
|
+
}
|
|
351
|
+
resolveSemanticTemplatePath({ dirPath, basename }) {
|
|
352
|
+
const extensions = this.config.templatesExt.length > 0 ? this.config.templatesExt : [".ghtml.ts"];
|
|
353
|
+
const matches = extensions.map((extension) => path.join(dirPath, `${basename}${extension}`)).filter((candidate) => fileSystem.exists(candidate));
|
|
354
|
+
invariant(matches.length <= 1, CONFIG_BUILDER_ERRORS.duplicateSemanticTemplate(basename, matches));
|
|
355
|
+
if (matches.length === 1) {
|
|
356
|
+
return matches[0];
|
|
357
|
+
}
|
|
358
|
+
return path.join(dirPath, `${basename}${extensions[0]}`);
|
|
359
|
+
}
|
|
360
|
+
createIntegrationTemplatesExt(integrations) {
|
|
361
|
+
const integrationName = integrations.map((integration) => integration.name);
|
|
362
|
+
const uniqueName = new Set(integrationName);
|
|
363
|
+
invariant(integrationName.length === uniqueName.size, CONFIG_BUILDER_ERRORS.DUPLICATE_INTEGRATION_NAMES);
|
|
364
|
+
const hasKitaJs = uniqueName.has("kitajs");
|
|
365
|
+
const hasReact = uniqueName.has("react");
|
|
366
|
+
if (hasKitaJs && hasReact) {
|
|
367
|
+
appLogger.warn(CONFIG_BUILDER_ERRORS.MIXED_JSX_ENGINES);
|
|
368
|
+
}
|
|
369
|
+
const integrationsExtensions = integrations.flatMap((integration) => integration.extensions);
|
|
370
|
+
const uniqueExtensions = new Set(integrationsExtensions);
|
|
371
|
+
invariant(
|
|
372
|
+
integrationsExtensions.length === uniqueExtensions.size,
|
|
373
|
+
CONFIG_BUILDER_ERRORS.DUPLICATE_INTEGRATION_EXTENSIONS
|
|
374
|
+
);
|
|
375
|
+
this.config.templatesExt = integrationsExtensions;
|
|
376
|
+
}
|
|
377
|
+
initializeProcessors() {
|
|
378
|
+
for (const processor of this.config.processors.values()) {
|
|
379
|
+
processor.setContext(this.config);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
validateRuntimeCapabilities() {
|
|
383
|
+
const runtimeEnvironment = this.detectRuntimeEnvironment();
|
|
384
|
+
const contributors = [
|
|
385
|
+
...this.config.integrations.map((integration) => ({
|
|
386
|
+
kind: "integration",
|
|
387
|
+
name: integration.name,
|
|
388
|
+
runtimeCapability: integration.runtimeCapability
|
|
389
|
+
})),
|
|
390
|
+
...Array.from(this.config.processors.values(), (processor) => ({
|
|
391
|
+
kind: "processor",
|
|
392
|
+
name: processor.name,
|
|
393
|
+
runtimeCapability: processor.runtimeCapability
|
|
394
|
+
}))
|
|
395
|
+
];
|
|
396
|
+
for (const contributor of contributors) {
|
|
397
|
+
this.validateRuntimeCapability(contributor, runtimeEnvironment);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
validateRuntimeCapability(contributor, environment) {
|
|
401
|
+
const declaration = contributor.runtimeCapability;
|
|
402
|
+
if (!declaration) {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
for (const tag of declaration.tags) {
|
|
406
|
+
if (environment.supportedTags.has(tag)) {
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
throw new Error(
|
|
410
|
+
CONFIG_BUILDER_ERRORS.incompatibleRuntimeCapability(
|
|
411
|
+
contributor.kind,
|
|
412
|
+
contributor.name,
|
|
413
|
+
environment.runtime,
|
|
414
|
+
this.describeUnsupportedRuntimeTag(tag)
|
|
415
|
+
)
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
if (!declaration.minRuntimeVersion) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
const minVersion = this.parseVersion(declaration.minRuntimeVersion);
|
|
422
|
+
if (!minVersion) {
|
|
423
|
+
throw new Error(
|
|
424
|
+
CONFIG_BUILDER_ERRORS.invalidRuntimeVersion(
|
|
425
|
+
contributor.kind,
|
|
426
|
+
contributor.name,
|
|
427
|
+
declaration.minRuntimeVersion
|
|
428
|
+
)
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
const currentVersion = this.parseVersion(environment.version);
|
|
432
|
+
if (!currentVersion) {
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
if (this.compareVersions(currentVersion, minVersion) >= 0) {
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
throw new Error(
|
|
439
|
+
CONFIG_BUILDER_ERRORS.unsupportedRuntimeVersion(
|
|
440
|
+
contributor.kind,
|
|
441
|
+
contributor.name,
|
|
442
|
+
environment.runtime,
|
|
443
|
+
environment.version,
|
|
444
|
+
declaration.minRuntimeVersion
|
|
445
|
+
)
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
detectRuntimeEnvironment() {
|
|
449
|
+
const bunVersion = this.getBunVersion();
|
|
450
|
+
if (bunVersion) {
|
|
451
|
+
return {
|
|
452
|
+
runtime: "bun",
|
|
453
|
+
version: bunVersion,
|
|
454
|
+
supportedTags: /* @__PURE__ */ new Set([
|
|
455
|
+
"bun-only",
|
|
456
|
+
"node-compatible",
|
|
457
|
+
"requires-native-bun-api",
|
|
458
|
+
"requires-node-builtins"
|
|
459
|
+
])
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
return {
|
|
463
|
+
runtime: "node",
|
|
464
|
+
version: process.versions.node,
|
|
465
|
+
supportedTags: /* @__PURE__ */ new Set(["node-compatible", "requires-node-builtins"])
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
getBunVersion() {
|
|
469
|
+
const bun = globalThis;
|
|
470
|
+
return typeof bun.Bun?.version === "string" ? bun.Bun.version : void 0;
|
|
471
|
+
}
|
|
472
|
+
describeUnsupportedRuntimeTag(tag) {
|
|
473
|
+
switch (tag) {
|
|
474
|
+
case "bun-only":
|
|
475
|
+
return "it is Bun-only";
|
|
476
|
+
case "requires-native-bun-api":
|
|
477
|
+
return "it requires the native Bun API";
|
|
478
|
+
case "requires-node-builtins":
|
|
479
|
+
return "it requires Node builtins";
|
|
480
|
+
case "node-compatible":
|
|
481
|
+
return "it requires a Node-compatible runtime";
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
parseVersion(version) {
|
|
485
|
+
const normalized = version.trim().replace(/^v/i, "");
|
|
486
|
+
if (!/^\d+(?:\.\d+)*$/.test(normalized)) {
|
|
487
|
+
return void 0;
|
|
488
|
+
}
|
|
489
|
+
return normalized.split(".").map((segment) => Number(segment));
|
|
490
|
+
}
|
|
491
|
+
compareVersions(left, right) {
|
|
492
|
+
const maxLength = Math.max(left.length, right.length);
|
|
493
|
+
for (let index = 0; index < maxLength; index += 1) {
|
|
494
|
+
const leftValue = left[index] ?? 0;
|
|
495
|
+
const rightValue = right[index] ?? 0;
|
|
496
|
+
if (leftValue > rightValue) {
|
|
497
|
+
return 1;
|
|
498
|
+
}
|
|
499
|
+
if (leftValue < rightValue) {
|
|
500
|
+
return -1;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
return 0;
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Initializes default loaders that are required for EcoPages to function.
|
|
507
|
+
* This includes the eco-component-meta-plugin which auto-injects __eco metadata into component configs.
|
|
508
|
+
*/
|
|
509
|
+
async initializeDefaultLoaders() {
|
|
510
|
+
const componentMetaPlugin = createEcoComponentMetaPlugin({ config: this.config });
|
|
511
|
+
if (!this.config.loaders.has(componentMetaPlugin.name)) {
|
|
512
|
+
this.config.loaders.set(componentMetaPlugin.name, componentMetaPlugin);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
reviewBaseUrl(baseUrl) {
|
|
516
|
+
if (baseUrl) {
|
|
517
|
+
this.config.baseUrl = baseUrl;
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
const envBaseUrl = process.env.ECOPAGES_BASE_URL;
|
|
521
|
+
if (envBaseUrl) {
|
|
522
|
+
this.config.baseUrl = envBaseUrl;
|
|
523
|
+
} else if (!this.config.baseUrl) {
|
|
524
|
+
this.config.baseUrl = `http://${DEFAULT_ECOPAGES_HOSTNAME}:${DEFAULT_ECOPAGES_PORT}`;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Builds and returns the final configuration object.
|
|
529
|
+
* This performs validation and initialization of the configuration.
|
|
530
|
+
*
|
|
531
|
+
* @returns A promise that resolves to the final EcoPagesAppConfig
|
|
532
|
+
* @throws Error if required configuration is missing (e.g., baseUrl)
|
|
533
|
+
*/
|
|
534
|
+
async build() {
|
|
535
|
+
this.reviewBaseUrl(this.config.baseUrl);
|
|
536
|
+
if (!this.config.integrations.some((integration) => integration.name === GHTML_PLUGIN_NAME)) {
|
|
537
|
+
this.config.integrations.push(ghtmlPlugin());
|
|
538
|
+
}
|
|
539
|
+
this.createIntegrationTemplatesExt(this.config.integrations);
|
|
540
|
+
this.createAbsolutePaths(this.config);
|
|
541
|
+
await this.initializeDefaultLoaders();
|
|
542
|
+
this.initializeProcessors();
|
|
543
|
+
this.validateRuntimeCapabilities();
|
|
544
|
+
const buildAdapter = createBuildAdapter();
|
|
545
|
+
setAppBuildAdapter(this.config, buildAdapter);
|
|
546
|
+
updateAppBuildManifest(this.config, await collectConfiguredAppBuildManifestContributions(this.config));
|
|
547
|
+
setAppServerInvalidationState(this.config, new CounterServerInvalidationState());
|
|
548
|
+
setAppEntrypointDependencyGraph(this.config, new NoopEntrypointDependencyGraph());
|
|
549
|
+
setAppRuntimeSpecifierRegistry(this.config, new InMemoryRuntimeSpecifierRegistry());
|
|
550
|
+
setAppBuildExecutor(
|
|
551
|
+
this.config,
|
|
552
|
+
createAppBuildExecutor({
|
|
553
|
+
development: false,
|
|
554
|
+
adapter: buildAdapter,
|
|
555
|
+
getPlugins: () => getAppServerBuildPlugins(this.config)
|
|
556
|
+
})
|
|
557
|
+
);
|
|
558
|
+
setAppNodeRuntimeManifest(this.config, createNodeRuntimeManifest(this.config));
|
|
559
|
+
return this.config;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
export {
|
|
563
|
+
CONFIG_BUILDER_ERRORS,
|
|
564
|
+
ConfigBuilder
|
|
565
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains constants used throughout the project.
|
|
3
|
+
* @module constants
|
|
4
|
+
**/
|
|
5
|
+
/**
|
|
6
|
+
* Collection of status messages used in the application.
|
|
7
|
+
*/
|
|
8
|
+
export declare const STATUS_MESSAGE: {
|
|
9
|
+
404: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
*Variables used to determine if the app is running on Bun
|
|
13
|
+
*/
|
|
14
|
+
export declare const IS_BUN: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Directory used for storing assets.
|
|
17
|
+
*/
|
|
18
|
+
export declare const RESOLVED_ASSETS_DIR = "assets";
|
|
19
|
+
/**
|
|
20
|
+
* Directory used for storing vendor assets.
|
|
21
|
+
* This is a subdirectory of the assets directory.
|
|
22
|
+
*/
|
|
23
|
+
export declare const RESOLVED_ASSETS_VENDORS_DIR: string;
|
|
24
|
+
/**
|
|
25
|
+
* Base paths for generated project files.
|
|
26
|
+
*/
|
|
27
|
+
export declare const GENERATED_BASE_PATHS: {
|
|
28
|
+
readonly types: "node_modules/@types";
|
|
29
|
+
readonly cache: "cache";
|
|
30
|
+
};
|
|
31
|
+
export declare const DEFAULT_ECOPAGES_PORT = 3000;
|
|
32
|
+
export declare const DEFAULT_ECOPAGES_HOSTNAME = "localhost";
|
|
33
|
+
/**
|
|
34
|
+
* Default directory used for deployable output.
|
|
35
|
+
*/
|
|
36
|
+
export declare const DEFAULT_ECOPAGES_DIST_DIR = "dist";
|
|
37
|
+
/**
|
|
38
|
+
* Default internal working directory used for runtime-only artifacts.
|
|
39
|
+
*
|
|
40
|
+
* @remarks
|
|
41
|
+
* This directory is a local tool workspace and is not intended for deployment.
|
|
42
|
+
* It owns transpiled server modules, runtime manifests, and processor caches
|
|
43
|
+
* so the export directory can remain a clean deployable tree.
|
|
44
|
+
*/
|
|
45
|
+
export declare const DEFAULT_ECOPAGES_WORK_DIR = ".eco";
|
package/src/constants.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const STATUS_MESSAGE = {
|
|
2
|
+
404: "404 Not Found"
|
|
3
|
+
};
|
|
4
|
+
const IS_BUN = typeof Bun !== "undefined";
|
|
5
|
+
const RESOLVED_ASSETS_DIR = "assets";
|
|
6
|
+
const RESOLVED_ASSETS_VENDORS_DIR = `${RESOLVED_ASSETS_DIR}/vendors`;
|
|
7
|
+
const GENERATED_BASE_PATHS = {
|
|
8
|
+
types: "node_modules/@types",
|
|
9
|
+
cache: "cache"
|
|
10
|
+
};
|
|
11
|
+
const DEFAULT_ECOPAGES_PORT = 3e3;
|
|
12
|
+
const DEFAULT_ECOPAGES_HOSTNAME = "localhost";
|
|
13
|
+
const DEFAULT_ECOPAGES_DIST_DIR = "dist";
|
|
14
|
+
const DEFAULT_ECOPAGES_WORK_DIR = ".eco";
|
|
15
|
+
export {
|
|
16
|
+
DEFAULT_ECOPAGES_DIST_DIR,
|
|
17
|
+
DEFAULT_ECOPAGES_HOSTNAME,
|
|
18
|
+
DEFAULT_ECOPAGES_PORT,
|
|
19
|
+
DEFAULT_ECOPAGES_WORK_DIR,
|
|
20
|
+
GENERATED_BASE_PATHS,
|
|
21
|
+
IS_BUN,
|
|
22
|
+
RESOLVED_ASSETS_DIR,
|
|
23
|
+
RESOLVED_ASSETS_VENDORS_DIR,
|
|
24
|
+
STATUS_MESSAGE
|
|
25
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { EcopagesAppOptions as BunOptions } from './adapters/bun/create-app.js';
|
|
2
|
+
import type { EcopagesAppOptions as NodeOptions } from './adapters/node/create-app.js';
|
|
3
|
+
import { AbstractApplicationAdapter } from './adapters/abstract/application-adapter.js';
|
|
4
|
+
import { SharedApplicationAdapter } from './adapters/shared/application-adapter.js';
|
|
5
|
+
export type EcopagesAppOptions = BunOptions | NodeOptions;
|
|
6
|
+
export type UniversalEcopagesApp = AbstractApplicationAdapter<EcopagesAppOptions, any, Request>;
|
|
7
|
+
export declare function createApp<WebSocketData = undefined>(options: EcopagesAppOptions): Promise<UniversalEcopagesApp>;
|
|
8
|
+
export declare class EcopagesApp extends SharedApplicationAdapter<EcopagesAppOptions, unknown, Request> {
|
|
9
|
+
private readonly appOptions;
|
|
10
|
+
private runtimeApp;
|
|
11
|
+
private runtimeAppPromise;
|
|
12
|
+
constructor(options: EcopagesAppOptions);
|
|
13
|
+
private getRuntimeApp;
|
|
14
|
+
protected initializeServerAdapter(): Promise<UniversalEcopagesApp>;
|
|
15
|
+
start(): Promise<unknown>;
|
|
16
|
+
fetch(request: Request): Promise<Response>;
|
|
17
|
+
}
|