@arkts/image-manager 0.0.2
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/LICENSE +21 -0
- package/README.md +81 -0
- package/dist/default-product-config.cjs +370 -0
- package/dist/default-product-config.d.cts +5 -0
- package/dist/default-product-config.d.mts +6 -0
- package/dist/default-product-config.mjs +369 -0
- package/dist/index.cjs +663 -0
- package/dist/index.d.cts +264 -0
- package/dist/index.d.mts +264 -0
- package/dist/index.mjs +629 -0
- package/dist/product-config-BbaYsaoV.d.mts +250 -0
- package/dist/product-config-Dk21FD9U.d.cts +250 -0
- package/package.json +67 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { a as OS, c as Stringifiable, d as DeployedImageConfigWithProductName, f as DeployedImageOptions, i as DeviceType, l as DeployedDevModel, m as FullDeployedImageOptions, n as ProductConfigItem, o as PascalCaseDeviceType, p as DevModel, r as Arch, s as SnakecaseDeviceType, t as ProductConfig, u as DeployedImageConfig } from "./product-config-Dk21FD9U.cjs";
|
|
2
|
+
import { AxiosProgressEvent } from "axios";
|
|
3
|
+
import { Emitter } from "mitt";
|
|
4
|
+
import * as node_child_process0 from "node:child_process";
|
|
5
|
+
import progress from "progress-stream";
|
|
6
|
+
import * as node_os0 from "node:os";
|
|
7
|
+
import * as node_fs0 from "node:fs";
|
|
8
|
+
import * as node_path0 from "node:path";
|
|
9
|
+
import * as node_process0 from "node:process";
|
|
10
|
+
import * as node_crypto0 from "node:crypto";
|
|
11
|
+
|
|
12
|
+
//#region src/images/local-image.d.ts
|
|
13
|
+
interface LocalImage extends BaseImage, Stringifiable<LocalImage.Stringifiable> {
|
|
14
|
+
imageType: 'local';
|
|
15
|
+
createDeployer(name: string, config: DeployedImageConfigWithProductName): ImageDeployer;
|
|
16
|
+
getProductConfig(): Promise<ProductConfigItem[]>;
|
|
17
|
+
delete(): Promise<void | Error>;
|
|
18
|
+
buildStartCommand(deployer: ImageDeployer): Promise<string>;
|
|
19
|
+
start(deployer: ImageDeployer): Promise<node_child_process0.ChildProcess>;
|
|
20
|
+
buildStopCommand(deployer: ImageDeployer): Promise<string>;
|
|
21
|
+
stop(deployer: ImageDeployer): Promise<node_child_process0.ChildProcess>;
|
|
22
|
+
}
|
|
23
|
+
declare namespace LocalImage {
|
|
24
|
+
interface Stringifiable {
|
|
25
|
+
imageType: 'local';
|
|
26
|
+
path: string;
|
|
27
|
+
version: string;
|
|
28
|
+
apiVersion: string;
|
|
29
|
+
targetVersion: string;
|
|
30
|
+
checksum: string;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/images/remote-image.d.ts
|
|
35
|
+
interface RemoteImage extends BaseImage, Stringifiable<RemoteImage.Stringifiable> {
|
|
36
|
+
imageType: 'remote';
|
|
37
|
+
}
|
|
38
|
+
declare namespace RemoteImage {
|
|
39
|
+
interface Stringifiable {
|
|
40
|
+
imageType: 'remote';
|
|
41
|
+
path: string;
|
|
42
|
+
apiVersion: string;
|
|
43
|
+
checksum: string;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/image-downloader.d.ts
|
|
48
|
+
interface ImageDownloadProgressEvent extends AxiosProgressEvent {
|
|
49
|
+
/**
|
|
50
|
+
* The network speed of the download.
|
|
51
|
+
*/
|
|
52
|
+
network: number;
|
|
53
|
+
/**
|
|
54
|
+
* The unit of the network speed.
|
|
55
|
+
*/
|
|
56
|
+
unit: 'KB' | 'MB';
|
|
57
|
+
/**
|
|
58
|
+
* The increment of the {@linkcode ImageDownloadProgressEvent.percentage}.
|
|
59
|
+
*/
|
|
60
|
+
increment: number;
|
|
61
|
+
}
|
|
62
|
+
interface ExtractProgressEvent extends progress.Progress {}
|
|
63
|
+
type ImageDownloadEventMap = {
|
|
64
|
+
'download-progress': ImageDownloadProgressEvent;
|
|
65
|
+
'extract-progress': ExtractProgressEvent;
|
|
66
|
+
};
|
|
67
|
+
interface ImageDownloader<T extends BaseImage> extends Emitter<ImageDownloadEventMap> {
|
|
68
|
+
/**
|
|
69
|
+
* Start downloading the image.
|
|
70
|
+
*
|
|
71
|
+
* @param signal - The abort signal.
|
|
72
|
+
*/
|
|
73
|
+
startDownload(signal?: AbortSignal): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Check the checksum of the image.
|
|
76
|
+
*
|
|
77
|
+
* @param signal - The abort signal.
|
|
78
|
+
*/
|
|
79
|
+
checkChecksum(signal?: AbortSignal): Promise<boolean>;
|
|
80
|
+
/**
|
|
81
|
+
* Extract the image.
|
|
82
|
+
*
|
|
83
|
+
* @param signal - The abort signal.
|
|
84
|
+
* @param symlinkOpenHarmonySdk - If true, symlink the OpenHarmony SDK to the image. Default is `true`.
|
|
85
|
+
*/
|
|
86
|
+
extract(signal?: AbortSignal, symlinkOpenHarmonySdk?: boolean): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Clean the cache of the image.
|
|
89
|
+
*/
|
|
90
|
+
clean(): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Get the image.
|
|
93
|
+
*/
|
|
94
|
+
getImage(): T;
|
|
95
|
+
/**
|
|
96
|
+
* Get the URL of the image.
|
|
97
|
+
*/
|
|
98
|
+
getUrl(): string;
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/options.d.ts
|
|
102
|
+
interface ImageManagerOptions {
|
|
103
|
+
/**
|
|
104
|
+
* The base path to store the images.
|
|
105
|
+
*/
|
|
106
|
+
imageBasePath?: string;
|
|
107
|
+
/**
|
|
108
|
+
* The path to store the deployed images.
|
|
109
|
+
*/
|
|
110
|
+
deployedPath?: string;
|
|
111
|
+
/**
|
|
112
|
+
* The base path to store the downloaded images zip files.
|
|
113
|
+
*
|
|
114
|
+
* @default `imageBasePath/cache`
|
|
115
|
+
*/
|
|
116
|
+
cachePath?: string;
|
|
117
|
+
/**
|
|
118
|
+
* The path to store the HarmonyOS SDK.
|
|
119
|
+
*
|
|
120
|
+
* - In macOS, it will be `/Applications/DevEco-Studio.app/Contents/sdk/default/openharmony` by default;
|
|
121
|
+
* - In Windows, it will be `C:\Program Files\Huawei\DevEco Studio\sdk\default\openharmony` by default;
|
|
122
|
+
* - In other platforms, it will be `~/.huawei/Sdk/default/openharmony` by default.
|
|
123
|
+
*/
|
|
124
|
+
sdkPath?: string;
|
|
125
|
+
/**
|
|
126
|
+
* The path to store the HarmonyOS configuration files.
|
|
127
|
+
*
|
|
128
|
+
* - In macOS, it will be `~/Library/Application Support/Huawei/DevEcoStudio6.0` by default;
|
|
129
|
+
* - In Windows, it will be `%APPDATA%\Roaming\Huawei\DevEcoStudio6.0` by default;
|
|
130
|
+
* - In other platforms, it will be `~/.huawei/DevEcoStudio6.0` by default.
|
|
131
|
+
*/
|
|
132
|
+
configPath?: string;
|
|
133
|
+
/**
|
|
134
|
+
* The path to store the HarmonyOS log files.
|
|
135
|
+
*
|
|
136
|
+
* - In macOS, it will be `~/Library/Logs/Huawei/DevEcoStudio6.0` by default;
|
|
137
|
+
* - In Windows, it will be `%APPDATA%\Local\Huawei\DevEcoStudio6.0\log` by default;
|
|
138
|
+
* - In other platforms, it will be `~/.huawei/DevEcoStudio6.0/log` by default.
|
|
139
|
+
*/
|
|
140
|
+
logPath?: string;
|
|
141
|
+
/**
|
|
142
|
+
* The folder to store the emulator executable files.
|
|
143
|
+
*
|
|
144
|
+
* It must contain the `Emulator` (In windows, it will be `Emulator.exe`) executable file.
|
|
145
|
+
*
|
|
146
|
+
* - In macOS, it will be `/Applications/DevEco-Studio.app/Contents/tools/emulator`;
|
|
147
|
+
* - In Windows, it will be `C:\Program Files\Huawei\DevEco Studio\tools\emulator`;
|
|
148
|
+
* - In other platforms, it will be `~/.huawei/Emulator`.
|
|
149
|
+
*/
|
|
150
|
+
emulatorPath?: string;
|
|
151
|
+
os?: typeof node_os0;
|
|
152
|
+
fs?: typeof node_fs0;
|
|
153
|
+
path?: typeof node_path0;
|
|
154
|
+
process?: typeof node_process0;
|
|
155
|
+
crypto?: typeof node_crypto0;
|
|
156
|
+
child_process?: typeof node_child_process0;
|
|
157
|
+
}
|
|
158
|
+
type ResolvedImageManagerOptions = Required<ImageManagerOptions>;
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/image-manager.d.ts
|
|
161
|
+
interface ImageManager {
|
|
162
|
+
/**
|
|
163
|
+
* Get the resolved options.
|
|
164
|
+
*/
|
|
165
|
+
getOptions(): ResolvedImageManagerOptions;
|
|
166
|
+
/**
|
|
167
|
+
* Get the images.
|
|
168
|
+
*/
|
|
169
|
+
getImages(): Promise<Image[]>;
|
|
170
|
+
/**
|
|
171
|
+
* Get the product config.
|
|
172
|
+
*
|
|
173
|
+
* It will automatically read from the `imageBasePath/productConfig.json` file if it exists.
|
|
174
|
+
* If the file does not exist, it will use the default product config.
|
|
175
|
+
*/
|
|
176
|
+
getProductConfig(): Promise<ProductConfig>;
|
|
177
|
+
/**
|
|
178
|
+
* Write the product config.
|
|
179
|
+
*
|
|
180
|
+
* @param existSkip - If the file exists, skip writing. Defaults to `false`.
|
|
181
|
+
*/
|
|
182
|
+
writeDefaultProductConfig(existSkip?: boolean): Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* Get the operating system.
|
|
185
|
+
*/
|
|
186
|
+
getOS(): OS;
|
|
187
|
+
/**
|
|
188
|
+
* Get the architecture.
|
|
189
|
+
*/
|
|
190
|
+
getArch(): Arch;
|
|
191
|
+
}
|
|
192
|
+
declare function createImageManager(options?: ImageManagerOptions): Promise<ImageManager>;
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/errors/request-url-error.d.ts
|
|
195
|
+
declare class RequestUrlError extends Error {
|
|
196
|
+
readonly message: string;
|
|
197
|
+
readonly code: number;
|
|
198
|
+
readonly cause?: Error;
|
|
199
|
+
constructor(message: string, code: number, cause?: Error);
|
|
200
|
+
}
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region src/images/image.d.ts
|
|
203
|
+
interface BaseImage {
|
|
204
|
+
getImageManager(): ImageManager;
|
|
205
|
+
getPath(): string;
|
|
206
|
+
getArch(): 'arm' | 'x86' | (string & {});
|
|
207
|
+
getChecksum(): string;
|
|
208
|
+
getVersion(): string;
|
|
209
|
+
getApiVersion(): string;
|
|
210
|
+
getTargetOS(): string;
|
|
211
|
+
getTargetVersion(): string;
|
|
212
|
+
getFsPath(): string;
|
|
213
|
+
getDeviceType(): DeviceType | (string & {});
|
|
214
|
+
getSnakecaseDeviceType(): SnakecaseDeviceType | (string & {});
|
|
215
|
+
getUrl(): Promise<string | RequestUrlError>;
|
|
216
|
+
isDownloaded(): Promise<boolean>;
|
|
217
|
+
createDownloader(signal?: AbortSignal): Promise<ImageDownloader<this> | RequestUrlError>;
|
|
218
|
+
}
|
|
219
|
+
type Image = LocalImage | RemoteImage;
|
|
220
|
+
type ImageType = 'local' | 'remote';
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/deployer/image-deployer.d.ts
|
|
223
|
+
interface ImageDeployer {
|
|
224
|
+
setUuid(uuid: `${string}-${string}-${string}-${string}-${string}`): this;
|
|
225
|
+
setModel(model: string): this;
|
|
226
|
+
setDevModel(devModel: FullDeployedImageOptions['devModel']): this;
|
|
227
|
+
setCpuNumber(cpuNumber: number): this;
|
|
228
|
+
setMemoryRamSize(memoryRamSize: number): this;
|
|
229
|
+
setDataDiskSize(dataDiskSize: number): this;
|
|
230
|
+
setCoverResolutionWidth(coverResolutionWidth: number | string): this;
|
|
231
|
+
setCoverResolutionHeight(coverResolutionHeight: number | string): this;
|
|
232
|
+
setCoverDiagonalSize(coverDiagonalSize: number | string): this;
|
|
233
|
+
setIsDefault(isDefault: boolean): this;
|
|
234
|
+
setIsCustomize(isCustomize: boolean): this;
|
|
235
|
+
setIsPublic(isPublic: boolean): this;
|
|
236
|
+
setVendorCountry(vendorCountry: string): this;
|
|
237
|
+
setHwHdcPort(hwHdcPort: string | number): this;
|
|
238
|
+
/**
|
|
239
|
+
* Build the list object of the current device.
|
|
240
|
+
*
|
|
241
|
+
* @returns The list object of the current device. Can be used to build the `lists.json` file.
|
|
242
|
+
*/
|
|
243
|
+
buildList(): Promise<FullDeployedImageOptions>;
|
|
244
|
+
/**
|
|
245
|
+
* Build the `config.ini` object of the current device.
|
|
246
|
+
*
|
|
247
|
+
* @returns The `config.ini` object of the current device.
|
|
248
|
+
*/
|
|
249
|
+
buildIni(): Promise<Record<string, string | undefined>>;
|
|
250
|
+
/**
|
|
251
|
+
* Build the `config.ini` string of the current device.
|
|
252
|
+
*
|
|
253
|
+
* @returns The `config.ini` string of the current device, can write to file directly.
|
|
254
|
+
*/
|
|
255
|
+
toIniString(): Promise<string>;
|
|
256
|
+
/**
|
|
257
|
+
* Deploy the image.
|
|
258
|
+
*
|
|
259
|
+
* @param symlinkImage - If true, symlink the system image to current device directory. Default is `true`.
|
|
260
|
+
*/
|
|
261
|
+
deploy(symlinkImage?: boolean): Promise<void | Error>;
|
|
262
|
+
}
|
|
263
|
+
//#endregion
|
|
264
|
+
export { Arch, DeployedDevModel, DeployedImageConfig, DeployedImageConfigWithProductName, DeployedImageOptions, DevModel, DeviceType, FullDeployedImageOptions, Image, ImageDeployer, type ImageManager, type ImageManagerOptions, ImageType, LocalImage, OS, PascalCaseDeviceType, type ProductConfig, RemoteImage, RequestUrlError, SnakecaseDeviceType, Stringifiable, createImageManager };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { a as OS, c as Stringifiable, d as DeployedImageConfigWithProductName, f as DeployedImageOptions, i as DeviceType, l as DeployedDevModel, m as FullDeployedImageOptions, n as ProductConfigItem, o as PascalCaseDeviceType, p as DevModel, r as Arch, s as SnakecaseDeviceType, t as ProductConfig, u as DeployedImageConfig } from "./product-config-BbaYsaoV.mjs";
|
|
2
|
+
import { AxiosProgressEvent } from "axios";
|
|
3
|
+
import { Emitter } from "mitt";
|
|
4
|
+
import progress from "progress-stream";
|
|
5
|
+
import * as node_child_process0 from "node:child_process";
|
|
6
|
+
import * as node_crypto0 from "node:crypto";
|
|
7
|
+
import * as node_fs0 from "node:fs";
|
|
8
|
+
import * as node_os0 from "node:os";
|
|
9
|
+
import * as node_path0 from "node:path";
|
|
10
|
+
import * as node_process0 from "node:process";
|
|
11
|
+
|
|
12
|
+
//#region src/images/local-image.d.ts
|
|
13
|
+
interface LocalImage extends BaseImage, Stringifiable<LocalImage.Stringifiable> {
|
|
14
|
+
imageType: 'local';
|
|
15
|
+
createDeployer(name: string, config: DeployedImageConfigWithProductName): ImageDeployer;
|
|
16
|
+
getProductConfig(): Promise<ProductConfigItem[]>;
|
|
17
|
+
delete(): Promise<void | Error>;
|
|
18
|
+
buildStartCommand(deployer: ImageDeployer): Promise<string>;
|
|
19
|
+
start(deployer: ImageDeployer): Promise<node_child_process0.ChildProcess>;
|
|
20
|
+
buildStopCommand(deployer: ImageDeployer): Promise<string>;
|
|
21
|
+
stop(deployer: ImageDeployer): Promise<node_child_process0.ChildProcess>;
|
|
22
|
+
}
|
|
23
|
+
declare namespace LocalImage {
|
|
24
|
+
interface Stringifiable {
|
|
25
|
+
imageType: 'local';
|
|
26
|
+
path: string;
|
|
27
|
+
version: string;
|
|
28
|
+
apiVersion: string;
|
|
29
|
+
targetVersion: string;
|
|
30
|
+
checksum: string;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/images/remote-image.d.ts
|
|
35
|
+
interface RemoteImage extends BaseImage, Stringifiable<RemoteImage.Stringifiable> {
|
|
36
|
+
imageType: 'remote';
|
|
37
|
+
}
|
|
38
|
+
declare namespace RemoteImage {
|
|
39
|
+
interface Stringifiable {
|
|
40
|
+
imageType: 'remote';
|
|
41
|
+
path: string;
|
|
42
|
+
apiVersion: string;
|
|
43
|
+
checksum: string;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/image-downloader.d.ts
|
|
48
|
+
interface ImageDownloadProgressEvent extends AxiosProgressEvent {
|
|
49
|
+
/**
|
|
50
|
+
* The network speed of the download.
|
|
51
|
+
*/
|
|
52
|
+
network: number;
|
|
53
|
+
/**
|
|
54
|
+
* The unit of the network speed.
|
|
55
|
+
*/
|
|
56
|
+
unit: 'KB' | 'MB';
|
|
57
|
+
/**
|
|
58
|
+
* The increment of the {@linkcode ImageDownloadProgressEvent.percentage}.
|
|
59
|
+
*/
|
|
60
|
+
increment: number;
|
|
61
|
+
}
|
|
62
|
+
interface ExtractProgressEvent extends progress.Progress {}
|
|
63
|
+
type ImageDownloadEventMap = {
|
|
64
|
+
'download-progress': ImageDownloadProgressEvent;
|
|
65
|
+
'extract-progress': ExtractProgressEvent;
|
|
66
|
+
};
|
|
67
|
+
interface ImageDownloader<T extends BaseImage> extends Emitter<ImageDownloadEventMap> {
|
|
68
|
+
/**
|
|
69
|
+
* Start downloading the image.
|
|
70
|
+
*
|
|
71
|
+
* @param signal - The abort signal.
|
|
72
|
+
*/
|
|
73
|
+
startDownload(signal?: AbortSignal): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Check the checksum of the image.
|
|
76
|
+
*
|
|
77
|
+
* @param signal - The abort signal.
|
|
78
|
+
*/
|
|
79
|
+
checkChecksum(signal?: AbortSignal): Promise<boolean>;
|
|
80
|
+
/**
|
|
81
|
+
* Extract the image.
|
|
82
|
+
*
|
|
83
|
+
* @param signal - The abort signal.
|
|
84
|
+
* @param symlinkOpenHarmonySdk - If true, symlink the OpenHarmony SDK to the image. Default is `true`.
|
|
85
|
+
*/
|
|
86
|
+
extract(signal?: AbortSignal, symlinkOpenHarmonySdk?: boolean): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Clean the cache of the image.
|
|
89
|
+
*/
|
|
90
|
+
clean(): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Get the image.
|
|
93
|
+
*/
|
|
94
|
+
getImage(): T;
|
|
95
|
+
/**
|
|
96
|
+
* Get the URL of the image.
|
|
97
|
+
*/
|
|
98
|
+
getUrl(): string;
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/options.d.ts
|
|
102
|
+
interface ImageManagerOptions {
|
|
103
|
+
/**
|
|
104
|
+
* The base path to store the images.
|
|
105
|
+
*/
|
|
106
|
+
imageBasePath?: string;
|
|
107
|
+
/**
|
|
108
|
+
* The path to store the deployed images.
|
|
109
|
+
*/
|
|
110
|
+
deployedPath?: string;
|
|
111
|
+
/**
|
|
112
|
+
* The base path to store the downloaded images zip files.
|
|
113
|
+
*
|
|
114
|
+
* @default `imageBasePath/cache`
|
|
115
|
+
*/
|
|
116
|
+
cachePath?: string;
|
|
117
|
+
/**
|
|
118
|
+
* The path to store the HarmonyOS SDK.
|
|
119
|
+
*
|
|
120
|
+
* - In macOS, it will be `/Applications/DevEco-Studio.app/Contents/sdk/default/openharmony` by default;
|
|
121
|
+
* - In Windows, it will be `C:\Program Files\Huawei\DevEco Studio\sdk\default\openharmony` by default;
|
|
122
|
+
* - In other platforms, it will be `~/.huawei/Sdk/default/openharmony` by default.
|
|
123
|
+
*/
|
|
124
|
+
sdkPath?: string;
|
|
125
|
+
/**
|
|
126
|
+
* The path to store the HarmonyOS configuration files.
|
|
127
|
+
*
|
|
128
|
+
* - In macOS, it will be `~/Library/Application Support/Huawei/DevEcoStudio6.0` by default;
|
|
129
|
+
* - In Windows, it will be `%APPDATA%\Roaming\Huawei\DevEcoStudio6.0` by default;
|
|
130
|
+
* - In other platforms, it will be `~/.huawei/DevEcoStudio6.0` by default.
|
|
131
|
+
*/
|
|
132
|
+
configPath?: string;
|
|
133
|
+
/**
|
|
134
|
+
* The path to store the HarmonyOS log files.
|
|
135
|
+
*
|
|
136
|
+
* - In macOS, it will be `~/Library/Logs/Huawei/DevEcoStudio6.0` by default;
|
|
137
|
+
* - In Windows, it will be `%APPDATA%\Local\Huawei\DevEcoStudio6.0\log` by default;
|
|
138
|
+
* - In other platforms, it will be `~/.huawei/DevEcoStudio6.0/log` by default.
|
|
139
|
+
*/
|
|
140
|
+
logPath?: string;
|
|
141
|
+
/**
|
|
142
|
+
* The folder to store the emulator executable files.
|
|
143
|
+
*
|
|
144
|
+
* It must contain the `Emulator` (In windows, it will be `Emulator.exe`) executable file.
|
|
145
|
+
*
|
|
146
|
+
* - In macOS, it will be `/Applications/DevEco-Studio.app/Contents/tools/emulator`;
|
|
147
|
+
* - In Windows, it will be `C:\Program Files\Huawei\DevEco Studio\tools\emulator`;
|
|
148
|
+
* - In other platforms, it will be `~/.huawei/Emulator`.
|
|
149
|
+
*/
|
|
150
|
+
emulatorPath?: string;
|
|
151
|
+
os?: typeof node_os0;
|
|
152
|
+
fs?: typeof node_fs0;
|
|
153
|
+
path?: typeof node_path0;
|
|
154
|
+
process?: typeof node_process0;
|
|
155
|
+
crypto?: typeof node_crypto0;
|
|
156
|
+
child_process?: typeof node_child_process0;
|
|
157
|
+
}
|
|
158
|
+
type ResolvedImageManagerOptions = Required<ImageManagerOptions>;
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/image-manager.d.ts
|
|
161
|
+
interface ImageManager {
|
|
162
|
+
/**
|
|
163
|
+
* Get the resolved options.
|
|
164
|
+
*/
|
|
165
|
+
getOptions(): ResolvedImageManagerOptions;
|
|
166
|
+
/**
|
|
167
|
+
* Get the images.
|
|
168
|
+
*/
|
|
169
|
+
getImages(): Promise<Image[]>;
|
|
170
|
+
/**
|
|
171
|
+
* Get the product config.
|
|
172
|
+
*
|
|
173
|
+
* It will automatically read from the `imageBasePath/productConfig.json` file if it exists.
|
|
174
|
+
* If the file does not exist, it will use the default product config.
|
|
175
|
+
*/
|
|
176
|
+
getProductConfig(): Promise<ProductConfig>;
|
|
177
|
+
/**
|
|
178
|
+
* Write the product config.
|
|
179
|
+
*
|
|
180
|
+
* @param existSkip - If the file exists, skip writing. Defaults to `false`.
|
|
181
|
+
*/
|
|
182
|
+
writeDefaultProductConfig(existSkip?: boolean): Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* Get the operating system.
|
|
185
|
+
*/
|
|
186
|
+
getOS(): OS;
|
|
187
|
+
/**
|
|
188
|
+
* Get the architecture.
|
|
189
|
+
*/
|
|
190
|
+
getArch(): Arch;
|
|
191
|
+
}
|
|
192
|
+
declare function createImageManager(options?: ImageManagerOptions): Promise<ImageManager>;
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/errors/request-url-error.d.ts
|
|
195
|
+
declare class RequestUrlError extends Error {
|
|
196
|
+
readonly message: string;
|
|
197
|
+
readonly code: number;
|
|
198
|
+
readonly cause?: Error;
|
|
199
|
+
constructor(message: string, code: number, cause?: Error);
|
|
200
|
+
}
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region src/images/image.d.ts
|
|
203
|
+
interface BaseImage {
|
|
204
|
+
getImageManager(): ImageManager;
|
|
205
|
+
getPath(): string;
|
|
206
|
+
getArch(): 'arm' | 'x86' | (string & {});
|
|
207
|
+
getChecksum(): string;
|
|
208
|
+
getVersion(): string;
|
|
209
|
+
getApiVersion(): string;
|
|
210
|
+
getTargetOS(): string;
|
|
211
|
+
getTargetVersion(): string;
|
|
212
|
+
getFsPath(): string;
|
|
213
|
+
getDeviceType(): DeviceType | (string & {});
|
|
214
|
+
getSnakecaseDeviceType(): SnakecaseDeviceType | (string & {});
|
|
215
|
+
getUrl(): Promise<string | RequestUrlError>;
|
|
216
|
+
isDownloaded(): Promise<boolean>;
|
|
217
|
+
createDownloader(signal?: AbortSignal): Promise<ImageDownloader<this> | RequestUrlError>;
|
|
218
|
+
}
|
|
219
|
+
type Image = LocalImage | RemoteImage;
|
|
220
|
+
type ImageType = 'local' | 'remote';
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/deployer/image-deployer.d.ts
|
|
223
|
+
interface ImageDeployer {
|
|
224
|
+
setUuid(uuid: `${string}-${string}-${string}-${string}-${string}`): this;
|
|
225
|
+
setModel(model: string): this;
|
|
226
|
+
setDevModel(devModel: FullDeployedImageOptions['devModel']): this;
|
|
227
|
+
setCpuNumber(cpuNumber: number): this;
|
|
228
|
+
setMemoryRamSize(memoryRamSize: number): this;
|
|
229
|
+
setDataDiskSize(dataDiskSize: number): this;
|
|
230
|
+
setCoverResolutionWidth(coverResolutionWidth: number | string): this;
|
|
231
|
+
setCoverResolutionHeight(coverResolutionHeight: number | string): this;
|
|
232
|
+
setCoverDiagonalSize(coverDiagonalSize: number | string): this;
|
|
233
|
+
setIsDefault(isDefault: boolean): this;
|
|
234
|
+
setIsCustomize(isCustomize: boolean): this;
|
|
235
|
+
setIsPublic(isPublic: boolean): this;
|
|
236
|
+
setVendorCountry(vendorCountry: string): this;
|
|
237
|
+
setHwHdcPort(hwHdcPort: string | number): this;
|
|
238
|
+
/**
|
|
239
|
+
* Build the list object of the current device.
|
|
240
|
+
*
|
|
241
|
+
* @returns The list object of the current device. Can be used to build the `lists.json` file.
|
|
242
|
+
*/
|
|
243
|
+
buildList(): Promise<FullDeployedImageOptions>;
|
|
244
|
+
/**
|
|
245
|
+
* Build the `config.ini` object of the current device.
|
|
246
|
+
*
|
|
247
|
+
* @returns The `config.ini` object of the current device.
|
|
248
|
+
*/
|
|
249
|
+
buildIni(): Promise<Record<string, string | undefined>>;
|
|
250
|
+
/**
|
|
251
|
+
* Build the `config.ini` string of the current device.
|
|
252
|
+
*
|
|
253
|
+
* @returns The `config.ini` string of the current device, can write to file directly.
|
|
254
|
+
*/
|
|
255
|
+
toIniString(): Promise<string>;
|
|
256
|
+
/**
|
|
257
|
+
* Deploy the image.
|
|
258
|
+
*
|
|
259
|
+
* @param symlinkImage - If true, symlink the system image to current device directory. Default is `true`.
|
|
260
|
+
*/
|
|
261
|
+
deploy(symlinkImage?: boolean): Promise<void | Error>;
|
|
262
|
+
}
|
|
263
|
+
//#endregion
|
|
264
|
+
export { Arch, DeployedDevModel, DeployedImageConfig, DeployedImageConfigWithProductName, DeployedImageOptions, DevModel, DeviceType, FullDeployedImageOptions, type Image, type ImageDeployer, type ImageManager, type ImageManagerOptions, type ImageType, type LocalImage, OS, PascalCaseDeviceType, type ProductConfig, type RemoteImage, RequestUrlError, SnakecaseDeviceType, Stringifiable, createImageManager };
|