@vue/compiler-sfc 3.5.4 → 3.5.6

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.4
2
+ * @vue/compiler-sfc v3.5.6
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -7911,16 +7911,12 @@ function rewriteSelector(id, rule, selector, selectorRoot, deep, slotted = false
7911
7911
  });
7912
7912
  if (rule.nodes.some((node2) => node2.type === "rule")) {
7913
7913
  const deep2 = rule.__deep;
7914
- const decls = rule.nodes.filter((node2) => node2.type === "decl");
7915
- if (!deep2 && decls.length) {
7916
- for (const decl of decls) {
7917
- rule.removeChild(decl);
7914
+ if (!deep2) {
7915
+ extractAndWrapNodes(rule);
7916
+ const atruleNodes = rule.nodes.filter((node2) => node2.type === "atrule");
7917
+ for (const atnode of atruleNodes) {
7918
+ extractAndWrapNodes(atnode);
7918
7919
  }
7919
- const hostRule = new require$$0$1.Rule({
7920
- nodes: decls,
7921
- selector: "&"
7922
- });
7923
- rule.prepend(hostRule);
7924
7920
  }
7925
7921
  shouldInject = deep2;
7926
7922
  }
@@ -7956,6 +7952,22 @@ function rewriteSelector(id, rule, selector, selectorRoot, deep, slotted = false
7956
7952
  function isSpaceCombinator(node) {
7957
7953
  return node.type === "combinator" && /^\s+$/.test(node.value);
7958
7954
  }
7955
+ function extractAndWrapNodes(parentNode) {
7956
+ if (!parentNode.nodes) return;
7957
+ const nodes = parentNode.nodes.filter(
7958
+ (node) => node.type === "decl" || node.type === "comment"
7959
+ );
7960
+ if (nodes.length) {
7961
+ for (const node of nodes) {
7962
+ parentNode.removeChild(node);
7963
+ }
7964
+ const wrappedRule = new require$$0$1.Rule({
7965
+ nodes,
7966
+ selector: "&"
7967
+ });
7968
+ parentNode.prepend(wrappedRule);
7969
+ }
7970
+ }
7959
7971
  scopedPlugin.postcss = true;
7960
7972
 
7961
7973
  var sourceMap$1 = {};
@@ -15711,20 +15723,26 @@ ${shared.generateCodeFrame(
15711
15723
  const block = scriptSetup ? this.descriptor.scriptSetup : this.descriptor.script;
15712
15724
  return block.content.slice(node.start, node.end);
15713
15725
  }
15726
+ warn(msg, node, scope) {
15727
+ warn(generateError(msg, node, this, scope));
15728
+ }
15714
15729
  error(msg, node, scope) {
15715
- const offset = scope ? scope.offset : this.startOffset;
15716
15730
  throw new Error(
15717
- `[@vue/compiler-sfc] ${msg}
15718
-
15719
- ${(scope || this.descriptor).filename}
15720
- ${shared.generateCodeFrame(
15721
- (scope || this.descriptor).source,
15722
- node.start + offset,
15723
- node.end + offset
15724
- )}`
15731
+ `[@vue/compiler-sfc] ${generateError(msg, node, this, scope)}`
15725
15732
  );
15726
15733
  }
15727
15734
  }
15735
+ function generateError(msg, node, ctx, scope) {
15736
+ const offset = scope ? scope.offset : ctx.startOffset;
15737
+ return `${msg}
15738
+
15739
+ ${(scope || ctx.descriptor).filename}
15740
+ ${shared.generateCodeFrame(
15741
+ (scope || ctx.descriptor).source,
15742
+ node.start + offset,
15743
+ node.end + offset
15744
+ )}`;
15745
+ }
15728
15746
  function resolveParserPlugins(lang, userPlugins, dts = false) {
15729
15747
  const plugins = [];
15730
15748
  if (!userPlugins || !userPlugins.some(
@@ -19456,7 +19474,7 @@ function genModelProps(ctx) {
19456
19474
 
19457
19475
  const DEFINE_PROPS = "defineProps";
19458
19476
  const WITH_DEFAULTS = "withDefaults";
19459
- function processDefineProps(ctx, node, declId) {
19477
+ function processDefineProps(ctx, node, declId, isWithDefaults = false) {
19460
19478
  if (!isCallOf(node, DEFINE_PROPS)) {
19461
19479
  return processWithDefaults(ctx, node, declId);
19462
19480
  }
@@ -19481,7 +19499,7 @@ function processDefineProps(ctx, node, declId) {
19481
19499
  }
19482
19500
  ctx.propsTypeDecl = node.typeParameters.params[0];
19483
19501
  }
19484
- if (declId && declId.type === "ObjectPattern") {
19502
+ if (!isWithDefaults && declId && declId.type === "ObjectPattern") {
19485
19503
  processPropsDestructure(ctx, declId);
19486
19504
  }
19487
19505
  ctx.propsCall = node;
@@ -19492,7 +19510,12 @@ function processWithDefaults(ctx, node, declId) {
19492
19510
  if (!isCallOf(node, WITH_DEFAULTS)) {
19493
19511
  return false;
19494
19512
  }
19495
- if (!processDefineProps(ctx, node.arguments[0], declId)) {
19513
+ if (!processDefineProps(
19514
+ ctx,
19515
+ node.arguments[0],
19516
+ declId,
19517
+ true
19518
+ )) {
19496
19519
  ctx.error(
19497
19520
  `${WITH_DEFAULTS}' first argument must be a ${DEFINE_PROPS} call.`,
19498
19521
  node.arguments[0] || node
@@ -19504,10 +19527,11 @@ function processWithDefaults(ctx, node, declId) {
19504
19527
  node
19505
19528
  );
19506
19529
  }
19507
- if (ctx.propsDestructureDecl) {
19508
- ctx.error(
19530
+ if (declId && declId.type === "ObjectPattern") {
19531
+ ctx.warn(
19509
19532
  `${WITH_DEFAULTS}() is unnecessary when using destructure with ${DEFINE_PROPS}().
19510
- Prefer using destructure default values, e.g. const { foo = 1 } = defineProps(...).`,
19533
+ Reactive destructure will be disabled when using withDefaults().
19534
+ Prefer using destructure default values, e.g. const { foo = 1 } = defineProps(...). `,
19511
19535
  node.callee
19512
19536
  );
19513
19537
  }
@@ -20882,7 +20906,7 @@ function isStaticNode(node) {
20882
20906
  return false;
20883
20907
  }
20884
20908
 
20885
- const version = "3.5.4";
20909
+ const version = "3.5.6";
20886
20910
  const parseCache = parseCache$1;
20887
20911
  const errorMessages = {
20888
20912
  ...CompilerDOM.errorMessages,
@@ -395,6 +395,7 @@ export declare class ScriptCompileContext {
395
395
  fs?: NonNullable<SFCScriptCompileOptions['fs']>;
396
396
  constructor(descriptor: SFCDescriptor, options: Partial<SFCScriptCompileOptions>);
397
397
  getString(node: Node, scriptSetup?: boolean): string;
398
+ warn(msg: string, node: Node, scope?: TypeScope): void;
398
399
  error(msg: string, node: Node, scope?: TypeScope): never;
399
400
  }
400
401