@vue/language-core 2.1.10 → 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 (75) hide show
  1. package/lib/codegen/globalTypes.js +11 -2
  2. package/lib/codegen/localTypes.js +3 -3
  3. package/lib/codegen/script/component.js +42 -42
  4. package/lib/codegen/script/componentSelf.js +13 -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 +19 -37
  8. package/lib/codegen/script/scriptSetup.js +240 -197
  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 +86 -98
  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 -83
  49. package/lib/parsers/scriptSetupRanges.js +193 -167
  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 -74
  60. package/lib/plugins/vue-tsx.js +65 -68
  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/utils/findDestructuredProps.d.ts +0 -1
  73. package/lib/utils/findDestructuredProps.js +0 -3
  74. /package/lib/codegen/{template → utils}/camelized.d.ts +0 -0
  75. /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 && !options.scriptSetupRanges?.cssModules.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,16 +1,28 @@
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
7
  const path = require("path-browserify");
8
8
  const shared_1 = require("../../utils/shared");
9
- const common_1 = require("../common");
10
9
  const context_1 = require("../template/context");
11
10
  const interpolation_1 = require("../template/interpolation");
12
11
  const styleScopedClasses_1 = require("../template/styleScopedClasses");
12
+ const utils_1 = require("../utils");
13
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
+ }
14
26
  function* generateTemplateCtx(options) {
15
27
  const exps = [];
16
28
  exps.push(`{} as InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>`);
@@ -23,101 +35,113 @@ function* generateTemplateCtx(options) {
23
35
  yield `const __VLS_ctx = `;
24
36
  if (exps.length === 1) {
25
37
  yield exps[0];
26
- yield `${common_1.endOfLine}`;
38
+ yield `${utils_1.endOfLine}`;
27
39
  }
28
40
  else {
29
- yield `{${common_1.newLine}`;
41
+ yield `{${utils_1.newLine}`;
30
42
  for (const exp of exps) {
31
43
  yield `...`;
32
44
  yield exp;
33
- yield `,${common_1.newLine}`;
45
+ yield `,${utils_1.newLine}`;
34
46
  }
35
- yield `}${common_1.endOfLine}`;
47
+ yield `}${utils_1.endOfLine}`;
36
48
  }
37
49
  }
38
50
  function* generateTemplateComponents(options) {
39
- const exps = [];
51
+ const types = [];
40
52
  if (options.sfc.script && options.scriptRanges?.exportDefault?.componentsOption) {
41
53
  const { componentsOption } = options.scriptRanges.exportDefault;
42
- exps.push([
43
- 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),
44
57
  'script',
45
58
  componentsOption.start,
46
59
  index_1.codeFeatures.navigation,
47
- ]);
60
+ ];
61
+ yield utils_1.endOfLine;
62
+ types.push(`typeof __VLS_componentsOption`);
48
63
  }
49
64
  let nameType;
50
65
  if (options.sfc.script && options.scriptRanges?.exportDefault?.nameOption) {
51
66
  const { nameOption } = options.scriptRanges.exportDefault;
52
- nameType = options.sfc.script.content.substring(nameOption.start, nameOption.end);
67
+ nameType = options.sfc.script.content.slice(nameOption.start, nameOption.end);
53
68
  }
54
69
  else if (options.sfc.scriptSetup) {
55
70
  const baseName = path.basename(options.fileName);
56
- nameType = `'${options.scriptSetupRanges?.options.name ?? baseName.substring(0, baseName.lastIndexOf('.'))}'`;
71
+ nameType = `'${options.scriptSetupRanges?.defineOptions?.name ?? baseName.slice(0, baseName.lastIndexOf('.'))}'`;
57
72
  }
58
73
  if (nameType) {
59
- exps.push(`{} as {
60
- [K in ${nameType}]: typeof __VLS_self
61
- & (new () => {
62
- ${(0, shared_1.getSlotsPropertyName)(options.vueCompilerOptions.target)}: typeof ${options.scriptSetupRanges?.slots?.name ?? '__VLS_slots'}
63
- })
64
- }`);
65
- }
66
- exps.push(`{} as NonNullable<typeof __VLS_self extends { components: infer C } ? C : {}>`);
67
- exps.push(`__VLS_ctx`);
68
- yield `const __VLS_localComponents = {${common_1.newLine}`;
69
- for (const type of exps) {
70
- 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 ` & `;
71
82
  yield type;
72
- yield `,${common_1.newLine}`;
73
83
  }
