@omnia/tooling-vue 8.0.102-vnext → 8.0.104-vnext
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/shared.d.ts +6 -1
- package/internal-do-not-import-from-here/shared.js +18 -2
- package/internal-do-not-import-from-here/tasks/ComponentDocRegistrations.js +1 -1
- package/internal-do-not-import-from-here/tasks/bundle.js +10 -354
- package/internal-do-not-import-from-here/tasks/doc.d.ts +2 -1
- package/internal-do-not-import-from-here/tasks/doc.js +257 -397
- package/internal-do-not-import-from-here/vite/hmr/graph.js +1 -1
- package/internal-do-not-import-from-here/webpack-loaders/wc-loader.js +3 -1
- package/package.json +3 -3
|
@@ -1,424 +1,284 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateComponentTypingsAndDoc = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
|
-
const
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
5
6
|
const shared_1 = require("../shared");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
const tooling_composers_1 = require("@omnia/tooling-composers");
|
|
8
|
+
const tooling_1 = require("@omnia/tooling");
|
|
9
|
+
const core_1 = require("@swc/core");
|
|
10
|
+
const fsExtra = tslib_1.__importStar(require("fs-extra"));
|
|
11
|
+
const fx_models_1 = require("@omnia/fx-models");
|
|
12
|
+
async function generateComponentTypingsAndDoc(componentRegistrations) {
|
|
13
|
+
tooling_1.utils.log("Generate components typings and documentation running...");
|
|
14
|
+
var startTime = new Date().getTime();
|
|
15
|
+
let DefineVueType;
|
|
16
|
+
(function (DefineVueType) {
|
|
17
|
+
DefineVueType[DefineVueType["Prop"] = 0] = "Prop";
|
|
18
|
+
DefineVueType[DefineVueType["Model"] = 1] = "Model";
|
|
19
|
+
DefineVueType[DefineVueType["Slot"] = 2] = "Slot";
|
|
20
|
+
DefineVueType[DefineVueType["Emit"] = 4] = "Emit";
|
|
21
|
+
})(DefineVueType || (DefineVueType = {}));
|
|
22
|
+
const docResult = {};
|
|
23
|
+
function getPropertyFunctionTypeAsString(type) {
|
|
24
|
+
let params = "";
|
|
25
|
+
if (type.params?.length > 0) {
|
|
26
|
+
type.params.forEach(p => {
|
|
27
|
+
params += `${p.value}:${getPropertyType(p.typeAnnotation)}, `;
|
|
28
|
+
});
|
|
29
|
+
params = params.replace(/,\s*$/, "");
|
|
30
|
+
}
|
|
31
|
+
return `(${params}) => ${getPropertyType(type.typeAnnotation)}`;
|
|
23
32
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
function getPropertyType(tsType) {
|
|
34
|
+
let result = "";
|
|
35
|
+
if (tsType.type === "TsTypeAnnotation") {
|
|
36
|
+
return getPropertyType(tsType.typeAnnotation);
|
|
37
|
+
}
|
|
38
|
+
switch (tsType.type) {
|
|
39
|
+
case "TsLiteralType":
|
|
40
|
+
result = tsType.literal.value;
|
|
41
|
+
break;
|
|
42
|
+
case "TsKeywordType":
|
|
43
|
+
result = tsType.kind;
|
|
44
|
+
break;
|
|
45
|
+
case "TsTypeReference":
|
|
46
|
+
result = tsType.typeName.value;
|
|
47
|
+
break;
|
|
48
|
+
case "TsFunctionType":
|
|
49
|
+
result = getPropertyFunctionTypeAsString(tsType);
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
30
55
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// }, reject);
|
|
63
|
-
// }
|
|
64
|
-
// else {
|
|
65
|
-
// $.tooling.logTime('Done - Generating documentation manifest', startTime);
|
|
66
|
-
// resolve();
|
|
67
|
-
// }
|
|
68
|
-
//}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
function generate(paths) {
|
|
72
|
-
return new Promise(function (resolve, reject) {
|
|
73
|
-
const { Documentalist, TypescriptPlugin } = require("documentalist");
|
|
74
|
-
new Documentalist()
|
|
75
|
-
.use(/\.ts?$/, new TypescriptPlugin())
|
|
76
|
-
.documentGlobs(...paths) // ← async operation, returns a Promise
|
|
77
|
-
.then(docs => {
|
|
78
|
-
//console.log("ahihi", docs.typescript);
|
|
79
|
-
var rootModel = docs.typescript;
|
|
80
|
-
var filterFilesPath = filterInterfaceFilePaths(rootModel, paths);
|
|
81
|
-
var elementInterfaces = getWebComponentAndMainInterface(Object.keys(filterFilesPath));
|
|
82
|
-
var fxDocs = builtFxDocs(rootModel, elementInterfaces);
|
|
83
|
-
writeFile(extensionEnvironment.outPutPaths.rawFile, JSON.stringify(fxDocs, null, 2)); //For debugging purpose
|
|
84
|
-
writeDocsManifest(extensionEnvironment.outPutPaths.manifest, extensionEnvironment.paths.composorImportPath, fxDocs);
|
|
85
|
-
writeNavRegistrion(extensionEnvironment.outPutPaths.navRegistration, extensionEnvironment.paths.topicImportPath, extensionEnvironment.paths.messageBusTopicMediatorImportPath, fxDocs);
|
|
86
|
-
writeDocsRegistration(extensionEnvironment.outPutPaths.folder, extensionEnvironment.paths.topicImportPath, extensionEnvironment.paths.messageBusTopicMediatorImportPath, fxDocs);
|
|
87
|
-
let docManifestRelativePath = relativeOutDir + "/docs.manifest.ts";
|
|
88
|
-
let docManifestAbsolutePath = $.tooling.utils.root(docManifestRelativePath);
|
|
89
|
-
// register docs manifest
|
|
90
|
-
if ($.fs.existsSync(docManifestAbsolutePath)) {
|
|
91
|
-
try {
|
|
92
|
-
$.composers.ManifestRegistry.setCurrentManifestPath(docManifestRelativePath);
|
|
93
|
-
require(docManifestAbsolutePath);
|
|
94
|
-
$.composers.ManifestRegistry.setCurrentManifestPath();
|
|
95
|
-
delete require.cache[docManifestAbsolutePath];
|
|
96
|
-
}
|
|
97
|
-
catch (ex) {
|
|
98
|
-
console.dir(ex.stack);
|
|
99
|
-
reject();
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
resolve();
|
|
103
|
-
}, reject);
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
function getSamples(interfaceFilePath) {
|
|
107
|
-
var elementNameReg = /elementName:( )*['"][^'"]+['"]/g; //Only @Prop has define default value
|
|
108
|
-
var entryPointReg = /entryPoint:( )*['"][^'"]+['"]/g;
|
|
109
|
-
var samples = [];
|
|
110
|
-
var interfaceSegments = interfaceFilePath.split('\\');
|
|
111
|
-
interfaceSegments.splice(-1, 1);
|
|
112
|
-
var folderPath = interfaceSegments.join('\\') + '\\samples';
|
|
113
|
-
var samplesManifests = getAllFilesInFolderRecursively(folderPath);
|
|
114
|
-
for (var sampleManifest of samplesManifests) {
|
|
115
|
-
var content = readFile(sampleManifest.filePath);
|
|
116
|
-
var elemNameMatches = content.match(elementNameReg);
|
|
117
|
-
var entryPointMatches = content.match(entryPointReg);
|
|
118
|
-
if (elemNameMatches && entryPointMatches) {
|
|
119
|
-
for (var i = 0; i < entryPointMatches.length; i++) {
|
|
120
|
-
var elemNameMatch = elemNameMatches[i];
|
|
121
|
-
var entryPointMatch = entryPointMatches[i];
|
|
122
|
-
var sampleElemDefinition = elemNameMatch.split(':').pop();
|
|
123
|
-
sampleElemDefinition = sampleElemDefinition.trim();
|
|
124
|
-
var sampleElem = sampleElemDefinition.substr(1, sampleElemDefinition.length - 2);
|
|
125
|
-
var entryPointDefinition = entryPointMatch.split(':').pop();
|
|
126
|
-
entryPointDefinition = entryPointDefinition.trim();
|
|
127
|
-
var entryPoint = entryPointDefinition.substr(1, entryPointDefinition.length - 2);
|
|
128
|
-
entryPoint = entryPoint.replace('./', '').replace('.jsx', '.tsx').split('/').join('\\');
|
|
129
|
-
var sampleTsxFilePath = sampleManifest.dirPath + '\\' + entryPoint;
|
|
130
|
-
var sampleTsxFileContent = readFile(sampleTsxFilePath);
|
|
131
|
-
sampleTsxFileContent = sampleTsxFileContent.replace(new RegExp('\\r\\n', 'g'), '\\\\r\\\\n');
|
|
132
|
-
//console.log(sampleTsxFileContent);
|
|
133
|
-
samples.push({ elem: sampleElem, content: sampleTsxFileContent });
|
|
56
|
+
function getNameProperty(ce, result) {
|
|
57
|
+
const identifier = ce.callee?.property?.value;
|
|
58
|
+
if (identifier) {
|
|
59
|
+
switch (identifier) {
|
|
60
|
+
case "name":
|
|
61
|
+
result.name = ce.arguments[0].expression.value;
|
|
62
|
+
getNameProperty(ce.callee.object, result);
|
|
63
|
+
break;
|
|
64
|
+
case "vModel":
|
|
65
|
+
result.type = DefineVueType.Model;
|
|
66
|
+
result.propertyTypeAsString = getPropertyType(ce.typeArguments.params[0]);
|
|
67
|
+
result.name = result.name ? `v-model:${result.name}` : result.name;
|
|
68
|
+
break;
|
|
69
|
+
case "slots":
|
|
70
|
+
result.type = DefineVueType.Slot;
|
|
71
|
+
result.propertyTypeAsObject = {};
|
|
72
|
+
ce.typeArguments.params[0].members
|
|
73
|
+
.forEach(m => {
|
|
74
|
+
result.propertyTypeAsObject[m.key.value] = getPropertyType(m.typeAnnotation);
|
|
75
|
+
});
|
|
76
|
+
break;
|
|
77
|
+
case "prop":
|
|
78
|
+
result.type = DefineVueType.Prop;
|
|
79
|
+
result.propertyTypeAsString = getPropertyType(ce.typeArguments.params[0]);
|
|
80
|
+
break;
|
|
81
|
+
case "emit":
|
|
82
|
+
result.type = DefineVueType.Emit;
|
|
83
|
+
result.propertyTypeAsString = getPropertyType(ce.typeArguments.params[0]);
|
|
84
|
+
break;
|
|
85
|
+
default:
|
|
86
|
+
getNameProperty(ce.callee.object, result);
|
|
134
87
|
}
|
|
135
88
|
}
|
|
136
89
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
90
|
+
async function buildDoc(wc) {
|
|
91
|
+
try {
|
|
92
|
+
const wcPath = (0, shared_1.convertManifestPathToEntryPath)(wc.manifestPath, [wc.componentOptions.entryPoint])[0];
|
|
93
|
+
const wcParseResult = await (0, core_1.parseFile)(wcPath, {
|
|
94
|
+
syntax: 'typescript',
|
|
95
|
+
target: 'es2020',
|
|
96
|
+
tsx: true,
|
|
97
|
+
decorators: true,
|
|
98
|
+
dynamicImport: true
|
|
99
|
+
});
|
|
100
|
+
wcParseResult.body.forEach(b => {
|
|
101
|
+
if (b.type === 'ExportDefaultExpression'
|
|
102
|
+
&& b.expression.callee?.value === "defineVueComponent") {
|
|
103
|
+
b.expression.arguments[0].expression
|
|
104
|
+
.properties?.filter(p => p.key.value === "props"
|
|
105
|
+
|| p.key.value === "emits")
|
|
106
|
+
?.forEach(propsIdentifier => {
|
|
107
|
+
if (propsIdentifier) {
|
|
108
|
+
propsIdentifier.value
|
|
109
|
+
.properties?.forEach(p => {
|
|
110
|
+
const em = p.arguments;
|
|
111
|
+
if (em?.callee?.property?.value === "doc$") {
|
|
112
|
+
const PropertyResult = {
|
|
113
|
+
type: null,
|
|
114
|
+
propertyTypeAsString: "",
|
|
115
|
+
name: ""
|
|
116
|
+
};
|
|
117
|
+
getNameProperty(em, PropertyResult);
|
|
118
|
+
if (!docResult[wc.componentOptions.elementName]) {
|
|
119
|
+
docResult[wc.componentOptions.elementName] = {
|
|
120
|
+
emits: {},
|
|
121
|
+
models: {},
|
|
122
|
+
props: {},
|
|
123
|
+
slots: {}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
switch (PropertyResult.type) {
|
|
127
|
+
case DefineVueType.Prop:
|
|
128
|
+
docResult[wc.componentOptions.elementName].props[PropertyResult.name] = {
|
|
129
|
+
type: PropertyResult.propertyTypeAsString,
|
|
130
|
+
description: em.arguments[0].expression.value
|
|
131
|
+
};
|
|
132
|
+
break;
|
|
133
|
+
case DefineVueType.Model:
|
|
134
|
+
docResult[wc.componentOptions.elementName].models[PropertyResult.name] = {
|
|
135
|
+
type: PropertyResult.propertyTypeAsString,
|
|
136
|
+
description: em.arguments[0].expression.value
|
|
137
|
+
};
|
|
138
|
+
break;
|
|
139
|
+
case DefineVueType.Emit:
|
|
140
|
+
docResult[wc.componentOptions.elementName].emits[PropertyResult.name] = {
|
|
141
|
+
type: PropertyResult.propertyTypeAsString,
|
|
142
|
+
description: em.arguments[0].expression.value
|
|
143
|
+
};
|
|
144
|
+
break;
|
|
145
|
+
case DefineVueType.Slot:
|
|
146
|
+
em.arguments[0].expression
|
|
147
|
+
.properties
|
|
148
|
+
.forEach(p => {
|
|
149
|
+
const slotName = p.key.value;
|
|
150
|
+
docResult[wc.componentOptions.elementName].slots[slotName] = {
|
|
151
|
+
type: PropertyResult.propertyTypeAsObject[slotName],
|
|
152
|
+
description: p.value.value
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
break;
|
|
156
|
+
default:
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
});
|
|
201
163
|
}
|
|
202
|
-
}
|
|
203
|
-
var defaultValue = propObj.defaultValue;
|
|
204
|
-
if (defaultValue && defaultValue.indexOf('\"') >= 0) {
|
|
205
|
-
defaultValue = defaultValue.replace(new RegExp('\\"', 'g'), '\\\"');
|
|
206
|
-
}
|
|
207
|
-
props.push({ name: prop, type: propObj.type, description: description, defaultValue: defaultValue });
|
|
164
|
+
});
|
|
208
165
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
var componentNodes = [];
|
|
214
|
-
for (var elem of Object.keys(fxDocs)) {
|
|
215
|
-
var name = elem;
|
|
216
|
-
if (fxDocs[elem] && fxDocs[elem].documentation && fxDocs[elem].documentation.contentsRaw) {
|
|
217
|
-
name = fxDocs[elem].documentation.contentsRaw.split('-')[0].trim();
|
|
166
|
+
catch (ex) {
|
|
167
|
+
tooling_1.utils.log(`Have a exception when extract doc$ for web component manifest -> ${wc.manifestPath}`, tooling_1.utils.LogTypes.Error);
|
|
168
|
+
console.error(ex);
|
|
169
|
+
throw new Error("Exit, have an exception.");
|
|
218
170
|
}
|
|
219
|
-
componentNodes.push({ name: name, elem: elem });
|
|
220
171
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
172
|
+
let docPath = path_1.default.resolve(__dirname, "ComponentDocRegistrations.ts");
|
|
173
|
+
;
|
|
174
|
+
const wcNamespace = (0, shared_1.getBuildOption)()?.webComponentNamespace;
|
|
175
|
+
const info = shared_1.ConfigurationManager.outputInfo.get();
|
|
176
|
+
info.wc = {
|
|
177
|
+
namespace: wcNamespace,
|
|
178
|
+
mappings: {}
|
|
179
|
+
};
|
|
180
|
+
let wcTypings = wcNamespace ? `
|
|
181
|
+
//{{importWC}}
|
|
182
|
+
declare global {
|
|
183
|
+
namespace JSX {
|
|
184
|
+
interface Element { }
|
|
185
|
+
interface ElementClass { }
|
|
186
|
+
|
|
187
|
+
interface IntrinsicElements {
|
|
188
|
+
//{{elementName}}
|
|
238
189
|
}
|
|
239
|
-
elementDoc.props = props;
|
|
240
|
-
var samples = getSamples(elementInfo.interfaceFilePath);
|
|
241
|
-
elementDoc.samples = samples;
|
|
242
|
-
fxDocs[element] = elementDoc;
|
|
243
190
|
}
|
|
244
|
-
return fxDocs;
|
|
245
191
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
var fileContent = readFile(componentPath);
|
|
252
|
-
var reg = /@Prop\(\{[^\)d]+(default)[^\)]+\)[a-zA-Z0-9?_ ]+:/g; //Only @Prop has define default value
|
|
253
|
-
var regResults = fileContent.match(reg);
|
|
254
|
-
if (regResults) {
|
|
255
|
-
for (var regResultContent of regResults) {
|
|
256
|
-
var propertyName = getPropertyNameFromPropDecorator(regResultContent);
|
|
257
|
-
var defaultValue = getDefaultValueFromPropDecorator(regResultContent);
|
|
258
|
-
if (propertyName && props[propertyName]) {
|
|
259
|
-
props[propertyName].defaultValue = defaultValue;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
192
|
+
|
|
193
|
+
declare global {
|
|
194
|
+
let ${wcNamespace}: {
|
|
195
|
+
//{{nselementName}}
|
|
196
|
+
};
|
|
263
197
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
var character = '';
|
|
275
|
-
for (var index = startIndex; index < propDecorator.length; index++) {
|
|
276
|
-
beforeCharacter = character;
|
|
277
|
-
character = propDecorator[index];
|
|
278
|
-
if (start) {
|
|
279
|
-
//IF the first default value character is not a object begin ({...), then we mark a flag to stop by ending at a normal text
|
|
280
|
-
if (!defaultValue.trim() && (character === "{" || character === "[" || character === "'" || character === '"')) {
|
|
281
|
-
enteredScope = true;
|
|
282
|
-
}
|
|
283
|
-
defaultValue += character;
|
|
284
|
-
if (enteredScope && character.trim()) {
|
|
285
|
-
if (character === "{" && (!enteredScopeKind || enteredScopeKind === "{")) {
|
|
286
|
-
enteredScopeKind = "{";
|
|
287
|
-
scope++;
|
|
288
|
-
}
|
|
289
|
-
else if (character === "}" && enteredScopeKind === "{") {
|
|
290
|
-
scope--;
|
|
291
|
-
if (scope === 0)
|
|
292
|
-
break;
|
|
293
|
-
}
|
|
294
|
-
else if (character === "[" && (!enteredScopeKind || enteredScopeKind === "[")) {
|
|
295
|
-
enteredScopeKind = "[";
|
|
296
|
-
scope++;
|
|
297
|
-
}
|
|
298
|
-
else if (character === "]" && enteredScopeKind === "]") {
|
|
299
|
-
scope--;
|
|
300
|
-
if (scope === 0)
|
|
301
|
-
break;
|
|
302
|
-
}
|
|
303
|
-
else if (character === "'" && !enteredScopeKind) {
|
|
304
|
-
enteredScopeKind = "'";
|
|
305
|
-
}
|
|
306
|
-
else if (character === "'" && enteredScopeKind === "'" && beforeCharacter !== '\\') {
|
|
307
|
-
break;
|
|
308
|
-
}
|
|
309
|
-
else if (character === '"' && !enteredScopeKind) {
|
|
310
|
-
enteredScopeKind = '"';
|
|
311
|
-
}
|
|
312
|
-
else if (character === '"' && enteredScopeKind === '"' && beforeCharacter !== '\\') {
|
|
313
|
-
break;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
if (!enteredScope && defaultValue.trim() && character && !regularValueReg.test(character))
|
|
317
|
-
break;
|
|
198
|
+
`
|
|
199
|
+
: `
|
|
200
|
+
//{{importWC}}
|
|
201
|
+
declare global {
|
|
202
|
+
namespace JSX {
|
|
203
|
+
interface Element { }
|
|
204
|
+
interface ElementClass { }
|
|
205
|
+
|
|
206
|
+
interface IntrinsicElements {
|
|
207
|
+
//{{elementName}}
|
|
318
208
|
}
|
|
319
|
-
if (character === ":")
|
|
320
|
-
start = true;
|
|
321
209
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
propDecorator = propDecorator.substring(0, propDecorator.lastIndexOf(':'));
|
|
327
|
-
var name = propDecorator.trim();
|
|
328
|
-
name = name.replace("?", ""); //remove optional in name
|
|
329
|
-
return name;
|
|
330
|
-
}
|
|
331
|
-
function getComponentProperties(rootModel, key, props) {
|
|
332
|
-
var model = rootModel[key];
|
|
333
|
-
var properties = model.properties;
|
|
334
|
-
for (var property of properties) {
|
|
335
|
-
props[property.name] = {
|
|
336
|
-
documentation: property.documentation,
|
|
337
|
-
type: property.type || 'any'
|
|
338
|
-
};
|
|
210
|
+
}`;
|
|
211
|
+
if (shared_1.isExtensionEnv) {
|
|
212
|
+
wcTypings = `import { VueComponentBaseProps } from "@omnia/fx/ux";
|
|
213
|
+
${wcTypings}`;
|
|
339
214
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
getComponentProperties(rootModel, extend, props);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
215
|
+
else {
|
|
216
|
+
wcTypings = `import { VueComponentBaseProps } from "../../../../client/fx/ux/index";
|
|
217
|
+
${wcTypings}`;
|
|
346
218
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
219
|
+
await tooling_1.utils.asyncForEach(componentRegistrations, async (wc) => {
|
|
220
|
+
wcTypings = generateWebComponentTypings(wc, wcTypings, info);
|
|
221
|
+
await buildDoc(wc);
|
|
222
|
+
});
|
|
223
|
+
if (Object.keys(docResult).length > 0) {
|
|
224
|
+
fsExtra.outputFileSync(docPath, `
|
|
225
|
+
import { extendApi } from "@omnia/fx";
|
|
226
|
+
import { ComponentDoc } from "@omnia/fx-models";
|
|
227
|
+
|
|
228
|
+
extendApi(api => api.fx.docs.registrations, api => {
|
|
229
|
+
|
|
230
|
+
const registrations: { [elementName: string]: ComponentDoc } = ${JSON.stringify(docResult)}
|
|
231
|
+
|
|
232
|
+
Object.keys(registrations).forEach(elementName => {
|
|
233
|
+
api.register(elementName, registrations[elementName]);
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
`);
|
|
237
|
+
// create dynamic doc manifest
|
|
238
|
+
tooling_composers_1.ManifestRegistry.setCurrentManifestPath(`${path_1.default.relative(tooling_1.utils.root(""), path_1.default.resolve(__dirname))}/`);
|
|
239
|
+
tooling_composers_1.Composer
|
|
240
|
+
.registerManifest((0, shared_1.getBuildOption)().docResourceManifestId || new fx_models_1.Guid(`${tooling_1.utils.generateGuid()}`), "omnia.fx.docs.components.registraions")
|
|
241
|
+
.registerResources({
|
|
242
|
+
resourcePaths: ["./ComponentDocRegistrations.ts"]
|
|
243
|
+
})
|
|
244
|
+
.withTarget(fx_models_1.ClientManifestTargetTypes.Docs)
|
|
245
|
+
.extendApi(api => api.fx.docs.registrations);
|
|
246
|
+
tooling_composers_1.ManifestRegistry.setCurrentManifestPath();
|
|
366
247
|
}
|
|
367
|
-
|
|
248
|
+
shared_1.ConfigurationManager.webComponentTypings.update(wcTypings);
|
|
249
|
+
shared_1.ConfigurationManager.outputInfo.update(info);
|
|
250
|
+
tooling_1.utils.logTime('Done - Generate components typings and documentation', startTime);
|
|
368
251
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}
|
|
252
|
+
exports.generateComponentTypingsAndDoc = generateComponentTypingsAndDoc;
|
|
253
|
+
function generateWebComponentTypings(wc, template, info) {
|
|
254
|
+
// export default defineVueWebComponent
|
|
255
|
+
const wcPath = wc.componentOptions.entryPointPath;
|
|
256
|
+
let content = fsExtra.readFileSync(wcPath, 'utf8');
|
|
257
|
+
if (content.indexOf("defineVueComponent") > -1) {
|
|
258
|
+
if (!new RegExp('export\\s+default\\s+').test(content)) {
|
|
259
|
+
throw new Error(`Missing statement 'export default a vue web component' in ${wcPath}`);
|
|
378
260
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
// return fs.readdirSync(filepath).filter(function (file) {
|
|
384
|
-
// return fs.statSync($.path.join(filepath, file)).isFile();
|
|
385
|
-
// });
|
|
386
|
-
//}
|
|
387
|
-
function writeFile(filepath, content) {
|
|
388
|
-
fs.writeFileSync(filepath, content);
|
|
389
|
-
}
|
|
390
|
-
function readFile(filePath) {
|
|
391
|
-
return fs.readFileSync(filePath, 'utf-8');
|
|
392
|
-
}
|
|
393
|
-
function getAllFilesInFolderRecursively(dirPath) {
|
|
394
|
-
var files = [];
|
|
395
|
-
if (fs.existsSync(dirPath)) {
|
|
396
|
-
var paths = fs.readdirSync(dirPath).map(function (file) { return { dirPath: dirPath, filePath: dirPath + '\\' + file }; });
|
|
397
|
-
files = paths.filter(function (path) {
|
|
398
|
-
return fs.statSync(path.filePath).isFile() && path.filePath.indexOf('.manifest.ts') >= 0;
|
|
399
|
-
});
|
|
400
|
-
var folders = paths.filter(function (path) {
|
|
401
|
-
return fs.statSync(path.filePath).isFile() === false;
|
|
402
|
-
});
|
|
403
|
-
for (var path of folders) {
|
|
404
|
-
files = files.concat(getAllFilesInFolderRecursively(path.filePath));
|
|
261
|
+
let friendlyManifestId = `wc${wc.manifest.resourceId.toString().replace(/-/g, '').toLowerCase()}`;
|
|
262
|
+
let importPath = wcPath.substring(0, wcPath.lastIndexOf('.tsx'));
|
|
263
|
+
if (importPath.indexOf("./") === 0) {
|
|
264
|
+
importPath = importPath.replace("./", "");
|
|
405
265
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
;
|
|
410
|
-
function extractDocPathForComponents(componentRegistrations) {
|
|
411
|
-
let componentsDocCount = 0;
|
|
412
|
-
let paths = [];
|
|
413
|
-
componentRegistrations.forEach((comp) => {
|
|
414
|
-
let defPaths = comp.componentOptions.documentations;
|
|
415
|
-
if (defPaths) {
|
|
416
|
-
componentsDocCount++;
|
|
417
|
-
defPaths.forEach((defPath) => {
|
|
418
|
-
paths.push((0, shared_1.convertManifestPathToEntryPath)(comp.manifestPath, [defPath])[0]);
|
|
419
|
-
//paths.push($.tooling.utils.root(convertManifestPathToEntryPath(comp.manifestPath, [defPath])[0]));
|
|
420
|
-
});
|
|
266
|
+
if (shared_1.isExtensionEnv) {
|
|
267
|
+
importPath = `../../../../${importPath}`;
|
|
421
268
|
}
|
|
422
|
-
|
|
423
|
-
|
|
269
|
+
else {
|
|
270
|
+
importPath = `../../../../${importPath}`;
|
|
271
|
+
}
|
|
272
|
+
let elementNamePascalCase = wc.componentOptions.elementName.replace("omfx-", "").replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
|
|
273
|
+
elementNamePascalCase = elementNamePascalCase[0].toUpperCase() + elementNamePascalCase.substring(1, elementNamePascalCase.length);
|
|
274
|
+
info.wc.mappings[elementNamePascalCase] = wc.componentOptions.elementName;
|
|
275
|
+
return template
|
|
276
|
+
.replace(/\/\/{{importWC}}/, `import ${friendlyManifestId} from '${importPath}';
|
|
277
|
+
//{{importWC}}`)
|
|
278
|
+
.replace(/\/\/{{elementName}}/, `"${wc.componentOptions.elementName}": typeof ${friendlyManifestId}.propsDefinition & Omit<VueComponentBaseProps, keyof typeof ${friendlyManifestId}.propsDefinition>
|
|
279
|
+
//{{elementName}}`)
|
|
280
|
+
.replace(/\/\/{{nselementName}}/, `"${elementNamePascalCase}": { new(...args: any[]): { $props: typeof ${friendlyManifestId}.propsDefinition & Omit<VueComponentBaseProps, keyof typeof ${friendlyManifestId}.propsDefinition> } }
|
|
281
|
+
//{{nselementName}}`);
|
|
282
|
+
}
|
|
283
|
+
return template;
|
|
424
284
|
}
|