vue-component-meta 0.40.13 → 1.0.0-alpha.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.js +11 -10
- package/out/types.d.ts +1 -0
- package/package.json +4 -4
package/out/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
2
|
exports.createComponentMetaChecker = exports.createComponentMetaCheckerByJsonConfig = void 0;
|
|
3
3
|
const vue = require("@volar/vue-language-core");
|
|
4
|
-
const
|
|
4
|
+
const embedded = require("@volar/language-core");
|
|
5
5
|
const ts = require("typescript/lib/tsserverlibrary");
|
|
6
6
|
const parseConfigHost = {
|
|
7
7
|
useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
|
|
@@ -55,7 +55,8 @@ function createComponentMetaCheckerBase(tsconfigPath, parsedCommandLine, checker
|
|
|
55
55
|
}
|
|
56
56
|
return scriptSnapshot[fileName];
|
|
57
57
|
}, getTypeScriptModule: () => ts, getVueCompilationSettings: () => parsedCommandLine.vueOptions });
|
|
58
|
-
const
|
|
58
|
+
const vueLanguageModule = vue.createEmbeddedLanguageModule(host.getTypeScriptModule(), host.getCurrentDirectory(), host.getCompilationSettings(), host.getVueCompilationSettings(), ['.vue']);
|
|
59
|
+
const core = embedded.createEmbeddedLanguageServiceHost(host, [vueLanguageModule]);
|
|
59
60
|
const proxyApis = checkerOptions.forceUseTs ? {
|
|
60
61
|
getScriptKind: (fileName) => {
|
|
61
62
|
if (fileName.endsWith('.vue.js')) {
|
|
@@ -120,6 +121,7 @@ function createComponentMetaCheckerBase(tsconfigPath, parsedCommandLine, checker
|
|
|
120
121
|
exposed: getExposed(),
|
|
121
122
|
};
|
|
122
123
|
function getProps() {
|
|
124
|
+
var _a;
|
|
123
125
|
const $props = symbolProperties.find(prop => prop.escapedName === '$props');
|
|
124
126
|
const propEventRegex = /^(on[A-Z])/;
|
|
125
127
|
let result = [];
|
|
@@ -138,12 +140,13 @@ function createComponentMetaCheckerBase(tsconfigPath, parsedCommandLine, checker
|
|
|
138
140
|
prop.global = globalPropNames.includes(prop.name);
|
|
139
141
|
}
|
|
140
142
|
// fill defaults
|
|
141
|
-
const printer =
|
|
143
|
+
const printer = ts.createPrinter(checkerOptions.printer);
|
|
142
144
|
const snapshot = host.getScriptSnapshot(componentPath);
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
+
const vueSourceFile = (_a = core.mapper.get(componentPath)) === null || _a === void 0 ? void 0 : _a[0];
|
|
146
|
+
const vueDefaults = vueSourceFile && exportName === 'default'
|
|
147
|
+
? (vueSourceFile instanceof vue.VueSourceFile ? readVueComponentDefaultProps(vueSourceFile, printer) : {})
|
|
145
148
|
: {};
|
|
146
|
-
const tsDefaults = !
|
|
149
|
+
const tsDefaults = !vueSourceFile ? readTsComponentDefaultProps(componentPath.substring(componentPath.lastIndexOf('.') + 1), // ts | js | tsx | jsx
|
|
147
150
|
snapshot.getText(0, snapshot.getLength()), exportName, printer) : {};
|
|
148
151
|
for (const [propName, defaultExp] of Object.entries(Object.assign(Object.assign({}, vueDefaults), tsDefaults))) {
|
|
149
152
|
const prop = result.find(p => p.name === propName);
|
|
@@ -361,16 +364,15 @@ function createSchemaResolvers(typeChecker, symbolNode, { rawType, schema: optio
|
|
|
361
364
|
resolveSchema,
|
|
362
365
|
};
|
|
363
366
|
}
|
|
364
|
-
function readVueComponentDefaultProps(
|
|
367
|
+
function readVueComponentDefaultProps(vueSourceFile, printer) {
|
|
365
368
|
let result = {};
|
|
366
369
|
scriptSetupWorker();
|
|
367
370
|
scriptWorker();
|
|
368
371
|
return result;
|
|
369
372
|
function scriptSetupWorker() {
|
|
370
373
|
var _a;
|
|
371
|
-
const vueSourceFile = vue.createSourceFile('/tmp.vue', vueFileScript, ts, core.plugins);
|
|
372
374
|
const descriptor = vueSourceFile.sfc;
|
|
373
|
-
const scriptSetupRanges = descriptor.scriptSetupAst ?
|
|
375
|
+
const scriptSetupRanges = descriptor.scriptSetupAst ? vue.parseScriptSetupRanges(ts, descriptor.scriptSetupAst) : undefined;
|
|
374
376
|
if (descriptor.scriptSetup && (scriptSetupRanges === null || scriptSetupRanges === void 0 ? void 0 : scriptSetupRanges.withDefaultsArg)) {
|
|
375
377
|
const defaultsText = descriptor.scriptSetup.content.substring(scriptSetupRanges.withDefaultsArg.start, scriptSetupRanges.withDefaultsArg.end);
|
|
376
378
|
const ast = ts.createSourceFile('/tmp.' + descriptor.scriptSetup.lang, '(' + defaultsText + ')', ts.ScriptTarget.Latest);
|
|
@@ -410,7 +412,6 @@ function readVueComponentDefaultProps(core, vueFileScript, printer) {
|
|
|
410
412
|
}
|
|
411
413
|
}
|
|
412
414
|
function scriptWorker() {
|
|
413
|
-
const vueSourceFile = vue.createSourceFile('/tmp.vue', vueFileScript, ts, core.plugins);
|
|
414
415
|
const descriptor = vueSourceFile.sfc;
|
|
415
416
|
if (descriptor.script) {
|
|
416
417
|
const scriptResult = readTsComponentDefaultProps(descriptor.script.lang, descriptor.script.content, 'default', printer);
|
package/out/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-component-meta",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.0",
|
|
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/
|
|
16
|
+
"@volar/language-core": "1.0.0-alpha.0",
|
|
17
|
+
"@volar/vue-language-core": "1.0.0-alpha.0"
|
|
17
18
|
},
|
|
18
19
|
"peerDependencies": {
|
|
19
20
|
"typescript": "*"
|
|
20
|
-
}
|
|
21
|
-
"gitHead": "baeeddd7399fa95688c66e9e3bf743bcaa77c32c"
|
|
21
|
+
}
|
|
22
22
|
}
|