react-native-inapp-inspector 1.1.12 → 1.1.14

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 (64) hide show
  1. package/dist/commonjs/components/AnalyticsDetail.js +64 -21
  2. package/dist/commonjs/components/AnalyticsEventCard.js +100 -13
  3. package/dist/commonjs/components/HighlightText.js +1 -1
  4. package/dist/commonjs/components/JsonViewer.d.ts +3 -1
  5. package/dist/commonjs/components/JsonViewer.js +327 -9
  6. package/dist/commonjs/components/MetaAccordion.d.ts +10 -1
  7. package/dist/commonjs/components/MetaAccordion.js +121 -24
  8. package/dist/commonjs/components/NetworkIcons.d.ts +1 -0
  9. package/dist/commonjs/components/NetworkIcons.js +8 -1
  10. package/dist/commonjs/components/ReduxTreeView.d.ts +12 -3
  11. package/dist/commonjs/components/ReduxTreeView.js +1096 -278
  12. package/dist/commonjs/components/SectionHeader.d.ts +1 -1
  13. package/dist/commonjs/components/SectionHeader.js +7 -1
  14. package/dist/commonjs/constants/version.d.ts +1 -1
  15. package/dist/commonjs/constants/version.js +1 -1
  16. package/dist/commonjs/customHooks/analyticsLogger.d.ts +8 -0
  17. package/dist/commonjs/customHooks/analyticsLogger.js +42 -1
  18. package/dist/commonjs/customHooks/reduxLogger.d.ts +2 -0
  19. package/dist/commonjs/customHooks/reduxLogger.js +2 -0
  20. package/dist/commonjs/helpers/index.d.ts +1 -0
  21. package/dist/commonjs/helpers/index.js +15 -1
  22. package/dist/commonjs/helpers/settingsStore.d.ts +1 -0
  23. package/dist/commonjs/helpers/settingsStore.js +4 -0
  24. package/dist/commonjs/index.d.ts +1 -1
  25. package/dist/commonjs/index.js +347 -444
  26. package/dist/commonjs/styles/index.d.ts +92 -33
  27. package/dist/commonjs/styles/index.js +101 -45
  28. package/dist/commonjs/types/index.d.ts +3 -0
  29. package/dist/esm/components/AnalyticsDetail.js +64 -21
  30. package/dist/esm/components/AnalyticsEventCard.js +100 -13
  31. package/dist/esm/components/HighlightText.js +3 -3
  32. package/dist/esm/components/JsonViewer.d.ts +3 -1
  33. package/dist/esm/components/JsonViewer.js +295 -10
  34. package/dist/esm/components/MetaAccordion.d.ts +10 -1
  35. package/dist/esm/components/MetaAccordion.js +90 -26
  36. package/dist/esm/components/NetworkIcons.d.ts +1 -0
  37. package/dist/esm/components/NetworkIcons.js +6 -0
  38. package/dist/esm/components/ReduxTreeView.d.ts +12 -3
  39. package/dist/esm/components/ReduxTreeView.js +1095 -279
  40. package/dist/esm/components/SectionHeader.d.ts +1 -1
  41. package/dist/esm/components/SectionHeader.js +8 -2
  42. package/dist/esm/constants/version.d.ts +1 -1
  43. package/dist/esm/constants/version.js +1 -1
  44. package/dist/esm/customHooks/analyticsLogger.d.ts +8 -0
  45. package/dist/esm/customHooks/analyticsLogger.js +37 -0
  46. package/dist/esm/customHooks/reduxLogger.d.ts +2 -0
  47. package/dist/esm/customHooks/reduxLogger.js +2 -0
  48. package/dist/esm/helpers/index.d.ts +1 -0
  49. package/dist/esm/helpers/index.js +14 -1
  50. package/dist/esm/helpers/settingsStore.d.ts +1 -0
  51. package/dist/esm/helpers/settingsStore.js +3 -0
  52. package/dist/esm/index.d.ts +1 -1
  53. package/dist/esm/index.js +345 -446
  54. package/dist/esm/styles/index.d.ts +92 -33
  55. package/dist/esm/styles/index.js +101 -45
  56. package/dist/esm/types/index.d.ts +3 -0
  57. package/example/android/app/build.gradle +29 -1
  58. package/example/android/app/src/main/java/com/example/MainApplication.kt +25 -0
  59. package/example/android/build.gradle +31 -4
  60. package/example/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  61. package/example/android/gradle.properties +1 -0
  62. package/example/android/settings.gradle +20 -1
  63. package/example/package-lock.json +1 -1
  64. package/package.json +1 -1
@@ -44,6 +44,7 @@ const JsonViewer_1 = __importDefault(require("./JsonViewer"));
44
44
  const TouchableScale_1 = __importDefault(require("./TouchableScale"));
45
45
  // Utils
