Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually map Safari versions in getMatchingBrowserVersion #16594

Merged
merged 2 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 36 additions & 12 deletions api/PerformanceNavigationTiming.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -61,7 +63,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -97,7 +101,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -133,7 +139,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -169,7 +177,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -205,7 +215,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -241,7 +253,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -277,7 +291,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -313,7 +329,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -349,7 +367,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -385,7 +405,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down Expand Up @@ -421,7 +443,9 @@
"safari": {
"version_added": "15"
},
"safari_ios": "mirror",
"safari_ios": {
"version_added": "15.1"
},
"samsunginternet_android": "mirror",
"webview_android": "mirror"
},
Expand Down
8 changes: 4 additions & 4 deletions scripts/release/mirror.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ describe('mirror', () => {
['1.2', '1'],
['1.3', '1'],
['2', '1'],
['3', '2'], // wrong, should be 1
['3', '2'],
['3.1', '2'],
['4', '3.2'], // ambiguous
['4', '3.2'],
['5', '4.2'],
['5.1', '6'],
['6', '6'],
['7', '8'], // wrong, should be 7
['7', '7'],
['8', '8'],
['9', '9'],
['9.1', '9.3'],
Expand All @@ -85,7 +85,7 @@ describe('mirror', () => {
['13.1', '13.4'],
['14', '14'],
['14.1', '14.5'],
['15', '15.1'], // wrong, should be 15
['15', '15'],
['15.1', '15.1'],
['15.2', '15.2'],
['15.3', '15.3'],
Expand Down
41 changes: 41 additions & 0 deletions scripts/release/mirror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,32 @@ import compareVersions from 'compare-versions';
import bcd from '../../index.js';
const { browsers } = bcd;

/**
* @typedef {import('../types').Identifier} Identifier
* @typedef {import('../types').SupportStatement} SupportStatement
* @typedef {import('../types').ReleaseStatement} ReleaseStatement
*/

const matchingSafariVersions = new Map([
['≤4', '≤3'],
['1', '1'],
['1.1', '1'],
['1.2', '1'],
['1.3', '1'],
['2', '1'],
['3', '2'],
['3.1', '2'],
['4', '3.2'],
['5', '4.2'],
['5.1', '6'],
['9.1', '9.3'],
['10.1', '10.3'],
['11.1', '11.3'],
['12.1', '12.2'],
['13.1', '13.4'],
['14.1', '14.5'],
]);

/**
* @param {string} targetBrowser
* @param {string} sourceVersion
Expand All @@ -33,6 +59,21 @@ export const getMatchingBrowserVersion = (
}
/* c8 ignore stop */

if (targetBrowser === 'safari_ios') {
// The mapping between Safari macOS and iOS releases is complicated and
// cannot be entirely derived from the WebKit versions. After Safari 15
// the versions have been the same, so map earlier versions manually
// and then assume if the versions are identical it's also a match.
const v = matchingSafariVersions.get(sourceVersion);
if (v) {
return v;
}
if (sourceVersion in browserData.releases) {
return sourceVersion;
}
throw new Error(`Cannot find iOS version matching Safari ${sourceVersion}`);
}

const releaseKeys = Object.keys(browserData.releases);
releaseKeys.sort(compareVersions);

Expand Down