@ecopages/core 0.2.0-rc.9 → 0.2.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 +39 -38
- package/package.json +22 -152
- package/src/adapters/README.md +11 -3
- package/src/adapters/abstract/application-adapter.d.ts +32 -36
- package/src/adapters/abstract/application-adapter.js +61 -47
- package/src/adapters/abstract/server-adapter.d.ts +14 -0
- package/src/adapters/abstract/server-adapter.js +10 -0
- package/src/adapters/abstract/ws-pattern-matcher.d.ts +0 -5
- package/src/adapters/abstract/ws-pattern-matcher.js +0 -9
- package/src/adapters/bun/create-app.d.ts +12 -16
- package/src/adapters/bun/create-app.js +25 -55
- package/src/adapters/bun/hmr-manager.d.ts +0 -1
- package/src/adapters/bun/hmr-manager.js +2 -4
- package/src/adapters/bun/server-adapter.d.ts +15 -21
- package/src/adapters/bun/server-adapter.js +33 -67
- package/src/adapters/bun/static-preview-host.d.ts +1 -0
- package/src/adapters/bun/static-preview-host.js +1 -1
- package/src/adapters/create-app.d.ts +63 -8
- package/src/adapters/create-app.js +62 -5
- package/src/adapters/node/create-app.d.ts +8 -12
- package/src/adapters/node/create-app.js +22 -14
- package/src/adapters/node/runtime-host.d.ts +10 -10
- package/src/adapters/node/runtime-host.js +13 -8
- package/src/adapters/node/server-adapter-dependencies.d.ts +2 -10
- package/src/adapters/node/server-adapter-dependencies.js +8 -13
- package/src/adapters/node/server-adapter.d.ts +30 -32
- package/src/adapters/node/server-adapter.js +59 -65
- package/src/adapters/shared/hmr/shared-hmr-manager.d.ts +0 -4
- package/src/adapters/shared/hmr/shared-hmr-manager.js +0 -12
- package/src/adapters/shared/http/api-request-pipeline.d.ts +27 -1
- package/src/adapters/shared/http/api-request-pipeline.js +31 -16
- package/src/adapters/shared/http/explicit-static-route-matcher.js +5 -2
- package/src/adapters/shared/http/fs-server-response-factory.d.ts +2 -9
- package/src/adapters/shared/http/fs-server-response-factory.js +5 -33
- package/src/adapters/shared/http/fs-server-response-matcher.d.ts +24 -24
- package/src/adapters/shared/http/fs-server-response-matcher.js +59 -83
- package/src/adapters/shared/runtime/application-adapter.d.ts +1 -0
- package/src/adapters/shared/runtime/application-adapter.js +12 -0
- package/src/adapters/shared/runtime/bind-runtime-server.d.ts +17 -0
- package/src/adapters/shared/runtime/bind-runtime-server.js +50 -0
- package/src/adapters/shared/runtime/collect-dev-prewarm-plan.d.ts +1 -3
- package/src/adapters/shared/runtime/collect-dev-prewarm-plan.js +1 -4
- package/src/adapters/shared/runtime/port-manager-default-prompt.d.ts +6 -0
- package/src/adapters/shared/runtime/port-manager-default-prompt.js +41 -0
- package/src/adapters/shared/runtime/port-manager.d.ts +3 -3
- package/src/adapters/shared/runtime/port-manager.js +14 -45
- package/src/adapters/shared/runtime/runtime-app-bootstrap.d.ts +0 -10
- package/src/adapters/shared/runtime/runtime-app-bootstrap.js +0 -7
- package/src/adapters/shared/runtime/runtime-host.d.ts +5 -2
- package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +1 -1
- package/src/adapters/shared/runtime/runtime-server-lifecycle.js +1 -1
- package/src/adapters/shared/runtime/server-adapter.d.ts +26 -5
- package/src/adapters/shared/runtime/server-adapter.js +35 -8
- package/src/adapters/shared/runtime/server-route-handler.js +11 -3
- package/src/adapters/shared/runtime/server-static-builder.d.ts +9 -3
- package/src/adapters/shared/runtime/server-static-builder.js +59 -37
- package/src/adapters/shared/ws/node-http-websocket-upgrades.d.ts +9 -1
- package/src/adapters/shared/ws/node-http-websocket-upgrades.js +8 -2
- package/src/build/README.md +12 -8
- package/src/build/cache/cache-constants.d.ts +0 -2
- package/src/build/cache/cache-constants.js +0 -2
- package/src/build/cache/cache-keys.d.ts +0 -2
- package/src/build/cache/cache-keys.js +0 -2
- package/src/build/cache/output-imports.d.ts +35 -0
- package/src/build/cache/output-imports.js +87 -0
- package/src/build/cache/pages-unified-graph-build.d.ts +15 -1
- package/src/build/cache/pages-unified-graph-build.js +73 -22
- package/src/build/cache/production-build-cache.d.ts +2 -2
- package/src/build/cache/production-build-cache.js +2 -2
- package/src/build/cache/server-entry-build-cache.d.ts +25 -3
- package/src/build/cache/server-entry-build-cache.js +129 -13
- package/src/build/contracts/build-contracts.d.ts +1 -13
- package/src/build/rolldown/runtime-build-output-normalizer.js +3 -6
- package/src/build/runtime/build-request-identity.d.ts +2 -6
- package/src/build/runtime/build-request-identity.js +2 -8
- package/src/build/runtime/build-request-policy.js +1 -1
- package/src/build/runtime/deduping-build-executor.d.ts +0 -1
- package/src/build/runtime/deduping-build-executor.js +0 -1
- package/src/build/server-bundle-publication.d.ts +14 -0
- package/src/build/server-bundle-publication.js +49 -0
- package/src/cache/index.d.ts +1 -1
- package/src/cache/index.js +1 -1
- package/src/cache/module-parse-cache.d.ts +2 -29
- package/src/cache/module-parse-cache.js +6 -39
- package/src/config/README.md +17 -2
- package/src/config/apply-user-config.d.ts +8 -0
- package/src/config/apply-user-config.js +68 -0
- package/src/config/config-builder.d.ts +11 -1
- package/src/config/config-builder.js +53 -12
- package/src/config/constants.d.ts +4 -4
- package/src/config/constants.js +4 -4
- package/src/config/define-config.d.ts +9 -0
- package/src/config/define-config.js +10 -0
- package/src/config/index.d.ts +5 -0
- package/src/config/index.js +4 -0
- package/src/config/is-finalized-app-config.d.ts +6 -0
- package/src/config/is-finalized-app-config.js +11 -0
- package/src/config/load-eco-config.d.ts +21 -0
- package/src/config/load-eco-config.js +107 -0
- package/src/config/resolve-eco-config-path.d.ts +32 -0
- package/src/config/resolve-eco-config-path.js +58 -0
- package/src/config/server-config-bundle.d.ts +25 -0
- package/src/config/server-config-bundle.js +148 -0
- package/src/config/user-config-types.d.ts +170 -0
- package/src/config/user-config-types.js +1 -0
- package/src/dev/README.md +4 -0
- package/src/dev/development-restart-watch-paths.d.ts +13 -0
- package/src/dev/development-restart-watch-paths.js +37 -0
- package/src/dev/development-restart.d.ts +13 -0
- package/src/dev/development-restart.js +21 -0
- package/src/dev/host-runtime.d.ts +0 -1
- package/src/dev/host-runtime.js +0 -3
- package/src/dev/sc-server.d.ts +4 -1
- package/src/dev/sc-server.js +11 -20
- package/src/dev/transform-server/dev-transform-import-rewriter.js +2 -2
- package/src/eco/eco.js +4 -0
- package/src/errors/http-error-page-contract.d.ts +77 -0
- package/src/errors/http-error-page-contract.js +106 -0
- package/src/hmr/hmr-file-change-prep.d.ts +0 -1
- package/src/hmr/hmr-file-change-prep.js +2 -5
- package/src/hmr/hmr-strategy.d.ts +3 -8
- package/src/hmr/hmr-strategy.js +3 -8
- package/src/index.browser.d.ts +1 -2
- package/src/index.browser.js +1 -2
- package/src/index.d.ts +5 -6
- package/src/index.js +5 -6
- package/src/islands/island-host.d.ts +0 -9
- package/src/islands/island-host.js +1 -13
- package/src/plugins/component-import-discovery.js +2 -2
- package/src/plugins/eco-component-meta-plugin.js +5 -5
- package/src/plugins/integration-plugin.d.ts +0 -1
- package/src/plugins/integration-plugin.js +0 -4
- package/src/plugins/processor.d.ts +6 -2
- package/src/route-renderer/README.md +4 -0
- package/src/{adapters/shared/http/explicit-static-render-preparation.d.ts → route-renderer/explicit-view-render-preparation.d.ts} +3 -3
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +1 -4
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +25 -24
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +18 -20
- package/src/route-renderer/orchestration/integration-renderer.d.ts +24 -7
- package/src/route-renderer/orchestration/integration-renderer.js +44 -33
- package/src/route-renderer/orchestration/integration-renderer.test-fixtures.js +1 -1
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +1 -1
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +1 -1
- package/src/route-renderer/route-renderer.d.ts +9 -0
- package/src/route-renderer/route-renderer.js +18 -0
- package/src/services/README.md +2 -1
- package/src/services/assets/browser-bundle.service.d.ts +1 -6
- package/src/services/error-pages/README.md +9 -0
- package/src/services/error-pages/default-error-pages.d.ts +39 -0
- package/src/services/error-pages/default-error-pages.js +199 -0
- package/src/services/error-pages/error-page-renderer.d.ts +58 -0
- package/src/services/error-pages/error-page-renderer.js +146 -0
- package/src/services/error-pages/semantic-error-page-exporter.d.ts +23 -0
- package/src/services/error-pages/semantic-error-page-exporter.js +35 -0
- package/src/services/html/html-rewriter.d.ts +77 -0
- package/src/services/html/html-rewriter.js +751 -0
- package/src/services/html/html-rewriter.parity.test.bun.d.ts +1 -0
- package/src/services/html/html-rewriter.parity.test.bun.js +74 -0
- package/src/services/html/html-transformer.service.d.ts +29 -42
- package/src/services/html/html-transformer.service.js +85 -157
- package/src/services/invalidation/development-invalidation.service.d.ts +9 -20
- package/src/services/invalidation/development-invalidation.service.js +26 -39
- package/src/services/module-loading/README.md +20 -15
- package/src/services/module-loading/app-module-loader.service.d.ts +0 -2
- package/src/services/module-loading/app-server-module-transpiler.service.d.ts +1 -1
- package/src/services/module-loading/app-server-module-transpiler.service.js +2 -10
- package/src/services/module-loading/collection-server-module-build.service.d.ts +0 -1
- package/src/services/module-loading/collection-server-module-build.service.js +0 -3
- package/src/services/module-loading/host-module-loader-registry.d.ts +0 -1
- package/src/services/module-loading/host-module-loader-registry.js +0 -3
- package/src/services/module-loading/route-module-build-cache-registry.d.ts +0 -4
- package/src/services/module-loading/route-module-build-cache-registry.js +0 -4
- package/src/services/module-loading/route-module-build-cache.store.d.ts +8 -0
- package/src/services/module-loading/route-module-build-cache.store.js +25 -7
- package/src/services/module-loading/route-module-build-manifest.d.ts +12 -1
- package/src/services/module-loading/route-module-build-manifest.js +7 -3
- package/src/services/module-loading/route-module-dependency-hasher.d.ts +3 -2
- package/src/services/module-loading/route-module-dependency-hasher.js +13 -1
- package/src/services/module-loading/server-module-transpiler.service.d.ts +1 -15
- package/src/services/module-loading/server-module-transpiler.service.js +0 -24
- package/src/services/module-loading/view-module-loader.d.ts +10 -0
- package/src/services/module-loading/view-module-loader.js +46 -0
- package/src/services/runtime-state/entrypoint-dependency-graph.service.js +0 -12
- package/src/services/runtime-state/server-invalidation-state.service.d.ts +4 -2
- package/src/services/runtime-state/server-invalidation-state.service.js +7 -14
- package/src/static-site-generator/README.md +12 -8
- package/src/static-site-generator/static-site-generator.d.ts +3 -2
- package/src/static-site-generator/static-site-generator.js +17 -3
- package/src/types/internal-types.d.ts +1 -38
- package/src/types/public-types.d.ts +28 -130
- package/src/watchers/project-watcher.d.ts +9 -16
- package/src/watchers/project-watcher.js +35 -28
- package/src/watchers/project-watcher.test-helpers.d.ts +10 -1
- package/src/watchers/project-watcher.test-helpers.js +12 -0
- package/src/adapters/abstract/router-adapter.d.ts +0 -26
- package/src/adapters/abstract/router-adapter.js +0 -13
- package/src/adapters/bun/index.d.ts +0 -2
- package/src/adapters/bun/index.js +0 -2
- package/src/adapters/index.d.ts +0 -2
- package/src/adapters/index.js +0 -2
- package/src/eco/eco.utils.d.ts +0 -1
- package/src/eco/eco.utils.js +0 -1
- package/src/services/cache/index.d.ts +0 -9
- package/src/services/cache/index.js +0 -8
- package/src/services/html/html-rewriter-provider.service.d.ts +0 -40
- package/src/services/html/html-rewriter-provider.service.js +0 -68
- package/src/services/module-loading/route-module-build-cache.d.ts +0 -4
- package/src/services/module-loading/route-module-build-cache.js +0 -3
- package/src/services/runtime-state/dev-graph.service.d.ts +0 -118
- package/src/services/runtime-state/dev-graph.service.js +0 -170
- /package/src/{adapters/shared/http/explicit-static-render-preparation.js → route-renderer/explicit-view-render-preparation.js} +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { HttpError } from './http-error.js';
|
|
2
|
+
/**
|
|
3
|
+
* HTTP statuses that own a semantic HTML error page (`pages/{status}.*` and
|
|
4
|
+
* matching `app.*()` loaders).
|
|
5
|
+
*/
|
|
6
|
+
export const HTTP_ERROR_PAGE_STATUSES = [400, 401, 403, 404, 409, 500];
|
|
7
|
+
export const ERROR_PAGE_KIND_BY_STATUS = {
|
|
8
|
+
400: 'badRequest',
|
|
9
|
+
401: 'unauthorized',
|
|
10
|
+
403: 'forbidden',
|
|
11
|
+
404: 'notFound',
|
|
12
|
+
409: 'conflict',
|
|
13
|
+
500: 'serverError',
|
|
14
|
+
};
|
|
15
|
+
export const ERROR_PAGE_STATUS_BY_KIND = {
|
|
16
|
+
badRequest: 400,
|
|
17
|
+
unauthorized: 401,
|
|
18
|
+
forbidden: 403,
|
|
19
|
+
notFound: 404,
|
|
20
|
+
conflict: 409,
|
|
21
|
+
serverError: 500,
|
|
22
|
+
};
|
|
23
|
+
export const SEMANTIC_ERROR_PAGE_PATHNAMES = HTTP_ERROR_PAGE_STATUSES.map((status) => `/${status}`);
|
|
24
|
+
/**
|
|
25
|
+
* Built-in copy and CSS modifier suffix for each semantic HTML error page.
|
|
26
|
+
*/
|
|
27
|
+
export const ERROR_PAGE_COPY = {
|
|
28
|
+
400: {
|
|
29
|
+
title: 'Bad Request',
|
|
30
|
+
message: 'The request could not be understood.',
|
|
31
|
+
modifier: 'bad-request',
|
|
32
|
+
},
|
|
33
|
+
401: {
|
|
34
|
+
title: 'Unauthorized',
|
|
35
|
+
message: 'Authentication is required to access this page.',
|
|
36
|
+
modifier: 'unauthorized',
|
|
37
|
+
},
|
|
38
|
+
403: {
|
|
39
|
+
title: 'Forbidden',
|
|
40
|
+
message: 'You do not have permission to access this page.',
|
|
41
|
+
modifier: 'forbidden',
|
|
42
|
+
},
|
|
43
|
+
404: {
|
|
44
|
+
title: 'Not Found',
|
|
45
|
+
message: 'The page you requested could not be found.',
|
|
46
|
+
modifier: 'not-found',
|
|
47
|
+
},
|
|
48
|
+
409: {
|
|
49
|
+
title: 'Conflict',
|
|
50
|
+
message: 'The request could not be completed due to a conflict.',
|
|
51
|
+
modifier: 'conflict',
|
|
52
|
+
},
|
|
53
|
+
500: {
|
|
54
|
+
title: 'Something went wrong',
|
|
55
|
+
message: 'An error occurred while handling this request.',
|
|
56
|
+
modifier: 'server-error',
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
export function isHttpErrorPageStatus(status) {
|
|
60
|
+
return HTTP_ERROR_PAGE_STATUSES.includes(status);
|
|
61
|
+
}
|
|
62
|
+
export function isHttpErrorStatus(status) {
|
|
63
|
+
return Number.isInteger(status) && status >= 400 && status <= 599;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Resolves the semantic page kind for an HTTP status.
|
|
67
|
+
*
|
|
68
|
+
* @remarks
|
|
69
|
+
* Factory statuses map 1:1. Other 5xx statuses reuse the server-error page
|
|
70
|
+
* with the original status. Other 4xx statuses have no custom page and use a
|
|
71
|
+
* built-in document.
|
|
72
|
+
*/
|
|
73
|
+
export function kindForStatus(status) {
|
|
74
|
+
if (isHttpErrorPageStatus(status)) {
|
|
75
|
+
return ERROR_PAGE_KIND_BY_STATUS[status];
|
|
76
|
+
}
|
|
77
|
+
if (status >= 500 && status <= 599) {
|
|
78
|
+
return 'serverError';
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
export function classifyPageFailure(error) {
|
|
83
|
+
if (error instanceof Response) {
|
|
84
|
+
return {
|
|
85
|
+
status: error.status,
|
|
86
|
+
kind: kindForStatus(error.status),
|
|
87
|
+
logAsServerError: error.status >= 500,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
if (HttpError.isHttpError(error)) {
|
|
91
|
+
const status = isHttpErrorStatus(error.status) ? error.status : 500;
|
|
92
|
+
return {
|
|
93
|
+
status,
|
|
94
|
+
kind: kindForStatus(status),
|
|
95
|
+
logAsServerError: status >= 500,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
status: 500,
|
|
100
|
+
kind: 'serverError',
|
|
101
|
+
logAsServerError: true,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export function shouldLogPageFailure(error) {
|
|
105
|
+
return classifyPageFailure(error).logAsServerError;
|
|
106
|
+
}
|
|
@@ -2,7 +2,6 @@ import type { EcoPagesAppConfig } from '../types/internal-types.js';
|
|
|
2
2
|
import { type AffectedGraphIdentity } from '../route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js';
|
|
3
3
|
export type HmrFileChangePreparation = {
|
|
4
4
|
affectedGraphIdentities: AffectedGraphIdentity[];
|
|
5
|
-
invalidatedGraphCount: number;
|
|
6
5
|
};
|
|
7
6
|
/**
|
|
8
7
|
* Invalidates affected Page Browser Graph records before HMR strategy dispatch.
|
|
@@ -6,9 +6,6 @@ import { getAffectedPageBrowserGraphIdentities, invalidatePageBrowserGraphSessio
|
|
|
6
6
|
export function prepareHmrFileChange(appConfig, filePath) {
|
|
7
7
|
const resolvedFilePath = path.resolve(filePath);
|
|
8
8
|
const affectedGraphIdentities = getAffectedPageBrowserGraphIdentities(appConfig, resolvedFilePath);
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
affectedGraphIdentities,
|
|
12
|
-
invalidatedGraphCount,
|
|
13
|
-
};
|
|
9
|
+
invalidatePageBrowserGraphSession(appConfig, resolvedFilePath);
|
|
10
|
+
return { affectedGraphIdentities };
|
|
14
11
|
}
|
|
@@ -26,7 +26,7 @@ import type { ClientBridgeEvent } from '../types/public-types.js';
|
|
|
26
26
|
*/
|
|
27
27
|
/**
|
|
28
28
|
* Defines the category of an HMR strategy, which determines its execution priority.
|
|
29
|
-
* Strategies are evaluated in descending order: INTEGRATION →
|
|
29
|
+
* Strategies are evaluated in descending order: INTEGRATION → SCRIPT → FALLBACK.
|
|
30
30
|
*
|
|
31
31
|
* @remarks
|
|
32
32
|
* The numeric values represent base priorities. Strategies can fine-tune their priority
|
|
@@ -38,11 +38,6 @@ export declare const HmrStrategyType: {
|
|
|
38
38
|
* Highest priority to allow framework-specific HMR handling.
|
|
39
39
|
*/
|
|
40
40
|
readonly INTEGRATION: 100;
|
|
41
|
-
/**
|
|
42
|
-
* Asset processing strategies (CSS, images, etc.)
|
|
43
|
-
* High priority for specialized asset handling.
|
|
44
|
-
*/
|
|
45
|
-
readonly ASSET: 50;
|
|
46
41
|
/**
|
|
47
42
|
* Generic script bundling strategies (JS/TS)
|
|
48
43
|
* Medium priority for standard script processing.
|
|
@@ -82,8 +77,8 @@ export interface HmrAction {
|
|
|
82
77
|
*
|
|
83
78
|
* @example
|
|
84
79
|
* ```typescript
|
|
85
|
-
* class
|
|
86
|
-
* readonly type = HmrStrategyType.
|
|
80
|
+
* class MyImageStrategy extends HmrStrategy {
|
|
81
|
+
* readonly type = HmrStrategyType.INTEGRATION;
|
|
87
82
|
* readonly priorityOffset = 5;
|
|
88
83
|
*
|
|
89
84
|
* matches(filePath: string): boolean {
|
package/src/hmr/hmr-strategy.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
*/
|
|
26
26
|
/**
|
|
27
27
|
* Defines the category of an HMR strategy, which determines its execution priority.
|
|
28
|
-
* Strategies are evaluated in descending order: INTEGRATION →
|
|
28
|
+
* Strategies are evaluated in descending order: INTEGRATION → SCRIPT → FALLBACK.
|
|
29
29
|
*
|
|
30
30
|
* @remarks
|
|
31
31
|
* The numeric values represent base priorities. Strategies can fine-tune their priority
|
|
@@ -37,11 +37,6 @@ export const HmrStrategyType = {
|
|
|
37
37
|
* Highest priority to allow framework-specific HMR handling.
|
|
38
38
|
*/
|
|
39
39
|
INTEGRATION: 100,
|
|
40
|
-
/**
|
|
41
|
-
* Asset processing strategies (CSS, images, etc.)
|
|
42
|
-
* High priority for specialized asset handling.
|
|
43
|
-
*/
|
|
44
|
-
ASSET: 50,
|
|
45
40
|
/**
|
|
46
41
|
* Generic script bundling strategies (JS/TS)
|
|
47
42
|
* Medium priority for standard script processing.
|
|
@@ -66,8 +61,8 @@ export const HmrStrategyType = {
|
|
|
66
61
|
*
|
|
67
62
|
* @example
|
|
68
63
|
* ```typescript
|
|
69
|
-
* class
|
|
70
|
-
* readonly type = HmrStrategyType.
|
|
64
|
+
* class MyImageStrategy extends HmrStrategy {
|
|
65
|
+
* readonly type = HmrStrategyType.INTEGRATION;
|
|
71
66
|
* readonly priorityOffset = 5;
|
|
72
67
|
*
|
|
73
68
|
* matches(filePath: string): boolean {
|
package/src/index.browser.d.ts
CHANGED
|
@@ -3,5 +3,4 @@ export type * from './eco/eco.types.js';
|
|
|
3
3
|
export { eco } from './eco/eco.browser.js';
|
|
4
4
|
export { bindComponentIdentity, getComponentIdentity, type ComponentIdentity } from './eco/component-identity.js';
|
|
5
5
|
export { attachDiscoveredDependencies } from './eco/discovered-dependencies.js';
|
|
6
|
-
export {
|
|
7
|
-
export { mergeLayoutDependencies } from './eco/page-layout-normalization.js';
|
|
6
|
+
export { mergePageDependencies } from './eco/page-dependency-contributions.js';
|
package/src/index.browser.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { eco } from './eco/eco.browser.js';
|
|
2
2
|
export { bindComponentIdentity, getComponentIdentity } from './eco/component-identity.js';
|
|
3
3
|
export { attachDiscoveredDependencies } from './eco/discovered-dependencies.js';
|
|
4
|
-
export {
|
|
5
|
-
export { mergeLayoutDependencies } from './eco/page-layout-normalization.js';
|
|
4
|
+
export { mergePageDependencies } from './eco/page-dependency-contributions.js';
|
package/src/index.d.ts
CHANGED
|
@@ -2,11 +2,10 @@ export type * from './types/public-types.js';
|
|
|
2
2
|
export type * from './eco/eco.types.js';
|
|
3
3
|
export { eco } from './eco/eco.js';
|
|
4
4
|
export { defineApiHandler, defineGroupHandler, defineGet, definePost, definePut, defineDelete, definePatch, defineOptions, defineHead, json, html, redirect, type GroupHandler, } from './adapters/shared/http/define-api-handler.js';
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
5
|
+
export { createVitePluginsFromAppSourceTransforms, createVitePluginFromSourceTransform, type EcoSourceTransform, type EcoSourceTransformResult, type EcoViteCompatiblePlugin, } from './plugins/source-transform.js';
|
|
6
|
+
export { attributeMdxComponentIdentity, createEcoComponentMetaTransform } from './plugins/eco-component-meta-plugin.js';
|
|
7
7
|
export { bindComponentIdentity, getComponentIdentity, type ComponentIdentity } from './eco/component-identity.js';
|
|
8
|
-
export { attachDiscoveredDependencies
|
|
9
|
-
export {
|
|
10
|
-
export { mergeLayoutDependencies } from './eco/page-layout-normalization.js';
|
|
8
|
+
export { attachDiscoveredDependencies } from './eco/discovered-dependencies.js';
|
|
9
|
+
export { mergePageDependencies } from './eco/page-dependency-contributions.js';
|
|
11
10
|
export { SchemaError, validateStandardSchema } from './services/validation/validate-standard-schema.js';
|
|
12
|
-
export { buildIslandHostAttributes,
|
|
11
|
+
export { buildIslandHostAttributes, finalizeIslandComponentRender } from './islands/island-host.js';
|
package/src/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export { eco } from './eco/eco.js';
|
|
2
2
|
export { defineApiHandler, defineGroupHandler, defineGet, definePost, definePut, defineDelete, definePatch, defineOptions, defineHead, json, html, redirect, } from './adapters/shared/http/define-api-handler.js';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
3
|
+
export { createVitePluginsFromAppSourceTransforms, createVitePluginFromSourceTransform, } from './plugins/source-transform.js';
|
|
4
|
+
export { attributeMdxComponentIdentity, createEcoComponentMetaTransform } from './plugins/eco-component-meta-plugin.js';
|
|
5
5
|
export { bindComponentIdentity, getComponentIdentity } from './eco/component-identity.js';
|
|
6
|
-
export { attachDiscoveredDependencies
|
|
7
|
-
export {
|
|
8
|
-
export { mergeLayoutDependencies } from './eco/page-layout-normalization.js';
|
|
6
|
+
export { attachDiscoveredDependencies } from './eco/discovered-dependencies.js';
|
|
7
|
+
export { mergePageDependencies } from './eco/page-dependency-contributions.js';
|
|
9
8
|
export { SchemaError, validateStandardSchema } from './services/validation/validate-standard-schema.js';
|
|
10
|
-
export { buildIslandHostAttributes,
|
|
9
|
+
export { buildIslandHostAttributes, finalizeIslandComponentRender } from './islands/island-host.js';
|
|
@@ -10,16 +10,7 @@ export type IslandHostAttributesInput = {
|
|
|
10
10
|
props?: Record<string, unknown>;
|
|
11
11
|
existing?: Record<string, string>;
|
|
12
12
|
};
|
|
13
|
-
/**
|
|
14
|
-
* @remarks Presence marker for hydratable component hosts, similar in spirit to Astro's `astro-island`.
|
|
15
|
-
*/
|
|
16
|
-
export declare function mergeIslandHostAttributes(input: {
|
|
17
|
-
integrationName: string;
|
|
18
|
-
componentInstanceId: string;
|
|
19
|
-
existing?: Record<string, string>;
|
|
20
|
-
}): Record<string, string>;
|
|
21
13
|
export declare function buildIslandHostAttributes(input: IslandHostAttributesInput): Record<string, string>;
|
|
22
|
-
export declare function isIslandHostElement(element: Element): boolean;
|
|
23
14
|
export declare function componentRenderHasIslandBootstrap(assets: Array<{
|
|
24
15
|
kind: string;
|
|
25
16
|
}> | undefined): boolean;
|
|
@@ -6,7 +6,7 @@ export const ECO_ISLAND_PROPS_ATTRIBUTE = 'data-eco-props';
|
|
|
6
6
|
/**
|
|
7
7
|
* @remarks Presence marker for hydratable component hosts, similar in spirit to Astro's `astro-island`.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
function mergeIslandHostAttributes(input) {
|
|
10
10
|
return {
|
|
11
11
|
...input.existing,
|
|
12
12
|
[ECO_ISLAND_HOST_ATTRIBUTE]: '',
|
|
@@ -24,18 +24,6 @@ export function buildIslandHostAttributes(input) {
|
|
|
24
24
|
}
|
|
25
25
|
return attributes;
|
|
26
26
|
}
|
|
27
|
-
export function isIslandHostElement(element) {
|
|
28
|
-
if (element.hasAttribute(ECO_ISLAND_HOST_ATTRIBUTE)) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
if (element.hasAttribute(ECO_ISLAND_COMPONENT_KEY_ATTRIBUTE)) {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
if (element.tagName.toLowerCase() === 'eco-island') {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
return element.hasAttribute(ECO_ISLAND_COMPONENT_ID_ATTRIBUTE) && element.hasAttribute(ECO_ISLAND_PROPS_ATTRIBUTE);
|
|
38
|
-
}
|
|
39
27
|
export function componentRenderHasIslandBootstrap(assets) {
|
|
40
28
|
return (assets ?? []).some((asset) => asset.kind === 'script');
|
|
41
29
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
3
|
-
import {
|
|
3
|
+
import { parseModuleSource } from '../cache/module-parse-cache.js';
|
|
4
4
|
import { loadTsconfigPathPrefixes, matchesTsconfigPathPrefix, resolveProjectModulePath, } from './tsconfig-import-resolver.js';
|
|
5
5
|
function node(value) {
|
|
6
6
|
return typeof value === 'object' && value !== null ? value : undefined;
|
|
@@ -90,7 +90,7 @@ function indexModuleExports(file, cache) {
|
|
|
90
90
|
if (cached)
|
|
91
91
|
return cached;
|
|
92
92
|
const source = readFileSync(file, 'utf8');
|
|
93
|
-
const parsed =
|
|
93
|
+
const parsed = parseModuleSource(file, source, { sourceType: 'module' });
|
|
94
94
|
const body = nodes(parsed.program.body);
|
|
95
95
|
const { declared, factories } = collectDeclaredFactoryBindings(body);
|
|
96
96
|
const namedReexports = new Map();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { prependJsxImportSourceIfMissing } from './jsx-import-source.utils.js';
|
|
2
2
|
import { createEcoBuildPluginFromSourceTransform, createVitePluginFromSourceTransform } from './source-transform.js';
|
|
3
|
-
import {
|
|
3
|
+
import { parseModuleSource } from '../cache/module-parse-cache.js';
|
|
4
4
|
import { rapidhash } from '../utils/hash.js';
|
|
5
5
|
import { discoverComponentImports } from './component-import-discovery.js';
|
|
6
6
|
function integrationForFile(filePath, config) {
|
|
@@ -98,7 +98,7 @@ export function attributeComponentIdentity(contents, filePath, integration, proj
|
|
|
98
98
|
return contents;
|
|
99
99
|
let program;
|
|
100
100
|
try {
|
|
101
|
-
program =
|
|
101
|
+
program = parseModuleSource(filePath, contents, { sourceType: 'module' }).program;
|
|
102
102
|
}
|
|
103
103
|
catch {
|
|
104
104
|
return contents;
|
|
@@ -133,7 +133,7 @@ export function attributeComponentIdentity(contents, filePath, integration, proj
|
|
|
133
133
|
for (const edit of edits.sort((left, right) => right.start - left.start)) {
|
|
134
134
|
transformed = `${transformed.slice(0, edit.start)}${edit.replacement}${transformed.slice(edit.end)}`;
|
|
135
135
|
}
|
|
136
|
-
return addIdentityBindingImport(transformed,
|
|
136
|
+
return addIdentityBindingImport(transformed, parseModuleSource(filePath, transformed, { sourceType: 'module' }).program);
|
|
137
137
|
}
|
|
138
138
|
function findMdxConfigDeclarator(program) {
|
|
139
139
|
for (const statement of nodes(program?.body)) {
|
|
@@ -180,7 +180,7 @@ export function attributeMdxComponentIdentity(contents, filePath, integration, p
|
|
|
180
180
|
}
|
|
181
181
|
let program;
|
|
182
182
|
try {
|
|
183
|
-
program =
|
|
183
|
+
program = parseModuleSource(filePath, contents, { lang: 'jsx', sourceType: 'module' })
|
|
184
184
|
.program;
|
|
185
185
|
}
|
|
186
186
|
catch {
|
|
@@ -206,7 +206,7 @@ export function attributeMdxComponentIdentity(contents, filePath, integration, p
|
|
|
206
206
|
transformed = `${transformed.slice(0, edit.start)}${edit.replacement}${transformed.slice(edit.end)}`;
|
|
207
207
|
}
|
|
208
208
|
transformed = `${transformed}\n${appended}`;
|
|
209
|
-
return addNamedImport(transformed,
|
|
209
|
+
return addNamedImport(transformed, parseModuleSource(filePath, transformed, { lang: 'jsx', sourceType: 'module' }).program, '@ecopages/core', ['bindComponentIdentity', 'attachDiscoveredDependencies']);
|
|
210
210
|
}
|
|
211
211
|
export function createEcoComponentMetaTransform(options) {
|
|
212
212
|
const extensions = options.config.integrations
|
|
@@ -25,7 +25,6 @@ export declare const INTEGRATION_PLUGIN_ERRORS: {
|
|
|
25
25
|
readonly NOT_INITIALIZED_WITH_ASSET_SERVICE: "Plugin not initialized with asset dependency service";
|
|
26
26
|
};
|
|
27
27
|
export declare function mergeIntegrationOptions<TDefaults, TOverrides>(defaults: TDefaults, overrides: TOverrides): TDefaults & TOverrides;
|
|
28
|
-
export declare function assertIntegrationInvariant(condition: boolean, message?: string): asserts condition;
|
|
29
28
|
/**
|
|
30
29
|
* Base configuration shared by all integration plugins.
|
|
31
30
|
*
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createBrowserRuntimeManifest, } from '../build/browser/browser-runtime-manifest.js';
|
|
2
2
|
import { AssetProcessingService } from '../services/assets/asset-processing-service/asset-processing.service.js';
|
|
3
3
|
import { deepMerge } from '../utils/deep-merge.js';
|
|
4
|
-
import { invariant } from '../utils/invariant.js';
|
|
5
4
|
export const INTEGRATION_PLUGIN_ERRORS = {
|
|
6
5
|
NOT_INITIALIZED_WITH_APP_CONFIG: 'Plugin not initialized with app config',
|
|
7
6
|
NOT_INITIALIZED_WITH_ASSET_SERVICE: 'Plugin not initialized with asset dependency service',
|
|
@@ -9,9 +8,6 @@ export const INTEGRATION_PLUGIN_ERRORS = {
|
|
|
9
8
|
export function mergeIntegrationOptions(defaults, overrides) {
|
|
10
9
|
return deepMerge(defaults, overrides);
|
|
11
10
|
}
|
|
12
|
-
export function assertIntegrationInvariant(condition, message) {
|
|
13
|
-
invariant(condition, message);
|
|
14
|
-
}
|
|
15
11
|
/**
|
|
16
12
|
* Base class for framework integrations.
|
|
17
13
|
*
|
|
@@ -62,7 +62,7 @@ export interface ProcessorAssetCapability {
|
|
|
62
62
|
*/
|
|
63
63
|
extensions?: ProcessorExtensionPattern[];
|
|
64
64
|
}
|
|
65
|
-
export interface ProcessorConfig<TOptions =
|
|
65
|
+
export interface ProcessorConfig<TOptions = unknown> {
|
|
66
66
|
name: string;
|
|
67
67
|
description?: string;
|
|
68
68
|
options?: TOptions;
|
|
@@ -77,6 +77,10 @@ export interface ProcessorContext {
|
|
|
77
77
|
distDir: string;
|
|
78
78
|
cache?: string;
|
|
79
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Unconstrained processor type for heterogeneous processor collections.
|
|
82
|
+
*/
|
|
83
|
+
export type AnyProcessor = Processor<unknown>;
|
|
80
84
|
/**
|
|
81
85
|
* Base class for content and asset processors that contribute build plugins.
|
|
82
86
|
*
|
|
@@ -90,7 +94,7 @@ export interface ProcessorContext {
|
|
|
90
94
|
* Virtual modules that must resolve during route-module transpile belong in
|
|
91
95
|
* `plugins`. Browser-only bundler hooks belong in `buildPlugins`.
|
|
92
96
|
*/
|
|
93
|
-
export declare abstract class Processor<TOptions =
|
|
97
|
+
export declare abstract class Processor<TOptions = unknown> {
|
|
94
98
|
readonly name: string;
|
|
95
99
|
protected context?: ProcessorContext;
|
|
96
100
|
protected options?: TOptions;
|
|
@@ -52,6 +52,10 @@ See [`../build/README.md`](../build/README.md) for the JSX ownership helper spli
|
|
|
52
52
|
- `RouteRendererFactory` chooses integration renderers from route files
|
|
53
53
|
- `RouteRenderer` delegates execution to the selected renderer
|
|
54
54
|
|
|
55
|
+
### `explicit-view-render-preparation.ts`
|
|
56
|
+
|
|
57
|
+
Resolves the integration renderer and static props for one `eco.page()` view. Explicit static routes, static export, and registered error pages share this helper so view rendering does not fork per caller.
|
|
58
|
+
|
|
55
59
|
### `orchestration/`
|
|
56
60
|
|
|
57
61
|
Root renderer classes:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { EcoPagesAppConfig } from '
|
|
2
|
-
import type { EcoFunctionComponent, EcoPageComponent } from '
|
|
3
|
-
import type { ExplicitViewRenderer, ExplicitViewRendererResolver } from '
|
|
1
|
+
import type { EcoPagesAppConfig } from '../types/internal-types.js';
|
|
2
|
+
import type { EcoFunctionComponent, EcoPageComponent } from '../types/public-types.js';
|
|
3
|
+
import type { ExplicitViewRenderer, ExplicitViewRendererResolver } from './route-renderer.js';
|
|
4
4
|
type ExplicitStaticRenderPreparationResult = {
|
|
5
5
|
renderer: ExplicitViewRenderer;
|
|
6
6
|
props: Record<string, unknown>;
|
|
@@ -150,8 +150,5 @@ export async function finalizeDocumentShellHtml(htmlTransformer, options) {
|
|
|
150
150
|
if (!shouldTransform) {
|
|
151
151
|
return html;
|
|
152
152
|
}
|
|
153
|
-
|
|
154
|
-
headers: { 'Content-Type': 'text/html' },
|
|
155
|
-
}), options.htmlContributions);
|
|
156
|
-
return await transformedResponse.text();
|
|
153
|
+
return htmlTransformer.transformHtml(html, options.htmlContributions);
|
|
157
154
|
}
|
package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts
CHANGED
|
@@ -24,11 +24,22 @@ export type QueuedForeignSubtreeResolutionContext = {
|
|
|
24
24
|
queuedResolutions: QueuedForeignSubtreeResolution[];
|
|
25
25
|
};
|
|
26
26
|
type QueuedForeignSubtreeIntegrationContext = BaseIntegrationContext & Record<string, unknown>;
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Children of a queued foreign subtree after the host renderer has processed them.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Set `html` when the host serialized the children, or `children` to pass them
|
|
32
|
+
* to the owning renderer unserialized. Leave both unset when there are no
|
|
33
|
+
* children. Assets are not returned here: the owning renderer reports the
|
|
34
|
+
* foreign component's assets, and host components' assets come from their
|
|
35
|
+
* declared dependencies.
|
|
36
|
+
*/
|
|
37
|
+
export type QueuedForeignSubtreeChildRenderResult = {
|
|
29
38
|
html?: string;
|
|
30
39
|
children?: unknown;
|
|
31
40
|
};
|
|
41
|
+
/** Renders the children of one queued foreign subtree inside the host renderer. */
|
|
42
|
+
export type RenderQueuedForeignSubtreeChildren<TContext extends QueuedForeignSubtreeResolutionContext> = (children: unknown, runtimeContext: TContext, queuedResolutionsByToken: Map<string, QueuedForeignSubtreeResolution>, resolveToken: (token: string) => Promise<string>) => Promise<QueuedForeignSubtreeChildRenderResult>;
|
|
32
43
|
export interface ForeignSubtreeExecutionOwningRenderer {
|
|
33
44
|
readonly name: string;
|
|
34
45
|
renderComponentWithForeignChildren(input: ComponentRenderInput): Promise<ComponentRenderResult>;
|
|
@@ -56,38 +67,20 @@ export interface ForeignSubtreeQueuedRuntimeOptions<TContext extends QueuedForei
|
|
|
56
67
|
tokenPrefix: string;
|
|
57
68
|
createRuntimeContext?: (integrationContext: BaseIntegrationContext & Record<string, unknown>, rendererCache: Map<string, unknown>) => TContext;
|
|
58
69
|
}
|
|
59
|
-
export interface ForeignSubtreeStringQueuedHtmlOptions {
|
|
60
|
-
currentIntegrationName: string;
|
|
61
|
-
renderInput: ComponentRenderInput;
|
|
62
|
-
html: string;
|
|
63
|
-
runtimeContextKey: string;
|
|
64
|
-
queueLabel: string;
|
|
65
|
-
getOwningRenderer(integrationName: string, rendererCache: Map<string, ForeignSubtreeExecutionOwningRenderer>): Promise<ForeignSubtreeExecutionOwningRenderer>;
|
|
66
|
-
applyAttributesToFirstElement(html: string, attributes: Record<string, string>): string;
|
|
67
|
-
dedupeProcessedAssets(assets: ProcessedAsset[]): ProcessedAsset[];
|
|
68
|
-
}
|
|
69
70
|
export interface ForeignSubtreeQueuedHtmlOptions<TContext extends QueuedForeignSubtreeResolutionContext> {
|
|
70
71
|
currentIntegrationName: string;
|
|
71
72
|
html: string;
|
|
72
73
|
runtimeContext?: TContext;
|
|
73
|
-
|
|
74
|
-
renderQueuedChildren(children: unknown, runtimeContext: TContext, queuedResolutionsByToken: Map<string, QueuedForeignSubtreeResolution>, resolveToken: (token: string) => Promise<string>): Promise<{
|
|
75
|
-
assets: ProcessedAsset[];
|
|
76
|
-
children?: unknown;
|
|
77
|
-
html?: string;
|
|
78
|
-
}>;
|
|
74
|
+
renderQueuedChildren: RenderQueuedForeignSubtreeChildren<TContext>;
|
|
79
75
|
getOwningRenderer(integrationName: string, rendererCache: Map<string, ForeignSubtreeExecutionOwningRenderer>): Promise<ForeignSubtreeExecutionOwningRenderer>;
|
|
80
|
-
applyAttributesToFirstElement(html: string, attributes: Record<string, string>): string;
|
|
81
|
-
dedupeProcessedAssets(assets: ProcessedAsset[]): ProcessedAsset[];
|
|
82
76
|
}
|
|
77
|
+
export type ForeignSubtreeStringQueuedHtmlOptions = Omit<ForeignSubtreeQueuedHtmlOptions<QueuedForeignSubtreeResolutionContext>, 'renderQueuedChildren'>;
|
|
83
78
|
export interface ResolveQueuedForeignSubtreeTokensOptions<TContext extends QueuedForeignSubtreeResolutionContext> {
|
|
84
79
|
html: string;
|
|
85
80
|
runtimeContext?: TContext;
|
|
86
81
|
queueLabel: string;
|
|
87
|
-
renderQueuedChildren:
|
|
82
|
+
renderQueuedChildren: RenderQueuedForeignSubtreeChildren<TContext>;
|
|
88
83
|
resolveForeignSubtree: (input: ComponentRenderInput, rendererCache: Map<string, unknown>) => Promise<ForeignSubtreeRenderPayload | undefined>;
|
|
89
|
-
applyAttributesToFirstElement: (html: string, attributes: Record<string, string>) => string;
|
|
90
|
-
dedupeProcessedAssets: (assets: ProcessedAsset[]) => ProcessedAsset[];
|
|
91
84
|
}
|
|
92
85
|
/**
|
|
93
86
|
* Maps one component render result into the foreign-subtree payload shape used by
|
|
@@ -115,7 +108,15 @@ export declare class ForeignSubtreeExecutionService {
|
|
|
115
108
|
createRuntimeContext?: (integrationContext: QueuedForeignSubtreeIntegrationContext, rendererCache: Map<string, unknown>) => TContext;
|
|
116
109
|
}): ForeignChildRuntime;
|
|
117
110
|
getRuntimeContext<TContext extends QueuedForeignSubtreeResolutionContext>(input: ComponentRenderInput, runtimeContextKey: string): TContext | undefined;
|
|
118
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Resolves queued foreign subtrees for a renderer whose children are markup.
|
|
113
|
+
*
|
|
114
|
+
* @remarks
|
|
115
|
+
* String children and markup nodes are serialized and their nested tokens
|
|
116
|
+
* resolved. Structured children pass to the owning renderer unchanged; opaque
|
|
117
|
+
* objects are rejected.
|
|
118
|
+
*/
|
|
119
|
+
resolveStringQueuedHtml(options: ForeignSubtreeStringQueuedHtmlOptions): Promise<{
|
|
119
120
|
assets: ProcessedAsset[];
|
|
120
121
|
html: string;
|
|
121
122
|
}>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { applyAttributesToFirstElement } from '../../../services/html/html-transformer.service.js';
|
|
1
2
|
import { getComponentRenderContext, runWithComponentRenderContext, } from './component-render-context.js';
|
|
2
3
|
import { assertForeignChildrenNotOpaque, isMarkupNodeLike } from './foreign-child-output.utils.js';
|
|
4
|
+
import { dedupeProcessedAssets } from '../page-browser-graph/processed-asset-dedupe.js';
|
|
3
5
|
/**
|
|
4
6
|
* Maps one component render result into the foreign-subtree payload shape used by
|
|
5
7
|
* queue resolution and integration tests.
|
|
@@ -106,34 +108,35 @@ export class ForeignSubtreeExecutionService {
|
|
|
106
108
|
}
|
|
107
109
|
return runtimeContext;
|
|
108
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Resolves queued foreign subtrees for a renderer whose children are markup.
|
|
113
|
+
*
|
|
114
|
+
* @remarks
|
|
115
|
+
* String children and markup nodes are serialized and their nested tokens
|
|
116
|
+
* resolved. Structured children pass to the owning renderer unchanged; opaque
|
|
117
|
+
* objects are rejected.
|
|
118
|
+
*/
|
|
109
119
|
async resolveStringQueuedHtml(options) {
|
|
110
|
-
const runtimeContext = this.getQueuedRuntimeContext(options.renderInput, options.runtimeContextKey);
|
|
111
120
|
return this.resolveQueuedHtml({
|
|
112
|
-
|
|
113
|
-
html: options.html,
|
|
114
|
-
runtimeContext,
|
|
115
|
-
queueLabel: options.queueLabel,
|
|
121
|
+
...options,
|
|
116
122
|
renderQueuedChildren: async (children, _runtimeContext, queuedResolutionsByToken, resolveToken) => {
|
|
117
123
|
if (children === undefined) {
|
|
118
|
-
return {
|
|
124
|
+
return {};
|
|
119
125
|
}
|
|
120
126
|
if (typeof children !== 'string' && !isMarkupNodeLike(children)) {
|
|
121
|
-
assertForeignChildrenNotOpaque(children, options.
|
|
122
|
-
return {
|
|
127
|
+
assertForeignChildrenNotOpaque(children, options.currentIntegrationName);
|
|
128
|
+
return { children };
|
|
123
129
|
}
|
|
124
130
|
const html = await this.resolveQueuedTokens(typeof children === 'string' ? children : (children.outerHTML ?? ''), queuedResolutionsByToken, resolveToken);
|
|
125
|
-
return {
|
|
131
|
+
return { html };
|
|
126
132
|
},
|
|
127
|
-
getOwningRenderer: options.getOwningRenderer,
|
|
128
|
-
applyAttributesToFirstElement: options.applyAttributesToFirstElement,
|
|
129
|
-
dedupeProcessedAssets: options.dedupeProcessedAssets,
|
|
130
133
|
});
|
|
131
134
|
}
|
|
132
135
|
async resolveQueuedHtml(options) {
|
|
133
136
|
return this.resolveQueuedForeignSubtreeTokens({
|
|
134
137
|
html: options.html,
|
|
135
138
|
runtimeContext: options.runtimeContext,
|
|
136
|
-
queueLabel: options.
|
|
139
|
+
queueLabel: options.currentIntegrationName,
|
|
137
140
|
renderQueuedChildren: options.renderQueuedChildren,
|
|
138
141
|
resolveForeignSubtree: (input, rendererCache) => this.resolveForeignSubtreeInOwningRenderer({
|
|
139
142
|
currentIntegrationName: options.currentIntegrationName,
|
|
@@ -141,8 +144,6 @@ export class ForeignSubtreeExecutionService {
|
|
|
141
144
|
rendererCache: rendererCache,
|
|
142
145
|
getOwningRenderer: options.getOwningRenderer,
|
|
143
146
|
}),
|
|
144
|
-
applyAttributesToFirstElement: options.applyAttributesToFirstElement,
|
|
145
|
-
dedupeProcessedAssets: options.dedupeProcessedAssets,
|
|
146
147
|
});
|
|
147
148
|
}
|
|
148
149
|
async resolveQueuedForeignSubtreeTokens(options) {
|
|
@@ -178,9 +179,6 @@ export class ForeignSubtreeExecutionService {
|
|
|
178
179
|
try {
|
|
179
180
|
const renderedChildren = await options.renderQueuedChildren(resolution.props.children, runtimeContext, queuedResolutionsByToken, resolveToken);
|
|
180
181
|
syncQueuedResolutions();
|
|
181
|
-
if (renderedChildren.assets.length > 0) {
|
|
182
|
-
collectedAssets.push(...renderedChildren.assets);
|
|
183
|
-
}
|
|
184
182
|
const foreignSubtreeRender = await options.resolveForeignSubtree({
|
|
185
183
|
component: resolution.component,
|
|
186
184
|
props: { ...resolution.props },
|
|
@@ -198,7 +196,7 @@ export class ForeignSubtreeExecutionService {
|
|
|
198
196
|
}
|
|
199
197
|
const resolvedHtml = foreignSubtreeRender.attachmentPolicy.kind === 'first-element' &&
|
|
200
198
|
foreignSubtreeRender.rootAttributes
|
|
201
|
-
?
|
|
199
|
+
? applyAttributesToFirstElement(foreignSubtreeRender.html, foreignSubtreeRender.rootAttributes)
|
|
202
200
|
: foreignSubtreeRender.html;
|
|
203
201
|
resolvedHtmlByToken.set(token, resolvedHtml);
|
|
204
202
|
return resolvedHtml;
|
|
@@ -217,7 +215,7 @@ export class ForeignSubtreeExecutionService {
|
|
|
217
215
|
resolvedHtml = resolvedHtml.split(resolution.token).join(await resolveToken(resolution.token));
|
|
218
216
|
}
|
|
219
217
|
return {
|
|
220
|
-
assets:
|
|
218
|
+
assets: dedupeProcessedAssets(collectedAssets),
|
|
221
219
|
html: resolvedHtml,
|
|
222
220
|
};
|
|
223
221
|
}
|