@lingxia/types 0.16.0 → 0.18.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.
Files changed (43) hide show
  1. package/dist/automation/index.d.ts +105 -35
  2. package/dist/automation/index.d.ts.map +1 -1
  3. package/dist/error.d.ts +19 -0
  4. package/dist/error.d.ts.map +1 -1
  5. package/dist/error.js +23 -1
  6. package/dist/error.js.map +1 -1
  7. package/dist/esm/error.js +21 -0
  8. package/dist/esm/error.js.map +1 -1
  9. package/dist/esm/generated/error.js +1 -0
  10. package/dist/esm/generated/error.js.map +1 -1
  11. package/dist/esm/generated/i18n.js +10 -1
  12. package/dist/esm/generated/i18n.js.map +1 -1
  13. package/dist/esm/testing/public-api.js +72 -46
  14. package/dist/esm/testing/public-api.js.map +1 -1
  15. package/dist/generated/error.d.ts +4 -0
  16. package/dist/generated/error.d.ts.map +1 -1
  17. package/dist/generated/error.js +1 -0
  18. package/dist/generated/error.js.map +1 -1
  19. package/dist/generated/i18n.d.ts +1 -1
  20. package/dist/generated/i18n.d.ts.map +1 -1
  21. package/dist/generated/i18n.js +10 -1
  22. package/dist/generated/i18n.js.map +1 -1
  23. package/dist/generated/logic-web.d.ts +24 -3
  24. package/dist/generated/logic.d.ts +739 -383
  25. package/dist/generated/logic.d.ts.map +1 -1
  26. package/dist/index.d.ts +7 -5
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/process.d.ts +15 -4
  29. package/dist/process.d.ts.map +1 -1
  30. package/dist/testing/public-api.d.ts +70 -45
  31. package/dist/testing/public-api.d.ts.map +1 -1
  32. package/dist/testing/public-api.js +72 -46
  33. package/dist/testing/public-api.js.map +1 -1
  34. package/package.json +2 -2
  35. package/src/automation/index.ts +82 -34
  36. package/src/error.ts +23 -0
  37. package/src/generated/error.ts +1 -0
  38. package/src/generated/i18n.ts +10 -1
  39. package/src/generated/logic-web.d.ts +24 -3
  40. package/src/generated/logic.ts +795 -407
  41. package/src/index.ts +9 -6
  42. package/src/process.ts +14 -4
  43. package/src/testing/public-api.ts +80 -47
