vue-component-meta 1.5.3 → 1.6.0
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 +1 -1
- package/out/index.js +12 -40
- package/package.json +6 -6
package/out/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare function createComponentMetaChecker(tsconfigPath: string, checker
|
|
|
25
25
|
tsLs: ts.LanguageService;
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
|
-
export declare function baseCreate(_host: vue.VueLanguageServiceHost, checkerOptions: MetaCheckerOptions, globalComponentName: string, ts: typeof import('typescript/lib/tsserverlibrary')
|
|
28
|
+
export declare function baseCreate(_host: vue.VueLanguageServiceHost, checkerOptions: MetaCheckerOptions, globalComponentName: string, ts: typeof import('typescript/lib/tsserverlibrary')): {
|
|
29
29
|
getExportNames: (componentPath: string) => string[];
|
|
30
30
|
getComponentMeta: (componentPath: string, exportName?: string) => ComponentMeta;
|
|
31
31
|
__internal__: {
|
package/out/index.js
CHANGED
|
@@ -18,6 +18,7 @@ exports.baseCreate = exports.createComponentMetaChecker = exports.createComponen
|
|
|
18
18
|
const vue = require("@volar/vue-language-core");
|
|
19
19
|
const language_core_1 = require("@volar/language-core");
|
|
20
20
|
const path = require("typesafe-path/posix");
|
|
21
|
+
const vue_component_type_helpers_1 = require("vue-component-type-helpers");
|
|
21
22
|
__exportStar(require("./types"), exports);
|
|
22
23
|
const extraFileExtensions = [{
|
|
23
24
|
extension: 'vue',
|
|
@@ -62,7 +63,7 @@ function createComponentMetaCheckerWorker(loadParsedCommandLine, checkerOptions,
|
|
|
62
63
|
getVueCompilationSettings: () => parsedCommandLine.vueOptions,
|
|
63
64
|
};
|
|
64
65
|
return {
|
|
65
|
-
...baseCreate(_host, checkerOptions, globalComponentName, ts
|
|
66
|
+
...baseCreate(_host, checkerOptions, globalComponentName, ts),
|
|
66
67
|
updateFile(fileName, text) {
|
|
67
68
|
fileName = fileName.replace(/\\/g, '/');
|
|
68
69
|
scriptSnapshots.set(fileName, ts.ScriptSnapshot.fromString(text));
|
|
@@ -86,7 +87,7 @@ function createComponentMetaCheckerWorker(loadParsedCommandLine, checkerOptions,
|
|
|
86
87
|
},
|
|
87
88
|
};
|
|
88
89
|
}
|
|
89
|
-
function baseCreate(_host, checkerOptions, globalComponentName, ts
|
|
90
|
+
function baseCreate(_host, checkerOptions, globalComponentName, ts) {
|
|
90
91
|
const globalComponentSnapshot = ts.ScriptSnapshot.fromString('<script setup lang="ts"></script>');
|
|
91
92
|
const metaSnapshots = {};
|
|
92
93
|
const host = new Proxy({
|
|
@@ -102,7 +103,7 @@ function baseCreate(_host, checkerOptions, globalComponentName, ts, embeddedType
|
|
|
102
103
|
getScriptSnapshot: fileName => {
|
|
103
104
|
if (isMetaFileName(fileName)) {
|
|
104
105
|
if (!metaSnapshots[fileName]) {
|
|
105
|
-
metaSnapshots[fileName] = ts.ScriptSnapshot.fromString(getMetaScriptContent(fileName
|
|
106
|
+
metaSnapshots[fileName] = ts.ScriptSnapshot.fromString(getMetaScriptContent(fileName));
|
|
106
107
|
}
|
|
107
108
|
return metaSnapshots[fileName];
|
|
108
109
|
}
|
|
@@ -158,49 +159,20 @@ function baseCreate(_host, checkerOptions, globalComponentName, ts, embeddedType
|
|
|
158
159
|
function getMetaFileName(fileName) {
|
|
159
160
|
return (fileName.endsWith('.vue') ? fileName : fileName.substring(0, fileName.lastIndexOf('.'))) + '.meta.ts';
|
|
160
161
|
}
|
|
161
|
-
function getMetaScriptContent(fileName
|
|
162
|
-
const importCode = embeddedTypes ? '' : `import('vue-component-type-helpers').`;
|
|
162
|
+
function getMetaScriptContent(fileName) {
|
|
163
163
|
let code = `
|
|
164
164
|
import * as Components from '${fileName.substring(0, fileName.length - '.meta.ts'.length)}';
|
|
165
165
|
export default {} as { [K in keyof typeof Components]: ComponentMeta<typeof Components[K]>; };
|
|
166
166
|
|
|
167
167
|
interface ComponentMeta<T> {
|
|
168
|
-
props:
|
|
169
|
-
emit:
|
|
170
|
-
slots: ${
|
|
171
|
-
exposed:
|
|
172
|
-
}
|
|
173
|
-
if (embeddedTypes) {
|
|
174
|
-
code += `
|
|
175
|
-
type ComponentProps<T> =
|
|
176
|
-
T extends new () => { $props: infer P } ? NonNullable<P> :
|
|
177
|
-
T extends (props: infer P, ...args: any) => any ? P :
|
|
178
|
-
{};
|
|
179
|
-
|
|
180
|
-
type ComponentSlots<T> =
|
|
181
|
-
T extends new () => { $slots: infer S } ? NonNullable<S> :
|
|
182
|
-
T extends (props: any, ctx: { slots: infer S }, ...args: any) => any ? NonNullable<S> :
|
|
183
|
-
{};
|
|
184
|
-
|
|
185
|
-
type ComponentEmit<T> =
|
|
186
|
-
T extends new () => { $emit: infer E } ? NonNullable<E> :
|
|
187
|
-
T extends (props: any, ctx: { emit: infer E }, ...args: any) => any ? NonNullable<E> :
|
|
188
|
-
{};
|
|
189
|
-
|
|
190
|
-
type ComponentExposed<T> =
|
|
191
|
-
T extends new () => infer E ? E :
|
|
192
|
-
T extends (props: any, ctx: { expose(exposed: infer E): any }, ...args: any) => any ? NonNullable<E> :
|
|
193
|
-
{};
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Vue 2.x
|
|
197
|
-
*/
|
|
168
|
+
props: ComponentProps<T>;
|
|
169
|
+
emit: ComponentEmit<T>;
|
|
170
|
+
slots: ${vueCompilerOptions.target < 3 ? 'Vue2ComponentSlots' : 'ComponentSlots'}<T>;
|
|
171
|
+
exposed: ComponentExposed<T>;
|
|
172
|
+
};
|
|
198
173
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
T extends (props: any, ctx: { slots: infer S }, ...args: any) => any ? NonNullable<S> :
|
|
202
|
-
{};`;
|
|
203
|
-
}
|
|
174
|
+
${vue_component_type_helpers_1.default}
|
|
175
|
+
`.trim();
|
|
204
176
|
return code;
|
|
205
177
|
}
|
|
206
178
|
function getExportNames(componentPath) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-component-meta",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@volar/language-core": "1.4.1",
|
|
17
|
-
"@volar/vue-language-core": "1.
|
|
18
|
-
"typesafe-path": "^0.2.2"
|
|
17
|
+
"@volar/vue-language-core": "1.6.0",
|
|
18
|
+
"typesafe-path": "^0.2.2",
|
|
19
|
+
"vue-component-type-helpers": "1.6.0"
|
|
19
20
|
},
|
|
20
21
|
"peerDependencies": {
|
|
21
|
-
"typescript": "*"
|
|
22
|
-
"vue-component-type-helpers": "1.3.12"
|
|
22
|
+
"typescript": "*"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "34b578e2c0fc23645b2f60e9206d91c1bd3833d0"
|
|
25
25
|
}
|