vue-component-meta 1.7.8 → 1.7.9
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/out/index.d.ts +22 -4
- package/out/index.js +17 -28
- package/package.json +5 -5
package/out/index.d.ts
CHANGED
|
@@ -11,7 +11,13 @@ export declare function createComponentMetaCheckerByJsonConfig(root: string, jso
|
|
|
11
11
|
getExportNames: (componentPath: string) => string[];
|
|
12
12
|
getComponentMeta: (componentPath: string, exportName?: string) => ComponentMeta;
|
|
13
13
|
__internal__: {
|
|
14
|
-
tsLs:
|
|
14
|
+
tsLs: {
|
|
15
|
+
__internal__: {
|
|
16
|
+
languageServiceHost: ts.LanguageServiceHost;
|
|
17
|
+
languageService: ts.LanguageService;
|
|
18
|
+
context: vue.LanguageContext;
|
|
19
|
+
};
|
|
20
|
+
} & ts.LanguageService;
|
|
15
21
|
};
|
|
16
22
|
};
|
|
17
23
|
export declare function createComponentMetaChecker(tsconfigPath: string, checkerOptions?: MetaCheckerOptions, ts?: typeof import('typescript/lib/tsserverlibrary')): {
|
|
@@ -22,13 +28,25 @@ export declare function createComponentMetaChecker(tsconfigPath: string, checker
|
|
|
22
28
|
getExportNames: (componentPath: string) => string[];
|
|
23
29
|
getComponentMeta: (componentPath: string, exportName?: string) => ComponentMeta;
|
|
24
30
|
__internal__: {
|
|
25
|
-
tsLs:
|
|
31
|
+
tsLs: {
|
|
32
|
+
__internal__: {
|
|
33
|
+
languageServiceHost: ts.LanguageServiceHost;
|
|
34
|
+
languageService: ts.LanguageService;
|
|
35
|
+
context: vue.LanguageContext;
|
|
36
|
+
};
|
|
37
|
+
} & ts.LanguageService;
|
|
26
38
|
};
|
|
27
39
|
};
|
|
28
|
-
export declare function baseCreate(_host: vue.
|
|
40
|
+
export declare function baseCreate(_host: vue.TypeScriptLanguageHost, _vueCompilerOptions: Partial<vue.VueCompilerOptions>, checkerOptions: MetaCheckerOptions, globalComponentName: string, ts: typeof import('typescript/lib/tsserverlibrary')): {
|
|
29
41
|
getExportNames: (componentPath: string) => string[];
|
|
30
42
|
getComponentMeta: (componentPath: string, exportName?: string) => ComponentMeta;
|
|
31
43
|
__internal__: {
|
|
32
|
-
tsLs:
|
|
44
|
+
tsLs: {
|
|
45
|
+
__internal__: {
|
|
46
|
+
languageServiceHost: ts.LanguageServiceHost;
|
|
47
|
+
languageService: ts.LanguageService;
|
|
48
|
+
context: vue.LanguageContext;
|
|
49
|
+
};
|
|
50
|
+
} & ts.LanguageService;
|
|
33
51
|
};
|
|
34
52
|
};
|
package/out/index.js
CHANGED
|
@@ -16,19 +16,21 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.baseCreate = exports.createComponentMetaChecker = exports.createComponentMetaCheckerByJsonConfig = void 0;
|
|
18
18
|
const vue = require("@vue/language-core");
|
|
19
|
-
const language_core_1 = require("@volar/language-core");
|
|
20
19
|
const path = require("typesafe-path/posix");
|
|
21
20
|
const vue_component_type_helpers_1 = require("vue-component-type-helpers");
|
|
21
|
+
const typescript_1 = require("@volar/typescript");
|
|
22
22
|
__exportStar(require("./types"), exports);
|
|
23
23
|
function createComponentMetaCheckerByJsonConfig(root, json, checkerOptions = {}, ts = require('typescript')) {
|
|
24
|
-
|
|
24
|
+
const rootPath = root.replace(/\\/g, '/');
|
|
25
|
+
return createComponentMetaCheckerWorker(() => vue.createParsedCommandLineByJson(ts, ts.sys, root, json), checkerOptions, rootPath, path.join(rootPath, 'jsconfig.json.global.vue'), ts);
|
|
25
26
|
}
|
|
26
27
|
exports.createComponentMetaCheckerByJsonConfig = createComponentMetaCheckerByJsonConfig;
|
|
27
28
|
function createComponentMetaChecker(tsconfigPath, checkerOptions = {}, ts = require('typescript')) {
|
|
28
|
-
|
|
29
|
+
const tsconfig = tsconfigPath.replace(/\\/g, '/');
|
|
30
|
+
return createComponentMetaCheckerWorker(() => vue.createParsedCommandLine(ts, ts.sys, tsconfigPath), checkerOptions, path.dirname(tsconfig), tsconfig + '.global.vue', ts);
|
|
29
31
|
}
|
|
30
32
|
exports.createComponentMetaChecker = createComponentMetaChecker;
|
|
31
|
-
function createComponentMetaCheckerWorker(loadParsedCommandLine, checkerOptions, globalComponentName, ts) {
|
|
33
|
+
function createComponentMetaCheckerWorker(loadParsedCommandLine, checkerOptions, rootPath, globalComponentName, ts) {
|
|
32
34
|
/**
|
|
33
35
|
* Original Host
|
|
34
36
|
*/
|
|
@@ -36,16 +38,12 @@ function createComponentMetaCheckerWorker(loadParsedCommandLine, checkerOptions,
|
|
|
36
38
|
let fileNames = parsedCommandLine.fileNames.map(path => path.replace(/\\/g, '/'));
|
|
37
39
|
let projectVersion = 0;
|
|
38
40
|
const scriptSnapshots = new Map();
|
|
39
|
-
const scriptVersions = new Map();
|
|
40
41
|
const _host = {
|
|
41
|
-
|
|
42
|
-
getProjectVersion: () => projectVersion
|
|
43
|
-
getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options),
|
|
44
|
-
useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
|
|
42
|
+
getCurrentDirectory: () => rootPath,
|
|
43
|
+
getProjectVersion: () => projectVersion,
|
|
45
44
|
getCompilationSettings: () => parsedCommandLine.options,
|
|
46
45
|
getScriptFileNames: () => fileNames,
|
|
47
46
|
getProjectReferences: () => parsedCommandLine.projectReferences,
|
|
48
|
-
getScriptVersion: (fileName) => scriptVersions.get(fileName)?.toString() ?? '',
|
|
49
47
|
getScriptSnapshot: (fileName) => {
|
|
50
48
|
if (!scriptSnapshots.has(fileName)) {
|
|
51
49
|
const fileText = ts.sys.readFile(fileName);
|
|
@@ -61,7 +59,6 @@ function createComponentMetaCheckerWorker(loadParsedCommandLine, checkerOptions,
|
|
|
61
59
|
updateFile(fileName, text) {
|
|
62
60
|
fileName = fileName.replace(/\\/g, '/');
|
|
63
61
|
scriptSnapshots.set(fileName, ts.ScriptSnapshot.fromString(text));
|
|
64
|
-
scriptVersions.set(fileName, scriptVersions.has(fileName) ? scriptVersions.get(fileName) + 1 : 1);
|
|
65
62
|
projectVersion++;
|
|
66
63
|
},
|
|
67
64
|
deleteFile(fileName) {
|
|
@@ -76,7 +73,6 @@ function createComponentMetaCheckerWorker(loadParsedCommandLine, checkerOptions,
|
|
|
76
73
|
},
|
|
77
74
|
clearCache() {
|
|
78
75
|
scriptSnapshots.clear();
|
|
79
|
-
scriptVersions.clear();
|
|
80
76
|
projectVersion++;
|
|
81
77
|
},
|
|
82
78
|
};
|
|
@@ -118,27 +114,20 @@ function baseCreate(_host, _vueCompilerOptions, checkerOptions, globalComponentN
|
|
|
118
114
|
},
|
|
119
115
|
});
|
|
120
116
|
const vueLanguages = ts ? vue.createLanguages(host.getCompilationSettings(), vueCompilerOptions, ts) : [];
|
|
121
|
-
const core =
|
|
122
|
-
const
|
|
123
|
-
|
|
117
|
+
const core = vue.createLanguageContext(host, vueLanguages);
|
|
118
|
+
const tsLs = (0, typescript_1.createLanguageService)(core, ts, ts.sys);
|
|
119
|
+
if (checkerOptions.forceUseTs) {
|
|
120
|
+
const getScriptKind = tsLs.__internal__.languageServiceHost.getScriptKind;
|
|
121
|
+
tsLs.__internal__.languageServiceHost.getScriptKind = (fileName) => {
|
|
124
122
|
if (fileName.endsWith('.vue.js')) {
|
|
125
123
|
return ts.ScriptKind.TS;
|
|
126
124
|
}
|
|
127
125
|
if (fileName.endsWith('.vue.jsx')) {
|
|
128
126
|
return ts.ScriptKind.TSX;
|
|
129
127
|
}
|
|
130
|
-
return
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
const proxyHost = new Proxy(core.typescript.languageServiceHost, {
|
|
134
|
-
get(target, propKey) {
|
|
135
|
-
if (propKey in proxyApis) {
|
|
136
|
-
return proxyApis[propKey];
|
|
137
|
-
}
|
|
138
|
-
return target[propKey];
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
const tsLs = ts.createLanguageService(proxyHost);
|
|
128
|
+
return getScriptKind(fileName);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
142
131
|
let globalPropNames;
|
|
143
132
|
return {
|
|
144
133
|
getExportNames,
|
|
@@ -491,7 +480,7 @@ function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: optio
|
|
|
491
480
|
const [virtualFile] = core.virtualFiles.getVirtualFile(fileName);
|
|
492
481
|
if (virtualFile) {
|
|
493
482
|
const maps = core.virtualFiles.getMaps(virtualFile);
|
|
494
|
-
for (const [source, map] of maps) {
|
|
483
|
+
for (const [source, [_, map]] of maps) {
|
|
495
484
|
const start = map.toSourceOffset(declaration.getStart());
|
|
496
485
|
const end = map.toSourceOffset(declaration.getEnd());
|
|
497
486
|
if (start && end) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-component-meta",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.9",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"directory": "packages/vue-component-meta"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/
|
|
17
|
-
"@vue/language-core": "1.7.
|
|
16
|
+
"@volar/typescript": "1.7.3",
|
|
17
|
+
"@vue/language-core": "1.7.9",
|
|
18
18
|
"typesafe-path": "^0.2.2",
|
|
19
|
-
"vue-component-type-helpers": "1.7.
|
|
19
|
+
"vue-component-type-helpers": "1.7.9"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"typescript": "*"
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"optional": true
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "70f9ebedbc55a8d342ec425cc483dfe39c4b7489"
|
|
30
30
|
}
|