2019-11-30 01:42:04 +08:00
|
|
|
import {
|
|
|
|
baseCompile,
|
2019-12-23 08:44:21 +08:00
|
|
|
baseParse,
|
2019-11-30 01:42:04 +08:00
|
|
|
CompilerOptions,
|
|
|
|
CodegenResult,
|
2020-01-03 07:21:56 +08:00
|
|
|
ParserOptions,
|
2020-02-05 01:20:51 +08:00
|
|
|
RootNode,
|
2020-02-07 14:06:51 +08:00
|
|
|
noopDirectiveTransform,
|
2020-02-08 03:24:56 +08:00
|
|
|
NodeTransform,
|
|
|
|
DirectiveTransform
|
2019-11-30 01:42:04 +08:00
|
|
|
} from '@vue/compiler-core'
|
2020-04-09 06:51:25 +08:00
|
|
|
import { parserOptions } from './parserOptions'
|
2019-10-04 04:55:14 +08:00
|
|
|
import { transformStyle } from './transforms/transformStyle'
|
2019-10-09 03:35:57 +08:00
|
|
|
import { transformVHtml } from './transforms/vHtml'
|
2019-10-10 22:18:19 +08:00
|
|
|
import { transformVText } from './transforms/vText'
|
2019-10-11 06:02:51 +08:00
|
|
|
import { transformModel } from './transforms/vModel'
|
2019-10-14 12:33:23 +08:00
|
|
|
import { transformOn } from './transforms/vOn'
|
2019-11-25 11:04:26 +08:00
|
|
|
import { transformShow } from './transforms/vShow'
|
2020-02-07 04:53:26 +08:00
|
|
|
import { warnTransitionChildren } from './transforms/warnTransitionChildren'
|
2020-02-13 04:00:00 +08:00
|
|
|
import { stringifyStatic } from './transforms/stringifyStatic'
|
2019-09-17 23:57:25 +08:00
|
|
|
|
2020-04-09 06:51:25 +08:00
|
|
|
export { parserOptions }
|
2019-12-23 08:44:21 +08:00
|
|
|
|
2020-02-08 03:24:56 +08:00
|
|
|
export const DOMNodeTransforms: NodeTransform[] = [
|
|
|
|
transformStyle,
|
|
|
|
...(__DEV__ ? [warnTransitionChildren] : [])
|
|
|
|
]
|
|
|
|
|
|
|
|
export const DOMDirectiveTransforms: Record<string, DirectiveTransform> = {
|
|
|
|
cloak: noopDirectiveTransform,
|
|
|
|
html: transformVHtml,
|
|
|
|
text: transformVText,
|
|
|
|
model: transformModel, // override compiler-core
|
|
|
|
on: transformOn, // override compiler-core
|
|
|
|
show: transformShow
|
2020-02-07 14:06:51 +08:00
|
|
|
}
|
|
|
|
|
2019-09-20 12:12:37 +08:00
|
|
|
export function compile(
|
|
|
|
template: string,
|
|
|
|
options: CompilerOptions = {}
|
|
|
|
): CodegenResult {
|
2020-02-13 00:56:42 +08:00
|
|
|
return baseCompile(template, {
|
2019-12-23 08:44:21 +08:00
|
|
|
...parserOptions,
|
2019-09-21 00:16:19 +08:00
|
|
|
...options,
|
2020-02-08 03:24:56 +08:00
|
|
|
nodeTransforms: [...DOMNodeTransforms, ...(options.nodeTransforms || [])],
|
2019-09-22 05:42:12 +08:00
|
|
|
directiveTransforms: {
|
2020-02-08 03:24:56 +08:00
|
|
|
...DOMDirectiveTransforms,
|
2019-09-22 05:42:12 +08:00
|
|
|
...(options.directiveTransforms || {})
|
2020-02-13 00:56:42 +08:00
|
|
|
},
|
|
|
|
transformHoist: __BROWSER__ ? null : stringifyStatic
|
2019-09-20 12:12:37 +08:00
|
|
|
})
|
|
|
|
}
|
2019-09-23 04:50:57 +08:00
|
|
|
|
2020-01-03 07:21:56 +08:00
|
|
|
export function parse(template: string, options: ParserOptions = {}): RootNode {
|
2019-12-23 08:44:21 +08:00
|
|
|
return baseParse(template, {
|
|
|
|
...parserOptions,
|
|
|
|
...options
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-02-07 04:29:02 +08:00
|
|
|
export * from './runtimeHelpers'
|
2020-02-05 07:37:23 +08:00
|
|
|
export { transformStyle } from './transforms/transformStyle'
|
2020-02-06 03:23:03 +08:00
|
|
|
export { createDOMCompilerError, DOMErrorCodes } from './errors'
|
2019-09-23 04:50:57 +08:00
|
|
|
export * from '@vue/compiler-core'
|