@vue/compiler-sfc 3.6.0-beta.16 → 3.6.0-beta.17
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 +2 -2
- package/dist/compiler-sfc.esm-browser.js +390 -168
- 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-beta.
|
|
2
|
+
* @vue/compiler-sfc v3.6.0-beta.17
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -18394,7 +18394,7 @@ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
|
|
|
18394
18394
|
}
|
|
18395
18395
|
//#endregion
|
|
18396
18396
|
//#region packages/compiler-sfc/src/index.ts
|
|
18397
|
-
const version = "3.6.0-beta.
|
|
18397
|
+
const version = "3.6.0-beta.17";
|
|
18398
18398
|
const parseCache = parseCache$1;
|
|
18399
18399
|
const errorMessages = {
|
|
18400
18400
|
..._vue_compiler_dom.errorMessages,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-sfc v3.6.0-beta.
|
|
2
|
+
* @vue/compiler-sfc v3.6.0-beta.17
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -24908,6 +24908,7 @@ function getBlockShape(block) {
|
|
|
24908
24908
|
//#endregion
|
|
24909
24909
|
//#region packages/compiler-vapor/src/transform.ts
|
|
24910
24910
|
const generatedVarRE = /^[nxr](\d+)$/;
|
|
24911
|
+
const childContextInfoCache = /* @__PURE__ */ new WeakMap();
|
|
24911
24912
|
var TransformContext = class TransformContext {
|
|
24912
24913
|
constructor(ir, node, options = {}) {
|
|
24913
24914
|
this.ir = ir;
|
|
@@ -24933,6 +24934,7 @@ var TransformContext = class TransformContext {
|
|
|
24933
24934
|
this.operationIndex = this.block.operation.length;
|
|
24934
24935
|
this.isLastEffectiveChild = true;
|
|
24935
24936
|
this.isOnRightmostPath = true;
|
|
24937
|
+
this.isSingleRoot = false;
|
|
24936
24938
|
this.templateCloseTags = void 0;
|
|
24937
24939
|
this.templateCloseBlocks = false;
|
|
24938
24940
|
this.globalId = 0;
|
|
@@ -25058,8 +25060,10 @@ var TransformContext = class TransformContext {
|
|
|
25058
25060
|
create(node, index) {
|
|
25059
25061
|
let effectiveParent = this;
|
|
25060
25062
|
while (effectiveParent && effectiveParent.node.type === 1 && effectiveParent.node.tagType === 3) effectiveParent = effectiveParent.parent;
|
|
25061
|
-
const
|
|
25063
|
+
const childInfo = this.getChildContextInfo();
|
|
25064
|
+
const isLastEffectiveChild = childInfo.isLastEffectiveChild[index];
|
|
25062
25065
|
const isOnRightmostPath = this.isOnRightmostPath && isLastEffectiveChild;
|
|
25066
|
+
const isSingleRoot = this.isSingleRootChild(childInfo);
|
|
25063
25067
|
return Object.assign(Object.create(TransformContext.prototype), this, {
|
|
25064
25068
|
node,
|
|
25065
25069
|
parent: this,
|
|
@@ -25074,6 +25078,7 @@ var TransformContext = class TransformContext {
|
|
|
25074
25078
|
effectiveParent,
|
|
25075
25079
|
isLastEffectiveChild,
|
|
25076
25080
|
isOnRightmostPath,
|
|
25081
|
+
isSingleRoot,
|
|
25077
25082
|
templateCloseTags: this.templateCloseTags,
|
|
25078
25083
|
templateCloseBlocks: this.templateCloseBlocks
|
|
25079
25084
|
});
|
|
@@ -25083,12 +25088,59 @@ var TransformContext = class TransformContext {
|
|
|
25083
25088
|
if (operation && isBlockOperation(operation) && operation.effectIndex !== void 0 && operation.effectIndex >= index) operation.effectIndex++;
|
|
25084
25089
|
for (const child of dynamic.children) this.shiftEffectBoundaries(index, child);
|
|
25085
25090
|
}
|
|
25086
|
-
|
|
25087
|
-
const
|
|
25088
|
-
if (
|
|
25089
|
-
|
|
25091
|
+
getChildContextInfo() {
|
|
25092
|
+
const node = this.node;
|
|
25093
|
+
if (node.type !== 0 && node.type !== 1) return {
|
|
25094
|
+
node,
|
|
25095
|
+
hasSingleRootChild: true,
|
|
25096
|
+
isLastEffectiveChild: []
|
|
25097
|
+
};
|
|
25098
|
+
const cached = childContextInfoCache.get(this);
|
|
25099
|
+
if (cached && cached.node === node) return cached;
|
|
25100
|
+
const { children } = node;
|
|
25101
|
+
const isLastEffectiveChild = new Array(children.length);
|
|
25102
|
+
let hasFollowingEffectiveChild = false;
|
|
25103
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
25104
|
+
isLastEffectiveChild[i] = !hasFollowingEffectiveChild;
|
|
25105
|
+
if (!isComponentChild(children[i])) hasFollowingEffectiveChild = true;
|
|
25106
|
+
}
|
|
25107
|
+
const childInfo = {
|
|
25108
|
+
node,
|
|
25109
|
+
hasSingleRootChild: hasSingleRootChild(children),
|
|
25110
|
+
isLastEffectiveChild
|
|
25111
|
+
};
|
|
25112
|
+
childContextInfoCache.set(this, childInfo);
|
|
25113
|
+
return childInfo;
|
|
25114
|
+
}
|
|
25115
|
+
isSingleRootChild(childInfo) {
|
|
25116
|
+
if (this.inVFor || !childInfo.hasSingleRootChild) return false;
|
|
25117
|
+
if (this.node.type === 0) return true;
|
|
25118
|
+
return this.node.type === 1 && this.node.tagType === 3 && !!this.parent && this.isSingleRoot;
|
|
25090
25119
|
}
|
|
25091
25120
|
};
|
|
25121
|
+
function hasSingleRootChild(children) {
|
|
25122
|
+
let nonCommentChildren = 0;
|
|
25123
|
+
let hasEncounteredIf = false;
|
|
25124
|
+
let isSingleIfBlock = true;
|
|
25125
|
+
for (const child of children) {
|
|
25126
|
+
if (isCommentOrWhitespace(child)) continue;
|
|
25127
|
+
nonCommentChildren++;
|
|
25128
|
+
if (isIfChild(child)) {
|
|
25129
|
+
if (hasEncounteredIf) isSingleIfBlock = false;
|
|
25130
|
+
hasEncounteredIf = true;
|
|
25131
|
+
} else if (!hasEncounteredIf || !isElseChild(child)) isSingleIfBlock = false;
|
|
25132
|
+
}
|
|
25133
|
+
return nonCommentChildren === 1 || isSingleIfBlock;
|
|
25134
|
+
}
|
|
25135
|
+
function isComponentChild(child) {
|
|
25136
|
+
return child.type === 1 && child.tagType === 1;
|
|
25137
|
+
}
|
|
25138
|
+
function isIfChild(child) {
|
|
25139
|
+
return child.type === 9 || child.type === 1 && !!findDir$1(child, "if");
|
|
25140
|
+
}
|
|
25141
|
+
function isElseChild(child) {
|
|
25142
|
+
return child.type === 1 && !!findDir$1(child, /^else(-if)?$/, true);
|
|
25143
|
+
}
|
|
25092
25144
|
const defaultOptions = {
|
|
25093
25145
|
filename: "",
|
|
25094
25146
|
prefixIdentifiers: true,
|
|
@@ -25504,28 +25556,31 @@ function canPrefix(name) {
|
|
|
25504
25556
|
}
|
|
25505
25557
|
function processExpressions(context, expressions, shouldDeclare) {
|
|
25506
25558
|
const expressionReplacements = /* @__PURE__ */ new Map();
|
|
25507
|
-
const { seenVariable, variableToExpMap,
|
|
25559
|
+
const { seenVariable, variableToExpMap, expressionRecords, seenIdentifier, updatedVariable } = analyzeExpressions(expressions);
|
|
25508
25560
|
const reservedNames = new Set(seenIdentifier);
|
|
25509
|
-
const varDeclarations = processRepeatedVariables(context, seenVariable, variableToExpMap,
|
|
25510
|
-
const expDeclarations = processRepeatedExpressions(context, expressions, varDeclarations, updatedVariable,
|
|
25561
|
+
const varDeclarations = processRepeatedVariables(context, seenVariable, variableToExpMap, expressionRecords, seenIdentifier, updatedVariable, reservedNames, expressionReplacements);
|
|
25562
|
+
const expDeclarations = processRepeatedExpressions(context, expressions, varDeclarations, updatedVariable, expressionRecords, reservedNames, expressionReplacements);
|
|
25511
25563
|
return _objectSpread2(_objectSpread2({}, genDeclarations([...varDeclarations, ...expDeclarations], context, shouldDeclare)), {}, { expressionReplacements });
|
|
25512
25564
|
}
|
|
25513
25565
|
function analyzeExpressions(expressions) {
|
|
25514
25566
|
const seenVariable = Object.create(null);
|
|
25515
25567
|
const variableToExpMap = /* @__PURE__ */ new Map();
|
|
25516
|
-
const
|
|
25568
|
+
const expressionRecords = /* @__PURE__ */ new Map();
|
|
25517
25569
|
const seenIdentifier = /* @__PURE__ */ new Set();
|
|
25518
25570
|
const updatedVariable = /* @__PURE__ */ new Set();
|
|
25571
|
+
const getRecord = (exp) => {
|
|
25572
|
+
let record = expressionRecords.get(exp);
|
|
25573
|
+
if (!record) expressionRecords.set(exp, record = { variables: [] });
|
|
25574
|
+
return record;
|
|
25575
|
+
};
|
|
25519
25576
|
const registerVariable = (name, exp, isIdentifier, loc, parentStack = []) => {
|
|
25520
25577
|
if (isIdentifier) seenIdentifier.add(name);
|
|
25521
25578
|
seenVariable[name] = (seenVariable[name] || 0) + 1;
|
|
25522
25579
|
variableToExpMap.set(name, (variableToExpMap.get(name) || /* @__PURE__ */ new Set()).add(exp));
|
|
25523
|
-
|
|
25524
|
-
variables.push({
|
|
25580
|
+
getRecord(exp).variables.push({
|
|
25525
25581
|
name,
|
|
25526
25582
|
loc
|
|
25527
25583
|
});
|
|
25528
|
-
expToVariableMap.set(exp, variables);
|
|
25529
25584
|
if (parentStack.some((p) => p.type === "UpdateExpression" || p.type === "AssignmentExpression")) updatedVariable.add(name);
|
|
25530
25585
|
};
|
|
25531
25586
|
for (const exp of expressions) {
|
|
@@ -25562,7 +25617,7 @@ function analyzeExpressions(expressions) {
|
|
|
25562
25617
|
seenVariable,
|
|
25563
25618
|
seenIdentifier,
|
|
25564
25619
|
variableToExpMap,
|
|
25565
|
-
|
|
25620
|
+
expressionRecords,
|
|
25566
25621
|
updatedVariable
|
|
25567
25622
|
};
|
|
25568
25623
|
}
|
|
@@ -25572,9 +25627,10 @@ function getProcessedExpression(exp, expressionReplacements) {
|
|
|
25572
25627
|
function setExpressionReplacement(expressionReplacements, exp, content, ast) {
|
|
25573
25628
|
expressionReplacements.set(exp, extend({ ast }, createSimpleExpression(content, exp.isStatic, exp.loc, exp.constType)));
|
|
25574
25629
|
}
|
|
25575
|
-
function processRepeatedVariables(context, seenVariable, variableToExpMap,
|
|
25630
|
+
function processRepeatedVariables(context, seenVariable, variableToExpMap, expressionRecords, seenIdentifier, updatedVariable, reservedNames, expressionReplacements) {
|
|
25576
25631
|
const declarations = [];
|
|
25577
|
-
const
|
|
25632
|
+
const declaredNames = /* @__PURE__ */ new Set();
|
|
25633
|
+
const replacementPlan = /* @__PURE__ */ new Map();
|
|
25578
25634
|
for (const [name, exps] of variableToExpMap) {
|
|
25579
25635
|
if (updatedVariable.has(name)) continue;
|
|
25580
25636
|
if (isGloballyAllowed(name)) continue;
|
|
@@ -25583,96 +25639,201 @@ function processRepeatedVariables(context, seenVariable, variableToExpMap, expTo
|
|
|
25583
25639
|
const varName = isIdentifier ? name : getUniqueDeclarationName(genVarName(name), reservedNames);
|
|
25584
25640
|
exps.forEach((node) => {
|
|
25585
25641
|
if (node.ast && varName !== name) {
|
|
25586
|
-
const
|
|
25587
|
-
|
|
25588
|
-
|
|
25589
|
-
|
|
25590
|
-
if (v.name === name && v.loc) locs.push(v.loc);
|
|
25591
|
-
return locs;
|
|
25592
|
-
}, [])
|
|
25642
|
+
for (const variable of getExpressionVariables(expressionRecords, node)) if (variable.name === name && variable.loc) queueContentReplacement(replacementPlan, node, {
|
|
25643
|
+
start: variable.loc.start - 1,
|
|
25644
|
+
end: variable.loc.end - 1,
|
|
25645
|
+
content: varName
|
|
25593
25646
|
});
|
|
25594
|
-
expToReplacementMap.set(node, replacements);
|
|
25595
25647
|
}
|
|
25596
25648
|
});
|
|
25597
|
-
if (!
|
|
25598
|
-
|
|
25599
|
-
|
|
25600
|
-
|
|
25601
|
-
|
|
25602
|
-
|
|
25603
|
-
|
|
25604
|
-
|
|
25649
|
+
if (!declaredNames.has(varName) && (!isIdentifier || shouldDeclareVariable(name, expressionRecords, exps))) {
|
|
25650
|
+
declaredNames.add(varName);
|
|
25651
|
+
declarations.push({
|
|
25652
|
+
name: varName,
|
|
25653
|
+
isIdentifier,
|
|
25654
|
+
value: extend({ ast: isIdentifier ? null : parseExp(context, name) }, createSimpleExpression(name)),
|
|
25655
|
+
rawName: name,
|
|
25656
|
+
exps,
|
|
25657
|
+
seenCount: seenVariable[name]
|
|
25658
|
+
});
|
|
25659
|
+
}
|
|
25605
25660
|
}
|
|
25606
25661
|
}
|
|
25607
|
-
|
|
25608
|
-
let content = getProcessedExpression(exp, expressionReplacements).content;
|
|
25609
|
-
replacements.flatMap(({ name, locs }) => locs.map(({ start, end }) => ({
|
|
25610
|
-
start,
|
|
25611
|
-
end,
|
|
25612
|
-
name
|
|
25613
|
-
}))).sort((a, b) => b.end - a.end).forEach(({ start, end, name }) => {
|
|
25614
|
-
content = content.slice(0, start - 1) + name + content.slice(end - 1);
|
|
25615
|
-
});
|
|
25616
|
-
setExpressionReplacement(expressionReplacements, exp, content, parseExp(context, content));
|
|
25617
|
-
}
|
|
25662
|
+
applyReplacementPlan(context, expressionReplacements, replacementPlan);
|
|
25618
25663
|
return declarations;
|
|
25619
25664
|
}
|
|
25620
|
-
function shouldDeclareVariable(name,
|
|
25621
|
-
const
|
|
25622
|
-
|
|
25623
|
-
|
|
25624
|
-
|
|
25625
|
-
|
|
25626
|
-
|
|
25665
|
+
function shouldDeclareVariable(name, expressionRecords, exps) {
|
|
25666
|
+
const variableUsages = [];
|
|
25667
|
+
let allSingleVariable = true;
|
|
25668
|
+
let hasRepeatedName = false;
|
|
25669
|
+
let hasDifferentLength = false;
|
|
25670
|
+
outer: for (const exp of exps) {
|
|
25671
|
+
const variables = getExpressionVariables(expressionRecords, exp);
|
|
25672
|
+
if (allSingleVariable && variables.length !== 1) allSingleVariable = false;
|
|
25673
|
+
if (!hasDifferentLength && variableUsages.length > 0 && variables.length !== variableUsages[0].length) hasDifferentLength = true;
|
|
25674
|
+
let nameCount = 0;
|
|
25675
|
+
for (const variable of variables) if (variable.name === name && ++nameCount > 1) {
|
|
25676
|
+
hasRepeatedName = true;
|
|
25677
|
+
break outer;
|
|
25678
|
+
}
|
|
25679
|
+
variableUsages.push(variables);
|
|
25680
|
+
}
|
|
25681
|
+
if (allSingleVariable) return true;
|
|
25682
|
+
if (hasRepeatedName) return true;
|
|
25683
|
+
const first = variableUsages[0];
|
|
25684
|
+
if (hasDifferentLength) {
|
|
25685
|
+
for (const variables of variableUsages) {
|
|
25686
|
+
if (variables.length === first.length) continue;
|
|
25687
|
+
const longer = variables.length > first.length ? variables : first;
|
|
25688
|
+
const shorter = variables.length > first.length ? first : variables;
|
|
25689
|
+
const shorterNames = /* @__PURE__ */ new Set();
|
|
25690
|
+
for (const variable of shorter) shorterNames.add(variable.name);
|
|
25691
|
+
let isSubset = true;
|
|
25692
|
+
for (const variable of longer) if (!shorterNames.has(variable.name)) {
|
|
25693
|
+
isSubset = false;
|
|
25694
|
+
break;
|
|
25695
|
+
}
|
|
25696
|
+
if (isSubset) return false;
|
|
25697
|
+
}
|
|
25627
25698
|
return true;
|
|
25628
25699
|
}
|
|
25629
|
-
|
|
25630
|
-
return
|
|
25700
|
+
for (const variables of variableUsages) for (let i = 0; i < variables.length; i++) if (variables[i].name !== first[i].name) return true;
|
|
25701
|
+
return false;
|
|
25631
25702
|
}
|
|
25632
|
-
function processRepeatedExpressions(context, expressions, varDeclarations, updatedVariable,
|
|
25703
|
+
function processRepeatedExpressions(context, expressions, varDeclarations, updatedVariable, expressionRecords, reservedNames, expressionReplacements) {
|
|
25633
25704
|
const declarations = [];
|
|
25634
|
-
const seenExp =
|
|
25635
|
-
|
|
25636
|
-
|
|
25705
|
+
const seenExp = /* @__PURE__ */ new Map();
|
|
25706
|
+
for (const exp of expressions) {
|
|
25707
|
+
var _expressionRecords$ge;
|
|
25708
|
+
const vars = (_expressionRecords$ge = expressionRecords.get(exp)) === null || _expressionRecords$ge === void 0 ? void 0 : _expressionRecords$ge.variables;
|
|
25709
|
+
if (!vars) continue;
|
|
25637
25710
|
const processed = getProcessedExpression(exp, expressionReplacements);
|
|
25638
|
-
|
|
25639
|
-
|
|
25640
|
-
|
|
25641
|
-
|
|
25642
|
-
|
|
25643
|
-
|
|
25644
|
-
const delVars = {};
|
|
25645
|
-
for (let i = varDeclarations.length - 1; i >= 0; i--) {
|
|
25646
|
-
const item = varDeclarations[i];
|
|
25647
|
-
if (!item.exps || !item.seenCount) continue;
|
|
25648
|
-
if ([...item.exps].every((node) => getProcessedExpression(node, expressionReplacements).content === content && item.seenCount === count)) {
|
|
25649
|
-
delVars[item.name] = item.rawName;
|
|
25650
|
-
reservedNames.delete(item.name);
|
|
25651
|
-
varDeclarations.splice(i, 1);
|
|
25652
|
-
}
|
|
25653
|
-
}
|
|
25654
|
-
const value = extend({}, getProcessedExpression(expressions.find((exp) => getProcessedExpression(exp, expressionReplacements).content === content), expressionReplacements));
|
|
25655
|
-
Object.keys(delVars).forEach((name) => {
|
|
25656
|
-
value.content = value.content.replace(name, delVars[name]);
|
|
25657
|
-
if (value.ast) value.ast = parseExp(context, value.content);
|
|
25658
|
-
});
|
|
25659
|
-
const varName = getUniqueDeclarationName(genVarName(content), reservedNames);
|
|
25660
|
-
declarations.push({
|
|
25661
|
-
name: varName,
|
|
25662
|
-
value
|
|
25711
|
+
if (canCacheExpression(processed, vars, updatedVariable)) {
|
|
25712
|
+
const seen = seenExp.get(processed.content);
|
|
25713
|
+
if (seen) seen.count++;
|
|
25714
|
+
else seenExp.set(processed.content, {
|
|
25715
|
+
count: 1,
|
|
25716
|
+
first: exp
|
|
25663
25717
|
});
|
|
25664
|
-
|
|
25665
|
-
|
|
25666
|
-
|
|
25667
|
-
|
|
25668
|
-
|
|
25718
|
+
}
|
|
25719
|
+
}
|
|
25720
|
+
const repeatedExpressions = [...seenExp].sort(([contentA], [contentB]) => contentB.length - contentA.length);
|
|
25721
|
+
for (const [content, { count, first }] of repeatedExpressions) if (count > 1) {
|
|
25722
|
+
const removedDeclarations = [];
|
|
25723
|
+
for (let i = varDeclarations.length - 1; i >= 0; i--) {
|
|
25724
|
+
const item = varDeclarations[i];
|
|
25725
|
+
if (!item.exps || !item.seenCount) continue;
|
|
25726
|
+
if ([...item.exps].every((node) => getProcessedExpression(node, expressionReplacements).content === content && item.seenCount === count)) {
|
|
25727
|
+
removedDeclarations.push({
|
|
25728
|
+
name: item.name,
|
|
25729
|
+
rawName: item.rawName
|
|
25730
|
+
});
|
|
25731
|
+
reservedNames.delete(item.name);
|
|
25732
|
+
varDeclarations.splice(i, 1);
|
|
25733
|
+
}
|
|
25734
|
+
}
|
|
25735
|
+
const value = extend({}, getProcessedExpression(first, expressionReplacements));
|
|
25736
|
+
const restorePlan = [];
|
|
25737
|
+
for (const { name, rawName } of removedDeclarations) restorePlan.push(...findIdentifierReplacements(value, name, rawName));
|
|
25738
|
+
if (restorePlan.length) {
|
|
25739
|
+
value.content = applyContentReplacements(value.content, restorePlan);
|
|
25740
|
+
if (value.ast) value.ast = parseExp(context, value.content);
|
|
25741
|
+
}
|
|
25742
|
+
const varName = getUniqueDeclarationName(genVarName(content), reservedNames);
|
|
25743
|
+
declarations.push({
|
|
25744
|
+
name: varName,
|
|
25745
|
+
value
|
|
25746
|
+
});
|
|
25747
|
+
for (const exp of expressions) {
|
|
25748
|
+
const processed = getProcessedExpression(exp, expressionReplacements);
|
|
25749
|
+
if (processed.content === content) setExpressionReplacement(expressionReplacements, exp, varName, null);
|
|
25750
|
+
else if (processed.content.includes(content)) {
|
|
25751
|
+
const replacements = findContentReplacements(processed, content, varName);
|
|
25752
|
+
if (replacements.length) {
|
|
25753
|
+
const replacedContent = applyContentReplacements(processed.content, replacements);
|
|
25669
25754
|
setExpressionReplacement(expressionReplacements, exp, replacedContent, parseExp(context, replacedContent));
|
|
25670
25755
|
}
|
|
25671
|
-
}
|
|
25756
|
+
}
|
|
25672
25757
|
}
|
|
25673
|
-
}
|
|
25758
|
+
}
|
|
25674
25759
|
return declarations;
|
|
25675
25760
|
}
|
|
25761
|
+
function canCacheExpression(processed, vars, updatedVariable) {
|
|
25762
|
+
if (!processed.ast || processed.ast.type === "Identifier") return false;
|
|
25763
|
+
for (const { name } of vars) if (updatedVariable.has(name) || isGloballyAllowed(name)) return false;
|
|
25764
|
+
return true;
|
|
25765
|
+
}
|
|
25766
|
+
function getExpressionVariables(expressionRecords, exp) {
|
|
25767
|
+
var _expressionRecords$ge2;
|
|
25768
|
+
return ((_expressionRecords$ge2 = expressionRecords.get(exp)) === null || _expressionRecords$ge2 === void 0 ? void 0 : _expressionRecords$ge2.variables) || [];
|
|
25769
|
+
}
|
|
25770
|
+
function queueContentReplacement(replacementPlan, exp, replacement) {
|
|
25771
|
+
const replacements = replacementPlan.get(exp);
|
|
25772
|
+
if (replacements) replacements.push(replacement);
|
|
25773
|
+
else replacementPlan.set(exp, [replacement]);
|
|
25774
|
+
}
|
|
25775
|
+
function applyReplacementPlan(context, expressionReplacements, replacementPlan) {
|
|
25776
|
+
for (const [exp, replacements] of replacementPlan) {
|
|
25777
|
+
if (!replacements.length) continue;
|
|
25778
|
+
const content = applyContentReplacements(getProcessedExpression(exp, expressionReplacements).content, replacements);
|
|
25779
|
+
setExpressionReplacement(expressionReplacements, exp, content, parseExp(context, content));
|
|
25780
|
+
}
|
|
25781
|
+
}
|
|
25782
|
+
function findContentReplacements(exp, content, replacement) {
|
|
25783
|
+
const identifiers = getIdentifierRanges(exp);
|
|
25784
|
+
if (!identifiers.length) return [];
|
|
25785
|
+
const replacements = [];
|
|
25786
|
+
let searchStart = 0;
|
|
25787
|
+
let start = exp.content.indexOf(content, searchStart);
|
|
25788
|
+
while (start !== -1) {
|
|
25789
|
+
const end = start + content.length;
|
|
25790
|
+
let canReplace = false;
|
|
25791
|
+
for (const identifier of identifiers) {
|
|
25792
|
+
if (start >= identifier.end || end <= identifier.start) continue;
|
|
25793
|
+
if (start > identifier.start || end < identifier.end) {
|
|
25794
|
+
canReplace = false;
|
|
25795
|
+
break;
|
|
25796
|
+
}
|
|
25797
|
+
canReplace = true;
|
|
25798
|
+
}
|
|
25799
|
+
if (canReplace) {
|
|
25800
|
+
replacements.push({
|
|
25801
|
+
start,
|
|
25802
|
+
end,
|
|
25803
|
+
content: replacement
|
|
25804
|
+
});
|
|
25805
|
+
searchStart = end;
|
|
25806
|
+
} else searchStart = start + 1;
|
|
25807
|
+
start = exp.content.indexOf(content, searchStart);
|
|
25808
|
+
}
|
|
25809
|
+
return replacements;
|
|
25810
|
+
}
|
|
25811
|
+
function findIdentifierReplacements(exp, name, replacement) {
|
|
25812
|
+
const replacements = [];
|
|
25813
|
+
for (const { start, end } of getIdentifierRanges(exp)) if (exp.content.slice(start, end) === name) replacements.push({
|
|
25814
|
+
start,
|
|
25815
|
+
end,
|
|
25816
|
+
content: replacement
|
|
25817
|
+
});
|
|
25818
|
+
return replacements;
|
|
25819
|
+
}
|
|
25820
|
+
function getIdentifierRanges(exp) {
|
|
25821
|
+
if (!exp.ast || typeof exp.ast !== "object") return [];
|
|
25822
|
+
const identifiers = [];
|
|
25823
|
+
walkIdentifiers(exp.ast, (id) => {
|
|
25824
|
+
identifiers.push({
|
|
25825
|
+
start: id.start - 1,
|
|
25826
|
+
end: id.end - 1
|
|
25827
|
+
});
|
|
25828
|
+
}, false);
|
|
25829
|
+
return identifiers;
|
|
25830
|
+
}
|
|
25831
|
+
function applyContentReplacements(content, replacements) {
|
|
25832
|
+
replacements.sort((a, b) => b.start - a.start).forEach(({ start, end, content: replacement }) => {
|
|
25833
|
+
content = content.slice(0, start) + replacement + content.slice(end);
|
|
25834
|
+
});
|
|
25835
|
+
return content;
|
|
25836
|
+
}
|
|
25676
25837
|
function genDeclarations(declarations, context, shouldDeclare) {
|
|
25677
25838
|
const [frag, push] = buildCodeFragment();
|
|
25678
25839
|
const ids = Object.create(null);
|
|
@@ -25700,9 +25861,6 @@ function genDeclarations(declarations, context, shouldDeclare) {
|
|
|
25700
25861
|
varNames: [...varNames]
|
|
25701
25862
|
};
|
|
25702
25863
|
}
|
|
25703
|
-
function escapeRegExp(string) {
|
|
25704
|
-
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
25705
|
-
}
|
|
25706
25864
|
function parseExp(context, content) {
|
|
25707
25865
|
return (0, import_lib.parseExpression)(`(${content})`, getParserOptions(context.options.expressionPlugins));
|
|
25708
25866
|
}
|
|
@@ -25893,7 +26051,7 @@ function genFor(oper, context) {
|
|
|
25893
26051
|
idMap[rawIndex] = `${indexVar}.value`;
|
|
25894
26052
|
idMap[indexVar] = null;
|
|
25895
26053
|
}
|
|
25896
|
-
const { selectorPatterns, keyOnlyBindingPatterns } = matchPatterns(render, keyProp, idMap, context);
|
|
26054
|
+
const { selectorPatterns, keyOnlyBindingPatterns, skippedEffectIndexes } = matchPatterns(render, keyProp, idMap, context);
|
|
25897
26055
|
const selectorDeclarations = [];
|
|
25898
26056
|
const selectorName = (i) => selectorPatterns.length > 1 ? `_selector${id}_${i}` : `_selector${id}`;
|
|
25899
26057
|
for (let i = 0; i < selectorPatterns.length; i++) {
|
|
@@ -25913,26 +26071,20 @@ function genFor(oper, context) {
|
|
|
25913
26071
|
}
|
|
25914
26072
|
for (const { effect } of keyOnlyBindingPatterns) for (const oper of effect.operations) patternFrag.push(...genOperation(oper, context));
|
|
25915
26073
|
return patternFrag;
|
|
25916
|
-
}));
|
|
26074
|
+
}, skippedEffectIndexes));
|
|
25917
26075
|
else frag.push(...genBlockContent(render, context));
|
|
25918
26076
|
frag.push(INDENT_END, NEWLINE, "}");
|
|
25919
26077
|
return frag;
|
|
25920
26078
|
}, idMap);
|
|
25921
26079
|
exitScope();
|
|
25922
|
-
|
|
25923
|
-
if (onlyChild) flags |= 1;
|
|
25924
|
-
if (component) flags |= 2;
|
|
25925
|
-
if (isFragmentBlock(render)) flags |= 16;
|
|
25926
|
-
if (!component && isSingleNodeBlock(render)) flags |= 8;
|
|
25927
|
-
if (once) flags |= 4;
|
|
25928
|
-
if (slotRoot) flags |= 32;
|
|
26080
|
+
const flags = genForFlags(onlyChild, component, isFragmentBlock(render), !component && isSingleNodeBlock(render), once, slotRoot);
|
|
25929
26081
|
const onResetCalls = [];
|
|
25930
26082
|
for (let i = 0; i < selectorPatterns.length; i++) onResetCalls.push(NEWLINE, `n${id}.onReset(${selectorName(i)}.reset)`);
|
|
25931
26083
|
return [
|
|
25932
26084
|
NEWLINE,
|
|
25933
26085
|
...selectorDeclarations,
|
|
25934
26086
|
`const n${id} = `,
|
|
25935
|
-
...genCall([helper("createFor"), "undefined"], sourceExpr, blockFn, genCallback(keyProp), flags
|
|
26087
|
+
...genCall([helper("createFor"), "undefined"], sourceExpr, blockFn, genCallback(keyProp), flags),
|
|
25936
26088
|
...onResetCalls
|
|
25937
26089
|
];
|
|
25938
26090
|
function genCallback(expr) {
|
|
@@ -25957,6 +26109,36 @@ function genFor(oper, context) {
|
|
|
25957
26109
|
return idMap;
|
|
25958
26110
|
}
|
|
25959
26111
|
}
|
|
26112
|
+
function genForFlags(onlyChild, component, isFragment, isSingleNode, once, slotRoot) {
|
|
26113
|
+
let flags = 0;
|
|
26114
|
+
const names = [];
|
|
26115
|
+
if (onlyChild) {
|
|
26116
|
+
flags |= 1;
|
|
26117
|
+
names.push("FAST_REMOVE");
|
|
26118
|
+
}
|
|
26119
|
+
if (component) {
|
|
26120
|
+
flags |= 2;
|
|
26121
|
+
names.push("IS_COMPONENT");
|
|
26122
|
+
}
|
|
26123
|
+
if (isFragment) {
|
|
26124
|
+
flags |= 16;
|
|
26125
|
+
names.push("IS_FRAGMENT");
|
|
26126
|
+
}
|
|
26127
|
+
if (isSingleNode) {
|
|
26128
|
+
flags |= 8;
|
|
26129
|
+
names.push("IS_SINGLE_NODE");
|
|
26130
|
+
}
|
|
26131
|
+
if (once) {
|
|
26132
|
+
flags |= 4;
|
|
26133
|
+
names.push("ONCE");
|
|
26134
|
+
}
|
|
26135
|
+
if (slotRoot) {
|
|
26136
|
+
flags |= 32;
|
|
26137
|
+
names.push("SLOT_ROOT");
|
|
26138
|
+
}
|
|
26139
|
+
if (!flags) return;
|
|
26140
|
+
return `${flags} /* ${names.join(", ")} */`;
|
|
26141
|
+
}
|
|
25960
26142
|
function isSingleNodeBlock(block) {
|
|
25961
26143
|
const child = getSingleReturnedChild(block);
|
|
25962
26144
|
return !!child && child.template != null;
|
|
@@ -26043,39 +26225,35 @@ function buildDestructureIdMap(idToPathMap, baseAccessor, plugins) {
|
|
|
26043
26225
|
function matchPatterns(render, keyProp, idMap, context) {
|
|
26044
26226
|
const selectorPatterns = [];
|
|
26045
26227
|
const keyOnlyBindingPatterns = [];
|
|
26046
|
-
|
|
26047
|
-
|
|
26048
|
-
|
|
26049
|
-
|
|
26050
|
-
|
|
26051
|
-
|
|
26052
|
-
|
|
26053
|
-
|
|
26054
|
-
|
|
26055
|
-
|
|
26056
|
-
|
|
26057
|
-
|
|
26058
|
-
|
|
26059
|
-
return false;
|
|
26060
|
-
}
|
|
26228
|
+
let skippedEffectIndexes;
|
|
26229
|
+
if (keyProp === void 0) return {
|
|
26230
|
+
keyOnlyBindingPatterns,
|
|
26231
|
+
selectorPatterns,
|
|
26232
|
+
skippedEffectIndexes
|
|
26233
|
+
};
|
|
26234
|
+
for (let index = 0; index < render.effect.length; index++) {
|
|
26235
|
+
const effect = render.effect[index];
|
|
26236
|
+
const selector = matchSelectorPattern(effect, keyProp.content, idMap, context);
|
|
26237
|
+
if (selector) {
|
|
26238
|
+
selectorPatterns.push(selector);
|
|
26239
|
+
skipEffect(index);
|
|
26240
|
+
continue;
|
|
26061
26241
|
}
|
|
26062
|
-
|
|
26063
|
-
|
|
26064
|
-
|
|
26242
|
+
const keyOnly = matchKeyOnlyBindingPattern(effect, keyProp.content);
|
|
26243
|
+
if (keyOnly) {
|
|
26244
|
+
keyOnlyBindingPatterns.push(keyOnly);
|
|
26245
|
+
skipEffect(index);
|
|
26246
|
+
}
|
|
26247
|
+
}
|
|
26065
26248
|
return {
|
|
26066
26249
|
keyOnlyBindingPatterns,
|
|
26067
|
-
selectorPatterns
|
|
26250
|
+
selectorPatterns,
|
|
26251
|
+
skippedEffectIndexes
|
|
26068
26252
|
};
|
|
26069
|
-
|
|
26070
|
-
|
|
26071
|
-
|
|
26072
|
-
if (operation && isBlockOperation(operation) && operation.effectIndex !== void 0) {
|
|
26073
|
-
let offset = 0;
|
|
26074
|
-
for (const removedIndex of removedEffectIndexes) if (removedIndex < operation.effectIndex) offset++;
|
|
26075
|
-
else break;
|
|
26076
|
-
operation.effectIndex -= offset;
|
|
26253
|
+
function skipEffect(index) {
|
|
26254
|
+
if (!skippedEffectIndexes) skippedEffectIndexes = /* @__PURE__ */ new Set();
|
|
26255
|
+
skippedEffectIndexes.add(index);
|
|
26077
26256
|
}
|
|
26078
|
-
for (const child of dynamic.children) shiftEffectBoundaries(child, removedEffectIndexes);
|
|
26079
26257
|
}
|
|
26080
26258
|
function matchKeyOnlyBindingPattern(effect, key) {
|
|
26081
26259
|
if (effect.expressions.length === 1) {
|
|
@@ -26180,14 +26358,25 @@ function genIfFlags(blockShape, once, slotRoot, index) {
|
|
|
26180
26358
|
return `${flags} /* ${genIfFlagNames(once, slotRoot, index, blockShape)} */`;
|
|
26181
26359
|
}
|
|
26182
26360
|
function genIfFlagNames(once, slotRoot, index, blockShape) {
|
|
26183
|
-
const names = [
|
|
26361
|
+
const names = [`TRUE_${genBlockShapeName(blockShape)}`];
|
|
26362
|
+
const falseShape = blockShape >> 2;
|
|
26363
|
+
const hasFalseBranch = (falseShape & 3) !== 0;
|
|
26364
|
+
if (hasFalseBranch) names.push(`FALSE_${genBlockShapeName(falseShape)}`);
|
|
26184
26365
|
if (blockShape & 32) names.push("TRUE_NO_SCOPE");
|
|
26185
|
-
if (blockShape & 64) names.push("FALSE_NO_SCOPE");
|
|
26366
|
+
if (hasFalseBranch && blockShape & 64) names.push("FALSE_NO_SCOPE");
|
|
26186
26367
|
if (once) names.push("ONCE");
|
|
26187
26368
|
if (slotRoot) names.push("SLOT_ROOT");
|
|
26188
|
-
if (!once && index !== void 0) names.push(
|
|
26369
|
+
if (!once && index !== void 0) names.push(`KEYED_INDEX_${index}`);
|
|
26189
26370
|
return names.join(", ");
|
|
26190
26371
|
}
|
|
26372
|
+
function genBlockShapeName(flags) {
|
|
26373
|
+
switch (flags & 3) {
|
|
26374
|
+
case 0: return "EMPTY";
|
|
26375
|
+
case 1: return "SINGLE_ROOT";
|
|
26376
|
+
case 2: return "MULTI_ROOT";
|
|
26377
|
+
}
|
|
26378
|
+
return "UNKNOWN";
|
|
26379
|
+
}
|
|
26191
26380
|
//#endregion
|
|
26192
26381
|
//#region packages/compiler-vapor/src/generators/prop.ts
|
|
26193
26382
|
const helpers = {
|
|
@@ -26544,7 +26733,7 @@ function genCreateComponent(operation, context) {
|
|
|
26544
26733
|
const tag = genTag();
|
|
26545
26734
|
const { root, props, slots, once, slotRoot } = operation;
|
|
26546
26735
|
const isRuntimeDynamicComponent = !!(operation.dynamic && !operation.dynamic.isStatic);
|
|
26547
|
-
const dynamicComponentFlags = isRuntimeDynamicComponent ? (root
|
|
26736
|
+
const dynamicComponentFlags = isRuntimeDynamicComponent ? genDynamicComponentFlags(root, once, slotRoot) : false;
|
|
26548
26737
|
const rawSlots = genRawSlots(slots, context);
|
|
26549
26738
|
const [ids, handlers] = processInlineHandlers(props, context);
|
|
26550
26739
|
const rawProps = context.withId(() => genRawProps(props, context, true), ids);
|
|
@@ -26560,7 +26749,7 @@ function genCreateComponent(operation, context) {
|
|
|
26560
26749
|
];
|
|
26561
26750
|
}, []),
|
|
26562
26751
|
`const n${operation.id} = `,
|
|
26563
|
-
...genCall(isRuntimeDynamicComponent ? helper("createDynamicComponent") : operation.useCreateElement ? helper("createPlainElement") : useAssetComponentHelper ? helper("createAssetComponent") : operation.asset ? helper("createComponentWithFallback") : helper("createComponent"), tag, rawProps, rawSlots, isRuntimeDynamicComponent ? dynamicComponentFlags
|
|
26752
|
+
...genCall(isRuntimeDynamicComponent ? helper("createDynamicComponent") : operation.useCreateElement ? helper("createPlainElement") : useAssetComponentHelper ? helper("createAssetComponent") : operation.asset ? helper("createComponentWithFallback") : helper("createComponent"), tag, rawProps, rawSlots, isRuntimeDynamicComponent ? dynamicComponentFlags : root ? "true" : false, isRuntimeDynamicComponent ? false : once && "true", isRuntimeDynamicComponent ? false : maybeSelfReference && "true"),
|
|
26564
26753
|
...genDirectivesForElement(operation.id, context)
|
|
26565
26754
|
];
|
|
26566
26755
|
function genTag() {
|
|
@@ -26586,6 +26775,24 @@ function genCreateComponent(operation, context) {
|
|
|
26586
26775
|
}
|
|
26587
26776
|
}
|
|
26588
26777
|
}
|
|
26778
|
+
function genDynamicComponentFlags(root, once, slotRoot) {
|
|
26779
|
+
let flags = 0;
|
|
26780
|
+
const names = [];
|
|
26781
|
+
if (root) {
|
|
26782
|
+
flags |= 1;
|
|
26783
|
+
names.push("SINGLE_ROOT");
|
|
26784
|
+
}
|
|
26785
|
+
if (once) {
|
|
26786
|
+
flags |= 2;
|
|
26787
|
+
names.push("ONCE");
|
|
26788
|
+
}
|
|
26789
|
+
if (slotRoot) {
|
|
26790
|
+
flags |= 4;
|
|
26791
|
+
names.push("SLOT_ROOT");
|
|
26792
|
+
}
|
|
26793
|
+
if (!flags) return false;
|
|
26794
|
+
return `${flags} /* ${names.join(", ")} */`;
|
|
26795
|
+
}
|
|
26589
26796
|
function getUniqueHandlerName(context, name) {
|
|
26590
26797
|
const { seenInlineHandlerNames } = context;
|
|
26591
26798
|
name = genVarName(name);
|
|
@@ -26896,13 +27103,22 @@ function genSlotBlockWithProps(oper, context, emitNonStableFlag = true) {
|
|
|
26896
27103
|
const idMap = idToPathMap.size ? buildDestructureIdMap(idToPathMap, propsName || "", context.options.expressionPlugins) : {};
|
|
26897
27104
|
if (propsName) idMap[propsName] = null;
|
|
26898
27105
|
const exitSlotBlock = context.enterSlotBlock();
|
|
26899
|
-
|
|
27106
|
+
const hasStableRoot = hasStableSlotRoot(oper, context);
|
|
27107
|
+
if (!hasStableRoot) markSlotRootOperations(oper);
|
|
26900
27108
|
let blockFn = context.withId(() => genBlock(oper, context, propsName ? [propsName] : []), idMap);
|
|
26901
|
-
if (emitNonStableFlag && !
|
|
27109
|
+
if (emitNonStableFlag && !hasStableRoot) blockFn = genCall(context.helper("extend"), blockFn, [`{ _: ${genSlotFlags$1(8)} }`]);
|
|
26902
27110
|
exitSlotBlock();
|
|
26903
27111
|
exitScope && exitScope();
|
|
26904
27112
|
return blockFn;
|
|
26905
27113
|
}
|
|
27114
|
+
function genSlotFlags$1(flags) {
|
|
27115
|
+
const names = [];
|
|
27116
|
+
if (flags & 1) names.push("NO_SLOTTED");
|
|
27117
|
+
if (flags & 2) names.push("ONCE");
|
|
27118
|
+
if (flags & 4) names.push("SLOT_ROOT");
|
|
27119
|
+
if (flags & 8) names.push("NON_STABLE");
|
|
27120
|
+
return `${flags} /* ${names.join(", ")} */`;
|
|
27121
|
+
}
|
|
26906
27122
|
const commentOnlyTemplateRE = /^(?:<!--[\s\S]*?-->)+$/;
|
|
26907
27123
|
function hasStableSlotRoot(block, context) {
|
|
26908
27124
|
let hasValidRoot = false;
|
|
@@ -26920,14 +27136,14 @@ function hasStableSlotRoot(block, context) {
|
|
|
26920
27136
|
hasValidRoot = true;
|
|
26921
27137
|
continue;
|
|
26922
27138
|
}
|
|
26923
|
-
|
|
27139
|
+
continue;
|
|
26924
27140
|
case 17:
|
|
26925
27141
|
if (hasStableSlotRoot(operation.block, context)) {
|
|
26926
27142
|
hasValidRoot = true;
|
|
26927
27143
|
continue;
|
|
26928
27144
|
}
|
|
26929
|
-
|
|
26930
|
-
default:
|
|
27145
|
+
continue;
|
|
27146
|
+
default: continue;
|
|
26931
27147
|
}
|
|
26932
27148
|
}
|
|
26933
27149
|
return hasValidRoot;
|
|
@@ -26945,7 +27161,7 @@ function genSlotOutlet(oper, context) {
|
|
|
26945
27161
|
const [frag, push] = buildCodeFragment();
|
|
26946
27162
|
let fallbackArg;
|
|
26947
27163
|
if (fallback) {
|
|
26948
|
-
markSlotRootOperations(fallback);
|
|
27164
|
+
if (context.inSlotBlock) markSlotRootOperations(fallback);
|
|
26949
27165
|
fallbackArg = genBlock(fallback, context);
|
|
26950
27166
|
}
|
|
26951
27167
|
const createSlot = helper("createSlot");
|
|
@@ -26955,9 +27171,17 @@ function genSlotOutlet(oper, context) {
|
|
|
26955
27171
|
...genExpression(name, context),
|
|
26956
27172
|
")"
|
|
26957
27173
|
];
|
|
26958
|
-
push(NEWLINE, `const n${id} = `, ...genCall(createSlot, nameArg, rawPropsArg, fallbackArg,
|
|
27174
|
+
push(NEWLINE, `const n${id} = `, ...genCall(createSlot, nameArg, rawPropsArg, fallbackArg, genSlotFlags(flags)));
|
|
26959
27175
|
return frag;
|
|
26960
27176
|
}
|
|
27177
|
+
function genSlotFlags(flags) {
|
|
27178
|
+
if (!flags) return;
|
|
27179
|
+
const names = [];
|
|
27180
|
+
if (flags & 1) names.push("NO_SLOTTED");
|
|
27181
|
+
if (flags & 2) names.push("ONCE");
|
|
27182
|
+
if (flags & 4) names.push("SLOT_ROOT");
|
|
27183
|
+
return `${flags} /* ${names.join(", ")} */`;
|
|
27184
|
+
}
|
|
26961
27185
|
//#endregion
|
|
26962
27186
|
//#region packages/compiler-vapor/src/generators/key.ts
|
|
26963
27187
|
function genKey(oper, context) {
|
|
@@ -27230,7 +27454,7 @@ function genBlock(oper, context, args = [], root) {
|
|
|
27230
27454
|
"}"
|
|
27231
27455
|
];
|
|
27232
27456
|
}
|
|
27233
|
-
function genBlockContent(block, context, root, genEffectsExtraFrag) {
|
|
27457
|
+
function genBlockContent(block, context, root, genEffectsExtraFrag, skippedEffectIndexes) {
|
|
27234
27458
|
const [frag, push] = buildCodeFragment();
|
|
27235
27459
|
const { dynamic, effect, operation, returns } = block;
|
|
27236
27460
|
const resetBlock = context.enterBlock(block);
|
|
@@ -27255,7 +27479,7 @@ function genBlockContent(block, context, root, genEffectsExtraFrag) {
|
|
|
27255
27479
|
operationIndex++;
|
|
27256
27480
|
}
|
|
27257
27481
|
if (effectIndex < effectEnd) {
|
|
27258
|
-
push(...
|
|
27482
|
+
push(...genEffectRange(effectIndex, effectEnd));
|
|
27259
27483
|
effectIndex = effectEnd;
|
|
27260
27484
|
}
|
|
27261
27485
|
};
|
|
@@ -27269,7 +27493,7 @@ function genBlockContent(block, context, root, genEffectsExtraFrag) {
|
|
|
27269
27493
|
}
|
|
27270
27494
|
for (const child of dynamic.children) if (!child.hasDynamicChild) push(...genChildren(child, context, push, `n${child.id}`, flushBeforeDynamic));
|
|
27271
27495
|
if (operationIndex < operation.length) push(...genOperations(operation.slice(operationIndex), context));
|
|
27272
|
-
if (effectIndex < effect.length) push(...
|
|
27496
|
+
if (effectIndex < effect.length) push(...genEffectRange(effectIndex, effect.length, genEffectsExtraFrag));
|
|
27273
27497
|
else if (genEffectsExtraFrag) push(...genEffects([], context, genEffectsExtraFrag));
|
|
27274
27498
|
push(NEWLINE, `return `);
|
|
27275
27499
|
const returnNodes = returns.map((n) => `n${n}`);
|
|
@@ -27277,6 +27501,13 @@ function genBlockContent(block, context, root, genEffectsExtraFrag) {
|
|
|
27277
27501
|
resetBlock();
|
|
27278
27502
|
context.singleUseAssetComponentNames = prevSingleUseAssetComponentNames;
|
|
27279
27503
|
return frag;
|
|
27504
|
+
function genEffectRange(start, end, genExtraFrag) {
|
|
27505
|
+
if (!skippedEffectIndexes) return genEffects(effect.slice(start, end), context, genExtraFrag);
|
|
27506
|
+
const effects = [];
|
|
27507
|
+
for (let i = start; i < end; i++) if (!skippedEffectIndexes.has(i)) effects.push(effect[i]);
|
|
27508
|
+
if (effects.length || genExtraFrag) return genEffects(effects, context, genExtraFrag);
|
|
27509
|
+
return [];
|
|
27510
|
+
}
|
|
27280
27511
|
function genResolveAssets(kind, helper) {
|
|
27281
27512
|
for (const name of context.ir[kind]) push(NEWLINE, `const ${toValidAssetId(name, kind)} = `, ...genCall(context.helper(helper), JSON.stringify(name)));
|
|
27282
27513
|
}
|
|
@@ -27288,7 +27519,6 @@ function markSlotRootOperations(block) {
|
|
|
27288
27519
|
if (!operation) continue;
|
|
27289
27520
|
if (operation.type === 15) markSlotRootIf(operation);
|
|
27290
27521
|
else if (operation.type === 16) markSlotRootFor(operation);
|
|
27291
|
-
else if (operation.type === 13) markSlotRootSlotOutlet(operation);
|
|
27292
27522
|
else if (operation.type === 12) markSlotRootComponent(operation);
|
|
27293
27523
|
}
|
|
27294
27524
|
}
|
|
@@ -27304,10 +27534,6 @@ function markSlotRootFor(operation) {
|
|
|
27304
27534
|
if (!operation.once) operation.slotRoot = true;
|
|
27305
27535
|
markSlotRootOperations(operation.render);
|
|
27306
27536
|
}
|
|
27307
|
-
function markSlotRootSlotOutlet(operation) {
|
|
27308
|
-
operation.flags |= 4;
|
|
27309
|
-
if (operation.fallback) markSlotRootOperations(operation.fallback);
|
|
27310
|
-
}
|
|
27311
27537
|
function markSlotRootComponent(operation) {
|
|
27312
27538
|
if (!operation.once && operation.dynamic && !operation.dynamic.isStatic) operation.slotRoot = true;
|
|
27313
27539
|
}
|
|
@@ -27656,7 +27882,7 @@ const transformElement = (node, context) => {
|
|
|
27656
27882
|
const isDynamicComponent = isComponentTag(node.tag);
|
|
27657
27883
|
const staticKey = resolveStaticKey(node, context, isComponent);
|
|
27658
27884
|
const propsResult = buildProps(node, context, isComponent, isDynamicComponent, getEffectIndex);
|
|
27659
|
-
const singleRoot = isSingleRoot
|
|
27885
|
+
const singleRoot = context.isSingleRoot;
|
|
27660
27886
|
if (isComponent) transformComponentElement(node, propsResult, staticKey, singleRoot, context, isDynamicComponent, useCreateElement);
|
|
27661
27887
|
else transformNativeElement(node, propsResult, staticKey, singleRoot, context, getEffectIndex, context.root === context.effectiveParent || canOmitEndTag(node, context));
|
|
27662
27888
|
if (parentSlots) context.slots = parentSlots;
|
|
@@ -27695,16 +27921,6 @@ function isInSameTemplateAsParent(context) {
|
|
|
27695
27921
|
if (parentNode.type !== 1 || parentNode.tagType !== 0) return false;
|
|
27696
27922
|
return !shouldUseCreateElement(parentNode, parent) && isValidHTMLNesting(parentNode.tag, node.tag);
|
|
27697
27923
|
}
|
|
27698
|
-
function isSingleRoot(context) {
|
|
27699
|
-
if (context.inVFor) return false;
|
|
27700
|
-
let { parent } = context;
|
|
27701
|
-
if (parent && !(hasSingleChild(parent.node) || isSingleIfBlock(parent.node))) return false;
|
|
27702
|
-
while (parent && parent.parent && parent.node.type === 1 && parent.node.tagType === 3) {
|
|
27703
|
-
parent = parent.parent;
|
|
27704
|
-
if (!(hasSingleChild(parent.node) || isSingleIfBlock(parent.node))) return false;
|
|
27705
|
-
}
|
|
27706
|
-
return context.root === parent;
|
|
27707
|
-
}
|
|
27708
27924
|
function transformComponentElement(node, propsResult, staticKey, singleRoot, context, isDynamicComponent, useCreateElement) {
|
|
27709
27925
|
const dynamicComponent = isDynamicComponent ? resolveDynamicComponent(node) : void 0;
|
|
27710
27926
|
let { tag } = node;
|
|
@@ -28369,13 +28585,7 @@ const transformText = (node, context) => {
|
|
|
28369
28585
|
};
|
|
28370
28586
|
function processInterpolation(context) {
|
|
28371
28587
|
const parentNode = context.parent.node;
|
|
28372
|
-
const
|
|
28373
|
-
const nexts = children.slice(context.index);
|
|
28374
|
-
const idx = nexts.findIndex((n) => !isTextLike(n));
|
|
28375
|
-
const nodes = idx > -1 ? nexts.slice(0, idx) : nexts;
|
|
28376
|
-
const prev = children[context.index - 1];
|
|
28377
|
-
if (prev && prev.type === 2) nodes.unshift(prev);
|
|
28378
|
-
const values = processTextLikeChildren(nodes, context);
|
|
28588
|
+
const values = processTextLikeChildren(collectAdjacentText(context), context);
|
|
28379
28589
|
if (values.length === 0 && parentNode.type !== 0) return;
|
|
28380
28590
|
const literalValues = values.map((v) => getLiteralExpressionValue(v));
|
|
28381
28591
|
if (literalValues.every((v) => v != null) && parentNode.type !== 0) {
|
|
@@ -28397,6 +28607,18 @@ function processInterpolation(context) {
|
|
|
28397
28607
|
values
|
|
28398
28608
|
});
|
|
28399
28609
|
}
|
|
28610
|
+
function collectAdjacentText(context) {
|
|
28611
|
+
const children = context.parent.node.children;
|
|
28612
|
+
const nodes = [];
|
|
28613
|
+
const prev = children[context.index - 1];
|
|
28614
|
+
let index = prev && prev.type === 2 ? context.index - 1 : context.index;
|
|
28615
|
+
for (; index < children.length; index++) {
|
|
28616
|
+
const child = children[index];
|
|
28617
|
+
if (!isTextLike(child)) break;
|
|
28618
|
+
nodes.push(child);
|
|
28619
|
+
}
|
|
28620
|
+
return nodes;
|
|
28621
|
+
}
|
|
28400
28622
|
function processTextContainer(children, context) {
|
|
28401
28623
|
const values = processTextLikeChildren(children, context);
|
|
28402
28624
|
const literals = values.map((value) => getLiteralExpressionValue(value));
|
|
@@ -42298,7 +42520,7 @@ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
|
|
|
42298
42520
|
//#endregion
|
|
42299
42521
|
//#region packages/compiler-sfc/src/index.ts
|
|
42300
42522
|
init_objectSpread2();
|
|
42301
|
-
const version = "3.6.0-beta.
|
|
42523
|
+
const version = "3.6.0-beta.17";
|
|
42302
42524
|
const parseCache = parseCache$1;
|
|
42303
42525
|
const errorMessages = _objectSpread2(_objectSpread2({}, errorMessages$1), DOMErrorMessages);
|
|
42304
42526
|
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-beta.
|
|
3
|
+
"version": "3.6.0-beta.17",
|
|
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.14",
|
|
49
49
|
"source-map-js": "^1.2.1",
|
|
50
|
-
"@vue/compiler-core": "3.6.0-beta.
|
|
51
|
-
"@vue/compiler-dom": "3.6.0-beta.
|
|
52
|
-
"@vue/compiler-ssr": "3.6.0-beta.
|
|
53
|
-
"@vue/compiler-vapor": "3.6.0-beta.
|
|
54
|
-
"@vue/shared": "3.6.0-beta.
|
|
50
|
+
"@vue/compiler-core": "3.6.0-beta.17",
|
|
51
|
+
"@vue/compiler-dom": "3.6.0-beta.17",
|
|
52
|
+
"@vue/compiler-ssr": "3.6.0-beta.17",
|
|
53
|
+
"@vue/compiler-vapor": "3.6.0-beta.17",
|
|
54
|
+
"@vue/shared": "3.6.0-beta.17"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@babel/types": "^7.29.7",
|