@omnia/tooling-vue 8.0.87-dev → 8.0.88-dev
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/internal-do-not-import-from-here/config/tooling.output.json +1 -1
- package/internal-do-not-import-from-here/config/wctypings.d.ts +362 -102
- package/internal-do-not-import-from-here/shared.js +1 -1
- package/internal-do-not-import-from-here/tasks/ComponentDocRegistrations.js +1 -1
- package/internal-do-not-import-from-here/tasks/bundle.js +1 -1
- package/internal-do-not-import-from-here/tasks/doc.js +79 -31
- package/package.json +3 -3
|
@@ -25,16 +25,16 @@ async function generateComponentTypingsAndDoc(componentRegistrations) {
|
|
|
25
25
|
let params = "";
|
|
26
26
|
if (type.params?.length > 0) {
|
|
27
27
|
type.params.forEach(p => {
|
|
28
|
-
params += `${p.value}:${
|
|
28
|
+
params += `${p.value}:${extractTypeToString(p.typeAnnotation)}, `;
|
|
29
29
|
});
|
|
30
30
|
params = params.replace(/,\s*$/, "");
|
|
31
31
|
}
|
|
32
|
-
return `(${params}) => ${
|
|
32
|
+
return `(${params}) => ${extractTypeToString(type.typeAnnotation)}`;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function extractTypeToString(tsType) {
|
|
35
35
|
let result = "";
|
|
36
36
|
if (tsType.type === "TsTypeAnnotation") {
|
|
37
|
-
return
|
|
37
|
+
return extractTypeToString(tsType.typeAnnotation);
|
|
38
38
|
}
|
|
39
39
|
switch (tsType.type) {
|
|
40
40
|
case "TsLiteralType":
|
|
@@ -54,17 +54,17 @@ async function generateComponentTypingsAndDoc(componentRegistrations) {
|
|
|
54
54
|
}
|
|
55
55
|
return result;
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function getPropertyInfo(ce, result) {
|
|
58
58
|
const identifier = ce.callee?.property?.value;
|
|
59
59
|
if (identifier) {
|
|
60
60
|
switch (identifier) {
|
|
61
61
|
case "name":
|
|
62
62
|
result.name = ce.arguments[0].expression.value;
|
|
63
|
-
|
|
63
|
+
getPropertyInfo(ce.callee.object, result);
|
|
64
64
|
break;
|
|
65
65
|
case "vModel":
|
|
66
66
|
result.type = DefineVueType.Model;
|
|
67
|
-
result.propertyTypeAsString =
|
|
67
|
+
result.propertyTypeAsString = extractTypeToString(ce.typeArguments.params[0]);
|
|
68
68
|
result.name = result.name ? `v-model:${result.name}` : result.name;
|
|
69
69
|
break;
|
|
70
70
|
case "slots":
|
|
@@ -72,19 +72,19 @@ async function generateComponentTypingsAndDoc(componentRegistrations) {
|
|
|
72
72
|
result.propertyTypeAsObject = {};
|
|
73
73
|
ce.typeArguments.params[0].members
|
|
74
74
|
.forEach(m => {
|
|
75
|
-
result.propertyTypeAsObject[m.key.value] =
|
|
75
|
+
result.propertyTypeAsObject[m.key.value] = extractTypeToString(m.typeAnnotation);
|
|
76
76
|
});
|
|
77
77
|
break;
|
|
78
78
|
case "prop":
|
|
79
79
|
result.type = DefineVueType.Prop;
|
|
80
|
-
result.propertyTypeAsString =
|
|
80
|
+
result.propertyTypeAsString = extractTypeToString(ce.typeArguments.params[0]);
|
|
81
81
|
break;
|
|
82
82
|
case "emit":
|
|
83
83
|
result.type = DefineVueType.Emit;
|
|
84
|
-
result.propertyTypeAsString =
|
|
84
|
+
result.propertyTypeAsString = extractTypeToString(ce.typeArguments.params[0]);
|
|
85
85
|
break;
|
|
86
86
|
default:
|
|
87
|
-
|
|
87
|
+
getPropertyInfo(ce.callee.object, result);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -104,14 +104,60 @@ async function generateComponentTypingsAndDoc(componentRegistrations) {
|
|
|
104
104
|
if (b.expression.arguments[0].expression.type === "ArrowFunctionExpression") {
|
|
105
105
|
const params = b.expression.arguments[0].expression.params;
|
|
106
106
|
const typeParams = params[0].typeAnnotation.typeAnnotation.typeParams.params;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
107
|
+
const props = typeParams[0];
|
|
108
|
+
props.types.forEach((t) => {
|
|
109
|
+
const typeName = t.typeName.value;
|
|
110
|
+
if (typeName === "DefineProp"
|
|
111
|
+
|| typeName === "DefineVModel"
|
|
112
|
+
|| typeName === "DefineSlot"
|
|
113
|
+
|| typeName === "DefineEmit") {
|
|
114
|
+
// const isDefineVModel = (t.typeName as Identifier).value === "DefineVModel$";
|
|
115
|
+
if (!docResult[wc.componentOptions.elementName]) {
|
|
116
|
+
docResult[wc.componentOptions.elementName] = {
|
|
117
|
+
emits: {},
|
|
118
|
+
models: {},
|
|
119
|
+
props: {},
|
|
120
|
+
slots: {}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const params = t.typeParams.params;
|
|
124
|
+
const name = extractTypeToString(params[0]);
|
|
125
|
+
const type = extractTypeToString(params[1]);
|
|
126
|
+
if (typeName === "DefineProp" || typeName === "DefineVModel") { // props or vmodel
|
|
127
|
+
const required = params.length > 2 ? extractTypeToString(params[2]) : false;
|
|
128
|
+
const description = params.length > 3 ? extractTypeToString(params[3]) : "";
|
|
129
|
+
if (typeName === "DefineVModel") {
|
|
130
|
+
docResult[wc.componentOptions.elementName].models[name] = {
|
|
131
|
+
type: type,
|
|
132
|
+
description: description,
|
|
133
|
+
required: required.toString().toLowerCase() === "true" ? true : false
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
else { // props
|
|
137
|
+
docResult[wc.componentOptions.elementName].props[name] = {
|
|
138
|
+
type: type,
|
|
139
|
+
description: description,
|
|
140
|
+
required: required.toString().toLowerCase() === "true" ? true : false
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else { // slots or emits
|
|
145
|
+
const description = params.length > 2 ? extractTypeToString(params[2]) : "";
|
|
146
|
+
if (typeName === "DefineEmit") {
|
|
147
|
+
docResult[wc.componentOptions.elementName].emits[name] = {
|
|
148
|
+
type: type,
|
|
149
|
+
description: description,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
else { // slots
|
|
153
|
+
docResult[wc.componentOptions.elementName].slots[name] = {
|
|
154
|
+
type: type,
|
|
155
|
+
description: description,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
});
|
|
115
161
|
}
|
|
116
162
|
else {
|
|
117
163
|
b.expression.arguments[0].expression
|
|
@@ -128,7 +174,7 @@ async function generateComponentTypingsAndDoc(componentRegistrations) {
|
|
|
128
174
|
propertyTypeAsString: "",
|
|
129
175
|
name: ""
|
|
130
176
|
};
|
|
131
|
-
|
|
177
|
+
getPropertyInfo(em, PropertyResult);
|
|
132
178
|
if (!docResult[wc.componentOptions.elementName]) {
|
|
133
179
|
docResult[wc.componentOptions.elementName] = {
|
|
134
180
|
emits: {},
|
|
@@ -217,14 +263,13 @@ declare global {
|
|
|
217
263
|
}
|
|
218
264
|
const elementNamespaces = {};
|
|
219
265
|
const wcNamespace = (0, shared_1.getBuildOption)()?.componentNamespace;
|
|
220
|
-
const skipElementNames = (0, shared_1.getBuildOption)()?.skipElementNames;
|
|
221
266
|
const info = shared_1.ConfigurationManager.outputInfo.get();
|
|
222
267
|
info.wc = {
|
|
223
268
|
namespaces: wcNamespace ? [wcNamespace] : null,
|
|
224
269
|
mappings: {}
|
|
225
270
|
};
|
|
226
271
|
await tooling_1.utils.asyncForEach(componentRegistrations, async (wc) => {
|
|
227
|
-
wcTypings = generateWebComponentTypings(wc, wcTypings, info, elementNamespaces
|
|
272
|
+
wcTypings = generateWebComponentTypings(wc, wcTypings, info, elementNamespaces);
|
|
228
273
|
await buildDoc(wc);
|
|
229
274
|
});
|
|
230
275
|
if (Object.keys(elementNamespaces).length > 0) {
|
|
@@ -272,7 +317,7 @@ extendApi(api => api.fx.docs.registrations, api => {
|
|
|
272
317
|
tooling_1.utils.logTime('Done - Generate components typings and documentation', startTime);
|
|
273
318
|
}
|
|
274
319
|
exports.generateComponentTypingsAndDoc = generateComponentTypingsAndDoc;
|
|
275
|
-
function generateWebComponentTypings(wc, template, info, elementNamespace
|
|
320
|
+
function generateWebComponentTypings(wc, template, info, elementNamespace) {
|
|
276
321
|
// export default defineVueWebComponent
|
|
277
322
|
const wcPath = wc.componentOptions.entryPointPath;
|
|
278
323
|
let content = fsExtra.readFileSync(wcPath, 'utf8');
|
|
@@ -291,12 +336,8 @@ function generateWebComponentTypings(wc, template, info, elementNamespace, skipE
|
|
|
291
336
|
else {
|
|
292
337
|
importPath = `../../../../${importPath}`;
|
|
293
338
|
}
|
|
294
|
-
if (info.wc.namespaces
|
|
295
|
-
let elementName = wc.componentOptions.elementName
|
|
296
|
-
.replace(/-/g, ".");
|
|
297
|
-
// .replace("omfx-", "")
|
|
298
|
-
// .replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
|
|
299
|
-
// elementNamePascalCase = elementNamePascalCase[0].toUpperCase() + elementNamePascalCase.substring(1, elementNamePascalCase.length)
|
|
339
|
+
if (info.wc.namespaces) {
|
|
340
|
+
let elementName = wc.componentOptions.elementName.replace(/-/g, ".");
|
|
300
341
|
const namespace = (wc.componentOptions.namespace === true ? "" : wc.componentOptions.namespace) || (0, shared_1.getBuildOption)()?.componentNamespace;
|
|
301
342
|
if (namespace && elementName.indexOf(`${namespace}.`) !== 0) {
|
|
302
343
|
elementName = `${namespace}.${elementName}`;
|
|
@@ -367,9 +408,16 @@ function populateElementNamespace(namespace, elementName, importElement) {
|
|
|
367
408
|
}
|
|
368
409
|
else {
|
|
369
410
|
if (i === parts.length - 1) {
|
|
370
|
-
|
|
411
|
+
namespace[`${name}$`] = `typeof ${importElement} extends { propsDefinition: infer TProp } ? { new(...args: any[]): { $props: TProp & Omit<VueComponentBaseProps, keyof TProp> } } : typeof ${importElement} <<end>>`;
|
|
412
|
+
// throw new Error("Build element namespace -> Exist an element name contain a above that element name");
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
if (typeof namespace[name] === "string") {
|
|
416
|
+
namespace[`${name}$`] = namespace[name];
|
|
417
|
+
namespace[name] = {};
|
|
418
|
+
}
|
|
419
|
+
namespace = namespace[name];
|
|
371
420
|
}
|
|
372
|
-
namespace = namespace[name];
|
|
373
421
|
}
|
|
374
422
|
}
|
|
375
423
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnia/tooling-vue",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "8.0.
|
|
4
|
+
"version": "8.0.88-dev",
|
|
5
5
|
"description": "Used to bundle and serve manifests web component that build on Vue framework.",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
],
|
|
20
20
|
"author": "Precio Fishbone",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@omnia/fx-models": "8.0.
|
|
23
|
-
"@omnia/tooling-composers": "8.0.
|
|
22
|
+
"@omnia/fx-models": "8.0.88-dev",
|
|
23
|
+
"@omnia/tooling-composers": "8.0.88-dev",
|
|
24
24
|
"@types/mousetrap": "1.5.34",
|
|
25
25
|
"@types/quill": "1.3.6",
|
|
26
26
|
"@types/zepto": "1.0.29",
|