@admin-layout/gluestack-ui-mobile 9.0.2-alpha.4 → 9.0.4-alpha.102

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.
Files changed (70) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/lib/components/AuthWrapper.d.ts +4 -1
  3. package/lib/components/AuthWrapper.js +6 -5
  4. package/lib/components/AuthWrapper.js.map +1 -1
  5. package/lib/components/Layout/components/Drawer.js +9 -9
  6. package/lib/components/Layout/components/Drawer.js.map +1 -1
  7. package/lib/components/Layout/components/Header.js +28 -15
  8. package/lib/components/Layout/components/Header.js.map +1 -1
  9. package/lib/components/Layout/components/SettingDrawer/LayoutButton.js +14 -6
  10. package/lib/components/Layout/components/SettingDrawer/LayoutButton.js.map +1 -1
  11. package/lib/components/Layout/components/SettingDrawer/SettingDrawer.d.ts +1 -1
  12. package/lib/components/Layout/components/SettingDrawer/SettingDrawer.js +55 -15
  13. package/lib/components/Layout/components/SettingDrawer/SettingDrawer.js.map +1 -1
  14. package/lib/components/Layout/components/SettingDrawer/ThemeColorButton.js +1 -1
  15. package/lib/components/NavigationComponent.js +11 -2
  16. package/lib/components/NavigationComponent.js.map +1 -1
  17. package/lib/components/WithConfiguration.d.ts +18 -0
  18. package/lib/components/WithConfiguration.js +42 -0
  19. package/lib/components/WithConfiguration.js.map +1 -0
  20. package/lib/components/WithPermission.d.ts +31 -0
  21. package/lib/components/WithPermission.js +53 -0
  22. package/lib/components/WithPermission.js.map +1 -0
  23. package/lib/components/WithPolicy.d.ts +13 -0
  24. package/lib/components/WithPolicy.js +18 -0
  25. package/lib/components/WithPolicy.js.map +1 -0
  26. package/lib/components/index.d.ts +5 -0
  27. package/lib/components/index.js +5 -0
  28. package/lib/components/index.js.map +1 -1
  29. package/lib/components/usePermissionAutoFetch.d.ts +75 -0
  30. package/lib/components/usePermissionAutoFetch.js +63 -0
  31. package/lib/components/usePermissionAutoFetch.js.map +1 -0
  32. package/lib/components/useSetting.d.ts +25 -0
  33. package/lib/components/useSetting.js +87 -0
  34. package/lib/components/useSetting.js.map +1 -0
  35. package/lib/components/with-interactions-lifecycle-managed.d.ts +3 -3
  36. package/lib/components/with-interactions-lifecycle-managed.js +23 -15
  37. package/lib/components/with-interactions-lifecycle-managed.js.map +1 -1
  38. package/lib/containers/layout/BasicLayout.d.ts +3 -3
  39. package/lib/containers/layout/DrawerBottomNavigationConfig.d.ts +393 -88
  40. package/lib/containers/layout/DrawerConfig.d.ts +266 -60
  41. package/lib/containers/layout/module.js +2 -2
  42. package/lib/containers/layout/module.js.map +1 -1
  43. package/lib/redux/settings.d.ts +8 -8
  44. package/lib/utils/ThemeColor.js +11 -1
  45. package/lib/utils/ThemeColor.js.map +1 -1
  46. package/lib/utils/generateMobileNavigations.d.ts +4 -10
  47. package/lib/utils/generateMobileNavigations.js +720 -310
  48. package/lib/utils/generateMobileNavigations.js.map +1 -1
  49. package/package.json +7 -7
  50. package/src/components/AuthWrapper.tsx +30 -17
  51. package/src/components/Layout/components/Drawer.tsx +19 -20
  52. package/src/components/Layout/components/Header.tsx +154 -93
  53. package/src/components/Layout/components/SettingDrawer/LayoutButton.tsx +27 -13
  54. package/src/components/Layout/components/SettingDrawer/SettingDrawer.tsx +151 -48
  55. package/src/components/Layout/components/SettingDrawer/ThemeColorButton.tsx +2 -2
  56. package/src/components/NavigationComponent.tsx +9 -2
  57. package/src/components/WithConfiguration.tsx +74 -0
  58. package/src/components/WithPermission.tsx +81 -0
  59. package/src/components/WithPolicy.tsx +32 -0
  60. package/src/components/index.ts +6 -1
  61. package/src/components/usePermissionAutoFetch.tsx +78 -0
  62. package/src/components/useSetting.tsx +137 -0
  63. package/src/components/with-interactions-lifecycle-managed.tsx +62 -26
  64. package/src/containers/layout/module.ts +2 -2
  65. package/src/utils/ThemeColor.ts +11 -1
  66. package/src/utils/generateMobileNavigations.ts +780 -290
  67. package/lib/components/Layout/components/util.d.ts +0 -1
  68. package/lib/components/Layout/components/util.js +0 -15
  69. package/lib/components/Layout/components/util.js.map +0 -1
  70. package/src/components/Layout/components/util.ts +0 -14
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _GenerateMobileNavigations_instances, _GenerateMobileNavigations_layoutSettings, _GenerateMobileNavigations_appDirPath, _GenerateMobileNavigations_modules, _GenerateMobileNavigations_initialRouteName, _GenerateMobileNavigations_unauthenticatedComponentPath, _GenerateMobileNavigations_customTabBarPath, _GenerateMobileNavigations_customDrawerPath, _GenerateMobileNavigations_customHeaderPath, _GenerateMobileNavigations_readJsonFile, _GenerateMobileNavigations_getLayoutConfig, _GenerateMobileNavigations_execPromise, _GenerateMobileNavigations_renameFile, _GenerateMobileNavigations_writeFile, _GenerateMobileNavigations_makeDir, _GenerateMobileNavigations_getModulesRouteConfig, _GenerateMobileNavigations_resolveImportPath, _GenerateMobileNavigations_generateAppRoutesJson, _GenerateMobileNavigations_generateImportStatements, _GenerateMobileNavigations_generateModulesTsFile, _GenerateMobileNavigations_generateStackNavigations, _GenerateMobileNavigations_generateDrawerNavigationsFile, _GenerateMobileNavigations_generateDrawerNavigations, _GenerateMobileNavigations_generateBottomTabNavigationsFile, _GenerateMobileNavigations_generateBottomTabNavigations, _GenerateMobileNavigations_generateBottomTabDrawerNavigations, _GenerateMobileNavigations_generateAppNavigationFile, _GenerateMobileNavigations_setLayoutAndGenerateNavigation;
12
+ var _GenerateMobileNavigations_instances, _GenerateMobileNavigations_configFileData, _GenerateMobileNavigations_configFilePath, _GenerateMobileNavigations_appPath, _GenerateMobileNavigations_isDefaultPackagePathMobileRoot, _GenerateMobileNavigations_mobileStackPath, _GenerateMobileNavigations_appDirPath, _GenerateMobileNavigations_modules, _GenerateMobileNavigations_initialRouteNameRootStack, _GenerateMobileNavigations_initialRouteName, _GenerateMobileNavigations_unauthenticatedComponentPath, _GenerateMobileNavigations_customTabBarPath, _GenerateMobileNavigations_customDrawerPath, _GenerateMobileNavigations_customHeaderPath, _GenerateMobileNavigations_i18Options, _GenerateMobileNavigations_iconsRepository, _GenerateMobileNavigations_readConfigFile, _GenerateMobileNavigations_readJsonFile, _GenerateMobileNavigations_getLayoutConfig, _GenerateMobileNavigations_execPromise, _GenerateMobileNavigations_renameFile, _GenerateMobileNavigations_writeFile, _GenerateMobileNavigations_makeDir, _GenerateMobileNavigations_getModulesRouteConfig, _GenerateMobileNavigations_resolveImportPath, _GenerateMobileNavigations_generateAppRoutesJson, _GenerateMobileNavigations_generateImportStatements, _GenerateMobileNavigations_generateModulesTsFile, _GenerateMobileNavigations_generateMainRoutesFile, _GenerateMobileNavigations_generateMainRoutes, _GenerateMobileNavigations_generateAppFile, _GenerateMobileNavigations_generateApp, _GenerateMobileNavigations_generateStackNavigations, _GenerateMobileNavigations_generateDrawerNavigationsFile, _GenerateMobileNavigations_generateDrawerNavigations, _GenerateMobileNavigations_generateBottomTabNavigationsFile, _GenerateMobileNavigations_generateBottomTabNavigations, _GenerateMobileNavigations_generateBottomTabDrawerNavigations, _GenerateMobileNavigations_generateAppNavigationFile, _GenerateMobileNavigations_generateSelectiveIconsFile, _GenerateMobileNavigations_setLayoutAndGenerateNavigation, _GenerateMobileNavigations_performCopyOperations, _GenerateMobileNavigations_deleteDirectoryRecursive, _GenerateMobileNavigations_createAppDirectory;
13
13
  import * as fs from 'fs';
14
14
  import path from 'path';
15
15
  import prettier from 'prettier';
@@ -17,19 +17,22 @@ import { fileURLToPath } from 'url';
17
17
  import { createRequire } from 'module';
18
18
  import { exec as execCallback } from 'child_process';
19
19
  import { getSortedNavigations } from '@common-stack/client-react/lib/route/react-navigation/get-navigation-utils.js';
20
+ import { performCopyOperations } from '@common-stack/rollup-vite-utils/lib/preStartup/configLoader/configLoader.js';
20
21
  import { getReplacedRouteConfig } from './getReplacedRouteConfig.js';
21
22
  const require = createRequire(import.meta.url);
22
23
  const __filename = fileURLToPath(import.meta.url);
23
24
  const __dirname = path.dirname(__filename);
24
25
  const configFilePath = path.join(__dirname, '../layout.json');
25
- const appNavigationFileName = 'navigation.tsx';
26
+ const appNavigationFileName = 'navigation.js';
26
27
  const mainRoutesFileName = 'main_routes.json';
27
28
  const modulesFileName = 'modules.ts';
