@lingxia/types 0.10.0 → 0.11.1

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 (130) hide show
  1. package/dist/automation/index.d.ts +942 -0
  2. package/dist/automation/index.d.ts.map +1 -0
  3. package/dist/automation/index.js +13 -0
  4. package/dist/automation/index.js.map +1 -0
  5. package/dist/generated/i18n.d.ts +1 -1
  6. package/dist/generated/i18n.d.ts.map +1 -1
  7. package/dist/generated/i18n.js +29 -0
  8. package/dist/generated/i18n.js.map +1 -1
  9. package/dist/generated/logic-web.d.ts +305 -0
  10. package/dist/generated/logic.d.ts +1909 -0
  11. package/dist/generated/logic.d.ts.map +1 -0
  12. package/dist/generated/logic.js +5 -0
  13. package/dist/generated/logic.js.map +1 -0
  14. package/dist/index.d.ts +16 -313
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +3 -16
  17. package/dist/index.js.map +1 -1
  18. package/dist/logic-globals.d.ts +1 -0
  19. package/dist/process.d.ts +117 -0
  20. package/dist/process.d.ts.map +1 -0
  21. package/dist/process.js +10 -0
  22. package/dist/process.js.map +1 -0
  23. package/package.json +73 -47
  24. package/src/automation/index.ts +1074 -0
  25. package/src/generated/i18n.ts +29 -0
  26. package/src/generated/logic-web.d.ts +305 -0
  27. package/src/generated/logic.ts +2123 -0
  28. package/src/index.ts +18 -459
  29. package/src/logic-globals.d.ts +1 -0
  30. package/src/process.ts +135 -0
  31. package/dist/app/index.d.ts +0 -328
  32. package/dist/app/index.d.ts.map +0 -1
  33. package/dist/app/index.js +0 -6
  34. package/dist/app/index.js.map +0 -1
  35. package/dist/device/actions.d.ts +0 -7
  36. package/dist/device/actions.d.ts.map +0 -1
  37. package/dist/device/actions.js +0 -6
  38. package/dist/device/actions.js.map +0 -1
  39. package/dist/device/index.d.ts +0 -5
  40. package/dist/device/index.d.ts.map +0 -1
  41. package/dist/device/index.js +0 -21
  42. package/dist/device/index.js.map +0 -1
  43. package/dist/device/info.d.ts +0 -16
  44. package/dist/device/info.d.ts.map +0 -1
  45. package/dist/device/info.js +0 -6
  46. package/dist/device/info.js.map +0 -1
  47. package/dist/device/network.d.ts +0 -12
  48. package/dist/device/network.d.ts.map +0 -1
  49. package/dist/device/network.js +0 -6
  50. package/dist/device/network.js.map +0 -1
  51. package/dist/device/wifi.d.ts +0 -20
  52. package/dist/device/wifi.d.ts.map +0 -1
  53. package/dist/device/wifi.js +0 -6
  54. package/dist/device/wifi.js.map +0 -1
  55. package/dist/display/index.d.ts +0 -8
  56. package/dist/display/index.d.ts.map +0 -1
  57. package/dist/display/index.js +0 -6
  58. package/dist/display/index.js.map +0 -1
  59. package/dist/env/index.d.ts +0 -8
  60. package/dist/env/index.d.ts.map +0 -1
  61. package/dist/env/index.js +0 -6
  62. package/dist/env/index.js.map +0 -1
  63. package/dist/file/index.d.ts +0 -146
  64. package/dist/file/index.d.ts.map +0 -1
  65. package/dist/file/index.js +0 -6
  66. package/dist/file/index.js.map +0 -1
  67. package/dist/input/index.d.ts +0 -18
  68. package/dist/input/index.d.ts.map +0 -1
  69. package/dist/input/index.js +0 -8
  70. package/dist/input/index.js.map +0 -1
  71. package/dist/location/index.d.ts +0 -19
  72. package/dist/location/index.d.ts.map +0 -1
  73. package/dist/location/index.js +0 -6
  74. package/dist/location/index.js.map +0 -1
  75. package/dist/lxapp/index.d.ts +0 -11
  76. package/dist/lxapp/index.d.ts.map +0 -1
  77. package/dist/lxapp/index.js +0 -6
  78. package/dist/lxapp/index.js.map +0 -1
  79. package/dist/media/index.d.ts +0 -372
  80. package/dist/media/index.d.ts.map +0 -1
  81. package/dist/media/index.js +0 -6
  82. package/dist/media/index.js.map +0 -1
  83. package/dist/navigator/index.d.ts +0 -14
  84. package/dist/navigator/index.d.ts.map +0 -1
  85. package/dist/navigator/index.js +0 -6
  86. package/dist/navigator/index.js.map +0 -1
  87. package/dist/share/index.d.ts +0 -90
  88. package/dist/share/index.d.ts.map +0 -1
  89. package/dist/share/index.js +0 -6
  90. package/dist/share/index.js.map +0 -1
  91. package/dist/storage/index.d.ts +0 -13
  92. package/dist/storage/index.d.ts.map +0 -1
  93. package/dist/storage/index.js +0 -6
  94. package/dist/storage/index.js.map +0 -1
  95. package/dist/system/index.d.ts +0 -9
  96. package/dist/system/index.d.ts.map +0 -1
  97. package/dist/system/index.js +0 -6
  98. package/dist/system/index.js.map +0 -1
  99. package/dist/transfer/index.d.ts +0 -166
  100. package/dist/transfer/index.d.ts.map +0 -1
  101. package/dist/transfer/index.js +0 -6
  102. package/dist/transfer/index.js.map +0 -1
  103. package/dist/ui/index.d.ts +0 -134
  104. package/dist/ui/index.d.ts.map +0 -1
  105. package/dist/ui/index.js +0 -6
  106. package/dist/ui/index.js.map +0 -1
  107. package/dist/update/index.d.ts +0 -17
  108. package/dist/update/index.d.ts.map +0 -1
  109. package/dist/update/index.js +0 -6
  110. package/dist/update/index.js.map +0 -1
  111. package/src/app/index.ts +0 -378
  112. package/src/device/actions.ts +0 -7
  113. package/src/device/index.ts +0 -4
  114. package/src/device/info.ts +0 -17
  115. package/src/device/network.ts +0 -23
  116. package/src/device/wifi.ts +0 -23
  117. package/src/display/index.ts +0 -9
  118. package/src/env/index.ts +0 -8
  119. package/src/file/index.ts +0 -171
  120. package/src/input/index.ts +0 -19
  121. package/src/location/index.ts +0 -20
  122. package/src/lxapp/index.ts +0 -12
  123. package/src/media/index.ts +0 -411
  124. package/src/navigator/index.ts +0 -16
  125. package/src/share/index.ts +0 -97
  126. package/src/storage/index.ts +0 -13
  127. package/src/system/index.ts +0 -9
  128. package/src/transfer/index.ts +0 -194
  129. package/src/ui/index.ts +0 -165
  130. package/src/update/index.ts +0 -19
