@binblink/wasmnest-plugin-sdk-mobile 0.0.0-stage → 0.0.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 +363 -2
- package/README_en.md +353 -0
- package/bin/build.js +269 -0
- package/bin/cli.js +96 -0
- package/bin/lib.js +349 -0
- package/bin/manifest-gen.js +324 -0
- package/bin/package.js +150 -0
- package/bin/scaffold.js +285 -0
- package/dev-shell/README.md +151 -0
- package/dev-shell/index.html +27 -0
- package/dev-shell/package.json +27 -0
- package/dev-shell/pnpm-workspace.yaml +9 -0
- package/dev-shell/postcss.config.js +6 -0
- package/dev-shell/src/App.vue +90 -0
- package/dev-shell/src/apps/mock-terminal/MockTerminalSlotCard.vue +51 -0
- package/dev-shell/src/apps/mock-terminal/MockTerminalView.vue +168 -0
- package/dev-shell/src/apps/mock-terminal/index.ts +50 -0
- package/dev-shell/src/components/DevToolbar.vue +100 -0
- package/dev-shell/src/components/DialogHost.vue +119 -0
- package/dev-shell/src/components/LogPanel.vue +80 -0
- package/dev-shell/src/i18n.ts +22 -0
- package/dev-shell/src/loader.ts +239 -0
- package/dev-shell/src/locale.ts +29 -0
- package/dev-shell/src/locales/en-shell.ts +328 -0
- package/dev-shell/src/locales/index.ts +70 -0
- package/dev-shell/src/locales/shell.ts +328 -0
- package/dev-shell/src/main.ts +58 -0
- package/dev-shell/src/mock/dialog-service.ts +58 -0
- package/dev-shell/src/mock/file-transfer.ts +390 -0
- package/dev-shell/src/mock/mobile-api.ts +369 -0
- package/dev-shell/src/mock/preset-tasks.ts +186 -0
- package/dev-shell/src/mock/session.ts +121 -0
- package/dev-shell/src/mock-context.ts +351 -0
- package/dev-shell/src/registry.ts +151 -0
- package/dev-shell/src/shared-runtime.ts +44 -0
- package/dev-shell/src/shell/ShellView.vue +52 -0
- package/dev-shell/src/shell/adapters/devAppSource.ts +155 -0
- package/dev-shell/src/shell/components/PluginContextHost.vue +40 -0
- package/dev-shell/src/shell/components/ShellAppCell.vue +75 -0
- package/dev-shell/src/shell/components/ShellAppIcon.vue +111 -0
- package/dev-shell/src/shell/components/ShellAppSurface.vue +46 -0
- package/dev-shell/src/shell/components/ShellBrandTile.vue +27 -0
- package/dev-shell/src/shell/components/ShellCapsuleMenu.vue +123 -0
- package/dev-shell/src/shell/components/ShellChip.vue +49 -0
- package/dev-shell/src/shell/components/ShellGroupCard.vue +17 -0
- package/dev-shell/src/shell/components/ShellHost.vue +75 -0
- package/dev-shell/src/shell/components/ShellNotificationShade.vue +496 -0
- package/dev-shell/src/shell/components/ShellPermissionPrompt.vue +127 -0
- package/dev-shell/src/shell/components/ShellPlaceholderSurface.vue +33 -0
- package/dev-shell/src/shell/components/ShellSection.vue +27 -0
- package/dev-shell/src/shell/components/ShellSheet.vue +74 -0
- package/dev-shell/src/shell/components/ShellStatusbar.vue +84 -0
- package/dev-shell/src/shell/components/screens/PluginRoutePage.vue +98 -0
- package/dev-shell/src/shell/components/screens/ShellAppDetailScreen.vue +378 -0
- package/dev-shell/src/shell/components/screens/ShellAppRunScreen.vue +90 -0
- package/dev-shell/src/shell/components/screens/ShellAppsScreen.vue +195 -0
- package/dev-shell/src/shell/components/screens/ShellHomeScreen.vue +316 -0
- package/dev-shell/src/shell/components/screens/ShellPermissionsScreen.vue +376 -0
- package/dev-shell/src/shell/components/screens/ShellSettingsScreen.vue +240 -0
- package/dev-shell/src/shell/components/screens/ShellSwitcherScreen.vue +559 -0
- package/dev-shell/src/shell/components/ui/ConfirmDialog.vue +137 -0
- package/dev-shell/src/shell/components/ui/Toggle.vue +53 -0
- package/dev-shell/src/shell/composables/useShellApps.ts +415 -0
- package/dev-shell/src/shell/composables/useShellNavigation.ts +197 -0
- package/dev-shell/src/shell/composables/useShellNotifications.ts +115 -0
- package/dev-shell/src/shell/composables/useShellOpen.ts +35 -0
- package/dev-shell/src/shell/composables/useShellOverlays.ts +101 -0
- package/dev-shell/src/shell/composables/useShellPreferences.ts +143 -0
- package/dev-shell/src/shell/composables/useShellRecent.ts +84 -0
- package/dev-shell/src/shell/composables/useToast.ts +33 -0
- package/dev-shell/src/shell/index.ts +88 -0
- package/dev-shell/src/shell/logger.ts +45 -0
- package/dev-shell/src/shell/permissions.ts +145 -0
- package/dev-shell/src/shell/registry.ts +220 -0
- package/dev-shell/src/shell/styles/shell.css +841 -0
- package/dev-shell/src/shell/types.ts +137 -0
- package/dev-shell/src/shell/utils.ts +54 -0
- package/dev-shell/src/styles/main.css +153 -0
- package/dev-shell/src/styles/mobile.css +884 -0
- package/dev-shell/src/styles/wallpaper.css +130 -0
- package/dev-shell/src/theme.ts +71 -0
- package/dev-shell/src/vite-env.d.ts +20 -0
- package/dev-shell/tailwind.config.js +101 -0
- package/dev-shell/tsconfig.json +16 -0
- package/dev-shell/vite.config.ts +130 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.js +161 -0
- package/dist/types.d.ts +637 -0
- package/dist/types.js +0 -0
- package/dist/vite-plugin.d.ts +16 -0
- package/dist/vite-plugin.js +95 -0
- package/package.json +80 -3
- package/src/constants.ts +6 -0
- package/src/global-dialog.ts +168 -0
- package/src/index.ts +87 -0
- package/src/runtime.ts +44 -0
- package/src/types.ts +715 -0
- package/src/ui/PluginGlobalDialog.vue +388 -0
- package/src/ui/Select.d.ts +37 -0
- package/src/ui/Select.vue +307 -0
- package/src/ui/plugin-global-dialog.d.ts +11 -0
- package/src/ui/useSwipeTabs.d.ts +20 -0
- package/src/ui/useSwipeTabs.ts +53 -0
- package/src/vite-plugin.ts +132 -0
- package/template/.gitignore +4 -0
- package/template/README.md +46 -0
- package/template/package.json +23 -0
- package/template/plugin.json +13 -0
- package/template/rust/Cargo.toml +19 -0
- package/template/rust/src/lib.rs +33 -0
- package/template/src/env.d.ts +24 -0
- package/template/src/index.ts +37 -0
- package/template/tsconfig.json +17 -0
- package/template/vite.config.ts +21 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,715 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @binblink/wasmnest-plugin-sdk-mobile 类型定义
|
|
3
|
+
*
|
|
4
|
+
* 移动端插件开发者可用的所有公开类型
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// ==================== 基础类型 ====================
|
|
8
|
+
|
|
9
|
+
/** Disposable 接口 */
|
|
10
|
+
export interface Disposable {
|
|
11
|
+
dispose(): void
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** 插件类型 */
|
|
15
|
+
export type PluginType = 'rust' | 'rust-ts' | 'ts-only' | 'wasm'
|
|
16
|
+
|
|
17
|
+
/** 插件运行时状态
|
|
18
|
+
*
|
|
19
|
+
* 取值口径(2026-10-14 对齐):真源 = 共享 crate `wasmnest-wasm-core/src/manifest.rs` 的
|
|
20
|
+
* `PluginState`,其 serde 属性为 `#[serde(tag = "state", rename_all = "camelCase")]`——
|
|
21
|
+
* 线上 JSON 是 **camelCase**(`{state:'activated'}` / `{state:'needsApproval'}` …)。
|
|
22
|
+
* 旧声明写成 PascalCase(`'Activated'`),与后端序列化不一致:宿主前端按 PascalCase 分支
|
|
23
|
+
* 判断时永远命中不了,表现为「应用明明在跑,壳里显示 0 个运行中 / 未启动」。
|
|
24
|
+
* 改动词表时先改共享 crate,再同步本类型与两端消费者。 */
|
|
25
|
+
export type PluginState =
|
|
26
|
+
| { state: 'loaded' }
|
|
27
|
+
| { state: 'activating' }
|
|
28
|
+
| { state: 'activated' }
|
|
29
|
+
| { state: 'degraded'; error: string }
|
|
30
|
+
| { state: 'needsApproval' }
|
|
31
|
+
| { state: 'deactivated' }
|
|
32
|
+
| { state: 'error'; error: string }
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 适配平台(manifest `platform` 字段,必填)
|
|
36
|
+
*
|
|
37
|
+
* 三值:`desktop`(仅桌面)/ `mobile`(仅移动)/ `both`(双端适配)。
|
|
38
|
+
* 宿主在加载 / zip 安装期按本端校验:桌面拒 `mobile`、移动拒 `desktop`,
|
|
39
|
+
* `both` 两端均可装载(真源 SDK `rust/src/types.rs::PluginPlatform`)。
|
|
40
|
+
*/
|
|
41
|
+
export type PluginPlatform = 'desktop' | 'mobile' | 'both'
|
|
42
|
+
|
|
43
|
+
/** 插件描述文件结构 */
|
|
44
|
+
export interface PluginManifest {
|
|
45
|
+
id: string
|
|
46
|
+
name: string
|
|
47
|
+
version: string
|
|
48
|
+
/**
|
|
49
|
+
* 适配平台:`desktop`(仅桌面)/ `mobile`(仅移动)/ `both`(双端适配)。
|
|
50
|
+
*
|
|
51
|
+
* **必填**(与 id/name/version 同档):宿主加载 / 安装时校验声明必须覆盖
|
|
52
|
+
* 当前端,不匹配即 fail-visible 拒绝装载。
|
|
53
|
+
*/
|
|
54
|
+
platform: PluginPlatform
|
|
55
|
+
description: string
|
|
56
|
+
author: string
|
|
57
|
+
main: string
|
|
58
|
+
pluginType: PluginType
|
|
59
|
+
permissions: string[]
|
|
60
|
+
contributes: MobilePluginContributes
|
|
61
|
+
/** 插件图标:emoji、内联 <svg> 标记或相对插件目录的图片路径,缺省时前端生成字母头像回退 */
|
|
62
|
+
icon?: string
|
|
63
|
+
wasmHash?: string
|
|
64
|
+
rustLibrary?: string
|
|
65
|
+
/** 启用前预授权目录(宿主 preauthorize 统一弹窗,支持 ${downloads} 模板) */
|
|
66
|
+
preauthDirs?: string[]
|
|
67
|
+
/** 外网访问预授权 URL 声明(Egress L2 glob:`[scheme://][*.]host[:port][/path-prefix]`) */
|
|
68
|
+
preauthUrls?: string[]
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** 移动端扩展点声明 */
|
|
72
|
+
export interface MobilePluginContributes {
|
|
73
|
+
commands: CommandContribution[]
|
|
74
|
+
views: ViewContribution[]
|
|
75
|
+
terminal?: TerminalContribution
|
|
76
|
+
navTab?: NavTabContribution
|
|
77
|
+
settings?: SettingsContribution
|
|
78
|
+
/** 动态路由扩展点(activate 时经 ui.registerRoute 注册,宿主 addRoute) */
|
|
79
|
+
routes?: RouteContribution[]
|
|
80
|
+
configuration?: PluginConfiguration
|
|
81
|
+
lifecycle?: LifecycleContribution
|
|
82
|
+
/** 自定义监控面板声明(monitor 统一壳消费;实现住提供方应用工程) */
|
|
83
|
+
monitorPanels?: MonitorPanelContribution[]
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** 自定义监控面板声明(只登记元数据) */
|
|
87
|
+
export interface MonitorPanelContribution {
|
|
88
|
+
id: string
|
|
89
|
+
title: string
|
|
90
|
+
/** 排序权重(小者靠前;缺省 100) */
|
|
91
|
+
order?: number
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** 命令扩展点 */
|
|
95
|
+
export interface CommandContribution {
|
|
96
|
+
id: string
|
|
97
|
+
title: string
|
|
98
|
+
icon?: string
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** 视图扩展点 */
|
|
102
|
+
export interface ViewContribution {
|
|
103
|
+
id: string
|
|
104
|
+
type: 'toolbox'
|
|
105
|
+
title: string
|
|
106
|
+
component: string
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** 底部导航 Tab 扩展点 */
|
|
110
|
+
export interface NavTabContribution {
|
|
111
|
+
id: string
|
|
112
|
+
title: string
|
|
113
|
+
icon: string
|
|
114
|
+
component: string
|
|
115
|
+
order?: number
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** 设置页扩展点 */
|
|
119
|
+
export interface SettingsContribution {
|
|
120
|
+
section: string
|
|
121
|
+
component: string
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** 路由扩展点声明(manifest 声明,宿主按 id 命名空间挂载动态路由) */
|
|
125
|
+
export interface RouteContribution {
|
|
126
|
+
id: string
|
|
127
|
+
title?: string
|
|
128
|
+
component: string
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** 终端扩展点(inputHandlers/outputParsers 已随票 15 阶段 B 退役——terminal-hooks 删面) */
|
|
132
|
+
export interface TerminalContribution {
|
|
133
|
+
toolbarItems: TerminalToolbarItemContribution[]
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** 终端工具栏按钮 */
|
|
137
|
+
export interface TerminalToolbarItemContribution {
|
|
138
|
+
id: string
|
|
139
|
+
title: string
|
|
140
|
+
icon: string
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** 插件配置声明 */
|
|
144
|
+
export interface PluginConfiguration {
|
|
145
|
+
title: string
|
|
146
|
+
properties: Record<string, ConfigProperty>
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** 配置属性 */
|
|
150
|
+
export interface ConfigProperty {
|
|
151
|
+
type: 'string' | 'number' | 'boolean'
|
|
152
|
+
title: string
|
|
153
|
+
description?: string
|
|
154
|
+
default?: any
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** 生命周期声明(onTerminalInput/onTerminalOutput 已随票 15 阶段 B 退役) */
|
|
158
|
+
export interface LifecycleContribution {
|
|
159
|
+
onStartup?: boolean
|
|
160
|
+
onShutdown?: boolean
|
|
161
|
+
onAuthSuccess?: boolean
|
|
162
|
+
onDisconnect?: boolean
|
|
163
|
+
onSessionCreated?: boolean
|
|
164
|
+
onSessionStopped?: boolean
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// ==================== UI 描述符 ====================
|
|
168
|
+
//
|
|
169
|
+
// 票 2026-10-10 批次 C2:`ToolboxPageDescriptor` / `TerminalViewContribution` /
|
|
170
|
+
// `NavTabDescriptor` / `TerminalToolbarItemDescriptor` 及其对应注册方法已整面退役
|
|
171
|
+
// (宿主壳只认 `registerSurface` 一种运行面形态)。保留位仅供旧版本插件对照报错。
|
|
172
|
+
|
|
173
|
+
/** 插件路由描述符:整体路由由插件决定(openPage 跳转);id 即路径段,可含 '/' 支持深路径 */
|
|
174
|
+
export interface PluginRouteDescriptor {
|
|
175
|
+
/** 路由 id(路径段),宿主挂到 /mobile/plugins/{pluginId}/{id} */
|
|
176
|
+
id: string
|
|
177
|
+
/** 宿主页头标题(header 为真时展示) */
|
|
178
|
+
title?: string
|
|
179
|
+
component: any
|
|
180
|
+
/** 是否渲染宿主页头(back + title),默认 true;false 时插件自带布局 */
|
|
181
|
+
header?: boolean
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// ==================== 宿主壳(Host Shell)贡献描述符 ====================
|
|
185
|
+
// 契约形状与宿主 `src/shell/types.ts` 逐字段一致(插件侧不 import 宿主代码,
|
|
186
|
+
// 数据经宿主壳 registry 双写投影)。appId 一律 = 插件 id,由宿主 context 代填。
|
|
187
|
+
|
|
188
|
+
/** 宿主壳运行面:应用在壳(/mobile/shell)内被打开时挂载的整页界面 */
|
|
189
|
+
export interface ShellSurfaceContribution {
|
|
190
|
+
/** 运行面组件;壳透传 { app } prop(应用元数据,可忽略) */
|
|
191
|
+
component: any
|
|
192
|
+
/** 应用自带主题色(仅作用于应用内部,绝不写回平台 token) */
|
|
193
|
+
accent?: string
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** 宿主壳首页快捷卡片(应用自持内容,如「N 个活跃会话」) */
|
|
197
|
+
export interface ShellSlotContribution {
|
|
198
|
+
id: string
|
|
199
|
+
/** 卡片组件;壳透传 { app } prop */
|
|
200
|
+
component: any
|
|
201
|
+
/** 排序权重,小者靠前;缺省 100 */
|
|
202
|
+
order?: number
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** 宿主壳胶囊菜单附加项(平台项 order:权限 10 / 停用 30,应用用中间值插入) */
|
|
206
|
+
export interface ShellCapsuleItem {
|
|
207
|
+
id: string
|
|
208
|
+
label: string
|
|
209
|
+
/** SVG path d(24×24 视框,stroke 风格);缺省用平台通用图标 */
|
|
210
|
+
icon?: string
|
|
211
|
+
order?: number
|
|
212
|
+
onSelect?: (appId: string) => void | Promise<void>
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** 日志 API */
|
|
216
|
+
export interface LoggerAPI {
|
|
217
|
+
info(message: string): void
|
|
218
|
+
debug(message: string): void
|
|
219
|
+
warn(message: string): void
|
|
220
|
+
error(message: string): void
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// ==================== 移动端宿主能力 ====================
|
|
224
|
+
|
|
225
|
+
/** 连接引擎状态(与宿主 useMobileConnection ConnectionStatus 一一对应) */
|
|
226
|
+
export type MobileConnectionStatus =
|
|
227
|
+
| 'disconnected'
|
|
228
|
+
| 'connecting'
|
|
229
|
+
| 'connected'
|
|
230
|
+
| 'pairing'
|
|
231
|
+
| 'paired'
|
|
232
|
+
| 'error'
|
|
233
|
+
|
|
234
|
+
/** 连接目标设备(最小形状;mobileApi.connectDevice 入参) */
|
|
235
|
+
export interface MobileDeviceTarget {
|
|
236
|
+
address: string
|
|
237
|
+
port: number
|
|
238
|
+
name?: string
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** 连接历史条目(宿主连接域引擎事实) */
|
|
242
|
+
export interface MobileConnectionHistoryItem {
|
|
243
|
+
address: string
|
|
244
|
+
name: string
|
|
245
|
+
/** ISO 时间字符串 */
|
|
246
|
+
lastConnected?: string
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** 连接生命周期事件(引擎事实面,与宿主 ws_reconnecting 等逐一对应) */
|
|
250
|
+
export type MobileHostConnectionEvent =
|
|
251
|
+
| { type: 'reconnecting'; retry: number; maxRetry: number }
|
|
252
|
+
| { type: 'reconnected' }
|
|
253
|
+
| { type: 'unexpected_disconnect' }
|
|
254
|
+
| { type: 'reauth_rejected'; reason: string }
|
|
255
|
+
| { type: 'reconnect_failed'; reason: string }
|
|
256
|
+
| { type: 'event_channel_ready' }
|
|
257
|
+
|
|
258
|
+
/** mDNS 发现到的服务(与宿主 useMdnsDiscovery DiscoveredService 同形状) */
|
|
259
|
+
export interface MobileMdnsService {
|
|
260
|
+
instance_name: string
|
|
261
|
+
host_name: string
|
|
262
|
+
address: string
|
|
263
|
+
port: number
|
|
264
|
+
txt_records: Record<string, string>
|
|
265
|
+
platform: string
|
|
266
|
+
device_name: string
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** 生物凭证状态(与宿主 useMobileCommands BiometricKeyStatus 同形状) */
|
|
270
|
+
export interface MobileBiometricKeyStatus {
|
|
271
|
+
deviceSupported: boolean
|
|
272
|
+
deviceReason: number
|
|
273
|
+
hasKey: boolean
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** HTTP API 结果(与宿主 useHttpApi 同构) */
|
|
277
|
+
export interface MobileHttpResult<T = any> {
|
|
278
|
+
code: number
|
|
279
|
+
message: string
|
|
280
|
+
data?: T
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** 通用对端 REST 请求选项(宿主注入 JWT / 链路加密 / 错误归一化) */
|
|
284
|
+
export interface MobileHttpRequestOptions {
|
|
285
|
+
method?: string
|
|
286
|
+
body?: any
|
|
287
|
+
headers?: Record<string, string>
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** 终端输出流句柄(openTerminalStream 返回;dispose = 注销页面通道) */
|
|
291
|
+
export interface TerminalStreamHandle {
|
|
292
|
+
dispose(): void
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** 宿主会话/连接生命周期事件(onSessionEvent 投递;宿主白名单封装,插件不裸听 Tauri 事件名) */
|
|
296
|
+
export interface MobileHostSessionEvent {
|
|
297
|
+
/** disconnected:连接断开(含意外断开);session_status:会话状态变化;session_stopped:会话停止;session_removed:会话移除 */
|
|
298
|
+
type: 'disconnected' | 'session_status' | 'session_stopped' | 'session_removed'
|
|
299
|
+
/** 会话相关事件携带的会话 id(disconnected 无) */
|
|
300
|
+
sessionId?: string
|
|
301
|
+
/** session_status 的新状态(如 'running') */
|
|
302
|
+
newStatus?: string
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** 移动端宿主连接/HTTP 能力(共享运行时 mobileApi 模块)
|
|
306
|
+
*
|
|
307
|
+
* 通用能力层:连接状态 + 对端桌面端 REST 请求通道 + 终端流/主题/本地设置只读投影
|
|
308
|
+
* (票 15 扩展:openTerminalStream / isDark / mobileSettings / onSessionEvent / mockSessionId)。
|
|
309
|
+
* 具体插件业务端点(任务队列 / 会话模式 / 任务历史 / 定时任务等)
|
|
310
|
+
* 由各插件基于 httpRequest 自行封装,SDK 不感知插件领域细节。
|
|
311
|
+
*/
|
|
312
|
+
export interface MobileHostApi {
|
|
313
|
+
/** 当前活动会话 id(响应式 ref,可 watch / computed) */
|
|
314
|
+
activeSessionId: import('vue').Ref<string | null>
|
|
315
|
+
/** 活跃会话列表(响应式 ref) */
|
|
316
|
+
activeSessions: import('vue').Ref<any[]>
|
|
317
|
+
/** 会话配置列表(响应式 ref) */
|
|
318
|
+
sessionConfigs: import('vue').Ref<any[]>
|
|
319
|
+
/** 是否已连接对端桌面端(响应式 ref,可 watch / computed)
|
|
320
|
+
*
|
|
321
|
+
* 注意语义边界:**只表示传输层已连**(connected/pairing/paired)。未认证的连接不能
|
|
322
|
+
* 访问需要 JWT 的端点(会话 / 任务等),凡是要发受保护请求前先判 {@link isPaired}。 */
|
|
323
|
+
isConnected: import('vue').Ref<boolean>
|
|
324
|
+
/** 是否已完成对端认证(paired,即持有可用的 JWT;响应式 ref)
|
|
325
|
+
*
|
|
326
|
+
* 与 `isConnected` 的区别:连上传输层 ≠ 已认证。用宿主持有的凭据静默换新 JWT 后、
|
|
327
|
+
* 或配对 / QR / 生物认证成功后置 true。 */
|
|
328
|
+
isPaired: import('vue').Ref<boolean>
|
|
329
|
+
/** 通用对端 REST 请求;返回 { code, message, data } 形状 */
|
|
330
|
+
httpRequest<T = any>(path: string, options?: MobileHttpRequestOptions): Promise<MobileHttpResult<T>>
|
|
331
|
+
/** 拉取/刷新活跃会话列表(宿主连接域机制;结果写入 activeSessions ref) */
|
|
332
|
+
loadActiveSessions(): Promise<void>
|
|
333
|
+
/** 拉取/刷新会话配置列表(结果写入 sessionConfigs ref) */
|
|
334
|
+
loadSessionConfigs(): Promise<void>
|
|
335
|
+
/** 会话配置是否已加载过(宿主连接域状态投影) */
|
|
336
|
+
hasLoadedConfigs: import('vue').Ref<boolean>
|
|
337
|
+
/** 会话配置是否加载中(宿主连接域状态投影) */
|
|
338
|
+
isLoadingConfigs: import('vue').Ref<boolean>
|
|
339
|
+
/** 打开终端输出字节流:宿主创建页面 Channel 并登记(terminal_page_subscribe),输出按序裸字节回调;
|
|
340
|
+
* 返回句柄,dispose 注销(terminal_page_unsubscribe)。链路订阅由插件命令面负责,本通道只承载页面接收 */
|
|
341
|
+
openTerminalStream(sessionId: string, onBytes: (bytes: Uint8Array) => void): Promise<TerminalStreamHandle>
|
|
342
|
+
/** 当前 App 是否深色(响应式 ref;终端主题解析依据) */
|
|
343
|
+
isDark: import('vue').Ref<boolean>
|
|
344
|
+
/** 移动端本地设置只读投影(vibrate / maxOpenTerminals 等;平台项由宿主设置页写入,
|
|
345
|
+
* 业务项由插件设置面经下方 KV 桥写入后反映到此) */
|
|
346
|
+
mobileSettings: import('vue').Ref<Record<string, unknown>>
|
|
347
|
+
/** 读全部设置键值(扁平表 `{ key: value }`;通用机制,插件自持哪些键是自己的设置项) */
|
|
348
|
+
readAllSettings(): Promise<Record<string, string>>
|
|
349
|
+
/** 写单个设置键(通用机制面:命中宿主已知键写穿其响应式单例,未命中直落 KV) */
|
|
350
|
+
writeSetting(key: string, value: string): Promise<void>
|
|
351
|
+
/** 会话/连接生命周期事件(断线 / 会话状态 / 停止 / 移除);Disposable.dispose = 取消订阅 */
|
|
352
|
+
onSessionEvent(handler: (event: MobileHostSessionEvent) => void): Disposable
|
|
353
|
+
// ── 连接引擎面(票 2026-10-09:宿主页下沉 bedcode 应用,引擎事实与动作)──
|
|
354
|
+
|
|
355
|
+
/** 连接引擎状态(disconnected/connecting/connected/pairing/paired/error) */
|
|
356
|
+
connectionStatus: import('vue').Ref<MobileConnectionStatus>
|
|
357
|
+
/** 是否正在连接(连接中禁止重复点击) */
|
|
358
|
+
isConnecting: import('vue').Ref<boolean>
|
|
359
|
+
/** 当前连接目标设备 */
|
|
360
|
+
currentDevice: import('vue').Ref<MobileDeviceTarget | null>
|
|
361
|
+
/** 连接历史(此前尝试连接过的桌面端端点;宿主连接域引擎事实) */
|
|
362
|
+
connectionHistory: import('vue').Ref<MobileConnectionHistoryItem[]>
|
|
363
|
+
/** 建立到目标桌面的连接(HTTP base url 探测 + WS 事件通道建链;宿主引擎动作) */
|
|
364
|
+
connectDevice(device: MobileDeviceTarget): Promise<void>
|
|
365
|
+
/** 取消进行中的连接 */
|
|
366
|
+
cancelConnection(): Promise<void>
|
|
367
|
+
/** 用宿主持有的凭据静默换新 JWT(返回用户免配对;凭据零过境,插件拿不到 token)
|
|
368
|
+
*
|
|
369
|
+
* - 宿主无凭据 / 桌面端拒绝 → false(由配对流程接管)
|
|
370
|
+
* - 成功 → `isPaired` 翻转 true,宿主广播 ws_paired */
|
|
371
|
+
authenticateWithStoredToken(): Promise<boolean>
|
|
372
|
+
/** 断开当前连接 */
|
|
373
|
+
disconnect(): Promise<void>
|
|
374
|
+
/** 刷新连接历史(force=true 忽略已加载标记) */
|
|
375
|
+
loadConnectionHistory(force?: boolean): Promise<void>
|
|
376
|
+
/** 清空连接历史 */
|
|
377
|
+
clearConnectionHistory(): Promise<void>
|
|
378
|
+
/** 从连接历史移除单条 */
|
|
379
|
+
removeFromConnectionHistory(address: string): Promise<void>
|
|
380
|
+
/** 写入/更新一条连接历史(去重后置顶,宿主域上限 10 条;认证成功时由连接页调用) */
|
|
381
|
+
addToConnectionHistory(address: string, name?: string): Promise<void>
|
|
382
|
+
/** 连接生命周期事件白名单(reconnecting/reconnected/unexpected_disconnect/reauth_rejected/reconnect_failed/event_channel_ready) */
|
|
383
|
+
onConnectionEvent(handler: (event: MobileHostConnectionEvent) => void): Disposable
|
|
384
|
+
|
|
385
|
+
// ── mDNS 主机发现引擎事实(原始发现事实投影;派生列表归插件自持)──
|
|
386
|
+
|
|
387
|
+
/** 已发现服务列表(响应式 ref) */
|
|
388
|
+
mdnsServices: import('vue').Ref<MobileMdnsService[]>
|
|
389
|
+
/** 是否扫描中(响应式 ref) */
|
|
390
|
+
mdnsScanning: import('vue').Ref<boolean>
|
|
391
|
+
/** 启动扫描(keepResults=true 保留既有列表续扫) */
|
|
392
|
+
mdnsStart(options?: { keepResults?: boolean }): Promise<void>
|
|
393
|
+
/** 停止扫描 */
|
|
394
|
+
mdnsStop(): Promise<void>
|
|
395
|
+
/** 重新拉取已发现服务 */
|
|
396
|
+
mdnsRefresh(): Promise<void>
|
|
397
|
+
|
|
398
|
+
// ── 生物凭证引擎面(C4 凭据零过境:只投状态与绑定动作,材料留宿主)──
|
|
399
|
+
|
|
400
|
+
getBiometricKeyStatus(): Promise<MobileBiometricKeyStatus>
|
|
401
|
+
bindBiometricCredential(): Promise<boolean>
|
|
402
|
+
unbindBiometricCredential(): Promise<boolean>
|
|
403
|
+
|
|
404
|
+
/** DEV mock 会话 id(生产为 null;终端 UI 据此进入本地 mock 渲染) */
|
|
405
|
+
mockSessionId: string | null
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// ==================== 对话框 ====================
|
|
409
|
+
|
|
410
|
+
/** 对话框选项 */
|
|
411
|
+
export interface DialogOptions {
|
|
412
|
+
title?: string
|
|
413
|
+
message?: string
|
|
414
|
+
/** 视觉风格(默认 info) */
|
|
415
|
+
variant?: 'info' | 'warning' | 'danger'
|
|
416
|
+
confirmText?: string
|
|
417
|
+
cancelText?: string
|
|
418
|
+
/** showPrompt 时:输入框 placeholder */
|
|
419
|
+
inputPlaceholder?: string
|
|
420
|
+
/** showPrompt 时:输入框默认值 */
|
|
421
|
+
inputValue?: string
|
|
422
|
+
/** 是否可点击背景关闭(默认 false) */
|
|
423
|
+
dismissible?: boolean
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/** 对话框结果 */
|
|
427
|
+
export interface DialogResult {
|
|
428
|
+
action: 'confirm' | 'cancel'
|
|
429
|
+
value?: string
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/** 对话框 API — 宿主渲染移动端样式弹窗 */
|
|
433
|
+
export interface DialogAPI {
|
|
434
|
+
/** 通用对话框:返回用户操作结果 */
|
|
435
|
+
showDialog(options: DialogOptions): Promise<DialogResult>
|
|
436
|
+
/** 确认框:返回是否确认 */
|
|
437
|
+
showConfirm(options: DialogOptions): Promise<boolean>
|
|
438
|
+
/** 输入框:返回输入值;取消返回 null */
|
|
439
|
+
showPrompt(options: DialogOptions): Promise<string | null>
|
|
440
|
+
/** 轻提示(宿主 toast) */
|
|
441
|
+
showToast(message: string, type?: 'info' | 'success' | 'warning' | 'error'): void
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// ==================== 通知 ====================
|
|
445
|
+
|
|
446
|
+
/** 系统通知 API — 走宿主 tauri-plugin-notification */
|
|
447
|
+
export interface NotificationAPI {
|
|
448
|
+
notify(title: string, body?: string): Promise<void>
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// ==================== 状态上报 ====================
|
|
452
|
+
|
|
453
|
+
/** 插件状态上报 API — 启用时通过生命周期函数上报启动成功/失败 */
|
|
454
|
+
export interface StatusAPI {
|
|
455
|
+
/** 显式上报启动成功(activate 隐式成功之外的自愈通道:Error → Activated) */
|
|
456
|
+
reportReady(): Promise<void>
|
|
457
|
+
/** 上报启动/运行失败,宿主置 Error 状态并持久化未启用 */
|
|
458
|
+
reportError(error: string): Promise<void>
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// ==================== PluginContext API ====================
|
|
462
|
+
|
|
463
|
+
/** 命令注册表 */
|
|
464
|
+
export interface CommandRegistry {
|
|
465
|
+
register(id: string, handler: (...args: any[]) => any): Disposable
|
|
466
|
+
execute(id: string, ...args: any[]): Promise<any>
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/** 会话 API */
|
|
470
|
+
export interface SessionAPI {
|
|
471
|
+
list(): Promise<any[]>
|
|
472
|
+
get(sessionId: string): Promise<any>
|
|
473
|
+
onStatusChange(handler: (event: any) => void): Disposable
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// ==================== 全局弹窗(宿主通用能力,与桌面端 SDK 同构) ====================
|
|
477
|
+
|
|
478
|
+
/** 弹窗动作按钮(预设模式,Label 文案由插件经自身 i18n 生成后传入) */
|
|
479
|
+
export interface PluginDialogAction {
|
|
480
|
+
label: string
|
|
481
|
+
/** 视觉变体:默认 / 主按钮 / 危险 / 幽灵 */
|
|
482
|
+
kind?: 'default' | 'primary' | 'danger' | 'ghost'
|
|
483
|
+
/** 点击回调(可异步);成功返回后自动关闭弹窗(抛错则保持打开以便重试) */
|
|
484
|
+
onClick?: () => void | Promise<void>
|
|
485
|
+
/** 点击后经宿主 router 跳转的目标路由(先关弹窗再跳转) */
|
|
486
|
+
navigateTo?: string
|
|
487
|
+
/** 动作进行中禁用(如提交中防重复点击);经 handle.update() 联动 */
|
|
488
|
+
disabled?: boolean
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* 全局弹窗选项(宿主统一渲染:遮罩/卡片/z-index/定时关闭/按钮/路由跳转)
|
|
493
|
+
*
|
|
494
|
+
* 两种模式:
|
|
495
|
+
* - 预设模式:title + message + icon + actions,常见「确认/拒绝」类请求开箱即用;
|
|
496
|
+
* - 组件模式:content 传入任意 Vue 组件(经 provide('pluginContext') 渲染),
|
|
497
|
+
* props 可经 handle.update() 热更新。
|
|
498
|
+
* 定时关闭为可选能力:仅当 timeoutSec / deadlineAt 之一提供时生效。
|
|
499
|
+
*/
|
|
500
|
+
export interface PluginDialogOptions {
|
|
501
|
+
/** 自定义内容组件(组件模式);缺省用 title/message/icon/actions 预设渲染 */
|
|
502
|
+
content?: any
|
|
503
|
+
/** 内容组件 props(组件模式;handle.update() 可热更新) */
|
|
504
|
+
props?: Record<string, unknown>
|
|
505
|
+
/** 预设模式:标题 */
|
|
506
|
+
title?: string
|
|
507
|
+
/** 预设模式:正文 */
|
|
508
|
+
message?: string
|
|
509
|
+
/** 预设模式:图标(SVG path d,随文字颜色渲染) */
|
|
510
|
+
icon?: string
|
|
511
|
+
/** 预设模式:动作按钮组(缺省无按钮;顺序即展示顺序) */
|
|
512
|
+
actions?: PluginDialogAction[]
|
|
513
|
+
/** 定时自动关闭(可选):相对秒数,从弹窗弹出起算 */
|
|
514
|
+
timeoutSec?: number
|
|
515
|
+
/** 定时自动关闭(可选):绝对截止时间戳 ms(迟到打开 / 排队续算更准确,优先于 timeoutSec) */
|
|
516
|
+
deadlineAt?: number
|
|
517
|
+
/** 倒计时文案模板,{seconds} 占位(如 '{seconds} 秒后自动拒绝');缺省不显示倒计时 */
|
|
518
|
+
countdownLabel?: string
|
|
519
|
+
/** 超时回调(自动关闭前触发);缺省仅关闭 */
|
|
520
|
+
onTimeout?: () => void
|
|
521
|
+
/** 是否可手动关闭(右上角关闭按钮 / Escape / 遮罩点击),默认 true */
|
|
522
|
+
closable?: boolean
|
|
523
|
+
/** 点击遮罩是否关闭,默认 true(closable=false 时无效) */
|
|
524
|
+
closeOnBackdrop?: boolean
|
|
525
|
+
/** 卡片宽度(Tailwind max-w-* 类),默认 max-w-md */
|
|
526
|
+
widthClass?: string
|
|
527
|
+
/** 内容区 padding(Tailwind 类),默认 p-0(组件模式自带内距,预设模式内部处理) */
|
|
528
|
+
bodyClass?: string
|
|
529
|
+
/** 关闭后回调(按钮 / 遮罩 / Escape / 超时 / close() / 排队项被取消 均触发) */
|
|
530
|
+
onClose?: () => void
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/** 全局弹窗句柄:调用方据此关闭或热更新当前弹窗 */
|
|
534
|
+
export interface PluginDialogHandle {
|
|
535
|
+
/** 关闭当前弹窗(幂等);队列中下一个弹窗自动接替 */
|
|
536
|
+
close(): void
|
|
537
|
+
/** 热更新选项(props / 文案 / 按钮 / 倒计时等) */
|
|
538
|
+
update(options: Partial<PluginDialogOptions>): void
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/** 监控面板环境(收窄只读面;面板实现住提供方应用工程) */
|
|
542
|
+
export interface MonitorPanelEnv {
|
|
543
|
+
appId: string
|
|
544
|
+
panelId: string
|
|
545
|
+
/** 本应用插件面命令(与主界面同一权限;只在面板内只读取数) */
|
|
546
|
+
appInvoke: <T = any>(command: string, ...args: any[]) => Promise<T>
|
|
547
|
+
/** 本应用插件 KV 只读访问 */
|
|
548
|
+
appStorageGet: <T = any>(key: string) => Promise<T | undefined>
|
|
549
|
+
locale: string
|
|
550
|
+
theme: string
|
|
551
|
+
platform?: string
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/** 监控面板句柄(monitor 切换页签 / 卸载时销毁) */
|
|
555
|
+
export interface MonitorPanelHandle {
|
|
556
|
+
unmount(): Promise<void>
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/** 提供方模块可选导出;未导出 = 没有该面板实现(不是错误) */
|
|
560
|
+
export type MountMonitorPanel = (
|
|
561
|
+
root: HTMLElement,
|
|
562
|
+
env: MonitorPanelEnv,
|
|
563
|
+
) => Promise<MonitorPanelHandle>
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* UI 注册表
|
|
567
|
+
*
|
|
568
|
+
* 票 2026-10-10 批次 C2 整面退役:`registerToolboxPage` / `registerNavTab` /
|
|
569
|
+
* `registerTerminalToolbarItem` / `registerTerminalView` 及其描述符类型已删除。
|
|
570
|
+
* 应用在宿主壳内**只有一种运行面形态**——`registerSurface`;应用内页签与子页走本表
|
|
571
|
+
* 保留的 `registerRoute` + `openPage`,不占宿主导航形态。旧插件若仍调用已退役方法,
|
|
572
|
+
* 宿主在调用点显式抛错(fail-visible),不做「查不到就静默忽略」。
|
|
573
|
+
*/
|
|
574
|
+
export interface UIRegistry {
|
|
575
|
+
/**
|
|
576
|
+
* 装载其他应用注册的自定义监控面板(monitor 统一壳用;宿主中介)。
|
|
577
|
+
* 只 import 提供方前端模块并调用其 `mountMonitorPanel`,不激活其后端。
|
|
578
|
+
*/
|
|
579
|
+
mountMonitorPanel(
|
|
580
|
+
container: HTMLElement,
|
|
581
|
+
appId: string,
|
|
582
|
+
panelId: string,
|
|
583
|
+
): Promise<MonitorPanelHandle>
|
|
584
|
+
/** 宿主壳运行面(/mobile/shell 的应用运行屏;appId = 插件 id 由宿主代填)。
|
|
585
|
+
* 应用自持整个运行面——含底部导航与页签,壳不向其内加壳 chrome。 */
|
|
586
|
+
registerSurface(surface: ShellSurfaceContribution): Disposable
|
|
587
|
+
/** 宿主壳首页快捷卡片(应用自持内容;壳 Home 屏渲染,appId 由宿主代填) */
|
|
588
|
+
registerSlot(slot: ShellSlotContribution): Disposable
|
|
589
|
+
/** 宿主壳胶囊菜单附加项(appId 由宿主代填) */
|
|
590
|
+
registerCapsuleItem(item: ShellCapsuleItem): Disposable
|
|
591
|
+
/** 动态注册插件路由(宿主 addRoute 至 /mobile/plugins/{pluginId}/{id};Disposable.dispose = removeRoute 撤销) */
|
|
592
|
+
registerRoute(route: PluginRouteDescriptor): Disposable
|
|
593
|
+
/** 整体跳转到本插件已注册路由;返回入口页用 goBack 或宿主页头返回按钮 */
|
|
594
|
+
openPage(routeId: string): void
|
|
595
|
+
/** 返回上一页(router.back) */
|
|
596
|
+
goBack(): void
|
|
597
|
+
/** 监听 Android 系统返回键(仅 Android 真机触发;有订阅者时系统返回不再执行默认的
|
|
598
|
+
* webview 后退/退出,改由回调接管)。
|
|
599
|
+
* 回调自行决定行为:应用自持的二级页 / 浮层在这里逐级收掉(回到应用主页面后不再
|
|
600
|
+
* 消费,交平台兜底);**返回 true 表示本次已消费**——不消费
|
|
601
|
+
* (返回 undefined / false)时返回会交给平台兜底(宿主壳回退到上一屏,主屏无兜底
|
|
602
|
+
* 则退出应用),因此应用在「自己已到头」的分支上不要返回 true,否则用户按返回无反应。
|
|
603
|
+
* 载荷 canGoBack = webview 自身是否有历史(需要时可用它恢复默认后退)。
|
|
604
|
+
* 非 Android(dev-shell / iOS)静默降级为永不触发;Disposable.dispose = 取消监听,
|
|
605
|
+
* 最后一个订阅者取消后恢复系统默认返回行为。 */
|
|
606
|
+
onBackPressed(handler: (payload: { canGoBack: boolean }) => boolean | void): Disposable
|
|
607
|
+
/** 全局弹窗(宿主统一渲染遮罩/卡片/倒计时/按钮/路由跳转;见 PluginDialogOptions) */
|
|
608
|
+
showDialog(options: PluginDialogOptions): PluginDialogHandle
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/** 事件 API */
|
|
612
|
+
export interface EventAPI {
|
|
613
|
+
on(event: string, handler: (...args: any[]) => void): Disposable
|
|
614
|
+
emit(event: string, ...args: any[]): void
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/** 存储 API */
|
|
618
|
+
export interface StorageAPI {
|
|
619
|
+
get<T = any>(key: string): Promise<T | undefined>
|
|
620
|
+
set(key: string, value: any): Promise<void>
|
|
621
|
+
delete(key: string): Promise<void>
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// ==================== System API ====================
|
|
625
|
+
|
|
626
|
+
/** 系统 API — 宿主 OS 级文件操作(需 system:open 权限) */
|
|
627
|
+
export interface SystemAPI {
|
|
628
|
+
/** 用系统查看器打开本地文件(传输完成「打开本地文件」;Android ACTION_VIEW) */
|
|
629
|
+
openFile(path: string, displayName?: string): Promise<void>
|
|
630
|
+
/** 用系统文件管理器打开文件所在目录(历史记录「打开所在文件夹」;
|
|
631
|
+
* Android FileProvider 暴露父目录 + ACTION_VIEW,需 system:open 权限) */
|
|
632
|
+
revealInDir(path: string): Promise<void>
|
|
633
|
+
/** 按文件名打开接收文件的所在目录(历史「打开所在文件夹」真机路径;
|
|
634
|
+
* 接收落点不在 wire 上,宿主 MediaStore 公共下载按 displayName 命中 →
|
|
635
|
+
* primary:Download 目录,未命中回退 app 私有下载目录;需 system:open 权限) */
|
|
636
|
+
revealReceivedFileLocation(fileName: string): Promise<void>
|
|
637
|
+
/** 引导开启「所有文件访问」权限(打开系统公共 Download 目录需要
|
|
638
|
+
* MANAGE_EXTERNAL_STORAGE,无运行时弹窗只能跳系统设置页手动开启;
|
|
639
|
+
* 未授权时跳转系统授权页并在无该页面的 ROM 兑底应用详情页),返回
|
|
640
|
+
* 跳转前的授权状态;授权后用户重试 revealReceivedFileLocation 即达;
|
|
641
|
+
* 需 system:open 权限) */
|
|
642
|
+
requestAllFilesAccess(): Promise<boolean>
|
|
643
|
+
/** 打开系统公共下载目录(设置页下载目录区「打开」,核对文件是否落盘;
|
|
644
|
+
* 目标为系统 Download 目录(ExternalStorageProvider 树 URI),未授予
|
|
645
|
+
* 「所有文件访问」时报 needs_all_files_access,前端据此引导授权;
|
|
646
|
+
* 需 system:open 权限) */
|
|
647
|
+
openDownloadDir(): Promise<void>
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
// ==================== 插件开发期领域数据(dev-shell mock 协议) ====================
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* 插件开发期领域数据(dev-shell mock 协议,仅浏览器 dev 环境消费)。
|
|
654
|
+
*
|
|
655
|
+
* 与"宿主能力 mock"(会话/对话框/事件/HTTP 接口等,固定在 dev-shell 内实现)区分:
|
|
656
|
+
* 本协议只承载各插件自己的业务演示数据,由插件入口导出 devMock,dev-shell
|
|
657
|
+
* 加载插件时按 pluginId 注册、按需取用。
|
|
658
|
+
*
|
|
659
|
+
* SDK 只约定「入口导出 devMock」的通用容器协议,不感知任何插件领域细节:
|
|
660
|
+
* 各插件自有类型(任务队列种子 / 文件传输对等与传输域种子等)
|
|
661
|
+
* 由插件工程自行定义;dev-shell 消费时 cast 到插件自有形状。
|
|
662
|
+
* 真实宿主忽略该字段(多余导出对 activate 无影响),插件无需条件编译。
|
|
663
|
+
*/
|
|
664
|
+
export type PluginDevMock = Record<string, unknown>
|
|
665
|
+
|
|
666
|
+
/** 国际化 API */
|
|
667
|
+
export interface I18nAPI {
|
|
668
|
+
registerMessages(locale: string, messages: Record<string, unknown>): void
|
|
669
|
+
t(key: string, params?: Record<string, unknown>): string
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/** 生命周期 API(onTerminalInput/onTerminalOutput 已随票 15 阶段 B 退役) */
|
|
673
|
+
export interface LifecycleAPI {
|
|
674
|
+
onAppStartup(handler: () => void): Disposable
|
|
675
|
+
onAppShutdown(handler: () => void): Disposable
|
|
676
|
+
onAuthSuccess(handler: () => void): Disposable
|
|
677
|
+
onDisconnect(handler: (reason: string) => void): Disposable
|
|
678
|
+
onSessionCreated(handler: (sessionId: string) => void): Disposable
|
|
679
|
+
onSessionStopped(handler: (sessionId: string) => void): Disposable
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/** 插件上下文 */
|
|
683
|
+
export interface PluginContext {
|
|
684
|
+
readonly id: string
|
|
685
|
+
readonly commands: CommandRegistry
|
|
686
|
+
readonly session: SessionAPI
|
|
687
|
+
readonly ui: UIRegistry
|
|
688
|
+
readonly events: EventAPI
|
|
689
|
+
readonly storage: StorageAPI
|
|
690
|
+
readonly i18n: I18nAPI
|
|
691
|
+
readonly lifecycle: LifecycleAPI
|
|
692
|
+
readonly logger: LoggerAPI
|
|
693
|
+
/** 对话框(弹窗扩展性) */
|
|
694
|
+
readonly dialogs: DialogAPI
|
|
695
|
+
/** 系统通知 */
|
|
696
|
+
readonly notifications: NotificationAPI
|
|
697
|
+
/** 系统 API(需 system:open 权限) */
|
|
698
|
+
readonly system: SystemAPI
|
|
699
|
+
/** 生命周期状态上报(启用成功/失败) */
|
|
700
|
+
readonly status: StatusAPI
|
|
701
|
+
readonly _disposables: Disposable[]
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/** 插件入口模块约定 */
|
|
705
|
+
export interface PluginModule {
|
|
706
|
+
activate(context: PluginContext): Promise<void>
|
|
707
|
+
deactivate?: () => Promise<void>
|
|
708
|
+
/**
|
|
709
|
+
* 可选:自定义监控面板实现(由 monitor 统一壳经宿主中介装载)。
|
|
710
|
+
* 只在面板装载时调用,不要求 activate 先执行;面板自行处理后端未运行的情况。
|
|
711
|
+
*/
|
|
712
|
+
mountMonitorPanel?: MountMonitorPanel
|
|
713
|
+
/** dev-shell 领域数据(见 PluginDevMock);真实宿主忽略 */
|
|
714
|
+
devMock?: PluginDevMock
|
|
715
|
+
}
|