@binblink/wasmnest-plugin-sdk-desktop 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.
- package/README.md +24 -4
- package/README_en.md +1 -1
- package/bin/cli.js +5 -5
- package/bin/manifest-gen.js +4 -0
- package/bin/manifest-validate.js +68 -6
- package/bin/permission-vocabulary.json +2 -2
- package/dev-shell/README.md +6 -5
- package/dev-shell/src/loader.ts +0 -5
- package/dev-shell/src/mock/commands.ts +1 -1
- package/dev-shell/src/mock/domain-context.ts +1 -1
- package/dev-shell/src/shell/types.ts +21 -32
- package/dev-shell/src/styles/shell.css +208 -2
- package/dev-shell/src/styles/style.css +72 -26
- package/dist/index.d.ts +44 -3
- package/dist/index.js +69 -1
- package/dist/types.d.ts +52 -5
- package/go/.gitignore +5 -0
- package/go/README.md +80 -0
- package/go/gen/wasmnest/api-call/host-api-call/empty.s +3 -0
- package/go/gen/wasmnest/api-call/host-api-call/host-api-call.wasm.go +13 -0
- package/go/gen/wasmnest/api-call/host-api-call/host-api-call.wit.go +34 -0
- package/go/gen/wasmnest/app/host-app/empty.s +3 -0
- package/go/gen/wasmnest/app/host-app/host-app.wasm.go +29 -0
- package/go/gen/wasmnest/app/host-app/host-app.wit.go +108 -0
- package/go/gen/wasmnest/auth-center/host-auth-center/abi.go +14 -0
- package/go/gen/wasmnest/auth-center/host-auth-center/empty.s +3 -0
- package/go/gen/wasmnest/auth-center/host-auth-center/host-auth-center.wasm.go +49 -0
- package/go/gen/wasmnest/auth-center/host-auth-center/host-auth-center.wit.go +225 -0
- package/go/gen/wasmnest/clipboard/host-clipboard/abi.go +14 -0
- package/go/gen/wasmnest/clipboard/host-clipboard/empty.s +3 -0
- package/go/gen/wasmnest/clipboard/host-clipboard/host-clipboard.wasm.go +17 -0
- package/go/gen/wasmnest/clipboard/host-clipboard/host-clipboard.wit.go +68 -0
- package/go/gen/wasmnest/connection-registry/host-connection-registry/empty.s +3 -0
- package/go/gen/wasmnest/connection-registry/host-connection-registry/host-connection-registry.wasm.go +13 -0
- package/go/gen/wasmnest/connection-registry/host-connection-registry/host-connection-registry.wit.go +50 -0
- package/go/gen/wasmnest/crypto/host-crypto/abi.go +18 -0
- package/go/gen/wasmnest/crypto/host-crypto/empty.s +3 -0
- package/go/gen/wasmnest/crypto/host-crypto/host-crypto.wasm.go +37 -0
- package/go/gen/wasmnest/crypto/host-crypto/host-crypto.wit.go +139 -0
- package/go/gen/wasmnest/fs-desktop/host-fs-desktop/abi.go +14 -0
- package/go/gen/wasmnest/fs-desktop/host-fs-desktop/empty.s +3 -0
- package/go/gen/wasmnest/fs-desktop/host-fs-desktop/host-fs-desktop.wasm.go +21 -0
- package/go/gen/wasmnest/fs-desktop/host-fs-desktop/host-fs-desktop.wit.go +62 -0
- package/go/gen/wasmnest/http/host-http/abi.go +14 -0
- package/go/gen/wasmnest/http/host-http/empty.s +3 -0
- package/go/gen/wasmnest/http/host-http/host-http.wasm.go +13 -0
- package/go/gen/wasmnest/http/host-http/host-http.wit.go +40 -0
- package/go/gen/wasmnest/http-endpoint/host-http-endpoint/empty.s +3 -0
- package/go/gen/wasmnest/http-endpoint/host-http-endpoint/host-http-endpoint.wasm.go +17 -0
- package/go/gen/wasmnest/http-endpoint/host-http-endpoint/host-http-endpoint.wit.go +69 -0
- package/go/gen/wasmnest/mdns/host-mdns/empty.s +3 -0
- package/go/gen/wasmnest/mdns/host-mdns/host-mdns.wasm.go +29 -0
- package/go/gen/wasmnest/mdns/host-mdns/host-mdns.wit.go +101 -0
- package/go/gen/wasmnest/notify/host-notify/empty.s +3 -0
- package/go/gen/wasmnest/notify/host-notify/host-notify.wasm.go +13 -0
- package/go/gen/wasmnest/notify/host-notify/host-notify.wit.go +64 -0
- package/go/gen/wasmnest/peer/host-peer/abi.go +14 -0
- package/go/gen/wasmnest/peer/host-peer/empty.s +3 -0
- package/go/gen/wasmnest/peer/host-peer/host-peer.wasm.go +85 -0
- package/go/gen/wasmnest/peer/host-peer/host-peer.wit.go +357 -0
- package/go/gen/wasmnest/platform-desktop/host-platform-desktop/empty.s +3 -0
- package/go/gen/wasmnest/platform-desktop/host-platform-desktop/host-platform-desktop.wasm.go +21 -0
- package/go/gen/wasmnest/platform-desktop/host-platform-desktop/host-platform-desktop.wit.go +70 -0
- package/go/gen/wasmnest/plugin/abi-form/abi-form.exports.go +11 -0
- package/go/gen/wasmnest/plugin/abi-form/abi-form.wasm.go +13 -0
- package/go/gen/wasmnest/plugin/abi-form/abi-form.wit.go +7 -0
- package/go/gen/wasmnest/plugin/abi-form/empty.s +3 -0
- package/go/gen/wasmnest/plugin/command/command.exports.go +11 -0
- package/go/gen/wasmnest/plugin/command/command.wasm.go +19 -0
- package/go/gen/wasmnest/plugin/command/command.wit.go +6 -0
- package/go/gen/wasmnest/plugin/command/empty.s +3 -0
- package/go/gen/wasmnest/plugin/events/empty.s +3 -0
- package/go/gen/wasmnest/plugin/events/events.exports.go +52 -0
- package/go/gen/wasmnest/plugin/events/events.wasm.go +74 -0
- package/go/gen/wasmnest/plugin/events/events.wit.go +195 -0
- package/go/gen/wasmnest/plugin/host-bus/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-bus/host-bus.wasm.go +29 -0
- package/go/gen/wasmnest/plugin/host-bus/host-bus.wit.go +94 -0
- package/go/gen/wasmnest/plugin/host-config/abi.go +14 -0
- package/go/gen/wasmnest/plugin/host-config/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-config/host-config.wasm.go +13 -0
- package/go/gen/wasmnest/plugin/host-config/host-config.wit.go +21 -0
- package/go/gen/wasmnest/plugin/host-events/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-events/host-events.wasm.go +9 -0
- package/go/gen/wasmnest/plugin/host-events/host-events.wit.go +27 -0
- package/go/gen/wasmnest/plugin/host-fs/abi.go +14 -0
- package/go/gen/wasmnest/plugin/host-fs/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-fs/host-fs.wasm.go +33 -0
- package/go/gen/wasmnest/plugin/host-fs/host-fs.wit.go +86 -0
- package/go/gen/wasmnest/plugin/host-log/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-log/host-log.wasm.go +25 -0
- package/go/gen/wasmnest/plugin/host-log/host-log.wit.go +65 -0
- package/go/gen/wasmnest/plugin/host-metrics/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-metrics/host-metrics.wasm.go +13 -0
- package/go/gen/wasmnest/plugin/host-metrics/host-metrics.wit.go +34 -0
- package/go/gen/wasmnest/plugin/host-platform/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-platform/host-platform.wasm.go +21 -0
- package/go/gen/wasmnest/plugin/host-platform/host-platform.wit.go +85 -0
- package/go/gen/wasmnest/plugin/host-plugin-database/abi.go +14 -0
- package/go/gen/wasmnest/plugin/host-plugin-database/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-plugin-database/host-plugin-database.wasm.go +29 -0
- package/go/gen/wasmnest/plugin/host-plugin-database/host-plugin-database.wit.go +70 -0
- package/go/gen/wasmnest/plugin/host-storage/abi.go +14 -0
- package/go/gen/wasmnest/plugin/host-storage/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-storage/host-storage.wasm.go +21 -0
- package/go/gen/wasmnest/plugin/host-storage/host-storage.wit.go +44 -0
- package/go/gen/wasmnest/plugin/host-worker/empty.s +3 -0
- package/go/gen/wasmnest/plugin/host-worker/host-worker.wasm.go +17 -0
- package/go/gen/wasmnest/plugin/host-worker/host-worker.wit.go +50 -0
- package/go/gen/wasmnest/plugin/lifecycle/empty.s +3 -0
- package/go/gen/wasmnest/plugin/lifecycle/lifecycle.exports.go +32 -0
- package/go/gen/wasmnest/plugin/lifecycle/lifecycle.wasm.go +41 -0
- package/go/gen/wasmnest/plugin/lifecycle/lifecycle.wit.go +9 -0
- package/go/gen/wasmnest/plugin/manifest/empty.s +3 -0
- package/go/gen/wasmnest/plugin/manifest/manifest.exports.go +11 -0
- package/go/gen/wasmnest/plugin/manifest/manifest.wasm.go +13 -0
- package/go/gen/wasmnest/plugin/manifest/manifest.wit.go +6 -0
- package/go/gen/wasmnest/plugin/plugin/plugin.wit.go +4 -0
- package/go/gen/wasmnest/process/host-process/empty.s +3 -0
- package/go/gen/wasmnest/process/host-process/host-process.wasm.go +21 -0
- package/go/gen/wasmnest/process/host-process/host-process.wit.go +56 -0
- package/go/gen/wasmnest/pty/host-pty/abi.go +14 -0
- package/go/gen/wasmnest/pty/host-pty/empty.s +3 -0
- package/go/gen/wasmnest/pty/host-pty/host-pty.wasm.go +33 -0
- package/go/gen/wasmnest/pty/host-pty/host-pty.wit.go +164 -0
- package/go/gen/wasmnest/task/host-task/abi.go +14 -0
- package/go/gen/wasmnest/task/host-task/empty.s +3 -0
- package/go/gen/wasmnest/task/host-task/host-task.wasm.go +29 -0
- package/go/gen/wasmnest/task/host-task/host-task.wit.go +110 -0
- package/go/gen/wasmnest/timer/host-timer/empty.s +3 -0
- package/go/gen/wasmnest/timer/host-timer/host-timer.wasm.go +13 -0
- package/go/gen/wasmnest/timer/host-timer/host-timer.wit.go +25 -0
- package/go/gen/wasmnest/ws/host-websocket/empty.s +3 -0
- package/go/gen/wasmnest/ws/host-websocket/host-websocket.wasm.go +29 -0
- package/go/gen/wasmnest/ws/host-websocket/host-websocket.wit.go +109 -0
- package/go/gen/wasmnest/ws-server/host-websocket-server/empty.s +3 -0
- package/go/gen/wasmnest/ws-server/host-websocket-server/host-websocket-server.wasm.go +49 -0
- package/go/gen/wasmnest/ws-server/host-websocket-server/host-websocket-server.wit.go +220 -0
- package/go/go.mod +14 -0
- package/go/go.sum +2 -0
- package/go/sdk/dispatch.go +49 -0
- package/go/sdk/dispatch_test.go +81 -0
- package/go/sdk/entry_native.go +13 -0
- package/go/sdk/entry_wasip2.go +188 -0
- package/go/sdk/host_http_wasip2.go +42 -0
- package/go/sdk/host_wasip2.go +251 -0
- package/go/sdk/plugin.go +103 -0
- package/go/testplugin/index.js +1 -0
- package/go/testplugin/main.go +67 -0
- package/go/testplugin/plugin.json +24 -0
- package/go/tools/assemble-wit.mjs +152 -0
- package/go/tools/gen-bindings.mjs +51 -0
- package/go/wit/core.wit +273 -0
- package/go/wit/deps/api-call/cap-api-call.wit +20 -0
- package/go/wit/deps/app/cap-app.wit +54 -0
- package/go/wit/deps/auth-center/cap-auth-center.wit +124 -0
- package/go/wit/deps/clipboard/clipboard.wit +48 -0
- package/go/wit/deps/clocks/monotonic-clock.wit +45 -0
- package/go/wit/deps/clocks/wall-clock.wit +42 -0
- package/go/wit/deps/clocks/world.wit +6 -0
- package/go/wit/deps/connection-registry/cap-connection-registry.wit +40 -0
- package/go/wit/deps/crypto/cap-crypto.wit +68 -0
- package/go/wit/deps/filesystem/preopens.wit +8 -0
- package/go/wit/deps/filesystem/types.wit +634 -0
- package/go/wit/deps/filesystem/world.wit +6 -0
- package/go/wit/deps/fs-desktop/cap-fs-desktop.wit +29 -0
- package/go/wit/deps/http/http.wit +28 -0
- package/go/wit/deps/http-endpoint/cap-http.wit +44 -0
- package/go/wit/deps/io/error.wit +34 -0
- package/go/wit/deps/io/poll.wit +41 -0
- package/go/wit/deps/io/streams.wit +262 -0
- package/go/wit/deps/io/world.wit +6 -0
- package/go/wit/deps/mdns/mdns.wit +45 -0
- package/go/wit/deps/notify/notify.wit +51 -0
- package/go/wit/deps/peer/peer.wit +126 -0
- package/go/wit/deps/platform-desktop/cap-platform-desktop.wit +38 -0
- package/go/wit/deps/process/cap-process.wit +25 -0
- package/go/wit/deps/pty/pty.wit +80 -0
- package/go/wit/deps/random/insecure-seed.wit +25 -0
- package/go/wit/deps/random/insecure.wit +22 -0
- package/go/wit/deps/random/random.wit +26 -0
- package/go/wit/deps/random/world.wit +7 -0
- package/go/wit/deps/sockets/instance-network.wit +9 -0
- package/go/wit/deps/sockets/ip-name-lookup.wit +51 -0
- package/go/wit/deps/sockets/network.wit +145 -0
- package/go/wit/deps/sockets/tcp-create-socket.wit +27 -0
- package/go/wit/deps/sockets/tcp.wit +353 -0
- package/go/wit/deps/sockets/udp-create-socket.wit +27 -0
- package/go/wit/deps/sockets/udp.wit +266 -0
- package/go/wit/deps/sockets/world.wit +11 -0
- package/go/wit/deps/task/cap-task.wit +56 -0
- package/go/wit/deps/timer/cap-timer.wit +14 -0
- package/go/wit/deps/wasi-cli/command.wit +7 -0
- package/go/wit/deps/wasi-cli/environment.wit +18 -0
- package/go/wit/deps/wasi-cli/exit.wit +4 -0
- package/go/wit/deps/wasi-cli/imports.wit +20 -0
- package/go/wit/deps/wasi-cli/run.wit +4 -0
- package/go/wit/deps/wasi-cli/stdio.wit +17 -0
- package/go/wit/deps/wasi-cli/terminal.wit +49 -0
- package/go/wit/deps/ws/ws.wit +50 -0
- package/go/wit/deps/ws-server/cap-ws.wit +99 -0
- package/go/wit/go-plugin.wit +28 -0
- package/go/wit/plugin-face.wit +355 -0
- package/go/wit/wasmnest.wit +25 -0
- package/package.json +12 -1
- package/src/index.ts +8 -0
- package/src/types.ts +681 -630
- package/src/ui/AppUpdateSection.d.ts +44 -0
- package/src/ui/AppUpdateSection.vue +253 -0
- package/src/ui/NumberField.d.ts +49 -0
- package/src/ui/NumberField.vue +390 -0
- package/src/ui/Select.vue +4 -4
- package/src/update.ts +123 -0
- package/template/README.md +39 -39
- package/tools/componentize/Cargo.lock +30 -1
- package/tools/componentize/Cargo.toml +3 -0
- package/tools/componentize/src/main.rs +197 -94
- package/dev-shell/src/mock/agent-hub-commands.ts +0 -1065
- package/dev-shell/src/mock/agent-hub.ts +0 -42
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { DefineComponent } from 'vue'
|
|
2
|
+
import type { AppUpdateCheckResult } from '../types'
|
|
3
|
+
|
|
4
|
+
/** 默认更新卡片文案(应用可覆盖任意字段;`{version}` 由组件替换) */
|
|
5
|
+
export interface AppUpdateLabels {
|
|
6
|
+
title: string
|
|
7
|
+
check: string
|
|
8
|
+
checking: string
|
|
9
|
+
upToDate: string
|
|
10
|
+
available: string
|
|
11
|
+
incompatible: string
|
|
12
|
+
failed: string
|
|
13
|
+
unsupported: string
|
|
14
|
+
reasonNoCompat: string
|
|
15
|
+
reasonMountContract: string
|
|
16
|
+
reasonHostRuntime: string
|
|
17
|
+
reasonHostRuntimeInvalid: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** AppUpdateSection 组件 props */
|
|
21
|
+
export interface AppUpdateSectionProps {
|
|
22
|
+
/** 当前版本(可选;不传时用检查结果的 currentVersion) */
|
|
23
|
+
currentVersion?: string
|
|
24
|
+
/** 自定义检查器;缺省使用宿主 `PluginContext.appUpdate.check` */
|
|
25
|
+
check?: () => Promise<AppUpdateCheckResult>
|
|
26
|
+
/** 文案覆盖(缺省按系统语言内置中 / 英) */
|
|
27
|
+
labels?: Partial<AppUpdateLabels>
|
|
28
|
+
disabled?: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 应用更新检查卡片(SDK 默认实现)
|
|
33
|
+
*
|
|
34
|
+
* 用法(应用设置页直接嵌入):
|
|
35
|
+
* ```vue
|
|
36
|
+
* <AppUpdateSection />
|
|
37
|
+
* ```
|
|
38
|
+
* - 数据面 = 宿主 `PluginContext.appUpdate.check`(GitHub Release 统一判定)
|
|
39
|
+
* - 应用自实现更新检查时传 `check` 覆盖,或完全不用本组件
|
|
40
|
+
* - 更新动作统一在宿主应用管理页执行(需停用应用 + 换目录 + 重新审批)
|
|
41
|
+
*/
|
|
42
|
+
export declare const AppUpdateSection: DefineComponent<AppUpdateSectionProps>
|
|
43
|
+
|
|
44
|
+
export default AppUpdateSection
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!--
|
|
3
|
+
应用更新检查(SDK 默认实现)
|
|
4
|
+
|
|
5
|
+
应用设置页直接嵌入即可:宿主提供 GitHub Release 判定,本组件只负责状态与
|
|
6
|
+
展示。应用想自实现时不必使用本组件(或传 `check` 覆盖数据面)。
|
|
7
|
+
-->
|
|
8
|
+
<section class="wasmnest-update" data-testid="sdk-app-update">
|
|
9
|
+
<div class="wasmnest-update__row">
|
|
10
|
+
<div class="wasmnest-update__main">
|
|
11
|
+
<span v-if="text.title" class="wasmnest-update__title">{{ text.title }}</span>
|
|
12
|
+
<span v-if="versionLabel" class="wasmnest-update__version">{{ versionLabel }}</span>
|
|
13
|
+
</div>
|
|
14
|
+
<button
|
|
15
|
+
type="button"
|
|
16
|
+
class="wasmnest-update__button"
|
|
17
|
+
:disabled="disabled || checking || !supported"
|
|
18
|
+
:aria-busy="checking"
|
|
19
|
+
data-testid="sdk-app-update-check"
|
|
20
|
+
@click="onCheck"
|
|
21
|
+
>
|
|
22
|
+
{{ checking ? text.checking : text.check }}
|
|
23
|
+
</button>
|
|
24
|
+
</div>
|
|
25
|
+
<p
|
|
26
|
+
v-if="statusLabel"
|
|
27
|
+
class="wasmnest-update__status"
|
|
28
|
+
:class="{ 'is-error': isBad, 'is-available': status === 'available' }"
|
|
29
|
+
data-testid="sdk-app-update-status"
|
|
30
|
+
>
|
|
31
|
+
{{ statusLabel }}
|
|
32
|
+
</p>
|
|
33
|
+
<p
|
|
34
|
+
v-if="reasonLabel"
|
|
35
|
+
class="wasmnest-update__status is-error"
|
|
36
|
+
data-testid="sdk-app-update-reason"
|
|
37
|
+
>
|
|
38
|
+
{{ reasonLabel }}
|
|
39
|
+
</p>
|
|
40
|
+
</section>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<script setup lang="ts">
|
|
44
|
+
/**
|
|
45
|
+
* AppUpdateSection — SDK 默认应用更新卡片(双端同形)
|
|
46
|
+
*
|
|
47
|
+
* 数据面:`PluginContext.appUpdate.check`(宿主统一实现)或调用方传入的 `check`
|
|
48
|
+
* (应用自实现)。状态机在 `useAppUpdate`;本组件只做展示,不发起安装——
|
|
49
|
+
* 更新动作统一收口在宿主应用管理页(需要先停用应用、替换插件目录并重新审批)。
|
|
50
|
+
*
|
|
51
|
+
* 视觉:只依赖 `--mobile-*` / 桌面 `--bg-card` 等 token 的回退组合,不引入
|
|
52
|
+
* 任何一端专属组件;应用可在外层继续套自己的卡片样式。
|
|
53
|
+
*/
|
|
54
|
+
import { computed } from 'vue'
|
|
55
|
+
import { useAppUpdate } from '../update'
|
|
56
|
+
import type { AppUpdateCheckResult } from '../types'
|
|
57
|
+
|
|
58
|
+
/** 文案包(应用可覆盖任意字段;`{version}` 由组件替换) */
|
|
59
|
+
export interface AppUpdateLabels {
|
|
60
|
+
title: string
|
|
61
|
+
check: string
|
|
62
|
+
checking: string
|
|
63
|
+
upToDate: string
|
|
64
|
+
available: string
|
|
65
|
+
incompatible: string
|
|
66
|
+
failed: string
|
|
67
|
+
unsupported: string
|
|
68
|
+
reasonNoCompat: string
|
|
69
|
+
reasonMountContract: string
|
|
70
|
+
reasonHostRuntime: string
|
|
71
|
+
reasonHostRuntimeInvalid: string
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const props = withDefaults(
|
|
75
|
+
defineProps<{
|
|
76
|
+
/** 当前版本(可选;不传时用检查结果的 currentVersion) */
|
|
77
|
+
currentVersion?: string
|
|
78
|
+
/** 自定义检查器;缺省使用宿主 `PluginContext.appUpdate.check` */
|
|
79
|
+
check?: () => Promise<AppUpdateCheckResult>
|
|
80
|
+
/** 文案覆盖(缺省按系统语言内置中 / 英) */
|
|
81
|
+
labels?: Partial<AppUpdateLabels>
|
|
82
|
+
disabled?: boolean
|
|
83
|
+
}>(),
|
|
84
|
+
{ currentVersion: '', check: undefined, labels: undefined, disabled: false },
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
const ZH: AppUpdateLabels = {
|
|
88
|
+
title: '版本更新',
|
|
89
|
+
check: '检查更新',
|
|
90
|
+
checking: '正在检查…',
|
|
91
|
+
upToDate: '已是最新版本(v{version})',
|
|
92
|
+
available: '发现新版本 v{version};请在应用管理中更新',
|
|
93
|
+
incompatible: '发现新版本 v{version},但与当前平台不兼容',
|
|
94
|
+
failed: '检查失败,请稍后重试',
|
|
95
|
+
unsupported: '当前平台不提供更新检查',
|
|
96
|
+
reasonNoCompat: '该发布物缺少兼容声明(旧版发布格式),无法确认与当前平台兼容',
|
|
97
|
+
reasonMountContract: '要求挂载契约 {required},当前平台为 {current}',
|
|
98
|
+
reasonHostRuntime: '要求宿主运行时 {required},当前为 {current};请先升级平台',
|
|
99
|
+
reasonHostRuntimeInvalid: '兼容声明版本形态异常({required}),已拒绝',
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const EN: AppUpdateLabels = {
|
|
103
|
+
title: 'Version update',
|
|
104
|
+
check: 'Check for updates',
|
|
105
|
+
checking: 'Checking…',
|
|
106
|
+
upToDate: 'Up to date (v{version})',
|
|
107
|
+
available: 'v{version} available; update it in App Management',
|
|
108
|
+
incompatible: 'v{version} found, but it is incompatible with this platform',
|
|
109
|
+
failed: 'Update check failed, try again later',
|
|
110
|
+
unsupported: 'Update check is not available on this platform',
|
|
111
|
+
reasonNoCompat:
|
|
112
|
+
'The release lacks a compatibility declaration (legacy format); compatibility cannot be confirmed',
|
|
113
|
+
reasonMountContract: 'Requires mount contract {required}; this platform is {current}',
|
|
114
|
+
reasonHostRuntime:
|
|
115
|
+
'Requires host runtime {required}; this platform is {current}. Upgrade the platform first',
|
|
116
|
+
reasonHostRuntimeInvalid: 'Malformed compatibility version ({required}); refused',
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const text = computed<AppUpdateLabels>(() => {
|
|
120
|
+
const isZh = typeof navigator !== 'undefined' && navigator.language.toLowerCase().startsWith('zh')
|
|
121
|
+
return { ...(isZh ? ZH : EN), ...(props.labels ?? {}) }
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
const {
|
|
125
|
+
status,
|
|
126
|
+
latestVersion,
|
|
127
|
+
currentVersion,
|
|
128
|
+
reason,
|
|
129
|
+
checking,
|
|
130
|
+
supported,
|
|
131
|
+
check: runCheck,
|
|
132
|
+
} = useAppUpdate({ check: props.check })
|
|
133
|
+
|
|
134
|
+
const versionLabel = computed(() => {
|
|
135
|
+
const v = props.currentVersion || currentVersion.value
|
|
136
|
+
return v ? `v${v}` : ''
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
function fill(template: string, params: Record<string, string | undefined>): string {
|
|
140
|
+
return template.replace(/\{(\w+)\}/g, (_, key: string) => params[key] ?? '')
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const statusLabel = computed(() => {
|
|
144
|
+
if (!supported.value) return text.value.unsupported
|
|
145
|
+
switch (status.value) {
|
|
146
|
+
case 'checking':
|
|
147
|
+
return text.value.checking
|
|
148
|
+
case 'up-to-date':
|
|
149
|
+
return fill(text.value.upToDate, {
|
|
150
|
+
version: latestVersion.value || currentVersion.value || '',
|
|
151
|
+
})
|
|
152
|
+
case 'available':
|
|
153
|
+
return fill(text.value.available, { version: latestVersion.value || '' })
|
|
154
|
+
case 'incompatible':
|
|
155
|
+
return fill(text.value.incompatible, { version: latestVersion.value || '' })
|
|
156
|
+
case 'error':
|
|
157
|
+
return text.value.failed
|
|
158
|
+
default:
|
|
159
|
+
return ''
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
const isBad = computed(() => status.value === 'error' || status.value === 'incompatible')
|
|
164
|
+
|
|
165
|
+
const reasonLabel = computed(() => {
|
|
166
|
+
const r = reason.value
|
|
167
|
+
if (!r) return ''
|
|
168
|
+
const params = { ...(r.params ?? {}), version: latestVersion.value }
|
|
169
|
+
if (r.key.endsWith('noCompat')) return text.value.reasonNoCompat
|
|
170
|
+
if (r.key.endsWith('mountContract')) return fill(text.value.reasonMountContract, params)
|
|
171
|
+
if (r.key.endsWith('hostRuntimeInvalid')) return fill(text.value.reasonHostRuntimeInvalid, params)
|
|
172
|
+
if (r.key.endsWith('hostRuntime')) return fill(text.value.reasonHostRuntime, params)
|
|
173
|
+
return ''
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
function onCheck(): void {
|
|
177
|
+
void runCheck()
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
defineExpose({ check: runCheck })
|
|
181
|
+
</script>
|
|
182
|
+
|
|
183
|
+
<style scoped>
|
|
184
|
+
.wasmnest-update {
|
|
185
|
+
border: 1px solid var(--mobile-border, var(--border, rgba(127, 127, 127, 0.28)));
|
|
186
|
+
background: var(--mobile-bg-card, var(--bg-card, transparent));
|
|
187
|
+
border-radius: var(--mobile-radius-lg, 12px);
|
|
188
|
+
padding: 10px 12px;
|
|
189
|
+
display: flex;
|
|
190
|
+
flex-direction: column;
|
|
191
|
+
gap: 6px;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.wasmnest-update__row {
|
|
195
|
+
display: flex;
|
|
196
|
+
align-items: center;
|
|
197
|
+
gap: 10px;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.wasmnest-update__main {
|
|
201
|
+
flex: 1;
|
|
202
|
+
min-width: 0;
|
|
203
|
+
display: flex;
|
|
204
|
+
align-items: baseline;
|
|
205
|
+
gap: 8px;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.wasmnest-update__title {
|
|
209
|
+
font-size: 14px;
|
|
210
|
+
font-weight: 600;
|
|
211
|
+
color: var(--mobile-text-primary, var(--text-primary, inherit));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.wasmnest-update__version {
|
|
215
|
+
font-size: 12px;
|
|
216
|
+
color: var(--mobile-text-secondary, var(--text-secondary, #888));
|
|
217
|
+
font-variant-numeric: tabular-nums;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.wasmnest-update__button {
|
|
221
|
+
flex-shrink: 0;
|
|
222
|
+
min-height: var(--mobile-touch-target-min, 32px);
|
|
223
|
+
padding: 0 12px;
|
|
224
|
+
border-radius: var(--mobile-radius-md, 8px);
|
|
225
|
+
border: 1px solid var(--mobile-border, var(--border, rgba(127, 127, 127, 0.28)));
|
|
226
|
+
background: transparent;
|
|
227
|
+
color: var(--mobile-accent, var(--brand, #4f8cff));
|
|
228
|
+
font-size: 12px;
|
|
229
|
+
font-weight: 600;
|
|
230
|
+
cursor: pointer;
|
|
231
|
+
transition: opacity 0.2s ease;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.wasmnest-update__button:disabled {
|
|
235
|
+
opacity: 0.5;
|
|
236
|
+
cursor: not-allowed;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.wasmnest-update__status {
|
|
240
|
+
margin: 0;
|
|
241
|
+
font-size: 12px;
|
|
242
|
+
line-height: 1.5;
|
|
243
|
+
color: var(--mobile-text-secondary, var(--text-secondary, #888));
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.wasmnest-update__status.is-available {
|
|
247
|
+
color: var(--mobile-accent, var(--brand, #4f8cff));
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.wasmnest-update__status.is-error {
|
|
251
|
+
color: var(--mobile-error, var(--danger, #e5484d));
|
|
252
|
+
}
|
|
253
|
+
</style>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { DefineComponent } from 'vue'
|
|
2
|
+
|
|
3
|
+
/** NumberField 组件 props */
|
|
4
|
+
export interface NumberFieldProps {
|
|
5
|
+
/** 当前值;清空后以 null 回抛 */
|
|
6
|
+
modelValue: number | null
|
|
7
|
+
/** 下限(含) */
|
|
8
|
+
min?: number
|
|
9
|
+
/** 上限(含);不传 = 不设上限 */
|
|
10
|
+
max?: number
|
|
11
|
+
/** 每次点击 / 方向键的变化量,默认 1 */
|
|
12
|
+
step?: number
|
|
13
|
+
/** sm:插件紧凑行(32px 高 / 12.5px 字 / 24px 步进列);md:宿主表单默认(--input-height 36px / 28px 步进列) */
|
|
14
|
+
size?: 'sm' | 'md'
|
|
15
|
+
/** 文本对齐;设置页右侧控件用 right(默认),表单字段用 left */
|
|
16
|
+
align?: 'left' | 'right'
|
|
17
|
+
/** 宽度(CSS 长度);不传则铺满父容器 */
|
|
18
|
+
width?: string
|
|
19
|
+
/** 等宽字体,默认 true(端口 / 秒数这类纯数字更整齐) */
|
|
20
|
+
mono?: boolean
|
|
21
|
+
disabled?: boolean
|
|
22
|
+
readonly?: boolean
|
|
23
|
+
/** 无障碍名称(没有外置 label 时必须给) */
|
|
24
|
+
ariaLabel?: string
|
|
25
|
+
/** 增 / 减按钮的无障碍名称,默认「增加」/「减少」 */
|
|
26
|
+
labelIncrease?: string
|
|
27
|
+
labelDecrease?: string
|
|
28
|
+
testid?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 数字输入(含右侧竖排步进按钮)共享组件
|
|
33
|
+
*
|
|
34
|
+
* 取代原生 `<input type="number">`:原生 spinner 的上下箭头只有 6px 左右,点不中、
|
|
35
|
+
* 也不吃 token。本组件用 reka-ui 的 `Primitive` 原语下发元素(开源 headless),
|
|
36
|
+
* 值、解析、钳制、提交时机全部在本组件内闭环,视觉绑定宿主 token。
|
|
37
|
+
*
|
|
38
|
+
* 用法:
|
|
39
|
+
* ```vue
|
|
40
|
+
* <NumberField v-model="ttl" :min="60" :max="3600" @commit="save" />
|
|
41
|
+
* ```
|
|
42
|
+
* - `update:modelValue`:合法键入 / 步进即时抛;清空为 null。
|
|
43
|
+
* - `commit`:失焦或回车时抛,携带**已按 min/max 钳制**的最终值——落盘用它,
|
|
44
|
+
* 不要在 `@blur` 里读事件值。
|
|
45
|
+
* - 键位:↑/↓ 单步、PageUp/PageDown 十步、Home/End 到边界、Enter 提交。
|
|
46
|
+
*/
|
|
47
|
+
export declare const NumberField: DefineComponent<NumberFieldProps>
|
|
48
|
+
|
|
49
|
+
export default NumberField
|