Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish browser release data #1514

Merged
merged 3 commits into from
Aug 7, 2024
Merged
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
22 changes: 19 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ 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';
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;
Expand Down Expand Up @@ -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<WebFeaturesData["browsers"]> = {};
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 };

1 change: 1 addition & 0 deletions packages/compute-baseline/src/baseline/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
79 changes: 79 additions & 0 deletions schemas/data.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@
"$ref": "#/definitions/WebFeaturesData",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"BrowserData": {
"additionalProperties": false,
"description": "Browser information",
"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": {
Expand Down Expand Up @@ -236,6 +258,25 @@
],
"type": "object"
},
"Release": {
"additionalProperties": false,
"description": "Browser release information",
"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": {
Expand All @@ -258,6 +299,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": [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice touch, publishing the core browser set in the schema as well, indirectly.

"chrome",
"chrome_android",
"edge",
"firefox",
"firefox_android",
"safari",
"safari_ios"
],
"type": "object"
},
"features": {
"additionalProperties": {
"$ref": "#/definitions/FeatureData"
Expand All @@ -281,6 +359,7 @@
}
},
"required": [
"browsers",
"features",
"groups",
"snapshots"
Expand Down
23 changes: 21 additions & 2 deletions types.ts
Original file line number Diff line number Diff line change
@@ -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 */
Expand All @@ -7,6 +9,23 @@ 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;
/** The browser's releases */
releases: Release[];
}

/** Browser release information */
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;
Expand All @@ -28,7 +47,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";

Expand All @@ -41,7 +60,7 @@ interface Status {
baseline_high_date?: string;
/** Browser versions that most-recently introduced the feature */
support: {
[K in browserIdentifier]?: string;
[K in BrowserIdentifier]?: string;
};
}

Expand Down