package/src/index.ts CHANGED
@@ -4,477 +4,36 @@
4
4
  * Type declarations for the LingXia JS API, driven by Rust implementation.
5
5
  */
6
6
 
7
- export * from './app';
8
- export * from './lxapp';
9
- export * from './device';
10
- export * from './display';
11
- export * from './input';
12
- export * from './env';
13
- export * from './storage';
14
- export * from './file';
15
- export * from './transfer';
16
- export * from './location';
17
- export * from './navigator';
18
- export * from './system';
19
- export * from './update';
20
- export * from './media';
21
- export * from './share';
22
- export * from './ui';
7
+ export * from './generated/logic';
8
+ export * from './automation';
23
9
  export * from './error';
24
10
  export * from './generated/error';
25
11
  export * from './generated/i18n';
26
12
 
13
+ import './generated/logic';
14
+
27
15
  import type {
28
16
  AppConfig,
29
17
  AppInstance,
30
- HostAppApi,
31
- PageMessagePort,
32
18
  PageConfig,
33
19
  PageInstance,
34
- Surface,
35
- SurfaceHandle,
36
- } from './app';
37
-
38
- import type {
39
- LxAppInfo,
40
- } from './lxapp';
41
-
42
- import type {
43
- DeviceInfo,
44
- ScreenInfo,
45
- MakePhoneCallOptions,
46
- WifiInfo,
47
- ConnectWifiOptions,
48
- WifiConnectedCallback,
49
- NetworkInfo,
50
- NetworkChangeCallback,
51
- } from './device';
52
-
53
- import type { KeyEventCallback } from './input';
54
-
55
- import type { LxEnv } from './env';
56
-
57
- import type { Storage } from './storage';
58
-
59
- import type {
60
- OpenFileOptions,
61
- ChooseDirectoryOptions,
62
- ChooseDirectoryResult,
63
- ChooseFileOptions,
64
- ChooseFileResult,
65
- FileManager,
66
- } from './file';
67
-
68
- import type {
69
- AppDownloadOptions,
70
- AppDownloadResult,
71
- DownloadDestination,
72
- DownloadOptions,
73
- DownloadResultForDestination,
74
- DownloadTask,
75
- DownloadsDownloadOptions,
76
- DownloadsDownloadResult,
77
- UploadOptions,
78
- UploadTask,
79
- } from './transfer';
80
-
81
- import type {
82
- DeviceOrientation,
83
- DeviceOrientationChangeEvent,
84
- } from './display';
85
-
86
- import type {
87
- GetLocationOptions,
88
- LocationInfo,
89
- } from './location';
90
-
91
- import type {
92
- SystemSettingInfo,
93
- } from './system';
94
-
95
- import type { NavigateToLxAppOptions } from './navigator';
96
-
97
- import type { UpdateManager } from './update';
98
-
99
- import type {
100
- GetImageInfoOptions,
101
- ImageInfo,
102
- CompressImageOptions,
103
- CompressImageResult,
104
- CompressVideoOptions,
105
- CompressVideoTask,
106
- GetVideoInfoOptions,
107
- VideoInfo,
108
- ExtractVideoThumbnailOptions,
109
- ExtractVideoThumbnailResult,
110
- ChooseMediaOptions,
111
- ChosenMediaEntry,
112
- PreviewMediaHandle,
113
- PreviewMediaOptions,
114
- SaveMediaOptions,
115
- ScanCodeOptions,
116
- ScanCodeResult,
117
- VideoContext,
118
- } from './media';
119
-
120
- import type {
121
- ShareOptions,
122
- ShareResult,
123
- } from './share';
124
-
125
- import type {
126
- ShowToastOptions,
127
- ShowModalOptions,
128
- ModalResult,
129
- ShowActionSheetOptions,
130
- ActionSheetResult,
131
- NavigateToOptions,
132
- NavigateBackOptions,
133
- RedirectToOptions,
134
- SwitchTabOptions,
135
- ReLaunchOptions,
136
- SetNavigationBarTitleOptions,
137
- SetNavigationBarColorOptions,
138
- TabBarRedDotOptions,
139
- SetTabBarBadgeOptions,
140
- RemoveTabBarBadgeOptions,
141
- SetTabBarStyleOptions,
142
- SetTabBarItemOptions,
143
- SurfaceEdge,
144
- SurfaceFloatPosition,
145
- OverlaySurfaceSize,
146
- SurfaceContext,
147
- CapsuleRect,
148
- } from './ui';
149
-
150
- interface WindowSurfaceSize {
151
- /** Initial window width in logical pixels. */
152
- width?: number;
153
- /** Initial window height in logical pixels. */
154
- height?: number;
155
- }
156
-
157
- /**
158
- * Spec for {@link Lx.openSurface}. A discriminated union keyed by source so a
159
- * page name and a declared surface id never collide (each is its own string
160
- * space, separately type-checkable).
161
- *
162
- * - `{ page }` — one of this lxapp's own pages, by name, arranged as `as`
163
- * (`aside` is a companion of the main; `float` is a popup; `window` is a bare
164
- * desktop window, which rejects on mobile). `edge` applies to `aside`,
165
- * `position` applies to `float`, and `size` is a Host-clamped hint. They are
166
- * fixed at open (re-open to change).
167
- *
168
- * `aside` is **size-class adaptive**, not a fixed form: only on `medium` /
169
- * `expanded` (room to sit alongside) does it dock and split beside the main at
170
- * `edge` as a sidebar/split panel. On `compact` (phone, or a folded foldable)
171
- * there is no room to dock, so the same surface presents **full-screen** —
172
- * pushed over the main and dismissed by the host back affordance / edge swipe
173
- * (a drill-in), never a docked panel. So one declaration reads as a side panel
174
- * on large screens and a full-screen drill-in on small ones. For a destination
175
- * that should stay switchable on phones, declare it `role: main` instead.
176
- *
177
- * `float` is a popup layered above the main at `position` (like a dialog); it
178
- * takes no layout space. The SDK gives it **no chrome of its own — there is no
179
- * built-in close button**: the lxapp owns the popup UI and dismisses it by
180
- * calling `surface.close()` (or `.hide()`). A float sized to the full container
181
- * (`size: { width: '100%', height: '100%' }`) presents immersively on mobile
182
- * (system bars hidden) and is likewise chrome-less — draw your own close
183
- * affordance. (iOS retains a silent left-edge swipe as a last-resort escape so a
184
- * full-screen float can never trap the user; don't rely on it as the primary
185
- * dismissal.)
186
- * - `{ surface }` — a surface declared in `lingxia.yaml` `surfaces:`, by id
187
- * (e.g. `'terminal'`, `'ai-assistant'`). Form, position, and startup data come
188
- * from the declaration.
189
- * - `{ url }` — an `http(s)://` or `lingxia://` url, shown in the in-app chromed
190
- * browser (always with an address bar — never a chromeless embed). Without
191
- * `as` it opens as a main browser tab (host chrome, no handle). With
192
- * `as: 'aside'` it docks an `http(s)://` page beside the main as a single
193
- * browser aside (its own chrome + close, returns a closable handle); `edge`
194
- * defaults to `'right'` and `size` is a host-clamped preferred size. At most
195
- * one browser aside per window — a new one replaces the existing one.
196
- */
197
- export type OpenPageSurfaceSpec =
198
- | {
199
- page: string;
200
- as: 'aside';
201
- edge?: SurfaceEdge;
202
- size?: OverlaySurfaceSize;
203
- query?: Record<string, unknown>;
204
- position?: never;
205
- surface?: never;
206
- url?: never;
207
- }
208
- | {
209
- page: string;
210
- /**
211
- * A chrome-less popup above the main: the lxapp draws its own UI and close
212
- * affordance — there is no SDK-provided close button (see
213
- * {@link OpenPageSurfaceSpec}).
214
- */
215
- as: 'float';
216
- position?: SurfaceFloatPosition;
217
- size?: OverlaySurfaceSize;
218
- query?: Record<string, unknown>;
219
- edge?: never;
220
- surface?: never;
221
- url?: never;
222
- }
223
- | {
224
- page: string;
225
- as: 'window';
226
- size?: WindowSurfaceSize;
227
- query?: Record<string, unknown>;
228
- edge?: never;
229
- position?: never;
230
- surface?: never;
231
- url?: never;
232
- };
233
-
234
- export interface OpenDeclaredSurfaceSpec {
235
- surface: string;
236
- page?: never;
237
- url?: never;
238
- as?: never;
239
- edge?: never;
240
- position?: never;
241
- size?: never;
242
- query?: never;
243
- }
244
-
245
- export interface OpenUrlTabSpec {
246
- url: string;
247
- as?: never;
248
- page?: never;
249
- surface?: never;
250
- edge?: never;
251
- position?: never;
252
- size?: never;
253
- query?: never;
254
- }
255
-
256
- export interface OpenUrlAsideSpec {
257
- url: string;
258
- as: 'aside';
259
- edge?: SurfaceEdge;
260
- size?: OverlaySurfaceSize;
261
- page?: never;
262
- surface?: never;
263
- position?: never;
264
- query?: never;
265
- }
20
+ } from './generated/logic';
21
+ import type { Automation } from './automation';
266
22
 
