@arkts/image-manager 0.5.3 → 0.5.5

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.d.cts CHANGED
@@ -33,7 +33,7 @@ interface SerializableContent<T extends SerializableContent.Content = Serializab
33
33
  }
34
34
  declare namespace SerializableContent {
35
35
  type Content = Record<PropertyKey, any> | Content[];
36
- interface Serializable extends BaseSerializable<SerializableContent> {}
36
+ interface Serializable extends Omit<BaseSerializable<SerializableContent>, 'imageManager'> {}
37
37
  }
38
38
  //#endregion
39
39
  //#region src/configs/product/product.d.ts
@@ -90,7 +90,7 @@ declare namespace ProductConfigFile {
90
90
  } ? Content[DeviceType][number] : Content[DeviceType][number];
91
91
  /** Names from device types other than DeviceType. Used to detect ambiguous names like "Customize". */
92
92
  type OtherDeviceTypeNames<DeviceType extends ProductConfigFile.DeviceType> = Exclude<ProductConfigItem.Name, Content[DeviceType][number]['name']>;
93
- interface Serializable extends BaseSerializable<ProductConfigFile> {}
93
+ interface Serializable extends Omit<BaseSerializable<ProductConfigFile>, 'imageManager'> {}
94
94
  interface Generic {
95
95
  readonly deviceType: DeviceType;
96
96
  readonly name: ProductConfigItem.NameWithString;
@@ -295,7 +295,7 @@ declare namespace ProductConfigItem {
295
295
  readonly name: WearableKidName;
296
296
  }
297
297
  type Content = PhoneContent | TabletContent | TwoInOneContent | FoldableContent | WideFoldContent | TripleFoldContent | TwoInOneFoldableContent | TVContent | WearableContent | WearableKidContent;
298
- interface Serializable extends BaseSerializable<ProductConfigItem> {}
298
+ interface Serializable extends Omit<BaseSerializable<ProductConfigItem>, 'imageManager'> {}
299
299
  type DevModel = 'MCHEMU-AL00CN' | 'PHEMU-FD00' | 'PHEMU-FD01' | 'PHEMU-FD02' | 'PCEMU-FD05' | 'PHEMU-FD06';
300
300
  type DevModelWithString = DevModel | (string & {});
301
301
  function is(value: unknown): value is ProductConfigItem;
@@ -309,7 +309,7 @@ interface ListsFile extends Serializable<ListsFile.Serializable>, Omit<Serializa
309
309
  }
310
310
  declare namespace ListsFile {
311
311
  type Content = ListsFileItem.Content[];
312
- interface Serializable extends BaseSerializable<ListsFile> {}
312
+ interface Serializable extends Omit<BaseSerializable<ListsFile>, 'imageManager'> {}
313
313
  function is(value: unknown): value is ListsFile;
314
314
  }
315
315
  //#endregion
@@ -318,7 +318,7 @@ interface ListsFileItem<ProductDeviceType extends ProductConfigFile.DeviceType =
318
318
  getListsFile(): ListsFile;
319
319
  }