package/src/index.ts CHANGED
@@ -18,7 +18,9 @@ import type {
18
18
  AppLifecycleName,
19
19
  BinaryFileData,
20
20
  FsWriteOptions,
21
+ ManagedPath,
21
22
  NoLifecycleTypos,
23
+ NoReservedPageMembers,
22
24
  PageConfig,
23
25
  PageInstance,
24
26
  PageLifecycleName,
@@ -36,9 +38,9 @@ declare global {
36
38
  * signature above covers the string case.
37
39
  */
38
40
  write(
39
- path: string,
41
+ path: ManagedPath,
40
42
  data: BinaryFileData,
41
- options?: Omit<FsWriteOptions, 'encoding'>
43
+ options?: Omit<FsWriteOptions, 'encoding'> & { encoding?: never }
42
44
  ): Promise<void>;
43
45
  }
44
46
 
@@ -69,14 +71,15 @@ declare global {
69
71
  function getApp<T extends AppInstance = AppInstance>(): T | null;
70
72
  /**
71
73
  * `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
+ * `this.data` is a readonly view of that type, `this.myMethod()` resolves,
75
+ * and `setData` checks top-level keys against `data`.
74
76
  */
75
- function Page<TData extends Record<string, unknown>, TCustom>(
77
+ function Page<TData extends object, TCustom>(
76
78
  config: PageConfig<TData> &
77
79
  TCustom &
78
80
  NoLifecycleTypos<TCustom, PageLifecycleName> &
79
- ThisType<PageInstance<TData> & TCustom>
81
+ NoReservedPageMembers<TCustom> &
82
+ ThisType<PageInstance<TData> & Omit<TCustom, keyof PageInstance>>
80
83
  ): void;
81
84
  function getCurrentPages<T extends PageInstance = PageInstance>(): T[];
82
85
  }
package/src/process.ts CHANGED
@@ -31,6 +31,14 @@ export interface RongSpawnOptionsWithCmd extends RongSpawnOptions {
31
31
  cmd: string[];
32
32
  }
33
33
 
34
+ /** Synchronous spawning cannot deliver async callbacks or react to an AbortSignal. */
35
+ export type RongSpawnSyncOptions = Omit<RongSpawnOptions, 'onExit' | 'signal' | 'killSignal'> & {
36
+ onExit?: never;
37
+ signal?: never;
38
+ killSignal?: never;
39
+ };
40
+ export type RongSpawnSyncOptionsWithCmd = RongSpawnSyncOptions & { cmd: string[] };
41
+
34
42
  export interface RongSyncSubprocess {
35
43
  readonly exitCode: number | null;
36
44
  readonly success: boolean;
@@ -96,8 +104,10 @@ export interface RongShellCommand extends PromiseLike<RongShellResult> {
96
104
  export interface RongShellTag {
97
105
  (strings: TemplateStringsArray, ...values: unknown[]): RongShellCommand;
98
106
  (command: string): RongShellCommand;
99
- cwd(path?: string): string | RongShellTag | undefined;
100
- env(values?: RongEnvMap): RongEnvMap | RongShellTag | undefined;
107
+ cwd(): string | undefined;
108
+ cwd(path: string): RongShellTag;
109
+ env(): RongEnvMap | undefined;
110
+ env(values: RongEnvMap): RongShellTag;
101
111
  throws(value?: boolean): RongShellTag;
102
112
  nothrow(): RongShellTag;
103
113
  quiet(): RongShellTag;
@@ -122,8 +132,8 @@ declare global {
122
132
  readonly stderr: RongOutputHandle;
123
133
  spawn(cmd: string[], options?: RongSpawnOptions): RongSubprocess;
124
134
  spawn(options: RongSpawnOptionsWithCmd): RongSubprocess;
125
- spawnSync(cmd: string[], options?: RongSpawnOptions): RongSyncSubprocess;
126
- spawnSync(options: RongSpawnOptionsWithCmd): RongSyncSubprocess;
135
+ spawnSync(cmd: string[], options?: RongSpawnSyncOptions): RongSyncSubprocess;
136
+ spawnSync(options: RongSpawnSyncOptionsWithCmd): RongSyncSubprocess;
127
137
  readonly $: RongShellTag;
128
138
  readonly ShellError: {
129
139
  new (message: string): RongShellError;
@@ -25,18 +25,21 @@ import type {
25
25
  AppearanceApi,
26
26
  AppCacheApi,
27
27
  AutostartApi,
28
+ BannerApi,
28
29
  CompressVideoTask,
29
30
  ControlApi,
30
31
  ControlAppearanceApi,
31
32
  ControlDisplayLanguageApi,
32
33
  DisplayLanguageApi,
33
34
  DownloadTask,
35
+ ClipboardApi,
34
36
  FileSystemApi,
35
37
  HostAppApi,
36
38
  HostAppUpdateInfo,
37
39
  HostAppUpdateTask,
38
40
  LxFile,
39
41
  NavigationBarApi,
42
+ NotificationApi,
40
43
  PageMessagePort,
41
44
  PreviewMediaHandle,
42
45
  TabSurface,
@@ -57,11 +60,16 @@ import type {
57
60
  } from '../generated/logic.js';
58
61
 
59
62
  export const LX_API_NAMES = [
60
- 'app',
63
+ 'host',
61
64
  'automation',
65
+ 'alert',
66
+ 'confirm',
67
+ 'pickFile',
68
+ 'pickFiles',
62
69
  'chooseDirectory',
63
70
  'chooseFile',
64
71
  'chooseMedia',
72
+ 'clipboard',
65
73
  'compressImage',
66
74
  'compressVideo',
67
75
  'connectWifi',
@@ -127,22 +135,38 @@ export const LX_API_NAMES = [
127
135
  const HOST_APP_API = [
128
136
  'appearance',
129
137
  'autostart',
138
+ 'banner',
130
139
  'cache',
131
140
  'checkUpdate',
141
+ 'claimCustomUpdate',
132
142
  'control',
133
143
  'displayLanguage',
134
144
  'env',
135
145
  'exit',
136
146
  'getBaseInfo',
147
+ 'notification',
137
148
  'screenshot',
138
149
  'setBadge',
139
150
  ] as const;
140
- // `autostart`, `control`, and `cache` are injected only where they apply, so a
141
- // runtime walk of `lx.app` must not require them.
151
+ // `autostart`, `banner`, `control`, `cache`, and `notification` are injected
152
+ // only where they apply, so a runtime walk of `lx.host` must not require them.
142
153
  const HOST_APP_RUNTIME_API = HOST_APP_API.filter(
143
- (name) => name !== 'autostart' && name !== 'control' && name !== 'cache',
154
+ (name) =>
155
+ name !== 'autostart' &&
156
+ name !== 'banner' &&
157
+ name !== 'control' &&
158
+ name !== 'cache' &&
159
+ name !== 'notification',
144
160
  );
145
161
  const AUTOSTART_API = ['isEnabled', 'setEnabled'] as const;
162
+ const BANNER_API = ['dismiss', 'show'] as const;
163
+ const NOTIFICATION_API = [
164
+ 'cancel',
165
+ 'cancelAll',
166
+ 'getPermission',
167
+ 'requestPermission',
168
+ 'show',
169
+ ] as const;
146
170
  const APP_CACHE_API = ['clear', 'size'] as const;
147
171
  const DISPLAY_LANGUAGE_API = ['get', 'watch'] as const;
148
172
  const CONTROL_API = ['appearance', 'displayLanguage'] as const;
@@ -166,10 +190,11 @@ const TERMINAL_FONTS_API = ['list'] as const;
166
190
  const TERMINAL_PREVIEW_API = ['clear', 'close', 'show'] as const;
167
191
  const WINDOWS_TERMINAL_API = ['install', 'setEnabled', 'status'] as const;
168
192
  const ENV_API = ['USER_CACHE_PATH', 'USER_DATA_PATH'] as const;
169
- const SURFACE_NAMESPACE_API = ['get', 'onContext', 'openDeclared', 'openPage', 'openUrl'] as const;
193
+ const SURFACE_NAMESPACE_API = ['getByKey', 'watchContext', 'openDeclared', 'openPage', 'openUrl'] as const;
170
194
  const SHELL_API = ['openApp', 'openBuiltin', 'openDeclared', 'reconfigure', 'sidebarActions'] as const;
171
195
  const SHELL_SIDEBAR_ACTIONS_API = ['clear', 'remove', 'replace', 'update'] as const;
172
- const TRAY_API = ['hide', 'onClick', 'setBadge', 'setIcon', 'setMenu', 'setTitle', 'show'] as const;
196
+ const TRAY_API = ['hide', 'onClick', 'setIcon', 'setMenu', 'setTitle', 'show'] as const;
197
+ const CLIPBOARD_API = ['clear', 'read', 'readText', 'types', 'write', 'writeText'] as const;
173
198
  const FILE_SYSTEM_API = [
174
199
  'copy',
175
200
  'exists',
@@ -212,7 +237,7 @@ const AUTOMATION_API = [
212
237
  'shell',
213
238
  'terminal',
214
239
  ] as const;
215
- const SHELL_DRIVER_API = ['pins', 'setPin'] as const;
240
+ const SHELL_DRIVER_API = ['pins', 'setPin', 'reorderPins'] as const;
216
241
  const TERMINAL_DRIVER_API = ['input', 'newTab', 'setMaximized', 'snapshot', 'split'] as const;
217
242
  const LXAPP_DRIVER_API = ['eval', 'info', 'nav', 'page', 'pages', 'surfaceLayout'] as const;
218
243
  const LXAPP_MANAGER_API = [
@@ -333,9 +358,10 @@ export const LX_RUNTIME_SURFACES = [
333
358
  members: LX_API_NAMES,
334
359
  optionalMembers: ['terminal'],
335
360
  properties: [
336
- 'app',
361
+ 'clipboard',
337
362
  'env',
338
363
  'fs',
364
+ 'host',
339
365
  'navigationBar',
340
366
  'shell',
341
367
  'surface',
@@ -345,57 +371,71 @@ export const LX_RUNTIME_SURFACES = [
345
371
  ],
346
372
  },
347
373
  {
348
- name: 'lx.app',
374
+ name: 'lx.host',
349
375
  layer: 'logic',
350
- expression: 'lx.app',
376
+ expression: 'lx.host',
351
377
  members: HOST_APP_RUNTIME_API,
352
378
  properties: ['appearance', 'displayLanguage', 'env'],
353
379
  },
354
380
  {
355
- name: 'lx.app.autostart',
381
+ name: 'lx.host.autostart',
356
382
  layer: 'logic',
357
- expression: 'lx.app.autostart',
383
+ expression: 'lx.host.autostart',
358
384
  members: AUTOSTART_API,
359
385
  optional: true,
360
386
  },
361
387
  {
362
- name: 'lx.app.cache',
388
+ name: 'lx.host.banner',
363
389
  layer: 'logic',
364
- expression: 'lx.app.cache',
390
+ expression: 'lx.host.banner',
391
+ members: BANNER_API,
392
+ optional: true,
393
+ },
394
+ {
395
+ name: 'lx.host.notification',
396
+ layer: 'logic',
397
+ expression: 'lx.host.notification',
398
+ members: NOTIFICATION_API,
399
+ optional: true,
400
+ },
401
+ {
402
+ name: 'lx.host.cache',
403
+ layer: 'logic',
404
+ expression: 'lx.host.cache',
365
405
  members: APP_CACHE_API,
366
406
  optional: true,
367
407
  },
368
408
  {
369
- name: 'lx.app.displayLanguage',
409
+ name: 'lx.host.displayLanguage',
370
410
  layer: 'logic',
371
- expression: 'lx.app.displayLanguage',
411
+ expression: 'lx.host.displayLanguage',
372
412
  members: DISPLAY_LANGUAGE_API,
373
413
  },
374
414
  {
375
- name: 'lx.app.control',
415
+ name: 'lx.host.control',
376
416
  layer: 'logic',
377
- expression: 'lx.app.control',
417
+ expression: 'lx.host.control',
378
418
  members: CONTROL_API,
379
419
  properties: CONTROL_API,
380
420
  optional: true,
381
421
  },
382
422
  {
383
- name: 'lx.app.control.displayLanguage',
423
+ name: 'lx.host.control.displayLanguage',
384
424
  layer: 'logic',
385
- expression: 'lx.app.control?.displayLanguage',
425
+ expression: 'lx.host.control?.displayLanguage',
386
426
  members: CONTROL_DISPLAY_LANGUAGE_API,
387
427
  optional: true,
388
428
  },
389
429
  {
390
- name: 'lx.app.appearance',
430
+ name: 'lx.host.appearance',
391
431
  layer: 'logic',
392
- expression: 'lx.app.appearance',
432
+ expression: 'lx.host.appearance',
393
433
  members: APPEARANCE_API,
394
434
  },
395
435
  {
396
- name: 'lx.app.control.appearance',
436
+ name: 'lx.host.control.appearance',
397
437
  layer: 'logic',
398
- expression: 'lx.app.control?.appearance',
438
+ expression: 'lx.host.control?.appearance',
399
439
  members: CONTROL_APPEARANCE_API,
400
440
  optional: true,
401
441
  },
@@ -476,6 +516,7 @@ export const LX_RUNTIME_SURFACES = [
476
516
  },
477
517
  { name: 'lx.tray', layer: 'logic', expression: 'lx.tray', members: TRAY_API },
478
518
  { name: 'lx.fs', layer: 'logic', expression: 'lx.fs', members: FILE_SYSTEM_API },
519
+ { name: 'lx.clipboard', layer: 'logic', expression: 'lx.clipboard', members: CLIPBOARD_API },
479
520
  { name: 'Storage', layer: 'logic', expression: 'lx.getStorage()', members: STORAGE_API },
480
521
  { name: 'UpdateManager', layer: 'logic', expression: 'lx.getUpdateManager()', members: UPDATE_MANAGER_API },
481
522
  {
@@ -549,22 +590,11 @@ export const LX_RUNTIME_CAPABILITY_NAMES = LX_RUNTIME_SURFACES.flatMap(({ name,
549
590
  /** Canonical identifiers used by runtime shape automation coverage. */
550
591
  export const LX_RUNTIME_SHAPE_NAMES = LX_RUNTIME_CAPABILITY_NAMES.map((name) => `shape:${name}`);
551
592
 
552
- const DOWNLOAD_TASK_API = [
553
- 'abort',
554
- 'cancel',
555
- 'catch',
556
- 'finally',
557
- 'next',
558
- 'pause',
559
- 'resume',
560
- 'return',
561
- 'then',
562
- 'wait',
563
- ] as const;
564
- const UPLOAD_TASK_API = ['cancel', 'catch', 'finally', 'next', 'return', 'then', 'wait'] as const;
565
- const COMPRESS_VIDEO_TASK_API = ['cancel', 'catch', 'finally', 'next', 'return', 'then', 'wait'] as const;
566
- const HOST_UPDATE_INFO_API = ['apply', 'isForceUpdate', 'releaseNotes', 'size', 'version'] as const;
567
- const HOST_UPDATE_TASK_API = ['catch', 'finally', 'next', 'return', 'then', 'wait'] as const;
593
+ const DOWNLOAD_TASK_API = ["result", "progress", "pause", "resume", "cancel"] as const;
594
+ const UPLOAD_TASK_API = ["result", "progress", "cancel"] as const;
595
+ const COMPRESS_VIDEO_TASK_API = ["result", "progress", "cancel"] as const;
596
+ const HOST_UPDATE_INFO_API = ['apply', 'channel', 'releaseNotes', 'size', 'version'] as const;
597
+ const HOST_UPDATE_TASK_API = ["result", "progress"] as const;
568
598
  const PREVIEW_MEDIA_API = ['completed', 'current', 'onChange', 'presented'] as const;
569
599
  const PAGE_SURFACE_API = [
570
600
  'alive',
@@ -616,7 +646,7 @@ export const LX_RETURNED_OBJECT_SURFACES = [
616
646
  {
617
647
  name: 'DownloadTask',
618
648
  members: DOWNLOAD_TASK_API,
619
- properties: [],
649
+ properties: ['result', 'progress'],
620
650
  optionalProperties: [],
621
651
  fixture: 'external-service',
622
652
  factory: 'lx.downloadFile',
@@ -624,7 +654,7 @@ export const LX_RETURNED_OBJECT_SURFACES = [
624
654
  {
625
655
  name: 'UploadTask',
626
656
  members: UPLOAD_TASK_API,
627
- properties: [],
657
+ properties: ['result', 'progress'],
628
658
  optionalProperties: [],
629
659
  fixture: 'external-service',
630
660
  factory: 'lx.uploadFile',
@@ -632,7 +662,7 @@ export const LX_RETURNED_OBJECT_SURFACES = [
632
662
  {
633
663
  name: 'CompressVideoTask',
634
664
  members: COMPRESS_VIDEO_TASK_API,
635
- properties: [],
665
+ properties: ['result', 'progress'],
636
666
  optionalProperties: [],
637
667
  fixture: 'external-media',
638
668
  factory: 'lx.compressVideo',
@@ -640,15 +670,15 @@ export const LX_RETURNED_OBJECT_SURFACES = [
640
670
  {
641
671
  name: 'HostAppUpdateInfo',
642
672
  members: HOST_UPDATE_INFO_API,
643
- properties: ['isForceUpdate', 'releaseNotes', 'size', 'version'],
673
+ properties: ['channel', 'releaseNotes', 'size', 'version'],
644
674
  optionalProperties: ['releaseNotes', 'size'],
645
675
  fixture: 'external-service',
646
- factory: 'lx.app.checkUpdate().update',
676
+ factory: 'lx.host.checkUpdate().update',
647
677
  },
648
678
  {
649
679
  name: 'HostAppUpdateTask',
650
680
  members: HOST_UPDATE_TASK_API,
651
- properties: [],
681
+ properties: ['result', 'progress'],
652
682
  optionalProperties: [],
653
683
  fixture: 'external-service',
654
684
  factory: 'HostAppUpdateInfo.apply',
@@ -731,6 +761,8 @@ export type LxApiManifestGate = [
731
761
  AssertTrue<Exact<PublishedLx, typeof LX_API_NAMES>>,
732
762
  AssertTrue<Exact<HostAppApi, typeof HOST_APP_API>>,
733
763
  AssertTrue<Exact<AutostartApi, typeof AUTOSTART_API>>,
764
+ AssertTrue<Exact<BannerApi, typeof BANNER_API>>,
765
+ AssertTrue<Exact<NotificationApi, typeof NOTIFICATION_API>>,
734
766
  AssertTrue<Exact<AppCacheApi, typeof APP_CACHE_API>>,
735
767
  AssertTrue<Exact<DisplayLanguageApi, typeof DISPLAY_LANGUAGE_API>>,
736
768
  AssertTrue<Exact<ControlApi, typeof CONTROL_API>>,
@@ -749,6 +781,7 @@ export type LxApiManifestGate = [
749
781
  AssertTrue<Exact<ShellApi['sidebarActions'], typeof SHELL_SIDEBAR_ACTIONS_API>>,
750
782
  AssertTrue<Exact<TrayApi, typeof TRAY_API>>,
751
783
  AssertTrue<Exact<FileSystemApi, typeof FILE_SYSTEM_API>>,
784
+ AssertTrue<Exact<ClipboardApi, typeof CLIPBOARD_API>>,
752
785
  AssertTrue<Exact<LxFile, typeof LX_FILE_API>>,
753
786
  AssertTrue<Exact<Storage, typeof STORAGE_API>>,
754
787
  AssertTrue<Exact<UpdateManager, typeof UPDATE_MANAGER_API>>,
@@ -782,6 +815,6 @@ export type LxApiManifestGate = [
782
815
  AssertTrue<Exact<PreviewMediaHandle, typeof PREVIEW_MEDIA_API>>,
783
816
  AssertTrue<Exact<SurfaceApi, typeof SURFACE_NAMESPACE_API>>,
784
817
  AssertTrue<Exact<PageSurface, typeof PAGE_SURFACE_API>>,
785
- AssertTrue<Exact<TabSurface, typeof TAB_SURFACE_API>>,
818
+ AssertTrue<Exact<Extract<TabSurface, { scope: 'tab' }>, typeof TAB_SURFACE_API>>,
786
819
  AssertTrue<Exact<PageMessagePort, typeof PAGE_MESSAGE_PORT_API>>,
787
820
  ];