@bleedingdev/modern-js-renderer-core 3.9.3-ultramodern.8 → 3.9.3-ultramodern.9
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/dist/cjs/adapter.js +1 -1
- package/dist/cjs/entry-client.js +5 -0
- package/dist/cjs/federation.js +14 -5
- package/dist/cjs/server/worker.js +2 -1
- package/dist/cjs/worker-federation/contract.js +298 -0
- package/dist/cjs/worker-federation/handler.js +197 -0
- package/dist/cjs/worker-federation/index.js +63 -0
- package/dist/cjs/worker-federation/lease.js +167 -0
- package/dist/cjs/worker-federation/transport.js +272 -0
- package/dist/esm/adapter.mjs +1 -1
- package/dist/esm/entry-client.mjs +5 -0
- package/dist/esm/federation.mjs +14 -5
- package/dist/esm/server/worker.mjs +2 -1
- package/dist/esm/worker-federation/contract.mjs +227 -0
- package/dist/esm/worker-federation/handler.mjs +159 -0
- package/dist/esm/worker-federation/index.mjs +3 -0
- package/dist/esm/worker-federation/lease.mjs +107 -0
- package/dist/esm/worker-federation/transport.mjs +234 -0
- package/dist/esm-node/adapter.mjs +1 -1
- package/dist/esm-node/entry-client.mjs +5 -0
- package/dist/esm-node/federation.mjs +14 -5
- package/dist/esm-node/server/worker.mjs +2 -1
- package/dist/esm-node/worker-federation/contract.mjs +228 -0
- package/dist/esm-node/worker-federation/handler.mjs +160 -0
- package/dist/esm-node/worker-federation/index.mjs +4 -0
- package/dist/esm-node/worker-federation/lease.mjs +108 -0
- package/dist/esm-node/worker-federation/transport.mjs +235 -0
- package/dist/types/entry-client.d.ts +2 -0
- package/dist/types/federation.d.ts +15 -2
- package/dist/types/server/types.d.ts +3 -0
- package/dist/types/server/worker.d.ts +19 -0
- package/dist/types/worker-federation/contract.d.ts +70 -0
- package/dist/types/worker-federation/handler.d.ts +21 -0
- package/dist/types/worker-federation/index.d.ts +6 -0
- package/dist/types/worker-federation/lease.d.ts +11 -0
- package/dist/types/worker-federation/transport.d.ts +47 -0
- package/package.json +12 -2
- package/src/adapter.ts +3 -1
- package/src/entry-client.ts +5 -0
- package/src/federation.ts +36 -8
- package/src/server/types.ts +3 -0
- package/src/server/worker.ts +23 -0
- package/src/worker-federation/contract.ts +449 -0
- package/src/worker-federation/handler.ts +274 -0
- package/src/worker-federation/index.ts +23 -0
- package/src/worker-federation/lease.ts +143 -0
- package/src/worker-federation/transport.ts +430 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type RendererIdentity } from '../identity.js';
|
|
2
|
+
export declare const WORKER_FEDERATION_METADATA_KEY = "ultramodernWorkerFederation";
|
|
3
|
+
export declare const WORKER_FEDERATION_SCHEMA = "ultramodern.worker-federation";
|
|
4
|
+
export declare const WORKER_FEDERATION_VERSION = 1;
|
|
5
|
+
export interface WorkerFederationExpose {
|
|
6
|
+
readonly entryName: string;
|
|
7
|
+
readonly boundaryId: string;
|
|
8
|
+
readonly paths: Readonly<Record<string, string>>;
|
|
9
|
+
readonly native: {
|
|
10
|
+
readonly publisherBuildId: string;
|
|
11
|
+
readonly runtimeABI: 1;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface WorkerFederationPublication {
|
|
15
|
+
readonly schema: typeof WORKER_FEDERATION_SCHEMA;
|
|
16
|
+
readonly schemaVersion: typeof WORKER_FEDERATION_VERSION;
|
|
17
|
+
readonly remote: string;
|
|
18
|
+
readonly exposes: Readonly<Record<string, WorkerFederationExpose>>;
|
|
19
|
+
}
|
|
20
|
+
/** The canonical renderer-contract reader and compatibility check are required. */
|
|
21
|
+
export type AdmitWorkerRendererContract = (value: unknown) => {
|
|
22
|
+
readonly identities: Readonly<Record<string, RendererIdentity>>;
|
|
23
|
+
};
|
|
24
|
+
export interface WorkerFederationAuthority {
|
|
25
|
+
readonly origin: string;
|
|
26
|
+
readonly renderer: ReturnType<AdmitWorkerRendererContract>;
|
|
27
|
+
readonly worker: WorkerFederationPublication;
|
|
28
|
+
}
|
|
29
|
+
export interface AdmittedWorkerFederationExpose {
|
|
30
|
+
readonly authority: WorkerFederationAuthority;
|
|
31
|
+
readonly expose: string;
|
|
32
|
+
readonly locale: string;
|
|
33
|
+
readonly coordinate: WorkerFederationExpose;
|
|
34
|
+
readonly path: string;
|
|
35
|
+
readonly identity: Readonly<RendererIdentity>;
|
|
36
|
+
readonly endpoint: string;
|
|
37
|
+
/** Browser styles captured from this exact admitted manifest/expose. */
|
|
38
|
+
readonly styles: readonly string[];
|
|
39
|
+
}
|
|
40
|
+
export interface WorkerFederationEnvelope {
|
|
41
|
+
readonly schema: 'ultramodern.worker-federation-request' | 'ultramodern.worker-federation-response';
|
|
42
|
+
readonly schemaVersion: 1;
|
|
43
|
+
readonly authority: WorkerFederationAuthority;
|
|
44
|
+
readonly expose: string;
|
|
45
|
+
readonly locale: string;
|
|
46
|
+
/** Encoded and decoded by the native renderer; the framework never reads it. */
|
|
47
|
+
readonly payload: unknown;
|
|
48
|
+
}
|
|
49
|
+
export declare function workerFederationRecord(value: unknown, label: string): Record<string, unknown>;
|
|
50
|
+
export declare function readWorkerFederationPath(value: unknown): string;
|
|
51
|
+
export declare function readWorkerFederationManifestUrl(value: string): URL;
|
|
52
|
+
export declare function readWorkerFederationPublication(value: unknown, identities: Readonly<Record<string, RendererIdentity>>): WorkerFederationPublication;
|
|
53
|
+
/** Stable JSON also prevents non-wire values from silently changing on POST. */
|
|
54
|
+
export declare function workerFederationWireJson(value: unknown): string;
|
|
55
|
+
/** Preserve the completed MF browser publicPath/asset URL semantics. */
|
|
56
|
+
export declare function readWorkerFederationStyles(options: {
|
|
57
|
+
manifest: unknown;
|
|
58
|
+
manifestUrl: string;
|
|
59
|
+
expose: string;
|
|
60
|
+
}): readonly string[];
|
|
61
|
+
export declare function admitWorkerFederationExpose(options: {
|
|
62
|
+
manifest: unknown;
|
|
63
|
+
manifestUrl: string;
|
|
64
|
+
remote: string;
|
|
65
|
+
expose: string;
|
|
66
|
+
locale: string;
|
|
67
|
+
admitRendererContract: AdmitWorkerRendererContract;
|
|
68
|
+
}): AdmittedWorkerFederationExpose;
|
|
69
|
+
export declare function workerFederationEnvelope(kind: 'request' | 'response', admitted: AdmittedWorkerFederationExpose, payload: unknown): WorkerFederationEnvelope;
|
|
70
|
+
export declare function readWorkerFederationEnvelope(value: unknown, kind: 'request' | 'response', admitted: AdmittedWorkerFederationExpose): unknown;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type AdmittedWorkerFederationExpose, type AdmitWorkerRendererContract } from './contract.js';
|
|
2
|
+
export interface WorkerFederationExecution {
|
|
3
|
+
readonly admitted: AdmittedWorkerFederationExpose;
|
|
4
|
+
readonly signal: AbortSignal;
|
|
5
|
+
}
|
|
6
|
+
/** Bind once to the compiled registry and this Worker's own publication. */
|
|
7
|
+
export declare function createWorkerFederationHandler<NativeRequest>(options: {
|
|
8
|
+
publication: {
|
|
9
|
+
readonly renderer: unknown;
|
|
10
|
+
readonly worker: unknown;
|
|
11
|
+
};
|
|
12
|
+
manifestUrl: string;
|
|
13
|
+
exposes: Readonly<Record<string, () => Promise<unknown>>>;
|
|
14
|
+
admitRendererContract: AdmitWorkerRendererContract;
|
|
15
|
+
/** Native codec admission runs before even loading the exposed module. */
|
|
16
|
+
admitNativeRequest(payload: unknown, execution: WorkerFederationExecution): NativeRequest | Promise<NativeRequest>;
|
|
17
|
+
/** Close the admitted native lease, including a preparation resolving after abort. */
|
|
18
|
+
releaseNativeRequest(request: NativeRequest): void | Promise<void>;
|
|
19
|
+
renderNativeSnapshot(module: unknown, request: NativeRequest, execution: WorkerFederationExecution): unknown | Promise<unknown>;
|
|
20
|
+
requestTimeout?: number;
|
|
21
|
+
}): (request: Request) => Promise<Response | undefined>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { AdmittedWorkerFederationExpose, AdmitWorkerRendererContract, WorkerFederationAuthority, WorkerFederationExpose, WorkerFederationPublication, } from './contract.js';
|
|
2
|
+
export { readWorkerFederationManifestUrl, readWorkerFederationPath, readWorkerFederationPublication, WORKER_FEDERATION_METADATA_KEY, WORKER_FEDERATION_SCHEMA, WORKER_FEDERATION_VERSION, } from './contract.js';
|
|
3
|
+
export type { WorkerFederationExecution } from './handler.js';
|
|
4
|
+
export { createWorkerFederationHandler } from './handler.js';
|
|
5
|
+
export type { WorkerFederationService, WorkerFederationSnapshot, WorkerFederationTransport, } from './transport.js';
|
|
6
|
+
export { createWorkerFederationTransport } from './transport.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function checkWorkerFederationDeadline(deadlineAt: number, signal?: AbortSignal, controller?: AbortController): void;
|
|
2
|
+
export declare function workerFederationErrorMessage(error: unknown, fallback: string, maxLength?: number): string;
|
|
3
|
+
export declare function workerAbortReason(signal: AbortSignal): unknown;
|
|
4
|
+
export declare function workerAbortable<T>(operation: Promise<T>, signal: AbortSignal): Promise<T>;
|
|
5
|
+
export declare function readWorkerFederationJsonBody(body: ReadableStream<Uint8Array>, signal: AbortSignal, contentLength?: string | null, checkDeadline?: () => void): Promise<unknown>;
|
|
6
|
+
export declare const WORKER_FEDERATION_MAX_BODY_BYTES: number;
|
|
7
|
+
export declare class WorkerFederationBodyTooLargeError extends Error {
|
|
8
|
+
constructor();
|
|
9
|
+
}
|
|
10
|
+
/** Count UTF-8 bytes without allocating a second encoded body. */
|
|
11
|
+
export declare function assertWorkerFederationBodySize(value: string): string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type AdmittedWorkerFederationExpose, type AdmitWorkerRendererContract } from './contract.js';
|
|
2
|
+
export interface WorkerFederationService {
|
|
3
|
+
readonly remote: string;
|
|
4
|
+
/** Existing MF import alias, mapped to the pinned topology publisher. */
|
|
5
|
+
readonly alias?: string;
|
|
6
|
+
readonly manifestUrl: string;
|
|
7
|
+
readonly fragments: readonly {
|
|
8
|
+
readonly expose: string;
|
|
9
|
+
readonly boundaryId: string;
|
|
10
|
+
readonly paths: Readonly<Record<string, string>>;
|
|
11
|
+
}[];
|
|
12
|
+
/** A configured Workers service binding, never a caller-selected fetch target. */
|
|
13
|
+
fetch(request: Request): Promise<Response>;
|
|
14
|
+
}
|
|
15
|
+
export interface WorkerFederationSnapshot {
|
|
16
|
+
readonly admitted: AdmittedWorkerFederationExpose;
|
|
17
|
+
readonly payload: unknown;
|
|
18
|
+
}
|
|
19
|
+
export interface WorkerFederationTransport {
|
|
20
|
+
/** Retire the owning document, its authorities and outstanding requests. */
|
|
21
|
+
dispose(reason?: unknown): void;
|
|
22
|
+
/** Admit lazily before constructing the native snapshot boundary. */
|
|
23
|
+
admit(options: {
|
|
24
|
+
remote: string;
|
|
25
|
+
expose: string;
|
|
26
|
+
locale: string;
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
}): Promise<AdmittedWorkerFederationExpose>;
|
|
29
|
+
/** Deduplicate active requests only; the native boundary owns settled snapshots. */
|
|
30
|
+
request(options: {
|
|
31
|
+
remote: string;
|
|
32
|
+
expose: string;
|
|
33
|
+
locale: string;
|
|
34
|
+
/** Already encoded by the renderer's native wire codec. */
|
|
35
|
+
payload: unknown;
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
}): Promise<WorkerFederationSnapshot>;
|
|
38
|
+
}
|
|
39
|
+
export declare function createWorkerFederationTransport(options: {
|
|
40
|
+
services: readonly WorkerFederationService[];
|
|
41
|
+
admitRendererContract: AdmitWorkerRendererContract;
|
|
42
|
+
fetchManifest?: (request: Request) => Promise<Response>;
|
|
43
|
+
/** One lease covers manifest headers/body and snapshot headers/body. */
|
|
44
|
+
requestTimeout?: number;
|
|
45
|
+
/** The document handle owns this transport's complete lifetime. */
|
|
46
|
+
signal?: AbortSignal;
|
|
47
|
+
}): WorkerFederationTransport;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bleedingdev/modern-js-renderer-core",
|
|
3
|
-
"version": "3.9.3-ultramodern.
|
|
3
|
+
"version": "3.9.3-ultramodern.9",
|
|
4
4
|
"description": "UltraModern native renderer request, data and document contracts.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -106,6 +106,16 @@
|
|
|
106
106
|
"default": "./dist/cjs/server/index.js"
|
|
107
107
|
}
|
|
108
108
|
},
|
|
109
|
+
"./worker-federation": {
|
|
110
|
+
"import": {
|
|
111
|
+
"types": "./dist/types/worker-federation/index.d.ts",
|
|
112
|
+
"default": "./dist/esm/worker-federation/index.mjs"
|
|
113
|
+
},
|
|
114
|
+
"require": {
|
|
115
|
+
"types": "./dist/types/worker-federation/index.d.ts",
|
|
116
|
+
"default": "./dist/cjs/worker-federation/index.js"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
109
119
|
"./entry-client": {
|
|
110
120
|
"import": {
|
|
111
121
|
"types": "./dist/types/entry-client.d.ts",
|
|
@@ -142,7 +152,7 @@
|
|
|
142
152
|
}
|
|
143
153
|
},
|
|
144
154
|
"devDependencies": {
|
|
145
|
-
"@modern-js/tsconfig": "npm:@bleedingdev/modern-js-tsconfig@3.9.3-ultramodern.
|
|
155
|
+
"@modern-js/tsconfig": "npm:@bleedingdev/modern-js-tsconfig@3.9.3-ultramodern.9",
|
|
146
156
|
"@rsbuild/core": "2.2.13",
|
|
147
157
|
"@rslib/core": "1.0.3",
|
|
148
158
|
"@scripts/rstest-config": "2.66.0",
|
package/src/adapter.ts
CHANGED
|
@@ -250,6 +250,8 @@ export function nativeRendererDependencies(
|
|
|
250
250
|
([name]) => !name.startsWith('@modern-js/'),
|
|
251
251
|
),
|
|
252
252
|
),
|
|
253
|
-
[profile.router.coreName]:
|
|
253
|
+
[profile.router.coreName]:
|
|
254
|
+
profile.dependencies[profile.router.coreName] ??
|
|
255
|
+
profile.router.coreVersion,
|
|
254
256
|
};
|
|
255
257
|
}
|
package/src/entry-client.ts
CHANGED
|
@@ -78,6 +78,8 @@ export interface NativeClientAdapter<
|
|
|
78
78
|
application: NativeRoutedApplication,
|
|
79
79
|
options: NativeRouterOptions,
|
|
80
80
|
): Router;
|
|
81
|
+
/** Release the router and browser history created for this entry. */
|
|
82
|
+
disposeRouter(router: Router): void;
|
|
81
83
|
/** Load a fresh router, or adopt the server's matches when hydrating. */
|
|
82
84
|
prepareRouter(
|
|
83
85
|
router: Router,
|
|
@@ -197,6 +199,9 @@ export function startNativeClientEntry<
|
|
|
197
199
|
? { rewrite: i18n.rewrite(() => current.language) }
|
|
198
200
|
: {}),
|
|
199
201
|
});
|
|
202
|
+
const releaseRouter = () => adapter.disposeRouter(router);
|
|
203
|
+
if (signal.aborted) releaseRouter();
|
|
204
|
+
else signal.addEventListener('abort', releaseRouter, { once: true });
|
|
200
205
|
// HMR disposal aborts the signal; a failed start stops the sync too.
|
|
201
206
|
const stopSync =
|
|
202
207
|
i18n && current ? i18n.syncWithRouter(router, current) : undefined;
|
package/src/federation.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
/** The Node dev runtime captures assets before releasing a container load. */
|
|
2
|
+
const LOAD_WITH_CAPTURE = Symbol.for(
|
|
3
|
+
'ultramodern.federation.load-with-capture',
|
|
4
|
+
);
|
|
5
|
+
|
|
1
6
|
/** The application compiler's native Module Federation runtime. */
|
|
2
7
|
export interface FederationInstance {
|
|
3
8
|
/** The application's federation name, unique among this realm's instances. */
|
|
4
9
|
readonly name?: string;
|
|
5
10
|
loadRemote<T>(id: string): Promise<T | null>;
|
|
11
|
+
[LOAD_WITH_CAPTURE]?: <T, Captured>(
|
|
12
|
+
id: string,
|
|
13
|
+
capture: (module: T | null, resolution?: LoadResolution) => Captured,
|
|
14
|
+
) => Promise<{ module: T | null; captured: Captured | undefined }>;
|
|
6
15
|
readonly remoteHandler?: {
|
|
7
16
|
readonly idToRemoteMap?: Record<string, { name: string; expose: string }>;
|
|
8
17
|
};
|
|
@@ -27,6 +36,11 @@ interface RemoteSnapshot {
|
|
|
27
36
|
}[];
|
|
28
37
|
}
|
|
29
38
|
|
|
39
|
+
interface LoadResolution {
|
|
40
|
+
readonly remoteSnapshot: unknown;
|
|
41
|
+
readonly expose: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
30
44
|
/** Generated entries retain their own compiler's host, including on the server. */
|
|
31
45
|
export interface NativeFederationBinding {
|
|
32
46
|
readonly instance: () => FederationInstance;
|
|
@@ -59,27 +73,41 @@ export function getFederationHost(
|
|
|
59
73
|
export async function loadFederatedModule<T>(
|
|
60
74
|
instance: FederationInstance | undefined,
|
|
61
75
|
id: string,
|
|
62
|
-
): Promise<T> {
|
|
76
|
+
): Promise<{ module: T; assets: FederatedAssets | undefined }> {
|
|
63
77
|
if (!instance)
|
|
64
78
|
throw new Error(
|
|
65
79
|
`Cannot load ${id}: this application has no Module Federation runtime. Add module-federation.config.ts with its remotes.`,
|
|
66
80
|
);
|
|
67
|
-
const
|
|
81
|
+
const coupledLoad = instance[LOAD_WITH_CAPTURE];
|
|
82
|
+
const result = coupledLoad
|
|
83
|
+
? await coupledLoad<T, FederatedAssets | undefined>(
|
|
84
|
+
id,
|
|
85
|
+
(_module, resolution) => remoteBrowserAssets(instance, id, resolution),
|
|
86
|
+
)
|
|
87
|
+
: {
|
|
88
|
+
module: await instance.loadRemote<T>(id),
|
|
89
|
+
captured: remoteBrowserAssets(instance, id),
|
|
90
|
+
};
|
|
91
|
+
const module = result.module;
|
|
68
92
|
if (!module) throw new Error(`Remote module ${id} is unavailable`);
|
|
69
|
-
return module;
|
|
93
|
+
return { module, assets: result.captured };
|
|
70
94
|
}
|
|
71
95
|
|
|
72
96
|
/** Browser assets from the native snapshot that admitted and loaded this remote. */
|
|
73
97
|
export function remoteBrowserAssets(
|
|
74
98
|
instance: FederationInstance,
|
|
75
99
|
id: string,
|
|
100
|
+
resolution?: LoadResolution,
|
|
76
101
|
): FederatedAssets | undefined {
|
|
77
102
|
const target = instance.remoteHandler?.idToRemoteMap?.[id];
|
|
78
103
|
const loaded = target && instance.moduleCache?.get(target.name);
|
|
79
|
-
const snapshot =
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
104
|
+
const snapshot = (
|
|
105
|
+
resolution
|
|
106
|
+
? resolution.remoteSnapshot
|
|
107
|
+
: loaded &&
|
|
108
|
+
instance.snapshotHandler?.getGlobalRemoteInfo(loaded.remoteInfo)
|
|
109
|
+
.remoteSnapshot
|
|
110
|
+
) as RemoteSnapshot | undefined;
|
|
83
111
|
if (
|
|
84
112
|
!snapshot ||
|
|
85
113
|
typeof snapshot.publicPath !== 'string' ||
|
|
@@ -89,7 +117,7 @@ export function remoteBrowserAssets(
|
|
|
89
117
|
)
|
|
90
118
|
return undefined;
|
|
91
119
|
const expose = snapshot.modules?.find(
|
|
92
|
-
module => module.modulePath === target
|
|
120
|
+
module => module.modulePath === (resolution?.expose ?? target?.expose),
|
|
93
121
|
);
|
|
94
122
|
if (!expose?.assets) return undefined;
|
|
95
123
|
const publicPath = snapshot.publicPath;
|
package/src/server/types.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DocumentAsset } from '../document';
|
|
2
2
|
import type { RendererIdentity } from '../identity';
|
|
3
3
|
import type { RequestPlatform, RequestSession } from '../session';
|
|
4
|
+
import type { WorkerFederationTransport } from '../worker-federation';
|
|
4
5
|
|
|
5
6
|
/** Native route matching remains with the selected router adapter. */
|
|
6
7
|
export interface NativeServerConfig {
|
|
@@ -17,6 +18,8 @@ export interface NativeRequestContext<Bindings extends object = object> {
|
|
|
17
18
|
readonly nativeManifest?: unknown;
|
|
18
19
|
readonly serverConfig?: NativeServerConfig;
|
|
19
20
|
readonly entry: Readonly<RendererIdentity>;
|
|
21
|
+
/** Request-owned service transport for native Worker snapshot boundaries. */
|
|
22
|
+
readonly workerFederation?: WorkerFederationTransport;
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
export type NativeRequestHandler<Bindings extends object = object> = (
|
package/src/server/worker.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { collectDocumentAssets, type DocumentAsset } from '../document';
|
|
2
2
|
import { assertRendererIdentity, type RendererIdentity } from '../identity';
|
|
3
|
+
import type {
|
|
4
|
+
WorkerFederationPublication,
|
|
5
|
+
WorkerFederationTransport,
|
|
6
|
+
} from '../worker-federation';
|
|
3
7
|
import { dispatchNativeRequest, rejectNativeRscRequest } from './dispatch';
|
|
4
8
|
import type {
|
|
5
9
|
NativeExecutionContext,
|
|
@@ -17,6 +21,22 @@ export interface NativeWorkerEntryResources {
|
|
|
17
21
|
/** Present only when the entry admits a CSR fallback request. */
|
|
18
22
|
readonly csrFallbackHeader?: string;
|
|
19
23
|
readonly nonce?: string;
|
|
24
|
+
readonly workerFederation?: {
|
|
25
|
+
readonly renderer: unknown;
|
|
26
|
+
readonly worker: WorkerFederationPublication;
|
|
27
|
+
};
|
|
28
|
+
readonly workerFederationManifestUrl?: string;
|
|
29
|
+
readonly workerFederationServices?: readonly {
|
|
30
|
+
readonly remote: string;
|
|
31
|
+
readonly alias?: string;
|
|
32
|
+
readonly manifestUrl: string;
|
|
33
|
+
readonly binding: string;
|
|
34
|
+
readonly fragments: readonly {
|
|
35
|
+
readonly expose: string;
|
|
36
|
+
readonly boundaryId: string;
|
|
37
|
+
readonly paths: Readonly<Record<string, string>>;
|
|
38
|
+
}[];
|
|
39
|
+
}[];
|
|
20
40
|
}
|
|
21
41
|
|
|
22
42
|
export interface NativeWorkerDispatchOptions<Bindings extends object> {
|
|
@@ -27,6 +47,8 @@ export interface NativeWorkerDispatchOptions<Bindings extends object> {
|
|
|
27
47
|
/** The module worker `env`, forwarded unchanged as the platform binding. */
|
|
28
48
|
readonly bindings: Bindings | undefined;
|
|
29
49
|
readonly executionContext?: NativeExecutionContext;
|
|
50
|
+
/** Constructed by this compiled renderer entry for this document only. */
|
|
51
|
+
readonly workerFederation?: WorkerFederationTransport;
|
|
30
52
|
}
|
|
31
53
|
|
|
32
54
|
function workerManifest<Bindings extends object>(
|
|
@@ -89,6 +111,7 @@ export function dispatchNativeWorkerRequest<Bindings extends object>(
|
|
|
89
111
|
bindings,
|
|
90
112
|
serverConfig: { ...resources.serverConfig, forceCSR },
|
|
91
113
|
nonce: resources.nonce,
|
|
114
|
+
workerFederation: options.workerFederation,
|
|
92
115
|
},
|
|
93
116
|
});
|
|
94
117
|
}
|