webloom-framework 0.4.1 → 0.4.3
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 -1
- package/dist/advanced.d.ts +19 -7
- package/dist/advanced.js +4 -4
- package/dist/advanced.js.map +1 -1
- package/dist/{chunk-SX46RHDI.js → chunk-UZAO6ORB.js} +205 -41
- package/dist/chunk-UZAO6ORB.js.map +1 -0
- package/dist/{chunk-ANA6GBEI.js → chunk-YIIDRFHK.js} +553 -47
- package/dist/chunk-YIIDRFHK.js.map +1 -0
- package/dist/{chunk-HJKPKWI7.js → chunk-ZP5QYTXX.js} +19 -4
- package/dist/chunk-ZP5QYTXX.js.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -4
- package/dist/{messageBus-CtrwkjrO.d.ts → messageBus-DigYfj74.d.ts} +1 -1
- package/dist/{messagePortServiceTransport-BYprNvQY.d.ts → messagePortServiceTransport-B9-24RK6.d.ts} +95 -4
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/{runtimeTypes-DquUCHz-.d.ts → runtimeTypes-50LVQs0h.d.ts} +55 -2
- package/dist/{sharedWorkerHost-KI7TIGdX.d.ts → sharedWorkerHost-DikS18hA.d.ts} +88 -2
- package/dist/testing.d.ts +6 -6
- package/dist/testing.js +4 -4
- package/dist/{windowRuntime-BKkLPsAS.d.ts → windowRuntime-e1Tn6SnN.d.ts} +2 -2
- package/docs/api.md +28 -1
- package/docs/proposals/webloom-v4/requirements.md +1 -1
- package/docs/proposals/webloom-v4/verification.md +26 -11
- package/package.json +1 -1
- package/dist/chunk-ANA6GBEI.js.map +0 -1
- package/dist/chunk-HJKPKWI7.js.map +0 -1
- package/dist/chunk-SX46RHDI.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export { C as CreateWindowAppOptions, a as createWindowApp } from './windowRuntime-
|
|
5
|
-
export { c as createMessageBus } from './messageBus-
|
|
1
|
+
import { N as Capability, O as CapabilityDependency, Q as PluginContribution, T as PluginConfig, V as PluginContextExtension, R as RuntimeKind, e as PluginPermission, X as PluginSetup, Y as PluginDefinition } from './runtimeTypes-50LVQs0h.js';
|
|
2
|
+
export { Z as AppLike, _ as CapabilityBridge, $ as CapabilityClient, C as CapabilityDescriptor, a0 as CapabilityKind, k as CapabilityPeer, h as CreateUpgradeGateOptions, a1 as DefineLocalCapabilityOptions, a2 as DefineRpcCapabilityOptions, a3 as DefineStreamCapabilityOptions, a4 as DispatchOptions, a5 as EventHandler, a6 as FrameworkErrorCode, a7 as FrameworkErrorContext, a8 as FrameworkErrorPhase, a9 as HandlerCallContext, aa as HandlerOptions, ab as HandlerOrigin, ac as HostListener, ad as ItemOf, ae as LIFECYCLE_ERROR_TEXT, af as LifecycleCleanup, ag as LifecycleCleanupIssue, ah as LifecycleCleanupPhase, ai as LifecycleDisposeOptions, aj as LifecycleDisposeResult, ak as LifecycleResourceHandle, al as LifecycleResourceSnapshot, f as LifecycleScope, L as LifecycleScopeIdentity, am as LifecycleScopeKind, an as LifecycleScopeRevokedError, ao as LifecycleScopeState, ap as LocalCapability, aq as LocalServiceOf, ar as Message, as as MessageBus, at as MessageBusSnapshot, au as MessageHandler, av as MessageMode, aw as OwnedResourceDefinition, ax as PeerCapabilityDependency, ay as PeerScopeView, az as PermissionDeniedError, g as PermissionLease, aA as PermissionLeaseBinding, aB as PermissionLeaseBindingExpectation, aC as PermissionLeaseRevokedError, aD as PluginAttributes, aE as PluginContext, a as PluginGraph, aF as PluginIntentCommand, aG as PluginIntentCommandResult, aH as PluginIntentController, aI as PluginIntentCoordinator, aJ as PluginIntentSnapshot, aK as PluginIntentSubmissionResult, aL as PluginLifecycleState, P as PluginManifest, aM as PluginManifestInput, c as PluginReverseDep, aN as PluginStartupMode, aO as PluginState, aP as PluginStateKind, aQ as PluginTeardown, aR as PluginUnitGraph, aS as PluginUnitState, aT as PublishOptions, aU as RESOURCE_OWNER, aV as RESOURCE_REGISTRY, aW as RUNTIME_MESSAGE_BUS, aX as RemoteCapability, aY as RequestOf, aZ as RequestOptions, a_ as ResourceContext, a$ as ResourceDefinition, b0 as ResourceKey, b1 as ResourceRegistry, b2 as ResourceSnapshot, b3 as ResourceStatus, b4 as ResponseOf, b5 as RpcCallOptions, b6 as RpcCapability, b7 as RpcCapabilityBase, b8 as RpcClient, b9 as RpcHandler, ba as RpcTransferDescriptor, bb as RuntimeCapabilityDependency, l as RuntimeDrainResult, j as RuntimeEndpointBinding, bc as RuntimeEndpointState, n as RuntimeHandle, bd as RuntimeInitializationError, be as RuntimeLimits, bf as RuntimeServiceSnapshot, bg as RuntimeSnapshot, bh as RuntimeStatusListener, bi as RuntimeStatusSnapshot, bj as RuntimeUnavailableError, b as RuntimeUnitDependency, bk as RuntimeUnitDependencyInput, d as RuntimeUnitDescriptor, bl as RuntimeUnitDescriptorInput, bm as RuntimeUnitImplementationRegistry, bn as SCOPED_TASK_SCHEDULER_CAPABILITY, bo as ScopedTaskDefinition, S as ScopedTaskScheduler, bp as ScopedTaskSnapshot, i as ServiceReference, bq as SnapshotApplyResult, br as StartupCapabilityErrorDetails, bs as StartupPluginErrorDetails, bt as StreamCapability, bu as StreamCapabilityBase, bv as StreamClient, bw as StreamHandler, bx as StreamSubscribeOptions, by as StreamSubscription, bz as StreamTransferDescriptor, bA as TransferExtractor, bB as UpgradeDrainResult, U as UpgradeGate, bC as UpgradeGateRejectedError, bD as UpgradeGateState, bE as UpgradeHandshake, bF as UpgradeHandshakeResult, bG as UpgradeIoLease, bH as UpgradeMode, bI as UpgradeSession, bJ as ValueParser, bK as WebLoomError, W as WindowApp, bL as assertCapability, bM as capabilityDescriptor, bN as capabilityKey, bO as defineCapability, bP as isCapability, bQ as isCapabilityDescriptor, bR as lifecycleErrorText } from './runtimeTypes-50LVQs0h.js';
|
|
3
|
+
export { q as ConnectSharedWorkerOptions, P as PeerController, d as PeerExposureOptions, f as RuntimeLockError, g as RuntimeLockFailureCode, h as RuntimeLockHandle, i as RuntimeLockManagerLike, j as RuntimeLockMessages, k as RuntimeLockOptions, c as RuntimePluginDefinition, S as SharedWorkerApp, r as SharedWorkerLike, m as StartSharedWorkerAppOptions, W as WEBLOOM_RUNTIME_LOCK_PREFIX, s as connectSharedWorker, o as createLifecycleScope, p as createResourceScope, t as startSharedWorkerApp } from './sharedWorkerHost-DikS18hA.js';
|
|
4
|
+
export { C as CreateWindowAppOptions, a as createWindowApp } from './windowRuntime-e1Tn6SnN.js';
|
|
5
|
+
export { c as createMessageBus } from './messageBus-DigYfj74.js';
|
|
6
6
|
|
|
7
7
|
/** 普通插件定义选项;插件声明只使用 typed capability 与单一启动策略。 */
|
|
8
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> {
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { startSharedWorkerApp } from './chunk-
|
|
2
|
-
export { connectSharedWorker } from './chunk-
|
|
3
|
-
import { capabilityDescriptor } from './chunk-
|
|
4
|
-
export { LIFECYCLE_ERROR_TEXT, LifecycleScopeRevokedError, PermissionDeniedError, PermissionLeaseRevokedError, RESOURCE_OWNER, RESOURCE_REGISTRY, RuntimeInitializationError, RuntimeUnavailableError, SCOPED_TASK_SCHEDULER_CAPABILITY, UpgradeGateRejectedError, WebLoomError, assertCapability, capabilityDescriptor, capabilityKey, createLifecycleScope, createMessageBus, createResourceScope, createWindowApp, defineCapability, isCapability, isCapabilityDescriptor, lifecycleErrorText } from './chunk-
|
|
1
|
+
export { startSharedWorkerApp } from './chunk-UZAO6ORB.js';
|
|
2
|
+
export { RuntimeLockError, WEBLOOM_RUNTIME_LOCK_PREFIX, connectSharedWorker } from './chunk-YIIDRFHK.js';
|
|
3
|
+
import { capabilityDescriptor } from './chunk-ZP5QYTXX.js';
|
|
4
|
+
export { LIFECYCLE_ERROR_TEXT, LifecycleScopeRevokedError, PermissionDeniedError, PermissionLeaseRevokedError, RESOURCE_OWNER, RESOURCE_REGISTRY, RuntimeInitializationError, RuntimeUnavailableError, SCOPED_TASK_SCHEDULER_CAPABILITY, UpgradeGateRejectedError, WebLoomError, assertCapability, capabilityDescriptor, capabilityKey, createLifecycleScope, createMessageBus, createResourceScope, createWindowApp, defineCapability, isCapability, isCapabilityDescriptor, lifecycleErrorText } from './chunk-ZP5QYTXX.js';
|
|
5
5
|
|
|
6
6
|
// src/contracts/messageBus.ts
|
|
7
7
|
var RUNTIME_MESSAGE_BUS = "webloom.messageBus";
|
package/dist/{messagePortServiceTransport-BYprNvQY.d.ts → messagePortServiceTransport-B9-24RK6.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { R as ReceivePortLedger, a as RuntimeLimitsInput, b as RuntimeBudget } from './sharedWorkerHost-
|
|
1
|
+
import { X as PluginSetup, N as Capability, bm as RuntimeUnitImplementationRegistry, aJ as PluginIntentSnapshot, aH as PluginIntentController, b1 as ResourceRegistry, a$ as ResourceDefinition, bg as RuntimeSnapshot, j as RuntimeEndpointBinding, R as RuntimeKind, aP as PluginStateKind, bc as RuntimeEndpointState, l as RuntimeDrainResult, _ as CapabilityBridge } from './runtimeTypes-50LVQs0h.js';
|
|
2
|
+
import { R as ReceivePortLedger, a as RuntimeLimitsInput, b as RuntimeBudget } from './sharedWorkerHost-DikS18hA.js';
|
|
3
3
|
|
|
4
4
|
interface RuntimeUnitImplementation {
|
|
5
5
|
/** 产品标识。 */
|
|
@@ -51,6 +51,10 @@ declare const RUNTIME_ERROR_MESSAGE_TYPE: "webloom.runtime.v1.error";
|
|
|
51
51
|
declare const RUNTIME_CANCEL_TYPE: "webloom.runtime.v1.cancel";
|
|
52
52
|
declare const RUNTIME_NEXT_TYPE: "webloom.runtime.v1.next";
|
|
53
53
|
declare const RUNTIME_CREDIT_TYPE: "webloom.runtime.v1.credit";
|
|
54
|
+
declare const RUNTIME_CLOSE_TYPE: "webloom.runtime.v1.close";
|
|
55
|
+
declare const RUNTIME_CLOSE_ACK_TYPE: "webloom.runtime.v1.close-ack";
|
|
56
|
+
/** 每条 Runtime wire 消息所属的框架 endpoint 身份。 */
|
|
57
|
+
type RuntimeSessionBinding = RuntimeEndpointBinding;
|
|
54
58
|
interface RuntimeSnapshotUnit {
|
|
55
59
|
/** 插件标识。 */
|
|
56
60
|
readonly pluginId: string;
|
|
@@ -65,12 +69,15 @@ interface RuntimeSnapshotUnit {
|
|
|
65
69
|
}
|
|
66
70
|
type RuntimeSnapshotMessage = RuntimeSnapshot & {
|
|
67
71
|
readonly type: typeof RUNTIME_SNAPSHOT_TYPE;
|
|
72
|
+
readonly binding?: RuntimeSessionBinding;
|
|
68
73
|
};
|
|
69
74
|
interface RuntimeErrorMessage {
|
|
70
75
|
/** 消息类型。 */
|
|
71
76
|
readonly type: typeof RUNTIME_ERROR_TYPE;
|
|
72
77
|
/** 协议版本。 */
|
|
73
78
|
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
79
|
+
/** 发送此错误的物理 endpoint 绑定。 */
|
|
80
|
+
readonly binding?: RuntimeSessionBinding;
|
|
74
81
|
/** 结构化错误码。 */
|
|
75
82
|
readonly code: string;
|
|
76
83
|
/** 脱敏消息。 */
|
|
@@ -87,6 +94,8 @@ interface RuntimeCallMessage {
|
|
|
87
94
|
readonly type: typeof RUNTIME_CALL_TYPE;
|
|
88
95
|
/** 协议版本。 */
|
|
89
96
|
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
97
|
+
/** 发起调用的物理 endpoint 绑定。 */
|
|
98
|
+
readonly binding?: RuntimeSessionBinding;
|
|
90
99
|
/** 方向内唯一 call id。 */
|
|
91
100
|
readonly callId: string;
|
|
92
101
|
/** capability 标识。 */
|
|
@@ -113,6 +122,8 @@ interface RuntimeUnaryResultMessage {
|
|
|
113
122
|
readonly type: typeof RUNTIME_RESULT_TYPE;
|
|
114
123
|
/** 协议版本。 */
|
|
115
124
|
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
125
|
+
/** 发送结果的物理 endpoint 绑定。 */
|
|
126
|
+
readonly binding?: RuntimeSessionBinding;
|
|
116
127
|
/** call id。 */
|
|
117
128
|
readonly callId: string;
|
|
118
129
|
/** exposure 身份。 */
|
|
@@ -125,6 +136,8 @@ interface RuntimeStreamReadyMessage {
|
|
|
125
136
|
readonly type: typeof RUNTIME_RESULT_TYPE;
|
|
126
137
|
/** 协议版本。 */
|
|
127
138
|
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
139
|
+
/** 发送结果的物理 endpoint 绑定。 */
|
|
140
|
+
readonly binding?: RuntimeSessionBinding;
|
|
128
141
|
/** call id。 */
|
|
129
142
|
readonly callId: string;
|
|
130
143
|
/** exposure 身份。 */
|
|
@@ -137,6 +150,8 @@ interface RuntimeStreamDoneMessage {
|
|
|
137
150
|
readonly type: typeof RUNTIME_RESULT_TYPE;
|
|
138
151
|
/** 协议版本。 */
|
|
139
152
|
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
153
|
+
/** 发送结果的物理 endpoint 绑定。 */
|
|
154
|
+
readonly binding?: RuntimeSessionBinding;
|
|
140
155
|
/** call id。 */
|
|
141
156
|
readonly callId: string;
|
|
142
157
|
/** exposure 身份。 */
|
|
@@ -150,6 +165,8 @@ interface RuntimeErrorResponseMessage {
|
|
|
150
165
|
readonly type: typeof RUNTIME_ERROR_MESSAGE_TYPE;
|
|
151
166
|
/** 协议版本。 */
|
|
152
167
|
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
168
|
+
/** 发送错误响应的物理 endpoint 绑定。 */
|
|
169
|
+
readonly binding?: RuntimeSessionBinding;
|
|
153
170
|
/** call id。 */
|
|
154
171
|
readonly callId: string;
|
|
155
172
|
/** exposure 身份。 */
|
|
@@ -167,6 +184,8 @@ interface RuntimeCancelMessage {
|
|
|
167
184
|
readonly type: typeof RUNTIME_CANCEL_TYPE;
|
|
168
185
|
/** 协议版本。 */
|
|
169
186
|
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
187
|
+
/** 发送取消的物理 endpoint 绑定。 */
|
|
188
|
+
readonly binding?: RuntimeSessionBinding;
|
|
170
189
|
/** call id。 */
|
|
171
190
|
readonly callId: string;
|
|
172
191
|
/** exposure 身份。 */
|
|
@@ -177,6 +196,8 @@ interface RuntimeNextMessage {
|
|
|
177
196
|
readonly type: typeof RUNTIME_NEXT_TYPE;
|
|
178
197
|
/** 协议版本。 */
|
|
179
198
|
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
199
|
+
/** 发送 stream item 的物理 endpoint 绑定。 */
|
|
200
|
+
readonly binding?: RuntimeSessionBinding;
|
|
180
201
|
/** call id。 */
|
|
181
202
|
readonly callId: string;
|
|
182
203
|
/** exposure 身份。 */
|
|
@@ -191,6 +212,8 @@ interface RuntimeCreditMessage {
|
|
|
191
212
|
readonly type: typeof RUNTIME_CREDIT_TYPE;
|
|
192
213
|
/** 协议版本。 */
|
|
193
214
|
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
215
|
+
/** 发送 credit 的物理 endpoint 绑定。 */
|
|
216
|
+
readonly binding?: RuntimeSessionBinding;
|
|
194
217
|
/** call id。 */
|
|
195
218
|
readonly callId: string;
|
|
196
219
|
/** exposure 身份。 */
|
|
@@ -198,7 +221,35 @@ interface RuntimeCreditMessage {
|
|
|
198
221
|
/** 新增 credit。 */
|
|
199
222
|
readonly count: number;
|
|
200
223
|
}
|
|
201
|
-
|
|
224
|
+
/** 请求对端先同步 fence、再等待真实执行排空。 */
|
|
225
|
+
interface RuntimeCloseMessage {
|
|
226
|
+
/** 消息类型。 */
|
|
227
|
+
readonly type: typeof RUNTIME_CLOSE_TYPE;
|
|
228
|
+
/** 协议版本。 */
|
|
229
|
+
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
230
|
+
/** 发起关闭的物理 endpoint 绑定。 */
|
|
231
|
+
readonly binding?: RuntimeSessionBinding;
|
|
232
|
+
/** 对端 drain 的最大等待时间。 */
|
|
233
|
+
readonly timeoutMs?: number;
|
|
234
|
+
}
|
|
235
|
+
/** 对端完成或超时 drain 后返回的关闭确认。 */
|
|
236
|
+
interface RuntimeCloseAckMessage {
|
|
237
|
+
/** 消息类型。 */
|
|
238
|
+
readonly type: typeof RUNTIME_CLOSE_ACK_TYPE;
|
|
239
|
+
/** 协议版本。 */
|
|
240
|
+
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
241
|
+
/** 发送确认的物理 endpoint 绑定。 */
|
|
242
|
+
readonly binding: RuntimeSessionBinding;
|
|
243
|
+
/** 确认对应的发起方 binding,防止旧 close-ack 误配新 session。 */
|
|
244
|
+
readonly acknowledgedBinding: RuntimeSessionBinding;
|
|
245
|
+
/** 对端本次 drain 的结果。 */
|
|
246
|
+
readonly drained: boolean;
|
|
247
|
+
/** 是否达到 bounded deadline。 */
|
|
248
|
+
readonly timedOut: boolean;
|
|
249
|
+
/** deadline 到达时仍存活的执行槽数量。 */
|
|
250
|
+
readonly pendingExecutions: number;
|
|
251
|
+
}
|
|
252
|
+
type RuntimeWireMessage = RuntimeSnapshotMessage | RuntimeErrorMessage | RuntimeCallMessage | RuntimeResultMessage | RuntimeErrorResponseMessage | RuntimeCancelMessage | RuntimeNextMessage | RuntimeCreditMessage | RuntimeCloseMessage | RuntimeCloseAckMessage;
|
|
202
253
|
interface RuntimeMessageCodec {
|
|
203
254
|
/** 严格验证并冻结 v4 message。 */
|
|
204
255
|
encode(message: RuntimeWireMessage): RuntimeWireMessage;
|
|
@@ -208,6 +259,40 @@ interface RuntimeMessageCodec {
|
|
|
208
259
|
declare function createRuntimeMessageCodec(): RuntimeMessageCodec;
|
|
209
260
|
declare function isRuntimeSnapshot(value: RuntimeWireMessage): value is RuntimeSnapshotMessage;
|
|
210
261
|
|
|
262
|
+
/** 一个需要等待真实执行槽结束的框架参与者。 */
|
|
263
|
+
interface RuntimeDrainParticipant {
|
|
264
|
+
/** 等待该参与者自己的真实执行槽结束。 */
|
|
265
|
+
readonly drain: () => Promise<void>;
|
|
266
|
+
/** deadline 到达时报告仍未结束的真实执行槽数量。 */
|
|
267
|
+
readonly pending: () => number;
|
|
268
|
+
}
|
|
269
|
+
interface RuntimeEndpointSession {
|
|
270
|
+
/** 本端由框架生成、不可复用的 endpoint 身份。 */
|
|
271
|
+
readonly binding: RuntimeEndpointBinding;
|
|
272
|
+
/** 已由对端首条合法框架消息建立的身份;尚未建立时为空。 */
|
|
273
|
+
readonly remoteBinding?: RuntimeEndpointBinding;
|
|
274
|
+
/** active -> closing -> closed。 */
|
|
275
|
+
readonly state: RuntimeEndpointState;
|
|
276
|
+
/** 最近一次同步关闭原因;只用于本地诊断。 */
|
|
277
|
+
readonly closeReason?: string;
|
|
278
|
+
/** 本端允许的最大 drain 时间;远端只能进一步收紧,不能扩大。 */
|
|
279
|
+
readonly maxDrainTimeoutMs: number;
|
|
280
|
+
/** 精确比较并建立对端 binding;不接受后续替换。 */
|
|
281
|
+
acceptRemoteBinding(binding: unknown): boolean;
|
|
282
|
+
/** 同步停止准入、触发撤权和 abort;幂等。 */
|
|
283
|
+
beginClose(reason?: string): void;
|
|
284
|
+
/** 等待全部参与者排空,始终受 bounded deadline 限制。 */
|
|
285
|
+
drain(timeoutMs?: number): Promise<RuntimeDrainResult>;
|
|
286
|
+
/** 物理 transport 即将关闭时标记终态;幂等。 */
|
|
287
|
+
close(): void;
|
|
288
|
+
/** 注册同步关闭回调。 */
|
|
289
|
+
onBeginClose(listener: (reason: string) => void): () => void;
|
|
290
|
+
/** 注册物理关闭回调。 */
|
|
291
|
+
onClosed(listener: () => void): () => void;
|
|
292
|
+
/** 注册一个真实执行排空参与者。 */
|
|
293
|
+
registerDrainParticipant(participant: RuntimeDrainParticipant): () => void;
|
|
294
|
+
}
|
|
295
|
+
|
|
211
296
|
interface RuntimeReceiveMetadata {
|
|
212
297
|
/** 本次 MessageEvent 实际携带的业务 MessagePort;仅 transport 本地使用。 */
|
|
213
298
|
readonly ports?: readonly MessagePort[];
|
|
@@ -239,6 +324,12 @@ interface CreateCapabilityBridgeOptions {
|
|
|
239
324
|
readonly limits?: RuntimeLimitsInput;
|
|
240
325
|
/** 可选的 Runtime 方向共享计数器。 */
|
|
241
326
|
readonly budget?: RuntimeBudget;
|
|
327
|
+
/** 当前物理 endpoint 的框架 binding;省略时由 bridge 生成。 */
|
|
328
|
+
readonly binding?: RuntimeEndpointBinding;
|
|
329
|
+
/** 与反向 provider 共用的 endpoint session。 */
|
|
330
|
+
readonly session?: RuntimeEndpointSession;
|
|
331
|
+
/** 关闭握手默认 drain deadline。 */
|
|
332
|
+
readonly drainTimeoutMs?: number;
|
|
242
333
|
}
|
|
243
334
|
/** 创建按 peer 绑定、可撤销且支持 typed stream 的 bridge。 */
|
|
244
335
|
declare function createCapabilityBridge(options: CreateCapabilityBridgeOptions): CapabilityBridge & {
|
|
@@ -261,4 +352,4 @@ declare function createMessagePortRuntimeTransport(port: MessagePortLike, option
|
|
|
261
352
|
readonly limits?: RuntimeLimitsInput;
|
|
262
353
|
}): RuntimeTransport;
|
|
263
354
|
|
|
264
|
-
export {
|
|
355
|
+
export { type RuntimeSnapshotUnit as A, type RuntimeStreamDoneMessage as B, type CreateCapabilityBridgeOptions as C, type RuntimeStreamReadyMessage as D, type RuntimeUnaryResultMessage as E, type RuntimeUnitImplementation as F, type RuntimeWireMessage as G, createCapabilityBridge as H, createMessagePortRuntimeTransport as I, createPluginIntentController as J, createResourceRegistry as K, createRuntimeMessageCodec as L, type MessagePortLike as M, createRuntimeUnitImplementationRegistry as N, isRuntimeSnapshot as O, registerOwnedResource as P, validateTransferables as Q, type RuntimeCallMessage as R, type RuntimeTransport as a, type RuntimeEndpointSession as b, type CreatePluginIntentControllerOptions as c, RUNTIME_CALL_TYPE as d, RUNTIME_CANCEL_TYPE as e, RUNTIME_CLOSE_ACK_TYPE as f, RUNTIME_CLOSE_TYPE as g, RUNTIME_CREDIT_TYPE as h, RUNTIME_ERROR_MESSAGE_TYPE as i, RUNTIME_ERROR_TYPE as j, RUNTIME_NEXT_TYPE as k, RUNTIME_PROTOCOL_VERSION as l, RUNTIME_RESULT_TYPE as m, RUNTIME_SNAPSHOT_TYPE as n, type RuntimeCancelMessage as o, type RuntimeCloseAckMessage as p, type RuntimeCloseMessage as q, type RuntimeCreditMessage as r, type RuntimeErrorMessage as s, type RuntimeErrorResponseMessage as t, type RuntimeMessageCodec as u, type RuntimeNextMessage as v, type RuntimeReceiveMetadata as w, type RuntimeResultMessage as x, type RuntimeSessionBinding as y, type RuntimeSnapshotMessage as z };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import { W as WindowApp,
|
|
4
|
+
import { W as WindowApp, n as RuntimeHandle, N as Capability, $ as CapabilityClient, Z as AppLike, aO as PluginState, a as PluginGraph, c as PluginReverseDep, aK as PluginIntentSubmissionResult, P as PluginManifest, C as CapabilityDescriptor, m as ResourceStoreApi, b2 as ResourceSnapshot } from './runtimeTypes-50LVQs0h.js';
|
|
5
5
|
|
|
6
6
|
type WebLoomApp = WindowApp | RuntimeHandle;
|
|
7
7
|
declare const WebLoomContext: react.Context<WebLoomApp | undefined>;
|
package/dist/react.js
CHANGED
|
@@ -393,6 +393,32 @@ type LifecycleScopeState = "active" | "stopping" | "stopped";
|
|
|
393
393
|
type RuntimeKind = "window-main" | "shared-worker";
|
|
394
394
|
/** 权限动作名称。 */
|
|
395
395
|
type PluginPermission = string;
|
|
396
|
+
/**
|
|
397
|
+
* WebLoom 为每条物理 Runtime endpoint 生成的连接绑定。
|
|
398
|
+
*
|
|
399
|
+
* `runtimeInstanceId` 标识一次 Runtime 启动,`connectionId` 标识该启动内
|
|
400
|
+
* 的一条物理连接。两者只能由框架创建并且不得复用;它不是产品领域的
|
|
401
|
+
* lease、owner 或领域 generation,也不能由请求载荷覆盖。
|
|
402
|
+
*/
|
|
403
|
+
interface RuntimeEndpointBinding {
|
|
404
|
+
/** 产生此 endpoint 的 Runtime 启动身份。 */
|
|
405
|
+
readonly runtimeInstanceId: string;
|
|
406
|
+
/** 此 Runtime 启动内不可复用的物理连接身份。 */
|
|
407
|
+
readonly connectionId: string;
|
|
408
|
+
}
|
|
409
|
+
/** Runtime endpoint 的通用关闭阶段。 */
|
|
410
|
+
type RuntimeEndpointState = "active" | "closing" | "closed";
|
|
411
|
+
/** 一次 bounded drain 的结果;超时不伪装成已经排空。 */
|
|
412
|
+
interface RuntimeDrainResult {
|
|
413
|
+
/** 关闭阶段结束时的状态。 */
|
|
414
|
+
readonly state: RuntimeEndpointState;
|
|
415
|
+
/** 是否在 deadline 前等待到所有框架执行槽结束。 */
|
|
416
|
+
readonly drained: boolean;
|
|
417
|
+
/** 是否达到 bounded deadline。 */
|
|
418
|
+
readonly timedOut: boolean;
|
|
419
|
+
/** deadline 到达时仍未完成的真实执行槽数量。 */
|
|
420
|
+
readonly pendingExecutions: number;
|
|
421
|
+
}
|
|
396
422
|
/** 一个作用域的不可替换身份绑定。 */
|
|
397
423
|
interface LifecycleScopeIdentity<TAttributes extends Readonly<Record<string, unknown>> = Readonly<Record<string, unknown>>> {
|
|
398
424
|
/** 作用域唯一标识。 */
|
|
@@ -571,6 +597,8 @@ interface RuntimeServiceSnapshot {
|
|
|
571
597
|
interface RuntimeSnapshot {
|
|
572
598
|
/** 固定协议版本。 */
|
|
573
599
|
protocolVersion: string;
|
|
600
|
+
/** 当前物理 endpoint 的框架绑定;旧兼容快照可以省略,收到后由 transport 补齐。 */
|
|
601
|
+
readonly binding?: RuntimeEndpointBinding;
|
|
574
602
|
/** Runtime 逻辑标识。 */
|
|
575
603
|
runtimeId: string;
|
|
576
604
|
/** 真实 Runtime 类型。 */
|
|
@@ -654,7 +682,7 @@ type SnapshotApplyResult = {
|
|
|
654
682
|
receivedRevision?: number;
|
|
655
683
|
};
|
|
656
684
|
/** 框架结构化错误码。 */
|
|
657
|
-
type FrameworkErrorCode = "protocol_mismatch" | "invalid_snapshot" | "capability_unavailable" | "contract_mismatch" | "request_validation_failed" | "response_validation_failed" | "request_clone_failed" | "response_clone_failed" | "transfer_invalid" | "handler_failed" | "call_timeout" | "request_cancelled" | "service_revoked" | "service_stale" | "transport_unavailable" | "runtime_initialization_failed" | "stream_overflow" | "resource_limit_exceeded" | "permission_denied" | (string & {});
|
|
685
|
+
type FrameworkErrorCode = "protocol_mismatch" | "invalid_snapshot" | "capability_unavailable" | "contract_mismatch" | "request_validation_failed" | "response_validation_failed" | "request_clone_failed" | "response_clone_failed" | "transfer_invalid" | "handler_failed" | "call_timeout" | "request_cancelled" | "service_revoked" | "service_stale" | "transport_unavailable" | "runtime_initialization_failed" | "stream_overflow" | "resource_limit_exceeded" | "permission_denied" | "session_binding_mismatch" | (string & {});
|
|
658
686
|
/** 框架错误阶段。 */
|
|
659
687
|
type FrameworkErrorPhase = "validate" | "wait" | "dispatch" | "execute" | "receive" | "dispose";
|
|
660
688
|
/** 脱敏错误上下文。 */
|
|
@@ -1024,6 +1052,8 @@ interface ServiceReference {
|
|
|
1024
1052
|
interface CapabilityPeer {
|
|
1025
1053
|
/** 对端连接的不可复用身份。 */
|
|
1026
1054
|
readonly peerId: string;
|
|
1055
|
+
/** 当前物理 endpoint 的框架 binding;不包含产品领域授权。 */
|
|
1056
|
+
readonly binding: RuntimeEndpointBinding;
|
|
1027
1057
|
/** 已观察到的对端 Runtime 类型;首个快照前为空。 */
|
|
1028
1058
|
readonly runtime?: RuntimeKind;
|
|
1029
1059
|
/** 已观察到的对端 Runtime 一次启动身份;首个快照前为空。 */
|
|
@@ -1068,9 +1098,14 @@ interface CapabilityBridge {
|
|
|
1068
1098
|
readonly runtimeInstanceId?: string;
|
|
1069
1099
|
/** 当前已观察到的对端 Runtime 类型;快照到达前为空。 */
|
|
1070
1100
|
readonly runtimeKind?: RuntimeKind;
|
|
1101
|
+
/** 本端物理 endpoint 的框架 binding。 */
|
|
1102
|
+
readonly binding: RuntimeEndpointBinding;
|
|
1103
|
+
/** 当前 endpoint 生命周期;与远端 Runtime state 独立。 */
|
|
1104
|
+
readonly endpointState: RuntimeEndpointState;
|
|
1071
1105
|
/** 取惰性 typed client;没有服务时不在此处同步失败。 */
|
|
1072
1106
|
getClient<C extends RemoteCapability>(capability: C, scope?: LifecycleScope): CapabilityClient<C>;
|
|
1073
1107
|
/** 应用一个完整对端目录。 */
|
|
1108
|
+
/** 应用一个远端完整目录;生产 wire 带 binding,旧 testing fixture 可省略。 */
|
|
1074
1109
|
applySnapshot(snapshot: RuntimeSnapshot): SnapshotApplyResult;
|
|
1075
1110
|
/** 同步撤销全部旧代理。 */
|
|
1076
1111
|
invalidate(reason?: string): void;
|
|
@@ -1078,6 +1113,10 @@ interface CapabilityBridge {
|
|
|
1078
1113
|
disconnect(reason?: string): void;
|
|
1079
1114
|
/** 永久销毁 bridge。 */
|
|
1080
1115
|
dispose(reason?: string): void;
|
|
1116
|
+
/** 同步停止新调用、撤销代理并 abort 已进入调用;幂等。 */
|
|
1117
|
+
beginClose(reason?: string): void;
|
|
1118
|
+
/** 等待本端与对端框架执行槽 bounded drain;超时不伪装成功。 */
|
|
1119
|
+
drain(timeoutMs?: number): Promise<RuntimeDrainResult>;
|
|
1081
1120
|
/** 订阅目录/连接状态变化。 */
|
|
1082
1121
|
subscribe(listener: () => void): () => void;
|
|
1083
1122
|
/** 当前已发布的完整服务引用。 */
|
|
@@ -1093,6 +1132,8 @@ interface HandlerCallContext {
|
|
|
1093
1132
|
readonly operationId?: string;
|
|
1094
1133
|
/** 当前服务 exposure 身份。 */
|
|
1095
1134
|
readonly reference: ServiceReference;
|
|
1135
|
+
/** 远程调用对应的框架 endpoint binding;同 realm 调用没有物理 endpoint。 */
|
|
1136
|
+
readonly binding?: RuntimeEndpointBinding;
|
|
1096
1137
|
/** 调用来源。 */
|
|
1097
1138
|
readonly origin: HandlerOrigin;
|
|
1098
1139
|
/** 远程调用的框架绑定对端;local 调用必为 undefined。 */
|
|
@@ -1581,8 +1622,12 @@ interface RuntimeStatusSnapshot extends Omit<RuntimeSnapshot, "protocolVersion"
|
|
|
1581
1622
|
readonly protocolVersion: string;
|
|
1582
1623
|
/** Runtime 当前状态。 */
|
|
1583
1624
|
readonly state: RuntimeAppState;
|
|
1625
|
+
/** 当前观察到的远端物理 endpoint binding;本地 WindowApp 不填写。 */
|
|
1626
|
+
readonly binding?: RuntimeEndpointBinding;
|
|
1584
1627
|
/** 脱敏 Runtime 错误。 */
|
|
1585
1628
|
readonly error?: string;
|
|
1629
|
+
/** 结构化运行错误码,例如 runtime_lock_conflict。 */
|
|
1630
|
+
readonly errorCode?: string;
|
|
1586
1631
|
}
|
|
1587
1632
|
type RuntimeStatusListener = (snapshot: RuntimeStatusSnapshot) => void;
|
|
1588
1633
|
interface AppLike {
|
|
@@ -1612,10 +1657,18 @@ interface WindowApp extends AppLike {
|
|
|
1612
1657
|
}
|
|
1613
1658
|
interface RuntimeHandle extends AppLike {
|
|
1614
1659
|
readonly runtimeKind: "shared-worker";
|
|
1660
|
+
/** 当前 Window ↔ Worker 物理 endpoint 的不可复用框架 binding。 */
|
|
1661
|
+
readonly binding: RuntimeEndpointBinding;
|
|
1662
|
+
/** 当前物理连接生命周期;不等同于远端 Runtime state。 */
|
|
1663
|
+
readonly endpointState: RuntimeEndpointState;
|
|
1615
1664
|
/** 获取远程 typed RPC/stream capability;代理构造不等待 Worker。 */
|
|
1616
1665
|
capability<C extends RemoteCapability>(capability: C): CapabilityClient<C>;
|
|
1617
1666
|
/** 当前已观察到的 remote capability。 */
|
|
1618
1667
|
optionalCapability<C extends RemoteCapability>(capability: C): CapabilityClient<C> | undefined;
|
|
1668
|
+
/** 同步停止新调用与本端反向 handler admission。 */
|
|
1669
|
+
beginClose(reason?: string): void;
|
|
1670
|
+
/** 等待本端及远端框架执行槽的 bounded drain。 */
|
|
1671
|
+
drain(timeoutMs?: number): Promise<RuntimeDrainResult>;
|
|
1619
1672
|
}
|
|
1620
1673
|
declare class RuntimeInitializationError extends Error {
|
|
1621
1674
|
readonly code: "runtime_initialization_failed";
|
|
@@ -1637,4 +1690,4 @@ declare class RuntimeUnavailableError extends Error {
|
|
|
1637
1690
|
constructor(message?: string);
|
|
1638
1691
|
}
|
|
1639
1692
|
|
|
1640
|
-
export { type
|
|
1693
|
+
export { type CapabilityClient as $, type RuntimeUnitAttributesInput as A, type RuntimeUnitAvailabilityInput as B, type CapabilityDescriptor as C, type RuntimeUnitParentScopeInput as D, type RuntimeUnitSnapshot as E, StartupCapabilityError as F, StartupPluginError as G, type HostCapabilityRegistration as H, createCapabilityRegistry as I, createInMemoryPluginConfigStore as J, createPluginHost as K, type LifecycleScopeIdentity as L, invokeCapabilityHandler as M, type Capability as N, type CapabilityDependency as O, type PluginManifest as P, type PluginContribution as Q, type RuntimeKind as R, type ScopedTaskScheduler as S, type PluginConfig as T, type UpgradeGate as U, type PluginContextExtension as V, type WindowApp as W, type PluginSetup as X, type PluginDefinition as Y, type AppLike as Z, type CapabilityBridge as _, type PluginGraph as a, type ResourceDefinition as a$, type CapabilityKind as a0, type DefineLocalCapabilityOptions as a1, type DefineRpcCapabilityOptions as a2, type DefineStreamCapabilityOptions as a3, type DispatchOptions as a4, type EventHandler as a5, type FrameworkErrorCode as a6, type FrameworkErrorContext as a7, type FrameworkErrorPhase as a8, type HandlerCallContext as a9, type PermissionLeaseBinding as aA, type PermissionLeaseBindingExpectation as aB, PermissionLeaseRevokedError as aC, type PluginAttributes as aD, type PluginContext as aE, type PluginIntentCommand as aF, type PluginIntentCommandResult as aG, type PluginIntentController as aH, type PluginIntentCoordinator as aI, type PluginIntentSnapshot as aJ, type PluginIntentSubmissionResult as aK, type PluginLifecycleState as aL, type PluginManifestInput as aM, type PluginStartupMode as aN, type PluginState as aO, type PluginStateKind as aP, type PluginTeardown as aQ, type PluginUnitGraph as aR, type PluginUnitState as aS, type PublishOptions as aT, RESOURCE_OWNER as aU, RESOURCE_REGISTRY as aV, RUNTIME_MESSAGE_BUS as aW, type RemoteCapability as aX, type RequestOf as aY, type RequestOptions as aZ, type ResourceContext as a_, type HandlerOptions as aa, type HandlerOrigin as ab, type HostListener as ac, type ItemOf as ad, LIFECYCLE_ERROR_TEXT as ae, type LifecycleCleanup as af, type LifecycleCleanupIssue as ag, type LifecycleCleanupPhase as ah, type LifecycleDisposeOptions as ai, type LifecycleDisposeResult as aj, type LifecycleResourceHandle as ak, type LifecycleResourceSnapshot as al, type LifecycleScopeKind as am, LifecycleScopeRevokedError as an, type LifecycleScopeState as ao, type LocalCapability as ap, type LocalServiceOf as aq, type Message as ar, type MessageBus as as, type MessageBusSnapshot as at, type MessageHandler as au, type MessageMode as av, type OwnedResourceDefinition as aw, type PeerCapabilityDependency as ax, type PeerScopeView as ay, PermissionDeniedError as az, type RuntimeUnitDependency as b, type ResourceKey as b0, type ResourceRegistry as b1, type ResourceSnapshot as b2, type ResourceStatus as b3, type ResponseOf as b4, type RpcCallOptions as b5, type RpcCapability as b6, type RpcCapabilityBase as b7, type RpcClient as b8, type RpcHandler as b9, type TransferExtractor as bA, type UpgradeDrainResult as bB, UpgradeGateRejectedError as bC, type UpgradeGateState as bD, type UpgradeHandshake as bE, type UpgradeHandshakeResult as bF, type UpgradeIoLease as bG, type UpgradeMode as bH, type UpgradeSession as bI, type ValueParser as bJ, WebLoomError as bK, assertCapability as bL, capabilityDescriptor as bM, capabilityKey as bN, defineCapability as bO, isCapability as bP, isCapabilityDescriptor as bQ, lifecycleErrorText as bR, createResourceStore as bS, type RpcTransferDescriptor as ba, type RuntimeCapabilityDependency as bb, type RuntimeEndpointState as bc, RuntimeInitializationError as bd, type RuntimeLimits as be, type RuntimeServiceSnapshot as bf, type RuntimeSnapshot as bg, type RuntimeStatusListener as bh, type RuntimeStatusSnapshot as bi, RuntimeUnavailableError as bj, type RuntimeUnitDependencyInput as bk, type RuntimeUnitDescriptorInput as bl, type RuntimeUnitImplementationRegistry as bm, SCOPED_TASK_SCHEDULER_CAPABILITY as bn, type ScopedTaskDefinition as bo, type ScopedTaskSnapshot as bp, type SnapshotApplyResult as bq, type StartupCapabilityErrorDetails as br, type StartupPluginErrorDetails as bs, type StreamCapability as bt, type StreamCapabilityBase as bu, type StreamClient as bv, type StreamHandler as bw, type StreamSubscribeOptions as bx, type StreamSubscription as by, type StreamTransferDescriptor as bz, type PluginReverseDep as c, type RuntimeUnitDescriptor as d, type PluginPermission as e, type LifecycleScope as f, type PermissionLease as g, type CreateUpgradeGateOptions as h, type ServiceReference as i, type RuntimeEndpointBinding as j, type CapabilityPeer as k, type RuntimeDrainResult as l, type ResourceStoreApi as m, type RuntimeHandle as n, type CapabilityRegistration as o, type CapabilityRegistry as p, type ContextExtensionInput as q, type ContributionAdapter as r, type ContributionAdapterInput as s, type ContributionHandle as t, type CreatePluginHostOptions as u, type HostInspection as v, type PermissionPolicyInput as w, type PermissionPolicyResult as x, type PluginConfigStore as y, type PluginHost as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { am as LifecycleScopeKind, L as LifecycleScopeIdentity, f as LifecycleScope, aj as LifecycleDisposeResult, be as RuntimeLimits, P as PluginManifest, X as PluginSetup, N as Capability, n as RuntimeHandle, _ as CapabilityBridge, W as WindowApp, aX as RemoteCapability, j as RuntimeEndpointBinding, bc as RuntimeEndpointState, k as CapabilityPeer, $ as CapabilityClient, a9 as HandlerCallContext, l as RuntimeDrainResult, bi as RuntimeStatusSnapshot, bh as RuntimeStatusListener, v as HostInspection, u as CreatePluginHostOptions } from './runtimeTypes-50LVQs0h.js';
|
|
2
2
|
|
|
3
3
|
interface CreateResourceScopeOptions {
|
|
4
4
|
/** 可选固定作用域标识;生产代码通常省略,让实现生成不可复用 ID。 */
|
|
@@ -106,6 +106,53 @@ declare function connectSharedWorkerForTesting(options: ConnectSharedWorkerOptio
|
|
|
106
106
|
/** advanced 装配层取得连接 bridge;普通 RuntimeHandle 不暴露该实现细节。 */
|
|
107
107
|
declare function bridgeForRuntimeHandle(handle: RuntimeHandle): CapabilityBridge;
|
|
108
108
|
|
|
109
|
+
declare const WEBLOOM_RUNTIME_LOCK_PREFIX: "webloom.runtime";
|
|
110
|
+
/** 浏览器 LockManager 的最小可信接口,便于在 Node/单测中注入替身。 */
|
|
111
|
+
interface RuntimeLockManagerLike {
|
|
112
|
+
request<T>(name: string, options: {
|
|
113
|
+
readonly mode: "exclusive";
|
|
114
|
+
readonly ifAvailable: true;
|
|
115
|
+
}, callback: (lock: RuntimeLockLike | null) => T | PromiseLike<T>): Promise<T>;
|
|
116
|
+
}
|
|
117
|
+
/** 浏览器授予的临时锁对象;业务不能依赖它保存任何状态。 */
|
|
118
|
+
interface RuntimeLockLike {
|
|
119
|
+
readonly name: string;
|
|
120
|
+
readonly mode: "exclusive" | "shared";
|
|
121
|
+
}
|
|
122
|
+
type RuntimeLockFailureCode = "runtime_lock_conflict" | "runtime_lock_unavailable";
|
|
123
|
+
interface RuntimeLockMessages {
|
|
124
|
+
/** 已有运行实例时显示的用户提示;应用可以替换为自己的产品名称。 */
|
|
125
|
+
readonly conflict?: string;
|
|
126
|
+
/** 浏览器没有 Web Locks 时显示的用户提示;应用可以替换为自己的产品名称。 */
|
|
127
|
+
readonly unavailable?: string;
|
|
128
|
+
}
|
|
129
|
+
/** WebLoom 运行锁失败;code 会通过 Runtime 状态和 wire 错误公开。 */
|
|
130
|
+
declare class RuntimeLockError extends Error {
|
|
131
|
+
readonly code: RuntimeLockFailureCode;
|
|
132
|
+
readonly lockName: string;
|
|
133
|
+
constructor(code: RuntimeLockFailureCode, lockName: string, messages?: RuntimeLockMessages);
|
|
134
|
+
}
|
|
135
|
+
/** 锁名由 runtimeId 固定生成,不允许调用方拼接构建号、版本号或 Worker URL,避免升级后意外得到不同的锁。 */
|
|
136
|
+
interface RuntimeLockOptions {
|
|
137
|
+
/** 测试可注入 LockManager;生产默认读取 navigator.locks。null 表示明确模拟不支持。 */
|
|
138
|
+
readonly manager?: RuntimeLockManagerLike | null;
|
|
139
|
+
/** 应用层中文提示;WebLoom 不绑定任何具体业务产品名称。 */
|
|
140
|
+
readonly messages?: RuntimeLockMessages;
|
|
141
|
+
}
|
|
142
|
+
interface RuntimeLockHandle {
|
|
143
|
+
/** 锁名,便于诊断;不会写入 localStorage/IndexedDB/业务桶。 */
|
|
144
|
+
readonly name: string;
|
|
145
|
+
/** 取得锁后完成;冲突或 API 缺失时拒绝。 */
|
|
146
|
+
readonly acquired: Promise<void>;
|
|
147
|
+
/** 结束 LockManager 回调并等待浏览器确认释放;Worker 终止时也会自动释放。 */
|
|
148
|
+
release(): Promise<void>;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* testing 入口使用的进程内 LockManager;它只用于单测,不是生产回退。
|
|
152
|
+
* 生产入口如果 navigator.locks 不存在仍然必须失败。
|
|
153
|
+
*/
|
|
154
|
+
declare function createInMemoryRuntimeLockManager(): RuntimeLockManagerLike;
|
|
155
|
+
|
|
109
156
|
interface SharedWorkerScopeLike {
|
|
110
157
|
/** SharedWorker 连接事件。 */
|
|
111
158
|
onconnect: ((event: {
|
|
@@ -127,6 +174,10 @@ interface PeerExposureOptions {
|
|
|
127
174
|
interface PeerController {
|
|
128
175
|
/** peer 标识。 */
|
|
129
176
|
readonly peerId: string;
|
|
177
|
+
/** 当前物理 endpoint 的不可复用框架 binding。 */
|
|
178
|
+
readonly binding: RuntimeEndpointBinding;
|
|
179
|
+
/** 当前物理 endpoint 的关闭阶段。 */
|
|
180
|
+
readonly endpointState: RuntimeEndpointState;
|
|
130
181
|
/** 已观察到的页面 Runtime 实例;首个页面快照前为空。 */
|
|
131
182
|
readonly runtimeInstanceId?: string;
|
|
132
183
|
/** 对端 Window Runtime 类型。 */
|
|
@@ -150,9 +201,32 @@ interface PeerController {
|
|
|
150
201
|
};
|
|
151
202
|
/** 断开此 peer,不影响其它页面。 */
|
|
152
203
|
disconnect(reason?: string): void;
|
|
204
|
+
/** 同步停止新调用与暴露;后续由 drain/close 完成异步收尾。 */
|
|
205
|
+
beginClose(reason?: string): void;
|
|
206
|
+
/** 等待该 peer endpoint 的 bounded drain。 */
|
|
207
|
+
drain(timeoutMs?: number): Promise<RuntimeDrainResult>;
|
|
153
208
|
/** peer 诊断。 */
|
|
154
209
|
inspect(): Readonly<Record<string, unknown>>;
|
|
155
210
|
}
|
|
211
|
+
/** 可信 Host 可观察的 peer 生命周期事件;不包含 owner/lease 等领域字段。 */
|
|
212
|
+
interface PeerLifecycleEvent {
|
|
213
|
+
/** active 建立、handoff 通知或关闭阶段。 */
|
|
214
|
+
readonly event: "active" | "handoff" | "closing" | "closed";
|
|
215
|
+
/** peer 物理连接的 opaque 标识。 */
|
|
216
|
+
readonly peerId: string;
|
|
217
|
+
/** 当前物理 endpoint 的框架 binding。 */
|
|
218
|
+
readonly binding: RuntimeEndpointBinding;
|
|
219
|
+
/** endpoint 的框架生命周期。 */
|
|
220
|
+
readonly state: RuntimeEndpointState;
|
|
221
|
+
/** closed 事件的真实 bounded drain 结果。 */
|
|
222
|
+
readonly drain?: RuntimeDrainResult;
|
|
223
|
+
/** 可信 Host 提供的 handoff 修订;WebLoom 不解释或选择 owner。 */
|
|
224
|
+
readonly handoffRevision?: number;
|
|
225
|
+
}
|
|
226
|
+
/** 可信 Host 查询到的 active peer 只读投影。 */
|
|
227
|
+
type ActivePeerSnapshot = Omit<PeerLifecycleEvent, "event" | "drain" | "handoffRevision"> & {
|
|
228
|
+
readonly event: "active";
|
|
229
|
+
};
|
|
156
230
|
interface StartSharedWorkerAppOptions extends Omit<CreatePluginHostOptions, "runtime" | "runtimeUnitImplementationRegistry" | "runtimeId" | "runtimeInstanceId"> {
|
|
157
231
|
/** Worker Runtime 逻辑标识。 */
|
|
158
232
|
readonly id: string;
|
|
@@ -166,6 +240,12 @@ interface StartSharedWorkerAppOptions extends Omit<CreatePluginHostOptions, "run
|
|
|
166
240
|
readonly peerExposureAllowlist?: readonly RemoteCapability[];
|
|
167
241
|
/** 可信 transport 配额;只能使用默认值或收紧。 */
|
|
168
242
|
readonly limits?: RuntimeLimitsInput;
|
|
243
|
+
/**
|
|
244
|
+
* 浏览器唯一运行锁。锁名只由 runtime id 生成,不含构建号、版本号或
|
|
245
|
+
* Worker URL;生产入口缺少 navigator.locks 时安全失败。manager 仅供
|
|
246
|
+
* testing 入口注入,不能作为生产回退。
|
|
247
|
+
*/
|
|
248
|
+
readonly runtimeLock?: RuntimeLockOptions;
|
|
169
249
|
}
|
|
170
250
|
interface StartSharedWorkerAppForTestingOptions extends StartSharedWorkerAppOptions {
|
|
171
251
|
/** testing 入口注入的 SharedWorkerGlobalScope 替身。 */
|
|
@@ -182,6 +262,12 @@ interface SharedWorkerApp {
|
|
|
182
262
|
state(): RuntimeStatusSnapshot;
|
|
183
263
|
subscribe(listener: RuntimeStatusListener): () => void;
|
|
184
264
|
inspect(): HostInspection;
|
|
265
|
+
/** 只读查询当前仍处于 active 的物理 peer。 */
|
|
266
|
+
activePeers(): readonly ActivePeerSnapshot[];
|
|
267
|
+
/** 订阅 Host 可见的 peer active/closing/closed/handoff 事件。 */
|
|
268
|
+
subscribePeerLifecycle(listener: (event: PeerLifecycleEvent) => void): () => void;
|
|
269
|
+
/** 可信领域在完成自己的 owner/session 交接后报告 handoff;框架不选择 owner。 */
|
|
270
|
+
notifyPeerHandoff(peerId: string, handoffRevision?: number): boolean;
|
|
185
271
|
dispose(reason?: string): Promise<LifecycleDisposeResult>;
|
|
186
272
|
}
|
|
187
273
|
/** 生产入口:只从真实 SharedWorkerGlobalScope 获取连接事件。 */
|
|
@@ -189,4 +275,4 @@ declare function startSharedWorkerApp(options: StartSharedWorkerAppOptions): Sha
|
|
|
189
275
|
/** testing/advanced harness 入口;生产包的 startSharedWorkerApp 不接受 scope 注入。 */
|
|
190
276
|
declare function startSharedWorkerAppForTesting(options: StartSharedWorkerAppForTestingOptions): SharedWorkerApp;
|
|
191
277
|
|
|
192
|
-
export { type CreateResourceScopeOptions as C, type PeerController as P, type ReceivePortLedger as R, type SharedWorkerApp as S, type RuntimeLimitsInput as a, type RuntimeBudget as b, type RuntimePluginDefinition as c, type PeerExposureOptions as d, type ResourceScopeOptions as e, type StartSharedWorkerAppForTestingOptions as
|
|
278
|
+
export { type CreateResourceScopeOptions as C, type PeerController as P, type ReceivePortLedger as R, type SharedWorkerApp as S, WEBLOOM_RUNTIME_LOCK_PREFIX as W, type RuntimeLimitsInput as a, type RuntimeBudget as b, type RuntimePluginDefinition as c, type PeerExposureOptions as d, type ResourceScopeOptions as e, RuntimeLockError as f, type RuntimeLockFailureCode as g, type RuntimeLockHandle as h, type RuntimeLockManagerLike as i, type RuntimeLockMessages as j, type RuntimeLockOptions as k, type StartSharedWorkerAppForTestingOptions as l, type StartSharedWorkerAppOptions as m, bridgeForRuntimeHandle as n, createLifecycleScope as o, createResourceScope as p, type ConnectSharedWorkerOptions as q, type SharedWorkerLike as r, connectSharedWorker as s, startSharedWorkerApp as t, type SharedWorkerFactory as u, type SharedWorkerScopeLike as v, connectSharedWorkerForTesting as w, createInMemoryRuntimeLockManager as x, startSharedWorkerAppForTesting as y };
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export { C as CreateCapabilityBridgeOptions,
|
|
5
|
-
export { C as CreateResourceScopeOptions, e as ResourceScopeOptions,
|
|
6
|
-
export { c as createMessageBus } from './messageBus-
|
|
1
|
+
import { u as CreatePluginHostOptions, z as PluginHost } from './runtimeTypes-50LVQs0h.js';
|
|
2
|
+
export { o as CapabilityRegistration, p as CapabilityRegistry, q as ContextExtensionInput, r as ContributionAdapter, s as ContributionAdapterInput, t as ContributionHandle, H as HostCapabilityRegistration, v as HostInspection, w as PermissionPolicyInput, x as PermissionPolicyResult, y as PluginConfigStore, A as RuntimeUnitAttributesInput, B as RuntimeUnitAvailabilityInput, D as RuntimeUnitParentScopeInput, E as RuntimeUnitSnapshot, F as StartupCapabilityError, G as StartupPluginError, I as createCapabilityRegistry, J as createInMemoryPluginConfigStore, K as createPluginHost, bS as createResourceStore, M as invokeCapabilityHandler } from './runtimeTypes-50LVQs0h.js';
|
|
3
|
+
import { G as RuntimeWireMessage, a as RuntimeTransport } from './messagePortServiceTransport-B9-24RK6.js';
|
|
4
|
+
export { C as CreateCapabilityBridgeOptions, c as CreatePluginIntentControllerOptions, M as MessagePortLike, w as RuntimeReceiveMetadata, F as RuntimeUnitImplementation, H as createCapabilityBridge, I as createMessagePortRuntimeTransport, J as createPluginIntentController, K as createResourceRegistry, N as createRuntimeUnitImplementationRegistry, Q as validateTransferables } from './messagePortServiceTransport-B9-24RK6.js';
|
|
5
|
+
export { C as CreateResourceScopeOptions, e as ResourceScopeOptions, i as RuntimeLockManagerLike, j as RuntimeLockMessages, k as RuntimeLockOptions, u as SharedWorkerFactory, v as SharedWorkerScopeLike, l as StartSharedWorkerAppForTestingOptions, w as connectSharedWorkerForTesting, x as createInMemoryRuntimeLockManager, o as createLifecycleScope, p as createResourceScope, y as startSharedWorkerAppForTesting } from './sharedWorkerHost-DikS18hA.js';
|
|
6
|
+
export { c as createMessageBus } from './messageBus-DigYfj74.js';
|
|
7
7
|
|
|
8
8
|
/** 可观察的 transport 发送记录。 */
|
|
9
9
|
interface FakeTransportMessage {
|
package/dist/testing.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { startSharedWorkerAppForTesting } from './chunk-
|
|
1
|
+
export { startSharedWorkerAppForTesting } from './chunk-UZAO6ORB.js';
|
|
2
2
|
export { createPluginIntentController } from './chunk-4DSINPZD.js';
|
|
3
|
-
export { connectSharedWorkerForTesting, createCapabilityBridge, createMessagePortRuntimeTransport, validateTransferables } from './chunk-
|
|
4
|
-
import { createPluginHost } from './chunk-
|
|
5
|
-
export { StartupCapabilityError, StartupPluginError, createCapabilityRegistry, createInMemoryPluginConfigStore, createLifecycleScope, createMessageBus, createPluginHost, createResourceRegistry, createResourceScope, createResourceStore, createRuntimeUnitImplementationRegistry, invokeCapabilityHandler } from './chunk-
|
|
3
|
+
export { connectSharedWorkerForTesting, createCapabilityBridge, createInMemoryRuntimeLockManager, createMessagePortRuntimeTransport, validateTransferables } from './chunk-YIIDRFHK.js';
|
|
4
|
+
import { createPluginHost } from './chunk-ZP5QYTXX.js';
|
|
5
|
+
export { StartupCapabilityError, StartupPluginError, createCapabilityRegistry, createInMemoryPluginConfigStore, createLifecycleScope, createMessageBus, createPluginHost, createResourceRegistry, createResourceScope, createResourceStore, createRuntimeUnitImplementationRegistry, invokeCapabilityHandler } from './chunk-ZP5QYTXX.js';
|
|
6
6
|
|
|
7
7
|
// src/testing/fakes.ts
|
|
8
8
|
function createFakeRuntimeTransport() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as RuntimePluginDefinition } from './sharedWorkerHost-
|
|
1
|
+
import { u as CreatePluginHostOptions, z as PluginHost, W as WindowApp } from './runtimeTypes-50LVQs0h.js';
|
|
2
|
+
import { c as RuntimePluginDefinition } from './sharedWorkerHost-DikS18hA.js';
|
|
3
3
|
|
|
4
4
|
interface CreateWindowAppOptions extends Omit<CreatePluginHostOptions, "runtime" | "runtimeUnitImplementationRegistry" | "runtimeInstanceId" | "runtimeId" | "capabilityBridge"> {
|
|
5
5
|
/** Window Runtime 逻辑标识。 */
|