@vue/compiler-sfc 3.4.27 → 3.4.29
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 +246 -186
- package/dist/compiler-sfc.esm-browser.js +621 -574
- package/package.json +10 -10
package/dist/compiler-sfc.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-sfc v3.4.
|
|
2
|
+
* @vue/compiler-sfc v3.4.29
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -44,8 +44,7 @@ function resolveObjectKey(node, computed) {
|
|
|
44
44
|
case "NumericLiteral":
|
|
45
45
|
return String(node.value);
|
|
46
46
|
case "Identifier":
|
|
47
|
-
if (!computed)
|
|
48
|
-
return node.name;
|
|
47
|
+
if (!computed) return node.name;
|
|
49
48
|
}
|
|
50
49
|
return void 0;
|
|
51
50
|
}
|
|
@@ -64,8 +63,7 @@ function toRuntimeTypeString(types) {
|
|
|
64
63
|
function getImportedName(specifier) {
|
|
65
64
|
if (specifier.type === "ImportSpecifier")
|
|
66
65
|
return specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value;
|
|
67
|
-
else if (specifier.type === "ImportNamespaceSpecifier")
|
|
68
|
-
return "*";
|
|
66
|
+
else if (specifier.type === "ImportNamespaceSpecifier") return "*";
|
|
69
67
|
return "default";
|
|
70
68
|
}
|
|
71
69
|
function getId(node) {
|
|
@@ -1764,8 +1762,7 @@ function resolveTemplateUsedIdentifiers(sfc) {
|
|
|
1764
1762
|
switch (node.type) {
|
|
1765
1763
|
case 1:
|
|
1766
1764
|
let tag = node.tag;
|
|
1767
|
-
if (tag.includes("."))
|
|
1768
|
-
tag = tag.split(".")[0].trim();
|
|
1765
|
+
if (tag.includes(".")) tag = tag.split(".")[0].trim();
|
|
1769
1766
|
if (!CompilerDOM.parserOptions.isNativeTag(tag) && !CompilerDOM.parserOptions.isBuiltInComponent(tag)) {
|
|
1770
1767
|
ids.add(shared.camelize(tag));
|
|
1771
1768
|
ids.add(shared.capitalize(shared.camelize(tag)));
|
|
@@ -2257,11 +2254,9 @@ const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
|
|
|
2257
2254
|
if (srcsetTags.includes(node.tag) && node.props.length) {
|
|
2258
2255
|
node.props.forEach((attr, index) => {
|
|
2259
2256
|
if (attr.name === "srcset" && attr.type === 6) {
|
|
2260
|
-
if (!attr.value)
|
|
2261
|
-
return;
|
|
2257
|
+
if (!attr.value) return;
|
|
2262
2258
|
const value = attr.value.content;
|
|
2263
|
-
if (!value)
|
|
2264
|
-
return;
|
|
2259
|
+
if (!value) return;
|
|
2265
2260
|
const imageCandidates = value.split(",").map((s) => {
|
|
2266
2261
|
const [url, descriptor] = s.replace(escapedSpaceCharacters, " ").trim().split(" ", 2);
|
|
2267
2262
|
return { url, descriptor };
|
|
@@ -4192,13 +4187,11 @@ function preprocess$1({ source, filename, preprocessOptions }, preprocessor) {
|
|
|
4192
4187
|
source,
|
|
4193
4188
|
{ filename, ...preprocessOptions },
|
|
4194
4189
|
(_err, _res) => {
|
|
4195
|
-
if (_err)
|
|
4196
|
-
err = _err;
|
|
4190
|
+
if (_err) err = _err;
|
|
4197
4191
|
res = _res;
|
|
4198
4192
|
}
|
|
4199
4193
|
);
|
|
4200
|
-
if (err)
|
|
4201
|
-
throw err;
|
|
4194
|
+
if (err) throw err;
|
|
4202
4195
|
return res;
|
|
4203
4196
|
}
|
|
4204
4197
|
function compileTemplate(options) {
|
|
@@ -4264,11 +4257,11 @@ function doCompileTemplate({
|
|
|
4264
4257
|
}
|
|
4265
4258
|
if (ssr && !ssrCssVars) {
|
|
4266
4259
|
warnOnce(
|
|
4267
|
-
`compileTemplate is called with \`ssr: true\` but no corresponding \`cssVars\` option
|
|
4260
|
+
`compileTemplate is called with \`ssr: true\` but no corresponding \`cssVars\` option.`
|
|
4268
4261
|
);
|
|
4269
4262
|
}
|
|
4270
4263
|
if (!id) {
|
|
4271
|
-
warnOnce(`compileTemplate now requires the \`id\` option
|
|
4264
|
+
warnOnce(`compileTemplate now requires the \`id\` option.`);
|
|
4272
4265
|
id = "";
|
|
4273
4266
|
}
|
|
4274
4267
|
const shortId = id.replace(/^data-v-/, "");
|
|
@@ -4329,10 +4322,8 @@ ${shared.generateCodeFrame(
|
|
|
4329
4322
|
return { code, ast, preamble, source, errors, tips, map };
|
|
4330
4323
|
}
|
|
4331
4324
|
function mapLines(oldMap, newMap) {
|
|
4332
|
-
if (!oldMap)
|
|
4333
|
-
|
|
4334
|
-
if (!newMap)
|
|
4335
|
-
return oldMap;
|
|
4325
|
+
if (!oldMap) return newMap;
|
|
4326
|
+
if (!newMap) return oldMap;
|
|
4336
4327
|
const oldMapConsumer = new sourceMapJs.SourceMapConsumer(oldMap);
|
|
4337
4328
|
const newMapConsumer = new sourceMapJs.SourceMapConsumer(newMap);
|
|
4338
4329
|
const mergedMapGenerator = new sourceMapJs.SourceMapGenerator();
|
|
@@ -4397,10 +4388,8 @@ const trimPlugin = () => {
|
|
|
4397
4388
|
Once(root) {
|
|
4398
4389
|
root.walk(({ type, raws }) => {
|
|
4399
4390
|
if (type === "rule" || type === "atrule") {
|
|
4400
|
-
if (raws.before)
|
|
4401
|
-
|
|
4402
|
-
if ("after" in raws && raws.after)
|
|
4403
|
-
raws.after = "\n";
|
|
4391
|
+
if (raws.before) raws.before = "\n";
|
|
4392
|
+
if ("after" in raws && raws.after) raws.after = "\n";
|
|
4404
4393
|
}
|
|
4405
4394
|
});
|
|
4406
4395
|
}
|
|
@@ -6583,7 +6572,8 @@ tokenTypes.combinator = combinator$1;
|
|
|
6583
6572
|
line: 1,
|
|
6584
6573
|
column: 1
|
|
6585
6574
|
}
|
|
6586
|
-
}
|
|
6575
|
+
},
|
|
6576
|
+
sourceIndex: 0
|
|
6587
6577
|
});
|
|
6588
6578
|
this.root.append(selector);
|
|
6589
6579
|
this.current = selector;
|
|
@@ -7042,7 +7032,8 @@ tokenTypes.combinator = combinator$1;
|
|
|
7042
7032
|
var selector = new _selector["default"]({
|
|
7043
7033
|
source: {
|
|
7044
7034
|
start: tokenStart(this.tokens[this.position + 1])
|
|
7045
|
-
}
|
|
7035
|
+
},
|
|
7036
|
+
sourceIndex: this.tokens[this.position + 1][_tokenize.FIELDS.START_POS]
|
|
7046
7037
|
});
|
|
7047
7038
|
this.current.parent.append(selector);
|
|
7048
7039
|
this.current = selector;
|
|
@@ -7111,8 +7102,9 @@ tokenTypes.combinator = combinator$1;
|
|
|
7111
7102
|
if (last && last.type === types.PSEUDO) {
|
|
7112
7103
|
var selector = new _selector["default"]({
|
|
7113
7104
|
source: {
|
|
7114
|
-
start: tokenStart(this.tokens[this.position
|
|
7115
|
-
}
|
|
7105
|
+
start: tokenStart(this.tokens[this.position])
|
|
7106
|
+
},
|
|
7107
|
+
sourceIndex: this.tokens[this.position][_tokenize.FIELDS.START_POS]
|
|
7116
7108
|
});
|
|
7117
7109
|
var cache = this.current;
|
|
7118
7110
|
last.append(selector);
|
|
@@ -7960,8 +7952,7 @@ function rewriteSelector(id, selector, selectorRoot, slotted = false) {
|
|
|
7960
7952
|
return false;
|
|
7961
7953
|
}
|
|
7962
7954
|
}
|
|
7963
|
-
if (node)
|
|
7964
|
-
return;
|
|
7955
|
+
if (node) return;
|
|
7965
7956
|
}
|
|
7966
7957
|
if (n.type !== "pseudo" && n.type !== "combinator" || n.type === "pseudo" && (n.value === ":is" || n.value === ":where") && !node) {
|
|
7967
7958
|
node = n;
|
|
@@ -11274,8 +11265,7 @@ const less = (source, map, options, load = require) => {
|
|
|
11274
11265
|
result = output;
|
|
11275
11266
|
}
|
|
11276
11267
|
);
|
|
11277
|
-
if (error)
|
|
11278
|
-
return { code: "", errors: [error], dependencies: [] };
|
|
11268
|
+
if (error) return { code: "", errors: [error], dependencies: [] };
|
|
11279
11269
|
const dependencies = result.imports;
|
|
11280
11270
|
if (map) {
|
|
11281
11271
|
return {
|
|
@@ -11295,8 +11285,7 @@ const styl = (source, map, options, load = require) => {
|
|
|
11295
11285
|
const nodeStylus = load("stylus");
|
|
11296
11286
|
try {
|
|
11297
11287
|
const ref = nodeStylus(source, options);
|
|
11298
|
-
if (map)
|
|
11299
|
-
ref.set("sourcemap", { inline: false, comment: false });
|
|
11288
|
+
if (map) ref.set("sourcemap", { inline: false, comment: false });
|
|
11300
11289
|
const result = ref.render();
|
|
11301
11290
|
const dependencies = ref.deps();
|
|
11302
11291
|
if (map) {
|
|
@@ -11313,8 +11302,7 @@ const styl = (source, map, options, load = require) => {
|
|
|
11313
11302
|
}
|
|
11314
11303
|
};
|
|
11315
11304
|
function getSource(source, filename, additionalData) {
|
|
11316
|
-
if (!additionalData)
|
|
11317
|
-
return source;
|
|
11305
|
+
if (!additionalData) return source;
|
|
11318
11306
|
if (shared.isFunction(additionalData)) {
|
|
11319
11307
|
return additionalData(source, filename);
|
|
11320
11308
|
}
|
|
@@ -15604,11 +15592,9 @@ function analyzeBindingsFromOptions(node) {
|
|
|
15604
15592
|
function getObjectExpressionKeys(node) {
|
|
15605
15593
|
const keys = [];
|
|
15606
15594
|
for (const prop of node.properties) {
|
|
15607
|
-
if (prop.type === "SpreadElement")
|
|
15608
|
-
continue;
|
|
15595
|
+
if (prop.type === "SpreadElement") continue;
|
|
15609
15596
|
const key = resolveObjectKey(prop.key, prop.computed);
|
|
15610
|
-
if (key)
|
|
15611
|
-
keys.push(String(key));
|
|
15597
|
+
if (key) keys.push(String(key));
|
|
15612
15598
|
}
|
|
15613
15599
|
return keys;
|
|
15614
15600
|
}
|
|
@@ -15722,12 +15708,12 @@ function resolveParserPlugins(lang, userPlugins, dts = false) {
|
|
|
15722
15708
|
)) {
|
|
15723
15709
|
plugins.push("importAttributes");
|
|
15724
15710
|
}
|
|
15725
|
-
if (lang === "jsx" || lang === "tsx") {
|
|
15711
|
+
if (lang === "jsx" || lang === "tsx" || lang === "mtsx") {
|
|
15726
15712
|
plugins.push("jsx");
|
|
15727
15713
|
} else if (userPlugins) {
|
|
15728
15714
|
userPlugins = userPlugins.filter((p) => p !== "jsx");
|
|
15729
15715
|
}
|
|
15730
|
-
if (lang === "ts" || lang === "tsx") {
|
|
15716
|
+
if (lang === "ts" || lang === "mts" || lang === "tsx" || lang === "mtsx") {
|
|
15731
15717
|
plugins.push(["typescript", { dts }], "explicitResourceManagement");
|
|
15732
15718
|
if (!userPlugins || !userPlugins.includes("decorators")) {
|
|
15733
15719
|
plugins.push("decorators-legacy");
|
|
@@ -17945,6 +17931,9 @@ function resolveTypeElements(ctx, node, scope, typeParameters) {
|
|
|
17945
17931
|
}
|
|
17946
17932
|
function innerResolveTypeElements(ctx, node, scope, typeParameters) {
|
|
17947
17933
|
var _a, _b;
|
|
17934
|
+
if (node.leadingComments && node.leadingComments.some((c) => c.value.includes("@vue-ignore"))) {
|
|
17935
|
+
return { props: {} };
|
|
17936
|
+
}
|
|
17948
17937
|
switch (node.type) {
|
|
17949
17938
|
case "TSTypeLiteral":
|
|
17950
17939
|
return typeElementsToMap(ctx, node.members, scope, typeParameters);
|
|
@@ -17968,7 +17957,7 @@ function innerResolveTypeElements(ctx, node, scope, typeParameters) {
|
|
|
17968
17957
|
node.type
|
|
17969
17958
|
);
|
|
17970
17959
|
case "TSMappedType":
|
|
17971
|
-
return resolveMappedType(ctx, node, scope);
|
|
17960
|
+
return resolveMappedType(ctx, node, scope, typeParameters);
|
|
17972
17961
|
case "TSIndexedAccessType": {
|
|
17973
17962
|
const types = resolveIndexType(ctx, node, scope);
|
|
17974
17963
|
return mergeElements(
|
|
@@ -17997,8 +17986,7 @@ function innerResolveTypeElements(ctx, node, scope, typeParameters) {
|
|
|
17997
17986
|
typeParams = /* @__PURE__ */ Object.create(null);
|
|
17998
17987
|
resolved.typeParameters.params.forEach((p, i) => {
|
|
17999
17988
|
let param = typeParameters && typeParameters[p.name];
|
|
18000
|
-
if (!param)
|
|
18001
|
-
param = node.typeParameters.params[i];
|
|
17989
|
+
if (!param) param = node.typeParameters.params[i];
|
|
18002
17990
|
typeParams[p.name] = param;
|
|
18003
17991
|
});
|
|
18004
17992
|
}
|
|
@@ -18108,8 +18096,7 @@ function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx), typeParameter
|
|
|
18108
18096
|
return res;
|
|
18109
18097
|
}
|
|
18110
18098
|
function mergeElements(maps, type) {
|
|
18111
|
-
if (maps.length === 1)
|
|
18112
|
-
return maps[0];
|
|
18099
|
+
if (maps.length === 1) return maps[0];
|
|
18113
18100
|
const res = { props: {} };
|
|
18114
18101
|
const { props: baseProps } = res;
|
|
18115
18102
|
for (const { props, calls } of maps) {
|
|
@@ -18157,9 +18144,6 @@ function resolveInterfaceMembers(ctx, node, scope, typeParameters) {
|
|
|
18157
18144
|
);
|
|
18158
18145
|
if (node.extends) {
|
|
18159
18146
|
for (const ext of node.extends) {
|
|
18160
|
-
if (ext.leadingComments && ext.leadingComments.some((c) => c.value.includes("@vue-ignore"))) {
|
|
18161
|
-
continue;
|
|
18162
|
-
}
|
|
18163
18147
|
try {
|
|
18164
18148
|
const { props, calls } = resolveTypeElements(ctx, ext, scope);
|
|
18165
18149
|
for (const key in props) {
|
|
@@ -18179,16 +18163,25 @@ If this previously worked in 3.2, you can instruct the compiler to ignore this e
|
|
|
18179
18163
|
interface Props extends /* @vue-ignore */ Base {}
|
|
18180
18164
|
|
|
18181
18165
|
Note: both in 3.2 or with the ignore, the properties in the base type are treated as fallthrough attrs at runtime.`,
|
|
18182
|
-
ext
|
|
18166
|
+
ext,
|
|
18167
|
+
scope
|
|
18183
18168
|
);
|
|
18184
18169
|
}
|
|
18185
18170
|
}
|
|
18186
18171
|
}
|
|
18187
18172
|
return base;
|
|
18188
18173
|
}
|
|
18189
|
-
function resolveMappedType(ctx, node, scope) {
|
|
18174
|
+
function resolveMappedType(ctx, node, scope, typeParameters) {
|
|
18190
18175
|
const res = { props: {} };
|
|
18191
|
-
|
|
18176
|
+
let keys;
|
|
18177
|
+
if (node.nameType) {
|
|
18178
|
+
const { name, constraint } = node.typeParameter;
|
|
18179
|
+
scope = createChildScope(scope);
|
|
18180
|
+
Object.assign(scope.types, { ...typeParameters, [name]: constraint });
|
|
18181
|
+
keys = resolveStringType(ctx, node.nameType, scope);
|
|
18182
|
+
} else {
|
|
18183
|
+
keys = resolveStringType(ctx, node.typeParameter.constraint, scope);
|
|
18184
|
+
}
|
|
18192
18185
|
for (const key of keys) {
|
|
18193
18186
|
res.props[key] = createProperty(
|
|
18194
18187
|
{
|
|
@@ -18533,13 +18526,12 @@ function importSourceToScope(ctx, node, scope, source) {
|
|
|
18533
18526
|
const osSpecificJoinFn = process__namespace.platform === "win32" ? path$3.join : joinPaths;
|
|
18534
18527
|
const filename = osSpecificJoinFn(path$3.dirname(scope.filename), source);
|
|
18535
18528
|
resolved = resolveExt(filename, fs);
|
|
18536
|
-
} else if (source
|
|
18529
|
+
} else if (source[0] === ".") {
|
|
18537
18530
|
const filename = joinPaths(path$3.dirname(scope.filename), source);
|
|
18538
18531
|
resolved = resolveExt(filename, fs);
|
|
18539
18532
|
} else {
|
|
18540
18533
|
if (!ts) {
|
|
18541
|
-
if (loadTS)
|
|
18542
|
-
ts = loadTS();
|
|
18534
|
+
if (loadTS) ts = loadTS();
|
|
18543
18535
|
if (!ts) {
|
|
18544
18536
|
return ctx.error(
|
|
18545
18537
|
`Failed to resolve import source ${JSON.stringify(source)}. typescript is required as a peer dep for vue in order to support resolving types from module imports.`,
|
|
@@ -18568,8 +18560,7 @@ function importSourceToScope(ctx, node, scope, source) {
|
|
|
18568
18560
|
function resolveExt(filename, fs) {
|
|
18569
18561
|
filename = filename.replace(/\.js$/, "");
|
|
18570
18562
|
const tryResolve = (filename2) => {
|
|
18571
|
-
if (fs.fileExists(filename2))
|
|
18572
|
-
return filename2;
|
|
18563
|
+
if (fs.fileExists(filename2)) return filename2;
|
|
18573
18564
|
};
|
|
18574
18565
|
return tryResolve(filename) || tryResolve(filename + `.ts`) || tryResolve(filename + `.tsx`) || tryResolve(filename + `.d.ts`) || tryResolve(joinPaths(filename, `index.ts`)) || tryResolve(joinPaths(filename, `index.tsx`)) || tryResolve(joinPaths(filename, `index.d.ts`));
|
|
18575
18566
|
}
|
|
@@ -18600,7 +18591,7 @@ function resolveWithTS(containingFile, source, ts2, fs) {
|
|
|
18600
18591
|
);
|
|
18601
18592
|
const included = (_a = c.config.raw) == null ? void 0 : _a.include;
|
|
18602
18593
|
const excluded = (_b = c.config.raw) == null ? void 0 : _b.exclude;
|
|
18603
|
-
if (!included && (!base || containingFile.startsWith(base)) || included.some((p) => minimatch(containingFile, joinPaths(base, p)))) {
|
|
18594
|
+
if (!included && (!base || containingFile.startsWith(base)) || (included == null ? void 0 : included.some((p) => minimatch(containingFile, joinPaths(base, p))))) {
|
|
18604
18595
|
if (excluded && excluded.some((p) => minimatch(containingFile, joinPaths(base, p)))) {
|
|
18605
18596
|
continue;
|
|
18606
18597
|
}
|
|
@@ -18648,8 +18639,12 @@ function loadTSConfig(configPath, ts2, fs) {
|
|
|
18648
18639
|
const res = [config];
|
|
18649
18640
|
if (config.projectReferences) {
|
|
18650
18641
|
for (const ref of config.projectReferences) {
|
|
18651
|
-
|
|
18652
|
-
|
|
18642
|
+
const refPath = ts2.resolveProjectReferencePath(ref);
|
|
18643
|
+
if (!fs.fileExists(refPath)) {
|
|
18644
|
+
continue;
|
|
18645
|
+
}
|
|
18646
|
+
tsConfigRefMap.set(refPath, configPath);
|
|
18647
|
+
res.unshift(...loadTSConfig(refPath, ts2, fs));
|
|
18653
18648
|
}
|
|
18654
18649
|
}
|
|
18655
18650
|
return res;
|
|
@@ -18660,8 +18655,7 @@ function invalidateTypeCache(filename) {
|
|
|
18660
18655
|
fileToScopeCache.delete(filename);
|
|
18661
18656
|
tsConfigCache.delete(filename);
|
|
18662
18657
|
const affectedConfig = tsConfigRefMap.get(filename);
|
|
18663
|
-
if (affectedConfig)
|
|
18664
|
-
tsConfigCache.delete(affectedConfig);
|
|
18658
|
+
if (affectedConfig) tsConfigCache.delete(affectedConfig);
|
|
18665
18659
|
}
|
|
18666
18660
|
function fileToScope(ctx, filename, asGlobal = false) {
|
|
18667
18661
|
const cached = fileToScopeCache.get(filename);
|
|
@@ -18678,12 +18672,12 @@ function fileToScope(ctx, filename, asGlobal = false) {
|
|
|
18678
18672
|
}
|
|
18679
18673
|
function parseFile(filename, content, parserPlugins) {
|
|
18680
18674
|
const ext = path$3.extname(filename);
|
|
18681
|
-
if (ext === ".ts" || ext === ".tsx") {
|
|
18675
|
+
if (ext === ".ts" || ext === ".mts" || ext === ".tsx" || ext === ".mtsx") {
|
|
18682
18676
|
return parser$1.parse(content, {
|
|
18683
18677
|
plugins: resolveParserPlugins(
|
|
18684
18678
|
ext.slice(1),
|
|
18685
18679
|
parserPlugins,
|
|
18686
|
-
|
|
18680
|
+
/\.d\.m?ts$/.test(filename)
|
|
18687
18681
|
),
|
|
18688
18682
|
sourceType: "module"
|
|
18689
18683
|
}).program.body;
|
|
@@ -18824,8 +18818,7 @@ function recordTypes(ctx, body, scope, asGlobal = false) {
|
|
|
18824
18818
|
for (const key of Object.keys(types)) {
|
|
18825
18819
|
const node = types[key];
|
|
18826
18820
|
node._ownerScope = scope;
|
|
18827
|
-
if (node._ns)
|
|
18828
|
-
node._ns._ownerScope = scope;
|
|
18821
|
+
if (node._ns) node._ns._ownerScope = scope;
|
|
18829
18822
|
}
|
|
18830
18823
|
for (const key of Object.keys(declares)) {
|
|
18831
18824
|
declares[key]._ownerScope = scope;
|
|
@@ -18866,15 +18859,13 @@ function recordType(node, types, declares, overwriteId) {
|
|
|
18866
18859
|
break;
|
|
18867
18860
|
}
|
|
18868
18861
|
case "ClassDeclaration":
|
|
18869
|
-
if (overwriteId || node.id)
|
|
18870
|
-
types[overwriteId || getId(node.id)] = node;
|
|
18862
|
+
if (overwriteId || node.id) types[overwriteId || getId(node.id)] = node;
|
|
18871
18863
|
break;
|
|
18872
18864
|
case "TSTypeAliasDeclaration":
|
|
18873
18865
|
types[node.id.name] = node.typeParameters ? node : node.typeAnnotation;
|
|
18874
18866
|
break;
|
|
18875
18867
|
case "TSDeclareFunction":
|
|
18876
|
-
if (node.id)
|
|
18877
|
-
declares[node.id.name] = node;
|
|
18868
|
+
if (node.id) declares[node.id.name] = node;
|
|
18878
18869
|
break;
|
|
18879
18870
|
case "VariableDeclaration": {
|
|
18880
18871
|
if (node.declare) {
|
|
@@ -18959,6 +18950,17 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
|
|
|
18959
18950
|
if (isKeyOf) {
|
|
18960
18951
|
if (m.type === "TSPropertySignature" && m.key.type === "NumericLiteral") {
|
|
18961
18952
|
types.add("Number");
|
|
18953
|
+
} else if (m.type === "TSIndexSignature") {
|
|
18954
|
+
const annotation = m.parameters[0].typeAnnotation;
|
|
18955
|
+
if (annotation && annotation.type !== "Noop") {
|
|
18956
|
+
const type = inferRuntimeType(
|
|
18957
|
+
ctx,
|
|
18958
|
+
annotation.typeAnnotation,
|
|
18959
|
+
scope
|
|
18960
|
+
)[0];
|
|
18961
|
+
if (type === UNKNOWN_TYPE) return [UNKNOWN_TYPE];
|
|
18962
|
+
types.add(type);
|
|
18963
|
+
}
|
|
18962
18964
|
} else {
|
|
18963
18965
|
types.add("String");
|
|
18964
18966
|
}
|
|
@@ -18968,7 +18970,7 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
|
|
|
18968
18970
|
types.add("Object");
|
|
18969
18971
|
}
|
|
18970
18972
|
}
|
|
18971
|
-
return types.size ? Array.from(types) : ["Object"];
|
|
18973
|
+
return types.size ? Array.from(types) : [isKeyOf ? UNKNOWN_TYPE : "Object"];
|
|
18972
18974
|
}
|
|
18973
18975
|
case "TSPropertySignature":
|
|
18974
18976
|
if (node.typeAnnotation) {
|
|
@@ -19008,73 +19010,113 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
|
|
|
19008
19010
|
case "String":
|
|
19009
19011
|
case "Array":
|
|
19010
19012
|
case "ArrayLike":
|
|
19013
|
+
case "Parameters":
|
|
19014
|
+
case "ConstructorParameters":
|
|
19011
19015
|
case "ReadonlyArray":
|
|
19012
19016
|
return ["String", "Number"];
|
|
19013
|
-
|
|
19017
|
+
case "Record":
|
|
19018
|
+
case "Partial":
|
|
19019
|
+
case "Required":
|
|
19020
|
+
case "Readonly":
|
|
19021
|
+
if (node.typeParameters && node.typeParameters.params[0]) {
|
|
19022
|
+
return inferRuntimeType(
|
|
19023
|
+
ctx,
|
|
19024
|
+
node.typeParameters.params[0],
|
|
19025
|
+
scope,
|
|
19026
|
+
true
|
|
19027
|
+
);
|
|
19028
|
+
}
|
|
19029
|
+
break;
|
|
19030
|
+
case "Pick":
|
|
19031
|
+
case "Extract":
|
|
19032
|
+
if (node.typeParameters && node.typeParameters.params[1]) {
|
|
19033
|
+
return inferRuntimeType(
|
|
19034
|
+
ctx,
|
|
19035
|
+
node.typeParameters.params[1],
|
|
19036
|
+
scope
|
|
19037
|
+
);
|
|
19038
|
+
}
|
|
19039
|
+
break;
|
|
19040
|
+
case "Function":
|
|
19041
|
+
case "Object":
|
|
19042
|
+
case "Set":
|
|
19043
|
+
case "Map":
|
|
19044
|
+
case "WeakSet":
|
|
19045
|
+
case "WeakMap":
|
|
19046
|
+
case "Date":
|
|
19047
|
+
case "Promise":
|
|
19048
|
+
case "Error":
|
|
19049
|
+
case "Uppercase":
|
|
19050
|
+
case "Lowercase":
|
|
19051
|
+
case "Capitalize":
|
|
19052
|
+
case "Uncapitalize":
|
|
19053
|
+
case "ReadonlyMap":
|
|
19054
|
+
case "ReadonlySet":
|
|
19014
19055
|
return ["String"];
|
|
19015
19056
|
}
|
|
19016
|
-
}
|
|
19017
|
-
|
|
19018
|
-
|
|
19019
|
-
|
|
19020
|
-
|
|
19021
|
-
|
|
19022
|
-
|
|
19023
|
-
|
|
19024
|
-
|
|
19025
|
-
|
|
19026
|
-
|
|
19027
|
-
|
|
19028
|
-
|
|
19029
|
-
|
|
19030
|
-
|
|
19031
|
-
|
|
19032
|
-
|
|
19033
|
-
|
|
19034
|
-
|
|
19035
|
-
|
|
19036
|
-
|
|
19037
|
-
|
|
19038
|
-
|
|
19039
|
-
|
|
19040
|
-
|
|
19041
|
-
|
|
19042
|
-
|
|
19043
|
-
|
|
19044
|
-
|
|
19045
|
-
|
|
19046
|
-
|
|
19047
|
-
|
|
19048
|
-
|
|
19049
|
-
|
|
19050
|
-
|
|
19051
|
-
|
|
19052
|
-
|
|
19053
|
-
|
|
19054
|
-
|
|
19055
|
-
|
|
19056
|
-
|
|
19057
|
-
|
|
19058
|
-
|
|
19059
|
-
|
|
19060
|
-
|
|
19061
|
-
|
|
19062
|
-
|
|
19063
|
-
|
|
19064
|
-
|
|
19065
|
-
|
|
19066
|
-
|
|
19067
|
-
|
|
19068
|
-
|
|
19069
|
-
|
|
19070
|
-
|
|
19071
|
-
|
|
19072
|
-
|
|
19073
|
-
|
|
19074
|
-
|
|
19075
|
-
|
|
19076
|
-
|
|
19077
|
-
|
|
19057
|
+
} else {
|
|
19058
|
+
switch (node.typeName.name) {
|
|
19059
|
+
case "Array":
|
|
19060
|
+
case "Function":
|
|
19061
|
+
case "Object":
|
|
19062
|
+
case "Set":
|
|
19063
|
+
case "Map":
|
|
19064
|
+
case "WeakSet":
|
|
19065
|
+
case "WeakMap":
|
|
19066
|
+
case "Date":
|
|
19067
|
+
case "Promise":
|
|
19068
|
+
case "Error":
|
|
19069
|
+
return [node.typeName.name];
|
|
19070
|
+
case "Partial":
|
|
19071
|
+
case "Required":
|
|
19072
|
+
case "Readonly":
|
|
19073
|
+
case "Record":
|
|
19074
|
+
case "Pick":
|
|
19075
|
+
case "Omit":
|
|
19076
|
+
case "InstanceType":
|
|
19077
|
+
return ["Object"];
|
|
19078
|
+
case "Uppercase":
|
|
19079
|
+
case "Lowercase":
|
|
19080
|
+
case "Capitalize":
|
|
19081
|
+
case "Uncapitalize":
|
|
19082
|
+
return ["String"];
|
|
19083
|
+
case "Parameters":
|
|
19084
|
+
case "ConstructorParameters":
|
|
19085
|
+
case "ReadonlyArray":
|
|
19086
|
+
return ["Array"];
|
|
19087
|
+
case "ReadonlyMap":
|
|
19088
|
+
return ["Map"];
|
|
19089
|
+
case "ReadonlySet":
|
|
19090
|
+
return ["Set"];
|
|
19091
|
+
case "NonNullable":
|
|
19092
|
+
if (node.typeParameters && node.typeParameters.params[0]) {
|
|
19093
|
+
return inferRuntimeType(
|
|
19094
|
+
ctx,
|
|
19095
|
+
node.typeParameters.params[0],
|
|
19096
|
+
scope
|
|
19097
|
+
).filter((t) => t !== "null");
|
|
19098
|
+
}
|
|
19099
|
+
break;
|
|
19100
|
+
case "Extract":
|
|
19101
|
+
if (node.typeParameters && node.typeParameters.params[1]) {
|
|
19102
|
+
return inferRuntimeType(
|
|
19103
|
+
ctx,
|
|
19104
|
+
node.typeParameters.params[1],
|
|
19105
|
+
scope
|
|
19106
|
+
);
|
|
19107
|
+
}
|
|
19108
|
+
break;
|
|
19109
|
+
case "Exclude":
|
|
19110
|
+
case "OmitThisParameter":
|
|
19111
|
+
if (node.typeParameters && node.typeParameters.params[0]) {
|
|
19112
|
+
return inferRuntimeType(
|
|
19113
|
+
ctx,
|
|
19114
|
+
node.typeParameters.params[0],
|
|
19115
|
+
scope
|
|
19116
|
+
);
|
|
19117
|
+
}
|
|
19118
|
+
break;
|
|
19119
|
+
}
|
|
19078
19120
|
}
|
|
19079
19121
|
}
|
|
19080
19122
|
break;
|
|
@@ -19082,9 +19124,9 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
|
|
|
19082
19124
|
case "TSParenthesizedType":
|
|
19083
19125
|
return inferRuntimeType(ctx, node.typeAnnotation, scope);
|
|
19084
19126
|
case "TSUnionType":
|
|
19085
|
-
return flattenTypes(ctx, node.types, scope);
|
|
19127
|
+
return flattenTypes(ctx, node.types, scope, isKeyOf);
|
|
19086
19128
|
case "TSIntersectionType": {
|
|
19087
|
-
return flattenTypes(ctx, node.types, scope).filter(
|
|
19129
|
+
return flattenTypes(ctx, node.types, scope, isKeyOf).filter(
|
|
19088
19130
|
(t) => t !== UNKNOWN_TYPE
|
|
19089
19131
|
);
|
|
19090
19132
|
}
|
|
@@ -19129,19 +19171,25 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
|
|
|
19129
19171
|
node.operator === "keyof"
|
|
19130
19172
|
);
|
|
19131
19173
|
}
|
|
19174
|
+
case "TSAnyKeyword": {
|
|
19175
|
+
if (isKeyOf) {
|
|
19176
|
+
return ["String", "Number", "Symbol"];
|
|
19177
|
+
}
|
|
19178
|
+
break;
|
|
19179
|
+
}
|
|
19132
19180
|
}
|
|
19133
19181
|
} catch (e) {
|
|
19134
19182
|
}
|
|
19135
19183
|
return [UNKNOWN_TYPE];
|
|
19136
19184
|
}
|
|
19137
|
-
function flattenTypes(ctx, types, scope) {
|
|
19185
|
+
function flattenTypes(ctx, types, scope, isKeyOf = false) {
|
|
19138
19186
|
if (types.length === 1) {
|
|
19139
|
-
return inferRuntimeType(ctx, types[0], scope);
|
|
19187
|
+
return inferRuntimeType(ctx, types[0], scope, isKeyOf);
|
|
19140
19188
|
}
|
|
19141
19189
|
return [
|
|
19142
19190
|
...new Set(
|
|
19143
19191
|
[].concat(
|
|
19144
|
-
...types.map((t) => inferRuntimeType(ctx, t, scope))
|
|
19192
|
+
...types.map((t) => inferRuntimeType(ctx, t, scope, isKeyOf))
|
|
19145
19193
|
)
|
|
19146
19194
|
)
|
|
19147
19195
|
];
|
|
@@ -19197,8 +19245,7 @@ function reverseInferType(key, node, scope, optional = true, checkObjectSyntax =
|
|
|
19197
19245
|
if ((node.type === "TSTypeReference" || node.type === "TSImportType") && node.typeParameters) {
|
|
19198
19246
|
for (const t of node.typeParameters.params) {
|
|
19199
19247
|
const inferred = reverseInferType(key, t, scope, optional);
|
|
19200
|
-
if (inferred)
|
|
19201
|
-
return inferred;
|
|
19248
|
+
if (inferred) return inferred;
|
|
19202
19249
|
}
|
|
19203
19250
|
}
|
|
19204
19251
|
return createProperty(key, { type: `TSNullKeyword` }, scope, optional);
|
|
@@ -19238,8 +19285,7 @@ function resolveReturnType(ctx, arg, scope) {
|
|
|
19238
19285
|
if (arg.type === "TSTypeReference" || arg.type === "TSTypeQuery" || arg.type === "TSImportType") {
|
|
19239
19286
|
resolved = resolveTypeReference(ctx, arg, scope);
|
|
19240
19287
|
}
|
|
19241
|
-
if (!resolved)
|
|
19242
|
-
return;
|
|
19288
|
+
if (!resolved) return;
|
|
19243
19289
|
if (resolved.type === "TSFunctionType") {
|
|
19244
19290
|
return (_a = resolved.typeAnnotation) == null ? void 0 : _a.typeAnnotation;
|
|
19245
19291
|
}
|
|
@@ -19250,8 +19296,7 @@ function resolveReturnType(ctx, arg, scope) {
|
|
|
19250
19296
|
function resolveUnionType(ctx, node, scope) {
|
|
19251
19297
|
if (node.type === "TSTypeReference") {
|
|
19252
19298
|
const resolved = resolveTypeReference(ctx, node, scope);
|
|
19253
|
-
if (resolved)
|
|
19254
|
-
node = resolved;
|
|
19299
|
+
if (resolved) node = resolved;
|
|
19255
19300
|
}
|
|
19256
19301
|
let types;
|
|
19257
19302
|
if (node.type === "TSUnionType") {
|
|
@@ -19328,8 +19373,7 @@ function processDefineModel(ctx, node, declId) {
|
|
|
19328
19373
|
return true;
|
|
19329
19374
|
}
|
|
19330
19375
|
function genModelProps(ctx) {
|
|
19331
|
-
if (!ctx.hasDefineModelCall)
|
|
19332
|
-
return;
|
|
19376
|
+
if (!ctx.hasDefineModelCall) return;
|
|
19333
19377
|
const isProd = !!ctx.options.isProd;
|
|
19334
19378
|
let modelPropsDecl = "";
|
|
19335
19379
|
for (const [name, { type, options: runtimeOptions }] of Object.entries(
|
|
@@ -19531,8 +19575,7 @@ function genRuntimePropFromType(ctx, { key, required, type, skipCheck }, hasStat
|
|
|
19531
19575
|
} else if (hasStaticDefaults) {
|
|
19532
19576
|
const prop = ctx.propsRuntimeDefaults.properties.find(
|
|
19533
19577
|
(node) => {
|
|
19534
|
-
if (node.type === "SpreadElement")
|
|
19535
|
-
return false;
|
|
19578
|
+
if (node.type === "SpreadElement") return false;
|
|
19536
19579
|
return resolveObjectKey(node.key, node.computed) === key;
|
|
19537
19580
|
}
|
|
19538
19581
|
);
|
|
@@ -19704,8 +19747,7 @@ function transformDestructuredProps(ctx, vueImportAliases) {
|
|
|
19704
19747
|
if (stmt.type === "VariableDeclaration") {
|
|
19705
19748
|
walkVariableDeclaration(stmt, isRoot);
|
|
19706
19749
|
} else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
|
|
19707
|
-
if (stmt.declare || !stmt.id)
|
|
19708
|
-
continue;
|
|
19750
|
+
if (stmt.declare || !stmt.id) continue;
|
|
19709
19751
|
registerLocalBinding(stmt.id);
|
|
19710
19752
|
} else if ((stmt.type === "ForOfStatement" || stmt.type === "ForInStatement") && stmt.left.type === "VariableDeclaration") {
|
|
19711
19753
|
walkVariableDeclaration(stmt.left);
|
|
@@ -19931,8 +19973,7 @@ function processDefineOptions(ctx, node) {
|
|
|
19931
19973
|
if (node.typeParameters) {
|
|
19932
19974
|
ctx.error(`${DEFINE_OPTIONS}() cannot accept type arguments`, node);
|
|
19933
19975
|
}
|
|
19934
|
-
if (!node.arguments[0])
|
|
19935
|
-
return true;
|
|
19976
|
+
if (!node.arguments[0]) return true;
|
|
19936
19977
|
ctx.hasDefineOptionsCall = true;
|
|
19937
19978
|
ctx.optionsRuntimeDecl = CompilerDOM.unwrapTSNode(node.arguments[0]);
|
|
19938
19979
|
let propsOption = void 0;
|
|
@@ -19942,14 +19983,20 @@ function processDefineOptions(ctx, node) {
|
|
|
19942
19983
|
if (ctx.optionsRuntimeDecl.type === "ObjectExpression") {
|
|
19943
19984
|
for (const prop of ctx.optionsRuntimeDecl.properties) {
|
|
19944
19985
|
if ((prop.type === "ObjectProperty" || prop.type === "ObjectMethod") && prop.key.type === "Identifier") {
|
|
19945
|
-
|
|
19946
|
-
|
|
19947
|
-
|
|
19948
|
-
|
|
19949
|
-
|
|
19950
|
-
|
|
19951
|
-
|
|
19952
|
-
|
|
19986
|
+
switch (prop.key.name) {
|
|
19987
|
+
case "props":
|
|
19988
|
+
propsOption = prop;
|
|
19989
|
+
break;
|
|
19990
|
+
case "emits":
|
|
19991
|
+
emitsOption = prop;
|
|
19992
|
+
break;
|
|
19993
|
+
case "expose":
|
|
19994
|
+
exposeOption = prop;
|
|
19995
|
+
break;
|
|
19996
|
+
case "slots":
|
|
19997
|
+
slotsOption = prop;
|
|
19998
|
+
break;
|
|
19999
|
+
}
|
|
19953
20000
|
}
|
|
19954
20001
|
}
|
|
19955
20002
|
}
|
|
@@ -20006,6 +20053,15 @@ function processAwait(ctx, node, needSemi, isStatement) {
|
|
|
20006
20053
|
);
|
|
20007
20054
|
}
|
|
20008
20055
|
|
|
20056
|
+
const MACROS = [
|
|
20057
|
+
DEFINE_PROPS,
|
|
20058
|
+
DEFINE_EMITS,
|
|
20059
|
+
DEFINE_EXPOSE,
|
|
20060
|
+
DEFINE_OPTIONS,
|
|
20061
|
+
DEFINE_SLOTS,
|
|
20062
|
+
DEFINE_MODEL,
|
|
20063
|
+
WITH_DEFAULTS
|
|
20064
|
+
];
|
|
20009
20065
|
function compileScript(sfc, options) {
|
|
20010
20066
|
var _a, _b, _c;
|
|
20011
20067
|
if (!options.id) {
|
|
@@ -20073,8 +20129,7 @@ Upgrade your vite or vue-loader version for compatibility with the latest experi
|
|
|
20073
20129
|
};
|
|
20074
20130
|
}
|
|
20075
20131
|
function checkInvalidScopeReference(node, method) {
|
|
20076
|
-
if (!node)
|
|
20077
|
-
return;
|
|
20132
|
+
if (!node) return;
|
|
20078
20133
|
CompilerDOM.walkIdentifiers(node, (id) => {
|
|
20079
20134
|
const binding = setupBindings[id.name];
|
|
20080
20135
|
if (binding && binding !== "literal-const") {
|
|
@@ -20124,10 +20179,17 @@ Upgrade your vite or vue-loader version for compatibility with the latest experi
|
|
|
20124
20179
|
const imported = getImportedName(specifier);
|
|
20125
20180
|
const source2 = node.source.value;
|
|
20126
20181
|
const existing = ctx.userImports[local];
|
|
20127
|
-
if (source2 === "vue" && (imported
|
|
20128
|
-
|
|
20129
|
-
|
|
20130
|
-
|
|
20182
|
+
if (source2 === "vue" && MACROS.includes(imported)) {
|
|
20183
|
+
if (local === imported) {
|
|
20184
|
+
warnOnce(
|
|
20185
|
+
`\`${imported}\` is a compiler macro and no longer needs to be imported.`
|
|
20186
|
+
);
|
|
20187
|
+
} else {
|
|
20188
|
+
ctx.error(
|
|
20189
|
+
`\`${imported}\` is a compiler macro and cannot be aliased to a different name.`,
|
|
20190
|
+
specifier
|
|
20191
|
+
);
|
|
20192
|
+
}
|
|
20131
20193
|
removeSpecifier(i);
|
|
20132
20194
|
} else if (existing) {
|
|
20133
20195
|
if (existing.source === source2 && existing.imported === imported) {
|
|
@@ -20157,8 +20219,7 @@ Upgrade your vite or vue-loader version for compatibility with the latest experi
|
|
|
20157
20219
|
const vueImportAliases = {};
|
|
20158
20220
|
for (const key in ctx.userImports) {
|
|
20159
20221
|
const { source: source2, imported, local } = ctx.userImports[key];
|
|
20160
|
-
if (source2 === "vue")
|
|
20161
|
-
vueImportAliases[imported] = local;
|
|
20222
|
+
if (source2 === "vue") vueImportAliases[imported] = local;
|
|
20162
20223
|
}
|
|
20163
20224
|
if (script && scriptAst) {
|
|
20164
20225
|
for (const node of scriptAst.body) {
|
|
@@ -20272,6 +20333,9 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
|
|
|
20272
20333
|
);
|
|
20273
20334
|
}
|
|
20274
20335
|
const isDefineProps = processDefineProps(ctx, init, decl.id);
|
|
20336
|
+
if (ctx.propsDestructureRestId) {
|
|
20337
|
+
setupBindings[ctx.propsDestructureRestId] = "setup-reactive-const";
|
|
20338
|
+
}
|
|
20275
20339
|
const isDefineEmits = !isDefineProps && processDefineEmits(ctx, init, decl.id);
|
|
20276
20340
|
!isDefineEmits && (processDefineSlots(ctx, init, decl.id) || processDefineModel(ctx, init, decl.id));
|
|
20277
20341
|
if (isDefineProps && !ctx.propsDestructureRestId && ctx.propsDestructureDecl) {
|
|
@@ -20338,8 +20402,7 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
|
|
|
20338
20402
|
}
|
|
20339
20403
|
},
|
|
20340
20404
|
exit(node2) {
|
|
20341
|
-
if (node2.type === "BlockStatement")
|
|
20342
|
-
scope.pop();
|
|
20405
|
+
if (node2.type === "BlockStatement") scope.pop();
|
|
20343
20406
|
}
|
|
20344
20407
|
});
|
|
20345
20408
|
}
|
|
@@ -20390,8 +20453,7 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
|
|
|
20390
20453
|
for (const [key, { isType, imported, source: source2 }] of Object.entries(
|
|
20391
20454
|
ctx.userImports
|
|
20392
20455
|
)) {
|
|
20393
|
-
if (isType)
|
|
20394
|
-
continue;
|
|
20456
|
+
if (isType) continue;
|
|
20395
20457
|
ctx.bindingMetadata[key] = imported === "*" || imported === "default" && source2.endsWith(".vue") || source2 === "vue" ? "setup-const" : "setup-maybe-ref";
|
|
20396
20458
|
}
|
|
20397
20459
|
for (const key in scriptBindings) {
|
|
@@ -20562,12 +20624,10 @@ return ${returned}
|
|
|
20562
20624
|
__ssrInlineRender: true,`;
|
|
20563
20625
|
}
|
|
20564
20626
|
const propsDecl = genRuntimeProps(ctx);
|
|
20565
|
-
if (propsDecl)
|
|
20566
|
-
runtimeOptions += `
|
|
20627
|
+
if (propsDecl) runtimeOptions += `
|
|
20567
20628
|
props: ${propsDecl},`;
|
|
20568
20629
|
const emitsDecl = genRuntimeEmits(ctx);
|
|
20569
|
-
if (emitsDecl)
|
|
20570
|
-
runtimeOptions += `
|
|
20630
|
+
if (emitsDecl) runtimeOptions += `
|
|
20571
20631
|
emits: ${emitsDecl},`;
|
|
20572
20632
|
let definedOptions = "";
|
|
20573
20633
|
if (ctx.optionsRuntimeDecl) {
|
|
@@ -20645,10 +20705,10 @@ function walkDeclaration(from, node, bindings, userImportAliases, hoistStatic) {
|
|
|
20645
20705
|
);
|
|
20646
20706
|
for (const { id, init: _init } of node.declarations) {
|
|
20647
20707
|
const init = _init && CompilerDOM.unwrapTSNode(_init);
|
|
20648
|
-
const
|
|
20708
|
+
const isConstMacroCall = isConst && isCallOf(
|
|
20649
20709
|
init,
|
|
20650
|
-
(c) => c === DEFINE_PROPS || c === DEFINE_EMITS || c === WITH_DEFAULTS
|
|
20651
|
-
)
|
|
20710
|
+
(c) => c === DEFINE_PROPS || c === DEFINE_EMITS || c === WITH_DEFAULTS || c === DEFINE_SLOTS
|
|
20711
|
+
);
|
|
20652
20712
|
if (id.type === "Identifier") {
|
|
20653
20713
|
let bindingType;
|
|
20654
20714
|
const userReactiveBinding = userImportAliases["reactive"];
|
|
@@ -20659,7 +20719,7 @@ function walkDeclaration(from, node, bindings, userImportAliases, hoistStatic) {
|
|
|
20659
20719
|
} else if (
|
|
20660
20720
|
// if a declaration is a const literal, we can mark it so that
|
|
20661
20721
|
// the generated render fn code doesn't need to unref() it
|
|
20662
|
-
|
|
20722
|
+
isConstMacroCall || isConst && canNeverBeRef(init, userReactiveBinding)
|
|
20663
20723
|
) {
|
|
20664
20724
|
bindingType = isCallOf(init, DEFINE_PROPS) ? "setup-reactive-const" : "setup-const";
|
|
20665
20725
|
} else if (isConst) {
|
|
@@ -20680,9 +20740,9 @@ function walkDeclaration(from, node, bindings, userImportAliases, hoistStatic) {
|
|
|
20680
20740
|
continue;
|
|
20681
20741
|
}
|
|
20682
20742
|
if (id.type === "ObjectPattern") {
|
|
20683
|
-
walkObjectPattern(id, bindings, isConst,
|
|
20743
|
+
walkObjectPattern(id, bindings, isConst, isConstMacroCall);
|
|
20684
20744
|
} else if (id.type === "ArrayPattern") {
|
|
20685
|
-
walkArrayPattern(id, bindings, isConst,
|
|
20745
|
+
walkArrayPattern(id, bindings, isConst, isConstMacroCall);
|
|
20686
20746
|
}
|
|
20687
20747
|
}
|
|
20688
20748
|
}
|
|
@@ -20789,7 +20849,7 @@ function isStaticNode(node) {
|
|
|
20789
20849
|
return false;
|
|
20790
20850
|
}
|
|
20791
20851
|
|
|
20792
|
-
const version = "3.4.
|
|
20852
|
+
const version = "3.4.29";
|
|
20793
20853
|
const parseCache = parseCache$1;
|
|
20794
20854
|
const errorMessages = {
|
|
20795
20855
|
...CompilerDOM.errorMessages,
|