Skip to content

Commit 788dcb6

Browse files
committed
refactor support to ecosystem_support
1 parent 52bba08 commit 788dcb6

8 files changed

Lines changed: 99 additions & 44 deletions

File tree

index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import YAML from 'yaml';
77
import { convertMarkdown } from "./text";
88
import { GroupData, SnapshotData, WebFeaturesData } from './types';
99

10-
import { BASELINE_LOW_TO_HIGH_DURATION, allIdentifiers, getStatus, parseRangedDateString } from 'compute-baseline';
10+
import { BASELINE_LOW_TO_HIGH_DURATION, coreBrowserSet, getStatus, parseRangedDateString } from 'compute-baseline';
1111
import { Compat } from 'compute-baseline/browser-compat-data';
1212
import { assertRequiredRemovalDateSet, assertValidFeatureReference } from './assertions';
1313
import { isMoved, isOrdinaryFeatureData, isSplit } from './type-guards';
@@ -262,7 +262,7 @@ for (const [id, feature] of Object.entries(features)) {
262262

263263
const compat = new Compat();
264264
const browsers: Partial<WebFeaturesData["browsers"]> = {};
265-
for (const browser of allIdentifiers.map(identifier => compat.browser(identifier))) {
265+
for (const browser of coreBrowserSet.map(identifier => compat.browser(identifier))) {
266266
const { id, name } = browser;
267267
const releases = browser.releases.filter(release => !release.isPrerelease()).map(release => ({
268268
version: release.version,

packages/compute-baseline/src/baseline/core-browser-set.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,10 @@ export const identifiers = [
1212

1313
export const webViewIdentifiers = ["webview_android", "webview_ios"];
1414

15-
export const allIdentifiers = [...identifiers, ...webViewIdentifiers];
16-
1715
export function browsers(compat: Compat) {
1816
return identifiers.map((b) => compat.browser(b));
1917
}
2018

2119
export function webViews(compat: Compat) {
2220
return webViewIdentifiers.map((b) => compat.browser(b));
2321
}
24-
25-
export function allBrowsers(compat: Compat) {
26-
return [...browsers(compat), ...webViews(compat)];
27-
}

packages/compute-baseline/src/baseline/index.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,18 +182,18 @@ describe("computeBaseline", function () {
182182
checkAncestors: true,
183183
});
184184

185-
const androidWebview = [...result.support.keys()].find(
185+
const androidWebview = [...result.ecosystem_support.keys()].find(
186186
(b) => b.id === "webview_android",
187187
);
188-
const iosWebview = [...result.support.keys()].find(
188+
const iosWebview = [...result.ecosystem_support.keys()].find(
189189
(b) => b.id === "webview_ios",
190190
);
191191

192192
assert(androidWebview, "android_webview should be present in support data");
193193
assert(iosWebview, "ios_webview should be present in support data");
194194

195-
const androidWebviewSupport = result.support.get(androidWebview);
196-
const iosWebviewSupport = result.support.get(iosWebview);
195+
const androidWebviewSupport = result.ecosystem_support.get(androidWebview);
196+
const iosWebviewSupport = result.ecosystem_support.get(iosWebview);
197197

198198
assert(androidWebviewSupport, "android_webview should have support data");
199199
assert(iosWebviewSupport, "ios_webview should have support data");
@@ -205,18 +205,18 @@ describe("computeBaseline", function () {
205205
checkAncestors: true,
206206
});
207207

208-
const androidWebview = [...result.support.keys()].find(
208+
const androidWebview = [...result.ecosystem_support.keys()].find(
209209
(b) => b.id === "webview_android",
210210
);
211-
const iosWebview = [...result.support.keys()].find(
211+
const iosWebview = [...result.ecosystem_support.keys()].find(
212212
(b) => b.id === "webview_ios",
213213
);
214214

215215
assert(androidWebview, "android_webview should be present in support data");
216216
assert(iosWebview, "ios_webview should be present in support data");
217217

218-
const androidWebviewSupport = result.support.get(androidWebview);
219-
const iosWebviewSupport = result.support.get(iosWebview);
218+
const androidWebviewSupport = result.ecosystem_support.get(androidWebview);
219+
const iosWebviewSupport = result.ecosystem_support.get(iosWebview);
220220

221221
assert(
222222
!androidWebviewSupport,

packages/compute-baseline/src/baseline/index.test.ts.snap

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ exports[`computeBaseline disregards support that's been removed 1`] = `
66
\\"support\\": {
77
\\"safari\\": \\"8\\",
88
\\"safari_ios\\": \\"8\\"
9+
},
10+
\\"ecosystem_support\\": {
11+
\\"webview_ios\\": \\"8\\"
912
}
1013
}"
1114
`;
@@ -23,6 +26,9 @@ exports[`computeBaseline finds discrepancies with ancestors (checkAncestors) 1`]
2326
\\"firefox_android\\": \\"64\\",
2427
\\"safari\\": \\"16.4\\",
2528
\\"safari_ios\\": \\"16.4\\"
29+
},
30+
\\"ecosystem_support\\": {
31+
\\"webview_android\\": \\"69\\"
2632
}
2733
}"
2834
`;
@@ -37,6 +43,9 @@ exports[`computeBaseline finds discrepancies with ancestors (checkAncestors) 2`]
3743
\\"firefox\\": \\"64\\",
3844
\\"firefox_android\\": \\"64\\",
3945
\\"safari\\": \\"16.4\\"
46+
},
47+
\\"ecosystem_support\\": {
48+
\\"webview_android\\": \\"71\\"
4049
}
4150
}"
4251
`;
@@ -51,6 +60,9 @@ exports[`computeBaseline finds discrepancies with ancestors (checkAncestors) 3`]
5160
\\"firefox\\": \\"64\\",
5261
\\"firefox_android\\": \\"64\\",
5362
\\"safari\\": \\"16.4\\"
63+
},
64+
\\"ecosystem_support\\": {
65+
\\"webview_android\\": \\"71\\"
5466
}
5567
}"
5668
`;
@@ -62,7 +74,8 @@ Object {
6274
\\"support\\": {
6375
\\"firefox\\": \\"82\\",
6476
\\"firefox_android\\": \\"82\\"
65-
}
77+
},
78+
\\"ecosystem_support\\": {}
6679
}",
6780
"html.elements.form.target": "{
6881
\\"baseline\\": \\"high\\",
@@ -76,6 +89,10 @@ Object {
7689
\\"firefox_android\\": \\"4\\",
7790
\\"safari\\": \\"3\\",
7891
\\"safari_ios\\": \\"2\\"
92+
},
93+
\\"ecosystem_support\\": {
94+
\\"webview_android\\": \\"4.4\\",
95+
\\"webview_ios\\": \\"2\\"
7996
}
8097
}",
8198
"html.global_attributes.exportparts": "{
@@ -90,6 +107,10 @@ Object {
90107
\\"firefox_android\\": \\"79\\",
91108
\\"safari\\": \\"13.1\\",
92109
\\"safari_ios\\": \\"13.4\\"
110+
},
111+
\\"ecosystem_support\\": {
112+
\\"webview_android\\": \\"73\\",
113+
\\"webview_ios\\": \\"13.4\\"
93114
}
94115
}",
95116
}
@@ -109,6 +130,10 @@ Object {
109130
\\"firefox_android\\": \\"33\\",
110131
\\"safari\\": \\"11\\",
111132
\\"safari_ios\\": \\"11\\"
133+
},
134+
\\"ecosystem_support\\": {
135+
\\"webview_android\\": \\"61\\",
136+
\\"webview_ios\\": \\"11\\"
112137
}
113138
}",
114139
"api.Document.visibilitychange_event": "{
@@ -123,6 +148,10 @@ Object {
123148
\\"firefox_android\\": \\"56\\",
124149
\\"safari\\": \\"14.1\\",
125150
\\"safari_ios\\": \\"14.5\\"
151+
},
152+
\\"ecosystem_support\\": {
153+
\\"webview_android\\": \\"62\\",
154+
\\"webview_ios\\": \\"14.5\\"
126155
}
127156
}",
128157
"css.types.basic-shape.path": "{
@@ -137,13 +166,20 @@ Object {
137166
\\"firefox_android\\": \\"79\\",
138167
\\"safari\\": \\"13.1\\",
139168
\\"safari_ios\\": \\"13\\"
169+
},
170+
\\"ecosystem_support\\": {
171+
\\"webview_android\\": \\"52\\",
172+
\\"webview_ios\\": \\"13\\"
140173
}
141174
}",
142175
"css.types.image.cross-fade": "{
143176
\\"baseline\\": false,
144177
\\"support\\": {
145178
\\"safari\\": \\"10\\",
146179
\\"safari_ios\\": \\"9.3\\"
180+
},
181+
\\"ecosystem_support\\": {
182+
\\"webview_ios\\": \\"9.3\\"
147183
}
148184
}",
149185
}
@@ -154,6 +190,10 @@ Object {
154190
"baseline": "high",
155191
"baseline_high_date": "2019-09-27",
156192
"baseline_low_date": "2017-03-27",
193+
"ecosystem_support": Object {
194+
"webview_android": "42",
195+
"webview_ios": "10.3",
196+
},
157197
"support": Object {
158198
"chrome": "42",
159199
"chrome_android": "42",

packages/compute-baseline/src/baseline/index.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Temporal } from "@js-temporal/polyfill";
22
import { Browser } from "../browser-compat-data/browser.js";
33
import { Compat, defaultCompat } from "../browser-compat-data/compat.js";
44
import { feature } from "../browser-compat-data/feature.js";
5-
import { browsers, allBrowsers } from "./core-browser-set.js";
5+
import { browsers, webViews } from "./core-browser-set.js";
66
import {
77
parseRangedDateString,
88
toHighDate,
@@ -16,8 +16,7 @@ import {
1616
} from "./support.js";
1717

1818
// Include this in the public API
19-
export { identifiers as coreBrowserSet, allIdentifiers } from "./core-browser-set.js";
20-
export { allBrowsers } from "./core-browser-set.js";
19+
export { identifiers as coreBrowserSet, webViews } from "./core-browser-set.js";
2120
export { parseRangedDateString } from "./date-utils.js";
2221

2322
interface Logger {
@@ -51,6 +50,7 @@ interface SupportDetails {
5150
baseline_high_date: BaselineDate;
5251
discouraged: boolean;
5352
support: Map<Browser, InitialSupport | undefined>;
53+
ecosystem_support: Map<Browser, InitialSupport | undefined>;
5454
toJSON: () => string;
5555
}
5656

@@ -60,6 +60,7 @@ interface SupportStatus {
6060
baseline_low_date: string;
6161
baseline_high_date?: string;
6262
support: Record<string, string>;
63+
ecosystem_support?: Record<string, string>;
6364
}
6465

6566
/**
@@ -114,16 +115,11 @@ export function computeBaseline(
114115
: compatKeys;
115116

116117
const statuses = keys.map((key) => calculate(key, compat));
117-
// For baseline status, use only core browsers; for support map, include all browsers (including webviews)
118-
const supportForBaseline = collateSupport(
119-
statuses.map((status) => status.supportForBaseline),
120-
);
121118
const support = collateSupport(statuses.map((status) => status.support));
122-
123-
//console.debug(support);
119+
const ecosystem_support = collateSupport(statuses.map((status) => status.ecosystem_support));
124120

125121
const keystoneDate = findKeystoneDate(
126-
[...supportForBaseline.values()],
122+
statuses.flatMap((s) => [...s.support.values()]),
127123
);
128124
const discouraged = statuses.some((s) => s.discouraged);
129125
const { baseline, baseline_low_date, baseline_high_date } =
@@ -135,6 +131,7 @@ export function computeBaseline(
135131
baseline_high_date,
136132
discouraged,
137133
support,
134+
ecosystem_support,
138135
toJSON: function () {
139136
return jsonify(this);
140137
},
@@ -151,7 +148,8 @@ function calculate(compatKey: string, compat: Compat) {
151148
return {
152149
discouraged: f.deprecated ?? false,
153150
supportForBaseline: support(f, browsers(compat)),
154-
support: support(f, allBrowsers(compat)),
151+
support: support(f, browsers(compat)),
152+
ecosystem_support: support(f, webViews(compat)),
155153
};
156154
}
157155

@@ -294,21 +292,28 @@ function findKeystoneDate(
294292
function jsonify(status: SupportDetails): string {
295293
const { baseline_low_date, baseline_high_date } = status;
296294
const support: Record<string, string> = {};
295+
const ecosystem_support: Record<string, string> = {};
297296

298297
for (const [browser, initialSupport] of status.support.entries()) {
299298
if (initialSupport !== undefined) {
300-
//console.debug(`Browser ${browser} has initial support:`, initialSupport);
301299
support[browser.id] = initialSupport.text;
302300
}
303301
}
304302

303+
for (const [browser, initialSupport] of status.ecosystem_support.entries()) {
304+
if (initialSupport !== undefined) {
305+
ecosystem_support[browser.id] = initialSupport.text;
306+
}
307+
}
308+
305309
if (status.baseline === "high") {
306310
return JSON.stringify(
307311
{
308312
baseline: status.baseline,
309313
baseline_low_date,
310314
baseline_high_date,
311315
support,
316+
ecosystem_support
312317
},
313318
undefined,
314319
2,
@@ -321,6 +326,7 @@ function jsonify(status: SupportDetails): string {
321326
baseline: status.baseline,
322327
baseline_low_date,
323328
support,
329+
ecosystem_support
324330
},
325331
undefined,
326332
2,
@@ -331,6 +337,7 @@ function jsonify(status: SupportDetails): string {
331337
{
332338
baseline: status.baseline,
333339
support,
340+
ecosystem_support
334341
},
335342
undefined,
336343
2,

schemas/data.schema.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@
2727
},
2828
"safari_ios": {
2929
"$ref": "#/definitions/BrowserData"
30-
},
31-
"webview_android": {
32-
"$ref": "#/definitions/BrowserData"
33-
},
34-
"webview_ios": {
35-
"$ref": "#/definitions/BrowserData"
3630
}
3731
},
3832
"required": [
@@ -42,9 +36,7 @@
4236
"firefox",
4337
"firefox_android",
4438
"safari",
45-
"safari_ios",
46-
"webview_android",
47-
"webview_ios"
39+
"safari_ios"
4840
],
4941
"additionalProperties": false
5042
},
@@ -303,7 +295,14 @@
303295
},
304296
"safari_ios": {
305297
"type": "string"
306-
},
298+
}
299+
},
300+
"additionalProperties": false
301+
},
302+
"ecosystem_support": {
303+
"description": "Support in user agents that are not part of the core browser set.",
304+
"type": "object",
305+
"properties": {
307306
"webview_android": {
308307
"type": "string"
309308
},
@@ -324,6 +323,7 @@
324323
"baseline_high_date": {},
325324
"baseline_low_date": {},
326325
"support": {},
326+
"ecosystem_support": {},
327327
"by_compat_key": {
328328
"description": "Statuses for each key in the feature's compat_features list, if applicable.",
329329
"type": "object",

scripts/dist.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ function toDist(sourcePath: string): YAML.Document {
282282
}
283283

284284
computedStatus = JSON.parse(computedStatus.toJSON());
285+
delete computedStatus.ecosystem_support;
285286

286287
if (source.status) {
287288
if (isDeepStrictEqual(source.status, computedStatus)) {
@@ -294,7 +295,8 @@ function toDist(sourcePath: string): YAML.Document {
294295
// Map between status object and BCD keys with that computed status.
295296
const groups = new Map<SupportStatus, string[]>();
296297
for (const key of compatFeatures) {
297-
const status = getStatus(id, key);
298+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
299+
const { ecosystem_support: _, ...status } = getStatus(id, key);
298300
let added = false;
299301
for (const [existingKey, list] of groups.entries()) {
300302
if (isDeepStrictEqual(status, existingKey)) {

0 commit comments

Comments
 (0)