@vue/language-core 1.9.0-alpha.3 → 2.0.1

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 (93) hide show
  1. package/index.d.ts +13 -0
  2. package/{out/index.js → index.js} +12 -14
  3. package/lib/generators/script.d.ts +13 -0
  4. package/lib/generators/script.js +1060 -0
  5. package/lib/generators/template.d.ts +9 -0
  6. package/lib/generators/template.js +1567 -0
  7. package/lib/generators/utils.d.ts +6 -0
  8. package/lib/generators/utils.js +58 -0
  9. package/lib/languageModule.d.ts +5 -0
  10. package/lib/languageModule.js +114 -0
  11. package/{out → lib}/parsers/scriptRanges.d.ts +2 -3
  12. package/{out → lib}/parsers/scriptRanges.js +11 -6
  13. package/{out → lib}/parsers/scriptSetupRanges.d.ts +17 -9
  14. package/{out → lib}/parsers/scriptSetupRanges.js +42 -35
  15. package/lib/plugins/file-html.d.ts +3 -0
  16. package/{out → lib}/plugins/file-html.js +1 -1
  17. package/lib/plugins/file-md.d.ts +3 -0
  18. package/{out → lib}/plugins/file-md.js +8 -8
  19. package/lib/plugins/file-vue.d.ts +3 -0
  20. package/{out → lib}/plugins/file-vue.js +9 -2
  21. package/lib/plugins/vue-sfc-customblocks.d.ts +3 -0
  22. package/lib/plugins/vue-sfc-customblocks.js +28 -0
  23. package/lib/plugins/vue-sfc-scripts.d.ts +3 -0
  24. package/lib/plugins/vue-sfc-scripts.js +36 -0
  25. package/lib/plugins/vue-sfc-styles.d.ts +3 -0
  26. package/lib/plugins/vue-sfc-styles.js +28 -0
  27. package/lib/plugins/vue-sfc-template.d.ts +3 -0
  28. package/lib/plugins/vue-sfc-template.js +29 -0
  29. package/lib/plugins/vue-template-html.d.ts +3 -0
  30. package/{out → lib}/plugins/vue-template-html.js +12 -12
  31. package/{out → lib}/plugins/vue-tsx.d.ts +25 -18
  32. package/lib/plugins/vue-tsx.js +212 -0
  33. package/{out → lib}/plugins.d.ts +19 -7
  34. package/{out → lib}/plugins.js +24 -18
  35. package/{out → lib}/types.d.ts +26 -9
  36. package/lib/types.js +5 -0
  37. package/{out → lib}/utils/parseCssClassNames.d.ts +0 -1
  38. package/{out → lib}/utils/parseCssVars.d.ts +0 -1
  39. package/{out → lib}/utils/parseSfc.d.ts +0 -1
  40. package/{out → lib}/utils/parseSfc.js +4 -18
  41. package/{out → lib}/utils/shared.d.ts +0 -1
  42. package/lib/utils/transform.d.ts +8 -0
  43. package/{out → lib}/utils/transform.js +62 -62
  44. package/{out → lib}/utils/ts.d.ts +3 -4
  45. package/{out → lib}/utils/ts.js +0 -12
  46. package/lib/utils/vue2TemplateCompiler.d.ts +2 -0
  47. package/{out → lib}/utils/vue2TemplateCompiler.js +5 -2
  48. package/{out → lib}/virtualFile/computedFiles.d.ts +2 -3
  49. package/{out → lib}/virtualFile/computedFiles.js +55 -42
  50. package/lib/virtualFile/computedMappings.d.ts +4 -0
  51. package/{out → lib}/virtualFile/computedMappings.js +9 -12
  52. package/lib/virtualFile/computedSfc.d.ts +4 -0
  53. package/{out → lib}/virtualFile/computedSfc.js +3 -3
  54. package/{out → lib}/virtualFile/computedVueSfc.d.ts +2 -3
  55. package/lib/virtualFile/embeddedFile.d.ts +12 -0
  56. package/lib/virtualFile/embeddedFile.js +15 -0
  57. package/lib/virtualFile/vueFile.d.ts +25 -0
  58. package/{out → lib}/virtualFile/vueFile.js +11 -21
  59. package/package.json +8 -11
  60. package/out/generators/script.d.ts +0 -15
  61. package/out/generators/script.js +0 -887
  62. package/out/generators/template.d.ts +0 -21
  63. package/out/generators/template.js +0 -1506
  64. package/out/index.d.ts +0 -16
  65. package/out/languageModule.d.ts +0 -10
  66. package/out/languageModule.js +0 -99
  67. package/out/plugins/file-html.d.ts +0 -4
  68. package/out/plugins/file-md.d.ts +0 -4
  69. package/out/plugins/file-vue.d.ts +0 -4
  70. package/out/plugins/vue-sfc-customblocks.d.ts +0 -4
  71. package/out/plugins/vue-sfc-customblocks.js +0 -33
  72. package/out/plugins/vue-sfc-scripts.d.ts +0 -4
  73. package/out/plugins/vue-sfc-scripts.js +0 -42
  74. package/out/plugins/vue-sfc-styles.d.ts +0 -4
  75. package/out/plugins/vue-sfc-styles.js +0 -33
  76. package/out/plugins/vue-sfc-template.d.ts +0 -4
  77. package/out/plugins/vue-sfc-template.js +0 -29
  78. package/out/plugins/vue-template-html.d.ts +0 -4
  79. package/out/plugins/vue-tsx.js +0 -159
  80. package/out/types.js +0 -3
  81. package/out/utils/globalTypes.d.ts +0 -4
  82. package/out/utils/globalTypes.js +0 -135
  83. package/out/utils/transform.d.ts +0 -9
  84. package/out/utils/vue2TemplateCompiler.d.ts +0 -3
  85. package/out/virtualFile/computedMappings.d.ts +0 -6
  86. package/out/virtualFile/computedSfc.d.ts +0 -5
  87. package/out/virtualFile/embeddedFile.d.ts +0 -13
  88. package/out/virtualFile/embeddedFile.js +0 -16
  89. package/out/virtualFile/vueFile.d.ts +0 -28
  90. /package/{out → lib}/utils/parseCssClassNames.js +0 -0
  91. /package/{out → lib}/utils/parseCssVars.js +0 -0
  92. /package/{out → lib}/utils/shared.js +0 -0
  93. /package/{out → lib}/virtualFile/computedVueSfc.js +0 -0
