@buoy-gg/impersonate 7.0.41 → 7.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -80
- package/lib/commonjs/impersonate/components/DataNukeSettings.js +8 -675
- package/lib/commonjs/impersonate/components/ImpersonateBanner.js +1 -221
- package/lib/commonjs/impersonate/components/ImpersonateHistoryList.js +1 -181
- package/lib/commonjs/impersonate/components/ImpersonateModal.js +1 -319
- package/lib/commonjs/impersonate/components/ImpersonateOverlay.js +1 -26
- package/lib/commonjs/impersonate/components/ImpersonateStatusBar.js +1 -130
- package/lib/commonjs/impersonate/components/UserAvatar.js +1 -146
- package/lib/commonjs/impersonate/components/UserCard.js +1 -201
- package/lib/commonjs/impersonate/components/UserSearchView.js +1 -227
- package/lib/commonjs/impersonate/hooks/asyncStoragePeer.js +1 -17
- package/lib/commonjs/impersonate/hooks/asyncStoragePeer.web.js +1 -11
- package/lib/commonjs/impersonate/hooks/useAutoClearAsyncStorage.js +1 -134
- package/lib/commonjs/impersonate/hooks/useAutoClearReactQuery.js +1 -155
- package/lib/commonjs/impersonate/hooks/useAutoClearReactQuery.web.js +1 -20
- package/lib/commonjs/impersonate/hooks/useAutoClearRedux.js +1 -188
- package/lib/commonjs/impersonate/hooks/useAutoClearRedux.web.js +1 -27
- package/lib/commonjs/impersonate/hooks/useImpersonate.js +1 -215
- package/lib/commonjs/impersonate/hooks/useImpersonateHistory.js +1 -56
- package/lib/commonjs/impersonate/types/index.js +1 -16
- package/lib/commonjs/impersonate/types/types.js +1 -1
- package/lib/commonjs/impersonate/utils/impersonateListener.js +1 -350
- package/lib/commonjs/impersonate/utils/impersonateStore.js +1 -689
- package/lib/commonjs/index.js +1 -150
- package/lib/commonjs/preset.js +1 -232
- package/lib/commonjs/sync/impersonateSyncAdapter.js +1 -170
- package/lib/module/impersonate/components/DataNukeSettings.js +8 -670
- package/lib/module/impersonate/components/ImpersonateBanner.js +1 -215
- package/lib/module/impersonate/components/ImpersonateHistoryList.js +1 -176
- package/lib/module/impersonate/components/ImpersonateModal.js +1 -314
- package/lib/module/impersonate/components/ImpersonateOverlay.js +1 -21
- package/lib/module/impersonate/components/ImpersonateStatusBar.js +1 -125
- package/lib/module/impersonate/components/UserAvatar.js +1 -140
- package/lib/module/impersonate/components/UserCard.js +1 -196
- package/lib/module/impersonate/components/UserSearchView.js +1 -222
- package/lib/module/impersonate/hooks/asyncStoragePeer.js +1 -13
- package/lib/module/impersonate/hooks/asyncStoragePeer.web.js +1 -6
- package/lib/module/impersonate/hooks/useAutoClearAsyncStorage.js +1 -130
- package/lib/module/impersonate/hooks/useAutoClearReactQuery.js +1 -151
- package/lib/module/impersonate/hooks/useAutoClearReactQuery.web.js +1 -16
- package/lib/module/impersonate/hooks/useAutoClearRedux.js +1 -183
- package/lib/module/impersonate/hooks/useAutoClearRedux.web.js +1 -22
- package/lib/module/impersonate/hooks/useImpersonate.js +1 -212
- package/lib/module/impersonate/hooks/useImpersonateHistory.js +1 -52
- package/lib/module/impersonate/types/index.js +1 -3
- package/lib/module/impersonate/types/types.js +1 -1
- package/lib/module/impersonate/utils/impersonateListener.js +1 -341
- package/lib/module/impersonate/utils/impersonateStore.js +1 -686
- package/lib/module/index.js +1 -117
- package/lib/module/preset.js +1 -216
- package/lib/module/sync/impersonateSyncAdapter.js +1 -162
- package/lib/web/index.mjs +7 -8
- package/package.json +2 -2
- package/lib/typescript/impersonate/components/DataNukeSettings.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/ImpersonateBanner.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/ImpersonateHistoryList.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/ImpersonateModal.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/ImpersonateOverlay.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/ImpersonateStatusBar.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/UserAvatar.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/UserCard.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/UserSearchView.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/asyncStoragePeer.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/asyncStoragePeer.web.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useAutoClearAsyncStorage.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useAutoClearReactQuery.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useAutoClearReactQuery.web.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useAutoClearRedux.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useAutoClearRedux.web.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useImpersonate.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useImpersonateHistory.d.ts.map +0 -1
- package/lib/typescript/impersonate/types/index.d.ts.map +0 -1
- package/lib/typescript/impersonate/types/types.d.ts.map +0 -1
- package/lib/typescript/impersonate/utils/impersonateListener.d.ts.map +0 -1
- package/lib/typescript/impersonate/utils/impersonateStore.d.ts.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/preset.d.ts.map +0 -1
- package/lib/typescript/sync/impersonateSyncAdapter.d.ts.map +0 -1
|
@@ -1,677 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.DataNukeSettings = DataNukeSettings;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
10
|
-
var _dataViewer = require("@buoy-gg/shared-ui/dataViewer");
|
|
11
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
-
/**
|
|
14
|
-
* DataNukeSettings Component
|
|
15
|
-
*
|
|
16
|
-
* Settings panel for configuring what data to clear on impersonation change.
|
|
17
|
-
* Features Save/Discard/Restore pattern for reliable persistence.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const DEFAULT_HEADER_KEY = "x-impersonate-user-id";
|
|
21
|
-
const DEFAULT_SHOW_BANNER = true;
|
|
22
|
-
const DEFAULT_DATA_NUKE_SETTINGS = {
|
|
23
|
-
reactQuery: true,
|
|
24
|
-
redux: true,
|
|
25
|
-
asyncStorage: false,
|
|
26
|
-
mmkv: false
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Detection status for auto-clear integrations
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
function ToggleRow({
|
|
34
|
-
label,
|
|
35
|
-
description,
|
|
36
|
-
value,
|
|
37
|
-
onChange,
|
|
38
|
-
recommended,
|
|
39
|
-
dangerous,
|
|
40
|
-
detected
|
|
41
|
-
}) {
|
|
42
|
-
const accessory = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
43
|
-
children: [detected !== undefined && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
44
|
-
style: [styles.detectedBadge, detected ? styles.detectedBadgeActive : styles.detectedBadgeInactive],
|
|
45
|
-
children: [detected ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.Check, {
|
|
46
|
-
size: 10,
|
|
47
|
-
color: _sharedUi.buoyColors.success
|
|
48
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.X, {
|
|
49
|
-
size: 10,
|
|
50
|
-
color: _sharedUi.night.color.textTertiary
|
|
51
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
52
|
-
style: [styles.detectedText, detected ? styles.detectedTextActive : styles.detectedTextInactive],
|
|
53
|
-
children: detected ? "Detected" : "Not Detected"
|
|
54
|
-
})]
|
|
55
|
-
}), recommended && detected !== false && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
56
|
-
style: styles.recommendedBadge,
|
|
57
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.Zap, {
|
|
58
|
-
size: 10,
|
|
59
|
-
color: _sharedUi.night.color.accent
|
|
60
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
61
|
-
style: styles.recommendedText,
|
|
62
|
-
children: "Recommended"
|
|
63
|
-
})]
|
|
64
|
-
})]
|
|
65
|
-
});
|
|
66
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.ToggleRow, {
|
|
67
|
-
variant: "plain",
|
|
68
|
-
label: label,
|
|
69
|
-
description: description,
|
|
70
|
-
value: value,
|
|
71
|
-
onValueChange: onChange,
|
|
72
|
-
tone: dangerous ? "warning" : "accent",
|
|
73
|
-
emphasizeLabel: dangerous,
|
|
74
|
-
accessory: accessory
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
function DataNukeSettings({
|
|
78
|
-
headerKey,
|
|
79
|
-
settings,
|
|
80
|
-
showBanner,
|
|
81
|
-
onSave,
|
|
82
|
-
onShowBannerChange,
|
|
83
|
-
detectionStatus
|
|
84
|
-
}) {
|
|
85
|
-
// Local state for editing
|
|
86
|
-
const [localHeaderKey, setLocalHeaderKey] = (0, _react.useState)(headerKey);
|
|
87
|
-
const [localSettings, setLocalSettings] = (0, _react.useState)(settings);
|
|
88
|
-
const [localShowBanner, setLocalShowBanner] = (0, _react.useState)(showBanner);
|
|
89
|
-
const [copySuccess, setCopySuccess] = (0, _react.useState)(false);
|
|
90
|
-
|
|
91
|
-
// Sync local state when props change (e.g., after async load from storage)
|
|
92
|
-
(0, _react.useEffect)(() => {
|
|
93
|
-
setLocalHeaderKey(headerKey);
|
|
94
|
-
}, [headerKey]);
|
|
95
|
-
(0, _react.useEffect)(() => {
|
|
96
|
-
setLocalSettings(settings);
|
|
97
|
-
}, [settings]);
|
|
98
|
-
(0, _react.useEffect)(() => {
|
|
99
|
-
setLocalShowBanner(showBanner);
|
|
100
|
-
}, [showBanner]);
|
|
101
|
-
|
|
102
|
-
// Check if there are unsaved changes
|
|
103
|
-
// Note: showBanner is not included here because it applies immediately
|
|
104
|
-
const hasChanges = (0, _react.useMemo)(() => {
|
|
105
|
-
return localHeaderKey !== headerKey || localSettings.reactQuery !== settings.reactQuery || localSettings.redux !== settings.redux || localSettings.asyncStorage !== settings.asyncStorage || localSettings.mmkv !== settings.mmkv;
|
|
106
|
-
}, [localHeaderKey, localSettings, headerKey, settings]);
|
|
107
|
-
|
|
108
|
-
// Check if current values differ from defaults
|
|
109
|
-
const isDefault = (0, _react.useMemo)(() => {
|
|
110
|
-
return localHeaderKey === DEFAULT_HEADER_KEY && localShowBanner === DEFAULT_SHOW_BANNER && localSettings.reactQuery === DEFAULT_DATA_NUKE_SETTINGS.reactQuery && localSettings.redux === DEFAULT_DATA_NUKE_SETTINGS.redux && localSettings.asyncStorage === DEFAULT_DATA_NUKE_SETTINGS.asyncStorage && localSettings.mmkv === DEFAULT_DATA_NUKE_SETTINGS.mmkv;
|
|
111
|
-
}, [localHeaderKey, localShowBanner, localSettings]);
|
|
112
|
-
const handleSave = () => {
|
|
113
|
-
onSave(localHeaderKey.trim() || DEFAULT_HEADER_KEY, localSettings, localShowBanner);
|
|
114
|
-
};
|
|
115
|
-
const handleDiscard = () => {
|
|
116
|
-
setLocalHeaderKey(headerKey);
|
|
117
|
-
setLocalSettings(settings);
|
|
118
|
-
setLocalShowBanner(showBanner);
|
|
119
|
-
};
|
|
120
|
-
const handleRestoreDefaults = () => {
|
|
121
|
-
setLocalHeaderKey(DEFAULT_HEADER_KEY);
|
|
122
|
-
setLocalSettings(DEFAULT_DATA_NUKE_SETTINGS);
|
|
123
|
-
setLocalShowBanner(DEFAULT_SHOW_BANNER);
|
|
124
|
-
onShowBannerChange(DEFAULT_SHOW_BANNER); // Apply banner change immediately
|
|
125
|
-
};
|
|
126
|
-
const updateLocalSetting = (key, value) => {
|
|
127
|
-
setLocalSettings(prev => ({
|
|
128
|
-
...prev,
|
|
129
|
-
[key]: value
|
|
130
|
-
}));
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
// Config object for DataViewer and copying
|
|
134
|
-
const configData = (0, _react.useMemo)(() => ({
|
|
135
|
-
defaults: {
|
|
136
|
-
headerKey: localHeaderKey,
|
|
137
|
-
showBanner: localShowBanner,
|
|
138
|
-
dataNukeSettings: {
|
|
139
|
-
reactQuery: localSettings.reactQuery,
|
|
140
|
-
redux: localSettings.redux,
|
|
141
|
-
asyncStorage: localSettings.asyncStorage,
|
|
142
|
-
mmkv: localSettings.mmkv
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}), [localHeaderKey, localShowBanner, localSettings]);
|
|
146
|
-
const handleCopyConfig = async () => {
|
|
147
|
-
// Format as JS object literal (not JSON) for direct paste into createImpersonateTool()
|
|
148
|
-
const configString = `defaults: {
|
|
149
|
-
headerKey: '${localHeaderKey}',
|
|
150
|
-
showBanner: ${localShowBanner},
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.DataNukeSettings=DataNukeSettings;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _dataViewer=require("@buoy-gg/shared-ui/dataViewer");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(c,n){if("function"==typeof WeakMap)var l=new WeakMap,u=new WeakMap;return(_interopRequireWildcard=function(o,s){if(!s&&o&&o.__esModule)return o;var t,i,e={__proto__:null,default:o};if(null===o||"object"!=typeof o&&"function"!=typeof o)return e;if(t=s?u:l){if(t.has(o))return t.get(o);t.set(o,e)}for(const a in o)"default"!==a&&{}.hasOwnProperty.call(o,a)&&((i=(t=Object.defineProperty)&&Object.getOwnPropertyDescriptor(o,a))&&(i.get||i.set)?t(e,a,i):e[a]=o[a]);return e})(c,n)}const DEFAULT_HEADER_KEY="x-impersonate-user-id";const DEFAULT_SHOW_BANNER=true;const DEFAULT_DATA_NUKE_SETTINGS={reactQuery:true,redux:true,asyncStorage:false,mmkv:false};function ToggleRow({label:c,description:n,value:l,onChange:u,recommended:o,dangerous:s,detected:t}){const i=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[t!==void 0&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.detectedBadge,t?styles.detectedBadgeActive:styles.detectedBadgeInactive],children:[t?(0,_jsxRuntime.jsx)(_sharedUi.Check,{size:10,color:_sharedUi.buoyColors.success}):(0,_jsxRuntime.jsx)(_sharedUi.X,{size:10,color:_sharedUi.night.color.textTertiary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.detectedText,t?styles.detectedTextActive:styles.detectedTextInactive],children:t?"Detected":"Not Detected"})]}),o&&t!==false&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.recommendedBadge,children:[(0,_jsxRuntime.jsx)(_sharedUi.Zap,{size:10,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.recommendedText,children:"Recommended"})]})]});return(0,_jsxRuntime.jsx)(_sharedUi.ToggleRow,{variant:"plain",label:c,description:n,value:l,onValueChange:u,tone:s?"warning":"accent",emphasizeLabel:s,accessory:i})}function DataNukeSettings({headerKey:c,settings:n,showBanner:l,onSave:u,onShowBannerChange:o,detectionStatus:s}){const[t,i]=(0,_react.useState)(c);const[e,a]=(0,_react.useState)(n);const[d,g]=(0,_react.useState)(l);const[y,x]=(0,_react.useState)(false);(0,_react.useEffect)(()=>{i(c)},[c]);(0,_react.useEffect)(()=>{a(n)},[n]);(0,_react.useEffect)(()=>{g(l)},[l]);const p=(0,_react.useMemo)(()=>{return t!==c||e.reactQuery!==n.reactQuery||e.redux!==n.redux||e.asyncStorage!==n.asyncStorage||e.mmkv!==n.mmkv},[t,e,c,n]);const f=(0,_react.useMemo)(()=>{return t===DEFAULT_HEADER_KEY&&d===DEFAULT_SHOW_BANNER&&e.reactQuery===DEFAULT_DATA_NUKE_SETTINGS.reactQuery&&e.redux===DEFAULT_DATA_NUKE_SETTINGS.redux&&e.asyncStorage===DEFAULT_DATA_NUKE_SETTINGS.asyncStorage&&e.mmkv===DEFAULT_DATA_NUKE_SETTINGS.mmkv},[t,d,e]);const m=()=>{u(t.trim()||DEFAULT_HEADER_KEY,e,d)};const T=()=>{i(c);a(n);g(l)};const b=()=>{i(DEFAULT_HEADER_KEY);a(DEFAULT_DATA_NUKE_SETTINGS);g(DEFAULT_SHOW_BANNER);o(DEFAULT_SHOW_BANNER)};const h=(r,S)=>{a(w=>({...w,[r]:S}))};const C=(0,_react.useMemo)(()=>({defaults:{headerKey:t,showBanner:d,dataNukeSettings:{reactQuery:e.reactQuery,redux:e.redux,asyncStorage:e.asyncStorage,mmkv:e.mmkv}}}),[t,d,e]);const j=async()=>{const r=`defaults: {
|
|
2
|
+
headerKey: '${t}',
|
|
3
|
+
showBanner: ${d},
|
|
151
4
|
dataNukeSettings: {
|
|
152
|
-
reactQuery: ${
|
|
153
|
-
redux: ${
|
|
154
|
-
asyncStorage: ${
|
|
155
|
-
mmkv: ${
|
|
5
|
+
reactQuery: ${e.reactQuery},
|
|
6
|
+
redux: ${e.redux},
|
|
7
|
+
asyncStorage: ${e.asyncStorage},
|
|
8
|
+
mmkv: ${e.mmkv},
|
|
156
9
|
},
|
|
157
|
-
},`;
|
|
158
|
-
try {
|
|
159
|
-
await (0, _sharedUi.copyToClipboard)(configString);
|
|
160
|
-
setCopySuccess(true);
|
|
161
|
-
setTimeout(() => setCopySuccess(false), 2000);
|
|
162
|
-
} catch {
|
|
163
|
-
// Silently fail - user will notice copy didn't work
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.ScrollView, {
|
|
167
|
-
style: styles.container,
|
|
168
|
-
contentContainerStyle: styles.contentContainer,
|
|
169
|
-
children: [hasChanges && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
170
|
-
style: styles.actionBar,
|
|
171
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
172
|
-
style: styles.actionBarContent,
|
|
173
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
174
|
-
style: styles.unsavedText,
|
|
175
|
-
children: "Unsaved changes"
|
|
176
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
177
|
-
style: styles.actionButtons,
|
|
178
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
|
|
179
|
-
style: styles.discardButton,
|
|
180
|
-
onPress: handleDiscard,
|
|
181
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.X, {
|
|
182
|
-
size: 14,
|
|
183
|
-
color: _sharedUi.night.color.textSecondary
|
|
184
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
185
|
-
style: styles.discardButtonText,
|
|
186
|
-
children: "Discard"
|
|
187
|
-
})]
|
|
188
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
|
|
189
|
-
style: styles.saveButton,
|
|
190
|
-
onPress: handleSave,
|
|
191
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.Check, {
|
|
192
|
-
size: 14,
|
|
193
|
-
color: _sharedUi.night.color.onAccent
|
|
194
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
195
|
-
style: styles.saveButtonText,
|
|
196
|
-
children: "Save"
|
|
197
|
-
})]
|
|
198
|
-
})]
|
|
199
|
-
})]
|
|
200
|
-
})
|
|
201
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.CollapsibleSection, {
|
|
202
|
-
title: "Header Configuration",
|
|
203
|
-
icon: _sharedUi.Settings,
|
|
204
|
-
defaultOpen: true,
|
|
205
|
-
variant: "bordered",
|
|
206
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
207
|
-
style: styles.sectionContent,
|
|
208
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
209
|
-
style: styles.inputLabel,
|
|
210
|
-
children: "Header Key"
|
|
211
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TextInput, {
|
|
212
|
-
style: styles.input,
|
|
213
|
-
value: localHeaderKey,
|
|
214
|
-
onChangeText: setLocalHeaderKey,
|
|
215
|
-
placeholder: "x-impersonate-user-id",
|
|
216
|
-
placeholderTextColor: _sharedUi.night.color.placeholder,
|
|
217
|
-
autoCapitalize: "none",
|
|
218
|
-
autoCorrect: false
|
|
219
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
220
|
-
style: styles.inputFooter,
|
|
221
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
222
|
-
style: styles.helperText,
|
|
223
|
-
children: "The HTTP header key used for impersonation. Value will be the user ID."
|
|
224
|
-
}), localHeaderKey !== DEFAULT_HEADER_KEY && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
225
|
-
onPress: () => setLocalHeaderKey(DEFAULT_HEADER_KEY),
|
|
226
|
-
style: styles.resetLink,
|
|
227
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
228
|
-
style: styles.resetLinkText,
|
|
229
|
-
children: "Reset to default"
|
|
230
|
-
})
|
|
231
|
-
})]
|
|
232
|
-
})]
|
|
233
|
-
})
|
|
234
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.CollapsibleSection, {
|
|
235
|
-
title: "Display",
|
|
236
|
-
icon: _sharedUi.Eye,
|
|
237
|
-
defaultOpen: true,
|
|
238
|
-
variant: "bordered",
|
|
239
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
240
|
-
style: styles.sectionContent,
|
|
241
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
242
|
-
style: styles.togglesCard,
|
|
243
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ToggleRow, {
|
|
244
|
-
label: "Floating Banner",
|
|
245
|
-
description: "Show a floating banner when impersonation is active",
|
|
246
|
-
value: localShowBanner,
|
|
247
|
-
onChange: value => {
|
|
248
|
-
setLocalShowBanner(value);
|
|
249
|
-
onShowBannerChange(value); // Apply immediately
|
|
250
|
-
},
|
|
251
|
-
recommended: true
|
|
252
|
-
})
|
|
253
|
-
})
|
|
254
|
-
})
|
|
255
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.CollapsibleSection, {
|
|
256
|
-
title: "Data Clearing",
|
|
257
|
-
icon: _sharedUi.AlertTriangle,
|
|
258
|
-
defaultOpen: true,
|
|
259
|
-
variant: "bordered",
|
|
260
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
261
|
-
style: styles.sectionContent,
|
|
262
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
263
|
-
style: styles.sectionDescription,
|
|
264
|
-
children: "Choose what data to clear when impersonation starts or stops. This ensures you see fresh data for the impersonated user."
|
|
265
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
266
|
-
style: styles.togglesCard,
|
|
267
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ToggleRow, {
|
|
268
|
-
label: "React Query",
|
|
269
|
-
description: "Clear query cache and cancel pending queries",
|
|
270
|
-
value: localSettings.reactQuery,
|
|
271
|
-
onChange: v => updateLocalSetting("reactQuery", v),
|
|
272
|
-
recommended: true,
|
|
273
|
-
detected: detectionStatus?.reactQuery
|
|
274
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
275
|
-
style: styles.divider
|
|
276
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(ToggleRow, {
|
|
277
|
-
label: "Redux",
|
|
278
|
-
description: "Reset Redux store to initial state",
|
|
279
|
-
value: localSettings.redux,
|
|
280
|
-
onChange: v => updateLocalSetting("redux", v),
|
|
281
|
-
recommended: true,
|
|
282
|
-
detected: detectionStatus?.redux
|
|
283
|
-
})]
|
|
284
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
285
|
-
style: styles.advancedSection,
|
|
286
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
287
|
-
style: styles.advancedLabel,
|
|
288
|
-
children: "Storage Options"
|
|
289
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
290
|
-
style: [styles.togglesCard, styles.dangerousCard],
|
|
291
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ToggleRow, {
|
|
292
|
-
label: "AsyncStorage",
|
|
293
|
-
description: "Clear app data (preserves @buoy/* keys)",
|
|
294
|
-
value: localSettings.asyncStorage,
|
|
295
|
-
onChange: v => updateLocalSetting("asyncStorage", v),
|
|
296
|
-
dangerous: true,
|
|
297
|
-
detected: detectionStatus?.asyncStorage
|
|
298
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
299
|
-
style: styles.divider
|
|
300
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(ToggleRow, {
|
|
301
|
-
label: "MMKV",
|
|
302
|
-
description: "Clear MMKV storage (preserves @buoy/* keys)",
|
|
303
|
-
value: localSettings.mmkv,
|
|
304
|
-
onChange: v => updateLocalSetting("mmkv", v),
|
|
305
|
-
dangerous: true,
|
|
306
|
-
detected: detectionStatus?.mmkv
|
|
307
|
-
})]
|
|
308
|
-
})]
|
|
309
|
-
}), (localSettings.asyncStorage || localSettings.mmkv) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
310
|
-
style: styles.warningCard,
|
|
311
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.AlertTriangle, {
|
|
312
|
-
size: 16,
|
|
313
|
-
color: _sharedUi.night.color.warning
|
|
314
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
315
|
-
style: styles.warningContent,
|
|
316
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
317
|
-
style: styles.warningTitle,
|
|
318
|
-
children: "Storage Clearing Enabled"
|
|
319
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
320
|
-
style: styles.warningText,
|
|
321
|
-
children: "This will remove app data like settings and cached content. Auth tokens managed by @buoy/* are preserved."
|
|
322
|
-
})]
|
|
323
|
-
})]
|
|
324
|
-
})]
|
|
325
|
-
})
|
|
326
|
-
}), !isDefault && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
|
|
327
|
-
style: styles.restoreButton,
|
|
328
|
-
onPress: handleRestoreDefaults,
|
|
329
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.RefreshCw, {
|
|
330
|
-
size: 14,
|
|
331
|
-
color: _sharedUi.night.color.textSecondary
|
|
332
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
333
|
-
style: styles.restoreButtonText,
|
|
334
|
-
children: "Restore Defaults"
|
|
335
|
-
})]
|
|
336
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.CollapsibleSection, {
|
|
337
|
-
title: "How It Works",
|
|
338
|
-
icon: _sharedUi.Info,
|
|
339
|
-
defaultOpen: false,
|
|
340
|
-
variant: "bordered",
|
|
341
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
342
|
-
style: styles.sectionContent,
|
|
343
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
344
|
-
style: styles.infoText,
|
|
345
|
-
children: "When impersonation is enabled, the configured header is automatically added to all outgoing fetch and XMLHttpRequest calls."
|
|
346
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
347
|
-
style: [styles.infoText, styles.infoTextSpaced],
|
|
348
|
-
children: "Your backend should check for this header and return data for the specified user ID instead of the authenticated user."
|
|
349
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
350
|
-
style: styles.codeBlock,
|
|
351
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
352
|
-
style: styles.codeComment,
|
|
353
|
-
children: "// Example request header"
|
|
354
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
|
|
355
|
-
style: styles.codeText,
|
|
356
|
-
children: [localHeaderKey || "x-impersonate-user-id", ": ", /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
357
|
-
style: styles.codeValue,
|
|
358
|
-
children: "user_123"
|
|
359
|
-
})]
|
|
360
|
-
})]
|
|
361
|
-
})]
|
|
362
|
-
})
|
|
363
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.CollapsibleSection, {
|
|
364
|
-
title: "Export Configuration",
|
|
365
|
-
icon: _sharedUi.Copy,
|
|
366
|
-
defaultOpen: false,
|
|
367
|
-
variant: "bordered",
|
|
368
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
369
|
-
style: styles.sectionContent,
|
|
370
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
371
|
-
style: styles.infoText,
|
|
372
|
-
children: "Copy current settings to use in createImpersonateTool()."
|
|
373
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
374
|
-
style: styles.dataViewerContainer,
|
|
375
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataViewer.DataViewer, {
|
|
376
|
-
title: "",
|
|
377
|
-
data: configData,
|
|
378
|
-
showTypeFilter: true,
|
|
379
|
-
rawMode: true,
|
|
380
|
-
initialExpanded: true
|
|
381
|
-
})
|
|
382
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
383
|
-
style: styles.copyButton,
|
|
384
|
-
onPress: handleCopyConfig,
|
|
385
|
-
children: copySuccess ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
386
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.Check, {
|
|
387
|
-
size: 14,
|
|
388
|
-
color: _sharedUi.buoyColors.success
|
|
389
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
390
|
-
style: [styles.copyButtonText, styles.copySuccessText],
|
|
391
|
-
children: "Copied!"
|
|
392
|
-
})]
|
|
393
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
394
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.Copy, {
|
|
395
|
-
size: 14,
|
|
396
|
-
color: _sharedUi.night.color.accent
|
|
397
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
398
|
-
style: styles.copyButtonText,
|
|
399
|
-
children: "Copy Config"
|
|
400
|
-
})]
|
|
401
|
-
})
|
|
402
|
-
})]
|
|
403
|
-
})
|
|
404
|
-
})]
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
const styles = _reactNative.StyleSheet.create({
|
|
408
|
-
container: {
|
|
409
|
-
flex: 1
|
|
410
|
-
},
|
|
411
|
-
contentContainer: {
|
|
412
|
-
padding: 16,
|
|
413
|
-
gap: 12,
|
|
414
|
-
paddingBottom: 32
|
|
415
|
-
},
|
|
416
|
-
actionBar: {
|
|
417
|
-
backgroundColor: _sharedUi.night.color.accentSoft,
|
|
418
|
-
borderRadius: 10,
|
|
419
|
-
borderWidth: 1,
|
|
420
|
-
borderColor: _sharedUi.night.color.accentBorder,
|
|
421
|
-
padding: 12
|
|
422
|
-
},
|
|
423
|
-
actionBarContent: {
|
|
424
|
-
flexDirection: "row",
|
|
425
|
-
alignItems: "center",
|
|
426
|
-
justifyContent: "space-between"
|
|
427
|
-
},
|
|
428
|
-
unsavedText: {
|
|
429
|
-
fontSize: 13,
|
|
430
|
-
fontWeight: "500",
|
|
431
|
-
color: _sharedUi.night.color.accent
|
|
432
|
-
},
|
|
433
|
-
actionButtons: {
|
|
434
|
-
flexDirection: "row",
|
|
435
|
-
gap: 8
|
|
436
|
-
},
|
|
437
|
-
saveButton: {
|
|
438
|
-
flexDirection: "row",
|
|
439
|
-
alignItems: "center",
|
|
440
|
-
gap: 6,
|
|
441
|
-
backgroundColor: _sharedUi.night.color.accent,
|
|
442
|
-
paddingHorizontal: 14,
|
|
443
|
-
paddingVertical: 8,
|
|
444
|
-
borderRadius: 6
|
|
445
|
-
},
|
|
446
|
-
saveButtonText: {
|
|
447
|
-
fontSize: 13,
|
|
448
|
-
fontWeight: "600",
|
|
449
|
-
// Ink on a filled accent surface — the night accent takes dark ink.
|
|
450
|
-
color: _sharedUi.night.color.onAccent
|
|
451
|
-
},
|
|
452
|
-
discardButton: {
|
|
453
|
-
flexDirection: "row",
|
|
454
|
-
alignItems: "center",
|
|
455
|
-
gap: 6,
|
|
456
|
-
backgroundColor: _sharedUi.night.color.surfaceElevated,
|
|
457
|
-
paddingHorizontal: 14,
|
|
458
|
-
paddingVertical: 8,
|
|
459
|
-
borderRadius: 6,
|
|
460
|
-
borderWidth: 1,
|
|
461
|
-
borderColor: _sharedUi.night.color.border
|
|
462
|
-
},
|
|
463
|
-
discardButtonText: {
|
|
464
|
-
fontSize: 13,
|
|
465
|
-
fontWeight: "500",
|
|
466
|
-
color: _sharedUi.night.color.textSecondary
|
|
467
|
-
},
|
|
468
|
-
restoreButton: {
|
|
469
|
-
flexDirection: "row",
|
|
470
|
-
alignItems: "center",
|
|
471
|
-
justifyContent: "center",
|
|
472
|
-
gap: 8,
|
|
473
|
-
paddingVertical: 12,
|
|
474
|
-
borderRadius: 8,
|
|
475
|
-
borderWidth: 1,
|
|
476
|
-
borderColor: _sharedUi.night.color.border,
|
|
477
|
-
borderStyle: "dashed"
|
|
478
|
-
},
|
|
479
|
-
restoreButtonText: {
|
|
480
|
-
fontSize: 13,
|
|
481
|
-
color: _sharedUi.night.color.textSecondary
|
|
482
|
-
},
|
|
483
|
-
sectionContent: {
|
|
484
|
-
paddingTop: 8
|
|
485
|
-
},
|
|
486
|
-
sectionDescription: {
|
|
487
|
-
fontSize: 13,
|
|
488
|
-
color: _sharedUi.night.color.textSecondary,
|
|
489
|
-
lineHeight: 18,
|
|
490
|
-
marginBottom: 14
|
|
491
|
-
},
|
|
492
|
-
togglesCard: {
|
|
493
|
-
backgroundColor: _sharedUi.night.color.surface,
|
|
494
|
-
borderRadius: 10,
|
|
495
|
-
borderWidth: 1,
|
|
496
|
-
borderColor: _sharedUi.night.color.border,
|
|
497
|
-
padding: 4
|
|
498
|
-
},
|
|
499
|
-
dangerousCard: {
|
|
500
|
-
borderColor: _sharedUi.night.color.warning + "30"
|
|
501
|
-
},
|
|
502
|
-
advancedSection: {
|
|
503
|
-
marginTop: 16
|
|
504
|
-
},
|
|
505
|
-
advancedLabel: {
|
|
506
|
-
fontSize: 11,
|
|
507
|
-
fontWeight: "600",
|
|
508
|
-
color: _sharedUi.night.color.textTertiary,
|
|
509
|
-
textTransform: "uppercase",
|
|
510
|
-
letterSpacing: 0.5,
|
|
511
|
-
marginBottom: 8,
|
|
512
|
-
marginLeft: 2
|
|
513
|
-
},
|
|
514
|
-
inputLabel: {
|
|
515
|
-
fontSize: 12,
|
|
516
|
-
fontWeight: "600",
|
|
517
|
-
color: _sharedUi.night.color.textSecondary,
|
|
518
|
-
marginBottom: 8
|
|
519
|
-
},
|
|
520
|
-
input: {
|
|
521
|
-
height: 42,
|
|
522
|
-
backgroundColor: _sharedUi.night.color.surfaceElevated,
|
|
523
|
-
borderRadius: 8,
|
|
524
|
-
borderWidth: 1,
|
|
525
|
-
borderColor: _sharedUi.night.color.border,
|
|
526
|
-
paddingHorizontal: 14,
|
|
527
|
-
fontSize: 14,
|
|
528
|
-
color: _sharedUi.night.color.text,
|
|
529
|
-
fontFamily: _sharedUi.monoFont
|
|
530
|
-
},
|
|
531
|
-
inputFooter: {
|
|
532
|
-
flexDirection: "row",
|
|
533
|
-
justifyContent: "space-between",
|
|
534
|
-
alignItems: "flex-start",
|
|
535
|
-
marginTop: 8,
|
|
536
|
-
gap: 12
|
|
537
|
-
},
|
|
538
|
-
helperText: {
|
|
539
|
-
flex: 1,
|
|
540
|
-
fontSize: 12,
|
|
541
|
-
color: _sharedUi.night.color.textTertiary,
|
|
542
|
-
lineHeight: 16
|
|
543
|
-
},
|
|
544
|
-
resetLink: {
|
|
545
|
-
paddingVertical: 2
|
|
546
|
-
},
|
|
547
|
-
resetLinkText: {
|
|
548
|
-
fontSize: 12,
|
|
549
|
-
color: _sharedUi.night.color.accent,
|
|
550
|
-
fontWeight: "500"
|
|
551
|
-
},
|
|
552
|
-
recommendedBadge: {
|
|
553
|
-
flexDirection: "row",
|
|
554
|
-
alignItems: "center",
|
|
555
|
-
gap: 4,
|
|
556
|
-
backgroundColor: _sharedUi.night.color.accentSoft,
|
|
557
|
-
paddingHorizontal: 8,
|
|
558
|
-
paddingVertical: 3,
|
|
559
|
-
borderRadius: 4
|
|
560
|
-
},
|
|
561
|
-
recommendedText: {
|
|
562
|
-
fontSize: 10,
|
|
563
|
-
fontWeight: "600",
|
|
564
|
-
color: _sharedUi.night.color.accent
|
|
565
|
-
},
|
|
566
|
-
detectedBadge: {
|
|
567
|
-
flexDirection: "row",
|
|
568
|
-
alignItems: "center",
|
|
569
|
-
gap: 4,
|
|
570
|
-
paddingHorizontal: 8,
|
|
571
|
-
paddingVertical: 3,
|
|
572
|
-
borderRadius: 4
|
|
573
|
-
},
|
|
574
|
-
detectedBadgeActive: {
|
|
575
|
-
backgroundColor: _sharedUi.buoyColors.success + "15"
|
|
576
|
-
},
|
|
577
|
-
detectedBadgeInactive: {
|
|
578
|
-
backgroundColor: _sharedUi.night.color.textTertiary + "15"
|
|
579
|
-
},
|
|
580
|
-
detectedText: {
|
|
581
|
-
fontSize: 10,
|
|
582
|
-
fontWeight: "600"
|
|
583
|
-
},
|
|
584
|
-
detectedTextActive: {
|
|
585
|
-
color: _sharedUi.buoyColors.success
|
|
586
|
-
},
|
|
587
|
-
detectedTextInactive: {
|
|
588
|
-
color: _sharedUi.night.color.textTertiary
|
|
589
|
-
},
|
|
590
|
-
divider: {
|
|
591
|
-
height: 1,
|
|
592
|
-
backgroundColor: _sharedUi.night.color.separator,
|
|
593
|
-
marginHorizontal: 12
|
|
594
|
-
},
|
|
595
|
-
warningCard: {
|
|
596
|
-
marginTop: 14,
|
|
597
|
-
flexDirection: "row",
|
|
598
|
-
alignItems: "flex-start",
|
|
599
|
-
gap: 12,
|
|
600
|
-
backgroundColor: _sharedUi.night.color.warningSoft,
|
|
601
|
-
borderRadius: 10,
|
|
602
|
-
borderWidth: 1,
|
|
603
|
-
borderColor: _sharedUi.night.color.warning + "25",
|
|
604
|
-
padding: 14
|
|
605
|
-
},
|
|
606
|
-
warningContent: {
|
|
607
|
-
flex: 1
|
|
608
|
-
},
|
|
609
|
-
warningTitle: {
|
|
610
|
-
fontSize: 13,
|
|
611
|
-
fontWeight: "600",
|
|
612
|
-
color: _sharedUi.night.color.warning,
|
|
613
|
-
marginBottom: 4
|
|
614
|
-
},
|
|
615
|
-
warningText: {
|
|
616
|
-
fontSize: 12,
|
|
617
|
-
color: _sharedUi.night.color.textSecondary,
|
|
618
|
-
lineHeight: 17
|
|
619
|
-
},
|
|
620
|
-
infoText: {
|
|
621
|
-
fontSize: 13,
|
|
622
|
-
color: _sharedUi.night.color.textSecondary,
|
|
623
|
-
lineHeight: 19
|
|
624
|
-
},
|
|
625
|
-
infoTextSpaced: {
|
|
626
|
-
marginTop: 10
|
|
627
|
-
},
|
|
628
|
-
codeBlock: {
|
|
629
|
-
marginTop: 14,
|
|
630
|
-
// Inset code box — darker than the card, the night track color.
|
|
631
|
-
backgroundColor: _sharedUi.night.color.bg,
|
|
632
|
-
borderRadius: 8,
|
|
633
|
-
padding: 14
|
|
634
|
-
},
|
|
635
|
-
codeComment: {
|
|
636
|
-
fontSize: 12,
|
|
637
|
-
color: _sharedUi.night.color.textTertiary,
|
|
638
|
-
fontFamily: _sharedUi.monoFont,
|
|
639
|
-
marginBottom: 6
|
|
640
|
-
},
|
|
641
|
-
codeText: {
|
|
642
|
-
fontSize: 13,
|
|
643
|
-
color: _sharedUi.night.color.text,
|
|
644
|
-
fontFamily: _sharedUi.monoFont
|
|
645
|
-
},
|
|
646
|
-
codeValue: {
|
|
647
|
-
color: _sharedUi.night.color.accent
|
|
648
|
-
},
|
|
649
|
-
dataViewerContainer: {
|
|
650
|
-
marginTop: 12,
|
|
651
|
-
borderRadius: 8,
|
|
652
|
-
overflow: "hidden",
|
|
653
|
-
borderWidth: 1,
|
|
654
|
-
borderColor: _sharedUi.night.color.border
|
|
655
|
-
},
|
|
656
|
-
copyButton: {
|
|
657
|
-
flexDirection: "row",
|
|
658
|
-
alignItems: "center",
|
|
659
|
-
justifyContent: "center",
|
|
660
|
-
gap: 8,
|
|
661
|
-
marginTop: 14,
|
|
662
|
-
backgroundColor: _sharedUi.night.color.accentSoft,
|
|
663
|
-
paddingVertical: 10,
|
|
664
|
-
paddingHorizontal: 16,
|
|
665
|
-
borderRadius: 8,
|
|
666
|
-
borderWidth: 1,
|
|
667
|
-
borderColor: _sharedUi.night.color.accentBorder
|
|
668
|
-
},
|
|
669
|
-
copyButtonText: {
|
|
670
|
-
fontSize: 13,
|
|
671
|
-
fontWeight: "600",
|
|
672
|
-
color: _sharedUi.night.color.accent
|
|
673
|
-
},
|
|
674
|
-
copySuccessText: {
|
|
675
|
-
color: _sharedUi.buoyColors.success
|
|
676
|
-
}
|
|
677
|
-
});
|
|
10
|
+
},`;try{await(0,_sharedUi.copyToClipboard)(r);x(true);setTimeout(()=>x(false),2e3)}catch{}};return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.container,contentContainerStyle:styles.contentContainer,children:[p&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.actionBar,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.actionBarContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.unsavedText,children:"Unsaved changes"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.actionButtons,children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{style:styles.discardButton,onPress:T,children:[(0,_jsxRuntime.jsx)(_sharedUi.X,{size:14,color:_sharedUi.night.color.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.discardButtonText,children:"Discard"})]}),(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{style:styles.saveButton,onPress:m,children:[(0,_jsxRuntime.jsx)(_sharedUi.Check,{size:14,color:_sharedUi.night.color.onAccent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.saveButtonText,children:"Save"})]})]})]})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Header Configuration",icon:_sharedUi.Settings,defaultOpen:true,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.inputLabel,children:"Header Key"}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{style:styles.input,value:t,onChangeText:i,placeholder:"x-impersonate-user-id",placeholderTextColor:_sharedUi.night.color.placeholder,autoCapitalize:"none",autoCorrect:false}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.inputFooter,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.helperText,children:"The HTTP header key used for impersonation. Value will be the user ID."}),t!==DEFAULT_HEADER_KEY&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>i(DEFAULT_HEADER_KEY),style:styles.resetLink,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.resetLinkText,children:"Reset to default"})})]})]})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Display",icon:_sharedUi.Eye,defaultOpen:true,variant:"bordered",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.sectionContent,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.togglesCard,children:(0,_jsxRuntime.jsx)(ToggleRow,{label:"Floating Banner",description:"Show a floating banner when impersonation is active",value:d,onChange:r=>{g(r);o(r)},recommended:true})})})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Data Clearing",icon:_sharedUi.AlertTriangle,defaultOpen:true,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sectionDescription,children:"Choose what data to clear when impersonation starts or stops. This ensures you see fresh data for the impersonated user."}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.togglesCard,children:[(0,_jsxRuntime.jsx)(ToggleRow,{label:"React Query",description:"Clear query cache and cancel pending queries",value:e.reactQuery,onChange:r=>h("reactQuery",r),recommended:true,detected:s?.reactQuery}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.divider}),(0,_jsxRuntime.jsx)(ToggleRow,{label:"Redux",description:"Reset Redux store to initial state",value:e.redux,onChange:r=>h("redux",r),recommended:true,detected:s?.redux})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.advancedSection,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.advancedLabel,children:"Storage Options"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.togglesCard,styles.dangerousCard],children:[(0,_jsxRuntime.jsx)(ToggleRow,{label:"AsyncStorage",description:"Clear app data (preserves @buoy/* keys)",value:e.asyncStorage,onChange:r=>h("asyncStorage",r),dangerous:true,detected:s?.asyncStorage}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.divider}),(0,_jsxRuntime.jsx)(ToggleRow,{label:"MMKV",description:"Clear MMKV storage (preserves @buoy/* keys)",value:e.mmkv,onChange:r=>h("mmkv",r),dangerous:true,detected:s?.mmkv})]})]}),(e.asyncStorage||e.mmkv)&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warningCard,children:[(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:16,color:_sharedUi.night.color.warning}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warningContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningTitle,children:"Storage Clearing Enabled"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningText,children:"This will remove app data like settings and cached content. Auth tokens managed by @buoy/* are preserved."})]})]})]})}),!f&&(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{style:styles.restoreButton,onPress:b,children:[(0,_jsxRuntime.jsx)(_sharedUi.RefreshCw,{size:14,color:_sharedUi.night.color.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.restoreButtonText,children:"Restore Defaults"})]}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"How It Works",icon:_sharedUi.Info,defaultOpen:false,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.infoText,children:"When impersonation is enabled, the configured header is automatically added to all outgoing fetch and XMLHttpRequest calls."}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.infoText,styles.infoTextSpaced],children:"Your backend should check for this header and return data for the specified user ID instead of the authenticated user."}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.codeBlock,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.codeComment,children:"// Example request header"}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.codeText,children:[t||"x-impersonate-user-id",": ",(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.codeValue,children:"user_123"})]})]})]})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Export Configuration",icon:_sharedUi.Copy,defaultOpen:false,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.infoText,children:"Copy current settings to use in createImpersonateTool()."}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.dataViewerContainer,children:(0,_jsxRuntime.jsx)(_dataViewer.DataViewer,{title:"",data:C,showTypeFilter:true,rawMode:true,initialExpanded:true})}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.copyButton,onPress:j,children:y?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_sharedUi.Check,{size:14,color:_sharedUi.buoyColors.success}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.copyButtonText,styles.copySuccessText],children:"Copied!"})]}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_sharedUi.Copy,{size:14,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.copyButtonText,children:"Copy Config"})]})})]})})]})}const styles=_reactNative.StyleSheet.create({container:{flex:1},contentContainer:{padding:16,gap:12,paddingBottom:32},actionBar:{backgroundColor:_sharedUi.night.color.accentSoft,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.accentBorder,padding:12},actionBarContent:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},unsavedText:{fontSize:13,fontWeight:"500",color:_sharedUi.night.color.accent},actionButtons:{flexDirection:"row",gap:8},saveButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:_sharedUi.night.color.accent,paddingHorizontal:14,paddingVertical:8,borderRadius:6},saveButtonText:{fontSize:13,fontWeight:"600",color:_sharedUi.night.color.onAccent},discardButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:_sharedUi.night.color.surfaceElevated,paddingHorizontal:14,paddingVertical:8,borderRadius:6,borderWidth:1,borderColor:_sharedUi.night.color.border},discardButtonText:{fontSize:13,fontWeight:"500",color:_sharedUi.night.color.textSecondary},restoreButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,paddingVertical:12,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,borderStyle:"dashed"},restoreButtonText:{fontSize:13,color:_sharedUi.night.color.textSecondary},sectionContent:{paddingTop:8},sectionDescription:{fontSize:13,color:_sharedUi.night.color.textSecondary,lineHeight:18,marginBottom:14},togglesCard:{backgroundColor:_sharedUi.night.color.surface,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.border,padding:4},dangerousCard:{borderColor:_sharedUi.night.color.warning+"30"},advancedSection:{marginTop:16},advancedLabel:{fontSize:11,fontWeight:"600",color:_sharedUi.night.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,marginBottom:8,marginLeft:2},inputLabel:{fontSize:12,fontWeight:"600",color:_sharedUi.night.color.textSecondary,marginBottom:8},input:{height:42,backgroundColor:_sharedUi.night.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,paddingHorizontal:14,fontSize:14,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},inputFooter:{flexDirection:"row",justifyContent:"space-between",alignItems:"flex-start",marginTop:8,gap:12},helperText:{flex:1,fontSize:12,color:_sharedUi.night.color.textTertiary,lineHeight:16},resetLink:{paddingVertical:2},resetLinkText:{fontSize:12,color:_sharedUi.night.color.accent,fontWeight:"500"},recommendedBadge:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:_sharedUi.night.color.accentSoft,paddingHorizontal:8,paddingVertical:3,borderRadius:4},recommendedText:{fontSize:10,fontWeight:"600",color:_sharedUi.night.color.accent},detectedBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4},detectedBadgeActive:{backgroundColor:_sharedUi.buoyColors.success+"15"},detectedBadgeInactive:{backgroundColor:_sharedUi.night.color.textTertiary+"15"},detectedText:{fontSize:10,fontWeight:"600"},detectedTextActive:{color:_sharedUi.buoyColors.success},detectedTextInactive:{color:_sharedUi.night.color.textTertiary},divider:{height:1,backgroundColor:_sharedUi.night.color.separator,marginHorizontal:12},warningCard:{marginTop:14,flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:_sharedUi.night.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:13,fontWeight:"600",color:_sharedUi.night.color.warning,marginBottom:4},warningText:{fontSize:12,color:_sharedUi.night.color.textSecondary,lineHeight:17},infoText:{fontSize:13,color:_sharedUi.night.color.textSecondary,lineHeight:19},infoTextSpaced:{marginTop:10},codeBlock:{marginTop:14,backgroundColor:_sharedUi.night.color.bg,borderRadius:8,padding:14},codeComment:{fontSize:12,color:_sharedUi.night.color.textTertiary,fontFamily:_sharedUi.monoFont,marginBottom:6},codeText:{fontSize:13,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},codeValue:{color:_sharedUi.night.color.accent},dataViewerContainer:{marginTop:12,borderRadius:8,overflow:"hidden",borderWidth:1,borderColor:_sharedUi.night.color.border},copyButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,marginTop:14,backgroundColor:_sharedUi.night.color.accentSoft,paddingVertical:10,paddingHorizontal:16,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.accentBorder},copyButtonText:{fontSize:13,fontWeight:"600",color:_sharedUi.night.color.accent},copySuccessText:{color:_sharedUi.buoyColors.success}});
|