Skip to content
Open
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
6 changes: 6 additions & 0 deletions packages/compute-baseline/src/baseline/core-browser-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ export const identifiers = [
"safari_ios",
];

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

export function browsers(compat: Compat) {
return identifiers.map((b) => compat.browser(b));
}

export function webViews(compat: Compat) {
return webViewIdentifiers.map((b) => compat.browser(b));
}
49 changes: 49 additions & 0 deletions packages/compute-baseline/src/baseline/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,55 @@ describe("computeBaseline", function () {
});
assert.equal(actual.baseline, false);
});

it("computes support data for android and ios webviews", function () {
const result = computeBaseline({
compatKeys: ["css.properties.border-color"],
checkAncestors: true,
});

const androidWebview = [...result.ecosystem_support.keys()].find(
(b) => b.id === "webview_android",
);
const iosWebview = [...result.ecosystem_support.keys()].find(
(b) => b.id === "webview_ios",
);

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

const androidWebviewSupport = result.ecosystem_support.get(androidWebview);
const iosWebviewSupport = result.ecosystem_support.get(iosWebview);

assert(androidWebviewSupport, "android_webview should have support data");
assert(iosWebviewSupport, "ios_webview should have support data");
});

it("shows no support for android and ios webviews", function () {
const result = computeBaseline({
compatKeys: ["api.ServiceWorkerRegistration.backgroundFetch"],
checkAncestors: true,
});

const androidWebview = [...result.ecosystem_support.keys()].find(
(b) => b.id === "webview_android",
);
const iosWebview = [...result.ecosystem_support.keys()].find(
(b) => b.id === "webview_ios",
);

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

const androidWebviewSupport = result.ecosystem_support.get(androidWebview);
const iosWebviewSupport = result.ecosystem_support.get(iosWebview);

assert(
!androidWebviewSupport,
"android_webview should have no support data",
);
assert(!iosWebviewSupport, "ios_webview should have no support data");
});
});

