vue-component-meta 1.7.11 → 1.7.13
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 +15 -3
- package/out/types.d.ts +6 -0
- package/out/types.js +7 -0
- package/package.json +5 -5
package/out/index.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare function createComponentMetaChecker(tsconfigPath: string, checker
|
|
|
37
37
|
} & ts.LanguageService;
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
|
-
export declare function baseCreate(_host: vue.TypeScriptLanguageHost,
|
|
40
|
+
export declare function baseCreate(_host: vue.TypeScriptLanguageHost, vueCompilerOptions: vue.VueCompilerOptions, checkerOptions: MetaCheckerOptions, globalComponentName: string, ts: typeof import('typescript/lib/tsserverlibrary')): {
|
|
41
41
|
getExportNames: (componentPath: string) => string[];
|
|
42
42
|
getComponentMeta: (componentPath: string, exportName?: string) => ComponentMeta;
|
|
43
43
|
__internal__: {
|
package/out/index.js
CHANGED
|
@@ -55,7 +55,7 @@ function createComponentMetaCheckerWorker(loadParsedCommandLine, checkerOptions,
|
|
|
55
55
|
},
|
|
56
56
|
};
|
|
57
57
|
return {
|
|
58
|
-
...baseCreate(_host, parsedCommandLine.vueOptions, checkerOptions, globalComponentName, ts),
|
|
58
|
+
...baseCreate(_host, vue.resolveVueCompilerOptions(parsedCommandLine.vueOptions), checkerOptions, globalComponentName, ts),
|
|
59
59
|
updateFile(fileName, text) {
|
|
60
60
|
fileName = fileName.replace(/\\/g, '/');
|
|
61
61
|
scriptSnapshots.set(fileName, ts.ScriptSnapshot.fromString(text));
|
|
@@ -77,8 +77,7 @@ function createComponentMetaCheckerWorker(loadParsedCommandLine, checkerOptions,
|
|
|
77
77
|
},
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
-
function baseCreate(_host,
|
|
81
|
-
const vueCompilerOptions = vue.resolveVueCompilerOptions(_vueCompilerOptions);
|
|
80
|
+
function baseCreate(_host, vueCompilerOptions, checkerOptions, globalComponentName, ts) {
|
|
82
81
|
const globalComponentSnapshot = ts.ScriptSnapshot.fromString('<script setup lang="ts"></script>');
|
|
83
82
|
const metaSnapshots = {};
|
|
84
83
|
const host = new Proxy({
|
|
@@ -148,6 +147,7 @@ import * as Components from '${fileName.substring(0, fileName.length - '.meta.ts
|
|
|
148
147
|
export default {} as { [K in keyof typeof Components]: ComponentMeta<typeof Components[K]>; };
|
|
149
148
|
|
|
150
149
|
interface ComponentMeta<T> {
|
|
150
|
+
type: ComponentType<T>;
|
|
151
151
|
props: ComponentProps<T>;
|
|
152
152
|
emit: ComponentEmit<T>;
|
|
153
153
|
slots: ${vueCompilerOptions.target < 3 ? 'Vue2ComponentSlots' : 'ComponentSlots'}<T>;
|
|
@@ -173,11 +173,15 @@ ${vue_component_type_helpers_1.default}
|
|
|
173
173
|
}
|
|
174
174
|
const componentType = typeChecker.getTypeOfSymbolAtLocation(_export, symbolNode);
|
|
175
175
|
const symbolProperties = componentType.getProperties() ?? [];
|
|
176
|
+
let _type;
|
|
176
177
|
let _props;
|
|
177
178
|
let _events;
|
|
178
179
|
let _slots;
|
|
179
180
|
let _exposed;
|
|
180
181
|
return {
|
|
182
|
+
get type() {
|
|
183
|
+
return _type ?? (_type = getType());
|
|
184
|
+
},
|
|
181
185
|
get props() {
|
|
182
186
|
return _props ?? (_props = getProps());
|
|
183
187
|
},
|
|
@@ -191,6 +195,14 @@ ${vue_component_type_helpers_1.default}
|
|
|
191
195
|
return _exposed ?? (_exposed = getExposed());
|
|
192
196
|
},
|
|
193
197
|
};
|
|
198
|
+
function getType() {
|
|
199
|
+
const $type = symbolProperties.find(prop => prop.escapedName === 'type');
|
|
200
|
+
if ($type) {
|
|
201
|
+
const type = typeChecker.getTypeOfSymbolAtLocation($type, symbolNode);
|
|
202
|
+
return Number(typeChecker.typeToString(type));
|
|
203
|
+
}
|
|
204
|
+
return 0;
|
|
205
|
+
}
|
|
194
206
|
function getProps() {
|
|
195
207
|
const $props = symbolProperties.find(prop => prop.escapedName === 'props');
|
|
196
208
|
const propEventRegex = /^(on[A-Z])/;
|
package/out/types.d.ts
CHANGED
|
@@ -4,11 +4,17 @@ export interface Declaration {
|
|
|
4
4
|
range: [number, number];
|
|
5
5
|
}
|
|
6
6
|
export interface ComponentMeta {
|
|
7
|
+
type: TypeMeta;
|
|
7
8
|
props: PropertyMeta[];
|
|
8
9
|
events: EventMeta[];
|
|
9
10
|
slots: SlotMeta[];
|
|
10
11
|
exposed: ExposeMeta[];
|
|
11
12
|
}
|
|
13
|
+
export declare enum TypeMeta {
|
|
14
|
+
Unknown = 0,
|
|
15
|
+
Class = 1,
|
|
16
|
+
Function = 2
|
|
17
|
+
}
|
|
12
18
|
export interface PropertyMeta {
|
|
13
19
|
name: string;
|
|
14
20
|
default?: string;
|
package/out/types.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypeMeta = void 0;
|
|
4
|
+
var TypeMeta;
|
|
5
|
+
(function (TypeMeta) {
|
|
6
|
+
TypeMeta[TypeMeta["Unknown"] = 0] = "Unknown";
|
|
7
|
+
TypeMeta[TypeMeta["Class"] = 1] = "Class";
|
|
8
|
+
TypeMeta[TypeMeta["Function"] = 2] = "Function";
|
|
9
|
+
})(TypeMeta || (exports.TypeMeta = TypeMeta = {}));
|
|
3
10
|
//# sourceMappingURL=types.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-component-meta",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.13",
|
|
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/typescript": "1.7.
|
|
17
|
-
"@vue/language-core": "1.7.
|
|
16
|
+
"@volar/typescript": "1.7.5",
|
|
17
|
+
"@vue/language-core": "1.7.13",
|
|
18
18
|
"typesafe-path": "^0.2.2",
|
|
19
|
-
"vue-component-type-helpers": "1.7.
|
|
19
|
+
"vue-component-type-helpers": "1.7.13"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"typescript": "*"
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"optional": true
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "32d5d5e4414f97b0dc28cd727a9cecf60acd4e97"
|
|
30
30
|
}
|