1
import { install } from './install'
2

3
// Types
4
import Vue from 'vue'
5
import {
6
  UserVuetifyPreset,
7
  VuetifyPreset,
8
} from 'vuetify/types/services/presets'
9
import {
10
  VuetifyService,
11
  VuetifyServiceContract,
12
} from 'vuetify/types/services'
13

14
// Services
15
import * as services from './services'
16

17
export default class Vuetify {
18 1
  static install = install
19

20 1
  static installed = false
21

22 1
  static version = __VUETIFY_VERSION__
23

24 1
  static config = {
25
    silent: false,
26
  }
27

28 1
  public framework: Dictionary<VuetifyServiceContract> = {
29
    isHydrating: false,
30
  } as any
31

32 1
  public installed: string[] = []
33

34 1
  public preset = {} as VuetifyPreset
35

36 1
  public userPreset: UserVuetifyPreset = {}
37

38 1
  constructor (userPreset: UserVuetifyPreset = {}) {
39 1
    this.userPreset = userPreset
40

41 1
    this.use(services.Presets)
42 1
    this.use(services.Application)
43 1
    this.use(services.Breakpoint)
44 1
    this.use(services.Goto)
45 1
    this.use(services.Icons)
46 1
    this.use(services.Lang)
47 1
    this.use(services.Theme)
48
  }
49

50
  // Called on the new vuetify instance
51
  // bootstrap in install beforeCreate
52
  // Exposes ssrContext if available
53 0
  init (root: Vue, ssrContext?: object) {
54 0
    this.installed.forEach(property => {
55 0
      const service = this.framework[property]
56

57 0
      service.framework = this.framework
58

59 0
      service.init(root, ssrContext)
60
    })
61

62
    // rtl is not installed and
63
    // will never be called by
64
    // the init process
65 0
    this.framework.rtl = Boolean(this.preset.rtl) as any
66
  }
67

68
  // Instantiate a VuetifyService
69 1
  use (Service: VuetifyService) {
70 1
    const property = Service.property
71

72 1
    if (this.installed.includes(property)) return
73

74
    // TODO maybe a specific type for arg 2?
75 1
    this.framework[property] = new Service(this.preset, this as any)
76 1
    this.installed.push(property)
77
  }
78
}

Read our documentation on viewing source code .

Loading