baseline-browser-mapping 2.1.1 → 2.2.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/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
By the [W3C WebDX Community Group](https://www.w3.org/community/webdx/) and contributors.
|
|
4
4
|
|
|
5
|
-
`baseline-browser-mapping` exposes arrays of browsers compatible with Baseline Widely
|
|
5
|
+
`baseline-browser-mapping` exposes arrays of browsers compatible with Baseline Widely available and specified Baseline year feature sets.
|
|
6
6
|
You can use `baseline-browser-mapping` to help you determine minimum browser version support for your chosen Baseline feature set.
|
|
7
7
|
|
|
8
8
|
## Prerequisites
|
|
@@ -25,11 +25,9 @@ To install the package, run:
|
|
|
25
25
|
]
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
##
|
|
28
|
+
## Get Baseline Widely available browser versions or Baseline year browser versions
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
To get the current list of minimum browser versions compatible with Baseline Widely Available features from the core browser set, call the `getCompatibleVersions()` function with:
|
|
30
|
+
To get the current list of minimum browser versions compatible with Baseline Widely available features from the core browser set, call the `getCompatibleVersions()` function:
|
|
33
31
|
|
|
34
32
|
```javascript
|
|
35
33
|
import { getCompatibleVersions } from "baseline-browser-mapping";
|
|
@@ -64,9 +62,9 @@ Executed on 7th March 2025, the above code returns the following browser version
|
|
|
64
62
|
```
|
|
65
63
|
|
|
66
64
|
> [!NOTE]
|
|
67
|
-
> The minimum versions of each browser are not strictly the final release before the Widely
|
|
65
|
+
> The minimum versions of each browser are not strictly the final release before the Widely available cutoff date of `TODAY - 30 MONTHS`. Some earlier versions will have supported the full Widely available feature set.
|
|
68
66
|
|
|
69
|
-
###
|
|
67
|
+
### `getCompatibleVersions()` configuration options
|
|
70
68
|
|
|
71
69
|
`getCompatibleVersions()` accepts an `Object` as an argument with configuration options. The defaults are as follows:
|
|
72
70
|
|
|
@@ -81,7 +79,7 @@ Executed on 7th March 2025, the above code returns the following browser version
|
|
|
81
79
|
|
|
82
80
|
#### `targetYear`
|
|
83
81
|
|
|
84
|
-
The `targetYear` option returns the minimum browser versions compatible with all
|
|
82
|
+
The `targetYear` option returns the minimum browser versions compatible with all **Baseline Newly available** features at the end of the specified calendar year. For example, calling:
|
|
85
83
|
|
|
86
84
|
```javascript
|
|
87
85
|
getCompatibleVersions({
|
|
@@ -118,7 +116,7 @@ Returns the following versions:
|
|
|
118
116
|
|
|
119
117
|
#### `widelyAvailableOnDate`
|
|
120
118
|
|
|
121
|
-
The `widelyAvailableOnDate`
|
|
119
|
+
The `widelyAvailableOnDate` option returns the minimum versions compatible with Baseline Widely available on a specified date in the formay `YYYY-MM-DD`:
|
|
122
120
|
|
|
123
121
|
```javascript
|
|
124
122
|
getCompatibleVersions({
|
|
@@ -127,7 +125,7 @@ getCompatibleVersions({
|
|
|
127
125
|
```
|
|
128
126
|
|
|
129
127
|
> [!TIP]
|
|
130
|
-
> This
|
|
128
|
+
> This option is useful if you provide a versioned library that targets Baseline Widely available on each version's release date and you need to provide a statement on minimum supported browser versions in your documentation.
|
|
131
129
|
|
|
132
130
|
#### `includeDownstreamBrowsers`
|
|
133
131
|
|
|
@@ -143,7 +141,7 @@ For more information on downstream browsers, see [the section on downstream brow
|
|
|
143
141
|
|
|
144
142
|
#### `listAllCompatibleVersions`
|
|
145
143
|
|
|
146
|
-
|
|
144
|
+
Setting `listAllCompatibleVersions` to true will include the minimum versions of each compatible browser, and all the subsequent versions:
|
|
147
145
|
|
|
148
146
|
```javascript
|
|
149
147
|
getCompatibleVersions({
|
|
@@ -151,6 +149,150 @@ getCompatibleVersions({
|
|
|
151
149
|
});
|
|
152
150
|
```
|
|
153
151
|
|
|
152
|
+
## Get data for all browser versions
|
|
153
|
+
|
|
154
|
+
You may want to obtain data on all the browser versions available in this module for use in an analytics solution or dashboard. To get details of each browser version's level of Baseline support, call the `getAllVersions()` function:
|
|
155
|
+
|
|
156
|
+
```javascript
|
|
157
|
+
import { getAllVersions } from "baseline-browser-mapping";
|
|
158
|
+
|
|
159
|
+
getAllVersions();
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
By default, this function returns an `Array` of `Objects` and excludes downstream browsers:
|
|
163
|
+
|
|
164
|
+
```javascript
|
|
165
|
+
[
|
|
166
|
+
...
|
|
167
|
+
{
|
|
168
|
+
browser: 'chrome_android', // Browser name
|
|
169
|
+
version: '68', // Browser version as a string
|
|
170
|
+
release_date: '2018-07-24', // Release date
|
|
171
|
+
year: 2019, //Baseline year feature set the version supports
|
|
172
|
+
waCompatible: false // Boolean indicating whether the version is compatible with Baseline Widely available
|
|
173
|
+
},
|
|
174
|
+
...
|
|
175
|
+
]
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### `getAllVersions()` Configuration options
|
|
179
|
+
|
|
180
|
+
`getAllVersions()` accepts an `Object` as an argument with configuration options. The defaults are as follows:
|
|
181
|
+
|
|
182
|
+
```javascript
|
|
183
|
+
{
|
|
184
|
+
includeDownstreamBrowsers: false,
|
|
185
|
+
outputFormat: "array"
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
#### `includeDownstreamBrowsers` (in `getAllVersions()` output)
|
|
190
|
+
|
|
191
|
+
As with `getCompatibleVersions()`, you can set `includeDownstreamBrowsers` to `true` to include the Chromium downstream browsers [listed below](#list-of-downstream-browsers).
|
|
192
|
+
|
|
193
|
+
```javascript
|
|
194
|
+
getAllVersions({
|
|
195
|
+
includeDownstreamBrowsers: true,
|
|
196
|
+
});
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Downstream browsers include the same properties as core browsers, as well as the `engine`they use and `engine_version`, for example:
|
|
200
|
+
|
|
201
|
+
```javascript
|
|
202
|
+
[
|
|
203
|
+
...
|
|
204
|
+
{
|
|
205
|
+
"browser": "samsunginternet_android",
|
|
206
|
+
"version": "18.0",
|
|
207
|
+
"release_date": "2022-08-08",
|
|
208
|
+
"engine": "Blink",
|
|
209
|
+
"engine_version": "99",
|
|
210
|
+
"year": 2021,
|
|
211
|
+
"waCompatible": false
|
|
212
|
+
},
|
|
213
|
+
...
|
|
214
|
+
]
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
#### `outputFormat`
|
|
218
|
+
|
|
219
|
+
By default, this function returns an `Array` of `Objects` which can be manipulated in Javascript or output to JSON.
|
|
220
|
+
|
|
221
|
+
To return an `Object` that nests keys , set `outputFormat` to `object`:
|
|
222
|
+
|
|
223
|
+
```javascript
|
|
224
|
+
getAllVersions({
|
|
225
|
+
outputFormat: "object",
|
|
226
|
+
});
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
In thise case, `getAllVersions()` returns a nested object with the browser [IDs listed below](#list-of-downstream-browsers) as keys, and versions as keys within them:
|
|
230
|
+
|
|
231
|
+
```javascript
|
|
232
|
+
{
|
|
233
|
+
"chrome": {
|
|
234
|
+
"53": {
|
|
235
|
+
"year": 2016,
|
|
236
|
+
"wa_compatible": false,
|
|
237
|
+
"release_date": "2016-09-07"
|
|
238
|
+
},
|
|
239
|
+
...
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Downstream browsers will include extra fields for `engine` and `engine_versions`
|
|
244
|
+
|
|
245
|
+
```javascript
|
|
246
|
+
{
|
|
247
|
+
...
|
|
248
|
+
"webview_android": {
|
|
249
|
+
"53": {
|
|
250
|
+
"year": 2016,
|
|
251
|
+
"waCompatible": false,
|
|
252
|
+
"release_date": "2016-09-07",
|
|
253
|
+
"engine": "Blink",
|
|
254
|
+
"engine_version": "53"
|
|
255
|
+
},
|
|
256
|
+
...
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
To return a `String` in CSV format, set `outputFormat` to `csv`:
|
|
261
|
+
|
|
262
|
+
```javascript
|
|
263
|
+
getAllVersions({
|
|
264
|
+
outputFormat: "csv",
|
|
265
|
+
});
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
`getAllVersions` returns a `String` with a header row and comma-separated values for each browser version that you can write to a file or pass to another service. Core browsers will have "NULL" as the value for their `engine` and `engine_version`:
|
|
269
|
+
|
|
270
|
+
```csv
|
|
271
|
+
"browser","version","year","wa_compatible","release_date","engine","engine_version"
|
|
272
|
+
"chrome","53","2016","false","2016-09-07","NULL","NULL"
|
|
273
|
+
...
|
|
274
|
+
"ya_android","20.12","2020","false","2020-12-20","Blink","87"
|
|
275
|
+
...
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
> [!NOTE]
|
|
279
|
+
> The above example uses `"includeDownstreamBrowsers": true`
|
|
280
|
+
|
|
281
|
+
### Static resources
|
|
282
|
+
|
|
283
|
+
The outputs of `getAllVersions()` are available as JSON or CSV files generated on a daily basis and hosted on GitHub pages:
|
|
284
|
+
|
|
285
|
+
- Core browsers only
|
|
286
|
+
- [Array](https://web-platform-dx.github.io/baseline-browser-mapping/all_versions_array.json)
|
|
287
|
+
- [Object](https://web-platform-dx.github.io/baseline-browser-mapping/all_versions_object.json)
|
|
288
|
+
- [CSV](https://web-platform-dx.github.io/baseline-browser-mapping/all_versions.csv)
|
|
289
|
+
- Including downstream browsers
|
|
290
|
+
- [Array](https://web-platform-dx.github.io/baseline-browser-mapping/with_downstream/all_versions_array.json)
|
|
291
|
+
- [Object](https://web-platform-dx.github.io/baseline-browser-mapping/with_downstream/all_versions_object.json)
|
|
292
|
+
- [CSV](https://web-platform-dx.github.io/baseline-browser-mapping/with_downstream/all_versions.csv)
|
|
293
|
+
|
|
294
|
+
These files are updated on a daily basis.
|
|
295
|
+
|
|
154
296
|
## Downstream browsers
|
|
155
297
|
|
|
156
298
|
### Limitations
|
|
@@ -170,7 +312,7 @@ Shows UC Browser Mobile 13.8 implementing Chromium 100, and:
|
|
|
170
312
|
|
|
171
313
|
`Mozilla/5.0 (Linux; arm_64; Android 11; Redmi Note 8 Pro) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.6613.123 YaBrowser/24.10.2.123.00 SA/3 Mobile Safari/537.36`
|
|
172
314
|
|
|
173
|
-
Shows Yandex Browser Mobile 24.10 implementing Chromium 128. The Chromium version from this string is mapped to the
|
|
315
|
+
Shows Yandex Browser Mobile 24.10 implementing Chromium 128. The Chromium version from this string is mapped to the corresponding Chrome version from MDN `browser-compat-data`.
|
|
174
316
|
|
|
175
317
|
> [!NOTE]
|
|
176
318
|
> Where possible, approximate release dates have been included based on useragents.io "first seen" data. useragents.io does not have "first seen" dates prior to June 2020. However, these browsers' Baseline compatibility is determined by their Chromium version, so their release dates are more informative than critical.
|
|
@@ -198,7 +340,3 @@ This data is updated on a daily basis using a [script](https://github.com/web-pl
|
|
|
198
340
|
|
|
199
341
|
> [!NOTE]
|
|
200
342
|
> All the non-core browsers currently included implement Chromium. Their inclusion in any of the above methods is based on the Baseline feature set supported by the Chromium version they implement, not their release date.
|
|
201
|
-
|
|
202
|
-
## Contributing
|
|
203
|
-
|
|
204
|
-
`baseline-browser-mapping` is part of the W3C WebDX Community Group's web-features project. To learn more about contributing to this module, see [CONTRIBUTING](/CONTRIBUTING.md).
|
|
@@ -995,6 +995,12 @@
|
|
|
995
995
|
"engine_version": "100",
|
|
996
996
|
"status": "unknown",
|
|
997
997
|
"release_date": "2025-02-26"
|
|
998
|
+
},
|
|
999
|
+
"17.5": {
|
|
1000
|
+
"engine": "Blink",
|
|
1001
|
+
"engine_version": "100",
|
|
1002
|
+
"status": "unknown",
|
|
1003
|
+
"release_date": "2025-04-08"
|
|
998
1004
|
}
|
|
999
1005
|
}
|
|
1000
1006
|
},
|
|
@@ -1498,5 +1504,5 @@
|
|
|
1498
1504
|
}
|
|
1499
1505
|
}
|
|
1500
1506
|
},
|
|
1501
|
-
"lastUpdated": "2025-
|
|
1507
|
+
"lastUpdated": "2025-04-09T14:12:33.205Z"
|
|
1502
1508
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { getCompatibleVersions } from "./scripts/baseline-browser-versions.js";
|
|
2
|
-
export { getCompatibleVersions };
|
|
1
|
+
import { getCompatibleVersions, getAllVersions } from "./scripts/baseline-browser-versions.js";
|
|
2
|
+
export { getCompatibleVersions, getAllVersions };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { getCompatibleVersions } from "./scripts/baseline-browser-versions.js";
|
|
2
|
-
export { getCompatibleVersions };
|
|
1
|
+
import { getCompatibleVersions, getAllVersions, } from "./scripts/baseline-browser-versions.js";
|
|
2
|
+
export { getCompatibleVersions, getAllVersions };
|
|
@@ -5,6 +5,21 @@ type BrowserVersion = {
|
|
|
5
5
|
engine?: string;
|
|
6
6
|
engine_version?: string;
|
|
7
7
|
};
|
|
8
|
+
interface AllBrowsersBrowserVersion extends BrowserVersion {
|
|
9
|
+
year: number;
|
|
10
|
+
wa_compatible: boolean;
|
|
11
|
+
}
|
|
12
|
+
type NestedBrowserVersions = {
|
|
13
|
+
[browser: string]: {
|
|
14
|
+
[version: string]: {
|
|
15
|
+
year: number;
|
|
16
|
+
wa_compatible: boolean;
|
|
17
|
+
release_date?: string;
|
|
18
|
+
engine?: string;
|
|
19
|
+
engine_version?: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
8
23
|
type Options = {
|
|
9
24
|
/**
|
|
10
25
|
* Whether to include only the minimum compatible browser versions or all compatible versions.
|
|
@@ -18,14 +33,44 @@ type Options = {
|
|
|
18
33
|
includeDownstreamBrowsers?: boolean;
|
|
19
34
|
/**
|
|
20
35
|
* Pass a date in the format 'YYYY-MM-DD' to get versions compatible with Widely available on the specified date.
|
|
21
|
-
* If left undefined and a `targetYear` is not passed, defaults to Widely
|
|
36
|
+
* If left undefined and a `targetYear` is not passed, defaults to Widely available as of the current date.
|
|
37
|
+
* > NOTE: cannot be used with `targetYear`.
|
|
22
38
|
*/
|
|
23
39
|
widelyAvailableOnDate?: string | number;
|
|
24
40
|
/**
|
|
25
41
|
* Pass a year between 2016 and the current year to get browser versions compatible with all
|
|
26
42
|
* Newly Available features as of the end of the year specified.
|
|
43
|
+
* > NOTE: cannot be used with `widelyAvailableOnDate`.
|
|
27
44
|
*/
|
|
28
45
|
targetYear?: number;
|
|
29
46
|
};
|
|
30
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Returns browser versions compatible with specified Baseline targets.
|
|
49
|
+
* Defaults to returning the minimum versions of the core browser set that support Baseline Widely available.
|
|
50
|
+
* Takes an optional configuraation object `Object` with four optional properties:
|
|
51
|
+
* - `listAllCompatibleVersions`: `false` (default) or `false`
|
|
52
|
+
* - `includeDownstreamBrowsers`: `false` (default) or `false`
|
|
53
|
+
* - `widelyAvailableOnDate`: date in format `YYYY-MM-DD`
|
|
54
|
+
* - `targetYear`: year in format `YYYY`
|
|
55
|
+
*/
|
|
56
|
+
export declare function getCompatibleVersions(userOptions?: Options): BrowserVersion[];
|
|
57
|
+
type AllVersionsOptions = {
|
|
58
|
+
/**
|
|
59
|
+
* Whether to return the output as a Javascript `Array` (`array`) or a CSV string (`csv`).
|
|
60
|
+
* Defaults to `array`.
|
|
61
|
+
*/
|
|
62
|
+
outputFormat?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Whether to include browsers that use the same engines as a core Baseline browser.
|
|
65
|
+
* Defaults to `false`.
|
|
66
|
+
*/
|
|
67
|
+
includeDownstreamBrowsers?: boolean;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Returns all browser versions known to this module with their level of Baseline support either as an `Array` or a `String` CSV.
|
|
71
|
+
* Takes an object as an argument with two optional properties:
|
|
72
|
+
* - `includeDownstreamBrowsers`: `true` (default) or `false`
|
|
73
|
+
* - `outputFormat`: `array` (default), `object` or `csv`
|
|
74
|
+
*/
|
|
75
|
+
export declare function getAllVersions(userOptions?: AllVersionsOptions): AllBrowsersBrowserVersion[] | NestedBrowserVersions | string;
|
|
31
76
|
export {};
|
|
@@ -34,6 +34,9 @@ const stripLTEPrefix = (str) => {
|
|
|
34
34
|
return str.slice(1);
|
|
35
35
|
};
|
|
36
36
|
const compareVersions = (incomingVersionString, previousVersionString) => {
|
|
37
|
+
if (incomingVersionString === previousVersionString) {
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
37
40
|
let [incomingVersionStringMajor, incomingVersionStringMinor] = incomingVersionString.split(".");
|
|
38
41
|
let [previousVersionStringMajor, previousVersionStringMinor] = previousVersionString.split(".");
|
|
39
42
|
if (!incomingVersionStringMajor || !previousVersionStringMajor) {
|
|
@@ -55,7 +58,7 @@ const compareVersions = (incomingVersionString, previousVersionString) => {
|
|
|
55
58
|
return 1;
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
|
-
return
|
|
61
|
+
return -1;
|
|
59
62
|
};
|
|
60
63
|
const getCompatibleFeaturesByDate = (date) => {
|
|
61
64
|
const compatibleFeatures = new Array();
|
|
@@ -133,8 +136,8 @@ const getSubsequentVersions = (minimumVersions) => {
|
|
|
133
136
|
return subsequentVersions;
|
|
134
137
|
};
|
|
135
138
|
const getCoreVersionsByDate = (date, listAllCompatibleVersions = false) => {
|
|
136
|
-
if (date.getFullYear() <
|
|
137
|
-
throw new Error("There are no browser versions compatible with Baseline before
|
|
139
|
+
if (date.getFullYear() < 2016) {
|
|
140
|
+
throw new Error("There are no browser versions compatible with Baseline before 2016");
|
|
138
141
|
}
|
|
139
142
|
if (date.getFullYear() > new Date().getFullYear()) {
|
|
140
143
|
throw new Error("There are no browser versions compatible with Baseline in the future");
|
|
@@ -195,25 +198,33 @@ const getDownstreamBrowsers = (inputArray = [], listAllCompatibleVersions = true
|
|
|
195
198
|
const versionEntry = sortedAndFilteredVersions[i];
|
|
196
199
|
if (versionEntry) {
|
|
197
200
|
const [versionNumber, versionData] = versionEntry;
|
|
198
|
-
let
|
|
201
|
+
let outputArray = {
|
|
199
202
|
browser: browserName,
|
|
200
203
|
version: versionNumber,
|
|
201
204
|
release_date: versionData.release_date ?? "unknown",
|
|
202
205
|
};
|
|
203
206
|
if (versionData.engine && versionData.engine_version) {
|
|
204
|
-
|
|
205
|
-
|
|
207
|
+
outputArray.engine = versionData.engine;
|
|
208
|
+
outputArray.engine_version = versionData.engine_version;
|
|
206
209
|
}
|
|
207
|
-
downstreamArray.push(
|
|
210
|
+
downstreamArray.push(outputArray);
|
|
208
211
|
if (!listAllCompatibleVersions) {
|
|
209
212
|
break;
|
|
210
213
|
}
|
|
211
214
|
}
|
|
212
215
|
}
|
|
213
216
|
});
|
|
214
|
-
|
|
215
|
-
return outputArray;
|
|
217
|
+
return downstreamArray;
|
|
216
218
|
};
|
|
219
|
+
/**
|
|
220
|
+
* Returns browser versions compatible with specified Baseline targets.
|
|
221
|
+
* Defaults to returning the minimum versions of the core browser set that support Baseline Widely available.
|
|
222
|
+
* Takes an optional configuraation object `Object` with four optional properties:
|
|
223
|
+
* - `listAllCompatibleVersions`: `false` (default) or `false`
|
|
224
|
+
* - `includeDownstreamBrowsers`: `false` (default) or `false`
|
|
225
|
+
* - `widelyAvailableOnDate`: date in format `YYYY-MM-DD`
|
|
226
|
+
* - `targetYear`: year in format `YYYY`
|
|
227
|
+
*/
|
|
217
228
|
export function getCompatibleVersions(userOptions) {
|
|
218
229
|
let incomingOptions = userOptions ?? {};
|
|
219
230
|
let options = {
|
|
@@ -238,13 +249,137 @@ export function getCompatibleVersions(userOptions) {
|
|
|
238
249
|
}
|
|
239
250
|
// Sets a cutoff date for feature interoperability 30 months before the stated date
|
|
240
251
|
if (options.widelyAvailableOnDate || options.targetYear === undefined) {
|
|
241
|
-
targetDate.setMonth(
|
|
252
|
+
targetDate.setMonth(targetDate.getMonth() - 30);
|
|
242
253
|
}
|
|
243
254
|
let coreBrowserArray = getCoreVersionsByDate(targetDate, options.listAllCompatibleVersions);
|
|
244
255
|
if (options.includeDownstreamBrowsers === false) {
|
|
245
256
|
return coreBrowserArray;
|
|
246
257
|
}
|
|
247
258
|
else {
|
|
248
|
-
return
|
|
259
|
+
return [
|
|
260
|
+
...coreBrowserArray,
|
|
261
|
+
...getDownstreamBrowsers(coreBrowserArray, options.listAllCompatibleVersions),
|
|
262
|
+
];
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Returns all browser versions known to this module with their level of Baseline support either as an `Array` or a `String` CSV.
|
|
267
|
+
* Takes an object as an argument with two optional properties:
|
|
268
|
+
* - `includeDownstreamBrowsers`: `true` (default) or `false`
|
|
269
|
+
* - `outputFormat`: `array` (default), `object` or `csv`
|
|
270
|
+
*/
|
|
271
|
+
export function getAllVersions(userOptions) {
|
|
272
|
+
let incomingOptions = userOptions ?? {};
|
|
273
|
+
let options = {
|
|
274
|
+
outputFormat: incomingOptions.outputFormat ?? "array",
|
|
275
|
+
includeDownstreamBrowsers: incomingOptions.includeDownstreamBrowsers ?? false,
|
|
276
|
+
};
|
|
277
|
+
let nextYear = new Date().getFullYear() + 1;
|
|
278
|
+
const yearArray = [...Array(nextYear).keys()].slice(2016);
|
|
279
|
+
const yearMinimumVersions = {};
|
|
280
|
+
yearArray.forEach((year) => {
|
|
281
|
+
yearMinimumVersions[year] = {};
|
|
282
|
+
getCompatibleVersions({ targetYear: year }).forEach((version) => {
|
|
283
|
+
if (yearMinimumVersions[year])
|
|
284
|
+
yearMinimumVersions[year][version.browser] = version;
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
const waMinimumVersions = getCompatibleVersions({});
|
|
288
|
+
const waObject = {};
|
|
289
|
+
waMinimumVersions.forEach((version) => {
|
|
290
|
+
waObject[version.browser] = version;
|
|
291
|
+
});
|
|
292
|
+
const allVersions = getCompatibleVersions({
|
|
293
|
+
targetYear: 2016,
|
|
294
|
+
listAllCompatibleVersions: true,
|
|
295
|
+
});
|
|
296
|
+
const outputArray = new Array();
|
|
297
|
+
bcdCoreBrowserNames.forEach((browserName) => {
|
|
298
|
+
let thisBrowserAllVersions = allVersions
|
|
299
|
+
.filter((version) => version.browser == browserName)
|
|
300
|
+
.sort((a, b) => {
|
|
301
|
+
return compareVersions(a.version, b.version);
|
|
302
|
+
});
|
|
303
|
+
let waVersion = waObject[browserName]?.version ?? "0";
|
|
304
|
+
yearArray.forEach((year) => {
|
|
305
|
+
if (yearMinimumVersions[year]) {
|
|
306
|
+
let minBrowserVersionInfo = yearMinimumVersions[year][browserName] ?? {
|
|
307
|
+
version: "0",
|
|
308
|
+
};
|
|
309
|
+
let minBrowserVersion = minBrowserVersionInfo.version;
|
|
310
|
+
let sliceIndex = thisBrowserAllVersions.findIndex((element) => compareVersions(element.version, minBrowserVersion) === 0);
|
|
311
|
+
let subArray = year === nextYear - 1
|
|
312
|
+
? thisBrowserAllVersions
|
|
313
|
+
: thisBrowserAllVersions.slice(0, sliceIndex);
|
|
314
|
+
subArray.forEach((version) => {
|
|
315
|
+
let iswa_compatible = compareVersions(version.version, waVersion) >= 0 ? true : false;
|
|
316
|
+
outputArray.push({
|
|
317
|
+
...version,
|
|
318
|
+
year: year - 1,
|
|
319
|
+
wa_compatible: iswa_compatible,
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
thisBrowserAllVersions = thisBrowserAllVersions.slice(sliceIndex, thisBrowserAllVersions.length);
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
if (options.includeDownstreamBrowsers) {
|
|
327
|
+
let downstreamBrowsers = getDownstreamBrowsers(outputArray);
|
|
328
|
+
downstreamBrowsers.forEach((version) => {
|
|
329
|
+
let correspondingChromiumVersion = outputArray.find((upstreamVersion) => upstreamVersion.browser === "chrome" &&
|
|
330
|
+
upstreamVersion.version === version.engine_version);
|
|
331
|
+
if (correspondingChromiumVersion) {
|
|
332
|
+
outputArray.push({
|
|
333
|
+
...version,
|
|
334
|
+
year: correspondingChromiumVersion.year,
|
|
335
|
+
wa_compatible: correspondingChromiumVersion.wa_compatible,
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
});
|
|
249
339
|
}
|
|
340
|
+
outputArray.sort((a, b) => {
|
|
341
|
+
if (a.year < b.year) {
|
|
342
|
+
return -1;
|
|
343
|
+
}
|
|
344
|
+
else if (a.browser > b.browser) {
|
|
345
|
+
return 1;
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
return compareVersions(a.version, b.version);
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
if (options.outputFormat === "object") {
|
|
352
|
+
const outputObject = {};
|
|
353
|
+
outputArray.forEach((version) => {
|
|
354
|
+
if (!outputObject[version.browser]) {
|
|
355
|
+
outputObject[version.browser] = {};
|
|
356
|
+
}
|
|
357
|
+
//@ts-ignore
|
|
358
|
+
outputObject[version.browser][version.version] = {
|
|
359
|
+
year: version.year,
|
|
360
|
+
wa_compatible: version.wa_compatible,
|
|
361
|
+
release_date: version.release_date,
|
|
362
|
+
engine: version.engine,
|
|
363
|
+
engine_version: version.engine_version,
|
|
364
|
+
};
|
|
365
|
+
});
|
|
366
|
+
return outputObject ?? {};
|
|
367
|
+
}
|
|
368
|
+
if (options.outputFormat === "csv") {
|
|
369
|
+
let outputString = `"browser","version","year","wa_compatible","release_date","engine","engine_version"`;
|
|
370
|
+
outputArray.forEach((version) => {
|
|
371
|
+
let outputs = {
|
|
372
|
+
browser: version.browser,
|
|
373
|
+
version: version.version,
|
|
374
|
+
year: version.year,
|
|
375
|
+
wa_compatible: version.wa_compatible,
|
|
376
|
+
release_date: version.release_date ?? "NULL",
|
|
377
|
+
engine: version.engine ?? "NULL",
|
|
378
|
+
engine_version: version.engine_version ?? "NULL",
|
|
379
|
+
};
|
|
380
|
+
outputString += `\n"${outputs.browser}","${outputs.version}","${outputs.year}","${outputs.wa_compatible}","${outputs.release_date}","${outputs.engine}","${outputs.engine_version}"`;
|
|
381
|
+
});
|
|
382
|
+
return outputString;
|
|
383
|
+
}
|
|
384
|
+
return outputArray;
|
|
250
385
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "baseline-browser-mapping",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "A library for obtaining browser versions with their maximum supported Baseline feature set and Widely Available status.",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js"
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
18
18
|
"prepare": "rm -rf dist; prettier . --write; tsc",
|
|
19
|
-
"refresh-downstream": "npx tsx scripts/refresh-downstream.ts"
|
|
19
|
+
"refresh-downstream": "npx tsx scripts/refresh-downstream.ts",
|
|
20
|
+
"refresh-static": "npx tsx scripts/refresh-static.ts"
|
|
20
21
|
},
|
|
21
22
|
"license": "Apache-2.0",
|
|
22
23
|
"dependencies": {
|