Skip to content

Commit

Permalink
fix(vue2): get Vue from global hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Feb 9, 2022
1 parent 7bf86e5 commit dc0f5de
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions packages/app-backend-core/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { JobQueue } from './util/queue'
import { scan } from './legacy/scan'
import { addBuiltinLayers, removeLayersForApp } from './timeline'
import { getBackend, availableBackends } from './backend'
import { hook } from './global-hook.js'

const jobs = new JobQueue()

Expand All @@ -30,6 +31,10 @@ async function registerAppJob (options: AppRecordOptions, ctx: BackendContext) {
return
}

if (!options.version) {
throw new Error('[Vue Devtools] Vue version not found')
}

// Find correct backend
const baseFrameworkVersion = parseInt(options.version.substring(0, options.version.indexOf('.')))
for (let i = 0; i < availableBackends.length; i++) {
Expand Down Expand Up @@ -221,16 +226,6 @@ export async function removeApp (app: App, ctx: BackendContext) {
}
}

// eslint-disable-next-line camelcase
function _legacy_getVueFromApp (app) {
if (app.constructor.name === 'VueComponent') {
// When Vue.extend is used the component is an instance of VueComponent instead of Vue.
// VueComponent has a property super which points to the original Vue constructor
return app.constructor.super
}
return app.constructor
}

// eslint-disable-next-line camelcase
export async function _legacy_getAndRegisterApps (ctx: BackendContext) {
// Remove apps that are legacy
Expand All @@ -242,11 +237,11 @@ export async function _legacy_getAndRegisterApps (ctx: BackendContext) {

const apps = scan()
apps.forEach(app => {
const Vue = _legacy_getVueFromApp(app)
const Vue = hook.Vue
registerApp({
app,
types: {},
version: Vue.version,
version: Vue?.version,
meta: {
Vue,
},
Expand Down

0 comments on commit dc0f5de

Please sign in to comment.