vue-component-meta 3.0.0-alpha.4 → 3.0.0-alpha.8
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.js +17 -13
- package/package.json +5 -5
package/lib/base.js
CHANGED
|
@@ -21,7 +21,6 @@ const typescript_1 = require("@volar/typescript");
|
|
|
21
21
|
const vue = require("@vue/language-core");
|
|
22
22
|
const path_browserify_1 = require("path-browserify");
|
|
23
23
|
const vue_component_type_helpers_1 = require("vue-component-type-helpers");
|
|
24
|
-
const vue2_1 = require("vue-component-type-helpers/vue2");
|
|
25
24
|
__exportStar(require("./types"), exports);
|
|
26
25
|
const windowsPathReg = /\\/g;
|
|
27
26
|
function createCheckerByJsonConfigBase(ts, rootDir, json, checkerOptions = {}) {
|
|
@@ -189,7 +188,7 @@ interface ComponentMeta<T> {
|
|
|
189
188
|
exposed: ComponentExposed<T>;
|
|
190
189
|
};
|
|
191
190
|
|
|
192
|
-
${
|
|
191
|
+
${vue_component_type_helpers_1.code}
|
|
193
192
|
`.trim();
|
|
194
193
|
return code;
|
|
195
194
|
}
|
|
@@ -240,7 +239,7 @@ ${commandLine.vueOptions.target < 3 ? vue2_1.code : vue_component_type_helpers_1
|
|
|
240
239
|
}
|
|
241
240
|
function getProps() {
|
|
242
241
|
const $props = symbolProperties.find(prop => prop.escapedName === 'props');
|
|
243
|
-
const
|
|
242
|
+
const vnodeEventRegex = /^onVnode[A-Z]/;
|
|
244
243
|
let result = [];
|
|
245
244
|
if ($props) {
|
|
246
245
|
const type = typeChecker.getTypeOfSymbolAtLocation($props, symbolNode);
|
|
@@ -250,7 +249,7 @@ ${commandLine.vueOptions.target < 3 ? vue2_1.code : vue_component_type_helpers_1
|
|
|
250
249
|
const { resolveNestedProperties, } = createSchemaResolvers(typeChecker, symbolNode, checkerOptions, ts, language);
|
|
251
250
|
return resolveNestedProperties(prop);
|
|
252
251
|
})
|
|
253
|
-
.filter(prop => !
|
|
252
|
+
.filter(prop => !vnodeEventRegex.test(prop.name));
|
|
254
253
|
}
|
|
255
254
|
// fill global
|
|
256
255
|
if (componentPath !== globalComponentName) {
|
|
@@ -356,7 +355,7 @@ ${commandLine.vueOptions.target < 3 ? vue2_1.code : vue_component_type_helpers_1
|
|
|
356
355
|
function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: options, noDeclarations }, ts, language) {
|
|
357
356
|
const visited = new Set();
|
|
358
357
|
function shouldIgnore(subtype) {
|
|
359
|
-
const name =
|
|
358
|
+
const name = getFullyQualifiedName(subtype);
|
|
360
359
|
if (name === 'any') {
|
|
361
360
|
return true;
|
|
362
361
|
}
|
|
@@ -395,7 +394,7 @@ function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: optio
|
|
|
395
394
|
text: tag.text !== undefined ? ts.displayPartsToString(tag.text) : undefined,
|
|
396
395
|
})),
|
|
397
396
|
required: !(prop.flags & ts.SymbolFlags.Optional),
|
|
398
|
-
type:
|
|
397
|
+
type: getFullyQualifiedName(subtype),
|
|
399
398
|
rawType: rawType ? subtype : undefined,
|
|
400
399
|
get declarations() {
|
|
401
400
|
return declarations ??= getDeclarations(prop.declarations ?? []);
|
|
@@ -414,7 +413,7 @@ function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: optio
|
|
|
414
413
|
let declarations;
|
|
415
414
|
return {
|
|
416
415
|
name: prop.getName(),
|
|
417
|
-
type:
|
|
416
|
+
type: getFullyQualifiedName(subtype),
|
|
418
417
|
rawType: rawType ? subtype : undefined,
|
|
419
418
|
description: ts.displayPartsToString(prop.getDocumentationComment(typeChecker)),
|
|
420
419
|
get declarations() {
|
|
@@ -431,7 +430,7 @@ function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: optio
|
|
|
431
430
|
let declarations;
|
|
432
431
|
return {
|
|
433
432
|
name: expose.getName(),
|
|
434
|
-
type:
|
|
433
|
+
type: getFullyQualifiedName(subtype),
|
|
435
434
|
rawType: rawType ? subtype : undefined,
|
|
436
435
|
description: ts.displayPartsToString(expose.getDocumentationComment(typeChecker)),
|
|
437
436
|
get declarations() {
|
|
@@ -451,13 +450,13 @@ function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: optio
|
|
|
451
450
|
if (call.parameters.length >= 2) {
|
|
452
451
|
subtype = typeChecker.getTypeOfSymbolAtLocation(call.parameters[1], symbolNode);
|
|
453
452
|
if (call.parameters[1].valueDeclaration?.dotDotDotToken) {
|
|
454
|
-
subtypeStr =
|
|
453
|
+
subtypeStr = getFullyQualifiedName(subtype);
|
|
455
454
|
getSchema = () => typeChecker.getTypeArguments(subtype).map(resolveSchema);
|
|
456
455
|
}
|
|
457
456
|
else {
|
|
458
457
|
subtypeStr = '[';
|
|
459
458
|
for (let i = 1; i < call.parameters.length; i++) {
|
|
460
|
-
subtypeStr +=
|
|
459
|
+
subtypeStr += getFullyQualifiedName(typeChecker.getTypeOfSymbolAtLocation(call.parameters[i], symbolNode)) + ', ';
|
|
461
460
|
}
|
|
462
461
|
subtypeStr = subtypeStr.slice(0, -2) + ']';
|
|
463
462
|
getSchema = () => {
|
|
@@ -502,7 +501,7 @@ function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: optio
|
|
|
502
501
|
};
|
|
503
502
|
}
|
|
504
503
|
function resolveSchema(subtype) {
|
|
505
|
-
const type =
|
|
504
|
+
const type = getFullyQualifiedName(subtype);
|
|
506
505
|
if (shouldIgnore(subtype)) {
|
|
507
506
|
return type;
|
|
508
507
|
}
|
|
@@ -517,7 +516,6 @@ function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: optio
|
|
|
517
516
|
},
|
|
518
517
|
};
|
|
519
518
|
}
|
|
520
|
-
// @ts-ignore - typescript internal, isArrayLikeType exists
|
|
521
519
|
else if (typeChecker.isArrayLikeType(subtype)) {
|
|
522
520
|
let schema;
|
|
523
521
|
return {
|
|
@@ -544,6 +542,13 @@ function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: optio
|
|
|
544
542
|
}
|
|
545
543
|
return type;
|
|
546
544
|
}
|
|
545
|
+
function getFullyQualifiedName(type) {
|
|
546
|
+
const str = typeChecker.typeToString(type, undefined, ts.TypeFormatFlags.UseFullyQualifiedType | ts.TypeFormatFlags.NoTruncation);
|
|
547
|
+
if (str.includes('import(')) {
|
|
548
|
+
return str.replace(/import\(.*?\)\./g, '');
|
|
549
|
+
}
|
|
550
|
+
return str;
|
|
551
|
+
}
|
|
547
552
|
function getDeclarations(declaration) {
|
|
548
553
|
if (noDeclarations) {
|
|
549
554
|
return [];
|
|
@@ -699,7 +704,6 @@ function readTsComponentDefaultProps(ast, exportName, printer, ts) {
|
|
|
699
704
|
return component;
|
|
700
705
|
}
|
|
701
706
|
// export default defineComponent({ ... })
|
|
702
|
-
// export default Vue.extend({ ... })
|
|
703
707
|
else if (ts.isCallExpression(component)) {
|
|
704
708
|
if (component.arguments.length) {
|
|
705
709
|
const arg = component.arguments[0];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-component-meta",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"directory": "packages/component-meta"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/typescript": "~2.4.
|
|
17
|
-
"@vue/language-core": "3.0.0-alpha.
|
|
16
|
+
"@volar/typescript": "~2.4.13",
|
|
17
|
+
"@vue/language-core": "3.0.0-alpha.8",
|
|
18
18
|
"path-browserify": "^1.0.1",
|
|
19
|
-
"vue-component-type-helpers": "3.0.0-alpha.
|
|
19
|
+
"vue-component-type-helpers": "3.0.0-alpha.8"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"typescript": "*"
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"@types/node": "^22.10.4",
|
|
31
31
|
"@types/path-browserify": "^1.0.1"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "d38cb93558fe8015c7ffe9ceacfdd3296e3692f6"
|
|
34
34
|
}
|