@vue/compiler-sfc 3.3.9 → 3.3.11
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 +209 -49
- package/dist/compiler-sfc.d.ts +6 -1
- package/dist/compiler-sfc.esm-browser.js +202 -57
- package/package.json +10 -10
package/dist/compiler-sfc.cjs.js
CHANGED
|
@@ -94,8 +94,11 @@ function getEscapedPropName(key) {
|
|
|
94
94
|
return propNameEscapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
|
|
95
95
|
}
|
|
96
96
|
const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
|
|
97
|
-
function getEscapedCssVarName(key) {
|
|
98
|
-
return key.replace(
|
|
97
|
+
function getEscapedCssVarName(key, doubleEscape) {
|
|
98
|
+
return key.replace(
|
|
99
|
+
cssVarNameEscapeSymbolsRE,
|
|
100
|
+
(s) => doubleEscape ? `\\\\${s}` : `\\${s}`
|
|
101
|
+
);
|
|
99
102
|
}
|
|
100
103
|
|
|
101
104
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -178,15 +181,15 @@ const CSS_VARS_HELPER = `useCssVars`;
|
|
|
178
181
|
function genCssVarsFromList(vars, id, isProd, isSSR = false) {
|
|
179
182
|
return `{
|
|
180
183
|
${vars.map(
|
|
181
|
-
(key) => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd)}": (${key})`
|
|
184
|
+
(key) => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd, isSSR)}": (${key})`
|
|
182
185
|
).join(",\n ")}
|
|
183
186
|
}`;
|
|
184
187
|
}
|
|
185
|
-
function genVarName(id, raw, isProd) {
|
|
188
|
+
function genVarName(id, raw, isProd, isSSR = false) {
|
|
186
189
|
if (isProd) {
|
|
187
190
|
return hash$1(id + raw);
|
|
188
191
|
} else {
|
|
189
|
-
return `${id}-${getEscapedCssVarName(raw)}`;
|
|
192
|
+
return `${id}-${getEscapedCssVarName(raw, isSSR)}`;
|
|
190
193
|
}
|
|
191
194
|
}
|
|
192
195
|
function normalizeExpression(exp) {
|
|
@@ -1041,6 +1044,37 @@ class LRUCache {
|
|
|
1041
1044
|
}
|
|
1042
1045
|
return deleted;
|
|
1043
1046
|
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Get the extended info about a given entry, to get its value, size, and
|
|
1049
|
+
* TTL info simultaneously. Like {@link LRUCache#dump}, but just for a
|
|
1050
|
+
* single key. Always returns stale values, if their info is found in the
|
|
1051
|
+
* cache, so be sure to check for expired TTLs if relevant.
|
|
1052
|
+
*/
|
|
1053
|
+
info(key) {
|
|
1054
|
+
const i = this.#keyMap.get(key);
|
|
1055
|
+
if (i === undefined)
|
|
1056
|
+
return undefined;
|
|
1057
|
+
const v = this.#valList[i];
|
|
1058
|
+
const value = this.#isBackgroundFetch(v)
|
|
1059
|
+
? v.__staleWhileFetching
|
|
1060
|
+
: v;
|
|
1061
|
+
if (value === undefined)
|
|
1062
|
+
return undefined;
|
|
1063
|
+
const entry = { value };
|
|
1064
|
+
if (this.#ttls && this.#starts) {
|
|
1065
|
+
const ttl = this.#ttls[i];
|
|
1066
|
+
const start = this.#starts[i];
|
|
1067
|
+
if (ttl && start) {
|
|
1068
|
+
const remain = ttl - (perf.now() - start);
|
|
1069
|
+
entry.ttl = remain;
|
|
1070
|
+
entry.start = Date.now();
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
if (this.#sizes) {
|
|
1074
|
+
entry.size = this.#sizes[i];
|
|
1075
|
+
}
|
|
1076
|
+
return entry;
|
|
1077
|
+
}
|
|
1044
1078
|
/**
|
|
1045
1079
|
* Return an array of [key, {@link LRUCache.Entry}] tuples which can be
|
|
1046
1080
|
* passed to cache.load()
|
|
@@ -1935,22 +1969,29 @@ function parse$2(source, {
|
|
|
1935
1969
|
descriptor.script = null;
|
|
1936
1970
|
}
|
|
1937
1971
|
}
|
|
1972
|
+
let templateColumnOffset = 0;
|
|
1973
|
+
if (descriptor.template && (descriptor.template.lang === "pug" || descriptor.template.lang === "jade")) {
|
|
1974
|
+
[descriptor.template.content, templateColumnOffset] = dedent(
|
|
1975
|
+
descriptor.template.content
|
|
1976
|
+
);
|
|
1977
|
+
}
|
|
1938
1978
|
if (sourceMap) {
|
|
1939
|
-
const genMap = (block) => {
|
|
1979
|
+
const genMap = (block, columnOffset = 0) => {
|
|
1940
1980
|
if (block && !block.src) {
|
|
1941
1981
|
block.map = generateSourceMap(
|
|
1942
1982
|
filename,
|
|
1943
1983
|
source,
|
|
1944
1984
|
block.content,
|
|
1945
1985
|
sourceRoot,
|
|
1946
|
-
!pad || block.type === "template" ? block.loc.start.line - 1 : 0
|
|
1986
|
+
!pad || block.type === "template" ? block.loc.start.line - 1 : 0,
|
|
1987
|
+
columnOffset
|
|
1947
1988
|
);
|
|
1948
1989
|
}
|
|
1949
1990
|
};
|
|
1950
|
-
genMap(descriptor.template);
|
|
1991
|
+
genMap(descriptor.template, templateColumnOffset);
|
|
1951
1992
|
genMap(descriptor.script);
|
|
1952
|
-
descriptor.styles.forEach(genMap);
|
|
1953
|
-
descriptor.customBlocks.forEach(genMap);
|
|
1993
|
+
descriptor.styles.forEach((s) => genMap(s));
|
|
1994
|
+
descriptor.customBlocks.forEach((s) => genMap(s));
|
|
1954
1995
|
}
|
|
1955
1996
|
descriptor.cssVars = parseCssVars(descriptor);
|
|
1956
1997
|
const slottedRE = /(?:::v-|:)slotted\(/;
|
|
@@ -2028,7 +2069,7 @@ function createBlock(node, source, pad) {
|
|
|
2028
2069
|
const splitRE = /\r?\n/g;
|
|
2029
2070
|
const emptyRE = /^(?:\/\/)?\s*$/;
|
|
2030
2071
|
const replaceRE = /./g;
|
|
2031
|
-
function generateSourceMap(filename, source, generated, sourceRoot, lineOffset) {
|
|
2072
|
+
function generateSourceMap(filename, source, generated, sourceRoot, lineOffset, columnOffset) {
|
|
2032
2073
|
const map = new sourceMapJs.SourceMapGenerator({
|
|
2033
2074
|
file: filename.replace(/\\/g, "/"),
|
|
2034
2075
|
sourceRoot: sourceRoot.replace(/\\/g, "/")
|
|
@@ -2044,7 +2085,7 @@ function generateSourceMap(filename, source, generated, sourceRoot, lineOffset)
|
|
|
2044
2085
|
source: filename,
|
|
2045
2086
|
original: {
|
|
2046
2087
|
line: originalLine,
|
|
2047
|
-
column: i
|
|
2088
|
+
column: i + columnOffset
|
|
2048
2089
|
},
|
|
2049
2090
|
generated: {
|
|
2050
2091
|
line: generatedLine,
|
|
@@ -2095,6 +2136,26 @@ function hmrShouldReload(prevImports, next) {
|
|
|
2095
2136
|
}
|
|
2096
2137
|
return false;
|
|
2097
2138
|
}
|
|
2139
|
+
function dedent(s) {
|
|
2140
|
+
const lines = s.split("\n");
|
|
2141
|
+
const minIndent = lines.reduce(function(minIndent2, line) {
|
|
2142
|
+
var _a, _b;
|
|
2143
|
+
if (line.trim() === "") {
|
|
2144
|
+
return minIndent2;
|
|
2145
|
+
}
|
|
2146
|
+
const indent = ((_b = (_a = line.match(/^\s*/)) == null ? void 0 : _a[0]) == null ? void 0 : _b.length) || 0;
|
|
2147
|
+
return Math.min(indent, minIndent2);
|
|
2148
|
+
}, Infinity);
|
|
2149
|
+
if (minIndent === 0) {
|
|
2150
|
+
return [s, minIndent];
|
|
2151
|
+
}
|
|
2152
|
+
return [
|
|
2153
|
+
lines.map(function(line) {
|
|
2154
|
+
return line.slice(minIndent);
|
|
2155
|
+
}).join("\n"),
|
|
2156
|
+
minIndent
|
|
2157
|
+
];
|
|
2158
|
+
}
|
|
2098
2159
|
|
|
2099
2160
|
function isRelativeUrl(url) {
|
|
2100
2161
|
const firstChar = url.charAt(0);
|
|
@@ -7909,14 +7970,19 @@ function rewriteSelector(id, selector, selectorRoot, slotted = false) {
|
|
|
7909
7970
|
return false;
|
|
7910
7971
|
}
|
|
7911
7972
|
}
|
|
7912
|
-
if (n.type !== "pseudo" && n.type !== "combinator") {
|
|
7973
|
+
if (n.type !== "pseudo" && n.type !== "combinator" || n.type === "pseudo" && (n.value === ":is" || n.value === ":where")) {
|
|
7913
7974
|
node = n;
|
|
7914
7975
|
}
|
|
7915
|
-
|
|
7916
|
-
|
|
7976
|
+
});
|
|
7977
|
+
if (node) {
|
|
7978
|
+
const { type, value } = node;
|
|
7979
|
+
if (type === "pseudo" && (value === ":is" || value === ":where")) {
|
|
7980
|
+
node.nodes.forEach(
|
|
7981
|
+
(value2) => rewriteSelector(id, value2, selectorRoot, slotted)
|
|
7982
|
+
);
|
|
7917
7983
|
shouldInject = false;
|
|
7918
7984
|
}
|
|
7919
|
-
}
|
|
7985
|
+
}
|
|
7920
7986
|
if (node) {
|
|
7921
7987
|
node.spaces.after = "";
|
|
7922
7988
|
} else {
|
|
@@ -15606,6 +15672,7 @@ class ScriptCompileContext {
|
|
|
15606
15672
|
constructor(descriptor, options) {
|
|
15607
15673
|
this.descriptor = descriptor;
|
|
15608
15674
|
this.options = options;
|
|
15675
|
+
this.isCE = false;
|
|
15609
15676
|
this.source = this.descriptor.source;
|
|
15610
15677
|
this.filename = this.descriptor.filename;
|
|
15611
15678
|
this.s = new MagicString(this.source);
|
|
@@ -15632,6 +15699,11 @@ class ScriptCompileContext {
|
|
|
15632
15699
|
const scriptSetupLang = scriptSetup && scriptSetup.lang;
|
|
15633
15700
|
this.isJS = scriptLang === "js" || scriptLang === "jsx" || scriptSetupLang === "js" || scriptSetupLang === "jsx";
|
|
15634
15701
|
this.isTS = scriptLang === "ts" || scriptLang === "tsx" || scriptSetupLang === "ts" || scriptSetupLang === "tsx";
|
|
15702
|
+
const customElement = options.customElement;
|
|
15703
|
+
const filename = this.descriptor.filename;
|
|
15704
|
+
if (customElement) {
|
|
15705
|
+
this.isCE = typeof customElement === "boolean" ? customElement : customElement(filename);
|
|
15706
|
+
}
|
|
15635
15707
|
const plugins = resolveParserPlugins(
|
|
15636
15708
|
scriptLang || scriptSetupLang,
|
|
15637
15709
|
options.babelParserPlugins
|
|
@@ -17743,33 +17815,39 @@ class TypeScope {
|
|
|
17743
17815
|
this.exportedDeclares = /* @__PURE__ */ Object.create(null);
|
|
17744
17816
|
}
|
|
17745
17817
|
}
|
|
17746
|
-
function resolveTypeElements(ctx, node, scope) {
|
|
17818
|
+
function resolveTypeElements(ctx, node, scope, typeParameters) {
|
|
17747
17819
|
if (node._resolvedElements) {
|
|
17748
17820
|
return node._resolvedElements;
|
|
17749
17821
|
}
|
|
17750
17822
|
return node._resolvedElements = innerResolveTypeElements(
|
|
17751
17823
|
ctx,
|
|
17752
17824
|
node,
|
|
17753
|
-
node._ownerScope || scope || ctxToScope(ctx)
|
|
17825
|
+
node._ownerScope || scope || ctxToScope(ctx),
|
|
17826
|
+
typeParameters
|
|
17754
17827
|
);
|
|
17755
17828
|
}
|
|
17756
|
-
function innerResolveTypeElements(ctx, node, scope) {
|
|
17829
|
+
function innerResolveTypeElements(ctx, node, scope, typeParameters) {
|
|
17757
17830
|
var _a, _b;
|
|
17758
17831
|
switch (node.type) {
|
|
17759
17832
|
case "TSTypeLiteral":
|
|
17760
|
-
return typeElementsToMap(ctx, node.members, scope);
|
|
17833
|
+
return typeElementsToMap(ctx, node.members, scope, typeParameters);
|
|
17761
17834
|
case "TSInterfaceDeclaration":
|
|
17762
|
-
return resolveInterfaceMembers(ctx, node, scope);
|
|
17835
|
+
return resolveInterfaceMembers(ctx, node, scope, typeParameters);
|
|
17763
17836
|
case "TSTypeAliasDeclaration":
|
|
17764
17837
|
case "TSParenthesizedType":
|
|
17765
|
-
return resolveTypeElements(
|
|
17838
|
+
return resolveTypeElements(
|
|
17839
|
+
ctx,
|
|
17840
|
+
node.typeAnnotation,
|
|
17841
|
+
scope,
|
|
17842
|
+
typeParameters
|
|
17843
|
+
);
|
|
17766
17844
|
case "TSFunctionType": {
|
|
17767
17845
|
return { props: {}, calls: [node] };
|
|
17768
17846
|
}
|
|
17769
17847
|
case "TSUnionType":
|
|
17770
17848
|
case "TSIntersectionType":
|
|
17771
17849
|
return mergeElements(
|
|
17772
|
-
node.types.map((t) => resolveTypeElements(ctx, t, scope)),
|
|
17850
|
+
node.types.map((t) => resolveTypeElements(ctx, t, scope, typeParameters)),
|
|
17773
17851
|
node.type
|
|
17774
17852
|
);
|
|
17775
17853
|
case "TSMappedType":
|
|
@@ -17786,20 +17864,53 @@ function innerResolveTypeElements(ctx, node, scope) {
|
|
|
17786
17864
|
const typeName = getReferenceName(node);
|
|
17787
17865
|
if ((typeName === "ExtractPropTypes" || typeName === "ExtractPublicPropTypes") && node.typeParameters && ((_a = scope.imports[typeName]) == null ? void 0 : _a.source) === "vue") {
|
|
17788
17866
|
return resolveExtractPropTypes(
|
|
17789
|
-
resolveTypeElements(
|
|
17867
|
+
resolveTypeElements(
|
|
17868
|
+
ctx,
|
|
17869
|
+
node.typeParameters.params[0],
|
|
17870
|
+
scope,
|
|
17871
|
+
typeParameters
|
|
17872
|
+
),
|
|
17790
17873
|
scope
|
|
17791
17874
|
);
|
|
17792
17875
|
}
|
|
17793
17876
|
const resolved = resolveTypeReference(ctx, node, scope);
|
|
17794
17877
|
if (resolved) {
|
|
17795
|
-
|
|
17878
|
+
const typeParams = /* @__PURE__ */ Object.create(null);
|
|
17879
|
+
if ((resolved.type === "TSTypeAliasDeclaration" || resolved.type === "TSInterfaceDeclaration") && resolved.typeParameters && node.typeParameters) {
|
|
17880
|
+
resolved.typeParameters.params.forEach((p, i) => {
|
|
17881
|
+
let param = typeParameters && typeParameters[p.name];
|
|
17882
|
+
if (!param)
|
|
17883
|
+
param = node.typeParameters.params[i];
|
|
17884
|
+
typeParams[p.name] = param;
|
|
17885
|
+
});
|
|
17886
|
+
}
|
|
17887
|
+
return resolveTypeElements(
|
|
17888
|
+
ctx,
|
|
17889
|
+
resolved,
|
|
17890
|
+
resolved._ownerScope,
|
|
17891
|
+
typeParams
|
|
17892
|
+
);
|
|
17796
17893
|
} else {
|
|
17797
17894
|
if (typeof typeName === "string") {
|
|
17895
|
+
if (typeParameters && typeParameters[typeName]) {
|
|
17896
|
+
return resolveTypeElements(
|
|
17897
|
+
ctx,
|
|
17898
|
+
typeParameters[typeName],
|
|
17899
|
+
scope,
|
|
17900
|
+
typeParameters
|
|
17901
|
+
);
|
|
17902
|
+
}
|
|
17798
17903
|
if (
|
|
17799
17904
|
// @ts-ignore
|
|
17800
17905
|
SupportedBuiltinsSet.has(typeName)
|
|
17801
17906
|
) {
|
|
17802
|
-
return resolveBuiltin(
|
|
17907
|
+
return resolveBuiltin(
|
|
17908
|
+
ctx,
|
|
17909
|
+
node,
|
|
17910
|
+
typeName,
|
|
17911
|
+
scope,
|
|
17912
|
+
typeParameters
|
|
17913
|
+
);
|
|
17803
17914
|
} else if (typeName === "ReturnType" && node.typeParameters) {
|
|
17804
17915
|
const ret = resolveReturnType(
|
|
17805
17916
|
ctx,
|
|
@@ -17848,10 +17959,14 @@ function innerResolveTypeElements(ctx, node, scope) {
|
|
|
17848
17959
|
}
|
|
17849
17960
|
return ctx.error(`Unresolvable type: ${node.type}`, node, scope);
|
|
17850
17961
|
}
|
|
17851
|
-
function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx)) {
|
|
17962
|
+
function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx), typeParameters) {
|
|
17852
17963
|
const res = { props: {} };
|
|
17853
17964
|
for (const e of elements) {
|
|
17854
17965
|
if (e.type === "TSPropertySignature" || e.type === "TSMethodSignature") {
|
|
17966
|
+
if (typeParameters) {
|
|
17967
|
+
scope = createChildScope(scope);
|
|
17968
|
+
Object.assign(scope.types, typeParameters);
|
|
17969
|
+
}
|
|
17855
17970
|
e._ownerScope = scope;
|
|
17856
17971
|
const name = getId(e.key);
|
|
17857
17972
|
if (name && !e.computed) {
|
|
@@ -17914,8 +18029,13 @@ function createProperty(key, typeAnnotation, scope, optional) {
|
|
|
17914
18029
|
_ownerScope: scope
|
|
17915
18030
|
};
|
|
17916
18031
|
}
|
|
17917
|
-
function resolveInterfaceMembers(ctx, node, scope) {
|
|
17918
|
-
const base = typeElementsToMap(
|
|
18032
|
+
function resolveInterfaceMembers(ctx, node, scope, typeParameters) {
|
|
18033
|
+
const base = typeElementsToMap(
|
|
18034
|
+
ctx,
|
|
18035
|
+
node.body.body,
|
|
18036
|
+
node._ownerScope,
|
|
18037
|
+
typeParameters
|
|
18038
|
+
);
|
|
17919
18039
|
if (node.extends) {
|
|
17920
18040
|
for (const ext of node.extends) {
|
|
17921
18041
|
if (ext.leadingComments && ext.leadingComments.some((c) => c.value.includes("@vue-ignore"))) {
|
|
@@ -18090,8 +18210,13 @@ const SupportedBuiltinsSet = /* @__PURE__ */ new Set([
|
|
|
18090
18210
|
"Pick",
|
|
18091
18211
|
"Omit"
|
|
18092
18212
|
]);
|
|
18093
|
-
function resolveBuiltin(ctx, node, name, scope) {
|
|
18094
|
-
const t = resolveTypeElements(
|
|
18213
|
+
function resolveBuiltin(ctx, node, name, scope, typeParameters) {
|
|
18214
|
+
const t = resolveTypeElements(
|
|
18215
|
+
ctx,
|
|
18216
|
+
node.typeParameters.params[0],
|
|
18217
|
+
scope,
|
|
18218
|
+
typeParameters
|
|
18219
|
+
);
|
|
18095
18220
|
switch (name) {
|
|
18096
18221
|
case "Partial": {
|
|
18097
18222
|
const res2 = { props: {}, calls: t.calls };
|
|
@@ -18219,7 +18344,21 @@ function resolveGlobalScope(ctx) {
|
|
|
18219
18344
|
let ts;
|
|
18220
18345
|
let loadTS;
|
|
18221
18346
|
function registerTS(_loadTS) {
|
|
18222
|
-
loadTS =
|
|
18347
|
+
loadTS = () => {
|
|
18348
|
+
try {
|
|
18349
|
+
return _loadTS();
|
|
18350
|
+
} catch (err) {
|
|
18351
|
+
if (typeof err.message === "string" && err.message.includes("Cannot find module")) {
|
|
18352
|
+
throw new Error(
|
|
18353
|
+
'Failed to load TypeScript, which is required for resolving imported types. Please make sure "typescript" is installed as a project dependency.'
|
|
18354
|
+
);
|
|
18355
|
+
} else {
|
|
18356
|
+
throw new Error(
|
|
18357
|
+
"Failed to load TypeScript for resolving imported types."
|
|
18358
|
+
);
|
|
18359
|
+
}
|
|
18360
|
+
}
|
|
18361
|
+
};
|
|
18223
18362
|
}
|
|
18224
18363
|
function resolveFS(ctx) {
|
|
18225
18364
|
if (ctx.fs) {
|
|
@@ -18253,7 +18392,12 @@ function resolveTypeFromImport(ctx, node, name, scope) {
|
|
|
18253
18392
|
return resolveTypeReference(ctx, node, sourceScope, imported, true);
|
|
18254
18393
|
}
|
|
18255
18394
|
function importSourceToScope(ctx, node, scope, source) {
|
|
18256
|
-
|
|
18395
|
+
let fs;
|
|
18396
|
+
try {
|
|
18397
|
+
fs = resolveFS(ctx);
|
|
18398
|
+
} catch (err) {
|
|
18399
|
+
return ctx.error(err.message, node, scope);
|
|
18400
|
+
}
|
|
18257
18401
|
if (!fs) {
|
|
18258
18402
|
return ctx.error(
|
|
18259
18403
|
`No fs option provided to \`compileScript\` in non-Node environment. File system access is required for resolving imported types.`,
|
|
@@ -18462,14 +18606,7 @@ function moduleDeclToScope(ctx, node, parentScope) {
|
|
|
18462
18606
|
if (node._resolvedChildScope) {
|
|
18463
18607
|
return node._resolvedChildScope;
|
|
18464
18608
|
}
|
|
18465
|
-
const scope =
|
|
18466
|
-
parentScope.filename,
|
|
18467
|
-
parentScope.source,
|
|
18468
|
-
parentScope.offset,
|
|
18469
|
-
Object.create(parentScope.imports),
|
|
18470
|
-
Object.create(parentScope.types),
|
|
18471
|
-
Object.create(parentScope.declares)
|
|
18472
|
-
);
|
|
18609
|
+
const scope = createChildScope(parentScope);
|
|
18473
18610
|
if (node.body.type === "TSModuleDeclaration") {
|
|
18474
18611
|
const decl = node.body;
|
|
18475
18612
|
decl._ownerScope = scope;
|
|
@@ -18480,6 +18617,16 @@ function moduleDeclToScope(ctx, node, parentScope) {
|
|
|
18480
18617
|
}
|
|
18481
18618
|
return node._resolvedChildScope = scope;
|
|
18482
18619
|
}
|
|
18620
|
+
function createChildScope(parentScope) {
|
|
18621
|
+
return new TypeScope(
|
|
18622
|
+
parentScope.filename,
|
|
18623
|
+
parentScope.source,
|
|
18624
|
+
parentScope.offset,
|
|
18625
|
+
Object.create(parentScope.imports),
|
|
18626
|
+
Object.create(parentScope.types),
|
|
18627
|
+
Object.create(parentScope.declares)
|
|
18628
|
+
);
|
|
18629
|
+
}
|
|
18483
18630
|
const importExportRE = /^Import|^Export/;
|
|
18484
18631
|
function recordTypes(ctx, body, scope, asGlobal = false) {
|
|
18485
18632
|
const { types, declares, exportedTypes, exportedDeclares, imports } = scope;
|
|
@@ -18601,7 +18748,7 @@ function recordType(node, types, declares, overwriteId) {
|
|
|
18601
18748
|
types[overwriteId || getId(node.id)] = node;
|
|
18602
18749
|
break;
|
|
18603
18750
|
case "TSTypeAliasDeclaration":
|
|
18604
|
-
types[node.id.name] = node.typeAnnotation;
|
|
18751
|
+
types[node.id.name] = node.typeParameters ? node : node.typeAnnotation;
|
|
18605
18752
|
break;
|
|
18606
18753
|
case "TSDeclareFunction":
|
|
18607
18754
|
if (node.id)
|
|
@@ -19141,7 +19288,7 @@ function genRuntimeProps(ctx) {
|
|
|
19141
19288
|
);
|
|
19142
19289
|
}
|
|
19143
19290
|
if (defaults.length) {
|
|
19144
|
-
propsDecls =
|
|
19291
|
+
propsDecls = `/*#__PURE__*/${ctx.helper(
|
|
19145
19292
|
`mergeDefaults`
|
|
19146
19293
|
)}(${propsDecls}, {
|
|
19147
19294
|
${defaults.join(",\n ")}
|
|
@@ -19153,7 +19300,9 @@ function genRuntimeProps(ctx) {
|
|
|
19153
19300
|
}
|
|
19154
19301
|
const modelsDecls = genModelProps(ctx);
|
|
19155
19302
|
if (propsDecls && modelsDecls) {
|
|
19156
|
-
return
|
|
19303
|
+
return `/*#__PURE__*/${ctx.helper(
|
|
19304
|
+
"mergeModels"
|
|
19305
|
+
)}(${propsDecls}, ${modelsDecls})`;
|
|
19157
19306
|
} else {
|
|
19158
19307
|
return modelsDecls || propsDecls;
|
|
19159
19308
|
}
|
|
@@ -19175,9 +19324,9 @@ function genRuntimePropsFromTypes(ctx) {
|
|
|
19175
19324
|
${propStrings.join(",\n ")}
|
|
19176
19325
|
}`;
|
|
19177
19326
|
if (ctx.propsRuntimeDefaults && !hasStaticDefaults) {
|
|
19178
|
-
propsDecls =
|
|
19179
|
-
|
|
19180
|
-
)})`;
|
|
19327
|
+
propsDecls = `/*#__PURE__*/${ctx.helper(
|
|
19328
|
+
"mergeDefaults"
|
|
19329
|
+
)}(${propsDecls}, ${ctx.getString(ctx.propsRuntimeDefaults)})`;
|
|
19181
19330
|
}
|
|
19182
19331
|
return propsDecls;
|
|
19183
19332
|
}
|
|
@@ -19242,6 +19391,15 @@ function genRuntimePropFromType(ctx, { key, required, type, skipCheck }, hasStat
|
|
|
19242
19391
|
defaultString
|
|
19243
19392
|
])} }`;
|
|
19244
19393
|
} else {
|
|
19394
|
+
if (ctx.isCE) {
|
|
19395
|
+
if (defaultString) {
|
|
19396
|
+
return `${finalKey}: ${`{ ${defaultString}, type: ${toRuntimeTypeString(
|
|
19397
|
+
type
|
|
19398
|
+
)} }`}`;
|
|
19399
|
+
} else {
|
|
19400
|
+
return `${finalKey}: {type: ${toRuntimeTypeString(type)}}`;
|
|
19401
|
+
}
|
|
19402
|
+
}
|
|
19245
19403
|
return `${finalKey}: ${defaultString ? `{ ${defaultString} }` : `{}`}`;
|
|
19246
19404
|
}
|
|
19247
19405
|
}
|
|
@@ -19514,7 +19672,9 @@ function genRuntimeEmits(ctx) {
|
|
|
19514
19672
|
}
|
|
19515
19673
|
if (ctx.hasDefineModelCall) {
|
|
19516
19674
|
let modelEmitsDecl = `[${Object.keys(ctx.modelDecls).map((n) => JSON.stringify(`update:${n}`)).join(", ")}]`;
|
|
19517
|
-
emitsDecl = emitsDecl ?
|
|
19675
|
+
emitsDecl = emitsDecl ? `/*#__PURE__*/${ctx.helper(
|
|
19676
|
+
"mergeModels"
|
|
19677
|
+
)}(${emitsDecl}, ${modelEmitsDecl})` : modelEmitsDecl;
|
|
19518
19678
|
}
|
|
19519
19679
|
return emitsDecl;
|
|
19520
19680
|
}
|
|
@@ -20484,7 +20644,7 @@ function isStaticNode(node) {
|
|
|
20484
20644
|
return false;
|
|
20485
20645
|
}
|
|
20486
20646
|
|
|
20487
|
-
const version = "3.3.
|
|
20647
|
+
const version = "3.3.11";
|
|
20488
20648
|
const parseCache = parseCache$1;
|
|
20489
20649
|
const walk = estreeWalker.walk;
|
|
20490
20650
|
|
package/dist/compiler-sfc.d.ts
CHANGED
|
@@ -144,6 +144,10 @@ export interface SFCScriptCompileOptions {
|
|
|
144
144
|
* using it, disable this and switch to the [Vue Macros implementation](https://vue-macros.sxzz.moe/features/reactivity-transform.html).
|
|
145
145
|
*/
|
|
146
146
|
reactivityTransform?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Transform Vue SFCs into custom elements.
|
|
149
|
+
*/
|
|
150
|
+
customElement?: boolean | ((filename: string) => boolean);
|
|
147
151
|
}
|
|
148
152
|
interface ImportBinding {
|
|
149
153
|
isType: boolean;
|
|
@@ -355,6 +359,7 @@ export declare class ScriptCompileContext {
|
|
|
355
359
|
options: Partial<SFCScriptCompileOptions>;
|
|
356
360
|
isJS: boolean;
|
|
357
361
|
isTS: boolean;
|
|
362
|
+
isCE: boolean;
|
|
358
363
|
scriptAst: Program | null;
|
|
359
364
|
scriptSetupAst: Program | null;
|
|
360
365
|
source: string;
|
|
@@ -455,7 +460,7 @@ interface ResolvedElements {
|
|
|
455
460
|
*/
|
|
456
461
|
export declare function resolveTypeElements(ctx: TypeResolveContext, node: Node & MaybeWithScope & {
|
|
457
462
|
_resolvedElements?: ResolvedElements;
|
|
458
|
-
}, scope?: TypeScope): ResolvedElements;
|
|
463
|
+
}, scope?: TypeScope, typeParameters?: Record<string, Node>): ResolvedElements;
|
|
459
464
|
/**
|
|
460
465
|
* @private
|
|
461
466
|
*/
|
|
@@ -11,8 +11,8 @@ const EMPTY_OBJ = Object.freeze({}) ;
|
|
|
11
11
|
const NOOP = () => {
|
|
12
12
|
};
|
|
13
13
|
const NO = () => false;
|
|
14
|
-
const
|
|
15
|
-
|
|
14
|
+
const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
|
|
15
|
+
(key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
|
|
16
16
|
const extend = Object.assign;
|
|
17
17
|
const hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
18
18
|
const hasOwn = (val, key) => hasOwnProperty$3.call(val, key);
|
|
@@ -275,20 +275,29 @@ const replacer = (_key, val) => {
|
|
|
275
275
|
return replacer(_key, val.value);
|
|
276
276
|
} else if (isMap(val)) {
|
|
277
277
|
return {
|
|
278
|
-
[`Map(${val.size})`]: [...val.entries()].reduce(
|
|
279
|
-
entries[
|
|
280
|
-
|
|
281
|
-
|
|
278
|
+
[`Map(${val.size})`]: [...val.entries()].reduce(
|
|
279
|
+
(entries, [key, val2], i) => {
|
|
280
|
+
entries[stringifySymbol(key, i) + " =>"] = val2;
|
|
281
|
+
return entries;
|
|
282
|
+
},
|
|
283
|
+
{}
|
|
284
|
+
)
|
|
282
285
|
};
|
|
283
286
|
} else if (isSet(val)) {
|
|
284
287
|
return {
|
|
285
|
-
[`Set(${val.size})`]: [...val.values()]
|
|
288
|
+
[`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
|
|
286
289
|
};
|
|
290
|
+
} else if (isSymbol$1(val)) {
|
|
291
|
+
return stringifySymbol(val);
|
|
287
292
|
} else if (isObject$2(val) && !isArray$3(val) && !isPlainObject(val)) {
|
|
288
293
|
return String(val);
|
|
289
294
|
}
|
|
290
295
|
return val;
|
|
291
296
|
};
|
|
297
|
+
const stringifySymbol = (v, i = "") => {
|
|
298
|
+
var _a;
|
|
299
|
+
return isSymbol$1(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v;
|
|
300
|
+
};
|
|
292
301
|
|
|
293
302
|
function defaultOnError(error) {
|
|
294
303
|
throw error;
|
|
@@ -22483,6 +22492,10 @@ function resolveSetupReference(name, context) {
|
|
|
22483
22492
|
`${context.helperString(UNREF)}(${fromMaybeRef})`
|
|
22484
22493
|
) : `$setup[${JSON.stringify(fromMaybeRef)}]`;
|
|
22485
22494
|
}
|
|
22495
|
+
const fromProps = checkType("props");
|
|
22496
|
+
if (fromProps) {
|
|
22497
|
+
return `${context.helperString(UNREF)}(${context.inline ? "__props" : "$props"}[${JSON.stringify(fromProps)}])`;
|
|
22498
|
+
}
|
|
22486
22499
|
}
|
|
22487
22500
|
function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
|
|
22488
22501
|
const { tag, loc: elementLoc, children } = node;
|
|
@@ -22523,6 +22536,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
22523
22536
|
if (isEventHandler && isReservedProp(name)) {
|
|
22524
22537
|
hasVnodeHook = true;
|
|
22525
22538
|
}
|
|
22539
|
+
if (isEventHandler && value.type === 14) {
|
|
22540
|
+
value = value.arguments[0];
|
|
22541
|
+
}
|
|
22526
22542
|
if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
|
|
22527
22543
|
return;
|
|
22528
22544
|
}
|
|
@@ -26842,8 +26858,11 @@ function getEscapedPropName(key) {
|
|
|
26842
26858
|
return propNameEscapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
|
|
26843
26859
|
}
|
|
26844
26860
|
const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
|
|
26845
|
-
function getEscapedCssVarName(key) {
|
|
26846
|
-
return key.replace(
|
|
26861
|
+
function getEscapedCssVarName(key, doubleEscape) {
|
|
26862
|
+
return key.replace(
|
|
26863
|
+
cssVarNameEscapeSymbolsRE,
|
|
26864
|
+
(s) => doubleEscape ? `\\\\${s}` : `\\${s}`
|
|
26865
|
+
);
|
|
26847
26866
|
}
|
|
26848
26867
|
|
|
26849
26868
|
function pad$1 (hash, len) {
|
|
@@ -26920,15 +26939,15 @@ const CSS_VARS_HELPER = `useCssVars`;
|
|
|
26920
26939
|
function genCssVarsFromList(vars, id, isProd, isSSR = false) {
|
|
26921
26940
|
return `{
|
|
26922
26941
|
${vars.map(
|
|
26923
|
-
(key) => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd)}": (${key})`
|
|
26942
|
+
(key) => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd, isSSR)}": (${key})`
|
|
26924
26943
|
).join(",\n ")}
|
|
26925
26944
|
}`;
|
|
26926
26945
|
}
|
|
26927
|
-
function genVarName(id, raw, isProd) {
|
|
26946
|
+
function genVarName(id, raw, isProd, isSSR = false) {
|
|
26928
26947
|
if (isProd) {
|
|
26929
26948
|
return hash(id + raw);
|
|
26930
26949
|
} else {
|
|
26931
|
-
return `${id}-${getEscapedCssVarName(raw)}`;
|
|
26950
|
+
return `${id}-${getEscapedCssVarName(raw, isSSR)}`;
|
|
26932
26951
|
}
|
|
26933
26952
|
}
|
|
26934
26953
|
function normalizeExpression(exp) {
|
|
@@ -27516,22 +27535,29 @@ function parse$7(source, {
|
|
|
27516
27535
|
descriptor.script = null;
|
|
27517
27536
|
}
|
|
27518
27537
|
}
|
|
27538
|
+
let templateColumnOffset = 0;
|
|
27539
|
+
if (descriptor.template && (descriptor.template.lang === "pug" || descriptor.template.lang === "jade")) {
|
|
27540
|
+
[descriptor.template.content, templateColumnOffset] = dedent(
|
|
27541
|
+
descriptor.template.content
|
|
27542
|
+
);
|
|
27543
|
+
}
|
|
27519
27544
|
if (sourceMap) {
|
|
27520
|
-
const genMap = (block) => {
|
|
27545
|
+
const genMap = (block, columnOffset = 0) => {
|
|
27521
27546
|
if (block && !block.src) {
|
|
27522
27547
|
block.map = generateSourceMap(
|
|
27523
27548
|
filename,
|
|
27524
27549
|
source,
|
|
27525
27550
|
block.content,
|
|
27526
27551
|
sourceRoot,
|
|
27527
|
-
!pad || block.type === "template" ? block.loc.start.line - 1 : 0
|
|
27552
|
+
!pad || block.type === "template" ? block.loc.start.line - 1 : 0,
|
|
27553
|
+
columnOffset
|
|
27528
27554
|
);
|
|
27529
27555
|
}
|
|
27530
27556
|
};
|
|
27531
|
-
genMap(descriptor.template);
|
|
27557
|
+
genMap(descriptor.template, templateColumnOffset);
|
|
27532
27558
|
genMap(descriptor.script);
|
|
27533
|
-
descriptor.styles.forEach(genMap);
|
|
27534
|
-
descriptor.customBlocks.forEach(genMap);
|
|
27559
|
+
descriptor.styles.forEach((s) => genMap(s));
|
|
27560
|
+
descriptor.customBlocks.forEach((s) => genMap(s));
|
|
27535
27561
|
}
|
|
27536
27562
|
descriptor.cssVars = parseCssVars(descriptor);
|
|
27537
27563
|
const slottedRE = /(?:::v-|:)slotted\(/;
|
|
@@ -27609,7 +27635,7 @@ function createBlock(node, source, pad) {
|
|
|
27609
27635
|
const splitRE = /\r?\n/g;
|
|
27610
27636
|
const emptyRE = /^(?:\/\/)?\s*$/;
|
|
27611
27637
|
const replaceRE = /./g;
|
|
27612
|
-
function generateSourceMap(filename, source, generated, sourceRoot, lineOffset) {
|
|
27638
|
+
function generateSourceMap(filename, source, generated, sourceRoot, lineOffset, columnOffset) {
|
|
27613
27639
|
const map = new SourceMapGenerator$6({
|
|
27614
27640
|
file: filename.replace(/\\/g, "/"),
|
|
27615
27641
|
sourceRoot: sourceRoot.replace(/\\/g, "/")
|
|
@@ -27625,7 +27651,7 @@ function generateSourceMap(filename, source, generated, sourceRoot, lineOffset)
|
|
|
27625
27651
|
source: filename,
|
|
27626
27652
|
original: {
|
|
27627
27653
|
line: originalLine,
|
|
27628
|
-
column: i
|
|
27654
|
+
column: i + columnOffset
|
|
27629
27655
|
},
|
|
27630
27656
|
generated: {
|
|
27631
27657
|
line: generatedLine,
|
|
@@ -27676,6 +27702,26 @@ function hmrShouldReload(prevImports, next) {
|
|
|
27676
27702
|
}
|
|
27677
27703
|
return false;
|
|
27678
27704
|
}
|
|
27705
|
+
function dedent(s) {
|
|
27706
|
+
const lines = s.split("\n");
|
|
27707
|
+
const minIndent = lines.reduce(function(minIndent2, line) {
|
|
27708
|
+
var _a, _b;
|
|
27709
|
+
if (line.trim() === "") {
|
|
27710
|
+
return minIndent2;
|
|
27711
|
+
}
|
|
27712
|
+
const indent = ((_b = (_a = line.match(/^\s*/)) == null ? void 0 : _a[0]) == null ? void 0 : _b.length) || 0;
|
|
27713
|
+
return Math.min(indent, minIndent2);
|
|
27714
|
+
}, Infinity);
|
|
27715
|
+
if (minIndent === 0) {
|
|
27716
|
+
return [s, minIndent];
|
|
27717
|
+
}
|
|
27718
|
+
return [
|
|
27719
|
+
lines.map(function(line) {
|
|
27720
|
+
return line.slice(minIndent);
|
|
27721
|
+
}).join("\n"),
|
|
27722
|
+
minIndent
|
|
27723
|
+
];
|
|
27724
|
+
}
|
|
27679
27725
|
|
|
27680
27726
|
/*! https://mths.be/punycode v1.4.1 by @mathias */
|
|
27681
27727
|
|
|
@@ -37602,7 +37648,7 @@ let Root$2 = root$2;
|
|
|
37602
37648
|
|
|
37603
37649
|
let Processor$1 = class Processor {
|
|
37604
37650
|
constructor(plugins = []) {
|
|
37605
|
-
this.version = '8.4.
|
|
37651
|
+
this.version = '8.4.32';
|
|
37606
37652
|
this.plugins = this.normalize(plugins);
|
|
37607
37653
|
}
|
|
37608
37654
|
|
|
@@ -41394,14 +41440,19 @@ function rewriteSelector(id, selector, selectorRoot, slotted = false) {
|
|
|
41394
41440
|
return false;
|
|
41395
41441
|
}
|
|
41396
41442
|
}
|
|
41397
|
-
if (n.type !== "pseudo" && n.type !== "combinator") {
|
|
41443
|
+
if (n.type !== "pseudo" && n.type !== "combinator" || n.type === "pseudo" && (n.value === ":is" || n.value === ":where")) {
|
|
41398
41444
|
node = n;
|
|
41399
41445
|
}
|
|
41400
|
-
|
|
41401
|
-
|
|
41446
|
+
});
|
|
41447
|
+
if (node) {
|
|
41448
|
+
const { type, value } = node;
|
|
41449
|
+
if (type === "pseudo" && (value === ":is" || value === ":where")) {
|
|
41450
|
+
node.nodes.forEach(
|
|
41451
|
+
(value2) => rewriteSelector(id, value2, selectorRoot, slotted)
|
|
41452
|
+
);
|
|
41402
41453
|
shouldInject = false;
|
|
41403
41454
|
}
|
|
41404
|
-
}
|
|
41455
|
+
}
|
|
41405
41456
|
if (node) {
|
|
41406
41457
|
node.spaces.after = "";
|
|
41407
41458
|
} else {
|
|
@@ -47006,6 +47057,7 @@ class ScriptCompileContext {
|
|
|
47006
47057
|
constructor(descriptor, options) {
|
|
47007
47058
|
this.descriptor = descriptor;
|
|
47008
47059
|
this.options = options;
|
|
47060
|
+
this.isCE = false;
|
|
47009
47061
|
this.source = this.descriptor.source;
|
|
47010
47062
|
this.filename = this.descriptor.filename;
|
|
47011
47063
|
this.s = new MagicString(this.source);
|
|
@@ -47032,6 +47084,11 @@ class ScriptCompileContext {
|
|
|
47032
47084
|
const scriptSetupLang = scriptSetup && scriptSetup.lang;
|
|
47033
47085
|
this.isJS = scriptLang === "js" || scriptLang === "jsx" || scriptSetupLang === "js" || scriptSetupLang === "jsx";
|
|
47034
47086
|
this.isTS = scriptLang === "ts" || scriptLang === "tsx" || scriptSetupLang === "ts" || scriptSetupLang === "tsx";
|
|
47087
|
+
const customElement = options.customElement;
|
|
47088
|
+
const filename = this.descriptor.filename;
|
|
47089
|
+
if (customElement) {
|
|
47090
|
+
this.isCE = typeof customElement === "boolean" ? customElement : customElement(filename);
|
|
47091
|
+
}
|
|
47035
47092
|
const plugins = resolveParserPlugins(
|
|
47036
47093
|
scriptLang || scriptSetupLang,
|
|
47037
47094
|
options.babelParserPlugins
|
|
@@ -47130,33 +47187,39 @@ class TypeScope {
|
|
|
47130
47187
|
this.exportedDeclares = /* @__PURE__ */ Object.create(null);
|
|
47131
47188
|
}
|
|
47132
47189
|
}
|
|
47133
|
-
function resolveTypeElements(ctx, node, scope) {
|
|
47190
|
+
function resolveTypeElements(ctx, node, scope, typeParameters) {
|
|
47134
47191
|
if (node._resolvedElements) {
|
|
47135
47192
|
return node._resolvedElements;
|
|
47136
47193
|
}
|
|
47137
47194
|
return node._resolvedElements = innerResolveTypeElements(
|
|
47138
47195
|
ctx,
|
|
47139
47196
|
node,
|
|
47140
|
-
node._ownerScope || scope || ctxToScope(ctx)
|
|
47197
|
+
node._ownerScope || scope || ctxToScope(ctx),
|
|
47198
|
+
typeParameters
|
|
47141
47199
|
);
|
|
47142
47200
|
}
|
|
47143
|
-
function innerResolveTypeElements(ctx, node, scope) {
|
|
47201
|
+
function innerResolveTypeElements(ctx, node, scope, typeParameters) {
|
|
47144
47202
|
var _a, _b;
|
|
47145
47203
|
switch (node.type) {
|
|
47146
47204
|
case "TSTypeLiteral":
|
|
47147
|
-
return typeElementsToMap(ctx, node.members, scope);
|
|
47205
|
+
return typeElementsToMap(ctx, node.members, scope, typeParameters);
|
|
47148
47206
|
case "TSInterfaceDeclaration":
|
|
47149
|
-
return resolveInterfaceMembers(ctx, node, scope);
|
|
47207
|
+
return resolveInterfaceMembers(ctx, node, scope, typeParameters);
|
|
47150
47208
|
case "TSTypeAliasDeclaration":
|
|
47151
47209
|
case "TSParenthesizedType":
|
|
47152
|
-
return resolveTypeElements(
|
|
47210
|
+
return resolveTypeElements(
|
|
47211
|
+
ctx,
|
|
47212
|
+
node.typeAnnotation,
|
|
47213
|
+
scope,
|
|
47214
|
+
typeParameters
|
|
47215
|
+
);
|
|
47153
47216
|
case "TSFunctionType": {
|
|
47154
47217
|
return { props: {}, calls: [node] };
|
|
47155
47218
|
}
|
|
47156
47219
|
case "TSUnionType":
|
|
47157
47220
|
case "TSIntersectionType":
|
|
47158
47221
|
return mergeElements(
|
|
47159
|
-
node.types.map((t) => resolveTypeElements(ctx, t, scope)),
|
|
47222
|
+
node.types.map((t) => resolveTypeElements(ctx, t, scope, typeParameters)),
|
|
47160
47223
|
node.type
|
|
47161
47224
|
);
|
|
47162
47225
|
case "TSMappedType":
|
|
@@ -47173,20 +47236,53 @@ function innerResolveTypeElements(ctx, node, scope) {
|
|
|
47173
47236
|
const typeName = getReferenceName(node);
|
|
47174
47237
|
if ((typeName === "ExtractPropTypes" || typeName === "ExtractPublicPropTypes") && node.typeParameters && ((_a = scope.imports[typeName]) == null ? void 0 : _a.source) === "vue") {
|
|
47175
47238
|
return resolveExtractPropTypes(
|
|
47176
|
-
resolveTypeElements(
|
|
47239
|
+
resolveTypeElements(
|
|
47240
|
+
ctx,
|
|
47241
|
+
node.typeParameters.params[0],
|
|
47242
|
+
scope,
|
|
47243
|
+
typeParameters
|
|
47244
|
+
),
|
|
47177
47245
|
scope
|
|
47178
47246
|
);
|
|
47179
47247
|
}
|
|
47180
47248
|
const resolved = resolveTypeReference(ctx, node, scope);
|
|
47181
47249
|
if (resolved) {
|
|
47182
|
-
|
|
47250
|
+
const typeParams = /* @__PURE__ */ Object.create(null);
|
|
47251
|
+
if ((resolved.type === "TSTypeAliasDeclaration" || resolved.type === "TSInterfaceDeclaration") && resolved.typeParameters && node.typeParameters) {
|
|
47252
|
+
resolved.typeParameters.params.forEach((p, i) => {
|
|
47253
|
+
let param = typeParameters && typeParameters[p.name];
|
|
47254
|
+
if (!param)
|
|
47255
|
+
param = node.typeParameters.params[i];
|
|
47256
|
+
typeParams[p.name] = param;
|
|
47257
|
+
});
|
|
47258
|
+
}
|
|
47259
|
+
return resolveTypeElements(
|
|
47260
|
+
ctx,
|
|
47261
|
+
resolved,
|
|
47262
|
+
resolved._ownerScope,
|
|
47263
|
+
typeParams
|
|
47264
|
+
);
|
|
47183
47265
|
} else {
|
|
47184
47266
|
if (typeof typeName === "string") {
|
|
47267
|
+
if (typeParameters && typeParameters[typeName]) {
|
|
47268
|
+
return resolveTypeElements(
|
|
47269
|
+
ctx,
|
|
47270
|
+
typeParameters[typeName],
|
|
47271
|
+
scope,
|
|
47272
|
+
typeParameters
|
|
47273
|
+
);
|
|
47274
|
+
}
|
|
47185
47275
|
if (
|
|
47186
47276
|
// @ts-ignore
|
|
47187
47277
|
SupportedBuiltinsSet.has(typeName)
|
|
47188
47278
|
) {
|
|
47189
|
-
return resolveBuiltin(
|
|
47279
|
+
return resolveBuiltin(
|
|
47280
|
+
ctx,
|
|
47281
|
+
node,
|
|
47282
|
+
typeName,
|
|
47283
|
+
scope,
|
|
47284
|
+
typeParameters
|
|
47285
|
+
);
|
|
47190
47286
|
} else if (typeName === "ReturnType" && node.typeParameters) {
|
|
47191
47287
|
const ret = resolveReturnType(
|
|
47192
47288
|
ctx,
|
|
@@ -47235,10 +47331,14 @@ function innerResolveTypeElements(ctx, node, scope) {
|
|
|
47235
47331
|
}
|
|
47236
47332
|
return ctx.error(`Unresolvable type: ${node.type}`, node, scope);
|
|
47237
47333
|
}
|
|
47238
|
-
function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx)) {
|
|
47334
|
+
function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx), typeParameters) {
|
|
47239
47335
|
const res = { props: {} };
|
|
47240
47336
|
for (const e of elements) {
|
|
47241
47337
|
if (e.type === "TSPropertySignature" || e.type === "TSMethodSignature") {
|
|
47338
|
+
if (typeParameters) {
|
|
47339
|
+
scope = createChildScope(scope);
|
|
47340
|
+
Object.assign(scope.types, typeParameters);
|
|
47341
|
+
}
|
|
47242
47342
|
e._ownerScope = scope;
|
|
47243
47343
|
const name = getId(e.key);
|
|
47244
47344
|
if (name && !e.computed) {
|
|
@@ -47301,8 +47401,13 @@ function createProperty(key, typeAnnotation, scope, optional) {
|
|
|
47301
47401
|
_ownerScope: scope
|
|
47302
47402
|
};
|
|
47303
47403
|
}
|
|
47304
|
-
function resolveInterfaceMembers(ctx, node, scope) {
|
|
47305
|
-
const base = typeElementsToMap(
|
|
47404
|
+
function resolveInterfaceMembers(ctx, node, scope, typeParameters) {
|
|
47405
|
+
const base = typeElementsToMap(
|
|
47406
|
+
ctx,
|
|
47407
|
+
node.body.body,
|
|
47408
|
+
node._ownerScope,
|
|
47409
|
+
typeParameters
|
|
47410
|
+
);
|
|
47306
47411
|
if (node.extends) {
|
|
47307
47412
|
for (const ext of node.extends) {
|
|
47308
47413
|
if (ext.leadingComments && ext.leadingComments.some((c) => c.value.includes("@vue-ignore"))) {
|
|
@@ -47476,8 +47581,13 @@ const SupportedBuiltinsSet = /* @__PURE__ */ new Set([
|
|
|
47476
47581
|
"Pick",
|
|
47477
47582
|
"Omit"
|
|
47478
47583
|
]);
|
|
47479
|
-
function resolveBuiltin(ctx, node, name, scope) {
|
|
47480
|
-
const t = resolveTypeElements(
|
|
47584
|
+
function resolveBuiltin(ctx, node, name, scope, typeParameters) {
|
|
47585
|
+
const t = resolveTypeElements(
|
|
47586
|
+
ctx,
|
|
47587
|
+
node.typeParameters.params[0],
|
|
47588
|
+
scope,
|
|
47589
|
+
typeParameters
|
|
47590
|
+
);
|
|
47481
47591
|
switch (name) {
|
|
47482
47592
|
case "Partial": {
|
|
47483
47593
|
const res2 = { props: {}, calls: t.calls };
|
|
@@ -47605,7 +47715,21 @@ function resolveGlobalScope(ctx) {
|
|
|
47605
47715
|
let ts;
|
|
47606
47716
|
let loadTS;
|
|
47607
47717
|
function registerTS(_loadTS) {
|
|
47608
|
-
loadTS =
|
|
47718
|
+
loadTS = () => {
|
|
47719
|
+
try {
|
|
47720
|
+
return _loadTS();
|
|
47721
|
+
} catch (err) {
|
|
47722
|
+
if (typeof err.message === "string" && err.message.includes("Cannot find module")) {
|
|
47723
|
+
throw new Error(
|
|
47724
|
+
'Failed to load TypeScript, which is required for resolving imported types. Please make sure "typescript" is installed as a project dependency.'
|
|
47725
|
+
);
|
|
47726
|
+
} else {
|
|
47727
|
+
throw new Error(
|
|
47728
|
+
"Failed to load TypeScript for resolving imported types."
|
|
47729
|
+
);
|
|
47730
|
+
}
|
|
47731
|
+
}
|
|
47732
|
+
};
|
|
47609
47733
|
}
|
|
47610
47734
|
function resolveFS(ctx) {
|
|
47611
47735
|
if (ctx.fs) {
|
|
@@ -47639,7 +47763,12 @@ function resolveTypeFromImport(ctx, node, name, scope) {
|
|
|
47639
47763
|
return resolveTypeReference(ctx, node, sourceScope, imported, true);
|
|
47640
47764
|
}
|
|
47641
47765
|
function importSourceToScope(ctx, node, scope, source) {
|
|
47642
|
-
|
|
47766
|
+
let fs;
|
|
47767
|
+
try {
|
|
47768
|
+
fs = resolveFS(ctx);
|
|
47769
|
+
} catch (err) {
|
|
47770
|
+
return ctx.error(err.message, node, scope);
|
|
47771
|
+
}
|
|
47643
47772
|
if (!fs) {
|
|
47644
47773
|
return ctx.error(
|
|
47645
47774
|
`No fs option provided to \`compileScript\` in non-Node environment. File system access is required for resolving imported types.`,
|
|
@@ -47764,14 +47893,7 @@ function moduleDeclToScope(ctx, node, parentScope) {
|
|
|
47764
47893
|
if (node._resolvedChildScope) {
|
|
47765
47894
|
return node._resolvedChildScope;
|
|
47766
47895
|
}
|
|
47767
|
-
const scope =
|
|
47768
|
-
parentScope.filename,
|
|
47769
|
-
parentScope.source,
|
|
47770
|
-
parentScope.offset,
|
|
47771
|
-
Object.create(parentScope.imports),
|
|
47772
|
-
Object.create(parentScope.types),
|
|
47773
|
-
Object.create(parentScope.declares)
|
|
47774
|
-
);
|
|
47896
|
+
const scope = createChildScope(parentScope);
|
|
47775
47897
|
if (node.body.type === "TSModuleDeclaration") {
|
|
47776
47898
|
const decl = node.body;
|
|
47777
47899
|
decl._ownerScope = scope;
|
|
@@ -47782,6 +47904,16 @@ function moduleDeclToScope(ctx, node, parentScope) {
|
|
|
47782
47904
|
}
|
|
47783
47905
|
return node._resolvedChildScope = scope;
|
|
47784
47906
|
}
|
|
47907
|
+
function createChildScope(parentScope) {
|
|
47908
|
+
return new TypeScope(
|
|
47909
|
+
parentScope.filename,
|
|
47910
|
+
parentScope.source,
|
|
47911
|
+
parentScope.offset,
|
|
47912
|
+
Object.create(parentScope.imports),
|
|
47913
|
+
Object.create(parentScope.types),
|
|
47914
|
+
Object.create(parentScope.declares)
|
|
47915
|
+
);
|
|
47916
|
+
}
|
|
47785
47917
|
const importExportRE = /^Import|^Export/;
|
|
47786
47918
|
function recordTypes(ctx, body, scope, asGlobal = false) {
|
|
47787
47919
|
const { types, declares, exportedTypes, exportedDeclares, imports } = scope;
|
|
@@ -47903,7 +48035,7 @@ function recordType(node, types, declares, overwriteId) {
|
|
|
47903
48035
|
types[overwriteId || getId(node.id)] = node;
|
|
47904
48036
|
break;
|
|
47905
48037
|
case "TSTypeAliasDeclaration":
|
|
47906
|
-
types[node.id.name] = node.typeAnnotation;
|
|
48038
|
+
types[node.id.name] = node.typeParameters ? node : node.typeAnnotation;
|
|
47907
48039
|
break;
|
|
47908
48040
|
case "TSDeclareFunction":
|
|
47909
48041
|
if (node.id)
|
|
@@ -48443,7 +48575,7 @@ function genRuntimeProps(ctx) {
|
|
|
48443
48575
|
);
|
|
48444
48576
|
}
|
|
48445
48577
|
if (defaults.length) {
|
|
48446
|
-
propsDecls =
|
|
48578
|
+
propsDecls = `/*#__PURE__*/${ctx.helper(
|
|
48447
48579
|
`mergeDefaults`
|
|
48448
48580
|
)}(${propsDecls}, {
|
|
48449
48581
|
${defaults.join(",\n ")}
|
|
@@ -48455,7 +48587,9 @@ function genRuntimeProps(ctx) {
|
|
|
48455
48587
|
}
|
|
48456
48588
|
const modelsDecls = genModelProps(ctx);
|
|
48457
48589
|
if (propsDecls && modelsDecls) {
|
|
48458
|
-
return
|
|
48590
|
+
return `/*#__PURE__*/${ctx.helper(
|
|
48591
|
+
"mergeModels"
|
|
48592
|
+
)}(${propsDecls}, ${modelsDecls})`;
|
|
48459
48593
|
} else {
|
|
48460
48594
|
return modelsDecls || propsDecls;
|
|
48461
48595
|
}
|
|
@@ -48477,9 +48611,9 @@ function genRuntimePropsFromTypes(ctx) {
|
|
|
48477
48611
|
${propStrings.join(",\n ")}
|
|
48478
48612
|
}`;
|
|
48479
48613
|
if (ctx.propsRuntimeDefaults && !hasStaticDefaults) {
|
|
48480
|
-
propsDecls =
|
|
48481
|
-
|
|
48482
|
-
)})`;
|
|
48614
|
+
propsDecls = `/*#__PURE__*/${ctx.helper(
|
|
48615
|
+
"mergeDefaults"
|
|
48616
|
+
)}(${propsDecls}, ${ctx.getString(ctx.propsRuntimeDefaults)})`;
|
|
48483
48617
|
}
|
|
48484
48618
|
return propsDecls;
|
|
48485
48619
|
}
|
|
@@ -48544,6 +48678,15 @@ function genRuntimePropFromType(ctx, { key, required, type, skipCheck }, hasStat
|
|
|
48544
48678
|
defaultString
|
|
48545
48679
|
])} }`;
|
|
48546
48680
|
} else {
|
|
48681
|
+
if (ctx.isCE) {
|
|
48682
|
+
if (defaultString) {
|
|
48683
|
+
return `${finalKey}: ${`{ ${defaultString}, type: ${toRuntimeTypeString(
|
|
48684
|
+
type
|
|
48685
|
+
)} }`}`;
|
|
48686
|
+
} else {
|
|
48687
|
+
return `${finalKey}: {type: ${toRuntimeTypeString(type)}}`;
|
|
48688
|
+
}
|
|
48689
|
+
}
|
|
48547
48690
|
return `${finalKey}: ${defaultString ? `{ ${defaultString} }` : `{}`}`;
|
|
48548
48691
|
}
|
|
48549
48692
|
}
|
|
@@ -48816,7 +48959,9 @@ function genRuntimeEmits(ctx) {
|
|
|
48816
48959
|
}
|
|
48817
48960
|
if (ctx.hasDefineModelCall) {
|
|
48818
48961
|
let modelEmitsDecl = `[${Object.keys(ctx.modelDecls).map((n) => JSON.stringify(`update:${n}`)).join(", ")}]`;
|
|
48819
|
-
emitsDecl = emitsDecl ?
|
|
48962
|
+
emitsDecl = emitsDecl ? `/*#__PURE__*/${ctx.helper(
|
|
48963
|
+
"mergeModels"
|
|
48964
|
+
)}(${emitsDecl}, ${modelEmitsDecl})` : modelEmitsDecl;
|
|
48820
48965
|
}
|
|
48821
48966
|
return emitsDecl;
|
|
48822
48967
|
}
|
|
@@ -49800,7 +49945,7 @@ function isStaticNode(node) {
|
|
|
49800
49945
|
return false;
|
|
49801
49946
|
}
|
|
49802
49947
|
|
|
49803
|
-
const version = "3.3.
|
|
49948
|
+
const version = "3.3.11";
|
|
49804
49949
|
const parseCache = parseCache$1;
|
|
49805
49950
|
const walk = walk$1;
|
|
49806
49951
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/compiler-sfc",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.11",
|
|
4
4
|
"description": "@vue/compiler-sfc",
|
|
5
5
|
"main": "dist/compiler-sfc.cjs.js",
|
|
6
6
|
"module": "dist/compiler-sfc.esm-browser.js",
|
|
@@ -32,22 +32,22 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-sfc#readme",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@babel/parser": "^7.23.
|
|
35
|
+
"@babel/parser": "^7.23.5",
|
|
36
36
|
"estree-walker": "^2.0.2",
|
|
37
37
|
"magic-string": "^0.30.5",
|
|
38
|
-
"postcss": "^8.4.
|
|
38
|
+
"postcss": "^8.4.32",
|
|
39
39
|
"source-map-js": "^1.0.2",
|
|
40
|
-
"@vue/compiler-
|
|
41
|
-
"@vue/compiler-
|
|
42
|
-
"@vue/
|
|
43
|
-
"@vue/
|
|
44
|
-
"@vue/
|
|
40
|
+
"@vue/compiler-dom": "3.3.11",
|
|
41
|
+
"@vue/compiler-ssr": "3.3.11",
|
|
42
|
+
"@vue/shared": "3.3.11",
|
|
43
|
+
"@vue/compiler-core": "3.3.11",
|
|
44
|
+
"@vue/reactivity-transform": "3.3.11"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@babel/types": "^7.23.
|
|
47
|
+
"@babel/types": "^7.23.5",
|
|
48
48
|
"@vue/consolidate": "^0.17.3",
|
|
49
49
|
"hash-sum": "^2.0.0",
|
|
50
|
-
"lru-cache": "^10.0
|
|
50
|
+
"lru-cache": "^10.1.0",
|
|
51
51
|
"merge-source-map": "^1.1.0",
|
|
52
52
|
"minimatch": "^9.0.3",
|
|
53
53
|
"postcss-modules": "^4.3.1",
|