@vue/compiler-sfc 3.6.0-beta.11 → 3.6.0-beta.12
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
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-sfc v3.6.0-beta.
|
|
2
|
+
* @vue/compiler-sfc v3.6.0-beta.12
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -197,33 +197,33 @@ function genNormalScriptCssVarsCode(cssVars, bindings, id, isProd, defaultVar) {
|
|
|
197
197
|
return `\nimport { ${CSS_VARS_HELPER} as _${CSS_VARS_HELPER} } from 'vue'\nconst __injectCSSVars__ = () => {\n${genCssVarsCode(cssVars, bindings, id, isProd)}}\nconst __setup__ = ${defaultVar}.setup\n${defaultVar}.setup = __setup__\n ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) }\n : __injectCSSVars__\n`;
|
|
198
198
|
}
|
|
199
199
|
//#endregion
|
|
200
|
-
//#region \0@oxc-project+runtime@0.
|
|
200
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/checkPrivateRedeclaration.js
|
|
201
201
|
function _checkPrivateRedeclaration(e, t) {
|
|
202
202
|
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
203
203
|
}
|
|
204
204
|
//#endregion
|
|
205
|
-
//#region \0@oxc-project+runtime@0.
|
|
205
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/classPrivateMethodInitSpec.js
|
|
206
206
|
function _classPrivateMethodInitSpec(e, a) {
|
|
207
207
|
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
208
208
|
}
|
|
209
209
|
//#endregion
|
|
210
|
-
//#region \0@oxc-project+runtime@0.
|
|
210
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/classPrivateFieldInitSpec.js
|
|
211
211
|
function _classPrivateFieldInitSpec(e, t, a) {
|
|
212
212
|
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
213
213
|
}
|
|
214
214
|
//#endregion
|
|
215
|
-
//#region \0@oxc-project+runtime@0.
|
|
215
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/assertClassBrand.js
|
|
216
216
|
function _assertClassBrand(e, t, n) {
|
|
217
217
|
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
218
218
|
throw new TypeError("Private element is not present on this object");
|
|
219
219
|
}
|
|
220
220
|
//#endregion
|
|
221
|
-
//#region \0@oxc-project+runtime@0.
|
|
221
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/classPrivateFieldGet2.js
|
|
222
222
|
function _classPrivateFieldGet2(s, a) {
|
|
223
223
|
return s.get(_assertClassBrand(s, a));
|
|
224
224
|
}
|
|
225
225
|
//#endregion
|
|
226
|
-
//#region \0@oxc-project+runtime@0.
|
|
226
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/classPrivateFieldSet2.js
|
|
227
227
|
function _classPrivateFieldSet2(s, a, r) {
|
|
228
228
|
return s.set(_assertClassBrand(s, a), r), r;
|
|
229
229
|
}
|
|
@@ -15282,7 +15282,7 @@ function compileScript(sfc, options) {
|
|
|
15282
15282
|
if (emitsDecl) runtimeOptions += `\n emits: ${emitsDecl},`;
|
|
15283
15283
|
if (vapor && !ssr && sfc.template && !sfc.template.src) {
|
|
15284
15284
|
var _options$templateOpti2;
|
|
15285
|
-
|
|
15285
|
+
if (isMultiRoot(sfc.template.ast, (_options$templateOpti2 = options.templateOptions) === null || _options$templateOpti2 === void 0 ? void 0 : _options$templateOpti2.compilerOptions)) runtimeOptions += `\n __multiRoot: true,`;
|
|
15286
15286
|
}
|
|
15287
15287
|
let definedOptions = "";
|
|
15288
15288
|
if (ctx.optionsRuntimeDecl) definedOptions = scriptSetup.content.slice(ctx.optionsRuntimeDecl.start, ctx.optionsRuntimeDecl.end).trim();
|
|
@@ -15440,7 +15440,7 @@ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
|
|
|
15440
15440
|
}
|
|
15441
15441
|
//#endregion
|
|
15442
15442
|
//#region packages/compiler-sfc/src/index.ts
|
|
15443
|
-
const version = "3.6.0-beta.
|
|
15443
|
+
const version = "3.6.0-beta.12";
|
|
15444
15444
|
const parseCache = parseCache$1;
|
|
15445
15445
|
const errorMessages = {
|
|
15446
15446
|
..._vue_compiler_dom.errorMessages,
|
package/dist/compiler-sfc.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as _babel_types0 from "@babel/types";
|
|
1
|
+
import * as _$_babel_types0 from "@babel/types";
|
|
2
2
|
import { CallExpression as CallExpression$1, Expression as Expression$1, Node as Node$1, ObjectPattern, Program as Program$1, Statement as Statement$1, TSCallSignatureDeclaration, TSFunctionType, TSMethodSignature, TSModuleDeclaration, TSPropertySignature, TSType } from "@babel/types";
|
|
3
3
|
import { BaseCodegenResult, BindingMetadata, BindingMetadata as BindingMetadata$1, CompilerError, CompilerError as CompilerError$1, CompilerOptions as CompilerOptions$1, CompilerOptions as CompilerOptions$2, ParserOptions, RawSourceMap, RootNode, SourceLocation, extractIdentifiers, generateCodeFrame, isInDestructureAssignment, isStaticProperty, walkIdentifiers } from "@vue/compiler-core";
|
|
4
4
|
import { ParserPlugin, parse as babelParse } from "@babel/parser";
|
|
@@ -185,8 +185,8 @@ export interface SFCScriptBlock extends SFCBlock {
|
|
|
185
185
|
setup?: string | boolean;
|
|
186
186
|
bindings?: BindingMetadata$1;
|
|
187
187
|
imports?: Record<string, ImportBinding>;
|
|
188
|
-
scriptAst?: _babel_types0.Statement[];
|
|
189
|
-
scriptSetupAst?: _babel_types0.Statement[];
|
|
188
|
+
scriptAst?: _$_babel_types0.Statement[];
|
|
189
|
+
scriptSetupAst?: _$_babel_types0.Statement[];
|
|
190
190
|
warnings?: string[];
|
|
191
191
|
/**
|
|
192
192
|
* Fully resolved dependency file paths (unix slashes) with imported types
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-sfc v3.6.0-beta.
|
|
2
|
+
* @vue/compiler-sfc v3.6.0-beta.12
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -41,7 +41,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
41
41
|
throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
42
42
|
});
|
|
43
43
|
//#endregion
|
|
44
|
-
//#region \0@oxc-project+runtime@0.
|
|
44
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
|
|
45
45
|
function _typeof(o) {
|
|
46
46
|
"@babel/helpers - typeof";
|
|
47
47
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -52,7 +52,7 @@ function _typeof(o) {
|
|
|
52
52
|
}
|
|
53
53
|
var init_typeof = __esmMin((() => {}));
|
|
54
54
|
//#endregion
|
|
55
|
-
//#region \0@oxc-project+runtime@0.
|
|
55
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
|
|
56
56
|
function toPrimitive(t, r) {
|
|
57
57
|
if ("object" != _typeof(t) || !t) return t;
|
|
58
58
|
var e = t[Symbol.toPrimitive];
|
|
@@ -67,7 +67,7 @@ var init_toPrimitive = __esmMin((() => {
|
|
|
67
67
|
init_typeof();
|
|
68
68
|
}));
|
|
69
69
|
//#endregion
|
|
70
|
-
//#region \0@oxc-project+runtime@0.
|
|
70
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
|
|
71
71
|
function toPropertyKey(t) {
|
|
72
72
|
var i = toPrimitive(t, "string");
|
|
73
73
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
@@ -77,7 +77,7 @@ var init_toPropertyKey = __esmMin((() => {
|
|
|
77
77
|
init_toPrimitive();
|
|
78
78
|
}));
|
|
79
79
|
//#endregion
|
|
80
|
-
//#region \0@oxc-project+runtime@0.
|
|
80
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
|
|
81
81
|
function _defineProperty(e, r, t) {
|
|
82
82
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
83
83
|
value: t,
|
|
@@ -90,7 +90,7 @@ var init_defineProperty = __esmMin((() => {
|
|
|
90
90
|
init_toPropertyKey();
|
|
91
91
|
}));
|
|
92
92
|
//#endregion
|
|
93
|
-
//#region \0@oxc-project+runtime@0.
|
|
93
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/objectSpread2.js
|
|
94
94
|
function ownKeys(e, r) {
|
|
95
95
|
var t = Object.keys(e);
|
|
96
96
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -1069,6 +1069,12 @@ function write(buffer, value, offset, isLE, mLen, nBytes) {
|
|
|
1069
1069
|
for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8);
|
|
1070
1070
|
buffer[offset + i - d] |= s * 128;
|
|
1071
1071
|
}
|
|
1072
|
+
/*!
|
|
1073
|
+
* The buffer module from node.js, for the browser.
|
|
1074
|
+
*
|
|
1075
|
+
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
1076
|
+
* @license MIT
|
|
1077
|
+
*/
|
|
1072
1078
|
function kMaxLength() {
|
|
1073
1079
|
return Buffer$1.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823;
|
|
1074
1080
|
}
|
|
@@ -16182,7 +16188,7 @@ var require_lib$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
16182
16188
|
exports.parseExpression = parseExpression;
|
|
16183
16189
|
}));
|
|
16184
16190
|
//#endregion
|
|
16185
|
-
//#region \0@oxc-project+runtime@0.
|
|
16191
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/asyncToGenerator.js
|
|
16186
16192
|
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
16187
16193
|
try {
|
|
16188
16194
|
var i = n[a](c), u = i.value;
|
|
@@ -23365,6 +23371,7 @@ var init__polyfill_node_path = __esmMin((() => {
|
|
|
23365
23371
|
}));
|
|
23366
23372
|
//#endregion
|
|
23367
23373
|
//#region \0polyfill-node.punycode.js
|
|
23374
|
+
/*! https://mths.be/punycode v1.4.1 by @mathias */
|
|
23368
23375
|
/**
|
|
23369
23376
|
* A generic error utility function.
|
|
23370
23377
|
* @private
|
|
@@ -24910,7 +24917,8 @@ var TransformContext = class TransformContext {
|
|
|
24910
24917
|
this.operationIndex = this.block.operation.length;
|
|
24911
24918
|
this.isLastEffectiveChild = true;
|
|
24912
24919
|
this.isOnRightmostPath = true;
|
|
24913
|
-
this.
|
|
24920
|
+
this.templateCloseTags = void 0;
|
|
24921
|
+
this.templateCloseBlocks = false;
|
|
24914
24922
|
this.globalId = 0;
|
|
24915
24923
|
this.nextIdMap = null;
|
|
24916
24924
|
this.ifIndex = 0;
|
|
@@ -25036,11 +25044,6 @@ var TransformContext = class TransformContext {
|
|
|
25036
25044
|
while (effectiveParent && effectiveParent.node.type === 1 && effectiveParent.node.tagType === 3) effectiveParent = effectiveParent.parent;
|
|
25037
25045
|
const isLastEffectiveChild = this.isEffectivelyLastChild(index);
|
|
25038
25046
|
const isOnRightmostPath = this.isOnRightmostPath && isLastEffectiveChild;
|
|
25039
|
-
let hasInlineAncestorNeedingClose = this.hasInlineAncestorNeedingClose;
|
|
25040
|
-
if (this.node.type === 1) {
|
|
25041
|
-
if (this.node.tag === "template") hasInlineAncestorNeedingClose = false;
|
|
25042
|
-
else if (!hasInlineAncestorNeedingClose && !this.isOnRightmostPath && isInlineTag(this.node.tag)) hasInlineAncestorNeedingClose = true;
|
|
25043
|
-
}
|
|
25044
25047
|
return Object.assign(Object.create(TransformContext.prototype), this, {
|
|
25045
25048
|
node,
|
|
25046
25049
|
parent: this,
|
|
@@ -25055,7 +25058,8 @@ var TransformContext = class TransformContext {
|
|
|
25055
25058
|
effectiveParent,
|
|
25056
25059
|
isLastEffectiveChild,
|
|
25057
25060
|
isOnRightmostPath,
|
|
25058
|
-
|
|
25061
|
+
templateCloseTags: this.templateCloseTags,
|
|
25062
|
+
templateCloseBlocks: this.templateCloseBlocks
|
|
25059
25063
|
});
|
|
25060
25064
|
}
|
|
25061
25065
|
shiftEffectBoundaries(index, dynamic = this.dynamic) {
|
|
@@ -25248,6 +25252,9 @@ function genCall(name, ...frags) {
|
|
|
25248
25252
|
hasPlaceholder ? name[1] : "null"
|
|
25249
25253
|
], ...frags)];
|
|
25250
25254
|
}
|
|
25255
|
+
function getParserOptions(plugins) {
|
|
25256
|
+
return { plugins: plugins ? plugins.some((plugin) => plugin === "typescript") ? plugins : [...plugins, "typescript"] : ["typescript"] };
|
|
25257
|
+
}
|
|
25251
25258
|
function codeFragmentToString(code, context) {
|
|
25252
25259
|
const { options: { filename, sourceMap } } = context;
|
|
25253
25260
|
let map;
|
|
@@ -25630,9 +25637,7 @@ function escapeRegExp(string) {
|
|
|
25630
25637
|
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
25631
25638
|
}
|
|
25632
25639
|
function parseExp(context, content) {
|
|
25633
|
-
|
|
25634
|
-
const options = { plugins: plugins ? [...plugins, "typescript"] : ["typescript"] };
|
|
25635
|
-
return (0, import_lib.parseExpression)(`(${content})`, options);
|
|
25640
|
+
return (0, import_lib.parseExpression)(`(${content})`, getParserOptions(context.options.expressionPlugins));
|
|
25636
25641
|
}
|
|
25637
25642
|
function genVarName(exp) {
|
|
25638
25643
|
return `${exp.replace(/[^a-zA-Z0-9]/g, "_").replace(/_+/g, "_").replace(/_+$/, "")}`;
|
|
@@ -25810,16 +25815,12 @@ function genFor(oper, context) {
|
|
|
25810
25815
|
idMap[rawIndex] = `${indexVar}.value`;
|
|
25811
25816
|
idMap[indexVar] = null;
|
|
25812
25817
|
}
|
|
25813
|
-
const { selectorPatterns, keyOnlyBindingPatterns } = matchPatterns(render, keyProp, idMap);
|
|
25818
|
+
const { selectorPatterns, keyOnlyBindingPatterns } = matchPatterns(render, keyProp, idMap, context);
|
|
25814
25819
|
const selectorDeclarations = [];
|
|
25815
|
-
const
|
|
25820
|
+
const selectorName = (i) => selectorPatterns.length > 1 ? `_selector${id}_${i}` : `_selector${id}`;
|
|
25816
25821
|
for (let i = 0; i < selectorPatterns.length; i++) {
|
|
25817
25822
|
const { selector } = selectorPatterns[i];
|
|
25818
|
-
const selectorName = `
|
|
25819
|
-
selectorDeclarations.push(`let ${selectorName}`, NEWLINE);
|
|
25820
|
-
if (i === 0) selectorSetup.push(`({ createSelector }) => {`, INDENT_START);
|
|
25821
|
-
selectorSetup.push(NEWLINE, `${selectorName} = `, ...genCall(`createSelector`, [`() => `, ...genExpression(selector, context)]));
|
|
25822
|
-
if (i === selectorPatterns.length - 1) selectorSetup.push(INDENT_END, NEWLINE, "}");
|
|
25823
|
+
selectorDeclarations.push(`const ${selectorName(i)} = `, ...genCall(helper("createSelector"), [`() => `, ...genExpression(selector, context)]), NEWLINE);
|
|
25823
25824
|
}
|
|
25824
25825
|
const blockFn = context.withId(() => {
|
|
25825
25826
|
const frag = [];
|
|
@@ -25828,7 +25829,7 @@ function genFor(oper, context) {
|
|
|
25828
25829
|
const patternFrag = [];
|
|
25829
25830
|
for (let i = 0; i < selectorPatterns.length; i++) {
|
|
25830
25831
|
const { effect } = selectorPatterns[i];
|
|
25831
|
-
patternFrag.push(NEWLINE,
|
|
25832
|
+
patternFrag.push(NEWLINE, `${selectorName(i)}(`, ...genExpression(keyProp, context), `, () => {`, INDENT_START);
|
|
25832
25833
|
for (const oper of effect.operations) patternFrag.push(...genOperation(oper, context));
|
|
25833
25834
|
patternFrag.push(INDENT_END, NEWLINE, `})`);
|
|
25834
25835
|
}
|
|
@@ -25844,11 +25845,14 @@ function genFor(oper, context) {
|
|
|
25844
25845
|
if (onlyChild) flags |= 1;
|
|
25845
25846
|
if (component) flags |= 2;
|
|
25846
25847
|
if (once) flags |= 4;
|
|
25848
|
+
const onResetCalls = [];
|
|
25849
|
+
for (let i = 0; i < selectorPatterns.length; i++) onResetCalls.push(NEWLINE, `n${id}.onReset(${selectorName(i)}.reset)`);
|
|
25847
25850
|
return [
|
|
25848
25851
|
NEWLINE,
|
|
25849
25852
|
...selectorDeclarations,
|
|
25850
25853
|
`const n${id} = `,
|
|
25851
|
-
...genCall([helper("createFor"), "undefined"], sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0,
|
|
25854
|
+
...genCall([helper("createFor"), "undefined"], sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0),
|
|
25855
|
+
...onResetCalls
|
|
25852
25856
|
];
|
|
25853
25857
|
function genCallback(expr) {
|
|
25854
25858
|
if (!expr) return false;
|
|
@@ -25934,19 +25938,19 @@ function buildDestructureIdMap(idToPathMap, baseAccessor, plugins) {
|
|
|
25934
25938
|
}
|
|
25935
25939
|
if (pathInfo.dynamic) {
|
|
25936
25940
|
const node = idMap[id] = createSimpleExpression(path);
|
|
25937
|
-
node.ast = (0, import_lib.parseExpression)(`(${path})`,
|
|
25941
|
+
node.ast = (0, import_lib.parseExpression)(`(${path})`, getParserOptions(plugins));
|
|
25938
25942
|
} else idMap[id] = path;
|
|
25939
25943
|
} else idMap[id] = path;
|
|
25940
25944
|
});
|
|
25941
25945
|
return idMap;
|
|
25942
25946
|
}
|
|
25943
|
-
function matchPatterns(render, keyProp, idMap) {
|
|
25947
|
+
function matchPatterns(render, keyProp, idMap, context) {
|
|
25944
25948
|
const selectorPatterns = [];
|
|
25945
25949
|
const keyOnlyBindingPatterns = [];
|
|
25946
25950
|
const removedEffectIndexes = [];
|
|
25947
25951
|
render.effect = render.effect.filter((effect, index) => {
|
|
25948
25952
|
if (keyProp !== void 0) {
|
|
25949
|
-
const selector = matchSelectorPattern(effect, keyProp.content, idMap);
|
|
25953
|
+
const selector = matchSelectorPattern(effect, keyProp.content, idMap, context);
|
|
25950
25954
|
if (selector) {
|
|
25951
25955
|
selectorPatterns.push(selector);
|
|
25952
25956
|
removedEffectIndexes.push(index);
|
|
@@ -25985,7 +25989,7 @@ function matchKeyOnlyBindingPattern(effect, key) {
|
|
|
25985
25989
|
}
|
|
25986
25990
|
}
|
|
25987
25991
|
}
|
|
25988
|
-
function matchSelectorPattern(effect, key, idMap) {
|
|
25992
|
+
function matchSelectorPattern(effect, key, idMap, context) {
|
|
25989
25993
|
if (effect.expressions.length === 1) {
|
|
25990
25994
|
const { ast, content } = effect.expressions[0];
|
|
25991
25995
|
if (typeof ast === "object" && ast) {
|
|
@@ -26010,17 +26014,11 @@ function matchSelectorPattern(effect, key, idMap) {
|
|
|
26010
26014
|
}, false);
|
|
26011
26015
|
if (!hasExtraId) {
|
|
26012
26016
|
const name = content.slice(selector.start - 1, selector.end - 1);
|
|
26017
|
+
const selectorExpression = createSimpleExpression(name, false, selector.loc);
|
|
26018
|
+
selectorExpression.ast = (0, import_lib.parseExpression)(`(${name})`, getParserOptions(context.options.expressionPlugins));
|
|
26013
26019
|
return {
|
|
26014
26020
|
effect,
|
|
26015
|
-
selector:
|
|
26016
|
-
content: name,
|
|
26017
|
-
ast: extend({}, selector, {
|
|
26018
|
-
start: 1,
|
|
26019
|
-
end: name.length + 1
|
|
26020
|
-
}),
|
|
26021
|
-
loc: selector.loc,
|
|
26022
|
-
isStatic: false
|
|
26023
|
-
}
|
|
26021
|
+
selector: selectorExpression
|
|
26024
26022
|
};
|
|
26025
26023
|
}
|
|
26026
26024
|
}
|
|
@@ -26082,6 +26080,7 @@ const helpers = {
|
|
|
26082
26080
|
setText: { name: "setText" },
|
|
26083
26081
|
setHtml: { name: "setHtml" },
|
|
26084
26082
|
setClass: { name: "setClass" },
|
|
26083
|
+
setClassName: { name: "setClassName" },
|
|
26085
26084
|
setStyle: { name: "setStyle" },
|
|
26086
26085
|
setValue: { name: "setValue" },
|
|
26087
26086
|
setAttr: {
|
|
@@ -26101,9 +26100,132 @@ function genSetProp(oper, context) {
|
|
|
26101
26100
|
const { helper } = context;
|
|
26102
26101
|
const { prop: { key, values, modifier }, tag } = oper;
|
|
26103
26102
|
const resolvedHelper = getRuntimeHelper(tag, key.content, modifier);
|
|
26103
|
+
if (key.content === "class" && !resolvedHelper.isSVG && resolvedHelper.name === "setClass") {
|
|
26104
|
+
const className = genSetClassName(oper, context);
|
|
26105
|
+
if (className) return className;
|
|
26106
|
+
}
|
|
26104
26107
|
const propValue = genPropValue(values, context);
|
|
26105
26108
|
return [NEWLINE, ...genCall([helper(resolvedHelper.name), null], `n${oper.element}`, resolvedHelper.needKey ? genExpression(key, context) : false, propValue, resolvedHelper.isSVG && "true")];
|
|
26106
26109
|
}
|
|
26110
|
+
const MAX_CLASS_NAME_ENTRIES = 31;
|
|
26111
|
+
function genSetClassName(oper, context) {
|
|
26112
|
+
const info = resolveClassName(oper.prop.values, context);
|
|
26113
|
+
if (!info) return;
|
|
26114
|
+
const { helper } = context;
|
|
26115
|
+
const flags = genClassFlags(info.entries, context);
|
|
26116
|
+
const classFragments = info.entries.map((entry) => JSON.stringify(!info.prefix && info.entries.length === 1 ? entry.className : ` ${entry.className}`));
|
|
26117
|
+
const fragments = classFragments.length === 1 ? classFragments[0] : genMulti(DELIMITERS_ARRAY, ...classFragments);
|
|
26118
|
+
return [NEWLINE, ...genCall([helper("setClassName"), "\"\""], `n${oper.element}`, flags, fragments, info.prefix && JSON.stringify(info.prefix), info.suffix && JSON.stringify(info.suffix))];
|
|
26119
|
+
}
|
|
26120
|
+
function resolveClassName(values, context) {
|
|
26121
|
+
let prefix = "";
|
|
26122
|
+
let suffix = "";
|
|
26123
|
+
const entries = [];
|
|
26124
|
+
let sawDynamic = false;
|
|
26125
|
+
let sawSuffix = false;
|
|
26126
|
+
for (const value of values) {
|
|
26127
|
+
const staticValue = getLiteralExpressionValue(value, true);
|
|
26128
|
+
if (staticValue != null) {
|
|
26129
|
+
const normalized = normalizeClass(staticValue);
|
|
26130
|
+
if (normalized) if (sawSuffix) suffix = appendClass(suffix, normalized);
|
|
26131
|
+
else if (sawDynamic) {
|
|
26132
|
+
sawSuffix = true;
|
|
26133
|
+
suffix = appendClass(suffix, normalized);
|
|
26134
|
+
} else prefix = appendClass(prefix, normalized);
|
|
26135
|
+
continue;
|
|
26136
|
+
}
|
|
26137
|
+
const ast = value.ast;
|
|
26138
|
+
if (!ast || sawSuffix) return;
|
|
26139
|
+
sawDynamic = true;
|
|
26140
|
+
if (ast.type === "ObjectExpression") {
|
|
26141
|
+
if (!resolveObjectClassName(value, ast, entries, context)) return;
|
|
26142
|
+
} else if (ast.type === "ConditionalExpression") {
|
|
26143
|
+
if (!resolveConditionalClassName(value, ast, entries, context)) return;
|
|
26144
|
+
} else return;
|
|
26145
|
+
}
|
|
26146
|
+
return entries.length && entries.length <= MAX_CLASS_NAME_ENTRIES ? {
|
|
26147
|
+
prefix,
|
|
26148
|
+
suffix,
|
|
26149
|
+
entries
|
|
26150
|
+
} : void 0;
|
|
26151
|
+
}
|
|
26152
|
+
function resolveObjectClassName(source, ast, entries, context) {
|
|
26153
|
+
for (const prop of ast.properties) {
|
|
26154
|
+
if (prop.type !== "ObjectProperty" || prop.computed) return false;
|
|
26155
|
+
const rawClassName = getObjectPropertyName(prop);
|
|
26156
|
+
if (rawClassName == null) return false;
|
|
26157
|
+
const className = normalizeClass(rawClassName);
|
|
26158
|
+
if (!className) continue;
|
|
26159
|
+
const value = getBooleanValue(prop.value);
|
|
26160
|
+
entries.push({
|
|
26161
|
+
className,
|
|
26162
|
+
value,
|
|
26163
|
+
condition: value == null ? createSubExpression(source, prop.value, context) : void 0
|
|
26164
|
+
});
|
|
26165
|
+
}
|
|
26166
|
+
return true;
|
|
26167
|
+
}
|
|
26168
|
+
function resolveConditionalClassName(source, ast, entries, context) {
|
|
26169
|
+
const consequent = getStringClassValue(ast.consequent);
|
|
26170
|
+
const alternate = getStringClassValue(ast.alternate);
|
|
26171
|
+
if (consequent && alternate === "") {
|
|
26172
|
+
entries.push({
|
|
26173
|
+
className: consequent,
|
|
26174
|
+
condition: createSubExpression(source, ast.test, context)
|
|
26175
|
+
});
|
|
26176
|
+
return true;
|
|
26177
|
+
} else if (alternate && consequent === "") {
|
|
26178
|
+
entries.push({
|
|
26179
|
+
className: alternate,
|
|
26180
|
+
condition: createSubExpression(source, ast.test, context),
|
|
26181
|
+
negate: true
|
|
26182
|
+
});
|
|
26183
|
+
return true;
|
|
26184
|
+
}
|
|
26185
|
+
return false;
|
|
26186
|
+
}
|
|
26187
|
+
function genClassFlags(entries, context) {
|
|
26188
|
+
const values = [];
|
|
26189
|
+
entries.forEach((entry, index) => {
|
|
26190
|
+
if (index) values.push(" | ");
|
|
26191
|
+
const bit = 1 << index;
|
|
26192
|
+
if (entry.value != null) {
|
|
26193
|
+
values.push(entry.value ? String(bit) : "0");
|
|
26194
|
+
return;
|
|
26195
|
+
}
|
|
26196
|
+
values.push("(", ...genExpression(entry.condition, context), entry.negate ? ` ? 0 : ${bit}` : ` ? ${bit} : 0`, ")");
|
|
26197
|
+
});
|
|
26198
|
+
return values;
|
|
26199
|
+
}
|
|
26200
|
+
function appendClass(base, value) {
|
|
26201
|
+
return base ? value ? `${base} ${value}` : base : value;
|
|
26202
|
+
}
|
|
26203
|
+
function getObjectPropertyName(prop) {
|
|
26204
|
+
const key = prop.key;
|
|
26205
|
+
if (key.type === "Identifier") return key.name;
|
|
26206
|
+
else if (key.type === "StringLiteral") return key.value;
|
|
26207
|
+
else if (key.type === "NumericLiteral") return String(key.value);
|
|
26208
|
+
}
|
|
26209
|
+
function getStringClassValue(node) {
|
|
26210
|
+
if (node.type === "StringLiteral") return normalizeClass(node.value);
|
|
26211
|
+
else if (node.type === "TemplateLiteral" && node.expressions.length === 0) return normalizeClass(node.quasis[0].value.cooked || "");
|
|
26212
|
+
else if (node.type === "NullLiteral" || node.type === "BooleanLiteral" && !node.value) return "";
|
|
26213
|
+
}
|
|
26214
|
+
function getBooleanValue(node) {
|
|
26215
|
+
if (node.type === "BooleanLiteral") return node.value;
|
|
26216
|
+
}
|
|
26217
|
+
function createSubExpression(source, node, context) {
|
|
26218
|
+
const start = node.start == null ? 0 : node.start - 1;
|
|
26219
|
+
const end = node.end == null ? source.content.length : node.end - 1;
|
|
26220
|
+
const content = source.content.slice(start, end);
|
|
26221
|
+
const expression = createSimpleExpression(content, false, {
|
|
26222
|
+
start: advancePositionWithClone(source.loc.start, source.content, start),
|
|
26223
|
+
end: advancePositionWithClone(source.loc.start, source.content, end),
|
|
26224
|
+
source: content
|
|
26225
|
+
});
|
|
26226
|
+
expression.ast = isSimpleIdentifier(content) ? null : (0, import_lib.parseExpression)(`(${content})`, getParserOptions(context.options.expressionPlugins));
|
|
26227
|
+
return expression;
|
|
26228
|
+
}
|
|
26107
26229
|
function genDynamicProps$1(oper, context) {
|
|
26108
26230
|
const { helper } = context;
|
|
26109
26231
|
const isSVG = isSVGTag(oper.tag);
|
|
@@ -26513,11 +26635,23 @@ function genDynamicSlot(slot, context, withFunction = false) {
|
|
|
26513
26635
|
frag = genConditionalSlot(slot, context);
|
|
26514
26636
|
break;
|
|
26515
26637
|
}
|
|
26516
|
-
|
|
26638
|
+
if (!withFunction) return frag;
|
|
26639
|
+
return needsDynamicSlotSourceCtx(slot) ? [
|
|
26640
|
+
`${context.helper("withVaporCtx")}(() => (`,
|
|
26641
|
+
...frag,
|
|
26642
|
+
"))"
|
|
26643
|
+
] : [
|
|
26517
26644
|
"() => (",
|
|
26518
26645
|
...frag,
|
|
26519
26646
|
")"
|
|
26520
|
-
]
|
|
26647
|
+
];
|
|
26648
|
+
}
|
|
26649
|
+
function needsDynamicSlotSourceCtx(slot) {
|
|
26650
|
+
switch (slot.slotType) {
|
|
26651
|
+
case 1: return needsVaporCtx(slot.fn);
|
|
26652
|
+
case 2: return needsVaporCtx(slot.fn);
|
|
26653
|
+
case 3: return needsDynamicSlotSourceCtx(slot.positive) || (slot.negative ? needsDynamicSlotSourceCtx(slot.negative) : false);
|
|
26654
|
+
}
|
|
26521
26655
|
}
|
|
26522
26656
|
function genBasicDynamicSlot(slot, context) {
|
|
26523
26657
|
const { name, fn } = slot;
|
|
@@ -27072,11 +27206,35 @@ function canOmitEndTag(node, context) {
|
|
|
27072
27206
|
const { block, parent } = context;
|
|
27073
27207
|
if (!parent) return false;
|
|
27074
27208
|
if (block !== parent.block) return true;
|
|
27209
|
+
if (context.templateCloseTags && (context.templateCloseTags.has(node.tag) || isAlwaysCloseTag(node.tag) || isFormattingTag(node.tag)) || context.templateCloseBlocks && isBlockTag(node.tag)) return false;
|
|
27075
27210
|
if (isAlwaysCloseTag(node.tag) && !context.isOnRightmostPath) return false;
|
|
27076
27211
|
if (isFormattingTag(node.tag) || parent.node.type === 1 && node.tag === parent.node.tag) return context.isOnRightmostPath;
|
|
27077
|
-
if (isBlockTag(node.tag) && context.hasInlineAncestorNeedingClose) return false;
|
|
27078
27212
|
return context.isLastEffectiveChild;
|
|
27079
27213
|
}
|
|
27214
|
+
function getChildTemplateCloseState(context) {
|
|
27215
|
+
const { node } = context;
|
|
27216
|
+
if (node.type !== 1 || node.tagType !== 0 || shouldUseCreateElement(node, context)) return;
|
|
27217
|
+
const inSameTemplateAsParent = isInSameTemplateAsParent(context);
|
|
27218
|
+
const inheritedTags = inSameTemplateAsParent ? context.templateCloseTags : void 0;
|
|
27219
|
+
const inheritedBlocks = inSameTemplateAsParent && context.templateCloseBlocks;
|
|
27220
|
+
if (context.root === context.effectiveParent || canOmitEndTag(node, context) || isVoidTag(node.tag)) return inheritedTags || inheritedBlocks ? {
|
|
27221
|
+
tags: inheritedTags,
|
|
27222
|
+
blocks: inheritedBlocks
|
|
27223
|
+
} : void 0;
|
|
27224
|
+
const tags = new Set(inheritedTags);
|
|
27225
|
+
tags.add(node.tag);
|
|
27226
|
+
return {
|
|
27227
|
+
tags,
|
|
27228
|
+
blocks: inheritedBlocks || isInlineTag(node.tag)
|
|
27229
|
+
};
|
|
27230
|
+
}
|
|
27231
|
+
function isInSameTemplateAsParent(context) {
|
|
27232
|
+
const { parent, node, block } = context;
|
|
27233
|
+
if (!parent || block !== parent.block) return false;
|
|
27234
|
+
const parentNode = parent.node;
|
|
27235
|
+
if (parentNode.type !== 1 || parentNode.tagType !== 0) return false;
|
|
27236
|
+
return !shouldUseCreateElement(parentNode, parent) && isValidHTMLNesting(parentNode.tag, node.tag);
|
|
27237
|
+
}
|
|
27080
27238
|
function isSingleRoot(context) {
|
|
27081
27239
|
if (context.inVFor) return false;
|
|
27082
27240
|
let { parent } = context;
|
|
@@ -27340,8 +27498,12 @@ const transformChildren = (node, context) => {
|
|
|
27340
27498
|
const isFragment = node.type === 0 || node.type === 1 && (node.tagType === 3 || node.tagType === 1);
|
|
27341
27499
|
if (!isFragment && node.type !== 1) return;
|
|
27342
27500
|
const useCreateElement = node.type === 1 && shouldUseCreateElement(node, context);
|
|
27501
|
+
const childTemplateCloseState = !isFragment && !useCreateElement ? getChildTemplateCloseState(context) : void 0;
|
|
27343
27502
|
for (const [i, child] of node.children.entries()) {
|
|
27344
27503
|
const childContext = context.create(child, i);
|
|
27504
|
+
const isInSameTemplate = childTemplateCloseState && child.type === 1 && child.tagType === 0 && isInSameTemplateAsParent(childContext);
|
|
27505
|
+
childContext.templateCloseTags = isInSameTemplate ? childTemplateCloseState.tags : void 0;
|
|
27506
|
+
childContext.templateCloseBlocks = isInSameTemplate ? childTemplateCloseState.blocks : false;
|
|
27345
27507
|
transformNode(childContext);
|
|
27346
27508
|
const childDynamic = childContext.dynamic;
|
|
27347
27509
|
if (isFragment) {
|
|
@@ -30400,7 +30562,7 @@ var require_document = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
30400
30562
|
Document.default = Document;
|
|
30401
30563
|
}));
|
|
30402
30564
|
//#endregion
|
|
30403
|
-
//#region \0@oxc-project+runtime@0.
|
|
30565
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/objectWithoutPropertiesLoose.js
|
|
30404
30566
|
function _objectWithoutPropertiesLoose(r, e) {
|
|
30405
30567
|
if (null == r) return {};
|
|
30406
30568
|
var t = {};
|
|
@@ -30412,7 +30574,7 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
30412
30574
|
}
|
|
30413
30575
|
var init_objectWithoutPropertiesLoose = __esmMin((() => {}));
|
|
30414
30576
|
//#endregion
|
|
30415
|
-
//#region \0@oxc-project+runtime@0.
|
|
30577
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/objectWithoutProperties.js
|
|
30416
30578
|
function _objectWithoutProperties(e, t) {
|
|
30417
30579
|
if (null == e) return {};
|
|
30418
30580
|
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
@@ -41151,7 +41313,7 @@ function compileScript(sfc, options) {
|
|
|
41151
41313
|
if (emitsDecl) runtimeOptions += `\n emits: ${emitsDecl},`;
|
|
41152
41314
|
if (vapor && !ssr && sfc.template && !sfc.template.src) {
|
|
41153
41315
|
var _options$templateOpti2;
|
|
41154
|
-
|
|
41316
|
+
if (isMultiRoot(sfc.template.ast, (_options$templateOpti2 = options.templateOptions) === null || _options$templateOpti2 === void 0 ? void 0 : _options$templateOpti2.compilerOptions)) runtimeOptions += `\n __multiRoot: true,`;
|
|
41155
41317
|
}
|
|
41156
41318
|
let definedOptions = "";
|
|
41157
41319
|
if (ctx.optionsRuntimeDecl) definedOptions = scriptSetup.content.slice(ctx.optionsRuntimeDecl.start, ctx.optionsRuntimeDecl.end).trim();
|
|
@@ -41309,7 +41471,7 @@ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
|
|
|
41309
41471
|
//#endregion
|
|
41310
41472
|
//#region packages/compiler-sfc/src/index.ts
|
|
41311
41473
|
init_objectSpread2();
|
|
41312
|
-
const version = "3.6.0-beta.
|
|
41474
|
+
const version = "3.6.0-beta.12";
|
|
41313
41475
|
const parseCache = parseCache$1;
|
|
41314
41476
|
const errorMessages = _objectSpread2(_objectSpread2({}, errorMessages$1), DOMErrorMessages);
|
|
41315
41477
|
const walk = walk$2;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/compiler-sfc",
|
|
3
|
-
"version": "3.6.0-beta.
|
|
3
|
+
"version": "3.6.0-beta.12",
|
|
4
4
|
"description": "@vue/compiler-sfc",
|
|
5
5
|
"main": "dist/compiler-sfc.cjs.js",
|
|
6
6
|
"module": "dist/compiler-sfc.esm-browser.js",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"magic-string": "^0.30.21",
|
|
48
48
|
"postcss": "^8.5.14",
|
|
49
49
|
"source-map-js": "^1.2.1",
|
|
50
|
-
"@vue/compiler-core": "3.6.0-beta.
|
|
51
|
-
"@vue/compiler-dom": "3.6.0-beta.
|
|
52
|
-
"@vue/compiler-
|
|
53
|
-
"@vue/
|
|
54
|
-
"@vue/
|
|
50
|
+
"@vue/compiler-core": "3.6.0-beta.12",
|
|
51
|
+
"@vue/compiler-dom": "3.6.0-beta.12",
|
|
52
|
+
"@vue/compiler-ssr": "3.6.0-beta.12",
|
|
53
|
+
"@vue/shared": "3.6.0-beta.12",
|
|
54
|
+
"@vue/compiler-vapor": "3.6.0-beta.12"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@babel/types": "^7.29.0",
|