@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
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
主屏壁纸样式(唯一真源)
|
|
3
|
+
----------------------------------------------------------------------------
|
|
4
|
+
渐变全部由 color-mix() 从既有 --mobile-* 语义 token 派生(零新 hex),
|
|
5
|
+
双主题与主色色板自动适配:default 色板下 accent 是象牙白/近黑,壁纸呈现
|
|
6
|
+
低饱和的纸感;forest/ocean/sunset/violet 色板下壁纸随主色偏色。
|
|
7
|
+
遮罩强度 --wall-dim(0–70,%)由壳偏好提供,用页面底色压住壁纸护文字对比度。
|
|
8
|
+
|
|
9
|
+
消费者(共用同一份档位与遮罩逻辑,禁止在别处另写一份渐变):
|
|
10
|
+
· 壳主屏背景层:shell-wall + shell-wallpaper
|
|
11
|
+
· 壳设置页壁纸预览:shell-wall-swatch(2026-10-15 起已随背景区块迁往外观设置页)
|
|
12
|
+
· 外观设置页壁纸选择器:wallpaper-picker / wallpaper-swatch(旧路由 /mobile/settings/appearance)
|
|
13
|
+
============================================================================ */
|
|
14
|
+
|
|
15
|
+
.shell-wall {
|
|
16
|
+
--wall-active: none;
|
|
17
|
+
}
|
|
18
|
+
.shell-wall.wall-aurora {
|
|
19
|
+
--wall-active: linear-gradient(
|
|
20
|
+
160deg,
|
|
21
|
+
color-mix(in srgb, var(--mobile-accent) 26%, var(--mobile-bg-primary)) 0%,
|
|
22
|
+
color-mix(in srgb, var(--mobile-success) 16%, var(--mobile-bg-primary)) 58%,
|
|
23
|
+
var(--mobile-bg-primary) 100%
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
.shell-wall.wall-dune {
|
|
27
|
+
--wall-active: linear-gradient(
|
|
28
|
+
160deg,
|
|
29
|
+
color-mix(in srgb, var(--mobile-warning) 24%, var(--mobile-bg-primary)) 0%,
|
|
30
|
+
color-mix(in srgb, var(--mobile-accent) 12%, var(--mobile-bg-primary)) 55%,
|
|
31
|
+
var(--mobile-bg-primary) 100%
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
.shell-wall.wall-reef {
|
|
35
|
+
--wall-active: linear-gradient(
|
|
36
|
+
160deg,
|
|
37
|
+
color-mix(in srgb, var(--mobile-accent-secondary) 90%, var(--mobile-bg-primary)) 0%,
|
|
38
|
+
color-mix(in srgb, var(--mobile-success) 10%, var(--mobile-bg-primary)) 62%,
|
|
39
|
+
var(--mobile-bg-primary) 100%
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* 壁纸层:绝对定位铺满主屏根容器(不随内容滚动),遮罩由 ::after 叠加 */
|
|
44
|
+
.shell-wallpaper {
|
|
45
|
+
position: absolute;
|
|
46
|
+
inset: 0;
|
|
47
|
+
background-image: var(--wall-active, none);
|
|
48
|
+
background-size: cover;
|
|
49
|
+
background-position: center;
|
|
50
|
+
pointer-events: none;
|
|
51
|
+
}
|
|
52
|
+
.shell-wallpaper::after {
|
|
53
|
+
content: '';
|
|
54
|
+
position: absolute;
|
|
55
|
+
inset: 0;
|
|
56
|
+
/* --wall-dim 为 0 时透明 = 壁纸全显;70 时页面色占 70% */
|
|
57
|
+
background: color-mix(in srgb, var(--mobile-bg-primary) calc(var(--wall-dim, 30) * 1%), transparent);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* 壁纸预览色块:与主屏同一份 --wall-* 真源,避免两处各写一份渐变。
|
|
61
|
+
缩略图必须与页面底色分离(深底上的深色渐变不描边就融进页面):给一档更实
|
|
62
|
+
的投影。遮罩叠层与主屏同一逻辑(--wall-dim),由选择器把滑杆当前值实时绑到
|
|
63
|
+
色块上——预览即所得。 */
|
|
64
|
+
.shell-wall-swatch {
|
|
65
|
+
position: relative;
|
|
66
|
+
background-image: var(--wall-active, none);
|
|
67
|
+
background-size: cover;
|
|
68
|
+
background-position: center;
|
|
69
|
+
box-shadow: var(--mobile-card-shadow);
|
|
70
|
+
}
|
|
71
|
+
.shell-wall-swatch::after {
|
|
72
|
+
content: '';
|
|
73
|
+
position: absolute;
|
|
74
|
+
inset: 0;
|
|
75
|
+
background: color-mix(in srgb, var(--mobile-bg-primary) calc(var(--wall-dim, 30) * 1%), transparent);
|
|
76
|
+
pointer-events: none;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* ============================================================================
|
|
80
|
+
外观设置页壁纸选择器(旧路由 /mobile/settings/appearance)
|
|
81
|
+
----------------------------------------------------------------------------
|
|
82
|
+
与 set-... 页的 palette-picker 同形态:全宽换行的色块按钮(预览 + 文字标签,
|
|
83
|
+
非纯色传达);预览块复用上面的 shell-wall-swatch 档位与遮罩逻辑。
|
|
84
|
+
============================================================================ */
|
|
85
|
+
.wallpaper-picker {
|
|
86
|
+
display: flex;
|
|
87
|
+
flex-wrap: wrap;
|
|
88
|
+
gap: 8px;
|
|
89
|
+
padding: 0 16px 12px;
|
|
90
|
+
}
|
|
91
|
+
.wallpaper-picker-btn {
|
|
92
|
+
display: flex;
|
|
93
|
+
align-items: center;
|
|
94
|
+
gap: 8px;
|
|
95
|
+
flex: 1 1 140px;
|
|
96
|
+
min-width: 0;
|
|
97
|
+
padding: 8px 10px;
|
|
98
|
+
border-radius: 10px;
|
|
99
|
+
border: 1px solid var(--mobile-border);
|
|
100
|
+
background: var(--mobile-bg-card);
|
|
101
|
+
color: var(--mobile-text-primary);
|
|
102
|
+
transition: border-color 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
|
|
103
|
+
}
|
|
104
|
+
.wallpaper-picker-btn:active {
|
|
105
|
+
opacity: 0.75;
|
|
106
|
+
}
|
|
107
|
+
.wallpaper-picker-btn.active {
|
|
108
|
+
border-color: var(--mobile-accent);
|
|
109
|
+
background: var(--mobile-accent-muted);
|
|
110
|
+
}
|
|
111
|
+
.wallpaper-swatch {
|
|
112
|
+
flex-shrink: 0;
|
|
113
|
+
width: 40px;
|
|
114
|
+
height: 40px;
|
|
115
|
+
border-radius: 10px;
|
|
116
|
+
overflow: hidden;
|
|
117
|
+
}
|
|
118
|
+
/* 自定义档位:未选图时是「+」占位,选过后是图片缩略图 */
|
|
119
|
+
.wallpaper-swatch--custom {
|
|
120
|
+
display: flex;
|
|
121
|
+
align-items: center;
|
|
122
|
+
justify-content: center;
|
|
123
|
+
background: var(--mobile-bg-elevated);
|
|
124
|
+
color: var(--mobile-text-secondary);
|
|
125
|
+
}
|
|
126
|
+
.wallpaper-swatch--custom img {
|
|
127
|
+
width: 100%;
|
|
128
|
+
height: 100%;
|
|
129
|
+
object-fit: cover;
|
|
130
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 主题管理(与宿主 useTheme 同语义)
|
|
3
|
+
*
|
|
4
|
+
* - 模式:dark(深色)/ light(浅色)/ system(跟随系统),持久化到 localStorage
|
|
5
|
+
* - 应用方式与宿主一致:切换 <html> 的 .dark 类(mobile.css 中深色为 :root 默认,
|
|
6
|
+
* 浅色作用于 html:not(.dark) .mobile-ui / .mobile-app)
|
|
7
|
+
* - system 模式监听 prefers-color-scheme 变化实时切换
|
|
8
|
+
*/
|
|
9
|
+
import { ref } from 'vue'
|
|
10
|
+
|
|
11
|
+
export type ThemeMode = 'dark' | 'light' | 'system'
|
|
12
|
+
|
|
13
|
+
const THEME_KEY = 'wasmnest-dev-shell:theme'
|
|
14
|
+
|
|
15
|
+
const theme = ref<ThemeMode>('system')
|
|
16
|
+
let systemQuery: MediaQueryList | null = null
|
|
17
|
+
|
|
18
|
+
/** 按当前模式 + 系统偏好应用 .dark 类 */
|
|
19
|
+
function applyTheme(): void {
|
|
20
|
+
const isDark =
|
|
21
|
+
theme.value === 'system'
|
|
22
|
+
? (systemQuery?.matches ?? true)
|
|
23
|
+
: theme.value === 'dark'
|
|
24
|
+
document.documentElement.classList.toggle('dark', isDark)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function setupSystemListener(): void {
|
|
28
|
+
systemQuery?.removeEventListener('change', applyTheme)
|
|
29
|
+
systemQuery = window.matchMedia('(prefers-color-scheme: dark)')
|
|
30
|
+
systemQuery.addEventListener('change', applyTheme)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function teardownSystemListener(): void {
|
|
34
|
+
systemQuery?.removeEventListener('change', applyTheme)
|
|
35
|
+
systemQuery = null
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** 启动时调用(index.html 内联脚本已按持久化偏好消除首帧闪烁) */
|
|
39
|
+
export function initTheme(): void {
|
|
40
|
+
try {
|
|
41
|
+
const saved = localStorage.getItem(THEME_KEY)
|
|
42
|
+
if (saved === 'dark' || saved === 'light' || saved === 'system') {
|
|
43
|
+
theme.value = saved
|
|
44
|
+
}
|
|
45
|
+
} catch {
|
|
46
|
+
// 隐私模式等场景使用默认 system
|
|
47
|
+
}
|
|
48
|
+
if (theme.value === 'system') setupSystemListener()
|
|
49
|
+
applyTheme()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** 切换主题模式(持久化;system 时建立系统偏好监听) */
|
|
53
|
+
export function setTheme(mode: ThemeMode): void {
|
|
54
|
+
theme.value = mode
|
|
55
|
+
try {
|
|
56
|
+
localStorage.setItem(THEME_KEY, mode)
|
|
57
|
+
} catch {
|
|
58
|
+
// 忽略持久化失败
|
|
59
|
+
}
|
|
60
|
+
if (mode === 'system') {
|
|
61
|
+
setupSystemListener()
|
|
62
|
+
} else {
|
|
63
|
+
teardownSystemListener()
|
|
64
|
+
}
|
|
65
|
+
applyTheme()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** 供组件读取/切换(DevToolbar 分段按钮) */
|
|
69
|
+
export function useDevTheme() {
|
|
70
|
+
return { theme, setTheme }
|
|
71
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
declare module '*.vue' {
|
|
4
|
+
import type { DefineComponent } from 'vue'
|
|
5
|
+
const component: DefineComponent<Record<string, unknown>, Record<string, unknown>, unknown>
|
|
6
|
+
export default component
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare module 'virtual:dev-plugins' {
|
|
10
|
+
export interface DevPluginRecordSpec {
|
|
11
|
+
/** 插件目录(绝对路径) */
|
|
12
|
+
dir: string
|
|
13
|
+
/** plugin.json 解析结果 */
|
|
14
|
+
manifest: Record<string, unknown>
|
|
15
|
+
/** 插件前端入口模块(activate/deactivate) */
|
|
16
|
+
entry: any
|
|
17
|
+
}
|
|
18
|
+
const records: DevPluginRecordSpec[]
|
|
19
|
+
export default records
|
|
20
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/** @type {import('tailwindcss').Config} */
|
|
2
|
+
// 语义别名与宿主 wasmnest-mobile/tailwind.config.js 保持一致;
|
|
3
|
+
// content 动态追加被调试插件目录(env WASMNEST_DEV_PLUGINS),插件 SFC 的 Tailwind 类才生效。
|
|
4
|
+
export default {
|
|
5
|
+
content: [
|
|
6
|
+
'./index.html',
|
|
7
|
+
'./src/**/*.{vue,js,ts,jsx,tsx}',
|
|
8
|
+
...(process.env.WASMNEST_DEV_PLUGINS || '')
|
|
9
|
+
.split(',')
|
|
10
|
+
.map((item) => item.trim())
|
|
11
|
+
.filter(Boolean)
|
|
12
|
+
.map((item) => item.split('::')[0] + '/src/**/*.{vue,js,ts,jsx,tsx}'),
|
|
13
|
+
],
|
|
14
|
+
darkMode: 'class',
|
|
15
|
+
theme: {
|
|
16
|
+
extend: {
|
|
17
|
+
colors: {
|
|
18
|
+
// 与宿主 wasmnest-mobile/tailwind.config.js 逐字一致(theme 整段由
|
|
19
|
+
// dev-shell/__tests__/visualParity.test.ts 深比对锁定):
|
|
20
|
+
// 调色板缺一项 = 插件用到该类时被 purge 成无样式,预览与真机长得不一样
|
|
21
|
+
primary: {
|
|
22
|
+
50: '#f0f9ff',
|
|
23
|
+
100: '#e0f2fe',
|
|
24
|
+
200: '#bae6fd',
|
|
25
|
+
300: '#7dd3fc',
|
|
26
|
+
400: '#38bdf8',
|
|
27
|
+
500: '#0ea5e9',
|
|
28
|
+
600: '#0284c7',
|
|
29
|
+
700: '#0369a1',
|
|
30
|
+
800: '#075985',
|
|
31
|
+
900: '#0c4a6e',
|
|
32
|
+
950: '#082f49',
|
|
33
|
+
},
|
|
34
|
+
dark: {
|
|
35
|
+
50: '#f8fafc',
|
|
36
|
+
100: '#f1f5f9',
|
|
37
|
+
200: '#e2e8f0',
|
|
38
|
+
300: '#cbd5e1',
|
|
39
|
+
400: '#94a3b8',
|
|
40
|
+
500: '#64748b',
|
|
41
|
+
600: '#475569',
|
|
42
|
+
650: '#3d4f63',
|
|
43
|
+
700: '#334155',
|
|
44
|
+
750: '#2d3a4f',
|
|
45
|
+
800: '#1e293b',
|
|
46
|
+
850: '#172033',
|
|
47
|
+
900: '#0f172a',
|
|
48
|
+
950: '#020617',
|
|
49
|
+
},
|
|
50
|
+
// 移动端语义别名 - 映射 --mobile-* token 到 Tailwind utility(与宿主一致)
|
|
51
|
+
mobile: {
|
|
52
|
+
bg: {
|
|
53
|
+
primary: 'var(--mobile-bg-primary)',
|
|
54
|
+
secondary: 'var(--mobile-bg-secondary)',
|
|
55
|
+
tertiary: 'var(--mobile-bg-tertiary)',
|
|
56
|
+
card: 'var(--mobile-bg-card)',
|
|
57
|
+
elevated: 'var(--mobile-bg-elevated)',
|
|
58
|
+
},
|
|
59
|
+
text: {
|
|
60
|
+
primary: 'var(--mobile-text-primary)',
|
|
61
|
+
secondary: 'var(--mobile-text-secondary)',
|
|
62
|
+
muted: 'var(--mobile-text-muted)',
|
|
63
|
+
disabled: 'var(--mobile-text-disabled)',
|
|
64
|
+
onAccent: 'var(--mobile-text-on-accent)',
|
|
65
|
+
},
|
|
66
|
+
accent: 'var(--mobile-accent)',
|
|
67
|
+
accentMuted: 'var(--mobile-accent-muted)',
|
|
68
|
+
accentSecondary: 'var(--mobile-accent-secondary)',
|
|
69
|
+
border: 'var(--mobile-border)',
|
|
70
|
+
borderHover: 'var(--mobile-border-hover)',
|
|
71
|
+
borderActive: 'var(--mobile-border-active)',
|
|
72
|
+
success: 'var(--mobile-success)',
|
|
73
|
+
successMuted: 'var(--mobile-success-muted)',
|
|
74
|
+
warning: 'var(--mobile-warning)',
|
|
75
|
+
warningMuted: 'var(--mobile-warning-muted)',
|
|
76
|
+
error: 'var(--mobile-error)',
|
|
77
|
+
errorMuted: 'var(--mobile-error-muted)',
|
|
78
|
+
overlay: 'var(--mobile-overlay)',
|
|
79
|
+
overlayHeavy: 'var(--mobile-overlay-heavy)',
|
|
80
|
+
overlayLight: 'var(--mobile-overlay-light)',
|
|
81
|
+
navBg: 'var(--mobile-nav-bg)',
|
|
82
|
+
navBorder: 'var(--mobile-nav-border)',
|
|
83
|
+
navActive: 'var(--mobile-nav-active)',
|
|
84
|
+
navInactive: 'var(--mobile-nav-inactive)',
|
|
85
|
+
inputBg: 'var(--mobile-input-bg)',
|
|
86
|
+
inputBorder: 'var(--mobile-input-border)',
|
|
87
|
+
inputFocus: 'var(--mobile-input-focus)',
|
|
88
|
+
inputPlaceholder: 'var(--mobile-input-placeholder)',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
fontFamily: {
|
|
92
|
+
sans: ['Inter', 'system-ui', 'sans-serif'],
|
|
93
|
+
mono: ['Consolas', 'Monaco', 'monospace'],
|
|
94
|
+
},
|
|
95
|
+
boxShadow: {
|
|
96
|
+
xs: '0 1px 2px 0 rgb(0 0 0 / 0.04)',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
plugins: [],
|
|
101
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"jsx": "preserve",
|
|
8
|
+
"resolveJsonModule": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"noEmit": true,
|
|
12
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
13
|
+
"types": ["vite/client"]
|
|
14
|
+
},
|
|
15
|
+
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.vue"]
|
|
16
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev Shell Vite 配置
|
|
3
|
+
*
|
|
4
|
+
* 环境变量:
|
|
5
|
+
* WASMNEST_DEV_PLUGINS 逗号分隔的插件说明,每项 `<插件目录>[::<入口文件>]`,
|
|
6
|
+
* 入口缺省为 `<插件目录>/src/index.ts`(由 wasmnest-plugin dev 注入)
|
|
7
|
+
* WASMNEST_DEV_PORT 端口(缺省 5173,也可用 vite --port 覆盖)
|
|
8
|
+
*
|
|
9
|
+
* 插件前端源码经虚拟模块 virtual:dev-plugins 挂入构建图:
|
|
10
|
+
* - 入口(index.ts)与 plugin.json 均由 vite 解析,插件源码改动走标准 HMR
|
|
11
|
+
* - server.fs.allow 动态放行插件目录(含其 node_modules / SDK file: 软链的真实路径)
|
|
12
|
+
*/
|
|
13
|
+
import { defineConfig, type Plugin } from 'vite'
|
|
14
|
+
import vue from '@vitejs/plugin-vue'
|
|
15
|
+
import { existsSync, realpathSync } from 'node:fs'
|
|
16
|
+
import { join, resolve } from 'node:path'
|
|
17
|
+
import { fileURLToPath } from 'node:url'
|
|
18
|
+
|
|
19
|
+
const DEV_SHELL_ROOT = fileURLToPath(new URL('.', import.meta.url))
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 设计 token 的单一真源
|
|
23
|
+
*
|
|
24
|
+
* 插件 UI 几乎只靠 `var(--mobile-*)` 上色(file-transfer 一个插件就引用 130 处),
|
|
25
|
+
* token 一旦与宿主分叉,预览里看到的就是另一套配色——而这正是 dev-shell 唯一不该
|
|
26
|
+
* 发生的事(同型壳的价值就是所见即真机)。
|
|
27
|
+
*
|
|
28
|
+
* monorepo 内 dev-shell 与宿主同仓,直接指向宿主 `src/styles/`(跟随宿主更新,零维护);
|
|
29
|
+
* npm 包内没有宿主,退回自带副本(`files` 白名单携带),副本与宿主的一致性由
|
|
30
|
+
* `dev-shell/__tests__/visualParity.test.ts` 钉住。
|
|
31
|
+
*/
|
|
32
|
+
const TOKEN_STYLE_ALIAS = '@wasmnest/mobile-styles'
|
|
33
|
+
const HOST_STYLE_DIR = resolve(DEV_SHELL_ROOT, '../../../src/styles')
|
|
34
|
+
const BUNDLED_STYLE_DIR = resolve(DEV_SHELL_ROOT, 'src/styles')
|
|
35
|
+
const TOKEN_STYLE_DIR = existsSync(join(HOST_STYLE_DIR, 'mobile.css'))
|
|
36
|
+
? HOST_STYLE_DIR
|
|
37
|
+
: BUNDLED_STYLE_DIR
|
|
38
|
+
|
|
39
|
+
/** 单个被调试插件 */
|
|
40
|
+
export interface DevPluginSpec {
|
|
41
|
+
/** 插件目录(绝对路径) */
|
|
42
|
+
dir: string
|
|
43
|
+
/** 前端入口(绝对路径) */
|
|
44
|
+
entry: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** 解析 WASMNEST_DEV_PLUGINS 环境变量 */
|
|
48
|
+
export function parseDevPlugins(): DevPluginSpec[] {
|
|
49
|
+
const raw = process.env.WASMNEST_DEV_PLUGINS
|
|
50
|
+
if (!raw) return []
|
|
51
|
+
return raw
|
|
52
|
+
.split(',')
|
|
53
|
+
.map((item) => item.trim())
|
|
54
|
+
.filter(Boolean)
|
|
55
|
+
.map((item) => {
|
|
56
|
+
const [dir, entry] = item.split('::')
|
|
57
|
+
const absDir = resolve(dir)
|
|
58
|
+
return {
|
|
59
|
+
dir: absDir,
|
|
60
|
+
entry: entry ? resolve(dir, entry) : resolve(absDir, 'src/index.ts'),
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 虚拟模块:导出被调试插件列表 [{ dir, manifest, entry }]
|
|
67
|
+
*
|
|
68
|
+
* 由 vite 解析 import 语句,插件源码与 plugin.json 进入构建图,天然支持 HMR。
|
|
69
|
+
*/
|
|
70
|
+
function devPluginsVirtual(plugins: DevPluginSpec[]): Plugin {
|
|
71
|
+
const VIRTUAL_ID = 'virtual:dev-plugins'
|
|
72
|
+
return {
|
|
73
|
+
name: 'wasmnest-dev-shell:virtual-plugins',
|
|
74
|
+
resolveId(id) {
|
|
75
|
+
if (id === VIRTUAL_ID) return '\0' + VIRTUAL_ID
|
|
76
|
+
},
|
|
77
|
+
load(id) {
|
|
78
|
+
if (id !== '\0' + VIRTUAL_ID) return
|
|
79
|
+
if (plugins.length === 0) return 'export default []'
|
|
80
|
+
const imports = plugins
|
|
81
|
+
.map((p, i) => {
|
|
82
|
+
const manifestPath = resolve(p.dir, 'plugin.json')
|
|
83
|
+
return (
|
|
84
|
+
`import * as entry${i} from ${JSON.stringify(p.entry)}\n` +
|
|
85
|
+
`import manifest${i} from ${JSON.stringify(manifestPath)}`
|
|
86
|
+
)
|
|
87
|
+
})
|
|
88
|
+
.join('\n')
|
|
89
|
+
const records = plugins
|
|
90
|
+
.map(
|
|
91
|
+
(p, i) =>
|
|
92
|
+
`{ dir: ${JSON.stringify(p.dir)}, manifest: manifest${i}, entry: entry${i} }`,
|
|
93
|
+
)
|
|
94
|
+
.join(',\n ')
|
|
95
|
+
return `${imports}\n\nexport default [\n ${records},\n]\n`
|
|
96
|
+
},
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export default defineConfig(() => {
|
|
101
|
+
const plugins = parseDevPlugins()
|
|
102
|
+
|
|
103
|
+
// fs.allow:dev-shell 自身 + 插件目录(file: SDK 依赖为软链,需放行真实路径)+ token 目录
|
|
104
|
+
const allow = new Set<string>([DEV_SHELL_ROOT, TOKEN_STYLE_DIR])
|
|
105
|
+
for (const p of plugins) {
|
|
106
|
+
allow.add(p.dir)
|
|
107
|
+
try {
|
|
108
|
+
allow.add(realpathSync(p.dir))
|
|
109
|
+
} catch {
|
|
110
|
+
// 目录不存在时 vite 会给出更明确的错误,此处仅尽力放行
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
plugins: [vue(), devPluginsVirtual(plugins)],
|
|
116
|
+
resolve: {
|
|
117
|
+
// 强制插件源码与 dev-shell 共用同一份 vue 实例(provide/inject、响应式共享依赖它)
|
|
118
|
+
dedupe: ['vue', 'vue-i18n', 'pinia', 'vue-router'],
|
|
119
|
+
alias: { [TOKEN_STYLE_ALIAS]: TOKEN_STYLE_DIR },
|
|
120
|
+
},
|
|
121
|
+
// main.ts 使用 top-level await 串行初始化共享运行时 → 加载插件 → 挂载
|
|
122
|
+
build: {
|
|
123
|
+
target: 'esnext',
|
|
124
|
+
},
|
|
125
|
+
server: {
|
|
126
|
+
port: Number(process.env.WASMNEST_DEV_PORT || 5173),
|
|
127
|
+
fs: { allow: [...allow] },
|
|
128
|
+
},
|
|
129
|
+
}
|
|
130
|
+
})
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { MobileHostApi, PluginContext, PluginDialogOptions } from './types.js';
|
|
2
|
+
export { CommandContribution, CommandRegistry, ConfigProperty, DialogAPI, DialogOptions, DialogResult, Disposable, EventAPI, I18nAPI, LifecycleAPI, LifecycleContribution, LoggerAPI, MobileHostSessionEvent, MobileHttpRequestOptions, MobileHttpResult, MobilePluginContributes, MonitorPanelContribution, MonitorPanelEnv, MonitorPanelHandle, MountMonitorPanel, NavTabContribution, NotificationAPI, PluginConfiguration, PluginDevMock, PluginDialogAction, PluginDialogHandle, PluginManifest, PluginModule, PluginRouteDescriptor, PluginState, PluginType, RouteContribution, SessionAPI, SettingsContribution, ShellCapsuleItem, ShellSlotContribution, ShellSurfaceContribution, StatusAPI, StorageAPI, SystemAPI, TerminalContribution, TerminalStreamHandle, TerminalToolbarItemContribution, UIRegistry, ViewContribution } from './types.js';
|
|
3
|
+
import 'vue';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @binblink/wasmnest-plugin-sdk-mobile 运行时代理
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** 获取宿主共享模块 */
|
|
10
|
+
declare function getSharedModule(name: string): any;
|
|
11
|
+
/** 获取宿主 i18n 实例 */
|
|
12
|
+
declare function getI18n(): any;
|
|
13
|
+
/** 获取宿主 Vue 实例 */
|
|
14
|
+
declare function getVue(): any;
|
|
15
|
+
/** 获取宿主 vue-i18n 模块 */
|
|
16
|
+
declare function getVueI18n(): any;
|
|
17
|
+
/** 获取宿主 Pinia 模块 */
|
|
18
|
+
declare function getPinia(): any;
|
|
19
|
+
/** 获取宿主 Router 实例 */
|
|
20
|
+
declare function getRouter(): any;
|
|
21
|
+
/** 获取宿主预设任务 composable */
|
|
22
|
+
declare function getPresetTasks(): any;
|
|
23
|
+
/** 获取宿主移动端连接/HTTP 能力(MobileHostApi,通用连接 + httpRequest 通道) */
|
|
24
|
+
declare function getMobileApi(): MobileHostApi;
|
|
25
|
+
/** 从 Vue inject 获取 PluginContext */
|
|
26
|
+
declare function getPluginContext(): PluginContext;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* SDK 常量(宿主与插件共用单一事实源)
|
|
30
|
+
*/
|
|
31
|
+
/** DEV mock 会话 id:宿主 useMockTerminal / 终端插件 UI 共用;生产构建无意义 */
|
|
32
|
+
declare const MOCK_SESSION_ID = "__mock_terminal__";
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 全局弹窗控制器(移动端宿主 + dev-shell 共用)
|
|
36
|
+
*
|
|
37
|
+
* 与桌面端 packages/plugin-sdk-desktop/src/global-dialog.ts 同构:
|
|
38
|
+
* 发布-订阅实现,不直接依赖 Vue reactivity,宿主 / dev-shell 的
|
|
39
|
+
* PluginGlobalDialog 组件经 subscribeGlobalDialog 订阅渲染。
|
|
40
|
+
*
|
|
41
|
+
* 语义:
|
|
42
|
+
* - FIFO 队列:同一时刻至多一个弹窗,后到的排队;当前关闭后自动接替;
|
|
43
|
+
* - update() 生成新条目对象再广播(订阅方拿到新引用触发重渲染);
|
|
44
|
+
* - close() 幂等;排队中的条目也可关闭(从队列移除);
|
|
45
|
+
* - 定时自动关闭为**可选能力**:仅当提供 timeoutSec / deadlineAt 时生效,
|
|
46
|
+
* 计时从条目成为当前弹窗起计算。
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/** 内部弹窗条目 = 公开选项 + 宿主注入字段 */
|
|
50
|
+
interface GlobalDialogEntry extends PluginDialogOptions {
|
|
51
|
+
/** 内部唯一 ID(句柄路由用) */
|
|
52
|
+
_id: number;
|
|
53
|
+
/** 内容组件宿主上下文(provide('pluginContext') 用;宿主 showDialog 注入) */
|
|
54
|
+
pluginContext?: unknown;
|
|
55
|
+
/** 条目创建时刻(ms) */
|
|
56
|
+
createdAt: number;
|
|
57
|
+
}
|
|
58
|
+
/** 订阅输入(宿主注入 pluginContext 后交 openGlobalDialog) */
|
|
59
|
+
type OpenGlobalDialogInput = PluginDialogOptions & {
|
|
60
|
+
pluginContext?: unknown;
|
|
61
|
+
};
|
|
62
|
+
type GlobalDialogListener = (entry: GlobalDialogEntry | null) => void;
|
|
63
|
+
/** 打开/更新/关闭返回的句柄(供插件调用方使用) */
|
|
64
|
+
interface GlobalDialogHandleOutput {
|
|
65
|
+
close(): void;
|
|
66
|
+
update(options: Partial<PluginDialogOptions>): void;
|
|
67
|
+
}
|
|
68
|
+
/** 当前弹窗(无则 null) */
|
|
69
|
+
declare function getGlobalDialog(): GlobalDialogEntry | null;
|
|
70
|
+
/** 订阅弹窗变化;立即以当前值回调一次,返回退订函数 */
|
|
71
|
+
declare function subscribeGlobalDialog(listener: GlobalDialogListener): () => void;
|
|
72
|
+
/** 解析条目的绝对截止时刻(deadlineAt 优先;缺省无定时关闭) */
|
|
73
|
+
declare function resolveDialogDeadline(entry: GlobalDialogEntry): number | null;
|
|
74
|
+
/** 关闭指定弹窗:当前弹窗关闭后队列自动顶上;排队中直接移除(均幂等) */
|
|
75
|
+
declare function closeGlobalDialog(id: number): void;
|
|
76
|
+
/** 热更新指定弹窗(当前或排队中;新对象广播触发重渲染) */
|
|
77
|
+
declare function updateGlobalDialog(id: number, options: Partial<PluginDialogOptions>): void;
|
|
78
|
+
/**
|
|
79
|
+
* 打开全局弹窗(宿主 ui.showDialog 调用)。
|
|
80
|
+
* 返回句柄:close() 幂等关闭(当前或排队项),update() 热更新选项。
|
|
81
|
+
*/
|
|
82
|
+
declare function openGlobalDialog(input: OpenGlobalDialogInput): GlobalDialogHandleOutput;
|
|
83
|
+
|
|
84
|
+
export { type GlobalDialogEntry, type GlobalDialogHandleOutput, type GlobalDialogListener, MOCK_SESSION_ID, MobileHostApi, type OpenGlobalDialogInput, PluginContext, PluginDialogOptions, closeGlobalDialog, getGlobalDialog, getI18n, getMobileApi, getPinia, getPluginContext, getPresetTasks, getRouter, getSharedModule, getVue, getVueI18n, openGlobalDialog, resolveDialogDeadline, subscribeGlobalDialog, updateGlobalDialog };
|