vue-component-meta 1.3.15 → 1.3.16
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.js +52 -8
- package/out/types.d.ts +9 -0
- package/out/types.js +0 -1
- package/package.json +4 -4
package/out/index.js
CHANGED
|
@@ -16,7 +16,7 @@ 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("@volar/vue-language-core");
|
|
19
|
-
const
|
|
19
|
+
const language_core_1 = require("@volar/language-core");
|
|
20
20
|
const path = require("typesafe-path/posix");
|
|
21
21
|
__exportStar(require("./types"), exports);
|
|
22
22
|
const extraFileExtensions = [{
|
|
@@ -59,7 +59,6 @@ function createComponentMetaCheckerWorker(loadParsedCommandLine, checkerOptions,
|
|
|
59
59
|
}
|
|
60
60
|
return scriptSnapshots.get(fileName);
|
|
61
61
|
},
|
|
62
|
-
getTypeScriptModule: () => ts,
|
|
63
62
|
getVueCompilationSettings: () => parsedCommandLine.vueOptions,
|
|
64
63
|
};
|
|
65
64
|
return {
|
|
@@ -124,7 +123,7 @@ function baseCreate(_host, checkerOptions, globalComponentName, ts, embeddedType
|
|
|
124
123
|
});
|
|
125
124
|
const vueCompilerOptions = vue.resolveVueCompilerOptions(host.getVueCompilationSettings());
|
|
126
125
|
const vueLanguageModules = ts ? vue.createLanguageModules(ts, host.getCompilationSettings(), vueCompilerOptions) : [];
|
|
127
|
-
const core =
|
|
126
|
+
const core = (0, language_core_1.createLanguageContext)(host, { typescript: ts }, vueLanguageModules);
|
|
128
127
|
const proxyApis = checkerOptions.forceUseTs ? {
|
|
129
128
|
getScriptKind: (fileName) => {
|
|
130
129
|
if (fileName.endsWith('.vue.js')) {
|
|
@@ -246,7 +245,7 @@ T extends new () => { $scopedSlots: infer S } ? NonNullable<S> :
|
|
|
246
245
|
const properties = type.getProperties();
|
|
247
246
|
result = properties
|
|
248
247
|
.map((prop) => {
|
|
249
|
-
const { resolveNestedProperties, } = createSchemaResolvers(typeChecker, symbolNode, checkerOptions, ts);
|
|
248
|
+
const { resolveNestedProperties, } = createSchemaResolvers(typeChecker, symbolNode, checkerOptions, ts, core);
|
|
250
249
|
return resolveNestedProperties(prop);
|
|
251
250
|
})
|
|
252
251
|
.filter((prop) => !prop.name.match(propEventRegex));
|
|
@@ -290,7 +289,7 @@ T extends new () => { $scopedSlots: infer S } ? NonNullable<S> :
|
|
|
290
289
|
const type = typeChecker.getTypeOfSymbolAtLocation($emit, symbolNode);
|
|
291
290
|
const calls = type.getCallSignatures();
|
|
292
291
|
return calls.map((call) => {
|
|
293
|
-
const { resolveEventSignature, } = createSchemaResolvers(typeChecker, symbolNode, checkerOptions, ts);
|
|
292
|
+
const { resolveEventSignature, } = createSchemaResolvers(typeChecker, symbolNode, checkerOptions, ts, core);
|
|
294
293
|
return resolveEventSignature(call);
|
|
295
294
|
}).filter(event => event.name);
|
|
296
295
|
}
|
|
@@ -302,7 +301,7 @@ T extends new () => { $scopedSlots: infer S } ? NonNullable<S> :
|
|
|
302
301
|
const type = typeChecker.getTypeOfSymbolAtLocation($slots, symbolNode);
|
|
303
302
|
const properties = type.getProperties();
|
|
304
303
|
return properties.map((prop) => {
|
|
305
|
-
const { resolveSlotProperties, } = createSchemaResolvers(typeChecker, symbolNode, checkerOptions, ts);
|
|
304
|
+
const { resolveSlotProperties, } = createSchemaResolvers(typeChecker, symbolNode, checkerOptions, ts, core);
|
|
306
305
|
return resolveSlotProperties(prop);
|
|
307
306
|
});
|
|
308
307
|
}
|
|
@@ -316,7 +315,7 @@ T extends new () => { $scopedSlots: infer S } ? NonNullable<S> :
|
|
|
316
315
|
// only exposed props will not have a valueDeclaration
|
|
317
316
|
!prop.valueDeclaration);
|
|
318
317
|
return properties.map((prop) => {
|
|
319
|
-
const { resolveExposedProperties, } = createSchemaResolvers(typeChecker, symbolNode, checkerOptions, ts);
|
|
318
|
+
const { resolveExposedProperties, } = createSchemaResolvers(typeChecker, symbolNode, checkerOptions, ts, core);
|
|
320
319
|
return resolveExposedProperties(prop);
|
|
321
320
|
});
|
|
322
321
|
}
|
|
@@ -352,7 +351,7 @@ T extends new () => { $scopedSlots: infer S } ? NonNullable<S> :
|
|
|
352
351
|
}
|
|
353
352
|
}
|
|
354
353
|
exports.baseCreate = baseCreate;
|
|
355
|
-
function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: options }, ts) {
|
|
354
|
+
function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: options, noDeclarations }, ts, core) {
|
|
356
355
|
const visited = new Set();
|
|
357
356
|
;
|
|
358
357
|
function shouldIgnore(subtype) {
|
|
@@ -384,6 +383,7 @@ function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: optio
|
|
|
384
383
|
function resolveNestedProperties(prop) {
|
|
385
384
|
const subtype = typeChecker.getTypeOfSymbolAtLocation(prop, symbolNode);
|
|
386
385
|
let schema;
|
|
386
|
+
let declarations;
|
|
387
387
|
return {
|
|
388
388
|
name: prop.getEscapedName().toString(),
|
|
389
389
|
global: false,
|
|
@@ -395,6 +395,9 @@ function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: optio
|
|
|
395
395
|
required: !(prop.flags & ts.SymbolFlags.Optional),
|
|
396
396
|
type: typeChecker.typeToString(subtype),
|
|
397
397
|
rawType: rawType ? subtype : undefined,
|
|
398
|
+
get declarations() {
|
|
399
|
+
return declarations ??= getDeclarations(prop.declarations ?? []);
|
|
400
|
+
},
|
|
398
401
|
get schema() {
|
|
399
402
|
return schema ??= resolveSchema(subtype);
|
|
400
403
|
},
|
|
@@ -406,11 +409,15 @@ function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: optio
|
|
|
406
409
|
const paramType = signatures[0].parameters[0];
|
|
407
410
|
const subtype = typeChecker.getTypeOfSymbolAtLocation(paramType, symbolNode);
|
|
408
411
|
let schema;
|
|
412
|
+
let declarations;
|
|
409
413
|
return {
|
|
410
414
|
name: prop.getName(),
|
|
411
415
|
type: typeChecker.typeToString(subtype),
|
|
412
416
|
rawType: rawType ? subtype : undefined,
|
|
413
417
|
description: ts.displayPartsToString(prop.getDocumentationComment(typeChecker)),
|
|
418
|
+
get declarations() {
|
|
419
|
+
return declarations ??= getDeclarations(prop.declarations ?? []);
|
|
420
|
+
},
|
|
414
421
|
get schema() {
|
|
415
422
|
return schema ??= resolveSchema(subtype);
|
|
416
423
|
},
|
|
@@ -419,11 +426,15 @@ function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: optio
|
|
|
419
426
|
function resolveExposedProperties(expose) {
|
|
420
427
|
const subtype = typeChecker.getTypeOfSymbolAtLocation(expose, symbolNode);
|
|
421
428
|
let schema;
|
|
429
|
+
let declarations;
|
|
422
430
|
return {
|
|
423
431
|
name: expose.getName(),
|
|
424
432
|
type: typeChecker.typeToString(subtype),
|
|
425
433
|
rawType: rawType ? subtype : undefined,
|
|
426
434
|
description: ts.displayPartsToString(expose.getDocumentationComment(typeChecker)),
|
|
435
|
+
get declarations() {
|
|
436
|
+
return declarations ??= getDeclarations(expose.declarations ?? []);
|
|
437
|
+
},
|
|
427
438
|
get schema() {
|
|
428
439
|
return schema ??= resolveSchema(subtype);
|
|
429
440
|
},
|
|
@@ -432,11 +443,15 @@ function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: optio
|
|
|
432
443
|
function resolveEventSignature(call) {
|
|
433
444
|
const subtype = typeChecker.getTypeOfSymbolAtLocation(call.parameters[1], symbolNode);
|
|
434
445
|
let schema;
|
|
446
|
+
let declarations;
|
|
435
447
|
return {
|
|
436
448
|
name: typeChecker.getTypeOfSymbolAtLocation(call.parameters[0], symbolNode).value,
|
|
437
449
|
type: typeChecker.typeToString(subtype),
|
|
438
450
|
rawType: rawType ? subtype : undefined,
|
|
439
451
|
signature: typeChecker.signatureToString(call),
|
|
452
|
+
get declarations() {
|
|
453
|
+
return declarations ??= call.declaration ? getDeclarations([call.declaration]) : [];
|
|
454
|
+
},
|
|
440
455
|
get schema() {
|
|
441
456
|
return schema ??= typeChecker.getTypeArguments(subtype).map(resolveSchema);
|
|
442
457
|
},
|
|
@@ -499,6 +514,35 @@ function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: optio
|
|
|
499
514
|
}
|
|
500
515
|
return type;
|
|
501
516
|
}
|
|
517
|
+
function getDeclarations(declaration) {
|
|
518
|
+
if (noDeclarations) {
|
|
519
|
+
return [];
|
|
520
|
+
}
|
|
521
|
+
return declaration.map(getDeclaration).filter(d => !!d);
|
|
522
|
+
}
|
|
523
|
+
function getDeclaration(declaration) {
|
|
524
|
+
const fileName = declaration.getSourceFile().fileName;
|
|
525
|
+
const [virtualFile] = core.virtualFiles.getVirtualFile(fileName);
|
|
526
|
+
if (virtualFile) {
|
|
527
|
+
const maps = core.virtualFiles.getMaps(virtualFile);
|
|
528
|
+
for (const [source, map] of maps) {
|
|
529
|
+
const start = map.toSourceOffset(declaration.getStart());
|
|
530
|
+
const end = map.toSourceOffset(declaration.getEnd());
|
|
531
|
+
if (start && end) {
|
|
532
|
+
return {
|
|
533
|
+
file: source,
|
|
534
|
+
range: [start[0], end[0]],
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
;
|
|
538
|
+
}
|
|
539
|
+
return undefined;
|
|
540
|
+
}
|
|
541
|
+
return {
|
|
542
|
+
file: declaration.getSourceFile().fileName,
|
|
543
|
+
range: [declaration.getStart(), declaration.getEnd()],
|
|
544
|
+
};
|
|
545
|
+
}
|
|
502
546
|
return {
|
|
503
547
|
resolveNestedProperties,
|
|
504
548
|
resolveSlotProperties,
|
package/out/types.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
+
export interface Declaration {
|
|
3
|
+
file: string;
|
|
4
|
+
range: [number, number];
|
|
5
|
+
}
|
|
2
6
|
export interface ComponentMeta {
|
|
3
7
|
props: PropertyMeta[];
|
|
4
8
|
events: EventMeta[];
|
|
@@ -17,6 +21,7 @@ export interface PropertyMeta {
|
|
|
17
21
|
name: string;
|
|
18
22
|
text?: string;
|
|
19
23
|
}[];
|
|
24
|
+
declarations: Declaration[];
|
|
20
25
|
schema: PropertyMetaSchema;
|
|
21
26
|
}
|
|
22
27
|
export interface EventMeta {
|
|
@@ -24,6 +29,7 @@ export interface EventMeta {
|
|
|
24
29
|
type: string;
|
|
25
30
|
rawType?: ts.Type;
|
|
26
31
|
signature: string;
|
|
32
|
+
declarations: Declaration[];
|
|
27
33
|
schema: PropertyMetaSchema[];
|
|
28
34
|
}
|
|
29
35
|
export interface SlotMeta {
|
|
@@ -31,6 +37,7 @@ export interface SlotMeta {
|
|
|
31
37
|
type: string;
|
|
32
38
|
rawType?: ts.Type;
|
|
33
39
|
description: string;
|
|
40
|
+
declarations: Declaration[];
|
|
34
41
|
schema: PropertyMetaSchema;
|
|
35
42
|
}
|
|
36
43
|
export interface ExposeMeta {
|
|
@@ -38,6 +45,7 @@ export interface ExposeMeta {
|
|
|
38
45
|
description: string;
|
|
39
46
|
type: string;
|
|
40
47
|
rawType?: ts.Type;
|
|
48
|
+
declarations: Declaration[];
|
|
41
49
|
schema: PropertyMetaSchema;
|
|
42
50
|
}
|
|
43
51
|
export type PropertyMetaSchema = string | {
|
|
@@ -69,4 +77,5 @@ export interface MetaCheckerOptions {
|
|
|
69
77
|
forceUseTs?: boolean;
|
|
70
78
|
printer?: ts.PrinterOptions;
|
|
71
79
|
rawType?: boolean;
|
|
80
|
+
noDeclarations?: boolean;
|
|
72
81
|
}
|
package/out/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-component-meta",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.16",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"directory": "packages/vue-component-meta"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "1.4.0-alpha.
|
|
17
|
-
"@volar/vue-language-core": "1.3.
|
|
16
|
+
"@volar/language-core": "1.4.0-alpha.9",
|
|
17
|
+
"@volar/vue-language-core": "1.3.16",
|
|
18
18
|
"typesafe-path": "^0.2.2"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"typescript": "*",
|
|
22
22
|
"vue-component-type-helpers": "1.3.12"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "40066617609780f891a60eea1fc3c7c84cbc5505"
|
|
25
25
|
}
|