@vue/compiler-sfc 3.3.2 → 3.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler-sfc.cjs.js +82 -31
- package/dist/compiler-sfc.d.ts +5 -1
- package/dist/compiler-sfc.esm-browser.js +78 -31
- package/package.json +6 -6
package/dist/compiler-sfc.cjs.js
CHANGED
|
@@ -1142,7 +1142,8 @@ function processExp(exp, dir) {
|
|
|
1142
1142
|
} else if (dir === "for") {
|
|
1143
1143
|
const inMatch = exp.match(forAliasRE);
|
|
1144
1144
|
if (inMatch) {
|
|
1145
|
-
|
|
1145
|
+
let [, LHS, RHS] = inMatch;
|
|
1146
|
+
LHS = LHS.trim().replace(/^\(|\)$/g, "");
|
|
1146
1147
|
return processExp(`(${LHS})=>{}`) + processExp(RHS);
|
|
1147
1148
|
}
|
|
1148
1149
|
}
|
|
@@ -18351,7 +18352,7 @@ function qualifiedNameToPath(node) {
|
|
|
18351
18352
|
}
|
|
18352
18353
|
function resolveGlobalScope(ctx) {
|
|
18353
18354
|
if (ctx.options.globalTypeFiles) {
|
|
18354
|
-
const fs = ctx
|
|
18355
|
+
const fs = resolveFS(ctx);
|
|
18355
18356
|
if (!fs) {
|
|
18356
18357
|
throw new Error("[vue/compiler-sfc] globalTypeFiles requires fs access.");
|
|
18357
18358
|
}
|
|
@@ -18364,15 +18365,38 @@ let ts;
|
|
|
18364
18365
|
function registerTS(_ts) {
|
|
18365
18366
|
ts = _ts;
|
|
18366
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
|
+
}
|
|
18367
18391
|
function resolveTypeFromImport(ctx, node, name, scope) {
|
|
18368
18392
|
const { source, imported } = scope.imports[name];
|
|
18369
18393
|
const sourceScope = importSourceToScope(ctx, node, scope, source);
|
|
18370
18394
|
return resolveTypeReference(ctx, node, sourceScope, imported, true);
|
|
18371
18395
|
}
|
|
18372
18396
|
function importSourceToScope(ctx, node, scope, source) {
|
|
18373
|
-
const fs = ctx
|
|
18397
|
+
const fs = resolveFS(ctx);
|
|
18374
18398
|
if (!fs) {
|
|
18375
|
-
ctx.error(
|
|
18399
|
+
return ctx.error(
|
|
18376
18400
|
`No fs option provided to \`compileScript\` in non-Node environment. File system access is required for resolving imported types.`,
|
|
18377
18401
|
node,
|
|
18378
18402
|
scope
|
|
@@ -18409,6 +18433,7 @@ function importSourceToScope(ctx, node, scope, source) {
|
|
|
18409
18433
|
}
|
|
18410
18434
|
}
|
|
18411
18435
|
function resolveExt(filename, fs) {
|
|
18436
|
+
filename = filename.replace(/\.js$/, "");
|
|
18412
18437
|
const tryResolve = (filename2) => {
|
|
18413
18438
|
if (fs.fileExists(filename2))
|
|
18414
18439
|
return filename2;
|
|
@@ -18471,7 +18496,11 @@ function resolveWithTS(containingFile, source, fs) {
|
|
|
18471
18496
|
tsResolveCache
|
|
18472
18497
|
);
|
|
18473
18498
|
if (res.resolvedModule) {
|
|
18474
|
-
|
|
18499
|
+
let filename = res.resolvedModule.resolvedFileName;
|
|
18500
|
+
if (filename.endsWith(".vue.ts")) {
|
|
18501
|
+
filename = filename.replace(/\.ts$/, "");
|
|
18502
|
+
}
|
|
18503
|
+
return filename;
|
|
18475
18504
|
}
|
|
18476
18505
|
}
|
|
18477
18506
|
function loadTSConfig(configPath, fs) {
|
|
@@ -18506,7 +18535,7 @@ function fileToScope(ctx, filename, asGlobal = false) {
|
|
|
18506
18535
|
if (cached) {
|
|
18507
18536
|
return cached;
|
|
18508
18537
|
}
|
|
18509
|
-
const fs = ctx
|
|
18538
|
+
const fs = resolveFS(ctx);
|
|
18510
18539
|
const source = fs.readFile(filename) || "";
|
|
18511
18540
|
const body = parseFile(filename, source, ctx.options.babelParserPlugins);
|
|
18512
18541
|
const scope = new TypeScope(filename, source, 0, recordImports(body));
|
|
@@ -18641,6 +18670,18 @@ function recordTypes(ctx, body, scope, asGlobal = false) {
|
|
|
18641
18670
|
stmt.source.value
|
|
18642
18671
|
);
|
|
18643
18672
|
Object.assign(scope.exportedTypes, sourceScope.exportedTypes);
|
|
18673
|
+
} else if (stmt.type === "ExportDefaultDeclaration" && stmt.declaration) {
|
|
18674
|
+
if (stmt.declaration.type !== "Identifier") {
|
|
18675
|
+
recordType(stmt.declaration, types, declares, "default");
|
|
18676
|
+
recordType(
|
|
18677
|
+
stmt.declaration,
|
|
18678
|
+
exportedTypes,
|
|
18679
|
+
exportedDeclares,
|
|
18680
|
+
"default"
|
|
18681
|
+
);
|
|
18682
|
+
} else if (types[stmt.declaration.name]) {
|
|
18683
|
+
exportedTypes["default"] = types[stmt.declaration.name];
|
|
18684
|
+
}
|
|
18644
18685
|
}
|
|
18645
18686
|
}
|
|
18646
18687
|
}
|
|
@@ -18654,12 +18695,12 @@ function recordTypes(ctx, body, scope, asGlobal = false) {
|
|
|
18654
18695
|
declares[key]._ownerScope = scope;
|
|
18655
18696
|
}
|
|
18656
18697
|
}
|
|
18657
|
-
function recordType(node, types, declares) {
|
|
18698
|
+
function recordType(node, types, declares, overwriteId) {
|
|
18658
18699
|
switch (node.type) {
|
|
18659
18700
|
case "TSInterfaceDeclaration":
|
|
18660
18701
|
case "TSEnumDeclaration":
|
|
18661
18702
|
case "TSModuleDeclaration": {
|
|
18662
|
-
const id = getId(node.id);
|
|
18703
|
+
const id = overwriteId || getId(node.id);
|
|
18663
18704
|
let existing = types[id];
|
|
18664
18705
|
if (existing) {
|
|
18665
18706
|
if (node.type === "TSModuleDeclaration") {
|
|
@@ -18689,7 +18730,7 @@ function recordType(node, types, declares) {
|
|
|
18689
18730
|
break;
|
|
18690
18731
|
}
|
|
18691
18732
|
case "ClassDeclaration":
|
|
18692
|
-
types[getId(node.id)] = node;
|
|
18733
|
+
types[overwriteId || getId(node.id)] = node;
|
|
18693
18734
|
break;
|
|
18694
18735
|
case "TSTypeAliasDeclaration":
|
|
18695
18736
|
types[node.id.name] = node.typeAnnotation;
|
|
@@ -19037,6 +19078,20 @@ function resolveReturnType(ctx, arg, scope) {
|
|
|
19037
19078
|
return resolved.returnType;
|
|
19038
19079
|
}
|
|
19039
19080
|
}
|
|
19081
|
+
function resolveUnionType(ctx, node, scope) {
|
|
19082
|
+
if (node.type === "TSTypeReference") {
|
|
19083
|
+
const resolved = resolveTypeReference(ctx, node, scope);
|
|
19084
|
+
if (resolved)
|
|
19085
|
+
node = resolved;
|
|
19086
|
+
}
|
|
19087
|
+
let types;
|
|
19088
|
+
if (node.type === "TSUnionType") {
|
|
19089
|
+
types = node.types.flatMap((node2) => resolveUnionType(ctx, node2, scope));
|
|
19090
|
+
} else {
|
|
19091
|
+
types = [node];
|
|
19092
|
+
}
|
|
19093
|
+
return types;
|
|
19094
|
+
}
|
|
19040
19095
|
|
|
19041
19096
|
const DEFINE_MODEL = "defineModel";
|
|
19042
19097
|
function processDefineModel(ctx, node, declId) {
|
|
@@ -19327,7 +19382,7 @@ function genDestructuredDefaultValue(ctx, key, inferredType) {
|
|
|
19327
19382
|
if (defaultVal) {
|
|
19328
19383
|
const value = ctx.getString(defaultVal);
|
|
19329
19384
|
const unwrapped = unwrapTSNode(defaultVal);
|
|
19330
|
-
if (inferredType && inferredType.length && !inferredType.includes(
|
|
19385
|
+
if (inferredType && inferredType.length && !inferredType.includes("null")) {
|
|
19331
19386
|
const valueType = inferValueType(unwrapped);
|
|
19332
19387
|
if (valueType && !inferredType.includes(valueType)) {
|
|
19333
19388
|
ctx.error(
|
|
@@ -19596,7 +19651,7 @@ function extractRuntimeEmits(ctx) {
|
|
|
19596
19651
|
const emits = /* @__PURE__ */ new Set();
|
|
19597
19652
|
const node = ctx.emitsTypeDecl;
|
|
19598
19653
|
if (node.type === "TSFunctionType") {
|
|
19599
|
-
extractEventNames(node.parameters[0], emits);
|
|
19654
|
+
extractEventNames(ctx, node.parameters[0], emits);
|
|
19600
19655
|
return emits;
|
|
19601
19656
|
}
|
|
19602
19657
|
const { props, calls } = resolveTypeElements(ctx, node);
|
|
@@ -19613,22 +19668,18 @@ function extractRuntimeEmits(ctx) {
|
|
|
19613
19668
|
);
|
|
19614
19669
|
}
|
|
19615
19670
|
for (const call of calls) {
|
|
19616
|
-
extractEventNames(call.parameters[0], emits);
|
|
19671
|
+
extractEventNames(ctx, call.parameters[0], emits);
|
|
19617
19672
|
}
|
|
19618
19673
|
}
|
|
19619
19674
|
return emits;
|
|
19620
19675
|
}
|
|
19621
|
-
function extractEventNames(eventName, emits) {
|
|
19676
|
+
function extractEventNames(ctx, eventName, emits) {
|
|
19622
19677
|
if (eventName.type === "Identifier" && eventName.typeAnnotation && eventName.typeAnnotation.type === "TSTypeAnnotation") {
|
|
19623
|
-
const
|
|
19624
|
-
|
|
19625
|
-
if (
|
|
19626
|
-
|
|
19627
|
-
|
|
19628
|
-
} else if (typeNode.type === "TSUnionType") {
|
|
19629
|
-
for (const t of typeNode.types) {
|
|
19630
|
-
if (t.type === "TSLiteralType" && t.literal.type !== "UnaryExpression" && t.literal.type !== "TemplateLiteral") {
|
|
19631
|
-
emits.add(String(t.literal.value));
|
|
19678
|
+
const types = resolveUnionType(ctx, eventName.typeAnnotation.typeAnnotation);
|
|
19679
|
+
for (const type of types) {
|
|
19680
|
+
if (type.type === "TSLiteralType") {
|
|
19681
|
+
if (type.literal.type !== "UnaryExpression" && type.literal.type !== "TemplateLiteral") {
|
|
19682
|
+
emits.add(String(type.literal.value));
|
|
19632
19683
|
}
|
|
19633
19684
|
}
|
|
19634
19685
|
}
|
|
@@ -20531,6 +20582,7 @@ function canNeverBeRef(node, userReactiveImport) {
|
|
|
20531
20582
|
}
|
|
20532
20583
|
}
|
|
20533
20584
|
function isStaticNode(node) {
|
|
20585
|
+
node = unwrapTSNode(node);
|
|
20534
20586
|
switch (node.type) {
|
|
20535
20587
|
case "UnaryExpression":
|
|
20536
20588
|
return isStaticNode(node.argument);
|
|
@@ -20544,19 +20596,18 @@ function isStaticNode(node) {
|
|
|
20544
20596
|
case "TemplateLiteral":
|
|
20545
20597
|
return node.expressions.every((expr) => isStaticNode(expr));
|
|
20546
20598
|
case "ParenthesizedExpression":
|
|
20547
|
-
case "TSNonNullExpression":
|
|
20548
|
-
case "TSAsExpression":
|
|
20549
|
-
case "TSTypeAssertion":
|
|
20550
20599
|
return isStaticNode(node.expression);
|
|
20551
|
-
|
|
20552
|
-
|
|
20553
|
-
|
|
20554
|
-
|
|
20555
|
-
|
|
20600
|
+
case "StringLiteral":
|
|
20601
|
+
case "NumericLiteral":
|
|
20602
|
+
case "BooleanLiteral":
|
|
20603
|
+
case "NullLiteral":
|
|
20604
|
+
case "BigIntLiteral":
|
|
20605
|
+
return true;
|
|
20556
20606
|
}
|
|
20607
|
+
return false;
|
|
20557
20608
|
}
|
|
20558
20609
|
|
|
20559
|
-
const version = "3.3.
|
|
20610
|
+
const version = "3.3.4";
|
|
20560
20611
|
const walk = estreeWalker.walk;
|
|
20561
20612
|
|
|
20562
20613
|
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;
|
|
@@ -146,7 +146,7 @@ function normalizeStyle(value) {
|
|
|
146
146
|
}
|
|
147
147
|
const listDelimiterRE = /;(?![^(]*\))/g;
|
|
148
148
|
const propertyDelimiterRE = /:([^]+)/;
|
|
149
|
-
const styleCommentRE =
|
|
149
|
+
const styleCommentRE = /\/\*[^]*?\*\//g;
|
|
150
150
|
function parseStringStyle(cssText) {
|
|
151
151
|
const ret = {};
|
|
152
152
|
cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
|
|
@@ -26963,7 +26963,8 @@ function processExp(exp, dir) {
|
|
|
26963
26963
|
} else if (dir === "for") {
|
|
26964
26964
|
const inMatch = exp.match(forAliasRE);
|
|
26965
26965
|
if (inMatch) {
|
|
26966
|
-
|
|
26966
|
+
let [, LHS, RHS] = inMatch;
|
|
26967
|
+
LHS = LHS.trim().replace(/^\(|\)$/g, "");
|
|
26967
26968
|
return processExp(`(${LHS})=>{}`) + processExp(RHS);
|
|
26968
26969
|
}
|
|
26969
26970
|
}
|
|
@@ -48102,7 +48103,7 @@ function qualifiedNameToPath(node) {
|
|
|
48102
48103
|
}
|
|
48103
48104
|
function resolveGlobalScope(ctx) {
|
|
48104
48105
|
if (ctx.options.globalTypeFiles) {
|
|
48105
|
-
const fs = ctx
|
|
48106
|
+
const fs = resolveFS(ctx);
|
|
48106
48107
|
if (!fs) {
|
|
48107
48108
|
throw new Error("[vue/compiler-sfc] globalTypeFiles requires fs access.");
|
|
48108
48109
|
}
|
|
@@ -48115,15 +48116,38 @@ let ts;
|
|
|
48115
48116
|
function registerTS(_ts) {
|
|
48116
48117
|
ts = _ts;
|
|
48117
48118
|
}
|
|
48119
|
+
function resolveFS(ctx) {
|
|
48120
|
+
if (ctx.fs) {
|
|
48121
|
+
return ctx.fs;
|
|
48122
|
+
}
|
|
48123
|
+
const fs = ctx.options.fs || ts.sys;
|
|
48124
|
+
if (!fs) {
|
|
48125
|
+
return;
|
|
48126
|
+
}
|
|
48127
|
+
return ctx.fs = {
|
|
48128
|
+
fileExists(file) {
|
|
48129
|
+
if (file.endsWith(".vue.ts")) {
|
|
48130
|
+
file = file.replace(/\.ts$/, "");
|
|
48131
|
+
}
|
|
48132
|
+
return fs.fileExists(file);
|
|
48133
|
+
},
|
|
48134
|
+
readFile(file) {
|
|
48135
|
+
if (file.endsWith(".vue.ts")) {
|
|
48136
|
+
file = file.replace(/\.ts$/, "");
|
|
48137
|
+
}
|
|
48138
|
+
return fs.readFile(file);
|
|
48139
|
+
}
|
|
48140
|
+
};
|
|
48141
|
+
}
|
|
48118
48142
|
function resolveTypeFromImport(ctx, node, name, scope) {
|
|
48119
48143
|
const { source, imported } = scope.imports[name];
|
|
48120
48144
|
const sourceScope = importSourceToScope(ctx, node, scope, source);
|
|
48121
48145
|
return resolveTypeReference(ctx, node, sourceScope, imported, true);
|
|
48122
48146
|
}
|
|
48123
48147
|
function importSourceToScope(ctx, node, scope, source) {
|
|
48124
|
-
const fs = ctx
|
|
48148
|
+
const fs = resolveFS(ctx);
|
|
48125
48149
|
if (!fs) {
|
|
48126
|
-
ctx.error(
|
|
48150
|
+
return ctx.error(
|
|
48127
48151
|
`No fs option provided to \`compileScript\` in non-Node environment. File system access is required for resolving imported types.`,
|
|
48128
48152
|
node,
|
|
48129
48153
|
scope
|
|
@@ -48167,6 +48191,7 @@ function importSourceToScope(ctx, node, scope, source) {
|
|
|
48167
48191
|
}
|
|
48168
48192
|
}
|
|
48169
48193
|
function resolveExt(filename, fs) {
|
|
48194
|
+
filename = filename.replace(/\.js$/, "");
|
|
48170
48195
|
const tryResolve = (filename2) => {
|
|
48171
48196
|
if (fs.fileExists(filename2))
|
|
48172
48197
|
return filename2;
|
|
@@ -48192,7 +48217,7 @@ function fileToScope(ctx, filename, asGlobal = false) {
|
|
|
48192
48217
|
if (cached) {
|
|
48193
48218
|
return cached;
|
|
48194
48219
|
}
|
|
48195
|
-
const fs = ctx
|
|
48220
|
+
const fs = resolveFS(ctx);
|
|
48196
48221
|
const source = fs.readFile(filename) || "";
|
|
48197
48222
|
const body = parseFile(filename, source, ctx.options.babelParserPlugins);
|
|
48198
48223
|
const scope = new TypeScope(filename, source, 0, recordImports(body));
|
|
@@ -48327,6 +48352,18 @@ function recordTypes(ctx, body, scope, asGlobal = false) {
|
|
|
48327
48352
|
stmt.source.value
|
|
48328
48353
|
);
|
|
48329
48354
|
Object.assign(scope.exportedTypes, sourceScope.exportedTypes);
|
|
48355
|
+
} else if (stmt.type === "ExportDefaultDeclaration" && stmt.declaration) {
|
|
48356
|
+
if (stmt.declaration.type !== "Identifier") {
|
|
48357
|
+
recordType(stmt.declaration, types, declares, "default");
|
|
48358
|
+
recordType(
|
|
48359
|
+
stmt.declaration,
|
|
48360
|
+
exportedTypes,
|
|
48361
|
+
exportedDeclares,
|
|
48362
|
+
"default"
|
|
48363
|
+
);
|
|
48364
|
+
} else if (types[stmt.declaration.name]) {
|
|
48365
|
+
exportedTypes["default"] = types[stmt.declaration.name];
|
|
48366
|
+
}
|
|
48330
48367
|
}
|
|
48331
48368
|
}
|
|
48332
48369
|
}
|
|
@@ -48340,12 +48377,12 @@ function recordTypes(ctx, body, scope, asGlobal = false) {
|
|
|
48340
48377
|
declares[key]._ownerScope = scope;
|
|
48341
48378
|
}
|
|
48342
48379
|
}
|
|
48343
|
-
function recordType(node, types, declares) {
|
|
48380
|
+
function recordType(node, types, declares, overwriteId) {
|
|
48344
48381
|
switch (node.type) {
|
|
48345
48382
|
case "TSInterfaceDeclaration":
|
|
48346
48383
|
case "TSEnumDeclaration":
|
|
48347
48384
|
case "TSModuleDeclaration": {
|
|
48348
|
-
const id = getId(node.id);
|
|
48385
|
+
const id = overwriteId || getId(node.id);
|
|
48349
48386
|
let existing = types[id];
|
|
48350
48387
|
if (existing) {
|
|
48351
48388
|
if (node.type === "TSModuleDeclaration") {
|
|
@@ -48375,7 +48412,7 @@ function recordType(node, types, declares) {
|
|
|
48375
48412
|
break;
|
|
48376
48413
|
}
|
|
48377
48414
|
case "ClassDeclaration":
|
|
48378
|
-
types[getId(node.id)] = node;
|
|
48415
|
+
types[overwriteId || getId(node.id)] = node;
|
|
48379
48416
|
break;
|
|
48380
48417
|
case "TSTypeAliasDeclaration":
|
|
48381
48418
|
types[node.id.name] = node.typeAnnotation;
|
|
@@ -48723,6 +48760,20 @@ function resolveReturnType(ctx, arg, scope) {
|
|
|
48723
48760
|
return resolved.returnType;
|
|
48724
48761
|
}
|
|
48725
48762
|
}
|
|
48763
|
+
function resolveUnionType(ctx, node, scope) {
|
|
48764
|
+
if (node.type === "TSTypeReference") {
|
|
48765
|
+
const resolved = resolveTypeReference(ctx, node, scope);
|
|
48766
|
+
if (resolved)
|
|
48767
|
+
node = resolved;
|
|
48768
|
+
}
|
|
48769
|
+
let types;
|
|
48770
|
+
if (node.type === "TSUnionType") {
|
|
48771
|
+
types = node.types.flatMap((node2) => resolveUnionType(ctx, node2, scope));
|
|
48772
|
+
} else {
|
|
48773
|
+
types = [node];
|
|
48774
|
+
}
|
|
48775
|
+
return types;
|
|
48776
|
+
}
|
|
48726
48777
|
|
|
48727
48778
|
const DEFINE_MODEL = "defineModel";
|
|
48728
48779
|
function processDefineModel(ctx, node, declId) {
|
|
@@ -49013,7 +49064,7 @@ function genDestructuredDefaultValue(ctx, key, inferredType) {
|
|
|
49013
49064
|
if (defaultVal) {
|
|
49014
49065
|
const value = ctx.getString(defaultVal);
|
|
49015
49066
|
const unwrapped = unwrapTSNode(defaultVal);
|
|
49016
|
-
if (inferredType && inferredType.length && !inferredType.includes(
|
|
49067
|
+
if (inferredType && inferredType.length && !inferredType.includes("null")) {
|
|
49017
49068
|
const valueType = inferValueType(unwrapped);
|
|
49018
49069
|
if (valueType && !inferredType.includes(valueType)) {
|
|
49019
49070
|
ctx.error(
|
|
@@ -49282,7 +49333,7 @@ function extractRuntimeEmits(ctx) {
|
|
|
49282
49333
|
const emits = /* @__PURE__ */ new Set();
|
|
49283
49334
|
const node = ctx.emitsTypeDecl;
|
|
49284
49335
|
if (node.type === "TSFunctionType") {
|
|
49285
|
-
extractEventNames(node.parameters[0], emits);
|
|
49336
|
+
extractEventNames(ctx, node.parameters[0], emits);
|
|
49286
49337
|
return emits;
|
|
49287
49338
|
}
|
|
49288
49339
|
const { props, calls } = resolveTypeElements(ctx, node);
|
|
@@ -49299,22 +49350,18 @@ function extractRuntimeEmits(ctx) {
|
|
|
49299
49350
|
);
|
|
49300
49351
|
}
|
|
49301
49352
|
for (const call of calls) {
|
|
49302
|
-
extractEventNames(call.parameters[0], emits);
|
|
49353
|
+
extractEventNames(ctx, call.parameters[0], emits);
|
|
49303
49354
|
}
|
|
49304
49355
|
}
|
|
49305
49356
|
return emits;
|
|
49306
49357
|
}
|
|
49307
|
-
function extractEventNames(eventName, emits) {
|
|
49358
|
+
function extractEventNames(ctx, eventName, emits) {
|
|
49308
49359
|
if (eventName.type === "Identifier" && eventName.typeAnnotation && eventName.typeAnnotation.type === "TSTypeAnnotation") {
|
|
49309
|
-
const
|
|
49310
|
-
|
|
49311
|
-
if (
|
|
49312
|
-
|
|
49313
|
-
|
|
49314
|
-
} else if (typeNode.type === "TSUnionType") {
|
|
49315
|
-
for (const t of typeNode.types) {
|
|
49316
|
-
if (t.type === "TSLiteralType" && t.literal.type !== "UnaryExpression" && t.literal.type !== "TemplateLiteral") {
|
|
49317
|
-
emits.add(String(t.literal.value));
|
|
49360
|
+
const types = resolveUnionType(ctx, eventName.typeAnnotation.typeAnnotation);
|
|
49361
|
+
for (const type of types) {
|
|
49362
|
+
if (type.type === "TSLiteralType") {
|
|
49363
|
+
if (type.literal.type !== "UnaryExpression" && type.literal.type !== "TemplateLiteral") {
|
|
49364
|
+
emits.add(String(type.literal.value));
|
|
49318
49365
|
}
|
|
49319
49366
|
}
|
|
49320
49367
|
}
|
|
@@ -50231,6 +50278,7 @@ function canNeverBeRef(node, userReactiveImport) {
|
|
|
50231
50278
|
}
|
|
50232
50279
|
}
|
|
50233
50280
|
function isStaticNode(node) {
|
|
50281
|
+
node = unwrapTSNode(node);
|
|
50234
50282
|
switch (node.type) {
|
|
50235
50283
|
case "UnaryExpression":
|
|
50236
50284
|
return isStaticNode(node.argument);
|
|
@@ -50244,19 +50292,18 @@ function isStaticNode(node) {
|
|
|
50244
50292
|
case "TemplateLiteral":
|
|
50245
50293
|
return node.expressions.every((expr) => isStaticNode(expr));
|
|
50246
50294
|
case "ParenthesizedExpression":
|
|
50247
|
-
case "TSNonNullExpression":
|
|
50248
|
-
case "TSAsExpression":
|
|
50249
|
-
case "TSTypeAssertion":
|
|
50250
50295
|
return isStaticNode(node.expression);
|
|
50251
|
-
|
|
50252
|
-
|
|
50253
|
-
|
|
50254
|
-
|
|
50255
|
-
|
|
50296
|
+
case "StringLiteral":
|
|
50297
|
+
case "NumericLiteral":
|
|
50298
|
+
case "BooleanLiteral":
|
|
50299
|
+
case "NullLiteral":
|
|
50300
|
+
case "BigIntLiteral":
|
|
50301
|
+
return true;
|
|
50256
50302
|
}
|
|
50303
|
+
return false;
|
|
50257
50304
|
}
|
|
50258
50305
|
|
|
50259
|
-
const version = "3.3.
|
|
50306
|
+
const version = "3.3.4";
|
|
50260
50307
|
const walk = walk$1;
|
|
50261
50308
|
|
|
50262
50309
|
export { MagicString, parse_1$1 as babelParse, compileScript, compileStyle, compileStyleAsync, compileTemplate, extractIdentifiers, generateCodeFrame, inferRuntimeType, invalidateTypeCache, isInDestructureAssignment, isStaticProperty, parse$7 as parse, parseCache, registerTS, resolveTypeElements, rewriteDefault, rewriteDefaultAST, shouldTransform as shouldTransformRef, transform as transformRef, transformAST as transformRefAST, version, walk, walkIdentifiers };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/compiler-sfc",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.4",
|
|
4
4
|
"description": "@vue/compiler-sfc",
|
|
5
5
|
"main": "dist/compiler-sfc.cjs.js",
|
|
6
6
|
"module": "dist/compiler-sfc.esm-browser.js",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-sfc#readme",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/parser": "^7.20.15",
|
|
36
|
-
"@vue/compiler-core": "3.3.
|
|
37
|
-
"@vue/compiler-dom": "3.3.
|
|
38
|
-
"@vue/compiler-ssr": "3.3.
|
|
39
|
-
"@vue/reactivity-transform": "3.3.
|
|
40
|
-
"@vue/shared": "3.3.
|
|
36
|
+
"@vue/compiler-core": "3.3.4",
|
|
37
|
+
"@vue/compiler-dom": "3.3.4",
|
|
38
|
+
"@vue/compiler-ssr": "3.3.4",
|
|
39
|
+
"@vue/reactivity-transform": "3.3.4",
|
|
40
|
+
"@vue/shared": "3.3.4",
|
|
41
41
|
"estree-walker": "^2.0.2",
|
|
42
42
|
"magic-string": "^0.30.0",
|
|
43
43
|
"postcss": "^8.1.10",
|