@ecopages/core 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -14
- 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/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 +10 -10
- 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-manifest.d.ts +1 -3
- package/src/assets/app-browser-client-manifest.js +5 -58
- 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/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/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 +3 -1
- package/src/build.js +3 -1
- 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/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 +4 -0
- package/src/html-pages/html-page-renderer.js +9 -3
- 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 -1
- package/src/integration.js +1 -0
- 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 +33 -6
- package/src/plugins/integration-plugin.js +14 -2
- package/src/plugins/processor.d.ts +17 -0
- 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/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/integration-renderer.d.ts +1 -0
- package/src/route-renderer/orchestration/integration-renderer.js +17 -2
- 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/router/client/navigation-commit.js +16 -2
- package/src/router/client/navigation-head-order.fixture.css +3 -0
- package/src/router/client/navigation-head.d.ts +2 -1
- package/src/router/client/navigation-head.fixture.css +3 -0
- package/src/router/client/navigation-head.js +222 -39
- package/src/router/server/route-registry.d.ts +22 -2
- package/src/router/server/route-registry.js +39 -15
- 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 -9
- 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/contracts.d.ts +20 -31
- 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
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-wide server DOM installation for Integrations that render custom elements.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Lit and Radiant each need constructors on `globalThis`. Installing a complete
|
|
6
|
+
* surface after an incomplete one replaces `customElements` and drops defined
|
|
7
|
+
* elements. Core therefore runs every configured `complete` installer, then
|
|
8
|
+
* every `repair`, before Integration `setup()` continues. Config order does not
|
|
9
|
+
* change the result. Installers must be idempotent and must not replace an
|
|
10
|
+
* existing custom element registry.
|
|
11
|
+
*/
|
|
12
|
+
export type ServerDomSurfaceKind = 'complete' | 'repair';
|
|
13
|
+
export type ServerDomInstaller = {
|
|
14
|
+
kind: ServerDomSurfaceKind;
|
|
15
|
+
install: () => void | Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
export type ServerDomContributor = {
|
|
18
|
+
serverDom?: ServerDomInstaller;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Installs the configured server DOM surfaces, serializing concurrent callers.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* Complete surfaces run first, then repairs, regardless of Integration order.
|
|
25
|
+
* Each caller runs its own installers after the previous pass, so a second app
|
|
26
|
+
* that starts while the first is still installing is not skipped. Installers
|
|
27
|
+
* must be idempotent and must not replace an existing custom element registry.
|
|
28
|
+
*/
|
|
29
|
+
export declare function installConfiguredServerDom(integrations: ReadonlyArray<ServerDomContributor>): Promise<void>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-wide server DOM installation for Integrations that render custom elements.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Lit and Radiant each need constructors on `globalThis`. Installing a complete
|
|
6
|
+
* surface after an incomplete one replaces `customElements` and drops defined
|
|
7
|
+
* elements. Core therefore runs every configured `complete` installer, then
|
|
8
|
+
* every `repair`, before Integration `setup()` continues. Config order does not
|
|
9
|
+
* change the result. Installers must be idempotent and must not replace an
|
|
10
|
+
* existing custom element registry.
|
|
11
|
+
*/
|
|
12
|
+
let tail = Promise.resolve();
|
|
13
|
+
/**
|
|
14
|
+
* Installs the configured server DOM surfaces, serializing concurrent callers.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* Complete surfaces run first, then repairs, regardless of Integration order.
|
|
18
|
+
* Each caller runs its own installers after the previous pass, so a second app
|
|
19
|
+
* that starts while the first is still installing is not skipped. Installers
|
|
20
|
+
* must be idempotent and must not replace an existing custom element registry.
|
|
21
|
+
*/
|
|
22
|
+
export async function installConfiguredServerDom(integrations) {
|
|
23
|
+
const run = tail.then(() => runInstallers(integrations));
|
|
24
|
+
tail = run.then(() => undefined, () => undefined);
|
|
25
|
+
await run;
|
|
26
|
+
}
|
|
27
|
+
async function runInstallers(integrations) {
|
|
28
|
+
const installers = integrations
|
|
29
|
+
.map((integration) => integration.serverDom)
|
|
30
|
+
.filter((installer) => installer !== undefined);
|
|
31
|
+
const complete = installers.filter((installer) => installer.kind === 'complete');
|
|
32
|
+
const repair = installers.filter((installer) => installer.kind !== 'complete');
|
|
33
|
+
for (const installer of [...complete, ...repair]) {
|
|
34
|
+
await installer.install();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -15,10 +15,12 @@ export type ErrorPageRenderInput = {
|
|
|
15
15
|
* Owns error-page source precedence and rendering for runtime and static paths.
|
|
16
16
|
*
|
|
17
17
|
* @remarks
|
|
18
|
-
* Filesystem semantic pages win over explicitly registered views. A
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
18
|
+
* Filesystem semantic pages win over explicitly registered views. A recorded
|
|
19
|
+
* production server-modules entry counts as a filesystem source when the
|
|
20
|
+
* original file is gone. A missing custom source is the only case that uses a
|
|
21
|
+
* framework default; rendering failures are intentionally propagated so
|
|
22
|
+
* callers can apply their own retry or fallback policy without hiding the
|
|
23
|
+
* original failure.
|
|
22
24
|
*/
|
|
23
25
|
export declare class ErrorPageRenderer {
|
|
24
26
|
private readonly appConfig;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { fileSystem } from '@ecopages/file-system';
|
|
2
2
|
import { appLogger } from '../../global/app-logger.js';
|
|
3
3
|
import { ensureIntegrationRuntimeReady } from '../../build/app-build-manifest-runtime.js';
|
|
4
|
+
import { hasProductionServerModule } from '../../build/server/server-modules-manifest.js';
|
|
4
5
|
import { findIntegrationForFile } from '../../plugins/find-integration-for-file.js';
|
|
5
6
|
import { prepareExplicitStaticRender } from '../explicit-view-render-preparation.js';
|
|
6
7
|
import { ERROR_PAGE_STATUS_BY_KIND, kindForStatus } from '../../errors/http-error-page-contract.js';
|
|
@@ -20,10 +21,12 @@ function resolveRenderTarget(input) {
|
|
|
20
21
|
* Owns error-page source precedence and rendering for runtime and static paths.
|
|
21
22
|
*
|
|
22
23
|
* @remarks
|
|
23
|
-
* Filesystem semantic pages win over explicitly registered views. A
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* Filesystem semantic pages win over explicitly registered views. A recorded
|
|
25
|
+
* production server-modules entry counts as a filesystem source when the
|
|
26
|
+
* original file is gone. A missing custom source is the only case that uses a
|
|
27
|
+
* framework default; rendering failures are intentionally propagated so
|
|
28
|
+
* callers can apply their own retry or fallback policy without hiding the
|
|
29
|
+
* original failure.
|
|
27
30
|
*/
|
|
28
31
|
export class ErrorPageRenderer {
|
|
29
32
|
appConfig;
|
|
@@ -62,7 +65,8 @@ export class ErrorPageRenderer {
|
|
|
62
65
|
}
|
|
63
66
|
resolveCustomSource(kind) {
|
|
64
67
|
const templatePath = this.getTemplatePath(kind);
|
|
65
|
-
if (templatePath &&
|
|
68
|
+
if (templatePath &&
|
|
69
|
+
(fileSystem.exists(templatePath) || hasProductionServerModule(this.appConfig, templatePath))) {
|
|
66
70
|
return { kind: 'filesystem', templatePath };
|
|
67
71
|
}
|
|
68
72
|
const loader = this.loaders[kind];
|
|
@@ -455,6 +455,7 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
455
455
|
*/
|
|
456
456
|
buildPageClientBrowserAssets(plan: PageClientPlan, route?: Pick<RouteRendererOptions, 'file' | 'params' | 'query'>): Promise<PageClientBrowserAssets>;
|
|
457
457
|
private buildPrebuiltPageClientBrowserAssets;
|
|
458
|
+
private rejectUnplannedProductionPageClientGraph;
|
|
458
459
|
private resolvePrebuiltPageClientInstance;
|
|
459
460
|
private collectAppBrowserClientBuildEntries;
|
|
460
461
|
private prepareGraphLazyClientDependencies;
|
|
@@ -37,6 +37,7 @@ import { renderPageDocumentShell, } from './document-shell/document-shell-render
|
|
|
37
37
|
import { resolveInnermostPageLayout, resolvePageLayoutComponents, resolveDocumentShellLayouts, } from './document-shell/layout-shell-props.service.js';
|
|
38
38
|
import { finalizeIslandComponentRender } from '../../islands/island-host.js';
|
|
39
39
|
import { isProductionRuntime } from '../../utils/runtime.js';
|
|
40
|
+
import { describeProductionBrowserGraphEntry, missingProductionBrowserGraphError, shouldRejectUnplannedProductionBrowserGraph, } from './page-browser-graph/missing-production-browser-graph.js';
|
|
40
41
|
const syntheticExplicitViewKeys = new WeakMap();
|
|
41
42
|
let nextSyntheticExplicitViewKey = 0;
|
|
42
43
|
/**
|
|
@@ -980,8 +981,10 @@ export class IntegrationRenderer {
|
|
|
980
981
|
}
|
|
981
982
|
async buildPrebuiltPageClientBrowserAssets(plan, route) {
|
|
982
983
|
const prebuiltInstance = this.resolvePrebuiltPageClientInstance(route);
|
|
983
|
-
if (!prebuiltInstance)
|
|
984
|
+
if (!prebuiltInstance) {
|
|
985
|
+
await this.rejectUnplannedProductionPageClientGraph(plan, route);
|
|
984
986
|
return undefined;
|
|
987
|
+
}
|
|
985
988
|
const currentEntries = await this.collectAppBrowserClientBuildEntries(plan);
|
|
986
989
|
const plannedEntries = prebuiltInstance.pageClientBuildEntries ?? [];
|
|
987
990
|
const hasMatchingEntries = JSON.stringify(currentEntries
|
|
@@ -991,8 +994,12 @@ export class IntegrationRenderer {
|
|
|
991
994
|
.map((entry) => createAppBrowserClientEntryKey(entry.integrationName, entry.dependency))
|
|
992
995
|
.sort());
|
|
993
996
|
const prebuilt = hasMatchingEntries ? prebuiltInstance.prebuiltPageClientBrowserAssets : undefined;
|
|
994
|
-
if (!prebuilt)
|
|
997
|
+
if (!prebuilt) {
|
|
998
|
+
if (shouldRejectUnplannedProductionBrowserGraph(this.appConfig)) {
|
|
999
|
+
throw missingProductionBrowserGraphError(route.file, describeProductionBrowserGraphEntry(route.params));
|
|
1000
|
+
}
|
|
995
1001
|
return undefined;
|
|
1002
|
+
}
|
|
996
1003
|
const fallbackGroups = new Map();
|
|
997
1004
|
for (const { dependency, integrationName } of prebuilt.fallbackDependencies) {
|
|
998
1005
|
const dependencies = fallbackGroups.get(integrationName) ?? [];
|
|
@@ -1006,6 +1013,14 @@ export class IntegrationRenderer {
|
|
|
1006
1013
|
lazyTriggers: this.dependencyResolverService.applyPendingLazyTriggers(processedAssets, plan.lazyConfigs),
|
|
1007
1014
|
};
|
|
1008
1015
|
}
|
|
1016
|
+
async rejectUnplannedProductionPageClientGraph(plan, route) {
|
|
1017
|
+
if (!shouldRejectUnplannedProductionBrowserGraph(this.appConfig))
|
|
1018
|
+
return;
|
|
1019
|
+
const currentEntries = await this.collectAppBrowserClientBuildEntries(plan);
|
|
1020
|
+
if (currentEntries.length > 0 || this.integrationHooks.buildIslandClientAssets) {
|
|
1021
|
+
throw missingProductionBrowserGraphError(route.file, describeProductionBrowserGraphEntry(route.params));
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1009
1024
|
resolvePrebuiltPageClientInstance(route) {
|
|
1010
1025
|
const routeKey = createPrebuiltRoutePreparationKey(route);
|
|
1011
1026
|
const exact = this.prebuiltPageClientBrowserAssets.get(routeKey);
|
package/src/route-renderer/orchestration/page-browser-graph/missing-production-browser-graph.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { EcoPagesAppConfig } from '../../../config/internal-types.js';
|
|
2
|
+
import type { PageParams } from '../../../types/contracts.js';
|
|
3
|
+
/**
|
|
4
|
+
* Formats the `entry …` label for {@link missingProductionBrowserGraphError}.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Prefers Params when present. Otherwise formats the instance key next to its serializer.
|
|
8
|
+
*/
|
|
9
|
+
export declare function describeProductionBrowserGraphEntry(params?: PageParams, dependencyInstanceKey?: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Returns whether production serving must reject a Page Browser Graph that was not built.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* True only after `ecopages start` restores the browser client manifest. Static export still
|
|
15
|
+
* builds a graph while writing HTML, including Lit workers that never load that manifest.
|
|
16
|
+
*/
|
|
17
|
+
export declare function shouldRejectUnplannedProductionBrowserGraph(appConfig: EcoPagesAppConfig): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Error for a production request whose Page Browser Graph was not built by `ecopages build`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function missingProductionBrowserGraphError(routeFile: string, entry: string): Error;
|
package/src/route-renderer/orchestration/page-browser-graph/missing-production-browser-graph.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { isProductionRuntime } from '../../../utils/runtime.js';
|
|
2
|
+
import { requireAppRuntime } from '../../../utils/app-runtime.js';
|
|
3
|
+
import { describePageDependencyInstance, describePageDependencyInstanceKey } from './route-instance-key.js';
|
|
4
|
+
/**
|
|
5
|
+
* Formats the `entry …` label for {@link missingProductionBrowserGraphError}.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Prefers Params when present. Otherwise formats the instance key next to its serializer.
|
|
9
|
+
*/
|
|
10
|
+
export function describeProductionBrowserGraphEntry(params, dependencyInstanceKey) {
|
|
11
|
+
if (params && Object.keys(params).length > 0) {
|
|
12
|
+
return describePageDependencyInstance({ params });
|
|
13
|
+
}
|
|
14
|
+
return describePageDependencyInstanceKey(dependencyInstanceKey ?? '');
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Returns whether production serving must reject a Page Browser Graph that was not built.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* True only after `ecopages start` restores the browser client manifest. Static export still
|
|
21
|
+
* builds a graph while writing HTML, including Lit workers that never load that manifest.
|
|
22
|
+
*/
|
|
23
|
+
export function shouldRejectUnplannedProductionBrowserGraph(appConfig) {
|
|
24
|
+
return isProductionRuntime() && requireAppRuntime(appConfig).productionBrowserGraphsSealed;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Error for a production request whose Page Browser Graph was not built by `ecopages build`.
|
|
28
|
+
*/
|
|
29
|
+
export function missingProductionBrowserGraphError(routeFile, entry) {
|
|
30
|
+
return new Error(`The production Page Browser Graph for ${routeFile} is missing from the manifest (entry ${entry}). Run \`ecopages build\` again.`);
|
|
31
|
+
}
|
|
@@ -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
|
*/
|
|
@@ -2,6 +2,10 @@ import { completeNavigationLifecycle, dispatchBeforeSwap } from './navigation-li
|
|
|
2
2
|
import { activatePreparedNavigationScripts, prepareNavigationHead, } from './navigation-head.js';
|
|
3
3
|
import { runNavigationViewTransition } from './navigation-view-transition.js';
|
|
4
4
|
import { ECO_PERSIST_ATTRIBUTE } from '../../client/navigation-attributes.js';
|
|
5
|
+
async function requestReload(input) {
|
|
6
|
+
await input.onReloadRequested?.();
|
|
7
|
+
return input.isStale() ? 'stale' : 'reload-requested';
|
|
8
|
+
}
|
|
5
9
|
/** Runs shared document work around the router-specific page swap. */
|
|
6
10
|
export async function commitNavigationPage(input) {
|
|
7
11
|
let headUpdate = null;
|
|
@@ -14,20 +18,28 @@ export async function commitNavigationPage(input) {
|
|
|
14
18
|
if (input.isStale())
|
|
15
19
|
return 'stale';
|
|
16
20
|
if (requestedReload) {
|
|
17
|
-
await input
|
|
18
|
-
return input.isStale() ? 'stale' : 'reload-requested';
|
|
21
|
+
return await requestReload(input);
|
|
19
22
|
}
|
|
20
23
|
const preparedHeadUpdate = await prepareNavigationHead(input.newDocument, input.persistAttribute ?? ECO_PERSIST_ATTRIBUTE, input.skipScriptActivation);
|
|
21
24
|
headUpdate = preparedHeadUpdate;
|
|
22
25
|
if (input.isStale())
|
|
23
26
|
return 'stale';
|
|
27
|
+
if (preparedHeadUpdate.requiresReload) {
|
|
28
|
+
return await requestReload(input);
|
|
29
|
+
}
|
|
24
30
|
await input.beforeTransition?.();
|
|
25
31
|
if (input.isStale())
|
|
26
32
|
return 'stale';
|
|
27
33
|
let committed = false;
|
|
34
|
+
let reloadRequested = false;
|
|
28
35
|
await runNavigationViewTransition(async () => {
|
|
29
36
|
if (input.isStale())
|
|
30
37
|
return false;
|
|
38
|
+
if (preparedHeadUpdate.requiresReload) {
|
|
39
|
+
reloadRequested = true;
|
|
40
|
+
await requestReload(input);
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
31
43
|
input.beforeCommit?.();
|
|
32
44
|
if (input.isStale())
|
|
33
45
|
return false;
|
|
@@ -45,6 +57,8 @@ export async function commitNavigationPage(input) {
|
|
|
45
57
|
committed = true;
|
|
46
58
|
return true;
|
|
47
59
|
}, { enabled: input.viewTransitionsEnabled, incomingDocument: input.newDocument });
|
|
60
|
+
if (reloadRequested)
|
|
61
|
+
return input.isStale() ? 'stale' : 'reload-requested';
|
|
48
62
|
if (input.isStale() || !committed)
|
|
49
63
|
return 'stale';
|
|
50
64
|
completeNavigationLifecycle(document, { url: input.url, direction: input.direction }, { isStale: input.isStale });
|
|
@@ -2,11 +2,12 @@ import { type ScriptActivation } from '../../client/navigation-scripts/activatio
|
|
|
2
2
|
export type NavigationHeadUpdate = {
|
|
3
3
|
scriptActivations: ScriptActivation[];
|
|
4
4
|
rerunScriptActivations: ScriptActivation[];
|
|
5
|
+
requiresReload: boolean;
|
|
5
6
|
commit(): void;
|
|
6
7
|
cancel(): void;
|
|
7
8
|
};
|
|
8
9
|
/**
|
|
9
|
-
* Stages incoming stylesheets and prepares one diff for either router to commit.
|
|
10
|
+
* Stages incoming stylesheets without applying them and prepares one diff for either router to commit.
|
|
10
11
|
*/
|
|
11
12
|
export declare function prepareNavigationHead(newDocument: Document, persistAttribute?: string, shouldSkipScriptActivation?: (script: HTMLScriptElement) => boolean): Promise<NavigationHeadUpdate>;
|
|
12
13
|
/** Starts the shared head and body script queue after an adapter has swapped its page. */
|