@vue/language-core 2.0.16 → 2.0.18

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 (39) hide show
  1. package/lib/codegen/script/globalTypes.js +10 -14
  2. package/lib/codegen/script/index.d.ts +3 -6
  3. package/lib/codegen/script/index.js +12 -15
  4. package/lib/codegen/script/internalComponent.js +1 -1
  5. package/lib/codegen/script/scriptSetup.js +21 -23
  6. package/lib/codegen/script/template.d.ts +1 -1
  7. package/lib/codegen/script/template.js +45 -36
  8. package/lib/codegen/template/context.d.ts +8 -3
  9. package/lib/codegen/template/context.js +42 -13
  10. package/lib/codegen/template/element.js +81 -50
  11. package/lib/codegen/template/elementDirectives.js +1 -1
  12. package/lib/codegen/template/elementEvents.d.ts +2 -2
  13. package/lib/codegen/template/elementEvents.js +46 -35
  14. package/lib/codegen/template/elementProps.js +56 -63
  15. package/lib/codegen/template/index.d.ts +4 -46
  16. package/lib/codegen/template/index.js +36 -21
  17. package/lib/codegen/template/interpolation.d.ts +2 -2
  18. package/lib/codegen/template/interpolation.js +12 -46
  19. package/lib/codegen/template/vFor.js +13 -3
  20. package/lib/languageModule.d.ts +1 -1
  21. package/lib/languageModule.js +4 -4
  22. package/lib/parsers/scriptRanges.d.ts +1 -0
  23. package/lib/parsers/scriptRanges.js +7 -0
  24. package/lib/parsers/scriptSetupRanges.d.ts +4 -0
  25. package/lib/parsers/scriptSetupRanges.js +24 -0
  26. package/lib/plugins/file-md.js +1 -0
  27. package/lib/plugins/vue-script-js.d.ts +3 -0
  28. package/lib/plugins/vue-script-js.js +15 -0
  29. package/lib/plugins/vue-template-html.js +1 -1
  30. package/lib/plugins/vue-template-inline-ts.js +1 -1
  31. package/lib/plugins/vue-tsx.d.ts +46 -40
  32. package/lib/plugins/vue-tsx.js +34 -28
  33. package/lib/plugins.d.ts +1 -0
  34. package/lib/plugins.js +2 -0
  35. package/lib/types.d.ts +1 -15
  36. package/lib/utils/parseCssClassNames.js +1 -1
  37. package/lib/utils/ts.js +0 -1
  38. package/lib/virtualFile/computedSfc.js +20 -5
  39. package/package.json +3 -3
package/lib/plugins.js CHANGED
@@ -19,6 +19,7 @@ const vue_sfc_customblocks_1 = require("./plugins/vue-sfc-customblocks");
19
19
  const vue_sfc_scripts_1 = require("./plugins/vue-sfc-scripts");
20
20
  const vue_sfc_styles_1 = require("./plugins/vue-sfc-styles");
21
21
  const vue_sfc_template_1 = require("./plugins/vue-sfc-template");
22
+ const vue_script_js_1 = require("./plugins/vue-script-js");
22
23
  const vue_template_html_1 = require("./plugins/vue-template-html");
23
24
  const vue_template_inline_css_1 = require("./plugins/vue-template-inline-css");
24
25
  const vue_template_inline_ts_1 = require("./plugins/vue-template-inline-ts");
@@ -27,6 +28,7 @@ const types_1 = require("./types");
27
28
  __exportStar(require("./plugins/shared"), exports);
