@vue/compiler-sfc 3.5.17 → 3.5.19
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 +62 -22
- package/dist/compiler-sfc.d.ts +1 -1
- package/dist/compiler-sfc.esm-browser.js +268 -142
- package/package.json +8 -8
package/dist/compiler-sfc.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-sfc v3.5.
|
|
2
|
+
* @vue/compiler-sfc v3.5.19
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -127,7 +127,14 @@ const CSS_VARS_HELPER = `useCssVars`;
|
|
|
127
127
|
function genCssVarsFromList(vars, id, isProd, isSSR = false) {
|
|
128
128
|
return `{
|
|
129
129
|
${vars.map(
|
|
130
|
-
(key) =>
|
|
130
|
+
(key) => (
|
|
131
|
+
// The `:` prefix here is used in `ssrRenderStyle` to distinguish whether
|
|
132
|
+
// a custom property comes from `ssrCssVars`. If it does, we need to reset
|
|
133
|
+
// its value to `initial` on the component instance to avoid unintentionally
|
|
134
|
+
// inheriting the same property value from a different instance of the same
|
|
135
|
+
// component in the outer scope.
|
|
136
|
+
`"${isSSR ? `:--` : ``}${genVarName(id, key, isProd, isSSR)}": (${key})`
|
|
137
|
+
)
|
|
131
138
|
).join(",\n ")}
|
|
132
139
|
}`;
|
|
133
140
|
}
|
|
@@ -2213,7 +2220,7 @@ const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
|
|
|
2213
2220
|
}
|
|
2214
2221
|
}
|
|
2215
2222
|
const shouldProcessUrl = (url) => {
|
|
2216
|
-
return !isExternalUrl(url) && !isDataUrl(url) && (options.includeAbsolute || isRelativeUrl(url));
|
|
2223
|
+
return url && !isExternalUrl(url) && !isDataUrl(url) && (options.includeAbsolute || isRelativeUrl(url));
|
|
2217
2224
|
};
|
|
2218
2225
|
if (!imageCandidates.some(({ url }) => shouldProcessUrl(url))) {
|
|
2219
2226
|
return;
|
|
@@ -7980,6 +7987,7 @@ var selectorParser = /*@__PURE__*/getDefaultExportFromCjs(distExports);
|
|
|
7980
7987
|
|
|
7981
7988
|
const animationNameRE = /^(-\w+-)?animation-name$/;
|
|
7982
7989
|
const animationRE = /^(-\w+-)?animation$/;
|
|
7990
|
+
const keyframesRE = /^(?:-\w+-)?keyframes$/;
|
|
7983
7991
|
const scopedPlugin = (id = "") => {
|
|
7984
7992
|
const keyframes = /* @__PURE__ */ Object.create(null);
|
|
7985
7993
|
const shortId = id.replace(/^data-v-/, "");
|
|
@@ -7989,7 +7997,7 @@ const scopedPlugin = (id = "") => {
|
|
|
7989
7997
|
processRule(id, rule);
|
|
7990
7998
|
},
|
|
7991
7999
|
AtRule(node) {
|
|
7992
|
-
if (
|
|
8000
|
+
if (keyframesRE.test(node.name) && !node.params.endsWith(`-${shortId}`)) {
|
|
7993
8001
|
keyframes[node.params] = node.params = node.params + "-" + shortId;
|
|
7994
8002
|
}
|
|
7995
8003
|
},
|
|
@@ -8018,7 +8026,7 @@ const scopedPlugin = (id = "") => {
|
|
|
8018
8026
|
};
|
|
8019
8027
|
const processedRules = /* @__PURE__ */ new WeakSet();
|
|
8020
8028
|
function processRule(id, rule) {
|
|
8021
|
-
if (processedRules.has(rule) || rule.parent && rule.parent.type === "atrule" &&
|
|
8029
|
+
if (processedRules.has(rule) || rule.parent && rule.parent.type === "atrule" && keyframesRE.test(rule.parent.name)) {
|
|
8022
8030
|
return;
|
|
8023
8031
|
}
|
|
8024
8032
|
processedRules.add(rule);
|
|
@@ -22998,7 +23006,7 @@ function recordImport(node, imports) {
|
|
|
22998
23006
|
};
|
|
22999
23007
|
}
|
|
23000
23008
|
}
|
|
23001
|
-
function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx), isKeyOf = false) {
|
|
23009
|
+
function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx), isKeyOf = false, typeParameters) {
|
|
23002
23010
|
try {
|
|
23003
23011
|
switch (node.type) {
|
|
23004
23012
|
case "TSStringKeyword":
|
|
@@ -23071,12 +23079,38 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
|
|
|
23071
23079
|
case "TSTypeReference": {
|
|
23072
23080
|
const resolved = resolveTypeReference(ctx, node, scope);
|
|
23073
23081
|
if (resolved) {
|
|
23074
|
-
if (resolved.type === "TSTypeAliasDeclaration"
|
|
23075
|
-
|
|
23082
|
+
if (resolved.type === "TSTypeAliasDeclaration") {
|
|
23083
|
+
if (resolved.typeAnnotation.type === "TSFunctionType") {
|
|
23084
|
+
return ["Function"];
|
|
23085
|
+
}
|
|
23086
|
+
if (node.typeParameters) {
|
|
23087
|
+
const typeParams = /* @__PURE__ */ Object.create(null);
|
|
23088
|
+
if (resolved.typeParameters) {
|
|
23089
|
+
resolved.typeParameters.params.forEach((p, i) => {
|
|
23090
|
+
typeParams[p.name] = node.typeParameters.params[i];
|
|
23091
|
+
});
|
|
23092
|
+
}
|
|
23093
|
+
return inferRuntimeType(
|
|
23094
|
+
ctx,
|
|
23095
|
+
resolved.typeAnnotation,
|
|
23096
|
+
resolved._ownerScope,
|
|
23097
|
+
isKeyOf,
|
|
23098
|
+
typeParams
|
|
23099
|
+
);
|
|
23100
|
+
}
|
|
23076
23101
|
}
|
|
23077
23102
|
return inferRuntimeType(ctx, resolved, resolved._ownerScope, isKeyOf);
|
|
23078
23103
|
}
|
|
23079
23104
|
if (node.typeName.type === "Identifier") {
|
|
23105
|
+
if (typeParameters && typeParameters[node.typeName.name]) {
|
|
23106
|
+
return inferRuntimeType(
|
|
23107
|
+
ctx,
|
|
23108
|
+
typeParameters[node.typeName.name],
|
|
23109
|
+
scope,
|
|
23110
|
+
isKeyOf,
|
|
23111
|
+
typeParameters
|
|
23112
|
+
);
|
|
23113
|
+
}
|
|
23080
23114
|
if (isKeyOf) {
|
|
23081
23115
|
switch (node.typeName.name) {
|
|
23082
23116
|
case "String":
|
|
@@ -23199,11 +23233,15 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
|
|
|
23199
23233
|
case "TSParenthesizedType":
|
|
23200
23234
|
return inferRuntimeType(ctx, node.typeAnnotation, scope);
|
|
23201
23235
|
case "TSUnionType":
|
|
23202
|
-
return flattenTypes(ctx, node.types, scope, isKeyOf);
|
|
23236
|
+
return flattenTypes(ctx, node.types, scope, isKeyOf, typeParameters);
|
|
23203
23237
|
case "TSIntersectionType": {
|
|
23204
|
-
return flattenTypes(
|
|
23205
|
-
|
|
23206
|
-
|
|
23238
|
+
return flattenTypes(
|
|
23239
|
+
ctx,
|
|
23240
|
+
node.types,
|
|
23241
|
+
scope,
|
|
23242
|
+
isKeyOf,
|
|
23243
|
+
typeParameters
|
|
23244
|
+
).filter((t) => t !== UNKNOWN_TYPE);
|
|
23207
23245
|
}
|
|
23208
23246
|
case "TSEnumDeclaration":
|
|
23209
23247
|
return inferEnumType(node);
|
|
@@ -23258,14 +23296,16 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
|
|
|
23258
23296
|
}
|
|
23259
23297
|
return [UNKNOWN_TYPE];
|
|
23260
23298
|
}
|
|
23261
|
-
function flattenTypes(ctx, types, scope, isKeyOf = false) {
|
|
23299
|
+
function flattenTypes(ctx, types, scope, isKeyOf = false, typeParameters = void 0) {
|
|
23262
23300
|
if (types.length === 1) {
|
|
23263
|
-
return inferRuntimeType(ctx, types[0], scope, isKeyOf);
|
|
23301
|
+
return inferRuntimeType(ctx, types[0], scope, isKeyOf, typeParameters);
|
|
23264
23302
|
}
|
|
23265
23303
|
return [
|
|
23266
23304
|
...new Set(
|
|
23267
23305
|
[].concat(
|
|
23268
|
-
...types.map(
|
|
23306
|
+
...types.map(
|
|
23307
|
+
(t) => inferRuntimeType(ctx, t, scope, isKeyOf, typeParameters)
|
|
23308
|
+
)
|
|
23269
23309
|
)
|
|
23270
23310
|
)
|
|
23271
23311
|
];
|
|
@@ -24150,23 +24190,23 @@ function compileScript(sfc, options) {
|
|
|
24150
24190
|
Upgrade your vite or vue-loader version for compatibility with the latest experimental proposals.`
|
|
24151
24191
|
);
|
|
24152
24192
|
}
|
|
24153
|
-
const ctx = new ScriptCompileContext(sfc, options);
|
|
24154
24193
|
const { script, scriptSetup, source, filename } = sfc;
|
|
24155
24194
|
const hoistStatic = options.hoistStatic !== false && !script;
|
|
24156
24195
|
const scopeId = options.id ? options.id.replace(/^data-v-/, "") : "";
|
|
24157
24196
|
const scriptLang = script && script.lang;
|
|
24158
24197
|
const scriptSetupLang = scriptSetup && scriptSetup.lang;
|
|
24198
|
+
if (script && scriptSetup && scriptLang !== scriptSetupLang) {
|
|
24199
|
+
throw new Error(
|
|
24200
|
+
`[@vue/compiler-sfc] <script> and <script setup> must have the same language type.`
|
|
24201
|
+
);
|
|
24202
|
+
}
|
|
24203
|
+
const ctx = new ScriptCompileContext(sfc, options);
|
|
24159
24204
|
if (!scriptSetup) {
|
|
24160
24205
|
if (!script) {
|
|
24161
24206
|
throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
|
|
24162
24207
|
}
|
|
24163
24208
|
return processNormalScript(ctx, scopeId);
|
|
24164
24209
|
}
|
|
24165
|
-
if (script && scriptLang !== scriptSetupLang) {
|
|
24166
|
-
throw new Error(
|
|
24167
|
-
`[@vue/compiler-sfc] <script> and <script setup> must have the same language type.`
|
|
24168
|
-
);
|
|
24169
|
-
}
|
|
24170
24210
|
if (scriptSetupLang && !ctx.isJS && !ctx.isTS) {
|
|
24171
24211
|
return scriptSetup;
|
|
24172
24212
|
}
|
|
@@ -24974,7 +25014,7 @@ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
|
|
|
24974
25014
|
return generator.toJSON();
|
|
24975
25015
|
}
|
|
24976
25016
|
|
|
24977
|
-
const version = "3.5.
|
|
25017
|
+
const version = "3.5.19";
|
|
24978
25018
|
const parseCache = parseCache$1;
|
|
24979
25019
|
const errorMessages = {
|
|
24980
25020
|
...CompilerDOM.errorMessages,
|
package/dist/compiler-sfc.d.ts
CHANGED
|
@@ -464,7 +464,7 @@ export declare function registerTS(_loadTS: () => typeof TS): void;
|
|
|
464
464
|
* @private
|
|
465
465
|
*/
|
|
466
466
|
export declare function invalidateTypeCache(filename: string): void;
|
|
467
|
-
export declare function inferRuntimeType(ctx: TypeResolveContext, node: Node & MaybeWithScope, scope?: TypeScope, isKeyOf?: boolean): string[];
|
|
467
|
+
export declare function inferRuntimeType(ctx: TypeResolveContext, node: Node & MaybeWithScope, scope?: TypeScope, isKeyOf?: boolean, typeParameters?: Record<string, Node>): string[];
|
|
468
468
|
|
|
469
469
|
export declare function extractRuntimeEmits(ctx: TypeResolveContext): Set<string>;
|
|
470
470
|
|