@arkts/image-manager 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -38,7 +38,7 @@ let progress_stream = require("progress-stream");
38
38
  progress_stream = __toESM(progress_stream);
39
39
 
40
40
  //#region package.json
41
- var version = "0.4.1";
41
+ var version = "0.4.2";
42
42
 
43
43
  //#endregion
44
44
  //#region src/devices/list.ts
@@ -142,9 +142,6 @@ let ProductConfigItem;
142
142
  }
143
143
  _ProductConfigItem.is = is;
144
144
  })(ProductConfigItem || (ProductConfigItem = {}));
145
- function isProductConfig(value) {
146
- return typeof value === "object" && value !== null && Object.values(value).every((item) => Array.isArray(item));
147
- }
148
145
 
149
146
  //#endregion
150
147
  //#region src/types.ts
@@ -155,27 +152,6 @@ function isPCAllSnakecaseDeviceType(value) {
155
152
  return value === "2in1_foldable" || value === "2in1";
156
153
  }
157
154
 
158
- //#endregion
159
- //#region src/screens/emulator-preset.ts
160
- var EmulatorPresetImpl = class {
161
- constructor(emulatorConfigItem, screenPreset) {
162
- this.emulatorConfigItem = emulatorConfigItem;
163
- this.screenPreset = screenPreset;
164
- }
165
- getScreenPreset() {
166
- return this.screenPreset;
167
- }
168
- getEmulatorConfig() {
169
- return this.emulatorConfigItem;
170
- }
171
- toJSON() {
172
- return { emulatorConfig: this.emulatorConfigItem };
173
- }
174
- };
175
- function createEmulatorPreset(emulatorConfigItem, screenPreset) {
176
- return new EmulatorPresetImpl(emulatorConfigItem, screenPreset);
177
- }
178
-
179
155
  //#endregion
180
156
  //#region src/screens/base-screen.ts
181
157
  var BaseScreenImpl = class {
@@ -208,6 +184,73 @@ var BaseScreenImpl = class {
208
184
  }
209
185
  };
210
186
 
187
+ //#endregion
188
+ //#region src/screens/cover-screen.ts
189
+ let CoverScreen;
190
+ (function(_CoverScreen) {
191
+ function is(value) {
192
+ return value instanceof CoverScreenImpl;
193
+ }
194
+ _CoverScreen.is = is;
195
+ })(CoverScreen || (CoverScreen = {}));
196
+ var CoverScreenImpl = class extends BaseScreenImpl {
197
+ constructor(options, screen) {
198
+ super(options);
199
+ this.options = options;
200
+ this.screen = screen;
201
+ }
202
+ getScreen() {
203
+ return this.screen;
204
+ }
205
+ };
206
+ function createCoverScreen(options, screen) {
207
+ return new CoverScreenImpl(options, screen);
208
+ }
209
+
210
+ //#endregion
211
+ //#region src/screens/double-screen.ts
212
+ let DoubleScreen;
213
+ (function(_DoubleScreen) {
214
+ function is(value) {
215
+ return value instanceof DoubleScreenImpl;
216
+ }
217
+ _DoubleScreen.is = is;
218
+ })(DoubleScreen || (DoubleScreen = {}));
219
+ var DoubleScreenImpl = class extends BaseScreenImpl {
220
+ constructor(options, screen) {
221
+ super(options);
222
+ this.options = options;
223
+ this.screen = screen;
224
+ }
225
+ getScreen() {
226
+ return this.screen;
227
+ }
228
+ };
229
+ function createDoubleScreen(options, screen) {
230
+ return new DoubleScreenImpl(options, screen);
231
+ }
232
+
233
+ //#endregion
234
+ //#region src/screens/emulator-preset.ts
235
+ var EmulatorPresetImpl = class {
236
+ constructor(emulatorConfigItem, screenPreset) {
237
+ this.emulatorConfigItem = emulatorConfigItem;
238
+ this.screenPreset = screenPreset;
239
+ }
240
+ getScreenPreset() {
241
+ return this.screenPreset;
242
+ }
243
+ getEmulatorConfig() {
244
+ return this.emulatorConfigItem;
245
+ }
246
+ toJSON() {
247
+ return { emulatorConfig: this.emulatorConfigItem };
248
+ }
249
+ };
250
+ function createEmulatorPreset(emulatorConfigItem, screenPreset) {
251
+ return new EmulatorPresetImpl(emulatorConfigItem, screenPreset);
252
+ }
253
+
211
254
  //#endregion
212
255
  //#region src/screens/outer-screen.ts
213
256
  let OuterScreen;
@@ -297,52 +340,6 @@ function createProductPreset(productConfig, deviceType, screenPreset) {
297
340
  return new ProductPresetImpl(productConfig, deviceType, screenPreset);
298
341
  }
299
342
 
300
- //#endregion
301
- //#region src/screens/cover-screen.ts
302
- let CoverScreen;
303
- (function(_CoverScreen) {
304
- function is(value) {
305
- return value instanceof CoverScreenImpl;
306
- }
307
- _CoverScreen.is = is;
308
- })(CoverScreen || (CoverScreen = {}));
309
- var CoverScreenImpl = class extends BaseScreenImpl {
310
- constructor(options, screen) {
311
- super(options);
312
- this.options = options;
313
- this.screen = screen;
314
- }
315
- getScreen() {
316
- return this.screen;
317
- }
318
- };
319
- function createCoverScreen(options, screen) {
320
- return new CoverScreenImpl(options, screen);
321
- }
322
-
323
- //#endregion
324
- //#region src/screens/double-screen.ts
325
- let DoubleScreen;
326
- (function(_DoubleScreen) {
327
- function is(value) {
328
- return value instanceof DoubleScreenImpl;
329
- }
330
- _DoubleScreen.is = is;
331
- })(DoubleScreen || (DoubleScreen = {}));
332
- var DoubleScreenImpl = class extends BaseScreenImpl {
333
- constructor(options, screen) {
334
- super(options);
335
- this.options = options;
336
- this.screen = screen;
337
- }
338
- getScreen() {
339
- return this.screen;
340
- }
341
- };
342
- function createDoubleScreen(options, screen) {
343
- return new DoubleScreenImpl(options, screen);
344
- }
345
-
346
343
  //#endregion
347
344
  //#region src/screens/single-screen.ts
348
345
  let SingleScreen;
