@jsenv/core 24.5.4 → 24.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,8 @@
1
1
  import { userAgentToVersion, firstMatch } from "./util.js"
2
2
 
3
- export const detectChrome = () => userAgentToBrowser(window.navigator.userAgent)
3
+ export const detectChrome = () => {
4
+ return userAgentToBrowser(window.navigator.userAgent)
5
+ }
4
6
 
5
7
  const userAgentToBrowser = (userAgent) => {
6
8
  if (/chromium/i.test(userAgent)) {
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Prefer window.navigator.userAgentData before resorting to
3
+ * window.navigator.userAgent because of
4
+ * https://blog.chromium.org/2021/09/user-agent-reduction-origin-trial-and-dates.html
5
+ */
6
+
7
+ export const detectFromUserAgentData = () => {
8
+ const { userAgentData } = window.navigator
9
+ if (!userAgentData) {
10
+ return null
11
+ }
12
+
13
+ const { brands } = userAgentData
14
+ let i = 0
15
+ while (i < brands.length) {
16
+ const { brand, version } = brands[i]
17
+ i++
18
+ if (brand === "chromium" || brand === "Google Chrome") {
19
+ return {
20
+ name: "chrome",
21
+ version,
22
+ }
23
+ }
24
+ }
25
+ return null
26
+ }
@@ -27,6 +27,10 @@ export const jsenvServiceWorkerFinalizer = (
27
27
  buildUrl,
28
28
  serviceWorkerBuildUrl,
29
29
  )
30
+ if (urlRelativeToServiceWorker === "") {
31
+ // don't put the service worker itself
32
+ return
33
+ }
30
34
  const versioned = fileNameContainsHash(buildRelativeUrl)
31
35
  const rollupFile = rollupBuild[buildRelativeUrl]
32
36