@vue/compiler-sfc 3.3.7 → 3.3.9

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,13 @@ 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) {
98
+ return key.replace(cssVarNameEscapeSymbolsRE, (s) => `\\${s}`);
93
99
  }
94
100
 
95
101
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -180,7 +186,7 @@ function genVarName(id, raw, isProd) {
180
186
  if (isProd) {
181
187
  return hash$1(id + raw);
182
188
  } else {
183
- return `${id}-${raw.replace(escapeSymbolsRE, (s) => `\\${s}`)}`;
189
+ return `${id}-${getEscapedCssVarName(raw)}`;
184
190
  }
185
191
  }
186
192
  function normalizeExpression(exp) {
@@ -734,6 +740,9 @@ class LRUCache {
734
740
  if (ttls[index]) {
735
741
  const ttl = ttls[index];
736
742
  const start = starts[index];
743
+ /* c8 ignore next */
744
+ if (!ttl || !start)
745
+ return;
737
746
  status.ttl = ttl;
738
747
  status.start = start;
739
748
  status.now = cachedNow || getNow();
@@ -765,16 +774,16 @@ class LRUCache {
765
774
  }
766
775
  const ttl = ttls[index];
767
776
  const start = starts[index];
768
- if (ttl === 0 || start === 0) {
777
+ if (!ttl || !start) {
769
778
  return Infinity;
770
779
  }
771
780
  const age = (cachedNow || getNow()) - start;
772
781
  return ttl - age;
773
782
  };
774
783
  this.#isStale = index => {
775
- return (ttls[index] !== 0 &&
776
- starts[index] !== 0 &&
777
- (cachedNow || getNow()) - starts[index] > ttls[index]);
784
+ const s = starts[index];
785
+ const t = ttls[index];
786
+ return !!t && !!s && (cachedNow || getNow()) - s > t;
778
787
  };
779
788
  }
780
789
  // conditionally set private methods related to TTL
@@ -1298,12 +1307,13 @@ class LRUCache {
1298
1307
  peek(k, peekOptions = {}) {
1299
1308
  const { allowStale = this.allowStale } = peekOptions;
1300
1309
  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;
1310
+ if (index === undefined ||
1311
+ (!allowStale && this.#isStale(index))) {
1312
+ return;
1306
1313
  }
1314
+ const v = this.#valList[index];
1315
+ // either stale and allowed, or forcing a refresh of non-stale value
1316
+ return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
1307
1317
  }
1308
1318
  #backgroundFetch(k, index, options, context) {
1309
1319
  const v = index === undefined ? undefined : this.#valList[index];
@@ -1639,8 +1649,10 @@ class LRUCache {
1639
1649
  this.#head = this.#next[index];
1640
1650
  }
1641
1651
  else {
1642
- this.#next[this.#prev[index]] = this.#next[index];
1643
- this.#prev[this.#next[index]] = this.#prev[index];
1652
+ const pi = this.#prev[index];
1653
+ this.#next[pi] = this.#next[index];
1654
+ const ni = this.#next[index];
1655
+ this.#prev[ni] = this.#prev[index];
1644
1656
  }
1645
1657
  this.#size--;
1646
1658
  this.#free.push(index);
@@ -1734,9 +1746,8 @@ function resolveTemplateUsageCheckString(sfc) {
1734
1746
  code += `,v${shared.capitalize(shared.camelize(prop.name))}`;
1735
1747
  }
1736
1748
  if (prop.arg && !prop.arg.isStatic) {
1737
- code += `,${processExp(
1738
- prop.arg.content,
1739
- prop.name
1749
+ code += `,${stripStrings(
1750
+ prop.arg.content
1740
1751
  )}`;
1741
1752
  }
1742
1753
  if (prop.exp) {
@@ -1762,7 +1773,6 @@ function resolveTemplateUsageCheckString(sfc) {
1762
1773
  templateUsageCheckCache.set(content, code);
1763
1774
  return code;
1764
1775
  }
1765
- const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
1766
1776
  function processExp(exp, dir) {
1767
1777
  if (/ as\s+\w|<.*>|:/.test(exp)) {
1768
1778
  if (dir === "slot") {
@@ -1770,7 +1780,7 @@ function processExp(exp, dir) {
1770
1780
  } else if (dir === "on") {
1771
1781
  exp = `()=>{return ${exp}}`;
1772
1782
  } else if (dir === "for") {
1773
- const inMatch = exp.match(forAliasRE);
1783
+ const inMatch = exp.match(CompilerDOM.forAliasRE);
1774
1784
  if (inMatch) {
1775
1785
  let [, LHS, RHS] = inMatch;
1776
1786
  LHS = LHS.trim().replace(/^\(|\)$/g, "");
@@ -1798,7 +1808,7 @@ function stripTemplateString(str) {
1798
1808
  }
1799
1809
 
1800
1810
  const DEFAULT_FILENAME = "anonymous.vue";
1801
- const parseCache = createCache();
1811
+ const parseCache$1 = createCache();
1802
1812
  function parse$2(source, {
1803
1813
  sourceMap = true,
1804
1814
  filename = DEFAULT_FILENAME,
@@ -1808,7 +1818,7 @@ function parse$2(source, {
1808
1818
  compiler = CompilerDOM__namespace
1809
1819
  } = {}) {
1810
1820
  const sourceKey = source + sourceMap + filename + sourceRoot + pad + compiler.parse;
1811
- const cache = parseCache.get(sourceKey);
1821
+ const cache = parseCache$1.get(sourceKey);
1812
1822
  if (cache) {
1813
1823
  return cache;
1814
1824
  }
@@ -1951,7 +1961,7 @@ function parse$2(source, {
1951
1961
  descriptor,
1952
1962
  errors
1953
1963
  };
1954
- parseCache.set(sourceKey, result);
1964
+ parseCache$1.set(sourceKey, result);
1955
1965
  return result;
1956
1966
  }
1957
1967
  function createDuplicateBlockError(node, isScriptSetup = false) {
@@ -7902,6 +7912,10 @@ function rewriteSelector(id, selector, selectorRoot, slotted = false) {
7902
7912
  if (n.type !== "pseudo" && n.type !== "combinator") {
7903
7913
  node = n;
7904
7914
  }
7915
+ if (n.type === "pseudo" && (n.value === ":is" || n.value === ":where")) {
7916
+ rewriteSelector(id, n.nodes[0], selectorRoot, slotted);
7917
+ shouldInject = false;
7918
+ }
7905
7919
  });
7906
7920
  if (node) {
7907
7921
  node.spaces.after = "";
@@ -15674,7 +15688,7 @@ function resolveParserPlugins(lang, userPlugins, dts = false) {
15674
15688
  }
15675
15689
  if (lang === "ts" || lang === "tsx") {
15676
15690
  plugins.push(["typescript", { dts }]);
15677
- if (!plugins.includes("decorators")) {
15691
+ if (!userPlugins || !userPlugins.includes("decorators")) {
15678
15692
  plugins.push("decorators-legacy");
15679
15693
  }
15680
15694
  }
@@ -17908,12 +17922,16 @@ function resolveInterfaceMembers(ctx, node, scope) {
17908
17922
  continue;
17909
17923
  }
17910
17924
  try {
17911
- const { props } = resolveTypeElements(ctx, ext, scope);
17925
+ const { props, calls } = resolveTypeElements(ctx, ext, scope);
17912
17926
  for (const key in props) {
17913
17927
  if (!shared.hasOwn(base.props, key)) {
17914
17928
  base.props[key] = props[key];
17915
17929
  }
17916
17930
  }
17931
+ if (calls) {
17932
+ ;
17933
+ (base.calls || (base.calls = [])).push(...calls);
17934
+ }
17917
17935
  } catch (e) {
17918
17936
  ctx.error(
17919
17937
  `Failed to resolve extends base type.
@@ -18245,7 +18263,11 @@ function importSourceToScope(ctx, node, scope, source) {
18245
18263
  }
18246
18264
  let resolved = scope.resolvedImportSources[source];
18247
18265
  if (!resolved) {
18248
- if (source.startsWith(".")) {
18266
+ if (source.startsWith("..")) {
18267
+ const osSpecificJoinFn = process__namespace.platform === "win32" ? path$3.join : joinPaths;
18268
+ const filename = osSpecificJoinFn(path$3.dirname(scope.filename), source);
18269
+ resolved = resolveExt(filename, fs);
18270
+ } else if (source.startsWith(".")) {
18249
18271
  const filename = joinPaths(path$3.dirname(scope.filename), source);
18250
18272
  resolved = resolveExt(filename, fs);
18251
18273
  } else {
@@ -18326,7 +18348,7 @@ function resolveWithTS(containingFile, source, ts2, fs) {
18326
18348
  }
18327
18349
  tsCompilerOptions = matchedConfig.config.options;
18328
18350
  tsResolveCache = matchedConfig.cache || (matchedConfig.cache = ts2.createModuleResolutionCache(
18329
- process.cwd(),
18351
+ process__namespace.cwd(),
18330
18352
  createGetCanonicalFileName(ts2.sys.useCaseSensitiveFileNames),
18331
18353
  tsCompilerOptions
18332
18354
  ));
@@ -18715,6 +18737,7 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
18715
18737
  case "WeakMap":
18716
18738
  case "Date":
18717
18739
  case "Promise":
18740
+ case "Error":
18718
18741
  return [node.typeName.name];
18719
18742
  case "Partial":
18720
18743
  case "Required":
@@ -19111,7 +19134,7 @@ function genRuntimeProps(ctx) {
19111
19134
  const defaults = [];
19112
19135
  for (const key in ctx.propsDestructuredBindings) {
19113
19136
  const d = genDestructuredDefaultValue(ctx, key);
19114
- const finalKey = getEscapedKey(key);
19137
+ const finalKey = getEscapedPropName(key);
19115
19138
  if (d)
19116
19139
  defaults.push(
19117
19140
  `${finalKey}: ${d.valueString}${d.needSkipFactory ? `, __skip_${finalKey}: true` : ``}`
@@ -19203,7 +19226,7 @@ function genRuntimePropFromType(ctx, { key, required, type, skipCheck }, hasStat
19203
19226
  }
19204
19227
  }
19205
19228
  }
19206
- const finalKey = getEscapedKey(key);
19229
+ const finalKey = getEscapedPropName(key);
19207
19230
  if (!ctx.options.isProd) {
19208
19231
  return `${finalKey}: { ${concatStrings([
19209
19232
  `type: ${toRuntimeTypeString(type)}`,
@@ -20461,7 +20484,8 @@ function isStaticNode(node) {
20461
20484
  return false;
20462
20485
  }
20463
20486
 
20464
- const version = "3.3.7";
20487
+ const version = "3.3.9";
20488
+ const parseCache = parseCache$1;
20465
20489
  const walk = estreeWalker.walk;
20466
20490
 
20467
20491
  exports.babelParse = parser$2.parse;
@@ -1,4 +1,3 @@
1
- import * as lru_cache_min from 'lru-cache/min';
2
1
  import * as _babel_types from '@babel/types';
3
2
  import { Statement, Expression, TSType, Program, CallExpression, Node, ObjectPattern, TSModuleDeclaration, TSPropertySignature, TSMethodSignature, TSCallSignatureDeclaration, TSFunctionType } from '@babel/types';
4
3
  import { CompilerOptions, CodegenResult, ParserOptions, RootNode, CompilerError, SourceLocation, ElementNode, BindingMetadata as BindingMetadata$1 } from '@vue/compiler-core';
@@ -230,7 +229,6 @@ export interface SFCParseResult {
230
229
  descriptor: SFCDescriptor;
231
230
  errors: (CompilerError | SyntaxError)[];
232
231
  }
233
- export declare const parseCache: Map<string, SFCParseResult> | lru_cache_min.LRUCache<string, SFCParseResult, unknown>;
234
232
  export declare function parse(source: string, { sourceMap, filename, sourceRoot, pad, ignoreEmpty, compiler }?: SFCParseOptions): SFCParseResult;
235
233
 
236
234
  type PreprocessLang = 'less' | 'sass' | 'scss' | 'styl' | 'stylus';
@@ -470,5 +468,7 @@ export declare function inferRuntimeType(ctx: TypeResolveContext, node: Node & M
470
468
 
471
469
  export declare const version: string;
472
470
 
471
+ export declare const parseCache: Map<string, SFCParseResult>;
472
+
473
473
  export declare const walk: any;
474
474
 
@@ -66,7 +66,7 @@ const PatchFlagNames = {
66
66
  [4]: `STYLE`,
67
67
  [8]: `PROPS`,
68
68
  [16]: `FULL_PROPS`,
69
- [32]: `HYDRATE_EVENTS`,
69
+ [32]: `NEED_HYDRATION`,
70
70
  [64]: `STABLE_FRAGMENT`,
71
71
  [128]: `KEYED_FRAGMENT`,
72
72
  [256]: `UNKEYED_FRAGMENT`,
@@ -4162,11 +4162,6 @@ function newAsyncArrowScope() {
4162
4162
  function newExpressionScope() {
4163
4163
  return new ExpressionScope();
4164
4164
  }
4165
- const PARAM = 0b0000,
4166
- PARAM_YIELD = 0b0001,
4167
- PARAM_AWAIT = 0b0010,
4168
- PARAM_RETURN = 0b0100,
4169
- PARAM_IN = 0b1000;
4170
4165
  class ProductionParameterHandler {
4171
4166
  constructor() {
4172
4167
  this.stacks = [];
@@ -4181,20 +4176,20 @@ class ProductionParameterHandler {
4181
4176
  return this.stacks[this.stacks.length - 1];
4182
4177
  }
4183
4178
  get hasAwait() {
4184
- return (this.currentFlags() & PARAM_AWAIT) > 0;
4179
+ return (this.currentFlags() & 2) > 0;
4185
4180
  }
4186
4181
  get hasYield() {
4187
- return (this.currentFlags() & PARAM_YIELD) > 0;
4182
+ return (this.currentFlags() & 1) > 0;
4188
4183
  }
4189
4184
  get hasReturn() {
4190
- return (this.currentFlags() & PARAM_RETURN) > 0;
4185
+ return (this.currentFlags() & 4) > 0;
4191
4186
  }
4192
4187
  get hasIn() {
4193
- return (this.currentFlags() & PARAM_IN) > 0;
4188
+ return (this.currentFlags() & 8) > 0;
4194
4189
  }
4195
4190
  }
4196
4191
  function functionFlags(isAsync, isGenerator) {
4197
- return (isAsync ? PARAM_AWAIT : 0) | (isGenerator ? PARAM_YIELD : 0);
4192
+ return (isAsync ? 2 : 0) | (isGenerator ? 1 : 0);
4198
4193
  }
4199
4194
  class UtilParser extends Tokenizer {
4200
4195
  addExtra(node, key, value, enumerable = true) {
@@ -4391,9 +4386,9 @@ class UtilParser extends Tokenizer {
4391
4386
  };
4392
4387
  }
4393
4388
  enterInitialScopes() {
4394
- let paramFlags = PARAM;
4389
+ let paramFlags = 0;
4395
4390
  if (this.inModule) {
4396
- paramFlags |= PARAM_AWAIT;
4391
+ paramFlags |= 2;
4397
4392
  }
4398
4393
  this.scope.enter(1);
4399
4394
  this.prodParam.enter(paramFlags);
@@ -9436,7 +9431,7 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
9436
9431
  node.body = inner;
9437
9432
  } else {
9438
9433
  this.scope.enter(256);
9439
- this.prodParam.enter(PARAM);
9434
+ this.prodParam.enter(0);
9440
9435
  node.body = this.tsParseModuleBlock();
9441
9436
  this.prodParam.exit();
9442
9437
  this.scope.exit();
@@ -9454,7 +9449,7 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
9454
9449
  }
9455
9450
  if (this.match(5)) {
9456
9451
  this.scope.enter(256);
9457
- this.prodParam.enter(PARAM);
9452
+ this.prodParam.enter(0);
9458
9453
  node.body = this.tsParseModuleBlock();
9459
9454
  this.prodParam.exit();
9460
9455
  this.scope.exit();
@@ -9581,7 +9576,7 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
9581
9576
  case "global":
9582
9577
  if (this.match(5)) {
9583
9578
  this.scope.enter(256);
9584
- this.prodParam.enter(PARAM);
9579
+ this.prodParam.enter(0);
9585
9580
  const mod = node;
9586
9581
  mod.global = true;
9587
9582
  mod.id = expr;
@@ -12012,7 +12007,7 @@ class ExpressionParser extends LValParser {
12012
12007
  const oldLabels = this.state.labels;
12013
12008
  this.state.labels = [];
12014
12009
  if (isAsync) {
12015
- this.prodParam.enter(PARAM_AWAIT);
12010
+ this.prodParam.enter(2);
12016
12011
  node.body = this.parseBlock();
12017
12012
  this.prodParam.exit();
12018
12013
  } else {
@@ -12576,7 +12571,7 @@ class ExpressionParser extends LValParser {
12576
12571
  this.scope.enter(2 | 4);
12577
12572
  let flags = functionFlags(isAsync, false);
12578
12573
  if (!this.match(5) && this.prodParam.hasIn) {
12579
- flags |= PARAM_IN;
12574
+ flags |= 8;
12580
12575
  }
12581
12576
  this.prodParam.enter(flags);
12582
12577
  this.initFunction(node, isAsync);
@@ -12610,7 +12605,7 @@ class ExpressionParser extends LValParser {
12610
12605
  const oldStrict = this.state.strict;
12611
12606
  const oldLabels = this.state.labels;
12612
12607
  this.state.labels = [];
12613
- this.prodParam.enter(this.prodParam.currentFlags() | PARAM_RETURN);
12608
+ this.prodParam.enter(this.prodParam.currentFlags() | 4);
12614
12609
  node.body = this.parseBlock(true, false, hasStrictModeDirective => {
12615
12610
  const nonSimple = !this.isSimpleParamList(node.params);
12616
12611
  if (hasStrictModeDirective && nonSimple) {
@@ -12951,9 +12946,9 @@ class ExpressionParser extends LValParser {
12951
12946
  }
12952
12947
  allowInAnd(callback) {
12953
12948
  const flags = this.prodParam.currentFlags();
12954
- const prodParamToSet = PARAM_IN & ~flags;
12949
+ const prodParamToSet = 8 & ~flags;
12955
12950
  if (prodParamToSet) {
12956
- this.prodParam.enter(flags | PARAM_IN);
12951
+ this.prodParam.enter(flags | 8);
12957
12952
  try {
12958
12953
  return callback();
12959
12954
  } finally {
@@ -12964,9 +12959,9 @@ class ExpressionParser extends LValParser {
12964
12959
  }
12965
12960
  disallowInAnd(callback) {
12966
12961
  const flags = this.prodParam.currentFlags();
12967
- const prodParamToClear = PARAM_IN & flags;
12962
+ const prodParamToClear = 8 & flags;
12968
12963
  if (prodParamToClear) {
12969
- this.prodParam.enter(flags & ~PARAM_IN);
12964
+ this.prodParam.enter(flags & ~8);
12970
12965
  try {
12971
12966
  return callback();
12972
12967
  } finally {
@@ -13881,7 +13876,7 @@ class StatementParser extends ExpressionParser {
13881
13876
  }
13882
13877
  body.push(stmt);
13883
13878
  }
13884
- afterBlockParse == null ? void 0 : afterBlockParse.call(this, hasStrictModeDirective);
13879
+ afterBlockParse == null || afterBlockParse.call(this, hasStrictModeDirective);
13885
13880
  if (!oldStrict) {
13886
13881
  this.setStrict(false);
13887
13882
  }
@@ -14257,7 +14252,7 @@ class StatementParser extends ExpressionParser {
14257
14252
  this.scope.enter(64 | 128 | 16);
14258
14253
  const oldLabels = this.state.labels;
14259
14254
  this.state.labels = [];
14260
- this.prodParam.enter(PARAM);
14255
+ this.prodParam.enter(0);
14261
14256
  const body = member.body = [];
14262
14257
  this.parseBlockOrModuleBlockBody(body, undefined, false, 8);
14263
14258
  this.prodParam.exit();
@@ -14329,7 +14324,7 @@ class StatementParser extends ExpressionParser {
14329
14324
  parseInitializer(node) {
14330
14325
  this.scope.enter(64 | 16);
14331
14326
  this.expressionScope.enter(newExpressionScope());
14332
- this.prodParam.enter(PARAM);
14327
+ this.prodParam.enter(0);
14333
14328
  node.value = this.eat(29) ? this.parseMaybeAssignAllowIn() : null;
14334
14329
  this.expressionScope.exit();
14335
14330
  this.prodParam.exit();
@@ -15450,6 +15445,7 @@ function getMemoedVNodeCall(node) {
15450
15445
  return node;
15451
15446
  }
15452
15447
  }
15448
+ const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
15453
15449
 
15454
15450
  const deprecationData = {
15455
15451
  ["COMPILER_IS_ON_ELEMENT"]: {
@@ -21124,6 +21120,15 @@ function walkBlockDeclarations(block, onIdent) {
21124
21120
  if (stmt.declare || !stmt.id)
21125
21121
  continue;
21126
21122
  onIdent(stmt.id);
21123
+ } else if (stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement") {
21124
+ const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
21125
+ if (variable && variable.type === "VariableDeclaration") {
21126
+ for (const decl of variable.declarations) {
21127
+ for (const id of extractIdentifiers(decl.id)) {
21128
+ onIdent(id);
21129
+ }
21130
+ }
21131
+ }
21127
21132
  }
21128
21133
  }
21129
21134
  }
@@ -21376,8 +21381,8 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
21376
21381
  const isScopeVarReference = context.identifiers[rawExp];
21377
21382
  const isAllowedGlobal = isGloballyAllowed(rawExp);
21378
21383
  const isLiteral = isLiteralWhitelisted(rawExp);
21379
- if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) {
21380
- if (isConst(bindingMetadata[node.content])) {
21384
+ if (!asParams && !isScopeVarReference && !isLiteral && (!isAllowedGlobal || bindingMetadata[rawExp])) {
21385
+ if (isConst(bindingMetadata[rawExp])) {
21381
21386
  node.constType = 1;
21382
21387
  }
21383
21388
  node.content = rewriteIdentifier(rawExp);
@@ -21911,13 +21916,12 @@ function processFor(node, dir, context, processCodegen) {
21911
21916
  onExit();
21912
21917
  };
21913
21918
  }
21914
- const forAliasRE$1 = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
21915
21919
  const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
21916
21920
  const stripParensRE = /^\(|\)$/g;
21917
21921
  function parseForExpression(input, context) {
21918
21922
  const loc = input.loc;
21919
21923
  const exp = input.content;
21920
- const inMatch = exp.match(forAliasRE$1);
21924
+ const inMatch = exp.match(forAliasRE);
21921
21925
  if (!inMatch)
21922
21926
  return;
21923
21927
  const [, LHS, RHS] = inMatch;
@@ -22584,7 +22588,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
22584
22588
  )
22585
22589
  );
22586
22590
  } else {
22587
- const { name, arg, exp, loc } = prop;
22591
+ const { name, arg, exp, loc, modifiers } = prop;
22588
22592
  const isVBind = name === "bind";
22589
22593
  const isVOn = name === "on";
22590
22594
  if (name === "slot") {
@@ -22644,6 +22648,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
22644
22648
  }
22645
22649
  continue;
22646
22650
  }
22651
+ if (isVBind && modifiers.includes("prop")) {
22652
+ patchFlag |= 32;
22653
+ }
22647
22654
  const directiveTransform = context.directiveTransforms[name];
22648
22655
  if (directiveTransform) {
22649
22656
  const { props: props2, needRuntime } = directiveTransform(prop, node, context);
@@ -25906,8 +25913,8 @@ const transformModel = (dir, node, context) => {
25906
25913
  );
25907
25914
  }
25908
25915
  function checkDuplicatedValue() {
25909
- const value = findProp(node, "value");
25910
- if (value) {
25916
+ const value = findDir(node, "bind");
25917
+ if (value && isStaticArgOf(value.arg, "value")) {
25911
25918
  context.onError(
25912
25919
  createDOMCompilerError(
25913
25920
  60,
@@ -26477,6 +26484,7 @@ var CompilerDOM = /*#__PURE__*/Object.freeze({
26477
26484
  extractIdentifiers: extractIdentifiers,
26478
26485
  findDir: findDir,
26479
26486
  findProp: findProp,
26487
+ forAliasRE: forAliasRE,
26480
26488
  generate: generate,
26481
26489
  generateCodeFrame: generateCodeFrame,
26482
26490
  getBaseTransformPreset: getBaseTransformPreset,
@@ -26829,9 +26837,13 @@ function normalizePath(p) {
26829
26837
  return normalize(p.replace(windowsSlashRE, "/"));
26830
26838
  }
26831
26839
  const joinPaths = (path.posix || path).join;
26832
- const escapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
26833
- function getEscapedKey(key) {
26834
- return escapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
26840
+ const propNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~\-]/;
26841
+ function getEscapedPropName(key) {
26842
+ return propNameEscapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
26843
+ }
26844
+ const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
26845
+ function getEscapedCssVarName(key) {
26846
+ return key.replace(cssVarNameEscapeSymbolsRE, (s) => `\\${s}`);
26835
26847
  }
26836
26848
 
26837
26849
  function pad$1 (hash, len) {
@@ -26916,7 +26928,7 @@ function genVarName(id, raw, isProd) {
26916
26928
  if (isProd) {
26917
26929
  return hash(id + raw);
26918
26930
  } else {
26919
- return `${id}-${raw.replace(escapeSymbolsRE, (s) => `\\${s}`)}`;
26931
+ return `${id}-${getEscapedCssVarName(raw)}`;
26920
26932
  }
26921
26933
  }
26922
26934
  function normalizeExpression(exp) {
@@ -27299,9 +27311,8 @@ function resolveTemplateUsageCheckString(sfc) {
27299
27311
  code += `,v${capitalize$1(camelize(prop.name))}`;
27300
27312
  }
27301
27313
  if (prop.arg && !prop.arg.isStatic) {
27302
- code += `,${processExp(
27303
- prop.arg.content,
27304
- prop.name
27314
+ code += `,${stripStrings(
27315
+ prop.arg.content
27305
27316
  )}`;
27306
27317
  }
27307
27318
  if (prop.exp) {
@@ -27327,7 +27338,6 @@ function resolveTemplateUsageCheckString(sfc) {
27327
27338
  templateUsageCheckCache.set(content, code);
27328
27339
  return code;
27329
27340
  }
27330
- const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
27331
27341
  function processExp(exp, dir) {
27332
27342
  if (/ as\s+\w|<.*>|:/.test(exp)) {
27333
27343
  if (dir === "slot") {
@@ -27379,7 +27389,7 @@ var __spreadValues$a = (a, b) => {
27379
27389
  return a;
27380
27390
  };
27381
27391
  const DEFAULT_FILENAME = "anonymous.vue";
27382
- const parseCache = createCache();
27392
+ const parseCache$1 = createCache();
27383
27393
  function parse$7(source, {
27384
27394
  sourceMap = true,
27385
27395
  filename = DEFAULT_FILENAME,
@@ -27389,7 +27399,7 @@ function parse$7(source, {
27389
27399
  compiler = CompilerDOM
27390
27400
  } = {}) {
27391
27401
  const sourceKey = source + sourceMap + filename + sourceRoot + pad + compiler.parse;
27392
- const cache = parseCache.get(sourceKey);
27402
+ const cache = parseCache$1.get(sourceKey);
27393
27403
  if (cache) {
27394
27404
  return cache;
27395
27405
  }
@@ -27532,7 +27542,7 @@ function parse$7(source, {
27532
27542
  descriptor,
27533
27543
  errors
27534
27544
  };
27535
- parseCache.set(sourceKey, result);
27545
+ parseCache$1.set(sourceKey, result);
27536
27546
  return result;
27537
27547
  }
27538
27548
  function createDuplicateBlockError(node, isScriptSetup = false) {
@@ -33190,7 +33200,7 @@ function compile(template, options = {}) {
33190
33200
  // reusing core v-bind
33191
33201
  bind: transformBind,
33192
33202
  on: transformOn$1,
33193
- // model and show has dedicated SSR handling
33203
+ // model and show have dedicated SSR handling
33194
33204
  model: ssrTransformModel,
33195
33205
  show: ssrTransformShow,
33196
33206
  // the following are ignored during SSR
@@ -41387,6 +41397,10 @@ function rewriteSelector(id, selector, selectorRoot, slotted = false) {
41387
41397
  if (n.type !== "pseudo" && n.type !== "combinator") {
41388
41398
  node = n;
41389
41399
  }
41400
+ if (n.type === "pseudo" && (n.value === ":is" || n.value === ":where")) {
41401
+ rewriteSelector(id, n.nodes[0], selectorRoot, slotted);
41402
+ shouldInject = false;
41403
+ }
41390
41404
  });
41391
41405
  if (node) {
41392
41406
  node.spaces.after = "";
@@ -47074,7 +47088,7 @@ function resolveParserPlugins(lang, userPlugins, dts = false) {
47074
47088
  }
47075
47089
  if (lang === "ts" || lang === "tsx") {
47076
47090
  plugins.push(["typescript", { dts }]);
47077
- if (!plugins.includes("decorators")) {
47091
+ if (!userPlugins || !userPlugins.includes("decorators")) {
47078
47092
  plugins.push("decorators-legacy");
47079
47093
  }
47080
47094
  }
@@ -47295,12 +47309,16 @@ function resolveInterfaceMembers(ctx, node, scope) {
47295
47309
  continue;
47296
47310
  }
47297
47311
  try {
47298
- const { props } = resolveTypeElements(ctx, ext, scope);
47312
+ const { props, calls } = resolveTypeElements(ctx, ext, scope);
47299
47313
  for (const key in props) {
47300
47314
  if (!hasOwn(base.props, key)) {
47301
47315
  base.props[key] = props[key];
47302
47316
  }
47303
47317
  }
47318
+ if (calls) {
47319
+ ;
47320
+ (base.calls || (base.calls = [])).push(...calls);
47321
+ }
47304
47322
  } catch (e) {
47305
47323
  ctx.error(
47306
47324
  `Failed to resolve extends base type.
@@ -47631,7 +47649,11 @@ function importSourceToScope(ctx, node, scope, source) {
47631
47649
  }
47632
47650
  let resolved = scope.resolvedImportSources[source];
47633
47651
  if (!resolved) {
47634
- if (source.startsWith(".")) {
47652
+ if (source.startsWith("..")) {
47653
+ const osSpecificJoinFn = joinPaths;
47654
+ const filename = osSpecificJoinFn(dirname$2(scope.filename), source);
47655
+ resolved = resolveExt(filename, fs);
47656
+ } else if (source.startsWith(".")) {
47635
47657
  const filename = joinPaths(dirname$2(scope.filename), source);
47636
47658
  resolved = resolveExt(filename, fs);
47637
47659
  } else {
@@ -48017,6 +48039,7 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
48017
48039
  case "WeakMap":
48018
48040
  case "Date":
48019
48041
  case "Promise":
48042
+ case "Error":
48020
48043
  return [node.typeName.name];
48021
48044
  case "Partial":
48022
48045
  case "Required":
@@ -48413,7 +48436,7 @@ function genRuntimeProps(ctx) {
48413
48436
  const defaults = [];
48414
48437
  for (const key in ctx.propsDestructuredBindings) {
48415
48438
  const d = genDestructuredDefaultValue(ctx, key);
48416
- const finalKey = getEscapedKey(key);
48439
+ const finalKey = getEscapedPropName(key);
48417
48440
  if (d)
48418
48441
  defaults.push(
48419
48442
  `${finalKey}: ${d.valueString}${d.needSkipFactory ? `, __skip_${finalKey}: true` : ``}`
@@ -48505,7 +48528,7 @@ function genRuntimePropFromType(ctx, { key, required, type, skipCheck }, hasStat
48505
48528
  }
48506
48529
  }
48507
48530
  }
48508
- const finalKey = getEscapedKey(key);
48531
+ const finalKey = getEscapedPropName(key);
48509
48532
  if (!ctx.options.isProd) {
48510
48533
  return `${finalKey}: { ${concatStrings([
48511
48534
  `type: ${toRuntimeTypeString(type)}`,
@@ -49777,7 +49800,8 @@ function isStaticNode(node) {
49777
49800
  return false;
49778
49801
  }
49779
49802
 
49780
- const version = "3.3.7";
49803
+ const version = "3.3.9";
49804
+ const parseCache = parseCache$1;
49781
49805
  const walk = walk$1;
49782
49806
 
49783
49807
  export { MagicString, parse_1$1 as babelParse, compileScript, compileStyle, compileStyleAsync, compileTemplate, extractIdentifiers, generateCodeFrame, inferRuntimeType, invalidateTypeCache, isInDestructureAssignment, isStaticProperty, parse$7 as parse, parseCache, registerTS, resolveTypeElements, rewriteDefault, rewriteDefaultAST, shouldTransform as shouldTransformRef, transform as transformRef, transformAST as transformRefAST, version, walk, walkIdentifiers };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "3.3.7",
3
+ "version": "3.3.9",
4
4
  "description": "@vue/compiler-sfc",
5
5
  "main": "dist/compiler-sfc.cjs.js",
6
6
  "module": "dist/compiler-sfc.esm-browser.js",
@@ -32,27 +32,27 @@
32
32
  },
33
33
  "homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-sfc#readme",
34
34
  "dependencies": {
35
- "@babel/parser": "^7.23.0",
36
- "@vue/compiler-core": "3.3.7",
37
- "@vue/compiler-dom": "3.3.7",
38
- "@vue/compiler-ssr": "3.3.7",
39
- "@vue/reactivity-transform": "3.3.7",
40
- "@vue/shared": "3.3.7",
35
+ "@babel/parser": "^7.23.3",
41
36
  "estree-walker": "^2.0.2",
42
37
  "magic-string": "^0.30.5",
43
38
  "postcss": "^8.4.31",
44
- "source-map-js": "^1.0.2"
39
+ "source-map-js": "^1.0.2",
40
+ "@vue/compiler-core": "3.3.9",
41
+ "@vue/compiler-dom": "3.3.9",
42
+ "@vue/reactivity-transform": "3.3.9",
43
+ "@vue/shared": "3.3.9",
44
+ "@vue/compiler-ssr": "3.3.9"
45
45
  },
46
46
  "devDependencies": {
47
- "@babel/types": "^7.23.0",
47
+ "@babel/types": "^7.23.3",
48
48
  "@vue/consolidate": "^0.17.3",
49
49
  "hash-sum": "^2.0.0",
50
- "lru-cache": "^10.0.1",
50
+ "lru-cache": "^10.0.3",
51
51
  "merge-source-map": "^1.1.0",
52
52
  "minimatch": "^9.0.3",
53
53
  "postcss-modules": "^4.3.1",
54
54
  "postcss-selector-parser": "^6.0.13",
55
55
  "pug": "^3.0.2",
56
- "sass": "^1.69.4"
56
+ "sass": "^1.69.5"
57
57
  }
58
58
  }