describe("keystoneDateToStatus()", function () {
Expand Down
42 changes: 41 additions & 1 deletion packages/compute-baseline/src/baseline/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ exports[`computeBaseline disregards support that's been removed 1`] = `
\\"support\\": {
\\"safari\\": \\"8\\",
\\"safari_ios\\": \\"8\\"
},
\\"ecosystem_support\\": {
\\"webview_ios\\": \\"8\\"
}
}"
`;
Expand All @@ -23,6 +26,9 @@ exports[`computeBaseline finds discrepancies with ancestors (checkAncestors) 1`]
\\"firefox_android\\": \\"64\\",
\\"safari\\": \\"16.4\\",
\\"safari_ios\\": \\"16.4\\"
},
\\"ecosystem_support\\": {
\\"webview_android\\": \\"69\\"
}
}"
`;
Expand All @@ -37,6 +43,9 @@ exports[`computeBaseline finds discrepancies with ancestors (checkAncestors) 2`]
\\"firefox\\": \\"64\\",
\\"firefox_android\\": \\"64\\",
\\"safari\\": \\"16.4\\"
},
\\"ecosystem_support\\": {
\\"webview_android\\": \\"71\\"
}
}"
`;
Expand All @@ -51,6 +60,9 @@ exports[`computeBaseline finds discrepancies with ancestors (checkAncestors) 3`]
\\"firefox\\": \\"64\\",
\\"firefox_android\\": \\"64\\",
\\"safari\\": \\"16.4\\"
},
\\"ecosystem_support\\": {
\\"webview_android\\": \\"71\\"
}
}"
`;
Expand All @@ -62,7 +74,8 @@ Object {
\\"support\\": {
\\"firefox\\": \\"82\\",
\\"firefox_android\\": \\"82\\"
}
},
\\"ecosystem_support\\": {}
}",
"html.elements.form.target": "{
\\"baseline\\": \\"high\\",
Expand All @@ -76,6 +89,10 @@ Object {
\\"firefox_android\\": \\"4\\",
\\"safari\\": \\"3\\",
\\"safari_ios\\": \\"2\\"
},
\\"ecosystem_support\\": {
\\"webview_android\\": \\"4.4\\",
\\"webview_ios\\": \\"2\\"
}
}",
"html.global_attributes.exportparts": "{
Expand All @@ -90,6 +107,10 @@ Object {
\\"firefox_android\\": \\"79\\",
\\"safari\\": \\"13.1\\",
\\"safari_ios\\": \\"13.4\\"
},
\\"ecosystem_support\\": {
\\"webview_android\\": \\"73\\",
\\"webview_ios\\": \\"13.4\\"
}
}",
}
Expand All @@ -109,6 +130,10 @@ Object {
\\"firefox_android\\": \\"33\\",
\\"safari\\": \\"11\\",
\\"safari_ios\\": \\"11\\"
},
\\"ecosystem_support\\": {
\\"webview_android\\": \\"61\\",
\\"webview_ios\\": \\"11\\"
}
}",
"api.Document.visibilitychange_event": "{
Expand All @@ -123,6 +148,10 @@ Object {
\\"firefox_android\\": \\"56\\",
\\"safari\\": \\"14.1\\",
\\"safari_ios\\": \\"14.5\\"
},
\\"ecosystem_support\\": {
\\"webview_android\\": \\"62\\",
\\"webview_ios\\": \\"14.5\\"
}
}",
"css.types.basic-shape.path": "{
Expand All @@ -137,13 +166,20 @@ Object {
\\"firefox_android\\": \\"79\\",
\\"safari\\": \\"13.1\\",
\\"safari_ios\\": \\"13\\"
},
\\"ecosystem_support\\": {
\\"webview_android\\": \\"52\\",
\\"webview_ios\\": \\"13\\"
}
}",
"css.types.image.cross-fade": "{
\\"baseline\\": false,
\\"support\\": {
\\"safari\\": \\"10\\",
\\"safari_ios\\": \\"9.3\\"
},
\\"ecosystem_support\\": {
\\"webview_ios\\": \\"9.3\\"
}
}",
}
Expand All @@ -154,6 +190,10 @@ Object {
"baseline": "high",
"baseline_high_date": "2019-09-27",
"baseline_low_date": "2017-03-27",
"ecosystem_support": Object {
"webview_android": "42",
"webview_ios": "10.3",
},
"support": Object {
"chrome": "42",
"chrome_android": "42",
Expand Down
20 changes: 18 additions & 2 deletions packages/compute-baseline/src/baseline/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Temporal } from "@js-temporal/polyfill";
import { Browser } from "../browser-compat-data/browser.js";
import { Compat, defaultCompat } from "../browser-compat-data/compat.js";
import { feature } from "../browser-compat-data/feature.js";
import { browsers } from "./core-browser-set.js";
import { browsers, webViews } from "./core-browser-set.js";
import {
parseRangedDateString,
toHighDate,
Expand All @@ -16,7 +16,7 @@ import {
} from "./support.js";

// Include this in the public API
export { identifiers as coreBrowserSet } from "./core-browser-set.js";
export { identifiers as coreBrowserSet, webViews } from "./core-browser-set.js";
export { parseRangedDateString } from "./date-utils.js";

interface Logger {
Expand Down Expand Up @@ -50,6 +50,7 @@ interface SupportDetails {
baseline_high_date: BaselineDate;
discouraged: boolean;
support: Map<Browser, InitialSupport | undefined>;
ecosystem_support: Map<Browser, InitialSupport | undefined>;
toJSON: () => string;
}

Expand All @@ -59,6 +60,7 @@ interface SupportStatus {
baseline_low_date: string;
baseline_high_date?: string;
support: Record<string, string>;
ecosystem_support?: Record<string, string>;
}

/**
Expand Down Expand Up @@ -114,6 +116,7 @@ export function computeBaseline(

const statuses = keys.map((key) => calculate(key, compat));
const support = collateSupport(statuses.map((status) => status.support));
const ecosystem_support = collateSupport(statuses.map((status) => status.ecosystem_support));

const keystoneDate = findKeystoneDate(
statuses.flatMap((s) => [...s.support.values()]),
Expand All @@ -128,6 +131,7 @@ export function computeBaseline(
baseline_high_date,
discouraged,
support,
ecosystem_support,
toJSON: function () {
return jsonify(this);
},
Expand All @@ -143,7 +147,9 @@ function calculate(compatKey: string, compat: Compat) {

return {
discouraged: f.deprecated ?? false,
supportForBaseline: support(f, browsers(compat)),
support: support(f, browsers(compat)),
ecosystem_support: support(f, webViews(compat)),
};
}

Expand Down Expand Up @@ -286,20 +292,28 @@ function findKeystoneDate(
function jsonify(status: SupportDetails): string {
const { baseline_low_date, baseline_high_date } = status;
const support: Record<string, string> = {};
const ecosystem_support: Record<string, string> = {};

for (const [browser, initialSupport] of status.support.entries()) {
if (initialSupport !== undefined) {
support[browser.id] = initialSupport.text;
}
}

for (const [browser, initialSupport] of status.ecosystem_support.entries()) {
if (initialSupport !== undefined) {
ecosystem_support[browser.id] = initialSupport.text;
}
}

if (status.baseline === "high") {
return JSON.stringify(
{
baseline: status.baseline,
baseline_low_date,
baseline_high_date,
support,
ecosystem_support
},
undefined,
2,
Expand All @@ -312,6 +326,7 @@ function jsonify(status: SupportDetails): string {
baseline: status.baseline,
baseline_low_date,
support,
ecosystem_support
},
undefined,
2,
Expand All @@ -322,6 +337,7 @@ function jsonify(status: SupportDetails): string {
{
baseline: status.baseline,
support,
ecosystem_support
},
undefined,
2,
Expand Down
14 changes: 14 additions & 0 deletions schemas/data.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,19 @@
}
},
"additionalProperties": false
},
"ecosystem_support": {
"description": "Support in user agents that are not part of the core browser set.",
"type": "object",
"properties": {
"webview_android": {
"type": "string"
},
"webview_ios": {
"type": "string"
}
},
"additionalProperties": false
}
},
"required": ["baseline", "support"]
Expand All @@ -310,6 +323,7 @@
"baseline_high_date": {},
"baseline_low_date": {},
"support": {},
"ecosystem_support": {},
"by_compat_key": {
"description": "Statuses for each key in the feature's compat_features list, if applicable.",
"type": "object",
Expand Down
4 changes: 3 additions & 1 deletion scripts/dist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ function toDist(sourcePath: string): YAML.Document {
}

computedStatus = JSON.parse(computedStatus.toJSON());
delete computedStatus.ecosystem_support;

if (source.status) {
if (isDeepStrictEqual(source.status, computedStatus)) {
Expand All @@ -294,7 +295,8 @@ function toDist(sourcePath: string): YAML.Document {
// Map between status object and BCD keys with that computed status.
const groups = new Map<SupportStatus, string[]>();
for (const key of compatFeatures) {
const status = getStatus(id, key);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { ecosystem_support: _, ...status } = getStatus(id, key);
let added = false;
for (const [existingKey, list] of groups.entries()) {
if (isDeepStrictEqual(status, existingKey)) {
Expand Down
16 changes: 16 additions & 0 deletions types.quicktype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ export interface StatusHeadline {
* Statuses for each key in the feature's compat_features list, if applicable.
*/
by_compat_key?: { [key: string]: Status };
/**
* Support in user agents that are not part of the core browser set.
*/
ecosystem_support?: EcosystemSupport;
/**
* Browser versions that most-recently introduced the feature
*/
Expand All @@ -192,13 +196,25 @@ export interface Status {
* Date the feature achieved Baseline low status
*/
baseline_low_date?: string;
/**
* Support in user agents that are not part of the core browser set.
*/
ecosystem_support?: EcosystemSupport;
/**
* Browser versions that most-recently introduced the feature
*/
support: Support;
[property: string]: any;
}

/**
* Support in user agents that are not part of the core browser set.
*/
export interface EcosystemSupport {
webview_android?: string;
webview_ios?: string;
}

/**
* Browser versions that most-recently introduced the feature
*/
Expand Down