@binblink/wasmnest-plugin-sdk-mobile 0.0.1 → 0.0.2

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.
Files changed (34) hide show
  1. package/README.md +78 -2
  2. package/README_en.md +64 -2
  3. package/bin/build.js +4 -2
  4. package/bin/manifest-gen.js +3 -0
  5. package/bin/package.js +2 -1
  6. package/bin/scaffold.js +22 -8
  7. package/dev-shell/README.md +1 -1
  8. package/dev-shell/src/apps/mock-terminal/MockTerminalSlotCard.vue +13 -21
  9. package/dev-shell/src/locales/en-shell.ts +6 -2
  10. package/dev-shell/src/locales/shell.ts +5 -2
  11. package/dev-shell/src/mock-context.ts +28 -5
  12. package/dev-shell/src/shell/adapters/devAppSource.ts +2 -13
  13. package/dev-shell/src/shell/components/ShellNotificationShade.vue +22 -17
  14. package/dev-shell/src/shell/components/screens/ShellAppDetailScreen.vue +16 -35
  15. package/dev-shell/src/shell/components/screens/ShellHomeScreen.vue +58 -17
  16. package/dev-shell/src/shell/composables/useShellApps.ts +5 -3
  17. package/dev-shell/src/shell/composables/useShellOpen.ts +12 -3
  18. package/dev-shell/src/shell/composables/useSlotCarousel.ts +238 -0
  19. package/dev-shell/src/shell/slotCards.ts +47 -0
  20. package/dev-shell/src/shell/styles/shell.css +340 -26
  21. package/dev-shell/src/shell/surfaceIntent.ts +107 -0
  22. package/dev-shell/src/shell/types.ts +17 -2
  23. package/dev-shell/src/styles/mobile.css +981 -884
  24. package/dist/index.d.ts +44 -4
  25. package/dist/index.js +69 -1
  26. package/dist/types.d.ts +107 -6
  27. package/package.json +9 -1
  28. package/src/index.ts +9 -0
  29. package/src/types.ts +822 -715
  30. package/src/ui/AppUpdateSection.d.ts +44 -0
  31. package/src/ui/AppUpdateSection.vue +253 -0
  32. package/src/ui/QuickCard.d.ts +33 -0
  33. package/src/ui/QuickCard.vue +167 -0
  34. package/src/update.ts +123 -0
package/README.md CHANGED
@@ -65,7 +65,7 @@ wasmnest-plugin dev --host # 监听局域网,手机浏览器访问 h
65
65
  "author": "you",
66
66
  "icon": "🧩",
67
67
  "main": "index.js",
68
- "pluginType": "ts-only",
68
+ "pluginType": "frontend",
69
69
  "permissions": ["storage", "ui:input"],
