vue 2.6.13 → 2.7.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -295
- package/compiler-sfc/index.d.ts +1 -0
- package/compiler-sfc/index.js +1 -0
- package/compiler-sfc/index.mjs +1 -0
- package/compiler-sfc/package.json +5 -0
- package/dist/vue.common.dev.js +11481 -11946
- package/dist/vue.common.prod.js +8 -3
- package/dist/vue.esm.browser.js +11321 -12011
- package/dist/vue.esm.browser.min.js +8 -3
- package/dist/vue.esm.js +11476 -11984
- package/dist/vue.js +11484 -11949
- package/dist/vue.min.js +8 -3
- package/dist/vue.runtime.common.dev.js +8427 -8421
- package/dist/vue.runtime.common.prod.js +8 -3
- package/dist/vue.runtime.esm.js +8436 -8454
- package/dist/vue.runtime.js +8430 -8424
- package/dist/vue.runtime.min.js +8 -3
- package/package.json +88 -111
- package/packages/compiler-sfc/dist/compiler-sfc.js +7 -0
- package/packages/compiler-sfc/node_modules/.bin/parser +17 -0
- package/packages/compiler-sfc/node_modules/.bin/sass +17 -0
- package/packages/compiler-sfc/package.json +30 -0
- package/src/compiler/{codeframe.js → codeframe.ts} +9 -7
- package/src/compiler/codegen/{events.js → events.ts} +21 -41
- package/src/compiler/codegen/{index.js → index.ts} +146 -136
- package/src/compiler/{create-compiler.js → create-compiler.ts} +26 -18
- package/src/compiler/directives/bind.ts +9 -0
- package/src/compiler/directives/{index.js → index.ts} +0 -2
- package/src/compiler/directives/{model.js → model.ts} +15 -18
- package/src/compiler/directives/{on.js → on.ts} +3 -4
- package/src/compiler/{error-detector.js → error-detector.ts} +61 -31
- package/src/compiler/{helpers.js → helpers.ts} +73 -61
- package/src/compiler/{index.js → index.ts} +2 -3
- package/src/compiler/{optimizer.js → optimizer.ts} +30 -23
- package/src/compiler/parser/{entity-decoder.js → entity-decoder.ts} +1 -3
- package/src/compiler/parser/{filter-parser.js → filter-parser.ts} +43 -24
- package/src/compiler/parser/{html-parser.js → html-parser.ts} +50 -29
- package/src/compiler/parser/{index.js → index.ts} +190 -172
- package/src/compiler/parser/{text-parser.js → text-parser.ts} +8 -9
- package/src/compiler/{to-function.js → to-function.ts} +27 -22
- package/src/core/components/{index.js → index.ts} +0 -0
- package/src/core/components/{keep-alive.js → keep-alive.ts} +42 -30
- package/src/core/{config.js → config.ts} +28 -30
- package/src/core/global-api/{assets.js → assets.ts} +8 -7
- package/src/core/global-api/{extend.js → extend.ts} +10 -13
- package/src/core/global-api/{index.js → index.ts} +4 -5
- package/src/core/global-api/{mixin.js → mixin.ts} +2 -3
- package/src/core/global-api/use.ts +23 -0
- package/src/core/{index.js → index.ts} +1 -1
- package/src/core/instance/{events.js → events.ts} +41 -24
- package/src/core/instance/{index.js → index.ts} +9 -5
- package/src/core/instance/{init.js → init.ts} +26 -15
- package/src/core/instance/inject.ts +72 -0
- package/src/core/instance/{lifecycle.js → lifecycle.ts} +86 -44
- package/src/core/instance/{proxy.js → proxy.ts} +29 -24
- package/src/core/instance/render-helpers/{bind-dynamic-keys.js → bind-dynamic-keys.ts} +6 -5
- package/src/core/instance/render-helpers/{bind-object-listeners.js → bind-object-listeners.ts} +4 -8
- package/src/core/instance/render-helpers/{bind-object-props.js → bind-object-props.ts} +12 -17
- package/src/core/instance/render-helpers/{check-keycodes.js → check-keycodes.ts} +5 -7
- package/src/core/instance/render-helpers/{index.js → index.ts} +1 -3
- package/src/core/instance/render-helpers/{render-list.js → render-list.ts} +12 -13
- package/src/core/instance/render-helpers/{render-slot.js → render-slot.ts} +10 -11
- package/src/core/instance/render-helpers/{render-static.js → render-static.ts} +7 -10
- package/src/core/instance/render-helpers/{resolve-filter.js → resolve-filter.ts} +1 -3
- package/src/core/instance/render-helpers/{resolve-scoped-slots.js → resolve-scoped-slots.ts} +11 -8
- package/src/core/instance/render-helpers/{resolve-slots.js → resolve-slots.ts} +12 -11
- package/src/core/instance/{render.js → render.ts} +66 -29
- package/src/core/instance/{state.js → state.ts} +100 -83
- package/src/core/observer/{array.js → array.ts} +11 -2
- package/src/core/observer/{dep.js → dep.ts} +37 -15
- package/src/core/observer/{index.js → index.ts} +137 -71
- package/src/core/observer/{scheduler.js → scheduler.ts} +42 -43
- package/src/core/observer/{traverse.js → traverse.ts} +10 -7
- package/src/core/observer/{watcher.js → watcher.ts} +88 -60
- package/src/core/util/{debug.js → debug.ts} +38 -34
- package/src/core/util/{env.js → env.ts} +27 -30
- package/src/core/util/{error.js → error.ts} +12 -14
- package/src/core/util/{index.js → index.ts} +0 -2
- package/src/core/util/{lang.js → lang.ts} +6 -7
- package/src/core/util/{next-tick.js → next-tick.ts} +16 -10
- package/src/core/util/{options.js → options.ts} +119 -114
- package/src/core/util/{perf.js → perf.ts} +5 -1
- package/src/core/util/{props.js → props.ts} +54 -50
- package/src/core/vdom/{create-component.js → create-component.ts} +51 -50
- package/src/core/vdom/{create-element.js → create-element.ts} +49 -43
- package/src/core/vdom/{create-functional-component.js → create-functional-component.ts} +52 -27
- package/src/core/vdom/helpers/{extract-props.js → extract-props.ts} +18 -18
- package/src/core/vdom/helpers/{get-first-component-child.js → get-first-component-child.ts} +6 -5
- package/src/core/vdom/helpers/{index.js → index.ts} +0 -2
- package/src/core/vdom/helpers/is-async-placeholder.ts +6 -0
- package/src/core/vdom/helpers/{merge-hook.js → merge-hook.ts} +7 -5
- package/src/core/vdom/helpers/{normalize-children.js → normalize-children.ts} +26 -16
- package/src/core/vdom/helpers/{normalize-scoped-slots.js → normalize-scoped-slots.ts} +23 -17
- package/src/core/vdom/helpers/{resolve-async-component.js → resolve-async-component.ts} +29 -37
- package/src/core/vdom/helpers/update-listeners.ts +101 -0
- package/src/core/vdom/modules/{directives.js → directives.ts} +20 -14
- package/src/core/vdom/modules/index.ts +4 -0
- package/src/core/vdom/modules/template-ref.ts +96 -0
- package/src/core/vdom/{patch.js → patch.ts} +239 -138
- package/src/core/vdom/{vnode.js → vnode.ts} +36 -31
- package/src/global.d.ts +15 -0
- package/src/platforms/web/compiler/directives/html.ts +8 -0
- package/src/platforms/web/compiler/directives/{index.js → index.ts} +0 -0
- package/src/platforms/web/compiler/directives/{model.js → model.ts} +47 -41
- package/src/platforms/web/compiler/directives/{text.js → text.ts} +2 -3
- package/src/platforms/web/compiler/{index.js → index.ts} +0 -2
- package/src/platforms/web/compiler/modules/{class.js → class.ts} +10 -15
- package/src/platforms/web/compiler/modules/{index.js → index.ts} +1 -5
- package/src/platforms/web/compiler/modules/{model.js → model.ts} +6 -11
- package/src/platforms/web/compiler/modules/{style.js → style.ts} +9 -14
- package/src/platforms/web/compiler/{options.js → options.ts} +1 -2
- package/src/platforms/web/compiler/{util.js → util.ts} +5 -7
- package/src/platforms/web/entry-compiler-sfc.ts +1 -0
- package/src/platforms/web/{entry-compiler.js → entry-compiler.ts} +1 -3
- package/src/platforms/web/{entry-runtime.js → entry-runtime-esm.ts} +2 -2
- package/src/platforms/web/entry-runtime-with-compiler-esm.ts +5 -0
- package/src/platforms/web/entry-runtime-with-compiler.ts +10 -0
- package/src/platforms/web/entry-runtime.ts +7 -0
- package/src/platforms/web/runtime/{class-util.js → class-util.ts} +2 -4
- package/src/platforms/web/runtime/components/{index.js → index.ts} +0 -0
- package/src/platforms/web/runtime/components/{transition-group.js → transition-group.ts} +59 -46
- package/src/platforms/web/runtime/components/{transition.js → transition.ts} +43 -36
- package/src/platforms/web/runtime/directives/{index.js → index.ts} +0 -0
- package/src/platforms/web/runtime/directives/{model.js → model.ts} +22 -21
- package/src/platforms/web/runtime/directives/{show.js → show.ts} +11 -10
- package/src/platforms/web/runtime/{index.js → index.ts} +9 -10
- package/src/platforms/web/runtime/modules/{attrs.js → attrs.ts} +12 -16
- package/src/platforms/web/runtime/modules/{class.js → class.ts} +7 -18
- package/src/platforms/web/runtime/modules/{dom-props.js → dom-props.ts} +24 -17
- package/src/platforms/web/runtime/modules/{events.js → events.ts} +22 -15
- package/src/platforms/web/runtime/modules/{index.js → index.ts} +1 -8
- package/src/platforms/web/runtime/modules/{style.js → style.ts} +24 -13
- package/src/platforms/web/runtime/modules/{transition.js → transition.ts} +61 -63
- package/src/platforms/web/runtime/node-ops.ts +66 -0
- package/src/platforms/web/runtime/{patch.js → patch.ts} +0 -2
- package/src/platforms/web/runtime/{transition-util.js → transition-util.ts} +63 -38
- package/src/platforms/web/{entry-runtime-with-compiler.js → runtime-with-compiler.ts} +28 -19
- package/src/platforms/web/util/{attrs.js → attrs.ts} +18 -14
- package/src/platforms/web/util/{class.js → class.ts} +23 -21
- package/src/platforms/web/util/{compat.js → compat.ts} +4 -4
- package/src/platforms/web/util/{element.js → element.ts} +21 -22
- package/src/platforms/web/util/{index.js → index.ts} +2 -6
- package/src/platforms/web/util/{style.js → style.ts} +12 -12
- package/src/sfc/{parser.js → parser.ts} +18 -15
- package/src/shared/{constants.js → constants.ts} +2 -6
- package/src/shared/{util.js → util.ts} +78 -55
- package/src/types/compiler.ts +224 -0
- package/src/types/component.ts +209 -0
- package/src/types/global-api.ts +37 -0
- package/src/types/modules.d.ts +15 -0
- package/src/types/options.ts +120 -0
- package/src/types/ssr.ts +27 -0
- package/src/types/utils.ts +3 -0
- package/src/types/vnode.ts +127 -0
- package/src/v3/apiInject.ts +66 -0
- package/src/v3/apiLifecycle.ts +53 -0
- package/src/v3/apiSetup.ts +161 -0
- package/src/v3/apiWatch.ts +355 -0
- package/src/v3/currentInstance.ts +23 -0
- package/src/v3/debug.ts +21 -0
- package/src/v3/h.ts +18 -0
- package/src/v3/index.ts +77 -0
- package/src/v3/reactivity/computed.ts +100 -0
- package/src/v3/reactivity/effect.ts +20 -0
- package/src/v3/reactivity/effectScope.ts +134 -0
- package/src/v3/reactivity/operations.ts +14 -0
- package/src/v3/reactivity/reactive.ts +123 -0
- package/src/v3/reactivity/readonly.ts +121 -0
- package/src/v3/reactivity/ref.ts +249 -0
- package/types/index.d.ts +10 -13
- package/types/options.d.ts +265 -132
- package/types/plugin.d.ts +4 -4
- package/types/umd.d.ts +47 -27
- package/types/v3-generated.d.ts +389 -0
- package/types/v3.d.ts +16 -0
- package/types/vnode.d.ts +70 -57
- package/types/vue.d.ts +292 -88
- package/dist/README.md +0 -122
- package/src/compiler/directives/bind.js +0 -11
- package/src/core/global-api/use.js +0 -23
- package/src/core/instance/inject.js +0 -73
- package/src/core/vdom/helpers/is-async-placeholder.js +0 -5
- package/src/core/vdom/helpers/update-listeners.js +0 -95
- package/src/core/vdom/modules/index.js +0 -7
- package/src/core/vdom/modules/ref.js +0 -45
- package/src/platforms/web/compiler/directives/html.js +0 -9
- package/src/platforms/web/entry-server-basic-renderer.js +0 -13
- package/src/platforms/web/entry-server-renderer.js +0 -27
- package/src/platforms/web/runtime/node-ops.js +0 -59
- package/src/platforms/web/server/compiler.js +0 -11
- package/src/platforms/web/server/directives/index.js +0 -7
- package/src/platforms/web/server/directives/model.js +0 -44
- package/src/platforms/web/server/directives/show.js +0 -12
- package/src/platforms/web/server/modules/attrs.js +0 -67
- package/src/platforms/web/server/modules/class.js +0 -11
- package/src/platforms/web/server/modules/dom-props.js +0 -50
- package/src/platforms/web/server/modules/index.js +0 -11
- package/src/platforms/web/server/modules/style.js +0 -41
- package/src/platforms/web/server/util.js +0 -101
- package/src/platforms/weex/compiler/directives/index.js +0 -5
- package/src/platforms/weex/compiler/directives/model.js +0 -33
- package/src/platforms/weex/compiler/index.js +0 -52
- package/src/platforms/weex/compiler/modules/append.js +0 -27
- package/src/platforms/weex/compiler/modules/class.js +0 -74
- package/src/platforms/weex/compiler/modules/index.js +0 -13
- package/src/platforms/weex/compiler/modules/props.js +0 -37
- package/src/platforms/weex/compiler/modules/recycle-list/component-root.js +0 -13
- package/src/platforms/weex/compiler/modules/recycle-list/component.js +0 -16
- package/src/platforms/weex/compiler/modules/recycle-list/index.js +0 -60
- package/src/platforms/weex/compiler/modules/recycle-list/recycle-list.js +0 -50
- package/src/platforms/weex/compiler/modules/recycle-list/text.js +0 -23
- package/src/platforms/weex/compiler/modules/recycle-list/v-bind.js +0 -21
- package/src/platforms/weex/compiler/modules/recycle-list/v-for.js +0 -33
- package/src/platforms/weex/compiler/modules/recycle-list/v-if.js +0 -63
- package/src/platforms/weex/compiler/modules/recycle-list/v-on.js +0 -25
- package/src/platforms/weex/compiler/modules/recycle-list/v-once.js +0 -19
- package/src/platforms/weex/compiler/modules/style.js +0 -87
- package/src/platforms/weex/entry-compiler.js +0 -2
- package/src/platforms/weex/entry-framework.js +0 -187
- package/src/platforms/weex/entry-runtime-factory.js +0 -6
- package/src/platforms/weex/runtime/components/index.js +0 -9
- package/src/platforms/weex/runtime/components/richtext.js +0 -82
- package/src/platforms/weex/runtime/components/transition-group.js +0 -148
- package/src/platforms/weex/runtime/components/transition.js +0 -9
- package/src/platforms/weex/runtime/directives/index.js +0 -2
- package/src/platforms/weex/runtime/index.js +0 -42
- package/src/platforms/weex/runtime/modules/attrs.js +0 -44
- package/src/platforms/weex/runtime/modules/class.js +0 -76
- package/src/platforms/weex/runtime/modules/events.js +0 -54
- package/src/platforms/weex/runtime/modules/index.js +0 -13
- package/src/platforms/weex/runtime/modules/style.js +0 -84
- package/src/platforms/weex/runtime/modules/transition.js +0 -270
- package/src/platforms/weex/runtime/node-ops.js +0 -91
- package/src/platforms/weex/runtime/patch.js +0 -16
- package/src/platforms/weex/runtime/recycle-list/render-component-template.js +0 -34
- package/src/platforms/weex/runtime/recycle-list/virtual-component.js +0 -136
- package/src/platforms/weex/runtime/text-node.js +0 -9
- package/src/platforms/weex/util/element.js +0 -52
- package/src/platforms/weex/util/index.js +0 -40
- package/src/platforms/weex/util/parser.js +0 -60
- package/src/server/bundle-renderer/create-bundle-renderer.js +0 -151
- package/src/server/bundle-renderer/create-bundle-runner.js +0 -150
- package/src/server/bundle-renderer/source-map-support.js +0 -45
- package/src/server/create-basic-renderer.js +0 -37
- package/src/server/create-renderer.js +0 -152
- package/src/server/optimizing-compiler/codegen.js +0 -264
- package/src/server/optimizing-compiler/index.js +0 -20
- package/src/server/optimizing-compiler/modules.js +0 -124
- package/src/server/optimizing-compiler/optimizer.js +0 -141
- package/src/server/optimizing-compiler/runtime-helpers.js +0 -150
- package/src/server/render-context.js +0 -130
- package/src/server/render-stream.js +0 -95
- package/src/server/render.js +0 -437
- package/src/server/template-renderer/create-async-file-mapper.js +0 -57
- package/src/server/template-renderer/index.js +0 -277
- package/src/server/template-renderer/parse-template.js +0 -42
- package/src/server/template-renderer/template-stream.js +0 -82
- package/src/server/util.js +0 -18
- package/src/server/webpack-plugin/client.js +0 -65
- package/src/server/webpack-plugin/server.js +0 -66
- package/src/server/webpack-plugin/util.js +0 -34
- package/src/server/write.js +0 -50
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import deindent from 'de-indent'
|
|
4
2
|
import { parseHTML } from 'compiler/parser/html-parser'
|
|
5
3
|
import { makeMap } from 'shared/util'
|
|
4
|
+
import {
|
|
5
|
+
ASTAttr,
|
|
6
|
+
SFCBlock,
|
|
7
|
+
SFCDescriptor,
|
|
8
|
+
WarningMessage
|
|
9
|
+
} from 'types/compiler'
|
|
6
10
|
|
|
7
11
|
const splitRE = /\r?\n/g
|
|
8
12
|
const replaceRE = /./g
|
|
@@ -11,9 +15,9 @@ const isSpecialTag = makeMap('script,style,template', true)
|
|
|
11
15
|
/**
|
|
12
16
|
* Parse a single-file component (*.vue) file into an SFC Descriptor Object.
|
|
13
17
|
*/
|
|
14
|
-
export function parseComponent
|
|
18
|
+
export function parseComponent(
|
|
15
19
|
content: string,
|
|
16
|
-
options
|
|
20
|
+
options: Record<string, any> = {}
|
|
17
21
|
): SFCDescriptor {
|
|
18
22
|
const sfc: SFCDescriptor = {
|
|
19
23
|
template: null,
|
|
@@ -23,13 +27,13 @@ export function parseComponent (
|
|
|
23
27
|
errors: []
|
|
24
28
|
}
|
|
25
29
|
let depth = 0
|
|
26
|
-
let currentBlock:
|
|
30
|
+
let currentBlock: SFCBlock | null = null
|
|
27
31
|
|
|
28
|
-
let warn = msg => {
|
|
32
|
+
let warn: any = msg => {
|
|
29
33
|
sfc.errors.push(msg)
|
|
30
34
|
}
|
|
31
35
|
|
|
32
|
-
if (
|
|
36
|
+
if (__DEV__ && options.outputSourceRange) {
|
|
33
37
|
warn = (msg, range) => {
|
|
34
38
|
const data: WarningMessage = { msg }
|
|
35
39
|
if (range.start != null) {
|
|
@@ -42,7 +46,7 @@ export function parseComponent (
|
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
48
|
|
|
45
|
-
function start
|
|
49
|
+
function start(
|
|
46
50
|
tag: string,
|
|
47
51
|
attrs: Array<ASTAttr>,
|
|
48
52
|
unary: boolean,
|
|
@@ -66,7 +70,8 @@ export function parseComponent (
|
|
|
66
70
|
} else {
|
|
67
71
|
sfc[tag] = currentBlock
|
|
68
72
|
}
|
|
69
|
-
} else {
|
|
73
|
+
} else {
|
|
74
|
+
// custom blocks
|
|
70
75
|
sfc.customBlocks.push(currentBlock)
|
|
71
76
|
}
|
|
72
77
|
}
|
|
@@ -75,7 +80,7 @@ export function parseComponent (
|
|
|
75
80
|
}
|
|
76
81
|
}
|
|
77
82
|
|
|
78
|
-
function checkAttrs
|
|
83
|
+
function checkAttrs(block: SFCBlock, attrs: Array<ASTAttr>) {
|
|
79
84
|
for (let i = 0; i < attrs.length; i++) {
|
|
80
85
|
const attr = attrs[i]
|
|
81
86
|
if (attr.name === 'lang') {
|
|
@@ -93,7 +98,7 @@ export function parseComponent (
|
|
|
93
98
|
}
|
|
94
99
|
}
|
|
95
100
|
|
|
96
|
-
function end
|
|
101
|
+
function end(tag: string, start: number) {
|
|
97
102
|
if (depth === 1 && currentBlock) {
|
|
98
103
|
currentBlock.end = start
|
|
99
104
|
let text = content.slice(currentBlock.start, currentBlock.end)
|
|
@@ -111,14 +116,12 @@ export function parseComponent (
|
|
|
111
116
|
depth--
|
|
112
117
|
}
|
|
113
118
|
|
|
114
|
-
function padContent
|
|
119
|
+
function padContent(block: SFCBlock, pad: true | 'line' | 'space') {
|
|
115
120
|
if (pad === 'space') {
|
|
116
121
|
return content.slice(0, block.start).replace(replaceRE, ' ')
|
|
117
122
|
} else {
|
|
118
123
|
const offset = content.slice(0, block.start).split(splitRE).length
|
|
119
|
-
const padChar = block.type === 'script' && !block.lang
|
|
120
|
-
? '//\n'
|
|
121
|
-
: '\n'
|
|
124
|
+
const padChar = block.type === 'script' && !block.lang ? '//\n' : '\n'
|
|
122
125
|
return Array(offset).join(padChar)
|
|
123
126
|
}
|
|
124
127
|
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
export const SSR_ATTR = 'data-server-rendered'
|
|
2
2
|
|
|
3
|
-
export const ASSET_TYPES = [
|
|
4
|
-
'component',
|
|
5
|
-
'directive',
|
|
6
|
-
'filter'
|
|
7
|
-
]
|
|
3
|
+
export const ASSET_TYPES = ['component', 'directive', 'filter'] as const
|
|
8
4
|
|
|
9
5
|
export const LIFECYCLE_HOOKS = [
|
|
10
6
|
'beforeCreate',
|
|
@@ -19,4 +15,4 @@ export const LIFECYCLE_HOOKS = [
|
|
|
19
15
|
'deactivated',
|
|
20
16
|
'errorCaptured',
|
|
21
17
|
'serverPrefetch'
|
|
22
|
-
]
|
|
18
|
+
] as const
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
export const emptyObject: Record<string, any> = Object.freeze({})
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const isArray = Array.isArray
|
|
4
4
|
|
|
5
5
|
// These helpers produce better VM code in JS engines due to their
|
|
6
6
|
// explicitness and function inlining.
|
|
7
|
-
export function isUndef
|
|
7
|
+
export function isUndef(v: any): v is undefined | null {
|
|
8
8
|
return v === undefined || v === null
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export function isDef
|
|
11
|
+
export function isDef<T>(v: T): v is NonNullable<T> {
|
|
12
12
|
return v !== undefined && v !== null
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export function isTrue
|
|
15
|
+
export function isTrue(v: any): boolean {
|
|
16
16
|
return v === true
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export function isFalse
|
|
19
|
+
export function isFalse(v: any): boolean {
|
|
20
20
|
return v === false
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Check if value is primitive.
|
|
25
25
|
*/
|
|
26
|
-
export function isPrimitive
|
|
26
|
+
export function isPrimitive(value: any): boolean {
|
|
27
27
|
return (
|
|
28
28
|
typeof value === 'string' ||
|
|
29
29
|
typeof value === 'number' ||
|
|
@@ -33,12 +33,16 @@ export function isPrimitive (value: any): boolean %checks {
|
|
|
33
33
|
)
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
export function isFunction(value: any): value is (...args: any[]) => any {
|
|
37
|
+
return typeof value === 'function'
|
|
38
|
+
}
|
|
39
|
+
|
|
36
40
|
/**
|
|
37
41
|
* Quick object check - this is primarily used to tell
|
|
38
|
-
*
|
|
42
|
+
* objects from primitive values when we know the value
|
|
39
43
|
* is a JSON-compliant type.
|
|
40
44
|
*/
|
|
41
|
-
export function isObject
|
|
45
|
+
export function isObject(obj: any): boolean {
|
|
42
46
|
return obj !== null && typeof obj === 'object'
|
|
43
47
|
}
|
|
44
48
|
|
|
@@ -47,7 +51,7 @@ export function isObject (obj: mixed): boolean %checks {
|
|
|
47
51
|
*/
|
|
48
52
|
const _toString = Object.prototype.toString
|
|
49
53
|
|
|
50
|
-
export function toRawType
|
|
54
|
+
export function toRawType(value: any): string {
|
|
51
55
|
return _toString.call(value).slice(8, -1)
|
|
52
56
|
}
|
|
53
57
|
|
|
@@ -55,23 +59,23 @@ export function toRawType (value: any): string {
|
|
|
55
59
|
* Strict object type check. Only returns true
|
|
56
60
|
* for plain JavaScript objects.
|
|
57
61
|
*/
|
|
58
|
-
export function isPlainObject
|
|
62
|
+
export function isPlainObject(obj: any): boolean {
|
|
59
63
|
return _toString.call(obj) === '[object Object]'
|
|
60
64
|
}
|
|
61
65
|
|
|
62
|
-
export function isRegExp
|
|
66
|
+
export function isRegExp(v: any): v is RegExp {
|
|
63
67
|
return _toString.call(v) === '[object RegExp]'
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
/**
|
|
67
71
|
* Check if val is a valid array index.
|
|
68
72
|
*/
|
|
69
|
-
export function isValidArrayIndex
|
|
73
|
+
export function isValidArrayIndex(val: any): boolean {
|
|
70
74
|
const n = parseFloat(String(val))
|
|
71
75
|
return n >= 0 && Math.floor(n) === n && isFinite(val)
|
|
72
76
|
}
|
|
73
77
|
|
|
74
|
-
export function isPromise
|
|
78
|
+
export function isPromise(val: any): val is Promise<any> {
|
|
75
79
|
return (
|
|
76
80
|
isDef(val) &&
|
|
77
81
|
typeof val.then === 'function' &&
|
|
@@ -82,19 +86,19 @@ export function isPromise (val: any): boolean {
|
|
|
82
86
|
/**
|
|
83
87
|
* Convert a value to a string that is actually rendered.
|
|
84
88
|
*/
|
|
85
|
-
export function toString
|
|
89
|
+
export function toString(val: any): string {
|
|
86
90
|
return val == null
|
|
87
91
|
? ''
|
|
88
92
|
: Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
|
|
89
|
-
|
|
90
|
-
|
|
93
|
+
? JSON.stringify(val, null, 2)
|
|
94
|
+
: String(val)
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
/**
|
|
94
98
|
* Convert an input value to a number for persistence.
|
|
95
99
|
* If the conversion fails, return original string.
|
|
96
100
|
*/
|
|
97
|
-
export function toNumber
|
|
101
|
+
export function toNumber(val: string): number | string {
|
|
98
102
|
const n = parseFloat(val)
|
|
99
103
|
return isNaN(n) ? val : n
|
|
100
104
|
}
|
|
@@ -103,18 +107,16 @@ export function toNumber (val: string): number | string {
|
|
|
103
107
|
* Make a map and return a function for checking if a key
|
|
104
108
|
* is in that map.
|
|
105
109
|
*/
|
|
106
|
-
export function makeMap
|
|
110
|
+
export function makeMap(
|
|
107
111
|
str: string,
|
|
108
112
|
expectsLowerCase?: boolean
|
|
109
|
-
): (key: string) => true |
|
|
113
|
+
): (key: string) => true | undefined {
|
|
110
114
|
const map = Object.create(null)
|
|
111
115
|
const list: Array<string> = str.split(',')
|
|
112
116
|
for (let i = 0; i < list.length; i++) {
|
|
113
117
|
map[list[i]] = true
|
|
114
118
|
}
|
|
115
|
-
return expectsLowerCase
|
|
116
|
-
? val => map[val.toLowerCase()]
|
|
117
|
-
: val => map[val]
|
|
119
|
+
return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val]
|
|
118
120
|
}
|
|
119
121
|
|
|
120
122
|
/**
|
|
@@ -130,7 +132,7 @@ export const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is')
|
|
|
130
132
|
/**
|
|
131
133
|
* Remove an item from an array.
|
|
132
134
|
*/
|
|
133
|
-
export function remove
|
|
135
|
+
export function remove(arr: Array<any>, item: any): Array<any> | void {
|
|
134
136
|
if (arr.length) {
|
|
135
137
|
const index = arr.indexOf(item)
|
|
136
138
|
if (index > -1) {
|
|
@@ -143,19 +145,19 @@ export function remove (arr: Array<any>, item: any): Array<any> | void {
|
|
|
143
145
|
* Check whether an object has the property.
|
|
144
146
|
*/
|
|
145
147
|
const hasOwnProperty = Object.prototype.hasOwnProperty
|
|
146
|
-
export function hasOwn
|
|
148
|
+
export function hasOwn(obj: Object | Array<any>, key: string): boolean {
|
|
147
149
|
return hasOwnProperty.call(obj, key)
|
|
148
150
|
}
|
|
149
151
|
|
|
150
152
|
/**
|
|
151
153
|
* Create a cached version of a pure function.
|
|
152
154
|
*/
|
|
153
|
-
export function cached<
|
|
154
|
-
const cache = Object.create(null)
|
|
155
|
-
return
|
|
155
|
+
export function cached<R>(fn: (str: string) => R): (sr: string) => R {
|
|
156
|
+
const cache: Record<string, R> = Object.create(null)
|
|
157
|
+
return function cachedFn(str: string) {
|
|
156
158
|
const hit = cache[str]
|
|
157
159
|
return hit || (cache[str] = fn(str))
|
|
158
|
-
}
|
|
160
|
+
}
|
|
159
161
|
}
|
|
160
162
|
|
|
161
163
|
/**
|
|
@@ -163,7 +165,7 @@ export function cached<F: Function> (fn: F): F {
|
|
|
163
165
|
*/
|
|
164
166
|
const camelizeRE = /-(\w)/g
|
|
165
167
|
export const camelize = cached((str: string): string => {
|
|
166
|
-
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '')
|
|
168
|
+
return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''))
|
|
167
169
|
})
|
|
168
170
|
|
|
169
171
|
/**
|
|
@@ -190,8 +192,8 @@ export const hyphenate = cached((str: string): string => {
|
|
|
190
192
|
*/
|
|
191
193
|
|
|
192
194
|
/* istanbul ignore next */
|
|
193
|
-
function polyfillBind
|
|
194
|
-
function boundFn
|
|
195
|
+
function polyfillBind(fn: Function, ctx: Object): Function {
|
|
196
|
+
function boundFn(a: any) {
|
|
195
197
|
const l = arguments.length
|
|
196
198
|
return l
|
|
197
199
|
? l > 1
|
|
@@ -204,18 +206,17 @@ function polyfillBind (fn: Function, ctx: Object): Function {
|
|
|
204
206
|
return boundFn
|
|
205
207
|
}
|
|
206
208
|
|
|
207
|
-
function nativeBind
|
|
209
|
+
function nativeBind(fn: Function, ctx: Object): Function {
|
|
208
210
|
return fn.bind(ctx)
|
|
209
211
|
}
|
|
210
212
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
: polyfillBind
|
|
213
|
+
// @ts-expect-error bind cannot be `undefined`
|
|
214
|
+
export const bind = Function.prototype.bind ? nativeBind : polyfillBind
|
|
214
215
|
|
|
215
216
|
/**
|
|
216
217
|
* Convert an Array-like object to a real Array.
|
|
217
218
|
*/
|
|
218
|
-
export function toArray
|
|
219
|
+
export function toArray(list: any, start?: number): Array<any> {
|
|
219
220
|
start = start || 0
|
|
220
221
|
let i = list.length - start
|
|
221
222
|
const ret: Array<any> = new Array(i)
|
|
@@ -228,7 +229,10 @@ export function toArray (list: any, start?: number): Array<any> {
|
|
|
228
229
|
/**
|
|
229
230
|
* Mix properties into target object.
|
|
230
231
|
*/
|
|
231
|
-
export function extend
|
|
232
|
+
export function extend(
|
|
233
|
+
to: Record<PropertyKey, any>,
|
|
234
|
+
_from?: Record<PropertyKey, any>
|
|
235
|
+
): Record<PropertyKey, any> {
|
|
232
236
|
for (const key in _from) {
|
|
233
237
|
to[key] = _from[key]
|
|
234
238
|
}
|
|
@@ -238,7 +242,7 @@ export function extend (to: Object, _from: ?Object): Object {
|
|
|
238
242
|
/**
|
|
239
243
|
* Merge an Array of Objects into a single Object.
|
|
240
244
|
*/
|
|
241
|
-
export function toObject
|
|
245
|
+
export function toObject(arr: Array<any>): object {
|
|
242
246
|
const res = {}
|
|
243
247
|
for (let i = 0; i < arr.length; i++) {
|
|
244
248
|
if (arr[i]) {
|
|
@@ -255,7 +259,7 @@ export function toObject (arr: Array<any>): Object {
|
|
|
255
259
|
* Stubbing args to make Flow happy without leaving useless transpiled code
|
|
256
260
|
* with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
|
|
257
261
|
*/
|
|
258
|
-
export function noop
|
|
262
|
+
export function noop(a?: any, b?: any, c?: any) {}
|
|
259
263
|
|
|
260
264
|
/**
|
|
261
265
|
* Always return false.
|
|
@@ -272,17 +276,21 @@ export const identity = (_: any) => _
|
|
|
272
276
|
/**
|
|
273
277
|
* Generate a string containing static keys from compiler modules.
|
|
274
278
|
*/
|
|
275
|
-
export function genStaticKeys
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
+
export function genStaticKeys(
|
|
280
|
+
modules: Array<{ staticKeys?: string[] } /* ModuleOptions */>
|
|
281
|
+
): string {
|
|
282
|
+
return modules
|
|
283
|
+
.reduce((keys, m) => {
|
|
284
|
+
return keys.concat(m.staticKeys || [])
|
|
285
|
+
}, [] as string[])
|
|
286
|
+
.join(',')
|
|
279
287
|
}
|
|
280
288
|
|
|
281
289
|
/**
|
|
282
290
|
* Check if two values are loosely equal - that is,
|
|
283
291
|
* if they are plain objects, do they have the same shape?
|
|
284
292
|
*/
|
|
285
|
-
export function looseEqual
|
|
293
|
+
export function looseEqual(a: any, b: any): boolean {
|
|
286
294
|
if (a === b) return true
|
|
287
295
|
const isObjectA = isObject(a)
|
|
288
296
|
const isObjectB = isObject(b)
|
|
@@ -291,22 +299,28 @@ export function looseEqual (a: any, b: any): boolean {
|
|
|
291
299
|
const isArrayA = Array.isArray(a)
|
|
292
300
|
const isArrayB = Array.isArray(b)
|
|
293
301
|
if (isArrayA && isArrayB) {
|
|
294
|
-
return
|
|
295
|
-
|
|
296
|
-
|
|
302
|
+
return (
|
|
303
|
+
a.length === b.length &&
|
|
304
|
+
a.every((e: any, i: any) => {
|
|
305
|
+
return looseEqual(e, b[i])
|
|
306
|
+
})
|
|
307
|
+
)
|
|
297
308
|
} else if (a instanceof Date && b instanceof Date) {
|
|
298
309
|
return a.getTime() === b.getTime()
|
|
299
310
|
} else if (!isArrayA && !isArrayB) {
|
|
300
311
|
const keysA = Object.keys(a)
|
|
301
312
|
const keysB = Object.keys(b)
|
|
302
|
-
return
|
|
303
|
-
|
|
304
|
-
|
|
313
|
+
return (
|
|
314
|
+
keysA.length === keysB.length &&
|
|
315
|
+
keysA.every(key => {
|
|
316
|
+
return looseEqual(a[key], b[key])
|
|
317
|
+
})
|
|
318
|
+
)
|
|
305
319
|
} else {
|
|
306
320
|
/* istanbul ignore next */
|
|
307
321
|
return false
|
|
308
322
|
}
|
|
309
|
-
} catch (e) {
|
|
323
|
+
} catch (e: any) {
|
|
310
324
|
/* istanbul ignore next */
|
|
311
325
|
return false
|
|
312
326
|
}
|
|
@@ -322,7 +336,7 @@ export function looseEqual (a: any, b: any): boolean {
|
|
|
322
336
|
* found in the array (if value is a plain object, the array must
|
|
323
337
|
* contain an object of the same shape), or -1 if it is not present.
|
|
324
338
|
*/
|
|
325
|
-
export function looseIndexOf
|
|
339
|
+
export function looseIndexOf(arr: Array<unknown>, val: unknown): number {
|
|
326
340
|
for (let i = 0; i < arr.length; i++) {
|
|
327
341
|
if (looseEqual(arr[i], val)) return i
|
|
328
342
|
}
|
|
@@ -332,12 +346,21 @@ export function looseIndexOf (arr: Array<mixed>, val: mixed): number {
|
|
|
332
346
|
/**
|
|
333
347
|
* Ensure a function is called only once.
|
|
334
348
|
*/
|
|
335
|
-
export function once (fn:
|
|
349
|
+
export function once<T extends (...args: any[]) => any>(fn: T): T {
|
|
336
350
|
let called = false
|
|
337
351
|
return function () {
|
|
338
352
|
if (!called) {
|
|
339
353
|
called = true
|
|
340
|
-
fn.apply(this, arguments)
|
|
354
|
+
fn.apply(this, arguments as any)
|
|
341
355
|
}
|
|
356
|
+
} as any
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#polyfill
|
|
360
|
+
export function hasChanged(x: unknown, y: unknown): boolean {
|
|
361
|
+
if (x === y) {
|
|
362
|
+
return x === 0 && 1 / x !== 1 / (y as number)
|
|
363
|
+
} else {
|
|
364
|
+
return x === x && y === y
|
|
342
365
|
}
|
|
343
366
|
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
export type CompilerOptions = {
|
|
2
|
+
warn?: Function // allow customizing warning in different environments; e.g. node
|
|
3
|
+
modules?: Array<ModuleOptions> // platform specific modules; e.g. style; class
|
|
4
|
+
directives?: { [key: string]: Function } // platform specific directives
|
|
5
|
+
staticKeys?: string // a list of AST properties to be considered static; for optimization
|
|
6
|
+
isUnaryTag?: (tag: string) => boolean | undefined // check if a tag is unary for the platform
|
|
7
|
+
canBeLeftOpenTag?: (tag: string) => boolean | undefined // check if a tag can be left opened
|
|
8
|
+
isReservedTag?: (tag: string) => boolean | undefined // check if a tag is a native for the platform
|
|
9
|
+
preserveWhitespace?: boolean // preserve whitespace between elements? (Deprecated)
|
|
10
|
+
whitespace?: 'preserve' | 'condense' // whitespace handling strategy
|
|
11
|
+
optimize?: boolean // optimize static content?
|
|
12
|
+
|
|
13
|
+
// web specific
|
|
14
|
+
mustUseProp?: (tag: string, type: string | null, name: string) => boolean // check if an attribute should be bound as a property
|
|
15
|
+
isPreTag?: (attr: string) => boolean | null // check if a tag needs to preserve whitespace
|
|
16
|
+
getTagNamespace?: (tag: string) => string | undefined // check the namespace for a tag
|
|
17
|
+
expectHTML?: boolean // only false for non-web builds
|
|
18
|
+
isFromDOM?: boolean
|
|
19
|
+
shouldDecodeTags?: boolean
|
|
20
|
+
shouldDecodeNewlines?: boolean
|
|
21
|
+
shouldDecodeNewlinesForHref?: boolean
|
|
22
|
+
outputSourceRange?: boolean
|
|
23
|
+
|
|
24
|
+
// runtime user-configurable
|
|
25
|
+
delimiters?: [string, string] // template delimiters
|
|
26
|
+
comments?: boolean // preserve comments in template
|
|
27
|
+
|
|
28
|
+
// for ssr optimization compiler
|
|
29
|
+
scopeId?: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type WarningMessage = {
|
|
33
|
+
msg: string
|
|
34
|
+
start?: number
|
|
35
|
+
end?: number
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type CompiledResult = {
|
|
39
|
+
ast: ASTElement | null
|
|
40
|
+
render: string
|
|
41
|
+
staticRenderFns: Array<string>
|
|
42
|
+
stringRenderFns?: Array<string>
|
|
43
|
+
errors?: Array<string | WarningMessage>
|
|
44
|
+
tips?: Array<string | WarningMessage>
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type ModuleOptions = {
|
|
48
|
+
// transform an AST node before any attributes are processed
|
|
49
|
+
// returning an ASTElement from pre/transforms replaces the element
|
|
50
|
+
preTransformNode: (el: ASTElement) => ASTElement | null
|
|
51
|
+
// transform an AST node after built-ins like v-if, v-for are processed
|
|
52
|
+
transformNode: (el: ASTElement) => ASTElement | null
|
|
53
|
+
// transform an AST node after its children have been processed
|
|
54
|
+
// cannot return replacement in postTransform because tree is already finalized
|
|
55
|
+
postTransformNode: (el: ASTElement) => void
|
|
56
|
+
genData: (el: ASTElement) => string // generate extra data string for an element
|
|
57
|
+
transformCode?: (el: ASTElement, code: string) => string // further transform generated code for an element
|
|
58
|
+
staticKeys?: Array<string> // AST properties to be considered static
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export type ASTModifiers = { [key: string]: boolean }
|
|
62
|
+
export type ASTIfCondition = { exp: string | null; block: ASTElement }
|
|
63
|
+
export type ASTIfConditions = Array<ASTIfCondition>
|
|
64
|
+
|
|
65
|
+
export type ASTAttr = {
|
|
66
|
+
name: string
|
|
67
|
+
value: any
|
|
68
|
+
dynamic?: boolean
|
|
69
|
+
start?: number
|
|
70
|
+
end?: number
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export type ASTElementHandler = {
|
|
74
|
+
value: string
|
|
75
|
+
params?: Array<any>
|
|
76
|
+
modifiers: ASTModifiers | null
|
|
77
|
+
dynamic?: boolean
|
|
78
|
+
start?: number
|
|
79
|
+
end?: number
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export type ASTElementHandlers = {
|
|
83
|
+
[key: string]: ASTElementHandler | Array<ASTElementHandler>
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export type ASTDirective = {
|
|
87
|
+
name: string
|
|
88
|
+
rawName: string
|
|
89
|
+
value: string
|
|
90
|
+
arg: string | null
|
|
91
|
+
isDynamicArg: boolean
|
|
92
|
+
modifiers: ASTModifiers | null
|
|
93
|
+
start?: number
|
|
94
|
+
end?: number
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type ASTNode = ASTElement | ASTText | ASTExpression
|
|
98
|
+
|
|
99
|
+
export type ASTElement = {
|
|
100
|
+
type: 1
|
|
101
|
+
tag: string
|
|
102
|
+
attrsList: Array<ASTAttr>
|
|
103
|
+
attrsMap: { [key: string]: any }
|
|
104
|
+
rawAttrsMap: { [key: string]: ASTAttr }
|
|
105
|
+
parent: ASTElement | void
|
|
106
|
+
children: Array<ASTNode>
|
|
107
|
+
|
|
108
|
+
start?: number
|
|
109
|
+
end?: number
|
|
110
|
+
|
|
111
|
+
processed?: true
|
|
112
|
+
|
|
113
|
+
static?: boolean
|
|
114
|
+
staticRoot?: boolean
|
|
115
|
+
staticInFor?: boolean
|
|
116
|
+
staticProcessed?: boolean
|
|
117
|
+
hasBindings?: boolean
|
|
118
|
+
|
|
119
|
+
text?: string
|
|
120
|
+
attrs?: Array<ASTAttr>
|
|
121
|
+
dynamicAttrs?: Array<ASTAttr>
|
|
122
|
+
props?: Array<ASTAttr>
|
|
123
|
+
plain?: boolean
|
|
124
|
+
pre?: true
|
|
125
|
+
ns?: string
|
|
126
|
+
|
|
127
|
+
component?: string
|
|
128
|
+
inlineTemplate?: true
|
|
129
|
+
transitionMode?: string | null
|
|
130
|
+
slotName?: string | null
|
|
131
|
+
slotTarget?: string | null
|
|
132
|
+
slotTargetDynamic?: boolean
|
|
133
|
+
slotScope?: string | null
|
|
134
|
+
scopedSlots?: { [name: string]: ASTElement }
|
|
135
|
+
|
|
136
|
+
ref?: string
|
|
137
|
+
refInFor?: boolean
|
|
138
|
+
|
|
139
|
+
if?: string
|
|
140
|
+
ifProcessed?: boolean
|
|
141
|
+
elseif?: string
|
|
142
|
+
else?: true
|
|
143
|
+
ifConditions?: ASTIfConditions
|
|
144
|
+
|
|
145
|
+
for?: string
|
|
146
|
+
forProcessed?: boolean
|
|
147
|
+
key?: string
|
|
148
|
+
alias?: string
|
|
149
|
+
iterator1?: string
|
|
150
|
+
iterator2?: string
|
|
151
|
+
|
|
152
|
+
staticClass?: string
|
|
153
|
+
classBinding?: string
|
|
154
|
+
staticStyle?: string
|
|
155
|
+
styleBinding?: string
|
|
156
|
+
events?: ASTElementHandlers
|
|
157
|
+
nativeEvents?: ASTElementHandlers
|
|
158
|
+
|
|
159
|
+
transition?: string | true
|
|
160
|
+
transitionOnAppear?: boolean
|
|
161
|
+
|
|
162
|
+
model?: {
|
|
163
|
+
value: string
|
|
164
|
+
callback: string
|
|
165
|
+
expression: string
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
directives?: Array<ASTDirective>
|
|
169
|
+
|
|
170
|
+
forbidden?: true
|
|
171
|
+
once?: true
|
|
172
|
+
onceProcessed?: boolean
|
|
173
|
+
wrapData?: (code: string) => string
|
|
174
|
+
wrapListeners?: (code: string) => string
|
|
175
|
+
|
|
176
|
+
// 2.4 ssr optimization
|
|
177
|
+
ssrOptimizability?: number
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export type ASTExpression = {
|
|
181
|
+
type: 2
|
|
182
|
+
expression: string
|
|
183
|
+
text: string
|
|
184
|
+
tokens: Array<string | Object>
|
|
185
|
+
static?: boolean
|
|
186
|
+
// 2.4 ssr optimization
|
|
187
|
+
ssrOptimizability?: number
|
|
188
|
+
start?: number
|
|
189
|
+
end?: number
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export type ASTText = {
|
|
193
|
+
type: 3
|
|
194
|
+
text: string
|
|
195
|
+
static?: boolean
|
|
196
|
+
isComment?: boolean
|
|
197
|
+
// 2.4 ssr optimization
|
|
198
|
+
ssrOptimizability?: number
|
|
199
|
+
start?: number
|
|
200
|
+
end?: number
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// SFC-parser related declarations
|
|
204
|
+
|
|
205
|
+
// an object format describing a single-file component
|
|
206
|
+
export type SFCDescriptor = {
|
|
207
|
+
template: SFCBlock | null
|
|
208
|
+
script: SFCBlock | null
|
|
209
|
+
styles: Array<SFCBlock>
|
|
210
|
+
customBlocks: Array<SFCBlock>
|
|
211
|
+
errors: Array<string | WarningMessage>
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export type SFCBlock = {
|
|
215
|
+
type: string
|
|
216
|
+
content: string
|
|
217
|
+
attrs: { [attribute: string]: string }
|
|
218
|
+
start?: number
|
|
219
|
+
end?: number
|
|
220
|
+
lang?: string
|
|
221
|
+
src?: string
|
|
222
|
+
scoped?: boolean
|
|
223
|
+
module?: string | boolean
|
|
224
|
+
}
|