@vue/compiler-sfc 3.3.1 → 3.3.3
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 +171 -109
- package/dist/compiler-sfc.d.ts +5 -1
- package/dist/compiler-sfc.esm-browser.js +403 -341
- package/package.json +6 -6
package/dist/compiler-sfc.cjs.js
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var CompilerDOM = require('@vue/compiler-dom');
|
|
6
6
|
var sourceMapJs = require('source-map-js');
|
|
7
|
+
var path$3 = require('path');
|
|
7
8
|
var parser$2 = require('@babel/parser');
|
|
8
9
|
var shared = require('@vue/shared');
|
|
9
|
-
var path$3 = require('path');
|
|
10
10
|
var compilerCore = require('@vue/compiler-core');
|
|
11
11
|
var url = require('url');
|
|
12
12
|
var CompilerSSR = require('@vue/compiler-ssr');
|
|
@@ -18,19 +18,80 @@ var reactivityTransform = require('@vue/reactivity-transform');
|
|
|
18
18
|
var MagicString = require('magic-string');
|
|
19
19
|
|
|
20
20
|
function _interopNamespaceDefault(e) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
var n = Object.create(null);
|
|
22
|
+
if (e) {
|
|
23
|
+
for (var k in e) {
|
|
24
|
+
n[k] = e[k];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
n.default = e;
|
|
28
|
+
return Object.freeze(n);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
var CompilerDOM__namespace = /*#__PURE__*/_interopNamespaceDefault(CompilerDOM);
|
|
32
32
|
var CompilerSSR__namespace = /*#__PURE__*/_interopNamespaceDefault(CompilerSSR);
|
|
33
33
|
|
|
34
|
+
const UNKNOWN_TYPE = "Unknown";
|
|
35
|
+
function resolveObjectKey(node, computed) {
|
|
36
|
+
switch (node.type) {
|
|
37
|
+
case "StringLiteral":
|
|
38
|
+
case "NumericLiteral":
|
|
39
|
+
return String(node.value);
|
|
40
|
+
case "Identifier":
|
|
41
|
+
if (!computed)
|
|
42
|
+
return node.name;
|
|
43
|
+
}
|
|
44
|
+
return void 0;
|
|
45
|
+
}
|
|
46
|
+
function concatStrings(strs) {
|
|
47
|
+
return strs.filter((s) => !!s).join(", ");
|
|
48
|
+
}
|
|
49
|
+
function isLiteralNode(node) {
|
|
50
|
+
return node.type.endsWith("Literal");
|
|
51
|
+
}
|
|
52
|
+
function unwrapTSNode(node) {
|
|
53
|
+
if (CompilerDOM.TS_NODE_TYPES.includes(node.type)) {
|
|
54
|
+
return unwrapTSNode(node.expression);
|
|
55
|
+
} else {
|
|
56
|
+
return node;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function isCallOf(node, test) {
|
|
60
|
+
return !!(node && test && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : test(node.callee.name)));
|
|
61
|
+
}
|
|
62
|
+
function toRuntimeTypeString(types) {
|
|
63
|
+
return types.length > 1 ? `[${types.join(", ")}]` : types[0];
|
|
64
|
+
}
|
|
65
|
+
function getImportedName(specifier) {
|
|
66
|
+
if (specifier.type === "ImportSpecifier")
|
|
67
|
+
return specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value;
|
|
68
|
+
else if (specifier.type === "ImportNamespaceSpecifier")
|
|
69
|
+
return "*";
|
|
70
|
+
return "default";
|
|
71
|
+
}
|
|
72
|
+
function getId(node) {
|
|
73
|
+
return node.type === "Identifier" ? node.name : node.type === "StringLiteral" ? node.value : null;
|
|
74
|
+
}
|
|
75
|
+
const identity = (str) => str;
|
|
76
|
+
const fileNameLowerCaseRegExp = /[^\u0130\u0131\u00DFa-z0-9\\/:\-_\. ]+/g;
|
|
77
|
+
const toLowerCase = (str) => str.toLowerCase();
|
|
78
|
+
function toFileNameLowerCase(x) {
|
|
79
|
+
return fileNameLowerCaseRegExp.test(x) ? x.replace(fileNameLowerCaseRegExp, toLowerCase) : x;
|
|
80
|
+
}
|
|
81
|
+
function createGetCanonicalFileName(useCaseSensitiveFileNames) {
|
|
82
|
+
return useCaseSensitiveFileNames ? identity : toFileNameLowerCase;
|
|
83
|
+
}
|
|
84
|
+
const normalize = (path$3.posix || path$3).normalize;
|
|
85
|
+
const windowsSlashRE = /\\/g;
|
|
86
|
+
function normalizePath(p) {
|
|
87
|
+
return normalize(p.replace(windowsSlashRE, "/"));
|
|
88
|
+
}
|
|
89
|
+
const joinPaths = (path$3.posix || path$3).join;
|
|
90
|
+
const escapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
|
|
91
|
+
function getEscapedKey(key) {
|
|
92
|
+
return escapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
|
|
93
|
+
}
|
|
94
|
+
|
|
34
95
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
35
96
|
|
|
36
97
|
function getDefaultExportFromCjs (x) {
|
|
@@ -119,10 +180,7 @@ function genVarName(id, raw, isProd) {
|
|
|
119
180
|
if (isProd) {
|
|
120
181
|
return hash$1(id + raw);
|
|
121
182
|
} else {
|
|
122
|
-
return `${id}-${raw.replace(
|
|
123
|
-
/[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g,
|
|
124
|
-
(s) => `\\${s}`
|
|
125
|
-
)}`;
|
|
183
|
+
return `${id}-${raw.replace(escapeSymbolsRE, (s) => `\\${s}`)}`;
|
|
126
184
|
}
|
|
127
185
|
}
|
|
128
186
|
function normalizeExpression(exp) {
|
|
@@ -1084,7 +1142,8 @@ function processExp(exp, dir) {
|
|
|
1084
1142
|
} else if (dir === "for") {
|
|
1085
1143
|
const inMatch = exp.match(forAliasRE);
|
|
1086
1144
|
if (inMatch) {
|
|
1087
|
-
|
|
1145
|
+
let [, LHS, RHS] = inMatch;
|
|
1146
|
+
LHS = LHS.trim().replace(/^\(|\)$/g, "");
|
|
1088
1147
|
return processExp(`(${LHS})=>{}`) + processExp(RHS);
|
|
1089
1148
|
}
|
|
1090
1149
|
}
|
|
@@ -15484,63 +15543,6 @@ function preprocess(options, preprocessor) {
|
|
|
15484
15543
|
);
|
|
15485
15544
|
}
|
|
15486
15545
|
|
|
15487
|
-
const UNKNOWN_TYPE = "Unknown";
|
|
15488
|
-
function resolveObjectKey(node, computed) {
|
|
15489
|
-
switch (node.type) {
|
|
15490
|
-
case "StringLiteral":
|
|
15491
|
-
case "NumericLiteral":
|
|
15492
|
-
return String(node.value);
|
|
15493
|
-
case "Identifier":
|
|
15494
|
-
if (!computed)
|
|
15495
|
-
return node.name;
|
|
15496
|
-
}
|
|
15497
|
-
return void 0;
|
|
15498
|
-
}
|
|
15499
|
-
function concatStrings(strs) {
|
|
15500
|
-
return strs.filter((s) => !!s).join(", ");
|
|
15501
|
-
}
|
|
15502
|
-
function isLiteralNode(node) {
|
|
15503
|
-
return node.type.endsWith("Literal");
|
|
15504
|
-
}
|
|
15505
|
-
function unwrapTSNode(node) {
|
|
15506
|
-
if (CompilerDOM.TS_NODE_TYPES.includes(node.type)) {
|
|
15507
|
-
return unwrapTSNode(node.expression);
|
|
15508
|
-
} else {
|
|
15509
|
-
return node;
|
|
15510
|
-
}
|
|
15511
|
-
}
|
|
15512
|
-
function isCallOf(node, test) {
|
|
15513
|
-
return !!(node && test && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : test(node.callee.name)));
|
|
15514
|
-
}
|
|
15515
|
-
function toRuntimeTypeString(types) {
|
|
15516
|
-
return types.length > 1 ? `[${types.join(", ")}]` : types[0];
|
|
15517
|
-
}
|
|
15518
|
-
function getImportedName(specifier) {
|
|
15519
|
-
if (specifier.type === "ImportSpecifier")
|
|
15520
|
-
return specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value;
|
|
15521
|
-
else if (specifier.type === "ImportNamespaceSpecifier")
|
|
15522
|
-
return "*";
|
|
15523
|
-
return "default";
|
|
15524
|
-
}
|
|
15525
|
-
function getId(node) {
|
|
15526
|
-
return node.type === "Identifier" ? node.name : node.type === "StringLiteral" ? node.value : null;
|
|
15527
|
-
}
|
|
15528
|
-
const identity = (str) => str;
|
|
15529
|
-
const fileNameLowerCaseRegExp = /[^\u0130\u0131\u00DFa-z0-9\\/:\-_\. ]+/g;
|
|
15530
|
-
const toLowerCase = (str) => str.toLowerCase();
|
|
15531
|
-
function toFileNameLowerCase(x) {
|
|
15532
|
-
return fileNameLowerCaseRegExp.test(x) ? x.replace(fileNameLowerCaseRegExp, toLowerCase) : x;
|
|
15533
|
-
}
|
|
15534
|
-
function createGetCanonicalFileName(useCaseSensitiveFileNames) {
|
|
15535
|
-
return useCaseSensitiveFileNames ? identity : toFileNameLowerCase;
|
|
15536
|
-
}
|
|
15537
|
-
const normalize = (path$3.posix || path$3).normalize;
|
|
15538
|
-
const windowsSlashRE = /\\/g;
|
|
15539
|
-
function normalizePath(p) {
|
|
15540
|
-
return normalize(p.replace(windowsSlashRE, "/"));
|
|
15541
|
-
}
|
|
15542
|
-
const joinPaths = (path$3.posix || path$3).join;
|
|
15543
|
-
|
|
15544
15546
|
function analyzeScriptBindings(ast) {
|
|
15545
15547
|
for (const node of ast) {
|
|
15546
15548
|
if (node.type === "ExportDefaultDeclaration" && node.declaration.type === "ObjectExpression") {
|
|
@@ -15848,7 +15850,7 @@ ${shared.generateCodeFrame(
|
|
|
15848
15850
|
);
|
|
15849
15851
|
}
|
|
15850
15852
|
}
|
|
15851
|
-
function resolveParserPlugins(lang, userPlugins) {
|
|
15853
|
+
function resolveParserPlugins(lang, userPlugins, dts = false) {
|
|
15852
15854
|
const plugins = [];
|
|
15853
15855
|
if (lang === "jsx" || lang === "tsx") {
|
|
15854
15856
|
plugins.push("jsx");
|
|
@@ -15856,7 +15858,7 @@ function resolveParserPlugins(lang, userPlugins) {
|
|
|
15856
15858
|
userPlugins = userPlugins.filter((p) => p !== "jsx");
|
|
15857
15859
|
}
|
|
15858
15860
|
if (lang === "ts" || lang === "tsx") {
|
|
15859
|
-
plugins.push("typescript");
|
|
15861
|
+
plugins.push(["typescript", { dts }]);
|
|
15860
15862
|
if (!plugins.includes("decorators")) {
|
|
15861
15863
|
plugins.push("decorators-legacy");
|
|
15862
15864
|
}
|
|
@@ -18065,11 +18067,26 @@ function resolveInterfaceMembers(ctx, node, scope) {
|
|
|
18065
18067
|
const base = typeElementsToMap(ctx, node.body.body, node._ownerScope);
|
|
18066
18068
|
if (node.extends) {
|
|
18067
18069
|
for (const ext of node.extends) {
|
|
18068
|
-
|
|
18069
|
-
|
|
18070
|
-
|
|
18071
|
-
|
|
18070
|
+
if (ext.leadingComments && ext.leadingComments.some((c) => c.value.includes("@vue-ignore"))) {
|
|
18071
|
+
continue;
|
|
18072
|
+
}
|
|
18073
|
+
try {
|
|
18074
|
+
const { props } = resolveTypeElements(ctx, ext, scope);
|
|
18075
|
+
for (const key in props) {
|
|
18076
|
+
if (!shared.hasOwn(base.props, key)) {
|
|
18077
|
+
base.props[key] = props[key];
|
|
18078
|
+
}
|
|
18072
18079
|
}
|
|
18080
|
+
} catch (e) {
|
|
18081
|
+
ctx.error(
|
|
18082
|
+
`Failed to resolve extends base type.
|
|
18083
|
+
If this previously worked in 3.2, you can instruct the compiler to ignore this extend by adding /* @vue-ignore */ before it, for example:
|
|
18084
|
+
|
|
18085
|
+
interface Props extends /* @vue-ignore */ Base {}
|
|
18086
|
+
|
|
18087
|
+
Note: both in 3.2 or with the ignore, the properties in the base type are treated as fallthrough attrs at runtime.`,
|
|
18088
|
+
ext
|
|
18089
|
+
);
|
|
18073
18090
|
}
|
|
18074
18091
|
}
|
|
18075
18092
|
}
|
|
@@ -18335,7 +18352,7 @@ function qualifiedNameToPath(node) {
|
|
|
18335
18352
|
}
|
|
18336
18353
|
function resolveGlobalScope(ctx) {
|
|
18337
18354
|
if (ctx.options.globalTypeFiles) {
|
|
18338
|
-
const fs = ctx
|
|
18355
|
+
const fs = resolveFS(ctx);
|
|
18339
18356
|
if (!fs) {
|
|
18340
18357
|
throw new Error("[vue/compiler-sfc] globalTypeFiles requires fs access.");
|
|
18341
18358
|
}
|
|
@@ -18348,15 +18365,38 @@ let ts;
|
|
|
18348
18365
|
function registerTS(_ts) {
|
|
18349
18366
|
ts = _ts;
|
|
18350
18367
|
}
|
|
18368
|
+
function resolveFS(ctx) {
|
|
18369
|
+
if (ctx.fs) {
|
|
18370
|
+
return ctx.fs;
|
|
18371
|
+
}
|
|
18372
|
+
const fs = ctx.options.fs || ts.sys;
|
|
18373
|
+
if (!fs) {
|
|
18374
|
+
return;
|
|
18375
|
+
}
|
|
18376
|
+
return ctx.fs = {
|
|
18377
|
+
fileExists(file) {
|
|
18378
|
+
if (file.endsWith(".vue.ts")) {
|
|
18379
|
+
file = file.replace(/\.ts$/, "");
|
|
18380
|
+
}
|
|
18381
|
+
return fs.fileExists(file);
|
|
18382
|
+
},
|
|
18383
|
+
readFile(file) {
|
|
18384
|
+
if (file.endsWith(".vue.ts")) {
|
|
18385
|
+
file = file.replace(/\.ts$/, "");
|
|
18386
|
+
}
|
|
18387
|
+
return fs.readFile(file);
|
|
18388
|
+
}
|
|
18389
|
+
};
|
|
18390
|
+
}
|
|
18351
18391
|
function resolveTypeFromImport(ctx, node, name, scope) {
|
|
18352
18392
|
const { source, imported } = scope.imports[name];
|
|
18353
18393
|
const sourceScope = importSourceToScope(ctx, node, scope, source);
|
|
18354
18394
|
return resolveTypeReference(ctx, node, sourceScope, imported, true);
|
|
18355
18395
|
}
|
|
18356
18396
|
function importSourceToScope(ctx, node, scope, source) {
|
|
18357
|
-
const fs = ctx
|
|
18397
|
+
const fs = resolveFS(ctx);
|
|
18358
18398
|
if (!fs) {
|
|
18359
|
-
ctx.error(
|
|
18399
|
+
return ctx.error(
|
|
18360
18400
|
`No fs option provided to \`compileScript\` in non-Node environment. File system access is required for resolving imported types.`,
|
|
18361
18401
|
node,
|
|
18362
18402
|
scope
|
|
@@ -18393,6 +18433,7 @@ function importSourceToScope(ctx, node, scope, source) {
|
|
|
18393
18433
|
}
|
|
18394
18434
|
}
|
|
18395
18435
|
function resolveExt(filename, fs) {
|
|
18436
|
+
filename = filename.replace(/\.js$/, "");
|
|
18396
18437
|
const tryResolve = (filename2) => {
|
|
18397
18438
|
if (fs.fileExists(filename2))
|
|
18398
18439
|
return filename2;
|
|
@@ -18455,7 +18496,11 @@ function resolveWithTS(containingFile, source, fs) {
|
|
|
18455
18496
|
tsResolveCache
|
|
18456
18497
|
);
|
|
18457
18498
|
if (res.resolvedModule) {
|
|
18458
|
-
|
|
18499
|
+
let filename = res.resolvedModule.resolvedFileName;
|
|
18500
|
+
if (filename.endsWith(".vue.ts")) {
|
|
18501
|
+
filename = filename.replace(/\.ts$/, "");
|
|
18502
|
+
}
|
|
18503
|
+
return filename;
|
|
18459
18504
|
}
|
|
18460
18505
|
}
|
|
18461
18506
|
function loadTSConfig(configPath, fs) {
|
|
@@ -18490,7 +18535,7 @@ function fileToScope(ctx, filename, asGlobal = false) {
|
|
|
18490
18535
|
if (cached) {
|
|
18491
18536
|
return cached;
|
|
18492
18537
|
}
|
|
18493
|
-
const fs = ctx
|
|
18538
|
+
const fs = resolveFS(ctx);
|
|
18494
18539
|
const source = fs.readFile(filename) || "";
|
|
18495
18540
|
const body = parseFile(filename, source, ctx.options.babelParserPlugins);
|
|
18496
18541
|
const scope = new TypeScope(filename, source, 0, recordImports(body));
|
|
@@ -18502,7 +18547,11 @@ function parseFile(filename, content, parserPlugins) {
|
|
|
18502
18547
|
const ext = path$3.extname(filename);
|
|
18503
18548
|
if (ext === ".ts" || ext === ".tsx") {
|
|
18504
18549
|
return parser$2.parse(content, {
|
|
18505
|
-
plugins: resolveParserPlugins(
|
|
18550
|
+
plugins: resolveParserPlugins(
|
|
18551
|
+
ext.slice(1),
|
|
18552
|
+
parserPlugins,
|
|
18553
|
+
filename.endsWith(".d.ts")
|
|
18554
|
+
),
|
|
18506
18555
|
sourceType: "module"
|
|
18507
18556
|
}).program.body;
|
|
18508
18557
|
} else if (ext === ".vue") {
|
|
@@ -19017,6 +19066,20 @@ function resolveReturnType(ctx, arg, scope) {
|
|
|
19017
19066
|
return resolved.returnType;
|
|
19018
19067
|
}
|
|
19019
19068
|
}
|
|
19069
|
+
function resolveUnionType(ctx, node, scope) {
|
|
19070
|
+
if (node.type === "TSTypeReference") {
|
|
19071
|
+
const resolved = resolveTypeReference(ctx, node, scope);
|
|
19072
|
+
if (resolved)
|
|
19073
|
+
node = resolved;
|
|
19074
|
+
}
|
|
19075
|
+
let types;
|
|
19076
|
+
if (node.type === "TSUnionType") {
|
|
19077
|
+
types = node.types.flatMap((node2) => resolveUnionType(ctx, node2, scope));
|
|
19078
|
+
} else {
|
|
19079
|
+
types = [node];
|
|
19080
|
+
}
|
|
19081
|
+
return types;
|
|
19082
|
+
}
|
|
19020
19083
|
|
|
19021
19084
|
const DEFINE_MODEL = "defineModel";
|
|
19022
19085
|
function processDefineModel(ctx, node, declId) {
|
|
@@ -19185,9 +19248,10 @@ function genRuntimeProps(ctx) {
|
|
|
19185
19248
|
const defaults = [];
|
|
19186
19249
|
for (const key in ctx.propsDestructuredBindings) {
|
|
19187
19250
|
const d = genDestructuredDefaultValue(ctx, key);
|
|
19251
|
+
const finalKey = getEscapedKey(key);
|
|
19188
19252
|
if (d)
|
|
19189
19253
|
defaults.push(
|
|
19190
|
-
`${
|
|
19254
|
+
`${finalKey}: ${d.valueString}${d.needSkipFactory ? `, __skip_${finalKey}: true` : ``}`
|
|
19191
19255
|
);
|
|
19192
19256
|
}
|
|
19193
19257
|
if (defaults.length) {
|
|
@@ -19276,8 +19340,9 @@ function genRuntimePropFromType(ctx, { key, required, type, skipCheck }, hasStat
|
|
|
19276
19340
|
}
|
|
19277
19341
|
}
|
|
19278
19342
|
}
|
|
19343
|
+
const finalKey = getEscapedKey(key);
|
|
19279
19344
|
if (!ctx.options.isProd) {
|
|
19280
|
-
return `${
|
|
19345
|
+
return `${finalKey}: { ${concatStrings([
|
|
19281
19346
|
`type: ${toRuntimeTypeString(type)}`,
|
|
19282
19347
|
`required: ${required}`,
|
|
19283
19348
|
skipCheck && "skipCheck: true",
|
|
@@ -19286,12 +19351,12 @@ function genRuntimePropFromType(ctx, { key, required, type, skipCheck }, hasStat
|
|
|
19286
19351
|
} else if (type.some(
|
|
19287
19352
|
(el) => el === "Boolean" || (!hasStaticDefaults || defaultString) && el === "Function"
|
|
19288
19353
|
)) {
|
|
19289
|
-
return `${
|
|
19354
|
+
return `${finalKey}: { ${concatStrings([
|
|
19290
19355
|
`type: ${toRuntimeTypeString(type)}`,
|
|
19291
19356
|
defaultString
|
|
19292
19357
|
])} }`;
|
|
19293
19358
|
} else {
|
|
19294
|
-
return `${
|
|
19359
|
+
return `${finalKey}: ${defaultString ? `{ ${defaultString} }` : `{}`}`;
|
|
19295
19360
|
}
|
|
19296
19361
|
}
|
|
19297
19362
|
function hasStaticWithDefaults(ctx) {
|
|
@@ -19305,7 +19370,7 @@ function genDestructuredDefaultValue(ctx, key, inferredType) {
|
|
|
19305
19370
|
if (defaultVal) {
|
|
19306
19371
|
const value = ctx.getString(defaultVal);
|
|
19307
19372
|
const unwrapped = unwrapTSNode(defaultVal);
|
|
19308
|
-
if (inferredType && inferredType.length && !inferredType.includes(
|
|
19373
|
+
if (inferredType && inferredType.length && !inferredType.includes("null")) {
|
|
19309
19374
|
const valueType = inferValueType(unwrapped);
|
|
19310
19375
|
if (valueType && !inferredType.includes(valueType)) {
|
|
19311
19376
|
ctx.error(
|
|
@@ -19342,6 +19407,7 @@ function inferValueType(node) {
|
|
|
19342
19407
|
|
|
19343
19408
|
function processPropsDestructure(ctx, declId) {
|
|
19344
19409
|
if (!ctx.options.propsDestructure && !ctx.options.reactivityTransform) {
|
|
19410
|
+
ctx.propsIdentifier = ctx.getString(declId);
|
|
19345
19411
|
return;
|
|
19346
19412
|
}
|
|
19347
19413
|
warnOnce(
|
|
@@ -19573,7 +19639,7 @@ function extractRuntimeEmits(ctx) {
|
|
|
19573
19639
|
const emits = /* @__PURE__ */ new Set();
|
|
19574
19640
|
const node = ctx.emitsTypeDecl;
|
|
19575
19641
|
if (node.type === "TSFunctionType") {
|
|
19576
|
-
extractEventNames(node.parameters[0], emits);
|
|
19642
|
+
extractEventNames(ctx, node.parameters[0], emits);
|
|
19577
19643
|
return emits;
|
|
19578
19644
|
}
|
|
19579
19645
|
const { props, calls } = resolveTypeElements(ctx, node);
|
|
@@ -19590,22 +19656,18 @@ function extractRuntimeEmits(ctx) {
|
|
|
19590
19656
|
);
|
|
19591
19657
|
}
|
|
19592
19658
|
for (const call of calls) {
|
|
19593
|
-
extractEventNames(call.parameters[0], emits);
|
|
19659
|
+
extractEventNames(ctx, call.parameters[0], emits);
|
|
19594
19660
|
}
|
|
19595
19661
|
}
|
|
19596
19662
|
return emits;
|
|
19597
19663
|
}
|
|
19598
|
-
function extractEventNames(eventName, emits) {
|
|
19664
|
+
function extractEventNames(ctx, eventName, emits) {
|
|
19599
19665
|
if (eventName.type === "Identifier" && eventName.typeAnnotation && eventName.typeAnnotation.type === "TSTypeAnnotation") {
|
|
19600
|
-
const
|
|
19601
|
-
|
|
19602
|
-
if (
|
|
19603
|
-
|
|
19604
|
-
|
|
19605
|
-
} else if (typeNode.type === "TSUnionType") {
|
|
19606
|
-
for (const t of typeNode.types) {
|
|
19607
|
-
if (t.type === "TSLiteralType" && t.literal.type !== "UnaryExpression" && t.literal.type !== "TemplateLiteral") {
|
|
19608
|
-
emits.add(String(t.literal.value));
|
|
19666
|
+
const types = resolveUnionType(ctx, eventName.typeAnnotation.typeAnnotation);
|
|
19667
|
+
for (const type of types) {
|
|
19668
|
+
if (type.type === "TSLiteralType") {
|
|
19669
|
+
if (type.literal.type !== "UnaryExpression" && type.literal.type !== "TemplateLiteral") {
|
|
19670
|
+
emits.add(String(type.literal.value));
|
|
19609
19671
|
}
|
|
19610
19672
|
}
|
|
19611
19673
|
}
|
|
@@ -20508,6 +20570,7 @@ function canNeverBeRef(node, userReactiveImport) {
|
|
|
20508
20570
|
}
|
|
20509
20571
|
}
|
|
20510
20572
|
function isStaticNode(node) {
|
|
20573
|
+
node = unwrapTSNode(node);
|
|
20511
20574
|
switch (node.type) {
|
|
20512
20575
|
case "UnaryExpression":
|
|
20513
20576
|
return isStaticNode(node.argument);
|
|
@@ -20521,19 +20584,18 @@ function isStaticNode(node) {
|
|
|
20521
20584
|
case "TemplateLiteral":
|
|
20522
20585
|
return node.expressions.every((expr) => isStaticNode(expr));
|
|
20523
20586
|
case "ParenthesizedExpression":
|
|
20524
|
-
case "TSNonNullExpression":
|
|
20525
|
-
case "TSAsExpression":
|
|
20526
|
-
case "TSTypeAssertion":
|
|
20527
20587
|
return isStaticNode(node.expression);
|
|
20528
|
-
|
|
20529
|
-
|
|
20530
|
-
|
|
20531
|
-
|
|
20532
|
-
|
|
20588
|
+
case "StringLiteral":
|
|
20589
|
+
case "NumericLiteral":
|
|
20590
|
+
case "BooleanLiteral":
|
|
20591
|
+
case "NullLiteral":
|
|
20592
|
+
case "BigIntLiteral":
|
|
20593
|
+
return true;
|
|
20533
20594
|
}
|
|
20595
|
+
return false;
|
|
20534
20596
|
}
|
|
20535
20597
|
|
|
20536
|
-
const version = "3.3.
|
|
20598
|
+
const version = "3.3.3";
|
|
20537
20599
|
const walk = estreeWalker.walk;
|
|
20538
20600
|
|
|
20539
20601
|
exports.babelParse = parser$2.parse;
|
package/dist/compiler-sfc.d.ts
CHANGED
|
@@ -394,6 +394,10 @@ export declare class ScriptCompileContext {
|
|
|
394
394
|
* to be exposed on compiled script block for HMR cache busting
|
|
395
395
|
*/
|
|
396
396
|
deps?: Set<string>;
|
|
397
|
+
/**
|
|
398
|
+
* cache for resolved fs
|
|
399
|
+
*/
|
|
400
|
+
fs?: NonNullable<SFCScriptCompileOptions['fs']>;
|
|
397
401
|
constructor(descriptor: SFCDescriptor, options: Partial<SFCScriptCompileOptions>);
|
|
398
402
|
getString(node: Node, scriptSetup?: boolean): string;
|
|
399
403
|
error(msg: string, node: Node, scope?: TypeScope): never;
|
|
@@ -414,7 +418,7 @@ export declare class ScriptCompileContext {
|
|
|
414
418
|
* }
|
|
415
419
|
* ```
|
|
416
420
|
*/
|
|
417
|
-
export type SimpleTypeResolveContext = Pick<ScriptCompileContext, 'source' | 'filename' | 'error' | 'options'> & Partial<Pick<ScriptCompileContext, 'scope' | 'globalScopes' | 'deps'>> & {
|
|
421
|
+
export type SimpleTypeResolveContext = Pick<ScriptCompileContext, 'source' | 'filename' | 'error' | 'options'> & Partial<Pick<ScriptCompileContext, 'scope' | 'globalScopes' | 'deps' | 'fs'>> & {
|
|
418
422
|
ast: Statement[];
|
|
419
423
|
};
|
|
420
424
|
export type TypeResolveContext = ScriptCompileContext | SimpleTypeResolveContext;
|