vue-component-meta 2.0.4 → 2.0.6
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 +4 -4
- package/lib/base.js +22 -3
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
## Guide 📗
|
|
6
6
|
|
|
7
|
-
First of all, you need to create a component meta checker using `
|
|
7
|
+
First of all, you need to create a component meta checker using `createChecker`:
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
import * as url from 'url'
|
|
11
11
|
import path from 'path'
|
|
12
12
|
|
|
13
13
|
import type { MetaCheckerOptions } from 'vue-component-meta'
|
|
14
|
-
import {
|
|
14
|
+
import { createChecker } from 'vue-component-meta'
|
|
15
15
|
|
|
16
16
|
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
|
|
17
17
|
|
|
@@ -21,7 +21,7 @@ const checkerOptions: MetaCheckerOptions = {
|
|
|
21
21
|
printer: { newLine: 1 },
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const tsconfigChecker =
|
|
24
|
+
const tsconfigChecker = createChecker(
|
|
25
25
|
// Write your tsconfig path
|
|
26
26
|
path.join(__dirname, 'path-to-tsconfig'),
|
|
27
27
|
checkerOptions,
|
|
@@ -40,7 +40,7 @@ const componentPath = path.join(__dirname, 'path-to-component');
|
|
|
40
40
|
const meta = checker.getComponentMeta(componentPath);
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
This meta contains really useful stuff like component props, slots, events and more. You can refer to its [type definition](https://github.com/vuejs/language-tools/blob/master/packages/component-meta/
|
|
43
|
+
This meta contains really useful stuff like component props, slots, events and more. You can refer to its [type definition](https://github.com/vuejs/language-tools/blob/master/packages/component-meta/lib/types.ts) for more details.
|
|
44
44
|
|
|
45
45
|
### Extracting prop meta
|
|
46
46
|
|
package/lib/base.js
CHANGED
|
@@ -40,6 +40,7 @@ function createCheckerWorker(ts, loadParsedCommandLine, checkerOptions, rootPath
|
|
|
40
40
|
let fileNames = parsedCommandLine.fileNames.map(path => path.replace(windowsPathReg, '/'));
|
|
41
41
|
let projectVersion = 0;
|
|
42
42
|
const scriptSnapshots = new Map();
|
|
43
|
+
const resolvedVueOptions = vue.resolveVueCompilerOptions(parsedCommandLine.vueOptions);
|
|
43
44
|
const _host = {
|
|
44
45
|
getCurrentDirectory: () => rootPath,
|
|
45
46
|
getProjectVersion: () => projectVersion.toString(),
|
|
@@ -55,10 +56,15 @@ function createCheckerWorker(ts, loadParsedCommandLine, checkerOptions, rootPath
|
|
|
55
56
|
}
|
|
56
57
|
return scriptSnapshots.get(fileName);
|
|
57
58
|
},
|
|
58
|
-
getLanguageId:
|
|
59
|
+
getLanguageId: fileName => {
|
|
60
|
+
if (resolvedVueOptions.extensions.some(ext => fileName.endsWith(ext))) {
|
|
61
|
+
return 'vue';
|
|
62
|
+
}
|
|
63
|
+
return vue.resolveCommonLanguageId(fileName);
|
|
64
|
+
},
|
|
59
65
|
};
|
|
60
66
|
return {
|
|
61
|
-
...baseCreate(ts, configFileName, _host,
|
|
67
|
+
...baseCreate(ts, configFileName, _host, resolvedVueOptions, checkerOptions, globalComponentName),
|
|
62
68
|
updateFile(fileName, text) {
|
|
63
69
|
fileName = fileName.replace(windowsPathReg, '/');
|
|
64
70
|
scriptSnapshots.set(fileName, ts.ScriptSnapshot.fromString(text));
|
|
@@ -108,7 +114,20 @@ function baseCreate(ts, configFileName, host, vueCompilerOptions, checkerOptions
|
|
|
108
114
|
return getScriptSnapshot(fileName);
|
|
109
115
|
}
|
|
110
116
|
};
|
|
111
|
-
const vueLanguagePlugin = vue.createVueLanguagePlugin(ts, id => id,
|
|
117
|
+
const vueLanguagePlugin = vue.createVueLanguagePlugin(ts, id => id, fileName => {
|
|
118
|
+
if (ts.sys.useCaseSensitiveFileNames) {
|
|
119
|
+
return host.getScriptFileNames().includes(fileName) ?? false;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
const lowerFileName = fileName.toLowerCase();
|
|
123
|
+
for (const rootFile of host.getScriptFileNames()) {
|
|
124
|
+
if (rootFile.toLowerCase() === lowerFileName) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
}, host.getCompilationSettings(), vueCompilerOptions);
|
|
112
131
|
const language = (0, typescript_1.createLanguage)(ts, ts.sys, [vueLanguagePlugin], configFileName, host, {
|
|
113
132
|
fileIdToFileName: id => id,
|
|
114
133
|
fileNameToFileId: id => id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-component-meta",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"directory": "packages/component-meta"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/typescript": "~2.1.
|
|
16
|
-
"@vue/language-core": "2.0.
|
|
15
|
+
"@volar/typescript": "~2.1.2",
|
|
16
|
+
"@vue/language-core": "2.0.6",
|
|
17
17
|
"path-browserify": "^1.0.1",
|
|
18
|
-
"vue-component-type-helpers": "2.0.
|
|
18
|
+
"vue-component-type-helpers": "2.0.6"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"typescript": "*"
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"@types/node": "latest",
|
|
30
30
|
"@types/path-browserify": "latest"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "feb990ccec85f6330bba37c8b1d1287f0980274c"
|
|
33
33
|
}
|