react-native-ai-devtools 1.4.26 → 1.4.27
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.
|
@@ -3,15 +3,15 @@ import { getNextMessageId } from "./state.js";
|
|
|
3
3
|
import { trackAppDetection } from "./telemetry.js";
|
|
4
4
|
const DETECTION_TIMEOUT_MS = 3000;
|
|
5
5
|
const DETECTION_DELAY_MS = 500;
|
|
6
|
-
// Detection expression —
|
|
7
|
-
//
|
|
6
|
+
// Detection expression — synchronous IIFE (awaitPromise does not work reliably with Hermes CDP).
|
|
7
|
+
// Runs after a 500ms delay (see scheduleAppDetection) so the RN module system is initialized.
|
|
8
8
|
// Fallback paths for PlatformConstants:
|
|
9
9
|
// 1. nativeModuleProxy.PlatformConstants (Bridgeless / New Arch)
|
|
10
10
|
// 2. __turboModuleProxy('PlatformConstants') (TurboModules)
|
|
11
11
|
// 3. __fbBatchedBridgeConfig.remoteModuleConfig (Old Arch Bridge — inlined constants)
|
|
12
12
|
// 4. nativeRequireModuleConfig (Old Arch Bridge — lazy load)
|
|
13
13
|
// Always returns arch/engine even when version is unavailable.
|
|
14
|
-
const DETECTION_EXPRESSION = `
|
|
14
|
+
const DETECTION_EXPRESSION = `(function(){
|
|
15
15
|
var r={},c=null,p=globalThis.nativeModuleProxy;
|
|
16
16
|
if(p&&p.PlatformConstants){c=typeof p.PlatformConstants.getConstants==='function'?p.PlatformConstants.getConstants():p.PlatformConstants}
|
|
17
17
|
if(!c&&typeof globalThis.__turboModuleProxy==='function'){try{var tm=globalThis.__turboModuleProxy('PlatformConstants');if(tm)c=typeof tm.getConstants==='function'?tm.getConstants():tm}catch(e){}}
|
|
@@ -22,7 +22,7 @@ r.newArch=typeof globalThis.nativeFabricUIManager==='object';
|
|
|
22
22
|
r.hermes=typeof globalThis.HermesInternal!=='undefined';
|
|
23
23
|
var ep=p&&p.ExpoConstants;if(!ep&&typeof globalThis.__turboModuleProxy==='function'){try{ep=globalThis.__turboModuleProxy('ExpoConstants')}catch(e){}}
|
|
24
24
|
if(ep){try{var ec=typeof ep.getConstants==='function'?ep.getConstants():ep;if(ec&&ec.expoConfig&&ec.expoConfig.sdkVersion)r.expoSdk=ec.expoConfig.sdkVersion}catch(e){}}
|
|
25
|
-
return r})`;
|
|
25
|
+
return r})()`;
|
|
26
26
|
function formatVersion(v) {
|
|
27
27
|
return `${v.major}.${v.minor}.${v.patch}`;
|
|
28
28
|
}
|
|
@@ -106,7 +106,6 @@ function detectApp(ws) {
|
|
|
106
106
|
params: {
|
|
107
107
|
expression: DETECTION_EXPRESSION,
|
|
108
108
|
returnByValue: true,
|
|
109
|
-
awaitPromise: true,
|
|
110
109
|
userGesture: true,
|
|
111
110
|
generatePreview: false,
|
|
112
111
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appDetection.js","sourceRoot":"","sources":["../../src/core/appDetection.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,IAAI,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGnD,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAClC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B,
|
|
1
|
+
{"version":3,"file":"appDetection.js","sourceRoot":"","sources":["../../src/core/appDetection.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,IAAI,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGnD,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAClC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B,iGAAiG;AACjG,8FAA8F;AAC9F,wCAAwC;AACxC,iEAAiE;AACjE,4DAA4D;AAC5D,sFAAsF;AACtF,6DAA6D;AAC7D,+DAA+D;AA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BtF;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAqCzE;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CA4ErF;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,cAAc,CAChC,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,OAAO,GAAE;IACL,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACd,GACP,OAAO,CAAC,eAAe,CAAC,CA2M1B"}
|
package/build/core/executor.js
CHANGED
|
@@ -158,11 +158,21 @@ async function executeExpressionCore(expression, awaitPromise, timeoutMs = 10000
|
|
|
158
158
|
return { success: false, error: validation.error };
|
|
159
159
|
}
|
|
160
160
|
const cleanedExpression = validation.expression;
|
|
161
|
+
// Hermes CDP does not support awaitPromise — it serializes the Promise's
|
|
162
|
+
// internal fields (_A, _x, _y, _z) instead of waiting for resolution.
|
|
163
|
+
// When the caller wants awaitPromise, we handle it ourselves: wrap the
|
|
164
|
+
// expression to store the resolved value in a temp global, then poll.
|
|
165
|
+
if (awaitPromise) {
|
|
166
|
+
return executeWithManualAwait(app, cleanedExpression, timeoutMs);
|
|
167
|
+
}
|
|
168
|
+
return executeCDP(app, cleanedExpression, false, timeoutMs);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Execute a CDP Runtime.evaluate call (no promise awaiting).
|
|
172
|
+
*/
|
|
173
|
+
function executeCDP(app, cleanedExpression, awaitPromise, timeoutMs) {
|
|
161
174
|
const TIMEOUT_MS = timeoutMs;
|
|
162
175
|
const currentMessageId = getNextMessageId();
|
|
163
|
-
// Prepend global polyfill for Hermes compatibility
|
|
164
|
-
// Runtime.evaluate returns the completion value of the last expression naturally,
|
|
165
|
-
// so no IIFE wrapping is needed (similar to browser console behavior)
|
|
166
176
|
const wrappedExpression = `${GLOBAL_POLYFILL} ${cleanedExpression}`;
|
|
167
177
|
return new Promise((resolve) => {
|
|
168
178
|
const timeoutId = setTimeout(() => {
|
|
@@ -217,6 +227,63 @@ async function executeExpressionCore(expression, awaitPromise, timeoutMs = 10000
|
|
|
217
227
|
}
|
|
218
228
|
});
|
|
219
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* Hermes workaround for awaitPromise: execute the expression, and if it
|
|
232
|
+
* returns a Promise, store the resolved/rejected value in a temp global
|
|
233
|
+
* and read it back with a small number of spaced-out retries.
|
|
234
|
+
*/
|
|
235
|
+
async function executeWithManualAwait(app, cleanedExpression, timeoutMs) {
|
|
236
|
+
const slotId = `__rn_dbg_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
237
|
+
// Wrap: run the expression, if result is thenable store resolved value in
|
|
238
|
+
// a temp global slot; otherwise store the sync value immediately.
|
|
239
|
+
const wrapperExpr = `(function(){
|
|
240
|
+
var __v=(${cleanedExpression});
|
|
241
|
+
if(__v&&typeof __v==='object'&&typeof __v.then==='function'){
|
|
242
|
+
globalThis['${slotId}']={s:'pending'};
|
|
243
|
+
__v.then(function(r){globalThis['${slotId}']={s:'ok',v:r}},function(e){globalThis['${slotId}']={s:'err',v:String(e)}});
|
|
244
|
+
return '__awaiting__'}
|
|
245
|
+
else{return __v}})()`;
|
|
246
|
+
const initial = await executeCDP(app, wrapperExpr, false, timeoutMs);
|
|
247
|
+
// If the expression didn't return a Promise, return the result directly
|
|
248
|
+
if (!initial.success || initial.result !== "__awaiting__") {
|
|
249
|
+
return initial;
|
|
250
|
+
}
|
|
251
|
+
// Read the settled value with a few spaced-out retries (not aggressive polling).
|
|
252
|
+
// Most Promises resolve within a microtask or a single event loop tick.
|
|
253
|
+
const RETRY_DELAYS_MS = [100, 300, 600, 1000, 2000, 3000];
|
|
254
|
+
const readExpr = `(function(){var s=globalThis['${slotId}'];if(!s||s.s==='pending')return '__pending__';delete globalThis['${slotId}'];return{status:s.s,value:s.v}})()`;
|
|
255
|
+
for (const delayMs of RETRY_DELAYS_MS) {
|
|
256
|
+
await new Promise((r) => setTimeout(r, delayMs));
|
|
257
|
+
const poll = await executeCDP(app, readExpr, false, 5000);
|
|
258
|
+
if (!poll.success)
|
|
259
|
+
return poll;
|
|
260
|
+
if (poll.result === "__pending__")
|
|
261
|
+
continue;
|
|
262
|
+
// The poll result comes through formatRemoteObject — objects are
|
|
263
|
+
// JSON.stringified, so we need to parse it back.
|
|
264
|
+
try {
|
|
265
|
+
const parsed = typeof poll.result === "string" ? JSON.parse(poll.result) : poll.result;
|
|
266
|
+
if (parsed?.status === "err") {
|
|
267
|
+
return { success: false, error: parsed.value || "Promise rejected" };
|
|
268
|
+
}
|
|
269
|
+
const value = parsed?.value;
|
|
270
|
+
return {
|
|
271
|
+
success: true,
|
|
272
|
+
result: value === undefined || value === null
|
|
273
|
+
? String(value)
|
|
274
|
+
: typeof value === "object"
|
|
275
|
+
? JSON.stringify(value, null, 2)
|
|
276
|
+
: String(value)
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
catch {
|
|
280
|
+
return poll;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
// Cleanup on timeout
|
|
284
|
+
await executeCDP(app, `delete globalThis['${slotId}']`, false, 2000).catch(() => { });
|
|
285
|
+
return { success: false, error: "Timeout: Promise did not resolve within the time limit." };
|
|
286
|
+
}
|
|
220
287
|
// Execute JavaScript in the connected React Native app with retry logic
|
|
221
288
|
export async function executeInApp(expression, awaitPromise = true, options = {}, device) {
|
|
222
289
|
const { maxRetries = 2, retryDelayMs = 1000, autoReconnect = true, timeoutMs = 10000 } = options;
|
|
@@ -798,29 +865,34 @@ export async function getComponentTree(options = {}) {
|
|
|
798
865
|
}
|
|
799
866
|
|
|
800
867
|
function extractLayoutStyles(style) {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
868
|
+
try {
|
|
869
|
+
if (!style) return null;
|
|
870
|
+
const merged = Array.isArray(style)
|
|
871
|
+
? Object.assign({}, ...style.filter(Boolean).map(s => {
|
|
872
|
+
try { return typeof s === 'object' ? s : {}; }
|
|
873
|
+
catch { return {}; }
|
|
874
|
+
}))
|
|
875
|
+
: (typeof style === 'object' ? style : {});
|
|
876
|
+
|
|
877
|
+
const layout = {};
|
|
878
|
+
const layoutKeys = [
|
|
879
|
+
'padding', 'paddingTop', 'paddingBottom', 'paddingLeft', 'paddingRight',
|
|
880
|
+
'paddingHorizontal', 'paddingVertical',
|
|
881
|
+
'margin', 'marginTop', 'marginBottom', 'marginLeft', 'marginRight',
|
|
882
|
+
'marginHorizontal', 'marginVertical',
|
|
883
|
+
'width', 'height', 'minWidth', 'minHeight', 'maxWidth', 'maxHeight',
|
|
884
|
+
'flex', 'flexDirection', 'flexWrap', 'flexGrow', 'flexShrink',
|
|
885
|
+
'justifyContent', 'alignItems', 'alignSelf', 'alignContent',
|
|
886
|
+
'position', 'top', 'bottom', 'left', 'right',
|
|
887
|
+
'gap', 'rowGap', 'columnGap',
|
|
888
|
+
'borderWidth', 'borderTopWidth', 'borderBottomWidth', 'borderLeftWidth', 'borderRightWidth'
|
|
889
|
+
];
|
|
890
|
+
|
|
891
|
+
for (const key of layoutKeys) {
|
|
892
|
+
if (merged[key] !== undefined) layout[key] = merged[key];
|
|
893
|
+
}
|
|
894
|
+
return Object.keys(layout).length > 0 ? layout : null;
|
|
895
|
+
} catch { return null; }
|
|
824
896
|
}
|
|
825
897
|
|
|
826
898
|
function walkFiber(fiber, depth) {
|
|
@@ -849,23 +921,29 @@ export async function getComponentTree(options = {}) {
|
|
|
849
921
|
const props = {};
|
|
850
922
|
for (const key of Object.keys(fiber.memoizedProps)) {
|
|
851
923
|
if (key === 'children' || key === 'style') continue;
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
924
|
+
try {
|
|
925
|
+
const val = fiber.memoizedProps[key];
|
|
926
|
+
if (typeof val === 'function') {
|
|
927
|
+
props[key] = '[Function]';
|
|
928
|
+
} else if (typeof val === 'object' && val !== null) {
|
|
929
|
+
props[key] = Array.isArray(val) ? '[Array]' : '[Object]';
|
|
930
|
+
} else {
|
|
931
|
+
props[key] = val;
|
|
932
|
+
}
|
|
933
|
+
} catch {
|
|
934
|
+
props[key] = '[Animated Value]';
|
|
859
935
|
}
|
|
860
936
|
}
|
|
861
937
|
if (Object.keys(props).length > 0) node.props = props;
|
|
862
938
|
}
|
|
863
939
|
|
|
864
940
|
// Include layout styles if requested
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
941
|
+
try {
|
|
942
|
+
if (includeStyles && fiber.memoizedProps?.style) {
|
|
943
|
+
const layout = extractLayoutStyles(fiber.memoizedProps.style);
|
|
944
|
+
if (layout) node.layout = layout;
|
|
945
|
+
}
|
|
946
|
+
} catch { /* animated style — skip */ }
|
|
869
947
|
|
|
870
948
|
// Traverse children
|
|
871
949
|
let child = fiber.child;
|
|
@@ -1232,31 +1310,36 @@ export async function getScreenLayout(options = {}) {
|
|
|
1232
1310
|
}
|
|
1233
1311
|
|
|
1234
1312
|
function extractLayoutStyles(style) {
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1313
|
+
try {
|
|
1314
|
+
if (!style) return null;
|
|
1315
|
+
var merged = Array.isArray(style)
|
|
1316
|
+
? Object.assign.apply(null, [{}].concat(style.filter(Boolean).map(function(s) {
|
|
1317
|
+
try { return typeof s === 'object' ? s : {}; }
|
|
1318
|
+
catch(e) { return {}; }
|
|
1319
|
+
})))
|
|
1320
|
+
: (typeof style === 'object' ? style : {});
|
|
1321
|
+
|
|
1322
|
+
var layout = {};
|
|
1323
|
+
var layoutKeys = [
|
|
1324
|
+
'padding', 'paddingTop', 'paddingBottom', 'paddingLeft', 'paddingRight',
|
|
1325
|
+
'paddingHorizontal', 'paddingVertical',
|
|
1326
|
+
'margin', 'marginTop', 'marginBottom', 'marginLeft', 'marginRight',
|
|
1327
|
+
'marginHorizontal', 'marginVertical',
|
|
1328
|
+
'width', 'height', 'minWidth', 'minHeight', 'maxWidth', 'maxHeight',
|
|
1329
|
+
'flex', 'flexDirection', 'flexWrap', 'flexGrow', 'flexShrink',
|
|
1330
|
+
'justifyContent', 'alignItems', 'alignSelf', 'alignContent',
|
|
1331
|
+
'position', 'top', 'bottom', 'left', 'right',
|
|
1332
|
+
'gap', 'rowGap', 'columnGap',
|
|
1333
|
+
'borderWidth', 'borderTopWidth', 'borderBottomWidth', 'borderLeftWidth', 'borderRightWidth',
|
|
1334
|
+
'backgroundColor', 'borderColor', 'borderRadius',
|
|
1335
|
+
'zIndex', 'elevation'
|
|
1336
|
+
];
|
|
1337
|
+
|
|
1338
|
+
for (var k = 0; k < layoutKeys.length; k++) {
|
|
1339
|
+
if (merged[layoutKeys[k]] !== undefined) layout[layoutKeys[k]] = merged[layoutKeys[k]];
|
|
1340
|
+
}
|
|
1341
|
+
return Object.keys(layout).length > 0 ? layout : null;
|
|
1342
|
+
} catch(e) { return null; }
|
|
1260
1343
|
}
|
|
1261
1344
|
|
|
1262
1345
|
var elements = [];
|
|
@@ -1277,13 +1360,15 @@ export async function getScreenLayout(options = {}) {
|
|
|
1277
1360
|
if (!displayName) continue;
|
|
1278
1361
|
if (componentsOnly && !info.customName) continue;
|
|
1279
1362
|
|
|
1280
|
-
var style =
|
|
1363
|
+
var style = null;
|
|
1364
|
+
try { style = fiber.memoizedProps ? fiber.memoizedProps.style : null; } catch {}
|
|
1281
1365
|
var layout = extractLayoutStyles(style);
|
|
1282
1366
|
|
|
1283
1367
|
// Get text content — use pre-collected text from step 1, or fall back to host fiber
|
|
1284
1368
|
var textContent = info.text || null;
|
|
1285
1369
|
if (!textContent && (info.hostName === 'RCTText' || info.hostName === 'Text')) {
|
|
1286
|
-
var children =
|
|
1370
|
+
var children = null;
|
|
1371
|
+
try { children = fiber.memoizedProps ? fiber.memoizedProps.children : null; } catch {}
|
|
1287
1372
|
if (typeof children === 'string') textContent = children;
|
|
1288
1373
|
else if (typeof children === 'number') textContent = String(children);
|
|
1289
1374
|
}
|
|
@@ -1506,11 +1591,16 @@ export async function inspectComponent(componentName, options = {}) {
|
|
|
1506
1591
|
}
|
|
1507
1592
|
|
|
1508
1593
|
function extractStyles(style) {
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1594
|
+
try {
|
|
1595
|
+
if (!style) return null;
|
|
1596
|
+
const merged = Array.isArray(style)
|
|
1597
|
+
? Object.assign({}, ...style.filter(Boolean).map(s => {
|
|
1598
|
+
try { return typeof s === 'object' ? s : {}; }
|
|
1599
|
+
catch { return {}; }
|
|
1600
|
+
}))
|
|
1601
|
+
: (typeof style === 'object' ? style : {});
|
|
1602
|
+
return Object.keys(merged).length > 0 ? merged : null;
|
|
1603
|
+
} catch { return { _note: '[Contains animated styles]' }; }
|
|
1514
1604
|
}
|
|
1515
1605
|
|
|
1516
1606
|
function serializeValue(val, depth = 0) {
|
|
@@ -1528,7 +1618,11 @@ export async function inspectComponent(componentName, options = {}) {
|
|
|
1528
1618
|
if (keys.length > 20) return '[Object(' + keys.length + ' keys)]';
|
|
1529
1619
|
const result = {};
|
|
1530
1620
|
for (const k of keys) {
|
|
1531
|
-
|
|
1621
|
+
try {
|
|
1622
|
+
result[k] = serializeValue(val[k], depth + 1);
|
|
1623
|
+
} catch {
|
|
1624
|
+
result[k] = '[Animated Value]';
|
|
1625
|
+
}
|
|
1532
1626
|
}
|
|
1533
1627
|
return result;
|
|
1534
1628
|
}
|
|
@@ -1596,42 +1690,56 @@ export async function inspectComponent(componentName, options = {}) {
|
|
|
1596
1690
|
const props = {};
|
|
1597
1691
|
for (const key of Object.keys(fiber.memoizedProps)) {
|
|
1598
1692
|
if (key === 'children') continue;
|
|
1599
|
-
|
|
1693
|
+
try {
|
|
1694
|
+
props[key] = serializeValue(fiber.memoizedProps[key]);
|
|
1695
|
+
} catch {
|
|
1696
|
+
props[key] = '[Animated Value]';
|
|
1697
|
+
}
|
|
1600
1698
|
}
|
|
1601
1699
|
result.props = props;
|
|
1602
1700
|
}
|
|
1603
1701
|
|
|
1604
1702
|
// Style separately for clarity
|
|
1605
|
-
|
|
1606
|
-
|
|
1703
|
+
try {
|
|
1704
|
+
if (fiber.memoizedProps?.style) {
|
|
1705
|
+
result.style = extractStyles(fiber.memoizedProps.style);
|
|
1706
|
+
}
|
|
1707
|
+
} catch {
|
|
1708
|
+
result.style = { _note: '[Contains animated styles]' };
|
|
1607
1709
|
}
|
|
1608
1710
|
|
|
1609
1711
|
// State (for hooks, this is a linked list)
|
|
1610
1712
|
if (includeState && fiber.memoizedState) {
|
|
1611
1713
|
// Simplified hook value serialization
|
|
1612
1714
|
function serializeHookValue(val, depth = 0) {
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
if (
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1715
|
+
try {
|
|
1716
|
+
if (depth > 2) return '[...]';
|
|
1717
|
+
if (val === null || val === undefined) return val;
|
|
1718
|
+
if (typeof val === 'function') return '[Function]';
|
|
1719
|
+
if (typeof val !== 'object') return val;
|
|
1720
|
+
// Skip React internal structures (effects, refs with destroy/create)
|
|
1721
|
+
if (val.create && val.destroy !== undefined) return '[Effect]';
|
|
1722
|
+
if (val.inst && val.deps) return '[Effect]';
|
|
1723
|
+
if (val.current !== undefined && Object.keys(val).length === 1) {
|
|
1724
|
+
// Ref object - just show current value
|
|
1725
|
+
return { current: serializeHookValue(val.current, depth + 1) };
|
|
1726
|
+
}
|
|
1727
|
+
if (Array.isArray(val)) {
|
|
1728
|
+
if (val.length > 5) return '[Array(' + val.length + ')]';
|
|
1729
|
+
return val.slice(0, 5).map(v => serializeHookValue(v, depth + 1));
|
|
1730
|
+
}
|
|
1731
|
+
const keys = Object.keys(val);
|
|
1732
|
+
if (keys.length > 10) return '[Object(' + keys.length + ' keys)]';
|
|
1733
|
+
const result = {};
|
|
1734
|
+
for (const k of keys.slice(0, 10)) {
|
|
1735
|
+
try {
|
|
1736
|
+
result[k] = serializeHookValue(val[k], depth + 1);
|
|
1737
|
+
} catch {
|
|
1738
|
+
result[k] = '[Animated Value]';
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
return result;
|
|
1742
|
+
} catch { return '[Animated Value]'; }
|
|
1635
1743
|
}
|
|
1636
1744
|
|
|
1637
1745
|
// For function components with hooks
|
|
@@ -1717,20 +1825,25 @@ export async function findComponents(pattern, options = {}) {
|
|
|
1717
1825
|
}
|
|
1718
1826
|
|
|
1719
1827
|
function extractLayoutStyles(style) {
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1828
|
+
try {
|
|
1829
|
+
if (!style) return null;
|
|
1830
|
+
const merged = Array.isArray(style)
|
|
1831
|
+
? Object.assign({}, ...style.filter(Boolean).map(s => {
|
|
1832
|
+
try { return typeof s === 'object' ? s : {}; }
|
|
1833
|
+
catch { return {}; }
|
|
1834
|
+
}))
|
|
1835
|
+
: (typeof style === 'object' ? style : {});
|
|
1836
|
+
|
|
1837
|
+
const layout = {};
|
|
1838
|
+
const keys = ['padding', 'paddingTop', 'paddingBottom', 'paddingLeft', 'paddingRight',
|
|
1839
|
+
'paddingHorizontal', 'paddingVertical', 'margin', 'marginTop', 'marginBottom',
|
|
1840
|
+
'marginLeft', 'marginRight', 'marginHorizontal', 'marginVertical',
|
|
1841
|
+
'width', 'height', 'flex', 'flexDirection', 'justifyContent', 'alignItems'];
|
|
1842
|
+
for (const k of keys) {
|
|
1843
|
+
if (merged[k] !== undefined) layout[k] = merged[k];
|
|
1844
|
+
}
|
|
1845
|
+
return Object.keys(layout).length > 0 ? layout : null;
|
|
1846
|
+
} catch { return null; }
|
|
1734
1847
|
}
|
|
1735
1848
|
|
|
1736
1849
|
const results = [];
|