webloom-framework 0.2.0 → 0.3.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 +11 -8
- package/dist/{chunk-URY3E6UH.js → chunk-76BGPI6M.js} +771 -312
- package/dist/chunk-76BGPI6M.js.map +1 -0
- package/dist/{createPluginHost-ChJNBTsX.d.ts → createPluginHost-BVsUCDKN.d.ts} +67 -88
- package/dist/index.d.ts +15 -200
- package/dist/index.js +276 -884
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/resourceRegistry-BFnjmeGE.d.ts +267 -0
- package/dist/testing.d.ts +3 -3
- package/dist/testing.js +2 -2
- package/docs/api.md +20 -19
- 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/package.json +1 -1
- package/dist/chunk-URY3E6UH.js.map +0 -1
- package/dist/resourceRegistry-MNM1c7od.d.ts +0 -157
|
@@ -170,70 +170,42 @@ interface PermissionLease {
|
|
|
170
170
|
interface RemoteServiceReference {
|
|
171
171
|
/** 服务契约标识。 */
|
|
172
172
|
capabilityId: string;
|
|
173
|
-
/**
|
|
174
|
-
|
|
173
|
+
/** 要求精确匹配的服务契约版本。 */
|
|
174
|
+
contractVersion: string;
|
|
175
175
|
/** 提供者所在真实 Runtime。 */
|
|
176
176
|
runtime: RuntimeKind;
|
|
177
|
-
/** 服务契约版本;第一阶段要求精确匹配。 */
|
|
178
|
-
contractVersion: string;
|
|
179
177
|
/** 提供环境的启动身份;重启后变化。 */
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
|
|
183
|
-
/** 提供者所在 Coordinator 的升级接管世代;旧 Worker 引用不能跨世代使用。 */
|
|
184
|
-
handoverGeneration: number;
|
|
185
|
-
/** 宿主绑定的只读服务属性;服务桥不解释其业务含义。 */
|
|
186
|
-
attributes: Readonly<Record<string, unknown>>;
|
|
178
|
+
runtimeInstanceId: string;
|
|
179
|
+
/** 服务实例身份;撤销后永不复用。 */
|
|
180
|
+
serviceInstanceId: string;
|
|
187
181
|
/** 当前服务目录状态。 */
|
|
188
182
|
status: "starting" | "ready" | "unavailable" | "failed";
|
|
189
|
-
/**
|
|
190
|
-
|
|
191
|
-
/** 当前权威目录流修订号。 */
|
|
192
|
-
snapshotRevision: number;
|
|
183
|
+
/** 宿主绑定的只读服务属性;服务桥不解释其业务含义。 */
|
|
184
|
+
attributes: Readonly<Record<string, unknown>>;
|
|
193
185
|
/** 可选的外部授权标识;引用不是授权本身,Provider 仍需查权威状态。 */
|
|
194
186
|
grantId?: string;
|
|
195
187
|
/** 服务端授权策略修订;策略变化时旧引用必须失效。 */
|
|
196
188
|
authorizationRevision?: number;
|
|
197
189
|
}
|
|
198
|
-
/**
|
|
199
|
-
interface RemoteServiceHandshake {
|
|
200
|
-
/** 当前端口 / MessagePort 连接标识。 */
|
|
201
|
-
connectionId: string;
|
|
202
|
-
/** 对端提供环境的启动身份。 */
|
|
203
|
-
authorityInstanceId: string;
|
|
204
|
-
/** 桥协议版本。 */
|
|
205
|
-
protocolVersion: string;
|
|
206
|
-
}
|
|
207
|
-
/** 一次服务目录基线或增量快照。 */
|
|
190
|
+
/** 传给服务桥的完整目录快照;Runtime Host 是它的唯一权威发布者。 */
|
|
208
191
|
interface RemoteServiceSnapshot {
|
|
209
|
-
/**
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
|
|
217
|
-
/**
|
|
192
|
+
/** 快照协议版本;解析成功但版本不匹配时不得当成可用目录。 */
|
|
193
|
+
protocolVersion: string;
|
|
194
|
+
/** 权威 Runtime 的逻辑标识;独立服务桥可省略。 */
|
|
195
|
+
runtimeId?: string;
|
|
196
|
+
/** 权威 Runtime 类型;独立服务桥可省略。 */
|
|
197
|
+
runtimeKind?: RuntimeKind;
|
|
198
|
+
/** 每次 Worker 启动唯一的 Runtime 身份。 */
|
|
199
|
+
runtimeInstanceId: string;
|
|
200
|
+
/** 当前完整目录修订;同一 Runtime 只接受严格递增值。 */
|
|
201
|
+
revision: number;
|
|
202
|
+
/** Runtime 当前状态。 */
|
|
203
|
+
state?: "starting" | "ready" | "stopping" | "failed" | "disposed";
|
|
204
|
+
/** 当前完整服务目录。 */
|
|
218
205
|
services: readonly RemoteServiceReference[];
|
|
219
206
|
}
|
|
220
|
-
/**
|
|
221
|
-
type
|
|
222
|
-
/** 控制消息类型由 codec 绑定,核心不固定产品前缀。 */
|
|
223
|
-
type: string;
|
|
224
|
-
handshake: RemoteServiceHandshake;
|
|
225
|
-
} | {
|
|
226
|
-
type: string;
|
|
227
|
-
snapshot: RemoteServiceSnapshot;
|
|
228
|
-
} | {
|
|
229
|
-
type: string;
|
|
230
|
-
reason?: string;
|
|
231
|
-
} | {
|
|
232
|
-
type: string;
|
|
233
|
-
reason?: string;
|
|
234
|
-
};
|
|
235
|
-
/** MessagePort 服务消息类别;具体字符串由 codec 统一编码。 */
|
|
236
|
-
type RemoteServiceMessageKind = "call" | "result" | "error" | "cancel" | "handshake" | "snapshot" | "invalidate" | "disconnect";
|
|
207
|
+
/** MessagePort 服务消息类别;codec 只承载调用生命周期。 */
|
|
208
|
+
type RemoteServiceMessageKind = "call" | "result" | "error" | "cancel";
|
|
237
209
|
/** 服务桥 wire codec;负责类型名、编解码和协议版本,不让传输层散落字符串判断。 */
|
|
238
210
|
interface RemoteServiceMessageCodec {
|
|
239
211
|
/** codec 对应的协议版本。 */
|
|
@@ -245,7 +217,7 @@ interface RemoteServiceMessageCodec {
|
|
|
245
217
|
/** 将 wire 数据解码为对象;无效消息返回 undefined。 */
|
|
246
218
|
decode(input: unknown): Record<string, unknown> | undefined;
|
|
247
219
|
}
|
|
248
|
-
/**
|
|
220
|
+
/** 创建 WebLoom v2 codec;产品可以只替换 wire 前缀,不能恢复控制消息。 */
|
|
249
221
|
declare function createRemoteServiceMessageCodec(options?: {
|
|
250
222
|
prefix?: string;
|
|
251
223
|
protocolVersion?: string;
|
|
@@ -258,82 +230,89 @@ interface RemoteServiceLookup {
|
|
|
258
230
|
contractVersion: string;
|
|
259
231
|
/** 可选的预期提供 Runtime。 */
|
|
260
232
|
runtime?: RuntimeKind;
|
|
261
|
-
/** 可选的预期作用域。 */
|
|
262
|
-
scopeId?: string;
|
|
263
233
|
}
|
|
264
234
|
/** 服务代理调用上下文;服务端必须在最终边界重新检查引用和租约。 */
|
|
265
235
|
interface RemoteServiceCallContext {
|
|
266
236
|
/** 业务操作标识;可由调用方复用,用于审计和幂等,不作为传输关联键。 */
|
|
267
237
|
operationId?: string;
|
|
268
|
-
/** 实际建立代理的端口连接标识。 */
|
|
269
|
-
connectionId: string;
|
|
270
238
|
/** 创建代理时捕获的不可变引用。 */
|
|
271
239
|
reference: RemoteServiceReference;
|
|
272
240
|
/** 引用绑定的外部授权标识,供最终服务边界再次核验。 */
|
|
273
241
|
grantId?: string;
|
|
274
242
|
/** 同时受消费者作用域和本次请求控制的 signal。 */
|
|
275
243
|
signal: AbortSignal;
|
|
244
|
+
/** 从调用开始计算的总 deadline;等待目录和远程执行共用它。 */
|
|
245
|
+
deadlineAt?: number;
|
|
246
|
+
/** 传输直调用时的总 timeout;桥调用会同时提供 deadlineAt。 */
|
|
247
|
+
timeoutMs?: number;
|
|
276
248
|
}
|
|
277
249
|
/** 跨环境传输实现;桥不负责自动重放有外部副作用的请求。 */
|
|
278
250
|
interface RemoteServiceTransport {
|
|
279
251
|
call<TRequest, TResult>(request: TRequest, context: RemoteServiceCallContext): Promise<TResult>;
|
|
280
252
|
}
|
|
281
|
-
|
|
253
|
+
interface RemoteServiceCallOptions {
|
|
254
|
+
signal?: AbortSignal;
|
|
255
|
+
operationId?: string;
|
|
256
|
+
/** 兼容旧业务命名;只作为 operationId,不作为传输 callId。 */
|
|
257
|
+
requestId?: string;
|
|
258
|
+
/** 覆盖 RuntimeHandle 的默认有限 deadline。 */
|
|
259
|
+
timeoutMs?: number;
|
|
260
|
+
}
|
|
261
|
+
/** 惰性服务代理;第一次成功调用后永久绑定一份服务引用。 */
|
|
282
262
|
interface RemoteServiceProxy {
|
|
283
|
-
|
|
263
|
+
/** 未绑定时为 undefined;绑定后引用永远不换绑。 */
|
|
264
|
+
readonly reference?: RemoteServiceReference;
|
|
284
265
|
readonly revoked: boolean;
|
|
285
|
-
call<TRequest, TResult>(request: TRequest, options?:
|
|
286
|
-
signal?: AbortSignal;
|
|
287
|
-
operationId?: string; /** 旧 requestId 调用方别名;不作为传输 callId。 */
|
|
288
|
-
requestId?: string;
|
|
289
|
-
}): Promise<TResult>;
|
|
266
|
+
call<TRequest, TResult>(request: TRequest, options?: RemoteServiceCallOptions): Promise<TResult>;
|
|
290
267
|
revoke(reason?: string): void;
|
|
291
268
|
}
|
|
292
|
-
type RemoteServiceBridgeState = "
|
|
293
|
-
/**
|
|
269
|
+
type RemoteServiceBridgeState = "empty" | "ready" | "stale" | "disposed";
|
|
270
|
+
/** 服务桥完整快照结果;旧/重复 revision 直接忽略,不清空当前目录。 */
|
|
294
271
|
type RemoteServiceSnapshotResult = {
|
|
295
272
|
accepted: true;
|
|
296
273
|
state: RemoteServiceBridgeState;
|
|
297
|
-
|
|
274
|
+
revision: number;
|
|
298
275
|
} | {
|
|
299
276
|
accepted: false;
|
|
300
|
-
reason: "
|
|
301
|
-
|
|
302
|
-
receivedRevision: number;
|
|
277
|
+
reason: "stale-revision" | "protocol-mismatch" | "invalid-snapshot" | "disposed";
|
|
278
|
+
receivedRevision?: number;
|
|
303
279
|
};
|
|
280
|
+
/** WebLoom v2 调用错误的稳定码;业务 handler 可以附加自己的 code。 */
|
|
281
|
+
type RemoteServiceErrorCode = "transport_unavailable" | "call_timeout" | "runtime_initialization_failed" | "protocol_mismatch" | "capability_unavailable" | "contract_version_mismatch" | "service_stale" | "service_revoked" | "permission_denied" | "request_cancelled" | "request_clone_failed" | "handler_failed" | (string & {});
|
|
282
|
+
declare class RemoteServiceError extends Error {
|
|
283
|
+
readonly code: RemoteServiceErrorCode;
|
|
284
|
+
readonly details?: Readonly<Record<string, unknown>>;
|
|
285
|
+
constructor(code: RemoteServiceErrorCode, message: string, details?: Readonly<Record<string, unknown>>);
|
|
286
|
+
}
|
|
304
287
|
/** 跨 Worker 服务桥最小本地契约。 */
|
|
305
288
|
interface RemoteServiceBridge {
|
|
306
289
|
/** 当前端口连接状态。 */
|
|
307
290
|
readonly state: RemoteServiceBridgeState;
|
|
308
|
-
/**
|
|
309
|
-
readonly
|
|
310
|
-
/**
|
|
311
|
-
readonly authorityInstanceId?: string;
|
|
312
|
-
/** 接受一次新握手;新连接会使旧代理全部失效。 */
|
|
313
|
-
handshake(input: RemoteServiceHandshake): {
|
|
314
|
-
accepted: boolean;
|
|
315
|
-
reason?: "protocol-mismatch";
|
|
316
|
-
};
|
|
317
|
-
/** 应用基线或连续增量快照;乱序和旧连接快照会被丢弃。 */
|
|
291
|
+
/** 当前权威 Runtime 启动身份。 */
|
|
292
|
+
readonly runtimeInstanceId?: string;
|
|
293
|
+
/** 应用一份完整快照;第一次调用可以早于它到达。 */
|
|
318
294
|
applySnapshot(snapshot: RemoteServiceSnapshot): RemoteServiceSnapshotResult;
|
|
319
|
-
/**
|
|
295
|
+
/** 记录可解析但版本不兼容的对端;后续调用返回 protocol_mismatch。 */
|
|
296
|
+
markProtocolMismatch(reason?: string): void;
|
|
297
|
+
/** 记录权威 Runtime 初始化失败;后续调用返回 runtime_initialization_failed。 */
|
|
298
|
+
markInitializationFailed(reason?: string): void;
|
|
299
|
+
/** 总 deadline 默认值;必须是有限且大于零的毫秒数。 */
|
|
300
|
+
readonly defaultCallTimeoutMs: number;
|
|
301
|
+
/** 获取一个惰性、单次绑定代理;不得因当前目录为空同步失败。 */
|
|
320
302
|
getProxy(lookup: RemoteServiceLookup, scope?: LifecycleScope): RemoteServiceProxy | undefined;
|
|
321
|
-
/**
|
|
303
|
+
/** 获取惰性代理的显式别名;只在桥 disposed 后仍返回会失败的代理。 */
|
|
322
304
|
requireProxy(lookup: RemoteServiceLookup, scope?: LifecycleScope): RemoteServiceProxy;
|
|
323
305
|
/** 同步撤下全部代理;不等待远端。 */
|
|
324
306
|
invalidate(reason?: string): void;
|
|
325
|
-
/**
|
|
307
|
+
/** 端口断线;旧代理永久失效,后续恢复必须创建新 RuntimeHandle。 */
|
|
326
308
|
disconnect(reason?: string): void;
|
|
309
|
+
/** 永久销毁桥,并拒绝所有等待绑定和 pending call。 */
|
|
310
|
+
dispose(reason?: string): void;
|
|
327
311
|
/** 订阅桥状态和服务目录变化。 */
|
|
328
312
|
subscribe(listener: () => void): () => void;
|
|
329
313
|
/** 只读当前有效服务引用。 */
|
|
330
314
|
services(): readonly RemoteServiceReference[];
|
|
331
315
|
}
|
|
332
|
-
/** 服务桥未就绪或代理已失效。 */
|
|
333
|
-
declare class RemoteServiceUnavailableError extends Error {
|
|
334
|
-
readonly code: "service.unavailable";
|
|
335
|
-
constructor(message?: string);
|
|
336
|
-
}
|
|
337
316
|
/** 首次发布采用的升级并存策略。冷切换要求旧环境先退出;两阶段允许
|
|
338
317
|
* 短暂并存,但必须先在写入边界完成同一接管世代的排空。 */
|
|
339
318
|
type UpgradeMode = "cold-switch" | "two-phase";
|
|
@@ -1336,4 +1315,4 @@ interface PluginHost {
|
|
|
1336
1315
|
}): void;
|
|
1337
1316
|
}
|
|
1338
1317
|
|
|
1339
|
-
export {
|
|
1318
|
+
export { PermissionLeaseRevokedError as $, type LifecycleCleanup as A, type LifecycleCleanupIssue as B, type CreatePluginHostOptions as C, type DispatchOptions as D, type EventHandler as E, type LifecycleCleanupPhase as F, type LifecycleDisposeOptions as G, type HandlerOptions as H, type LifecycleResourceHandle as I, type LifecycleResourceSnapshot as J, type LifecycleScopeKind as K, type LifecycleDisposeResult as L, type MessageBus as M, LifecycleScopeRevokedError as N, type LifecycleScopeState as O, type PluginManifest as P, type Message as Q, type RuntimeKind as R, type ScopedTaskScheduler as S, type MessageBusSnapshot as T, type UpgradeGate as U, type MessageHandler as V, type MessageMode as W, type OwnedResourceDefinition as X, PermissionDeniedError as Y, type PermissionLeaseBinding as Z, type PermissionLeaseBindingExpectation as _, type PluginGraph as a, type UpgradeMode as a$, type PermissionPolicyInput as a0, type PermissionPolicyResult as a1, type PluginAttributes as a2, type PluginConfigStore as a3, type PluginContext as a4, type PluginIntentCommand as a5, type PluginIntentCommandResult as a6, type PluginIntentController as a7, type PluginIntentCoordinator as a8, type PluginIntentSnapshot as a9, type ResourceDefinition as aA, type ResourceKey as aB, type ResourceRegistry as aC, type ResourceSnapshot as aD, type ResourceStatus as aE, type ResourceStoreApi as aF, type RuntimeUnitAttributesInput as aG, type RuntimeUnitAvailabilityInput as aH, type RuntimeUnitDependency as aI, type RuntimeUnitDependencyInput as aJ, type RuntimeUnitDescriptor as aK, type RuntimeUnitImplementationRegistry as aL, type RuntimeUnitParentScopeInput as aM, type RuntimeUnitSnapshot as aN, SCOPED_TASK_SCHEDULER_CAPABILITY as aO, type ScopedTaskDefinition as aP, type ScopedTaskSnapshot as aQ, StartupCapabilityError as aR, type StartupCapabilityErrorDetails as aS, StartupPluginError as aT, type StartupPluginErrorDetails as aU, type UpgradeDrainResult as aV, UpgradeGateRejectedError as aW, type UpgradeGateState as aX, type UpgradeHandshake as aY, type UpgradeHandshakeResult as aZ, type UpgradeIoLease as a_, type PluginIntentSubmissionResult as aa, type PluginLifecycleState as ab, type PluginStartupMode as ac, type PluginState as ad, type PluginStateKind as ae, type PluginTeardown as af, type PluginUnitGraph as ag, type PluginUnitState as ah, type PublishOptions as ai, RESOURCE_OWNER as aj, RESOURCE_REGISTRY_CAPABILITY as ak, RUNTIME_MESSAGE_BUS as al, type RemoteServiceBridge as am, type RemoteServiceBridgeState as an, type RemoteServiceCallContext as ao, type RemoteServiceCallOptions as ap, RemoteServiceError as aq, type RemoteServiceErrorCode as ar, type RemoteServiceLookup as as, type RemoteServiceMessageKind as at, type RemoteServiceProxy as au, type RemoteServiceSnapshot as av, type RemoteServiceSnapshotResult as aw, type RemoteServiceTransport as ax, type RequestOptions as ay, type ResourceContext as az, type PluginDependency as b, type UpgradeSession as b0, createCapabilityRegistry as b1, createInMemoryPluginConfigStore as b2, createPluginHost as b3, createRemoteServiceMessageCodec as b4, createResourceStore as b5, defineRuntimeUnitDependencies as b6, defineRuntimeUnitProvidedContracts as b7, lifecycleErrorText as b8, runtimeCapabilityContractVersion as b9, type PluginReverseDep as c, type PluginContribution as d, type PluginConfig as e, type PluginContextExtension as f, type PluginManifestInput as g, type RuntimeUnitDescriptorInput as h, type PluginSetup as i, type RuntimeDependency as j, type PluginPermission as k, type PluginMeta as l, type PluginHost as m, type LifecycleScope as n, type LifecycleScopeIdentity as o, type PermissionLease as p, type CreateUpgradeGateOptions as q, type RemoteServiceReference as r, type RemoteServiceMessageCodec as s, type CapabilityRegistry as t, type ContextExtensionInput as u, type ContributionAdapter as v, type ContributionAdapterInput as w, type ContributionHandle as x, type HostListener as y, LIFECYCLE_ERROR_TEXT as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { R as RuntimeKind, P as PluginManifest, a as PluginGraph, b as PluginDependency, c as PluginReverseDep, d as PluginContribution, e as PluginConfig, f as PluginContextExtension, g as PluginManifestInput, h as RuntimeUnitDescriptorInput, i as PluginSetup, j as RuntimeDependency, k as PluginPermission, l as PluginMeta,
|
|
2
|
-
export {
|
|
3
|
-
import { R as
|
|
4
|
-
export { C as CreateMessagePortServiceTransportOptions,
|
|
1
|
+
import { R as RuntimeKind, P as PluginManifest, a as PluginGraph, b as PluginDependency, c as PluginReverseDep, d as PluginContribution, e as PluginConfig, f as PluginContextExtension, g as PluginManifestInput, h as RuntimeUnitDescriptorInput, i as PluginSetup, j as RuntimeDependency, k as PluginPermission, l as PluginMeta, C as CreatePluginHostOptions, m as PluginHost, L as LifecycleDisposeResult, M as MessageBus, n as LifecycleScope, o as LifecycleScopeIdentity, p as PermissionLease, S as ScopedTaskScheduler, q as CreateUpgradeGateOptions, U as UpgradeGate, r as RemoteServiceReference, s as RemoteServiceMessageCodec } from './createPluginHost-BVsUCDKN.js';
|
|
2
|
+
export { t as CapabilityRegistry, u as ContextExtensionInput, v as ContributionAdapter, w as ContributionAdapterInput, x as ContributionHandle, D as DispatchOptions, E as EventHandler, H as HandlerOptions, y as HostListener, z as LIFECYCLE_ERROR_TEXT, A as LifecycleCleanup, B as LifecycleCleanupIssue, F as LifecycleCleanupPhase, G as LifecycleDisposeOptions, I as LifecycleResourceHandle, J as LifecycleResourceSnapshot, K as LifecycleScopeKind, N as LifecycleScopeRevokedError, O as LifecycleScopeState, Q as Message, T as MessageBusSnapshot, V as MessageHandler, W as MessageMode, X as OwnedResourceDefinition, Y as PermissionDeniedError, Z as PermissionLeaseBinding, _ as PermissionLeaseBindingExpectation, $ as PermissionLeaseRevokedError, a0 as PermissionPolicyInput, a1 as PermissionPolicyResult, a2 as PluginAttributes, a3 as PluginConfigStore, a4 as PluginContext, a5 as PluginIntentCommand, a6 as PluginIntentCommandResult, a7 as PluginIntentController, a8 as PluginIntentCoordinator, a9 as PluginIntentSnapshot, aa as PluginIntentSubmissionResult, ab as PluginLifecycleState, ac as PluginStartupMode, ad as PluginState, ae as PluginStateKind, af as PluginTeardown, ag as PluginUnitGraph, ah as PluginUnitState, ai as PublishOptions, aj as RESOURCE_OWNER, ak as RESOURCE_REGISTRY_CAPABILITY, al as RUNTIME_MESSAGE_BUS, am as RemoteServiceBridge, an as RemoteServiceBridgeState, ao as RemoteServiceCallContext, ap as RemoteServiceCallOptions, aq as RemoteServiceError, ar as RemoteServiceErrorCode, as as RemoteServiceLookup, at as RemoteServiceMessageKind, au as RemoteServiceProxy, av as RemoteServiceSnapshot, aw as RemoteServiceSnapshotResult, ax as RemoteServiceTransport, ay as RequestOptions, az as ResourceContext, aA as ResourceDefinition, aB as ResourceKey, aC as ResourceRegistry, aD as ResourceSnapshot, aE as ResourceStatus, aF as ResourceStoreApi, aG as RuntimeUnitAttributesInput, aH as RuntimeUnitAvailabilityInput, aI as RuntimeUnitDependency, aJ as RuntimeUnitDependencyInput, aK as RuntimeUnitDescriptor, aL as RuntimeUnitImplementationRegistry, aM as RuntimeUnitParentScopeInput, aN as RuntimeUnitSnapshot, aO as SCOPED_TASK_SCHEDULER_CAPABILITY, aP as ScopedTaskDefinition, aQ as ScopedTaskSnapshot, aR as StartupCapabilityError, aS as StartupCapabilityErrorDetails, aT as StartupPluginError, aU as StartupPluginErrorDetails, aV as UpgradeDrainResult, aW as UpgradeGateRejectedError, aX as UpgradeGateState, aY as UpgradeHandshake, aZ as UpgradeHandshakeResult, a_ as UpgradeIoLease, a$ as UpgradeMode, b0 as UpgradeSession, b1 as createCapabilityRegistry, b2 as createInMemoryPluginConfigStore, b3 as createPluginHost, b4 as createRemoteServiceMessageCodec, b5 as createResourceStore, b6 as defineRuntimeUnitDependencies, b7 as defineRuntimeUnitProvidedContracts, b8 as lifecycleErrorText, b9 as runtimeCapabilityContractVersion } from './createPluginHost-BVsUCDKN.js';
|
|
3
|
+
import { R as RuntimeHandle, W as WindowApp, a as RuntimeStatusSnapshot, b as RuntimeStatusListener, M as MessagePortServiceCallInput } from './resourceRegistry-BFnjmeGE.js';
|
|
4
|
+
export { C as ConnectSharedWorkerOptions, c as CreateMessagePortServiceTransportOptions, d as CreatePluginIntentControllerOptions, e as CreateResourceScopeOptions, f as CreateServiceBridgeOptions, g as RUNTIME_ERROR_TYPE, h as RUNTIME_PROTOCOL_VERSION, i as RUNTIME_SNAPSHOT_TYPE, j as RemoteServicePortCallMessage, k as RemoteServicePortCancelMessage, l as RemoteServicePortErrorMessage, m as RemoteServicePortResponseMessage, n as RemoteServicePortResultMessage, o as ResourceScopeOptions, p as RuntimeAppState, q as RuntimeErrorMessage, r as RuntimeInitializationError, s as RuntimeInitializationErrorDetails, t as RuntimeSnapshot, u as RuntimeSnapshotUnit, v as RuntimeUnavailableError, w as RuntimeUnitImplementation, S as SharedWorkerConnectionContext, x as SharedWorkerLike, y as connectSharedWorker, z as createLifecycleScope, A as createMessageBus, B as createMessagePortServiceTransport, D as createPluginIntentController, E as createResourceRegistry, F as createResourceScope, G as createRuntimeMessageCodec, H as createRuntimeUnitImplementationRegistry, I as createServiceBridge, J as isRuntimeError, K as isRuntimeSnapshot, L as isRuntimeSnapshotProtocol, N as registerOwnedResource, O as unitSnapshotFromState } from './resourceRegistry-BFnjmeGE.js';
|
|
5
5
|
|
|
6
6
|
interface BuildPluginGraphOptions {
|
|
7
7
|
/** 当前真正运行的插件;不传时使用 manifest.meta.defaultEnabled。 */
|
|
@@ -124,119 +124,6 @@ interface MaterializedPluginDefinition {
|
|
|
124
124
|
declare function materializePluginDefinition(input: RuntimePluginDefinition, runtime: RuntimeKind): MaterializedPluginDefinition;
|
|
125
125
|
declare function materializePluginDefinitions(inputs: readonly RuntimePluginDefinition[], runtime: RuntimeKind): MaterializedPluginDefinition[];
|
|
126
126
|
|
|
127
|
-
declare const RUNTIME_PROTOCOL_VERSION = "webloom.runtime.v1";
|
|
128
|
-
declare const RUNTIME_HELLO_TYPE = "webloom.runtime.hello";
|
|
129
|
-
declare const RUNTIME_SNAPSHOT_TYPE = "webloom.runtime.snapshot";
|
|
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);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
127
|
interface CreateWindowAppOptions extends Omit<CreatePluginHostOptions, "runtime" | "runtimeUnitImplementationRegistry"> {
|
|
241
128
|
/** 逻辑 Runtime 标识;同一页面通常只创建一个 App。 */
|
|
242
129
|
id?: string;
|
|
@@ -260,17 +147,10 @@ interface SharedWorkerScopeLike {
|
|
|
260
147
|
}) => void) | null;
|
|
261
148
|
}
|
|
262
149
|
interface StartSharedWorkerAppOptions extends Omit<CreatePluginHostOptions, "runtime" | "runtimeUnitImplementationRegistry"> {
|
|
263
|
-
/** SharedWorker 的逻辑稳定标识。 */
|
|
264
150
|
id: string;
|
|
265
|
-
/** 只在 SharedWorker realm 执行的插件定义。 */
|
|
266
151
|
plugins: readonly RuntimePluginDefinition[];
|
|
267
|
-
/** 测试 fixture 可注入结构等价的 SharedWorkerGlobalScope。 */
|
|
268
152
|
globalScope?: SharedWorkerScopeLike;
|
|
269
|
-
/**
|
|
270
|
-
* 复用已有领域 Worker 入口的 onconnect 装配。回调只负责安装领域协议
|
|
271
|
-
* listener;WebLoom 仍在同一端口上安装自己的 Runtime listener,不会创建
|
|
272
|
-
* 第二个 Worker 或第二条物理连接。
|
|
273
|
-
*/
|
|
153
|
+
/** SWCF-009 完成前的临时领域端口装配接缝。 */
|
|
274
154
|
onPortConnect?: (event: {
|
|
275
155
|
ports: MessagePort[];
|
|
276
156
|
}) => void;
|
|
@@ -280,7 +160,6 @@ interface SharedWorkerApp {
|
|
|
280
160
|
readonly runtimeId: string;
|
|
281
161
|
readonly runtimeInstanceId: string;
|
|
282
162
|
ready(): Promise<void>;
|
|
283
|
-
/** 重新按当前外部身份/意图对账运行单元;不会创建第二个 Worker。 */
|
|
284
163
|
reconcile(): Promise<void>;
|
|
285
164
|
state(): RuntimeStatusSnapshot;
|
|
286
165
|
subscribe(listener: RuntimeStatusListener): () => void;
|
|
@@ -289,60 +168,6 @@ interface SharedWorkerApp {
|
|
|
289
168
|
/** 在当前 SharedWorkerGlobalScope 中安装唯一的 Worker Runtime。 */
|
|
290
169
|
declare function startSharedWorkerApp(options: StartSharedWorkerAppOptions): SharedWorkerApp;
|
|
291
170
|
|
|
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
|
-
/**
|
|
304
|
-
* 供仍需在同一物理连接上承载产品 RPC 的装配层使用。
|
|
305
|
-
*
|
|
306
|
-
* 普通调用方不需要这个接缝;它们只使用 RuntimeHandle 的状态和
|
|
307
|
-
* serviceBridge。已有大量领域 RPC 的应用迁移时可以先把
|
|
308
|
-
* Runtime 握手与旧 RPC 复用同一 MessagePort,再逐步把领域调用收敛到
|
|
309
|
-
* capability service,而不会偷偷创建第二个 SharedWorker 连接。
|
|
310
|
-
*/
|
|
311
|
-
interface SharedWorkerConnectionContext {
|
|
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
171
|
/** 创建绑定到指定插件实例的 MessageBus 视图。 */
|
|
347
172
|
declare function createScopedMessageBus(base: MessageBus, scope: LifecycleScope): MessageBus;
|
|
348
173
|
|
|
@@ -413,37 +238,27 @@ declare function createScopedRegistryFacade<T extends object>(target: T, scope:
|
|
|
413
238
|
/** 创建一个绑定当前构建和接管世代的升级门禁。 */
|
|
414
239
|
declare function createUpgradeGate(options: CreateUpgradeGateOptions): UpgradeGate;
|
|
415
240
|
|
|
416
|
-
interface MessagePortServiceCallInput {
|
|
417
|
-
/** 传输层生成的调用包;业务 handler 不得把 callId 当业务幂等键。 */
|
|
418
|
-
message: RemoteServicePortCallMessage;
|
|
419
|
-
/** 调用方撤销或端点失效时自动终止的信号。 */
|
|
420
|
-
signal: AbortSignal;
|
|
421
|
-
}
|
|
422
241
|
interface CreateMessagePortServiceProviderOptions {
|
|
423
242
|
/** 与页面服务桥配对的专用双工端口。 */
|
|
424
243
|
port: MessagePort;
|
|
425
|
-
/**
|
|
426
|
-
|
|
427
|
-
/** 初始必须是完整基线快照。 */
|
|
428
|
-
snapshot: RemoteServiceSnapshot;
|
|
244
|
+
/** Provider 的本地权威目录;不会采信客户端回传的完整 reference。 */
|
|
245
|
+
services?: () => readonly RemoteServiceReference[];
|
|
429
246
|
/** 具体服务分派;这里不自动重放调用。 */
|
|
430
247
|
handleCall(input: MessagePortServiceCallInput): Promise<unknown>;
|
|
431
248
|
/** dispose 时是否关闭本端端口;默认关闭。 */
|
|
432
249
|
closeOnDispose?: boolean;
|
|
433
|
-
/** wire 消息 codec
|
|
250
|
+
/** wire 消息 codec;默认 webloom.remote-service.v2。 */
|
|
434
251
|
codec?: RemoteServiceMessageCodec;
|
|
435
252
|
}
|
|
436
253
|
interface MessagePortServiceProvider {
|
|
437
|
-
/**
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
disconnect(reason?: string): void;
|
|
443
|
-
/** 撤销未决调用、移除监听器并释放端口。 */
|
|
254
|
+
/** 替换 Provider 本地权威目录;不产生 wire 控制消息。 */
|
|
255
|
+
setServices(services: readonly RemoteServiceReference[]): void;
|
|
256
|
+
/** 同步停止新调用并 abort 当前 handler。 */
|
|
257
|
+
revoke(reason?: string): void;
|
|
258
|
+
/** 移除监听器并释放端口;不发送断开控制包。 */
|
|
444
259
|
dispose(): void;
|
|
445
260
|
}
|
|
446
|
-
/**
|
|
261
|
+
/** 创建一条只服务于当前 MessagePort 的 Provider 端点。 */
|
|
447
262
|
declare function createMessagePortServiceProvider(options: CreateMessagePortServiceProviderOptions): MessagePortServiceProvider;
|
|
448
263
|
|
|
449
|
-
export { type BuildPluginGraphOptions, type
|
|
264
|
+
export { type BuildPluginGraphOptions, type CreateMessagePortServiceProviderOptions, type CreatePermissionLeaseOptions, CreatePluginHostOptions, type CreateScopedRegistryFacadeOptions, type CreateScopedTaskSchedulerOptions, CreateUpgradeGateOptions, type CreateWindowAppOptions, type DefinePluginOptions, LifecycleDisposeResult, LifecycleScope, LifecycleScopeIdentity, type MaterializedPluginDefinition, MessageBus, MessagePortServiceCallInput, type MessagePortServiceProvider, PermissionLease, PluginConfig, PluginContextExtension, PluginContribution, type PluginDefinition, PluginDependency, PluginGraph, type PluginGraphDiagnostic, PluginGraphValidationError, PluginHost, PluginManifest, PluginManifestInput, PluginMeta, PluginPermission, PluginReverseDep, PluginSetup, RemoteServiceMessageCodec, RemoteServiceReference, RuntimeDependency, RuntimeHandle, RuntimeKind, type RuntimePluginDefinition, RuntimeStatusListener, RuntimeStatusSnapshot, RuntimeUnitDescriptorInput, type ScopedRegistryRegistration, ScopedTaskScheduler, type SharedWorkerApp, type SharedWorkerScopeLike, type StartSharedWorkerAppOptions, UpgradeGate, type ValidatePluginGraphOptions, type VerifyPermissionLeaseOptions, WindowApp, buildPluginGraph, createMessagePortServiceProvider, createPermissionLease, createScopedMessageBus, createScopedRegistryFacade, createScopedTaskScheduler, createUpgradeGate, createWindowApp, definePlugin, dependenciesOfManifest, materializePluginDefinition, materializePluginDefinitions, providesOfManifest, reverseDependentsOf, startSharedWorkerApp, validatePluginGraph, validateRuntimeUnitDependencyContracts, verifyPermissionLease };
|