320
320
  declare namespace ListsFileItem {
321
- interface Serializable extends BaseSerializable<ListsFileItem> {}
321
+ interface Serializable extends Omit<BaseSerializable<ListsFileItem>, 'imageManager'> {}
322
322
  type DeviceType = 'phone' | 'tablet' | '2in1' | 'foldable' | 'widefold' | 'triplefold' | '2in1_foldable' | 'tv' | 'wearable';
323
323
  type DeviceTypeWithString = DeviceType | (string & {});
324
324
  interface Content<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> {
@@ -529,225 +529,100 @@ declare namespace CustomizeFoldableScreen {
529
529
  function is(value: unknown): value is CustomizeFoldableScreen;
530
530
  }
531
531
  //#endregion
532
- //#region src/configs/emulator/emulator-basic-item.d.ts
533
- interface EmulatorBasicItem extends SerializableContent<EmulatorBasicItem.Content> {
534
- getEmulatorFile(): EmulatorFile;
535
- }
536
- declare namespace EmulatorBasicItem {
537
- type DeviceType = '2in1' | 'tablet' | 'tv' | 'wearable' | 'phone';
538
- type DeviceTypeWithString = DeviceType | (string & {});
539
- interface Content {
540
- readonly name: string;
541
- readonly deviceType: DeviceType;
542
- readonly resolutionWidth: number;
543
- readonly resolutionHeight: number;
544
- readonly physicalWidth: number;
545
- readonly physicalHeight: number;
546
- readonly diagonalSize: number;
547
- readonly density: number;
548
- readonly memoryRamSize: number;
549
- readonly datadiskSize: number;
550
- readonly procNumber: number;
551
- readonly api: number;
552
- }
553
- function is(value: unknown): value is EmulatorBasicItem;
554
- function isDeviceType(value: unknown): value is DeviceType;
555
- function isContent(value: unknown): value is Content;
556
- }
557
- //#endregion
558
- //#region src/configs/emulator/emulator-fold-item.d.ts
559
- interface EmulatorFoldItem extends SerializableContent<EmulatorFoldItem.Content> {
560
- getEmulatorFile(): EmulatorFile;
532
+ //#region src/images/local-image.d.ts
533
+ interface LocalImage extends Serializable<LocalImage.Serializable>, Omit<BaseImage, 'toJSON'> {
534
+ readonly imageType: 'local';
535
+ /**
536
+ * Get the SDK package file.
537
+ *
538
+ * @returns The SDK package file.
539
+ */
540
+ getSdkPkgFile(): LocalImage.OptionalSdkPkgFile;
541
+ /**
542
+ * Create a device from the local image.
543
+ *
544
+ * @param options - The options to create the device.
545
+ */
546
+ createDevice<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']>(options: LocalImage.CreateDeviceOptions<ProductDeviceType, ProductName>): Promise<Device<ProductDeviceType, ProductName>>;
561
547
  }
562
- declare namespace EmulatorFoldItem {
563
- type DeviceType = 'foldable' | '2in1_foldable' | 'triplefold' | 'widefold';
564
- interface Content extends Omit<EmulatorBasicItem.Content, 'deviceType'> {
565
- readonly deviceType: DeviceType;
566
- readonly coverResolutionWidth: number;
567
- readonly coverResolutionHeight: number;
568
- readonly coverDiagonalSize: number;
548
+ declare namespace LocalImage {
549
+ interface Serializable extends BaseImage.Serializable, Omit<BaseSerializable<LocalImage>, 'imageManager'> {}
550
+ interface SdkPkgFile {
551
+ /**
552
+ * The SDK package file data.
553
+ */
554
+ readonly data: SdkPkgFile.Data;
569
555
  }
570
- function is(value: unknown): value is EmulatorFoldItem;
571
- function isDeviceType(value: unknown): value is DeviceType;
572
- function isContent(value: unknown): value is Content;
573
- }
574
- //#endregion
575
- //#region src/configs/emulator/emulator-triplefold-item.d.ts
576
- interface EmulatorTripleFoldItem extends SerializableContent<EmulatorTripleFoldItem.Content> {
577
- getEmulatorFile(): EmulatorFile;
578
- }
579
- declare namespace EmulatorTripleFoldItem {
580
- type DeviceType = 'triplefold';
581
- type DeviceTypeWithString = DeviceType;
582
- interface Content extends Omit<EmulatorBasicItem.Content, 'deviceType'> {
583
- readonly deviceType: DeviceType;
584
- readonly singleResolutionWidth: number;
585
- readonly singleResolutionHeight: number;
586
- readonly singleDiagonalSize: number;
587
- readonly doubleResolutionWidth: number;
588
- readonly doubleResolutionHeight: number;
589
- readonly doubleDiagonalSize: number;
556
+ namespace SdkPkgFile {
557
+ interface Data {
558
+ /** @example '13' */
559
+ readonly apiVersion: string;
560
+ /** @example 'System-image-foldable' */
561
+ readonly displayName: string;
562
+ /** @example 'system-image,HarmonyOS-5.0.1,foldable_arm' */
563
+ readonly path: string;
564
+ /** @example '5.0.1' */
565
+ readonly platformVersion: string;
566
+ /** @example 'Release' */
567
+ readonly releaseType: string;
568
+ /** @example '5.0.0.112' */
569
+ readonly version: string;
570
+ /** @example 'HarmonyOS 5.0.0.112(SP2)' */
571
+ readonly guestVersion: string;
572
+ /** @example 'Release' */
573
+ readonly stage: string;
574
+ }
590
575
  }
591
- function is(value: unknown): value is EmulatorTripleFoldItem;
592
- function isDeviceType(value: unknown): value is DeviceType;
593
- function isContent(value: unknown): value is Content;
594
- }
595
- //#endregion
596
- //#region src/configs/emulator/group-item.d.ts
597
- interface EmulatorGroupItem extends SerializableContent<EmulatorGroupItem.Content> {
598
- getEmulatorFile(): EmulatorFile;
599
- getChildren(): EmulatorFile.DeviceItem[];
600
- }
601
- declare namespace EmulatorGroupItem {
602
- type DeviceType = 'phone_all' | 'pc_all';
603
- type DeviceTypeWithString = DeviceType | (string & {});
604
- interface Content {
605
- readonly name: string;
606
- readonly deviceType: DeviceTypeWithString;
607
- readonly api: number;
608
- readonly children: EmulatorFile.ItemContent[];
576
+ type OptionalSdkPkgFile = DeepPartial<SdkPkgFile>;
577
+ interface InfoFile {
578
+ /** @example '21' */
579
+ apiVersion: string;
580
+ /** @example 'arm' */
581
+ abi: string;
582
+ /** @example '6.0.0.112' */
583
+ version: string;
609
584
  }
610
- function is(value: unknown): value is EmulatorGroupItem;
611
- function isContent(value: unknown): value is EmulatorGroupItem.Content;
612
- }
613
- //#endregion
614
- //#region src/configs/emulator/emulator.d.ts
615
- interface EmulatorFile extends Serializable<EmulatorFile.Serializable>, Omit<SerializableFile, 'toJSON'> {
616
- findDeviceItems<DeviceType extends EmulatorFile.DeviceType>(options?: EmulatorFile.FindDeviceItemOptions<DeviceType extends EmulatorGroupItem.DeviceType ? never : DeviceType>): EmulatorFile.DeviceItem[];
617
- findDeviceItem<DeviceType extends EmulatorFile.DeviceType>(options?: EmulatorFile.FindDeviceItemOptions<DeviceType extends EmulatorGroupItem.DeviceType ? never : DeviceType>): EmulatorFile.DeviceItem | undefined;
618
- findItems(options?: EmulatorFile.FindItemOptions): EmulatorFile.Item[];
619
- findItem(options?: EmulatorFile.FindItemOptions): EmulatorFile.Item | undefined;
620
- getItems(): EmulatorFile.Item[];
621
- }
622
- declare namespace EmulatorFile {
623
- interface Serializable extends BaseSerializable<EmulatorFile> {}
624
- type ItemContent = EmulatorBasicItem.Content | EmulatorFoldItem.Content | EmulatorTripleFoldItem.Content;
625
- type Content = Array<ContentItem>;
626
- type ContentItem = EmulatorGroupItem.Content | ItemContent;
627
- type DeviceItem = EmulatorBasicItem | EmulatorFoldItem | EmulatorTripleFoldItem;
628
- type Item = EmulatorGroupItem | DeviceItem;
629
- type DeviceType = EmulatorBasicItem.DeviceType | EmulatorFoldItem.DeviceType | EmulatorTripleFoldItem.DeviceType;
630
- type DeviceTypeWithString = DeviceType | (string & {});
631
- type FullDeviceType = DeviceType | EmulatorGroupItem.DeviceType;
632
- type FullDeviceTypeWithString = FullDeviceType | (string & {});
633
- function is(value: unknown): value is EmulatorFile;
634
- function isItemContent(value: unknown): value is EmulatorFile.ItemContent;
635
- function isContentItem(value: unknown): value is EmulatorFile.ContentItem;
636
- interface FindDeviceItemOptions<DeviceType extends DeviceTypeWithString = DeviceTypeWithString> {
637
- /**
638
- * The API version to find.
639
- */
640
- readonly apiVersion?: number;
585
+ interface CreateDeviceOptions<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> {
641
586
  /**
642
- * The device type to find.
587
+ * The name of the device.
588
+ *
589
+ * @example 'Huawei_Wearable'
643
590
  */
644
- readonly deviceType?: DeviceType;
645
- }
646
- interface FindItemOptions {
591
+ readonly name: string;
647
592
  /**
648
- * The API version to find.
593
+ * The CPU number.
594
+ *
595
+ * @example 4
649
596
  */
650
- readonly apiVersion?: number;
597
+ readonly cpuNumber: number;
651
598
  /**
652
- * The device type to find.
599
+ * The memory RAM size. (in MB)
600
+ *
601
+ * @example 4096
653
602
  */
654
- readonly fullDeviceType?: FullDeviceTypeWithString;
655
- }
656
- }
657
- //#endregion
658
- //#region src/screens/screen-preset.d.ts
659
- interface ScreenPreset<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> {
660
- /**
661
- * Get the emulator item content.
662
- *
663
- * @returns The emulator item content.
664
- */
665
- getEmulatorDeviceItem(): EmulatorFile.DeviceItem;
666
- /**
667
- * Get the product config item content.
668
- *
669
- * @returns The product config item content.
670
- */
671
- getProductConfigItem(): ProductConfigItem<ProductDeviceType, ProductName>;
672
- /**
673
- * Get the customize screen config.
674
- *
675
- * @returns The customize screen config.
676
- */
677
- getCustomizeScreenConfig(): CustomizeScreen | CustomizeFoldableScreen | undefined;
678
- }
679
- declare namespace ScreenPreset {
680
- interface Serializable<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> extends BaseSerializable<ScreenPreset<ProductDeviceType, ProductName>> {}
681
- interface PresetOptions<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> {
603
+ readonly memoryRamSize: number;
682
604
  /**
683
- * The emulator item content.
605
+ * The data disk size. (in MB)
606
+ *
607
+ * @example 6144
684
608
  */
685
- readonly emulatorDeviceItem: EmulatorFile.DeviceItem;
609
+ readonly dataDiskSize: number;
686
610
  /**
687
- * The product config item content.
611
+ * The screen.
688
612
  */
689
- readonly productConfigItem: ProductConfigItem<ProductDeviceType, ProductName>;
690
- }
691
- interface CustomizeOptions<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> extends PresetOptions<ProductDeviceType, ProductName> {
613
+ readonly screen: ScreenPreset.Options<ProductDeviceType, ProductName>;
692
614
  /**
693
- * The customize screen options.
615
+ * The vendor country.
616
+ *
617
+ * @example 'CN'
694
618
  */
695
- readonly customizeScreen: CustomizeScreen.Options;
696
- }
697
- interface CustomizeFoldableOptions<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> extends CustomizeOptions<ProductDeviceType, ProductName> {
619
+ readonly vendorCountry?: string;
698
620
  /**
699
- * The customize foldable screen options.
621
+ * @default true
700
622
  */
701
- readonly customizeFoldableScreen: CustomizeFoldableScreen.Options;
623
+ readonly isPublic?: boolean;
702
624
  }
703
- type Options<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> = ProductName extends ProductConfigItem.Customize ? ProductDeviceType extends 'Foldable' ? CustomizeFoldableOptions<ProductDeviceType, ProductName> : CustomizeOptions<ProductDeviceType, ProductName> : PresetOptions<ProductDeviceType, ProductName>;
704
- function is(value: unknown): value is ScreenPreset;
705
- }
706
- //#endregion
707
- //#region src/devices/device.d.ts
708
- interface Device<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> extends Serializable<Device.Serializable<ProductDeviceType, ProductName>> {
709
- /** Get the screen of the device. */
710
- getScreen(): ScreenPreset<ProductDeviceType, ProductName>;
711
- /** Get the image manager of the device. */
712
- getImageManager(): ImageManager;
713
- /** Get the lists file of the device. */
714
- getListsFile(): ListsFile;
715
- /** Get the lists file item of the device. */
716
- getListsFileItem(): ListsFileItem;
717
- /** Get the config INI file of the device. */
718
- getConfigIniFile(): ConfigIniFile<ProductDeviceType, ProductName>;
719
- /** Get the named INI file of the device. */
720
- getNamedIniFile(): NamedIniFile<ProductDeviceType, ProductName>;
721
- /** Get the executable URI of the device. */
722
- getExecutableUri(): vscode_uri0.URI;
723
- /** Get the snapshot URI of the device. */
724
- getSnapshotUri(): vscode_uri0.URI;
725
- /** Get the snapshot base64 string of the device. */
726
- getSnapshot(): Promise<string>;
727
- /** Get the start command of the device. */
728
- getStartCommand(): [string, string[]];
729
- /** Get the stop command of the device. */
730
- getStopCommand(): [string, string[]];
731
- /** Start the device. */
732
- start(): Promise<child_process.ChildProcessByStdio<null, Readable, Readable>>;
733
- /** Stop the device. */
734
- stop(): Promise<child_process.ChildProcessByStdio<null, Readable, Readable>>;
735
- /** Delete the device. */
736
- delete(): Promise<void>;
737
- /** Get the storage size of the device. */
738
- getStorageSize(): Promise<number>;
739
- /**
740
- * Get the watcher of the device.
741
- *
742
- * - If the watcher is already created, it will return the existing watcher.
743
- * - If the watcher is disposed, it will create a new watcher.
744
- * - If the watcher is already created but disposed, it will create a new watcher.
745
- */
746
- getWatcher(): Promise<FileSystemWatcher>;
747
- }
748
- declare namespace Device {
749
- interface Serializable<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> extends Omit<BaseSerializable<Device<ProductDeviceType, ProductName>>, 'imageManager'> {}
750
- function is(value: unknown): value is Device;
625
+ function is(value: unknown): value is LocalImage;
751
626
  }
752
627
  //#endregion
753
628
  //#region src/event-emitter.d.ts
@@ -876,199 +751,326 @@ declare namespace SDKList {
876
751
  type OKResponse = RemoteImageSDK[];
877
752
  interface ErrorResponse {
878
753
  /**
879
- * The error code.
754
+ * The error code.
755
+ */
756
+ readonly code: number;
757
+ /**
758
+ * The error message.
759
+ */
760
+ readonly body: string;
761
+ }
762
+ type AxiosResponse = axios.AxiosResponse<OKResponse>;
763
+ type AxiosError = axios.AxiosError<ErrorResponse>;
764
+ type Result = AxiosResponse | AxiosError;
765
+ function isOKResponse(result: Result): result is AxiosResponse;
766
+ class SDKListError extends Error {
767
+ readonly code: SDKListError.Code;
768
+ readonly message: string;
769
+ readonly cause?: (AxiosError | AxiosResponse) | undefined;
770
+ constructor(code: SDKListError.Code, message: string, cause?: (AxiosError | AxiosResponse) | undefined);
771
+ }
772
+ namespace SDKListError {
773
+ enum Code {
774
+ VALIDATION_ERROR = 400,
775
+ REQUEST_ERROR = 500
776
+ }
777
+ }
778
+ }
779
+ //#endregion
780
+ //#region src/images/remote-image.d.ts
781
+ interface RemoteImage extends Serializable<RemoteImage.Serializable>, Omit<BaseImage, 'toJSON'> {
782
+ readonly imageType: 'remote';
783
+ /**
784
+ * Get the remote image SDK.
785
+ *
786
+ * @returns The remote image SDK.
787
+ */
788
+ getRemoteImageSDK(): SDKList.OptionalRemoteImageSDK;
789
+ /**
790
+ * Get the local image if it is already downloaded.
791
+ *
792
+ * @param force - If `true` will reload the local image from the image manager and file system again. Default is `false`.
793
+ * @returns The local image if it is already downloaded, otherwise `undefined`.
794
+ */
795
+ getLocalImage(force?: boolean): Promise<LocalImage | undefined>;
796
+ /**
797
+ * Create a downloader for the remote image.
798
+ *
799
+ * @param signals - The signals to abort the download.
800
+ */
801
+ createDownloader(signals?: AbortController): Promise<ImageDownloader>;
802
+ }
803
+ declare namespace RemoteImage {
804
+ interface Serializable extends BaseImage.Serializable, Omit<BaseSerializable<RemoteImage>, 'imageManager'> {}
805
+ function is(value: unknown): value is RemoteImage;
806
+ }
807
+ //#endregion
808
+ //#region src/images/image.d.ts
809
+ type Image = LocalImage | RemoteImage;
810
+ declare namespace Image {
811
+ type RelativePath = `system-image/${string}/${string}`;
812
+ function is(value: unknown): value is Image;
813
+ }
814
+ //#endregion
815
+ //#region src/images/base-image.d.ts
816
+ interface BaseImage extends Serializable<BaseImage.Serializable> {
817
+ /**
818
+ * The type of the image.
819
+ */
820
+ readonly imageType: 'local' | 'remote';
821
+ /**
822
+ * Get the image manager.
823
+ */
824
+ getImageManager(): ImageManager;
825
+ /**
826
+ * Get the relative path of the image.
827
+ */
828
+ getRelativePath(): Image.RelativePath;
829
+ /**
830
+ * Get the full path of the image.
831
+ */
832
+ getFullPath(): vscode_uri0.URI;
833
+ /**
834
+ * Check if the image is downloaded.
835
+ */
836
+ isDownloaded(): Promise<boolean>;
837
+ /**
838
+ * Get the API version of the image.
839
+ */
840
+ getApiVersion(): number;
841
+ /**
842
+ * Get the device type of the image.
843
+ */
844
+ getFullDeviceType(): EmulatorFile.FullDeviceTypeWithString;
845
+ }
846
+ declare namespace BaseImage {
847
+ interface Serializable extends Omit<BaseSerializable<BaseImage>, 'imageManager'> {
848
+ imageType: 'local' | 'remote';
849
+ }
850
+ function is(value: unknown): value is BaseImage;
851
+ }
852
+ //#endregion
853
+ //#region src/configs/emulator/emulator-basic-item.d.ts
854
+ interface EmulatorBasicItem extends SerializableContent<EmulatorBasicItem.Content> {
855
+ getEmulatorFile(): EmulatorFile;
856
+ }
857
+ declare namespace EmulatorBasicItem {
858
+ type DeviceType = '2in1' | 'tablet' | 'tv' | 'wearable' | 'phone';
859
+ type DeviceTypeWithString = DeviceType | (string & {});
860
+ interface Content {
861
+ readonly name: string;
862
+ readonly deviceType: DeviceType;
863
+ readonly resolutionWidth: number;
864
+ readonly resolutionHeight: number;
865
+ readonly physicalWidth: number;
866
+ readonly physicalHeight: number;
867
+ readonly diagonalSize: number;
868
+ readonly density: number;
869
+ readonly memoryRamSize: number;
870
+ readonly datadiskSize: number;
871
+ readonly procNumber: number;
872
+ readonly api: number;
873
+ }
874
+ function is(value: unknown): value is EmulatorBasicItem;
875
+ function isDeviceType(value: unknown): value is DeviceType;
876
+ function isContent(value: unknown): value is Content;
877
+ }
878
+ //#endregion
879
+ //#region src/configs/emulator/emulator-fold-item.d.ts
880
+ interface EmulatorFoldItem extends SerializableContent<EmulatorFoldItem.Content> {
881
+ getEmulatorFile(): EmulatorFile;
882
+ }
883
+ declare namespace EmulatorFoldItem {
884
+ type DeviceType = 'foldable' | '2in1_foldable' | 'triplefold' | 'widefold';
885
+ interface Content extends Omit<EmulatorBasicItem.Content, 'deviceType'> {
886
+ readonly deviceType: DeviceType;
887
+ readonly coverResolutionWidth: number;
888
+ readonly coverResolutionHeight: number;
889
+ readonly coverDiagonalSize: number;
890
+ }
891
+ function is(value: unknown): value is EmulatorFoldItem;
892
+ function isDeviceType(value: unknown): value is DeviceType;
893
+ function isContent(value: unknown): value is Content;
894
+ }
895
+ //#endregion
896
+ //#region src/configs/emulator/emulator-triplefold-item.d.ts
897
+ interface EmulatorTripleFoldItem extends SerializableContent<EmulatorTripleFoldItem.Content> {
898
+ getEmulatorFile(): EmulatorFile;
899
+ }
900
+ declare namespace EmulatorTripleFoldItem {
901
+ type DeviceType = 'triplefold';
902
+ type DeviceTypeWithString = DeviceType;
903
+ interface Content extends Omit<EmulatorBasicItem.Content, 'deviceType'> {
904
+ readonly deviceType: DeviceType;
905
+ readonly singleResolutionWidth: number;
906
+ readonly singleResolutionHeight: number;
907
+ readonly singleDiagonalSize: number;
908
+ readonly doubleResolutionWidth: number;
909
+ readonly doubleResolutionHeight: number;
910
+ readonly doubleDiagonalSize: number;
911
+ }
912
+ function is(value: unknown): value is EmulatorTripleFoldItem;
913
+ function isDeviceType(value: unknown): value is DeviceType;
914
+ function isContent(value: unknown): value is Content;
915
+ }
916
+ //#endregion
917
+ //#region src/configs/emulator/group-item.d.ts
918
+ interface EmulatorGroupItem extends SerializableContent<EmulatorGroupItem.Content> {
919
+ getEmulatorFile(): EmulatorFile;
920
+ getChildren(): EmulatorFile.DeviceItem[];
921
+ }
922
+ declare namespace EmulatorGroupItem {
923
+ type DeviceType = 'phone_all' | 'pc_all';
924
+ type DeviceTypeWithString = DeviceType | (string & {});
925
+ interface Content {
926
+ readonly name: string;
927
+ readonly deviceType: DeviceTypeWithString;
928
+ readonly api: number;
929
+ readonly children: EmulatorFile.ItemContent[];
930
+ }
931
+ function is(value: unknown): value is EmulatorGroupItem;
932
+ function isContent(value: unknown): value is EmulatorGroupItem.Content;
933
+ }
934
+ //#endregion
935
+ //#region src/configs/emulator/emulator.d.ts
936
+ interface EmulatorFile extends Serializable<EmulatorFile.Serializable>, Omit<SerializableFile, 'toJSON'> {
937
+ findDeviceItems<DeviceType extends EmulatorFile.DeviceType>(options?: EmulatorFile.FindDeviceItemOptions<DeviceType extends EmulatorGroupItem.DeviceType ? never : DeviceType>): EmulatorFile.DeviceItem[];
938
+ findDeviceItem<DeviceType extends EmulatorFile.DeviceType>(options?: EmulatorFile.FindDeviceItemOptions<DeviceType extends EmulatorGroupItem.DeviceType ? never : DeviceType>): EmulatorFile.DeviceItem | undefined;
939
+ findItems(options?: EmulatorFile.FindItemOptions): EmulatorFile.Item[];
940
+ findItem(options?: EmulatorFile.FindItemOptions): EmulatorFile.Item | undefined;
941
+ findRemoteImageByDeviceItem(deviceItem: EmulatorFile.DeviceItem, remoteImages: RemoteImage[]): RemoteImage | undefined;
942
+ getItems(): EmulatorFile.Item[];
943
+ getDeviceItems(): EmulatorFile.DeviceItem[];
944
+ }
945
+ declare namespace EmulatorFile {
946
+ interface Serializable extends Omit<BaseSerializable<EmulatorFile>, 'imageManager'> {}
947
+ type ItemContent = EmulatorBasicItem.Content | EmulatorFoldItem.Content | EmulatorTripleFoldItem.Content;
948
+ type Content = Array<ContentItem>;
949
+ type ContentItem = EmulatorGroupItem.Content | ItemContent;
950
+ type DeviceItem = EmulatorBasicItem | EmulatorFoldItem | EmulatorTripleFoldItem;
951
+ type Item = EmulatorGroupItem | DeviceItem;
952
+ type DeviceType = EmulatorBasicItem.DeviceType | EmulatorFoldItem.DeviceType | EmulatorTripleFoldItem.DeviceType;
953
+ type DeviceTypeWithString = DeviceType | (string & {});
954
+ type FullDeviceType = DeviceType | EmulatorGroupItem.DeviceType;
955
+ type FullDeviceTypeWithString = FullDeviceType | (string & {});
956
+ function is(value: unknown): value is EmulatorFile;
957
+ function isItemContent(value: unknown): value is EmulatorFile.ItemContent;
958
+ function isContentItem(value: unknown): value is EmulatorFile.ContentItem;
959
+ interface FindDeviceItemOptions<DeviceType extends DeviceTypeWithString = DeviceTypeWithString> {
960
+ /**
961
+ * The API version to find.
880
962
  */
881
- readonly code: number;
963
+ readonly apiVersion?: number;
882
964
  /**
883
- * The error message.
965
+ * The device type to find.
884
966
  */
885
- readonly body: string;
886
- }
887
- type AxiosResponse = axios.AxiosResponse<OKResponse>;
888
- type AxiosError = axios.AxiosError<ErrorResponse>;
889
- type Result = AxiosResponse | AxiosError;
890
- function isOKResponse(result: Result): result is AxiosResponse;
891
- class SDKListError extends Error {
892
- readonly code: SDKListError.Code;
893
- readonly message: string;
894
- readonly cause?: (AxiosError | AxiosResponse) | undefined;
895
- constructor(code: SDKListError.Code, message: string, cause?: (AxiosError | AxiosResponse) | undefined);
967
+ readonly deviceType?: DeviceType;
896
968
  }
897
- namespace SDKListError {
898
- enum Code {
899
- VALIDATION_ERROR = 400,
900
- REQUEST_ERROR = 500
901
- }
969
+ interface FindItemOptions {
970
+ /**
971
+ * The API version to find.
972
+ */
973
+ readonly apiVersion?: number;
974
+ /**
975
+ * The device type to find.
976
+ */
977
+ readonly fullDeviceType?: FullDeviceTypeWithString;
902
978
  }
903
979
  }
904
980
  //#endregion
905
- //#region src/images/remote-image.d.ts
906
- interface RemoteImage extends Serializable<RemoteImage.Serializable>, Omit<BaseImage, 'toJSON'> {
907
- readonly imageType: 'remote';
908
- /**
909
- * Get the remote image SDK.
910
- *
911
- * @returns The remote image SDK.
912
- */
913
- getRemoteImageSDK(): SDKList.OptionalRemoteImageSDK;
914
- /**
915
- * Get the local image if it is already downloaded.
916
- *
917
- * @param force - If `true` will reload the local image from the image manager and file system again. Default is `false`.
918
- * @returns The local image if it is already downloaded, otherwise `undefined`.
919
- */
920
- getLocalImage(force?: boolean): Promise<LocalImage | undefined>;
981
+ //#region src/screens/screen-preset.d.ts
982
+ interface ScreenPreset<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> {
921
983
  /**
922
- * Create a downloader for the remote image.
984
+ * Get the emulator item content.
923
985
  *
924
- * @param signals - The signals to abort the download.
925
- */
926
- createDownloader(signals?: AbortController): Promise<ImageDownloader>;
927
- }
928
- declare namespace RemoteImage {
929
- interface Serializable extends BaseImage.Serializable, BaseSerializable<RemoteImage> {}
930
- function is(value: unknown): value is RemoteImage;
931
- }
932
- //#endregion
933
- //#region src/images/image.d.ts
934
- type Image = LocalImage | RemoteImage;
935
- declare namespace Image {
936
- type RelativePath = `system-image/${string}/${string}`;
937
- function is(value: unknown): value is Image;
938
- }
939
- //#endregion
940
- //#region src/images/base-image.d.ts
941
- interface BaseImage extends Serializable<BaseImage.Serializable> {
942
- /**
943
- * The type of the image.
944
- */
945
- readonly imageType: 'local' | 'remote';
946
- /**
947
- * Get the image manager.
948
- */
949
- getImageManager(): ImageManager;
950
- /**
951
- * Get the relative path of the image.
952
- */
953
- getRelativePath(): Image.RelativePath;
954
- /**
955
- * Get the full path of the image.
956
- */
957
- getFullPath(): vscode_uri0.URI;
958
- /**
959
- * Check if the image is downloaded.
960
- */
961
- isDownloaded(): Promise<boolean>;
962
- /**
963
- * Get the API version of the image.
964
- */
965
- getApiVersion(): number;
966
- /**
967
- * Get the device type of the image.
986
+ * @returns The emulator item content.
968
987
  */
969
- getFullDeviceType(): EmulatorFile.FullDeviceTypeWithString;
970
- }
971
- declare namespace BaseImage {
972
- interface Serializable extends BaseSerializable<BaseImage> {
973
- imageType: 'local' | 'remote';
974
- }
975
- function is(value: unknown): value is BaseImage;
976
- }
977
- //#endregion
978
- //#region src/images/local-image.d.ts
979
- interface LocalImage extends Serializable<LocalImage.Serializable>, Omit<BaseImage, 'toJSON'> {
980
- readonly imageType: 'local';
988
+ getEmulatorDeviceItem(): EmulatorFile.DeviceItem;
981
989
  /**
982
- * Get the SDK package file.
990
+ * Get the product config item content.
983
991
  *
984
- * @returns The SDK package file.
992
+ * @returns The product config item content.
985
993
  */
986
- getSdkPkgFile(): LocalImage.OptionalSdkPkgFile;
994
+ getProductConfigItem(): ProductConfigItem<ProductDeviceType, ProductName>;
987
995
  /**
988
- * Create a device from the local image.
996
+ * Get the customize screen config.
989
997
  *
990
- * @param options - The options to create the device.
998
+ * @returns The customize screen config.
991
999
  */
992
- createDevice<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']>(options: LocalImage.CreateDeviceOptions<ProductDeviceType, ProductName>): Promise<Device<ProductDeviceType, ProductName>>;
1000
+ getCustomizeScreenConfig(): CustomizeScreen | CustomizeFoldableScreen | undefined;
993
1001
  }
994
- declare namespace LocalImage {
995
- interface Serializable extends BaseImage.Serializable, BaseSerializable<LocalImage> {}
996
- interface SdkPkgFile {
997
- /**
998
- * The SDK package file data.
999
- */
1000
- readonly data: SdkPkgFile.Data;
1001
- }
1002
- namespace SdkPkgFile {
1003
- interface Data {
1004
- /** @example '13' */
1005
- readonly apiVersion: string;
1006
- /** @example 'System-image-foldable' */
1007
- readonly displayName: string;
1008
- /** @example 'system-image,HarmonyOS-5.0.1,foldable_arm' */
1009
- readonly path: string;
1010
- /** @example '5.0.1' */
1011
- readonly platformVersion: string;
1012
- /** @example 'Release' */
1013
- readonly releaseType: string;
1014
- /** @example '5.0.0.112' */
1015
- readonly version: string;
1016
- /** @example 'HarmonyOS 5.0.0.112(SP2)' */
1017
- readonly guestVersion: string;
1018
- /** @example 'Release' */
1019
- readonly stage: string;
1020
- }
1021
- }
1022
- type OptionalSdkPkgFile = DeepPartial<SdkPkgFile>;
1023
- interface InfoFile {
1024
- /** @example '21' */
1025
- apiVersion: string;
1026
- /** @example 'arm' */
1027
- abi: string;
1028
- /** @example '6.0.0.112' */
1029
- version: string;
1030
- }
1031
- interface CreateDeviceOptions<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> {
1032
- /**
1033
- * The name of the device.
1034
- *
1035
- * @example 'Huawei_Wearable'
1036
- */
1037
- readonly name: string;
1038
- /**
1039
- * The CPU number.
1040
- *
1041
- * @example 4
1042
- */
1043
- readonly cpuNumber: number;
1044
- /**
1045
- * The memory RAM size. (in MB)
1046
- *
1047
- * @example 4096
1048
- */
1049
- readonly memoryRamSize: number;
1002
+ declare namespace ScreenPreset {
1003
+ interface Serializable<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> extends BaseSerializable<ScreenPreset<ProductDeviceType, ProductName>> {}
1004
+ interface PresetOptions<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> {
1050
1005
  /**
1051
- * The data disk size. (in MB)
1052
- *
1053
- * @example 6144
1006
+ * The emulator item content.
1054
1007
  */
1055
- readonly dataDiskSize: number;
1008
+ readonly emulatorDeviceItem: EmulatorFile.DeviceItem;
1056
1009
  /**
1057
- * The screen.
1010
+ * The product config item content.
1058
1011
  */
1059
- readonly screen: ScreenPreset.Options<ProductDeviceType, ProductName>;
1012
+ readonly productConfigItem: ProductConfigItem<ProductDeviceType, ProductName>;
1013
+ }
1014
+ interface CustomizeOptions<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> extends PresetOptions<ProductDeviceType, ProductName> {
1060
1015
  /**
1061
- * The vendor country.
1062
- *
1063
- * @example 'CN'
1016
+ * The customize screen options.
1064
1017
  */
1065
- readonly vendorCountry?: string;
1018
+ readonly customizeScreen: CustomizeScreen.Options;
1019
+ }
1020
+ interface CustomizeFoldableOptions<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> extends CustomizeOptions<ProductDeviceType, ProductName> {
1066
1021
  /**
1067
- * @default true
1022
+ * The customize foldable screen options.
1068
1023
  */
1069
- readonly isPublic?: boolean;
1024
+ readonly customizeFoldableScreen: CustomizeFoldableScreen.Options;
1070
1025
  }
1071
- function is(value: unknown): value is LocalImage;
1026
+ type Options<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> = ProductName extends ProductConfigItem.Customize ? ProductDeviceType extends 'Foldable' ? CustomizeFoldableOptions<ProductDeviceType, ProductName> : CustomizeOptions<ProductDeviceType, ProductName> : PresetOptions<ProductDeviceType, ProductName>;
1027
+ function is(value: unknown): value is ScreenPreset;
1028
+ }
1029
+ //#endregion
1030
+ //#region src/devices/device.d.ts
1031
+ interface Device<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> extends Serializable<Device.Serializable<ProductDeviceType, ProductName>> {
1032
+ /** Get the screen of the device. */
1033
+ getScreen(): ScreenPreset<ProductDeviceType, ProductName>;
1034
+ /** Get the image manager of the device. */
1035
+ getImageManager(): ImageManager;
1036
+ /** Get the lists file of the device. */
1037
+ getListsFile(): ListsFile;
1038
+ /** Get the lists file item of the device. */
1039
+ getListsFileItem(): ListsFileItem;
1040
+ /** Get the config INI file of the device. */
1041
+ getConfigIniFile(): ConfigIniFile<ProductDeviceType, ProductName>;
1042
+ /** Get the named INI file of the device. */
1043
+ getNamedIniFile(): NamedIniFile<ProductDeviceType, ProductName>;
1044
+ /** Get the executable URI of the device. */
1045
+ getExecutableUri(): vscode_uri0.URI;
1046
+ /** Get the snapshot URI of the device. */
1047
+ getSnapshotUri(): vscode_uri0.URI;
1048
+ /** Get the snapshot base64 string of the device. */
1049
+ getSnapshot(): Promise<string>;
1050
+ /** Get the start command of the device. */
1051
+ getStartCommand(): [string, string[]];
1052
+ /** Get the stop command of the device. */
1053
+ getStopCommand(): [string, string[]];
1054
+ /** Start the device. */
1055
+ start(): Promise<child_process.ChildProcessByStdio<null, Readable, Readable>>;
1056
+ /** Stop the device. */
1057
+ stop(): Promise<child_process.ChildProcessByStdio<null, Readable, Readable>>;
1058
+ /** Delete the device. */
1059
+ delete(): Promise<void>;
1060
+ /** Get the storage size of the device. */
1061
+ getStorageSize(): Promise<number>;
1062
+ /**
1063
+ * Get the watcher of the device.
1064
+ *
1065
+ * - If the watcher is already created, it will return the existing watcher.
1066
+ * - If the watcher is disposed, it will create a new watcher.
1067
+ * - If the watcher is already created but disposed, it will create a new watcher.
1068
+ */
1069
+ getWatcher(): Promise<FileSystemWatcher>;
1070
+ }
1071
+ declare namespace Device {
1072
+ interface Serializable<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> extends Omit<BaseSerializable<Device<ProductDeviceType, ProductName>>, 'imageManager'> {}
1073
+ function is(value: unknown): value is Device;
1072
1074
  }
1073
1075
  //#endregion
1074
1076
  //#region src/options.d.ts
@@ -1230,7 +1232,7 @@ interface SerializableFile extends Serializable<SerializableFile.Serializable>,
1230
1232
  }
1231
1233
  declare namespace SerializableFile {
1232
1234
  type Content = SerializableContent.Content;
1233
- interface Serializable extends BaseSerializable<SerializableFile> {}
1235
+ interface Serializable extends Omit<BaseSerializable<SerializableFile>, 'imageManager'> {}
1234
1236
  }
1235
1237
  //#endregion
1236
1238
  //#region src/configs/config-ini/config-ini.d.ts
@@ -1243,7 +1245,7 @@ declare namespace ConfigIniFile {
1243
1245
  type GenericContent<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> = Content & {
1244
1246
  productModel: ProductName;
1245
1247
  };
1246
- interface Serializable<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> extends Omit<BaseSerializable<ConfigIniFile<ProductDeviceType, ProductName>>, 'device'> {}
1248
+ interface Serializable<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> extends Omit<BaseSerializable<ConfigIniFile<ProductDeviceType, ProductName>>, 'device' | 'imageManager'> {}
1247
1249
  function is(value: unknown): value is ConfigIniFile;
1248
1250
  }
1249
1251
  //#endregion
@@ -1254,7 +1256,7 @@ interface NamedIniFile<ProductDeviceType extends ProductConfigFile.DeviceType =
1254
1256
  }
1255
1257
  declare namespace NamedIniFile {
1256
1258
  type Content = Record<string, string>;
1257
- interface Serializable<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> extends Omit<BaseSerializable<NamedIniFile<ProductDeviceType, ProductName>>, 'device'> {}
1259
+ interface Serializable<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> extends Omit<BaseSerializable<NamedIniFile<ProductDeviceType, ProductName>>, 'device' | 'imageManager'> {}
1258
1260
  function is(value: unknown): value is NamedIniFile;
1259
1261
  }
1260
1262
  //#endregion