@arkts/image-manager 0.3.5 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/default-emulator-config.cjs +793 -0
- package/dist/default-emulator-config.d.cts +5 -0
- package/dist/default-emulator-config.d.mts +6 -0
- package/dist/default-emulator-config.mjs +792 -0
- package/dist/default-product-config.d.cts +1 -1
- package/dist/default-product-config.d.mts +1 -1
- package/dist/emulator-config-DbI3FRE5.d.mts +64 -0
- package/dist/emulator-config-HeXlMqZ-.d.cts +64 -0
- package/dist/index.cjs +528 -53
- package/dist/index.d.cts +160 -19
- package/dist/index.d.mts +160 -19
- package/dist/index.mjs +486 -51
- package/dist/{product-config-2xNDbvax.d.cts → product-config-ByDVg0-5.d.mts} +6 -11
- package/dist/{product-config-CDvEXtfy.d.mts → product-config-DuzOJEvZ.d.cts} +6 -11
- package/dist/types-CayFonNb.d.cts +16 -0
- package/dist/types-DD8_iqBV.d.mts +16 -0
- package/package.json +21 -3
package/dist/index.cjs
CHANGED
|
@@ -36,11 +36,9 @@ let mitt = require("mitt");
|
|
|
36
36
|
mitt = __toESM(mitt);
|
|
37
37
|
let progress_stream = require("progress-stream");
|
|
38
38
|
progress_stream = __toESM(progress_stream);
|
|
39
|
-
let unzipper = require("unzipper");
|
|
40
|
-
unzipper = __toESM(unzipper);
|
|
41
39
|
|
|
42
40
|
//#region package.json
|
|
43
|
-
var version = "0.
|
|
41
|
+
var version = "0.4.1";
|
|
44
42
|
|
|
45
43
|
//#endregion
|
|
46
44
|
//#region src/devices/list.ts
|
|
@@ -55,6 +53,51 @@ let DevModel = /* @__PURE__ */ function(DevModel) {
|
|
|
55
53
|
return DevModel;
|
|
56
54
|
}({});
|
|
57
55
|
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/emulator-config.ts
|
|
58
|
+
let BaseEmulatorConfigItem;
|
|
59
|
+
(function(_BaseEmulatorConfigItem) {
|
|
60
|
+
function is(value) {
|
|
61
|
+
return typeof value === "object" && value !== null && "name" in value && typeof value.name === "string" && "deviceType" in value && typeof value.deviceType === "string" && "api" in value && typeof value.api === "number";
|
|
62
|
+
}
|
|
63
|
+
_BaseEmulatorConfigItem.is = is;
|
|
64
|
+
})(BaseEmulatorConfigItem || (BaseEmulatorConfigItem = {}));
|
|
65
|
+
let ParentEmulatorConfigItem;
|
|
66
|
+
(function(_ParentEmulatorConfigItem) {
|
|
67
|
+
function is(value) {
|
|
68
|
+
return BaseEmulatorConfigItem.is(value) && "resolutionWidth" in value && typeof value.resolutionWidth === "number" && "resolutionHeight" in value && typeof value.resolutionHeight === "number" && "physicalWidth" in value && typeof value.physicalWidth === "number" && "physicalHeight" in value && typeof value.physicalHeight === "number" && "diagonalSize" in value && typeof value.diagonalSize === "number" && "density" in value && typeof value.density === "number" && "memoryRamSize" in value && typeof value.memoryRamSize === "number" && "datadiskSize" in value && typeof value.datadiskSize === "number" && "procNumber" in value && typeof value.procNumber === "number" && "api" in value && typeof value.api === "number";
|
|
69
|
+
}
|
|
70
|
+
_ParentEmulatorConfigItem.is = is;
|
|
71
|
+
})(ParentEmulatorConfigItem || (ParentEmulatorConfigItem = {}));
|
|
72
|
+
let PhoneAllEmulatorConfigItem;
|
|
73
|
+
(function(_PhoneAllEmulatorConfigItem) {
|
|
74
|
+
function is(value) {
|
|
75
|
+
return ParentEmulatorConfigItem.is(value);
|
|
76
|
+
}
|
|
77
|
+
_PhoneAllEmulatorConfigItem.is = is;
|
|
78
|
+
})(PhoneAllEmulatorConfigItem || (PhoneAllEmulatorConfigItem = {}));
|
|
79
|
+
let GroupPhoneAllEmulatorConfigItem;
|
|
80
|
+
(function(_GroupPhoneAllEmulatorConfigItem) {
|
|
81
|
+
function is(value) {
|
|
82
|
+
return BaseEmulatorConfigItem.is(value) && "children" in value && Array.isArray(value.children) && value.children.every(PhoneAllEmulatorConfigItem.is);
|
|
83
|
+
}
|
|
84
|
+
_GroupPhoneAllEmulatorConfigItem.is = is;
|
|
85
|
+
})(GroupPhoneAllEmulatorConfigItem || (GroupPhoneAllEmulatorConfigItem = {}));
|
|
86
|
+
let PCAllEmulatorConfigItem;
|
|
87
|
+
(function(_PCAllEmulatorConfigItem) {
|
|
88
|
+
function is(value) {
|
|
89
|
+
return ParentEmulatorConfigItem.is(value);
|
|
90
|
+
}
|
|
91
|
+
_PCAllEmulatorConfigItem.is = is;
|
|
92
|
+
})(PCAllEmulatorConfigItem || (PCAllEmulatorConfigItem = {}));
|
|
93
|
+
let GroupPCAllEmulatorConfigItem;
|
|
94
|
+
(function(_GroupPCAllEmulatorConfigItem) {
|
|
95
|
+
function is(value) {
|
|
96
|
+
return BaseEmulatorConfigItem.is(value) && "children" in value && Array.isArray(value.children) && value.children.every(PCAllEmulatorConfigItem.is);
|
|
97
|
+
}
|
|
98
|
+
_GroupPCAllEmulatorConfigItem.is = is;
|
|
99
|
+
})(GroupPCAllEmulatorConfigItem || (GroupPCAllEmulatorConfigItem = {}));
|
|
100
|
+
|
|
58
101
|
//#endregion
|
|
59
102
|
//#region src/errors/deploy-error.ts
|
|
60
103
|
var DeployError = class extends Error {
|
|
@@ -91,23 +134,59 @@ var RequestUrlError = class extends Error {
|
|
|
91
134
|
};
|
|
92
135
|
|
|
93
136
|
//#endregion
|
|
94
|
-
//#region src/
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
137
|
+
//#region src/product-config.ts
|
|
138
|
+
let ProductConfigItem;
|
|
139
|
+
(function(_ProductConfigItem) {
|
|
140
|
+
function is(value) {
|
|
141
|
+
return typeof value === "object" && value !== null && "name" in value && "screenWidth" in value && "screenHeight" in value && "screenDiagonal" in value && "screenDensity" in value && typeof value.name === "string" && typeof value.screenWidth === "string" && typeof value.screenHeight === "string" && typeof value.screenDiagonal === "string" && typeof value.screenDensity === "string";
|
|
142
|
+
}
|
|
143
|
+
_ProductConfigItem.is = is;
|
|
144
|
+
})(ProductConfigItem || (ProductConfigItem = {}));
|
|
145
|
+
function isProductConfig(value) {
|
|
146
|
+
return typeof value === "object" && value !== null && Object.values(value).every((item) => Array.isArray(item));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/types.ts
|
|
151
|
+
function isPhoneAllSnakecaseDeviceType(value) {
|
|
152
|
+
return value === "phone" || value === "triplefold" || value === "widefold" || value === "foldable";
|
|
153
|
+
}
|
|
154
|
+
function isPCAllSnakecaseDeviceType(value) {
|
|
155
|
+
return value === "2in1_foldable" || value === "2in1";
|
|
156
|
+
}
|
|
157
|
+
|
|
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;
|
|
98
164
|
}
|
|
99
|
-
|
|
100
|
-
return this.
|
|
165
|
+
getScreenPreset() {
|
|
166
|
+
return this.screenPreset;
|
|
101
167
|
}
|
|
102
|
-
|
|
103
|
-
this.
|
|
104
|
-
return this;
|
|
168
|
+
getEmulatorConfig() {
|
|
169
|
+
return this.emulatorConfigItem;
|
|
105
170
|
}
|
|
106
|
-
|
|
107
|
-
return this.
|
|
171
|
+
toJSON() {
|
|
172
|
+
return { emulatorConfig: this.emulatorConfigItem };
|
|
108
173
|
}
|
|
109
|
-
|
|
110
|
-
|
|
174
|
+
};
|
|
175
|
+
function createEmulatorPreset(emulatorConfigItem, screenPreset) {
|
|
176
|
+
return new EmulatorPresetImpl(emulatorConfigItem, screenPreset);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/screens/base-screen.ts
|
|
181
|
+
var BaseScreenImpl = class {
|
|
182
|
+
constructor(options) {
|
|
183
|
+
this.options = options;
|
|
184
|
+
}
|
|
185
|
+
getWidth() {
|
|
186
|
+
return this.options.width;
|
|
187
|
+
}
|
|
188
|
+
setWidth(width) {
|
|
189
|
+
this.options.width = width;
|
|
111
190
|
return this;
|
|
112
191
|
}
|
|
113
192
|
getHeight() {
|
|
@@ -117,27 +196,86 @@ var ScreenImpl = class {
|
|
|
117
196
|
this.options.height = height;
|
|
118
197
|
return this;
|
|
119
198
|
}
|
|
120
|
-
|
|
121
|
-
return this.options.
|
|
199
|
+
getDiagonal() {
|
|
200
|
+
return this.options.diagonal;
|
|
122
201
|
}
|
|
123
|
-
|
|
124
|
-
this.options.
|
|
202
|
+
setDiagonal(diagonal) {
|
|
203
|
+
this.options.diagonal = diagonal;
|
|
125
204
|
return this;
|
|
126
205
|
}
|
|
127
206
|
toJSON() {
|
|
128
207
|
return this.options;
|
|
129
208
|
}
|
|
130
209
|
};
|
|
131
|
-
|
|
132
|
-
|
|
210
|
+
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region src/screens/outer-screen.ts
|
|
213
|
+
let OuterScreen;
|
|
214
|
+
(function(_OuterScreen) {
|
|
215
|
+
function is(value) {
|
|
216
|
+
return value instanceof OuterScreenImpl;
|
|
217
|
+
}
|
|
218
|
+
_OuterScreen.is = is;
|
|
219
|
+
})(OuterScreen || (OuterScreen = {}));
|
|
220
|
+
var OuterScreenImpl = class extends BaseScreenImpl {
|
|
221
|
+
outerDoubleScreen;
|
|
222
|
+
constructor(options, screen) {
|
|
223
|
+
super(options);
|
|
224
|
+
this.options = options;
|
|
225
|
+
this.screen = screen;
|
|
226
|
+
if (options.double) this.outerDoubleScreen = OuterDoubleScreen.is(options.double) ? options.double : createOuterDoubleScreen(options.double, this);
|
|
227
|
+
}
|
|
228
|
+
getScreen() {
|
|
229
|
+
return this.screen;
|
|
230
|
+
}
|
|
231
|
+
getOuterDoubleScreen() {
|
|
232
|
+
return this.outerDoubleScreen;
|
|
233
|
+
}
|
|
234
|
+
setOuterDoubleScreen(outerDoubleScreen) {
|
|
235
|
+
this.outerDoubleScreen = OuterDoubleScreen.is(outerDoubleScreen) ? outerDoubleScreen : createOuterDoubleScreen(outerDoubleScreen, this);
|
|
236
|
+
return this;
|
|
237
|
+
}
|
|
238
|
+
toJSON() {
|
|
239
|
+
return {
|
|
240
|
+
...super.toJSON(),
|
|
241
|
+
double: this.outerDoubleScreen?.toJSON()
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
function createOuterScreen(options, screen) {
|
|
246
|
+
return new OuterScreenImpl(options, screen);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/screens/outer-double-screen.ts
|
|
251
|
+
let OuterDoubleScreen;
|
|
252
|
+
(function(_OuterDoubleScreen) {
|
|
253
|
+
function is(value) {
|
|
254
|
+
return value instanceof OuterDoubleScreenImpl;
|
|
255
|
+
}
|
|
256
|
+
_OuterDoubleScreen.is = is;
|
|
257
|
+
})(OuterDoubleScreen || (OuterDoubleScreen = {}));
|
|
258
|
+
var OuterDoubleScreenImpl = class extends OuterScreenImpl {
|
|
259
|
+
constructor(options, outerScreen) {
|
|
260
|
+
super(options, outerScreen.getScreen());
|
|
261
|
+
this.options = options;
|
|
262
|
+
this.outerScreen = outerScreen;
|
|
263
|
+
}
|
|
264
|
+
getOuterScreen() {
|
|
265
|
+
return this.outerScreen;
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
function createOuterDoubleScreen(options, outerScreen) {
|
|
269
|
+
return new OuterDoubleScreenImpl(options, outerScreen);
|
|
133
270
|
}
|
|
134
271
|
|
|
135
272
|
//#endregion
|
|
136
273
|
//#region src/screens/product-preset.ts
|
|
137
274
|
var ProductPresetImpl = class {
|
|
138
|
-
constructor(productConfig, deviceType) {
|
|
275
|
+
constructor(productConfig, deviceType, screenPreset) {
|
|
139
276
|
this.productConfig = productConfig;
|
|
140
277
|
this.deviceType = deviceType;
|
|
278
|
+
this.screenPreset = screenPreset;
|
|
141
279
|
}
|
|
142
280
|
getProductConfig() {
|
|
143
281
|
return this.productConfig;
|
|
@@ -145,13 +283,8 @@ var ProductPresetImpl = class {
|
|
|
145
283
|
getDeviceType() {
|
|
146
284
|
return this.deviceType;
|
|
147
285
|
}
|
|
148
|
-
|
|
149
|
-
return
|
|
150
|
-
diagonal: Number(this.productConfig.screenDiagonal),
|
|
151
|
-
density: Number(this.productConfig.screenDensity),
|
|
152
|
-
height: Number(this.productConfig.screenHeight),
|
|
153
|
-
width: Number(this.productConfig.screenWidth)
|
|
154
|
-
});
|
|
286
|
+
getScreenPreset() {
|
|
287
|
+
return this.screenPreset;
|
|
155
288
|
}
|
|
156
289
|
toJSON() {
|
|
157
290
|
return {
|
|
@@ -160,8 +293,280 @@ var ProductPresetImpl = class {
|
|
|
160
293
|
};
|
|
161
294
|
}
|
|
162
295
|
};
|
|
163
|
-
|
|
164
|
-
return new ProductPresetImpl(productConfig, deviceType);
|
|
296
|
+
function createProductPreset(productConfig, deviceType, screenPreset) {
|
|
297
|
+
return new ProductPresetImpl(productConfig, deviceType, screenPreset);
|
|
298
|
+
}
|
|
299
|
+
|
|
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
|
+
//#endregion
|
|
347
|
+
//#region src/screens/single-screen.ts
|
|
348
|
+
let SingleScreen;
|
|
349
|
+
(function(_SingleScreen) {
|
|
350
|
+
function is(value) {
|
|
351
|
+
return value instanceof SingleScreenImpl;
|
|
352
|
+
}
|
|
353
|
+
_SingleScreen.is = is;
|
|
354
|
+
})(SingleScreen || (SingleScreen = {}));
|
|
355
|
+
var SingleScreenImpl = class extends BaseScreenImpl {
|
|
356
|
+
constructor(options, screen) {
|
|
357
|
+
super(options);
|
|
358
|
+
this.options = options;
|
|
359
|
+
this.screen = screen;
|
|
360
|
+
}
|
|
361
|
+
getScreen() {
|
|
362
|
+
return this.screen;
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
function createSingleScreen(options, screen) {
|
|
366
|
+
return new SingleScreenImpl(options, screen);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
//#endregion
|
|
370
|
+
//#region src/screens/screen.ts
|
|
371
|
+
let Screen;
|
|
372
|
+
(function(_Screen) {
|
|
373
|
+
function is(value) {
|
|
374
|
+
return value instanceof ScreenImpl;
|
|
375
|
+
}
|
|
376
|
+
_Screen.is = is;
|
|
377
|
+
})(Screen || (Screen = {}));
|
|
378
|
+
var ScreenImpl = class extends BaseScreenImpl {
|
|
379
|
+
outerScreen;
|
|
380
|
+
coverScreen;
|
|
381
|
+
singleScreen;
|
|
382
|
+
doubleScreen;
|
|
383
|
+
constructor(options) {
|
|
384
|
+
super(options);
|
|
385
|
+
this.options = options;
|
|
386
|
+
if (options.outer) this.outerScreen = OuterScreen.is(options.outer) ? options.outer : createOuterScreen(options.outer, this);
|
|
387
|
+
if (options.cover) this.coverScreen = CoverScreen.is(options.cover) ? options.cover : createCoverScreen(options.cover, this);
|
|
388
|
+
if (options.single) this.singleScreen = SingleScreen.is(options.single) ? options.single : createSingleScreen(options.single, this);
|
|
389
|
+
if (options.double) this.doubleScreen = DoubleScreen.is(options.double) ? options.double : createDoubleScreen(options.double, this);
|
|
390
|
+
}
|
|
391
|
+
getScreen() {
|
|
392
|
+
return this;
|
|
393
|
+
}
|
|
394
|
+
getApiVersion() {
|
|
395
|
+
return this.options.apiVersion;
|
|
396
|
+
}
|
|
397
|
+
getSnakecaseDeviceType() {
|
|
398
|
+
return this.options.deviceType;
|
|
399
|
+
}
|
|
400
|
+
getOuterScreen() {
|
|
401
|
+
return this.outerScreen;
|
|
402
|
+
}
|
|
403
|
+
setOuterScreen(outerScreen) {
|
|
404
|
+
this.outerScreen = OuterScreen.is(outerScreen) ? outerScreen : createOuterScreen(outerScreen, this);
|
|
405
|
+
return this;
|
|
406
|
+
}
|
|
407
|
+
getCoverScreen() {
|
|
408
|
+
return this.coverScreen;
|
|
409
|
+
}
|
|
410
|
+
setCoverScreen(coverScreen) {
|
|
411
|
+
this.coverScreen = CoverScreen.is(coverScreen) ? coverScreen : createCoverScreen(coverScreen, this);
|
|
412
|
+
return this;
|
|
413
|
+
}
|
|
414
|
+
getSingleScreen() {
|
|
415
|
+
return this.singleScreen;
|
|
416
|
+
}
|
|
417
|
+
setSingleScreen(singleScreen) {
|
|
418
|
+
this.singleScreen = SingleScreen.is(singleScreen) ? singleScreen : createSingleScreen(singleScreen, this);
|
|
419
|
+
return this;
|
|
420
|
+
}
|
|
421
|
+
getDoubleScreen() {
|
|
422
|
+
return this.doubleScreen;
|
|
423
|
+
}
|
|
424
|
+
setDoubleScreen(doubleScreen) {
|
|
425
|
+
this.doubleScreen = DoubleScreen.is(doubleScreen) ? doubleScreen : createDoubleScreen(doubleScreen, this);
|
|
426
|
+
return this;
|
|
427
|
+
}
|
|
428
|
+
getDensity() {
|
|
429
|
+
return this.options.density;
|
|
430
|
+
}
|
|
431
|
+
setDensity(density) {
|
|
432
|
+
this.options.density = density;
|
|
433
|
+
return this;
|
|
434
|
+
}
|
|
435
|
+
toJSON() {
|
|
436
|
+
return {
|
|
437
|
+
...super.toJSON(),
|
|
438
|
+
density: this.options.density,
|
|
439
|
+
apiVersion: this.options.apiVersion,
|
|
440
|
+
deviceType: this.options.deviceType,
|
|
441
|
+
outer: this.outerScreen?.toJSON(),
|
|
442
|
+
cover: this.coverScreen?.toJSON(),
|
|
443
|
+
single: this.singleScreen?.toJSON()
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
function createScreen(options) {
|
|
448
|
+
return new ScreenImpl(options);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
//#endregion
|
|
452
|
+
//#region src/screens/screen-preset.ts
|
|
453
|
+
let ScreenPreset;
|
|
454
|
+
(function(_ScreenPreset) {
|
|
455
|
+
function is(value) {
|
|
456
|
+
return value instanceof ScreenPresetImpl;
|
|
457
|
+
}
|
|
458
|
+
_ScreenPreset.is = is;
|
|
459
|
+
})(ScreenPreset || (ScreenPreset = {}));
|
|
460
|
+
var ScreenPresetImpl = class {
|
|
461
|
+
emulatorPreset;
|
|
462
|
+
productPreset;
|
|
463
|
+
constructor(options) {
|
|
464
|
+
this.options = options;
|
|
465
|
+
this._screen = this.getScreen();
|
|
466
|
+
this.setEmulatorPreset();
|
|
467
|
+
this.setProductPreset();
|
|
468
|
+
}
|
|
469
|
+
isScreenOptions(options) {
|
|
470
|
+
return "screen" in options && Screen.is(options.screen);
|
|
471
|
+
}
|
|
472
|
+
_screen;
|
|
473
|
+
getScreen() {
|
|
474
|
+
if (this.isScreenOptions(this.options)) return this.options.screen;
|
|
475
|
+
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];
|
|
499
|
+
else if (pascalCaseDeviceType === "2in1 Foldable" && this.getScreen().getSnakecaseDeviceType() === "2in1_foldable") return [productConfigItem, pascalCaseDeviceType];
|
|
500
|
+
else if (pascalCaseDeviceType === "Foldable" && this.getScreen().getSnakecaseDeviceType() === "foldable") return [productConfigItem, pascalCaseDeviceType];
|
|
501
|
+
else if (pascalCaseDeviceType === "Phone" && this.getScreen().getSnakecaseDeviceType() === "phone") return [productConfigItem, pascalCaseDeviceType];
|
|
502
|
+
else if (pascalCaseDeviceType === "TV" && this.getScreen().getSnakecaseDeviceType() === "tv") return [productConfigItem, pascalCaseDeviceType];
|
|
503
|
+
else if (pascalCaseDeviceType === "Tablet" && this.getScreen().getSnakecaseDeviceType() === "tablet") return [productConfigItem, pascalCaseDeviceType];
|
|
504
|
+
else if (pascalCaseDeviceType === "TripleFold" && this.getScreen().getSnakecaseDeviceType() === "triplefold") return [productConfigItem, pascalCaseDeviceType];
|
|
505
|
+
else if (pascalCaseDeviceType === "Wearable" && this.getScreen().getSnakecaseDeviceType() === "wearable") return [productConfigItem, pascalCaseDeviceType];
|
|
506
|
+
else if (pascalCaseDeviceType === "WideFold" && this.getScreen().getSnakecaseDeviceType() === "widefold") return [productConfigItem, pascalCaseDeviceType];
|
|
507
|
+
else if (pascalCaseDeviceType.toLowerCase() === this.getScreen().getSnakecaseDeviceType().toLowerCase()) return [productConfigItem, pascalCaseDeviceType];
|
|
508
|
+
}
|
|
509
|
+
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;
|
|
527
|
+
}
|
|
528
|
+
this.productPreset = createProductPreset(productConfigItem, pascalCaseDeviceType, this);
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
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);
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
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;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
getEmulatorPreset() {
|
|
556
|
+
return this.emulatorPreset;
|
|
557
|
+
}
|
|
558
|
+
getProductPreset() {
|
|
559
|
+
return this.productPreset;
|
|
560
|
+
}
|
|
561
|
+
toJSON() {
|
|
562
|
+
return {
|
|
563
|
+
emulatorPreset: this.emulatorPreset?.toJSON(),
|
|
564
|
+
productPreset: this.productPreset?.toJSON()
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
function createScreenPreset(options) {
|
|
569
|
+
return new ScreenPresetImpl(options);
|
|
165
570
|
}
|
|
166
571
|
|
|
167
572
|
//#endregion
|
|
@@ -180,9 +585,12 @@ var DeviceImpl = class {
|
|
|
180
585
|
return this.image;
|
|
181
586
|
}
|
|
182
587
|
getScreen() {
|
|
183
|
-
if (this.options.screen instanceof
|
|
588
|
+
if (this.options.screen instanceof ScreenPresetImpl) return this.options.screen.getScreen();
|
|
184
589
|
return this.options.screen;
|
|
185
590
|
}
|
|
591
|
+
getScreenPreset() {
|
|
592
|
+
if (this.options.screen instanceof ScreenPresetImpl) return this.options.screen;
|
|
593
|
+
}
|
|
186
594
|
setUuid(uuid) {
|
|
187
595
|
this.uuid = uuid;
|
|
188
596
|
return this;
|
|
@@ -228,10 +636,10 @@ var DeviceImpl = class {
|
|
|
228
636
|
"harmonyOSVersion": `${this.image.getTargetOS()}-${this.image.getTargetVersion()}`,
|
|
229
637
|
"guestVersion": `${this.image.getTargetOS()} ${this.image.getVersion()}(${this.image.getReleaseType()})`
|
|
230
638
|
};
|
|
231
|
-
if (this.options.screen instanceof
|
|
232
|
-
const productConfig = this.options.screen.getProductConfig();
|
|
233
|
-
if (productConfig
|
|
234
|
-
if (productConfig
|
|
639
|
+
if (this.options.screen instanceof ScreenPresetImpl) {
|
|
640
|
+
const productConfig = this.options.screen.getProductPreset()?.getProductConfig();
|
|
641
|
+
if (productConfig?.devModel) list.devModel = productConfig.devModel;
|
|
642
|
+
if (productConfig?.name) list.model = productConfig.name;
|
|
235
643
|
}
|
|
236
644
|
return list;
|
|
237
645
|
}
|
|
@@ -240,8 +648,8 @@ var DeviceImpl = class {
|
|
|
240
648
|
const listConfig = this.buildList();
|
|
241
649
|
const screen = this.getScreen();
|
|
242
650
|
const is2in1Foldable = listConfig.type === "2in1_foldable";
|
|
243
|
-
const
|
|
244
|
-
const productConfig =
|
|
651
|
+
const screenPreset = this.options.screen instanceof ScreenPresetImpl ? this.options.screen.getProductPreset() : null;
|
|
652
|
+
const productConfig = screenPreset?.getProductConfig();
|
|
245
653
|
const useDualScreen = is2in1Foldable && productConfig?.outerScreenWidth != null && productConfig?.outerScreenHeight != null && productConfig?.outerScreenDiagonal != null;
|
|
246
654
|
const singleDiagonal = useDualScreen ? productConfig.outerScreenDiagonal : screen.getDiagonal().toString();
|
|
247
655
|
const singleHeight = useDualScreen ? productConfig.outerScreenHeight : screen.getHeight().toString();
|
|
@@ -274,7 +682,7 @@ var DeviceImpl = class {
|
|
|
274
682
|
"hw.lcd.number": useDualScreen ? "2" : "1",
|
|
275
683
|
"hw.ramSize": listConfig.memoryRamSize,
|
|
276
684
|
"hw.dataPartitionSize": listConfig.dataDiskSize,
|
|
277
|
-
"isCustomize":
|
|
685
|
+
"isCustomize": screenPreset ? "false" : "true",
|
|
278
686
|
"hw.hdc.port": "notset",
|
|
279
687
|
...options.overrides
|
|
280
688
|
};
|
|
@@ -283,7 +691,7 @@ var DeviceImpl = class {
|
|
|
283
691
|
ini["hw.lcd.double.height"] = doubleHeight;
|
|
284
692
|
ini["hw.lcd.double.width"] = doubleWidth;
|
|
285
693
|
}
|
|
286
|
-
if (
|
|
694
|
+
if (screenPreset && productConfig && !useDualScreen) {
|
|
287
695
|
if (productConfig.outerScreenHeight) ini["hw.phy.height"] = productConfig.outerScreenHeight;
|
|
288
696
|
if (productConfig.outerScreenWidth) ini["hw.phy.width"] = productConfig.outerScreenWidth;
|
|
289
697
|
}
|
|
@@ -440,11 +848,12 @@ var ImageDownloaderImpl = class {
|
|
|
440
848
|
return hash.digest("hex") === checksum;
|
|
441
849
|
}
|
|
442
850
|
async extract(signal, symlinkOpenHarmonySdk = true) {
|
|
851
|
+
const unzipper = await import("unzipper");
|
|
443
852
|
const { fs, path, imageBasePath, sdkPath } = this.image.getImageManager().getOptions();
|
|
444
853
|
const cacheFsPath = this.getCacheFsPath();
|
|
445
854
|
const stream = fs.createReadStream(cacheFsPath, { signal });
|
|
446
855
|
const progressStream = (0, progress_stream.default)({ length: fs.statSync(cacheFsPath).size });
|
|
447
|
-
const extractStream = unzipper.
|
|
856
|
+
const extractStream = unzipper.Extract({ path: this.image.getFsPath() });
|
|
448
857
|
progressStream.on("progress", (progress) => this.emitter.emit("extract-progress", progress));
|
|
449
858
|
stream.pipe(progressStream).pipe(extractStream);
|
|
450
859
|
await extractStream.promise();
|
|
@@ -655,21 +1064,41 @@ var LocalImageImpl = class extends ImageBase {
|
|
|
655
1064
|
return child_process.exec(await this.buildStopCommand(device), { cwd: emulatorPath });
|
|
656
1065
|
}
|
|
657
1066
|
async createScreenLike(listsJsonItem) {
|
|
658
|
-
|
|
659
|
-
diagonal: Number(listsJsonItem.diagonalSize),
|
|
660
|
-
height: Number(listsJsonItem.resolutionHeight),
|
|
661
|
-
width: Number(listsJsonItem.resolutionWidth),
|
|
662
|
-
density: Number(listsJsonItem.density)
|
|
663
|
-
});
|
|
664
|
-
const productConfigItem = (await this.getProductConfig()).find((item) => item.name === listsJsonItem.model);
|
|
1067
|
+
const productConfig = await this.getImageManager().getProductConfig();
|
|
665
1068
|
const pascalCaseDeviceType = await this.getPascalCaseDeviceType();
|
|
666
|
-
|
|
1069
|
+
const screen = createScreen({
|
|
667
1070
|
diagonal: Number(listsJsonItem.diagonalSize),
|
|
668
1071
|
height: Number(listsJsonItem.resolutionHeight),
|
|
669
1072
|
width: Number(listsJsonItem.resolutionWidth),
|
|
670
|
-
density: Number(listsJsonItem.density)
|
|
1073
|
+
density: Number(listsJsonItem.density),
|
|
1074
|
+
deviceType: listsJsonItem.type,
|
|
1075
|
+
apiVersion: Number(listsJsonItem.apiVersion),
|
|
1076
|
+
cover: listsJsonItem.coverResolutionWidth && listsJsonItem.coverResolutionHeight && listsJsonItem.coverDiagonalSize ? {
|
|
1077
|
+
height: Number(listsJsonItem.coverResolutionHeight),
|
|
1078
|
+
width: Number(listsJsonItem.coverResolutionWidth),
|
|
1079
|
+
diagonal: Number(listsJsonItem.coverDiagonalSize)
|
|
1080
|
+
} : void 0
|
|
1081
|
+
});
|
|
1082
|
+
if (pascalCaseDeviceType) {
|
|
1083
|
+
const productConfigItem = productConfig[pascalCaseDeviceType]?.find((item) => item.name === listsJsonItem.model);
|
|
1084
|
+
if (productConfigItem && productConfigItem.outerScreenWidth && productConfigItem.outerScreenHeight && productConfigItem.outerScreenDiagonal) screen.setOuterScreen(createOuterScreen({
|
|
1085
|
+
width: Number(productConfigItem.outerScreenWidth),
|
|
1086
|
+
height: Number(productConfigItem.outerScreenHeight),
|
|
1087
|
+
diagonal: Number(productConfigItem.outerScreenDiagonal)
|
|
1088
|
+
}, screen));
|
|
1089
|
+
if (productConfigItem && productConfigItem.outerDoubleScreenWidth && productConfigItem.outerDoubleScreenHeight && productConfigItem.outerDoubleScreenDiagonal) screen.getOuterScreen()?.setOuterDoubleScreen(createOuterDoubleScreen({
|
|
1090
|
+
width: Number(productConfigItem.outerDoubleScreenWidth),
|
|
1091
|
+
height: Number(productConfigItem.outerDoubleScreenHeight),
|
|
1092
|
+
diagonal: Number(productConfigItem.outerDoubleScreenDiagonal)
|
|
1093
|
+
}, screen.getOuterScreen()));
|
|
1094
|
+
}
|
|
1095
|
+
const screenPreset = createScreenPreset({
|
|
1096
|
+
screen,
|
|
1097
|
+
productConfig,
|
|
1098
|
+
emulatorConfig: await this.getImageManager().getEmulatorConfig()
|
|
671
1099
|
});
|
|
672
|
-
|
|
1100
|
+
if (screenPreset.getProductPreset() || screenPreset.getEmulatorPreset()) return screenPreset;
|
|
1101
|
+
else return screen;
|
|
673
1102
|
}
|
|
674
1103
|
async getDevices() {
|
|
675
1104
|
const { path, fs, deployedPath, imageBasePath } = this.getImageManager().getOptions();
|
|
@@ -818,6 +1247,11 @@ var ImageManagerImpl = class {
|
|
|
818
1247
|
if (!this.resolvedOptions.fs.existsSync(productConfigPath) || !this.resolvedOptions.fs.statSync(productConfigPath).isFile()) return (await Promise.resolve().then(() => require("./default-product-config.cjs"))).default;
|
|
819
1248
|
return JSON.parse(this.resolvedOptions.fs.readFileSync(productConfigPath, "utf-8"));
|
|
820
1249
|
}
|
|
1250
|
+
async getEmulatorConfig() {
|
|
1251
|
+
const emulatorConfigPath = this.resolvedOptions.path.resolve(this.resolvedOptions.emulatorPath, "emulator.json");
|
|
1252
|
+
if (!this.resolvedOptions.fs.existsSync(emulatorConfigPath) || !this.resolvedOptions.fs.statSync(emulatorConfigPath).isFile()) return (await Promise.resolve().then(() => require("./default-emulator-config.cjs"))).default;
|
|
1253
|
+
return JSON.parse(this.resolvedOptions.fs.readFileSync(emulatorConfigPath, "utf-8"));
|
|
1254
|
+
}
|
|
821
1255
|
async writeDefaultProductConfig(existSkip = false) {
|
|
822
1256
|
const productConfigPath = this.resolvedOptions.path.resolve(this.resolvedOptions.imageBasePath, "productConfig.json");
|
|
823
1257
|
if (existSkip && this.resolvedOptions.fs.existsSync(productConfigPath)) return;
|
|
@@ -838,6 +1272,12 @@ async function createImageManager(options = {}) {
|
|
|
838
1272
|
}
|
|
839
1273
|
|
|
840
1274
|
//#endregion
|
|
1275
|
+
Object.defineProperty(exports, 'BaseEmulatorConfigItem', {
|
|
1276
|
+
enumerable: true,
|
|
1277
|
+
get: function () {
|
|
1278
|
+
return BaseEmulatorConfigItem;
|
|
1279
|
+
}
|
|
1280
|
+
});
|
|
841
1281
|
Object.defineProperty(exports, 'DeployError', {
|
|
842
1282
|
enumerable: true,
|
|
843
1283
|
get: function () {
|
|
@@ -845,10 +1285,45 @@ Object.defineProperty(exports, 'DeployError', {
|
|
|
845
1285
|
}
|
|
846
1286
|
});
|
|
847
1287
|
exports.DevModel = DevModel;
|
|
1288
|
+
Object.defineProperty(exports, 'GroupPCAllEmulatorConfigItem', {
|
|
1289
|
+
enumerable: true,
|
|
1290
|
+
get: function () {
|
|
1291
|
+
return GroupPCAllEmulatorConfigItem;
|
|
1292
|
+
}
|
|
1293
|
+
});
|
|
1294
|
+
Object.defineProperty(exports, 'GroupPhoneAllEmulatorConfigItem', {
|
|
1295
|
+
enumerable: true,
|
|
1296
|
+
get: function () {
|
|
1297
|
+
return GroupPhoneAllEmulatorConfigItem;
|
|
1298
|
+
}
|
|
1299
|
+
});
|
|
1300
|
+
Object.defineProperty(exports, 'PCAllEmulatorConfigItem', {
|
|
1301
|
+
enumerable: true,
|
|
1302
|
+
get: function () {
|
|
1303
|
+
return PCAllEmulatorConfigItem;
|
|
1304
|
+
}
|
|
1305
|
+
});
|
|
1306
|
+
Object.defineProperty(exports, 'ParentEmulatorConfigItem', {
|
|
1307
|
+
enumerable: true,
|
|
1308
|
+
get: function () {
|
|
1309
|
+
return ParentEmulatorConfigItem;
|
|
1310
|
+
}
|
|
1311
|
+
});
|
|
1312
|
+
Object.defineProperty(exports, 'PhoneAllEmulatorConfigItem', {
|
|
1313
|
+
enumerable: true,
|
|
1314
|
+
get: function () {
|
|
1315
|
+
return PhoneAllEmulatorConfigItem;
|
|
1316
|
+
}
|
|
1317
|
+
});
|
|
848
1318
|
exports.RequestUrlError = RequestUrlError;
|
|
1319
|
+
exports.createCoverScreen = createCoverScreen;
|
|
1320
|
+
exports.createDoubleScreen = createDoubleScreen;
|
|
849
1321
|
exports.createImageManager = createImageManager;
|
|
850
|
-
exports.
|
|
1322
|
+
exports.createOuterDoubleScreen = createOuterDoubleScreen;
|
|
1323
|
+
exports.createOuterScreen = createOuterScreen;
|
|
851
1324
|
exports.createScreen = createScreen;
|
|
1325
|
+
exports.createScreenPreset = createScreenPreset;
|
|
1326
|
+
exports.createSingleScreen = createSingleScreen;
|
|
852
1327
|
Object.defineProperty(exports, 'version', {
|
|
853
1328
|
enumerable: true,
|
|
854
1329
|
get: function () {
|