@ecopages/core 0.2.0-alpha.8 → 0.2.1
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 +18 -11
- package/README.md +23 -26
- package/package.json +76 -58
- package/src/adapters/README.md +2 -2
- package/src/adapters/abstract/application-adapter.d.ts +28 -2
- package/src/adapters/abstract/application-adapter.js +14 -2
- package/src/adapters/abstract/router-adapter.d.ts +1 -1
- package/src/adapters/abstract/server-adapter.d.ts +2 -2
- package/src/adapters/bun/client-bridge.d.ts +1 -1
- package/src/adapters/bun/create-app.d.ts +4 -12
- package/src/adapters/bun/create-app.js +4 -5
- package/src/adapters/bun/hmr-manager.d.ts +4 -4
- package/src/adapters/bun/hmr-manager.js +8 -8
- package/src/adapters/bun/index.d.ts +1 -1
- package/src/adapters/bun/index.js +2 -2
- package/src/adapters/bun/server-adapter.d.ts +5 -5
- package/src/adapters/bun/server-adapter.js +6 -5
- package/src/adapters/bun/server-lifecycle.d.ts +4 -4
- package/src/adapters/bun/server-lifecycle.js +2 -2
- package/src/{create-app.d.ts → adapters/create-app.d.ts} +9 -6
- package/src/{create-app.js → adapters/create-app.js} +4 -4
- package/src/adapters/index.d.ts +1 -5
- package/src/adapters/index.js +1 -7
- package/src/adapters/node/create-app.d.ts +6 -9
- package/src/adapters/node/create-app.js +12 -6
- package/src/adapters/node/node-client-bridge.d.ts +1 -1
- package/src/adapters/node/node-hmr-manager.d.ts +2 -2
- package/src/adapters/node/node-hmr-manager.js +3 -3
- package/src/adapters/node/server-adapter.d.ts +4 -4
- package/src/adapters/node/server-adapter.js +13 -12
- package/src/adapters/node/static-content-server.d.ts +1 -1
- package/src/adapters/node/static-content-server.js +1 -1
- package/src/adapters/shared/application-adapter.d.ts +1 -1
- package/src/adapters/shared/define-api-handler.d.ts +1 -1
- package/src/adapters/shared/explicit-static-route-matcher.d.ts +2 -2
- package/src/adapters/shared/file-route-middleware-pipeline.d.ts +1 -1
- package/src/adapters/shared/fs-server-response-factory.d.ts +2 -2
- package/src/adapters/shared/fs-server-response-factory.js +1 -1
- package/src/adapters/shared/fs-server-response-matcher.d.ts +1 -1
- package/src/adapters/shared/hmr-entrypoint-registrar.js +1 -1
- package/src/adapters/shared/hmr-html-response.d.ts +1 -1
- package/src/adapters/shared/render-context.d.ts +2 -1
- package/src/adapters/shared/render-context.js +3 -1
- package/src/adapters/shared/runtime-bootstrap.d.ts +1 -1
- package/src/adapters/shared/runtime-bootstrap.js +1 -1
- package/src/adapters/shared/server-adapter.d.ts +1 -1
- package/src/adapters/shared/server-adapter.js +5 -1
- package/src/adapters/shared/server-route-handler.d.ts +4 -4
- package/src/adapters/shared/server-route-handler.js +3 -3
- package/src/adapters/shared/server-static-builder.d.ts +5 -5
- package/src/adapters/shared/server-static-builder.js +5 -4
- package/src/build/README.md +19 -13
- package/src/build/build-adapter.d.ts +67 -20
- package/src/build/build-adapter.js +420 -19
- package/src/build/dev-build-coordinator.d.ts +10 -12
- package/src/build/dev-build-coordinator.js +8 -15
- package/src/build/esbuild-build-adapter.d.ts +6 -0
- package/src/build/esbuild-build-adapter.js +94 -11
- package/src/build/runtime-build-executor.d.ts +5 -4
- package/src/build/runtime-build-executor.js +5 -3
- package/src/build/runtime-specifier-alias-plugin.js +19 -15
- package/src/build/runtime-specifier-aliases.d.ts +5 -0
- package/src/build/runtime-specifier-aliases.js +95 -0
- package/src/config/README.md +5 -2
- package/src/config/config-builder.d.ts +25 -2
- package/src/config/config-builder.js +44 -7
- package/src/declarations.d.ts +1 -1
- package/src/dev/sc-server.d.ts +1 -1
- package/src/dev/sc-server.js +1 -1
- package/src/eco/eco.browser.d.ts +2 -0
- package/src/eco/eco.browser.js +83 -0
- package/src/eco/eco.js +19 -48
- package/src/eco/eco.types.d.ts +1 -1
- package/src/eco/eco.utils.d.ts +1 -40
- package/src/eco/eco.utils.js +5 -35
- package/src/eco/global-injector-map.d.ts +1 -1
- package/src/eco/lazy-injector-map.d.ts +1 -1
- package/src/hmr/hmr-strategy.d.ts +16 -13
- package/src/hmr/hmr-strategy.js +22 -7
- package/src/hmr/strategies/default-hmr-strategy.d.ts +2 -2
- package/src/hmr/strategies/default-hmr-strategy.js +1 -1
- package/src/hmr/strategies/js-hmr-strategy.d.ts +2 -2
- package/src/hmr/strategies/js-hmr-strategy.js +2 -2
- package/src/index.browser.d.ts +2 -2
- package/src/index.browser.js +1 -1
- package/src/index.d.ts +3 -2
- package/src/index.js +15 -4
- package/src/integrations/ghtml/ghtml-renderer.d.ts +6 -1
- package/src/integrations/ghtml/ghtml-renderer.js +29 -28
- package/src/integrations/ghtml/ghtml.plugin.d.ts +2 -2
- package/src/integrations/ghtml/ghtml.plugin.js +2 -2
- package/src/plugins/README.md +1 -0
- package/src/plugins/eco-component-meta-plugin.d.ts +12 -1
- package/src/plugins/eco-component-meta-plugin.js +26 -20
- package/src/plugins/foreign-jsx-override-plugin.d.ts +31 -0
- package/src/plugins/foreign-jsx-override-plugin.js +35 -0
- package/src/plugins/integration-plugin.d.ts +99 -33
- package/src/plugins/integration-plugin.js +68 -21
- package/src/plugins/processor.d.ts +2 -2
- package/src/plugins/processor.js +2 -2
- package/src/plugins/source-transform.d.ts +46 -0
- package/src/plugins/source-transform.js +71 -0
- package/src/route-renderer/GRAPH.md +54 -84
- package/src/route-renderer/README.md +14 -20
- package/src/route-renderer/orchestration/component-render-context.d.ts +83 -0
- package/src/route-renderer/orchestration/component-render-context.js +147 -0
- package/src/route-renderer/orchestration/integration-renderer.d.ts +233 -76
- package/src/route-renderer/orchestration/integration-renderer.js +500 -143
- package/src/route-renderer/orchestration/queued-boundary-runtime.service.d.ts +93 -0
- package/src/route-renderer/orchestration/queued-boundary-runtime.service.js +155 -0
- package/src/route-renderer/orchestration/render-execution.service.d.ts +11 -71
- package/src/route-renderer/orchestration/render-execution.service.js +65 -80
- package/src/{eco/eco.utils.ts → route-renderer/orchestration/render-output.utils.d.ts} +10 -53
- package/src/route-renderer/orchestration/render-output.utils.js +65 -0
- package/src/route-renderer/orchestration/render-preparation.service.d.ts +2 -8
- package/src/route-renderer/orchestration/render-preparation.service.js +10 -17
- package/src/route-renderer/orchestration/template-serialization.d.ts +38 -0
- package/src/route-renderer/orchestration/template-serialization.js +45 -0
- package/src/route-renderer/page-loading/dependency-resolver.d.ts +2 -2
- package/src/route-renderer/page-loading/dependency-resolver.js +10 -8
- package/src/route-renderer/page-loading/page-module-loader.d.ts +6 -4
- package/src/route-renderer/page-loading/page-module-loader.js +7 -5
- package/src/route-renderer/route-renderer.d.ts +5 -3
- package/src/route-renderer/route-renderer.js +13 -3
- package/src/router/README.md +79 -8
- package/src/router/client/navigation-coordinator.js +2 -2
- package/src/router/server/fs-router-scanner.d.ts +1 -1
- package/src/router/server/fs-router-scanner.js +6 -1
- package/src/router/server/fs-router.d.ts +1 -1
- package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +3 -3
- package/src/services/assets/asset-processing-service/asset-processing.service.js +6 -6
- package/src/services/assets/asset-processing-service/asset.factory.d.ts +1 -1
- package/src/services/assets/asset-processing-service/asset.factory.js +2 -2
- package/src/services/assets/asset-processing-service/index.d.ts +5 -5
- package/src/services/assets/asset-processing-service/index.js +5 -5
- package/src/services/assets/asset-processing-service/processor.interface.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processor.registry.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +1 -1
- package/src/services/assets/asset-processing-service/processors/base/base-processor.js +1 -1
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +3 -3
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +2 -2
- package/src/services/assets/asset-processing-service/processors/index.d.ts +5 -5
- package/src/services/assets/asset-processing-service/processors/index.js +5 -5
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +1 -1
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +4 -3
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +15 -3
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.d.ts +3 -3
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +1 -1
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +1 -1
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +1 -1
- package/src/services/assets/browser-bundle.service.d.ts +1 -1
- package/src/services/assets/browser-bundle.service.js +2 -2
- package/src/services/html/html-rewriter-provider.service.js +4 -1
- package/src/services/html/html-transformer.service.d.ts +2 -2
- package/src/services/html/html-transformer.service.js +4 -10
- package/src/services/invalidation/development-invalidation.service.d.ts +1 -1
- package/src/services/invalidation/development-invalidation.service.js +1 -0
- package/src/services/module-loading/app-module-loader.service.d.ts +25 -0
- package/src/services/module-loading/app-module-loader.service.js +31 -0
- package/src/services/module-loading/app-server-module-transpiler.service.d.ts +9 -1
- package/src/services/module-loading/app-server-module-transpiler.service.js +77 -2
- package/src/services/module-loading/host-module-loader-registry.d.ts +4 -0
- package/src/services/module-loading/host-module-loader-registry.js +15 -0
- package/src/services/module-loading/module-loading-types.d.ts +2 -0
- package/src/{adapters/node/bootstrap-dependency-resolver.d.ts → services/module-loading/node-bootstrap-plugin.d.ts} +2 -24
- package/src/{adapters/node/bootstrap-dependency-resolver.js → services/module-loading/node-bootstrap-plugin.js} +42 -22
- package/src/services/module-loading/page-module-import.service.d.ts +4 -0
- package/src/services/module-loading/page-module-import.service.js +38 -9
- package/src/services/module-loading/server-module-transpiler.service.d.ts +3 -0
- package/src/services/module-loading/server-module-transpiler.service.js +4 -1
- package/src/services/runtime-state/dev-graph.service.d.ts +6 -6
- package/src/services/runtime-state/dev-graph.service.js +10 -10
- package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +1 -1
- package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +1 -1
- package/src/services/runtime-state/server-invalidation-state.service.d.ts +1 -1
- package/src/static-site-generator/static-site-generator.d.ts +2 -2
- package/src/static-site-generator/static-site-generator.js +1 -1
- package/src/{internal-types.d.ts → types/internal-types.d.ts} +24 -14
- package/src/{public-types.d.ts → types/public-types.d.ts} +30 -14
- package/src/types/public-types.js +0 -0
- package/src/utils/html-escaping.d.ts +7 -0
- package/src/utils/html-escaping.js +6 -0
- package/src/utils/locals-utils.d.ts +1 -1
- package/src/utils/parse-cli-args.d.ts +4 -1
- package/src/utils/parse-cli-args.js +16 -1
- package/src/utils/resolve-work-dir.js +1 -1
- package/src/watchers/project-watcher.d.ts +4 -4
- package/src/watchers/project-watcher.js +4 -10
- package/src/watchers/project-watcher.test-helpers.d.ts +2 -2
- 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/hmr-manager.ts +0 -409
- package/src/adapters/bun/index.ts +0 -2
- package/src/adapters/bun/server-adapter.ts +0 -499
- package/src/adapters/bun/server-lifecycle.ts +0 -124
- package/src/adapters/index.ts +0 -6
- package/src/adapters/node/bootstrap-dependency-resolver.ts +0 -301
- package/src/adapters/node/create-app.ts +0 -179
- package/src/adapters/node/index.d.ts +0 -6
- package/src/adapters/node/index.js +0 -11
- package/src/adapters/node/index.ts +0 -16
- package/src/adapters/node/node-client-bridge.ts +0 -79
- package/src/adapters/node/node-hmr-manager.ts +0 -381
- package/src/adapters/node/runtime-adapter.d.ts +0 -46
- package/src/adapters/node/runtime-adapter.js +0 -306
- package/src/adapters/node/runtime-adapter.ts +0 -439
- package/src/adapters/node/server-adapter.ts +0 -488
- package/src/adapters/node/static-content-server.ts +0 -239
- package/src/adapters/node/write-runtime-manifest.d.ts +0 -26
- package/src/adapters/node/write-runtime-manifest.js +0 -12
- package/src/adapters/node/write-runtime-manifest.ts +0 -38
- package/src/adapters/shared/api-response.ts +0 -104
- package/src/adapters/shared/application-adapter.ts +0 -199
- package/src/adapters/shared/define-api-handler.ts +0 -66
- package/src/adapters/shared/explicit-static-route-matcher.ts +0 -140
- package/src/adapters/shared/file-route-middleware-pipeline.ts +0 -127
- package/src/adapters/shared/fs-server-response-factory.ts +0 -118
- package/src/adapters/shared/fs-server-response-matcher.ts +0 -205
- package/src/adapters/shared/hmr-entrypoint-registrar.ts +0 -149
- package/src/adapters/shared/hmr-html-response.ts +0 -52
- package/src/adapters/shared/render-context.ts +0 -120
- package/src/adapters/shared/runtime-bootstrap.ts +0 -79
- package/src/adapters/shared/server-adapter.ts +0 -489
- package/src/adapters/shared/server-route-handler.ts +0 -153
- package/src/adapters/shared/server-static-builder.ts +0 -166
- package/src/build/build-adapter.ts +0 -361
- package/src/build/build-manifest.ts +0 -54
- package/src/build/build-types.ts +0 -83
- package/src/build/dev-build-coordinator.ts +0 -221
- package/src/build/esbuild-build-adapter.ts +0 -559
- package/src/build/runtime-build-executor.ts +0 -34
- package/src/build/runtime-specifier-alias-plugin.ts +0 -58
- package/src/config/config-builder.ts +0 -706
- package/src/constants.ts +0 -54
- package/src/create-app.ts +0 -87
- package/src/dev/sc-server.ts +0 -143
- package/src/eco/component-render-context.d.ts +0 -105
- package/src/eco/component-render-context.js +0 -87
- package/src/eco/component-render-context.ts +0 -224
- package/src/eco/eco.ts +0 -242
- package/src/eco/eco.types.ts +0 -221
- 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/hmr-runtime.ts +0 -152
- package/src/hmr/hmr-strategy.ts +0 -172
- package/src/hmr/hmr.postcss.test.e2e.ts +0 -41
- package/src/hmr/hmr.test.e2e.ts +0 -66
- package/src/hmr/strategies/default-hmr-strategy.ts +0 -60
- package/src/hmr/strategies/js-hmr-strategy.ts +0 -320
- package/src/index.browser.ts +0 -3
- package/src/index.ts +0 -5
- package/src/integrations/ghtml/ghtml-renderer.ts +0 -96
- package/src/integrations/ghtml/ghtml.plugin.ts +0 -32
- package/src/internal-types.ts +0 -232
- package/src/plugins/alias-resolver-plugin.ts +0 -63
- package/src/plugins/eco-component-meta-plugin.ts +0 -481
- package/src/plugins/integration-plugin.ts +0 -226
- package/src/plugins/processor.ts +0 -240
- package/src/plugins/runtime-capability.ts +0 -14
- package/src/public-types.ts +0 -1317
- package/src/route-renderer/component-graph/component-graph-executor.d.ts +0 -32
- package/src/route-renderer/component-graph/component-graph-executor.js +0 -31
- package/src/route-renderer/component-graph/component-graph-executor.ts +0 -84
- package/src/route-renderer/component-graph/component-graph.d.ts +0 -42
- package/src/route-renderer/component-graph/component-graph.js +0 -72
- package/src/route-renderer/component-graph/component-graph.ts +0 -159
- package/src/route-renderer/component-graph/component-marker.d.ts +0 -52
- package/src/route-renderer/component-graph/component-marker.js +0 -46
- package/src/route-renderer/component-graph/component-marker.ts +0 -117
- package/src/route-renderer/component-graph/component-reference.d.ts +0 -10
- package/src/route-renderer/component-graph/component-reference.js +0 -19
- package/src/route-renderer/component-graph/component-reference.ts +0 -29
- package/src/route-renderer/component-graph/marker-graph-resolver.d.ts +0 -77
- package/src/route-renderer/component-graph/marker-graph-resolver.js +0 -95
- package/src/route-renderer/component-graph/marker-graph-resolver.ts +0 -155
- package/src/route-renderer/orchestration/integration-renderer.ts +0 -790
- package/src/route-renderer/orchestration/render-execution.service.ts +0 -230
- package/src/route-renderer/orchestration/render-preparation.service.ts +0 -476
- package/src/route-renderer/page-loading/dependency-resolver.ts +0 -612
- package/src/route-renderer/page-loading/page-module-loader.ts +0 -181
- package/src/route-renderer/route-renderer.ts +0 -115
- package/src/router/client/link-intent.test.browser.ts +0 -51
- package/src/router/client/link-intent.ts +0 -92
- package/src/router/client/navigation-coordinator.ts +0 -433
- package/src/router/server/fs-router-scanner.ts +0 -219
- package/src/router/server/fs-router.ts +0 -122
- package/src/services/assets/asset-processing-service/asset-processing.service.ts +0 -401
- package/src/services/assets/asset-processing-service/asset.factory.ts +0 -105
- package/src/services/assets/asset-processing-service/assets.types.ts +0 -113
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.ts +0 -95
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.ts +0 -78
- package/src/services/assets/asset-processing-service/index.ts +0 -5
- package/src/services/assets/asset-processing-service/processor.interface.ts +0 -27
- package/src/services/assets/asset-processing-service/processor.registry.ts +0 -18
- package/src/services/assets/asset-processing-service/processors/base/base-processor.ts +0 -82
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.ts +0 -95
- package/src/services/assets/asset-processing-service/processors/index.ts +0 -5
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.ts +0 -66
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.ts +0 -88
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.ts +0 -85
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +0 -27
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +0 -80
- package/src/services/assets/browser-bundle.service.ts +0 -53
- 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/cache/page-request-cache-coordinator.service.ts +0 -131
- package/src/services/html/html-rewriter-provider.service.ts +0 -103
- package/src/services/html/html-transformer.service.ts +0 -279
- package/src/services/invalidation/development-invalidation.service.ts +0 -261
- package/src/services/module-loading/app-server-module-transpiler.service.ts +0 -52
- package/src/services/module-loading/page-module-import.service.ts +0 -200
- package/src/services/module-loading/server-loader.service.d.ts +0 -96
- package/src/services/module-loading/server-loader.service.js +0 -32
- package/src/services/module-loading/server-loader.service.ts +0 -130
- package/src/services/module-loading/server-module-transpiler.service.ts +0 -105
- package/src/services/runtime-manifest/node-runtime-manifest.service.d.ts +0 -35
- package/src/services/runtime-manifest/node-runtime-manifest.service.js +0 -60
- package/src/services/runtime-manifest/node-runtime-manifest.service.ts +0 -101
- package/src/services/runtime-state/dev-graph.service.ts +0 -217
- package/src/services/runtime-state/entrypoint-dependency-graph.service.ts +0 -136
- package/src/services/runtime-state/runtime-specifier-registry.service.ts +0 -96
- package/src/services/runtime-state/server-invalidation-state.service.ts +0 -68
- package/src/services/validation/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 -462
- package/src/utils/css.d.ts +0 -1
- package/src/utils/css.js +0 -7
- package/src/utils/css.ts +0 -5
- package/src/utils/deep-merge.ts +0 -47
- package/src/utils/hash.ts +0 -5
- package/src/utils/html.ts +0 -1
- package/src/utils/invariant.ts +0 -15
- package/src/utils/locals-utils.ts +0 -37
- package/src/utils/parse-cli-args.ts +0 -83
- package/src/utils/path-utils.module.ts +0 -14
- package/src/utils/resolve-work-dir.ts +0 -45
- 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 -41
- package/src/watchers/project-watcher.ts +0 -363
- /package/src/{constants.d.ts → config/constants.d.ts} +0 -0
- /package/src/{constants.js → config/constants.js} +0 -0
- /package/src/{internal-types.js → services/module-loading/module-loading-types.js} +0 -0
- /package/src/{public-types.js → types/internal-types.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Rendering Logic Graph
|
|
2
2
|
|
|
3
|
-
This document maps the end-to-end rendering logic in core, including request-time rendering, explicit route rendering, static generation, and
|
|
3
|
+
This document maps the end-to-end rendering logic in core, including request-time rendering, explicit route rendering, static generation, and deferred boundary orchestration.
|
|
4
4
|
|
|
5
5
|
## Design Principles
|
|
6
6
|
|
|
@@ -12,16 +12,14 @@ These diagrams are based on a few architectural assumptions that seem important
|
|
|
12
12
|
Adapters and route matchers decide which renderer to use; once selected, the integration renderer owns the page render pipeline.
|
|
13
13
|
- **Data resolution should happen before HTML transformation.**
|
|
14
14
|
Static props, metadata, dependency processing, and route assets are all upstream of final HTML injection.
|
|
15
|
-
- **
|
|
16
|
-
The initial integration render
|
|
17
|
-
- **
|
|
18
|
-
|
|
19
|
-
- **The marker pipeline remains generic after emission.**
|
|
20
|
-
Once markers exist, core resolves them generically through marker graph extraction, integration renderer dispatch, asset collection, and HTML replacement. The current built-in React integration is one concrete consumer of that mechanism.
|
|
15
|
+
- **Deferred boundary orchestration should stay renderer-owned.**
|
|
16
|
+
The initial integration render is responsible for handing foreign boundaries back to their owning renderer before final route HTML is returned.
|
|
17
|
+
- **Foreign boundary ownership is renderer-defined behavior.**
|
|
18
|
+
If a renderer cannot resolve a foreign boundary inside its own runtime, route execution now treats any leftover unresolved boundary artifact HTML as an error instead of attempting any route-level fallback.
|
|
21
19
|
- **Caching policy is authoritative at the page layer.**
|
|
22
20
|
Middleware, locals, and response reuse all depend on the effective page cache strategy.
|
|
23
21
|
- **Asset emission should converge into one injection stage.**
|
|
24
|
-
Route-level assets, integration assets, page-root component assets, and
|
|
22
|
+
Route-level assets, integration assets, page-root component assets, and renderer-owned boundary assets all end up in the HTML transformer.
|
|
25
23
|
|
|
26
24
|
## Entry Points
|
|
27
25
|
|
|
@@ -143,7 +141,7 @@ flowchart TD
|
|
|
143
141
|
|
|
144
142
|
### 4.2 Main execute flow via `RenderExecutionService`
|
|
145
143
|
|
|
146
|
-
Important nuance: this phase does not
|
|
144
|
+
Important nuance: this phase does not resolve mixed-integration boundaries itself anymore. Renderer-owned runtimes must finish that work before route finalization. If unresolved boundary artifact HTML survives to this phase, route execution fails fast.
|
|
147
145
|
|
|
148
146
|
```mermaid
|
|
149
147
|
flowchart TD
|
|
@@ -151,19 +149,14 @@ flowchart TD
|
|
|
151
149
|
B --> C[prepareRenderOptions]
|
|
152
150
|
C --> D[runWithComponentRenderContext then render]
|
|
153
151
|
D --> E[normalize response body to renderedHtml]
|
|
154
|
-
E --> F
|
|
155
|
-
F --> G
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
H --> J[
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
K --> L
|
|
162
|
-
L -- Yes --> M[HtmlTransformerService applyAttributesToFirstBodyElement]
|
|
163
|
-
L -- No --> N[leave html unchanged]
|
|
164
|
-
M --> O[htmlTransformer transform]
|
|
165
|
-
N --> O
|
|
166
|
-
O --> P[return body stream and cache strategy]
|
|
152
|
+
E --> F{contains unresolved boundary artifact html?}
|
|
153
|
+
F -- Yes --> G[throw unresolved boundary error]
|
|
154
|
+
F -- No --> H{root attributes attachable?}
|
|
155
|
+
H -- Yes --> I[HtmlTransformerService applyAttributesToFirstBodyElement]
|
|
156
|
+
H -- No --> J[leave html unchanged]
|
|
157
|
+
I --> K[htmlTransformer transform]
|
|
158
|
+
J --> K
|
|
159
|
+
K --> L[return body stream and cache strategy]
|
|
167
160
|
```
|
|
168
161
|
|
|
169
162
|
### 4.3 Render preparation responsibilities
|
|
@@ -189,7 +182,7 @@ flowchart LR
|
|
|
189
182
|
flowchart LR
|
|
190
183
|
A[IntegrationRenderer] --> B[RenderPreparationService]
|
|
191
184
|
A --> C[RenderExecutionService]
|
|
192
|
-
A --> D[
|
|
185
|
+
A --> D[QueuedBoundaryRuntimeService]
|
|
193
186
|
A --> F[PageModuleLoaderService]
|
|
194
187
|
A --> G[DependencyResolverService]
|
|
195
188
|
A --> H[HtmlTransformerService]
|
|
@@ -197,32 +190,32 @@ flowchart LR
|
|
|
197
190
|
B --> F
|
|
198
191
|
B --> G
|
|
199
192
|
B --> H
|
|
200
|
-
C --> D
|
|
201
193
|
C --> H
|
|
194
|
+
D --> H
|
|
202
195
|
```
|
|
203
196
|
|
|
204
|
-
## 5)
|
|
197
|
+
## 5) Boundary Tokens And Renderer-Owned Resolution
|
|
205
198
|
|
|
206
|
-
This part is architecturally interesting because
|
|
199
|
+
This part is architecturally interesting because boundaries can still emit temporary transport tokens, but renderer-owned runtimes are now responsible for resolving foreign descendants before final route HTML is returned.
|
|
207
200
|
|
|
208
201
|
If this feels complex, the simplest mental model is:
|
|
209
202
|
|
|
210
203
|
- first pass: render everything that can be rendered safely right now
|
|
211
|
-
- when a
|
|
212
|
-
-
|
|
213
|
-
- final pass: merge
|
|
204
|
+
- when a renderer supports mixed boundaries, hand foreign descendants back to the owning renderer inside that renderer's runtime
|
|
205
|
+
- if literal `<eco-marker>` boundary artifact HTML survives to route finalization, treat it as a failure instead of attempting any route-level fallback
|
|
206
|
+
- final pass: merge emitted assets and perform the normal HTML transformation
|
|
214
207
|
|
|
215
|
-
In the current implementation,
|
|
208
|
+
In the current implementation, renderer-owned runtimes use internal boundary tokens for queued nested handoff. Literal `<eco-marker>` markup remains only as a route-level failure signal when unresolved boundary artifacts escape renderer-owned resolution.
|
|
216
209
|
|
|
217
|
-
Important clarification: not every integration automatically goes through this stage.
|
|
210
|
+
Important clarification: not every integration automatically goes through this stage. Boundary queueing is conditional.
|
|
218
211
|
|
|
219
|
-
- If
|
|
220
|
-
- If
|
|
221
|
-
-
|
|
212
|
+
- If a render pass stays inside one integration, rendering continues directly to post-processing and HTML transformation.
|
|
213
|
+
- If a renderer can resolve foreign descendants inline, the boundary runtime returns resolved HTML immediately.
|
|
214
|
+
- If a renderer needs token-based nested handoff, it queues renderer-owned transport tokens and resolves them before returning final HTML.
|
|
222
215
|
|
|
223
216
|
### Why this exists
|
|
224
217
|
|
|
225
|
-
|
|
218
|
+
Renderer-owned boundary queueing exists because some component boundaries cannot always be rendered eagerly inside the current integration pass.
|
|
226
219
|
|
|
227
220
|
Typical reasons include:
|
|
228
221
|
|
|
@@ -231,62 +224,45 @@ Typical reasons include:
|
|
|
231
224
|
- the parent render needs to preserve ordering and slots before the child subtree is resolved
|
|
232
225
|
- the child render may emit its own assets or root attributes that must be merged back into the final document
|
|
233
226
|
|
|
234
|
-
So the first pass
|
|
235
|
-
|
|
236
|
-
Responsibility split:
|
|
237
|
-
|
|
238
|
-
- core resolves the deferred marker mechanically: graph shape, refs, slot relationships, and target renderer lookup
|
|
239
|
-
- the selected integration renderer resolves the actual component render once it receives `component`, `props`, and optional `children`
|
|
227
|
+
So the first pass either returns resolved renderer-owned output immediately or emits a renderer-local transport token that is resolved before the enclosing renderer returns its final HTML.
|
|
240
228
|
|
|
241
229
|
Another way to say it:
|
|
242
230
|
|
|
243
|
-
- a
|
|
244
|
-
- the
|
|
245
|
-
- the
|
|
231
|
+
- a boundary token says "this subtree belongs to another renderer, but the current renderer still owns the overall render pass"
|
|
232
|
+
- the token stores just enough information to make that later renderer-owned handoff deterministic
|
|
233
|
+
- the queue exists so nested foreign boundaries resolve from leaves to parents while preserving child insertion order and emitted assets
|
|
246
234
|
|
|
247
|
-
### 5.1
|
|
235
|
+
### 5.1 Boundary interception in `eco.component` factory
|
|
248
236
|
|
|
249
|
-
The key rule here today is:
|
|
237
|
+
The key rule here today is: boundaries are resolved by the owning renderer, not by a shared core fallback. During an active component render pass, `eco.component` asks the current render boundary context whether the next boundary should render inline or be resolved by a foreign renderer runtime.
|
|
250
238
|
|
|
251
|
-
For the current built-in integrations, this is how non-
|
|
239
|
+
For the current built-in integrations, this is how non-owning renderers hand foreign subtrees back to the owning runtime without relying on a shared core fallback.
|
|
252
240
|
|
|
253
241
|
```mermaid
|
|
254
242
|
flowchart TD
|
|
255
243
|
A[eco component render] --> B[getComponentRenderContext]
|
|
256
|
-
B --> C[
|
|
257
|
-
C --> D{
|
|
258
|
-
D -- No --> E[render component content
|
|
259
|
-
D -- Yes --> F[
|
|
260
|
-
F --> G[store props in propsByRef]
|
|
261
|
-
G --> H{children include eco-marker tokens?}
|
|
262
|
-
H -- Yes --> I[create slotRef and slotChildrenByRef links]
|
|
263
|
-
H -- No --> J[no slot links]
|
|
264
|
-
I --> K[createComponentMarker]
|
|
265
|
-
J --> K
|
|
266
|
-
K --> L[return eco marker token]
|
|
244
|
+
B --> C[boundaryRuntime interceptBoundarySync]
|
|
245
|
+
C --> D{resolved foreign boundary?}
|
|
246
|
+
D -- No --> E[render component content inline]
|
|
247
|
+
D -- Yes --> F[return renderer-owned resolved html]
|
|
267
248
|
```
|
|
268
249
|
|
|
269
|
-
### 5.2
|
|
250
|
+
### 5.2 Queued boundary execution
|
|
270
251
|
|
|
271
|
-
|
|
252
|
+
When string-first renderers queue foreign boundaries, the base renderer helper resolves queued boundary tokens directly against the shared queue service. That pass is intentionally narrow: it only resolves queued boundary tokens that the owning renderer emitted as transport artifacts for that string runtime.
|
|
272
253
|
|
|
273
|
-
This means
|
|
254
|
+
This means boundary tokens are no longer a general component-boundary contract. Core only resolves queued boundary payloads that already belong to a renderer-owned string boundary workflow.
|
|
274
255
|
|
|
275
256
|
```mermaid
|
|
276
257
|
flowchart TD
|
|
277
|
-
A[
|
|
278
|
-
B --> C[
|
|
279
|
-
C --> D[
|
|
280
|
-
D --> E[
|
|
281
|
-
E --> F[
|
|
282
|
-
F --> G[
|
|
283
|
-
G --> H[
|
|
284
|
-
H --> I[
|
|
285
|
-
I --> J[renderer.renderComponent]
|
|
286
|
-
J --> K[collect component assets]
|
|
287
|
-
K --> L[apply root attributes to first element]
|
|
288
|
-
L --> M[replace marker token in HTML]
|
|
289
|
-
M --> N[resolved html and assets]
|
|
258
|
+
A[string boundary runtime html] --> B[find queued boundary tokens]
|
|
259
|
+
B --> C[resolve nested child tokens first]
|
|
260
|
+
C --> D[dispatch boundary to owning renderer]
|
|
261
|
+
D --> E[renderer.renderComponentBoundary]
|
|
262
|
+
E --> F[collect emitted assets]
|
|
263
|
+
F --> G[apply root attributes to first element]
|
|
264
|
+
G --> H[replace queued token in html]
|
|
265
|
+
H --> I[resolved html and merged assets]
|
|
290
266
|
```
|
|
291
267
|
|
|
292
268
|
## 6) Explicit Rendering Paths (outside FS page matching)
|
|
@@ -345,15 +321,12 @@ For someone new to the rendering system, this is probably the most useful order
|
|
|
345
321
|
6. `integration-renderer.ts`
|
|
346
322
|
7. `render-preparation.service.ts`
|
|
347
323
|
8. `render-execution.service.ts`
|
|
348
|
-
9. `
|
|
324
|
+
9. `queued-boundary-runtime.service.ts`
|
|
349
325
|
10. `html-transformer.service.ts`
|
|
350
326
|
11. `page-module-loader.ts`
|
|
351
327
|
12. `dependency-resolver.ts`
|
|
352
|
-
13. `
|
|
353
|
-
14. `component-
|
|
354
|
-
15. `component-graph-executor.ts`
|
|
355
|
-
16. `eco.ts`
|
|
356
|
-
17. `component-render-context.ts`
|
|
328
|
+
13. `eco.ts`
|
|
329
|
+
14. `component-render-context.ts`
|
|
357
330
|
|
|
358
331
|
## 9) Key Files
|
|
359
332
|
|
|
@@ -368,10 +341,7 @@ For someone new to the rendering system, this is probably the most useful order
|
|
|
368
341
|
- `packages/core/src/route-renderer/orchestration/integration-renderer.ts`
|
|
369
342
|
- `packages/core/src/route-renderer/orchestration/render-preparation.service.ts`
|
|
370
343
|
- `packages/core/src/route-renderer/orchestration/render-execution.service.ts`
|
|
371
|
-
- `packages/core/src/route-renderer/
|
|
372
|
-
- `packages/core/src/route-renderer/component-graph/component-marker.ts`
|
|
373
|
-
- `packages/core/src/route-renderer/component-graph/component-graph.ts`
|
|
374
|
-
- `packages/core/src/route-renderer/component-graph/component-graph-executor.ts`
|
|
344
|
+
- `packages/core/src/route-renderer/orchestration/queued-boundary-runtime.service.ts`
|
|
375
345
|
- `packages/core/src/route-renderer/page-loading/page-module-loader.ts`
|
|
376
346
|
- `packages/core/src/route-renderer/page-loading/dependency-resolver.ts`
|
|
377
347
|
- `packages/core/src/services/module-loading/page-module-import.service.ts`
|
|
@@ -25,23 +25,18 @@ Framework-owned orchestration services and renderer base class:
|
|
|
25
25
|
|
|
26
26
|
- `integration-renderer.ts`: abstract base class that coordinates end-to-end route rendering.
|
|
27
27
|
- `render-preparation.service.ts`: page module/data/dependency preparation before render.
|
|
28
|
-
- `render-execution.service.ts`: render capture,
|
|
28
|
+
- `render-execution.service.ts`: render capture, unresolved boundary artifact enforcement, and finalization.
|
|
29
|
+
- `queued-boundary-runtime.service.ts`: shared queued foreign-boundary runtime used directly by renderer-owned helpers, including string-first renderers.
|
|
29
30
|
|
|
30
31
|
It also provides:
|
|
31
32
|
|
|
32
33
|
- `renderToResponse()` contract for explicit-route rendering.
|
|
33
34
|
- `renderComponent()` contract for component-level orchestration and artifact reporting.
|
|
34
|
-
-
|
|
35
|
+
- deferred boundary resolution for nested cross-integration component boundaries.
|
|
35
36
|
|
|
36
|
-
###
|
|
37
|
+
### Boundary Tokens
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
- `createComponentMarker()` for canonical `<eco-marker ...></eco-marker>` generation.
|
|
41
|
-
- `parseComponentMarkers()` for marker extraction from rendered HTML.
|
|
42
|
-
- node collection by marker id.
|
|
43
|
-
- parent/child edges from slot reference registry.
|
|
44
|
-
- topological levels for bottom-up execution.
|
|
39
|
+
Renderer-owned runtimes may emit internal boundary tokens while they resolve foreign descendants before returning final HTML. If literal `<eco-marker ...></eco-marker>` markup survives to route finalization, it is treated as an unresolved boundary artifact rather than a normal transport mechanism.
|
|
45
40
|
|
|
46
41
|
### `page-loading/`
|
|
47
42
|
|
|
@@ -61,7 +56,7 @@ Builds processed assets from component dependency declarations:
|
|
|
61
56
|
|
|
62
57
|
Default behavior:
|
|
63
58
|
|
|
64
|
-
-
|
|
59
|
+
- renderer-owned component-boundary orchestration + component render artifacts.
|
|
65
60
|
- global lazy trigger map + global injector bootstrap.
|
|
66
61
|
|
|
67
62
|
Global injector lifecycle notes:
|
|
@@ -87,12 +82,10 @@ Current base orchestration behavior:
|
|
|
87
82
|
- Merges returned `assets` into processed dependencies.
|
|
88
83
|
- Applies returned `rootAttributes` to the first element under `<body>`.
|
|
89
84
|
|
|
90
|
-
When rendered output contains
|
|
85
|
+
When rendered output still contains unresolved boundary artifact HTML:
|
|
91
86
|
|
|
92
|
-
-
|
|
93
|
-
-
|
|
94
|
-
- fails fast when marker component refs or props refs are missing.
|
|
95
|
-
- merges marker-rendered assets back into the dependency pipeline with deduplication.
|
|
87
|
+
- route execution now fails fast instead of attempting any route-level unresolved-boundary fallback.
|
|
88
|
+
- renderer-owned boundary runtimes are responsible for resolving foreign nested components before final route HTML is returned.
|
|
96
89
|
|
|
97
90
|
This enables island-style hydration assets (for example React/Lit/Kita integration outputs) to be emitted through the normal dependency injection pipeline.
|
|
98
91
|
|
|
@@ -115,8 +108,9 @@ This enables island-style hydration assets (for example React/Lit/Kita integrati
|
|
|
115
108
|
6. HTML transformer injects head/body dependencies.
|
|
116
109
|
7. Route result returns body + metadata + cache strategy.
|
|
117
110
|
|
|
118
|
-
##
|
|
111
|
+
## Current Limits And Near-Term Work
|
|
112
|
+
|
|
113
|
+
If you are reading this file to understand today's contract, you can stop at the output pipeline above. The items below describe areas still evolving rather than required behavior.
|
|
119
114
|
|
|
120
|
-
-
|
|
121
|
-
-
|
|
122
|
-
- Add optional batching by integration per graph level to reduce repeated renderer invocations.
|
|
115
|
+
- Deep multi-level mixed-integration trees now rely on renderer-owned boundary runtimes rather than a shared post-render graph resolver.
|
|
116
|
+
- Each renderer still decides how to hand off foreign boundaries, so specialized runtimes remain appropriate where child serialization or hydration contracts differ.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { EcoComponent } from '../../types/public-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Result returned by a renderer-owned boundary runtime.
|
|
4
|
+
*
|
|
5
|
+
* `inline` keeps rendering inside the current integration. `resolved` returns a
|
|
6
|
+
* renderer-owned value immediately, which can be final HTML or a renderer-local
|
|
7
|
+
* transport token for later queue resolution.
|
|
8
|
+
*/
|
|
9
|
+
export type ComponentBoundaryInterceptionResult = {
|
|
10
|
+
kind: 'inline';
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'resolved';
|
|
13
|
+
value: unknown;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Boundary metadata passed into the active renderer-owned runtime.
|
|
17
|
+
*/
|
|
18
|
+
export type ComponentBoundaryInterceptionInput = {
|
|
19
|
+
currentIntegration: string;
|
|
20
|
+
targetIntegration?: string;
|
|
21
|
+
component: EcoComponent;
|
|
22
|
+
props: Record<string, unknown>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Narrow renderer-owned boundary runtime injected into one active render
|
|
26
|
+
* context.
|
|
27
|
+
*
|
|
28
|
+
* Integrations implement this contract when foreign boundaries must be handed
|
|
29
|
+
* off inside the renderer instead of being left for route-level reconciliation.
|
|
30
|
+
*/
|
|
31
|
+
export interface ComponentBoundaryRuntime {
|
|
32
|
+
interceptBoundary?(input: ComponentBoundaryInterceptionInput): ComponentBoundaryInterceptionResult | Promise<ComponentBoundaryInterceptionResult>;
|
|
33
|
+
interceptBoundarySync?(input: ComponentBoundaryInterceptionInput): ComponentBoundaryInterceptionResult;
|
|
34
|
+
}
|
|
35
|
+
type ComponentBoundaryRenderInput = {
|
|
36
|
+
component: EcoComponent;
|
|
37
|
+
props: Record<string, unknown>;
|
|
38
|
+
targetIntegration?: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Per-render mutable state used while applying boundary interception and lazy
|
|
42
|
+
* output wrapping.
|
|
43
|
+
*/
|
|
44
|
+
export type ComponentRenderContext = {
|
|
45
|
+
currentIntegration: string;
|
|
46
|
+
boundaryRuntime?: ComponentBoundaryRuntime;
|
|
47
|
+
interceptBoundary(input: ComponentBoundaryRenderInput): Promise<unknown | undefined> | unknown | undefined;
|
|
48
|
+
finalizeComponentRender<T>(component: EcoComponent, content: T): T;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Returns the current component render context, if one is active.
|
|
52
|
+
*
|
|
53
|
+
* @returns Active render context or `undefined` outside render execution.
|
|
54
|
+
*/
|
|
55
|
+
export declare function getComponentRenderContext(): ComponentRenderContext | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Runs boundary interception for one component boundary.
|
|
58
|
+
*
|
|
59
|
+
* The active runtime may resolve the boundary immediately or keep it inline.
|
|
60
|
+
*/
|
|
61
|
+
export declare function interceptComponentBoundary(input: ComponentBoundaryRenderInput): Promise<unknown | undefined> | unknown | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Applies lazy trigger or injector wrapping to completed component output.
|
|
64
|
+
*
|
|
65
|
+
* This helper works both inside render-context execution and in fallback flows
|
|
66
|
+
* where no active context exists.
|
|
67
|
+
*/
|
|
68
|
+
export declare function finalizeComponentRender<T>(component: EcoComponent, content: T): T;
|
|
69
|
+
/**
|
|
70
|
+
* Runs render work under a fresh component render context and returns the
|
|
71
|
+
* resulting value.
|
|
72
|
+
*
|
|
73
|
+
* @param input Execution metadata for current integration and boundary policy.
|
|
74
|
+
* @param render Async render function to execute inside the context.
|
|
75
|
+
* @returns Render result value.
|
|
76
|
+
*/
|
|
77
|
+
export declare function runWithComponentRenderContext<T>(input: {
|
|
78
|
+
currentIntegration: string;
|
|
79
|
+
boundaryRuntime?: ComponentBoundaryRuntime;
|
|
80
|
+
}, render: () => Promise<T>): Promise<{
|
|
81
|
+
value: T;
|
|
82
|
+
}>;
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { addTriggerAttribute, isThenable, wrapWithScriptsInjector } from "./render-output.utils.js";
|
|
2
|
+
class ComponentRenderOutputRuntime {
|
|
3
|
+
finalizeComponentRender(component, content) {
|
|
4
|
+
const lazyTriggers = component.config?._resolvedLazyTriggers;
|
|
5
|
+
if (lazyTriggers && lazyTriggers.length > 0) {
|
|
6
|
+
return this.addTriggerToContent(content, lazyTriggers[0].triggerId);
|
|
7
|
+
}
|
|
8
|
+
const lazyGroups = component.config?._resolvedLazyScripts;
|
|
9
|
+
if (lazyGroups && lazyGroups.length > 0) {
|
|
10
|
+
return this.wrapContentWithScriptsInjector(content, lazyGroups);
|
|
11
|
+
}
|
|
12
|
+
return content;
|
|
13
|
+
}
|
|
14
|
+
addTriggerToContent(content, triggerId) {
|
|
15
|
+
if (isThenable(content)) {
|
|
16
|
+
return content.then((resolvedContent) => addTriggerAttribute(resolvedContent, triggerId));
|
|
17
|
+
}
|
|
18
|
+
return addTriggerAttribute(content, triggerId);
|
|
19
|
+
}
|
|
20
|
+
wrapContentWithScriptsInjector(content, lazyGroups) {
|
|
21
|
+
if (isThenable(content)) {
|
|
22
|
+
return content.then((resolvedContent) => wrapWithScriptsInjector(resolvedContent, lazyGroups));
|
|
23
|
+
}
|
|
24
|
+
return wrapWithScriptsInjector(content, lazyGroups);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
class ContextualComponentRenderRuntime extends ComponentRenderOutputRuntime {
|
|
28
|
+
context;
|
|
29
|
+
constructor(context) {
|
|
30
|
+
super();
|
|
31
|
+
this.context = context;
|
|
32
|
+
}
|
|
33
|
+
applyBoundaryInterceptionResult(result) {
|
|
34
|
+
if (result.kind === "resolved") {
|
|
35
|
+
return result.value;
|
|
36
|
+
}
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Resolves one boundary interception through the active runtime.
|
|
41
|
+
*
|
|
42
|
+
* The runtime may choose inline rendering or immediate resolved output.
|
|
43
|
+
*/
|
|
44
|
+
interceptBoundary(input) {
|
|
45
|
+
const boundaryRuntimeInput = {
|
|
46
|
+
currentIntegration: this.context.currentIntegration,
|
|
47
|
+
targetIntegration: input.targetIntegration,
|
|
48
|
+
component: input.component,
|
|
49
|
+
props: input.props
|
|
50
|
+
};
|
|
51
|
+
const asyncInterception = this.context.boundaryRuntime?.interceptBoundary?.(boundaryRuntimeInput);
|
|
52
|
+
if (asyncInterception !== void 0) {
|
|
53
|
+
if (isThenable(asyncInterception)) {
|
|
54
|
+
return asyncInterception.then((result) => this.applyBoundaryInterceptionResult(result));
|
|
55
|
+
}
|
|
56
|
+
return this.applyBoundaryInterceptionResult(asyncInterception);
|
|
57
|
+
}
|
|
58
|
+
const syncInterception = this.context.boundaryRuntime?.interceptBoundarySync?.(boundaryRuntimeInput);
|
|
59
|
+
if (syncInterception === void 0) {
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
return this.applyBoundaryInterceptionResult(syncInterception);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const GLOBAL_COMPONENT_RENDER_CONTEXT_STATE_KEY = "__ECOPAGES_COMPONENT_RENDER_CONTEXT_STATE__";
|
|
66
|
+
function getSharedContextScope() {
|
|
67
|
+
const globalProcess = globalThis.process;
|
|
68
|
+
if (globalProcess && typeof globalProcess === "object") {
|
|
69
|
+
return globalProcess;
|
|
70
|
+
}
|
|
71
|
+
return globalThis;
|
|
72
|
+
}
|
|
73
|
+
function getComponentRenderContextState() {
|
|
74
|
+
const sharedScope = getSharedContextScope();
|
|
75
|
+
sharedScope[GLOBAL_COMPONENT_RENDER_CONTEXT_STATE_KEY] ??= {
|
|
76
|
+
contextStack: [],
|
|
77
|
+
nodeContextStorage: null,
|
|
78
|
+
nodeContextStorageLoader: null
|
|
79
|
+
};
|
|
80
|
+
return sharedScope[GLOBAL_COMPONENT_RENDER_CONTEXT_STATE_KEY];
|
|
81
|
+
}
|
|
82
|
+
async function getContextStorage() {
|
|
83
|
+
const state = getComponentRenderContextState();
|
|
84
|
+
if (state.nodeContextStorage) {
|
|
85
|
+
return state.nodeContextStorage;
|
|
86
|
+
}
|
|
87
|
+
if (state.nodeContextStorageLoader) {
|
|
88
|
+
return state.nodeContextStorageLoader;
|
|
89
|
+
}
|
|
90
|
+
state.nodeContextStorageLoader = import("node:async_hooks").then((module) => {
|
|
91
|
+
const storage = new module.AsyncLocalStorage();
|
|
92
|
+
state.nodeContextStorage = {
|
|
93
|
+
getStore: () => storage.getStore(),
|
|
94
|
+
run: (store, callback) => storage.run(store, callback)
|
|
95
|
+
};
|
|
96
|
+
return state.nodeContextStorage;
|
|
97
|
+
}).catch(() => {
|
|
98
|
+
state.nodeContextStorage = null;
|
|
99
|
+
return null;
|
|
100
|
+
}).finally(() => {
|
|
101
|
+
state.nodeContextStorageLoader = null;
|
|
102
|
+
});
|
|
103
|
+
return state.nodeContextStorageLoader;
|
|
104
|
+
}
|
|
105
|
+
function getComponentRenderContext() {
|
|
106
|
+
const state = getComponentRenderContextState();
|
|
107
|
+
return state.nodeContextStorage?.getStore() ?? state.contextStack[state.contextStack.length - 1];
|
|
108
|
+
}
|
|
109
|
+
const componentRenderOutputRuntime = new ComponentRenderOutputRuntime();
|
|
110
|
+
function interceptComponentBoundary(input) {
|
|
111
|
+
return getComponentRenderContext()?.interceptBoundary(input);
|
|
112
|
+
}
|
|
113
|
+
function finalizeComponentRender(component, content) {
|
|
114
|
+
const renderContext = getComponentRenderContext();
|
|
115
|
+
return renderContext?.finalizeComponentRender(component, content) ?? componentRenderOutputRuntime.finalizeComponentRender(component, content);
|
|
116
|
+
}
|
|
117
|
+
async function runWithComponentRenderContext(input, render) {
|
|
118
|
+
const context = {
|
|
119
|
+
currentIntegration: input.currentIntegration,
|
|
120
|
+
boundaryRuntime: input.boundaryRuntime
|
|
121
|
+
};
|
|
122
|
+
const runtime = new ContextualComponentRenderRuntime(context);
|
|
123
|
+
context.interceptBoundary = (deferredInput) => runtime.interceptBoundary(deferredInput);
|
|
124
|
+
context.finalizeComponentRender = (component, content) => runtime.finalizeComponentRender(component, content);
|
|
125
|
+
const storage = await getContextStorage();
|
|
126
|
+
let value;
|
|
127
|
+
if (storage) {
|
|
128
|
+
value = await storage.run(context, render);
|
|
129
|
+
} else {
|
|
130
|
+
const state = getComponentRenderContextState();
|
|
131
|
+
state.contextStack.push(context);
|
|
132
|
+
try {
|
|
133
|
+
value = await render();
|
|
134
|
+
} finally {
|
|
135
|
+
state.contextStack.pop();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
value
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
export {
|
|
143
|
+
finalizeComponentRender,
|
|
144
|
+
getComponentRenderContext,
|
|
145
|
+
interceptComponentBoundary,
|
|
146
|
+
runWithComponentRenderContext
|
|
147
|
+
};
|