@vue/language-core 3.1.3 → 3.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +1 -0
  3. package/lib/codegen/globalTypes.js +4 -3
  4. package/lib/codegen/script/component.js +1 -1
  5. package/lib/codegen/script/index.js +17 -10
  6. package/lib/codegen/script/scriptSetup.js +2 -2
  7. package/lib/codegen/script/src.js +1 -1
  8. package/lib/codegen/style/classProperty.js +1 -1
  9. package/lib/codegen/style/imports.js +1 -1
  10. package/lib/codegen/template/context.d.ts +3 -3
  11. package/lib/codegen/template/context.js +8 -4
  12. package/lib/codegen/template/element.js +30 -17
  13. package/lib/codegen/template/elementDirectives.js +5 -5
  14. package/lib/codegen/template/elementEvents.d.ts +1 -1
  15. package/lib/codegen/template/elementEvents.js +4 -8
  16. package/lib/codegen/template/elementProps.d.ts +2 -2
  17. package/lib/codegen/template/elementProps.js +38 -83
  18. package/lib/codegen/template/index.d.ts +7 -9
  19. package/lib/codegen/template/index.js +2 -37
  20. package/lib/codegen/template/interpolation.js +38 -39
  21. package/lib/codegen/template/objectProperty.js +1 -1
  22. package/lib/codegen/template/slotOutlet.js +5 -10
  23. package/lib/codegen/template/styleScopedClasses.js +8 -8
  24. package/lib/codegen/template/templateChild.js +5 -12
  25. package/lib/codegen/template/vIf.js +5 -7
  26. package/lib/codegen/template/vSlot.js +3 -4
  27. package/lib/codegen/utils/index.d.ts +0 -2
  28. package/lib/codegen/utils/index.js +0 -11
  29. package/lib/codegen/utils/stringLiteralKey.js +1 -1
  30. package/lib/codegen/utils/unicode.js +1 -1
  31. package/lib/codegen/utils/wrapWith.d.ts +1 -2
  32. package/lib/codegen/utils/wrapWith.js +1 -10
  33. package/lib/compilerOptions.d.ts +2 -5
  34. package/lib/compilerOptions.js +43 -66
  35. package/lib/languagePlugin.js +16 -23
  36. package/lib/plugins/vue-template-html.js +12 -9
  37. package/lib/plugins/vue-template-inline-css.js +10 -16
  38. package/lib/plugins/vue-tsx.d.ts +3 -3
  39. package/lib/plugins/vue-tsx.js +0 -1
  40. package/lib/utils/forEachTemplateNode.d.ts +3 -0
  41. package/lib/utils/forEachTemplateNode.js +68 -0
  42. package/lib/utils/parseSfc.js +5 -10
  43. package/lib/utils/shared.d.ts +1 -0
  44. package/lib/utils/shared.js +8 -0
  45. package/lib/virtualFile/computedSfc.d.ts +1 -1
  46. package/lib/virtualFile/computedSfc.js +6 -2
  47. package/package.json +2 -2
@@ -1,4 +1,3 @@
1
- import * as CompilerDOM from '@vue/compiler-dom';
2
1
  import type * as ts from 'typescript';
3
2
  import type { Code, Sfc, VueCompilerOptions } from '../../types';
