@lingxia/types 0.11.1 → 0.12.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/automation/index.d.ts +289 -3
- package/dist/automation/index.d.ts.map +1 -1
- package/dist/automation-test-globals.d.ts +14 -0
- package/dist/error.d.ts +13 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +47 -1
- package/dist/error.js.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 +8 -0
- package/dist/generated/i18n.js.map +1 -1
- package/dist/generated/logic.d.ts +1055 -462
- package/dist/generated/logic.d.ts.map +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/testing/public-api.d.ts +429 -0
- package/dist/testing/public-api.d.ts.map +1 -0
- package/dist/testing/public-api.js +588 -0
- package/dist/testing/public-api.js.map +1 -0
- package/dist/testing/public-api.mjs +584 -0
- package/package.json +12 -3
- package/src/automation/index.ts +299 -3
- package/src/error.ts +47 -1
- package/src/generated/i18n.ts +8 -0
- package/src/generated/logic.ts +1117 -487
- package/src/index.ts +16 -0
- package/src/testing/public-api.ts +716 -0
|
@@ -14,9 +14,10 @@ export interface PageInstance<TData extends Record<string, unknown> = Record<str
|
|
|
14
14
|
data: TData;
|
|
15
15
|
route: string;
|
|
16
16
|
/**
|
|
17
|
-
* Available when this page was opened as a surface via
|
|
17
|
+
* Available when this page was opened as a surface via
|
|
18
|
+
* `lx.surface.openPage(...)`.
|
|
18
19
|
*/
|
|
19
|
-
surface?:
|
|
20
|
+
surface?: PageSurface;
|
|
20
21
|
/**
|
|
21
22
|
* Available when this page was opened by `lx.navigateTo(...)`.
|
|
22
23
|
*/
|
|
@@ -93,11 +94,6 @@ export interface DownloadTask<TDownloadResult extends DownloadResult = DownloadR
|
|
|
93
94
|
abort(): Promise<void>;
|
|
94
95
|
wait(): Promise<TDownloadResult>;
|
|
95
96
|
}
|
|
96
|
-
export interface FileManager {
|
|
97
|
-
readFile(options: ReadTextFileOptions): Promise<ReadTextFileResult>;
|
|
98
|
-
readFile(options: ReadBinaryFileOptions): Promise<ReadBinaryFileResult>;
|
|
99
|
-
readFile(options: ReadFileOptions): Promise<ReadFileResult>;
|
|
100
|
-
}
|
|
101
97
|
declare global {
|
|
102
98
|
interface HostAppApi {
|
|
103
99
|
/**
|
|
@@ -106,8 +102,9 @@ declare global {
|
|
|
106
102
|
*/
|
|
107
103
|
readonly envVersion: HostAppEnvVersion;
|
|
108
104
|
/**
|
|
109
|
-
* Launch-at-startup control.
|
|
110
|
-
*
|
|
105
|
+
* Launch-at-startup control. Absent where the host cannot register a
|
|
106
|
+
* startup item; its presence and `lx.supports({ capability: 'autostart' })` always
|
|
107
|
+
* agree, so `lx.app.autostart?.…` and the query are interchangeable.
|
|
111
108
|
*/
|
|
112
109
|
autostart?: AutostartApi;
|
|
113
110
|
}
|
|
@@ -116,27 +113,65 @@ declare global {
|
|
|
116
113
|
}
|
|
117
114
|
interface Lx {
|
|
118
115
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* `as: "window"` is desktop-only.
|
|
116
|
+
* Terminal product settings. Present only in the host-bundled Terminal
|
|
117
|
+
* Settings lxapp when the host declares `capabilities.terminal`; its
|
|
118
|
+
* presence and `lx.supports({ capability: 'terminal' })` always agree.
|
|
123
119
|
*/
|
|
124
|
-
|
|
125
|
-
openSurface(spec: OpenDeclaredSurfaceSpec | OpenLxappSurfaceSpec | OpenNativeSurfaceSpec): Promise<SurfaceHandle>;
|
|
126
|
-
openSurface(spec: OpenPageSurfaceSpec): Promise<Surface>;
|
|
127
|
-
openSurface(spec: OpenUrlAsideSpec): Promise<Surface | null>;
|
|
128
|
-
openSurface(spec: OpenSurfaceSpec): Promise<Surface | SurfaceHandle | null>;
|
|
120
|
+
readonly terminal?: TerminalApi;
|
|
129
121
|
/** Download to the downloads directory. */
|
|
130
122
|
downloadFile(options: DownloadsDownloadOptions): DownloadTask<DownloadsDownloadResult>;
|
|
131
123
|
/** Download to the lxapp-managed app directory. */
|
|
132
124
|
downloadFile(options: AppDownloadOptions): DownloadTask<AppDownloadResult>;
|
|
133
125
|
/** Download with a destination-correlated result type. */
|
|
134
126
|
downloadFile<TDestination extends DownloadDestination = "app">(options: DownloadOptions<TDestination>): DownloadTask<DownloadResultForDestination<TDestination>>;
|
|
127
|
+
/**
|
|
128
|
+
* Open this lxapp's store with every key's shape pinned on the handle.
|
|
129
|
+
* `get` / `set` / `delete` then share that schema instead of
|
|
130
|
+
* repeating `get<T>()` at each call site.
|
|
131
|
+
*/
|
|
132
|
+
getStorage<S extends StorageSchema>(): TypedStorage<S>;
|
|
135
133
|
}
|
|
136
134
|
}
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
/**
|
|
136
|
+
* A map of storage keys to stored value shapes.
|
|
137
|
+
*
|
|
138
|
+
* `object` deliberately accepts both type aliases and interfaces. Requiring a
|
|
139
|
+
* string index signature would reject ordinary interface-based schemas.
|
|
140
|
+
*/
|
|
141
|
+
export type StorageSchema = object;
|
|
142
|
+
type StorageKey<S extends object> = Extract<keyof S, string>;
|
|
143
|
+
type StorageEntry<S extends object> = {
|
|
144
|
+
[K in StorageKey<S>]: [key: K, value: S[K]];
|
|
145
|
+
}[StorageKey<S>];
|
|
146
|
+
/**
|
|
147
|
+
* Schema-typed view of the same store `lx.getStorage()` returns.
|
|
148
|
+
* Runtime is identical; only the key/value types are pinned.
|
|
149
|
+
*
|
|
150
|
+
* The schema constrains what this handle writes and reads, not what the store
|
|
151
|
+
* contains: a previous app version, or another code path holding the untyped
|
|
152
|
+
* handle, can have written keys outside it. That is why `list` still resolves
|
|
153
|
+
* plain strings — narrowing it to the schema's keys would be the same
|
|
154
|
+
* unchecked assertion this type exists to remove from `get<T>()`.
|
|
155
|
+
*/
|
|
156
|
+
export type TypedStorage<S extends object> = {
|
|
157
|
+
get<K extends StorageKey<S>>(key: K): Promise<S[K] | undefined>;
|
|
158
|
+
set(...entry: StorageEntry<S>): Promise<void>;
|
|
159
|
+
delete(key: StorageKey<S>): Promise<void>;
|
|
160
|
+
clear(): Promise<void>;
|
|
161
|
+
list(prefix?: string): Promise<string[]>;
|
|
162
|
+
info(): Promise<StorageInfo>;
|
|
139
163
|
};
|
|
164
|
+
/**
|
|
165
|
+
* Result of `lx.showActionSheet`. Branch on `canceled` before reading
|
|
166
|
+
* the selected item index.
|
|
167
|
+
*/
|
|
168
|
+
export type ActionSheetResult = {
|
|
169
|
+
canceled: false;
|
|
170
|
+
/** Index of the tapped item in `itemList`. */
|
|
171
|
+
index: number;
|
|
172
|
+
} | CanceledResult;
|
|
173
|
+
/** Every surface handle, narrowable by `kind`. */
|
|
174
|
+
export type AnySurface = PageSurface | DeclaredSurface | AppSurface | TabSurface | BuiltinSurface;
|
|
140
175
|
export type AppConfig = {
|
|
141
176
|
globalData?: Record<string, unknown>;
|
|
142
177
|
onLaunch?: (options?: AppLaunchOptions) => void | Promise<void>;
|
|
@@ -214,13 +249,20 @@ export type AppScreenshotResult = {
|
|
|
214
249
|
/** Image height in pixels, when the runtime could read it from the PNG. */
|
|
215
250
|
height?: number;
|
|
216
251
|
};
|
|
252
|
+
/** Another lxapp composed into a shell slot. */
|
|
253
|
+
export type AppSurface = SurfaceBase & SurfaceShowable & {
|
|
254
|
+
readonly kind: 'app';
|
|
255
|
+
readonly realized: 'main' | 'aside';
|
|
256
|
+
};
|
|
257
|
+
export type AppearanceApi = globalThis.AppearanceApi;
|
|
258
|
+
export type AppearancePreference = 'auto' | 'light' | 'dark';
|
|
217
259
|
/**
|
|
218
260
|
* Launch-at-startup control for the host app.
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
261
|
+
* Absent (`undefined`) wherever the host cannot register a startup item.
|
|
262
|
+
* `lx.supports({ capability: 'autostart' })` and the member's presence always
|
|
263
|
+
* agree, so either gate works:
|
|
222
264
|
* ```ts
|
|
223
|
-
* if (lx.
|
|
265
|
+
* if (lx.supports({ capability: 'autostart' })) {
|
|
224
266
|
* // render the "Launch at startup" toggle
|
|
225
267
|
* }
|
|
226
268
|
* ```
|
|
@@ -250,24 +292,37 @@ export type AutostartApi = {
|
|
|
250
292
|
setEnabled(on: boolean): Promise<void>;
|
|
251
293
|
};
|
|
252
294
|
export type BinaryFileData = ArrayBuffer | ArrayBufferView;
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
295
|
+
/**
|
|
296
|
+
* Built-in browser product page. Opening one requires
|
|
297
|
+
* `capabilities.browser` and is restricted to the home lxapp.
|
|
298
|
+
*/
|
|
299
|
+
export type BuiltinShellPage = 'settings' | 'downloads';
|
|
300
|
+
/**
|
|
301
|
+
* A host builtin page such as settings or downloads. The shell owns
|
|
302
|
+
* its lifetime and its visibility, so this handle reports identity:
|
|
303
|
+
* there is no `show` / `hide`, and the inherited `close()` rejects
|
|
304
|
+
* with `unsupported_placement`.
|
|
305
|
+
*/
|
|
306
|
+
export type BuiltinSurface = SurfaceBase & {
|
|
307
|
+
readonly kind: 'builtin';
|
|
308
|
+
};
|
|
309
|
+
/** The user dismissed the operation. Never an error. */
|
|
310
|
+
export type CanceledResult = {
|
|
311
|
+
canceled: true;
|
|
260
312
|
};
|
|
261
313
|
export type ChooseDirectoryOptions = {
|
|
262
314
|
/** Initial directory the dialog opens in. Platform default if omitted. */
|
|
263
315
|
defaultPath?: string;
|
|
264
316
|
};
|
|
317
|
+
/**
|
|
318
|
+
* Result of `lx.chooseDirectory`. Branch on `canceled` before reading
|
|
319
|
+
* the selected directory.
|
|
320
|
+
*/
|
|
265
321
|
export type ChooseDirectoryResult = {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
};
|
|
322
|
+
canceled: false;
|
|
323
|
+
/** Native-consumable directory reference (path or URI). */
|
|
324
|
+
path: string;
|
|
325
|
+
} | CanceledResult;
|
|
271
326
|
export type ChooseFileOptions = {
|
|
272
327
|
/** Allow selecting multiple files. Default: false */
|
|
273
328
|
multiple?: boolean;
|
|
@@ -281,16 +336,20 @@ export type ChooseFileOptions = {
|
|
|
281
336
|
*/
|
|
282
337
|
defaultPath?: string;
|
|
283
338
|
};
|
|
339
|
+
/**
|
|
340
|
+
* Result of `lx.chooseFile`. Branch on `canceled` before reading the
|
|
341
|
+
* selected paths.
|
|
342
|
+
*/
|
|
284
343
|
export type ChooseFileResult = {
|
|
285
|
-
|
|
286
|
-
canceled: boolean;
|
|
344
|
+
canceled: false;
|
|
287
345
|
/**
|
|
288
|
-
* File paths returned by LingXia. Values may be
|
|
289
|
-
* paths, or platform system-picker references.
|
|
290
|
-
* and pass them back to LingXia APIs such as
|
|
346
|
+
* File paths returned by LingXia; always at least one. Values may be
|
|
347
|
+
* app-local paths, `lx://...` paths, or platform system-picker references.
|
|
348
|
+
* Treat them as opaque strings and pass them back to LingXia APIs such as
|
|
349
|
+
* `lx.share`.
|
|
291
350
|
*/
|
|
292
|
-
paths: string[];
|
|
293
|
-
};
|
|
351
|
+
paths: [string, ...string[]];
|
|
352
|
+
} | CanceledResult;
|
|
294
353
|
export type ChooseMediaOptions = {
|
|
295
354
|
count?: number;
|
|
296
355
|
mediaType?: ('image' | 'video')[];
|
|
@@ -298,6 +357,15 @@ export type ChooseMediaOptions = {
|
|
|
298
357
|
camera?: 'back' | 'front';
|
|
299
358
|
maxDuration?: number;
|
|
300
359
|
};
|
|
360
|
+
/**
|
|
361
|
+
* Result of `lx.chooseMedia`. Branch on `canceled` before reading the
|
|
362
|
+
* selected entries.
|
|
363
|
+
*/
|
|
364
|
+
export type ChooseMediaResult = {
|
|
365
|
+
canceled: false;
|
|
366
|
+
/** Picked media; always at least one entry. */
|
|
367
|
+
entries: [ChosenMediaEntry, ...ChosenMediaEntry[]];
|
|
368
|
+
} | CanceledResult;
|
|
301
369
|
export type ChosenMediaEntry = {
|
|
302
370
|
tempFilePath: string;
|
|
303
371
|
fileType: 'image' | 'video';
|
|
@@ -388,11 +456,9 @@ export type ConnectWifiOptions = {
|
|
|
388
456
|
SSID: string;
|
|
389
457
|
password?: string;
|
|
390
458
|
};
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
/** Defaults to false. */
|
|
395
|
-
overwrite?: boolean;
|
|
459
|
+
/** A surface declared by the host in `lingxia.yaml`. */
|
|
460
|
+
export type DeclaredSurface = SurfaceBase & SurfaceShowable & {
|
|
461
|
+
readonly kind: 'declared';
|
|
396
462
|
};
|
|
397
463
|
/** Display and orientation APIs. */
|
|
398
464
|
export type DeviceOrientation = "portrait" | "landscape";
|
|
@@ -417,22 +483,19 @@ export type DownloadResult = AppDownloadResult | DownloadsDownloadResult;
|
|
|
417
483
|
export type DownloadsDownloadOptions = DownloadOptionsBase & {
|
|
418
484
|
/**
|
|
419
485
|
* Optional filename hint for the system Downloads destination.
|
|
420
|
-
* This is not an app-owned
|
|
486
|
+
* This is not an app-owned `lx.fs` path.
|
|
421
487
|
*/
|
|
422
488
|
filePath?: string;
|
|
423
489
|
/** Save into the user's system Downloads directory. */
|
|
424
490
|
destination: 'downloads';
|
|
425
491
|
};
|
|
426
492
|
export type DownloadsDownloadResult = {
|
|
427
|
-
/** Native system Downloads path. Do not pass this to `
|
|
493
|
+
/** Native system Downloads path. Do not pass this to `lx.fs`. */
|
|
428
494
|
filePath: SystemDownloadsPath;
|
|
429
495
|
tempFilePath?: never;
|
|
430
496
|
mimeType?: string;
|
|
431
497
|
size: number;
|
|
432
498
|
};
|
|
433
|
-
export type ExistsOptions = {
|
|
434
|
-
path: string;
|
|
435
|
-
};
|
|
436
499
|
export type ExtractVideoThumbnailOptions = {
|
|
437
500
|
/**
|
|
438
501
|
* Source video path or `lx://` URI.
|
|
@@ -486,6 +549,30 @@ export type FileDialogFilter = {
|
|
|
486
549
|
/** Allowed extensions without dots, e.g. ['pdf', 'txt']. */
|
|
487
550
|
extensions: string[];
|
|
488
551
|
};
|
|
552
|
+
export type FileSystemApi = globalThis.FileSystemApi;
|
|
553
|
+
export type FsCopyOptions = {
|
|
554
|
+
/** Defaults to false. */
|
|
555
|
+
overwrite?: boolean;
|
|
556
|
+
};
|
|
557
|
+
export type FsMkdirOptions = {
|
|
558
|
+
recursive?: boolean;
|
|
559
|
+
};
|
|
560
|
+
export type FsRemoveOptions = {
|
|
561
|
+
recursive?: boolean;
|
|
562
|
+
};
|
|
563
|
+
export type FsRenameOptions = {
|
|
564
|
+
/** Defaults to false. */
|
|
565
|
+
overwrite?: boolean;
|
|
566
|
+
};
|
|
567
|
+
export type FsWriteOptions = {
|
|
568
|
+
/**
|
|
569
|
+
* How string input is interpreted. Strings are UTF-8 by default; `base64`
|
|
570
|
+
* decodes the input into raw bytes before writing.
|
|
571
|
+
*/
|
|
572
|
+
encoding?: 'utf8' | 'base64';
|
|
573
|
+
/** Defaults to false. */
|
|
574
|
+
overwrite?: boolean;
|
|
575
|
+
};
|
|
489
576
|
/** Media picker, preview, scan, and file processing APIs. */
|
|
490
577
|
export type GetImageInfoOptions = {
|
|
491
578
|
path: string;
|
|
@@ -546,9 +633,9 @@ export type HostAppUpdateInfo = {
|
|
|
546
633
|
* The returned task can be awaited directly when progress is not needed, or
|
|
547
634
|
* consumed with `for await...of` to render progress.
|
|
548
635
|
*
|
|
549
|
-
*
|
|
550
|
-
*
|
|
551
|
-
* `releaseNotes` to guide users to the
|
|
636
|
+
* Requires `lx.supports({ capability: 'selfUpdate' })`. Where the host cannot
|
|
637
|
+
* install its own update it rejects with an unsupported-operation error;
|
|
638
|
+
* use `version` and `releaseNotes` to guide users to the app marketplace.
|
|
552
639
|
*/
|
|
553
640
|
apply(): HostAppUpdateTask;
|
|
554
641
|
};
|
|
@@ -567,6 +654,12 @@ export type HostAppUpdateTask = PromiseLike<HostAppUpdateResult> & AsyncIterable
|
|
|
567
654
|
finally(onfinally?: (() => void) | null): Promise<HostAppUpdateResult>;
|
|
568
655
|
wait(): Promise<HostAppUpdateResult>;
|
|
569
656
|
};
|
|
657
|
+
export type InstalledTerminalFont = {
|
|
658
|
+
family: string;
|
|
659
|
+
monospace: boolean;
|
|
660
|
+
ligatures: boolean;
|
|
661
|
+
nerdIcons: boolean;
|
|
662
|
+
};
|
|
570
663
|
/**
|
|
571
664
|
* Input event APIs.
|
|
572
665
|
* Platform support: Android only
|
|
@@ -586,33 +679,97 @@ export type KeyEventCallback = (event: KeyEvent) => void;
|
|
|
586
679
|
export type LxAppEnvVersion = 'release' | 'preview' | 'develop';
|
|
587
680
|
/** LxApp metadata APIs. */
|
|
588
681
|
export type LxAppReleaseType = 'release' | 'preview' | 'developer';
|
|
682
|
+
/** Boolean capability names accepted by `lx.supports`. */
|
|
683
|
+
export type LxCapabilityFlag = 'terminal' | 'autostart' | 'notifications' | 'browser' | 'proxy' | 'selfUpdate' | 'process' | 'appUse' | 'computerUse' | 'browserUse' | 'mediaCapture';
|
|
684
|
+
/**
|
|
685
|
+
* One capability question per call. The catalog is closed, so
|
|
686
|
+
* completion enumerates it and a typo is a type error. `capability`
|
|
687
|
+
* is the discriminant; only the `surface` branch accepts a `value`.
|
|
688
|
+
* Two surface answers describe an *affordance*, not whether the call
|
|
689
|
+
* succeeds: `tab` is "the host has an in-app browser" — without it a
|
|
690
|
+
* url still opens, in the OS browser instead — and `aside` is "a
|
|
691
|
+
* docked region exists right now", while a compact layout still opens
|
|
692
|
+
* the url through the in-app browser's own chrome. Ask them to decide
|
|
693
|
+
* what to render, not whether to call.
|
|
694
|
+
* `chrome` qualifies a window and only a window: it asks whether this
|
|
695
|
+
* host can produce that decoration, not merely a window.
|
|
696
|
+
*/
|
|
697
|
+
export type LxCapabilityQuery = {
|
|
698
|
+
capability: 'surface';
|
|
699
|
+
value: 'window';
|
|
700
|
+
chrome?: WindowChrome;
|
|
701
|
+
} | {
|
|
702
|
+
capability: 'surface';
|
|
703
|
+
value: Exclude<LxSurfaceCapability, 'window'>;
|
|
704
|
+
} | {
|
|
705
|
+
capability: LxCapabilityFlag;
|
|
706
|
+
};
|
|
589
707
|
export type LxEnv = globalThis.LxEnv;
|
|
708
|
+
/** Surface placements accepted by `lx.supports`. */
|
|
709
|
+
export type LxSurfaceCapability = 'main' | 'aside' | 'float' | 'window' | 'tab';
|
|
590
710
|
/** Device action APIs. */
|
|
591
711
|
export type MakePhoneCallOptions = {
|
|
592
712
|
phoneNumber: string;
|
|
593
713
|
};
|
|
594
714
|
export type MediaObjectFit = 'cover' | 'contain' | 'fill' | 'fit';
|
|
595
715
|
export type MediaRotation = 0 | 90 | 180 | 270;
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
716
|
+
/**
|
|
717
|
+
* Result of `lx.showModal`. `canceled: false` means the user confirmed;
|
|
718
|
+
* there is no third resolved outcome. Presentation failures reject.
|
|
719
|
+
*/
|
|
600
720
|
export type ModalResult = {
|
|
601
|
-
|
|
602
|
-
|
|
721
|
+
canceled: false;
|
|
722
|
+
} | CanceledResult;
|
|
723
|
+
/**
|
|
724
|
+
* One app-declared action shown in the host-provided More affordance.
|
|
725
|
+
* Mobile hosts render these in the capsule sheet; desktop hosts render
|
|
726
|
+
* them in the lxapp context menu. The native menu is fully dismissed
|
|
727
|
+
* before `onClick` runs.
|
|
728
|
+
*/
|
|
729
|
+
export type MoreAction = {
|
|
730
|
+
/** Bundled resource path or an app-accessible local `lx://` path. */
|
|
731
|
+
icon: string;
|
|
732
|
+
/** Visible action label. */
|
|
733
|
+
label: string;
|
|
734
|
+
onClick: () => void | Promise<void>;
|
|
603
735
|
};
|
|
736
|
+
/**
|
|
737
|
+
* Options for `lx.navigateBack()`. Omit the object or `delta` to pop
|
|
738
|
+
* one page.
|
|
739
|
+
*/
|
|
604
740
|
export type NavigateBackOptions = {
|
|
605
|
-
|
|
741
|
+
/** Number of pages to pop. Defaults to 1. */
|
|
742
|
+
delta?: number;
|
|
606
743
|
};
|
|
607
|
-
|
|
744
|
+
/**
|
|
745
|
+
* Navigate to another lxapp inside the current App Surface. JavaScript
|
|
746
|
+
* callers address pages by their configured name; page routes are an
|
|
747
|
+
* internal runtime detail and are not accepted as input.
|
|
748
|
+
*/
|
|
749
|
+
export type NavigateToAppOptions = {
|
|
608
750
|
appId: string;
|
|
751
|
+
/**
|
|
752
|
+
* Configured page name from the target lxapp's `lxapp.json`. Omit it to
|
|
753
|
+
* open the target app's initial page. Full routes such as
|
|
754
|
+
* `/pages/home/index` are not supported.
|
|
755
|
+
*/
|
|
609
756
|
page?: string;
|
|
610
|
-
path?: string;
|
|
611
757
|
query?: PageQuery;
|
|
612
758
|
envVersion?: LxAppEnvVersion;
|
|
613
759
|
targetVersion?: string;
|
|
614
760
|
};
|
|
615
761
|
export type NavigateToOptions = PageTargetOptions;
|
|
762
|
+
export type NavigationBarApi = globalThis.NavigationBarApi;
|
|
763
|
+
export type NavigationBarPatch = {
|
|
764
|
+
title?: string | null;
|
|
765
|
+
homeButton?: VisibilityPreference;
|
|
766
|
+
style?: NavigationBarStylePatch | null;
|
|
767
|
+
};
|
|
768
|
+
export type NavigationBarStylePatch = {
|
|
769
|
+
backgroundColor?: string | null;
|
|
770
|
+
foregroundColor?: string | null;
|
|
771
|
+
dividerColor?: string | null;
|
|
772
|
+
};
|
|
616
773
|
export type NetworkChangeCallback = (info: NetworkInfo) => void;
|
|
617
774
|
export type NetworkInfo = {
|
|
618
775
|
isConnected: boolean;
|
|
@@ -622,23 +779,6 @@ export type NetworkInfo = {
|
|
|
622
779
|
};
|
|
623
780
|
/** Network status APIs. */
|
|
624
781
|
export type NetworkType = 'none' | 'unknown' | 'wifi' | '2g' | '3g' | '4g' | '5g' | 'ethernet';
|
|
625
|
-
/**
|
|
626
|
-
* Show a surface declared by id in the host's `lingxia.yaml`.
|
|
627
|
-
* Available to any lxapp granted access to that declaration.
|
|
628
|
-
*/
|
|
629
|
-
export type OpenDeclaredSurfaceSpec = {
|
|
630
|
-
surface: string;
|
|
631
|
-
/** Docking edge override for this open. */
|
|
632
|
-
edge?: SurfaceEdge;
|
|
633
|
-
page?: never;
|
|
634
|
-
url?: never;
|
|
635
|
-
lxapp?: never;
|
|
636
|
-
native?: never;
|
|
637
|
-
as?: never;
|
|
638
|
-
position?: never;
|
|
639
|
-
size?: never;
|
|
640
|
-
query?: never;
|
|
641
|
-
};
|
|
642
782
|
/** File system APIs. */
|
|
643
783
|
export type OpenFileOptions = {
|
|
644
784
|
/** Local file path or runtime-managed temp path. */
|
|
@@ -655,134 +795,56 @@ export type OpenFileOptions = {
|
|
|
655
795
|
showMenu?: boolean;
|
|
656
796
|
};
|
|
657
797
|
/**
|
|
658
|
-
*
|
|
659
|
-
*
|
|
660
|
-
*
|
|
798
|
+
* `as` picks the shape. A float anchors and carries no decoration; a
|
|
799
|
+
* window is decorated and does not anchor. The runtime rejects the
|
|
800
|
+
* wrong pairing either way, so the type says it first — except with an
|
|
801
|
+
* ordered preference, where the realized placement is not known up
|
|
802
|
+
* front and both stay open.
|
|
661
803
|
*/
|
|
662
|
-
export type
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
804
|
+
export type OpenPageOptions = (OpenPageShared & {
|
|
805
|
+
/** The default. Rejects when the host cannot float. */
|
|
806
|
+
as?: 'float';
|
|
807
|
+
/** Where the float anchors. */
|
|
808
|
+
position?: SurfaceFloatPosition;
|
|
809
|
+
chrome?: never;
|
|
810
|
+
}) | (OpenPageShared & {
|
|
811
|
+
/** A separate desktop window. Rejects when the host cannot make one. */
|
|
812
|
+
as: 'window';
|
|
813
|
+
/** Window decoration. */
|
|
814
|
+
chrome?: WindowChrome;
|
|
815
|
+
position?: never;
|
|
816
|
+
}) | (OpenPageShared & {
|
|
666
817
|
/**
|
|
667
|
-
*
|
|
668
|
-
*
|
|
669
|
-
* opens there — or moves there if already visible.
|
|
818
|
+
* An ordered preference: the first placement the host can realize wins,
|
|
819
|
+
* and `realized` reports which.
|
|
670
820
|
*/
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
url?: never;
|
|
674
|
-
native?: never;
|
|
675
|
-
position?: never;
|
|
676
|
-
size?: never;
|
|
677
|
-
query?: never;
|
|
678
|
-
};
|
|
679
|
-
/**
|
|
680
|
-
* Open a host-registered native capability (home lxapp only), e.g.
|
|
681
|
-
* the built-in terminal declared in `lingxia.yaml` surfaces.
|
|
682
|
-
*/
|
|
683
|
-
export type OpenNativeSurfaceSpec = {
|
|
684
|
-
native: string;
|
|
685
|
-
/** Docking edge override for this open. */
|
|
686
|
-
edge?: SurfaceEdge;
|
|
687
|
-
page?: never;
|
|
688
|
-
url?: never;
|
|
689
|
-
lxapp?: never;
|
|
690
|
-
as?: never;
|
|
691
|
-
position?: never;
|
|
692
|
-
size?: never;
|
|
693
|
-
query?: never;
|
|
694
|
-
};
|
|
695
|
-
/**
|
|
696
|
-
* Spec for {@link OpenSurfaceSpec}. A discriminated union keyed by source so a
|
|
697
|
-
* page name and a declared surface id never collide (each is its own string
|
|
698
|
-
* space, separately type-checkable).
|
|
699
|
-
* - `{ page }` — one of this lxapp's own pages, by name, arranged as `as`
|
|
700
|
-
* (`float` is a popup; `window` is a bare desktop window, which rejects on
|
|
701
|
-
* mobile). `position` applies to `float`, and `size` is a Host-clamped hint.
|
|
702
|
-
* They are fixed at open (re-open to change). Your own pages **cannot** be
|
|
703
|
-
* docked as an `aside` — an aside is external content only (see `{ url }`).
|
|
704
|
-
* For a side panel of your own, use a declared `surface`, an in-page split
|
|
705
|
-
* layout, or `role: main` for a switchable destination.
|
|
706
|
-
* `float` is a popup layered above the main at `position` (like a dialog); it
|
|
707
|
-
* takes no layout space. `interaction` controls the native close button,
|
|
708
|
-
* outside-click dismissal, and modality. Defaults are no button,
|
|
709
|
-
* `tapOutside`, and non-modal.
|
|
710
|
-
* - `{ surface }` — a surface declared in `lingxia.yaml` `surfaces:`, by id
|
|
711
|
-
* (e.g. `'terminal'`, `'ai-assistant'`). Form, position, and startup data come
|
|
712
|
-
* from the declaration.
|
|
713
|
-
* - `{ url }` — external content in the in-app browser. Without `as` it opens as
|
|
714
|
-
* a main browser tab (the **self** browser: full chrome **with an editable
|
|
715
|
-
* address bar**, no handle). With `as: 'aside'` it opens in the **browser
|
|
716
|
-
* aside** — a docked (large screen) / full-screen (phone) **multi-tab** browser
|
|
717
|
-
* for external content only (`https://` or `file://`).
|
|
718
|
-
* The aside is **API-only** and never permits address editing or a manual
|
|
719
|
-
* "new tab" action. Desktop may show the current address read-only; compact
|
|
720
|
-
* phone/Runner chrome omits the address row entirely.
|
|
721
|
-
* Tabs are **deduped by URL** — reopening a URL focuses the existing tab and
|
|
722
|
-
* preserves its current navigation. On `medium` / `expanded`, the returned
|
|
723
|
-
* handle is **tab-scoped**: `close()` closes that tab. Compact browser chrome
|
|
724
|
-
* owns the group and returns `null`. Closing the last tab closes the aside;
|
|
725
|
-
* dismissing it only hides the group. The tab UI shows page **titles** (never
|
|
726
|
-
* the URL), plus per-tab close, back/forward, refresh, and dismissal.
|
|
727
|
-
* Presentation is the only large/small difference: on `medium` / `expanded`
|
|
728
|
-
* the aside **docks** and splits beside the main at `edge` (default `'right'`)
|
|
729
|
-
* with a horizontal title tab strip; on `compact` (phone / runner) it presents
|
|
730
|
-
* **full-screen** with a single-row **bottom** browser toolbar (tabs reached
|
|
731
|
-
* via an aside-only switcher). System/edge Back and the toolbar dismiss action
|
|
732
|
-
* exit the whole aside even when page history exists; the explicit browser
|
|
733
|
-
* Back button navigates history. `size` is a host-clamped preferred size
|
|
734
|
-
* (large screen only).
|
|
735
|
-
*/
|
|
736
|
-
export type OpenPageSurfaceSpec = {
|
|
737
|
-
page: string;
|
|
738
|
-
/** A popup above the main. */
|
|
739
|
-
as: 'float';
|
|
821
|
+
as: readonly ('float' | 'window')[];
|
|
822
|
+
chrome?: WindowChrome;
|
|
740
823
|
position?: SurfaceFloatPosition;
|
|
824
|
+
});
|
|
825
|
+
export type OpenPageShared = {
|
|
826
|
+
/**
|
|
827
|
+
* A float accepts a percentage; a window is in logical pixels and ignores
|
|
828
|
+
* one. Both live here rather than in two option types, because `as` may be
|
|
829
|
+
* an ordered preference and the realized placement is not known up front.
|
|
830
|
+
*/
|
|
741
831
|
size?: OverlaySurfaceSize;
|
|
742
832
|
interaction?: SurfaceInteraction;
|
|
743
833
|
query?: Record<string, unknown>;
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
url?: never;
|
|
747
|
-
} | {
|
|
748
|
-
page: string;
|
|
749
|
-
as: 'window';
|
|
750
|
-
size?: WindowSurfaceSize;
|
|
751
|
-
/** Windows use manual dismissal; `tapOutside` is invalid. */
|
|
752
|
-
interaction?: SurfaceInteraction;
|
|
753
|
-
query?: Record<string, unknown>;
|
|
754
|
-
edge?: never;
|
|
755
|
-
position?: never;
|
|
756
|
-
surface?: never;
|
|
757
|
-
url?: never;
|
|
834
|
+
/** Caller-owned identity, for `lx.surface.get(key)` later. */
|
|
835
|
+
key?: string;
|
|
758
836
|
};
|
|
759
|
-
export type
|
|
760
|
-
/**
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
*/
|
|
767
|
-
export type OpenUrlAsideSpec = {
|
|
768
|
-
url: string;
|
|
769
|
-
as: 'aside';
|
|
837
|
+
export type OpenUrlOptions = {
|
|
838
|
+
/**
|
|
839
|
+
* `tab` opens a browser tab; `aside` docks the browser beside the main.
|
|
840
|
+
* Defaults to `'tab'`.
|
|
841
|
+
*/
|
|
842
|
+
as?: 'tab' | 'aside' | readonly ('tab' | 'aside')[];
|
|
843
|
+
/** Preferred docking side when the realized placement is an aside. */
|
|
770
844
|
edge?: SurfaceEdge;
|
|
771
845
|
size?: OverlaySurfaceSize;
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
position?: never;
|
|
775
|
-
query?: never;
|
|
776
|
-
};
|
|
777
|
-
export type OpenUrlTabSpec = {
|
|
778
|
-
url: string;
|
|
779
|
-
as?: never;
|
|
780
|
-
page?: never;
|
|
781
|
-
surface?: never;
|
|
782
|
-
edge?: never;
|
|
783
|
-
position?: never;
|
|
784
|
-
size?: never;
|
|
785
|
-
query?: never;
|
|
846
|
+
/** Stable identity for `lx.surface.get(key)`. */
|
|
847
|
+
key?: string;
|
|
786
848
|
};
|
|
787
849
|
export type OverlaySurfaceSize = {
|
|
788
850
|
/** Width hint. */
|
|
@@ -805,20 +867,19 @@ export type PageMessagePort = {
|
|
|
805
867
|
};
|
|
806
868
|
export type PageQuery = Record<string, PageQueryValue>;
|
|
807
869
|
export type PageQueryValue = string | number | boolean | null | undefined;
|
|
870
|
+
/** One of this lxapp's own pages, opened as a float or a window. */
|
|
871
|
+
export type PageSurface = SurfaceBase & SurfaceShowable & SurfaceMessaging & {
|
|
872
|
+
readonly kind: 'page';
|
|
873
|
+
readonly realized: 'float' | 'window';
|
|
874
|
+
};
|
|
808
875
|
/**
|
|
809
876
|
* Target page for `navigateTo`, `redirectTo`, `switchTab`, and `reLaunch`.
|
|
810
|
-
*
|
|
811
|
-
*
|
|
877
|
+
* JavaScript navigation accepts only the configured page name; full routes
|
|
878
|
+
* are internal runtime details. Discover names with `lxdev lxapp pages`.
|
|
812
879
|
*/
|
|
813
880
|
export type PageTargetOptions = {
|
|
814
881
|
/** Configured page name from `lingxia.yaml` / `lxapp.json`. */
|
|
815
882
|
page: string;
|
|
816
|
-
path?: never;
|
|
817
|
-
query?: PageQuery;
|
|
818
|
-
} | {
|
|
819
|
-
/** Full page route, for example `/pages/home/index`. */
|
|
820
|
-
path: string;
|
|
821
|
-
page?: never;
|
|
822
883
|
query?: PageQuery;
|
|
823
884
|
};
|
|
824
885
|
export type PreviewMediaAdvance = 'manual' | 'next' | 'loop';
|
|
@@ -968,36 +1029,8 @@ export type PreviewMediaSource = {
|
|
|
968
1029
|
durationMs?: number;
|
|
969
1030
|
};
|
|
970
1031
|
export type ReLaunchOptions = PageTargetOptions;
|
|
971
|
-
export type ReadBinaryFileOptions = {
|
|
972
|
-
filePath: string;
|
|
973
|
-
encoding?: undefined;
|
|
974
|
-
};
|
|
975
|
-
export type ReadBinaryFileResult = {
|
|
976
|
-
data: ArrayBuffer;
|
|
977
|
-
};
|
|
978
|
-
export type ReadDirOptions = {
|
|
979
|
-
path: string;
|
|
980
|
-
};
|
|
981
|
-
export type ReadFileOptions = ReadTextFileOptions | ReadBinaryFileOptions;
|
|
982
|
-
export type ReadFileResult = ReadTextFileResult | ReadBinaryFileResult;
|
|
983
|
-
export type ReadTextFileOptions = {
|
|
984
|
-
filePath: string;
|
|
985
|
-
encoding: 'utf8' | 'base64';
|
|
986
|
-
};
|
|
987
|
-
export type ReadTextFileResult = {
|
|
988
|
-
data: string;
|
|
989
|
-
};
|
|
990
1032
|
export type RedirectToOptions = PageTargetOptions;
|
|
991
|
-
export type
|
|
992
|
-
path: string;
|
|
993
|
-
recursive?: boolean;
|
|
994
|
-
};
|
|
995
|
-
export type RenameOptions = {
|
|
996
|
-
oldPath: string;
|
|
997
|
-
newPath: string;
|
|
998
|
-
/** Defaults to false. */
|
|
999
|
-
overwrite?: boolean;
|
|
1000
|
-
};
|
|
1033
|
+
export type ResolvedAppearance = 'light' | 'dark';
|
|
1001
1034
|
export type SaveMediaOptions = {
|
|
1002
1035
|
filePath: string;
|
|
1003
1036
|
};
|
|
@@ -1005,10 +1038,15 @@ export type ScanCodeOptions = {
|
|
|
1005
1038
|
onlyFromCamera?: boolean;
|
|
1006
1039
|
scanType?: ('barCode' | 'qrCode' | 'datamatrix' | 'pdf417')[];
|
|
1007
1040
|
};
|
|
1041
|
+
/**
|
|
1042
|
+
* Result of `lx.scanCode`. Branch on `canceled` before reading the scan
|
|
1043
|
+
* payload.
|
|
1044
|
+
*/
|
|
1008
1045
|
export type ScanCodeResult = {
|
|
1046
|
+
canceled: false;
|
|
1009
1047
|
scanResult: string;
|
|
1010
1048
|
scanType: string;
|
|
1011
|
-
};
|
|
1049
|
+
} | CanceledResult;
|
|
1012
1050
|
/** Share images, PDFs, or other files. */
|
|
1013
1051
|
export type ShareFilesOptions = ShareTitleOptions & {
|
|
1014
1052
|
/**
|
|
@@ -1064,10 +1102,12 @@ export type SharePageOptions = ShareTextBaseOptions & {
|
|
|
1064
1102
|
export type ShareQuery = Record<string, string | number | boolean>;
|
|
1065
1103
|
export type ShareResult = {
|
|
1066
1104
|
/**
|
|
1067
|
-
*
|
|
1068
|
-
* system
|
|
1105
|
+
* What the share sheet reported. Not part of the `canceled` family: some
|
|
1106
|
+
* platforms only observe that the system UI opened and closed, so the
|
|
1107
|
+
* unknown case is stated rather than hidden in a missing boolean that
|
|
1108
|
+
* every call site would read as "not shared".
|
|
1069
1109
|
*/
|
|
1070
|
-
completed
|
|
1110
|
+
outcome: 'completed' | 'dismissed' | 'unknown';
|
|
1071
1111
|
};
|
|
1072
1112
|
export type ShareTextBaseOptions = ShareTitleOptions & {
|
|
1073
1113
|
/**
|
|
@@ -1090,26 +1130,143 @@ export type ShareTitleOptions = {
|
|
|
1090
1130
|
title?: string;
|
|
1091
1131
|
};
|
|
1092
1132
|
/**
|
|
1093
|
-
*
|
|
1094
|
-
*
|
|
1095
|
-
* callback; the app owns every resulting action.
|
|
1133
|
+
* App-owned host-shell chrome. Mutations are available only to the home
|
|
1134
|
+
* lxapp's Logic context; other lxapps receive a permission error.
|
|
1096
1135
|
*/
|
|
1097
|
-
export type
|
|
1136
|
+
export type ShellApi = {
|
|
1137
|
+
/**
|
|
1138
|
+
* Declares runtime actions in the desktop shell's sidebar header or footer.
|
|
1139
|
+
* The shell controls layout and only dispatches activation; callbacks own
|
|
1140
|
+
* navigation and all other behavior.
|
|
1141
|
+
*/
|
|
1142
|
+
sidebarActions: ShellSidebarActionsApi;
|
|
1143
|
+
/** Compose another lxapp into a shell slot. */
|
|
1144
|
+
openApp(appId: string, options: ShellOpenAppOptions): Promise<AppSurface>;
|
|
1145
|
+
/** Open a host builtin page such as settings or downloads. */
|
|
1146
|
+
openBuiltin(page: BuiltinShellPage): Promise<BuiltinSurface>;
|
|
1147
|
+
/**
|
|
1148
|
+
* Open a declared surface with shell privileges — the same declaration
|
|
1149
|
+
* `lx.surface.openDeclared` opens, plus the keyed multi-instance form and
|
|
1150
|
+
* placement overrides.
|
|
1151
|
+
*/
|
|
1152
|
+
openDeclared(id: string, options?: ShellOpenDeclaredOptions): Promise<DeclaredSurface>;
|
|
1153
|
+
/** Re-place a live declared surface: change its role or its edge. */
|
|
1154
|
+
reconfigure(id: string, patch: ShellSurfacePatch): Promise<void>;
|
|
1155
|
+
};
|
|
1156
|
+
export type ShellOpenAppOptions = {
|
|
1157
|
+
/** `main` occupies the primary content area; `aside` a companion region. */
|
|
1158
|
+
as: 'main' | 'aside';
|
|
1159
|
+
/** Preferred docking side. Only meaningful with `as: 'aside'`. */
|
|
1160
|
+
edge?: SurfaceEdge;
|
|
1161
|
+
/**
|
|
1162
|
+
* Configured page name from the target lxapp's `lxapp.json`. Omit it to
|
|
1163
|
+
* open that app's initial page. Full page routes are not supported.
|
|
1164
|
+
*/
|
|
1165
|
+
page?: string;
|
|
1166
|
+
query?: PageQuery;
|
|
1167
|
+
/** Defaults to 'release'. */
|
|
1168
|
+
envVersion?: LxAppEnvVersion;
|
|
1169
|
+
targetVersion?: string;
|
|
1170
|
+
/** Stable identity for `lx.surface.get(key)`. */
|
|
1171
|
+
key?: string;
|
|
1172
|
+
};
|
|
1173
|
+
/**
|
|
1174
|
+
* The declared-surface options only the home lxapp may use.
|
|
1175
|
+
* Creating an extra instance and overriding a placement both mutate
|
|
1176
|
+
* shared shell composition, so they live here and not on
|
|
1177
|
+
* `lx.surface.openDeclared` — which consumes a declaration exactly as
|
|
1178
|
+
* the host authored it, and therefore takes no options at all.
|
|
1179
|
+
*/
|
|
1180
|
+
export type ShellOpenDeclaredOptions = {
|
|
1181
|
+
/**
|
|
1182
|
+
* Caller-owned identity, for `lx.surface.get(key)` later — the same key
|
|
1183
|
+
* every opener takes. It carries one extra power here: a declaration can
|
|
1184
|
+
* be opened more than once, and the key is which instance you mean, so a
|
|
1185
|
+
* new key creates one. 1 to 128 UTF-8 bytes. Declarations without
|
|
1186
|
+
* instantiable native providers reject it with `capability_missing`.
|
|
1187
|
+
*/
|
|
1188
|
+
key?: string;
|
|
1189
|
+
/**
|
|
1190
|
+
* Open with a role other than the declaration's. Must be realizable by the
|
|
1191
|
+
* declared provider; a stable root rejects anything but `main`. Prefer this
|
|
1192
|
+
* over opening and then calling `reconfigure`, which would present the
|
|
1193
|
+
* wrong role first.
|
|
1194
|
+
*/
|
|
1195
|
+
as?: 'main' | 'aside' | 'float';
|
|
1196
|
+
/** Preferred docking side when the effective role is `aside`. */
|
|
1197
|
+
edge?: SurfaceEdge;
|
|
1198
|
+
};
|
|
1199
|
+
/**
|
|
1200
|
+
* One app-declared shell sidebar action. It is a stateless command, not a
|
|
1201
|
+
* selectable navigation item: the shell invokes `onActivate` once and
|
|
1202
|
+
* does not infer a target or active state.
|
|
1203
|
+
*/
|
|
1204
|
+
export type ShellSidebarAction = {
|
|
1205
|
+
/** Stable, non-empty id; unique across both header and footer actions. */
|
|
1098
1206
|
id: string;
|
|
1207
|
+
/**
|
|
1208
|
+
* Initial host-owned region. Use `replace` to move an action. The header
|
|
1209
|
+
* takes at most two; everything else belongs in the footer.
|
|
1210
|
+
*/
|
|
1211
|
+
placement: ShellSidebarActionPlacement;
|
|
1212
|
+
/**
|
|
1213
|
+
* Local lxapp-accessible icon. Use a bundled relative path such as
|
|
1214
|
+
* `public/settings.svg`, or an `lx://temp`, `lx://usercache`, or
|
|
1215
|
+
* `lx://userdata` path returned by LingXia file APIs. Native absolute paths,
|
|
1216
|
+
* parent traversal, `file:` URLs, and network URLs are rejected; download a
|
|
1217
|
+
* remote icon before registration. For portable rendering, prefer a square,
|
|
1218
|
+
* transparent, monochrome SVG or PNG designed for a 16-point visual.
|
|
1219
|
+
*/
|
|
1099
1220
|
icon: string;
|
|
1221
|
+
/**
|
|
1222
|
+
* Visible footer title and the tooltip/accessibility text for every
|
|
1223
|
+
* placement. Long footer labels are kept on one line and tail-truncated.
|
|
1224
|
+
*/
|
|
1100
1225
|
label: string;
|
|
1226
|
+
/** Visible but non-activatable when true. Defaults to false. */
|
|
1101
1227
|
disabled?: boolean;
|
|
1228
|
+
/**
|
|
1229
|
+
* Called once for each enabled mouse, keyboard, accessibility, shortcut, or
|
|
1230
|
+
* automation activation. Explicitly open or navigate to the desired content.
|
|
1231
|
+
*/
|
|
1102
1232
|
onActivate: () => void;
|
|
1103
1233
|
};
|
|
1104
|
-
/**
|
|
1105
|
-
|
|
1234
|
+
/**
|
|
1235
|
+
* Where the host renders a sidebar action on desktop.
|
|
1236
|
+
* - `header`: icon-only, at most two actions; `label` supplies tooltip
|
|
1237
|
+
* and accessibility text. Hidden in the compact/collapsed shell.
|
|
1238
|
+
* - `footer`: icon and label in the expanded sidebar, icon-only in the
|
|
1239
|
+
* compact rail. The host wraps cells and scrolls after five visible
|
|
1240
|
+
* rows.
|
|
1241
|
+
* Apps cannot configure cell size, row, weight, color, or selected state.
|
|
1242
|
+
* Where an action lives in the sidebar.
|
|
1243
|
+
* `header` is the caption row beside the window controls: at most two
|
|
1244
|
+
* actions, for the ones a person reaches for constantly. Declaring a
|
|
1245
|
+
* third rejects the whole `replace` call rather than hiding one.
|
|
1246
|
+
* `footer` is unbounded and scrolls, and every entry stays visible at
|
|
1247
|
+
* any window size. Anything that must be findable belongs here.
|
|
1248
|
+
*/
|
|
1249
|
+
export type ShellSidebarActionPlacement = 'header' | 'footer';
|
|
1250
|
+
/**
|
|
1251
|
+
* Mutable presentation fields for an existing sidebar action. The patch
|
|
1252
|
+
* must contain at least one field. Use `replace` to change `placement` or
|
|
1253
|
+
* `onActivate`.
|
|
1254
|
+
*/
|
|
1255
|
+
export type ShellSidebarActionUpdate = {
|
|
1256
|
+
/** Replacement local icon, with the same path rules as registration. */
|
|
1106
1257
|
icon?: string;
|
|
1258
|
+
/** Replacement non-empty visible/accessibility label. */
|
|
1107
1259
|
label?: string;
|
|
1260
|
+
/** Whether the action remains visible but rejects activation. */
|
|
1108
1261
|
disabled?: boolean;
|
|
1109
1262
|
};
|
|
1110
|
-
/**
|
|
1111
|
-
|
|
1112
|
-
|
|
1263
|
+
/**
|
|
1264
|
+
* Role and edge overrides the home lxapp may apply to a live declared
|
|
1265
|
+
* surface. A stable root rejects non-main roles.
|
|
1266
|
+
*/
|
|
1267
|
+
export type ShellSurfacePatch = {
|
|
1268
|
+
as?: 'main' | 'aside' | 'float';
|
|
1269
|
+
edge?: SurfaceEdge;
|
|
1113
1270
|
};
|
|
1114
1271
|
export type ShowActionSheetOptions = {
|
|
1115
1272
|
itemList: string[];
|
|
@@ -1133,16 +1290,25 @@ export type ShowToastOptions = {
|
|
|
1133
1290
|
mask?: boolean;
|
|
1134
1291
|
position?: 'top' | 'center' | 'bottom';
|
|
1135
1292
|
};
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1293
|
+
/**
|
|
1294
|
+
* Asynchronous persistent key-value storage backed by the lxapp
|
|
1295
|
+
* database. Use `lx.fs` for path-based data.
|
|
1296
|
+
* `get<T>()` is an unchecked assertion at the call site. Pin every
|
|
1297
|
+
* key's shape once with `lx.getStorage<Schema>()` — that returns a
|
|
1298
|
+
* `TypedStorage<Schema>` instead of this untyped handle.
|
|
1299
|
+
*/
|
|
1140
1300
|
export type Storage = {
|
|
1141
|
-
|
|
1301
|
+
/**
|
|
1302
|
+
* Reads a stored value. `T` is an unchecked assertion about the stored
|
|
1303
|
+
* shape, exactly like a `JSON.parse` boundary; a missing key resolves
|
|
1304
|
+
* `undefined`, which a stored `null` never does.
|
|
1305
|
+
*/
|
|
1306
|
+
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
1142
1307
|
set(key: string, value: unknown): Promise<void>;
|
|
1143
1308
|
delete(key: string): Promise<void>;
|
|
1144
1309
|
clear(): Promise<void>;
|
|
1145
|
-
|
|
1310
|
+
/** Resolves every key, optionally filtered by prefix. */
|
|
1311
|
+
list(prefix?: string): Promise<string[]>;
|
|
1146
1312
|
info(): Promise<StorageInfo>;
|
|
1147
1313
|
};
|
|
1148
1314
|
/** Current persistent-storage usage and configured limits. */
|
|
@@ -1157,61 +1323,65 @@ export type StreamSourceOptions = {
|
|
|
1157
1323
|
duration?: number;
|
|
1158
1324
|
params?: Record<string, unknown>;
|
|
1159
1325
|
};
|
|
1160
|
-
|
|
1161
|
-
|
|
1326
|
+
/**
|
|
1327
|
+
* Content-keyed surface composition, callable by any lxapp. Privileged
|
|
1328
|
+
* composition lives on `lx.shell`, so the namespace is the privilege.
|
|
1329
|
+
*/
|
|
1330
|
+
export type SurfaceApi = {
|
|
1331
|
+
/** Open one of this lxapp's own pages as a float or a window. */
|
|
1332
|
+
openPage(page: string, options?: OpenPageOptions): Promise<PageSurface>;
|
|
1333
|
+
/** Open external content in the in-app browser. */
|
|
1334
|
+
openUrl(url: string, options?: OpenUrlOptions): Promise<TabSurface>;
|
|
1162
1335
|
/**
|
|
1163
|
-
*
|
|
1164
|
-
*
|
|
1165
|
-
*
|
|
1336
|
+
* Open a surface the host declared in `lingxia.yaml`, with the placement
|
|
1337
|
+
* the declaration chose. Instance keys and placement overrides are shell
|
|
1338
|
+
* composition; they live on `lx.shell.openDeclared`.
|
|
1166
1339
|
*/
|
|
1167
|
-
|
|
1340
|
+
openDeclared(id: string): Promise<DeclaredSurface>;
|
|
1168
1341
|
/**
|
|
1169
|
-
*
|
|
1170
|
-
*
|
|
1171
|
-
*
|
|
1342
|
+
* The live handle for a surface this lxapp opened **with a `key`**, found
|
|
1343
|
+
* by that key or by its `id`. Removes the need to cache handles in order
|
|
1344
|
+
* to reuse or close them. A surface opened without a `key` is not
|
|
1345
|
+
* addressable — nothing else refers to a runtime-assigned id, so nothing
|
|
1346
|
+
* registers it. A key you chose wins over an id it happens to spell.
|
|
1172
1347
|
*/
|
|
1173
|
-
|
|
1174
|
-
/**
|
|
1175
|
-
* Sends a message to the other side of a page surface.
|
|
1176
|
-
*
|
|
1177
|
-
* For the opener this targets the opened page. For the opened page this
|
|
1178
|
-
* targets the opener. URL surfaces have no page-side receiver.
|
|
1179
|
-
*/
|
|
1180
|
-
postMessage(message: unknown): void;
|
|
1181
|
-
onMessage(handler: (message: unknown) => void): () => void;
|
|
1182
|
-
onClose(handler: (event: SurfaceClosedEvent) => void): () => void;
|
|
1348
|
+
get(keyOrId: string): AnySurface | undefined;
|
|
1183
1349
|
/**
|
|
1184
|
-
*
|
|
1185
|
-
*
|
|
1186
|
-
* function.
|
|
1187
|
-
* already-visible surface is a no-op for listeners.
|
|
1350
|
+
* Observe this presentation's viewport. Invoked immediately with the
|
|
1351
|
+
* current context, then again whenever it changes. Returns an unsubscribe
|
|
1352
|
+
* function.
|
|
1188
1353
|
*/
|
|
1189
|
-
|
|
1354
|
+
onContext(handler: (context: SurfaceContext) => void): () => void;
|
|
1355
|
+
};
|
|
1356
|
+
/** What every surface handle carries, whatever opened it. */
|
|
1357
|
+
export type SurfaceBase = {
|
|
1358
|
+
readonly kind: SurfaceKind;
|
|
1359
|
+
readonly id: string;
|
|
1360
|
+
/** The caller-supplied identity, when this surface was opened with one. */
|
|
1361
|
+
readonly key?: string;
|
|
1190
1362
|
/**
|
|
1191
|
-
*
|
|
1192
|
-
*
|
|
1193
|
-
*
|
|
1363
|
+
* The placement the host produced, which an ordered preference may narrow.
|
|
1364
|
+
* Live rather than a snapshot: `lx.shell.reconfigure` updates it on the
|
|
1365
|
+
* handle you already hold.
|
|
1194
1366
|
*/
|
|
1195
|
-
|
|
1196
|
-
close()
|
|
1367
|
+
readonly realized: SurfacePlacement;
|
|
1368
|
+
/** True until `close()` fires; afterwards the page instance is torn down. */
|
|
1369
|
+
readonly alive: boolean;
|
|
1197
1370
|
/**
|
|
1198
|
-
*
|
|
1199
|
-
*
|
|
1200
|
-
* destroys the surface and fires the onClose listener. Idempotent: calling
|
|
1201
|
-
* on an already-visible surface resolves without firing `onShow`.
|
|
1371
|
+
* Last-known visibility, kept in sync with the native side. Safe to bind
|
|
1372
|
+
* into declarative UI; for event-driven updates use `onShow` / `onHide`.
|
|
1202
1373
|
*/
|
|
1203
|
-
|
|
1374
|
+
readonly visible: boolean;
|
|
1204
1375
|
/**
|
|
1205
|
-
*
|
|
1206
|
-
*
|
|
1207
|
-
* and JS state. Hidden surfaces still receive postMessage but are not
|
|
1208
|
-
* visible to the user. Idempotent.
|
|
1376
|
+
* Destroy the surface. The stable root main cannot be closed. Repeated
|
|
1377
|
+
* calls after a successful close are idempotent.
|
|
1209
1378
|
*/
|
|
1210
|
-
|
|
1379
|
+
close(): Promise<void>;
|
|
1380
|
+
onClose(handler: (event: SurfaceClosedEvent) => void): () => void;
|
|
1211
1381
|
};
|
|
1212
1382
|
/**
|
|
1213
1383
|
* Surfaces (docked asides, floats, windows, browser tabs, declared surfaces)
|
|
1214
|
-
* and the desktop tray — the types behind `lx.
|
|
1384
|
+
* and the desktop tray — the types behind `lx.surface`, `lx.shell`,
|
|
1215
1385
|
* and `lx.tray`.
|
|
1216
1386
|
*/
|
|
1217
1387
|
export type SurfaceCloseReason = 'user' | 'programmatic' | 'owner_closed' | 'app_closed' | 'failed'
|
|
@@ -1223,11 +1393,10 @@ export type SurfaceCloseReason = 'user' | 'programmatic' | 'owner_closed' | 'app
|
|
|
1223
1393
|
| 'reclaimed' | 'unknown';
|
|
1224
1394
|
export type SurfaceClosedEvent = {
|
|
1225
1395
|
id: string;
|
|
1226
|
-
kind: 'overlay' | 'window';
|
|
1227
1396
|
reason: SurfaceCloseReason;
|
|
1228
1397
|
};
|
|
1229
1398
|
/**
|
|
1230
|
-
* The current surface viewport context, delivered to `lx.
|
|
1399
|
+
* The current surface viewport context, delivered to `lx.surface.onContext()`
|
|
1231
1400
|
* so an lxapp can self-adapt (e.g. switch column count by `sizeClass`).
|
|
1232
1401
|
*/
|
|
1233
1402
|
export type SurfaceContext = {
|
|
@@ -1238,34 +1407,51 @@ export type SurfaceContext = {
|
|
|
1238
1407
|
/** Actual surface viewport height in logical pixels. */
|
|
1239
1408
|
height: number;
|
|
1240
1409
|
};
|
|
1241
|
-
/**
|
|
1410
|
+
/**
|
|
1411
|
+
* Preferred docking side for an aside when the Host has room for a docked
|
|
1412
|
+
* layout. `aside` selects the companion region; `edge` selects a side within
|
|
1413
|
+
* it. Compact Hosts may reproject the same aside as a full-screen overlay.
|
|
1414
|
+
*/
|
|
1242
1415
|
export type SurfaceEdge = 'left' | 'right' | 'top' | 'bottom';
|
|
1416
|
+
/**
|
|
1417
|
+
* A surface rejection. The runtime carries the surface code on
|
|
1418
|
+
* `data.code` — `code` itself is the transport-level host code, shared
|
|
1419
|
+
* with every other `lx` rejection — so read it with
|
|
1420
|
+
* `surfaceErrorCode(error)` and never parse the message.
|
|
1421
|
+
* ```ts
|
|
1422
|
+
* import { surfaceErrorCode } from 'lingxia-types/error';
|
|
1423
|
+
* catch (error) {
|
|
1424
|
+
* if (surfaceErrorCode(error) === 'unsupported_placement') { … }
|
|
1425
|
+
* }
|
|
1426
|
+
* ```
|
|
1427
|
+
*/
|
|
1428
|
+
export type SurfaceError = Error & {
|
|
1429
|
+
readonly data?: {
|
|
1430
|
+
readonly code?: SurfaceErrorCode;
|
|
1431
|
+
};
|
|
1432
|
+
};
|
|
1433
|
+
/**
|
|
1434
|
+
* Why a surface operation was refused. Carried as `code` on every
|
|
1435
|
+
* `SurfaceError`, so no caller has to match on message text.
|
|
1436
|
+
*/
|
|
1437
|
+
export type SurfaceErrorCode = /** The placement cannot be realized by this host build. */ 'unsupported_placement'
|
|
1438
|
+
/** A privileged operation was called by an lxapp other than the home lxapp. */
|
|
1439
|
+
| 'denied'
|
|
1440
|
+
/** No such declared surface, lxapp, or builtin page. */
|
|
1441
|
+
| 'not_declared'
|
|
1442
|
+
/** The arguments are malformed or combine options that cannot apply together. */
|
|
1443
|
+
| 'invalid_arg'
|
|
1444
|
+
/** The target is already open in a role this call cannot change. */
|
|
1445
|
+
| 'already_open_other_role'
|
|
1446
|
+
/** The surface has been closed; the handle is detached. */
|
|
1447
|
+
| 'closed'
|
|
1448
|
+
/** The host lacks a capability the request needs, such as an instantiable
|
|
1449
|
+
* native provider for a keyed surface. */
|
|
1450
|
+
| 'capability_missing'
|
|
1451
|
+
/** The operation reached the host and failed there. */
|
|
1452
|
+
| 'failed';
|
|
1243
1453
|
/** Where a float popup anchors (default `center`). */
|
|
1244
1454
|
export type SurfaceFloatPosition = 'center' | 'top' | 'bottom' | 'left' | 'right';
|
|
1245
|
-
export type SurfaceHandle = {
|
|
1246
|
-
readonly id: string;
|
|
1247
|
-
/** Standalone windows have no role in the primary shell graph. */
|
|
1248
|
-
readonly role?: SurfaceRole;
|
|
1249
|
-
readonly presentation: SurfacePresentation;
|
|
1250
|
-
readonly visible: boolean;
|
|
1251
|
-
readonly alive: boolean;
|
|
1252
|
-
/**
|
|
1253
|
-
* Show a host-managed surface. Dynamic page/url surfaces return a Promise;
|
|
1254
|
-
* host-declared surfaces may complete synchronously.
|
|
1255
|
-
*/
|
|
1256
|
-
show(): void | Promise<void>;
|
|
1257
|
-
/**
|
|
1258
|
-
* Hide without destroying user-visible state when the platform supports it.
|
|
1259
|
-
*/
|
|
1260
|
-
hide(): void | Promise<void>;
|
|
1261
|
-
/**
|
|
1262
|
-
* Destroy the live surface. Repeated close calls are idempotent.
|
|
1263
|
-
*/
|
|
1264
|
-
close(): void | Promise<void>;
|
|
1265
|
-
onShow(handler: (event: SurfaceVisibilityEvent) => void): () => void;
|
|
1266
|
-
onHide(handler: (event: SurfaceVisibilityEvent) => void): () => void;
|
|
1267
|
-
onClose(handler: (event: SurfaceClosedEvent) => void): () => void;
|
|
1268
|
-
};
|
|
1269
1455
|
/** Native interaction supplied by the host around page content. */
|
|
1270
1456
|
export type SurfaceInteraction = {
|
|
1271
1457
|
/** Show the standard circular close button. Default `false`. */
|
|
@@ -1275,27 +1461,212 @@ export type SurfaceInteraction = {
|
|
|
1275
1461
|
/** Block interaction with content below. Default `false`. */
|
|
1276
1462
|
modal?: boolean;
|
|
1277
1463
|
};
|
|
1464
|
+
/**
|
|
1465
|
+
* Where the content came from. The discriminant on every surface
|
|
1466
|
+
* handle, so `AnySurface` narrows without a runtime `typeof` check.
|
|
1467
|
+
*/
|
|
1468
|
+
export type SurfaceKind = 'page' | 'declared' | 'app' | 'tab' | 'builtin';
|
|
1469
|
+
/** Two-way messaging, available when both sides are lxapp pages. */
|
|
1470
|
+
export type SurfaceMessaging = {
|
|
1471
|
+
/**
|
|
1472
|
+
* Send to the other side. For the opener this targets the opened page;
|
|
1473
|
+
* for the opened page it targets the opener.
|
|
1474
|
+
*/
|
|
1475
|
+
postMessage(message: unknown): void;
|
|
1476
|
+
onMessage(handler: (message: unknown) => void): () => void;
|
|
1477
|
+
};
|
|
1478
|
+
/**
|
|
1479
|
+
* What the host actually produced. Reported by `realized`, which is
|
|
1480
|
+
* how a caller reads the outcome of an ordered placement preference.
|
|
1481
|
+
*/
|
|
1482
|
+
export type SurfacePlacement = 'main' | 'aside' | 'float' | 'window' | 'tab';
|
|
1278
1483
|
export type SurfacePresentation = 'main' | 'dock' | 'overlay' | 'popover' | 'sheet' | 'window';
|
|
1279
1484
|
export type SurfaceRole = 'main' | 'aside' | 'float';
|
|
1485
|
+
/** Surfaces the host can hide and restore without losing page state. */
|
|
1486
|
+
export type SurfaceShowable = {
|
|
1487
|
+
/**
|
|
1488
|
+
* Restore a hidden surface. The page instance survived, so scroll
|
|
1489
|
+
* position, form input, and JS state come back with it. Idempotent.
|
|
1490
|
+
*/
|
|
1491
|
+
show(): Promise<void>;
|
|
1492
|
+
/**
|
|
1493
|
+
* Hide without destroying. Main surfaces cannot be hidden and reject.
|
|
1494
|
+
* Idempotent.
|
|
1495
|
+
*/
|
|
1496
|
+
hide(): Promise<void>;
|
|
1497
|
+
/** Fires on a real transition to visible, whichever side drove it. */
|
|
1498
|
+
onShow(handler: (event: SurfaceVisibilityEvent) => void): () => void;
|
|
1499
|
+
/** Fires on a real transition to hidden, whichever side drove it. */
|
|
1500
|
+
onHide(handler: (event: SurfaceVisibilityEvent) => void): () => void;
|
|
1501
|
+
};
|
|
1280
1502
|
/**
|
|
1281
1503
|
* Detail payload for `onShow` / `onHide` events. `source` identifies which
|
|
1282
1504
|
* Surface object initiated the visibility change so observers can
|
|
1283
1505
|
* distinguish self-driven transitions from peer-driven ones (e.g. an opener
|
|
1284
1506
|
* UI that wants to update its own button state only when the page side
|
|
1285
|
-
* toggled visibility).
|
|
1507
|
+
* toggled visibility). `shell` identifies a host-driven main switch.
|
|
1286
1508
|
*/
|
|
1287
1509
|
export type SurfaceVisibilityEvent = {
|
|
1288
1510
|
id: string;
|
|
1289
|
-
|
|
1290
|
-
source: 'opener' | 'page';
|
|
1511
|
+
source: 'opener' | 'page' | 'shell';
|
|
1291
1512
|
};
|
|
1292
1513
|
export type SwitchTabOptions = PageTargetOptions;
|
|
1293
|
-
/** Native system Downloads path. Do not pass this to `
|
|
1514
|
+
/** Native system Downloads path. Do not pass this to `lx.fs`. */
|
|
1294
1515
|
export type SystemDownloadsPath = string & {
|
|
1295
1516
|
readonly [systemDownloadsPathBrand]: 'system-downloads-path';
|
|
1296
1517
|
};
|
|
1297
|
-
export type
|
|
1518
|
+
export type TabBarApi = globalThis.TabBarApi;
|
|
1519
|
+
export type TabBarItemPatch = {
|
|
1298
1520
|
index: number;
|
|
1521
|
+
text?: string | null;
|
|
1522
|
+
iconPath?: string | null;
|
|
1523
|
+
selectedIconPath?: string | null;
|
|
1524
|
+
badge?: string | null;
|
|
1525
|
+
redDot?: boolean;
|
|
1526
|
+
};
|
|
1527
|
+
export type TabBarPatch = {
|
|
1528
|
+
visibility?: TabBarVisibilityPreference;
|
|
1529
|
+
style?: TabBarStylePatch | null;
|
|
1530
|
+
items?: readonly TabBarItemPatch[];
|
|
1531
|
+
};
|
|
1532
|
+
export type TabBarStylePatch = {
|
|
1533
|
+
foregroundColor?: string | null;
|
|
1534
|
+
selectedForegroundColor?: string | null;
|
|
1535
|
+
};
|
|
1536
|
+
export type TabBarVisibilityPreference = 'auto' | 'visible' | 'hidden';
|
|
1537
|
+
/** External content in the in-app browser. */
|
|
1538
|
+
export type TabSurface = SurfaceBase & {
|
|
1539
|
+
readonly kind: 'tab';
|
|
1540
|
+
readonly realized: 'tab' | 'aside';
|
|
1541
|
+
/**
|
|
1542
|
+
* `tab` when this handle owns exactly the tab it opened, and `close()` /
|
|
1543
|
+
* `activate()` act on it. `group` when the browser chrome owns the tab
|
|
1544
|
+
* strip: the content is open, but control belongs to that chrome, so both
|
|
1545
|
+
* methods reject with `unsupported_placement`. Branch on this rather than
|
|
1546
|
+
* on the old platform-dependent `null`.
|
|
1547
|
+
*/
|
|
1548
|
+
readonly scope: 'tab' | 'group';
|
|
1549
|
+
/** Bring this tab to the front of its browser. `scope: 'group'` rejects. */
|
|
1550
|
+
activate(): Promise<void>;
|
|
1551
|
+
};
|
|
1552
|
+
export type TerminalApi = {
|
|
1553
|
+
/** Saved terminal settings, revision-checked on write. */
|
|
1554
|
+
readonly settings: TerminalSettingsApi;
|
|
1555
|
+
/** Installed color schemes, plus import and live preview. */
|
|
1556
|
+
readonly colorSchemes: TerminalColorSchemesApi;
|
|
1557
|
+
/** Terminal fonts installed on this machine. */
|
|
1558
|
+
readonly fonts: TerminalFontsApi;
|
|
1559
|
+
/** Windows-only optional inline-image compatibility runtime. */
|
|
1560
|
+
readonly windows?: WindowsTerminalApi;
|
|
1561
|
+
};
|
|
1562
|
+
export type TerminalColorScheme = {
|
|
1563
|
+
name?: string;
|
|
1564
|
+
background: string;
|
|
1565
|
+
foreground: string;
|
|
1566
|
+
cursorColor?: string;
|
|
1567
|
+
selectionBackground?: string;
|
|
1568
|
+
selectionForeground?: string;
|
|
1569
|
+
black: string;
|
|
1570
|
+
red: string;
|
|
1571
|
+
green: string;
|
|
1572
|
+
yellow: string;
|
|
1573
|
+
blue: string;
|
|
1574
|
+
purple: string;
|
|
1575
|
+
cyan: string;
|
|
1576
|
+
white: string;
|
|
1577
|
+
brightBlack: string;
|
|
1578
|
+
brightRed: string;
|
|
1579
|
+
brightGreen: string;
|
|
1580
|
+
brightYellow: string;
|
|
1581
|
+
brightBlue: string;
|
|
1582
|
+
brightPurple: string;
|
|
1583
|
+
brightCyan: string;
|
|
1584
|
+
brightWhite: string;
|
|
1585
|
+
};
|
|
1586
|
+
export type TerminalColorSchemeDetails = {
|
|
1587
|
+
name: string;
|
|
1588
|
+
source: 'builtIn' | 'imported';
|
|
1589
|
+
scheme: TerminalColorScheme;
|
|
1590
|
+
};
|
|
1591
|
+
export type TerminalColorSchemesApi = {
|
|
1592
|
+
list(): Promise<TerminalColorSchemeDetails[]>;
|
|
1593
|
+
import(options: {
|
|
1594
|
+
text: string;
|
|
1595
|
+
name?: string;
|
|
1596
|
+
/** Existing names are rejected unless overwrite is explicit. */
|
|
1597
|
+
overwrite?: boolean;
|
|
1598
|
+
}): Promise<TerminalColorSchemeDetails>;
|
|
1599
|
+
createPreview(): TerminalPreviewController;
|
|
1600
|
+
};
|
|
1601
|
+
export type TerminalFontSettings = {
|
|
1602
|
+
/** Ordered candidates; the first installed monospaced family wins. */
|
|
1603
|
+
family: string[];
|
|
1604
|
+
size: number;
|
|
1605
|
+
lineHeight: number;
|
|
1606
|
+
ligatures: boolean;
|
|
1607
|
+
};
|
|
1608
|
+
export type TerminalFontsApi = {
|
|
1609
|
+
list(): Promise<InstalledTerminalFont[]>;
|
|
1610
|
+
};
|
|
1611
|
+
export type TerminalPreviewController = {
|
|
1612
|
+
/** Preview a stored name or an unpersisted scheme. Last request wins. */
|
|
1613
|
+
show(scheme: string | TerminalColorScheme): Promise<void>;
|
|
1614
|
+
/** Restore saved settings only when this controller owns the preview. */
|
|
1615
|
+
clear(): Promise<void>;
|
|
1616
|
+
/** Idempotently clear and retire this controller. */
|
|
1617
|
+
close(): Promise<void>;
|
|
1618
|
+
};
|
|
1619
|
+
export type TerminalSettingsApi = {
|
|
1620
|
+
get(): Promise<TerminalSettingsSnapshot>;
|
|
1621
|
+
update(patch: TerminalSettingsPatch, options: {
|
|
1622
|
+
ifRevision: number;
|
|
1623
|
+
}): Promise<TerminalSettingsSnapshot>;
|
|
1624
|
+
reset(options: {
|
|
1625
|
+
ifRevision: number;
|
|
1626
|
+
scope?: 'font' | 'theme';
|
|
1627
|
+
}): Promise<TerminalSettingsSnapshot>;
|
|
1628
|
+
/** Fires after saved settings, effective appearance, or fonts change. */
|
|
1629
|
+
onChange(listener: (snapshot: TerminalSettingsSnapshot) => void): () => void;
|
|
1630
|
+
};
|
|
1631
|
+
export type TerminalSettingsPatch = {
|
|
1632
|
+
font?: Partial<TerminalFontSettings>;
|
|
1633
|
+
theme?: Partial<TerminalThemeSettings>;
|
|
1634
|
+
};
|
|
1635
|
+
export type TerminalSettingsSnapshot = {
|
|
1636
|
+
/** Monotonic process revision used by update/reset compare-and-swap. */
|
|
1637
|
+
revision: number;
|
|
1638
|
+
/** Framework defaults. */
|
|
1639
|
+
defaults: TerminalSettingsValue;
|
|
1640
|
+
/** User-authored fields only. */
|
|
1641
|
+
overrides: TerminalSettingsPatch;
|
|
1642
|
+
/** Resolved configuration after all valid layers. */
|
|
1643
|
+
value: TerminalSettingsValue;
|
|
1644
|
+
effective: {
|
|
1645
|
+
/** Host appearance before applying terminal.theme.mode. */
|
|
1646
|
+
systemAppearance: 'light' | 'dark';
|
|
1647
|
+
appearance: 'light' | 'dark';
|
|
1648
|
+
colorScheme: string | null;
|
|
1649
|
+
font: {
|
|
1650
|
+
family: string;
|
|
1651
|
+
missing: string[];
|
|
1652
|
+
fellBack: boolean;
|
|
1653
|
+
};
|
|
1654
|
+
};
|
|
1655
|
+
warnings: TerminalSettingsWarning[];
|
|
1656
|
+
};
|
|
1657
|
+
export type TerminalSettingsValue = {
|
|
1658
|
+
font: TerminalFontSettings;
|
|
1659
|
+
theme: TerminalThemeSettings;
|
|
1660
|
+
};
|
|
1661
|
+
export type TerminalSettingsWarning = {
|
|
1662
|
+
code: 'invalidUserFile' | 'missingColorScheme';
|
|
1663
|
+
message: string;
|
|
1664
|
+
};
|
|
1665
|
+
export type TerminalThemeMode = 'system' | 'light' | 'dark';
|
|
1666
|
+
export type TerminalThemeSettings = {
|
|
1667
|
+
mode: TerminalThemeMode;
|
|
1668
|
+
light: string;
|
|
1669
|
+
dark: string;
|
|
1299
1670
|
};
|
|
1300
1671
|
export type TrayApi = globalThis.TrayApi;
|
|
1301
1672
|
/**
|
|
@@ -1320,11 +1691,17 @@ export type TrayMenuSeparator = {
|
|
|
1320
1691
|
export type UpdateFailedInfo = UpdateReadyInfo & {
|
|
1321
1692
|
error?: string;
|
|
1322
1693
|
};
|
|
1323
|
-
/**
|
|
1694
|
+
/**
|
|
1695
|
+
* Callback-based updates for this lxapp's bundle. Available to every
|
|
1696
|
+
* lxapp. To update the native host app, the home lxapp uses the
|
|
1697
|
+
* task-based `lx.app.checkUpdate()` API instead.
|
|
1698
|
+
*/
|
|
1324
1699
|
export type UpdateManager = {
|
|
1325
1700
|
applyUpdate(): void;
|
|
1326
|
-
|
|
1327
|
-
|
|
1701
|
+
/** Subscribes to a ready update and returns the unsubscribe fn. */
|
|
1702
|
+
onUpdateReady(callback: (info: UpdateReadyInfo) => void): () => void;
|
|
1703
|
+
/** Subscribes to a failed update and returns the unsubscribe fn. */
|
|
1704
|
+
onUpdateFailed(callback: (info: UpdateFailedInfo) => void): () => void;
|
|
1328
1705
|
};
|
|
1329
1706
|
export type UpdateReadyInfo = {
|
|
1330
1707
|
version?: string;
|
|
@@ -1452,31 +1829,47 @@ export type VideoInfo = {
|
|
|
1452
1829
|
*/
|
|
1453
1830
|
path: string;
|
|
1454
1831
|
};
|
|
1832
|
+
export type VisibilityPreference = 'auto' | 'hidden';
|
|
1455
1833
|
export type WifiConnectedCallback = (info: WifiConnectedInfo) => void;
|
|
1456
1834
|
export type WifiConnectedInfo = WifiInfo & {
|
|
1457
1835
|
connected: boolean;
|
|
1458
1836
|
state: string;
|
|
1459
1837
|
};
|
|
1838
|
+
/**
|
|
1839
|
+
* Window decoration. `system` is the standard title bar. `full`
|
|
1840
|
+
* extends the page to the window edge while keeping the system
|
|
1841
|
+
* minimize, maximize, resize, and drag affordances — the runtime owns
|
|
1842
|
+
* a native drag strip across the top and publishes its height as
|
|
1843
|
+
* `topInset` on the page-chrome snapshot, so a page that does nothing
|
|
1844
|
+
* to opt in still cannot trap the user.
|
|
1845
|
+
*/
|
|
1846
|
+
export type WindowChrome = 'system' | 'full';
|
|
1460
1847
|
export type WindowSurfaceSize = {
|
|
1461
1848
|
/** Initial window width in logical pixels. */
|
|
1462
1849
|
width?: number;
|
|
1463
1850
|
/** Initial window height in logical pixels. */
|
|
1464
1851
|
height?: number;
|
|
1465
1852
|
};
|
|
1466
|
-
export type
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1853
|
+
export type WindowsTerminalApi = {
|
|
1854
|
+
status(): Promise<WindowsTerminalInlineImageStatus>;
|
|
1855
|
+
/** Verify and install the fixed Microsoft ConPTY package from lxapp temp storage. */
|
|
1856
|
+
install(options: {
|
|
1857
|
+
path: string;
|
|
1858
|
+
}): Promise<WindowsTerminalInlineImageStatus>;
|
|
1859
|
+
/** Select the installed runtime for new terminal sessions. */
|
|
1860
|
+
setEnabled(options: {
|
|
1861
|
+
enabled: boolean;
|
|
1862
|
+
}): Promise<WindowsTerminalInlineImageStatus>;
|
|
1863
|
+
};
|
|
1864
|
+
export type WindowsTerminalInlineImageStatus = {
|
|
1865
|
+
enabled: boolean;
|
|
1866
|
+
installed: boolean;
|
|
1867
|
+
package: {
|
|
1868
|
+
version: string;
|
|
1869
|
+
url: string;
|
|
1870
|
+
sha256: string;
|
|
1871
|
+
bytes: number;
|
|
1872
|
+
};
|
|
1480
1873
|
};
|
|
1481
1874
|
/** Host app base information. */
|
|
1482
1875
|
export interface AppBaseInfo {
|
|
@@ -1500,6 +1893,10 @@ export interface AppBaseInfo {
|
|
|
1500
1893
|
version: string;
|
|
1501
1894
|
SDKVersion: string;
|
|
1502
1895
|
}
|
|
1896
|
+
export interface AppearanceState {
|
|
1897
|
+
preference: AppearancePreference;
|
|
1898
|
+
resolved: ResolvedAppearance;
|
|
1899
|
+
}
|
|
1503
1900
|
/** Device info APIs. */
|
|
1504
1901
|
export interface DeviceInfo {
|
|
1505
1902
|
brand: string;
|
|
@@ -1546,43 +1943,11 @@ export interface LxAppInfo {
|
|
|
1546
1943
|
version: string;
|
|
1547
1944
|
releaseType: LxAppReleaseType;
|
|
1548
1945
|
}
|
|
1549
|
-
/** Options for removing TabBar badge */
|
|
1550
|
-
export interface RemoveTabBarBadgeOptions {
|
|
1551
|
-
index: number;
|
|
1552
|
-
}
|
|
1553
1946
|
export interface ScreenInfo {
|
|
1554
1947
|
width: number;
|
|
1555
1948
|
height: number;
|
|
1556
1949
|
scale: number;
|
|
1557
1950
|
}
|
|
1558
|
-
/** Options for setNavigationBarColor */
|
|
1559
|
-
export interface SetNavigationBarColorOptions {
|
|
1560
|
-
frontColor: string;
|
|
1561
|
-
backgroundColor: string;
|
|
1562
|
-
}
|
|
1563
|
-
/** Options for setNavigationBarTitle */
|
|
1564
|
-
export interface SetNavigationBarTitleOptions {
|
|
1565
|
-
title: string;
|
|
1566
|
-
}
|
|
1567
|
-
/** Options for setting TabBar badge */
|
|
1568
|
-
export interface SetTabBarBadgeOptions {
|
|
1569
|
-
index: number;
|
|
1570
|
-
text: string;
|
|
1571
|
-
}
|
|
1572
|
-
/** Options for setting TabBar item */
|
|
1573
|
-
export interface SetTabBarItemOptions {
|
|
1574
|
-
index: number;
|
|
1575
|
-
text?: string;
|
|
1576
|
-
iconPath?: string;
|
|
1577
|
-
selectedIconPath?: string;
|
|
1578
|
-
}
|
|
1579
|
-
/** Options for setting TabBar style */
|
|
1580
|
-
export interface SetTabBarStyleOptions {
|
|
1581
|
-
color?: string;
|
|
1582
|
-
selectedColor?: string;
|
|
1583
|
-
backgroundColor?: string;
|
|
1584
|
-
borderStyle?: string;
|
|
1585
|
-
}
|
|
1586
1951
|
/** System setting status */
|
|
1587
1952
|
export interface SystemSettingInfo {
|
|
1588
1953
|
bluetoothEnabled: boolean;
|
|
@@ -1609,18 +1974,6 @@ export declare class DirEntry {
|
|
|
1609
1974
|
readonly isDirectory: boolean;
|
|
1610
1975
|
readonly isSymlink: boolean;
|
|
1611
1976
|
}
|
|
1612
|
-
export declare class FileManager {
|
|
1613
|
-
private constructor();
|
|
1614
|
-
exists(options: ExistsOptions): Promise<boolean>;
|
|
1615
|
-
stat(options: StatOptions): Promise<FileStats>;
|
|
1616
|
-
readDir(options: ReadDirOptions): Promise<AsyncIterableIterator<DirEntry>>;
|
|
1617
|
-
mkdir(options: MkdirOptions): Promise<void>;
|
|
1618
|
-
readFile(options: never): Promise<never>;
|
|
1619
|
-
writeFile(options: WriteFileOptions): Promise<void>;
|
|
1620
|
-
copyFile(options: CopyFileOptions): Promise<void>;
|
|
1621
|
-
rename(options: RenameOptions): Promise<void>;
|
|
1622
|
-
remove(options: RemoveOptions): Promise<void>;
|
|
1623
|
-
}
|
|
1624
1977
|
export declare class JSMessagePort {
|
|
1625
1978
|
constructor();
|
|
1626
1979
|
static postMessage(payload: any): void;
|
|
@@ -1637,8 +1990,10 @@ export declare class JSUpdateManager {
|
|
|
1637
1990
|
constructor();
|
|
1638
1991
|
/** Apply update by restarting the app */
|
|
1639
1992
|
applyUpdate(): void;
|
|
1640
|
-
|
|
1641
|
-
|
|
1993
|
+
/** Subscribes to a ready update and returns the unsubscribe fn. */
|
|
1994
|
+
onUpdateReady(cb: (...args: any[]) => any): (...args: any[]) => any;
|
|
1995
|
+
/** Subscribes to a failed update and returns the unsubscribe fn. */
|
|
1996
|
+
onUpdateFailed(cb: (...args: any[]) => any): (...args: any[]) => any;
|
|
1642
1997
|
}
|
|
1643
1998
|
export declare class JSVideoContext {
|
|
1644
1999
|
constructor();
|
|
@@ -1650,6 +2005,64 @@ export declare class JSVideoContext {
|
|
|
1650
2005
|
exitFullScreen(): void;
|
|
1651
2006
|
setStreamSource(options: StreamSourceOptions): void;
|
|
1652
2007
|
}
|
|
2008
|
+
export declare class LxFile {
|
|
2009
|
+
private constructor();
|
|
2010
|
+
/** The path supplied to `lx.fs.file`. */
|
|
2011
|
+
readonly path: string;
|
|
2012
|
+
/** Read the complete file as strict UTF-8 text. */
|
|
2013
|
+
text(): Promise<string>;
|
|
2014
|
+
/**
|
|
2015
|
+
* Read and parse the complete file as JSON. Stays `unknown`: a class
|
|
2016
|
+
* method cannot carry a type parameter through the binding, so unlike
|
|
2017
|
+
* `lx.getStorage().get<T>()` the assertion is spelled `as` at the call
|
|
2018
|
+
* site rather than passed in.
|
|
2019
|
+
*/
|
|
2020
|
+
json(): Promise<unknown>;
|
|
2021
|
+
/** Read the complete file as a Base64 string. */
|
|
2022
|
+
base64(): Promise<string>;
|
|
2023
|
+
/** Read the complete file as bytes. */
|
|
2024
|
+
bytes(): Promise<Uint8Array>;
|
|
2025
|
+
/** Read the complete file as an ArrayBuffer. */
|
|
2026
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
2027
|
+
/** Test whether this managed path currently exists. */
|
|
2028
|
+
exists(): Promise<boolean>;
|
|
2029
|
+
/** Read metadata for this managed path. */
|
|
2030
|
+
stat(): Promise<FileStats>;
|
|
2031
|
+
}
|
|
2032
|
+
declare global {
|
|
2033
|
+
interface AppearanceApi {
|
|
2034
|
+
/** Read the appearance preference and the light/dark value it resolves to. */
|
|
2035
|
+
get(): AppearanceState;
|
|
2036
|
+
/** Set the appearance preference to `auto`, `light`, or `dark`. */
|
|
2037
|
+
set(preference: AppearancePreference): Promise<void>;
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
declare global {
|
|
2041
|
+
interface FileSystemApi {
|
|
2042
|
+
/**
|
|
2043
|
+
* Create a lazy reference to a LingXia-managed path.
|
|
2044
|
+
* Relative paths resolve under `lx.env.USER_DATA_PATH`. Creating a reference
|
|
2045
|
+
* does not require the path to exist.
|
|
2046
|
+
*/
|
|
2047
|
+
file(path: string): LxFile;
|
|
2048
|
+
/** Test whether a managed path currently exists. */
|
|
2049
|
+
exists(path: string): Promise<boolean>;
|
|
2050
|
+
/** Read metadata for a managed path. */
|
|
2051
|
+
stat(path: string): Promise<FileStats>;
|
|
2052
|
+
/** The direct children of a managed directory. */
|
|
2053
|
+
readDir(path: string): Promise<DirEntry[]>;
|
|
2054
|
+
/** Create a managed directory. */
|
|
2055
|
+
mkdir(path: string, options?: FsMkdirOptions): Promise<void>;
|
|
2056
|
+
/** Write UTF-8 text or bytes to a managed file. */
|
|
2057
|
+
write(path: string, data: string, options?: FsWriteOptions): Promise<void>;
|
|
2058
|
+
/** Copy a managed file. */
|
|
2059
|
+
copy(source: string, destination: string, options?: FsCopyOptions): Promise<void>;
|
|
2060
|
+
/** Rename or move a managed file or directory. */
|
|
2061
|
+
rename(source: string, destination: string, options?: FsRenameOptions): Promise<void>;
|
|
2062
|
+
/** Remove a managed file or directory. */
|
|
2063
|
+
remove(path: string, options?: FsRemoveOptions): Promise<void>;
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
1653
2066
|
declare global {
|
|
1654
2067
|
interface HostAppApi {
|
|
1655
2068
|
/**
|
|
@@ -1670,7 +2083,19 @@ declare global {
|
|
|
1670
2083
|
*/
|
|
1671
2084
|
checkUpdate(): Promise<HostAppUpdateCheckResult>;
|
|
1672
2085
|
readonly envVersion: HostAppEnvVersion;
|
|
2086
|
+
/**
|
|
2087
|
+
* Read the host app's identity: locale, display language, OS, product name,
|
|
2088
|
+
* product version, and SDK runtime version.
|
|
2089
|
+
*/
|
|
1673
2090
|
getBaseInfo(): AppBaseInfo;
|
|
2091
|
+
/**
|
|
2092
|
+
* Follow the host's effective display language.
|
|
2093
|
+
* `getBaseInfo().displayLanguage` answers what it is now; this answers when it
|
|
2094
|
+
* changes. Logic needs both because the strings it hands to native chrome —
|
|
2095
|
+
* navigation bar titles, tab bar labels, modal and action-sheet text — are the
|
|
2096
|
+
* app's own, and nothing re-renders them on its behalf.
|
|
2097
|
+
*/
|
|
2098
|
+
onDisplayLanguageChange(callback: (language: string) => void): () => void;
|
|
1674
2099
|
/**
|
|
1675
2100
|
* Exit the host app immediately without a confirmation dialog.
|
|
1676
2101
|
* If the user should confirm first, call `lx.showModal(...)` and invoke this
|
|
@@ -1689,14 +2114,31 @@ declare global {
|
|
|
1689
2114
|
declare global {
|
|
1690
2115
|
interface Lx {
|
|
1691
2116
|
readonly app: HostAppApi;
|
|
2117
|
+
/**
|
|
2118
|
+
* Whether this host exposes a capability to this Logic context, right now.
|
|
2119
|
+
* Synchronous, because it is meant to be called from render paths. The answer
|
|
2120
|
+
* is live and may be stale by the time you act on it — it is an affordance for
|
|
2121
|
+
* deciding what to render, not a replacement for handling a rejection.
|
|
2122
|
+
* `{ capability: 'surface', value: 'aside' }` in particular changes when a
|
|
2123
|
+
* desktop window crosses the compact breakpoint; pair it with
|
|
2124
|
+
* `lx.surface.onContext` instead of polling. The answer is per runtime context:
|
|
2125
|
+
* a context that does not expose an API reports false for it.
|
|
2126
|
+
*/
|
|
2127
|
+
supports(query: LxCapabilityQuery): boolean;
|
|
2128
|
+
/** Vibrate briefly, where the device has a vibrator. */
|
|
1692
2129
|
vibrateShort(): boolean;
|
|
2130
|
+
/** Vibrate for a longer pulse, where the device has a vibrator. */
|
|
1693
2131
|
vibrateLong(): boolean;
|
|
2132
|
+
/** Hand a number to the system dialer; the user still places the call. */
|
|
1694
2133
|
makePhoneCall(options: MakePhoneCallOptions): boolean;
|
|
2134
|
+
/** Read the device and OS facts this host reports. */
|
|
1695
2135
|
getDeviceInfo(): DeviceInfo;
|
|
2136
|
+
/** Read the screen geometry and pixel ratio this host reports. */
|
|
1696
2137
|
getScreenInfo(): ScreenInfo;
|
|
2138
|
+
/** Read connectivity right now: whether it is connected, its type, and addresses. */
|
|
1697
2139
|
getNetworkInfo(): Promise<NetworkInfo>;
|
|
1698
|
-
|
|
1699
|
-
|
|
2140
|
+
/** Subscribes to network changes and returns the unsubscribe fn. */
|
|
2141
|
+
onNetworkChange(callback: NetworkChangeCallback): () => void;
|
|
1700
2142
|
/** Initialize WiFi module */
|
|
1701
2143
|
startWifi(): Promise<void>;
|
|
1702
2144
|
/** Stop WiFi module */
|
|
@@ -1711,13 +2153,23 @@ declare global {
|
|
|
1711
2153
|
getWifiList(): Promise<WifiInfo[]>;
|
|
1712
2154
|
/** Get connected WiFi info */
|
|
1713
2155
|
getConnectedWifi(): Promise<WifiInfo>;
|
|
1714
|
-
|
|
1715
|
-
|
|
2156
|
+
/** Subscribes to WiFi connection events and returns the unsubscribe fn. */
|
|
2157
|
+
onWifiConnected(callback: WifiConnectedCallback): () => void;
|
|
2158
|
+
/**
|
|
2159
|
+
* Lock this lxapp to `portrait` or `landscape`.
|
|
2160
|
+
* Any other value rejects. Where the host does not report the change back,
|
|
2161
|
+
* the runtime emits the orientation event itself so JS state stays in sync.
|
|
2162
|
+
*/
|
|
1716
2163
|
setDeviceOrientation(orientation: DeviceOrientation): boolean;
|
|
1717
|
-
|
|
1718
|
-
|
|
2164
|
+
/** Subscribes to orientation changes and returns the unsubscribe fn. */
|
|
2165
|
+
onDeviceOrientationChange(callback: (event: DeviceOrientationChangeEvent) => void): () => void;
|
|
1719
2166
|
readonly env: LxEnv;
|
|
1720
2167
|
downloadFile(options: never): never;
|
|
2168
|
+
/**
|
|
2169
|
+
* Upload a managed file to an ordinary HTTP multipart endpoint.
|
|
2170
|
+
* Returns a task handle synchronously so progress and abort can be wired up
|
|
2171
|
+
* before the transfer starts.
|
|
2172
|
+
*/
|
|
1721
2173
|
uploadFile(options: UploadOptions): UploadTask;
|
|
1722
2174
|
/**
|
|
1723
2175
|
* Open a local file with the requested strategy.
|
|
@@ -1725,19 +2177,41 @@ declare global {
|
|
|
1725
2177
|
* `mode: "auto"`.
|
|
1726
2178
|
*/
|
|
1727
2179
|
openFile(options: OpenFileOptions): Promise<void>;
|
|
2180
|
+
/**
|
|
2181
|
+
* Opens a file picker.
|
|
2182
|
+
* Resolves `{ canceled: true }` only when the user dismisses the picker. A
|
|
2183
|
+
* completed selection resolves `{ canceled: false, paths }` with at least one
|
|
2184
|
+
* path. Rejects when the picker fails or returns an invalid payload.
|
|
2185
|
+
*/
|
|
1728
2186
|
chooseFile(options?: ChooseFileOptions): Promise<ChooseFileResult>;
|
|
2187
|
+
/**
|
|
2188
|
+
* Opens a directory picker.
|
|
2189
|
+
* Resolves `{ canceled: true }` only when the user dismisses the picker. A
|
|
2190
|
+
* completed selection resolves `{ canceled: false, path }`. Rejects when the
|
|
2191
|
+
* picker fails or returns an invalid payload.
|
|
2192
|
+
*/
|
|
1729
2193
|
chooseDirectory(options?: ChooseDirectoryOptions): Promise<ChooseDirectoryResult>;
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
2194
|
+
readonly fs: FileSystemApi;
|
|
2195
|
+
/** Subscribes to key-down events and returns the unsubscribe fn. */
|
|
2196
|
+
onKeyDown(callback: KeyEventCallback): () => void;
|
|
2197
|
+
/** Subscribes to key-up events and returns the unsubscribe fn. */
|
|
2198
|
+
onKeyUp(callback: KeyEventCallback): () => void;
|
|
1735
2199
|
/** Get location function */
|
|
1736
2200
|
getLocation(options?: GetLocationOptions): Promise<LocationInfo>;
|
|
2201
|
+
/** Identify the running lxapp: its id, display name, version, and release type. */
|
|
1737
2202
|
getLxAppInfo(): LxAppInfo;
|
|
2203
|
+
/** Read an image's dimensions, type, and orientation without decoding it into a view. */
|
|
1738
2204
|
getImageInfo(options: GetImageInfoOptions): Promise<ImageInfo>;
|
|
2205
|
+
/** Re-encode an image at a lower quality or size, writing a new managed file. */
|
|
1739
2206
|
compressImage(options: CompressImageOptions): Promise<CompressImageResult>;
|
|
1740
|
-
|
|
2207
|
+
/**
|
|
2208
|
+
* Opens the media picker or camera.
|
|
2209
|
+
* Resolves `{ canceled: true }` only when the user dismisses the picker. A
|
|
2210
|
+
* completed selection resolves `{ canceled: false, entries }` with at least one
|
|
2211
|
+
* entry. Rejects when capture or selection fails, or the host returns an invalid
|
|
2212
|
+
* payload.
|
|
2213
|
+
*/
|
|
2214
|
+
chooseMedia(options?: ChooseMediaOptions): Promise<ChooseMediaResult>;
|
|
1741
2215
|
/**
|
|
1742
2216
|
* Synchronously returns a JS handle so listeners can be attached before the
|
|
1743
2217
|
* first event fires:
|
|
@@ -1756,9 +2230,18 @@ declare global {
|
|
|
1756
2230
|
* caller never re-indexes their own array.
|
|
1757
2231
|
*/
|
|
1758
2232
|
previewMedia(options: PreviewMediaOptions): PreviewMediaHandle;
|
|
2233
|
+
/** Save an image into the system photo library. */
|
|
1759
2234
|
saveImageToPhotosAlbum(options: SaveMediaOptions): Promise<void>;
|
|
2235
|
+
/** Save a video into the system photo library. */
|
|
1760
2236
|
saveVideoToPhotosAlbum(options: SaveMediaOptions): Promise<void>;
|
|
2237
|
+
/**
|
|
2238
|
+
* Opens the scanner.
|
|
2239
|
+
* Resolves `{ canceled: true }` only when the user dismisses the scanner. A
|
|
2240
|
+
* completed scan resolves `{ canceled: false, scanResult, scanType }`. Rejects
|
|
2241
|
+
* when scanning fails or the host returns an invalid payload.
|
|
2242
|
+
*/
|
|
1761
2243
|
scanCode(options?: ScanCodeOptions): Promise<ScanCodeResult>;
|
|
2244
|
+
/** Take a control handle for the `<lx-video>` component with this id. */
|
|
1762
2245
|
createVideoContext(componentId: string): VideoContext;
|
|
1763
2246
|
/**
|
|
1764
2247
|
* Reads local video metadata for upload preflight and presentation.
|
|
@@ -1768,47 +2251,63 @@ declare global {
|
|
|
1768
2251
|
* still validate the uploaded bytes.
|
|
1769
2252
|
*/
|
|
1770
2253
|
getVideoInfo(options: GetVideoInfoOptions): Promise<VideoInfo>;
|
|
2254
|
+
/** Write one frame of a video out as an image file. */
|
|
1771
2255
|
extractVideoThumbnail(options: ExtractVideoThumbnailOptions): Promise<ExtractVideoThumbnailResult>;
|
|
2256
|
+
/**
|
|
2257
|
+
* Transcode a video to a smaller file.
|
|
2258
|
+
* Returns a task handle synchronously, so progress and cancellation can be
|
|
2259
|
+
* wired up before transcoding starts.
|
|
2260
|
+
*/
|
|
1772
2261
|
compressVideo(options: CompressVideoOptions): CompressVideoTask;
|
|
1773
|
-
|
|
1774
|
-
|
|
2262
|
+
/**
|
|
2263
|
+
* Open another lxapp, optionally at one of its pages.
|
|
2264
|
+
* Navigating to the lxapp already running is a no-op. Rejects with
|
|
2265
|
+
* `E_SURFACE_CONFLICT` when the target is currently docked as an aside —
|
|
2266
|
+
* close that aside before opening it as a main.
|
|
2267
|
+
*/
|
|
2268
|
+
navigateToApp(options: NavigateToAppOptions): Promise<void>;
|
|
2269
|
+
/** Leave this lxapp and reveal the one that opened it. */
|
|
2270
|
+
navigateBackApp(): Promise<void>;
|
|
2271
|
+
/**
|
|
2272
|
+
* Hand content to the system share sheet.
|
|
2273
|
+
* Share text, files, or a page link — files cannot be combined with a page
|
|
2274
|
+
* target or with text; share those separately.
|
|
2275
|
+
*/
|
|
1775
2276
|
share(options: ShareOptions): Promise<ShareResult>;
|
|
1776
|
-
getStorage(): Storage;
|
|
1777
2277
|
/**
|
|
1778
|
-
*
|
|
1779
|
-
*
|
|
1780
|
-
*
|
|
1781
|
-
* pages as a `float` (overlay popup) or a `window` (bare standalone desktop
|
|
1782
|
-
* window). Pages cannot be docked as an `aside` — an aside shows external
|
|
1783
|
-
* content only.
|
|
1784
|
-
* - `{ surface, edge?, query? }` shows a host-declared surface by its `ui` id.
|
|
1785
|
-
* - `{ url }` opens an authorized HTTPS/file URL in the in-app chromed browser.
|
|
2278
|
+
* Open this lxapp's asynchronous persistent key-value store. `get` asserts the
|
|
2279
|
+
* value shape at the call site and resolves `undefined` for a missing key. Use
|
|
2280
|
+
* `lx.fs` instead for path-based data.
|
|
1786
2281
|
*/
|
|
1787
|
-
|
|
2282
|
+
getStorage(): Storage;
|
|
1788
2283
|
/** `lx.openExternal(url)` — hand the url off to the OS default browser. */
|
|
1789
2284
|
openExternal(url: string): void;
|
|
2285
|
+
readonly surface: SurfaceApi;
|
|
2286
|
+
/** Read system switches the lxapp may branch on, such as location and WiFi. */
|
|
2287
|
+
getSystemSetting(): SystemSettingInfo;
|
|
1790
2288
|
/**
|
|
1791
|
-
*
|
|
1792
|
-
*
|
|
1793
|
-
*
|
|
2289
|
+
* Shows a list of actions.
|
|
2290
|
+
* Resolves `{ canceled: false, index }` when the user selects an item; `index`
|
|
2291
|
+
* points into `options.itemList`. Resolves `{ canceled: true }` only when the
|
|
2292
|
+
* user dismisses the sheet. Rejects when presentation fails or the host returns
|
|
2293
|
+
* an invalid selection.
|
|
1794
2294
|
*/
|
|
1795
|
-
onSurfaceContext(handler: (context: SurfaceContext) => void): () => void;
|
|
1796
|
-
getSystemSetting(): SystemSettingInfo;
|
|
1797
|
-
/** Show action sheet function for JavaScript */
|
|
1798
2295
|
showActionSheet(options: ShowActionSheetOptions): Promise<ActionSheetResult>;
|
|
2296
|
+
readonly appearance: AppearanceApi;
|
|
1799
2297
|
/**
|
|
1800
|
-
*
|
|
1801
|
-
*
|
|
2298
|
+
* Shows a confirmation modal.
|
|
2299
|
+
* Resolves `{ canceled: false }` when the user confirms and `{ canceled: true }`
|
|
2300
|
+
* only when the user dismisses or cancels the modal. Rejects when presentation
|
|
2301
|
+
* fails or the host returns an invalid payload.
|
|
1802
2302
|
*/
|
|
1803
|
-
getCapsuleRect(): Promise<CapsuleRect>;
|
|
1804
|
-
/** Show modal function (async) */
|
|
1805
2303
|
showModal(options: ShowModalOptions): Promise<ModalResult>;
|
|
1806
|
-
/**
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
2304
|
+
/**
|
|
2305
|
+
* Replace the current lxapp's complete app-declared More action list (seven
|
|
2306
|
+
* entries maximum). Pass an empty array to clear it. Native hosts append these
|
|
2307
|
+
* entries after their own lifecycle actions.
|
|
2308
|
+
*/
|
|
2309
|
+
setMoreActions(items: MoreAction[]): void;
|
|
2310
|
+
readonly navigationBar: NavigationBarApi;
|
|
1812
2311
|
/**
|
|
1813
2312
|
* lx.startPullDownRefresh()
|
|
1814
2313
|
* Programmatically start the pull-to-refresh animation.
|
|
@@ -1821,38 +2320,47 @@ declare global {
|
|
|
1821
2320
|
* This should be called after the refresh operation is complete.
|
|
1822
2321
|
*/
|
|
1823
2322
|
stopPullDownRefresh(): void;
|
|
1824
|
-
/**
|
|
2323
|
+
/**
|
|
2324
|
+
* Push a configured page onto the stack.
|
|
2325
|
+
* A route can appear on the stack only once. The promise rejects with
|
|
2326
|
+
* `data.reason === "duplicate_route"` when the target is already present,
|
|
2327
|
+
* or `data.reason === "stack_full"` when the ten-page limit is reached.
|
|
2328
|
+
*/
|
|
1825
2329
|
navigateTo(options: NavigateToOptions): Promise<PageMessagePort>;
|
|
1826
|
-
/**
|
|
1827
|
-
|
|
1828
|
-
|
|
2330
|
+
/**
|
|
2331
|
+
* Pop one or more pages and reveal the destination page.
|
|
2332
|
+
* `options` and `options.delta` are optional; both default to one page. The
|
|
2333
|
+
* promise resolves once the destination WebView is ready, so callers can
|
|
2334
|
+
* safely continue with work that targets the revealed page.
|
|
2335
|
+
*/
|
|
2336
|
+
navigateBack(options?: NavigateBackOptions): Promise<void>;
|
|
2337
|
+
/**
|
|
2338
|
+
* Replace the current stack entry with a configured page.
|
|
2339
|
+
* Redirecting to the current route keeps its page instance and runs `onLoad`
|
|
2340
|
+
* again with the new query. Redirecting to a route lower in the stack rejects
|
|
2341
|
+
* with `data.reason === "duplicate_route"`.
|
|
2342
|
+
*/
|
|
1829
2343
|
redirectTo(options: RedirectToOptions): Promise<void>;
|
|
1830
|
-
/**
|
|
2344
|
+
/**
|
|
2345
|
+
* Switch to a configured tab page.
|
|
2346
|
+
* The tab page being left is hidden and retained. Non-tab pages pushed above
|
|
2347
|
+
* a tab leave the stack and receive `onUnload`.
|
|
2348
|
+
*/
|
|
1831
2349
|
switchTab(options: SwitchTabOptions): Promise<void>;
|
|
1832
|
-
/**
|
|
2350
|
+
/** Clear the page stack and launch a configured page as the new root. */
|
|
1833
2351
|
reLaunch(options: ReLaunchOptions): Promise<void>;
|
|
1834
2352
|
readonly shell: ShellApi;
|
|
1835
|
-
|
|
1836
|
-
showTabBarRedDot(options: TabBarRedDotOptions): boolean;
|
|
1837
|
-
/** Hide TabBar red dot */
|
|
1838
|
-
hideTabBarRedDot(options: TabBarRedDotOptions): boolean;
|
|
1839
|
-
/** Set TabBar badge */
|
|
1840
|
-
setTabBarBadge(options: SetTabBarBadgeOptions): boolean;
|
|
1841
|
-
/** Remove TabBar badge */
|
|
1842
|
-
removeTabBarBadge(options: RemoveTabBarBadgeOptions): boolean;
|
|
1843
|
-
/** Show TabBar */
|
|
1844
|
-
showTabBar(): Promise<boolean>;
|
|
1845
|
-
/** Hide TabBar */
|
|
1846
|
-
hideTabBar(): Promise<boolean>;
|
|
1847
|
-
/** Set TabBar style */
|
|
1848
|
-
setTabBarStyle(options: SetTabBarStyleOptions): boolean;
|
|
1849
|
-
/** Set TabBar item */
|
|
1850
|
-
setTabBarItem(options: SetTabBarItemOptions): boolean;
|
|
2353
|
+
readonly tabBar: TabBarApi;
|
|
1851
2354
|
/** Show toast function */
|
|
1852
2355
|
showToast(options: ShowToastOptions): Promise<void>;
|
|
1853
2356
|
/** Hide toast function */
|
|
1854
2357
|
hideToast(): Promise<void>;
|
|
1855
2358
|
readonly tray: TrayApi;
|
|
2359
|
+
/**
|
|
2360
|
+
* Return the callback-based update manager for this lxapp's bundle. This is
|
|
2361
|
+
* available to every lxapp and is distinct from the home-only
|
|
2362
|
+
* `lx.app.checkUpdate()`, which updates the native host app.
|
|
2363
|
+
*/
|
|
1856
2364
|
getUpdateManager(): UpdateManager;
|
|
1857
2365
|
}
|
|
1858
2366
|
}
|
|
@@ -1863,21 +2371,106 @@ declare global {
|
|
|
1863
2371
|
}
|
|
1864
2372
|
}
|
|
1865
2373
|
declare global {
|
|
1866
|
-
interface
|
|
2374
|
+
interface NavigationBarApi {
|
|
2375
|
+
/** Patch the navigation bar of the active page; unset fields stay as they are. */
|
|
2376
|
+
update(patch: NavigationBarPatch): Promise<void>;
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
declare global {
|
|
2380
|
+
interface ShellApi {
|
|
2381
|
+
/**
|
|
2382
|
+
* `lx.shell.openApp(appId, options)` — compose another lxapp into a shell
|
|
2383
|
+
* slot. Home-lxapp only; the namespace is the privilege.
|
|
2384
|
+
*/
|
|
2385
|
+
openApp(appId: string, options: ShellOpenAppOptions): Promise<AppSurface>;
|
|
2386
|
+
/** `lx.shell.openBuiltin(page)` — a host builtin page. Home-lxapp only. */
|
|
2387
|
+
openBuiltin(page: BuiltinShellPage): Promise<BuiltinSurface>;
|
|
2388
|
+
/**
|
|
2389
|
+
* `lx.shell.openDeclared(id, options?)` — the declared surface, plus the
|
|
2390
|
+
* keyed multi-instance form and placement overrides. Home-lxapp only.
|
|
2391
|
+
*/
|
|
2392
|
+
openDeclared(id: string, options?: ShellOpenDeclaredOptions): Promise<DeclaredSurface>;
|
|
2393
|
+
/** `lx.shell.reconfigure(id, patch)` — re-place a live declared surface. */
|
|
2394
|
+
reconfigure(id: string, patch: ShellSurfacePatch): Promise<void>;
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
declare global {
|
|
2398
|
+
interface ShellSidebarActionsApi {
|
|
1867
2399
|
/**
|
|
1868
|
-
* Atomically replaces the complete desktop
|
|
1869
|
-
*
|
|
1870
|
-
*
|
|
2400
|
+
* Atomically replaces the complete desktop sidebar action declaration. Only the
|
|
2401
|
+
* home lxapp may call this API. Ids must be non-empty and unique across both
|
|
2402
|
+
* placements; header accepts at most two entries. Icons must be bundled relative
|
|
2403
|
+
* paths or runtime-managed `lx://` paths accessible to the home lxapp.
|
|
2404
|
+
* Every entry is bound to its generation-scoped callback. The shell invokes that
|
|
2405
|
+
* callback but never infers navigation or selected state. Validation or host
|
|
2406
|
+
* projection failure leaves the previous generation active. `replace([])` clears
|
|
2407
|
+
* the chrome explicitly. Declarations are process-local, so call `replace` again
|
|
2408
|
+
* on every Logic launch.
|
|
2409
|
+
*/
|
|
2410
|
+
replace(items: ShellSidebarAction[]): void;
|
|
2411
|
+
/**
|
|
2412
|
+
* Atomically updates the icon, label, and/or disabled state of one stable id.
|
|
2413
|
+
* Only the home lxapp may call this API. The patch must be non-empty; unknown
|
|
2414
|
+
* fields are rejected. The callback and placement stay unchanged. Throws
|
|
2415
|
+
* `E_NOT_FOUND` when `id` is not in the current declaration.
|
|
2416
|
+
*/
|
|
2417
|
+
update(id: string, patch: ShellSidebarActionUpdate): void;
|
|
2418
|
+
/**
|
|
2419
|
+
* Atomically removes one stable id and its generation-scoped callback. Only the
|
|
2420
|
+
* home lxapp may call this API. Throws `E_NOT_FOUND` when `id` is not in the
|
|
2421
|
+
* current declaration.
|
|
1871
2422
|
*/
|
|
1872
|
-
replace(items: ShellActivator[]): void;
|
|
1873
|
-
/** Updates presentation fields for one stable id. Home lxapp only. */
|
|
1874
|
-
update(id: string, patch: ShellActivatorUpdate): void;
|
|
1875
|
-
/** Removes one stable id from the declaration. Home lxapp only. */
|
|
1876
2423
|
remove(id: string): void;
|
|
1877
|
-
/**
|
|
2424
|
+
/**
|
|
2425
|
+
* Atomically clears every runtime sidebar action and callback. Only the home
|
|
2426
|
+
* lxapp may call this API. Equivalent to `replace([])` and safe when already
|
|
2427
|
+
* empty; the home lxapp must still redeclare actions after the next Logic launch.
|
|
2428
|
+
*/
|
|
1878
2429
|
clear(): void;
|
|
1879
2430
|
}
|
|
1880
2431
|
}
|
|
2432
|
+
declare global {
|
|
2433
|
+
interface SurfaceApi {
|
|
2434
|
+
/**
|
|
2435
|
+
* `lx.surface.openPage(page, options?)` — one of this lxapp's own pages as a
|
|
2436
|
+
* float or a window. A page can never be an aside: asides carry external
|
|
2437
|
+
* content only, which is why that member does not exist on this signature.
|
|
2438
|
+
*/
|
|
2439
|
+
openPage(page: string, options?: OpenPageOptions): Promise<PageSurface>;
|
|
2440
|
+
/**
|
|
2441
|
+
* `lx.surface.openUrl(url, options?)` — external content in the in-app
|
|
2442
|
+
* browser, as a tab or docked as an aside.
|
|
2443
|
+
*/
|
|
2444
|
+
openUrl(url: string, options?: OpenUrlOptions): Promise<TabSurface>;
|
|
2445
|
+
/**
|
|
2446
|
+
* `lx.surface.openDeclared(id, options?)` — a surface the host declared in
|
|
2447
|
+
* `lingxia.yaml`, opened with the declaration's own presentation.
|
|
2448
|
+
*/
|
|
2449
|
+
openDeclared(id: string): Promise<DeclaredSurface>;
|
|
2450
|
+
/**
|
|
2451
|
+
* `lx.surface.get(keyOrId)` — the live handle for a surface this lxapp opened
|
|
2452
|
+
* **with a `key`**, so no caller has to cache one in order to reuse or close
|
|
2453
|
+
* it. An unkeyed surface is not addressable: nothing registers it, because
|
|
2454
|
+
* holding one for the session costs its closures and its message port and
|
|
2455
|
+
* nobody can look up a uuid they never chose.
|
|
2456
|
+
* A `key` you chose wins over a runtime-assigned `id`, so a key that happens
|
|
2457
|
+
* to spell another surface's id still finds yours.
|
|
2458
|
+
*/
|
|
2459
|
+
get(keyOrId: string): AnySurface | undefined;
|
|
2460
|
+
/**
|
|
2461
|
+
* `lx.surface.onContext(handler)` — register a JS callback (scoped to this
|
|
2462
|
+
* lxapp's JS context), invoke it immediately, then again whenever that
|
|
2463
|
+
* presentation's actual viewport changes. Returns an unsubscribe fn.
|
|
2464
|
+
*/
|
|
2465
|
+
onContext(handler: (context: SurfaceContext) => void): () => void;
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2468
|
+
declare global {
|
|
2469
|
+
interface TabBarApi {
|
|
2470
|
+
/** Patch this lxapp's tab bar; unset fields stay as they are. */
|
|
2471
|
+
update(patch: TabBarPatch): Promise<void>;
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
1881
2474
|
declare global {
|
|
1882
2475
|
interface TrayApi {
|
|
1883
2476
|
/** lx.tray.setBadge(value) — the menu-bar / system-tray badge. Null/empty clears it. */
|