diff --git a/build/web-features.ts b/build/web-features.ts index 2d07c244e679..c9fca37f3735 100644 --- a/build/web-features.ts +++ b/build/web-features.ts @@ -1,14 +1,14 @@ -import webFeatures from "web-features"; +import { features } from "web-features"; -export function getWebFeatureStatus(...features: string[]) { - if (features.length === 0) { +export function getWebFeatureStatus(...bcdKeys: string[]) { + if (bcdKeys.length === 0) { return; } - for (const feature of Object.values(webFeatures)) { + for (const feature of Object.values(features)) { if ( feature.status && - feature.compat_features?.some((feature) => features.includes(feature)) + feature.compat_features?.some((feature) => bcdKeys.includes(feature)) ) { return feature.status; } diff --git a/client/src/document/baseline-indicator.tsx b/client/src/document/baseline-indicator.tsx index a2445868ff96..f217846188ad 100644 --- a/client/src/document/baseline-indicator.tsx +++ b/client/src/document/baseline-indicator.tsx @@ -7,14 +7,15 @@ import { useLocation } from "react-router"; import "./baseline-indicator.scss"; -import type { - SupportStatus, - browserIdentifier, -} from "../../../libs/types/web-features"; +// web-features doesn't export these types directly so we need to do a little typescript magic: +import type { features } from "web-features"; +type SupportStatus = (typeof features)[keyof typeof features]["status"]; +type BrowserIdentifier = + keyof (typeof features)[keyof typeof features]["status"]["support"]; interface BrowserGroup { name: string; - ids: browserIdentifier[]; + ids: BrowserIdentifier[]; } const ENGINES: { @@ -62,9 +63,11 @@ export function BaselineIndicator({ status }: { status: SupportStatus }) { LOCALIZED_BCD_IDS[locale] || LOCALIZED_BCD_IDS[DEFAULT_LOCALE] }`; + const low_date_range = status.baseline_low_date?.match(/^([^0-9])/)?.[0]; const low_date = status.baseline_low_date - ? new Date(status.baseline_low_date) + ? new Date(status.baseline_low_date.slice(low_date_range ? 1 : 0)) : undefined; + const level = status.baseline ? status.baseline : status.baseline === false diff --git a/libs/types/document.ts b/libs/types/document.ts index 33bdb7a21114..8a8990dfb106 100644 --- a/libs/types/document.ts +++ b/libs/types/document.ts @@ -1,5 +1,8 @@ import { type Locale } from "./core.js"; -import type { SupportStatus } from "./web-features.js"; + +// web-features doesn't export this type directly so we need to do a little typescript magic: +import type { features } from "web-features"; +type SupportStatus = (typeof features)[keyof typeof features]["status"]; export interface Source { folder: string; diff --git a/libs/types/web-features.ts b/libs/types/web-features.ts deleted file mode 100644 index 40802af5820f..000000000000 --- a/libs/types/web-features.ts +++ /dev/null @@ -1,53 +0,0 @@ -export type Features = { [key: string]: FeatureData }; - -// Types below copied from web-platform-dx/web-features GitHub repo: -// https://github.com/web-platform-dx/web-features/blob/5ad19b0dec722eaf6484b7d569e62e64ad7bfef0/index.ts#L8-L44 - -export interface FeatureData { - /** Alias identifier */ - alias?: string | [string, string, ...string[]]; - /** Specification */ - spec: - | specification_url - | [specification_url, specification_url, ...specification_url[]]; - /** caniuse.com identifier */ - caniuse?: string | [string, string, ...string[]]; - /** Whether a feature is considered a "baseline" web platform feature and when it achieved that status */ - status?: SupportStatus; - /** Sources of support data for this feature */ - compat_features?: string[]; - /** Usage stats */ - usage_stats?: - | usage_stats_url - | [usage_stats_url, usage_stats_url, ...usage_stats_url[]]; // A single URL or an array of two or more -} - -export type browserIdentifier = - | "chrome" - | "chrome_android" - | "edge" - | "firefox" - | "firefox_android" - | "safari" - | "safari_ios"; - -type BaselineHighLow = "high" | "low"; - -export interface SupportStatus { - /** Whether the feature is Baseline (low substatus), Baseline (high substatus), or not (false) */ - baseline?: BaselineHighLow | false; - /** Date the feature achieved Baseline low status */ - baseline_low_date?: string; - /** Browser versions that most-recently introduced the feature */ - support?: { [K in browserIdentifier]?: string }; -} - -/** Specification URL - * @format uri - */ -type specification_url = string; - -/** Usage stats URL - * @format uri - */ -type usage_stats_url = string; diff --git a/package.json b/package.json index 00fc364bc112..6b815fe3fec8 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "@mdn/bcd-utils-api": "^0.0.7", "@mdn/browser-compat-data": "^5.5.41", "@mozilla/glean": "5.0.2", - "@sentry/node": "^8.19.0", + "@sentry/node": "^8.20.0", "@stripe/stripe-js": "^4.1.0", "@use-it/interval": "^1.0.0", "@vscode/ripgrep": "^1.15.9", @@ -145,7 +145,7 @@ "unified": "^11.0.5", "unist-builder": "^4.0.0", "unist-util-visit": "^5.0.0", - "web-features": "^0.9.0", + "web-features": "^1.0.0", "web-specs": "^3.13.1" }, "devDependencies": { @@ -216,7 +216,7 @@ "mini-css-extract-plugin": "^2.9.0", "node-dev": "^8.0.0", "peggy": "^4.0.3", - "postcss": "^8.4.39", + "postcss": "^8.4.40", "postcss-flexbugs-fixes": "^5.0.2", "postcss-loader": "^8.1.1", "postcss-normalize": "^10.0.1", @@ -236,7 +236,7 @@ "resolve-url-loader": "^5.0.0", "rough-notation": "^0.5.1", "sass": "^1.77.6", - "sass-loader": "^14.2.1", + "sass-loader": "^15.0.0", "source-map-explorer": "^2.5.3", "source-map-loader": "^5.0.0", "style-loader": "^3.3.4", diff --git a/tsconfig.json b/tsconfig.json index 1e145d71f752..b04b539ef81b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,8 +12,7 @@ "front-matter": ["./type-fixes/front-matter.js"], "@mdn/browser-compat-data/types": [ "./node_modules/@mdn/browser-compat-data/types.d.ts" - ], - "web-features": ["./type-fixes/web-features.js"] + ] }, "preserveWatchOutput": true, "resolveJsonModule": true, diff --git a/type-fixes/web-features.ts b/type-fixes/web-features.ts deleted file mode 100644 index 393ea95e32bb..000000000000 --- a/type-fixes/web-features.ts +++ /dev/null @@ -1,5 +0,0 @@ -import features from "../node_modules/web-features/index.js"; - -import type { Features } from "../libs/types/web-features.js"; - -export default features as Features; diff --git a/yarn.lock b/yarn.lock index b0e4deba36b3..41c78ac87b9c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2756,18 +2756,18 @@ resolved "https://registry.yarnpkg.com/@sec-ant/readable-stream/-/readable-stream-0.4.1.tgz#60de891bb126abfdc5410fdc6166aca065f10a0c" integrity sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg== -"@sentry/core@8.19.0": - version "8.19.0" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-8.19.0.tgz#427d09ca27557ddc7c1bfa5e810b7f802836e0b4" - integrity sha512-MrgjsZCEjOJgQjIznnDSrLEy7qL+4LVpNieAvr49cV1rzBNSwGmWRnt/puVaPsLyCUgupVx/43BPUHB/HtKNUw== +"@sentry/core@8.20.0": + version "8.20.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-8.20.0.tgz#c50d082033a44295d2fe9140319f912ba1f946d3" + integrity sha512-R81snuw+67VT4aCxr6ShST/s0Y6FlwN2YczhDwaGyzumn5rlvA6A4JtQDeExduNoDDyv4T3LrmW8wlYZn3CJJw== dependencies: - "@sentry/types" "8.19.0" - "@sentry/utils" "8.19.0" + "@sentry/types" "8.20.0" + "@sentry/utils" "8.20.0" -"@sentry/node@^8.19.0": - version "8.19.0" - resolved "https://registry.yarnpkg.com/@sentry/node/-/node-8.19.0.tgz#366ca24436461b103c245867cc7881c8f5aca13c" - integrity sha512-r7AeKxfB9eE/UW0NZT3AMh+hNA65NFEwtsMYO6iI52FPLFZh0DLOvzVOeNsmsJqPpyetooUGTtUYpBdinZldWA== +"@sentry/node@^8.20.0": + version "8.20.0" + resolved "https://registry.yarnpkg.com/@sentry/node/-/node-8.20.0.tgz#dc20f03dfdec8797f2a0074ebe90044d305d1c59" + integrity sha512-i4ywT2m0Gw65U3uwI4NwiNcyqp9YF6/RsusfH1pg4YkiL/RYp7FS0MPVgMggfvoue9S3KjCgRVlzTLwFATyPXQ== dependencies: "@opentelemetry/api" "^1.9.0" "@opentelemetry/context-async-hooks" "^1.25.1" @@ -2792,33 +2792,34 @@ "@opentelemetry/sdk-trace-base" "^1.25.1" "@opentelemetry/semantic-conventions" "^1.25.1" "@prisma/instrumentation" "5.17.0" - "@sentry/core" "8.19.0" - "@sentry/opentelemetry" "8.19.0" - "@sentry/types" "8.19.0" - "@sentry/utils" "8.19.0" + "@sentry/core" "8.20.0" + "@sentry/opentelemetry" "8.20.0" + "@sentry/types" "8.20.0" + "@sentry/utils" "8.20.0" + import-in-the-middle "^1.10.0" optionalDependencies: opentelemetry-instrumentation-fetch-node "1.2.3" -"@sentry/opentelemetry@8.19.0": - version "8.19.0" - resolved "https://registry.yarnpkg.com/@sentry/opentelemetry/-/opentelemetry-8.19.0.tgz#5656cfb372e09a4e792838692885435d7b7b6cfd" - integrity sha512-L1aSxO/aJJ7D3pIlTaVOgbiZJAnUHXezobTc8j5pqFCQACjxnLMSDrt53QfFV52CcjbliDWCYe4IB8umu4DgpA== +"@sentry/opentelemetry@8.20.0": + version "8.20.0" + resolved "https://registry.yarnpkg.com/@sentry/opentelemetry/-/opentelemetry-8.20.0.tgz#5e62a361f43e6b53686037a62b82a7de51995578" + integrity sha512-NFcLK6+t9wUc4HlGKeuDn6W4KjZxZfZmWlrK2/tgC5KzG1cnVeOnWUrJzGHTa+YDDdIijpjiFUcpXGPkX3rmIg== dependencies: - "@sentry/core" "8.19.0" - "@sentry/types" "8.19.0" - "@sentry/utils" "8.19.0" + "@sentry/core" "8.20.0" + "@sentry/types" "8.20.0" + "@sentry/utils" "8.20.0" -"@sentry/types@8.19.0": - version "8.19.0" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-8.19.0.tgz#26a5d56c823c5eabbb7d6f53112da335b6d96dcb" - integrity sha512-52C8X5V7mK2KIxMJt8MV5TxXAFHqrQR1RKm1oPTwKVWm8hKr1ZYJXINymNrWvpAc3oVIKLC/sa9WFYgXQh+YlA== +"@sentry/types@8.20.0": + version "8.20.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-8.20.0.tgz#f0f50c84eb768df8b55ee7b41459fec2d39d0d5e" + integrity sha512-6IP278KojOpiAA7vrd1hjhUyn26cl0n0nGsShzic5ztCVs92sTeVRnh7MTB9irDVtAbOEyt/YH6go3h+Jia1pA== -"@sentry/utils@8.19.0": - version "8.19.0" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-8.19.0.tgz#f22df2a38327b1cff1e04ba7f11fdf1a32d3ba22" - integrity sha512-8dWJJKaUN6Hf92Oxw2TBmHchGua2W3ZmonrZTTwLvl06jcAigbiQD0MGuF5ytZP8PHx860orV+SbTGKFzfU3Pg== +"@sentry/utils@8.20.0": + version "8.20.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-8.20.0.tgz#fcbf46c8e8c8eccbf1db532b087547eb4f6c449c" + integrity sha512-+1I5H8dojURiEUGPliDwheQk8dhjp8uV1sMccR/W/zjFrt4wZyPs+Ttp/V7gzm9LDJoNek9tmELert/jQqWTgg== dependencies: - "@sentry/types" "8.19.0" + "@sentry/types" "8.20.0" "@sidvind/better-ajv-errors@2.1.3": version "2.1.3" @@ -8938,10 +8939,10 @@ import-in-the-middle@1.7.1: cjs-module-lexer "^1.2.2" module-details-from-path "^1.0.3" -import-in-the-middle@^1.8.1: - version "1.8.1" - resolved "https://registry.yarnpkg.com/import-in-the-middle/-/import-in-the-middle-1.8.1.tgz#8b51c2cc631b64e53e958d7048d2d9463ce628f8" - integrity sha512-yhRwoHtiLGvmSozNOALgjRPFI6uYsds60EoMqqnXyyv+JOIW/BrrLejuTGBt+bq0T5tLzOHrN0T7xYTm4Qt/ng== +import-in-the-middle@^1.10.0, import-in-the-middle@^1.8.1: + version "1.10.0" + resolved "https://registry.yarnpkg.com/import-in-the-middle/-/import-in-the-middle-1.10.0.tgz#f15b0841950ded8d899b635058da5646256949b1" + integrity sha512-Z1jumVdF2GwnnYfM0a/y2ts7mZbwFMgt5rRuVmLgobgahC6iKgN5MBuXjzfTIOUpq5LSU10vJIPpVKe0X89fIw== dependencies: acorn "^8.8.2" acorn-import-attributes "^1.9.5" @@ -12764,10 +12765,10 @@ postcss-value-parser@^4.1.0, postcss-value-parser@^4.2.0: resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514" integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== -postcss@^8.2.14, postcss@^8.4.28, postcss@^8.4.32, postcss@^8.4.33, postcss@^8.4.38, postcss@^8.4.39: - version "8.4.39" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.39.tgz#aa3c94998b61d3a9c259efa51db4b392e1bde0e3" - integrity sha512-0vzE+lAiG7hZl1/9I8yzKLx3aR9Xbof3fBHKunvMfOCYAtMhrsnccJY2iTURb9EZd5+pLuiNV9/c/GZJOHsgIw== +postcss@^8.2.14, postcss@^8.4.28, postcss@^8.4.32, postcss@^8.4.33, postcss@^8.4.38, postcss@^8.4.40: + version "8.4.40" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.40.tgz#eb81f2a4dd7668ed869a6db25999e02e9ad909d8" + integrity sha512-YF2kKIUzAofPMpfH6hOi2cGnv/HrUlfucspc7pDyvv7kGdqXrfj8SCl/t8owkEgKEuu8ZcRjSOxFxVLqwChZ2Q== dependencies: nanoid "^3.3.7" picocolors "^1.0.1" @@ -13778,10 +13779,10 @@ sanitize.css@*: resolved "https://registry.yarnpkg.com/sanitize.css/-/sanitize.css-13.0.0.tgz#2675553974b27964c75562ade3bd85d79879f173" integrity sha512-ZRwKbh/eQ6w9vmTjkuG0Ioi3HBwPFce0O+v//ve+aOq1oeCy7jMV2qzzAlpsNuqpqCBjjriM1lbtZbF/Q8jVyA== -sass-loader@^14.2.1: - version "14.2.1" - resolved "https://registry.yarnpkg.com/sass-loader/-/sass-loader-14.2.1.tgz#db9ad96b56dc1c1ea546101e76375d5b008fec70" - integrity sha512-G0VcnMYU18a4N7VoNDegg2OuMjYtxnqzQWARVWCIVSZwJeiL9kg8QMsuIZOplsJgTzZLF6jGxI3AClj8I9nRdQ== +sass-loader@^15.0.0: + version "15.0.0" + resolved "https://registry.yarnpkg.com/sass-loader/-/sass-loader-15.0.0.tgz#a883fda2b70c27d4a49835057da6b8d8564a419d" + integrity sha512-mbXAL7sI/fgt3skXR6xHxtKkaGyxRrGf7zrU4hLLWxBDJEcAe0QsoNy92qKttCb3zfMniTkU2kD9yakUKtW7vQ== dependencies: neo-async "^2.6.2" @@ -15824,10 +15825,10 @@ wbuf@^1.1.0, wbuf@^1.7.3: dependencies: minimalistic-assert "^1.0.0" -web-features@^0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/web-features/-/web-features-0.9.0.tgz#f46748e1cffe50e03a3331e44fcd85844cbc47d5" - integrity sha512-Y1SZbw8yt762LBfdDgD0Qe2XHpsmjcKnUKNi5HH/Y/uqJYST06ua+VFatwxvS/NIBPPuRwI0KbJl0VG606jNpg== +web-features@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/web-features/-/web-features-1.0.0.tgz#c40f74bd38a09ef9ba7b7769521a336686b5811b" + integrity sha512-U/ppX0h851Fr8LbOVMybiuH3iGWGlPi+DYXoj6VkOvXJc6VgYpSdGDosduYl/4qvW6YNlZ4IaczLgqHqbaU25A== web-namespaces@^2.0.0: version "2.0.1"