webloom-framework 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -42
- package/dist/advanced.d.ts +168 -0
- package/dist/advanced.js +441 -0
- package/dist/advanced.js.map +1 -0
- package/dist/chunk-4DSINPZD.js +158 -0
- package/dist/chunk-4DSINPZD.js.map +1 -0
- package/dist/chunk-JHJZIO2H.js +4018 -0
- package/dist/chunk-JHJZIO2H.js.map +1 -0
- package/dist/chunk-RAQOFUZY.js +1737 -0
- package/dist/chunk-RAQOFUZY.js.map +1 -0
- package/dist/chunk-YOIH6H36.js +433 -0
- package/dist/chunk-YOIH6H36.js.map +1 -0
- package/dist/index.d.ts +39 -259
- package/dist/index.js +38 -1359
- package/dist/index.js.map +1 -1
- package/dist/messageBus-CtrwkjrO.d.ts +5 -0
- package/dist/messagePortServiceTransport-B0FyJr43.d.ts +264 -0
- package/dist/react.d.ts +41 -28
- package/dist/react.js +79 -88
- package/dist/react.js.map +1 -1
- package/dist/runtimeTypes-DquUCHz-.d.ts +1640 -0
- package/dist/sharedWorkerHost-Cb2a1_KD.d.ts +190 -0
- package/dist/testing.d.ts +18 -17
- package/dist/testing.js +23 -15
- package/dist/testing.js.map +1 -1
- package/dist/windowRuntime-B6Ue8jso.d.ts +23 -0
- package/docs/api.md +148 -111
- package/docs/proposals/webloom-v4/implementation-plan.md +443 -0
- package/docs/proposals/webloom-v4/requirements.md +555 -0
- package/docs/proposals/webloom-v4/verification.md +84 -0
- package/package.json +9 -2
- package/dist/chunk-76BGPI6M.js +0 -4261
- package/dist/chunk-76BGPI6M.js.map +0 -1
- package/dist/createPluginHost-BVsUCDKN.d.ts +0 -1318
- package/dist/resourceRegistry-BFnjmeGE.d.ts +0 -267
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { ak as LifecycleScopeKind, L as LifecycleScopeIdentity, f as LifecycleScope, ah as LifecycleDisposeResult, bb as RuntimeLimits, P as PluginManifest, T as PluginSetup, K as Capability, l as RuntimeHandle, Y as CapabilityBridge, W as WindowApp, aV as RemoteCapability, j as CapabilityPeer, Z as CapabilityClient, a7 as HandlerCallContext, bf as RuntimeStatusSnapshot, be as RuntimeStatusListener, t as HostInspection, s as CreatePluginHostOptions } from './runtimeTypes-DquUCHz-.js';
|
|
2
|
+
|
|
3
|
+
interface CreateResourceScopeOptions {
|
|
4
|
+
/** 可选固定作用域标识;生产代码通常省略,让实现生成不可复用 ID。 */
|
|
5
|
+
scopeId?: string;
|
|
6
|
+
/** 运行实例标识;省略时与 scopeId 同源生成。 */
|
|
7
|
+
instanceId?: string;
|
|
8
|
+
/** 作用域类型。 */
|
|
9
|
+
kind: LifecycleScopeKind;
|
|
10
|
+
/** 绑定插件和宿主只读属性。 */
|
|
11
|
+
metadata?: Omit<Partial<LifecycleScopeIdentity>, "scopeId" | "instanceId" | "kind">;
|
|
12
|
+
/** 测试或宿主诊断使用的状态变更回调。 */
|
|
13
|
+
onChange?: (scope: LifecycleScope) => void;
|
|
14
|
+
/** 子作用域生成最终清理结果后的内部通知;用于更新父级登记。 */
|
|
15
|
+
onDisposeResult?: (result: LifecycleDisposeResult) => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 创建一个可嵌套的生命周期作用域。
|
|
19
|
+
*
|
|
20
|
+
* `createResourceScope` 是 `createLifecycleScope` 的同义入口,方便不同
|
|
21
|
+
* 模块按“作用域”或“资源”语义调用;两者不代表两套实现。
|
|
22
|
+
*/
|
|
23
|
+
declare function createLifecycleScope(options: CreateResourceScopeOptions): LifecycleScope;
|
|
24
|
+
/** 语义别名:资源管理代码通常以 ResourceScope 称呼同一原语。 */
|
|
25
|
+
declare const createResourceScope: typeof createLifecycleScope;
|
|
26
|
+
type ResourceScopeOptions = CreateResourceScopeOptions;
|
|
27
|
+
|
|
28
|
+
type RuntimeLimitsInput = Partial<RuntimeLimits>;
|
|
29
|
+
/** Runtime execution slot 释放时等待调度的回调。 */
|
|
30
|
+
type RuntimeExecutionWaiter = () => void;
|
|
31
|
+
/** 一个 Runtime/方向共享的原子配额计数器;仅由 transport 装配层持有。 */
|
|
32
|
+
interface RuntimeBudget {
|
|
33
|
+
readonly limits: RuntimeLimits;
|
|
34
|
+
pendingCalls: number;
|
|
35
|
+
activeStreams: number;
|
|
36
|
+
executionSlots: number;
|
|
37
|
+
retainedPayloadBytes: number;
|
|
38
|
+
/** 以 FIFO 顺序登记一个等待全局 execution slot 的 transport 队列。 */
|
|
39
|
+
registerExecutionWaiter(waiter: RuntimeExecutionWaiter): () => void;
|
|
40
|
+
/** 释放一个全局 execution slot,并公平唤醒一个等待者。 */
|
|
41
|
+
releaseExecutionSlot(): void;
|
|
42
|
+
}
|
|
43
|
+
/** 对接收端已有的 MessageEvent.ports 建立一次性关闭账本。 */
|
|
44
|
+
interface ReceivePortLedger {
|
|
45
|
+
/** 本次消息实际收到的 raw ports。 */
|
|
46
|
+
readonly ports: readonly MessagePort[];
|
|
47
|
+
/** raw 账本是否通过数量、类型和去重检查。 */
|
|
48
|
+
readonly valid: boolean;
|
|
49
|
+
/** 将所有端口的关闭责任移交业务调用者。 */
|
|
50
|
+
handoff(): void;
|
|
51
|
+
/** 关闭尚未移交的端口;幂等。 */
|
|
52
|
+
closeUndelivered(): void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** 可传给 Runtime 的 v4 插件定义;没有旧 manifest 字段或兼容签名。 */
|
|
56
|
+
type RuntimePluginDefinition = {
|
|
57
|
+
/** 静态 manifest。 */
|
|
58
|
+
readonly manifest: PluginManifest;
|
|
59
|
+
/** 当前 realm 的 setup 实现。 */
|
|
60
|
+
readonly setup: PluginSetup;
|
|
61
|
+
/** 当前 realm 的 typed capability 定义表。 */
|
|
62
|
+
readonly capabilities?: readonly Capability[];
|
|
63
|
+
/** 多 unit 定义中的实现目标。 */
|
|
64
|
+
readonly unitId?: string;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
interface SharedWorkerLike {
|
|
68
|
+
/** SharedWorker 主端口。 */
|
|
69
|
+
readonly port: MessagePort;
|
|
70
|
+
/** Worker error callback。 */
|
|
71
|
+
onerror?: (event: Event) => void;
|
|
72
|
+
addEventListener?(type: "error", listener: (event: Event) => void): void;
|
|
73
|
+
removeEventListener?(type: "error", listener: (event: Event) => void): void;
|
|
74
|
+
}
|
|
75
|
+
type SharedWorkerFactory = (url: string | URL, options: {
|
|
76
|
+
type: "module";
|
|
77
|
+
name?: string;
|
|
78
|
+
credentials?: RequestCredentials;
|
|
79
|
+
}) => SharedWorkerLike;
|
|
80
|
+
interface SharedWorkerClientExposure {
|
|
81
|
+
/** 已完成本地初始化的 WindowApp。 */
|
|
82
|
+
readonly app: WindowApp;
|
|
83
|
+
/** 明确暴露给 Worker 的 RPC/stream capability。 */
|
|
84
|
+
readonly expose?: readonly RemoteCapability[];
|
|
85
|
+
}
|
|
86
|
+
interface ConnectSharedWorkerOptions {
|
|
87
|
+
/** Worker Runtime 逻辑标识。 */
|
|
88
|
+
readonly id: string;
|
|
89
|
+
/** Worker 构建 URL。 */
|
|
90
|
+
readonly url: string | URL;
|
|
91
|
+
/** SharedWorker name。 */
|
|
92
|
+
readonly name?: string;
|
|
93
|
+
/** 请求 credentials。 */
|
|
94
|
+
readonly credentials?: RequestCredentials;
|
|
95
|
+
/** 默认 call 预算。 */
|
|
96
|
+
readonly defaultCallTimeoutMs?: number;
|
|
97
|
+
/** 可信 transport 配额;只能使用默认值或收紧。 */
|
|
98
|
+
readonly limits?: RuntimeLimitsInput;
|
|
99
|
+
/** 可选的页面反向能力。 */
|
|
100
|
+
readonly client?: SharedWorkerClientExposure;
|
|
101
|
+
}
|
|
102
|
+
/** 同步创建 RuntimeHandle;ready 由 state/capability Promise 观察。 */
|
|
103
|
+
declare function connectSharedWorker(options: ConnectSharedWorkerOptions): RuntimeHandle;
|
|
104
|
+
/** testing 入口才允许注入可控 Worker 工厂。 */
|
|
105
|
+
declare function connectSharedWorkerForTesting(options: ConnectSharedWorkerOptions, workerFactory: SharedWorkerFactory): RuntimeHandle;
|
|
106
|
+
/** advanced 装配层取得连接 bridge;普通 RuntimeHandle 不暴露该实现细节。 */
|
|
107
|
+
declare function bridgeForRuntimeHandle(handle: RuntimeHandle): CapabilityBridge;
|
|
108
|
+
|
|
109
|
+
interface SharedWorkerScopeLike {
|
|
110
|
+
/** SharedWorker 连接事件。 */
|
|
111
|
+
onconnect: ((event: {
|
|
112
|
+
ports: MessagePort[];
|
|
113
|
+
}) => void) | null;
|
|
114
|
+
}
|
|
115
|
+
interface PeerExposureOptions {
|
|
116
|
+
/** 领域授权标识。 */
|
|
117
|
+
readonly grantId?: string;
|
|
118
|
+
/** 授权修订。 */
|
|
119
|
+
readonly authorizationRevision?: number;
|
|
120
|
+
/** 无环公开属性。 */
|
|
121
|
+
readonly attributes?: Readonly<Record<string, unknown>>;
|
|
122
|
+
/** 领域授权检查。 */
|
|
123
|
+
readonly authorize?: (context: HandlerCallContext, request: unknown) => boolean | Promise<boolean>;
|
|
124
|
+
/** 领域 Scope。 */
|
|
125
|
+
readonly scope?: LifecycleScope;
|
|
126
|
+
}
|
|
127
|
+
interface PeerController {
|
|
128
|
+
/** peer 标识。 */
|
|
129
|
+
readonly peerId: string;
|
|
130
|
+
/** 已观察到的页面 Runtime 实例;首个页面快照前为空。 */
|
|
131
|
+
readonly runtimeInstanceId?: string;
|
|
132
|
+
/** 对端 Window Runtime 类型。 */
|
|
133
|
+
readonly runtime: "window-main";
|
|
134
|
+
/** peer 子作用域。 */
|
|
135
|
+
readonly scope: LifecycleScope;
|
|
136
|
+
/** 传给普通 handler 的最小 PeerView。 */
|
|
137
|
+
readonly view: CapabilityPeer;
|
|
138
|
+
/** 获取页面暴露的 typed remote capability。 */
|
|
139
|
+
capability<C extends RemoteCapability>(capability: C): CapabilityClient<C>;
|
|
140
|
+
/** 暴露 Worker 已注册的 capability。 */
|
|
141
|
+
expose<C extends RemoteCapability>(capability: C, options?: PeerExposureOptions): {
|
|
142
|
+
revoke(): void;
|
|
143
|
+
};
|
|
144
|
+
/** 原子暴露一组 capability;任一项非法时不得部分开放。 */
|
|
145
|
+
exposeGroup(entries: readonly {
|
|
146
|
+
readonly capability: RemoteCapability;
|
|
147
|
+
readonly options?: PeerExposureOptions;
|
|
148
|
+
}[]): {
|
|
149
|
+
revoke(): void;
|
|
150
|
+
};
|
|
151
|
+
/** 断开此 peer,不影响其它页面。 */
|
|
152
|
+
disconnect(reason?: string): void;
|
|
153
|
+
/** peer 诊断。 */
|
|
154
|
+
inspect(): Readonly<Record<string, unknown>>;
|
|
155
|
+
}
|
|
156
|
+
interface StartSharedWorkerAppOptions extends Omit<CreatePluginHostOptions, "runtime" | "runtimeUnitImplementationRegistry" | "runtimeId" | "runtimeInstanceId"> {
|
|
157
|
+
/** Worker Runtime 逻辑标识。 */
|
|
158
|
+
readonly id: string;
|
|
159
|
+
/** Worker realm 的插件定义。 */
|
|
160
|
+
readonly plugins: readonly RuntimePluginDefinition[];
|
|
161
|
+
/** 对每个新 peer 顶层暴露的能力。 */
|
|
162
|
+
readonly expose?: readonly RemoteCapability[];
|
|
163
|
+
/** 同步配置 peer 级策略。 */
|
|
164
|
+
readonly configurePeer?: (peer: PeerController) => void;
|
|
165
|
+
/** configurePeer 可管理的显式 capability allowlist;未设置时不开放动态能力。 */
|
|
166
|
+
readonly peerExposureAllowlist?: readonly RemoteCapability[];
|
|
167
|
+
/** 可信 transport 配额;只能使用默认值或收紧。 */
|
|
168
|
+
readonly limits?: RuntimeLimitsInput;
|
|
169
|
+
}
|
|
170
|
+
interface StartSharedWorkerAppForTestingOptions extends StartSharedWorkerAppOptions {
|
|
171
|
+
/** testing 入口注入的 SharedWorkerGlobalScope 替身。 */
|
|
172
|
+
readonly globalScope: SharedWorkerScopeLike;
|
|
173
|
+
}
|
|
174
|
+
interface SharedWorkerApp {
|
|
175
|
+
readonly runtimeKind: "shared-worker";
|
|
176
|
+
readonly runtimeId: string;
|
|
177
|
+
readonly runtimeInstanceId: string;
|
|
178
|
+
ready(): Promise<void>;
|
|
179
|
+
reconcile(): Promise<void>;
|
|
180
|
+
state(): RuntimeStatusSnapshot;
|
|
181
|
+
subscribe(listener: RuntimeStatusListener): () => void;
|
|
182
|
+
inspect(): HostInspection;
|
|
183
|
+
dispose(reason?: string): Promise<LifecycleDisposeResult>;
|
|
184
|
+
}
|
|
185
|
+
/** 生产入口:只从真实 SharedWorkerGlobalScope 获取连接事件。 */
|
|
186
|
+
declare function startSharedWorkerApp(options: StartSharedWorkerAppOptions): SharedWorkerApp;
|
|
187
|
+
/** testing/advanced harness 入口;生产包的 startSharedWorkerApp 不接受 scope 注入。 */
|
|
188
|
+
declare function startSharedWorkerAppForTesting(options: StartSharedWorkerAppForTestingOptions): SharedWorkerApp;
|
|
189
|
+
|
|
190
|
+
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 f, type StartSharedWorkerAppOptions as g, bridgeForRuntimeHandle as h, createLifecycleScope as i, createResourceScope as j, type ConnectSharedWorkerOptions as k, type SharedWorkerLike as l, connectSharedWorker as m, type SharedWorkerFactory as n, type SharedWorkerScopeLike as o, connectSharedWorkerForTesting as p, startSharedWorkerAppForTesting as q, startSharedWorkerApp as s };
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
|
|
1
|
+
import { s as CreatePluginHostOptions, x as PluginHost } from './runtimeTypes-DquUCHz-.js';
|
|
2
|
+
export { m as CapabilityRegistration, n as CapabilityRegistry, o as ContextExtensionInput, p as ContributionAdapter, q as ContributionAdapterInput, r as ContributionHandle, H as HostCapabilityRegistration, t as HostInspection, u as PermissionPolicyInput, v as PermissionPolicyResult, w as PluginConfigStore, y as RuntimeUnitAttributesInput, z as RuntimeUnitAvailabilityInput, A as RuntimeUnitParentScopeInput, B as RuntimeUnitSnapshot, D as StartupCapabilityError, E as StartupPluginError, F as createCapabilityRegistry, G as createInMemoryPluginConfigStore, I as createPluginHost, bP as createResourceStore, J as invokeCapabilityHandler } from './runtimeTypes-DquUCHz-.js';
|
|
3
|
+
import { z as RuntimeWireMessage, a as RuntimeTransport } from './messagePortServiceTransport-B0FyJr43.js';
|
|
4
|
+
export { C as CreateCapabilityBridgeOptions, b as CreatePluginIntentControllerOptions, M as MessagePortLike, r as RuntimeReceiveMetadata, y as RuntimeUnitImplementation, A as createCapabilityBridge, B as createMessagePortRuntimeTransport, D as createPluginIntentController, E as createResourceRegistry, G as createRuntimeUnitImplementationRegistry, J as validateTransferables } from './messagePortServiceTransport-B0FyJr43.js';
|
|
5
|
+
export { C as CreateResourceScopeOptions, e as ResourceScopeOptions, n as SharedWorkerFactory, o as SharedWorkerScopeLike, f as StartSharedWorkerAppForTestingOptions, p as connectSharedWorkerForTesting, i as createLifecycleScope, j as createResourceScope, q as startSharedWorkerAppForTesting } from './sharedWorkerHost-Cb2a1_KD.js';
|
|
6
|
+
export { c as createMessageBus } from './messageBus-CtrwkjrO.js';
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
/** 可观察的 transport 发送记录。 */
|
|
9
|
+
interface FakeTransportMessage {
|
|
10
|
+
/** 已验证的 v4 message。 */
|
|
11
|
+
readonly message: RuntimeWireMessage;
|
|
12
|
+
/** transfer 资源。 */
|
|
13
|
+
readonly transfer: readonly Transferable[];
|
|
10
14
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/** 创建可观察的假服务传输;每次 call 都记录 request 和 context。 */
|
|
16
|
-
declare function createFakeRemoteServiceTransport(options?: CreateFakeTransportOptions): RemoteServiceTransport & {
|
|
17
|
-
readonly calls: readonly FakeTransportCall[];
|
|
15
|
+
/** 创建内存双向 transport;两侧可通过 emit 注入真实 wire message。 */
|
|
16
|
+
declare function createFakeRuntimeTransport(): RuntimeTransport & {
|
|
17
|
+
readonly sent: readonly FakeTransportMessage[];
|
|
18
|
+
emit(message: RuntimeWireMessage, ports?: readonly MessagePort[]): void;
|
|
18
19
|
reset(): void;
|
|
19
20
|
};
|
|
20
|
-
/** 创建测试 Host
|
|
21
|
+
/** 创建测试 Host;生产 Host 的 parser/lifecycle 路径保持不变。 */
|
|
21
22
|
declare function createFakePluginHost(options?: CreatePluginHostOptions): PluginHost;
|
|
22
23
|
|
|
23
|
-
export {
|
|
24
|
+
export { CreatePluginHostOptions, type FakeTransportMessage, PluginHost, RuntimeTransport, createFakePluginHost, createFakeRuntimeTransport };
|
package/dist/testing.js
CHANGED
|
@@ -1,27 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
1
|
+
export { startSharedWorkerAppForTesting } from './chunk-YOIH6H36.js';
|
|
2
|
+
export { createPluginIntentController } from './chunk-4DSINPZD.js';
|
|
3
|
+
export { connectSharedWorkerForTesting, createCapabilityBridge, createMessagePortRuntimeTransport, validateTransferables } from './chunk-RAQOFUZY.js';
|
|
4
|
+
import { createPluginHost } from './chunk-JHJZIO2H.js';
|
|
5
|
+
export { StartupCapabilityError, StartupPluginError, createCapabilityRegistry, createInMemoryPluginConfigStore, createLifecycleScope, createMessageBus, createPluginHost, createResourceRegistry, createResourceScope, createResourceStore, createRuntimeUnitImplementationRegistry, invokeCapabilityHandler } from './chunk-JHJZIO2H.js';
|
|
3
6
|
|
|
4
7
|
// src/testing/fakes.ts
|
|
5
|
-
function
|
|
6
|
-
const
|
|
8
|
+
function createFakeRuntimeTransport() {
|
|
9
|
+
const sent = [];
|
|
10
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
7
11
|
return {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
sent,
|
|
13
|
+
send(message, transfer = []) {
|
|
14
|
+
sent.push({ message, transfer: [...transfer] });
|
|
15
|
+
},
|
|
16
|
+
subscribe(listener) {
|
|
17
|
+
listeners.add(listener);
|
|
18
|
+
return () => listeners.delete(listener);
|
|
11
19
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
emit(message, ports = []) {
|
|
21
|
+
const metadata = { ports: Object.freeze([...ports]) };
|
|
22
|
+
for (const listener of [...listeners]) listener(message, metadata);
|
|
23
|
+
},
|
|
24
|
+
reset() {
|
|
25
|
+
sent.length = 0;
|
|
15
26
|
}
|
|
16
27
|
};
|
|
17
28
|
}
|
|
18
29
|
function createFakePluginHost(options = {}) {
|
|
19
|
-
return createPluginHost({
|
|
20
|
-
...options,
|
|
21
|
-
initialPluginConfig: options.initialPluginConfig ?? {}
|
|
22
|
-
});
|
|
30
|
+
return createPluginHost({ ...options, initialPluginConfig: options.initialPluginConfig ?? {} });
|
|
23
31
|
}
|
|
24
32
|
|
|
25
|
-
export { createFakePluginHost,
|
|
33
|
+
export { createFakePluginHost, createFakeRuntimeTransport };
|
|
26
34
|
//# sourceMappingURL=testing.js.map
|
|
27
35
|
//# sourceMappingURL=testing.js.map
|
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/testing/fakes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/testing/fakes.ts"],"names":[],"mappings":";;;;;;;AAeO,SAAS,0BAAA,GAId;AACA,EAAA,MAAM,OAA+B,EAAC;AACtC,EAAA,MAAM,SAAA,uBAAgB,GAAA,EAA8E;AACpG,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,IAAA,CAAK,OAAA,EAAS,QAAA,GAAW,EAAC,EAAG;AAAE,MAAA,IAAA,CAAK,IAAA,CAAK,EAAE,OAAA,EAAS,QAAA,EAAU,CAAC,GAAG,QAAQ,GAAG,CAAA;AAAA,IAAG,CAAA;AAAA,IAChF,UAAU,QAAA,EAAU;AAAE,MAAA,SAAA,CAAU,IAAI,QAAQ,CAAA;AAAG,MAAA,OAAO,MAAM,SAAA,CAAU,MAAA,CAAO,QAAQ,CAAA;AAAA,IAAG,CAAA;AAAA,IACxF,IAAA,CAAK,OAAA,EAAS,KAAA,GAAQ,EAAC,EAAG;AAAE,MAAA,MAAM,QAAA,GAAmC,EAAE,KAAA,EAAO,MAAA,CAAO,OAAO,CAAC,GAAG,KAAK,CAAC,CAAA,EAAE;AAAG,MAAA,KAAA,MAAW,YAAY,CAAC,GAAG,SAAS,CAAA,EAAG,QAAA,CAAS,SAAS,QAAQ,CAAA;AAAA,IAAG,CAAA;AAAA,IAC/K,KAAA,GAAQ;AAAE,MAAA,IAAA,CAAK,MAAA,GAAS,CAAA;AAAA,IAAG;AAAA,GAC7B;AACF;AAGO,SAAS,oBAAA,CAAqB,OAAA,GAAmC,EAAC,EAAe;AACtF,EAAA,OAAO,gBAAA,CAAiB,EAAE,GAAG,OAAA,EAAS,qBAAqB,OAAA,CAAQ,mBAAA,IAAuB,EAAC,EAAG,CAAA;AAChG","file":"testing.js","sourcesContent":["// WebLoom 测试辅助:不注入产品授权或绕过生产 parser。\n\nimport type { RuntimeReceiveMetadata, RuntimeTransport } from \"../transport/serviceBridge.js\";\nimport type { RuntimeWireMessage } from \"../runtime/runtimeProtocol.js\";\nimport { createPluginHost, type CreatePluginHostOptions, type PluginHost } from \"../host/createPluginHost.js\";\n\n/** 可观察的 transport 发送记录。 */\nexport interface FakeTransportMessage {\n /** 已验证的 v4 message。 */\n readonly message: RuntimeWireMessage;\n /** transfer 资源。 */\n readonly transfer: readonly Transferable[];\n}\n\n/** 创建内存双向 transport;两侧可通过 emit 注入真实 wire message。 */\nexport function createFakeRuntimeTransport(): RuntimeTransport & {\n readonly sent: readonly FakeTransportMessage[];\n emit(message: RuntimeWireMessage, ports?: readonly MessagePort[]): void;\n reset(): void;\n} {\n const sent: FakeTransportMessage[] = [];\n const listeners = new Set<(message: RuntimeWireMessage, metadata?: RuntimeReceiveMetadata) => void>();\n return {\n sent,\n send(message, transfer = []) { sent.push({ message, transfer: [...transfer] }); },\n subscribe(listener) { listeners.add(listener); return () => listeners.delete(listener); },\n emit(message, ports = []) { const metadata: RuntimeReceiveMetadata = { ports: Object.freeze([...ports]) }; for (const listener of [...listeners]) listener(message, metadata); },\n reset() { sent.length = 0; },\n };\n}\n\n/** 创建测试 Host;生产 Host 的 parser/lifecycle 路径保持不变。 */\nexport function createFakePluginHost(options: CreatePluginHostOptions = {}): PluginHost {\n return createPluginHost({ ...options, initialPluginConfig: options.initialPluginConfig ?? {} });\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { s as CreatePluginHostOptions, x as PluginHost, W as WindowApp } from './runtimeTypes-DquUCHz-.js';
|
|
2
|
+
import { c as RuntimePluginDefinition } from './sharedWorkerHost-Cb2a1_KD.js';
|
|
3
|
+
|
|
4
|
+
interface CreateWindowAppOptions extends Omit<CreatePluginHostOptions, "runtime" | "runtimeUnitImplementationRegistry" | "runtimeInstanceId" | "runtimeId" | "capabilityBridge"> {
|
|
5
|
+
/** Window Runtime 逻辑标识。 */
|
|
6
|
+
readonly id?: string;
|
|
7
|
+
/** 当前 Window realm 的插件定义。 */
|
|
8
|
+
readonly plugins: readonly RuntimePluginDefinition[];
|
|
9
|
+
}
|
|
10
|
+
interface CreateWindowAppFromHostOptions extends Omit<CreatePluginHostOptions, "runtime" | "runtimeUnitImplementationRegistry" | "capabilityBridge"> {
|
|
11
|
+
/** Window Runtime 逻辑标识。 */
|
|
12
|
+
readonly id?: string;
|
|
13
|
+
/** 已创建且所有权转移给 App 的 v4 Host。 */
|
|
14
|
+
readonly host: PluginHost;
|
|
15
|
+
}
|
|
16
|
+
/** 创建当前 Window 的 v4 Runtime;本地插件启动完成后 resolve。 */
|
|
17
|
+
declare function createWindowApp(options: CreateWindowAppOptions): Promise<WindowApp>;
|
|
18
|
+
/** advanced:接管一个现有 v4 Host,不复制 Host。 */
|
|
19
|
+
declare function createWindowAppFromHost(options: CreateWindowAppFromHostOptions): Promise<WindowApp>;
|
|
20
|
+
/** advanced 装配层查询 App 所拥有的 Host。 */
|
|
21
|
+
declare function hostForWindowApp(app: WindowApp): PluginHost;
|
|
22
|
+
|
|
23
|
+
export { type CreateWindowAppOptions as C, createWindowApp as a, createWindowAppFromHost as c, hostForWindowApp as h };
|