@vue/typescript-plugin 3.0.0-beta.1 → 3.0.0-beta.2

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 (2) hide show
  1. package/lib/common.js +26 -2
  2. package/package.json +3 -3
package/lib/common.js CHANGED
@@ -10,7 +10,7 @@ function createVueLanguageServiceProxy(ts, language, languageService, vueOptions
10
10
  const proxyCache = new Map();
11
11
  const getProxyMethod = (target, p) => {
12
12
  switch (p) {
13
- case 'getCompletionsAtPosition': return getCompletionsAtPosition(vueOptions, target[p]);
13
+ case 'getCompletionsAtPosition': return getCompletionsAtPosition(ts, language, vueOptions, asScriptId, target[p]);
14
14
  case 'getCompletionEntryDetails': return getCompletionEntryDetails(language, asScriptId, target[p]);
15
15
  case 'getCodeFixesAtPosition': return getCodeFixesAtPosition(target[p]);
16
16
  case 'getDefinitionAndBoundSpan': return getDefinitionAndBoundSpan(ts, language, languageService, vueOptions, asScriptId, target[p]);
@@ -37,7 +37,7 @@ function createVueLanguageServiceProxy(ts, language, languageService, vueOptions
37
37
  },
38
38
  });
39
39
  }
40
- function getCompletionsAtPosition(vueOptions, getCompletionsAtPosition) {
40
+ function getCompletionsAtPosition(ts, language, vueOptions, asScriptId, getCompletionsAtPosition) {
41
41
  return (filePath, position, options, formattingSettings) => {
42
42
  const fileName = filePath.replace(windowsPathReg, '/');
43
43
  const result = getCompletionsAtPosition(fileName, position, options, formattingSettings);
@@ -45,6 +45,30 @@ function getCompletionsAtPosition(vueOptions, getCompletionsAtPosition) {
45
45
  // filter __VLS_
46
46
  result.entries = result.entries.filter(entry => !entry.name.includes('__VLS_')
47
47
  && !entry.labelDetails?.description?.includes('__VLS_'));
48
+ // filter global variables in template and styles
49
+ const sourceScript = language.scripts.get(asScriptId(fileName));
50
+ const root = sourceScript?.generated?.root;
51
+ if (root instanceof language_core_1.VueVirtualCode) {
52
+ const blocks = [
53
+ root.sfc.template,
54
+ ...root.sfc.styles,
55
+ ];
56
+ const ranges = blocks.filter(Boolean).map(block => [
57
+ block.startTagEnd,
58
+ block.endTagStart,
59
+ ]);
60
+ if (ranges.some(([start, end]) => position >= start && position <= end)) {
61
+ const globalsOrKeywords = ts.Completions.SortText.GlobalsOrKeywords;
62
+ const sortTexts = new Set([
63
+ globalsOrKeywords,
64
+ 'z' + globalsOrKeywords,
65
+ globalsOrKeywords + '1',
66
+ ]);
67
+ result.entries = result.entries.filter(entry => !(entry.kind === 'const' && entry.name in vueOptions.macros) && (entry.kind !== 'var' && entry.kind !== 'function'
68
+ || !sortTexts.has(entry.sortText)
69
+ || (0, shared_1.isGloballyAllowed)(entry.name)));
70
+ }
71
+ }
48
72
  // modify label
49
73
  for (const item of result.entries) {
50
74
  if (item.source) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/typescript-plugin",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-beta.2",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@volar/typescript": "2.4.14",
17
- "@vue/language-core": "3.0.0-beta.1",
17
+ "@vue/language-core": "3.0.0-beta.2",
18
18
  "@vue/shared": "^3.5.0",
19
19
  "path-browserify": "^1.0.1"
20
20
  },
@@ -22,5 +22,5 @@
22
22
  "@types/node": "^22.10.4",
23
23
  "@types/path-browserify": "^1.0.1"
24
24
  },
25
- "gitHead": "7a2ea48123679387d7095a81ac49cfc667aeeabb"
25
+ "gitHead": "ea40288f6fceebb65346732b6de5859c300cf1ee"
26
26
  }