webloom-framework 0.3.0 → 0.4.1
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-ANA6GBEI.js +1737 -0
- package/dist/chunk-ANA6GBEI.js.map +1 -0
- package/dist/chunk-HJKPKWI7.js +4024 -0
- package/dist/chunk-HJKPKWI7.js.map +1 -0
- package/dist/chunk-SX46RHDI.js +433 -0
- package/dist/chunk-SX46RHDI.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-BYprNvQY.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-KI7TIGdX.d.ts +192 -0
- package/dist/testing.d.ts +18 -17
- package/dist/testing.js +23 -15
- package/dist/testing.js.map +1 -1
- package/dist/windowRuntime-BKkLPsAS.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 +115 -0
- package/package.json +11 -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
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# WebLoom
|
|
2
2
|
|
|
3
|
-
WebLoom 是一个只面向浏览器的插件 Runtime 框架。0.
|
|
4
|
-
`window-main` 和 `shared-worker` JavaScript realm
|
|
5
|
-
|
|
3
|
+
WebLoom 是一个只面向浏览器的插件 Runtime 框架。0.4.1 管理真实的
|
|
4
|
+
`window-main` 和 `shared-worker` JavaScript realm、插件运行单元、实例、依赖图、
|
|
5
|
+
ResourceScope、权限租约、typed capability、服务桥和资源缓存;路由、存储、日志、
|
|
6
6
|
国际化等产品能力由插件或下游应用注入。
|
|
7
7
|
|
|
8
8
|
## 安装
|
|
@@ -11,10 +11,11 @@ WebLoom 是一个只面向浏览器的插件 Runtime 框架。0.3.0 管理真实
|
|
|
11
11
|
pnpm add webloom-framework
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
WebLoom 是 ESM
|
|
14
|
+
WebLoom 是 ESM 单包,提供四个入口:
|
|
15
15
|
|
|
16
16
|
- `webloom-framework`:浏览器核心,提供 Window/SharedWorker Runtime,不加载 React;
|
|
17
|
-
- `webloom-framework/
|
|
17
|
+
- `webloom-framework/advanced`:Host、graph、peer、transport 和分阶段装配工具;
|
|
18
|
+
- `webloom-framework/react`:Provider、typed capability、plugin 和 Resource Hooks;
|
|
18
19
|
- `webloom-framework/testing`:无产品语义的假 Host、假传输和测试辅助。
|
|
19
20
|
|
|
20
21
|
React 是可选 peer dependency。只使用 `webloom-framework` 时不需要安装 React。
|
|
@@ -22,27 +23,37 @@ React 是可选 peer dependency。只使用 `webloom-framework` 时不需要安
|
|
|
22
23
|
## 最小 Window Runtime
|
|
23
24
|
|
|
24
25
|
```ts
|
|
25
|
-
import { createWindowApp, definePlugin } from "webloom-framework";
|
|
26
|
+
import { defineCapability, createWindowApp, definePlugin } from "webloom-framework";
|
|
27
|
+
|
|
28
|
+
const Hello = defineCapability<{ value: string }>({
|
|
29
|
+
kind: "local",
|
|
30
|
+
id: "hello.service",
|
|
31
|
+
version: "1",
|
|
32
|
+
});
|
|
26
33
|
|
|
27
34
|
const hello = definePlugin({
|
|
28
35
|
id: "hello",
|
|
29
|
-
provides: [
|
|
36
|
+
provides: [Hello] as const,
|
|
30
37
|
setup(ctx) {
|
|
31
|
-
ctx.provide(
|
|
38
|
+
ctx.provide(Hello, { value: "world" });
|
|
32
39
|
},
|
|
33
40
|
});
|
|
34
41
|
|
|
35
42
|
const app = await createWindowApp({ plugins: [hello] });
|
|
36
|
-
const service = app.capability
|
|
43
|
+
const service = app.capability(Hello);
|
|
37
44
|
console.log(service.value); // world
|
|
38
45
|
|
|
39
46
|
await app.dispose();
|
|
40
47
|
```
|
|
41
48
|
|
|
49
|
+
`defineCapability()` 是 capability 的唯一身份入口。local capability 只在同一 realm
|
|
50
|
+
提供和消费;RPC/stream capability 必须声明生产 `request`、`response` 或 `item`
|
|
51
|
+
parser,调用参数与结果从契约对象自动推导。
|
|
52
|
+
|
|
42
53
|
`createWindowApp()` 会固定创建一个 `window-main` Runtime、生成新的
|
|
43
54
|
`runtimeInstanceId`、装配实现并等待初始插件启动。普通插件不需要手工创建
|
|
44
|
-
Implementation Registry 或调用 `host.register()
|
|
45
|
-
|
|
55
|
+
Implementation Registry 或调用 `host.register()`;静态 manifest 不包含 setup、parser
|
|
56
|
+
或 transfer 函数。
|
|
46
57
|
|
|
47
58
|
## SharedWorker Runtime
|
|
48
59
|
|
|
@@ -50,28 +61,44 @@ Worker 入口只在 Worker realm 中装配插件:
|
|
|
50
61
|
|
|
51
62
|
```ts
|
|
52
63
|
// coordinator.worker.ts
|
|
53
|
-
import { definePlugin, startSharedWorkerApp } from "webloom-framework";
|
|
64
|
+
import { defineCapability, definePlugin, startSharedWorkerApp } from "webloom-framework";
|
|
65
|
+
|
|
66
|
+
const Health = defineCapability({
|
|
67
|
+
kind: "rpc",
|
|
68
|
+
id: "coordinator.health",
|
|
69
|
+
version: "1",
|
|
70
|
+
request: { parse(value: unknown): { type: string } {
|
|
71
|
+
if (!value || typeof value !== "object" || typeof (value as { type?: unknown }).type !== "string") {
|
|
72
|
+
throw new Error("invalid health request");
|
|
73
|
+
}
|
|
74
|
+
return value as { type: string };
|
|
75
|
+
} },
|
|
76
|
+
response: { parse(value: unknown): { type: string; instanceId: string } {
|
|
77
|
+
if (!value || typeof value !== "object") throw new Error("invalid health response");
|
|
78
|
+
const result = value as { type?: unknown; instanceId?: unknown };
|
|
79
|
+
if (typeof result.type !== "string" || typeof result.instanceId !== "string") throw new Error("invalid health response");
|
|
80
|
+
return value as { type: string; instanceId: string };
|
|
81
|
+
} },
|
|
82
|
+
});
|
|
54
83
|
|
|
55
84
|
const coordinator = definePlugin({
|
|
56
85
|
id: "coordinator",
|
|
57
|
-
provides: [
|
|
86
|
+
provides: [Health] as const,
|
|
58
87
|
setup(ctx) {
|
|
59
|
-
ctx.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
88
|
+
ctx.handle(Health, (request) => ({
|
|
89
|
+
type: request.type,
|
|
90
|
+
instanceId: ctx.instanceId,
|
|
91
|
+
}));
|
|
64
92
|
},
|
|
65
93
|
});
|
|
66
94
|
|
|
67
|
-
startSharedWorkerApp({ id: "coordinator", plugins: [coordinator] });
|
|
95
|
+
startSharedWorkerApp({ id: "coordinator", plugins: [coordinator], expose: [Health] });
|
|
68
96
|
```
|
|
69
97
|
|
|
70
98
|
Window 侧只连接 Worker,不创建第二套 Worker 插件生命周期:
|
|
71
99
|
|
|
72
100
|
```ts
|
|
73
101
|
// Vite: this query emits a real, hashed JavaScript SharedWorker chunk.
|
|
74
|
-
// Do not pass the source `.ts` URL to connectSharedWorker in a production build.
|
|
75
102
|
import coordinatorWorkerUrl from "./coordinator.worker.ts?sharedworker&url";
|
|
76
103
|
import { connectSharedWorker } from "webloom-framework";
|
|
77
104
|
|
|
@@ -79,27 +106,27 @@ const runtime = connectSharedWorker({
|
|
|
79
106
|
id: "coordinator",
|
|
80
107
|
url: coordinatorWorkerUrl,
|
|
81
108
|
});
|
|
82
|
-
const service = runtime.capability(
|
|
109
|
+
const service = runtime.capability(Health);
|
|
83
110
|
await service.call({ type: "health" });
|
|
84
111
|
```
|
|
85
112
|
|
|
86
|
-
`connectSharedWorker()` 同步返回本地句柄;Worker 通过完整 `RuntimeSnapshot`
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
113
|
+
`connectSharedWorker()` 同步返回本地句柄;Worker 通过完整 `RuntimeSnapshot` 发布状态和
|
|
114
|
+
服务目录,代理的第一次 `call()` 在有限 deadline 内等待精确匹配。协议不兼容、断线、
|
|
115
|
+
超时和服务撤销都从调用 Promise 返回;框架不自动重连或重放调用。旧代理不会静默换绑
|
|
116
|
+
到新 Worker;Worker 重启后 `runtimeInstanceId`、服务的 `serviceInstanceId` 和运行单元
|
|
117
|
+
实例都会变化。
|
|
91
118
|
|
|
92
|
-
Vite 项目必须把 Worker 入口交给 Vite 的 Worker importer(例如
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
真实浏览器验收。
|
|
119
|
+
Vite 项目必须把 Worker 入口交给 Vite 的 Worker importer(例如 `?sharedworker&url`),
|
|
120
|
+
再把构建后导出的 URL 传给框架。框架内部的 `new SharedWorker(url, { type: "module" })`
|
|
121
|
+
只负责运行时连接,不能替调用方的 Bundler 发现源码 `.ts` 入口。其它 Bundler 应使用
|
|
122
|
+
等价的独立 SharedWorker Rollup entry。仓库的 `pnpm run test:browser` 会先执行生产构建,
|
|
123
|
+
再从 dist 启动真实浏览器验收。
|
|
98
124
|
|
|
99
|
-
|
|
100
|
-
`
|
|
101
|
-
`
|
|
102
|
-
|
|
125
|
+
页面要向 Worker 暴露反向能力时,先创建本地 `WindowApp`,再通过
|
|
126
|
+
`connectSharedWorker({ client: { app, expose } })` 绑定同一条私有端口。页面消费 Worker
|
|
127
|
+
capability 时使用 `runtime.capability(C)`;需要分阶段把远程依赖装入已有页面 Host,则从
|
|
128
|
+
`webloom-framework/advanced` 使用 `attachRemote()` 和 `registerPlugins()`。Worker 断线
|
|
129
|
+
会撤销旧代理;框架不会自动重连或重放调用。
|
|
103
130
|
|
|
104
131
|
## 公共字段中文语义
|
|
105
132
|
|
|
@@ -113,8 +140,8 @@ Host 会把相关单元置为 `blocked`;新的完整快照到达后按原启
|
|
|
113
140
|
| `serviceInstanceId` | 某个服务实例的不可复用身份;服务撤销或重建后必须变化。 |
|
|
114
141
|
| `revision` | 完整 RuntimeSnapshot 的单调修订号;只用于观察和目录收敛。 |
|
|
115
142
|
| `scopeId` | 本次生命周期 Scope 的唯一标识。 |
|
|
116
|
-
| `capability` |
|
|
117
|
-
| `contractVersion` | capability
|
|
143
|
+
| `capability` | 插件提供或依赖的 typed 服务契约。 |
|
|
144
|
+
| `contractVersion` | capability 的精确业务契约版本。 |
|
|
118
145
|
| `permission` | 字符串形式的权限动作;具体集合由宿主批准。 |
|
|
119
146
|
| `attributes` | 宿主绑定的只读扩展元数据,不包含私密材料。 |
|
|
120
147
|
| `desiredEnabled` | 用户或控制面希望产品启用的持久意图。 |
|
|
@@ -127,6 +154,7 @@ Host 会把相关单元置为 `blocked`;新的完整快照到达后按原启
|
|
|
127
154
|
pnpm install
|
|
128
155
|
pnpm lint:boundaries
|
|
129
156
|
pnpm typecheck
|
|
157
|
+
pnpm test:types
|
|
130
158
|
pnpm test
|
|
131
159
|
pnpm build
|
|
132
160
|
pnpm run pack:consumer
|
|
@@ -134,9 +162,9 @@ pnpm run pack:consumer
|
|
|
134
162
|
pnpm run test:browser
|
|
135
163
|
```
|
|
136
164
|
|
|
137
|
-
`pack:consumer` 会在不访问本仓库源码的临时项目中安装 tarball,分别执行
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
165
|
+
`pack:consumer` 会在不访问本仓库源码的临时项目中安装 tarball,分别执行 core-only、
|
|
166
|
+
advanced、React 和 Worker 消费者的 `tsc --noEmit` 与运行时 smoke,并检查发布文件白名单、
|
|
167
|
+
体积、`.d.ts` 和 `.js.map` 的本地路径及产品字段。版本、发布身份与许可证确认属于
|
|
168
|
+
发布责任人的操作,本仓库不自动执行发布。
|
|
141
169
|
|
|
142
170
|
详细 API 约束见 [`docs/api.md`](docs/api.md)。
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { R as RuntimeKind, C as CapabilityDescriptor, P as PluginManifest, a as PluginGraph, b as RuntimeUnitDependency, c as PluginReverseDep, d as RuntimeUnitDescriptor, L as LifecycleScopeIdentity, e as PluginPermission, f as LifecycleScope, g as PermissionLease, S as ScopedTaskScheduler, h as CreateUpgradeGateOptions, U as UpgradeGate, i as ServiceReference, j as CapabilityPeer, k as ResourceStoreApi$1, W as WindowApp, l as RuntimeHandle } from './runtimeTypes-DquUCHz-.js';
|
|
2
|
+
export { m as CapabilityRegistration, n as CapabilityRegistry, o as ContextExtensionInput, p as ContributionAdapter, q as ContributionAdapterInput, r as ContributionHandle, s as CreatePluginHostOptions, H as HostCapabilityRegistration, t as HostInspection, u as PermissionPolicyInput, v as PermissionPolicyResult, w as PluginConfigStore, x as PluginHost, 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, J as invokeCapabilityHandler } from './runtimeTypes-DquUCHz-.js';
|
|
3
|
+
import { R as RuntimeCallMessage, M as MessagePortLike, a as RuntimeTransport } from './messagePortServiceTransport-BYprNvQY.js';
|
|
4
|
+
export { C as CreateCapabilityBridgeOptions, b as CreatePluginIntentControllerOptions, c as RUNTIME_CALL_TYPE, d as RUNTIME_CANCEL_TYPE, e as RUNTIME_CREDIT_TYPE, f as RUNTIME_ERROR_MESSAGE_TYPE, g as RUNTIME_ERROR_TYPE, h as RUNTIME_NEXT_TYPE, i as RUNTIME_PROTOCOL_VERSION, j as RUNTIME_RESULT_TYPE, k as RUNTIME_SNAPSHOT_TYPE, l as RuntimeCancelMessage, m as RuntimeCreditMessage, n as RuntimeErrorMessage, o as RuntimeErrorResponseMessage, p as RuntimeMessageCodec, q as RuntimeNextMessage, r as RuntimeReceiveMetadata, s as RuntimeResultMessage, t as RuntimeSnapshotMessage, u as RuntimeSnapshotUnit, v as RuntimeStreamDoneMessage, w as RuntimeStreamReadyMessage, x as RuntimeUnaryResultMessage, y as RuntimeUnitImplementation, z as RuntimeWireMessage, A as createCapabilityBridge, B as createMessagePortRuntimeTransport, D as createPluginIntentController, E as createResourceRegistry, F as createRuntimeMessageCodec, G as createRuntimeUnitImplementationRegistry, H as isRuntimeSnapshot, I as registerOwnedResource, J as validateTransferables } from './messagePortServiceTransport-BYprNvQY.js';
|
|
5
|
+
import { R as ReceivePortLedger, a as RuntimeLimitsInput, b as RuntimeBudget, c as RuntimePluginDefinition } from './sharedWorkerHost-KI7TIGdX.js';
|
|
6
|
+
export { C as CreateResourceScopeOptions, P as PeerController, d as PeerExposureOptions, e as ResourceScopeOptions, S as SharedWorkerApp, f as StartSharedWorkerAppForTestingOptions, g as StartSharedWorkerAppOptions, h as bridgeForRuntimeHandle, i as createLifecycleScope, j as createResourceScope } from './sharedWorkerHost-KI7TIGdX.js';
|
|
7
|
+
export { c as createWindowAppFromHost, h as hostForWindowApp } from './windowRuntime-BKkLPsAS.js';
|
|
8
|
+
|
|
9
|
+
interface PluginGraphOptions {
|
|
10
|
+
/** 当前 Host 的 Runtime;未指定时只用于静态检查。 */
|
|
11
|
+
readonly runtime?: RuntimeKind;
|
|
12
|
+
/** 当前已经启用的插件,用于生成反向依赖状态。 */
|
|
13
|
+
readonly enabledPluginIds?: ReadonlySet<string>;
|
|
14
|
+
/** Host-owned 或远端已发布的 descriptor。 */
|
|
15
|
+
readonly builtinCapabilities?: ReadonlySet<CapabilityDescriptor | string>;
|
|
16
|
+
/** 是否允许尚未出现在本图中的跨 Runtime provider。 */
|
|
17
|
+
readonly externalRuntimeDependencies?: boolean;
|
|
18
|
+
/** registerAll 的调用阶段是否允许缺依赖。 */
|
|
19
|
+
readonly allowMissingDependencies?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** 选择一个插件在当前 Runtime 中的实现单元;多匹配必须显式消歧。 */
|
|
22
|
+
declare function selectRuntimeUnit(manifest: PluginManifest, runtime: RuntimeKind | undefined): (RuntimeUnitDescriptor & {
|
|
23
|
+
id: string;
|
|
24
|
+
runtime: RuntimeKind;
|
|
25
|
+
}) | undefined;
|
|
26
|
+
declare function dependenciesOfManifest(manifest: PluginManifest, runtime?: RuntimeKind): readonly RuntimeUnitDependency[];
|
|
27
|
+
declare function providesOfManifest(manifest: PluginManifest, runtime?: RuntimeKind): readonly CapabilityDescriptor[];
|
|
28
|
+
/** 构建不可变图快照;结果顺序始终由 manifest 输入顺序和 descriptor 顺序决定。 */
|
|
29
|
+
declare function buildPluginGraph(manifests: readonly PluginManifest[], options?: PluginGraphOptions): PluginGraph;
|
|
30
|
+
/** 在注册/批量装配前验证 manifest 及其依赖闭包。 */
|
|
31
|
+
declare function validatePluginGraph(manifests: readonly PluginManifest[], options?: PluginGraphOptions): void;
|
|
32
|
+
/** 查询依赖某 provider 的已启用插件。 */
|
|
33
|
+
declare function reverseDependentsOf(graph: PluginGraph, pluginId: string, enabledPluginIds?: ReadonlySet<string>): readonly PluginReverseDep[];
|
|
34
|
+
|
|
35
|
+
interface CreatePermissionLeaseOptions {
|
|
36
|
+
/** 已由 Host 绑定的作用域身份;调用方不能从请求体自报。 */
|
|
37
|
+
identity: LifecycleScopeIdentity;
|
|
38
|
+
/** 插件 manifest 申请的权限。 */
|
|
39
|
+
requested?: readonly PluginPermission[];
|
|
40
|
+
/** 可信策略批准的权限。 */
|
|
41
|
+
approved?: readonly PluginPermission[];
|
|
42
|
+
/** 当前会话约束;存在时再与申请、批准求交集。 */
|
|
43
|
+
sessionConstraints?: readonly PluginPermission[];
|
|
44
|
+
/** 内置可信策略修订;策略变化后不能复用旧租约。 */
|
|
45
|
+
policyRevision?: number;
|
|
46
|
+
/** Connect 用户授权修订;内置插件可以省略。 */
|
|
47
|
+
grantRevision?: number;
|
|
48
|
+
/** Connect/外部授权的不可猜测授权标识;最终边界仍需查权威状态。 */
|
|
49
|
+
grantId?: string;
|
|
50
|
+
/** 可选作用域;撤权时自动撤销租约。 */
|
|
51
|
+
scope?: LifecycleScope;
|
|
52
|
+
}
|
|
53
|
+
/** 创建一个不可换绑的权限租约。 */
|
|
54
|
+
declare function createPermissionLease(options: CreatePermissionLeaseOptions): PermissionLease;
|
|
55
|
+
|
|
56
|
+
interface VerifyPermissionLeaseOptions {
|
|
57
|
+
/** 已由受信装配层创建的租约。 */
|
|
58
|
+
lease: PermissionLease;
|
|
59
|
+
/** 本次实际操作所需的最小权限。 */
|
|
60
|
+
permission: PluginPermission;
|
|
61
|
+
/** 从端口 / 当前会话权威取得的绑定值。 */
|
|
62
|
+
binding?: Parameters<PermissionLease["assertBinding"]>[0];
|
|
63
|
+
}
|
|
64
|
+
/** 在最终 RPC / I/O 边界执行一次 fail-closed 校验。 */
|
|
65
|
+
declare function verifyPermissionLease(options: VerifyPermissionLeaseOptions): void;
|
|
66
|
+
|
|
67
|
+
interface CreateScopedTaskSchedulerOptions {
|
|
68
|
+
/** 注册后是否先恢复运行一次;缺省为 false,由业务显式触发。 */
|
|
69
|
+
runOnRegister?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/** 创建绑定到一个 lifecycle scope 的任务调度器。 */
|
|
72
|
+
declare function createScopedTaskScheduler(scope: LifecycleScope, options?: CreateScopedTaskSchedulerOptions): ScopedTaskScheduler & {
|
|
73
|
+
dispose(): Promise<void>;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
interface ScopedRegistryRegistration {
|
|
77
|
+
/** 注册方法名,例如 register / registerFeature。 */
|
|
78
|
+
method: string;
|
|
79
|
+
/** 从参数哪个位置读取带 id 的定义。 */
|
|
80
|
+
idArgument?: number;
|
|
81
|
+
/** 没有返回取消函数时使用的注销方法。 */
|
|
82
|
+
unregisterMethod?: string;
|
|
83
|
+
/** 注销方法的参数位置;默认使用 idArgument。 */
|
|
84
|
+
unregisterArgument?: number;
|
|
85
|
+
/** 含 ownerPluginId 参数的注册方法;由 Host 绑定当前插件身份。 */
|
|
86
|
+
bindPluginIdArgument?: number;
|
|
87
|
+
/** 定义对象中的 ownerPluginId 字段;存在时必须与当前插件一致。 */
|
|
88
|
+
ownerPluginIdProperty?: string;
|
|
89
|
+
}
|
|
90
|
+
interface CreateScopedRegistryFacadeOptions {
|
|
91
|
+
/** 日志和作用域资源中显示的注册表名。 */
|
|
92
|
+
name: string;
|
|
93
|
+
/** 注册方法规则;缺省只包装 register(item)。 */
|
|
94
|
+
registrations?: readonly ScopedRegistryRegistration[];
|
|
95
|
+
}
|
|
96
|
+
/** 创建一个只对当前插件实例开放的 Registry 视图。 */
|
|
97
|
+
declare function createScopedRegistryFacade<T extends object>(target: T, scope: LifecycleScope, options: CreateScopedRegistryFacadeOptions): T;
|
|
98
|
+
|
|
99
|
+
/** 创建一个绑定当前构建和接管世代的升级门禁。 */
|
|
100
|
+
declare function createUpgradeGate(options: CreateUpgradeGateOptions): UpgradeGate;
|
|
101
|
+
|
|
102
|
+
interface MessagePortServiceCallInput {
|
|
103
|
+
/** 已验证的 call message;request 已由生产 parser 规范化。 */
|
|
104
|
+
readonly message: RuntimeCallMessage;
|
|
105
|
+
/** parser 规范化后的请求。 */
|
|
106
|
+
readonly request: unknown;
|
|
107
|
+
/** 服务绑定身份。 */
|
|
108
|
+
readonly reference: ServiceReference;
|
|
109
|
+
/** 取消信号。 */
|
|
110
|
+
readonly signal: AbortSignal;
|
|
111
|
+
/** 本端以接收时钟计算的调用截止时间。 */
|
|
112
|
+
readonly deadlineAt: number;
|
|
113
|
+
/** 对端 peer 视图。 */
|
|
114
|
+
readonly peer?: CapabilityPeer;
|
|
115
|
+
}
|
|
116
|
+
interface PreparedRequest {
|
|
117
|
+
/** parser 规范化后的 DTO。 */
|
|
118
|
+
readonly value: unknown;
|
|
119
|
+
/** 契约声明的 transfer。 */
|
|
120
|
+
readonly transfer?: readonly Transferable[];
|
|
121
|
+
/** 可选的已计算计费值。 */
|
|
122
|
+
readonly budgetBytes?: number;
|
|
123
|
+
}
|
|
124
|
+
interface MessagePortServiceProviderOptions {
|
|
125
|
+
/** 兼容 standalone/testing 的当前 MessagePort;实际 Runtime 使用 shared transport。 */
|
|
126
|
+
readonly port?: MessagePortLike;
|
|
127
|
+
/** 当前物理 endpoint 的唯一 v4 transport。 */
|
|
128
|
+
readonly transport?: RuntimeTransport;
|
|
129
|
+
/** 当前可暴露的服务;返回空集合即拒绝新的调用。 */
|
|
130
|
+
readonly services: () => readonly ServiceReference[];
|
|
131
|
+
/** 调用 Host handler。 */
|
|
132
|
+
readonly handleCall: (input: MessagePortServiceCallInput) => unknown | Promise<unknown | AsyncIterable<unknown>>;
|
|
133
|
+
/** 当前 peer scope。 */
|
|
134
|
+
readonly peerScope?: LifecycleScope;
|
|
135
|
+
/** 默认 peer view;peerForCall 可按 handler 依赖进一步收窄。 */
|
|
136
|
+
readonly peer?: CapabilityPeer;
|
|
137
|
+
/** 当前 handler 所属插件允许观察的 peer view。 */
|
|
138
|
+
readonly peerForCall?: (call: RuntimeCallMessage, reference: ServiceReference) => CapabilityPeer | undefined;
|
|
139
|
+
/** 接收 request 的 parser/transfer 适配。 */
|
|
140
|
+
readonly prepareRequest?: (call: RuntimeCallMessage, ledger: ReceivePortLedger) => PreparedRequest;
|
|
141
|
+
/** 发送前验证/提取 unary response。 */
|
|
142
|
+
readonly prepareResult?: (value: unknown, call: RuntimeCallMessage) => PreparedRequest;
|
|
143
|
+
/** 发送前验证/提取 stream item。 */
|
|
144
|
+
readonly prepareItem?: (value: unknown, call: RuntimeCallMessage) => PreparedRequest;
|
|
145
|
+
/** 可信 Runtime/advanced 装配预算。 */
|
|
146
|
+
readonly limits?: RuntimeLimitsInput;
|
|
147
|
+
/** 可选的 Runtime 方向共享计数器。 */
|
|
148
|
+
readonly budget?: RuntimeBudget;
|
|
149
|
+
}
|
|
150
|
+
/** 创建一个严格 bounded 的 MessagePort provider。 */
|
|
151
|
+
declare function createMessagePortServiceProvider(options: MessagePortServiceProviderOptions): {
|
|
152
|
+
setServices(): void;
|
|
153
|
+
dispose(): void;
|
|
154
|
+
pendingCount(): number;
|
|
155
|
+
executionCount(): number;
|
|
156
|
+
nonCooperativeExecutionCount(): number;
|
|
157
|
+
retainedPayloadBytes(): number;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/** Resource Store 的 advanced 类型出口;显式 alias 可被 dts bundler 保留。 */
|
|
161
|
+
type ResourceStoreApi = ResourceStoreApi$1;
|
|
162
|
+
|
|
163
|
+
/** 分阶段向已经拥有的 App 注册新的 typed plugin definitions。 */
|
|
164
|
+
declare function registerPlugins(app: WindowApp, definitions: readonly RuntimePluginDefinition[]): Promise<void>;
|
|
165
|
+
/** 把一个连接绑定到现有 WindowApp;替换时先撤销旧 bridge。 */
|
|
166
|
+
declare function attachRemote(app: WindowApp, runtime: RuntimeHandle): Promise<() => void>;
|
|
167
|
+
|
|
168
|
+
export { type CreatePermissionLeaseOptions, type CreateScopedRegistryFacadeOptions, type CreateScopedTaskSchedulerOptions, MessagePortLike, type MessagePortServiceCallInput, type MessagePortServiceProviderOptions, type PluginGraphOptions, type PreparedRequest, type ResourceStoreApi, RuntimeCallMessage, RuntimeTransport, type ScopedRegistryRegistration, type VerifyPermissionLeaseOptions, attachRemote, buildPluginGraph, createMessagePortServiceProvider, createPermissionLease, createScopedRegistryFacade, createScopedTaskScheduler, createUpgradeGate, dependenciesOfManifest, providesOfManifest, registerPlugins, reverseDependentsOf, selectRuntimeUnit, validatePluginGraph, verifyPermissionLease };
|