@lingxia/types 0.9.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.
- package/dist/automation/index.d.ts +942 -0
- package/dist/automation/index.d.ts.map +1 -0
- package/dist/automation/index.js +13 -0
- package/dist/automation/index.js.map +1 -0
- package/dist/generated/i18n.d.ts +1 -1
- package/dist/generated/i18n.d.ts.map +1 -1
- package/dist/generated/i18n.js +44 -22
- package/dist/generated/i18n.js.map +1 -1
- package/dist/generated/logic-web.d.ts +305 -0
- package/dist/generated/logic.d.ts +1909 -0
- package/dist/generated/logic.d.ts.map +1 -0
- package/dist/generated/logic.js +5 -0
- package/dist/generated/logic.js.map +1 -0
- package/dist/index.d.ts +16 -139
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -16
- package/dist/index.js.map +1 -1
- package/dist/logic-globals.d.ts +1 -0
- package/dist/process.d.ts +117 -0
- package/dist/process.d.ts.map +1 -0
- package/dist/process.js +10 -0
- package/dist/process.js.map +1 -0
- package/package.json +73 -47
- package/src/automation/index.ts +1074 -0
- package/src/generated/i18n.ts +44 -22
- package/src/generated/logic-web.d.ts +305 -0
- package/src/generated/logic.ts +2123 -0
- package/src/index.ts +18 -258
- package/src/logic-globals.d.ts +1 -0
- package/src/process.ts +135 -0
- package/dist/app/index.d.ts +0 -278
- package/dist/app/index.d.ts.map +0 -1
- package/dist/app/index.js +0 -6
- package/dist/app/index.js.map +0 -1
- package/dist/device/actions.d.ts +0 -7
- package/dist/device/actions.d.ts.map +0 -1
- package/dist/device/actions.js +0 -6
- package/dist/device/actions.js.map +0 -1
- package/dist/device/index.d.ts +0 -5
- package/dist/device/index.d.ts.map +0 -1
- package/dist/device/index.js +0 -21
- package/dist/device/index.js.map +0 -1
- package/dist/device/info.d.ts +0 -16
- package/dist/device/info.d.ts.map +0 -1
- package/dist/device/info.js +0 -6
- package/dist/device/info.js.map +0 -1
- package/dist/device/network.d.ts +0 -12
- package/dist/device/network.d.ts.map +0 -1
- package/dist/device/network.js +0 -6
- package/dist/device/network.js.map +0 -1
- package/dist/device/wifi.d.ts +0 -20
- package/dist/device/wifi.d.ts.map +0 -1
- package/dist/device/wifi.js +0 -6
- package/dist/device/wifi.js.map +0 -1
- package/dist/display/index.d.ts +0 -8
- package/dist/display/index.d.ts.map +0 -1
- package/dist/display/index.js +0 -6
- package/dist/display/index.js.map +0 -1
- package/dist/env/index.d.ts +0 -8
- package/dist/env/index.d.ts.map +0 -1
- package/dist/env/index.js +0 -6
- package/dist/env/index.js.map +0 -1
- package/dist/file/index.d.ts +0 -146
- package/dist/file/index.d.ts.map +0 -1
- package/dist/file/index.js +0 -6
- package/dist/file/index.js.map +0 -1
- package/dist/input/index.d.ts +0 -18
- package/dist/input/index.d.ts.map +0 -1
- package/dist/input/index.js +0 -8
- package/dist/input/index.js.map +0 -1
- package/dist/location/index.d.ts +0 -19
- package/dist/location/index.d.ts.map +0 -1
- package/dist/location/index.js +0 -6
- package/dist/location/index.js.map +0 -1
- package/dist/lxapp/index.d.ts +0 -11
- package/dist/lxapp/index.d.ts.map +0 -1
- package/dist/lxapp/index.js +0 -6
- package/dist/lxapp/index.js.map +0 -1
- package/dist/media/index.d.ts +0 -313
- package/dist/media/index.d.ts.map +0 -1
- package/dist/media/index.js +0 -6
- package/dist/media/index.js.map +0 -1
- package/dist/navigator/index.d.ts +0 -14
- package/dist/navigator/index.d.ts.map +0 -1
- package/dist/navigator/index.js +0 -6
- package/dist/navigator/index.js.map +0 -1
- package/dist/share/index.d.ts +0 -90
- package/dist/share/index.d.ts.map +0 -1
- package/dist/share/index.js +0 -6
- package/dist/share/index.js.map +0 -1
- package/dist/storage/index.d.ts +0 -13
- package/dist/storage/index.d.ts.map +0 -1
- package/dist/storage/index.js +0 -6
- package/dist/storage/index.js.map +0 -1
- package/dist/system/index.d.ts +0 -13
- package/dist/system/index.d.ts.map +0 -1
- package/dist/system/index.js +0 -6
- package/dist/system/index.js.map +0 -1
- package/dist/transfer/index.d.ts +0 -121
- package/dist/transfer/index.d.ts.map +0 -1
- package/dist/transfer/index.js +0 -6
- package/dist/transfer/index.js.map +0 -1
- package/dist/ui/index.d.ts +0 -147
- package/dist/ui/index.d.ts.map +0 -1
- package/dist/ui/index.js +0 -6
- package/dist/ui/index.js.map +0 -1
- package/dist/update/index.d.ts +0 -17
- package/dist/update/index.d.ts.map +0 -1
- package/dist/update/index.js +0 -6
- package/dist/update/index.js.map +0 -1
- package/src/app/index.ts +0 -323
- package/src/device/actions.ts +0 -7
- package/src/device/index.ts +0 -4
- package/src/device/info.ts +0 -17
- package/src/device/network.ts +0 -23
- package/src/device/wifi.ts +0 -23
- package/src/display/index.ts +0 -9
- package/src/env/index.ts +0 -8
- package/src/file/index.ts +0 -171
- package/src/input/index.ts +0 -19
- package/src/location/index.ts +0 -20
- package/src/lxapp/index.ts +0 -12
- package/src/media/index.ts +0 -343
- package/src/navigator/index.ts +0 -16
- package/src/share/index.ts +0 -97
- package/src/storage/index.ts +0 -13
- package/src/system/index.ts +0 -14
- package/src/transfer/index.ts +0 -136
- package/src/ui/index.ts +0 -180
- package/src/update/index.ts +0 -19
package/src/index.ts
CHANGED
|
@@ -4,276 +4,36 @@
|
|
|
4
4
|
* Type declarations for the LingXia JS API, driven by Rust implementation.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
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
|
-
|
|
35
|
-
} from './
|
|
36
|
-
|
|
37
|
-
import type {
|
|
38
|
-
LxAppInfo,
|
|
39
|
-
} from './lxapp';
|
|
40
|
-
|
|
41
|
-
import type {
|
|
42
|
-
DeviceInfo,
|
|
43
|
-
ScreenInfo,
|
|
44
|
-
MakePhoneCallOptions,
|
|
45
|
-
WifiInfo,
|
|
46
|
-
ConnectWifiOptions,
|
|
47
|
-
WifiConnectedCallback,
|
|
48
|
-
NetworkInfo,
|
|
49
|
-
NetworkChangeCallback,
|
|
50
|
-
} from './device';
|
|
51
|
-
|
|
52
|
-
import type { KeyEventCallback } from './input';
|
|
53
|
-
|
|
54
|
-
import type { LxEnv } from './env';
|
|
55
|
-
|
|
56
|
-
import type { Storage } from './storage';
|
|
57
|
-
|
|
58
|
-
import type {
|
|
59
|
-
OpenFileOptions,
|
|
60
|
-
ChooseDirectoryOptions,
|
|
61
|
-
ChooseDirectoryResult,
|
|
62
|
-
ChooseFileOptions,
|
|
63
|
-
ChooseFileResult,
|
|
64
|
-
FileManager,
|
|
65
|
-
} from './file';
|
|
66
|
-
|
|
67
|
-
import type {
|
|
68
|
-
DownloadOptions,
|
|
69
|
-
DownloadTask,
|
|
70
|
-
UploadOptions,
|
|
71
|
-
UploadTask,
|
|
72
|
-
} from './transfer';
|
|
73
|
-
|
|
74
|
-
import type {
|
|
75
|
-
DeviceOrientation,
|
|
76
|
-
DeviceOrientationChangeEvent,
|
|
77
|
-
} from './display';
|
|
78
|
-
|
|
79
|
-
import type {
|
|
80
|
-
GetLocationOptions,
|
|
81
|
-
LocationInfo,
|
|
82
|
-
} from './location';
|
|
83
|
-
|
|
84
|
-
import type {
|
|
85
|
-
SystemSettingInfo,
|
|
86
|
-
OpenURLOptions,
|
|
87
|
-
} from './system';
|
|
88
|
-
|
|
89
|
-
import type { NavigateToLxAppOptions } from './navigator';
|
|
90
|
-
|
|
91
|
-
import type { UpdateManager } from './update';
|
|
92
|
-
|
|
93
|
-
import type {
|
|
94
|
-
GetImageInfoOptions,
|
|
95
|
-
ImageInfo,
|
|
96
|
-
CompressImageOptions,
|
|
97
|
-
CompressImageResult,
|
|
98
|
-
CompressVideoOptions,
|
|
99
|
-
CompressVideoResult,
|
|
100
|
-
GetVideoInfoOptions,
|
|
101
|
-
VideoInfo,
|
|
102
|
-
ExtractVideoThumbnailOptions,
|
|
103
|
-
ExtractVideoThumbnailResult,
|
|
104
|
-
ChooseMediaOptions,
|
|
105
|
-
ChosenMediaEntry,
|
|
106
|
-
PreviewMediaHandle,
|
|
107
|
-
PreviewMediaOptions,
|
|
108
|
-
SaveMediaOptions,
|
|
109
|
-
ScanCodeOptions,
|
|
110
|
-
ScanCodeResult,
|
|
111
|
-
VideoContext,
|
|
112
|
-
} from './media';
|
|
113
|
-
|
|
114
|
-
import type {
|
|
115
|
-
ShareOptions,
|
|
116
|
-
ShareResult,
|
|
117
|
-
} from './share';
|
|
118
|
-
|
|
119
|
-
import type {
|
|
120
|
-
ShowToastOptions,
|
|
121
|
-
ShowModalOptions,
|
|
122
|
-
ModalResult,
|
|
123
|
-
ShowActionSheetOptions,
|
|
124
|
-
ActionSheetResult,
|
|
125
|
-
NavigateToOptions,
|
|
126
|
-
NavigateBackOptions,
|
|
127
|
-
RedirectToOptions,
|
|
128
|
-
SwitchTabOptions,
|
|
129
|
-
ReLaunchOptions,
|
|
130
|
-
SetNavigationBarTitleOptions,
|
|
131
|
-
SetNavigationBarColorOptions,
|
|
132
|
-
TabBarRedDotOptions,
|
|
133
|
-
SetTabBarBadgeOptions,
|
|
134
|
-
RemoveTabBarBadgeOptions,
|
|
135
|
-
SetTabBarStyleOptions,
|
|
136
|
-
SetTabBarItemOptions,
|
|
137
|
-
SurfaceOpenOptions,
|
|
138
|
-
CapsuleRect,
|
|
139
|
-
} from './ui';
|
|
140
|
-
|
|
141
|
-
export interface SurfaceApi {
|
|
142
|
-
/**
|
|
143
|
-
* Dynamically opens a page or URL in a runtime-managed surface.
|
|
144
|
-
*
|
|
145
|
-
* `overlay` is cross-platform. `window` is a desktop capability and rejects
|
|
146
|
-
* on mobile platforms.
|
|
147
|
-
*/
|
|
148
|
-
open(options: SurfaceOpenOptions): Promise<Surface>;
|
|
149
|
-
}
|
|
20
|
+
} from './generated/logic';
|
|
21
|
+
import type { Automation } from './automation';
|
|
150
22
|
|
|
151
|
-
export
|
|
152
|
-
env: LxEnv;
|
|
153
|
-
app: HostAppApi;
|
|
154
|
-
surface: SurfaceApi;
|
|
155
|
-
|
|
156
|
-
getDeviceInfo(): DeviceInfo;
|
|
157
|
-
getScreenInfo(): ScreenInfo;
|
|
158
|
-
vibrateShort(): boolean;
|
|
159
|
-
vibrateLong(): boolean;
|
|
160
|
-
makePhoneCall(options: MakePhoneCallOptions): boolean;
|
|
161
|
-
|
|
162
|
-
startWifi(): Promise<void>;
|
|
163
|
-
stopWifi(): Promise<void>;
|
|
164
|
-
connectWifi(options: ConnectWifiOptions): Promise<void>;
|
|
165
|
-
getWifiList(): Promise<WifiInfo[]>;
|
|
166
|
-
getConnectedWifi(): Promise<WifiInfo>;
|
|
167
|
-
onWifiConnected(callback: WifiConnectedCallback): void;
|
|
168
|
-
offWifiConnected(callback?: WifiConnectedCallback): void;
|
|
169
|
-
getNetworkInfo(): Promise<NetworkInfo>;
|
|
170
|
-
onNetworkChange(callback: NetworkChangeCallback): void;
|
|
171
|
-
offNetworkChange(callback?: NetworkChangeCallback): void;
|
|
172
|
-
|
|
173
|
-
setDeviceOrientation(orientation: DeviceOrientation): boolean;
|
|
174
|
-
onDeviceOrientationChange(callback: (event: DeviceOrientationChangeEvent) => void): void;
|
|
175
|
-
offDeviceOrientationChange(callback?: (event: DeviceOrientationChangeEvent) => void): void;
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Open a local file with the requested strategy.
|
|
179
|
-
* Use `mode: 'review'` when the UX requires in-app preview,
|
|
180
|
-
* otherwise prefer `mode: 'auto'`.
|
|
181
|
-
*/
|
|
182
|
-
openFile(options: OpenFileOptions): void;
|
|
183
|
-
downloadFile(options: DownloadOptions): DownloadTask;
|
|
184
|
-
uploadFile(options: UploadOptions): UploadTask;
|
|
185
|
-
getFileManager(): FileManager;
|
|
186
|
-
|
|
187
|
-
getStorage(): Storage;
|
|
188
|
-
|
|
189
|
-
getLocation(options?: GetLocationOptions): Promise<LocationInfo>;
|
|
190
|
-
|
|
191
|
-
navigateToLxApp(options: NavigateToLxAppOptions): Promise<void>;
|
|
192
|
-
navigateBackLxApp(): Promise<void>;
|
|
193
|
-
|
|
194
|
-
getLxAppInfo(): LxAppInfo;
|
|
195
|
-
getSystemSetting(): SystemSettingInfo;
|
|
196
|
-
openURL(options: OpenURLOptions): void;
|
|
197
|
-
|
|
198
|
-
getUpdateManager(): UpdateManager;
|
|
199
|
-
|
|
200
|
-
getImageInfo(options: GetImageInfoOptions): Promise<ImageInfo>;
|
|
201
|
-
compressImage(options: CompressImageOptions): Promise<CompressImageResult>;
|
|
202
|
-
compressVideo(options: CompressVideoOptions): Promise<CompressVideoResult>;
|
|
203
|
-
getVideoInfo(options: GetVideoInfoOptions): Promise<VideoInfo>;
|
|
204
|
-
extractVideoThumbnail(options: ExtractVideoThumbnailOptions): Promise<ExtractVideoThumbnailResult>;
|
|
205
|
-
|
|
206
|
-
chooseMedia(options?: ChooseMediaOptions): Promise<ChosenMediaEntry[]>;
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Opens native media preview.
|
|
210
|
-
*
|
|
211
|
-
* Supports:
|
|
212
|
-
* - a single source path string for the simplest case
|
|
213
|
-
* - a single-item object for per-item options like `rotate`, `objectFit`, or `durationMs`
|
|
214
|
-
* - a sequence object for multi-item preview with `sources`, `startIndex`, and `advance`
|
|
215
|
-
*
|
|
216
|
-
* Returns a {@link PreviewMediaHandle} synchronously. Await `handle.completed`
|
|
217
|
-
* for the final session result (`reason`, `lastIndex`). Subscribe to
|
|
218
|
-
* `handle.presented` to learn when the first pixel hits the screen — useful
|
|
219
|
-
* for coordinating a hide of any overlay surface that was previously visible.
|
|
220
|
-
*
|
|
221
|
-
* `handle.completed` rejects with a cancellation error if `signal` is aborted;
|
|
222
|
-
* abort also requests the active native preview session to close immediately.
|
|
223
|
-
* `handle.presented` never rejects.
|
|
224
|
-
*/
|
|
225
|
-
previewMedia(options: PreviewMediaOptions): PreviewMediaHandle;
|
|
226
|
-
|
|
227
|
-
saveImageToPhotosAlbum(options: SaveMediaOptions): Promise<void>;
|
|
228
|
-
saveVideoToPhotosAlbum(options: SaveMediaOptions): Promise<void>;
|
|
229
|
-
|
|
230
|
-
scanCode(options?: ScanCodeOptions): Promise<ScanCodeResult>;
|
|
231
|
-
|
|
232
|
-
share(options: ShareOptions): Promise<ShareResult>;
|
|
233
|
-
|
|
234
|
-
createVideoContext(componentId: string): VideoContext;
|
|
235
|
-
|
|
236
|
-
showToast(options: ShowToastOptions): void;
|
|
237
|
-
hideToast(): void;
|
|
238
|
-
|
|
239
|
-
showModal(options: ShowModalOptions): Promise<ModalResult>;
|
|
240
|
-
|
|
241
|
-
showActionSheet(options: ShowActionSheetOptions): Promise<ActionSheetResult>;
|
|
242
|
-
|
|
243
|
-
navigateTo(options: NavigateToOptions): Promise<PageMessagePort>;
|
|
244
|
-
navigateBack(options: NavigateBackOptions): void;
|
|
245
|
-
redirectTo(options: RedirectToOptions): Promise<void>;
|
|
246
|
-
switchTab(options: SwitchTabOptions): Promise<void>;
|
|
247
|
-
reLaunch(options: ReLaunchOptions): Promise<void>;
|
|
248
|
-
|
|
249
|
-
setNavigationBarTitle(options: SetNavigationBarTitleOptions): boolean;
|
|
250
|
-
setNavigationBarColor(options: SetNavigationBarColorOptions): boolean;
|
|
251
|
-
hideHomeButton(): boolean;
|
|
252
|
-
|
|
253
|
-
showTabBarRedDot(options: TabBarRedDotOptions): boolean;
|
|
254
|
-
hideTabBarRedDot(options: TabBarRedDotOptions): boolean;
|
|
255
|
-
setTabBarBadge(options: SetTabBarBadgeOptions): boolean;
|
|
256
|
-
removeTabBarBadge(options: RemoveTabBarBadgeOptions): boolean;
|
|
257
|
-
showTabBar(): boolean;
|
|
258
|
-
hideTabBar(): boolean;
|
|
259
|
-
setTabBarStyle(options: SetTabBarStyleOptions): boolean;
|
|
260
|
-
setTabBarItem(options: SetTabBarItemOptions): boolean;
|
|
261
|
-
|
|
262
|
-
startPullDownRefresh(): void;
|
|
263
|
-
stopPullDownRefresh(): void;
|
|
264
|
-
|
|
265
|
-
getCapsuleRect(): Promise<CapsuleRect>;
|
|
266
|
-
|
|
267
|
-
chooseFile(options?: ChooseFileOptions): Promise<ChooseFileResult>;
|
|
268
|
-
chooseDirectory(options?: ChooseDirectoryOptions): Promise<ChooseDirectoryResult>;
|
|
269
|
-
|
|
270
|
-
onKeyDown(callback: KeyEventCallback): void;
|
|
271
|
-
offKeyDown(callback?: KeyEventCallback): void;
|
|
272
|
-
onKeyUp(callback: KeyEventCallback): void;
|
|
273
|
-
offKeyUp(callback?: KeyEventCallback): void;
|
|
274
|
-
}
|
|
23
|
+
export type Lx = globalThis.Lx;
|
|
275
24
|
|
|
276
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
|
+
|
|
277
37
|
const lx: Lx;
|
|
278
38
|
|
|
279
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
|
+
}
|
package/dist/app/index.d.ts
DELETED
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Host app, app lifecycle, and page instance APIs.
|
|
3
|
-
*/
|
|
4
|
-
export interface AppBaseInfo {
|
|
5
|
-
language: string;
|
|
6
|
-
productName: string;
|
|
7
|
-
version: string;
|
|
8
|
-
SDKVersion: string;
|
|
9
|
-
}
|
|
10
|
-
export interface HostAppUpdateInfo {
|
|
11
|
-
version: string;
|
|
12
|
-
size?: number;
|
|
13
|
-
releaseNotes?: string[];
|
|
14
|
-
isForceUpdate: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Download and apply this checked update.
|
|
17
|
-
*
|
|
18
|
-
* `apply()` is single-use for this update object.
|
|
19
|
-
*
|
|
20
|
-
* The returned task can be awaited directly when progress is not needed, or
|
|
21
|
-
* consumed with `for await...of` to render progress.
|
|
22
|
-
*
|
|
23
|
-
* Direct package handoff is currently supported on Android and macOS. Other
|
|
24
|
-
* platforms reject with an unsupported-operation error; use `version` and
|
|
25
|
-
* `releaseNotes` to guide users to the appropriate app marketplace.
|
|
26
|
-
*/
|
|
27
|
-
apply(): HostAppUpdateTask;
|
|
28
|
-
}
|
|
29
|
-
export type HostAppUpdateApplyStage = 'download' | 'install';
|
|
30
|
-
export type HostAppUpdateCheckResult = {
|
|
31
|
-
hasUpdate: false;
|
|
32
|
-
update?: never;
|
|
33
|
-
} | {
|
|
34
|
-
hasUpdate: true;
|
|
35
|
-
update: HostAppUpdateInfo;
|
|
36
|
-
};
|
|
37
|
-
export type HostAppUpdateEvent = {
|
|
38
|
-
state: 'downloading';
|
|
39
|
-
downloadedBytes?: number;
|
|
40
|
-
progress?: number;
|
|
41
|
-
} | {
|
|
42
|
-
state: 'downloaded' | 'installRequested';
|
|
43
|
-
} | {
|
|
44
|
-
state: 'failed';
|
|
45
|
-
stage: HostAppUpdateApplyStage;
|
|
46
|
-
error: string;
|
|
47
|
-
};
|
|
48
|
-
export interface HostAppUpdateResult {
|
|
49
|
-
state: 'installRequested';
|
|
50
|
-
}
|
|
51
|
-
export interface HostAppUpdateIteratorResult {
|
|
52
|
-
done: boolean;
|
|
53
|
-
value?: HostAppUpdateEvent;
|
|
54
|
-
}
|
|
55
|
-
export interface HostAppUpdateTask extends PromiseLike<HostAppUpdateResult>, AsyncIterable<HostAppUpdateEvent> {
|
|
56
|
-
next(): Promise<HostAppUpdateIteratorResult>;
|
|
57
|
-
/** Stops iteration only. It does not cancel an app update already handed to the platform. */
|
|
58
|
-
return(): Promise<HostAppUpdateIteratorResult>;
|
|
59
|
-
catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<HostAppUpdateResult | TResult>;
|
|
60
|
-
finally(onfinally?: (() => void) | null): Promise<HostAppUpdateResult>;
|
|
61
|
-
wait(): Promise<HostAppUpdateResult>;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Build-time environment version of the host app.
|
|
65
|
-
*
|
|
66
|
-
* Surfaced via {@link HostAppApi.envVersion}. Mirrors the
|
|
67
|
-
* `crates/lingxia-update::ReleaseType` enum and the `envVersion` field in the
|
|
68
|
-
* generated `app.json`. Pre-envVersion app artifacts are treated as `'release'`.
|
|
69
|
-
*
|
|
70
|
-
* Note: this is *separate* from `LxAppEnvVersion` in the navigator module,
|
|
71
|
-
* which encodes lxapp release channels (`'develop' | 'preview' | 'release'`)
|
|
72
|
-
* for cross-app navigation URLs and uses the truncated `develop` form.
|
|
73
|
-
*/
|
|
74
|
-
export type HostAppEnvVersion = 'developer' | 'preview' | 'release';
|
|
75
|
-
export interface HostAppApi {
|
|
76
|
-
/**
|
|
77
|
-
* The environment this build was produced for, mirroring `app.json::envVersion`.
|
|
78
|
-
* Always present; defaults to `'release'` for builds produced before the field
|
|
79
|
-
* existed in the artifact.
|
|
80
|
-
*
|
|
81
|
-
* Use this to branch on environment-specific behavior (e.g. verbose logging in
|
|
82
|
-
* developer builds, distinct theme tinting, distinct error-reporter tags).
|
|
83
|
-
* Synchronous; the value is fixed at app boot.
|
|
84
|
-
*/
|
|
85
|
-
readonly envVersion: HostAppEnvVersion;
|
|
86
|
-
getBaseInfo(): AppBaseInfo;
|
|
87
|
-
/**
|
|
88
|
-
* Check whether the host app has an update.
|
|
89
|
-
*
|
|
90
|
-
* This is a host app level capability and is only available to the home
|
|
91
|
-
* lxapp. Non-home lxapps receive a permission error.
|
|
92
|
-
*
|
|
93
|
-
* Calling this API opts the host app into custom update handling for this
|
|
94
|
-
* process. LingXia will not show its built-in host app update UI or
|
|
95
|
-
* auto-install host app updates after that point.
|
|
96
|
-
*
|
|
97
|
-
* If no update is available, or if an update requires a newer LingXia
|
|
98
|
-
* runtime than the current host app provides, `hasUpdate` is `false`.
|
|
99
|
-
*
|
|
100
|
-
* `checkUpdate()` may return version metadata on platforms that cannot apply
|
|
101
|
-
* host app packages directly. In that case, `update.apply()` rejects with an
|
|
102
|
-
* unsupported-operation error.
|
|
103
|
-
*/
|
|
104
|
-
checkUpdate(): Promise<HostAppUpdateCheckResult>;
|
|
105
|
-
/**
|
|
106
|
-
* Exit the host app immediately.
|
|
107
|
-
*
|
|
108
|
-
* This API does not show a confirmation dialog. If the user should confirm
|
|
109
|
-
* first, call `lx.showModal(...)` in page logic and invoke `lx.app.exit()`
|
|
110
|
-
* only after the user confirms.
|
|
111
|
-
*/
|
|
112
|
-
exit(): void;
|
|
113
|
-
}
|
|
114
|
-
export interface AppLifecycleEventArgs {
|
|
115
|
-
source: 'host' | 'lxapp';
|
|
116
|
-
reason: 'foreground' | 'background' | 'screenshot' | 'open' | 'close' | 'switch_back' | 'switch_away';
|
|
117
|
-
}
|
|
118
|
-
export interface AppLaunchOptions {
|
|
119
|
-
path?: string;
|
|
120
|
-
query?: Record<string, string>;
|
|
121
|
-
scene?: number;
|
|
122
|
-
referrerInfo?: {
|
|
123
|
-
appId?: string;
|
|
124
|
-
extraData?: Record<string, unknown>;
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
export interface AppConfig {
|
|
128
|
-
globalData?: Record<string, unknown>;
|
|
129
|
-
onLaunch?: (options?: AppLaunchOptions) => void | Promise<void>;
|
|
130
|
-
onShow?: (args?: AppLifecycleEventArgs) => void | Promise<void>;
|
|
131
|
-
onHide?: (args?: AppLifecycleEventArgs) => void | Promise<void>;
|
|
132
|
-
onUserCaptureScreen?: () => void | Promise<void>;
|
|
133
|
-
[key: string]: unknown;
|
|
134
|
-
}
|
|
135
|
-
export interface AppInstance extends AppConfig {
|
|
136
|
-
globalData: Record<string, unknown>;
|
|
137
|
-
}
|
|
138
|
-
export interface PageLoadOptions {
|
|
139
|
-
[key: string]: string | undefined;
|
|
140
|
-
}
|
|
141
|
-
export interface PageConfig<TData extends Record<string, unknown> = Record<string, unknown>> {
|
|
142
|
-
data?: TData;
|
|
143
|
-
onLoad?: (options?: PageLoadOptions) => void | Promise<void>;
|
|
144
|
-
onShow?: () => void | Promise<void>;
|
|
145
|
-
onReady?: () => void | Promise<void>;
|
|
146
|
-
onHide?: () => void | Promise<void>;
|
|
147
|
-
onUnload?: () => void | Promise<void>;
|
|
148
|
-
onPullDownRefresh?: () => void | Promise<void>;
|
|
149
|
-
[key: string]: unknown;
|
|
150
|
-
}
|
|
151
|
-
export type SurfaceCloseReason = 'user' | 'programmatic' | 'owner_closed' | 'app_closed' | 'failed'
|
|
152
|
-
/**
|
|
153
|
-
* The SDK reclaimed a long-hidden overlay surface for resource reasons.
|
|
154
|
-
* Treat as a normal close: the page instance is gone; further postMessage /
|
|
155
|
-
* show / hide calls will fail. The opener may immediately reopen if needed.
|
|
156
|
-
*/
|
|
157
|
-
| 'reclaimed' | 'unknown';
|
|
158
|
-
export interface SurfaceClosedEvent {
|
|
159
|
-
id: string;
|
|
160
|
-
kind: 'overlay' | 'window';
|
|
161
|
-
reason: SurfaceCloseReason;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Detail payload for `onShow` / `onHide` events. `source` identifies which
|
|
165
|
-
* Surface object initiated the visibility change so observers can
|
|
166
|
-
* distinguish self-driven transitions from peer-driven ones (e.g. an opener
|
|
167
|
-
* UI that wants to update its own button state only when the page side
|
|
168
|
-
* toggled visibility).
|
|
169
|
-
*/
|
|
170
|
-
export interface SurfaceVisibilityEvent {
|
|
171
|
-
id: string;
|
|
172
|
-
kind: 'overlay' | 'window';
|
|
173
|
-
source: 'opener' | 'page';
|
|
174
|
-
}
|
|
175
|
-
export interface Surface {
|
|
176
|
-
readonly id: string;
|
|
177
|
-
readonly kind: 'overlay' | 'window';
|
|
178
|
-
/**
|
|
179
|
-
* Last-known visibility, kept in sync with the native side via show/hide
|
|
180
|
-
* events. False once the surface has been closed. Safe to bind into
|
|
181
|
-
* declarative UI; for event-driven updates subscribe via `onShow`/`onHide`.
|
|
182
|
-
*/
|
|
183
|
-
readonly visible: boolean;
|
|
184
|
-
/**
|
|
185
|
-
* True until `close()` fires. After close the surface is detached and the
|
|
186
|
-
* page instance is being torn down; further `show()` / `hide()` calls will
|
|
187
|
-
* reject.
|
|
188
|
-
*/
|
|
189
|
-
readonly alive: boolean;
|
|
190
|
-
/**
|
|
191
|
-
* Sends a message to the other side of a page surface.
|
|
192
|
-
*
|
|
193
|
-
* For the opener this targets the opened page. For the opened page this
|
|
194
|
-
* targets the opener. URL surfaces have no page-side receiver.
|
|
195
|
-
*/
|
|
196
|
-
postMessage(message: unknown): void;
|
|
197
|
-
onMessage(handler: (message: unknown) => void): () => void;
|
|
198
|
-
onClose(handler: (event: SurfaceClosedEvent) => void): () => void;
|
|
199
|
-
/**
|
|
200
|
-
* Fires when the surface transitions to visible, regardless of whether
|
|
201
|
-
* `show()` was called on this side or on the peer. Returns an unsubscribe
|
|
202
|
-
* function. Only fires on real state changes — calling `show()` on an
|
|
203
|
-
* already-visible surface is a no-op for listeners.
|
|
204
|
-
*/
|
|
205
|
-
onShow(handler: (event: SurfaceVisibilityEvent) => void): () => void;
|
|
206
|
-
/**
|
|
207
|
-
* Fires when the surface transitions to hidden, regardless of which side
|
|
208
|
-
* triggered it. Returns an unsubscribe function. Only fires on real state
|
|
209
|
-
* changes.
|
|
210
|
-
*/
|
|
211
|
-
onHide(handler: (event: SurfaceVisibilityEvent) => void): () => void;
|
|
212
|
-
close(): Promise<void>;
|
|
213
|
-
/**
|
|
214
|
-
* Toggle the surface to visible without tearing it down. The page instance
|
|
215
|
-
* and its state survive a hide / show round-trip — only close() actually
|
|
216
|
-
* destroys the surface and fires the onClose listener. Idempotent: calling
|
|
217
|
-
* on an already-visible surface resolves without firing `onShow`.
|
|
218
|
-
*/
|
|
219
|
-
show(): Promise<void>;
|
|
220
|
-
/**
|
|
221
|
-
* Hide the surface without destroying it. The page instance stays mounted,
|
|
222
|
-
* so a subsequent show() restores the same scroll position, form input,
|
|
223
|
-
* and JS state. Hidden surfaces still receive postMessage but are not
|
|
224
|
-
* visible to the user. Idempotent.
|
|
225
|
-
*/
|
|
226
|
-
hide(): Promise<void>;
|
|
227
|
-
}
|
|
228
|
-
export interface PageMessagePort {
|
|
229
|
-
postMessage(message: unknown): void;
|
|
230
|
-
onMessage(handler: (message: unknown) => void): () => void;
|
|
231
|
-
}
|
|
232
|
-
export interface PageInstance<TData extends Record<string, unknown> = Record<string, unknown>> {
|
|
233
|
-
data: TData;
|
|
234
|
-
route: string;
|
|
235
|
-
/**
|
|
236
|
-
* Available when this page was opened by `lx.surface.open(...)`.
|
|
237
|
-
*/
|
|
238
|
-
surface?: Surface;
|
|
239
|
-
/**
|
|
240
|
-
* Available when this page was opened by `lx.navigateTo(...)`.
|
|
241
|
-
*/
|
|
242
|
-
opener?: PageMessagePort;
|
|
243
|
-
setData(data: Partial<TData> | Record<string, unknown>, callback?: () => void): void;
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Injected by the runtime into methods listed in `stream_handlers` page metadata.
|
|
247
|
-
*
|
|
248
|
-
* Use this when your async source uses callbacks rather than an async iterator.
|
|
249
|
-
* For the generator form (`async *method()`), no handle is needed — the runtime
|
|
250
|
-
* pumps the generator automatically.
|
|
251
|
-
*/
|
|
252
|
-
export interface StreamHandle<T = unknown> {
|
|
253
|
-
/** Send a chunk to View. */
|
|
254
|
-
send(payload: T): void;
|
|
255
|
-
/** End the stream with an optional final value. */
|
|
256
|
-
end(result?: unknown): void;
|
|
257
|
-
/** End the stream with an error. */
|
|
258
|
-
error(code: string, message?: string): void;
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Injected by the runtime as the second parameter when View opens a channel.
|
|
262
|
-
*
|
|
263
|
-
* Use `ch.send()` to push data to View, `ch.on()` to receive data/close
|
|
264
|
-
* events from View, and `ch.close()` to shut down the channel.
|
|
265
|
-
*/
|
|
266
|
-
export interface ChannelHandle<TSend = unknown, TReceive = unknown> {
|
|
267
|
-
/** Push a message to View. */
|
|
268
|
-
send(payload: TSend): void;
|
|
269
|
-
/** Close the channel from Logic side. */
|
|
270
|
-
close(code?: string, reason?: string): void;
|
|
271
|
-
/** Register a listener for incoming events. */
|
|
272
|
-
on(event: 'data', handler: (payload: TReceive) => void): void;
|
|
273
|
-
on(event: 'close', handler: (info: {
|
|
274
|
-
code: string;
|
|
275
|
-
reason: string;
|
|
276
|
-
}) => void): void;
|
|
277
|
-
}
|
|
278
|
-
//# sourceMappingURL=index.d.ts.map
|