@arkts/image-manager 0.0.4 → 0.1.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/index.cjs +26 -20
- package/dist/index.d.cts +18 -10
- package/dist/index.d.mts +18 -10
- package/dist/index.mjs +26 -20
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -464,6 +464,21 @@ var ImageBase = class {
|
|
|
464
464
|
return new RequestUrlError(error.message, error.code, error);
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
|
+
toJSON() {
|
|
468
|
+
return {
|
|
469
|
+
imageType: this.imageType,
|
|
470
|
+
arch: this.getArch(),
|
|
471
|
+
path: this.getPath(),
|
|
472
|
+
checksum: this.getChecksum(),
|
|
473
|
+
fsPath: this.getFsPath(),
|
|
474
|
+
version: this.getVersion(),
|
|
475
|
+
apiVersion: this.getApiVersion(),
|
|
476
|
+
targetOS: this.getTargetOS(),
|
|
477
|
+
targetVersion: this.getTargetVersion(),
|
|
478
|
+
deviceType: this.getDeviceType(),
|
|
479
|
+
snakecaseDeviceType: this.getSnakecaseDeviceType()
|
|
480
|
+
};
|
|
481
|
+
}
|
|
467
482
|
};
|
|
468
483
|
|
|
469
484
|
//#endregion
|
|
@@ -517,12 +532,8 @@ var LocalImageImpl = class extends ImageBase {
|
|
|
517
532
|
}
|
|
518
533
|
toJSON() {
|
|
519
534
|
return {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
version: this.getVersion(),
|
|
523
|
-
apiVersion: this.getApiVersion(),
|
|
524
|
-
targetVersion: this.getTargetVersion(),
|
|
525
|
-
checksum: this.getChecksum()
|
|
535
|
+
...super.toJSON(),
|
|
536
|
+
executablePath: this.getExecutablePath()
|
|
526
537
|
};
|
|
527
538
|
}
|
|
528
539
|
};
|
|
@@ -532,12 +543,7 @@ var LocalImageImpl = class extends ImageBase {
|
|
|
532
543
|
var RemoteImageImpl = class extends ImageBase {
|
|
533
544
|
imageType = "remote";
|
|
534
545
|
toJSON() {
|
|
535
|
-
return
|
|
536
|
-
imageType: this.imageType,
|
|
537
|
-
path: this.getPath(),
|
|
538
|
-
apiVersion: this.getApiVersion(),
|
|
539
|
-
checksum: this.getChecksum()
|
|
540
|
-
};
|
|
546
|
+
return super.toJSON();
|
|
541
547
|
}
|
|
542
548
|
};
|
|
543
549
|
|
|
@@ -584,20 +590,20 @@ async function resolveImageManagerOptions(options) {
|
|
|
584
590
|
function resolveDefaultEmulatorPath() {
|
|
585
591
|
switch (process.platform) {
|
|
586
592
|
case "darwin": return "/Applications/DevEco-Studio.app/Contents/tools/emulator/Emulator";
|
|
587
|
-
case "win32": return
|
|
593
|
+
case "win32": return "C:\\Program Files\\Huawei\\DevEco Studio\\tools\\emulator\\Emulator.exe";
|
|
588
594
|
default: return path.resolve(os.homedir(), ".huawei", "Emulator");
|
|
589
595
|
}
|
|
590
596
|
}
|
|
591
|
-
const imageBasePath = options.imageBasePath
|
|
592
|
-
const cachePath = options.cachePath
|
|
597
|
+
const imageBasePath = options.imageBasePath || resolveDefaultImageBasePath();
|
|
598
|
+
const cachePath = options.cachePath || path.resolve(imageBasePath, "cache");
|
|
593
599
|
return {
|
|
594
600
|
imageBasePath,
|
|
595
|
-
deployedPath: options.deployedPath
|
|
601
|
+
deployedPath: options.deployedPath || resolveDefaultDeployedPath(),
|
|
596
602
|
cachePath,
|
|
597
|
-
sdkPath: options.sdkPath
|
|
598
|
-
configPath: options.configPath
|
|
599
|
-
logPath: options.logPath
|
|
600
|
-
emulatorPath: options.emulatorPath
|
|
603
|
+
sdkPath: options.sdkPath || resolveDefaultSdkPath(),
|
|
604
|
+
configPath: options.configPath || resolveDefaultConfigPath(),
|
|
605
|
+
logPath: options.logPath || resolveDefaultLogPath(),
|
|
606
|
+
emulatorPath: options.emulatorPath || resolveDefaultEmulatorPath(),
|
|
601
607
|
path,
|
|
602
608
|
os,
|
|
603
609
|
fs: options.fs ?? await import("node:fs"),
|
package/dist/index.d.cts
CHANGED
|
@@ -21,13 +21,9 @@ interface LocalImage extends BaseImage, Stringifiable<LocalImage.Stringifiable>
|
|
|
21
21
|
stop(deployer: ImageDeployer): Promise<node_child_process0.ChildProcess>;
|
|
22
22
|
}
|
|
23
23
|
declare namespace LocalImage {
|
|
24
|
-
interface Stringifiable {
|
|
24
|
+
interface Stringifiable extends Omit<BaseImage.Stringifiable, 'imageType'> {
|
|
25
25
|
imageType: 'local';
|
|
26
|
-
|
|
27
|
-
version: string;
|
|
28
|
-
apiVersion: string;
|
|
29
|
-
targetVersion: string;
|
|
30
|
-
checksum: string;
|
|
26
|
+
executablePath: string;
|
|
31
27
|
}
|
|
32
28
|
}
|
|
33
29
|
//#endregion
|
|
@@ -36,11 +32,8 @@ interface RemoteImage extends BaseImage, Stringifiable<RemoteImage.Stringifiable
|
|
|
36
32
|
imageType: 'remote';
|
|
37
33
|
}
|
|
38
34
|
declare namespace RemoteImage {
|
|
39
|
-
interface Stringifiable {
|
|
35
|
+
interface Stringifiable extends Omit<BaseImage.Stringifiable, 'imageType'> {
|
|
40
36
|
imageType: 'remote';
|
|
41
|
-
path: string;
|
|
42
|
-
apiVersion: string;
|
|
43
|
-
checksum: string;
|
|
44
37
|
}
|
|
45
38
|
}
|
|
46
39
|
//#endregion
|
|
@@ -216,6 +209,21 @@ interface BaseImage {
|
|
|
216
209
|
isDownloaded(): Promise<boolean>;
|
|
217
210
|
createDownloader(signal?: AbortSignal): Promise<ImageDownloader<this> | RequestUrlError>;
|
|
218
211
|
}
|
|
212
|
+
declare namespace BaseImage {
|
|
213
|
+
interface Stringifiable {
|
|
214
|
+
imageType: ImageType;
|
|
215
|
+
arch: 'arm' | 'x86' | (string & {});
|
|
216
|
+
path: string;
|
|
217
|
+
checksum: string;
|
|
218
|
+
fsPath: string;
|
|
219
|
+
version: string;
|
|
220
|
+
apiVersion: string;
|
|
221
|
+
targetOS: string;
|
|
222
|
+
targetVersion: string;
|
|
223
|
+
deviceType: DeviceType | (string & {});
|
|
224
|
+
snakecaseDeviceType: SnakecaseDeviceType | (string & {});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
219
227
|
type Image = LocalImage | RemoteImage;
|
|
220
228
|
type ImageType = 'local' | 'remote';
|
|
221
229
|
//#endregion
|
package/dist/index.d.mts
CHANGED
|
@@ -21,13 +21,9 @@ interface LocalImage extends BaseImage, Stringifiable<LocalImage.Stringifiable>
|
|
|
21
21
|
stop(deployer: ImageDeployer): Promise<node_child_process0.ChildProcess>;
|
|
22
22
|
}
|
|
23
23
|
declare namespace LocalImage {
|
|
24
|
-
interface Stringifiable {
|
|
24
|
+
interface Stringifiable extends Omit<BaseImage.Stringifiable, 'imageType'> {
|
|
25
25
|
imageType: 'local';
|
|
26
|
-
|
|
27
|
-
version: string;
|
|
28
|
-
apiVersion: string;
|
|
29
|
-
targetVersion: string;
|
|
30
|
-
checksum: string;
|
|
26
|
+
executablePath: string;
|
|
31
27
|
}
|
|
32
28
|
}
|
|
33
29
|
//#endregion
|
|
@@ -36,11 +32,8 @@ interface RemoteImage extends BaseImage, Stringifiable<RemoteImage.Stringifiable
|
|
|
36
32
|
imageType: 'remote';
|
|
37
33
|
}
|
|
38
34
|
declare namespace RemoteImage {
|
|
39
|
-
interface Stringifiable {
|
|
35
|
+
interface Stringifiable extends Omit<BaseImage.Stringifiable, 'imageType'> {
|
|
40
36
|
imageType: 'remote';
|
|
41
|
-
path: string;
|
|
42
|
-
apiVersion: string;
|
|
43
|
-
checksum: string;
|
|
44
37
|
}
|
|
45
38
|
}
|
|
46
39
|
//#endregion
|
|
@@ -216,6 +209,21 @@ interface BaseImage {
|
|
|
216
209
|
isDownloaded(): Promise<boolean>;
|
|
217
210
|
createDownloader(signal?: AbortSignal): Promise<ImageDownloader<this> | RequestUrlError>;
|
|
218
211
|
}
|
|
212
|
+
declare namespace BaseImage {
|
|
213
|
+
interface Stringifiable {
|
|
214
|
+
imageType: ImageType;
|
|
215
|
+
arch: 'arm' | 'x86' | (string & {});
|
|
216
|
+
path: string;
|
|
217
|
+
checksum: string;
|
|
218
|
+
fsPath: string;
|
|
219
|
+
version: string;
|
|
220
|
+
apiVersion: string;
|
|
221
|
+
targetOS: string;
|
|
222
|
+
targetVersion: string;
|
|
223
|
+
deviceType: DeviceType | (string & {});
|
|
224
|
+
snakecaseDeviceType: SnakecaseDeviceType | (string & {});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
219
227
|
type Image = LocalImage | RemoteImage;
|
|
220
228
|
type ImageType = 'local' | 'remote';
|
|
221
229
|
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -432,6 +432,21 @@ var ImageBase = class {
|
|
|
432
432
|
return new RequestUrlError(error.message, error.code, error);
|
|
433
433
|
}
|
|
434
434
|
}
|
|
435
|
+
toJSON() {
|
|
436
|
+
return {
|
|
437
|
+
imageType: this.imageType,
|
|
438
|
+
arch: this.getArch(),
|
|
439
|
+
path: this.getPath(),
|
|
440
|
+
checksum: this.getChecksum(),
|
|
441
|
+
fsPath: this.getFsPath(),
|
|
442
|
+
version: this.getVersion(),
|
|
443
|
+
apiVersion: this.getApiVersion(),
|
|
444
|
+
targetOS: this.getTargetOS(),
|
|
445
|
+
targetVersion: this.getTargetVersion(),
|
|
446
|
+
deviceType: this.getDeviceType(),
|
|
447
|
+
snakecaseDeviceType: this.getSnakecaseDeviceType()
|
|
448
|
+
};
|
|
449
|
+
}
|
|
435
450
|
};
|
|
436
451
|
|
|
437
452
|
//#endregion
|
|
@@ -485,12 +500,8 @@ var LocalImageImpl = class extends ImageBase {
|
|
|
485
500
|
}
|
|
486
501
|
toJSON() {
|
|
487
502
|
return {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
version: this.getVersion(),
|
|
491
|
-
apiVersion: this.getApiVersion(),
|
|
492
|
-
targetVersion: this.getTargetVersion(),
|
|
493
|
-
checksum: this.getChecksum()
|
|
503
|
+
...super.toJSON(),
|
|
504
|
+
executablePath: this.getExecutablePath()
|
|
494
505
|
};
|
|
495
506
|
}
|
|
496
507
|
};
|
|
@@ -500,12 +511,7 @@ var LocalImageImpl = class extends ImageBase {
|
|
|
500
511
|
var RemoteImageImpl = class extends ImageBase {
|
|
501
512
|
imageType = "remote";
|
|
502
513
|
toJSON() {
|
|
503
|
-
return
|
|
504
|
-
imageType: this.imageType,
|
|
505
|
-
path: this.getPath(),
|
|
506
|
-
apiVersion: this.getApiVersion(),
|
|
507
|
-
checksum: this.getChecksum()
|
|
508
|
-
};
|
|
514
|
+
return super.toJSON();
|
|
509
515
|
}
|
|
510
516
|
};
|
|
511
517
|
|
|
@@ -552,20 +558,20 @@ async function resolveImageManagerOptions(options) {
|
|
|
552
558
|
function resolveDefaultEmulatorPath() {
|
|
553
559
|
switch (process.platform) {
|
|
554
560
|
case "darwin": return "/Applications/DevEco-Studio.app/Contents/tools/emulator/Emulator";
|
|
555
|
-
case "win32": return
|
|
561
|
+
case "win32": return "C:\\Program Files\\Huawei\\DevEco Studio\\tools\\emulator\\Emulator.exe";
|
|
556
562
|
default: return path.resolve(os.homedir(), ".huawei", "Emulator");
|
|
557
563
|
}
|
|
558
564
|
}
|
|
559
|
-
const imageBasePath = options.imageBasePath
|
|
560
|
-
const cachePath = options.cachePath
|
|
565
|
+
const imageBasePath = options.imageBasePath || resolveDefaultImageBasePath();
|
|
566
|
+
const cachePath = options.cachePath || path.resolve(imageBasePath, "cache");
|
|
561
567
|
return {
|
|
562
568
|
imageBasePath,
|
|
563
|
-
deployedPath: options.deployedPath
|
|
569
|
+
deployedPath: options.deployedPath || resolveDefaultDeployedPath(),
|
|
564
570
|
cachePath,
|
|
565
|
-
sdkPath: options.sdkPath
|
|
566
|
-
configPath: options.configPath
|
|
567
|
-
logPath: options.logPath
|
|
568
|
-
emulatorPath: options.emulatorPath
|
|
571
|
+
sdkPath: options.sdkPath || resolveDefaultSdkPath(),
|
|
572
|
+
configPath: options.configPath || resolveDefaultConfigPath(),
|
|
573
|
+
logPath: options.logPath || resolveDefaultLogPath(),
|
|
574
|
+
emulatorPath: options.emulatorPath || resolveDefaultEmulatorPath(),
|
|
569
575
|
path,
|
|
570
576
|
os,
|
|
571
577
|
fs: options.fs ?? await import("node:fs"),
|
package/package.json
CHANGED