@@ -1,12 +1,27 @@
1
1
  import type * as CompilerDOM from '@vue/compiler-dom';
2
2
  import type { SFCParseResult } from '@vue/compiler-sfc';
3
- import type * as ts from 'typescript/lib/tsserverlibrary';
4
- import type { VueEmbeddedFile } from './virtualFile/embeddedFile';
3
+ import type * as ts from 'typescript';
4
+ import type { VueEmbeddedCode } from './virtualFile/embeddedFile';
5
+ import type { CodeInformation, Segment } from '@volar/language-core';
5
6
  export type { SFCParseResult } from '@vue/compiler-sfc';
6
7
  export type RawVueCompilerOptions = Partial<Omit<VueCompilerOptions, 'target' | 'plugins'>> & {
7
8
  target?: 'auto' | 2 | 2.7 | 3 | 3.3;
8
9
  plugins?: string[];
9
10
  };
11
+ export interface VueCodeInformation extends CodeInformation {
12
+ __referencesCodeLens?: boolean;
13
+ __displayWithLink?: boolean;
14
+ __hint?: {
15
+ setting: string;
16
+ label: string;
17
+ tooltip: string;
18
+ paddingRight?: boolean;
19
+ paddingLeft?: boolean;
20
+ };
21
+ __combineLastMappping?: boolean;
22
+ }
23
+ export type CodeAndStack = [code: Code, stack: string];
24
+ export type Code = Segment<VueCodeInformation>;
10
25
  export interface VueCompilerOptions {
11
26
  target: number;
12
27
  lib: string;
@@ -28,23 +43,23 @@ export interface VueCompilerOptions {
28
43
  withDefaults: string[];
29
44
  };
30
45
  plugins: VueLanguagePlugin[];
31
- hooks: string[];
32
46
  experimentalDefinePropProposal: 'kevinEdition' | 'johnsonEdition' | false;
33
47
  experimentalResolveStyleCssClasses: 'scoped' | 'always' | 'never';
34
48
  experimentalModelPropName: Record<string, Record<string, boolean | Record<string, string> | Record<string, string>[]>>;
35
49
  experimentalUseElementAccessInTemplate: boolean;
36
- experimentalAdditionalLanguageModules: string[];
37
50
  }
