codeplay-common 4.11.39 → 4.11.40
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/files/take-screen-image.js +106 -7
- package/package.json +1 -1
|
@@ -107,6 +107,32 @@ const deviceProfiles = [
|
|
|
107
107
|
orientationSensitive: true,
|
|
108
108
|
mobile: true,
|
|
109
109
|
},
|
|
110
|
+
{
|
|
111
|
+
name: 'ru-store-phone',
|
|
112
|
+
aliases: ['ru-store'],
|
|
113
|
+
label: 'RuStore Russian phone promotion',
|
|
114
|
+
outputDirectory: 'Ru-Store/Phone',
|
|
115
|
+
sourceDirectory: 'Android',
|
|
116
|
+
copyLocale: 'ru',
|
|
117
|
+
frameType: 'android-phone',
|
|
118
|
+
frameless: true,
|
|
119
|
+
framedWidth: 1080,
|
|
120
|
+
framedHeight: 1920,
|
|
121
|
+
width: 360,
|
|
122
|
+
height: 800,
|
|
123
|
+
deviceScaleFactor: 3,
|
|
124
|
+
orientationSensitive: true,
|
|
125
|
+
mobile: true,
|
|
126
|
+
storeRequirements: {
|
|
127
|
+
maxFileSizeBytes: 5 * 1000 * 1000,
|
|
128
|
+
minPixels: 320,
|
|
129
|
+
maxPixels: 3840,
|
|
130
|
+
minAspectRatio: 9 / 16,
|
|
131
|
+
maxAspectRatio: 16 / 9,
|
|
132
|
+
minImages: 3,
|
|
133
|
+
maxImages: 10,
|
|
134
|
+
},
|
|
135
|
+
},
|
|
110
136
|
{
|
|
111
137
|
name: 'vivo-store',
|
|
112
138
|
label: 'Vivo Store portrait screenshot',
|
|
@@ -180,6 +206,30 @@ const deviceProfiles = [
|
|
|
180
206
|
orientationSensitive: true,
|
|
181
207
|
mobile: true,
|
|
182
208
|
},
|
|
209
|
+
{
|
|
210
|
+
name: 'ru-store-tablet',
|
|
211
|
+
label: 'RuStore Russian tablet promotion',
|
|
212
|
+
outputDirectory: 'Ru-Store/Tablet',
|
|
213
|
+
sourceDirectory: 'Android-Tab-10inch',
|
|
214
|
+
copyLocale: 'ru',
|
|
215
|
+
frameType: 'tablet',
|
|
216
|
+
width: 900,
|
|
217
|
+
height: 1600,
|
|
218
|
+
deviceScaleFactor: 2,
|
|
219
|
+
framedWidth: 1800,
|
|
220
|
+
framedHeight: 3200,
|
|
221
|
+
orientationSensitive: true,
|
|
222
|
+
mobile: true,
|
|
223
|
+
storeRequirements: {
|
|
224
|
+
maxFileSizeBytes: 5 * 1000 * 1000,
|
|
225
|
+
minPixels: 320,
|
|
226
|
+
maxPixels: 3840,
|
|
227
|
+
minAspectRatio: 9 / 16,
|
|
228
|
+
maxAspectRatio: 16 / 9,
|
|
229
|
+
minImages: 3,
|
|
230
|
+
maxImages: 10,
|
|
231
|
+
},
|
|
232
|
+
},
|
|
183
233
|
{
|
|
184
234
|
name: 'iphone',
|
|
185
235
|
label: 'iPhone Dynamic Island medium-display App Store viewport',
|
|
@@ -310,6 +360,27 @@ const deviceProfiles = [
|
|
|
310
360
|
deviceScaleFactor: 1,
|
|
311
361
|
mobile: false,
|
|
312
362
|
},
|
|
363
|
+
{
|
|
364
|
+
name: 'ru-store-tv',
|
|
365
|
+
label: 'RuStore Russian TV promotion',
|
|
366
|
+
outputDirectory: 'Ru-Store/TV',
|
|
367
|
+
sourceDirectory: 'Android-TV',
|
|
368
|
+
copyLocale: 'ru',
|
|
369
|
+
frameType: 'tv',
|
|
370
|
+
width: 1920,
|
|
371
|
+
height: 1080,
|
|
372
|
+
deviceScaleFactor: 1,
|
|
373
|
+
mobile: false,
|
|
374
|
+
storeRequirements: {
|
|
375
|
+
maxFileSizeBytes: 5 * 1000 * 1000,
|
|
376
|
+
minPixels: 320,
|
|
377
|
+
maxPixels: 3840,
|
|
378
|
+
minAspectRatio: 16 / 9,
|
|
379
|
+
maxAspectRatio: 16 / 9,
|
|
380
|
+
minImages: 3,
|
|
381
|
+
maxImages: 10,
|
|
382
|
+
},
|
|
383
|
+
},
|
|
313
384
|
{
|
|
314
385
|
name: 'chromebook',
|
|
315
386
|
label: 'Chromebook 4K Play Store viewport',
|
|
@@ -454,7 +525,7 @@ function sanitizeName(input, fallback) {
|
|
|
454
525
|
|
|
455
526
|
function getSelectedOutputDirectories(selectedProfiles) {
|
|
456
527
|
return [...new Set(selectedProfiles.flatMap((profile) => ([
|
|
457
|
-
path.join(screenshotDirectory, profile.outputDirectory),
|
|
528
|
+
path.join(screenshotDirectory, profile.sourceDirectory || profile.outputDirectory),
|
|
458
529
|
...(profile.screenshotOnly ? [] : [path.join(inFrameDirectory, profile.outputDirectory)]),
|
|
459
530
|
])))];
|
|
460
531
|
}
|
|
@@ -484,7 +555,7 @@ function getUniqueFileName(prefix, selectedProfiles) {
|
|
|
484
555
|
|
|
485
556
|
while (selectedProfiles.some((profile) => {
|
|
486
557
|
const profileFileName = getProfileScreenshotFileName(fileName, profile);
|
|
487
|
-
return fs.existsSync(path.join(screenshotDirectory, profile.outputDirectory, profileFileName))
|
|
558
|
+
return fs.existsSync(path.join(screenshotDirectory, profile.sourceDirectory || profile.outputDirectory, profileFileName))
|
|
488
559
|
|| (!profile.screenshotOnly && fs.existsSync(path.join(inFrameDirectory, profile.outputDirectory, profileFileName)));
|
|
489
560
|
})) {
|
|
490
561
|
fileName = `${prefix}-${duplicateNumber}.${extension}`;
|
|
@@ -645,6 +716,7 @@ function printHelp() {
|
|
|
645
716
|
console.log(' node take-screen-image.js --prefix home --profiles android-phone');
|
|
646
717
|
console.log(' node take-screen-image.js --frame-existing');
|
|
647
718
|
console.log(' node take-screen-image.js --reframe-existing --profiles android-phone');
|
|
719
|
+
console.log(' node take-screen-image.js --reframe-existing --profiles ru-store-phone,ru-store-tablet,ru-store-tv');
|
|
648
720
|
console.log(' node take-screen-image.js --reframe-existing --screenshots 1,2');
|
|
649
721
|
console.log(' node take-screen-image.js --refresh-info 1');
|
|
650
722
|
console.log(' node take-screen-image.js --vivo-existing');
|
|
@@ -817,6 +889,17 @@ function removeScreenshotRecords(names) {
|
|
|
817
889
|
removedNames.push(name);
|
|
818
890
|
}
|
|
819
891
|
|
|
892
|
+
if (filePath === screenshotCopyPath) {
|
|
893
|
+
for (const localized of Object.values(source.localizations || {})) {
|
|
894
|
+
for (const name of names) {
|
|
895
|
+
if (localized.screenshots && Object.hasOwn(localized.screenshots, name)) {
|
|
896
|
+
delete localized.screenshots[name];
|
|
897
|
+
if (!removedNames.includes(name)) removedNames.push(name);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
|
|
820
903
|
if (!removedNames.length) continue;
|
|
821
904
|
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
822
905
|
fs.writeFileSync(filePath, `${JSON.stringify({ ...source, screenshots }, null, 2)}\n`);
|
|
@@ -858,6 +941,11 @@ function reconcileScreenshotRecords() {
|
|
|
858
941
|
? source.screenshots
|
|
859
942
|
: {};
|
|
860
943
|
Object.keys(screenshots).forEach((name) => configuredNames.add(name));
|
|
944
|
+
if (filePath === screenshotCopyPath) {
|
|
945
|
+
for (const localized of Object.values(source.localizations || {})) {
|
|
946
|
+
Object.keys(localized.screenshots || {}).forEach((name) => configuredNames.add(name));
|
|
947
|
+
}
|
|
948
|
+
}
|
|
861
949
|
}
|
|
862
950
|
|
|
863
951
|
const staleNames = new Set(
|
|
@@ -1902,10 +1990,12 @@ async function getScreenshotBarStyle(screenshotBuffer, edge = 'top') {
|
|
|
1902
1990
|
};
|
|
1903
1991
|
}
|
|
1904
1992
|
|
|
1905
|
-
function getScreenshotCopy(screenshotFileName) {
|
|
1993
|
+
function getScreenshotCopy(screenshotFileName, profile = {}) {
|
|
1906
1994
|
screenshotCopyConfig ||= readJsonAssetSource(screenshotCopyPath);
|
|
1907
1995
|
const screenshotKey = path.parse(screenshotFileName).name;
|
|
1908
|
-
const configuredCopy =
|
|
1996
|
+
const configuredCopy = profile.copyLocale
|
|
1997
|
+
? screenshotCopyConfig.localizations?.[profile.copyLocale]?.screenshots?.[screenshotKey]
|
|
1998
|
+
: screenshotCopyConfig.screenshots?.[screenshotKey];
|
|
1909
1999
|
|
|
1910
2000
|
if (!configuredCopy || typeof configuredCopy !== 'object') return null;
|
|
1911
2001
|
|
|
@@ -3512,7 +3602,7 @@ async function captureFramedScreenshot(
|
|
|
3512
3602
|
const navigationBarStyle = statusBarPlatform
|
|
3513
3603
|
? await getScreenshotBarStyle(screenshotBuffer, 'bottom')
|
|
3514
3604
|
: null;
|
|
3515
|
-
const screenshotCopy = getScreenshotCopy(screenshotFileName);
|
|
3605
|
+
const screenshotCopy = getScreenshotCopy(screenshotFileName, profile);
|
|
3516
3606
|
const promotionalPalette = await getPromotionalPalette(screenshotBuffer, screenshotFileName);
|
|
3517
3607
|
const screenshotKey = path.parse(screenshotFileName).name;
|
|
3518
3608
|
|
|
@@ -3520,7 +3610,7 @@ async function captureFramedScreenshot(
|
|
|
3520
3610
|
missingScreenshotCopyWarnings.add(screenshotKey);
|
|
3521
3611
|
console.warn(
|
|
3522
3612
|
`No promotional copy configured for screenshot ${screenshotKey}; `
|
|
3523
|
-
+ `add it to ${screenshotCopyPath}.`,
|
|
3613
|
+
+ `add it to ${screenshotCopyPath}${profile.copyLocale ? ` (localizations.${profile.copyLocale})` : ''}.`,
|
|
3524
3614
|
);
|
|
3525
3615
|
}
|
|
3526
3616
|
|
|
@@ -3650,6 +3740,15 @@ function validateStoreImage(profile, width, height, imageBuffer) {
|
|
|
3650
3740
|
}
|
|
3651
3741
|
|
|
3652
3742
|
async function captureProfile(client, snapshot, profile, screenshotFileName) {
|
|
3743
|
+
if (profile.sourceDirectory) {
|
|
3744
|
+
const sourceFileName = getProfileScreenshotFileName(screenshotFileName, profile);
|
|
3745
|
+
const sourcePath = path.join(screenshotDirectory, profile.sourceDirectory, sourceFileName);
|
|
3746
|
+
if (!fs.existsSync(sourcePath)) {
|
|
3747
|
+
throw new Error(`Capture ${profile.sourceDirectory} before ${profile.label}: ${sourcePath}`);
|
|
3748
|
+
}
|
|
3749
|
+
await captureFramedScreenshot(client, fs.readFileSync(sourcePath), profile, sourceFileName);
|
|
3750
|
+
return;
|
|
3751
|
+
}
|
|
3653
3752
|
await client.send('Emulation.setDeviceMetricsOverride', {
|
|
3654
3753
|
width: profile.width,
|
|
3655
3754
|
height: profile.height,
|
|
@@ -3771,7 +3870,7 @@ async function frameExistingScreenshots(
|
|
|
3771
3870
|
replayClient = await createReplayPage(replayBrowser);
|
|
3772
3871
|
|
|
3773
3872
|
for (const profile of selectedProfiles) {
|
|
3774
|
-
const profileDirectory = path.join(screenshotDirectory, profile.outputDirectory);
|
|
3873
|
+
const profileDirectory = path.join(screenshotDirectory, profile.sourceDirectory || profile.outputDirectory);
|
|
3775
3874
|
|
|
3776
3875
|
if (!fs.existsSync(profileDirectory)) {
|
|
3777
3876
|
continue;
|