@tantawowa/hosanna-tools 0.1.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/README.md +69 -0
- package/dist/build-info.json +3 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +128 -0
- package/dist/cli.js.map +1 -0
- package/dist/generation/command-handler-generator.d.ts +3 -0
- package/dist/generation/command-handler-generator.js +169 -0
- package/dist/generation/command-handler-generator.js.map +1 -0
- package/dist/generation/generation-utils.d.ts +9 -0
- package/dist/generation/generation-utils.js +114 -0
- package/dist/generation/generation-utils.js.map +1 -0
- package/dist/generation/struct-generator.d.ts +10 -0
- package/dist/generation/struct-generator.js +553 -0
- package/dist/generation/struct-generator.js.map +1 -0
- package/dist/generation/view-generator.d.ts +1 -0
- package/dist/generation/view-generator.js +71 -0
- package/dist/generation/view-generator.js.map +1 -0
- package/dist/hosanna-tools/cli.d.ts +0 -0
- package/dist/hosanna-tools/cli.js +2 -0
- package/dist/hosanna-tools/cli.js.map +1 -0
- package/dist/lib/hosanna-tools-utils.d.ts +1 -0
- package/dist/lib/hosanna-tools-utils.js +87 -0
- package/dist/lib/hosanna-tools-utils.js.map +1 -0
- package/dist/updater/sdk-manager.d.ts +3 -0
- package/dist/updater/sdk-manager.js +196 -0
- package/dist/updater/sdk-manager.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.containsHosannaView = exports.getViewMetadata = exports.generateStructForFile = void 0;
|
|
27
|
+
// hs:exclude-from-platform roku
|
|
28
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
29
|
+
const fs = __importStar(require("fs"));
|
|
30
|
+
const path = __importStar(require("path"));
|
|
31
|
+
const ts = __importStar(require("typescript"));
|
|
32
|
+
function getImports(sourceFile) {
|
|
33
|
+
const importMap = new Map();
|
|
34
|
+
let baseViewPath;
|
|
35
|
+
function extractTypeReferences(typeNode, sourceFile) {
|
|
36
|
+
if (!typeNode)
|
|
37
|
+
return;
|
|
38
|
+
switch (typeNode.kind) {
|
|
39
|
+
case ts.SyntaxKind.Identifier: {
|
|
40
|
+
const typeName = typeNode.text;
|
|
41
|
+
if (!importMap.has(typeName)) {
|
|
42
|
+
importMap.set(typeName, sourceFile.fileName);
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
case ts.SyntaxKind.TypeReference: {
|
|
47
|
+
const typeRef = typeNode;
|
|
48
|
+
if (ts.isIdentifier(typeRef.typeName)) {
|
|
49
|
+
const typeName = typeRef.typeName.getText();
|
|
50
|
+
if (!importMap.has(typeName)) {
|
|
51
|
+
importMap.set(typeName, sourceFile.fileName);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (typeRef.typeArguments) {
|
|
55
|
+
typeRef.typeArguments.forEach((arg) => extractTypeReferences(arg, sourceFile));
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
case ts.SyntaxKind.UnionType:
|
|
60
|
+
typeNode.types.forEach((type) => extractTypeReferences(type, sourceFile));
|
|
61
|
+
break;
|
|
62
|
+
case ts.SyntaxKind.ArrayType:
|
|
63
|
+
extractTypeReferences(typeNode.elementType, sourceFile);
|
|
64
|
+
break;
|
|
65
|
+
case ts.SyntaxKind.FunctionType: {
|
|
66
|
+
const funcType = typeNode;
|
|
67
|
+
funcType.parameters.forEach((param) => {
|
|
68
|
+
if (param.type) {
|
|
69
|
+
extractTypeReferences(param.type, sourceFile);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
if (funcType.type) {
|
|
73
|
+
extractTypeReferences(funcType.type, sourceFile);
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
case ts.SyntaxKind.TypeLiteral: {
|
|
78
|
+
typeNode.members.forEach((member) => {
|
|
79
|
+
if (ts.isPropertySignature(member) &&
|
|
80
|
+
member.type) {
|
|
81
|
+
extractTypeReferences(member.type, sourceFile);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
case ts.SyntaxKind.ParenthesizedType:
|
|
87
|
+
extractTypeReferences(typeNode.type, sourceFile);
|
|
88
|
+
break;
|
|
89
|
+
default: {
|
|
90
|
+
if (typeNode.typeName && ts.isIdentifier(typeNode.typeName)) {
|
|
91
|
+
const name = typeNode.typeName.getText();
|
|
92
|
+
if (!importMap.has(name)) {
|
|
93
|
+
importMap.set(name, sourceFile.fileName);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
ts.forEachChild(sourceFile, (node) => {
|
|
101
|
+
var _a, _b, _c, _d;
|
|
102
|
+
if (ts.isImportDeclaration(node)) {
|
|
103
|
+
const importClause = node.importClause;
|
|
104
|
+
const modulePath = (_a = node.moduleSpecifier) === null || _a === void 0 ? void 0 : _a.text;
|
|
105
|
+
const importClauseNode = importClause === null || importClause === void 0 ? void 0 : importClause.namedBindings;
|
|
106
|
+
if (importClause && modulePath && importClauseNode && ts.isNamedImports(importClauseNode)) {
|
|
107
|
+
const namedImports = importClause.namedBindings;
|
|
108
|
+
(_b = namedImports === null || namedImports === void 0 ? void 0 : namedImports.elements) === null || _b === void 0 ? void 0 : _b.forEach((element) => {
|
|
109
|
+
const importName = element.name.getText();
|
|
110
|
+
importMap.set(importName, modulePath);
|
|
111
|
+
if (importName === 'BaseView') {
|
|
112
|
+
baseViewPath = modulePath;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (ts.isExportDeclaration(node) && node.exportClause && ts.isNamedExports(node.exportClause)) {
|
|
118
|
+
const modulePath = (_c = node.moduleSpecifier) === null || _c === void 0 ? void 0 : _c.text;
|
|
119
|
+
if (modulePath) {
|
|
120
|
+
node.exportClause.elements.forEach((element) => {
|
|
121
|
+
const exportName = element.name.getText();
|
|
122
|
+
importMap.set(exportName, modulePath);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (ts.isEnumDeclaration(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node)) {
|
|
127
|
+
const exportName = (_d = node.name) === null || _d === void 0 ? void 0 : _d.getText();
|
|
128
|
+
if (exportName) {
|
|
129
|
+
const relativePath = './' + path.relative(path.dirname(sourceFile.fileName), sourceFile.fileName).replace(/\\/g, '/').replace(/\.ts$/, '');
|
|
130
|
+
importMap.set(exportName, relativePath);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Check interface members for types, including function types
|
|
134
|
+
if (ts.isInterfaceDeclaration(node) && node.members) {
|
|
135
|
+
node.members.forEach((member) => {
|
|
136
|
+
if (ts.isPropertySignature(member) && member.type) {
|
|
137
|
+
extractTypeReferences(member.type, sourceFile);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
if (baseViewPath) {
|
|
143
|
+
importMap.set('ViewStruct', baseViewPath.replace('/BaseView', '/view-api'));
|
|
144
|
+
importMap.set('ViewState', baseViewPath.replace('/BaseView', '/view-api'));
|
|
145
|
+
}
|
|
146
|
+
return importMap;
|
|
147
|
+
}
|
|
148
|
+
// Check if a specific import already exists in the original file
|
|
149
|
+
function hasImportStatement(originalContent, generatedFileName) {
|
|
150
|
+
const importRegex = new RegExp(`import\\s*{[^}]*\\b\\w+ViewStruct\\b[^}]*}\\s*from\\s*['"]\\./${path.basename(generatedFileName, '.ts')}['"];`, 's');
|
|
151
|
+
return importRegex.test(originalContent);
|
|
152
|
+
}
|
|
153
|
+
// Check if a specific export already exists in the original file
|
|
154
|
+
function hasExportStatement(originalContent) {
|
|
155
|
+
const exportRegex = /export\s*{[^}]*\b\w+ViewStruct\b[^}]*}/;
|
|
156
|
+
return exportRegex.test(originalContent);
|
|
157
|
+
}
|
|
158
|
+
let _rootProjectPath = '';
|
|
159
|
+
// Parse and generate struct based on the interface
|
|
160
|
+
function generateStructForFile(fileName, rootProjectPath) {
|
|
161
|
+
_rootProjectPath = rootProjectPath;
|
|
162
|
+
const sourceCode = fs.readFileSync(fileName).toString();
|
|
163
|
+
const sourceFile = ts.createSourceFile(fileName, sourceCode, ts.ScriptTarget.Latest, true);
|
|
164
|
+
const imports = getImports(sourceFile); // Get all imports from the original file
|
|
165
|
+
const baseFileName = path.basename(fileName, '.ts'); // Extract the base file name
|
|
166
|
+
const generatedStructs = [];
|
|
167
|
+
const requiredImports = new Set();
|
|
168
|
+
const viewMetadata = getViewMetadata(sourceFile);
|
|
169
|
+
if (!viewMetadata) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const { viewName: targetViewName, isAggregate: isAggregateView, className: viewClassName } = viewMetadata;
|
|
173
|
+
ts.forEachChild(sourceFile, (node) => {
|
|
174
|
+
if (ts.isInterfaceDeclaration(node)) {
|
|
175
|
+
const heritageClauses = node.heritageClauses;
|
|
176
|
+
if (heritageClauses) {
|
|
177
|
+
const isViewState = isInterfaceViewState(heritageClauses, sourceFile, imports);
|
|
178
|
+
if (isViewState) {
|
|
179
|
+
console.log(`Generating view struct for ${sourceFile.fileName}`);
|
|
180
|
+
const stateInterface = node.name.getText(); // E.g., "LabelState"
|
|
181
|
+
const structClassName = getTargetStructClassName(targetViewName);
|
|
182
|
+
//FIXME - we need to know the actual class name of this view!!! the way we work this out presently is wrong - it should come from the class that has the @view decorator
|
|
183
|
+
const generatorFunctionName = targetViewName; // E.g., "LabelView"
|
|
184
|
+
const requiredImportsMap = getImports(sourceFile);
|
|
185
|
+
const usedImports = new Set();
|
|
186
|
+
// Determine the correct base struct class
|
|
187
|
+
let baseStructClass = 'ViewStruct<T>';
|
|
188
|
+
heritageClauses.forEach(clause => {
|
|
189
|
+
clause.types.forEach(type => {
|
|
190
|
+
const typeName = type.expression.getText();
|
|
191
|
+
if (typeName !== 'ViewState' && imports.has(typeName)) {
|
|
192
|
+
const viewName = getViewNameForState(typeName, sourceFile, imports);
|
|
193
|
+
if (viewName) {
|
|
194
|
+
baseStructClass = `_${viewName}ViewStruct<T>`;
|
|
195
|
+
// console.log(`>>>Using base struct class ${baseStructClass} for ${typeName}`);
|
|
196
|
+
// baseStructClass = `${viewName}ViewStruct<${typeName}>`;
|
|
197
|
+
addImportsForExtendedViewStruct(typeName, viewName, sourceFile, imports, requiredImportsMap, usedImports);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
const structMethods = node.members.map((member) => {
|
|
203
|
+
const memberName = member.name.getText();
|
|
204
|
+
const memberType = member.type ? member.type.getFullText(sourceFile).trim() : 'any';
|
|
205
|
+
return ` ${memberName}(${memberName}: ${memberType}) {
|
|
206
|
+
this.state.${memberName} = ${memberName};
|
|
207
|
+
return this;
|
|
208
|
+
}`;
|
|
209
|
+
});
|
|
210
|
+
requiredImportsMap.forEach((value, key) => requiredImports.add(key));
|
|
211
|
+
// Filter required imports to remove anything that is not used in the ViewState
|
|
212
|
+
node.members.forEach((member) => {
|
|
213
|
+
const memberType = member.type;
|
|
214
|
+
if (memberType) {
|
|
215
|
+
if (ts.isUnionTypeNode(memberType)) {
|
|
216
|
+
memberType.types.forEach((type) => {
|
|
217
|
+
const typeName = type.getText().replace(/<.*>/, '');
|
|
218
|
+
if (requiredImports.has(typeName)) {
|
|
219
|
+
usedImports.add(typeName);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
else if (ts.isArrayTypeNode(memberType)) {
|
|
224
|
+
const elementType = memberType.elementType;
|
|
225
|
+
if (ts.isTypeReferenceNode(elementType)) {
|
|
226
|
+
const typeName = elementType.getText().replace(/<.*>/, '');
|
|
227
|
+
if (requiredImports.has(typeName)) {
|
|
228
|
+
usedImports.add(typeName);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
else if (ts.isTypeReferenceNode(memberType)) {
|
|
233
|
+
const typeName = memberType.typeName.getText();
|
|
234
|
+
if (requiredImports.has(typeName)) {
|
|
235
|
+
usedImports.add(typeName);
|
|
236
|
+
}
|
|
237
|
+
// Check for generic types
|
|
238
|
+
if (memberType.typeArguments) {
|
|
239
|
+
memberType.typeArguments.forEach((typeArg) => {
|
|
240
|
+
const typeArgName = typeArg.getText();
|
|
241
|
+
if (requiredImports.has(typeArgName)) {
|
|
242
|
+
usedImports.add(typeArgName);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else if (ts.isFunctionTypeNode(memberType)) {
|
|
248
|
+
// Walk parameter types
|
|
249
|
+
memberType.parameters.forEach((param) => {
|
|
250
|
+
if (param.type) {
|
|
251
|
+
const paramTypeName = getTypeName(param.type);
|
|
252
|
+
if (requiredImports.has(paramTypeName)) {
|
|
253
|
+
usedImports.add(paramTypeName);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
// Return type
|
|
258
|
+
if (memberType.type) {
|
|
259
|
+
const returnTypeName = getTypeName(memberType.type);
|
|
260
|
+
if (requiredImports.has(returnTypeName)) {
|
|
261
|
+
usedImports.add(returnTypeName);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
const typeName = getTypeName(memberType);
|
|
267
|
+
if (requiredImports.has(typeName)) {
|
|
268
|
+
usedImports.add(typeName);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
// Ensure types that are exported are imported
|
|
274
|
+
const relativePathToAppUtils = getRelativePath(fileName, './src/hosanna-bridge-lib/AppUtils');
|
|
275
|
+
const relativePathToInstancePool = getRelativePath(fileName, './src/hosanna-ui/hosanna-api');
|
|
276
|
+
const relativePathToHsStruct = getRelativePath(fileName, './src/hosanna-ui/lib/struct-decorators');
|
|
277
|
+
const relativePathToViewApi = getRelativePath(fileName, './src/hosanna-ui/views/lib/view-api');
|
|
278
|
+
const exportedTypes = getExportedTypes(sourceFile);
|
|
279
|
+
usedImports.delete('ViewStruct');
|
|
280
|
+
usedImports.delete('AppUtils');
|
|
281
|
+
usedImports.delete('Record'); //do not allow this to accidentally be imported
|
|
282
|
+
usedImports.delete('IInstancePool');
|
|
283
|
+
usedImports.delete('FocusChildChangeEvent');
|
|
284
|
+
usedImports.delete(viewClassName);
|
|
285
|
+
imports.delete(viewClassName);
|
|
286
|
+
let generatedStruct = `
|
|
287
|
+
|
|
288
|
+
/* eslint-disable */
|
|
289
|
+
import { ${viewClassName}, ${stateInterface} } from '${viewMetadata.importFileName}';
|
|
290
|
+
${Array.from(usedImports).filter((type) => !exportedTypes.has(type)).map((type) => `import { ${type} } from '${imports.get(type)}';`).join('\n')}
|
|
291
|
+
import { FocusChildChangeEvent, ViewStruct, ViewState } from '${relativePathToViewApi}';
|
|
292
|
+
import { AppUtils } from '${relativePathToAppUtils}';
|
|
293
|
+
import { IInstancePool } from '${relativePathToInstancePool}';
|
|
294
|
+
import { hs_struct } from '${relativePathToHsStruct}';
|
|
295
|
+
|
|
296
|
+
${Array.from(exportedTypes).map((type) => `import { ${type} } from './${baseFileName}';`).join('\n')}
|
|
297
|
+
|
|
298
|
+
export class _${structClassName}<T extends ${stateInterface}> extends ${baseStructClass} {
|
|
299
|
+
__viewClassName = '${viewClassName}';
|
|
300
|
+
${structMethods.join('\n')}
|
|
301
|
+
override createHosannaView(): any {
|
|
302
|
+
const view = AppUtils.resolve<IInstancePool>('instancePool').get('${viewClassName}', ${viewClassName});
|
|
303
|
+
return view;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
@hs_struct("${structClassName}"${isAggregateView ? ', true' : ''})
|
|
308
|
+
export class ${structClassName} extends _${structClassName}<${stateInterface}> {
|
|
309
|
+
}
|
|
310
|
+
`;
|
|
311
|
+
//CHECKME
|
|
312
|
+
//CHECKME
|
|
313
|
+
//CHECKME
|
|
314
|
+
//CHECKME
|
|
315
|
+
//FIXME -why was I creating new structs for children every time???
|
|
316
|
+
if (isAggregateView) {
|
|
317
|
+
generatedStruct += `
|
|
318
|
+
export function ${generatorFunctionName}(children: ViewStruct<ViewState>[]) {
|
|
319
|
+
// return new ${structClassName}({} as any).children(children);
|
|
320
|
+
const struct = AppUtils.resolve<IInstancePool>('instancePool').get<${structClassName}>('${structClassName}', ${structClassName});
|
|
321
|
+
struct.setState({} as any);
|
|
322
|
+
return struct.children(children);
|
|
323
|
+
}`;
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
generatedStruct += `
|
|
327
|
+
|
|
328
|
+
export function ${generatorFunctionName}(state?: ${stateInterface}): ${structClassName} {
|
|
329
|
+
const struct = AppUtils.resolve<IInstancePool>('instancePool').get<${structClassName}>('${structClassName}', ${structClassName});
|
|
330
|
+
struct.setState(state as any);
|
|
331
|
+
return struct;
|
|
332
|
+
}
|
|
333
|
+
`;
|
|
334
|
+
}
|
|
335
|
+
generatedStructs.push(generatedStruct);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
if (generatedStructs.length > 0) {
|
|
341
|
+
const generatedFileName = generateOutputFileName(fileName);
|
|
342
|
+
fs.writeFileSync(generatedFileName, generatedStructs.join('\n'));
|
|
343
|
+
updateOriginalFile(fileName, generatedFileName, baseFileName, targetViewName);
|
|
344
|
+
}
|
|
345
|
+
else if (targetViewName) {
|
|
346
|
+
console.warn(`Could not ascertain viewState for view ${targetViewName} in ${sourceFile.fileName}`);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
exports.generateStructForFile = generateStructForFile;
|
|
350
|
+
function isInterfaceViewState(heritageClauses, sourceFile, imports) {
|
|
351
|
+
const parents = []; //!Do we need this???
|
|
352
|
+
for (const clause of heritageClauses) {
|
|
353
|
+
for (const t of clause.types) {
|
|
354
|
+
if (t.expression.getText().match(/(.*)ViewState/)) {
|
|
355
|
+
return true;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
for (const clause of heritageClauses) {
|
|
360
|
+
for (const t of clause.types) {
|
|
361
|
+
const typeName = t.expression.getText();
|
|
362
|
+
parents.push(typeName); //!Do we need this???
|
|
363
|
+
if (isParentInterfaceViewState(typeName, sourceFile, imports)) {
|
|
364
|
+
return true;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
// console.log(`Could not ascertain ViewState interface for ${sourceFile.fileName}: After checking parents ${parents.join(', ')}`);
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
function isParentInterfaceViewState(name, sourceFile, imports) {
|
|
372
|
+
const importPath = imports.get(name);
|
|
373
|
+
if (!importPath)
|
|
374
|
+
return false;
|
|
375
|
+
const resolvedPath = path.resolve(path.dirname(sourceFile.fileName), importPath + '.ts');
|
|
376
|
+
if (!fs.existsSync(resolvedPath))
|
|
377
|
+
return false;
|
|
378
|
+
const fileContent = fs.readFileSync(resolvedPath, 'utf-8');
|
|
379
|
+
const parentSourceFile = ts.createSourceFile(resolvedPath, fileContent, ts.ScriptTarget.Latest, true);
|
|
380
|
+
let parentInterface;
|
|
381
|
+
ts.forEachChild(parentSourceFile, (node) => {
|
|
382
|
+
if (ts.isInterfaceDeclaration(node) && node.name.getText() === name) {
|
|
383
|
+
parentInterface = node;
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
if (!parentInterface)
|
|
387
|
+
return false;
|
|
388
|
+
const heritageClauses = parentInterface.heritageClauses;
|
|
389
|
+
if (!heritageClauses)
|
|
390
|
+
return false;
|
|
391
|
+
return isInterfaceViewState(heritageClauses, parentSourceFile, getImports(parentSourceFile));
|
|
392
|
+
}
|
|
393
|
+
// Generate the new file name (e.g., Button.ts -> Button-generated-struct.ts)
|
|
394
|
+
function generateOutputFileName(fileName) {
|
|
395
|
+
const dirName = path.dirname(fileName);
|
|
396
|
+
const baseName = path.basename(fileName, '.ts');
|
|
397
|
+
return path.join(dirName, `${baseName}-generated-struct.ts`);
|
|
398
|
+
}
|
|
399
|
+
// Ensure the original file imports the generated file and exports the generated structs, only if they are missing
|
|
400
|
+
function updateOriginalFile(originalFileName, generatedFileName, baseFileName, targetViewName) {
|
|
401
|
+
const originalContent = fs.readFileSync(originalFileName).toString();
|
|
402
|
+
// Import statement to be added if missing
|
|
403
|
+
const importStatement = `import { ${targetViewName}ViewStruct, ${baseFileName} } from './${path.basename(generatedFileName, '.ts')}';\n`;
|
|
404
|
+
// Export statement to be added if missing
|
|
405
|
+
const exportStatement = `export { ${targetViewName}ViewStruct, ${baseFileName} };\n`;
|
|
406
|
+
let updatedContent = originalContent;
|
|
407
|
+
// Add export only if it doesn't already exist
|
|
408
|
+
if (!hasExportStatement(originalContent)) {
|
|
409
|
+
updatedContent = exportStatement + updatedContent;
|
|
410
|
+
}
|
|
411
|
+
// Add import at the top if it doesn't already exist
|
|
412
|
+
if (!hasImportStatement(originalContent, generatedFileName)) {
|
|
413
|
+
updatedContent = importStatement + updatedContent;
|
|
414
|
+
}
|
|
415
|
+
// Update the original file only if changes were made
|
|
416
|
+
if (updatedContent !== originalContent) {
|
|
417
|
+
fs.writeFileSync(originalFileName, updatedContent);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
function getViewMetadata(sourceFile) {
|
|
421
|
+
let metadata;
|
|
422
|
+
ts.forEachChild(sourceFile, (node) => {
|
|
423
|
+
var _a, _b;
|
|
424
|
+
if (ts.isClassDeclaration(node)) {
|
|
425
|
+
const className = (_b = (_a = node.name) === null || _a === void 0 ? void 0 : _a.getText()) !== null && _b !== void 0 ? _b : 'UnknownClass';
|
|
426
|
+
// Check for @view
|
|
427
|
+
const viewDecoratorArg = getDecoratorArgument(node, 'view');
|
|
428
|
+
if (viewDecoratorArg) {
|
|
429
|
+
if (!metadata) {
|
|
430
|
+
metadata = {
|
|
431
|
+
viewName: viewDecoratorArg,
|
|
432
|
+
className,
|
|
433
|
+
isAggregate: false,
|
|
434
|
+
importFileName: './' + path.basename(sourceFile.fileName, '.ts'), // <-- Add this
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
throw new Error(`Multiple @view/@aggregateView decorators found in ${sourceFile.fileName}. Only one is allowed.`);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
// Check for @aggregateView
|
|
442
|
+
const aggregateViewDecoratorArg = getDecoratorArgument(node, 'aggregateView');
|
|
443
|
+
if (aggregateViewDecoratorArg) {
|
|
444
|
+
if (!metadata) {
|
|
445
|
+
metadata = {
|
|
446
|
+
viewName: aggregateViewDecoratorArg,
|
|
447
|
+
className,
|
|
448
|
+
isAggregate: true,
|
|
449
|
+
importFileName: './' + path.basename(sourceFile.fileName, '.ts'), // <-- Add this
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
throw new Error(`Multiple @view/@aggregateView decorators found in ${sourceFile.fileName}. Only one is allowed.`);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
return metadata;
|
|
459
|
+
}
|
|
460
|
+
exports.getViewMetadata = getViewMetadata;
|
|
461
|
+
function getDecoratorArgument(node, decoratorName) {
|
|
462
|
+
var _a, _b;
|
|
463
|
+
const decorator = (_a = node === null || node === void 0 ? void 0 : node.modifiers) === null || _a === void 0 ? void 0 : _a.find((modifier) => {
|
|
464
|
+
var _a, _b;
|
|
465
|
+
return (ts.isDecorator(modifier) &&
|
|
466
|
+
ts.isCallExpression(modifier === null || modifier === void 0 ? void 0 : modifier.expression) && ((_b = (_a = modifier === null || modifier === void 0 ? void 0 : modifier.expression) === null || _a === void 0 ? void 0 : _a.expression) === null || _b === void 0 ? void 0 : _b.text) === decoratorName);
|
|
467
|
+
});
|
|
468
|
+
if (decorator && ts.isCallExpression(decorator === null || decorator === void 0 ? void 0 : decorator.expression)) {
|
|
469
|
+
const decoratorExpression = decorator.expression;
|
|
470
|
+
return ((_b = decoratorExpression.arguments[0]) === null || _b === void 0 ? void 0 : _b.text) || null;
|
|
471
|
+
}
|
|
472
|
+
return null;
|
|
473
|
+
}
|
|
474
|
+
function getRelativePath(fileName, targetPath) {
|
|
475
|
+
const hosannaPath = path.resolve(_rootProjectPath, '../../hosanna-ui');
|
|
476
|
+
targetPath = targetPath.replace(`${hosannaPath}/`, '');
|
|
477
|
+
targetPath = targetPath.replace(/^\.?\/?src\//, '');
|
|
478
|
+
fileName = fileName.replace(`${hosannaPath}/`, '');
|
|
479
|
+
const absoluteTargetPath = path.resolve(_rootProjectPath, targetPath);
|
|
480
|
+
const fromDir = path.dirname(fileName);
|
|
481
|
+
const relative = path.relative(fromDir, absoluteTargetPath);
|
|
482
|
+
// debugger;
|
|
483
|
+
return relative.replace(/\\/g, '/');
|
|
484
|
+
}
|
|
485
|
+
function getExportedTypes(sourceFile) {
|
|
486
|
+
const exportTypes = new Set();
|
|
487
|
+
ts.forEachChild(sourceFile, (node) => {
|
|
488
|
+
var _a;
|
|
489
|
+
if (ts.isTypeAliasDeclaration(node) && ((_a = node.modifiers) === null || _a === void 0 ? void 0 : _a.some(mod => mod.kind === ts.SyntaxKind.ExportKeyword))) {
|
|
490
|
+
const exportName = node.name.getText();
|
|
491
|
+
exportTypes.add(exportName);
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
return exportTypes;
|
|
495
|
+
}
|
|
496
|
+
function containsHosannaView(filePath) {
|
|
497
|
+
const fileContent = fs.readFileSync(filePath, 'utf-8');
|
|
498
|
+
const viewRegex = /^\s*@(view|aggregateView)\(['"].*['"]\)/m;
|
|
499
|
+
return viewRegex.test(fileContent);
|
|
500
|
+
}
|
|
501
|
+
exports.containsHosannaView = containsHosannaView;
|
|
502
|
+
function getTargetStructClassName(targetViewName) {
|
|
503
|
+
if (!targetViewName) {
|
|
504
|
+
return 'ViewStruct';
|
|
505
|
+
}
|
|
506
|
+
if (targetViewName.endsWith('State')) {
|
|
507
|
+
targetViewName = targetViewName.replace('State', 'ViewStruct');
|
|
508
|
+
}
|
|
509
|
+
return `${targetViewName}ViewStruct`;
|
|
510
|
+
}
|
|
511
|
+
function getViewNameForState(viewStateName, sourceFile, imports) {
|
|
512
|
+
const importPath = imports.get(viewStateName);
|
|
513
|
+
if (!importPath)
|
|
514
|
+
return undefined;
|
|
515
|
+
const resolvedPath = path.resolve(path.dirname(sourceFile.fileName), importPath + '.ts');
|
|
516
|
+
if (!fs.existsSync(resolvedPath))
|
|
517
|
+
return undefined;
|
|
518
|
+
const fileContent = fs.readFileSync(resolvedPath, 'utf-8');
|
|
519
|
+
const importedSourceFile = ts.createSourceFile(resolvedPath, fileContent, ts.ScriptTarget.Latest, true);
|
|
520
|
+
const metadata = getViewMetadata(importedSourceFile);
|
|
521
|
+
return metadata === null || metadata === void 0 ? void 0 : metadata.viewName;
|
|
522
|
+
}
|
|
523
|
+
function addImportsForExtendedViewStruct(typeName, viewName, sourceFile, imports, requiredImportsMap, usedImports) {
|
|
524
|
+
const importPath = imports.get(typeName);
|
|
525
|
+
if (!importPath)
|
|
526
|
+
return;
|
|
527
|
+
const resolvedPath = path.resolve(path.dirname(sourceFile.fileName), importPath + '.ts');
|
|
528
|
+
if (!fs.existsSync(resolvedPath))
|
|
529
|
+
return;
|
|
530
|
+
const generatedStructImportPath = `./${path.join(path.dirname(importPath), `${path.basename(importPath)}-generated-struct`)}`;
|
|
531
|
+
// Add the necessary imports
|
|
532
|
+
requiredImportsMap.set(`${viewName}State`, importPath);
|
|
533
|
+
imports.set(`${viewName}State`, importPath);
|
|
534
|
+
usedImports.add(`${viewName}State`);
|
|
535
|
+
imports.set(`${viewName}ViewStruct`, generatedStructImportPath);
|
|
536
|
+
requiredImportsMap.set(`${viewName}ViewStruct`, generatedStructImportPath);
|
|
537
|
+
usedImports.add(`${viewName}ViewStruct`);
|
|
538
|
+
imports.set(`_${viewName}ViewStruct`, generatedStructImportPath);
|
|
539
|
+
requiredImportsMap.set(`_${viewName}ViewStruct`, generatedStructImportPath);
|
|
540
|
+
usedImports.add(`_${viewName}ViewStruct`);
|
|
541
|
+
}
|
|
542
|
+
function getTypeName(typeNode) {
|
|
543
|
+
if (ts.isTypeReferenceNode(typeNode)) {
|
|
544
|
+
return typeNode.typeName.getText().replace(/<.*>/, '');
|
|
545
|
+
}
|
|
546
|
+
else if (ts.isIdentifier(typeNode)) {
|
|
547
|
+
return typeNode.text;
|
|
548
|
+
}
|
|
549
|
+
else {
|
|
550
|
+
return typeNode.getText().replace(/<.*>/, '');
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
//# sourceMappingURL=struct-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,CAAC,IAAI,CAAC;KACtB;SAAM;QACL,OAAO,QAAQ,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;KAC/C;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generateView(rootFolder: string): Promise<void>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.generateView = void 0;
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
const path = __importStar(require("path"));
|
|
29
|
+
const readline = __importStar(require("readline"));
|
|
30
|
+
const rl = readline.createInterface({
|
|
31
|
+
input: process.stdin,
|
|
32
|
+
output: process.stdout
|
|
33
|
+
});
|
|
34
|
+
function prompt(question) {
|
|
35
|
+
return new Promise((resolve) => rl.question(question, resolve));
|
|
36
|
+
}
|
|
37
|
+
async function generateView(rootFolder) {
|
|
38
|
+
const viewName = await prompt('Enter view name (e.g. Button): ');
|
|
39
|
+
const targetFolder = await prompt('Enter target folder relative to rootFolder (e.g. views/controls): ');
|
|
40
|
+
const viewClassName = `${viewName}View`;
|
|
41
|
+
const stateInterfaceName = `${viewName}State`;
|
|
42
|
+
const viewFilePath = path.resolve(rootFolder, targetFolder, `${viewName}.ts`);
|
|
43
|
+
const relativePathToLib = path.relative(path.dirname(viewFilePath), path.resolve(rootFolder, 'hosanna-ui/lib'));
|
|
44
|
+
const relativePathToViewsLib = path.relative(path.dirname(viewFilePath), path.resolve(rootFolder, 'hosanna-ui/views/lib'));
|
|
45
|
+
const content = `
|
|
46
|
+
import { layoutState, state, view } from '${relativePathToLib}/decorators';
|
|
47
|
+
import { BaseView } from '${relativePathToViewsLib}/BaseView';
|
|
48
|
+
import { ViewState, ViewStruct } from '${relativePathToViewsLib}/view-api';
|
|
49
|
+
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
51
|
+
export interface ${stateInterfaceName} extends ViewState {
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@view('${viewName}')
|
|
55
|
+
export class ${viewClassName} extends BaseView<${stateInterfaceName}> {
|
|
56
|
+
|
|
57
|
+
protected override getViews(): ViewStruct<ViewState>[] {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
const outputDir = path.dirname(viewFilePath);
|
|
63
|
+
if (!fs.existsSync(outputDir)) {
|
|
64
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
65
|
+
}
|
|
66
|
+
fs.writeFileSync(viewFilePath, content.trim());
|
|
67
|
+
console.log(`View ${viewName} created at ${viewFilePath}`);
|
|
68
|
+
rl.close(); // Close the readline interface here
|
|
69
|
+
}
|
|
70
|
+
exports.generateView = generateView;
|
|
71
|
+
//# sourceMappingURL=view-generator.js.map
|