@vue/language-core 3.3.4 → 3.3.5

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.
@@ -56,7 +56,6 @@ declare const raw: {
56
56
  FunctionalComponentProps: string;
57
57
  IsAny: string;
58
58
  IsFunction: string;
59
- NormalizeComponentEvent: string;
60
59
  NormalizeEmits: string;
61
60
  OverloadUnion: string;
62
61
  OverloadUnionInner: string;
@@ -64,6 +63,7 @@ declare const raw: {
64
63
  PrettifyGlobal: string;
65
64
  ResolveDirectives: string;
66
65
  ResolveEmits: string;
66
+ ResolveEvent: string;
67
67
  ShortEmits: string;
68
68
  ShortEmitsToObject: string;
69
69
  SpreadMerge: string;
@@ -60,7 +60,6 @@ const raw = {
60
60
  FunctionalComponentProps: '',
61
61
  IsAny: '',
62
62
  IsFunction: '',
63
- NormalizeComponentEvent: '',
64
63
  NormalizeEmits: '',
65
64
  OverloadUnion: '',
66
65
  OverloadUnionInner: '',
@@ -68,6 +67,7 @@ const raw = {
68
67
  PrettifyGlobal: '',
69
68
  ResolveDirectives: '',
70
69
  ResolveEmits: '',
70
+ ResolveEvent: '',
71
71
  ShortEmits: '',
72
72
  ShortEmitsToObject: '',
73
73
  SpreadMerge: '',
@@ -47,7 +47,7 @@ const boundary_1 = require("../utils/boundary");
47
47
  const camelized_1 = require("../utils/camelized");
48
48
  const interpolation_1 = require("./interpolation");
49
49
  function* generateElementEvents(options, ctx, node, componentOriginalVar, getCtxVar, getPropsVar) {
50
- const definitions = [];
50
+ const definitions = {};
51
51
  for (const prop of node.props) {
52
52
  if (prop.type === CompilerDOM.NodeTypes.DIRECTIVE
53
53
  && (prop.name === 'on'
@@ -71,49 +71,51 @@ function* generateElementEvents(options, ctx, node, componentOriginalVar, getCtx
71
71
  }
72
72
  const propName = (0, shared_1.camelize)(propPrefix + source);
73
73
  const emitName = emitPrefix + source;
74
- definitions.push({
75
- prop,
76
- source,
77
- offset,
78
- emitPrefix,
74
+ const key = [
75
+ prop.name,
76
+ propName,
77
+ ...prop.modifiers.map(modifier => modifier.content),
78
+ ].join('+');
79
+ definitions[key] ??= {
79
80
  propPrefix,
81
+ emitPrefix,
80
82
  propName,
81
83
  emitName,
84
+ items: [],
85
+ };
86
+ definitions[key].items.push({
87
+ prop,
88
+ source,
89
+ offset,
82
90
  });
83
91
  }
84
92
  }
85
- if (!definitions.length) {
93
+ if (!Object.keys(definitions).length) {
86
94
  return;
87
95
  }
88
96
  const emitsVar = ctx.getInternalVariable();
89
97
  yield `let ${emitsVar}!: ${names_1.names.ResolveEmits}<typeof ${componentOriginalVar}, typeof ${getCtxVar()}.emit>${utils_1.endOfLine}`;
90
- yield `const ${ctx.getInternalVariable()}: `;
91
- for (let i = 0; i < definitions.length; i++) {
92
- const { propName, emitName } = definitions[i];
93
- if (i > 0) {
94
- yield ` & `;
95
- }
96
- yield `${names_1.names.NormalizeComponentEvent}<typeof ${getPropsVar()}, typeof ${emitsVar}, '${propName}', '${emitName}', '${(0, shared_1.camelize)(emitName)}'>`;
97
- }
98
- yield ` = {${utils_1.newLine}`;
99
- for (const { prop, source, offset, emitPrefix, propPrefix, propName } of definitions) {
100
- if (prop.name === 'on') {
101
- yield `...{ `;
102
- yield* generateEventArg(options, source, offset, emitPrefix.slice(0, -1), codeFeatures_1.codeFeatures.navigation);
103
- yield `: {} as any } as typeof ${emitsVar},${utils_1.newLine}`;
104
- }
105
- if (prop.name === 'on') {
106
- yield* generateEventArg(options, source, offset, propPrefix.slice(0, -1));
107
- yield `: `;
108
- yield* generateEventExpression(options, ctx, prop);
109
- }
110
- else {
111
- yield `'${propName}': `;
112
- yield* generateModelEventExpression(options, ctx, prop);
98
+ for (const { propPrefix, emitPrefix, propName, emitName, items } of Object.values(definitions)) {
99
+ yield `const ${ctx.getInternalVariable()}: ${names_1.names.ResolveEvent}<typeof ${getPropsVar()}, typeof ${emitsVar}, '${propName}', '${emitName}', '${(0, shared_1.camelize)(emitName)}'> = {${utils_1.newLine}`;
100
+ for (const { prop, source, offset } of items) {
101
+ if (prop.name === 'on') {
102
+ yield `/** @type {typeof ${emitsVar}.`;
103
+ yield* generateEventArg(options, source, offset, emitPrefix.slice(0, -1), codeFeatures_1.codeFeatures.navigation);
104
+ yield `} */${utils_1.newLine}`;
105
+ }
106
+ if (prop.name === 'on') {
107
+ yield* generateEventArg(options, source, offset, propPrefix.slice(0, -1));
108
+ yield `: `;
109
+ yield* generateEventExpression(options, ctx, prop);
110
+ }
111
+ else {
112
+ yield `'${propName}': `;
113
+ yield* generateModelEventExpression(options, ctx, prop);
114
+ }
115
+ yield `,${utils_1.newLine}`;
113
116
  }
114
- yield `,${utils_1.newLine}`;
117
+ yield `}${utils_1.endOfLine}`;
115
118
  }
116
- yield `}${utils_1.endOfLine}`;
117
119
  }
118
120
  function* generateEventArg(options, name, start, directive = 'on', features) {
119
121
  features ??= {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-core",
3
- "version": "3.3.4",
3
+ "version": "3.3.5",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "index.d.ts",
@@ -34,5 +34,5 @@
34
34
  "@volar/typescript": "2.4.28",
35
35
  "@vue/compiler-sfc": "^3.5.0"
36
36
  },
37
- "gitHead": "043a77b6182db32f4076f84a767c1c674ef2b149"
37
+ "gitHead": "2fe255ca6d5809c93b71ec8185ec14562cff5945"
38
38
  }
@@ -54,7 +54,7 @@ declare global {
54
54
  : true
55
55
  : false
56
56
  : false;
57
- type __VLS_NormalizeComponentEvent<
57
+ type __VLS_ResolveEvent<
58
58
  Props,
59
59
  Emits,
60
60
  onEvent extends keyof Props,