@arkts/image-manager 0.5.4 → 0.5.6

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
@@ -529,226 +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
- getDeviceItems(): EmulatorFile.DeviceItem[];
622
- }
623
- declare namespace EmulatorFile {
624
- interface Serializable extends Omit<BaseSerializable<EmulatorFile>, 'imageManager'> {}
625
- type ItemContent = EmulatorBasicItem.Content | EmulatorFoldItem.Content | EmulatorTripleFoldItem.Content;
626
- type Content = Array<ContentItem>;
627
- type ContentItem = EmulatorGroupItem.Content | ItemContent;
628
- type DeviceItem = EmulatorBasicItem | EmulatorFoldItem | EmulatorTripleFoldItem;
629
- type Item = EmulatorGroupItem | DeviceItem;
630
- type DeviceType = EmulatorBasicItem.DeviceType | EmulatorFoldItem.DeviceType | EmulatorTripleFoldItem.DeviceType;
631
- type DeviceTypeWithString = DeviceType | (string & {});
632
- type FullDeviceType = DeviceType | EmulatorGroupItem.DeviceType;
633
- type FullDeviceTypeWithString = FullDeviceType | (string & {});
634
- function is(value: unknown): value is EmulatorFile;
635
- function isItemContent(value: unknown): value is EmulatorFile.ItemContent;
636
- function isContentItem(value: unknown): value is EmulatorFile.ContentItem;
637
- interface FindDeviceItemOptions<DeviceType extends DeviceTypeWithString = DeviceTypeWithString> {
638
- /**
639
- * The API version to find.
640
- */
641
- readonly apiVersion?: number;
585
+ interface CreateDeviceOptions<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> {
642
586
  /**
643
- * The device type to find.
587
+ * The name of the device.
588
+ *
589
+ * @example 'Huawei_Wearable'
644
590
  */
645
- readonly deviceType?: DeviceType;
646
- }
647
- interface FindItemOptions {
591
+ readonly name: string;
648
592
  /**
649
- * The API version to find.
593
+ * The CPU number.
594
+ *
595
+ * @example 4
650
596
  */
651
- readonly apiVersion?: number;
597
+ readonly cpuNumber: number;
652
598
  /**
653
- * The device type to find.
599
+ * The memory RAM size. (in MB)
600
+ *
601
+ * @example 4096
654
602
  */
655
- readonly fullDeviceType?: FullDeviceTypeWithString;
656
- }
657
- }
658
- //#endregion
659
- //#region src/screens/screen-preset.d.ts
660
- interface ScreenPreset<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> {
661
- /**
662
- * Get the emulator item content.
663
- *
664
- * @returns The emulator item content.
665
- */
666
- getEmulatorDeviceItem(): EmulatorFile.DeviceItem;
667
- /**
668
- * Get the product config item content.
669
- *
670
- * @returns The product config item content.
671
- */
672
- getProductConfigItem(): ProductConfigItem<ProductDeviceType, ProductName>;
673
- /**
674
- * Get the customize screen config.
675
- *
676
- * @returns The customize screen config.
677
- */
678
- getCustomizeScreenConfig(): CustomizeScreen | CustomizeFoldableScreen | undefined;
679
- }
680
- declare namespace ScreenPreset {
681
- interface Serializable<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> extends BaseSerializable<ScreenPreset<ProductDeviceType, ProductName>> {}
682
- interface PresetOptions<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> {
603
+ readonly memoryRamSize: number;
683
604
  /**
684
- * The emulator item content.
605
+ * The data disk size. (in MB)
606
+ *
607
+ * @example 6144
685
608
  */
686
- readonly emulatorDeviceItem: EmulatorFile.DeviceItem;
609
+ readonly dataDiskSize: number;
687
610
  /**
688
- * The product config item content.
611
+ * The screen.
689
612
  */
690
- readonly productConfigItem: ProductConfigItem<ProductDeviceType, ProductName>;
691
- }
692
- 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>;
693
614
  /**
694
- * The customize screen options.
615
+ * The vendor country.
616
+ *
617
+ * @example 'CN'
695
618
  */
696
- readonly customizeScreen: CustomizeScreen.Options;
697
- }
698
- 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;
699
620
  /**
700
- * The customize foldable screen options.
621
+ * @default true
701
622
  */
702
- readonly customizeFoldableScreen: CustomizeFoldableScreen.Options;
623
+ readonly isPublic?: boolean;
703
624
  }
