@vue/compiler-sfc 3.4.0-alpha.1 → 3.4.0-alpha.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/README.md +2 -2
- package/dist/compiler-sfc.cjs.js +177 -188
- package/dist/compiler-sfc.d.ts +13 -14
- package/dist/compiler-sfc.esm-browser.js +2649 -4293
- package/package.json +10 -11
package/dist/compiler-sfc.cjs.js
CHANGED
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var compilerCore = require('@vue/compiler-core');
|
|
5
6
|
var CompilerDOM = require('@vue/compiler-dom');
|
|
6
7
|
var sourceMapJs = require('source-map-js');
|
|
7
8
|
var path$3 = require('path');
|
|
8
9
|
var parser$2 = require('@babel/parser');
|
|
9
10
|
var shared = require('@vue/shared');
|
|
10
|
-
var compilerCore = require('@vue/compiler-core');
|
|
11
11
|
var url = require('url');
|
|
12
12
|
var CompilerSSR = require('@vue/compiler-ssr');
|
|
13
13
|
var require$$2 = require('util');
|
|
14
14
|
var require$$0 = require('fs');
|
|
15
15
|
var require$$0$1 = require('postcss');
|
|
16
16
|
var estreeWalker = require('estree-walker');
|
|
17
|
-
var reactivityTransform = require('@vue/reactivity-transform');
|
|
18
17
|
var MagicString = require('magic-string');
|
|
18
|
+
var process$1 = require('process');
|
|
19
19
|
|
|
20
20
|
function _interopNamespaceDefault(e) {
|
|
21
21
|
var n = Object.create(null);
|
|
@@ -30,6 +30,7 @@ function _interopNamespaceDefault(e) {
|
|
|
30
30
|
|
|
31
31
|
var CompilerDOM__namespace = /*#__PURE__*/_interopNamespaceDefault(CompilerDOM);
|
|
32
32
|
var CompilerSSR__namespace = /*#__PURE__*/_interopNamespaceDefault(CompilerSSR);
|
|
33
|
+
var process__namespace = /*#__PURE__*/_interopNamespaceDefault(process$1);
|
|
33
34
|
|
|
34
35
|
const UNKNOWN_TYPE = "Unknown";
|
|
35
36
|
function resolveObjectKey(node, computed) {
|
|
@@ -87,9 +88,13 @@ function normalizePath(p) {
|
|
|
87
88
|
return normalize(p.replace(windowsSlashRE, "/"));
|
|
88
89
|
}
|
|
89
90
|
const joinPaths = (path$3.posix || path$3).join;
|
|
90
|
-
const
|
|
91
|
-
function
|
|
92
|
-
return
|
|
91
|
+
const propNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~\-]/;
|
|
92
|
+
function getEscapedPropName(key) {
|
|
93
|
+
return propNameEscapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
|
|
94
|
+
}
|
|
95
|
+
const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
|
|
96
|
+
function getEscapedCssVarName(key) {
|
|
97
|
+
return key.replace(cssVarNameEscapeSymbolsRE, (s) => `\\${s}`);
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -180,7 +185,7 @@ function genVarName(id, raw, isProd) {
|
|
|
180
185
|
if (isProd) {
|
|
181
186
|
return hash$1(id + raw);
|
|
182
187
|
} else {
|
|
183
|
-
return `${id}-${raw
|
|
188
|
+
return `${id}-${getEscapedCssVarName(raw)}`;
|
|
184
189
|
}
|
|
185
190
|
}
|
|
186
191
|
function normalizeExpression(exp) {
|
|
@@ -734,6 +739,9 @@ class LRUCache {
|
|
|
734
739
|
if (ttls[index]) {
|
|
735
740
|
const ttl = ttls[index];
|
|
736
741
|
const start = starts[index];
|
|
742
|
+
/* c8 ignore next */
|
|
743
|
+
if (!ttl || !start)
|
|
744
|
+
return;
|
|
737
745
|
status.ttl = ttl;
|
|
738
746
|
status.start = start;
|
|
739
747
|
status.now = cachedNow || getNow();
|
|
@@ -765,16 +773,16 @@ class LRUCache {
|
|
|
765
773
|
}
|
|
766
774
|
const ttl = ttls[index];
|
|
767
775
|
const start = starts[index];
|
|
768
|
-
if (ttl
|
|
776
|
+
if (!ttl || !start) {
|
|
769
777
|
return Infinity;
|
|
770
778
|
}
|
|
771
779
|
const age = (cachedNow || getNow()) - start;
|
|
772
780
|
return ttl - age;
|
|
773
781
|
};
|
|
774
782
|
this.#isStale = index => {
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
783
|
+
const s = starts[index];
|
|
784
|
+
const t = ttls[index];
|
|
785
|
+
return !!t && !!s && (cachedNow || getNow()) - s > t;
|
|
778
786
|
};
|
|
779
787
|
}
|
|
780
788
|
// conditionally set private methods related to TTL
|
|
@@ -1032,6 +1040,37 @@ class LRUCache {
|
|
|
1032
1040
|
}
|
|
1033
1041
|
return deleted;
|
|
1034
1042
|
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Get the extended info about a given entry, to get its value, size, and
|
|
1045
|
+
* TTL info simultaneously. Like {@link LRUCache#dump}, but just for a
|
|
1046
|
+
* single key. Always returns stale values, if their info is found in the
|
|
1047
|
+
* cache, so be sure to check for expired TTLs if relevant.
|
|
1048
|
+
*/
|
|
1049
|
+
info(key) {
|
|
1050
|
+
const i = this.#keyMap.get(key);
|
|
1051
|
+
if (i === undefined)
|
|
1052
|
+
return undefined;
|
|
1053
|
+
const v = this.#valList[i];
|
|
1054
|
+
const value = this.#isBackgroundFetch(v)
|
|
1055
|
+
? v.__staleWhileFetching
|
|
1056
|
+
: v;
|
|
1057
|
+
if (value === undefined)
|
|
1058
|
+
return undefined;
|
|
1059
|
+
const entry = { value };
|
|
1060
|
+
if (this.#ttls && this.#starts) {
|
|
1061
|
+
const ttl = this.#ttls[i];
|
|
1062
|
+
const start = this.#starts[i];
|
|
1063
|
+
if (ttl && start) {
|
|
1064
|
+
const remain = ttl - (perf.now() - start);
|
|
1065
|
+
entry.ttl = remain;
|
|
1066
|
+
entry.start = Date.now();
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
if (this.#sizes) {
|
|
1070
|
+
entry.size = this.#sizes[i];
|
|
1071
|
+
}
|
|
1072
|
+
return entry;
|
|
1073
|
+
}
|
|
1035
1074
|
/**
|
|
1036
1075
|
* Return an array of [key, {@link LRUCache.Entry}] tuples which can be
|
|
1037
1076
|
* passed to cache.load()
|
|
@@ -1298,12 +1337,13 @@ class LRUCache {
|
|
|
1298
1337
|
peek(k, peekOptions = {}) {
|
|
1299
1338
|
const { allowStale = this.allowStale } = peekOptions;
|
|
1300
1339
|
const index = this.#keyMap.get(k);
|
|
1301
|
-
if (index
|
|
1302
|
-
(allowStale
|
|
1303
|
-
|
|
1304
|
-
// either stale and allowed, or forcing a refresh of non-stale value
|
|
1305
|
-
return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
1340
|
+
if (index === undefined ||
|
|
1341
|
+
(!allowStale && this.#isStale(index))) {
|
|
1342
|
+
return;
|
|
1306
1343
|
}
|
|
1344
|
+
const v = this.#valList[index];
|
|
1345
|
+
// either stale and allowed, or forcing a refresh of non-stale value
|
|
1346
|
+
return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
1307
1347
|
}
|
|
1308
1348
|
#backgroundFetch(k, index, options, context) {
|
|
1309
1349
|
const v = index === undefined ? undefined : this.#valList[index];
|
|
@@ -1639,8 +1679,10 @@ class LRUCache {
|
|
|
1639
1679
|
this.#head = this.#next[index];
|
|
1640
1680
|
}
|
|
1641
1681
|
else {
|
|
1642
|
-
|
|
1643
|
-
this.#
|
|
1682
|
+
const pi = this.#prev[index];
|
|
1683
|
+
this.#next[pi] = this.#next[index];
|
|
1684
|
+
const ni = this.#next[index];
|
|
1685
|
+
this.#prev[ni] = this.#prev[index];
|
|
1644
1686
|
}
|
|
1645
1687
|
this.#size--;
|
|
1646
1688
|
this.#free.push(index);
|
|
@@ -1719,50 +1761,47 @@ function resolveTemplateUsageCheckString(sfc) {
|
|
|
1719
1761
|
return cached;
|
|
1720
1762
|
}
|
|
1721
1763
|
let code = "";
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
}
|
|
1736
|
-
if (prop.arg && !prop.arg.isStatic) {
|
|
1737
|
-
code += `,${processExp(
|
|
1738
|
-
prop.arg.content,
|
|
1739
|
-
prop.name
|
|
1740
|
-
)}`;
|
|
1741
|
-
}
|
|
1742
|
-
if (prop.exp) {
|
|
1743
|
-
code += `,${processExp(
|
|
1744
|
-
prop.exp.content,
|
|
1745
|
-
prop.name
|
|
1746
|
-
)}`;
|
|
1747
|
-
}
|
|
1764
|
+
ast.children.forEach(walk);
|
|
1765
|
+
function walk(node) {
|
|
1766
|
+
var _a;
|
|
1767
|
+
switch (node.type) {
|
|
1768
|
+
case 1:
|
|
1769
|
+
if (!CompilerDOM.parserOptions.isNativeTag(node.tag) && !CompilerDOM.parserOptions.isBuiltInComponent(node.tag)) {
|
|
1770
|
+
code += `,${shared.camelize(node.tag)},${shared.capitalize(shared.camelize(node.tag))}`;
|
|
1771
|
+
}
|
|
1772
|
+
for (let i = 0; i < node.props.length; i++) {
|
|
1773
|
+
const prop = node.props[i];
|
|
1774
|
+
if (prop.type === 7) {
|
|
1775
|
+
if (!shared.isBuiltInDirective(prop.name)) {
|
|
1776
|
+
code += `,v${shared.capitalize(shared.camelize(prop.name))}`;
|
|
1748
1777
|
}
|
|
1749
|
-
if (prop.
|
|
1750
|
-
code += `,${
|
|
1778
|
+
if (prop.arg && !prop.arg.isStatic) {
|
|
1779
|
+
code += `,${stripStrings(
|
|
1780
|
+
prop.arg.content
|
|
1781
|
+
)}`;
|
|
1751
1782
|
}
|
|
1783
|
+
if (prop.exp) {
|
|
1784
|
+
code += `,${processExp(
|
|
1785
|
+
prop.exp.content,
|
|
1786
|
+
prop.name
|
|
1787
|
+
)}`;
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
if (prop.type === 6 && prop.name === "ref" && ((_a = prop.value) == null ? void 0 : _a.content)) {
|
|
1791
|
+
code += `,${prop.value.content}`;
|
|
1752
1792
|
}
|
|
1753
|
-
} else if (node.type === 5) {
|
|
1754
|
-
code += `,${processExp(
|
|
1755
|
-
node.content.content
|
|
1756
|
-
)}`;
|
|
1757
1793
|
}
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1794
|
+
node.children.forEach(walk);
|
|
1795
|
+
break;
|
|
1796
|
+
case 5:
|
|
1797
|
+
code += `,${processExp(node.content.content)}`;
|
|
1798
|
+
break;
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1761
1801
|
code += ";";
|
|
1762
1802
|
templateUsageCheckCache.set(content, code);
|
|
1763
1803
|
return code;
|
|
1764
1804
|
}
|
|
1765
|
-
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
|
|
1766
1805
|
function processExp(exp, dir) {
|
|
1767
1806
|
if (/ as\s+\w|<.*>|:/.test(exp)) {
|
|
1768
1807
|
if (dir === "slot") {
|
|
@@ -1770,7 +1809,7 @@ function processExp(exp, dir) {
|
|
|
1770
1809
|
} else if (dir === "on") {
|
|
1771
1810
|
exp = `()=>{return ${exp}}`;
|
|
1772
1811
|
} else if (dir === "for") {
|
|
1773
|
-
const inMatch = exp.match(forAliasRE);
|
|
1812
|
+
const inMatch = exp.match(CompilerDOM.forAliasRE);
|
|
1774
1813
|
if (inMatch) {
|
|
1775
1814
|
let [, LHS, RHS] = inMatch;
|
|
1776
1815
|
LHS = LHS.trim().replace(/^\(|\)$/g, "");
|
|
@@ -1798,7 +1837,7 @@ function stripTemplateString(str) {
|
|
|
1798
1837
|
}
|
|
1799
1838
|
|
|
1800
1839
|
const DEFAULT_FILENAME = "anonymous.vue";
|
|
1801
|
-
const parseCache = createCache();
|
|
1840
|
+
const parseCache$1 = createCache();
|
|
1802
1841
|
function parse$2(source, {
|
|
1803
1842
|
sourceMap = true,
|
|
1804
1843
|
filename = DEFAULT_FILENAME,
|
|
@@ -1808,7 +1847,7 @@ function parse$2(source, {
|
|
|
1808
1847
|
compiler = CompilerDOM__namespace
|
|
1809
1848
|
} = {}) {
|
|
1810
1849
|
const sourceKey = source + sourceMap + filename + sourceRoot + pad + compiler.parse;
|
|
1811
|
-
const cache = parseCache.get(sourceKey);
|
|
1850
|
+
const cache = parseCache$1.get(sourceKey);
|
|
1812
1851
|
if (cache) {
|
|
1813
1852
|
return cache;
|
|
1814
1853
|
}
|
|
@@ -1826,20 +1865,7 @@ function parse$2(source, {
|
|
|
1826
1865
|
};
|
|
1827
1866
|
const errors = [];
|
|
1828
1867
|
const ast = compiler.parse(source, {
|
|
1829
|
-
|
|
1830
|
-
isNativeTag: () => true,
|
|
1831
|
-
// preserve all whitespaces
|
|
1832
|
-
isPreTag: () => true,
|
|
1833
|
-
getTextMode: ({ tag, props }, parent) => {
|
|
1834
|
-
if (!parent && tag !== "template" || // <template lang="xxx"> should also be treated as raw text
|
|
1835
|
-
tag === "template" && props.some(
|
|
1836
|
-
(p) => p.type === 6 && p.name === "lang" && p.value && p.value.content && p.value.content !== "html"
|
|
1837
|
-
)) {
|
|
1838
|
-
return 2;
|
|
1839
|
-
} else {
|
|
1840
|
-
return 0;
|
|
1841
|
-
}
|
|
1842
|
-
},
|
|
1868
|
+
parseMode: "sfc",
|
|
1843
1869
|
onError: (e) => {
|
|
1844
1870
|
errors.push(e);
|
|
1845
1871
|
}
|
|
@@ -1859,12 +1885,16 @@ function parse$2(source, {
|
|
|
1859
1885
|
source,
|
|
1860
1886
|
false
|
|
1861
1887
|
);
|
|
1862
|
-
templateBlock.
|
|
1888
|
+
if (!templateBlock.attrs.src) {
|
|
1889
|
+
templateBlock.ast = compilerCore.createRoot(node.children, source);
|
|
1890
|
+
}
|
|
1863
1891
|
if (templateBlock.attrs.functional) {
|
|
1864
1892
|
const err = new SyntaxError(
|
|
1865
1893
|
`<template functional> is no longer supported in Vue 3, since functional components no longer have significant performance difference from stateful ones. Just use a normal <template> instead.`
|
|
1866
1894
|
);
|
|
1867
|
-
err.loc = node.props.find(
|
|
1895
|
+
err.loc = node.props.find(
|
|
1896
|
+
(p) => p.type === 6 && p.name === "functional"
|
|
1897
|
+
).loc;
|
|
1868
1898
|
errors.push(err);
|
|
1869
1899
|
}
|
|
1870
1900
|
} else {
|
|
@@ -1951,7 +1981,7 @@ function parse$2(source, {
|
|
|
1951
1981
|
descriptor,
|
|
1952
1982
|
errors
|
|
1953
1983
|
};
|
|
1954
|
-
parseCache.set(sourceKey, result);
|
|
1984
|
+
parseCache$1.set(sourceKey, result);
|
|
1955
1985
|
return result;
|
|
1956
1986
|
}
|
|
1957
1987
|
function createDuplicateBlockError(node, isScriptSetup = false) {
|
|
@@ -1963,32 +1993,11 @@ function createDuplicateBlockError(node, isScriptSetup = false) {
|
|
|
1963
1993
|
}
|
|
1964
1994
|
function createBlock(node, source, pad) {
|
|
1965
1995
|
const type = node.tag;
|
|
1966
|
-
|
|
1967
|
-
let content = "";
|
|
1968
|
-
if (node.children.length) {
|
|
1969
|
-
start = node.children[0].loc.start;
|
|
1970
|
-
end = node.children[node.children.length - 1].loc.end;
|
|
1971
|
-
content = source.slice(start.offset, end.offset);
|
|
1972
|
-
} else {
|
|
1973
|
-
const offset = node.loc.source.indexOf(`</`);
|
|
1974
|
-
if (offset > -1) {
|
|
1975
|
-
start = {
|
|
1976
|
-
line: start.line,
|
|
1977
|
-
column: start.column + offset,
|
|
1978
|
-
offset: start.offset + offset
|
|
1979
|
-
};
|
|
1980
|
-
}
|
|
1981
|
-
end = { ...start };
|
|
1982
|
-
}
|
|
1983
|
-
const loc = {
|
|
1984
|
-
source: content,
|
|
1985
|
-
start,
|
|
1986
|
-
end
|
|
1987
|
-
};
|
|
1996
|
+
const loc = node.innerLoc;
|
|
1988
1997
|
const attrs = {};
|
|
1989
1998
|
const block = {
|
|
1990
1999
|
type,
|
|
1991
|
-
content,
|
|
2000
|
+
content: source.slice(loc.start.offset, loc.end.offset),
|
|
1992
2001
|
loc,
|
|
1993
2002
|
attrs
|
|
1994
2003
|
};
|
|
@@ -1997,18 +2006,19 @@ function createBlock(node, source, pad) {
|
|
|
1997
2006
|
}
|
|
1998
2007
|
node.props.forEach((p) => {
|
|
1999
2008
|
if (p.type === 6) {
|
|
2000
|
-
|
|
2001
|
-
|
|
2009
|
+
const name = p.name;
|
|
2010
|
+
attrs[name] = p.value ? p.value.content || true : true;
|
|
2011
|
+
if (name === "lang") {
|
|
2002
2012
|
block.lang = p.value && p.value.content;
|
|
2003
|
-
} else if (
|
|
2013
|
+
} else if (name === "src") {
|
|
2004
2014
|
block.src = p.value && p.value.content;
|
|
2005
2015
|
} else if (type === "style") {
|
|
2006
|
-
if (
|
|
2016
|
+
if (name === "scoped") {
|
|
2007
2017
|
block.scoped = true;
|
|
2008
|
-
} else if (
|
|
2009
|
-
block.module = attrs[
|
|
2018
|
+
} else if (name === "module") {
|
|
2019
|
+
block.module = attrs[name];
|
|
2010
2020
|
}
|
|
2011
|
-
} else if (type === "script" &&
|
|
2021
|
+
} else if (type === "script" && name === "setup") {
|
|
2012
2022
|
block.setup = attrs.setup;
|
|
2013
2023
|
}
|
|
2014
2024
|
}
|
|
@@ -2024,28 +2034,27 @@ function generateSourceMap(filename, source, generated, sourceRoot, lineOffset)
|
|
|
2024
2034
|
sourceRoot: sourceRoot.replace(/\\/g, "/")
|
|
2025
2035
|
});
|
|
2026
2036
|
map.setSourceContent(filename, source);
|
|
2037
|
+
map._sources.add(filename);
|
|
2027
2038
|
generated.split(splitRE).forEach((line, index) => {
|
|
2028
2039
|
if (!emptyRE.test(line)) {
|
|
2029
2040
|
const originalLine = index + 1 + lineOffset;
|
|
2030
2041
|
const generatedLine = index + 1;
|
|
2031
2042
|
for (let i = 0; i < line.length; i++) {
|
|
2032
2043
|
if (!/\s/.test(line[i])) {
|
|
2033
|
-
map.
|
|
2044
|
+
map._mappings.add({
|
|
2045
|
+
originalLine,
|
|
2046
|
+
originalColumn: i,
|
|
2047
|
+
generatedLine,
|
|
2048
|
+
generatedColumn: i,
|
|
2034
2049
|
source: filename,
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
column: i
|
|
2038
|
-
},
|
|
2039
|
-
generated: {
|
|
2040
|
-
line: generatedLine,
|
|
2041
|
-
column: i
|
|
2042
|
-
}
|
|
2050
|
+
// @ts-ignore
|
|
2051
|
+
name: null
|
|
2043
2052
|
});
|
|
2044
2053
|
}
|
|
2045
2054
|
}
|
|
2046
2055
|
}
|
|
2047
2056
|
});
|
|
2048
|
-
return
|
|
2057
|
+
return map.toJSON();
|
|
2049
2058
|
}
|
|
2050
2059
|
function padContent(content, block, pad) {
|
|
2051
2060
|
content = content.slice(0, block.loc.start.offset);
|
|
@@ -4185,7 +4194,9 @@ function compileTemplate(options) {
|
|
|
4185
4194
|
try {
|
|
4186
4195
|
return doCompileTemplate({
|
|
4187
4196
|
...options,
|
|
4188
|
-
source: preprocess$1(options, preprocessor)
|
|
4197
|
+
source: preprocess$1(options, preprocessor),
|
|
4198
|
+
ast: void 0
|
|
4199
|
+
// invalidate AST if template goes through preprocessor
|
|
4189
4200
|
});
|
|
4190
4201
|
} catch (e) {
|
|
4191
4202
|
return {
|
|
@@ -4217,10 +4228,11 @@ function doCompileTemplate({
|
|
|
4217
4228
|
slotted,
|
|
4218
4229
|
inMap,
|
|
4219
4230
|
source,
|
|
4231
|
+
ast: inAST,
|
|
4220
4232
|
ssr = false,
|
|
4221
4233
|
ssrCssVars,
|
|
4222
4234
|
isProd = false,
|
|
4223
|
-
compiler
|
|
4235
|
+
compiler,
|
|
4224
4236
|
compilerOptions = {},
|
|
4225
4237
|
transformAssetUrls
|
|
4226
4238
|
}) {
|
|
@@ -4247,7 +4259,22 @@ function doCompileTemplate({
|
|
|
4247
4259
|
}
|
|
4248
4260
|
const shortId = id.replace(/^data-v-/, "");
|
|
4249
4261
|
const longId = `data-v-${shortId}`;
|
|
4250
|
-
|
|
4262
|
+
const defaultCompiler = ssr ? CompilerSSR__namespace : CompilerDOM__namespace;
|
|
4263
|
+
compiler = compiler || defaultCompiler;
|
|
4264
|
+
if (compiler !== defaultCompiler) {
|
|
4265
|
+
inAST = void 0;
|
|
4266
|
+
}
|
|
4267
|
+
if (inAST == null ? void 0 : inAST.transformed) {
|
|
4268
|
+
const newAST = (ssr ? CompilerDOM__namespace : compiler).parse(inAST.source, {
|
|
4269
|
+
parseMode: "sfc",
|
|
4270
|
+
onError: (e) => errors.push(e)
|
|
4271
|
+
});
|
|
4272
|
+
const template = newAST.children.find(
|
|
4273
|
+
(node) => node.type === 1 && node.tag === "template"
|
|
4274
|
+
);
|
|
4275
|
+
inAST = compilerCore.createRoot(template.children, inAST.source);
|
|
4276
|
+
}
|
|
4277
|
+
let { code, ast, preamble, map } = compiler.compile(inAST || source, {
|
|
4251
4278
|
mode: "module",
|
|
4252
4279
|
prefixIdentifiers: true,
|
|
4253
4280
|
hoistStatic: true,
|
|
@@ -4263,7 +4290,7 @@ function doCompileTemplate({
|
|
|
4263
4290
|
onError: (e) => errors.push(e),
|
|
4264
4291
|
onWarn: (w) => warnings.push(w)
|
|
4265
4292
|
});
|
|
4266
|
-
if (inMap) {
|
|
4293
|
+
if (inMap && !inAST) {
|
|
4267
4294
|
if (map) {
|
|
4268
4295
|
map = mapLines(inMap, map);
|
|
4269
4296
|
}
|
|
@@ -4276,7 +4303,7 @@ function doCompileTemplate({
|
|
|
4276
4303
|
if (w.loc) {
|
|
4277
4304
|
msg += `
|
|
4278
4305
|
${shared.generateCodeFrame(
|
|
4279
|
-
source,
|
|
4306
|
+
(inAST == null ? void 0 : inAST.source) || source,
|
|
4280
4307
|
w.loc.start.offset,
|
|
4281
4308
|
w.loc.end.offset
|
|
4282
4309
|
)}`;
|
|
@@ -7902,6 +7929,10 @@ function rewriteSelector(id, selector, selectorRoot, slotted = false) {
|
|
|
7902
7929
|
if (n.type !== "pseudo" && n.type !== "combinator") {
|
|
7903
7930
|
node = n;
|
|
7904
7931
|
}
|
|
7932
|
+
if (n.type === "pseudo" && (n.value === ":is" || n.value === ":where")) {
|
|
7933
|
+
rewriteSelector(id, n.nodes[0], selectorRoot, slotted);
|
|
7934
|
+
shouldInject = false;
|
|
7935
|
+
}
|
|
7905
7936
|
});
|
|
7906
7937
|
if (node) {
|
|
7907
7938
|
node.spaces.after = "";
|
|
@@ -11171,7 +11202,10 @@ const scss = (source, map, options, load = require) => {
|
|
|
11171
11202
|
if (map) {
|
|
11172
11203
|
return {
|
|
11173
11204
|
code: result.css.toString(),
|
|
11174
|
-
map: merge$1(
|
|
11205
|
+
map: merge$1(
|
|
11206
|
+
map,
|
|
11207
|
+
result.map.toJSON ? result.map.toJSON() : JSON.parse(result.map.toString())
|
|
11208
|
+
),
|
|
11175
11209
|
errors: [],
|
|
11176
11210
|
dependencies
|
|
11177
11211
|
};
|
|
@@ -15532,30 +15566,8 @@ function processNormalScript(ctx, scopeId) {
|
|
|
15532
15566
|
let map = script.map;
|
|
15533
15567
|
const scriptAst = ctx.scriptAst;
|
|
15534
15568
|
const bindings = analyzeScriptBindings(scriptAst.body);
|
|
15535
|
-
const {
|
|
15536
|
-
const {
|
|
15537
|
-
if (ctx.options.reactivityTransform && reactivityTransform.shouldTransform(content)) {
|
|
15538
|
-
const s = new MagicString(source);
|
|
15539
|
-
const startOffset = script.loc.start.offset;
|
|
15540
|
-
const endOffset = script.loc.end.offset;
|
|
15541
|
-
const { importedHelpers } = reactivityTransform.transformAST(scriptAst, s, startOffset);
|
|
15542
|
-
if (importedHelpers.length) {
|
|
15543
|
-
s.prepend(
|
|
15544
|
-
`import { ${importedHelpers.map((h) => `${h} as _${h}`).join(", ")} } from 'vue'
|
|
15545
|
-
`
|
|
15546
|
-
);
|
|
15547
|
-
}
|
|
15548
|
-
s.remove(0, startOffset);
|
|
15549
|
-
s.remove(endOffset, source.length);
|
|
15550
|
-
content = s.toString();
|
|
15551
|
-
if (sourceMap !== false) {
|
|
15552
|
-
map = s.generateMap({
|
|
15553
|
-
source: filename,
|
|
15554
|
-
hires: true,
|
|
15555
|
-
includeContent: true
|
|
15556
|
-
});
|
|
15557
|
-
}
|
|
15558
|
-
}
|
|
15569
|
+
const { cssVars } = ctx.descriptor;
|
|
15570
|
+
const { genDefaultAs, isProd } = ctx.options;
|
|
15559
15571
|
if (cssVars.length || genDefaultAs) {
|
|
15560
15572
|
const defaultVar = genDefaultAs || normalScriptDefaultVar;
|
|
15561
15573
|
const s = new MagicString(content);
|
|
@@ -15674,7 +15686,7 @@ function resolveParserPlugins(lang, userPlugins, dts = false) {
|
|
|
15674
15686
|
}
|
|
15675
15687
|
if (lang === "ts" || lang === "tsx") {
|
|
15676
15688
|
plugins.push(["typescript", { dts }]);
|
|
15677
|
-
if (!
|
|
15689
|
+
if (!userPlugins || !userPlugins.includes("decorators")) {
|
|
15678
15690
|
plugins.push("decorators-legacy");
|
|
15679
15691
|
}
|
|
15680
15692
|
}
|
|
@@ -17908,12 +17920,16 @@ function resolveInterfaceMembers(ctx, node, scope) {
|
|
|
17908
17920
|
continue;
|
|
17909
17921
|
}
|
|
17910
17922
|
try {
|
|
17911
|
-
const { props } = resolveTypeElements(ctx, ext, scope);
|
|
17923
|
+
const { props, calls } = resolveTypeElements(ctx, ext, scope);
|
|
17912
17924
|
for (const key in props) {
|
|
17913
17925
|
if (!shared.hasOwn(base.props, key)) {
|
|
17914
17926
|
base.props[key] = props[key];
|
|
17915
17927
|
}
|
|
17916
17928
|
}
|
|
17929
|
+
if (calls) {
|
|
17930
|
+
;
|
|
17931
|
+
(base.calls || (base.calls = [])).push(...calls);
|
|
17932
|
+
}
|
|
17917
17933
|
} catch (e) {
|
|
17918
17934
|
ctx.error(
|
|
17919
17935
|
`Failed to resolve extends base type.
|
|
@@ -18245,7 +18261,11 @@ function importSourceToScope(ctx, node, scope, source) {
|
|
|
18245
18261
|
}
|
|
18246
18262
|
let resolved = scope.resolvedImportSources[source];
|
|
18247
18263
|
if (!resolved) {
|
|
18248
|
-
if (source.startsWith("
|
|
18264
|
+
if (source.startsWith("..")) {
|
|
18265
|
+
const osSpecificJoinFn = process__namespace.platform === "win32" ? path$3.join : joinPaths;
|
|
18266
|
+
const filename = osSpecificJoinFn(path$3.dirname(scope.filename), source);
|
|
18267
|
+
resolved = resolveExt(filename, fs);
|
|
18268
|
+
} else if (source.startsWith(".")) {
|
|
18249
18269
|
const filename = joinPaths(path$3.dirname(scope.filename), source);
|
|
18250
18270
|
resolved = resolveExt(filename, fs);
|
|
18251
18271
|
} else {
|
|
@@ -18326,7 +18346,7 @@ function resolveWithTS(containingFile, source, ts2, fs) {
|
|
|
18326
18346
|
}
|
|
18327
18347
|
tsCompilerOptions = matchedConfig.config.options;
|
|
18328
18348
|
tsResolveCache = matchedConfig.cache || (matchedConfig.cache = ts2.createModuleResolutionCache(
|
|
18329
|
-
|
|
18349
|
+
process__namespace.cwd(),
|
|
18330
18350
|
createGetCanonicalFileName(ts2.sys.useCaseSensitiveFileNames),
|
|
18331
18351
|
tsCompilerOptions
|
|
18332
18352
|
));
|
|
@@ -18715,6 +18735,7 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
|
|
|
18715
18735
|
case "WeakMap":
|
|
18716
18736
|
case "Date":
|
|
18717
18737
|
case "Promise":
|
|
18738
|
+
case "Error":
|
|
18718
18739
|
return [node.typeName.name];
|
|
18719
18740
|
case "Partial":
|
|
18720
18741
|
case "Required":
|
|
@@ -19111,7 +19132,7 @@ function genRuntimeProps(ctx) {
|
|
|
19111
19132
|
const defaults = [];
|
|
19112
19133
|
for (const key in ctx.propsDestructuredBindings) {
|
|
19113
19134
|
const d = genDestructuredDefaultValue(ctx, key);
|
|
19114
|
-
const finalKey =
|
|
19135
|
+
const finalKey = getEscapedPropName(key);
|
|
19115
19136
|
if (d)
|
|
19116
19137
|
defaults.push(
|
|
19117
19138
|
`${finalKey}: ${d.valueString}${d.needSkipFactory ? `, __skip_${finalKey}: true` : ``}`
|
|
@@ -19203,7 +19224,7 @@ function genRuntimePropFromType(ctx, { key, required, type, skipCheck }, hasStat
|
|
|
19203
19224
|
}
|
|
19204
19225
|
}
|
|
19205
19226
|
}
|
|
19206
|
-
const finalKey =
|
|
19227
|
+
const finalKey = getEscapedPropName(key);
|
|
19207
19228
|
if (!ctx.options.isProd) {
|
|
19208
19229
|
return `${finalKey}: { ${concatStrings([
|
|
19209
19230
|
`type: ${toRuntimeTypeString(type)}`,
|
|
@@ -19269,7 +19290,7 @@ function inferValueType(node) {
|
|
|
19269
19290
|
}
|
|
19270
19291
|
|
|
19271
19292
|
function processPropsDestructure(ctx, declId) {
|
|
19272
|
-
if (!ctx.options.propsDestructure
|
|
19293
|
+
if (!ctx.options.propsDestructure) {
|
|
19273
19294
|
return;
|
|
19274
19295
|
}
|
|
19275
19296
|
warnOnce(
|
|
@@ -19317,7 +19338,7 @@ To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/502
|
|
|
19317
19338
|
}
|
|
19318
19339
|
}
|
|
19319
19340
|
function transformDestructuredProps(ctx, vueImportAliases) {
|
|
19320
|
-
if (!ctx.options.propsDestructure
|
|
19341
|
+
if (!ctx.options.propsDestructure) {
|
|
19321
19342
|
return;
|
|
19322
19343
|
}
|
|
19323
19344
|
const rootScope = {};
|
|
@@ -19668,8 +19689,6 @@ Upgrade your vite or vue-loader version for compatibility with the latest experi
|
|
|
19668
19689
|
const scopeId = options.id ? options.id.replace(/^data-v-/, "") : "";
|
|
19669
19690
|
const scriptLang = script && script.lang;
|
|
19670
19691
|
const scriptSetupLang = scriptSetup && scriptSetup.lang;
|
|
19671
|
-
const enableReactivityTransform = !!options.reactivityTransform;
|
|
19672
|
-
let refBindings;
|
|
19673
19692
|
if (!scriptSetup) {
|
|
19674
19693
|
if (!script) {
|
|
19675
19694
|
throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
|
|
@@ -19883,17 +19902,6 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
|
|
|
19883
19902
|
);
|
|
19884
19903
|
}
|
|
19885
19904
|
}
|
|
19886
|
-
if (enableReactivityTransform && reactivityTransform.shouldTransform(script.content)) {
|
|
19887
|
-
const { rootRefs, importedHelpers } = reactivityTransform.transformAST(
|
|
19888
|
-
scriptAst,
|
|
19889
|
-
ctx.s,
|
|
19890
|
-
scriptStartOffset
|
|
19891
|
-
);
|
|
19892
|
-
refBindings = rootRefs;
|
|
19893
|
-
for (const h of importedHelpers) {
|
|
19894
|
-
ctx.helperImports.add(h);
|
|
19895
|
-
}
|
|
19896
|
-
}
|
|
19897
19905
|
if (scriptStartOffset > startOffset) {
|
|
19898
19906
|
if (!/\n$/.test(script.content.trim())) {
|
|
19899
19907
|
ctx.s.appendLeft(scriptEndOffset, `
|
|
@@ -20021,19 +20029,6 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
|
|
|
20021
20029
|
if (ctx.propsDestructureDecl) {
|
|
20022
20030
|
transformDestructuredProps(ctx, vueImportAliases);
|
|
20023
20031
|
}
|
|
20024
|
-
if (enableReactivityTransform && // normal <script> had ref bindings that maybe used in <script setup>
|
|
20025
|
-
(refBindings || reactivityTransform.shouldTransform(scriptSetup.content))) {
|
|
20026
|
-
const { rootRefs, importedHelpers } = reactivityTransform.transformAST(
|
|
20027
|
-
scriptSetupAst,
|
|
20028
|
-
ctx.s,
|
|
20029
|
-
startOffset,
|
|
20030
|
-
refBindings
|
|
20031
|
-
);
|
|
20032
|
-
refBindings = refBindings ? [...refBindings, ...rootRefs] : rootRefs;
|
|
20033
|
-
for (const h of importedHelpers) {
|
|
20034
|
-
ctx.helperImports.add(h);
|
|
20035
|
-
}
|
|
20036
|
-
}
|
|
20037
20032
|
checkInvalidScopeReference(ctx.propsRuntimeDecl, DEFINE_PROPS);
|
|
20038
20033
|
checkInvalidScopeReference(ctx.propsRuntimeDefaults, DEFINE_PROPS);
|
|
20039
20034
|
checkInvalidScopeReference(ctx.propsDestructureDecl, DEFINE_PROPS);
|
|
@@ -20069,11 +20064,6 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
|
|
|
20069
20064
|
for (const key in setupBindings) {
|
|
20070
20065
|
ctx.bindingMetadata[key] = setupBindings[key];
|
|
20071
20066
|
}
|
|
20072
|
-
if (refBindings) {
|
|
20073
|
-
for (const key of refBindings) {
|
|
20074
|
-
ctx.bindingMetadata[key] = "setup-ref";
|
|
20075
|
-
}
|
|
20076
|
-
}
|
|
20077
20067
|
if (sfc.cssVars.length && // no need to do this when targeting SSR
|
|
20078
20068
|
!((_a = options.templateOptions) == null ? void 0 : _a.ssr)) {
|
|
20079
20069
|
ctx.helperImports.add(CSS_VARS_HELPER);
|
|
@@ -20289,7 +20279,6 @@ ${exposeCall}`
|
|
|
20289
20279
|
`
|
|
20290
20280
|
);
|
|
20291
20281
|
}
|
|
20292
|
-
ctx.s.trim();
|
|
20293
20282
|
return {
|
|
20294
20283
|
...scriptSetup,
|
|
20295
20284
|
bindings: ctx.bindingMetadata,
|
|
@@ -20461,18 +20450,17 @@ function isStaticNode(node) {
|
|
|
20461
20450
|
return false;
|
|
20462
20451
|
}
|
|
20463
20452
|
|
|
20464
|
-
const version = "3.4.0-alpha.
|
|
20453
|
+
const version = "3.4.0-alpha.3";
|
|
20454
|
+
const parseCache = parseCache$1;
|
|
20465
20455
|
const walk = estreeWalker.walk;
|
|
20456
|
+
const shouldTransformRef = () => false;
|
|
20466
20457
|
|
|
20467
|
-
exports.babelParse = parser$2.parse;
|
|
20468
20458
|
exports.extractIdentifiers = compilerCore.extractIdentifiers;
|
|
20469
20459
|
exports.generateCodeFrame = compilerCore.generateCodeFrame;
|
|
20470
20460
|
exports.isInDestructureAssignment = compilerCore.isInDestructureAssignment;
|
|
20471
20461
|
exports.isStaticProperty = compilerCore.isStaticProperty;
|
|
20472
20462
|
exports.walkIdentifiers = compilerCore.walkIdentifiers;
|
|
20473
|
-
exports.
|
|
20474
|
-
exports.transformRef = reactivityTransform.transform;
|
|
20475
|
-
exports.transformRefAST = reactivityTransform.transformAST;
|
|
20463
|
+
exports.babelParse = parser$2.parse;
|
|
20476
20464
|
exports.MagicString = MagicString;
|
|
20477
20465
|
exports.compileScript = compileScript;
|
|
20478
20466
|
exports.compileStyle = compileStyle;
|
|
@@ -20488,5 +20476,6 @@ exports.registerTS = registerTS;
|
|
|
20488
20476
|
exports.resolveTypeElements = resolveTypeElements;
|
|
20489
20477
|
exports.rewriteDefault = rewriteDefault;
|
|
20490
20478
|
exports.rewriteDefaultAST = rewriteDefaultAST;
|
|
20479
|
+
exports.shouldTransformRef = shouldTransformRef;
|
|
20491
20480
|
exports.version = version;
|
|
20492
20481
|
exports.walk = walk;
|