@wailsnet/plugin-mobile 0.0.0-stage → 0.1.0-alpha.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/LICENSE +21 -0
- package/dist/index.d.ts +75 -0
- package/dist/index.js +80 -0
- package/package.json +28 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Wails.Net Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { CameraCaptureResult, DeviceInfo, GeoPosition, GeoWatchHandle, HapticsNotificationType, PermissionStatus } from "@wailsnet/runtime";
|
|
2
|
+
/**
|
|
3
|
+
* 硬件能力可用性。
|
|
4
|
+
* - `available` —— 可用
|
|
5
|
+
* - `unavailable` —— 硬件存在但当前不可用
|
|
6
|
+
* - `none` —— 无硬件支持
|
|
7
|
+
*/
|
|
8
|
+
export type Availability = "available" | "unavailable" | "none";
|
|
9
|
+
/** 条码扫描(命令前缀 `barcode-scanner.*`)。 */
|
|
10
|
+
export declare const barcodeScanner: {
|
|
11
|
+
/** 启动扫描,返回扫描到的文本内容。 */
|
|
12
|
+
scan: () => import("@wailsnet/runtime").CancellablePromise<string>;
|
|
13
|
+
cancel: () => import("@wailsnet/runtime").CancellablePromise<void>;
|
|
14
|
+
};
|
|
15
|
+
/** 生物识别(命令前缀 `biometric.*`)。 */
|
|
16
|
+
export declare const biometric: {
|
|
17
|
+
checkAvailability: () => import("@wailsnet/runtime").CancellablePromise<Availability>;
|
|
18
|
+
/** @param reason 展示给用户的认证理由文本。 */
|
|
19
|
+
authenticate: (reason: string) => import("@wailsnet/runtime").CancellablePromise<boolean>;
|
|
20
|
+
};
|
|
21
|
+
/** 相机(命令前缀 `camera.*`)。 */
|
|
22
|
+
export declare const camera: {
|
|
23
|
+
checkAvailability: () => import("@wailsnet/runtime").CancellablePromise<Availability>;
|
|
24
|
+
capture: () => import("@wailsnet/runtime").CancellablePromise<CameraCaptureResult>;
|
|
25
|
+
cancel: () => import("@wailsnet/runtime").CancellablePromise<void>;
|
|
26
|
+
};
|
|
27
|
+
/** `geolocation.*` 的定位参数。 */
|
|
28
|
+
export interface GeolocationOptions {
|
|
29
|
+
/** 是否启用高精度定位。 */
|
|
30
|
+
enableHighAccuracy?: boolean;
|
|
31
|
+
/** 超时毫秒数。 */
|
|
32
|
+
timeout?: number;
|
|
33
|
+
/** 可接受的缓存位置最大存活毫秒数。 */
|
|
34
|
+
maximumAge?: number;
|
|
35
|
+
}
|
|
36
|
+
/** 地理定位(命令前缀 `geolocation.*`)。 */
|
|
37
|
+
export declare const geolocation: {
|
|
38
|
+
checkAvailability: () => import("@wailsnet/runtime").CancellablePromise<Availability>;
|
|
39
|
+
getCurrentPosition: (options?: GeolocationOptions) => import("@wailsnet/runtime").CancellablePromise<GeoPosition | null>;
|
|
40
|
+
watchPosition: (options?: GeolocationOptions) => import("@wailsnet/runtime").CancellablePromise<GeoWatchHandle>;
|
|
41
|
+
/** @param handle `watchPosition` 返回的句柄,或直接传数字 `watchId`。 */
|
|
42
|
+
clearWatch: (handle: GeoWatchHandle | number) => import("@wailsnet/runtime").CancellablePromise<void>;
|
|
43
|
+
};
|
|
44
|
+
/** 触感反馈(命令前缀 `haptics.*`)。 */
|
|
45
|
+
export declare const haptics: {
|
|
46
|
+
/** @param duration 震动时长(毫秒)。 */
|
|
47
|
+
vibrate: (duration: number) => import("@wailsnet/runtime").CancellablePromise<void>;
|
|
48
|
+
notification: (type: HapticsNotificationType) => import("@wailsnet/runtime").CancellablePromise<void>;
|
|
49
|
+
cancel: () => import("@wailsnet/runtime").CancellablePromise<void>;
|
|
50
|
+
};
|
|
51
|
+
/** NFC(命令前缀 `nfc.*`)。 */
|
|
52
|
+
export declare const nfc: {
|
|
53
|
+
/** 读取 NFC 标签,返回文本内容。 */
|
|
54
|
+
read: () => import("@wailsnet/runtime").CancellablePromise<string>;
|
|
55
|
+
/** @param data 写入的文本数据。 */
|
|
56
|
+
write: (data: string) => import("@wailsnet/runtime").CancellablePromise<void>;
|
|
57
|
+
cancel: () => import("@wailsnet/runtime").CancellablePromise<void>;
|
|
58
|
+
};
|
|
59
|
+
/** 权限(命令前缀 `permissions.*`)。 */
|
|
60
|
+
export declare const permissions: {
|
|
61
|
+
check: (permission: string) => import("@wailsnet/runtime").CancellablePromise<PermissionStatus>;
|
|
62
|
+
request: (permission: string) => import("@wailsnet/runtime").CancellablePromise<PermissionStatus>;
|
|
63
|
+
};
|
|
64
|
+
/** 设备信息 / Toast(Android 运行时插件,命令前缀 `device.*` / `toast.*`)。 */
|
|
65
|
+
export declare const device: {
|
|
66
|
+
/**
|
|
67
|
+
* 获取设备信息。
|
|
68
|
+
* 后端返回 JSON 字符串,此处解析为对象。
|
|
69
|
+
*/
|
|
70
|
+
info: () => Promise<DeviceInfo>;
|
|
71
|
+
/** 获取设备信息的后端原始 JSON 字符串。 */
|
|
72
|
+
infoRaw: () => import("@wailsnet/runtime").CancellablePromise<string>;
|
|
73
|
+
/** 弹出系统 Toast。 */
|
|
74
|
+
showToast: (message: string) => import("@wailsnet/runtime").CancellablePromise<void>;
|
|
75
|
+
};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @wailsnet/plugin-mobile — 移动端插件聚合封装(M3 双包模型)。
|
|
3
|
+
* 条码扫描/生物识别/相机/定位/触感/NFC/权限/设备(AndroidRuntimePlugin)。
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 移动端插件命令封装(Android / iOS 通用):
|
|
7
|
+
* 条码扫描、生物识别、相机、定位、触感、NFC、权限、设备信息。
|
|
8
|
+
*
|
|
9
|
+
* 说明:`camera.capture` / `nfc.read` / `barcode-scanner.scan` 等命令的取消由后端
|
|
10
|
+
* `ICommandContext.CancellationToken` 提供,**不接受前端传参**(见 AGENTS.md §3.4.6)。
|
|
11
|
+
*/
|
|
12
|
+
import { call } from "@wailsnet/runtime";
|
|
13
|
+
/** 条码扫描(命令前缀 `barcode-scanner.*`)。 */
|
|
14
|
+
export const barcodeScanner = {
|
|
15
|
+
/** 启动扫描,返回扫描到的文本内容。 */
|
|
16
|
+
scan: () => call("barcode-scanner.scan", []),
|
|
17
|
+
cancel: () => call("barcode-scanner.cancel", []),
|
|
18
|
+
};
|
|
19
|
+
/** 生物识别(命令前缀 `biometric.*`)。 */
|
|
20
|
+
export const biometric = {
|
|
21
|
+
checkAvailability: () => call("biometric.checkAvailability", []),
|
|
22
|
+
/** @param reason 展示给用户的认证理由文本。 */
|
|
23
|
+
authenticate: (reason) => call("biometric.authenticate", [{ reason }]),
|
|
24
|
+
};
|
|
25
|
+
/** 相机(命令前缀 `camera.*`)。 */
|
|
26
|
+
export const camera = {
|
|
27
|
+
checkAvailability: () => call("camera.checkAvailability", []),
|
|
28
|
+
capture: () => call("camera.capture", []),
|
|
29
|
+
cancel: () => call("camera.cancel", []),
|
|
30
|
+
};
|
|
31
|
+
/** 地理定位(命令前缀 `geolocation.*`)。 */
|
|
32
|
+
export const geolocation = {
|
|
33
|
+
checkAvailability: () => call("geolocation.checkAvailability", []),
|
|
34
|
+
getCurrentPosition: (options) => call("geolocation.getCurrentPosition", [options ?? null]),
|
|
35
|
+
watchPosition: (options) => call("geolocation.watchPosition", [options ?? null]),
|
|
36
|
+
/** @param handle `watchPosition` 返回的句柄,或直接传数字 `watchId`。 */
|
|
37
|
+
clearWatch: (handle) => call("geolocation.clearWatch", [
|
|
38
|
+
typeof handle === "number" ? { watchId: handle } : { watchId: handle.watchId },
|
|
39
|
+
]),
|
|
40
|
+
};
|
|
41
|
+
/** 触感反馈(命令前缀 `haptics.*`)。 */
|
|
42
|
+
export const haptics = {
|
|
43
|
+
/** @param duration 震动时长(毫秒)。 */
|
|
44
|
+
vibrate: (duration) => call("haptics.vibrate", [{ duration }]),
|
|
45
|
+
notification: (type) => call("haptics.notification", [{ type }]),
|
|
46
|
+
cancel: () => call("haptics.cancel", []),
|
|
47
|
+
};
|
|
48
|
+
/** NFC(命令前缀 `nfc.*`)。 */
|
|
49
|
+
export const nfc = {
|
|
50
|
+
/** 读取 NFC 标签,返回文本内容。 */
|
|
51
|
+
read: () => call("nfc.read", []),
|
|
52
|
+
/** @param data 写入的文本数据。 */
|
|
53
|
+
write: (data) => call("nfc.write", [{ data }]),
|
|
54
|
+
cancel: () => call("nfc.cancel", []),
|
|
55
|
+
};
|
|
56
|
+
/** 权限(命令前缀 `permissions.*`)。 */
|
|
57
|
+
export const permissions = {
|
|
58
|
+
check: (permission) => call("permissions.check", [permission]),
|
|
59
|
+
request: (permission) => call("permissions.request", [permission]),
|
|
60
|
+
};
|
|
61
|
+
/** 设备信息 / Toast(Android 运行时插件,命令前缀 `device.*` / `toast.*`)。 */
|
|
62
|
+
export const device = {
|
|
63
|
+
/**
|
|
64
|
+
* 获取设备信息。
|
|
65
|
+
* 后端返回 JSON 字符串,此处解析为对象。
|
|
66
|
+
*/
|
|
67
|
+
info: async () => {
|
|
68
|
+
const raw = await call("device.info", []);
|
|
69
|
+
try {
|
|
70
|
+
return JSON.parse(raw);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return {};
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
/** 获取设备信息的后端原始 JSON 字符串。 */
|
|
77
|
+
infoRaw: () => call("device.info", []),
|
|
78
|
+
/** 弹出系统 Toast。 */
|
|
79
|
+
showToast: (message) => call("toast.show", [{ message }]),
|
|
80
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wailsnet/plugin-mobile",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@wailsnet/runtime": "0.1.0-alpha.1"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"typescript": "^5.9.3"
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public",
|
|
25
|
+
"registry": "https://registry.npmjs.org"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc -p tsconfig.json",
|
|
29
|
+
"typecheck": "tsc --noEmit"
|
|
30
|
+
}
|
|
6
31
|
}
|
package/README.md
DELETED