@@ -452,6 +449,27 @@ function createScreen(options) {
452
449
  //#region src/screens/screen-preset.ts
453
450
  let ScreenPreset;
454
451
  (function(_ScreenPreset) {
452
+ let ScreenOptions;
453
+ (function(_ScreenOptions) {
454
+ function is(value) {
455
+ return typeof value === "object" && value !== null && "screen" in value && Screen.is(value.screen);
456
+ }
457
+ _ScreenOptions.is = is;
458
+ })(ScreenOptions || (ScreenOptions = _ScreenPreset.ScreenOptions || (_ScreenPreset.ScreenOptions = {})));
459
+ let ProductOptions;
460
+ (function(_ProductOptions) {
461
+ function is(value) {
462
+ return typeof value === "object" && value !== null && "image" in value && "productConfig" in value && ProductConfigItem.is(value.productConfig);
463
+ }
464
+ _ProductOptions.is = is;
465
+ })(ProductOptions || (ProductOptions = _ScreenPreset.ProductOptions || (_ScreenPreset.ProductOptions = {})));
466
+ let EmulatorOptions;
467
+ (function(_EmulatorOptions) {
468
+ function is(value) {
469
+ return typeof value === "object" && value !== null && "image" in value && "emulatorConfig" in value;
470
+ }
471
+ _EmulatorOptions.is = is;
472
+ })(EmulatorOptions || (EmulatorOptions = _ScreenPreset.EmulatorOptions || (_ScreenPreset.EmulatorOptions = {})));
455
473
  function is(value) {
456
474
  return value instanceof ScreenPresetImpl;
457
475
  }
@@ -466,36 +484,64 @@ var ScreenPresetImpl = class {
466
484
  this.setEmulatorPreset();
467
485
  this.setProductPreset();
468
486
  }
469
- isScreenOptions(options) {
470
- return "screen" in options && Screen.is(options.screen);
471
- }
472
487
  _screen;
473
488
  getScreen() {
474
- if (this.isScreenOptions(this.options)) return this.options.screen;
489
+ if (ScreenPreset.ScreenOptions.is(this.options)) return this.options.screen;
475
490
  if (this._screen) return this._screen;
476
- this._screen = createScreen({
477
- width: Number(this.options.productConfig.screenWidth),
478
- height: Number(this.options.productConfig.screenHeight),
479
- diagonal: Number(this.options.productConfig.screenDiagonal),
480
- density: Number(this.options.productConfig.screenDensity),
481
- apiVersion: Number.parseInt(this.options.image.getApiVersion()),
482
- deviceType: this.options.image.getSnakecaseDeviceType()
483
- });
484
- if (this.options.productConfig.outerScreenWidth && this.options.productConfig.outerScreenHeight && this.options.productConfig.outerScreenDiagonal) this._screen.setOuterScreen(createOuterScreen({
485
- width: Number(this.options.productConfig.outerScreenWidth),
486
- height: Number(this.options.productConfig.outerScreenHeight),
487
- diagonal: Number(this.options.productConfig.outerScreenDiagonal)
488
- }, this._screen));
489
- if (this.options.productConfig.outerDoubleScreenWidth && this.options.productConfig.outerDoubleScreenHeight && this.options.productConfig.outerDoubleScreenDiagonal) this._screen.getOuterScreen()?.setOuterDoubleScreen(createOuterDoubleScreen({
490
- width: Number(this.options.productConfig.outerDoubleScreenWidth),
491
- height: Number(this.options.productConfig.outerDoubleScreenHeight),
492
- diagonal: Number(this.options.productConfig.outerDoubleScreenDiagonal)
493
- }, this._screen.getOuterScreen()));
494
- return this._screen;
495
- }
496
- getProductConfigItems() {
497
- if (!this.options.productConfig || !isProductConfig(this.options.productConfig)) return;
498
- for (const [pascalCaseDeviceType, productConfigItem] of Object.entries(this.options.productConfig)) if (pascalCaseDeviceType === "2in1" && this.getScreen().getSnakecaseDeviceType() === "2in1") return [productConfigItem, pascalCaseDeviceType];
491
+ if (ScreenPreset.ProductOptions.is(this.options)) {
492
+ this._screen = createScreen({
493
+ width: Number(this.options.productConfig.screenWidth),
494
+ height: Number(this.options.productConfig.screenHeight),
495
+ diagonal: Number(this.options.productConfig.screenDiagonal),
496
+ density: Number(this.options.productConfig.screenDensity),
497
+ apiVersion: Number.parseInt(this.options.image.getApiVersion()),
498
+ deviceType: this.options.image.getSnakecaseDeviceType()
499
+ });
500
+ if (this.options.productConfig.outerScreenWidth && this.options.productConfig.outerScreenHeight && this.options.productConfig.outerScreenDiagonal) this._screen.setOuterScreen(createOuterScreen({
501
+ width: Number(this.options.productConfig.outerScreenWidth),
502
+ height: Number(this.options.productConfig.outerScreenHeight),
503
+ diagonal: Number(this.options.productConfig.outerScreenDiagonal)
504
+ }, this._screen));
505
+ if (this.options.productConfig.outerDoubleScreenWidth && this.options.productConfig.outerDoubleScreenHeight && this.options.productConfig.outerDoubleScreenDiagonal) this._screen.getOuterScreen()?.setOuterDoubleScreen(createOuterDoubleScreen({
506
+ width: Number(this.options.productConfig.outerDoubleScreenWidth),
507
+ height: Number(this.options.productConfig.outerDoubleScreenHeight),
508
+ diagonal: Number(this.options.productConfig.outerDoubleScreenDiagonal)
509
+ }, this._screen.getOuterScreen()));
510
+ return this._screen;
511
+ }
512
+ if (ScreenPreset.EmulatorOptions.is(this.options)) {
513
+ this._screen = createScreen({
514
+ width: this.options.emulatorConfig.resolutionWidth,
515
+ height: this.options.emulatorConfig.resolutionHeight,
516
+ diagonal: this.options.emulatorConfig.diagonalSize,
517
+ density: this.options.emulatorConfig.density,
518
+ apiVersion: Number.parseInt(this.options.image.getApiVersion()),
519
+ deviceType: this.options.image.getSnakecaseDeviceType()
520
+ });
521
+ if (this.options.emulatorConfig.coverResolutionWidth && this.options.emulatorConfig.coverResolutionHeight && this.options.emulatorConfig.coverDiagonalSize) this._screen.setCoverScreen(createCoverScreen({
522
+ width: this.options.emulatorConfig.coverResolutionWidth,
523
+ height: this.options.emulatorConfig.coverResolutionHeight,
524
+ diagonal: this.options.emulatorConfig.coverDiagonalSize
525
+ }, this._screen));
526
+ if (PhoneAllEmulatorConfigItem.is(this.options.emulatorConfig)) {
527
+ if (this.options.emulatorConfig.singleResolutionWidth && this.options.emulatorConfig.singleResolutionHeight && this.options.emulatorConfig.singleDiagonalSize) this._screen.setSingleScreen(createSingleScreen({
528
+ width: this.options.emulatorConfig.singleResolutionWidth,
529
+ height: this.options.emulatorConfig.singleResolutionHeight,
530
+ diagonal: this.options.emulatorConfig.singleDiagonalSize
531
+ }, this._screen));
532
+ if (this.options.emulatorConfig.doubleResolutionWidth && this.options.emulatorConfig.doubleResolutionHeight && this.options.emulatorConfig.doubleDiagonalSize) this._screen.setDoubleScreen(createDoubleScreen({
533
+ width: this.options.emulatorConfig.doubleResolutionWidth,
534
+ height: this.options.emulatorConfig.doubleResolutionHeight,
535
+ diagonal: this.options.emulatorConfig.doubleDiagonalSize
536
+ }, this._screen));
537
+ }
538
+ return this._screen;
539
+ }
540
+ throw new Error("Invalid createScreenPreset options.");
541
+ }
542
+ getProductConfigItemsByScreenOptions() {
543
+ if (!ScreenPreset.ScreenOptions.is(this.options)) return;
544
+ for (const [pascalCaseDeviceType, productConfigItem] of Object.entries(this.options.productConfig ?? {})) if (pascalCaseDeviceType === "2in1" && this.getScreen().getSnakecaseDeviceType() === "2in1") return [productConfigItem, pascalCaseDeviceType];
499
545
  else if (pascalCaseDeviceType === "2in1 Foldable" && this.getScreen().getSnakecaseDeviceType() === "2in1_foldable") return [productConfigItem, pascalCaseDeviceType];
500
546
  else if (pascalCaseDeviceType === "Foldable" && this.getScreen().getSnakecaseDeviceType() === "foldable") return [productConfigItem, pascalCaseDeviceType];
501
547
  else if (pascalCaseDeviceType === "Phone" && this.getScreen().getSnakecaseDeviceType() === "phone") return [productConfigItem, pascalCaseDeviceType];
@@ -507,50 +553,50 @@ var ScreenPresetImpl = class {
507
553
  else if (pascalCaseDeviceType.toLowerCase() === this.getScreen().getSnakecaseDeviceType().toLowerCase()) return [productConfigItem, pascalCaseDeviceType];
508
554
  }
509
555
  setProductPreset() {
510
- if (!this.isScreenOptions(this.options)) {
511
- this.productPreset = createProductPreset(this.options.productConfig, this.options.pascalCaseDeviceType, this);
512
- return;
513
- }
514
- const [productConfigItems = [], pascalCaseDeviceType] = this.getProductConfigItems() ?? [];
515
- if (!pascalCaseDeviceType || !productConfigItems.length) return;
516
- for (const productConfigItem of productConfigItems) {
517
- if (this.getScreen().getWidth() !== Number(productConfigItem.screenWidth) || this.getScreen().getHeight() !== Number(productConfigItem.screenHeight) || this.getScreen().getDiagonal() !== Number(productConfigItem.screenDiagonal) || this.getScreen().getDensity() !== Number(productConfigItem.screenDensity)) continue;
518
- if (productConfigItem.outerScreenWidth && productConfigItem.outerScreenHeight && productConfigItem.outerScreenDiagonal) {
519
- const outerScreen = this.getScreen().getOuterScreen();
520
- if (!outerScreen) continue;
521
- if (outerScreen.getWidth() !== Number(productConfigItem.outerScreenWidth) || outerScreen.getHeight() !== Number(productConfigItem.outerScreenHeight) || outerScreen.getDiagonal() !== Number(productConfigItem.outerScreenDiagonal)) continue;
522
- }
523
- if (productConfigItem.outerDoubleScreenWidth && productConfigItem.outerDoubleScreenHeight && productConfigItem.outerDoubleScreenDiagonal) {
524
- const outerDoubleScreen = this.getScreen().getOuterScreen()?.getOuterDoubleScreen();
525
- if (!outerDoubleScreen) continue;
526
- if (outerDoubleScreen.getWidth() !== Number(productConfigItem.outerDoubleScreenWidth) || outerDoubleScreen.getHeight() !== Number(productConfigItem.outerDoubleScreenHeight) || outerDoubleScreen.getDiagonal() !== Number(productConfigItem.outerDoubleScreenDiagonal)) continue;
556
+ if (ScreenPreset.ScreenOptions.is(this.options)) {
557
+ const [productConfigItems = [], pascalCaseDeviceType] = this.getProductConfigItemsByScreenOptions() ?? [];
558
+ if (!pascalCaseDeviceType || !productConfigItems.length) return;
559
+ for (const productConfigItem of productConfigItems) {
560
+ if (this.getScreen().getWidth() !== Number(productConfigItem.screenWidth) || this.getScreen().getHeight() !== Number(productConfigItem.screenHeight) || this.getScreen().getDiagonal() !== Number(productConfigItem.screenDiagonal) || this.getScreen().getDensity() !== Number(productConfigItem.screenDensity)) continue;
561
+ if (productConfigItem.outerScreenWidth && productConfigItem.outerScreenHeight && productConfigItem.outerScreenDiagonal) {
562
+ const outerScreen = this.getScreen().getOuterScreen();
563
+ if (!outerScreen) continue;
564
+ if (outerScreen.getWidth() !== Number(productConfigItem.outerScreenWidth) || outerScreen.getHeight() !== Number(productConfigItem.outerScreenHeight) || outerScreen.getDiagonal() !== Number(productConfigItem.outerScreenDiagonal)) continue;
565
+ }
566
+ if (productConfigItem.outerDoubleScreenWidth && productConfigItem.outerDoubleScreenHeight && productConfigItem.outerDoubleScreenDiagonal) {
567
+ const outerDoubleScreen = this.getScreen().getOuterScreen()?.getOuterDoubleScreen();
568
+ if (!outerDoubleScreen) continue;
569
+ if (outerDoubleScreen.getWidth() !== Number(productConfigItem.outerDoubleScreenWidth) || outerDoubleScreen.getHeight() !== Number(productConfigItem.outerDoubleScreenHeight) || outerDoubleScreen.getDiagonal() !== Number(productConfigItem.outerDoubleScreenDiagonal)) continue;
570
+ }
571
+ this.productPreset = createProductPreset(productConfigItem, pascalCaseDeviceType, this);
572
+ return;
527
573
  }
528
- this.productPreset = createProductPreset(productConfigItem, pascalCaseDeviceType, this);
529
- return;
530
- }
574
+ } else if (ScreenPreset.ProductOptions.is(this.options)) this.productPreset = createProductPreset(this.options.productConfig, this.options.pascalCaseDeviceType, this);
575
+ else if (ScreenPreset.EmulatorOptions.is(this.options)) this.emulatorPreset = createEmulatorPreset(this.options.emulatorConfig, this);
531
576
  }
532
577
  setEmulatorPreset() {
533
- if (!this.isScreenOptions(this.options)) return;
534
- if (!this.options.emulatorConfig) return;
535
- for (const parentConfigItem of this.options.emulatorConfig) {
536
- if (parentConfigItem.api !== this.options.screen.getApiVersion()) continue;
537
- if (ParentEmulatorConfigItem.is(parentConfigItem) && parentConfigItem.deviceType === this.options.screen.getSnakecaseDeviceType()) {
538
- this.emulatorPreset = createEmulatorPreset(parentConfigItem, this);
539
- return;
540
- }
541
- if (GroupPhoneAllEmulatorConfigItem.is(parentConfigItem) && isPhoneAllSnakecaseDeviceType(this.options.screen.getSnakecaseDeviceType())) {
542
- for (const childrenConfigItem of parentConfigItem.children) if (PhoneAllEmulatorConfigItem.is(childrenConfigItem) && childrenConfigItem.deviceType === this.options.screen.getSnakecaseDeviceType()) {
543
- this.emulatorPreset = createEmulatorPreset(childrenConfigItem, this);
578
+ if (ScreenPreset.ScreenOptions.is(this.options)) {
579
+ if (!this.options.emulatorConfig) return;
580
+ for (const parentConfigItem of this.options.emulatorConfig) {
581
+ if (parentConfigItem.api !== this.options.screen.getApiVersion()) continue;
582
+ if (ParentEmulatorConfigItem.is(parentConfigItem) && parentConfigItem.deviceType === this.options.screen.getSnakecaseDeviceType()) {
583
+ this.emulatorPreset = createEmulatorPreset(parentConfigItem, this);
544
584
  return;
545
585
  }
546
- }
547
- if (GroupPCAllEmulatorConfigItem.is(parentConfigItem) && isPCAllSnakecaseDeviceType(this.options.screen.getSnakecaseDeviceType())) {
548
- for (const childrenConfigItem of parentConfigItem.children) if (PCAllEmulatorConfigItem.is(childrenConfigItem) && childrenConfigItem.deviceType === this.options.screen.getSnakecaseDeviceType()) {
549
- this.emulatorPreset = createEmulatorPreset(childrenConfigItem, this);
550
- return;
586
+ if (GroupPhoneAllEmulatorConfigItem.is(parentConfigItem) && isPhoneAllSnakecaseDeviceType(this.options.screen.getSnakecaseDeviceType())) {
587
+ for (const childrenConfigItem of parentConfigItem.children) if (PhoneAllEmulatorConfigItem.is(childrenConfigItem) && childrenConfigItem.deviceType === this.options.screen.getSnakecaseDeviceType()) {
588
+ this.emulatorPreset = createEmulatorPreset(childrenConfigItem, this);
589
+ return;
590
+ }
591
+ }
592
+ if (GroupPCAllEmulatorConfigItem.is(parentConfigItem) && isPCAllSnakecaseDeviceType(this.options.screen.getSnakecaseDeviceType())) {
593
+ for (const childrenConfigItem of parentConfigItem.children) if (PCAllEmulatorConfigItem.is(childrenConfigItem) && childrenConfigItem.deviceType === this.options.screen.getSnakecaseDeviceType()) {
594
+ this.emulatorPreset = createEmulatorPreset(childrenConfigItem, this);
595
+ return;
596
+ }
551
597
  }
552
598
  }
553
- }
599
+ } else if (ScreenPreset.EmulatorOptions.is(this.options)) this.emulatorPreset = createEmulatorPreset(this.options.emulatorConfig, this);
554
600
  }
555
601
  getEmulatorPreset() {
556
602
  return this.emulatorPreset;
@@ -1315,6 +1361,12 @@ Object.defineProperty(exports, 'PhoneAllEmulatorConfigItem', {
1315
1361
  return PhoneAllEmulatorConfigItem;
1316
1362
  }
1317
1363
  });
1364
+ Object.defineProperty(exports, 'ProductConfigItem', {
1365
+ enumerable: true,
1366
+ get: function () {
1367
+ return ProductConfigItem;
1368
+ }
1369
+ });
1318
1370
  exports.RequestUrlError = RequestUrlError;
1319
1371
  exports.createCoverScreen = createCoverScreen;
1320
1372
  exports.createDoubleScreen = createDoubleScreen;
package/dist/index.d.cts CHANGED
@@ -409,12 +409,25 @@ declare namespace ScreenPreset {
409
409
  productConfig?: Partial<ProductConfig>;
410
410
  emulatorConfig?: EmulatorConfig;
411
411
  }
412
+ namespace ScreenOptions {
413
+ function is(value: unknown): value is ScreenOptions;
414
+ }
412
415
  interface ProductOptions {
413
416
  image: LocalImage;
414
417
  productConfig: ProductConfigItem;
415
418
  pascalCaseDeviceType: PascalCaseDeviceType;
416
419
  }
417
- type Options = ScreenOptions | ProductOptions;
420
+ namespace ProductOptions {
421
+ function is(value: unknown): value is ProductOptions;
422
+ }
423
+ interface EmulatorOptions {
424
+ image: LocalImage;
425
+ emulatorConfig: EmulatorConfigItem;
426
+ }
427
+ namespace EmulatorOptions {
428
+ function is(value: unknown): value is EmulatorOptions;
429
+ }
430
+ type Options = ScreenOptions | ProductOptions | EmulatorOptions;
418
431
  interface Stringifiable {
419
432
  emulatorPreset?: EmulatorPreset.Stringifiable;
420
433
  productPreset?: ProductPreset.Stringifiable;
@@ -669,4 +682,4 @@ declare namespace Device {
669
682
  }
670
683
  }
671
684
  //#endregion
672
- export { Arch, BaseEmulatorConfigItem, CoverScreen, DeployError, DeployedDevModel, DeployedImageConfig, DeployedImageConfigWithProductName, DeployedImageOptions, DevModel, Device, DeviceType, DoubleScreen, EmulatorConfig, EmulatorConfigItem, EmulatorPreset, FullDeployedImageOptions, GroupPCAllEmulatorConfigItem, GroupPhoneAllEmulatorConfigItem, Image, type ImageManager, type ImageManagerOptions, ImageType, LocalImage, OS, OuterDoubleScreen, OuterScreen, PCAllEmulatorConfigItem, PCAllSnakecaseDeviceType, ParentEmulatorConfigItem, ParentEmulatorSnakecaseDeviceType, PascalCaseDeviceType, PhoneAllEmulatorConfigItem, PhoneAllSnakecaseDeviceType, type ProductConfig, type ProductConfigItem, ProductNameable, ProductPreset, RemoteImage, RequestUrlError, Screen, ScreenPreset, SingleScreen, SnakecaseDeviceType, Stringifiable, createCoverScreen, createDoubleScreen, createImageManager, createOuterDoubleScreen, createOuterScreen, createScreen, createScreenPreset, createSingleScreen, isPCAllSnakecaseDeviceType, isPhoneAllSnakecaseDeviceType, version };
685
+ export { Arch, BaseEmulatorConfigItem, CoverScreen, DeployError, DeployedDevModel, DeployedImageConfig, DeployedImageConfigWithProductName, DeployedImageOptions, DevModel, Device, DeviceType, DoubleScreen, EmulatorConfig, EmulatorConfigItem, EmulatorPreset, FullDeployedImageOptions, GroupPCAllEmulatorConfigItem, GroupPhoneAllEmulatorConfigItem, Image, type ImageManager, type ImageManagerOptions, ImageType, LocalImage, OS, OuterDoubleScreen, OuterScreen, PCAllEmulatorConfigItem, PCAllSnakecaseDeviceType, ParentEmulatorConfigItem, ParentEmulatorSnakecaseDeviceType, PascalCaseDeviceType, PhoneAllEmulatorConfigItem, PhoneAllSnakecaseDeviceType, type ProductConfig, ProductConfigItem, ProductNameable, ProductPreset, RemoteImage, RequestUrlError, Screen, ScreenPreset, SingleScreen, SnakecaseDeviceType, Stringifiable, createCoverScreen, createDoubleScreen, createImageManager, createOuterDoubleScreen, createOuterScreen, createScreen, createScreenPreset, createSingleScreen, isPCAllSnakecaseDeviceType, isPhoneAllSnakecaseDeviceType, version };
package/dist/index.d.mts CHANGED
@@ -409,12 +409,25 @@ declare namespace ScreenPreset {
409
409
  productConfig?: Partial<ProductConfig>;
410
410
  emulatorConfig?: EmulatorConfig;
411
411
  }
412
+ namespace ScreenOptions {
413
+ function is(value: unknown): value is ScreenOptions;
414
+ }
412
415
  interface ProductOptions {
413
416
  image: LocalImage;
414
417
  productConfig: ProductConfigItem;
415
418
  pascalCaseDeviceType: PascalCaseDeviceType;
416
419
  }
417
- type Options = ScreenOptions | ProductOptions;
420
+ namespace ProductOptions {
421
+ function is(value: unknown): value is ProductOptions;
422
+ }
423
+ interface EmulatorOptions {
424
+ image: LocalImage;
425
+ emulatorConfig: EmulatorConfigItem;
426
+ }
427
+ namespace EmulatorOptions {
428
+ function is(value: unknown): value is EmulatorOptions;
429
+ }
430
+ type Options = ScreenOptions | ProductOptions | EmulatorOptions;
418
431
  interface Stringifiable {
419
432
  emulatorPreset?: EmulatorPreset.Stringifiable;
420
433
  productPreset?: ProductPreset.Stringifiable;
@@ -669,4 +682,4 @@ declare namespace Device {
669
682
  }
670
683
  }
671
684
  //#endregion
672
- export { Arch, BaseEmulatorConfigItem, type CoverScreen, DeployError, DeployedDevModel, DeployedImageConfig, DeployedImageConfigWithProductName, DeployedImageOptions, DevModel, type Device, DeviceType, type DoubleScreen, EmulatorConfig, EmulatorConfigItem, type EmulatorPreset, FullDeployedImageOptions, GroupPCAllEmulatorConfigItem, GroupPhoneAllEmulatorConfigItem, type Image, type ImageManager, type ImageManagerOptions, type ImageType, type LocalImage, OS, type OuterDoubleScreen, type OuterScreen, PCAllEmulatorConfigItem, PCAllSnakecaseDeviceType, ParentEmulatorConfigItem, ParentEmulatorSnakecaseDeviceType, PascalCaseDeviceType, PhoneAllEmulatorConfigItem, PhoneAllSnakecaseDeviceType, type ProductConfig, type ProductConfigItem, ProductNameable, type ProductPreset, type RemoteImage, RequestUrlError, type Screen, type ScreenPreset, type SingleScreen, SnakecaseDeviceType, Stringifiable, createCoverScreen, createDoubleScreen, createImageManager, createOuterDoubleScreen, createOuterScreen, createScreen, createScreenPreset, createSingleScreen, isPCAllSnakecaseDeviceType, isPhoneAllSnakecaseDeviceType, version };
685
+ export { Arch, BaseEmulatorConfigItem, type CoverScreen, DeployError, DeployedDevModel, DeployedImageConfig, DeployedImageConfigWithProductName, DeployedImageOptions, DevModel, type Device, DeviceType, type DoubleScreen, EmulatorConfig, EmulatorConfigItem, type EmulatorPreset, FullDeployedImageOptions, GroupPCAllEmulatorConfigItem, GroupPhoneAllEmulatorConfigItem, type Image, type ImageManager, type ImageManagerOptions, type ImageType, type LocalImage, OS, type OuterDoubleScreen, type OuterScreen, PCAllEmulatorConfigItem, PCAllSnakecaseDeviceType, ParentEmulatorConfigItem, ParentEmulatorSnakecaseDeviceType, PascalCaseDeviceType, PhoneAllEmulatorConfigItem, PhoneAllSnakecaseDeviceType, type ProductConfig, ProductConfigItem, ProductNameable, type ProductPreset, type RemoteImage, RequestUrlError, type Screen, type ScreenPreset, type SingleScreen, SnakecaseDeviceType, Stringifiable, createCoverScreen, createDoubleScreen, createImageManager, createOuterDoubleScreen, createOuterScreen, createScreen, createScreenPreset, createSingleScreen, isPCAllSnakecaseDeviceType, isPhoneAllSnakecaseDeviceType, version };
package/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ import mitt from "mitt";
5
5
  import progress from "progress-stream";
6
6
 
7
7
  //#region package.json
8
- var version = "0.4.1";
8
+ var version = "0.4.2";
9
9
 
10
10
  //#endregion
11
11
  //#region src/devices/list.ts
@@ -109,9 +109,6 @@ let ProductConfigItem;
109
109
  }
110
110
  _ProductConfigItem.is = is;
111
111
  })(ProductConfigItem || (ProductConfigItem = {}));
112
- function isProductConfig(value) {
113
- return typeof value === "object" && value !== null && Object.values(value).every((item) => Array.isArray(item));
114
- }
115
112
 
116
113
  //#endregion
117
114
  //#region src/types.ts
@@ -122,27 +119,6 @@ function isPCAllSnakecaseDeviceType(value) {
122
119
  return value === "2in1_foldable" || value === "2in1";
123
120
  }
124
121
 
125
- //#endregion
126
- //#region src/screens/emulator-preset.ts
127
- var EmulatorPresetImpl = class {
128
- constructor(emulatorConfigItem, screenPreset) {
129
- this.emulatorConfigItem = emulatorConfigItem;
130
- this.screenPreset = screenPreset;
131
- }
132
- getScreenPreset() {
133
- return this.screenPreset;
134
- }
135
- getEmulatorConfig() {
136
- return this.emulatorConfigItem;
137
- }
138
- toJSON() {
139
- return { emulatorConfig: this.emulatorConfigItem };
140
- }
141
- };
142
- function createEmulatorPreset(emulatorConfigItem, screenPreset) {
143
- return new EmulatorPresetImpl(emulatorConfigItem, screenPreset);
144
- }
145
-
146
122
  //#endregion
147
123
  //#region src/screens/base-screen.ts
148
124
  var BaseScreenImpl = class {
@@ -175,6 +151,73 @@ var BaseScreenImpl = class {
175
151
  }
176
152
  };
177
153
 
154
+ //#endregion
155
+ //#region src/screens/cover-screen.ts
156
+ let CoverScreen;
157
+ (function(_CoverScreen) {
158
+ function is(value) {
159
+ return value instanceof CoverScreenImpl;
160
+ }
161
+ _CoverScreen.is = is;
162
+ })(CoverScreen || (CoverScreen = {}));
163
+ var CoverScreenImpl = class extends BaseScreenImpl {
164
+ constructor(options, screen) {
165
+ super(options);
166
+ this.options = options;
167
+ this.screen = screen;
168
+ }
169
+ getScreen() {
170
+ return this.screen;
171
+ }
172
+ };
173
+ function createCoverScreen(options, screen) {
174
+ return new CoverScreenImpl(options, screen);
175
+ }
176
+
177
+ //#endregion
178
+ //#region src/screens/double-screen.ts
179
+ let DoubleScreen;
180
+ (function(_DoubleScreen) {
181
+ function is(value) {
182
+ return value instanceof DoubleScreenImpl;
183
+ }
184
+ _DoubleScreen.is = is;
185
+ })(DoubleScreen || (DoubleScreen = {}));
186
+ var DoubleScreenImpl = class extends BaseScreenImpl {
187
+ constructor(options, screen) {
188
+ super(options);
189
+ this.options = options;
190
+ this.screen = screen;
191
+ }
192
+ getScreen() {
193
+ return this.screen;
194
+ }
195
+ };
196
+ function createDoubleScreen(options, screen) {
197
+ return new DoubleScreenImpl(options, screen);
198
+ }
199
+
200
+ //#endregion
201
+ //#region src/screens/emulator-preset.ts
202
+ var EmulatorPresetImpl = class {
203
+ constructor(emulatorConfigItem, screenPreset) {
204
+ this.emulatorConfigItem = emulatorConfigItem;
205
+ this.screenPreset = screenPreset;
206
+ }
207
+ getScreenPreset() {
208
+ return this.screenPreset;
209
+ }
210
+ getEmulatorConfig() {
211
+ return this.emulatorConfigItem;
212
+ }
213
+ toJSON() {
214
+ return { emulatorConfig: this.emulatorConfigItem };
215
+ }
216
+ };
217
+ function createEmulatorPreset(emulatorConfigItem, screenPreset) {
218
+ return new EmulatorPresetImpl(emulatorConfigItem, screenPreset);
219
+ }
220
+
178
221
  //#endregion
179
222
  //#region src/screens/outer-screen.ts
180
223
  let OuterScreen;
@@ -264,52 +307,6 @@ function createProductPreset(productConfig, deviceType, screenPreset) {
264
307
  return new ProductPresetImpl(productConfig, deviceType, screenPreset);
265
308
  }
266
309
 
267
- //#endregion
268
- //#region src/screens/cover-screen.ts
269
- let CoverScreen;
270
- (function(_CoverScreen) {
271
- function is(value) {
272
- return value instanceof CoverScreenImpl;
273
- }
274
- _CoverScreen.is = is;
275
- })(CoverScreen || (CoverScreen = {}));
276
- var CoverScreenImpl = class extends BaseScreenImpl {
277
- constructor(options, screen) {
278
- super(options);
279
- this.options = options;
280
- this.screen = screen;
281
- }
282
- getScreen() {
283
- return this.screen;
284
- }
285
- };
286
- function createCoverScreen(options, screen) {
287
- return new CoverScreenImpl(options, screen);
288
- }
289
-
290
- //#endregion
291
- //#region src/screens/double-screen.ts
292
- let DoubleScreen;
293
- (function(_DoubleScreen) {
294
- function is(value) {
295
- return value instanceof DoubleScreenImpl;
296
- }
297
- _DoubleScreen.is = is;
298
- })(DoubleScreen || (DoubleScreen = {}));
299
- var DoubleScreenImpl = class extends BaseScreenImpl {
300
- constructor(options, screen) {
301
- super(options);
302
- this.options = options;
303
- this.screen = screen;
304
- }
305
- getScreen() {
306
- return this.screen;
307
- }
308
- };
309
- function createDoubleScreen(options, screen) {
310
- return new DoubleScreenImpl(options, screen);
311
- }
312
-
313
310
  //#endregion
314
311
  //#region src/screens/single-screen.ts
315
312
  let SingleScreen;
@@ -419,6 +416,27 @@ function createScreen(options) {
419
416
  //#region src/screens/screen-preset.ts
420
417
  let ScreenPreset;
421
418
  (function(_ScreenPreset) {
419
+ let ScreenOptions;
420
+ (function(_ScreenOptions) {
421
+ function is(value) {
422
+ return typeof value === "object" && value !== null && "screen" in value && Screen.is(value.screen);
423
+ }
424
+ _ScreenOptions.is = is;
425
+ })(ScreenOptions || (ScreenOptions = _ScreenPreset.ScreenOptions || (_ScreenPreset.ScreenOptions = {})));
426
+ let ProductOptions;
427
+ (function(_ProductOptions) {
428
+ function is(value) {
429
+ return typeof value === "object" && value !== null && "image" in value && "productConfig" in value && ProductConfigItem.is(value.productConfig);
430
+ }
431
+ _ProductOptions.is = is;
432
+ })(ProductOptions || (ProductOptions = _ScreenPreset.ProductOptions || (_ScreenPreset.ProductOptions = {})));
433
+ let EmulatorOptions;
434
+ (function(_EmulatorOptions) {
435
+ function is(value) {
436
+ return typeof value === "object" && value !== null && "image" in value && "emulatorConfig" in value;
437
+ }
438
+ _EmulatorOptions.is = is;
439
+ })(EmulatorOptions || (EmulatorOptions = _ScreenPreset.EmulatorOptions || (_ScreenPreset.EmulatorOptions = {})));
422
440
  function is(value) {
423
441
  return value instanceof ScreenPresetImpl;
424
442
  }
@@ -433,36 +451,64 @@ var ScreenPresetImpl = class {
433
451
  this.setEmulatorPreset();
434
452
  this.setProductPreset();
435
453
  }
436
- isScreenOptions(options) {
437
- return "screen" in options && Screen.is(options.screen);
438
- }
439
454
  _screen;
440
455
  getScreen() {
441
- if (this.isScreenOptions(this.options)) return this.options.screen;
456
+ if (ScreenPreset.ScreenOptions.is(this.options)) return this.options.screen;
442
457
  if (this._screen) return this._screen;
443
- this._screen = createScreen({
444
- width: Number(this.options.productConfig.screenWidth),
445
- height: Number(this.options.productConfig.screenHeight),
446
- diagonal: Number(this.options.productConfig.screenDiagonal),
447
- density: Number(this.options.productConfig.screenDensity),
448
- apiVersion: Number.parseInt(this.options.image.getApiVersion()),
449
- deviceType: this.options.image.getSnakecaseDeviceType()
450
- });
451
- if (this.options.productConfig.outerScreenWidth && this.options.productConfig.outerScreenHeight && this.options.productConfig.outerScreenDiagonal) this._screen.setOuterScreen(createOuterScreen({
452
- width: Number(this.options.productConfig.outerScreenWidth),
453
- height: Number(this.options.productConfig.outerScreenHeight),
454
- diagonal: Number(this.options.productConfig.outerScreenDiagonal)
455
- }, this._screen));
456
- if (this.options.productConfig.outerDoubleScreenWidth && this.options.productConfig.outerDoubleScreenHeight && this.options.productConfig.outerDoubleScreenDiagonal) this._screen.getOuterScreen()?.setOuterDoubleScreen(createOuterDoubleScreen({
457
- width: Number(this.options.productConfig.outerDoubleScreenWidth),
458
- height: Number(this.options.productConfig.outerDoubleScreenHeight),
459
- diagonal: Number(this.options.productConfig.outerDoubleScreenDiagonal)
460
- }, this._screen.getOuterScreen()));
461
- return this._screen;
462
- }
463
- getProductConfigItems() {
464
- if (!this.options.productConfig || !isProductConfig(this.options.productConfig)) return;
465
- for (const [pascalCaseDeviceType, productConfigItem] of Object.entries(this.options.productConfig)) if (pascalCaseDeviceType === "2in1" && this.getScreen().getSnakecaseDeviceType() === "2in1") return [productConfigItem, pascalCaseDeviceType];
458
+ if (ScreenPreset.ProductOptions.is(this.options)) {
459
+ this._screen = createScreen({
460
+ width: Number(this.options.productConfig.screenWidth),
461
+ height: Number(this.options.productConfig.screenHeight),
462
+ diagonal: Number(this.options.productConfig.screenDiagonal),
463
+ density: Number(this.options.productConfig.screenDensity),
464
+ apiVersion: Number.parseInt(this.options.image.getApiVersion()),
465
+ deviceType: this.options.image.getSnakecaseDeviceType()
466
+ });
467
+ if (this.options.productConfig.outerScreenWidth && this.options.productConfig.outerScreenHeight && this.options.productConfig.outerScreenDiagonal) this._screen.setOuterScreen(createOuterScreen({
468
+ width: Number(this.options.productConfig.outerScreenWidth),
469
+ height: Number(this.options.productConfig.outerScreenHeight),
470
+ diagonal: Number(this.options.productConfig.outerScreenDiagonal)
471
+ }, this._screen));
472
+ if (this.options.productConfig.outerDoubleScreenWidth && this.options.productConfig.outerDoubleScreenHeight && this.options.productConfig.outerDoubleScreenDiagonal) this._screen.getOuterScreen()?.setOuterDoubleScreen(createOuterDoubleScreen({
473
+ width: Number(this.options.productConfig.outerDoubleScreenWidth),
474
+ height: Number(this.options.productConfig.outerDoubleScreenHeight),
475
+ diagonal: Number(this.options.productConfig.outerDoubleScreenDiagonal)
476
+ }, this._screen.getOuterScreen()));
477
+ return this._screen;
478
+ }
479
+ if (ScreenPreset.EmulatorOptions.is(this.options)) {
480
+ this._screen = createScreen({
481
+ width: this.options.emulatorConfig.resolutionWidth,
482
+ height: this.options.emulatorConfig.resolutionHeight,
483
+ diagonal: this.options.emulatorConfig.diagonalSize,
484
+ density: this.options.emulatorConfig.density,
485
+ apiVersion: Number.parseInt(this.options.image.getApiVersion()),
486
+ deviceType: this.options.image.getSnakecaseDeviceType()
487
+ });
488
+ if (this.options.emulatorConfig.coverResolutionWidth && this.options.emulatorConfig.coverResolutionHeight && this.options.emulatorConfig.coverDiagonalSize) this._screen.setCoverScreen(createCoverScreen({
489
+ width: this.options.emulatorConfig.coverResolutionWidth,
490
+ height: this.options.emulatorConfig.coverResolutionHeight,
491
+ diagonal: this.options.emulatorConfig.coverDiagonalSize
492
+ }, this._screen));
493
+ if (PhoneAllEmulatorConfigItem.is(this.options.emulatorConfig)) {
494
+ if (this.options.emulatorConfig.singleResolutionWidth && this.options.emulatorConfig.singleResolutionHeight && this.options.emulatorConfig.singleDiagonalSize) this._screen.setSingleScreen(createSingleScreen({
495
+ width: this.options.emulatorConfig.singleResolutionWidth,
496
+ height: this.options.emulatorConfig.singleResolutionHeight,
497
+ diagonal: this.options.emulatorConfig.singleDiagonalSize
498
+ }, this._screen));
499
+ if (this.options.emulatorConfig.doubleResolutionWidth && this.options.emulatorConfig.doubleResolutionHeight && this.options.emulatorConfig.doubleDiagonalSize) this._screen.setDoubleScreen(createDoubleScreen({
500
+ width: this.options.emulatorConfig.doubleResolutionWidth,
501
+ height: this.options.emulatorConfig.doubleResolutionHeight,
502
+ diagonal: this.options.emulatorConfig.doubleDiagonalSize
503
+ }, this._screen));
504
+ }
505
+ return this._screen;
506
+ }
507
+ throw new Error("Invalid createScreenPreset options.");
508
+ }
509
+ getProductConfigItemsByScreenOptions() {
510
+ if (!ScreenPreset.ScreenOptions.is(this.options)) return;
511
+ for (const [pascalCaseDeviceType, productConfigItem] of Object.entries(this.options.productConfig ?? {})) if (pascalCaseDeviceType === "2in1" && this.getScreen().getSnakecaseDeviceType() === "2in1") return [productConfigItem, pascalCaseDeviceType];
466
512
  else if (pascalCaseDeviceType === "2in1 Foldable" && this.getScreen().getSnakecaseDeviceType() === "2in1_foldable") return [productConfigItem, pascalCaseDeviceType];
467
513
  else if (pascalCaseDeviceType === "Foldable" && this.getScreen().getSnakecaseDeviceType() === "foldable") return [productConfigItem, pascalCaseDeviceType];
468
514
  else if (pascalCaseDeviceType === "Phone" && this.getScreen().getSnakecaseDeviceType() === "phone") return [productConfigItem, pascalCaseDeviceType];
@@ -474,50 +520,50 @@ var ScreenPresetImpl = class {
474
520
  else if (pascalCaseDeviceType.toLowerCase() === this.getScreen().getSnakecaseDeviceType().toLowerCase()) return [productConfigItem, pascalCaseDeviceType];
475
521
  }
476
522
  setProductPreset() {
477
- if (!this.isScreenOptions(this.options)) {
478
- this.productPreset = createProductPreset(this.options.productConfig, this.options.pascalCaseDeviceType, this);
479
- return;
480
- }
481
- const [productConfigItems = [], pascalCaseDeviceType] = this.getProductConfigItems() ?? [];
482
- if (!pascalCaseDeviceType || !productConfigItems.length) return;
483
- for (const productConfigItem of productConfigItems) {
484
- if (this.getScreen().getWidth() !== Number(productConfigItem.screenWidth) || this.getScreen().getHeight() !== Number(productConfigItem.screenHeight) || this.getScreen().getDiagonal() !== Number(productConfigItem.screenDiagonal) || this.getScreen().getDensity() !== Number(productConfigItem.screenDensity)) continue;
485
- if (productConfigItem.outerScreenWidth && productConfigItem.outerScreenHeight && productConfigItem.outerScreenDiagonal) {
486
- const outerScreen = this.getScreen().getOuterScreen();
487
- if (!outerScreen) continue;
488
- if (outerScreen.getWidth() !== Number(productConfigItem.outerScreenWidth) || outerScreen.getHeight() !== Number(productConfigItem.outerScreenHeight) || outerScreen.getDiagonal() !== Number(productConfigItem.outerScreenDiagonal)) continue;
489
- }
490
- if (productConfigItem.outerDoubleScreenWidth && productConfigItem.outerDoubleScreenHeight && productConfigItem.outerDoubleScreenDiagonal) {
491
- const outerDoubleScreen = this.getScreen().getOuterScreen()?.getOuterDoubleScreen();
492
- if (!outerDoubleScreen) continue;
493
- if (outerDoubleScreen.getWidth() !== Number(productConfigItem.outerDoubleScreenWidth) || outerDoubleScreen.getHeight() !== Number(productConfigItem.outerDoubleScreenHeight) || outerDoubleScreen.getDiagonal() !== Number(productConfigItem.outerDoubleScreenDiagonal)) continue;
523
+ if (ScreenPreset.ScreenOptions.is(this.options)) {
524
+ const [productConfigItems = [], pascalCaseDeviceType] = this.getProductConfigItemsByScreenOptions() ?? [];
525
+ if (!pascalCaseDeviceType || !productConfigItems.length) return;
526
+ for (const productConfigItem of productConfigItems) {
527
+ if (this.getScreen().getWidth() !== Number(productConfigItem.screenWidth) || this.getScreen().getHeight() !== Number(productConfigItem.screenHeight) || this.getScreen().getDiagonal() !== Number(productConfigItem.screenDiagonal) || this.getScreen().getDensity() !== Number(productConfigItem.screenDensity)) continue;
528
+ if (productConfigItem.outerScreenWidth && productConfigItem.outerScreenHeight && productConfigItem.outerScreenDiagonal) {
529
+ const outerScreen = this.getScreen().getOuterScreen();
530
+ if (!outerScreen) continue;
531
+ if (outerScreen.getWidth() !== Number(productConfigItem.outerScreenWidth) || outerScreen.getHeight() !== Number(productConfigItem.outerScreenHeight) || outerScreen.getDiagonal() !== Number(productConfigItem.outerScreenDiagonal)) continue;
532
+ }
533
+ if (productConfigItem.outerDoubleScreenWidth && productConfigItem.outerDoubleScreenHeight && productConfigItem.outerDoubleScreenDiagonal) {
534
+ const outerDoubleScreen = this.getScreen().getOuterScreen()?.getOuterDoubleScreen();
535
+ if (!outerDoubleScreen) continue;
536
+ if (outerDoubleScreen.getWidth() !== Number(productConfigItem.outerDoubleScreenWidth) || outerDoubleScreen.getHeight() !== Number(productConfigItem.outerDoubleScreenHeight) || outerDoubleScreen.getDiagonal() !== Number(productConfigItem.outerDoubleScreenDiagonal)) continue;
537
+ }
538
+ this.productPreset = createProductPreset(productConfigItem, pascalCaseDeviceType, this);
539
+ return;
494
540
  }
495
- this.productPreset = createProductPreset(productConfigItem, pascalCaseDeviceType, this);
496
- return;
497
- }
541
+ } else if (ScreenPreset.ProductOptions.is(this.options)) this.productPreset = createProductPreset(this.options.productConfig, this.options.pascalCaseDeviceType, this);
542
+ else if (ScreenPreset.EmulatorOptions.is(this.options)) this.emulatorPreset = createEmulatorPreset(this.options.emulatorConfig, this);
498
543
  }
499
544
  setEmulatorPreset() {
500
- if (!this.isScreenOptions(this.options)) return;
501
- if (!this.options.emulatorConfig) return;
502
- for (const parentConfigItem of this.options.emulatorConfig) {
503
- if (parentConfigItem.api !== this.options.screen.getApiVersion()) continue;
504
- if (ParentEmulatorConfigItem.is(parentConfigItem) && parentConfigItem.deviceType === this.options.screen.getSnakecaseDeviceType()) {
505
- this.emulatorPreset = createEmulatorPreset(parentConfigItem, this);
506
- return;
507
- }
508
- if (GroupPhoneAllEmulatorConfigItem.is(parentConfigItem) && isPhoneAllSnakecaseDeviceType(this.options.screen.getSnakecaseDeviceType())) {
509
- for (const childrenConfigItem of parentConfigItem.children) if (PhoneAllEmulatorConfigItem.is(childrenConfigItem) && childrenConfigItem.deviceType === this.options.screen.getSnakecaseDeviceType()) {
510
- this.emulatorPreset = createEmulatorPreset(childrenConfigItem, this);
545
+ if (ScreenPreset.ScreenOptions.is(this.options)) {
546
+ if (!this.options.emulatorConfig) return;
547
+ for (const parentConfigItem of this.options.emulatorConfig) {
548
+ if (parentConfigItem.api !== this.options.screen.getApiVersion()) continue;
549
+ if (ParentEmulatorConfigItem.is(parentConfigItem) && parentConfigItem.deviceType === this.options.screen.getSnakecaseDeviceType()) {
550
+ this.emulatorPreset = createEmulatorPreset(parentConfigItem, this);
511
551
  return;
512
552
  }
513
- }
514
- if (GroupPCAllEmulatorConfigItem.is(parentConfigItem) && isPCAllSnakecaseDeviceType(this.options.screen.getSnakecaseDeviceType())) {
515
- for (const childrenConfigItem of parentConfigItem.children) if (PCAllEmulatorConfigItem.is(childrenConfigItem) && childrenConfigItem.deviceType === this.options.screen.getSnakecaseDeviceType()) {
516
- this.emulatorPreset = createEmulatorPreset(childrenConfigItem, this);
517
- return;
553
+ if (GroupPhoneAllEmulatorConfigItem.is(parentConfigItem) && isPhoneAllSnakecaseDeviceType(this.options.screen.getSnakecaseDeviceType())) {
554
+ for (const childrenConfigItem of parentConfigItem.children) if (PhoneAllEmulatorConfigItem.is(childrenConfigItem) && childrenConfigItem.deviceType === this.options.screen.getSnakecaseDeviceType()) {
555
+ this.emulatorPreset = createEmulatorPreset(childrenConfigItem, this);
556
+ return;
557
+ }
558
+ }
559
+ if (GroupPCAllEmulatorConfigItem.is(parentConfigItem) && isPCAllSnakecaseDeviceType(this.options.screen.getSnakecaseDeviceType())) {
560
+ for (const childrenConfigItem of parentConfigItem.children) if (PCAllEmulatorConfigItem.is(childrenConfigItem) && childrenConfigItem.deviceType === this.options.screen.getSnakecaseDeviceType()) {
561
+ this.emulatorPreset = createEmulatorPreset(childrenConfigItem, this);
562
+ return;
563
+ }
518
564
  }
519
565
  }
520
- }
566
+ } else if (ScreenPreset.EmulatorOptions.is(this.options)) this.emulatorPreset = createEmulatorPreset(this.options.emulatorConfig, this);
521
567
  }
522
568
  getEmulatorPreset() {
523
569
  return this.emulatorPreset;
@@ -1239,4 +1285,4 @@ async function createImageManager(options = {}) {
1239
1285
  }
1240
1286
 
1241
1287
  //#endregion
1242
- export { BaseEmulatorConfigItem, DeployError, DevModel, GroupPCAllEmulatorConfigItem, GroupPhoneAllEmulatorConfigItem, PCAllEmulatorConfigItem, ParentEmulatorConfigItem, PhoneAllEmulatorConfigItem, RequestUrlError, createCoverScreen, createDoubleScreen, createImageManager, createOuterDoubleScreen, createOuterScreen, createScreen, createScreenPreset, createSingleScreen, version };
1288
+ export { BaseEmulatorConfigItem, DeployError, DevModel, GroupPCAllEmulatorConfigItem, GroupPhoneAllEmulatorConfigItem, PCAllEmulatorConfigItem, ParentEmulatorConfigItem, PhoneAllEmulatorConfigItem, ProductConfigItem, RequestUrlError, createCoverScreen, createDoubleScreen, createImageManager, createOuterDoubleScreen, createOuterScreen, createScreen, createScreenPreset, createSingleScreen, version };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arkts/image-manager",
3
3
  "type": "module",
4
- "version": "0.4.1",
4
+ "version": "0.4.2",
5
5
  "description": "OpenHarmony/HarmonyOS qemu image manager.",
6
6
  "author": "Naily Zero <zero@naily.cc> (https://naily.cc)",
7
7
  "license": "MIT",