@binblink/wasmnest-plugin-sdk-mobile 0.0.0-stage → 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 (122) hide show
  1. package/README.md +439 -2
  2. package/README_en.md +415 -0
  3. package/bin/build.js +271 -0
  4. package/bin/cli.js +96 -0
  5. package/bin/lib.js +349 -0
  6. package/bin/manifest-gen.js +327 -0
  7. package/bin/package.js +151 -0
  8. package/bin/scaffold.js +299 -0
  9. package/dev-shell/README.md +151 -0
  10. package/dev-shell/index.html +27 -0
  11. package/dev-shell/package.json +27 -0
  12. package/dev-shell/pnpm-workspace.yaml +9 -0
  13. package/dev-shell/postcss.config.js +6 -0
  14. package/dev-shell/src/App.vue +90 -0
  15. package/dev-shell/src/apps/mock-terminal/MockTerminalSlotCard.vue +43 -0
  16. package/dev-shell/src/apps/mock-terminal/MockTerminalView.vue +168 -0
  17. package/dev-shell/src/apps/mock-terminal/index.ts +50 -0
  18. package/dev-shell/src/components/DevToolbar.vue +100 -0
  19. package/dev-shell/src/components/DialogHost.vue +119 -0
  20. package/dev-shell/src/components/LogPanel.vue +80 -0
  21. package/dev-shell/src/i18n.ts +22 -0
  22. package/dev-shell/src/loader.ts +239 -0
  23. package/dev-shell/src/locale.ts +29 -0
  24. package/dev-shell/src/locales/en-shell.ts +332 -0
  25. package/dev-shell/src/locales/index.ts +70 -0
  26. package/dev-shell/src/locales/shell.ts +331 -0
  27. package/dev-shell/src/main.ts +58 -0
  28. package/dev-shell/src/mock/dialog-service.ts +58 -0
  29. package/dev-shell/src/mock/file-transfer.ts +390 -0
  30. package/dev-shell/src/mock/mobile-api.ts +369 -0
  31. package/dev-shell/src/mock/preset-tasks.ts +186 -0
  32. package/dev-shell/src/mock/session.ts +121 -0
  33. package/dev-shell/src/mock-context.ts +374 -0
  34. package/dev-shell/src/registry.ts +151 -0
  35. package/dev-shell/src/shared-runtime.ts +44 -0
  36. package/dev-shell/src/shell/ShellView.vue +52 -0
  37. package/dev-shell/src/shell/adapters/devAppSource.ts +144 -0
  38. package/dev-shell/src/shell/components/PluginContextHost.vue +40 -0
  39. package/dev-shell/src/shell/components/ShellAppCell.vue +75 -0
  40. package/dev-shell/src/shell/components/ShellAppIcon.vue +111 -0
  41. package/dev-shell/src/shell/components/ShellAppSurface.vue +46 -0
  42. package/dev-shell/src/shell/components/ShellBrandTile.vue +27 -0
  43. package/dev-shell/src/shell/components/ShellCapsuleMenu.vue +123 -0
  44. package/dev-shell/src/shell/components/ShellChip.vue +49 -0
  45. package/dev-shell/src/shell/components/ShellGroupCard.vue +17 -0
  46. package/dev-shell/src/shell/components/ShellHost.vue +75 -0
  47. package/dev-shell/src/shell/components/ShellNotificationShade.vue +501 -0
  48. package/dev-shell/src/shell/components/ShellPermissionPrompt.vue +127 -0
  49. package/dev-shell/src/shell/components/ShellPlaceholderSurface.vue +33 -0
  50. package/dev-shell/src/shell/components/ShellSection.vue +27 -0
  51. package/dev-shell/src/shell/components/ShellSheet.vue +74 -0
  52. package/dev-shell/src/shell/components/ShellStatusbar.vue +84 -0
  53. package/dev-shell/src/shell/components/screens/PluginRoutePage.vue +98 -0
  54. package/dev-shell/src/shell/components/screens/ShellAppDetailScreen.vue +359 -0
  55. package/dev-shell/src/shell/components/screens/ShellAppRunScreen.vue +90 -0
  56. package/dev-shell/src/shell/components/screens/ShellAppsScreen.vue +195 -0
  57. package/dev-shell/src/shell/components/screens/ShellHomeScreen.vue +357 -0
  58. package/dev-shell/src/shell/components/screens/ShellPermissionsScreen.vue +376 -0
  59. package/dev-shell/src/shell/components/screens/ShellSettingsScreen.vue +240 -0
  60. package/dev-shell/src/shell/components/screens/ShellSwitcherScreen.vue +559 -0
  61. package/dev-shell/src/shell/components/ui/ConfirmDialog.vue +137 -0
  62. package/dev-shell/src/shell/components/ui/Toggle.vue +53 -0
  63. package/dev-shell/src/shell/composables/useShellApps.ts +417 -0
  64. package/dev-shell/src/shell/composables/useShellNavigation.ts +197 -0
  65. package/dev-shell/src/shell/composables/useShellNotifications.ts +115 -0
  66. package/dev-shell/src/shell/composables/useShellOpen.ts +44 -0
  67. package/dev-shell/src/shell/composables/useShellOverlays.ts +101 -0
  68. package/dev-shell/src/shell/composables/useShellPreferences.ts +143 -0
  69. package/dev-shell/src/shell/composables/useShellRecent.ts +84 -0
  70. package/dev-shell/src/shell/composables/useSlotCarousel.ts +238 -0
  71. package/dev-shell/src/shell/composables/useToast.ts +33 -0
  72. package/dev-shell/src/shell/index.ts +88 -0
  73. package/dev-shell/src/shell/logger.ts +45 -0
  74. package/dev-shell/src/shell/permissions.ts +145 -0
  75. package/dev-shell/src/shell/registry.ts +220 -0
  76. package/dev-shell/src/shell/slotCards.ts +47 -0
  77. package/dev-shell/src/shell/styles/shell.css +1155 -0
  78. package/dev-shell/src/shell/surfaceIntent.ts +107 -0
  79. package/dev-shell/src/shell/types.ts +152 -0
  80. package/dev-shell/src/shell/utils.ts +54 -0
  81. package/dev-shell/src/styles/main.css +153 -0
  82. package/dev-shell/src/styles/mobile.css +981 -0
  83. package/dev-shell/src/styles/wallpaper.css +130 -0
  84. package/dev-shell/src/theme.ts +71 -0
  85. package/dev-shell/src/vite-env.d.ts +20 -0
  86. package/dev-shell/tailwind.config.js +101 -0
  87. package/dev-shell/tsconfig.json +16 -0
  88. package/dev-shell/vite.config.ts +130 -0
  89. package/dist/index.d.ts +124 -0
  90. package/dist/index.js +229 -0
  91. package/dist/types.d.ts +738 -0
  92. package/dist/types.js +0 -0
  93. package/dist/vite-plugin.d.ts +16 -0
  94. package/dist/vite-plugin.js +95 -0
  95. package/package.json +88 -3
  96. package/src/constants.ts +6 -0
  97. package/src/global-dialog.ts +168 -0
  98. package/src/index.ts +96 -0
  99. package/src/runtime.ts +44 -0
  100. package/src/types.ts +822 -0
  101. package/src/ui/AppUpdateSection.d.ts +44 -0
  102. package/src/ui/AppUpdateSection.vue +253 -0
  103. package/src/ui/PluginGlobalDialog.vue +388 -0
  104. package/src/ui/QuickCard.d.ts +33 -0
  105. package/src/ui/QuickCard.vue +167 -0
  106. package/src/ui/Select.d.ts +37 -0
  107. package/src/ui/Select.vue +307 -0
  108. package/src/ui/plugin-global-dialog.d.ts +11 -0
  109. package/src/ui/useSwipeTabs.d.ts +20 -0
  110. package/src/ui/useSwipeTabs.ts +53 -0
  111. package/src/update.ts +123 -0
  112. package/src/vite-plugin.ts +132 -0
  113. package/template/.gitignore +4 -0
  114. package/template/README.md +46 -0
  115. package/template/package.json +23 -0
  116. package/template/plugin.json +13 -0
  117. package/template/rust/Cargo.toml +19 -0
  118. package/template/rust/src/lib.rs +33 -0
  119. package/template/src/env.d.ts +24 -0
  120. package/template/src/index.ts +37 -0
  121. package/template/tsconfig.json +17 -0
  122. package/template/vite.config.ts +21 -0
