@lingxia/types 0.8.0 → 0.10.0
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 +52 -2
- package/dist/app/index.d.ts.map +1 -1
- package/dist/file/index.d.ts +11 -2
- package/dist/file/index.d.ts.map +1 -1
- package/dist/generated/i18n.d.ts +1 -1
- package/dist/generated/i18n.d.ts.map +1 -1
- package/dist/generated/i18n.js +18 -25
- package/dist/generated/i18n.js.map +1 -1
- package/dist/index.d.ts +194 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/media/index.d.ts +66 -7
- package/dist/media/index.d.ts.map +1 -1
- package/dist/share/index.d.ts +90 -0
- package/dist/share/index.d.ts.map +1 -0
- package/dist/share/index.js +6 -0
- package/dist/share/index.js.map +1 -0
- package/dist/system/index.d.ts +1 -5
- package/dist/system/index.d.ts.map +1 -1
- package/dist/system/index.js +1 -1
- package/dist/transfer/index.d.ts +65 -20
- package/dist/transfer/index.d.ts.map +1 -1
- package/dist/ui/index.d.ts +36 -49
- package/dist/ui/index.d.ts.map +1 -1
- package/package.json +10 -1
- package/src/app/index.ts +57 -2
- package/src/file/index.ts +11 -2
- package/src/generated/i18n.ts +18 -25
- package/src/index.ts +224 -15
- package/src/media/index.ts +75 -7
- package/src/share/index.ts +97 -0
- package/src/system/index.ts +1 -6
- package/src/transfer/index.ts +80 -22
- package/src/ui/index.ts +42 -57
package/src/app/index.ts
CHANGED
|
@@ -91,6 +91,23 @@ export interface HostAppUpdateTask
|
|
|
91
91
|
*/
|
|
92
92
|
export type HostAppEnvVersion = 'developer' | 'preview' | 'release';
|
|
93
93
|
|
|
94
|
+
export interface AppScreenshotOptions {
|
|
95
|
+
/**
|
|
96
|
+
* Platform-specific window id to capture (desktop only). Omit to let the
|
|
97
|
+
* platform pick: the key/main window on desktop, the sole window on mobile.
|
|
98
|
+
*/
|
|
99
|
+
windowId?: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface AppScreenshotResult {
|
|
103
|
+
/** `lx://` URI of the captured PNG in the lxapp temp directory. */
|
|
104
|
+
tempFilePath: string;
|
|
105
|
+
/** Image width in pixels, when the runtime could read it from the PNG. */
|
|
106
|
+
width?: number;
|
|
107
|
+
/** Image height in pixels, when the runtime could read it from the PNG. */
|
|
108
|
+
height?: number;
|
|
109
|
+
}
|
|
110
|
+
|
|
94
111
|
export interface HostAppApi {
|
|
95
112
|
/**
|
|
96
113
|
* The environment this build was produced for, mirroring `app.json::envVersion`.
|
|
@@ -132,6 +149,28 @@ export interface HostAppApi {
|
|
|
132
149
|
* only after the user confirms.
|
|
133
150
|
*/
|
|
134
151
|
exit(): void;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Capture the host app's window as a PNG and save it to the lxapp temp
|
|
155
|
+
* directory.
|
|
156
|
+
*
|
|
157
|
+
* App-level semantics — one level above any page/WebView capture: the image
|
|
158
|
+
* is what the user currently sees of the whole app, including host-drawn
|
|
159
|
+
* navigation chrome, native overlays, and every composited WebView. Because
|
|
160
|
+
* that view can include other lxapps' UI, this API is only available to the
|
|
161
|
+
* home lxapp; other lxapps receive a permission error.
|
|
162
|
+
*/
|
|
163
|
+
screenshot(options?: AppScreenshotOptions): Promise<AppScreenshotResult>;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Set the app-icon badge — e.g. an unread count.
|
|
167
|
+
*
|
|
168
|
+
* Cross-platform: the dock (macOS), the taskbar (Windows), and the home /
|
|
169
|
+
* launcher icon (iOS, Android). Pass `null` or an empty string to clear it.
|
|
170
|
+
* On platforms where it is not wired this is a no-op (it never throws), so it
|
|
171
|
+
* is safe to call from portable code.
|
|
172
|
+
*/
|
|
173
|
+
setBadge(value: string | number | null): void;
|
|
135
174
|
}
|
|
136
175
|
|
|
137
176
|
export interface AppLifecycleEventArgs {
|
|
@@ -217,8 +256,24 @@ export interface SurfaceVisibilityEvent {
|
|
|
217
256
|
source: 'opener' | 'page';
|
|
218
257
|
}
|
|
219
258
|
|
|
220
|
-
export interface
|
|
259
|
+
export interface SurfaceHandle {
|
|
221
260
|
readonly id: string;
|
|
261
|
+
/**
|
|
262
|
+
* Show a host-managed surface. Dynamic page/url surfaces return a Promise;
|
|
263
|
+
* host-declared surfaces may complete synchronously.
|
|
264
|
+
*/
|
|
265
|
+
show(): void | Promise<void>;
|
|
266
|
+
/**
|
|
267
|
+
* Hide without destroying user-visible state when the platform supports it.
|
|
268
|
+
*/
|
|
269
|
+
hide(): void | Promise<void>;
|
|
270
|
+
/**
|
|
271
|
+
* Close or hide the surface depending on how it is managed by the host.
|
|
272
|
+
*/
|
|
273
|
+
close(): void | Promise<void>;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export interface Surface extends SurfaceHandle {
|
|
222
277
|
readonly kind: 'overlay' | 'window';
|
|
223
278
|
/**
|
|
224
279
|
* Last-known visibility, kept in sync with the native side via show/hide
|
|
@@ -280,7 +335,7 @@ export interface PageInstance<TData extends Record<string, unknown> = Record<str
|
|
|
280
335
|
data: TData;
|
|
281
336
|
route: string;
|
|
282
337
|
/**
|
|
283
|
-
* Available when this page was opened
|
|
338
|
+
* Available when this page was opened as a surface via `lx.openSurface(...)`.
|
|
284
339
|
*/
|
|
285
340
|
surface?: Surface;
|
|
286
341
|
/**
|
package/src/file/index.ts
CHANGED
|
@@ -29,14 +29,23 @@ export interface ChooseFileOptions {
|
|
|
29
29
|
multiple?: boolean;
|
|
30
30
|
/** Optional file filters. Empty or omitted means all file types. */
|
|
31
31
|
filters?: FileDialogFilter[];
|
|
32
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Initial directory the dialog opens in.
|
|
34
|
+
*
|
|
35
|
+
* When this resolves to an app-local directory, LingXia may use its internal
|
|
36
|
+
* file picker. When omitted, the platform system file picker is used.
|
|
37
|
+
*/
|
|
33
38
|
defaultPath?: string;
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
export interface ChooseFileResult {
|
|
37
42
|
/** True if the user dismissed the dialog without selecting. */
|
|
38
43
|
canceled: boolean;
|
|
39
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* File paths returned by LingXia. Values may be app-local paths, `lx://...`
|
|
46
|
+
* paths, or platform system-picker references. Treat them as opaque strings
|
|
47
|
+
* and pass them back to LingXia APIs such as `lx.share`.
|
|
48
|
+
*/
|
|
40
49
|
paths: string[];
|
|
41
50
|
}
|
|
42
51
|
|
package/src/generated/i18n.ts
CHANGED
|
@@ -26,37 +26,26 @@ export const I18N_KEYS = [
|
|
|
26
26
|
"camera_switch_to_front",
|
|
27
27
|
"camera_switching",
|
|
28
28
|
"camera_tap_to_capture",
|
|
29
|
-
"camera_tap_to_record",
|
|
30
|
-
"camera_tap_to_stop",
|
|
31
29
|
"camera_video_input_failed",
|
|
32
30
|
"camera_video_output_failed",
|
|
33
31
|
"capsule_clean_cache",
|
|
34
32
|
"capsule_restart",
|
|
35
33
|
"capsule_uninstall",
|
|
36
|
-
"common_auto",
|
|
37
34
|
"common_back",
|
|
38
35
|
"common_cancel",
|
|
39
36
|
"common_close",
|
|
40
37
|
"common_confirm",
|
|
41
38
|
"common_delete",
|
|
42
39
|
"common_done",
|
|
43
|
-
"common_edit",
|
|
44
|
-
"common_home",
|
|
45
40
|
"common_loading",
|
|
46
41
|
"common_ok",
|
|
47
|
-
"
|
|
48
|
-
"common_save",
|
|
49
|
-
"common_settings",
|
|
50
|
-
"common_share",
|
|
51
|
-
"common_success",
|
|
52
|
-
"common_warning",
|
|
42
|
+
"common_refresh",
|
|
53
43
|
"date_last_30_days",
|
|
54
44
|
"date_last_7_days",
|
|
55
45
|
"date_last_month",
|
|
56
46
|
"date_last_week",
|
|
57
47
|
"date_this_month",
|
|
58
48
|
"date_this_week",
|
|
59
|
-
"document_pdf_page_preview",
|
|
60
49
|
"err_code_1000",
|
|
61
50
|
"err_code_1001",
|
|
62
51
|
"err_code_1002",
|
|
@@ -96,13 +85,10 @@ export const I18N_KEYS = [
|
|
|
96
85
|
"err_code_6000",
|
|
97
86
|
"err_code_6001",
|
|
98
87
|
"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
88
|
"error_video_too_short",
|
|
89
|
+
"file_chooser_choose_images",
|
|
90
|
+
"file_chooser_choose_media",
|
|
91
|
+
"file_chooser_choose_videos",
|
|
106
92
|
"file_chooser_default_title",
|
|
107
93
|
"file_chooser_empty_subtitle",
|
|
108
94
|
"file_chooser_empty_title",
|
|
@@ -113,19 +99,26 @@ export const I18N_KEYS = [
|
|
|
113
99
|
"file_chooser_filtered_empty_subtitle",
|
|
114
100
|
"file_chooser_filtered_empty_title",
|
|
115
101
|
"file_chooser_folder_subtitle",
|
|
102
|
+
"file_chooser_select_file",
|
|
103
|
+
"file_chooser_select_folder",
|
|
116
104
|
"permission_limited_access_add_more_media",
|
|
117
105
|
"permission_limited_access_add_more_photos",
|
|
118
106
|
"permission_limited_access_add_more_videos",
|
|
119
107
|
"permission_limited_access_warning",
|
|
120
|
-
"permission_location_reason",
|
|
121
108
|
"permission_media_reason",
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"
|
|
125
|
-
"
|
|
109
|
+
"terminal_change_title",
|
|
110
|
+
"terminal_close_pane",
|
|
111
|
+
"terminal_copy",
|
|
112
|
+
"terminal_new_tab",
|
|
113
|
+
"terminal_paste",
|
|
114
|
+
"terminal_read_only",
|
|
115
|
+
"terminal_reset",
|
|
116
|
+
"terminal_split_down",
|
|
117
|
+
"terminal_split_left",
|
|
118
|
+
"terminal_split_right",
|
|
119
|
+
"terminal_split_up",
|
|
120
|
+
"terminal_title",
|
|
126
121
|
"update_downloading",
|
|
127
|
-
"update_message",
|
|
128
|
-
"update_title",
|
|
129
122
|
"video_quality",
|
|
130
123
|
"video_speed",
|
|
131
124
|
] as const;
|
package/src/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from './navigator';
|
|
|
18
18
|
export * from './system';
|
|
19
19
|
export * from './update';
|
|
20
20
|
export * from './media';
|
|
21
|
+
export * from './share';
|
|
21
22
|
export * from './ui';
|
|
22
23
|
export * from './error';
|
|
23
24
|
export * from './generated/error';
|
|
@@ -31,6 +32,7 @@ import type {
|
|
|
31
32
|
PageConfig,
|
|
32
33
|
PageInstance,
|
|
33
34
|
Surface,
|
|
35
|
+
SurfaceHandle,
|
|
34
36
|
} from './app';
|
|
35
37
|
|
|
36
38
|
import type {
|
|
@@ -64,8 +66,14 @@ import type {
|
|
|
64
66
|
} from './file';
|
|
65
67
|
|
|
66
68
|
import type {
|
|
69
|
+
AppDownloadOptions,
|
|
70
|
+
AppDownloadResult,
|
|
71
|
+
DownloadDestination,
|
|
67
72
|
DownloadOptions,
|
|
73
|
+
DownloadResultForDestination,
|
|
68
74
|
DownloadTask,
|
|
75
|
+
DownloadsDownloadOptions,
|
|
76
|
+
DownloadsDownloadResult,
|
|
69
77
|
UploadOptions,
|
|
70
78
|
UploadTask,
|
|
71
79
|
} from './transfer';
|
|
@@ -82,7 +90,6 @@ import type {
|
|
|
82
90
|
|
|
83
91
|
import type {
|
|
84
92
|
SystemSettingInfo,
|
|
85
|
-
OpenURLOptions,
|
|
86
93
|
} from './system';
|
|
87
94
|
|
|
88
95
|
import type { NavigateToLxAppOptions } from './navigator';
|
|
@@ -95,7 +102,7 @@ import type {
|
|
|
95
102
|
CompressImageOptions,
|
|
96
103
|
CompressImageResult,
|
|
97
104
|
CompressVideoOptions,
|
|
98
|
-
|
|
105
|
+
CompressVideoTask,
|
|
99
106
|
GetVideoInfoOptions,
|
|
100
107
|
VideoInfo,
|
|
101
108
|
ExtractVideoThumbnailOptions,
|
|
@@ -110,6 +117,11 @@ import type {
|
|
|
110
117
|
VideoContext,
|
|
111
118
|
} from './media';
|
|
112
119
|
|
|
120
|
+
import type {
|
|
121
|
+
ShareOptions,
|
|
122
|
+
ShareResult,
|
|
123
|
+
} from './share';
|
|
124
|
+
|
|
113
125
|
import type {
|
|
114
126
|
ShowToastOptions,
|
|
115
127
|
ShowModalOptions,
|
|
@@ -128,24 +140,213 @@ import type {
|
|
|
128
140
|
RemoveTabBarBadgeOptions,
|
|
129
141
|
SetTabBarStyleOptions,
|
|
130
142
|
SetTabBarItemOptions,
|
|
131
|
-
|
|
143
|
+
SurfaceEdge,
|
|
144
|
+
SurfaceFloatPosition,
|
|
145
|
+
OverlaySurfaceSize,
|
|
146
|
+
SurfaceContext,
|
|
132
147
|
CapsuleRect,
|
|
133
148
|
} from './ui';
|
|
134
149
|
|
|
135
|
-
|
|
150
|
+
interface WindowSurfaceSize {
|
|
151
|
+
/** Initial window width in logical pixels. */
|
|
152
|
+
width?: number;
|
|
153
|
+
/** Initial window height in logical pixels. */
|
|
154
|
+
height?: number;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Spec for {@link Lx.openSurface}. A discriminated union keyed by source so a
|
|
159
|
+
* page name and a declared surface id never collide (each is its own string
|
|
160
|
+
* space, separately type-checkable).
|
|
161
|
+
*
|
|
162
|
+
* - `{ page }` — one of this lxapp's own pages, by name, arranged as `as`
|
|
163
|
+
* (`aside` is a companion of the main; `float` is a popup; `window` is a bare
|
|
164
|
+
* desktop window, which rejects on mobile). `edge` applies to `aside`,
|
|
165
|
+
* `position` applies to `float`, and `size` is a Host-clamped hint. They are
|
|
166
|
+
* fixed at open (re-open to change).
|
|
167
|
+
*
|
|
168
|
+
* `aside` is **size-class adaptive**, not a fixed form: only on `medium` /
|
|
169
|
+
* `expanded` (room to sit alongside) does it dock and split beside the main at
|
|
170
|
+
* `edge` as a sidebar/split panel. On `compact` (phone, or a folded foldable)
|
|
171
|
+
* there is no room to dock, so the same surface presents **full-screen** —
|
|
172
|
+
* pushed over the main and dismissed by the host back affordance / edge swipe
|
|
173
|
+
* (a drill-in), never a docked panel. So one declaration reads as a side panel
|
|
174
|
+
* on large screens and a full-screen drill-in on small ones. For a destination
|
|
175
|
+
* that should stay switchable on phones, declare it `role: main` instead.
|
|
176
|
+
*
|
|
177
|
+
* `float` is a popup layered above the main at `position` (like a dialog); it
|
|
178
|
+
* takes no layout space. The SDK gives it **no chrome of its own — there is no
|
|
179
|
+
* built-in close button**: the lxapp owns the popup UI and dismisses it by
|
|
180
|
+
* calling `surface.close()` (or `.hide()`). A float sized to the full container
|
|
181
|
+
* (`size: { width: '100%', height: '100%' }`) presents immersively on mobile
|
|
182
|
+
* (system bars hidden) and is likewise chrome-less — draw your own close
|
|
183
|
+
* affordance. (iOS retains a silent left-edge swipe as a last-resort escape so a
|
|
184
|
+
* full-screen float can never trap the user; don't rely on it as the primary
|
|
185
|
+
* dismissal.)
|
|
186
|
+
* - `{ surface }` — a surface declared in `lingxia.yaml` `surfaces:`, by id
|
|
187
|
+
* (e.g. `'terminal'`, `'ai-assistant'`). Form, position, and startup data come
|
|
188
|
+
* from the declaration.
|
|
189
|
+
* - `{ url }` — an `http(s)://` or `lingxia://` url, shown in the in-app chromed
|
|
190
|
+
* browser (always with an address bar — never a chromeless embed). Without
|
|
191
|
+
* `as` it opens as a main browser tab (host chrome, no handle). With
|
|
192
|
+
* `as: 'aside'` it docks an `http(s)://` page beside the main as a single
|
|
193
|
+
* browser aside (its own chrome + close, returns a closable handle); `edge`
|
|
194
|
+
* defaults to `'right'` and `size` is a host-clamped preferred size. At most
|
|
195
|
+
* one browser aside per window — a new one replaces the existing one.
|
|
196
|
+
*/
|
|
197
|
+
export type OpenPageSurfaceSpec =
|
|
198
|
+
| {
|
|
199
|
+
page: string;
|
|
200
|
+
as: 'aside';
|
|
201
|
+
edge?: SurfaceEdge;
|
|
202
|
+
size?: OverlaySurfaceSize;
|
|
203
|
+
query?: Record<string, unknown>;
|
|
204
|
+
position?: never;
|
|
205
|
+
surface?: never;
|
|
206
|
+
url?: never;
|
|
207
|
+
}
|
|
208
|
+
| {
|
|
209
|
+
page: string;
|
|
210
|
+
/**
|
|
211
|
+
* A chrome-less popup above the main: the lxapp draws its own UI and close
|
|
212
|
+
* affordance — there is no SDK-provided close button (see
|
|
213
|
+
* {@link OpenPageSurfaceSpec}).
|
|
214
|
+
*/
|
|
215
|
+
as: 'float';
|
|
216
|
+
position?: SurfaceFloatPosition;
|
|
217
|
+
size?: OverlaySurfaceSize;
|
|
218
|
+
query?: Record<string, unknown>;
|
|
219
|
+
edge?: never;
|
|
220
|
+
surface?: never;
|
|
221
|
+
url?: never;
|
|
222
|
+
}
|
|
223
|
+
| {
|
|
224
|
+
page: string;
|
|
225
|
+
as: 'window';
|
|
226
|
+
size?: WindowSurfaceSize;
|
|
227
|
+
query?: Record<string, unknown>;
|
|
228
|
+
edge?: never;
|
|
229
|
+
position?: never;
|
|
230
|
+
surface?: never;
|
|
231
|
+
url?: never;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
export interface OpenDeclaredSurfaceSpec {
|
|
235
|
+
surface: string;
|
|
236
|
+
page?: never;
|
|
237
|
+
url?: never;
|
|
238
|
+
as?: never;
|
|
239
|
+
edge?: never;
|
|
240
|
+
position?: never;
|
|
241
|
+
size?: never;
|
|
242
|
+
query?: never;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface OpenUrlTabSpec {
|
|
246
|
+
url: string;
|
|
247
|
+
as?: never;
|
|
248
|
+
page?: never;
|
|
249
|
+
surface?: never;
|
|
250
|
+
edge?: never;
|
|
251
|
+
position?: never;
|
|
252
|
+
size?: never;
|
|
253
|
+
query?: never;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export interface OpenUrlAsideSpec {
|
|
257
|
+
url: string;
|
|
258
|
+
as: 'aside';
|
|
259
|
+
edge?: SurfaceEdge;
|
|
260
|
+
size?: OverlaySurfaceSize;
|
|
261
|
+
page?: never;
|
|
262
|
+
surface?: never;
|
|
263
|
+
position?: never;
|
|
264
|
+
query?: never;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export type OpenSurfaceSpec =
|
|
268
|
+
| OpenPageSurfaceSpec
|
|
269
|
+
| OpenDeclaredSurfaceSpec
|
|
270
|
+
| OpenUrlTabSpec
|
|
271
|
+
| OpenUrlAsideSpec;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Runtime control of the menu-bar (macOS) / system-tray (Windows) status item.
|
|
275
|
+
* The tray is declared in `lingxia.yaml` (`tray:`); these update its dynamic
|
|
276
|
+
* content at runtime.
|
|
277
|
+
*
|
|
278
|
+
* **Desktop only.** Mobile platforms have no tray, so every method here is a
|
|
279
|
+
* no-op there (it never throws) — safe to call from portable code. For an
|
|
280
|
+
* app-icon badge that *is* cross-platform (including mobile), use
|
|
281
|
+
* {@link HostAppApi.setBadge}.
|
|
282
|
+
*/
|
|
283
|
+
export interface TrayMenuItem {
|
|
284
|
+
label: string;
|
|
285
|
+
/** Invoked when this item is clicked. */
|
|
286
|
+
onClick?: () => void;
|
|
287
|
+
enabled?: boolean;
|
|
288
|
+
checked?: boolean;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export interface TrayMenuSeparator {
|
|
292
|
+
separator: true;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export interface TrayApi {
|
|
296
|
+
/** Replace the status-item icon (a resource path). */
|
|
297
|
+
setIcon(icon: string): void;
|
|
298
|
+
/** Set the text shown beside the icon (macOS). Pass `null`/empty to clear. */
|
|
299
|
+
setTitle(text: string | null): void;
|
|
300
|
+
/** Set the badge — e.g. an unread count. Pass `null`/empty to clear. */
|
|
301
|
+
setBadge(value: string | number | null): void;
|
|
136
302
|
/**
|
|
137
|
-
*
|
|
303
|
+
* Replace the right-click dropdown menu. There is no default menu — provide
|
|
304
|
+
* your own items (e.g. `{ label: 'Quit', onClick: () => lx.app.exit() }`).
|
|
138
305
|
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
306
|
+
* The menu is a snapshot: to change an item's `checked`/`enabled`/`label`
|
|
307
|
+
* state, call `setMenu` again with the full updated array. There is no
|
|
308
|
+
* per-item mutation API.
|
|
309
|
+
*/
|
|
310
|
+
setMenu(items: Array<TrayMenuItem | TrayMenuSeparator>): void;
|
|
311
|
+
/**
|
|
312
|
+
* Handle a left-click on the tray icon yourself. While a handler is
|
|
313
|
+
* registered the click runs only the handler — the tray's configured surface
|
|
314
|
+
* `action` is suppressed, so the click is fully yours (e.g. toggle a state and
|
|
315
|
+
* `setIcon`). Returns an unsubscribe function.
|
|
141
316
|
*/
|
|
142
|
-
|
|
317
|
+
onClick(handler: () => void): () => void;
|
|
318
|
+
/** Show the tray status item. */
|
|
319
|
+
show(): void;
|
|
320
|
+
/** Hide the tray status item (without removing the app). */
|
|
321
|
+
hide(): void;
|
|
143
322
|
}
|
|
144
323
|
|
|
145
324
|
export interface Lx {
|
|
146
325
|
env: LxEnv;
|
|
147
326
|
app: HostAppApi;
|
|
148
|
-
|
|
327
|
+
tray: TrayApi;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Open a surface.
|
|
331
|
+
*
|
|
332
|
+
* - `{ url }` without `as` opens a host browser tab and resolves to `null`.
|
|
333
|
+
* - `{ surface }` resolves to a host-managed handle with show/hide/close.
|
|
334
|
+
* - page surfaces and `{ url, as: 'aside' }` resolve to a full Surface handle.
|
|
335
|
+
*
|
|
336
|
+
* `as: 'window'` is desktop-only and rejects on mobile. See
|
|
337
|
+
* {@link OpenSurfaceSpec}.
|
|
338
|
+
*/
|
|
339
|
+
openSurface(spec: OpenUrlTabSpec): Promise<null>;
|
|
340
|
+
openSurface(spec: OpenDeclaredSurfaceSpec): Promise<SurfaceHandle>;
|
|
341
|
+
openSurface(spec: OpenPageSurfaceSpec | OpenUrlAsideSpec): Promise<Surface>;
|
|
342
|
+
openSurface(spec: OpenSurfaceSpec): Promise<Surface | SurfaceHandle | null>;
|
|
343
|
+
/** Hand a url off to the OS default browser (leaves the app). */
|
|
344
|
+
openExternal(url: string): void;
|
|
345
|
+
/**
|
|
346
|
+
* Subscribe to adaptive-context changes ({@link SurfaceContext}); the handler
|
|
347
|
+
* fires with the new context. Returns an unsubscribe function.
|
|
348
|
+
*/
|
|
349
|
+
onSurfaceContext(handler: (context: SurfaceContext) => void): () => void;
|
|
149
350
|
|
|
150
351
|
getDeviceInfo(): DeviceInfo;
|
|
151
352
|
getScreenInfo(): ScreenInfo;
|
|
@@ -174,7 +375,11 @@ export interface Lx {
|
|
|
174
375
|
* otherwise prefer `mode: 'auto'`.
|
|
175
376
|
*/
|
|
176
377
|
openFile(options: OpenFileOptions): void;
|
|
177
|
-
downloadFile(options:
|
|
378
|
+
downloadFile(options: DownloadsDownloadOptions): DownloadTask<DownloadsDownloadResult>;
|
|
379
|
+
downloadFile(options: AppDownloadOptions): DownloadTask<AppDownloadResult>;
|
|
380
|
+
downloadFile<TDestination extends DownloadDestination = 'app'>(
|
|
381
|
+
options: DownloadOptions<TDestination>,
|
|
382
|
+
): DownloadTask<DownloadResultForDestination<TDestination>>;
|
|
178
383
|
uploadFile(options: UploadOptions): UploadTask;
|
|
179
384
|
getFileManager(): FileManager;
|
|
180
385
|
|
|
@@ -187,13 +392,12 @@ export interface Lx {
|
|
|
187
392
|
|
|
188
393
|
getLxAppInfo(): LxAppInfo;
|
|
189
394
|
getSystemSetting(): SystemSettingInfo;
|
|
190
|
-
openURL(options: OpenURLOptions): void;
|
|
191
395
|
|
|
192
396
|
getUpdateManager(): UpdateManager;
|
|
193
397
|
|
|
194
398
|
getImageInfo(options: GetImageInfoOptions): Promise<ImageInfo>;
|
|
195
399
|
compressImage(options: CompressImageOptions): Promise<CompressImageResult>;
|
|
196
|
-
compressVideo(options: CompressVideoOptions):
|
|
400
|
+
compressVideo(options: CompressVideoOptions): CompressVideoTask;
|
|
197
401
|
getVideoInfo(options: GetVideoInfoOptions): Promise<VideoInfo>;
|
|
198
402
|
extractVideoThumbnail(options: ExtractVideoThumbnailOptions): Promise<ExtractVideoThumbnailResult>;
|
|
199
403
|
|
|
@@ -208,9 +412,12 @@ export interface Lx {
|
|
|
208
412
|
* - a sequence object for multi-item preview with `sources`, `startIndex`, and `advance`
|
|
209
413
|
*
|
|
210
414
|
* Returns a {@link PreviewMediaHandle} synchronously. Await `handle.completed`
|
|
211
|
-
* for the final session result (`reason`, `
|
|
212
|
-
*
|
|
213
|
-
*
|
|
415
|
+
* for the final session result (`reason`, `index`, `source` — the item the
|
|
416
|
+
* user was viewing when the preview closed). Subscribe to
|
|
417
|
+
* `handle.onChange(...)` / read `handle.current` to follow the viewed item
|
|
418
|
+
* live, and to `handle.presented` to learn when the first pixel hits the
|
|
419
|
+
* screen — useful for coordinating a hide of any overlay surface that was
|
|
420
|
+
* previously visible.
|
|
214
421
|
*
|
|
215
422
|
* `handle.completed` rejects with a cancellation error if `signal` is aborted;
|
|
216
423
|
* abort also requests the active native preview session to close immediately.
|
|
@@ -223,6 +430,8 @@ export interface Lx {
|
|
|
223
430
|
|
|
224
431
|
scanCode(options?: ScanCodeOptions): Promise<ScanCodeResult>;
|
|
225
432
|
|
|
433
|
+
share(options: ShareOptions): Promise<ShareResult>;
|
|
434
|
+
|
|
226
435
|
createVideoContext(componentId: string): VideoContext;
|
|
227
436
|
|
|
228
437
|
showToast(options: ShowToastOptions): void;
|
package/src/media/index.ts
CHANGED
|
@@ -73,6 +73,41 @@ export interface CompressVideoResult {
|
|
|
73
73
|
type: string;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
export interface CompressVideoProgressEvent {
|
|
77
|
+
/** Transcode progress in percent, `0`-`100`. */
|
|
78
|
+
progress: number;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface CompressVideoIteratorResult {
|
|
82
|
+
done: boolean;
|
|
83
|
+
value?: CompressVideoProgressEvent;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Handle returned by `lx.compressVideo`.
|
|
88
|
+
*
|
|
89
|
+
* Awaiting the task resolves with the final {@link CompressVideoResult}.
|
|
90
|
+
* Iterating it with `for await` yields {@link CompressVideoProgressEvent}s
|
|
91
|
+
* while the transcode runs.
|
|
92
|
+
*/
|
|
93
|
+
export interface CompressVideoTask
|
|
94
|
+
extends PromiseLike<CompressVideoResult>,
|
|
95
|
+
AsyncIterable<CompressVideoProgressEvent> {
|
|
96
|
+
next(): Promise<CompressVideoIteratorResult>;
|
|
97
|
+
/** Stops iteration only. Does not cancel the compression. */
|
|
98
|
+
return(): Promise<CompressVideoIteratorResult>;
|
|
99
|
+
catch<TResult = never>(
|
|
100
|
+
onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null,
|
|
101
|
+
): Promise<CompressVideoResult | TResult>;
|
|
102
|
+
finally(onfinally?: (() => void) | null): Promise<CompressVideoResult>;
|
|
103
|
+
/**
|
|
104
|
+
* Cancels the transcode and deletes any partial output.
|
|
105
|
+
* The task promise rejects with an `AbortError` (`code: 'E_ABORT'`).
|
|
106
|
+
*/
|
|
107
|
+
cancel(): void;
|
|
108
|
+
wait(): Promise<CompressVideoResult>;
|
|
109
|
+
}
|
|
110
|
+
|
|
76
111
|
export interface GetVideoInfoOptions {
|
|
77
112
|
/**
|
|
78
113
|
* Video file path or `lx://` URI.
|
|
@@ -279,35 +314,68 @@ export type PreviewMediaOptions =
|
|
|
279
314
|
|
|
280
315
|
export type PreviewMediaCloseReason = 'manual' | 'completed' | 'interrupted' | 'error';
|
|
281
316
|
|
|
317
|
+
/**
|
|
318
|
+
* The item the user is (or was) looking at, handed back as the caller
|
|
319
|
+
* described it — `path` is returned verbatim, so it can be matched against
|
|
320
|
+
* the caller's own data without re-indexing an array.
|
|
321
|
+
*/
|
|
322
|
+
export interface PreviewMediaShownSource {
|
|
323
|
+
/** The path exactly as passed in the request. */
|
|
324
|
+
path: string;
|
|
325
|
+
/** Resolved media kind (after extension inference when `type` was omitted). */
|
|
326
|
+
type: 'image' | 'video';
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** One change-stream event / the `current` snapshot. */
|
|
330
|
+
export interface PreviewMediaChange {
|
|
331
|
+
index: number;
|
|
332
|
+
source: PreviewMediaShownSource;
|
|
333
|
+
}
|
|
334
|
+
|
|
282
335
|
export interface PreviewMediaResult {
|
|
283
336
|
/**
|
|
284
337
|
* Why the preview session finished.
|
|
285
338
|
*/
|
|
286
339
|
reason: PreviewMediaCloseReason;
|
|
287
340
|
/**
|
|
288
|
-
*
|
|
341
|
+
* Index of the item on screen when the session closed.
|
|
342
|
+
*/
|
|
343
|
+
index: number;
|
|
344
|
+
/**
|
|
345
|
+
* The item on screen when the session closed — "what the user just
|
|
346
|
+
* viewed/played", without mapping `index` back yourself.
|
|
289
347
|
*/
|
|
290
|
-
|
|
348
|
+
source: PreviewMediaShownSource;
|
|
291
349
|
}
|
|
292
350
|
|
|
293
351
|
/**
|
|
294
|
-
* Handle returned synchronously from `lx.previewMedia(...)
|
|
295
|
-
*
|
|
352
|
+
* Handle returned synchronously from `lx.previewMedia(...)` — synchronous so
|
|
353
|
+
* listeners can be attached before the first event fires:
|
|
296
354
|
*
|
|
297
355
|
* - `presented` resolves once the first pixel of the underlying media has
|
|
298
356
|
* been composited to screen. Use this to time the hide of an overlay
|
|
299
357
|
* surface above the preview so the swap is seamless. Never rejects;
|
|
300
358
|
* resolves with no value when the first frame is up. Safe to ignore.
|
|
301
|
-
* - `
|
|
302
|
-
*
|
|
303
|
-
*
|
|
359
|
+
* - `current` is a live `{ index, source }` snapshot of the item on screen,
|
|
360
|
+
* updated as the user swipes and as the session auto-advances.
|
|
361
|
+
* - `onChange(listener)` fires for every item change. Returns an
|
|
362
|
+
* unsubscribe function.
|
|
363
|
+
* - `completed` resolves `{ reason, index, source }` when the preview
|
|
364
|
+
* session ends (manual / auto / interrupted / error), or rejects on abort.
|
|
304
365
|
*
|
|
305
366
|
* If the call was aborted before any frame was presented, `presented` still
|
|
306
367
|
* resolves (with no value) once the abort takes effect — it never rejects,
|
|
307
368
|
* to keep fire-and-forget usage safe.
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* const preview = lx.previewMedia({ sources, startIndex: 2 });
|
|
372
|
+
* preview.onChange(({ source }) => markAsViewed(source.path));
|
|
373
|
+
* const { reason, source } = await preview.completed;
|
|
308
374
|
*/
|
|
309
375
|
export interface PreviewMediaHandle {
|
|
310
376
|
readonly presented: Promise<void>;
|
|
377
|
+
readonly current: PreviewMediaChange;
|
|
378
|
+
onChange(listener: (change: PreviewMediaChange) => void): () => void;
|
|
311
379
|
readonly completed: Promise<PreviewMediaResult>;
|
|
312
380
|
}
|
|
313
381
|
|