704
- 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>;
705
- function is(value: unknown): value is ScreenPreset;
706
- }
707
- //#endregion
708
- //#region src/devices/device.d.ts
709
- interface Device<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> extends Serializable<Device.Serializable<ProductDeviceType, ProductName>> {
710
- /** Get the screen of the device. */
711
- getScreen(): ScreenPreset<ProductDeviceType, ProductName>;
712
- /** Get the image manager of the device. */
713
- getImageManager(): ImageManager;
714
- /** Get the lists file of the device. */
715
- getListsFile(): ListsFile;
716
- /** Get the lists file item of the device. */
717
- getListsFileItem(): ListsFileItem;
718
- /** Get the config INI file of the device. */
719
- getConfigIniFile(): ConfigIniFile<ProductDeviceType, ProductName>;
720
- /** Get the named INI file of the device. */
721
- getNamedIniFile(): NamedIniFile<ProductDeviceType, ProductName>;
722
- /** Get the executable URI of the device. */
723
- getExecutableUri(): vscode_uri0.URI;
724
- /** Get the snapshot URI of the device. */
725
- getSnapshotUri(): vscode_uri0.URI;
726
- /** Get the snapshot base64 string of the device. */
727
- getSnapshot(): Promise<string>;
728
- /** Get the start command of the device. */
729
- getStartCommand(): [string, string[]];
730
- /** Get the stop command of the device. */
731
- getStopCommand(): [string, string[]];
732
- /** Start the device. */
733
- start(): Promise<child_process.ChildProcessByStdio<null, Readable, Readable>>;
734
- /** Stop the device. */
735
- stop(): Promise<child_process.ChildProcessByStdio<null, Readable, Readable>>;
736
- /** Delete the device. */
737
- delete(): Promise<void>;
738
- /** Get the storage size of the device. */
739
- getStorageSize(): Promise<number>;
740
- /**
741
- * Get the watcher of the device.
742
- *
743
- * - If the watcher is already created, it will return the existing watcher.
744
- * - If the watcher is disposed, it will create a new watcher.
745
- * - If the watcher is already created but disposed, it will create a new watcher.
746
- */
747
- getWatcher(): Promise<FileSystemWatcher>;
748
- }
749
- declare namespace Device {
750
- 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'> {}
751
- function is(value: unknown): value is Device;
625
+ function is(value: unknown): value is LocalImage;
752
626
  }
753
627
  //#endregion
754
628
  //#region src/event-emitter.d.ts
@@ -877,199 +751,326 @@ declare namespace SDKList {
877
751
  type OKResponse = RemoteImageSDK[];
878
752
  interface ErrorResponse {
879
753
  /**
880
- * 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.
881
962
  */
882
- readonly code: number;
963
+ readonly apiVersion?: number;
883
964
  /**
884
- * The error message.
965
+ * The device type to find.
885
966
  */
886
- readonly body: string;
887
- }
888
- type AxiosResponse = axios.AxiosResponse<OKResponse>;
889
- type AxiosError = axios.AxiosError<ErrorResponse>;
890
- type Result = AxiosResponse | AxiosError;
891
- function isOKResponse(result: Result): result is AxiosResponse;
892
- class SDKListError extends Error {
893
- readonly code: SDKListError.Code;
894
- readonly message: string;
895
- readonly cause?: (AxiosError | AxiosResponse) | undefined;
896
- constructor(code: SDKListError.Code, message: string, cause?: (AxiosError | AxiosResponse) | undefined);
967
+ readonly deviceType?: DeviceType;
897
968
  }
898
- namespace SDKListError {
899
- enum Code {
900
- VALIDATION_ERROR = 400,
901
- REQUEST_ERROR = 500
902
- }
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;
903
978
  }
904
979
  }
905
980
  //#endregion
906
- //#region src/images/remote-image.d.ts
907
- interface RemoteImage extends Serializable<RemoteImage.Serializable>, Omit<BaseImage, 'toJSON'> {
908
- readonly imageType: 'remote';
909
- /**
910
- * Get the remote image SDK.
911
- *
912
- * @returns The remote image SDK.
913
- */
914
- getRemoteImageSDK(): SDKList.OptionalRemoteImageSDK;
915
- /**
916
- * Get the local image if it is already downloaded.
917
- *
918
- * @param force - If `true` will reload the local image from the image manager and file system again. Default is `false`.
919
- * @returns The local image if it is already downloaded, otherwise `undefined`.
920
- */
921
- 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']> {
922
983
  /**
923
- * Create a downloader for the remote image.
984
+ * Get the emulator item content.
924
985
  *
925
- * @param signals - The signals to abort the download.
926
- */
927
- createDownloader(signals?: AbortController): Promise<ImageDownloader>;
928
- }
929
- declare namespace RemoteImage {
930
- interface Serializable extends BaseImage.Serializable, Omit<BaseSerializable<RemoteImage>, 'imageManager'> {}
931
- function is(value: unknown): value is RemoteImage;
932
- }
933
- //#endregion
934
- //#region src/images/image.d.ts
935
- type Image = LocalImage | RemoteImage;
936
- declare namespace Image {
937
- type RelativePath = `system-image/${string}/${string}`;
938
- function is(value: unknown): value is Image;
939
- }
940
- //#endregion
941
- //#region src/images/base-image.d.ts
942
- interface BaseImage extends Serializable<BaseImage.Serializable> {
943
- /**
944
- * The type of the image.
945
- */
946
- readonly imageType: 'local' | 'remote';
947
- /**
948
- * Get the image manager.
949
- */
950
- getImageManager(): ImageManager;
951
- /**
952
- * Get the relative path of the image.
953
- */
954
- getRelativePath(): Image.RelativePath;
955
- /**
956
- * Get the full path of the image.
957
- */
958
- getFullPath(): vscode_uri0.URI;
959
- /**
960
- * Check if the image is downloaded.
961
- */
962
- isDownloaded(): Promise<boolean>;
963
- /**
964
- * Get the API version of the image.
965
- */
966
- getApiVersion(): number;
967
- /**
968
- * Get the device type of the image.
986
+ * @returns The emulator item content.
969
987
  */
970
- getFullDeviceType(): EmulatorFile.FullDeviceTypeWithString;
971
- }
972
- declare namespace BaseImage {
973
- interface Serializable extends Omit<BaseSerializable<BaseImage>, 'imageManager'> {
974
- imageType: 'local' | 'remote';
975
- }
976
- function is(value: unknown): value is BaseImage;
977
- }
978
- //#endregion
979
- //#region src/images/local-image.d.ts
980
- interface LocalImage extends Serializable<LocalImage.Serializable>, Omit<BaseImage, 'toJSON'> {
981
- readonly imageType: 'local';
988
+ getEmulatorDeviceItem(): EmulatorFile.DeviceItem;
982
989
  /**
983
- * Get the SDK package file.
990
+ * Get the product config item content.
984
991
  *
985
- * @returns The SDK package file.
992
+ * @returns The product config item content.
986
993
  */
987
- getSdkPkgFile(): LocalImage.OptionalSdkPkgFile;
994
+ getProductConfigItem(): ProductConfigItem<ProductDeviceType, ProductName>;
988
995
  /**
989
- * Create a device from the local image.
996
+ * Get the customize screen config.
990
997
  *
991
- * @param options - The options to create the device.
998
+ * @returns The customize screen config.
992
999
  */
993
- 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;
994
1001
  }
