@vue/compiler-sfc 3.6.0-alpha.4 → 3.6.0-alpha.6
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/compiler-sfc.cjs.js +10 -6
- package/dist/compiler-sfc.esm-browser.js +340 -227
- package/package.json +6 -6
package/dist/compiler-sfc.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-sfc v3.6.0-alpha.
|
|
2
|
+
* @vue/compiler-sfc v3.6.0-alpha.6
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -126,6 +126,9 @@ var hashSumExports = /*@__PURE__*/ requireHashSum();
|
|
|
126
126
|
var hash = /*@__PURE__*/getDefaultExportFromCjs(hashSumExports);
|
|
127
127
|
|
|
128
128
|
const CSS_VARS_HELPER = `useCssVars`;
|
|
129
|
+
function getCssVarsHelper(vapor) {
|
|
130
|
+
return vapor ? `useVaporCssVars` : CSS_VARS_HELPER;
|
|
131
|
+
}
|
|
129
132
|
function genCssVarsFromList(vars, id, isProd, isSSR = false) {
|
|
130
133
|
return `{
|
|
131
134
|
${vars.map(
|
|
@@ -234,7 +237,7 @@ const cssVarsPlugin = (opts) => {
|
|
|
234
237
|
};
|
|
235
238
|
};
|
|
236
239
|
cssVarsPlugin.postcss = true;
|
|
237
|
-
function genCssVarsCode(vars, bindings, id, isProd) {
|
|
240
|
+
function genCssVarsCode(vars, bindings, id, isProd, vapor) {
|
|
238
241
|
const varsExp = genCssVarsFromList(vars, id, isProd);
|
|
239
242
|
const exp = CompilerDOM.createSimpleExpression(varsExp, false);
|
|
240
243
|
const context = CompilerDOM.createTransformContext(CompilerDOM.createRoot([]), {
|
|
@@ -246,7 +249,7 @@ function genCssVarsCode(vars, bindings, id, isProd) {
|
|
|
246
249
|
const transformedString = transformed.type === 4 ? transformed.content : transformed.children.map((c) => {
|
|
247
250
|
return typeof c === "string" ? c : c.content;
|
|
248
251
|
}).join("");
|
|
249
|
-
return `_${
|
|
252
|
+
return `_${getCssVarsHelper(vapor)}(_ctx => (${transformedString}))`;
|
|
250
253
|
}
|
|
251
254
|
function genNormalScriptCssVarsCode(cssVars, bindings, id, isProd, defaultVar) {
|
|
252
255
|
return `
|
|
@@ -21332,7 +21335,7 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
|
|
|
21332
21335
|
}
|
|
21333
21336
|
if (sfc.cssVars.length && // no need to do this when targeting SSR
|
|
21334
21337
|
!ssr) {
|
|
21335
|
-
ctx.helperImports.add(
|
|
21338
|
+
ctx.helperImports.add(getCssVarsHelper(vapor));
|
|
21336
21339
|
ctx.helperImports.add("unref");
|
|
21337
21340
|
ctx.s.prependLeft(
|
|
21338
21341
|
startOffset,
|
|
@@ -21341,7 +21344,8 @@ ${genCssVarsCode(
|
|
|
21341
21344
|
sfc.cssVars,
|
|
21342
21345
|
ctx.bindingMetadata,
|
|
21343
21346
|
scopeId,
|
|
21344
|
-
!!options.isProd
|
|
21347
|
+
!!options.isProd,
|
|
21348
|
+
vapor
|
|
21345
21349
|
)}
|
|
21346
21350
|
`
|
|
21347
21351
|
);
|
|
@@ -21752,7 +21756,7 @@ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
|
|
|
21752
21756
|
return generator.toJSON();
|
|
21753
21757
|
}
|
|
21754
21758
|
|
|
21755
|
-
const version = "3.6.0-alpha.
|
|
21759
|
+
const version = "3.6.0-alpha.6";
|
|
21756
21760
|
const parseCache = parseCache$1;
|
|
21757
21761
|
const errorMessages = {
|
|
21758
21762
|
...CompilerDOM.errorMessages,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-sfc v3.6.0-alpha.
|
|
2
|
+
* @vue/compiler-sfc v3.6.0-alpha.6
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -18115,7 +18115,43 @@ function getMemoedVNodeCall(node) {
|
|
|
18115
18115
|
return node;
|
|
18116
18116
|
}
|
|
18117
18117
|
}
|
|
18118
|
+
function filterNonCommentChildren(node) {
|
|
18119
|
+
return node.children.filter((n) => n.type !== 3);
|
|
18120
|
+
}
|
|
18121
|
+
function hasSingleChild(node) {
|
|
18122
|
+
return filterNonCommentChildren(node).length === 1;
|
|
18123
|
+
}
|
|
18124
|
+
function isSingleIfBlock(parent) {
|
|
18125
|
+
let hasEncounteredIf = false;
|
|
18126
|
+
for (const c of filterNonCommentChildren(parent)) {
|
|
18127
|
+
if (c.type === 9 || c.type === 1 && findDir$1(c, "if")) {
|
|
18128
|
+
if (hasEncounteredIf) return false;
|
|
18129
|
+
hasEncounteredIf = true;
|
|
18130
|
+
} else if (
|
|
18131
|
+
// node before v-if
|
|
18132
|
+
!hasEncounteredIf || // non else nodes
|
|
18133
|
+
!(c.type === 1 && findDir$1(c, /^else(-if)?$/, true))
|
|
18134
|
+
) {
|
|
18135
|
+
return false;
|
|
18136
|
+
}
|
|
18137
|
+
}
|
|
18138
|
+
return true;
|
|
18139
|
+
}
|
|
18118
18140
|
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
|
|
18141
|
+
function isAllWhitespace(str) {
|
|
18142
|
+
for (let i = 0; i < str.length; i++) {
|
|
18143
|
+
if (!isWhitespace(str.charCodeAt(i))) {
|
|
18144
|
+
return false;
|
|
18145
|
+
}
|
|
18146
|
+
}
|
|
18147
|
+
return true;
|
|
18148
|
+
}
|
|
18149
|
+
function isWhitespaceText(node) {
|
|
18150
|
+
return node.type === 2 && isAllWhitespace(node.content) || node.type === 12 && isWhitespaceText(node.content);
|
|
18151
|
+
}
|
|
18152
|
+
function isCommentOrWhitespace(node) {
|
|
18153
|
+
return node.type === 3 || isWhitespaceText(node);
|
|
18154
|
+
}
|
|
18119
18155
|
|
|
18120
18156
|
const defaultParserOptions = {
|
|
18121
18157
|
parseMode: "base",
|
|
@@ -18652,14 +18688,6 @@ function condenseWhitespace(nodes) {
|
|
|
18652
18688
|
}
|
|
18653
18689
|
return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
|
18654
18690
|
}
|
|
18655
|
-
function isAllWhitespace(str) {
|
|
18656
|
-
for (let i = 0; i < str.length; i++) {
|
|
18657
|
-
if (!isWhitespace(str.charCodeAt(i))) {
|
|
18658
|
-
return false;
|
|
18659
|
-
}
|
|
18660
|
-
}
|
|
18661
|
-
return true;
|
|
18662
|
-
}
|
|
18663
18691
|
function hasNewlineChar(str) {
|
|
18664
18692
|
for (let i = 0; i < str.length; i++) {
|
|
18665
18693
|
const c = str.charCodeAt(i);
|
|
@@ -23905,13 +23933,11 @@ function processIf$1(node, dir, context, processCodegen) {
|
|
|
23905
23933
|
let i = siblings.indexOf(node);
|
|
23906
23934
|
while (i-- >= -1) {
|
|
23907
23935
|
const sibling = siblings[i];
|
|
23908
|
-
if (sibling && sibling
|
|
23909
|
-
context.removeNode(sibling);
|
|
23910
|
-
comments.unshift(sibling);
|
|
23911
|
-
continue;
|
|
23912
|
-
}
|
|
23913
|
-
if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
|
|
23936
|
+
if (sibling && isCommentOrWhitespace(sibling)) {
|
|
23914
23937
|
context.removeNode(sibling);
|
|
23938
|
+
if (sibling.type === 3) {
|
|
23939
|
+
comments.unshift(sibling);
|
|
23940
|
+
}
|
|
23915
23941
|
continue;
|
|
23916
23942
|
}
|
|
23917
23943
|
if (sibling && sibling.type === 9) {
|
|
@@ -24429,7 +24455,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
24429
24455
|
let prev;
|
|
24430
24456
|
while (j--) {
|
|
24431
24457
|
prev = children[j];
|
|
24432
|
-
if (
|
|
24458
|
+
if (!isCommentOrWhitespace(prev)) {
|
|
24433
24459
|
break;
|
|
24434
24460
|
}
|
|
24435
24461
|
}
|
|
@@ -24504,7 +24530,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
24504
24530
|
} else if (implicitDefaultChildren.length && // #3766
|
|
24505
24531
|
// with whitespace: 'preserve', whitespaces between slots will end up in
|
|
24506
24532
|
// implicitDefaultChildren. Ignore if all implicit children are whitespaces.
|
|
24507
|
-
implicitDefaultChildren.
|
|
24533
|
+
!implicitDefaultChildren.every(isWhitespaceText)) {
|
|
24508
24534
|
if (hasNamedDefaultSlot) {
|
|
24509
24535
|
context.onError(
|
|
24510
24536
|
createCompilerError(
|
|
@@ -24577,11 +24603,6 @@ function hasForwardedSlots(children) {
|
|
|
24577
24603
|
}
|
|
24578
24604
|
return false;
|
|
24579
24605
|
}
|
|
24580
|
-
function isNonWhitespaceContent$1(node) {
|
|
24581
|
-
if (node.type !== 2 && node.type !== 12)
|
|
24582
|
-
return true;
|
|
24583
|
-
return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent$1(node.content);
|
|
24584
|
-
}
|
|
24585
24606
|
|
|
24586
24607
|
const directiveImportMap = /* @__PURE__ */ new WeakMap();
|
|
24587
24608
|
const transformElement$1 = (node, context) => {
|
|
@@ -26016,7 +26037,9 @@ const isNonKeyModifier = /* @__PURE__ */ makeMap(
|
|
|
26016
26037
|
`stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
|
|
26017
26038
|
);
|
|
26018
26039
|
const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
|
|
26019
|
-
const isKeyboardEvent = /* @__PURE__ */ makeMap(
|
|
26040
|
+
const isKeyboardEvent = /* @__PURE__ */ makeMap(
|
|
26041
|
+
`onkeyup,onkeydown,onkeypress`
|
|
26042
|
+
);
|
|
26020
26043
|
const resolveModifiers = (key, modifiers, context, loc) => {
|
|
26021
26044
|
const keyModifiers = [];
|
|
26022
26045
|
const nonKeyModifiers = [];
|
|
@@ -26151,7 +26174,7 @@ function postTransformTransition(node, onError, hasMultipleChildren = defaultHas
|
|
|
26151
26174
|
}
|
|
26152
26175
|
function defaultHasMultipleChildren(node) {
|
|
26153
26176
|
const children = node.children = node.children.filter(
|
|
26154
|
-
(c) =>
|
|
26177
|
+
(c) => !isCommentOrWhitespace(c)
|
|
26155
26178
|
);
|
|
26156
26179
|
const child = children[0];
|
|
26157
26180
|
return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
|
|
@@ -26718,6 +26741,7 @@ var CompilerDOM = /*#__PURE__*/Object.freeze({
|
|
|
26718
26741
|
defaultOnWarn: defaultOnWarn,
|
|
26719
26742
|
errorMessages: errorMessages$1,
|
|
26720
26743
|
extractIdentifiers: extractIdentifiers$1,
|
|
26744
|
+
filterNonCommentChildren: filterNonCommentChildren,
|
|
26721
26745
|
findDir: findDir$1,
|
|
26722
26746
|
findProp: findProp$1,
|
|
26723
26747
|
forAliasRE: forAliasRE,
|
|
@@ -26731,8 +26755,11 @@ var CompilerDOM = /*#__PURE__*/Object.freeze({
|
|
|
26731
26755
|
getVNodeHelper: getVNodeHelper,
|
|
26732
26756
|
hasDynamicKeyVBind: hasDynamicKeyVBind,
|
|
26733
26757
|
hasScopeRef: hasScopeRef,
|
|
26758
|
+
hasSingleChild: hasSingleChild,
|
|
26734
26759
|
helperNameMap: helperNameMap,
|
|
26735
26760
|
injectProp: injectProp,
|
|
26761
|
+
isAllWhitespace: isAllWhitespace,
|
|
26762
|
+
isCommentOrWhitespace: isCommentOrWhitespace,
|
|
26736
26763
|
isConstantNode: isConstantNode,
|
|
26737
26764
|
isCoreComponent: isCoreComponent,
|
|
26738
26765
|
isFnExpression: isFnExpression,
|
|
@@ -26741,12 +26768,14 @@ var CompilerDOM = /*#__PURE__*/Object.freeze({
|
|
|
26741
26768
|
isFunctionType: isFunctionType,
|
|
26742
26769
|
isInDestructureAssignment: isInDestructureAssignment,
|
|
26743
26770
|
isInNewExpression: isInNewExpression,
|
|
26771
|
+
isKeyboardEvent: isKeyboardEvent,
|
|
26744
26772
|
isLiteralWhitelisted: isLiteralWhitelisted,
|
|
26745
26773
|
isMemberExpression: isMemberExpression$1,
|
|
26746
26774
|
isMemberExpressionBrowser: isMemberExpressionBrowser,
|
|
26747
26775
|
isMemberExpressionNode: isMemberExpressionNode,
|
|
26748
26776
|
isReferencedIdentifier: isReferencedIdentifier,
|
|
26749
26777
|
isSimpleIdentifier: isSimpleIdentifier,
|
|
26778
|
+
isSingleIfBlock: isSingleIfBlock,
|
|
26750
26779
|
isSlotOutlet: isSlotOutlet,
|
|
26751
26780
|
isStaticArgOf: isStaticArgOf,
|
|
26752
26781
|
isStaticExp: isStaticExp,
|
|
@@ -26758,6 +26787,7 @@ var CompilerDOM = /*#__PURE__*/Object.freeze({
|
|
|
26758
26787
|
isVPre: isVPre,
|
|
26759
26788
|
isVSlot: isVSlot,
|
|
26760
26789
|
isValidHTMLNesting: isValidHTMLNesting,
|
|
26790
|
+
isWhitespaceText: isWhitespaceText,
|
|
26761
26791
|
locStub: locStub,
|
|
26762
26792
|
noopDirectiveTransform: noopDirectiveTransform,
|
|
26763
26793
|
parse: parse$3,
|
|
@@ -26872,6 +26902,9 @@ var hashSumExports = /*@__PURE__*/ requireHashSum();
|
|
|
26872
26902
|
var hash = /*@__PURE__*/getDefaultExportFromCjs(hashSumExports);
|
|
26873
26903
|
|
|
26874
26904
|
const CSS_VARS_HELPER = `useCssVars`;
|
|
26905
|
+
function getCssVarsHelper(vapor) {
|
|
26906
|
+
return vapor ? `useVaporCssVars` : CSS_VARS_HELPER;
|
|
26907
|
+
}
|
|
26875
26908
|
function genCssVarsFromList(vars, id, isProd, isSSR = false) {
|
|
26876
26909
|
return `{
|
|
26877
26910
|
${vars.map(
|
|
@@ -26980,7 +27013,7 @@ const cssVarsPlugin = (opts) => {
|
|
|
26980
27013
|
};
|
|
26981
27014
|
};
|
|
26982
27015
|
cssVarsPlugin.postcss = true;
|
|
26983
|
-
function genCssVarsCode(vars, bindings, id, isProd) {
|
|
27016
|
+
function genCssVarsCode(vars, bindings, id, isProd, vapor) {
|
|
26984
27017
|
const varsExp = genCssVarsFromList(vars, id, isProd);
|
|
26985
27018
|
const exp = createSimpleExpression(varsExp, false);
|
|
26986
27019
|
const context = createTransformContext(createRoot([]), {
|
|
@@ -26992,7 +27025,7 @@ function genCssVarsCode(vars, bindings, id, isProd) {
|
|
|
26992
27025
|
const transformedString = transformed.type === 4 ? transformed.content : transformed.children.map((c) => {
|
|
26993
27026
|
return typeof c === "string" ? c : c.content;
|
|
26994
27027
|
}).join("");
|
|
26995
|
-
return `_${
|
|
27028
|
+
return `_${getCssVarsHelper(vapor)}(_ctx => (${transformedString}))`;
|
|
26996
27029
|
}
|
|
26997
27030
|
function genNormalScriptCssVarsCode(cssVars, bindings, id, isProd, defaultVar) {
|
|
26998
27031
|
return `
|
|
@@ -32028,8 +32061,7 @@ const newBlock = (node) => ({
|
|
|
32028
32061
|
effect: [],
|
|
32029
32062
|
operation: [],
|
|
32030
32063
|
returns: [],
|
|
32031
|
-
tempId: 0
|
|
32032
|
-
hasDeferredVShow: false
|
|
32064
|
+
tempId: 0
|
|
32033
32065
|
});
|
|
32034
32066
|
function wrapTemplate(node, dirs) {
|
|
32035
32067
|
if (node.tagType === 3) {
|
|
@@ -32286,10 +32318,12 @@ function transform(node, options = {}) {
|
|
|
32286
32318
|
source: node.source,
|
|
32287
32319
|
template: /* @__PURE__ */ new Map(),
|
|
32288
32320
|
templateIndexMap: /* @__PURE__ */ new Map(),
|
|
32321
|
+
rootTemplateIndexes: /* @__PURE__ */ new Set(),
|
|
32289
32322
|
component: /* @__PURE__ */ new Set(),
|
|
32290
32323
|
directive: /* @__PURE__ */ new Set(),
|
|
32291
32324
|
block: newBlock(node),
|
|
32292
|
-
hasTemplateRef: false
|
|
32325
|
+
hasTemplateRef: false,
|
|
32326
|
+
hasDeferredVShow: false
|
|
32293
32327
|
};
|
|
32294
32328
|
const context = new TransformContext(ir, node, options);
|
|
32295
32329
|
transformNode(context);
|
|
@@ -32782,8 +32816,10 @@ function analyzeExpressions(expressions) {
|
|
|
32782
32816
|
exp.ast === null && registerVariable(exp.content, exp, true);
|
|
32783
32817
|
continue;
|
|
32784
32818
|
}
|
|
32819
|
+
const seenParents = /* @__PURE__ */ new Set();
|
|
32785
32820
|
walkIdentifiers(exp.ast, (currentNode, parent, parentStack) => {
|
|
32786
|
-
if (parent && isMemberExpression(parent)) {
|
|
32821
|
+
if (parent && isMemberExpression(parent) && !seenParents.has(parent)) {
|
|
32822
|
+
seenParents.add(parent);
|
|
32787
32823
|
const memberExp = extractMemberExpression(parent, (id) => {
|
|
32788
32824
|
registerVariable(id.name, exp, true, {
|
|
32789
32825
|
start: id.start,
|
|
@@ -32885,7 +32921,7 @@ function shouldDeclareVariable(name, expToVariableMap, exps) {
|
|
|
32885
32921
|
}
|
|
32886
32922
|
return true;
|
|
32887
32923
|
}
|
|
32888
|
-
if (vars.
|
|
32924
|
+
if (vars.every((v) => v.every((e, idx) => e === first[idx]))) {
|
|
32889
32925
|
return false;
|
|
32890
32926
|
}
|
|
32891
32927
|
return true;
|
|
@@ -32894,7 +32930,9 @@ function processRepeatedExpressions(context, expressions, varDeclarations, updat
|
|
|
32894
32930
|
const declarations = [];
|
|
32895
32931
|
const seenExp = expressions.reduce(
|
|
32896
32932
|
(acc, exp) => {
|
|
32897
|
-
const
|
|
32933
|
+
const vars = expToVariableMap.get(exp);
|
|
32934
|
+
if (!vars) return acc;
|
|
32935
|
+
const variables = vars.map((v) => v.name);
|
|
32898
32936
|
if (exp.ast && exp.ast.type !== "Identifier" && !(variables && variables.some((v) => updatedVariable.has(v)))) {
|
|
32899
32937
|
acc[exp.content] = (acc[exp.content] || 0) + 1;
|
|
32900
32938
|
}
|
|
@@ -33010,12 +33048,14 @@ function extractMemberExpression(exp, onIdentifier) {
|
|
|
33010
33048
|
const object = extractMemberExpression(exp.object, onIdentifier);
|
|
33011
33049
|
const prop = exp.computed ? `[${extractMemberExpression(exp.property, onIdentifier)}]` : `.${extractMemberExpression(exp.property, NOOP)}`;
|
|
33012
33050
|
return `${object}${prop}`;
|
|
33051
|
+
case "TSNonNullExpression":
|
|
33052
|
+
return `${extractMemberExpression(exp.expression, onIdentifier)}`;
|
|
33013
33053
|
default:
|
|
33014
33054
|
return "";
|
|
33015
33055
|
}
|
|
33016
33056
|
}
|
|
33017
33057
|
const isMemberExpression = (node) => {
|
|
33018
|
-
return node.type === "MemberExpression" || node.type === "OptionalMemberExpression";
|
|
33058
|
+
return node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "TSNonNullExpression";
|
|
33019
33059
|
};
|
|
33020
33060
|
|
|
33021
33061
|
function genSetEvent(oper, context) {
|
|
@@ -33024,7 +33064,7 @@ function genSetEvent(oper, context) {
|
|
|
33024
33064
|
const name = genName();
|
|
33025
33065
|
const handler = [
|
|
33026
33066
|
`${context.helper("createInvoker")}(`,
|
|
33027
|
-
...genEventHandler(context, value, modifiers),
|
|
33067
|
+
...genEventHandler(context, [value], modifiers),
|
|
33028
33068
|
`)`
|
|
33029
33069
|
];
|
|
33030
33070
|
const eventOptions = genEventOptions();
|
|
@@ -33081,37 +33121,47 @@ function genSetDynamicEvents(oper, context) {
|
|
|
33081
33121
|
)
|
|
33082
33122
|
];
|
|
33083
33123
|
}
|
|
33084
|
-
function genEventHandler(context,
|
|
33085
|
-
let handlerExp = [
|
|
33086
|
-
if (
|
|
33087
|
-
|
|
33088
|
-
|
|
33089
|
-
if (
|
|
33090
|
-
|
|
33091
|
-
|
|
33092
|
-
|
|
33093
|
-
|
|
33094
|
-
|
|
33095
|
-
|
|
33096
|
-
|
|
33097
|
-
|
|
33098
|
-
|
|
33099
|
-
|
|
33100
|
-
|
|
33101
|
-
|
|
33102
|
-
|
|
33103
|
-
|
|
33104
|
-
|
|
33105
|
-
|
|
33106
|
-
|
|
33107
|
-
|
|
33108
|
-
|
|
33109
|
-
|
|
33110
|
-
|
|
33111
|
-
|
|
33112
|
-
|
|
33124
|
+
function genEventHandler(context, values, modifiers = { nonKeys: [], keys: [] }, extraWrap = false) {
|
|
33125
|
+
let handlerExp = [];
|
|
33126
|
+
if (values) {
|
|
33127
|
+
values.forEach((value, index) => {
|
|
33128
|
+
let exp = [];
|
|
33129
|
+
if (value && value.content.trim()) {
|
|
33130
|
+
if (isMemberExpression$1(value, context.options)) {
|
|
33131
|
+
exp = genExpression(value, context);
|
|
33132
|
+
if (!isConstantBinding(value, context) && !extraWrap) {
|
|
33133
|
+
const isTSNode = value.ast && TS_NODE_TYPES.includes(value.ast.type);
|
|
33134
|
+
exp = [
|
|
33135
|
+
`e => `,
|
|
33136
|
+
isTSNode ? "(" : "",
|
|
33137
|
+
...exp,
|
|
33138
|
+
isTSNode ? ")" : "",
|
|
33139
|
+
`(e)`
|
|
33140
|
+
];
|
|
33141
|
+
}
|
|
33142
|
+
} else if (isFnExpression(value, context.options)) {
|
|
33143
|
+
exp = genExpression(value, context);
|
|
33144
|
+
} else {
|
|
33145
|
+
const referencesEvent = value.content.includes("$event");
|
|
33146
|
+
const hasMultipleStatements = value.content.includes(`;`);
|
|
33147
|
+
const expr = referencesEvent ? context.withId(() => genExpression(value, context), {
|
|
33148
|
+
$event: null
|
|
33149
|
+
}) : genExpression(value, context);
|
|
33150
|
+
exp = [
|
|
33151
|
+
referencesEvent ? "$event => " : "() => ",
|
|
33152
|
+
hasMultipleStatements ? "{" : "(",
|
|
33153
|
+
...expr,
|
|
33154
|
+
hasMultipleStatements ? "}" : ")"
|
|
33155
|
+
];
|
|
33156
|
+
}
|
|
33157
|
+
handlerExp = handlerExp.concat([index !== 0 ? ", " : "", ...exp]);
|
|
33158
|
+
}
|
|
33159
|
+
});
|
|
33160
|
+
if (values.length > 1) {
|
|
33161
|
+
handlerExp = ["[", ...handlerExp, "]"];
|
|
33113
33162
|
}
|
|
33114
33163
|
}
|
|
33164
|
+
if (handlerExp.length === 0) handlerExp = ["() => {}"];
|
|
33115
33165
|
const { keys, nonKeys } = modifiers;
|
|
33116
33166
|
if (nonKeys.length)
|
|
33117
33167
|
handlerExp = genWithModifiers(context, handlerExp, nonKeys);
|
|
@@ -33152,35 +33202,19 @@ function genFor(oper, context) {
|
|
|
33152
33202
|
component,
|
|
33153
33203
|
onlyChild
|
|
33154
33204
|
} = oper;
|
|
33155
|
-
|
|
33205
|
+
const rawValue = value && value.content;
|
|
33156
33206
|
const rawKey = key && key.content;
|
|
33157
33207
|
const rawIndex = index && index.content;
|
|
33158
33208
|
const sourceExpr = ["() => (", ...genExpression(source, context), ")"];
|
|
33159
|
-
const idToPathMap = parseValueDestructure();
|
|
33209
|
+
const idToPathMap = parseValueDestructure(value, context);
|
|
33160
33210
|
const [depth, exitScope] = context.enterScope();
|
|
33161
|
-
const idMap = {};
|
|
33162
33211
|
const itemVar = `_for_item${depth}`;
|
|
33212
|
+
const idMap = buildDestructureIdMap(
|
|
33213
|
+
idToPathMap,
|
|
33214
|
+
`${itemVar}.value`,
|
|
33215
|
+
context.options.expressionPlugins
|
|
33216
|
+
);
|
|
33163
33217
|
idMap[itemVar] = null;
|
|
33164
|
-
idToPathMap.forEach((pathInfo, id2) => {
|
|
33165
|
-
let path = `${itemVar}.value${pathInfo ? pathInfo.path : ""}`;
|
|
33166
|
-
if (pathInfo) {
|
|
33167
|
-
if (pathInfo.helper) {
|
|
33168
|
-
idMap[pathInfo.helper] = null;
|
|
33169
|
-
path = `${pathInfo.helper}(${path}, ${pathInfo.helperArgs})`;
|
|
33170
|
-
}
|
|
33171
|
-
if (pathInfo.dynamic) {
|
|
33172
|
-
const node = idMap[id2] = createSimpleExpression(path);
|
|
33173
|
-
const plugins = context.options.expressionPlugins;
|
|
33174
|
-
node.ast = libExports.parseExpression(`(${path})`, {
|
|
33175
|
-
plugins: plugins ? [...plugins, "typescript"] : ["typescript"]
|
|
33176
|
-
});
|
|
33177
|
-
} else {
|
|
33178
|
-
idMap[id2] = path;
|
|
33179
|
-
}
|
|
33180
|
-
} else {
|
|
33181
|
-
idMap[id2] = path;
|
|
33182
|
-
}
|
|
33183
|
-
});
|
|
33184
33218
|
const args = [itemVar];
|
|
33185
33219
|
if (rawKey) {
|
|
33186
33220
|
const keyVar = `_for_key${depth}`;
|
|
@@ -33278,77 +33312,6 @@ function genFor(oper, context) {
|
|
|
33278
33312
|
// todo: hydrationNode
|
|
33279
33313
|
)
|
|
33280
33314
|
];
|
|
33281
|
-
function parseValueDestructure() {
|
|
33282
|
-
const map = /* @__PURE__ */ new Map();
|
|
33283
|
-
if (value) {
|
|
33284
|
-
rawValue = value && value.content;
|
|
33285
|
-
if (value.ast) {
|
|
33286
|
-
walkIdentifiers(
|
|
33287
|
-
value.ast,
|
|
33288
|
-
(id2, _, parentStack, ___, isLocal) => {
|
|
33289
|
-
if (isLocal) {
|
|
33290
|
-
let path = "";
|
|
33291
|
-
let isDynamic = false;
|
|
33292
|
-
let helper2;
|
|
33293
|
-
let helperArgs;
|
|
33294
|
-
for (let i = 0; i < parentStack.length; i++) {
|
|
33295
|
-
const parent = parentStack[i];
|
|
33296
|
-
const child = parentStack[i + 1] || id2;
|
|
33297
|
-
if (parent.type === "ObjectProperty" && parent.value === child) {
|
|
33298
|
-
if (parent.key.type === "StringLiteral") {
|
|
33299
|
-
path += `[${JSON.stringify(parent.key.value)}]`;
|
|
33300
|
-
} else if (parent.computed) {
|
|
33301
|
-
isDynamic = true;
|
|
33302
|
-
path += `[${value.content.slice(
|
|
33303
|
-
parent.key.start - 1,
|
|
33304
|
-
parent.key.end - 1
|
|
33305
|
-
)}]`;
|
|
33306
|
-
} else {
|
|
33307
|
-
path += `.${parent.key.name}`;
|
|
33308
|
-
}
|
|
33309
|
-
} else if (parent.type === "ArrayPattern") {
|
|
33310
|
-
const index2 = parent.elements.indexOf(child);
|
|
33311
|
-
if (child.type === "RestElement") {
|
|
33312
|
-
path += `.slice(${index2})`;
|
|
33313
|
-
} else {
|
|
33314
|
-
path += `[${index2}]`;
|
|
33315
|
-
}
|
|
33316
|
-
} else if (parent.type === "ObjectPattern" && child.type === "RestElement") {
|
|
33317
|
-
helper2 = context.helper("getRestElement");
|
|
33318
|
-
helperArgs = "[" + parent.properties.filter((p) => p.type === "ObjectProperty").map((p) => {
|
|
33319
|
-
if (p.key.type === "StringLiteral") {
|
|
33320
|
-
return JSON.stringify(p.key.value);
|
|
33321
|
-
} else if (p.computed) {
|
|
33322
|
-
isDynamic = true;
|
|
33323
|
-
return value.content.slice(
|
|
33324
|
-
p.key.start - 1,
|
|
33325
|
-
p.key.end - 1
|
|
33326
|
-
);
|
|
33327
|
-
} else {
|
|
33328
|
-
return JSON.stringify(p.key.name);
|
|
33329
|
-
}
|
|
33330
|
-
}).join(", ") + "]";
|
|
33331
|
-
}
|
|
33332
|
-
if (child.type === "AssignmentPattern" && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
|
|
33333
|
-
isDynamic = true;
|
|
33334
|
-
helper2 = context.helper("getDefaultValue");
|
|
33335
|
-
helperArgs = value.content.slice(
|
|
33336
|
-
child.right.start - 1,
|
|
33337
|
-
child.right.end - 1
|
|
33338
|
-
);
|
|
33339
|
-
}
|
|
33340
|
-
}
|
|
33341
|
-
map.set(id2.name, { path, dynamic: isDynamic, helper: helper2, helperArgs });
|
|
33342
|
-
}
|
|
33343
|
-
},
|
|
33344
|
-
true
|
|
33345
|
-
);
|
|
33346
|
-
} else {
|
|
33347
|
-
map.set(rawValue, null);
|
|
33348
|
-
}
|
|
33349
|
-
}
|
|
33350
|
-
return map;
|
|
33351
|
-
}
|
|
33352
33315
|
function genCallback(expr) {
|
|
33353
33316
|
if (!expr) return false;
|
|
33354
33317
|
const res = context.withId(
|
|
@@ -33375,6 +33338,98 @@ function genFor(oper, context) {
|
|
|
33375
33338
|
return idMap2;
|
|
33376
33339
|
}
|
|
33377
33340
|
}
|
|
33341
|
+
function parseValueDestructure(value, context) {
|
|
33342
|
+
const map = /* @__PURE__ */ new Map();
|
|
33343
|
+
if (value) {
|
|
33344
|
+
const rawValue = value.content;
|
|
33345
|
+
if (value.ast) {
|
|
33346
|
+
walkIdentifiers(
|
|
33347
|
+
value.ast,
|
|
33348
|
+
(id, _, parentStack, ___, isLocal) => {
|
|
33349
|
+
if (isLocal) {
|
|
33350
|
+
let path = "";
|
|
33351
|
+
let isDynamic = false;
|
|
33352
|
+
let helper;
|
|
33353
|
+
let helperArgs;
|
|
33354
|
+
for (let i = 0; i < parentStack.length; i++) {
|
|
33355
|
+
const parent = parentStack[i];
|
|
33356
|
+
const child = parentStack[i + 1] || id;
|
|
33357
|
+
if (parent.type === "ObjectProperty" && parent.value === child) {
|
|
33358
|
+
if (parent.key.type === "StringLiteral") {
|
|
33359
|
+
path += `[${JSON.stringify(parent.key.value)}]`;
|
|
33360
|
+
} else if (parent.computed) {
|
|
33361
|
+
isDynamic = true;
|
|
33362
|
+
path += `[${rawValue.slice(
|
|
33363
|
+
parent.key.start - 1,
|
|
33364
|
+
parent.key.end - 1
|
|
33365
|
+
)}]`;
|
|
33366
|
+
} else {
|
|
33367
|
+
path += `.${parent.key.name}`;
|
|
33368
|
+
}
|
|
33369
|
+
} else if (parent.type === "ArrayPattern") {
|
|
33370
|
+
const index = parent.elements.indexOf(child);
|
|
33371
|
+
if (child.type === "RestElement") {
|
|
33372
|
+
path += `.slice(${index})`;
|
|
33373
|
+
} else {
|
|
33374
|
+
path += `[${index}]`;
|
|
33375
|
+
}
|
|
33376
|
+
} else if (parent.type === "ObjectPattern" && child.type === "RestElement") {
|
|
33377
|
+
helper = context.helper("getRestElement");
|
|
33378
|
+
helperArgs = "[" + parent.properties.filter((p) => p.type === "ObjectProperty").map((p) => {
|
|
33379
|
+
if (p.key.type === "StringLiteral") {
|
|
33380
|
+
return JSON.stringify(p.key.value);
|
|
33381
|
+
} else if (p.computed) {
|
|
33382
|
+
isDynamic = true;
|
|
33383
|
+
return rawValue.slice(p.key.start - 1, p.key.end - 1);
|
|
33384
|
+
} else {
|
|
33385
|
+
return JSON.stringify(p.key.name);
|
|
33386
|
+
}
|
|
33387
|
+
}).join(", ") + "]";
|
|
33388
|
+
}
|
|
33389
|
+
if (child.type === "AssignmentPattern" && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
|
|
33390
|
+
isDynamic = true;
|
|
33391
|
+
helper = context.helper("getDefaultValue");
|
|
33392
|
+
helperArgs = rawValue.slice(
|
|
33393
|
+
child.right.start - 1,
|
|
33394
|
+
child.right.end - 1
|
|
33395
|
+
);
|
|
33396
|
+
}
|
|
33397
|
+
}
|
|
33398
|
+
map.set(id.name, { path, dynamic: isDynamic, helper, helperArgs });
|
|
33399
|
+
}
|
|
33400
|
+
},
|
|
33401
|
+
true
|
|
33402
|
+
);
|
|
33403
|
+
} else if (rawValue) {
|
|
33404
|
+
map.set(rawValue, null);
|
|
33405
|
+
}
|
|
33406
|
+
}
|
|
33407
|
+
return map;
|
|
33408
|
+
}
|
|
33409
|
+
function buildDestructureIdMap(idToPathMap, baseAccessor, plugins) {
|
|
33410
|
+
const idMap = {};
|
|
33411
|
+
idToPathMap.forEach((pathInfo, id) => {
|
|
33412
|
+
let path = baseAccessor;
|
|
33413
|
+
if (pathInfo) {
|
|
33414
|
+
path = `${baseAccessor}${pathInfo.path}`;
|
|
33415
|
+
if (pathInfo.helper) {
|
|
33416
|
+
idMap[pathInfo.helper] = null;
|
|
33417
|
+
path = pathInfo.helperArgs ? `${pathInfo.helper}(${path}, ${pathInfo.helperArgs})` : `${pathInfo.helper}(${path})`;
|
|
33418
|
+
}
|
|
33419
|
+
if (pathInfo.dynamic) {
|
|
33420
|
+
const node = idMap[id] = createSimpleExpression(path);
|
|
33421
|
+
node.ast = libExports.parseExpression(`(${path})`, {
|
|
33422
|
+
plugins: plugins ? [...plugins, "typescript"] : ["typescript"]
|
|
33423
|
+
});
|
|
33424
|
+
} else {
|
|
33425
|
+
idMap[id] = path;
|
|
33426
|
+
}
|
|
33427
|
+
} else {
|
|
33428
|
+
idMap[id] = path;
|
|
33429
|
+
}
|
|
33430
|
+
});
|
|
33431
|
+
return idMap;
|
|
33432
|
+
}
|
|
33378
33433
|
function matchPatterns(render, keyProp, idMap) {
|
|
33379
33434
|
const selectorPatterns = [];
|
|
33380
33435
|
const keyOnlyBindingPatterns = [];
|
|
@@ -33586,7 +33641,6 @@ function genDynamicProps$1(oper, context) {
|
|
|
33586
33641
|
helper("setDynamicProps"),
|
|
33587
33642
|
`n${oper.element}`,
|
|
33588
33643
|
genMulti(DELIMITERS_ARRAY, ...values),
|
|
33589
|
-
oper.root && "true",
|
|
33590
33644
|
isSVG && "true"
|
|
33591
33645
|
)
|
|
33592
33646
|
];
|
|
@@ -33616,6 +33670,7 @@ function genPropKey({ key: node, modifier, runtimeCamelize, handler, handlerModi
|
|
|
33616
33670
|
}
|
|
33617
33671
|
let key = genExpression(node, context);
|
|
33618
33672
|
if (runtimeCamelize) {
|
|
33673
|
+
key.push(' || ""');
|
|
33619
33674
|
key = genCall(helper("camelize"), key);
|
|
33620
33675
|
}
|
|
33621
33676
|
if (handler) {
|
|
@@ -33857,7 +33912,7 @@ function genCreateComponent(operation, context) {
|
|
|
33857
33912
|
const rawProps = context.withId(() => genRawProps(props, context), ids);
|
|
33858
33913
|
const inlineHandlers = handlers.reduce(
|
|
33859
33914
|
(acc, { name, value }) => {
|
|
33860
|
-
const handler = genEventHandler(context, value, void 0, false);
|
|
33915
|
+
const handler = genEventHandler(context, [value], void 0, false);
|
|
33861
33916
|
return [...acc, `const ${name} = `, ...handler, NEWLINE];
|
|
33862
33917
|
},
|
|
33863
33918
|
[]
|
|
@@ -33991,7 +34046,7 @@ function genProp(prop, context, isStatic) {
|
|
|
33991
34046
|
": ",
|
|
33992
34047
|
...prop.handler ? genEventHandler(
|
|
33993
34048
|
context,
|
|
33994
|
-
prop.values
|
|
34049
|
+
prop.values,
|
|
33995
34050
|
prop.handlerModifiers,
|
|
33996
34051
|
true
|
|
33997
34052
|
) : isStatic ? ["() => (", ...values, ")"] : values,
|
|
@@ -34119,35 +34174,29 @@ function genConditionalSlot(slot, context) {
|
|
|
34119
34174
|
];
|
|
34120
34175
|
}
|
|
34121
34176
|
function genSlotBlockWithProps(oper, context) {
|
|
34122
|
-
let isDestructureAssignment = false;
|
|
34123
|
-
let rawProps;
|
|
34124
34177
|
let propsName;
|
|
34125
34178
|
let exitScope;
|
|
34126
34179
|
let depth;
|
|
34127
34180
|
const { props, key, node } = oper;
|
|
34128
|
-
const
|
|
34181
|
+
const idToPathMap = props ? parseValueDestructure(props, context) : /* @__PURE__ */ new Map();
|
|
34129
34182
|
if (props) {
|
|
34130
|
-
|
|
34131
|
-
if (isDestructureAssignment = !!props.ast) {
|
|
34183
|
+
if (props.ast) {
|
|
34132
34184
|
[depth, exitScope] = context.enterScope();
|
|
34133
34185
|
propsName = `_slotProps${depth}`;
|
|
34134
|
-
walkIdentifiers(
|
|
34135
|
-
props.ast,
|
|
34136
|
-
(id, _, __, ___, isLocal) => {
|
|
34137
|
-
if (isLocal) idsOfProps.add(id.name);
|
|
34138
|
-
},
|
|
34139
|
-
true
|
|
34140
|
-
);
|
|
34141
34186
|
} else {
|
|
34142
|
-
|
|
34187
|
+
propsName = props.content;
|
|
34143
34188
|
}
|
|
34144
34189
|
}
|
|
34145
|
-
const idMap =
|
|
34146
|
-
|
|
34147
|
-
|
|
34148
|
-
|
|
34190
|
+
const idMap = idToPathMap.size ? buildDestructureIdMap(
|
|
34191
|
+
idToPathMap,
|
|
34192
|
+
propsName || "",
|
|
34193
|
+
context.options.expressionPlugins
|
|
34194
|
+
) : {};
|
|
34195
|
+
if (propsName) {
|
|
34196
|
+
idMap[propsName] = null;
|
|
34197
|
+
}
|
|
34149
34198
|
let blockFn = context.withId(
|
|
34150
|
-
() => genBlock(oper, context, [propsName]),
|
|
34199
|
+
() => genBlock(oper, context, propsName ? [propsName] : []),
|
|
34151
34200
|
idMap
|
|
34152
34201
|
);
|
|
34153
34202
|
exitScope && exitScope();
|
|
@@ -34168,14 +34217,69 @@ function genSlotBlockWithProps(oper, context) {
|
|
|
34168
34217
|
];
|
|
34169
34218
|
}
|
|
34170
34219
|
if (node.type === 1) {
|
|
34171
|
-
|
|
34220
|
+
if (needsVaporCtx(oper)) {
|
|
34221
|
+
blockFn = [`${context.helper("withVaporCtx")}(`, ...blockFn, `)`];
|
|
34222
|
+
}
|
|
34172
34223
|
}
|
|
34173
34224
|
return blockFn;
|
|
34174
34225
|
}
|
|
34226
|
+
function needsVaporCtx(block) {
|
|
34227
|
+
return hasComponentOrSlotInBlock(block);
|
|
34228
|
+
}
|
|
34229
|
+
function hasComponentOrSlotInBlock(block) {
|
|
34230
|
+
if (hasComponentOrSlotInOperations(block.operation)) return true;
|
|
34231
|
+
return hasComponentOrSlotInDynamic(block.dynamic);
|
|
34232
|
+
}
|
|
34233
|
+
function hasComponentOrSlotInDynamic(dynamic) {
|
|
34234
|
+
if (dynamic.operation) {
|
|
34235
|
+
const type = dynamic.operation.type;
|
|
34236
|
+
if (type === 11 || type === 12) {
|
|
34237
|
+
return true;
|
|
34238
|
+
}
|
|
34239
|
+
if (type === 15) {
|
|
34240
|
+
if (hasComponentOrSlotInIf(dynamic.operation)) return true;
|
|
34241
|
+
}
|
|
34242
|
+
if (type === 16) {
|
|
34243
|
+
if (hasComponentOrSlotInBlock(dynamic.operation.render))
|
|
34244
|
+
return true;
|
|
34245
|
+
}
|
|
34246
|
+
}
|
|
34247
|
+
for (const child of dynamic.children) {
|
|
34248
|
+
if (hasComponentOrSlotInDynamic(child)) return true;
|
|
34249
|
+
}
|
|
34250
|
+
return false;
|
|
34251
|
+
}
|
|
34252
|
+
function hasComponentOrSlotInOperations(operations) {
|
|
34253
|
+
for (const op of operations) {
|
|
34254
|
+
switch (op.type) {
|
|
34255
|
+
case 11:
|
|
34256
|
+
case 12:
|
|
34257
|
+
return true;
|
|
34258
|
+
case 15:
|
|
34259
|
+
if (hasComponentOrSlotInIf(op)) return true;
|
|
34260
|
+
break;
|
|
34261
|
+
case 16:
|
|
34262
|
+
if (hasComponentOrSlotInBlock(op.render)) return true;
|
|
34263
|
+
break;
|
|
34264
|
+
}
|
|
34265
|
+
}
|
|
34266
|
+
return false;
|
|
34267
|
+
}
|
|
34268
|
+
function hasComponentOrSlotInIf(node) {
|
|
34269
|
+
if (hasComponentOrSlotInBlock(node.positive)) return true;
|
|
34270
|
+
if (node.negative) {
|
|
34271
|
+
if ("positive" in node.negative) {
|
|
34272
|
+
return hasComponentOrSlotInIf(node.negative);
|
|
34273
|
+
} else {
|
|
34274
|
+
return hasComponentOrSlotInBlock(node.negative);
|
|
34275
|
+
}
|
|
34276
|
+
}
|
|
34277
|
+
return false;
|
|
34278
|
+
}
|
|
34175
34279
|
|
|
34176
34280
|
function genSlotOutlet(oper, context) {
|
|
34177
34281
|
const { helper } = context;
|
|
34178
|
-
const { id, name, fallback, noSlotted } = oper;
|
|
34282
|
+
const { id, name, fallback, noSlotted, once } = oper;
|
|
34179
34283
|
const [frag, push] = buildCodeFragment();
|
|
34180
34284
|
const nameExpr = name.isStatic ? genExpression(name, context) : ["() => (", ...genExpression(name, context), ")"];
|
|
34181
34285
|
let fallbackArg;
|
|
@@ -34190,8 +34294,10 @@ function genSlotOutlet(oper, context) {
|
|
|
34190
34294
|
nameExpr,
|
|
34191
34295
|
genRawProps(oper.props, context) || "null",
|
|
34192
34296
|
fallbackArg,
|
|
34193
|
-
noSlotted && "true"
|
|
34297
|
+
noSlotted && "true",
|
|
34194
34298
|
// noSlotted
|
|
34299
|
+
once && "true"
|
|
34300
|
+
// v-once
|
|
34195
34301
|
)
|
|
34196
34302
|
);
|
|
34197
34303
|
return frag;
|
|
@@ -34323,7 +34429,7 @@ function genInsertionState(operation, context) {
|
|
|
34323
34429
|
];
|
|
34324
34430
|
}
|
|
34325
34431
|
|
|
34326
|
-
function genTemplates(templates,
|
|
34432
|
+
function genTemplates(templates, rootIndexes, context) {
|
|
34327
34433
|
const result = [];
|
|
34328
34434
|
let i = 0;
|
|
34329
34435
|
templates.forEach((ns, template) => {
|
|
@@ -34334,7 +34440,7 @@ function genTemplates(templates, rootIndex, context) {
|
|
|
34334
34440
|
// replace import expressions with string concatenation
|
|
34335
34441
|
IMPORT_EXPR_RE,
|
|
34336
34442
|
`" + $1 + "`
|
|
34337
|
-
)}${i
|
|
34443
|
+
)}${rootIndexes.has(i) ? ", true" : ns ? ", false" : ""}${ns ? `, ${ns}` : ""})
|
|
34338
34444
|
`
|
|
34339
34445
|
);
|
|
34340
34446
|
i++;
|
|
@@ -34441,9 +34547,6 @@ function genBlockContent(block, context, root, genEffectsExtraFrag) {
|
|
|
34441
34547
|
const [frag, push] = buildCodeFragment();
|
|
34442
34548
|
const { dynamic, effect, operation, returns, key } = block;
|
|
34443
34549
|
const resetBlock = context.enterBlock(block);
|
|
34444
|
-
if (block.hasDeferredVShow) {
|
|
34445
|
-
push(NEWLINE, `const deferredApplyVShows = []`);
|
|
34446
|
-
}
|
|
34447
34550
|
if (root) {
|
|
34448
34551
|
for (let name of context.ir.component) {
|
|
34449
34552
|
const id = toValidAssetId(name, "component");
|
|
@@ -34472,7 +34575,7 @@ function genBlockContent(block, context, root, genEffectsExtraFrag) {
|
|
|
34472
34575
|
}
|
|
34473
34576
|
push(...genOperations(operation, context));
|
|
34474
34577
|
push(...genEffects(effect, context, genEffectsExtraFrag));
|
|
34475
|
-
if (
|
|
34578
|
+
if (root && context.ir.hasDeferredVShow) {
|
|
34476
34579
|
push(NEWLINE, `deferredApplyVShows.forEach(fn => fn())`);
|
|
34477
34580
|
}
|
|
34478
34581
|
if (dynamic.needsKey) {
|
|
@@ -34628,13 +34731,16 @@ function generate(ir, options = {}) {
|
|
|
34628
34731
|
`const ${setTemplateRefIdent} = ${context.helper("createTemplateRefSetter")}()`
|
|
34629
34732
|
);
|
|
34630
34733
|
}
|
|
34734
|
+
if (ir.hasDeferredVShow) {
|
|
34735
|
+
push(NEWLINE, `const deferredApplyVShows = []`);
|
|
34736
|
+
}
|
|
34631
34737
|
push(...genBlockContent(ir.block, context, true));
|
|
34632
34738
|
push(INDENT_END, NEWLINE);
|
|
34633
34739
|
if (!inline) {
|
|
34634
34740
|
push("}");
|
|
34635
34741
|
}
|
|
34636
34742
|
const delegates = genDelegates(context);
|
|
34637
|
-
const templates = genTemplates(ir.template, ir.
|
|
34743
|
+
const templates = genTemplates(ir.template, ir.rootTemplateIndexes, context);
|
|
34638
34744
|
const imports = genHelperImports(context) + genAssetImports(context);
|
|
34639
34745
|
const preamble = imports + templates + delegates;
|
|
34640
34746
|
const newlineCount = [...preamble].filter((c) => c === "\n").length;
|
|
@@ -34781,6 +34887,11 @@ const isReservedProp = /* @__PURE__ */ makeMap(
|
|
|
34781
34887
|
const transformElement = (node, context) => {
|
|
34782
34888
|
let effectIndex = context.block.effect.length;
|
|
34783
34889
|
const getEffectIndex = () => effectIndex++;
|
|
34890
|
+
let parentSlots;
|
|
34891
|
+
if (node.type === 1 && (node.tagType === 1 || context.options.isCustomElement(node.tag))) {
|
|
34892
|
+
parentSlots = context.slots;
|
|
34893
|
+
context.slots = [];
|
|
34894
|
+
}
|
|
34784
34895
|
return function postTransformElement() {
|
|
34785
34896
|
({ node } = context);
|
|
34786
34897
|
if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1)))
|
|
@@ -34795,11 +34906,7 @@ const transformElement = (node, context) => {
|
|
|
34795
34906
|
isDynamicComponent,
|
|
34796
34907
|
getEffectIndex
|
|
34797
34908
|
);
|
|
34798
|
-
|
|
34799
|
-
while (parent && parent.parent && parent.node.type === 1 && parent.node.tagType === 3) {
|
|
34800
|
-
parent = parent.parent;
|
|
34801
|
-
}
|
|
34802
|
-
const singleRoot = context.root === parent && parent.node.children.filter((child) => child.type !== 3).length === 1 || isCustomElement;
|
|
34909
|
+
const singleRoot = isSingleRoot(context);
|
|
34803
34910
|
if (isComponent) {
|
|
34804
34911
|
transformComponentElement(
|
|
34805
34912
|
node,
|
|
@@ -34818,8 +34925,27 @@ const transformElement = (node, context) => {
|
|
|
34818
34925
|
getEffectIndex
|
|
34819
34926
|
);
|
|
34820
34927
|
}
|
|
34928
|
+
if (parentSlots) {
|
|
34929
|
+
context.slots = parentSlots;
|
|
34930
|
+
}
|
|
34821
34931
|
};
|
|
34822
34932
|
};
|
|
34933
|
+
function isSingleRoot(context) {
|
|
34934
|
+
if (context.inVFor) {
|
|
34935
|
+
return false;
|
|
34936
|
+
}
|
|
34937
|
+
let { parent } = context;
|
|
34938
|
+
if (parent && !(hasSingleChild(parent.node) || isSingleIfBlock(parent.node))) {
|
|
34939
|
+
return false;
|
|
34940
|
+
}
|
|
34941
|
+
while (parent && parent.parent && parent.node.type === 1 && parent.node.tagType === 3) {
|
|
34942
|
+
parent = parent.parent;
|
|
34943
|
+
if (!(hasSingleChild(parent.node) || isSingleIfBlock(parent.node))) {
|
|
34944
|
+
return false;
|
|
34945
|
+
}
|
|
34946
|
+
}
|
|
34947
|
+
return context.root === parent;
|
|
34948
|
+
}
|
|
34823
34949
|
function transformComponentElement(node, propsResult, singleRoot, context, isDynamicComponent, isCustomElement) {
|
|
34824
34950
|
const dynamicComponent = isDynamicComponent ? resolveDynamicComponent(node) : void 0;
|
|
34825
34951
|
let { tag } = node;
|
|
@@ -34857,7 +34983,7 @@ function transformComponentElement(node, propsResult, singleRoot, context, isDyn
|
|
|
34857
34983
|
tag,
|
|
34858
34984
|
props: propsResult[0] ? propsResult[1] : [propsResult[1]],
|
|
34859
34985
|
asset,
|
|
34860
|
-
root: singleRoot
|
|
34986
|
+
root: singleRoot,
|
|
34861
34987
|
slots: [...context.slots],
|
|
34862
34988
|
once: context.inVOnce,
|
|
34863
34989
|
dynamic: dynamicComponent,
|
|
@@ -34908,7 +35034,6 @@ function transformNativeElement(node, propsResult, singleRoot, context, getEffec
|
|
|
34908
35034
|
type: 3,
|
|
34909
35035
|
element: context.reference(),
|
|
34910
35036
|
props: dynamicArgs,
|
|
34911
|
-
root: singleRoot,
|
|
34912
35037
|
tag
|
|
34913
35038
|
},
|
|
34914
35039
|
getEffectIndex
|
|
@@ -34932,7 +35057,6 @@ function transformNativeElement(node, propsResult, singleRoot, context, getEffec
|
|
|
34932
35057
|
type: 2,
|
|
34933
35058
|
element: context.reference(),
|
|
34934
35059
|
prop,
|
|
34935
|
-
root: singleRoot,
|
|
34936
35060
|
tag
|
|
34937
35061
|
},
|
|
34938
35062
|
getEffectIndex
|
|
@@ -34945,7 +35069,7 @@ function transformNativeElement(node, propsResult, singleRoot, context, getEffec
|
|
|
34945
35069
|
template += `</${tag}>`;
|
|
34946
35070
|
}
|
|
34947
35071
|
if (singleRoot) {
|
|
34948
|
-
context.ir.
|
|
35072
|
+
context.ir.rootTemplateIndexes.add(context.ir.template.size);
|
|
34949
35073
|
}
|
|
34950
35074
|
if (context.parent && context.parent.node.type === 1 && !isValidHTMLNesting(context.parent.node.tag, tag)) {
|
|
34951
35075
|
context.reference();
|
|
@@ -35078,7 +35202,7 @@ function dedupeProperties(results) {
|
|
|
35078
35202
|
const name = prop.key.content;
|
|
35079
35203
|
const existing = knownProps.get(name);
|
|
35080
35204
|
if (existing && existing.handler === prop.handler) {
|
|
35081
|
-
if (name === "style" || name === "class") {
|
|
35205
|
+
if (name === "style" || name === "class" || prop.handler) {
|
|
35082
35206
|
mergePropValues(existing, prop);
|
|
35083
35207
|
}
|
|
35084
35208
|
} else {
|
|
@@ -35243,6 +35367,9 @@ const transformVOn = (dir, node, context) => {
|
|
|
35243
35367
|
keyOverride = ["click", "contextmenu"];
|
|
35244
35368
|
}
|
|
35245
35369
|
}
|
|
35370
|
+
if (keyModifiers.length && isStaticExp(arg) && !isKeyboardEvent(`on${arg.content.toLowerCase()}`)) {
|
|
35371
|
+
keyModifiers.length = 0;
|
|
35372
|
+
}
|
|
35246
35373
|
if (isComponent || isSlotOutlet) {
|
|
35247
35374
|
const handler = exp || EMPTY_EXPRESSION;
|
|
35248
35375
|
return {
|
|
@@ -35296,7 +35423,7 @@ const transformVShow = (dir, node, context) => {
|
|
|
35296
35423
|
if (parentNode && parentNode.type === 1) {
|
|
35297
35424
|
shouldDeferred = !!(isTransitionTag(parentNode.tag) && findProp(parentNode, "appear", false, true));
|
|
35298
35425
|
if (shouldDeferred) {
|
|
35299
|
-
context.
|
|
35426
|
+
context.ir.hasDeferredVShow = true;
|
|
35300
35427
|
}
|
|
35301
35428
|
}
|
|
35302
35429
|
context.registerOperation({
|
|
@@ -35569,7 +35696,7 @@ function getSiblingIf(context, reverse) {
|
|
|
35569
35696
|
let i = siblings.indexOf(context.node);
|
|
35570
35697
|
while (reverse ? --i >= 0 : ++i < siblings.length) {
|
|
35571
35698
|
sibling = siblings[i];
|
|
35572
|
-
if (!
|
|
35699
|
+
if (!isCommentOrWhitespace(sibling)) {
|
|
35573
35700
|
break;
|
|
35574
35701
|
}
|
|
35575
35702
|
}
|
|
@@ -35579,9 +35706,6 @@ function getSiblingIf(context, reverse) {
|
|
|
35579
35706
|
return sibling;
|
|
35580
35707
|
}
|
|
35581
35708
|
}
|
|
35582
|
-
function isCommentLike(node) {
|
|
35583
|
-
return node.type === 3 || node.type === 2 && !node.content.trim().length;
|
|
35584
|
-
}
|
|
35585
35709
|
|
|
35586
35710
|
const transformVIf = createStructuralDirectiveTransform(
|
|
35587
35711
|
["if", "else", "else-if"],
|
|
@@ -35805,7 +35929,8 @@ const transformSlotOutlet = (node, context) => {
|
|
|
35805
35929
|
name: slotName,
|
|
35806
35930
|
props: irProps,
|
|
35807
35931
|
fallback,
|
|
35808
|
-
noSlotted: !!(context.options.scopeId && !context.options.slotted)
|
|
35932
|
+
noSlotted: !!(context.options.scopeId && !context.options.slotted),
|
|
35933
|
+
once: context.inVOnce
|
|
35809
35934
|
};
|
|
35810
35935
|
};
|
|
35811
35936
|
};
|
|
@@ -37317,11 +37442,11 @@ const ssrTransformModel = (dir, node, context) => {
|
|
|
37317
37442
|
}
|
|
37318
37443
|
if (node.tagType === 0) {
|
|
37319
37444
|
const res = { props: [] };
|
|
37320
|
-
const defaultProps = [
|
|
37321
|
-
// default value binding for text type inputs
|
|
37322
|
-
createObjectProperty(`value`, model)
|
|
37323
|
-
];
|
|
37324
37445
|
if (node.tag === "input") {
|
|
37446
|
+
const defaultProps = [
|
|
37447
|
+
// default value binding for text type inputs
|
|
37448
|
+
createObjectProperty(`value`, model)
|
|
37449
|
+
];
|
|
37325
37450
|
const type = findProp$1(node, "type");
|
|
37326
37451
|
if (type) {
|
|
37327
37452
|
const value = findValueBinding(node);
|
|
@@ -37442,14 +37567,12 @@ const ssrTransformShow = (dir, node, context) => {
|
|
|
37442
37567
|
};
|
|
37443
37568
|
};
|
|
37444
37569
|
|
|
37445
|
-
const filterChild = (node) => node.children.filter((n) => n.type !== 3);
|
|
37446
|
-
const hasSingleChild = (node) => filterChild(node).length === 1;
|
|
37447
37570
|
const ssrInjectFallthroughAttrs = (node, context) => {
|
|
37448
37571
|
if (node.type === 0) {
|
|
37449
37572
|
context.identifiers._attrs = 1;
|
|
37450
37573
|
}
|
|
37451
37574
|
if (node.type === 1 && node.tagType === 1 && (node.tag === "transition" || node.tag === "Transition" || node.tag === "KeepAlive" || node.tag === "keep-alive")) {
|
|
37452
|
-
const rootChildren =
|
|
37575
|
+
const rootChildren = filterNonCommentChildren(context.root);
|
|
37453
37576
|
if (rootChildren.length === 1 && rootChildren[0] === node) {
|
|
37454
37577
|
if (hasSingleChild(node)) {
|
|
37455
37578
|
injectFallthroughAttrs(node.children[0]);
|
|
@@ -37462,20 +37585,9 @@ const ssrInjectFallthroughAttrs = (node, context) => {
|
|
|
37462
37585
|
return;
|
|
37463
37586
|
}
|
|
37464
37587
|
if (node.type === 10 && hasSingleChild(node)) {
|
|
37465
|
-
|
|
37466
|
-
|
|
37467
|
-
if (c.type === 9 || c.type === 1 && findDir$1(c, "if")) {
|
|
37468
|
-
if (hasEncounteredIf) return;
|
|
37469
|
-
hasEncounteredIf = true;
|
|
37470
|
-
} else if (
|
|
37471
|
-
// node before v-if
|
|
37472
|
-
!hasEncounteredIf || // non else nodes
|
|
37473
|
-
!(c.type === 1 && findDir$1(c, /else/, true))
|
|
37474
|
-
) {
|
|
37475
|
-
return;
|
|
37476
|
-
}
|
|
37588
|
+
if (isSingleIfBlock(parent)) {
|
|
37589
|
+
injectFallthroughAttrs(node.children[0]);
|
|
37477
37590
|
}
|
|
37478
|
-
injectFallthroughAttrs(node.children[0]);
|
|
37479
37591
|
} else if (hasSingleChild(parent)) {
|
|
37480
37592
|
injectFallthroughAttrs(node);
|
|
37481
37593
|
}
|
|
@@ -54517,7 +54629,7 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
|
|
|
54517
54629
|
}
|
|
54518
54630
|
if (sfc.cssVars.length && // no need to do this when targeting SSR
|
|
54519
54631
|
!ssr) {
|
|
54520
|
-
ctx.helperImports.add(
|
|
54632
|
+
ctx.helperImports.add(getCssVarsHelper(vapor));
|
|
54521
54633
|
ctx.helperImports.add("unref");
|
|
54522
54634
|
ctx.s.prependLeft(
|
|
54523
54635
|
startOffset,
|
|
@@ -54526,7 +54638,8 @@ ${genCssVarsCode(
|
|
|
54526
54638
|
sfc.cssVars,
|
|
54527
54639
|
ctx.bindingMetadata,
|
|
54528
54640
|
scopeId,
|
|
54529
|
-
!!options.isProd
|
|
54641
|
+
!!options.isProd,
|
|
54642
|
+
vapor
|
|
54530
54643
|
)}
|
|
54531
54644
|
`
|
|
54532
54645
|
);
|
|
@@ -54948,7 +55061,7 @@ var __spreadValues = (a, b) => {
|
|
|
54948
55061
|
}
|
|
54949
55062
|
return a;
|
|
54950
55063
|
};
|
|
54951
|
-
const version = "3.6.0-alpha.
|
|
55064
|
+
const version = "3.6.0-alpha.6";
|
|
54952
55065
|
const parseCache = parseCache$1;
|
|
54953
55066
|
const errorMessages = __spreadValues(__spreadValues({}, errorMessages$1), DOMErrorMessages);
|
|
54954
55067
|
const walk = walk$2;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/compiler-sfc",
|
|
3
|
-
"version": "3.6.0-alpha.
|
|
3
|
+
"version": "3.6.0-alpha.6",
|
|
4
4
|
"description": "@vue/compiler-sfc",
|
|
5
5
|
"main": "dist/compiler-sfc.cjs.js",
|
|
6
6
|
"module": "dist/compiler-sfc.esm-browser.js",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"magic-string": "^0.30.21",
|
|
48
48
|
"postcss": "^8.5.6",
|
|
49
49
|
"source-map-js": "^1.2.1",
|
|
50
|
-
"@vue/compiler-core": "3.6.0-alpha.
|
|
51
|
-
"@vue/compiler-dom": "3.6.0-alpha.
|
|
52
|
-
"@vue/compiler-vapor": "3.6.0-alpha.
|
|
53
|
-
"@vue/compiler-ssr": "3.6.0-alpha.
|
|
54
|
-
"@vue/shared": "3.6.0-alpha.
|
|
50
|
+
"@vue/compiler-core": "3.6.0-alpha.6",
|
|
51
|
+
"@vue/compiler-dom": "3.6.0-alpha.6",
|
|
52
|
+
"@vue/compiler-vapor": "3.6.0-alpha.6",
|
|
53
|
+
"@vue/compiler-ssr": "3.6.0-alpha.6",
|
|
54
|
+
"@vue/shared": "3.6.0-alpha.6"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@babel/types": "^7.28.5",
|