28
- const stacksDirPath = 'stack/index.tsx';
29
- const drawerFilePath = 'drawer/index.tsx';
30
- const hostDrawerFilePath = 'host_drawer/index.tsx';
31
- const bottomFilePath = 'bottom/index.tsx';
32
- const hostBottomFilePath = 'host_bottom/index.tsx';
29
+ const stacksDirPath = 'stack/index.js';
30
+ const drawerFilePath = 'drawer/index.js';
31
+ const hostDrawerFilePath = 'host_drawer/index.js';
32
+ const bottomFilePath = 'bottom/index.js';
33
+ const hostBottomFilePath = 'host_bottom/index.js';
34
+ const mainRoutesJsFileName = 'mainRoutes.js';
35
+ const mainAppFileName = 'index.js';
33
36
  export const readJsonFile = (filePath) => {
34
37
  return new Promise((resolve, reject) => {
35
38
  fs.readFile(filePath, 'utf8', (err, data) => {
@@ -66,30 +69,50 @@ export const getLayoutConfig = async () => {
66
69
  return layoutConfigFileData;
67
70
  };
68
71
  export class GenerateMobileNavigations {
69
- constructor({ appDirPath, modules, initialRouteName = '', unauthenticatedComponentPath = null, customTabBarPath = null, customDrawerPath = null, customHeaderPath = null, }) {
72
+ constructor({ configFilePath }) {
70
73
  _GenerateMobileNavigations_instances.add(this);
71
- _GenerateMobileNavigations_layoutSettings.set(this, process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null);
74
+ _GenerateMobileNavigations_configFileData.set(this, {});
75
+ _GenerateMobileNavigations_configFilePath.set(this, void 0);
76
+ _GenerateMobileNavigations_appPath.set(this, 'app');
77
+ _GenerateMobileNavigations_isDefaultPackagePathMobileRoot.set(this, void 0);
78
+ _GenerateMobileNavigations_mobileStackPath.set(this, 'mobile-stack-react');
79
+ //#layoutSettings: any = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
72
80
  _GenerateMobileNavigations_appDirPath.set(this, void 0);
73
81
  _GenerateMobileNavigations_modules.set(this, void 0);
82
+ _GenerateMobileNavigations_initialRouteNameRootStack.set(this, void 0);
74
83
  _GenerateMobileNavigations_initialRouteName.set(this, void 0);
75
84
  _GenerateMobileNavigations_unauthenticatedComponentPath.set(this, void 0);
76
85
  _GenerateMobileNavigations_customTabBarPath.set(this, void 0);
77
86
  _GenerateMobileNavigations_customDrawerPath.set(this, void 0);
78
87
  _GenerateMobileNavigations_customHeaderPath.set(this, void 0);
79
- __classPrivateFieldSet(this, _GenerateMobileNavigations_layoutSettings, process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null, "f");
80
- __classPrivateFieldSet(this, _GenerateMobileNavigations_appDirPath, appDirPath, "f");
81
- __classPrivateFieldSet(this, _GenerateMobileNavigations_modules, modules, "f");
82
- __classPrivateFieldSet(this, _GenerateMobileNavigations_initialRouteName, initialRouteName, "f");
83
- __classPrivateFieldSet(this, _GenerateMobileNavigations_unauthenticatedComponentPath, unauthenticatedComponentPath, "f");
84
- __classPrivateFieldSet(this, _GenerateMobileNavigations_customTabBarPath, customTabBarPath, "f");
85
- __classPrivateFieldSet(this, _GenerateMobileNavigations_customDrawerPath, customDrawerPath, "f");
86
- __classPrivateFieldSet(this, _GenerateMobileNavigations_customHeaderPath, customHeaderPath, "f");
88
+ _GenerateMobileNavigations_i18Options.set(this, void 0);
89
+ _GenerateMobileNavigations_iconsRepository.set(this, void 0);
90
+ __classPrivateFieldSet(this, _GenerateMobileNavigations_configFilePath, configFilePath, "f");
91
+ const config = __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_readConfigFile).call(this, configFilePath);
92
+ __classPrivateFieldSet(this, _GenerateMobileNavigations_configFileData, config, "f");
93
+ // this.#layoutSettings = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
94
+ __classPrivateFieldSet(this, _GenerateMobileNavigations_appPath, config?.commonPaths?.appPath ?? 'app', "f");
95
+ __classPrivateFieldSet(this, _GenerateMobileNavigations_isDefaultPackagePathMobileRoot, config?.mobileConfig?.isDefaultPackagePathMobileRoot ?? false, "f");
96
+ __classPrivateFieldSet(this, _GenerateMobileNavigations_iconsRepository, config?.iconsRepository ?? '', "f");
97
+ __classPrivateFieldSet(this, _GenerateMobileNavigations_mobileStackPath, config?.mobileStackPath ?? 'mobile-stack-react', "f");
98
+ __classPrivateFieldSet(this, _GenerateMobileNavigations_appDirPath, path.join(path.dirname(configFilePath), __classPrivateFieldGet(this, _GenerateMobileNavigations_appPath, "f")), "f");
99
+ __classPrivateFieldSet(this, _GenerateMobileNavigations_modules, config?.modules ?? [], "f");
100
+ __classPrivateFieldSet(this, _GenerateMobileNavigations_initialRouteName, config?.mobileConfig?.initialRouteName ?? '', "f");
101
+ __classPrivateFieldSet(this, _GenerateMobileNavigations_initialRouteNameRootStack, config?.mobileConfig?.initialRouteNameRootStack ?? 'MainStack', "f");
102
+ __classPrivateFieldSet(this, _GenerateMobileNavigations_unauthenticatedComponentPath, config?.mobileConfig?.unauthenticatedComponentPath ?? '', "f");
103
+ __classPrivateFieldSet(this, _GenerateMobileNavigations_customTabBarPath, config?.mobileConfig?.customTabBarPath ?? '', "f");
104
+ __classPrivateFieldSet(this, _GenerateMobileNavigations_customDrawerPath, config?.mobileConfig?.customDrawerPath ?? '', "f");
105
+ __classPrivateFieldSet(this, _GenerateMobileNavigations_customHeaderPath, config?.mobileConfig?.customHeaderPath ?? '', "f");
106
+ __classPrivateFieldSet(this, _GenerateMobileNavigations_i18Options, config?.i18n ?? {}, "f");
87
107
  }
88
108
  async generateAppNavigations() {
89
- return __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_setLayoutAndGenerateNavigation).call(this);
109
+ return __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_createAppDirectory).call(this);
90
110
  }
91
111
  }
92
- _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNavigations_appDirPath = new WeakMap(), _GenerateMobileNavigations_modules = new WeakMap(), _GenerateMobileNavigations_initialRouteName = new WeakMap(), _GenerateMobileNavigations_unauthenticatedComponentPath = new WeakMap(), _GenerateMobileNavigations_customTabBarPath = new WeakMap(), _GenerateMobileNavigations_customDrawerPath = new WeakMap(), _GenerateMobileNavigations_customHeaderPath = new WeakMap(), _GenerateMobileNavigations_instances = new WeakSet(), _GenerateMobileNavigations_readJsonFile = async function _GenerateMobileNavigations_readJsonFile(filePath) {
112
+ _GenerateMobileNavigations_configFileData = new WeakMap(), _GenerateMobileNavigations_configFilePath = new WeakMap(), _GenerateMobileNavigations_appPath = new WeakMap(), _GenerateMobileNavigations_isDefaultPackagePathMobileRoot = new WeakMap(), _GenerateMobileNavigations_mobileStackPath = new WeakMap(), _GenerateMobileNavigations_appDirPath = new WeakMap(), _GenerateMobileNavigations_modules = new WeakMap(), _GenerateMobileNavigations_initialRouteNameRootStack = new WeakMap(), _GenerateMobileNavigations_initialRouteName = new WeakMap(), _GenerateMobileNavigations_unauthenticatedComponentPath = new WeakMap(), _GenerateMobileNavigations_customTabBarPath = new WeakMap(), _GenerateMobileNavigations_customDrawerPath = new WeakMap(), _GenerateMobileNavigations_customHeaderPath = new WeakMap(), _GenerateMobileNavigations_i18Options = new WeakMap(), _GenerateMobileNavigations_iconsRepository = new WeakMap(), _GenerateMobileNavigations_instances = new WeakSet(), _GenerateMobileNavigations_readConfigFile = function _GenerateMobileNavigations_readConfigFile(configFilePath) {
113
+ const jsonData = fs.readFileSync(configFilePath, 'utf-8');
114
+ return JSON.parse(jsonData);
115
+ }, _GenerateMobileNavigations_readJsonFile = async function _GenerateMobileNavigations_readJsonFile(filePath) {
93
116
  return readJsonFile(filePath);
94
117
  }, _GenerateMobileNavigations_getLayoutConfig = async function _GenerateMobileNavigations_getLayoutConfig() {
95
118
  return getLayoutConfig();
@@ -133,10 +156,17 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
133
156
  });
134
157
  }, _GenerateMobileNavigations_getModulesRouteConfig = async function _GenerateMobileNavigations_getModulesRouteConfig({ modules }) {
135
158
  const allFilteredRoutes = [];
159
+ let pkgFile;
136
160
  for (const pkg of modules) {
137
- const pkgPath = require.resolve(pkg);
138
- const pkgDirPath = path.dirname(pkgPath);
139
- const pkgFile = path.join(pkgDirPath, 'routes.json');
161
+ if (__classPrivateFieldGet(this, _GenerateMobileNavigations_isDefaultPackagePathMobileRoot, "f")) {
162
+ const pkgRootFilePath = path.join(path.join(path.dirname(__classPrivateFieldGet(this, _GenerateMobileNavigations_configFilePath, "f")), 'node_modules/lib'), pkg);
163
+ pkgFile = path.join(pkgRootFilePath, 'routes.json');
164
+ }
165
+ else {
166
+ const pkgPath = require.resolve(pkg);
167
+ const pkgDirPath = path.dirname(pkgPath);
168
+ pkgFile = path.join(pkgDirPath, 'routes.json');
169
+ }
140
170
  if (fs.existsSync(pkgFile)) {
141
171
  const fileModuleJSON = await readJsonFile(pkgFile);
142
172
  if (fileModuleJSON) {
@@ -166,14 +196,16 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
166
196
  }
167
197
  }
168
198
  return value;
169
- }, _GenerateMobileNavigations_generateAppRoutesJson = async function _GenerateMobileNavigations_generateAppRoutesJson({ appDirPath }) {
170
- const parentDirPath = path.dirname(appDirPath);
199
+ }, _GenerateMobileNavigations_generateAppRoutesJson = async function _GenerateMobileNavigations_generateAppRoutesJson() {
200
+ const appDirPath = __classPrivateFieldGet(this, _GenerateMobileNavigations_appDirPath, "f");
201
+ const parentDirPath = path.dirname(__classPrivateFieldGet(this, _GenerateMobileNavigations_configFileData, "f")?.mobileConfig?.computeFilePath ?? __classPrivateFieldGet(this, _GenerateMobileNavigations_configFilePath, "f"));
171
202
  const parentDirName = path.basename(parentDirPath);
172
203
  const appDirName = path.basename(appDirPath);
173
204
  // const tsFile = 'src/compute.ts';
174
205
  // const outputDir = 'src/app';
175
206
  const tsFile = `${parentDirName}/compute.ts`;
176
- const outputDir = `${parentDirName}/${appDirName}`;
207
+ // const outputDir = `${parentDirName}/${appDirName}`;
208
+ const outputDir = `${appDirName}`;
177
209
  const tscCommand = `tsc ${tsFile} --outDir ${outputDir} --target es6 --module esnext --jsx react --allowSyntheticDefaultImports true --moduleResolution node --esModuleInterop true --forceConsistentCasingInFileNames true --skipLibCheck true`;
178
210
  const mainRoutesJsFile = path.join(appDirPath, '/compute.js');
179
211
  const mainRoutesMjsFile = path.join(appDirPath, '/compute.mjs');
@@ -189,17 +221,13 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
189
221
  const noWhitespaceJsData = noCommentsData.replace(/\s+/g, '');
190
222
  if (noWhitespaceJsData?.length == 0) {
191
223
  const outPutDirName = path.dirname(outputFile);
192
- const isDirCreated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_makeDir).call(this, outPutDirName);
193
- if (isDirCreated) {
194
- const writeFileResponse = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, outputFile, JSON.stringify(allFilteredRoutes));
195
- if (writeFileResponse) {
196
- return true;
197
- }
198
- else
199
- return false;
224
+ try {
225
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_makeDir).call(this, outPutDirName);
226
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, outputFile, JSON.stringify(allFilteredRoutes));
227
+ }
228
+ catch (error) {
229
+ console.log('Error directory/file create', error);
200
230
  }
201
- else
202
- return false;
203
231
  }
204
232
  else {
205
233
  const newFilePath = mainRoutesJsFile.replace('.js', '.mjs');
@@ -219,56 +247,45 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
219
247
  return { [routConfig.path]: routConfig };
220
248
  }) ?? [];
