@umituz/react-native-settings 5.2.37 → 5.2.39

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-settings",
3
- "version": "5.2.37",
3
+ "version": "5.2.39",
4
4
  "description": "Complete settings hub for React Native apps - consolidated package with settings, localization, about, legal, appearance, feedback, FAQs, rating, and gamification",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -1,4 +1,5 @@
1
1
  import fs from 'fs';
2
+ import path from 'path';
2
3
  import { getLangDisplayName } from './translation-config.js';
3
4
 
4
5
  /**
@@ -8,7 +9,9 @@ import { getLangDisplayName } from './translation-config.js';
8
9
 
9
10
  export function parseTypeScriptFile(filePath) {
10
11
  const content = fs.readFileSync(filePath, 'utf8');
11
- const match = content.match(/export\s+default\s+(\{[\s\S]*\});?\s*$/);
12
+
13
+ // Match: export default { ... } OR export const NAME = { ... }
14
+ const match = content.match(/export\s+(?:default|const\s+\w+\s*=)\s*(\{[\s\S]*\});?\s*$/);
12
15
 
13
16
  if (!match) {
14
17
  throw new Error(`Could not parse TypeScript file: ${filePath}`);
@@ -17,12 +20,35 @@ export function parseTypeScriptFile(filePath) {
17
20
  const objectStr = match[1].replace(/;$/, '');
18
21
 
19
22
  try {
20
- // Basic evaluation for simple objects
23
+ // Basic evaluation for simple objects (works for generated language files like tr-TR.ts
24
+ // and sub-module files like common.ts, home.ts, etc.)
21
25
  // eslint-disable-next-line no-eval
22
26
  return eval(`(${objectStr})`);
23
27
  } catch (error) {
28
+ // File might be a barrel file with named imports (e.g., en-US.ts that imports sub-modules)
29
+ // Try to resolve each import and merge into a single object
30
+ const dir = path.dirname(filePath);
31
+ const importMatches = [...content.matchAll(/import\s*\{\s*(\w+)\s*\}\s*from\s*["']\.\/(\w+)["']/g)];
32
+
33
+ if (importMatches.length > 0) {
34
+ const result = {};
35
+ for (const [, varName, moduleName] of importMatches) {
36
+ const subFilePath = path.join(dir, `${moduleName}.ts`);
37
+ if (fs.existsSync(subFilePath)) {
38
+ try {
39
+ result[varName] = parseTypeScriptFile(subFilePath);
40
+ } catch {
41
+ // ignore individual sub-file parse errors
42
+ }
43
+ }
44
+ }
45
+ if (Object.keys(result).length > 0) {
46
+ return result;
47
+ }
48
+ }
49
+
24
50
  console.warn(`\n⚠️ Warning: Could not fully parse ${filePath}. Files with complex imports/spreads are currently limited.`);
25
- return {}; // Return empty to avoid breaking the whole process
51
+ return {};
26
52
  }
27
53
  }
28
54