vue-component-meta 2.0.7 → 2.0.11
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/lib/base.d.ts +1 -1
- package/lib/base.js +14 -27
- package/package.json +5 -5
package/lib/base.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare function createCheckerBase(ts: typeof import('typescript'), tscon
|
|
|
24
24
|
tsLs: ts.LanguageService;
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
-
export declare function baseCreate(ts: typeof import('typescript'),
|
|
27
|
+
export declare function baseCreate(ts: typeof import('typescript'), host: vue.TypeScriptProjectHost, vueCompilerOptions: vue.VueCompilerOptions, checkerOptions: MetaCheckerOptions, globalComponentName: string): {
|
|
28
28
|
getExportNames: (componentPath: string) => string[];
|
|
29
29
|
getComponentMeta: (componentPath: string, exportName?: string) => ComponentMeta;
|
|
30
30
|
__internal__: {
|
package/lib/base.js
CHANGED
|
@@ -40,7 +40,9 @@ 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
|
|
43
|
+
const projectHost = {
|
|
44
|
+
...ts.sys,
|
|
45
|
+
configFileName,
|
|
44
46
|
getCurrentDirectory: () => rootPath,
|
|
45
47
|
getProjectVersion: () => projectVersion.toString(),
|
|
46
48
|
getCompilationSettings: () => parsedCommandLine.options,
|
|
@@ -61,9 +63,11 @@ function createCheckerWorker(ts, loadParsedCommandLine, checkerOptions, rootPath
|
|
|
61
63
|
}
|
|
62
64
|
return vue.resolveCommonLanguageId(fileName);
|
|
63
65
|
},
|
|
66
|
+
scriptIdToFileName: id => id,
|
|
67
|
+
fileNameToScriptId: id => id,
|
|
64
68
|
};
|
|
65
69
|
return {
|
|
66
|
-
...baseCreate(ts,
|
|
70
|
+
...baseCreate(ts, projectHost, parsedCommandLine.vueOptions, checkerOptions, globalComponentName),
|
|
67
71
|
updateFile(fileName, text) {
|
|
68
72
|
fileName = fileName.replace(windowsPathReg, '/');
|
|
69
73
|
scriptSnapshots.set(fileName, ts.ScriptSnapshot.fromString(text));
|
|
@@ -85,7 +89,7 @@ function createCheckerWorker(ts, loadParsedCommandLine, checkerOptions, rootPath
|
|
|
85
89
|
},
|
|
86
90
|
};
|
|
87
91
|
}
|
|
88
|
-
function baseCreate(ts,
|
|
92
|
+
function baseCreate(ts, host, vueCompilerOptions, checkerOptions, globalComponentName) {
|
|
89
93
|
const globalComponentSnapshot = ts.ScriptSnapshot.fromString('<script setup lang="ts"></script>');
|
|
90
94
|
const metaSnapshots = {};
|
|
91
95
|
const getScriptFileNames = host.getScriptFileNames;
|
|
@@ -113,24 +117,8 @@ function baseCreate(ts, configFileName, host, vueCompilerOptions, checkerOptions
|
|
|
113
117
|
return getScriptSnapshot(fileName);
|
|
114
118
|
}
|
|
115
119
|
};
|
|
116
|
-
const vueLanguagePlugin = vue.createVueLanguagePlugin(ts, id => id,
|
|
117
|
-
|
|
118
|
-
return host.getScriptFileNames().includes(fileName) ?? false;
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
const lowerFileName = fileName.toLowerCase();
|
|
122
|
-
for (const rootFile of host.getScriptFileNames()) {
|
|
123
|
-
if (rootFile.toLowerCase() === lowerFileName) {
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
}, host.getCompilationSettings(), vueCompilerOptions);
|
|
130
|
-
const language = (0, typescript_1.createLanguage)(ts, ts.sys, [vueLanguagePlugin], configFileName, host, {
|
|
131
|
-
fileIdToFileName: id => id,
|
|
132
|
-
fileNameToFileId: id => id,
|
|
133
|
-
});
|
|
120
|
+
const vueLanguagePlugin = vue.createVueLanguagePlugin(ts, id => id, ts.sys.useCaseSensitiveFileNames, () => host.getProjectVersion?.() ?? '', () => host.getScriptFileNames(), host.getCompilationSettings(), vueCompilerOptions);
|
|
121
|
+
const language = (0, typescript_1.createTypeScriptLanguage)(ts, [vueLanguagePlugin], host);
|
|
134
122
|
const { languageServiceHost } = language.typescript;
|
|
135
123
|
const tsLs = ts.createLanguageService(languageServiceHost);
|
|
136
124
|
if (checkerOptions.forceUseTs) {
|
|
@@ -245,7 +233,7 @@ ${vueCompilerOptions.target < 3 ? vue2_1.code : vue_component_type_helpers_1.cod
|
|
|
245
233
|
// fill defaults
|
|
246
234
|
const printer = ts.createPrinter(checkerOptions.printer);
|
|
247
235
|
const snapshot = host.getScriptSnapshot(componentPath);
|
|
248
|
-
const vueFile = language.
|
|
236
|
+
const vueFile = language.scripts.get(componentPath)?.generated?.root;
|
|
249
237
|
const vueDefaults = vueFile && exportName === 'default'
|
|
250
238
|
? (vueFile instanceof vue.VueGeneratedCode ? readVueComponentDefaultProps(vueFile, printer, ts, vueCompilerOptions) : {})
|
|
251
239
|
: {};
|
|
@@ -336,7 +324,7 @@ ${vueCompilerOptions.target < 3 ? vue2_1.code : vue_component_type_helpers_1.cod
|
|
|
336
324
|
}
|
|
337
325
|
}
|
|
338
326
|
exports.baseCreate = baseCreate;
|
|
339
|
-
function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: options, noDeclarations }, ts,
|
|
327
|
+
function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: options, noDeclarations }, ts, language) {
|
|
340
328
|
const visited = new Set();
|
|
341
329
|
function shouldIgnore(subtype) {
|
|
342
330
|
const name = typeChecker.typeToString(subtype);
|
|
@@ -507,12 +495,11 @@ function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: optio
|
|
|
507
495
|
}
|
|
508
496
|
function getDeclaration(declaration) {
|
|
509
497
|
const fileName = declaration.getSourceFile().fileName;
|
|
510
|
-
const sourceFile =
|
|
498
|
+
const sourceFile = language.scripts.get(fileName);
|
|
511
499
|
if (sourceFile?.generated) {
|
|
512
|
-
const script = sourceFile.generated.languagePlugin.typescript?.
|
|
500
|
+
const script = sourceFile.generated.languagePlugin.typescript?.getServiceScript(sourceFile.generated.root);
|
|
513
501
|
if (script) {
|
|
514
|
-
const
|
|
515
|
-
for (const [source, [_, map]] of maps) {
|
|
502
|
+
for (const [source, [_, map]] of language.maps.forEach(script.code)) {
|
|
516
503
|
const start = map.getSourceOffset(declaration.getStart());
|
|
517
504
|
const end = map.getSourceOffset(declaration.getEnd());
|
|
518
505
|
if (start && end) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-component-meta",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11",
|
|
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.
|
|
16
|
-
"@vue/language-core": "2.0.
|
|
15
|
+
"@volar/typescript": "~2.2.0-alpha.6",
|
|
16
|
+
"@vue/language-core": "2.0.11",
|
|
17
17
|
"path-browserify": "^1.0.1",
|
|
18
|
-
"vue-component-type-helpers": "2.0.
|
|
18
|
+
"vue-component-type-helpers": "2.0.11"
|
|
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": "c89f25ffc32c760130adeeac796b9a5d20585bf7"
|
|
33
33
|
}
|