221
249
  allFilteredRoutes.push(...newRoutes);
222
- const writeFileResponse = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, outputFile, JSON.stringify(allFilteredRoutes, null, 2));
223
- if (writeFileResponse) {
224
- fs.unlinkSync(mainRoutesMjsFile);
225
- return true;
250
+ try {
251
+ const writeFileResponse = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, outputFile, JSON.stringify(allFilteredRoutes, null, 2));
252
+ if (writeFileResponse)
253
+ fs.unlinkSync(mainRoutesMjsFile);
254
+ }
255
+ catch (error) {
256
+ console.log('Error creating main routes file', error);
226
257
  }
227
- else
228
- return false;
229
258
  }
230
259
  }
231
- else
232
- return false;
233
260
  }
234
- else
235
- return false;
236
261
  }
237
262
  }
238
263
  else {
239
264
  const outPutDirName = path.dirname(outputFile);
240
- const isDirCreated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_makeDir).call(this, outPutDirName);
241
- if (isDirCreated) {
242
- const writeFileResponse = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, outputFile, JSON.stringify(allFilteredRoutes));
243
- if (writeFileResponse) {
244
- return true;
245
- }
246
- else
247
- return false;
265
+ try {
266
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_makeDir).call(this, outPutDirName);
267
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, outputFile, JSON.stringify(allFilteredRoutes));
268
+ }
269
+ catch (error) {
270
+ console.log('Error creating main routes file', error);
248
271
  }
249
- else
250
- return false;
251
272
  }
252
273
  // return true;
253
274
  }
254
275
  catch (error) {
255
276
  console.error(`exec error: ${error.message}`);
256
277
  const outPutDirName = path.dirname(outputFile);
257
- const isDirCreated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_makeDir).call(this, outPutDirName);
258
- if (isDirCreated) {
259
- const writeFileResponse = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, outputFile, JSON.stringify(allFilteredRoutes));
260
- if (writeFileResponse) {
261
- return true;
262
- }
263
- else
264
- return false;
278
+ try {
279
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_makeDir).call(this, outPutDirName);
280
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, outputFile, JSON.stringify(allFilteredRoutes));
281
+ }
282
+ catch (error) {
283
+ console.log('Error creating main routes file', error);
265
284
  }
266
- else
267
- return false;
268
285
  }
269
286
  }, _GenerateMobileNavigations_generateImportStatements = async function _GenerateMobileNavigations_generateImportStatements({ modules, initialRouteName }) {
270
287
  try {
271
- const layoutSettings = __classPrivateFieldGet(this, _GenerateMobileNavigations_layoutSettings, "f");
288
+ const layoutSettings = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
272
289
  const layoutConfigFileData = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getLayoutConfig).call(this);
273
290
  const hostRouteConfig = layoutConfigFileData['host-bottom'];
274
291
  const hostRouteKey = Object.keys(hostRouteConfig)[1];
@@ -378,10 +395,215 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
378
395
  return false;
379
396
  }
380
397
  return false;
398
+ }, _GenerateMobileNavigations_generateMainRoutesFile = async function _GenerateMobileNavigations_generateMainRoutesFile({ initialRouteName, i18Options }) {
399
+ try {
400
+ const layoutSettings = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
401
+ const layoutConfigFileData = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getLayoutConfig).call(this);
402
+ const hostRouteConfig = layoutConfigFileData['host-bottom'];
403
+ const hostRouteKey = Object.keys(hostRouteConfig)[1];
404
+ const hostLayout = hostRouteConfig[hostRouteKey];
405
+ let importStatements = '';
406
+ importStatements += `import React from 'react';\n`;
407
+ importStatements += `import { InversifyProvider, PluginArea } from '@common-stack/client-react';\n`;
408
+ importStatements += `import { useSelector, useDispatch } from 'react-redux';\n`;
409
+ importStatements += `import { CHANGE_SETTINGS_ACTION } from '@admin-layout/client';\n`;
410
+ importStatements += `import {layoutRouteConfig,getReplacedRouteConfig,ErrorBoundary,NavigationContainerComponent,ApplicationErrorHandler,Box,Spinner,} from '@admin-layout/gluestack-ui-mobile';\n`;
411
+ importStatements += `import mainRouteConfig from './main_routes.json';\n`;
412
+ importStatements += `import features from './mobile-stack-react/modules.js';\n`;
413
+ importStatements += `import AppNavigations from './navigation';\n`;
414
+ importStatements += `import {loadContext} from './mobile-stack-react/load-context.mobile.js';\n`;
415
+ let classStructure = `
416
+
417
+ const mainAppRoutes = mainRouteConfig || [];
418
+
419
+ const appRoutes = [...[mainAppRoutes],features?.routeConfig];
420
+
421
+ const featureRouteConfig = appRoutes?.flat(1)??features?.routeConfig;
422
+ features.routeConfig = featureRouteConfig;
423
+ let appConfiguredRoutes = features?.getConfiguredRoutes2("/");
424
+
425
+ const DefaultProvider = ({children}) => <>{children}</>
426
+
427
+ export function MainRoute({ container,externalProvider: ExternalProvider = DefaultProvider,externalProviderProps={},linking = {} }){
428
+ const dispatch = useDispatch();
429
+ const defaultSettings = useSelector((state) => state.settings);
430
+ const initialRouteName = '${initialRouteName}';
431
+ const layoutSettings = ${JSON.stringify({ ...layoutSettings, hostLayout: hostLayout.key })}
432
+ const [mainFeatures, setMainFeatures] = React.useState(null);
433
+
434
+ React.useEffect(() => {
435
+ setDefalutSettings();
436
+ }, []);
437
+
438
+
439
+ const setDefalutSettings = React.useCallback(()=>{
440
+ const config = {
441
+ ...defaultSettings,
442
+ ...layoutSettings,
443
+ };
444
+ dispatch({
445
+ type: CHANGE_SETTINGS_ACTION,
446
+ payload: config,
447
+ });
448
+ },[]);
449
+
450
+ React.useEffect(() => {
451
+ if (defaultSettings) {
452
+ const settingObj = { ...defaultSettings };
453
+ const layoutType = settingObj.layout;
454
+ const {replacedConfiguredRouteConfig} = getReplacedRouteConfig({
455
+ layoutType: layoutType,
456
+ routeConfig: appRoutes,
457
+ layoutConfigData: layoutRouteConfig,
458
+ initialRouteName,
459
+ });
460
+ if(replacedConfiguredRouteConfig){
461
+ const moduleRouteConfigObject = Object.assign({}, ...replacedConfiguredRouteConfig?.flat(1)??[]);
462
+ const replacedRouteConfig = Object.fromEntries(Object.entries(moduleRouteConfigObject));
463
+ const appReplacedRouteConfig = replacedRouteConfig ? Object.keys(replacedRouteConfig)?.map((k)=>({[k]:replacedRouteConfig[k]})) : [];
464
+
465
+ if (appReplacedRouteConfig) {
466
+ const hostRouteConfig = appReplacedRouteConfig.filter(item => {
467
+ return Object.keys(item).some(key =>
468
+ key === "/" ||
469
+ (key.startsWith("//" + layoutSettings.hostLayout) || key.startsWith("//:orgName/" + layoutSettings.hostLayout))
470
+ );
471
+ })?.filter((value) => Object.keys(value).length !== 0) ?? [];
472
+
473
+
474
+ const layoutRouteConfig = appReplacedRouteConfig.filter(item => {
475
+ return Object.keys(item).some(key =>
476
+ key === "/" ||
477
+ (!key.startsWith("//" + layoutSettings.hostLayout) && !key.startsWith("//:orgName/" + layoutSettings.hostLayout))
478
+ );
479
+ })?.filter((value) => Object.keys(value).length !== 0) ?? [];
480
+
481
+
482
+ // const hostRouteConfig = appReplacedRouteConfig?.map((obj)=> Object.fromEntries(Object.entries(obj)?.filter(([key,val])=>key === '/' || key.startsWith('//'+layoutSettings.hostLayout))))?.filter(value => Object.keys(value).length !== 0)??[];
483
+ // const layoutRouteConfig = appReplacedRouteConfig?.map((obj)=> Object.fromEntries(Object.entries(obj)?.filter(([key,val])=>key === '/' || !key.startsWith('//'+layoutSettings.hostLayout))))?.filter(value => Object.keys(value).length !== 0)??[];
484
+ const featureRouteConfig = defaultSettings?.layout == 'host-bottom' ? hostRouteConfig:layoutRouteConfig;
485
+ features.routeConfig = featureRouteConfig;
486
+ setMainFeatures(features);
487
+ }
488
+ }
489
+ }
490
+ }, [defaultSettings]);
491
+
492
+ const loadingComponent = () => <Box flex={1}>{<Spinner />}</Box>;
493
+
494
+ if (!mainFeatures || mainFeatures?.routeConfig?.length == 0) return loadingComponent();
495
+
496
+ const plugins = mainFeatures?.getComponentFillPlugins();
497
+ const configuredRoutes = mainFeatures?.getConfiguredRoutes2('/');
498
+ appConfiguredRoutes = configuredRoutes;
499
+
500
+ return (
501
+ <InversifyProvider container={container} modules={mainFeatures}>
502
+ {mainFeatures?.getWrappedRoot(
503
+ <ErrorBoundary>
504
+ <NavigationContainerComponent configurableRoutes={configuredRoutes} independent={true} linking={linking}>
505
+ <ExternalProvider {...externalProviderProps}>
506
+ <AppNavigations />
507
+ </ExternalProvider>
508
+ <PluginArea />
509
+ <ApplicationErrorHandler plugins={plugins} />
510
+ </NavigationContainerComponent>
511
+ </ErrorBoundary>,
512
+ )}
513
+ </InversifyProvider>
514
+ );
515
+ }
516
+
517
+ export { loadContext,appConfiguredRoutes };
518
+
519
+ export default features;
520
+ `.replace(/,(\s*)$/, ''); // Removes trailing comma
521
+ // Use Prettier to format the code
522
+ classStructure = prettier.format(classStructure, { parser: 'babel' });
523
+ const appFeatures = importStatements + '\n' + classStructure;
524
+ return { appFeatures };
525
+ }
526
+ catch (err) {
527
+ console.error('Error:', err);
528
+ }
529
+ }, _GenerateMobileNavigations_generateMainRoutes = async function _GenerateMobileNavigations_generateMainRoutes({ appDirPath, i18Options, initialRouteName }) {
530
+ const mainRoutesFile = path.join(appDirPath, `/${mainRoutesJsFileName}`);
531
+ const imports = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateMainRoutesFile).call(this, { initialRouteName, i18Options });
532
+ const { appFeatures } = imports;
533
+ try {
534
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, mainRoutesFile, appFeatures);
535
+ }
536
+ catch (err) {
537
+ console.error('Error generating main routes:', err);
538
+ }
539
+ }, _GenerateMobileNavigations_generateAppFile = async function _GenerateMobileNavigations_generateAppFile({ initialRouteName, i18Options }) {
540
+ try {
541
+ let importStatements = '';
542
+ importStatements += `import 'reflect-metadata';\n`;
543
+ importStatements += `import React from 'react';\n`;
544
+ importStatements += `import { SlotFillProvider } from '@common-stack/components-pro';\n`;
545
+ importStatements += `import { ApolloProvider } from '@apollo/client';\n`;
546
+ importStatements += `import { Provider } from 'react-redux';\n`;
547
+ importStatements += `import { PersistGate } from 'redux-persist/integration/react';\n`;
548
+ importStatements += `import { SafeAreaProvider } from 'react-native-safe-area-context';\n`;
549
+ importStatements += `import {GluestackUIProvider,config,i18next,reactI18Next} from '@admin-layout/gluestack-ui-mobile';\n`;
550
+ importStatements += `import { enableScreens } from 'react-native-screens';\n`;
551
+ importStatements += `import {MainRoute,loadContext,appConfiguredRoutes} from './mainRoutes.js'\n`;
552
+ let classStructure = `
553
+ enableScreens(true);
554
+ const { I18nextProvider } = reactI18Next;
555
+ i18next.options ={...i18next?.options??{},...${JSON.stringify(i18Options)}};
556
+
557
+ const DefaultProvider = ({children}) => <>{children}</>
558
+
559
+ function App({externalProvider = DefaultProvider,externalProviderProps={},linking = {}}){
560
+ const {store,persistor,container,apolloClient: client} = loadContext();
561
+
562
+
563
+ return (
564
+ <SlotFillProvider>
565
+ <ApolloProvider client={client}>
566
+ <Provider store={store}>
567
+ <PersistGate persistor={persistor}>
568
+ <I18nextProvider i18n={i18next}>
569
+ <SafeAreaProvider>
570
+ <GluestackUIProvider config={config}>
571
+ <MainRoute container={container} externalProvider={externalProvider} linking={linking} externalProviderProps={externalProviderProps} />
572
+ </GluestackUIProvider>
573
+ </SafeAreaProvider>
574
+ </I18nextProvider>
575
+ </PersistGate>
576
+ </Provider>
577
+ </ApolloProvider>
578
+ </SlotFillProvider>
579
+ );
580
+ }
581
+
582
+ export const configuredRoutes = appConfiguredRoutes;
583
+ export default App;
584
+ `.replace(/,(\s*)$/, ''); // Removes trailing comma
585
+ // Use Prettier to format the code
586
+ classStructure = prettier.format(classStructure, { parser: 'babel' });
587
+ const appFeatures = importStatements + '\n' + classStructure;
588
+ return { appFeatures };
589
+ }
590
+ catch (err) {
591
+ console.error('Error:', err);
592
+ }
593
+ }, _GenerateMobileNavigations_generateApp = async function _GenerateMobileNavigations_generateApp({ appDirPath, i18Options, initialRouteName }) {
594
+ const mainRoutesFile = path.join(appDirPath, `/${mainAppFileName}`);
595
+ const imports = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateAppFile).call(this, { initialRouteName, i18Options });
596
+ const { appFeatures } = imports;
597
+ try {
598
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, mainRoutesFile, appFeatures);
599
+ }
600
+ catch (err) {
601
+ console.error('Error generating app:', err);
602
+ }
381
603
  }, _GenerateMobileNavigations_generateStackNavigations = async function _GenerateMobileNavigations_generateStackNavigations({ appDirPath, modules, initialRouteName, unauthenticatedComponentPath }) {
382
604
  const mainRoutes = path.join(appDirPath, `/${mainRoutesFileName}`);
383
605
  const stackDirPath = path.join(appDirPath, `/${stacksDirPath}`);
384
- const layoutSettings = __classPrivateFieldGet(this, _GenerateMobileNavigations_layoutSettings, "f");
606
+ const layoutSettings = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
385
607
  const layoutConfigFileData = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getLayoutConfig).call(this);
