@vue/language-core 2.1.8 → 2.2.0

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.
Files changed (77) hide show
  1. package/lib/codegen/globalTypes.js +12 -5
  2. package/lib/codegen/localTypes.js +3 -3
  3. package/lib/codegen/script/component.js +42 -42
  4. package/lib/codegen/script/componentSelf.js +14 -13
  5. package/lib/codegen/script/context.js +2 -2
  6. package/lib/codegen/script/index.d.ts +5 -3
  7. package/lib/codegen/script/index.js +24 -37
  8. package/lib/codegen/script/scriptSetup.js +240 -193
  9. package/lib/codegen/script/src.js +6 -6
  10. package/lib/codegen/script/styleModulesType.js +5 -5
  11. package/lib/codegen/script/template.d.ts +1 -1
  12. package/lib/codegen/script/template.js +89 -99
  13. package/lib/codegen/template/context.d.ts +13 -3
  14. package/lib/codegen/template/context.js +21 -12
  15. package/lib/codegen/template/element.d.ts +2 -4
  16. package/lib/codegen/template/element.js +132 -105
  17. package/lib/codegen/template/elementChildren.d.ts +1 -1
  18. package/lib/codegen/template/elementChildren.js +8 -8
  19. package/lib/codegen/template/elementDirectives.d.ts +1 -0
  20. package/lib/codegen/template/elementDirectives.js +28 -22
  21. package/lib/codegen/template/elementEvents.d.ts +2 -2
  22. package/lib/codegen/template/elementEvents.js +32 -65
  23. package/lib/codegen/template/elementProps.d.ts +3 -2
  24. package/lib/codegen/template/elementProps.js +119 -122
  25. package/lib/codegen/template/index.js +52 -60
  26. package/lib/codegen/template/interpolation.d.ts +5 -3
  27. package/lib/codegen/template/interpolation.js +18 -19
  28. package/lib/codegen/template/objectProperty.js +8 -8
  29. package/lib/codegen/template/propertyAccess.js +4 -4
  30. package/lib/codegen/template/slotOutlet.d.ts +1 -1
  31. package/lib/codegen/template/slotOutlet.js +13 -13
  32. package/lib/codegen/template/styleScopedClasses.d.ts +1 -1
  33. package/lib/codegen/template/styleScopedClasses.js +11 -8
  34. package/lib/codegen/template/templateChild.d.ts +1 -1
  35. package/lib/codegen/template/templateChild.js +31 -19
  36. package/lib/codegen/template/vFor.d.ts +1 -1
  37. package/lib/codegen/template/vFor.js +11 -11
  38. package/lib/codegen/template/vIf.d.ts +1 -1
  39. package/lib/codegen/template/vIf.js +6 -6
  40. package/lib/codegen/{template → utils}/camelized.js +2 -2
  41. package/lib/codegen/{common.d.ts → utils/index.d.ts} +1 -2
  42. package/lib/codegen/{common.js → utils/index.js} +4 -15
  43. package/lib/codegen/{template → utils}/stringLiteralKey.js +3 -3
  44. package/lib/codegen/utils/unicode.d.ts +2 -0
  45. package/lib/codegen/utils/unicode.js +25 -0
  46. package/lib/languagePlugin.js +1 -1
  47. package/lib/parsers/scriptRanges.d.ts +7 -2
  48. package/lib/parsers/scriptSetupRanges.d.ts +67 -81
  49. package/lib/parsers/scriptSetupRanges.js +195 -166
  50. package/lib/parsers/vueCompilerOptions.d.ts +2 -0
  51. package/lib/parsers/vueCompilerOptions.js +23 -0
  52. package/lib/plugins/file-html.js +4 -3
  53. package/lib/plugins/file-md.js +1 -1
  54. package/lib/plugins/file-vue.js +4 -4
  55. package/lib/plugins/vue-root-tags.js +2 -2
  56. package/lib/plugins/vue-template-html.js +6 -2
  57. package/lib/plugins/vue-template-inline-css.js +1 -1
  58. package/lib/plugins/vue-template-inline-ts.js +13 -5
  59. package/lib/plugins/vue-tsx.d.ts +101 -72
  60. package/lib/plugins/vue-tsx.js +65 -69
  61. package/lib/types.d.ts +19 -10
  62. package/lib/utils/buildMappings.d.ts +1 -1
  63. package/lib/utils/parseSfc.d.ts +5 -0
  64. package/lib/utils/parseSfc.js +7 -2
  65. package/lib/utils/ts.d.ts +1 -1
  66. package/lib/utils/ts.js +38 -24
  67. package/lib/virtualFile/computedEmbeddedCodes.d.ts +1 -2
  68. package/lib/virtualFile/computedSfc.js +23 -12
  69. package/lib/virtualFile/computedVueSfc.d.ts +1 -1
  70. package/lib/virtualFile/vueFile.d.ts +3 -3
  71. package/package.json +5 -5
  72. package/lib/codegen/types.d.ts +0 -9
  73. package/lib/codegen/types.js +0 -3
  74. package/lib/utils/findDestructuredProps.d.ts +0 -1
  75. package/lib/utils/findDestructuredProps.js +0 -3
  76. /package/lib/codegen/{template → utils}/camelized.d.ts +0 -0
  77. /package/lib/codegen/{template → utils}/stringLiteralKey.d.ts +0 -0
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateSrc = generateSrc;
4
- const common_1 = require("../common");
4
+ const utils_1 = require("../utils");
5
5
  const index_1 = require("./index");
