@jsenv/core 24.5.3 → 24.5.7
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.
- package/{license → LICENSE} +0 -0
- package/dist/build_manifest.js +4 -4
- package/dist/compile_proxy/asset-manifest.json +1 -1
- package/dist/compile_proxy/{compile_proxy-1dfca609.html → compile_proxy-501d6fa3.html} +36 -3
- package/dist/compile_proxy/{compile_proxy.html__inline__20-672ba17c.js.map → compile_proxy.html__inline__20-cbaf7522.js.map} +11 -4
- package/dist/redirector/asset-manifest.json +1 -1
- package/dist/redirector/{redirector-d1316407.html → redirector-d614cffb.html} +36 -3
- package/dist/redirector/{redirector.html__inline__15-4d453af0.js.map → redirector.html__inline__15-2953c307.js.map} +11 -4
- package/dist/toolbar/asset-manifest.json +1 -1
- package/dist/toolbar/{toolbar-afb71355.html → toolbar-c23caf7b.html} +36 -3
- package/dist/toolbar/{toolbar.main-feac7fa3.js.map → toolbar.main-bdbf37d1.js.map} +11 -4
- package/dist/toolbar_injector/asset-manifest.json +1 -1
- package/dist/toolbar_injector/{toolbar_injector-445d3ea0.js → toolbar_injector-52ec0940.js} +2 -2
- package/dist/toolbar_injector/{toolbar_injector-445d3ea0.js.map → toolbar_injector-52ec0940.js.map} +2 -2
- package/package.json +1 -1
- package/src/internal/browser_detection/browser_detection.js +2 -0
- package/src/internal/browser_detection/detectChrome.js +3 -1
- package/src/internal/browser_detection/user_agent_data.js +26 -0
- package/src/internal/building/asset_url_versioning.js +23 -6
- package/src/jsenvServiceWorkerFinalizer.js +4 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { userAgentToVersion, firstMatch } from "./util.js"
|
|
2
2
|
|
|
3
|
-
export const detectChrome = () =>
|
|
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.legth) {
|
|
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
|
+
}
|
|
@@ -20,14 +20,31 @@ const fileNamePatternFromRessource = (ressource) => {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
if (ressource.urlVersioningDisabled) {
|
|
23
|
-
if (ressource
|
|
24
|
-
return
|
|
23
|
+
if (canMoveToAssetsDirectory(ressource)) {
|
|
24
|
+
return assetFileNamePatternWithoutHash
|
|
25
25
|
}
|
|
26
|
-
return
|
|
26
|
+
return `[name][extname]`
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
if (ressource
|
|
30
|
-
return
|
|
29
|
+
if (canMoveToAssetsDirectory(ressource)) {
|
|
30
|
+
return assetFileNamePattern
|
|
31
31
|
}
|
|
32
|
-
return
|
|
32
|
+
return `[name]-[hash][extname]`
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const canMoveToAssetsDirectory = (ressource) => {
|
|
36
|
+
if (ressource.isEntryPoint) {
|
|
37
|
+
return false
|
|
38
|
+
}
|
|
39
|
+
// in theory js module can be moved to assets directory
|
|
40
|
+
// but that needs to be tested
|
|
41
|
+
if (ressource.isJsModule) {
|
|
42
|
+
return false
|
|
43
|
+
}
|
|
44
|
+
// service worker MUST be at the root (same level than the HTML file)
|
|
45
|
+
// otherwise it might be registered for the scope "/assets/" instead of "/"
|
|
46
|
+
if (ressource.isServiceWorker) {
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
return true
|
|
33
50
|
}
|
|
@@ -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
|
|