UNPKG

1.56 kBPlain TextView Raw
1import { install } from './install'
2
3// Types
4import {
5 VuetifyService,
6 VuetifyServiceContract,
7} from 'vuetify/types/services'
8import { VuetifyPreset } from 'vuetify/types/presets'
9import Vue from 'vue'
10
11// Services
12import * as services from './services'
13
14// Styles
15import './styles/main.sass'
16
17export default class Vuetify {
18 static install = install
19
20 static installed = false
21
22 static version = __VUETIFY_VERSION__
23
24 framework: Record<string, VuetifyServiceContract> = {}
25
26 installed: string[] = []
27
28 preset: Partial<VuetifyPreset> = {}
29
30 constructor (preset: Partial<VuetifyPreset> = {}) {
31 this.preset = preset
32
33 this.use(services.Application)
34 this.use(services.Breakpoint)
35 this.use(services.Goto)
36 this.use(services.Icons)
37 this.use(services.Lang)
38 this.use(services.Theme)
39 }
40
41 // Called on the new vuetify instance
42 // bootstrap in install beforeCreate
43 // Exposes ssrContext if available
44 init (root: Vue, ssrContext?: object) {
45 this.installed.forEach(property => {
46 const service = this.framework[property]
47 service.framework = this.framework
48
49 service.init(root, ssrContext)
50 })
51
52 // rtl is not installed and
53 // will never be called by
54 // the init process
55 this.framework.rtl = Boolean(this.preset.rtl) as any
56 }
57
58 // Instantiate a VuetifyService
59 use (Service: VuetifyService) {
60 const property = Service.property
61
62 if (this.installed.includes(property)) return
63
64 this.framework[property] = new Service(this.preset[property])
65 this.installed.push(property)
66 }
67}