@vue/compiler-sfc 3.6.0-rc.2 → 3.6.0-rc.4
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 +152 -85
- package/dist/compiler-sfc.d.ts +412 -291
- package/dist/compiler-sfc.esm-browser.js +381 -241
- package/package.json +10 -10
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-sfc v3.6.0-rc.
|
|
2
|
+
* @vue/compiler-sfc v3.6.0-rc.4
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -388,7 +388,7 @@ const isBlockTag = /* @__PURE__ */ makeMap(BLOCK_TAGS);
|
|
|
388
388
|
/**
|
|
389
389
|
* The full list is needed during SSR to produce the correct initial markup.
|
|
390
390
|
*/
|
|
391
|
-
const isBooleanAttr = /* @__PURE__ */ makeMap("itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly,async,autofocus,autoplay,controls,default,defer,disabled,
|
|
391
|
+
const isBooleanAttr = /* @__PURE__ */ makeMap("itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly,async,autofocus,autoplay,controls,default,defer,disabled,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected");
|
|
392
392
|
/**
|
|
393
393
|
* Boolean attributes should be included if the value is truthy or ''.
|
|
394
394
|
* e.g. `<select multiple>` compiles to `{ multiple: '' }`
|
|
@@ -3607,7 +3607,7 @@ const errorMessages$1 = {
|
|
|
3607
3607
|
[54]: ``
|
|
3608
3608
|
};
|
|
3609
3609
|
//#endregion
|
|
3610
|
-
//#region node_modules/.pnpm/@babel+parser@7.29.
|
|
3610
|
+
//#region node_modules/.pnpm/@babel+parser@7.29.8/node_modules/@babel/parser/lib/index.js
|
|
3611
3611
|
var require_lib$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3612
3612
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3613
3613
|
function _objectWithoutPropertiesLoose(r, e) {
|
|
@@ -3794,6 +3794,7 @@ var require_lib$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3794
3794
|
SloppyFunctionAnnexB: "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement.",
|
|
3795
3795
|
SourcePhaseImportRequiresDefault: "Only `import source x from \"./module\"` is valid.",
|
|
3796
3796
|
StaticPrototype: "Classes may not have static property named prototype.",
|
|
3797
|
+
SuperCallNotNewExpression: "Cannot use new with super(...).",
|
|
3797
3798
|
SuperNotAllowed: "`super()` is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?",
|
|
3798
3799
|
SuperPrivateField: "Private fields can't be accessed on super.",
|
|
3799
3800
|
TrailingDecorator: "Decorators must be attached to a class element.",
|
|
@@ -3816,7 +3817,6 @@ var require_lib$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3816
3817
|
UnexpectedTokenUnaryExponentiation: "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.",
|
|
3817
3818
|
UnexpectedUsingDeclaration: "Using declaration cannot appear in the top level when source type is `script` or in the bare case statement.",
|
|
3818
3819
|
UnexpectedVoidPattern: "Unexpected void binding.",
|
|
3819
|
-
UnsupportedBind: "Binding should be performed on object property.",
|
|
3820
3820
|
UnsupportedDecoratorExport: "A decorated export must export a class declaration.",
|
|
3821
3821
|
UnsupportedDefaultExport: "Only expressions, functions or classes are allowed as the `default` export.",
|
|
3822
3822
|
UnsupportedImport: "`import` can only be used in `import()` or `import.meta`.",
|
|
@@ -3872,6 +3872,10 @@ var require_lib$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3872
3872
|
PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding.",
|
|
3873
3873
|
PrimaryTopicRequiresSmartPipeline: "Topic reference is used, but the pipelineOperator plugin was not passed a \"proposal\": \"hack\" or \"smart\" option."
|
|
3874
3874
|
});
|
|
3875
|
+
var FunctionBindErrors = {
|
|
3876
|
+
UnsupportedBind: "Binding should be performed on object property.",
|
|
3877
|
+
UnsupportedBindRHS: "The right-hand side of binding can not be super or import."
|
|
3878
|
+
};
|
|
3875
3879
|
const _excluded = ["message"];
|
|
3876
3880
|
function defineHidden(obj, key, value) {
|
|
3877
3881
|
Object.defineProperty(obj, key, {
|
|
@@ -3936,7 +3940,7 @@ var require_lib$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3936
3940
|
}
|
|
3937
3941
|
return ParseErrorConstructors;
|
|
3938
3942
|
}
|
|
3939
|
-
const Errors = Object.assign({}, ParseErrorEnum(ModuleErrors), ParseErrorEnum(StandardErrors), ParseErrorEnum(StrictModeErrors), ParseErrorEnum(ParseExpressionErrors), ParseErrorEnum`pipelineOperator`(PipelineOperatorErrors));
|
|
3943
|
+
const Errors = Object.assign({}, ParseErrorEnum(ModuleErrors), ParseErrorEnum(StandardErrors), ParseErrorEnum(StrictModeErrors), ParseErrorEnum(ParseExpressionErrors), ParseErrorEnum`pipelineOperator`(PipelineOperatorErrors), ParseErrorEnum`functionBind`(FunctionBindErrors));
|
|
3940
3944
|
function createDefaultOptions() {
|
|
3941
3945
|
return {
|
|
3942
3946
|
sourceType: "script",
|
|
@@ -13511,7 +13515,7 @@ var require_lib$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
13511
13515
|
}
|
|
13512
13516
|
parseSubscript(base, startLoc, noCalls, state) {
|
|
13513
13517
|
const { type } = this.state;
|
|
13514
|
-
if (!noCalls && type === 15) return this.parseBind(base, startLoc,
|
|
13518
|
+
if (!noCalls && type === 15) return this.parseBind(base, startLoc, state);
|
|
13515
13519
|
else if (tokenIsTemplate(type)) return this.parseTaggedTemplateExpression(base, startLoc, state);
|
|
13516
13520
|
let optional = false;
|
|
13517
13521
|
if (type === 18) {
|
|
@@ -13550,13 +13554,16 @@ var require_lib$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
13550
13554
|
return this.finishNode(node, "OptionalMemberExpression");
|
|
13551
13555
|
} else return this.finishNode(node, "MemberExpression");
|
|
13552
13556
|
}
|
|
13553
|
-
parseBind(base, startLoc,
|
|
13557
|
+
parseBind(base, startLoc, state) {
|
|
13554
13558
|
const node = this.startNodeAt(startLoc);
|
|
13555
13559
|
node.object = base;
|
|
13556
13560
|
this.next();
|
|
13557
|
-
|
|
13561
|
+
const isImport = this.match(83);
|
|
13562
|
+
const callee = this.parseNoCallExpr();
|
|
13563
|
+
if (callee.type === "Super" || isImport && callee.type === "ImportExpression" || callee.type === "Import") throw this.raise(Errors.UnsupportedBindRHS, callee);
|
|
13564
|
+
node.callee = callee;
|
|
13558
13565
|
state.stop = true;
|
|
13559
|
-
return this.parseSubscripts(this.finishNode(node, "BindExpression"), startLoc,
|
|
13566
|
+
return this.parseSubscripts(this.finishNode(node, "BindExpression"), startLoc, false);
|
|
13560
13567
|
}
|
|
13561
13568
|
parseCoverCallAndAsyncArrowHead(base, startLoc, state, optional) {
|
|
13562
13569
|
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
|
@@ -14013,7 +14020,8 @@ var require_lib$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
14013
14020
|
const isImport = this.match(83);
|
|
14014
14021
|
const callee = this.parseNoCallExpr();
|
|
14015
14022
|
node.callee = callee;
|
|
14016
|
-
if (isImport &&
|
|
14023
|
+
if (isImport && callee.type === "ImportExpression" || callee.type === "Import") this.raise(Errors.ImportCallNotNewExpression, callee);
|
|
14024
|
+
if (callee.type === "Super") this.raise(Errors.SuperCallNotNewExpression, callee);
|
|
14017
14025
|
}
|
|
14018
14026
|
parseTemplateElement(isTagged) {
|
|
14019
14027
|
const { start, startLoc, end, value } = this.state;
|
|
@@ -20818,15 +20826,22 @@ const transformFor = createStructuralDirectiveTransform$1("for", (node, dir, con
|
|
|
20818
20826
|
else {
|
|
20819
20827
|
childBlock = children[0].codegenNode;
|
|
20820
20828
|
if (isTemplate && keyProperty) injectProp(childBlock, keyProperty, context);
|
|
20821
|
-
|
|
20829
|
+
const shouldUseBlock = !isStableFragment || childBlock.isBlockRequired === true;
|
|
20830
|
+
if (childBlock.isBlock !== shouldUseBlock) if (childBlock.isBlock) {
|
|
20822
20831
|
removeHelper(OPEN_BLOCK);
|
|
20823
20832
|
removeHelper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
|
|
20824
20833
|
} else removeHelper(getVNodeHelper(context.inSSR, childBlock.isComponent));
|
|
20825
|
-
childBlock.isBlock =
|
|
20834
|
+
childBlock.isBlock = shouldUseBlock;
|
|
20826
20835
|
if (childBlock.isBlock) {
|
|
20827
20836
|
helper(OPEN_BLOCK);
|
|
20828
20837
|
helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
|
|
20829
|
-
} else
|
|
20838
|
+
} else {
|
|
20839
|
+
helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
|
|
20840
|
+
if (childBlock.needsPatch) {
|
|
20841
|
+
var _childBlock$patchFlag;
|
|
20842
|
+
childBlock.patchFlag = ((_childBlock$patchFlag = childBlock.patchFlag) !== null && _childBlock$patchFlag !== void 0 ? _childBlock$patchFlag : 0) | 512;
|
|
20843
|
+
}
|
|
20844
|
+
}
|
|
20830
20845
|
}
|
|
20831
20846
|
if (memo) {
|
|
20832
20847
|
const loop = createFunctionExpression(createForLoopParams(forNode.parseResult, [createSimpleExpression(`_cached`)]));
|
|
@@ -21082,12 +21097,16 @@ const transformElement$1 = (node, context) => {
|
|
|
21082
21097
|
let vnodeDynamicProps;
|
|
21083
21098
|
let dynamicPropNames;
|
|
21084
21099
|
let vnodeDirectives;
|
|
21100
|
+
let needsPatch = false;
|
|
21101
|
+
let isBlockRequired = false;
|
|
21085
21102
|
let shouldUseBlock = isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && (tag === "svg" || tag === "foreignObject" || tag === "math");
|
|
21086
21103
|
if (props.length > 0) {
|
|
21087
21104
|
const propsBuildResult = buildProps$1(node, context, void 0, isComponent, isDynamicComponent);
|
|
21088
21105
|
vnodeProps = propsBuildResult.props;
|
|
21089
21106
|
patchFlag = propsBuildResult.patchFlag;
|
|
21090
21107
|
dynamicPropNames = propsBuildResult.dynamicPropNames;
|
|
21108
|
+
needsPatch = propsBuildResult.needsPatch;
|
|
21109
|
+
isBlockRequired = propsBuildResult.isBlockRequired;
|
|
21091
21110
|
const directives = propsBuildResult.directives;
|
|
21092
21111
|
vnodeDirectives = directives && directives.length ? createArrayExpression(directives.map((dir) => buildDirectiveArgs(dir, context))) : void 0;
|
|
21093
21112
|
if (propsBuildResult.shouldUseBlock) shouldUseBlock = true;
|
|
@@ -21116,7 +21135,10 @@ const transformElement$1 = (node, context) => {
|
|
|
21116
21135
|
} else vnodeChildren = node.children;
|
|
21117
21136
|
}
|
|
21118
21137
|
if (dynamicPropNames && dynamicPropNames.length) vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
|
|
21119
|
-
node.codegenNode = createVNodeCall(context, vnodeTag, vnodeProps, vnodeChildren, patchFlag === 0 ? void 0 : patchFlag, vnodeDynamicProps, vnodeDirectives, !!shouldUseBlock, false, isComponent, node.loc);
|
|
21138
|
+
const vnodeCall = node.codegenNode = createVNodeCall(context, vnodeTag, vnodeProps, vnodeChildren, patchFlag === 0 ? void 0 : patchFlag, vnodeDynamicProps, vnodeDirectives, !!shouldUseBlock, false, isComponent, node.loc);
|
|
21139
|
+
needsPatch = needsPatch && (patchFlag === 0 || patchFlag === 32);
|
|
21140
|
+
if (needsPatch) vnodeCall.needsPatch = true;
|
|
21141
|
+
if (isBlockRequired) vnodeCall.isBlockRequired = true;
|
|
21120
21142
|
};
|
|
21121
21143
|
};
|
|
21122
21144
|
function resolveComponentType(node, context, ssr = false) {
|
|
@@ -21201,6 +21223,7 @@ function buildProps$1(node, context, props = node.props, isComponent, isDynamicC
|
|
|
21201
21223
|
const runtimeDirectives = [];
|
|
21202
21224
|
const hasChildren = children.length > 0;
|
|
21203
21225
|
let shouldUseBlock = false;
|
|
21226
|
+
let isBlockRequired = false;
|
|
21204
21227
|
let patchFlag = 0;
|
|
21205
21228
|
let hasRef = false;
|
|
21206
21229
|
let hasClassBinding = false;
|
|
@@ -21225,12 +21248,12 @@ function buildProps$1(node, context, props = node.props, isComponent, isDynamicC
|
|
|
21225
21248
|
const isEventHandler = isOn(name);
|
|
21226
21249
|
if (isEventHandler && (!isComponent || isDynamicComponent) && name.toLowerCase() !== "onclick" && name !== "onUpdate:modelValue" && !isReservedProp$1(name)) hasHydrationEventBinding = true;
|
|
21227
21250
|
if (isEventHandler && isReservedProp$1(name)) hasVnodeHook = true;
|
|
21251
|
+
if (name === "ref") hasRef = true;
|
|
21228
21252
|
if (isEventHandler && value.type === 14) value = value.arguments[0];
|
|
21229
21253
|
if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) return;
|
|
21230
|
-
if (name === "
|
|
21231
|
-
else if (name === "class") hasClassBinding = true;
|
|
21254
|
+
if (name === "class") hasClassBinding = true;
|
|
21232
21255
|
else if (name === "style") hasStyleBinding = true;
|
|
21233
|
-
else if (name !== "key" && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
|
|
21256
|
+
else if (name !== "ref" && name !== "key" && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
|
|
21234
21257
|
if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
|
|
21235
21258
|
} else hasDynamicKeys = true;
|
|
21236
21259
|
};
|
|
@@ -21263,7 +21286,11 @@ function buildProps$1(node, context, props = node.props, isComponent, isDynamicC
|
|
|
21263
21286
|
if (name === "once" || name === "memo") continue;
|
|
21264
21287
|
if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag$1(tag) || false)) continue;
|
|
21265
21288
|
if (isVOn && ssr) continue;
|
|
21266
|
-
if (isVBind && isStaticArgOf(arg, "key")
|
|
21289
|
+
if (isVBind && isStaticArgOf(arg, "key")) shouldUseBlock = true;
|
|
21290
|
+
if (isVOn && hasChildren && arg && isStaticExp(arg) && camelize(arg.content) === "vue:beforeUpdate") {
|
|
21291
|
+
shouldUseBlock = true;
|
|
21292
|
+
isBlockRequired = true;
|
|
21293
|
+
}
|
|
21267
21294
|
if (isVBind && isStaticArgOf(arg, "ref")) pushRefVForMarker();
|
|
21268
21295
|
if (!arg && (isVBind || isVOn)) {
|
|
21269
21296
|
hasDynamicKeys = true;
|
|
@@ -21293,7 +21320,10 @@ function buildProps$1(node, context, props = node.props, isComponent, isDynamicC
|
|
|
21293
21320
|
}
|
|
21294
21321
|
} else if (!isBuiltInDirective(name)) {
|
|
21295
21322
|
runtimeDirectives.push(prop);
|
|
21296
|
-
if (hasChildren)
|
|
21323
|
+
if (hasChildren) {
|
|
21324
|
+
shouldUseBlock = true;
|
|
21325
|
+
isBlockRequired = true;
|
|
21326
|
+
}
|
|
21297
21327
|
}
|
|
21298
21328
|
}
|
|
21299
21329
|
}
|
|
@@ -21310,7 +21340,8 @@ function buildProps$1(node, context, props = node.props, isComponent, isDynamicC
|
|
|
21310
21340
|
if (dynamicPropNames.length) patchFlag |= 8;
|
|
21311
21341
|
if (hasHydrationEventBinding) patchFlag |= 32;
|
|
21312
21342
|
}
|
|
21313
|
-
|
|
21343
|
+
const needsPatch = (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0);
|
|
21344
|
+
if (!shouldUseBlock && needsPatch) patchFlag |= 512;
|
|
21314
21345
|
if (!context.inSSR && propsExpression) switch (propsExpression.type) {
|
|
21315
21346
|
case 15:
|
|
21316
21347
|
let classKeyIndex = -1;
|
|
@@ -21340,7 +21371,9 @@ function buildProps$1(node, context, props = node.props, isComponent, isDynamicC
|
|
|
21340
21371
|
directives: runtimeDirectives,
|
|
21341
21372
|
patchFlag,
|
|
21342
21373
|
dynamicPropNames,
|
|
21343
|
-
shouldUseBlock
|
|
21374
|
+
shouldUseBlock,
|
|
21375
|
+
needsPatch,
|
|
21376
|
+
isBlockRequired
|
|
21344
21377
|
};
|
|
21345
21378
|
}
|
|
21346
21379
|
function dedupeProperties$1(properties) {
|
|
@@ -22223,10 +22256,11 @@ function stringifyElement(node, context) {
|
|
|
22223
22256
|
res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
|
|
22224
22257
|
continue;
|
|
22225
22258
|
}
|
|
22226
|
-
if (isBooleanAttr(p.arg.content) && exp.content === "false") continue;
|
|
22259
|
+
if ((isBooleanAttr(p.arg.content) || p.arg.content === "hidden") && exp.content === "false") continue;
|
|
22227
22260
|
let evaluated = evaluateConstant(exp);
|
|
22228
22261
|
if (evaluated != null) {
|
|
22229
22262
|
const arg = p.arg && p.arg.content;
|
|
22263
|
+
if (arg === "hidden" && typeof evaluated === "number" && !includeBooleanAttr(evaluated)) continue;
|
|
22230
22264
|
if (arg === "class") evaluated = normalizeClass(evaluated);
|
|
22231
22265
|
else if (arg === "style") evaluated = stringifyStyle(normalizeStyle(evaluated));
|
|
22232
22266
|
res += ` ${p.arg.content}="${escapeHtml(evaluated)}"`;
|
|
@@ -22980,6 +23014,16 @@ function createCache(max = 500) {
|
|
|
22980
23014
|
return /* @__PURE__ */ new Map();
|
|
22981
23015
|
}
|
|
22982
23016
|
//#endregion
|
|
23017
|
+
//#region packages/compiler-sfc/src/template/resolveTemplateAST.ts
|
|
23018
|
+
function resolveTemplateAST(inAST, options) {
|
|
23019
|
+
if (!(inAST === null || inAST === void 0 ? void 0 : inAST.transformed)) return inAST;
|
|
23020
|
+
const { compiler = src_exports$2, compilerOptions, ssr, onError } = options;
|
|
23021
|
+
return createRoot((ssr ? src_exports$2 : compiler).parse(inAST.source, _objectSpread2(_objectSpread2({ prefixIdentifiers: true }, compilerOptions), {}, {
|
|
23022
|
+
parseMode: "sfc",
|
|
23023
|
+
onError
|
|
23024
|
+
})).children.find((node) => node.type === 1 && node.tag === "template").children, inAST.source);
|
|
23025
|
+
}
|
|
23026
|
+
//#endregion
|
|
22983
23027
|
//#region packages/compiler-sfc/src/script/importUsageCheck.ts
|
|
22984
23028
|
/**
|
|
22985
23029
|
* Check if an identifier is used in the SFC's template.
|
|
@@ -22987,23 +23031,28 @@ function createCache(max = 500) {
|
|
|
22987
23031
|
* when not using inline mode.
|
|
22988
23032
|
* - 2.check whether the built-in properties such as $attrs, $slots, $emit are used in the template
|
|
22989
23033
|
*/
|
|
22990
|
-
function isUsedInTemplate(identifier, sfc) {
|
|
22991
|
-
return resolveTemplateUsedIdentifiers(sfc).has(identifier);
|
|
23034
|
+
function isUsedInTemplate(identifier, sfc, options) {
|
|
23035
|
+
return resolveTemplateUsedIdentifiers(sfc, options).has(identifier);
|
|
22992
23036
|
}
|
|
22993
23037
|
const templateAnalysisCache = createCache();
|
|
22994
|
-
function resolveTemplateVModelIdentifiers(sfc) {
|
|
22995
|
-
return resolveTemplateAnalysisResult(sfc, false).vModelIds;
|
|
23038
|
+
function resolveTemplateVModelIdentifiers(sfc, options) {
|
|
23039
|
+
return resolveTemplateAnalysisResult(sfc, false, options).vModelIds;
|
|
22996
23040
|
}
|
|
22997
|
-
function resolveTemplateUsedIdentifiers(sfc) {
|
|
22998
|
-
return resolveTemplateAnalysisResult(sfc).usedIds;
|
|
23041
|
+
function resolveTemplateUsedIdentifiers(sfc, options) {
|
|
23042
|
+
return resolveTemplateAnalysisResult(sfc, true, options).usedIds;
|
|
22999
23043
|
}
|
|
23000
|
-
function resolveTemplateAnalysisResult(sfc, collectUsedIds = true) {
|
|
23044
|
+
function resolveTemplateAnalysisResult(sfc, collectUsedIds = true, options) {
|
|
23001
23045
|
const { content, ast } = sfc.template;
|
|
23002
23046
|
const cached = templateAnalysisCache.get(content);
|
|
23003
23047
|
if (cached && (!collectUsedIds || cached.usedIds)) return cached;
|
|
23004
23048
|
const ids = collectUsedIds ? /* @__PURE__ */ new Set() : void 0;
|
|
23005
23049
|
const vModelIds = /* @__PURE__ */ new Set();
|
|
23006
|
-
ast
|
|
23050
|
+
resolveTemplateAST(ast, {
|
|
23051
|
+
compiler: options === null || options === void 0 ? void 0 : options.compiler,
|
|
23052
|
+
compilerOptions: options === null || options === void 0 ? void 0 : options.compilerOptions,
|
|
23053
|
+
ssr: options === null || options === void 0 ? void 0 : options.ssr,
|
|
23054
|
+
onError: () => {}
|
|
23055
|
+
}).children.forEach(walk);
|
|
23007
23056
|
function walk(node) {
|
|
23008
23057
|
switch (node.type) {
|
|
23009
23058
|
case 1:
|
|
@@ -23058,6 +23107,7 @@ function extractIdentifiers$1(ids, node) {
|
|
|
23058
23107
|
}
|
|
23059
23108
|
//#endregion
|
|
23060
23109
|
//#region packages/compiler-sfc/src/parse.ts
|
|
23110
|
+
init_objectSpread2();
|
|
23061
23111
|
const DEFAULT_FILENAME = "anonymous.vue";
|
|
23062
23112
|
const parseCache$1 = createCache();
|
|
23063
23113
|
function parse(source, options = {}) {
|
|
@@ -24756,22 +24806,20 @@ const IRNodeTypes = {
|
|
|
24756
24806
|
"9": "SET_TEMPLATE_REF",
|
|
24757
24807
|
"INSERT_NODE": 10,
|
|
24758
24808
|
"10": "INSERT_NODE",
|
|
24759
|
-
"
|
|
24760
|
-
"11": "
|
|
24761
|
-
"
|
|
24762
|
-
"12": "
|
|
24763
|
-
"
|
|
24764
|
-
"13": "
|
|
24765
|
-
"
|
|
24766
|
-
"14": "
|
|
24767
|
-
"
|
|
24768
|
-
"15": "
|
|
24769
|
-
"
|
|
24770
|
-
"16": "
|
|
24771
|
-
"
|
|
24772
|
-
"17": "
|
|
24773
|
-
"GET_TEXT_CHILD": 18,
|
|
24774
|
-
"18": "GET_TEXT_CHILD"
|
|
24809
|
+
"CREATE_COMPONENT_NODE": 11,
|
|
24810
|
+
"11": "CREATE_COMPONENT_NODE",
|
|
24811
|
+
"SLOT_OUTLET_NODE": 12,
|
|
24812
|
+
"12": "SLOT_OUTLET_NODE",
|
|
24813
|
+
"DIRECTIVE": 13,
|
|
24814
|
+
"13": "DIRECTIVE",
|
|
24815
|
+
"IF": 14,
|
|
24816
|
+
"14": "IF",
|
|
24817
|
+
"FOR": 15,
|
|
24818
|
+
"15": "FOR",
|
|
24819
|
+
"KEY": 16,
|
|
24820
|
+
"16": "KEY",
|
|
24821
|
+
"GET_TEXT_CHILD": 17,
|
|
24822
|
+
"17": "GET_TEXT_CHILD"
|
|
24775
24823
|
};
|
|
24776
24824
|
var TemplateRegistry = class {
|
|
24777
24825
|
constructor() {
|
|
@@ -24793,7 +24841,7 @@ const DynamicFlag = {
|
|
|
24793
24841
|
};
|
|
24794
24842
|
function isBlockOperation(op) {
|
|
24795
24843
|
const type = op.type;
|
|
24796
|
-
return type ===
|
|
24844
|
+
return type === 11 || type === 12 || type === 14 || type === 16 || type === 15;
|
|
24797
24845
|
}
|
|
24798
24846
|
//#endregion
|
|
24799
24847
|
//#region packages/compiler-vapor/src/transforms/utils.ts
|
|
@@ -25137,7 +25185,7 @@ var TransformContext = class TransformContext {
|
|
|
25137
25185
|
isSingleRootChild(childInfo) {
|
|
25138
25186
|
if (this.inVFor || !childInfo.hasSingleRootChild) return false;
|
|
25139
25187
|
if (this.node.type === 0) return true;
|
|
25140
|
-
return this.node.type === 1 && this.node.tagType === 3 && !!this.parent && this.isSingleRoot;
|
|
25188
|
+
return this.node.type === 1 && (this.node.tagType === 3 || isTransitionNode(this.node)) && !!this.parent && this.isSingleRoot;
|
|
25141
25189
|
}
|
|
25142
25190
|
};
|
|
25143
25191
|
function hasSingleRootChild(children) {
|
|
@@ -25414,9 +25462,6 @@ function genInsertNode({ parent, elements, anchor }, { helper }) {
|
|
|
25414
25462
|
if (elements.length > 1) element = `[${element}]`;
|
|
25415
25463
|
return [NEWLINE, ...genCall(helper("insert"), element, `n${parent}`, anchor === void 0 ? void 0 : `n${anchor}`)];
|
|
25416
25464
|
}
|
|
25417
|
-
function genPrependNode(oper, { helper }) {
|
|
25418
|
-
return [NEWLINE, ...genCall(helper("prepend"), `n${oper.parent}`, ...oper.elements.map((el) => `n${el}`))];
|
|
25419
|
-
}
|
|
25420
25465
|
//#endregion
|
|
25421
25466
|
//#region packages/compiler-vapor/src/generators/expression.ts
|
|
25422
25467
|
init_objectSpread2();
|
|
@@ -25906,7 +25951,10 @@ function extractMemberExpression(exp, onIdentifier) {
|
|
|
25906
25951
|
case "CallExpression": return `${extractMemberExpression(exp.callee, onIdentifier)}(${exp.arguments.map((arg) => extractMemberExpression(arg, onIdentifier)).join(", ")})`;
|
|
25907
25952
|
case "OptionalCallExpression": return `${extractMemberExpression(exp.callee, onIdentifier)}?.(${exp.arguments.map((arg) => extractMemberExpression(arg, onIdentifier)).join(", ")})`;
|
|
25908
25953
|
case "MemberExpression":
|
|
25909
|
-
case "OptionalMemberExpression":
|
|
25954
|
+
case "OptionalMemberExpression":
|
|
25955
|
+
const object = extractMemberExpression(exp.object, onIdentifier);
|
|
25956
|
+
const optional = exp.type === "OptionalMemberExpression" && exp.optional;
|
|
25957
|
+
return `${object}${exp.computed ? `${optional ? "?." : ""}[${extractMemberExpression(exp.property, onIdentifier)}]` : `${optional ? "?." : "."}${extractMemberExpression(exp.property, NOOP)}`}`;
|
|
25910
25958
|
case "TSNonNullExpression": return `${extractMemberExpression(exp.expression, onIdentifier)}`;
|
|
25911
25959
|
default: return "";
|
|
25912
25960
|
}
|
|
@@ -26166,7 +26214,7 @@ function isFragmentBlock(block) {
|
|
|
26166
26214
|
const child = getSingleReturnedChild(block);
|
|
26167
26215
|
const operation = child && child.operation;
|
|
26168
26216
|
if (!operation) return false;
|
|
26169
|
-
return operation.type ===
|
|
26217
|
+
return operation.type === 12 || operation.type === 15 || operation.type === 16 || operation.type === 14 && !operation.once || operation.type === 11 && !!operation.dynamic && !operation.dynamic.isStatic;
|
|
26170
26218
|
}
|
|
26171
26219
|
function getSingleReturnedChild(block) {
|
|
26172
26220
|
if (block.returns.length !== 1) return;
|
|
@@ -26345,8 +26393,8 @@ function isKeyOnlyBinding(expr, key, source) {
|
|
|
26345
26393
|
//#region packages/compiler-vapor/src/generators/html.ts
|
|
26346
26394
|
function genSetHtml(oper, context) {
|
|
26347
26395
|
const { helper } = context;
|
|
26348
|
-
const { value, element
|
|
26349
|
-
return [NEWLINE, ...genCall(
|
|
26396
|
+
const { value, element } = oper;
|
|
26397
|
+
return [NEWLINE, ...genCall(helper("setHtml"), `n${element}`, genExpression(value, context))];
|
|
26350
26398
|
}
|
|
26351
26399
|
//#endregion
|
|
26352
26400
|
//#region packages/compiler-vapor/src/generators/if.ts
|
|
@@ -26648,9 +26696,9 @@ function genRefValue(value, context) {
|
|
|
26648
26696
|
//#region packages/compiler-vapor/src/generators/text.ts
|
|
26649
26697
|
function genSetText(oper, context) {
|
|
26650
26698
|
const { helper } = context;
|
|
26651
|
-
const { element, values, generated
|
|
26699
|
+
const { element, values, generated } = oper;
|
|
26652
26700
|
const texts = combineValues(values, context);
|
|
26653
|
-
return [NEWLINE, ...genCall(
|
|
26701
|
+
return [NEWLINE, ...genCall(helper("setText"), `${generated ? "x" : "n"}${element}`, texts)];
|
|
26654
26702
|
}
|
|
26655
26703
|
function combineValues(values, context) {
|
|
26656
26704
|
return values.flatMap((value, i) => {
|
|
@@ -26725,7 +26773,11 @@ function genCustomDirectives(opers, context) {
|
|
|
26725
26773
|
return [NEWLINE, ...genCall(helper("withVaporDirectives"), element, directives)];
|
|
26726
26774
|
function genDirectiveItem({ dir, name, asset }) {
|
|
26727
26775
|
const directiveVar = asset ? toValidAssetId(name, "directive") : genExpression(extend(createSimpleExpression(name, false), { ast: null }), context);
|
|
26728
|
-
const value = dir.exp && [
|
|
26776
|
+
const value = dir.exp && [
|
|
26777
|
+
"() => (",
|
|
26778
|
+
...genExpression(dir.exp, context),
|
|
26779
|
+
")"
|
|
26780
|
+
];
|
|
26729
26781
|
const argument = dir.arg && genExpression(dir.arg, context);
|
|
26730
26782
|
const modifiers = !!dir.modifiers.length && [
|
|
26731
26783
|
"{ ",
|
|
@@ -26736,7 +26788,7 @@ function genCustomDirectives(opers, context) {
|
|
|
26736
26788
|
}
|
|
26737
26789
|
}
|
|
26738
26790
|
function filterCustomDirectives(id, operations) {
|
|
26739
|
-
return operations.filter((oper) => oper.type ===
|
|
26791
|
+
return operations.filter((oper) => oper.type === 13 && oper.element === id && !oper.builtin);
|
|
26740
26792
|
}
|
|
26741
26793
|
//#endregion
|
|
26742
26794
|
//#region packages/compiler-vapor/src/generators/component.ts
|
|
@@ -26969,7 +27021,8 @@ function genDynamicProps(props, context, directStaticLiteralProps = false) {
|
|
|
26969
27021
|
if (frags.length) return genMulti(DELIMITERS_ARRAY_NEWLINE, ...frags);
|
|
26970
27022
|
}
|
|
26971
27023
|
function genProp(prop, context, isStatic, wrapHandler = true, directStaticLiteral = false) {
|
|
26972
|
-
|
|
27024
|
+
let values = genPropValue(prop.values, context);
|
|
27025
|
+
if (prop.toDisplayString) values = genCall(context.helper("toDisplayString"), values);
|
|
26973
27026
|
return [
|
|
26974
27027
|
...genPropKey(prop, context),
|
|
26975
27028
|
": ",
|
|
@@ -27047,7 +27100,7 @@ function genStaticSlots({ slots }, context, dynamicSlots) {
|
|
|
27047
27100
|
return genMulti(DELIMITERS_OBJECT_NEWLINE, ...args);
|
|
27048
27101
|
}
|
|
27049
27102
|
function genDynamicSlots(slots, context) {
|
|
27050
|
-
return genMulti(DELIMITERS_ARRAY_NEWLINE, ...slots.map((slot) => slot.slotType === 0 ? genStaticSlots(slot, context) : slot.slotType === 4 ? slot.slots.content : genDynamicSlot(slot, context,
|
|
27103
|
+
return genMulti(DELIMITERS_ARRAY_NEWLINE, ...slots.map((slot) => slot.slotType === 0 ? genStaticSlots(slot, context) : slot.slotType === 4 ? slot.slots.content : genDynamicSlot(slot, context, slot.slotType !== 2)));
|
|
27051
27104
|
}
|
|
27052
27105
|
function genDynamicSlot(slot, context, withFunction = false) {
|
|
27053
27106
|
let frag;
|
|
@@ -27074,26 +27127,65 @@ function genBasicDynamicSlot(slot, context) {
|
|
|
27074
27127
|
return genMulti(DELIMITERS_OBJECT_NEWLINE, ["name: ", ...genExpression(name, context)], ["fn: ", ...genSlotBlockWithProps(fn, context, false)]);
|
|
27075
27128
|
}
|
|
27076
27129
|
function genLoopSlot(slot, context) {
|
|
27077
|
-
const { name, fn, loop } = slot;
|
|
27130
|
+
const { name, fn, loop, keyProp } = slot;
|
|
27078
27131
|
const { value, key, index, source } = loop;
|
|
27079
27132
|
const rawValue = value && value.content;
|
|
27080
27133
|
const rawKey = key && key.content;
|
|
27081
27134
|
const rawIndex = index && index.content;
|
|
27082
|
-
const
|
|
27083
|
-
|
|
27084
|
-
|
|
27085
|
-
|
|
27086
|
-
|
|
27087
|
-
|
|
27135
|
+
const idToPathMap = parseValueDestructure(value, context);
|
|
27136
|
+
const [depth, exitScope] = context.enterScope();
|
|
27137
|
+
const itemVar = `_for_item${depth}`;
|
|
27138
|
+
const idMap = buildDestructureIdMap(idToPathMap, `${itemVar}.value`, context.options.expressionPlugins);
|
|
27139
|
+
idMap[itemVar] = null;
|
|
27140
|
+
const args = [itemVar];
|
|
27141
|
+
if (rawKey) {
|
|
27142
|
+
const keyVar = `_for_key${depth}`;
|
|
27143
|
+
args.push(keyVar);
|
|
27144
|
+
idMap[rawKey] = `${keyVar}.value`;
|
|
27145
|
+
idMap[keyVar] = null;
|
|
27146
|
+
} else if (rawIndex) args.push("_");
|
|
27147
|
+
if (rawIndex) {
|
|
27148
|
+
const indexVar = `_for_index${depth}`;
|
|
27149
|
+
args.push(indexVar);
|
|
27150
|
+
idMap[rawIndex] = `${indexVar}.value`;
|
|
27151
|
+
idMap[indexVar] = null;
|
|
27152
|
+
}
|
|
27153
|
+
const renderSlot = [
|
|
27088
27154
|
...genMulti([
|
|
27089
27155
|
"(",
|
|
27090
27156
|
")",
|
|
27091
27157
|
", "
|
|
27092
|
-
],
|
|
27158
|
+
], ...args),
|
|
27159
|
+
" => ",
|
|
27160
|
+
...context.withId(() => genSlotBlockWithProps(fn, context, false), idMap)
|
|
27161
|
+
];
|
|
27162
|
+
exitScope();
|
|
27163
|
+
const rawIdMap = {};
|
|
27164
|
+
if (rawKey) rawIdMap[rawKey] = null;
|
|
27165
|
+
if (rawIndex) rawIdMap[rawIndex] = null;
|
|
27166
|
+
idToPathMap.forEach((_, id) => rawIdMap[id] = null);
|
|
27167
|
+
const rawParams = genMulti([
|
|
27168
|
+
"(",
|
|
27169
|
+
")",
|
|
27170
|
+
", "
|
|
27171
|
+
], rawValue ? rawValue : rawKey || rawIndex ? "_" : void 0, rawKey ? rawKey : rawIndex ? "__" : void 0, rawIndex);
|
|
27172
|
+
const getName = [
|
|
27173
|
+
...rawParams,
|
|
27093
27174
|
" => (",
|
|
27094
|
-
...
|
|
27175
|
+
...context.withId(() => genExpression(name, context), rawIdMap),
|
|
27095
27176
|
")"
|
|
27096
|
-
]
|
|
27177
|
+
];
|
|
27178
|
+
const getKey = keyProp && [
|
|
27179
|
+
...rawParams,
|
|
27180
|
+
" => (",
|
|
27181
|
+
...context.withId(() => genExpression(keyProp, context), rawIdMap),
|
|
27182
|
+
")"
|
|
27183
|
+
];
|
|
27184
|
+
return [...genCall(context.helper("createForSlots"), [
|
|
27185
|
+
"() => (",
|
|
27186
|
+
...genExpression(source, context),
|
|
27187
|
+
")"
|
|
27188
|
+
], renderSlot, getName, getKey)];
|
|
27097
27189
|
}
|
|
27098
27190
|
function genConditionalSlot(slot, context) {
|
|
27099
27191
|
const { condition, positive, negative } = slot;
|
|
@@ -27123,7 +27215,7 @@ function genSlotBlockWithProps(oper, context, emitNonStableFlag = true) {
|
|
|
27123
27215
|
if (propsName) idMap[propsName] = null;
|
|
27124
27216
|
const exitSlotBlock = context.enterSlotBlock();
|
|
27125
27217
|
const hasStableRoot = hasStableSlotRoot(oper, context);
|
|
27126
|
-
if (!hasStableRoot) markSlotRootOperations(oper);
|
|
27218
|
+
if (!hasStableRoot) markSlotRootOperations(oper, context);
|
|
27127
27219
|
let blockFn = context.withId(() => genBlock(oper, context, propsName ? [propsName] : []), idMap);
|
|
27128
27220
|
if (emitNonStableFlag && !hasStableRoot) blockFn = genCall(context.helper("extend"), blockFn, [`{ _: ${genSlotFlags$1(8)} }`]);
|
|
27129
27221
|
exitSlotBlock();
|
|
@@ -27138,40 +27230,6 @@ function genSlotFlags$1(flags) {
|
|
|
27138
27230
|
if (flags & 8) names.push("NON_STABLE");
|
|
27139
27231
|
return `${flags} /* ${names.join(", ")} */`;
|
|
27140
27232
|
}
|
|
27141
|
-
const commentOnlyTemplateRE = /^(?:<!--[\s\S]*?-->)+$/;
|
|
27142
|
-
function hasStableSlotRoot(block, context) {
|
|
27143
|
-
let hasValidRoot = false;
|
|
27144
|
-
for (let i = 0; i < block.returns.length; i++) {
|
|
27145
|
-
const id = block.returns[i];
|
|
27146
|
-
const child = findReturnedDynamic$1(block, id);
|
|
27147
|
-
const operation = child && child.operation;
|
|
27148
|
-
if (!operation) {
|
|
27149
|
-
if (child && isStableTemplateSlotRoot(child, context)) hasValidRoot = true;
|
|
27150
|
-
continue;
|
|
27151
|
-
}
|
|
27152
|
-
switch (operation.type) {
|
|
27153
|
-
case 12:
|
|
27154
|
-
if (!operation.dynamic || operation.dynamic.isStatic) {
|
|
27155
|
-
hasValidRoot = true;
|
|
27156
|
-
continue;
|
|
27157
|
-
}
|
|
27158
|
-
continue;
|
|
27159
|
-
case 17:
|
|
27160
|
-
if (hasStableSlotRoot(operation.block, context)) {
|
|
27161
|
-
hasValidRoot = true;
|
|
27162
|
-
continue;
|
|
27163
|
-
}
|
|
27164
|
-
continue;
|
|
27165
|
-
default: continue;
|
|
27166
|
-
}
|
|
27167
|
-
}
|
|
27168
|
-
return hasValidRoot;
|
|
27169
|
-
}
|
|
27170
|
-
function isStableTemplateSlotRoot(child, context) {
|
|
27171
|
-
if (child.template == null) return false;
|
|
27172
|
-
const content = context.ir.template.entries[child.template].content;
|
|
27173
|
-
return content !== "" && !commentOnlyTemplateRE.test(content.trim());
|
|
27174
|
-
}
|
|
27175
27233
|
//#endregion
|
|
27176
27234
|
//#region packages/compiler-vapor/src/generators/slotOutlet.ts
|
|
27177
27235
|
function genSlotOutlet(oper, context) {
|
|
@@ -27180,7 +27238,7 @@ function genSlotOutlet(oper, context) {
|
|
|
27180
27238
|
const [frag, push] = buildCodeFragment();
|
|
27181
27239
|
let fallbackArg;
|
|
27182
27240
|
if (fallback) {
|
|
27183
|
-
if (context.inSlotBlock) markSlotRootOperations(fallback);
|
|
27241
|
+
if (context.inSlotBlock) markSlotRootOperations(fallback, context);
|
|
27184
27242
|
fallbackArg = genBlock(fallback, context);
|
|
27185
27243
|
}
|
|
27186
27244
|
const createSlot = helper("createSlot");
|
|
@@ -27199,19 +27257,21 @@ function genSlotFlags(flags) {
|
|
|
27199
27257
|
if (flags & 1) names.push("NO_SLOTTED");
|
|
27200
27258
|
if (flags & 2) names.push("ONCE");
|
|
27201
27259
|
if (flags & 4) names.push("SLOT_ROOT");
|
|
27260
|
+
if (flags & 16) names.push("SHARED_FALLBACK");
|
|
27261
|
+
if (flags & 32) names.push("INHERIT_FALLBACK");
|
|
27202
27262
|
return `${flags} /* ${names.join(", ")} */`;
|
|
27203
27263
|
}
|
|
27204
27264
|
//#endregion
|
|
27205
27265
|
//#region packages/compiler-vapor/src/generators/key.ts
|
|
27206
27266
|
function genKey(oper, context) {
|
|
27207
|
-
const { id, value, block } = oper;
|
|
27267
|
+
const { id, value, block, slotRoot } = oper;
|
|
27208
27268
|
const [frag, push] = buildCodeFragment();
|
|
27209
27269
|
const blockFn = genBlock(block, context);
|
|
27210
27270
|
push(NEWLINE, `const n${id} = `, ...genCall(context.helper("createKeyedFragment"), [
|
|
27211
27271
|
`() => (`,
|
|
27212
27272
|
...genExpression(value, context),
|
|
27213
27273
|
")"
|
|
27214
|
-
], blockFn));
|
|
27274
|
+
], blockFn, slotRoot ? "true" : false));
|
|
27215
27275
|
return frag;
|
|
27216
27276
|
}
|
|
27217
27277
|
function genSetBlockKey(oper, context) {
|
|
@@ -27241,14 +27301,13 @@ function genOperation(oper, context) {
|
|
|
27241
27301
|
case 8: return genSetHtml(oper, context);
|
|
27242
27302
|
case 9: return genSetTemplateRef(oper, context);
|
|
27243
27303
|
case 10: return genInsertNode(oper, context);
|
|
27244
|
-
case
|
|
27245
|
-
case 15: return
|
|
27246
|
-
case 16: return
|
|
27247
|
-
case
|
|
27248
|
-
case 12: return
|
|
27249
|
-
case 13: return
|
|
27250
|
-
case
|
|
27251
|
-
case 18: return genGetTextChild(oper, context);
|
|
27304
|
+
case 14: return genIf(oper, context);
|
|
27305
|
+
case 15: return genFor(oper, context);
|
|
27306
|
+
case 16: return genKey(oper, context);
|
|
27307
|
+
case 11: return genCreateComponent(oper, context);
|
|
27308
|
+
case 12: return genSlotOutlet(oper, context);
|
|
27309
|
+
case 13: return genBuiltinDirective(oper, context);
|
|
27310
|
+
case 17: return genGetTextChild(oper, context);
|
|
27252
27311
|
default: throw new Error(`Unhandled operation type in genOperation: ${oper}`);
|
|
27253
27312
|
}
|
|
27254
27313
|
}
|
|
@@ -27296,9 +27355,8 @@ function genEffect({ operations }, context) {
|
|
|
27296
27355
|
return frag;
|
|
27297
27356
|
}
|
|
27298
27357
|
function genInsertionState(operation, context) {
|
|
27299
|
-
const { parent, anchor,
|
|
27300
|
-
|
|
27301
|
-
return [NEWLINE, ...genCall(context.helper("setInsertionState"), `n${parent}`, anchor == null ? void 0 : isPrepend ? `0` : append ? "null" : `n${anchor}`, logicalIndex !== void 0 && (!isPrepend || logicalIndex !== 0) ? String(logicalIndex) : void 0)];
|
|
27358
|
+
const { parent, anchor, appendIndex } = operation;
|
|
27359
|
+
return [NEWLINE, ...genCall(context.helper("setInsertionState"), `n${parent}`, anchor != null ? `n${anchor}` : appendIndex ? String(appendIndex) : void 0)];
|
|
27302
27360
|
}
|
|
27303
27361
|
//#endregion
|
|
27304
27362
|
//#region packages/compiler-vapor/src/generators/template.ts
|
|
@@ -27336,6 +27394,16 @@ function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`, flush
|
|
|
27336
27394
|
for (const [index, child] of children.entries()) {
|
|
27337
27395
|
if (child.flags & 2) offset--;
|
|
27338
27396
|
if (child.flags & 4 && child.template != null) {
|
|
27397
|
+
if (child.anchor !== void 0) {
|
|
27398
|
+
const elementIndex = index + offset;
|
|
27399
|
+
const variable = `n${child.anchor}`;
|
|
27400
|
+
pushBlock(NEWLINE, `const ${variable} = `, ...genAccessPath(context, from, elementIndex, prev));
|
|
27401
|
+
prev = [
|
|
27402
|
+
variable,
|
|
27403
|
+
elementIndex,
|
|
27404
|
+
false
|
|
27405
|
+
];
|
|
27406
|
+
}
|
|
27339
27407
|
flushBeforeDynamic && flushBeforeDynamic(child, push);
|
|
27340
27408
|
push(...genSelf(child, context, flushBeforeDynamic));
|
|
27341
27409
|
continue;
|
|
@@ -27347,9 +27415,8 @@ function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`, flush
|
|
|
27347
27415
|
continue;
|
|
27348
27416
|
}
|
|
27349
27417
|
const elementIndex = index + offset;
|
|
27350
|
-
const logicalIndex = child.logicalIndex !== void 0 ? String(child.logicalIndex) : void 0;
|
|
27351
27418
|
const inlinePlaceholder = id === void 0 && canInlinePlaceholder(child) && child.template == null && child.operation === void 0 && !(child.flags & 6);
|
|
27352
|
-
const accessPath = genAccessPath(context, from,
|
|
27419
|
+
const accessPath = genAccessPath(context, from, elementIndex, prev);
|
|
27353
27420
|
if (inlinePlaceholder) {
|
|
27354
27421
|
if (prev && prev[2]) {
|
|
27355
27422
|
push(...genChildren(child, context, pushBlock, [
|
|
@@ -27397,11 +27464,14 @@ function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`, flush
|
|
|
27397
27464
|
* Build one DOM lookup path while preserving the fast sibling walk:
|
|
27398
27465
|
* adjacent nodes use _next(prev), otherwise fall back to _nthChild(parent).
|
|
27399
27466
|
*/
|
|
27400
|
-
function genAccessPath({ helper }, from,
|
|
27401
|
-
if (prev) return elementIndex - prev[1] === 1 ? genCall(helper("next"), prev[0]
|
|
27402
|
-
if (elementIndex === 0) return genCall(helper("child"), from
|
|
27403
|
-
|
|
27404
|
-
|
|
27467
|
+
function genAccessPath({ helper }, from, elementIndex, prev) {
|
|
27468
|
+
if (prev) return elementIndex - prev[1] === 1 ? genCall(helper("next"), prev[0]) : genCall(helper("nthChild"), from, String(elementIndex));
|
|
27469
|
+
if (elementIndex === 0) return genCall(helper("child"), from);
|
|
27470
|
+
if (elementIndex === 1) {
|
|
27471
|
+
const firstChild = genCall(helper("child"), from);
|
|
27472
|
+
return genCall(helper("next"), firstChild);
|
|
27473
|
+
}
|
|
27474
|
+
return genCall(helper("nthChild"), from, String(elementIndex));
|
|
27405
27475
|
}
|
|
27406
27476
|
/**
|
|
27407
27477
|
* Only inline a placeholder when materializing it would not save a parent
|
|
@@ -27414,13 +27484,15 @@ function canInlinePlaceholder(dynamic) {
|
|
|
27414
27484
|
/**
|
|
27415
27485
|
* A following access can reuse the current placeholder cursor only when it is
|
|
27416
27486
|
* the next DOM sibling. Gapped siblings need _nthChild(parent, index) instead.
|
|
27487
|
+
* Kept in lockstep with genChildren's traversal rules.
|
|
27417
27488
|
*/
|
|
27418
27489
|
function hasAdjacentFollowingAccessChild(children, index, elementIndex, offset) {
|
|
27419
27490
|
let futureOffset = offset;
|
|
27420
27491
|
for (let i = index + 1; i < children.length; i++) {
|
|
27421
27492
|
const child = children[i];
|
|
27422
27493
|
if (child.flags & 2) futureOffset--;
|
|
27423
|
-
if (
|
|
27494
|
+
if (child.flags & 4 && child.anchor === void 0) continue;
|
|
27495
|
+
if (!!(child.flags & 1) || child.hasDynamicChild) return i + futureOffset - elementIndex === 1;
|
|
27424
27496
|
}
|
|
27425
27497
|
return false;
|
|
27426
27498
|
}
|
|
@@ -27435,7 +27507,7 @@ function countParentAccessUsages(dynamic) {
|
|
|
27435
27507
|
let prev;
|
|
27436
27508
|
for (const [index, child] of dynamic.children.entries()) {
|
|
27437
27509
|
if (child.flags & 2) offset--;
|
|
27438
|
-
if (child.flags & 4 && child.template != null) continue;
|
|
27510
|
+
if (child.flags & 4 && child.template != null && child.anchor === void 0) continue;
|
|
27439
27511
|
const id = child.flags & 1 ? child.flags & 4 ? child.anchor : child.id : void 0;
|
|
27440
27512
|
if (id === void 0 && !child.hasDynamicChild) continue;
|
|
27441
27513
|
const elementIndex = index + offset;
|
|
@@ -27456,10 +27528,6 @@ function countParentAccessUsages(dynamic) {
|
|
|
27456
27528
|
}
|
|
27457
27529
|
return usages;
|
|
27458
27530
|
}
|
|
27459
|
-
function genNthChild(nthChild, from, elementIndex, logicalIndex) {
|
|
27460
|
-
const index = String(elementIndex);
|
|
27461
|
-
return genCall(nthChild, from, index, logicalIndex === index ? void 0 : logicalIndex);
|
|
27462
|
-
}
|
|
27463
27531
|
//#endregion
|
|
27464
27532
|
//#region packages/compiler-vapor/src/generators/block.ts
|
|
27465
27533
|
function genBlock(oper, context, args = [], root) {
|
|
@@ -27477,6 +27545,7 @@ function genBlock(oper, context, args = [], root) {
|
|
|
27477
27545
|
function genBlockContent(block, context, root, genEffectsExtraFrag, skippedEffectIndexes) {
|
|
27478
27546
|
const [frag, push] = buildCodeFragment();
|
|
27479
27547
|
const { dynamic, effect, operation, returns } = block;
|
|
27548
|
+
const modelOperations = operation.filter(isVModelOperation);
|
|
27480
27549
|
const resetBlock = context.enterBlock(block);
|
|
27481
27550
|
const singleUseAssetComponentNames = root ? collectSingleUseAssetComponents(block) : void 0;
|
|
27482
27551
|
const prevSingleUseAssetComponentNames = context.singleUseAssetComponentNames;
|
|
@@ -27495,7 +27564,8 @@ function genBlockContent(block, context, root, genEffectsExtraFrag, skippedEffec
|
|
|
27495
27564
|
let effectIndex = 0;
|
|
27496
27565
|
const flushPendingOperations = (operationEnd, effectEnd, push) => {
|
|
27497
27566
|
while (operationIndex < operationEnd) {
|
|
27498
|
-
|
|
27567
|
+
const oper = operation[operationIndex];
|
|
27568
|
+
if (!isVModelOperation(oper)) push(...genOperationWithInsertionState(oper, context));
|
|
27499
27569
|
operationIndex++;
|
|
27500
27570
|
}
|
|
27501
27571
|
if (effectIndex < effectEnd) {
|
|
@@ -27512,9 +27582,10 @@ function genBlockContent(block, context, root, genEffectsExtraFrag, skippedEffec
|
|
|
27512
27582
|
push(...genSelf(child, context, flushBeforeDynamic));
|
|
27513
27583
|
}
|
|
27514
27584
|
for (const child of dynamic.children) if (!child.hasDynamicChild) push(...genChildren(child, context, push, `n${child.id}`, flushBeforeDynamic));
|
|
27515
|
-
if (operationIndex < operation.length) push(...genOperations(operation.slice(operationIndex), context));
|
|
27585
|
+
if (operationIndex < operation.length) push(...genOperations(operation.slice(operationIndex).filter((oper) => !isVModelOperation(oper)), context));
|
|
27516
27586
|
if (effectIndex < effect.length) push(...genEffectRange(effectIndex, effect.length, genEffectsExtraFrag));
|
|
27517
27587
|
else if (genEffectsExtraFrag) push(...genEffects([], context, genEffectsExtraFrag));
|
|
27588
|
+
if (modelOperations.length) push(...genOperations(modelOperations, context));
|
|
27518
27589
|
push(NEWLINE, `return `);
|
|
27519
27590
|
const returnNodes = returns.map((n) => `n${n}`);
|
|
27520
27591
|
push(...returnNodes.length > 1 ? genMulti(DELIMITERS_ARRAY, ...returnNodes) : [returnNodes[0] || "[]"]);
|
|
@@ -27532,27 +27603,48 @@ function genBlockContent(block, context, root, genEffectsExtraFrag, skippedEffec
|
|
|
27532
27603
|
for (const name of context.ir[kind]) push(NEWLINE, `const ${toValidAssetId(name, kind)} = `, ...genCall(context.helper(helper), JSON.stringify(name)));
|
|
27533
27604
|
}
|
|
27534
27605
|
}
|
|
27535
|
-
function
|
|
27606
|
+
function isVModelOperation(oper) {
|
|
27607
|
+
return oper.type === 13 && oper.builtin === true && oper.name === "model";
|
|
27608
|
+
}
|
|
27609
|
+
function markSlotRootOperations(block, context, sharedFallback = false) {
|
|
27610
|
+
if (hasStableSlotRoot(block, context)) return;
|
|
27611
|
+
sharedFallback = sharedFallback || hasMultipleDynamicSlotRoots(block);
|
|
27536
27612
|
for (let i = 0; i < block.returns.length; i++) {
|
|
27537
27613
|
const child = findReturnedDynamic$1(block, block.returns[i]);
|
|
27538
27614
|
const operation = child && child.operation;
|
|
27539
27615
|
if (!operation) continue;
|
|
27540
|
-
if (operation.type ===
|
|
27541
|
-
else if (operation.type ===
|
|
27542
|
-
else if (operation.type ===
|
|
27616
|
+
if (operation.type === 14) markSlotRootIf(operation, context, sharedFallback);
|
|
27617
|
+
else if (operation.type === 15) markSlotRootFor(operation, context);
|
|
27618
|
+
else if (operation.type === 16) {
|
|
27619
|
+
operation.slotRoot = true;
|
|
27620
|
+
markSlotRootOperations(operation.block, context, sharedFallback);
|
|
27621
|
+
} else if (operation.type === 11) markSlotRootComponent(operation);
|
|
27622
|
+
else if (operation.type === 12) {
|
|
27623
|
+
if (!(operation.flags & 2)) operation.flags |= 4;
|
|
27624
|
+
if (sharedFallback) operation.flags |= 16;
|
|
27625
|
+
else operation.flags |= 32;
|
|
27626
|
+
}
|
|
27543
27627
|
}
|
|
27544
27628
|
}
|
|
27545
|
-
function markSlotRootIf(operation) {
|
|
27629
|
+
function markSlotRootIf(operation, context, sharedFallback) {
|
|
27546
27630
|
if (!operation.once) operation.slotRoot = true;
|
|
27547
|
-
markSlotRootOperations(operation.positive);
|
|
27631
|
+
markSlotRootOperations(operation.positive, context, sharedFallback);
|
|
27548
27632
|
const negative = operation.negative;
|
|
27549
27633
|
if (!negative) return;
|
|
27550
|
-
if (negative.type ===
|
|
27551
|
-
else markSlotRootOperations(negative);
|
|
27634
|
+
if (negative.type === 14) markSlotRootIf(negative, context, sharedFallback);
|
|
27635
|
+
else markSlotRootOperations(negative, context, sharedFallback);
|
|
27552
27636
|
}
|
|
27553
|
-
function markSlotRootFor(operation) {
|
|
27637
|
+
function markSlotRootFor(operation, context) {
|
|
27554
27638
|
if (!operation.once) operation.slotRoot = true;
|
|
27555
|
-
markSlotRootOperations(operation.render);
|
|
27639
|
+
markSlotRootOperations(operation.render, context, true);
|
|
27640
|
+
}
|
|
27641
|
+
function hasMultipleDynamicSlotRoots(block) {
|
|
27642
|
+
let count = 0;
|
|
27643
|
+
for (let i = 0; i < block.returns.length; i++) {
|
|
27644
|
+
const child = findReturnedDynamic$1(block, block.returns[i]);
|
|
27645
|
+
if (child && child.operation && ++count > 1) return true;
|
|
27646
|
+
}
|
|
27647
|
+
return false;
|
|
27556
27648
|
}
|
|
27557
27649
|
function markSlotRootComponent(operation) {
|
|
27558
27650
|
if (!operation.once && operation.dynamic && !operation.dynamic.isStatic) operation.slotRoot = true;
|
|
@@ -27563,6 +27655,40 @@ function findReturnedDynamic$1(block, id) {
|
|
|
27563
27655
|
if (child.id === id) return child;
|
|
27564
27656
|
}
|
|
27565
27657
|
}
|
|
27658
|
+
const commentOnlyTemplateRE = /^(?:<!--[\s\S]*?-->)+$/;
|
|
27659
|
+
function hasStableSlotRoot(block, context) {
|
|
27660
|
+
let hasValidRoot = false;
|
|
27661
|
+
for (let i = 0; i < block.returns.length; i++) {
|
|
27662
|
+
const id = block.returns[i];
|
|
27663
|
+
const child = findReturnedDynamic$1(block, id);
|
|
27664
|
+
const operation = child && child.operation;
|
|
27665
|
+
if (!operation) {
|
|
27666
|
+
if (child && isStableTemplateSlotRoot(child, context)) hasValidRoot = true;
|
|
27667
|
+
continue;
|
|
27668
|
+
}
|
|
27669
|
+
switch (operation.type) {
|
|
27670
|
+
case 11:
|
|
27671
|
+
if (!operation.dynamic || operation.dynamic.isStatic) {
|
|
27672
|
+
hasValidRoot = true;
|
|
27673
|
+
continue;
|
|
27674
|
+
}
|
|
27675
|
+
continue;
|
|
27676
|
+
case 16:
|
|
27677
|
+
if (hasStableSlotRoot(operation.block, context)) {
|
|
27678
|
+
hasValidRoot = true;
|
|
27679
|
+
continue;
|
|
27680
|
+
}
|
|
27681
|
+
continue;
|
|
27682
|
+
default: continue;
|
|
27683
|
+
}
|
|
27684
|
+
}
|
|
27685
|
+
return hasValidRoot;
|
|
27686
|
+
}
|
|
27687
|
+
function isStableTemplateSlotRoot(child, context) {
|
|
27688
|
+
if (child.template == null) return false;
|
|
27689
|
+
const content = context.ir.template.entries[child.template].content;
|
|
27690
|
+
return content !== "" && !commentOnlyTemplateRE.test(content.trim());
|
|
27691
|
+
}
|
|
27566
27692
|
function collectSingleUseAssetComponents(block) {
|
|
27567
27693
|
const usageMap = /* @__PURE__ */ new Map();
|
|
27568
27694
|
const seenOperations = /* @__PURE__ */ new Set();
|
|
@@ -27582,7 +27708,7 @@ function collectSingleUseAssetComponents(block) {
|
|
|
27582
27708
|
function visitOperation(operation, rootCandidate) {
|
|
27583
27709
|
if (seenOperations.has(operation)) return;
|
|
27584
27710
|
seenOperations.add(operation);
|
|
27585
|
-
if (operation.type ===
|
|
27711
|
+
if (operation.type === 11) {
|
|
27586
27712
|
if (operation.asset) {
|
|
27587
27713
|
const usage = usageMap.get(operation.tag) || {
|
|
27588
27714
|
count: 0,
|
|
@@ -27596,18 +27722,18 @@ function collectSingleUseAssetComponents(block) {
|
|
|
27596
27722
|
return;
|
|
27597
27723
|
}
|
|
27598
27724
|
switch (operation.type) {
|
|
27599
|
-
case
|
|
27725
|
+
case 14:
|
|
27600
27726
|
visitBlock(operation.positive, false);
|
|
27601
|
-
if (operation.negative) if (operation.negative.type ===
|
|
27727
|
+
if (operation.negative) if (operation.negative.type === 14) visitOperation(operation.negative, false);
|
|
27602
27728
|
else visitBlock(operation.negative, false);
|
|
27603
27729
|
break;
|
|
27604
|
-
case
|
|
27730
|
+
case 15:
|
|
27605
27731
|
visitBlock(operation.render, false);
|
|
27606
27732
|
break;
|
|
27607
|
-
case
|
|
27733
|
+
case 16:
|
|
27608
27734
|
visitBlock(operation.block, false);
|
|
27609
27735
|
break;
|
|
27610
|
-
case
|
|
27736
|
+
case 12:
|
|
27611
27737
|
if (operation.fallback) visitBlock(operation.fallback, false);
|
|
27612
27738
|
break;
|
|
27613
27739
|
}
|
|
@@ -27881,11 +28007,14 @@ const transformVHtml = (dir, node, context) => {
|
|
|
27881
28007
|
exp = EMPTY_EXPRESSION;
|
|
27882
28008
|
}
|
|
27883
28009
|
ignoreVHtmlChildren(node, context, "template");
|
|
28010
|
+
if (node.tagType === 1) return {
|
|
28011
|
+
key: createSimpleExpression("innerHTML", true, loc),
|
|
28012
|
+
value: exp
|
|
28013
|
+
};
|
|
27884
28014
|
context.registerEffect([exp], {
|
|
27885
28015
|
type: 8,
|
|
27886
28016
|
element: context.reference(),
|
|
27887
|
-
value: exp
|
|
27888
|
-
isComponent: node.tagType === 1
|
|
28017
|
+
value: exp
|
|
27889
28018
|
});
|
|
27890
28019
|
};
|
|
27891
28020
|
//#endregion
|
|
@@ -27979,7 +28108,7 @@ function transformComponentElement(node, propsResult, staticKey, singleRoot, con
|
|
|
27979
28108
|
context.dynamic.flags |= 6;
|
|
27980
28109
|
const id = context.reference();
|
|
27981
28110
|
context.dynamic.operation = _objectSpread2(_objectSpread2({
|
|
27982
|
-
type:
|
|
28111
|
+
type: 11,
|
|
27983
28112
|
id
|
|
27984
28113
|
}, context.effectBoundary()), {}, {
|
|
27985
28114
|
tag,
|
|
@@ -28025,27 +28154,22 @@ function transformNativeElement(node, propsResult, staticKey, singleRoot, contex
|
|
|
28025
28154
|
tag
|
|
28026
28155
|
}, getEffectIndex);
|
|
28027
28156
|
} else {
|
|
28028
|
-
let prevWasQuoted = false;
|
|
28029
28157
|
const appendTemplateProp = (key, value = "", generated = false) => {
|
|
28030
|
-
|
|
28031
|
-
template += key;
|
|
28158
|
+
template += ` ${key}`;
|
|
28032
28159
|
if (value) {
|
|
28033
28160
|
const escapedValue = generated ? escapeGeneratedAttrValue(value) : value.replace(/"/g, """);
|
|
28034
|
-
template +=
|
|
28035
|
-
}
|
|
28161
|
+
template += NEEDS_QUOTES_RE.test(value) ? `="${escapedValue}"` : `=${escapedValue}`;
|
|
28162
|
+
}
|
|
28036
28163
|
};
|
|
28037
28164
|
for (const prop of propsResult[1]) {
|
|
28038
28165
|
const { key, values } = prop;
|
|
28039
28166
|
const canStringifyAttrName = key.isStatic && !UNSAFE_ATTR_NAME_RE.test(key.content);
|
|
28040
28167
|
let foldedValue;
|
|
28041
|
-
if (canStringifyAttrName && context.imports.some((imported) => values[0].content.includes(imported.exp.content))) {
|
|
28042
|
-
|
|
28043
|
-
template += `${key.content}="${IMPORT_EXP_START}${values[0].content}${IMPORT_EXP_END}"`;
|
|
28044
|
-
prevWasQuoted = true;
|
|
28045
|
-
} else if (canStringifyAttrName && values.length === 1 && (values[0].isStatic || values[0].content === "''") && !dynamicKeys.includes(key.content)) {
|
|
28168
|
+
if (canStringifyAttrName && context.imports.some((imported) => values[0].content.includes(imported.exp.content))) template += ` ${key.content}="${IMPORT_EXP_START}${values[0].content}${IMPORT_EXP_END}"`;
|
|
28169
|
+
else if (canStringifyAttrName && values.length === 1 && (values[0].isStatic || values[0].content === "''") && !dynamicKeys.includes(key.content)) {
|
|
28046
28170
|
const value = values[0].content === "''" ? "" : values[0].content;
|
|
28047
28171
|
appendTemplateProp(key.content, value);
|
|
28048
|
-
} else if (canStringifyAttrName && !prop.modifier && isBooleanAttr(key.content) && (foldedValue = foldBooleanAttrValue(values)) != null) {
|
|
28172
|
+
} else if (canStringifyAttrName && !prop.modifier && (isBooleanAttr(key.content) || key.content === "hidden") && (foldedValue = foldBooleanAttrValue(key.content, values)) != null) {
|
|
28049
28173
|
if (foldedValue) appendTemplateProp(key.content);
|
|
28050
28174
|
} else if (canStringifyAttrName && !prop.modifier && hasBoundValue(values) && (foldedValue = key.content === "class" ? foldClassValues(values) : key.content === "style" ? foldStyleValues(values) : void 0) != null) {
|
|
28051
28175
|
if (foldedValue) appendTemplateProp(key.content, foldedValue, true);
|
|
@@ -28070,11 +28194,12 @@ function transformNativeElement(node, propsResult, staticKey, singleRoot, contex
|
|
|
28070
28194
|
function escapeGeneratedAttrValue(value) {
|
|
28071
28195
|
return value.replace(/&/g, "&").replace(/"/g, """);
|
|
28072
28196
|
}
|
|
28073
|
-
function foldBooleanAttrValue(values) {
|
|
28197
|
+
function foldBooleanAttrValue(key, values) {
|
|
28074
28198
|
if (values.length !== 1) return;
|
|
28075
28199
|
const evaluated = evaluateConstantExpression(values[0]);
|
|
28076
28200
|
if (!evaluated) return;
|
|
28077
28201
|
const value = evaluated.value;
|
|
28202
|
+
if (key === "hidden" && typeof value === "number") return includeBooleanAttr(value);
|
|
28078
28203
|
if (value === true || value === false || value == null) return includeBooleanAttr(value);
|
|
28079
28204
|
}
|
|
28080
28205
|
function foldStyleValues(values) {
|
|
@@ -28436,7 +28561,7 @@ function transformProp(prop, node, context) {
|
|
|
28436
28561
|
if (fromSetup) name = fromSetup;
|
|
28437
28562
|
else context.directive.add(name);
|
|
28438
28563
|
context.registerOperation({
|
|
28439
|
-
type:
|
|
28564
|
+
type: 13,
|
|
28440
28565
|
element: context.reference(),
|
|
28441
28566
|
dir: prop,
|
|
28442
28567
|
name,
|
|
@@ -28456,7 +28581,8 @@ function dedupeProperties(results) {
|
|
|
28456
28581
|
const name = prop.key.content;
|
|
28457
28582
|
const existing = knownProps.get(name);
|
|
28458
28583
|
if (existing && existing.handler === prop.handler) {
|
|
28459
|
-
if (
|
|
28584
|
+
if (prop.handler) deduped.push(prop);
|
|
28585
|
+
else if (name === "style" || name === "class") mergePropValues(existing, prop);
|
|
28460
28586
|
} else {
|
|
28461
28587
|
knownProps.set(name, prop);
|
|
28462
28588
|
deduped.push(prop);
|
|
@@ -28517,49 +28643,33 @@ const transformChildren = (node, context) => {
|
|
|
28517
28643
|
if (!isFragment) processDynamicChildren(context);
|
|
28518
28644
|
};
|
|
28519
28645
|
function processDynamicChildren(context) {
|
|
28520
|
-
let prevDynamics = [];
|
|
28521
|
-
let staticCount = 0;
|
|
28522
28646
|
const children = context.dynamic.children;
|
|
28523
|
-
let
|
|
28524
|
-
for (
|
|
28525
|
-
|
|
28526
|
-
|
|
28527
|
-
|
|
28528
|
-
|
|
28529
|
-
|
|
28530
|
-
|
|
28531
|
-
|
|
28532
|
-
|
|
28533
|
-
|
|
28534
|
-
|
|
28535
|
-
|
|
28536
|
-
|
|
28537
|
-
registerInsertion(prevDynamics, context, anchor);
|
|
28538
|
-
} else registerInsertion(prevDynamics, context, -1);
|
|
28539
|
-
prevDynamics = [];
|
|
28540
|
-
}
|
|
28541
|
-
staticCount++;
|
|
28542
|
-
logicalIndex++;
|
|
28543
|
-
}
|
|
28544
|
-
}
|
|
28545
|
-
if (prevDynamics.length) registerInsertion(prevDynamics, context, prevDynamics[0].logicalIndex, true);
|
|
28546
|
-
}
|
|
28547
|
-
function registerInsertion(dynamics, context, anchor, append) {
|
|
28548
|
-
for (const child of dynamics) {
|
|
28549
|
-
const logicalIndex = child.logicalIndex;
|
|
28550
|
-
if (child.template != null) context.registerOperation({
|
|
28647
|
+
let lastTemplateIndex = -1;
|
|
28648
|
+
for (let i = children.length - 1; i >= 0; i--) if (!(children[i].flags & 2)) {
|
|
28649
|
+
lastTemplateIndex = i;
|
|
28650
|
+
break;
|
|
28651
|
+
}
|
|
28652
|
+
let unitIndex = 0;
|
|
28653
|
+
for (const [index, child] of children.entries()) if (child.flags & 4) {
|
|
28654
|
+
let anchor;
|
|
28655
|
+
if (index < lastTemplateIndex) {
|
|
28656
|
+
context.childrenTemplate[index] = `<!>`;
|
|
28657
|
+
child.flags = child.flags - 2 | 1;
|
|
28658
|
+
anchor = child.anchor = context.increaseId();
|
|
28659
|
+
}
|
|
28660
|
+
if (child.template != null) child.operation = {
|
|
28551
28661
|
type: 10,
|
|
28552
|
-
elements:
|
|
28662
|
+
elements: [child.id],
|
|
28553
28663
|
parent: context.reference(),
|
|
28554
|
-
anchor
|
|
28555
|
-
}
|
|
28664
|
+
anchor
|
|
28665
|
+
};
|
|
28556
28666
|
else if (child.operation && isBlockOperation(child.operation)) {
|
|
28557
28667
|
child.operation.parent = context.reference();
|
|
28558
|
-
child.operation.anchor = anchor;
|
|
28559
|
-
child.operation.
|
|
28560
|
-
child.operation.append = append;
|
|
28668
|
+
if (anchor !== void 0) child.operation.anchor = anchor;
|
|
28669
|
+
else child.operation.appendIndex = unitIndex;
|
|
28561
28670
|
}
|
|
28562
|
-
|
|
28671
|
+
unitIndex++;
|
|
28672
|
+
} else if (!(child.flags & 2)) unitIndex++;
|
|
28563
28673
|
}
|
|
28564
28674
|
//#endregion
|
|
28565
28675
|
//#region packages/compiler-vapor/src/transforms/vOnce.ts
|
|
@@ -28653,7 +28763,7 @@ function processTextContainer(children, context) {
|
|
|
28653
28763
|
else {
|
|
28654
28764
|
context.childrenTemplate = [" "];
|
|
28655
28765
|
context.registerOperation({
|
|
28656
|
-
type:
|
|
28766
|
+
type: 17,
|
|
28657
28767
|
parent: context.reference()
|
|
28658
28768
|
});
|
|
28659
28769
|
context.registerEffect(values, {
|
|
@@ -28709,6 +28819,7 @@ function isTextLike(node) {
|
|
|
28709
28819
|
}
|
|
28710
28820
|
//#endregion
|
|
28711
28821
|
//#region packages/compiler-vapor/src/transforms/vText.ts
|
|
28822
|
+
const isRawTextContainer = /* @__PURE__ */ makeMap("iframe,noembed,noframes,noscript,script,style,xmp");
|
|
28712
28823
|
const transformVText = (dir, node, context) => {
|
|
28713
28824
|
let { exp, loc } = dir;
|
|
28714
28825
|
if (!exp) {
|
|
@@ -28721,18 +28832,22 @@ const transformVText = (dir, node, context) => {
|
|
|
28721
28832
|
for (const child of node.children) markNonTemplate(child, context);
|
|
28722
28833
|
}
|
|
28723
28834
|
if (isVoidTag(context.node.tag)) return;
|
|
28835
|
+
if (node.tagType === 1) return {
|
|
28836
|
+
key: createSimpleExpression("textContent", true),
|
|
28837
|
+
value: exp,
|
|
28838
|
+
toDisplayString: !isConstantVTextExpression(exp, context.options.bindingMetadata)
|
|
28839
|
+
};
|
|
28724
28840
|
const literal = getLiteralExpressionValue(exp);
|
|
28725
28841
|
const useCreateElement = shouldUseCreateElement(context.node, context);
|
|
28726
|
-
if (literal != null) if (useCreateElement) {
|
|
28842
|
+
if (literal != null) if (useCreateElement || isRawTextContainer(node.tag)) {
|
|
28727
28843
|
const id = registerSyntheticTextChild(context, "", [exp]);
|
|
28728
28844
|
context.registerOperation({
|
|
28729
28845
|
type: 10,
|
|
28730
28846
|
elements: [id],
|
|
28731
28847
|
parent: context.reference()
|
|
28732
28848
|
});
|
|
28733
|
-
} else context.childrenTemplate = [
|
|
28849
|
+
} else context.childrenTemplate = [escapeHtml(literal)];
|
|
28734
28850
|
else {
|
|
28735
|
-
const isComponent = node.tagType === 1;
|
|
28736
28851
|
let id;
|
|
28737
28852
|
if (useCreateElement) {
|
|
28738
28853
|
id = registerSyntheticTextChild(context, "");
|
|
@@ -28741,10 +28856,10 @@ const transformVText = (dir, node, context) => {
|
|
|
28741
28856
|
elements: [id],
|
|
28742
28857
|
parent: context.reference()
|
|
28743
28858
|
});
|
|
28744
|
-
} else
|
|
28859
|
+
} else {
|
|
28745
28860
|
context.childrenTemplate = [" "];
|
|
28746
28861
|
context.registerOperation({
|
|
28747
|
-
type:
|
|
28862
|
+
type: 17,
|
|
28748
28863
|
parent: context.reference()
|
|
28749
28864
|
});
|
|
28750
28865
|
}
|
|
@@ -28752,11 +28867,24 @@ const transformVText = (dir, node, context) => {
|
|
|
28752
28867
|
type: 5,
|
|
28753
28868
|
element: useCreateElement ? id : context.reference(),
|
|
28754
28869
|
values: [exp],
|
|
28755
|
-
generated: !useCreateElement
|
|
28756
|
-
isComponent
|
|
28870
|
+
generated: !useCreateElement
|
|
28757
28871
|
});
|
|
28758
28872
|
}
|
|
28759
28873
|
};
|
|
28874
|
+
function isConstantVTextExpression(exp, bindings) {
|
|
28875
|
+
if (isConstantExpression(exp)) return true;
|
|
28876
|
+
if (exp.ast === null) {
|
|
28877
|
+
const type = bindings[exp.content];
|
|
28878
|
+
return type === "setup-const" || type === "literal-const";
|
|
28879
|
+
}
|
|
28880
|
+
if (!exp.ast) return false;
|
|
28881
|
+
let isConstant = true;
|
|
28882
|
+
walkIdentifiers(exp.ast, (id, parent, _parentStack, isReferenced) => {
|
|
28883
|
+
if (parent && isStaticPropertyKey(id, parent)) return;
|
|
28884
|
+
if (isReferenced && !isGloballyAllowed(id.name) && id.name !== "require" || (parent === null || parent === void 0 ? void 0 : parent.type) === "CallExpression" || (parent === null || parent === void 0 ? void 0 : parent.type) === "NewExpression" || (parent === null || parent === void 0 ? void 0 : parent.type) === "MemberExpression") isConstant = false;
|
|
28885
|
+
}, true);
|
|
28886
|
+
return isConstant;
|
|
28887
|
+
}
|
|
28760
28888
|
//#endregion
|
|
28761
28889
|
//#region packages/compiler-vapor/src/transforms/vOn.ts
|
|
28762
28890
|
const delegatedEvents = /* @__PURE__ */ makeMap("beforeinput,click,dblclick,contextmenu,focusin,focusout,input,keydown,keyup,mousedown,mousemove,mouseout,mouseover,mouseup,pointerdown,pointermove,pointerout,pointerover,pointerup,touchend,touchmove,touchstart");
|
|
@@ -28856,7 +28984,7 @@ const transformVShow = (dir, node, context) => {
|
|
|
28856
28984
|
return;
|
|
28857
28985
|
}
|
|
28858
28986
|
context.registerOperation({
|
|
28859
|
-
type:
|
|
28987
|
+
type: 13,
|
|
28860
28988
|
element: context.reference(),
|
|
28861
28989
|
dir,
|
|
28862
28990
|
name: "show",
|
|
@@ -28940,7 +29068,7 @@ const transformVModel = (dir, node, context) => {
|
|
|
28940
29068
|
else checkDuplicatedValue();
|
|
28941
29069
|
else context.options.onError(createDOMCompilerError(58, dir.loc));
|
|
28942
29070
|
if (modelType) context.registerOperation({
|
|
28943
|
-
type:
|
|
29071
|
+
type: 13,
|
|
28944
29072
|
element: context.reference(),
|
|
28945
29073
|
dir,
|
|
28946
29074
|
name: "model",
|
|
@@ -29005,7 +29133,7 @@ function processIf(node, dir, context) {
|
|
|
29005
29133
|
return () => {
|
|
29006
29134
|
onExit();
|
|
29007
29135
|
context.dynamic.operation = _objectSpread2(_objectSpread2({
|
|
29008
|
-
type:
|
|
29136
|
+
type: 14,
|
|
29009
29137
|
id
|
|
29010
29138
|
}, context.effectBoundary()), {}, {
|
|
29011
29139
|
blockShape: encodeIfBlockShape(branch, forceMultiRoot, void 0, allowNoScope),
|
|
@@ -29021,16 +29149,16 @@ function processIf(node, dir, context) {
|
|
|
29021
29149
|
let lastIfNode;
|
|
29022
29150
|
if (siblings) {
|
|
29023
29151
|
let i = siblings.length;
|
|
29024
|
-
while (i--) if (siblings[i].operation && siblings[i].operation.type ===
|
|
29152
|
+
while (i--) if (siblings[i].operation && siblings[i].operation.type === 14) {
|
|
29025
29153
|
lastIfNode = siblings[i].operation;
|
|
29026
29154
|
break;
|
|
29027
29155
|
}
|
|
29028
29156
|
}
|
|
29029
|
-
if (!siblingIf || !lastIfNode || lastIfNode.type !==
|
|
29157
|
+
if (!siblingIf || !lastIfNode || lastIfNode.type !== 14) {
|
|
29030
29158
|
context.options.onError(createCompilerError(30, node.loc));
|
|
29031
29159
|
return;
|
|
29032
29160
|
}
|
|
29033
|
-
while (lastIfNode.negative && lastIfNode.negative.type ===
|
|
29161
|
+
while (lastIfNode.negative && lastIfNode.negative.type === 14) lastIfNode = lastIfNode.negative;
|
|
29034
29162
|
if (dir.name === "else-if" && lastIfNode.negative) context.options.onError(createCompilerError(30, node.loc));
|
|
29035
29163
|
const comments = context.comment;
|
|
29036
29164
|
if (comments.length) {
|
|
@@ -29043,7 +29171,7 @@ function processIf(node, dir, context) {
|
|
|
29043
29171
|
const [branch, onExit] = createIfBranch(node, context);
|
|
29044
29172
|
if (dir.name === "else") lastIfNode.negative = branch;
|
|
29045
29173
|
else lastIfNode.negative = {
|
|
29046
|
-
type:
|
|
29174
|
+
type: 14,
|
|
29047
29175
|
id: -1,
|
|
29048
29176
|
condition: dir.exp,
|
|
29049
29177
|
positive: branch,
|
|
@@ -29053,7 +29181,7 @@ function processIf(node, dir, context) {
|
|
|
29053
29181
|
};
|
|
29054
29182
|
return () => {
|
|
29055
29183
|
onExit();
|
|
29056
|
-
if (lastIfNode.negative.type ===
|
|
29184
|
+
if (lastIfNode.negative.type === 14) lastIfNode.negative.blockShape = encodeIfBlockShape(lastIfNode.negative.positive, forceMultiRoot, void 0, allowNoScope);
|
|
29057
29185
|
lastIfNode.blockShape = encodeIfBlockShape(lastIfNode.positive, forceMultiRoot, lastIfNode.negative, allowNoScope);
|
|
29058
29186
|
};
|
|
29059
29187
|
}
|
|
@@ -29072,12 +29200,12 @@ function createIfBranch(node, context) {
|
|
|
29072
29200
|
function encodeIfBlockShape(positive, forceMultiRoot = false, negative, allowNoScope = true) {
|
|
29073
29201
|
if (forceMultiRoot) return 10;
|
|
29074
29202
|
const positiveNoScope = allowNoScope && canSkipIfBranchScope(positive);
|
|
29075
|
-
const negativeNoScope = allowNoScope && negative && negative.type !==
|
|
29203
|
+
const negativeNoScope = allowNoScope && negative && negative.type !== 14 && canSkipIfBranchScope(negative);
|
|
29076
29204
|
return getBlockShape(positive) | getNegativeIfBranchShape(negative) << 2 | (positiveNoScope ? 32 : 0) | (negativeNoScope ? 64 : 0);
|
|
29077
29205
|
}
|
|
29078
29206
|
function getNegativeIfBranchShape(negative) {
|
|
29079
29207
|
if (!negative) return 0;
|
|
29080
|
-
return negative.type ===
|
|
29208
|
+
return negative.type === 14 ? 1 : getBlockShape(negative);
|
|
29081
29209
|
}
|
|
29082
29210
|
function canSkipIfBranchScope(block) {
|
|
29083
29211
|
if (block.effect.length || block.operation.length) return false;
|
|
@@ -29134,7 +29262,7 @@ function processFor(node, dir, context) {
|
|
|
29134
29262
|
const { parent } = context;
|
|
29135
29263
|
const isOnlyChild = parent && parent.block.node !== parent.node && parent.node.children.length === 1;
|
|
29136
29264
|
context.dynamic.operation = _objectSpread2(_objectSpread2({
|
|
29137
|
-
type:
|
|
29265
|
+
type: 15,
|
|
29138
29266
|
id
|
|
29139
29267
|
}, context.effectBoundary()), {}, {
|
|
29140
29268
|
source,
|
|
@@ -29182,7 +29310,7 @@ const transformSlotOutlet = (node, context) => {
|
|
|
29182
29310
|
if (slotProps.length) {
|
|
29183
29311
|
const [isDynamic, props] = buildProps(extend({}, node, { props: slotProps }), context, true);
|
|
29184
29312
|
irProps = isDynamic ? props : [props];
|
|
29185
|
-
const runtimeDirective = context.block.operation.find((oper) => oper.type ===
|
|
29313
|
+
const runtimeDirective = context.block.operation.find((oper) => oper.type === 13 && oper.element === id);
|
|
29186
29314
|
if (runtimeDirective) context.options.onError(createCompilerError(36, runtimeDirective.dir.loc));
|
|
29187
29315
|
}
|
|
29188
29316
|
return () => {
|
|
@@ -29191,7 +29319,7 @@ const transformSlotOutlet = (node, context) => {
|
|
|
29191
29319
|
if (context.options.scopeId && !context.options.slotted) flags |= 1;
|
|
29192
29320
|
if (context.inVOnce) flags |= 2;
|
|
29193
29321
|
context.dynamic.operation = _objectSpread2(_objectSpread2({
|
|
29194
|
-
type:
|
|
29322
|
+
type: 12,
|
|
29195
29323
|
id
|
|
29196
29324
|
}, context.effectBoundary()), {}, {
|
|
29197
29325
|
name: slotName,
|
|
@@ -29308,13 +29436,16 @@ function transformTemplateSlot(node, dir, context) {
|
|
|
29308
29436
|
};
|
|
29309
29437
|
ifNode.negative = negative;
|
|
29310
29438
|
} else context.options.onError(createCompilerError(30, vElse.loc));
|
|
29311
|
-
} else if (vFor) if (vFor.forParseResult)
|
|
29312
|
-
|
|
29313
|
-
|
|
29314
|
-
|
|
29315
|
-
|
|
29316
|
-
|
|
29317
|
-
|
|
29439
|
+
} else if (vFor) if (vFor.forParseResult) {
|
|
29440
|
+
const keyProp = findProp(node, "key");
|
|
29441
|
+
registerDynamicSlot(slots, {
|
|
29442
|
+
slotType: 2,
|
|
29443
|
+
name: arg,
|
|
29444
|
+
fn: block,
|
|
29445
|
+
loop: vFor.forParseResult,
|
|
29446
|
+
keyProp: keyProp && propToExpression(keyProp)
|
|
29447
|
+
});
|
|
29448
|
+
} else context.options.onError(createCompilerError(32, vFor.loc));
|
|
29318
29449
|
return onExit;
|
|
29319
29450
|
}
|
|
29320
29451
|
function ensureStaticSlots(slots) {
|
|
@@ -29391,7 +29522,7 @@ const transformKey = (node, context) => {
|
|
|
29391
29522
|
return () => {
|
|
29392
29523
|
exitBlock();
|
|
29393
29524
|
context.dynamic.operation = _objectSpread2(_objectSpread2({
|
|
29394
|
-
type:
|
|
29525
|
+
type: 16,
|
|
29395
29526
|
id
|
|
29396
29527
|
}, context.effectBoundary()), {}, {
|
|
29397
29528
|
value,
|
|
@@ -29759,6 +29890,7 @@ const ssrTransformElement = (node, context) => {
|
|
|
29759
29890
|
else {
|
|
29760
29891
|
attrName = node.tag.indexOf("-") > 0 ? attrName : propsToAttrMap[attrName] || attrName.toLowerCase();
|
|
29761
29892
|
if (isBooleanAttr(attrName)) openTag.push(createConditionalExpression(createCallExpression(context.helper(SSR_INCLUDE_BOOLEAN_ATTR), [value]), createSimpleExpression(" " + attrName, true), createSimpleExpression("", true), false));
|
|
29893
|
+
else if (attrName === "hidden") openTag.push(createCallExpression(context.helper(SSR_RENDER_DYNAMIC_ATTR), [key, value]));
|
|
29762
29894
|
else if (isSSRSafeAttrName(attrName)) openTag.push(createCallExpression(context.helper(SSR_RENDER_ATTR), [key, value]));
|
|
29763
29895
|
else context.onError(createSSRCompilerError(65, key.loc));
|
|
29764
29896
|
}
|
|
@@ -30411,10 +30543,12 @@ function doCompileTemplate({ filename, id, scoped, slotted, inMap, source, ast:
|
|
|
30411
30543
|
const defaultCompiler = ssr ? src_exports : vapor ? src_exports$1 : src_exports$2;
|
|
30412
30544
|
compiler = compiler || defaultCompiler;
|
|
30413
30545
|
if (compiler !== defaultCompiler) inAST = void 0;
|
|
30414
|
-
|
|
30415
|
-
|
|
30546
|
+
inAST = resolveTemplateAST(inAST, {
|
|
30547
|
+
compiler,
|
|
30548
|
+
compilerOptions,
|
|
30549
|
+
ssr,
|
|
30416
30550
|
onError: (e) => errors.push(e)
|
|
30417
|
-
})
|
|
30551
|
+
});
|
|
30418
30552
|
let { code, ast, preamble, map, helpers } = compiler.compile(inAST || source, _objectSpread2(_objectSpread2({
|
|
30419
30553
|
mode: "module",
|
|
30420
30554
|
prefixIdentifiers: true,
|
|
@@ -41423,7 +41557,13 @@ function resolveTypeReference(ctx, node, scope, name, onlyExported = false) {
|
|
|
41423
41557
|
return node._resolvedReference;
|
|
41424
41558
|
}
|
|
41425
41559
|
const resolved = innerResolveTypeReference(ctx, scope || ctxToScope(ctx), name || getReferenceName(node), node, onlyExported);
|
|
41426
|
-
|
|
41560
|
+
if (canCache) Object.defineProperty(node, "_resolvedReference", {
|
|
41561
|
+
value: resolved,
|
|
41562
|
+
writable: true,
|
|
41563
|
+
configurable: true,
|
|
41564
|
+
enumerable: false
|
|
41565
|
+
});
|
|
41566
|
+
return resolved;
|
|
41427
41567
|
}
|
|
41428
41568
|
function innerResolveTypeReference(ctx, scope, name, node, onlyExported) {
|
|
41429
41569
|
if (typeof name === "string") if (scope.imports[name]) return resolveTypeFromImport(ctx, node, name, scope);
|
|
@@ -42645,7 +42785,7 @@ function compileScript(sfc, options) {
|
|
|
42645
42785
|
}
|
|
42646
42786
|
function registerUserImport(source, local, imported, isType, isFromSetup, needTemplateUsageCheck) {
|
|
42647
42787
|
let isImportUsed = needTemplateUsageCheck;
|
|
42648
|
-
if (needTemplateUsageCheck && ctx.isTS && sfc.template && !sfc.template.src && !sfc.template.lang) isImportUsed = isUsedInTemplate(local, sfc);
|
|
42788
|
+
if (needTemplateUsageCheck && ctx.isTS && sfc.template && !sfc.template.src && !sfc.template.lang) isImportUsed = isUsedInTemplate(local, sfc, options.templateOptions);
|
|
42649
42789
|
ctx.userImports[local] = {
|
|
42650
42790
|
isType,
|
|
42651
42791
|
imported,
|
|
@@ -42848,7 +42988,7 @@ function compileScript(sfc, options) {
|
|
|
42848
42988
|
for (const key in scriptBindings) ctx.bindingMetadata[key] = scriptBindings[key];
|
|
42849
42989
|
for (const key in setupBindings) ctx.bindingMetadata[key] = setupBindings[key];
|
|
42850
42990
|
if (sfc.template && !sfc.template.src && sfc.template.ast) {
|
|
42851
|
-
const vModelIds = resolveTemplateVModelIdentifiers(sfc);
|
|
42991
|
+
const vModelIds = resolveTemplateVModelIdentifiers(sfc, options.templateOptions);
|
|
42852
42992
|
if (vModelIds.size) {
|
|
42853
42993
|
const toDemote = /* @__PURE__ */ new Set();
|
|
42854
42994
|
for (const id of vModelIds) if (setupBindings[id] === "setup-reactive-const") toDemote.add(id);
|
|
@@ -43105,7 +43245,7 @@ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
|
|
|
43105
43245
|
//#endregion
|
|
43106
43246
|
//#region packages/compiler-sfc/src/index.ts
|
|
43107
43247
|
init_objectSpread2();
|
|
43108
|
-
const version = "3.6.0-rc.
|
|
43248
|
+
const version = "3.6.0-rc.4";
|
|
43109
43249
|
const parseCache = parseCache$1;
|
|
43110
43250
|
const errorMessages = _objectSpread2(_objectSpread2({}, errorMessages$1), DOMErrorMessages);
|
|
43111
43251
|
const walk = walk$2;
|