Skip to content

Commit

Permalink
fix(puppets): fix wrong splash screen resolution for Apple iPhone Plu…
Browse files Browse the repository at this point in the history
…s devices

fix #391
  • Loading branch information
onderceylan committed Oct 23, 2020
1 parent 6bd681e commit afe9833
Show file tree
Hide file tree
Showing 186 changed files with 179 additions and 176 deletions.
2 changes: 1 addition & 1 deletion src/__snapshots__/cli.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports[`CLI integrates with main API and creates an output with generated meta
<link rel=\\"apple-touch-startup-image\\" href=\\"%PUBLIC_URL%/temp/apple-splash-dark-2688-1242.jpg\\" media=\\"(prefers-color-scheme: dark) and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)\\">
<link rel=\\"apple-touch-startup-image\\" href=\\"%PUBLIC_URL%/temp/apple-splash-dark-2436-1125.jpg\\" media=\\"(prefers-color-scheme: dark) and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)\\">
<link rel=\\"apple-touch-startup-image\\" href=\\"%PUBLIC_URL%/temp/apple-splash-dark-1792-828.jpg\\" media=\\"(prefers-color-scheme: dark) and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)\\">
<link rel=\\"apple-touch-startup-image\\" href=\\"%PUBLIC_URL%/temp/apple-splash-dark-1920-1080.jpg\\" media=\\"(prefers-color-scheme: dark) and (device-width: 360px) and (device-height: 640px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)\\">
<link rel=\\"apple-touch-startup-image\\" href=\\"%PUBLIC_URL%/temp/apple-splash-dark-2208-1242.jpg\\" media=\\"(prefers-color-scheme: dark) and (device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)\\">
<link rel=\\"apple-touch-startup-image\\" href=\\"%PUBLIC_URL%/temp/apple-splash-dark-1334-750.jpg\\" media=\\"(prefers-color-scheme: dark) and (device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)\\">
<link rel=\\"apple-touch-startup-image\\" href=\\"%PUBLIC_URL%/temp/apple-splash-dark-1136-640.jpg\\" media=\\"(prefers-color-scheme: dark) and (device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)\\">
Expand Down
288 changes: 144 additions & 144 deletions src/__snapshots__/main.test.ts.snap

Large diffs are not rendered by default.

Binary file modified src/__snapshots__/visual/input-html-dark/apple-icon-120.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/__snapshots__/visual/input-html-dark/apple-icon-152.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/__snapshots__/visual/input-html-dark/apple-icon-167.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/__snapshots__/visual/input-html-dark/apple-icon-180.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/__snapshots__/visual/input-html-dark/manifest-icon-192.png
Binary file modified src/__snapshots__/visual/input-html-dark/manifest-icon-512.png
Binary file modified src/__snapshots__/visual/input-html/apple-icon-120.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-icon-152.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-icon-167.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-icon-180.jpg
Diff not rendered.
Binary file modified src/__snapshots__/visual/input-html/apple-splash-1125-2436.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-splash-1136-640.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-splash-1242-2688.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-splash-1334-750.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-splash-1536-2048.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-splash-1620-2160.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-splash-1668-2224.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-splash-1668-2388.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-splash-1792-828.jpg
Diff not rendered.
Binary file modified src/__snapshots__/visual/input-html/apple-splash-2048-1536.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-splash-2048-2732.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-splash-2160-1620.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-splash-2224-1668.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-splash-2388-1668.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-splash-2436-1125.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-splash-2688-1242.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-splash-2732-2048.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-splash-640-1136.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-splash-750-1334.jpg
Binary file modified src/__snapshots__/visual/input-html/apple-splash-828-1792.jpg
Binary file modified src/__snapshots__/visual/input-html/manifest-icon-192.png
Binary file modified src/__snapshots__/visual/input-html/manifest-icon-512.png
Binary file modified src/__snapshots__/visual/input-png/apple-icon-120.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-icon-152.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-icon-167.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-icon-180.jpg
Diff not rendered.
Binary file modified src/__snapshots__/visual/input-png/apple-splash-1125-2436.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-splash-1136-640.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-splash-1242-2688.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-splash-1334-750.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-splash-1536-2048.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-splash-1620-2160.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-splash-1668-2224.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-splash-1668-2388.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-splash-1792-828.jpg
Diff not rendered.
Binary file modified src/__snapshots__/visual/input-png/apple-splash-2048-1536.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-splash-2048-2732.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-splash-2160-1620.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-splash-2224-1668.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-splash-2388-1668.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-splash-2436-1125.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-splash-2688-1242.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-splash-2732-2048.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-splash-640-1136.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-splash-750-1334.jpg
Binary file modified src/__snapshots__/visual/input-png/apple-splash-828-1792.jpg
Binary file modified src/__snapshots__/visual/input-png/manifest-icon-192.png
Binary file modified src/__snapshots__/visual/input-png/manifest-icon-512.png
Binary file modified src/__snapshots__/visual/input-svg/apple-icon-120.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-icon-152.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-icon-167.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-icon-180.jpg
Diff not rendered.
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-1125-2436.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-1136-640.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-1242-2688.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-1334-750.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-1536-2048.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-1620-2160.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-1668-2224.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-1668-2388.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-1792-828.jpg
Diff not rendered.
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-2048-1536.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-2048-2732.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-2160-1620.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-2224-1668.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-2388-1668.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-2436-1125.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-2688-1242.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-2732-2048.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-640-1136.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-750-1334.jpg
Binary file modified src/__snapshots__/visual/input-svg/apple-splash-828-1792.jpg
Binary file modified src/__snapshots__/visual/input-svg/manifest-icon-192.png
Binary file modified src/__snapshots__/visual/input-svg/manifest-icon-512.png
Binary file modified src/__snapshots__/visual/output-png/apple-icon-120.png
Binary file modified src/__snapshots__/visual/output-png/apple-icon-152.png
Binary file modified src/__snapshots__/visual/output-png/apple-icon-167.png
Binary file modified src/__snapshots__/visual/output-png/apple-icon-180.png
Diff not rendered.
Binary file modified src/__snapshots__/visual/output-png/apple-splash-1125-2436.png
Binary file modified src/__snapshots__/visual/output-png/apple-splash-1136-640.png
Binary file modified src/__snapshots__/visual/output-png/apple-splash-1242-2688.png
Binary file modified src/__snapshots__/visual/output-png/apple-splash-1334-750.png
Binary file modified src/__snapshots__/visual/output-png/apple-splash-1536-2048.png
Binary file modified src/__snapshots__/visual/output-png/apple-splash-1620-2160.png
Binary file modified src/__snapshots__/visual/output-png/apple-splash-1668-2224.png
Binary file modified src/__snapshots__/visual/output-png/apple-splash-1668-2388.png
Binary file modified src/__snapshots__/visual/output-png/apple-splash-1792-828.png
Diff not rendered.
Binary file modified src/__snapshots__/visual/output-png/apple-splash-2048-1536.png
Binary file modified src/__snapshots__/visual/output-png/apple-splash-2048-2732.png
Binary file modified src/__snapshots__/visual/output-png/apple-splash-2160-1620.png
Binary file modified src/__snapshots__/visual/output-png/apple-splash-2224-1668.png
Binary file modified src/__snapshots__/visual/output-png/apple-splash-2388-1668.png
Binary file modified src/__snapshots__/visual/output-png/apple-splash-2436-1125.png
Binary file modified src/__snapshots__/visual/output-png/apple-splash-2688-1242.png
Binary file modified src/__snapshots__/visual/output-png/apple-splash-2732-2048.png
Binary file modified src/__snapshots__/visual/output-png/apple-splash-640-1136.png
Binary file modified src/__snapshots__/visual/output-png/apple-splash-750-1334.png
Binary file modified src/__snapshots__/visual/output-png/apple-splash-828-1792.png
Binary file modified src/__snapshots__/visual/output-png/manifest-icon-192.png
Binary file modified src/__snapshots__/visual/output-png/manifest-icon-512.png
Binary file modified src/__snapshots__/visual/output-transparent/apple-icon-120.png
Binary file modified src/__snapshots__/visual/output-transparent/apple-icon-152.png
Binary file modified src/__snapshots__/visual/output-transparent/apple-icon-167.png
Binary file modified src/__snapshots__/visual/output-transparent/apple-icon-180.png
Diff not rendered.
Diff not rendered.
Binary file modified src/__snapshots__/visual/output-transparent/manifest-icon-192.png
Binary file modified src/__snapshots__/visual/output-transparent/manifest-icon-512.png
34 changes: 17 additions & 17 deletions src/config/apple-fallback-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,12 @@
{
"device": "iPhone 8 Plus",
"portrait": {
"width": 1080,
"height": 1920
"width": 1242,
"height": 2208
},
"landscape": {
"width": 1920,
"height": 1080
"width": 2208,
"height": 1242
},
"scaleFactor": 3
},
Expand All @@ -218,12 +218,12 @@
{
"device": "iPhone 7 Plus",
"portrait": {
"width": 1080,
"height": 1920
"width": 1242,
"height": 2208
},
"landscape": {
"width": 1920,
"height": 1080
"width": 2208,
"height": 1242
},
"scaleFactor": 3
},
Expand All @@ -242,12 +242,12 @@
{
"device": "iPhone 6s Plus",
"portrait": {
"width": 1080,
"height": 1920
"width": 1242,
"height": 2208
},
"landscape": {
"width": 1920,
"height": 1080
"width": 2208,
"height": 1242
},
"scaleFactor": 3
},
Expand All @@ -266,12 +266,12 @@
{
"device": "iPhone 6 Plus",
"portrait": {
"width": 1080,
"height": 1920
"width": 1242,
"height": 2208
},
"landscape": {
"width": 1920,
"height": 1080
"width": 2208,
"height": 1242
},
"scaleFactor": 3
},
Expand Down Expand Up @@ -323,4 +323,4 @@
},
"scaleFactor": 2
}
]
]
1 change: 1 addition & 0 deletions src/helpers/images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const mapToSqImageFileObj = (fileNamePrefix: string, size: number): Image => ({
width: size,
height: size,
orientation: null,
scaleFactor: 1,
});

const mapToImageFileObj = (
Expand Down
28 changes: 15 additions & 13 deletions src/helpers/puppets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ const getAppleSplashScreenData = async (
return Array.from(
document.querySelectorAll('table')?.[0].querySelectorAll('tbody tr'),
).map((tr) => {
// https://regex101.com/r/4dwvYf/3
const dimensionRegex = new RegExp(/\((\d+)x(\d+)\spx\s@(\d)x\)/gm);
// https://regex101.com/r/4dwvYf/4
const dimensionRegex = new RegExp(
/(\d+)x(\d+)\spt\s\((\d+)x(\d+)\spx\s@(\d)x\)/gm,
);

const getParsedSpecs = (
val: string,
Expand All @@ -54,24 +56,24 @@ const getAppleSplashScreenData = async (
throw Error('Regex match failed while scraping the specs');
}

const width = parseInt(regexMatch[1], 10);
const height = parseInt(regexMatch[2], 10);
const scaleFactor = parseInt(regexMatch[3], 10);
const widthInPoints = parseInt(regexMatch[1], 10);
const heightInPoints = parseInt(regexMatch[2], 10);
const scaleFactor = parseInt(regexMatch[5], 10);

if (
width === 0 ||
Number.isNaN(width) ||
height === 0 ||
Number.isNaN(height) ||
widthInPoints === 0 ||
Number.isNaN(widthInPoints) ||
heightInPoints === 0 ||
Number.isNaN(heightInPoints) ||
scaleFactor === 0 ||
Number.isNaN(scaleFactor)
) {
throw Error('Got unexpected dimensions while scraping the specs');
}

return {
width,
height,
width: widthInPoints * scaleFactor,
height: heightInPoints * scaleFactor,
scaleFactor,
};
};
Expand Down Expand Up @@ -194,8 +196,8 @@ const saveImages = async (
width: width / scaleFactor,
height: height / scaleFactor,
deviceScaleFactor: scaleFactor,
isLandscape: orientation === 'landscape'
}
isLandscape: orientation === 'landscape',
},
});

if (address) {
Expand Down
2 changes: 1 addition & 1 deletion src/models/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface Image {
Key defaults to undefined for icons
*/
scaleFactor?: number;
scaleFactor: number;

/**
Device orientation used for generating HTML meta tags for iOS splash screens
Expand Down

0 comments on commit afe9833

Please sign in to comment.