vite-plugin-vue-devtools 8.1.1 → 8.1.2

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/src/overlay.js CHANGED
@@ -41,7 +41,20 @@ link.href = `${overlayDir}/devtools-overlay.css`
41
41
 
42
42
  // create script
43
43
  const script = document.createElement('script')
44
- script.src = `${overlayDir}/devtools-overlay.mjs`
44
+ const scriptUrl = `${overlayDir}/devtools-overlay.mjs`
45
+ // Under a `require-trusted-types-for 'script'` CSP, assigning a string to
46
+ // `script.src` is blocked. Wrap the URL in a TrustedScriptURL via a named
47
+ // policy so apps can opt-in by allowing `vue-devtools` in their CSP's
48
+ // `trusted-types` directive.
49
+ if (typeof window !== 'undefined' && window.trustedTypes && typeof window.trustedTypes.createPolicy === 'function') {
50
+ const policy = window.trustedTypes.createPolicy('vue-devtools', {
51
+ createScriptURL: input => input,
52
+ })
53
+ script.src = policy.createScriptURL(scriptUrl)
54
+ }
55
+ else {
56
+ script.src = scriptUrl
57
+ }
45
58
  script.type = 'module'
46
59
 
47
60
  // append to head