70
70
  "contributes": {
71
71
  "commands": [{ "id": "my-plugin.hello", "title": "Hello" }],
@@ -106,7 +106,7 @@ export async function deactivate(): Promise<void> {
106
106
  |-----|------|----------|
107
107
  | `context.commands` | 注册 / 执行命令(`register` / `execute`)——含本应用的自持业务命令(如 `file-transfer.list-remote`) | 默认授予 |
108
108
  | `context.session` | 会话列表、单会话查询、状态变更订阅 | `session:read` / `session:write` |
109
- | `context.ui` | 宿主壳运行面 / 首页卡片 / 胶囊菜单 / 平台设置入口 / 动态路由(`registerSurface` / `registerSlot` / `registerCapsuleItem` / `registerSettingsEntry` / `registerRoute`)、跳转与返回(`openPage` / `goBack`)、系统返回键接管(`onBackPressed`)、全局弹窗(`showDialog`) | `ui:route` / `ui:back` / `ui:dialog` / `ui:settings` |
109
+ | `context.ui` | 宿主壳运行面 / 首页卡片 / 胶囊菜单 / 平台设置入口 / 动态路由(`registerSurface` / `registerSlot` / `registerCapsuleItem` / `registerSettingsEntry` / `registerRoute`)、跳转与返回(`openPage` / `goBack`)、系统返回键接管(`onBackPressed`)、入口意图(`onSurfaceIntent`)、全局弹窗(`showDialog`) | `ui:route` / `ui:back` / `ui:dialog` / `ui:settings` |
110
110
  | `context.events` | 宿主事件订阅与发布(`on` / `emit`) | 默认授予 |
111
111
  | `context.storage` | 键值存储(`get` / `set` / `delete`) | `storage`(**移动端恒授予**,见下方说明) |
112
112
  | `context.lifecycle` | 应用生命周期钩子(`onAppStartup` / `onAppShutdown` / `onAuthSuccess` / `onDisconnect` / `onSessionCreated` / `onSessionStopped`) | 默认授予 |
@@ -115,6 +115,7 @@ export async function deactivate(): Promise<void> {
115
115
  | `context.status` | 生命周期状态上报(`reportReady` / `reportError`) | 默认授予 |
116
116
  | `context.logger` | 分级日志(`info` / `debug` / `warn` / `error`) | 默认授予 |
117
117
  | `context.i18n` | 注册应用翻译、`t()` 快捷翻译 | 默认授予 |
118
+ | `context.appUpdate` | 应用更新检查(宿主统一 GitHub Release 判定;失败归一化为 `status: 'error'`) | 默认授予 |
118
119
  | `context.system` | 系统级操作(`openFile` / `revealInDir` / `revealReceivedFileLocation` / `requestAllFilesAccess` / `openDownloadDir`) | `system:open` |
119
120
  | `context._disposables` | 宿主在注销时统一回收的 Disposable 列表(内部使用) | — |
120
121
 
@@ -335,11 +336,84 @@ const options = [
335
336
  </template>
336
337
  ```
337
338
 
339
+ ### 应用更新检查(AppUpdateSection)
340
+
341
+ manifest 声明 `update`(缺省 = 不参与检查)后,应用设置页直接嵌入 SDK 默认卡片:
342
+
343
+ ```vue
344
+ <script setup lang="ts">
345
+ import AppUpdateSection from '@binblink/wasmnest-plugin-sdk-mobile/ui/app-update'
346
+ </script>
347
+
348
+ <template>
349
+ <AppUpdateSection />
350
+ </template>
351
+ ```
352
+
353
+ - 数据面 = `context.appUpdate.check`(宿主注入;令牌只能查自己);应用可给 `check` 传自实现,或只用 `useAppUpdate()` 自己画 UI。
354
+ - 更新安装统一在宿主应用管理页执行(需先停用、替换目录并重新审批)。
355
+
356
+ ### 首页快捷卡片(QuickCard)
357
+
358
+ 宿主壳首页的快捷卡片 = **SDK 公共外观 + 应用内容 + 宿主跳转**:应用只实现卡片内容,
359
+ activate 期用 `context.ui.registerSlot` 注册;宿主壳负责展示、自动轮播(最多 5 张)与
360
+ 点击打开本应用,应用不需要也不应该在卡片里处理导航。
361
+
362
+ 卡片可以**直达应用内某个位置**(如「活跃会话」卡点进最近一个会话):`registerSlot`
363
+ 的可选 `onPress()` 在点击时刻现算一个入口意图(`{ key, payload }`,内容全归应用),
364
+ 宿主启动并打开应用后原样投递给运行面——运行面在 `onMounted` 里用
365
+ `context.ui.onSurfaceIntent(handler)` 订阅即可。订阅前到达的意图由宿主排队补投,
366
+ 运行面晚于点击创建也不会丢;应用停用 / 卸载后队列清空。
367
+
368
+ ```vue
369
+ <script setup lang="ts">
370
+ import QuickCard from '@binblink/wasmnest-plugin-sdk-mobile/ui/quick-card'
371
+
372
+ defineProps<{ activeCount: number }>()
373
+ </script>
374
+
375
+ <template>
376
+ <QuickCard
377
+ label="活跃会话"
378
+ :value="activeCount"
379
+ hint="正在运行"
380
+ tone="success"
381
+ :icon-path="['M4 5h16v14H4z', 'M8 10l3 2.5-3 2.5']"
382
+ />
383
+ </template>
384
+ ```
385
+
386
+ ```ts
387
+ context.ui.registerSlot({
388
+ id: 'sessions',
389
+ component: SessionCard,
390
+ order: 10,
391
+ // 点击直达应用内位置;省略 = 只打开应用(旧行为)
392
+ onPress: () => ({ key: 'open-session', payload: { sessionId: latestLiveSessionId() } }),
393
+ })
394
+ ```
395
+
396
+ ```ts
397
+ // 运行面(应用根组件):宿主投递入口意图
398
+ const sub = context.ui.onSurfaceIntent((intent) => {
399
+ if (intent.key !== 'open-session') return
400
+ openSession((intent.payload as { sessionId: string }).sessionId)
401
+ })
402
+ // 卸载时 sub.dispose()
403
+ ```
404
+
405
+ - 宿主把整张卡渲染成按钮(点击 = 启动并打开贡献方应用,再投递 `onPress()` 的返回值),
406
+ 卡片内不得再放按钮 / 链接;
407
+ - 宿主按注册顺序截断展示(当前 5 张),多张时自动轮播——触摸 / 键盘聚焦 / 切后台 /
408
+ 系统「减少动效」时停走,标题行提供暂停 / 播放控件;
409
+ - `label` / `value` / `hint` / `tone` / `iconPath` 覆盖常见读数卡,复杂内容用默认插槽。
410
+
338
411
  当前提供(每个子路径 = 一个独立导出):
339
412
 
340
413
  | 子路径 | 内容 | 用途 |
341
414
  |--------|------|------|
342
415
  | `./ui` | `Select` 组件 | 下拉选择(`update:modelValue` / `open` 事件,`md` / `sm` 尺寸) |
416
+ | `./ui/quick-card` | `QuickCard` 组件 | 宿主壳首页快捷卡片公共外观(宿主 token / 明暗 / 字号自适应;点击归宿主) |
343
417
  | `./ui/plugin-global-dialog` | `PluginGlobalDialog` 组件 | 移动端宿主全局弹窗(应用根挂载一次;渲染由全局弹窗控制器驱动,与桌面端同构) |
344
418
  | `./ui/swipe-tabs` | `useSwipeTabs` composable | 弹窗/页签内容区横向滑动切换(内容区水平主导滑动超阈值触发 `onSwitch`;垂直主导不记录位移;`shouldSkip` 排除输入控件等不应作切页手势的起点) |
345
419
  | `./global-dialog` | 全局弹窗控制器 | 发布-订阅式弹窗队列(FIFO,同时至多一个;`update()` 生成新条目对象再广播),宿主与 dev-shell 共用 |
@@ -352,6 +426,8 @@ const options = [
352
426
  | `@binblink/wasmnest-plugin-sdk-mobile/vite` | `wasmnestPlugin()` Vite 构建插件 |
353
427
  | `@binblink/wasmnest-plugin-sdk-mobile/types` | 纯类型导出(仅类型,无运行时) |
354
428
  | `@binblink/wasmnest-plugin-sdk-mobile/ui` | 共享 Vue 组件:`Select` |
429
+ | `@binblink/wasmnest-plugin-sdk-mobile/ui/quick-card` | `QuickCard` 首页快捷卡片 |
430
+ | `@binblink/wasmnest-plugin-sdk-mobile/ui/app-update` | `AppUpdateSection`(应用更新检查) |
355
431
  | `@binblink/wasmnest-plugin-sdk-mobile/ui/plugin-global-dialog` | `PluginGlobalDialog` |
356
432
  | `@binblink/wasmnest-plugin-sdk-mobile/ui/swipe-tabs` | `useSwipeTabs` |
357
433
  | `@binblink/wasmnest-plugin-sdk-mobile/global-dialog` | 全局弹窗控制器 |
package/README_en.md CHANGED
@@ -65,7 +65,7 @@ A minimal plugin needs just two files:
65
65
  "author": "you",
66
66
  "icon": "🧩",
67
67
  "main": "index.js",
68
- "pluginType": "ts-only",
68
+ "pluginType": "frontend",
69
69
  "permissions": ["storage", "ui:input"],
70
70
  "contributes": {
71
71
  "commands": [{ "id": "my-plugin.hello", "title": "Hello" }],
@@ -106,7 +106,7 @@ The `PluginContext` received by `activate(context)` is the **single channel** th
106
106
  |-----|-------------|---------------------|
107
107
  | `context.commands` | Register / execute commands (`register` / `execute`) — including the app's own business commands (e.g. `file-transfer.list-remote`) | granted by default |
108
108
  | `context.session` | Session list, single-session lookup, status change subscription | `session:read` / `session:write` |
109
- | `context.ui` | Host-shell surface / home quick cards / capsule menu / platform settings entries / dynamic routes (`registerSurface` / `registerSlot` / `registerCapsuleItem` / `registerSettingsEntry` / `registerRoute`), navigation (`openPage` / `goBack`), system back-key interception (`onBackPressed`), global dialogs (`showDialog`) | `ui:route` / `ui:back` / `ui:dialog` / `ui:settings` |
109
+ | `context.ui` | Host-shell surface / home quick cards / capsule menu / platform settings entries / dynamic routes (`registerSurface` / `registerSlot` / `registerCapsuleItem` / `registerSettingsEntry` / `registerRoute`), navigation (`openPage` / `goBack`), system back-key interception (`onBackPressed`), surface entry intents (`onSurfaceIntent`), global dialogs (`showDialog`) | `ui:route` / `ui:back` / `ui:dialog` / `ui:settings` |
110
110
  | `context.events` | Host event subscription & publishing (`on` / `emit`) | granted by default |
111
111
  | `context.storage` | Key-value storage (`get` / `set` / `delete`) | `storage` (**always granted on mobile** — see note below) |
112
112
  | `context.lifecycle` | App lifecycle hooks (`onAppStartup` / `onAppShutdown` / `onAuthSuccess` / `onDisconnect` / `onSessionCreated` / `onSessionStopped`) | granted by default |
@@ -324,11 +324,72 @@ const options = [
324
324
  </template>
325
325
  ```
326
326
 
327
+ ### Home quick cards (QuickCard)
328
+
329
+ A host-shell quick card = **shared SDK chrome + app-owned content + host navigation**.
330
+ The app only implements the content and registers it with `context.ui.registerSlot` during
331
+ `activate`; the host shell renders it, auto-rotates the rail (up to 5 cards) and opens the
332
+ owning app on tap. The app must not handle navigation inside the card.
333
+
334
+ A card can **deep-link into a position inside the app** (e.g. an "active sessions" card that
335
+ jumps into the most recent session): the optional `onPress()` on `registerSlot` computes an
336
+ entry intent (`{ key, payload }`, entirely app-owned) at tap time. The host launches and
337
+ opens the app, then delivers that intent verbatim to the surface — subscribe with
338
+ `context.ui.onSurfaceIntent(handler)` in the surface's `onMounted`. Intents that arrive
339
+ before subscription are queued and flushed on subscribe, so a surface created after the tap
340
+ does not lose them; the queue is cleared when the app is stopped / uninstalled.
341
+
342
+ ```vue
343
+ <script setup lang="ts">
344
+ import QuickCard from '@binblink/wasmnest-plugin-sdk-mobile/ui/quick-card'
345
+
346
+ defineProps<{ activeCount: number }>()
347
+ </script>
348
+
349
+ <template>
350
+ <QuickCard
351
+ label="Active sessions"
352
+ :value="activeCount"
353
+ hint="Running"
354
+ tone="success"
355
+ :icon-path="['M4 5h16v14H4z', 'M8 10l3 2.5-3 2.5']"
356
+ />
357
+ </template>
358
+ ```
359
+
360
+ ```ts
361
+ context.ui.registerSlot({
362
+ id: 'sessions',
363
+ component: SessionCard,
364
+ order: 10,
365
+ // Deep link target; omit to only open the app (previous behavior)
366
+ onPress: () => ({ key: 'open-session', payload: { sessionId: latestLiveSessionId() } }),
367
+ })
368
+ ```
369
+
370
+ ```ts
371
+ // App surface root: consume the host-delivered entry intent
372
+ const sub = context.ui.onSurfaceIntent((intent) => {
373
+ if (intent.key !== 'open-session') return
374
+ openSession((intent.payload as { sessionId: string }).sessionId)
375
+ })
376
+ // sub.dispose() on unmount
377
+ ```
378
+
379
+ - The host wraps the whole card in a button (tap = launch and open the contributing app,
380
+ then deliver the value returned by `onPress()`); do not put buttons or links inside the card;
381
+ - The host truncates by registration order (currently 5 cards) and auto-rotates when there
382
+ are several — paused on touch / keyboard focus / background / system reduced motion, with
383
+ a pause/play control in the section header;
384
+ - `label` / `value` / `hint` / `tone` / `iconPath` cover the common metric card; use the
385
+ default slot for custom content.
386
+
327
387
  Currently provided (each subpath is an independent export):
328
388
 
329
389
  | Subpath | Contents | Purpose |
330
390
  |---------|----------|---------|
331
391
  | `./ui` | `Select` component | Dropdown (`update:modelValue` / `open` events, `md` / `sm` sizes) |
392
+ | `./ui/quick-card` | `QuickCard` component | Shared chrome for host-shell home quick cards (host tokens / dark mode / font scale; tap handled by the host) |
332
393
  | `./ui/plugin-global-dialog` | `PluginGlobalDialog` component | Mobile host global dialog (mounted once at the app root; rendering driven by the global dialog controller, same shape as desktop) |
333
394
  | `./ui/swipe-tabs` | `useSwipeTabs` composable | Horizontal swipe switching for dialog/tab content areas (a dominant-horizontal swipe past the threshold fires `onSwitch`; dominant-vertical swipes record no offset; `shouldSkip` excludes touch origins that must not act as page-swipe gestures, e.g. input controls) |
334
395
  | `./global-dialog` | global dialog controller | Publish-subscribe dialog queue (FIFO, at most one open at a time; `update()` builds a fresh entry object before broadcasting), shared by the host and the dev-shell |
@@ -341,6 +402,7 @@ Currently provided (each subpath is an independent export):
341
402
  | `@binblink/wasmnest-plugin-sdk-mobile/vite` | `wasmnestPlugin()` Vite build plugin |
342
403
  | `@binblink/wasmnest-plugin-sdk-mobile/types` | Pure types (types only, no runtime) |
343
404
  | `@binblink/wasmnest-plugin-sdk-mobile/ui` | Shared Vue component: `Select` |
405
+ | `@binblink/wasmnest-plugin-sdk-mobile/ui/quick-card` | `QuickCard` home quick card |
344
406
  | `@binblink/wasmnest-plugin-sdk-mobile/ui/plugin-global-dialog` | `PluginGlobalDialog` |
345
407
  | `@binblink/wasmnest-plugin-sdk-mobile/ui/swipe-tabs` | `useSwipeTabs` |
346
408
  | `@binblink/wasmnest-plugin-sdk-mobile/global-dialog` | global dialog controller |
package/bin/build.js CHANGED
@@ -85,7 +85,8 @@ function cmdDev(positional, flags) {
85
85
  */
86
86
  function startBuildWatch(cwd, resourcesDir, manifest) {
87
87
  const { id, main = 'index.js', rustLibrary, pluginType } = manifest
88
- const hasWasm = pluginType === 'wasm' && rustLibrary
88
+ // 形态三档(wasmnest-apps#21):backend / full 都携带 wasm 后端
89
+ const hasWasm = (pluginType === 'full' || pluginType === 'backend') && rustLibrary
89
90
  const viteBin = findViteBin(cwd)
90
91
  if (!viteBin) {
91
92
  console.error(
@@ -161,7 +162,8 @@ function cmdBuild(flags) {
161
162
  }
162
163
  const manifest = readJson(manifestPath, 'plugin.json')
163
164
  const { id, main, rustLibrary, pluginType } = manifest
164
- const hasWasm = pluginType === 'wasm' && rustLibrary
165
+ // 形态三档(wasmnest-apps#21):backend / full 都携带 wasm 后端
166
+ const hasWasm = (pluginType === 'full' || pluginType === 'backend') && rustLibrary
165
167
  const frontendOnly = flags['frontend-only'] === true
166
168
  const rustOnly = flags['rust-only'] === true
167
169
  const resourcesDir = flags['resources-dir']
@@ -39,6 +39,9 @@ const RUST_PERMISSION_RULES = [
39
39
  { re: /\bhttp_fetch\b/, perm: 'network:http' },
40
40
  { re: /\b(fs_read|fs_copy)\b/, perm: 'fs:read' },
41
41
  { re: /\bfs_write\b/, perm: 'fs:write' },
42
+ // 内网穿透(T06):服务端 / 客户端分域;configure / status 是共用面,不推导。
43
+ { re: /\btunnel_(expose|unexpose|issue_pairing_ticket)\b/, perm: 'tunnel:serve' },
44
+ { re: /\btunnel_(connect|close)\b/, perm: 'tunnel:connect' },
42
45
  ]
43
46
 
44
47
  /**
package/bin/package.js CHANGED
@@ -19,7 +19,8 @@ function cmdPackage(flags) {
19
19
  }
20
20
  const manifest = readJson(manifestPath, 'plugin.json')
21
21
  const { id, main, rustLibrary, pluginType } = manifest
22
- const hasWasm = pluginType === 'wasm' && rustLibrary
22
+ // 形态三档(wasmnest-apps#21):backend / full 都携带 wasm 后端
23
+ const hasWasm = (pluginType === 'full' || pluginType === 'backend') && rustLibrary
23
24
 
24
25
  // 打包前自动填充,保证 zip 内 plugin.json 与源码一致
25
26
  try {
package/bin/scaffold.js CHANGED
@@ -41,9 +41,8 @@ function cmdCreate(positional, flags) {
41
41
  .join('')}Plugin`
42
42
  const pkgName = `@wasmnest/plugin-${last}`
43
43
 
44
- // 插件类型:默认 wasm(前端 + WASM 后端);--ts-only 生成纯前端插件
45
- const tsOnly = flags['ts-only'] === true
46
- const pluginType = tsOnly ? 'ts-only' : 'wasm'
44
+ // 产物形态(语言无关三档,wasmnest-apps#21):默认 full(前端 + wasm 后端,
45
+ // 移动端原 `wasm` 形态的归属);--ts-only 生成纯前端 frontend
47
46
  // 注意:值内直接嵌入实际 crate 名(fillPlaceholders 按序替换,不能引用占位符本身)
48
47
  const rustLibraryLine = tsOnly ? '' : ` "rustLibrary": "${crate}",\n`
49
48
 
@@ -114,7 +113,7 @@ function cmdManifest(flags) {
114
113
 
115
114
  // ==================== 命令:validate(清单校验) ====================
116
115
 
117
- /** 合法权限列表(与宿主 src/plugin/permission.ts 权限映射键同步) */
116
+ /** 合法权限列表(真源 = SDK `rust/src/permission.rs` 的 VALID_PERMISSIONS) */
118
117
  const VALID_PERMISSIONS = new Set([
119
118
  'terminal:output',
120
119
  'session:read',
@@ -134,9 +133,19 @@ const VALID_PERMISSIONS = new Set([
134
133
  'auth',
135
134
  'notify',
136
135
  'metrics:read',
136
+ 'tunnel:connect',
137
+ 'tunnel:probe',
138
+ 'tunnel:serve',
137
139
  ])
138
140
 
139
- const VALID_PLUGIN_TYPES = new Set(['wasm', 'ts-only', 'rust', 'rust-ts'])
141
+ const VALID_PLUGIN_TYPES = new Set(['frontend', 'backend', 'full'])
142
+ // 退役 pluginType → 迁移出路(fail-visible:点名旧值并给出新值,不静默拒绝)
143
+ const RETIRED_PLUGIN_TYPES = new Map([
144
+ ['ts-only', 'frontend'],
145
+ ['rust', 'backend'],
146
+ ['rust-ts', 'full'],
147
+ ['wasm', 'full'],
148
+ ])
140
149
  // 装配角色(manifest `type`,ADR 0032):真源 = wasm-core `PluginKind`。
141
150
  // `system` / `application` 是历史拼写,宿主反序列化仍按别名接受,这里只告警。
142
151
  const VALID_PLUGIN_KINDS = new Set(['basic-service', 'internal-business', 'business-app'])
@@ -194,9 +203,14 @@ function cmdValidate(flags) {
194
203
  }
195
204
 
196
205
  // pluginType / rustLibrary / wasmHash
206
+ // 形态三档(frontend / backend / full,2026-10-26 语义重定义,wasmnest-apps#21);
207
+ // 旧值(含移动端原 wasm)退役——点名拒绝并给出迁移出路
197
208
  if (manifest.pluginType && !VALID_PLUGIN_TYPES.has(manifest.pluginType)) {
209
+ const retired = RETIRED_PLUGIN_TYPES.get(manifest.pluginType)
198
210
  errors.push(
199
- `pluginType 非法: "${manifest.pluginType}"(允许: ${[...VALID_PLUGIN_TYPES].join(' / ')})`,
211
+ retired
212
+ ? `pluginType "${manifest.pluginType}" 已退役(形态三档重定义,2026-10-26,wasmnest-apps#21):改用 "${retired}"——词汇只表达形态,不表达后端语言`
213
+ : `pluginType 非法: "${manifest.pluginType}"(允许: ${[...VALID_PLUGIN_TYPES].join(' / ')})`,
200
214
  )
201
215
  }
202
216
  // type(装配角色):非法取值构建期拒;历史拼写只告警(宿主仍按别名接受)
@@ -211,8 +225,8 @@ function cmdValidate(flags) {
211
225
  )
212
226
  }
213
227
  }
214
- if (manifest.pluginType === 'wasm' && !manifest.rustLibrary) {
215
- errors.push('pluginType=wasm 时必须提供 rustLibrary(与 Cargo.toml 包名一致)')
228
+ if (manifest.pluginType === 'full' && !manifest.rustLibrary) {
229
+ errors.push('pluginType=full 时必须提供 rustLibrary(与 Cargo.toml 包名一致)')
216
230
  }
217
231
  if (manifest.wasmHash !== undefined && !WASM_HASH_RE.test(manifest.wasmHash)) {
218
232
  errors.push(`wasmHash 格式非法: "${manifest.wasmHash}"(应为 sha256-<64位hex>)`)
@@ -147,5 +147,5 @@ dev-shell/src/
147
147
  浏览器模拟,发布前仍按 `../../../docs/wasm-app-dev-mobile.md` 验证清单过真机。
148
148
  - **应用在「应用」页点启动没反应**:dev-shell 的启动即重新跑一次插件 `activate()`;
149
149
  若插件在 activate 期抛错,详情页会显示错误原因,日志面板同步记 error。
150
- - **权限开关是灰的**:预览环境没有可写的权限真源(`setPermissionGrant` 恒返回 false),
150
+ - **权限清单是只读的**:预览环境没有逐项授权写面(与真机宿主 / 桌面端同口径),
151
151
  权限逻辑请到真机验证。
@@ -6,15 +6,19 @@
6
6
  * 组件,插件开发者在这里能确认自己的 slot 组件在壳的布局里表现如何(而不是自己
7
7
  * 搭一个假首页去验)。
8
8
  *
9
- * 卡片内容由应用自持(壳只传 app 上下文,不解释「N 个会话」是什么);
10
- * 应用自带的卡片也不负责打开应用——打开由壳的宫格 / 列表承担。
9
+ * 外观用 SDK 公共 QuickCard(`src/ui/QuickCard.vue`;dev-shell 不装自己的 npm 包,
10
+ * 故以内联源码路径引用)。点击与跳转归宿主壳——整张卡由壳包成按钮并打开本应用,
11
+ * 卡片内不再放按钮 / 交互。
11
12
  */
12
13
  import { computed, onMounted, onUnmounted, ref } from 'vue'
14
+ import QuickCard from '../../../../src/ui/QuickCard.vue'
13
15
  import { sessions } from '../../mock/session'
14
16
 
15
17
  /** 壳透传的应用上下文(本卡不消费,留着是为了与 slot 契约一致) */
16
18
  defineProps<{ app?: { id: string; name: string } }>()
17
19
 
20
+ const ICON = ['M4 5h16v14H4z', 'M8 10l3 2.5-3 2.5', 'M13.5 15H16']
21
+
18
22
  const running = ref(0)
19
23
 
20
24
  function refresh(): void {
@@ -29,23 +33,11 @@ const hint = computed(() => `mock · ${running.value} running`)
29
33
  </script>
30
34
 
31
35
  <template>
32
- <div
33
- class="w-full text-left rounded-[12px] border border-[var(--mobile-border)] bg-[var(--mobile-bg-card)] p-3.5"
34
- :style="{ boxShadow: 'var(--mobile-card-shadow)' }"
35
- >
36
- <span class="flex items-center gap-1.5 text-[var(--font-size-xs)] text-[var(--mobile-text-secondary)]">
37
- <span
38
- class="w-1.5 h-1.5 rounded-full flex-shrink-0"
39
- style="background: var(--mobile-success)"
40
- aria-hidden="true"
41
- />
42
- mock-terminal
43
- </span>
44
- <span class="mt-1.5 block text-[var(--font-size-base)] font-semibold text-[var(--mobile-text-primary)]">
45
- {{ running }} sessions
46
- </span>
47
- <span class="mt-1 block text-[var(--font-size-xs)] text-[var(--mobile-text-secondary)]">
48
- {{ hint }}
49
- </span>
50
- </div>
36
+ <QuickCard
37
+ label="mock-terminal"
38
+ :value="running"
39
+ :hint="hint"
40
+ :tone="running > 0 ? 'success' : 'neutral'"
41
+ :icon-path="ICON"
42
+ />
51
43
  </template>
@@ -31,6 +31,9 @@ export const enShell = {
31
31
  switchTo: 'Switch to {name}',
32
32
  stopInstance: 'Stop',
33
33
  slotsTitle: 'Quick cards',
34
+ slotOpen: 'Open {name}',
35
+ slotPause: 'Pause carousel',
36
+ slotPlay: 'Play carousel',
34
37
  appsTitle: 'My WASM apps',
35
38
  appsNote: '{count} installed',
36
39
  manageApps: 'Manage apps',
@@ -69,9 +72,10 @@ export const enShell = {
69
72
  state: 'Runtime state',
70
73
  permissions: 'Permissions',
71
74
  permissionsNote: '{granted} granted · {locked} by default',
72
- permissionLocked: 'Granted by default · cannot be turned off',
75
+ permissionsReadonly:
76
+ 'Permissions are declared by the app package and decided as a whole by the host; read-only here, cannot be changed per item.',
77
+ permissionLocked: 'Granted by default · cannot be changed',
73
78
  permissionUnsupported: 'Per-permission toggles are not supported by the current backend',
74
- permissionToggleFailed: 'Permission change not applied: {reason}',
75
79
  storage: 'Storage',
76
80
  appData: 'App data',
77
81
  grants: 'Grant log',
@@ -31,6 +31,9 @@ export const zhCNShell = {
31
31
  switchTo: '切换到 {name}',
32
32
  stopInstance: '停止',
33
33
  slotsTitle: '快捷卡片',
34
+ slotOpen: '打开 {name}',
35
+ slotPause: '暂停轮播',
36
+ slotPlay: '开始轮播',
34
37
  appsTitle: '我的 WASM 应用',
35
38
  appsNote: '{count} 个已安装',
36
39
  manageApps: '应用管理',
@@ -69,9 +72,9 @@ export const zhCNShell = {
69
72
  state: '运行状态',
70
73
  permissions: '权限',
71
74
  permissionsNote: '{granted} 项已授予 · {locked} 项默认',
72
- permissionLocked: '默认授予 · 不可关闭',
75
+ permissionsReadonly: '权限随应用包声明,宿主整单裁决;此处只读,不可逐项变更。',
76
+ permissionLocked: '默认授予 · 不可变更',
73
77
  permissionUnsupported: '当前后端不支持逐项开关权限',
74
- permissionToggleFailed: '权限变更未生效:{reason}',
75
78
  storage: '存储',
76
79
  appData: '应用数据',
77
80
  grants: '授权记录',
@@ -36,6 +36,7 @@ import {
36
36
  import { dialogService } from './mock/dialog-service'
37
37
  import PluginContextHost from './shell/components/PluginContextHost.vue'
38
38
  import { getShellRegistry } from './shell/registry'
39
+ import { subscribeSurfaceIntent } from './shell/surfaceIntent'
39
40
  import { getSharedModule } from './shared-runtime'
40
41
  import {
41
42
  findRoute,
@@ -52,6 +53,27 @@ function storageKey(pluginId: string, key: string): string {
52
53
  }
53
54
 
54
55
  /** 创建插件的 PluginContext */
56
+ /**
57
+ * 把插件的消息树展平为「完整点分 key → 叶子值」(与宿主 context.ts 同口径)
58
+ *
59
+ * 不展平时嵌套消息(`{ hub: { slotTitle } }`)会被挂成带点对象,`t()` 路径寻址
60
+ * 在第二段就断,插件文案全部回退成 key 字面量——预览与真机表现不一致。
61
+ */
62
+ function flattenMessages(
63
+ source: Record<string, unknown>,
64
+ prefix: string,
65
+ out: Record<string, unknown>,
66
+ ): void {
67
+ for (const [key, value] of Object.entries(source)) {
68
+ const fullKey = prefix ? `${prefix}.${key}` : key
69
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
70
+ flattenMessages(value as Record<string, unknown>, fullKey, out)
71
+ } else {
72
+ out[fullKey] = value
73
+ }
74
+ }
75
+ }
76
+
55
77
  export function createMockContext(pluginId: string): PluginContext {
56
78
  const disposables: Disposable[] = []
57
79
  // 供 ui.showDialog 闭包惰性引用(与桌面端 dev-shell 同模式,调用时 context 已初始化)
@@ -123,6 +145,10 @@ export function createMockContext(pluginId: string): PluginContext {
123
145
  registerSlot(slot) {
124
146
  return track(shellRegistry.registerSlot(pluginId, slot))
125
147
  },
148
+ onSurfaceIntent(handler) {
149
+ // 与宿主同构:入口意图按 appId 排队,订阅前到达的补投(见 shell/surfaceIntent.ts)
150
+ return track(subscribeSurfaceIntent(pluginId, handler))
151
+ },
126
152
  registerCapsuleItem(item) {
127
153
  return track(shellRegistry.registerCapsuleItem(pluginId, item))
128
154
  },
@@ -214,11 +240,8 @@ export function createMockContext(pluginId: string): PluginContext {
214
240
  const hostI18n = (window as any).__WASMNEST_SHARED__?.i18n
215
241
  if (!hostI18n) return
216
242
  const prefixed: Record<string, unknown> = {}
217
- for (const [key, value] of Object.entries(messages)) {
218
- prefixed[`${pluginId}.${key}`] = value
219
- }
220
- const existing = hostI18n.global.getLocaleMessage(locale)
221
- hostI18n.global.mergeLocaleMessage(locale, { ...existing, ...prefixed })
243
+ flattenMessages(messages, pluginId, prefixed)
244
+ hostI18n.global.mergeLocaleMessage(locale, prefixed)
222
245
  },
223
246
  t(key: string, params?: Record<string, unknown>): string {
224
247
  const hostI18n = (window as any).__WASMNEST_SHARED__?.i18n
@@ -8,9 +8,8 @@
8
8
  * 两处与宿主不同,都是浏览器环境的必然结果,不是偷懒:
9
9
  * 1. 启动 = `loader.activatePlugin`(重新跑插件 activate),停止 = `deactivatePlugin`;
10
10
  * 没有 WASM 后端,也就没有宿主那套 runtime 生命周期。
11
- * 2. 权限授予是纯展示:dev-shell 全程跳过权限检查(README「Mock 边界」已声明),
12
- * 因此 setPermissionGrant 明确返回 false,壳据此把开关置灰并说明原因——
13
- * 不做「本地写一下就假装生效」的降级。
11
+ * 2. 权限是纯展示:dev-shell 全程跳过权限检查(README「Mock 边界」已声明),
12
+ * 没有逐项授权写面;适配器不实现 setPermissionGrant,详情页只读呈现。
14
13
  */
15
14
 
16
15
  import { plugins, type DevPluginRecord } from '../../registry'
@@ -129,16 +128,6 @@ export function createDevAppSource(deps: DevAppSourceDeps): ShellAppSource {
129
128
  await deps.deactivate(appId)
130
129
  },
131
130
 
132
- /**
133
- * 逐项权限开关:dev-shell 全程跳过权限检查,没有可写的真源
134
- *
135
- * 明确返回 false,让壳把开关置灰并说明——「点了就通过」的假成功会让插件开发者
136
- * 误以为权限逻辑已验证。
137
- */
138
- async setPermissionGrant(): Promise<boolean> {
139
- return false
140
- },
141
-
142
131
  /**
143
132
  * 延迟解析运行面
144
133
  *
@@ -33,6 +33,24 @@
33
33
  {{ t('shell.notify.count', { count: totalCount }) }}
34
34
  </p>
35
35
  </div>
36
+ <!-- 清除全部:面板右上角的扫除图标(2026-11-01 用户裁决,底部整行文字按钮退役)。
37
+ 图标按钮无可见文字,可访问名走 aria-label;没有可清条目时不渲染。 -->
38
+ <button
39
+ v-if="hasClearable"
40
+ type="button"
41
+ class="flex items-center justify-center rounded-[10px] min-w-[var(--mobile-touch-target-min)] min-h-[var(--mobile-touch-target-min)] transition-colors duration-200 active:bg-[var(--mobile-accent-muted)] disabled:opacity-40"
42
+ :aria-label="t('shell.notify.clearAll')"
43
+ :disabled="clearingAll"
44
+ @click="clearAllCascade"
45
+ >
46
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
47
+ <path d="M20.5 3.5 13 11" />
48
+ <path d="M10.9 8.9 15.1 13.1" />
49
+ <path d="M10.8 9.6 5.6 15.4" />
50
+ <path d="M12.4 11.2 8.2 17.4" />
51
+ <path d="M14 12.8 11 18.8" />
52
+ </svg>
53
+ </button>
36
54
  <button
37
55
  type="button"
38
56
  class="flex items-center justify-center rounded-[10px] min-w-[var(--mobile-touch-target-min)] min-h-[var(--mobile-touch-target-min)] transition-colors duration-200 active:bg-[var(--mobile-accent-muted)]"
@@ -216,22 +234,6 @@
216
234
  </p>
217
235
  </div>
218
236
  </div>
219
-
220
- <!-- 底部动作:清除全部。触发级联飞离动画(等差异步右飞),全部飞出后才真正
221
- 清空 store——删除要有可见表达,而不是瞬间消失。级联期间按钮禁用防重入。 -->
222
- <div
223
- v-if="notifications.length > 0"
224
- class="flex-shrink-0 border-t border-[var(--mobile-group-divider)] px-4 py-3"
225
- >
226
- <button
227
- type="button"
228
- class="shell-btn-danger-outline w-full rounded-[10px] px-4 py-2.5 text-[var(--font-size-base)] min-h-[var(--mobile-touch-target-min)]"
229
- :disabled="clearingAll"
230
- @click="clearAllCascade"
231
- >
232
- {{ t('shell.notify.clearAll') }}
233
- </button>
234
- </div>
235
237
  </section>
236
238
  </Transition>
237
239
  </Teleport>
@@ -242,7 +244,8 @@
242
244
  * 通知栏(Android 式独立通知面)
243
245
  * -----------------------------------------------------------------------------
244
246
  * 打开入口在状态条与主屏铃铛(见 ShellStatusbar / ShellHomeScreen),本组件只负责
245
- * 面板本身:待处理(审批派生)+ 通知(壳动作 / 宿主引擎事件)+ 清除全部。
247
+ * 面板本身:待处理(审批派生)+ 通知(壳动作 / 宿主引擎事件);「清除全部」是面板
248
+ * 右上角的扫除图标按钮(2026-11-01 用户裁决),不再占一条底部动作栏。
246
249
  *
247
250
  * 为什么不接管「顶部边缘下拉」手势:Android 上从屏幕最顶端下拉属于**系统**手势
248
251
  * (拉出系统通知栏),应用层再实现一次会与之冲突(ui-ux-pro-max `--domain ux`
@@ -276,6 +279,8 @@ const { notifications, notificationCount, dismissNotification, clearNotification
276
279
  const open = computed(() => overlays.shadeOpen.value)
277
280
  const pendingApps = computed(() => apps.value.filter((a) => a.state === 'approval'))
278
281
  const totalCount = computed(() => notificationCount.value + pendingApps.value.length)
282
+ /** 只剩驻留项时「清除全部」是 no-op:不渲染入口(与宿主同一口径) */
283
+ const hasClearable = computed(() => notifications.value.some((n) => !n.sticky))
279
284
 
280
285
  /** 相对时间随面板打开而刷新:否则「3 分钟前」会一直停在打开那一刻的读数 */
281
286
  const now = ref(Date.now())