28
29
  function getBasePlugins(pluginContext) {
29
30
  const plugins = [
31
+ vue_script_js_1.default,
30
32
  vue_template_html_1.default,
31
33
  vue_template_inline_css_1.default,
32
34
  vue_template_inline_ts_1.default,
package/lib/types.d.ts CHANGED
@@ -10,8 +10,6 @@ export type RawVueCompilerOptions = Partial<Omit<VueCompilerOptions, 'target' |
10
10
  plugins?: string[];
11
11
  };
12
12
  export interface VueCodeInformation extends CodeInformation {
13
- __referencesCodeLens?: boolean;
14
- __displayWithLink?: boolean;
15
13
  __hint?: {
16
14
  setting: string;
17
15
  label: string;
@@ -48,7 +46,6 @@ export interface VueCompilerOptions {
48
46
  experimentalDefinePropProposal: 'kevinEdition' | 'johnsonEdition' | false;
49
47
  experimentalResolveStyleCssClasses: 'scoped' | 'always' | 'never';
50
48
  experimentalModelPropName: Record<string, Record<string, boolean | Record<string, string> | Record<string, string>[]>>;
51
- experimentalUseElementAccessInTemplate: boolean;
52
49
  }
53
50
  export declare const pluginVersion = 2;
54
51
  export type VueLanguagePlugin = (ctx: {
@@ -71,6 +68,7 @@ export type VueLanguagePlugin = (ctx: {
71
68
  newText: string;
72
69
  }): SFCParseResult | undefined;
73
70
  resolveTemplateCompilerOptions?(options: CompilerDOM.CompilerOptions): CompilerDOM.CompilerOptions;
71
+ compileSFCScript?(lang: string, script: string): ts.SourceFile | undefined;
74
72
  compileSFCTemplate?(lang: string, template: string, options: CompilerDOM.CompilerOptions): CompilerDOM.CodegenResult | undefined;
75
73
  updateSFCTemplate?(oldResult: CompilerDOM.CodegenResult, textChange: {
76
74
  start: number;
@@ -124,18 +122,6 @@ export interface Sfc {
124
122
  customBlocks: readonly (SfcBlock & {
125
123
  type: string;
126
124
  })[];
127
- /**
128
- * @deprecated use `template.ast` instead
129
- */
130
- templateAst: CompilerDOM.RootNode | undefined;
131
- /**
132
- * @deprecated use `script.ast` instead
133
- */
134
- scriptAst: ts.SourceFile | undefined;
135
- /**
136
- * @deprecated use `scriptSetup.ast` instead
137
- */
138
- scriptSetupAst: ts.SourceFile | undefined;
139
125
  }
140
126
  export interface TextRange {
141
127
  start: number;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseCssClassNames = void 0;
4
4
  const parseCssVars_1 = require("./parseCssVars");
5
- const cssClassNameReg = /(?=([\.]{1}[a-zA-Z_]+[\w\_\-]*)[\s\.\+\{\>#\:]{1})/g;
5
+ const cssClassNameReg = /(?=([\.]{1}[a-zA-Z_]+[\w\_\-]*)[\s\.\,\+\{\>#\:]{1})/g;
6
6
  function* parseCssClassNames(styleContent) {
7
7
  styleContent = (0, parseCssVars_1.clearComments)(styleContent);
8
8
  const matches = styleContent.matchAll(cssClassNameReg);
package/lib/utils/ts.js CHANGED
@@ -210,7 +210,6 @@ function resolveVueCompilerOptions(vueOptions) {
210
210
  select: true
211
211
  }
212
212
  },
213
- experimentalUseElementAccessInTemplate: vueOptions.experimentalUseElementAccessInTemplate ?? false,
214
213
  };
215
214
  }
216
215
  exports.resolveVueCompilerOptions = resolveVueCompilerOptions;
@@ -25,7 +25,16 @@ function computedSfc(ts, plugins, fileName, snapshot, parsed) {
25
25
  const _src = src();
26
26
  return _src ? untrackedSnapshot().getText(0, base.startTagEnd).lastIndexOf(_src) - base.startTagEnd : -1;
27
27
  });
28
- const ast = (0, computeds_1.computed)(() => ts.createSourceFile(fileName + '.' + base.lang, base.content, 99));
28
+ const ast = (0, computeds_1.computed)(() => {
29
+ for (const plugin of plugins) {
30
+ const ast = plugin.compileSFCScript?.(base.lang, base.content);
31
+ if (ast) {
32
+ return ast;
33
+ ;
34
+ }
35
+ }
36
+ return ts.createSourceFile(fileName + '.' + base.lang, '', 99);
37
+ });
29
38
  return mergeObject(base, {
30
39
  get src() { return src(); },
31
40
  get srcOffset() { return srcOffset(); },
@@ -41,7 +50,16 @@ function computedSfc(ts, plugins, fileName, snapshot, parsed) {
41
50
  const _generic = generic();
42
51
  return _generic !== undefined ? untrackedSnapshot().getText(0, base.startTagEnd).lastIndexOf(_generic) - base.startTagEnd : -1;
43
52
  });
44
- const ast = (0, computeds_1.computed)(() => ts.createSourceFile(fileName + '.' + base.lang, base.content, 99));
53
+ const ast = (0, computeds_1.computed)(() => {
54
+ for (const plugin of plugins) {
55
+ const ast = plugin.compileSFCScript?.(base.lang, base.content);
56
+ if (ast) {
57
+ return ast;
58
+ ;
59
+ }
60
+ }
61
+ return ts.createSourceFile(fileName + '.' + base.lang, '', 99);
62
+ });
45
63
  return mergeObject(base, {
46
64
  get generic() { return generic(); },
47
65
  get genericOffset() { return genericOffset(); },
@@ -95,9 +113,6 @@ function computedSfc(ts, plugins, fileName, snapshot, parsed) {
95
113
  get scriptSetup() { return scriptSetup(); },
96
114
  get styles() { return styles; },
97
115
  get customBlocks() { return customBlocks; },
98
- get templateAst() { return template()?.ast; },
99
- get scriptAst() { return script()?.ast; },
100
- get scriptSetupAst() { return scriptSetup()?.ast; },
101
116
  };
102
117
  function computedTemplateAst(base) {
103
118
  let cache;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-core",
3
- "version": "2.0.16",
3
+ "version": "2.0.18",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -12,7 +12,7 @@
12
12
  "directory": "packages/language-core"
13
13
  },
14
14
  "dependencies": {
15
- "@volar/language-core": "~2.2.0",
15
+ "@volar/language-core": "~2.2.4",
16
16
  "@vue/compiler-dom": "^3.4.0",
17
17
  "@vue/shared": "^3.4.0",
18
18
  "computeds": "^0.0.1",
@@ -34,5 +34,5 @@
34
34
  "optional": true
35
35
  }
36
36
  },
37
- "gitHead": "95b78c38cbf75481ebb59e11956b592346f01d92"
37
+ "gitHead": "7aac2805f03b17e4c624335f509d502002bb75a8"
38
38
  }