@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.mjs
CHANGED
|
@@ -3,10 +3,9 @@ import satisfies from "semver/functions/satisfies";
|
|
|
3
3
|
import INI from "ini";
|
|
4
4
|
import mitt from "mitt";
|
|
5
5
|
import progress from "progress-stream";
|
|
6
|
-
import unzipper from "unzipper";
|
|
7
6
|
|
|
8
7
|
//#region package.json
|
|
9
|
-
var version = "0.
|
|
8
|
+
var version = "0.4.1";
|
|
10
9
|
|
|
11
10
|
//#endregion
|
|
12
11
|
//#region src/devices/list.ts
|
|
@@ -21,6 +20,51 @@ let DevModel = /* @__PURE__ */ function(DevModel) {
|
|
|
21
20
|
return DevModel;
|
|
22
21
|
}({});
|
|
23
22
|
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/emulator-config.ts
|
|
25
|
+
let BaseEmulatorConfigItem;
|
|
26
|
+
(function(_BaseEmulatorConfigItem) {
|
|
27
|
+
function is(value) {
|
|
28
|
+
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";
|
|
29
|
+
}
|
|
30
|
+
_BaseEmulatorConfigItem.is = is;
|
|
31
|
+
})(BaseEmulatorConfigItem || (BaseEmulatorConfigItem = {}));
|
|
32
|
+
let ParentEmulatorConfigItem;
|
|
33
|
+
(function(_ParentEmulatorConfigItem) {
|
|
34
|
+
function is(value) {
|
|
35
|
+
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";
|
|
36
|
+
}
|
|
37
|
+
_ParentEmulatorConfigItem.is = is;
|
|
38
|
+
})(ParentEmulatorConfigItem || (ParentEmulatorConfigItem = {}));
|
|
39
|
+
let PhoneAllEmulatorConfigItem;
|
|
40
|
+
(function(_PhoneAllEmulatorConfigItem) {
|
|
41
|
+
function is(value) {
|
|
42
|
+
return ParentEmulatorConfigItem.is(value);
|
|
43
|
+
}
|
|
44
|
+
_PhoneAllEmulatorConfigItem.is = is;
|
|
45
|
+
})(PhoneAllEmulatorConfigItem || (PhoneAllEmulatorConfigItem = {}));
|
|
46
|
+
let GroupPhoneAllEmulatorConfigItem;
|
|
47
|
+
(function(_GroupPhoneAllEmulatorConfigItem) {
|
|
48
|
+
function is(value) {
|
|
49
|
+
return BaseEmulatorConfigItem.is(value) && "children" in value && Array.isArray(value.children) && value.children.every(PhoneAllEmulatorConfigItem.is);
|
|
50
|
+
}
|
|
51
|
+
_GroupPhoneAllEmulatorConfigItem.is = is;
|
|
52
|
+
})(GroupPhoneAllEmulatorConfigItem || (GroupPhoneAllEmulatorConfigItem = {}));
|
|
53
|
+
let PCAllEmulatorConfigItem;
|
|
54
|
+
(function(_PCAllEmulatorConfigItem) {
|
|
55
|
+
function is(value) {
|
|
56
|
+
return ParentEmulatorConfigItem.is(value);
|
|
57
|
+
}
|
|
58
|
+
_PCAllEmulatorConfigItem.is = is;
|
|
59
|
+
})(PCAllEmulatorConfigItem || (PCAllEmulatorConfigItem = {}));
|
|
60
|
+
let GroupPCAllEmulatorConfigItem;
|
|
61
|
+
(function(_GroupPCAllEmulatorConfigItem) {
|
|
62
|
+
function is(value) {
|
|
63
|
+
return BaseEmulatorConfigItem.is(value) && "children" in value && Array.isArray(value.children) && value.children.every(PCAllEmulatorConfigItem.is);
|
|
64
|
+
}
|
|
65
|
+
_GroupPCAllEmulatorConfigItem.is = is;
|
|
66
|
+
})(GroupPCAllEmulatorConfigItem || (GroupPCAllEmulatorConfigItem = {}));
|
|
67
|
+
|
|
24
68
|
//#endregion
|
|
25
69
|
//#region src/errors/deploy-error.ts
|
|
26
70
|
var DeployError = class extends Error {
|
|
@@ -57,23 +101,59 @@ var RequestUrlError = class extends Error {
|
|
|
57
101
|
};
|
|
58
102
|
|
|
59
103
|
//#endregion
|
|
60
|
-
//#region src/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
104
|
+
//#region src/product-config.ts
|
|
105
|
+
let ProductConfigItem;
|
|
106
|
+
(function(_ProductConfigItem) {
|
|
107
|
+
function is(value) {
|
|
108
|
+
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";
|
|
109
|
+
}
|
|
110
|
+
_ProductConfigItem.is = is;
|
|
111
|
+
})(ProductConfigItem || (ProductConfigItem = {}));
|
|
112
|
+
function isProductConfig(value) {
|
|
113
|
+
return typeof value === "object" && value !== null && Object.values(value).every((item) => Array.isArray(item));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/types.ts
|
|
118
|
+
function isPhoneAllSnakecaseDeviceType(value) {
|
|
119
|
+
return value === "phone" || value === "triplefold" || value === "widefold" || value === "foldable";
|
|
120
|
+
}
|
|
121
|
+
function isPCAllSnakecaseDeviceType(value) {
|
|
122
|
+
return value === "2in1_foldable" || value === "2in1";
|
|
123
|
+
}
|
|
124
|
+
|
|
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;
|
|
64
131
|
}
|
|
65
|
-
|
|
66
|
-
return this.
|
|
132
|
+
getScreenPreset() {
|
|
133
|
+
return this.screenPreset;
|
|
67
134
|
}
|
|
68
|
-
|
|
69
|
-
this.
|
|
70
|
-
return this;
|
|
135
|
+
getEmulatorConfig() {
|
|
136
|
+
return this.emulatorConfigItem;
|
|
71
137
|
}
|
|
72
|
-
|
|
73
|
-
return this.
|
|
138
|
+
toJSON() {
|
|
139
|
+
return { emulatorConfig: this.emulatorConfigItem };
|
|
74
140
|
}
|
|
75
|
-
|
|
76
|
-
|
|
141
|
+
};
|
|
142
|
+
function createEmulatorPreset(emulatorConfigItem, screenPreset) {
|
|
143
|
+
return new EmulatorPresetImpl(emulatorConfigItem, screenPreset);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/screens/base-screen.ts
|
|
148
|
+
var BaseScreenImpl = class {
|
|
149
|
+
constructor(options) {
|
|
150
|
+
this.options = options;
|
|
151
|
+
}
|
|
152
|
+
getWidth() {
|
|
153
|
+
return this.options.width;
|
|
154
|
+
}
|
|
155
|
+
setWidth(width) {
|
|
156
|
+
this.options.width = width;
|
|
77
157
|
return this;
|
|
78
158
|
}
|
|
79
159
|
getHeight() {
|
|
@@ -83,27 +163,86 @@ var ScreenImpl = class {
|
|
|
83
163
|
this.options.height = height;
|
|
84
164
|
return this;
|
|
85
165
|
}
|
|
86
|
-
|
|
87
|
-
return this.options.
|
|
166
|
+
getDiagonal() {
|
|
167
|
+
return this.options.diagonal;
|
|
88
168
|
}
|
|
89
|
-
|
|
90
|
-
this.options.
|
|
169
|
+
setDiagonal(diagonal) {
|
|
170
|
+
this.options.diagonal = diagonal;
|
|
91
171
|
return this;
|
|
92
172
|
}
|
|
93
173
|
toJSON() {
|
|
94
174
|
return this.options;
|
|
95
175
|
}
|
|
96
176
|
};
|
|
97
|
-
|
|
98
|
-
|
|
177
|
+
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/screens/outer-screen.ts
|
|
180
|
+
let OuterScreen;
|
|
181
|
+
(function(_OuterScreen) {
|
|
182
|
+
function is(value) {
|
|
183
|
+
return value instanceof OuterScreenImpl;
|
|
184
|
+
}
|
|
185
|
+
_OuterScreen.is = is;
|
|
186
|
+
})(OuterScreen || (OuterScreen = {}));
|
|
187
|
+
var OuterScreenImpl = class extends BaseScreenImpl {
|
|
188
|
+
outerDoubleScreen;
|
|
189
|
+
constructor(options, screen) {
|
|
190
|
+
super(options);
|
|
191
|
+
this.options = options;
|
|
192
|
+
this.screen = screen;
|
|
193
|
+
if (options.double) this.outerDoubleScreen = OuterDoubleScreen.is(options.double) ? options.double : createOuterDoubleScreen(options.double, this);
|
|
194
|
+
}
|
|
195
|
+
getScreen() {
|
|
196
|
+
return this.screen;
|
|
197
|
+
}
|
|
198
|
+
getOuterDoubleScreen() {
|
|
199
|
+
return this.outerDoubleScreen;
|
|
200
|
+
}
|
|
201
|
+
setOuterDoubleScreen(outerDoubleScreen) {
|
|
202
|
+
this.outerDoubleScreen = OuterDoubleScreen.is(outerDoubleScreen) ? outerDoubleScreen : createOuterDoubleScreen(outerDoubleScreen, this);
|
|
203
|
+
return this;
|
|
204
|
+
}
|
|
205
|
+
toJSON() {
|
|
206
|
+
return {
|
|
207
|
+
...super.toJSON(),
|
|
208
|
+
double: this.outerDoubleScreen?.toJSON()
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
function createOuterScreen(options, screen) {
|
|
213
|
+
return new OuterScreenImpl(options, screen);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region src/screens/outer-double-screen.ts
|
|
218
|
+
let OuterDoubleScreen;
|
|
219
|
+
(function(_OuterDoubleScreen) {
|
|
220
|
+
function is(value) {
|
|
221
|
+
return value instanceof OuterDoubleScreenImpl;
|
|
222
|
+
}
|
|
223
|
+
_OuterDoubleScreen.is = is;
|
|
224
|
+
})(OuterDoubleScreen || (OuterDoubleScreen = {}));
|
|
225
|
+
var OuterDoubleScreenImpl = class extends OuterScreenImpl {
|
|
226
|
+
constructor(options, outerScreen) {
|
|
227
|
+
super(options, outerScreen.getScreen());
|
|
228
|
+
this.options = options;
|
|
229
|
+
this.outerScreen = outerScreen;
|
|
230
|
+
}
|
|
231
|
+
getOuterScreen() {
|
|
232
|
+
return this.outerScreen;
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
function createOuterDoubleScreen(options, outerScreen) {
|
|
236
|
+
return new OuterDoubleScreenImpl(options, outerScreen);
|
|
99
237
|
}
|
|
100
238
|
|
|
101
239
|
//#endregion
|
|
102
240
|
//#region src/screens/product-preset.ts
|
|
103
241
|
var ProductPresetImpl = class {
|
|
104
|
-
constructor(productConfig, deviceType) {
|
|
242
|
+
constructor(productConfig, deviceType, screenPreset) {
|
|
105
243
|
this.productConfig = productConfig;
|
|
106
244
|
this.deviceType = deviceType;
|
|
245
|
+
this.screenPreset = screenPreset;
|
|
107
246
|
}
|
|
108
247
|
getProductConfig() {
|
|
109
248
|
return this.productConfig;
|
|
@@ -111,13 +250,8 @@ var ProductPresetImpl = class {
|
|
|
111
250
|
getDeviceType() {
|
|
112
251
|
return this.deviceType;
|
|
113
252
|
}
|
|
114
|
-
|
|
115
|
-
return
|
|
116
|
-
diagonal: Number(this.productConfig.screenDiagonal),
|
|
117
|
-
density: Number(this.productConfig.screenDensity),
|
|
118
|
-
height: Number(this.productConfig.screenHeight),
|
|
119
|
-
width: Number(this.productConfig.screenWidth)
|
|
120
|
-
});
|
|
253
|
+
getScreenPreset() {
|
|
254
|
+
return this.screenPreset;
|
|
121
255
|
}
|
|
122
256
|
toJSON() {
|
|
123
257
|
return {
|
|
@@ -126,8 +260,280 @@ var ProductPresetImpl = class {
|
|
|
126
260
|
};
|
|
127
261
|
}
|
|
128
262
|
};
|
|
129
|
-
|
|
130
|
-
return new ProductPresetImpl(productConfig, deviceType);
|
|
263
|
+
function createProductPreset(productConfig, deviceType, screenPreset) {
|
|
264
|
+
return new ProductPresetImpl(productConfig, deviceType, screenPreset);
|
|
265
|
+
}
|
|
266
|
+
|
|
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
|
+
//#endregion
|
|
314
|
+
//#region src/screens/single-screen.ts
|
|
315
|
+
let SingleScreen;
|
|
316
|
+
(function(_SingleScreen) {
|
|
317
|
+
function is(value) {
|
|
318
|
+
return value instanceof SingleScreenImpl;
|
|
319
|
+
}
|
|
320
|
+
_SingleScreen.is = is;
|
|
321
|
+
})(SingleScreen || (SingleScreen = {}));
|
|
322
|
+
var SingleScreenImpl = class extends BaseScreenImpl {
|
|
323
|
+
constructor(options, screen) {
|
|
324
|
+
super(options);
|
|
325
|
+
this.options = options;
|
|
326
|
+
this.screen = screen;
|
|
327
|
+
}
|
|
328
|
+
getScreen() {
|
|
329
|
+
return this.screen;
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
function createSingleScreen(options, screen) {
|
|
333
|
+
return new SingleScreenImpl(options, screen);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region src/screens/screen.ts
|
|
338
|
+
let Screen;
|
|
339
|
+
(function(_Screen) {
|
|
340
|
+
function is(value) {
|
|
341
|
+
return value instanceof ScreenImpl;
|
|
342
|
+
}
|
|
343
|
+
_Screen.is = is;
|
|
344
|
+
})(Screen || (Screen = {}));
|
|
345
|
+
var ScreenImpl = class extends BaseScreenImpl {
|
|
346
|
+
outerScreen;
|
|
347
|
+
coverScreen;
|
|
348
|
+
singleScreen;
|
|
349
|
+
doubleScreen;
|
|
350
|
+
constructor(options) {
|
|
351
|
+
super(options);
|
|
352
|
+
this.options = options;
|
|
353
|
+
if (options.outer) this.outerScreen = OuterScreen.is(options.outer) ? options.outer : createOuterScreen(options.outer, this);
|
|
354
|
+
if (options.cover) this.coverScreen = CoverScreen.is(options.cover) ? options.cover : createCoverScreen(options.cover, this);
|
|
355
|
+
if (options.single) this.singleScreen = SingleScreen.is(options.single) ? options.single : createSingleScreen(options.single, this);
|
|
356
|
+
if (options.double) this.doubleScreen = DoubleScreen.is(options.double) ? options.double : createDoubleScreen(options.double, this);
|
|
357
|
+
}
|
|
358
|
+
getScreen() {
|
|
359
|
+
return this;
|
|
360
|
+
}
|
|
361
|
+
getApiVersion() {
|
|
362
|
+
return this.options.apiVersion;
|
|
363
|
+
}
|
|
364
|
+
getSnakecaseDeviceType() {
|
|
365
|
+
return this.options.deviceType;
|
|
366
|
+
}
|
|
367
|
+
getOuterScreen() {
|
|
368
|
+
return this.outerScreen;
|
|
369
|
+
}
|
|
370
|
+
setOuterScreen(outerScreen) {
|
|
371
|
+
this.outerScreen = OuterScreen.is(outerScreen) ? outerScreen : createOuterScreen(outerScreen, this);
|
|
372
|
+
return this;
|
|
373
|
+
}
|
|
374
|
+
getCoverScreen() {
|
|
375
|
+
return this.coverScreen;
|
|
376
|
+
}
|
|
377
|
+
setCoverScreen(coverScreen) {
|
|
378
|
+
this.coverScreen = CoverScreen.is(coverScreen) ? coverScreen : createCoverScreen(coverScreen, this);
|
|
379
|
+
return this;
|
|
380
|
+
}
|
|
381
|
+
getSingleScreen() {
|
|
382
|
+
return this.singleScreen;
|
|
383
|
+
}
|
|
384
|
+
setSingleScreen(singleScreen) {
|
|
385
|
+
this.singleScreen = SingleScreen.is(singleScreen) ? singleScreen : createSingleScreen(singleScreen, this);
|
|
386
|
+
return this;
|
|
387
|
+
}
|
|
388
|
+
getDoubleScreen() {
|
|
389
|
+
return this.doubleScreen;
|
|
390
|
+
}
|
|
391
|
+
setDoubleScreen(doubleScreen) {
|
|
392
|
+
this.doubleScreen = DoubleScreen.is(doubleScreen) ? doubleScreen : createDoubleScreen(doubleScreen, this);
|
|
393
|
+
return this;
|
|
394
|
+
}
|
|
395
|
+
getDensity() {
|
|
396
|
+
return this.options.density;
|
|
397
|
+
}
|
|
398
|
+
setDensity(density) {
|
|
399
|
+
this.options.density = density;
|
|
400
|
+
return this;
|
|
401
|
+
}
|
|
402
|
+
toJSON() {
|
|
403
|
+
return {
|
|
404
|
+
...super.toJSON(),
|
|
405
|
+
density: this.options.density,
|
|
406
|
+
apiVersion: this.options.apiVersion,
|
|
407
|
+
deviceType: this.options.deviceType,
|
|
408
|
+
outer: this.outerScreen?.toJSON(),
|
|
409
|
+
cover: this.coverScreen?.toJSON(),
|
|
410
|
+
single: this.singleScreen?.toJSON()
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
function createScreen(options) {
|
|
415
|
+
return new ScreenImpl(options);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
//#endregion
|
|
419
|
+
//#region src/screens/screen-preset.ts
|
|
420
|
+
let ScreenPreset;
|
|
421
|
+
(function(_ScreenPreset) {
|
|
422
|
+
function is(value) {
|
|
423
|
+
return value instanceof ScreenPresetImpl;
|
|
424
|
+
}
|
|
425
|
+
_ScreenPreset.is = is;
|
|
426
|
+
})(ScreenPreset || (ScreenPreset = {}));
|
|
427
|
+
var ScreenPresetImpl = class {
|
|
428
|
+
emulatorPreset;
|
|
429
|
+
productPreset;
|
|
430
|
+
constructor(options) {
|
|
431
|
+
this.options = options;
|
|
432
|
+
this._screen = this.getScreen();
|
|
433
|
+
this.setEmulatorPreset();
|
|
434
|
+
this.setProductPreset();
|
|
435
|
+
}
|
|
436
|
+
isScreenOptions(options) {
|
|
437
|
+
return "screen" in options && Screen.is(options.screen);
|
|
438
|
+
}
|
|
439
|
+
_screen;
|
|
440
|
+
getScreen() {
|
|
441
|
+
if (this.isScreenOptions(this.options)) return this.options.screen;
|
|
442
|
+
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];
|
|
466
|
+
else if (pascalCaseDeviceType === "2in1 Foldable" && this.getScreen().getSnakecaseDeviceType() === "2in1_foldable") return [productConfigItem, pascalCaseDeviceType];
|
|
467
|
+
else if (pascalCaseDeviceType === "Foldable" && this.getScreen().getSnakecaseDeviceType() === "foldable") return [productConfigItem, pascalCaseDeviceType];
|
|
468
|
+
else if (pascalCaseDeviceType === "Phone" && this.getScreen().getSnakecaseDeviceType() === "phone") return [productConfigItem, pascalCaseDeviceType];
|
|
469
|
+
else if (pascalCaseDeviceType === "TV" && this.getScreen().getSnakecaseDeviceType() === "tv") return [productConfigItem, pascalCaseDeviceType];
|
|
470
|
+
else if (pascalCaseDeviceType === "Tablet" && this.getScreen().getSnakecaseDeviceType() === "tablet") return [productConfigItem, pascalCaseDeviceType];
|
|
471
|
+
else if (pascalCaseDeviceType === "TripleFold" && this.getScreen().getSnakecaseDeviceType() === "triplefold") return [productConfigItem, pascalCaseDeviceType];
|
|
472
|
+
else if (pascalCaseDeviceType === "Wearable" && this.getScreen().getSnakecaseDeviceType() === "wearable") return [productConfigItem, pascalCaseDeviceType];
|
|
473
|
+
else if (pascalCaseDeviceType === "WideFold" && this.getScreen().getSnakecaseDeviceType() === "widefold") return [productConfigItem, pascalCaseDeviceType];
|
|
474
|
+
else if (pascalCaseDeviceType.toLowerCase() === this.getScreen().getSnakecaseDeviceType().toLowerCase()) return [productConfigItem, pascalCaseDeviceType];
|
|
475
|
+
}
|
|
476
|
+
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;
|
|
494
|
+
}
|
|
495
|
+
this.productPreset = createProductPreset(productConfigItem, pascalCaseDeviceType, this);
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
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);
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
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;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
getEmulatorPreset() {
|
|
523
|
+
return this.emulatorPreset;
|
|
524
|
+
}
|
|
525
|
+
getProductPreset() {
|
|
526
|
+
return this.productPreset;
|
|
527
|
+
}
|
|
528
|
+
toJSON() {
|
|
529
|
+
return {
|
|
530
|
+
emulatorPreset: this.emulatorPreset?.toJSON(),
|
|
531
|
+
productPreset: this.productPreset?.toJSON()
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
function createScreenPreset(options) {
|
|
536
|
+
return new ScreenPresetImpl(options);
|
|
131
537
|
}
|
|
132
538
|
|
|
133
539
|
//#endregion
|
|
@@ -146,9 +552,12 @@ var DeviceImpl = class {
|
|
|
146
552
|
return this.image;
|
|
147
553
|
}
|
|
148
554
|
getScreen() {
|
|
149
|
-
if (this.options.screen instanceof
|
|
555
|
+
if (this.options.screen instanceof ScreenPresetImpl) return this.options.screen.getScreen();
|
|
150
556
|
return this.options.screen;
|
|
151
557
|
}
|
|
558
|
+
getScreenPreset() {
|
|
559
|
+
if (this.options.screen instanceof ScreenPresetImpl) return this.options.screen;
|
|
560
|
+
}
|
|
152
561
|
setUuid(uuid) {
|
|
153
562
|
this.uuid = uuid;
|
|
154
563
|
return this;
|
|
@@ -194,10 +603,10 @@ var DeviceImpl = class {
|
|
|
194
603
|
"harmonyOSVersion": `${this.image.getTargetOS()}-${this.image.getTargetVersion()}`,
|
|
195
604
|
"guestVersion": `${this.image.getTargetOS()} ${this.image.getVersion()}(${this.image.getReleaseType()})`
|
|
196
605
|
};
|
|
197
|
-
if (this.options.screen instanceof
|
|
198
|
-
const productConfig = this.options.screen.getProductConfig();
|
|
199
|
-
if (productConfig
|
|
200
|
-
if (productConfig
|
|
606
|
+
if (this.options.screen instanceof ScreenPresetImpl) {
|
|
607
|
+
const productConfig = this.options.screen.getProductPreset()?.getProductConfig();
|
|
608
|
+
if (productConfig?.devModel) list.devModel = productConfig.devModel;
|
|
609
|
+
if (productConfig?.name) list.model = productConfig.name;
|
|
201
610
|
}
|
|
202
611
|
return list;
|
|
203
612
|
}
|
|
@@ -206,8 +615,8 @@ var DeviceImpl = class {
|
|
|
206
615
|
const listConfig = this.buildList();
|
|
207
616
|
const screen = this.getScreen();
|
|
208
617
|
const is2in1Foldable = listConfig.type === "2in1_foldable";
|
|
209
|
-
const
|
|
210
|
-
const productConfig =
|
|
618
|
+
const screenPreset = this.options.screen instanceof ScreenPresetImpl ? this.options.screen.getProductPreset() : null;
|
|
619
|
+
const productConfig = screenPreset?.getProductConfig();
|
|
211
620
|
const useDualScreen = is2in1Foldable && productConfig?.outerScreenWidth != null && productConfig?.outerScreenHeight != null && productConfig?.outerScreenDiagonal != null;
|
|
212
621
|
const singleDiagonal = useDualScreen ? productConfig.outerScreenDiagonal : screen.getDiagonal().toString();
|
|
213
622
|
const singleHeight = useDualScreen ? productConfig.outerScreenHeight : screen.getHeight().toString();
|
|
@@ -240,7 +649,7 @@ var DeviceImpl = class {
|
|
|
240
649
|
"hw.lcd.number": useDualScreen ? "2" : "1",
|
|
241
650
|
"hw.ramSize": listConfig.memoryRamSize,
|
|
242
651
|
"hw.dataPartitionSize": listConfig.dataDiskSize,
|
|
243
|
-
"isCustomize":
|
|
652
|
+
"isCustomize": screenPreset ? "false" : "true",
|
|
244
653
|
"hw.hdc.port": "notset",
|
|
245
654
|
...options.overrides
|
|
246
655
|
};
|
|
@@ -249,7 +658,7 @@ var DeviceImpl = class {
|
|
|
249
658
|
ini["hw.lcd.double.height"] = doubleHeight;
|
|
250
659
|
ini["hw.lcd.double.width"] = doubleWidth;
|
|
251
660
|
}
|
|
252
|
-
if (
|
|
661
|
+
if (screenPreset && productConfig && !useDualScreen) {
|
|
253
662
|
if (productConfig.outerScreenHeight) ini["hw.phy.height"] = productConfig.outerScreenHeight;
|
|
254
663
|
if (productConfig.outerScreenWidth) ini["hw.phy.width"] = productConfig.outerScreenWidth;
|
|
255
664
|
}
|
|
@@ -406,6 +815,7 @@ var ImageDownloaderImpl = class {
|
|
|
406
815
|
return hash.digest("hex") === checksum;
|
|
407
816
|
}
|
|
408
817
|
async extract(signal, symlinkOpenHarmonySdk = true) {
|
|
818
|
+
const unzipper = await import("unzipper");
|
|
409
819
|
const { fs, path, imageBasePath, sdkPath } = this.image.getImageManager().getOptions();
|
|
410
820
|
const cacheFsPath = this.getCacheFsPath();
|
|
411
821
|
const stream = fs.createReadStream(cacheFsPath, { signal });
|
|
@@ -621,21 +1031,41 @@ var LocalImageImpl = class extends ImageBase {
|
|
|
621
1031
|
return child_process.exec(await this.buildStopCommand(device), { cwd: emulatorPath });
|
|
622
1032
|
}
|
|
623
1033
|
async createScreenLike(listsJsonItem) {
|
|
624
|
-
|
|
625
|
-
diagonal: Number(listsJsonItem.diagonalSize),
|
|
626
|
-
height: Number(listsJsonItem.resolutionHeight),
|
|
627
|
-
width: Number(listsJsonItem.resolutionWidth),
|
|
628
|
-
density: Number(listsJsonItem.density)
|
|
629
|
-
});
|
|
630
|
-
const productConfigItem = (await this.getProductConfig()).find((item) => item.name === listsJsonItem.model);
|
|
1034
|
+
const productConfig = await this.getImageManager().getProductConfig();
|
|
631
1035
|
const pascalCaseDeviceType = await this.getPascalCaseDeviceType();
|
|
632
|
-
|
|
1036
|
+
const screen = createScreen({
|
|
633
1037
|
diagonal: Number(listsJsonItem.diagonalSize),
|
|
634
1038
|
height: Number(listsJsonItem.resolutionHeight),
|
|
635
1039
|
width: Number(listsJsonItem.resolutionWidth),
|
|
636
|
-
density: Number(listsJsonItem.density)
|
|
1040
|
+
density: Number(listsJsonItem.density),
|
|
1041
|
+
deviceType: listsJsonItem.type,
|
|
1042
|
+
apiVersion: Number(listsJsonItem.apiVersion),
|
|
1043
|
+
cover: listsJsonItem.coverResolutionWidth && listsJsonItem.coverResolutionHeight && listsJsonItem.coverDiagonalSize ? {
|
|
1044
|
+
height: Number(listsJsonItem.coverResolutionHeight),
|
|
1045
|
+
width: Number(listsJsonItem.coverResolutionWidth),
|
|
1046
|
+
diagonal: Number(listsJsonItem.coverDiagonalSize)
|
|
1047
|
+
} : void 0
|
|
637
1048
|
});
|
|
638
|
-
|
|
1049
|
+
if (pascalCaseDeviceType) {
|
|
1050
|
+
const productConfigItem = productConfig[pascalCaseDeviceType]?.find((item) => item.name === listsJsonItem.model);
|
|
1051
|
+
if (productConfigItem && productConfigItem.outerScreenWidth && productConfigItem.outerScreenHeight && productConfigItem.outerScreenDiagonal) screen.setOuterScreen(createOuterScreen({
|
|
1052
|
+
width: Number(productConfigItem.outerScreenWidth),
|
|
1053
|
+
height: Number(productConfigItem.outerScreenHeight),
|
|
1054
|
+
diagonal: Number(productConfigItem.outerScreenDiagonal)
|
|
1055
|
+
}, screen));
|
|
1056
|
+
if (productConfigItem && productConfigItem.outerDoubleScreenWidth && productConfigItem.outerDoubleScreenHeight && productConfigItem.outerDoubleScreenDiagonal) screen.getOuterScreen()?.setOuterDoubleScreen(createOuterDoubleScreen({
|
|
1057
|
+
width: Number(productConfigItem.outerDoubleScreenWidth),
|
|
1058
|
+
height: Number(productConfigItem.outerDoubleScreenHeight),
|
|
1059
|
+
diagonal: Number(productConfigItem.outerDoubleScreenDiagonal)
|
|
1060
|
+
}, screen.getOuterScreen()));
|
|
1061
|
+
}
|
|
1062
|
+
const screenPreset = createScreenPreset({
|
|
1063
|
+
screen,
|
|
1064
|
+
productConfig,
|
|
1065
|
+
emulatorConfig: await this.getImageManager().getEmulatorConfig()
|
|
1066
|
+
});
|
|
1067
|
+
if (screenPreset.getProductPreset() || screenPreset.getEmulatorPreset()) return screenPreset;
|
|
1068
|
+
else return screen;
|
|
639
1069
|
}
|
|
640
1070
|
async getDevices() {
|
|
641
1071
|
const { path, fs, deployedPath, imageBasePath } = this.getImageManager().getOptions();
|
|
@@ -784,6 +1214,11 @@ var ImageManagerImpl = class {
|
|
|
784
1214
|
if (!this.resolvedOptions.fs.existsSync(productConfigPath) || !this.resolvedOptions.fs.statSync(productConfigPath).isFile()) return (await import("./default-product-config.mjs")).default;
|
|
785
1215
|
return JSON.parse(this.resolvedOptions.fs.readFileSync(productConfigPath, "utf-8"));
|
|
786
1216
|
}
|
|
1217
|
+
async getEmulatorConfig() {
|
|
1218
|
+
const emulatorConfigPath = this.resolvedOptions.path.resolve(this.resolvedOptions.emulatorPath, "emulator.json");
|
|
1219
|
+
if (!this.resolvedOptions.fs.existsSync(emulatorConfigPath) || !this.resolvedOptions.fs.statSync(emulatorConfigPath).isFile()) return (await import("./default-emulator-config.mjs")).default;
|
|
1220
|
+
return JSON.parse(this.resolvedOptions.fs.readFileSync(emulatorConfigPath, "utf-8"));
|
|
1221
|
+
}
|
|
787
1222
|
async writeDefaultProductConfig(existSkip = false) {
|
|
788
1223
|
const productConfigPath = this.resolvedOptions.path.resolve(this.resolvedOptions.imageBasePath, "productConfig.json");
|
|
789
1224
|
if (existSkip && this.resolvedOptions.fs.existsSync(productConfigPath)) return;
|
|
@@ -804,4 +1239,4 @@ async function createImageManager(options = {}) {
|
|
|
804
1239
|
}
|
|
805
1240
|
|
|
806
1241
|
//#endregion
|
|
807
|
-
export { DeployError, DevModel, RequestUrlError, createImageManager,
|
|
1242
|
+
export { BaseEmulatorConfigItem, DeployError, DevModel, GroupPCAllEmulatorConfigItem, GroupPhoneAllEmulatorConfigItem, PCAllEmulatorConfigItem, ParentEmulatorConfigItem, PhoneAllEmulatorConfigItem, RequestUrlError, createCoverScreen, createDoubleScreen, createImageManager, createOuterDoubleScreen, createOuterScreen, createScreen, createScreenPreset, createSingleScreen, version };
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
toJSON(): T;
|
|
4
|
-
}
|
|
5
|
-
type OS = 'windows' | 'mac' | 'linux';
|
|
6
|
-
type Arch = 'x86' | 'arm64';
|
|
7
|
-
type DeviceType = 'pc' | 'phone' | 'tablet' | 'wearable' | 'tv' | 'foldable' | 'widefold' | '2in1';
|
|
8
|
-
type SnakecaseDeviceType = 'phone' | 'tablet' | '2in1' | 'foldable' | 'widefold' | 'triplefold' | '2in1_foldable' | 'tv' | 'wearable';
|
|
9
|
-
type PascalCaseDeviceType = 'Phone' | 'Tablet' | '2in1' | 'Foldable' | 'WideFold' | 'TripleFold' | '2in1 Foldable' | 'TV' | 'Wearable';
|
|
10
|
-
//#endregion
|
|
1
|
+
import { o as PascalCaseDeviceType } from "./types-DD8_iqBV.mjs";
|
|
2
|
+
|
|
11
3
|
//#region src/product-config.d.ts
|
|
12
4
|
interface ProductConfigItem {
|
|
13
5
|
/**
|
|
@@ -67,6 +59,9 @@ interface ProductConfigItem {
|
|
|
67
59
|
*/
|
|
68
60
|
devModel?: string;
|
|
69
61
|
}
|
|
62
|
+
declare namespace ProductConfigItem {
|
|
63
|
+
function is(value: unknown): value is ProductConfigItem;
|
|
64
|
+
}
|
|
70
65
|
type ProductConfig = Record<PascalCaseDeviceType, ProductConfigItem[]>;
|
|
71
66
|
//#endregion
|
|
72
|
-
export {
|
|
67
|
+
export { ProductConfigItem as n, ProductConfig as t };
|