@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/index.ts
CHANGED
|
@@ -4,23 +4,26 @@
|
|
|
4
4
|
* Type declarations for the LingXia JS API, driven by Rust implementation.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
export * from './generated/logic';
|
|
8
|
-
export
|
|
9
|
-
export * from './error';
|
|
10
|
-
export * from './generated/error';
|
|
11
|
-
export * from './generated/i18n';
|
|
7
|
+
export * from './generated/logic.js';
|
|
8
|
+
export type { Automation } from './automation/index.js';
|
|
9
|
+
export * from './error.js';
|
|
10
|
+
export * from './generated/error.js';
|
|
11
|
+
export * from './generated/i18n.js';
|
|
12
12
|
|
|
13
|
-
import './generated/logic';
|
|
13
|
+
import './generated/logic.js';
|
|
14
14
|
|
|
15
15
|
import type {
|
|
16
16
|
AppConfig,
|
|
17
17
|
AppInstance,
|
|
18
|
+
AppLifecycleName,
|
|
18
19
|
BinaryFileData,
|
|
19
20
|
FsWriteOptions,
|
|
21
|
+
NoLifecycleTypos,
|
|
20
22
|
PageConfig,
|
|
21
23
|
PageInstance,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
PageLifecycleName,
|
|
25
|
+
} from './generated/logic.js';
|
|
26
|
+
import type { Automation } from './automation/index.js';
|
|
24
27
|
|
|
25
28
|
export type Lx = globalThis.Lx;
|
|
26
29
|
|
|
@@ -52,10 +55,28 @@ declare global {
|
|
|
52
55
|
|
|
53
56
|
const lx: Lx;
|
|
54
57
|
|
|
55
|
-
|
|
58
|
+
/**
|
|
59
|
+
* `TCustom` is inferred from the members you write beside the lifecycle
|
|
60
|
+
* hooks, so `this.myMethod()` resolves inside the config and a key that is
|
|
61
|
+
* only a case away from a hook is rejected.
|
|
62
|
+
*/
|
|
63
|
+
function App<TCustom>(
|
|
64
|
+
config: AppConfig &
|
|
65
|
+
TCustom &
|
|
66
|
+
NoLifecycleTypos<TCustom, AppLifecycleName> &
|
|
67
|
+
ThisType<AppInstance & TCustom>
|
|
68
|
+
): AppInstance & TCustom;
|
|
56
69
|
function getApp<T extends AppInstance = AppInstance>(): T | null;
|
|
57
|
-
|
|
58
|
-
|
|
70
|
+
/**
|
|
71
|
+
* `TData` comes from `data`, `TCustom` from everything else you declare, so
|
|
72
|
+
* `this.data` is typed, `this.myMethod()` resolves, and `setData` checks
|
|
73
|
+
* top-level keys against `data`.
|
|
74
|
+
*/
|
|
75
|
+
function Page<TData extends Record<string, unknown>, TCustom>(
|
|
76
|
+
config: PageConfig<TData> &
|
|
77
|
+
TCustom &
|
|
78
|
+
NoLifecycleTypos<TCustom, PageLifecycleName> &
|
|
79
|
+
ThisType<PageInstance<TData> & TCustom>
|
|
59
80
|
): void;
|
|
60
81
|
function getCurrentPages<T extends PageInstance = PageInstance>(): T[];
|
|
61
82
|
}
|
package/src/process.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OS process capability for
|
|
2
|
+
* OS process capability for the Control app.
|
|
3
3
|
*
|
|
4
4
|
* Add `@lingxia/types/process` to the Logic tsconfig only when the host sets
|
|
5
|
-
* `capabilities.process: true` and the
|
|
5
|
+
* `capabilities.process: true` and the Control app declares the `process`
|
|
6
6
|
* security privilege. These declarations have no runtime payload.
|
|
7
7
|
*/
|
|
8
8
|
|
|
@@ -23,8 +23,13 @@ import type {
|
|
|
23
23
|
} from '../automation/index.js';
|
|
24
24
|
import type {
|
|
25
25
|
AppearanceApi,
|
|
26
|
+
AppCacheApi,
|
|
26
27
|
AutostartApi,
|
|
27
28
|
CompressVideoTask,
|
|
29
|
+
ControlApi,
|
|
30
|
+
ControlAppearanceApi,
|
|
31
|
+
ControlDisplayLanguageApi,
|
|
32
|
+
DisplayLanguageApi,
|
|
28
33
|
DownloadTask,
|
|
29
34
|
FileSystemApi,
|
|
30
35
|
HostAppApi,
|
|
@@ -53,7 +58,6 @@ import type {
|
|
|
53
58
|
|
|
54
59
|
export const LX_API_NAMES = [
|
|
55
60
|
'app',
|
|
56
|
-
'appearance',
|
|
57
61
|
'automation',
|
|
58
62
|
'chooseDirectory',
|
|
59
63
|
'chooseFile',
|
|
@@ -121,18 +125,38 @@ export const LX_API_NAMES = [
|
|
|
121
125
|
] as const;
|
|
122
126
|
|
|
123
127
|
const HOST_APP_API = [
|
|
128
|
+
'appearance',
|
|
124
129
|
'autostart',
|
|
130
|
+
'cache',
|
|
125
131
|
'checkUpdate',
|
|
126
|
-
'
|
|
132
|
+
'control',
|
|
133
|
+
'displayLanguage',
|
|
134
|
+
'env',
|
|
127
135
|
'exit',
|
|
128
136
|
'getBaseInfo',
|
|
129
|
-
'onDisplayLanguageChange',
|
|
130
137
|
'screenshot',
|
|
131
138
|
'setBadge',
|
|
132
139
|
] as const;
|
|
133
|
-
|
|
140
|
+
// `autostart`, `control`, and `cache` are injected only where they apply, so a
|
|
141
|
+
// runtime walk of `lx.app` must not require them.
|
|
142
|
+
const HOST_APP_RUNTIME_API = HOST_APP_API.filter(
|
|
143
|
+
(name) => name !== 'autostart' && name !== 'control' && name !== 'cache',
|
|
144
|
+
);
|
|
134
145
|
const AUTOSTART_API = ['isEnabled', 'setEnabled'] as const;
|
|
135
|
-
const
|
|
146
|
+
const APP_CACHE_API = ['clear', 'size'] as const;
|
|
147
|
+
const DISPLAY_LANGUAGE_API = ['get', 'watch'] as const;
|
|
148
|
+
const CONTROL_API = ['appearance', 'displayLanguage'] as const;
|
|
149
|
+
const CONTROL_DISPLAY_LANGUAGE_API = [
|
|
150
|
+
'getPreference',
|
|
151
|
+
'setPreference',
|
|
152
|
+
'watchPreference',
|
|
153
|
+
] as const;
|
|
154
|
+
const APPEARANCE_API = ['get', 'watch'] as const;
|
|
155
|
+
const CONTROL_APPEARANCE_API = [
|
|
156
|
+
'getPreference',
|
|
157
|
+
'setPreference',
|
|
158
|
+
'watchPreference',
|
|
159
|
+
] as const;
|
|
136
160
|
const NAVIGATION_BAR_API = ['update'] as const;
|
|
137
161
|
const TAB_BAR_API = ['update'] as const;
|
|
138
162
|
const TERMINAL_API = ['colorSchemes', 'fonts', 'settings', 'windows'] as const;
|
|
@@ -167,7 +191,7 @@ const LX_FILE_API = [
|
|
|
167
191
|
'stat',
|
|
168
192
|
'text',
|
|
169
193
|
] as const;
|
|
170
|
-
const STORAGE_API = ['clear', 'delete', 'get', 'info', 'list', 'set'] as const;
|
|
194
|
+
const STORAGE_API = ['clear', 'delete', 'get', 'has', 'info', 'list', 'set'] as const;
|
|
171
195
|
const UPDATE_MANAGER_API = ['applyUpdate', 'onUpdateFailed', 'onUpdateReady'] as const;
|
|
172
196
|
const VIDEO_CONTEXT_API = [
|
|
173
197
|
'exitFullScreen',
|
|
@@ -192,6 +216,7 @@ const SHELL_DRIVER_API = ['pins', 'setPin'] as const;
|
|
|
192
216
|
const TERMINAL_DRIVER_API = ['input', 'newTab', 'setMaximized', 'snapshot', 'split'] as const;
|
|
193
217
|
const LXAPP_DRIVER_API = ['eval', 'info', 'nav', 'page', 'pages', 'surfaceLayout'] as const;
|
|
194
218
|
const LXAPP_MANAGER_API = [
|
|
219
|
+
'applink',
|
|
195
220
|
'close',
|
|
196
221
|
'current',
|
|
197
222
|
'list',
|
|
@@ -309,7 +334,6 @@ export const LX_RUNTIME_SURFACES = [
|
|
|
309
334
|
optionalMembers: ['terminal'],
|
|
310
335
|
properties: [
|
|
311
336
|
'app',
|
|
312
|
-
'appearance',
|
|
313
337
|
'env',
|
|
314
338
|
'fs',
|
|
315
339
|
'navigationBar',
|
|
@@ -325,7 +349,7 @@ export const LX_RUNTIME_SURFACES = [
|
|
|
325
349
|
layer: 'logic',
|
|
326
350
|
expression: 'lx.app',
|
|
327
351
|
members: HOST_APP_RUNTIME_API,
|
|
328
|
-
properties: ['
|
|
352
|
+
properties: ['appearance', 'displayLanguage', 'env'],
|
|
329
353
|
},
|
|
330
354
|
{
|
|
331
355
|
name: 'lx.app.autostart',
|
|
@@ -335,11 +359,46 @@ export const LX_RUNTIME_SURFACES = [
|
|
|
335
359
|
optional: true,
|
|
336
360
|
},
|
|
337
361
|
{
|
|
338
|
-
name: 'lx.
|
|
362
|
+
name: 'lx.app.cache',
|
|
339
363
|
layer: 'logic',
|
|
340
|
-
expression: 'lx.
|
|
364
|
+
expression: 'lx.app.cache',
|
|
365
|
+
members: APP_CACHE_API,
|
|
366
|
+
optional: true,
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
name: 'lx.app.displayLanguage',
|
|
370
|
+
layer: 'logic',
|
|
371
|
+
expression: 'lx.app.displayLanguage',
|
|
372
|
+
members: DISPLAY_LANGUAGE_API,
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
name: 'lx.app.control',
|
|
376
|
+
layer: 'logic',
|
|
377
|
+
expression: 'lx.app.control',
|
|
378
|
+
members: CONTROL_API,
|
|
379
|
+
properties: CONTROL_API,
|
|
380
|
+
optional: true,
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
name: 'lx.app.control.displayLanguage',
|
|
384
|
+
layer: 'logic',
|
|
385
|
+
expression: 'lx.app.control?.displayLanguage',
|
|
386
|
+
members: CONTROL_DISPLAY_LANGUAGE_API,
|
|
387
|
+
optional: true,
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
name: 'lx.app.appearance',
|
|
391
|
+
layer: 'logic',
|
|
392
|
+
expression: 'lx.app.appearance',
|
|
341
393
|
members: APPEARANCE_API,
|
|
342
394
|
},
|
|
395
|
+
{
|
|
396
|
+
name: 'lx.app.control.appearance',
|
|
397
|
+
layer: 'logic',
|
|
398
|
+
expression: 'lx.app.control?.appearance',
|
|
399
|
+
members: CONTROL_APPEARANCE_API,
|
|
400
|
+
optional: true,
|
|
401
|
+
},
|
|
343
402
|
{
|
|
344
403
|
name: 'lx.navigationBar',
|
|
345
404
|
layer: 'logic',
|
|
@@ -358,6 +417,7 @@ export const LX_RUNTIME_SURFACES = [
|
|
|
358
417
|
expression: 'lx.terminal',
|
|
359
418
|
members: TERMINAL_API,
|
|
360
419
|
properties: TERMINAL_API,
|
|
420
|
+
optionalMembers: ['windows'],
|
|
361
421
|
optional: true,
|
|
362
422
|
},
|
|
363
423
|
{
|
|
@@ -423,6 +483,10 @@ export const LX_RUNTIME_SURFACES = [
|
|
|
423
483
|
layer: 'automation',
|
|
424
484
|
expression: 'lx.automation()',
|
|
425
485
|
members: AUTOMATION_API,
|
|
486
|
+
// The desktop tier is deliberately absent on mobile hosts. Keep the
|
|
487
|
+
// portable shape contract honest while the desktop entry covers it on
|
|
488
|
+
// Windows and macOS.
|
|
489
|
+
optionalMembers: ['desktop'],
|
|
426
490
|
properties: ['browser', 'desktop', 'device', 'lxapps', 'shell', 'terminal'],
|
|
427
491
|
},
|
|
428
492
|
{ name: 'ShellDriver', layer: 'automation', expression: 'lx.automation().shell', members: SHELL_DRIVER_API },
|
|
@@ -464,16 +528,17 @@ export const LX_RUNTIME_SURFACES = [
|
|
|
464
528
|
layer: 'automation',
|
|
465
529
|
expression: 'lx.automation().desktop',
|
|
466
530
|
members: DESKTOP_DRIVER_API,
|
|
531
|
+
optional: true,
|
|
467
532
|
properties: ['app', 'ax', 'clipboard', 'key', 'pointer', 'process', 'wait', 'window'],
|
|
468
533
|
},
|
|
469
|
-
{ name: 'DesktopPointer', layer: 'automation', expression: 'lx.automation().desktop.pointer', members: DESKTOP_POINTER_API },
|
|
470
|
-
{ name: 'DesktopKey', layer: 'automation', expression: 'lx.automation().desktop.key', members: DESKTOP_KEY_API },
|
|
471
|
-
{ name: 'DesktopWindow', layer: 'automation', expression: 'lx.automation().desktop.window', members: DESKTOP_WINDOW_API },
|
|
472
|
-
{ name: 'DesktopClipboard', layer: 'automation', expression: 'lx.automation().desktop.clipboard', members: DESKTOP_CLIPBOARD_API },
|
|
473
|
-
{ name: 'DesktopAx', layer: 'automation', expression: 'lx.automation().desktop.ax', members: DESKTOP_AX_API },
|
|
474
|
-
{ name: 'DesktopWait', layer: 'automation', expression: 'lx.automation().desktop.wait', members: DESKTOP_WAIT_API },
|
|
475
|
-
{ name: 'DesktopApp', layer: 'automation', expression: 'lx.automation().desktop.app', members: DESKTOP_APP_API },
|
|
476
|
-
{ name: 'DesktopProcess', layer: 'automation', expression: 'lx.automation().desktop.process', members: DESKTOP_PROCESS_API },
|
|
534
|
+
{ name: 'DesktopPointer', layer: 'automation', expression: 'lx.automation().desktop.pointer', members: DESKTOP_POINTER_API, optional: true },
|
|
535
|
+
{ name: 'DesktopKey', layer: 'automation', expression: 'lx.automation().desktop.key', members: DESKTOP_KEY_API, optional: true },
|
|
536
|
+
{ name: 'DesktopWindow', layer: 'automation', expression: 'lx.automation().desktop.window', members: DESKTOP_WINDOW_API, optional: true },
|
|
537
|
+
{ name: 'DesktopClipboard', layer: 'automation', expression: 'lx.automation().desktop.clipboard', members: DESKTOP_CLIPBOARD_API, optional: true },
|
|
538
|
+
{ name: 'DesktopAx', layer: 'automation', expression: 'lx.automation().desktop.ax', members: DESKTOP_AX_API, optional: true },
|
|
539
|
+
{ name: 'DesktopWait', layer: 'automation', expression: 'lx.automation().desktop.wait', members: DESKTOP_WAIT_API, optional: true },
|
|
540
|
+
{ name: 'DesktopApp', layer: 'automation', expression: 'lx.automation().desktop.app', members: DESKTOP_APP_API, optional: true },
|
|
541
|
+
{ name: 'DesktopProcess', layer: 'automation', expression: 'lx.automation().desktop.process', members: DESKTOP_PROCESS_API, optional: true },
|
|
477
542
|
] as const;
|
|
478
543
|
|
|
479
544
|
/** Canonical identifiers used by behavioral automation coverage. */
|
|
@@ -646,7 +711,8 @@ export const LX_REQUIRED_RUNTIME_SHAPE_NAMES = [
|
|
|
646
711
|
.map((member) => `shape:${surface.name}.${member}`);
|
|
647
712
|
}),
|
|
648
713
|
...LX_RETURNED_OBJECT_SURFACES
|
|
649
|
-
.filter((
|
|
714
|
+
.filter((surface) => surface.fixture === 'runtime-safe'
|
|
715
|
+
&& !('optional' in surface && surface.optional))
|
|
650
716
|
.flatMap(({ name, members }) => members.map((member) => `shape:${name}.${member}`)),
|
|
651
717
|
];
|
|
652
718
|
|
|
@@ -665,6 +731,11 @@ export type LxApiManifestGate = [
|
|
|
665
731
|
AssertTrue<Exact<PublishedLx, typeof LX_API_NAMES>>,
|
|
666
732
|
AssertTrue<Exact<HostAppApi, typeof HOST_APP_API>>,
|
|
667
733
|
AssertTrue<Exact<AutostartApi, typeof AUTOSTART_API>>,
|
|
734
|
+
AssertTrue<Exact<AppCacheApi, typeof APP_CACHE_API>>,
|
|
735
|
+
AssertTrue<Exact<DisplayLanguageApi, typeof DISPLAY_LANGUAGE_API>>,
|
|
736
|
+
AssertTrue<Exact<ControlApi, typeof CONTROL_API>>,
|
|
737
|
+
AssertTrue<Exact<ControlDisplayLanguageApi, typeof CONTROL_DISPLAY_LANGUAGE_API>>,
|
|
738
|
+
AssertTrue<Exact<ControlAppearanceApi, typeof CONTROL_APPEARANCE_API>>,
|
|
668
739
|
AssertTrue<Exact<AppearanceApi, typeof APPEARANCE_API>>,
|
|
669
740
|
AssertTrue<Exact<NavigationBarApi, typeof NAVIGATION_BAR_API>>,
|
|
670
741
|
AssertTrue<Exact<TabBarApi, typeof TAB_BAR_API>>,
|