Skip to content

Commit 4d72a3a

Browse files
authored
Adds supports field option to getAllVersions() (#29)
* Adds a new `supports` field when `getAllVersions()` receives `useSupports: true`. This field describes whether a browser version supports `newly` available, `widely` available or just `year_only`. * Adds new static file exports including these fields and updates the `refresh-static.ts` script to include these exports. * Updates README to explain new options. * Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 22.13.5 to 22.15.3. * Bumps [web-features](https://github.com/web-platform-dx/web-features/tree/HEAD/packages/web-features) from 2.31.0 to 2.34.1. * Bumps [@mdn/browser-compat-data](https://github.com/mdn/browser-compat-data) from 6.0.1 to 6.0.9.
1 parent 377e916 commit 4d72a3a

13 files changed

+1560
-52
lines changed

README.md

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,34 @@ By default, this function returns an `Array` of `Objects` and excludes downstrea
165165
[
166166
...
167167
{
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
168+
browser: "firefox_android", // Browser name
169+
version: "125", // Browser version
170+
release_date: "2024-04-16", // Release date
171+
year: 2023, // Baseline year feature set the version supports
172+
wa_compatible: true // Whether the browser version supports Widely available
173173
},
174174
...
175175
]
176176
```
177177

178+
### Understanding which browsers support Newly available features
179+
180+
You may want to understand which recent browser versions support all Newly available features. You can replace the `wa_compatible` property with a `supports` property using the `useSupport` option:
181+
182+
```javascript
183+
getAllVersions({
184+
useSupports: true,
185+
});
186+
```
187+
188+
The `supports` property has three possible values:
189+
190+
- `year_only` for browser versions that do not support all Baseline Widely available Newly Available features.
191+
- `widely` for browser versions that support all Widely available features.
192+
- `newly` for browser versions that support all Newly available features.
193+
194+
Browser versions that support all Newly available features also support all Widely available features.
195+
178196
### `getAllVersions()` Configuration options
179197

180198
`getAllVersions()` accepts an `Object` as an argument with configuration options. The defaults are as follows:
@@ -202,13 +220,13 @@ Downstream browsers include the same properties as core browsers, as well as the
202220
[
203221
...
204222
{
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
223+
browser: "samsunginternet_android",
224+
version: "27.0",
225+
release_date: "2024-11-06",
226+
engine: "Blink",
227+
engine_version: "125",
228+
year: 2023,
229+
supports: "widely"
212230
},
213231
...
214232
]
@@ -233,7 +251,7 @@ In thise case, `getAllVersions()` returns a nested object with the browser [IDs
233251
"chrome": {
234252
"53": {
235253
"year": 2016,
236-
"wa_compatible": false,
254+
"supports": "year_only",
237255
"release_date": "2016-09-07"
238256
},
239257
...
@@ -248,7 +266,7 @@ Downstream browsers will include extra fields for `engine` and `engine_versions`
248266
"webview_android": {
249267
"53": {
250268
"year": 2016,
251-
"waCompatible": false,
269+
"supports": "year_only",
252270
"release_date": "2016-09-07",
253271
"engine": "Blink",
254272
"engine_version": "53"
@@ -268,10 +286,13 @@ getAllVersions({
268286
`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`:
269287
270288
```csv
271-
"browser","version","year","wa_compatible","release_date","engine","engine_version"
272-
"chrome","53","2016","false","2016-09-07","NULL","NULL"
289+
"browser","version","year","supports","release_date","engine","engine_version"
290+
"chrome","53","2016","year_only","2016-09-07","NULL","NULL"
291+
...
292+
"firefox","135","2024","widely","2025-02-04","NULL","NULL"
293+
"firefox","136","2024","newly","2025-03-04","NULL","NULL"
273294
...
274-
"ya_android","20.12","2020","false","2020-12-20","Blink","87"
295+
"ya_android","20.12","2020","year_only","2020-12-20","Blink","87"
275296
...
276297
```
277298
@@ -286,10 +307,18 @@ The outputs of `getAllVersions()` are available as JSON or CSV files generated o
286307
- [Array](https://web-platform-dx.github.io/baseline-browser-mapping/all_versions_array.json)
287308
- [Object](https://web-platform-dx.github.io/baseline-browser-mapping/all_versions_object.json)
288309
- [CSV](https://web-platform-dx.github.io/baseline-browser-mapping/all_versions.csv)
310+
Core browsers only, with `supports` property
311+
- [Array](https://web-platform-dx.github.io/baseline-browser-mapping/all_versions_array_with_supports.json)
312+
- [Object](https://web-platform-dx.github.io/baseline-browser-mapping/all_versions_object_with_supports.json)
313+
- [CSV](https://web-platform-dx.github.io/baseline-browser-mapping/all_versions_with_supports.csv)
289314
- Including downstream browsers
290315
- [Array](https://web-platform-dx.github.io/baseline-browser-mapping/with_downstream/all_versions_array.json)
291316
- [Object](https://web-platform-dx.github.io/baseline-browser-mapping/with_downstream/all_versions_object.json)
292317
- [CSV](https://web-platform-dx.github.io/baseline-browser-mapping/with_downstream/all_versions.csv)
318+
- Including downstream browsers with `supports` property
319+
- [Array](https://web-platform-dx.github.io/baseline-browser-mapping/with_downstream/all_versions_array_with_supports.json)
320+
- [Object](https://web-platform-dx.github.io/baseline-browser-mapping/with_downstream/all_versions_object_with_supports.json)
321+
- [CSV](https://web-platform-dx.github.io/baseline-browser-mapping/with_downstream/all_versions_with_supports.csv)
293322
294323
These files are updated on a daily basis.
295324

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
},
2222
"license": "Apache-2.0",
2323
"dependencies": {
24-
"@mdn/browser-compat-data": "^6.0.1",
25-
"web-features": "^2.31.0"
24+
"@mdn/browser-compat-data": "^6.0.9",
25+
"web-features": "^2.34.1"
2626
},
2727
"devDependencies": {
28-
"@types/node": "^22.13.5",
28+
"@types/node": "^22.15.3",
2929
"prettier": "^3.5.3",
3030
"typescript": "^5.7.2"
3131
},

scripts/refresh-static.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,30 @@ writeFileSync(
1919
{ encoding: "utf-8" },
2020
);
2121

22+
writeFileSync(
23+
"./static/all_versions_array_with_supports.json",
24+
JSON.stringify(getAllVersions({ useSupports: true })),
25+
{ encoding: "utf-8" },
26+
);
27+
writeFileSync(
28+
"./static/all_versions_object_with_supports.json",
29+
JSON.stringify(
30+
getAllVersions({
31+
outputFormat: "object",
32+
useSupports: true,
33+
}),
34+
),
35+
{ encoding: "utf-8" },
36+
);
37+
writeFileSync(
38+
"./static/all_versions_with_supports.csv",
39+
getAllVersions({
40+
outputFormat: "csv",
41+
useSupports: true,
42+
}).toString(),
43+
{ encoding: "utf-8" },
44+
);
45+
2246
// Write with downstream versions
2347
writeFileSync(
2448
"./static/with_downstream/all_versions_array.json",
@@ -47,3 +71,34 @@ writeFileSync(
4771
}).toString(),
4872
{ encoding: "utf-8" },
4973
);
74+
75+
writeFileSync(
76+
"./static/with_downstream/all_versions_array_with_supports.json",
77+
JSON.stringify(
78+
getAllVersions({
79+
includeDownstreamBrowsers: true,
80+
useSupports: true,
81+
}),
82+
),
83+
{ encoding: "utf-8" },
84+
);
85+
writeFileSync(
86+
"./static/with_downstream/all_versions_object_with_supports.json",
87+
JSON.stringify(
88+
getAllVersions({
89+
outputFormat: "object",
90+
includeDownstreamBrowsers: true,
91+
useSupports: true,
92+
}),
93+
),
94+
{ encoding: "utf-8" },
95+
);
96+
writeFileSync(
97+
"./static/with_downstream/all_versions_with_supports.csv",
98+
getAllVersions({
99+
outputFormat: "csv",
100+
includeDownstreamBrowsers: true,
101+
useSupports: true,
102+
}).toString(),
103+
{ encoding: "utf-8" },
104+
);

0 commit comments

Comments
 (0)