From 11efed53d82327dfbfeecfa96839726ddbfd3c21 Mon Sep 17 00:00:00 2001 From: pimlie Date: Mon, 1 Feb 2021 00:13:40 +0100 Subject: [PATCH] chore: remove old types --- types/index.d.ts | 28 ----- types/test/index.ts | 95 ---------------- types/test/tsconfig.json | 18 --- types/vue-meta.d.ts | 235 --------------------------------------- types/vue.d.ts | 18 --- 5 files changed, 394 deletions(-) delete mode 100644 types/index.d.ts delete mode 100644 types/test/index.ts delete mode 100644 types/test/tsconfig.json delete mode 100644 types/vue-meta.d.ts delete mode 100644 types/vue.d.ts diff --git a/types/index.d.ts b/types/index.d.ts deleted file mode 100644 index 73dcbd4..0000000 --- a/types/index.d.ts +++ /dev/null @@ -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' diff --git a/types/test/index.ts b/types/test/index.ts deleted file mode 100644 index 3d242e5..0000000 --- a/types/test/index.ts +++ /dev/null @@ -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 = { - metaInfo: FooMetaInfo -} - -const Bar: ComponentOptions = { - 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 }) diff --git a/types/test/tsconfig.json b/types/test/tsconfig.json deleted file mode 100644 index 4858453..0000000 --- a/types/test/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "es2015", - "moduleResolution": "node", - "strict": true, - "noEmit": true, - "lib": [ - "es5", - "dom", - "es2015.promise" - ] - }, - "include": [ - "*.ts", - "../*.d.ts" - ] -} diff --git a/types/vue-meta.d.ts b/types/vue-meta.d.ts deleted file mode 100644 index 6cef142..0000000 --- a/types/vue-meta.d.ts +++ /dev/null @@ -1,235 +0,0 @@ -import './vue' -import Vue, { ComponentOptions, PluginFunction } from 'vue' - -type Component = ComponentOptions | 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 - 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?: (newInfo: T, addedTags: elements, removedTags: elements) => void - afterNavigation?: (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 -} diff --git a/types/vue.d.ts b/types/vue.d.ts deleted file mode 100644 index 1b06bbb..0000000 --- a/types/vue.d.ts +++ /dev/null @@ -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 { - metaInfo?: MetaInfo | MetaInfoComputed - } -}