386
608
  const layoutType = layoutSettings?.layout || 'bottom';
387
609
  const layoutRouteConfig = layoutConfigFileData[layoutType];
@@ -422,7 +644,7 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
422
644
  let customUnauthenticatedComponentNames = '';
423
645
  const regex = /\.(tsx|ts|jsx|js)$/i;
424
646
  importStatements += `import * as React from 'react';\n`;
425
- importStatements += `import {AuthWrapper} from '@admin-layout/gluestack-ui-mobile';\n`;
647
+ importStatements += `import AuthWrapper from '@admin-layout/gluestack-ui-mobile/lib/components/AuthWrapper.js';\n`;
426
648
  if (unauthenticatedComponentPath)
427
649
  importStatements += `import UnauthenticatedComponent from '${unauthenticatedComponentPath}';\n`;
428
650
  for (const pkg of stackRouteConfig) {
@@ -456,11 +678,16 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
456
678
  options={{...${options},...{${pkgRouteConfig?.customHeader &&
457
679
  Object.keys(pkgRouteConfig.customHeader)?.length &&
458
680
  customHeaderComponentPath
459
- ? `header: (props: any) => <${customHeaderName} {...props} {...${JSON.stringify(pkgRouteConfig?.customHeader?.props ?? '')}} />`
681
+ ? `header: (props) => <${customHeaderName} {...props} {...${JSON.stringify(pkgRouteConfig?.customHeader?.props ?? '')}} />`
460
682
  : ''}}}}
461
- >{(props:any) => <AuthWrapper
683
+ >{(props) => <AuthWrapper
462
684
  auth={${pkgRouteConfig?.props?.initialParams?.auth ?? false}}
463
- component={<Component${moduleNumber} {...props} />}
685
+ authority={${JSON.stringify(pkgRouteConfig?.authority) ?? null}}
686
+ extraPermissions={${JSON.stringify(pkgRouteConfig?.extraPermissions) ?? null}}
687
+ component={<Component${moduleNumber} {...props}
688
+ permissions={${JSON.stringify(pkgRouteConfig?.authority) ?? null}}
689
+ extraPermissions={${JSON.stringify(pkgRouteConfig?.extraPermissions) ?? null}}
690
+ />}
464
691
  ${pkgRouteConfig?.unauthenticatedComponent && customUnauthenticatedComponentPath
465
692
  ? `unauthenticatedComponent={<${customUnauthenticatedComponentName}/>}`
466
693
  : unauthenticatedComponentPath
@@ -498,26 +725,21 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
498
725
  });
499
726
  }
500
727
  moduleContent += `</Stack.Group>`;
501
- moduleRender = `export default ({Stack,...rest}:any) => { return (<>${moduleContent}</>)}`;
728
+ moduleRender = `export default ({Stack,...rest}) => { return (<>${moduleContent}</>)}`;
502
729
  }
503
730
  stackNavigator = importStatements + '\n' + moduleRender;
504
- if (stackNavigator) {
505
- let stackNavigation = stackNavigator;
506
- stackNavigation = prettier.format(stackNavigation, { parser: 'babel' });
507
- const stackDirName = path.dirname(stackDirPath);
731
+ let stackNavigation = stackNavigator;
732
+ stackNavigation = prettier.format(stackNavigation, { parser: 'babel' });
733
+ const stackDirName = path.dirname(stackDirPath);
734
+ try {
508
735
  const isDirCreated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_makeDir).call(this, stackDirName);
509
736
  if (isDirCreated) {
510
- const writeFileResponse = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, stackDirPath, stackNavigation);
511
- if (writeFileResponse)
512
- return true;
513
- else
514
- return false;
737
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, stackDirPath, stackNavigation);
515
738
  }
516
- else
517
- return false;
518
739
  }
