Skip to content

Commit

Permalink
feat: global hook version check
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Feb 14, 2022
1 parent 228b217 commit b513878
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/app-backend-core/src/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @param {Window|global} target
*/
export function installHook (target, isIframe = false) {
const devtoolsVersion = '6.0'
let listeners = {}

function injectIframeHook (iframe) {
Expand Down Expand Up @@ -49,7 +50,12 @@ export function installHook (target, isIframe = false) {
}
}, 1000)

if (Object.prototype.hasOwnProperty.call(target, '__VUE_DEVTOOLS_GLOBAL_HOOK__')) return
if (Object.prototype.hasOwnProperty.call(target, '__VUE_DEVTOOLS_GLOBAL_HOOK__')) {
if (target.__VUE_DEVTOOLS_GLOBAL_HOOK__.devtoolsVersion !== devtoolsVersion) {
console.error(`Another version of Vue Devtools seems to be installed. Please enable only one version at a time.`)
}
return
}

let hook

Expand All @@ -68,6 +74,7 @@ export function installHook (target, isIframe = false) {
}

hook = {
devtoolsVersion,
// eslint-disable-next-line accessor-pairs
set Vue (value) {
sendToParent(hook => { hook.Vue = value })
Expand Down Expand Up @@ -96,6 +103,7 @@ export function installHook (target, isIframe = false) {
}
} else {
hook = {
devtoolsVersion,
Vue: null,
enabled: undefined,
_buffer: [],
Expand Down

0 comments on commit b513878

Please sign in to comment.