@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.
- package/README.md +439 -2
- package/README_en.md +415 -0
- package/bin/build.js +271 -0
- package/bin/cli.js +96 -0
- package/bin/lib.js +349 -0
- package/bin/manifest-gen.js +327 -0
- package/bin/package.js +151 -0
- package/bin/scaffold.js +299 -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 +43 -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 +332 -0
- package/dev-shell/src/locales/index.ts +70 -0
- package/dev-shell/src/locales/shell.ts +331 -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 +374 -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 +144 -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 +501 -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 +359 -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 +357 -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 +417 -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 +44 -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/useSlotCarousel.ts +238 -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/slotCards.ts +47 -0
- package/dev-shell/src/shell/styles/shell.css +1155 -0
- package/dev-shell/src/shell/surfaceIntent.ts +107 -0
- package/dev-shell/src/shell/types.ts +152 -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 +981 -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 +124 -0
- package/dist/index.js +229 -0
- package/dist/types.d.ts +738 -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 +88 -3
- package/src/constants.ts +6 -0
- package/src/global-dialog.ts +168 -0
- package/src/index.ts +96 -0
- package/src/runtime.ts +44 -0
- package/src/types.ts +822 -0
- package/src/ui/AppUpdateSection.d.ts +44 -0
- package/src/ui/AppUpdateSection.vue +253 -0
- package/src/ui/PluginGlobalDialog.vue +388 -0
- package/src/ui/QuickCard.d.ts +33 -0
- package/src/ui/QuickCard.vue +167 -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/update.ts +123 -0
- package/src/vite-plugin.ts +132 -0
- package/template/.gitignore +4 -0
- package/template/README.md +46 -0
- package/template/package.json +23 -0
- package/template/plugin.json +13 -0
- package/template/rust/Cargo.toml +19 -0
- package/template/rust/src/lib.rs +33 -0
- package/template/src/env.d.ts +24 -0
- package/template/src/index.ts +37 -0
- package/template/tsconfig.json +17 -0
- package/template/vite.config.ts +21 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
// src/runtime.ts
|
|
2
|
+
var SHARED_KEY = "__WASMNEST_SHARED__";
|
|
3
|
+
function getSharedModule(name) {
|
|
4
|
+
const shared = window[SHARED_KEY];
|
|
5
|
+
if (!shared) throw new Error("[PluginSDK] Shared runtime not initialized");
|
|
6
|
+
const mod = shared[name];
|
|
7
|
+
if (!mod) throw new Error(`[PluginSDK] Shared module "${name}" not found`);
|
|
8
|
+
return mod;
|
|
9
|
+
}
|
|
10
|
+
function getI18n() {
|
|
11
|
+
return getSharedModule("i18n");
|
|
12
|
+
}
|
|
13
|
+
function getVue() {
|
|
14
|
+
return getSharedModule("vue");
|
|
15
|
+
}
|
|
16
|
+
function getVueI18n() {
|
|
17
|
+
return getSharedModule("vue-i18n");
|
|
18
|
+
}
|
|
19
|
+
function getPinia() {
|
|
20
|
+
return getSharedModule("pinia");
|
|
21
|
+
}
|
|
22
|
+
function getRouter() {
|
|
23
|
+
return getSharedModule("router");
|
|
24
|
+
}
|
|
25
|
+
function getPresetTasks() {
|
|
26
|
+
return getSharedModule("presetTasks");
|
|
27
|
+
}
|
|
28
|
+
function getMobileApi() {
|
|
29
|
+
return getSharedModule("mobileApi");
|
|
30
|
+
}
|
|
31
|
+
function getPluginContext() {
|
|
32
|
+
const vue = getVue();
|
|
33
|
+
const context = vue.inject("pluginContext");
|
|
34
|
+
if (!context) throw new Error("[PluginSDK] PluginContext not available");
|
|
35
|
+
return context;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// src/constants.ts
|
|
39
|
+
var MOCK_SESSION_ID = "__mock_terminal__";
|
|
40
|
+
|
|
41
|
+
// src/global-dialog.ts
|
|
42
|
+
var seq = 0;
|
|
43
|
+
var current = null;
|
|
44
|
+
var queue = [];
|
|
45
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
46
|
+
var timers = /* @__PURE__ */ new Map();
|
|
47
|
+
function getGlobalDialog() {
|
|
48
|
+
return current;
|
|
49
|
+
}
|
|
50
|
+
function subscribeGlobalDialog(listener) {
|
|
51
|
+
listeners.add(listener);
|
|
52
|
+
listener(current);
|
|
53
|
+
return () => {
|
|
54
|
+
listeners.delete(listener);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function emit() {
|
|
58
|
+
for (const fn of [...listeners]) fn(current);
|
|
59
|
+
}
|
|
60
|
+
function clearTimer(id) {
|
|
61
|
+
const timer = timers.get(id);
|
|
62
|
+
if (timer) {
|
|
63
|
+
clearTimeout(timer);
|
|
64
|
+
timers.delete(id);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function resolveDialogDeadline(entry) {
|
|
68
|
+
if (entry.deadlineAt != null && entry.deadlineAt > 0) return entry.deadlineAt;
|
|
69
|
+
if (entry.timeoutSec != null && entry.timeoutSec > 0) return entry.createdAt + entry.timeoutSec * 1e3;
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
function startTimeout(entry) {
|
|
73
|
+
clearTimer(entry._id);
|
|
74
|
+
const deadline = resolveDialogDeadline(entry);
|
|
75
|
+
if (deadline == null) return;
|
|
76
|
+
const delay = Math.max(0, deadline - Date.now());
|
|
77
|
+
timers.set(
|
|
78
|
+
entry._id,
|
|
79
|
+
setTimeout(() => {
|
|
80
|
+
try {
|
|
81
|
+
entry.onTimeout?.();
|
|
82
|
+
} catch (e) {
|
|
83
|
+
console.error("[PluginDialog] onTimeout failed:", e);
|
|
84
|
+
}
|
|
85
|
+
closeGlobalDialog(entry._id);
|
|
86
|
+
}, delay)
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
function fireOnClose(entry) {
|
|
90
|
+
try {
|
|
91
|
+
entry.onClose?.();
|
|
92
|
+
} catch (e) {
|
|
93
|
+
console.error("[PluginDialog] onClose failed:", e);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function closeGlobalDialog(id) {
|
|
97
|
+
if (current && current._id === id) {
|
|
98
|
+
const closed = current;
|
|
99
|
+
clearTimer(id);
|
|
100
|
+
current = null;
|
|
101
|
+
const next = queue.shift() ?? null;
|
|
102
|
+
current = next;
|
|
103
|
+
emit();
|
|
104
|
+
fireOnClose(closed);
|
|
105
|
+
if (next) startTimeout(next);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const idx = queue.findIndex((e) => e._id === id);
|
|
109
|
+
if (idx >= 0) {
|
|
110
|
+
const [removed] = queue.splice(idx, 1);
|
|
111
|
+
fireOnClose(removed);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function updateGlobalDialog(id, options) {
|
|
115
|
+
if (current && current._id === id) {
|
|
116
|
+
current = { ...current, ...options };
|
|
117
|
+
emit();
|
|
118
|
+
startTimeout(current);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const idx = queue.findIndex((e) => e._id === id);
|
|
122
|
+
if (idx >= 0) {
|
|
123
|
+
queue[idx] = { ...queue[idx], ...options };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function openGlobalDialog(input) {
|
|
127
|
+
const entry = {
|
|
128
|
+
...input,
|
|
129
|
+
_id: ++seq,
|
|
130
|
+
createdAt: Date.now()
|
|
131
|
+
};
|
|
132
|
+
if (current) {
|
|
133
|
+
queue.push(entry);
|
|
134
|
+
} else {
|
|
135
|
+
current = entry;
|
|
136
|
+
emit();
|
|
137
|
+
startTimeout(entry);
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
close: () => closeGlobalDialog(entry._id),
|
|
141
|
+
update: (options) => updateGlobalDialog(entry._id, options)
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// src/update.ts
|
|
146
|
+
import { computed, getCurrentInstance, inject, ref } from "vue";
|
|
147
|
+
function resolveHostApi() {
|
|
148
|
+
if (!getCurrentInstance()) return void 0;
|
|
149
|
+
return inject("pluginContext", void 0)?.appUpdate;
|
|
150
|
+
}
|
|
151
|
+
function useAppUpdate(options = {}) {
|
|
152
|
+
const hostApi = options.check ? void 0 : resolveHostApi();
|
|
153
|
+
const checker = options.check ?? (() => {
|
|
154
|
+
if (!hostApi) {
|
|
155
|
+
return Promise.reject(
|
|
156
|
+
new Error("[PluginSDK] app update capability is not provided by this host")
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
return hostApi.check();
|
|
160
|
+
});
|
|
161
|
+
const status = ref("idle");
|
|
162
|
+
const latestVersion = ref();
|
|
163
|
+
const currentVersion = ref();
|
|
164
|
+
const reason = ref();
|
|
165
|
+
let inFlight = null;
|
|
166
|
+
const supported = computed(() => Boolean(options.check || hostApi));
|
|
167
|
+
async function run() {
|
|
168
|
+
status.value = "checking";
|
|
169
|
+
reason.value = void 0;
|
|
170
|
+
try {
|
|
171
|
+
const result = await checker();
|
|
172
|
+
currentVersion.value = result.currentVersion;
|
|
173
|
+
latestVersion.value = result.latestVersion;
|
|
174
|
+
reason.value = result.reason;
|
|
175
|
+
switch (result.status) {
|
|
176
|
+
case "up-to-date":
|
|
177
|
+
case "available":
|
|
178
|
+
case "incompatible":
|
|
179
|
+
status.value = result.status;
|
|
180
|
+
break;
|
|
181
|
+
case "idle":
|
|
182
|
+
case "checking":
|
|
183
|
+
status.value = "error";
|
|
184
|
+
break;
|
|
185
|
+
default:
|
|
186
|
+
status.value = "error";
|
|
187
|
+
}
|
|
188
|
+
} catch {
|
|
189
|
+
status.value = "error";
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function check() {
|
|
193
|
+
if (!inFlight) {
|
|
194
|
+
const pending = run().finally(() => {
|
|
195
|
+
if (inFlight === pending) inFlight = null;
|
|
196
|
+
});
|
|
197
|
+
inFlight = pending;
|
|
198
|
+
}
|
|
199
|
+
return inFlight;
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
status,
|
|
203
|
+
latestVersion,
|
|
204
|
+
currentVersion,
|
|
205
|
+
reason,
|
|
206
|
+
checking: computed(() => status.value === "checking"),
|
|
207
|
+
supported,
|
|
208
|
+
check
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
export {
|
|
212
|
+
MOCK_SESSION_ID,
|
|
213
|
+
closeGlobalDialog,
|
|
214
|
+
getGlobalDialog,
|
|
215
|
+
getI18n,
|
|
216
|
+
getMobileApi,
|
|
217
|
+
getPinia,
|
|
218
|
+
getPluginContext,
|
|
219
|
+
getPresetTasks,
|
|
220
|
+
getRouter,
|
|
221
|
+
getSharedModule,
|
|
222
|
+
getVue,
|
|
223
|
+
getVueI18n,
|
|
224
|
+
openGlobalDialog,
|
|
225
|
+
resolveDialogDeadline,
|
|
226
|
+
subscribeGlobalDialog,
|
|
227
|
+
updateGlobalDialog,
|
|
228
|
+
useAppUpdate
|
|
229
|
+
};
|