51
+ export declare const pluginVersion = 2;
38
52
  export type VueLanguagePlugin = (ctx: {
39
53
  modules: {
40
- typescript: typeof import('typescript/lib/tsserverlibrary');
54
+ typescript: typeof import('typescript');
41
55
  '@vue/compiler-dom': typeof import('@vue/compiler-dom');
42
56
  };
43
57
  compilerOptions: ts.CompilerOptions;
44
58
  vueCompilerOptions: VueCompilerOptions;
45
59
  codegenStack: boolean;
60
+ globalTypesHolder: string | undefined;
46
61
  }) => {
47
- version: 1;
62
+ version: typeof pluginVersion;
48
63
  name?: string;
49
64
  order?: number;
50
65
  requiredCompilerOptions?: string[];
@@ -61,8 +76,11 @@ export type VueLanguagePlugin = (ctx: {
61
76
  end: number;
62
77
  newText: string;
63
78
  }): CompilerDOM.CodegenResult | undefined;
64
- getEmbeddedFileNames?(fileName: string, sfc: Sfc): string[];
65
- resolveEmbeddedFile?(fileName: string, sfc: Sfc, embeddedFile: VueEmbeddedFile): void;
79
+ getEmbeddedCodes?(fileName: string, sfc: Sfc): {
80
+ id: string;
81
+ lang: string;
82
+ }[];
83
+ resolveEmbeddedCode?(fileName: string, sfc: Sfc, embeddedFile: VueEmbeddedCode): void;
66
84
  };
