@ecopages/core 0.2.0-rc.11 → 0.2.0-rc.13
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/package.json +3 -11
- package/src/build/cache/output-imports.d.ts +19 -11
- package/src/build/cache/output-imports.js +22 -15
- package/src/build/cache/pages-unified-graph-build.js +9 -3
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +25 -24
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +18 -20
- package/src/route-renderer/orchestration/integration-renderer.d.ts +24 -1
- package/src/route-renderer/orchestration/integration-renderer.js +43 -22
- package/src/services/html/html-transformer.service.d.ts +8 -8
- package/src/services/html/html-transformer.service.js +10 -10
- package/src/services/module-loading/route-module-build-cache.store.js +5 -3
- package/src/services/module-loading/route-module-build-manifest.d.ts +9 -3
- package/src/services/module-loading/route-module-build-manifest.js +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecopages/core",
|
|
3
|
-
"version": "0.2.0-rc.
|
|
3
|
+
"version": "0.2.0-rc.13",
|
|
4
4
|
"description": "Core package for Ecopages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecopages",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@clack/prompts": "^1.7.0",
|
|
24
|
-
"@ecopages/file-system": "0.2.0-rc.
|
|
24
|
+
"@ecopages/file-system": "0.2.0-rc.13",
|
|
25
25
|
"@ecopages/logger": "^0.2.3",
|
|
26
26
|
"@ecopages/scripts-injector": "^0.1.5",
|
|
27
27
|
"@oxc-project/runtime": "0.141.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@standard-schema/utils": "^0.3.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@ecopages/dev-toolbar": "0.2.0-rc.
|
|
37
|
+
"@ecopages/dev-toolbar": "0.2.0-rc.13"
|
|
38
38
|
},
|
|
39
39
|
"peerDependenciesMeta": {
|
|
40
40
|
"@ecopages/dev-toolbar": {
|
|
@@ -102,10 +102,6 @@
|
|
|
102
102
|
"types": "./src/route-renderer/page-loading/file-scoped-dependency-components.d.ts",
|
|
103
103
|
"default": "./src/route-renderer/page-loading/file-scoped-dependency-components.js"
|
|
104
104
|
},
|
|
105
|
-
"./route-renderer/orchestration/foreign-child/owning-renderer-resolution": {
|
|
106
|
-
"types": "./src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.d.ts",
|
|
107
|
-
"default": "./src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.js"
|
|
108
|
-
},
|
|
109
105
|
"./router/navigation-coordinator": {
|
|
110
106
|
"types": "./src/router/client/navigation-coordinator.d.ts",
|
|
111
107
|
"default": "./src/router/client/navigation-coordinator.js"
|
|
@@ -345,10 +341,6 @@
|
|
|
345
341
|
"types": "./src/route-renderer/page-loading/file-scoped-dependency-components.d.ts",
|
|
346
342
|
"default": "./src/route-renderer/page-loading/file-scoped-dependency-components.js"
|
|
347
343
|
},
|
|
348
|
-
"./route-renderer/orchestration/foreign-child/owning-renderer-resolution.ts": {
|
|
349
|
-
"types": "./src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.d.ts",
|
|
350
|
-
"default": "./src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.js"
|
|
351
|
-
},
|
|
352
344
|
"./router/navigation-coordinator.ts": {
|
|
353
345
|
"types": "./src/router/client/navigation-coordinator.d.ts",
|
|
354
346
|
"default": "./src/router/client/navigation-coordinator.js"
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
* `file:` specifiers in static imports, re-exports and literal dynamic imports.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
*
|
|
7
|
-
* the shared chunks and generated modules
|
|
8
|
-
* `.server-collections`) still exist. Uses `parseSync`
|
|
9
|
-
* shared parse cache, so large compiled bundles are not
|
|
6
|
+
* {@link collectReachableLocalImports} follows these edges so persisted build
|
|
7
|
+
* caches can check that the shared chunks and generated modules a cached module
|
|
8
|
+
* loads (for example `.server-collections`) still exist. Uses `parseSync`
|
|
9
|
+
* directly rather than the shared parse cache, so large compiled bundles are not
|
|
10
|
+
* retained in memory.
|
|
10
11
|
*/
|
|
11
12
|
export declare function collectLocalImports(code: string, modulePath: string): string[];
|
|
12
13
|
export type LocalImportFileAccess = {
|
|
@@ -17,11 +18,18 @@ export type LocalImportFileAccess = {
|
|
|
17
18
|
* Lists every local file reachable from `modulePath` through local imports.
|
|
18
19
|
*
|
|
19
20
|
* @remarks
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* already check that the compiled output exists.
|
|
21
|
+
* {@link collectLocalImports} alone misses shared chunks that a page output only
|
|
22
|
+
* reaches through another chunk. Persisted caches record this full set and are
|
|
23
|
+
* reused only while every file in it exists. `modulePath` itself is omitted,
|
|
24
|
+
* because callers already check that the compiled output exists.
|
|
25
|
+
*
|
|
26
|
+
* A missing file is listed but not followed, so a cache recorded against it
|
|
27
|
+
* never validates.
|
|
28
|
+
*
|
|
29
|
+
* Pass one `directImportsCache` to every walk of a single build so shared chunks
|
|
30
|
+
* are read and parsed once instead of once per output.
|
|
24
31
|
*/
|
|
25
|
-
export declare function collectReachableLocalImports(modulePath: string,
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
export declare function collectReachableLocalImports(modulePath: string, options?: {
|
|
33
|
+
fileAccess?: LocalImportFileAccess;
|
|
34
|
+
directImportsCache?: Map<string, string[]>;
|
|
35
|
+
}): string[];
|
|
@@ -7,10 +7,11 @@ import { parseSync } from 'oxc-parser';
|
|
|
7
7
|
* `file:` specifiers in static imports, re-exports and literal dynamic imports.
|
|
8
8
|
*
|
|
9
9
|
* @remarks
|
|
10
|
-
*
|
|
11
|
-
* the shared chunks and generated modules
|
|
12
|
-
* `.server-collections`) still exist. Uses `parseSync`
|
|
13
|
-
* shared parse cache, so large compiled bundles are not
|
|
10
|
+
* {@link collectReachableLocalImports} follows these edges so persisted build
|
|
11
|
+
* caches can check that the shared chunks and generated modules a cached module
|
|
12
|
+
* loads (for example `.server-collections`) still exist. Uses `parseSync`
|
|
13
|
+
* directly rather than the shared parse cache, so large compiled bundles are not
|
|
14
|
+
* retained in memory.
|
|
14
15
|
*/
|
|
15
16
|
export function collectLocalImports(code, modulePath) {
|
|
16
17
|
const { module } = parseSync(modulePath, code, { lang: 'js', sourceType: 'module' });
|
|
@@ -36,12 +37,19 @@ const defaultLocalImportFileAccess = {
|
|
|
36
37
|
* Lists every local file reachable from `modulePath` through local imports.
|
|
37
38
|
*
|
|
38
39
|
* @remarks
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* already check that the compiled output exists.
|
|
40
|
+
* {@link collectLocalImports} alone misses shared chunks that a page output only
|
|
41
|
+
* reaches through another chunk. Persisted caches record this full set and are
|
|
42
|
+
* reused only while every file in it exists. `modulePath` itself is omitted,
|
|
43
|
+
* because callers already check that the compiled output exists.
|
|
44
|
+
*
|
|
45
|
+
* A missing file is listed but not followed, so a cache recorded against it
|
|
46
|
+
* never validates.
|
|
47
|
+
*
|
|
48
|
+
* Pass one `directImportsCache` to every walk of a single build so shared chunks
|
|
49
|
+
* are read and parsed once instead of once per output.
|
|
43
50
|
*/
|
|
44
|
-
export function collectReachableLocalImports(modulePath,
|
|
51
|
+
export function collectReachableLocalImports(modulePath, options = {}) {
|
|
52
|
+
const { fileAccess = defaultLocalImportFileAccess, directImportsCache = new Map() } = options;
|
|
45
53
|
const reachable = new Set();
|
|
46
54
|
const pending = [modulePath];
|
|
47
55
|
const visited = new Set();
|
|
@@ -57,16 +65,15 @@ export function collectReachableLocalImports(modulePath, fileAccess = defaultLoc
|
|
|
57
65
|
if (current !== modulePath && !fileAccess.exists(current)) {
|
|
58
66
|
continue;
|
|
59
67
|
}
|
|
60
|
-
|
|
61
|
-
|
|
68
|
+
let directImports = directImportsCache.get(current);
|
|
69
|
+
if (!directImports) {
|
|
70
|
+
directImports = collectLocalImports(fileAccess.readFile(current), current);
|
|
71
|
+
directImportsCache.set(current, directImports);
|
|
62
72
|
}
|
|
73
|
+
pending.push(...directImports);
|
|
63
74
|
}
|
|
64
75
|
return [...reachable];
|
|
65
76
|
}
|
|
66
|
-
/** Reads a compiled module from disk and lists its local imports. */
|
|
67
|
-
export function readLocalImports(modulePath) {
|
|
68
|
-
return collectLocalImports(fileSystem.readFileSync(modulePath), modulePath);
|
|
69
|
-
}
|
|
70
77
|
function resolveLocalSpecifier(specifier, directory) {
|
|
71
78
|
const bare = specifier.replace(/[?#].*$/, '');
|
|
72
79
|
if (bare.startsWith('file:'))
|
|
@@ -57,9 +57,14 @@ function createPagesUnifiedGraphBuildKey(appConfig, outdir) {
|
|
|
57
57
|
'external-packages',
|
|
58
58
|
].join('::');
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* @remarks
|
|
62
|
+
* Manifests without `outputImports` predate import validation and cannot show
|
|
63
|
+
* that their chunks still exist, so they are treated as absent.
|
|
64
|
+
*/
|
|
60
65
|
function readPagesUnifiedGraphManifest(appConfig) {
|
|
61
66
|
const manifest = readProductionCacheManifest(getPagesUnifiedGraphCachePath(appConfig));
|
|
62
|
-
if (!manifest?.outputs) {
|
|
67
|
+
if (!manifest?.outputs || !Array.isArray(manifest.outputImports)) {
|
|
63
68
|
return undefined;
|
|
64
69
|
}
|
|
65
70
|
return manifest;
|
|
@@ -104,7 +109,7 @@ function isGraphManifestCurrent(manifest, appConfig, outdir) {
|
|
|
104
109
|
return (isProductionCacheManifestCurrent(manifest, getCorePackageVersion()) &&
|
|
105
110
|
matchesProductionCacheFingerprint(manifest, createBuildInputsFingerprint(appConfig)) &&
|
|
106
111
|
matchesProductionCacheBuildKey(manifest, createPagesUnifiedGraphBuildKey(appConfig, outdir)) &&
|
|
107
|
-
manifest.outputImports
|
|
112
|
+
manifest.outputImports.every((filePath) => fileSystem.exists(filePath)));
|
|
108
113
|
}
|
|
109
114
|
function isManifestValidForEntries(manifest, appConfig, outdir, entryPaths) {
|
|
110
115
|
return (isGraphManifestCurrent(manifest, appConfig, outdir) &&
|
|
@@ -175,6 +180,7 @@ export async function ensurePagesUnifiedGraphBuilt(options) {
|
|
|
175
180
|
}
|
|
176
181
|
const outputs = {};
|
|
177
182
|
const outputImports = new Set();
|
|
183
|
+
const directImportsCache = new Map();
|
|
178
184
|
for (const entryPath of eligibleEntryPaths) {
|
|
179
185
|
const fileHash = fileSystem.hash(entryPath);
|
|
180
186
|
const entryKey = entryKeysByPath.get(entryPath);
|
|
@@ -183,7 +189,7 @@ export async function ensurePagesUnifiedGraphBuilt(options) {
|
|
|
183
189
|
throw new Error(`Pages unified graph build produced no output for ${entryPath}`);
|
|
184
190
|
}
|
|
185
191
|
outputs[entryPath] = compiledOutput;
|
|
186
|
-
const compiledOutputImports = collectReachableLocalImports(compiledOutput);
|
|
192
|
+
const compiledOutputImports = collectReachableLocalImports(compiledOutput, { directImportsCache });
|
|
187
193
|
for (const importPath of compiledOutputImports)
|
|
188
194
|
outputImports.add(importPath);
|
|
189
195
|
routeModuleBuildCache.recordBuild({
|
package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts
CHANGED
|
@@ -24,11 +24,22 @@ export type QueuedForeignSubtreeResolutionContext = {
|
|
|
24
24
|
queuedResolutions: QueuedForeignSubtreeResolution[];
|
|
25
25
|
};
|
|
26
26
|
type QueuedForeignSubtreeIntegrationContext = BaseIntegrationContext & Record<string, unknown>;
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Children of a queued foreign subtree after the host renderer has processed them.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Set `html` when the host serialized the children, or `children` to pass them
|
|
32
|
+
* to the owning renderer unserialized. Leave both unset when there are no
|
|
33
|
+
* children. Assets are not returned here: the owning renderer reports the
|
|
34
|
+
* foreign component's assets, and host components' assets come from their
|
|
35
|
+
* declared dependencies.
|
|
36
|
+
*/
|
|
37
|
+
export type QueuedForeignSubtreeChildRenderResult = {
|
|
29
38
|
html?: string;
|
|
30
39
|
children?: unknown;
|
|
31
40
|
};
|
|
41
|
+
/** Renders the children of one queued foreign subtree inside the host renderer. */
|
|
42
|
+
export type RenderQueuedForeignSubtreeChildren<TContext extends QueuedForeignSubtreeResolutionContext> = (children: unknown, runtimeContext: TContext, queuedResolutionsByToken: Map<string, QueuedForeignSubtreeResolution>, resolveToken: (token: string) => Promise<string>) => Promise<QueuedForeignSubtreeChildRenderResult>;
|
|
32
43
|
export interface ForeignSubtreeExecutionOwningRenderer {
|
|
33
44
|
readonly name: string;
|
|
34
45
|
renderComponentWithForeignChildren(input: ComponentRenderInput): Promise<ComponentRenderResult>;
|
|
@@ -56,38 +67,20 @@ export interface ForeignSubtreeQueuedRuntimeOptions<TContext extends QueuedForei
|
|
|
56
67
|
tokenPrefix: string;
|
|
57
68
|
createRuntimeContext?: (integrationContext: BaseIntegrationContext & Record<string, unknown>, rendererCache: Map<string, unknown>) => TContext;
|
|
58
69
|
}
|
|
59
|
-
export interface ForeignSubtreeStringQueuedHtmlOptions {
|
|
60
|
-
currentIntegrationName: string;
|
|
61
|
-
renderInput: ComponentRenderInput;
|
|
62
|
-
html: string;
|
|
63
|
-
runtimeContextKey: string;
|
|
64
|
-
queueLabel: string;
|
|
65
|
-
getOwningRenderer(integrationName: string, rendererCache: Map<string, ForeignSubtreeExecutionOwningRenderer>): Promise<ForeignSubtreeExecutionOwningRenderer>;
|
|
66
|
-
applyAttributesToFirstElement(html: string, attributes: Record<string, string>): string;
|
|
67
|
-
dedupeProcessedAssets(assets: ProcessedAsset[]): ProcessedAsset[];
|
|
68
|
-
}
|
|
69
70
|
export interface ForeignSubtreeQueuedHtmlOptions<TContext extends QueuedForeignSubtreeResolutionContext> {
|
|
70
71
|
currentIntegrationName: string;
|
|
71
72
|
html: string;
|
|
72
73
|
runtimeContext?: TContext;
|
|
73
|
-
|
|
74
|
-
renderQueuedChildren(children: unknown, runtimeContext: TContext, queuedResolutionsByToken: Map<string, QueuedForeignSubtreeResolution>, resolveToken: (token: string) => Promise<string>): Promise<{
|
|
75
|
-
assets: ProcessedAsset[];
|
|
76
|
-
children?: unknown;
|
|
77
|
-
html?: string;
|
|
78
|
-
}>;
|
|
74
|
+
renderQueuedChildren: RenderQueuedForeignSubtreeChildren<TContext>;
|
|
79
75
|
getOwningRenderer(integrationName: string, rendererCache: Map<string, ForeignSubtreeExecutionOwningRenderer>): Promise<ForeignSubtreeExecutionOwningRenderer>;
|
|
80
|
-
applyAttributesToFirstElement(html: string, attributes: Record<string, string>): string;
|
|
81
|
-
dedupeProcessedAssets(assets: ProcessedAsset[]): ProcessedAsset[];
|
|
82
76
|
}
|
|
77
|
+
export type ForeignSubtreeStringQueuedHtmlOptions = Omit<ForeignSubtreeQueuedHtmlOptions<QueuedForeignSubtreeResolutionContext>, 'renderQueuedChildren'>;
|
|
83
78
|
export interface ResolveQueuedForeignSubtreeTokensOptions<TContext extends QueuedForeignSubtreeResolutionContext> {
|
|
84
79
|
html: string;
|
|
85
80
|
runtimeContext?: TContext;
|
|
86
81
|
queueLabel: string;
|
|
87
|
-
renderQueuedChildren:
|
|
82
|
+
renderQueuedChildren: RenderQueuedForeignSubtreeChildren<TContext>;
|
|
88
83
|
resolveForeignSubtree: (input: ComponentRenderInput, rendererCache: Map<string, unknown>) => Promise<ForeignSubtreeRenderPayload | undefined>;
|
|
89
|
-
applyAttributesToFirstElement: (html: string, attributes: Record<string, string>) => string;
|
|
90
|
-
dedupeProcessedAssets: (assets: ProcessedAsset[]) => ProcessedAsset[];
|
|
91
84
|
}
|
|
92
85
|
/**
|
|
93
86
|
* Maps one component render result into the foreign-subtree payload shape used by
|
|
@@ -115,7 +108,15 @@ export declare class ForeignSubtreeExecutionService {
|
|
|
115
108
|
createRuntimeContext?: (integrationContext: QueuedForeignSubtreeIntegrationContext, rendererCache: Map<string, unknown>) => TContext;
|
|
116
109
|
}): ForeignChildRuntime;
|
|
117
110
|
getRuntimeContext<TContext extends QueuedForeignSubtreeResolutionContext>(input: ComponentRenderInput, runtimeContextKey: string): TContext | undefined;
|
|
118
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Resolves queued foreign subtrees for a renderer whose children are markup.
|
|
113
|
+
*
|
|
114
|
+
* @remarks
|
|
115
|
+
* String children and markup nodes are serialized and their nested tokens
|
|
116
|
+
* resolved. Structured children pass to the owning renderer unchanged; opaque
|
|
117
|
+
* objects are rejected.
|
|
118
|
+
*/
|
|
119
|
+
resolveStringQueuedHtml(options: ForeignSubtreeStringQueuedHtmlOptions): Promise<{
|
|
119
120
|
assets: ProcessedAsset[];
|
|
120
121
|
html: string;
|
|
121
122
|
}>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { applyAttributesToFirstElement } from '../../../services/html/html-transformer.service.js';
|
|
1
2
|
import { getComponentRenderContext, runWithComponentRenderContext, } from './component-render-context.js';
|
|
2
3
|
import { assertForeignChildrenNotOpaque, isMarkupNodeLike } from './foreign-child-output.utils.js';
|
|
4
|
+
import { dedupeProcessedAssets } from '../page-browser-graph/processed-asset-dedupe.js';
|
|
3
5
|
/**
|
|
4
6
|
* Maps one component render result into the foreign-subtree payload shape used by
|
|
5
7
|
* queue resolution and integration tests.
|
|
@@ -106,34 +108,35 @@ export class ForeignSubtreeExecutionService {
|
|
|
106
108
|
}
|
|
107
109
|
return runtimeContext;
|
|
108
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Resolves queued foreign subtrees for a renderer whose children are markup.
|
|
113
|
+
*
|
|
114
|
+
* @remarks
|
|
115
|
+
* String children and markup nodes are serialized and their nested tokens
|
|
116
|
+
* resolved. Structured children pass to the owning renderer unchanged; opaque
|
|
117
|
+
* objects are rejected.
|
|
118
|
+
*/
|
|
109
119
|
async resolveStringQueuedHtml(options) {
|
|
110
|
-
const runtimeContext = this.getQueuedRuntimeContext(options.renderInput, options.runtimeContextKey);
|
|
111
120
|
return this.resolveQueuedHtml({
|
|
112
|
-
|
|
113
|
-
html: options.html,
|
|
114
|
-
runtimeContext,
|
|
115
|
-
queueLabel: options.queueLabel,
|
|
121
|
+
...options,
|
|
116
122
|
renderQueuedChildren: async (children, _runtimeContext, queuedResolutionsByToken, resolveToken) => {
|
|
117
123
|
if (children === undefined) {
|
|
118
|
-
return {
|
|
124
|
+
return {};
|
|
119
125
|
}
|
|
120
126
|
if (typeof children !== 'string' && !isMarkupNodeLike(children)) {
|
|
121
|
-
assertForeignChildrenNotOpaque(children, options.
|
|
122
|
-
return {
|
|
127
|
+
assertForeignChildrenNotOpaque(children, options.currentIntegrationName);
|
|
128
|
+
return { children };
|
|
123
129
|
}
|
|
124
130
|
const html = await this.resolveQueuedTokens(typeof children === 'string' ? children : (children.outerHTML ?? ''), queuedResolutionsByToken, resolveToken);
|
|
125
|
-
return {
|
|
131
|
+
return { html };
|
|
126
132
|
},
|
|
127
|
-
getOwningRenderer: options.getOwningRenderer,
|
|
128
|
-
applyAttributesToFirstElement: options.applyAttributesToFirstElement,
|
|
129
|
-
dedupeProcessedAssets: options.dedupeProcessedAssets,
|
|
130
133
|
});
|
|
131
134
|
}
|
|
132
135
|
async resolveQueuedHtml(options) {
|
|
133
136
|
return this.resolveQueuedForeignSubtreeTokens({
|
|
134
137
|
html: options.html,
|
|
135
138
|
runtimeContext: options.runtimeContext,
|
|
136
|
-
queueLabel: options.
|
|
139
|
+
queueLabel: options.currentIntegrationName,
|
|
137
140
|
renderQueuedChildren: options.renderQueuedChildren,
|
|
138
141
|
resolveForeignSubtree: (input, rendererCache) => this.resolveForeignSubtreeInOwningRenderer({
|
|
139
142
|
currentIntegrationName: options.currentIntegrationName,
|
|
@@ -141,8 +144,6 @@ export class ForeignSubtreeExecutionService {
|
|
|
141
144
|
rendererCache: rendererCache,
|
|
142
145
|
getOwningRenderer: options.getOwningRenderer,
|
|
143
146
|
}),
|
|
144
|
-
applyAttributesToFirstElement: options.applyAttributesToFirstElement,
|
|
145
|
-
dedupeProcessedAssets: options.dedupeProcessedAssets,
|
|
146
147
|
});
|
|
147
148
|
}
|
|
148
149
|
async resolveQueuedForeignSubtreeTokens(options) {
|
|
@@ -178,9 +179,6 @@ export class ForeignSubtreeExecutionService {
|
|
|
178
179
|
try {
|
|
179
180
|
const renderedChildren = await options.renderQueuedChildren(resolution.props.children, runtimeContext, queuedResolutionsByToken, resolveToken);
|
|
180
181
|
syncQueuedResolutions();
|
|
181
|
-
if (renderedChildren.assets.length > 0) {
|
|
182
|
-
collectedAssets.push(...renderedChildren.assets);
|
|
183
|
-
}
|
|
184
182
|
const foreignSubtreeRender = await options.resolveForeignSubtree({
|
|
185
183
|
component: resolution.component,
|
|
186
184
|
props: { ...resolution.props },
|
|
@@ -198,7 +196,7 @@ export class ForeignSubtreeExecutionService {
|
|
|
198
196
|
}
|
|
199
197
|
const resolvedHtml = foreignSubtreeRender.attachmentPolicy.kind === 'first-element' &&
|
|
200
198
|
foreignSubtreeRender.rootAttributes
|
|
201
|
-
?
|
|
199
|
+
? applyAttributesToFirstElement(foreignSubtreeRender.html, foreignSubtreeRender.rootAttributes)
|
|
202
200
|
: foreignSubtreeRender.html;
|
|
203
201
|
resolvedHtmlByToken.set(token, resolvedHtml);
|
|
204
202
|
return resolvedHtml;
|
|
@@ -217,7 +215,7 @@ export class ForeignSubtreeExecutionService {
|
|
|
217
215
|
resolvedHtml = resolvedHtml.split(resolution.token).join(await resolveToken(resolution.token));
|
|
218
216
|
}
|
|
219
217
|
return {
|
|
220
|
-
assets:
|
|
218
|
+
assets: dedupeProcessedAssets(collectedAssets),
|
|
221
219
|
html: resolvedHtml,
|
|
222
220
|
};
|
|
223
221
|
}
|
|
@@ -15,7 +15,7 @@ import { RouteRenderOrchestrator, type RouteRenderOrchestratorAdapter, type Rout
|
|
|
15
15
|
import { type ResolvedPageDependencies } from '../page-loading/resolved-page-dependencies.js';
|
|
16
16
|
import { type GroupedGraphBuildPlan } from './page-browser-graph/grouped-graph-build-plan.js';
|
|
17
17
|
import type { ForeignChildRuntime } from './foreign-child/component-render-context.js';
|
|
18
|
-
import { ForeignSubtreeExecutionService } from './foreign-child/foreign-subtree-execution.service.js';
|
|
18
|
+
import { ForeignSubtreeExecutionService, type ForeignSubtreeExecutionOwningRenderer, type QueuedForeignSubtreeResolutionContext, type RenderQueuedForeignSubtreeChildren } from './foreign-child/foreign-subtree-execution.service.js';
|
|
19
19
|
import { type DocumentShellLayoutInput } from './document-shell/document-shell-render.service.js';
|
|
20
20
|
/**
|
|
21
21
|
* Controls how one route module is loaded outside the normal render path.
|
|
@@ -353,6 +353,29 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
353
353
|
* renderer's nested foreign-child handoff.
|
|
354
354
|
*/
|
|
355
355
|
renderComponentWithForeignChildren(input: InternalComponentRenderInput): Promise<ComponentRenderResult>;
|
|
356
|
+
/**
|
|
357
|
+
* Returns the renderer that owns `integrationName`, reusing `rendererCache`
|
|
358
|
+
* for the current render.
|
|
359
|
+
*/
|
|
360
|
+
protected resolveOwningRenderer(integrationName: string, rendererCache: Map<string, ForeignSubtreeExecutionOwningRenderer>): Promise<ForeignSubtreeExecutionOwningRenderer>;
|
|
361
|
+
/**
|
|
362
|
+
* Returns the queued foreign-subtree state this renderer keeps on `input`, or
|
|
363
|
+
* `undefined` when nothing was queued for it.
|
|
364
|
+
*/
|
|
365
|
+
protected getQueuedForeignSubtreeContext<TContext extends QueuedForeignSubtreeResolutionContext = QueuedForeignSubtreeResolutionContext>(input: ComponentRenderInput): TContext | undefined;
|
|
366
|
+
/**
|
|
367
|
+
* Replaces the foreign-subtree tokens queued while rendering `html` with the
|
|
368
|
+
* HTML each owning renderer produces.
|
|
369
|
+
*
|
|
370
|
+
* @remarks
|
|
371
|
+
* `renderQueuedChildren` renders a subtree's children inside this renderer
|
|
372
|
+
* before the owning renderer renders the subtree around them. The returned
|
|
373
|
+
* assets are the owning renderers' assets, deduplicated.
|
|
374
|
+
*/
|
|
375
|
+
protected resolveQueuedForeignSubtrees<TContext extends QueuedForeignSubtreeResolutionContext>(html: string, runtimeContext: TContext | undefined, renderQueuedChildren: RenderQueuedForeignSubtreeChildren<TContext>): Promise<{
|
|
376
|
+
assets: ProcessedAsset[];
|
|
377
|
+
html: string;
|
|
378
|
+
}>;
|
|
356
379
|
protected finalizeIslandComponentRender(input: ComponentRenderInput, result: ComponentRenderResult): ComponentRenderResult;
|
|
357
380
|
private normalizeComponentRenderOutput;
|
|
358
381
|
protected normalizeUnresolvedMarkerArtifactHtml(html: string): string;
|
|
@@ -22,7 +22,7 @@ import { normalizeUnresolvedMarkerArtifactHtml } from './route-pipeline/marker-a
|
|
|
22
22
|
import { isMarkupNodeLike } from './foreign-child/foreign-child-output.utils.js';
|
|
23
23
|
import { getForeignSubtreeResolutionContextKey, getForeignSubtreeTokenPrefix, resolveOwningIntegrationRenderer, } from './foreign-child/owning-renderer-resolution.js';
|
|
24
24
|
import { ensureIntegrationRuntimeReady } from '../../build/app-build-manifest-runtime.js';
|
|
25
|
-
import { ForeignSubtreeExecutionService } from './foreign-child/foreign-subtree-execution.service.js';
|
|
25
|
+
import { ForeignSubtreeExecutionService, } from './foreign-child/foreign-subtree-execution.service.js';
|
|
26
26
|
import { composeDocumentShell, finalizeDocumentShellHtml, renderPageDocumentShell, } from './document-shell/document-shell-render.service.js';
|
|
27
27
|
import { resolveInnermostPageLayout, resolvePageLayoutComponents, } from './document-shell/layout-shell-props.service.js';
|
|
28
28
|
import { finalizeIslandComponentRender } from '../../islands/island-host.js';
|
|
@@ -421,20 +421,9 @@ export class IntegrationRenderer {
|
|
|
421
421
|
const componentRender = await this.renderStringComponentWithSerializedChildren(input, component);
|
|
422
422
|
const queuedForeignSubtreeResolution = await this.foreignSubtreeExecutionService.resolveStringQueuedHtml({
|
|
423
423
|
currentIntegrationName: this.name,
|
|
424
|
-
renderInput: input,
|
|
425
424
|
html: componentRender.html,
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
getOwningRenderer: (integrationName, rendererCache) => resolveOwningIntegrationRenderer({
|
|
429
|
-
appConfig: this.appConfig,
|
|
430
|
-
runtimeOrigin: this.runtimeOrigin,
|
|
431
|
-
currentIntegrationName: this.name,
|
|
432
|
-
currentRenderer: this,
|
|
433
|
-
integrationName,
|
|
434
|
-
cache: rendererCache,
|
|
435
|
-
}),
|
|
436
|
-
applyAttributesToFirstElement: (html, attributes) => this.htmlTransformer.applyAttributesToFirstElement(html, attributes),
|
|
437
|
-
dedupeProcessedAssets: (assets) => this.htmlTransformer.dedupeProcessedAssets(assets),
|
|
425
|
+
runtimeContext: this.getQueuedForeignSubtreeContext(input),
|
|
426
|
+
getOwningRenderer: (integrationName, rendererCache) => this.resolveOwningRenderer(integrationName, rendererCache),
|
|
438
427
|
});
|
|
439
428
|
const mergedAssets = this.htmlTransformer.dedupeProcessedAssets([
|
|
440
429
|
...(componentRender.assets ?? []),
|
|
@@ -704,14 +693,46 @@ export class IntegrationRenderer {
|
|
|
704
693
|
renderInput,
|
|
705
694
|
rendererCache: rendererCache,
|
|
706
695
|
}),
|
|
707
|
-
getOwningRenderer: (integrationName, rendererCache) =>
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
696
|
+
getOwningRenderer: (integrationName, rendererCache) => this.resolveOwningRenderer(integrationName, rendererCache),
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Returns the renderer that owns `integrationName`, reusing `rendererCache`
|
|
701
|
+
* for the current render.
|
|
702
|
+
*/
|
|
703
|
+
resolveOwningRenderer(integrationName, rendererCache) {
|
|
704
|
+
return resolveOwningIntegrationRenderer({
|
|
705
|
+
appConfig: this.appConfig,
|
|
706
|
+
runtimeOrigin: this.runtimeOrigin,
|
|
707
|
+
currentIntegrationName: this.name,
|
|
708
|
+
currentRenderer: this,
|
|
709
|
+
integrationName,
|
|
710
|
+
cache: rendererCache,
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Returns the queued foreign-subtree state this renderer keeps on `input`, or
|
|
715
|
+
* `undefined` when nothing was queued for it.
|
|
716
|
+
*/
|
|
717
|
+
getQueuedForeignSubtreeContext(input) {
|
|
718
|
+
return this.foreignSubtreeExecutionService.getQueuedRuntimeContext(input, getForeignSubtreeResolutionContextKey(this.name));
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Replaces the foreign-subtree tokens queued while rendering `html` with the
|
|
722
|
+
* HTML each owning renderer produces.
|
|
723
|
+
*
|
|
724
|
+
* @remarks
|
|
725
|
+
* `renderQueuedChildren` renders a subtree's children inside this renderer
|
|
726
|
+
* before the owning renderer renders the subtree around them. The returned
|
|
727
|
+
* assets are the owning renderers' assets, deduplicated.
|
|
728
|
+
*/
|
|
729
|
+
resolveQueuedForeignSubtrees(html, runtimeContext, renderQueuedChildren) {
|
|
730
|
+
return this.foreignSubtreeExecutionService.resolveQueuedHtml({
|
|
731
|
+
currentIntegrationName: this.name,
|
|
732
|
+
html,
|
|
733
|
+
runtimeContext,
|
|
734
|
+
renderQueuedChildren,
|
|
735
|
+
getOwningRenderer: (integrationName, rendererCache) => this.resolveOwningRenderer(integrationName, rendererCache),
|
|
715
736
|
});
|
|
716
737
|
}
|
|
717
738
|
finalizeIslandComponentRender(input, result) {
|
|
@@ -40,14 +40,6 @@ export declare class HtmlTransformerService {
|
|
|
40
40
|
* Nothing is stamped when text or a comment comes first (whitespace aside).
|
|
41
41
|
*/
|
|
42
42
|
applyAttributesToFirstBodyElement(html: string, attributes: Record<string, string>): string;
|
|
43
|
-
/**
|
|
44
|
-
* Sets attributes on the element a fragment or document starts with.
|
|
45
|
-
*
|
|
46
|
-
* @remarks
|
|
47
|
-
* Nothing is stamped when text or a comment comes first (whitespace aside),
|
|
48
|
-
* so a Lit render that opens with `<!--lit-part-->` keeps its markup.
|
|
49
|
-
*/
|
|
50
|
-
applyAttributesToFirstElement(html: string, attributes: Record<string, string>): string;
|
|
51
43
|
/**
|
|
52
44
|
* Removes duplicate processed assets while preserving first-seen order.
|
|
53
45
|
*
|
|
@@ -81,3 +73,11 @@ export declare class HtmlTransformerService {
|
|
|
81
73
|
private groupDependenciesByPosition;
|
|
82
74
|
private resolvePagePackageHtmlDependencies;
|
|
83
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Sets attributes on the element a fragment or document starts with.
|
|
78
|
+
*
|
|
79
|
+
* @remarks
|
|
80
|
+
* Nothing is stamped when text or a comment comes first (whitespace aside),
|
|
81
|
+
* so a Lit render that opens with `<!--lit-part-->` keeps its markup.
|
|
82
|
+
*/
|
|
83
|
+
export declare function applyAttributesToFirstElement(html: string, attributes: Record<string, string>): string;
|
|
@@ -78,16 +78,6 @@ export class HtmlTransformerService {
|
|
|
78
78
|
return false;
|
|
79
79
|
}, { leadingOnly: true });
|
|
80
80
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Sets attributes on the element a fragment or document starts with.
|
|
83
|
-
*
|
|
84
|
-
* @remarks
|
|
85
|
-
* Nothing is stamped when text or a comment comes first (whitespace aside),
|
|
86
|
-
* so a Lit render that opens with `<!--lit-part-->` keeps its markup.
|
|
87
|
-
*/
|
|
88
|
-
applyAttributesToFirstElement(html, attributes) {
|
|
89
|
-
return stampAttributes(html, attributes, () => true, { leadingOnly: true });
|
|
90
|
-
}
|
|
91
81
|
/**
|
|
92
82
|
* Removes duplicate processed assets while preserving first-seen order.
|
|
93
83
|
*
|
|
@@ -180,6 +170,16 @@ export class HtmlTransformerService {
|
|
|
180
170
|
return dedupeProcessedAssets([...nonGraphHtmlAssets, ...entryHtmlAssets]);
|
|
181
171
|
}
|
|
182
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Sets attributes on the element a fragment or document starts with.
|
|
175
|
+
*
|
|
176
|
+
* @remarks
|
|
177
|
+
* Nothing is stamped when text or a comment comes first (whitespace aside),
|
|
178
|
+
* so a Lit render that opens with `<!--lit-part-->` keeps its markup.
|
|
179
|
+
*/
|
|
180
|
+
export function applyAttributesToFirstElement(html, attributes) {
|
|
181
|
+
return stampAttributes(html, attributes, () => true, { leadingOnly: true });
|
|
182
|
+
}
|
|
183
183
|
/**
|
|
184
184
|
* Sets `attributes` on the first element that `isTarget` accepts.
|
|
185
185
|
*
|
|
@@ -47,7 +47,7 @@ export class RouteModuleBuildCache {
|
|
|
47
47
|
if (!this.dependencies.exists(outputPath)) {
|
|
48
48
|
return undefined;
|
|
49
49
|
}
|
|
50
|
-
if (!entry.outputImports
|
|
50
|
+
if (!entry.outputImports.every((importPath) => this.dependencies.exists(importPath))) {
|
|
51
51
|
return undefined;
|
|
52
52
|
}
|
|
53
53
|
return { outputPath, entry };
|
|
@@ -74,8 +74,10 @@ export class RouteModuleBuildCache {
|
|
|
74
74
|
dependencyHashes,
|
|
75
75
|
outputImports: options.outputImports ??
|
|
76
76
|
collectReachableLocalImports(outputPath, {
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
fileAccess: {
|
|
78
|
+
exists: (filePath) => this.dependencies.exists(filePath),
|
|
79
|
+
readFile: (filePath) => this.dependencies.readFile(filePath),
|
|
80
|
+
},
|
|
79
81
|
}),
|
|
80
82
|
renderedOutputs: existingEntry?.renderedOutputs,
|
|
81
83
|
};
|
|
@@ -10,10 +10,11 @@ export interface RouteModuleBuildCacheEntry {
|
|
|
10
10
|
buildKey: string;
|
|
11
11
|
dependencyHashes?: RouteModuleDependencyHashes;
|
|
12
12
|
/**
|
|
13
|
-
* Local files the compiled output
|
|
14
|
-
* The entry is reused only
|
|
13
|
+
* Local files reachable from the compiled output through local imports,
|
|
14
|
+
* including shared chunks and collection modules. The entry is reused only
|
|
15
|
+
* while all of them exist.
|
|
15
16
|
*/
|
|
16
|
-
outputImports
|
|
17
|
+
outputImports: string[];
|
|
17
18
|
renderedOutputs?: Record<string, RouteModuleStaticRenderCacheEntry>;
|
|
18
19
|
}
|
|
19
20
|
/** Metadata for one rendered static HTML artifact derived from a route module. */
|
|
@@ -58,5 +59,10 @@ export declare function resolvePageModuleOutputFileName(options: {
|
|
|
58
59
|
/** Builds the cache key for persisted production route-module builds. */
|
|
59
60
|
export declare function createPersistedRouteModuleBuildKey(options: PageModuleBuildImportOptions, sourceTransforms?: BuildOptions['sourceTransforms']): string;
|
|
60
61
|
export declare function createEmptyRouteModuleBuildCacheManifest(): RouteModuleBuildCacheManifest;
|
|
62
|
+
/**
|
|
63
|
+
* @remarks
|
|
64
|
+
* Entries without `outputImports` predate import validation and cannot show that
|
|
65
|
+
* their chunks still exist, so they are dropped and rebuild on the next lookup.
|
|
66
|
+
*/
|
|
61
67
|
export declare function readRouteModuleBuildCacheManifest(manifestPath: string): RouteModuleBuildCacheManifest | undefined;
|
|
62
68
|
export declare function writeRouteModuleBuildCacheManifest(manifestPath: string, manifest: RouteModuleBuildCacheManifest): void;
|
|
@@ -42,6 +42,11 @@ export function createEmptyRouteModuleBuildCacheManifest() {
|
|
|
42
42
|
entries: {},
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* @remarks
|
|
47
|
+
* Entries without `outputImports` predate import validation and cannot show that
|
|
48
|
+
* their chunks still exist, so they are dropped and rebuild on the next lookup.
|
|
49
|
+
*/
|
|
45
50
|
export function readRouteModuleBuildCacheManifest(manifestPath) {
|
|
46
51
|
const parsed = readProductionCacheManifest(manifestPath);
|
|
47
52
|
if (!parsed || typeof parsed.entries !== 'object') {
|
|
@@ -51,7 +56,7 @@ export function readRouteModuleBuildCacheManifest(manifestPath) {
|
|
|
51
56
|
corePackageVersion: parsed.corePackageVersion ?? '',
|
|
52
57
|
configHash: parsed.configHash,
|
|
53
58
|
buildInputsFingerprint: parsed.buildInputsFingerprint,
|
|
54
|
-
entries: parsed.entries,
|
|
59
|
+
entries: Object.fromEntries(Object.entries(parsed.entries).filter(([, entry]) => Array.isArray(entry.outputImports))),
|
|
55
60
|
};
|
|
56
61
|
}
|
|
57
62
|
export function writeRouteModuleBuildCacheManifest(manifestPath, manifest) {
|