@dcloudio/uni-cli-shared 3.0.0-alpha-4070720250804001 → 3.0.0-alpha-4070620250731002
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/dist/easycom.d.ts +0 -1
- package/dist/easycom.js +13 -17
- package/dist/hbx/alias.js +10 -43
- package/dist/hbx/index.js +0 -10
- package/dist/hbx/log.js +1 -23
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -3
- package/dist/json/index.d.ts +1 -1
- package/dist/json/index.js +1 -2
- package/dist/json/manifest.d.ts +0 -1
- package/dist/json/manifest.js +1 -11
- package/dist/json/mp/jsonFile.js +2 -4
- package/dist/json/mp/pages.js +0 -1
- package/dist/json/mp/types.d.ts +1 -4
- package/dist/json/uni-x/manifest.d.ts +0 -1
- package/dist/json/uni-x/manifest.js +1 -5
- package/dist/messages/zh_CN.js +0 -1
- package/dist/uni_modules.cloud.d.ts +4 -10
- package/dist/uni_modules.cloud.js +19 -58
- package/dist/uni_modules.d.ts +0 -2
- package/dist/uni_modules.js +2 -81
- package/dist/uts.js +0 -16
- package/dist/vite/autoImport.js +0 -2
- package/dist/vite/cloud.js +5 -51
- package/dist/vite/plugins/index.d.ts +0 -1
- package/dist/vite/plugins/index.js +1 -3
- package/dist/vite/plugins/inject.js +1 -3
- package/dist/vite/plugins/uts/uni_modules.d.ts +0 -1
- package/dist/vite/plugins/uts/uni_modules.js +14 -63
- package/dist/vite/plugins/uts/uvue.js +3 -17
- package/dist/vite/plugins/vitejs/plugins/css.js +5 -40
- package/dist/vue/transforms/transformUTSComponent.js +3 -8
- package/package.json +38 -38
- package/dist/vite/plugins/stats.d.ts +0 -2
- package/dist/vite/plugins/stats.js +0 -42
- package/dist/workers.d.ts +0 -14
- package/dist/workers.js +0 -187
- package/lib/vapor/@vitejs/plugin-vue/LICENSE +0 -21
- package/lib/vapor/@vitejs/plugin-vue/README.md +0 -278
- package/lib/vapor/@vitejs/plugin-vue/dist/index.cjs +0 -3105
- package/lib/vapor/@vitejs/plugin-vue/dist/index.d.cts +0 -113
- package/lib/vapor/@vitejs/plugin-vue/dist/index.d.mts +0 -111
- package/lib/vapor/@vitejs/plugin-vue/dist/index.d.ts +0 -113
- package/lib/vapor/@vitejs/plugin-vue/dist/index.mjs +0 -3090
- package/lib/vapor/@vitejs/plugin-vue/package.json +0 -50
- package/lib/vapor/@vue/compiler-core/LICENSE +0 -21
- package/lib/vapor/@vue/compiler-core/README.md +0 -1
- package/lib/vapor/@vue/compiler-core/dist/compiler-core.cjs.js +0 -6902
- package/lib/vapor/@vue/compiler-core/dist/compiler-core.cjs.prod.js +0 -6779
- package/lib/vapor/@vue/compiler-core/dist/compiler-core.esm-bundler.js +0 -5870
- package/lib/vapor/@vue/compiler-core/index.js +0 -7
- package/lib/vapor/@vue/compiler-core/package.json +0 -58
- package/lib/vapor/@vue/compiler-dom/LICENSE +0 -21
- package/lib/vapor/@vue/compiler-dom/README.md +0 -1
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.cjs.js +0 -936
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +0 -856
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.esm-browser.js +0 -6682
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js +0 -14
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js +0 -693
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.global.js +0 -6855
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.global.prod.js +0 -14
- package/lib/vapor/@vue/compiler-dom/index.js +0 -7
- package/lib/vapor/@vue/compiler-dom/package.json +0 -57
- package/lib/vapor/@vue/compiler-sfc/LICENSE +0 -21
- package/lib/vapor/@vue/compiler-sfc/README.md +0 -80
- package/lib/vapor/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +0 -21682
- package/lib/vapor/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +0 -66272
- package/lib/vapor/@vue/compiler-sfc/package.json +0 -68
- package/lib/vapor/@vue/compiler-ssr/LICENSE +0 -21
- package/lib/vapor/@vue/compiler-ssr/README.md +0 -1
- package/lib/vapor/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +0 -1402
- package/lib/vapor/@vue/compiler-ssr/package.json +0 -34
- package/lib/vapor/@vue/compiler-vapor/LICENSE +0 -21
- package/lib/vapor/@vue/compiler-vapor/README.md +0 -1
- package/lib/vapor/@vue/compiler-vapor/dist/compiler-vapor.cjs.js +0 -4540
- package/lib/vapor/@vue/compiler-vapor/dist/compiler-vapor.esm-browser.js +0 -37020
- package/lib/vapor/@vue/compiler-vapor/package.json +0 -49
- package/lib/vapor/@vue/reactivity/LICENSE +0 -21
- package/lib/vapor/@vue/reactivity/README.md +0 -19
- package/lib/vapor/@vue/reactivity/dist/reactivity.cjs.js +0 -2033
- package/lib/vapor/@vue/reactivity/dist/reactivity.cjs.prod.js +0 -1841
- package/lib/vapor/@vue/reactivity/dist/reactivity.esm-browser.js +0 -2023
- package/lib/vapor/@vue/reactivity/dist/reactivity.esm-browser.prod.js +0 -5
- package/lib/vapor/@vue/reactivity/dist/reactivity.esm-bundler.js +0 -1992
- package/lib/vapor/@vue/reactivity/dist/reactivity.global.js +0 -2082
- package/lib/vapor/@vue/reactivity/dist/reactivity.global.prod.js +0 -5
- package/lib/vapor/@vue/reactivity/index.js +0 -7
- package/lib/vapor/@vue/reactivity/package.json +0 -55
- package/lib/vapor/@vue/runtime-core/LICENSE +0 -21
- package/lib/vapor/@vue/runtime-core/README.md +0 -28
- package/lib/vapor/@vue/runtime-core/dist/runtime-core.cjs.js +0 -8972
- package/lib/vapor/@vue/runtime-core/dist/runtime-core.cjs.prod.js +0 -7088
- package/lib/vapor/@vue/runtime-core/dist/runtime-core.esm-bundler.js +0 -8913
- package/lib/vapor/@vue/runtime-core/index.js +0 -7
- package/lib/vapor/@vue/runtime-core/package.json +0 -54
- package/lib/vapor/@vue/runtime-dom/LICENSE +0 -21
- package/lib/vapor/@vue/runtime-dom/README.md +0 -13
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.cjs.js +0 -1797
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +0 -1646
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.esm-browser.js +0 -12929
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.esm-browser.prod.js +0 -6
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +0 -1838
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.global.js +0 -13086
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.global.prod.js +0 -6
- package/lib/vapor/@vue/runtime-dom/index.js +0 -7
- package/lib/vapor/@vue/runtime-dom/package.json +0 -60
- package/lib/vapor/@vue/runtime-vapor/LICENSE +0 -21
- package/lib/vapor/@vue/runtime-vapor/README.md +0 -8
- package/lib/vapor/@vue/runtime-vapor/dist/runtime-vapor.esm-bundler.js +0 -3242
- package/lib/vapor/@vue/runtime-vapor/package.json +0 -47
- package/lib/vapor/@vue/server-renderer/LICENSE +0 -21
- package/lib/vapor/@vue/server-renderer/README.md +0 -178
- package/lib/vapor/@vue/server-renderer/dist/server-renderer.cjs.js +0 -1144
- package/lib/vapor/@vue/server-renderer/dist/server-renderer.cjs.prod.js +0 -871
- package/lib/vapor/@vue/server-renderer/dist/server-renderer.esm-browser.js +0 -8756
- package/lib/vapor/@vue/server-renderer/dist/server-renderer.esm-browser.prod.js +0 -5
- package/lib/vapor/@vue/server-renderer/dist/server-renderer.esm-bundler.js +0 -1366
- package/lib/vapor/@vue/server-renderer/index.js +0 -7
- package/lib/vapor/@vue/server-renderer/package.json +0 -55
- package/lib/vapor/@vue/shared/LICENSE +0 -21
- package/lib/vapor/@vue/shared/README.md +0 -3
- package/lib/vapor/@vue/shared/dist/shared.cjs.js +0 -698
- package/lib/vapor/@vue/shared/dist/shared.cjs.prod.js +0 -690
- package/lib/vapor/@vue/shared/dist/shared.esm-bundler.js +0 -616
- package/lib/vapor/@vue/shared/index.js +0 -7
- package/lib/vapor/@vue/shared/package.json +0 -47
- package/lib/vapor/@vue/vue/LICENSE +0 -21
- package/lib/vapor/@vue/vue/README.md +0 -62
- package/lib/vapor/@vue/vue/compiler-sfc/index.browser.js +0 -1
- package/lib/vapor/@vue/vue/compiler-sfc/index.browser.mjs +0 -1
- package/lib/vapor/@vue/vue/compiler-sfc/index.d.mts +0 -1
- package/lib/vapor/@vue/vue/compiler-sfc/index.d.ts +0 -1
- package/lib/vapor/@vue/vue/compiler-sfc/index.js +0 -3
- package/lib/vapor/@vue/vue/compiler-sfc/index.mjs +0 -3
- package/lib/vapor/@vue/vue/compiler-sfc/package.json +0 -4
- package/lib/vapor/@vue/vue/compiler-sfc/register-ts.js +0 -3
- package/lib/vapor/@vue/vue/dist/vue.cjs.js +0 -80
- package/lib/vapor/@vue/vue/dist/vue.cjs.prod.js +0 -66
- package/lib/vapor/@vue/vue/dist/vue.esm-browser.js +0 -18840
- package/lib/vapor/@vue/vue/dist/vue.esm-browser.prod.js +0 -12
- package/lib/vapor/@vue/vue/dist/vue.esm-bundler.js +0 -72
- package/lib/vapor/@vue/vue/dist/vue.global.js +0 -18820
- package/lib/vapor/@vue/vue/dist/vue.global.prod.js +0 -12
- package/lib/vapor/@vue/vue/dist/vue.runtime-with-vapor.esm-browser.js +0 -15648
- package/lib/vapor/@vue/vue/dist/vue.runtime-with-vapor.esm-browser.prod.js +0 -9
- package/lib/vapor/@vue/vue/dist/vue.runtime.esm-browser.js +0 -12953
- package/lib/vapor/@vue/vue/dist/vue.runtime.esm-browser.prod.js +0 -6
- package/lib/vapor/@vue/vue/dist/vue.runtime.esm-bundler.js +0 -29
- package/lib/vapor/@vue/vue/dist/vue.runtime.global.js +0 -13111
- package/lib/vapor/@vue/vue/dist/vue.runtime.global.prod.js +0 -6
- package/lib/vapor/@vue/vue/index.js +0 -7
- package/lib/vapor/@vue/vue/index.mjs +0 -1
- package/lib/vapor/@vue/vue/jsx-runtime/index.d.ts +0 -25
- package/lib/vapor/@vue/vue/jsx-runtime/index.js +0 -15
- package/lib/vapor/@vue/vue/jsx-runtime/index.mjs +0 -12
- package/lib/vapor/@vue/vue/jsx-runtime/package.json +0 -5
- package/lib/vapor/@vue/vue/jsx.d.ts +0 -22
- package/lib/vapor/@vue/vue/package.json +0 -114
- package/lib/vapor/@vue/vue/server-renderer/index.d.mts +0 -1
- package/lib/vapor/@vue/vue/server-renderer/index.d.ts +0 -1
- package/lib/vapor/@vue/vue/server-renderer/index.js +0 -1
- package/lib/vapor/@vue/vue/server-renderer/index.mjs +0 -1
- package/lib/vapor/@vue/vue/server-renderer/package.json +0 -4
|
@@ -1,936 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @vue/compiler-dom v3.6.0-alpha.2
|
|
3
|
-
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
|
-
* @license MIT
|
|
5
|
-
**/
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
|
-
|
|
10
|
-
var compilerCore = require('@vue/compiler-core');
|
|
11
|
-
var shared = require('@vue/shared');
|
|
12
|
-
|
|
13
|
-
const V_MODEL_RADIO = Symbol(`vModelRadio` );
|
|
14
|
-
const V_MODEL_CHECKBOX = Symbol(
|
|
15
|
-
`vModelCheckbox`
|
|
16
|
-
);
|
|
17
|
-
const V_MODEL_TEXT = Symbol(`vModelText` );
|
|
18
|
-
const V_MODEL_SELECT = Symbol(
|
|
19
|
-
`vModelSelect`
|
|
20
|
-
);
|
|
21
|
-
const V_MODEL_DYNAMIC = Symbol(
|
|
22
|
-
`vModelDynamic`
|
|
23
|
-
);
|
|
24
|
-
const V_ON_WITH_MODIFIERS = Symbol(
|
|
25
|
-
`vOnModifiersGuard`
|
|
26
|
-
);
|
|
27
|
-
const V_ON_WITH_KEYS = Symbol(
|
|
28
|
-
`vOnKeysGuard`
|
|
29
|
-
);
|
|
30
|
-
const V_SHOW = Symbol(`vShow` );
|
|
31
|
-
const TRANSITION = Symbol(`Transition` );
|
|
32
|
-
const TRANSITION_GROUP = Symbol(
|
|
33
|
-
`TransitionGroup`
|
|
34
|
-
);
|
|
35
|
-
compilerCore.registerRuntimeHelpers({
|
|
36
|
-
[V_MODEL_RADIO]: `vModelRadio`,
|
|
37
|
-
[V_MODEL_CHECKBOX]: `vModelCheckbox`,
|
|
38
|
-
[V_MODEL_TEXT]: `vModelText`,
|
|
39
|
-
[V_MODEL_SELECT]: `vModelSelect`,
|
|
40
|
-
[V_MODEL_DYNAMIC]: `vModelDynamic`,
|
|
41
|
-
[V_ON_WITH_MODIFIERS]: `withModifiers`,
|
|
42
|
-
[V_ON_WITH_KEYS]: `withKeys`,
|
|
43
|
-
[V_SHOW]: `vShow`,
|
|
44
|
-
[TRANSITION]: `Transition`,
|
|
45
|
-
[TRANSITION_GROUP]: `TransitionGroup`
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const parserOptions = {
|
|
49
|
-
parseMode: "html",
|
|
50
|
-
isVoidTag: shared.isVoidTag,
|
|
51
|
-
isNativeTag: (tag) => shared.isHTMLTag(tag) || shared.isSVGTag(tag) || shared.isMathMLTag(tag),
|
|
52
|
-
isPreTag: (tag) => tag === "pre",
|
|
53
|
-
isIgnoreNewlineTag: (tag) => tag === "pre" || tag === "textarea",
|
|
54
|
-
decodeEntities: void 0,
|
|
55
|
-
isBuiltInComponent: (tag) => {
|
|
56
|
-
if (tag === "Transition" || tag === "transition") {
|
|
57
|
-
return TRANSITION;
|
|
58
|
-
} else if (tag === "TransitionGroup" || tag === "transition-group") {
|
|
59
|
-
return TRANSITION_GROUP;
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
// https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
|
|
63
|
-
getNamespace(tag, parent, rootNamespace) {
|
|
64
|
-
let ns = parent ? parent.ns : rootNamespace;
|
|
65
|
-
if (parent && ns === 2) {
|
|
66
|
-
if (parent.tag === "annotation-xml") {
|
|
67
|
-
if (tag === "svg") {
|
|
68
|
-
return 1;
|
|
69
|
-
}
|
|
70
|
-
if (parent.props.some(
|
|
71
|
-
(a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
|
|
72
|
-
)) {
|
|
73
|
-
ns = 0;
|
|
74
|
-
}
|
|
75
|
-
} else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
|
|
76
|
-
ns = 0;
|
|
77
|
-
}
|
|
78
|
-
} else if (parent && ns === 1) {
|
|
79
|
-
if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
|
|
80
|
-
ns = 0;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (ns === 0) {
|
|
84
|
-
if (tag === "svg") {
|
|
85
|
-
return 1;
|
|
86
|
-
}
|
|
87
|
-
if (tag === "math") {
|
|
88
|
-
return 2;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return ns;
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const transformStyle = (node) => {
|
|
96
|
-
if (node.type === 1) {
|
|
97
|
-
node.props.forEach((p, i) => {
|
|
98
|
-
if (p.type === 6 && p.name === "style" && p.value) {
|
|
99
|
-
node.props[i] = {
|
|
100
|
-
type: 7,
|
|
101
|
-
name: `bind`,
|
|
102
|
-
arg: compilerCore.createSimpleExpression(`style`, true, p.loc),
|
|
103
|
-
exp: parseInlineCSS(p.value.content, p.loc),
|
|
104
|
-
modifiers: [],
|
|
105
|
-
loc: p.loc
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
const parseInlineCSS = (cssText, loc) => {
|
|
112
|
-
const normalized = shared.parseStringStyle(cssText);
|
|
113
|
-
return compilerCore.createSimpleExpression(
|
|
114
|
-
JSON.stringify(normalized),
|
|
115
|
-
false,
|
|
116
|
-
loc,
|
|
117
|
-
3
|
|
118
|
-
);
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
function createDOMCompilerError(code, loc) {
|
|
122
|
-
return compilerCore.createCompilerError(
|
|
123
|
-
code,
|
|
124
|
-
loc,
|
|
125
|
-
DOMErrorMessages
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
const DOMErrorCodes = {
|
|
129
|
-
"X_V_HTML_NO_EXPRESSION": 53,
|
|
130
|
-
"53": "X_V_HTML_NO_EXPRESSION",
|
|
131
|
-
"X_V_HTML_WITH_CHILDREN": 54,
|
|
132
|
-
"54": "X_V_HTML_WITH_CHILDREN",
|
|
133
|
-
"X_V_TEXT_NO_EXPRESSION": 55,
|
|
134
|
-
"55": "X_V_TEXT_NO_EXPRESSION",
|
|
135
|
-
"X_V_TEXT_WITH_CHILDREN": 56,
|
|
136
|
-
"56": "X_V_TEXT_WITH_CHILDREN",
|
|
137
|
-
"X_V_MODEL_ON_INVALID_ELEMENT": 57,
|
|
138
|
-
"57": "X_V_MODEL_ON_INVALID_ELEMENT",
|
|
139
|
-
"X_V_MODEL_ARG_ON_ELEMENT": 58,
|
|
140
|
-
"58": "X_V_MODEL_ARG_ON_ELEMENT",
|
|
141
|
-
"X_V_MODEL_ON_FILE_INPUT_ELEMENT": 59,
|
|
142
|
-
"59": "X_V_MODEL_ON_FILE_INPUT_ELEMENT",
|
|
143
|
-
"X_V_MODEL_UNNECESSARY_VALUE": 60,
|
|
144
|
-
"60": "X_V_MODEL_UNNECESSARY_VALUE",
|
|
145
|
-
"X_V_SHOW_NO_EXPRESSION": 61,
|
|
146
|
-
"61": "X_V_SHOW_NO_EXPRESSION",
|
|
147
|
-
"X_TRANSITION_INVALID_CHILDREN": 62,
|
|
148
|
-
"62": "X_TRANSITION_INVALID_CHILDREN",
|
|
149
|
-
"X_IGNORED_SIDE_EFFECT_TAG": 63,
|
|
150
|
-
"63": "X_IGNORED_SIDE_EFFECT_TAG",
|
|
151
|
-
"__EXTEND_POINT__": 64,
|
|
152
|
-
"64": "__EXTEND_POINT__"
|
|
153
|
-
};
|
|
154
|
-
const DOMErrorMessages = {
|
|
155
|
-
[53]: `v-html is missing expression.`,
|
|
156
|
-
[54]: `v-html will override element children.`,
|
|
157
|
-
[55]: `v-text is missing expression.`,
|
|
158
|
-
[56]: `v-text will override element children.`,
|
|
159
|
-
[57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
|
|
160
|
-
[58]: `v-model argument is not supported on plain elements.`,
|
|
161
|
-
[59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
|
|
162
|
-
[60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
|
|
163
|
-
[61]: `v-show is missing expression.`,
|
|
164
|
-
[62]: `<Transition> expects exactly one child element or component.`,
|
|
165
|
-
[63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`,
|
|
166
|
-
// just to fulfill types
|
|
167
|
-
[64]: ``
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
const transformVHtml = (dir, node, context) => {
|
|
171
|
-
const { exp, loc } = dir;
|
|
172
|
-
if (!exp) {
|
|
173
|
-
context.onError(
|
|
174
|
-
createDOMCompilerError(53, loc)
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
if (node.children.length) {
|
|
178
|
-
context.onError(
|
|
179
|
-
createDOMCompilerError(54, loc)
|
|
180
|
-
);
|
|
181
|
-
node.children.length = 0;
|
|
182
|
-
}
|
|
183
|
-
return {
|
|
184
|
-
props: [
|
|
185
|
-
compilerCore.createObjectProperty(
|
|
186
|
-
compilerCore.createSimpleExpression(`innerHTML`, true, loc),
|
|
187
|
-
exp || compilerCore.createSimpleExpression("", true)
|
|
188
|
-
)
|
|
189
|
-
]
|
|
190
|
-
};
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
const transformVText = (dir, node, context) => {
|
|
194
|
-
const { exp, loc } = dir;
|
|
195
|
-
if (!exp) {
|
|
196
|
-
context.onError(
|
|
197
|
-
createDOMCompilerError(55, loc)
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
if (node.children.length) {
|
|
201
|
-
context.onError(
|
|
202
|
-
createDOMCompilerError(56, loc)
|
|
203
|
-
);
|
|
204
|
-
node.children.length = 0;
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
props: [
|
|
208
|
-
compilerCore.createObjectProperty(
|
|
209
|
-
compilerCore.createSimpleExpression(`textContent`, true),
|
|
210
|
-
exp ? compilerCore.getConstantType(exp, context) > 0 ? exp : compilerCore.createCallExpression(
|
|
211
|
-
context.helperString(compilerCore.TO_DISPLAY_STRING),
|
|
212
|
-
[exp],
|
|
213
|
-
loc
|
|
214
|
-
) : compilerCore.createSimpleExpression("", true)
|
|
215
|
-
)
|
|
216
|
-
]
|
|
217
|
-
};
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
const transformModel = (dir, node, context) => {
|
|
221
|
-
const baseResult = compilerCore.transformModel(dir, node, context);
|
|
222
|
-
if (!baseResult.props.length || node.tagType === 1) {
|
|
223
|
-
return baseResult;
|
|
224
|
-
}
|
|
225
|
-
if (dir.arg) {
|
|
226
|
-
context.onError(
|
|
227
|
-
createDOMCompilerError(
|
|
228
|
-
58,
|
|
229
|
-
dir.arg.loc
|
|
230
|
-
)
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
function checkDuplicatedValue() {
|
|
234
|
-
const value = compilerCore.findDir(node, "bind");
|
|
235
|
-
if (value && compilerCore.isStaticArgOf(value.arg, "value")) {
|
|
236
|
-
context.onError(
|
|
237
|
-
createDOMCompilerError(
|
|
238
|
-
60,
|
|
239
|
-
value.loc
|
|
240
|
-
)
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
const { tag } = node;
|
|
245
|
-
const isCustomElement = context.isCustomElement(tag);
|
|
246
|
-
if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
|
|
247
|
-
let directiveToUse = V_MODEL_TEXT;
|
|
248
|
-
let isInvalidType = false;
|
|
249
|
-
if (tag === "input" || isCustomElement) {
|
|
250
|
-
const type = compilerCore.findProp(node, `type`);
|
|
251
|
-
if (type) {
|
|
252
|
-
if (type.type === 7) {
|
|
253
|
-
directiveToUse = V_MODEL_DYNAMIC;
|
|
254
|
-
} else if (type.value) {
|
|
255
|
-
switch (type.value.content) {
|
|
256
|
-
case "radio":
|
|
257
|
-
directiveToUse = V_MODEL_RADIO;
|
|
258
|
-
break;
|
|
259
|
-
case "checkbox":
|
|
260
|
-
directiveToUse = V_MODEL_CHECKBOX;
|
|
261
|
-
break;
|
|
262
|
-
case "file":
|
|
263
|
-
isInvalidType = true;
|
|
264
|
-
context.onError(
|
|
265
|
-
createDOMCompilerError(
|
|
266
|
-
59,
|
|
267
|
-
dir.loc
|
|
268
|
-
)
|
|
269
|
-
);
|
|
270
|
-
break;
|
|
271
|
-
default:
|
|
272
|
-
checkDuplicatedValue();
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
} else if (compilerCore.hasDynamicKeyVBind(node)) {
|
|
277
|
-
directiveToUse = V_MODEL_DYNAMIC;
|
|
278
|
-
} else {
|
|
279
|
-
checkDuplicatedValue();
|
|
280
|
-
}
|
|
281
|
-
} else if (tag === "select") {
|
|
282
|
-
directiveToUse = V_MODEL_SELECT;
|
|
283
|
-
} else {
|
|
284
|
-
checkDuplicatedValue();
|
|
285
|
-
}
|
|
286
|
-
if (!isInvalidType) {
|
|
287
|
-
baseResult.needRuntime = context.helper(directiveToUse);
|
|
288
|
-
}
|
|
289
|
-
} else {
|
|
290
|
-
context.onError(
|
|
291
|
-
createDOMCompilerError(
|
|
292
|
-
57,
|
|
293
|
-
dir.loc
|
|
294
|
-
)
|
|
295
|
-
);
|
|
296
|
-
}
|
|
297
|
-
baseResult.props = baseResult.props.filter(
|
|
298
|
-
(p) => !(p.key.type === 4 && p.key.content === "modelValue")
|
|
299
|
-
);
|
|
300
|
-
return baseResult;
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
const isEventOptionModifier = /* @__PURE__ */ shared.makeMap(`passive,once,capture`);
|
|
304
|
-
const isNonKeyModifier = /* @__PURE__ */ shared.makeMap(
|
|
305
|
-
// event propagation management
|
|
306
|
-
`stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
|
|
307
|
-
);
|
|
308
|
-
const maybeKeyModifier = /* @__PURE__ */ shared.makeMap("left,right");
|
|
309
|
-
const isKeyboardEvent = /* @__PURE__ */ shared.makeMap(`onkeyup,onkeydown,onkeypress`);
|
|
310
|
-
const resolveModifiers = (key, modifiers, context, loc) => {
|
|
311
|
-
const keyModifiers = [];
|
|
312
|
-
const nonKeyModifiers = [];
|
|
313
|
-
const eventOptionModifiers = [];
|
|
314
|
-
for (let i = 0; i < modifiers.length; i++) {
|
|
315
|
-
const modifier = modifiers[i].content;
|
|
316
|
-
if (modifier === "native" && context && compilerCore.checkCompatEnabled(
|
|
317
|
-
"COMPILER_V_ON_NATIVE",
|
|
318
|
-
context,
|
|
319
|
-
loc
|
|
320
|
-
)) {
|
|
321
|
-
eventOptionModifiers.push(modifier);
|
|
322
|
-
} else if (isEventOptionModifier(modifier)) {
|
|
323
|
-
eventOptionModifiers.push(modifier);
|
|
324
|
-
} else {
|
|
325
|
-
const keyString = shared.isString(key) ? key : compilerCore.isStaticExp(key) ? key.content : null;
|
|
326
|
-
if (maybeKeyModifier(modifier)) {
|
|
327
|
-
if (keyString) {
|
|
328
|
-
if (isKeyboardEvent(keyString.toLowerCase())) {
|
|
329
|
-
keyModifiers.push(modifier);
|
|
330
|
-
} else {
|
|
331
|
-
nonKeyModifiers.push(modifier);
|
|
332
|
-
}
|
|
333
|
-
} else {
|
|
334
|
-
keyModifiers.push(modifier);
|
|
335
|
-
nonKeyModifiers.push(modifier);
|
|
336
|
-
}
|
|
337
|
-
} else {
|
|
338
|
-
if (isNonKeyModifier(modifier)) {
|
|
339
|
-
nonKeyModifiers.push(modifier);
|
|
340
|
-
} else {
|
|
341
|
-
keyModifiers.push(modifier);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
return {
|
|
347
|
-
keyModifiers,
|
|
348
|
-
nonKeyModifiers,
|
|
349
|
-
eventOptionModifiers
|
|
350
|
-
};
|
|
351
|
-
};
|
|
352
|
-
const transformClick = (key, event) => {
|
|
353
|
-
const isStaticClick = compilerCore.isStaticExp(key) && key.content.toLowerCase() === "onclick";
|
|
354
|
-
return isStaticClick ? compilerCore.createSimpleExpression(event, true) : key.type !== 4 ? compilerCore.createCompoundExpression([
|
|
355
|
-
`(`,
|
|
356
|
-
key,
|
|
357
|
-
`) === "onClick" ? "${event}" : (`,
|
|
358
|
-
key,
|
|
359
|
-
`)`
|
|
360
|
-
]) : key;
|
|
361
|
-
};
|
|
362
|
-
const transformOn = (dir, node, context) => {
|
|
363
|
-
return compilerCore.transformOn(dir, node, context, (baseResult) => {
|
|
364
|
-
const { modifiers } = dir;
|
|
365
|
-
if (!modifiers.length) return baseResult;
|
|
366
|
-
let { key, value: handlerExp } = baseResult.props[0];
|
|
367
|
-
const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
|
|
368
|
-
if (nonKeyModifiers.includes("right")) {
|
|
369
|
-
key = transformClick(key, `onContextmenu`);
|
|
370
|
-
}
|
|
371
|
-
if (nonKeyModifiers.includes("middle")) {
|
|
372
|
-
key = transformClick(key, `onMouseup`);
|
|
373
|
-
}
|
|
374
|
-
if (nonKeyModifiers.length) {
|
|
375
|
-
handlerExp = compilerCore.createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
|
|
376
|
-
handlerExp,
|
|
377
|
-
JSON.stringify(nonKeyModifiers)
|
|
378
|
-
]);
|
|
379
|
-
}
|
|
380
|
-
if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
|
|
381
|
-
(!compilerCore.isStaticExp(key) || isKeyboardEvent(key.content.toLowerCase()))) {
|
|
382
|
-
handlerExp = compilerCore.createCallExpression(context.helper(V_ON_WITH_KEYS), [
|
|
383
|
-
handlerExp,
|
|
384
|
-
JSON.stringify(keyModifiers)
|
|
385
|
-
]);
|
|
386
|
-
}
|
|
387
|
-
if (eventOptionModifiers.length) {
|
|
388
|
-
const modifierPostfix = eventOptionModifiers.map(shared.capitalize).join("");
|
|
389
|
-
key = compilerCore.isStaticExp(key) ? compilerCore.createSimpleExpression(`${key.content}${modifierPostfix}`, true) : compilerCore.createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
|
|
390
|
-
}
|
|
391
|
-
return {
|
|
392
|
-
props: [compilerCore.createObjectProperty(key, handlerExp)]
|
|
393
|
-
};
|
|
394
|
-
});
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
const transformShow = (dir, node, context) => {
|
|
398
|
-
const { exp, loc } = dir;
|
|
399
|
-
if (!exp) {
|
|
400
|
-
context.onError(
|
|
401
|
-
createDOMCompilerError(61, loc)
|
|
402
|
-
);
|
|
403
|
-
}
|
|
404
|
-
return {
|
|
405
|
-
props: [],
|
|
406
|
-
needRuntime: context.helper(V_SHOW)
|
|
407
|
-
};
|
|
408
|
-
};
|
|
409
|
-
|
|
410
|
-
const transformTransition = (node, context) => {
|
|
411
|
-
if (node.type === 1 && node.tagType === 1) {
|
|
412
|
-
const component = context.isBuiltInComponent(node.tag);
|
|
413
|
-
if (component === TRANSITION) {
|
|
414
|
-
return () => {
|
|
415
|
-
if (!node.children.length) {
|
|
416
|
-
return;
|
|
417
|
-
}
|
|
418
|
-
if (hasMultipleChildren(node)) {
|
|
419
|
-
context.onError(
|
|
420
|
-
createDOMCompilerError(
|
|
421
|
-
62,
|
|
422
|
-
{
|
|
423
|
-
start: node.children[0].loc.start,
|
|
424
|
-
end: node.children[node.children.length - 1].loc.end,
|
|
425
|
-
source: ""
|
|
426
|
-
}
|
|
427
|
-
)
|
|
428
|
-
);
|
|
429
|
-
}
|
|
430
|
-
const child = node.children[0];
|
|
431
|
-
if (child.type === 1) {
|
|
432
|
-
for (const p of child.props) {
|
|
433
|
-
if (p.type === 7 && p.name === "show") {
|
|
434
|
-
node.props.push({
|
|
435
|
-
type: 6,
|
|
436
|
-
name: "persisted",
|
|
437
|
-
nameLoc: node.loc,
|
|
438
|
-
value: void 0,
|
|
439
|
-
loc: node.loc
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
};
|
|
448
|
-
function hasMultipleChildren(node) {
|
|
449
|
-
const children = node.children = node.children.filter(
|
|
450
|
-
(c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
|
|
451
|
-
);
|
|
452
|
-
const child = children[0];
|
|
453
|
-
return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
|
|
457
|
-
const stringifyStatic = (children, context, parent) => {
|
|
458
|
-
if (context.scopes.vSlot > 0) {
|
|
459
|
-
return;
|
|
460
|
-
}
|
|
461
|
-
const isParentCached = parent.type === 1 && parent.codegenNode && parent.codegenNode.type === 13 && parent.codegenNode.children && !shared.isArray(parent.codegenNode.children) && parent.codegenNode.children.type === 20;
|
|
462
|
-
let nc = 0;
|
|
463
|
-
let ec = 0;
|
|
464
|
-
const currentChunk = [];
|
|
465
|
-
const stringifyCurrentChunk = (currentIndex) => {
|
|
466
|
-
if (nc >= 20 || ec >= 5) {
|
|
467
|
-
const staticCall = compilerCore.createCallExpression(context.helper(compilerCore.CREATE_STATIC), [
|
|
468
|
-
JSON.stringify(
|
|
469
|
-
currentChunk.map((node) => stringifyNode(node, context)).join("")
|
|
470
|
-
).replace(expReplaceRE, `" + $1 + "`),
|
|
471
|
-
// the 2nd argument indicates the number of DOM nodes this static vnode
|
|
472
|
-
// will insert / hydrate
|
|
473
|
-
String(currentChunk.length)
|
|
474
|
-
]);
|
|
475
|
-
const deleteCount = currentChunk.length - 1;
|
|
476
|
-
if (isParentCached) {
|
|
477
|
-
children.splice(
|
|
478
|
-
currentIndex - currentChunk.length,
|
|
479
|
-
currentChunk.length,
|
|
480
|
-
// @ts-expect-error
|
|
481
|
-
staticCall
|
|
482
|
-
);
|
|
483
|
-
} else {
|
|
484
|
-
currentChunk[0].codegenNode.value = staticCall;
|
|
485
|
-
if (currentChunk.length > 1) {
|
|
486
|
-
children.splice(currentIndex - currentChunk.length + 1, deleteCount);
|
|
487
|
-
const cacheIndex = context.cached.indexOf(
|
|
488
|
-
currentChunk[currentChunk.length - 1].codegenNode
|
|
489
|
-
);
|
|
490
|
-
if (cacheIndex > -1) {
|
|
491
|
-
for (let i2 = cacheIndex; i2 < context.cached.length; i2++) {
|
|
492
|
-
const c = context.cached[i2];
|
|
493
|
-
if (c) c.index -= deleteCount;
|
|
494
|
-
}
|
|
495
|
-
context.cached.splice(cacheIndex - deleteCount + 1, deleteCount);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
return deleteCount;
|
|
500
|
-
}
|
|
501
|
-
return 0;
|
|
502
|
-
};
|
|
503
|
-
let i = 0;
|
|
504
|
-
for (; i < children.length; i++) {
|
|
505
|
-
const child = children[i];
|
|
506
|
-
const isCached = isParentCached || getCachedNode(child);
|
|
507
|
-
if (isCached) {
|
|
508
|
-
const result = analyzeNode(child);
|
|
509
|
-
if (result) {
|
|
510
|
-
nc += result[0];
|
|
511
|
-
ec += result[1];
|
|
512
|
-
currentChunk.push(child);
|
|
513
|
-
continue;
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
i -= stringifyCurrentChunk(i);
|
|
517
|
-
nc = 0;
|
|
518
|
-
ec = 0;
|
|
519
|
-
currentChunk.length = 0;
|
|
520
|
-
}
|
|
521
|
-
stringifyCurrentChunk(i);
|
|
522
|
-
};
|
|
523
|
-
const getCachedNode = (node) => {
|
|
524
|
-
if ((node.type === 1 && node.tagType === 0 || node.type === 12) && node.codegenNode && node.codegenNode.type === 20) {
|
|
525
|
-
return node.codegenNode;
|
|
526
|
-
}
|
|
527
|
-
};
|
|
528
|
-
const dataAriaRE = /^(data|aria)-/;
|
|
529
|
-
const isStringifiableAttr = (name, ns) => {
|
|
530
|
-
return (ns === 0 ? shared.isKnownHtmlAttr(name) : ns === 1 ? shared.isKnownSvgAttr(name) : ns === 2 ? shared.isKnownMathMLAttr(name) : false) || dataAriaRE.test(name);
|
|
531
|
-
};
|
|
532
|
-
const isNonStringifiable = /* @__PURE__ */ shared.makeMap(
|
|
533
|
-
`caption,thead,tr,th,tbody,td,tfoot,colgroup,col`
|
|
534
|
-
);
|
|
535
|
-
function analyzeNode(node) {
|
|
536
|
-
if (node.type === 1 && isNonStringifiable(node.tag)) {
|
|
537
|
-
return false;
|
|
538
|
-
}
|
|
539
|
-
if (node.type === 12) {
|
|
540
|
-
return [1, 0];
|
|
541
|
-
}
|
|
542
|
-
let nc = 1;
|
|
543
|
-
let ec = node.props.length > 0 ? 1 : 0;
|
|
544
|
-
let bailed = false;
|
|
545
|
-
const bail = () => {
|
|
546
|
-
bailed = true;
|
|
547
|
-
return false;
|
|
548
|
-
};
|
|
549
|
-
function walk(node2) {
|
|
550
|
-
const isOptionTag = node2.tag === "option" && node2.ns === 0;
|
|
551
|
-
for (let i = 0; i < node2.props.length; i++) {
|
|
552
|
-
const p = node2.props[i];
|
|
553
|
-
if (p.type === 6 && !isStringifiableAttr(p.name, node2.ns)) {
|
|
554
|
-
return bail();
|
|
555
|
-
}
|
|
556
|
-
if (p.type === 7 && p.name === "bind") {
|
|
557
|
-
if (p.arg && (p.arg.type === 8 || p.arg.isStatic && !isStringifiableAttr(p.arg.content, node2.ns))) {
|
|
558
|
-
return bail();
|
|
559
|
-
}
|
|
560
|
-
if (p.exp && (p.exp.type === 8 || p.exp.constType < 3)) {
|
|
561
|
-
return bail();
|
|
562
|
-
}
|
|
563
|
-
if (isOptionTag && compilerCore.isStaticArgOf(p.arg, "value") && p.exp && !p.exp.isStatic) {
|
|
564
|
-
return bail();
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
for (let i = 0; i < node2.children.length; i++) {
|
|
569
|
-
nc++;
|
|
570
|
-
const child = node2.children[i];
|
|
571
|
-
if (child.type === 1) {
|
|
572
|
-
if (child.props.length > 0) {
|
|
573
|
-
ec++;
|
|
574
|
-
}
|
|
575
|
-
walk(child);
|
|
576
|
-
if (bailed) {
|
|
577
|
-
return false;
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
return true;
|
|
582
|
-
}
|
|
583
|
-
return walk(node) ? [nc, ec] : false;
|
|
584
|
-
}
|
|
585
|
-
function stringifyNode(node, context) {
|
|
586
|
-
if (shared.isString(node)) {
|
|
587
|
-
return node;
|
|
588
|
-
}
|
|
589
|
-
if (shared.isSymbol(node)) {
|
|
590
|
-
return ``;
|
|
591
|
-
}
|
|
592
|
-
switch (node.type) {
|
|
593
|
-
case 1:
|
|
594
|
-
return stringifyElement(node, context);
|
|
595
|
-
case 2:
|
|
596
|
-
return shared.escapeHtml(node.content);
|
|
597
|
-
case 3:
|
|
598
|
-
return `<!--${shared.escapeHtml(node.content)}-->`;
|
|
599
|
-
case 5:
|
|
600
|
-
return shared.escapeHtml(shared.toDisplayString(evaluateConstant(node.content)));
|
|
601
|
-
case 8:
|
|
602
|
-
return shared.escapeHtml(evaluateConstant(node));
|
|
603
|
-
case 12:
|
|
604
|
-
return stringifyNode(node.content, context);
|
|
605
|
-
default:
|
|
606
|
-
return "";
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
function stringifyElement(node, context) {
|
|
610
|
-
let res = `<${node.tag}`;
|
|
611
|
-
let innerHTML = "";
|
|
612
|
-
for (let i = 0; i < node.props.length; i++) {
|
|
613
|
-
const p = node.props[i];
|
|
614
|
-
if (p.type === 6) {
|
|
615
|
-
res += ` ${p.name}`;
|
|
616
|
-
if (p.value) {
|
|
617
|
-
res += `="${shared.escapeHtml(p.value.content)}"`;
|
|
618
|
-
}
|
|
619
|
-
} else if (p.type === 7) {
|
|
620
|
-
if (p.name === "bind") {
|
|
621
|
-
const exp = p.exp;
|
|
622
|
-
if (exp.content[0] === "_") {
|
|
623
|
-
res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
|
|
624
|
-
continue;
|
|
625
|
-
}
|
|
626
|
-
if (shared.isBooleanAttr(p.arg.content) && exp.content === "false") {
|
|
627
|
-
continue;
|
|
628
|
-
}
|
|
629
|
-
let evaluated = evaluateConstant(exp);
|
|
630
|
-
if (evaluated != null) {
|
|
631
|
-
const arg = p.arg && p.arg.content;
|
|
632
|
-
if (arg === "class") {
|
|
633
|
-
evaluated = shared.normalizeClass(evaluated);
|
|
634
|
-
} else if (arg === "style") {
|
|
635
|
-
evaluated = shared.stringifyStyle(shared.normalizeStyle(evaluated));
|
|
636
|
-
}
|
|
637
|
-
res += ` ${p.arg.content}="${shared.escapeHtml(
|
|
638
|
-
evaluated
|
|
639
|
-
)}"`;
|
|
640
|
-
}
|
|
641
|
-
} else if (p.name === "html") {
|
|
642
|
-
innerHTML = evaluateConstant(p.exp);
|
|
643
|
-
} else if (p.name === "text") {
|
|
644
|
-
innerHTML = shared.escapeHtml(
|
|
645
|
-
shared.toDisplayString(evaluateConstant(p.exp))
|
|
646
|
-
);
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
if (context.scopeId) {
|
|
651
|
-
res += ` ${context.scopeId}`;
|
|
652
|
-
}
|
|
653
|
-
res += `>`;
|
|
654
|
-
if (innerHTML) {
|
|
655
|
-
res += innerHTML;
|
|
656
|
-
} else {
|
|
657
|
-
for (let i = 0; i < node.children.length; i++) {
|
|
658
|
-
res += stringifyNode(node.children[i], context);
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
if (!shared.isVoidTag(node.tag)) {
|
|
662
|
-
res += `</${node.tag}>`;
|
|
663
|
-
}
|
|
664
|
-
return res;
|
|
665
|
-
}
|
|
666
|
-
function evaluateConstant(exp) {
|
|
667
|
-
if (exp.type === 4) {
|
|
668
|
-
return new Function(`return (${exp.content})`)();
|
|
669
|
-
} else {
|
|
670
|
-
let res = ``;
|
|
671
|
-
exp.children.forEach((c) => {
|
|
672
|
-
if (shared.isString(c) || shared.isSymbol(c)) {
|
|
673
|
-
return;
|
|
674
|
-
}
|
|
675
|
-
if (c.type === 2) {
|
|
676
|
-
res += c.content;
|
|
677
|
-
} else if (c.type === 5) {
|
|
678
|
-
res += shared.toDisplayString(evaluateConstant(c.content));
|
|
679
|
-
} else {
|
|
680
|
-
res += evaluateConstant(c);
|
|
681
|
-
}
|
|
682
|
-
});
|
|
683
|
-
return res;
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
const ignoreSideEffectTags = (node, context) => {
|
|
688
|
-
if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
|
|
689
|
-
context.onError(
|
|
690
|
-
createDOMCompilerError(
|
|
691
|
-
63,
|
|
692
|
-
node.loc
|
|
693
|
-
)
|
|
694
|
-
);
|
|
695
|
-
context.removeNode();
|
|
696
|
-
}
|
|
697
|
-
};
|
|
698
|
-
|
|
699
|
-
function isValidHTMLNesting(parent, child) {
|
|
700
|
-
if (parent === "template") {
|
|
701
|
-
return true;
|
|
702
|
-
}
|
|
703
|
-
if (parent in onlyValidChildren) {
|
|
704
|
-
return onlyValidChildren[parent].has(child);
|
|
705
|
-
}
|
|
706
|
-
if (child in onlyValidParents) {
|
|
707
|
-
return onlyValidParents[child].has(parent);
|
|
708
|
-
}
|
|
709
|
-
if (parent in knownInvalidChildren) {
|
|
710
|
-
if (knownInvalidChildren[parent].has(child)) return false;
|
|
711
|
-
}
|
|
712
|
-
if (child in knownInvalidParents) {
|
|
713
|
-
if (knownInvalidParents[child].has(parent)) return false;
|
|
714
|
-
}
|
|
715
|
-
return true;
|
|
716
|
-
}
|
|
717
|
-
const headings = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
|
|
718
|
-
const emptySet = /* @__PURE__ */ new Set([]);
|
|
719
|
-
const onlyValidChildren = {
|
|
720
|
-
head: /* @__PURE__ */ new Set([
|
|
721
|
-
"base",
|
|
722
|
-
"basefront",
|
|
723
|
-
"bgsound",
|
|
724
|
-
"link",
|
|
725
|
-
"meta",
|
|
726
|
-
"title",
|
|
727
|
-
"noscript",
|
|
728
|
-
"noframes",
|
|
729
|
-
"style",
|
|
730
|
-
"script",
|
|
731
|
-
"template"
|
|
732
|
-
]),
|
|
733
|
-
optgroup: /* @__PURE__ */ new Set(["option"]),
|
|
734
|
-
select: /* @__PURE__ */ new Set(["optgroup", "option", "hr"]),
|
|
735
|
-
// table
|
|
736
|
-
table: /* @__PURE__ */ new Set(["caption", "colgroup", "tbody", "tfoot", "thead"]),
|
|
737
|
-
tr: /* @__PURE__ */ new Set(["td", "th"]),
|
|
738
|
-
colgroup: /* @__PURE__ */ new Set(["col"]),
|
|
739
|
-
tbody: /* @__PURE__ */ new Set(["tr"]),
|
|
740
|
-
thead: /* @__PURE__ */ new Set(["tr"]),
|
|
741
|
-
tfoot: /* @__PURE__ */ new Set(["tr"]),
|
|
742
|
-
// these elements can not have any children elements
|
|
743
|
-
script: emptySet,
|
|
744
|
-
iframe: emptySet,
|
|
745
|
-
option: emptySet,
|
|
746
|
-
textarea: emptySet,
|
|
747
|
-
style: emptySet,
|
|
748
|
-
title: emptySet
|
|
749
|
-
};
|
|
750
|
-
const onlyValidParents = {
|
|
751
|
-
// sections
|
|
752
|
-
html: emptySet,
|
|
753
|
-
body: /* @__PURE__ */ new Set(["html"]),
|
|
754
|
-
head: /* @__PURE__ */ new Set(["html"]),
|
|
755
|
-
// table
|
|
756
|
-
td: /* @__PURE__ */ new Set(["tr"]),
|
|
757
|
-
colgroup: /* @__PURE__ */ new Set(["table"]),
|
|
758
|
-
caption: /* @__PURE__ */ new Set(["table"]),
|
|
759
|
-
tbody: /* @__PURE__ */ new Set(["table"]),
|
|
760
|
-
tfoot: /* @__PURE__ */ new Set(["table"]),
|
|
761
|
-
col: /* @__PURE__ */ new Set(["colgroup"]),
|
|
762
|
-
th: /* @__PURE__ */ new Set(["tr"]),
|
|
763
|
-
thead: /* @__PURE__ */ new Set(["table"]),
|
|
764
|
-
tr: /* @__PURE__ */ new Set(["tbody", "thead", "tfoot"]),
|
|
765
|
-
// data list
|
|
766
|
-
dd: /* @__PURE__ */ new Set(["dl", "div"]),
|
|
767
|
-
dt: /* @__PURE__ */ new Set(["dl", "div"]),
|
|
768
|
-
// other
|
|
769
|
-
figcaption: /* @__PURE__ */ new Set(["figure"]),
|
|
770
|
-
// li: new Set(["ul", "ol"]),
|
|
771
|
-
summary: /* @__PURE__ */ new Set(["details"]),
|
|
772
|
-
area: /* @__PURE__ */ new Set(["map"])
|
|
773
|
-
};
|
|
774
|
-
const knownInvalidChildren = {
|
|
775
|
-
p: /* @__PURE__ */ new Set([
|
|
776
|
-
"address",
|
|
777
|
-
"article",
|
|
778
|
-
"aside",
|
|
779
|
-
"blockquote",
|
|
780
|
-
"center",
|
|
781
|
-
"details",
|
|
782
|
-
"dialog",
|
|
783
|
-
"dir",
|
|
784
|
-
"div",
|
|
785
|
-
"dl",
|
|
786
|
-
"fieldset",
|
|
787
|
-
"figure",
|
|
788
|
-
"footer",
|
|
789
|
-
"form",
|
|
790
|
-
"h1",
|
|
791
|
-
"h2",
|
|
792
|
-
"h3",
|
|
793
|
-
"h4",
|
|
794
|
-
"h5",
|
|
795
|
-
"h6",
|
|
796
|
-
"header",
|
|
797
|
-
"hgroup",
|
|
798
|
-
"hr",
|
|
799
|
-
"li",
|
|
800
|
-
"main",
|
|
801
|
-
"nav",
|
|
802
|
-
"menu",
|
|
803
|
-
"ol",
|
|
804
|
-
"p",
|
|
805
|
-
"pre",
|
|
806
|
-
"section",
|
|
807
|
-
"table",
|
|
808
|
-
"ul"
|
|
809
|
-
]),
|
|
810
|
-
svg: /* @__PURE__ */ new Set([
|
|
811
|
-
"b",
|
|
812
|
-
"blockquote",
|
|
813
|
-
"br",
|
|
814
|
-
"code",
|
|
815
|
-
"dd",
|
|
816
|
-
"div",
|
|
817
|
-
"dl",
|
|
818
|
-
"dt",
|
|
819
|
-
"em",
|
|
820
|
-
"embed",
|
|
821
|
-
"h1",
|
|
822
|
-
"h2",
|
|
823
|
-
"h3",
|
|
824
|
-
"h4",
|
|
825
|
-
"h5",
|
|
826
|
-
"h6",
|
|
827
|
-
"hr",
|
|
828
|
-
"i",
|
|
829
|
-
"img",
|
|
830
|
-
"li",
|
|
831
|
-
"menu",
|
|
832
|
-
"meta",
|
|
833
|
-
"ol",
|
|
834
|
-
"p",
|
|
835
|
-
"pre",
|
|
836
|
-
"ruby",
|
|
837
|
-
"s",
|
|
838
|
-
"small",
|
|
839
|
-
"span",
|
|
840
|
-
"strong",
|
|
841
|
-
"sub",
|
|
842
|
-
"sup",
|
|
843
|
-
"table",
|
|
844
|
-
"u",
|
|
845
|
-
"ul",
|
|
846
|
-
"var"
|
|
847
|
-
])
|
|
848
|
-
};
|
|
849
|
-
const knownInvalidParents = {
|
|
850
|
-
a: /* @__PURE__ */ new Set(["a"]),
|
|
851
|
-
button: /* @__PURE__ */ new Set(["button"]),
|
|
852
|
-
dd: /* @__PURE__ */ new Set(["dd", "dt"]),
|
|
853
|
-
dt: /* @__PURE__ */ new Set(["dd", "dt"]),
|
|
854
|
-
form: /* @__PURE__ */ new Set(["form"]),
|
|
855
|
-
li: /* @__PURE__ */ new Set(["li"]),
|
|
856
|
-
h1: headings,
|
|
857
|
-
h2: headings,
|
|
858
|
-
h3: headings,
|
|
859
|
-
h4: headings,
|
|
860
|
-
h5: headings,
|
|
861
|
-
h6: headings
|
|
862
|
-
};
|
|
863
|
-
|
|
864
|
-
const validateHtmlNesting = (node, context) => {
|
|
865
|
-
if (node.type === 1 && node.tagType === 0 && context.parent && context.parent.type === 1 && context.parent.tagType === 0 && !isValidHTMLNesting(context.parent.tag, node.tag)) {
|
|
866
|
-
const error = new SyntaxError(
|
|
867
|
-
`<${node.tag}> cannot be child of <${context.parent.tag}>, according to HTML specifications. This can cause hydration errors or potentially disrupt future functionality.`
|
|
868
|
-
);
|
|
869
|
-
error.loc = node.loc;
|
|
870
|
-
context.onWarn(error);
|
|
871
|
-
}
|
|
872
|
-
};
|
|
873
|
-
|
|
874
|
-
const DOMNodeTransforms = [
|
|
875
|
-
transformStyle,
|
|
876
|
-
...[transformTransition, validateHtmlNesting]
|
|
877
|
-
];
|
|
878
|
-
const DOMDirectiveTransforms = {
|
|
879
|
-
cloak: compilerCore.noopDirectiveTransform,
|
|
880
|
-
html: transformVHtml,
|
|
881
|
-
text: transformVText,
|
|
882
|
-
model: transformModel,
|
|
883
|
-
// override compiler-core
|
|
884
|
-
on: transformOn,
|
|
885
|
-
// override compiler-core
|
|
886
|
-
show: transformShow
|
|
887
|
-
};
|
|
888
|
-
function compile(src, options = {}) {
|
|
889
|
-
return compilerCore.baseCompile(
|
|
890
|
-
src,
|
|
891
|
-
shared.extend({}, parserOptions, options, {
|
|
892
|
-
nodeTransforms: [
|
|
893
|
-
// ignore <script> and <tag>
|
|
894
|
-
// this is not put inside DOMNodeTransforms because that list is used
|
|
895
|
-
// by compiler-ssr to generate vnode fallback branches
|
|
896
|
-
ignoreSideEffectTags,
|
|
897
|
-
...DOMNodeTransforms,
|
|
898
|
-
...options.nodeTransforms || []
|
|
899
|
-
],
|
|
900
|
-
directiveTransforms: shared.extend(
|
|
901
|
-
{},
|
|
902
|
-
DOMDirectiveTransforms,
|
|
903
|
-
options.directiveTransforms || {}
|
|
904
|
-
),
|
|
905
|
-
transformHoist: stringifyStatic
|
|
906
|
-
})
|
|
907
|
-
);
|
|
908
|
-
}
|
|
909
|
-
function parse(template, options = {}) {
|
|
910
|
-
return compilerCore.baseParse(template, shared.extend({}, parserOptions, options));
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
exports.DOMDirectiveTransforms = DOMDirectiveTransforms;
|
|
914
|
-
exports.DOMErrorCodes = DOMErrorCodes;
|
|
915
|
-
exports.DOMErrorMessages = DOMErrorMessages;
|
|
916
|
-
exports.DOMNodeTransforms = DOMNodeTransforms;
|
|
917
|
-
exports.TRANSITION = TRANSITION;
|
|
918
|
-
exports.TRANSITION_GROUP = TRANSITION_GROUP;
|
|
919
|
-
exports.V_MODEL_CHECKBOX = V_MODEL_CHECKBOX;
|
|
920
|
-
exports.V_MODEL_DYNAMIC = V_MODEL_DYNAMIC;
|
|
921
|
-
exports.V_MODEL_RADIO = V_MODEL_RADIO;
|
|
922
|
-
exports.V_MODEL_SELECT = V_MODEL_SELECT;
|
|
923
|
-
exports.V_MODEL_TEXT = V_MODEL_TEXT;
|
|
924
|
-
exports.V_ON_WITH_KEYS = V_ON_WITH_KEYS;
|
|
925
|
-
exports.V_ON_WITH_MODIFIERS = V_ON_WITH_MODIFIERS;
|
|
926
|
-
exports.V_SHOW = V_SHOW;
|
|
927
|
-
exports.compile = compile;
|
|
928
|
-
exports.createDOMCompilerError = createDOMCompilerError;
|
|
929
|
-
exports.isValidHTMLNesting = isValidHTMLNesting;
|
|
930
|
-
exports.parse = parse;
|
|
931
|
-
exports.parserOptions = parserOptions;
|
|
932
|
-
exports.resolveModifiers = resolveModifiers;
|
|
933
|
-
exports.transformStyle = transformStyle;
|
|
934
|
-
Object.keys(compilerCore).forEach(function (k) {
|
|
935
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = compilerCore[k];
|
|
936
|
-
});
|