@vue/language-core 3.3.7 → 3.3.8

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.
package/README.md CHANGED
@@ -110,6 +110,7 @@ Configure Vue compiler behavior through the `vueCompilerOptions` field in `tscon
110
110
  | :--- | :--- | :--- | :--- |
111
111
  | `lib` | `string` | `'vue'` | Vue package name, used for generating import statements. |
112
112
  | `skipTemplateCodegen` | `boolean` | `false` | Skip virtual code generation for templates. |
113
+ | `vapor` | `boolean` | `false` | Enable Vapor mode for all Vue SFCs. |
113
114
  | `fallthroughAttributes` | `boolean` | `false` | Enable type inference for fallthrough attributes. |
114
115
  | `checkRequiredFallthroughAttributes` | `boolean` | `false` | Check required fallthrough attributes. |
115
116
  | `jsxSlots` | `boolean` | `false` | Use JSX-style slots types. |
@@ -61,7 +61,7 @@ function* generateWorker(options, ctx) {
61
61
  src = src.slice(0, -'.tsx'.length) + '.jsx';
62
62
  }
63
63
  yield `import ${names_1.names.src} from `;
64
- const boundary = yield* boundary_1.Boundary.start('main', script.src.offset, {
64
+ const boundary = yield* boundary_1.Boundary.start('main', script.src.offset, script.src.offset + script.src.text.length, {
65
65
  ...codeFeatures_1.codeFeatures.all,
66
66
  ...src !== script.src.text ? codeFeatures_1.codeFeatures.navigationWithoutRename : {},
67
67
  });
@@ -69,7 +69,7 @@ function* generateWorker(options, ctx) {
69
69
  yield [src.slice(0, script.src.text.length), 'main', script.src.offset, boundary.features];
70
70
  yield src.slice(script.src.text.length);
71
71
  yield `'`;
72
- yield boundary.end(script.src.offset + script.src.text.length);
72
+ yield boundary.end();
73
73
  yield utils_1.endOfLine;
74
74
  yield `export default ${names_1.names.src}${utils_1.endOfLine}`;
75
75
  yield* (0, template_1.generateTemplate)(options, ctx, names_1.names.src);