6
6
  function* generateSrc(script, src) {
7
7
  if (src.endsWith('.d.ts')) {
8
- src = src.substring(0, src.length - '.d.ts'.length);
8
+ src = src.slice(0, -'.d.ts'.length);
9
9
  }
10
10
  else if (src.endsWith('.ts')) {
11
- src = src.substring(0, src.length - '.ts'.length);
11
+ src = src.slice(0, -'.ts'.length);
12
12
  }
13
13
  else if (src.endsWith('.tsx')) {
14
- src = src.substring(0, src.length - '.tsx'.length) + '.jsx';
14
+ src = src.slice(0, -'.tsx'.length) + '.jsx';
15
15
  }
16
16
  if (!src.endsWith('.js') && !src.endsWith('.jsx')) {
17
17
  src = src + '.js';
@@ -45,7 +45,7 @@ function* generateSrc(script, src) {
45
45
  },
46
46
  },
47
47
  ];
48
- yield common_1.endOfLine;
49
- yield `export { default } from '${src}'${common_1.endOfLine}`;
48
+ yield utils_1.endOfLine;
49
+ yield `export { default } from '${src}'${utils_1.endOfLine}`;
50
50
  }
51
51
  //# sourceMappingURL=src.js.map
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateStyleModulesType = generateStyleModulesType;
4
+ const utils_1 = require("../utils");
4
5
  const index_1 = require("./index");
5
6
  const template_1 = require("./template");