@@ -0,0 +1,220 @@
1
+ /**
2
+ * Dev Shell 宿主壳注册表
3
+ * -----------------------------------------------------------------------------
4
+ * 结构与宿主 `wasmnest-mobile/src/shell/registry.ts` 同构(只做注册/撤销/查询,
5
+ * 不做 UI 决策、不感知数据来源)。
6
+ *
7
+ * 与宿主的唯一差异是数据源:宿主的数据源是插件系统(真后端),dev-shell 的数据源
8
+ * 是 `adapters/devAppSource.ts`(把被调试插件记录投影成应用)。壳内组件对两者无感——
9
+ * 这正是这套分层要保证的事:换真源只换数据源实现。
10
+ *
11
+ * 同构纪律:改这里之前先看宿主那份,两边结构应保持一致;字段级漂移由
12
+ * `__tests__/shell/contractDrift.test.ts` 兜底。
13
+ */
14
+
15
+ import { ref, markRaw, type Ref } from 'vue'
16
+ import type {
17
+ Disposable,
18
+ ShellApp,
19
+ ShellAppSource,
20
+ ShellCapsuleItem,
21
+ ShellSlotContribution,
22
+ ShellSurfaceContribution,
23
+ } from './types'
24
+
25
+ /** 单个应用的增量贡献集合(键为贡献项 id,重复注册即覆盖) */
26
+ interface ContributionStore {
27
+ slots: Map<string, ShellSlotContribution>
28
+ capsuleItems: Map<string, ShellCapsuleItem>
29
+ surface?: ShellSurfaceContribution
30
+ }
31
+
32
+ /** 应用记录归属:哪个数据源写入的,清理时按源整体回收 */
33
+ interface AppRecord {
34
+ sourceId: string
35
+ app: ShellApp
36
+ }
37
+
38
+ function emptyContributions(): ContributionStore {
39
+ return { slots: new Map(), capsuleItems: new Map() }
40
+ }
41
+
42
+ /** 宿主壳注册表 */
43
+ class ShellRegistryClass {
44
+ private readonly apps = new Map<string, AppRecord>()
45
+ private readonly sources = new Map<string, ShellAppSource>()
46
+ private readonly contributions = new Map<string, ContributionStore>()
47
+
48
+ /** 响应式应用清单(供壳内组件消费) */
49
+ readonly appsRef: Ref<ShellApp[]> = ref([])
50
+
51
+ // ==================== 数据源 ====================
52
+
53
+ /** 注册应用数据源;重复注册同一 id 覆盖旧源 */
54
+ registerSource(source: ShellAppSource): Disposable {
55
+ this.sources.set(source.id, source)
56
+ return {
57
+ dispose: () => {
58
+ this.sources.delete(source.id)
59
+ },
60
+ }
61
+ }
62
+
63
+ /** 已注册的数据源(按注册顺序) */
64
+ listSources(): ShellAppSource[] {
65
+ return [...this.sources.values()]
66
+ }
67
+
68
+ // ==================== 应用清单 ====================
69
+
70
+ /**
71
+ * 全量覆盖某数据源的应用清单
72
+ *
73
+ * 清单自带的 contributions 会并入增量贡献表(同 id 覆盖),因此「清单下发」与
74
+ * 「运行时注册」两条路径最终合并为同一份视图。
75
+ */
76
+ upsertApps(sourceId: string, apps: ShellApp[]): void {
77
+ for (const app of apps) {
78
+ this.apps.set(app.id, { sourceId, app })
79
+ this.mergeContributions(app.id, app.contributions)
80
+ }
81
+ // 该数据源本次未返回的应用视为已卸载:回收其记录与贡献
82
+ const alive = new Set(apps.map((a) => a.id))
83
+ for (const [id, rec] of [...this.apps.entries()]) {
84
+ if (rec.sourceId === sourceId && !alive.has(id)) this.apps.delete(id)
85
+ }
86
+ this.publish()
87
+ }
88
+
89
+ /** 单个应用的状态补丁(启动/停止/失败后回写,避免整表重拉) */
90
+ patchApp(appId: string, patch: Partial<ShellApp>): void {
91
+ const rec = this.apps.get(appId)
92
+ if (!rec) return
93
+ rec.app = { ...rec.app, ...patch }
94
+ this.publish()
95
+ }
96
+
97
+ /** 获取应用(含合并后的贡献) */
98
+ getApp(appId: string): ShellApp | undefined {
99
+ const rec = this.apps.get(appId)
100
+ if (!rec) return undefined
101
+ return this.toView(rec.app)
102
+ }
103
+
104
+ /** 清理单个应用(记录 + 贡献) */
105
+ clearApp(appId: string): void {
106
+ this.apps.delete(appId)
107
+ this.contributions.delete(appId)
108
+ this.publish()
109
+ }
110
+
111
+ /** 清理某数据源写入的全部应用 */
112
+ clearSource(sourceId: string): void {
113
+ for (const [id, rec] of [...this.apps.entries()]) {
114
+ if (rec.sourceId === sourceId) {
115
+ this.apps.delete(id)
116
+ this.contributions.delete(id)
117
+ }
118
+ }
119
+ this.publish()
120
+ }
121
+
122
+ /** 应用所属数据源(按来源解析延迟能力,如运行面组件) */
123
+ getSourceOf(appId: string): ShellAppSource | undefined {
124
+ const rec = this.apps.get(appId)
125
+ if (!rec) return undefined
126
+ return this.sources.get(rec.sourceId)
127
+ }
128
+
129
+ // ==================== 界面贡献 ====================
130
+
131
+ /** 注册首页快捷卡片 */
132
+ registerSlot(appId: string, slot: ShellSlotContribution): Disposable {
133
+ const store = this.storeFor(appId)
134
+ store.slots.set(slot.id, { ...slot, component: markRaw(slot.component) })
135
+ this.publish()
136
+ return { dispose: () => this.drop(store.slots, slot.id) }
137
+ }
138
+
139
+ /** 注册应用运行面 */
140
+ registerSurface(appId: string, surface: ShellSurfaceContribution): Disposable {
141
+ const store = this.storeFor(appId)
142
+ store.surface = { ...surface, component: markRaw(surface.component) }
143
+ this.publish()
144
+ return {
145
+ dispose: () => {
146
+ if (store.surface?.component === surface.component) store.surface = undefined
147
+ this.publish()
148
+ },
149
+ }
150
+ }
151
+
152
+ /** 注册胶囊菜单附加项 */
153
+ registerCapsuleItem(appId: string, item: ShellCapsuleItem): Disposable {
154
+ const store = this.storeFor(appId)
155
+ store.capsuleItems.set(item.id, item)
156
+ this.publish()
157
+ return { dispose: () => this.drop(store.capsuleItems, item.id) }
158
+ }
159
+
160
+ // ==================== 内部 ====================
161
+
162
+ private storeFor(appId: string): ContributionStore {
163
+ let store = this.contributions.get(appId)
164
+ if (!store) {
165
+ store = emptyContributions()
166
+ this.contributions.set(appId, store)
167
+ }
168
+ return store
169
+ }
170
+
171
+ private mergeContributions(appId: string, c: ShellApp['contributions']): void {
172
+ if (!c) return
173
+ const store = this.storeFor(appId)
174
+ for (const slot of c.slots ?? []) {
175
+ store.slots.set(slot.id, { ...slot, component: markRaw(slot.component) })
176
+ }
177
+ for (const item of c.capsuleItems ?? []) store.capsuleItems.set(item.id, item)
178
+ if (c.surface) {
179
+ store.surface = { ...c.surface, component: markRaw(c.surface.component) }
180
+ }
181
+ }
182
+
183
+ private drop(map: Map<string, unknown>, key: string): void {
184
+ map.delete(key)
185
+ this.publish()
186
+ }
187
+
188
+ /** 把存储模型投影为「含合并贡献」的视图模型 */
189
+ private toView(app: ShellApp): ShellApp {
190
+ const store = this.contributions.get(app.id)
191
+ if (!store) return { ...app, contributions: {} }
192
+ return {
193
+ ...app,
194
+ contributions: {
195
+ slots: [...store.slots.values()].sort(byOrder),
196
+ surface: store.surface,
197
+ capsuleItems: [...store.capsuleItems.values()].sort(byOrder),
198
+ },
199
+ }
200
+ }
201
+
202
+ /** 重算响应式清单 */
203
+ private publish(): void {
204
+ this.appsRef.value = [...this.apps.values()].map((rec) => this.toView(rec.app))
205
+ }
206
+ }
207
+
208
+ function byOrder<T extends { order?: number }>(a: T, b: T): number {
209
+ return (a.order ?? 100) - (b.order ?? 100)
210
+ }
211
+
212
+ /** 全局单例 */
213
+ const registry = new ShellRegistryClass()
214
+
215
+ /** 获取宿主壳注册表 */
216
+ export function getShellRegistry(): ShellRegistryClass {
217
+ return registry
218
+ }
219
+
220
+ export type { ShellRegistryClass }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * 首页快捷卡片选择
3
+ * -----------------------------------------------------------------------------
4
+ * 应用贡献的卡片可能远多于首页轨道能承载的量(每张一拍屏),宿主按注册顺序
5
+ * 取前 N 张并自动轮播;超出部分不展示,也不做「无限滚动」——轨道不是应用列表,
6
+ * 用户找完整应用入口走下方宫格 / 应用管理页。
7
+ *
8
+ * 顺序口径:应用注册顺序(壳清单顺序)→ 应用内槽位 order(registry 已排序)。
9
+ * 不按最近使用重排:卡片是应用自持内容的读数,位置漂移会让用户每次都要重新找。
10
+ */
11
+ import type { Component } from 'vue'
12
+ import type { ShellSurfaceIntent } from '../../../src/types'
13
+ import type { ShellApp } from './types'
14
+
15
+ /** 首页最多展示的快捷卡片数(一拍屏一张,5 张即一轮完整轮播) */
16
+ export const SHELL_SLOT_MAX_CARDS = 5
17
+
18
+ /** 首页轨道上的一张卡片视图 */
19
+ export interface ShellSlotCard {
20
+ /** 稳定 key:appId + 槽位 id(同一应用可贡献多张) */
21
+ key: string
22
+ component: Component
23
+ app: ShellApp
24
+ /** 点击时要投递给应用的入口意图(按点击时刻现算;缺省 = 只打开应用) */
25
+ onPress?: () => ShellSurfaceIntent | null | undefined
26
+ }
27
+
28
+ /** 按注册顺序摊平并截断到展示上限 */
29
+ export function selectSlotCards(
30
+ apps: readonly ShellApp[],
31
+ max: number = SHELL_SLOT_MAX_CARDS,
32
+ ): ShellSlotCard[] {
33
+ if (max <= 0) return []
34
+ const cards: ShellSlotCard[] = []
35
+ for (const app of apps) {
36
+ for (const slot of app.contributions.slots ?? []) {
37
+ if (cards.length >= max) return cards
38
+ cards.push({
39
+ key: `${app.id}:${slot.id}`,
40
+ component: slot.component,
41
+ app,
42
+ onPress: slot.onPress,
43
+ })
44
+ }
45
+ }
46
+ return cards
47
+ }