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/README.md +11 -1
- package/dist/advanced.d.ts +8 -8
- package/dist/advanced.js +4 -4
- package/dist/advanced.js.map +1 -1
- package/dist/{chunk-RRNUE457.js → chunk-UZAO6ORB.js} +110 -26
- package/dist/chunk-UZAO6ORB.js.map +1 -0
- package/dist/{chunk-XVD7ALPV.js → chunk-YIIDRFHK.js} +106 -15
- package/dist/chunk-YIIDRFHK.js.map +1 -0
- package/dist/{chunk-CKML74MG.js → chunk-ZP5QYTXX.js} +4 -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-BDtkjs6y.d.ts → messageBus-DigYfj74.d.ts} +1 -1
- package/dist/messagePortServiceTransport-B9-24RK6.d.ts +355 -0
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/{runtimeTypes-CleHMFaq.d.ts → runtimeTypes-50LVQs0h.d.ts} +7 -220
- package/dist/{sharedWorkerHost-BNMUW-8v.d.ts → sharedWorkerHost-DikS18hA.d.ts} +55 -2
- package/dist/testing.d.ts +6 -6
- package/dist/testing.js +4 -4
- package/dist/{windowRuntime-BGl_jfbK.d.ts → windowRuntime-e1Tn6SnN.d.ts} +2 -2
- package/docs/api.md +28 -1
- package/docs/proposals/webloom-v4/requirements.md +1 -1
- package/package.json +1 -1
- package/dist/chunk-CKML74MG.js.map +0 -1
- package/dist/chunk-RRNUE457.js.map +0 -1
- package/dist/chunk-XVD7ALPV.js.map +0 -1
- package/dist/messagePortServiceTransport-DyNmdgoa.d.ts +0 -150
|
@@ -597,6 +597,8 @@ interface RuntimeServiceSnapshot {
|
|
|
597
597
|
interface RuntimeSnapshot {
|
|
598
598
|
/** 固定协议版本。 */
|
|
599
599
|
protocolVersion: string;
|
|
600
|
+
/** 当前物理 endpoint 的框架绑定;旧兼容快照可以省略,收到后由 transport 补齐。 */
|
|
601
|
+
readonly binding?: RuntimeEndpointBinding;
|
|
600
602
|
/** Runtime 逻辑标识。 */
|
|
601
603
|
runtimeId: string;
|
|
602
604
|
/** 真实 Runtime 类型。 */
|
|
@@ -896,223 +898,6 @@ declare const LIFECYCLE_ERROR_TEXT: Readonly<Record<string, string>>;
|
|
|
896
898
|
/** 将生命周期错误码映射为中文提示。 */
|
|
897
899
|
declare function lifecycleErrorText(code: string): string;
|
|
898
900
|
|
|
899
|
-
declare const RUNTIME_PROTOCOL_VERSION: "webloom.runtime.v1";
|
|
900
|
-
declare const RUNTIME_SNAPSHOT_TYPE: "webloom.runtime.v1.snapshot";
|
|
901
|
-
declare const RUNTIME_ERROR_TYPE: "webloom.runtime.v1.runtime-error";
|
|
902
|
-
declare const RUNTIME_CALL_TYPE: "webloom.runtime.v1.call";
|
|
903
|
-
declare const RUNTIME_RESULT_TYPE: "webloom.runtime.v1.result";
|
|
904
|
-
declare const RUNTIME_ERROR_MESSAGE_TYPE: "webloom.runtime.v1.error";
|
|
905
|
-
declare const RUNTIME_CANCEL_TYPE: "webloom.runtime.v1.cancel";
|
|
906
|
-
declare const RUNTIME_NEXT_TYPE: "webloom.runtime.v1.next";
|
|
907
|
-
declare const RUNTIME_CREDIT_TYPE: "webloom.runtime.v1.credit";
|
|
908
|
-
declare const RUNTIME_CLOSE_TYPE: "webloom.runtime.v1.close";
|
|
909
|
-
declare const RUNTIME_CLOSE_ACK_TYPE: "webloom.runtime.v1.close-ack";
|
|
910
|
-
/** 每条 Runtime wire 消息所属的框架 endpoint 身份。 */
|
|
911
|
-
type RuntimeSessionBinding = RuntimeEndpointBinding;
|
|
912
|
-
interface RuntimeSnapshotUnit {
|
|
913
|
-
/** 插件标识。 */
|
|
914
|
-
readonly pluginId: string;
|
|
915
|
-
/** 单元标识。 */
|
|
916
|
-
readonly unitId: string;
|
|
917
|
-
/** Runtime。 */
|
|
918
|
-
readonly runtime: RuntimeKind;
|
|
919
|
-
/** 实例标识。 */
|
|
920
|
-
readonly instanceId?: string;
|
|
921
|
-
/** 状态。 */
|
|
922
|
-
readonly state: PluginStateKind;
|
|
923
|
-
}
|
|
924
|
-
type RuntimeSnapshotMessage = RuntimeSnapshot & {
|
|
925
|
-
readonly type: typeof RUNTIME_SNAPSHOT_TYPE;
|
|
926
|
-
readonly binding: RuntimeSessionBinding;
|
|
927
|
-
};
|
|
928
|
-
interface RuntimeErrorMessage {
|
|
929
|
-
/** 消息类型。 */
|
|
930
|
-
readonly type: typeof RUNTIME_ERROR_TYPE;
|
|
931
|
-
/** 协议版本。 */
|
|
932
|
-
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
933
|
-
/** 发送此错误的物理 endpoint 绑定。 */
|
|
934
|
-
readonly binding: RuntimeSessionBinding;
|
|
935
|
-
/** 结构化错误码。 */
|
|
936
|
-
readonly code: string;
|
|
937
|
-
/** 脱敏消息。 */
|
|
938
|
-
readonly message: string;
|
|
939
|
-
/** 失败阶段。 */
|
|
940
|
-
readonly phase: "validate" | "wait" | "dispatch" | "execute" | "receive" | "dispose";
|
|
941
|
-
/** 可选插件标识。 */
|
|
942
|
-
readonly pluginId?: string;
|
|
943
|
-
/** 可选单元标识。 */
|
|
944
|
-
readonly unitId?: string;
|
|
945
|
-
}
|
|
946
|
-
interface RuntimeCallMessage {
|
|
947
|
-
/** 消息类型。 */
|
|
948
|
-
readonly type: typeof RUNTIME_CALL_TYPE;
|
|
949
|
-
/** 协议版本。 */
|
|
950
|
-
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
951
|
-
/** 发起调用的物理 endpoint 绑定。 */
|
|
952
|
-
readonly binding: RuntimeSessionBinding;
|
|
953
|
-
/** 方向内唯一 call id。 */
|
|
954
|
-
readonly callId: string;
|
|
955
|
-
/** capability 标识。 */
|
|
956
|
-
readonly capabilityId: string;
|
|
957
|
-
/** 契约版本。 */
|
|
958
|
-
readonly contractVersion: string;
|
|
959
|
-
/** exposure 身份。 */
|
|
960
|
-
readonly serviceInstanceId: string;
|
|
961
|
-
/** 调用模式。 */
|
|
962
|
-
readonly mode: "unary" | "stream";
|
|
963
|
-
/** 本次派发的剩余预算。 */
|
|
964
|
-
readonly timeoutMs: number;
|
|
965
|
-
/** 已 parser 验证的请求。 */
|
|
966
|
-
readonly request: unknown;
|
|
967
|
-
/** 产品操作标识。 */
|
|
968
|
-
readonly operationId?: string;
|
|
969
|
-
/** 领域授权标识。 */
|
|
970
|
-
readonly grantId?: string;
|
|
971
|
-
/** stream 初始 credit。 */
|
|
972
|
-
readonly initialCredit?: number;
|
|
973
|
-
}
|
|
974
|
-
interface RuntimeUnaryResultMessage {
|
|
975
|
-
/** 消息类型。 */
|
|
976
|
-
readonly type: typeof RUNTIME_RESULT_TYPE;
|
|
977
|
-
/** 协议版本。 */
|
|
978
|
-
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
979
|
-
/** 发送结果的物理 endpoint 绑定。 */
|
|
980
|
-
readonly binding: RuntimeSessionBinding;
|
|
981
|
-
/** call id。 */
|
|
982
|
-
readonly callId: string;
|
|
983
|
-
/** exposure 身份。 */
|
|
984
|
-
readonly serviceInstanceId: string;
|
|
985
|
-
/** unary 结果。 */
|
|
986
|
-
readonly result: unknown;
|
|
987
|
-
}
|
|
988
|
-
interface RuntimeStreamReadyMessage {
|
|
989
|
-
/** 消息类型。 */
|
|
990
|
-
readonly type: typeof RUNTIME_RESULT_TYPE;
|
|
991
|
-
/** 协议版本。 */
|
|
992
|
-
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
993
|
-
/** 发送结果的物理 endpoint 绑定。 */
|
|
994
|
-
readonly binding: RuntimeSessionBinding;
|
|
995
|
-
/** call id。 */
|
|
996
|
-
readonly callId: string;
|
|
997
|
-
/** exposure 身份。 */
|
|
998
|
-
readonly serviceInstanceId: string;
|
|
999
|
-
/** stream 建立确认。 */
|
|
1000
|
-
readonly streamReady: true;
|
|
1001
|
-
}
|
|
1002
|
-
interface RuntimeStreamDoneMessage {
|
|
1003
|
-
/** 消息类型。 */
|
|
1004
|
-
readonly type: typeof RUNTIME_RESULT_TYPE;
|
|
1005
|
-
/** 协议版本。 */
|
|
1006
|
-
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
1007
|
-
/** 发送结果的物理 endpoint 绑定。 */
|
|
1008
|
-
readonly binding: RuntimeSessionBinding;
|
|
1009
|
-
/** call id。 */
|
|
1010
|
-
readonly callId: string;
|
|
1011
|
-
/** exposure 身份。 */
|
|
1012
|
-
readonly serviceInstanceId: string;
|
|
1013
|
-
/** stream 正常结束。 */
|
|
1014
|
-
readonly done: true;
|
|
1015
|
-
}
|
|
1016
|
-
type RuntimeResultMessage = RuntimeUnaryResultMessage | RuntimeStreamReadyMessage | RuntimeStreamDoneMessage;
|
|
1017
|
-
interface RuntimeErrorResponseMessage {
|
|
1018
|
-
/** 消息类型。 */
|
|
1019
|
-
readonly type: typeof RUNTIME_ERROR_MESSAGE_TYPE;
|
|
1020
|
-
/** 协议版本。 */
|
|
1021
|
-
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
1022
|
-
/** 发送错误响应的物理 endpoint 绑定。 */
|
|
1023
|
-
readonly binding: RuntimeSessionBinding;
|
|
1024
|
-
/** call id。 */
|
|
1025
|
-
readonly callId: string;
|
|
1026
|
-
/** exposure 身份。 */
|
|
1027
|
-
readonly serviceInstanceId: string;
|
|
1028
|
-
/** 结构化错误。 */
|
|
1029
|
-
readonly error: {
|
|
1030
|
-
readonly code: string;
|
|
1031
|
-
readonly message: string;
|
|
1032
|
-
readonly phase: RuntimeErrorMessage["phase"];
|
|
1033
|
-
readonly details?: Readonly<Record<string, unknown>>;
|
|
1034
|
-
};
|
|
1035
|
-
}
|
|
1036
|
-
interface RuntimeCancelMessage {
|
|
1037
|
-
/** 消息类型。 */
|
|
1038
|
-
readonly type: typeof RUNTIME_CANCEL_TYPE;
|
|
1039
|
-
/** 协议版本。 */
|
|
1040
|
-
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
1041
|
-
/** 发送取消的物理 endpoint 绑定。 */
|
|
1042
|
-
readonly binding: RuntimeSessionBinding;
|
|
1043
|
-
/** call id。 */
|
|
1044
|
-
readonly callId: string;
|
|
1045
|
-
/** exposure 身份。 */
|
|
1046
|
-
readonly serviceInstanceId: string;
|
|
1047
|
-
}
|
|
1048
|
-
interface RuntimeNextMessage {
|
|
1049
|
-
/** 消息类型。 */
|
|
1050
|
-
readonly type: typeof RUNTIME_NEXT_TYPE;
|
|
1051
|
-
/** 协议版本。 */
|
|
1052
|
-
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
1053
|
-
/** 发送 stream item 的物理 endpoint 绑定。 */
|
|
1054
|
-
readonly binding: RuntimeSessionBinding;
|
|
1055
|
-
/** call id。 */
|
|
1056
|
-
readonly callId: string;
|
|
1057
|
-
/** exposure 身份。 */
|
|
1058
|
-
readonly serviceInstanceId: string;
|
|
1059
|
-
/** 连续序号。 */
|
|
1060
|
-
readonly sequence: number;
|
|
1061
|
-
/** parser 验证的 item。 */
|
|
1062
|
-
readonly item: unknown;
|
|
1063
|
-
}
|
|
1064
|
-
interface RuntimeCreditMessage {
|
|
1065
|
-
/** 消息类型。 */
|
|
1066
|
-
readonly type: typeof RUNTIME_CREDIT_TYPE;
|
|
1067
|
-
/** 协议版本。 */
|
|
1068
|
-
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
1069
|
-
/** 发送 credit 的物理 endpoint 绑定。 */
|
|
1070
|
-
readonly binding: RuntimeSessionBinding;
|
|
1071
|
-
/** call id。 */
|
|
1072
|
-
readonly callId: string;
|
|
1073
|
-
/** exposure 身份。 */
|
|
1074
|
-
readonly serviceInstanceId: string;
|
|
1075
|
-
/** 新增 credit。 */
|
|
1076
|
-
readonly count: number;
|
|
1077
|
-
}
|
|
1078
|
-
/** 请求对端先同步 fence、再等待真实执行排空。 */
|
|
1079
|
-
interface RuntimeCloseMessage {
|
|
1080
|
-
/** 消息类型。 */
|
|
1081
|
-
readonly type: typeof RUNTIME_CLOSE_TYPE;
|
|
1082
|
-
/** 协议版本。 */
|
|
1083
|
-
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
1084
|
-
/** 发起关闭的物理 endpoint 绑定。 */
|
|
1085
|
-
readonly binding: RuntimeSessionBinding;
|
|
1086
|
-
/** 对端 drain 的最大等待时间。 */
|
|
1087
|
-
readonly timeoutMs?: number;
|
|
1088
|
-
}
|
|
1089
|
-
/** 对端完成或超时 drain 后返回的关闭确认。 */
|
|
1090
|
-
interface RuntimeCloseAckMessage {
|
|
1091
|
-
/** 消息类型。 */
|
|
1092
|
-
readonly type: typeof RUNTIME_CLOSE_ACK_TYPE;
|
|
1093
|
-
/** 协议版本。 */
|
|
1094
|
-
readonly protocolVersion: typeof RUNTIME_PROTOCOL_VERSION;
|
|
1095
|
-
/** 发送确认的物理 endpoint 绑定。 */
|
|
1096
|
-
readonly binding: RuntimeSessionBinding;
|
|
1097
|
-
/** 确认对应的发起方 binding,防止旧 close-ack 误配新 session。 */
|
|
1098
|
-
readonly acknowledgedBinding: RuntimeSessionBinding;
|
|
1099
|
-
/** 对端本次 drain 的结果。 */
|
|
1100
|
-
readonly drained: boolean;
|
|
1101
|
-
/** 是否达到 bounded deadline。 */
|
|
1102
|
-
readonly timedOut: boolean;
|
|
1103
|
-
/** deadline 到达时仍存活的执行槽数量。 */
|
|
1104
|
-
readonly pendingExecutions: number;
|
|
1105
|
-
}
|
|
1106
|
-
type RuntimeWireMessage = RuntimeSnapshotMessage | RuntimeErrorMessage | RuntimeCallMessage | RuntimeResultMessage | RuntimeErrorResponseMessage | RuntimeCancelMessage | RuntimeNextMessage | RuntimeCreditMessage | RuntimeCloseMessage | RuntimeCloseAckMessage;
|
|
1107
|
-
interface RuntimeMessageCodec {
|
|
1108
|
-
/** 严格验证并冻结 v4 message。 */
|
|
1109
|
-
encode(message: RuntimeWireMessage): RuntimeWireMessage;
|
|
1110
|
-
/** 严格解析 v4 message;旧协议直接拒绝。 */
|
|
1111
|
-
decode(value: unknown): RuntimeWireMessage;
|
|
1112
|
-
}
|
|
1113
|
-
declare function createRuntimeMessageCodec(): RuntimeMessageCodec;
|
|
1114
|
-
declare function isRuntimeSnapshot(value: RuntimeWireMessage): value is RuntimeSnapshotMessage;
|
|
1115
|
-
|
|
1116
901
|
/** 验证 unknown 并返回领域类型的生产 parser。 */
|
|
1117
902
|
interface ValueParser<T> {
|
|
1118
903
|
/** 验证 unknown;失败必须抛出校验错误。 */
|
|
@@ -1320,8 +1105,8 @@ interface CapabilityBridge {
|
|
|
1320
1105
|
/** 取惰性 typed client;没有服务时不在此处同步失败。 */
|
|
1321
1106
|
getClient<C extends RemoteCapability>(capability: C, scope?: LifecycleScope): CapabilityClient<C>;
|
|
1322
1107
|
/** 应用一个完整对端目录。 */
|
|
1323
|
-
/**
|
|
1324
|
-
applySnapshot(snapshot:
|
|
1108
|
+
/** 应用一个远端完整目录;生产 wire 带 binding,旧 testing fixture 可省略。 */
|
|
1109
|
+
applySnapshot(snapshot: RuntimeSnapshot): SnapshotApplyResult;
|
|
1325
1110
|
/** 同步撤销全部旧代理。 */
|
|
1326
1111
|
invalidate(reason?: string): void;
|
|
1327
1112
|
/** 连接断开;旧代理永久失效。 */
|
|
@@ -1841,6 +1626,8 @@ interface RuntimeStatusSnapshot extends Omit<RuntimeSnapshot, "protocolVersion"
|
|
|
1841
1626
|
readonly binding?: RuntimeEndpointBinding;
|
|
1842
1627
|
/** 脱敏 Runtime 错误。 */
|
|
1843
1628
|
readonly error?: string;
|
|
1629
|
+
/** 结构化运行错误码,例如 runtime_lock_conflict。 */
|
|
1630
|
+
readonly errorCode?: string;
|
|
1844
1631
|
}
|
|
1845
1632
|
type RuntimeStatusListener = (snapshot: RuntimeStatusSnapshot) => void;
|
|
1846
1633
|
interface AppLike {
|
|
@@ -1903,4 +1690,4 @@ declare class RuntimeUnavailableError extends Error {
|
|
|
1903
1690
|
constructor(message?: string);
|
|
1904
1691
|
}
|
|
1905
1692
|
|
|
1906
|
-
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: {
|
|
@@ -193,6 +240,12 @@ interface StartSharedWorkerAppOptions extends Omit<CreatePluginHostOptions, "run
|
|
|
193
240
|
readonly peerExposureAllowlist?: readonly RemoteCapability[];
|
|
194
241
|
/** 可信 transport 配额;只能使用默认值或收紧。 */
|
|
195
242
|
readonly limits?: RuntimeLimitsInput;
|
|
243
|
+
/**
|
|
244
|
+
* 浏览器唯一运行锁。锁名只由 runtime id 生成,不含构建号、版本号或
|
|
245
|
+
* Worker URL;生产入口缺少 navigator.locks 时安全失败。manager 仅供
|
|
246
|
+
* testing 入口注入,不能作为生产回退。
|
|
247
|
+
*/
|
|
248
|
+
readonly runtimeLock?: RuntimeLockOptions;
|
|
196
249
|
}
|
|
197
250
|
interface StartSharedWorkerAppForTestingOptions extends StartSharedWorkerAppOptions {
|
|
198
251
|
/** testing 入口注入的 SharedWorkerGlobalScope 替身。 */
|
|
@@ -222,4 +275,4 @@ declare function startSharedWorkerApp(options: StartSharedWorkerAppOptions): Sha
|
|
|
222
275
|
/** testing/advanced harness 入口;生产包的 startSharedWorkerApp 不接受 scope 注入。 */
|
|
223
276
|
declare function startSharedWorkerAppForTesting(options: StartSharedWorkerAppForTestingOptions): SharedWorkerApp;
|
|
224
277
|
|
|
225
|
-
export { type
|
|
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,
|
|
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 逻辑标识。 */
|
package/docs/api.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# WebLoom v4 API 说明
|
|
2
2
|
|
|
3
|
-
WebLoom 0.4.
|
|
3
|
+
WebLoom 0.4.3 只支持两个真实 JavaScript realm:`window-main` 和
|
|
4
4
|
`shared-worker`。`runtime` 是受限的 `RuntimeKind`,不是可自由填写的环境标签;不支持
|
|
5
5
|
的 Runtime 在装配边界 fail closed。
|
|
6
6
|
|
|
@@ -71,6 +71,33 @@ RPC/stream。`ctx.capability(C)` 和 `ctx.optionalCapability(C)` 的参数、返
|
|
|
71
71
|
|
|
72
72
|
## SharedWorker 与双向 peer
|
|
73
73
|
|
|
74
|
+
### SharedWorker 运行锁
|
|
75
|
+
|
|
76
|
+
`startSharedWorkerApp()` 在插件注册前会向浏览器 `navigator.locks` 申请一把
|
|
77
|
+
稳定的 exclusive(唯一)运行锁。锁名默认是
|
|
78
|
+
`webloom.runtime:<runtimeId>`;它不包含 buildId(构建标识)、版本号或 Worker
|
|
79
|
+
URL(脚本地址),所以两个都支持 Web Locks 的旧/新构建以及不同 URL 会竞争同一把锁。
|
|
80
|
+
|
|
81
|
+
这里的“旧/新构建”不包括不认识 Web Locks 的旧包。例如 registry
|
|
82
|
+
`webloom-framework@0.4.2` 的 Worker 不会申请这把锁,`0.4.3` 不能通过
|
|
83
|
+
`LockManager` 发现一个仍存活的 `0.4.2` Worker。首次启用 Web Lock 必须先关闭所有
|
|
84
|
+
旧页面并确认旧 Worker 已退出,再启动新版本;这属于部署冷切换,不是运行时自动接管。
|
|
85
|
+
只有双方都已支持 Web Locks 的后续升级,才可以把下面的
|
|
86
|
+
`runtime_lock_conflict` 当作“请刷新或关闭全部页面”的冲突提示。
|
|
87
|
+
|
|
88
|
+
锁属于浏览器的 LockManager(浏览器锁管理器),不写 `localStorage`、IndexedDB
|
|
89
|
+
或 Local/S3 业务桶。`ifAvailable`(立即检查)语义意味着第二个物理 Worker
|
|
90
|
+
不会等待或启动插件,而是收到 `runtime_lock_conflict`(运行锁冲突)错误:
|
|
91
|
+
“检测到另一个 WebLoom Runtime 正在运行。请刷新或关闭所有相关页面后重新打开。”
|
|
92
|
+
应用可以通过 `runtimeLock.messages` 把“相关页面”替换为自己的产品名称;WebLoom
|
|
93
|
+
核心不依赖具体业务。
|
|
94
|
+
|
|
95
|
+
同一稳定 SharedWorker name(Worker 名称)的多个页面仍连接同一个物理 Worker,
|
|
96
|
+
因此只申请一次锁。Worker 终止后浏览器自动释放锁;Web Locks 不可用时使用
|
|
97
|
+
`runtime_lock_unavailable`(运行锁不可用)安全失败,不能退化为 localStorage
|
|
98
|
+
锁或无锁运行。`StartSharedWorkerAppOptions.runtimeLock.manager` 仅供测试注入,
|
|
99
|
+
不是生产回退。
|
|
100
|
+
|
|
74
101
|
Worker 入口:
|
|
75
102
|
|
|
76
103
|
```ts
|
|
@@ -526,7 +526,7 @@ Local 桶是 Window `localStorage`,不换 IndexedDB;先选择/导入桶,
|
|
|
526
526
|
|
|
527
527
|
业务异步边界前后及最终写入前仍校验,同步 revoke 先于 drain。初始化事务仍先构建完整 Hold 候选,catalog/CAS 最后可见;恢复记录使用生产 parser。不得为通过 v4 测试放宽非法恢复状态。
|
|
528
528
|
|
|
529
|
-
旧页面/旧 Worker 与 v4 不混用业务调用。采用 build 隔离的 Worker 产物与名称,不共享旧 wire;新 Worker
|
|
529
|
+
旧页面/旧 Worker 与 v4 不混用业务调用。采用 build 隔离的 Worker 产物与名称,不共享旧 wire;新 Worker 不能因新名称就绕过运行唯一性。首次启用 Web Lock 时,旧版若不申请 Web Lock(例如 registry `0.4.2`)不会被新 Worker 自动发现,必须由部署门禁确认所有旧页面和旧 Worker 已退出后冷切换。只有新旧双方都申请同一稳定锁的后续升级,才用 `runtime_lock_conflict` 提示刷新;不能把它当成首次迁移检测。发现旧最终 I/O lease 未释放时仍进入 recovery-required,不能强抢或清空账本。
|
|
530
530
|
|
|
531
531
|
产品可在断线后显式重建 Runtime/重开 session/重订阅;不自动重放已经发送的写入、签名或交易。响应丢失走已有 operation/transaction 查询或恢复流程。
|
|
532
532
|
|