@vue/compiler-sfc 3.3.8 → 3.3.10

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 CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  **Note: as of 3.2.13+, this package is included as a dependency of the main `vue` package and can be accessed as `vue/compiler-sfc`. This means you no longer need to explicitly install this package and ensure its version match that of `vue`'s. Just use the main `vue/compiler-sfc` deep import instead.**
6
6
 
7
- This package contains lower level utilities that you can use if you are writing a plugin / transform for a bundler or module system that compiles Vue Single File Components (SFCs) into JavaScript. It is used in [vue-loader](https://github.com/vuejs/vue-loader), [rollup-plugin-vue](https://github.com/vuejs/rollup-plugin-vue) and [vite](https://github.com/vitejs/vite).
7
+ This package contains lower level utilities that you can use if you are writing a plugin / transform for a bundler or module system that compiles Vue Single File Components (SFCs) into JavaScript. It is used in [vue-loader](https://github.com/vuejs/vue-loader) and [@vitejs/plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue).
8
8
 
9
9
  ## API
10
10
 
@@ -77,4 +77,4 @@ export default script
77
77
 
78
78
  Options needed for these APIs can be passed via the query string.
79
79
 
80
- For detailed API references and options, check out the source type definitions. For actual usage of these APIs, check out [rollup-plugin-vue](https://github.com/vuejs/rollup-plugin-vue/tree/next) or [vue-loader](https://github.com/vuejs/vue-loader/tree/next).
80
+ For detailed API references and options, check out the source type definitions. For actual usage of these APIs, check out [@vitejs/plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue) or [vue-loader](https://github.com/vuejs/vue-loader/tree/next).
@@ -16,6 +16,7 @@ var require$$0$1 = require('postcss');
16
16
  var estreeWalker = require('estree-walker');
17
17
  var reactivityTransform = require('@vue/reactivity-transform');
18
18
  var MagicString = require('magic-string');
19
+ var process$1 = require('process');
19
20
 
20
21
  function _interopNamespaceDefault(e) {
21
22
  var n = Object.create(null);
@@ -30,6 +31,7 @@ function _interopNamespaceDefault(e) {
30
31
 
31
32
  var CompilerDOM__namespace = /*#__PURE__*/_interopNamespaceDefault(CompilerDOM);
32
33
  var CompilerSSR__namespace = /*#__PURE__*/_interopNamespaceDefault(CompilerSSR);
34
+ var process__namespace = /*#__PURE__*/_interopNamespaceDefault(process$1);
33
35
 
34
36
  const UNKNOWN_TYPE = "Unknown";
35
37
  function resolveObjectKey(node, computed) {
@@ -87,9 +89,16 @@ function normalizePath(p) {
87
89
  return normalize(p.replace(windowsSlashRE, "/"));
88
90
  }
89
91
  const joinPaths = (path$3.posix || path$3).join;
90
- const escapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
91
- function getEscapedKey(key) {
92
- return escapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
92
+ const propNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~\-]/;
93
+ function getEscapedPropName(key) {
94
+ return propNameEscapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
95
+ }
96
+ const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
97
+ function getEscapedCssVarName(key, doubleEscape) {
98
+ return key.replace(
99
+ cssVarNameEscapeSymbolsRE,
100
+ (s) => doubleEscape ? `\\\\${s}` : `\\${s}`
101
+ );
93
102
  }
94
103
 
95
104
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -172,15 +181,15 @@ const CSS_VARS_HELPER = `useCssVars`;
172
181
  function genCssVarsFromList(vars, id, isProd, isSSR = false) {
173
182
  return `{
174
183
  ${vars.map(
175
- (key) => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd)}": (${key})`
184
+ (key) => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd, isSSR)}": (${key})`
176
185
  ).join(",\n ")}
177
186
  }`;
178
187
  }
179
- function genVarName(id, raw, isProd) {
188
+ function genVarName(id, raw, isProd, isSSR = false) {
180
189
  if (isProd) {
181
190
  return hash$1(id + raw);
182
191
  } else {
183
- return `${id}-${raw.replace(escapeSymbolsRE, (s) => `\\${s}`)}`;
192
+ return `${id}-${getEscapedCssVarName(raw, isSSR)}`;
184
193
  }
185
194
  }
186
195
  function normalizeExpression(exp) {
@@ -734,6 +743,9 @@ class LRUCache {
734
743
  if (ttls[index]) {
735
744
  const ttl = ttls[index];
736
745
  const start = starts[index];
746
+ /* c8 ignore next */
747
+ if (!ttl || !start)
748
+ return;
737
749
  status.ttl = ttl;
738
750
  status.start = start;
739
751
  status.now = cachedNow || getNow();
@@ -765,16 +777,16 @@ class LRUCache {
765
777
  }
766
778
  const ttl = ttls[index];
767
779
  const start = starts[index];
768
- if (ttl === 0 || start === 0) {
780
+ if (!ttl || !start) {
769
781
  return Infinity;
770
782
  }
771
783
  const age = (cachedNow || getNow()) - start;
772
784
  return ttl - age;
773
785
  };
774
786
  this.#isStale = index => {
775
- return (ttls[index] !== 0 &&
776
- starts[index] !== 0 &&
777
- (cachedNow || getNow()) - starts[index] > ttls[index]);
787
+ const s = starts[index];
788
+ const t = ttls[index];
789
+ return !!t && !!s && (cachedNow || getNow()) - s > t;
778
790
  };
779
791
  }
780
792
  // conditionally set private methods related to TTL
@@ -1032,6 +1044,37 @@ class LRUCache {
1032
1044
  }
1033
1045
  return deleted;
1034
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
+ }
1035
1078
  /**
1036
1079
  * Return an array of [key, {@link LRUCache.Entry}] tuples which can be
1037
1080
  * passed to cache.load()
@@ -1298,12 +1341,13 @@ class LRUCache {
1298
1341
  peek(k, peekOptions = {}) {
1299
1342
  const { allowStale = this.allowStale } = peekOptions;
1300
1343
  const index = this.#keyMap.get(k);
1301
- if (index !== undefined &&
1302
- (allowStale || !this.#isStale(index))) {
1303
- const v = this.#valList[index];
1304
- // either stale and allowed, or forcing a refresh of non-stale value
1305
- return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
1344
+ if (index === undefined ||
1345
+ (!allowStale && this.#isStale(index))) {
1346
+ return;
1306
1347
  }
1348
+ const v = this.#valList[index];
1349
+ // either stale and allowed, or forcing a refresh of non-stale value
1350
+ return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
1307
1351
  }
1308
1352
  #backgroundFetch(k, index, options, context) {
1309
1353
  const v = index === undefined ? undefined : this.#valList[index];
@@ -1639,8 +1683,10 @@ class LRUCache {
1639
1683
  this.#head = this.#next[index];
1640
1684
  }
1641
1685
  else {
1642
- this.#next[this.#prev[index]] = this.#next[index];
1643
- this.#prev[this.#next[index]] = this.#prev[index];
1686
+ const pi = this.#prev[index];
1687
+ this.#next[pi] = this.#next[index];
1688
+ const ni = this.#next[index];
1689
+ this.#prev[ni] = this.#prev[index];
1644
1690
  }
1645
1691
  this.#size--;
1646
1692
  this.#free.push(index);
@@ -1761,7 +1807,6 @@ function resolveTemplateUsageCheckString(sfc) {
1761
1807
  templateUsageCheckCache.set(content, code);
1762
1808
  return code;
1763
1809
  }
1764
- const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
1765
1810
  function processExp(exp, dir) {
1766
1811
  if (/ as\s+\w|<.*>|:/.test(exp)) {
1767
1812
  if (dir === "slot") {
@@ -1769,7 +1814,7 @@ function processExp(exp, dir) {
1769
1814
  } else if (dir === "on") {
1770
1815
  exp = `()=>{return ${exp}}`;
1771
1816
  } else if (dir === "for") {
1772
- const inMatch = exp.match(forAliasRE);
1817
+ const inMatch = exp.match(CompilerDOM.forAliasRE);
1773
1818
  if (inMatch) {
1774
1819
  let [, LHS, RHS] = inMatch;
1775
1820
  LHS = LHS.trim().replace(/^\(|\)$/g, "");
@@ -1924,22 +1969,29 @@ function parse$2(source, {
1924
1969
  descriptor.script = null;
1925
1970
  }
1926
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
+ }
1927
1978
  if (sourceMap) {
1928
- const genMap = (block) => {
1979
+ const genMap = (block, columnOffset = 0) => {
1929
1980
  if (block && !block.src) {
1930
1981
  block.map = generateSourceMap(
1931
1982
  filename,
1932
1983
  source,
1933
1984
  block.content,
1934
1985
  sourceRoot,
1935
- !pad || block.type === "template" ? block.loc.start.line - 1 : 0
1986
+ !pad || block.type === "template" ? block.loc.start.line - 1 : 0,
1987
+ columnOffset
1936
1988
  );
1937
1989
  }
1938
1990
  };
1939
- genMap(descriptor.template);
1991
+ genMap(descriptor.template, templateColumnOffset);
1940
1992
  genMap(descriptor.script);
1941
- descriptor.styles.forEach(genMap);
1942
- descriptor.customBlocks.forEach(genMap);
1993
+ descriptor.styles.forEach((s) => genMap(s));
1994
+ descriptor.customBlocks.forEach((s) => genMap(s));
1943
1995
  }
1944
1996
  descriptor.cssVars = parseCssVars(descriptor);
1945
1997
  const slottedRE = /(?:::v-|:)slotted\(/;
@@ -2017,7 +2069,7 @@ function createBlock(node, source, pad) {
2017
2069
  const splitRE = /\r?\n/g;
2018
2070
  const emptyRE = /^(?:\/\/)?\s*$/;
2019
2071
  const replaceRE = /./g;
2020
- function generateSourceMap(filename, source, generated, sourceRoot, lineOffset) {
2072
+ function generateSourceMap(filename, source, generated, sourceRoot, lineOffset, columnOffset) {
2021
2073
  const map = new sourceMapJs.SourceMapGenerator({
2022
2074
  file: filename.replace(/\\/g, "/"),
2023
2075
  sourceRoot: sourceRoot.replace(/\\/g, "/")
@@ -2033,7 +2085,7 @@ function generateSourceMap(filename, source, generated, sourceRoot, lineOffset)
2033
2085
  source: filename,
2034
2086
  original: {
2035
2087
  line: originalLine,
2036
- column: i
2088
+ column: i + columnOffset
2037
2089
  },
2038
2090
  generated: {
2039
2091
  line: generatedLine,
@@ -2084,6 +2136,26 @@ function hmrShouldReload(prevImports, next) {
2084
2136
  }
2085
2137
  return false;
2086
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
+ }
2087
2159
 
2088
2160
  function isRelativeUrl(url) {
2089
2161
  const firstChar = url.charAt(0);
@@ -7898,10 +7970,19 @@ function rewriteSelector(id, selector, selectorRoot, slotted = false) {
7898
7970
  return false;
7899
7971
  }
7900
7972
  }
7901
- if (n.type !== "pseudo" && n.type !== "combinator") {
7973
+ if (n.type !== "pseudo" && n.type !== "combinator" || n.type === "pseudo" && (n.value === ":is" || n.value === ":where")) {
7902
7974
  node = n;
7903
7975
  }
7904
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
+ );
7983
+ shouldInject = false;
7984
+ }
7985
+ }
7905
7986
  if (node) {
7906
7987
  node.spaces.after = "";
7907
7988
  } else {
@@ -15673,7 +15754,7 @@ function resolveParserPlugins(lang, userPlugins, dts = false) {
15673
15754
  }
15674
15755
  if (lang === "ts" || lang === "tsx") {
15675
15756
  plugins.push(["typescript", { dts }]);
15676
- if (!plugins.includes("decorators")) {
15757
+ if (!userPlugins || !userPlugins.includes("decorators")) {
15677
15758
  plugins.push("decorators-legacy");
15678
15759
  }
15679
15760
  }
@@ -17728,33 +17809,39 @@ class TypeScope {
17728
17809
  this.exportedDeclares = /* @__PURE__ */ Object.create(null);
17729
17810
  }
17730
17811
  }
17731
- function resolveTypeElements(ctx, node, scope) {
17812
+ function resolveTypeElements(ctx, node, scope, typeParameters) {
17732
17813
  if (node._resolvedElements) {
17733
17814
  return node._resolvedElements;
17734
17815
  }
17735
17816
  return node._resolvedElements = innerResolveTypeElements(
17736
17817
  ctx,
17737
17818
  node,
17738
- node._ownerScope || scope || ctxToScope(ctx)
17819
+ node._ownerScope || scope || ctxToScope(ctx),
17820
+ typeParameters
17739
17821
  );
17740
17822
  }
17741
- function innerResolveTypeElements(ctx, node, scope) {
17823
+ function innerResolveTypeElements(ctx, node, scope, typeParameters) {
17742
17824
  var _a, _b;
17743
17825
  switch (node.type) {
17744
17826
  case "TSTypeLiteral":
17745
- return typeElementsToMap(ctx, node.members, scope);
17827
+ return typeElementsToMap(ctx, node.members, scope, typeParameters);
17746
17828
  case "TSInterfaceDeclaration":
17747
- return resolveInterfaceMembers(ctx, node, scope);
17829
+ return resolveInterfaceMembers(ctx, node, scope, typeParameters);
17748
17830
  case "TSTypeAliasDeclaration":
17749
17831
  case "TSParenthesizedType":
17750
- return resolveTypeElements(ctx, node.typeAnnotation, scope);
17832
+ return resolveTypeElements(
17833
+ ctx,
17834
+ node.typeAnnotation,
17835
+ scope,
17836
+ typeParameters
17837
+ );
17751
17838
  case "TSFunctionType": {
17752
17839
  return { props: {}, calls: [node] };
17753
17840
  }
17754
17841
  case "TSUnionType":
17755
17842
  case "TSIntersectionType":
17756
17843
  return mergeElements(
17757
- node.types.map((t) => resolveTypeElements(ctx, t, scope)),
17844
+ node.types.map((t) => resolveTypeElements(ctx, t, scope, typeParameters)),
17758
17845
  node.type
17759
17846
  );
17760
17847
  case "TSMappedType":
@@ -17771,20 +17858,53 @@ function innerResolveTypeElements(ctx, node, scope) {
17771
17858
  const typeName = getReferenceName(node);
17772
17859
  if ((typeName === "ExtractPropTypes" || typeName === "ExtractPublicPropTypes") && node.typeParameters && ((_a = scope.imports[typeName]) == null ? void 0 : _a.source) === "vue") {
17773
17860
  return resolveExtractPropTypes(
17774
- resolveTypeElements(ctx, node.typeParameters.params[0], scope),
17861
+ resolveTypeElements(
17862
+ ctx,
17863
+ node.typeParameters.params[0],
17864
+ scope,
17865
+ typeParameters
17866
+ ),
17775
17867
  scope
17776
17868
  );
17777
17869
  }
17778
17870
  const resolved = resolveTypeReference(ctx, node, scope);
17779
17871
  if (resolved) {
17780
- return resolveTypeElements(ctx, resolved, resolved._ownerScope);
17872
+ const typeParams = /* @__PURE__ */ Object.create(null);
17873
+ if ((resolved.type === "TSTypeAliasDeclaration" || resolved.type === "TSInterfaceDeclaration") && resolved.typeParameters && node.typeParameters) {
17874
+ resolved.typeParameters.params.forEach((p, i) => {
17875
+ let param = typeParameters && typeParameters[p.name];
17876
+ if (!param)
17877
+ param = node.typeParameters.params[i];
17878
+ typeParams[p.name] = param;
17879
+ });
17880
+ }
17881
+ return resolveTypeElements(
17882
+ ctx,
17883
+ resolved,
17884
+ resolved._ownerScope,
17885
+ typeParams
17886
+ );
17781
17887
  } else {
17782
17888
  if (typeof typeName === "string") {
17889
+ if (typeParameters && typeParameters[typeName]) {
17890
+ return resolveTypeElements(
17891
+ ctx,
17892
+ typeParameters[typeName],
17893
+ scope,
17894
+ typeParameters
17895
+ );
17896
+ }
17783
17897
  if (
17784
17898
  // @ts-ignore
17785
17899
  SupportedBuiltinsSet.has(typeName)
17786
17900
  ) {
17787
- return resolveBuiltin(ctx, node, typeName, scope);
17901
+ return resolveBuiltin(
17902
+ ctx,
17903
+ node,
17904
+ typeName,
17905
+ scope,
17906
+ typeParameters
17907
+ );
17788
17908
  } else if (typeName === "ReturnType" && node.typeParameters) {
17789
17909
  const ret = resolveReturnType(
17790
17910
  ctx,
@@ -17833,10 +17953,14 @@ function innerResolveTypeElements(ctx, node, scope) {
17833
17953
  }
17834
17954
  return ctx.error(`Unresolvable type: ${node.type}`, node, scope);
17835
17955
  }
17836
- function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx)) {
17956
+ function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx), typeParameters) {
17837
17957
  const res = { props: {} };
17838
17958
  for (const e of elements) {
17839
17959
  if (e.type === "TSPropertySignature" || e.type === "TSMethodSignature") {
17960
+ if (typeParameters) {
17961
+ scope = createChildScope(scope);
17962
+ Object.assign(scope.types, typeParameters);
17963
+ }
17840
17964
  e._ownerScope = scope;
17841
17965
  const name = getId(e.key);
17842
17966
  if (name && !e.computed) {
@@ -17899,20 +18023,29 @@ function createProperty(key, typeAnnotation, scope, optional) {
17899
18023
  _ownerScope: scope
17900
18024
  };
17901
18025
  }
17902
- function resolveInterfaceMembers(ctx, node, scope) {
17903
- const base = typeElementsToMap(ctx, node.body.body, node._ownerScope);
18026
+ function resolveInterfaceMembers(ctx, node, scope, typeParameters) {
18027
+ const base = typeElementsToMap(
18028
+ ctx,
18029
+ node.body.body,
18030
+ node._ownerScope,
18031
+ typeParameters
18032
+ );
17904
18033
  if (node.extends) {
17905
18034
  for (const ext of node.extends) {
17906
18035
  if (ext.leadingComments && ext.leadingComments.some((c) => c.value.includes("@vue-ignore"))) {
17907
18036
  continue;
17908
18037
  }
17909
18038
  try {
17910
- const { props } = resolveTypeElements(ctx, ext, scope);
18039
+ const { props, calls } = resolveTypeElements(ctx, ext, scope);
17911
18040
  for (const key in props) {
17912
18041
  if (!shared.hasOwn(base.props, key)) {
17913
18042
  base.props[key] = props[key];
17914
18043
  }
17915
18044
  }
18045
+ if (calls) {
18046
+ ;
18047
+ (base.calls || (base.calls = [])).push(...calls);
18048
+ }
17916
18049
  } catch (e) {
17917
18050
  ctx.error(
17918
18051
  `Failed to resolve extends base type.
@@ -18071,8 +18204,13 @@ const SupportedBuiltinsSet = /* @__PURE__ */ new Set([
18071
18204
  "Pick",
18072
18205
  "Omit"
18073
18206
  ]);
18074
- function resolveBuiltin(ctx, node, name, scope) {
18075
- const t = resolveTypeElements(ctx, node.typeParameters.params[0], scope);
18207
+ function resolveBuiltin(ctx, node, name, scope, typeParameters) {
18208
+ const t = resolveTypeElements(
18209
+ ctx,
18210
+ node.typeParameters.params[0],
18211
+ scope,
18212
+ typeParameters
18213
+ );
18076
18214
  switch (name) {
18077
18215
  case "Partial": {
18078
18216
  const res2 = { props: {}, calls: t.calls };
@@ -18200,7 +18338,21 @@ function resolveGlobalScope(ctx) {
18200
18338
  let ts;
18201
18339
  let loadTS;
18202
18340
  function registerTS(_loadTS) {
18203
- loadTS = _loadTS;
18341
+ loadTS = () => {
18342
+ try {
18343
+ return _loadTS();
18344
+ } catch (err) {
18345
+ if (typeof err.message === "string" && err.message.includes("Cannot find module")) {
18346
+ throw new Error(
18347
+ 'Failed to load TypeScript, which is required for resolving imported types. Please make sure "typescript" is installed as a project dependency.'
18348
+ );
18349
+ } else {
18350
+ throw new Error(
18351
+ "Failed to load TypeScript for resolving imported types."
18352
+ );
18353
+ }
18354
+ }
18355
+ };
18204
18356
  }
18205
18357
  function resolveFS(ctx) {
18206
18358
  if (ctx.fs) {
@@ -18234,7 +18386,12 @@ function resolveTypeFromImport(ctx, node, name, scope) {
18234
18386
  return resolveTypeReference(ctx, node, sourceScope, imported, true);
18235
18387
  }
18236
18388
  function importSourceToScope(ctx, node, scope, source) {
18237
- const fs = resolveFS(ctx);
18389
+ let fs;
18390
+ try {
18391
+ fs = resolveFS(ctx);
18392
+ } catch (err) {
18393
+ return ctx.error(err.message, node, scope);
18394
+ }
18238
18395
  if (!fs) {
18239
18396
  return ctx.error(
18240
18397
  `No fs option provided to \`compileScript\` in non-Node environment. File system access is required for resolving imported types.`,
@@ -18244,7 +18401,11 @@ function importSourceToScope(ctx, node, scope, source) {
18244
18401
  }
18245
18402
  let resolved = scope.resolvedImportSources[source];
18246
18403
  if (!resolved) {
18247
- if (source.startsWith(".")) {
18404
+ if (source.startsWith("..")) {
18405
+ const osSpecificJoinFn = process__namespace.platform === "win32" ? path$3.join : joinPaths;
18406
+ const filename = osSpecificJoinFn(path$3.dirname(scope.filename), source);
18407
+ resolved = resolveExt(filename, fs);
18408
+ } else if (source.startsWith(".")) {
18248
18409
  const filename = joinPaths(path$3.dirname(scope.filename), source);
18249
18410
  resolved = resolveExt(filename, fs);
18250
18411
  } else {
@@ -18325,7 +18486,7 @@ function resolveWithTS(containingFile, source, ts2, fs) {
18325
18486
  }
18326
18487
  tsCompilerOptions = matchedConfig.config.options;
18327
18488
  tsResolveCache = matchedConfig.cache || (matchedConfig.cache = ts2.createModuleResolutionCache(
18328
- process.cwd(),
18489
+ process__namespace.cwd(),
18329
18490
  createGetCanonicalFileName(ts2.sys.useCaseSensitiveFileNames),
18330
18491
  tsCompilerOptions
18331
18492
  ));
@@ -18439,14 +18600,7 @@ function moduleDeclToScope(ctx, node, parentScope) {
18439
18600
  if (node._resolvedChildScope) {
18440
18601
  return node._resolvedChildScope;
18441
18602
  }
18442
- const scope = new TypeScope(
18443
- parentScope.filename,
18444
- parentScope.source,
18445
- parentScope.offset,
18446
- Object.create(parentScope.imports),
18447
- Object.create(parentScope.types),
18448
- Object.create(parentScope.declares)
18449
- );
18603
+ const scope = createChildScope(parentScope);
18450
18604
  if (node.body.type === "TSModuleDeclaration") {
18451
18605
  const decl = node.body;
18452
18606
  decl._ownerScope = scope;
@@ -18457,6 +18611,16 @@ function moduleDeclToScope(ctx, node, parentScope) {
18457
18611
  }
18458
18612
  return node._resolvedChildScope = scope;
18459
18613
  }
18614
+ function createChildScope(parentScope) {
18615
+ return new TypeScope(
18616
+ parentScope.filename,
18617
+ parentScope.source,
18618
+ parentScope.offset,
18619
+ Object.create(parentScope.imports),
18620
+ Object.create(parentScope.types),
18621
+ Object.create(parentScope.declares)
18622
+ );
18623
+ }
18460
18624
  const importExportRE = /^Import|^Export/;
18461
18625
  function recordTypes(ctx, body, scope, asGlobal = false) {
18462
18626
  const { types, declares, exportedTypes, exportedDeclares, imports } = scope;
@@ -18578,7 +18742,7 @@ function recordType(node, types, declares, overwriteId) {
18578
18742
  types[overwriteId || getId(node.id)] = node;
18579
18743
  break;
18580
18744
  case "TSTypeAliasDeclaration":
18581
- types[node.id.name] = node.typeAnnotation;
18745
+ types[node.id.name] = node.typeParameters ? node : node.typeAnnotation;
18582
18746
  break;
18583
18747
  case "TSDeclareFunction":
18584
18748
  if (node.id)
@@ -19111,14 +19275,14 @@ function genRuntimeProps(ctx) {
19111
19275
  const defaults = [];
19112
19276
  for (const key in ctx.propsDestructuredBindings) {
19113
19277
  const d = genDestructuredDefaultValue(ctx, key);
19114
- const finalKey = getEscapedKey(key);
19278
+ const finalKey = getEscapedPropName(key);
19115
19279
  if (d)
19116
19280
  defaults.push(
19117
19281
  `${finalKey}: ${d.valueString}${d.needSkipFactory ? `, __skip_${finalKey}: true` : ``}`
19118
19282
  );
19119
19283
  }
19120
19284
  if (defaults.length) {
19121
- propsDecls = `${ctx.helper(
19285
+ propsDecls = `/*#__PURE__*/${ctx.helper(
19122
19286
  `mergeDefaults`
19123
19287
  )}(${propsDecls}, {
19124
19288
  ${defaults.join(",\n ")}
@@ -19130,7 +19294,9 @@ function genRuntimeProps(ctx) {
19130
19294
  }
19131
19295
  const modelsDecls = genModelProps(ctx);
19132
19296
  if (propsDecls && modelsDecls) {
19133
- return `${ctx.helper("mergeModels")}(${propsDecls}, ${modelsDecls})`;
19297
+ return `/*#__PURE__*/${ctx.helper(
19298
+ "mergeModels"
19299
+ )}(${propsDecls}, ${modelsDecls})`;
19134
19300
  } else {
19135
19301
  return modelsDecls || propsDecls;
19136
19302
  }
@@ -19152,9 +19318,9 @@ function genRuntimePropsFromTypes(ctx) {
19152
19318
  ${propStrings.join(",\n ")}
19153
19319
  }`;
19154
19320
  if (ctx.propsRuntimeDefaults && !hasStaticDefaults) {
19155
- propsDecls = `${ctx.helper("mergeDefaults")}(${propsDecls}, ${ctx.getString(
19156
- ctx.propsRuntimeDefaults
19157
- )})`;
19321
+ propsDecls = `/*#__PURE__*/${ctx.helper(
19322
+ "mergeDefaults"
19323
+ )}(${propsDecls}, ${ctx.getString(ctx.propsRuntimeDefaults)})`;
19158
19324
  }
19159
19325
  return propsDecls;
19160
19326
  }
@@ -19203,7 +19369,7 @@ function genRuntimePropFromType(ctx, { key, required, type, skipCheck }, hasStat
19203
19369
  }
19204
19370
  }
19205
19371
  }
19206
- const finalKey = getEscapedKey(key);
19372
+ const finalKey = getEscapedPropName(key);
19207
19373
  if (!ctx.options.isProd) {
19208
19374
  return `${finalKey}: { ${concatStrings([
19209
19375
  `type: ${toRuntimeTypeString(type)}`,
@@ -19491,7 +19657,9 @@ function genRuntimeEmits(ctx) {
19491
19657
  }
19492
19658
  if (ctx.hasDefineModelCall) {
19493
19659
  let modelEmitsDecl = `[${Object.keys(ctx.modelDecls).map((n) => JSON.stringify(`update:${n}`)).join(", ")}]`;
19494
- emitsDecl = emitsDecl ? `${ctx.helper("mergeModels")}(${emitsDecl}, ${modelEmitsDecl})` : modelEmitsDecl;
19660
+ emitsDecl = emitsDecl ? `/*#__PURE__*/${ctx.helper(
19661
+ "mergeModels"
19662
+ )}(${emitsDecl}, ${modelEmitsDecl})` : modelEmitsDecl;
19495
19663
  }
19496
19664
  return emitsDecl;
19497
19665
  }
@@ -20461,7 +20629,7 @@ function isStaticNode(node) {
20461
20629
  return false;
20462
20630
  }
20463
20631
 
20464
- const version = "3.3.8";
20632
+ const version = "3.3.10";
20465
20633
  const parseCache = parseCache$1;
20466
20634
  const walk = estreeWalker.walk;
20467
20635
 
@@ -455,7 +455,7 @@ interface ResolvedElements {
455
455
  */
456
456
  export declare function resolveTypeElements(ctx: TypeResolveContext, node: Node & MaybeWithScope & {
457
457
  _resolvedElements?: ResolvedElements;
458
- }, scope?: TypeScope): ResolvedElements;
458
+ }, scope?: TypeScope, typeParameters?: Record<string, Node>): ResolvedElements;
459
459
  /**
460
460
  * @private
461
461
  */