@lingxia/types 0.1.2 → 0.4.3
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/dist/app/index.d.ts +7 -0
- package/dist/app/index.d.ts.map +1 -1
- package/dist/device/actions.d.ts +8 -0
- package/dist/device/actions.d.ts.map +1 -0
- package/dist/device/actions.js +7 -0
- package/dist/device/actions.js.map +1 -0
- package/dist/device/index.d.ts +4 -37
- package/dist/device/index.d.ts.map +1 -1
- package/dist/device/index.js +18 -4
- package/dist/device/index.js.map +1 -1
- package/dist/device/info.d.ts +17 -0
- package/dist/device/info.d.ts.map +1 -0
- package/dist/device/info.js +7 -0
- package/dist/device/info.js.map +1 -0
- package/dist/device/network.d.ts +13 -0
- package/dist/device/network.d.ts.map +1 -0
- package/dist/device/network.js +7 -0
- package/dist/device/network.js.map +1 -0
- package/dist/device/wifi.d.ts +21 -0
- package/dist/device/wifi.d.ts.map +1 -0
- package/dist/device/wifi.js +7 -0
- package/dist/device/wifi.js.map +1 -0
- package/dist/display/index.d.ts +9 -0
- package/dist/display/index.d.ts.map +1 -0
- package/dist/display/index.js +7 -0
- package/dist/display/index.js.map +1 -0
- package/dist/error.d.ts +15 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +85 -0
- package/dist/error.js.map +1 -0
- package/dist/file/index.d.ts +102 -0
- package/dist/file/index.d.ts.map +1 -0
- package/dist/file/index.js +7 -0
- package/dist/file/index.js.map +1 -0
- package/dist/generated/error.d.ts +165 -0
- package/dist/generated/error.d.ts.map +1 -0
- package/dist/generated/error.js +46 -0
- package/dist/generated/error.js.map +1 -0
- package/dist/generated/i18n.d.ts +3 -0
- package/dist/generated/i18n.d.ts.map +1 -0
- package/dist/generated/i18n.js +124 -0
- package/dist/generated/i18n.js.map +1 -0
- package/dist/index.d.ts +44 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/media/index.d.ts +233 -3
- package/dist/media/index.d.ts.map +1 -1
- package/dist/navigator/index.d.ts +10 -0
- package/dist/navigator/index.d.ts.map +1 -0
- package/dist/navigator/index.js +7 -0
- package/dist/navigator/index.js.map +1 -0
- package/dist/storage/index.d.ts +2 -7
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +2 -2
- package/dist/system/index.d.ts +3 -12
- package/dist/system/index.d.ts.map +1 -1
- package/dist/system/index.js +1 -1
- package/dist/update/index.d.ts +18 -0
- package/dist/update/index.d.ts.map +1 -0
- package/dist/update/index.js +7 -0
- package/dist/update/index.js.map +1 -0
- package/package.json +29 -3
- package/src/app/index.ts +9 -0
- package/src/device/actions.ts +8 -0
- package/src/device/index.ts +4 -46
- package/src/device/info.ts +18 -0
- package/src/device/network.ts +24 -0
- package/src/device/wifi.ts +24 -0
- package/src/display/index.ts +10 -0
- package/src/error.ts +82 -0
- package/src/file/index.ts +121 -0
- package/src/generated/error.ts +52 -0
- package/src/generated/i18n.ts +123 -0
- package/src/index.ts +65 -8
- package/src/media/index.ts +250 -3
- package/src/navigator/index.ts +10 -0
- package/src/storage/index.ts +2 -8
- package/src/system/index.ts +3 -14
- package/src/update/index.ts +20 -0
package/src/error.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ERR_CODE_INFO_BY_CODE, type LxErrorCodeInfo } from "./generated/error";
|
|
2
|
+
|
|
3
|
+
const ERR_CODE_INDEX = ERR_CODE_INFO_BY_CODE as Record<number, LxErrorCodeInfo>;
|
|
4
|
+
|
|
5
|
+
export interface LxApiError {
|
|
6
|
+
readonly code: number;
|
|
7
|
+
readonly key: LxErrorCodeInfo["key"];
|
|
8
|
+
readonly message: string;
|
|
9
|
+
readonly raw: unknown;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function isLxApiError(error: unknown): error is LxApiError {
|
|
13
|
+
return parseLxApiError(error) !== null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function readMessage(error: unknown): string {
|
|
17
|
+
if (typeof error === "string") return error;
|
|
18
|
+
if (error instanceof Error && typeof error.message === "string") return error.message;
|
|
19
|
+
if (typeof error === "object" && error !== null) {
|
|
20
|
+
const value = (error as { message?: unknown }).message;
|
|
21
|
+
if (typeof value === "string") return value;
|
|
22
|
+
}
|
|
23
|
+
return "Unknown LingXia error";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function toRecord(value: unknown): Record<string, unknown> | null {
|
|
27
|
+
if (typeof value !== "object" || value === null) return null;
|
|
28
|
+
return value as Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function parseIntegerCode(value: unknown): number | null {
|
|
32
|
+
if (typeof value === "number" && Number.isInteger(value)) return value;
|
|
33
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
34
|
+
const parsed = Number(value);
|
|
35
|
+
if (Number.isInteger(parsed)) return parsed;
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function extractLxErrorCode(error: unknown): number | null {
|
|
41
|
+
const root = toRecord(error);
|
|
42
|
+
if (!root) return null;
|
|
43
|
+
|
|
44
|
+
const rootCode = parseIntegerCode(root.code);
|
|
45
|
+
if (rootCode !== null) return rootCode;
|
|
46
|
+
|
|
47
|
+
const data = toRecord(root.data);
|
|
48
|
+
if (!data) return null;
|
|
49
|
+
|
|
50
|
+
return parseIntegerCode(data.bizCode) ?? parseIntegerCode(data.code);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function isKnownLxErrorCode(code: number): boolean {
|
|
54
|
+
return Number.isInteger(code) && Object.prototype.hasOwnProperty.call(ERR_CODE_INDEX, code);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function infoForLxErrorCode(code: number): LxErrorCodeInfo | null {
|
|
58
|
+
if (!isKnownLxErrorCode(code)) return null;
|
|
59
|
+
return ERR_CODE_INDEX[code];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function parseLxApiError(error: unknown): LxApiError | null {
|
|
63
|
+
const code = extractLxErrorCode(error);
|
|
64
|
+
if (code === null) return null;
|
|
65
|
+
const info = infoForLxErrorCode(code);
|
|
66
|
+
if (!info) return null;
|
|
67
|
+
return {
|
|
68
|
+
...info,
|
|
69
|
+
message: readMessage(error),
|
|
70
|
+
raw: error,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function requireLxApiError(error: unknown): LxApiError {
|
|
75
|
+
const parsed = parseLxApiError(error);
|
|
76
|
+
if (parsed) return parsed;
|
|
77
|
+
throw new Error(`Unknown LingXia API error: ${readMessage(error)}`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function formatLxApiError(error: LxApiError): string {
|
|
81
|
+
return `[${error.code}] ${error.message}`;
|
|
82
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File system APIs.
|
|
3
|
+
* Corresponds to: lingxia-logic/src/fs.rs
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface OpenDocumentOptions {
|
|
7
|
+
filePath: string;
|
|
8
|
+
fileType?: string;
|
|
9
|
+
showMenu?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Desktop only. Currently supported on macOS. Windows is planned. */
|
|
13
|
+
export interface FileDialogFilter {
|
|
14
|
+
/** Optional label shown in the native dialog. */
|
|
15
|
+
name?: string;
|
|
16
|
+
/** Allowed extensions without dots, e.g. ['pdf', 'txt']. */
|
|
17
|
+
extensions: string[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Desktop only. Currently supported on macOS. Windows is planned. */
|
|
21
|
+
export interface ChooseFileOptions {
|
|
22
|
+
/** Allow selecting multiple files. Default: false */
|
|
23
|
+
multiple?: boolean;
|
|
24
|
+
/** Optional file filters. Empty or omitted means all file types. */
|
|
25
|
+
filters?: FileDialogFilter[];
|
|
26
|
+
/** Dialog window title. Platform provides a default if omitted. */
|
|
27
|
+
title?: string;
|
|
28
|
+
/** Initial directory the dialog opens in. Platform default if omitted. */
|
|
29
|
+
defaultPath?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Desktop only. Currently supported on macOS. Windows is planned. */
|
|
33
|
+
export interface ChooseFileResult {
|
|
34
|
+
/** True if the user dismissed the dialog without selecting. */
|
|
35
|
+
canceled: boolean;
|
|
36
|
+
/** Absolute system paths of selected files. Empty when canceled. */
|
|
37
|
+
paths: string[];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Desktop only. Currently supported on macOS. Windows is planned. */
|
|
41
|
+
export interface ChooseDirectoryOptions {
|
|
42
|
+
/** Dialog window title. Platform provides a default if omitted. */
|
|
43
|
+
title?: string;
|
|
44
|
+
/** Initial directory the dialog opens in. Platform default if omitted. */
|
|
45
|
+
defaultPath?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Desktop only. Currently supported on macOS. Windows is planned. */
|
|
49
|
+
export interface ChooseDirectoryResult {
|
|
50
|
+
/** True if the user dismissed the dialog without selecting. */
|
|
51
|
+
canceled: boolean;
|
|
52
|
+
/** Absolute system path of the selected directory. Undefined when canceled. */
|
|
53
|
+
path?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface DownloadOptions {
|
|
57
|
+
/** HTTP(S) source URL. */
|
|
58
|
+
url: string;
|
|
59
|
+
/**
|
|
60
|
+
* Optional external cancellation channel.
|
|
61
|
+
* When aborted, it has the same effect as calling `task.cancel()`.
|
|
62
|
+
* Useful for timeout/router/lifecycle composition.
|
|
63
|
+
*/
|
|
64
|
+
signal?: AbortSignal;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface DownloadResult {
|
|
68
|
+
/** Downloaded file URI under user cache, e.g. lx://usercache/... */
|
|
69
|
+
tempFilePath: string;
|
|
70
|
+
/** Suggested filename resolved by runtime from headers/url. */
|
|
71
|
+
fileName: string;
|
|
72
|
+
/** MIME type when available. */
|
|
73
|
+
mimeType?: string;
|
|
74
|
+
/** File size in bytes. */
|
|
75
|
+
size: number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface DownloadProgressEvent {
|
|
79
|
+
kind: 'progress';
|
|
80
|
+
downloadedBytes: number;
|
|
81
|
+
totalBytes?: number;
|
|
82
|
+
/**
|
|
83
|
+
* 0~1 progress value.
|
|
84
|
+
* - precise ratio when totalBytes is known
|
|
85
|
+
* - monotonic estimated progress when totalBytes is unknown
|
|
86
|
+
*/
|
|
87
|
+
progress: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface DownloadSuccessEvent {
|
|
91
|
+
kind: 'success';
|
|
92
|
+
result: DownloadResult;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface DownloadPausedEvent {
|
|
96
|
+
kind: 'paused';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface DownloadResumedEvent {
|
|
100
|
+
kind: 'resumed';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface DownloadCanceledEvent {
|
|
104
|
+
kind: 'canceled';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export type DownloadEvent =
|
|
108
|
+
| DownloadProgressEvent
|
|
109
|
+
| DownloadSuccessEvent
|
|
110
|
+
| DownloadPausedEvent
|
|
111
|
+
| DownloadResumedEvent
|
|
112
|
+
| DownloadCanceledEvent;
|
|
113
|
+
|
|
114
|
+
export interface DownloadTask extends AsyncIterable<DownloadEvent> {
|
|
115
|
+
/** Pause current download and keep resume metadata. */
|
|
116
|
+
pause(): Promise<void>;
|
|
117
|
+
/** Resume a paused download from persisted resume metadata. */
|
|
118
|
+
resume(): Promise<void>;
|
|
119
|
+
/** Cancel and remove downloaded temp artifacts. */
|
|
120
|
+
cancel(): Promise<void>;
|
|
121
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Auto-generated by lingxia-gen. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
import type { I18nKey } from "./i18n";
|
|
4
|
+
|
|
5
|
+
export const ERR_CODE_INFO_BY_CODE = {
|
|
6
|
+
1000: { code: 1000, key: "err_code_1000" },
|
|
7
|
+
1001: { code: 1001, key: "err_code_1001" },
|
|
8
|
+
1002: { code: 1002, key: "err_code_1002" },
|
|
9
|
+
1003: { code: 1003, key: "err_code_1003" },
|
|
10
|
+
1004: { code: 1004, key: "err_code_1004" },
|
|
11
|
+
1005: { code: 1005, key: "err_code_1005" },
|
|
12
|
+
2000: { code: 2000, key: "err_code_2000" },
|
|
13
|
+
2001: { code: 2001, key: "err_code_2001" },
|
|
14
|
+
3000: { code: 3000, key: "err_code_3000" },
|
|
15
|
+
3001: { code: 3001, key: "err_code_3001" },
|
|
16
|
+
3002: { code: 3002, key: "err_code_3002" },
|
|
17
|
+
3003: { code: 3003, key: "err_code_3003" },
|
|
18
|
+
3004: { code: 3004, key: "err_code_3004" },
|
|
19
|
+
3005: { code: 3005, key: "err_code_3005" },
|
|
20
|
+
3006: { code: 3006, key: "err_code_3006" },
|
|
21
|
+
3007: { code: 3007, key: "err_code_3007" },
|
|
22
|
+
4000: { code: 4000, key: "err_code_4000" },
|
|
23
|
+
4001: { code: 4001, key: "err_code_4001" },
|
|
24
|
+
4002: { code: 4002, key: "err_code_4002" },
|
|
25
|
+
4003: { code: 4003, key: "err_code_4003" },
|
|
26
|
+
5000: { code: 5000, key: "err_code_5000" },
|
|
27
|
+
5001: { code: 5001, key: "err_code_5001" },
|
|
28
|
+
5002: { code: 5002, key: "err_code_5002" },
|
|
29
|
+
5003: { code: 5003, key: "err_code_5003" },
|
|
30
|
+
5004: { code: 5004, key: "err_code_5004" },
|
|
31
|
+
6000: { code: 6000, key: "err_code_6000" },
|
|
32
|
+
6001: { code: 6001, key: "err_code_6001" },
|
|
33
|
+
6002: { code: 6002, key: "err_code_6002" },
|
|
34
|
+
12000: { code: 12000, key: "err_code_12000" },
|
|
35
|
+
12001: { code: 12001, key: "err_code_12001" },
|
|
36
|
+
12002: { code: 12002, key: "err_code_12002" },
|
|
37
|
+
12003: { code: 12003, key: "err_code_12003" },
|
|
38
|
+
12004: { code: 12004, key: "err_code_12004" },
|
|
39
|
+
12005: { code: 12005, key: "err_code_12005" },
|
|
40
|
+
12006: { code: 12006, key: "err_code_12006" },
|
|
41
|
+
12007: { code: 12007, key: "err_code_12007" },
|
|
42
|
+
12008: { code: 12008, key: "err_code_12008" },
|
|
43
|
+
12009: { code: 12009, key: "err_code_12009" },
|
|
44
|
+
12010: { code: 12010, key: "err_code_12010" },
|
|
45
|
+
} as const;
|
|
46
|
+
|
|
47
|
+
export type LxErrorCode = (typeof ERR_CODE_INFO_BY_CODE)[keyof typeof ERR_CODE_INFO_BY_CODE]["code"];
|
|
48
|
+
export interface LxErrorCodeInfo {
|
|
49
|
+
readonly code: LxErrorCode;
|
|
50
|
+
readonly key: I18nKey;
|
|
51
|
+
}
|
|
52
|
+
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// Auto-generated by lingxia-gen. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
export const I18N_KEYS = [
|
|
4
|
+
"album_add_more_media",
|
|
5
|
+
"album_add_more_photos",
|
|
6
|
+
"album_add_more_videos",
|
|
7
|
+
"album_all_media",
|
|
8
|
+
"album_all_photos",
|
|
9
|
+
"album_all_videos",
|
|
10
|
+
"album_label",
|
|
11
|
+
"album_original_image",
|
|
12
|
+
"album_selected",
|
|
13
|
+
"camera_access_denied",
|
|
14
|
+
"camera_audio_init_failed",
|
|
15
|
+
"camera_cancelling",
|
|
16
|
+
"camera_init_failed",
|
|
17
|
+
"camera_label",
|
|
18
|
+
"camera_long_press_to_record",
|
|
19
|
+
"camera_max_duration_reached",
|
|
20
|
+
"camera_preparing",
|
|
21
|
+
"camera_record_video",
|
|
22
|
+
"camera_release_to_stop",
|
|
23
|
+
"camera_switch",
|
|
24
|
+
"camera_switch_failed",
|
|
25
|
+
"camera_switch_to_back",
|
|
26
|
+
"camera_switch_to_front",
|
|
27
|
+
"camera_switching",
|
|
28
|
+
"camera_tap_to_capture",
|
|
29
|
+
"camera_tap_to_record",
|
|
30
|
+
"camera_tap_to_stop",
|
|
31
|
+
"camera_video_input_failed",
|
|
32
|
+
"camera_video_output_failed",
|
|
33
|
+
"capsule_clean_cache",
|
|
34
|
+
"capsule_restart",
|
|
35
|
+
"capsule_uninstall",
|
|
36
|
+
"common_auto",
|
|
37
|
+
"common_back",
|
|
38
|
+
"common_cancel",
|
|
39
|
+
"common_close",
|
|
40
|
+
"common_confirm",
|
|
41
|
+
"common_delete",
|
|
42
|
+
"common_done",
|
|
43
|
+
"common_edit",
|
|
44
|
+
"common_home",
|
|
45
|
+
"common_loading",
|
|
46
|
+
"common_ok",
|
|
47
|
+
"common_retry",
|
|
48
|
+
"common_save",
|
|
49
|
+
"common_settings",
|
|
50
|
+
"common_share",
|
|
51
|
+
"common_success",
|
|
52
|
+
"common_warning",
|
|
53
|
+
"date_last_30_days",
|
|
54
|
+
"date_last_7_days",
|
|
55
|
+
"date_last_month",
|
|
56
|
+
"date_last_week",
|
|
57
|
+
"date_this_month",
|
|
58
|
+
"date_this_week",
|
|
59
|
+
"document_pdf_page_preview",
|
|
60
|
+
"err_code_1000",
|
|
61
|
+
"err_code_1001",
|
|
62
|
+
"err_code_1002",
|
|
63
|
+
"err_code_1003",
|
|
64
|
+
"err_code_1004",
|
|
65
|
+
"err_code_1005",
|
|
66
|
+
"err_code_12000",
|
|
67
|
+
"err_code_12001",
|
|
68
|
+
"err_code_12002",
|
|
69
|
+
"err_code_12003",
|
|
70
|
+
"err_code_12004",
|
|
71
|
+
"err_code_12005",
|
|
72
|
+
"err_code_12006",
|
|
73
|
+
"err_code_12007",
|
|
74
|
+
"err_code_12008",
|
|
75
|
+
"err_code_12009",
|
|
76
|
+
"err_code_12010",
|
|
77
|
+
"err_code_2000",
|
|
78
|
+
"err_code_2001",
|
|
79
|
+
"err_code_3000",
|
|
80
|
+
"err_code_3001",
|
|
81
|
+
"err_code_3002",
|
|
82
|
+
"err_code_3003",
|
|
83
|
+
"err_code_3004",
|
|
84
|
+
"err_code_3005",
|
|
85
|
+
"err_code_3006",
|
|
86
|
+
"err_code_3007",
|
|
87
|
+
"err_code_4000",
|
|
88
|
+
"err_code_4001",
|
|
89
|
+
"err_code_4002",
|
|
90
|
+
"err_code_4003",
|
|
91
|
+
"err_code_5000",
|
|
92
|
+
"err_code_5001",
|
|
93
|
+
"err_code_5002",
|
|
94
|
+
"err_code_5003",
|
|
95
|
+
"err_code_5004",
|
|
96
|
+
"err_code_6000",
|
|
97
|
+
"err_code_6001",
|
|
98
|
+
"err_code_6002",
|
|
99
|
+
"error_network_error",
|
|
100
|
+
"error_save_failed",
|
|
101
|
+
"error_server_error",
|
|
102
|
+
"error_timeout",
|
|
103
|
+
"error_unauthorized",
|
|
104
|
+
"error_unknown",
|
|
105
|
+
"error_video_too_short",
|
|
106
|
+
"permission_limited_access_add_more_media",
|
|
107
|
+
"permission_limited_access_add_more_photos",
|
|
108
|
+
"permission_limited_access_add_more_videos",
|
|
109
|
+
"permission_limited_access_warning",
|
|
110
|
+
"permission_location_reason",
|
|
111
|
+
"permission_media_reason",
|
|
112
|
+
"permission_network_reason",
|
|
113
|
+
"permission_wifi_reason",
|
|
114
|
+
"update_confirm",
|
|
115
|
+
"update_download_failed",
|
|
116
|
+
"update_downloading",
|
|
117
|
+
"update_message",
|
|
118
|
+
"update_title",
|
|
119
|
+
"video_quality",
|
|
120
|
+
"video_speed",
|
|
121
|
+
] as const;
|
|
122
|
+
|
|
123
|
+
export type I18nKey = (typeof I18N_KEYS)[number];
|
package/src/index.ts
CHANGED
|
@@ -6,16 +6,24 @@
|
|
|
6
6
|
|
|
7
7
|
export * from './app';
|
|
8
8
|
export * from './device';
|
|
9
|
+
export * from './display';
|
|
9
10
|
export * from './input';
|
|
10
11
|
export * from './storage';
|
|
12
|
+
export * from './file';
|
|
11
13
|
export * from './location';
|
|
14
|
+
export * from './navigator';
|
|
12
15
|
export * from './system';
|
|
16
|
+
export * from './update';
|
|
13
17
|
export * from './media';
|
|
14
18
|
export * from './ui';
|
|
19
|
+
export * from './error';
|
|
20
|
+
export * from './generated/error';
|
|
21
|
+
export * from './generated/i18n';
|
|
15
22
|
|
|
16
23
|
import type {
|
|
17
24
|
AppConfig,
|
|
18
25
|
AppInstance,
|
|
26
|
+
LxAppInfo,
|
|
19
27
|
PageConfig,
|
|
20
28
|
PageInstance,
|
|
21
29
|
} from './app';
|
|
@@ -27,8 +35,8 @@ import type {
|
|
|
27
35
|
WifiInfo,
|
|
28
36
|
ConnectWifiOptions,
|
|
29
37
|
WifiConnectedCallback,
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
NetworkInfo,
|
|
39
|
+
NetworkChangeCallback,
|
|
32
40
|
} from './device';
|
|
33
41
|
|
|
34
42
|
import type { KeyEventCallback } from './input';
|
|
@@ -36,9 +44,23 @@ import type { KeyEventCallback } from './input';
|
|
|
36
44
|
import type {
|
|
37
45
|
LxEnv,
|
|
38
46
|
Storage,
|
|
39
|
-
OpenDocumentOptions,
|
|
40
47
|
} from './storage';
|
|
41
48
|
|
|
49
|
+
import type {
|
|
50
|
+
OpenDocumentOptions,
|
|
51
|
+
ChooseDirectoryOptions,
|
|
52
|
+
ChooseDirectoryResult,
|
|
53
|
+
ChooseFileOptions,
|
|
54
|
+
ChooseFileResult,
|
|
55
|
+
DownloadTask,
|
|
56
|
+
DownloadOptions,
|
|
57
|
+
} from './file';
|
|
58
|
+
|
|
59
|
+
import type {
|
|
60
|
+
DeviceOrientation,
|
|
61
|
+
DeviceOrientationChangeEvent,
|
|
62
|
+
} from './display';
|
|
63
|
+
|
|
42
64
|
import type {
|
|
43
65
|
GetLocationOptions,
|
|
44
66
|
LocationInfo,
|
|
@@ -48,18 +70,27 @@ import type {
|
|
|
48
70
|
AppBaseInfo,
|
|
49
71
|
SystemSettingInfo,
|
|
50
72
|
OpenURLOptions,
|
|
51
|
-
NavigateToLxAppOptions,
|
|
52
|
-
UpdateManager,
|
|
53
73
|
} from './system';
|
|
54
74
|
|
|
75
|
+
import type { NavigateToLxAppOptions } from './navigator';
|
|
76
|
+
|
|
77
|
+
import type { UpdateManager } from './update';
|
|
78
|
+
|
|
55
79
|
import type {
|
|
56
80
|
GetImageInfoOptions,
|
|
57
81
|
ImageInfo,
|
|
58
82
|
CompressImageOptions,
|
|
59
83
|
CompressImageResult,
|
|
84
|
+
CompressVideoOptions,
|
|
85
|
+
CompressVideoResult,
|
|
86
|
+
GetVideoInfoOptions,
|
|
87
|
+
VideoInfo,
|
|
88
|
+
ExtractVideoThumbnailOptions,
|
|
89
|
+
ExtractVideoThumbnailResult,
|
|
60
90
|
ChooseMediaOptions,
|
|
61
91
|
ChosenMediaEntry,
|
|
62
92
|
PreviewMediaOptions,
|
|
93
|
+
PreviewMediaResult,
|
|
63
94
|
SaveMediaOptions,
|
|
64
95
|
ScanCodeOptions,
|
|
65
96
|
ScanCodeResult,
|
|
@@ -106,11 +137,16 @@ export interface Lx {
|
|
|
106
137
|
getConnectedWifi(): Promise<WifiInfo>;
|
|
107
138
|
onWifiConnected(callback: WifiConnectedCallback): void;
|
|
108
139
|
offWifiConnected(callback?: WifiConnectedCallback): void;
|
|
140
|
+
getNetworkInfo(): Promise<NetworkInfo>;
|
|
141
|
+
onNetworkChange(callback: NetworkChangeCallback): void;
|
|
142
|
+
offNetworkChange(callback?: NetworkChangeCallback): void;
|
|
109
143
|
|
|
110
|
-
|
|
111
|
-
|
|
144
|
+
setDeviceOrientation(orientation: DeviceOrientation): boolean;
|
|
145
|
+
onDeviceOrientationChange(callback: (event: DeviceOrientationChangeEvent) => void): void;
|
|
146
|
+
offDeviceOrientationChange(callback?: (event: DeviceOrientationChangeEvent) => void): void;
|
|
112
147
|
|
|
113
148
|
openDocument(options: OpenDocumentOptions): void;
|
|
149
|
+
downloadFile(options: DownloadOptions): DownloadTask;
|
|
114
150
|
|
|
115
151
|
getStorage(): Storage;
|
|
116
152
|
|
|
@@ -120,6 +156,7 @@ export interface Lx {
|
|
|
120
156
|
navigateBackLxApp(): Promise<void>;
|
|
121
157
|
|
|
122
158
|
getAppBaseInfo(): AppBaseInfo;
|
|
159
|
+
getLxAppInfo(): LxAppInfo;
|
|
123
160
|
getSystemSetting(): SystemSettingInfo;
|
|
124
161
|
openURL(options: OpenURLOptions): void;
|
|
125
162
|
|
|
@@ -127,10 +164,25 @@ export interface Lx {
|
|
|
127
164
|
|
|
128
165
|
getImageInfo(options: GetImageInfoOptions): Promise<ImageInfo>;
|
|
129
166
|
compressImage(options: CompressImageOptions): Promise<CompressImageResult>;
|
|
167
|
+
compressVideo(options: CompressVideoOptions): Promise<CompressVideoResult>;
|
|
168
|
+
getVideoInfo(options: GetVideoInfoOptions): Promise<VideoInfo>;
|
|
169
|
+
extractVideoThumbnail(options: ExtractVideoThumbnailOptions): Promise<ExtractVideoThumbnailResult>;
|
|
130
170
|
|
|
131
171
|
chooseMedia(options?: ChooseMediaOptions): Promise<ChosenMediaEntry[]>;
|
|
132
172
|
|
|
133
|
-
|
|
173
|
+
/**
|
|
174
|
+
* Opens native media preview.
|
|
175
|
+
*
|
|
176
|
+
* Supports:
|
|
177
|
+
* - a single source path string for the simplest case
|
|
178
|
+
* - a single-item object for per-item options like `rotate`, `objectFit`, or `durationMs`
|
|
179
|
+
* - a sequence object for multi-item preview with `sources`, `startIndex`, and `advance`
|
|
180
|
+
*
|
|
181
|
+
* Resolves when preview session is closed (manual/auto/interrupted/error).
|
|
182
|
+
* Rejects with a cancellation error if `signal` is aborted, and abort also requests
|
|
183
|
+
* the active native preview session to close immediately.
|
|
184
|
+
*/
|
|
185
|
+
previewMedia(options: PreviewMediaOptions): Promise<PreviewMediaResult>;
|
|
134
186
|
|
|
135
187
|
saveImageToPhotosAlbum(options: SaveMediaOptions): Promise<void>;
|
|
136
188
|
saveVideoToPhotosAlbum(options: SaveMediaOptions): Promise<void>;
|
|
@@ -173,6 +225,11 @@ export interface Lx {
|
|
|
173
225
|
|
|
174
226
|
getCapsuleRect(): Promise<CapsuleRect>;
|
|
175
227
|
|
|
228
|
+
/** Desktop only. Currently supported on macOS. Windows is planned. */
|
|
229
|
+
chooseFile(options?: ChooseFileOptions): Promise<ChooseFileResult>;
|
|
230
|
+
/** Desktop only. Currently supported on macOS. Windows is planned. */
|
|
231
|
+
chooseDirectory(options?: ChooseDirectoryOptions): Promise<ChooseDirectoryResult>;
|
|
232
|
+
|
|
176
233
|
onKeyDown(callback: KeyEventCallback): void;
|
|
177
234
|
offKeyDown(callback?: KeyEventCallback): void;
|
|
178
235
|
onKeyUp(callback: KeyEventCallback): void;
|