@@ -194,9 +194,9 @@ function* generateGlobalTypesReference({ typesRoot, lib, target, checkUnknownPro
194
194
  }
195
195
  function* generateExportDeclareEqual(block, name) {
196
196
  yield `const `;
197
- const boundary = yield* boundary_1.Boundary.start(block.name, 0, codeFeatures_1.codeFeatures.doNotReportTs6133);
197
+ const boundary = yield* boundary_1.Boundary.start(block.name, 0, block.content.length, codeFeatures_1.codeFeatures.doNotReportTs6133);
198
198
  yield name;
199
- yield boundary.end(block.content.length);
199
+ yield boundary.end();
200
200
  yield ` = `;
201
201
  }
202
202
  //# sourceMappingURL=index.js.map
@@ -161,9 +161,9 @@ function* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, bo
161
161
  else {
162
162
  transforms.push((0, transform_1.insert)(callExp.end, function* () {
163
163
  yield ` as ${type}[`;
164
- const boundary = yield* boundary_1.Boundary.start(scriptSetup.name, exp.start, codeFeatures_1.codeFeatures.verification);
164
+ const boundary = yield* boundary_1.Boundary.start(scriptSetup.name, exp.start, exp.end, codeFeatures_1.codeFeatures.verification);
165
165
  yield `'$style'`;
166
- yield boundary.end(exp.end);
166
+ yield boundary.end();
167
167
  yield `])`;
168
168
  }));
169
169
  }
@@ -7,22 +7,22 @@ const utils_1 = require("../utils");
7
7
  const boundary_1 = require("../utils/boundary");
8
8
  function* generateClassProperty(source, classNameWithDot, offset, propertyType) {
9
9
  yield `${utils_1.newLine} & { `;
10
- const boundary = yield* boundary_1.Boundary.start(source, offset, codeFeatures_1.codeFeatures.navigation);
10
+ const boundary = yield* boundary_1.Boundary.start(source, offset, offset + classNameWithDot.length, codeFeatures_1.codeFeatures.navigation);
11
11
  yield `'`;
12
12
  yield [classNameWithDot.slice(1), source, offset + 1, boundary.features];
13
13
  yield `'`;
14
- yield boundary.end(offset + classNameWithDot.length);
14
+ yield boundary.end();
15
15
  yield `: ${propertyType}`;
16
16
  yield ` }`;
17
17
  }
18
18
  function* generateStyleImports(style) {
19
19
  if (typeof style.src === 'object') {
20
20
  yield `${utils_1.newLine} & typeof import(`;
21
- const boundary = yield* boundary_1.Boundary.start('main', style.src.offset, codeFeatures_1.codeFeatures.navigationAndVerification);
21
+ const boundary = yield* boundary_1.Boundary.start('main', style.src.offset, style.src.offset + style.src.text.length, codeFeatures_1.codeFeatures.navigationAndVerification);
22
22
  yield `'`;
23
23
  yield [style.src.text, 'main', style.src.offset, boundary.features];
24
24
  yield `'`;
25
- yield boundary.end(style.src.offset + style.src.text.length);
25
+ yield boundary.end();
26
26
  yield `).default`;
27
27
  }
28
28
  for (const { text, offset } of style.imports) {
@@ -25,9 +25,9 @@ declare function generate(options: StyleCodegenOptions): {
25
25
  getInternalVariable: () => string;
26
26
  scopes: {
27
27
  add(value: string): /*elided*/ any;
28
+ clear(): void;
28
29
  declare(...variables: string[]): void;
29
30
  end(): Generator<Code, any, any>;
30
- clear(): void;
31
31
  delete(value: string): boolean;
32
32
  forEach(callbackfn: (value: string, value2: string, set: Set<string>) => void, thisArg?: any): void;
33
33
  has(value: string): boolean;
@@ -40,9 +40,9 @@ declare function generate(options: StyleCodegenOptions): {
40
40
  }[];
41
41
  scope: () => {
42
42
  add(value: string): any;
43
+ clear(): void;
43
44
  declare(...variables: string[]): void;
44
45
  end(): Generator<Code, any, any>;
45
- clear(): void;
46
46
  delete(value: string): boolean;
47
47
  forEach(callbackfn: (value: string, value2: string, set: Set<string>) => void, thisArg?: any): void;
48
48
  has(value: string): boolean;
@@ -20,9 +20,9 @@ export declare function createTemplateCodegenContext(): {
20
20
  getInternalVariable: () => string;
21
21
  scopes: {
22
22
  add(value: string): /*elided*/ any;
23
+ clear(): void;
23
24
  declare(...variables: string[]): void;
24
25
  end(): Generator<Code, any, any>;
25
- clear(): void;
26
26
  delete(value: string): boolean;
27
27
  forEach(callbackfn: (value: string, value2: string, set: Set<string>) => void, thisArg?: any): void;
28
28
  has(value: string): boolean;
@@ -35,9 +35,9 @@ export declare function createTemplateCodegenContext(): {
35
35
  }[];
36
36
  scope: () => {
37
37
  add(value: string): any;
38
+ clear(): void;
38
39
  declare(...variables: string[]): void;
39
40
  end(): Generator<Code, any, any>;
40
- clear(): void;
41
41
  delete(value: string): boolean;
42
42
  forEach(callbackfn: (value: string, value2: string, set: Set<string>) => void, thisArg?: any): void;
43
43
  has(value: string): boolean;
@@ -94,13 +94,13 @@ function createTemplateCodegenContext() {
94
94
  const info = stack.pop();
95
95
  commentBuffer.length = 0;
96
96
  if (info.expectError !== undefined) {
97
- const boundary = yield* boundary_1.Boundary.start('template', info.expectError.node.loc.start.offset, {
97
+ const boundary = yield* boundary_1.Boundary.start('template', info.expectError.node.loc.start.offset, info.expectError.node.loc.end.offset, {
98
98
  verification: {
99
99
  shouldReport: () => info.expectError.token === 0,
100
100
  },
101
101
  });
102
102
  yield `// @ts-expect-error`;
103
- yield boundary.end(info.expectError.node.loc.end.offset);
103
+ yield boundary.end();
104
104
  yield `${utils_1.newLine}${utils_1.endOfLine}`;
105
105
  }
106
106
  }
@@ -173,22 +173,22 @@ function* generateComponent(options, ctx, node) {
173
173
  yield propsStr;
174
174
  yield `}))${utils_1.endOfLine}`;
175
175
  yield `const `;
176
- const boundary = yield* boundary_1.Boundary.start('template', node.loc.start.offset, codeFeatures_1.codeFeatures.doNotReportTs6133);
176
+ const boundary = yield* boundary_1.Boundary.start('template', node.loc.start.offset, node.loc.end.offset, codeFeatures_1.codeFeatures.doNotReportTs6133);
177
177
  yield vnodeVar;
178
- yield boundary.end(node.loc.end.offset);
178
+ yield boundary.end();
179
179
  yield ` = ${functionalVar}`;
180
180
  const commentInfo = ctx.getCommentInfo();
181
181
  if (commentInfo.generic) {
182
182
  const { content, offset } = commentInfo.generic;
183
- const boundary = yield* boundary_1.Boundary.start('template', offset, codeFeatures_1.codeFeatures.verification);
183
+ const boundary = yield* boundary_1.Boundary.start('template', offset, offset + content.length, codeFeatures_1.codeFeatures.verification);
184
184
  yield `<`;
185
185
  yield [content, 'template', offset, codeFeatures_1.codeFeatures.all];
186
186
  yield `>`;
187
- yield boundary.end(offset + content.length);
187
+ yield boundary.end();
188
188
  }
189
189
  const shouldInheritAttrs = hasVBindAttrs(options, ctx, node);
190
190
  yield `(`;
191
- const boundary2 = yield* boundary_1.Boundary.start('template', startTagOffset, shouldInheritAttrs && options.vueCompilerOptions.checkRequiredFallthroughAttributes
191
+ const boundary2 = yield* boundary_1.Boundary.start('template', startTagOffset, startTagOffset + tag.length, shouldInheritAttrs && options.vueCompilerOptions.checkRequiredFallthroughAttributes
192
192
  ? {}
193
193
  : codeFeatures_1.codeFeatures.verification);
194
194
  yield `{`;
@@ -196,7 +196,7 @@ function* generateComponent(options, ctx, node) {
196
196
  yield utils_1.newLine;
197
197
  yield* propCodes;
198
198
  yield `}`;
199
- yield boundary2.end(startTagOffset + tag.length);
199
+ yield boundary2.end();
200
200
  yield `, ...${names_1.names.functionalComponentArgsRest}(${functionalVar}))${utils_1.endOfLine}`;
201
201
  yield* generateFailedExpressions(options, ctx, failedPropExps);
202
202
  yield* (0, elementEvents_1.generateElementEvents)(options, ctx, node, componentVar, getCtxVar, getPropsVar);
@@ -253,11 +253,11 @@ function* generateElement(options, ctx, node) {
253
253
  yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, node.tag, endTagOffset, codeFeatures_1.codeFeatures.withoutHighlightAndCompletion);
254
254
  }
255
255
  yield `)(`;
256
- const boundary = yield* boundary_1.Boundary.start('template', startTagOffset, codeFeatures_1.codeFeatures.verification);
256
+ const boundary = yield* boundary_1.Boundary.start('template', startTagOffset, startTagOffset + node.tag.length, codeFeatures_1.codeFeatures.verification);
257
257
  yield `{${utils_1.newLine}`;
258
258
  yield* (0, elementProps_1.generateElementProps)(options, ctx, node, node.props, options.vueCompilerOptions.checkUnknownProps, failedPropExps);
259
259
  yield `}`;
260
- yield boundary.end(startTagOffset + node.tag.length);
260
+ yield boundary.end();
261
261
  yield `)${utils_1.endOfLine}`;
262
262
  yield* generateFailedExpressions(options, ctx, failedPropExps);
263
263
  yield* (0, elementDirectives_1.generateElementDirectives)(options, ctx, node);
@@ -285,11 +285,11 @@ function* generateFragment(options, ctx, node) {
285
285
  // special case for <template v-for="..." :key="..." />
286
286
  if (node.props.length) {
287
287
  yield `__VLS_asFunctionalElement(__VLS_intrinsics.template)(`;
288
- const boundary = yield* boundary_1.Boundary.start('template', startTagOffset, codeFeatures_1.codeFeatures.verification);
288
+ const boundary = yield* boundary_1.Boundary.start('template', startTagOffset, startTagOffset + node.tag.length, codeFeatures_1.codeFeatures.verification);
289
289
  yield `{${utils_1.newLine}`;
290
290
  yield* (0, elementProps_1.generateElementProps)(options, ctx, node, node.props, options.vueCompilerOptions.checkUnknownProps);
291
291
  yield `}`;
292
- yield boundary.end(startTagOffset + node.tag.length);
292
+ yield boundary.end();
293
293
  yield `)${utils_1.endOfLine}`;
294
294
  }
295
295
  for (const child of node.children) {
@@ -3,4 +3,4 @@ import type { Code } from '../../types';
3
3
  import type { TemplateCodegenContext } from './context';
4
4
  import type { TemplateCodegenOptions } from './index';
5
5
  export declare function generateElementDirectives(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode): Generator<Code>;
6
- export declare function generateModifiers(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode, propertyName?: string): Generator<Code>;
6
+ export declare function generateModifiers(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode, propertyName?: string, asBindingProperty?: boolean): Generator<Code>;
@@ -55,22 +55,33 @@ function* generateElementDirectives(options, ctx, node) {
55
55
  || prop.name === 'bind') {
56
56
  continue;
57
57
  }
58
- const boundary = yield* boundary_1.Boundary.start('template', prop.loc.start.offset, codeFeatures_1.codeFeatures.verification);
59
- yield `${names_1.names.asFunctionalDirective}(`;
60
- yield* generateIdentifier(options, ctx, prop);
61
- yield `, {} as import('${options.vueCompilerOptions.lib}').ObjectDirective)(null!, { ...${names_1.names.directiveBindingRestFields}, `;
62
- yield* generateArg(options, ctx, prop);
63
- yield* generateModifiers(options, ctx, prop);
64
- yield* generateValue(options, ctx, prop);
65
- yield ` }, null!, null!)`;
66
- yield boundary.end(prop.loc.end.offset);
58
+ const boundary = yield* boundary_1.Boundary.start('template', prop.loc.start.offset, prop.loc.end.offset, codeFeatures_1.codeFeatures.verification);
59
+ if (options.isVapor && !(0, shared_1.isBuiltInDirective)(prop.name)) {
60
+ // vapor custom directives receive a value getter instead of a vdom binding object
61
+ yield* generateIdentifier(options, ctx, prop);
62
+ yield `(null!, `;
63
+ yield* generateValue(options, ctx, prop, false);
64
+ yield* generateArg(options, ctx, prop, false);
65
+ yield* generateModifiers(options, ctx, prop, 'modifiers', false);
66
+ yield `)`;
67
+ }
68
+ else {
69
+ yield `${names_1.names.asFunctionalDirective}(`;
70
+ yield* generateIdentifier(options, ctx, prop);
71
+ yield `, {} as import('${options.vueCompilerOptions.lib}').ObjectDirective)(null!, { ...${names_1.names.directiveBindingRestFields}, `;
72
+ yield* generateArg(options, ctx, prop);
73
+ yield* generateModifiers(options, ctx, prop);
74
+ yield* generateValue(options, ctx, prop);
75
+ yield `}, null!, null!)`;
76
+ }
77
+ yield boundary.end();
67
78
  yield utils_1.endOfLine;
68
79
  }
69
80
  }
70
81
  function* generateIdentifier(options, ctx, prop) {
71
82
  const rawName = 'v-' + prop.name;
72
83
  const startOffset = prop.loc.start.offset;
73
- const boundary = yield* boundary_1.Boundary.start('template', startOffset, codeFeatures_1.codeFeatures.verification);
84
+ const boundary = yield* boundary_1.Boundary.start('template', startOffset, startOffset + rawName.length, codeFeatures_1.codeFeatures.verification);
74
85
  yield names_1.names.directives;
75
86
  yield `.`;
76
87
  yield* (0, camelized_1.generateCamelized)(rawName, 'template', prop.loc.start.offset, {
@@ -80,52 +91,69 @@ function* generateIdentifier(options, ctx, prop) {
80
91
  if (!(0, shared_1.isBuiltInDirective)(prop.name)) {
81
92
  ctx.accessVariable('template', (0, shared_1.camelize)(rawName), prop.loc.start.offset);
82
93
  }
83
- yield boundary.end(startOffset + rawName.length);
94
+ yield boundary.end();
84
95
  }
85
- function* generateArg(options, ctx, prop) {
96
+ function* generateArg(options, ctx, prop, asBindingProperty = true) {
86
97
  const { arg } = prop;
87
- if (arg?.type !== CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
88
- return;
89
- }
90
- const startOffset = arg.loc.start.offset + arg.loc.source.indexOf(arg.content);
91
- const boundary = yield* boundary_1.Boundary.start('template', startOffset, codeFeatures_1.codeFeatures.verification);
92
- yield `arg`;
93
- yield boundary.end(startOffset + arg.content.length);
94
- yield `: `;
95
- if (arg.isStatic) {
96
- yield* (0, stringLiteralKey_1.generateStringLiteralKey)(arg.content, startOffset, codeFeatures_1.codeFeatures.all);
98
+ if (arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
99
+ const startOffset = arg.loc.start.offset + arg.loc.source.indexOf(arg.content);
100
+ if (asBindingProperty) {
101
+ const boundary = yield* boundary_1.Boundary.start('template', startOffset, startOffset + arg.content.length, codeFeatures_1.codeFeatures.verification);
102
+ yield `arg`;
103
+ yield boundary.end();
104
+ yield `: `;
105
+ }
106
+ if (arg.isStatic) {
107
+ yield* (0, stringLiteralKey_1.generateStringLiteralKey)(arg.content, startOffset, codeFeatures_1.codeFeatures.all);
108
+ }
109
+ else {
110
+ yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, codeFeatures_1.codeFeatures.all, arg.content, startOffset, `(`, `)`);
111
+ }
112
+ yield `, `;
97
113
  }
98
- else {
99
- yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, codeFeatures_1.codeFeatures.all, arg.content, startOffset, `(`, `)`);
114
+ else if (!asBindingProperty) {
115
+ yield `undefined, `;
100
116
  }
101
- yield `, `;
102
117
  }
103
- function* generateModifiers(options, ctx, prop, propertyName = 'modifiers') {
118
+ function* generateModifiers(options, ctx, prop, propertyName = 'modifiers', asBindingProperty = true) {
104
119
  const { modifiers } = prop;
105
- if (!modifiers.length) {
106
- return;
120
+ if (modifiers.length) {
121
+ if (asBindingProperty) {
122
+ const boundary = yield* boundary_1.Boundary.start('template', modifiers[0].loc.start.offset - 1, modifiers.at(-1).loc.end.offset, codeFeatures_1.codeFeatures.verification);
123
+ yield propertyName;
124
+ yield boundary.end();
125
+ yield `: `;
126
+ }
127
+ yield `{ `;
128
+ for (const mod of modifiers) {
129
+ yield* (0, objectProperty_1.generateObjectProperty)(options, ctx, mod.content, mod.loc.start.offset, codeFeatures_1.codeFeatures.withoutHighlight);
130
+ yield `: true, `;
131
+ }
132
+ yield `}, `;
107
133
  }
108
- const startOffset = modifiers[0].loc.start.offset - 1;
109
- const endOffset = modifiers.at(-1).loc.end.offset;
110
- const boundary = yield* boundary_1.Boundary.start('template', startOffset, codeFeatures_1.codeFeatures.verification);
111
- yield propertyName;
112
- yield boundary.end(endOffset);
113
- yield `: { `;
114
- for (const mod of modifiers) {
115
- yield* (0, objectProperty_1.generateObjectProperty)(options, ctx, mod.content, mod.loc.start.offset, codeFeatures_1.codeFeatures.withoutHighlight);
116
- yield `: true, `;
134
+ else if (!asBindingProperty) {
135
+ yield `undefined, `;
117
136
  }
118
- yield `}, `;
119
137
  }
120
- function* generateValue(options, ctx, prop) {
138
+ function* generateValue(options, ctx, prop, asBindingProperty = true) {
121
139
  const { exp } = prop;
122
- if (exp?.type !== CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
123
- return;
140
+ if (exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
141
+ const boundary = yield* boundary_1.Boundary.start('template', exp.loc.start.offset, exp.loc.end.offset, codeFeatures_1.codeFeatures.verification);
142
+ if (asBindingProperty) {
143
+ yield `value`;
144
+ yield boundary.end();
145
+ yield `: `;
146
+ yield* (0, elementProps_1.generatePropExp)(options, ctx, prop, exp);
147
+ }
148
+ else {
149
+ yield `() => `;
150
+ yield* (0, elementProps_1.generatePropExp)(options, ctx, prop, exp);
151
+ yield boundary.end();
152
+ }
153
+ yield `, `;
154
+ }
155
+ else if (!asBindingProperty) {
156
+ yield `undefined, `;
124
157
  }
125
- const boundary = yield* boundary_1.Boundary.start('template', exp.loc.start.offset, codeFeatures_1.codeFeatures.verification);
126
- yield `value`;
127
- yield boundary.end(exp.loc.end.offset);
128
- yield `: `;
129
- yield* (0, elementProps_1.generatePropExp)(options, ctx, prop, exp);
130
158
  }
131
159
  //# sourceMappingURL=elementDirectives.js.map
@@ -129,18 +129,17 @@ function* generateEventArg(options, name, start, directive = 'on', features) {
129
129
  if (directive.length) {
130
130
  name = (0, shared_1.capitalize)(name);
131
131
  }
132
+ const boundary = yield* boundary_1.Boundary.start('template', start, start + name.length, features);
132
133
  if (utils_2.identifierRE.test((0, shared_1.camelize)(name))) {
133
- const boundary = yield* boundary_1.Boundary.start('template', start, features);
134
134
  yield directive;
135
135
  yield* (0, camelized_1.generateCamelized)(name, 'template', start, boundary.features);
136
136
  }
137
137
  else {
138
- const boundary = yield* boundary_1.Boundary.start('template', start, features);
139
138
  yield `'`;
140
139
  yield directive;
141
140
  yield* (0, camelized_1.generateCamelized)(name, 'template', start, boundary.features);
142
141
  yield `'`;
143
- yield boundary.end(start + name.length);
142
+ yield boundary.end();
144
143
  }
145
144
  }
146
145
  function* generateEventExpression(options, ctx, prop) {
@@ -114,21 +114,21 @@ function* generateElementProps(options, ctx, node, props, checkUnknownProps, fai
114
114
  if (shouldSpread) {
115
115
  yield `...{ `;
116
116
  }
117
- const boundary = yield* boundary_1.Boundary.start('template', prop.loc.start.offset, codeFeatures_1.codeFeatures.verification);
117
+ const boundary = yield* boundary_1.Boundary.start('template', prop.loc.start.offset, prop.loc.end.offset, codeFeatures_1.codeFeatures.verification);
118
118
  if (prop.arg) {
119
119
  yield* (0, objectProperty_1.generateObjectProperty)(options, ctx, propName, prop.arg.loc.start.offset, features, shouldCamelize);
120
120
  }
121
121
  else {
122
- const boundary2 = yield* boundary_1.Boundary.start('template', prop.loc.start.offset, codeFeatures_1.codeFeatures.withoutHighlightAndCompletion);
122
+ const boundary2 = yield* boundary_1.Boundary.start('template', prop.loc.start.offset, prop.loc.start.offset + 'v-model'.length, codeFeatures_1.codeFeatures.withoutHighlightAndCompletion);
123
123
  yield propName;
124
- yield boundary2.end(prop.loc.start.offset + 'v-model'.length);
124
+ yield boundary2.end();
125
125
  }
126
126
  yield `: `;
127
127
  const argLoc = prop.arg?.loc ?? prop.loc;
128
- const boundary3 = yield* boundary_1.Boundary.start('template', argLoc.start.offset, codeFeatures_1.codeFeatures.verification);
128
+ const boundary3 = yield* boundary_1.Boundary.start('template', argLoc.start.offset, argLoc.end.offset, codeFeatures_1.codeFeatures.verification);
129
129
  yield* generatePropExp(options, ctx, prop, prop.exp);
130
- yield boundary3.end(argLoc.end.offset);
131
- yield boundary.end(prop.loc.end.offset);
130
+ yield boundary3.end();
131
+ yield boundary.end();
132
132
  if (shouldSpread) {
133
133
  yield ` }`;
134
134
  }
@@ -153,7 +153,7 @@ function* generateElementProps(options, ctx, node, props, checkUnknownProps, fai
153
153
  if (shouldSpread) {
154
154
  yield `...{ `;
155
155
  }
156
- const boundary = yield* boundary_1.Boundary.start('template', prop.loc.start.offset, codeFeatures_1.codeFeatures.verification);
156
+ const boundary = yield* boundary_1.Boundary.start('template', prop.loc.start.offset, prop.loc.end.offset, codeFeatures_1.codeFeatures.verification);
157
157
  const prefix = options.template.content.slice(prop.loc.start.offset, prop.loc.start.offset + 1);
158
158
  if (prefix === '.' || prefix === '#') {
159
159
  // Pug shorthand syntax
@@ -174,7 +174,7 @@ function* generateElementProps(options, ctx, node, props, checkUnknownProps, fai
174
174
  else {
175
175
  yield `true`;
176
176
  }
177
- yield boundary.end(prop.loc.end.offset);
177
+ yield boundary.end();
178
178
  if (shouldSpread) {
179
179
  yield ` }`;
180
180
  }
@@ -187,10 +187,10 @@ function* generateElementProps(options, ctx, node, props, checkUnknownProps, fai
187
187
  failedPropExps?.push({ node: prop.exp, prefix: `(`, suffix: `)` });
188
188
  }
189
189
  else {
190
- const boundary = yield* boundary_1.Boundary.start('template', prop.exp.loc.start.offset, codeFeatures_1.codeFeatures.verification);
190
+ const boundary = yield* boundary_1.Boundary.start('template', prop.exp.loc.start.offset, prop.exp.loc.end.offset, codeFeatures_1.codeFeatures.verification);
191
191
  yield `...`;
192
192
  yield* generatePropExp(options, ctx, prop, prop.exp);
193
- yield boundary.end(prop.exp.loc.end.offset);
193
+ yield boundary.end();
194
194
  yield `,${utils_1.newLine}`;
195
195
  }
196
196
  }
@@ -4,6 +4,7 @@ export interface TemplateCodegenOptions {
4
4
  typescript: typeof ts;
5
5
  vueCompilerOptions: VueCompilerOptions;
6
6
  template: IRTemplate;
7
+ isVapor: boolean;
7
8
  setupRefs: Set<string>;
8
9
  setupConsts: Set<string>;
9
10
  hasDefineSlots?: boolean;
@@ -31,9 +32,9 @@ declare function generate(options: TemplateCodegenOptions): {
31
32
  getInternalVariable: () => string;
32
33
  scopes: {
33
34
  add(value: string): /*elided*/ any;
35
+ clear(): void;
34
36
  declare(...variables: string[]): void;
35
37
  end(): Generator<Code, any, any>;
36
- clear(): void;
37
38
  delete(value: string): boolean;
38
39
  forEach(callbackfn: (value: string, value2: string, set: Set<string>) => void, thisArg?: any): void;
39
40
  has(value: string): boolean;
@@ -46,9 +47,9 @@ declare function generate(options: TemplateCodegenOptions): {
46
47
  }[];
47
48
  scope: () => {
48
49
  add(value: string): any;
50
+ clear(): void;
49
51
  declare(...variables: string[]): void;
50
52
  end(): Generator<Code, any, any>;
51
- clear(): void;
52
53
  delete(value: string): boolean;
53
54
  forEach(callbackfn: (value: string, value2: string, set: Set<string>) => void, thisArg?: any): void;
54
55
  has(value: string): boolean;
@@ -94,9 +94,9 @@ function* generateSlotsType(options, ctx) {
94
94
  yield* (0, objectProperty_1.generateObjectProperty)(options, ctx, slot.name, slot.offset, codeFeatures_1.codeFeatures.navigation);
95
95
  }
96
96
  else {
97
- const boundary = yield* boundary_1.Boundary.start('template', slot.tagRange[0], codeFeatures_1.codeFeatures.navigation);
97
+ const boundary = yield* boundary_1.Boundary.start('template', ...slot.tagRange, codeFeatures_1.codeFeatures.navigation);
98
98
  yield `default`;
99
- yield boundary.end(slot.tagRange[1]);
99
+ yield boundary.end();
100
100
  }
101
101
  yield `?: (props: typeof ${slot.propsVar}) => any }`;
102
102
  }
@@ -45,7 +45,7 @@ function* generateInterpolation({ typescript, setupRefs }, ctx, block, data, cod
45
45
  }
46
46
  else {
47
47
  // #1205, #1264
48
- const boundary = yield* boundary_1.Boundary.start(block.name, start + offset, codeFeatures_1.codeFeatures.verification);
48
+ const boundary = yield* boundary_1.Boundary.start(block.name, start + offset, start + offset + name.length, codeFeatures_1.codeFeatures.verification);
49
49
  if (ctx.dollarVars.has(name)) {
50
50
  yield names_1.names.dollars;
51
51
  }
@@ -62,7 +62,7 @@ function* generateInterpolation({ typescript, setupRefs }, ctx, block, data, cod
62
62
  ? { ...data, __shorthandExpression: 'js' }
63
63
  : data,
64
64
  ];
65
- yield boundary.end(start + offset + name.length);
65
+ yield boundary.end();
66
66
  }
67
67
  prevEnd = offset + name.length;
68
68
  }
@@ -22,11 +22,11 @@ function* generateObjectProperty(options, ctx, code, offset, features, shouldCam
22
22
  yield* (0, camelized_1.generateCamelized)(code, 'template', offset, features);
23
23
  }
24
24
  else {
25
- const boundary = yield* boundary_1.Boundary.start('template', offset, features);
25
+ const boundary = yield* boundary_1.Boundary.start('template', offset, offset + code.length, features);
26
26
  yield `'`;
27
27
  yield* (0, camelized_1.generateCamelized)(code, 'template', offset, boundary.features);
28
28
  yield `'`;
29
- yield boundary.end(offset + code.length);
29
+ yield boundary.end();
30
30
  }
31
31
  }
32
32
  else {
@@ -77,26 +77,26 @@ function* generateSlotOutlet(options, ctx, node) {
77
77
  else {
78
78
  codes = [`['default']`];
79
79
  }
80
- const boundary = yield* boundary_1.Boundary.start('template', nameProp.loc.start.offset, codeFeatures_1.codeFeatures.verification);
80
+ const boundary = yield* boundary_1.Boundary.start('template', nameProp.loc.start.offset, nameProp.loc.end.offset, codeFeatures_1.codeFeatures.verification);
81
81
  yield options.slotsAssignName ?? names_1.names.slots;
82
82
  yield* codes;
83
- yield boundary.end(nameProp.loc.end.offset);
83
+ yield boundary.end();
84
84
  }
85
85
  else {
86
- const boundary = yield* boundary_1.Boundary.start('template', startTagOffset, codeFeatures_1.codeFeatures.verification);
86
+ const boundary = yield* boundary_1.Boundary.start('template', startTagOffset, startTagEndOffset, codeFeatures_1.codeFeatures.verification);
87
87
  yield `${options.slotsAssignName ?? names_1.names.slots}[`;
88
- const boundary2 = yield* boundary_1.Boundary.start('template', startTagOffset, codeFeatures_1.codeFeatures.verification);
88
+ const boundary2 = yield* boundary_1.Boundary.start('template', startTagOffset, startTagEndOffset, codeFeatures_1.codeFeatures.verification);
89
89
  yield `'default'`;
90
- yield boundary2.end(startTagEndOffset);
90
+ yield boundary2.end();
91
91
  yield `]`;
92
- yield boundary.end(startTagEndOffset);
92
+ yield boundary.end();
93
93
  }
94
94
  yield `)(`;
95
- const boundary = yield* boundary_1.Boundary.start('template', startTagOffset, codeFeatures_1.codeFeatures.verification);
95
+ const boundary = yield* boundary_1.Boundary.start('template', startTagOffset, startTagEndOffset, codeFeatures_1.codeFeatures.verification);
96
96
  yield `{${utils_1.newLine}`;
97
97
  yield* (0, elementProps_1.generateElementProps)(options, ctx, node, node.props.filter(prop => prop !== nameProp), true);
98
98
  yield `}`;
99
- yield boundary.end(startTagEndOffset);
99
+ yield boundary.end();
100
100
  yield `)${utils_1.endOfLine}`;
101
101
  }
102
102
  else {
@@ -149,11 +149,11 @@ function* generateStyleScopedClassReference(block, className, offset, fullStart
149
149
  cache[1].push([className, offset]);
150
150
  }
151
151
  yield `/** @type {${names_1.names.StyleScopedClasses}[`;
152
- const boundary = yield* boundary_1.Boundary.start(block.name, fullStart, codeFeatures_1.codeFeatures.navigationAndCompletion);
152
+ const boundary = yield* boundary_1.Boundary.start(block.name, fullStart, offset + className.length, codeFeatures_1.codeFeatures.navigationAndCompletion);
153
153
  yield `'`;
154
154
  yield* (0, escaped_1.generateEscaped)(className, block.name, offset, boundary.features, classNameEscapeRE);
155
155
  yield `'`;
156
- yield boundary.end(offset + className.length);
156
+ yield boundary.end();
157
157
  yield `]} */${utils_1.endOfLine}`;
158
158
  }
159
159
  //# sourceMappingURL=styleScopedClasses.js.map
@@ -53,17 +53,17 @@ function* generateVSlot(options, ctx, node, slotDir, ctxVar) {
53
53
  yield* (0, objectProperty_1.generateObjectProperty)(options, ctx, slotDir.arg.loc.source, slotDir.arg.loc.start.offset, slotDir.arg.isStatic ? codeFeatures_1.codeFeatures.withoutHighlight : codeFeatures_1.codeFeatures.all, false, true);
54
54
  }
55
55
  else {
56
- const boundary = yield* boundary_1.Boundary.start('template', slotDir.loc.start.offset, codeFeatures_1.codeFeatures.withoutHighlightAndCompletion);
56
+ const boundary = yield* boundary_1.Boundary.start('template', slotDir.loc.start.offset, slotDir.loc.start.offset + (slotDir.rawName?.length ?? 0), codeFeatures_1.codeFeatures.withoutHighlightAndCompletion);
57
57
  yield `default`;
58
- yield boundary.end(slotDir.loc.start.offset + (slotDir.rawName?.length ?? 0));
58
+ yield boundary.end();
59
59
  }
60
60
  }
61
61
  else {
62
62
  yield `const { `;
63
63
  // #932: reference for implicit default slot
64
- const boundary = yield* boundary_1.Boundary.start('template', node.loc.start.offset, codeFeatures_1.codeFeatures.navigation);
64
+ const boundary = yield* boundary_1.Boundary.start('template', node.loc.start.offset, node.loc.end.offset, codeFeatures_1.codeFeatures.navigation);
65
65
  yield `default`;
66
- yield boundary.end(node.loc.end.offset);
66
+ yield boundary.end();
67
67
  }
68
68
  yield `: ${slotVar} } = ${ctxVar}.slots!${utils_1.endOfLine}`;
69
69
  const scope = ctx.scope();
@@ -129,11 +129,11 @@ function* generateSlotParameters(options, ctx, ast, exp, slotVar) {
129
129
  yield `] = ${names_1.names.vSlot}(${slotVar}!`;
130
130
  if (types.some(t => t)) {
131
131
  yield `, `;
132
- const boundary = yield* boundary_1.Boundary.start('template', exp.loc.start.offset, codeFeatures_1.codeFeatures.verification);
132
+ const boundary = yield* boundary_1.Boundary.start('template', exp.loc.start.offset, exp.loc.end.offset, codeFeatures_1.codeFeatures.verification);
133
133
  yield `(`;
134
134
  yield* types.flatMap(type => type ? [`_`, type, `, `] : `_, `);
135
135
  yield `) => [] as any`;
136
- yield boundary.end(exp.loc.end.offset);
136
+ yield boundary.end();
137
137
  }
138
138
  yield `)${utils_1.endOfLine}`;
139
139
  }
@@ -1,8 +1,9 @@
1
1
  import type { Code, VueCodeInformation } from '../../types';
2
2
  export declare class Boundary {
3
- source: string;
3
+ private source;
4
+ private endOffset;
4
5
  features: VueCodeInformation;
5
6
  private constructor();
6
- static start(source: string, offset: number, features: VueCodeInformation): Generator<Code, Boundary>;
7
- end(offset: number): Code;
7
+ static start(source: string, start: number, end: number, features: VueCodeInformation): Generator<Code, Boundary>;
8
+ end(): Code;
8
9
  }
@@ -2,17 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Boundary = void 0;
4
4
  class Boundary {
5
- constructor(source, features) {
5
+ constructor(source, endOffset, features) {
6
6
  this.source = source;
7
+ this.endOffset = endOffset;
7
8
  this.features = features;
8
9
  }
9
- static *start(source, offset, features) {
10
+ static *start(source, start, end, features) {
10
11
  features = { ...features, __combineToken: Symbol() };
11
- yield [``, source, offset, features];
12
- return new Boundary(source, features);
12
+ yield [``, source, start, features];
13
+ return new Boundary(source, end, features);
13
14
  }
14
- end(offset) {
15
- return [``, this.source, offset, this.features];
15
+ end() {
16
+ return [``, this.source, this.endOffset, this.features];
16
17
  }
17
18
  }
18
19
  exports.Boundary = Boundary;
@@ -1,2 +1,2 @@
1
1
  import type { Code, VueCodeInformation } from '../../types';
2
- export declare function generateStringLiteralKey(code: string, offset?: number, info?: VueCodeInformation): Generator<Code>;
2
+ export declare function generateStringLiteralKey(code: string, offset: number, features: VueCodeInformation): Generator<Code>;
@@ -2,16 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateStringLiteralKey = generateStringLiteralKey;
4
4
  const boundary_1 = require("./boundary");
5
- function* generateStringLiteralKey(code, offset, info) {
6
- if (offset === undefined || !info) {
7
- yield `'${code}'`;
8
- }
9
- else {
10
- const boundary = yield* boundary_1.Boundary.start('template', offset, info);
11
- yield `'`;
12
- yield [code, 'template', offset, boundary.features];
13
- yield `'`;
14
- yield boundary.end(offset + code.length);
15
- }
5
+ function* generateStringLiteralKey(code, offset, features) {
6
+ const boundary = yield* boundary_1.Boundary.start('template', offset, offset + code.length, features);
7
+ yield `'`;
8
+ yield [code, 'template', offset, boundary.features];
9
+ yield `'`;
10
+ yield boundary.end();
16
11
  }
17
12
  //# sourceMappingURL=stringLiteralKey.js.map
@@ -4,9 +4,9 @@ exports.generateUnicode = generateUnicode;
4
4
  const boundary_1 = require("./boundary");
5
5
  function* generateUnicode(code, offset, features) {
6
6
  if (needToUnicode(code)) {
7
- const boundary = yield* boundary_1.Boundary.start('template', offset, features);
7
+ const boundary = yield* boundary_1.Boundary.start('template', offset, offset + code.length, features);
8
8
  yield toUnicode(code);
9
- yield boundary.end(offset + code.length);
9
+ yield boundary.end();
10
10
  }
11
11
  else {
12
12
  yield [code, 'template', offset, features];
@@ -210,6 +210,7 @@ function getDefaultCompilerOptions(target = 99, lib = 'vue', strictTemplates = f
210
210
  inferTemplateDollarRefs: false,
211
211
  inferTemplateDollarSlots: false,
212
212
  skipTemplateCodegen: false,
213
+ vapor: false,
213
214
  fallthroughAttributes: false,
214
215
  checkRequiredFallthroughAttributes: false,
215
216
  resolveStyleImports: false,
@@ -67,9 +67,9 @@ export declare const tsCodegen: WeakMap<IR, {
67
67
  getInternalVariable: () => string;
68
68
  scopes: {
69
69
  add(value: string): /*elided*/ any;
70
+ clear(): void;
70
71
  declare(...variables: string[]): void;
71
72
  end(): Generator<import("../types").Code, any, any>;
72
- clear(): void;
73
73
  delete(value: string): boolean;
74
74
  forEach(callbackfn: (value: string, value2: string, set: Set<string>) => void, thisArg?: any): void;
75
75
  has(value: string): boolean;
@@ -82,9 +82,9 @@ export declare const tsCodegen: WeakMap<IR, {
82
82
  }[];
83
83
  scope: () => {
84
84
  add(value: string): any;
85
+ clear(): void;
85
86
  declare(...variables: string[]): void;
86
87
  end(): Generator<import("../types").Code, any, any>;
87
- clear(): void;
88
88
  delete(value: string): boolean;
89
89
  forEach(callbackfn: (value: string, value2: string, set: Set<string>) => void, thisArg?: any): void;
90
90
  has(value: string): boolean;
@@ -93,6 +93,7 @@ function useCodegen(ts, vueCompilerOptions, fileName, ir) {
93
93
  }
94
94
  return vueCompilerOptions;
95
95
  });
96
+ const getIsVapor = (0, alien_signals_1.computed)(() => getResolvedOptions().vapor || !!(ir.scriptSetup?.attrs.vapor || ir.template?.attrs.vapor));
96
97
  const getScriptRanges = (0, alien_signals_1.computed)(() => ir.script && validLangs.has(ir.script.lang)
97
98
  ? (0, scriptRanges_1.parseScriptRanges)(ts, ir.script.ast, getResolvedOptions())
98
99
  : undefined);
@@ -182,6 +183,7 @@ function useCodegen(ts, vueCompilerOptions, fileName, ir) {
182
183
  typescript: ts,
183
184
  vueCompilerOptions: getResolvedOptions(),
184
185
  template: ir.template,
186
+ isVapor: getIsVapor(),
185
187
  componentName: getComponentName(),
186
188
  setupConsts: getSetupConsts(),
187
189
  setupRefs: getSetupRefs(),
package/lib/types.d.ts CHANGED
@@ -43,6 +43,7 @@ export interface VueCompilerOptions {
43
43
  inferTemplateDollarRefs: boolean;
44
44
  inferTemplateDollarSlots: boolean;
45
45
  skipTemplateCodegen: boolean;
46
+ vapor: boolean;
46
47
  fallthroughAttributes: boolean;
47
48
  checkRequiredFallthroughAttributes: boolean;
48
49
  resolveStyleImports: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-core",
3
- "version": "3.3.7",
3
+ "version": "3.3.8",
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": "f6cc297eb9b2fddb3bed535b099b9697c909764d"
37
+ "gitHead": "876b0278ad0d1995c74c975c1f9fd4a8dc00e092"
38
38
  }