@ecopages/core 0.2.0-alpha.11 → 0.2.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -10
- package/README.md +5 -4
- package/package.json +30 -6
- package/src/adapters/bun/hmr-manager.js +2 -2
- package/src/adapters/node/node-hmr-manager.js +2 -2
- package/src/adapters/node/server-adapter.d.ts +2 -2
- package/src/adapters/node/server-adapter.js +5 -5
- package/src/build/build-adapter.d.ts +8 -6
- package/src/build/build-adapter.js +44 -7
- package/src/eco/eco.js +18 -118
- package/src/eco/eco.utils.d.ts +1 -40
- package/src/eco/eco.utils.js +5 -35
- package/src/hmr/hmr-strategy.d.ts +8 -6
- package/src/integrations/ghtml/ghtml-renderer.d.ts +6 -1
- package/src/integrations/ghtml/ghtml-renderer.js +29 -28
- package/src/plugins/foreign-jsx-override-plugin.d.ts +31 -0
- package/src/plugins/foreign-jsx-override-plugin.js +35 -0
- package/src/plugins/integration-plugin.d.ts +90 -29
- package/src/plugins/integration-plugin.js +62 -19
- package/src/route-renderer/GRAPH.md +54 -84
- package/src/route-renderer/README.md +11 -19
- package/src/route-renderer/orchestration/component-render-context.d.ts +83 -0
- package/src/route-renderer/orchestration/component-render-context.js +147 -0
- package/src/route-renderer/orchestration/integration-renderer.d.ts +219 -81
- package/src/route-renderer/orchestration/integration-renderer.js +415 -171
- package/src/route-renderer/orchestration/queued-boundary-runtime.service.d.ts +93 -0
- package/src/route-renderer/orchestration/queued-boundary-runtime.service.js +155 -0
- package/src/route-renderer/orchestration/render-execution.service.d.ts +8 -70
- package/src/route-renderer/orchestration/render-execution.service.js +28 -113
- package/src/route-renderer/orchestration/render-output.utils.d.ts +46 -0
- package/src/route-renderer/orchestration/render-output.utils.js +65 -0
- package/src/route-renderer/orchestration/render-preparation.service.d.ts +0 -6
- package/src/route-renderer/orchestration/render-preparation.service.js +5 -13
- package/src/route-renderer/orchestration/template-serialization.d.ts +38 -0
- package/src/route-renderer/orchestration/template-serialization.js +45 -0
- package/src/route-renderer/page-loading/dependency-resolver.js +10 -8
- package/src/router/client/navigation-coordinator.js +2 -2
- package/src/router/server/fs-router-scanner.js +6 -1
- package/src/services/module-loading/node-bootstrap-plugin.js +14 -1
- package/src/services/module-loading/page-module-import.service.js +1 -1
- package/src/services/runtime-state/dev-graph.service.d.ts +5 -5
- package/src/services/runtime-state/dev-graph.service.js +10 -10
- package/src/types/public-types.d.ts +18 -3
- package/src/utils/html-escaping.d.ts +7 -0
- package/src/utils/html-escaping.js +6 -0
- package/src/eco/component-render-context.d.ts +0 -105
- package/src/eco/component-render-context.js +0 -94
- package/src/route-renderer/component-graph/component-graph-executor.d.ts +0 -33
- package/src/route-renderer/component-graph/component-graph-executor.js +0 -30
- package/src/route-renderer/component-graph/component-graph.d.ts +0 -53
- package/src/route-renderer/component-graph/component-graph.js +0 -94
- package/src/route-renderer/component-graph/component-marker.d.ts +0 -52
- package/src/route-renderer/component-graph/component-marker.js +0 -46
- package/src/route-renderer/component-graph/component-reference.d.ts +0 -11
- package/src/route-renderer/component-graph/component-reference.js +0 -39
- package/src/route-renderer/component-graph/marker-graph-resolver.d.ts +0 -79
- package/src/route-renderer/component-graph/marker-graph-resolver.js +0 -117
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* This module contains the ghtml renderer
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
|
-
import type { EcoComponent, EcoPagesElement, IntegrationRendererRenderOptions, RouteRendererBody } from '../../types/public-types.js';
|
|
5
|
+
import type { ComponentRenderInput, ComponentRenderResult, EcoComponent, EcoPagesElement, IntegrationRendererRenderOptions, RouteRendererBody } from '../../types/public-types.js';
|
|
6
6
|
import { IntegrationRenderer, type RenderToResponseContext } from '../../route-renderer/orchestration/integration-renderer.js';
|
|
7
7
|
/**
|
|
8
8
|
* A renderer for the ghtml integration.
|
|
@@ -10,6 +10,11 @@ import { IntegrationRenderer, type RenderToResponseContext } from '../../route-r
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class GhtmlRenderer extends IntegrationRenderer<EcoPagesElement> {
|
|
12
12
|
name: string;
|
|
13
|
+
renderComponent(input: ComponentRenderInput): Promise<ComponentRenderResult>;
|
|
14
|
+
protected createComponentBoundaryRuntime(options: {
|
|
15
|
+
boundaryInput: ComponentRenderInput;
|
|
16
|
+
rendererCache: Map<string, IntegrationRenderer<any>>;
|
|
17
|
+
}): import("../../index.browser.js").ComponentBoundaryRuntime;
|
|
13
18
|
render({ params, query, props, locals, pageLocals, metadata, Page, Layout, HtmlTemplate, }: IntegrationRendererRenderOptions): Promise<RouteRendererBody>;
|
|
14
19
|
renderToResponse<P = Record<string, unknown>>(view: EcoComponent<P>, props: P, ctx: RenderToResponseContext): Promise<Response>;
|
|
15
20
|
}
|
|
@@ -4,6 +4,18 @@ import {
|
|
|
4
4
|
import { GHTML_PLUGIN_NAME } from "./ghtml.plugin.js";
|
|
5
5
|
class GhtmlRenderer extends IntegrationRenderer {
|
|
6
6
|
name = GHTML_PLUGIN_NAME;
|
|
7
|
+
async renderComponent(input) {
|
|
8
|
+
return this.renderStringComponentBoundaryWithQueuedForeignBoundaries(
|
|
9
|
+
input,
|
|
10
|
+
input.component
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
createComponentBoundaryRuntime(options) {
|
|
14
|
+
return this.createQueuedBoundaryRuntime({
|
|
15
|
+
boundaryInput: options.boundaryInput,
|
|
16
|
+
rendererCache: options.rendererCache
|
|
17
|
+
});
|
|
18
|
+
}
|
|
7
19
|
async render({
|
|
8
20
|
params,
|
|
9
21
|
query,
|
|
@@ -16,42 +28,31 @@ class GhtmlRenderer extends IntegrationRenderer {
|
|
|
16
28
|
HtmlTemplate
|
|
17
29
|
}) {
|
|
18
30
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
31
|
+
return await this.renderPageWithDocumentShell({
|
|
32
|
+
page: {
|
|
33
|
+
component: Page,
|
|
34
|
+
props: { params, query, ...props, locals: pageLocals }
|
|
35
|
+
},
|
|
36
|
+
layout: Layout ? {
|
|
37
|
+
component: Layout,
|
|
38
|
+
props: locals ? { locals } : {}
|
|
39
|
+
} : void 0,
|
|
40
|
+
htmlTemplate: HtmlTemplate,
|
|
22
41
|
metadata,
|
|
23
|
-
|
|
24
|
-
pageProps: props || {}
|
|
42
|
+
pageProps: props ?? {}
|
|
25
43
|
});
|
|
26
|
-
return this.DOC_TYPE + body;
|
|
27
44
|
} catch (error) {
|
|
28
45
|
throw this.createRenderError("Error rendering page", error);
|
|
29
46
|
}
|
|
30
47
|
}
|
|
31
48
|
async renderToResponse(view, props, ctx) {
|
|
32
49
|
try {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
} else {
|
|
40
|
-
const children = Layout ? await Layout({ children: pageContent }) : pageContent;
|
|
41
|
-
const HtmlTemplate = await this.getHtmlTemplate();
|
|
42
|
-
const metadata = view.metadata ? await view.metadata({
|
|
43
|
-
params: {},
|
|
44
|
-
query: {},
|
|
45
|
-
props,
|
|
46
|
-
appConfig: this.appConfig
|
|
47
|
-
}) : this.appConfig.defaultMetadata;
|
|
48
|
-
body = this.DOC_TYPE + await HtmlTemplate({
|
|
49
|
-
metadata,
|
|
50
|
-
children,
|
|
51
|
-
pageProps: props
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return this.createHtmlResponse(body, ctx);
|
|
50
|
+
return await this.renderViewWithDocumentShell({
|
|
51
|
+
view,
|
|
52
|
+
props,
|
|
53
|
+
ctx,
|
|
54
|
+
layout: view.config?.layout
|
|
55
|
+
});
|
|
55
56
|
} catch (error) {
|
|
56
57
|
throw this.createRenderError("Error rendering view", error);
|
|
57
58
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { EcoBuildPlugin } from '../build/build-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Options for the shared foreign-JSX override build plugin.
|
|
4
|
+
*/
|
|
5
|
+
export interface ForeignJsxOverrideOptions {
|
|
6
|
+
/** JSX runtime that should own the transformed foreign files. */
|
|
7
|
+
hostJsxImportSource: string;
|
|
8
|
+
/** Extensions claimed by other JSX integrations that may appear in the host graph. */
|
|
9
|
+
foreignExtensions: string[];
|
|
10
|
+
/** Optional plugin name override for debug output. */
|
|
11
|
+
name?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Build plugin that prepends a `@jsxImportSource` pragma to foreign integration
|
|
15
|
+
* files bundled into a host integration's client graph.
|
|
16
|
+
*
|
|
17
|
+
* When a host integration (e.g. React) bundles a component file that belongs to
|
|
18
|
+
* another JSX integration (e.g. `.kita.tsx`), that file inherits the project
|
|
19
|
+
* `tsconfig` JSX runtime which produces the wrong output (HTML strings instead
|
|
20
|
+
* of framework elements). This plugin rewrites the source to explicitly target
|
|
21
|
+
* the host's JSX factory so esbuild compiles every JSX expression into the
|
|
22
|
+
* correct element creation calls.
|
|
23
|
+
*
|
|
24
|
+
* The plugin is intentionally framework-agnostic: any integration that does
|
|
25
|
+
* client-side bundling can use it by passing its own `jsxImportSource` and the
|
|
26
|
+
* set of foreign extensions collected from the app config.
|
|
27
|
+
*
|
|
28
|
+
* When no JSX-bearing foreign extensions are present, the returned plugin is a
|
|
29
|
+
* no-op so integrations can register it unconditionally.
|
|
30
|
+
*/
|
|
31
|
+
export declare function createForeignJsxOverridePlugin(options: ForeignJsxOverrideOptions): EcoBuildPlugin;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
function createForeignJsxOverridePlugin(options) {
|
|
4
|
+
const extensions = options.foreignExtensions.filter((ext) => ext.endsWith(".tsx") || ext.endsWith(".jsx"));
|
|
5
|
+
if (extensions.length === 0) {
|
|
6
|
+
return {
|
|
7
|
+
name: options.name ?? "foreign-jsx-override",
|
|
8
|
+
setup() {
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
const pragma = `/** @jsxImportSource ${options.hostJsxImportSource} */
|
|
13
|
+
`;
|
|
14
|
+
const filter = new RegExp(`(${extensions.map((e) => e.replace(".", "\\.")).join("|")})$`);
|
|
15
|
+
return {
|
|
16
|
+
name: options.name ?? "foreign-jsx-override",
|
|
17
|
+
setup(build) {
|
|
18
|
+
build.onLoad({ filter }, (args) => {
|
|
19
|
+
const source = readFileSync(args.path, "utf-8");
|
|
20
|
+
const loader = args.path.endsWith(".jsx") ? "jsx" : "tsx";
|
|
21
|
+
if (source.includes("@jsxImportSource")) {
|
|
22
|
+
return void 0;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
contents: pragma + source,
|
|
26
|
+
loader,
|
|
27
|
+
resolveDir: path.dirname(args.path)
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
createForeignJsxOverridePlugin
|
|
35
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EcoBuildPlugin } from '../build/build-types.js';
|
|
2
2
|
import type { EcoPagesAppConfig, IHmrManager } from '../types/internal-types.js';
|
|
3
3
|
import type { HmrStrategy } from '../hmr/hmr-strategy.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { EcoPagesElement } from '../types/public-types.js';
|
|
5
5
|
import type { IntegrationRenderer } from '../route-renderer/orchestration/integration-renderer.js';
|
|
6
6
|
import { AssetProcessingService } from '../services/assets/asset-processing-service/asset-processing.service.js';
|
|
7
7
|
import type { AssetDefinition, ProcessedAsset } from '../services/assets/asset-processing-service/assets.types.js';
|
|
@@ -11,6 +11,14 @@ export declare const INTEGRATION_PLUGIN_ERRORS: {
|
|
|
11
11
|
readonly NOT_INITIALIZED_WITH_APP_CONFIG: "Plugin not initialized with app config";
|
|
12
12
|
readonly NOT_INITIALIZED_WITH_ASSET_SERVICE: "Plugin not initialized with asset dependency service";
|
|
13
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Base configuration shared by all integration plugins.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Integrations declare their file ownership, optional runtime requirements, and
|
|
19
|
+
* any global assets or build-time contributions here. Runtime-only side effects
|
|
20
|
+
* belong in `setup()` rather than the constructor.
|
|
21
|
+
*/
|
|
14
22
|
export interface IntegrationPluginConfig {
|
|
15
23
|
/**
|
|
16
24
|
* The name of the integration plugin.
|
|
@@ -38,19 +46,16 @@ export interface IntegrationPluginConfig {
|
|
|
38
46
|
* app can start with this integration enabled.
|
|
39
47
|
*/
|
|
40
48
|
runtimeCapability?: RuntimeCapabilityDeclaration;
|
|
49
|
+
/**
|
|
50
|
+
* JSX import source owned by this integration.
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* This is primarily used by mixed-JSX flows where host-owned browser bundles
|
|
54
|
+
* need to preserve the correct JSX runtime for files claimed by the
|
|
55
|
+
* integration.
|
|
56
|
+
*/
|
|
41
57
|
jsxImportSource?: string;
|
|
42
58
|
}
|
|
43
|
-
/**
|
|
44
|
-
* Metadata used by integration-owned boundary policy.
|
|
45
|
-
*
|
|
46
|
-
* This payload describes the currently active integration pass together with the
|
|
47
|
-
* target component boundary being entered.
|
|
48
|
-
*/
|
|
49
|
-
export type ComponentBoundaryPolicyInput = {
|
|
50
|
-
currentIntegration: string;
|
|
51
|
-
targetIntegration?: string;
|
|
52
|
-
component: EcoComponent;
|
|
53
|
-
};
|
|
54
59
|
type RendererClass<C> = new (options: {
|
|
55
60
|
appConfig: EcoPagesAppConfig;
|
|
56
61
|
assetProcessingService: AssetProcessingService;
|
|
@@ -58,6 +63,19 @@ type RendererClass<C> = new (options: {
|
|
|
58
63
|
rendererModules?: unknown;
|
|
59
64
|
runtimeOrigin: string;
|
|
60
65
|
}) => IntegrationRenderer<C>;
|
|
66
|
+
/**
|
|
67
|
+
* Base class for framework integrations.
|
|
68
|
+
*
|
|
69
|
+
* @remarks
|
|
70
|
+
* An integration owns three main concerns:
|
|
71
|
+
* - which file extensions it claims
|
|
72
|
+
* - which renderer class turns those files into HTML
|
|
73
|
+
* - which build-time or runtime contributions must be registered for that framework
|
|
74
|
+
*
|
|
75
|
+
* Core owns lifecycle ordering. Integrations declare contributions through the
|
|
76
|
+
* hooks on this class, while `ConfigBuilder.build()` and app startup decide when
|
|
77
|
+
* those hooks run.
|
|
78
|
+
*/
|
|
61
79
|
export declare abstract class IntegrationPlugin<C = EcoPagesElement> {
|
|
62
80
|
readonly name: string;
|
|
63
81
|
readonly extensions: string[];
|
|
@@ -73,8 +91,33 @@ export declare abstract class IntegrationPlugin<C = EcoPagesElement> {
|
|
|
73
91
|
protected hmrManager?: IHmrManager;
|
|
74
92
|
runtimeOrigin: string;
|
|
75
93
|
get plugins(): EcoBuildPlugin[];
|
|
94
|
+
/**
|
|
95
|
+
* Returns build plugins that should only apply to browser-oriented bundles.
|
|
96
|
+
*
|
|
97
|
+
* @remarks
|
|
98
|
+
* Browser-only transforms such as runtime import aliasing belong here so they
|
|
99
|
+
* do not affect server bundles or static-page module generation.
|
|
100
|
+
*/
|
|
101
|
+
get browserBuildPlugins(): EcoBuildPlugin[];
|
|
102
|
+
/**
|
|
103
|
+
* Creates the integration with static declaration-only configuration.
|
|
104
|
+
*
|
|
105
|
+
* @remarks
|
|
106
|
+
* Constructors are expected to stay side-effect free. Build-manifest
|
|
107
|
+
* contributions belong in `prepareBuildContributions()` and runtime-only setup
|
|
108
|
+
* belongs in `setup()`.
|
|
109
|
+
*/
|
|
76
110
|
constructor(config: IntegrationPluginConfig);
|
|
111
|
+
/**
|
|
112
|
+
* Attaches the finalized app config to the integration.
|
|
113
|
+
*
|
|
114
|
+
* Core calls this during config finalization before runtime setup so the
|
|
115
|
+
* integration can resolve asset paths and other app-owned services later.
|
|
116
|
+
*/
|
|
77
117
|
setConfig(appConfig: EcoPagesAppConfig): void;
|
|
118
|
+
/**
|
|
119
|
+
* Records the runtime origin used for page-module loading and renderer setup.
|
|
120
|
+
*/
|
|
78
121
|
setRuntimeOrigin(runtimeOrigin: string): void;
|
|
79
122
|
/**
|
|
80
123
|
* Returns an HMR strategy for this integration, if applicable.
|
|
@@ -96,8 +139,8 @@ export declare abstract class IntegrationPlugin<C = EcoPagesElement> {
|
|
|
96
139
|
* runtime specifier registry.
|
|
97
140
|
*
|
|
98
141
|
* @remarks
|
|
99
|
-
*
|
|
100
|
-
*
|
|
142
|
+
* Integrations that own browser runtime bundles can override this to expose
|
|
143
|
+
* stable bare specifiers for client-side imports.
|
|
101
144
|
*
|
|
102
145
|
* Today these mappings are consumed by the development runtime and browser
|
|
103
146
|
* bundle aliasing path. They are intentionally generic enough to grow into a
|
|
@@ -105,31 +148,41 @@ export declare abstract class IntegrationPlugin<C = EcoPagesElement> {
|
|
|
105
148
|
* map contents into core.
|
|
106
149
|
*/
|
|
107
150
|
getRuntimeSpecifierMap(): Record<string, string>;
|
|
151
|
+
/**
|
|
152
|
+
* Attaches the shared HMR manager and registers integration-owned development hooks.
|
|
153
|
+
*
|
|
154
|
+
* @remarks
|
|
155
|
+
* The default implementation registers both runtime bare-specifier mappings and
|
|
156
|
+
* the optional integration HMR strategy. Integrations should override this only
|
|
157
|
+
* when they need to extend that shared behavior rather than replace it.
|
|
158
|
+
*/
|
|
108
159
|
setHmrManager(hmrManager: IHmrManager): void;
|
|
160
|
+
/**
|
|
161
|
+
* Creates the asset-processing service used for global integration dependencies.
|
|
162
|
+
*/
|
|
109
163
|
initializeAssetDefinitionService(): void;
|
|
164
|
+
/**
|
|
165
|
+
* Returns processed global assets resolved during `setup()`.
|
|
166
|
+
*/
|
|
110
167
|
getResolvedIntegrationDependencies(): ProcessedAsset[];
|
|
111
|
-
initializeRenderer(options?: {
|
|
112
|
-
rendererModules?: unknown;
|
|
113
|
-
}): IntegrationRenderer<C>;
|
|
114
168
|
/**
|
|
115
|
-
*
|
|
116
|
-
* deferred through the marker pipeline.
|
|
169
|
+
* Instantiates the integration renderer with app-owned services.
|
|
117
170
|
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* @param input Boundary metadata for the current render pass.
|
|
123
|
-
* @returns `true` when the boundary should be deferred; otherwise `false`.
|
|
171
|
+
* @remarks
|
|
172
|
+
* Renderers are cheap runtime objects. They receive the finalized app config,
|
|
173
|
+
* a fresh asset-processing service, integration-global processed assets, and
|
|
174
|
+
* any renderer module context supplied by the active runtime.
|
|
124
175
|
*/
|
|
125
|
-
|
|
176
|
+
initializeRenderer(options?: {
|
|
177
|
+
rendererModules?: unknown;
|
|
178
|
+
}): IntegrationRenderer<C>;
|
|
126
179
|
/**
|
|
127
180
|
* Prepares build-facing contributions before the app build manifest is sealed.
|
|
128
181
|
*
|
|
129
182
|
* @remarks
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
183
|
+
* Integrations can override this when runtime or build plugin declarations must
|
|
184
|
+
* be materialized ahead of runtime startup. Runtime-only side effects stay in
|
|
185
|
+
* `setup()`.
|
|
133
186
|
*/
|
|
134
187
|
prepareBuildContributions(): Promise<void>;
|
|
135
188
|
/**
|
|
@@ -137,5 +190,13 @@ export declare abstract class IntegrationPlugin<C = EcoPagesElement> {
|
|
|
137
190
|
* sealed manifest contributions.
|
|
138
191
|
*/
|
|
139
192
|
setup(): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Releases runtime resources owned by the integration.
|
|
195
|
+
*
|
|
196
|
+
* @remarks
|
|
197
|
+
* Most integrations do not need custom teardown. Override this only for
|
|
198
|
+
* explicit cleanup such as watchers, compiler handles, or runtime registries
|
|
199
|
+
* that outlive individual requests.
|
|
200
|
+
*/
|
|
140
201
|
teardown(): Promise<void>;
|
|
141
202
|
}
|
|
@@ -18,6 +18,24 @@ class IntegrationPlugin {
|
|
|
18
18
|
get plugins() {
|
|
19
19
|
return [];
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns build plugins that should only apply to browser-oriented bundles.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* Browser-only transforms such as runtime import aliasing belong here so they
|
|
26
|
+
* do not affect server bundles or static-page module generation.
|
|
27
|
+
*/
|
|
28
|
+
get browserBuildPlugins() {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Creates the integration with static declaration-only configuration.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* Constructors are expected to stay side-effect free. Build-manifest
|
|
36
|
+
* contributions belong in `prepareBuildContributions()` and runtime-only setup
|
|
37
|
+
* belongs in `setup()`.
|
|
38
|
+
*/
|
|
21
39
|
constructor(config) {
|
|
22
40
|
this.name = config.name;
|
|
23
41
|
this.extensions = config.extensions;
|
|
@@ -26,10 +44,19 @@ class IntegrationPlugin {
|
|
|
26
44
|
this.runtimeCapability = config.runtimeCapability;
|
|
27
45
|
this.jsxImportSource = config.jsxImportSource;
|
|
28
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Attaches the finalized app config to the integration.
|
|
49
|
+
*
|
|
50
|
+
* Core calls this during config finalization before runtime setup so the
|
|
51
|
+
* integration can resolve asset paths and other app-owned services later.
|
|
52
|
+
*/
|
|
29
53
|
setConfig(appConfig) {
|
|
30
54
|
this.appConfig = appConfig;
|
|
31
55
|
this.initializeAssetDefinitionService();
|
|
32
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Records the runtime origin used for page-module loading and renderer setup.
|
|
59
|
+
*/
|
|
33
60
|
setRuntimeOrigin(runtimeOrigin) {
|
|
34
61
|
this.runtimeOrigin = runtimeOrigin;
|
|
35
62
|
}
|
|
@@ -38,8 +65,8 @@ class IntegrationPlugin {
|
|
|
38
65
|
* runtime specifier registry.
|
|
39
66
|
*
|
|
40
67
|
* @remarks
|
|
41
|
-
*
|
|
42
|
-
*
|
|
68
|
+
* Integrations that own browser runtime bundles can override this to expose
|
|
69
|
+
* stable bare specifiers for client-side imports.
|
|
43
70
|
*
|
|
44
71
|
* Today these mappings are consumed by the development runtime and browser
|
|
45
72
|
* bundle aliasing path. They are intentionally generic enough to grow into a
|
|
@@ -49,6 +76,14 @@ class IntegrationPlugin {
|
|
|
49
76
|
getRuntimeSpecifierMap() {
|
|
50
77
|
return {};
|
|
51
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Attaches the shared HMR manager and registers integration-owned development hooks.
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* The default implementation registers both runtime bare-specifier mappings and
|
|
84
|
+
* the optional integration HMR strategy. Integrations should override this only
|
|
85
|
+
* when they need to extend that shared behavior rather than replace it.
|
|
86
|
+
*/
|
|
52
87
|
setHmrManager(hmrManager) {
|
|
53
88
|
this.hmrManager = hmrManager;
|
|
54
89
|
hmrManager.registerSpecifierMap(this.getRuntimeSpecifierMap());
|
|
@@ -60,6 +95,9 @@ class IntegrationPlugin {
|
|
|
60
95
|
this.assetProcessingService.setHmrManager(hmrManager);
|
|
61
96
|
}
|
|
62
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Creates the asset-processing service used for global integration dependencies.
|
|
100
|
+
*/
|
|
63
101
|
initializeAssetDefinitionService() {
|
|
64
102
|
if (!this.appConfig) throw new Error(INTEGRATION_PLUGIN_ERRORS.NOT_INITIALIZED_WITH_APP_CONFIG);
|
|
65
103
|
this.assetProcessingService = AssetProcessingService.createWithDefaultProcessors(this.appConfig);
|
|
@@ -67,9 +105,20 @@ class IntegrationPlugin {
|
|
|
67
105
|
this.assetProcessingService.setHmrManager(this.hmrManager);
|
|
68
106
|
}
|
|
69
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Returns processed global assets resolved during `setup()`.
|
|
110
|
+
*/
|
|
70
111
|
getResolvedIntegrationDependencies() {
|
|
71
112
|
return this.resolvedIntegrationDependencies;
|
|
72
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Instantiates the integration renderer with app-owned services.
|
|
116
|
+
*
|
|
117
|
+
* @remarks
|
|
118
|
+
* Renderers are cheap runtime objects. They receive the finalized app config,
|
|
119
|
+
* a fresh asset-processing service, integration-global processed assets, and
|
|
120
|
+
* any renderer module context supplied by the active runtime.
|
|
121
|
+
*/
|
|
73
122
|
initializeRenderer(options) {
|
|
74
123
|
if (!this.appConfig) {
|
|
75
124
|
throw new Error(INTEGRATION_PLUGIN_ERRORS.NOT_INITIALIZED_WITH_APP_CONFIG);
|
|
@@ -91,27 +140,13 @@ class IntegrationPlugin {
|
|
|
91
140
|
}
|
|
92
141
|
return renderer;
|
|
93
142
|
}
|
|
94
|
-
/**
|
|
95
|
-
* Declares whether a component boundary targeting this integration should be
|
|
96
|
-
* deferred through the marker pipeline.
|
|
97
|
-
*
|
|
98
|
-
* The default implementation never defers. Integrations that require deferred
|
|
99
|
-
* subtree rendering should override this method and return `true` when their
|
|
100
|
-
* boundary must be resolved during the marker graph stage.
|
|
101
|
-
*
|
|
102
|
-
* @param input Boundary metadata for the current render pass.
|
|
103
|
-
* @returns `true` when the boundary should be deferred; otherwise `false`.
|
|
104
|
-
*/
|
|
105
|
-
shouldDeferComponentBoundary(_input) {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
143
|
/**
|
|
109
144
|
* Prepares build-facing contributions before the app build manifest is sealed.
|
|
110
145
|
*
|
|
111
146
|
* @remarks
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
147
|
+
* Integrations can override this when runtime or build plugin declarations must
|
|
148
|
+
* be materialized ahead of runtime startup. Runtime-only side effects stay in
|
|
149
|
+
* `setup()`.
|
|
115
150
|
*/
|
|
116
151
|
async prepareBuildContributions() {
|
|
117
152
|
}
|
|
@@ -128,6 +163,14 @@ class IntegrationPlugin {
|
|
|
128
163
|
);
|
|
129
164
|
this.initializeRenderer();
|
|
130
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Releases runtime resources owned by the integration.
|
|
168
|
+
*
|
|
169
|
+
* @remarks
|
|
170
|
+
* Most integrations do not need custom teardown. Override this only for
|
|
171
|
+
* explicit cleanup such as watchers, compiler handles, or runtime registries
|
|
172
|
+
* that outlive individual requests.
|
|
173
|
+
*/
|
|
131
174
|
async teardown() {
|
|
132
175
|
}
|
|
133
176
|
}
|