react-native-mcp-kit 3.0.0 → 4.0.0
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 +22 -10
- package/dist/bin/ios-hid +0 -0
- package/dist/client/contexts/McpContext/McpProvider.d.ts.map +1 -1
- package/dist/client/contexts/McpContext/McpProvider.js +5 -5
- package/dist/client/contexts/McpContext/McpProvider.js.map +1 -1
- package/dist/client/core/McpClient.d.ts.map +1 -1
- package/dist/client/core/McpClient.js +26 -32
- package/dist/client/core/McpClient.js.map +1 -1
- package/dist/modules/alert/alert.d.ts.map +1 -1
- package/dist/modules/alert/alert.js +2 -5
- package/dist/modules/alert/alert.js.map +1 -1
- package/dist/modules/console/console.d.ts.map +1 -1
- package/dist/modules/console/console.js +32 -107
- package/dist/modules/console/console.js.map +1 -1
- package/dist/modules/console/types.d.ts +1 -0
- package/dist/modules/console/types.d.ts.map +1 -1
- package/dist/modules/device/device.d.ts.map +1 -1
- package/dist/modules/device/device.js +224 -133
- package/dist/modules/device/device.js.map +1 -1
- package/dist/modules/errors/errors.d.ts.map +1 -1
- package/dist/modules/errors/errors.js +19 -36
- package/dist/modules/errors/errors.js.map +1 -1
- package/dist/modules/fiberTree/children.d.ts +49 -0
- package/dist/modules/fiberTree/children.d.ts.map +1 -0
- package/dist/modules/fiberTree/children.js +182 -0
- package/dist/modules/fiberTree/children.js.map +1 -0
- package/dist/modules/fiberTree/constants.d.ts +13 -0
- package/dist/modules/fiberTree/constants.d.ts.map +1 -0
- package/dist/modules/fiberTree/constants.js +24 -0
- package/dist/modules/fiberTree/constants.js.map +1 -0
- package/dist/modules/fiberTree/fiberTree.d.ts +3 -6
- package/dist/modules/fiberTree/fiberTree.d.ts.map +1 -1
- package/dist/modules/fiberTree/fiberTree.js +219 -1080
- package/dist/modules/fiberTree/fiberTree.js.map +1 -1
- package/dist/modules/fiberTree/finder.d.ts +60 -0
- package/dist/modules/fiberTree/finder.d.ts.map +1 -0
- package/dist/modules/fiberTree/finder.js +107 -0
- package/dist/modules/fiberTree/finder.js.map +1 -0
- package/dist/modules/fiberTree/hooks.d.ts +103 -0
- package/dist/modules/fiberTree/hooks.d.ts.map +1 -0
- package/dist/modules/fiberTree/hooks.js +532 -0
- package/dist/modules/fiberTree/hooks.js.map +1 -0
- package/dist/modules/fiberTree/projection.d.ts +49 -0
- package/dist/modules/fiberTree/projection.d.ts.map +1 -0
- package/dist/modules/fiberTree/projection.js +82 -0
- package/dist/modules/fiberTree/projection.js.map +1 -0
- package/dist/modules/fiberTree/query.d.ts +56 -0
- package/dist/modules/fiberTree/query.d.ts.map +1 -0
- package/dist/modules/fiberTree/query.js +151 -0
- package/dist/modules/fiberTree/query.js.map +1 -0
- package/dist/modules/fiberTree/redact.d.ts +24 -0
- package/dist/modules/fiberTree/redact.d.ts.map +1 -0
- package/dist/modules/fiberTree/redact.js +51 -0
- package/dist/modules/fiberTree/redact.js.map +1 -0
- package/dist/modules/fiberTree/types.d.ts +7 -0
- package/dist/modules/fiberTree/types.d.ts.map +1 -1
- package/dist/modules/fiberTree/utils.d.ts +8 -2
- package/dist/modules/fiberTree/utils.d.ts.map +1 -1
- package/dist/modules/fiberTree/utils.js +79 -78
- package/dist/modules/fiberTree/utils.js.map +1 -1
- package/dist/modules/fiberTree/viewport.d.ts +28 -0
- package/dist/modules/fiberTree/viewport.d.ts.map +1 -0
- package/dist/modules/fiberTree/viewport.js +50 -0
- package/dist/modules/fiberTree/viewport.js.map +1 -0
- package/dist/modules/fiberTree/waitFor.d.ts +52 -0
- package/dist/modules/fiberTree/waitFor.d.ts.map +1 -0
- package/dist/modules/fiberTree/waitFor.js +98 -0
- package/dist/modules/fiberTree/waitFor.js.map +1 -0
- package/dist/modules/logBox/logBox.d.ts.map +1 -1
- package/dist/modules/logBox/logBox.js +59 -66
- package/dist/modules/logBox/logBox.js.map +1 -1
- package/dist/modules/navigation/navigation.d.ts.map +1 -1
- package/dist/modules/navigation/navigation.js +115 -114
- package/dist/modules/navigation/navigation.js.map +1 -1
- package/dist/modules/network/network.d.ts.map +1 -1
- package/dist/modules/network/network.js +78 -197
- package/dist/modules/network/network.js.map +1 -1
- package/dist/modules/network/types.d.ts +23 -27
- package/dist/modules/network/types.d.ts.map +1 -1
- package/dist/modules/reactQuery/reactQuery.d.ts.map +1 -1
- package/dist/modules/reactQuery/reactQuery.js +46 -52
- package/dist/modules/reactQuery/reactQuery.js.map +1 -1
- package/dist/modules/storage/storage.d.ts.map +1 -1
- package/dist/modules/storage/storage.js +20 -3
- package/dist/modules/storage/storage.js.map +1 -1
- package/dist/server/host/tools/input.js +2 -2
- package/dist/server/host/tools/input.js.map +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +33 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/mcpServer.d.ts.map +1 -1
- package/dist/server/mcpServer.js +43 -3
- package/dist/server/mcpServer.js.map +1 -1
- package/dist/server/metro/eventCapture.d.ts +0 -2
- package/dist/server/metro/eventCapture.d.ts.map +1 -1
- package/dist/server/metro/eventCapture.js +1 -2
- package/dist/server/metro/eventCapture.js.map +1 -1
- package/dist/server/metro/tools/events.d.ts.map +1 -1
- package/dist/server/metro/tools/events.js +11 -11
- package/dist/server/metro/tools/events.js.map +1 -1
- package/dist/shared/projection/projectValue.d.ts +90 -0
- package/dist/shared/projection/projectValue.d.ts.map +1 -0
- package/dist/shared/projection/projectValue.js +322 -0
- package/dist/shared/projection/projectValue.js.map +1 -0
- package/dist/shared/projection/redact.d.ts +31 -0
- package/dist/shared/projection/redact.d.ts.map +1 -0
- package/dist/shared/projection/redact.js +78 -0
- package/dist/shared/projection/redact.js.map +1 -0
- package/dist/shared/projection/resolvePath.d.ts +45 -0
- package/dist/shared/projection/resolvePath.d.ts.map +1 -0
- package/dist/shared/projection/resolvePath.js +211 -0
- package/dist/shared/projection/resolvePath.js.map +1 -0
- package/dist/shared/rn/core.d.ts +48 -0
- package/dist/shared/rn/core.d.ts.map +1 -0
- package/dist/shared/rn/core.js +100 -0
- package/dist/shared/rn/core.js.map +1 -0
- package/dist/shared/rn/deviceInfo.d.ts +40 -0
- package/dist/shared/rn/deviceInfo.d.ts.map +1 -0
- package/dist/shared/rn/deviceInfo.js +78 -0
- package/dist/shared/rn/deviceInfo.js.map +1 -0
- package/package.json +2 -2
- package/dist/client/hooks/useMcpState.d.ts +0 -3
- package/dist/client/hooks/useMcpState.d.ts.map +0 -1
- package/dist/client/hooks/useMcpState.js +0 -20
- package/dist/client/hooks/useMcpState.js.map +0 -1
- package/dist/server/canonicalize.d.ts +0 -8
- package/dist/server/canonicalize.d.ts.map +0 -1
- package/dist/server/canonicalize.js +0 -23
- package/dist/server/canonicalize.js.map +0 -1
- package/dist/server/host/modules/screenshot.d.ts +0 -4
- package/dist/server/host/modules/screenshot.d.ts.map +0 -1
- package/dist/server/host/modules/screenshot.js +0 -615
- package/dist/server/host/modules/screenshot.js.map +0 -1
- package/dist/server/host/tools/connectionStatus.d.ts +0 -9
- package/dist/server/host/tools/connectionStatus.d.ts.map +0 -1
- package/dist/server/host/tools/connectionStatus.js +0 -39
- package/dist/server/host/tools/connectionStatus.js.map +0 -1
- package/dist/server/host/tools/symbolicate.d.ts +0 -3
- package/dist/server/host/tools/symbolicate.d.ts.map +0 -1
- package/dist/server/host/tools/symbolicate.js +0 -209
- package/dist/server/host/tools/symbolicate.js.map +0 -1
- package/dist/server/host/wda.d.ts +0 -15
- package/dist/server/host/wda.d.ts.map +0 -1
- package/dist/server/host/wda.js +0 -100
- package/dist/server/host/wda.js.map +0 -1
- package/dist/server/inputSchemaToZod.d.ts +0 -19
- package/dist/server/inputSchemaToZod.d.ts.map +0 -1
- package/dist/server/inputSchemaToZod.js +0 -89
- package/dist/server/inputSchemaToZod.js.map +0 -1
- package/dist/server/metro/tools/openUrl.d.ts +0 -3
- package/dist/server/metro/tools/openUrl.d.ts.map +0 -1
- package/dist/server/metro/tools/openUrl.js +0 -71
- package/dist/server/metro/tools/openUrl.js.map +0 -1
- package/dist/shared/slice.d.ts +0 -16
- package/dist/shared/slice.d.ts.map +0 -1
- package/dist/shared/slice.js +0 -29
- package/dist/shared/slice.js.map +0 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `select` parser — converts the agent's raw select array into a strict
|
|
4
|
+
* `Projection` object the query handler can read against. Recognises three
|
|
5
|
+
* shapes per entry:
|
|
6
|
+
* - bare string → include the named field with defaults
|
|
7
|
+
* - { field: true } → same
|
|
8
|
+
* - { field: options } → include with per-field options
|
|
9
|
+
*
|
|
10
|
+
* Heavy fields (`props`, `hooks`, `children`) take per-field option
|
|
11
|
+
* objects; light fields (mcpId / name / testID / bounds / refMethods) just
|
|
12
|
+
* toggle on. Validation of children's nested select happens inside
|
|
13
|
+
* `parseChildrenOptions` so the error surfaces with the offending field
|
|
14
|
+
* name.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.parseProjection = exports.QUERY_DEFAULT_FIELDS = void 0;
|
|
18
|
+
const children_1 = require("./children");
|
|
19
|
+
const hooks_1 = require("./hooks");
|
|
20
|
+
exports.QUERY_DEFAULT_FIELDS = ['mcpId', 'name', 'testID'];
|
|
21
|
+
/**
|
|
22
|
+
* Parse the `select` arg into a flat Projection. Each element of `select`
|
|
23
|
+
* may be either a string (include the named field with default options)
|
|
24
|
+
* or an object whose keys are field names and whose values are
|
|
25
|
+
* `true` / `false` / per-field projection options.
|
|
26
|
+
*
|
|
27
|
+
* Per-field options:
|
|
28
|
+
* props: { path?, depth?, maxBytes? } — projection of the props object
|
|
29
|
+
* hooks: HooksRawOptions — kinds/names filters + withValues
|
|
30
|
+
* + path/depth/maxBytes for hook
|
|
31
|
+
* values
|
|
32
|
+
* children: number | { treeDepth?, select?, itemsCap? }
|
|
33
|
+
* — recursive light-only walker; see
|
|
34
|
+
* parseChildrenSelect for limits.
|
|
35
|
+
*
|
|
36
|
+
* Heavy fields (props, hooks) are projected handler-side with these
|
|
37
|
+
* per-field options so the rest of the response (mcpId, name, total, ...)
|
|
38
|
+
* stays raw and always visible.
|
|
39
|
+
*/
|
|
40
|
+
const parseProjection = (selectArg) => {
|
|
41
|
+
const fields = new Set();
|
|
42
|
+
let propsRaw = {};
|
|
43
|
+
let hooksRaw;
|
|
44
|
+
let childrenOpts = null;
|
|
45
|
+
if (Array.isArray(selectArg)) {
|
|
46
|
+
for (const entry of selectArg) {
|
|
47
|
+
if (typeof entry === 'string') {
|
|
48
|
+
fields.add(entry);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (entry && typeof entry === 'object') {
|
|
52
|
+
for (const [key, value] of Object.entries(entry)) {
|
|
53
|
+
if (value === false)
|
|
54
|
+
continue;
|
|
55
|
+
if (key === 'children') {
|
|
56
|
+
childrenOpts = (0, children_1.parseChildrenOptions)(value);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
fields.add(key);
|
|
60
|
+
if (key === 'props' && value && typeof value === 'object') {
|
|
61
|
+
propsRaw = value;
|
|
62
|
+
}
|
|
63
|
+
else if (key === 'hooks' && value && typeof value === 'object') {
|
|
64
|
+
hooksRaw = value;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (fields.size === 0) {
|
|
71
|
+
for (const f of exports.QUERY_DEFAULT_FIELDS)
|
|
72
|
+
fields.add(f);
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
children: childrenOpts,
|
|
76
|
+
fields,
|
|
77
|
+
hooks: (0, hooks_1.buildHooksOptions)(hooksRaw),
|
|
78
|
+
props: propsRaw,
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
exports.parseProjection = parseProjection;
|
|
82
|
+
//# sourceMappingURL=projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.js","sourceRoot":"","sources":["../../../src/modules/f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,CAAC;wBACjE,QAAQ,GAAG,KAAwB,CAAC;oBACtC,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACtB,KAAK,MAAM,CAAC,IAAI,4BAAoB;YAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,YAAY;QACtB,MAAM;QACN,KAAK,EAAE,IAAA,yBAAiB,EAAC,QAAQ,CAAC;QAClC,KAAK,EAAE,QAAQ;KAChB,CAAC;AACJ,CAAC,CAAC;AAxCW,QAAA,eAAe,mBAwC1B"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query primitive — chained `steps`, each step a `scope` + criteria pair.
|
|
3
|
+
* Each step's matches fan out into the next step's scope (so a 2-step
|
|
4
|
+
* `[{ name: 'List' }, { scope: 'children', name: 'Item' }]` reads as
|
|
5
|
+
* "find all Lists, then for each List collect its Item children").
|
|
6
|
+
*
|
|
7
|
+
* Scopes (`QueryScope`) control which fibers a step *considers*; criteria
|
|
8
|
+
* (from `ComponentQuery`) filter that set. Validation rejects unknown
|
|
9
|
+
* scope strings at the entry point so typos surface as a structured
|
|
10
|
+
* error instead of silently degrading to the default `descendants`.
|
|
11
|
+
*/
|
|
12
|
+
import { type ComponentQuery, type Fiber } from './types';
|
|
13
|
+
export interface FiberTreeNavigationRef {
|
|
14
|
+
getCurrentRoute?: () => unknown;
|
|
15
|
+
}
|
|
16
|
+
export type QueryScope = 'ancestors' | 'children' | 'descendants' | 'nearest_host' | 'parent' | 'root' | 'screen' | 'self' | 'siblings';
|
|
17
|
+
export interface QueryStep extends ComponentQuery {
|
|
18
|
+
/**
|
|
19
|
+
* If provided, only the N-th match survives into the next step. Omit to
|
|
20
|
+
* forward every match along (fan-out across scopes on the next step).
|
|
21
|
+
*/
|
|
22
|
+
index?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Which fibers relative to the previous step's result are considered for this
|
|
25
|
+
* step. Defaults to 'descendants' (so the first step walks the whole tree
|
|
26
|
+
* from the fiber root). Other values walk 'parent'/'ancestors'/'siblings'/
|
|
27
|
+
* 'children'/'self'.
|
|
28
|
+
*/
|
|
29
|
+
scope?: QueryScope;
|
|
30
|
+
}
|
|
31
|
+
export interface QueryRuntime {
|
|
32
|
+
root: Fiber;
|
|
33
|
+
navigationRef?: FiberTreeNavigationRef | null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Up-front validation of every step's `scope`. Returns a human-readable
|
|
37
|
+
* error string on a bad scope (with the valid set listed for the agent),
|
|
38
|
+
* or null when all steps look sane. Keeps unknown scopes from silently
|
|
39
|
+
* collapsing to the default 'descendants' inside `collectByScope`.
|
|
40
|
+
*/
|
|
41
|
+
export declare const validateSteps: (steps: QueryStep[]) => string | null;
|
|
42
|
+
/**
|
|
43
|
+
* Walk the chain of steps starting from the fiber root. Each iteration
|
|
44
|
+
* collects candidates via `collectByScope`, then filters with
|
|
45
|
+
* `matchesQuery`. `step.index` picks one match; otherwise all matches
|
|
46
|
+
* fan out as the input set for the next step.
|
|
47
|
+
*/
|
|
48
|
+
export declare const runQueryChain: (runtime: QueryRuntime, steps: QueryStep[]) => Fiber[];
|
|
49
|
+
/**
|
|
50
|
+
* Keep only fibers whose ancestor chain contains no other match. Removes
|
|
51
|
+
* wrapper cascades (PressableView → Pressable → View → RCTView) while
|
|
52
|
+
* keeping independent siblings with overlapping bounds (e.g.
|
|
53
|
+
* absolute-positioned overlays). Preserves original DFS order.
|
|
54
|
+
*/
|
|
55
|
+
export declare const dedupAncestors: (matches: Fiber[]) => Fiber[];
|
|
56
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/modules/fiberTree/query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAc1D,MAAM,WAAW,sBAAsB;IACrC,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC;CACjC;AAED,MAAM,MAAM,UAAU,GAClB,WAAW,GACX,UAAU,GACV,aAAa,GACb,cAAc,GACd,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,MAAM,GACN,UAAU,CAAC;AAcf,MAAM,WAAW,SAAU,SAAQ,cAAc;IAC/C;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,KAAK,CAAC;IACZ,aAAa,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAC;CAC/C;AAiDD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,UAAW,SAAS,EAAE,KAAG,MAAM,GAAG,IAU3D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,YAAa,YAAY,SAAS,SAAS,EAAE,KAAG,KAAK,EA0B9E,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,YAAa,KAAK,EAAE,KAAG,KAAK,EAWtD,CAAC"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Query primitive — chained `steps`, each step a `scope` + criteria pair.
|
|
4
|
+
* Each step's matches fan out into the next step's scope (so a 2-step
|
|
5
|
+
* `[{ name: 'List' }, { scope: 'children', name: 'Item' }]` reads as
|
|
6
|
+
* "find all Lists, then for each List collect its Item children").
|
|
7
|
+
*
|
|
8
|
+
* Scopes (`QueryScope`) control which fibers a step *considers*; criteria
|
|
9
|
+
* (from `ComponentQuery`) filter that set. Validation rejects unknown
|
|
10
|
+
* scope strings at the entry point so typos surface as a structured
|
|
11
|
+
* error instead of silently degrading to the default `descendants`.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.dedupAncestors = exports.runQueryChain = exports.validateSteps = void 0;
|
|
15
|
+
const utils_1 = require("./utils");
|
|
16
|
+
const VALID_SCOPES = new Set([
|
|
17
|
+
'ancestors',
|
|
18
|
+
'children',
|
|
19
|
+
'descendants',
|
|
20
|
+
'nearest_host',
|
|
21
|
+
'parent',
|
|
22
|
+
'root',
|
|
23
|
+
'screen',
|
|
24
|
+
'self',
|
|
25
|
+
'siblings',
|
|
26
|
+
]);
|
|
27
|
+
const resolveScreenFiber = (runtime) => {
|
|
28
|
+
const nav = runtime.navigationRef;
|
|
29
|
+
if (!nav || typeof nav.getCurrentRoute !== 'function')
|
|
30
|
+
return null;
|
|
31
|
+
const route = nav.getCurrentRoute();
|
|
32
|
+
const key = route && typeof route.key === 'string' ? route.key : undefined;
|
|
33
|
+
if (!key)
|
|
34
|
+
return null;
|
|
35
|
+
return (0, utils_1.findScreenFiberByRouteKey)(runtime.root, key);
|
|
36
|
+
};
|
|
37
|
+
const collectByScope = (fiber, scope, runtime) => {
|
|
38
|
+
switch (scope) {
|
|
39
|
+
case 'self':
|
|
40
|
+
return [fiber];
|
|
41
|
+
case 'parent':
|
|
42
|
+
return fiber.return ? [fiber.return] : [];
|
|
43
|
+
case 'ancestors':
|
|
44
|
+
return (0, utils_1.getAncestors)(fiber);
|
|
45
|
+
case 'children':
|
|
46
|
+
return (0, utils_1.getDirectChildren)(fiber);
|
|
47
|
+
case 'siblings':
|
|
48
|
+
return (0, utils_1.getSiblings)(fiber);
|
|
49
|
+
case 'nearest_host': {
|
|
50
|
+
const host = (0, utils_1.findHostFiber)(fiber);
|
|
51
|
+
return host ? [host] : [];
|
|
52
|
+
}
|
|
53
|
+
case 'root':
|
|
54
|
+
// Top of the fiber tree, regardless of the previous step's match. Use
|
|
55
|
+
// as the first step (e.g. `query({ steps: [{ scope: 'root' }], select:
|
|
56
|
+
// [{ children: 5 }] })` to dump the whole tree). Criteria on this step
|
|
57
|
+
// are matched against the root fiber itself; if you want descendants
|
|
58
|
+
// of root, follow with another step using scope:'descendants'.
|
|
59
|
+
return [runtime.root];
|
|
60
|
+
case 'screen': {
|
|
61
|
+
const screen = resolveScreenFiber(runtime);
|
|
62
|
+
if (!screen)
|
|
63
|
+
return [];
|
|
64
|
+
return (0, utils_1.findAllByQuery)(screen, {}).filter((f) => {
|
|
65
|
+
return f !== screen;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
case 'descendants':
|
|
69
|
+
default:
|
|
70
|
+
return (0, utils_1.findAllByQuery)(fiber, {}).filter((f) => {
|
|
71
|
+
return f !== fiber;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Up-front validation of every step's `scope`. Returns a human-readable
|
|
77
|
+
* error string on a bad scope (with the valid set listed for the agent),
|
|
78
|
+
* or null when all steps look sane. Keeps unknown scopes from silently
|
|
79
|
+
* collapsing to the default 'descendants' inside `collectByScope`.
|
|
80
|
+
*/
|
|
81
|
+
const validateSteps = (steps) => {
|
|
82
|
+
for (let i = 0; i < steps.length; i++) {
|
|
83
|
+
const step = steps[i];
|
|
84
|
+
if (!step)
|
|
85
|
+
continue;
|
|
86
|
+
if (step.scope !== undefined && !VALID_SCOPES.has(step.scope)) {
|
|
87
|
+
const valid = Array.from(VALID_SCOPES).sort().join(' / ');
|
|
88
|
+
return `steps[${i}].scope: unknown scope "${step.scope}". Valid: ${valid}.`;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
};
|
|
93
|
+
exports.validateSteps = validateSteps;
|
|
94
|
+
/**
|
|
95
|
+
* Walk the chain of steps starting from the fiber root. Each iteration
|
|
96
|
+
* collects candidates via `collectByScope`, then filters with
|
|
97
|
+
* `matchesQuery`. `step.index` picks one match; otherwise all matches
|
|
98
|
+
* fan out as the input set for the next step.
|
|
99
|
+
*/
|
|
100
|
+
const runQueryChain = (runtime, steps) => {
|
|
101
|
+
let current = [runtime.root];
|
|
102
|
+
for (const step of steps) {
|
|
103
|
+
const scope = step.scope ?? 'descendants';
|
|
104
|
+
const seen = new Set();
|
|
105
|
+
const collected = [];
|
|
106
|
+
for (const fiber of current) {
|
|
107
|
+
for (const candidate of collectByScope(fiber, scope, runtime)) {
|
|
108
|
+
if (!seen.has(candidate)) {
|
|
109
|
+
seen.add(candidate);
|
|
110
|
+
collected.push(candidate);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const filtered = collected.filter((f) => {
|
|
115
|
+
return (0, utils_1.matchesQuery)(f, step);
|
|
116
|
+
});
|
|
117
|
+
if (typeof step.index === 'number') {
|
|
118
|
+
const picked = filtered[step.index];
|
|
119
|
+
current = picked ? [picked] : [];
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
current = filtered;
|
|
123
|
+
}
|
|
124
|
+
if (current.length === 0)
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
return current;
|
|
128
|
+
};
|
|
129
|
+
exports.runQueryChain = runQueryChain;
|
|
130
|
+
/**
|
|
131
|
+
* Keep only fibers whose ancestor chain contains no other match. Removes
|
|
132
|
+
* wrapper cascades (PressableView → Pressable → View → RCTView) while
|
|
133
|
+
* keeping independent siblings with overlapping bounds (e.g.
|
|
134
|
+
* absolute-positioned overlays). Preserves original DFS order.
|
|
135
|
+
*/
|
|
136
|
+
const dedupAncestors = (matches) => {
|
|
137
|
+
if (matches.length < 2)
|
|
138
|
+
return matches;
|
|
139
|
+
const matchSet = new Set(matches);
|
|
140
|
+
return matches.filter((fiber) => {
|
|
141
|
+
let p = fiber.return;
|
|
142
|
+
while (p) {
|
|
143
|
+
if (matchSet.has(p))
|
|
144
|
+
return false;
|
|
145
|
+
p = p.return;
|
|
146
|
+
}
|
|
147
|
+
return true;
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
exports.dedupAncestors = dedupAncestors;
|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C,CAAC,CAAC;QACH,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YACnC,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,QAAQ,CAAC;QACrB,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;IACtC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AA1BW,QAAA,aAAa,iBA0BxB;AAEF;;;;;GAKG;AACI,MAAM,cAAc,GAAG,CAAC,OAAgB,EAAW,EAAE;IAC1D,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC;IACvC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAQ,OAAO,CAAC,CAAC;IACzC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QAC9B,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,CAAC;YACT,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;YAClC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;QACf,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAXW,QAAA,cAAc,kBAWzB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook-value redaction. Names matching any compiled pattern have their
|
|
3
|
+
* `value` masked as `"[redacted]"` in `withValues: true` responses while
|
|
4
|
+
* keeping kind / name / hook visible. Matching is applied to a hook's
|
|
5
|
+
* `name` AND every entry in its `via` chain so values stay masked even
|
|
6
|
+
* when nested under a sensitive custom hook (a leaf `value` inside a
|
|
7
|
+
* `useAuth()` expansion).
|
|
8
|
+
*
|
|
9
|
+
* Default list catches the common security-sensitive names. Tuned to
|
|
10
|
+
* match real-world variable names without over-matching innocents:
|
|
11
|
+
* `Pin$` is anchored so it doesn't catch "Spinner"; broad terms like
|
|
12
|
+
* `auth` are deliberately omitted (would catch `isAuthenticated`).
|
|
13
|
+
*/
|
|
14
|
+
export declare const DEFAULT_REDACT_HOOK_NAMES: ReadonlyArray<string | RegExp>;
|
|
15
|
+
/** Placeholder put on the `value` field of a redacted hook entry. */
|
|
16
|
+
export declare const REDACTED_VALUE = "[redacted]";
|
|
17
|
+
/**
|
|
18
|
+
* Compile a mixed string/RegExp list into RegExps. String patterns are
|
|
19
|
+
* escaped and made case-insensitive (so `"password"` catches `password`,
|
|
20
|
+
* `oldPassword`, `passwordHash`); RegExp values are kept verbatim.
|
|
21
|
+
*/
|
|
22
|
+
export declare const compileRedactPatterns: (raw: ReadonlyArray<string | RegExp>) => RegExp[];
|
|
23
|
+
export declare const matchesAnyRedactPattern: (name: string, patterns: RegExp[]) => boolean;
|
|
24
|
+
//# sourceMappingURL=redact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../../../src/modules/fiberTree/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,EAAE,aAAa,CAAC,MAAM,GAAG,MAAM,CASpE,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,cAAc,eAAe,CAAC;AAM3C;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAS,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,KAAG,MAAM,EAIjF,CAAC;AAEF,eAAO,MAAM,uBAAuB,SAAU,MAAM,YAAY,MAAM,EAAE,KAAG,OAK1E,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.matchesAnyRedactPattern = exports.compileRedactPatterns = exports.REDACTED_VALUE = exports.DEFAULT_REDACT_HOOK_NAMES = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Hook-value redaction. Names matching any compiled pattern have their
|
|
6
|
+
* `value` masked as `"[redacted]"` in `withValues: true` responses while
|
|
7
|
+
* keeping kind / name / hook visible. Matching is applied to a hook's
|
|
8
|
+
* `name` AND every entry in its `via` chain so values stay masked even
|
|
9
|
+
* when nested under a sensitive custom hook (a leaf `value` inside a
|
|
10
|
+
* `useAuth()` expansion).
|
|
11
|
+
*
|
|
12
|
+
* Default list catches the common security-sensitive names. Tuned to
|
|
13
|
+
* match real-world variable names without over-matching innocents:
|
|
14
|
+
* `Pin$` is anchored so it doesn't catch "Spinner"; broad terms like
|
|
15
|
+
* `auth` are deliberately omitted (would catch `isAuthenticated`).
|
|
16
|
+
*/
|
|
17
|
+
exports.DEFAULT_REDACT_HOOK_NAMES = [
|
|
18
|
+
/password/i,
|
|
19
|
+
/token/i,
|
|
20
|
+
/jwt/i,
|
|
21
|
+
/secret/i,
|
|
22
|
+
/Pin$/,
|
|
23
|
+
/credential/i,
|
|
24
|
+
/apiKey/i,
|
|
25
|
+
/authorization/i,
|
|
26
|
+
];
|
|
27
|
+
/** Placeholder put on the `value` field of a redacted hook entry. */
|
|
28
|
+
exports.REDACTED_VALUE = '[redacted]';
|
|
29
|
+
const escapeRegExp = (s) => {
|
|
30
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Compile a mixed string/RegExp list into RegExps. String patterns are
|
|
34
|
+
* escaped and made case-insensitive (so `"password"` catches `password`,
|
|
35
|
+
* `oldPassword`, `passwordHash`); RegExp values are kept verbatim.
|
|
36
|
+
*/
|
|
37
|
+
const compileRedactPatterns = (raw) => {
|
|
38
|
+
return raw.map((p) => {
|
|
39
|
+
return typeof p === 'string' ? new RegExp(escapeRegExp(p), 'i') : p;
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
exports.compileRedactPatterns = compileRedactPatterns;
|
|
43
|
+
const matchesAnyRedactPattern = (name, patterns) => {
|
|
44
|
+
for (const p of patterns) {
|
|
45
|
+
if (p.test(name))
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
};
|
|
50
|
+
exports.matchesAnyRedactPattern = matchesAnyRedactPattern;
|
|
51
|
+
//# sourceMappingURL=redact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.js","sourceRoot":"","sources":["../../../src/modules/fiberTree/redact.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;GAYG;AACU,QAAA,yBAAyB,GAAmC;IACvE,WAAW;IACX,QAAQ;IACR,MAAM;IACN,SAAS;IACT,MAAM;IACN,aAAa;IACb,SAAS;IACT,gBAAgB;CACjB,CAAC;AAEF,qEAAqE;AACxD,QAAA,cAAc,GAAG,YAAY,CAAC;AAE3C,MAAM,YAAY,GAAG,CAAC,CAAS,EAAU,EAAE;IACzC,OAAO,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF;;;;GAIG;AACI,MAAM,qBAAqB,GAAG,CAAC,GAAmC,EAAY,EAAE;IACrF,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACnB,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAJW,QAAA,qBAAqB,yBAIhC;AAEK,MAAM,uBAAuB,GAAG,CAAC,IAAY,EAAE,QAAkB,EAAW,EAAE;IACnF,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;IAChC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AALW,QAAA,uBAAuB,2BAKlC"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loose alias for React's internal Fiber shape — we only ever poke a handful
|
|
3
|
+
* of fields (memoizedProps, memoizedState, type, return, sibling, child)
|
|
4
|
+
* and the exact shape drifts between React versions. Centralised here so
|
|
5
|
+
* every sub-module reaches for the same alias instead of re-declaring it.
|
|
6
|
+
*/
|
|
7
|
+
export type Fiber = any;
|
|
1
8
|
export type ComponentType = 'composite' | 'host' | 'other' | 'text';
|
|
2
9
|
export interface Bounds {
|
|
3
10
|
centerX: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/fiberTree/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAEpE,MAAM,WAAW,MAAM;IAErB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,C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,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,WAAW,GACnB,OAAO,GACP,MAAM,GACN,MAAM,GACN;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GACpC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEtC,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,GAAG,CAAC,EAAE,cAAc,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;OAQG;IACH,GAAG,CAAC,EAAE,cAAc,GAAG,cAAc,EAAE,CAAC;IACxC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import { type ProjectOptions } from '../../shared/projection/projectValue';
|
|
1
2
|
import { type Bounds, type ComponentQuery, type SerializedComponent } from './types';
|
|
2
3
|
type Fiber = any;
|
|
3
4
|
export declare const setRootRef: (ref: unknown) => void;
|
|
4
5
|
export declare const getFiberRoot: () => Fiber | null;
|
|
5
6
|
export declare const getComponentName: (fiber: Fiber) => string;
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Projection helper used everywhere fiber values are serialised (props, hook
|
|
9
|
+
* values, fiber refs). Pre-applies the fiber-aware collapse rule + skip list
|
|
10
|
+
* over the shared `projectValue`. Callers can pass `path` / `depth` / etc.
|
|
11
|
+
* through `options` like with `projectValue` directly.
|
|
12
|
+
*/
|
|
13
|
+
export declare const projectFiberValue: (value: unknown, options?: ProjectOptions) => unknown;
|
|
8
14
|
export declare const serializeFiber: (fiber: Fiber, maxDepth: number, currentDepth?: number) => SerializedComponent | null;
|
|
9
15
|
export declare const findFiber: (root: Fiber, predicate: (fiber: Fiber) => boolean) => Fiber | null;
|
|
10
16
|
export declare const findAllFibers: (root: Fiber, predicate: (fiber: Fiber) => boolean) => Fiber[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/modules/fiberTree/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,cAAc,EAGnB,KAAK,mBAAmB,EACzB,MAAM,SAAS,CAAC;AAYjB,KAAK,KAAK,GAAG,GAAG,CAAC;AAKjB,eAAO,MAAM,UAAU,QAAS,OAAO,KAAG,IAEzC,CAAC;AAeF,eAAO,MAAM,YAAY,QAAO,KAAK,GAAG,IAKvC,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAAW,KAAK,KAAG,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/modules/fiberTree/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EACL,KAAK,MAAM,EACX,KAAK,cAAc,EAGnB,KAAK,mBAAmB,EACzB,MAAM,SAAS,CAAC;AAYjB,KAAK,KAAK,GAAG,GAAG,CAAC;AAKjB,eAAO,MAAM,UAAU,QAAS,OAAO,KAAG,IAEzC,CAAC;AAeF,eAAO,MAAM,YAAY,QAAO,KAAK,GAAG,IAKvC,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAAW,KAAK,KAAG,MAqC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AiB,UAAW,KAAK,KAAG,OAoBhD,CAAC;AAYF,eAAO,MAAM,YAAY,UAAiB,KAAK,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAgDtE,CAAC;AAEF,eAAO,MAAM,mBAAmB,aAAc,OAAO,KAAG,MAAM,EAiB7D,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAvailableMethods = exports.measureFiber = exports.getNativeInstance = exports.findScreenFiberByRouteKey = exports.findHostFiber = exports.getAncestors = exports.getSiblings = exports.getDirectChildren = exports.findAllByQuery = exports.matchesQuery = exports.findByText = exports.findByName = exports.findByTestID = exports.findByMcpId = exports.findAllFibers = exports.findFiber = exports.serializeFiber = exports.
|
|
3
|
+
exports.getAvailableMethods = exports.measureFiber = exports.getNativeInstance = exports.findScreenFiberByRouteKey = exports.findHostFiber = exports.getAncestors = exports.getSiblings = exports.getDirectChildren = exports.findAllByQuery = exports.matchesQuery = exports.findByText = exports.findByName = exports.findByTestID = exports.findByMcpId = exports.findAllFibers = exports.findFiber = exports.serializeFiber = exports.projectFiberValue = exports.getComponentName = exports.getFiberRoot = exports.setRootRef = void 0;
|
|
4
|
+
const projectValue_1 = require("../../shared/projection/projectValue");
|
|
5
|
+
const core_1 = require("../../shared/rn/core");
|
|
4
6
|
// Fiber tag constants
|
|
5
7
|
const HOST_COMPONENT = 5;
|
|
6
8
|
const HOST_TEXT = 6;
|
|
@@ -36,8 +38,14 @@ const getFiberRoot = () => {
|
|
|
36
38
|
};
|
|
37
39
|
exports.getFiberRoot = getFiberRoot;
|
|
38
40
|
const getComponentName = (fiber) => {
|
|
39
|
-
|
|
41
|
+
// Host root has no `type` and no `return` parent. Surface it as
|
|
42
|
+
// "FiberRoot" instead of "Unknown" so dumps via scope:'root' read
|
|
43
|
+
// sensibly (and the name doesn't collide with a real component).
|
|
44
|
+
if (!fiber.type) {
|
|
45
|
+
if (!fiber.return)
|
|
46
|
+
return 'FiberRoot';
|
|
40
47
|
return 'Unknown';
|
|
48
|
+
}
|
|
41
49
|
if (typeof fiber.type === 'string') {
|
|
42
50
|
return fiber.type;
|
|
43
51
|
}
|
|
@@ -75,85 +83,76 @@ const getComponentType = (fiber) => {
|
|
|
75
83
|
}
|
|
76
84
|
return 'other';
|
|
77
85
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return '[...]';
|
|
84
|
-
if (typeof value === 'function') {
|
|
85
|
-
return `[Function: ${value.name || 'anonymous'}]`;
|
|
86
|
-
}
|
|
87
|
-
if (typeof value === 'symbol') {
|
|
88
|
-
return value.toString();
|
|
89
|
-
}
|
|
90
|
-
if (typeof value !== 'object')
|
|
91
|
-
return value;
|
|
92
|
-
// React element
|
|
93
|
-
if (value && typeof value === 'object' && '$$typeof' in value) {
|
|
94
|
-
return '[ReactElement]';
|
|
95
|
-
}
|
|
96
|
-
if (seen.has(value))
|
|
97
|
-
return '[Circular]';
|
|
98
|
-
seen.add(value);
|
|
99
|
-
// Skip objects that look like fiber nodes or native instances
|
|
100
|
-
if (value &&
|
|
101
|
-
typeof value === 'object' &&
|
|
102
|
-
('stateNode' in value || 'memoizedProps' in value || '__nativeTag' in value)) {
|
|
103
|
-
return '[InternalObject]';
|
|
104
|
-
}
|
|
105
|
-
if (Array.isArray(value)) {
|
|
106
|
-
return value.slice(0, 10).map((item) => {
|
|
107
|
-
return (0, exports.serializeValue)(item, seen, depth + 1, maxDepth);
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
const result = {};
|
|
111
|
-
try {
|
|
112
|
-
const keys = Object.keys(value);
|
|
113
|
-
for (const key of keys.slice(0, 20)) {
|
|
114
|
-
if (key.startsWith('__'))
|
|
115
|
-
continue;
|
|
116
|
-
try {
|
|
117
|
-
result[key] = (0, exports.serializeValue)(value[key], seen, depth + 1, maxDepth);
|
|
118
|
-
}
|
|
119
|
-
catch {
|
|
120
|
-
result[key] = '[Error]';
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
catch {
|
|
125
|
-
return '[Object]';
|
|
126
|
-
}
|
|
127
|
-
return result;
|
|
128
|
-
};
|
|
129
|
-
exports.serializeValue = serializeValue;
|
|
130
|
-
// Props to skip — internal React/RN properties that bloat output
|
|
131
|
-
const SKIP_PROPS = new Set([
|
|
86
|
+
// Props/values to drop — internal React/RN bookkeeping that bloats output.
|
|
87
|
+
// Used by `projectFiberValue` below as `skipKeys`. Anything matching the
|
|
88
|
+
// `__`-prefix regex is also dropped (covers `__nativeTag`, `__reactProps$...`,
|
|
89
|
+
// react-refresh internal markers, etc.).
|
|
90
|
+
const SKIP_KEYS_FIBER = [
|
|
132
91
|
'__internalInstanceHandle',
|
|
133
92
|
'__nativeTag',
|
|
134
93
|
'children',
|
|
135
94
|
'collapsableChildren',
|
|
136
95
|
'ref',
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
96
|
+
/^__/,
|
|
97
|
+
];
|
|
98
|
+
// Collapse rule: detect React elements / fiber nodes / native instances and
|
|
99
|
+
// replace them with compact `${...}`-keyed marker objects. Stops projectValue
|
|
100
|
+
// from descending into ~unbounded React internals graph and emits something
|
|
101
|
+
// the agent can act on (mcpId / componentName).
|
|
102
|
+
const fiberCollapseRule = (value) => {
|
|
103
|
+
if (!value || typeof value !== 'object')
|
|
104
|
+
return undefined;
|
|
105
|
+
const obj = value;
|
|
106
|
+
// React element — has `$$typeof` symbol
|
|
107
|
+
if ('$$typeof' in obj) {
|
|
108
|
+
return { ['${ReactElement}']: true };
|
|
109
|
+
}
|
|
110
|
+
// Fiber-like or native-instance — try to extract a compact ref
|
|
111
|
+
const looksLikeFiberOrNative = 'stateNode' in obj || 'memoizedProps' in obj || '__nativeTag' in obj;
|
|
112
|
+
if (!looksLikeFiberOrNative)
|
|
113
|
+
return undefined;
|
|
114
|
+
// pull a fiber out — direct, or via internal handle on a native view
|
|
115
|
+
const fiber = obj._reactInternals ??
|
|
116
|
+
obj._reactInternalFiber ??
|
|
117
|
+
obj._internalFiberInstanceHandleDEV ??
|
|
118
|
+
obj._internalInstanceHandle ??
|
|
119
|
+
('memoizedProps' in obj ? obj : undefined);
|
|
120
|
+
const meta = {};
|
|
121
|
+
if (fiber) {
|
|
122
|
+
const props = fiber.memoizedProps;
|
|
123
|
+
const mcpId = props?.['data-mcp-id'];
|
|
124
|
+
const testID = props?.testID;
|
|
125
|
+
if (mcpId)
|
|
126
|
+
meta.mcpId = mcpId;
|
|
127
|
+
if (testID)
|
|
128
|
+
meta.testID = testID;
|
|
129
|
+
const typeName = fiber.type?.displayName ??
|
|
130
|
+
fiber.type?.name;
|
|
131
|
+
if (typeName)
|
|
132
|
+
meta.name = typeName;
|
|
133
|
+
}
|
|
134
|
+
if ('__nativeTag' in obj) {
|
|
135
|
+
meta.nativeTag = obj.__nativeTag;
|
|
136
|
+
const viewConfig = obj.viewConfig;
|
|
137
|
+
if (viewConfig?.uiViewClassName)
|
|
138
|
+
meta.viewClass = viewConfig.uiViewClassName;
|
|
139
|
+
}
|
|
140
|
+
return { ['${ref}']: Object.keys(meta).length > 0 ? meta : true };
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Projection helper used everywhere fiber values are serialised (props, hook
|
|
144
|
+
* values, fiber refs). Pre-applies the fiber-aware collapse rule + skip list
|
|
145
|
+
* over the shared `projectValue`. Callers can pass `path` / `depth` / etc.
|
|
146
|
+
* through `options` like with `projectValue` directly.
|
|
147
|
+
*/
|
|
148
|
+
const projectFiberValue = (value, options = {}) => {
|
|
149
|
+
return (0, projectValue_1.projectValue)(value, {
|
|
150
|
+
...options,
|
|
151
|
+
collapse: [fiberCollapseRule, ...(options.collapse ?? [])],
|
|
152
|
+
skipKeys: [...SKIP_KEYS_FIBER, ...(options.skipKeys ?? [])],
|
|
153
|
+
}).value;
|
|
155
154
|
};
|
|
156
|
-
exports.
|
|
155
|
+
exports.projectFiberValue = projectFiberValue;
|
|
157
156
|
const getTextContent = (fiber) => {
|
|
158
157
|
if (fiber.tag === HOST_TEXT) {
|
|
159
158
|
return fiber.memoizedProps;
|
|
@@ -231,7 +230,10 @@ const serializeFiberUnsafe = (fiber, maxDepth, currentDepth) => {
|
|
|
231
230
|
return null;
|
|
232
231
|
}
|
|
233
232
|
const name = (0, exports.getComponentName)(fiber);
|
|
234
|
-
|
|
233
|
+
// Pass raw memoizedProps through — handler-level `applyProjection` runs the
|
|
234
|
+
// single canonical projectValue walk on the final response, including this
|
|
235
|
+
// tree. Projecting here would cause double-projection and break path drill.
|
|
236
|
+
const props = (fiber.memoizedProps ?? {});
|
|
235
237
|
const mcpId = fiber.memoizedProps?.['data-mcp-id'];
|
|
236
238
|
const testID = fiber.memoizedProps?.testID;
|
|
237
239
|
const text = getTextContent(fiber);
|
|
@@ -558,8 +560,7 @@ const measureFiber = async (fiber) => {
|
|
|
558
560
|
const instance = canonical?.publicInstance ?? hostFiber.stateNode;
|
|
559
561
|
if (!instance)
|
|
560
562
|
return null;
|
|
561
|
-
|
|
562
|
-
const RN = require('react-native');
|
|
563
|
+
const RN = (0, core_1.getRN)();
|
|
563
564
|
const { PixelRatio, UIManager, findNodeHandle } = RN;
|
|
564
565
|
const handle = typeof findNodeHandle === 'function' ? findNodeHandle(instance) : null;
|
|
565
566
|
if (handle == null)
|