webloom-framework 0.4.2 → 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/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { ak as Capability, al as CapabilityDependency, am as PluginContribution, an as PluginConfig, ao as PluginContextExtension, R as RuntimeKind, e as PluginPermission, ap as PluginSetup, aq as PluginDefinition } from './runtimeTypes-CleHMFaq.js';
2
- export { ar as AppLike, as as CapabilityBridge, at as CapabilityClient, C as CapabilityDescriptor, au as CapabilityKind, l as CapabilityPeer, h as CreateUpgradeGateOptions, av as DefineLocalCapabilityOptions, aw as DefineRpcCapabilityOptions, ax as DefineStreamCapabilityOptions, ay as DispatchOptions, az as EventHandler, aA as FrameworkErrorCode, aB as FrameworkErrorContext, aC as FrameworkErrorPhase, aD as HandlerCallContext, aE as HandlerOptions, aF as HandlerOrigin, aG as HostListener, aH as ItemOf, aI as LIFECYCLE_ERROR_TEXT, aJ as LifecycleCleanup, aK as LifecycleCleanupIssue, aL as LifecycleCleanupPhase, aM as LifecycleDisposeOptions, aN as LifecycleDisposeResult, aO as LifecycleResourceHandle, aP as LifecycleResourceSnapshot, f as LifecycleScope, L as LifecycleScopeIdentity, aQ as LifecycleScopeKind, aR as LifecycleScopeRevokedError, aS as LifecycleScopeState, aT as LocalCapability, aU as LocalServiceOf, aV as Message, aW as MessageBus, aX as MessageBusSnapshot, aY as MessageHandler, aZ as MessageMode, a_ as OwnedResourceDefinition, a$ as PeerCapabilityDependency, b0 as PeerScopeView, b1 as PermissionDeniedError, g as PermissionLease, b2 as PermissionLeaseBinding, b3 as PermissionLeaseBindingExpectation, b4 as PermissionLeaseRevokedError, b5 as PluginAttributes, b6 as PluginContext, a as PluginGraph, b7 as PluginIntentCommand, b8 as PluginIntentCommandResult, b9 as PluginIntentController, ba as PluginIntentCoordinator, bb as PluginIntentSnapshot, bc as PluginIntentSubmissionResult, bd as PluginLifecycleState, P as PluginManifest, be as PluginManifestInput, c as PluginReverseDep, bf as PluginStartupMode, bg as PluginState, bh as PluginStateKind, bi as PluginTeardown, bj as PluginUnitGraph, bk as PluginUnitState, bl as PublishOptions, bm as RESOURCE_OWNER, bn as RESOURCE_REGISTRY, bo as RUNTIME_MESSAGE_BUS, bp as RemoteCapability, bq as RequestOf, br as RequestOptions, bs as ResourceContext, bt as ResourceDefinition, bu as ResourceKey, bv as ResourceRegistry, bw as ResourceSnapshot, bx as ResourceStatus, by as ResponseOf, bz as RpcCallOptions, bA as RpcCapability, bB as RpcCapabilityBase, bC as RpcClient, bD as RpcHandler, bE as RpcTransferDescriptor, bF as RuntimeCapabilityDependency, m as RuntimeDrainResult, k as RuntimeEndpointBinding, bG as RuntimeEndpointState, o as RuntimeHandle, bH as RuntimeInitializationError, bI as RuntimeLimits, bJ as RuntimeServiceSnapshot, bK as RuntimeSnapshot, bL as RuntimeStatusListener, bM as RuntimeStatusSnapshot, bN as RuntimeUnavailableError, b as RuntimeUnitDependency, bO as RuntimeUnitDependencyInput, d as RuntimeUnitDescriptor, bP as RuntimeUnitDescriptorInput, bQ as RuntimeUnitImplementationRegistry, bR as SCOPED_TASK_SCHEDULER_CAPABILITY, bS as ScopedTaskDefinition, S as ScopedTaskScheduler, bT as ScopedTaskSnapshot, j as ServiceReference, bU as SnapshotApplyResult, bV as StartupCapabilityErrorDetails, bW as StartupPluginErrorDetails, bX as StreamCapability, bY as StreamCapabilityBase, bZ as StreamClient, b_ as StreamHandler, b$ as StreamSubscribeOptions, c0 as StreamSubscription, c1 as StreamTransferDescriptor, c2 as TransferExtractor, c3 as UpgradeDrainResult, U as UpgradeGate, c4 as UpgradeGateRejectedError, c5 as UpgradeGateState, c6 as UpgradeHandshake, c7 as UpgradeHandshakeResult, c8 as UpgradeIoLease, c9 as UpgradeMode, ca as UpgradeSession, cb as ValueParser, cc as WebLoomError, W as WindowApp, cd as assertCapability, ce as capabilityDescriptor, cf as capabilityKey, cg as defineCapability, ch as isCapability, ci as isCapabilityDescriptor, cj as lifecycleErrorText } from './runtimeTypes-CleHMFaq.js';
3
- export { A as ActivePeerSnapshot, l as ConnectSharedWorkerOptions, P as PeerController, d as PeerExposureOptions, e as PeerLifecycleEvent, c as RuntimePluginDefinition, S as SharedWorkerApp, m as SharedWorkerLike, h as StartSharedWorkerAppOptions, n as connectSharedWorker, j as createLifecycleScope, k as createResourceScope, s as startSharedWorkerApp } from './sharedWorkerHost-BNMUW-8v.js';
4
- export { C as CreateWindowAppOptions, a as createWindowApp } from './windowRuntime-BGl_jfbK.js';
5
- export { c as createMessageBus } from './messageBus-BDtkjs6y.js';
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-RRNUE457.js';
2
- export { connectSharedWorker } from './chunk-XVD7ALPV.js';
3
- import { capabilityDescriptor } from './chunk-CKML74MG.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-CKML74MG.js';
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";
@@ -1,4 +1,4 @@
1
- import { aW as MessageBus } from './runtimeTypes-CleHMFaq.js';
1
+ import { as as MessageBus } from './runtimeTypes-50LVQs0h.js';
2
2
 
