1 |
|
2 |
|
3 | import config from '../config'
|
4 | import { initUse } from './use'
|
5 | import { initMixin } from './mixin'
|
6 | import { initExtend } from './extend'
|
7 | import { initAssetRegisters } from './assets'
|
8 | import { set, del } from '../observer/index'
|
9 | import { ASSET_TYPES } from 'shared/constants'
|
10 | import builtInComponents from '../components/index'
|
11 | import { observe } from 'core/observer/index'
|
12 |
|
13 | import {
|
14 | warn,
|
15 | extend,
|
16 | nextTick,
|
17 | mergeOptions,
|
18 | defineReactive
|
19 | } from '../util/index'
|
20 |
|
21 | export function initGlobalAPI (Vue: GlobalAPI) {
|
22 |
|
23 | const configDef = {}
|
24 | configDef.get = () => config
|
25 | if (process.env.NODE_ENV !== 'production') {
|
26 | configDef.set = () => {
|
27 | warn(
|
28 | 'Do not replace the Vue.config object, set individual fields instead.'
|
29 | )
|
30 | }
|
31 | }
|
32 | Object.defineProperty(Vue, 'config', configDef)
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | Vue.util = {
|
38 | warn,
|
39 | extend,
|
40 | mergeOptions,
|
41 | defineReactive
|
42 | }
|
43 |
|
44 | Vue.set = set
|
45 | Vue.delete = del
|
46 | Vue.nextTick = nextTick
|
47 |
|
48 | // 2.6 explicit observable API
|
49 | Vue.observable = <T>(obj: T): T => {
|
50 | observe(obj)
|
51 | return obj
|
52 | }
|
53 |
|
54 | Vue.options = Object.create(null)
|
55 | ASSET_TYPES.forEach(type => {
|
56 | Vue.options[type + 's'] = Object.create(null)
|
57 | })
|
58 |
|
59 |
|
60 |
|
61 | Vue.options._base = Vue
|
62 |
|
63 | extend(Vue.options.components, builtInComponents)
|
64 |
|
65 | initUse(Vue)
|
66 | initMixin(Vue)
|
67 | initExtend(Vue)
|
68 | initAssetRegisters(Vue)
|
69 | }
|