4
3
  export interface TemplateCodegenOptions {
@@ -23,7 +22,7 @@ declare function generate(options: TemplateCodegenOptions): {
23
22
  ignoreError?: boolean;
24
23
  expectError?: {
25
24
  token: number;
26
- node: CompilerDOM.CommentNode;
25
+ node: import("@vue/compiler-dom").CommentNode;
27
26
  };
28
27
  generic?: {
29
28
  content: string;
@@ -54,18 +53,18 @@ declare function generate(options: TemplateCodegenOptions): {
54
53
  }[];
55
54
  emptyClassOffsets: number[];
56
55
  inlayHints: import("../inlayHints").InlayHintInfo[];
57
- bindingAttrLocs: CompilerDOM.SourceLocation[];
56
+ bindingAttrLocs: import("@vue/compiler-dom").SourceLocation[];
58
57
  inheritedAttrVars: Set<string>;
59
58
  templateRefs: Map<string, {
60
59
  typeExp: string;
61
60
  offset: number;
62
61
  }[]>;
63
62
  currentComponent: {
64
- ctxVar: string;
65
- used: boolean;
63
+ get ctxVar(): string;
64
+ get propsVar(): string;
66
65
  } | undefined;
67
- singleRootElTypes: string[];
68
- singleRootNodes: Set<CompilerDOM.ElementNode | null>;
66
+ singleRootElTypes: Set<string>;
67
+ singleRootNodes: Set<import("@vue/compiler-dom").ElementNode | null>;
69
68
  addTemplateRef(name: string, typeExp: string, offset: number): void;
70
69
  accessExternalVariable(name: string, offset?: number): void;
71
70
  hasLocalVariable(name: string): boolean;
@@ -76,7 +75,6 @@ declare function generate(options: TemplateCodegenOptions): {
76
75
  generateHoistVariables(): Generator<string, void, unknown>;
77
76
  generateConditionGuards(): Generator<string, void, unknown>;
78
77
  generateAutoImportCompletion(): Generator<Code>;
79
- enter(node: CompilerDOM.RootNode | CompilerDOM.TemplateChildNode | CompilerDOM.SimpleExpressionNode): boolean;
78
+ enter(node: import("@vue/compiler-dom").RootNode | import("@vue/compiler-dom").TemplateChildNode | import("@vue/compiler-dom").SimpleExpressionNode): boolean;
80
79
  exit(): Generator<Code>;
81
80
  };
82
- export declare function forEachElementNode(node: CompilerDOM.RootNode | CompilerDOM.TemplateChildNode): Generator<CompilerDOM.ElementNode>;
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateTemplate = generate;
4
- exports.forEachElementNode = forEachElementNode;
5
- const CompilerDOM = require("@vue/compiler-dom");
6
4
  const codeFeatures_1 = require("../codeFeatures");
7
5
  const utils_1 = require("../utils");
8
6
  const wrapWith_1 = require("../utils/wrapWith");
@@ -75,7 +73,7 @@ function* generateSlots(options, ctx) {
75
73
  yield* (0, objectProperty_1.generateObjectProperty)(options, ctx, slot.name, slot.offset, codeFeatures_1.codeFeatures.navigation);
76
74
  }
77
75
  else {
78
- yield* (0, wrapWith_1.wrapWith)(slot.tagRange[0], slot.tagRange[1], codeFeatures_1.codeFeatures.navigation, `default`);
76
+ yield* (0, wrapWith_1.wrapWith)('template', slot.tagRange[0], slot.tagRange[1], codeFeatures_1.codeFeatures.navigation, `default`);
79
77
  }
80
78
  yield `?: (props: typeof ${slot.propsVar}) => any }`;
81
79
  }
@@ -129,7 +127,7 @@ function* generateTemplateRefs(options, ctx) {
129
127
  }
130
128
  function* generateRootEl(ctx) {
131
129
  yield `type __VLS_RootEl = `;
132
- if (ctx.singleRootElTypes.length && !ctx.singleRootNodes.has(null)) {
130
+ if (ctx.singleRootElTypes.size && !ctx.singleRootNodes.has(null)) {
133
131
  for (const type of ctx.singleRootElTypes) {
134
132
  yield `${utils_1.newLine}| ${type}`;
135
133
  }
@@ -140,37 +138,4 @@ function* generateRootEl(ctx) {
140
138
  yield utils_1.endOfLine;
141
139
  return `__VLS_RootEl`;
142
140
  }
143
- function* forEachElementNode(node) {
144
- if (node.type === CompilerDOM.NodeTypes.ROOT) {
145
- for (const child of node.children) {
146
- yield* forEachElementNode(child);
147
- }
148
- }
149
- else if (node.type === CompilerDOM.NodeTypes.ELEMENT) {
150
- const patchForNode = (0, templateChild_1.getVForNode)(node);
151
- if (patchForNode) {
152
- yield* forEachElementNode(patchForNode);
153
- }
154
- else {
155
- yield node;
156
- for (const child of node.children) {
157
- yield* forEachElementNode(child);
158
- }
159
- }
160
- }
161
- else if (node.type === CompilerDOM.NodeTypes.IF) {
162
- // v-if / v-else-if / v-else
163
- for (const branch of node.branches) {
164
- for (const childNode of branch.children) {
165
- yield* forEachElementNode(childNode);
166
- }
167
- }
168
- }
169
- else if (node.type === CompilerDOM.NodeTypes.FOR) {
170
- // v-for
171
- for (const child of node.children) {
172
- yield* forEachElementNode(child);
173
- }
174
- }
175
- }
176
141
  //# sourceMappingURL=index.js.map
@@ -10,44 +10,43 @@ const utils_1 = require("../utils");
10
10
  const isLiteralWhitelisted = /*@__PURE__*/ (0, shared_1.makeMap)('true,false,null,this');
11
11
  function* generateInterpolation(options, ctx, source, data, code, start, prefix = '', suffix = '') {
12
12
  const { ts, destructuredPropNames, templateRefNames, } = options;
13
- for (let [section, offset, type] of forEachInterpolationSegment(ts, ctx.inlineTsAsts, destructuredPropNames, templateRefNames, ctx, code, start, prefix, suffix)) {
14
- if (offset === undefined) {
15
- yield section;
13
+ for (const segment of forEachInterpolationSegment(ts, ctx.inlineTsAsts, destructuredPropNames, templateRefNames, ctx, code, start, prefix, suffix)) {
14
+ if (typeof segment === 'string') {
15
+ yield segment;
16
+ continue;
16
17
  }
17
- else {
18
- offset -= prefix.length;
19
- let addSuffix = '';
20
- const overLength = offset + section.length - code.length;
21
- if (overLength > 0) {
22
- addSuffix = section.slice(section.length - overLength);
23
- section = section.slice(0, -overLength);
24
- }
25
- if (offset < 0) {
26
- yield section.slice(0, -offset);
27
- section = section.slice(-offset);
28
- offset = 0;
18
+ let [section, offset, type] = segment;
19
+ offset -= prefix.length;
20
+ let addSuffix = '';
21
+ const overLength = offset + section.length - code.length;
22
+ if (overLength > 0) {
23
+ addSuffix = section.slice(section.length - overLength);
24
+ section = section.slice(0, -overLength);
25
+ }
26
+ if (offset < 0) {
27
+ yield section.slice(0, -offset);
28
+ section = section.slice(-offset);
29
+ offset = 0;
30
+ }
31
+ const shouldSkip = section.length === 0 && (type === 'startText' || type === 'endText');
32
+ if (!shouldSkip) {
33
+ if (start !== undefined && data) {
34
+ yield [
35
+ section,
36
+ source,
37
+ start + offset,
38
+ type === 'errorMappingOnly'
39
+ ? codeFeatures_1.codeFeatures.verification
40
+ : typeof data === 'function'
41
+ ? data(start + offset)
42
+ : data,
43
+ ];
29
44
  }
30
- const shouldSkip = section.length === 0 && (type === 'startText' || type === 'endText');
31
- if (!shouldSkip) {
32
- if (start !== undefined
33
- && data) {
34
- yield [
35
- section,
36
- source,
37
- start + offset,
38
- type === 'errorMappingOnly'
39
- ? codeFeatures_1.codeFeatures.verification
40
- : typeof data === 'function'
41
- ? data(start + offset)
42
- : data,
43
- ];
44
- }
45
- else {
46
- yield section;
47
- }
45
+ else {
46
+ yield section;
48
47
  }
49
- yield addSuffix;
50
48
  }
49
+ yield addSuffix;
51
50
  }
52
51
  }
53
52
  function* forEachInterpolationSegment(ts, inlineTsAsts, destructuredPropNames, templateRefNames, ctx, originalCode, start, prefix, suffix) {
@@ -82,7 +81,7 @@ function* forEachInterpolationSegment(ts, inlineTsAsts, destructuredPropNames, t
82
81
  const lastVarEnd = lastVar ? lastVar.offset + lastVar.text.length : 0;
83
82
  if (curVar.isShorthand) {
84
83
  yield [code.slice(lastVarEnd, curVar.offset + curVar.text.length), lastVarEnd];
85
- yield [': ', undefined];
84
+ yield `: `;
86
85
  }
87
86
  else {
88
87
  yield [code.slice(lastVarEnd, curVar.offset), lastVarEnd, i ? undefined : 'startText'];
@@ -104,9 +103,9 @@ function* generateVar(templateRefNames, ctx, code, offset, curVar) {
104
103
  yield ['', curVar.offset, 'errorMappingOnly'];
105
104
  const isTemplateRef = templateRefNames?.has(curVar.text) ?? false;
106
105
  if (isTemplateRef) {
107
- yield [`__VLS_unref(`, undefined];
106
+ yield `__VLS_unref(`;
108
107
  yield [code.slice(curVar.offset, curVar.offset + curVar.text.length), curVar.offset];
109
- yield [`)`, undefined];
108
+ yield `)`;
110
109
  }
111
110
  else {
112
111
  if (offset !== undefined) {
@@ -116,10 +115,10 @@ function* generateVar(templateRefNames, ctx, code, offset, curVar) {
116
115
  ctx.accessExternalVariable(curVar.text);
117
116
  }
118
117
  if (ctx.dollarVars.has(curVar.text)) {
119
- yield [`__VLS_dollars.`, undefined];
118
+ yield `__VLS_dollars.`;
120
119
  }
121
120
  else {
122
- yield [`__VLS_ctx.`, undefined];
121
+ yield `__VLS_ctx.`;
123
122
  }
124
123
  yield [code.slice(curVar.offset, curVar.offset + curVar.text.length), curVar.offset];
125
124
  }
@@ -21,7 +21,7 @@ function* generateObjectProperty(options, ctx, code, offset, features, shouldCam
21
21
  yield* (0, camelized_1.generateCamelized)(code, 'template', offset, features);
22
22
  }
23
23
  else {
24
- yield* (0, wrapWith_1.wrapWith)(offset, offset + code.length, features, `'`, ...(0, camelized_1.generateCamelized)(code, 'template', offset, utils_1.combineLastMapping), `'`);
24
+ yield* (0, wrapWith_1.wrapWith)('template', offset, offset + code.length, features, `'`, ...(0, camelized_1.generateCamelized)(code, 'template', offset, utils_1.combineLastMapping), `'`);
25
25
  }
26
26
  }
27
27
  else {
@@ -29,12 +29,7 @@ function* generateSlotOutlet(options, ctx, node) {
29
29
  if (nameProp) {
30
30
  let codes;
31
31
  if (nameProp.type === CompilerDOM.NodeTypes.ATTRIBUTE && nameProp.value) {
32
- let { source, start: { offset } } = nameProp.value.loc;
33
- if (source.startsWith('"') || source.startsWith("'")) {
34
- source = source.slice(1, -1);
35
- offset++;
36
- }
37
- codes = (0, propertyAccess_1.generatePropertyAccess)(options, ctx, source, offset, codeFeatures_1.codeFeatures.navigationAndVerification);
32
+ codes = (0, propertyAccess_1.generatePropertyAccess)(options, ctx, nameProp.value.content, (0, shared_1.getAttributeValueOffset)(nameProp.value), codeFeatures_1.codeFeatures.navigationAndVerification);
38
33
  }
39
34
  else if (nameProp.type === CompilerDOM.NodeTypes.DIRECTIVE
40
35
  && nameProp.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
@@ -47,18 +42,18 @@ function* generateSlotOutlet(options, ctx, node) {
47
42
  else {
48
43
  codes = [`['default']`];
49
44
  }
50
- yield* (0, wrapWith_1.wrapWith)(nameProp.loc.start.offset, nameProp.loc.end.offset, codeFeatures_1.codeFeatures.verification, options.slotsAssignName ?? '__VLS_slots', ...codes);
45
+ yield* (0, wrapWith_1.wrapWith)('template', nameProp.loc.start.offset, nameProp.loc.end.offset, codeFeatures_1.codeFeatures.verification, options.slotsAssignName ?? '__VLS_slots', ...codes);
51
46
  }
52
47
  else {
53
- yield* (0, wrapWith_1.wrapWith)(startTagOffset, startTagEndOffset, codeFeatures_1.codeFeatures.verification, `${options.slotsAssignName ?? '__VLS_slots'}[`, ...(0, wrapWith_1.wrapWith)(startTagOffset, startTagEndOffset, codeFeatures_1.codeFeatures.verification, `'default'`), `]`);
48
+ yield* (0, wrapWith_1.wrapWith)('template', startTagOffset, startTagEndOffset, codeFeatures_1.codeFeatures.verification, `${options.slotsAssignName ?? '__VLS_slots'}[`, ...(0, wrapWith_1.wrapWith)('template', startTagOffset, startTagEndOffset, codeFeatures_1.codeFeatures.verification, `'default'`), `]`);
54
49
  }
55
50
  yield `)(`;
56
- yield* (0, wrapWith_1.wrapWith)(startTagOffset, startTagEndOffset, codeFeatures_1.codeFeatures.verification, `{${utils_1.newLine}`, ...(0, elementProps_1.generateElementProps)(options, ctx, node, node.props.filter(prop => prop !== nameProp), true, true), `}`);
51
+ yield* (0, wrapWith_1.wrapWith)('template', startTagOffset, startTagEndOffset, codeFeatures_1.codeFeatures.verification, `{${utils_1.newLine}`, ...(0, elementProps_1.generateElementProps)(options, ctx, node, node.props.filter(prop => prop !== nameProp), true), `}`);
57
52
  yield `)${utils_1.endOfLine}`;
58
53
  }
59
54
  else {
60
55
  yield `var ${propsVar} = {${utils_1.newLine}`;
61
- yield* (0, elementProps_1.generateElementProps)(options, ctx, node, node.props.filter(prop => prop !== nameProp), options.vueCompilerOptions.checkUnknownProps, true);
56
+ yield* (0, elementProps_1.generateElementProps)(options, ctx, node, node.props.filter(prop => prop !== nameProp), options.vueCompilerOptions.checkUnknownProps);
62
57
  yield `}${utils_1.endOfLine}`;
63
58
  if (nameProp?.type === CompilerDOM.NodeTypes.ATTRIBUTE
64
59
  && nameProp.value) {
@@ -22,7 +22,7 @@ function* generateStyleScopedClassReferences(ctx, withDot = false) {
22
22
  }
23
23
  for (const { source, className, offset } of ctx.scopedClasses) {
24
24
  yield `/** @type {__VLS_StyleScopedClasses[`;
25
- yield* (0, wrapWith_1.wrapWith)(offset - (withDot ? 1 : 0), offset + className.length, source, codeFeatures_1.codeFeatures.navigation, `'`, ...(0, escaped_1.generateEscaped)(className, source, offset, codeFeatures_1.codeFeatures.navigationAndAdditionalCompletion, classNameEscapeRegex), `'`);
25
+ yield* (0, wrapWith_1.wrapWith)(source, offset - (withDot ? 1 : 0), offset + className.length, codeFeatures_1.codeFeatures.navigation, `'`, ...(0, escaped_1.generateEscaped)(className, source, offset, codeFeatures_1.codeFeatures.navigationAndAdditionalCompletion, classNameEscapeRegex), `'`);
26
26
  yield `]} */${utils_1.endOfLine}`;
27
27
  }
28
28
  }
@@ -34,26 +34,26 @@ function collectStyleScopedClassReferences(options, ctx, node) {
34
34
  if (options.template.lang === 'pug') {
35
35
  const getClassOffset = Reflect.get(prop.value.loc.start, 'getClassOffset');
36
36
  const content = prop.value.loc.source.slice(1, -1);
37
- let startOffset = 1;
37
+ let offset = 1;
38
38
  for (const className of content.split(' ')) {
39
39
  if (className) {
40
40
  ctx.scopedClasses.push({
41
41
  source: 'template',
42
42
  className,
43
- offset: getClassOffset(startOffset),
43
+ offset: getClassOffset(offset),
44
44
  });
45
45
  }
46
- startOffset += className.length + 1;
46
+ offset += className.length + 1;
47
47
  }
48
48
  }
49
49
  else {
50
- const [content, startOffset] = (0, utils_1.normalizeAttributeValue)(prop.value);
51
- if (content) {
52
- const classes = collectClasses(content, startOffset);
50
+ const offset = (0, shared_1.getAttributeValueOffset)(prop.value);
51
+ if (prop.value.content) {
52
+ const classes = collectClasses(prop.value.content, offset);
53
53
  ctx.scopedClasses.push(...classes);
54
54
  }
55
55
  else {
56
- ctx.emptyClassOffsets.push(startOffset);
56
+ ctx.emptyClassOffsets.push(offset);
57
57
  }
58
58
  }
59
59
  }
@@ -167,22 +167,15 @@ function getVIfNode(node) {
167
167
  }
168
168
  }
169
169
  function parseInterpolationNode(node, template) {
170
- let content = node.content.loc.source;
171
170
  let start = node.content.loc.start.offset;
172
- let leftCharacter;
173
- let rightCharacter;
171
+ let end = node.content.loc.end.offset;
174
172
  // fix https://github.com/vuejs/language-tools/issues/1787
175
- while ((leftCharacter = template.slice(start - 1, start)).trim() === '' && leftCharacter.length) {
173
+ while (template[start - 1]?.trim() === '') {
176
174
  start--;
177
- content = leftCharacter + content;
178
175
  }
179
- while ((rightCharacter = template.slice(start + content.length, start + content.length + 1)).trim() === ''
180
- && rightCharacter.length) {
181
- content = content + rightCharacter;
176
+ while (template[end]?.trim() === '') {
177
+ end++;
182
178
  }
183
- return [
184
- content,
185
- start,
186
- ];
179
+ return [template.slice(start, end), start];
187
180
  }
188
181
  //# sourceMappingURL=templateChild.js.map
@@ -9,6 +9,10 @@ const elementChildren_1 = require("./elementChildren");
9
9
  const interpolation_1 = require("./interpolation");
10
10
  function* generateVIf(options, ctx, node) {
11
11
  const originalBlockConditionsLength = ctx.blockConditions.length;
12
+ const isFragment = node.codegenNode
13
+ && 'consequent' in node.codegenNode
14
+ && 'tag' in node.codegenNode.consequent
15
+ && node.codegenNode.consequent.tag === CompilerDOM.FRAGMENT;
12
16
  for (let i = 0; i < node.branches.length; i++) {
13
17
  const branch = node.branches[i];
14
18
  if (i === 0) {
@@ -29,7 +33,7 @@ function* generateVIf(options, ctx, node) {
29
33
  yield ` `;
30
34
  }
31
35
  yield `{${utils_1.newLine}`;
32
- yield* (0, elementChildren_1.generateElementChildren)(options, ctx, branch.children, isFragment(node));
36
+ yield* (0, elementChildren_1.generateElementChildren)(options, ctx, branch.children, i !== 0 || isFragment);
33
37
  yield `}${utils_1.newLine}`;
34
38
  if (addedBlockCondition) {
35
39
  ctx.blockConditions[ctx.blockConditions.length - 1] = `!${ctx.blockConditions[ctx.blockConditions.length - 1]}`;
@@ -37,10 +41,4 @@ function* generateVIf(options, ctx, node) {
37
41
  }
38
42
  ctx.blockConditions.length = originalBlockConditionsLength;
39
43
  }
40
- function isFragment(node) {
41
- return node.codegenNode
42
- && 'consequent' in node.codegenNode
43
- && 'tag' in node.codegenNode.consequent
44
- && node.codegenNode.consequent.tag === CompilerDOM.FRAGMENT;
45
- }
46
44
  //# sourceMappingURL=vIf.js.map
@@ -20,19 +20,18 @@ function* generateVSlot(options, ctx, node, slotDir) {
20
20
  yield `{${utils_1.newLine}`;
21
21
  }
22
22
  if (slotDir || node.children.length) {
23
- ctx.currentComponent.used = true;
24
23
  yield `const { `;
25
24
  if (slotDir) {
26
25
  if (slotDir.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && slotDir.arg.content) {
27
26
  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);
28
27
  }
29
28
  else {
30
- yield* (0, wrapWith_1.wrapWith)(slotDir.loc.start.offset, slotDir.loc.start.offset + (slotDir.rawName?.length ?? 0), codeFeatures_1.codeFeatures.withoutHighlightAndCompletion, `default`);
29
+ yield* (0, wrapWith_1.wrapWith)('template', slotDir.loc.start.offset, slotDir.loc.start.offset + (slotDir.rawName?.length ?? 0), codeFeatures_1.codeFeatures.withoutHighlightAndCompletion, `default`);
31
30
  }
32
31
  }
33
32
  else {
34
33
  // #932: reference for implicit default slot
35
- yield* (0, wrapWith_1.wrapWith)(node.loc.start.offset, node.loc.end.offset, codeFeatures_1.codeFeatures.navigation, `default`);
34
+ yield* (0, wrapWith_1.wrapWith)('template', node.loc.start.offset, node.loc.end.offset, codeFeatures_1.codeFeatures.navigation, `default`);
36
35
  }
37
36
  yield `: ${slotVar} } = ${ctx.currentComponent.ctxVar}.slots!${utils_1.endOfLine}`;
38
37
  }
@@ -101,7 +100,7 @@ function* generateSlotParameters(options, ctx, ast, exp, slotVar) {
101
100
  yield `] = __VLS_getSlotParameters(${slotVar}!`;
102
101
  if (types.some(t => t)) {
103
102
  yield `, `;
104
- yield* (0, wrapWith_1.wrapWith)(exp.loc.start.offset, exp.loc.end.offset, codeFeatures_1.codeFeatures.verification, `(`, ...types.flatMap(type => type ? [`_`, type, `, `] : `_, `), `) => [] as any`);
103
+ yield* (0, wrapWith_1.wrapWith)('template', exp.loc.start.offset, exp.loc.end.offset, codeFeatures_1.codeFeatures.verification, `(`, ...types.flatMap(type => type ? [`_`, type, `, `] : `_, `), `) => [] as any`);
105
104
  }
106
105
  yield `)${utils_1.endOfLine}`;
107
106
  }
@@ -1,11 +1,9 @@
1
- import type * as CompilerDOM from '@vue/compiler-dom';
2
1
  import type * as ts from 'typescript';
3
2
  import type { Code, SfcBlock, VueCodeInformation } from '../../types';
4
3
  export declare const newLine = "\n";
5
4
  export declare const endOfLine = ";\n";
6
5
  export declare const combineLastMapping: VueCodeInformation;
7
6
  export declare const identifierRegex: RegExp;
8
- export declare function normalizeAttributeValue(node: CompilerDOM.TextNode): readonly [string, number];
9
7
  export declare function createTsAst(ts: typeof import('typescript'), inlineTsAsts: Map<string, ts.SourceFile> | undefined, text: string): ts.SourceFile;
10
8
  export declare function generateSfcBlockSection(block: SfcBlock, start: number, end: number, features: VueCodeInformation): Code;
11
9
  export declare function generatePartiallyEnding(source: string, end: number, mark: string, delimiter?: string): Generator<Code>;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.identifierRegex = exports.combineLastMapping = exports.endOfLine = exports.newLine = void 0;
4
- exports.normalizeAttributeValue = normalizeAttributeValue;
5
4
  exports.createTsAst = createTsAst;
6
5
  exports.generateSfcBlockSection = generateSfcBlockSection;
7
6
  exports.generatePartiallyEnding = generatePartiallyEnding;
@@ -10,16 +9,6 @@ exports.newLine = `\n`;
10
9
  exports.endOfLine = `;${exports.newLine}`;
11
10
  exports.combineLastMapping = { __combineOffset: 1 };
12
11
  exports.identifierRegex = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
13
- function normalizeAttributeValue(node) {
14
- let offset = node.loc.start.offset;
15
- let content = node.loc.source;
16
- if ((content.startsWith(`'`) && content.endsWith(`'`))
17
- || (content.startsWith(`"`) && content.endsWith(`"`))) {
18
- offset++;
19
- content = content.slice(1, -1);
20
- }
21
- return [content, offset];
22
- }
23
12
  function createTsAst(ts, inlineTsAsts, text) {
24
13
  let ast = inlineTsAsts?.get(text);
25
14
  if (!ast) {
@@ -8,7 +8,7 @@ function* generateStringLiteralKey(code, offset, info) {
8
8
  yield `'${code}'`;
9
9
  }
10
10
  else {
11
- yield* (0, wrapWith_1.wrapWith)(offset, offset + code.length, info, `'`, [code, 'template', offset, index_1.combineLastMapping], `'`);
11
+ yield* (0, wrapWith_1.wrapWith)('template', offset, offset + code.length, info, `'`, [code, 'template', offset, index_1.combineLastMapping], `'`);
12
12
  }
13
13
  }
14
14
  //# sourceMappingURL=stringLiteralKey.js.map
@@ -4,7 +4,7 @@ exports.generateUnicode = generateUnicode;
4
4
  const wrapWith_1 = require("./wrapWith");
5
5
  function* generateUnicode(code, offset, info) {
6
6
  if (needToUnicode(code)) {
7
- yield* (0, wrapWith_1.wrapWith)(offset, offset + code.length, info, toUnicode(code));
7
+ yield* (0, wrapWith_1.wrapWith)('template', offset, offset + code.length, info, toUnicode(code));
8
8
  }
9
9
  else {
10
10
  yield [code, 'template', offset, info];
@@ -1,3 +1,2 @@
1
1
  import type { Code, VueCodeInformation } from '../../types';
2
- export declare function wrapWith(startOffset: number, endOffset: number, features: VueCodeInformation, ...codes: Code[]): Generator<Code>;
3
- export declare function wrapWith(startOffset: number, endOffset: number, source: string, features: VueCodeInformation, ...codes: Code[]): Generator<Code>;
2
+ export declare function wrapWith(source: string, startOffset: number, endOffset: number, features: VueCodeInformation, ...codes: Code[]): Generator<Code>;
@@ -1,16 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.wrapWith = wrapWith;
4
- function* wrapWith(startOffset, endOffset, ...args) {
5
- let source = 'template';
6
- let features;
7
- let codes;
8
- if (typeof args[0] === 'string') {
9
- [source, features, ...codes] = args;
10
- }
11
- else {
12
- [features, ...codes] = args;
13
- }
4
+ function* wrapWith(source, startOffset, endOffset, features, ...codes) {
14
5
  yield ['', source, startOffset, features];
15
6
  let offset = 1;
16
7
  for (const code of codes) {
@@ -1,12 +1,10 @@
1
1
  import type * as ts from 'typescript';
2
2
  import type { RawVueCompilerOptions, VueCompilerOptions, VueLanguagePlugin } from './types';
3
- interface ParseConfigHost extends Omit<ts.ParseConfigHost, 'readDirectory'> {
4
- }
5
3
  export interface ParsedCommandLine extends Omit<ts.ParsedCommandLine, 'fileNames'> {
6
4
  vueOptions: VueCompilerOptions;
7
5
  }
8
- export declare function createParsedCommandLineByJson(ts: typeof import('typescript'), host: ParseConfigHost, rootDir: string, json: any, configFileName?: string): ParsedCommandLine;
9
- export declare function createParsedCommandLine(ts: typeof import('typescript'), host: ParseConfigHost, configFileName: string): ParsedCommandLine;
6
+ export declare const createParsedCommandLineByJson: (ts: typeof import("typescript"), host: Omit<ts.ParseConfigHost, "readDirectory">, rootDir: string, json: any, configFileName?: string | undefined) => ParsedCommandLine;
7
+ export declare const createParsedCommandLine: (ts: typeof import("typescript"), host: Omit<ts.ParseConfigHost, "readDirectory">, configFileName: string) => ParsedCommandLine;
10
8
  export declare class CompilerOptionsResolver {
11
9
  fileExists?: ((path: string) => boolean) | undefined;
12
10
  options: Omit<RawVueCompilerOptions, 'target' | 'globalTypesPath' | 'plugins'>;
@@ -24,4 +22,3 @@ export declare function createGlobalTypesWriter(vueOptions: VueCompilerOptions,
24
22
  * @deprecated use `createGlobalTypesWriter` instead
25
23
  */
26
24
  export declare function writeGlobalTypes(vueOptions: VueCompilerOptions, writeFile: (fileName: string, data: string) => void): void;
27
- export {};
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CompilerOptionsResolver = void 0;
4
- exports.createParsedCommandLineByJson = createParsedCommandLineByJson;
5
- exports.createParsedCommandLine = createParsedCommandLine;
3
+ exports.CompilerOptionsResolver = exports.createParsedCommandLine = exports.createParsedCommandLineByJson = void 0;
6
4
  exports.getDefaultCompilerOptions = getDefaultCompilerOptions;
7
5
  exports.createGlobalTypesWriter = createGlobalTypesWriter;
8
6
  exports.writeGlobalTypes = writeGlobalTypes;
@@ -10,75 +8,54 @@ const shared_1 = require("@vue/shared");
10
8
  const path_browserify_1 = require("path-browserify");
11
9
  const globalTypes_1 = require("./codegen/globalTypes");
12
10
  const shared_2 = require("./utils/shared");
13
- function createParsedCommandLineByJson(ts, host, rootDir, json, configFileName) {
14
- const extendedPaths = new Set();
15
- const proxyHost = {
16
- ...host,
17
- readFile(fileName) {
18
- if (!fileName.endsWith('/package.json')) {
19
- extendedPaths.add(fileName);
20
- }
21
- return host.readFile(fileName);
22
- },
23
- readDirectory() {
24
- return [];
25
- },
26
- };
27
- const parsed = ts.parseJsonConfigFileContent(json, proxyHost, rootDir, {}, configFileName);
28
- const resolver = new CompilerOptionsResolver(host.fileExists);
29
- for (const extendPath of [...extendedPaths].reverse()) {
11
+ exports.createParsedCommandLineByJson = create((ts, host, rootDir, json, configFileName) => {
12
+ // `parseJsonConfigFileContent` is missing in tsc
13
+ return 'parseJsonConfigFileContent' in ts
14
+ ? ts.parseJsonConfigFileContent(json, host, rootDir, {}, configFileName)
15
+ : ts.parseJsonSourceFileConfigFileContent(ts.parseJsonText(configFileName ?? 'tsconfig.json', JSON.stringify(json)), host, rootDir, {}, configFileName);
16
+ });
17
+ exports.createParsedCommandLine = create((ts, host, configFileName) => {
18
+ const config = ts.readJsonConfigFile(configFileName, host.readFile);
19
+ return ts.parseJsonSourceFileConfigFileContent(config, host, path_browserify_1.posix.dirname(configFileName), {}, configFileName);
20
+ });
21
+ function create(getParsedCommandLine) {
22
+ return (ts, host, ...args) => {
30
23
  try {
31
- const configFile = ts.readJsonConfigFile(extendPath, host.readFile);
32
- const obj = ts.convertToObject(configFile, []);
33
- const rawOptions = obj?.vueCompilerOptions ?? {};
34
- resolver.addConfig(rawOptions, path_browserify_1.posix.dirname(configFile.fileName));
35
- }
36
- catch { }
37
- }
38
- // ensure the rootDir is added to the config roots
39
- resolver.addConfig({}, rootDir);
40
- return {
41
- ...parsed,
42
- vueOptions: resolver.build(),
43
- };
44
- }
45
- function createParsedCommandLine(ts, host, configFileName) {
46
- try {
47
- const extendedPaths = new Set();
48
- const proxyHost = {
49
- ...host,
50
- readFile(fileName) {
51
- if (!fileName.endsWith('/package.json')) {
52
- extendedPaths.add(fileName);
24
+ const extendedPaths = new Set();
25
+ const proxyHost = {
26
+ ...host,
27
+ readFile(fileName) {
28
+ if (!fileName.endsWith('/package.json')) {
29
+ extendedPaths.add(fileName);
30
+ }
31
+ return host.readFile(fileName);
32
+ },
33
+ readDirectory() {
34
+ return [];
35
+ },
36
+ };
37
+ const parsed = getParsedCommandLine(ts, proxyHost, ...args);
38
+ const resolver = new CompilerOptionsResolver(host.fileExists);
39
+ for (const extendPath of [...extendedPaths].reverse()) {
40
+ try {
41
+ const configFile = ts.readJsonConfigFile(extendPath, host.readFile);
42
+ const obj = ts.convertToObject(configFile, []);
43
+ const rawOptions = obj?.vueCompilerOptions ?? {};
44
+ resolver.addConfig(rawOptions, path_browserify_1.posix.dirname(configFile.fileName));
53
45
  }
54
- return host.readFile(fileName);
55
- },
56
- readDirectory() {
57
- return [];
58
- },
59
- };
60
- const config = ts.readJsonConfigFile(configFileName, proxyHost.readFile);
61
- const parsed = ts.parseJsonSourceFileConfigFileContent(config, proxyHost, path_browserify_1.posix.dirname(configFileName), {}, configFileName);
62
- const resolver = new CompilerOptionsResolver(host.fileExists);
63
- for (const extendPath of [...extendedPaths].reverse()) {
64
- try {
65
- const configFile = ts.readJsonConfigFile(extendPath, host.readFile);
66
- const obj = ts.convertToObject(configFile, []);
67
- const rawOptions = obj?.vueCompilerOptions ?? {};
68
- resolver.addConfig(rawOptions, path_browserify_1.posix.dirname(configFile.fileName));
46
+ catch { }
69
47
  }
70
- catch { }
48
+ return {
49
+ ...parsed,
50
+ vueOptions: resolver.build(),
51
+ };
71
52
  }
53
+ catch { }
72
54
  return {
73
- ...parsed,
74
- vueOptions: resolver.build(),
55
+ options: {},
56
+ errors: [],
57
+ vueOptions: getDefaultCompilerOptions(),
75
58
  };
76
- }
77
- catch { }
78
- return {
79
- options: {},
80
- errors: [],
81
- vueOptions: getDefaultCompilerOptions(),
82
59
  };
83
60
  }
84
61
  class CompilerOptionsResolver {