mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-08 11:42:24 +03:00
chore: remove old types
This commit is contained in:
Vendored
-28
@@ -1,28 +0,0 @@
|
||||
import './vue'
|
||||
import { VueMeta } from './vue-meta'
|
||||
|
||||
export default VueMeta
|
||||
|
||||
export {
|
||||
VueMetaOptions,
|
||||
VueMetaPlugin,
|
||||
VueMetaApp,
|
||||
MetaInfo,
|
||||
MetaInfoSSR,
|
||||
AttributeProperty,
|
||||
LinkPropertyBase,
|
||||
LinkPropertyHref,
|
||||
LinkPropertyHrefCallback,
|
||||
MetaPropertyCharset,
|
||||
MetaPropertyEquiv,
|
||||
MetaPropertyName,
|
||||
MetaPropertyMicrodata,
|
||||
MetaPropertyProperty,
|
||||
NoScriptProperty,
|
||||
ScriptPropertyBase,
|
||||
ScriptPropertyText,
|
||||
ScriptPropertySrc,
|
||||
ScriptPropertySrcCallback,
|
||||
ScriptPropertyJson,
|
||||
StyleProperty
|
||||
} from './vue-meta'
|
||||
@@ -1,95 +0,0 @@
|
||||
import Vue, { ComponentOptions } from 'vue'
|
||||
import VueMeta, {
|
||||
VueMetaPlugin,
|
||||
VueMetaOptions,
|
||||
VueMetaApp,
|
||||
MetaInfo,
|
||||
MetaInfoSSR,
|
||||
MetaPropertyCharset
|
||||
} from '../index'
|
||||
|
||||
Vue.use(VueMeta, {
|
||||
keyName: 'head'
|
||||
} as VueMetaOptions)
|
||||
|
||||
const FooMetaInfo: MetaInfo = {
|
||||
title: 'title',
|
||||
titleTemplate: '%s - Home',
|
||||
bodyAttrs: { class: 'a' }
|
||||
}
|
||||
|
||||
const BarMetaInfo: MetaInfo = {
|
||||
title: 'title',
|
||||
titleTemplate: c => `${c} - Home`,
|
||||
bodyAttrs: { class: ['a', 'b'] },
|
||||
__dangerouslyDisableSanitizers: ['script'],
|
||||
__dangerouslyDisableSanitizersByTagID: {
|
||||
ldjson: ['innerHTML']
|
||||
},
|
||||
link: [
|
||||
{ vmid: '', rel: '', href: '', callback: () => {} }
|
||||
],
|
||||
script: [
|
||||
{ src: '', crossorigin: '', async: true },
|
||||
{ vmid: '', src: '', callback: () => {} }
|
||||
],
|
||||
meta: [
|
||||
{ charset: 'utf-8' },
|
||||
{
|
||||
property: 'og:title',
|
||||
content: 'Test title',
|
||||
template: chunk => `${chunk} - My page`, //or as string template: '%s - My page',
|
||||
vmid: 'og:title'
|
||||
}
|
||||
],
|
||||
changed(newdata: MetaInfo, newTags: HTMLElement[], oldTags: HTMLElement[]) {
|
||||
},
|
||||
afterNavigation(data: MetaInfo) {
|
||||
}
|
||||
}
|
||||
|
||||
const Foo: ComponentOptions<Vue> = {
|
||||
metaInfo: FooMetaInfo
|
||||
}
|
||||
|
||||
const Bar: ComponentOptions<Vue> = {
|
||||
metaInfo() {
|
||||
return BarMetaInfo
|
||||
}
|
||||
}
|
||||
|
||||
const app: Vue = new Vue(Foo)
|
||||
const $meta: VueMetaPlugin = app.$meta()
|
||||
|
||||
// getOptions
|
||||
const options: VueMetaOptions = $meta.getOptions()
|
||||
|
||||
// client side refresh
|
||||
const { metaInfo: metaData1 }: { metaInfo: MetaInfo } = $meta.refresh()
|
||||
|
||||
// server side injection
|
||||
const metaDataSSR: MetaInfoSSR = $meta.inject()
|
||||
if (metaDataSSR.script) {
|
||||
metaDataSSR.script.text()
|
||||
metaDataSSR.script.text({ body: true })
|
||||
}
|
||||
|
||||
// add app
|
||||
const customApp: VueMetaApp = $meta.addApp('custom-app')
|
||||
|
||||
const metaCharset: MetaPropertyCharset = { charset: 'utf-8' }
|
||||
const customAppInfo: MetaInfo = {
|
||||
meta: [metaCharset]
|
||||
}
|
||||
|
||||
customApp.set(customAppInfo)
|
||||
|
||||
// pausing & resuming
|
||||
let resume
|
||||
resume = $meta.pause()
|
||||
const ret: void = resume()
|
||||
resume = $meta.pause(true)
|
||||
const { metaInfo: metaData2 }: { metaInfo: MetaInfo } = resume()
|
||||
const { metaInfo: metaData3 }: { metaInfo: MetaInfo } = $meta.resume(true)
|
||||
|
||||
const metaInfo: MetaInfoSSR = VueMeta.generate({ meta: [{ charset: 'utf-8' }] }, { ssrAppId: 1 })
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "es2015",
|
||||
"moduleResolution": "node",
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"lib": [
|
||||
"es5",
|
||||
"dom",
|
||||
"es2015.promise"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"*.ts",
|
||||
"../*.d.ts"
|
||||
]
|
||||
}
|
||||
Vendored
-235
@@ -1,235 +0,0 @@
|
||||
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)
|
||||
|
||||
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
|
||||
}
|
||||
Vendored
-18
@@ -1,18 +0,0 @@
|
||||
/**
|
||||
* Augment the typings of Vue.js
|
||||
*/
|
||||
|
||||
import Vue, { ComponentOptions } from 'vue'
|
||||
import { MetaInfo, MetaInfoComputed, VueMetaPlugin } from './vue-meta'
|
||||
|
||||
declare module 'vue/types/vue' {
|
||||
interface Vue {
|
||||
$meta(): VueMetaPlugin
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'vue/types/options' {
|
||||
interface ComponentOptions<V extends Vue> {
|
||||
metaInfo?: MetaInfo | MetaInfoComputed
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user