267
- export type OpenSurfaceSpec =
268
- | OpenPageSurfaceSpec
269
- | OpenDeclaredSurfaceSpec
270
- | OpenUrlTabSpec
271
- | OpenUrlAsideSpec;
272
-
273
- /**
274
- * Runtime control of the menu-bar (macOS) / system-tray (Windows) status item.
275
- * The tray is declared in `lingxia.yaml` (`tray:`); these update its dynamic
276
- * content at runtime.
277
- *
278
- * **Desktop only.** Mobile platforms have no tray, so every method here is a
279
- * no-op there (it never throws) — safe to call from portable code. For an
280
- * app-icon badge that *is* cross-platform (including mobile), use
281
- * {@link HostAppApi.setBadge}.
282
- */
283
- export interface TrayMenuItem {
284
- label: string;
285
- /** Invoked when this item is clicked. */
286
- onClick?: () => void;
287
- enabled?: boolean;
288
- checked?: boolean;
289
- }
290
-
291
- export interface TrayMenuSeparator {
292
- separator: true;
293
- }
294
-
295
- export interface TrayApi {
296
- /** Replace the status-item icon (a resource path). */
297
- setIcon(icon: string): void;
298
- /** Set the text shown beside the icon (macOS). Pass `null`/empty to clear. */
299
- setTitle(text: string | null): void;
300
- /** Set the badge — e.g. an unread count. Pass `null`/empty to clear. */
301
- setBadge(value: string | number | null): void;
302
- /**
303
- * Replace the right-click dropdown menu. There is no default menu — provide
304
- * your own items (e.g. `{ label: 'Quit', onClick: () => lx.app.exit() }`).
305
- *
306
- * The menu is a snapshot: to change an item's `checked`/`enabled`/`label`
307
- * state, call `setMenu` again with the full updated array. There is no
308
- * per-item mutation API.
309
- */
310
- setMenu(items: Array<TrayMenuItem | TrayMenuSeparator>): void;
311
- /**
312
- * Handle a left-click on the tray icon yourself. While a handler is
313
- * registered the click runs only the handler — the tray's configured surface
314
- * `action` is suppressed, so the click is fully yours (e.g. toggle a state and
315
- * `setIcon`). Returns an unsubscribe function.
316
- */
317
- onClick(handler: () => void): () => void;
318
- /** Show the tray status item. */
319
- show(): void;
320
- /** Hide the tray status item (without removing the app). */
321
- hide(): void;
322
- }
323
-
324
- export interface Lx {
325
- env: LxEnv;
326
- app: HostAppApi;
327
- tray: TrayApi;
328
-
329
- /**
330
- * Open a surface.
331
- *
332
- * - `{ url }` without `as` opens a host browser tab and resolves to `null`.
333
- * - `{ surface }` resolves to a host-managed handle with show/hide/close.
334
- * - page surfaces and `{ url, as: 'aside' }` resolve to a full Surface handle.
335
- *
336
- * `as: 'window'` is desktop-only and rejects on mobile. See
337
- * {@link OpenSurfaceSpec}.
338
- */
339
- openSurface(spec: OpenUrlTabSpec): Promise<null>;
340
- openSurface(spec: OpenDeclaredSurfaceSpec): Promise<SurfaceHandle>;
341
- openSurface(spec: OpenPageSurfaceSpec | OpenUrlAsideSpec): Promise<Surface>;
342
- openSurface(spec: OpenSurfaceSpec): Promise<Surface | SurfaceHandle | null>;
343
- /** Hand a url off to the OS default browser (leaves the app). */
344
- openExternal(url: string): void;
345
- /**
346
- * Subscribe to adaptive-context changes ({@link SurfaceContext}); the handler
347
- * fires with the new context. Returns an unsubscribe function.
348
- */
349
- onSurfaceContext(handler: (context: SurfaceContext) => void): () => void;
350
-
351
- getDeviceInfo(): DeviceInfo;
352
- getScreenInfo(): ScreenInfo;
353
- vibrateShort(): boolean;
354
- vibrateLong(): boolean;
355
- makePhoneCall(options: MakePhoneCallOptions): boolean;
356
-
357
- startWifi(): Promise<void>;
358
- stopWifi(): Promise<void>;
359
- connectWifi(options: ConnectWifiOptions): Promise<void>;
360
- getWifiList(): Promise<WifiInfo[]>;
361
- getConnectedWifi(): Promise<WifiInfo>;
362
- onWifiConnected(callback: WifiConnectedCallback): void;
363
- offWifiConnected(callback?: WifiConnectedCallback): void;
364
- getNetworkInfo(): Promise<NetworkInfo>;
365
- onNetworkChange(callback: NetworkChangeCallback): void;
366
- offNetworkChange(callback?: NetworkChangeCallback): void;
367
-
368
- setDeviceOrientation(orientation: DeviceOrientation): boolean;
369
- onDeviceOrientationChange(callback: (event: DeviceOrientationChangeEvent) => void): void;
370
- offDeviceOrientationChange(callback?: (event: DeviceOrientationChangeEvent) => void): void;
371
-
372
- /**
373
- * Open a local file with the requested strategy.
374
- * Use `mode: 'review'` when the UX requires in-app preview,
375
- * otherwise prefer `mode: 'auto'`.
376
- */
377
- openFile(options: OpenFileOptions): void;
378
- downloadFile(options: DownloadsDownloadOptions): DownloadTask<DownloadsDownloadResult>;
379
- downloadFile(options: AppDownloadOptions): DownloadTask<AppDownloadResult>;
380
- downloadFile<TDestination extends DownloadDestination = 'app'>(
381
- options: DownloadOptions<TDestination>,
382
- ): DownloadTask<DownloadResultForDestination<TDestination>>;
383
- uploadFile(options: UploadOptions): UploadTask;
384
- getFileManager(): FileManager;
385
-
386
- getStorage(): Storage;
387
-
388
- getLocation(options?: GetLocationOptions): Promise<LocationInfo>;
389
-
390
- navigateToLxApp(options: NavigateToLxAppOptions): Promise<void>;
391
- navigateBackLxApp(): Promise<void>;
392
-
393
- getLxAppInfo(): LxAppInfo;
394
- getSystemSetting(): SystemSettingInfo;
395
-
396
- getUpdateManager(): UpdateManager;
397
-
398
- getImageInfo(options: GetImageInfoOptions): Promise<ImageInfo>;
399
- compressImage(options: CompressImageOptions): Promise<CompressImageResult>;
400
- compressVideo(options: CompressVideoOptions): CompressVideoTask;
401
- getVideoInfo(options: GetVideoInfoOptions): Promise<VideoInfo>;
402
- extractVideoThumbnail(options: ExtractVideoThumbnailOptions): Promise<ExtractVideoThumbnailResult>;
403
-
404
- chooseMedia(options?: ChooseMediaOptions): Promise<ChosenMediaEntry[]>;
405
-
406
- /**
407
- * Opens native media preview.
408
- *
409
- * Supports:
410
- * - a single source path string for the simplest case
411
- * - a single-item object for per-item options like `rotate`, `objectFit`, or `durationMs`
412
- * - a sequence object for multi-item preview with `sources`, `startIndex`, and `advance`
413
- *
414
- * Returns a {@link PreviewMediaHandle} synchronously. Await `handle.completed`
415
- * for the final session result (`reason`, `index`, `source` — the item the
416
- * user was viewing when the preview closed). Subscribe to
417
- * `handle.onChange(...)` / read `handle.current` to follow the viewed item
418
- * live, and to `handle.presented` to learn when the first pixel hits the
419
- * screen — useful for coordinating a hide of any overlay surface that was
420
- * previously visible.
421
- *
422
- * `handle.completed` rejects with a cancellation error if `signal` is aborted;
423
- * abort also requests the active native preview session to close immediately.
424
- * `handle.presented` never rejects.
425
- */
426
- previewMedia(options: PreviewMediaOptions): PreviewMediaHandle;
427
-
428
- saveImageToPhotosAlbum(options: SaveMediaOptions): Promise<void>;
429
- saveVideoToPhotosAlbum(options: SaveMediaOptions): Promise<void>;
430
-
431
- scanCode(options?: ScanCodeOptions): Promise<ScanCodeResult>;
432
-
433
- share(options: ShareOptions): Promise<ShareResult>;
434
-
435
- createVideoContext(componentId: string): VideoContext;
436
-
437
- showToast(options: ShowToastOptions): void;
438
- hideToast(): void;
439
-
440
- showModal(options: ShowModalOptions): Promise<ModalResult>;
441
-
442
- showActionSheet(options: ShowActionSheetOptions): Promise<ActionSheetResult>;
443
-
444
- navigateTo(options: NavigateToOptions): Promise<PageMessagePort>;
445
- navigateBack(options: NavigateBackOptions): void;
446
- redirectTo(options: RedirectToOptions): Promise<void>;
447
- switchTab(options: SwitchTabOptions): Promise<void>;
448
- reLaunch(options: ReLaunchOptions): Promise<void>;
449
-
450
- setNavigationBarTitle(options: SetNavigationBarTitleOptions): boolean;
451
- setNavigationBarColor(options: SetNavigationBarColorOptions): boolean;
452
- hideHomeButton(): boolean;
453
-
454
- showTabBarRedDot(options: TabBarRedDotOptions): boolean;
455
- hideTabBarRedDot(options: TabBarRedDotOptions): boolean;
456
- setTabBarBadge(options: SetTabBarBadgeOptions): boolean;
457
- removeTabBarBadge(options: RemoveTabBarBadgeOptions): boolean;
458
- showTabBar(): boolean;
459
- hideTabBar(): boolean;
460
- setTabBarStyle(options: SetTabBarStyleOptions): boolean;
461
- setTabBarItem(options: SetTabBarItemOptions): boolean;
462
-
463
- startPullDownRefresh(): void;
464
- stopPullDownRefresh(): void;
465
-
466
- getCapsuleRect(): Promise<CapsuleRect>;
467
-
468
- chooseFile(options?: ChooseFileOptions): Promise<ChooseFileResult>;
469
- chooseDirectory(options?: ChooseDirectoryOptions): Promise<ChooseDirectoryResult>;
470
-
471
- onKeyDown(callback: KeyEventCallback): void;
472
- offKeyDown(callback?: KeyEventCallback): void;
473
- onKeyUp(callback: KeyEventCallback): void;
474
- offKeyUp(callback?: KeyEventCallback): void;
475
- }
23
+ export type Lx = globalThis.Lx;
476
24
 