995
- declare namespace LocalImage {
996
- interface Serializable extends BaseImage.Serializable, Omit<BaseSerializable<LocalImage>, 'imageManager'> {}
997
- interface SdkPkgFile {
998
- /**
999
- * The SDK package file data.
1000
- */
1001
- readonly data: SdkPkgFile.Data;
1002
- }
1003
- namespace SdkPkgFile {
1004
- interface Data {
1005
- /** @example '13' */
1006
- readonly apiVersion: string;
1007
- /** @example 'System-image-foldable' */
1008
- readonly displayName: string;
1009
- /** @example 'system-image,HarmonyOS-5.0.1,foldable_arm' */
1010
- readonly path: string;
1011
- /** @example '5.0.1' */
1012
- readonly platformVersion: string;
1013
- /** @example 'Release' */
1014
- readonly releaseType: string;
1015
- /** @example '5.0.0.112' */
1016
- readonly version: string;
1017
- /** @example 'HarmonyOS 5.0.0.112(SP2)' */
1018
- readonly guestVersion: string;
1019
- /** @example 'Release' */
1020
- readonly stage: string;
1021
- }
1022
- }
1023
- type OptionalSdkPkgFile = DeepPartial<SdkPkgFile>;
1024
- interface InfoFile {
1025
- /** @example '21' */
1026
- apiVersion: string;
1027
- /** @example 'arm' */
1028
- abi: string;
1029
- /** @example '6.0.0.112' */
1030
- version: string;
1031
- }
1032
- interface CreateDeviceOptions<ProductDeviceType extends ProductConfigFile.DeviceType = ProductConfigFile.DeviceType, ProductName extends ProductConfigFile.GenericContent<ProductDeviceType>['name'] = ProductConfigFile.GenericContent<ProductDeviceType>['name']> {
1033
- /**
1034
- * The name of the device.
1035
- *
1036
- * @example 'Huawei_Wearable'
1037
- */
1038
- readonly name: string;
1039
- /**
1040
- * The CPU number.
1041
- *
1042
- * @example 4
1043
- */
1044
- readonly cpuNumber: number;
1045
- /**
1046
- * The memory RAM size. (in MB)
1047
- *
1048
- * @example 4096
1049
- */
1050
- 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']> {
1051
1005
  /**
1052
- * The data disk size. (in MB)
1053
- *
1054
- * @example 6144
1006
+ * The emulator item content.
1055
1007
  */
1056
- readonly dataDiskSize: number;
1008
+ readonly emulatorDeviceItem: EmulatorFile.DeviceItem;
1057
1009
  /**
1058
- * The screen.
1010
+ * The product config item content.
1059
1011
  */
1060
- 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> {
1061
1015
  /**
1062
- * The vendor country.
1063
- *
1064
- * @example 'CN'
1016
+ * The customize screen options.
1065
1017
  */
1066
- 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> {
1067
1021
  /**
1068
- * @default true
1022
+ * The customize foldable screen options.
1069
1023
  */
1070
- readonly isPublic?: boolean;
1024
+ readonly customizeFoldableScreen: CustomizeFoldableScreen.Options;
1071
1025
  }
1072
- 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;
1073
1074
  }
1074
1075
  //#endregion
1075
1076
  //#region src/options.d.ts