@vue/compiler-vapor 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-vapor.cjs.js +399 -177
- package/dist/compiler-vapor.d.ts +11 -8
- package/dist/compiler-vapor.esm-browser.js +389 -181
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-vapor v3.6.0-beta.
|
|
2
|
+
* @vue/compiler-vapor v3.6.0-beta.17
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -15986,20 +15986,6 @@ function toValidAssetId(name, type) {
|
|
|
15986
15986
|
return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
|
|
15987
15987
|
})}`;
|
|
15988
15988
|
}
|
|
15989
|
-
function filterNonCommentChildren(node) {
|
|
15990
|
-
return node.children.filter((n) => !isCommentOrWhitespace(n));
|
|
15991
|
-
}
|
|
15992
|
-
function hasSingleChild(node) {
|
|
15993
|
-
return filterNonCommentChildren(node).length === 1;
|
|
15994
|
-
}
|
|
15995
|
-
function isSingleIfBlock(parent) {
|
|
15996
|
-
let hasEncounteredIf = false;
|
|
15997
|
-
for (const c of filterNonCommentChildren(parent)) if (c.type === 9 || c.type === 1 && findDir$1(c, "if")) {
|
|
15998
|
-
if (hasEncounteredIf) return false;
|
|
15999
|
-
hasEncounteredIf = true;
|
|
16000
|
-
} else if (!hasEncounteredIf || !(c.type === 1 && findDir$1(c, /^else(-if)?$/, true))) return false;
|
|
16001
|
-
return true;
|
|
16002
|
-
}
|
|
16003
15989
|
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
|
|
16004
15990
|
function isAllWhitespace(str) {
|
|
16005
15991
|
for (let i = 0; i < str.length; i++) if (!isWhitespace(str.charCodeAt(i))) return false;
|
|
@@ -19171,6 +19157,7 @@ function getBlockShape(block) {
|
|
|
19171
19157
|
//#endregion
|
|
19172
19158
|
//#region packages/compiler-vapor/src/transform.ts
|
|
19173
19159
|
const generatedVarRE = /^[nxr](\d+)$/;
|
|
19160
|
+
const childContextInfoCache = /* @__PURE__ */ new WeakMap();
|
|
19174
19161
|
var TransformContext = class TransformContext {
|
|
19175
19162
|
constructor(ir, node, options = {}) {
|
|
19176
19163
|
this.ir = ir;
|
|
@@ -19196,6 +19183,7 @@ var TransformContext = class TransformContext {
|
|
|
19196
19183
|
this.operationIndex = this.block.operation.length;
|
|
19197
19184
|
this.isLastEffectiveChild = true;
|
|
19198
19185
|
this.isOnRightmostPath = true;
|
|
19186
|
+
this.isSingleRoot = false;
|
|
19199
19187
|
this.templateCloseTags = void 0;
|
|
19200
19188
|
this.templateCloseBlocks = false;
|
|
19201
19189
|
this.globalId = 0;
|
|
@@ -19321,8 +19309,10 @@ var TransformContext = class TransformContext {
|
|
|
19321
19309
|
create(node, index) {
|
|
19322
19310
|
let effectiveParent = this;
|
|
19323
19311
|
while (effectiveParent && effectiveParent.node.type === 1 && effectiveParent.node.tagType === 3) effectiveParent = effectiveParent.parent;
|
|
19324
|
-
const
|
|
19312
|
+
const childInfo = this.getChildContextInfo();
|
|
19313
|
+
const isLastEffectiveChild = childInfo.isLastEffectiveChild[index];
|
|
19325
19314
|
const isOnRightmostPath = this.isOnRightmostPath && isLastEffectiveChild;
|
|
19315
|
+
const isSingleRoot = this.isSingleRootChild(childInfo);
|
|
19326
19316
|
return Object.assign(Object.create(TransformContext.prototype), this, {
|
|
19327
19317
|
node,
|
|
19328
19318
|
parent: this,
|
|
@@ -19337,6 +19327,7 @@ var TransformContext = class TransformContext {
|
|
|
19337
19327
|
effectiveParent,
|
|
19338
19328
|
isLastEffectiveChild,
|
|
19339
19329
|
isOnRightmostPath,
|
|
19330
|
+
isSingleRoot,
|
|
19340
19331
|
templateCloseTags: this.templateCloseTags,
|
|
19341
19332
|
templateCloseBlocks: this.templateCloseBlocks
|
|
19342
19333
|
});
|
|
@@ -19346,12 +19337,59 @@ var TransformContext = class TransformContext {
|
|
|
19346
19337
|
if (operation && isBlockOperation(operation) && operation.effectIndex !== void 0 && operation.effectIndex >= index) operation.effectIndex++;
|
|
19347
19338
|
for (const child of dynamic.children) this.shiftEffectBoundaries(index, child);
|
|
19348
19339
|
}
|
|
19349
|
-
|
|
19350
|
-
const
|
|
19351
|
-
if (
|
|
19352
|
-
|
|
19340
|
+
getChildContextInfo() {
|
|
19341
|
+
const node = this.node;
|
|
19342
|
+
if (node.type !== 0 && node.type !== 1) return {
|
|
19343
|
+
node,
|
|
19344
|
+
hasSingleRootChild: true,
|
|
19345
|
+
isLastEffectiveChild: []
|
|
19346
|
+
};
|
|
19347
|
+
const cached = childContextInfoCache.get(this);
|
|
19348
|
+
if (cached && cached.node === node) return cached;
|
|
19349
|
+
const { children } = node;
|
|
19350
|
+
const isLastEffectiveChild = new Array(children.length);
|
|
19351
|
+
let hasFollowingEffectiveChild = false;
|
|
19352
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
19353
|
+
isLastEffectiveChild[i] = !hasFollowingEffectiveChild;
|
|
19354
|
+
if (!isComponentChild(children[i])) hasFollowingEffectiveChild = true;
|
|
19355
|
+
}
|
|
19356
|
+
const childInfo = {
|
|
19357
|
+
node,
|
|
19358
|
+
hasSingleRootChild: hasSingleRootChild(children),
|
|
19359
|
+
isLastEffectiveChild
|
|
19360
|
+
};
|
|
19361
|
+
childContextInfoCache.set(this, childInfo);
|
|
19362
|
+
return childInfo;
|
|
19363
|
+
}
|
|
19364
|
+
isSingleRootChild(childInfo) {
|
|
19365
|
+
if (this.inVFor || !childInfo.hasSingleRootChild) return false;
|
|
19366
|
+
if (this.node.type === 0) return true;
|
|
19367
|
+
return this.node.type === 1 && this.node.tagType === 3 && !!this.parent && this.isSingleRoot;
|
|
19353
19368
|
}
|
|
19354
19369
|
};
|
|
19370
|
+
function hasSingleRootChild(children) {
|
|
19371
|
+
let nonCommentChildren = 0;
|
|
19372
|
+
let hasEncounteredIf = false;
|
|
19373
|
+
let isSingleIfBlock = true;
|
|
19374
|
+
for (const child of children) {
|
|
19375
|
+
if (isCommentOrWhitespace(child)) continue;
|
|
19376
|
+
nonCommentChildren++;
|
|
19377
|
+
if (isIfChild(child)) {
|
|
19378
|
+
if (hasEncounteredIf) isSingleIfBlock = false;
|
|
19379
|
+
hasEncounteredIf = true;
|
|
19380
|
+
} else if (!hasEncounteredIf || !isElseChild(child)) isSingleIfBlock = false;
|
|
19381
|
+
}
|
|
19382
|
+
return nonCommentChildren === 1 || isSingleIfBlock;
|
|
19383
|
+
}
|
|
19384
|
+
function isComponentChild(child) {
|
|
19385
|
+
return child.type === 1 && child.tagType === 1;
|
|
19386
|
+
}
|
|
19387
|
+
function isIfChild(child) {
|
|
19388
|
+
return child.type === 9 || child.type === 1 && !!findDir$1(child, "if");
|
|
19389
|
+
}
|
|
19390
|
+
function isElseChild(child) {
|
|
19391
|
+
return child.type === 1 && !!findDir$1(child, /^else(-if)?$/, true);
|
|
19392
|
+
}
|
|
19355
19393
|
const defaultOptions = {
|
|
19356
19394
|
filename: "",
|
|
19357
19395
|
prefixIdentifiers: true,
|
|
@@ -19828,28 +19866,31 @@ function canPrefix(name) {
|
|
|
19828
19866
|
}
|
|
19829
19867
|
function processExpressions(context, expressions, shouldDeclare) {
|
|
19830
19868
|
const expressionReplacements = /* @__PURE__ */ new Map();
|
|
19831
|
-
const { seenVariable, variableToExpMap,
|
|
19869
|
+
const { seenVariable, variableToExpMap, expressionRecords, seenIdentifier, updatedVariable } = analyzeExpressions(expressions);
|
|
19832
19870
|
const reservedNames = new Set(seenIdentifier);
|
|
19833
|
-
const varDeclarations = processRepeatedVariables(context, seenVariable, variableToExpMap,
|
|
19834
|
-
const expDeclarations = processRepeatedExpressions(context, expressions, varDeclarations, updatedVariable,
|
|
19871
|
+
const varDeclarations = processRepeatedVariables(context, seenVariable, variableToExpMap, expressionRecords, seenIdentifier, updatedVariable, reservedNames, expressionReplacements);
|
|
19872
|
+
const expDeclarations = processRepeatedExpressions(context, expressions, varDeclarations, updatedVariable, expressionRecords, reservedNames, expressionReplacements);
|
|
19835
19873
|
return _objectSpread2(_objectSpread2({}, genDeclarations([...varDeclarations, ...expDeclarations], context, shouldDeclare)), {}, { expressionReplacements });
|
|
19836
19874
|
}
|
|
19837
19875
|
function analyzeExpressions(expressions) {
|
|
19838
19876
|
const seenVariable = Object.create(null);
|
|
19839
19877
|
const variableToExpMap = /* @__PURE__ */ new Map();
|
|
19840
|
-
const
|
|
19878
|
+
const expressionRecords = /* @__PURE__ */ new Map();
|
|
19841
19879
|
const seenIdentifier = /* @__PURE__ */ new Set();
|
|
19842
19880
|
const updatedVariable = /* @__PURE__ */ new Set();
|
|
19881
|
+
const getRecord = (exp) => {
|
|
19882
|
+
let record = expressionRecords.get(exp);
|
|
19883
|
+
if (!record) expressionRecords.set(exp, record = { variables: [] });
|
|
19884
|
+
return record;
|
|
19885
|
+
};
|
|
19843
19886
|
const registerVariable = (name, exp, isIdentifier, loc, parentStack = []) => {
|
|
19844
19887
|
if (isIdentifier) seenIdentifier.add(name);
|
|
19845
19888
|
seenVariable[name] = (seenVariable[name] || 0) + 1;
|
|
19846
19889
|
variableToExpMap.set(name, (variableToExpMap.get(name) || /* @__PURE__ */ new Set()).add(exp));
|
|
19847
|
-
|
|
19848
|
-
variables.push({
|
|
19890
|
+
getRecord(exp).variables.push({
|
|
19849
19891
|
name,
|
|
19850
19892
|
loc
|
|
19851
19893
|
});
|
|
19852
|
-
expToVariableMap.set(exp, variables);
|
|
19853
19894
|
if (parentStack.some((p) => p.type === "UpdateExpression" || p.type === "AssignmentExpression")) updatedVariable.add(name);
|
|
19854
19895
|
};
|
|
19855
19896
|
for (const exp of expressions) {
|
|
@@ -19886,7 +19927,7 @@ function analyzeExpressions(expressions) {
|
|
|
19886
19927
|
seenVariable,
|
|
19887
19928
|
seenIdentifier,
|
|
19888
19929
|
variableToExpMap,
|
|
19889
|
-
|
|
19930
|
+
expressionRecords,
|
|
19890
19931
|
updatedVariable
|
|
19891
19932
|
};
|
|
19892
19933
|
}
|
|
@@ -19896,9 +19937,10 @@ function getProcessedExpression(exp, expressionReplacements) {
|
|
|
19896
19937
|
function setExpressionReplacement(expressionReplacements, exp, content, ast) {
|
|
19897
19938
|
expressionReplacements.set(exp, extend({ ast }, createSimpleExpression(content, exp.isStatic, exp.loc, exp.constType)));
|
|
19898
19939
|
}
|
|
19899
|
-
function processRepeatedVariables(context, seenVariable, variableToExpMap,
|
|
19940
|
+
function processRepeatedVariables(context, seenVariable, variableToExpMap, expressionRecords, seenIdentifier, updatedVariable, reservedNames, expressionReplacements) {
|
|
19900
19941
|
const declarations = [];
|
|
19901
|
-
const
|
|
19942
|
+
const declaredNames = /* @__PURE__ */ new Set();
|
|
19943
|
+
const replacementPlan = /* @__PURE__ */ new Map();
|
|
19902
19944
|
for (const [name, exps] of variableToExpMap) {
|
|
19903
19945
|
if (updatedVariable.has(name)) continue;
|
|
19904
19946
|
if (isGloballyAllowed(name)) continue;
|
|
@@ -19907,96 +19949,201 @@ function processRepeatedVariables(context, seenVariable, variableToExpMap, expTo
|
|
|
19907
19949
|
const varName = isIdentifier ? name : getUniqueDeclarationName(genVarName(name), reservedNames);
|
|
19908
19950
|
exps.forEach((node) => {
|
|
19909
19951
|
if (node.ast && varName !== name) {
|
|
19910
|
-
const
|
|
19911
|
-
|
|
19912
|
-
|
|
19913
|
-
|
|
19914
|
-
if (v.name === name && v.loc) locs.push(v.loc);
|
|
19915
|
-
return locs;
|
|
19916
|
-
}, [])
|
|
19952
|
+
for (const variable of getExpressionVariables(expressionRecords, node)) if (variable.name === name && variable.loc) queueContentReplacement(replacementPlan, node, {
|
|
19953
|
+
start: variable.loc.start - 1,
|
|
19954
|
+
end: variable.loc.end - 1,
|
|
19955
|
+
content: varName
|
|
19917
19956
|
});
|
|
19918
|
-
expToReplacementMap.set(node, replacements);
|
|
19919
19957
|
}
|
|
19920
19958
|
});
|
|
19921
|
-
if (!
|
|
19922
|
-
|
|
19923
|
-
|
|
19924
|
-
|
|
19925
|
-
|
|
19926
|
-
|
|
19927
|
-
|
|
19928
|
-
|
|
19959
|
+
if (!declaredNames.has(varName) && (!isIdentifier || shouldDeclareVariable(name, expressionRecords, exps))) {
|
|
19960
|
+
declaredNames.add(varName);
|
|
19961
|
+
declarations.push({
|
|
19962
|
+
name: varName,
|
|
19963
|
+
isIdentifier,
|
|
19964
|
+
value: extend({ ast: isIdentifier ? null : parseExp(context, name) }, createSimpleExpression(name)),
|
|
19965
|
+
rawName: name,
|
|
19966
|
+
exps,
|
|
19967
|
+
seenCount: seenVariable[name]
|
|
19968
|
+
});
|
|
19969
|
+
}
|
|
19929
19970
|
}
|
|
19930
19971
|
}
|
|
19931
|
-
|
|
19932
|
-
let content = getProcessedExpression(exp, expressionReplacements).content;
|
|
19933
|
-
replacements.flatMap(({ name, locs }) => locs.map(({ start, end }) => ({
|
|
19934
|
-
start,
|
|
19935
|
-
end,
|
|
19936
|
-
name
|
|
19937
|
-
}))).sort((a, b) => b.end - a.end).forEach(({ start, end, name }) => {
|
|
19938
|
-
content = content.slice(0, start - 1) + name + content.slice(end - 1);
|
|
19939
|
-
});
|
|
19940
|
-
setExpressionReplacement(expressionReplacements, exp, content, parseExp(context, content));
|
|
19941
|
-
}
|
|
19972
|
+
applyReplacementPlan(context, expressionReplacements, replacementPlan);
|
|
19942
19973
|
return declarations;
|
|
19943
19974
|
}
|
|
19944
|
-
function shouldDeclareVariable(name,
|
|
19945
|
-
const
|
|
19946
|
-
|
|
19947
|
-
|
|
19948
|
-
|
|
19949
|
-
|
|
19950
|
-
|
|
19975
|
+
function shouldDeclareVariable(name, expressionRecords, exps) {
|
|
19976
|
+
const variableUsages = [];
|
|
19977
|
+
let allSingleVariable = true;
|
|
19978
|
+
let hasRepeatedName = false;
|
|
19979
|
+
let hasDifferentLength = false;
|
|
19980
|
+
outer: for (const exp of exps) {
|
|
19981
|
+
const variables = getExpressionVariables(expressionRecords, exp);
|
|
19982
|
+
if (allSingleVariable && variables.length !== 1) allSingleVariable = false;
|
|
19983
|
+
if (!hasDifferentLength && variableUsages.length > 0 && variables.length !== variableUsages[0].length) hasDifferentLength = true;
|
|
19984
|
+
let nameCount = 0;
|
|
19985
|
+
for (const variable of variables) if (variable.name === name && ++nameCount > 1) {
|
|
19986
|
+
hasRepeatedName = true;
|
|
19987
|
+
break outer;
|
|
19988
|
+
}
|
|
19989
|
+
variableUsages.push(variables);
|
|
19990
|
+
}
|
|
19991
|
+
if (allSingleVariable) return true;
|
|
19992
|
+
if (hasRepeatedName) return true;
|
|
19993
|
+
const first = variableUsages[0];
|
|
19994
|
+
if (hasDifferentLength) {
|
|
19995
|
+
for (const variables of variableUsages) {
|
|
19996
|
+
if (variables.length === first.length) continue;
|
|
19997
|
+
const longer = variables.length > first.length ? variables : first;
|
|
19998
|
+
const shorter = variables.length > first.length ? first : variables;
|
|
19999
|
+
const shorterNames = /* @__PURE__ */ new Set();
|
|
20000
|
+
for (const variable of shorter) shorterNames.add(variable.name);
|
|
20001
|
+
let isSubset = true;
|
|
20002
|
+
for (const variable of longer) if (!shorterNames.has(variable.name)) {
|
|
20003
|
+
isSubset = false;
|
|
20004
|
+
break;
|
|
20005
|
+
}
|
|
20006
|
+
if (isSubset) return false;
|
|
20007
|
+
}
|
|
19951
20008
|
return true;
|
|
19952
20009
|
}
|
|
19953
|
-
|
|
19954
|
-
return
|
|
20010
|
+
for (const variables of variableUsages) for (let i = 0; i < variables.length; i++) if (variables[i].name !== first[i].name) return true;
|
|
20011
|
+
return false;
|
|
19955
20012
|
}
|
|
19956
|
-
function processRepeatedExpressions(context, expressions, varDeclarations, updatedVariable,
|
|
20013
|
+
function processRepeatedExpressions(context, expressions, varDeclarations, updatedVariable, expressionRecords, reservedNames, expressionReplacements) {
|
|
19957
20014
|
const declarations = [];
|
|
19958
|
-
const seenExp =
|
|
19959
|
-
|
|
19960
|
-
|
|
20015
|
+
const seenExp = /* @__PURE__ */ new Map();
|
|
20016
|
+
for (const exp of expressions) {
|
|
20017
|
+
var _expressionRecords$ge;
|
|
20018
|
+
const vars = (_expressionRecords$ge = expressionRecords.get(exp)) === null || _expressionRecords$ge === void 0 ? void 0 : _expressionRecords$ge.variables;
|
|
20019
|
+
if (!vars) continue;
|
|
19961
20020
|
const processed = getProcessedExpression(exp, expressionReplacements);
|
|
19962
|
-
|
|
19963
|
-
|
|
19964
|
-
|
|
19965
|
-
|
|
19966
|
-
|
|
19967
|
-
|
|
19968
|
-
const delVars = {};
|
|
19969
|
-
for (let i = varDeclarations.length - 1; i >= 0; i--) {
|
|
19970
|
-
const item = varDeclarations[i];
|
|
19971
|
-
if (!item.exps || !item.seenCount) continue;
|
|
19972
|
-
if ([...item.exps].every((node) => getProcessedExpression(node, expressionReplacements).content === content && item.seenCount === count)) {
|
|
19973
|
-
delVars[item.name] = item.rawName;
|
|
19974
|
-
reservedNames.delete(item.name);
|
|
19975
|
-
varDeclarations.splice(i, 1);
|
|
19976
|
-
}
|
|
19977
|
-
}
|
|
19978
|
-
const value = extend({}, getProcessedExpression(expressions.find((exp) => getProcessedExpression(exp, expressionReplacements).content === content), expressionReplacements));
|
|
19979
|
-
Object.keys(delVars).forEach((name) => {
|
|
19980
|
-
value.content = value.content.replace(name, delVars[name]);
|
|
19981
|
-
if (value.ast) value.ast = parseExp(context, value.content);
|
|
20021
|
+
if (canCacheExpression(processed, vars, updatedVariable)) {
|
|
20022
|
+
const seen = seenExp.get(processed.content);
|
|
20023
|
+
if (seen) seen.count++;
|
|
20024
|
+
else seenExp.set(processed.content, {
|
|
20025
|
+
count: 1,
|
|
20026
|
+
first: exp
|
|
19982
20027
|
});
|
|
19983
|
-
|
|
19984
|
-
|
|
19985
|
-
|
|
19986
|
-
|
|
19987
|
-
|
|
19988
|
-
|
|
19989
|
-
|
|
19990
|
-
|
|
19991
|
-
|
|
19992
|
-
|
|
20028
|
+
}
|
|
20029
|
+
}
|
|
20030
|
+
const repeatedExpressions = [...seenExp].sort(([contentA], [contentB]) => contentB.length - contentA.length);
|
|
20031
|
+
for (const [content, { count, first }] of repeatedExpressions) if (count > 1) {
|
|
20032
|
+
const removedDeclarations = [];
|
|
20033
|
+
for (let i = varDeclarations.length - 1; i >= 0; i--) {
|
|
20034
|
+
const item = varDeclarations[i];
|
|
20035
|
+
if (!item.exps || !item.seenCount) continue;
|
|
20036
|
+
if ([...item.exps].every((node) => getProcessedExpression(node, expressionReplacements).content === content && item.seenCount === count)) {
|
|
20037
|
+
removedDeclarations.push({
|
|
20038
|
+
name: item.name,
|
|
20039
|
+
rawName: item.rawName
|
|
20040
|
+
});
|
|
20041
|
+
reservedNames.delete(item.name);
|
|
20042
|
+
varDeclarations.splice(i, 1);
|
|
20043
|
+
}
|
|
20044
|
+
}
|
|
20045
|
+
const value = extend({}, getProcessedExpression(first, expressionReplacements));
|
|
20046
|
+
const restorePlan = [];
|
|
20047
|
+
for (const { name, rawName } of removedDeclarations) restorePlan.push(...findIdentifierReplacements(value, name, rawName));
|
|
20048
|
+
if (restorePlan.length) {
|
|
20049
|
+
value.content = applyContentReplacements(value.content, restorePlan);
|
|
20050
|
+
if (value.ast) value.ast = parseExp(context, value.content);
|
|
20051
|
+
}
|
|
20052
|
+
const varName = getUniqueDeclarationName(genVarName(content), reservedNames);
|
|
20053
|
+
declarations.push({
|
|
20054
|
+
name: varName,
|
|
20055
|
+
value
|
|
20056
|
+
});
|
|
20057
|
+
for (const exp of expressions) {
|
|
20058
|
+
const processed = getProcessedExpression(exp, expressionReplacements);
|
|
20059
|
+
if (processed.content === content) setExpressionReplacement(expressionReplacements, exp, varName, null);
|
|
20060
|
+
else if (processed.content.includes(content)) {
|
|
20061
|
+
const replacements = findContentReplacements(processed, content, varName);
|
|
20062
|
+
if (replacements.length) {
|
|
20063
|
+
const replacedContent = applyContentReplacements(processed.content, replacements);
|
|
19993
20064
|
setExpressionReplacement(expressionReplacements, exp, replacedContent, parseExp(context, replacedContent));
|
|
19994
20065
|
}
|
|
19995
|
-
}
|
|
20066
|
+
}
|
|
19996
20067
|
}
|
|
19997
|
-
}
|
|
20068
|
+
}
|
|
19998
20069
|
return declarations;
|
|
19999
20070
|
}
|
|
20071
|
+
function canCacheExpression(processed, vars, updatedVariable) {
|
|
20072
|
+
if (!processed.ast || processed.ast.type === "Identifier") return false;
|
|
20073
|
+
for (const { name } of vars) if (updatedVariable.has(name) || isGloballyAllowed(name)) return false;
|
|
20074
|
+
return true;
|
|
20075
|
+
}
|
|
20076
|
+
function getExpressionVariables(expressionRecords, exp) {
|
|
20077
|
+
var _expressionRecords$ge2;
|
|
20078
|
+
return ((_expressionRecords$ge2 = expressionRecords.get(exp)) === null || _expressionRecords$ge2 === void 0 ? void 0 : _expressionRecords$ge2.variables) || [];
|
|
20079
|
+
}
|
|
20080
|
+
function queueContentReplacement(replacementPlan, exp, replacement) {
|
|
20081
|
+
const replacements = replacementPlan.get(exp);
|
|
20082
|
+
if (replacements) replacements.push(replacement);
|
|
20083
|
+
else replacementPlan.set(exp, [replacement]);
|
|
20084
|
+
}
|
|
20085
|
+
function applyReplacementPlan(context, expressionReplacements, replacementPlan) {
|
|
20086
|
+
for (const [exp, replacements] of replacementPlan) {
|
|
20087
|
+
if (!replacements.length) continue;
|
|
20088
|
+
const content = applyContentReplacements(getProcessedExpression(exp, expressionReplacements).content, replacements);
|
|
20089
|
+
setExpressionReplacement(expressionReplacements, exp, content, parseExp(context, content));
|
|
20090
|
+
}
|
|
20091
|
+
}
|
|
20092
|
+
function findContentReplacements(exp, content, replacement) {
|
|
20093
|
+
const identifiers = getIdentifierRanges(exp);
|
|
20094
|
+
if (!identifiers.length) return [];
|
|
20095
|
+
const replacements = [];
|
|
20096
|
+
let searchStart = 0;
|
|
20097
|
+
let start = exp.content.indexOf(content, searchStart);
|
|
20098
|
+
while (start !== -1) {
|
|
20099
|
+
const end = start + content.length;
|
|
20100
|
+
let canReplace = false;
|
|
20101
|
+
for (const identifier of identifiers) {
|
|
20102
|
+
if (start >= identifier.end || end <= identifier.start) continue;
|
|
20103
|
+
if (start > identifier.start || end < identifier.end) {
|
|
20104
|
+
canReplace = false;
|
|
20105
|
+
break;
|
|
20106
|
+
}
|
|
20107
|
+
canReplace = true;
|
|
20108
|
+
}
|
|
20109
|
+
if (canReplace) {
|
|
20110
|
+
replacements.push({
|
|
20111
|
+
start,
|
|
20112
|
+
end,
|
|
20113
|
+
content: replacement
|
|
20114
|
+
});
|
|
20115
|
+
searchStart = end;
|
|
20116
|
+
} else searchStart = start + 1;
|
|
20117
|
+
start = exp.content.indexOf(content, searchStart);
|
|
20118
|
+
}
|
|
20119
|
+
return replacements;
|
|
20120
|
+
}
|
|
20121
|
+
function findIdentifierReplacements(exp, name, replacement) {
|
|
20122
|
+
const replacements = [];
|
|
20123
|
+
for (const { start, end } of getIdentifierRanges(exp)) if (exp.content.slice(start, end) === name) replacements.push({
|
|
20124
|
+
start,
|
|
20125
|
+
end,
|
|
20126
|
+
content: replacement
|
|
20127
|
+
});
|
|
20128
|
+
return replacements;
|
|
20129
|
+
}
|
|
20130
|
+
function getIdentifierRanges(exp) {
|
|
20131
|
+
if (!exp.ast || typeof exp.ast !== "object") return [];
|
|
20132
|
+
const identifiers = [];
|
|
20133
|
+
walkIdentifiers(exp.ast, (id) => {
|
|
20134
|
+
identifiers.push({
|
|
20135
|
+
start: id.start - 1,
|
|
20136
|
+
end: id.end - 1
|
|
20137
|
+
});
|
|
20138
|
+
}, false);
|
|
20139
|
+
return identifiers;
|
|
20140
|
+
}
|
|
20141
|
+
function applyContentReplacements(content, replacements) {
|
|
20142
|
+
replacements.sort((a, b) => b.start - a.start).forEach(({ start, end, content: replacement }) => {
|
|
20143
|
+
content = content.slice(0, start) + replacement + content.slice(end);
|
|
20144
|
+
});
|
|
20145
|
+
return content;
|
|
20146
|
+
}
|
|
20000
20147
|
function genDeclarations(declarations, context, shouldDeclare) {
|
|
20001
20148
|
const [frag, push] = buildCodeFragment();
|
|
20002
20149
|
const ids = Object.create(null);
|
|
@@ -20024,9 +20171,6 @@ function genDeclarations(declarations, context, shouldDeclare) {
|
|
|
20024
20171
|
varNames: [...varNames]
|
|
20025
20172
|
};
|
|
20026
20173
|
}
|
|
20027
|
-
function escapeRegExp(string) {
|
|
20028
|
-
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
20029
|
-
}
|
|
20030
20174
|
function parseExp(context, content) {
|
|
20031
20175
|
return (0, import_lib.parseExpression)(`(${content})`, getParserOptions(context.options.expressionPlugins));
|
|
20032
20176
|
}
|
|
@@ -20217,7 +20361,7 @@ function genFor(oper, context) {
|
|
|
20217
20361
|
idMap[rawIndex] = `${indexVar}.value`;
|
|
20218
20362
|
idMap[indexVar] = null;
|
|
20219
20363
|
}
|
|
20220
|
-
const { selectorPatterns, keyOnlyBindingPatterns } = matchPatterns(render, keyProp, idMap, context);
|
|
20364
|
+
const { selectorPatterns, keyOnlyBindingPatterns, skippedEffectIndexes } = matchPatterns(render, keyProp, idMap, context);
|
|
20221
20365
|
const selectorDeclarations = [];
|
|
20222
20366
|
const selectorName = (i) => selectorPatterns.length > 1 ? `_selector${id}_${i}` : `_selector${id}`;
|
|
20223
20367
|
for (let i = 0; i < selectorPatterns.length; i++) {
|
|
@@ -20237,26 +20381,20 @@ function genFor(oper, context) {
|
|
|
20237
20381
|
}
|
|
20238
20382
|
for (const { effect } of keyOnlyBindingPatterns) for (const oper of effect.operations) patternFrag.push(...genOperation(oper, context));
|
|
20239
20383
|
return patternFrag;
|
|
20240
|
-
}));
|
|
20384
|
+
}, skippedEffectIndexes));
|
|
20241
20385
|
else frag.push(...genBlockContent(render, context));
|
|
20242
20386
|
frag.push(INDENT_END, NEWLINE, "}");
|
|
20243
20387
|
return frag;
|
|
20244
20388
|
}, idMap);
|
|
20245
20389
|
exitScope();
|
|
20246
|
-
|
|
20247
|
-
if (onlyChild) flags |= 1;
|
|
20248
|
-
if (component) flags |= 2;
|
|
20249
|
-
if (isFragmentBlock(render)) flags |= 16;
|
|
20250
|
-
if (!component && isSingleNodeBlock(render)) flags |= 8;
|
|
20251
|
-
if (once) flags |= 4;
|
|
20252
|
-
if (slotRoot) flags |= 32;
|
|
20390
|
+
const flags = genForFlags(onlyChild, component, isFragmentBlock(render), !component && isSingleNodeBlock(render), once, slotRoot);
|
|
20253
20391
|
const onResetCalls = [];
|
|
20254
20392
|
for (let i = 0; i < selectorPatterns.length; i++) onResetCalls.push(NEWLINE, `n${id}.onReset(${selectorName(i)}.reset)`);
|
|
20255
20393
|
return [
|
|
20256
20394
|
NEWLINE,
|
|
20257
20395
|
...selectorDeclarations,
|
|
20258
20396
|
`const n${id} = `,
|
|
20259
|
-
...genCall([helper("createFor"), "undefined"], sourceExpr, blockFn, genCallback(keyProp), flags
|
|
20397
|
+
...genCall([helper("createFor"), "undefined"], sourceExpr, blockFn, genCallback(keyProp), flags),
|
|
20260
20398
|
...onResetCalls
|
|
20261
20399
|
];
|
|
20262
20400
|
function genCallback(expr) {
|
|
@@ -20281,6 +20419,36 @@ function genFor(oper, context) {
|
|
|
20281
20419
|
return idMap;
|
|
20282
20420
|
}
|
|
20283
20421
|
}
|
|
20422
|
+
function genForFlags(onlyChild, component, isFragment, isSingleNode, once, slotRoot) {
|
|
20423
|
+
let flags = 0;
|
|
20424
|
+
const names = [];
|
|
20425
|
+
if (onlyChild) {
|
|
20426
|
+
flags |= 1;
|
|
20427
|
+
names.push("FAST_REMOVE");
|
|
20428
|
+
}
|
|
20429
|
+
if (component) {
|
|
20430
|
+
flags |= 2;
|
|
20431
|
+
names.push("IS_COMPONENT");
|
|
20432
|
+
}
|
|
20433
|
+
if (isFragment) {
|
|
20434
|
+
flags |= 16;
|
|
20435
|
+
names.push("IS_FRAGMENT");
|
|
20436
|
+
}
|
|
20437
|
+
if (isSingleNode) {
|
|
20438
|
+
flags |= 8;
|
|
20439
|
+
names.push("IS_SINGLE_NODE");
|
|
20440
|
+
}
|
|
20441
|
+
if (once) {
|
|
20442
|
+
flags |= 4;
|
|
20443
|
+
names.push("ONCE");
|
|
20444
|
+
}
|
|
20445
|
+
if (slotRoot) {
|
|
20446
|
+
flags |= 32;
|
|
20447
|
+
names.push("SLOT_ROOT");
|
|
20448
|
+
}
|
|
20449
|
+
if (!flags) return;
|
|
20450
|
+
return `${flags} /* ${names.join(", ")} */`;
|
|
20451
|
+
}
|
|
20284
20452
|
function isSingleNodeBlock(block) {
|
|
20285
20453
|
const child = getSingleReturnedChild(block);
|
|
20286
20454
|
return !!child && child.template != null;
|
|
@@ -20367,39 +20535,35 @@ function buildDestructureIdMap(idToPathMap, baseAccessor, plugins) {
|
|
|
20367
20535
|
function matchPatterns(render, keyProp, idMap, context) {
|
|
20368
20536
|
const selectorPatterns = [];
|
|
20369
20537
|
const keyOnlyBindingPatterns = [];
|
|
20370
|
-
|
|
20371
|
-
|
|
20372
|
-
|
|
20373
|
-
|
|
20374
|
-
|
|
20375
|
-
|
|
20376
|
-
|
|
20377
|
-
|
|
20378
|
-
|
|
20379
|
-
|
|
20380
|
-
|
|
20381
|
-
|
|
20382
|
-
|
|
20383
|
-
return false;
|
|
20384
|
-
}
|
|
20538
|
+
let skippedEffectIndexes;
|
|
20539
|
+
if (keyProp === void 0) return {
|
|
20540
|
+
keyOnlyBindingPatterns,
|
|
20541
|
+
selectorPatterns,
|
|
20542
|
+
skippedEffectIndexes
|
|
20543
|
+
};
|
|
20544
|
+
for (let index = 0; index < render.effect.length; index++) {
|
|
20545
|
+
const effect = render.effect[index];
|
|
20546
|
+
const selector = matchSelectorPattern(effect, keyProp.content, idMap, context);
|
|
20547
|
+
if (selector) {
|
|
20548
|
+
selectorPatterns.push(selector);
|
|
20549
|
+
skipEffect(index);
|
|
20550
|
+
continue;
|
|
20385
20551
|
}
|
|
20386
|
-
|
|
20387
|
-
|
|
20388
|
-
|
|
20552
|
+
const keyOnly = matchKeyOnlyBindingPattern(effect, keyProp.content);
|
|
20553
|
+
if (keyOnly) {
|
|
20554
|
+
keyOnlyBindingPatterns.push(keyOnly);
|
|
20555
|
+
skipEffect(index);
|
|
20556
|
+
}
|
|
20557
|
+
}
|
|
20389
20558
|
return {
|
|
20390
20559
|
keyOnlyBindingPatterns,
|
|
20391
|
-
selectorPatterns
|
|
20560
|
+
selectorPatterns,
|
|
20561
|
+
skippedEffectIndexes
|
|
20392
20562
|
};
|
|
20393
|
-
|
|
20394
|
-
|
|
20395
|
-
|
|
20396
|
-
if (operation && isBlockOperation(operation) && operation.effectIndex !== void 0) {
|
|
20397
|
-
let offset = 0;
|
|
20398
|
-
for (const removedIndex of removedEffectIndexes) if (removedIndex < operation.effectIndex) offset++;
|
|
20399
|
-
else break;
|
|
20400
|
-
operation.effectIndex -= offset;
|
|
20563
|
+
function skipEffect(index) {
|
|
20564
|
+
if (!skippedEffectIndexes) skippedEffectIndexes = /* @__PURE__ */ new Set();
|
|
20565
|
+
skippedEffectIndexes.add(index);
|
|
20401
20566
|
}
|
|
20402
|
-
for (const child of dynamic.children) shiftEffectBoundaries(child, removedEffectIndexes);
|
|
20403
20567
|
}
|
|
20404
20568
|
function matchKeyOnlyBindingPattern(effect, key) {
|
|
20405
20569
|
if (effect.expressions.length === 1) {
|
|
@@ -20504,14 +20668,25 @@ function genIfFlags(blockShape, once, slotRoot, index) {
|
|
|
20504
20668
|
return `${flags} /* ${genIfFlagNames(once, slotRoot, index, blockShape)} */`;
|
|
20505
20669
|
}
|
|
20506
20670
|
function genIfFlagNames(once, slotRoot, index, blockShape) {
|
|
20507
|
-
const names = [
|
|
20671
|
+
const names = [`TRUE_${genBlockShapeName(blockShape)}`];
|
|
20672
|
+
const falseShape = blockShape >> 2;
|
|
20673
|
+
const hasFalseBranch = (falseShape & 3) !== 0;
|
|
20674
|
+
if (hasFalseBranch) names.push(`FALSE_${genBlockShapeName(falseShape)}`);
|
|
20508
20675
|
if (blockShape & 32) names.push("TRUE_NO_SCOPE");
|
|
20509
|
-
if (blockShape & 64) names.push("FALSE_NO_SCOPE");
|
|
20676
|
+
if (hasFalseBranch && blockShape & 64) names.push("FALSE_NO_SCOPE");
|
|
20510
20677
|
if (once) names.push("ONCE");
|
|
20511
20678
|
if (slotRoot) names.push("SLOT_ROOT");
|
|
20512
|
-
if (!once && index !== void 0) names.push(
|
|
20679
|
+
if (!once && index !== void 0) names.push(`KEYED_INDEX_${index}`);
|
|
20513
20680
|
return names.join(", ");
|
|
20514
20681
|
}
|
|
20682
|
+
function genBlockShapeName(flags) {
|
|
20683
|
+
switch (flags & 3) {
|
|
20684
|
+
case 0: return "EMPTY";
|
|
20685
|
+
case 1: return "SINGLE_ROOT";
|
|
20686
|
+
case 2: return "MULTI_ROOT";
|
|
20687
|
+
}
|
|
20688
|
+
return "UNKNOWN";
|
|
20689
|
+
}
|
|
20515
20690
|
//#endregion
|
|
20516
20691
|
//#region packages/compiler-vapor/src/generators/prop.ts
|
|
20517
20692
|
const helpers = {
|
|
@@ -20868,7 +21043,7 @@ function genCreateComponent(operation, context) {
|
|
|
20868
21043
|
const tag = genTag();
|
|
20869
21044
|
const { root, props, slots, once, slotRoot } = operation;
|
|
20870
21045
|
const isRuntimeDynamicComponent = !!(operation.dynamic && !operation.dynamic.isStatic);
|
|
20871
|
-
const dynamicComponentFlags = isRuntimeDynamicComponent ? (root
|
|
21046
|
+
const dynamicComponentFlags = isRuntimeDynamicComponent ? genDynamicComponentFlags(root, once, slotRoot) : false;
|
|
20872
21047
|
const rawSlots = genRawSlots(slots, context);
|
|
20873
21048
|
const [ids, handlers] = processInlineHandlers(props, context);
|
|
20874
21049
|
const rawProps = context.withId(() => genRawProps(props, context, true), ids);
|
|
@@ -20884,7 +21059,7 @@ function genCreateComponent(operation, context) {
|
|
|
20884
21059
|
];
|
|
20885
21060
|
}, []),
|
|
20886
21061
|
`const n${operation.id} = `,
|
|
20887
|
-
...genCall(isRuntimeDynamicComponent ? helper("createDynamicComponent") : operation.useCreateElement ? helper("createPlainElement") : useAssetComponentHelper ? helper("createAssetComponent") : operation.asset ? helper("createComponentWithFallback") : helper("createComponent"), tag, rawProps, rawSlots, isRuntimeDynamicComponent ? dynamicComponentFlags
|
|
21062
|
+
...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"),
|
|
20888
21063
|
...genDirectivesForElement(operation.id, context)
|
|
20889
21064
|
];
|
|
20890
21065
|
function genTag() {
|
|
@@ -20910,6 +21085,24 @@ function genCreateComponent(operation, context) {
|
|
|
20910
21085
|
}
|
|
20911
21086
|
}
|
|
20912
21087
|
}
|
|
21088
|
+
function genDynamicComponentFlags(root, once, slotRoot) {
|
|
21089
|
+
let flags = 0;
|
|
21090
|
+
const names = [];
|
|
21091
|
+
if (root) {
|
|
21092
|
+
flags |= 1;
|
|
21093
|
+
names.push("SINGLE_ROOT");
|
|
21094
|
+
}
|
|
21095
|
+
if (once) {
|
|
21096
|
+
flags |= 2;
|
|
21097
|
+
names.push("ONCE");
|
|
21098
|
+
}
|
|
21099
|
+
if (slotRoot) {
|
|
21100
|
+
flags |= 4;
|
|
21101
|
+
names.push("SLOT_ROOT");
|
|
21102
|
+
}
|
|
21103
|
+
if (!flags) return false;
|
|
21104
|
+
return `${flags} /* ${names.join(", ")} */`;
|
|
21105
|
+
}
|
|
20913
21106
|
function getUniqueHandlerName(context, name) {
|
|
20914
21107
|
const { seenInlineHandlerNames } = context;
|
|
20915
21108
|
name = genVarName(name);
|
|
@@ -21220,13 +21413,22 @@ function genSlotBlockWithProps(oper, context, emitNonStableFlag = true) {
|
|
|
21220
21413
|
const idMap = idToPathMap.size ? buildDestructureIdMap(idToPathMap, propsName || "", context.options.expressionPlugins) : {};
|
|
21221
21414
|
if (propsName) idMap[propsName] = null;
|
|
21222
21415
|
const exitSlotBlock = context.enterSlotBlock();
|
|
21223
|
-
|
|
21416
|
+
const hasStableRoot = hasStableSlotRoot(oper, context);
|
|
21417
|
+
if (!hasStableRoot) markSlotRootOperations(oper);
|
|
21224
21418
|
let blockFn = context.withId(() => genBlock(oper, context, propsName ? [propsName] : []), idMap);
|
|
21225
|
-
if (emitNonStableFlag && !
|
|
21419
|
+
if (emitNonStableFlag && !hasStableRoot) blockFn = genCall(context.helper("extend"), blockFn, [`{ _: ${genSlotFlags$1(8)} }`]);
|
|
21226
21420
|
exitSlotBlock();
|
|
21227
21421
|
exitScope && exitScope();
|
|
21228
21422
|
return blockFn;
|
|
21229
21423
|
}
|
|
21424
|
+
function genSlotFlags$1(flags) {
|
|
21425
|
+
const names = [];
|
|
21426
|
+
if (flags & 1) names.push("NO_SLOTTED");
|
|
21427
|
+
if (flags & 2) names.push("ONCE");
|
|
21428
|
+
if (flags & 4) names.push("SLOT_ROOT");
|
|
21429
|
+
if (flags & 8) names.push("NON_STABLE");
|
|
21430
|
+
return `${flags} /* ${names.join(", ")} */`;
|
|
21431
|
+
}
|
|
21230
21432
|
const commentOnlyTemplateRE = /^(?:<!--[\s\S]*?-->)+$/;
|
|
21231
21433
|
function hasStableSlotRoot(block, context) {
|
|
21232
21434
|
let hasValidRoot = false;
|
|
@@ -21244,14 +21446,14 @@ function hasStableSlotRoot(block, context) {
|
|
|
21244
21446
|
hasValidRoot = true;
|
|
21245
21447
|
continue;
|
|
21246
21448
|
}
|
|
21247
|
-
|
|
21449
|
+
continue;
|
|
21248
21450
|
case 17:
|
|
21249
21451
|
if (hasStableSlotRoot(operation.block, context)) {
|
|
21250
21452
|
hasValidRoot = true;
|
|
21251
21453
|
continue;
|
|
21252
21454
|
}
|
|
21253
|
-
|
|
21254
|
-
default:
|
|
21455
|
+
continue;
|
|
21456
|
+
default: continue;
|
|
21255
21457
|
}
|
|
21256
21458
|
}
|
|
21257
21459
|
return hasValidRoot;
|
|
@@ -21269,7 +21471,7 @@ function genSlotOutlet(oper, context) {
|
|
|
21269
21471
|
const [frag, push] = buildCodeFragment();
|
|
21270
21472
|
let fallbackArg;
|
|
21271
21473
|
if (fallback) {
|
|
21272
|
-
markSlotRootOperations(fallback);
|
|
21474
|
+
if (context.inSlotBlock) markSlotRootOperations(fallback);
|
|
21273
21475
|
fallbackArg = genBlock(fallback, context);
|
|
21274
21476
|
}
|
|
21275
21477
|
const createSlot = helper("createSlot");
|
|
@@ -21279,9 +21481,17 @@ function genSlotOutlet(oper, context) {
|
|
|
21279
21481
|
...genExpression(name, context),
|
|
21280
21482
|
")"
|
|
21281
21483
|
];
|
|
21282
|
-
push(NEWLINE, `const n${id} = `, ...genCall(createSlot, nameArg, rawPropsArg, fallbackArg,
|
|
21484
|
+
push(NEWLINE, `const n${id} = `, ...genCall(createSlot, nameArg, rawPropsArg, fallbackArg, genSlotFlags(flags)));
|
|
21283
21485
|
return frag;
|
|
21284
21486
|
}
|
|
21487
|
+
function genSlotFlags(flags) {
|
|
21488
|
+
if (!flags) return;
|
|
21489
|
+
const names = [];
|
|
21490
|
+
if (flags & 1) names.push("NO_SLOTTED");
|
|
21491
|
+
if (flags & 2) names.push("ONCE");
|
|
21492
|
+
if (flags & 4) names.push("SLOT_ROOT");
|
|
21493
|
+
return `${flags} /* ${names.join(", ")} */`;
|
|
21494
|
+
}
|
|
21285
21495
|
//#endregion
|
|
21286
21496
|
//#region packages/compiler-vapor/src/generators/key.ts
|
|
21287
21497
|
function genKey(oper, context) {
|
|
@@ -21554,7 +21764,7 @@ function genBlock(oper, context, args = [], root) {
|
|
|
21554
21764
|
"}"
|
|
21555
21765
|
];
|
|
21556
21766
|
}
|
|
21557
|
-
function genBlockContent(block, context, root, genEffectsExtraFrag) {
|
|
21767
|
+
function genBlockContent(block, context, root, genEffectsExtraFrag, skippedEffectIndexes) {
|
|
21558
21768
|
const [frag, push] = buildCodeFragment();
|
|
21559
21769
|
const { dynamic, effect, operation, returns } = block;
|
|
21560
21770
|
const resetBlock = context.enterBlock(block);
|
|
@@ -21579,7 +21789,7 @@ function genBlockContent(block, context, root, genEffectsExtraFrag) {
|
|
|
21579
21789
|
operationIndex++;
|
|
21580
21790
|
}
|
|
21581
21791
|
if (effectIndex < effectEnd) {
|
|
21582
|
-
push(...
|
|
21792
|
+
push(...genEffectRange(effectIndex, effectEnd));
|
|
21583
21793
|
effectIndex = effectEnd;
|
|
21584
21794
|
}
|
|
21585
21795
|
};
|
|
@@ -21593,7 +21803,7 @@ function genBlockContent(block, context, root, genEffectsExtraFrag) {
|
|
|
21593
21803
|
}
|
|
21594
21804
|
for (const child of dynamic.children) if (!child.hasDynamicChild) push(...genChildren(child, context, push, `n${child.id}`, flushBeforeDynamic));
|
|
21595
21805
|
if (operationIndex < operation.length) push(...genOperations(operation.slice(operationIndex), context));
|
|
21596
|
-
if (effectIndex < effect.length) push(...
|
|
21806
|
+
if (effectIndex < effect.length) push(...genEffectRange(effectIndex, effect.length, genEffectsExtraFrag));
|
|
21597
21807
|
else if (genEffectsExtraFrag) push(...genEffects([], context, genEffectsExtraFrag));
|
|
21598
21808
|
push(NEWLINE, `return `);
|
|
21599
21809
|
const returnNodes = returns.map((n) => `n${n}`);
|
|
@@ -21601,6 +21811,13 @@ function genBlockContent(block, context, root, genEffectsExtraFrag) {
|
|
|
21601
21811
|
resetBlock();
|
|
21602
21812
|
context.singleUseAssetComponentNames = prevSingleUseAssetComponentNames;
|
|
21603
21813
|
return frag;
|
|
21814
|
+
function genEffectRange(start, end, genExtraFrag) {
|
|
21815
|
+
if (!skippedEffectIndexes) return genEffects(effect.slice(start, end), context, genExtraFrag);
|
|
21816
|
+
const effects = [];
|
|
21817
|
+
for (let i = start; i < end; i++) if (!skippedEffectIndexes.has(i)) effects.push(effect[i]);
|
|
21818
|
+
if (effects.length || genExtraFrag) return genEffects(effects, context, genExtraFrag);
|
|
21819
|
+
return [];
|
|
21820
|
+
}
|
|
21604
21821
|
function genResolveAssets(kind, helper) {
|
|
21605
21822
|
for (const name of context.ir[kind]) push(NEWLINE, `const ${toValidAssetId(name, kind)} = `, ...genCall(context.helper(helper), JSON.stringify(name)));
|
|
21606
21823
|
}
|
|
@@ -21612,7 +21829,6 @@ function markSlotRootOperations(block) {
|
|
|
21612
21829
|
if (!operation) continue;
|
|
21613
21830
|
if (operation.type === 15) markSlotRootIf(operation);
|
|
21614
21831
|
else if (operation.type === 16) markSlotRootFor(operation);
|
|
21615
|
-
else if (operation.type === 13) markSlotRootSlotOutlet(operation);
|
|
21616
21832
|
else if (operation.type === 12) markSlotRootComponent(operation);
|
|
21617
21833
|
}
|
|
21618
21834
|
}
|
|
@@ -21628,10 +21844,6 @@ function markSlotRootFor(operation) {
|
|
|
21628
21844
|
if (!operation.once) operation.slotRoot = true;
|
|
21629
21845
|
markSlotRootOperations(operation.render);
|
|
21630
21846
|
}
|
|
21631
|
-
function markSlotRootSlotOutlet(operation) {
|
|
21632
|
-
operation.flags |= 4;
|
|
21633
|
-
if (operation.fallback) markSlotRootOperations(operation.fallback);
|
|
21634
|
-
}
|
|
21635
21847
|
function markSlotRootComponent(operation) {
|
|
21636
21848
|
if (!operation.once && operation.dynamic && !operation.dynamic.isStatic) operation.slotRoot = true;
|
|
21637
21849
|
}
|
|
@@ -21979,7 +22191,7 @@ const transformElement = (node, context) => {
|
|
|
21979
22191
|
const isDynamicComponent = isComponentTag(node.tag);
|
|
21980
22192
|
const staticKey = resolveStaticKey(node, context, isComponent);
|
|
21981
22193
|
const propsResult = buildProps(node, context, isComponent, isDynamicComponent, getEffectIndex);
|
|
21982
|
-
const singleRoot = isSingleRoot
|
|
22194
|
+
const singleRoot = context.isSingleRoot;
|
|
21983
22195
|
if (isComponent) transformComponentElement(node, propsResult, staticKey, singleRoot, context, isDynamicComponent, useCreateElement);
|
|
21984
22196
|
else transformNativeElement(node, propsResult, staticKey, singleRoot, context, getEffectIndex, context.root === context.effectiveParent || canOmitEndTag(node, context));
|
|
21985
22197
|
if (parentSlots) context.slots = parentSlots;
|
|
@@ -22018,16 +22230,6 @@ function isInSameTemplateAsParent(context) {
|
|
|
22018
22230
|
if (parentNode.type !== 1 || parentNode.tagType !== 0) return false;
|
|
22019
22231
|
return !shouldUseCreateElement(parentNode, parent) && isValidHTMLNesting(parentNode.tag, node.tag);
|
|
22020
22232
|
}
|
|
22021
|
-
function isSingleRoot(context) {
|
|
22022
|
-
if (context.inVFor) return false;
|
|
22023
|
-
let { parent } = context;
|
|
22024
|
-
if (parent && !(hasSingleChild(parent.node) || isSingleIfBlock(parent.node))) return false;
|
|
22025
|
-
while (parent && parent.parent && parent.node.type === 1 && parent.node.tagType === 3) {
|
|
22026
|
-
parent = parent.parent;
|
|
22027
|
-
if (!(hasSingleChild(parent.node) || isSingleIfBlock(parent.node))) return false;
|
|
22028
|
-
}
|
|
22029
|
-
return context.root === parent;
|
|
22030
|
-
}
|
|
22031
22233
|
function transformComponentElement(node, propsResult, staticKey, singleRoot, context, isDynamicComponent, useCreateElement) {
|
|
22032
22234
|
const dynamicComponent = isDynamicComponent ? resolveDynamicComponent(node) : void 0;
|
|
22033
22235
|
let { tag } = node;
|
|
@@ -22692,13 +22894,7 @@ const transformText = (node, context) => {
|
|
|
22692
22894
|
};
|
|
22693
22895
|
function processInterpolation(context) {
|
|
22694
22896
|
const parentNode = context.parent.node;
|
|
22695
|
-
const
|
|
22696
|
-
const nexts = children.slice(context.index);
|
|
22697
|
-
const idx = nexts.findIndex((n) => !isTextLike(n));
|
|
22698
|
-
const nodes = idx > -1 ? nexts.slice(0, idx) : nexts;
|
|
22699
|
-
const prev = children[context.index - 1];
|
|
22700
|
-
if (prev && prev.type === 2) nodes.unshift(prev);
|
|
22701
|
-
const values = processTextLikeChildren(nodes, context);
|
|
22897
|
+
const values = processTextLikeChildren(collectAdjacentText(context), context);
|
|
22702
22898
|
if (values.length === 0 && parentNode.type !== 0) return;
|
|
22703
22899
|
const literalValues = values.map((v) => getLiteralExpressionValue(v));
|
|
22704
22900
|
if (literalValues.every((v) => v != null) && parentNode.type !== 0) {
|
|
@@ -22720,6 +22916,18 @@ function processInterpolation(context) {
|
|
|
22720
22916
|
values
|
|
22721
22917
|
});
|
|
22722
22918
|
}
|
|
22919
|
+
function collectAdjacentText(context) {
|
|
22920
|
+
const children = context.parent.node.children;
|
|
22921
|
+
const nodes = [];
|
|
22922
|
+
const prev = children[context.index - 1];
|
|
22923
|
+
let index = prev && prev.type === 2 ? context.index - 1 : context.index;
|
|
22924
|
+
for (; index < children.length; index++) {
|
|
22925
|
+
const child = children[index];
|
|
22926
|
+
if (!isTextLike(child)) break;
|
|
22927
|
+
nodes.push(child);
|
|
22928
|
+
}
|
|
22929
|
+
return nodes;
|
|
22930
|
+
}
|
|
22723
22931
|
function processTextContainer(children, context) {
|
|
22724
22932
|
const values = processTextLikeChildren(children, context);
|
|
22725
22933
|
const literals = values.map((value) => getLiteralExpressionValue(value));
|