Skip to content

Commit dc0f5de

Browse files
committed
fix(vue2): get Vue from global hook
1 parent 7bf86e5 commit dc0f5de

File tree

1 file changed

+7
-12
lines changed
  • packages/app-backend-core/src

1 file changed

+7
-12
lines changed

packages/app-backend-core/src/app.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { JobQueue } from './util/queue'
1212
import { scan } from './legacy/scan'
1313
import { addBuiltinLayers, removeLayersForApp } from './timeline'
1414
import { getBackend, availableBackends } from './backend'
15+
import { hook } from './global-hook.js'
1516

1617
const jobs = new JobQueue()
1718

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

34+
if (!options.version) {
35+
throw new Error('[Vue Devtools] Vue version not found')
36+
}
37+
3338
// Find correct backend
3439
const baseFrameworkVersion = parseInt(options.version.substring(0, options.version.indexOf('.')))
3540
for (let i = 0; i < availableBackends.length; i++) {
@@ -221,16 +226,6 @@ export async function removeApp (app: App, ctx: BackendContext) {
221226
}
222227
}
223228

224-
// eslint-disable-next-line camelcase
225-
function _legacy_getVueFromApp (app) {
226-
if (app.constructor.name === 'VueComponent') {
227-
// When Vue.extend is used the component is an instance of VueComponent instead of Vue.
228-
// VueComponent has a property super which points to the original Vue constructor
229-
return app.constructor.super
230-
}
231-
return app.constructor
232-
}
233-
234229
// eslint-disable-next-line camelcase
235230
export async function _legacy_getAndRegisterApps (ctx: BackendContext) {
236231
// Remove apps that are legacy
@@ -242,11 +237,11 @@ export async function _legacy_getAndRegisterApps (ctx: BackendContext) {
242237

243238
const apps = scan()
244239
apps.forEach(app => {
245-
const Vue = _legacy_getVueFromApp(app)
240+
const Vue = hook.Vue
246241
registerApp({
247242
app,
248243
types: {},
249-
version: Vue.version,
244+
version: Vue?.version,
250245
meta: {
251246
Vue,
252247
},

0 commit comments

Comments
 (0)