From 456abb3ae72f3be16b5b009e95bc410b5dc88fca Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Thu, 11 May 2023 01:47:10 +0000 Subject: [PATCH 01/10] Redefine browser requirements for modern (latest) builds --- .browserslistrc | 29 ++++---- build-scripts/bundle.cjs | 9 ++- build-scripts/gulp/entry-html.js | 5 ++ cast/src/html/faq.html.template | 8 +-- cast/src/html/index.html.template | 10 +-- cast/src/html/media.html.template | 10 +-- demo/src/html/index.html.template | 11 +--- hassio/src/entrypoint.js.template | 10 +-- package.json | 1 + src/html/_js_base.html.template | 5 +- ....template => _script_loader.html.template} | 8 +++ src/html/authorize.html.template | 9 +-- src/html/index.html.template | 3 +- src/html/onboarding.html.template | 9 +-- yarn.lock | 66 ++++++++++++++++++- 15 files changed, 116 insertions(+), 77 deletions(-) rename src/html/{_script_load_es5.html.template => _script_loader.html.template} (66%) diff --git a/.browserslistrc b/.browserslistrc index f5926db66fca..9d793927358e 100644 --- a/.browserslistrc +++ b/.browserslistrc @@ -1,24 +1,21 @@ [modern] -# Support for dynamic import is the main litmus test for serving modern builds. -# Although officially a ES2020 feature, browsers implemented it early, so this -# enables all of ES2017 and some features in ES2018. -supports es6-module-dynamic-import - -# Exclude Safari 11-12 because of a bug in tagged template literals -# https://bugs.webkit.org/show_bug.cgi?id=190756 -# Note: Dropping version 11 also enables several more ES2018 features -not Safari < 13 -not iOS < 13 - -# Exclude KaiOS, QQ, and UC browsers due to lack of sufficient feature support data -# Babel ignores these automatically, but we need here for Webpack to output ESM with dynamic imports +# Modern builds target recent browsers supporting the latest features to minimize transpilation, polyfills,etc. +# It is served to browsers meeting the following requirements: +# - last 2 released + current alpha/beta versionss of all major browsers +# - Firefox extended support release (ESR) +# - browsers with global utilization above 0.5% +# - must support dynamic import of ES modules +# - exclude browsers no longer being maintained +# - exclude KaiOS, QQ, and UC browsers due to lack of sufficient feature support data +unreleased versions +last 2 versions +Firefox ESR +> 0.5% and supports es6-module-dynamic-import +not dead not KaiOS > 0 not QQAndroid > 0 not UCAndroid > 0 -# Exclude unsupported browsers -not dead - [legacy] # Legacy builds are served when modern requirements are not met and support browsers: # - released in the last 7 years + current alpha/beta versionss diff --git a/build-scripts/bundle.cjs b/build-scripts/bundle.cjs index f74ddfeef33d..04fecbb00fdb 100644 --- a/build-scripts/bundle.cjs +++ b/build-scripts/bundle.cjs @@ -140,8 +140,13 @@ module.exports.babelOptions = ({ "@babel/plugin-transform-runtime", { version: dependencies["@babel/runtime"] }, ], - // Support some proposals still in TC39 process - ["@babel/plugin-proposal-decorators", { decoratorsBeforeExport: true }], + // Transpile decorators (still in TC39 process) + // Modern browsers support class fields, but transform is required with the older decorator version dictated by Lit + [ + "@babel/plugin-proposal-decorators", + { version: "2018-09", decoratorsBeforeExport: true }, + ], + "@babel/plugin-proposal-class-properties", ].filter(Boolean), exclude: [ // \\ for Windows, / for Mac OS and Linux diff --git a/build-scripts/gulp/entry-html.js b/build-scripts/gulp/entry-html.js index dd6285c3103a..0645dcfaf916 100644 --- a/build-scripts/gulp/entry-html.js +++ b/build-scripts/gulp/entry-html.js @@ -1,5 +1,6 @@ // Tasks to generate entry HTML +import { getUserAgentRegex } from "browserslist-useragent-regexp"; import fs from "fs-extra"; import gulp from "gulp"; import { minify } from "html-minifier-terser"; @@ -17,6 +18,10 @@ const renderTemplate = (templateFile, data = {}) => { ...data, useRollup: env.useRollup(), useWDS: env.useWDS(), + modernRegex: getUserAgentRegex({ + env: "modern", + allowHigherVersions: true, + }).toString(), // Resolve any child/nested templates relative to the parent and pass the same data renderTemplate: (childTemplate) => renderTemplate( diff --git a/cast/src/html/faq.html.template b/cast/src/html/faq.html.template index 80fc487bef21..ba22de72849d 100644 --- a/cast/src/html/faq.html.template +++ b/cast/src/html/faq.html.template @@ -36,13 +36,7 @@ <%= renderTemplate("../../../src/html/_js_base.html.template") %> - - <%= renderTemplate("../../../src/html/_script_load_es5.html.template") %> + <%= renderTemplate("../../../src/html/_script_loader.html.template") %> - <%= renderTemplate("../../../src/html/_js_base.html.template") %> - - <%= renderTemplate("../../../src/html/_script_load_es5.html.template") %> + <%= renderTemplate("../../../src/html/_js_base.html.template") %> + <%= renderTemplate("../../../src/html/_script_loader.html.template") %> diff --git a/demo/src/html/index.html.template b/demo/src/html/index.html.template index 6b044e44a355..4f4353d63363 100644 --- a/demo/src/html/index.html.template +++ b/demo/src/html/index.html.template @@ -83,15 +83,6 @@ <%= renderTemplate("../../../src/html/_js_base.html.template") %> <%= renderTemplate("../../../src/html/_preload_roboto.html.template") %> - - <%= renderTemplate("../../../src/html/_script_load_es5.html.template") %> + <%= renderTemplate("../../../src/html/_script_loader.html.template") %> diff --git a/hassio/src/entrypoint.js.template b/hassio/src/entrypoint.js.template index c1c4e5831ced..8cc7ba82fdc4 100644 --- a/hassio/src/entrypoint.js.template +++ b/hassio/src/entrypoint.js.template @@ -4,11 +4,7 @@ el.src = src; document.body.appendChild(el); } - if (/.*Version\/(?:11|12)(?:\.\d+)*.*Safari\//.test(navigator.userAgent)) { - <% for (const entry of es5EntryJS) { %> - loadES5("<%= entry %>"); - <% } %> - } else { + if (<%= modernRegex %>.test(navigator.userAgent)) { try { <% for (const entry of latestEntryJS) { %> new Function("import('<%= entry %>')")(); @@ -17,6 +13,10 @@ <% for (const entry of es5EntryJS) { %> loadES5("<%= entry %>"); <% } %> + } else { + <% for (const entry of es5EntryJS) { %> + loadES5("<%= entry %>"); + <% } %> } } })(); diff --git a/package.json b/package.json index cf2d567423ee..b304f2a2cf55 100644 --- a/package.json +++ b/package.json @@ -191,6 +191,7 @@ "@web/dev-server-rollup": "0.4.1", "babel-loader": "9.1.3", "babel-plugin-template-html-minifier": "4.1.0", + "browserslist-useragent-regexp": "4.1.0", "chai": "5.1.1", "del": "7.1.0", "eslint": "8.57.0", diff --git a/src/html/_js_base.html.template b/src/html/_js_base.html.template index 690cd0cd7aa9..7c94ee3fa672 100644 --- a/src/html/_js_base.html.template +++ b/src/html/_js_base.html.template @@ -16,8 +16,5 @@ ) { _ls("/static/polyfills/webcomponents-bundle.js", true); } - var isS11_12 = - /(?:.*(?:iPhone|iPad).*OS (?:11|12)_\d)|(?:.*Version\/(?:11|12)(?:\.\d+)*.*Safari\/)/.test( - navigator.userAgent - ); + var isModern = <%= modernRegex %>.test(navigator.userAgent); diff --git a/src/html/_script_load_es5.html.template b/src/html/_script_loader.html.template similarity index 66% rename from src/html/_script_load_es5.html.template rename to src/html/_script_loader.html.template index cb72d05e5ae7..5ea3f23ac476 100644 --- a/src/html/_script_load_es5.html.template +++ b/src/html/_script_loader.html.template @@ -1,3 +1,11 @@ + - <%= renderTemplate("_script_load_es5.html.template") %> diff --git a/src/html/index.html.template b/src/html/index.html.template index 7cfa93ea97b1..ef34659178e9 100644 --- a/src/html/index.html.template +++ b/src/html/index.html.template @@ -60,8 +60,7 @@ <%= renderTemplate("_js_base.html.template") %> <%= renderTemplate("_preload_roboto.html.template") %> - <%= renderTemplate("_script_load_es5.html.template") %> diff --git a/yarn.lock b/yarn.lock index 5f3af4cbd53d..af72a441d884 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5605,6 +5605,13 @@ __metadata: languageName: node linkType: hard +"argue-cli@npm:^2.1.0": + version: 2.1.0 + resolution: "argue-cli@npm:2.1.0" + checksum: 10/0b300fa171895ad8856513a29320ff3db729637f0dcf0ff2e67a2991190d69d3eb08bc9318956e4bae42b0b6e2c8761b6929364c24640cadd12b5f04a4328a06 + languageName: node + linkType: hard + "aria-query@npm:^5.1.3": version: 5.3.0 resolution: "aria-query@npm:5.3.0" @@ -6051,6 +6058,24 @@ __metadata: languageName: node linkType: hard +"browserslist-useragent-regexp@npm:4.1.0": + version: 4.1.0 + resolution: "browserslist-useragent-regexp@npm:4.1.0" + dependencies: + argue-cli: "npm:^2.1.0" + easy-table: "npm:^1.1.1" + picocolors: "npm:^1.0.0" + regexp-tree: "npm:^0.1.24" + ua-regexes-lite: "npm:^1.1.3" + peerDependencies: + browserslist: ">=4.0.0" + bin: + bluare: dist/cli.js + browserslist-useragent-regexp: dist/cli.js + checksum: 10/ab777e63928ebbff895e9f523c42f4a1c80fdff0385c6fa87ef7ba024f3e563d7e553dc7b4abb4cd46f88e6f15af1b62c95e7274e21ab9e52221326269dfe53f + languageName: node + linkType: hard + "browserslist@npm:^4.21.10, browserslist@npm:^4.23.0, browserslist@npm:^4.23.1": version: 4.23.2 resolution: "browserslist@npm:4.23.2" @@ -6950,7 +6975,7 @@ __metadata: languageName: node linkType: hard -"defaults@npm:^1.0.4": +"defaults@npm:^1.0.3, defaults@npm:^1.0.4": version: 1.0.4 resolution: "defaults@npm:1.0.4" dependencies: @@ -7173,6 +7198,19 @@ __metadata: languageName: node linkType: hard +"easy-table@npm:^1.1.1": + version: 1.2.0 + resolution: "easy-table@npm:1.2.0" + dependencies: + ansi-regex: "npm:^5.0.1" + wcwidth: "npm:^1.0.1" + dependenciesMeta: + wcwidth: + optional: true + checksum: 10/0d1be7cd9419cd1b56ca5a978646b3cff241ccd8cf95bdb2742f36854084b3aef2e9af6ec14142855aa80e4cab1f4baad0f610a99c77509f23676b8330730177 + languageName: node + linkType: hard + "ee-first@npm:1.1.1": version: 1.1.1 resolution: "ee-first@npm:1.1.1" @@ -9017,6 +9055,7 @@ __metadata: app-datepicker: "npm:5.1.1" babel-loader: "npm:9.1.3" babel-plugin-template-html-minifier: "npm:4.1.0" + browserslist-useragent-regexp: "npm:4.1.0" chai: "npm:5.1.1" chart.js: "npm:4.4.3" color-name: "npm:2.0.0" @@ -12435,6 +12474,15 @@ __metadata: languageName: node linkType: hard +"regexp-tree@npm:^0.1.24": + version: 0.1.27 + resolution: "regexp-tree@npm:0.1.27" + bin: + regexp-tree: bin/regexp-tree + checksum: 10/08c70c8adb5a0d4af1061bf9eb05d3b6e1d948c433d6b7008e4b5eb12a49429c2d6ca8e9106339a432aa0d07bd6e1bccc638d8f4ab0d045f3adad22182b300a2 + languageName: node + linkType: hard + "regexp.prototype.flags@npm:^1.5.2": version: 1.5.2 resolution: "regexp.prototype.flags@npm:1.5.2" @@ -14326,6 +14374,13 @@ __metadata: languageName: node linkType: hard +"ua-regexes-lite@npm:^1.1.3": + version: 1.1.4 + resolution: "ua-regexes-lite@npm:1.1.4" + checksum: 10/c7a746cb6171ed898eb303b903f9cc813a0d52759b80b9d2fa6d3e1ca63f739d302d7de39179df8d512f6ed03ec5299779bbb1fb05127f712eb7974febb8fef8 + languageName: node + linkType: hard + "unbox-primitive@npm:^1.0.2": version: 1.0.2 resolution: "unbox-primitive@npm:1.0.2" @@ -14744,6 +14799,15 @@ __metadata: languageName: node linkType: hard +"wcwidth@npm:^1.0.1": + version: 1.0.1 + resolution: "wcwidth@npm:1.0.1" + dependencies: + defaults: "npm:^1.0.3" + checksum: 10/182ebac8ca0b96845fae6ef44afd4619df6987fe5cf552fdee8396d3daa1fb9b8ec5c6c69855acb7b3c1231571393bd1f0a4cdc4028d421575348f64bb0a8817 + languageName: node + linkType: hard + "web-component-analyzer@npm:^2.0.0": version: 2.0.0 resolution: "web-component-analyzer@npm:2.0.0" From 8ce335847dee0a1638aa643f44cfee87fe1180c2 Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Mon, 19 Jun 2023 19:18:48 +0000 Subject: [PATCH 02/10] Rename babel class properties plugin --- build-scripts/bundle.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-scripts/bundle.cjs b/build-scripts/bundle.cjs index 04fecbb00fdb..d04bd7889a51 100644 --- a/build-scripts/bundle.cjs +++ b/build-scripts/bundle.cjs @@ -146,7 +146,7 @@ module.exports.babelOptions = ({ "@babel/plugin-proposal-decorators", { version: "2018-09", decoratorsBeforeExport: true }, ], - "@babel/plugin-proposal-class-properties", + "@babel/plugin-transform-class-properties", ].filter(Boolean), exclude: [ // \\ for Windows, / for Mac OS and Linux From 23173bac8432a369cc17dbbf30e7cad9a234c062 Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Sun, 2 Jul 2023 02:07:16 +0000 Subject: [PATCH 03/10] Fix only allowing latest Android --- build-scripts/gulp/entry-html.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build-scripts/gulp/entry-html.js b/build-scripts/gulp/entry-html.js index 0645dcfaf916..3afb7510393c 100644 --- a/build-scripts/gulp/entry-html.js +++ b/build-scripts/gulp/entry-html.js @@ -21,6 +21,8 @@ const renderTemplate = (templateFile, data = {}) => { modernRegex: getUserAgentRegex({ env: "modern", allowHigherVersions: true, + mobileToDesktop: true, + throwOnMissing: true, }).toString(), // Resolve any child/nested templates relative to the parent and pass the same data renderTemplate: (childTemplate) => From faaaeea54907bcd18f73e08af532e4ff55590c39 Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Fri, 7 Jul 2023 18:38:01 +0000 Subject: [PATCH 04/10] Add browsers released in last year --- .browserslistrc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.browserslistrc b/.browserslistrc index 9d793927358e..8c9fbb55b189 100644 --- a/.browserslistrc +++ b/.browserslistrc @@ -3,6 +3,7 @@ # It is served to browsers meeting the following requirements: # - last 2 released + current alpha/beta versionss of all major browsers # - Firefox extended support release (ESR) +# - released in the last year # - browsers with global utilization above 0.5% # - must support dynamic import of ES modules # - exclude browsers no longer being maintained @@ -10,6 +11,7 @@ unreleased versions last 2 versions Firefox ESR +last 1 year > 0.5% and supports es6-module-dynamic-import not dead not KaiOS > 0 From 8b21eeefae7d04c5e4729dd9d9b92735fd3f7d04 Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Fri, 7 Jul 2023 19:32:59 +0000 Subject: [PATCH 05/10] Use at or above for utilization (no change to browsers currently) --- .browserslistrc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.browserslistrc b/.browserslistrc index 8c9fbb55b189..6d2511a96407 100644 --- a/.browserslistrc +++ b/.browserslistrc @@ -4,7 +4,7 @@ # - last 2 released + current alpha/beta versionss of all major browsers # - Firefox extended support release (ESR) # - released in the last year -# - browsers with global utilization above 0.5% +# - with global utilization at or above 0.5% # - must support dynamic import of ES modules # - exclude browsers no longer being maintained # - exclude KaiOS, QQ, and UC browsers due to lack of sufficient feature support data @@ -12,7 +12,7 @@ unreleased versions last 2 versions Firefox ESR last 1 year -> 0.5% and supports es6-module-dynamic-import +>= 0.5% and supports es6-module-dynamic-import not dead not KaiOS > 0 not QQAndroid > 0 @@ -21,7 +21,7 @@ not UCAndroid > 0 [legacy] # Legacy builds are served when modern requirements are not met and support browsers: # - released in the last 7 years + current alpha/beta versionss -# - with global utilization above 0.05% +# - with global utilization at or above 0.05% # The lattermost query ensures that support for popular old browsers is not dropped too early # (e.g. IE 11, Android 4.4, or Samsung 4). # @@ -35,10 +35,10 @@ not UCAndroid > 0 # As of May 2023, only web sockets must be added to the query. unreleased versions last 7 years -> 0.05% and supports websockets +>= 0.05% and supports websockets [legacy-sw] # Same as legacy plus supports service workers unreleased versions last 7 years -> 0.05% and supports websockets and supports serviceworkers +>= 0.05% and supports websockets and supports serviceworkers From b3475e019e4ea166e3323931f6a0d5fb8225ee85 Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Fri, 7 Jul 2023 19:57:58 +0000 Subject: [PATCH 06/10] Only use time query (no effective change) --- .browserslistrc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.browserslistrc b/.browserslistrc index 6d2511a96407..3cc2f99388a8 100644 --- a/.browserslistrc +++ b/.browserslistrc @@ -1,17 +1,15 @@ [modern] # Modern builds target recent browsers supporting the latest features to minimize transpilation, polyfills,etc. # It is served to browsers meeting the following requirements: -# - last 2 released + current alpha/beta versionss of all major browsers +# - released in the last year + current alpha/beta versionss # - Firefox extended support release (ESR) -# - released in the last year # - with global utilization at or above 0.5% # - must support dynamic import of ES modules # - exclude browsers no longer being maintained # - exclude KaiOS, QQ, and UC browsers due to lack of sufficient feature support data unreleased versions -last 2 versions -Firefox ESR last 1 year +Firefox ESR >= 0.5% and supports es6-module-dynamic-import not dead not KaiOS > 0 From 8f1e0b90a6d99eeeab4fe15b7bc4dee150e0b554 Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Mon, 21 Aug 2023 17:53:50 +0000 Subject: [PATCH 07/10] Add transform for private methods --- build-scripts/bundle.cjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build-scripts/bundle.cjs b/build-scripts/bundle.cjs index d04bd7889a51..84e1490f995b 100644 --- a/build-scripts/bundle.cjs +++ b/build-scripts/bundle.cjs @@ -141,12 +141,13 @@ module.exports.babelOptions = ({ { version: dependencies["@babel/runtime"] }, ], // Transpile decorators (still in TC39 process) - // Modern browsers support class fields, but transform is required with the older decorator version dictated by Lit + // Modern browsers support class fields and private methods, but transform is required with the older decorator version dictated by Lit [ "@babel/plugin-proposal-decorators", { version: "2018-09", decoratorsBeforeExport: true }, ], "@babel/plugin-transform-class-properties", + "@babel/plugin-transform-private-methods", ].filter(Boolean), exclude: [ // \\ for Windows, / for Mac OS and Linux From 89dd0cc942d3e291127c403b1a4c90aea296e6b2 Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Sat, 14 Oct 2023 20:16:38 -0400 Subject: [PATCH 08/10] Fix some typos in browserslist config Co-authored-by: Quentame --- .browserslistrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.browserslistrc b/.browserslistrc index 3cc2f99388a8..f500a9360514 100644 --- a/.browserslistrc +++ b/.browserslistrc @@ -1,7 +1,7 @@ [modern] -# Modern builds target recent browsers supporting the latest features to minimize transpilation, polyfills,etc. +# Modern builds target recent browsers supporting the latest features to minimize transpilation, polyfills, etc. # It is served to browsers meeting the following requirements: -# - released in the last year + current alpha/beta versionss +# - released in the last year + current alpha/beta versions # - Firefox extended support release (ESR) # - with global utilization at or above 0.5% # - must support dynamic import of ES modules From eaa90a41e77309d93b11204eb3640743b89e9d1c Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Wed, 27 Dec 2023 20:27:15 +0000 Subject: [PATCH 09/10] bump browserslist-useragent-regex --- package.json | 2 +- yarn.lock | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index b304f2a2cf55..75b57f7d165a 100644 --- a/package.json +++ b/package.json @@ -191,7 +191,7 @@ "@web/dev-server-rollup": "0.4.1", "babel-loader": "9.1.3", "babel-plugin-template-html-minifier": "4.1.0", - "browserslist-useragent-regexp": "4.1.0", + "browserslist-useragent-regexp": "4.1.3", "chai": "5.1.1", "del": "7.1.0", "eslint": "8.57.0", diff --git a/yarn.lock b/yarn.lock index af72a441d884..561ef5f48372 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6058,21 +6058,21 @@ __metadata: languageName: node linkType: hard -"browserslist-useragent-regexp@npm:4.1.0": - version: 4.1.0 - resolution: "browserslist-useragent-regexp@npm:4.1.0" +"browserslist-useragent-regexp@npm:4.1.3": + version: 4.1.3 + resolution: "browserslist-useragent-regexp@npm:4.1.3" dependencies: argue-cli: "npm:^2.1.0" - easy-table: "npm:^1.1.1" + easy-table: "npm:^1.2.0" picocolors: "npm:^1.0.0" regexp-tree: "npm:^0.1.24" - ua-regexes-lite: "npm:^1.1.3" + ua-regexes-lite: "npm:^1.2.1" peerDependencies: browserslist: ">=4.0.0" bin: bluare: dist/cli.js browserslist-useragent-regexp: dist/cli.js - checksum: 10/ab777e63928ebbff895e9f523c42f4a1c80fdff0385c6fa87ef7ba024f3e563d7e553dc7b4abb4cd46f88e6f15af1b62c95e7274e21ab9e52221326269dfe53f + checksum: 10/f774feb5a766a0b2469c38b5a9f257213375ce106b7d50640ee529cea9c17b91da0f55c4f029fd1e075c8b846fa38cee6feb5620ea1a09f099bb0da61a7950eb languageName: node linkType: hard @@ -7198,7 +7198,7 @@ __metadata: languageName: node linkType: hard -"easy-table@npm:^1.1.1": +"easy-table@npm:^1.2.0": version: 1.2.0 resolution: "easy-table@npm:1.2.0" dependencies: @@ -9055,7 +9055,7 @@ __metadata: app-datepicker: "npm:5.1.1" babel-loader: "npm:9.1.3" babel-plugin-template-html-minifier: "npm:4.1.0" - browserslist-useragent-regexp: "npm:4.1.0" + browserslist-useragent-regexp: "npm:4.1.3" chai: "npm:5.1.1" chart.js: "npm:4.4.3" color-name: "npm:2.0.0" @@ -14374,10 +14374,10 @@ __metadata: languageName: node linkType: hard -"ua-regexes-lite@npm:^1.1.3": - version: 1.1.4 - resolution: "ua-regexes-lite@npm:1.1.4" - checksum: 10/c7a746cb6171ed898eb303b903f9cc813a0d52759b80b9d2fa6d3e1ca63f739d302d7de39179df8d512f6ed03ec5299779bbb1fb05127f712eb7974febb8fef8 +"ua-regexes-lite@npm:^1.2.1": + version: 1.2.1 + resolution: "ua-regexes-lite@npm:1.2.1" + checksum: 10/3545a3bd0bedc5a66912b5ba8248a230f0f31f6f6446dd0fa83f7bf77a5e9b206122ab30a8c4b1150bb5ffe5407da8d3b7a557adfa542c0af6bae5ebd77dd703 languageName: node linkType: hard From f1214e43180f96296dc64e072e5ed84d00e53754 Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Thu, 27 Jun 2024 16:20:36 +0000 Subject: [PATCH 10/10] Add fallback feature detection for Array.prototype.findLast --- src/html/_js_base.html.template | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/html/_js_base.html.template b/src/html/_js_base.html.template index 7c94ee3fa672..aaa55cbfdcf0 100644 --- a/src/html/_js_base.html.template +++ b/src/html/_js_base.html.template @@ -16,5 +16,9 @@ ) { _ls("/static/polyfills/webcomponents-bundle.js", true); } - var isModern = <%= modernRegex %>.test(navigator.userAgent); + // Modern browsers are detected primarily using the user agent string. + // A feature detection which roughly lines up with the modern targets is used + // as a fallback to guard against spoofs. It should be updated periodically. + var isModern = <%= modernRegex %>.test(navigator.userAgent) && + "findLast" in Array.prototype;