-
Notifications
You must be signed in to change notification settings - Fork 247
/
vue-meta.d.ts
236 lines (195 loc) · 5.59 KB
/
vue-meta.d.ts
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
import './vue'
import Vue, { ComponentOptions, PluginFunction } from 'vue'
type Component = ComponentOptions<Vue> | typeof Vue
type CallbackFn = () => void
type elements = HTMLElement[]
export interface VueMetaOptionsRuntime {
refreshOnceOnNavigation?: boolean
debounceWait?: number
waitOnDestroyed?: boolean
}
export interface VueMetaOptions extends VueMetaOptionsRuntime {
keyName: string, // the component option name that vue-meta looks for meta info on.
attribute: string, // the attribute name vue-meta adds to the tags it observes
ssrAppId: string, // the app id used for ssr app
ssrAttribute: string, // the attribute name that lets vue-meta know that meta info has already been server-rendered
tagIDKeyName: string // the property name that vue-meta uses to determine whether to overwrite or append a tag
}
export declare class VueMeta {
static version: string
static install(vue: typeof Vue, options?: VueMetaOptions): PluginFunction<never>
static hasMetaInfo(vm: Component): boolean
static generate(metaInfo: MetaInfo, options?: Object): MetaInfoSSR
}
interface RefreshedTags {
addedTags: elements
removedTags: elements
}
interface Refreshed {
vm: Component,
metaInfo: MetaInfo,
tags: RefreshedTags
}
interface VueMetaApp {
set(metaInfo: MetaInfo): void | RefreshedTags
remove(): void
}
export interface VueMetaPlugin {
getOptions(): VueMetaOptions
setOptions(runtimeOptions: VueMetaOptionsRuntime): VueMetaOptions
addApp(appName: string): VueMetaApp
refresh(): Refreshed
inject(): MetaInfoSSR
pause(refresh: true): () => Refreshed
pause(refresh?: boolean): () => void
resume(refresh: true): Refreshed
resume(refresh?: boolean): void
}
export interface AttributeProperty {
[key: string]: string | string[]
}
export interface MetaDataProperty {
vmid?: string,
once?: boolean,
skip?: boolean,
body?: boolean,
pbody?: boolean,
[key: string]: any
}
export interface MetaPropertyCharset extends MetaDataProperty {
charset: string,
}
export interface MetaPropertyEquiv extends MetaDataProperty {
httpEquiv: string,
content: string,
template?: (chunk: string) => string
}
export interface MetaPropertyName extends MetaDataProperty {
name: string,
content: string,
template?: (chunk: string) => string
}
export interface MetaPropertyMicrodata extends MetaDataProperty {
itemprop: string,
content: string,
template?: (chunk: string) => string
}
// non-w3c interface
export interface MetaPropertyProperty extends MetaDataProperty {
property: string,
content: string,
template?: (chunk: string) => string
}
export interface LinkPropertyBase extends MetaDataProperty {
rel: string,
crossOrigin?: string | null,
media?: string,
nonce?: string,
referrerPolicy?: string,
rev?: string,
type?: string
}
export interface LinkPropertyHref extends LinkPropertyBase {
href?: string,
hreflang?: string,
callback?: void
}
export interface LinkPropertyHrefCallback extends LinkPropertyBase {
vmid: string,
callback: CallbackFn,
href?: string,
hreflang?: string
}
export interface StyleProperty extends MetaDataProperty {
cssText: string,
callback?: CallbackFn
media?: string,
nonce?: string,
type?: string,
}
export interface ScriptPropertyBase extends MetaDataProperty {
type?: string,
charset?: string,
async?: boolean,
defer?: boolean,
crossOrigin?: string,
nonce?: string
}
export interface ScriptPropertyText extends ScriptPropertyBase {
innerHTML: string
}
export interface ScriptPropertySrc extends ScriptPropertyBase {
src: string,
callback?: void
}
export interface ScriptPropertySrcCallback extends ScriptPropertyBase {
vmid: string,
callback: CallbackFn
}
type JsonVal = string | number | boolean | JsonObj | JsonObj[] | null
interface JsonObj {
[key: string]: JsonVal | JsonVal[]
}
export interface ScriptPropertyJson extends ScriptPropertyBase {
json: JsonObj
}
export interface NoScriptProperty extends MetaDataProperty {
innerHTML: string,
}
export interface MetaInfo {
title?: string
titleTemplate?: string | ((titleChunk: string) => string),
titleChunk?: string,
htmlAttrs?: AttributeProperty
headAttrs?: AttributeProperty
bodyAttrs?: AttributeProperty
base?: {
target: string,
href: string
}
meta?: (MetaPropertyCharset | MetaPropertyEquiv | MetaPropertyName | MetaPropertyMicrodata | MetaPropertyProperty)[]
link?: (LinkPropertyBase | LinkPropertyHref | LinkPropertyHrefCallback)[]
style?: StyleProperty[]
script?: (ScriptPropertyText | ScriptPropertySrc | ScriptPropertySrcCallback | ScriptPropertyJson)[]
noscript?: NoScriptProperty[]
__dangerouslyDisableSanitizers?: string[]
__dangerouslyDisableSanitizersByTagID?: {
[key: string]: string[]
}
changed?: <T extends MetaInfo>(newInfo: T, addedTags: elements, removedTags: elements) => void
afterNavigation?: <T extends MetaInfo>(newInfo: T) => void
}
export type MetaInfoComputed = () => MetaInfo
interface ToText {
text(): string
}
interface ToTextBooleanArg {
text(addSrrAttribute?: boolean): string
}
interface AddLineBreakOption {
ln: boolean
}
interface ToBodyTextOption {
body: boolean
}
interface ToPbodyTextOption {
pbody: boolean
}
interface ToBodyText {
text(options?: (ToBodyTextOption | ToPbodyTextOption | AddLineBreakOption)): string
}
export interface MetaInfoSSR {
head(ln?: boolean): string
bodyPrepend(ln?: boolean): string
bodyAppend(ln?: boolean): string
title?: ToText
htmlAttrs?: ToTextBooleanArg
headAttrs?: ToText
bodyAttrs?: ToText
base?: ToBodyText
meta?: ToBodyText
link?: ToBodyText
style?: ToBodyText
script?: ToBodyText
noscript?: ToBodyText
}