519
- else
520
- return false;
740
+ catch (error) {
741
+ console.log('Error generating stack navigation', error);
742
+ }
521
743
  }, _GenerateMobileNavigations_generateDrawerNavigationsFile = async function _GenerateMobileNavigations_generateDrawerNavigationsFile({ drawerConfig, unauthenticatedComponentPath, drawerDirPath }) {
522
744
  let moduleNumber = 0;
523
745
  let importStatements = '';
@@ -531,7 +753,8 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
531
753
  let customUnauthenticatedComponentNames = '';
532
754
  const regex = /\.(tsx|ts|jsx|js)$/i;
533
755
  importStatements += `import * as React from 'react';\n`;
534
- importStatements += `import {AuthWrapper} from '@admin-layout/gluestack-ui-mobile';\n`;
756
+ importStatements += `import AuthWrapper from '@admin-layout/gluestack-ui-mobile/lib/components/AuthWrapper.js';\n`;
757
+ importStatements += `import DynamicIcons from '@app/selectiveIcons';\n`;
535
758
  if (unauthenticatedComponentPath)
536
759
  importStatements += `import UnauthenticatedComponent from '${unauthenticatedComponentPath}';\n`;
537
760
  for (const pkgRouteConfig of drawerConfig) {
@@ -565,16 +788,38 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
565
788
  //component={Component${moduleNumber}}
566
789
  initialParams={${JSON.stringify(pkgRouteConfig?.props?.initialParams || {})}}
567
790
  options={{...${options},...{${pkgRouteConfig?.icon && Object.keys(pkgRouteConfig.icon)?.length && pkgRouteConfig?.icon?.name
568
- ? `drawerIcon: ({ color, size }: { color: any,size:any }) => <${pkgRouteConfig?.icon?.name} name="${pkgRouteConfig?.icon?.props?.name ?? 'home'}" size={${pkgRouteConfig?.icon?.props?.size ?? `size`}} color={${pkgRouteConfig?.icon?.props?.color ?? 'color'}} />`
791
+ ? `drawerIcon: ({ color }) => {
792
+ const focused = color === '${pkgRouteConfig?.props?.options?.tabBarActiveTintColor}' ? true : false;
793
+ const SelectedIcon = DynamicIcons('${pkgRouteConfig?.icon?.name}');
794
+ return (<SelectedIcon
795
+ {...{
796
+ ...${JSON.stringify({ ...(pkgRouteConfig?.icon?.props || {}) })},
797
+ ...{
798
+ color:focused ? ${JSON.stringify(pkgRouteConfig?.icon?.props?.color ??
799
+ pkgRouteConfig?.props?.options?.tabBarActiveTintColor) ?? 'black'}
800
+ :${JSON.stringify(pkgRouteConfig?.props?.options?.tabBarInactiveTintColor) ??
801
+ 'grey'},
802
+ stroke:focused ? ${JSON.stringify(pkgRouteConfig?.icon?.props?.color ??
803
+ pkgRouteConfig?.props?.options?.tabBarActiveTintColor) ?? 'black'}
804
+ :${JSON.stringify(pkgRouteConfig?.props?.options?.tabBarInactiveTintColor) ??
805
+ 'grey'}
806
+ }
807
+ }}
808
+ />)},`
569
809
  : ''}
570
810
  ${pkgRouteConfig?.customHeader &&
571
811
  Object.keys(pkgRouteConfig.customHeader)?.length &&
572
812
  customHeaderComponentPath
573
- ? `header: (props: any) => <${customHeaderName} {...props} {...${JSON.stringify(pkgRouteConfig?.customHeader?.props ?? '')}} />`
813
+ ? `header: (props) => <${customHeaderName} {...props} {...${JSON.stringify(pkgRouteConfig?.customHeader?.props ?? '')}} />`
574
814
  : ''}}}}
575
- >{(props:any) => <AuthWrapper
815
+ >{(props) => <AuthWrapper
576
816
  auth={${pkgRouteConfig?.props?.initialParams?.auth ?? false}}
577
- component={<Component${moduleNumber} {...props} />}
817
+ authority={${JSON.stringify(pkgRouteConfig?.authority) ?? null}}
818
+ extraPermissions={${JSON.stringify(pkgRouteConfig?.extraPermissions) ?? null}}
819
+ component={<Component${moduleNumber} {...props}
820
+ permissions={${JSON.stringify(pkgRouteConfig?.authority) ?? null}}
821
+ extraPermissions={${JSON.stringify(pkgRouteConfig?.extraPermissions) ?? null}}
822
+ />}
578
823
  ${pkgRouteConfig?.unauthenticatedComponent && customUnauthenticatedComponentPath
579
824
  ? `unauthenticatedComponent={<${customUnauthenticatedComponentName}/>}`
580
825
  : unauthenticatedComponentPath
@@ -591,10 +836,10 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
591
836
  : ''}
592
837
  />}</Drawer.Screen>`;
593
838
  }
594
- if (icons && icons?.length) {
595
- const uniqueIcons = [...new Set(icons.split(','))].join(',');
596
- importStatements += `import { ${uniqueIcons} } from '@expo/vector-icons';\n`;
597
- }
839
+ // if (icons && icons?.length) {
840
+ // const uniqueIcons = [...new Set(icons.split(','))].join(',');
841
+ // importStatements += `import Icons from '@expo/vector-icons';\n`;
842
+ // }
598
843
  if (customHeaderPaths && customHeaderPaths?.length) {
599
844
  const uniqueHeaderNames = [...new Set(customHeaderNames.split(','))]?.filter((str) => str?.length);
600
845
  const uniqueHeaderPaths = [...new Set(customHeaderPaths.split(','))]?.filter((str) => str?.length);
@@ -615,30 +860,26 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
615
860
  importStatements += `import ${impUnauthenticatedName} from '${unCompPath}';\n`;
616
861
  });
617
862
  }
618
- moduleRender = `export default ({Drawer,...rest}:any) => { return (<>${moduleContent}</>)}`;
863
+ moduleRender = `export default ({Drawer,...rest}) => { return (<>${moduleContent}</>)}`;
619
864
  moduleNavigation = importStatements + '\n' + moduleRender;
620
865
  const drawerNavigator = moduleNavigation;
621
- if (drawerNavigator) {
622
- let drawerNavigation = drawerNavigator;
623
- drawerNavigation = prettier.format(drawerNavigation, { parser: 'babel' });
624
- const drawerDirName = path.dirname(drawerDirPath);
866
+ let drawerNavigation = drawerNavigator;
867
+ drawerNavigation = prettier.format(drawerNavigation, { parser: 'babel' });
868
+ const drawerDirName = path.dirname(drawerDirPath);
869
+ try {
625
870
  const isDirCreated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_makeDir).call(this, drawerDirName);
626
871
  if (isDirCreated) {
627
- const writeFileResponse = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, drawerDirPath, drawerNavigation);
628
- if (writeFileResponse)
629
- return true;
630
- else
631
- return false;
872
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, drawerDirPath, drawerNavigation);
632
873
  }
633
- else
634
- return false;
635
874
  }
636
- return false;
875
+ catch (error) {
876
+ console.log('Error generating drawer navigation file', error);
877
+ }
637
878
  }, _GenerateMobileNavigations_generateDrawerNavigations = async function _GenerateMobileNavigations_generateDrawerNavigations({ appDirPath, modules, initialRouteName, unauthenticatedComponentPath }) {
638
879
  const mainRoutes = path.join(appDirPath, `/${mainRoutesFileName}`);
639
880
  const drawerDirPath = path.join(appDirPath, `/${drawerFilePath}`);
640
881
  const hostDirPath = path.join(appDirPath, `/${hostDrawerFilePath}`);
641
- const layoutSettings = __classPrivateFieldGet(this, _GenerateMobileNavigations_layoutSettings, "f");
882
+ const layoutSettings = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
642
883
  const layoutConfigFileData = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getLayoutConfig).call(this);
643
884
  const layoutType = 'side';
644
885
  const layoutRouteConfig = layoutConfigFileData[layoutType];
@@ -676,36 +917,34 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
676
917
  return -1;
677
918
  return a?.props?.options?.priority - b?.props?.options?.priority;
678
919
  }) ?? [];
679
- if (layoutSettings?.layout == 'side') {
680
- if (drawerConfig) {
681
- const drawerNavigation = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateDrawerNavigationsFile).call(this, {
682
- drawerConfig: drawerConfig,
683
- unauthenticatedComponentPath,
684
- drawerDirPath: drawerDirPath,
685
- });
686
- if (drawerNavigation)
920
+ try {
921
+ if (layoutSettings?.layout == 'side') {
922
+ if (drawerConfig) {
687
923
  await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateDrawerNavigationsFile).call(this, {
688
- drawerConfig: hostDrawerConfig,
924
+ drawerConfig: drawerConfig,
689
925
  unauthenticatedComponentPath,
690
- drawerDirPath: hostDirPath,
926
+ drawerDirPath: drawerDirPath,
691
927
  });
692
- return true;
693
- }
694
- else {
695
- if (hostDrawerConfig) {
696
- const isDrawerGenerated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateDrawerNavigationsFile).call(this, {
928
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateDrawerNavigationsFile).call(this, {
697
929
  drawerConfig: hostDrawerConfig,
698
930
  unauthenticatedComponentPath,
699
931
  drawerDirPath: hostDirPath,
700
932
  });
701
- return isDrawerGenerated;
702
933
  }
703
- else
704
- return false;
934
+ else {
935
+ if (hostDrawerConfig) {
936
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateDrawerNavigationsFile).call(this, {
937
+ drawerConfig: hostDrawerConfig,
938
+ unauthenticatedComponentPath,
939
+ drawerDirPath: hostDirPath,
940
+ });
941
+ }
942
+ }
705
943
  }
706
944
  }
707
- else
708
- return false;
945
+ catch (error) {
946
+ console.log('Error generating drawer navigation', error);
947
+ }
709
948
  }, _GenerateMobileNavigations_generateBottomTabNavigationsFile = async function _GenerateMobileNavigations_generateBottomTabNavigationsFile({ bottomTabConfig, unauthenticatedComponentPath, bottomDirPath, mixLayout = null, }) {
710
949
  let moduleNumber = 0;
711
950
  let importStatements = '';
@@ -719,7 +958,8 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
719
958
  let customUnauthenticatedComponentNames = '';
720
959
  const regex = /\.(tsx|ts|jsx|js)$/i;
721
960
  importStatements += `import * as React from 'react';\n`;
722
- importStatements += `import {AuthWrapper} from '@admin-layout/gluestack-ui-mobile';\n`;
961
+ importStatements += `import AuthWrapper from '@admin-layout/gluestack-ui-mobile/lib/components/AuthWrapper.js';\n`;
962
+ importStatements += `import DynamicIcons from '@app/selectiveIcons';\n`;
723
963
  if (unauthenticatedComponentPath)
724
964
  importStatements += `import UnauthenticatedComponent from '${unauthenticatedComponentPath}';\n`;
725
965
  for (const pkgRouteConfig of bottomTabConfig) {
@@ -745,10 +985,12 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
745
985
  customUnauthenticatedComponentName = `UnauthenticatedComponent${moduleNumber}`;
746
986
  customUnauthenticatedComponentNames += `${customUnauthenticatedComponentName},`;
747
987
  }
748
- const options = JSON.stringify({
749
- ...pkgRouteConfig?.props?.options,
750
- headerShown: mixLayout ? false : pkgRouteConfig?.props?.options?.headerShown,
751
- } || { headerShown: mixLayout ? false : true });
988
+ const options = JSON.stringify(pkgRouteConfig?.props?.options
989
+ ? {
990
+ ...pkgRouteConfig.props.options,
991
+ headerShown: mixLayout ? false : pkgRouteConfig.props.options.headerShown,
992
+ }
993
+ : { headerShown: mixLayout ? false : true });
752
994
  importStatements += `import Component${moduleNumber} from '${pkgRouteConfig.componentPath}';\n`;
753
995
  moduleContent += `<Tab.Screen
754
996
  key="${pkgRouteConfig.key}"
@@ -756,17 +998,40 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
756
998
  //component={Component${moduleNumber}}
757
999
  initialParams={${JSON.stringify(pkgRouteConfig?.props?.initialParams || {})}}
758
1000
  options={{...${options},...{${pkgRouteConfig?.icon && Object.keys(pkgRouteConfig.icon)?.length && pkgRouteConfig?.icon?.name
759
- ? `tabBarIcon: ({ color }: { color: any }) => <${pkgRouteConfig?.icon?.name} name="${pkgRouteConfig?.icon?.props?.name ?? 'home'}" size={${pkgRouteConfig?.icon?.props?.size ?? 24}} color={${pkgRouteConfig?.icon?.props?.color ?? 'color'}} />`
1001
+ ? `tabBarIcon: ({ color }) => {
1002
+ const focused = color === '${pkgRouteConfig?.props?.options?.tabBarActiveTintColor}' ? true : false;
1003
+ const SelectedIcon = DynamicIcons('${pkgRouteConfig?.icon?.name}');
1004
+ return (<SelectedIcon
1005
+ {...{
1006
+ ...${JSON.stringify({ ...(pkgRouteConfig?.icon?.props || {}) })},
1007
+ ...{
1008
+ color:focused ? ${JSON.stringify(pkgRouteConfig?.icon?.props?.color ??
1009
+ pkgRouteConfig?.props?.options?.tabBarActiveTintColor) ?? 'black'}
1010
+ :${JSON.stringify(pkgRouteConfig?.props?.options?.tabBarInactiveTintColor) ??
1011
+ 'grey'},
1012
+ stroke:focused ? ${JSON.stringify(pkgRouteConfig?.icon?.props?.color ??
1013
+ pkgRouteConfig?.props?.options?.tabBarActiveTintColor) ?? 'black'}
1014
+ :${JSON.stringify(pkgRouteConfig?.props?.options?.tabBarInactiveTintColor) ??
1015
+ 'grey'}
1016
+ }
1017
+ }}
1018
+
1019
+ />)}`
760
1020
  : ''}
761
1021
  ${pkgRouteConfig?.customHeader &&
762
1022
  Object.keys(pkgRouteConfig.customHeader)?.length &&
763
1023
  customHeaderComponentPath
764
- ? `,header: (props: any) => <${customHeaderName} {...props} {...${JSON.stringify(pkgRouteConfig?.customHeader?.props ?? '')}} />`
1024
+ ? `,header: (props) => <${customHeaderName} {...props} {...${JSON.stringify(pkgRouteConfig?.customHeader?.props ?? '')}} />`
765
1025
  : ''}
766
1026
  }}}
767
- >{(props:any) => <AuthWrapper
1027
+ >{(props) => <AuthWrapper
768
1028
  auth={${pkgRouteConfig?.props?.initialParams?.auth ?? false}}
769
- component={<Component${moduleNumber} {...props} />}
1029
+ authority={${JSON.stringify(pkgRouteConfig?.authority) ?? null}}
1030
+ extraPermissions={${JSON.stringify(pkgRouteConfig?.extraPermissions) ?? null}}
1031
+ component={<Component${moduleNumber} {...props}
1032
+ permissions={${JSON.stringify(pkgRouteConfig?.authority) ?? null}}
1033
+ extraPermissions={${JSON.stringify(pkgRouteConfig?.extraPermissions) ?? null}}
1034
+ />}
770
1035
  ${pkgRouteConfig?.unauthenticatedComponent && customUnauthenticatedComponentPath
771
1036
  ? `unauthenticatedComponent={<${customUnauthenticatedComponentName}/>}`
772
1037
  : unauthenticatedComponentPath
@@ -784,10 +1049,10 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
784
1049
  />}
785
1050
  </Tab.Screen>`;
786
1051
  }
787
- if (icons && icons?.length) {
788
- const uniqueIcons = [...new Set(icons.split(','))].join(',');
789
- importStatements += `import { ${uniqueIcons} } from '@expo/vector-icons';\n`;
790
- }
1052
+ // if (icons && icons?.length) {
1053
+ // const uniqueIcons = [...new Set(icons.split(','))].join(',');
1054
+ // importStatements += `import { ${uniqueIcons} } from '@expo/vector-icons';\n`;
1055
+ // }
791
1056
  if (customHeaderPaths && customHeaderPaths?.length) {
792
1057
  const uniqueHeaderNames = [...new Set(customHeaderNames.split(','))]?.filter((str) => str?.length);
793
1058
  const uniqueHeaderPaths = [...new Set(customHeaderPaths.split(','))]?.filter((str) => str?.length);
@@ -808,30 +1073,26 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
808
1073
  importStatements += `import ${impUnauthenticatedName} from '${unCompPath}';\n`;
809
1074
  });
810
1075
  }
811
- moduleRender = `export default ({Tab,...rest}:any) => { return (<>${moduleContent}</>)}`;
1076
+ moduleRender = `export default ({Tab,...rest}) => { return (<>${moduleContent}</>)}`;
812
1077
  moduleNavigation = importStatements + '\n' + moduleRender;
813
1078
  const bottomTabNavigator = moduleNavigation;
814
- if (bottomTabNavigator) {
815
- let bottomTabNavigation = bottomTabNavigator;
816
- bottomTabNavigation = prettier.format(bottomTabNavigation, { parser: 'babel' });
817
- const bottomDirName = path.dirname(bottomDirPath);
1079
+ let bottomTabNavigation = bottomTabNavigator;
1080
+ bottomTabNavigation = prettier.format(bottomTabNavigation, { parser: 'babel' });
1081
+ const bottomDirName = path.dirname(bottomDirPath);
1082
+ try {
818
1083
  const isDirCreated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_makeDir).call(this, bottomDirName);
819
1084
  if (isDirCreated) {
820
- const writeFileResponse = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, bottomDirPath, bottomTabNavigation);
821
- if (writeFileResponse)
822
- return true;
823
- else
824
- return false;
1085
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, bottomDirPath, bottomTabNavigation);
825
1086
  }
826
- else
827
- return false;
828
1087
  }
829
- return false;
1088
+ catch (error) {
1089
+ console.log('Error generating bottom tab navigation file', error);
1090
+ }
830
1091
  }, _GenerateMobileNavigations_generateBottomTabNavigations = async function _GenerateMobileNavigations_generateBottomTabNavigations({ appDirPath, modules, initialRouteName, unauthenticatedComponentPath }) {
831
1092
  const mainRoutes = path.join(appDirPath, `/${mainRoutesFileName}`);
832
1093
  const bottomDirPath = path.join(appDirPath, `/${bottomFilePath}`);
833
1094
  const hostBottomDirPath = path.join(appDirPath, `/${hostBottomFilePath}`);
834
- const layoutSettings = __classPrivateFieldGet(this, _GenerateMobileNavigations_layoutSettings, "f");
1095
+ const layoutSettings = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
835
1096
  const layoutConfigFileData = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getLayoutConfig).call(this);
836
1097
  const layoutType = layoutSettings?.layout ?? 'bottom';
837
1098
  const layoutRouteConfig = layoutConfigFileData[layoutType];
@@ -871,46 +1132,44 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
871
1132
  return -1;
872
1133
  return a?.props?.options?.priority - b?.props?.options?.priority;
873
1134
  }) ?? [];
874
- if (layoutType == 'bottom' || layoutType == 'mixSide') {
875
- if (bottomTabConfig) {
876
- const drawerNavigation = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabNavigationsFile).call(this, {
877
- bottomTabConfig: bottomTabConfig,
878
- unauthenticatedComponentPath,
879
- bottomDirPath: bottomDirPath,
880
- mixLayout,
881
- });
882
- if (drawerNavigation)
1135
+ try {
1136
+ if (layoutType == 'bottom' || layoutType == 'mixSide') {
1137
+ if (bottomTabConfig) {
883
1138
  await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabNavigationsFile).call(this, {
884
- bottomTabConfig: hostBottomTabConfig,
1139
+ bottomTabConfig: bottomTabConfig,
885
1140
  unauthenticatedComponentPath,
886
- bottomDirPath: hostBottomDirPath,
1141
+ bottomDirPath: bottomDirPath,
887
1142
  mixLayout,
888
1143
  });
889
- return true;
890
- }
891
- else {
892
- if (hostBottomTabConfig) {
893
- const isHostGenerated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabNavigationsFile).call(this, {
1144
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabNavigationsFile).call(this, {
894
1145
  bottomTabConfig: hostBottomTabConfig,
895
1146
  unauthenticatedComponentPath,
896
1147
  bottomDirPath: hostBottomDirPath,
897
1148
  mixLayout,
898
1149
  });
899
- return isHostGenerated;
900
1150
  }
901
- else
902
- return false;
1151
+ else {
1152
+ if (hostBottomTabConfig) {
1153
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabNavigationsFile).call(this, {
1154
+ bottomTabConfig: hostBottomTabConfig,
1155
+ unauthenticatedComponentPath,
1156
+ bottomDirPath: hostBottomDirPath,
1157
+ mixLayout,
1158
+ });
1159
+ }
1160
+ }
903
1161
  }
904
1162
  }
905
- else
906
- return false;
1163
+ catch (error) {
1164
+ console.log('Error generating bottom tab navigation', error);
1165
+ }
907
1166
  }, _GenerateMobileNavigations_generateBottomTabDrawerNavigations = async function _GenerateMobileNavigations_generateBottomTabDrawerNavigations({ appDirPath, modules, initialRouteName, unauthenticatedComponentPath }) {
908
1167
  const mainRoutes = path.join(appDirPath, `/${mainRoutesFileName}`);
909
1168
  const bottomDirPath = path.join(appDirPath, `/${bottomFilePath}`);
910
1169
  const hostBottomDirPath = path.join(appDirPath, `/${hostBottomFilePath}`);
911
1170
  const drawerDirPath = path.join(appDirPath, `/${drawerFilePath}`);
912
1171
  const hostDirPath = path.join(appDirPath, `/${hostDrawerFilePath}`);
913
- const layoutSettings = __classPrivateFieldGet(this, _GenerateMobileNavigations_layoutSettings, "f");
1172
+ const layoutSettings = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
914
1173
  const layoutConfigFileData = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getLayoutConfig).call(this);
915
1174
  const layoutType = layoutSettings?.layout ?? 'bottom';
916
1175
  const layoutRouteConfig = layoutConfigFileData[layoutType];
@@ -973,52 +1232,55 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
973
1232
  return a?.props?.options?.priority - b?.props?.options?.priority;
974
1233
  }) ?? [];
975
1234
  if (bottomTabConfig) {
976
- const drawerNavigation = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabNavigationsFile).call(this, {
977
- bottomTabConfig: bottomTabConfig,
978
- unauthenticatedComponentPath,
979
- bottomDirPath: bottomDirPath,
980
- mixLayout,
981
- });
982
- if (drawerNavigation)
1235
+ try {
983
1236
  await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabNavigationsFile).call(this, {
984
- bottomTabConfig: hostBottomTabConfig,
1237
+ bottomTabConfig: bottomTabConfig,
985
1238
  unauthenticatedComponentPath,
986
- bottomDirPath: hostBottomDirPath,
1239
+ bottomDirPath: bottomDirPath,
987
1240
  mixLayout,
988
1241
  });
989
- if (drawerConfig) {
990
- const drawerNavigation = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateDrawerNavigationsFile).call(this, {
991
- drawerConfig: drawerConfig,
1242
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabNavigationsFile).call(this, {
1243
+ bottomTabConfig: hostBottomTabConfig,
992
1244
  unauthenticatedComponentPath,
993
- drawerDirPath: drawerDirPath,
1245
+ bottomDirPath: hostBottomDirPath,
1246
+ mixLayout,
994
1247
  });
995
- if (drawerNavigation)
1248
+ if (drawerConfig) {
1249
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateDrawerNavigationsFile).call(this, {
1250
+ drawerConfig: drawerConfig,
1251
+ unauthenticatedComponentPath,
1252
+ drawerDirPath: drawerDirPath,
1253
+ });
996
1254
  await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateDrawerNavigationsFile).call(this, {
997
1255
  drawerConfig: hostDrawerConfig,
998
1256
  unauthenticatedComponentPath,
999
1257
  drawerDirPath: hostDirPath,
1000
1258
  });
1001
- return true;
1259
+ }
1260
+ }
1261
+ catch (error) {
1262
+ console.log('Error in generating drawer bottom tab navigation', error);
1002
1263
  }
1003
- else
1004
- return true;
1005
1264
  }
1006
- else
1007
- return false;
1008
1265
  }, _GenerateMobileNavigations_generateAppNavigationFile = async function _GenerateMobileNavigations_generateAppNavigationFile({ appDirPath, customTabBarPath, customDrawerPath, customHeaderPath }) {
1009
1266
  const navigationDirPath = path.join(appDirPath, `/${appNavigationFileName}`);
1010
- const layoutSettings = __classPrivateFieldGet(this, _GenerateMobileNavigations_layoutSettings, "f");
1267
+ const layoutSettings = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
1011
1268
  const layoutConfigFileData = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getLayoutConfig).call(this);
1012
1269
  const layoutType = layoutSettings?.layout || 'bottom';
1013
1270
  const layoutRouteConfig = layoutConfigFileData[layoutType];
1014
1271
  const layoutRouteKey = Object.keys(layoutRouteConfig)[1];
1015
1272
  const appLayout = layoutRouteConfig[layoutRouteKey];
1016
- const initialRouteName = layoutType === 'mixSide'
1017
- ? appLayout?.[appLayout?.key]?.props?.initialRouteName ?? 'MainStack.Layout.Home'
1018
- : appLayout?.props?.initialRouteName || 'MainStack.Home';
1273
+ const initialRouteNameRootStack = __classPrivateFieldGet(this, _GenerateMobileNavigations_initialRouteNameRootStack, "f");
1274
+ const layoutInitialRouteName = __classPrivateFieldGet(this, _GenerateMobileNavigations_initialRouteName, "f");
1275
+ const initialRouteName = layoutInitialRouteName
1276
+ ? layoutInitialRouteName
1277
+ : layoutType === 'mixSide'
1278
+ ? appLayout?.[appLayout?.key]?.props?.initialRouteName ?? 'MainStack.Layout.Home'
1279
+ : appLayout?.props?.initialRouteName || 'MainStack.Home';
1019
1280
  const isShowTabs = layoutType === 'mixSide' || layoutType === 'bottom' ? true : false;
1020
1281
  const isShowDefalutHeader = layoutType === 'mixSide' ? true : false;
1021
1282
  const defaultHeaderProps = {
1283
+ ...(layoutSettings || {}),
1022
1284
  showToggle: layoutSettings?.topLeftToggle || false,
1023
1285
  right: layoutSettings?.topRightSettingToggle || false,
1024
1286
  };
@@ -1052,8 +1314,8 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
1052
1314
  const Drawer = createDrawerNavigator();
1053
1315
  `;
1054
1316
  rootComponent += `
1055
- const RootComponent = (props:any) => {
1056
- const settings = useSelector((state: any) => state.settings);
1317
+ const RootComponent = (props) => {
1318
+ const settings = useSelector((state) => state.settings);
1057
1319
  const defaultHeaderProps = ${JSON.stringify(defaultHeaderProps || {})};
1058
1320
  return (
1059
1321
  <Drawer.Navigator
@@ -1061,13 +1323,15 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
1061
1323
  //screenOptions={${JSON.stringify(screenOptions)}}
1062
1324
  screenOptions={({ route }) => ({ ...${JSON.stringify(screenOptions)} ,...{
1063
1325
  ${customHeaderPath
1064
- ? `header: (props:any) => {
1326
+ ? `header: (props) => {
1065
1327
  const title = getHeaderTitle(props.options, props.route.name);
1066
1328
  return <CustomHeader {...defaultHeaderProps} {...props} title={title} style={props.options.headerStyle} />;
1067
1329
  }`
1068
1330
  : ''}
1069
1331
  }})}
1070
- ${customDrawerPath ? 'drawerContent={(props:any) => <CustomDrawerContent {...props} />}' : ''}
1332
+ ${customDrawerPath
1333
+ ? 'drawerContent={(props) => <CustomDrawerContent {...props} {...defaultHeaderProps || {}} />}'
1334
+ : ''}
1071
1335
  >
1072
1336
  {settings?.layout == 'host-bottom' ? hostDrawerNavigations({ Drawer }) : drawerNavigations({ Drawer })}
1073
1337
  </Drawer.Navigator>
@@ -1091,23 +1355,23 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
1091
1355
  const Tab = createBottomTabNavigator();
1092
1356
  `;
1093
1357
  rootComponent += `
1094
- const RootComponent = (props:any) => {
1095
- const settings = useSelector((state: any) => state.settings);
1358
+ const RootComponent = (props) => {
1359
+ const settings = useSelector((state) => state.settings);
1096
1360
  const initialRouteName = ${JSON.stringify(initialRouteName)};
1097
1361
  let defaultScreenOptions = ${JSON.stringify(screenOptionsTab)};
1098
1362
  const defaultHeaderProps = ${JSON.stringify(defaultHeaderProps || {})};
1099
- const defaultHeader = {${isShowDefalutHeader ? `header:(props:any)=><Header {...defaultHeaderProps} {...props} />` : ''}};
1363
+ const defaultHeader = {${isShowDefalutHeader ? `header:(props)=><Header {...defaultHeaderProps} {...props} />` : ''}};
1100
1364
  return (
1101
1365
  <Tab.Navigator
1102
1366
  initialRouteName={initialRouteName}
1103
- screenOptions={(props:any)=>({...props,...defaultScreenOptions,...{${customHeaderPath
1104
- ? `header: (props:any) => {
1367
+ screenOptions={(props)=>({...props,...defaultScreenOptions,...{${customHeaderPath
1368
+ ? `header: (props) => {
1105
1369
  const title = getHeaderTitle(props.options, props.route.name);
1106
1370
  return <CustomHeader {...defaultHeaderProps} {...props} title={title} style={props.options.headerStyle} />;
1107
1371
  }`
1108
1372
  : ''}}})}
1109
1373
  ${customTabBarPath
1110
- ? 'tabBar={(props:any) => <CustomTabBar key={props?.key??"customTabBarKey"} {...props} />}'
1374
+ ? 'tabBar={(props) => <CustomTabBar key={props?.key??"customTabBarKey"} {...props} />}'
1111
1375
  : ''}
1112
1376
  >
1113
1377
  {settings?.layout == 'host-bottom' ? hostBottomNavigations({ Tab }) : bottomNavigations({Tab})}
@@ -1140,30 +1404,30 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
1140
1404
  `;
1141
1405
  rootComponent += `
1142
1406
  const TabNavigator = () => {
1143
- const settings = useSelector((state: any) => state.settings);
1407
+ const settings = useSelector((state) => state.settings);
1144
1408
  const initialRouteName = ${JSON.stringify(initialRouteName)};
1145
1409
  let defaultScreenOptions = ${JSON.stringify(screenOptionsTab)};
1146
1410
  const defaultHeaderProps = ${JSON.stringify(defaultHeaderProps || {})};
1147
- const defaultHeader = {${isShowDefalutHeader ? `header:(props:any)=><Header {...defaultHeaderProps} {...props} />` : ''}};
1411
+ const defaultHeader = {${isShowDefalutHeader ? `header:(props)=><Header {...defaultHeaderProps} {...props} />` : ''}};
1148
1412
 
1149
1413
  return (
1150
1414
  <Tab.Navigator
1151
1415
  initialRouteName={initialRouteName}
1152
- screenOptions={(props:any)=>({...props,...defaultScreenOptions,...{headerShown: false,header:()=>null},})}
1416
+ screenOptions={(props)=>({...props,...defaultScreenOptions,...{headerShown: false,header:()=>null},})}
1153
1417
  ${customTabBarPath
1154
- ? 'tabBar={(props:any) => <CustomTabBar key={props?.key??"customTabBarKey"} {...props} />}'
1418
+ ? 'tabBar={(props) => <CustomTabBar key={props?.key??"customTabBarKey"} {...props} />}'
1155
1419
  : ''}
1156
1420
  >
1157
1421
  {settings?.layout == 'host-bottom' ? hostBottomNavigations({ Tab }) : bottomNavigations({Tab})}
1158
1422
  </Tab.Navigator>
1159
1423
  )
1160
1424
  }
1161
- const RootComponent = (props:any) => {
1425
+ const RootComponent = (props) => {
1162
1426
  const initialRouteName = ${JSON.stringify(initialRouteName)};
1163
- const settings = useSelector((state: any) => state.settings);
1427
+ const settings = useSelector((state) => state.settings);
1164
1428
  let defaultScreenOptions = ${JSON.stringify(screenOptionsTab)};
1165
1429
  const defaultHeaderProps = ${JSON.stringify(defaultHeaderProps || {})};
1166
- const defaultHeader = {${isShowDefalutHeader ? `header:(props:any)=><Header {...defaultHeaderProps} {...props} />` : ''}};
1430
+ const defaultHeader = {${isShowDefalutHeader ? `header:(props)=><Header {...defaultHeaderProps} {...props} />` : ''}};
1167
1431
  return (
1168
1432
  <Drawer.Navigator
1169
1433
  initialRouteName={${JSON.stringify(initialRouteName)}}
@@ -1174,7 +1438,7 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
1174
1438
  : navigationRef?.getCurrentRoute()?.route?.name
1175
1439
  : "Home",
1176
1440
  ${customHeaderPath
1177
- ? `header: (props:any) => {
1441
+ ? `header: (props) => {
1178
1442
  const title = getHeaderTitle(props.options, props.route.name);
1179
1443
  return <CustomHeader {...defaultHeaderProps} {...props} title={title} isMixedLayout={true} style={props.options.headerStyle} />;
1180
1444
  }`
@@ -1182,10 +1446,10 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
1182
1446
 
1183
1447
  }})}
1184
1448
  ${customDrawerPath
1185
- ? 'drawerContent={((props:any)) => <CustomDrawerContent {...props} showDefaultRoutes={true} />}'
1449
+ ? 'drawerContent={((props)) => <CustomDrawerContent {...props} showDefaultRoutes={true} />}'
1186
1450
  : ''}
1187
1451
  >
1188
- <Drawer.Screen name="Layout" options={{title:"Home", drawerIcon: ({ color, size }: { color: any, size: any }) => (
1452
+ <Drawer.Screen name="Layout" options={{title:"Home", drawerIcon: ({ color, size }) => (
1189
1453
  <MaterialIcons name="home" size={24} color={color} />
1190
1454
  ),}}
1191
1455
  component={TabNavigator} />
@@ -1198,7 +1462,7 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
1198
1462
  appComponent += `
1199
1463
  const AppNavigations = () => {
1200
1464
  return (
1201
- <Stack.Navigator initialRouteName="${initialRouteName}">
1465
+ <Stack.Navigator initialRouteName="${initialRouteNameRootStack}">
1202
1466
  <Stack.Screen
1203
1467
  name="MainStack"
1204
1468
  options={{ headerShown: false }}
@@ -1213,11 +1477,108 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
1213
1477
  `;
1214
1478
  appNavigation = importStatements + '\n' + rootComponent + '\n' + appComponent;
1215
1479
  appNavigation = prettier.format(appNavigation, { parser: 'babel' });
1216
- const writeFileResponse = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, navigationDirPath, appNavigation);
1217
- if (writeFileResponse)
1218
- return true;
1219
- else
1220
- return false;
1480
+ try {
1481
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, navigationDirPath, appNavigation);
1482
+ }
1483
+ catch (error) {
1484
+ console.log('Error in generating app navigationfile', error);
1485
+ }
1486
+ }, _GenerateMobileNavigations_generateSelectiveIconsFile = async function _GenerateMobileNavigations_generateSelectiveIconsFile({ appDirPath, modules }) {
1487
+ const mainRoutes = path.join(appDirPath, `/${mainRoutesFileName}`);
1488
+ const modulesRouteConfig = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getModulesRouteConfig).call(this, { modules: modules });
1489
+ const mainRouteConfig = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_readJsonFile).call(this, mainRoutes);
1490
+ const allRoutes = [...[mainRouteConfig ?? []], ...(modulesRouteConfig ?? [])];
1491
+ let iconNames = [];
1492
+ allRoutes?.flat(1)?.forEach((route) => {
1493
+ const key = Object.keys(route)[0];
1494
+ const value = route[key];
1495
+ if (value?.icon && typeof value.icon === 'object') {
1496
+ if (typeof value.icon.name === 'string') {
1497
+ if (!iconNames.includes(value.icon.name))
1498
+ iconNames.push(value.icon.name);
1499
+ }
1500
+ }
1501
+ else if (value?.icon && typeof value.icon === 'string') {
1502
+ if (!iconNames.includes(value.icon))
1503
+ iconNames.push(value.icon);
1504
+ }
1505
+ if (value?.extraIcons && Array.isArray(value.extraIcons) && value?.extraIcons?.length > 0) {
1506
+ value?.extraIcons?.map((icon) => {
1507
+ if (typeof icon === 'string') {
1508
+ if (!iconNames.includes(icon))
1509
+ iconNames.push(icon);
1510
+ }
1511
+ else {
1512
+ console.warn(`Invalid icon type: ${typeof icon}`);
1513
+ }
1514
+ });
1515
+ }
1516
+ else if (value?.extraIcons && typeof value.extraIcons === 'string') {
1517
+ if (!iconNames.includes(value.extraIcons))
1518
+ iconNames.push(value.extraIcons);
1519
+ }
1520
+ });
1521
+ const iconsRepository = __classPrivateFieldGet(this, _GenerateMobileNavigations_iconsRepository, "f");
1522
+ const expoIcons = [
1523
+ 'AntDesign',
1524
+ 'Entypo',
1525
+ 'EvilIcons',
1526
+ 'Feather',
1527
+ 'FontAwesome',
1528
+ 'FontAwesome5',
1529
+ 'Fontisto',
1530
+ 'Foundation',
1531
+ 'Ionicons',
1532
+ 'MaterialCommunityIcons',
1533
+ 'MaterialIcons',
1534
+ 'Octicons',
1535
+ 'SimpleLineIcons',
1536
+ 'Zocial',
1537
+ ];
1538
+ let content = `
1539
+ function __variableDynamicIcon(icon) {
1540
+ switch (icon) {
1541
+ `;
1542
+ iconNames.forEach((name) => {
1543
+ let prefix, iconName;
1544
+ if (name.includes('.')) {
1545
+ [prefix, iconName] = name.split('.');
1546
+ }
1547
+ if (prefix && iconsRepository[prefix]) {
1548
+ const importPath = iconsRepository[prefix].replace('{iconName}', prefix === 'expo' ? iconName : iconName + '.native');
1549
+ // prefix = prefix.charAt(0).toUpperCase() + prefix.slice(1).toLowerCase();
1550
+ content += `
1551
+ case '${prefix + '.' + iconName}':
1552
+ return require('${importPath}')?.default;
1553
+ `;
1554
+ }
1555
+ else {
1556
+ content += `
1557
+ case '${name}':
1558
+ return ${expoIcons.includes(name)
1559
+ ? `require('@expo/vector-icons/${name}.js')?.default`
1560
+ : `require('@expo/vector-icons/FontAwesome.js')?.default;`};
1561
+ `;
1562
+ }
1563
+ });
1564
+ content += `
1565
+ default:
1566
+ console.warn('Sorry, the icon named "', icon, '" could not be found in "@react-icon/all-files" and "@app/icons". Please check again.');
1567
+ return require('@expo/vector-icons/FontAwesome.js')?.default;
1568
+ }
1569
+ }
1570
+ export default function(icon) {
1571
+ return __variableDynamicIcon(icon);
1572
+ }
1573
+ `;
1574
+ const rootPath = process.cwd();
1575
+ const fileName = `selectiveIcons.js`;
1576
+ const newFilePath = path.join(rootPath, 'app', fileName);
1577
+ // Ensure the directory exists
1578
+ if (!fs.existsSync(path.dirname(newFilePath))) {
1579
+ fs.mkdirSync(path.dirname(newFilePath), { recursive: true });
1580
+ }
1581
+ fs.writeFileSync(newFilePath, content, 'utf8');
1221
1582
  }, _GenerateMobileNavigations_setLayoutAndGenerateNavigation = async function _GenerateMobileNavigations_setLayoutAndGenerateNavigation() {
1222
1583
  const appDirPath = __classPrivateFieldGet(this, _GenerateMobileNavigations_appDirPath, "f");
1223
1584
  const modules = __classPrivateFieldGet(this, _GenerateMobileNavigations_modules, "f");
@@ -1226,98 +1587,147 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
1226
1587
  const customTabBarPath = __classPrivateFieldGet(this, _GenerateMobileNavigations_customTabBarPath, "f");
1227
1588
  const customDrawerPath = __classPrivateFieldGet(this, _GenerateMobileNavigations_customDrawerPath, "f");
1228
1589
  const customHeaderPath = __classPrivateFieldGet(this, _GenerateMobileNavigations_customHeaderPath, "f");
1229
- const layoutSettings = __classPrivateFieldGet(this, _GenerateMobileNavigations_layoutSettings, "f");
1590
+ const i18Options = __classPrivateFieldGet(this, _GenerateMobileNavigations_i18Options, "f");
1591
+ const layoutSettings = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
1230
1592
  const layoutConfigFileData = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getLayoutConfig).call(this);
1231
1593
  const layoutType = layoutSettings?.layout || 'bottom';
1232
- const isAppRoutesGenerated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateAppRoutesJson).call(this, { appDirPath });
1233
- if (isAppRoutesGenerated) {
1234
- const isModuleTsFileGenerated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateModulesTsFile).call(this, {
1594
+ try {
1595
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateAppRoutesJson).call(this);
1596
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateSelectiveIconsFile).call(this, { appDirPath, modules });
1597
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateMainRoutes).call(this, {
1598
+ appDirPath,
1599
+ i18Options,
1600
+ initialRouteName,
1601
+ });
1602
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateApp).call(this, {
1603
+ appDirPath,
1604
+ i18Options,
1605
+ initialRouteName,
1606
+ });
1607
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateStackNavigations).call(this, {
1235
1608
  appDirPath,
1236
1609
  modules,
1237
1610
  initialRouteName,
1611
+ unauthenticatedComponentPath,
1238
1612
  });
1239
- if (isModuleTsFileGenerated) {
1240
- const isStackCreated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateStackNavigations).call(this, {
1241
- appDirPath,
1242
- modules,
1243
- initialRouteName,
1244
- unauthenticatedComponentPath,
1245
- });
1246
- if (isStackCreated) {
1247
- if (layoutType == 'side') {
1248
- const isDrawerGenerated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateDrawerNavigations).call(this, {
1249
- appDirPath,
1250
- modules,
1251
- initialRouteName,
1252
- unauthenticatedComponentPath,
1253
- });
1254
- if (isDrawerGenerated) {
1255
- const appNavigationGenerated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateAppNavigationFile).call(this, {
1256
- appDirPath,
1257
- customTabBarPath,
1258
- customDrawerPath,
1259
- customHeaderPath,
1260
- });
1261
- if (appNavigationGenerated)
1262
- return appNavigationGenerated;
1263
- else
1264
- return true;
1265
- }
1266
- else
1267
- return false;
1268
- }
1269
- else if (layoutType == 'bottom' || layoutType == 'host-bottom') {
1270
- const isBottomTabGenerated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabNavigations).call(this, {
1271
- appDirPath,
1272
- modules,
1273
- initialRouteName,
1274
- unauthenticatedComponentPath,
1275
- });
1276
- if (isBottomTabGenerated) {
1277
- const appNavigationGenerated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateAppNavigationFile).call(this, {
1278
- appDirPath,
1279
- customTabBarPath,
1280
- customDrawerPath,
1281
- customHeaderPath,
1282
- });
1283
- if (appNavigationGenerated)
1284
- return appNavigationGenerated;
1285
- else
1286
- return true;
1287
- }
1288
- else
1289
- return false;
1290
- }
1291
- else {
1292
- const isBottomTabDrawerGenerated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabDrawerNavigations).call(this, {
1293
- appDirPath,
1294
- modules,
1295
- initialRouteName,
1296
- unauthenticatedComponentPath,
1297
- });
1298
- if (isBottomTabDrawerGenerated) {
1299
- const appNavigationGenerated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateAppNavigationFile).call(this, {
1300
- appDirPath,
1301
- customTabBarPath,
1302
- customDrawerPath,
1303
- customHeaderPath,
1304
- });
1305
- if (appNavigationGenerated)
1306
- return appNavigationGenerated;
1307
- else
1308
- return true;
1309
- }
1310
- else
1311
- return false;
1312
- }
1613
+ if (layoutType == 'side') {
1614
+ try {
1615
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateDrawerNavigations).call(this, {
1616
+ appDirPath,
1617
+ modules,
1618
+ initialRouteName,
1619
+ unauthenticatedComponentPath,
1620
+ });
1621
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateAppNavigationFile).call(this, {
1622
+ appDirPath,
1623
+ customTabBarPath,
1624
+ customDrawerPath,
1625
+ customHeaderPath,
1626
+ });
1627
+ }
1628
+ catch (error) {
1629
+ console.log('Error in generating side navigation', error);
1630
+ }
1631
+ }
1632
+ else if (layoutType == 'bottom' || layoutType == 'host-bottom') {
1633
+ try {
1634
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabNavigations).call(this, {
1635
+ appDirPath,
1636
+ modules,
1637
+ initialRouteName,
1638
+ unauthenticatedComponentPath,
1639
+ });
1640
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateAppNavigationFile).call(this, {
1641
+ appDirPath,
1642
+ customTabBarPath,
1643
+ customDrawerPath,
1644
+ customHeaderPath,
1645
+ });
1646
+ }
1647
+ catch (error) {
1648
+ console.log('Error in generating bottom navigation', error);
1649
+ }
1650
+ }
1651
+ else {
1652
+ try {
1653
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabDrawerNavigations).call(this, {
1654
+ appDirPath,
1655
+ modules,
1656
+ initialRouteName,
1657
+ unauthenticatedComponentPath,
1658
+ });
1659
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateAppNavigationFile).call(this, {
1660
+ appDirPath,
1661
+ customTabBarPath,
1662
+ customDrawerPath,
1663
+ customHeaderPath,
1664
+ });
1665
+ }
1666
+ catch (error) {
1667
+ console.log('Error in generating drawer bottom navigation', error);
1313
1668
  }
