vue-component-meta 2.1.8 → 2.2.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/lib/base.js +9 -9
- package/package.json +5 -5
package/lib/base.js
CHANGED
|
@@ -102,7 +102,7 @@ function baseCreate(ts, getCommandLine, checkerOptions, rootPath, globalComponen
|
|
|
102
102
|
const globalTypesName = `${commandLine.vueOptions.lib}_${commandLine.vueOptions.target}_${commandLine.vueOptions.strictTemplates}.d.ts`;
|
|
103
103
|
const globalTypesContents = `// @ts-nocheck\nexport {};\n` + vue.generateGlobalTypes(commandLine.vueOptions.lib, commandLine.vueOptions.target, commandLine.vueOptions.strictTemplates);
|
|
104
104
|
const globalTypesSnapshot = {
|
|
105
|
-
getText: (start, end) => globalTypesContents.
|
|
105
|
+
getText: (start, end) => globalTypesContents.slice(start, end),
|
|
106
106
|
getLength: () => globalTypesContents.length,
|
|
107
107
|
getChangeRange: () => undefined,
|
|
108
108
|
};
|
|
@@ -174,11 +174,11 @@ function baseCreate(ts, getCommandLine, checkerOptions, rootPath, globalComponen
|
|
|
174
174
|
function getMetaFileName(fileName) {
|
|
175
175
|
return (commandLine.vueOptions.extensions.some(ext => fileName.endsWith(ext))
|
|
176
176
|
? fileName
|
|
177
|
-
: fileName.
|
|
177
|
+
: fileName.slice(0, fileName.lastIndexOf('.'))) + '.meta.ts';
|
|
178
178
|
}
|
|
179
179
|
function getMetaScriptContent(fileName) {
|
|
180
180
|
let code = `
|
|
181
|
-
import * as Components from '${fileName.
|
|
181
|
+
import * as Components from '${fileName.slice(0, -'.meta.ts'.length)}';
|
|
182
182
|
export default {} as { [K in keyof typeof Components]: ComponentMeta<typeof Components[K]>; };
|
|
183
183
|
|
|
184
184
|
interface ComponentMeta<T> {
|
|
@@ -250,7 +250,7 @@ ${commandLine.vueOptions.target < 3 ? vue2_1.code : vue_component_type_helpers_1
|
|
|
250
250
|
const { resolveNestedProperties, } = createSchemaResolvers(typeChecker, symbolNode, checkerOptions, ts, language);
|
|
251
251
|
return resolveNestedProperties(prop);
|
|
252
252
|
})
|
|
253
|
-
.filter(prop => !prop.name
|
|
253
|
+
.filter(prop => !propEventRegex.test(prop.name));
|
|
254
254
|
}
|
|
255
255
|
// fill global
|
|
256
256
|
if (componentPath !== globalComponentName) {
|
|
@@ -266,7 +266,7 @@ ${commandLine.vueOptions.target < 3 ? vue2_1.code : vue_component_type_helpers_1
|
|
|
266
266
|
const vueDefaults = vueFile && exportName === 'default'
|
|
267
267
|
? (vueFile instanceof vue.VueVirtualCode ? readVueComponentDefaultProps(vueFile, printer, ts, commandLine.vueOptions) : {})
|
|
268
268
|
: {};
|
|
269
|
-
const tsDefaults = !vueFile ? readTsComponentDefaultProps(componentPath.
|
|
269
|
+
const tsDefaults = !vueFile ? readTsComponentDefaultProps(componentPath.slice(componentPath.lastIndexOf('.') + 1), // ts | js | tsx | jsx
|
|
270
270
|
snapshot.getText(0, snapshot.getLength()), exportName, printer, ts) : {};
|
|
271
271
|
for (const [propName, defaultExp] of Object.entries({
|
|
272
272
|
...vueDefaults,
|
|
@@ -566,8 +566,8 @@ function readVueComponentDefaultProps(vueSourceFile, printer, ts, vueCompilerOpt
|
|
|
566
566
|
function scriptSetupWorker() {
|
|
567
567
|
const descriptor = vueSourceFile._sfc;
|
|
568
568
|
const scriptSetupRanges = descriptor.scriptSetup ? vue.parseScriptSetupRanges(ts, descriptor.scriptSetup.ast, vueCompilerOptions) : undefined;
|
|
569
|
-
if (descriptor.scriptSetup && scriptSetupRanges?.
|
|
570
|
-
const defaultsText = descriptor.scriptSetup.content.
|
|
569
|
+
if (descriptor.scriptSetup && scriptSetupRanges?.withDefaults?.arg) {
|
|
570
|
+
const defaultsText = descriptor.scriptSetup.content.slice(scriptSetupRanges.withDefaults.arg.start, scriptSetupRanges.withDefaults.arg.end);
|
|
571
571
|
const ast = ts.createSourceFile('/tmp.' + descriptor.scriptSetup.lang, '(' + defaultsText + ')', ts.ScriptTarget.Latest);
|
|
572
572
|
const obj = findObjectLiteralExpression(ast);
|
|
573
573
|
if (obj) {
|
|
@@ -583,8 +583,8 @@ function readVueComponentDefaultProps(vueSourceFile, printer, ts, vueCompilerOpt
|
|
|
583
583
|
}
|
|
584
584
|
}
|
|
585
585
|
}
|
|
586
|
-
else if (descriptor.scriptSetup && scriptSetupRanges?.
|
|
587
|
-
const defaultsText = descriptor.scriptSetup.content.
|
|
586
|
+
else if (descriptor.scriptSetup && scriptSetupRanges?.defineProps?.arg) {
|
|
587
|
+
const defaultsText = descriptor.scriptSetup.content.slice(scriptSetupRanges.defineProps.arg.start, scriptSetupRanges.defineProps.arg.end);
|
|
588
588
|
const ast = ts.createSourceFile('/tmp.' + descriptor.scriptSetup.lang, '(' + defaultsText + ')', ts.ScriptTarget.Latest);
|
|
589
589
|
const obj = findObjectLiteralExpression(ast);
|
|
590
590
|
if (obj) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-component-meta",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
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": "2.
|
|
16
|
+
"@volar/typescript": "~2.4.11",
|
|
17
|
+
"@vue/language-core": "2.2.0",
|
|
18
18
|
"path-browserify": "^1.0.1",
|
|
19
|
-
"vue-component-type-helpers": "2.
|
|
19
|
+
"vue-component-type-helpers": "2.2.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"typescript": "*"
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"@types/node": "latest",
|
|
31
31
|
"@types/path-browserify": "latest"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "5babca774658d4b9afbe877ac7c8cafdaecf2c3e"
|
|
34
34
|
}
|