@ecopages/core 0.4.0 → 0.6.0
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 +19 -15
- package/package.json +13 -4
- package/src/adapters/create-app.js +9 -5
- package/src/adapters/node/create-app.d.ts +18 -16
- package/src/adapters/node/create-app.js +26 -30
- package/src/adapters/node/server-adapter.d.ts +26 -9
- package/src/adapters/node/server-adapter.js +38 -8
- package/src/adapters/shared/hmr/hmr-manager.js +3 -2
- package/src/adapters/shared/http/api-request-pipeline.js +2 -2
- package/src/adapters/shared/http/dist-file-handler.js +25 -7
- package/src/adapters/shared/runtime/render-context.d.ts +2 -1
- package/src/adapters/shared/runtime/render-context.js +18 -21
- package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +4 -3
- package/src/adapters/shared/runtime/runtime-server-lifecycle.js +6 -4
- package/src/adapters/shared/runtime/server-request-pipeline.d.ts +6 -1
- package/src/adapters/shared/runtime/server-request-pipeline.js +11 -10
- package/src/adapters/shared/runtime/server-route-handler.js +4 -4
- package/src/adapters/shared/runtime/server-static-builder.d.ts +11 -11
- package/src/adapters/shared/runtime/server-static-builder.js +37 -18
- package/src/assets/app-browser-client-build.js +8 -21
- package/src/assets/app-browser-client-manifest.d.ts +1 -4
- package/src/assets/app-browser-client-manifest.js +6 -78
- package/src/assets/asset-processing-service/processors/script/file-script.processor.d.ts +2 -2
- package/src/assets/asset-processing-service/processors/script/file-script.processor.js +2 -2
- package/src/assets/browser-asset-output.d.ts +1 -1
- package/src/assets/browser-asset-output.js +1 -1
- package/src/build/app-build-manifest-runtime.d.ts +11 -1
- package/src/build/app-build-manifest-runtime.js +17 -3
- package/src/build/cache/pages-unified-graph-build.d.ts +32 -35
- package/src/build/cache/pages-unified-graph-build.js +206 -124
- package/src/build/cache/server-module-entries.d.ts +35 -0
- package/src/build/cache/server-module-entries.js +109 -0
- package/src/build/contracts/build-contracts.d.ts +5 -0
- package/src/build/contracts/content-virtual-modules.d.ts +9 -3
- package/src/build/contracts/content-virtual-modules.js +11 -5
- package/src/build/contracts.d.ts +1 -1
- package/src/build/contracts.js +1 -1
- package/src/build/copy-server-files.d.ts +10 -0
- package/src/build/copy-server-files.js +37 -0
- package/src/build/preserve-import-meta-transform.d.ts +1 -1
- package/src/build/preserve-import-meta-transform.js +1 -1
- package/src/build/production-build-id.d.ts +9 -0
- package/src/build/production-build-id.js +19 -0
- package/src/build/production-dist-complete.d.ts +5 -0
- package/src/build/production-dist-complete.js +101 -0
- package/src/build/production-route-list.d.ts +26 -0
- package/src/build/production-route-list.js +78 -0
- package/src/build/rolldown/rolldown-adapter-helpers.d.ts +2 -2
- package/src/build/rolldown/rolldown-adapter-helpers.js +56 -4
- package/src/build/rolldown/rolldown-build-adapter.js +1 -1
- package/src/build/rolldown/rolldown-plugin-bridge.js +2 -2
- package/src/build/runtime/build-request-identity.js +2 -1
- package/src/build/runtime/build-request-policy.d.ts +3 -2
- package/src/build/runtime/build-request-policy.js +5 -3
- package/src/build/server/import-view-module.d.ts +11 -0
- package/src/build/server/import-view-module.js +21 -0
- package/src/build/server/imported-view-plugin.d.ts +16 -0
- package/src/build/server/imported-view-plugin.js +59 -0
- package/src/build/server/page-module-import.service.d.ts +19 -20
- package/src/build/server/page-module-import.service.js +65 -36
- package/src/build/server/resolve-static-view.d.ts +9 -0
- package/src/build/server/resolve-static-view.js +28 -0
- package/src/build/server/route-module-build-cache-registry.d.ts +5 -3
- package/src/build/server/route-module-build-cache-registry.js +5 -3
- package/src/build/server/server-modules-manifest.d.ts +51 -0
- package/src/build/server/server-modules-manifest.js +129 -0
- package/src/build/server/view-reference.d.ts +38 -0
- package/src/build/server/view-reference.js +112 -0
- package/src/build/server-bundle-deploy-manifest.d.ts +9 -9
- package/src/build/server-bundle-deploy-manifest.js +24 -28
- package/src/build.d.ts +4 -2
- package/src/build.js +4 -2
- package/src/config/assembly/app-runtime.d.ts +15 -2
- package/src/config/assembly/app-runtime.js +3 -1
- package/src/config/assembly/finalize-config.js +64 -13
- package/src/config/index.d.ts +1 -0
- package/src/config/index.js +1 -0
- package/src/config/internal-types.d.ts +6 -0
- package/src/config/load-eco-config.d.ts +1 -0
- package/src/config/load-eco-config.js +11 -2
- package/src/config/resolve-eco-config-path.d.ts +2 -1
- package/src/config/resolve-eco-config-path.js +21 -15
- package/src/config/user-config-types.d.ts +9 -2
- package/src/dev/transform-server/dev-transform-server.js +1 -1
- package/src/dev/transform-server/dev-transform-vendor-registry.d.ts +29 -6
- package/src/dev/transform-server/dev-transform-vendor-registry.js +101 -53
- package/src/errors/http-error.d.ts +9 -0
- package/src/errors/http-error.js +11 -0
- package/src/html/html-transformer.service.d.ts +0 -21
- package/src/html/html-transformer.service.js +0 -32
- package/src/html-pages/html-page-module.d.ts +19 -0
- package/src/html-pages/html-page-module.js +66 -13
- package/src/html-pages/html-page-renderer.d.ts +6 -1
- package/src/html-pages/html-page-renderer.js +14 -6
- package/src/html-pages/html-pages.plugin.d.ts +10 -0
- package/src/html-pages/html-pages.plugin.js +7 -1
- package/src/index.d.ts +2 -0
- package/src/index.js +2 -0
- package/src/integration.d.ts +2 -2
- package/src/integration.js +1 -1
- package/src/islands/island-host.d.ts +1 -2
- package/src/islands/island-host.js +1 -2
- package/src/page-cache/page-cache-service.d.ts +8 -0
- package/src/page-cache/page-cache-service.js +12 -0
- package/src/plugins/integration-plugin.d.ts +34 -7
- package/src/plugins/integration-plugin.js +14 -2
- package/src/plugins/processor.d.ts +18 -1
- package/src/plugins/processor.js +20 -1
- package/src/plugins/server-dom.d.ts +29 -0
- package/src/plugins/server-dom.js +36 -0
- package/src/plugins/tsconfig-import-resolver.d.ts +3 -1
- package/src/plugins/tsconfig-import-resolver.js +4 -2
- package/src/processor.d.ts +1 -1
- package/src/route-renderer/error-pages/error-page-renderer.d.ts +6 -4
- package/src/route-renderer/error-pages/error-page-renderer.js +9 -5
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +2 -44
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +14 -89
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +4 -16
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +2 -10
- package/src/route-renderer/orchestration/foreign-child/render-session.d.ts +3 -5
- package/src/route-renderer/orchestration/integration-renderer.d.ts +21 -44
- package/src/route-renderer/orchestration/integration-renderer.js +69 -117
- package/src/route-renderer/orchestration/ownership-graph/page-client-browser-assets.d.ts +3 -4
- package/src/route-renderer/orchestration/ownership-graph/page-client-browser-assets.js +4 -15
- package/src/route-renderer/orchestration/ownership-graph/prepared-graph-membership.d.ts +22 -0
- package/src/route-renderer/orchestration/ownership-graph/prepared-graph-membership.js +45 -0
- package/src/route-renderer/orchestration/page-browser-graph/grouped-graph-build-plan.d.ts +0 -1
- package/src/route-renderer/orchestration/page-browser-graph/missing-production-browser-graph.d.ts +21 -0
- package/src/route-renderer/orchestration/page-browser-graph/missing-production-browser-graph.js +31 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +58 -24
- package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.d.ts +12 -0
- package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.js +55 -0
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +4 -3
- package/src/router/server/route-registry.d.ts +23 -1
- package/src/router/server/route-registry.js +41 -14
- package/src/static-site-generator/production-page-browser-graph-prebuild.d.ts +8 -2
- package/src/static-site-generator/production-page-browser-graph-prebuild.js +14 -13
- package/src/static-site-generator/static-site-generator.d.ts +19 -3
- package/src/static-site-generator/static-site-generator.js +78 -40
- package/src/types/build-types.d.ts +6 -0
- package/src/types/contracts.d.ts +26 -35
- package/src/types/eco-api-types.d.ts +1 -1
- package/src/types/public-types.d.ts +1 -0
- package/src/types/view-reference.d.ts +31 -0
- package/src/types/view-reference.js +15 -0
- package/src/utils/additional-watch-paths.d.ts +3 -3
- package/src/utils/additional-watch-paths.js +3 -1
- package/src/utils/resolve-entry-file.d.ts +4 -2
- package/src/utils/resolve-entry-file.js +4 -2
- package/src/utils/root-relative-path.d.ts +4 -0
- package/src/utils/root-relative-path.js +8 -0
- package/src/utils/server-bundle-context.d.ts +14 -0
- package/src/utils/server-bundle-context.js +45 -0
- package/src/watchers/project-watcher-ignore.d.ts +2 -5
- package/src/watchers/project-watcher-ignore.js +2 -5
- package/src/watchers/project-watcher.d.ts +9 -7
- package/src/watchers/project-watcher.js +100 -52
- package/src/watchers/workspace-package-watch-roots.d.ts +4 -4
- package/src/watchers/workspace-package-watch-roots.js +41 -25
- package/src/build/server/view-module-loader.d.ts +0 -10
- package/src/build/server/view-module-loader.js +0 -46
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.d.ts +0 -12
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.js +0 -32
|
@@ -6,7 +6,8 @@ import { requireAppRuntime } from '../../../utils/app-runtime.js';
|
|
|
6
6
|
import { startupTrace } from '../../../diagnostics/startup-trace.js';
|
|
7
7
|
import { createAppBrowserClientEntryKey } from '../../../assets/app-browser-client-build.js';
|
|
8
8
|
import { collectPageBrowserGraphDependencyPaths, createPageBrowserGraphEntryFingerprint, } from './page-browser-graph-session.js';
|
|
9
|
-
import { createRouteGraphLookupKey } from './route-instance-key.js';
|
|
9
|
+
import { createRouteGraphLookupKey, pageDependencyInstanceParams } from './route-instance-key.js';
|
|
10
|
+
import { describeProductionBrowserGraphEntry, missingProductionBrowserGraphError, shouldRejectUnplannedProductionBrowserGraph, } from './missing-production-browser-graph.js';
|
|
10
11
|
function isGroupedContentScriptAsset(asset) {
|
|
11
12
|
return asset.kind === 'script' && asset.source === 'content' && Boolean(asset.groupedBundle?.id);
|
|
12
13
|
}
|
|
@@ -30,6 +31,50 @@ function applyPrebuiltGroupedDependencyMetadata(currentContribution, plannedCont
|
|
|
30
31
|
}),
|
|
31
32
|
};
|
|
32
33
|
}
|
|
34
|
+
function groupedKeysMatch(integrationName, left, right) {
|
|
35
|
+
return (JSON.stringify(groupedDependencyKeys(integrationName, left)) ===
|
|
36
|
+
JSON.stringify(groupedDependencyKeys(integrationName, right)));
|
|
37
|
+
}
|
|
38
|
+
function findPlannedGroupedInstance(input, contribution, dependencyInstanceKey) {
|
|
39
|
+
const instances = input.groupedBuildPlan?.instances;
|
|
40
|
+
if (!instances)
|
|
41
|
+
return undefined;
|
|
42
|
+
const routeLookupKey = createRouteGraphLookupKey(input.routeFile, dependencyInstanceKey);
|
|
43
|
+
const exact = instances.find((instance) => !instance.isRouteTemplate &&
|
|
44
|
+
createRouteGraphLookupKey(instance.routeFile, instance.dependencyInstanceKey) === routeLookupKey);
|
|
45
|
+
if (exact)
|
|
46
|
+
return exact;
|
|
47
|
+
const requestParams = pageDependencyInstanceParams(dependencyInstanceKey);
|
|
48
|
+
const paramsMatch = instances.find((instance) => {
|
|
49
|
+
if (instance.isRouteTemplate || instance.routeFile !== input.routeFile)
|
|
50
|
+
return false;
|
|
51
|
+
if (!groupedKeysMatch(input.integrationName, instance.contribution, contribution))
|
|
52
|
+
return false;
|
|
53
|
+
return (JSON.stringify(pageDependencyInstanceParams(instance.dependencyInstanceKey)) ===
|
|
54
|
+
JSON.stringify(requestParams));
|
|
55
|
+
});
|
|
56
|
+
if (paramsMatch)
|
|
57
|
+
return paramsMatch;
|
|
58
|
+
return instances.find((instance) => instance.routeFile === input.routeFile &&
|
|
59
|
+
instance.isRouteTemplate === true &&
|
|
60
|
+
instance.prebuiltGroupedAssets !== undefined &&
|
|
61
|
+
groupedKeysMatch(input.integrationName, instance.contribution, contribution));
|
|
62
|
+
}
|
|
63
|
+
function remapPlannedInstanceKey(plan, plannedInstance, dependencyInstanceKey) {
|
|
64
|
+
if (plannedInstance.dependencyInstanceKey === dependencyInstanceKey)
|
|
65
|
+
return plan;
|
|
66
|
+
return {
|
|
67
|
+
...plan,
|
|
68
|
+
instances: plan.instances.map((instance) => instance === plannedInstance
|
|
69
|
+
? {
|
|
70
|
+
...instance,
|
|
71
|
+
dependencyInstanceKey,
|
|
72
|
+
skipStaticProps: false,
|
|
73
|
+
isRouteTemplate: false,
|
|
74
|
+
}
|
|
75
|
+
: instance),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
33
78
|
function resolveGroupedBuildPlan(input, contribution, dependencyInstanceKey) {
|
|
34
79
|
if (input.cacheable === false) {
|
|
35
80
|
return {
|
|
@@ -38,30 +83,13 @@ function resolveGroupedBuildPlan(input, contribution, dependencyInstanceKey) {
|
|
|
38
83
|
usesPrebuiltGroupedAssets: false,
|
|
39
84
|
};
|
|
40
85
|
}
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
? undefined
|
|
46
|
-
: input.groupedBuildPlan?.instances.find((instance) => instance.routeFile === input.routeFile &&
|
|
47
|
-
instance.isRouteTemplate === true &&
|
|
48
|
-
instance.prebuiltGroupedAssets !== undefined &&
|
|
49
|
-
JSON.stringify(groupedDependencyKeys(input.integrationName, instance.contribution)) ===
|
|
50
|
-
JSON.stringify(groupedDependencyKeys(input.integrationName, contribution)));
|
|
51
|
-
const plannedInstance = exactPlanInstance ?? templatePlanInstance;
|
|
52
|
-
const groupedBuildPlan = templatePlanInstance
|
|
53
|
-
? input.groupedBuildPlan && {
|
|
54
|
-
...input.groupedBuildPlan,
|
|
55
|
-
instances: input.groupedBuildPlan.instances.map((instance) => instance === templatePlanInstance
|
|
56
|
-
? { ...instance, dependencyInstanceKey, skipStaticProps: false, isRouteTemplate: false }
|
|
57
|
-
: instance),
|
|
58
|
-
}
|
|
59
|
-
: exactPlanInstance
|
|
60
|
-
? input.groupedBuildPlan
|
|
61
|
-
: undefined;
|
|
86
|
+
const plannedInstance = findPlannedGroupedInstance(input, contribution, dependencyInstanceKey);
|
|
87
|
+
const groupedBuildPlan = plannedInstance && input.groupedBuildPlan
|
|
88
|
+
? remapPlannedInstanceKey(input.groupedBuildPlan, plannedInstance, dependencyInstanceKey)
|
|
89
|
+
: undefined;
|
|
62
90
|
const usesPrebuiltGroupedAssets = plannedInstance?.prebuiltGroupedAssets !== undefined;
|
|
63
|
-
const graphContribution =
|
|
64
|
-
? applyPrebuiltGroupedDependencyMetadata(contribution,
|
|
91
|
+
const graphContribution = plannedInstance?.isRouteTemplate
|
|
92
|
+
? applyPrebuiltGroupedDependencyMetadata(contribution, plannedInstance.contribution, input.integrationName)
|
|
65
93
|
: usesPrebuiltGroupedAssets
|
|
66
94
|
? (plannedInstance.contribution ?? contribution)
|
|
67
95
|
: contribution;
|
|
@@ -185,6 +213,12 @@ export class PageBrowserGraphService {
|
|
|
185
213
|
cacheable: true,
|
|
186
214
|
};
|
|
187
215
|
}
|
|
216
|
+
const ungroupedDependencies = (contribution.dependencies ?? []).filter((dep) => !isGroupedContentScriptAsset(dep));
|
|
217
|
+
if (!hasGroupedDependencies && ungroupedDependencies.length === 0)
|
|
218
|
+
return undefined;
|
|
219
|
+
if (shouldRejectUnplannedProductionBrowserGraph(this.appConfig)) {
|
|
220
|
+
throw missingProductionBrowserGraphError(input.routeFile, describeProductionBrowserGraphEntry(undefined, input.dependencyInstanceKey));
|
|
221
|
+
}
|
|
188
222
|
if (!hasGroupedDependencies)
|
|
189
223
|
return undefined;
|
|
190
224
|
return this.resolveGroupedPageBrowserAssets(input, contribution);
|
|
@@ -15,6 +15,18 @@ export type GroupedGraphScope = {
|
|
|
15
15
|
* encodings would make otherwise distinct route inputs collide.
|
|
16
16
|
*/
|
|
17
17
|
export declare function createPageDependencyInstanceKey(input: PageDependencyInstance): string;
|
|
18
|
+
/**
|
|
19
|
+
* Formats Params for a missing production Page Browser Graph error.
|
|
20
|
+
*/
|
|
21
|
+
export declare function describePageDependencyInstance(input: PageDependencyInstance): string;
|
|
22
|
+
/**
|
|
23
|
+
* Params encoded in a {@link createPageDependencyInstanceKey} value, ignoring query.
|
|
24
|
+
*/
|
|
25
|
+
export declare function pageDependencyInstanceParams(dependencyInstanceKey: string): Array<[string, string | string[]]> | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Formats a {@link createPageDependencyInstanceKey} value for a missing-manifest error.
|
|
28
|
+
*/
|
|
29
|
+
export declare function describePageDependencyInstanceKey(dependencyInstanceKey: string): string;
|
|
18
30
|
/**
|
|
19
31
|
* Combines a route file with an optional dependency-instance key for grouped graph maps.
|
|
20
32
|
*/
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
function formatParamEntries(entries) {
|
|
2
|
+
return [...entries].map(([key, value]) => `${key}=${Array.isArray(value) ? value.join('/') : value}`).join(',');
|
|
3
|
+
}
|
|
1
4
|
/**
|
|
2
5
|
* Builds a stable cache key for one concrete dependency resolver input.
|
|
3
6
|
*
|
|
@@ -13,6 +16,58 @@ export function createPageDependencyInstanceKey(input) {
|
|
|
13
16
|
}
|
|
14
17
|
return JSON.stringify({ params, query });
|
|
15
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Formats Params for a missing production Page Browser Graph error.
|
|
21
|
+
*/
|
|
22
|
+
export function describePageDependencyInstance(input) {
|
|
23
|
+
const params = canonicalizeInput(input.params);
|
|
24
|
+
if (params.length === 0)
|
|
25
|
+
return 'default';
|
|
26
|
+
return formatParamEntries(params);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Params encoded in a {@link createPageDependencyInstanceKey} value, ignoring query.
|
|
30
|
+
*/
|
|
31
|
+
export function pageDependencyInstanceParams(dependencyInstanceKey) {
|
|
32
|
+
if (dependencyInstanceKey.length === 0)
|
|
33
|
+
return [];
|
|
34
|
+
try {
|
|
35
|
+
const parsed = JSON.parse(dependencyInstanceKey);
|
|
36
|
+
if (typeof parsed !== 'object' || parsed === null || !('params' in parsed)) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const params = parsed.params;
|
|
40
|
+
if (!Array.isArray(params))
|
|
41
|
+
return undefined;
|
|
42
|
+
const entries = [];
|
|
43
|
+
for (const item of params) {
|
|
44
|
+
if (!Array.isArray(item) || item.length !== 2 || typeof item[0] !== 'string') {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
const value = item[1];
|
|
48
|
+
if (typeof value !== 'string' &&
|
|
49
|
+
!(Array.isArray(value) && value.every((part) => typeof part === 'string'))) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
entries.push([item[0], value]);
|
|
53
|
+
}
|
|
54
|
+
return entries;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Formats a {@link createPageDependencyInstanceKey} value for a missing-manifest error.
|
|
62
|
+
*/
|
|
63
|
+
export function describePageDependencyInstanceKey(dependencyInstanceKey) {
|
|
64
|
+
const params = pageDependencyInstanceParams(dependencyInstanceKey);
|
|
65
|
+
if (params === undefined)
|
|
66
|
+
return dependencyInstanceKey;
|
|
67
|
+
if (params.length === 0)
|
|
68
|
+
return 'default';
|
|
69
|
+
return formatParamEntries(params);
|
|
70
|
+
}
|
|
16
71
|
/**
|
|
17
72
|
* Combines a route file with an optional dependency-instance key for grouped graph maps.
|
|
18
73
|
*/
|
|
@@ -7,6 +7,7 @@ import { createPreparedComponentGraphBuilder, } from '../ownership-graph/compone
|
|
|
7
7
|
import { OwnershipValidationService, throwIfOwnershipInvalid, } from '../ownership-graph/ownership-validation.service.js';
|
|
8
8
|
import { collectComponentGraphWatchPaths, collectUsedIntegrationDependenciesFromNames, } from '../ownership-graph/component-graph-collectors.js';
|
|
9
9
|
import { collectPageClientPlanFromGraph } from '../ownership-graph/page-client-plan.js';
|
|
10
|
+
import { collectPreparedGraphComponents } from '../ownership-graph/prepared-graph-membership.js';
|
|
10
11
|
import { buildGlobalInjectorAssets } from '../page-browser-graph/global-injector-assets.service.js';
|
|
11
12
|
import { mergePageBrowserGraphContributions } from '../page-browser-graph/page-browser-graph-contribution.merge.js';
|
|
12
13
|
import { PageBrowserGraphService } from '../page-browser-graph/page-browser-graph.service.js';
|
|
@@ -210,7 +211,7 @@ export class RouteRenderOrchestrator {
|
|
|
210
211
|
}),
|
|
211
212
|
sourceDependencyPaths,
|
|
212
213
|
pageClientPlan: clientPlan,
|
|
213
|
-
|
|
214
|
+
preparedGraphComponents: collectPreparedGraphComponents(preparedGraph),
|
|
214
215
|
};
|
|
215
216
|
}
|
|
216
217
|
async resolveDeclaredPageBrowserGraph(input) {
|
|
@@ -253,7 +254,7 @@ export class RouteRenderOrchestrator {
|
|
|
253
254
|
headers: {
|
|
254
255
|
'Content-Type': 'text/html',
|
|
255
256
|
},
|
|
256
|
-
}), htmlFinalization.htmlContributions, renderOptions
|
|
257
|
+
}), htmlFinalization.htmlContributions, renderOptions));
|
|
257
258
|
return {
|
|
258
259
|
body,
|
|
259
260
|
cacheStrategy: renderOptions.cacheStrategy,
|
|
@@ -268,7 +269,7 @@ export class RouteRenderOrchestrator {
|
|
|
268
269
|
headers: {
|
|
269
270
|
'Content-Type': 'text/html',
|
|
270
271
|
},
|
|
271
|
-
}), htmlFinalization.htmlContributions, renderOptions
|
|
272
|
+
}), htmlFinalization.htmlContributions, renderOptions));
|
|
272
273
|
return {
|
|
273
274
|
body,
|
|
274
275
|
cacheStrategy: renderOptions.cacheStrategy,
|
|
@@ -22,11 +22,12 @@ export type RouteMatch = {
|
|
|
22
22
|
readonly params: RouteParams;
|
|
23
23
|
readonly query: RouteQuery;
|
|
24
24
|
};
|
|
25
|
-
export type
|
|
25
|
+
export type PathExpansion = {
|
|
26
26
|
readonly pathname: string;
|
|
27
27
|
readonly templateRoute: TemplateRoute;
|
|
28
28
|
readonly params: RouteParams;
|
|
29
29
|
};
|
|
30
|
+
export type StaticPathExpansion = PathExpansion;
|
|
30
31
|
export type StaticGenerationRoute = {
|
|
31
32
|
readonly requestUrl: string;
|
|
32
33
|
readonly pathname: string;
|
|
@@ -44,6 +45,14 @@ export type RouteRegistryPageModule = {
|
|
|
44
45
|
}>;
|
|
45
46
|
}>;
|
|
46
47
|
readonly staticProps?: unknown;
|
|
48
|
+
/**
|
|
49
|
+
* The Page's Cache Strategy.
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* `'dynamic'` Pages are omitted from Static Path Expansions (no HTML at Build-Time Rendering).
|
|
53
|
+
* When they declare `staticPaths`, those Params are still listed for Page Browser Graph planning.
|
|
54
|
+
*/
|
|
55
|
+
readonly cache?: unknown;
|
|
47
56
|
};
|
|
48
57
|
export interface RouteRegistryPageModuleAdapter {
|
|
49
58
|
loadPageModule(filePath: string): Promise<RouteRegistryPageModule>;
|
|
@@ -86,9 +95,22 @@ export declare class RouteRegistry {
|
|
|
86
95
|
private compareSpecificity;
|
|
87
96
|
private getSpecificitySegments;
|
|
88
97
|
private isDynamicRouteSegment;
|
|
98
|
+
private expandStaticPaths;
|
|
99
|
+
private listPathExpansions;
|
|
89
100
|
listStaticPathExpansions(input: {
|
|
90
101
|
runtimeOrigin: string;
|
|
91
102
|
}): Promise<readonly StaticPathExpansion[]>;
|
|
103
|
+
/**
|
|
104
|
+
* Params of Dynamic Pages that declare `staticPaths`, for Page Browser Graph planning.
|
|
105
|
+
*
|
|
106
|
+
* @remarks
|
|
107
|
+
* The return shape is {@link PathExpansion}, the same records `staticPaths` produces. They are
|
|
108
|
+
* not Static Path Expansions: HTML still uses Request-Time Rendering. The build uses them so
|
|
109
|
+
* each Params list's graph is in the browser client manifest.
|
|
110
|
+
*/
|
|
111
|
+
listDynamicPagePathExpansions(input: {
|
|
112
|
+
runtimeOrigin: string;
|
|
113
|
+
}): Promise<readonly PathExpansion[]>;
|
|
92
114
|
listStaticGenerationRoutes(input: {
|
|
93
115
|
runtimeOrigin: string;
|
|
94
116
|
}): Promise<readonly StaticGenerationRoute[]>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { fileSystem } from '@ecopages/file-system';
|
|
3
3
|
import { appLogger } from '../../global/app-logger.js';
|
|
4
|
+
import { loadProductionTemplateRoutes } from '../../build/production-route-list.js';
|
|
4
5
|
import { invariant } from '../../utils/invariant.js';
|
|
6
|
+
import { isProductionRuntime } from '../../env.js';
|
|
5
7
|
import { hasKnownStaticExtension } from '../../utils/static-file-extensions.js';
|
|
6
8
|
import { ENDPOINT_FILE_EXTENSIONS, findEndpointFileExtension } from '../../utils/endpoint-file-extensions.js';
|
|
7
9
|
import { normalizePathname } from '../../utils/path-pattern.js';
|
|
@@ -40,7 +42,8 @@ export class RouteRegistry {
|
|
|
40
42
|
return this.templateRouteList.filter((route) => route.role === 'page');
|
|
41
43
|
}
|
|
42
44
|
async init() {
|
|
43
|
-
|
|
45
|
+
const productionRoutes = isProductionRuntime() ? loadProductionTemplateRoutes(this.appConfig) : undefined;
|
|
46
|
+
this.templateRouteList = productionRoutes ?? (await this.scanTemplateRoutes());
|
|
44
47
|
appLogger.debug('RouteRegistry initialized', this.templateRouteList);
|
|
45
48
|
}
|
|
46
49
|
async reload() {
|
|
@@ -105,35 +108,59 @@ export class RouteRegistry {
|
|
|
105
108
|
isDynamicRouteSegment(segment) {
|
|
106
109
|
return segment.startsWith('[') && segment.endsWith(']');
|
|
107
110
|
}
|
|
108
|
-
async
|
|
111
|
+
async expandStaticPaths(route, staticPaths, runtimeOrigin) {
|
|
112
|
+
const result = await staticPaths({
|
|
113
|
+
appConfig: this.appConfig,
|
|
114
|
+
runtimeOrigin,
|
|
115
|
+
});
|
|
116
|
+
return result.paths.map(({ params }) => ({
|
|
117
|
+
pathname: buildSegmentPath(route.pathname, params, 'filesystem'),
|
|
118
|
+
templateRoute: route,
|
|
119
|
+
params,
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
async listPathExpansions(input, options) {
|
|
109
123
|
const expansions = [];
|
|
110
124
|
for (const route of this.pageRoutes) {
|
|
111
125
|
if (route.kind === 'exact') {
|
|
112
126
|
continue;
|
|
113
127
|
}
|
|
114
128
|
const pageModule = await this.pageModuleAdapter.loadPageModule(route.filePath);
|
|
129
|
+
if (!options.include(pageModule)) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
115
132
|
const staticPaths = pageModule.staticPaths;
|
|
116
|
-
if (this.buildMode) {
|
|
133
|
+
if (options.requireStaticHooks && this.buildMode) {
|
|
117
134
|
invariant(staticPaths !== undefined, `[ecopages] Missing getStaticPaths in ${route.filePath}`);
|
|
118
135
|
invariant(pageModule.staticProps !== undefined, `[ecopages] Missing getStaticProps in ${route.filePath}`);
|
|
119
136
|
}
|
|
120
137
|
if (!staticPaths) {
|
|
121
138
|
continue;
|
|
122
139
|
}
|
|
123
|
-
|
|
124
|
-
appConfig: this.appConfig,
|
|
125
|
-
runtimeOrigin: input.runtimeOrigin,
|
|
126
|
-
});
|
|
127
|
-
for (const { params } of result.paths) {
|
|
128
|
-
expansions.push({
|
|
129
|
-
pathname: buildSegmentPath(route.pathname, params, 'filesystem'),
|
|
130
|
-
templateRoute: route,
|
|
131
|
-
params,
|
|
132
|
-
});
|
|
133
|
-
}
|
|
140
|
+
expansions.push(...(await this.expandStaticPaths(route, staticPaths, input.runtimeOrigin)));
|
|
134
141
|
}
|
|
135
142
|
return expansions;
|
|
136
143
|
}
|
|
144
|
+
async listStaticPathExpansions(input) {
|
|
145
|
+
return this.listPathExpansions(input, {
|
|
146
|
+
include: (pageModule) => pageModule.cache !== 'dynamic',
|
|
147
|
+
requireStaticHooks: true,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Params of Dynamic Pages that declare `staticPaths`, for Page Browser Graph planning.
|
|
152
|
+
*
|
|
153
|
+
* @remarks
|
|
154
|
+
* The return shape is {@link PathExpansion}, the same records `staticPaths` produces. They are
|
|
155
|
+
* not Static Path Expansions: HTML still uses Request-Time Rendering. The build uses them so
|
|
156
|
+
* each Params list's graph is in the browser client manifest.
|
|
157
|
+
*/
|
|
158
|
+
async listDynamicPagePathExpansions(input) {
|
|
159
|
+
return this.listPathExpansions(input, {
|
|
160
|
+
include: (pageModule) => pageModule.cache === 'dynamic' && pageModule.staticPaths !== undefined,
|
|
161
|
+
requireStaticHooks: false,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
137
164
|
async listStaticGenerationRoutes(input) {
|
|
138
165
|
const staticPathExpansions = await this.listStaticPathExpansions(input);
|
|
139
166
|
return [
|
|
@@ -20,7 +20,8 @@ export declare function shouldPrebuildProductionPageBrowserGraphs(): boolean;
|
|
|
20
20
|
*
|
|
21
21
|
* @remarks
|
|
22
22
|
* Clears only the `'production'` policy so a failed or force export cannot
|
|
23
|
-
* reuse staged graph output.
|
|
23
|
+
* reuse staged graph output. Also sets `productionBrowserGraphsSealed` to false so a
|
|
24
|
+
* retry of `ecopages build` can still emit graphs. Development session records are left intact.
|
|
24
25
|
*/
|
|
25
26
|
export declare function clearProductionPageBrowserGraphSession(appConfig: EcoPagesAppConfig): void;
|
|
26
27
|
/**
|
|
@@ -32,5 +33,10 @@ export declare function clearProductionPageBrowserGraphSession(appConfig: EcoPag
|
|
|
32
33
|
* then resolves into `page-browser-graph-session`). Does not persist a disk manifest.
|
|
33
34
|
*/
|
|
34
35
|
export declare function prebuildProductionPageBrowserGraphs(appConfig: EcoPagesAppConfig, routeInstances: readonly ProductionPageBrowserGraphRouteInstance[], routeRendererFactory: PageRendererResolver): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Reuses the browser outputs written by `ecopages build` while `ecopages start` prepares SSR routes.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* A successful restore sets `productionBrowserGraphsSealed` so a missing graph is an error.
|
|
41
|
+
*/
|
|
36
42
|
export declare function prebuildProductionPageBrowserGraphsFromManifest(appConfig: EcoPagesAppConfig, routeRendererFactory: PageRendererResolver): Promise<boolean>;
|
|
@@ -2,9 +2,9 @@ import path from 'node:path';
|
|
|
2
2
|
import { isProductionRuntime } from '../utils/runtime.js';
|
|
3
3
|
import { requireAppRuntime } from '../utils/app-runtime.js';
|
|
4
4
|
import { createPageDependencyInstanceKey } from '../route-renderer/orchestration/page-browser-graph/route-instance-key.js';
|
|
5
|
-
import {
|
|
5
|
+
import { setPrebuiltHtmlPageModuleScriptUrls } from '../html-pages/html-page-module-scripts.js';
|
|
6
6
|
import { buildAppBrowserClient } from '../assets/app-browser-client-build.js';
|
|
7
|
-
import { assertAppBrowserClientOutputsExist, assertAppBrowserClientManifestHtmlOutputsExist, clearAppBrowserClientManifest,
|
|
7
|
+
import { assertAppBrowserClientOutputsExist, assertAppBrowserClientManifestHtmlOutputsExist, clearAppBrowserClientManifest, createNormalizedAppBrowserClientEntryKey, readAppBrowserClientManifest, restoreAppBrowserClientAssets, resolveAppBrowserClientManifestPath, writeAppBrowserClientManifest, } from '../assets/app-browser-client-manifest.js';
|
|
8
8
|
/**
|
|
9
9
|
* Returns whether production should reuse prebuilt Page Browser Graphs.
|
|
10
10
|
*
|
|
@@ -20,10 +20,13 @@ export function shouldPrebuildProductionPageBrowserGraphs() {
|
|
|
20
20
|
*
|
|
21
21
|
* @remarks
|
|
22
22
|
* Clears only the `'production'` policy so a failed or force export cannot
|
|
23
|
-
* reuse staged graph output.
|
|
23
|
+
* reuse staged graph output. Also sets `productionBrowserGraphsSealed` to false so a
|
|
24
|
+
* retry of `ecopages build` can still emit graphs. Development session records are left intact.
|
|
24
25
|
*/
|
|
25
26
|
export function clearProductionPageBrowserGraphSession(appConfig) {
|
|
26
|
-
requireAppRuntime(appConfig)
|
|
27
|
+
const runtime = requireAppRuntime(appConfig);
|
|
28
|
+
runtime.pageBrowserGraphSession.clearPolicyRecords('production');
|
|
29
|
+
runtime.productionBrowserGraphsSealed = false;
|
|
27
30
|
clearAppBrowserClientManifest(appConfig);
|
|
28
31
|
}
|
|
29
32
|
function serializeProductionRouteInstance(instance) {
|
|
@@ -144,10 +147,6 @@ function restoreManifestRouteAssets(appConfig, renderer, entry, instance) {
|
|
|
144
147
|
instance.prebuiltGroupedAssets = restoreAppBrowserClientAssets(appConfig, entry.groupedAssets);
|
|
145
148
|
instance.prebuiltPageClientBrowserAssets = {
|
|
146
149
|
processedAssets: restoreAppBrowserClientAssets(appConfig, entry.pageClientAssets.processedAssets),
|
|
147
|
-
islandRenderAssetsByFile: new Map(entry.pageClientAssets.islandRenderAssetsByFile.map(([filePath, assets]) => [
|
|
148
|
-
resolveAppBrowserClientManifestPath(appConfig, filePath),
|
|
149
|
-
restoreAppBrowserClientAssets(appConfig, assets),
|
|
150
|
-
])),
|
|
151
150
|
fallbackDependencies: restoreFallbackDependencies(appConfig.rootDir, entry, instance),
|
|
152
151
|
};
|
|
153
152
|
}
|
|
@@ -172,17 +171,18 @@ async function prebuildManifestEntriesForRenderer(appConfig, renderer, entries)
|
|
|
172
171
|
});
|
|
173
172
|
}
|
|
174
173
|
}
|
|
175
|
-
/**
|
|
174
|
+
/**
|
|
175
|
+
* Reuses the browser outputs written by `ecopages build` while `ecopages start` prepares SSR routes.
|
|
176
|
+
*
|
|
177
|
+
* @remarks
|
|
178
|
+
* A successful restore sets `productionBrowserGraphsSealed` so a missing graph is an error.
|
|
179
|
+
*/
|
|
176
180
|
export async function prebuildProductionPageBrowserGraphsFromManifest(appConfig, routeRendererFactory) {
|
|
177
181
|
if (!shouldPrebuildProductionPageBrowserGraphs())
|
|
178
182
|
return false;
|
|
179
183
|
const manifest = readAppBrowserClientManifest(appConfig);
|
|
180
184
|
if (!manifest)
|
|
181
185
|
return false;
|
|
182
|
-
assertAppBrowserClientSourcesMatch(appConfig, manifest.sourceFingerprints);
|
|
183
|
-
if (collectHtmlPageModuleScriptBuildInputs(appConfig).fingerprint !== manifest.htmlPageModuleScriptFingerprint) {
|
|
184
|
-
throw new Error(`The app browser build manifest does not match the current HTML Page module scripts. Run \`ecopages build\` again.`);
|
|
185
|
-
}
|
|
186
186
|
assertAppBrowserClientOutputsExist(appConfig, manifest.browserOutputPaths);
|
|
187
187
|
assertAppBrowserClientManifestHtmlOutputsExist(appConfig, manifest.htmlPageModuleScriptUrls);
|
|
188
188
|
setPrebuiltHtmlPageModuleScriptUrls(appConfig, new Map(Object.entries(manifest.htmlPageModuleScriptUrls).map(([filePath, url]) => [
|
|
@@ -192,5 +192,6 @@ export async function prebuildProductionPageBrowserGraphsFromManifest(appConfig,
|
|
|
192
192
|
for (const [renderer, entries] of groupManifestEntriesByRenderer(appConfig, routeRendererFactory, manifest.entries)) {
|
|
193
193
|
await prebuildManifestEntriesForRenderer(appConfig, renderer, entries);
|
|
194
194
|
}
|
|
195
|
+
requireAppRuntime(appConfig).productionBrowserGraphsSealed = true;
|
|
195
196
|
return true;
|
|
196
197
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { EcoPagesAppConfig } from '../config/internal-types.js';
|
|
2
2
|
import type { SitemapConfig, StaticRoute, ErrorPageLoaders } from '../types/contracts.js';
|
|
3
3
|
import type { PageRendererResolver, StaticGenerationRendererResolver } from '../route-renderer/route-renderer.js';
|
|
4
|
-
import type { StaticGenerationRoute, TemplateRoute } from '../router/server/route-registry.js';
|
|
4
|
+
import type { PathExpansion, StaticGenerationRoute, TemplateRoute } from '../router/server/route-registry.js';
|
|
5
5
|
type StaticGenerationRouteSource = {
|
|
6
6
|
listStaticGenerationRoutes(input: {
|
|
7
7
|
runtimeOrigin: string;
|
|
8
8
|
}): Promise<readonly StaticGenerationRoute[]>;
|
|
9
|
+
listDynamicPagePathExpansions?(input: {
|
|
10
|
+
runtimeOrigin: string;
|
|
11
|
+
}): Promise<readonly PathExpansion[]>;
|
|
9
12
|
templateRoutes?: readonly TemplateRoute[];
|
|
10
13
|
};
|
|
11
14
|
type StaticPageRouteRendererFactory = PageRendererResolver;
|
|
@@ -81,7 +84,13 @@ export declare class StaticSiteGenerator {
|
|
|
81
84
|
private startStaticExports;
|
|
82
85
|
private releaseStaticExports;
|
|
83
86
|
private resetStaticGenerationState;
|
|
84
|
-
|
|
87
|
+
/**
|
|
88
|
+
* @remarks
|
|
89
|
+
* An empty `templateRoutes` array still emits explicit views, the Html shell,
|
|
90
|
+
* Layouts, and error pages. When the route source omits `templateRoutes`,
|
|
91
|
+
* listed Pages are used instead.
|
|
92
|
+
*/
|
|
93
|
+
private emitProductionServerModulesForStaticGeneration;
|
|
85
94
|
private executeStaticGenerationBody;
|
|
86
95
|
private finalizeStaticGenerationRun;
|
|
87
96
|
/**
|
|
@@ -96,9 +105,16 @@ export declare class StaticSiteGenerator {
|
|
|
96
105
|
force?: boolean;
|
|
97
106
|
keepGoing?: boolean;
|
|
98
107
|
}): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Loads each explicit static view, resolves its renderer and lists its pathnames.
|
|
110
|
+
*
|
|
111
|
+
* @remarks
|
|
112
|
+
* A view that fails here is recorded as a page failure and left out of both
|
|
113
|
+
* production browser-graph prebuild and generation.
|
|
114
|
+
*/
|
|
115
|
+
private prepareExplicitStaticRoutes;
|
|
99
116
|
private generateExplicitStaticPages;
|
|
100
117
|
private generateExplicitStaticRoute;
|
|
101
|
-
private planExplicitStaticRoute;
|
|
102
118
|
private createExplicitStaticContents;
|
|
103
119
|
private listExplicitStaticRouteEntries;
|
|
104
120
|
/**
|