types: use more specific type names
This commit is contained in:
parent
fa5390fb6f
commit
a0ee4fbc36
@ -10,7 +10,7 @@ import {
|
|||||||
} from './stylePreprocessors'
|
} from './stylePreprocessors'
|
||||||
import { RawSourceMap } from 'source-map'
|
import { RawSourceMap } from 'source-map'
|
||||||
|
|
||||||
export interface StyleCompileOptions {
|
export interface SFCStyleCompileOptions {
|
||||||
source: string
|
source: string
|
||||||
filename: string
|
filename: string
|
||||||
id: string
|
id: string
|
||||||
@ -23,11 +23,11 @@ export interface StyleCompileOptions {
|
|||||||
postcssPlugins?: any[]
|
postcssPlugins?: any[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AsyncStyleCompileOptions extends StyleCompileOptions {
|
export interface SFCAsyncStyleCompileOptions extends SFCStyleCompileOptions {
|
||||||
isAsync?: boolean
|
isAsync?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StyleCompileResults {
|
export interface SFCStyleCompileResults {
|
||||||
code: string
|
code: string
|
||||||
map: RawSourceMap | undefined
|
map: RawSourceMap | undefined
|
||||||
rawResult: LazyResult | Result | undefined
|
rawResult: LazyResult | Result | undefined
|
||||||
@ -35,22 +35,25 @@ export interface StyleCompileResults {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function compileStyle(
|
export function compileStyle(
|
||||||
options: StyleCompileOptions
|
options: SFCStyleCompileOptions
|
||||||
): StyleCompileResults {
|
): SFCStyleCompileResults {
|
||||||
return doCompileStyle({ ...options, isAsync: false }) as StyleCompileResults
|
return doCompileStyle({
|
||||||
|
...options,
|
||||||
|
isAsync: false
|
||||||
|
}) as SFCStyleCompileResults
|
||||||
}
|
}
|
||||||
|
|
||||||
export function compileStyleAsync(
|
export function compileStyleAsync(
|
||||||
options: StyleCompileOptions
|
options: SFCStyleCompileOptions
|
||||||
): Promise<StyleCompileResults> {
|
): Promise<SFCStyleCompileResults> {
|
||||||
return doCompileStyle({ ...options, isAsync: true }) as Promise<
|
return doCompileStyle({ ...options, isAsync: true }) as Promise<
|
||||||
StyleCompileResults
|
SFCStyleCompileResults
|
||||||
>
|
>
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doCompileStyle(
|
export function doCompileStyle(
|
||||||
options: AsyncStyleCompileOptions
|
options: SFCAsyncStyleCompileOptions
|
||||||
): StyleCompileResults | Promise<StyleCompileResults> {
|
): SFCStyleCompileResults | Promise<SFCStyleCompileResults> {
|
||||||
const {
|
const {
|
||||||
filename,
|
filename,
|
||||||
id,
|
id,
|
||||||
@ -131,7 +134,7 @@ export function doCompileStyle(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function preprocess(
|
function preprocess(
|
||||||
options: StyleCompileOptions,
|
options: SFCStyleCompileOptions,
|
||||||
preprocessor: StylePreprocessor
|
preprocessor: StylePreprocessor
|
||||||
): StylePreprocessorResults {
|
): StylePreprocessorResults {
|
||||||
return preprocessor.render(options.source, options.map, {
|
return preprocessor.render(options.source, options.map, {
|
||||||
|
@ -14,7 +14,11 @@ import { transformSrcset } from './templateTransformSrcset'
|
|||||||
import { isObject } from '@vue/shared'
|
import { isObject } from '@vue/shared'
|
||||||
import consolidate from 'consolidate'
|
import consolidate from 'consolidate'
|
||||||
|
|
||||||
export interface TemplateCompileResults {
|
export interface TemplateCompiler {
|
||||||
|
compile(template: string, options: CompilerOptions): CodegenResult
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SFCTemplateCompileResults {
|
||||||
code: string
|
code: string
|
||||||
source: string
|
source: string
|
||||||
tips: string[]
|
tips: string[]
|
||||||
@ -22,11 +26,7 @@ export interface TemplateCompileResults {
|
|||||||
map?: RawSourceMap
|
map?: RawSourceMap
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TemplateCompiler {
|
export interface SFCTemplateCompileOptions {
|
||||||
compile(template: string, options: CompilerOptions): CodegenResult
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TemplateCompileOptions {
|
|
||||||
source: string
|
source: string
|
||||||
filename: string
|
filename: string
|
||||||
compiler?: TemplateCompiler
|
compiler?: TemplateCompiler
|
||||||
@ -37,7 +37,7 @@ export interface TemplateCompileOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function preprocess(
|
function preprocess(
|
||||||
{ source, filename, preprocessOptions }: TemplateCompileOptions,
|
{ source, filename, preprocessOptions }: SFCTemplateCompileOptions,
|
||||||
preprocessor: any
|
preprocessor: any
|
||||||
): string {
|
): string {
|
||||||
// Consolidate exposes a callback based API, but the callback is in fact
|
// Consolidate exposes a callback based API, but the callback is in fact
|
||||||
@ -59,8 +59,8 @@ function preprocess(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function compileTemplate(
|
export function compileTemplate(
|
||||||
options: TemplateCompileOptions
|
options: SFCTemplateCompileOptions
|
||||||
): TemplateCompileResults {
|
): SFCTemplateCompileResults {
|
||||||
const { preprocessLang } = options
|
const { preprocessLang } = options
|
||||||
const preprocessor =
|
const preprocessor =
|
||||||
preprocessLang && consolidate[preprocessLang as keyof typeof consolidate]
|
preprocessLang && consolidate[preprocessLang as keyof typeof consolidate]
|
||||||
@ -104,7 +104,7 @@ function doCompileTemplate({
|
|||||||
compiler = require('@vue/compiler-dom'),
|
compiler = require('@vue/compiler-dom'),
|
||||||
compilerOptions = {},
|
compilerOptions = {},
|
||||||
transformAssetUrls
|
transformAssetUrls
|
||||||
}: TemplateCompileOptions): TemplateCompileResults {
|
}: SFCTemplateCompileOptions): SFCTemplateCompileResults {
|
||||||
const errors: CompilerError[] = []
|
const errors: CompilerError[] = []
|
||||||
|
|
||||||
let nodeTransforms: NodeTransform[] = []
|
let nodeTransforms: NodeTransform[] = []
|
||||||
|
@ -14,8 +14,8 @@ export {
|
|||||||
} from './parse'
|
} from './parse'
|
||||||
export {
|
export {
|
||||||
TemplateCompiler,
|
TemplateCompiler,
|
||||||
TemplateCompileOptions,
|
SFCTemplateCompileOptions,
|
||||||
TemplateCompileResults
|
SFCTemplateCompileResults
|
||||||
} from './compileTemplate'
|
} from './compileTemplate'
|
||||||
export { StyleCompileOptions, StyleCompileResults } from './compileStyle'
|
export { SFCStyleCompileOptions, SFCStyleCompileResults } from './compileStyle'
|
||||||
export { CompilerOptions, generateCodeFrame } from '@vue/compiler-core'
|
export { CompilerOptions, generateCodeFrame } from '@vue/compiler-core'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user