67
85
  export interface SfcBlock {
68
86
  name: string;
@@ -122,4 +140,3 @@ export interface TextRange {
122
140
  start: number;
123
141
  end: number;
124
142
  }
125
- //# sourceMappingURL=types.d.ts.map
package/lib/types.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pluginVersion = void 0;
4
+ exports.pluginVersion = 2;
5
+ //# sourceMappingURL=types.js.map
@@ -2,4 +2,3 @@ export declare function parseCssClassNames(styleContent: string): Generator<{
2
2
  offset: number;
3
3
  text: string;
4
4
  }, void, unknown>;
5
- //# sourceMappingURL=parseCssClassNames.d.ts.map
@@ -3,4 +3,3 @@ export declare function parseCssVars(styleContent: string): Generator<{
3
3
  text: string;
4
4
  }, void, unknown>;
5
5
  export declare function clearComments(css: string): string;
6
- //# sourceMappingURL=parseCssVars.d.ts.map
@@ -1,3 +1,2 @@
1
1
  import type { SFCParseResult } from '@vue/compiler-sfc';
2
2
  export declare function parse(source: string): SFCParseResult;
3
- //# sourceMappingURL=parseSfc.d.ts.map
@@ -9,20 +9,7 @@ function parse(source) {
9
9
  isNativeTag: () => true,
10
10
  // preserve all whitespaces
11
11
  isPreTag: () => true,
12
- getTextMode: ({ tag, props }, parent) => {
13
- if ((!parent && tag !== 'template')
14
- || (tag === 'template'
15
- && props.some(p => p.type === 6 /* compiler.NodeTypes.ATTRIBUTE */ &&
16
- p.name === 'lang' &&
17
- p.value &&
18
- p.value.content &&
19
- p.value.content !== 'html'))) {
20
- return 2 /* compiler.TextModes.RAWTEXT */;
21
- }
22
- else {
23
- return 0 /* compiler.TextModes.DATA */;
24
- }
25
- },
12
+ parseMode: 'sfc',
26
13
  onError: e => {
27
14
  errors.push(e);
28
15
  },
@@ -41,13 +28,12 @@ function parse(source) {
41
28
  shouldForceReload: () => false,
42
29
  };
43
30
  ast.children.forEach(node => {
44
- if (node.type !== 1 /* compiler.NodeTypes.ELEMENT */) {
31
+ if (node.type !== compiler.NodeTypes.ELEMENT) {
45
32
  return;
46
33
  }
47
34
  switch (node.tag) {
48
35
  case 'template':
49
- const templateBlock = (descriptor.template = createBlock(node, source));
50
- templateBlock.ast = node;
36
+ descriptor.template = createBlock(node, source);
51
37
  break;
52
38
  case 'script':
53
39
  const scriptBlock = createBlock(node, source);
@@ -109,7 +95,7 @@ function createBlock(node, source) {
109
95
  attrs
110
96
  };
111
97
  node.props.forEach(p => {
112
- if (p.type === 6 /* compiler.NodeTypes.ATTRIBUTE */) {
98
+ if (p.type === compiler.NodeTypes.ATTRIBUTE) {
113
99
  attrs[p.name] = p.value ? p.value.content || true : true;
114
100
  if (p.name === 'lang') {
115
101
  block.lang = p.value && p.value.content;
@@ -1,4 +1,3 @@
1
1
  export declare function getSlotsPropertyName(vueVersion: number): "$scopedSlots" | "$slots";
2
2
  export { hyphenate as hyphenateTag } from '@vue/shared';
3
3
  export declare function hyphenateAttr(str: string): string;
4
- //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1,8 @@
1
+ import type * as ts from 'typescript';
2
+ import type { VueCompilerOptions } from '../types';
3
+ export declare function eachInterpolationSegment(ts: typeof import('typescript'), code: string, ast: ts.SourceFile, localVars: Map<string, number>, identifiers: Set<string>, vueOptions: VueCompilerOptions, ctxVars?: {
4
+ text: string;
5
+ isShorthand: boolean;
6
+ offset: number;
7
+ }[]): Generator<[fragment: string, offset: number | undefined, isJustForErrorMapping?: boolean]>;
8
+ export declare function collectVars(ts: typeof import('typescript'), node: ts.Node, ast: ts.SourceFile, result: string[]): void;
@@ -1,94 +1,94 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.collectVars = exports.walkInterpolationFragment = void 0;
3
+ exports.collectVars = exports.eachInterpolationSegment = void 0;
4
4
  const shared_1 = require("@vue/shared");
5
- function walkInterpolationFragment(ts, code, ast, cb, localVars, identifiers, vueOptions) {
6
- let ctxVars = [];
5
+ const scriptSetupRanges_1 = require("../parsers/scriptSetupRanges");
6
+ function* eachInterpolationSegment(ts, code, ast, localVars, identifiers, vueOptions, ctxVars = []) {
7
7
  const varCb = (id, isShorthand) => {
8
- if (localVars.get(id.text) ||
8
+ const text = (0, scriptSetupRanges_1.getNodeText)(ts, id, ast);
9
+ if (localVars.get(text) ||
9
10
  // https://github.com/vuejs/core/blob/245230e135152900189f13a4281302de45fdcfaa/packages/compiler-core/src/transforms/transformExpression.ts#L342-L352
10
- (0, shared_1.isGloballyWhitelisted)(id.text) ||
11
- id.text === 'require' ||
12
- id.text.startsWith('__VLS_')) {
11
+ (0, shared_1.isGloballyWhitelisted)(text) ||
12
+ text === 'require' ||
13
+ text.startsWith('__VLS_')) {
13
14
  // localVarOffsets.push(localVar.getStart(ast));
14
15
  }
15
16
  else {
16
17
  ctxVars.push({
17
- text: id.text,
18
+ text,
18
19
  isShorthand: isShorthand,
19
- offset: id.getStart(ast),
20
+ offset: (0, scriptSetupRanges_1.getStartEnd)(ts, id, ast).start,
20
21
  });
21
- identifiers.add(id.text);
22
+ identifiers.add(text);
22
23
  }
23
24
  };
24
- ast.forEachChild(node => walkIdentifiers(ts, node, varCb, localVars));
25
+ ts.forEachChild(ast, node => walkIdentifiers(ts, node, ast, varCb, localVars));
25
26
  ctxVars = ctxVars.sort((a, b) => a.offset - b.offset);
26
27
  if (ctxVars.length) {
27
28
  if (ctxVars[0].isShorthand) {
28
- cb(code.substring(0, ctxVars[0].offset + ctxVars[0].text.length), 0);
29
- cb(': ', undefined);
29
+ yield [code.substring(0, ctxVars[0].offset + ctxVars[0].text.length), 0];
30
+ yield [': ', undefined];
30
31
  }
31
32
  else {
32
- cb(code.substring(0, ctxVars[0].offset), 0);
33
+ yield [code.substring(0, ctxVars[0].offset), 0];
33
34
  }
34
35
  for (let i = 0; i < ctxVars.length - 1; i++) {
35
36
  // fix https://github.com/vuejs/language-tools/issues/1205
36
37
  // fix https://github.com/vuejs/language-tools/issues/1264
37
- cb('', ctxVars[i + 1].offset, true);
38
+ yield ['', ctxVars[i + 1].offset, true];
38
39
  if (vueOptions.experimentalUseElementAccessInTemplate) {
39
40
  const varStart = ctxVars[i].offset;
40
41
  const varEnd = ctxVars[i].offset + ctxVars[i].text.length;
41
- cb('__VLS_ctx[', undefined);
42
- cb('', varStart, true);
43
- cb("'", undefined);
44
- cb(code.substring(varStart, varEnd), varStart);
45
- cb("'", undefined);
46
- cb('', varEnd, true);
47
- cb(']', undefined);
42
+ yield ['__VLS_ctx[', undefined];
43
+ yield ['', varStart, true];
44
+ yield ["'", undefined];
45
+ yield [code.substring(varStart, varEnd), varStart];
46
+ yield ["'", undefined];
47
+ yield ['', varEnd, true];
48
+ yield [']', undefined];
48
49
  if (ctxVars[i + 1].isShorthand) {
49
- cb(code.substring(varEnd, ctxVars[i + 1].offset + ctxVars[i + 1].text.length), varEnd);
50
- cb(': ', undefined);
50
+ yield [code.substring(varEnd, ctxVars[i + 1].offset + ctxVars[i + 1].text.length), varEnd];
51
+ yield [': ', undefined];
51
52
  }
52
53
  else {
53
- cb(code.substring(varEnd, ctxVars[i + 1].offset), varEnd);
54
+ yield [code.substring(varEnd, ctxVars[i + 1].offset), varEnd];
54
55
  }
55
56
  }
56
57
  else {
57
- cb('__VLS_ctx.', undefined);
58
+ yield ['__VLS_ctx.', undefined];
58
59
  if (ctxVars[i + 1].isShorthand) {
59
- cb(code.substring(ctxVars[i].offset, ctxVars[i + 1].offset + ctxVars[i + 1].text.length), ctxVars[i].offset);
60
- cb(': ', undefined);
60
+ yield [code.substring(ctxVars[i].offset, ctxVars[i + 1].offset + ctxVars[i + 1].text.length), ctxVars[i].offset];
61
+ yield [': ', undefined];
61
62
  }
62
63
  else {
63
- cb(code.substring(ctxVars[i].offset, ctxVars[i + 1].offset), ctxVars[i].offset);
64
+ yield [code.substring(ctxVars[i].offset, ctxVars[i + 1].offset), ctxVars[i].offset];
64
65
  }
65
66
  }
66
67
  }
67
68
  if (vueOptions.experimentalUseElementAccessInTemplate) {
68
69
  const varStart = ctxVars[ctxVars.length - 1].offset;
69
70
  const varEnd = ctxVars[ctxVars.length - 1].offset + ctxVars[ctxVars.length - 1].text.length;
70
- cb('__VLS_ctx[', undefined);
71
- cb('', varStart, true);
72
- cb("'", undefined);
73
- cb(code.substring(varStart, varEnd), varStart);
74
- cb("'", undefined);
75
- cb('', varEnd, true);
76
- cb(']', undefined);
77
- cb(code.substring(varEnd), varEnd);
71
+ yield ['__VLS_ctx[', undefined];
72
+ yield ['', varStart, true];
73
+ yield ["'", undefined];
74
+ yield [code.substring(varStart, varEnd), varStart];
75
+ yield ["'", undefined];
76
+ yield ['', varEnd, true];
77
+ yield [']', undefined];
78
+ yield [code.substring(varEnd), varEnd];
78
79
  }
79
80
  else {
80
- cb('', ctxVars[ctxVars.length - 1].offset, true);
81
- cb('__VLS_ctx.', undefined);
82
- cb(code.substring(ctxVars[ctxVars.length - 1].offset), ctxVars[ctxVars.length - 1].offset);
81
+ yield ['', ctxVars[ctxVars.length - 1].offset, true];
82
+ yield ['__VLS_ctx.', undefined];
83
+ yield [code.substring(ctxVars[ctxVars.length - 1].offset), ctxVars[ctxVars.length - 1].offset];
83
84
  }
84
85
  }
85
86
  else {
86
- cb(code, 0);
87
+ yield [code, 0];
87
88
  }
88
- return ctxVars;
89
89
  }
90
- exports.walkInterpolationFragment = walkInterpolationFragment;
91
- function walkIdentifiers(ts, node, cb, localVars, blockVars = [], isRoot = true) {
90
+ exports.eachInterpolationSegment = eachInterpolationSegment;
91
+ function walkIdentifiers(ts, node, ast, cb, localVars, blockVars = [], isRoot = true) {
92
92
  if (ts.isIdentifier(node)) {
93
93
  cb(node, false);
94
94
  }
@@ -96,27 +96,27 @@ function walkIdentifiers(ts, node, cb, localVars, blockVars = [], isRoot = true)
96
96
  cb(node.name, true);
97
97
  }
98
98
  else if (ts.isPropertyAccessExpression(node)) {
99
- walkIdentifiers(ts, node.expression, cb, localVars, blockVars, false);
99
+ walkIdentifiers(ts, node.expression, ast, cb, localVars, blockVars, false);
100
100
  }
101
101
  else if (ts.isVariableDeclaration(node)) {
102
- collectVars(ts, node.name, blockVars);
102
+ collectVars(ts, node.name, ast, blockVars);
103
103
  for (const varName of blockVars) {
104
104
  localVars.set(varName, (localVars.get(varName) ?? 0) + 1);
105
105
  }
106
106
  if (node.initializer)
107
- walkIdentifiers(ts, node.initializer, cb, localVars, blockVars, false);
107
+ walkIdentifiers(ts, node.initializer, ast, cb, localVars, blockVars, false);
108
108
  }
109
109
  else if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {
110
110
  const functionArgs = [];
111
111
  for (const param of node.parameters) {
112
- collectVars(ts, param.name, functionArgs);
112
+ collectVars(ts, param.name, ast, functionArgs);
113
113
  if (param.type) {
114
- walkIdentifiers(ts, param.type, cb, localVars, blockVars, false);
114
+ walkIdentifiers(ts, param.type, ast, cb, localVars, blockVars, false);
115
115
  }
116
116
  }
117
117
  for (const varName of functionArgs)
118
118
  localVars.set(varName, (localVars.get(varName) ?? 0) + 1);
119
- walkIdentifiers(ts, node.body, cb, localVars, blockVars, false);
119
+ walkIdentifiers(ts, node.body, ast, cb, localVars, blockVars, false);
120
120
  for (const varName of functionArgs)
121
121
  localVars.set(varName, localVars.get(varName) - 1);
122
122
  }
@@ -125,31 +125,31 @@ function walkIdentifiers(ts, node, cb, localVars, blockVars = [], isRoot = true)
125
125
  if (ts.isPropertyAssignment(prop)) {
126
126
  // fix https://github.com/vuejs/language-tools/issues/1176
127
127
  if (ts.isComputedPropertyName(prop.name)) {
128
- walkIdentifiers(ts, prop.name.expression, cb, localVars, blockVars, false);
128
+ walkIdentifiers(ts, prop.name.expression, ast, cb, localVars, blockVars, false);
129
129
  }
130
- walkIdentifiers(ts, prop.initializer, cb, localVars, blockVars, false);
130
+ walkIdentifiers(ts, prop.initializer, ast, cb, localVars, blockVars, false);
131
131
  }
132
132
  // fix https://github.com/vuejs/language-tools/issues/1156
133
133
  else if (ts.isShorthandPropertyAssignment(prop)) {
134
- walkIdentifiers(ts, prop, cb, localVars, blockVars, false);
134
+ walkIdentifiers(ts, prop, ast, cb, localVars, blockVars, false);
135
135
  }
136
136
  // fix https://github.com/vuejs/language-tools/issues/1148#issuecomment-1094378126
137
137
  else if (ts.isSpreadAssignment(prop)) {
138
138
  // TODO: cannot report "Spread types may only be created from object types.ts(2698)"
139
- walkIdentifiers(ts, prop.expression, cb, localVars, blockVars, false);
139
+ walkIdentifiers(ts, prop.expression, ast, cb, localVars, blockVars, false);
140
140
  }
141
141
  }
142
142
  }
143
143
  else if (ts.isTypeReferenceNode(node)) {
144
144
  // fix https://github.com/vuejs/language-tools/issues/1422
145
- node.forEachChild(node => walkIdentifiersInTypeReference(ts, node, cb));
145
+ ts.forEachChild(node, node => walkIdentifiersInTypeReference(ts, node, cb));
146
146
  }
147
147
  else {
148
148
  const _blockVars = blockVars;
149
149
  if (ts.isBlock(node)) {
150
150
  blockVars = [];
151
151
  }
152
- node.forEachChild(node => walkIdentifiers(ts, node, cb, localVars, blockVars, false));
152
+ ts.forEachChild(node, node => walkIdentifiers(ts, node, ast, cb, localVars, blockVars, false));
153
153
  if (ts.isBlock(node)) {
154
154
  for (const varName of blockVars) {
155
155
  localVars.set(varName, localVars.get(varName) - 1);
@@ -168,27 +168,27 @@ function walkIdentifiersInTypeReference(ts, node, cb) {
168
168
  cb(node.exprName, false);
169
169
  }
170
170
  else {
171
- node.forEachChild(node => walkIdentifiersInTypeReference(ts, node, cb));
171
+ ts.forEachChild(node, node => walkIdentifiersInTypeReference(ts, node, cb));
172
172
  }
173
173
  }
174
- function collectVars(ts, node, result) {
174
+ function collectVars(ts, node, ast, result) {
175
175
  if (ts.isIdentifier(node)) {
176
- result.push(node.text);
176
+ result.push((0, scriptSetupRanges_1.getNodeText)(ts, node, ast));
177
177
  }
178
178
  else if (ts.isObjectBindingPattern(node)) {
179
179
  for (const el of node.elements) {
180
- collectVars(ts, el.name, result);
180
+ collectVars(ts, el.name, ast, result);
181
181
  }
182
182
  }
183
183
  else if (ts.isArrayBindingPattern(node)) {
184
184
  for (const el of node.elements) {
185
185
  if (ts.isBindingElement(el)) {
186
- collectVars(ts, el.name, result);
186
+ collectVars(ts, el.name, ast, result);
187
187
  }
188
188
  }
189
189
  }
190
190
  else {
191
- node.forEachChild(node => collectVars(ts, node, result));
191
+ ts.forEachChild(node, node => collectVars(ts, node, ast, result));
192
192
  }
193
193
  }
194
194
  exports.collectVars = collectVars;
@@ -1,9 +1,8 @@
1
- import type * as ts from 'typescript/lib/tsserverlibrary';
1
+ import type * as ts from 'typescript';
2
2
  import type { VueCompilerOptions } from '../types';
3
3
  export type ParsedCommandLine = ts.ParsedCommandLine & {
4
4
  vueOptions: Partial<VueCompilerOptions>;
5
5
  };
6
- export declare function createParsedCommandLineByJson(ts: typeof import('typescript/lib/tsserverlibrary'), parseConfigHost: ts.ParseConfigHost, rootDir: string, json: any, configFileName?: string): ParsedCommandLine;
7
- export declare function createParsedCommandLine(ts: typeof import('typescript/lib/tsserverlibrary'), parseConfigHost: ts.ParseConfigHost, tsConfigPath: string): ParsedCommandLine;
6
+ export declare function createParsedCommandLineByJson(ts: typeof import('typescript'), parseConfigHost: ts.ParseConfigHost, rootDir: string, json: any, configFileName?: string): ParsedCommandLine;
7
+ export declare function createParsedCommandLine(ts: typeof import('typescript'), parseConfigHost: ts.ParseConfigHost, tsConfigPath: string): ParsedCommandLine;
8
8
  export declare function resolveVueCompilerOptions(vueOptions: Partial<VueCompilerOptions>): VueCompilerOptions;
9
- //# sourceMappingURL=ts.d.ts.map
@@ -132,16 +132,6 @@ function getPartialVueCompilerOptions(ts, tsConfigSourceFile) {
132
132
  .flat(Infinity);
133
133
  result.plugins = plugins;
134
134
  }
135
- if (rawOptions.hooks) {
136
- result.hooks = rawOptions.hooks
137
- .map(resolvePath)
138
- .filter((hook) => !!hook);
139
- }
140
- if (rawOptions.experimentalAdditionalLanguageModules) {
141
- result.experimentalAdditionalLanguageModules = rawOptions.experimentalAdditionalLanguageModules
142
- .map(resolvePath)
143
- .filter((module) => !!module);
144
- }
145
135
  return result;
146
136
  function resolvePath(scriptPath) {
147
137
  try {
@@ -213,10 +203,8 @@ function resolveVueCompilerOptions(vueOptions) {
213
203
  ...vueOptions.macros,
214
204
  },
215
205
  plugins: vueOptions.plugins ?? [],
216
- hooks: vueOptions.hooks ?? [],
217
206
  // experimental
218
207
  experimentalDefinePropProposal: vueOptions.experimentalDefinePropProposal ?? false,
219
- experimentalAdditionalLanguageModules: vueOptions.experimentalAdditionalLanguageModules ?? [],
220
208
  experimentalResolveStyleCssClasses: vueOptions.experimentalResolveStyleCssClasses ?? 'scoped',
221
209
  // https://github.com/vuejs/vue-next/blob/master/packages/compiler-dom/src/transforms/vModel.ts#L49-L51
222
210
  // https://vuejs.org/guide/essentials/forms.html#form-input-bindings
@@ -0,0 +1,2 @@
1
+ import * as CompilerDOM from '@vue/compiler-dom';
2
+ export declare const compile: typeof CompilerDOM.compile;
@@ -3,7 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.compile = void 0;
4
4
  const CompilerDOM = require("@vue/compiler-dom");
5
5
  const Vue2TemplateCompiler = require('vue-template-compiler/build');
6
- function compile(template, options = {}) {
6
+ const compile = (template, options = {}) => {
7
+ if (typeof template !== 'string') {
8
+ throw new Error(`[@vue/language-core] compile() first argument must be string.`);
9
+ }
7
10
  const onError = options.onError;
8
11
  const onWarn = options.onWarn;
9
12
  options.onError = (error) => {
@@ -51,7 +54,7 @@ function compile(template, options = {}) {
51
54
  ],
52
55
  directiveTransforms: Object.assign({}, CompilerDOM.DOMDirectiveTransforms, options.directiveTransforms || {}),
53
56
  }));
54
- }
57
+ };
55
58
  exports.compile = compile;
56
59
  function baseCompile(template, options = {}) {
57
60
  const onError = options.onError || ((error) => { throw error; });
@@ -1,4 +1,3 @@
1
- import { VirtualFile } from '@volar/language-core';
1
+ import { VirtualCode } from '@volar/language-core';
2
2
  import type { Sfc, VueLanguagePlugin } from '../types';
3
- export declare function computedFiles(plugins: ReturnType<VueLanguagePlugin>[], fileName: string, sfc: Sfc, codegenStack: boolean): () => VirtualFile[];
4
- //# sourceMappingURL=computedFiles.d.ts.map
3
+ export declare function computedFiles(plugins: ReturnType<VueLanguagePlugin>[], fileName: string, sfc: Sfc, codegenStack: boolean): () => VirtualCode[];