@vue/compiler-sfc 3.4.27 → 3.4.28
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 +237 -178
- package/dist/compiler-sfc.esm-browser.js +612 -566
- 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.28
|
|
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
|
}
|
|
@@ -17968,7 +17954,7 @@ function innerResolveTypeElements(ctx, node, scope, typeParameters) {
|
|
|
17968
17954
|
node.type
|
|
17969
17955
|
);
|
|
17970
17956
|
case "TSMappedType":
|
|
17971
|
-
return resolveMappedType(ctx, node, scope);
|
|
17957
|
+
return resolveMappedType(ctx, node, scope, typeParameters);
|
|
17972
17958
|
case "TSIndexedAccessType": {
|
|
17973
17959
|
const types = resolveIndexType(ctx, node, scope);
|
|
17974
17960
|
return mergeElements(
|
|
@@ -17997,8 +17983,7 @@ function innerResolveTypeElements(ctx, node, scope, typeParameters) {
|
|
|
17997
17983
|
typeParams = /* @__PURE__ */ Object.create(null);
|
|
17998
17984
|
resolved.typeParameters.params.forEach((p, i) => {
|
|
17999
17985
|
let param = typeParameters && typeParameters[p.name];
|
|
18000
|
-
if (!param)
|
|
18001
|
-
param = node.typeParameters.params[i];
|
|
17986
|
+
if (!param) param = node.typeParameters.params[i];
|
|
18002
17987
|
typeParams[p.name] = param;
|
|
18003
17988
|
});
|
|
18004
17989
|
}
|
|
@@ -18108,8 +18093,7 @@ function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx), typeParameter
|
|
|
18108
18093
|
return res;
|
|
18109
18094
|
}
|
|
18110
18095
|
function mergeElements(maps, type) {
|
|
18111
|
-
if (maps.length === 1)
|
|
18112
|
-
return maps[0];
|
|
18096
|
+
if (maps.length === 1) return maps[0];
|
|
18113
18097
|
const res = { props: {} };
|
|
18114
18098
|
const { props: baseProps } = res;
|
|
18115
18099
|
for (const { props, calls } of maps) {
|
|
@@ -18186,9 +18170,17 @@ Note: both in 3.2 or with the ignore, the properties in the base type are treate
|
|
|
18186
18170
|
}
|
|
18187
18171
|
return base;
|
|
18188
18172
|
}
|
|
18189
|
-
function resolveMappedType(ctx, node, scope) {
|
|
18173
|
+
function resolveMappedType(ctx, node, scope, typeParameters) {
|
|
18190
18174
|
const res = { props: {} };
|
|
18191
|
-
|
|
18175
|
+
let keys;
|
|
18176
|
+
if (node.nameType) {
|
|
18177
|
+
const { name, constraint } = node.typeParameter;
|
|
18178
|
+
scope = createChildScope(scope);
|
|
18179
|
+
Object.assign(scope.types, { ...typeParameters, [name]: constraint });
|
|
18180
|
+
keys = resolveStringType(ctx, node.nameType, scope);
|
|
18181
|
+
} else {
|
|
18182
|
+
keys = resolveStringType(ctx, node.typeParameter.constraint, scope);
|
|
18183
|
+
}
|
|
18192
18184
|
for (const key of keys) {
|
|
18193
18185
|
res.props[key] = createProperty(
|
|
18194
18186
|
{
|
|
@@ -18533,13 +18525,12 @@ function importSourceToScope(ctx, node, scope, source) {
|
|
|
18533
18525
|
const osSpecificJoinFn = process__namespace.platform === "win32" ? path$3.join : joinPaths;
|
|
18534
18526
|
const filename = osSpecificJoinFn(path$3.dirname(scope.filename), source);
|
|
18535
18527
|
resolved = resolveExt(filename, fs);
|
|
18536
|
-
} else if (source
|
|
18528
|
+
} else if (source[0] === ".") {
|
|
18537
18529
|
const filename = joinPaths(path$3.dirname(scope.filename), source);
|
|
18538
18530
|
resolved = resolveExt(filename, fs);
|
|
18539
18531
|
} else {
|
|
18540
18532
|
if (!ts) {
|
|
18541
|
-
if (loadTS)
|
|
18542
|
-
ts = loadTS();
|
|
18533
|
+
if (loadTS) ts = loadTS();
|
|
18543
18534
|
if (!ts) {
|
|
18544
18535
|
return ctx.error(
|
|
18545
18536
|
`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 +18559,7 @@ function importSourceToScope(ctx, node, scope, source) {
|
|
|
18568
18559
|
function resolveExt(filename, fs) {
|
|
18569
18560
|
filename = filename.replace(/\.js$/, "");
|
|
18570
18561
|
const tryResolve = (filename2) => {
|
|
18571
|
-
if (fs.fileExists(filename2))
|
|
18572
|
-
return filename2;
|
|
18562
|
+
if (fs.fileExists(filename2)) return filename2;
|
|
18573
18563
|
};
|
|
18574
18564
|
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
18565
|
}
|
|
@@ -18600,7 +18590,7 @@ function resolveWithTS(containingFile, source, ts2, fs) {
|
|
|
18600
18590
|
);
|
|
18601
18591
|
const included = (_a = c.config.raw) == null ? void 0 : _a.include;
|
|
18602
18592
|
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)))) {
|
|
18593
|
+
if (!included && (!base || containingFile.startsWith(base)) || (included == null ? void 0 : included.some((p) => minimatch(containingFile, joinPaths(base, p))))) {
|
|
18604
18594
|
if (excluded && excluded.some((p) => minimatch(containingFile, joinPaths(base, p)))) {
|
|
18605
18595
|
continue;
|
|
18606
18596
|
}
|
|
@@ -18648,8 +18638,12 @@ function loadTSConfig(configPath, ts2, fs) {
|
|
|
18648
18638
|
const res = [config];
|
|
18649
18639
|
if (config.projectReferences) {
|
|
18650
18640
|
for (const ref of config.projectReferences) {
|
|
18651
|
-
|
|
18652
|
-
|
|
18641
|
+
const refPath = ts2.resolveProjectReferencePath(ref);
|
|
18642
|
+
if (!fs.fileExists(refPath)) {
|
|
18643
|
+
continue;
|
|
18644
|
+
}
|
|
18645
|
+
tsConfigRefMap.set(refPath, configPath);
|
|
18646
|
+
res.unshift(...loadTSConfig(refPath, ts2, fs));
|
|
18653
18647
|
}
|
|
18654
18648
|
}
|
|
18655
18649
|
return res;
|
|
@@ -18660,8 +18654,7 @@ function invalidateTypeCache(filename) {
|
|
|
18660
18654
|
fileToScopeCache.delete(filename);
|
|
18661
18655
|
tsConfigCache.delete(filename);
|
|
18662
18656
|
const affectedConfig = tsConfigRefMap.get(filename);
|
|
18663
|
-
if (affectedConfig)
|
|
18664
|
-
tsConfigCache.delete(affectedConfig);
|
|
18657
|
+
if (affectedConfig) tsConfigCache.delete(affectedConfig);
|
|
18665
18658
|
}
|
|
18666
18659
|
function fileToScope(ctx, filename, asGlobal = false) {
|
|
18667
18660
|
const cached = fileToScopeCache.get(filename);
|
|
@@ -18824,8 +18817,7 @@ function recordTypes(ctx, body, scope, asGlobal = false) {
|
|
|
18824
18817
|
for (const key of Object.keys(types)) {
|
|
18825
18818
|
const node = types[key];
|
|
18826
18819
|
node._ownerScope = scope;
|
|
18827
|
-
if (node._ns)
|
|
18828
|
-
node._ns._ownerScope = scope;
|
|
18820
|
+
if (node._ns) node._ns._ownerScope = scope;
|
|
18829
18821
|
}
|
|
18830
18822
|
for (const key of Object.keys(declares)) {
|
|
18831
18823
|
declares[key]._ownerScope = scope;
|
|
@@ -18866,15 +18858,13 @@ function recordType(node, types, declares, overwriteId) {
|
|
|
18866
18858
|
break;
|
|
18867
18859
|
}
|
|
18868
18860
|
case "ClassDeclaration":
|
|
18869
|
-
if (overwriteId || node.id)
|
|
18870
|
-
types[overwriteId || getId(node.id)] = node;
|
|
18861
|
+
if (overwriteId || node.id) types[overwriteId || getId(node.id)] = node;
|
|
18871
18862
|
break;
|
|
18872
18863
|
case "TSTypeAliasDeclaration":
|
|
18873
18864
|
types[node.id.name] = node.typeParameters ? node : node.typeAnnotation;
|
|
18874
18865
|
break;
|
|
18875
18866
|
case "TSDeclareFunction":
|
|
18876
|
-
if (node.id)
|
|
18877
|
-
declares[node.id.name] = node;
|
|
18867
|
+
if (node.id) declares[node.id.name] = node;
|
|
18878
18868
|
break;
|
|
18879
18869
|
case "VariableDeclaration": {
|
|
18880
18870
|
if (node.declare) {
|
|
@@ -18959,6 +18949,17 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
|
|
|
18959
18949
|
if (isKeyOf) {
|
|
18960
18950
|
if (m.type === "TSPropertySignature" && m.key.type === "NumericLiteral") {
|
|
18961
18951
|
types.add("Number");
|
|
18952
|
+
} else if (m.type === "TSIndexSignature") {
|
|
18953
|
+
const annotation = m.parameters[0].typeAnnotation;
|
|
18954
|
+
if (annotation && annotation.type !== "Noop") {
|
|
18955
|
+
const type = inferRuntimeType(
|
|
18956
|
+
ctx,
|
|
18957
|
+
annotation.typeAnnotation,
|
|
18958
|
+
scope
|
|
18959
|
+
)[0];
|
|
18960
|
+
if (type === UNKNOWN_TYPE) return [UNKNOWN_TYPE];
|
|
18961
|
+
types.add(type);
|
|
18962
|
+
}
|
|
18962
18963
|
} else {
|
|
18963
18964
|
types.add("String");
|
|
18964
18965
|
}
|
|
@@ -18968,7 +18969,7 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
|
|
|
18968
18969
|
types.add("Object");
|
|
18969
18970
|
}
|
|
18970
18971
|
}
|
|
18971
|
-
return types.size ? Array.from(types) : ["Object"];
|
|
18972
|
+
return types.size ? Array.from(types) : [isKeyOf ? UNKNOWN_TYPE : "Object"];
|
|
18972
18973
|
}
|
|
18973
18974
|
case "TSPropertySignature":
|
|
18974
18975
|
if (node.typeAnnotation) {
|
|
@@ -19008,73 +19009,113 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
|
|
|
19008
19009
|
case "String":
|
|
19009
19010
|
case "Array":
|
|
19010
19011
|
case "ArrayLike":
|
|
19012
|
+
case "Parameters":
|
|
19013
|
+
case "ConstructorParameters":
|
|
19011
19014
|
case "ReadonlyArray":
|
|
19012
19015
|
return ["String", "Number"];
|
|
19013
|
-
|
|
19016
|
+
case "Record":
|
|
19017
|
+
case "Partial":
|
|
19018
|
+
case "Required":
|
|
19019
|
+
case "Readonly":
|
|
19020
|
+
if (node.typeParameters && node.typeParameters.params[0]) {
|
|
19021
|
+
return inferRuntimeType(
|
|
19022
|
+
ctx,
|
|
19023
|
+
node.typeParameters.params[0],
|
|
19024
|
+
scope,
|
|
19025
|
+
true
|
|
19026
|
+
);
|
|
19027
|
+
}
|
|
19028
|
+
break;
|
|
19029
|
+
case "Pick":
|
|
19030
|
+
case "Extract":
|
|
19031
|
+
if (node.typeParameters && node.typeParameters.params[1]) {
|
|
19032
|
+
return inferRuntimeType(
|
|
19033
|
+
ctx,
|
|
19034
|
+
node.typeParameters.params[1],
|
|
19035
|
+
scope
|
|
19036
|
+
);
|
|
19037
|
+
}
|
|
19038
|
+
break;
|
|
19039
|
+
case "Function":
|
|
19040
|
+
case "Object":
|
|
19041
|
+
case "Set":
|
|
19042
|
+
case "Map":
|
|
19043
|
+
case "WeakSet":
|
|
19044
|
+
case "WeakMap":
|
|
19045
|
+
case "Date":
|
|
19046
|
+
case "Promise":
|
|
19047
|
+
case "Error":
|
|
19048
|
+
case "Uppercase":
|
|
19049
|
+
case "Lowercase":
|
|
19050
|
+
case "Capitalize":
|
|
19051
|
+
case "Uncapitalize":
|
|
19052
|
+
case "ReadonlyMap":
|
|
19053
|
+
case "ReadonlySet":
|
|
19014
19054
|
return ["String"];
|
|
19015
19055
|
}
|
|
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
|
-
|
|
19056
|
+
} else {
|
|
19057
|
+
switch (node.typeName.name) {
|
|
19058
|
+
case "Array":
|
|
19059
|
+
case "Function":
|
|
19060
|
+
case "Object":
|
|
19061
|
+
case "Set":
|
|
19062
|
+
case "Map":
|
|
19063
|
+
case "WeakSet":
|
|
19064
|
+
case "WeakMap":
|
|
19065
|
+
case "Date":
|
|
19066
|
+
case "Promise":
|
|
19067
|
+
case "Error":
|
|
19068
|
+
return [node.typeName.name];
|
|
19069
|
+
case "Partial":
|
|
19070
|
+
case "Required":
|
|
19071
|
+
case "Readonly":
|
|
19072
|
+
case "Record":
|
|
19073
|
+
case "Pick":
|
|
19074
|
+
case "Omit":
|
|
19075
|
+
case "InstanceType":
|
|
19076
|
+
return ["Object"];
|
|
19077
|
+
case "Uppercase":
|
|
19078
|
+
case "Lowercase":
|
|
19079
|
+
case "Capitalize":
|
|
19080
|
+
case "Uncapitalize":
|
|
19081
|
+
return ["String"];
|
|
19082
|
+
case "Parameters":
|
|
19083
|
+
case "ConstructorParameters":
|
|
19084
|
+
case "ReadonlyArray":
|
|
19085
|
+
return ["Array"];
|
|
19086
|
+
case "ReadonlyMap":
|
|
19087
|
+
return ["Map"];
|
|
19088
|
+
case "ReadonlySet":
|
|
19089
|
+
return ["Set"];
|
|
19090
|
+
case "NonNullable":
|
|
19091
|
+
if (node.typeParameters && node.typeParameters.params[0]) {
|
|
19092
|
+
return inferRuntimeType(
|
|
19093
|
+
ctx,
|
|
19094
|
+
node.typeParameters.params[0],
|
|
19095
|
+
scope
|
|
19096
|
+
).filter((t) => t !== "null");
|
|
19097
|
+
}
|
|
19098
|
+
break;
|
|
19099
|
+
case "Extract":
|
|
19100
|
+
if (node.typeParameters && node.typeParameters.params[1]) {
|
|
19101
|
+
return inferRuntimeType(
|
|
19102
|
+
ctx,
|
|
19103
|
+
node.typeParameters.params[1],
|
|
19104
|
+
scope
|
|
19105
|
+
);
|
|
19106
|
+
}
|
|
19107
|
+
break;
|
|
19108
|
+
case "Exclude":
|
|
19109
|
+
case "OmitThisParameter":
|
|
19110
|
+
if (node.typeParameters && node.typeParameters.params[0]) {
|
|
19111
|
+
return inferRuntimeType(
|
|
19112
|
+
ctx,
|
|
19113
|
+
node.typeParameters.params[0],
|
|
19114
|
+
scope
|
|
19115
|
+
);
|
|
19116
|
+
}
|
|
19117
|
+
break;
|
|
19118
|
+
}
|
|
19078
19119
|
}
|
|
19079
19120
|
}
|
|
19080
19121
|
break;
|
|
@@ -19082,9 +19123,9 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
|
|
|
19082
19123
|
case "TSParenthesizedType":
|
|
19083
19124
|
return inferRuntimeType(ctx, node.typeAnnotation, scope);
|
|
19084
19125
|
case "TSUnionType":
|
|
19085
|
-
return flattenTypes(ctx, node.types, scope);
|
|
19126
|
+
return flattenTypes(ctx, node.types, scope, isKeyOf);
|
|
19086
19127
|
case "TSIntersectionType": {
|
|
19087
|
-
return flattenTypes(ctx, node.types, scope).filter(
|
|
19128
|
+
return flattenTypes(ctx, node.types, scope, isKeyOf).filter(
|
|
19088
19129
|
(t) => t !== UNKNOWN_TYPE
|
|
19089
19130
|
);
|
|
19090
19131
|
}
|
|
@@ -19129,19 +19170,25 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
|
|
|
19129
19170
|
node.operator === "keyof"
|
|
19130
19171
|
);
|
|
19131
19172
|
}
|
|
19173
|
+
case "TSAnyKeyword": {
|
|
19174
|
+
if (isKeyOf) {
|
|
19175
|
+
return ["String", "Number", "Symbol"];
|
|
19176
|
+
}
|
|
19177
|
+
break;
|
|
19178
|
+
}
|
|
19132
19179
|
}
|
|
19133
19180
|
} catch (e) {
|
|
19134
19181
|
}
|
|
19135
19182
|
return [UNKNOWN_TYPE];
|
|
19136
19183
|
}
|
|
19137
|
-
function flattenTypes(ctx, types, scope) {
|
|
19184
|
+
function flattenTypes(ctx, types, scope, isKeyOf = false) {
|
|
19138
19185
|
if (types.length === 1) {
|
|
19139
|
-
return inferRuntimeType(ctx, types[0], scope);
|
|
19186
|
+
return inferRuntimeType(ctx, types[0], scope, isKeyOf);
|
|
19140
19187
|
}
|
|
19141
19188
|
return [
|
|
19142
19189
|
...new Set(
|
|
19143
19190
|
[].concat(
|
|
19144
|
-
...types.map((t) => inferRuntimeType(ctx, t, scope))
|
|
19191
|
+
...types.map((t) => inferRuntimeType(ctx, t, scope, isKeyOf))
|
|
19145
19192
|
)
|
|
19146
19193
|
)
|
|
19147
19194
|
];
|
|
@@ -19197,8 +19244,7 @@ function reverseInferType(key, node, scope, optional = true, checkObjectSyntax =
|
|
|
19197
19244
|
if ((node.type === "TSTypeReference" || node.type === "TSImportType") && node.typeParameters) {
|
|
19198
19245
|
for (const t of node.typeParameters.params) {
|
|
19199
19246
|
const inferred = reverseInferType(key, t, scope, optional);
|
|
19200
|
-
if (inferred)
|
|
19201
|
-
return inferred;
|
|
19247
|
+
if (inferred) return inferred;
|
|
19202
19248
|
}
|
|
19203
19249
|
}
|
|
19204
19250
|
return createProperty(key, { type: `TSNullKeyword` }, scope, optional);
|
|
@@ -19238,8 +19284,7 @@ function resolveReturnType(ctx, arg, scope) {
|
|
|
19238
19284
|
if (arg.type === "TSTypeReference" || arg.type === "TSTypeQuery" || arg.type === "TSImportType") {
|
|
19239
19285
|
resolved = resolveTypeReference(ctx, arg, scope);
|
|
19240
19286
|
}
|
|
19241
|
-
if (!resolved)
|
|
19242
|
-
return;
|
|
19287
|
+
if (!resolved) return;
|
|
19243
19288
|
if (resolved.type === "TSFunctionType") {
|
|
19244
19289
|
return (_a = resolved.typeAnnotation) == null ? void 0 : _a.typeAnnotation;
|
|
19245
19290
|
}
|
|
@@ -19250,8 +19295,7 @@ function resolveReturnType(ctx, arg, scope) {
|
|
|
19250
19295
|
function resolveUnionType(ctx, node, scope) {
|
|
19251
19296
|
if (node.type === "TSTypeReference") {
|
|
19252
19297
|
const resolved = resolveTypeReference(ctx, node, scope);
|
|
19253
|
-
if (resolved)
|
|
19254
|
-
node = resolved;
|
|
19298
|
+
if (resolved) node = resolved;
|
|
19255
19299
|
}
|
|
19256
19300
|
let types;
|
|
19257
19301
|
if (node.type === "TSUnionType") {
|
|
@@ -19328,8 +19372,7 @@ function processDefineModel(ctx, node, declId) {
|
|
|
19328
19372
|
return true;
|
|
19329
19373
|
}
|
|
19330
19374
|
function genModelProps(ctx) {
|
|
19331
|
-
if (!ctx.hasDefineModelCall)
|
|
19332
|
-
return;
|
|
19375
|
+
if (!ctx.hasDefineModelCall) return;
|
|
19333
19376
|
const isProd = !!ctx.options.isProd;
|
|
19334
19377
|
let modelPropsDecl = "";
|
|
19335
19378
|
for (const [name, { type, options: runtimeOptions }] of Object.entries(
|
|
@@ -19531,8 +19574,7 @@ function genRuntimePropFromType(ctx, { key, required, type, skipCheck }, hasStat
|
|
|
19531
19574
|
} else if (hasStaticDefaults) {
|
|
19532
19575
|
const prop = ctx.propsRuntimeDefaults.properties.find(
|
|
19533
19576
|
(node) => {
|
|
19534
|
-
if (node.type === "SpreadElement")
|
|
19535
|
-
return false;
|
|
19577
|
+
if (node.type === "SpreadElement") return false;
|
|
19536
19578
|
return resolveObjectKey(node.key, node.computed) === key;
|
|
19537
19579
|
}
|
|
19538
19580
|
);
|
|
@@ -19704,8 +19746,7 @@ function transformDestructuredProps(ctx, vueImportAliases) {
|
|
|
19704
19746
|
if (stmt.type === "VariableDeclaration") {
|
|
19705
19747
|
walkVariableDeclaration(stmt, isRoot);
|
|
19706
19748
|
} else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
|
|
19707
|
-
if (stmt.declare || !stmt.id)
|
|
19708
|
-
continue;
|
|
19749
|
+
if (stmt.declare || !stmt.id) continue;
|
|
19709
19750
|
registerLocalBinding(stmt.id);
|
|
19710
19751
|
} else if ((stmt.type === "ForOfStatement" || stmt.type === "ForInStatement") && stmt.left.type === "VariableDeclaration") {
|
|
19711
19752
|
walkVariableDeclaration(stmt.left);
|
|
@@ -19931,8 +19972,7 @@ function processDefineOptions(ctx, node) {
|
|
|
19931
19972
|
if (node.typeParameters) {
|
|
19932
19973
|
ctx.error(`${DEFINE_OPTIONS}() cannot accept type arguments`, node);
|
|
19933
19974
|
}
|
|
19934
|
-
if (!node.arguments[0])
|
|
19935
|
-
return true;
|
|
19975
|
+
if (!node.arguments[0]) return true;
|
|
19936
19976
|
ctx.hasDefineOptionsCall = true;
|
|
19937
19977
|
ctx.optionsRuntimeDecl = CompilerDOM.unwrapTSNode(node.arguments[0]);
|
|
19938
19978
|
let propsOption = void 0;
|
|
@@ -19942,14 +19982,20 @@ function processDefineOptions(ctx, node) {
|
|
|
19942
19982
|
if (ctx.optionsRuntimeDecl.type === "ObjectExpression") {
|
|
19943
19983
|
for (const prop of ctx.optionsRuntimeDecl.properties) {
|
|
19944
19984
|
if ((prop.type === "ObjectProperty" || prop.type === "ObjectMethod") && prop.key.type === "Identifier") {
|
|
19945
|
-
|
|
19946
|
-
|
|
19947
|
-
|
|
19948
|
-
|
|
19949
|
-
|
|
19950
|
-
|
|
19951
|
-
|
|
19952
|
-
|
|
19985
|
+
switch (prop.key.name) {
|
|
19986
|
+
case "props":
|
|
19987
|
+
propsOption = prop;
|
|
19988
|
+
break;
|
|
19989
|
+
case "emits":
|
|
19990
|
+
emitsOption = prop;
|
|
19991
|
+
break;
|
|
19992
|
+
case "expose":
|
|
19993
|
+
exposeOption = prop;
|
|
19994
|
+
break;
|
|
19995
|
+
case "slots":
|
|
19996
|
+
slotsOption = prop;
|
|
19997
|
+
break;
|
|
19998
|
+
}
|
|
19953
19999
|
}
|
|
19954
20000
|
}
|
|
19955
20001
|
}
|
|
@@ -20006,6 +20052,15 @@ function processAwait(ctx, node, needSemi, isStatement) {
|
|
|
20006
20052
|
);
|
|
20007
20053
|
}
|
|
20008
20054
|
|
|
20055
|
+
const MACROS = [
|
|
20056
|
+
DEFINE_PROPS,
|
|
20057
|
+
DEFINE_EMITS,
|
|
20058
|
+
DEFINE_EXPOSE,
|
|
20059
|
+
DEFINE_OPTIONS,
|
|
20060
|
+
DEFINE_SLOTS,
|
|
20061
|
+
DEFINE_MODEL,
|
|
20062
|
+
WITH_DEFAULTS
|
|
20063
|
+
];
|
|
20009
20064
|
function compileScript(sfc, options) {
|
|
20010
20065
|
var _a, _b, _c;
|
|
20011
20066
|
if (!options.id) {
|
|
@@ -20073,8 +20128,7 @@ Upgrade your vite or vue-loader version for compatibility with the latest experi
|
|
|
20073
20128
|
};
|
|
20074
20129
|
}
|
|
20075
20130
|
function checkInvalidScopeReference(node, method) {
|
|
20076
|
-
if (!node)
|
|
20077
|
-
return;
|
|
20131
|
+
if (!node) return;
|
|
20078
20132
|
CompilerDOM.walkIdentifiers(node, (id) => {
|
|
20079
20133
|
const binding = setupBindings[id.name];
|
|
20080
20134
|
if (binding && binding !== "literal-const") {
|
|
@@ -20124,10 +20178,17 @@ Upgrade your vite or vue-loader version for compatibility with the latest experi
|
|
|
20124
20178
|
const imported = getImportedName(specifier);
|
|
20125
20179
|
const source2 = node.source.value;
|
|
20126
20180
|
const existing = ctx.userImports[local];
|
|
20127
|
-
if (source2 === "vue" && (imported
|
|
20128
|
-
|
|
20129
|
-
|
|
20130
|
-
|
|
20181
|
+
if (source2 === "vue" && MACROS.includes(imported)) {
|
|
20182
|
+
if (local === imported) {
|
|
20183
|
+
warnOnce(
|
|
20184
|
+
`\`${imported}\` is a compiler macro and no longer needs to be imported.`
|
|
20185
|
+
);
|
|
20186
|
+
} else {
|
|
20187
|
+
ctx.error(
|
|
20188
|
+
`\`${imported}\` is a compiler macro and cannot be aliased to a different name.`,
|
|
20189
|
+
specifier
|
|
20190
|
+
);
|
|
20191
|
+
}
|
|
20131
20192
|
removeSpecifier(i);
|
|
20132
20193
|
} else if (existing) {
|
|
20133
20194
|
if (existing.source === source2 && existing.imported === imported) {
|
|
@@ -20157,8 +20218,7 @@ Upgrade your vite or vue-loader version for compatibility with the latest experi
|
|
|
20157
20218
|
const vueImportAliases = {};
|
|
20158
20219
|
for (const key in ctx.userImports) {
|
|
20159
20220
|
const { source: source2, imported, local } = ctx.userImports[key];
|
|
20160
|
-
if (source2 === "vue")
|
|
20161
|
-
vueImportAliases[imported] = local;
|
|
20221
|
+
if (source2 === "vue") vueImportAliases[imported] = local;
|
|
20162
20222
|
}
|
|
20163
20223
|
if (script && scriptAst) {
|
|
20164
20224
|
for (const node of scriptAst.body) {
|
|
@@ -20272,6 +20332,9 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
|
|
|
20272
20332
|
);
|
|
20273
20333
|
}
|
|
20274
20334
|
const isDefineProps = processDefineProps(ctx, init, decl.id);
|
|
20335
|
+
if (ctx.propsDestructureRestId) {
|
|
20336
|
+
setupBindings[ctx.propsDestructureRestId] = "setup-reactive-const";
|
|
20337
|
+
}
|
|
20275
20338
|
const isDefineEmits = !isDefineProps && processDefineEmits(ctx, init, decl.id);
|
|
20276
20339
|
!isDefineEmits && (processDefineSlots(ctx, init, decl.id) || processDefineModel(ctx, init, decl.id));
|
|
20277
20340
|
if (isDefineProps && !ctx.propsDestructureRestId && ctx.propsDestructureDecl) {
|
|
@@ -20338,8 +20401,7 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
|
|
|
20338
20401
|
}
|
|
20339
20402
|
},
|
|
20340
20403
|
exit(node2) {
|
|
20341
|
-
if (node2.type === "BlockStatement")
|
|
20342
|
-
scope.pop();
|
|
20404
|
+
if (node2.type === "BlockStatement") scope.pop();
|
|
20343
20405
|
}
|
|
20344
20406
|
});
|
|
20345
20407
|
}
|
|
@@ -20390,8 +20452,7 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
|
|
|
20390
20452
|
for (const [key, { isType, imported, source: source2 }] of Object.entries(
|
|
20391
20453
|
ctx.userImports
|
|
20392
20454
|
)) {
|
|
20393
|
-
if (isType)
|
|
20394
|
-
continue;
|
|
20455
|
+
if (isType) continue;
|
|
20395
20456
|
ctx.bindingMetadata[key] = imported === "*" || imported === "default" && source2.endsWith(".vue") || source2 === "vue" ? "setup-const" : "setup-maybe-ref";
|
|
20396
20457
|
}
|
|
20397
20458
|
for (const key in scriptBindings) {
|
|
@@ -20562,12 +20623,10 @@ return ${returned}
|
|
|
20562
20623
|
__ssrInlineRender: true,`;
|
|
20563
20624
|
}
|
|
20564
20625
|
const propsDecl = genRuntimeProps(ctx);
|
|
20565
|
-
if (propsDecl)
|
|
20566
|
-
runtimeOptions += `
|
|
20626
|
+
if (propsDecl) runtimeOptions += `
|
|
20567
20627
|
props: ${propsDecl},`;
|
|
20568
20628
|
const emitsDecl = genRuntimeEmits(ctx);
|
|
20569
|
-
if (emitsDecl)
|
|
20570
|
-
runtimeOptions += `
|
|
20629
|
+
if (emitsDecl) runtimeOptions += `
|
|
20571
20630
|
emits: ${emitsDecl},`;
|
|
20572
20631
|
let definedOptions = "";
|
|
20573
20632
|
if (ctx.optionsRuntimeDecl) {
|
|
@@ -20645,10 +20704,10 @@ function walkDeclaration(from, node, bindings, userImportAliases, hoistStatic) {
|
|
|
20645
20704
|
);
|
|
20646
20705
|
for (const { id, init: _init } of node.declarations) {
|
|
20647
20706
|
const init = _init && CompilerDOM.unwrapTSNode(_init);
|
|
20648
|
-
const
|
|
20707
|
+
const isConstMacroCall = isConst && isCallOf(
|
|
20649
20708
|
init,
|
|
20650
|
-
(c) => c === DEFINE_PROPS || c === DEFINE_EMITS || c === WITH_DEFAULTS
|
|
20651
|
-
)
|
|
20709
|
+
(c) => c === DEFINE_PROPS || c === DEFINE_EMITS || c === WITH_DEFAULTS || c === DEFINE_SLOTS
|
|
20710
|
+
);
|
|
20652
20711
|
if (id.type === "Identifier") {
|
|
20653
20712
|
let bindingType;
|
|
20654
20713
|
const userReactiveBinding = userImportAliases["reactive"];
|
|
@@ -20659,7 +20718,7 @@ function walkDeclaration(from, node, bindings, userImportAliases, hoistStatic) {
|
|
|
20659
20718
|
} else if (
|
|
20660
20719
|
// if a declaration is a const literal, we can mark it so that
|
|
20661
20720
|
// the generated render fn code doesn't need to unref() it
|
|
20662
|
-
|
|
20721
|
+
isConstMacroCall || isConst && canNeverBeRef(init, userReactiveBinding)
|
|
20663
20722
|
) {
|
|
20664
20723
|
bindingType = isCallOf(init, DEFINE_PROPS) ? "setup-reactive-const" : "setup-const";
|
|
20665
20724
|
} else if (isConst) {
|
|
@@ -20680,9 +20739,9 @@ function walkDeclaration(from, node, bindings, userImportAliases, hoistStatic) {
|
|
|
20680
20739
|
continue;
|
|
20681
20740
|
}
|
|
20682
20741
|
if (id.type === "ObjectPattern") {
|
|
20683
|
-
walkObjectPattern(id, bindings, isConst,
|
|
20742
|
+
walkObjectPattern(id, bindings, isConst, isConstMacroCall);
|
|
20684
20743
|
} else if (id.type === "ArrayPattern") {
|
|
20685
|
-
walkArrayPattern(id, bindings, isConst,
|
|
20744
|
+
walkArrayPattern(id, bindings, isConst, isConstMacroCall);
|
|
20686
20745
|
}
|
|
20687
20746
|
}
|
|
20688
20747
|
}
|
|
@@ -20789,7 +20848,7 @@ function isStaticNode(node) {
|
|
|
20789
20848
|
return false;
|
|
20790
20849
|
}
|
|
20791
20850
|
|
|
20792
|
-
const version = "3.4.
|
|
20851
|
+
const version = "3.4.28";
|
|
20793
20852
|
const parseCache = parseCache$1;
|
|
20794
20853
|
const errorMessages = {
|
|
20795
20854
|
...CompilerDOM.errorMessages,
|