File size: 1,277 Bytes
4d70170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { getComponentName } from '@vue-devtools/shared-utils'
import type { AppRecord } from '@vue-devtools/app-backend-api'

export function isBeingDestroyed(instance) {
  return instance._isBeingDestroyed
}

/**
 * Get the appropriate display name for an instance.
 */
export function getInstanceName(instance) {
  const name = getComponentName(instance.$options || instance.fnOptions || {})
  if (name) {
    return name
  }
  return instance.$root === instance
    ? 'Root'
    : 'Anonymous Component'
}

export function getRenderKey(value): string {
  if (value == null) {
    return
  }
  const type = typeof value
  if (type === 'number') {
    return value.toString()
  }
  else if (type === 'string') {
    return `'${value}'`
  }
  else if (Array.isArray(value)) {
    return 'Array'
  }
  else {
    return 'Object'
  }
}

/**
 * Returns a devtools unique id for instance.
 */
export function getUniqueId(instance, appRecord?: AppRecord): string {
  if (instance.__VUE_DEVTOOLS_UID__ != null) {
    return instance.__VUE_DEVTOOLS_UID__
  }
  let rootVueId = instance.$root.__VUE_DEVTOOLS_APP_RECORD_ID__
  if (!rootVueId && appRecord) {
    rootVueId = appRecord.id
  }
  if (!rootVueId) {
    rootVueId = '_unmounted'
  }
  return `${rootVueId}:${instance._uid}`
}