74
- yield `}${common_1.endOfLine}`;
75
- 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}`;
76
86
  }
77
87
  function* generateTemplateDirectives(options) {
78
- const exps = [];
88
+ const types = [];
79
89
  if (options.sfc.script && options.scriptRanges?.exportDefault?.directivesOption) {
80
90
  const { directivesOption } = options.scriptRanges.exportDefault;
81
- exps.push([
82
- 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),
83
94
  'script',
84
95
  directivesOption.start,
85
96
  index_1.codeFeatures.navigation,
86
- ]);
87
- }
88
- exps.push(`{} as NonNullable<typeof __VLS_self extends { directives: infer D } ? D : {}>`);
89
- exps.push(`__VLS_ctx`);
90
- yield `const __VLS_localDirectives = {${common_1.newLine}`;
91
- for (const type of exps) {
92
- 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 ` & `;
93
105
  yield type;
94
- yield `,${common_1.newLine}`;
95
106
  }
96
- yield `}${common_1.endOfLine}`;
97
- yield `let __VLS_directives!: typeof __VLS_localDirectives & __VLS_GlobalDirectives${common_1.endOfLine}`;
98
- }
99
- function* generateTemplate(options, ctx) {
100
- ctx.generatedTemplate = true;
101
- const templateCodegenCtx = (0, context_1.createTemplateCodegenContext)({
102
- scriptSetupBindingNames: new Set(),
103
- edited: options.edited,
104
- });
105
- yield* generateTemplateCtx(options);
106
- yield* generateTemplateComponents(options);
107
- yield* generateTemplateDirectives(options);
108
- yield* generateTemplateBody(options, templateCodegenCtx);
109
- return templateCodegenCtx;
107
+ yield utils_1.endOfLine;
108
+ yield `let __VLS_directives!: __VLS_LocalDirectives & __VLS_GlobalDirectives${utils_1.endOfLine}`;
110
109
  }
111
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) {
112
136
  const firstClasses = new Set();
113
- yield `let __VLS_styleScopedClasses!: {}`;
137
+ yield `type __VLS_StyleScopedClasses = {}`;
114
138
  for (let i = 0; i < options.sfc.styles.length; i++) {
115
139
  const style = options.sfc.styles[i];
116
140
  const option = options.vueCompilerOptions.experimentalResolveStyleCssClasses;
117
141
  if (option === 'always' || (option === 'scoped' && style.scoped)) {
118
142
  for (const className of style.classNames) {
119
143
  if (firstClasses.has(className.text)) {
120
- templateCodegenCtx.scopedClasses.push({
144
+ ctx.scopedClasses.push({
121
145
  source: 'style_' + i,
122
146
  className: className.text.slice(1),
123
147
  offset: className.offset + 1
@@ -129,32 +153,10 @@ function* generateTemplateBody(options, templateCodegenCtx) {
129
153
  }
130
154
  }
131
155
  }
132
- yield common_1.endOfLine;
133
- yield* (0, styleScopedClasses_1.generateStyleScopedClasses)(templateCodegenCtx, true);
134
- yield* generateCssVars(options, templateCodegenCtx);
135
- if (options.templateCodegen) {
136
- for (const code of options.templateCodegen.codes) {
137
- yield code;
138
- }
139
- }
140
- else {
141
- yield `// no template${common_1.newLine}`;
142
- if (!options.scriptSetupRanges?.slots.define) {
143
- yield `const __VLS_slots = {}${common_1.endOfLine}`;
144
- }
145
- yield `const __VLS_inheritedAttrs = {}${common_1.endOfLine}`;
146
- yield `const $refs = {}${common_1.endOfLine}`;
147
- yield `const $el = {} as any${common_1.endOfLine}`;
148
- }
149
- yield `return {${common_1.newLine}`;
150
- yield ` attrs: {} as Partial<typeof __VLS_inheritedAttrs>,${common_1.newLine}`;
151
- yield ` slots: ${options.scriptSetupRanges?.slots.name ?? '__VLS_slots'},${common_1.newLine}`;
152
- yield ` refs: $refs,${common_1.newLine}`;
153
- yield ` rootEl: $el,${common_1.newLine}`;
154
- yield `}${common_1.endOfLine}`;
156
+ yield utils_1.endOfLine;
155
157
  }
156
158
  function* generateCssClassProperty(styleIndex, classNameWithDot, offset, propertyType, optional) {
157
- yield `${common_1.newLine} & { `;
159
+ yield `${utils_1.newLine} & { `;
158
160
  yield [
159
161
  '',
160
162
  'style_' + styleIndex,
@@ -163,7 +165,7 @@ function* generateCssClassProperty(styleIndex, classNameWithDot, offset, propert
163
165
  ];
164
166
  yield `'`;
165
167
  yield [
166
- classNameWithDot.substring(1),
168
+ classNameWithDot.slice(1),
167
169
  'style_' + styleIndex,
168
170
  offset + 1,
169
171
  index_1.codeFeatures.navigation,
@@ -182,28 +184,14 @@ function* generateCssVars(options, ctx) {
182
184
  if (!options.sfc.styles.length) {
183
185
  return;
184
186
  }
185
- yield `// CSS variable injection ${common_1.newLine}`;
187
+ yield `// CSS variable injection ${utils_1.newLine}`;
186
188
  for (const style of options.sfc.styles) {
187
189
  for (const cssBind of style.cssVars) {
188
- 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))) {
189
- if (offset === undefined) {
190
- yield segment;
191
- }
192
- else {
193
- yield [
194
- segment,
195
- style.name,
196
- cssBind.offset + offset,
197
- onlyError
198
- ? index_1.codeFeatures.navigation
199
- : index_1.codeFeatures.all,
200
- ];
201
- }
202
- }
203
- 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;
204
192
  }
205
193
  }
206
- yield `// CSS variable injection end ${common_1.newLine}`;
194
+ yield `// CSS variable injection end ${utils_1.newLine}`;
207
195
  }
208
196
  function getTemplateUsageVars(options, ctx) {
209
197
  const usageVars = new Set();
@@ -216,7 +204,7 @@ function getTemplateUsageVars(options, ctx) {
216
204
  }
217
205
  }
218
206
  for (const component of components) {
219
- if (component.indexOf('.') >= 0) {
207
+ if (component.includes('.')) {
220
208
  usageVars.add(component.split('.')[0]);
221
209
  }
222
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>;