Skip to content

Commit dae968b

Browse files
committed
types: update types for v2.3
1 parent 2231ec1 commit dae968b

File tree

4 files changed

+54
-15
lines changed

4 files changed

+54
-15
lines changed

Diff for: docs/api/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ Calling [`inject`](#meta-inject) will return an object on which you can call the
727727

728728
### head <Badge text="v2.3+"/>
729729
- arguments
730-
- ln (type `boolean`, default: `true`)
730+
- ln (type `boolean`, default: `false`)
731731

732732
This is a convenience method which will retrieve the template string which should be added to the `head`.
733733

@@ -737,15 +737,15 @@ By passing `ln = true` a line break will be added after each element. This could
737737

738738
### bodyPrepend <Badge text="v2.3+"/>
739739
- arguments
740-
- ln (type `boolean`, default: `true`)
740+
- ln (type `boolean`, default: `false`)
741741

742742
This is a convenience method which will retrieve the template string which should be prepended to the body, i.e. listed just after `<body>`.
743743

744744
Elements will be printed in the same order as the menu below.
745745

746746
### bodyAppend <Badge text="v2.3+"/>
747747
- arguments
748-
- ln (type `boolean`, default: `true`)
748+
- ln (type `boolean`, default: `false`)
749749

750750
This is a convenience method which will retrieve the template string which should be appended to the body, i.e. listed just before `</body>`.
751751

Diff for: types/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default VueMeta
66
export {
77
VueMetaOptions,
88
VueMetaPlugin,
9+
VueMetaApp,
910
MetaInfo,
1011
MetaInfoSSR,
1112
AttributeProperty,

Diff for: types/test/index.ts

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import Vue, { ComponentOptions } from 'vue'
2-
import VueMeta, { VueMetaPlugin, VueMetaOptions, MetaInfo, MetaInfoSSR } from '../index'
2+
import VueMeta, {
3+
VueMetaPlugin,
4+
VueMetaOptions,
5+
VueMetaApp,
6+
MetaInfo,
7+
MetaInfoSSR,
8+
MetaPropertyCharset
9+
} from '../index'
310

411
Vue.use(VueMeta, {
512
keyName: 'head'
@@ -67,6 +74,16 @@ if (metaDataSSR.script) {
6774
metaDataSSR.script.text({ body: true })
6875
}
6976

77+
// add app
78+
const customApp: VueMetaApp = $meta.addApp('custom-app')
79+
80+
const metaCharset: MetaPropertyCharset = { charset: 'utf-8' }
81+
const customAppInfo: MetaInfo = {
82+
meta: [metaCharset]
83+
}
84+
85+
customApp.set(customAppInfo)
86+
7087
// pausing & resuming
7188
let resume
7289
resume = $meta.pause()

Diff for: types/vue-meta.d.ts

+32-11
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ type Component = ComponentOptions<Vue> | typeof Vue
55
type CallbackFn = () => void
66
type elements = HTMLElement[]
77

8-
export interface VueMetaOptions {
8+
export interface VueMetaOptionsRuntime {
9+
refreshOnceOnNavigation?: boolean
10+
debounceWait?: number
11+
waitOnDestroyed?: boolean
12+
}
13+
14+
export interface VueMetaOptions extends VueMetaOptionsRuntime {
915
keyName: string, // the component option name that vue-meta looks for meta info on.
1016
attribute: string, // the attribute name vue-meta adds to the tags it observes
1117
ssrAppId: string, // the app id used for ssr app
1218
ssrAttribute: string, // the attribute name that lets vue-meta know that meta info has already been server-rendered
1319
tagIDKeyName: string // the property name that vue-meta uses to determine whether to overwrite or append a tag
14-
refreshOnceOnNavigation: boolean
1520
}
1621

1722
export declare class VueMeta {
@@ -21,17 +26,26 @@ export declare class VueMeta {
2126
static generate(metaInfo: MetaInfo, options?: Object): MetaInfoSSR
2227
}
2328

29+
interface RefreshedTags {
30+
addedTags: elements
31+
removedTags: elements
32+
}
33+
2434
interface Refreshed {
2535
vm: Component,
2636
metaInfo: MetaInfo,
27-
tags: {
28-
addedTags: elements
29-
removedTags: elements
30-
}
37+
tags: RefreshedTags
38+
}
39+
40+
interface VueMetaApp {
41+
set(metaInfo: MetaInfo): void | RefreshedTags
42+
remove(): void
3143
}
3244

3345
export interface VueMetaPlugin {
3446
getOptions(): VueMetaOptions
47+
setOptions(runtimeOptions: VueMetaOptionsRuntime): VueMetaOptions
48+
addApp(appName: string): VueMetaApp
3549
refresh(): Refreshed
3650
inject(): MetaInfoSSR
3751
pause(refresh: true): () => Refreshed
@@ -188,6 +202,10 @@ interface ToTextBooleanArg {
188202
text(addSrrAttribute?: boolean): string
189203
}
190204

205+
interface AddLineBreakOption {
206+
ln: boolean
207+
}
208+
191209
interface ToBodyTextOption {
192210
body: boolean
193211
}
@@ -197,18 +215,21 @@ interface ToPbodyTextOption {
197215
}
198216

199217
interface ToBodyText {
200-
text(options?: (ToBodyTextOption | ToPbodyTextOption)): string
218+
text(options?: (ToBodyTextOption | ToPbodyTextOption | AddLineBreakOption)): string
201219
}
202220

203221
export interface MetaInfoSSR {
222+
head(ln?: boolean): string
223+
bodyPrepend(ln?: boolean): string
224+
bodyAppend(ln?: boolean): string
204225
title?: ToText
205226
htmlAttrs?: ToTextBooleanArg
206227
headAttrs?: ToText
207228
bodyAttrs?: ToText
208-
base?: ToText
209-
meta?: ToText
210-
link?: ToText
211-
style?: ToText
229+
base?: ToBodyText
230+
meta?: ToBodyText
231+
link?: ToBodyText
232+
style?: ToBodyText
212233
script?: ToBodyText
213234
noscript?: ToBodyText
214235
}

0 commit comments

Comments
 (0)