46
46
  const AppFonts_1 = require("../styles/AppFonts");
47
+ const helpers_1 = require("../helpers");
47
48
  // Stylesheet
48
49
  const AppColors_1 = require("../styles/AppColors");
49
50
  const AnalyticsDetail = ({ event, }) => {
@@ -52,6 +53,26 @@ const AnalyticsDetail = ({ event, }) => {
52
53
  const params = event.params ?? {};
53
54
  const userProperties = event.userProperties ?? {};
54
55
  const upCount = Object.keys(userProperties).length;
56
+ const jsonData = {
57
+ name: event.name,
58
+ params: params,
59
+ ...(upCount > 0 ? { userProperties } : {}),
60
+ };
61
+ const isObject = typeof jsonData === 'object' && jsonData !== null;
62
+ const isArray = Array.isArray(jsonData);
63
+ let typeLabel = typeof jsonData;
64
+ let countLabel = '';
65
+ if (jsonData === null) {
66
+ typeLabel = 'null';
67
+ }
68
+ else if (isArray) {
69
+ typeLabel = 'array';
70
+ countLabel = `${jsonData.length} items`;
71
+ }
72
+ else if (isObject) {
73
+ typeLabel = 'object';
74
+ countLabel = `${Object.keys(jsonData).length} keys`;
75
+ }
55
76
  return (<react_native_1.ScrollView style={[detailStyles.scroll, { backgroundColor: AppColors_1.AppColors.grayBackground }]} contentContainerStyle={detailStyles.content} showsVerticalScrollIndicator contentInsetAdjustmentBehavior="never" automaticallyAdjustContentInsets={false}>
56
77
 
57
78
  {/* Clean Toolbar */}
@@ -65,7 +86,8 @@ const AnalyticsDetail = ({ event, }) => {
65
86
  borderBottomColor: AppColors_1.AppColors.grayBorderSecondary,
66
87
  backgroundColor: AppColors_1.AppColors.primaryLight,
67
88
  }}>
68
- <TouchableScale_1.default style={{
89
+ <react_native_1.View style={{ flexDirection: 'row', alignItems: 'center', gap: 8 }}>
90
+ <TouchableScale_1.default style={{
69
91
  flexDirection: 'row',
70
92
  alignItems: 'center',
71
93
  gap: 6,
@@ -80,20 +102,49 @@ const AnalyticsDetail = ({ event, }) => {
80
102
  setExpandDepth(nextDepth);
81
103
  setTreeKey(prev => prev + 1);
82
104
  }}>
83
- <react_native_1.Text style={{
105
+ <react_native_1.Text style={{
84
106
  fontFamily: AppFonts_1.AppFonts.interBold,
85
107
  fontSize: 12,
86
108
  color: AppColors_1.AppColors.purple,
87
109
  }}>
88
- {expandDepth === 99 ? 'Collapse All' : 'Expand All'}
89
- </react_native_1.Text>
90
- </TouchableScale_1.default>
110
+ {expandDepth === 99 ? 'Collapse All' : 'Expand All'}
111
+ </react_native_1.Text>
112
+ </TouchableScale_1.default>
113
+ <react_native_1.View style={{
114
+ flexDirection: 'row',
115
+ alignItems: 'center',
116
+ backgroundColor: AppColors_1.AppColors.grayBackground,
117
+ borderRadius: 6,
118
+ overflow: 'hidden',
119
+ borderWidth: 1,
120
+ borderColor: AppColors_1.AppColors.grayBorderSecondary,
121
+ }}>
122
+ <react_native_1.View style={{ paddingHorizontal: 6, paddingVertical: 4, backgroundColor: AppColors_1.AppColors.purple + '18' }}>
123
+ <react_native_1.Text style={{ fontFamily: AppFonts_1.AppFonts.interBold, fontSize: 9, color: AppColors_1.AppColors.purple, letterSpacing: 0.3 }}>
124
+ {typeLabel.toUpperCase()}
125
+ </react_native_1.Text>
126
+ </react_native_1.View>
127
+ {countLabel ? (<react_native_1.View style={{ paddingHorizontal: 6, paddingVertical: 4 }}>
128
+ <react_native_1.Text style={{ fontFamily: AppFonts_1.AppFonts.interMedium, fontSize: 9, color: AppColors_1.AppColors.grayText }}>
129
+ {countLabel}
130
+ </react_native_1.Text>
131
+ </react_native_1.View>) : null}
132
+ </react_native_1.View>
133
+ <react_native_1.View style={{
134
+ backgroundColor: AppColors_1.AppColors.grayBackground,
135
+ borderRadius: 6,
136
+ paddingHorizontal: 6,
137
+ paddingVertical: 4,
138
+ borderWidth: 1,
139
+ borderColor: AppColors_1.AppColors.grayBorderSecondary,
140
+ }}>
141
+ <react_native_1.Text style={{ fontFamily: AppFonts_1.AppFonts.interMedium, fontSize: 9, color: AppColors_1.AppColors.grayText }}>
142
+ {(0, helpers_1.getSize)(jsonData)}
143
+ </react_native_1.Text>
144
+ </react_native_1.View>
145
+ </react_native_1.View>
91
146
 
92
- <CopyButton_1.default value={JSON.stringify({
93
- name: event.name,
94
- params: params,
95
- ...(upCount > 0 ? { userProperties } : {}),
96
- }, null, 2)} label="Copy JSON"/>
147
+ <CopyButton_1.default value={JSON.stringify(jsonData, null, 2)} label="Copy JSON"/>
97
148
  </react_native_1.View>
98
149
 
99
150
  {/* Direct JSON Viewer View */}
@@ -105,15 +156,7 @@ const AnalyticsDetail = ({ event, }) => {
105
156
  marginTop: 16,
106
157
  },
107
158
  ]}>
108
- <JsonViewer_1.default key={treeKey} data={{
109
- name: event.name,
110
- params: params,
111
- ...(upCount > 0
112
- ? {
113
- userProperties: userProperties,
114
- }
115
- : {}),
116
- }} defaultExpandDepth={expandDepth}/>
159
+ <JsonViewer_1.default key={treeKey} data={jsonData} defaultExpandDepth={expandDepth} fullHeight/>
117
160
  </react_native_1.View>
118
161
  </react_native_1.ScrollView>);
119
162
  };
@@ -125,8 +168,8 @@ const detailStyles = react_native_1.StyleSheet.create({
125
168
  },
126
169
  jsonBlockContainer: {
127
170
  marginHorizontal: 16,
128
- marginTop: 8,
129
- padding: 12,
171
+ marginTop: 16,
172
+ marginBottom: 16,
130
173
  borderWidth: 1,
131
174
  borderRadius: 12,
132
175
  },
@@ -55,9 +55,10 @@ const EVENT_PALETTE = [
55
55
  '#2E7D32', // dark green
56
56
  ];
57
57
  function getEventColor(name) {
58
+ const safeName = typeof name === 'string' ? name : String(name || '');
58
59
  let hash = 0;
59
- for (let i = 0; i < name.length; i++) {
60
- hash = (hash * 31 + name.charCodeAt(i)) | 0;
60
+ for (let i = 0; i < safeName.length; i++) {
61
+ hash = (hash * 31 + safeName.charCodeAt(i)) | 0;
61
62
  }
62
63
  return EVENT_PALETTE[Math.abs(hash) % EVENT_PALETTE.length];
63
64
  }
@@ -80,6 +81,63 @@ function formatGap(ms) {
80
81
  const rem = s % 60;
81
82
  return rem > 0 ? `+${m}m ${rem}s` : `+${m}m`;
82
83
  }
84
+ function getEventCategory(name) {
85
+ if (!name)
86
+ return 'Custom';
87
+ const lowercaseName = name.toLowerCase();
88
+ if (lowercaseName === 'screen_view' || lowercaseName === 'page_view') {
89
+ return 'Page View';
90
+ }
91
+ // Ecommerce events
92
+ const ecommerceEvents = [
93
+ 'purchase', 'add_to_cart', 'begin_checkout', 'view_item',
94
+ 'select_item', 'remove_from_cart', 'view_cart',
95
+ 'add_shipping_info', 'add_payment_info', 'refund',
96
+ 'view_item_list', 'select_promotion', 'view_promotion'
97
+ ];
98
+ if (ecommerceEvents.includes(lowercaseName)) {
99
+ return 'Ecommerce';
100
+ }
101
+ // Firebase System Auto-events
102
+ const systemEvents = [
103
+ 'first_open', 'session_start', 'user_engagement',
104
+ 'app_clear_data', 'app_exception', 'app_update', 'os_update',
105
+ 'notification_receive', 'notification_open', 'notification_dismiss',
106
+ 'screen_active', 'screen_inactive'
107
+ ];
108
+ if (systemEvents.includes(lowercaseName) || lowercaseName.startsWith('firebase_') || lowercaseName.startsWith('_')) {
109
+ return 'System';
110
+ }
111
+ return 'Custom';
112
+ }
113
+ function getCategoryColors(category) {
114
+ switch (category) {
115
+ case 'Page View':
116
+ return {
117
+ bg: '#E3F2FD',
118
+ border: '#BBDEFB',
119
+ text: '#1976D2',
120
+ };
121
+ case 'Ecommerce':
122
+ return {
123
+ bg: '#E8F5E9',
124
+ border: '#C8E6C9',
125
+ text: '#2E7D32',
126
+ };
127
+ case 'System':
128
+ return {
129
+ bg: '#F5F5F5',
130
+ border: '#E0E0E0',
131
+ text: '#616161',
132
+ };
133
+ default:
134
+ return {
135
+ bg: '#F3E5F5',
136
+ border: '#E1BEE7',
137
+ text: '#7B1FA2',
138
+ };
139
+ }
140
+ }
83
141
  // ─── Component ────────────────────────────────────────────────────────────────
84
142
  const AnalyticsEventCard = react_1.default.memo(function AnalyticsEventCard({ event, onPress, isNew = false, searchStr = '', msSincePrev, computedScreenName, }) {
85
143
  const color = getEventColor(event.name);
@@ -128,6 +186,19 @@ const AnalyticsEventCard = react_1.default.memo(function AnalyticsEventCard({ ev
128
186
  <HighlightText_1.default text={event.name} search={searchStr} style={[cardStyles.eventName, { color: color }]} highlightStyle={cardStyles.highlight}/>
129
187
  </react_native_1.View>
130
188
 
189
+ {(() => {
190
+ const category = getEventCategory(event.name);
191
+ const tagColors = getCategoryColors(category);
192
+ return (<react_native_1.View style={[
193
+ cardStyles.categoryBadge,
194
+ { backgroundColor: tagColors.bg, borderColor: tagColors.border },
195
+ ]}>
196
+ <react_native_1.Text style={[cardStyles.categoryText, { color: tagColors.text }]}>
197
+ {category}
198
+ </react_native_1.Text>
199
+ </react_native_1.View>);
200
+ })()}
201
+
131
202
  {event.count !== undefined ? (<react_native_1.View style={[
132
203
  cardStyles.duplicateBadge,
133
204
  event.count === 1 && {
@@ -151,20 +222,24 @@ const AnalyticsEventCard = react_1.default.memo(function AnalyticsEventCard({ ev
151
222
  {/* Bottom Row: Metadata Chips & Sparkline */}
152
223
  <react_native_1.View style={cardStyles.cardBody}>
153
224
  <react_native_1.View style={cardStyles.chipsRow}>
154
- {computedScreenName ||
155
- event.screenName ||
156
- event.params?.firebase_screen ||
157
- event.params?.screen_name ||
158
- event.params?.firebase_screen_class ? (<react_native_1.View style={[cardStyles.chip, { backgroundColor: AppColors_1.AppColors.grayBackground, borderColor: AppColors_1.AppColors.grayBorderSecondary }]}>
159
- <react_native_1.View style={[cardStyles.screenDot, { backgroundColor: color }]}/>
160
- <react_native_1.Text style={[cardStyles.chipText, { color: AppColors_1.AppColors.grayText }]} numberOfLines={1}>
161
- {computedScreenName ||
225
+ {(() => {
226
+ const rawScreenName = computedScreenName ||
162
227
  event.screenName ||
163
228
  event.params?.firebase_screen ||
164
229
  event.params?.screen_name ||
165
- event.params?.firebase_screen_class}
166
- </react_native_1.Text>
167
- </react_native_1.View>) : null}
230
+ event.params?.firebase_screen_class;
231
+ if (!rawScreenName)
232
+ return null;
233
+ const screenNameStr = typeof rawScreenName === 'object'
234
+ ? JSON.stringify(rawScreenName)
235
+ : String(rawScreenName);
236
+ return (<react_native_1.View style={[cardStyles.chip, { backgroundColor: AppColors_1.AppColors.grayBackground, borderColor: AppColors_1.AppColors.grayBorderSecondary }]}>
237
+ <react_native_1.View style={[cardStyles.screenDot, { backgroundColor: color }]}/>
238
+ <react_native_1.Text style={[cardStyles.chipText, { color: AppColors_1.AppColors.grayText }]} numberOfLines={1}>
239
+ {screenNameStr}
240
+ </react_native_1.Text>
241
+ </react_native_1.View>);
242
+ })()}
168
243
 
169
244
  <react_native_1.View style={[cardStyles.chip, { backgroundColor: AppColors_1.AppColors.grayBackground, borderColor: AppColors_1.AppColors.grayBorderSecondary }]}>
170
245
  <react_native_1.Text style={[cardStyles.chipText, { color: AppColors_1.AppColors.grayText }]}>
@@ -311,6 +386,18 @@ const cardStyles = react_native_1.StyleSheet.create({
311
386
  textTransform: 'uppercase',
312
387
  letterSpacing: 0.5,
313
388
  },
389
+ categoryBadge: {
390
+ borderWidth: 1,
391
+ paddingHorizontal: 5,
392
+ paddingVertical: 2,
393
+ borderRadius: 4,
394
+ },
395
+ categoryText: {
396
+ fontFamily: AppFonts_1.AppFonts.interBold,
397
+ fontSize: 9,
398
+ textTransform: 'uppercase',
399
+ letterSpacing: 0.5,
400
+ },
314
401
  miniGraphWrapper: {
315
402
  flexDirection: 'row',
316
403
  alignItems: 'flex-end',
@@ -33,7 +33,7 @@ const HighlightText = ({ text, search, style, highlightStyle, detectLinks, ...re
33
33
  color: '#007AFF', // skyBlue link color
34
34
  textDecorationLine: 'underline',
35
35
  }} onPress={() => {
36
- react_native_1.Linking.openURL(part).catch(() => { });
36
+ (0, helpers_1.handleOpenExternalLink)(part);
37
37
  }}>
38
38
  {part}
39
39
  </react_native_1.Text>);
@@ -1,9 +1,11 @@
1
1
  import React from 'react';
2
- declare const JsonViewer: ({ data, search, forceOpen, defaultExpandDepth, wrap, }: {
2
+ declare const JsonViewer: ({ data, search, forceOpen, defaultExpandDepth, wrap, fullHeight, onModeChange, }: {
3
3
  data: unknown;
4
4
  search?: string;
5
5
  forceOpen?: boolean;
6
6
  defaultExpandDepth?: number;
7
7
  wrap?: boolean;
8
+ fullHeight?: boolean;
9
+ onModeChange?: (mode: "pretty" | "raw" | "table") => void;
8
10
  }) => React.JSX.Element;
9
11
  export default JsonViewer;
@@ -1,21 +1,339 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
39
+ const react_1 = __importStar(require("react"));
7
40
  const react_native_1 = require("react-native");
41
+ const react_native_svg_1 = __importStar(require("react-native-svg"));
8
42
  // Components
9
43
  const TreeNode_1 = __importDefault(require("./TreeNode"));
10
- // Stylesheet
44
+ const TouchableScale_1 = __importDefault(require("./TouchableScale"));
45
+ // Helpers
46
+ const helpers_1 = require("../helpers");
47
+ // Styles
48
+ const AppColors_1 = require("../styles/AppColors");
49
+ const AppFonts_1 = require("../styles/AppFonts");
11
50
  const styles_1 = __importDefault(require("../styles"));
12
- const JsonViewer = ({ data, search, forceOpen, defaultExpandDepth, wrap, }) => {
13
- const tree = (<TreeNode_1.default data={data} search={search} forceOpen={forceOpen} defaultExpandDepth={defaultExpandDepth}/>);
14
- if (wrap) {
15
- return <react_native_1.View style={[styles_1.default.codeBlock, { width: '100%' }]}>{tree}</react_native_1.View>;
51
+ // ── Tab Icons ────────────────────────────────────────────────────────────────
52
+ const PrettyIcon = ({ color = '#94A3B8', size = 12 }) => (<react_native_svg_1.default width={size} height={size} viewBox="0 0 16 16" fill="none">
53
+ <react_native_svg_1.Path d="M5 3C3.9 3 3 3.9 3 5v1.5c0 .8-.7 1.5-1.5 1.5S0 7.3 0 6.5V5c0-2.8 2.2-5 5-5 .6 0 1 .4 1 1s-.4 1-1 1zm6 0c-1.1 0-2 .9-2 2v1.5c0 .8-.7 1.5-1.5 1.5S6 9.3 6 8.5V5c0-2.8 2.2-5 5-5 .6 0 1 .4 1 1s-.4 1-1 1z" fill={color} opacity={0.9}/>
54
+ <react_native_svg_1.Path d="M3 11v1.5c0 .8.7 1.5 1.5 1.5S6 13.3 6 12.5V11H3zm7 0v1.5c0 .8.7 1.5 1.5 1.5S13 13.3 13 12.5V11H10z" fill={color} opacity={0.6}/>
55
+ </react_native_svg_1.default>);
56
+ const RawIcon = ({ color = '#94A3B8', size = 12 }) => (<react_native_svg_1.default width={size} height={size} viewBox="0 0 16 16" fill="none">
57
+ <react_native_svg_1.Rect x="1" y="2" width="10" height="1.5" rx="0.75" fill={color} opacity={0.9}/>
58
+ <react_native_svg_1.Rect x="1" y="5.5" width="14" height="1.5" rx="0.75" fill={color} opacity={0.6}/>
59
+ <react_native_svg_1.Rect x="1" y="9" width="8" height="1.5" rx="0.75" fill={color} opacity={0.45}/>
60
+ <react_native_svg_1.Rect x="1" y="12.5" width="12" height="1.5" rx="0.75" fill={color} opacity={0.3}/>
61
+ </react_native_svg_1.default>);
62
+ const TableIcon = ({ color = '#94A3B8', size = 12 }) => (<react_native_svg_1.default width={size} height={size} viewBox="0 0 16 16" fill="none">
63
+ <react_native_svg_1.Rect x="1" y="1" width="14" height="14" rx="2" stroke={color} strokeWidth={1.2} opacity={0.7}/>
64
+ <react_native_svg_1.Path d="M1 5.5h14M1 10h14M5.5 1v14M10.5 1v14" stroke={color} strokeWidth={0.8} opacity={0.5}/>
65
+ </react_native_svg_1.default>);
66
+ // ── JsonViewer Component ─────────────────────────────────────────────────────
67
+ const JsonViewer = ({ data, search, forceOpen, defaultExpandDepth, wrap, fullHeight = false, onModeChange, }) => {
68
+ const [mode, setMode] = (0, react_1.useState)('pretty');
69
+ (0, react_1.useEffect)(() => {
70
+ onModeChange?.(mode);
71
+ }, [mode, onModeChange]);
72
+ // Determine type and size details
73
+ const isObject = typeof data === 'object' && data !== null;
74
+ const isArray = Array.isArray(data);
75
+ let typeLabel = typeof data;
76
+ let countLabel = '';
77
+ if (data === null) {
78
+ typeLabel = 'null';
79
+ }
80
+ else if (isArray) {
81
+ typeLabel = 'array';
82
+ countLabel = `${data.length} items`;
16
83
  }
17
- return (<react_native_1.ScrollView horizontal showsHorizontalScrollIndicator={true} style={styles_1.default.codeBlockScroll}>
18
- <react_native_1.View style={styles_1.default.codeBlock}>{tree}</react_native_1.View>
19
- </react_native_1.ScrollView>);
84
+ else if (isObject) {
85
+ typeLabel = 'object';
86
+ countLabel = `${Object.keys(data).length} keys`;
87
+ }
88
+ // Copy helper
89
+ const handleCopy = () => {
90
+ (0, helpers_1.copyToClipboard)(data, 'JSON data');
91
+ };
92
+ // Render Table view (Key-Value flat table for root keys)
93
+ const renderTableMode = () => {
94
+ if (!isObject) {
95
+ return (<react_native_1.View style={localStyles.tableRow}>
96
+ <react_native_1.Text style={localStyles.tableCellKey}>value</react_native_1.Text>
97
+ <react_native_1.Text style={localStyles.tableCellValue}>{String(data)}</react_native_1.Text>
98
+ </react_native_1.View>);
99
+ }
100
+ const keys = Object.keys(data);
101
+ if (keys.length === 0) {
102
+ return (<react_native_1.View style={localStyles.emptyTable}>
103
+ <react_native_1.Text style={localStyles.emptyTableText}>Empty Object</react_native_1.Text>
104
+ </react_native_1.View>);
105
+ }
106
+ return (<react_native_1.View style={localStyles.tableView}>
107
+ <react_native_1.View style={localStyles.tableHeaderRow}>
108
+ <react_native_1.Text style={[localStyles.tableHeaderCell, { flex: 2 }]}>Key</react_native_1.Text>
109
+ <react_native_1.Text style={[localStyles.tableHeaderCell, { flex: 3 }]}>Value</react_native_1.Text>
110
+ </react_native_1.View>
111
+ {keys.map((key) => {
112
+ const val = data[key];
113
+ let displayVal = '';
114
+ if (val === null) {
115
+ displayVal = 'null';
116
+ }
117
+ else if (val === undefined) {
118
+ displayVal = 'undefined';
119
+ }
120
+ else if (typeof val === 'object') {
121
+ displayVal = Array.isArray(val) ? `[Array(${val.length})]` : '{Object}';
122
+ }
123
+ else {
124
+ displayVal = String(val);
125
+ }
126
+ return (<react_native_1.View key={key} style={localStyles.tableRow}>
127
+ <react_native_1.Text style={[localStyles.tableCellKey, { flex: 2 }]}>{key}</react_native_1.Text>
128
+ <react_native_1.Text style={[localStyles.tableCellValue, { flex: 3 }]} numberOfLines={2}>
129
+ {displayVal}
130
+ </react_native_1.Text>
131
+ </react_native_1.View>);
132
+ })}
133
+ </react_native_1.View>);
134
+ };
135
+ // Tree View Content
136
+ const tree = (<TreeNode_1.default data={data} search={search} forceOpen={forceOpen} defaultExpandDepth={defaultExpandDepth}/>);
137
+ return (<react_native_1.View style={[localStyles.container, fullHeight && { flex: 1 }]}>
138
+ {/* ── Top Toolbar Bar (Postman-style) ── */}
139
+ <react_native_1.View style={localStyles.toolbar}>
140
+ {/* Left Segmented Control */}
141
+ <react_native_1.View style={localStyles.segmentedControl}>
142
+ {[
143
+ { key: 'pretty', label: 'Pretty', icon: PrettyIcon },
144
+ { key: 'raw', label: 'Raw', icon: RawIcon },
145
+ { key: 'table', label: 'Table', icon: TableIcon },
146
+ ].map(({ key, label, icon: Icon }) => (<TouchableScale_1.default key={key} onPress={() => setMode(key)} style={[
147
+ localStyles.segButton,
148
+ mode === key && localStyles.segButtonActive,
149
+ ]}>
150
+ <Icon color={mode === key ? AppColors_1.AppColors.purple : '#94A3B8'} size={12}/>
151
+ <react_native_1.Text style={[
152
+ localStyles.segText,
153
+ mode === key && localStyles.segTextActive,
154
+ ]}>
155
+ {label}
156
+ </react_native_1.Text>
157
+ </TouchableScale_1.default>))}
158
+ </react_native_1.View>
159
+
160
+ {/* Right Actions — badges & copy removed (caller provides header) */}
161
+
162
+ </react_native_1.View>
163
+
164
+ {/* ── Main View Content Area (Royal Monospace Theme) ── */}
165
+ <react_native_1.View style={[localStyles.contentWrapper, { backgroundColor: '#F8F9FB' }, fullHeight && { flex: 1, maxHeight: undefined }]}>
166
+ {mode === 'pretty' && (wrap ? (fullHeight ? (<react_native_1.ScrollView style={{ flex: 1 }} contentContainerStyle={{ flexGrow: 1 }}>
167
+ <react_native_1.View style={[styles_1.default.codeBlock, { width: '100%' }]}>{tree}</react_native_1.View>
168
+ </react_native_1.ScrollView>) : (<react_native_1.View style={[styles_1.default.codeBlock, { width: '100%' }]}>{tree}</react_native_1.View>)) : (fullHeight ? (<react_native_1.ScrollView style={{ flex: 1 }} contentContainerStyle={{ flexGrow: 1 }}>
169
+ <react_native_1.View style={styles_1.default.codeBlock}>{tree}</react_native_1.View>
170
+ </react_native_1.ScrollView>) : (<react_native_1.ScrollView horizontal showsHorizontalScrollIndicator={true} style={styles_1.default.codeBlockScroll}>
171
+ <react_native_1.View style={styles_1.default.codeBlock}>{tree}</react_native_1.View>
172
+ </react_native_1.ScrollView>)))}
173
+
174
+ {mode === 'raw' && (fullHeight ? (<react_native_1.ScrollView style={localStyles.rawScroll} contentContainerStyle={localStyles.rawContent}>
175
+ <react_native_1.Text selectable={true} style={localStyles.rawMonospaceText}>
176
+ {JSON.stringify(data, null, 2)}
177
+ </react_native_1.Text>
178
+ </react_native_1.ScrollView>) : (<react_native_1.View style={localStyles.rawContent}>
179
+ <react_native_1.Text selectable={true} style={localStyles.rawMonospaceText}>
180
+ {JSON.stringify(data, null, 2)}
181
+ </react_native_1.Text>
182
+ </react_native_1.View>))}
183
+
184
+ {mode === 'table' && (fullHeight ? (<react_native_1.ScrollView style={localStyles.rawScroll}>
185
+ {renderTableMode()}
186
+ </react_native_1.ScrollView>) : (<react_native_1.View style={localStyles.rawScroll}>
187
+ {renderTableMode()}
188
+ </react_native_1.View>))}
189
+ </react_native_1.View>
190
+ </react_native_1.View>);
20
191
  };
192
+ const localStyles = react_native_1.StyleSheet.create({
193
+ container: {
194
+ backgroundColor: '#FFFFFF',
195
+ borderRadius: 12,
196
+ borderWidth: 1.5,
197
+ borderColor: '#E2E8F0',
198
+ overflow: 'hidden',
199
+ shadowColor: '#000',
200
+ shadowOpacity: 0.04,
201
+ shadowRadius: 5,
202
+ shadowOffset: { width: 0, height: 2 },
203
+ elevation: 2,
204
+ width: '100%',
205
+ },
206
+ toolbar: {
207
+ flexDirection: 'row',
208
+ alignItems: 'center',
209
+ justifyContent: 'space-between',
210
+ backgroundColor: '#F8FAFC',
211
+ borderBottomWidth: 1,
212
+ borderBottomColor: '#E2E8F0',
213
+ paddingHorizontal: 12,
214
+ paddingVertical: 8,
215
+ },
216
+ segmentedControl: {
217
+ flexDirection: 'row',
218
+ backgroundColor: '#E2E8F0',
219
+ borderRadius: 8,
220
+ padding: 2,
221
+ },
222
+ segButton: {
223
+ flexDirection: 'row',
224
+ alignItems: 'center',
225
+ gap: 4,
226
+ paddingHorizontal: 10,
227
+ paddingVertical: 5,
228
+ borderRadius: 6,
229
+ },
230
+ segButtonActive: {
231
+ backgroundColor: '#FFFFFF',
232
+ shadowColor: '#000',
233
+ shadowOpacity: 0.08,
234
+ shadowRadius: 2,
235
+ shadowOffset: { width: 0, height: 1 },
236
+ elevation: 1,
237
+ },
238
+ segText: {
239
+ fontFamily: AppFonts_1.AppFonts.interBold,
240
+ fontSize: 9.5,
241
+ color: '#64748B',
242
+ letterSpacing: 0.3,
243
+ },
244
+ segTextActive: {
245
+ color: AppColors_1.AppColors.purple,
246
+ },
247
+ rightActions: {
248
+ flexDirection: 'row',
249
+ alignItems: 'center',
250
+ gap: 6,
251
+ },
252
+ badge: {
253
+ backgroundColor: 'rgba(104,75,155,0.06)',
254
+ borderWidth: 1,
255
+ borderColor: 'rgba(104,75,155,0.15)',
256
+ borderRadius: 5,
257
+ paddingHorizontal: 6,
258
+ paddingVertical: 2.5,
259
+ },
260
+ badgeText: {
261
+ fontFamily: AppFonts_1.AppFonts.interBold,
262
+ fontSize: 9,
263
+ color: AppColors_1.AppColors.purple,
264
+ },
265
+ copyButton: {
266
+ width: 24,
267
+ height: 24,
268
+ borderRadius: 6,
269
+ backgroundColor: 'rgba(104,75,155,0.08)',
270
+ alignItems: 'center',
271
+ justifyContent: 'center',
272
+ },
273
+ contentWrapper: {
274
+ backgroundColor: '#FFFFFF',
275
+ minHeight: 120,
276
+ maxHeight: 480,
277
+ },
278
+ rawScroll: {
279
+ flex: 1,
280
+ backgroundColor: '#FAF9F6', // Royal off-white paper tone
281
+ },
282
+ rawContent: {
283
+ padding: 12,
284
+ },
285
+ rawMonospaceText: {
286
+ fontFamily: react_native_1.Platform.OS === 'ios' ? 'Courier New' : 'monospace',
287
+ fontSize: 11.5,
288
+ color: '#0F172A',
289
+ lineHeight: 16,
290
+ },
291
+ tableView: {
292
+ flex: 1,
293
+ },
294
+ tableHeaderRow: {
295
+ flexDirection: 'row',
296
+ backgroundColor: '#F1F5F9',
297
+ borderBottomWidth: 1,
298
+ borderBottomColor: '#E2E8F0',
299
+ paddingVertical: 8,
300
+ paddingHorizontal: 12,
301
+ },
302
+ tableHeaderCell: {
303
+ fontFamily: AppFonts_1.AppFonts.interBold,
304
+ fontSize: 9.5,
305
+ color: '#475569',
306
+ letterSpacing: 0.5,
307
+ textTransform: 'uppercase',
308
+ },
309
+ tableRow: {
310
+ flexDirection: 'row',
311
+ borderBottomWidth: 1,
312
+ borderBottomColor: '#F1F5F9',
313
+ paddingVertical: 10,
314
+ paddingHorizontal: 12,
315
+ alignItems: 'center',
316
+ },
317
+ tableCellKey: {
318
+ fontFamily: react_native_1.Platform.OS === 'ios' ? 'Courier-Bold' : 'monospace',
319
+ fontSize: 11.5,
320
+ fontWeight: 'bold',
321
+ color: '#0F172A',
322
+ },
323
+ tableCellValue: {
324
+ fontFamily: react_native_1.Platform.OS === 'ios' ? 'Courier' : 'monospace',
325
+ fontSize: 11.5,
326
+ color: '#475569',
327
+ },
328
+ emptyTable: {
329
+ padding: 24,
330
+ alignItems: 'center',
331
+ justifyContent: 'center',
332
+ },
333
+ emptyTableText: {
334
+ fontFamily: AppFonts_1.AppFonts.interMedium,
335
+ fontSize: 12,
336
+ color: '#94A3B8',
337
+ },
338
+ });
21
339
  exports.default = JsonViewer;
@@ -1,4 +1,13 @@
1
1
  import React from 'react';
2
- import { MetaAccordionProps } from '../types';
2
+ export interface MetaAccordionProps {
3
+ status: number | null | undefined;
4
+ statusColor: string;
5
+ duration: number | null | undefined;
6
+ size: string;
7
+ triggeredAt: string;
8
+ method: string;
9
+ contentType?: string;
10
+ url: string;
11
+ }
3
12
  declare const MetaAccordion: ({ status, statusColor, duration, size, triggeredAt, method, contentType, url, }: MetaAccordionProps) => React.JSX.Element;
4
13
  export default MetaAccordion;