@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,107 @@
1
+ /**
2
+ * 运行面入口意图通道(dev-shell 版;与宿主 shell/surfaceIntent.ts 同构)
3
+ * -----------------------------------------------------------------------------
4
+ * 场景:应用在首页快捷卡片上写「3 个活跃会话」,点击应直接进入某个会话,而不是
5
+ * 只停在应用门口。每应用运行面是独立 Vue 应用、且切走保活不重挂,所以入口不能
6
+ * 靠「首次挂载参数」传——必须是**可重复投递的事件通道**。
7
+ *
8
+ * 契约分三段:
9
+ * 1. 应用在卡片注册里给 `onPress()`(`ShellSlotContribution.onPress`);
10
+ * 2. 宿主点击时照常「启动并打开应用」,再 `queueSurfaceIntent(appId, intent)`;
11
+ * 3. 应用运行面经 `context.ui.onSurfaceIntent` 订阅,订阅前到达的按序补投。
12
+ *
13
+ * 边界纪律:意图对宿主**完全不透明**——只有 appId(键控)与两个应用自定义字段
14
+ * (key / payload),宿主不读、不解释、不翻译。B1–B6 均不命中。
15
+ *
16
+ * 生命周期:意图只属于「这一次打开」。应用停用 / 卸载 / 运行面销毁时由
17
+ * `clearSurfaceIntents` 清空排队项,旧意图不会在下一次打开时突然生效;队列有上限,
18
+ * 应用永不消费时也不会无限增长。
19
+ */
20
+ import type { Disposable, ShellSurfaceIntent } from '../../../src/types'
21
+
22
+ /** 单应用最多排队的意图数(超出丢最旧的;只保留「最近几次点击」) */
23
+ export const SURFACE_INTENT_MAX_PENDING = 8
24
+
25
+ /** 待投递意图(订阅者出现前滞留) */
26
+ const pending = new Map<string, ShellSurfaceIntent[]>()
27
+
28
+ /** 已订阅的运行面(同一应用通常一个;按 Set 容忍多订阅,逐个投递) */
29
+ const subscribers = new Map<string, Set<(intent: ShellSurfaceIntent) => void>>()
30
+
31
+ /** 把排队意图投给当前订阅者;没有订阅者时保留排队 */
32
+ function flush(appId: string): void {
33
+ const queue = pending.get(appId)
34
+ const handlers = subscribers.get(appId)
35
+ if (!queue || queue.length === 0 || !handlers || handlers.size === 0) return
36
+ pending.delete(appId)
37
+ for (const intent of queue) {
38
+ for (const handler of handlers) handler(intent)
39
+ }
40
+ }
41
+
42
+ /**
43
+ * 投递一条入口意图(宿主点击路径调用,启动成功后入队)
44
+ *
45
+ * 空 appId / 空意图直接忽略(调用方语义上是「没有入口」,不是错误)。
46
+ */
47
+ export function queueSurfaceIntent(
48
+ appId: string,
49
+ intent: ShellSurfaceIntent | null | undefined,
50
+ ): void {
51
+ if (!appId || !intent) return
52
+ const queue = pending.get(appId) ?? []
53
+ queue.push(intent)
54
+ if (queue.length > SURFACE_INTENT_MAX_PENDING) {
55
+ queue.splice(0, queue.length - SURFACE_INTENT_MAX_PENDING)
56
+ }
57
+ pending.set(appId, queue)
58
+ flush(appId)
59
+ }
60
+
61
+ /**
62
+ * 应用运行面订阅入口意图(`context.ui.onSurfaceIntent` 的落点)
63
+ *
64
+ * 返回 Disposable:只摘本订阅者,不动排队项(其它订阅者仍可收到)。
65
+ */
66
+ export function subscribeSurfaceIntent(
67
+ appId: string,
68
+ handler: (intent: ShellSurfaceIntent) => void,
69
+ ): Disposable {
70
+ let handlers = subscribers.get(appId)
71
+ if (!handlers) {
72
+ handlers = new Set()
73
+ subscribers.set(appId, handlers)
74
+ }
75
+ handlers.add(handler)
76
+ // 订阅前到达的意图按序补投
77
+ flush(appId)
78
+ return {
79
+ dispose() {
80
+ const current = subscribers.get(appId)
81
+ if (!current) return
82
+ current.delete(handler)
83
+ if (current.size === 0) subscribers.delete(appId)
84
+ },
85
+ }
86
+ }
87
+
88
+ /**
89
+ * 清空某应用的排队意图(停用 / 卸载 / 运行面销毁)
90
+ *
91
+ * 不清订阅者:运行面真正销毁时其订阅会随插件上下文 dispose 自摘;这里是
92
+ * 防止「点了卡片但应用没起来 / 被停用」留下的旧意图劫持下一次打开。
93
+ */
94
+ export function clearSurfaceIntents(appId: string): void {
95
+ pending.delete(appId)
96
+ }
97
+
98
+ /** 测试隔离:清空全部排队与订阅 */
99
+ export function resetSurfaceIntents(): void {
100
+ pending.clear()
101
+ subscribers.clear()
102
+ }
103
+
104
+ /** 排障 / 测试:当前排队意图数(只读) */
105
+ export function pendingSurfaceIntentCount(appId: string): number {
106
+ return pending.get(appId)?.length ?? 0
107
+ }
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Dev Shell 宿主壳契约
3
+ * -----------------------------------------------------------------------------
4
+ * 本文件是 dev-shell 内置 mini 壳与「应用形态」之间的唯一契约面,字段与宿主
5
+ * `wasmnest-mobile/src/shell/types.ts` **逐字段一致**(同构要求:插件在 dev-shell
6
+ * 里跑通就必须能在真机壳里跑通,两边形态不同就没有调试价值)。
7
+ *
8
+ * 贡献描述符(surface / slot / capsuleItem / settingsEntry)不在这里重定义,
9
+ * 直接复用 SDK 的 `src/types.ts`——那是插件侧契约的真源,宿主壳与 dev-shell
10
+ * 都只是它的消费方。重定义一份只会制造第三处可能漂移的地方。
11
+ *
12
+ * 漂移防线:`__tests__/shell/contractDrift.test.ts` 比对本文件与宿主 types.ts
13
+ * 的字段集,宿主新增字段而这里没跟随时直接测红。
14
+ *
15
+ * 边界纪律(与 docs/architecture.md §1 同源):壳只回答「平台怎么组织应用」,不回答
16
+ * 「某个应用做什么业务」。应用内部的业务由其 surface 组件自持。
17
+ */
18
+
19
+ import type { Component } from 'vue'
20
+ import type {
21
+ ShellCapsuleItem,
22
+ ShellSlotContribution,
23
+ ShellSurfaceContribution,
24
+ } from '../../../src/types'
25
+
26
+ export type {
27
+ ShellCapsuleItem,
28
+ ShellSlotContribution,
29
+ ShellSurfaceContribution,
30
+ }
31
+
32
+ /** 可释放句柄:注册扩展点的返回值,dispose 即摘除该注册 */
33
+ export interface Disposable {
34
+ dispose(): void
35
+ }
36
+
37
+ /** 应用在壳内的运行态(壳语义,与宿主 union 逐字一致) */
38
+ export type ShellAppState =
39
+ /** 前台/后台运行中 */
40
+ | 'running'
41
+ /** 已安装但未启动 */
42
+ | 'stopped'
43
+ /** 待人工审批(权限整单批准 + 内容哈希钉扎):批准前不可启动 */
44
+ | 'approval'
45
+ /** 被用户或平台停用(启用后才可启动) */
46
+ | 'disabled'
47
+ /** 上次启动失败(保留数据,可重试) */
48
+ | 'error'
49
+
50
+ /** 单条权限的授予情况 */
51
+ export interface ShellPermissionGrant {
52
+ /** 权限词(与移动端权限词汇真源一致,如 terminal:output / fs:write / bus) */
53
+ key: string
54
+ /** 是否已授予 */
55
+ granted: boolean
56
+ /** 默认授予且不可关闭(storage 等底座能力):置灰并标注,不隐藏 */
57
+ locked?: boolean
58
+ /** 授予范围补充说明 */
59
+ scope?: string
60
+ }
61
+
62
+ /** 应用对宿主壳的全部贡献(可随清单下发,也可运行时逐项注册) */
63
+ export interface ShellAppContributions {
64
+ slots?: ShellSlotContribution[]
65
+ surface?: ShellSurfaceContribution
66
+ capsuleItems?: ShellCapsuleItem[]
67
+ }
68
+
69
+ /** 宿主壳中的应用模型 */
70
+ export interface ShellApp {
71
+ id: string
72
+ name: string
73
+ version: string
74
+ description?: string
75
+ author?: string
76
+ /** 图标:emoji / SVG path d / 相对插件目录的图片路径(如 icon.svg);都取不到时壳生成首字母回退 */
77
+ icon?: string
78
+ /**
79
+ * 图片图标的已解析地址(asset protocol URL):数据源能解析时必须给出,否则首字母回退。
80
+ * dev-shell 的浏览器预览读不到插件包内资源(adapters/devAppSource.ts 的 resolveIcon 会把
81
+ * 图片路径换成通用 path 图形),因此调试数据源当前不产出该字段;保留字段是为与宿主
82
+ * ShellApp 契约逐字一致(dev-shell/__tests__/shell/contractDrift.test.ts 钉住)。
83
+ */
84
+ iconUrl?: string
85
+ /** 官方应用标记 */
86
+ official?: boolean
87
+ /** 装配角色(manifest kind;系统服务分区判据) */
88
+ kind?: string
89
+ state: ShellAppState
90
+ permissions: ShellPermissionGrant[]
91
+ /** 应用数据占用(字节);未统计时 undefined,UI 显示「—」而非伪造 0 */
92
+ sizeBytes?: number
93
+ /** 上一次失败的简短原因(state === 'error' 时展示) */
94
+ error?: string
95
+ /** manifest `update` 段(缺省 = 不参与更新检查;与宿主 ShellApp 契约逐字一致) */
96
+ update?: {
97
+ provider?: 'github-release'
98
+ repo?: string
99
+ tagPrefix?: string
100
+ slug?: string
101
+ }
102
+ contributions: ShellAppContributions
103
+ }
104
+
105
+ /**
106
+ * 应用数据源:壳与具体应用形态之间的唯一耦合面
107
+ *
108
+ * 能力可选:不支持的能力不实现该方法,壳据此不渲染对应入口,不做静默降级。
109
+ */
110
+ /**
111
+ * 本地包安装的「旧数据是否恢复」询问(与宿主同形状)
112
+ *
113
+ * dev-shell 当前没有安装能力的数据源,保留同构签名只为契约不漂移:
114
+ * 将来接安装时按宿主口径在落盘前询问(默认不恢复)。
115
+ */
116
+ export type ShellInstallRestoreDecider = (info: { pluginId: string }) => Promise<boolean | null>
117
+
118
+ export interface ShellAppSource {
119
+ /** 数据源标识(日志与诊断用) */
120
+ readonly id: string
121
+ /** 拉取应用清单(全量覆盖该数据源此前的记录) */
122
+ list(): Promise<ShellApp[]>
123
+ /** 启动应用(幂等:已运行直接返回) */
124
+ launch(appId: string): Promise<void>
125
+ /** 停止应用(幂等:未运行直接返回) */
126
+ stop(appId: string): Promise<void>
127
+ /** 逐项变更权限授予;@returns true 已生效,false 不支持(壳据此置灰并说明) */
128
+ setPermissionGrant?(
129
+ appId: string,
130
+ permissionKey: string,
131
+ granted: boolean,
132
+ ): Promise<boolean>
133
+ /**
134
+ * 批准应用的权限申请(整单:批准全部声明权限 + 内容哈希钉扎)。
135
+ * 未实现时壳不渲染「批准」入口——不提供点了没反应的按钮。
136
+ */
137
+ approve?(appId: string): Promise<void>
138
+ /** 延迟解析运行面组件;未实现时壳回退到应用自带的 contributions.surface */
139
+ resolveSurface?(appId: string): Component | undefined
140
+ /**
141
+ * 安装本地应用包(数据源自行完成选包与校验)。
142
+ *
143
+ * @returns 安装后的应用 id;`null` = 用户取消选包或取消恢复询问(不是失败)。
144
+ * 未实现时壳不渲染「安装本地包」入口——不提供点了没反应的按钮。
145
+ */
146
+ installFromLocalPackage?(decideRestore?: ShellInstallRestoreDecider): Promise<string | null>
147
+ /** 卸载应用并删除其数据;未实现时壳不渲染「卸载」入口 */
148
+ remove?(appId: string): Promise<boolean>
149
+ /** 查询 / 设置「启动时自动激活」偏好(未实现时壳不渲染自启开关) */
150
+ isAutostart?(appId: string): Promise<boolean>
151
+ setAutostart?(appId: string, autostart: boolean): Promise<void>
152
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Dev Shell 壳展示层小工具(纯函数,与宿主 shell/utils.ts 同构)
3
+ *
4
+ * 只放无状态纯函数,方便单测与复用。
5
+ */
6
+
7
+ /** 字节数格式化(1024 进制,保留 1 位小数;<1KB 直接给 B) */
8
+ export function formatBytes(bytes: number | undefined): string {
9
+ if (bytes === undefined || bytes === null || Number.isNaN(bytes)) return '—'
10
+ if (bytes < 1024) return `${bytes} B`
11
+ const units = ['KB', 'MB', 'GB', 'TB']
12
+ let value = bytes / 1024
13
+ let unitIndex = 0
14
+ while (value >= 1024 && unitIndex < units.length - 1) {
15
+ value /= 1024
16
+ unitIndex += 1
17
+ }
18
+ return `${value.toFixed(1)} ${units[unitIndex]}`
19
+ }
20
+
21
+ /**
22
+ * 首字母回退(无图标应用用)
23
+ *
24
+ * 取首个字符而非首字母:中文名取首字比取不到拉丁字母更可读。
25
+ */
26
+ export function initialOf(name: string): string {
27
+ const trimmed = (name ?? '').trim()
28
+ return trimmed ? trimmed.slice(0, 1).toUpperCase() : '?'
29
+ }
30
+
31
+ /** 图标形态:emoji / SVG path d / 图片路径 / 无 */
32
+ export type IconKind = 'emoji' | 'path' | 'image' | 'none'
33
+
34
+ /**
35
+ * 图片图标的扩展名判据(与宿主 shell/utils.ts 同源)
36
+ *
37
+ * 调试数据源读不到插件包内资源,会把图片路径换成通用 path 图形(见 adapters/devAppSource.ts
38
+ * 的 resolveIcon),因此壳内当前不会从 `icon` 命中 image;保留判据是为了与宿主同构——
39
+ * 数据源给出已解析 iconUrl 时,两种运行环境走同一条渲染分支。
40
+ */
41
+ const IMAGE_ICON_RE = /\.(png|jpe?g|webp|gif|svg)$/i
42
+
43
+ /**
44
+ * 判断图标形态
45
+ *
46
+ * 与宿主 utils.iconKindOf 同构,判据顺序一致:图片路径必须先于 path 判定——「icon.svg」
47
+ * 这类值不含路径指令字符,漏掉这一步会被当 emoji 字面量渲染。
48
+ */
49
+ export function iconKindOf(icon: string | undefined): IconKind {
50
+ if (!icon) return 'none'
51
+ if (IMAGE_ICON_RE.test(icon.trim())) return 'image'
52
+ if (/^[MmLlHhVvCcSsQqTtAaZz0-9\s.,+-]+$/.test(icon)) return 'path'
53
+ return 'emoji'
54
+ }
@@ -0,0 +1,153 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
5
+ :root {
6
+ /* 手机框最大高度:844px 真机尺寸,视口矮时收窄保证整体可见(底部导航不被裁切) */
7
+ --dev-shell-frame-h: min(844px, calc(100vh - 7rem));
8
+ }
9
+
10
+ @supports (height: 1dvh) {
11
+ :root {
12
+ /* 动态视口:浏览器工具条收起/展开时高度不闪变 */
13
+ --dev-shell-frame-h: min(844px, calc(100dvh - 7rem));
14
+ }
15
+ }
16
+
17
+ /* ===== 基础(与宿主 style.css 对齐的最小集合) ===== */
18
+ :root {
19
+ font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
20
+ line-height: 1.5;
21
+ font-weight: 400;
22
+ font-synthesis: none;
23
+ text-rendering: optimizeLegibility;
24
+ -webkit-font-smoothing: antialiased;
25
+ -moz-osx-font-smoothing: grayscale;
26
+
27
+ /* 安全区域(浏览器中恒为 0,保留变量兼容插件安全区逻辑) */
28
+ --safe-area-inset-top: env(safe-area-inset-top, 0px);
29
+ --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
30
+ --safe-area-inset-left: env(safe-area-inset-left, 0px);
31
+ --safe-area-inset-right: env(safe-area-inset-right, 0px);
32
+ --safe-area-top: var(--safe-area-inset-top);
33
+ --safe-area-bottom: var(--safe-area-inset-bottom);
34
+ --keyboard-height: 0px;
35
+ --keyboard-visible: 0;
36
+ }
37
+
38
+ :root {
39
+ color-scheme: light;
40
+ }
41
+ :root.dark {
42
+ color-scheme: dark;
43
+ }
44
+
45
+ :root {
46
+ --font-size-xs: 10px;
47
+ --font-size-sm: 12px;
48
+ --font-size-base: 14px;
49
+ --font-size-lg: 16px;
50
+ --font-size-xl: 18px;
51
+ }
52
+
53
+ body {
54
+ margin: 0;
55
+ min-width: 320px;
56
+ min-height: 100vh;
57
+ background: #14141a;
58
+ }
59
+
60
+ /* ===== 移动端字体规则(与宿主一致) ===== */
61
+ .mobile-ui {
62
+ font-size: var(--font-size-base);
63
+ line-height: 1.5;
64
+ }
65
+ .mobile-ui h1,
66
+ .mobile-ui .text-xl,
67
+ .mobile-ui .title-xl {
68
+ font-size: var(--font-size-xl);
69
+ font-weight: 600;
70
+ line-height: 1.3;
71
+ }
72
+ .mobile-ui h2,
73
+ .mobile-ui .text-lg,
74
+ .mobile-ui .title-lg {
75
+ font-size: var(--font-size-lg);
76
+ font-weight: 600;
77
+ line-height: 1.4;
78
+ }
79
+ .mobile-ui .text-sm,
80
+ .mobile-ui small {
81
+ font-size: var(--font-size-sm);
82
+ line-height: 1.5;
83
+ }
84
+ .mobile-ui .text-xs {
85
+ font-size: var(--font-size-xs);
86
+ line-height: 1.4;
87
+ }
88
+ .mobile-ui button,
89
+ .mobile-ui .btn {
90
+ font-size: var(--font-size-base);
91
+ font-weight: 500;
92
+ }
93
+ .mobile-ui input,
94
+ .mobile-ui textarea,
95
+ .mobile-ui select {
96
+ font-size: var(--font-size-base);
97
+ }
98
+
99
+ .text-xs {
100
+ font-size: var(--font-size-xs);
101
+ }
102
+ .text-sm {
103
+ font-size: var(--font-size-sm);
104
+ }
105
+ .text-base {
106
+ font-size: var(--font-size-base);
107
+ }
108
+ .text-lg {
109
+ font-size: var(--font-size-lg);
110
+ }
111
+ .text-xl {
112
+ font-size: var(--font-size-xl);
113
+ }
114
+
115
+ /* ===== 移动端容器 ===== */
116
+ .mobile-app {
117
+ min-height: 100vh;
118
+ min-height: 100dvh;
119
+ transition: padding-top 0.25s cubic-bezier(0.4, 0, 0.2, 1);
120
+ }
121
+ .mobile-nav-safe {
122
+ padding-bottom: var(--safe-area-bottom, 0px);
123
+ }
124
+ .mobile-header-safe {
125
+ padding-top: var(--safe-area-top, 0px);
126
+ }
127
+ .mobile-input-bar {
128
+ margin-bottom: env(keyboard-inset-bottom, 0px);
129
+ transition: margin-bottom 0.25s cubic-bezier(0.4, 0, 0.2, 1);
130
+ }
131
+
132
+ /* ===== 滚动条(token 驱动,深浅色自适应) ===== */
133
+ ::-webkit-scrollbar {
134
+ width: 8px;
135
+ height: 8px;
136
+ }
137
+ ::-webkit-scrollbar-track {
138
+ background: transparent;
139
+ }
140
+ ::-webkit-scrollbar-thumb {
141
+ background: color-mix(in srgb, var(--mobile-text-muted) 35%, transparent);
142
+ border-radius: 4px;
143
+ }
144
+ ::-webkit-scrollbar-thumb:hover {
145
+ background: color-mix(in srgb, var(--mobile-text-muted) 55%, transparent);
146
+ }
147
+
148
+ /* ===== 终端输出 ===== */
149
+ .terminal-output {
150
+ font-family: Consolas, Monaco, monospace;
151
+ white-space: pre-wrap;
152
+ word-break: break-word;
153
+ }