@lingxia/types 0.14.0 → 0.16.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 +26 -1
- package/dist/automation/index.d.ts.map +1 -1
- package/dist/error.d.ts +32 -3
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +33 -3
- package/dist/error.js.map +1 -1
- package/dist/esm/automation/index.js +12 -0
- package/dist/esm/automation/index.js.map +1 -0
- package/dist/esm/error.js +148 -0
- package/dist/esm/error.js.map +1 -0
- package/dist/esm/generated/error.js +44 -0
- package/dist/esm/generated/error.js.map +1 -0
- package/dist/esm/generated/i18n.js +167 -0
- package/dist/esm/generated/i18n.js.map +1 -0
- package/dist/esm/generated/logic.js +4 -0
- package/dist/esm/generated/logic.js.map +1 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +4 -0
- package/dist/esm/process.js +9 -0
- package/dist/esm/process.js.map +1 -0
- package/dist/{testing/public-api.mjs → esm/testing/public-api.js} +79 -19
- package/dist/esm/testing/public-api.js.map +1 -0
- package/dist/generated/error.d.ts +5 -1
- package/dist/generated/error.d.ts.map +1 -1
- package/dist/generated/error.js +1 -0
- package/dist/generated/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 +4 -0
- package/dist/generated/i18n.js.map +1 -1
- package/dist/generated/logic-web.d.ts +124 -0
- package/dist/generated/logic.d.ts +338 -136
- package/dist/generated/logic.d.ts.map +1 -1
- package/dist/index.d.ts +20 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -6
- package/dist/index.js.map +1 -1
- package/dist/process.d.ts +2 -2
- package/dist/process.js +2 -2
- package/dist/testing/public-api.d.ts +66 -15
- package/dist/testing/public-api.d.ts.map +1 -1
- package/dist/testing/public-api.js +78 -19
- package/dist/testing/public-api.js.map +1 -1
- package/package.json +9 -93
- package/src/automation/index.ts +28 -1
- package/src/error.ts +43 -3
- package/src/generated/error.ts +2 -1
- package/src/generated/i18n.ts +4 -0
- package/src/generated/logic-web.d.ts +124 -0
- package/src/generated/logic.ts +367 -144
- package/src/index.ts +32 -11
- package/src/process.ts +2 -2
- package/src/testing/public-api.ts +90 -19
package/src/generated/logic.ts
CHANGED
|
@@ -14,9 +14,61 @@ export interface PageConfig<TData extends Record<string, unknown> = Record<strin
|
|
|
14
14
|
onHide?: () => void | Promise<void>;
|
|
15
15
|
onUnload?: () => void | Promise<void>;
|
|
16
16
|
onPullDownRefresh?: () => void | Promise<void>;
|
|
17
|
-
[key: string]: unknown;
|
|
18
17
|
}
|
|
19
18
|
|
|
19
|
+
/** Lifecycle hook names a `Page({...})` config may declare. */
|
|
20
|
+
export type PageLifecycleName = Exclude<keyof PageConfig, 'data'>;
|
|
21
|
+
|
|
22
|
+
/** Lifecycle hook names an `App({...})` config may declare. */
|
|
23
|
+
export type AppLifecycleName = Exclude<keyof AppConfig, 'globalData'>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* What a key that differs from a lifecycle hook only in case resolves to, so
|
|
27
|
+
* the compiler names the mistake instead of silently accepting a new method.
|
|
28
|
+
*/
|
|
29
|
+
export type MisspelledLifecycle<K extends string> = {
|
|
30
|
+
'LingXia type error': `'${K}' differs only in case from a lifecycle hook`;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Applied to the custom half of a `Page`/`App` config. `onload` and `onShow`
|
|
35
|
+
* are one keystroke apart from real hooks and the runtime would simply never
|
|
36
|
+
* call the misspelling, so the closest case-insensitive match is rejected.
|
|
37
|
+
* Genuinely different names stay ordinary methods.
|
|
38
|
+
*/
|
|
39
|
+
export type NoLifecycleTypos<TCustom, TNames extends string> = {
|
|
40
|
+
[K in keyof TCustom]: K extends TNames
|
|
41
|
+
? TCustom[K]
|
|
42
|
+
: Lowercase<K & string> extends Lowercase<TNames>
|
|
43
|
+
? MisspelledLifecycle<K & string>
|
|
44
|
+
: TCustom[K];
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A `setData` key that addresses inside `data` — `'a.b'` or `'rows[0].name'`.
|
|
49
|
+
* Values behind a path stay `unknown`: the runtime resolves the path, so the
|
|
50
|
+
* type cannot.
|
|
51
|
+
*/
|
|
52
|
+
export type PageDataPath = `${string}.${string}` | `${string}[${number}]${string}`;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A field initialized to `null` or `[]` states nothing about what will fill it
|
|
56
|
+
* later, so it stays open. Annotate it (`null as Profile | null`) to have the
|
|
57
|
+
* fill checked.
|
|
58
|
+
*/
|
|
59
|
+
export type LazyInitField<T> = [T] extends [null | undefined]
|
|
60
|
+
? unknown
|
|
61
|
+
: [T] extends [never[]]
|
|
62
|
+
? unknown[]
|
|
63
|
+
: T;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Top-level keys are checked against `data`; only path-shaped keys stay open.
|
|
67
|
+
* A misspelled or wrongly typed top-level key is a compile error.
|
|
68
|
+
*/
|
|
69
|
+
export type SetDataPatch<TData> = { [K in keyof TData]?: LazyInitField<TData[K]> } &
|
|
70
|
+
Partial<Record<PageDataPath, unknown>>;
|
|
71
|
+
|
|
20
72
|
export interface PageInstance<TData extends Record<string, unknown> = Record<string, unknown>> {
|
|
21
73
|
data: TData;
|
|
22
74
|
route: string;
|
|
@@ -29,7 +81,7 @@ export interface PageInstance<TData extends Record<string, unknown> = Record<str
|
|
|
29
81
|
* Available when this page was opened by `lx.navigateTo(...)`.
|
|
30
82
|
*/
|
|
31
83
|
opener?: PageMessagePort;
|
|
32
|
-
setData(data:
|
|
84
|
+
setData(data: SetDataPatch<TData>, callback?: () => void): void;
|
|
33
85
|
}
|
|
34
86
|
|
|
35
87
|
/**
|
|
@@ -69,8 +121,8 @@ export interface ChannelHandle<TSend = unknown, TReceive = unknown> {
|
|
|
69
121
|
*
|
|
70
122
|
* - `app`: app-owned temporary output, or durable `lx://userdata` output when
|
|
71
123
|
* `filePath` is set
|
|
72
|
-
* - `downloads`: user-visible system Downloads output, requiring
|
|
73
|
-
*
|
|
124
|
+
* - `downloads`: user-visible system Downloads output, requiring a host
|
|
125
|
+
* privilege grant and a native Downloads grant
|
|
74
126
|
*
|
|
75
127
|
* Default: `app`.
|
|
76
128
|
*/
|
|
@@ -113,16 +165,26 @@ export interface DownloadTask<TDownloadResult extends DownloadResult = DownloadR
|
|
|
113
165
|
}
|
|
114
166
|
|
|
115
167
|
declare global {
|
|
168
|
+
/**
|
|
169
|
+
* The lxapp's configured page names, one key per page.
|
|
170
|
+
*
|
|
171
|
+
* Empty here on purpose. `lingxia dev` / `lingxia build` generates the
|
|
172
|
+
* project's own names into this interface; until then `ConfiguredPageName`
|
|
173
|
+
* stays `string` and every navigation call compiles exactly as before.
|
|
174
|
+
*/
|
|
175
|
+
interface LxAppPages {}
|
|
176
|
+
|
|
116
177
|
// HostAppApi/LxEnv members are emitted from the Rust js_api metadata; these
|
|
117
178
|
// merges only add what Rong cannot express — the cfg-gated autostart member
|
|
118
|
-
// and doc comments (js_api consts cannot carry docs).
|
|
179
|
+
// and doc comments (js_api consts cannot carry docs). env re-declares
|
|
119
180
|
// the generated member doc-only; tsc rejects the merge if the types drift.
|
|
120
181
|
interface HostAppApi {
|
|
121
182
|
/**
|
|
122
|
-
* The
|
|
123
|
-
* and defaults to `
|
|
183
|
+
* The host deployment environment from `app.json::env` (`dev` | `prod`).
|
|
184
|
+
* It is fixed at boot and defaults to `prod` for older artifacts.
|
|
185
|
+
* Not the lxapp publish channel (`release` | `preview` | `draft`).
|
|
124
186
|
*/
|
|
125
|
-
readonly
|
|
187
|
+
readonly env: HostAppEnv;
|
|
126
188
|
|
|
127
189
|
/**
|
|
128
190
|
* Launch-at-startup control. Absent where the host cannot register a
|
|
@@ -130,6 +192,28 @@ declare global {
|
|
|
130
192
|
* agree, so `lx.app.autostart?.…` and the query are interchangeable.
|
|
131
193
|
*/
|
|
132
194
|
autostart?: AutostartApi;
|
|
195
|
+
|
|
196
|
+
/** The language this lxapp renders in. Every lxapp follows it. */
|
|
197
|
+
readonly displayLanguage: DisplayLanguageApi;
|
|
198
|
+
|
|
199
|
+
/** The light/dark scheme this lxapp renders in. */
|
|
200
|
+
readonly appearance: AppearanceApi;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Product-wide settings, and their single writer. Present only in the
|
|
204
|
+
* Control app the host sealed at build time; its presence and
|
|
205
|
+
* `lx.supports({ capability: 'control' })` always agree, so
|
|
206
|
+
* `lx.app.control?.…` and the query are interchangeable.
|
|
207
|
+
*/
|
|
208
|
+
readonly control?: ControlApi;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Product-wide cache reporting and clearing for a settings screen.
|
|
212
|
+
* Present only in the Control app; its presence and
|
|
213
|
+
* `lx.supports({ capability: 'control' })` always agree, so
|
|
214
|
+
* `lx.app.cache?.…` and the query are interchangeable.
|
|
215
|
+
*/
|
|
216
|
+
cache?: AppCacheApi;
|
|
133
217
|
}
|
|
134
218
|
|
|
135
219
|
/** Runtime environment constants backed by abstract `lx://` paths. */
|
|
@@ -187,6 +271,7 @@ type StorageEntry<S extends object> = {
|
|
|
187
271
|
export type TypedStorage<S extends object> = {
|
|
188
272
|
get<K extends StorageKey<S>>(key: K): Promise<S[K] | undefined>;
|
|
189
273
|
set(...entry: StorageEntry<S>): Promise<void>;
|
|
274
|
+
has(key: StorageKey<S>): Promise<boolean>;
|
|
190
275
|
delete(key: StorageKey<S>): Promise<void>;
|
|
191
276
|
clear(): Promise<void>;
|
|
192
277
|
list(prefix?: string): Promise<string[]>;
|
|
@@ -206,13 +291,37 @@ export type ActionSheetResult = {
|
|
|
206
291
|
/** Every surface handle, narrowable by `kind`. */
|
|
207
292
|
export type AnySurface = PageSurface | DeclaredSurface | AppSurface | TabSurface | BuiltinSurface;
|
|
208
293
|
|
|
294
|
+
/**
|
|
295
|
+
* The product-wide cache a settings screen reports and clears.
|
|
296
|
+
* App-scoped, not lxapp-scoped: the figure covers every lxapp the host
|
|
297
|
+
* has run. Injected only into the Control app, same gate as
|
|
298
|
+
* `lx.app.control` — guests do not have the member.
|
|
299
|
+
*/
|
|
300
|
+
export type AppCacheApi = {
|
|
301
|
+
/** Estimated reclaimable managed bytes; excludes live session storage and WebView cache. */
|
|
302
|
+
size(): Promise<number>;
|
|
303
|
+
/**
|
|
304
|
+
* Clear reclaimable host caches. Control app only. Live session usercache and
|
|
305
|
+
* temp are preserved, including the caller's. Does not restart any lxapp.
|
|
306
|
+
* Userdata, KV, Downloads, cookies, valid installs and host components survive.
|
|
307
|
+
* Per-category failures are reported; setup/worker failures reject the call.
|
|
308
|
+
*/
|
|
309
|
+
clear(): Promise<{
|
|
310
|
+
/** Estimated file bytes successfully removed; excludes WebView cache. */
|
|
311
|
+
freedBytes: number;
|
|
312
|
+
/** Protected usercache/session paths skipped, not a count of apps. */
|
|
313
|
+
skippedActivePaths: number;
|
|
314
|
+
webview: 'cleared' | 'unsupported' | 'failed';
|
|
315
|
+
failures: string[];
|
|
316
|
+
}>;
|
|
317
|
+
};
|
|
318
|
+
|
|
209
319
|
export type AppConfig = {
|
|
210
320
|
globalData?: Record<string, unknown>;
|
|
211
321
|
onLaunch?: (options?: AppLaunchOptions) => void | Promise<void>;
|
|
212
322
|
onShow?: (args?: AppLifecycleEventArgs) => void | Promise<void>;
|
|
213
323
|
onHide?: (args?: AppLifecycleEventArgs) => void | Promise<void>;
|
|
214
324
|
onUserCaptureScreen?: () => void | Promise<void>;
|
|
215
|
-
[key: string]: unknown;
|
|
216
325
|
};
|
|
217
326
|
|
|
218
327
|
/** Runtime-managed app download path, usually under `lx://userdata`. */
|
|
@@ -263,16 +372,34 @@ export type AppInstance = AppConfig & {
|
|
|
263
372
|
export type AppLaunchOptions = {
|
|
264
373
|
path?: string;
|
|
265
374
|
query?: Record<string, string>;
|
|
266
|
-
|
|
375
|
+
/** `8003` = AppLink (cold: onLaunch; warm: onShow). */
|
|
376
|
+
scene?: AppLaunchScene;
|
|
377
|
+
/**
|
|
378
|
+
* Inbound link exactly as the OS delivered it, fragment included. Present
|
|
379
|
+
* only with `scene: 8003`. Untrusted: route from an allowlist of paths.
|
|
380
|
+
*/
|
|
381
|
+
url?: string;
|
|
267
382
|
referrerInfo?: {
|
|
268
383
|
appId?: string;
|
|
269
384
|
extraData?: Record<string, unknown>;
|
|
270
385
|
};
|
|
271
386
|
};
|
|
272
387
|
|
|
388
|
+
/**
|
|
389
|
+
* Launch scene. `8003` is AppLink (cold: `onLaunch`; warm: `onShow`).
|
|
390
|
+
* Other numeric scenes stay valid; completion offers `8003`.
|
|
391
|
+
*/
|
|
392
|
+
export type AppLaunchScene = 8003 | (number & {});
|
|
393
|
+
|
|
273
394
|
export type AppLifecycleEventArgs = {
|
|
274
395
|
source: 'host' | 'lxapp';
|
|
275
396
|
reason: 'foreground' | 'background' | 'screenshot' | 'open' | 'close' | 'switch_back' | 'switch_away';
|
|
397
|
+
path?: string;
|
|
398
|
+
query?: Record<string, string>;
|
|
399
|
+
/** `8003` = AppLink. */
|
|
400
|
+
scene?: AppLaunchScene;
|
|
401
|
+
/** Inbound link, present only with `scene: 8003`. */
|
|
402
|
+
url?: string;
|
|
276
403
|
};
|
|
277
404
|
|
|
278
405
|
export type AppScreenshotOptions = {
|
|
@@ -298,8 +425,26 @@ export type AppSurface = SurfaceBase & SurfaceShowable & {
|
|
|
298
425
|
readonly realized: 'main' | 'aside';
|
|
299
426
|
};
|
|
300
427
|
|
|
301
|
-
|
|
428
|
+
/** `lx.app.appearance` — the scheme this lxapp renders in. */
|
|
429
|
+
export type AppearanceApi = {
|
|
430
|
+
/**
|
|
431
|
+
* The scheme this lxapp is rendering in. An lxapp that pinned one in its
|
|
432
|
+
* `lxapp.json` reports that; every other lxapp reports the product's.
|
|
433
|
+
*/
|
|
434
|
+
get(): ResolvedAppearance;
|
|
435
|
+
/**
|
|
436
|
+
* Follow it, starting with the current value. Returns an unsubscribe.
|
|
437
|
+
*
|
|
438
|
+
* The first callback runs synchronously, before `watch` returns, so the
|
|
439
|
+
* unsubscribe is not yet bound inside it.
|
|
440
|
+
*/
|
|
441
|
+
watch(callback: (resolved: ResolvedAppearance) => void): () => void;
|
|
442
|
+
};
|
|
302
443
|
|
|
444
|
+
/**
|
|
445
|
+
* What the product's light/dark scheme is set to. `'auto'` follows
|
|
446
|
+
* the system.
|
|
447
|
+
*/
|
|
303
448
|
export type AppearancePreference = 'auto' | 'light' | 'dark';
|
|
304
449
|
|
|
305
450
|
/**
|
|
@@ -318,8 +463,8 @@ export type AppearancePreference = 'auto' | 'light' | 'dark';
|
|
|
318
463
|
* is called, so the decision stays with the user (typically a settings-page
|
|
319
464
|
* toggle, default off).
|
|
320
465
|
* Host-app-level capability: like `checkUpdate` and `screenshot`, the methods
|
|
321
|
-
* are available only to the
|
|
322
|
-
* error.
|
|
466
|
+
* are available only to the native-assigned Control app; other lxapps receive
|
|
467
|
+
* a permission error.
|
|
323
468
|
*/
|
|
324
469
|
export type AutostartApi = {
|
|
325
470
|
/**
|
|
@@ -342,12 +487,12 @@ export type BinaryFileData = ArrayBuffer | ArrayBufferView;
|
|
|
342
487
|
|
|
343
488
|
/**
|
|
344
489
|
* Built-in browser product page. Opening one requires
|
|
345
|
-
* `capabilities.browser` and is restricted to the
|
|
490
|
+
* `capabilities.browser` and is restricted to the native-assigned Control app.
|
|
346
491
|
*/
|
|
347
|
-
export type BuiltinShellPage = '
|
|
492
|
+
export type BuiltinShellPage = 'downloads';
|
|
348
493
|
|
|
349
494
|
/**
|
|
350
|
-
* A host builtin page such as
|
|
495
|
+
* A host builtin page such as downloads. The shell owns
|
|
351
496
|
* its lifetime and its visibility, so this handle reports identity:
|
|
352
497
|
* there is no `show` / `hide`, and the inherited `close()` rejects
|
|
353
498
|
* with `unsupported_placement`.
|
|
@@ -517,11 +662,73 @@ export type CompressVideoTask = PromiseLike<CompressVideoResult> & AsyncIterable
|
|
|
517
662
|
wait(): Promise<CompressVideoResult>;
|
|
518
663
|
};
|
|
519
664
|
|
|
665
|
+
/**
|
|
666
|
+
* Configured page name from `lxapp.json` / `lingxia.yaml`. JavaScript
|
|
667
|
+
* navigation accepts only this name; full routes such as
|
|
668
|
+
* `/pages/home/index` are internal runtime details. Discover names
|
|
669
|
+
* with `lxdev lxapp pages`.
|
|
670
|
+
* Narrows to the project's own names once `lingxia dev` or
|
|
671
|
+
* `lingxia build` has generated them; plain `string` before that, so
|
|
672
|
+
* a project that never ran a build still compiles.
|
|
673
|
+
*/
|
|
674
|
+
export type ConfiguredPageName = keyof LxAppPages extends never ? string : keyof LxAppPages;
|
|
675
|
+
|
|
520
676
|
export type ConnectWifiOptions = {
|
|
521
677
|
SSID: string;
|
|
522
678
|
password?: string;
|
|
523
679
|
};
|
|
524
680
|
|
|
681
|
+
/**
|
|
682
|
+
* `lx.app.control` — product-wide settings, and their single writer.
|
|
683
|
+
* Present only in the Control app. Bind it once rather than repeating
|
|
684
|
+
* `lx.app.control!`:
|
|
685
|
+
* ```js
|
|
686
|
+
* const control = lx.app.control;
|
|
687
|
+
* if (!control) return; // not the Control app
|
|
688
|
+
* await control.appearance.setPreference('dark');
|
|
689
|
+
* ```
|
|
690
|
+
*/
|
|
691
|
+
export type ControlApi = {
|
|
692
|
+
readonly displayLanguage: ControlDisplayLanguageApi;
|
|
693
|
+
readonly appearance: ControlAppearanceApi;
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
/** `lx.app.control.appearance` — the product's own light/dark setting. */
|
|
697
|
+
export type ControlAppearanceApi = {
|
|
698
|
+
/** What the user chose for the whole product. */
|
|
699
|
+
getPreference(): AppearancePreference;
|
|
700
|
+
/**
|
|
701
|
+
* Pin the product to `'light'` or `'dark'`, or follow the system with
|
|
702
|
+
* `'auto'`. An lxapp that pinned a scheme in its manifest keeps it.
|
|
703
|
+
*/
|
|
704
|
+
setPreference(preference: AppearancePreference): Promise<void>;
|
|
705
|
+
/**
|
|
706
|
+
* Follow the choice, not what it resolves to: a system flip under `'auto'`
|
|
707
|
+
* moves `lx.app.appearance.watch` and leaves this quiet. Starts with the
|
|
708
|
+
* current value; that first callback runs synchronously, before
|
|
709
|
+
* `watchPreference` returns.
|
|
710
|
+
*/
|
|
711
|
+
watchPreference(callback: (preference: AppearancePreference) => void): () => void;
|
|
712
|
+
};
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* `lx.app.control.displayLanguage` — the preference behind that
|
|
716
|
+
* language, for the one surface that edits it.
|
|
717
|
+
*/
|
|
718
|
+
export type ControlDisplayLanguageApi = {
|
|
719
|
+
/** What the user chose: `'auto'`, or a canonical BCP-47 tag. */
|
|
720
|
+
getPreference(): DisplayLanguagePreference;
|
|
721
|
+
/** Persist the product's language. Rejects a tag that is not valid BCP-47. */
|
|
722
|
+
setPreference(preference: DisplayLanguagePreference): Promise<void>;
|
|
723
|
+
/**
|
|
724
|
+
* Follow the choice, not what it resolves to: a system locale change under
|
|
725
|
+
* `'auto'` moves the language without moving the preference. Starts with
|
|
726
|
+
* the current value and returns an unsubscribe; that first callback runs
|
|
727
|
+
* synchronously, before `watchPreference` returns.
|
|
728
|
+
*/
|
|
729
|
+
watchPreference(callback: (preference: DisplayLanguagePreference) => void): () => void;
|
|
730
|
+
};
|
|
731
|
+
|
|
525
732
|
/** A surface declared by the host in `lingxia.yaml`. */
|
|
526
733
|
export type DeclaredSurface = SurfaceBase & SurfaceShowable & {
|
|
527
734
|
readonly kind: 'declared';
|
|
@@ -534,6 +741,35 @@ export type DeviceOrientationChangeEvent = {
|
|
|
534
741
|
value: DeviceOrientation;
|
|
535
742
|
};
|
|
536
743
|
|
|
744
|
+
/** `lx.app.displayLanguage` — the language this lxapp renders in. */
|
|
745
|
+
export type DisplayLanguageApi = {
|
|
746
|
+
/**
|
|
747
|
+
* The language in effect right now, as a canonical BCP-47 tag. Map it to
|
|
748
|
+
* the catalogs this lxapp actually ships and fall back where it has none;
|
|
749
|
+
* that narrowing is yours, and is not a language setting of its own.
|
|
750
|
+
*/
|
|
751
|
+
get(): string;
|
|
752
|
+
/**
|
|
753
|
+
* Follow the language, starting with the current value. Returns an
|
|
754
|
+
* unsubscribe.
|
|
755
|
+
*
|
|
756
|
+
* Logic needs this because the strings it hands to native chrome —
|
|
757
|
+
* navigation bar titles, tab bar labels, modal and action-sheet text — are
|
|
758
|
+
* the app's own, and nothing re-renders them on its behalf.
|
|
759
|
+
*
|
|
760
|
+
* The first callback runs synchronously, before `watch` returns, so the
|
|
761
|
+
* unsubscribe is not yet bound inside it.
|
|
762
|
+
*/
|
|
763
|
+
watch(callback: (language: string) => void): () => void;
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* What the product's language is set to: `'auto'` follows the system,
|
|
768
|
+
* or any canonical BCP-47 tag. `string & {}` keeps `'auto'` in
|
|
769
|
+
* autocomplete while still accepting a tag.
|
|
770
|
+
*/
|
|
771
|
+
export type DisplayLanguagePreference = 'auto' | (string & {});
|
|
772
|
+
|
|
537
773
|
export type DownloadDestination = 'app' | 'downloads';
|
|
538
774
|
|
|
539
775
|
export type DownloadOptionsBase = {
|
|
@@ -570,6 +806,13 @@ export type DownloadsDownloadResult = {
|
|
|
570
806
|
size: number;
|
|
571
807
|
};
|
|
572
808
|
|
|
809
|
+
/**
|
|
810
|
+
* Configured page name belonging to *another* lxapp. This app's own
|
|
811
|
+
* page union cannot check it, so it stays a plain string and the
|
|
812
|
+
* target runtime rejects a name it does not have.
|
|
813
|
+
*/
|
|
814
|
+
export type ExternalPageName = string;
|
|
815
|
+
|
|
573
816
|
export type ExtractVideoThumbnailOptions = {
|
|
574
817
|
/**
|
|
575
818
|
* Source video path or `lx://` URI.
|
|
@@ -679,15 +922,17 @@ export type GetVideoInfoOptions = {
|
|
|
679
922
|
export type HostAppApi = globalThis.HostAppApi;
|
|
680
923
|
|
|
681
924
|
/**
|
|
682
|
-
* Build-time environment
|
|
683
|
-
* Surfaced via {@link HostAppApi.
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
687
|
-
*
|
|
688
|
-
*
|
|
925
|
+
* Build-time deployment environment of the host app (`dev` | `prod`).
|
|
926
|
+
* Surfaced via {@link HostAppApi.env}. Taken from the `env` field in
|
|
927
|
+
* the generated `app.json`. Missing `env` is treated as `'prod'`.
|
|
928
|
+
* This is the host build axis: which server, package-id suffix, publish
|
|
929
|
+
* token, and self-update endpoint the host uses. It is **not** the
|
|
930
|
+
* lxapp publish channel (`LxAppEnvVersion` / `LxAppReleaseType`:
|
|
931
|
+
* `'release' | 'preview' | 'draft'`). Default channel is derived
|
|
932
|
+
* from env (`dev` → `draft`, `prod` → `release`) and can be
|
|
933
|
+
* overridden when opening an lxapp.
|
|
689
934
|
*/
|
|
690
|
-
export type
|
|
935
|
+
export type HostAppEnv = 'dev' | 'prod';
|
|
691
936
|
|
|
692
937
|
export type HostAppUpdateApplyStage = 'download' | 'install';
|
|
693
938
|
|
|
@@ -749,6 +994,12 @@ export type HostAppUpdateTask = PromiseLike<HostAppUpdateResult> & AsyncIterable
|
|
|
749
994
|
wait(): Promise<HostAppUpdateResult>;
|
|
750
995
|
};
|
|
751
996
|
|
|
997
|
+
/**
|
|
998
|
+
* Canonical platform-family label shared by `lx.app.getBaseInfo().os`
|
|
999
|
+
* and `lx.getDeviceInfo().osName`. `"unknown"` is a non-product build.
|
|
1000
|
+
*/
|
|
1001
|
+
export type HostOs = 'iOS' | 'macOS' | 'Android' | 'Windows' | 'Harmony' | 'unknown';
|
|
1002
|
+
|
|
752
1003
|
export type InstalledTerminalFont = {
|
|
753
1004
|
family: string;
|
|
754
1005
|
monospace: boolean;
|
|
@@ -774,13 +1025,13 @@ export type KeyEvent = {
|
|
|
774
1025
|
|
|
775
1026
|
export type KeyEventCallback = (event: KeyEvent) => void;
|
|
776
1027
|
|
|
777
|
-
export type LxAppEnvVersion = 'release' | 'preview' | '
|
|
1028
|
+
export type LxAppEnvVersion = 'release' | 'preview' | 'draft';
|
|
778
1029
|
|
|
779
1030
|
/** LxApp metadata APIs. */
|
|
780
|
-
export type LxAppReleaseType = 'release' | 'preview' | '
|
|
1031
|
+
export type LxAppReleaseType = 'release' | 'preview' | 'draft';
|
|
781
1032
|
|
|
782
1033
|
/** Boolean capability names accepted by `lx.supports`. */
|
|
783
|
-
export type LxCapabilityFlag = 'terminal' | 'autostart' | 'notifications' | 'browser' | 'proxy' | 'selfUpdate' | 'process' | 'appUse' | 'computerUse' | 'browserUse' | 'mediaCapture';
|
|
1034
|
+
export type LxCapabilityFlag = 'control' | 'terminal' | 'autostart' | 'notifications' | 'browser' | 'proxy' | 'selfUpdate' | 'process' | 'appUse' | 'computerUse' | 'browserUse' | 'mediaCapture';
|
|
784
1035
|
|
|
785
1036
|
/**
|
|
786
1037
|
* One capability question per call. The catalog is closed, so
|
|
@@ -863,9 +1114,13 @@ export type NavigateToAppOptions = {
|
|
|
863
1114
|
* open the target app's initial page. Full routes such as
|
|
864
1115
|
* `/pages/home/index` are not supported.
|
|
865
1116
|
*/
|
|
866
|
-
page?:
|
|
1117
|
+
page?: ExternalPageName;
|
|
867
1118
|
query?: PageQuery;
|
|
868
|
-
|
|
1119
|
+
/**
|
|
1120
|
+
* Lxapp publish channel. Defaults from the host env
|
|
1121
|
+
* (`dev` → `draft`, `prod` → `release`).
|
|
1122
|
+
*/
|
|
1123
|
+
channel?: LxAppEnvVersion;
|
|
869
1124
|
targetVersion?: string;
|
|
870
1125
|
};
|
|
871
1126
|
|
|
@@ -950,7 +1205,7 @@ export type OpenPageShared = {
|
|
|
950
1205
|
*/
|
|
951
1206
|
size?: OverlaySurfaceSize;
|
|
952
1207
|
interaction?: SurfaceInteraction;
|
|
953
|
-
query?:
|
|
1208
|
+
query?: PageQuery;
|
|
954
1209
|
/** Caller-owned identity, for `lx.surface.get(key)` later. */
|
|
955
1210
|
key?: string;
|
|
956
1211
|
};
|
|
@@ -1008,7 +1263,7 @@ export type PageSurface = SurfaceBase & SurfaceShowable & SurfaceMessaging & {
|
|
|
1008
1263
|
*/
|
|
1009
1264
|
export type PageTargetOptions = {
|
|
1010
1265
|
/** Configured page name from `lingxia.yaml` / `lxapp.json`. */
|
|
1011
|
-
page:
|
|
1266
|
+
page: ConfiguredPageName;
|
|
1012
1267
|
query?: PageQuery;
|
|
1013
1268
|
};
|
|
1014
1269
|
|
|
@@ -1146,7 +1401,11 @@ export type PreviewMediaSingleOptions = PreviewMediaSource & {
|
|
|
1146
1401
|
export type PreviewMediaSource = {
|
|
1147
1402
|
/**
|
|
1148
1403
|
* Media source path.
|
|
1149
|
-
*
|
|
1404
|
+
*
|
|
1405
|
+
* Accepts an `https://` (or `http://`) URL for a remote image or video —
|
|
1406
|
+
* the host loads it directly, so no prior `lx.downloadFile` is required,
|
|
1407
|
+
* and its domain must be permitted by the app's network policy — an
|
|
1408
|
+
* `lx://` path (for example `lx://usercache/...`), or a sandbox-local path
|
|
1150
1409
|
* that can be resolved by runtime access rules.
|
|
1151
1410
|
*/
|
|
1152
1411
|
path: string;
|
|
@@ -1286,8 +1545,8 @@ export type ShareTitleOptions = {
|
|
|
1286
1545
|
};
|
|
1287
1546
|
|
|
1288
1547
|
/**
|
|
1289
|
-
* App-owned host-shell chrome. Mutations are available only to the
|
|
1290
|
-
*
|
|
1548
|
+
* App-owned host-shell chrome. Mutations are available only to the
|
|
1549
|
+
* Control app's Logic context; other lxapps receive a permission error.
|
|
1291
1550
|
*/
|
|
1292
1551
|
export type ShellApi = {
|
|
1293
1552
|
/**
|
|
@@ -1298,7 +1557,7 @@ export type ShellApi = {
|
|
|
1298
1557
|
sidebarActions: ShellSidebarActionsApi;
|
|
1299
1558
|
/** Compose another lxapp into a shell slot. */
|
|
1300
1559
|
openApp(appId: string, options: ShellOpenAppOptions): Promise<AppSurface>;
|
|
1301
|
-
/** Open a host builtin page such as
|
|
1560
|
+
/** Open a host builtin page such as downloads. */
|
|
1302
1561
|
openBuiltin(page: BuiltinShellPage): Promise<BuiltinSurface>;
|
|
1303
1562
|
/**
|
|
1304
1563
|
* Open a declared surface with shell privileges — the same declaration
|
|
@@ -1319,17 +1578,20 @@ export type ShellOpenAppOptions = {
|
|
|
1319
1578
|
* Configured page name from the target lxapp's `lxapp.json`. Omit it to
|
|
1320
1579
|
* open that app's initial page. Full page routes are not supported.
|
|
1321
1580
|
*/
|
|
1322
|
-
page?:
|
|
1581
|
+
page?: ExternalPageName;
|
|
1323
1582
|
query?: PageQuery;
|
|
1324
|
-
/**
|
|
1325
|
-
|
|
1583
|
+
/**
|
|
1584
|
+
* Lxapp publish channel. Defaults from the host env
|
|
1585
|
+
* (`dev` → `draft`, `prod` → `release`).
|
|
1586
|
+
*/
|
|
1587
|
+
channel?: LxAppEnvVersion;
|
|
1326
1588
|
targetVersion?: string;
|
|
1327
1589
|
/** Stable identity for `lx.surface.get(key)`. */
|
|
1328
1590
|
key?: string;
|
|
1329
1591
|
};
|
|
1330
1592
|
|
|
1331
1593
|
/**
|
|
1332
|
-
* The declared-surface options only the
|
|
1594
|
+
* The declared-surface options only the native-assigned Control app may use.
|
|
1333
1595
|
* Creating an extra instance and overriding a placement both mutate
|
|
1334
1596
|
* shared shell composition, so they live here and not on
|
|
1335
1597
|
* `lx.surface.openDeclared` — which consumes a declaration exactly as
|
|
@@ -1373,8 +1635,13 @@ export type ShellSidebarAction = {
|
|
|
1373
1635
|
* `public/settings.svg`, or an `lx://temp`, `lx://usercache`, or
|
|
1374
1636
|
* `lx://userdata` path returned by LingXia file APIs. Native absolute paths,
|
|
1375
1637
|
* parent traversal, `file:` URLs, and network URLs are rejected; download a
|
|
1376
|
-
* remote icon before registration.
|
|
1377
|
-
*
|
|
1638
|
+
* remote icon before registration.
|
|
1639
|
+
*
|
|
1640
|
+
* SVG is a template glyph tinted by the host. Raster PNG/JPEG/WebP retains
|
|
1641
|
+
* its colour and is center-cropped to the square icon slot, which is suitable
|
|
1642
|
+
* for a brand logo; provide square artwork when the crop matters. A path in
|
|
1643
|
+
* `lx://temp` is temporary, so download and register it again after the next
|
|
1644
|
+
* Logic launch rather than persisting it.
|
|
1378
1645
|
*/
|
|
1379
1646
|
icon: string;
|
|
1380
1647
|
/**
|
|
@@ -1423,7 +1690,7 @@ export type ShellSidebarActionUpdate = {
|
|
|
1423
1690
|
};
|
|
1424
1691
|
|
|
1425
1692
|
/**
|
|
1426
|
-
* Role and edge overrides the
|
|
1693
|
+
* Role and edge overrides the native-assigned Control app may apply to a live declared
|
|
1427
1694
|
* surface. A stable root rejects non-main roles.
|
|
1428
1695
|
*/
|
|
1429
1696
|
export type ShellSurfacePatch = {
|
|
@@ -1471,6 +1738,12 @@ export type Storage = {
|
|
|
1471
1738
|
*/
|
|
1472
1739
|
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
1473
1740
|
set(key: string, value: unknown): Promise<void>;
|
|
1741
|
+
/**
|
|
1742
|
+
* Resolves whether an exact key exists, without reading its value. Prefer
|
|
1743
|
+
* it over comparing `get` against `undefined`: presence is a key lookup,
|
|
1744
|
+
* while `get` also reads and deserializes the stored value.
|
|
1745
|
+
*/
|
|
1746
|
+
has(key: string): Promise<boolean>;
|
|
1474
1747
|
delete(key: string): Promise<void>;
|
|
1475
1748
|
clear(): Promise<void>;
|
|
1476
1749
|
/** Resolves every key, optionally filtered by prefix. */
|
|
@@ -1498,7 +1771,7 @@ export type StreamSourceOptions = {
|
|
|
1498
1771
|
*/
|
|
1499
1772
|
export type SurfaceApi = {
|
|
1500
1773
|
/** Open one of this lxapp's own pages as a float or a window. */
|
|
1501
|
-
openPage(page:
|
|
1774
|
+
openPage(page: ConfiguredPageName, options?: OpenPageOptions): Promise<PageSurface>;
|
|
1502
1775
|
/** Open external content in the in-app browser. */
|
|
1503
1776
|
openUrl(url: string, options?: OpenUrlOptions): Promise<TabSurface>;
|
|
1504
1777
|
/**
|
|
@@ -1610,7 +1883,7 @@ export type SurfaceError = Error & {
|
|
|
1610
1883
|
*/
|
|
1611
1884
|
export type SurfaceErrorCode = /** The placement cannot be realized by this host build. */
|
|
1612
1885
|
'unsupported_placement'
|
|
1613
|
-
/** A privileged operation was called by an lxapp other than the
|
|
1886
|
+
/** A privileged operation was called by an lxapp other than the native-assigned Control app. */
|
|
1614
1887
|
| 'denied'
|
|
1615
1888
|
/** No such declared surface, lxapp, or builtin page. */
|
|
1616
1889
|
| 'not_declared'
|
|
@@ -1707,6 +1980,15 @@ export type TabBarApi = globalThis.TabBarApi;
|
|
|
1707
1980
|
export type TabBarItemPatch = {
|
|
1708
1981
|
index: number;
|
|
1709
1982
|
text?: string | null;
|
|
1983
|
+
/**
|
|
1984
|
+
* Package-relative path, or an `lx://temp` / `lx://usercache` /
|
|
1985
|
+
* `lx://userdata` path from a LingXia file API. Network URLs are rejected —
|
|
1986
|
+
* download first (`lx.downloadFile`) and pass the returned path.
|
|
1987
|
+
*
|
|
1988
|
+
* SVG (and SF Symbols) are template-tinted with `foregroundColor` /
|
|
1989
|
+
* `selectedForegroundColor`. Raster files (PNG/JPEG/WebP) keep their own
|
|
1990
|
+
* colour so a brand mark is not flattened into a solid square.
|
|
1991
|
+
*/
|
|
1710
1992
|
iconPath?: string | null;
|
|
1711
1993
|
badge?: string | null;
|
|
1712
1994
|
redDot?: boolean;
|
|
@@ -1844,8 +2126,7 @@ export type TerminalSettingsSnapshot = {
|
|
|
1844
2126
|
/** Resolved configuration after all valid layers. */
|
|
1845
2127
|
value: TerminalSettingsValue;
|
|
1846
2128
|
effective: {
|
|
1847
|
-
/**
|
|
1848
|
-
systemAppearance: 'light' | 'dark';
|
|
2129
|
+
/** The scheme the product is in, and therefore the terminal too. */
|
|
1849
2130
|
appearance: 'light' | 'dark';
|
|
1850
2131
|
colorScheme: string | null;
|
|
1851
2132
|
font: {
|
|
@@ -1867,10 +2148,11 @@ export type TerminalSettingsWarning = {
|
|
|
1867
2148
|
message: string;
|
|
1868
2149
|
};
|
|
1869
2150
|
|
|
1870
|
-
|
|
1871
|
-
|
|
2151
|
+
/**
|
|
2152
|
+
* A light scheme and a dark one. Which is in use follows the
|
|
2153
|
+
* product's light/dark setting; the terminal has no switch of its own.
|
|
2154
|
+
*/
|
|
1872
2155
|
export type TerminalThemeSettings = {
|
|
1873
|
-
mode: TerminalThemeMode;
|
|
1874
2156
|
light: string;
|
|
1875
2157
|
dark: string;
|
|
1876
2158
|
};
|
|
@@ -1904,7 +2186,7 @@ export type UpdateFailedInfo = UpdateReadyInfo & {
|
|
|
1904
2186
|
|
|
1905
2187
|
/**
|
|
1906
2188
|
* Callback-based updates for this lxapp's bundle. Available to every
|
|
1907
|
-
* lxapp. To update the native host app, the
|
|
2189
|
+
* lxapp. To update the native host app, the Control app uses the
|
|
1908
2190
|
* task-based `lx.app.checkUpdate()` API instead.
|
|
1909
2191
|
*/
|
|
1910
2192
|
export type UpdateManager = {
|
|
@@ -1918,7 +2200,7 @@ export type UpdateManager = {
|
|
|
1918
2200
|
export type UpdateReadyInfo = {
|
|
1919
2201
|
version?: string;
|
|
1920
2202
|
isForceUpdate?: boolean;
|
|
1921
|
-
channel?: "release" | "preview" | "
|
|
2203
|
+
channel?: "release" | "preview" | "draft" | string;
|
|
1922
2204
|
};
|
|
1923
2205
|
|
|
1924
2206
|
export type UploadIteratorResult = {
|
|
@@ -2151,40 +2433,28 @@ export type WindowsTerminalInlineImageStatus = {
|
|
|
2151
2433
|
};
|
|
2152
2434
|
};
|
|
2153
2435
|
|
|
2154
|
-
/**
|
|
2436
|
+
/**
|
|
2437
|
+
* Host app identity. Everything here is fixed for the life of the process;
|
|
2438
|
+
* the language the app renders in is not, and lives on
|
|
2439
|
+
* `lx.app.displayLanguage`.
|
|
2440
|
+
*/
|
|
2155
2441
|
export interface AppBaseInfo {
|
|
2156
|
-
/**
|
|
2157
|
-
* Raw system locale, unaffected by a saved in-app language override.
|
|
2158
|
-
* For the language the UI should actually render in, use
|
|
2159
|
-
* `display_language` instead.
|
|
2160
|
-
*/
|
|
2161
|
-
locale: string;
|
|
2162
|
-
/**
|
|
2163
|
-
* Effective display language: a saved user override when set, else
|
|
2164
|
-
* `locale`. This is what native chrome and `lx.*` i18n strings follow.
|
|
2165
|
-
*/
|
|
2166
|
-
displayLanguage: string;
|
|
2167
2442
|
/**
|
|
2168
2443
|
* Platform family: `"iOS"` / `"macOS"` / `"Android"` / `"Windows"` /
|
|
2169
2444
|
* `"Harmony"`. Matches the View-side `usePlatform().os` value.
|
|
2170
2445
|
*/
|
|
2171
|
-
os:
|
|
2446
|
+
os: HostOs;
|
|
2172
2447
|
productName: string;
|
|
2173
2448
|
version: string;
|
|
2174
2449
|
SDKVersion: string;
|
|
2175
2450
|
}
|
|
2176
2451
|
|
|
2177
|
-
export interface AppearanceState {
|
|
2178
|
-
preference: AppearancePreference;
|
|
2179
|
-
resolved: ResolvedAppearance;
|
|
2180
|
-
}
|
|
2181
|
-
|
|
2182
2452
|
/** Device info APIs. */
|
|
2183
2453
|
export interface DeviceInfo {
|
|
2184
2454
|
brand: string;
|
|
2185
2455
|
model: string;
|
|
2186
2456
|
marketName: string;
|
|
2187
|
-
osName:
|
|
2457
|
+
osName: HostOs;
|
|
2188
2458
|
osVersion: string;
|
|
2189
2459
|
}
|
|
2190
2460
|
|
|
@@ -2227,7 +2497,7 @@ export interface LxAppInfo {
|
|
|
2227
2497
|
appId: string;
|
|
2228
2498
|
appName: string;
|
|
2229
2499
|
version: string;
|
|
2230
|
-
|
|
2500
|
+
channel: LxAppReleaseType;
|
|
2231
2501
|
}
|
|
2232
2502
|
|
|
2233
2503
|
export interface ScreenInfo {
|
|
@@ -2265,41 +2535,6 @@ export declare class DirEntry {
|
|
|
2265
2535
|
readonly isSymlink: boolean;
|
|
2266
2536
|
}
|
|
2267
2537
|
|
|
2268
|
-
export declare class JSMessagePort {
|
|
2269
|
-
constructor();
|
|
2270
|
-
static postMessage(payload: any): void;
|
|
2271
|
-
static onMessage(handler: (...args: any[]) => any): (...args: any[]) => any;
|
|
2272
|
-
}
|
|
2273
|
-
|
|
2274
|
-
export declare class JSSurface {
|
|
2275
|
-
constructor();
|
|
2276
|
-
close(): Promise<void>;
|
|
2277
|
-
postMessage(payload: any): void;
|
|
2278
|
-
onMessage(handler: (...args: any[]) => any): (...args: any[]) => any;
|
|
2279
|
-
static onClose(handler: (...args: any[]) => any): (...args: any[]) => any;
|
|
2280
|
-
}
|
|
2281
|
-
|
|
2282
|
-
export declare class JSUpdateManager {
|
|
2283
|
-
constructor();
|
|
2284
|
-
/** Apply update by restarting the app */
|
|
2285
|
-
applyUpdate(): void;
|
|
2286
|
-
/** Subscribes to a ready update and returns the unsubscribe fn. */
|
|
2287
|
-
onUpdateReady(cb: (...args: any[]) => any): (...args: any[]) => any;
|
|
2288
|
-
/** Subscribes to a failed update and returns the unsubscribe fn. */
|
|
2289
|
-
onUpdateFailed(cb: (...args: any[]) => any): (...args: any[]) => any;
|
|
2290
|
-
}
|
|
2291
|
-
|
|
2292
|
-
export declare class JSVideoContext {
|
|
2293
|
-
constructor();
|
|
2294
|
-
play(): void;
|
|
2295
|
-
pause(): void;
|
|
2296
|
-
stop(): void;
|
|
2297
|
-
seek(position: number): void;
|
|
2298
|
-
requestFullScreen(): void;
|
|
2299
|
-
exitFullScreen(): void;
|
|
2300
|
-
setStreamSource(options: StreamSourceOptions): void;
|
|
2301
|
-
}
|
|
2302
|
-
|
|
2303
2538
|
export declare class LxFile {
|
|
2304
2539
|
private constructor();
|
|
2305
2540
|
/** The path supplied to `lx.fs.file`. */
|
|
@@ -2325,15 +2560,6 @@ export declare class LxFile {
|
|
|
2325
2560
|
stat(): Promise<FileStats>;
|
|
2326
2561
|
}
|
|
2327
2562
|
|
|
2328
|
-
declare global {
|
|
2329
|
-
interface AppearanceApi {
|
|
2330
|
-
/** Read the appearance preference and the light/dark value it resolves to. */
|
|
2331
|
-
get(): AppearanceState;
|
|
2332
|
-
/** Set the appearance preference to `auto`, `light`, or `dark`. */
|
|
2333
|
-
set(preference: AppearancePreference): Promise<void>;
|
|
2334
|
-
}
|
|
2335
|
-
}
|
|
2336
|
-
|
|
2337
2563
|
declare global {
|
|
2338
2564
|
interface FileSystemApi {
|
|
2339
2565
|
/**
|
|
@@ -2369,33 +2595,27 @@ declare global {
|
|
|
2369
2595
|
* is what the user sees of the whole app — host-drawn navigation chrome,
|
|
2370
2596
|
* native overlays, and every composited WebView, not just this lxapp's web
|
|
2371
2597
|
* content. Because that view can include other lxapps' UI, the API is
|
|
2372
|
-
* restricted to the
|
|
2598
|
+
* restricted to the Control app, like the other host-level APIs on `lx.app`.
|
|
2373
2599
|
*/
|
|
2374
2600
|
screenshot(options?: AppScreenshotOptions): Promise<AppScreenshotResult>;
|
|
2375
2601
|
/**
|
|
2376
2602
|
* Check whether the host app has an update.
|
|
2377
|
-
* This host-level capability is restricted to the
|
|
2603
|
+
* This host-level capability is restricted to the Control app. Calling it opts
|
|
2378
2604
|
* the process into custom update handling. Incompatible updates are hidden as
|
|
2379
2605
|
* `hasUpdate: false`; platforms that cannot apply a package may still return
|
|
2380
2606
|
* metadata and reject when `update.apply()` is invoked.
|
|
2381
2607
|
*/
|
|
2382
2608
|
checkUpdate(): Promise<HostAppUpdateCheckResult>;
|
|
2383
|
-
readonly
|
|
2609
|
+
readonly env: HostAppEnv;
|
|
2384
2610
|
/**
|
|
2385
|
-
* Read the host app's identity:
|
|
2386
|
-
*
|
|
2611
|
+
* Read the host app's identity: OS, product name, product version, and SDK
|
|
2612
|
+
* runtime version.
|
|
2387
2613
|
*/
|
|
2388
2614
|
getBaseInfo(): AppBaseInfo;
|
|
2389
|
-
/**
|
|
2390
|
-
* Follow the host's effective display language.
|
|
2391
|
-
* `getBaseInfo().displayLanguage` answers what it is now; this answers when it
|
|
2392
|
-
* changes. Logic needs both because the strings it hands to native chrome —
|
|
2393
|
-
* navigation bar titles, tab bar labels, modal and action-sheet text — are the
|
|
2394
|
-
* app's own, and nothing re-renders them on its behalf.
|
|
2395
|
-
*/
|
|
2396
|
-
onDisplayLanguageChange(callback: (language: string) => void): () => void;
|
|
2397
2615
|
/**
|
|
2398
2616
|
* Exit the host app immediately without a confirmation dialog.
|
|
2617
|
+
* Control app only: quitting the product is not an lxapp's decision. Other
|
|
2618
|
+
* lxapps get a permission error.
|
|
2399
2619
|
* If the user should confirm first, call `lx.showModal(...)` and invoke this
|
|
2400
2620
|
* only after confirmation.
|
|
2401
2621
|
*/
|
|
@@ -2403,8 +2623,9 @@ declare global {
|
|
|
2403
2623
|
/**
|
|
2404
2624
|
* Set the app-icon badge, for example an unread count.
|
|
2405
2625
|
* This targets the dock on macOS, taskbar on Windows, and home/launcher icon
|
|
2406
|
-
* on mobile
|
|
2407
|
-
*
|
|
2626
|
+
* on mobile — the product's own icon, not the calling lxapp's, so it is
|
|
2627
|
+
* Control app only and other lxapps get a permission error. Null or an empty
|
|
2628
|
+
* string clears it. Unsupported platforms treat the call as a no-op.
|
|
2408
2629
|
*/
|
|
2409
2630
|
setBadge(value: string | number | null): void;
|
|
2410
2631
|
}
|
|
@@ -2501,7 +2722,7 @@ declare global {
|
|
|
2501
2722
|
onKeyUp(callback: KeyEventCallback): () => void;
|
|
2502
2723
|
/** Get location function */
|
|
2503
2724
|
getLocation(options?: GetLocationOptions): Promise<LocationInfo>;
|
|
2504
|
-
/** Identify the running lxapp: its id, display name, version, and
|
|
2725
|
+
/** Identify the running lxapp: its id, display name, version, and channel. */
|
|
2505
2726
|
getLxAppInfo(): LxAppInfo;
|
|
2506
2727
|
/** Read an image's dimensions, type, and orientation without decoding it into a view. */
|
|
2507
2728
|
getImageInfo(options: GetImageInfoOptions): Promise<ImageInfo>;
|
|
@@ -2596,7 +2817,6 @@ declare global {
|
|
|
2596
2817
|
* an invalid selection.
|
|
2597
2818
|
*/
|
|
2598
2819
|
showActionSheet(options: ShowActionSheetOptions): Promise<ActionSheetResult>;
|
|
2599
|
-
readonly appearance: AppearanceApi;
|
|
2600
2820
|
/**
|
|
2601
2821
|
* Shows a confirmation modal.
|
|
2602
2822
|
* Resolves `{ canceled: false }` when the user confirms and `{ canceled: true }`
|
|
@@ -2615,6 +2835,8 @@ declare global {
|
|
|
2615
2835
|
* lx.startPullDownRefresh()
|
|
2616
2836
|
* Programmatically start the pull-to-refresh animation.
|
|
2617
2837
|
* This will show the refresh indicator and trigger the onPullDownRefresh lifecycle method.
|
|
2838
|
+
* Throws `E_INVALID_STATE` (`data.bizCode === 4004`) unless the current page
|
|
2839
|
+
* config sets `enablePullDownRefresh: true`.
|
|
2618
2840
|
*/
|
|
2619
2841
|
startPullDownRefresh(): void;
|
|
2620
2842
|
/**
|
|
@@ -2661,7 +2883,7 @@ declare global {
|
|
|
2661
2883
|
readonly tray: TrayApi;
|
|
2662
2884
|
/**
|
|
2663
2885
|
* Return the callback-based update manager for this lxapp's bundle. This is
|
|
2664
|
-
* available to every lxapp and is distinct from the
|
|
2886
|
+
* available to every lxapp and is distinct from the Control-app-only
|
|
2665
2887
|
* `lx.app.checkUpdate()`, which updates the native host app.
|
|
2666
2888
|
*/
|
|
2667
2889
|
getUpdateManager(): UpdateManager;
|
|
@@ -2686,18 +2908,19 @@ declare global {
|
|
|
2686
2908
|
interface ShellApi {
|
|
2687
2909
|
/**
|
|
2688
2910
|
* `lx.shell.openApp(appId, options)` — compose another lxapp into a shell
|
|
2689
|
-
* slot.
|
|
2911
|
+
* slot. Control-app only; the namespace is the privilege.
|
|
2690
2912
|
*/
|
|
2691
2913
|
openApp(appId: string, options: ShellOpenAppOptions): Promise<AppSurface>;
|
|
2692
|
-
/** `lx.shell.openBuiltin(page)` — a host builtin page.
|
|
2914
|
+
/** `lx.shell.openBuiltin(page)` — a host builtin page. Control-app only. */
|
|
2693
2915
|
openBuiltin(page: BuiltinShellPage): Promise<BuiltinSurface>;
|
|
2694
2916
|
/**
|
|
2695
2917
|
* `lx.shell.openDeclared(id, options?)` — the declared surface, plus the
|
|
2696
|
-
* keyed multi-instance form and placement overrides.
|
|
2918
|
+
* keyed multi-instance form and placement overrides. Control-app only.
|
|
2697
2919
|
*/
|
|
2698
2920
|
openDeclared(id: string, options?: ShellOpenDeclaredOptions): Promise<DeclaredSurface>;
|
|
2699
2921
|
/** `lx.shell.reconfigure(id, patch)` — re-place a live declared surface. */
|
|
2700
2922
|
reconfigure(id: string, patch: ShellSurfacePatch): Promise<void>;
|
|
2923
|
+
readonly sidebarActions: ShellSidebarActionsApi;
|
|
2701
2924
|
}
|
|
2702
2925
|
}
|
|
2703
2926
|
|
|
@@ -2705,9 +2928,9 @@ declare global {
|
|
|
2705
2928
|
interface ShellSidebarActionsApi {
|
|
2706
2929
|
/**
|
|
2707
2930
|
* Atomically replaces the complete desktop sidebar action declaration. Only the
|
|
2708
|
-
*
|
|
2931
|
+
* Control app may call this API. Ids must be non-empty and unique across both
|
|
2709
2932
|
* placements; header accepts at most two entries. Icons must be bundled relative
|
|
2710
|
-
* paths or runtime-managed `lx://` paths accessible to the
|
|
2933
|
+
* paths or runtime-managed `lx://` paths accessible to the Control app.
|
|
2711
2934
|
* Every entry is bound to its generation-scoped callback. The shell invokes that
|
|
2712
2935
|
* callback but never infers navigation or selected state. Validation or host
|
|
2713
2936
|
* projection failure leaves the previous generation active. `replace([])` clears
|
|
@@ -2717,21 +2940,21 @@ declare global {
|
|
|
2717
2940
|
replace(items: ShellSidebarAction[]): void;
|
|
2718
2941
|
/**
|
|
2719
2942
|
* Atomically updates the icon, label, and/or disabled state of one stable id.
|
|
2720
|
-
* Only the
|
|
2943
|
+
* Only the Control app may call this API. The patch must be non-empty; unknown
|
|
2721
2944
|
* fields are rejected. The callback and placement stay unchanged. Throws
|
|
2722
2945
|
* `E_NOT_FOUND` when `id` is not in the current declaration.
|
|
2723
2946
|
*/
|
|
2724
2947
|
update(id: string, patch: ShellSidebarActionUpdate): void;
|
|
2725
2948
|
/**
|
|
2726
2949
|
* Atomically removes one stable id and its generation-scoped callback. Only the
|
|
2727
|
-
*
|
|
2950
|
+
* Control app may call this API. Throws `E_NOT_FOUND` when `id` is not in the
|
|
2728
2951
|
* current declaration.
|
|
2729
2952
|
*/
|
|
2730
2953
|
remove(id: string): void;
|
|
2731
2954
|
/**
|
|
2732
|
-
* Atomically clears every runtime sidebar action and callback. Only the
|
|
2733
|
-
*
|
|
2734
|
-
* empty; the
|
|
2955
|
+
* Atomically clears every runtime sidebar action and callback. Only the
|
|
2956
|
+
* Control app may call this API. Equivalent to `replace([])` and safe when already
|
|
2957
|
+
* empty; the Control app must still redeclare actions after the next Logic launch.
|
|
2735
2958
|
*/
|
|
2736
2959
|
clear(): void;
|
|
2737
2960
|
}
|
|
@@ -2744,7 +2967,7 @@ declare global {
|
|
|
2744
2967
|
* float or a window. A page can never be an aside: asides carry external
|
|
2745
2968
|
* content only, which is why that member does not exist on this signature.
|
|
2746
2969
|
*/
|
|
2747
|
-
openPage(page:
|
|
2970
|
+
openPage(page: ConfiguredPageName, options?: OpenPageOptions): Promise<PageSurface>;
|
|
2748
2971
|
/**
|
|
2749
2972
|
* `lx.surface.openUrl(url, options?)` — external content in the in-app
|
|
2750
2973
|
* browser, as a tab or docked as an aside.
|