3
3
  declare function createMessageBus(): MessageBus;
4
4
 
@@ -0,0 +1,355 @@
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
+
4
+ interface RuntimeUnitImplementation {
5
+ /** 产品标识。 */
6
+ pluginId: string;
7
+ /** 稳定运行单元标识。 */
8
+ unitId: string;
9
+ /** 当前环境的可执行入口。 */
10
+ setup: PluginSetup;
11
+ /** 当前 realm 的 typed capability 定义。 */
12
+ capabilities?: readonly Capability[];
13
+ }
14
+ /** 创建一个拒绝重复注册、按产品和单元查找实现的运行时注册表。 */
15
+ declare function createRuntimeUnitImplementationRegistry(implementations?: readonly RuntimeUnitImplementation[]): RuntimeUnitImplementationRegistry & {
16
+ register(implementation: RuntimeUnitImplementation): void;
17
+ unregister(pluginId: string, unitId: string): void;
18
+ };
19
+
20
+ interface CreatePluginIntentControllerOptions {
21
+ /** 当前控制面启动身份;Worker 重启时应传入新值。 */
22
+ authorityInstanceId?: string;
23
+ /** Worker 恢复后读取的平台意图。 */
24
+ initial?: Partial<PluginIntentSnapshot>;
25
+ /** 将候选快照原子写入平台存储;缺省表示内存控制面(测试用)。 */
26
+ persist?: (snapshot: PluginIntentSnapshot) => Promise<void>;
27
+ /** 有界去重记录数量,避免 commandId 永久增长。 */
28
+ maxCommandRecords?: number;
29
+ }
30
+ /** 创建单一控制面上的插件意图控制器。 */
31
+ declare function createPluginIntentController(options?: CreatePluginIntentControllerOptions): PluginIntentController;
32
+
33
+ /**
34
+ * 资源注册表实现
35
+ *
36
+ * 设计缘由:管理资源定义的注册和查询,支持 owner-aware 生命周期。
37
+ * 重复 id 抛错,disable 时可回收。
38
+ */
39
+
40
+ /** 资源注册表实现 */
41
+ declare function createResourceRegistry(): ResourceRegistry;
42
+ /** Internal runtime hook; deliberately absent from ResourceRegistry's public type. */
43
+ declare function registerOwnedResource(registry: ResourceRegistry, ownerId: string, definition: ResourceDefinition<any, any>): void;
44
+
45
+ declare const RUNTIME_PROTOCOL_VERSION: "webloom.runtime.v1";
46
+ declare const RUNTIME_SNAPSHOT_TYPE: "webloom.runtime.v1.snapshot";
47
+ declare const RUNTIME_ERROR_TYPE: "webloom.runtime.v1.runtime-error";
48
+ declare const RUNTIME_CALL_TYPE: "webloom.runtime.v1.call";
49
+ declare const RUNTIME_RESULT_TYPE: "webloom.runtime.v1.result";
50
+ declare const RUNTIME_ERROR_MESSAGE_TYPE: "webloom.runtime.v1.error";
51
+ declare const RUNTIME_CANCEL_TYPE: "webloom.runtime.v1.cancel";
52
+ declare const RUNTIME_NEXT_TYPE: "webloom.runtime.v1.next";
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;
58
+ interface RuntimeSnapshotUnit {
59
+ /** 插件标识。 */
60
+ readonly pluginId: string;
61
+ /** 单元标识。 */
62
+ readonly unitId: string;
63
+ /** Runtime。 */
64
+ readonly runtime: RuntimeKind;
65
+ /** 实例标识。 */
66
+ readonly instanceId?: string;
67
+ /** 状态。 */
68
+ readonly state: PluginStateKind;
69
+ }
70
+ type RuntimeSnapshotMessage = RuntimeSnapshot & {
71
+ readonly type: typeof RUNTIME_SNAPSHOT_TYPE;
72
+ readonly binding?: RuntimeSessionBinding;
73
+ };
74
+ interface RuntimeErrorMessage {
75
+ /** 消息类型。 */
76
+ readonly type: typeof RUNTIME_ERROR_TYPE;
77
+ /** 协议版本。 */
78
+ readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
79
+ /** 发送此错误的物理 endpoint 绑定。 */
80
+ readonly binding?: RuntimeSessionBinding;
81
+ /** 结构化错误码。 */
82
+ readonly code: string;
83
+ /** 脱敏消息。 */
84
+ readonly message: string;
85
+ /** 失败阶段。 */
86
+ readonly phase: "validate" | "wait" | "dispatch" | "execute" | "receive" | "dispose";
87
+ /** 可选插件标识。 */
88
+ readonly pluginId?: string;
89
+ /** 可选单元标识。 */
90
+ readonly unitId?: string;
91
+ }
92
+ interface RuntimeCallMessage {
93
+ /** 消息类型。 */
94
+ readonly type: typeof RUNTIME_CALL_TYPE;
95
+ /** 协议版本。 */
96
+ readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
97
+ /** 发起调用的物理 endpoint 绑定。 */
98
+ readonly binding?: RuntimeSessionBinding;
99
+ /** 方向内唯一 call id。 */
100
+ readonly callId: string;
101
+ /** capability 标识。 */
102
+ readonly capabilityId: string;
103
+ /** 契约版本。 */
104
+ readonly contractVersion: string;
105
+ /** exposure 身份。 */
106
+ readonly serviceInstanceId: string;
107
+ /** 调用模式。 */
108
+ readonly mode: "unary" | "stream";
109
+ /** 本次派发的剩余预算。 */
110
+ readonly timeoutMs: number;
111
+ /** 已 parser 验证的请求。 */
112
+ readonly request: unknown;
113
+ /** 产品操作标识。 */
114
+ readonly operationId?: string;
115
+ /** 领域授权标识。 */
116
+ readonly grantId?: string;
117
+ /** stream 初始 credit。 */
118
+ readonly initialCredit?: number;
119
+ }
120
+ interface RuntimeUnaryResultMessage {
121
+ /** 消息类型。 */
122
+ readonly type: typeof RUNTIME_RESULT_TYPE;
123
+ /** 协议版本。 */
124
+ readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
125
+ /** 发送结果的物理 endpoint 绑定。 */
126
+ readonly binding?: RuntimeSessionBinding;
127
+ /** call id。 */
128
+ readonly callId: string;
129
+ /** exposure 身份。 */
130
+ readonly serviceInstanceId: string;
131
+ /** unary 结果。 */
132
+ readonly result: unknown;
133
+ }
134
+ interface RuntimeStreamReadyMessage {
135
+ /** 消息类型。 */
136
+ readonly type: typeof RUNTIME_RESULT_TYPE;
137
+ /** 协议版本。 */
138
+ readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
139
+ /** 发送结果的物理 endpoint 绑定。 */
140
+ readonly binding?: RuntimeSessionBinding;
141
+ /** call id。 */
142
+ readonly callId: string;
143
+ /** exposure 身份。 */
144
+ readonly serviceInstanceId: string;
145
+ /** stream 建立确认。 */
146
+ readonly streamReady: true;
147
+ }
148
+ interface RuntimeStreamDoneMessage {
149
+ /** 消息类型。 */
150
+ readonly type: typeof RUNTIME_RESULT_TYPE;
151
+ /** 协议版本。 */
152
+ readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
153
+ /** 发送结果的物理 endpoint 绑定。 */
154
+ readonly binding?: RuntimeSessionBinding;
155
+ /** call id。 */
156
+ readonly callId: string;
157
+ /** exposure 身份。 */
158
+ readonly serviceInstanceId: string;
159
+ /** stream 正常结束。 */
160
+ readonly done: true;
161
+ }
162
+ type RuntimeResultMessage = RuntimeUnaryResultMessage | RuntimeStreamReadyMessage | RuntimeStreamDoneMessage;
163
+ interface RuntimeErrorResponseMessage {
164
+ /** 消息类型。 */
165
+ readonly type: typeof RUNTIME_ERROR_MESSAGE_TYPE;
166
+ /** 协议版本。 */
167
+ readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
168
+ /** 发送错误响应的物理 endpoint 绑定。 */
169
+ readonly binding?: RuntimeSessionBinding;
170
+ /** call id。 */
171
+ readonly callId: string;
172
+ /** exposure 身份。 */
173
+ readonly serviceInstanceId: string;
174
+ /** 结构化错误。 */
175
+ readonly error: {
176
+ readonly code: string;
177
+ readonly message: string;
178
+ readonly phase: RuntimeErrorMessage["phase"];
179
+ readonly details?: Readonly<Record<string, unknown>>;
180
+ };
181
+ }
182
+ interface RuntimeCancelMessage {
183
+ /** 消息类型。 */
184
+ readonly type: typeof RUNTIME_CANCEL_TYPE;
185
+ /** 协议版本。 */
186
+ readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
187
+ /** 发送取消的物理 endpoint 绑定。 */
188
+ readonly binding?: RuntimeSessionBinding;
189
+ /** call id。 */
190
+ readonly callId: string;
191
+ /** exposure 身份。 */
192
+ readonly serviceInstanceId: string;
193
+ }
194
+ interface RuntimeNextMessage {
195
+ /** 消息类型。 */
196
+ readonly type: typeof RUNTIME_NEXT_TYPE;
197
+ /** 协议版本。 */
198
+ readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
199
+ /** 发送 stream item 的物理 endpoint 绑定。 */
200
+ readonly binding?: RuntimeSessionBinding;
201
+ /** call id。 */
202
+ readonly callId: string;
203
+ /** exposure 身份。 */
204
+ readonly serviceInstanceId: string;
205
+ /** 连续序号。 */
206
+ readonly sequence: number;
207
+ /** parser 验证的 item。 */
208
+ readonly item: unknown;
209
+ }
210
+ interface RuntimeCreditMessage {
211
+ /** 消息类型。 */
212
+ readonly type: typeof RUNTIME_CREDIT_TYPE;
213
+ /** 协议版本。 */
214
+ readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
215
+ /** 发送 credit 的物理 endpoint 绑定。 */
216
+ readonly binding?: RuntimeSessionBinding;
217
+ /** call id。 */
218
+ readonly callId: string;
219
+ /** exposure 身份。 */
220
+ readonly serviceInstanceId: string;
221
+ /** 新增 credit。 */
222
+ readonly count: number;
223
+ }
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;
253
+ interface RuntimeMessageCodec {
254
+ /** 严格验证并冻结 v4 message。 */
255
+ encode(message: RuntimeWireMessage): RuntimeWireMessage;
256
+ /** 严格解析 v4 message;旧协议直接拒绝。 */
257
+ decode(value: unknown): RuntimeWireMessage;
258
+ }
259
+ declare function createRuntimeMessageCodec(): RuntimeMessageCodec;
260
+ declare function isRuntimeSnapshot(value: RuntimeWireMessage): value is RuntimeSnapshotMessage;
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
+
296
+ interface RuntimeReceiveMetadata {
297
+ /** 本次 MessageEvent 实际携带的业务 MessagePort;仅 transport 本地使用。 */
298
+ readonly ports?: readonly MessagePort[];
299
+ /** 由物理 endpoint transport 创建的一次性接收资源账本。 */
300
+ readonly ledger?: ReceivePortLedger;
301
+ /** 物理 endpoint 已完成一次 codec decode。 */
302
+ readonly decoded?: boolean;
303
+ }
304
+ interface RuntimeTransport {
305
+ /** 发送已验证 v4 message;transfer 由契约 extractor 提供。 */
306
+ send(message: RuntimeWireMessage, transfer?: readonly Transferable[]): void;
307
+ /** 订阅接收 message 及本次事件的本地 transfer 元数据。 */
308
+ subscribe(listener: (message: RuntimeWireMessage, metadata?: RuntimeReceiveMetadata) => void): () => void;
309
+ /** 关闭本端传输。 */
310
+ close?(): void;
311
+ /** 物理 endpoint 对 decode/接收账本错误的统一通知。 */
312
+ subscribeError?(listener: (error: unknown, metadata?: RuntimeReceiveMetadata) => void): () => void;
313
+ }
314
+ interface CreateCapabilityBridgeOptions {
315
+ /** 底层双向 transport。 */
316
+ readonly transport: RuntimeTransport;
317
+ /** 预期的对端 Runtime 类型。 */
318
+ readonly remoteRuntimeKind?: RuntimeKind;
319
+ /** 预期的对端逻辑 Runtime id。 */
320
+ readonly remoteRuntimeId?: string;
321
+ /** 默认调用预算。 */
322
+ readonly defaultCallTimeoutMs?: number;
323
+ /** 可信 Runtime/advanced 装配提供的预算;只能收紧 v4 默认值。 */
324
+ readonly limits?: RuntimeLimitsInput;
325
+ /** 可选的 Runtime 方向共享计数器。 */
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;
333
+ }
334
+ /** 创建按 peer 绑定、可撤销且支持 typed stream 的 bridge。 */
335
+ declare function createCapabilityBridge(options: CreateCapabilityBridgeOptions): CapabilityBridge & {
336
+ readonly pendingCallCount: number;
337
+ readonly activeStreamCount: number;
338
+ readonly retainedPayloadBytes: number;
339
+ };
340
+ /** 内部 typed transfer 校验 helper;不接受 call 级临时 transfer 数组。 */
341
+ declare function validateTransferables(value: unknown, transfer: readonly Transferable[] | undefined, limits?: RuntimeLimitsInput): readonly Transferable[];
342
+
343
+ interface MessagePortLike {
344
+ addEventListener(type: "message" | "messageerror", listener: (event: MessageEvent) => void): void;
345
+ removeEventListener(type: "message" | "messageerror", listener: (event: MessageEvent) => void): void;
346
+ postMessage(message: unknown, transfer?: readonly Transferable[]): void;
347
+ start?(): void;
348
+ close?(): void;
349
+ }
350
+ /** 将一个真实 MessagePort 绑定为双向 v4 transport。 */
351
+ declare function createMessagePortRuntimeTransport(port: MessagePortLike, options?: {
352
+ readonly limits?: RuntimeLimitsInput;
353
+ }): RuntimeTransport;
354
+
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, o as RuntimeHandle, ak as Capability, at as CapabilityClient, ar as AppLike, bg as PluginState, a as PluginGraph, c as PluginReverseDep, bc as PluginIntentSubmissionResult, P as PluginManifest, C as CapabilityDescriptor, n as ResourceStoreApi, bw as ResourceSnapshot } from './runtimeTypes-CleHMFaq.js';
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
@@ -1,4 +1,4 @@
1
- import { hostForWindowApp } from './chunk-CKML74MG.js';
1
+ import { hostForWindowApp } from './chunk-ZP5QYTXX.js';
2
2
  import { createContext, useContext, useCallback, useSyncExternalStore, useMemo, useRef } from 'react';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4