1314
- else
1315
- return false;
1316
1669
  }
1317
- else
1318
- return false;
1319
1670
  }
1320
- else
1321
- return false;
1671
+ catch (error) {
1672
+ console.log('Error generating app navigations', error);
1673
+ }
1674
+ }, _GenerateMobileNavigations_performCopyOperations = async function _GenerateMobileNavigations_performCopyOperations() {
1675
+ const config = __classPrivateFieldGet(this, _GenerateMobileNavigations_configFileData, "f");
1676
+ try {
1677
+ await performCopyOperations(config);
1678
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_setLayoutAndGenerateNavigation).call(this);
1679
+ }
1680
+ catch (error) {
1681
+ console.error('PerformCopyOperations error:', error);
1682
+ }
1683
+ }, _GenerateMobileNavigations_deleteDirectoryRecursive = async function _GenerateMobileNavigations_deleteDirectoryRecursive(dirPath) {
1684
+ if (fs.existsSync(dirPath)) {
1685
+ const files = fs.readdirSync(dirPath);
1686
+ for (const file of files) {
1687
+ const curPath = path.join(dirPath, file);
1688
+ if (fs.lstatSync(curPath).isDirectory()) {
1689
+ // Recursively delete subdirectories
1690
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_deleteDirectoryRecursive).call(this, curPath);
1691
+ }
1692
+ else {
1693
+ // Delete files
1694
+ fs.unlinkSync(curPath);
1695
+ }
1696
+ }
1697
+ // Delete the directory itself
1698
+ fs.rmdirSync(dirPath);
1699
+ }
1700
+ }, _GenerateMobileNavigations_createAppDirectory = async function _GenerateMobileNavigations_createAppDirectory() {
1701
+ const appDir = __classPrivateFieldGet(this, _GenerateMobileNavigations_appDirPath, "f");
1702
+ try {
1703
+ // Check if the directory exists
1704
+ if (fs.existsSync(appDir)) {
1705
+ console.log('Directory exists. Recreating it...');
1706
+ // Delete the directory and its contents
1707
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_deleteDirectoryRecursive).call(this, appDir);
1708
+ }
1709
+ // Create the directory
1710
+ fs.mkdirSync(appDir);
1711
+ console.log('Directory created');
1712
+ // Add 'app' to .gitignore if not already present
1713
+ const gitignorePath = path.resolve(appDir, '.gitignore');
1714
+ let gitignoreContent = '';
1715
+ if (fs.existsSync(gitignorePath)) {
1716
+ gitignoreContent = fs.readFileSync(gitignorePath, 'utf8');
1717
+ }
1718
+ else {
1719
+ fs.writeFileSync(gitignorePath, '');
1720
+ console.log('Created .gitignore file');
1721
+ }
1722
+ if (!gitignoreContent.includes('*')) {
1723
+ fs.appendFileSync(gitignorePath, '*\n');
1724
+ console.log('Added "*" to .gitignore');
1725
+ }
1726
+ await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_performCopyOperations).call(this);
1727
+ }
1728
+ catch (error) {
1729
+ console.error('Error creating app directory:', error);
1730
+ }
1322
1731
  };
1732
+ export default GenerateMobileNavigations;
1323
1733
  //# sourceMappingURL=generateMobileNavigations.js.map