From 4b4be0f67d62f1b7604983f1363b69da749f0f38 Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Fri, 26 Jul 2024 12:33:40 +0200 Subject: [PATCH 1/2] Publish browser release data --- index.ts | 22 +++++- .../compute-baseline/src/baseline/index.ts | 1 + packages/web-features/package-lock.json | 4 +- packages/web-features/package.json | 2 +- schemas/data.schema.json | 77 +++++++++++++++++++ types.ts | 20 ++++- 6 files changed, 118 insertions(+), 8 deletions(-) diff --git a/index.ts b/index.ts index afc734c5107..87d3eec680c 100644 --- a/index.ts +++ b/index.ts @@ -4,7 +4,7 @@ import path from 'path'; import { Temporal } from '@js-temporal/polyfill'; import { fdir } from 'fdir'; import YAML from 'yaml'; -import { FeatureData, GroupData, SnapshotData } from './types'; +import { FeatureData, GroupData, SnapshotData, WebFeaturesData } from './types'; import { toString as hastTreeToString } from 'hast-util-to-string'; import rehypeStringify from 'rehype-stringify'; @@ -12,7 +12,8 @@ import remarkParse from 'remark-parse'; import remarkRehype from 'remark-rehype'; import { unified } from 'unified'; -import { BASELINE_LOW_TO_HIGH_DURATION, parseRangedDateString } from 'compute-baseline'; +import { BASELINE_LOW_TO_HIGH_DURATION, coreBrowserSet, parseRangedDateString } from 'compute-baseline'; +import { Compat } from 'compute-baseline/browser-compat-data'; // The longest name allowed, to allow for compact display. const nameMaxLength = 80; @@ -181,4 +182,19 @@ for (const [key, data] of yamlEntries('features')) { features[key] = data; } -export { features, groups, snapshots }; +const compat = new Compat(); +const browsers: Partial = {}; +for (const browser of coreBrowserSet.map(identifier => compat.browser(identifier))) { + const { id, name } = browser; + const releases = browser.releases.filter(release => !release.isPrerelease()).map(release => ({ + version: release.version, + date: String(release.date), + })) + browsers[id] = { + name, + releases, + } +} + +export { browsers, features, groups, snapshots }; + diff --git a/packages/compute-baseline/src/baseline/index.ts b/packages/compute-baseline/src/baseline/index.ts index 3bbe7d837a8..daef84fea90 100644 --- a/packages/compute-baseline/src/baseline/index.ts +++ b/packages/compute-baseline/src/baseline/index.ts @@ -16,6 +16,7 @@ import { } from "./support.js"; // Include this in the public API +export { identifiers as coreBrowserSet } from "./core-browser-set.js"; export { parseRangedDateString } from "./date-utils.js"; interface Logger { diff --git a/packages/web-features/package-lock.json b/packages/web-features/package-lock.json index db02891eb70..f58ae4a702f 100644 --- a/packages/web-features/package-lock.json +++ b/packages/web-features/package-lock.json @@ -1,12 +1,12 @@ { "name": "web-features", - "version": "1.0.0", + "version": "1.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "web-features", - "version": "1.0.0", + "version": "1.1.0", "license": "Apache-2.0", "devDependencies": { "tsup": "^8.0.1", diff --git a/packages/web-features/package.json b/packages/web-features/package.json index 6799812f47f..8c2ad8cb99e 100644 --- a/packages/web-features/package.json +++ b/packages/web-features/package.json @@ -1,7 +1,7 @@ { "name": "web-features", "description": "Curated list of Web platform features", - "version": "1.0.0", + "version": "1.1.0", "license": "Apache-2.0", "repository": { "type": "git", diff --git a/schemas/data.schema.json b/schemas/data.schema.json index 8d07d51fcd8..2a8a840684b 100644 --- a/schemas/data.schema.json +++ b/schemas/data.schema.json @@ -1,6 +1,27 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { + "BrowserData": { + "additionalProperties": false, + "properties": { + "name": { + "description": "The name of the browser, as in \"Edge\" or \"Safari on iOS\"", + "type": "string" + }, + "releases": { + "description": "The browser's releases", + "items": { + "$ref": "#/definitions/Release" + }, + "type": "array" + } + }, + "required": [ + "name", + "releases" + ], + "type": "object" + }, "FeatureData": { "additionalProperties": false, "properties": { @@ -173,6 +194,24 @@ ], "type": "object" }, + "Release": { + "additionalProperties": false, + "properties": { + "date": { + "description": "The release date, as in \"2023-12-11\"", + "type": "string" + }, + "version": { + "description": "The version string, as in \"10\" or \"17.1\"", + "type": "string" + } + }, + "required": [ + "version", + "date" + ], + "type": "object" + }, "SnapshotData": { "additionalProperties": false, "properties": { @@ -195,6 +234,43 @@ "WebFeaturesData": { "additionalProperties": false, "properties": { + "browsers": { + "additionalProperties": false, + "description": "Browsers and browser release data", + "properties": { + "chrome": { + "$ref": "#/definitions/BrowserData" + }, + "chrome_android": { + "$ref": "#/definitions/BrowserData" + }, + "edge": { + "$ref": "#/definitions/BrowserData" + }, + "firefox": { + "$ref": "#/definitions/BrowserData" + }, + "firefox_android": { + "$ref": "#/definitions/BrowserData" + }, + "safari": { + "$ref": "#/definitions/BrowserData" + }, + "safari_ios": { + "$ref": "#/definitions/BrowserData" + } + }, + "required": [ + "chrome", + "chrome_android", + "edge", + "firefox", + "firefox_android", + "safari", + "safari_ios" + ], + "type": "object" + }, "features": { "additionalProperties": { "$ref": "#/definitions/FeatureData" @@ -218,6 +294,7 @@ } }, "required": [ + "browsers", "features", "groups", "snapshots" diff --git a/types.ts b/types.ts index 524999a9504..422f01bdc5e 100644 --- a/types.ts +++ b/types.ts @@ -1,4 +1,6 @@ export interface WebFeaturesData { + /** Browsers and browser release data */ + browsers: { [key in BrowserIdentifier]: BrowserData }; /** Feature identifiers and data */ features: { [key: string]: FeatureData }; /** Group identifiers and data */ @@ -7,6 +9,20 @@ export interface WebFeaturesData { snapshots: { [key: string]: SnapshotData }; } +export interface BrowserData { + /** The name of the browser, as in "Edge" or "Safari on iOS" */ + name: string; + /** The browser's releases */ + releases: Release[]; +} + +export interface Release { + /** The version string, as in "10" or "17.1" */ + version: string; + /** The release date, as in "2023-12-11" */ + date: string; +} + export interface FeatureData { /** Short name */ name: string; @@ -28,7 +44,7 @@ export interface FeatureData { compat_features?: string[]; } -type browserIdentifier = "chrome" | "chrome_android" | "edge" | "firefox" | "firefox_android" | "safari" | "safari_ios"; +type BrowserIdentifier = "chrome" | "chrome_android" | "edge" | "firefox" | "firefox_android" | "safari" | "safari_ios"; type BaselineHighLow = "high" | "low"; @@ -41,7 +57,7 @@ interface SupportStatus { baseline_high_date?: string; /** Browser versions that most-recently introduced the feature */ support: { - [K in browserIdentifier]?: string; + [K in BrowserIdentifier]?: string; }; } From b5405e1b41aa0440e1478e2fe0a7833f34373db4 Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Wed, 7 Aug 2024 15:01:08 +0200 Subject: [PATCH 2/2] Add some missing descriptive strings --- schemas/data.schema.json | 2 ++ types.ts | 3 +++ 2 files changed, 5 insertions(+) diff --git a/schemas/data.schema.json b/schemas/data.schema.json index 3e4f22943aa..99363c4d78a 100644 --- a/schemas/data.schema.json +++ b/schemas/data.schema.json @@ -4,6 +4,7 @@ "definitions": { "BrowserData": { "additionalProperties": false, + "description": "Browser information", "properties": { "name": { "description": "The name of the browser, as in \"Edge\" or \"Safari on iOS\"", @@ -259,6 +260,7 @@ }, "Release": { "additionalProperties": false, + "description": "Browser release information", "properties": { "date": { "description": "The release date, as in \"2023-12-11\"", diff --git a/types.ts b/types.ts index 09ef2d77c8d..6d51e26b912 100644 --- a/types.ts +++ b/types.ts @@ -9,6 +9,8 @@ export interface WebFeaturesData { snapshots: { [key: string]: SnapshotData }; } + +/** Browser information */ export interface BrowserData { /** The name of the browser, as in "Edge" or "Safari on iOS" */ name: string; @@ -16,6 +18,7 @@ export interface BrowserData { releases: Release[]; } +/** Browser release information */ export interface Release { /** The version string, as in "10" or "17.1" */ version: string;