@ecopages/core 0.7.1 → 0.9.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 +2 -2
- package/package.json +14 -4
- package/src/adapters/node/create-app.d.ts +1 -1
- package/src/adapters/node/create-app.js +1 -1
- package/src/adapters/node/server-adapter.d.ts +1 -0
- package/src/adapters/node/server-adapter.js +4 -1
- package/src/adapters/shared/hmr/hmr-manager.d.ts +2 -0
- package/src/adapters/shared/hmr/hmr-manager.js +8 -4
- package/src/adapters/shared/http/api-request-pipeline.d.ts +16 -3
- package/src/adapters/shared/http/api-request-pipeline.js +16 -11
- package/src/adapters/shared/http/explicit-static-route-matcher.js +8 -4
- package/src/adapters/shared/runtime/render-context.d.ts +2 -0
- package/src/adapters/shared/runtime/render-context.js +4 -0
- package/src/adapters/shared/runtime/server-request-pipeline.d.ts +2 -2
- package/src/adapters/shared/runtime/server-request-pipeline.js +4 -3
- package/src/adapters/shared/runtime/server-static-builder.js +4 -1
- package/src/adapters/shared/runtime/unattached-scripts.d.ts +17 -0
- package/src/adapters/shared/runtime/unattached-scripts.js +57 -0
- package/src/adapters/shared/ws/node-http-websocket-upgrades.js +3 -2
- package/src/adapters/shared/ws/ws-pattern-matcher.d.ts +14 -1
- package/src/adapters/shared/ws/ws-pattern-matcher.js +14 -13
- package/src/assets/app-browser-client-build.js +3 -0
- package/src/assets/asset-processing-service/asset-processing.service.d.ts +9 -0
- package/src/assets/asset-processing-service/asset-processing.service.js +19 -0
- package/src/assets/asset-processing-service/processed-asset-ledger.d.ts +16 -2
- package/src/assets/asset-processing-service/processed-asset-ledger.js +31 -3
- package/src/assets/asset-processing-service/processors/stylesheet/import-order.js +5 -3
- package/src/build/build-graph.d.ts +19 -2
- package/src/build/build-graph.js +19 -18
- package/src/build/cache/pages-unified-graph-build.d.ts +4 -6
- package/src/build/cache/pages-unified-graph-build.js +14 -51
- package/src/build/cache/server-module-entries.d.ts +5 -9
- package/src/build/cache/server-module-entries.js +5 -58
- package/src/build/contracts/build-contracts.d.ts +15 -0
- package/src/build/contracts.d.ts +1 -1
- package/src/build/contracts.js +1 -1
- package/src/build/production-asset-ledger.d.ts +1 -1
- package/src/build/production-asset-ledger.js +4 -2
- package/src/build/rolldown/file-role-grammar-plugin.d.ts +11 -0
- package/src/build/rolldown/file-role-grammar-plugin.js +32 -0
- package/src/build/rolldown/rolldown-adapter-helpers.d.ts +11 -0
- package/src/build/rolldown/rolldown-adapter-helpers.js +79 -10
- package/src/build/rolldown/ssr-script-entries-plugin.d.ts +31 -0
- package/src/build/rolldown/ssr-script-entries-plugin.js +104 -0
- package/src/build/server/server-modules-manifest.d.ts +6 -1
- package/src/build/server/server-modules-manifest.js +10 -1
- package/src/build/server/view-reference.d.ts +9 -0
- package/src/build/server/view-reference.js +11 -0
- package/src/build.d.ts +2 -1
- package/src/build.js +2 -1
- package/src/cli.d.ts +14 -0
- package/src/cli.js +14 -0
- package/src/config/assembly/app-runtime.d.ts +13 -0
- package/src/config/assembly/app-runtime.js +2 -0
- package/src/config/assembly/finalize-config.js +13 -8
- package/src/config/internal-types.d.ts +0 -12
- package/src/config/resolve-eco-config-path.d.ts +2 -0
- package/src/config/resolve-eco-config-path.js +2 -1
- package/src/config/server-config-bundle.d.ts +0 -1
- package/src/config/server-config-bundle.js +1 -1
- package/src/config/user-config-types.d.ts +0 -12
- package/src/dev/invalidation/development-invalidation.service.d.ts +0 -2
- package/src/dev/invalidation/development-invalidation.service.js +1 -11
- package/src/dev/transform-server/dev-transform-vendor-registry.js +33 -19
- package/src/eco/discovered-dependencies.d.ts +5 -0
- package/src/eco/discovered-dependencies.js +9 -0
- package/src/eco/eco.browser.js +5 -5
- package/src/eco/eco.js +24 -5
- package/src/eco/migration-docs.d.ts +7 -0
- package/src/eco/migration-docs.js +7 -0
- package/src/hmr/client/hmr-runtime.js +1 -1
- package/src/hmr/strategies/js-hmr-strategy.d.ts +0 -2
- package/src/hmr/strategies/server-rendered-template-hmr-strategy.d.ts +2 -1
- package/src/hmr/strategies/server-rendered-template-hmr-strategy.js +4 -3
- package/src/html/html-rewriter.d.ts +9 -7
- package/src/html/html-rewriter.js +26 -41
- package/src/html/html-transformer.service.d.ts +2 -2
- package/src/html/html-transformer.service.js +21 -15
- package/src/html-pages/html-page-module-scripts.js +2 -1
- package/src/html-pages/html-pages.plugin.d.ts +1 -1
- package/src/html-pages/html-pages.plugin.js +1 -1
- package/src/integration.d.ts +1 -1
- package/src/integration.js +1 -1
- package/src/islands/island-host.d.ts +16 -5
- package/src/islands/island-host.js +8 -1
- package/src/plugins/component-import-discovery.d.ts +14 -1
- package/src/plugins/component-import-discovery.js +36 -16
- package/src/plugins/eco-component-meta-plugin.d.ts +5 -0
- package/src/plugins/eco-component-meta-plugin.js +39 -22
- package/src/plugins/ecopages-virtual-imports.d.ts +15 -0
- package/src/plugins/ecopages-virtual-imports.js +25 -0
- package/src/plugins/integration-plugin.d.ts +1 -1
- package/src/plugins/integration-plugin.js +1 -1
- package/src/plugins/tsconfig-import-resolver.d.ts +2 -0
- package/src/plugins/tsconfig-import-resolver.js +7 -5
- package/src/route-renderer/error-pages/error-page-renderer.js +3 -2
- package/src/route-renderer/explicit-view-render-preparation.d.ts +10 -3
- package/src/route-renderer/explicit-view-render-preparation.js +14 -8
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +24 -9
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +73 -50
- package/src/route-renderer/orchestration/integration-renderer.d.ts +39 -10
- package/src/route-renderer/orchestration/integration-renderer.js +74 -38
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.d.ts +32 -11
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +68 -61
- package/src/route-renderer/page-declaration.d.ts +25 -0
- package/src/route-renderer/page-declaration.js +39 -0
- package/src/route-renderer/page-loading/component-declarations.d.ts +65 -0
- package/src/route-renderer/page-loading/component-declarations.js +77 -0
- package/src/route-renderer/page-loading/component-dependency-collection.d.ts +4 -16
- package/src/route-renderer/page-loading/component-dependency-collection.js +36 -105
- package/src/route-renderer/page-loading/declared-asset-collection.d.ts +19 -14
- package/src/route-renderer/page-loading/declared-asset-collection.js +66 -67
- package/src/route-renderer/page-loading/dependency-resolver.d.ts +18 -10
- package/src/route-renderer/page-loading/dependency-resolver.js +58 -99
- package/src/route-renderer/page-loading/lazy-entry-collection.d.ts +19 -26
- package/src/route-renderer/page-loading/lazy-entry-collection.js +53 -64
- package/src/route-renderer/page-loading/module-declaration-aggregation.d.ts +17 -3
- package/src/route-renderer/page-loading/module-declaration-aggregation.js +14 -13
- package/src/route-renderer/page-loading/page-module-loader.d.ts +10 -11
- package/src/route-renderer/page-loading/page-module-loader.js +30 -30
- package/src/router/server/pages-dir.d.ts +7 -0
- package/src/router/server/pages-dir.js +7 -0
- package/src/router/server/route-registry.d.ts +22 -10
- package/src/router/server/route-registry.js +54 -23
- package/src/router/server/segment-path-matcher.d.ts +29 -5
- package/src/router/server/segment-path-matcher.js +22 -19
- package/src/static-site-generator/production-page-browser-graph-prebuild.d.ts +2 -2
- package/src/static-site-generator/production-page-browser-graph-prebuild.js +5 -5
- package/src/static-site-generator/static-site-generator.d.ts +17 -1
- package/src/static-site-generator/static-site-generator.js +46 -12
- package/src/types/contracts.d.ts +28 -28
- package/src/types/eco-api-types.d.ts +17 -12
- package/src/types/public-types.d.ts +1 -1
- package/src/utils/file-roles.d.ts +48 -0
- package/src/utils/file-roles.js +85 -0
- package/src/utils/node-builtin.d.ts +10 -0
- package/src/utils/node-builtin.js +13 -0
- package/src/watchers/project-watcher.js +2 -2
- package/src/build/contracts/server-only-specifier.d.ts +0 -8
- package/src/build/contracts/server-only-specifier.js +0 -11
- package/src/route-renderer/orchestration/route-pipeline/marker-artifact.utils.d.ts +0 -5
- package/src/route-renderer/orchestration/route-pipeline/marker-artifact.utils.js +0 -11
- package/src/route-renderer/page-loading/ecopages-virtual-imports.d.ts +0 -12
- package/src/route-renderer/page-loading/ecopages-virtual-imports.js +0 -100
- package/src/utils/endpoint-file-extensions.d.ts +0 -11
- package/src/utils/endpoint-file-extensions.js +0 -13
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { getComponentOwner } from '../eco/component-identity.js';
|
|
2
2
|
import { ensureIntegrationRuntimeReady } from '../build/app-build-manifest-runtime.js';
|
|
3
|
+
import { assertViewDeclaredIn } from './page-declaration.js';
|
|
3
4
|
/**
|
|
4
|
-
* Resolves the renderer for one explicit view without reading its
|
|
5
|
+
* Resolves the renderer for one explicit view without reading its `props` hook.
|
|
5
6
|
*
|
|
6
7
|
* @remarks
|
|
7
|
-
* Static export planning calls this so a dynamic route whose `
|
|
8
|
+
* Static export planning calls this so a dynamic route whose `props`
|
|
8
9
|
* reads params is not invoked before a slug exists.
|
|
9
10
|
*/
|
|
10
11
|
export function resolveExplicitViewRenderer(input) {
|
|
12
|
+
if (input.declaredIn)
|
|
13
|
+
assertViewDeclaredIn(input.declaredIn.file, input.view, input.declaredIn.rootDir);
|
|
11
14
|
const integrationName = getComponentOwner(input.view);
|
|
12
15
|
if (!integrationName) {
|
|
13
16
|
throw new Error(input.errors.missingIntegration(input.routePath));
|
|
@@ -22,7 +25,7 @@ export function resolveExplicitViewRenderer(input) {
|
|
|
22
25
|
};
|
|
23
26
|
}
|
|
24
27
|
/**
|
|
25
|
-
* Resolves the renderer and
|
|
28
|
+
* Resolves the renderer and props needed to render one explicit static
|
|
26
29
|
* view at runtime or during static generation.
|
|
27
30
|
*/
|
|
28
31
|
export async function prepareExplicitStaticRender(input) {
|
|
@@ -33,13 +36,16 @@ export async function prepareExplicitStaticRender(input) {
|
|
|
33
36
|
integrationName,
|
|
34
37
|
});
|
|
35
38
|
}
|
|
36
|
-
const { renderer, view } = resolveExplicitViewRenderer(
|
|
37
|
-
|
|
38
|
-
?
|
|
39
|
-
|
|
39
|
+
const { renderer, view } = resolveExplicitViewRenderer({
|
|
40
|
+
...input,
|
|
41
|
+
declaredIn: input.viewFile ? { file: input.viewFile, rootDir: input.appConfig.rootDir } : undefined,
|
|
42
|
+
});
|
|
43
|
+
const props = input.view.props
|
|
44
|
+
? await input.view.props({
|
|
45
|
+
params: input.params,
|
|
40
46
|
appConfig: input.appConfig,
|
|
41
47
|
runtimeOrigin: input.runtimeOrigin,
|
|
42
|
-
})
|
|
48
|
+
})
|
|
43
49
|
: {};
|
|
44
50
|
return {
|
|
45
51
|
renderer,
|
package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts
CHANGED
|
@@ -35,8 +35,16 @@ export type QueuedForeignSubtreeChildRenderResult = {
|
|
|
35
35
|
html?: string;
|
|
36
36
|
children?: unknown;
|
|
37
37
|
};
|
|
38
|
-
/**
|
|
39
|
-
export type
|
|
38
|
+
/** Replaces every queued Foreign Subtree token in `html` with the subtree's markup. */
|
|
39
|
+
export type ResolveForeignSubtreeTokens = (html: string) => Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Renders the children of one queued foreign subtree inside the host renderer.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* Serialized children may hold tokens of Foreign Children queued in the same render; pass them through
|
|
45
|
+
* `resolveTokens`, since core does not scan the returned HTML again.
|
|
46
|
+
*/
|
|
47
|
+
export type RenderQueuedForeignSubtreeChildren<TContext extends QueuedForeignSubtreeResolutionContext> = (children: unknown, runtimeContext: TContext, resolveTokens: ResolveForeignSubtreeTokens) => Promise<QueuedForeignSubtreeChildRenderResult>;
|
|
40
48
|
export interface ForeignSubtreeExecutionOwningRenderer {
|
|
41
49
|
readonly name: string;
|
|
42
50
|
renderComponentWithForeignChildren(input: ComponentRenderInput): Promise<ComponentRenderResult>;
|
|
@@ -49,7 +57,6 @@ export interface ForeignSubtreeExecutionRenderOptions {
|
|
|
49
57
|
currentIntegrationName: string;
|
|
50
58
|
input: InternalComponentRenderInput;
|
|
51
59
|
renderComponent(input: ComponentRenderInput): Promise<ComponentRenderResult>;
|
|
52
|
-
normalizeComponentRenderOutput(result: ComponentRenderResult): ComponentRenderResult;
|
|
53
60
|
hasForeignChildDescendants(component: EcoComponent, foreignChildRoots?: ReadonlyArray<EcoComponent | Partial<EcoComponent>>): boolean;
|
|
54
61
|
createForeignChildRuntime(options: {
|
|
55
62
|
renderInput: ComponentRenderInput;
|
|
@@ -60,8 +67,8 @@ export interface ForeignSubtreeExecutionRenderOptions {
|
|
|
60
67
|
export interface ForeignSubtreeQueuedRuntimeOptions<TContext extends QueuedForeignSubtreeResolutionContext> {
|
|
61
68
|
renderInput: ComponentRenderInput;
|
|
62
69
|
rendererCache: Map<string, ForeignSubtreeExecutionOwningRenderer>;
|
|
63
|
-
|
|
64
|
-
|
|
70
|
+
/** The Integration whose render queues the tokens; it names the token prefix and the runtime context key. */
|
|
71
|
+
integrationName: string;
|
|
65
72
|
createRuntimeContext?: (integrationContext: BaseIntegrationContext & Record<string, unknown>, rendererCache: Map<string, unknown>) => TContext;
|
|
66
73
|
}
|
|
67
74
|
export interface ForeignSubtreeQueuedHtmlOptions<TContext extends QueuedForeignSubtreeResolutionContext> {
|
|
@@ -75,7 +82,8 @@ export type ForeignSubtreeStringQueuedHtmlOptions = Omit<ForeignSubtreeQueuedHtm
|
|
|
75
82
|
export interface ResolveQueuedForeignSubtreeTokensOptions<TContext extends QueuedForeignSubtreeResolutionContext> {
|
|
76
83
|
html: string;
|
|
77
84
|
runtimeContext?: TContext;
|
|
78
|
-
|
|
85
|
+
/** The Integration whose render queued the tokens; it names the token prefix and error messages. */
|
|
86
|
+
integrationName: string;
|
|
79
87
|
renderQueuedChildren: RenderQueuedForeignSubtreeChildren<TContext>;
|
|
80
88
|
resolveForeignSubtree: (input: ComponentRenderInput, rendererCache: Map<string, unknown>) => Promise<ComponentRenderResult | undefined>;
|
|
81
89
|
}
|
|
@@ -85,8 +93,7 @@ export declare function createQueuedRuntime<TContext extends QueuedForeignSubtre
|
|
|
85
93
|
export declare function createQueueRuntime<TContext extends QueuedForeignSubtreeResolutionContext>(options: {
|
|
86
94
|
renderInput: ComponentRenderInput;
|
|
87
95
|
rendererCache: Map<string, unknown>;
|
|
88
|
-
|
|
89
|
-
tokenPrefix: string;
|
|
96
|
+
integrationName: string;
|
|
90
97
|
shouldQueueForeignChild: (input: QueuedForeignChildDecisionInput) => boolean;
|
|
91
98
|
createRuntimeContext?: (integrationContext: QueuedForeignSubtreeIntegrationContext, rendererCache: Map<string, unknown>) => TContext;
|
|
92
99
|
}): ForeignChildRuntime;
|
|
@@ -101,6 +108,15 @@ export declare function getRuntimeContext<TContext extends QueuedForeignSubtreeR
|
|
|
101
108
|
*/
|
|
102
109
|
export declare function resolveStringQueuedHtml(options: ForeignSubtreeStringQueuedHtmlOptions): Promise<string>;
|
|
103
110
|
export declare function resolveQueuedHtml<TContext extends QueuedForeignSubtreeResolutionContext>(options: ForeignSubtreeQueuedHtmlOptions<TContext>): Promise<string>;
|
|
111
|
+
/**
|
|
112
|
+
* Places the Foreign Subtrees queued during one render over their tokens in `html`.
|
|
113
|
+
*
|
|
114
|
+
* @remarks
|
|
115
|
+
* The HTML is scanned once: each token is rendered by its owning renderer when the scan reaches it, its children
|
|
116
|
+
* first, and the owner's root attributes are set on the subtree's leading element. The subtree's markup is scanned
|
|
117
|
+
* the same way, since structured children can carry tokens of this render into the owner's output. A token that
|
|
118
|
+
* appears twice is rendered once. A subtree that reaches its own token again is a cycle and throws.
|
|
119
|
+
*/
|
|
104
120
|
export declare function resolveQueuedForeignSubtreeTokens<TContext extends QueuedForeignSubtreeResolutionContext>(options: ResolveQueuedForeignSubtreeTokensOptions<TContext>): Promise<string>;
|
|
105
121
|
/**
|
|
106
122
|
* Runs one component render under the current integration's render context and
|
|
@@ -111,5 +127,4 @@ export declare function resolveQueuedForeignSubtreeTokens<TContext extends Queue
|
|
|
111
127
|
* integration, even when no foreign-child runtime is installed.
|
|
112
128
|
*/
|
|
113
129
|
export declare function executeComponentRender(options: ForeignSubtreeExecutionRenderOptions): Promise<ComponentRenderResult>;
|
|
114
|
-
export declare function resolveQueuedTokens(html: string, queuedResolutionsByToken: Map<string, QueuedForeignSubtreeResolution>, resolveToken: (token: string) => Promise<string>): Promise<string>;
|
|
115
130
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { applyAttributesToFirstElement } from '../../../html/html-transformer.service.js';
|
|
2
|
+
import { getForeignSubtreeResolutionContextKey, getForeignSubtreeTokenPrefix } from './owning-renderer-resolution.js';
|
|
2
3
|
import { getComponentOwner } from '../../../eco/component-identity.js';
|
|
3
4
|
import { getComponentRenderContext, runWithComponentRenderContext, } from '../../../eco/component-render-context.js';
|
|
4
5
|
import { isMarkupNodeLike } from '../../../eco/component-render-output.js';
|
|
@@ -32,14 +33,17 @@ export function createQueuedRuntime(options) {
|
|
|
32
33
|
return createQueueRuntime({
|
|
33
34
|
renderInput: options.renderInput,
|
|
34
35
|
rendererCache: options.rendererCache,
|
|
35
|
-
|
|
36
|
-
tokenPrefix: options.tokenPrefix,
|
|
36
|
+
integrationName: options.integrationName,
|
|
37
37
|
shouldQueueForeignChild: (input) => shouldDelegateForeignChild(input),
|
|
38
38
|
createRuntimeContext: options.createRuntimeContext,
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
export function createQueueRuntime(options) {
|
|
42
|
-
const runtimeContext = ensureRuntimeContext(
|
|
42
|
+
const runtimeContext = ensureRuntimeContext({
|
|
43
|
+
...options,
|
|
44
|
+
runtimeContextKey: getForeignSubtreeResolutionContextKey(options.integrationName),
|
|
45
|
+
});
|
|
46
|
+
const tokenPrefix = getForeignSubtreeTokenPrefix(options.integrationName);
|
|
43
47
|
const interceptForeignChild = (input) => {
|
|
44
48
|
if (!options.shouldQueueForeignChild(input)) {
|
|
45
49
|
return {
|
|
@@ -52,7 +56,7 @@ export function createQueueRuntime(options) {
|
|
|
52
56
|
}
|
|
53
57
|
runtimeContext.nextForeignSubtreeId += 1;
|
|
54
58
|
const foreignSubtreeId = runtimeContext.nextForeignSubtreeId;
|
|
55
|
-
const token = createForeignSubtreeToken(
|
|
59
|
+
const token = createForeignSubtreeToken(tokenPrefix, runtimeContext, foreignSubtreeId);
|
|
56
60
|
runtimeContext.queuedResolutions.push({
|
|
57
61
|
token,
|
|
58
62
|
component: input.component,
|
|
@@ -90,7 +94,7 @@ export function getRuntimeContext(input, runtimeContextKey) {
|
|
|
90
94
|
export async function resolveStringQueuedHtml(options) {
|
|
91
95
|
return resolveQueuedHtml({
|
|
92
96
|
...options,
|
|
93
|
-
renderQueuedChildren: async (children, _runtimeContext,
|
|
97
|
+
renderQueuedChildren: async (children, _runtimeContext, resolveTokens) => {
|
|
94
98
|
if (children === undefined) {
|
|
95
99
|
return {};
|
|
96
100
|
}
|
|
@@ -98,8 +102,7 @@ export async function resolveStringQueuedHtml(options) {
|
|
|
98
102
|
assertForeignChildrenNotOpaque(children, options.currentIntegrationName);
|
|
99
103
|
return { children };
|
|
100
104
|
}
|
|
101
|
-
|
|
102
|
-
return { html };
|
|
105
|
+
return { html: await resolveTokens(typeof children === 'string' ? children : (children.outerHTML ?? '')) };
|
|
103
106
|
},
|
|
104
107
|
});
|
|
105
108
|
}
|
|
@@ -107,7 +110,7 @@ export async function resolveQueuedHtml(options) {
|
|
|
107
110
|
return resolveQueuedForeignSubtreeTokens({
|
|
108
111
|
html: options.html,
|
|
109
112
|
runtimeContext: options.runtimeContext,
|
|
110
|
-
|
|
113
|
+
integrationName: options.currentIntegrationName,
|
|
111
114
|
renderQueuedChildren: options.renderQueuedChildren,
|
|
112
115
|
resolveForeignSubtree: (input, rendererCache) => resolveForeignChildInOwningRenderer({
|
|
113
116
|
currentIntegrationName: options.currentIntegrationName,
|
|
@@ -117,38 +120,46 @@ export async function resolveQueuedHtml(options) {
|
|
|
117
120
|
}),
|
|
118
121
|
});
|
|
119
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Places the Foreign Subtrees queued during one render over their tokens in `html`.
|
|
125
|
+
*
|
|
126
|
+
* @remarks
|
|
127
|
+
* The HTML is scanned once: each token is rendered by its owning renderer when the scan reaches it, its children
|
|
128
|
+
* first, and the owner's root attributes are set on the subtree's leading element. The subtree's markup is scanned
|
|
129
|
+
* the same way, since structured children can carry tokens of this render into the owner's output. A token that
|
|
130
|
+
* appears twice is rendered once. A subtree that reaches its own token again is a cycle and throws.
|
|
131
|
+
*/
|
|
120
132
|
export async function resolveQueuedForeignSubtreeTokens(options) {
|
|
121
|
-
|
|
133
|
+
const runtimeContext = options.runtimeContext;
|
|
134
|
+
if (!runtimeContext || runtimeContext.queuedResolutions.length === 0) {
|
|
122
135
|
return options.html;
|
|
123
136
|
}
|
|
124
|
-
const
|
|
137
|
+
const tokenPrefix = getForeignSubtreeTokenPrefix(options.integrationName);
|
|
125
138
|
const queuedResolutionsByToken = new Map();
|
|
126
|
-
const
|
|
139
|
+
const placedHtmlByToken = new Map();
|
|
127
140
|
const resolvingTokens = new Set();
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
141
|
+
const findResolution = (token) => {
|
|
142
|
+
const queued = runtimeContext.queuedResolutions;
|
|
143
|
+
for (let index = queuedResolutionsByToken.size; index < queued.length; index += 1) {
|
|
144
|
+
queuedResolutionsByToken.set(queued[index].token, queued[index]);
|
|
133
145
|
}
|
|
146
|
+
return queuedResolutionsByToken.get(token);
|
|
134
147
|
};
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return cachedHtml;
|
|
148
|
+
const placeToken = async (token) => {
|
|
149
|
+
const placedHtml = placedHtmlByToken.get(token);
|
|
150
|
+
if (placedHtml !== undefined) {
|
|
151
|
+
return placedHtml;
|
|
140
152
|
}
|
|
141
|
-
const resolution =
|
|
153
|
+
const resolution = findResolution(token);
|
|
142
154
|
if (!resolution) {
|
|
143
|
-
return
|
|
155
|
+
return undefined;
|
|
144
156
|
}
|
|
145
157
|
if (resolvingTokens.has(token)) {
|
|
146
|
-
throw new Error(`[ecopages] ${options.
|
|
158
|
+
throw new Error(`[ecopages] ${options.integrationName} foreign-subtree queue contains a cycle or unresolved dependency links.`);
|
|
147
159
|
}
|
|
148
160
|
resolvingTokens.add(token);
|
|
149
161
|
try {
|
|
150
|
-
const renderedChildren = await options.renderQueuedChildren(resolution.props.children, runtimeContext,
|
|
151
|
-
syncQueuedResolutions();
|
|
162
|
+
const renderedChildren = await options.renderQueuedChildren(resolution.props.children, runtimeContext, resolveTokens);
|
|
152
163
|
const foreignSubtreeRender = await options.resolveForeignSubtree({
|
|
153
164
|
component: resolution.component,
|
|
154
165
|
props: { ...resolution.props },
|
|
@@ -159,28 +170,50 @@ export async function resolveQueuedForeignSubtreeTokens(options) {
|
|
|
159
170
|
},
|
|
160
171
|
}, runtimeContext.rendererCache);
|
|
161
172
|
if (!foreignSubtreeRender) {
|
|
162
|
-
throw new Error(`[ecopages] ${options.
|
|
173
|
+
throw new Error(`[ecopages] ${options.integrationName} queued foreign subtree could not resolve its owning renderer.`);
|
|
163
174
|
}
|
|
164
|
-
const
|
|
175
|
+
const stampedHtml = foreignSubtreeRender.canAttachAttributes && foreignSubtreeRender.rootAttributes
|
|
165
176
|
? applyAttributesToFirstElement(foreignSubtreeRender.html, foreignSubtreeRender.rootAttributes)
|
|
166
177
|
: foreignSubtreeRender.html;
|
|
167
|
-
|
|
168
|
-
|
|
178
|
+
const html = await resolveTokens(stampedHtml);
|
|
179
|
+
placedHtmlByToken.set(token, html);
|
|
180
|
+
return html;
|
|
169
181
|
}
|
|
170
182
|
finally {
|
|
171
183
|
resolvingTokens.delete(token);
|
|
172
184
|
}
|
|
173
185
|
};
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
186
|
+
const resolveTokens = (html) => spliceTokens(html, tokenPrefix, placeToken);
|
|
187
|
+
return resolveTokens(options.html);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Replaces each `tokenPrefix` token in `html` that `place` knows, in one pass.
|
|
191
|
+
*
|
|
192
|
+
* @remarks
|
|
193
|
+
* A token is `<prefix><scope>__<id>__`, and no scope contains `__` (see {@link createForeignSubtreeToken}). Text that
|
|
194
|
+
* starts like a token but that `place` does not know is kept as written.
|
|
195
|
+
*/
|
|
196
|
+
async function spliceTokens(html, tokenPrefix, place) {
|
|
197
|
+
let start = html.indexOf(tokenPrefix);
|
|
198
|
+
if (start === -1) {
|
|
199
|
+
return html;
|
|
200
|
+
}
|
|
201
|
+
let output = '';
|
|
202
|
+
let copied = 0;
|
|
203
|
+
while (start !== -1) {
|
|
204
|
+
const scopeEnd = html.indexOf('__', start + tokenPrefix.length);
|
|
205
|
+
const idEnd = scopeEnd === -1 ? -1 : html.indexOf('__', scopeEnd + 2);
|
|
206
|
+
const end = idEnd === -1 ? -1 : idEnd + 2;
|
|
207
|
+
const placed = end === -1 ? undefined : await place(html.slice(start, end));
|
|
208
|
+
if (placed === undefined) {
|
|
209
|
+
start = html.indexOf(tokenPrefix, start + tokenPrefix.length);
|
|
179
210
|
continue;
|
|
180
211
|
}
|
|
181
|
-
|
|
212
|
+
output += `${html.slice(copied, start)}${placed}`;
|
|
213
|
+
copied = end;
|
|
214
|
+
start = html.indexOf(tokenPrefix, end);
|
|
182
215
|
}
|
|
183
|
-
return
|
|
216
|
+
return `${output}${html.slice(copied)}`;
|
|
184
217
|
}
|
|
185
218
|
/**
|
|
186
219
|
* Runs one component render under the current integration's render context and
|
|
@@ -206,12 +239,12 @@ export async function executeComponentRender(options) {
|
|
|
206
239
|
const activeRenderContext = getComponentRenderContext();
|
|
207
240
|
if (!hasForeignChildren) {
|
|
208
241
|
if (activeRenderContext && activeRenderContext.currentIntegration === options.currentIntegrationName) {
|
|
209
|
-
return
|
|
242
|
+
return await options.renderComponent(options.input);
|
|
210
243
|
}
|
|
211
244
|
const sameIntegrationExecution = await runWithComponentRenderContext({
|
|
212
245
|
currentIntegration: options.currentIntegrationName,
|
|
213
246
|
}, async () => options.renderComponent(options.input));
|
|
214
|
-
return
|
|
247
|
+
return sameIntegrationExecution.value;
|
|
215
248
|
}
|
|
216
249
|
const execution = await runWithComponentRenderContext({
|
|
217
250
|
currentIntegration: options.currentIntegrationName,
|
|
@@ -220,7 +253,7 @@ export async function executeComponentRender(options) {
|
|
|
220
253
|
rendererCache,
|
|
221
254
|
}),
|
|
222
255
|
}, async () => options.renderComponent(options.input));
|
|
223
|
-
return
|
|
256
|
+
return execution.value;
|
|
224
257
|
}
|
|
225
258
|
function getRendererCache(integrationContext) {
|
|
226
259
|
if (integrationContext?.rendererCache instanceof Map) {
|
|
@@ -270,16 +303,6 @@ async function runInForeignOwningRenderer(options) {
|
|
|
270
303
|
children: delegatedChildren,
|
|
271
304
|
});
|
|
272
305
|
}
|
|
273
|
-
export async function resolveQueuedTokens(html, queuedResolutionsByToken, resolveToken) {
|
|
274
|
-
let resolvedHtml = html;
|
|
275
|
-
for (const token of queuedResolutionsByToken.keys()) {
|
|
276
|
-
if (!resolvedHtml.includes(token)) {
|
|
277
|
-
continue;
|
|
278
|
-
}
|
|
279
|
-
resolvedHtml = resolvedHtml.split(token).join(await resolveToken(token));
|
|
280
|
-
}
|
|
281
|
-
return resolvedHtml;
|
|
282
|
-
}
|
|
283
306
|
function createForeignSubtreeToken(tokenPrefix, runtimeContext, foreignSubtreeId) {
|
|
284
307
|
return `${tokenPrefix}${runtimeContext.componentInstanceScope ?? 'root'}__${foreignSubtreeId}__`;
|
|
285
308
|
}
|
|
@@ -150,7 +150,7 @@ export type PlannedRouteInstance = {
|
|
|
150
150
|
routeFile: string;
|
|
151
151
|
params?: RouteRendererOptions['params'];
|
|
152
152
|
query?: RouteRendererOptions['query'];
|
|
153
|
-
|
|
153
|
+
skipPropsHook?: RouteRendererOptions['skipPropsHook'];
|
|
154
154
|
isRouteTemplate?: boolean;
|
|
155
155
|
};
|
|
156
156
|
/** One renderer's production routes: what they need from the app-wide browser build, and how to prepare them. */
|
|
@@ -228,6 +228,25 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
228
228
|
* `getStaticPaths` or `getMetadata` fails here with an error that points to the codemod.
|
|
229
229
|
*/
|
|
230
230
|
loadPageModule(file: string, options?: RouteModuleLoadOptions): Promise<EcoPageFile>;
|
|
231
|
+
/**
|
|
232
|
+
* Imports a route module and fails unless it is a Page this Integration accepts.
|
|
233
|
+
*
|
|
234
|
+
* @remarks
|
|
235
|
+
* The legacy-export check runs first, so a module that still exports `getStaticProps` gets the codemod message.
|
|
236
|
+
*/
|
|
237
|
+
protected importRouteModule(file: string, options?: RouteModuleLoadOptions): Promise<EcoPageFile>;
|
|
238
|
+
/**
|
|
239
|
+
* Fails when the default export of a route module is not a Page that the file itself declares.
|
|
240
|
+
*
|
|
241
|
+
* @remarks
|
|
242
|
+
* A Page is a declared component whose build-time identity names this route file: an `eco.page()` result
|
|
243
|
+
* (also an HTML Page or an MDX module, which the Integration stamps the same way). The identity transform
|
|
244
|
+
* stamps the file that holds the literal `eco.page(...)` call, so a Page made by a wrapper in another file,
|
|
245
|
+
* or re-exported from one, names that other file and fails here. A function with a `config` that fails the
|
|
246
|
+
* check gets the literal-call message; anything else gets the not-a-Page message with the fixes.
|
|
247
|
+
* @throws When the module has no default export that is a Page declared in `file`.
|
|
248
|
+
*/
|
|
249
|
+
private assertPageModule;
|
|
231
250
|
setHmrManager(hmrManager: IHmrManager): void;
|
|
232
251
|
/**
|
|
233
252
|
* Build response headers with optional custom headers.
|
|
@@ -388,7 +407,7 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
388
407
|
preparedGraph?: true;
|
|
389
408
|
}): Promise<ProcessedAsset[]>;
|
|
390
409
|
getRouteHtmlFinalization(renderOptions: InternalIntegrationRendererRenderOptions<C>): RouteHtmlFinalization;
|
|
391
|
-
|
|
410
|
+
transformRouteHtml(html: string, htmlContributions: HtmlDocumentContribution[] | undefined, renderOptions: InternalIntegrationRendererRenderOptions<C>): Promise<RouteRendererBody>;
|
|
392
411
|
protected finalizeDocument(body: RouteRendererBody, renderOptions: IntegrationRendererRenderOptions<C>): Promise<RouteRendererBody> | RouteRendererBody;
|
|
393
412
|
resolveRouteRenderInputs(routeOptions: RouteRendererOptions, options?: {
|
|
394
413
|
skipMetadata?: boolean;
|
|
@@ -398,12 +417,25 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
398
417
|
ownerFile: string;
|
|
399
418
|
}): Promise<PageBrowserGraphContribution | undefined>;
|
|
400
419
|
resolvePageDependenciesForRoute(context: PageBrowserGraphContributionContext): Promise<ResolvedPageDependencies | undefined>;
|
|
401
|
-
/**
|
|
420
|
+
/**
|
|
421
|
+
* Resolves a route's component assets.
|
|
422
|
+
*
|
|
423
|
+
* @remarks `declarationOrder` returns them in the order the asset ledger records them, for a recorded shell.
|
|
424
|
+
*/
|
|
402
425
|
resolveRouteDependencies(input: {
|
|
403
426
|
components: (EcoComponent | Partial<EcoComponent>)[];
|
|
427
|
+
declarationOrder?: boolean;
|
|
404
428
|
}): Promise<{
|
|
405
429
|
resolvedDependencies: ProcessedAsset[];
|
|
406
430
|
}>;
|
|
431
|
+
/**
|
|
432
|
+
* Holds the lazy client entries of a route's shell components for the page client build.
|
|
433
|
+
*
|
|
434
|
+
* @remarks
|
|
435
|
+
* Processing the shell holds them as a side effect; a shell read from the asset ledger is not processed, so its
|
|
436
|
+
* lazy entries are collected here.
|
|
437
|
+
*/
|
|
438
|
+
prepareRouteLazyDependencies(components: (EcoComponent | Partial<EcoComponent>)[]): void;
|
|
407
439
|
renderRouteBody(renderOptions: InternalIntegrationRendererRenderOptions<C>): Promise<RouteRendererBody>;
|
|
408
440
|
/**
|
|
409
441
|
* Prepares the render options for the integration renderer.
|
|
@@ -420,9 +452,8 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
420
452
|
* Execution flow:
|
|
421
453
|
* 1. Build normalized render options (`prepareRenderOptions`).
|
|
422
454
|
* 2. Render the route body once.
|
|
423
|
-
* 3.
|
|
424
|
-
* 4.
|
|
425
|
-
* 5. Run HTML transformer with final dependency set.
|
|
455
|
+
* 3. Optionally apply document attributes for integration-owned document boundaries.
|
|
456
|
+
* 4. Run HTML transformer with final dependency set.
|
|
426
457
|
*
|
|
427
458
|
* Stream-safety note: the first render result is normalized to a string once,
|
|
428
459
|
* then the pipeline continues with that immutable HTML value to avoid disturbed
|
|
@@ -450,7 +481,7 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
450
481
|
*
|
|
451
482
|
* @remarks
|
|
452
483
|
* `file` is the view's identity file, or a stable synthetic key when the view has
|
|
453
|
-
* none. `props` are the view's final props: its `
|
|
484
|
+
* none. `props` are the view's final props: its `props` hook is the caller's
|
|
454
485
|
* to run, so it is not run here.
|
|
455
486
|
*/
|
|
456
487
|
executeExplicitView<P>(view: EcoComponent<P>, props: P, ctx?: Omit<ExplicitViewRenderContext, 'partial'>): Promise<RouteRenderResult>;
|
|
@@ -524,14 +555,12 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
524
555
|
*/
|
|
525
556
|
protected resolveQueuedForeignSubtrees<TContext extends QueuedForeignSubtreeResolutionContext>(html: string, runtimeContext: TContext | undefined, renderQueuedChildren: RenderQueuedForeignSubtreeChildren<TContext>): Promise<string>;
|
|
526
557
|
/**
|
|
527
|
-
* Stamps `result` as an Island Host when the component itself
|
|
558
|
+
* Stamps `result` as an Island Host when the component itself ships a client script.
|
|
528
559
|
*
|
|
529
560
|
* @remarks Reads the component's own declarations, excluding Foreign Children: a component without
|
|
530
561
|
* scripts that wraps an island is not an island itself. Components without `dependencies` are never stamped.
|
|
531
562
|
*/
|
|
532
563
|
protected finalizeIslandComponentRender(input: ComponentRenderInput, result: ComponentRenderResult): ComponentRenderResult;
|
|
533
|
-
private normalizeComponentRenderOutput;
|
|
534
|
-
protected normalizeUnresolvedMarkerArtifactHtml(html: string): string;
|
|
535
564
|
/**
|
|
536
565
|
* @remarks
|
|
537
566
|
* The active plan is the page owner's, but it answers for any renderer: a nested renderer of
|