477
25
  declare global {
26
+ interface Lx {
27
+ /**
28
+ * In-process UI/runtime automation.
29
+ *
30
+ * Select the current app with `.lxapp()` or a specific running app with
31
+ * `.lxapp(appid)`. Host-only surfaces enforce the `host` privilege when
32
+ * selected; `lingxia dev` and the Runner grant it implicitly.
33
+ */
34
+ automation(): Automation;
35
+ }
36
+
478
37
  const lx: Lx;
479
38
 
480
39
  function App(config: AppConfig): AppInstance;
@@ -0,0 +1 @@
1
+ /// <reference path="./generated/logic-web.d.ts" />
package/src/process.ts ADDED
@@ -0,0 +1,135 @@
1
+ /**
2
+ * OS process capability for trusted LingXia home lxapps.
3
+ *
4
+ * Add `@lingxia/types/process` to the Logic tsconfig only when the host sets
5
+ * `capabilities.process: true` and the home lxapp declares the `process`
6
+ * security privilege. These declarations have no runtime payload.
7
+ */
8
+
9
+ export type RongSpawnStdio = "pipe" | "ignore" | "inherit";
10
+ export type RongEnvMap = Record<string, string | undefined>;
11
+
12
+ export interface RongSpawnOptions {
13
+ cwd?: string;
14
+ env?: RongEnvMap;
15
+ shell?: boolean;
16
+ stdin?: "pipe" | string | ArrayBuffer | ArrayBufferView | null;
17
+ stdout?: RongSpawnStdio;
18
+ stderr?: RongSpawnStdio;
19
+ timeout?: number;
20
+ killSignal?: string | number;
21
+ signal?: AbortSignal;
22
+ onExit?(
23
+ subprocess: RongSubprocess,
24
+ exitCode: number | null,
25
+ signalCode: number | null,
26
+ error?: unknown,
27
+ ): void | Promise<void>;
28
+ }
29
+
30
+ export interface RongSpawnOptionsWithCmd extends RongSpawnOptions {
31
+ cmd: string[];
32
+ }
33
+
34
+ export interface RongSyncSubprocess {
35
+ readonly exitCode: number | null;
36
+ readonly success: boolean;
37
+ readonly signalCode: number | null;
38
+ readonly stdout: Uint8Array;
39
+ readonly stderr: Uint8Array;
40
+ }
41
+
42
+ export interface RongReadableProcessStream extends ReadableStream<Uint8Array> {
43
+ bytes(): Promise<Uint8Array>;
44
+ text(): Promise<string>;
45
+ json(): Promise<unknown>;
46
+ blob(): Promise<Blob>;
47
+ lines(): AsyncIterableIterator<string>;
48
+ }
49
+
50
+ export interface RongOutputHandle {
51
+ write(chunk: string | ArrayBuffer | ArrayBufferView): void;
52
+ flush(): void;
53
+ }
54
+
55
+ export interface RongWritableProcessStream extends WritableStream<Uint8Array> {
56
+ write(chunk: string | ArrayBuffer | ArrayBufferView): Promise<this>;
57
+ flush(): Promise<void>;
58
+ end(): Promise<void>;
59
+ }
60
+
61
+ export interface RongSubprocess {
62
+ readonly pid: number | null;
63
+ readonly exitCode: number | null;
64
+ readonly signalCode: number | null;
65
+ readonly killed: boolean;
66
+ readonly success: boolean;
67
+ readonly exited: Promise<number | null>;
68
+ stdin: RongWritableProcessStream | null;
69
+ stdout: RongReadableProcessStream | null;
70
+ stderr: RongReadableProcessStream | null;
71
+ kill(signal?: string | number): boolean;
72
+ wait(): Promise<number | null>;
73
+ unref(): void;
74
+ }
75
+
76
+ export interface RongShellResult {
77
+ stdout: Uint8Array;
78
+ stderr: Uint8Array;
79
+ exitCode: number | null;
80
+ success: boolean;
81
+ }
82
+
83
+ export interface RongShellCommand extends PromiseLike<RongShellResult> {
84
+ cwd(path: string): RongShellCommand;
85
+ env(values: RongEnvMap): RongShellCommand;
86
+ quiet(): RongShellCommand;
87
+ nothrow(): RongShellCommand;
88
+ throws(value?: boolean): RongShellCommand;
89
+ run(): Promise<RongShellResult>;
90
+ text(): Promise<string>;
91
+ json(): Promise<unknown>;
92
+ blob(): Promise<Blob>;
93
+ lines(): AsyncIterableIterator<string>;
94
+ }
95
+
96
+ export interface RongShellTag {
97
+ (strings: TemplateStringsArray, ...values: unknown[]): RongShellCommand;
98
+ (command: string): RongShellCommand;
99
+ cwd(path?: string): string | RongShellTag | undefined;
100
+ env(values?: RongEnvMap): RongEnvMap | RongShellTag | undefined;
101
+ throws(value?: boolean): RongShellTag;
102
+ nothrow(): RongShellTag;
103
+ quiet(): RongShellTag;
104
+ escape(value: unknown): string;
105
+ }
106
+
107
+ export interface RongShellError extends Error {
108
+ command: string;
109
+ exitCode: number | null;
110
+ stdout: Uint8Array;
111
+ stderr: Uint8Array;
112
+ }
113
+
114
+ declare global {
115
+ /** Process APIs exposed only by a host with `capabilities.process`. */
116
+ interface RongNamespace {
117
+ readonly argv: string[];
118
+ readonly args: string[];
119
+ readonly env: RongEnvMap;
120
+ readonly stdin: RongReadableProcessStream;
121
+ readonly stdout: RongOutputHandle;
122
+ readonly stderr: RongOutputHandle;
123
+ spawn(cmd: string[], options?: RongSpawnOptions): RongSubprocess;
124
+ spawn(options: RongSpawnOptionsWithCmd): RongSubprocess;
125
+ spawnSync(cmd: string[], options?: RongSpawnOptions): RongSyncSubprocess;
126
+ spawnSync(options: RongSpawnOptionsWithCmd): RongSyncSubprocess;
127
+ readonly $: RongShellTag;
128
+ readonly ShellError: {
129
+ new (message: string): RongShellError;
130
+ prototype: RongShellError;
131
+ };
132
+ }
133
+
134
+ const Rong: RongNamespace;
135
+ }