webloom-framework 0.2.0 → 0.4.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 +74 -43
- package/dist/advanced.d.ts +168 -0
- package/dist/advanced.js +441 -0
- package/dist/advanced.js.map +1 -0
- package/dist/chunk-4DSINPZD.js +158 -0
- package/dist/chunk-4DSINPZD.js.map +1 -0
- package/dist/chunk-JHJZIO2H.js +4018 -0
- package/dist/chunk-JHJZIO2H.js.map +1 -0
- package/dist/chunk-RAQOFUZY.js +1737 -0
- package/dist/chunk-RAQOFUZY.js.map +1 -0
- package/dist/chunk-YOIH6H36.js +433 -0
- package/dist/chunk-YOIH6H36.js.map +1 -0
- package/dist/index.d.ts +38 -443
- package/dist/index.js +38 -1967
- package/dist/index.js.map +1 -1
- package/dist/messageBus-CtrwkjrO.d.ts +5 -0
- package/dist/messagePortServiceTransport-B0FyJr43.d.ts +264 -0
- package/dist/react.d.ts +41 -28
- package/dist/react.js +79 -88
- package/dist/react.js.map +1 -1
- package/dist/runtimeTypes-DquUCHz-.d.ts +1640 -0
- package/dist/sharedWorkerHost-Cb2a1_KD.d.ts +190 -0
- package/dist/testing.d.ts +18 -17
- package/dist/testing.js +23 -15
- package/dist/testing.js.map +1 -1
- package/dist/windowRuntime-B6Ue8jso.d.ts +23 -0
- package/docs/api.md +149 -111
- package/docs/migration-baseline.md +2 -2
- package/docs/proposals/browser-runtime-v1/implementation-plan.md +7 -1
- package/docs/proposals/browser-runtime-v1/requirements.md +6 -1
- package/docs/proposals/browser-runtime-v1/verification.md +20 -13
- package/docs/proposals/shared-worker-call-first/SWCF-009-typed-transfer-follow-up.md +34 -0
- package/docs/proposals/shared-worker-call-first/implementation-plan.md +567 -0
- package/docs/proposals/webloom-v4/implementation-plan.md +443 -0
- package/docs/proposals/webloom-v4/requirements.md +555 -0
- package/docs/proposals/webloom-v4/verification.md +84 -0
- package/package.json +9 -2
- package/dist/chunk-URY3E6UH.js +0 -3802
- package/dist/chunk-URY3E6UH.js.map +0 -1
- package/dist/createPluginHost-ChJNBTsX.d.ts +0 -1339
- package/dist/resourceRegistry-MNM1c7od.d.ts +0 -157
package/dist/index.d.ts
CHANGED
|
@@ -1,449 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
export { C as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/** 当前 Host 的真实 Runtime;未选中的 Window/Worker 单元不会进入图。 */
|
|
10
|
-
runtime?: RuntimeKind;
|
|
11
|
-
}
|
|
12
|
-
interface ValidatePluginGraphOptions extends BuildPluginGraphOptions {
|
|
13
|
-
/** 平台内建 capability,不需要由某个 manifest 提供。 */
|
|
14
|
-
builtinCapabilities?: ReadonlySet<string>;
|
|
15
|
-
/** 允许多 Provider 的 capability;调用方必须有专门 Registry 选择语义。 */
|
|
16
|
-
multiProviderCapabilities?: ReadonlySet<string>;
|
|
17
|
-
/** Host 分批注册时允许 provider 尚未注册;真正装配前仍会进入 blocked。 */
|
|
18
|
-
allowMissingDependencies?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* 允许依赖当前图之外的另一个真实 Runtime;实际是否 ready 由运行时
|
|
21
|
-
* snapshot 和 RemoteServiceBridge 在 Host reconcile 时决定。
|
|
22
|
-
*/
|
|
23
|
-
externalRuntimeDependencies?: boolean;
|
|
24
|
-
}
|
|
25
|
-
interface PluginGraphDiagnostic {
|
|
26
|
-
/** 稳定诊断码。 */
|
|
27
|
-
code: "plugin.duplicate_id" | "capability.duplicate_provider" | "plugin.missing_dependency" | "plugin.dependency_cycle" | "plugin.dependency_contract_invalid" | "plugin.dependency_contract_unavailable" | "plugin.runtime_invalid" | "plugin.runtime_declaration_at_product_level";
|
|
28
|
-
/** 相关插件或 capability。 */
|
|
29
|
-
ids: string[];
|
|
30
|
-
/** 中文诊断原因,供设置页直接显示或再做 i18n 映射。 */
|
|
31
|
-
message: string;
|
|
32
|
-
}
|
|
33
|
-
/** 依赖图不满足装配条件。 */
|
|
34
|
-
declare class PluginGraphValidationError extends Error {
|
|
35
|
-
readonly code: "plugin.graph_invalid";
|
|
36
|
-
readonly diagnostics: readonly PluginGraphDiagnostic[];
|
|
37
|
-
constructor(diagnostics: readonly PluginGraphDiagnostic[]);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* 校验所有显式运行单元的跨环境依赖契约。
|
|
41
|
-
*
|
|
42
|
-
* 多运行单元产品的运行期声明必须全部位于对应 unit;产品级字段只给没有
|
|
43
|
-
* `units` 的简单插件保留兼容性。此函数同时服务 TypeScript 以外导入的
|
|
44
|
-
* manifest,避免运行时只依赖静态类型。
|
|
45
|
-
*/
|
|
46
|
-
declare function validateRuntimeUnitDependencyContracts(manifests: readonly PluginManifest[]): PluginGraphDiagnostic[];
|
|
47
|
-
/**
|
|
48
|
-
* 返回当前执行环境的依赖;显式运行单元不会继承产品级依赖。
|
|
49
|
-
* 只有没有 units 的简单插件才读取历史 product-level dependencies。
|
|
50
|
-
*/
|
|
51
|
-
declare function dependenciesOfManifest(manifest: PluginManifest, runtime?: RuntimeKind): PluginDependency[];
|
|
52
|
-
/** 返回当前执行环境提供的 capability;显式单元不会继承产品级摘要。 */
|
|
53
|
-
declare function providesOfManifest(manifest: PluginManifest, runtime?: RuntimeKind): string[];
|
|
54
|
-
/** 从 manifest 列表构造依赖、提供者和反向依赖。 */
|
|
55
|
-
declare function buildPluginGraph(manifests: PluginManifest[], options?: BuildPluginGraphOptions): PluginGraph;
|
|
56
|
-
/** 在任何 setup 前校验重复提供、缺失硬依赖和硬依赖环。 */
|
|
57
|
-
declare function validatePluginGraph(manifests: readonly PluginManifest[], options?: ValidatePluginGraphOptions): PluginGraph;
|
|
58
|
-
/** 查询当前启用的逆依赖者;禁用提供者时应按此集合先停止消费者。 */
|
|
59
|
-
declare function reverseDependentsOf(graph: PluginGraph, pluginId: string, enabledSet: ReadonlySet<string>): PluginReverseDep[];
|
|
60
|
-
|
|
61
|
-
interface DefinePluginOptions<TContribution = PluginContribution, TConfig extends PluginConfig = PluginConfig, TExtension extends PluginContextExtension = PluginContextExtension> {
|
|
1
|
+
import { K as Capability, M as CapabilityDependency, N as PluginContribution, O as PluginConfig, Q as PluginContextExtension, R as RuntimeKind, e as PluginPermission, T as PluginSetup, V as PluginDefinition } from './runtimeTypes-DquUCHz-.js';
|
|
2
|
+
export { X as AppLike, Y as CapabilityBridge, Z as CapabilityClient, C as CapabilityDescriptor, _ as CapabilityKind, j as CapabilityPeer, h as CreateUpgradeGateOptions, $ as DefineLocalCapabilityOptions, a0 as DefineRpcCapabilityOptions, a1 as DefineStreamCapabilityOptions, a2 as DispatchOptions, a3 as EventHandler, a4 as FrameworkErrorCode, a5 as FrameworkErrorContext, a6 as FrameworkErrorPhase, a7 as HandlerCallContext, a8 as HandlerOptions, a9 as HandlerOrigin, aa as HostListener, ab as ItemOf, ac as LIFECYCLE_ERROR_TEXT, ad as LifecycleCleanup, ae as LifecycleCleanupIssue, af as LifecycleCleanupPhase, ag as LifecycleDisposeOptions, ah as LifecycleDisposeResult, ai as LifecycleResourceHandle, aj as LifecycleResourceSnapshot, f as LifecycleScope, L as LifecycleScopeIdentity, ak as LifecycleScopeKind, al as LifecycleScopeRevokedError, am as LifecycleScopeState, an as LocalCapability, ao as LocalServiceOf, ap as Message, aq as MessageBus, ar as MessageBusSnapshot, as as MessageHandler, at as MessageMode, au as OwnedResourceDefinition, av as PeerCapabilityDependency, aw as PeerScopeView, ax as PermissionDeniedError, g as PermissionLease, ay as PermissionLeaseBinding, az as PermissionLeaseBindingExpectation, aA as PermissionLeaseRevokedError, aB as PluginAttributes, aC as PluginContext, a as PluginGraph, aD as PluginIntentCommand, aE as PluginIntentCommandResult, aF as PluginIntentController, aG as PluginIntentCoordinator, aH as PluginIntentSnapshot, aI as PluginIntentSubmissionResult, aJ as PluginLifecycleState, P as PluginManifest, aK as PluginManifestInput, c as PluginReverseDep, aL as PluginStartupMode, aM as PluginState, aN as PluginStateKind, aO as PluginTeardown, aP as PluginUnitGraph, aQ as PluginUnitState, aR as PublishOptions, aS as RESOURCE_OWNER, aT as RESOURCE_REGISTRY, aU as RUNTIME_MESSAGE_BUS, aV as RemoteCapability, aW as RequestOf, aX as RequestOptions, aY as ResourceContext, aZ as ResourceDefinition, a_ as ResourceKey, a$ as ResourceRegistry, b0 as ResourceSnapshot, b1 as ResourceStatus, b2 as ResponseOf, b3 as RpcCallOptions, b4 as RpcCapability, b5 as RpcCapabilityBase, b6 as RpcClient, b7 as RpcHandler, b8 as RpcTransferDescriptor, b9 as RuntimeCapabilityDependency, l as RuntimeHandle, ba as RuntimeInitializationError, bb as RuntimeLimits, bc as RuntimeServiceSnapshot, bd as RuntimeSnapshot, be as RuntimeStatusListener, bf as RuntimeStatusSnapshot, bg as RuntimeUnavailableError, b as RuntimeUnitDependency, bh as RuntimeUnitDependencyInput, d as RuntimeUnitDescriptor, bi as RuntimeUnitDescriptorInput, bj as RuntimeUnitImplementationRegistry, bk as SCOPED_TASK_SCHEDULER_CAPABILITY, bl as ScopedTaskDefinition, S as ScopedTaskScheduler, bm as ScopedTaskSnapshot, i as ServiceReference, bn as SnapshotApplyResult, bo as StartupCapabilityErrorDetails, bp as StartupPluginErrorDetails, bq as StreamCapability, br as StreamCapabilityBase, bs as StreamClient, bt as StreamHandler, bu as StreamSubscribeOptions, bv as StreamSubscription, bw as StreamTransferDescriptor, bx as TransferExtractor, by as UpgradeDrainResult, U as UpgradeGate, bz as UpgradeGateRejectedError, bA as UpgradeGateState, bB as UpgradeHandshake, bC as UpgradeHandshakeResult, bD as UpgradeIoLease, bE as UpgradeMode, bF as UpgradeSession, bG as ValueParser, bH as WebLoomError, W as WindowApp, bI as assertCapability, bJ as capabilityDescriptor, bK as capabilityKey, bL as defineCapability, bM as isCapability, bN as isCapabilityDescriptor, bO as lifecycleErrorText } from './runtimeTypes-DquUCHz-.js';
|
|
3
|
+
export { k as ConnectSharedWorkerOptions, P as PeerController, d as PeerExposureOptions, c as RuntimePluginDefinition, S as SharedWorkerApp, l as SharedWorkerLike, g as StartSharedWorkerAppOptions, m as connectSharedWorker, i as createLifecycleScope, j as createResourceScope, s as startSharedWorkerApp } from './sharedWorkerHost-Cb2a1_KD.js';
|
|
4
|
+
export { C as CreateWindowAppOptions, a as createWindowApp } from './windowRuntime-B6Ue8jso.js';
|
|
5
|
+
export { c as createMessageBus } from './messageBus-CtrwkjrO.js';
|
|
6
|
+
|
|
7
|
+
/** 普通插件定义选项;插件声明只使用 typed capability 与单一启动策略。 */
|
|
8
|
+
interface DefinePluginOptions<TProvides extends readonly Capability[] = readonly Capability[], TDependencies extends readonly CapabilityDependency[] = readonly CapabilityDependency[], TContribution = PluginContribution, TConfig extends PluginConfig = PluginConfig, TExtension extends PluginContextExtension = PluginContextExtension> {
|
|
62
9
|
/** 全局稳定插件标识。 */
|
|
63
|
-
id: string;
|
|
64
|
-
/**
|
|
65
|
-
name?: string;
|
|
66
|
-
/**
|
|
67
|
-
description?: string;
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
dependencies?: readonly (RuntimeDependency | PluginDependency)[];
|
|
76
|
-
/** 本单元提供的 capability。 */
|
|
77
|
-
provides?: readonly string[];
|
|
78
|
-
/** 跨 Runtime 时可显式覆盖 capability 契约版本。 */
|
|
79
|
-
providedContracts?: Readonly<Record<string, string>>;
|
|
80
|
-
/** 请求的权限集合。 */
|
|
81
|
-
permissions?: readonly PluginPermission[];
|
|
82
|
-
/** 单元只读配置。 */
|
|
83
|
-
config?: TConfig;
|
|
84
|
-
/** 产品贡献;不会被框架解释。 */
|
|
85
|
-
contribution?: TContribution;
|
|
86
|
-
/** 是否默认启用;默认为 true。 */
|
|
87
|
-
defaultEnabled?: boolean;
|
|
88
|
-
/** 是否允许控制面停用;默认为 true。 */
|
|
89
|
-
canDisable?: boolean;
|
|
90
|
-
/** required 插件在 App 初始启动时必须成功。 */
|
|
91
|
-
required?: boolean;
|
|
92
|
-
/** 显式启动模式;required=true 时不能覆盖为 optional。 */
|
|
93
|
-
startup?: "required" | "optional";
|
|
94
|
-
/** 仅用于兼容低层消费方的静态 meta 扩展;WebLoom 不解释分类字段。 */
|
|
95
|
-
meta?: Partial<PluginMeta>;
|
|
96
|
-
}
|
|
97
|
-
/** 静态 descriptor 与当前 realm 的实现函数分离。 */
|
|
98
|
-
interface PluginDefinition<TContribution = PluginContribution, TConfig extends PluginConfig = PluginConfig, TExtension extends PluginContextExtension = PluginContextExtension> {
|
|
99
|
-
readonly manifest: PluginManifestInput<TContribution, TConfig, TExtension>;
|
|
100
|
-
readonly descriptor: RuntimeUnitDescriptorInput<TContribution, TConfig>;
|
|
101
|
-
readonly setup: PluginSetup<TConfig, TExtension>;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* 声明一个插件。
|
|
105
|
-
*
|
|
106
|
-
* 该函数不创建 Host,也不启动 setup;真正的启动边界由
|
|
107
|
-
* createWindowApp()/startSharedWorkerApp() 拥有。
|
|
108
|
-
*/
|
|
109
|
-
declare function definePlugin<TContribution = PluginContribution, TConfig extends PluginConfig = PluginConfig, TExtension extends PluginContextExtension = PluginContextExtension>(options: DefinePluginOptions<TContribution, TConfig, TExtension>): PluginDefinition<TContribution, TConfig, TExtension>;
|
|
110
|
-
|
|
111
|
-
type RuntimePluginDefinition = PluginDefinition<any, any, any> | {
|
|
112
|
-
readonly manifest: PluginManifest | PluginManifestInput;
|
|
113
|
-
readonly setup: PluginSetup<any, any>;
|
|
114
|
-
/** 多 unit manifest 中 setup 所实现的目标 unit;单一匹配 unit 可省略。 */
|
|
10
|
+
readonly id: string;
|
|
11
|
+
/** 展示名称。 */
|
|
12
|
+
readonly name?: string;
|
|
13
|
+
/** 诊断描述。 */
|
|
14
|
+
readonly description?: string;
|
|
15
|
+
/** 本插件声明提供的能力。 */
|
|
16
|
+
readonly provides?: TProvides;
|
|
17
|
+
/** 本插件声明消费的能力。 */
|
|
18
|
+
readonly dependencies?: TDependencies;
|
|
19
|
+
/** 默认执行 Runtime。 */
|
|
20
|
+
readonly runtime?: RuntimeKind;
|
|
21
|
+
/** 多 unit 装配时的稳定 unit id。 */
|
|
115
22
|
readonly unitId?: string;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
readonly
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
declare const RUNTIME_RESYNC_TYPE = "webloom.runtime.resync";
|
|
131
|
-
declare const RUNTIME_ERROR_TYPE = "webloom.runtime.error";
|
|
132
|
-
interface RuntimeHelloMessage {
|
|
133
|
-
type: typeof RUNTIME_HELLO_TYPE;
|
|
134
|
-
protocolVersion: string;
|
|
135
|
-
connectionId: string;
|
|
136
|
-
runtimeId: string;
|
|
137
|
-
}
|
|
138
|
-
interface RuntimeResyncMessage {
|
|
139
|
-
type: typeof RUNTIME_RESYNC_TYPE;
|
|
140
|
-
connectionId: string;
|
|
141
|
-
}
|
|
142
|
-
interface RuntimeErrorMessage {
|
|
143
|
-
type: typeof RUNTIME_ERROR_TYPE;
|
|
144
|
-
protocolVersion: string;
|
|
145
|
-
code: "runtime.protocol_mismatch" | "runtime.initialization_failed" | "runtime.invalid_connection";
|
|
146
|
-
message: string;
|
|
147
|
-
pluginId?: string;
|
|
148
|
-
unitId?: string;
|
|
149
|
-
phase?: string;
|
|
150
|
-
}
|
|
151
|
-
interface RuntimeSnapshot {
|
|
152
|
-
type: typeof RUNTIME_SNAPSHOT_TYPE;
|
|
153
|
-
protocolVersion: string;
|
|
154
|
-
runtimeId: string;
|
|
155
|
-
runtimeKind: RuntimeKind;
|
|
156
|
-
runtimeInstanceId: string;
|
|
157
|
-
connectionId: string;
|
|
158
|
-
snapshotRevision: number;
|
|
159
|
-
baseline: boolean;
|
|
160
|
-
state: "starting" | "ready" | "stopping" | "failed" | "disposed";
|
|
161
|
-
units: readonly RuntimeSnapshotUnit[];
|
|
162
|
-
services: readonly RemoteServiceReference[];
|
|
163
|
-
}
|
|
164
|
-
interface RuntimeSnapshotUnit {
|
|
165
|
-
pluginId: string;
|
|
166
|
-
unitId: string;
|
|
167
|
-
runtime: RuntimeKind;
|
|
168
|
-
instanceId?: string;
|
|
169
|
-
state: PluginStateKind;
|
|
170
|
-
}
|
|
171
|
-
declare function createRuntimeMessageCodec(): RemoteServiceMessageCodec;
|
|
172
|
-
declare function isRuntimeHello(input: unknown): input is RuntimeHelloMessage;
|
|
173
|
-
declare function isRuntimeResync(input: unknown): input is RuntimeResyncMessage;
|
|
174
|
-
declare function isRuntimeSnapshot(input: unknown): input is RuntimeSnapshot;
|
|
175
|
-
declare function isRuntimeError(input: unknown): input is RuntimeErrorMessage;
|
|
176
|
-
/** 将 Host 的 PluginUnitState 映射成不会泄露领域配置的运行时快照。 */
|
|
177
|
-
declare function unitSnapshotFromState(state: PluginUnitState, runtime: RuntimeKind): RuntimeSnapshotUnit;
|
|
178
|
-
|
|
179
|
-
type RuntimeAppState = "starting" | "ready" | "stopping" | "failed" | "disposed" | "connecting" | "disconnected";
|
|
180
|
-
interface RuntimeStatusSnapshot {
|
|
181
|
-
runtimeId: string;
|
|
182
|
-
runtimeKind: RuntimeKind;
|
|
183
|
-
runtimeInstanceId: string;
|
|
184
|
-
state: RuntimeAppState;
|
|
185
|
-
snapshotRevision: number;
|
|
186
|
-
connectionId?: string;
|
|
187
|
-
units: readonly RuntimeSnapshotUnit[];
|
|
188
|
-
services: readonly RemoteServiceReference[];
|
|
189
|
-
error?: string;
|
|
190
|
-
}
|
|
191
|
-
type RuntimeStatusListener = (snapshot: RuntimeStatusSnapshot) => void;
|
|
192
|
-
interface WindowApp {
|
|
193
|
-
readonly runtimeKind: "window-main";
|
|
194
|
-
readonly runtimeId: string;
|
|
195
|
-
readonly runtimeInstanceId: string;
|
|
196
|
-
/** 已由 createWindowApp 装配并注册完成的本地 Host。 */
|
|
197
|
-
readonly host: PluginHost;
|
|
198
|
-
state(): RuntimeStatusSnapshot;
|
|
199
|
-
/** 获取当前本地 capability;停止或销毁后同步抛错。 */
|
|
200
|
-
capability<T>(capabilityId: string): T;
|
|
201
|
-
subscribe(listener: RuntimeStatusListener): () => void;
|
|
202
|
-
dispose(reason?: string): Promise<LifecycleDisposeResult>;
|
|
203
|
-
}
|
|
204
|
-
interface RuntimeHandle {
|
|
205
|
-
readonly runtimeKind: "shared-worker";
|
|
206
|
-
readonly runtimeId: string;
|
|
207
|
-
/** 当前连接绑定的 Worker 启动身份;未握手时为 undefined。 */
|
|
208
|
-
readonly runtimeInstanceId?: string;
|
|
209
|
-
/** 当前物理连接身份;未握手时为 undefined。 */
|
|
210
|
-
readonly connectionId?: string;
|
|
211
|
-
/** 当前连接已校验的服务桥;不暴露原始 MessagePort。 */
|
|
212
|
-
readonly serviceBridge: RemoteServiceBridge;
|
|
213
|
-
state(): RuntimeStatusSnapshot;
|
|
214
|
-
ready(): Promise<void>;
|
|
215
|
-
capability<T = unknown>(capabilityId: string, options?: {
|
|
216
|
-
contractVersion?: string;
|
|
217
|
-
}): RemoteServiceProxy & {
|
|
218
|
-
readonly serviceType?: T;
|
|
219
|
-
};
|
|
220
|
-
subscribe(listener: RuntimeStatusListener): () => void;
|
|
221
|
-
dispose(reason?: string): Promise<void>;
|
|
222
|
-
}
|
|
223
|
-
/** 跨 realm 初始化失败;不把 required 插件错误包装成成功状态。 */
|
|
224
|
-
interface RuntimeInitializationErrorDetails {
|
|
225
|
-
pluginId?: string;
|
|
226
|
-
unitId?: string;
|
|
227
|
-
phase: "validate" | "register" | "startup" | "snapshot" | "handshake";
|
|
228
|
-
error: string;
|
|
229
|
-
}
|
|
230
|
-
declare class RuntimeInitializationError extends Error {
|
|
231
|
-
readonly code: "runtime.initialization_failed";
|
|
232
|
-
readonly details: RuntimeInitializationErrorDetails;
|
|
233
|
-
constructor(details: RuntimeInitializationErrorDetails);
|
|
234
|
-
}
|
|
235
|
-
declare class RuntimeUnavailableError extends Error {
|
|
236
|
-
readonly code: "runtime.unavailable";
|
|
237
|
-
constructor(message?: string);
|
|
23
|
+
/** 申请权限。 */
|
|
24
|
+
readonly permissions?: readonly PluginPermission[];
|
|
25
|
+
/** 只读插件配置。 */
|
|
26
|
+
readonly config?: TConfig;
|
|
27
|
+
/** 领域贡献。 */
|
|
28
|
+
readonly contribution?: TContribution;
|
|
29
|
+
/** 唯一启动策略;默认为 optional。 */
|
|
30
|
+
readonly startup?: "required" | "optional";
|
|
31
|
+
/** 默认启用意图;required 时必须为 true。 */
|
|
32
|
+
readonly defaultEnabled?: boolean;
|
|
33
|
+
/** optional 插件默认为可停用;required 必须为 false。 */
|
|
34
|
+
readonly canDisable?: boolean;
|
|
35
|
+
/** 当前 realm 的插件实现。 */
|
|
36
|
+
readonly setup: PluginSetup<TProvides, TDependencies, TConfig, TExtension>;
|
|
238
37
|
}
|
|
239
|
-
|
|
240
|
-
interface CreateWindowAppOptions extends Omit<CreatePluginHostOptions, "runtime" | "runtimeUnitImplementationRegistry"> {
|
|
241
|
-
/** 逻辑 Runtime 标识;同一页面通常只创建一个 App。 */
|
|
242
|
-
id?: string;
|
|
243
|
-
/** 当前 Window 的插件定义;setup 只在当前 Window realm 执行。 */
|
|
244
|
-
plugins: readonly RuntimePluginDefinition[];
|
|
245
|
-
/**
|
|
246
|
-
* 供领域适配层接管分阶段注册时复用已经创建的 Window Host。
|
|
247
|
-
* 普通插件应省略该字段;传入后由调用方负责后续 register,App 仍负责
|
|
248
|
-
* Window Runtime 快照、远端投影和最终 dispose。
|
|
249
|
-
*/
|
|
250
|
-
host?: PluginHost;
|
|
251
|
-
/** 可选的 SharedWorker Runtime;Window 单元只投影其状态,不创建 Worker 假实例。 */
|
|
252
|
-
remoteRuntime?: RuntimeHandle;
|
|
253
|
-
}
|
|
254
|
-
/** 创建当前 Window 的唯一 window-main Runtime。 */
|
|
255
|
-
declare function createWindowApp(options: CreateWindowAppOptions): Promise<WindowApp>;
|
|
256
|
-
|
|
257
|
-
interface SharedWorkerScopeLike {
|
|
258
|
-
onconnect: ((event: {
|
|
259
|
-
ports: MessagePort[];
|
|
260
|
-
}) => void) | null;
|
|
261
|
-
}
|
|
262
|
-
interface StartSharedWorkerAppOptions extends Omit<CreatePluginHostOptions, "runtime" | "runtimeUnitImplementationRegistry"> {
|
|
263
|
-
/** SharedWorker 的逻辑稳定标识。 */
|
|
264
|
-
id: string;
|
|
265
|
-
/** 只在 SharedWorker realm 执行的插件定义。 */
|
|
266
|
-
plugins: readonly RuntimePluginDefinition[];
|
|
267
|
-
/** 测试 fixture 可注入结构等价的 SharedWorkerGlobalScope。 */
|
|
268
|
-
globalScope?: SharedWorkerScopeLike;
|
|
269
|
-
/**
|
|
270
|
-
* 复用已有领域 Worker 入口的 onconnect 装配。回调只负责安装领域协议
|
|
271
|
-
* listener;WebLoom 仍在同一端口上安装自己的 Runtime listener,不会创建
|
|
272
|
-
* 第二个 Worker 或第二条物理连接。
|
|
273
|
-
*/
|
|
274
|
-
onPortConnect?: (event: {
|
|
275
|
-
ports: MessagePort[];
|
|
276
|
-
}) => void;
|
|
277
|
-
}
|
|
278
|
-
interface SharedWorkerApp {
|
|
279
|
-
readonly runtimeKind: "shared-worker";
|
|
280
|
-
readonly runtimeId: string;
|
|
281
|
-
readonly runtimeInstanceId: string;
|
|
282
|
-
ready(): Promise<void>;
|
|
283
|
-
/** 重新按当前外部身份/意图对账运行单元;不会创建第二个 Worker。 */
|
|
284
|
-
reconcile(): Promise<void>;
|
|
285
|
-
state(): RuntimeStatusSnapshot;
|
|
286
|
-
subscribe(listener: RuntimeStatusListener): () => void;
|
|
287
|
-
dispose(reason?: string): Promise<LifecycleDisposeResult>;
|
|
288
|
-
}
|
|
289
|
-
/** 在当前 SharedWorkerGlobalScope 中安装唯一的 Worker Runtime。 */
|
|
290
|
-
declare function startSharedWorkerApp(options: StartSharedWorkerAppOptions): SharedWorkerApp;
|
|
291
|
-
|
|
292
|
-
interface SharedWorkerLike {
|
|
293
|
-
readonly port: MessagePort;
|
|
294
|
-
onerror?: (event: Event) => void;
|
|
295
|
-
/** 浏览器 SharedWorker 的错误事件;测试 fake 可省略。 */
|
|
296
|
-
addEventListener?(type: "error", listener: (event: Event) => void): void;
|
|
297
|
-
removeEventListener?(type: "error", listener: (event: Event) => void): void;
|
|
298
|
-
}
|
|
299
|
-
type SharedWorkerFactory = (url: string | URL, options: {
|
|
300
|
-
type: "module";
|
|
301
|
-
name?: string;
|
|
302
|
-
}) => SharedWorkerLike;
|
|
303
38
|
/**
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
* 普通调用方不需要这个接缝;它们只使用 RuntimeHandle 的状态和
|
|
307
|
-
* serviceBridge。已有大量领域 RPC 的应用迁移时可以先把
|
|
308
|
-
* Runtime 握手与旧 RPC 复用同一 MessagePort,再逐步把领域调用收敛到
|
|
309
|
-
* capability service,而不会偷偷创建第二个 SharedWorker 连接。
|
|
39
|
+
* 声明一个插件。它不会创建 Host,也不会运行 setup;Runtime 装配边界
|
|
40
|
+
* createWindowApp()/startSharedWorkerApp() 才会执行实现。
|
|
310
41
|
*/
|
|
311
|
-
|
|
312
|
-
readonly worker: SharedWorkerLike;
|
|
313
|
-
readonly port: MessagePort;
|
|
314
|
-
readonly connectionId: string;
|
|
315
|
-
}
|
|
316
|
-
interface ConnectSharedWorkerOptions {
|
|
317
|
-
/** Worker 入口的逻辑 Runtime 标识。 */
|
|
318
|
-
id: string;
|
|
319
|
-
/** module SharedWorker URL;默认直接传给 new SharedWorker。 */
|
|
320
|
-
url: string | URL;
|
|
321
|
-
/** 可选的浏览器 SharedWorker name;不传时由 URL 参与实例隔离。 */
|
|
322
|
-
name?: string;
|
|
323
|
-
/** 断线后是否建立新连接;旧代理仍永久失效。默认为 true。 */
|
|
324
|
-
autoReconnect?: boolean;
|
|
325
|
-
/** 自动重连等待毫秒数。 */
|
|
326
|
-
reconnectDelayMs?: number;
|
|
327
|
-
/** 首个 runtime snapshot 到达前的握手超时;默认 10000ms。 */
|
|
328
|
-
handshakeTimeoutMs?: number;
|
|
329
|
-
/** 测试 fixture 使用;生产默认使用 globalThis.SharedWorker。 */
|
|
330
|
-
workerFactory?: SharedWorkerFactory;
|
|
331
|
-
/**
|
|
332
|
-
* 每次建立实际物理连接时调用一次;自动重连会再次调用。
|
|
333
|
-
* 回调可以在同一端口上安装产品协议,但不得替换 Runtime 的消息
|
|
334
|
-
* 监听器,也不得把旧端口保存为可重用连接。
|
|
335
|
-
*/
|
|
336
|
-
onConnection?: (context: SharedWorkerConnectionContext) => void | Promise<void>;
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* 从 Window 连接真实 module SharedWorker。
|
|
340
|
-
*
|
|
341
|
-
* Promise 只在首个完整 baseline 快照到达后成功;调用方得到的代理均绑定
|
|
342
|
-
* 当前 connection/runtime/provider/revision,断线或重启不会静默换绑旧代理。
|
|
343
|
-
*/
|
|
344
|
-
declare function connectSharedWorker(options: ConnectSharedWorkerOptions): Promise<RuntimeHandle>;
|
|
345
|
-
|
|
346
|
-
/** 创建绑定到指定插件实例的 MessageBus 视图。 */
|
|
347
|
-
declare function createScopedMessageBus(base: MessageBus, scope: LifecycleScope): MessageBus;
|
|
348
|
-
|
|
349
|
-
interface CreatePermissionLeaseOptions {
|
|
350
|
-
/** 已由 Host 绑定的作用域身份;调用方不能从请求体自报。 */
|
|
351
|
-
identity: LifecycleScopeIdentity;
|
|
352
|
-
/** 插件 manifest 申请的权限。 */
|
|
353
|
-
requested?: readonly PluginPermission[];
|
|
354
|
-
/** 可信策略批准的权限。 */
|
|
355
|
-
approved?: readonly PluginPermission[];
|
|
356
|
-
/** 当前会话约束;存在时再与申请、批准求交集。 */
|
|
357
|
-
sessionConstraints?: readonly PluginPermission[];
|
|
358
|
-
/** 内置可信策略修订;策略变化后不能复用旧租约。 */
|
|
359
|
-
policyRevision?: number;
|
|
360
|
-
/** Connect 用户授权修订;内置插件可以省略。 */
|
|
361
|
-
grantRevision?: number;
|
|
362
|
-
/** Connect/外部授权的不可猜测授权标识;最终边界仍需查权威状态。 */
|
|
363
|
-
grantId?: string;
|
|
364
|
-
/** 可选作用域;撤权时自动撤销租约。 */
|
|
365
|
-
scope?: LifecycleScope;
|
|
366
|
-
}
|
|
367
|
-
/** 创建一个不可换绑的权限租约。 */
|
|
368
|
-
declare function createPermissionLease(options: CreatePermissionLeaseOptions): PermissionLease;
|
|
369
|
-
|
|
370
|
-
interface VerifyPermissionLeaseOptions {
|
|
371
|
-
/** 已由受信装配层创建的租约。 */
|
|
372
|
-
lease: PermissionLease;
|
|
373
|
-
/** 本次实际操作所需的最小权限。 */
|
|
374
|
-
permission: PluginPermission;
|
|
375
|
-
/** 从端口 / 当前会话权威取得的绑定值。 */
|
|
376
|
-
binding?: Parameters<PermissionLease["assertBinding"]>[0];
|
|
377
|
-
}
|
|
378
|
-
/** 在最终 RPC / I/O 边界执行一次 fail-closed 校验。 */
|
|
379
|
-
declare function verifyPermissionLease(options: VerifyPermissionLeaseOptions): void;
|
|
380
|
-
|
|
381
|
-
interface CreateScopedTaskSchedulerOptions {
|
|
382
|
-
/** 注册后是否先恢复运行一次;缺省为 false,由业务显式触发。 */
|
|
383
|
-
runOnRegister?: boolean;
|
|
384
|
-
}
|
|
385
|
-
/** 创建绑定到一个 lifecycle scope 的任务调度器。 */
|
|
386
|
-
declare function createScopedTaskScheduler(scope: LifecycleScope, options?: CreateScopedTaskSchedulerOptions): ScopedTaskScheduler & {
|
|
387
|
-
dispose(): Promise<void>;
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
interface ScopedRegistryRegistration {
|
|
391
|
-
/** 注册方法名,例如 register / registerFeature。 */
|
|
392
|
-
method: string;
|
|
393
|
-
/** 从参数哪个位置读取带 id 的定义。 */
|
|
394
|
-
idArgument?: number;
|
|
395
|
-
/** 没有返回取消函数时使用的注销方法。 */
|
|
396
|
-
unregisterMethod?: string;
|
|
397
|
-
/** 注销方法的参数位置;默认使用 idArgument。 */
|
|
398
|
-
unregisterArgument?: number;
|
|
399
|
-
/** 含 ownerPluginId 参数的注册方法;由 Host 绑定当前插件身份。 */
|
|
400
|
-
bindPluginIdArgument?: number;
|
|
401
|
-
/** 定义对象中的 ownerPluginId 字段;存在时必须与当前插件一致。 */
|
|
402
|
-
ownerPluginIdProperty?: string;
|
|
403
|
-
}
|
|
404
|
-
interface CreateScopedRegistryFacadeOptions {
|
|
405
|
-
/** 日志和作用域资源中显示的注册表名。 */
|
|
406
|
-
name: string;
|
|
407
|
-
/** 注册方法规则;缺省只包装 register(item)。 */
|
|
408
|
-
registrations?: readonly ScopedRegistryRegistration[];
|
|
409
|
-
}
|
|
410
|
-
/** 创建一个只对当前插件实例开放的 Registry 视图。 */
|
|
411
|
-
declare function createScopedRegistryFacade<T extends object>(target: T, scope: LifecycleScope, options: CreateScopedRegistryFacadeOptions): T;
|
|
412
|
-
|
|
413
|
-
/** 创建一个绑定当前构建和接管世代的升级门禁。 */
|
|
414
|
-
declare function createUpgradeGate(options: CreateUpgradeGateOptions): UpgradeGate;
|
|
415
|
-
|
|
416
|
-
interface MessagePortServiceCallInput {
|
|
417
|
-
/** 传输层生成的调用包;业务 handler 不得把 callId 当业务幂等键。 */
|
|
418
|
-
message: RemoteServicePortCallMessage;
|
|
419
|
-
/** 调用方撤销或端点失效时自动终止的信号。 */
|
|
420
|
-
signal: AbortSignal;
|
|
421
|
-
}
|
|
422
|
-
interface CreateMessagePortServiceProviderOptions {
|
|
423
|
-
/** 与页面服务桥配对的专用双工端口。 */
|
|
424
|
-
port: MessagePort;
|
|
425
|
-
/** 本端产生的握手身份。 */
|
|
426
|
-
handshake: RemoteServiceHandshake;
|
|
427
|
-
/** 初始必须是完整基线快照。 */
|
|
428
|
-
snapshot: RemoteServiceSnapshot;
|
|
429
|
-
/** 具体服务分派;这里不自动重放调用。 */
|
|
430
|
-
handleCall(input: MessagePortServiceCallInput): Promise<unknown>;
|
|
431
|
-
/** dispose 时是否关闭本端端口;默认关闭。 */
|
|
432
|
-
closeOnDispose?: boolean;
|
|
433
|
-
/** wire 消息 codec;默认使用 webloom.remote-service.*。 */
|
|
434
|
-
codec?: RemoteServiceMessageCodec;
|
|
435
|
-
}
|
|
436
|
-
interface MessagePortServiceProvider {
|
|
437
|
-
/** 发布同一连接上的下一份连续目录快照。 */
|
|
438
|
-
publishSnapshot(snapshot: RemoteServiceSnapshot): void;
|
|
439
|
-
/** 同步通知消费者撤销当前代理;调用仍由 handler 自己做最终校验。 */
|
|
440
|
-
invalidate(reason?: string): void;
|
|
441
|
-
/** 发送断线控制消息并关闭端点。 */
|
|
442
|
-
disconnect(reason?: string): void;
|
|
443
|
-
/** 撤销未决调用、移除监听器并释放端口。 */
|
|
444
|
-
dispose(): void;
|
|
445
|
-
}
|
|
446
|
-
/** 创建一个只服务于一条实际 MessagePort 连接的 Provider 端点。 */
|
|
447
|
-
declare function createMessagePortServiceProvider(options: CreateMessagePortServiceProviderOptions): MessagePortServiceProvider;
|
|
42
|
+
declare function definePlugin<TProvides extends readonly Capability[] = readonly Capability[], TDependencies extends readonly CapabilityDependency[] = readonly CapabilityDependency[], TContribution = PluginContribution, TConfig extends PluginConfig = PluginConfig, TExtension extends PluginContextExtension = PluginContextExtension>(options: DefinePluginOptions<TProvides, TDependencies, TContribution, TConfig, TExtension>): PluginDefinition<TProvides, TDependencies, TContribution, TConfig, TExtension>;
|
|
448
43
|
|
|
449
|
-
export {
|
|
44
|
+
export { Capability, CapabilityDependency, type DefinePluginOptions, PluginConfig, PluginContextExtension, PluginContribution, PluginDefinition, PluginPermission, PluginSetup, RuntimeKind, definePlugin };
|