@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.mjs CHANGED
@@ -3,7 +3,7 @@ import { fromByteArray } from "base64-js";
3
3
  import { RelativePattern, WriteableFlags, createNodeFileSystem } from "vscode-fs";
4
4
 
5
5
  //#region package.json
6
- var version = "0.5.3";
6
+ var version = "0.5.5";
7
7
 
8
8
  //#endregion
9
9
  //#region src/common/serializable-content.ts
@@ -19,10 +19,7 @@ var SerializableContentImpl = class {
19
19
  return this.content;
20
20
  }
21
21
  toJSON() {
22
- return {
23
- imageManager: this.getImageManager().toJSON(),
24
- content: this.getContent()
25
- };
22
+ return { content: this.getContent() };
26
23
  }
27
24
  };
28
25
 
@@ -46,10 +43,7 @@ var SerializableFileImpl = class extends SerializableContentImpl {
46
43
  await fs.writeFile(uri, encodedContent);
47
44
  }
48
45
  toJSON() {
49
- return {
50
- imageManager: this.getImageManager().toJSON(),
51
- content: this.getContent()
52
- };
46
+ return { content: this.getContent() };
53
47
  }
54
48
  };
55
49
 
@@ -253,6 +247,29 @@ var EmulatorFileImpl = class extends SerializableFileImpl {
253
247
  }
254
248
  }).filter(Boolean);
255
249
  }
250
+ getDeviceItems(items = []) {
251
+ for (const item of this.getItems()) if (EmulatorBasicItem.is(item)) items.push(item);
252
+ else if (EmulatorFoldItem.is(item)) items.push(item);
253
+ else if (EmulatorTripleFoldItem.is(item)) items.push(item);
254
+ else this.getDeviceItems(item.getChildren());
255
+ return items;
256
+ }
257
+ findRemoteImageByDeviceItem(deviceItem, remoteImages) {
258
+ return remoteImages.find((image) => {
259
+ if (image.getApiVersion() !== deviceItem.getContent().api) return false;
260
+ if (image.getFullDeviceType() === deviceItem.getContent().deviceType) return true;
261
+ if (image.getFullDeviceType() === "pc_all") {
262
+ if (deviceItem.getContent().deviceType === "2in1") return true;
263
+ else if (deviceItem.getContent().deviceType === "2in1_foldable") return true;
264
+ } else if (image.getFullDeviceType() === "phone_all") {
265
+ if (deviceItem.getContent().deviceType === "phone") return true;
266
+ else if (deviceItem.getContent().deviceType === "foldable") return true;
267
+ else if (deviceItem.getContent().deviceType === "widefold") return true;
268
+ else if (deviceItem.getContent().deviceType === "triplefold") return true;
269
+ }
270
+ return false;
271
+ });
272
+ }
256
273
  findDeviceItems(options = {}) {
257
274
  const items = [];
258
275
  const pushDeviceItem = (item) => {
@@ -283,6 +300,7 @@ var EmulatorFileImpl = class extends SerializableFileImpl {
283
300
  toJSON() {
284
301
  return {
285
302
  ...super.toJSON(),
303
+ deviceItems: this.getDeviceItems().map((item) => item.toJSON()),
286
304
  items: this.getItems().map((item) => item.toJSON())
287
305
  };
288
306
  }
@@ -311,7 +329,6 @@ var ListsFileItemImpl = class extends SerializableContentImpl {
311
329
  }
312
330
  toJSON() {
313
331
  return {
314
- imageManager: this.getImageManager().toJSON(),
315
332
  content: this.getContent(),
316
333
  listsFile: this.getListsFile().toJSON()
317
334
  };
@@ -361,7 +378,6 @@ var ListsFileImpl = class extends SerializableFileImpl {
361
378
  }
362
379
  toJSON() {
363
380
  return {
364
- imageManager: this.getImageManager().toJSON(),
365
381
  content: this.getContent(),
366
382
  listsFileItems: this.getListsFileItems().map((item) => item.toJSON())
367
383
  };
@@ -406,7 +422,6 @@ var ProductConfigItemImpl = class extends SerializableContentImpl {
406
422
  }
407
423
  toJSON() {
408
424
  return {
409
- imageManager: this.getImageManager().toJSON(),
410
425
  content: this.getContent(),
411
426
  devModel: this.getDevModel(),
412
427
  deviceType: this.getDeviceType(),
@@ -637,7 +652,6 @@ var NamedIniFileImpl = class extends SerializableFileImpl {
637
652
  }
638
653
  toJSON() {
639
654
  return {
640
- imageManager: this.getImageManager().toJSON(),
641
655
  content: this.getContent(),
642
656
  fileUri: this.getFileUri().toJSON()
643
657
  };
@@ -793,7 +807,6 @@ var BaseImageImpl = class {
793
807
  toJSON() {
794
808
  return {
795
809
  imageType: this.imageType,
796
- imageManager: this.getImageManager().toJSON(),
797
810
  relativePath: this.getRelativePath(),
798
811
  fullPath: this.getFullPath().toJSON(),
799
812
  apiVersion: this.getApiVersion(),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arkts/image-manager",
3
3
  "type": "module",
4
- "version": "0.5.3",
4
+ "version": "0.5.5",
5
5
  "description": "OpenHarmony/HarmonyOS qemu image manager.",
6
6
  "author": "Naily Zero <zero@naily.cc> (https://naily.cc)",
7
7
  "license": "MIT",