@vue/compiler-sfc 3.5.20 → 3.5.22

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-sfc v3.5.20
2
+ * @vue/compiler-sfc v3.5.22
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -140,7 +140,7 @@ function genCssVarsFromList(vars, id, isProd, isSSR = false) {
140
140
  }
141
141
  function genVarName(id, raw, isProd, isSSR = false) {
142
142
  if (isProd) {
143
- return hash(id + raw);
143
+ return hash(id + raw).replace(/^\d/, (r) => `v${r}`);
144
144
  } else {
145
145
  return `${id}-${shared.getEscapedCssVarName(raw, isSSR)}`;
146
146
  }
@@ -2061,7 +2061,7 @@ function isRelativeUrl(url) {
2061
2061
  const firstChar = url.charAt(0);
2062
2062
  return firstChar === "." || firstChar === "~" || firstChar === "@";
2063
2063
  }
2064
- const externalRE = /^(https?:)?\/\//;
2064
+ const externalRE = /^(?:https?:)?\/\//;
2065
2065
  function isExternalUrl(url) {
2066
2066
  return externalRE.test(url);
2067
2067
  }
@@ -7985,8 +7985,8 @@ function requireDist$1 () {
7985
7985
  var distExports = /*@__PURE__*/ requireDist$1();
7986
7986
  var selectorParser = /*@__PURE__*/getDefaultExportFromCjs(distExports);
7987
7987
 
7988
- const animationNameRE = /^(-\w+-)?animation-name$/;
7989
- const animationRE = /^(-\w+-)?animation$/;
7988
+ const animationNameRE = /^(?:-\w+-)?animation-name$/;
7989
+ const animationRE = /^(?:-\w+-)?animation$/;
7990
7990
  const keyframesRE = /^(?:-\w+-)?keyframes$/;
7991
7991
  const scopedPlugin = (id = "") => {
7992
7992
  const keyframes = /* @__PURE__ */ Object.create(null);
@@ -19610,6 +19610,8 @@ const propNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~\-]/;
19610
19610
  function getEscapedPropName(key) {
19611
19611
  return propNameEscapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
19612
19612
  }
19613
+ const isJS = (...langs) => langs.some((lang) => lang === "js" || lang === "jsx");
19614
+ const isTS = (...langs) => langs.some((lang) => lang === "ts" || lang === "tsx");
19613
19615
 
19614
19616
  function analyzeScriptBindings(ast) {
19615
19617
  for (const node of ast) {
@@ -19710,8 +19712,8 @@ class ScriptCompileContext {
19710
19712
  const { script, scriptSetup } = descriptor;
19711
19713
  const scriptLang = script && script.lang;
19712
19714
  const scriptSetupLang = scriptSetup && scriptSetup.lang;
19713
- this.isJS = scriptLang === "js" || scriptLang === "jsx" || scriptSetupLang === "js" || scriptSetupLang === "jsx";
19714
- this.isTS = scriptLang === "ts" || scriptLang === "tsx" || scriptSetupLang === "ts" || scriptSetupLang === "tsx";
19715
+ this.isJS = isJS(scriptLang, scriptSetupLang);
19716
+ this.isTS = isTS(scriptLang, scriptSetupLang);
19715
19717
  const customElement = options.customElement;
19716
19718
  const filename = this.descriptor.filename;
19717
19719
  if (customElement) {
@@ -19890,9 +19892,6 @@ const normalScriptDefaultVar = `__default__`;
19890
19892
  function processNormalScript(ctx, scopeId) {
19891
19893
  var _a;
19892
19894
  const script = ctx.descriptor.script;
19893
- if (script.lang && !ctx.isJS && !ctx.isTS) {
19894
- return script;
19895
- }
19896
19895
  try {
19897
19896
  let content = script.content;
19898
19897
  let map = script.map;
@@ -22651,14 +22650,19 @@ function resolveWithTS(containingFile, source, ts2, fs) {
22651
22650
  if (configs.length === 1) {
22652
22651
  matchedConfig = configs[0];
22653
22652
  } else {
22653
+ const [major, minor] = ts2.versionMajorMinor.split(".").map(Number);
22654
+ const getPattern = (base, p) => {
22655
+ const supportsConfigDir = major > 5 || major === 5 && minor >= 5;
22656
+ return p.startsWith("${configDir}") && supportsConfigDir ? normalizePath(p.replace("${configDir}", path$1.dirname(configPath))) : joinPaths(base, p);
22657
+ };
22654
22658
  for (const c of configs) {
22655
22659
  const base = normalizePath(
22656
22660
  c.config.options.pathsBasePath || path$1.dirname(c.config.options.configFilePath)
22657
22661
  );
22658
22662
  const included = (_a = c.config.raw) == null ? void 0 : _a.include;
22659
22663
  const excluded = (_b = c.config.raw) == null ? void 0 : _b.exclude;
22660
- if (!included && (!base || containingFile.startsWith(base)) || (included == null ? void 0 : included.some((p) => minimatch(containingFile, joinPaths(base, p))))) {
22661
- if (excluded && excluded.some((p) => minimatch(containingFile, joinPaths(base, p)))) {
22664
+ if (!included && (!base || containingFile.startsWith(base)) || (included == null ? void 0 : included.some((p) => minimatch(containingFile, getPattern(base, p))))) {
22665
+ if (excluded && excluded.some((p) => minimatch(containingFile, getPattern(base, p)))) {
22662
22666
  continue;
22663
22667
  }
22664
22668
  matchedConfig = c;
@@ -22832,7 +22836,11 @@ function recordTypes(ctx, body, scope, asGlobal = false) {
22832
22836
  }
22833
22837
  } else if (stmt.type === "TSModuleDeclaration" && stmt.global) {
22834
22838
  for (const s of stmt.body.body) {
22835
- recordType(s, types, declares);
22839
+ if (s.type === "ExportNamedDeclaration" && s.declaration) {
22840
+ recordType(s.declaration, types, declares);
22841
+ } else {
22842
+ recordType(s, types, declares);
22843
+ }
22836
22844
  }
22837
22845
  }
22838
22846
  } else {
@@ -23007,6 +23015,9 @@ function recordImport(node, imports) {
23007
23015
  }
23008
23016
  }
23009
23017
  function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx), isKeyOf = false, typeParameters) {
23018
+ if (node.leadingComments && node.leadingComments.some((c) => c.value.includes("@vue-ignore"))) {
23019
+ return [UNKNOWN_TYPE];
23020
+ }
23010
23021
  try {
23011
23022
  switch (node.type) {
23012
23023
  case "TSStringKeyword":
@@ -23243,6 +23254,24 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
23243
23254
  typeParameters
23244
23255
  ).filter((t) => t !== UNKNOWN_TYPE);
23245
23256
  }
23257
+ case "TSMappedType": {
23258
+ const { typeAnnotation, typeParameter } = node;
23259
+ if (typeAnnotation && typeAnnotation.type === "TSIndexedAccessType" && typeParameter && typeParameter.constraint && typeParameters) {
23260
+ const constraint = typeParameter.constraint;
23261
+ if (constraint.type === "TSTypeOperator" && constraint.operator === "keyof" && constraint.typeAnnotation && constraint.typeAnnotation.type === "TSTypeReference" && constraint.typeAnnotation.typeName.type === "Identifier") {
23262
+ const typeName = constraint.typeAnnotation.typeName.name;
23263
+ const index = typeAnnotation.indexType;
23264
+ const obj = typeAnnotation.objectType;
23265
+ if (obj && obj.type === "TSTypeReference" && obj.typeName.type === "Identifier" && obj.typeName.name === typeName && index && index.type === "TSTypeReference" && index.typeName.type === "Identifier" && index.typeName.name === typeParameter.name) {
23266
+ const targetType = typeParameters[typeName];
23267
+ if (targetType) {
23268
+ return inferRuntimeType(ctx, targetType, scope);
23269
+ }
23270
+ }
23271
+ }
23272
+ }
23273
+ return [UNKNOWN_TYPE];
23274
+ }
23246
23275
  case "TSEnumDeclaration":
23247
23276
  return inferEnumType(node);
23248
23277
  case "TSSymbolKeyword":
@@ -24195,21 +24224,26 @@ Upgrade your vite or vue-loader version for compatibility with the latest experi
24195
24224
  const scopeId = options.id ? options.id.replace(/^data-v-/, "") : "";
24196
24225
  const scriptLang = script && script.lang;
24197
24226
  const scriptSetupLang = scriptSetup && scriptSetup.lang;
24227
+ const isJSOrTS = isJS(scriptLang, scriptSetupLang) || isTS(scriptLang, scriptSetupLang);
24198
24228
  if (script && scriptSetup && scriptLang !== scriptSetupLang) {
24199
24229
  throw new Error(
24200
24230
  `[@vue/compiler-sfc] <script> and <script setup> must have the same language type.`
24201
24231
  );
24202
24232
  }
24203
- const ctx = new ScriptCompileContext(sfc, options);
24204
24233
  if (!scriptSetup) {
24205
24234
  if (!script) {
24206
24235
  throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
24207
24236
  }
24208
- return processNormalScript(ctx, scopeId);
24237
+ if (script.lang && !isJSOrTS) {
24238
+ return script;
24239
+ }
24240
+ const ctx2 = new ScriptCompileContext(sfc, options);
24241
+ return processNormalScript(ctx2, scopeId);
24209
24242
  }
24210
- if (scriptSetupLang && !ctx.isJS && !ctx.isTS) {
24243
+ if (scriptSetupLang && !isJSOrTS) {
24211
24244
  return scriptSetup;
24212
24245
  }
24246
+ const ctx = new ScriptCompileContext(sfc, options);
24213
24247
  const scriptBindings = /* @__PURE__ */ Object.create(null);
24214
24248
  const setupBindings = /* @__PURE__ */ Object.create(null);
24215
24249
  let defaultExport;
@@ -24640,6 +24674,7 @@ let __temp${any}, __restore${any}
24640
24674
  }
24641
24675
  let templateMap;
24642
24676
  let returned;
24677
+ const propsDecl = genRuntimeProps(ctx);
24643
24678
  if (!options.inlineTemplate || !sfc.template && ctx.hasDefaultExportRender) {
24644
24679
  const allBindings = {
24645
24680
  ...scriptBindings,
@@ -24746,7 +24781,6 @@ return ${returned}
24746
24781
  runtimeOptions += `
24747
24782
  __ssrInlineRender: true,`;
24748
24783
  }
24749
- const propsDecl = genRuntimeProps(ctx);
24750
24784
  if (propsDecl) runtimeOptions += `
24751
24785
  props: ${propsDecl},`;
24752
24786
  const emitsDecl = genRuntimeEmits(ctx);
@@ -25014,7 +25048,7 @@ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
25014
25048
  return generator.toJSON();
25015
25049
  }
25016
25050
 
25017
- const version = "3.5.20";
25051
+ const version = "3.5.22";
25018
25052
  const parseCache = parseCache$1;
25019
25053
  const errorMessages = {
25020
25054
  ...CompilerDOM.errorMessages,
@@ -1,9 +1,8 @@
1
1
  /**
2
- * @vue/compiler-sfc v3.5.20
2
+ * @vue/compiler-sfc v3.5.22
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
6
- /*! #__NO_SIDE_EFFECTS__ */
7
6
  // @__NO_SIDE_EFFECTS__
8
7
  function makeMap(str) {
9
8
  const map = /* @__PURE__ */ Object.create(null);
@@ -44,10 +43,10 @@ const cacheStringFunction = (fn) => {
44
43
  return hit || (cache[str] = fn(str));
45
44
  });
46
45
  };
47
- const camelizeRE = /-(\w)/g;
46
+ const camelizeRE = /-\w/g;
48
47
  const camelize = cacheStringFunction(
49
48
  (str) => {
50
- return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
49
+ return str.replace(camelizeRE, (c) => c.slice(1).toUpperCase());
51
50
  }
52
51
  );
53
52
  const hyphenateRE = /\B([A-Z])/g;
@@ -12665,7 +12664,7 @@ function requireLib () {
12665
12664
  }
12666
12665
  }
12667
12666
  fillOptionalPropertiesForTSESLint(node) {
12668
- var _node$directive, _node$decorators, _node$optional, _node$typeAnnotation, _node$accessibility, _node$decorators2, _node$override, _node$readonly, _node$static, _node$declare, _node$returnType, _node$typeParameters, _node$optional2, _node$optional3, _node$accessibility2, _node$readonly2, _node$static2, _node$declare2, _node$definite, _node$readonly3, _node$typeAnnotation2, _node$accessibility3, _node$decorators3, _node$override2, _node$optional4, _node$id, _node$abstract, _node$declare3, _node$decorators4, _node$implements, _node$superTypeArgume, _node$typeParameters2, _node$declare4, _node$definite2, _node$const, _node$declare5, _node$computed, _node$qualifier, _node$options, _node$declare6, _node$extends, _node$declare7, _node$global, _node$const2, _node$in, _node$out;
12667
+ var _node$directive, _node$decorators, _node$optional, _node$typeAnnotation, _node$accessibility, _node$decorators2, _node$override, _node$readonly, _node$static, _node$declare, _node$returnType, _node$typeParameters, _node$optional2, _node$optional3, _node$accessibility2, _node$readonly2, _node$static2, _node$declare2, _node$definite, _node$readonly3, _node$typeAnnotation2, _node$accessibility3, _node$decorators3, _node$override2, _node$optional4, _node$id, _node$abstract, _node$declare3, _node$decorators4, _node$implements, _node$superTypeArgume, _node$typeParameters2, _node$declare4, _node$definite2, _node$const, _node$declare5, _node$computed, _node$qualifier, _node$options, _node$declare6, _node$extends, _node$optional5, _node$readonly4, _node$declare7, _node$global, _node$const2, _node$in, _node$out;
12669
12668
  switch (node.type) {
12670
12669
  case "ExpressionStatement":
12671
12670
  (_node$directive = node.directive) != null ? _node$directive : node.directive = undefined;
@@ -12756,6 +12755,10 @@ function requireLib () {
12756
12755
  (_node$declare6 = node.declare) != null ? _node$declare6 : node.declare = false;
12757
12756
  (_node$extends = node.extends) != null ? _node$extends : node.extends = [];
12758
12757
  return;
12758
+ case "TSMappedType":
12759
+ (_node$optional5 = node.optional) != null ? _node$optional5 : node.optional = false;
12760
+ (_node$readonly4 = node.readonly) != null ? _node$readonly4 : node.readonly = undefined;
12761
+ return;
12759
12762
  case "TSModuleDeclaration":
12760
12763
  (_node$declare7 = node.declare) != null ? _node$declare7 : node.declare = false;
12761
12764
  (_node$global = node.global) != null ? _node$global : node.global = node.kind === "global";
@@ -17267,16 +17270,34 @@ function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [
17267
17270
  (id) => markScopeIdentifier(node, id, knownIds)
17268
17271
  );
17269
17272
  }
17273
+ } else if (node.type === "SwitchStatement") {
17274
+ if (node.scopeIds) {
17275
+ node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
17276
+ } else {
17277
+ walkSwitchStatement(
17278
+ node,
17279
+ false,
17280
+ (id) => markScopeIdentifier(node, id, knownIds)
17281
+ );
17282
+ }
17270
17283
  } else if (node.type === "CatchClause" && node.param) {
17271
- for (const id of extractIdentifiers$1(node.param)) {
17272
- markScopeIdentifier(node, id, knownIds);
17284
+ if (node.scopeIds) {
17285
+ node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
17286
+ } else {
17287
+ for (const id of extractIdentifiers$1(node.param)) {
17288
+ markScopeIdentifier(node, id, knownIds);
17289
+ }
17273
17290
  }
17274
17291
  } else if (isForStatement(node)) {
17275
- walkForStatement(
17276
- node,
17277
- false,
17278
- (id) => markScopeIdentifier(node, id, knownIds)
17279
- );
17292
+ if (node.scopeIds) {
17293
+ node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
17294
+ } else {
17295
+ walkForStatement(
17296
+ node,
17297
+ false,
17298
+ (id) => markScopeIdentifier(node, id, knownIds)
17299
+ );
17300
+ }
17280
17301
  }
17281
17302
  },
17282
17303
  leave(node, parent) {
@@ -17347,7 +17368,8 @@ function walkFunctionParams(node, onIdent) {
17347
17368
  }
17348
17369
  }
17349
17370
  function walkBlockDeclarations(block, onIdent) {
17350
- for (const stmt of block.body) {
17371
+ const body = block.type === "SwitchCase" ? block.consequent : block.body;
17372
+ for (const stmt of body) {
17351
17373
  if (stmt.type === "VariableDeclaration") {
17352
17374
  if (stmt.declare) continue;
17353
17375
  for (const decl of stmt.declarations) {
@@ -17360,6 +17382,8 @@ function walkBlockDeclarations(block, onIdent) {
17360
17382
  onIdent(stmt.id);
17361
17383
  } else if (isForStatement(stmt)) {
17362
17384
  walkForStatement(stmt, true, onIdent);
17385
+ } else if (stmt.type === "SwitchStatement") {
17386
+ walkSwitchStatement(stmt, true, onIdent);
17363
17387
  }
17364
17388
  }
17365
17389
  }
@@ -17376,6 +17400,20 @@ function walkForStatement(stmt, isVar, onIdent) {
17376
17400
  }
17377
17401
  }
17378
17402
  }
17403
+ function walkSwitchStatement(stmt, isVar, onIdent) {
17404
+ for (const cs of stmt.cases) {
17405
+ for (const stmt2 of cs.consequent) {
17406
+ if (stmt2.type === "VariableDeclaration" && (stmt2.kind === "var" ? isVar : !isVar)) {
17407
+ for (const decl of stmt2.declarations) {
17408
+ for (const id of extractIdentifiers$1(decl.id)) {
17409
+ onIdent(id);
17410
+ }
17411
+ }
17412
+ }
17413
+ }
17414
+ walkBlockDeclarations(cs, onIdent);
17415
+ }
17416
+ }
17379
17417
  function extractIdentifiers$1(param, nodes = []) {
17380
17418
  switch (param.type) {
17381
17419
  case "Identifier":
@@ -17689,7 +17727,7 @@ const isMemberExpressionNode = (exp, context) => {
17689
17727
  }
17690
17728
  };
17691
17729
  const isMemberExpression = isMemberExpressionNode;
17692
- const fnExpRE = /^\s*(async\s*)?(\([^)]*?\)|[\w$_]+)\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
17730
+ const fnExpRE = /^\s*(?:async\s*)?(?:\([^)]*?\)|[\w$_]+)\s*(?::[^=]+)?=>|^\s*(?:async\s+)?function(?:\s+[\w$]+)?\s*\(/;
17693
17731
  const isFnExpressionBrowser = (exp) => fnExpRE.test(getExpSource(exp));
17694
17732
  const isFnExpressionNode = (exp, context) => {
17695
17733
  try {
@@ -23636,7 +23674,7 @@ function isConst(type) {
23636
23674
  }
23637
23675
 
23638
23676
  const transformIf = createStructuralDirectiveTransform(
23639
- /^(if|else|else-if)$/,
23677
+ /^(?:if|else|else-if)$/,
23640
23678
  (node, dir, context) => {
23641
23679
  return processIf(node, dir, context, (ifNode, branch, isRoot) => {
23642
23680
  const siblings = context.parent.children;
@@ -23854,90 +23892,6 @@ function getParentCondition(node) {
23854
23892
  }
23855
23893
  }
23856
23894
 
23857
- const transformBind = (dir, _node, context) => {
23858
- const { modifiers, loc } = dir;
23859
- const arg = dir.arg;
23860
- let { exp } = dir;
23861
- if (exp && exp.type === 4 && !exp.content.trim()) {
23862
- {
23863
- context.onError(
23864
- createCompilerError(34, loc)
23865
- );
23866
- return {
23867
- props: [
23868
- createObjectProperty(arg, createSimpleExpression("", true, loc))
23869
- ]
23870
- };
23871
- }
23872
- }
23873
- if (!exp) {
23874
- if (arg.type !== 4 || !arg.isStatic) {
23875
- context.onError(
23876
- createCompilerError(
23877
- 52,
23878
- arg.loc
23879
- )
23880
- );
23881
- return {
23882
- props: [
23883
- createObjectProperty(arg, createSimpleExpression("", true, loc))
23884
- ]
23885
- };
23886
- }
23887
- transformBindShorthand(dir, context);
23888
- exp = dir.exp;
23889
- }
23890
- if (arg.type !== 4) {
23891
- arg.children.unshift(`(`);
23892
- arg.children.push(`) || ""`);
23893
- } else if (!arg.isStatic) {
23894
- arg.content = arg.content ? `${arg.content} || ""` : `""`;
23895
- }
23896
- if (modifiers.some((mod) => mod.content === "camel")) {
23897
- if (arg.type === 4) {
23898
- if (arg.isStatic) {
23899
- arg.content = camelize(arg.content);
23900
- } else {
23901
- arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
23902
- }
23903
- } else {
23904
- arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
23905
- arg.children.push(`)`);
23906
- }
23907
- }
23908
- if (!context.inSSR) {
23909
- if (modifiers.some((mod) => mod.content === "prop")) {
23910
- injectPrefix(arg, ".");
23911
- }
23912
- if (modifiers.some((mod) => mod.content === "attr")) {
23913
- injectPrefix(arg, "^");
23914
- }
23915
- }
23916
- return {
23917
- props: [createObjectProperty(arg, exp)]
23918
- };
23919
- };
23920
- const transformBindShorthand = (dir, context) => {
23921
- const arg = dir.arg;
23922
- const propName = camelize(arg.content);
23923
- dir.exp = createSimpleExpression(propName, false, arg.loc);
23924
- {
23925
- dir.exp = processExpression(dir.exp, context);
23926
- }
23927
- };
23928
- const injectPrefix = (arg, prefix) => {
23929
- if (arg.type === 4) {
23930
- if (arg.isStatic) {
23931
- arg.content = prefix + arg.content;
23932
- } else {
23933
- arg.content = `\`${prefix}\${${arg.content}}\``;
23934
- }
23935
- } else {
23936
- arg.children.unshift(`'${prefix}' + (`);
23937
- arg.children.push(`)`);
23938
- }
23939
- };
23940
-
23941
23895
  const transformFor = createStructuralDirectiveTransform(
23942
23896
  "for",
23943
23897
  (node, dir, context) => {
@@ -23950,9 +23904,6 @@ const transformFor = createStructuralDirectiveTransform(
23950
23904
  const memo = findDir(node, "memo");
23951
23905
  const keyProp = findProp(node, `key`, false, true);
23952
23906
  const isDirKey = keyProp && keyProp.type === 7;
23953
- if (isDirKey && !keyProp.exp) {
23954
- transformBindShorthand(keyProp, context);
23955
- }
23956
23907
  let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
23957
23908
  if (memo && keyExp && isDirKey) {
23958
23909
  {
@@ -24233,7 +24184,9 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
24233
24184
  const dynamicSlots = [];
24234
24185
  let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
24235
24186
  if (!context.ssr && context.prefixIdentifiers) {
24236
- hasDynamicSlots = hasScopeRef(node, context.identifiers);
24187
+ hasDynamicSlots = node.props.some(
24188
+ (prop) => isVSlot(prop) && (hasScopeRef(prop.arg, context.identifiers) || hasScopeRef(prop.exp, context.identifiers))
24189
+ ) || children.some((child) => hasScopeRef(child, context.identifiers));
24237
24190
  }
24238
24191
  const onComponentSlot = findDir(node, "slot", true);
24239
24192
  if (onComponentSlot) {
@@ -24296,7 +24249,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
24296
24249
  );
24297
24250
  } else if (vElse = findDir(
24298
24251
  slotElement,
24299
- /^else(-if)?$/,
24252
+ /^else(?:-if)?$/,
24300
24253
  true
24301
24254
  /* allowEmpty */
24302
24255
  )) {
@@ -24308,7 +24261,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
24308
24261
  break;
24309
24262
  }
24310
24263
  }
24311
- if (prev && isTemplateNode(prev) && findDir(prev, /^(else-)?if$/)) {
24264
+ if (prev && isTemplateNode(prev) && findDir(prev, /^(?:else-)?if$/)) {
24312
24265
  let conditional = dynamicSlots[dynamicSlots.length - 1];
24313
24266
  while (conditional.alternate.type === 19) {
24314
24267
  conditional = conditional.alternate;
@@ -25223,6 +25176,65 @@ const transformOn$1 = (dir, node, context, augmentor) => {
25223
25176
  return ret;
25224
25177
  };
25225
25178
 
25179
+ const transformBind = (dir, _node, context) => {
25180
+ const { modifiers, loc } = dir;
25181
+ const arg = dir.arg;
25182
+ let { exp } = dir;
25183
+ if (exp && exp.type === 4 && !exp.content.trim()) {
25184
+ {
25185
+ context.onError(
25186
+ createCompilerError(34, loc)
25187
+ );
25188
+ return {
25189
+ props: [
25190
+ createObjectProperty(arg, createSimpleExpression("", true, loc))
25191
+ ]
25192
+ };
25193
+ }
25194
+ }
25195
+ if (arg.type !== 4) {
25196
+ arg.children.unshift(`(`);
25197
+ arg.children.push(`) || ""`);
25198
+ } else if (!arg.isStatic) {
25199
+ arg.content = arg.content ? `${arg.content} || ""` : `""`;
25200
+ }
25201
+ if (modifiers.some((mod) => mod.content === "camel")) {
25202
+ if (arg.type === 4) {
25203
+ if (arg.isStatic) {
25204
+ arg.content = camelize(arg.content);
25205
+ } else {
25206
+ arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
25207
+ }
25208
+ } else {
25209
+ arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
25210
+ arg.children.push(`)`);
25211
+ }
25212
+ }
25213
+ if (!context.inSSR) {
25214
+ if (modifiers.some((mod) => mod.content === "prop")) {
25215
+ injectPrefix(arg, ".");
25216
+ }
25217
+ if (modifiers.some((mod) => mod.content === "attr")) {
25218
+ injectPrefix(arg, "^");
25219
+ }
25220
+ }
25221
+ return {
25222
+ props: [createObjectProperty(arg, exp)]
25223
+ };
25224
+ };
25225
+ const injectPrefix = (arg, prefix) => {
25226
+ if (arg.type === 4) {
25227
+ if (arg.isStatic) {
25228
+ arg.content = prefix + arg.content;
25229
+ } else {
25230
+ arg.content = `\`${prefix}\${${arg.content}}\``;
25231
+ }
25232
+ } else {
25233
+ arg.children.unshift(`'${prefix}' + (`);
25234
+ arg.children.push(`)`);
25235
+ }
25236
+ };
25237
+
25226
25238
  const transformText = (node, context) => {
25227
25239
  if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
25228
25240
  return () => {
@@ -25429,9 +25441,35 @@ const transformMemo = (node, context) => {
25429
25441
  }
25430
25442
  };
25431
25443
 
25444
+ const transformVBindShorthand = (node, context) => {
25445
+ if (node.type === 1) {
25446
+ for (const prop of node.props) {
25447
+ if (prop.type === 7 && prop.name === "bind" && !prop.exp) {
25448
+ const arg = prop.arg;
25449
+ if (arg.type !== 4 || !arg.isStatic) {
25450
+ context.onError(
25451
+ createCompilerError(
25452
+ 52,
25453
+ arg.loc
25454
+ )
25455
+ );
25456
+ prop.exp = createSimpleExpression("", true, arg.loc);
25457
+ } else {
25458
+ const propName = camelize(arg.content);
25459
+ if (validFirstIdentCharRE.test(propName[0]) || // allow hyphen first char for https://github.com/vuejs/language-tools/pull/3424
25460
+ propName[0] === "-") {
25461
+ prop.exp = createSimpleExpression(propName, false, arg.loc);
25462
+ }
25463
+ }
25464
+ }
25465
+ }
25466
+ }
25467
+ };
25468
+
25432
25469
  function getBaseTransformPreset(prefixIdentifiers) {
25433
25470
  return [
25434
25471
  [
25472
+ transformVBindShorthand,
25435
25473
  transformOnce,
25436
25474
  transformIf,
25437
25475
  transformMemo,
@@ -26015,7 +26053,7 @@ const getCachedNode = (node) => {
26015
26053
  return node.codegenNode;
26016
26054
  }
26017
26055
  };
26018
- const dataAriaRE = /^(data|aria)-/;
26056
+ const dataAriaRE = /^(?:data|aria)-/;
26019
26057
  const isStringifiableAttr = (name, ns) => {
26020
26058
  return (ns === 0 ? isKnownHtmlAttr(name) : ns === 1 ? isKnownSvgAttr(name) : ns === 2 ? isKnownMathMLAttr(name) : false) || dataAriaRE.test(name);
26021
26059
  };
@@ -26026,6 +26064,9 @@ function analyzeNode(node) {
26026
26064
  if (node.type === 1 && isNonStringifiable(node.tag)) {
26027
26065
  return false;
26028
26066
  }
26067
+ if (node.type === 1 && findDir(node, "once", true)) {
26068
+ return false;
26069
+ }
26029
26070
  if (node.type === 12) {
26030
26071
  return [1, 0];
26031
26072
  }
@@ -26555,8 +26596,10 @@ var CompilerDOM = /*#__PURE__*/Object.freeze({
26555
26596
  transformModel: transformModel$1,
26556
26597
  transformOn: transformOn$1,
26557
26598
  transformStyle: transformStyle,
26599
+ transformVBindShorthand: transformVBindShorthand,
26558
26600
  traverseNode: traverseNode,
26559
26601
  unwrapTSNode: unwrapTSNode,
26602
+ validFirstIdentCharRE: validFirstIdentCharRE,
26560
26603
  walkBlockDeclarations: walkBlockDeclarations,
26561
26604
  walkFunctionParams: walkFunctionParams,
26562
26605
  walkIdentifiers: walkIdentifiers,
@@ -26660,7 +26703,7 @@ function genCssVarsFromList(vars, id, isProd, isSSR = false) {
26660
26703
  }
26661
26704
  function genVarName(id, raw, isProd, isSSR = false) {
26662
26705
  if (isProd) {
26663
- return hash(id + raw);
26706
+ return hash(id + raw).replace(/^\d/, (r) => `v${r}`);
26664
26707
  } else {
26665
26708
  return `${id}-${getEscapedCssVarName(raw, isSSR)}`;
26666
26709
  }
@@ -31531,7 +31574,7 @@ function isRelativeUrl(url) {
31531
31574
  const firstChar = url.charAt(0);
31532
31575
  return firstChar === "." || firstChar === "~" || firstChar === "@";
31533
31576
  }
31534
- const externalRE = /^(https?:)?\/\//;
31577
+ const externalRE = /^(?:https?:)?\/\//;
31535
31578
  function isExternalUrl(url) {
31536
31579
  return externalRE.test(url);
31537
31580
  }
@@ -31844,7 +31887,7 @@ const ssrHelpers = {
31844
31887
  registerRuntimeHelpers(ssrHelpers);
31845
31888
 
31846
31889
  const ssrTransformIf = createStructuralDirectiveTransform(
31847
- /^(if|else|else-if)$/,
31890
+ /^(?:if|else|else-if)$/,
31848
31891
  processIf
31849
31892
  );
31850
31893
  function ssrProcessIf(node, context, disableNestedFragments = false, disableComment = false) {
@@ -32083,6 +32126,14 @@ const ssrTransformElement = (node, context) => {
32083
32126
  const hasCustomDir = node.props.some(
32084
32127
  (p) => p.type === 7 && !isBuiltInDirective(p.name)
32085
32128
  );
32129
+ const vShowPropIndex = node.props.findIndex(
32130
+ (i) => i.type === 7 && i.name === "show"
32131
+ );
32132
+ if (vShowPropIndex !== -1) {
32133
+ const vShowProp = node.props[vShowPropIndex];
32134
+ node.props.splice(vShowPropIndex, 1);
32135
+ node.props.push(vShowProp);
32136
+ }
32086
32137
  const needMergeProps = hasDynamicVBind || hasCustomDir;
32087
32138
  if (needMergeProps) {
32088
32139
  const { props, directives } = buildProps(
@@ -33178,6 +33229,7 @@ function compile(source, options = {}) {
33178
33229
  transform(ast, __spreadProps$6(__spreadValues$7({}, options), {
33179
33230
  hoistStatic: false,
33180
33231
  nodeTransforms: [
33232
+ transformVBindShorthand,
33181
33233
  ssrTransformIf,
33182
33234
  ssrTransformFor,
33183
33235
  trackVForSlotScopes,
@@ -41899,8 +41951,8 @@ function requireDist () {
41899
41951
  var distExports = /*@__PURE__*/ requireDist();
41900
41952
  var selectorParser = /*@__PURE__*/getDefaultExportFromCjs(distExports);
41901
41953
 
41902
- const animationNameRE = /^(-\w+-)?animation-name$/;
41903
- const animationRE = /^(-\w+-)?animation$/;
41954
+ const animationNameRE = /^(?:-\w+-)?animation-name$/;
41955
+ const animationRE = /^(?:-\w+-)?animation$/;
41904
41956
  const keyframesRE = /^(?:-\w+-)?keyframes$/;
41905
41957
  const scopedPlugin = (id = "") => {
41906
41958
  const keyframes = /* @__PURE__ */ Object.create(null);
@@ -45740,6 +45792,8 @@ const propNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~\-]/;
45740
45792
  function getEscapedPropName(key) {
45741
45793
  return propNameEscapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
45742
45794
  }
45795
+ const isJS = (...langs) => langs.some((lang) => lang === "js" || lang === "jsx");
45796
+ const isTS = (...langs) => langs.some((lang) => lang === "ts" || lang === "tsx");
45743
45797
 
45744
45798
  function analyzeScriptBindings(ast) {
45745
45799
  for (const node of ast) {
@@ -45810,97 +45864,88 @@ function getObjectOrArrayExpressionKeys(value) {
45810
45864
  return [];
45811
45865
  }
45812
45866
 
45813
- const comma = ','.charCodeAt(0);
45814
- const semicolon = ';'.charCodeAt(0);
45815
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
45816
- const intToChar = new Uint8Array(64); // 64 possible chars.
45817
- const charToInt = new Uint8Array(128); // z is 122 in ASCII
45867
+ // src/vlq.ts
45868
+ var comma = ",".charCodeAt(0);
45869
+ var semicolon = ";".charCodeAt(0);
45870
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
45871
+ var intToChar = new Uint8Array(64);
45872
+ var charToInt = new Uint8Array(128);
45818
45873
  for (let i = 0; i < chars.length; i++) {
45819
- const c = chars.charCodeAt(i);
45820
- intToChar[i] = c;
45821
- charToInt[c] = i;
45874
+ const c = chars.charCodeAt(i);
45875
+ intToChar[i] = c;
45876
+ charToInt[c] = i;
45822
45877
  }
45823
45878
  function encodeInteger(builder, num, relative) {
45824
- let delta = num - relative;
45825
- delta = delta < 0 ? (-delta << 1) | 1 : delta << 1;
45826
- do {
45827
- let clamped = delta & 0b011111;
45828
- delta >>>= 5;
45829
- if (delta > 0)
45830
- clamped |= 0b100000;
45831
- builder.write(intToChar[clamped]);
45832
- } while (delta > 0);
45833
- return num;
45834
- }
45835
-
45836
- const bufLength = 1024 * 16;
45837
- // Provide a fallback for older environments.
45838
- const td = typeof TextDecoder !== 'undefined'
45839
- ? /* #__PURE__ */ new TextDecoder()
45840
- : typeof Buffer !== 'undefined'
45841
- ? {
45842
- decode(buf) {
45843
- const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
45844
- return out.toString();
45845
- },
45846
- }
45847
- : {
45848
- decode(buf) {
45849
- let out = '';
45850
- for (let i = 0; i < buf.length; i++) {
45851
- out += String.fromCharCode(buf[i]);
45852
- }
45853
- return out;
45854
- },
45855
- };
45856
- class StringWriter {
45857
- constructor() {
45858
- this.pos = 0;
45859
- this.out = '';
45860
- this.buffer = new Uint8Array(bufLength);
45861
- }
45862
- write(v) {
45863
- const { buffer } = this;
45864
- buffer[this.pos++] = v;
45865
- if (this.pos === bufLength) {
45866
- this.out += td.decode(buffer);
45867
- this.pos = 0;
45868
- }
45869
- }
45870
- flush() {
45871
- const { buffer, out, pos } = this;
45872
- return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
45879
+ let delta = num - relative;
45880
+ delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
45881
+ do {
45882
+ let clamped = delta & 31;
45883
+ delta >>>= 5;
45884
+ if (delta > 0) clamped |= 32;
45885
+ builder.write(intToChar[clamped]);
45886
+ } while (delta > 0);
45887
+ return num;
45888
+ }
45889
+
45890
+ // src/strings.ts
45891
+ var bufLength = 1024 * 16;
45892
+ var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
45893
+ decode(buf) {
45894
+ const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
45895
+ return out.toString();
45896
+ }
45897
+ } : {
45898
+ decode(buf) {
45899
+ let out = "";
45900
+ for (let i = 0; i < buf.length; i++) {
45901
+ out += String.fromCharCode(buf[i]);
45902
+ }
45903
+ return out;
45904
+ }
45905
+ };
45906
+ var StringWriter = class {
45907
+ constructor() {
45908
+ this.pos = 0;
45909
+ this.out = "";
45910
+ this.buffer = new Uint8Array(bufLength);
45911
+ }
45912
+ write(v) {
45913
+ const { buffer } = this;
45914
+ buffer[this.pos++] = v;
45915
+ if (this.pos === bufLength) {
45916
+ this.out += td.decode(buffer);
45917
+ this.pos = 0;
45873
45918
  }
45874
- }
45919
+ }
45920
+ flush() {
45921
+ const { buffer, out, pos } = this;
45922
+ return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
45923
+ }
45924
+ };
45875
45925
  function encode(decoded) {
45876
- const writer = new StringWriter();
45877
- let sourcesIndex = 0;
45878
- let sourceLine = 0;
45879
- let sourceColumn = 0;
45880
- let namesIndex = 0;
45881
- for (let i = 0; i < decoded.length; i++) {
45882
- const line = decoded[i];
45883
- if (i > 0)
45884
- writer.write(semicolon);
45885
- if (line.length === 0)
45886
- continue;
45887
- let genColumn = 0;
45888
- for (let j = 0; j < line.length; j++) {
45889
- const segment = line[j];
45890
- if (j > 0)
45891
- writer.write(comma);
45892
- genColumn = encodeInteger(writer, segment[0], genColumn);
45893
- if (segment.length === 1)
45894
- continue;
45895
- sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
45896
- sourceLine = encodeInteger(writer, segment[2], sourceLine);
45897
- sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
45898
- if (segment.length === 4)
45899
- continue;
45900
- namesIndex = encodeInteger(writer, segment[4], namesIndex);
45901
- }
45902
- }
45903
- return writer.flush();
45926
+ const writer = new StringWriter();
45927
+ let sourcesIndex = 0;
45928
+ let sourceLine = 0;
45929
+ let sourceColumn = 0;
45930
+ let namesIndex = 0;
45931
+ for (let i = 0; i < decoded.length; i++) {
45932
+ const line = decoded[i];
45933
+ if (i > 0) writer.write(semicolon);
45934
+ if (line.length === 0) continue;
45935
+ let genColumn = 0;
45936
+ for (let j = 0; j < line.length; j++) {
45937
+ const segment = line[j];
45938
+ if (j > 0) writer.write(comma);
45939
+ genColumn = encodeInteger(writer, segment[0], genColumn);
45940
+ if (segment.length === 1) continue;
45941
+ sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
45942
+ sourceLine = encodeInteger(writer, segment[2], sourceLine);
45943
+ sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
45944
+ if (segment.length === 4) continue;
45945
+ namesIndex = encodeInteger(writer, segment[4], namesIndex);
45946
+ }
45947
+ }
45948
+ return writer.flush();
45904
45949
  }
45905
45950
 
45906
45951
  class BitSet {
@@ -46474,6 +46519,10 @@ class MagicString {
46474
46519
  if (chunk.outro.length) mappings.advance(chunk.outro);
46475
46520
  });
46476
46521
 
46522
+ if (this.outro) {
46523
+ mappings.advance(this.outro);
46524
+ }
46525
+
46477
46526
  return {
46478
46527
  file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
46479
46528
  sources: [
@@ -46940,12 +46989,18 @@ class MagicString {
46940
46989
  if (this.byStart[index] || this.byEnd[index]) return;
46941
46990
 
46942
46991
  let chunk = this.lastSearchedChunk;
46992
+ let previousChunk = chunk;
46943
46993
  const searchForward = index > chunk.end;
46944
46994
 
46945
46995
  while (chunk) {
46946
46996
  if (chunk.contains(index)) return this._splitChunk(chunk, index);
46947
46997
 
46948
46998
  chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
46999
+
47000
+ // Prevent infinite loop (e.g. via empty chunks, where start === end)
47001
+ if (chunk === previousChunk) return;
47002
+
47003
+ previousChunk = chunk;
46949
47004
  }
46950
47005
  }
46951
47006
 
@@ -47133,7 +47188,12 @@ class MagicString {
47133
47188
  const index = original.indexOf(string);
47134
47189
 
47135
47190
  if (index !== -1) {
47136
- this.overwrite(index, index + string.length, replacement);
47191
+ if (typeof replacement === 'function') {
47192
+ replacement = replacement(string, index, original);
47193
+ }
47194
+ if (string !== replacement) {
47195
+ this.overwrite(index, index + string.length, replacement);
47196
+ }
47137
47197
  }
47138
47198
 
47139
47199
  return this;
@@ -47156,7 +47216,11 @@ class MagicString {
47156
47216
  index = original.indexOf(string, index + stringLength)
47157
47217
  ) {
47158
47218
  const previous = original.slice(index, index + stringLength);
47159
- if (previous !== replacement) this.overwrite(index, index + stringLength, replacement);
47219
+ let _replacement = replacement;
47220
+ if (typeof replacement === 'function') {
47221
+ _replacement = replacement(previous, index, original);
47222
+ }
47223
+ if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
47160
47224
  }
47161
47225
 
47162
47226
  return this;
@@ -47207,8 +47271,8 @@ class ScriptCompileContext {
47207
47271
  const { script, scriptSetup } = descriptor;
47208
47272
  const scriptLang = script && script.lang;
47209
47273
  const scriptSetupLang = scriptSetup && scriptSetup.lang;
47210
- this.isJS = scriptLang === "js" || scriptLang === "jsx" || scriptSetupLang === "js" || scriptSetupLang === "jsx";
47211
- this.isTS = scriptLang === "ts" || scriptLang === "tsx" || scriptSetupLang === "ts" || scriptSetupLang === "tsx";
47274
+ this.isJS = isJS(scriptLang, scriptSetupLang);
47275
+ this.isTS = isTS(scriptLang, scriptSetupLang);
47212
47276
  const customElement = options.customElement;
47213
47277
  const filename = this.descriptor.filename;
47214
47278
  if (customElement) {
@@ -47406,9 +47470,6 @@ const normalScriptDefaultVar = `__default__`;
47406
47470
  function processNormalScript(ctx, scopeId) {
47407
47471
  var _a;
47408
47472
  const script = ctx.descriptor.script;
47409
- if (script.lang && !ctx.isJS && !ctx.isTS) {
47410
- return script;
47411
- }
47412
47473
  try {
47413
47474
  let content = script.content;
47414
47475
  let map = script.map;
@@ -48258,7 +48319,11 @@ function recordTypes(ctx, body, scope, asGlobal = false) {
48258
48319
  }
48259
48320
  } else if (stmt.type === "TSModuleDeclaration" && stmt.global) {
48260
48321
  for (const s of stmt.body.body) {
48261
- recordType(s, types, declares);
48322
+ if (s.type === "ExportNamedDeclaration" && s.declaration) {
48323
+ recordType(s.declaration, types, declares);
48324
+ } else {
48325
+ recordType(s, types, declares);
48326
+ }
48262
48327
  }
48263
48328
  }
48264
48329
  } else {
@@ -48433,6 +48498,9 @@ function recordImport(node, imports) {
48433
48498
  }
48434
48499
  }
48435
48500
  function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx), isKeyOf = false, typeParameters) {
48501
+ if (node.leadingComments && node.leadingComments.some((c) => c.value.includes("@vue-ignore"))) {
48502
+ return [UNKNOWN_TYPE];
48503
+ }
48436
48504
  try {
48437
48505
  switch (node.type) {
48438
48506
  case "TSStringKeyword":
@@ -48669,6 +48737,24 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
48669
48737
  typeParameters
48670
48738
  ).filter((t) => t !== UNKNOWN_TYPE);
48671
48739
  }
48740
+ case "TSMappedType": {
48741
+ const { typeAnnotation, typeParameter } = node;
48742
+ if (typeAnnotation && typeAnnotation.type === "TSIndexedAccessType" && typeParameter && typeParameter.constraint && typeParameters) {
48743
+ const constraint = typeParameter.constraint;
48744
+ if (constraint.type === "TSTypeOperator" && constraint.operator === "keyof" && constraint.typeAnnotation && constraint.typeAnnotation.type === "TSTypeReference" && constraint.typeAnnotation.typeName.type === "Identifier") {
48745
+ const typeName = constraint.typeAnnotation.typeName.name;
48746
+ const index = typeAnnotation.indexType;
48747
+ const obj = typeAnnotation.objectType;
48748
+ if (obj && obj.type === "TSTypeReference" && obj.typeName.type === "Identifier" && obj.typeName.name === typeName && index && index.type === "TSTypeReference" && index.typeName.type === "Identifier" && index.typeName.name === typeParameter.name) {
48749
+ const targetType = typeParameters[typeName];
48750
+ if (targetType) {
48751
+ return inferRuntimeType(ctx, targetType, scope);
48752
+ }
48753
+ }
48754
+ }
48755
+ }
48756
+ return [UNKNOWN_TYPE];
48757
+ }
48672
48758
  case "TSEnumDeclaration":
48673
48759
  return inferEnumType(node);
48674
48760
  case "TSSymbolKeyword":
@@ -49640,21 +49726,26 @@ Upgrade your vite or vue-loader version for compatibility with the latest experi
49640
49726
  const scopeId = options.id ? options.id.replace(/^data-v-/, "") : "";
49641
49727
  const scriptLang = script && script.lang;
49642
49728
  const scriptSetupLang = scriptSetup && scriptSetup.lang;
49729
+ const isJSOrTS = isJS(scriptLang, scriptSetupLang) || isTS(scriptLang, scriptSetupLang);
49643
49730
  if (script && scriptSetup && scriptLang !== scriptSetupLang) {
49644
49731
  throw new Error(
49645
49732
  `[@vue/compiler-sfc] <script> and <script setup> must have the same language type.`
49646
49733
  );
49647
49734
  }
49648
- const ctx = new ScriptCompileContext(sfc, options);
49649
49735
  if (!scriptSetup) {
49650
49736
  if (!script) {
49651
49737
  throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
49652
49738
  }
49653
- return processNormalScript(ctx, scopeId);
49739
+ if (script.lang && !isJSOrTS) {
49740
+ return script;
49741
+ }
49742
+ const ctx2 = new ScriptCompileContext(sfc, options);
49743
+ return processNormalScript(ctx2, scopeId);
49654
49744
  }
49655
- if (scriptSetupLang && !ctx.isJS && !ctx.isTS) {
49745
+ if (scriptSetupLang && !isJSOrTS) {
49656
49746
  return scriptSetup;
49657
49747
  }
49748
+ const ctx = new ScriptCompileContext(sfc, options);
49658
49749
  const scriptBindings = /* @__PURE__ */ Object.create(null);
49659
49750
  const setupBindings = /* @__PURE__ */ Object.create(null);
49660
49751
  let defaultExport;
@@ -50085,6 +50176,7 @@ let __temp${any}, __restore${any}
50085
50176
  }
50086
50177
  let templateMap;
50087
50178
  let returned;
50179
+ const propsDecl = genRuntimeProps(ctx);
50088
50180
  if (!options.inlineTemplate || !sfc.template && ctx.hasDefaultExportRender) {
50089
50181
  const allBindings = __spreadValues$1(__spreadValues$1({}, scriptBindings), setupBindings);
50090
50182
  for (const key in ctx.userImports) {
@@ -50187,7 +50279,6 @@ return ${returned}
50187
50279
  runtimeOptions += `
50188
50280
  __ssrInlineRender: true,`;
50189
50281
  }
50190
- const propsDecl = genRuntimeProps(ctx);
50191
50282
  if (propsDecl) runtimeOptions += `
50192
50283
  props: ${propsDecl},`;
50193
50284
  const emitsDecl = genRuntimeEmits(ctx);
@@ -50470,7 +50561,7 @@ var __spreadValues = (a, b) => {
50470
50561
  }
50471
50562
  return a;
50472
50563
  };
50473
- const version = "3.5.20";
50564
+ const version = "3.5.22";
50474
50565
  const parseCache = parseCache$1;
50475
50566
  const errorMessages = __spreadValues(__spreadValues({}, errorMessages$1), DOMErrorMessages);
50476
50567
  const walk = walk$2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "3.5.20",
3
+ "version": "3.5.22",
4
4
  "description": "@vue/compiler-sfc",
5
5
  "main": "dist/compiler-sfc.cjs.js",
6
6
  "module": "dist/compiler-sfc.esm-browser.js",
@@ -42,18 +42,18 @@
42
42
  },
43
43
  "homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-sfc#readme",
44
44
  "dependencies": {
45
- "@babel/parser": "^7.28.3",
45
+ "@babel/parser": "^7.28.4",
46
46
  "estree-walker": "^2.0.2",
47
- "magic-string": "^0.30.17",
47
+ "magic-string": "^0.30.19",
48
48
  "postcss": "^8.5.6",
49
49
  "source-map-js": "^1.2.1",
50
- "@vue/compiler-core": "3.5.20",
51
- "@vue/compiler-dom": "3.5.20",
52
- "@vue/compiler-ssr": "3.5.20",
53
- "@vue/shared": "3.5.20"
50
+ "@vue/compiler-core": "3.5.22",
51
+ "@vue/compiler-ssr": "3.5.22",
52
+ "@vue/shared": "3.5.22",
53
+ "@vue/compiler-dom": "3.5.22"
54
54
  },
55
55
  "devDependencies": {
56
- "@babel/types": "^7.28.2",
56
+ "@babel/types": "^7.28.4",
57
57
  "@vue/consolidate": "^1.0.0",
58
58
  "hash-sum": "^2.0.0",
59
59
  "lru-cache": "10.1.0",
@@ -62,6 +62,6 @@
62
62
  "postcss-modules": "^6.0.1",
63
63
  "postcss-selector-parser": "^7.1.0",
64
64
  "pug": "^3.0.3",
65
- "sass": "^1.90.0"
65
+ "sass": "^1.93.2"
66
66
  }
67
67
  }