vue-component-meta 1.0.0-beta.8 → 1.0.0-rc.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.
- package/README.md +1 -1
- package/out/index.d.ts +17 -2
- package/out/index.js +74 -32
- package/package.json +5 -4
package/README.md
CHANGED
package/out/index.d.ts
CHANGED
|
@@ -2,11 +2,16 @@ import * as vue from '@volar/vue-language-core';
|
|
|
2
2
|
import * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
3
|
import type { MetaCheckerOptions, ComponentMeta, EventMeta, ExposeMeta, MetaCheckerSchemaOptions, PropertyMeta, PropertyMetaSchema, SlotMeta } from './types';
|
|
4
4
|
export type { MetaCheckerOptions, ComponentMeta, EventMeta, ExposeMeta, MetaCheckerSchemaOptions, PropertyMeta, PropertyMetaSchema, SlotMeta };
|
|
5
|
-
export type ComponentMetaChecker = ReturnType<typeof
|
|
5
|
+
export type ComponentMetaChecker = ReturnType<typeof baseCreate>;
|
|
6
6
|
export declare function createComponentMetaCheckerByJsonConfig(root: string, json: any, checkerOptions?: MetaCheckerOptions): {
|
|
7
7
|
getExportNames: (componentPath: string) => string[];
|
|
8
8
|
getComponentMeta: (componentPath: string, exportName?: string) => ComponentMeta;
|
|
9
|
+
updateFile(fileName: string, text: string): void;
|
|
10
|
+
deleteFile(fileName: string): void;
|
|
11
|
+
reload(): void;
|
|
12
|
+
clearCache(): void;
|
|
9
13
|
__internal__: {
|
|
14
|
+
parsedCommandLine: vue.ParsedCommandLine;
|
|
10
15
|
program: ts.Program;
|
|
11
16
|
tsLs: ts.LanguageService;
|
|
12
17
|
typeChecker: ts.TypeChecker;
|
|
@@ -15,16 +20,26 @@ export declare function createComponentMetaCheckerByJsonConfig(root: string, jso
|
|
|
15
20
|
export declare function createComponentMetaChecker(tsconfigPath: string, checkerOptions?: MetaCheckerOptions): {
|
|
16
21
|
getExportNames: (componentPath: string) => string[];
|
|
17
22
|
getComponentMeta: (componentPath: string, exportName?: string) => ComponentMeta;
|
|
23
|
+
updateFile(fileName: string, text: string): void;
|
|
24
|
+
deleteFile(fileName: string): void;
|
|
25
|
+
reload(): void;
|
|
26
|
+
clearCache(): void;
|
|
18
27
|
__internal__: {
|
|
28
|
+
parsedCommandLine: vue.ParsedCommandLine;
|
|
19
29
|
program: ts.Program;
|
|
20
30
|
tsLs: ts.LanguageService;
|
|
21
31
|
typeChecker: ts.TypeChecker;
|
|
22
32
|
};
|
|
23
33
|
};
|
|
24
|
-
declare function
|
|
34
|
+
declare function baseCreate(loadParsedCommandLine: () => vue.ParsedCommandLine, checkerOptions: MetaCheckerOptions, globalComponentName: string): {
|
|
25
35
|
getExportNames: (componentPath: string) => string[];
|
|
26
36
|
getComponentMeta: (componentPath: string, exportName?: string) => ComponentMeta;
|
|
37
|
+
updateFile(fileName: string, text: string): void;
|
|
38
|
+
deleteFile(fileName: string): void;
|
|
39
|
+
reload(): void;
|
|
40
|
+
clearCache(): void;
|
|
27
41
|
__internal__: {
|
|
42
|
+
parsedCommandLine: vue.ParsedCommandLine;
|
|
28
43
|
program: ts.Program;
|
|
29
44
|
tsLs: ts.LanguageService;
|
|
30
45
|
typeChecker: ts.TypeChecker;
|
package/out/index.js
CHANGED
|
@@ -3,55 +3,75 @@ exports.createComponentMetaChecker = exports.createComponentMetaCheckerByJsonCon
|
|
|
3
3
|
const vue = require("@volar/vue-language-core");
|
|
4
4
|
const embedded = require("@volar/language-core");
|
|
5
5
|
const ts = require("typescript/lib/tsserverlibrary");
|
|
6
|
+
const path = require("typesafe-path/posix");
|
|
6
7
|
const extraFileExtensions = [{
|
|
7
8
|
extension: 'vue',
|
|
8
9
|
isMixedContent: true,
|
|
9
10
|
scriptKind: ts.ScriptKind.Deferred,
|
|
10
11
|
}];
|
|
11
12
|
function createComponentMetaCheckerByJsonConfig(root, json, checkerOptions = {}) {
|
|
12
|
-
|
|
13
|
-
for (const error of parsedCommandLine.errors) {
|
|
14
|
-
console.error(error);
|
|
15
|
-
}
|
|
16
|
-
return createComponentMetaCheckerBase(root + '/jsconfig.json', parsedCommandLine, checkerOptions);
|
|
13
|
+
return baseCreate(() => vue.createParsedCommandLineByJson(ts, ts.sys, root, json, extraFileExtensions), checkerOptions, path.join(root.replace(/\\/g, '/'), 'jsconfig.json.global.vue'));
|
|
17
14
|
}
|
|
18
15
|
exports.createComponentMetaCheckerByJsonConfig = createComponentMetaCheckerByJsonConfig;
|
|
19
16
|
function createComponentMetaChecker(tsconfigPath, checkerOptions = {}) {
|
|
20
|
-
|
|
21
|
-
for (const error of parsedCommandLine.errors) {
|
|
22
|
-
console.error(error);
|
|
23
|
-
}
|
|
24
|
-
return createComponentMetaCheckerBase(tsconfigPath, parsedCommandLine, checkerOptions);
|
|
17
|
+
return baseCreate(() => vue.createParsedCommandLine(ts, ts.sys, tsconfigPath, extraFileExtensions), checkerOptions, tsconfigPath.replace(/\\/g, '/') + '.global.vue');
|
|
25
18
|
}
|
|
26
19
|
exports.createComponentMetaChecker = createComponentMetaChecker;
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
function baseCreate(loadParsedCommandLine, checkerOptions, globalComponentName) {
|
|
21
|
+
/**
|
|
22
|
+
* Original Host
|
|
23
|
+
*/
|
|
24
|
+
let parsedCommandLine = loadParsedCommandLine();
|
|
25
|
+
let fileNames = parsedCommandLine.fileNames.map(path => path.replace(/\\/g, '/'));
|
|
26
|
+
let projectVersion = 0;
|
|
27
|
+
const scriptSnapshots = new Map();
|
|
28
|
+
const scriptVersions = new Map();
|
|
29
|
+
const _host = Object.assign(Object.assign({}, ts.sys), { getProjectVersion: () => projectVersion.toString(), getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options), useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames, getCompilationSettings: () => parsedCommandLine.options, getScriptFileNames: () => fileNames, getProjectReferences: () => parsedCommandLine.projectReferences, getScriptVersion: (fileName) => { var _a, _b; return (_b = (_a = scriptVersions.get(fileName)) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : ''; }, getScriptSnapshot: (fileName) => {
|
|
30
|
+
if (!scriptSnapshots.has(fileName)) {
|
|
31
|
+
const fileText = ts.sys.readFile(fileName);
|
|
32
|
+
if (fileText !== undefined) {
|
|
33
|
+
scriptSnapshots.set(fileName, ts.ScriptSnapshot.fromString(fileText));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return scriptSnapshots.get(fileName);
|
|
37
|
+
}, getTypeScriptModule: () => ts, getVueCompilationSettings: () => parsedCommandLine.vueOptions });
|
|
38
|
+
/**
|
|
39
|
+
* Meta
|
|
40
|
+
*/
|
|
41
|
+
const globalComponentSnapshot = ts.ScriptSnapshot.fromString('<script setup lang="ts"></script>');
|
|
42
|
+
const metaSnapshots = {};
|
|
43
|
+
const host = new Proxy({
|
|
44
|
+
getScriptFileNames: () => {
|
|
45
|
+
const names = _host.getScriptFileNames();
|
|
31
46
|
return [
|
|
32
|
-
...
|
|
33
|
-
...
|
|
47
|
+
...names,
|
|
48
|
+
...names.map(getMetaFileName),
|
|
34
49
|
globalComponentName,
|
|
35
50
|
getMetaFileName(globalComponentName),
|
|
36
51
|
];
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
else if (fileName === globalComponentName) {
|
|
44
|
-
fileText = `<script setup lang="ts"></script>`;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
fileText = ts.sys.readFile(fileName);
|
|
48
|
-
}
|
|
49
|
-
if (fileText !== undefined) {
|
|
50
|
-
scriptSnapshot[fileName] = ts.ScriptSnapshot.fromString(fileText);
|
|
52
|
+
},
|
|
53
|
+
getScriptSnapshot: fileName => {
|
|
54
|
+
if (isMetaFileName(fileName)) {
|
|
55
|
+
if (!metaSnapshots[fileName]) {
|
|
56
|
+
metaSnapshots[fileName] = ts.ScriptSnapshot.fromString(getMetaScriptContent(fileName));
|
|
51
57
|
}
|
|
58
|
+
return metaSnapshots[fileName];
|
|
52
59
|
}
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
else if (fileName === globalComponentName) {
|
|
61
|
+
return globalComponentSnapshot;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return _host.getScriptSnapshot(fileName);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
}, {
|
|
68
|
+
get(target, prop) {
|
|
69
|
+
if (prop in target) {
|
|
70
|
+
return target[prop];
|
|
71
|
+
}
|
|
72
|
+
return _host[prop];
|
|
73
|
+
},
|
|
74
|
+
});
|
|
55
75
|
const vueLanguageModule = vue.createEmbeddedLanguageModule(host.getTypeScriptModule(), host.getCurrentDirectory(), host.getCompilationSettings(), host.getVueCompilationSettings(), ['.vue']);
|
|
56
76
|
const core = embedded.createEmbeddedLanguageServiceHost(host, [vueLanguageModule]);
|
|
57
77
|
const proxyApis = checkerOptions.forceUseTs ? {
|
|
@@ -81,7 +101,29 @@ function createComponentMetaCheckerBase(tsconfigPath, parsedCommandLine, checker
|
|
|
81
101
|
return {
|
|
82
102
|
getExportNames,
|
|
83
103
|
getComponentMeta,
|
|
104
|
+
updateFile(fileName, text) {
|
|
105
|
+
fileName = fileName.replace(/\\/g, '/');
|
|
106
|
+
scriptSnapshots.set(fileName, ts.ScriptSnapshot.fromString(text));
|
|
107
|
+
scriptVersions.set(fileName, scriptVersions.has(fileName) ? scriptVersions.get(fileName) + 1 : 1);
|
|
108
|
+
projectVersion++;
|
|
109
|
+
},
|
|
110
|
+
deleteFile(fileName) {
|
|
111
|
+
fileName = fileName.replace(/\\/g, '/');
|
|
112
|
+
fileNames = fileNames.filter(f => f !== fileName);
|
|
113
|
+
projectVersion++;
|
|
114
|
+
},
|
|
115
|
+
reload() {
|
|
116
|
+
parsedCommandLine = loadParsedCommandLine();
|
|
117
|
+
fileNames = parsedCommandLine.fileNames.map(path => path.replace(/\\/g, '/'));
|
|
118
|
+
this.clearCache();
|
|
119
|
+
},
|
|
120
|
+
clearCache() {
|
|
121
|
+
scriptSnapshots.clear();
|
|
122
|
+
scriptVersions.clear();
|
|
123
|
+
projectVersion++;
|
|
124
|
+
},
|
|
84
125
|
__internal__: {
|
|
126
|
+
parsedCommandLine,
|
|
85
127
|
program,
|
|
86
128
|
tsLs,
|
|
87
129
|
typeChecker,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-component-meta",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc.2",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
"directory": "vue-language-tools/vue-component-meta"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "1.0.0-
|
|
17
|
-
"@volar/vue-language-core": "1.0.0-
|
|
16
|
+
"@volar/language-core": "1.0.0-rc.2",
|
|
17
|
+
"@volar/vue-language-core": "1.0.0-rc.2",
|
|
18
|
+
"typesafe-path": "^0.2.1"
|
|
18
19
|
},
|
|
19
20
|
"peerDependencies": {
|
|
20
21
|
"typescript": "*"
|
|
21
22
|
},
|
|
22
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "f963241a38a0cc51ee8ff2a6aaa5a025e19fdfcb"
|
|
23
24
|
}
|