@plugmatica/plugin-sdk 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +136 -2
- package/dist/advanced.d.ts +315 -0
- package/dist/advanced.js +3 -0
- package/dist/advanced.js.map +1 -0
- package/dist/chunk-ACHELRPS.js +182 -0
- package/dist/chunk-ACHELRPS.js.map +1 -0
- package/dist/chunk-AFVR6B2A.js +256 -0
- package/dist/chunk-AFVR6B2A.js.map +1 -0
- package/dist/chunk-YY4H56JF.js +84 -0
- package/dist/chunk-YY4H56JF.js.map +1 -0
- package/dist/extension-index.d.ts +178 -0
- package/dist/extension-index.js +3 -0
- package/dist/extension-index.js.map +1 -0
- package/dist/host.d.ts +859 -0
- package/dist/host.js +2280 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +1465 -0
- package/dist/index.js +749 -0
- package/dist/index.js.map +1 -0
- package/dist/types-83DpQEKd.d.ts +599 -0
- package/package.json +107 -4
package/dist/host.d.ts
ADDED
|
@@ -0,0 +1,859 @@
|
|
|
1
|
+
import { ExtensionKind, ExtensionSurface, RuntimeOperationHookExtension, RuntimeEventHandlerExtension, RuntimeProviderExtension, RuntimeUiExtension } from '@plugmatica/core-sdk';
|
|
2
|
+
import { UiExtensionOperationResult, UiResolvedContribution } from '@plugmatica/ui-kit/host';
|
|
3
|
+
import { ExtensionIndexReadOnly } from './extension-index.js';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { ReactNode } from 'react';
|
|
6
|
+
import { RenderableUiExtensionModule } from './advanced.js';
|
|
7
|
+
import { PluginRenderContext, FederatedPlugin } from './index.js';
|
|
8
|
+
import '@plugmatica/i18n';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Severity levels emitted by plugin frontend-facet runtime diagnostics.
|
|
12
|
+
*/
|
|
13
|
+
type PluginRuntimeEventLevel = "debug" | "info" | "warning" | "error";
|
|
14
|
+
/**
|
|
15
|
+
* Runtime subsystems that can emit plugin observer events.
|
|
16
|
+
*/
|
|
17
|
+
type PluginRuntimeEventArea = "plugin" | "federation" | "ui_component" | "ui_extension" | "operation_hook" | "event_handler" | "provider" | "api" | "i18n";
|
|
18
|
+
/**
|
|
19
|
+
* Structured frontend runtime event emitted to a host observer.
|
|
20
|
+
*/
|
|
21
|
+
type PluginRuntimeEventInput = {
|
|
22
|
+
/**
|
|
23
|
+
* Diagnostic severity.
|
|
24
|
+
*/
|
|
25
|
+
level: PluginRuntimeEventLevel;
|
|
26
|
+
/**
|
|
27
|
+
* Runtime subsystem emitting the event.
|
|
28
|
+
*/
|
|
29
|
+
area: PluginRuntimeEventArea;
|
|
30
|
+
/**
|
|
31
|
+
* Stable action name describing the runtime activity.
|
|
32
|
+
*/
|
|
33
|
+
action: string;
|
|
34
|
+
/**
|
|
35
|
+
* Resolution/job/runtime status.
|
|
36
|
+
*/
|
|
37
|
+
status?: "started" | "matched" | "skipped" | "completed" | "failed";
|
|
38
|
+
/**
|
|
39
|
+
* Human-readable diagnostic/error message.
|
|
40
|
+
*/
|
|
41
|
+
message: string;
|
|
42
|
+
/**
|
|
43
|
+
* Identifier of the plugin associated with this operation.
|
|
44
|
+
*/
|
|
45
|
+
pluginIdentifier?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Identifier of the plugin whose surface/operation is targeted.
|
|
48
|
+
*/
|
|
49
|
+
targetPluginIdentifier?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Stable runtime extension identifier.
|
|
52
|
+
*/
|
|
53
|
+
extensionId?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Extension kind associated with this plugin runtime event input.
|
|
56
|
+
*/
|
|
57
|
+
extensionKind?: ExtensionKind;
|
|
58
|
+
/**
|
|
59
|
+
* Semantic extension surface.
|
|
60
|
+
*/
|
|
61
|
+
surface?: ExtensionSurface;
|
|
62
|
+
/**
|
|
63
|
+
* Stable semantic key identifying the concrete surface.
|
|
64
|
+
*/
|
|
65
|
+
surfaceKey?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Runtime identity of the concrete mounted surface instance.
|
|
68
|
+
*/
|
|
69
|
+
instanceKey?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Extension point within the surface.
|
|
72
|
+
*/
|
|
73
|
+
point?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Operation associated with this plugin runtime event input.
|
|
76
|
+
*/
|
|
77
|
+
operation?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Operation/extension lifecycle phase.
|
|
80
|
+
*/
|
|
81
|
+
phase?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Event contract name.
|
|
84
|
+
*/
|
|
85
|
+
event?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Provider contract name.
|
|
88
|
+
*/
|
|
89
|
+
provider?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Module Federation expose name or generated contribution module path.
|
|
92
|
+
*/
|
|
93
|
+
module?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Current host route path when known.
|
|
96
|
+
*/
|
|
97
|
+
routePath?: string | null;
|
|
98
|
+
/**
|
|
99
|
+
* Elapsed duration in milliseconds when measured.
|
|
100
|
+
*/
|
|
101
|
+
durationMs?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Correlation identifier connecting related runtime events.
|
|
104
|
+
*/
|
|
105
|
+
correlationId?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Optional structured diagnostic details.
|
|
108
|
+
*/
|
|
109
|
+
details?: Record<string, unknown>;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Host observer contract for plugin frontend-facet runtime events.
|
|
113
|
+
*/
|
|
114
|
+
interface PluginRuntimeObserver {
|
|
115
|
+
/**
|
|
116
|
+
* Emit one structured runtime event to the host observer.
|
|
117
|
+
*
|
|
118
|
+
* @param event Event contract name.
|
|
119
|
+
*/
|
|
120
|
+
emit(event: PluginRuntimeEventInput): void;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Provide a host runtime observer to nested federation/extension infrastructure.
|
|
124
|
+
*
|
|
125
|
+
* @param props Component/provider properties.
|
|
126
|
+
* @returns Provider element wrapping the supplied children.
|
|
127
|
+
*/
|
|
128
|
+
declare function PluginRuntimeObserverProvider({ observer, children, }: {
|
|
129
|
+
observer: PluginRuntimeObserver | null;
|
|
130
|
+
children: React.ReactNode;
|
|
131
|
+
}): React.JSX.Element;
|
|
132
|
+
/**
|
|
133
|
+
* Return the nearest host runtime observer, if one is configured.
|
|
134
|
+
*
|
|
135
|
+
* @returns Nearest configured observer, or `null` when absent.
|
|
136
|
+
*/
|
|
137
|
+
declare function usePluginRuntimeObserver(): PluginRuntimeObserver | null;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Resolved Module Federation remote name and entry URL for a plugin.
|
|
141
|
+
*/
|
|
142
|
+
type FederatedRemoteDescriptor = {
|
|
143
|
+
/**
|
|
144
|
+
* Stable field/remote/contribution name.
|
|
145
|
+
*/
|
|
146
|
+
name: string;
|
|
147
|
+
/**
|
|
148
|
+
* Resolved remote entry URL.
|
|
149
|
+
*/
|
|
150
|
+
entry: string;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Host callback used to resolve a plugin identifier to a federated remote descriptor.
|
|
154
|
+
*
|
|
155
|
+
* @param pluginIdentifier Plugin identifier to resolve/load.
|
|
156
|
+
* @returns Result returned by ResolveFederatedRemote.
|
|
157
|
+
*/
|
|
158
|
+
type ResolveFederatedRemote = (pluginIdentifier: string) => FederatedRemoteDescriptor | null | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* Host callback used to load one exposed module from a federated plugin.
|
|
161
|
+
*
|
|
162
|
+
* @param pluginIdentifier Plugin identifier to resolve/load.
|
|
163
|
+
* @param module Module Federation expose name.
|
|
164
|
+
* @param remoteUrl Optional explicit remote entry URL.
|
|
165
|
+
* @param remoteName Optional explicit Module Federation remote name.
|
|
166
|
+
* @returns Result returned by FederatedModuleLoader.
|
|
167
|
+
*/
|
|
168
|
+
type FederatedModuleLoader = (pluginIdentifier: string, module: string, remoteUrl?: string, remoteName?: string) => Promise<unknown>;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Host dependencies required to execute operation hooks, event handlers and providers.
|
|
172
|
+
*/
|
|
173
|
+
type ExtensionExecutionRuntimeOptions = {
|
|
174
|
+
/**
|
|
175
|
+
* Identifier of the plugin whose surface/operation is targeted.
|
|
176
|
+
*/
|
|
177
|
+
targetPluginIdentifier: string;
|
|
178
|
+
/**
|
|
179
|
+
* Runtime extension index queried by the resolver/executor.
|
|
180
|
+
*/
|
|
181
|
+
extensionIndex: ExtensionIndexReadOnly;
|
|
182
|
+
/**
|
|
183
|
+
* Host render context used as the owner of resolved extensions.
|
|
184
|
+
*/
|
|
185
|
+
ownerContext: PluginRenderContext;
|
|
186
|
+
/**
|
|
187
|
+
* Host runtime observer used for diagnostics and tracing.
|
|
188
|
+
*/
|
|
189
|
+
observer?: PluginRuntimeObserver | null;
|
|
190
|
+
/**
|
|
191
|
+
* Resolve a plugin identifier to its Module Federation remote.
|
|
192
|
+
*
|
|
193
|
+
* @param pluginIdentifier Plugin identifier to resolve/load.
|
|
194
|
+
* @returns Result returned by resolveRemote.
|
|
195
|
+
*/
|
|
196
|
+
resolveRemote(pluginIdentifier: string): FederatedRemoteDescriptor | null | undefined;
|
|
197
|
+
/**
|
|
198
|
+
* Load one exposed module from a resolved federated remote.
|
|
199
|
+
*
|
|
200
|
+
* @param pluginIdentifier Plugin identifier to resolve/load.
|
|
201
|
+
* @param module Module Federation expose name.
|
|
202
|
+
* @param remoteUrl Optional explicit remote entry URL.
|
|
203
|
+
* @param remoteName Optional explicit Module Federation remote name.
|
|
204
|
+
* @returns Result returned by loadModule.
|
|
205
|
+
*/
|
|
206
|
+
loadModule?: FederatedModuleLoader;
|
|
207
|
+
/**
|
|
208
|
+
* Build the scoped plugin render context for one extension descriptor.
|
|
209
|
+
*
|
|
210
|
+
* @param item Runtime extension descriptor being resolved/executed.
|
|
211
|
+
* @returns Result returned by resolveContext.
|
|
212
|
+
*/
|
|
213
|
+
resolveContext(item: RuntimeOperationHookExtension | RuntimeEventHandlerExtension | RuntimeProviderExtension): PluginRenderContext;
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* Host runtime that loads and executes non-UI extension modules against an extension index.
|
|
217
|
+
*/
|
|
218
|
+
declare class ExtensionExecutionRuntime {
|
|
219
|
+
#private;
|
|
220
|
+
constructor(options: ExtensionExecutionRuntimeOptions);
|
|
221
|
+
/**
|
|
222
|
+
* Execute one host operation through matched operation hooks.
|
|
223
|
+
*
|
|
224
|
+
* @param request Request payload/options for this operation.
|
|
225
|
+
* @returns Result returned by runOperation.
|
|
226
|
+
*/
|
|
227
|
+
runOperation<TPayload, TResult>(request: {
|
|
228
|
+
surface: ExtensionSurface;
|
|
229
|
+
surfaceKey: string;
|
|
230
|
+
instanceKey?: string;
|
|
231
|
+
extensionContext?: unknown;
|
|
232
|
+
operation: string;
|
|
233
|
+
payload: TPayload;
|
|
234
|
+
execute(payload: TPayload): TResult | Promise<TResult>;
|
|
235
|
+
signal?: AbortSignal;
|
|
236
|
+
}): Promise<UiExtensionOperationResult<TResult>>;
|
|
237
|
+
/**
|
|
238
|
+
* Emit one event through all matched event handlers.
|
|
239
|
+
*
|
|
240
|
+
* @param request Request payload/options for this operation.
|
|
241
|
+
* @returns Completes when the operation finishes.
|
|
242
|
+
*/
|
|
243
|
+
emitEvent<TPayload>(request: {
|
|
244
|
+
event: string;
|
|
245
|
+
payload: TPayload;
|
|
246
|
+
signal?: AbortSignal;
|
|
247
|
+
}): Promise<void>;
|
|
248
|
+
/**
|
|
249
|
+
* Resolve values from all providers matching one provider request.
|
|
250
|
+
*
|
|
251
|
+
* @param request Request payload/options for this operation.
|
|
252
|
+
* @returns Result returned by resolveProviders.
|
|
253
|
+
*/
|
|
254
|
+
resolveProviders<TRequest, TValue>(request: {
|
|
255
|
+
provider: string;
|
|
256
|
+
request: TRequest;
|
|
257
|
+
signal?: AbortSignal;
|
|
258
|
+
}): Promise<TValue[]>;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Stable failure codes for federated plugin module loading.
|
|
263
|
+
*/
|
|
264
|
+
type FederatedModuleLoadErrorCode = "invalid_module" | "federation_unavailable" | "remote_unavailable" | "stale_manifest_module_mismatch" | "empty_module";
|
|
265
|
+
/**
|
|
266
|
+
* Normalized error thrown when a federated plugin module cannot be loaded.
|
|
267
|
+
*/
|
|
268
|
+
declare class FederatedModuleLoadError extends Error {
|
|
269
|
+
/**
|
|
270
|
+
* Stable machine-readable code.
|
|
271
|
+
*/
|
|
272
|
+
readonly code: FederatedModuleLoadErrorCode;
|
|
273
|
+
/**
|
|
274
|
+
* Identifier of the plugin associated with this operation.
|
|
275
|
+
*/
|
|
276
|
+
readonly pluginIdentifier: string;
|
|
277
|
+
/**
|
|
278
|
+
* Module Federation expose name or generated contribution module path.
|
|
279
|
+
*/
|
|
280
|
+
readonly module: string;
|
|
281
|
+
/**
|
|
282
|
+
* Resolved Module Federation entry URL.
|
|
283
|
+
*/
|
|
284
|
+
readonly remoteUrl?: string;
|
|
285
|
+
/**
|
|
286
|
+
* Module Federation remote name.
|
|
287
|
+
*/
|
|
288
|
+
readonly remoteName?: string;
|
|
289
|
+
/**
|
|
290
|
+
* Whether callers may safely retry the failed load/resolve operation.
|
|
291
|
+
*/
|
|
292
|
+
readonly retryable: boolean;
|
|
293
|
+
constructor(options: {
|
|
294
|
+
code: FederatedModuleLoadErrorCode;
|
|
295
|
+
message: string;
|
|
296
|
+
pluginIdentifier: string;
|
|
297
|
+
module: string;
|
|
298
|
+
remoteUrl?: string;
|
|
299
|
+
remoteName?: string;
|
|
300
|
+
retryable: boolean;
|
|
301
|
+
cause?: unknown;
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Stable failure codes for UI extension resolution and rendering.
|
|
306
|
+
*/
|
|
307
|
+
type UiExtensionRuntimeFailureCode = "extension_context_unavailable" | "extension_i18n_unavailable" | "extension_module_unavailable" | "extension_manifest_module_mismatch" | "extension_contract_invalid" | "extension_visibility_failed" | "extension_order_failed" | "extension_render_failed";
|
|
308
|
+
/**
|
|
309
|
+
* Normalized error associated with one failing runtime UI extension.
|
|
310
|
+
*/
|
|
311
|
+
declare class UiExtensionRuntimeError extends Error {
|
|
312
|
+
/**
|
|
313
|
+
* Stable machine-readable code.
|
|
314
|
+
*/
|
|
315
|
+
readonly code: UiExtensionRuntimeFailureCode;
|
|
316
|
+
/**
|
|
317
|
+
* Stable runtime extension identifier.
|
|
318
|
+
*/
|
|
319
|
+
readonly extensionId: string;
|
|
320
|
+
/**
|
|
321
|
+
* Extension key associated with this ui extension runtime error.
|
|
322
|
+
*/
|
|
323
|
+
readonly extensionKey: string;
|
|
324
|
+
/**
|
|
325
|
+
* Identifier of the plugin associated with this operation.
|
|
326
|
+
*/
|
|
327
|
+
readonly pluginIdentifier: string;
|
|
328
|
+
/**
|
|
329
|
+
* Identifier of the plugin whose surface/operation is targeted.
|
|
330
|
+
*/
|
|
331
|
+
readonly targetPluginIdentifier: string;
|
|
332
|
+
/**
|
|
333
|
+
* Module Federation expose name or generated contribution module path.
|
|
334
|
+
*/
|
|
335
|
+
readonly module: string;
|
|
336
|
+
/**
|
|
337
|
+
* Whether callers may safely retry the failed load/resolve operation.
|
|
338
|
+
*/
|
|
339
|
+
readonly retryable: boolean;
|
|
340
|
+
constructor(options: {
|
|
341
|
+
code: UiExtensionRuntimeFailureCode;
|
|
342
|
+
message: string;
|
|
343
|
+
item: RuntimeUiExtension;
|
|
344
|
+
retryable?: boolean;
|
|
345
|
+
cause?: unknown;
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Normalize an arbitrary federation failure to `FederatedModuleLoadError`.
|
|
350
|
+
*
|
|
351
|
+
* @param value Input value to normalize/convert.
|
|
352
|
+
* @param context Scoped runtime context for this callback/operation.
|
|
353
|
+
* @returns Result returned by toFederatedModuleLoadError.
|
|
354
|
+
*/
|
|
355
|
+
declare function toFederatedModuleLoadError(value: unknown, context: {
|
|
356
|
+
pluginIdentifier: string;
|
|
357
|
+
module: string;
|
|
358
|
+
remoteUrl?: string;
|
|
359
|
+
remoteName?: string;
|
|
360
|
+
}): FederatedModuleLoadError;
|
|
361
|
+
/**
|
|
362
|
+
* Create the normalized error used when a federated remote resolves to an empty module.
|
|
363
|
+
*
|
|
364
|
+
* @param context Scoped runtime context for this callback/operation.
|
|
365
|
+
* @returns Result returned by emptyFederatedModuleError.
|
|
366
|
+
*/
|
|
367
|
+
declare function emptyFederatedModuleError(context: {
|
|
368
|
+
pluginIdentifier: string;
|
|
369
|
+
module: string;
|
|
370
|
+
remoteUrl?: string;
|
|
371
|
+
remoteName?: string;
|
|
372
|
+
}): FederatedModuleLoadError;
|
|
373
|
+
/**
|
|
374
|
+
* Normalize an arbitrary UI extension failure to `UiExtensionRuntimeError`.
|
|
375
|
+
*
|
|
376
|
+
* @param item Runtime extension descriptor being resolved/executed.
|
|
377
|
+
* @param value Input value to normalize/convert.
|
|
378
|
+
* @param phase Runtime phase in which the failure occurred.
|
|
379
|
+
* @returns Result returned by toUiExtensionRuntimeError.
|
|
380
|
+
*/
|
|
381
|
+
declare function toUiExtensionRuntimeError(item: RuntimeUiExtension, value: unknown, phase?: "resolve" | "render"): UiExtensionRuntimeError;
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Host dependencies required to resolve UI extension modules and contribution context.
|
|
385
|
+
*/
|
|
386
|
+
type UiExtensionResolverOptions = {
|
|
387
|
+
/**
|
|
388
|
+
* Identifier of the plugin whose surface/operation is targeted.
|
|
389
|
+
*/
|
|
390
|
+
targetPluginIdentifier: string;
|
|
391
|
+
/**
|
|
392
|
+
* Runtime extension index queried by the resolver/executor.
|
|
393
|
+
*/
|
|
394
|
+
extensionIndex: ExtensionIndexReadOnly;
|
|
395
|
+
/**
|
|
396
|
+
* Host render context used as the owner of resolved extensions.
|
|
397
|
+
*/
|
|
398
|
+
ownerContext: PluginRenderContext;
|
|
399
|
+
/**
|
|
400
|
+
* Current host route path when known.
|
|
401
|
+
*/
|
|
402
|
+
routePath?: string | null | (() => string | null);
|
|
403
|
+
/**
|
|
404
|
+
* Host runtime observer used for diagnostics and tracing.
|
|
405
|
+
*/
|
|
406
|
+
observer?: PluginRuntimeObserver | null;
|
|
407
|
+
/**
|
|
408
|
+
* Resolve a plugin identifier to its Module Federation remote.
|
|
409
|
+
*
|
|
410
|
+
* @param pluginIdentifier Plugin identifier to resolve/load.
|
|
411
|
+
* @returns Result returned by resolveRemote.
|
|
412
|
+
*/
|
|
413
|
+
resolveRemote(pluginIdentifier: string): FederatedRemoteDescriptor | null | undefined;
|
|
414
|
+
/**
|
|
415
|
+
* Build the scoped plugin render context for one extension descriptor.
|
|
416
|
+
*
|
|
417
|
+
* @param item Runtime extension descriptor being resolved/executed.
|
|
418
|
+
* @returns Result returned by resolveContext.
|
|
419
|
+
*/
|
|
420
|
+
resolveContext(item: RuntimeUiExtension): PluginRenderContext;
|
|
421
|
+
/** Test/host seam; production defaults to Module Federation. */
|
|
422
|
+
/**
|
|
423
|
+
* @param pluginIdentifier Plugin identifier to resolve/load.
|
|
424
|
+
* @param module Module Federation expose name.
|
|
425
|
+
* @param remoteUrl Optional explicit remote entry URL.
|
|
426
|
+
* @param remoteName Optional explicit Module Federation remote name.
|
|
427
|
+
* @returns Result returned by loadModule.
|
|
428
|
+
*/
|
|
429
|
+
loadModule?: FederatedModuleLoader;
|
|
430
|
+
};
|
|
431
|
+
/**
|
|
432
|
+
* Successfully loaded renderable UI extension and its scoped runtime context.
|
|
433
|
+
*/
|
|
434
|
+
type LoadedRenderableUiExtension<TPayload = unknown> = {
|
|
435
|
+
/**
|
|
436
|
+
* Item associated with this loaded renderable ui extension.
|
|
437
|
+
*/
|
|
438
|
+
item: RuntimeUiExtension;
|
|
439
|
+
/**
|
|
440
|
+
* Module Federation expose name or generated contribution module path.
|
|
441
|
+
*/
|
|
442
|
+
module: RenderableUiExtensionModule<TPayload>;
|
|
443
|
+
/**
|
|
444
|
+
* Scoped plugin render context.
|
|
445
|
+
*/
|
|
446
|
+
context: PluginRenderContext;
|
|
447
|
+
/**
|
|
448
|
+
* Resolved ordering value used to sort contributions.
|
|
449
|
+
*/
|
|
450
|
+
order: number;
|
|
451
|
+
};
|
|
452
|
+
/**
|
|
453
|
+
* UI extension resolution failure retained by settled resolution.
|
|
454
|
+
*/
|
|
455
|
+
type FailedRenderableUiExtension = {
|
|
456
|
+
/**
|
|
457
|
+
* Resolution/job/runtime status.
|
|
458
|
+
*/
|
|
459
|
+
status: "failed";
|
|
460
|
+
/**
|
|
461
|
+
* Item associated with this failed renderable ui extension.
|
|
462
|
+
*/
|
|
463
|
+
item: RuntimeUiExtension;
|
|
464
|
+
/**
|
|
465
|
+
* Failure value associated with the current operation.
|
|
466
|
+
*/
|
|
467
|
+
error: UiExtensionRuntimeError;
|
|
468
|
+
/**
|
|
469
|
+
* Resolved ordering value used to sort contributions.
|
|
470
|
+
*/
|
|
471
|
+
order: number;
|
|
472
|
+
};
|
|
473
|
+
/**
|
|
474
|
+
* Discriminated successful UI extension resolution result.
|
|
475
|
+
*/
|
|
476
|
+
type ResolvedRenderableUiExtension<TPayload = unknown> = {
|
|
477
|
+
/**
|
|
478
|
+
* Resolution/job/runtime status.
|
|
479
|
+
*/
|
|
480
|
+
status: "loaded";
|
|
481
|
+
/**
|
|
482
|
+
* Resolved remote entry URL.
|
|
483
|
+
*/
|
|
484
|
+
entry: LoadedRenderableUiExtension<TPayload>;
|
|
485
|
+
/**
|
|
486
|
+
* Item associated with this resolved renderable ui extension.
|
|
487
|
+
*/
|
|
488
|
+
item: RuntimeUiExtension;
|
|
489
|
+
/**
|
|
490
|
+
* Resolved ordering value used to sort contributions.
|
|
491
|
+
*/
|
|
492
|
+
order: number;
|
|
493
|
+
};
|
|
494
|
+
/**
|
|
495
|
+
* Settled result for one renderable UI extension match.
|
|
496
|
+
*/
|
|
497
|
+
type RenderableUiExtensionResolution<TPayload = unknown> = ResolvedRenderableUiExtension<TPayload> | FailedRenderableUiExtension;
|
|
498
|
+
/**
|
|
499
|
+
* Host resolver for matching, loading and evaluating UI extension contributions.
|
|
500
|
+
*/
|
|
501
|
+
declare class UiExtensionResolver {
|
|
502
|
+
#private;
|
|
503
|
+
constructor(options: UiExtensionResolverOptions);
|
|
504
|
+
/**
|
|
505
|
+
* Return the host runtime observer configured for this resolver.
|
|
506
|
+
*
|
|
507
|
+
* @returns Result returned by observer.
|
|
508
|
+
*/
|
|
509
|
+
get observer(): PluginRuntimeObserver | null | undefined;
|
|
510
|
+
/**
|
|
511
|
+
* Return the plugin identifier owning the target surface.
|
|
512
|
+
*
|
|
513
|
+
* @returns Result returned by targetPluginIdentifier.
|
|
514
|
+
*/
|
|
515
|
+
get targetPluginIdentifier(): string;
|
|
516
|
+
/**
|
|
517
|
+
* Return the route path used to build extension lifecycle context.
|
|
518
|
+
*
|
|
519
|
+
* @returns Result returned by routePath.
|
|
520
|
+
*/
|
|
521
|
+
get routePath(): string | null | undefined;
|
|
522
|
+
/**
|
|
523
|
+
* Return normalized UI extensions matching one surface/key/point.
|
|
524
|
+
*
|
|
525
|
+
* @param surface Extension surface to query.
|
|
526
|
+
* @param surfaceKey Stable semantic key for the target surface.
|
|
527
|
+
* @param point Extension point within the surface.
|
|
528
|
+
* @returns Result returned by matching.
|
|
529
|
+
*/
|
|
530
|
+
matching(surface: ExtensionSurface, surfaceKey: string, point: string): readonly RuntimeUiExtension[];
|
|
531
|
+
/**
|
|
532
|
+
* Resolve matching renderable extensions, throwing according to normal resolver semantics.
|
|
533
|
+
*
|
|
534
|
+
* @param request Request payload/options for this operation.
|
|
535
|
+
* @returns Result returned by resolveRenderable.
|
|
536
|
+
*/
|
|
537
|
+
resolveRenderable<TPayload = unknown>(request: {
|
|
538
|
+
surface: ExtensionSurface;
|
|
539
|
+
surfaceKey: string;
|
|
540
|
+
point: string;
|
|
541
|
+
instanceKey?: string;
|
|
542
|
+
extensionContext?: unknown;
|
|
543
|
+
payload?: TPayload;
|
|
544
|
+
signal?: AbortSignal;
|
|
545
|
+
}): Promise<LoadedRenderableUiExtension<TPayload>[]>;
|
|
546
|
+
/**
|
|
547
|
+
* Resolve only the modules for the requested rendered surface while retaining
|
|
548
|
+
* individual failures. ExtensionHost uses this to isolate one broken third-
|
|
549
|
+
* party contribution without hiding the identity of the offender.
|
|
550
|
+
*/
|
|
551
|
+
/**
|
|
552
|
+
* @param request Request payload/options for this operation.
|
|
553
|
+
* @returns Result returned by resolveRenderableSettled.
|
|
554
|
+
*/
|
|
555
|
+
resolveRenderableSettled<TPayload = unknown>(request: {
|
|
556
|
+
surface: ExtensionSurface;
|
|
557
|
+
surfaceKey: string;
|
|
558
|
+
point: string;
|
|
559
|
+
instanceKey?: string;
|
|
560
|
+
extensionContext?: unknown;
|
|
561
|
+
payload?: TPayload;
|
|
562
|
+
signal?: AbortSignal;
|
|
563
|
+
}): Promise<RenderableUiExtensionResolution<TPayload>[]>;
|
|
564
|
+
/**
|
|
565
|
+
* Resolve and flatten structured contributions for one surface point.
|
|
566
|
+
*
|
|
567
|
+
* @param request Request payload/options for this operation.
|
|
568
|
+
* @returns Result returned by resolveContributions.
|
|
569
|
+
*/
|
|
570
|
+
resolveContributions<TContribution, TPayload = unknown>(request: {
|
|
571
|
+
surface: ExtensionSurface;
|
|
572
|
+
surfaceKey: string;
|
|
573
|
+
point: string;
|
|
574
|
+
renderErrorPolicy?: "isolate" | "bubble";
|
|
575
|
+
instanceKey?: string;
|
|
576
|
+
extensionContext?: unknown;
|
|
577
|
+
payload?: TPayload;
|
|
578
|
+
signal?: AbortSignal;
|
|
579
|
+
}): Promise<UiResolvedContribution<TContribution>[]>;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* How `ExtensionHost` reacts when one matched UI extension fails to resolve or render.
|
|
584
|
+
*/
|
|
585
|
+
type ExtensionFailurePolicy = "ignore" | "fallback" | "fail-surface" | "fail-page";
|
|
586
|
+
/**
|
|
587
|
+
* Props used by the host-facing `ExtensionHost` component.
|
|
588
|
+
*/
|
|
589
|
+
type ExtensionHostProps<TPayload = unknown> = {
|
|
590
|
+
/**
|
|
591
|
+
* UI extension resolver used by the host component.
|
|
592
|
+
*/
|
|
593
|
+
resolver: UiExtensionResolver;
|
|
594
|
+
/**
|
|
595
|
+
* Semantic extension surface.
|
|
596
|
+
*/
|
|
597
|
+
surface: ExtensionSurface;
|
|
598
|
+
/**
|
|
599
|
+
* Stable semantic key identifying the concrete surface.
|
|
600
|
+
*/
|
|
601
|
+
surfaceKey: string;
|
|
602
|
+
/**
|
|
603
|
+
* Extension point within the surface.
|
|
604
|
+
*/
|
|
605
|
+
point: string;
|
|
606
|
+
/**
|
|
607
|
+
* Runtime identity of the concrete mounted surface instance.
|
|
608
|
+
*/
|
|
609
|
+
instanceKey?: string;
|
|
610
|
+
/**
|
|
611
|
+
* Host-owned context for the concrete surface instance.
|
|
612
|
+
*/
|
|
613
|
+
extensionContext?: unknown;
|
|
614
|
+
/**
|
|
615
|
+
* Operation/event/render payload.
|
|
616
|
+
*/
|
|
617
|
+
payload?: TPayload;
|
|
618
|
+
/** False means the surface is not currently rendered/active; no module work is performed. */
|
|
619
|
+
active?: boolean;
|
|
620
|
+
/** Host-only resilience control. Normal semantic components use the safe fallback default. */
|
|
621
|
+
failurePolicy?: ExtensionFailurePolicy;
|
|
622
|
+
/**
|
|
623
|
+
* Content rendered while a plugin/extension module is loading.
|
|
624
|
+
*/
|
|
625
|
+
loadingFallback?: React.ReactNode;
|
|
626
|
+
/**
|
|
627
|
+
* Content rendered when no matching UI extension contributes content.
|
|
628
|
+
*/
|
|
629
|
+
emptyFallback?: React.ReactNode;
|
|
630
|
+
/**
|
|
631
|
+
* Optional renderer used when a plugin/extension fails.
|
|
632
|
+
*
|
|
633
|
+
* @param error Error passed to the fallback renderer.
|
|
634
|
+
* @returns Result returned by errorFallback.
|
|
635
|
+
*/
|
|
636
|
+
errorFallback?: (error: Error) => React.ReactNode;
|
|
637
|
+
/**
|
|
638
|
+
* CSS class applied to the extension host wrapper.
|
|
639
|
+
*/
|
|
640
|
+
className?: string;
|
|
641
|
+
/**
|
|
642
|
+
* CSS class applied to each resolved extension item.
|
|
643
|
+
*/
|
|
644
|
+
itemClassName?: string;
|
|
645
|
+
};
|
|
646
|
+
/**
|
|
647
|
+
* Resolve and render UI extensions for one registered host surface/point.
|
|
648
|
+
*
|
|
649
|
+
* @param props Component/provider properties.
|
|
650
|
+
* @returns Rendered extension host content.
|
|
651
|
+
*/
|
|
652
|
+
declare function ExtensionHost<TPayload = unknown>({ resolver, surface, surfaceKey, point, instanceKey, extensionContext, payload, active, failurePolicy, loadingFallback, emptyFallback, errorFallback, className, itemClassName, }: ExtensionHostProps<TPayload>): React.JSX.Element;
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* One currently registered federated remote and its generation.
|
|
656
|
+
*/
|
|
657
|
+
type FederatedRemoteRegistration = Readonly<{
|
|
658
|
+
pluginIdentifier: string;
|
|
659
|
+
producerName: string;
|
|
660
|
+
registrationName: string;
|
|
661
|
+
entry: string;
|
|
662
|
+
generation: number;
|
|
663
|
+
}>;
|
|
664
|
+
/**
|
|
665
|
+
* Snapshot of registrations tracked by a federated remote registry.
|
|
666
|
+
*/
|
|
667
|
+
type FederatedRemoteRegistryStats = Readonly<{
|
|
668
|
+
registrations: number;
|
|
669
|
+
generations: ReadonlyArray<FederatedRemoteRegistration>;
|
|
670
|
+
}>;
|
|
671
|
+
/**
|
|
672
|
+
* Resolved remote registration returned by the federated remote registry.
|
|
673
|
+
*/
|
|
674
|
+
type FederatedRemoteResolution = Readonly<{
|
|
675
|
+
registration: FederatedRemoteRegistration;
|
|
676
|
+
replaced: boolean;
|
|
677
|
+
}>;
|
|
678
|
+
/**
|
|
679
|
+
* Adapter used by the registry to register/unregister remotes in the Module Federation runtime.
|
|
680
|
+
*/
|
|
681
|
+
type FederatedRemoteRuntimeAdapter = {
|
|
682
|
+
/**
|
|
683
|
+
* Register/update a federated remote in the Module Federation runtime.
|
|
684
|
+
*
|
|
685
|
+
* @param value Input value to normalize/convert.
|
|
686
|
+
* @param force Force re-registration even when the resolved remote is unchanged.
|
|
687
|
+
*/
|
|
688
|
+
register(value: {
|
|
689
|
+
name: string;
|
|
690
|
+
entry: string;
|
|
691
|
+
producerName: string;
|
|
692
|
+
}, force: boolean): void;
|
|
693
|
+
/**
|
|
694
|
+
* Remove a federated remote from the Module Federation runtime.
|
|
695
|
+
*
|
|
696
|
+
* @param name Remote registration name.
|
|
697
|
+
*/
|
|
698
|
+
unregister?(name: string): void;
|
|
699
|
+
};
|
|
700
|
+
/**
|
|
701
|
+
* Generation-aware registry that keeps Module Federation remote registrations consistent with resolved plugin URLs.
|
|
702
|
+
*/
|
|
703
|
+
declare class FederatedRemoteRegistry {
|
|
704
|
+
#private;
|
|
705
|
+
/**
|
|
706
|
+
* Return current federated remote registration statistics.
|
|
707
|
+
*
|
|
708
|
+
* @returns Result returned by stats.
|
|
709
|
+
*/
|
|
710
|
+
get stats(): FederatedRemoteRegistryStats;
|
|
711
|
+
/**
|
|
712
|
+
* Ensure the currently resolved remote is registered and return its generation.
|
|
713
|
+
*
|
|
714
|
+
* @param adapter Module Federation runtime adapter.
|
|
715
|
+
* @param value Resolved plugin remote descriptor.
|
|
716
|
+
* @returns Result returned by ensure.
|
|
717
|
+
*/
|
|
718
|
+
ensure(adapter: FederatedRemoteRuntimeAdapter, value: {
|
|
719
|
+
pluginIdentifier: string;
|
|
720
|
+
producerName: string;
|
|
721
|
+
entry: string;
|
|
722
|
+
}): FederatedRemoteResolution;
|
|
723
|
+
/**
|
|
724
|
+
* Invalidate all remote registrations associated with one plugin identifier.
|
|
725
|
+
*
|
|
726
|
+
* @param adapter Module Federation runtime adapter.
|
|
727
|
+
* @param pluginIdentifier Plugin identifier to resolve/load.
|
|
728
|
+
*/
|
|
729
|
+
invalidatePlugin(adapter: FederatedRemoteRuntimeAdapter, pluginIdentifier: string): void;
|
|
730
|
+
/**
|
|
731
|
+
* Remove every registration tracked by this registry.
|
|
732
|
+
*
|
|
733
|
+
* @param adapter Module Federation runtime adapter.
|
|
734
|
+
*/
|
|
735
|
+
reset(adapter: FederatedRemoteRuntimeAdapter): void;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Props used by the host-facing `PluginRenderer` component.
|
|
740
|
+
*/
|
|
741
|
+
interface PluginRendererProps {
|
|
742
|
+
/**
|
|
743
|
+
* Stable plugin identifier.
|
|
744
|
+
*/
|
|
745
|
+
identifier: string;
|
|
746
|
+
/**
|
|
747
|
+
* Module Federation expose name or generated contribution module path.
|
|
748
|
+
*/
|
|
749
|
+
module?: string;
|
|
750
|
+
/**
|
|
751
|
+
* Module Federation remote name.
|
|
752
|
+
*/
|
|
753
|
+
remoteName?: string;
|
|
754
|
+
/**
|
|
755
|
+
* Resolved Module Federation entry URL.
|
|
756
|
+
*/
|
|
757
|
+
remoteUrl?: string;
|
|
758
|
+
/**
|
|
759
|
+
* Scoped plugin render context.
|
|
760
|
+
*/
|
|
761
|
+
context: PluginRenderContext;
|
|
762
|
+
/**
|
|
763
|
+
* Content rendered while a plugin/extension module is loading.
|
|
764
|
+
*/
|
|
765
|
+
loadingFallback?: ReactNode;
|
|
766
|
+
/**
|
|
767
|
+
* Optional renderer used when a plugin/extension fails.
|
|
768
|
+
*
|
|
769
|
+
* @param error Error passed to the fallback renderer.
|
|
770
|
+
* @returns Result returned by errorFallback.
|
|
771
|
+
*/
|
|
772
|
+
errorFallback?: (error: Error) => ReactNode;
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Starts plugin JavaScript and translation loading in parallel, but gates the
|
|
776
|
+
* actual plugin render on the scoped translation namespace. Federated modules
|
|
777
|
+
* must remain side-effect free at module evaluation time and consume i18n from
|
|
778
|
+
* the runtime context during render/lifecycle execution.
|
|
779
|
+
*/
|
|
780
|
+
/**
|
|
781
|
+
* @param props Component/provider properties.
|
|
782
|
+
* @returns Rendered plugin provider/content state.
|
|
783
|
+
*/
|
|
784
|
+
declare function PluginRenderer({ identifier, module, remoteName, remoteUrl, context, loadingFallback, errorFallback, }: PluginRendererProps): React.JSX.Element;
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* Load one exposed module from a federated plugin with cache and remote-registration handling.
|
|
788
|
+
*
|
|
789
|
+
* @param identifier Plugin identifier.
|
|
790
|
+
* @param module Module Federation expose name.
|
|
791
|
+
* @param remoteUrl Optional explicit remote entry URL.
|
|
792
|
+
* @param remoteName Optional explicit Module Federation remote name.
|
|
793
|
+
* @returns Loaded exposed module value.
|
|
794
|
+
*/
|
|
795
|
+
declare function loadFederatedModule(identifier: string, module: string, remoteUrl?: string, remoteName?: string): Promise<unknown>;
|
|
796
|
+
/**
|
|
797
|
+
* Loads and validates a federated page/component ahead of a route commit.
|
|
798
|
+
* Resolved React exports are cached separately from the raw federation result
|
|
799
|
+
* so a prepared navigation can render the destination synchronously without a
|
|
800
|
+
* one-frame loading fallback.
|
|
801
|
+
*/
|
|
802
|
+
/**
|
|
803
|
+
* @param identifier Plugin identifier.
|
|
804
|
+
* @param module Module Federation expose name.
|
|
805
|
+
* @param remoteUrl Optional explicit remote entry URL.
|
|
806
|
+
* @param remoteName Optional explicit Module Federation remote name.
|
|
807
|
+
* @returns Validated federated React plugin component.
|
|
808
|
+
*/
|
|
809
|
+
declare function preloadFederatedPlugin(identifier: string, module?: string, remoteUrl?: string, remoteName?: string): Promise<FederatedPlugin>;
|
|
810
|
+
/**
|
|
811
|
+
* Invalidate cached modules and remote registrations for one plugin identifier.
|
|
812
|
+
*
|
|
813
|
+
* @param identifier Plugin identifier.
|
|
814
|
+
*/
|
|
815
|
+
declare function invalidateFederatedPluginModules(identifier: string): void;
|
|
816
|
+
/**
|
|
817
|
+
* Clear all cached federated modules and remote registrations.
|
|
818
|
+
*/
|
|
819
|
+
declare function resetFederatedModuleCache(): void;
|
|
820
|
+
/**
|
|
821
|
+
* Return the current federated module-cache entry count.
|
|
822
|
+
*
|
|
823
|
+
* @returns Current module-cache statistics.
|
|
824
|
+
*/
|
|
825
|
+
declare function getFederatedModuleCacheStats(): {
|
|
826
|
+
entries: number;
|
|
827
|
+
};
|
|
828
|
+
/**
|
|
829
|
+
* Return current module-cache and federated-remote registration statistics.
|
|
830
|
+
*
|
|
831
|
+
* @returns Current federation cache/registry statistics.
|
|
832
|
+
*/
|
|
833
|
+
declare function getFederatedRuntimeStats(): {
|
|
834
|
+
moduleCache: {
|
|
835
|
+
entries: number;
|
|
836
|
+
};
|
|
837
|
+
remoteRegistry: Readonly<{
|
|
838
|
+
registrations: number;
|
|
839
|
+
generations: ReadonlyArray<FederatedRemoteRegistration>;
|
|
840
|
+
}>;
|
|
841
|
+
};
|
|
842
|
+
/**
|
|
843
|
+
* React hook that loads a federated plugin component and exposes loading/error state.
|
|
844
|
+
*
|
|
845
|
+
* @param identifier Plugin identifier.
|
|
846
|
+
* @param module Module Federation expose name.
|
|
847
|
+
* @param remoteUrl Optional explicit remote entry URL.
|
|
848
|
+
* @param remoteName Optional explicit Module Federation remote name.
|
|
849
|
+
* @returns Loading/error/plugin state for the requested federated module.
|
|
850
|
+
*/
|
|
851
|
+
declare function useFederatedPlugin(identifier: string, module?: string, remoteUrl?: string, remoteName?: string): {
|
|
852
|
+
plugin: FederatedPlugin | null;
|
|
853
|
+
error: Error | null;
|
|
854
|
+
loading: boolean;
|
|
855
|
+
revision: number;
|
|
856
|
+
};
|
|
857
|
+
|
|
858
|
+
export { ExtensionExecutionRuntime, ExtensionHost, FederatedModuleLoadError, FederatedRemoteRegistry, PluginRenderer, PluginRuntimeObserverProvider, UiExtensionResolver, UiExtensionRuntimeError, emptyFederatedModuleError, getFederatedModuleCacheStats, getFederatedRuntimeStats, invalidateFederatedPluginModules, loadFederatedModule, preloadFederatedPlugin, resetFederatedModuleCache, toFederatedModuleLoadError, toUiExtensionRuntimeError, useFederatedPlugin, usePluginRuntimeObserver };
|
|
859
|
+
export type { ExtensionExecutionRuntimeOptions, ExtensionFailurePolicy, ExtensionHostProps, FailedRenderableUiExtension, FederatedModuleLoadErrorCode, FederatedModuleLoader, FederatedRemoteDescriptor, FederatedRemoteRegistration, FederatedRemoteRegistryStats, FederatedRemoteResolution, FederatedRemoteRuntimeAdapter, LoadedRenderableUiExtension, PluginRendererProps, PluginRuntimeEventArea, PluginRuntimeEventInput, PluginRuntimeEventLevel, PluginRuntimeObserver, RenderableUiExtensionResolution, ResolveFederatedRemote, ResolvedRenderableUiExtension, UiExtensionResolverOptions, UiExtensionRuntimeFailureCode };
|