@ecopages/core 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/package.json +3 -3
- package/src/adapters/node/create-app.d.ts +40 -11
- package/src/adapters/node/create-app.js +95 -69
- package/src/adapters/node/dev-session.js +0 -1
- package/src/adapters/node/http-request-bridge.d.ts +4 -0
- package/src/adapters/node/http-request-bridge.js +9 -1
- package/src/adapters/node/runtime-host.d.ts +28 -6
- package/src/adapters/node/runtime-host.js +35 -9
- package/src/adapters/node/server-adapter.d.ts +10 -35
- package/src/adapters/node/server-adapter.js +21 -58
- package/src/adapters/shared/hmr/hmr-manager.d.ts +21 -7
- package/src/adapters/shared/hmr/hmr-manager.js +58 -70
- package/src/adapters/shared/http/api-request-pipeline.d.ts +3 -12
- package/src/adapters/shared/http/api-request-pipeline.js +7 -7
- package/src/adapters/shared/http/dist-file-handler.d.ts +16 -0
- package/src/adapters/shared/http/dist-file-handler.js +172 -0
- package/src/adapters/shared/http/explicit-static-route-matcher.js +2 -1
- package/src/adapters/shared/http/fs-server-response-matcher.js +3 -2
- package/src/adapters/shared/runtime/bind-runtime-server.d.ts +5 -7
- package/src/adapters/shared/runtime/bind-runtime-server.js +8 -12
- package/src/adapters/shared/runtime/copy-runtime-public-dir.js +10 -9
- package/src/adapters/shared/runtime/port-manager.d.ts +8 -11
- package/src/adapters/shared/runtime/port-manager.js +19 -30
- package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +6 -9
- package/src/adapters/shared/runtime/runtime-server-lifecycle.js +2 -5
- package/src/adapters/shared/runtime/server-request-pipeline.d.ts +1 -3
- package/src/adapters/shared/runtime/server-request-pipeline.js +1 -5
- package/src/adapters/shared/runtime/server-static-builder.d.ts +3 -3
- package/src/adapters/shared/runtime/server-static-builder.js +3 -3
- package/src/adapters/shared/ws/node-http-websocket-upgrades.js +2 -1
- package/src/adapters/shared/ws/websocket-lifecycle.d.ts +5 -6
- package/src/adapters/shared/ws/websocket-lifecycle.js +1 -2
- package/src/assets/app-browser-client-build.js +1 -2
- package/src/assets/asset-processing-service/browser-runtime-entry-resolution.js +8 -8
- package/src/assets/asset-processing-service/browser-runtime-entry.factory.js +4 -4
- package/src/assets/asset-processing-service/processors/script/file-script.processor.d.ts +12 -8
- package/src/assets/asset-processing-service/processors/script/file-script.processor.js +36 -16
- package/src/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +11 -6
- package/src/assets/browser-asset-output.d.ts +19 -0
- package/src/assets/browser-asset-output.js +30 -0
- package/src/assets/hashed-browser-asset.d.ts +8 -6
- package/src/assets/hashed-browser-asset.js +8 -6
- package/src/build/build-adapter.d.ts +2 -19
- package/src/build/build-adapter.js +0 -21
- package/src/build/build-graph.js +2 -2
- package/src/build/cache/cache-keys.d.ts +0 -3
- package/src/build/cache/cache-keys.js +0 -14
- package/src/build/cache/pages-unified-graph-build.js +2 -17
- package/src/build/contracts/build-contracts.d.ts +0 -3
- package/src/build/preserve-import-meta-transform.js +2 -2
- package/src/build/rolldown/app-package-declarations.js +3 -3
- package/src/build/rolldown/rolldown-adapter-helpers.js +3 -3
- package/src/build/rolldown/rolldown-build-adapter.d.ts +0 -1
- package/src/build/rolldown/rolldown-build-adapter.js +1 -2
- package/src/build/rolldown/rolldown-build-invocation-metrics.d.ts +1 -2
- package/src/build/rolldown/rolldown-build-invocation-metrics.js +5 -12
- package/src/build/rolldown/server-side-css-shim-plugin.js +3 -3
- package/src/build/runtime/build-queue.d.ts +8 -13
- package/src/build/runtime/build-queue.js +6 -17
- package/src/build/server/app-module-loader.service.d.ts +1 -1
- package/src/build/server/app-module-loader.service.js +0 -2
- package/src/build/server/page-module-import.service.d.ts +2 -3
- package/src/build/server/page-module-import.service.js +3 -4
- package/src/build/server-bundle-deploy-manifest.d.ts +5 -0
- package/src/build/server-bundle-deploy-manifest.js +15 -1
- package/src/build/server-bundle-publication.js +4 -5
- package/src/build.d.ts +2 -2
- package/src/build.js +2 -2
- package/src/config/assembly/app-runtime.d.ts +2 -2
- package/src/config/assembly/app-runtime.js +2 -2
- package/src/config/assembly/finalize-config.d.ts +4 -4
- package/src/config/assembly/finalize-config.js +4 -5
- package/src/config/config-module-files.js +2 -3
- package/src/config/internal-types.d.ts +0 -7
- package/src/config/user-config-types.d.ts +0 -4
- package/src/diagnostics/request-pipeline-metrics.d.ts +3 -3
- package/src/diagnostics/request-pipeline-metrics.js +4 -4
- package/src/diagnostics/startup-trace.js +2 -5
- package/src/errors/http-error.d.ts +2 -2
- package/src/errors/http-error.js +4 -4
- package/src/hmr/client/hmr-runtime.js +16 -7
- package/src/hmr/client/module-update.d.ts +7 -0
- package/src/hmr/client/module-update.js +21 -4
- package/src/hmr/hmr-strategy.d.ts +0 -3
- package/src/hmr/hmr-strategy.js +0 -3
- package/src/hmr/strategies/js-hmr-strategy.d.ts +2 -3
- package/src/hmr/strategies/js-hmr-strategy.js +3 -6
- package/src/html-pages/html-page-module-scripts.js +4 -3
- package/src/html-pages/html-page-renderer.js +2 -3
- package/src/plugins/alias-resolver-cache.d.ts +4 -3
- package/src/plugins/alias-resolver-cache.js +4 -3
- package/src/plugins/component-import-discovery.js +4 -4
- package/src/plugins/eco-component-meta-plugin.d.ts +10 -1
- package/src/plugins/eco-component-meta-plugin.js +66 -10
- package/src/plugins/foreign-jsx-override-plugin.js +4 -3
- package/src/plugins/tsconfig-import-resolver.js +12 -12
- package/src/route-renderer/error-pages/default-error-pages.js +2 -1
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +1 -1
- package/src/route-renderer/orchestration/foreign-child/render-session.d.ts +0 -1
- package/src/route-renderer/orchestration/integration-renderer.d.ts +10 -5
- package/src/route-renderer/orchestration/integration-renderer.js +13 -14
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +1 -23
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +0 -29
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +10 -32
- package/src/route-renderer/page-loading/ecopages-virtual-imports.js +2 -2
- package/src/route-renderer/page-loading/page-dependency-bundling.js +5 -5
- package/src/route-renderer/page-loading/page-module-loader.js +1 -1
- package/src/route-renderer/route-renderer.d.ts +2 -5
- package/src/route-renderer/route-renderer.js +2 -4
- package/src/router/client/link-navigation-policy.d.ts +4 -1
- package/src/router/client/link-navigation-policy.js +20 -6
- package/src/router/server/route-registry.d.ts +0 -1
- package/src/router/server/route-registry.js +3 -13
- package/src/router/server/segment-path-matcher.d.ts +12 -0
- package/src/router/server/segment-path-matcher.js +30 -0
- package/src/static-site-generator/static-site-generator.d.ts +0 -5
- package/src/static-site-generator/static-site-generator.js +2 -15
- package/src/types/contracts.d.ts +17 -27
- package/src/types/public-types.d.ts +1 -1
- package/src/utils/format-error-chain.d.ts +9 -0
- package/src/utils/format-error-chain.js +20 -0
- package/src/utils/invariant.d.ts +6 -1
- package/src/utils/invariant.js +7 -2
- package/src/watchers/project-watcher.d.ts +20 -1
- package/src/watchers/project-watcher.js +40 -9
- package/src/watchers/workspace-package-watch-roots.js +5 -5
- package/src/adapters/README.md +0 -58
- package/src/adapters/shared/hmr/hmr-manager.test-helpers.d.ts +0 -28
- package/src/adapters/shared/hmr/hmr-manager.test-helpers.js +0 -53
- package/src/adapters/shared/runtime/runtime-host.d.ts +0 -15
- package/src/adapters/shared/runtime/runtime-host.js +0 -1
- package/src/assets/README.md +0 -35
- package/src/build/README.md +0 -298
- package/src/build/server/README.md +0 -50
- package/src/cache/README.md +0 -5
- package/src/client/README.md +0 -5
- package/src/client/navigation-scripts/navigation-scripts.test.browser.d.ts +0 -1
- package/src/client/navigation-scripts/navigation-scripts.test.browser.js +0 -111
- package/src/client/scroll.test.browser.d.ts +0 -1
- package/src/client/scroll.test.browser.js +0 -31
- package/src/client/view-transitions.test.browser.d.ts +0 -1
- package/src/client/view-transitions.test.browser.js +0 -53
- package/src/config/README.md +0 -58
- package/src/config/constants.d.ts +0 -1
- package/src/config/constants.js +0 -1
- package/src/dev/README.md +0 -61
- package/src/dev/invalidation/README.md +0 -11
- package/src/dev-toolbar/README.md +0 -66
- package/src/diagnostics/README.md +0 -11
- package/src/eco/README.md +0 -776
- package/src/errors/README.md +0 -5
- package/src/global/README.md +0 -5
- package/src/hmr/README.md +0 -64
- package/src/hmr/client/build-error-overlay.test.browser.d.ts +0 -1
- package/src/hmr/client/build-error-overlay.test.browser.js +0 -48
- package/src/hmr/client/hmr-runtime.test.browser.d.ts +0 -1
- package/src/hmr/client/hmr-runtime.test.browser.js +0 -32
- package/src/hmr/entrypoint-dependency-graph.d.ts +0 -12
- package/src/hmr/entrypoint-dependency-graph.js +0 -27
- package/src/hmr/hmr-file-change-prep.d.ts +0 -9
- package/src/hmr/hmr-file-change-prep.js +0 -11
- package/src/html/README.md +0 -15
- package/src/html-pages/README.md +0 -104
- package/src/islands/README.md +0 -44
- package/src/page-cache/README.md +0 -17
- package/src/plugins/README.md +0 -53
- package/src/route-renderer/GRAPH.md +0 -142
- package/src/route-renderer/README.md +0 -160
- package/src/route-renderer/error-pages/README.md +0 -11
- package/src/route-renderer/orchestration/custom-element-scripts/README.md +0 -15
- package/src/route-renderer/orchestration/integration-renderer.test-fixtures.d.ts +0 -39
- package/src/route-renderer/orchestration/integration-renderer.test-fixtures.js +0 -94
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.test-fixtures.d.ts +0 -35
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.test-fixtures.js +0 -69
- package/src/router/README.md +0 -160
- package/src/router/client/link-intent.test.browser.d.ts +0 -1
- package/src/router/client/link-intent.test.browser.js +0 -33
- package/src/router/client/link-navigation-policy.test.browser.d.ts +0 -1
- package/src/router/client/link-navigation-policy.test.browser.js +0 -142
- package/src/router/client/navigation-commit.test.browser.d.ts +0 -1
- package/src/router/client/navigation-commit.test.browser.js +0 -116
- package/src/router/client/navigation-document.test.browser.d.ts +0 -1
- package/src/router/client/navigation-document.test.browser.js +0 -77
- package/src/router/client/navigation-head.test.browser.d.ts +0 -1
- package/src/router/client/navigation-head.test.browser.js +0 -101
- package/src/router/client/navigation-lifecycle.test.browser.d.ts +0 -1
- package/src/router/client/navigation-lifecycle.test.browser.js +0 -97
- package/src/router/client/navigation-view-transition.test.browser.d.ts +0 -1
- package/src/router/client/navigation-view-transition.test.browser.js +0 -189
- package/src/router/client/staged-stylesheets.test-fixtures.d.ts +0 -18
- package/src/router/client/staged-stylesheets.test-fixtures.js +0 -31
- package/src/static-site-generator/README.md +0 -67
- package/src/static-site-generator/static-site-generator.test-utils.d.ts +0 -2
- package/src/static-site-generator/static-site-generator.test-utils.js +0 -41
- package/src/types/README.md +0 -5
- package/src/utils/README.md +0 -7
- package/src/validation/README.md +0 -9
- package/src/watchers/README.md +0 -15
- package/src/watchers/project-watcher.test-helpers.d.ts +0 -60
- package/src/watchers/project-watcher.test-helpers.js +0 -108
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
# Rendering Logic Graph
|
|
2
|
-
|
|
3
|
-
This document maps the rendering logic in core using the ownership, foreign-child, and foreign-subtree model.
|
|
4
|
-
|
|
5
|
-
## Design Principles
|
|
6
|
-
|
|
7
|
-
- Rendering entry points stay separate, but they converge on the same integration renderer contracts.
|
|
8
|
-
- Integration selection happens outside the renderer. Once selected, the integration renderer owns the render pipeline.
|
|
9
|
-
- Ownership is preparation-time metadata. Runtime handoff still happens inside renderer-owned foreign-child interception.
|
|
10
|
-
- Route-level fallback resolution is gone. Unresolved `<eco-marker>` artifacts are now a failure signal.
|
|
11
|
-
- Asset emission converges into one final HTML transformation step.
|
|
12
|
-
|
|
13
|
-
## 1) Runtime Request Flow
|
|
14
|
-
|
|
15
|
-
```mermaid
|
|
16
|
-
flowchart TD
|
|
17
|
-
A[HTTP request] --> B[NodeServerAdapter handleRequest]
|
|
18
|
-
B --> C[ServerRequestPipeline handleSharedRequest]
|
|
19
|
-
C --> D{API route?}
|
|
20
|
-
D -- Yes --> E[executeApiHandler]
|
|
21
|
-
D -- No --> F[ServerRouteHandler handleResponse]
|
|
22
|
-
|
|
23
|
-
F --> G{Explicit static route match?}
|
|
24
|
-
G -- Yes --> H[ExplicitStaticRouteMatcher handleMatch]
|
|
25
|
-
G -- No --> I{FS route match without file extension?}
|
|
26
|
-
I -- Yes --> J[FileSystemResponseMatcher handleMatch]
|
|
27
|
-
I -- No --> K[FileSystemResponseMatcher handleNoMatch]
|
|
28
|
-
|
|
29
|
-
J --> L[RouteRendererFactory createRenderer]
|
|
30
|
-
L --> M[RouteRenderer createRoute]
|
|
31
|
-
M --> N[IntegrationRenderer execute]
|
|
32
|
-
N --> O[response body and cache strategy]
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## 2) Route Render Flow
|
|
36
|
-
|
|
37
|
-
`IntegrationRenderer.execute()` delegates shared route orchestration to `RouteRenderOrchestrator`.
|
|
38
|
-
|
|
39
|
-
```mermaid
|
|
40
|
-
flowchart TD
|
|
41
|
-
A[IntegrationRenderer.execute] --> B[ensure Integration runtime]
|
|
42
|
-
B --> C[optional renderRemote hook]
|
|
43
|
-
C --> D{remote result?}
|
|
44
|
-
D -- Yes --> E[remote route result]
|
|
45
|
-
D -- No --> F[create per-render session]
|
|
46
|
-
F --> G[RouteRenderOrchestrator.prepareRenderOptions]
|
|
47
|
-
G --> H[resolve page, data, ownership, dependencies, and browser graph]
|
|
48
|
-
H --> I[build pagePackage and prepared render options]
|
|
49
|
-
I --> J[IntegrationRenderer.render via document shell]
|
|
50
|
-
J --> K[capture rendered body as html]
|
|
51
|
-
K --> L[inspect unresolved marker artifacts]
|
|
52
|
-
L --> M{unresolved eco-marker remains?}
|
|
53
|
-
M -- Yes --> N[throw unresolved artifact error]
|
|
54
|
-
M -- No --> O[stamp document attributes when needed]
|
|
55
|
-
O --> P[htmlTransformer transform]
|
|
56
|
-
P --> Q[final body and cache strategy]
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## 3) Mixed-Integration Render Model
|
|
60
|
-
|
|
61
|
-
The renderer-level mental model is:
|
|
62
|
-
|
|
63
|
-
1. declared dependencies describe ownership
|
|
64
|
-
2. active render context intercepts foreign children
|
|
65
|
-
3. the owning renderer returns a foreign subtree
|
|
66
|
-
|
|
67
|
-
```mermaid
|
|
68
|
-
flowchart TD
|
|
69
|
-
A[eco.component render] --> B[getComponentRenderContext]
|
|
70
|
-
B --> C[foreignChildRuntime interceptForeignChildSync]
|
|
71
|
-
C --> D{same integration?}
|
|
72
|
-
D -- Yes --> E[render inline]
|
|
73
|
-
D -- No --> F[delegate to owning renderer]
|
|
74
|
-
F --> G[owning renderer renderComponentWithForeignChildren]
|
|
75
|
-
G --> H[owning renderer returns ComponentRenderResult]
|
|
76
|
-
H --> I[resolved html plus assets and optional root attributes]
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## 4) Queued Foreign-Subtree Resolution
|
|
80
|
-
|
|
81
|
-
Some renderers cannot hand off foreign children inline. Those renderers can use the queue service during one render pass.
|
|
82
|
-
|
|
83
|
-
```mermaid
|
|
84
|
-
flowchart TD
|
|
85
|
-
A[current renderer encounters foreign child] --> B{can resolve inline?}
|
|
86
|
-
B -- Yes --> C[return resolved renderer-owned output]
|
|
87
|
-
B -- No --> D[queue foreign-subtree token]
|
|
88
|
-
D --> E[finish current render pass]
|
|
89
|
-
E --> F[resolveQueuedHtml function]
|
|
90
|
-
F --> G[resolve nested queued tokens first]
|
|
91
|
-
G --> H[dispatch foreign subtree to owning renderer]
|
|
92
|
-
H --> I[merge emitted assets and root attributes]
|
|
93
|
-
I --> J[replace token in html]
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## 5) Explicit Rendering Paths
|
|
97
|
-
|
|
98
|
-
These paths bypass most filesystem routing, but they still converge on the same renderer contracts.
|
|
99
|
-
|
|
100
|
-
```mermaid
|
|
101
|
-
flowchart TD
|
|
102
|
-
A[ExplicitStaticRouteMatcher handleMatch] --> B[route loader returns view]
|
|
103
|
-
B --> C[get renderer by integration]
|
|
104
|
-
C --> D[renderExplicitView then execute]
|
|
105
|
-
|
|
106
|
-
E[render context render] --> F[get renderer from integrations list]
|
|
107
|
-
F --> G[renderExplicitView then execute]
|
|
108
|
-
P[render context renderPartial] --> F2[get renderer from integrations list]
|
|
109
|
-
F2 --> G2[renderExplicitView on the component path]
|
|
110
|
-
|
|
111
|
-
H[StaticSiteGenerator explicit routes] --> I[resolve renderer without staticProps]
|
|
112
|
-
I --> J[renderExplicitView then execute]
|
|
113
|
-
J --> K[write html to dist]
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
## 6) Reading Order
|
|
117
|
-
|
|
118
|
-
The most useful reading order is:
|
|
119
|
-
|
|
120
|
-
1. `route-renderer.ts`
|
|
121
|
-
2. `orchestration/route-pipeline/route-render-orchestrator.ts`
|
|
122
|
-
3. `orchestration/integration-renderer.ts`
|
|
123
|
-
4. `orchestration/ownership-graph/ownership-validation.service.ts`
|
|
124
|
-
5. `orchestration/ownership-graph/component-graph.ts`
|
|
125
|
-
6. `../eco/component-render-context.ts`
|
|
126
|
-
7. `orchestration/foreign-child/foreign-subtree-execution.service.ts`
|
|
127
|
-
8. `page-loading/page-module-loader.ts`
|
|
128
|
-
9. `page-loading/dependency-resolver.ts`
|
|
129
|
-
10. `../eco/eco.ts`
|
|
130
|
-
|
|
131
|
-
## 7) Key Files
|
|
132
|
-
|
|
133
|
-
- `packages/core/src/route-renderer/route-renderer.ts`
|
|
134
|
-
- `packages/core/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.ts`
|
|
135
|
-
- `packages/core/src/route-renderer/orchestration/integration-renderer.ts`
|
|
136
|
-
- `packages/core/src/route-renderer/orchestration/ownership-graph/ownership-validation.service.ts`
|
|
137
|
-
- `packages/core/src/route-renderer/orchestration/ownership-graph/component-graph.ts`
|
|
138
|
-
- `packages/core/src/eco/component-render-context.ts`
|
|
139
|
-
- `packages/core/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.ts`
|
|
140
|
-
- `packages/core/src/route-renderer/page-loading/page-module-loader.ts`
|
|
141
|
-
- `packages/core/src/route-renderer/page-loading/dependency-resolver.ts`
|
|
142
|
-
- `packages/core/src/eco/eco.ts`
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
# Route Renderer Architecture
|
|
2
|
-
|
|
3
|
-
**Layer:** Rendering.
|
|
4
|
-
|
|
5
|
-
This folder contains the core rendering orchestration for Ecopages.
|
|
6
|
-
|
|
7
|
-
## Purpose
|
|
8
|
-
|
|
9
|
-
The route renderer layer is responsible for:
|
|
10
|
-
|
|
11
|
-
- selecting the correct integration renderer for a route
|
|
12
|
-
- loading page modules and resolving static data or metadata
|
|
13
|
-
- resolving component dependencies and page browser assets through the required app-owned `AssetProcessingService`
|
|
14
|
-
- coordinating mixed-integration rendering
|
|
15
|
-
- emitting final HTML plus cache strategy
|
|
16
|
-
|
|
17
|
-
## Core Concepts
|
|
18
|
-
|
|
19
|
-
The architecture is organized around three distinct concepts:
|
|
20
|
-
|
|
21
|
-
- `ownership`: declared component dependency metadata validated before render
|
|
22
|
-
- `foreign child`: a component encountered during render whose owning integration differs from the current integration
|
|
23
|
-
- `foreign subtree`: the rendered HTML and assets returned by the owning renderer for that Foreign Child
|
|
24
|
-
|
|
25
|
-
These concepts intentionally live in different places:
|
|
26
|
-
|
|
27
|
-
- `ownership-validation.service.ts` validates declared foreign ownership up front and fails the render on misconfiguration
|
|
28
|
-
- `../eco/component-render-context.ts` scopes component renders and exposes the active foreign-child runtime
|
|
29
|
-
- `foreign-subtree-execution.service.ts` contains the functions for mixed-integration execution and queued-token resolution
|
|
30
|
-
- `document-shell-render.service.ts` composes page, layout, and html template shells with one execution-scoped renderer cache
|
|
31
|
-
- `integration-renderer.ts` owns renderer-to-renderer delegation and integration-specific render hooks
|
|
32
|
-
- `route-render-orchestrator.ts` owns route preparation, final response capture, and unresolved artifact enforcement. Preparation builds one `PreparedComponentGraph` from the Html, Layout, Page, and resolved page-dependency roots. The graph records each component's owner, source file, direct assets, children, and foreign-descendant state. Ownership validation, route dependency collection, the page client plan, and dev cache watch paths consume that graph instead of walking component configs independently. The client plan contains entries, foreign runtimes, lazy triggers, and island files. Static route-plan preparation collects each node's lazy entries under its recorded owning Integration without processing eager assets, so Foreign Children contribute lazy entries to the app-wide build. `islandEntries` lists components whose Integration differs from their parent's, excluding the Html shell. The page owner's Page, Layout, and nested includes stay on `sourceComponents` so cache invalidation still watches them. Hydrating integrations pass `islandEntries` through `selectHydrationIslandEntries` so only Foreign Children of another owner receive per-component island scripts; the page owner's own tree is hydrated by the page bootstrap. On the non-HMR runtime path outside static export, each page owner contributes a grouped multi-entry browser build (`ecopages-app-browser-client`) for islands and lazy entries, so React islands on a Kita or Lit route still receive hydration scripts. Production static export collects those island and lazy entries together with every renderer's grouped Page Browser Graph entries and HTML shell module scripts into compatible app-wide browser build groups. React hydration entries import the component source inside their group, so compatible entries can share chunks when code splitting is enabled. Renderers stamp the resulting assets during SSR instead of starting per-island builds. Resolved lazy-trigger ids stay on the component config across later dependency passes so serialized foreign-child HTML can still receive `data-eco-trigger`. In the regular grouped build, island entries re-export the source module so the hydration script can import the component; a side-effect-only `import "path"` dropped named exports and left React counters inert.
|
|
33
|
-
|
|
34
|
-
## Build-Time JSX vs Runtime Foreign Children
|
|
35
|
-
|
|
36
|
-
Mixed-integration apps use two separate mechanisms:
|
|
37
|
-
|
|
38
|
-
| Layer | Mechanism | Purpose |
|
|
39
|
-
| ------- | ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
40
|
-
| Build | `getJsxOwnershipPlugins()` / `getHostScopedJsxOwnershipPlugins()` | Prepend `@jsxImportSource` so bundled `.tsx` files compile with the correct JSX runtime |
|
|
41
|
-
| Build | component identity source transform | After a lexical `eco.` gate, uses Oxc to wrap native factory options with `bindComponentIdentity()` and prepends the owning integration pragma |
|
|
42
|
-
| Runtime | `eco.component()` / `eco.embed()` + foreign-child runtime | Hand off cross-integration children during SSR |
|
|
43
|
-
|
|
44
|
-
See [`../build/README.md`](../build/README.md) for the JSX ownership helper split.
|
|
45
|
-
|
|
46
|
-
## Document shell composition
|
|
47
|
-
|
|
48
|
-
`composeDocumentShell` in core is the single string-shell primitive for wrapping a primary component with optional layout tiers and an Html template. Integrations may supply an optional `composeChildren` hook to replace sequential string wrapping with a unified tree (for example React element children) while still delegating foreign subtrees through `renderComponentWithForeignChildren`.
|
|
49
|
-
|
|
50
|
-
`IntegrationRenderer.render()` owns the common route shell and page-props contract. An Integration that only needs optional rendering behavior can use `createIntegrationRenderer()` with hooks for component rendering, queued children, foreign-child prop normalization, page-module preparation and normalization, Page Browser Graph contributions, shell composition and props, document contributions and attributes, island assets, pre-render setup, route render scoping, document finalization, or final HTML transforms. A hook factory receives the app config, asset service, `resolveDependencies()`, `resolveComponentDependencies()`, `resolveDependencyPath()`, and `applyPendingLazyTriggers()` once per renderer instance, so it can capture app-owned state and collect assets with core's dependency rules without a renderer subclass. Supplying `buildIslandClientAssets()` marks that Integration as a contributor to grouped app browser builds. Core resolves queued children and finalizes island attributes around a `renderComponent()` hook; the hook returns the integration's component output and own assets.
|
|
51
|
-
|
|
52
|
-
## Main Files
|
|
53
|
-
|
|
54
|
-
### `route-renderer.ts`
|
|
55
|
-
|
|
56
|
-
- `RouteRendererFactory` takes the assembled app runtime and chooses the owning Integration's shared renderer from route files; renderers and page loaders read `origin` and `hmr` from the app runtime
|
|
57
|
-
- `RouteRenderer` delegates execution to the selected renderer
|
|
58
|
-
|
|
59
|
-
### `explicit-view-render-preparation.ts`
|
|
60
|
-
|
|
61
|
-
`resolveExplicitViewRenderer` resolves the owning Integration's shared renderer for one `eco.page()` view without reading `staticProps`. Static export planning uses that so a dynamic route is not invoked before a slug exists. `prepareExplicitStaticRender` then reads `staticProps` with the route's params. A full explicit view calls `renderExplicitView` (a response) or `executeExplicitView` (the route result with its metadata), which run `execute` with the view as the page module and `skipStaticProps`, so it receives the same layouts, metadata, and page client plan as a filesystem Page but never re-runs `staticProps`. The props, route params, query and locals of the call are visible to the view and to its `metadata`. Static export renders through `executeExplicitView` and reuses the returned metadata for sitemap eligibility. Each `execute` opens a render session for that page's assets and foreign-renderer cache, so static export can render several pages of one Integration at the same time. Route rendering, explicit views, and foreign-child handoffs reuse that Integration's renderer. Render contexts use `node:async_hooks` AsyncLocalStorage to isolate nested and concurrent renders; a runtime without it fails before rendering. A partial render stays on the component path and opens its own render session.
|
|
62
|
-
|
|
63
|
-
### `error-pages/`
|
|
64
|
-
|
|
65
|
-
Owns semantic HTTP error-page source selection, rendering, built-in fallback documents, and static-export artifacts. Request adapters classify route failures and coordinate the final HTTP response.
|
|
66
|
-
|
|
67
|
-
### `orchestration/`
|
|
68
|
-
|
|
69
|
-
Renderer entrypoints:
|
|
70
|
-
|
|
71
|
-
- `integration-renderer.ts`: shared route pipeline, explicit view rendering, foreign-child delegation, and optional Integration hooks
|
|
72
|
-
- `string-markup-renderer.ts`: typed convenience base for string-markup integrations; common rendering behavior lives in `IntegrationRenderer`
|
|
73
|
-
|
|
74
|
-
Domain folders:
|
|
75
|
-
|
|
76
|
-
- `ownership-graph/`: the prepared route component graph, its page client plan, and ownership validation
|
|
77
|
-
- `foreign-child/`: foreign-subtree execution, opaque-child checks, deferred template serialization
|
|
78
|
-
- `document-shell/`: shared page/layout/html shell composition, layout prop resolution, and attribute stamping helpers
|
|
79
|
-
- `route-pipeline/`: route preparation, final HTML capture, marker-artifact enforcement
|
|
80
|
-
- `page-browser-graph/`: browser asset graph build, session cache, and injector assets
|
|
81
|
-
- `custom-element-scripts/`: shared `ssr: true` script collection and server preload for custom-element registration, with deduplication and invalidation state owned by each `AppRuntime`
|
|
82
|
-
|
|
83
|
-
**Page Browser Graph session behavior:**
|
|
84
|
-
|
|
85
|
-
- In development, each Page Browser Graph is built on first request, cached in `page-browser-graph-session` with generation-safe commits, and invalidated when a tracked dependency changes. The per-route fast path is disabled while HMR is enabled so prop-dependent `dependencies(props)` cannot reuse the wrong graph. `HmrManager` calls `prepareHmrFileChange()` for each dispatched file, and HMR managers defer client broadcasts when no browser subscribers are connected.
|
|
86
|
-
- Dev SSR prewarm schedules processor-declared pathnames for background rendering. Static pages cache in watch mode when their Cache Strategy allows it; dynamic pages are never retained. Each cached page registers its route-module closure, Page Browser Graph, processed assets, and render-shell source paths with the shared build-input index. An edit evicts only the HTML entries that registered the changed file, including the HTML template's imports; an `additionalWatchPaths` edit clears the HTML cache because its consumers are unknown.
|
|
87
|
-
- **Measuring dev page load:** set `ECOPAGES_REQUEST_PIPELINE_METRICS=1` and run `pnpm run test:bench:docs`. Compare cold vs warm navigations and phase totals from the benchmark output.
|
|
88
|
-
- Production static export gathers every renderer's grouped plan, builds the app-wide browser client once, and writes its route assets, HTML module-script URLs, source fingerprints, and emitted browser output paths to `.server/browser-client-manifest.json`. It also adds a parameter-free plan for every non-exact route template without invoking route data hooks for missing params. Production `ecopages start` reloads the manifest, validates its sources and output files, and prepares its listed route graphs before accepting SSR requests. A request for a new slug still renders through the server and follows the route's cache strategy, including `revalidate`; it reuses the template's emitted browser assets when the grouped dependencies and page-client entries match, and keeps the request-time browser build path if the graph differs. A generation failure clears staged production session records and the manifest so retries cannot reuse partial graph output.
|
|
89
|
-
- Core activates Integrations after Processor setup and before the first renderer is created. In watch mode it registers each Integration's HMR behavior first; graph prebuild and render paths join the same coalesced `ensureIntegrationRuntimeReady()` activation. Processors initialize their small virtual modules during `setupAppRuntimePlugins()`; content collection server artifacts are built lazily when a server build first resolves the collection.
|
|
90
|
-
|
|
91
|
-
### `page-loading/`
|
|
92
|
-
|
|
93
|
-
- `page-module-loader.ts`: imports page modules and normalizes page exports
|
|
94
|
-
- `dependency-resolver.ts`: resolves component dependencies and browser-facing assets
|
|
95
|
-
|
|
96
|
-
## Render Flow
|
|
97
|
-
|
|
98
|
-
The route-render contract is:
|
|
99
|
-
|
|
100
|
-
1. `RouteRendererFactory` selects the owning integration renderer.
|
|
101
|
-
2. `IntegrationRenderer.execute()` activates the Integration runtime, gives an optional remote-render hook first refusal, then opens a per-render session and delegates preparation and finalization to `RouteRenderOrchestrator`.
|
|
102
|
-
3. `RouteRenderOrchestrator.prepareRenderOptions()` loads the page module and final props, prepares and validates the shell graph, resolves page-dependency roots, then adds and validates those roots in the prepared graph. Route assets, the page client plan, and development cache watch paths reuse its recorded nodes; production grouped prebuild retains that same graph through route preparation. The page browser graph cache identity includes route params and query; contribution collection receives those same final props. When rendering, route params and query take precedence over similarly named extra props.
|
|
103
|
-
4. The integration renderer performs page, layout, and document-shell rendering. When it encounters a foreign child, it delegates that child back to the owning renderer.
|
|
104
|
-
5. If a renderer needs queued handoff, it emits internal foreign-subtree tokens and resolves them before returning final HTML.
|
|
105
|
-
6. `RouteRenderOrchestrator.executePrepared()` captures the final body, rejects unresolved `<eco-marker>` artifacts, stamps document attributes when needed, and runs the HTML transformer.
|
|
106
|
-
|
|
107
|
-
Important:
|
|
108
|
-
|
|
109
|
-
- route-level fallback resolution is gone; unresolved artifacts are now a hard failure
|
|
110
|
-
- ownership is declared from canonical component identity, not inferred from final HTML
|
|
111
|
-
- declared page dependencies are resolved from final render inputs and carried as dependency roots to the owning integration; those roots participate in asset, integration, ownership, and renderer-specific lifecycle collection
|
|
112
|
-
- same-integration children stay renderer-local and do not need to pass through a universal transport
|
|
113
|
-
|
|
114
|
-
## Declared Foreign Child Contract
|
|
115
|
-
|
|
116
|
-
Static mixed-integration component configs must declare every possible foreign child in `config.dependencies.components`. Page dependency resolvers can additionally provide request-time component roots when a route loads a component dynamically.
|
|
117
|
-
|
|
118
|
-
`OwnershipValidationService` surfaces missing metadata or unknown integrations during `prepareRenderOptions()` and throws before render execution starts.
|
|
119
|
-
|
|
120
|
-
At runtime, renderers still discover actual foreign children through the active component render context.
|
|
121
|
-
|
|
122
|
-
The render context lives in `AsyncLocalStorage`, so overlapping renders each see their own. Component renders always execute under a render context that names the rendering integration (`executeComponentRender` installs one when none is active). This lets ownership guards such as the content-processor's `getComponent()` detect a foreign render lane even when no foreign-child runtime is installed.
|
|
123
|
-
|
|
124
|
-
## Foreign Subtree Contract
|
|
125
|
-
|
|
126
|
-
`renderComponentWithForeignChildren()` is the renderer entrypoint for mixed-integration trees. It is responsible for:
|
|
127
|
-
|
|
128
|
-
- reusing the execution-scoped owning-renderer cache
|
|
129
|
-
- deciding whether the current component can stay local
|
|
130
|
-
- creating a foreign-child runtime when nested foreign ownership must be resolved
|
|
131
|
-
- normalizing unresolved artifact HTML before the render leaves the renderer
|
|
132
|
-
|
|
133
|
-
The owning renderer returns a `ComponentRenderResult` directly. Queue resolution merges its HTML and assets before replacing the token; there is no intermediate payload or root-tag contract.
|
|
134
|
-
|
|
135
|
-
## Queue Model
|
|
136
|
-
|
|
137
|
-
Not every integration needs queue-based handoff.
|
|
138
|
-
|
|
139
|
-
- If a renderer can resolve a foreign child inline, it returns resolved output immediately.
|
|
140
|
-
- If it cannot, it may emit internal foreign-subtree tokens and resolve them before returning final HTML.
|
|
141
|
-
- Queue mechanics are module functions in `foreign-subtree-execution.service.ts`; they are renderer-owned transport inside one render pass, not a general route-level fallback mechanism.
|
|
142
|
-
|
|
143
|
-
## React Island Notes
|
|
144
|
-
|
|
145
|
-
- React islands are emitted without synthetic wrapper elements.
|
|
146
|
-
- The React integration attaches island host attributes (`data-eco-island`, `data-eco-component-id`, `data-eco-component-key`, `data-eco-props`) to the SSR root when a single root exists.
|
|
147
|
-
- Other integrations call `finalizeIslandComponentRender()` from core when a component instance ships its own client scripts, excluding those of Foreign Children. See `packages/core/src/islands/README.md`.
|
|
148
|
-
- The island bootstrap mounts with `createRoot()` into that SSR root.
|
|
149
|
-
- Hydration bootstraps listen for `eco:after-swap` so islands hydrate after client-side navigation.
|
|
150
|
-
|
|
151
|
-
## Current Limits
|
|
152
|
-
|
|
153
|
-
- Different integrations still own different foreign-child runtime strategies, which is intentional where child transport or hydration behavior differs.
|
|
154
|
-
- `integration-renderer.ts` remains the largest integration hook surface even after document-shell extraction.
|
|
155
|
-
|
|
156
|
-
## Discovered Dependencies and loading policy
|
|
157
|
-
|
|
158
|
-
Dependency collection reads declared `config.dependencies` plus identity-keyed inferred stylesheets, including deferred direct-import Component references. Traversal visits each config once; multiple Components in one file remain distinct. It collects explicit styles before inferred styles across the graph, suppressing inferred duplicates by resolved path. Page dependency results may include multiple file-owned contributions so relative assets keep the file that declared them. Source watch paths include discovered Components, their stylesheet files, and named barrel hops recorded during discovery. Preparing a route records those paths on the app-owned build-input index so the Project Watcher subscribes even when HTML is not stored. Rendered HTML cache dependencies include identity files and watch hops from the whole declared Component graph (not only Html, Layout, and Page roots), so editing a nested Component or retargeting a named barrel misses cached HTML. The route's Html, Layout, and Page roots still contribute their own identity files and local assets, which is how an HTML Page or `html.html` shell invalidates cached HTML.
|
|
159
|
-
|
|
160
|
-
Lit preloads scripts marked `ssr: true` before server rendering, while the existing lazy-trigger manifest controls browser loading. The route pipeline does not emit a second eager script for these entries. Integration renderers refresh their resolved global assets after runtime activation so late setup cannot omit hydration support.
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# Error pages
|
|
2
|
-
|
|
3
|
-
**Layer:** Rendering.
|
|
4
|
-
|
|
5
|
-
This directory owns semantic error-page behavior for HTTP statuses 400, 401, 403, 404, 409, and 500, shared by request-time rendering and static export. Other 5xx statuses use the server-error page; other 4xx statuses use a built-in document.
|
|
6
|
-
|
|
7
|
-
- `error-page-renderer.ts` applies filesystem → registered-loader → built-in precedence. Registered views reuse `prepareExplicitStaticRender`. Callers that need a guaranteed built-in document after a custom-page failure use `renderBuiltIn()`.
|
|
8
|
-
- `default-error-pages.ts` renders self-contained fallback documents with development-only diagnostics.
|
|
9
|
-
- `semantic-error-page-exporter.ts` writes one artifact for each semantic status pathname during static export, unless another generated route already owns that pathname.
|
|
10
|
-
|
|
11
|
-
The renderer owns custom-source precedence and fallback documents. Runtime adapters classify route failures, coordinate fallback after a rendering failure, and wrap the final body in an HTTP response.
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# Custom element SSR script preload
|
|
2
|
-
|
|
3
|
-
**Layer:** Rendering.
|
|
4
|
-
|
|
5
|
-
Shared orchestration for `dependencies.scripts` entries marked `ssr: true`.
|
|
6
|
-
|
|
7
|
-
Lit and Ecopages JSX construct a {@link CustomElementScriptPreloader} with a stable `cacheScope` inside the app's `AppRuntime`. The scope deduplicates imports across concurrent renders for that app, and dev invalidation clears only that app's preload state. Two apps may use the same integration scope name without sharing preload history.
|
|
8
|
-
|
|
9
|
-
Every preloader takes one `importServerModule(scriptPath, registryKey)`, and every runtime, Bun included, evaluates scripts through it. A script is never imported from source, because a native import skips the server loaders for its CSS, MDX and asset imports.
|
|
10
|
-
|
|
11
|
-
- {@link createCustomElementSsrPipelineImporter} (Lit's render session) builds the script through the asset pipeline and imports a copy of the output per custom-element registry, written beside the pipeline file and removed once evaluated. Bun ignores a query-only URL change for every module, so a query cannot register the element on the next registry; the copy keeps the pipeline file's package scope and relative resolution. A script the pipeline cannot build, or whose output is its own source path, is reported as a preload failure.
|
|
12
|
-
- {@link createCustomElementServerModuleImporter} (the Lit static-render worker, which has no session) compiles the script through `requireAppRuntime(appConfig).moduleLoader` into a separate outdir per registry.
|
|
13
|
-
- {@link createSharedServerModuleImporter} (Ecopages JSX) compiles the script through the page server-module loader with external packages, because the dev asset pipeline still points at `.tsx` source and a browser bundle would register a second Radiant graph.
|
|
14
|
-
|
|
15
|
-
Lit only preloads lazy `ssr: true` script entries (`requireLazyScriptEntry`) so eager registrations are not evaluated in an isolated graph that would break `@lit-labs/ssr`. Ecopages JSX sets `collectForIntegration` so foreign integration scripts in shared dependency trees are not preloaded here; Lit and other hosts keep owning their registrations.
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { IntegrationRenderer, type HtmlDocumentContribution } from './integration-renderer.js';
|
|
2
|
-
import { getComponentRenderContext, type ForeignChildRuntime } from '../../eco/component-render-context.js';
|
|
3
|
-
import type { EcoPagesAppConfig } from '../../config/internal-types.js';
|
|
4
|
-
import type { AssetProcessingService, ProcessedAsset } from '../../assets/asset-processing-service/index.js';
|
|
5
|
-
import type { ComponentRenderInput, ComponentRenderResult, EcoPagesElement, IntegrationRendererRenderOptions, EcoPageFile, RouteRendererBody, EcoComponent, HtmlTemplateProps } from '../../types/contracts.js';
|
|
6
|
-
export declare function createUnresolvedMarkerArtifact(nodeId: string, componentRef: string, propsRef: string): string;
|
|
7
|
-
export declare function createMockIntegrationPlugin(plugin: {
|
|
8
|
-
name: string;
|
|
9
|
-
} & Record<string, unknown>): EcoPagesAppConfig['integrations'][number];
|
|
10
|
-
export declare function createMockAppConfig(overrides?: Partial<EcoPagesAppConfig>): EcoPagesAppConfig;
|
|
11
|
-
export declare const testAppConfig: EcoPagesAppConfig;
|
|
12
|
-
export declare const testAssetService: AssetProcessingService;
|
|
13
|
-
/**
|
|
14
|
-
* Concrete implementation with ed file loading for testing purposes.
|
|
15
|
-
*/
|
|
16
|
-
export declare class TestIntegrationRenderer extends IntegrationRenderer<EcoPagesElement> {
|
|
17
|
-
name: string;
|
|
18
|
-
ForeignChildRuntimeCreationCount: number;
|
|
19
|
-
PageModule: EcoPageFile | null;
|
|
20
|
-
HtmlTemplate: EcoComponent<HtmlTemplateProps> | null;
|
|
21
|
-
UseDocumentShellRender: boolean;
|
|
22
|
-
RenderedBody: RouteRendererBody;
|
|
23
|
-
RenderBodyFactory: ((context: ReturnType<typeof getComponentRenderContext>) => RouteRendererBody | Promise<RouteRendererBody>) | null;
|
|
24
|
-
MockComponentRenderResult: ComponentRenderResult | null;
|
|
25
|
-
ImportedFiles: string[];
|
|
26
|
-
HtmlContributions: HtmlDocumentContribution[];
|
|
27
|
-
render(options: IntegrationRendererRenderOptions<EcoPagesElement>): Promise<RouteRendererBody>;
|
|
28
|
-
renderComponent(_input: ComponentRenderInput): Promise<ComponentRenderResult>;
|
|
29
|
-
protected importPageFile(_file: string): Promise<EcoPageFile>;
|
|
30
|
-
protected getHtmlTemplate(): Promise<EcoComponent<HtmlTemplateProps>>;
|
|
31
|
-
protected resolveDependencies(_components: (EcoComponent | Partial<EcoComponent>)[]): Promise<ProcessedAsset[]>;
|
|
32
|
-
protected createForeignChildRuntime(options: {
|
|
33
|
-
renderInput: ComponentRenderInput;
|
|
34
|
-
rendererCache: Map<string, IntegrationRenderer<any>>;
|
|
35
|
-
}): ForeignChildRuntime;
|
|
36
|
-
protected getHtmlDocumentContributions(_options?: {
|
|
37
|
-
partial?: boolean;
|
|
38
|
-
}): HtmlDocumentContribution[] | undefined;
|
|
39
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { vi } from 'vitest';
|
|
2
|
-
import { createBrowserRuntimeManifest } from '../../build/browser/browser-runtime-manifest.js';
|
|
3
|
-
import { createAppRuntime } from '../../config/assembly/app-runtime.js';
|
|
4
|
-
import { IntegrationRenderer } from './integration-renderer.js';
|
|
5
|
-
import { getComponentRenderContext } from '../../eco/component-render-context.js';
|
|
6
|
-
export function createUnresolvedMarkerArtifact(nodeId, componentRef, propsRef) {
|
|
7
|
-
return `<eco-marker data-eco-node-id="${nodeId}" data-eco-component-ref="${componentRef}" data-eco-props-ref="${propsRef}"></eco-marker>`;
|
|
8
|
-
}
|
|
9
|
-
export function createMockIntegrationPlugin(plugin) {
|
|
10
|
-
return {
|
|
11
|
-
getRenderer: vi.fn(),
|
|
12
|
-
setup: vi.fn(async () => { }),
|
|
13
|
-
hmr: vi.fn(),
|
|
14
|
-
browserRuntimeManifest: createBrowserRuntimeManifest(),
|
|
15
|
-
...plugin,
|
|
16
|
-
plugins: typeof plugin.plugins === 'function'
|
|
17
|
-
? plugin.plugins
|
|
18
|
-
: () => (Array.isArray(plugin.plugins) ? plugin.plugins : []),
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export function createMockAppConfig(overrides = {}) {
|
|
22
|
-
const config = {
|
|
23
|
-
absolutePaths: {
|
|
24
|
-
pagesDir: '/app/pages',
|
|
25
|
-
htmlTemplatePath: '/app/index.ts',
|
|
26
|
-
},
|
|
27
|
-
loaders: new Map(),
|
|
28
|
-
processors: new Map(),
|
|
29
|
-
integrations: [],
|
|
30
|
-
defaultMetadata: {
|
|
31
|
-
title: 'Default Title',
|
|
32
|
-
description: 'Default Description',
|
|
33
|
-
},
|
|
34
|
-
srcDir: '/app',
|
|
35
|
-
...overrides,
|
|
36
|
-
};
|
|
37
|
-
createAppRuntime(config);
|
|
38
|
-
return config;
|
|
39
|
-
}
|
|
40
|
-
export const testAppConfig = createMockAppConfig();
|
|
41
|
-
export const testAssetService = {
|
|
42
|
-
processDependencies: vi.fn(() => Promise.resolve([])),
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Concrete implementation with ed file loading for testing purposes.
|
|
46
|
-
*/
|
|
47
|
-
export class TestIntegrationRenderer extends IntegrationRenderer {
|
|
48
|
-
name = 'test-renderer';
|
|
49
|
-
ForeignChildRuntimeCreationCount = 0;
|
|
50
|
-
PageModule = null;
|
|
51
|
-
HtmlTemplate = null;
|
|
52
|
-
UseDocumentShellRender = false;
|
|
53
|
-
RenderedBody = '<html><body>Test Page</body></html>';
|
|
54
|
-
RenderBodyFactory = null;
|
|
55
|
-
MockComponentRenderResult = null;
|
|
56
|
-
ImportedFiles = [];
|
|
57
|
-
HtmlContributions = [];
|
|
58
|
-
async render(options) {
|
|
59
|
-
if (this.UseDocumentShellRender) {
|
|
60
|
-
return super.render(options);
|
|
61
|
-
}
|
|
62
|
-
if (this.RenderBodyFactory) {
|
|
63
|
-
return await this.RenderBodyFactory(getComponentRenderContext());
|
|
64
|
-
}
|
|
65
|
-
return this.RenderedBody;
|
|
66
|
-
}
|
|
67
|
-
async renderComponent(_input) {
|
|
68
|
-
if (this.MockComponentRenderResult) {
|
|
69
|
-
return this.MockComponentRenderResult;
|
|
70
|
-
}
|
|
71
|
-
return super.renderComponent(_input);
|
|
72
|
-
}
|
|
73
|
-
async importPageFile(_file) {
|
|
74
|
-
this.ImportedFiles.push(_file);
|
|
75
|
-
if (!this.PageModule)
|
|
76
|
-
throw new Error('Mock page module not set');
|
|
77
|
-
return this.PageModule;
|
|
78
|
-
}
|
|
79
|
-
async getHtmlTemplate() {
|
|
80
|
-
if (!this.HtmlTemplate)
|
|
81
|
-
throw new Error('Mock HTML template not set');
|
|
82
|
-
return this.HtmlTemplate;
|
|
83
|
-
}
|
|
84
|
-
async resolveDependencies(_components) {
|
|
85
|
-
return [];
|
|
86
|
-
}
|
|
87
|
-
createForeignChildRuntime(options) {
|
|
88
|
-
this.ForeignChildRuntimeCreationCount += 1;
|
|
89
|
-
return super.createForeignChildRuntime(options);
|
|
90
|
-
}
|
|
91
|
-
getHtmlDocumentContributions(_options) {
|
|
92
|
-
return this.HtmlContributions;
|
|
93
|
-
}
|
|
94
|
-
}
|
package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.test-fixtures.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { ProcessedAsset } from '../../../assets/asset-processing-service/index.js';
|
|
2
|
-
import type { EcoComponent, EcoPageComponent, HtmlTemplateProps, PageBrowserGraphContribution, PageBrowserGraphContributionContext, PageMetadataProps, RouteRendererBody, RouteRendererOptions } from '../../../types/contracts.js';
|
|
3
|
-
import type { ResolvedPageDependencies } from '../../page-loading/resolved-page-dependencies.js';
|
|
4
|
-
import type { PreparedComponentGraphNode } from '../ownership-graph/component-graph.js';
|
|
5
|
-
import type { RouteHtmlFinalization, RouteRenderHost } from './route-render-orchestrator.js';
|
|
6
|
-
export interface FlowRendererInput {
|
|
7
|
-
name?: string;
|
|
8
|
-
Page?: EcoPageComponent<any> | EcoComponent;
|
|
9
|
-
integrationSpecificProps?: Record<string, unknown>;
|
|
10
|
-
HtmlTemplate?: EcoComponent<HtmlTemplateProps>;
|
|
11
|
-
pageData?: {
|
|
12
|
-
props: Record<string, unknown>;
|
|
13
|
-
metadata: PageMetadataProps;
|
|
14
|
-
};
|
|
15
|
-
resolveDependencies?: (components: (EcoComponent | Partial<EcoComponent>)[]) => Promise<ProcessedAsset[]>;
|
|
16
|
-
collectPageBrowserGraphContribution?: (context: PageBrowserGraphContributionContext) => Promise<PageBrowserGraphContribution | undefined>;
|
|
17
|
-
resolvePageDependencies?: (context: PageBrowserGraphContributionContext) => Promise<ResolvedPageDependencies | undefined>;
|
|
18
|
-
resolvePageDependencyContribution?: (input: {
|
|
19
|
-
nodes: ReadonlyArray<PreparedComponentGraphNode>;
|
|
20
|
-
ownerFile: string;
|
|
21
|
-
}) => Promise<PageBrowserGraphContribution | undefined>;
|
|
22
|
-
renderRouteBody?: () => Promise<RouteRendererBody>;
|
|
23
|
-
getRouteHtmlFinalization?: () => RouteHtmlFinalization;
|
|
24
|
-
transformRouteResponse?: (response: Response) => Promise<RouteRendererBody>;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Builds a {@link RouteRenderHost} whose every input has a working default, so a
|
|
28
|
-
* test names only the inputs it asserts on.
|
|
29
|
-
*
|
|
30
|
-
* @remarks
|
|
31
|
-
* Defaults describe an empty page: a one-line `Page`, an empty `<html>` template, no
|
|
32
|
-
* dependencies, an empty browser-graph contribution and a plain-text response transform.
|
|
33
|
-
*/
|
|
34
|
-
export declare function createFlowRenderer<C = unknown>(input?: FlowRendererInput): RouteRenderHost<C>;
|
|
35
|
-
export declare function createRouteOptions(file: string, overrides?: Partial<RouteRendererOptions>): RouteRendererOptions;
|
package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.test-fixtures.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { resolvePageLayoutComponents } from '../document-shell/layout-shell-props.service.js';
|
|
2
|
-
import { createPageDependencyInstanceKey } from '../page-browser-graph/route-instance-key.js';
|
|
3
|
-
/**
|
|
4
|
-
* Builds a {@link RouteRenderHost} whose every input has a working default, so a
|
|
5
|
-
* test names only the inputs it asserts on.
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* Defaults describe an empty page: a one-line `Page`, an empty `<html>` template, no
|
|
9
|
-
* dependencies, an empty browser-graph contribution and a plain-text response transform.
|
|
10
|
-
*/
|
|
11
|
-
export function createFlowRenderer(input = {}) {
|
|
12
|
-
const Page = input.Page ?? (() => '<main>Page</main>');
|
|
13
|
-
const HtmlTemplate = input.HtmlTemplate ?? (() => '<html></html>');
|
|
14
|
-
const integrationSpecificProps = input.integrationSpecificProps ?? {};
|
|
15
|
-
const pageData = input.pageData ?? {
|
|
16
|
-
props: {},
|
|
17
|
-
metadata: { title: 'Page', description: 'Page description' },
|
|
18
|
-
};
|
|
19
|
-
const pageModule = { default: Page, ...integrationSpecificProps };
|
|
20
|
-
return {
|
|
21
|
-
name: input.name ?? 'string',
|
|
22
|
-
resolveRouteRenderInputs: async () => {
|
|
23
|
-
const Layouts = resolvePageLayoutComponents(Page.config?.layouts);
|
|
24
|
-
return {
|
|
25
|
-
Page,
|
|
26
|
-
pageModule,
|
|
27
|
-
HtmlTemplate,
|
|
28
|
-
Layouts,
|
|
29
|
-
Layout: Layouts[Layouts.length - 1],
|
|
30
|
-
layoutEntries: Page.config?.layoutEntries,
|
|
31
|
-
props: pageData.props,
|
|
32
|
-
metadata: pageData.metadata,
|
|
33
|
-
integrationSpecificProps,
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
resolveRouteDependencies: async ({ components }) => ({
|
|
37
|
-
resolvedDependencies: (await input.resolveDependencies?.(components)) ?? [],
|
|
38
|
-
}),
|
|
39
|
-
collectPageBrowserGraphContribution: async (context) => input.collectPageBrowserGraphContribution
|
|
40
|
-
? await input.collectPageBrowserGraphContribution(context)
|
|
41
|
-
: { assets: [] },
|
|
42
|
-
resolvePageDependenciesForRoute: input.resolvePageDependencies ?? (async () => undefined),
|
|
43
|
-
getPrebuiltRouteComponentGraphs: () => undefined,
|
|
44
|
-
getGroupedBuildPlanForRoute: () => undefined,
|
|
45
|
-
resolvePageDependencyContribution: input.resolvePageDependencyContribution ?? (async () => undefined),
|
|
46
|
-
buildPageClientBrowserAssets: async () => ({
|
|
47
|
-
processedAssets: [],
|
|
48
|
-
islandRenderAssetsByFile: new Map(),
|
|
49
|
-
lazyTriggers: [],
|
|
50
|
-
}),
|
|
51
|
-
buildPageBrowserGraphContributionContext: async (routeFile, routeOptions) => ({
|
|
52
|
-
file: routeFile,
|
|
53
|
-
pageModule,
|
|
54
|
-
props: pageData.props,
|
|
55
|
-
params: routeOptions?.params,
|
|
56
|
-
query: routeOptions?.query,
|
|
57
|
-
dependencyInstanceKey: createPageDependencyInstanceKey({
|
|
58
|
-
params: routeOptions?.params,
|
|
59
|
-
query: routeOptions?.query,
|
|
60
|
-
}),
|
|
61
|
-
}),
|
|
62
|
-
renderRouteBody: input.renderRouteBody ?? (async () => ''),
|
|
63
|
-
getRouteHtmlFinalization: input.getRouteHtmlFinalization ?? (() => ({})),
|
|
64
|
-
transformRouteResponse: input.transformRouteResponse ?? (async (response) => await response.text()),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
export function createRouteOptions(file, overrides = {}) {
|
|
68
|
-
return { file, params: {}, query: {}, ...overrides };
|
|
69
|
-
}
|