6
- const common_1 = require("../common");
7
7
  function* generateStyleModulesType(options, ctx) {
8
8
  const styles = options.sfc.styles.map((style, i) => [style, i]).filter(([style]) => style.module);
9
- if (!styles.length) {
9
+ if (!styles.length && !options.scriptSetupRanges?.useCssModule.length) {
10
10
  return;
11
11
  }
12
- yield `type __VLS_StyleModules = {${common_1.newLine}`;
12
+ yield `type __VLS_StyleModules = {${utils_1.newLine}`;
13
13
  for (const [style, i] of styles) {
14
14
  const { name, offset } = style.module;
15
15
  if (offset) {
@@ -27,8 +27,8 @@ function* generateStyleModulesType(options, ctx) {
27
27
  for (const className of style.classNames) {
28
28
  yield* (0, template_1.generateCssClassProperty)(i, className.text, className.offset, 'string', false);
29
29
  }
30
- yield `>${common_1.endOfLine}`;
30
+ yield `>${utils_1.endOfLine}`;
31
31
  }
32
- yield `}${common_1.endOfLine}`;
32
+ yield `}${utils_1.endOfLine}`;
33
33
  }
34
34
  //# sourceMappingURL=styleModulesType.js.map
@@ -2,7 +2,7 @@ import type { Code } from '../../types';
2
2
  import { TemplateCodegenContext } from '../template/context';
3
3
  import type { ScriptCodegenContext } from './context';
4
4
  import { type ScriptCodegenOptions } from './index';
5
- export declare function generateTemplateDirectives(options: ScriptCodegenOptions): Generator<Code>;
6
5
  export declare function generateTemplate(options: ScriptCodegenOptions, ctx: ScriptCodegenContext): Generator<Code, TemplateCodegenContext>;
6
+ export declare function generateTemplateDirectives(options: ScriptCodegenOptions): Generator<Code>;
7
7
  export declare function generateCssClassProperty(styleIndex: number, classNameWithDot: string, offset: number, propertyType: string, optional: boolean): Generator<Code>;
8
8
  export declare function getTemplateUsageVars(options: ScriptCodegenOptions, ctx: ScriptCodegenContext): Set<string>;
@@ -1,19 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateTemplateDirectives = generateTemplateDirectives;
4
3
  exports.generateTemplate = generateTemplate;
4
+ exports.generateTemplateDirectives = generateTemplateDirectives;
5
5
  exports.generateCssClassProperty = generateCssClassProperty;
6
6
  exports.getTemplateUsageVars = getTemplateUsageVars;
7
+ const path = require("path-browserify");
7
8
  const shared_1 = require("../../utils/shared");
8
- const common_1 = require("../common");
9
9
  const context_1 = require("../template/context");
10
10
  const interpolation_1 = require("../template/interpolation");
11
11
  const styleScopedClasses_1 = require("../template/styleScopedClasses");
12
+ const utils_1 = require("../utils");
12
13
  const index_1 = require("./index");
14
+ function* generateTemplate(options, ctx) {
15
+ ctx.generatedTemplate = true;
16
+ const templateCodegenCtx = (0, context_1.createTemplateCodegenContext)({
17
+ scriptSetupBindingNames: new Set(),
18
+ edited: options.edited,
19
+ });
20
+ yield* generateTemplateCtx(options);
21
+ yield* generateTemplateComponents(options);
22
+ yield* generateTemplateDirectives(options);
23
+ yield* generateTemplateBody(options, templateCodegenCtx);
24
+ return templateCodegenCtx;
25
+ }
13
26
  function* generateTemplateCtx(options) {
14
27
  const exps = [];
15
28
  exps.push(`{} as InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>`);
16
- if (options.vueCompilerOptions.petiteVueExtensions.some(ext => options.fileBaseName.endsWith(ext))) {
29
+ if (options.vueCompilerOptions.petiteVueExtensions.some(ext => options.fileName.endsWith(ext))) {
17
30
  exps.push(`globalThis`);
18
31
  }
19
32
  if (options.sfc.styles.some(style => style.module)) {
@@ -22,100 +35,113 @@ function* generateTemplateCtx(options) {
22
35
  yield `const __VLS_ctx = `;
23
36
  if (exps.length === 1) {
24
37
  yield exps[0];
25
- yield `${common_1.endOfLine}`;
38
+ yield `${utils_1.endOfLine}`;
26
39
  }
27
40
  else {
28
- yield `{${common_1.newLine}`;
41
+ yield `{${utils_1.newLine}`;
29
42
  for (const exp of exps) {
30
43
  yield `...`;
31
44
  yield exp;
32
- yield `,${common_1.newLine}`;
45
+ yield `,${utils_1.newLine}`;
33
46
  }
34
- yield `}${common_1.endOfLine}`;
47
+ yield `}${utils_1.endOfLine}`;
35
48
  }
36
49
  }
37
50
  function* generateTemplateComponents(options) {
38
- const exps = [];
51
+ const types = [];
39
52
  if (options.sfc.script && options.scriptRanges?.exportDefault?.componentsOption) {
40
53
  const { componentsOption } = options.scriptRanges.exportDefault;
41
- exps.push([
42
- options.sfc.script.content.substring(componentsOption.start, componentsOption.end),
54
+ yield `const __VLS_componentsOption = `;
55
+ yield [
56
+ options.sfc.script.content.slice(componentsOption.start, componentsOption.end),
43
57
  'script',
44
58
  componentsOption.start,
45
59
  index_1.codeFeatures.navigation,
46
- ]);
60
+ ];
61
+ yield utils_1.endOfLine;
62
+ types.push(`typeof __VLS_componentsOption`);
47
63
  }
48
64
  let nameType;
49
65
  if (options.sfc.script && options.scriptRanges?.exportDefault?.nameOption) {
50
66
  const { nameOption } = options.scriptRanges.exportDefault;
51
- nameType = options.sfc.script.content.substring(nameOption.start, nameOption.end);
67
+ nameType = options.sfc.script.content.slice(nameOption.start, nameOption.end);
52
68
  }
53
69
  else if (options.sfc.scriptSetup) {
54
- nameType = `'${options.scriptSetupRanges?.options.name ?? options.fileBaseName.substring(0, options.fileBaseName.lastIndexOf('.'))}'`;
70
+ const baseName = path.basename(options.fileName);
71
+ nameType = `'${options.scriptSetupRanges?.defineOptions?.name ?? baseName.slice(0, baseName.lastIndexOf('.'))}'`;
55
72
  }
56
73
  if (nameType) {
57
- exps.push(`{} as {
58
- [K in ${nameType}]: typeof __VLS_self
59
- & (new () => {
60
- ${(0, shared_1.getSlotsPropertyName)(options.vueCompilerOptions.target)}: typeof ${options.scriptSetupRanges?.slots?.name ?? '__VLS_slots'}
61
- })
62
- }`);
63
- }
64
- exps.push(`{} as NonNullable<typeof __VLS_self extends { components: infer C } ? C : {}>`);
65
- exps.push(`__VLS_ctx`);
66
- yield `const __VLS_localComponents = {${common_1.newLine}`;
67
- for (const type of exps) {
68
- yield `...`;
74
+ types.push(`{ [K in ${nameType}]: typeof __VLS_self & (new () => { `
75
+ + (0, shared_1.getSlotsPropertyName)(options.vueCompilerOptions.target)
76
+ + `: typeof ${options.scriptSetupRanges?.defineSlots?.name ?? `__VLS_slots`} }) }`);
77
+ }
78
+ types.push(`typeof __VLS_ctx`);
79
+ yield `type __VLS_LocalComponents =`;
80
+ for (const type of types) {
81
+ yield ` & `;
69
82
  yield type;
70
- yield `,${common_1.newLine}`;
71
83
  }
72
- yield `}${common_1.endOfLine}`;
73
- yield `let __VLS_components!: typeof __VLS_localComponents & __VLS_GlobalComponents${common_1.endOfLine}`;
84
+ yield utils_1.endOfLine;
85
+ yield `let __VLS_components!: __VLS_LocalComponents & __VLS_GlobalComponents${utils_1.endOfLine}`;
74
86
  }
75
87
  function* generateTemplateDirectives(options) {
76
- const exps = [];
88
+ const types = [];
77
89
  if (options.sfc.script && options.scriptRanges?.exportDefault?.directivesOption) {
78
90
  const { directivesOption } = options.scriptRanges.exportDefault;
79
- exps.push([
80
- options.sfc.script.content.substring(directivesOption.start, directivesOption.end),
91
+ yield `const __VLS_directivesOption = `;
92
+ yield [
93
+ options.sfc.script.content.slice(directivesOption.start, directivesOption.end),
81
94
  'script',
82
95
  directivesOption.start,
83
96
  index_1.codeFeatures.navigation,
84
- ]);
85
- }
86
- exps.push(`{} as NonNullable<typeof __VLS_self extends { directives: infer D } ? D : {}>`);
87
- exps.push(`__VLS_ctx`);
88
- yield `const __VLS_localDirectives = {${common_1.newLine}`;
89
- for (const type of exps) {
90
- yield `...`;
97
+ ];
98
+ yield utils_1.endOfLine;
99
+ types.push(`typeof __VLS_directivesOption`);
100
+ }
101
+ types.push(`typeof __VLS_ctx`);
102
+ yield `type __VLS_LocalDirectives =`;
103
+ for (const type of types) {
104
+ yield ` & `;
91
105
  yield type;
92
- yield `,${common_1.newLine}`;
93
106
  }
94
- yield `}${common_1.endOfLine}`;
95
- yield `let __VLS_directives!: typeof __VLS_localDirectives & __VLS_GlobalDirectives${common_1.endOfLine}`;
96
- }
97
- function* generateTemplate(options, ctx) {
98
- ctx.generatedTemplate = true;
99
- const templateCodegenCtx = (0, context_1.createTemplateCodegenContext)({
100
- scriptSetupBindingNames: new Set(),
101
- edited: options.edited,
102
- });
103
- yield* generateTemplateCtx(options);
104
- yield* generateTemplateComponents(options);
105
- yield* generateTemplateDirectives(options);
106
- yield* generateTemplateBody(options, templateCodegenCtx);
107
- return templateCodegenCtx;
107
+ yield utils_1.endOfLine;
108
+ yield `let __VLS_directives!: __VLS_LocalDirectives & __VLS_GlobalDirectives${utils_1.endOfLine}`;
108
109
  }
109
110
  function* generateTemplateBody(options, templateCodegenCtx) {
111
+ yield* generateStyleScopedClasses(options, templateCodegenCtx);
112
+ yield* (0, styleScopedClasses_1.generateStyleScopedClassReferences)(templateCodegenCtx, true);
113
+ yield* generateCssVars(options, templateCodegenCtx);
114
+ if (options.templateCodegen) {
115
+ for (const code of options.templateCodegen.codes) {
116
+ yield code;
117
+ }
118
+ }
119
+ else {
120
+ yield `// no template${utils_1.newLine}`;
121
+ if (!options.scriptSetupRanges?.defineSlots) {
122
+ yield `const __VLS_slots = {}${utils_1.endOfLine}`;
123
+ }
124
+ yield `const __VLS_inheritedAttrs = {}${utils_1.endOfLine}`;
125
+ yield `const $refs = {}${utils_1.endOfLine}`;
126
+ yield `const $el = {} as any${utils_1.endOfLine}`;
127
+ }
128
+ yield `return {${utils_1.newLine}`;
129
+ yield ` attrs: {} as Partial<typeof __VLS_inheritedAttrs>,${utils_1.newLine}`;
130
+ yield ` slots: ${options.scriptSetupRanges?.defineSlots?.name ?? '__VLS_slots'},${utils_1.newLine}`;
131
+ yield ` refs: $refs,${utils_1.newLine}`;
132
+ yield ` rootEl: $el,${utils_1.newLine}`;
133
+ yield `}${utils_1.endOfLine}`;
134
+ }
135
+ function* generateStyleScopedClasses(options, ctx) {
110
136
  const firstClasses = new Set();
111
- yield `let __VLS_styleScopedClasses!: {}`;
137
+ yield `type __VLS_StyleScopedClasses = {}`;
112
138
  for (let i = 0; i < options.sfc.styles.length; i++) {
113
139
  const style = options.sfc.styles[i];
114
140
  const option = options.vueCompilerOptions.experimentalResolveStyleCssClasses;
115
141
  if (option === 'always' || (option === 'scoped' && style.scoped)) {
116
142
  for (const className of style.classNames) {
117
143
  if (firstClasses.has(className.text)) {
118
- templateCodegenCtx.scopedClasses.push({
144
+ ctx.scopedClasses.push({
119
145
  source: 'style_' + i,
120
146
  className: className.text.slice(1),
121
147
  offset: className.offset + 1
@@ -127,32 +153,10 @@ function* generateTemplateBody(options, templateCodegenCtx) {
127
153
  }
128
154
  }
129
155
  }
130
- yield common_1.endOfLine;
131
- yield* (0, styleScopedClasses_1.generateStyleScopedClasses)(templateCodegenCtx, true);
132
- yield* generateCssVars(options, templateCodegenCtx);
133
- if (options.templateCodegen) {
134
- for (const code of options.templateCodegen.codes) {
135
- yield code;
136
- }
137
- }
138
- else {
139
- yield `// no template${common_1.newLine}`;
140
- if (!options.scriptSetupRanges?.slots.define) {
141
- yield `const __VLS_slots = {}${common_1.endOfLine}`;
142
- }
143
- yield `const __VLS_inheritedAttrs = {}${common_1.endOfLine}`;
144
- yield `const $refs = {}${common_1.endOfLine}`;
145
- yield `const $el = {} as any${common_1.endOfLine}`;
146
- }
147
- yield `return {${common_1.newLine}`;
148
- yield ` attrs: {} as Partial<typeof __VLS_inheritedAttrs>,${common_1.newLine}`;
149
- yield ` slots: ${options.scriptSetupRanges?.slots.name ?? '__VLS_slots'},${common_1.newLine}`;
150
- yield ` refs: $refs,${common_1.newLine}`;
151
- yield ` rootEl: $el,${common_1.newLine}`;
152
- yield `}${common_1.endOfLine}`;
156
+ yield utils_1.endOfLine;
153
157
  }
154
158
  function* generateCssClassProperty(styleIndex, classNameWithDot, offset, propertyType, optional) {
155
- yield `${common_1.newLine} & { `;
159
+ yield `${utils_1.newLine} & { `;
156
160
  yield [
157
161
  '',
158
162
  'style_' + styleIndex,
@@ -161,7 +165,7 @@ function* generateCssClassProperty(styleIndex, classNameWithDot, offset, propert
161
165
  ];
162
166
  yield `'`;
163
167
  yield [
164
- classNameWithDot.substring(1),
168
+ classNameWithDot.slice(1),
165
169
  'style_' + styleIndex,
166
170
  offset + 1,
167
171
  index_1.codeFeatures.navigation,
@@ -180,28 +184,14 @@ function* generateCssVars(options, ctx) {
180
184
  if (!options.sfc.styles.length) {
181
185
  return;
182
186
  }
183
- yield `// CSS variable injection ${common_1.newLine}`;
187
+ yield `// CSS variable injection ${utils_1.newLine}`;
184
188
  for (const style of options.sfc.styles) {
185
189
  for (const cssBind of style.cssVars) {
186
- for (const [segment, offset, onlyError] of (0, interpolation_1.forEachInterpolationSegment)(options.ts, undefined, undefined, ctx, cssBind.text, cssBind.offset, options.ts.createSourceFile('/a.txt', cssBind.text, 99))) {
187
- if (offset === undefined) {
188
- yield segment;
189
- }
190
- else {
191
- yield [
192
- segment,
193
- style.name,
194
- cssBind.offset + offset,
195
- onlyError
196
- ? index_1.codeFeatures.navigation
197
- : index_1.codeFeatures.all,
198
- ];
199
- }
200
- }
201
- yield common_1.endOfLine;
190
+ yield* (0, interpolation_1.generateInterpolation)(options, ctx, style.name, index_1.codeFeatures.all, cssBind.text, cssBind.offset);
191
+ yield utils_1.endOfLine;
202
192
  }
203
193
  }
204
- yield `// CSS variable injection end ${common_1.newLine}`;
194
+ yield `// CSS variable injection end ${utils_1.newLine}`;
205
195
  }
206
196
  function getTemplateUsageVars(options, ctx) {
207
197
  const usageVars = new Set();
@@ -214,7 +204,7 @@ function getTemplateUsageVars(options, ctx) {
214
204
  }
215
205
  }
216
206
  for (const component of components) {
217
- if (component.indexOf('.') >= 0) {
207
+ if (component.includes('.')) {
218
208
  usageVars.add(component.split('.')[0]);
219
209
  }
220
210
  }
@@ -1,7 +1,7 @@
1
1
  import type * as CompilerDOM from '@vue/compiler-dom';
2
2
  import type { Code, VueCodeInformation } from '../../types';
3
- import type { TemplateCodegenOptions } from './index';
4
3
  import { InlayHintInfo } from '../inlayHints';
4
+ import type { TemplateCodegenOptions } from './index';
5
5
  export type TemplateCodegenContext = ReturnType<typeof createTemplateCodegenContext>;
6
6
  export declare function createTemplateCodegenContext(options: Pick<TemplateCodegenOptions, 'scriptSetupBindingNames' | 'edited'>): {
7
7
  slots: {
@@ -24,14 +24,18 @@ export declare function createTemplateCodegenContext(options: Pick<TemplateCodeg
24
24
  navigationWithoutRename: VueCodeInformation;
25
25
  navigationAndCompletion: VueCodeInformation;
26
26
  navigationAndAdditionalCompletion: VueCodeInformation;
27
+ withoutNavigation: VueCodeInformation;
27
28
  withoutHighlight: VueCodeInformation;
28
29
  withoutHighlightAndCompletion: VueCodeInformation;
29
30
  withoutHighlightAndCompletionAndNavigation: VueCodeInformation;
30
31
  };
31
32
  accessExternalVariables: Map<string, Set<number>>;
33
+ lastGenericComment: {
34
+ content: string;
35
+ offset: number;
36
+ } | undefined;
32
37
  hasSlotElements: Set<CompilerDOM.ElementNode>;
33
38
  blockConditions: string[];
34
- usedComponentCtxVars: Set<string>;
35
39
  scopedClasses: {
36
40
  source: string;
37
41
  className: string;
@@ -40,8 +44,14 @@ export declare function createTemplateCodegenContext(options: Pick<TemplateCodeg
40
44
  emptyClassOffsets: number[];
41
45
  inlayHints: InlayHintInfo[];
42
46
  hasSlot: boolean;
43
- inheritedAttrVars: Set<unknown>;
47
+ bindingAttrLocs: CompilerDOM.SourceLocation[];
48
+ inheritedAttrVars: Set<string>;
44
49
  templateRefs: Map<string, [varName: string, offset: number]>;
50
+ currentComponent: {
51
+ node: CompilerDOM.ElementNode;
52
+ ctxVar: string;
53
+ used: boolean;
54
+ } | undefined;
45
55
  singleRootElType: string | undefined;
46
56
  singleRootNode: CompilerDOM.ElementNode | undefined;
47
57
  accessExternalVariable(name: string, offset?: number): void;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTemplateCodegenContext = createTemplateCodegenContext;
4
- const common_1 = require("../common");
4
+ const utils_1 = require("../utils");
5
5
  const _codeFeatures = {
6
6
  all: {
7
7
  verification: true,
@@ -36,6 +36,11 @@ const _codeFeatures = {
36
36
  navigation: true,
37
37
  completion: { isAdditional: true },
38
38
  },
39
+ withoutNavigation: {
40
+ verification: true,
41
+ completion: true,
42
+ semantic: true,
43
+ },
39
44
  withoutHighlight: {
40
45
  semantic: { shouldHighlight: () => false },
41
46
  verification: true,
@@ -55,6 +60,7 @@ const _codeFeatures = {
55
60
  function createTemplateCodegenContext(options) {
56
61
  let ignoredError = false;
57
62
  let expectErrorToken;
63
+ let lastGenericComment;
58
64
  let variableId = 0;
59
65
  const codeFeatures = new Proxy(_codeFeatures, {
60
66
  get(target, key) {
@@ -91,25 +97,28 @@ function createTemplateCodegenContext(options) {
91
97
  const hasSlotElements = new Set();
92
98
  ;
93
99
  const blockConditions = [];
94
- const usedComponentCtxVars = new Set();
95
100
  const scopedClasses = [];
96
101
  const emptyClassOffsets = [];
97
102
  const inlayHints = [];
103
+ const bindingAttrLocs = [];
104
+ const inheritedAttrVars = new Set();
98
105
  const templateRefs = new Map();
99
106
  return {
100
107
  slots,
101
108
  dynamicSlots,
102
109
  codeFeatures,
103
110
  accessExternalVariables,
111
+ lastGenericComment,
104
112
  hasSlotElements,
105
113
  blockConditions,
106
- usedComponentCtxVars,
107
114
  scopedClasses,
108
115
  emptyClassOffsets,
109
116
  inlayHints,
110
117
  hasSlot: false,
111
- inheritedAttrVars: new Set(),
118
+ bindingAttrLocs,
119
+ inheritedAttrVars,
112
120
  templateRefs,
121
+ currentComponent: undefined,
113
122
  singleRootElType: undefined,
114
123
  singleRootNode: undefined,
115
124
  accessExternalVariable(name, offset) {
@@ -136,7 +145,7 @@ function createTemplateCodegenContext(options) {
136
145
  ignoreError: function* () {
137
146
  if (!ignoredError) {
138
147
  ignoredError = true;
139
- yield `// @vue-ignore start${common_1.newLine}`;
148
+ yield `// @vue-ignore start${utils_1.newLine}`;
140
149
  }
141
150
  },
142
151
  expectError: function* (prevNode) {
@@ -145,24 +154,24 @@ function createTemplateCodegenContext(options) {
145
154
  errors: 0,
146
155
  node: prevNode,
147
156
  };
148
- yield `// @vue-expect-error start${common_1.newLine}`;
157
+ yield `// @vue-expect-error start${utils_1.newLine}`;
149
158
  }
150
159
  },
151
160
  resetDirectiveComments: function* (endStr) {
152
161
  if (expectErrorToken) {
153
162
  const token = expectErrorToken;
154
- yield* (0, common_1.wrapWith)(expectErrorToken.node.loc.start.offset, expectErrorToken.node.loc.end.offset, {
163
+ yield* (0, utils_1.wrapWith)(expectErrorToken.node.loc.start.offset, expectErrorToken.node.loc.end.offset, {
155
164
  verification: {
156
165
  shouldReport: () => token.errors === 0,
157
166
  },
158
167
  }, `// @ts-expect-error __VLS_TS_EXPECT_ERROR`);
159
- yield `${common_1.newLine}${common_1.endOfLine}`;
168
+ yield `${utils_1.newLine}${utils_1.endOfLine}`;
160
169
  expectErrorToken = undefined;
161
- yield `// @vue-expect-error ${endStr}${common_1.newLine}`;
170
+ yield `// @vue-expect-error ${endStr}${utils_1.newLine}`;
162
171
  }
163
172
  if (ignoredError) {
164
173
  ignoredError = false;
165
- yield `// @vue-ignore ${endStr}${common_1.newLine}`;
174
+ yield `// @vue-ignore ${endStr}${utils_1.newLine}`;
166
175
  }
167
176
  },
168
177
  generateAutoImportCompletion: function* () {
@@ -173,7 +182,7 @@ function createTemplateCodegenContext(options) {
173
182
  if (!all.some(([_, offsets]) => offsets.size)) {
174
183
  return;
175
184
  }
176
- yield `// @ts-ignore${common_1.newLine}`; // #2304
185
+ yield `// @ts-ignore${utils_1.newLine}`; // #2304
177
186
  yield `[`;
178
187
  for (const [varName, offsets] of all) {
179
188
  for (const offset of offsets) {
@@ -201,7 +210,7 @@ function createTemplateCodegenContext(options) {
201
210
  }
202
211
  offsets.clear();
203
212
  }
204
- yield `]${common_1.endOfLine}`;
213
+ yield `]${utils_1.endOfLine}`;
205
214
  }
206
215
  };
207
216
  }
@@ -2,7 +2,5 @@ import * as CompilerDOM from '@vue/compiler-dom';
2
2
  import type { Code } from '../../types';
3
3
  import type { TemplateCodegenContext } from './context';
4
4
  import type { TemplateCodegenOptions } from './index';
5
- export declare function generateComponent(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode, currentComponent: CompilerDOM.ElementNode | undefined): Generator<Code>;
6
- export declare function generateElement(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode, currentComponent: CompilerDOM.ElementNode | undefined, componentCtxVar: string | undefined, isVForChild: boolean): Generator<Code>;
7
- export declare function getCanonicalComponentName(tagText: string): string;
8
- export declare function getPossibleOriginalComponentNames(tagText: string, deduplicate: boolean): string[];
5
+ export declare function generateComponent(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode): Generator<Code>;
6
+ export declare function generateElement(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode, isVForChild: boolean): Generator<Code>;