UNPKG

agent-device

Version:

Open source device layer for AI coding agents: a CLI, MCP server, and typed Node.js API to control mobile, web, TV, and desktop apps on devices and simulators, locally or in the cloud.

1 lines • 19.5 kB
import{v as e}from"./sdk-contracts.js";import{gt as t}from"./sdk-io.js";import"./file.js";import{r as n}from"./session-paths.js";import{a as r,c as i,i as a,l as o,m as s,n as c,r as l,s as u,t as d,u as f}from"./react-devtools-connection.js";import p from"node:fs";import m from"node:path";const ee=new Set([`ActivityIndicator`,`CellRenderer`,`FlatList`,`Image`,`ImageBackground`,`InternalTextInput`,`KeyboardAvoidingView`,`Modal`,`Pressable`,`PressabilityDebugView`,`RefreshControl`,`SafeAreaView`,`ScrollView`,`SectionList`,`Switch`,`Text`,`TextInput`,`TouchableHighlight`,`TouchableOpacity`,`TouchableWithoutFeedback`,`View`,`VirtualizedList`,`VirtualizedListCellContextProvider`,`VirtualizedSectionList`]);function te(e){let t=s(e);return t.wrappers.includes(`Animated`)?{...t,name:e}:t}function h(e){let{name:t,wrappers:n}=s(e);return ee.has(t)||n.includes(`Animated`)}function g(e){return`${e.name}\0${e.kind}`}function _(e,t){return e.name===t.name&&e.kind===t.kind}function v(e,t){return e.elements[String(t)]}function y(e){let{name:t,wrappers:n}=te(e[0]);return{name:t,kind:n.includes(`Memo`)?`memo`:f(e[1])}}function b(e,t){let n=new Map;for(let r of t){let t=v(e,r);if(!t)continue;let i=y(t);n.set(g(i),i)}return[...n.values()]}function x(e,t){return v(e,t)?.[3]||void 0}function S(e,t){return(t??[]).map(t=>e.keys[t]??`#${t}`)}function C(e,t,n=1){e[t]=(e[t]??0)+n}function*w(e,t){for(let n=0;n+2<t.fibers.length;n+=3){let r=t.fibers[n],i=v(e,r);!i||!Object.hasOwn(o,i[1])||(yield{...y(i),id:r,actualMs:t.fibers[n+1],selfMs:t.fibers[n+2],causes:ne(t,r)})}}function ne(e,t){if(e.changes===null)return[];let n=e.changes[String(t)];if(n===void 0)return[`parent`];if(n===1)return[`mount`];let[r,i,a,o]=n,s=[];return i?.length&&s.push(`props`),a?.length&&s.push(`state`),(o?.length||r&2)&&s.push(`hooks`),r&1&&s.push(`context`),s.length>0?s:[`parent`]}function re(e){return{name:e.name,kind:e.kind,instances:0,renders:0,selfMs:0,maxSelfMs:0,causes:{mount:0,props:0,state:0,hooks:0,context:0,parent:0},changedProps:{},changedState:{},changedHooks:{},owners:{},propKinds:{},costliestCommits:[],ids:new Set,recentIds:[],commitCosts:new Map}}function ie(e,t,n,r,i){e.ids.add(t.id),e.recentIds=[...e.recentIds.filter(e=>e!==t.id),t.id].slice(-3),e.renders+=1,e.selfMs+=t.selfMs,e.maxSelfMs=Math.max(e.maxSelfMs,t.selfMs),e.commitCosts.set(i,(e.commitCosts.get(i)??0)+t.selfMs);for(let n of t.causes)e.causes[n]+=1;let a=r.changes?.[String(t.id)];if(Array.isArray(a)){for(let t of S(n,a[1]))C(e.changedProps,t);for(let t of S(n,a[2]))C(e.changedState,t);for(let t of a[3]??[])C(e.changedHooks,String(t))}let o=v(n,t.id)?.[2],s=o?v(n,o):void 0;s&&C(e.owners,y(s).name)}function T(e){let t=new Map;e.commits.forEach((n,r)=>{for(let i of w(e,n)){let a=g(i),o=t.get(a);o||(o=re(i),t.set(a,o)),ie(o,i,e,n,r)}});for(let e of t.values())e.instances=e.ids.size,e.costliestCommits=[...e.commitCosts.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({index:e,selfMs:t}));return t}function ae(e){let t=[...T(D(e)).values()].filter(e=>e.causes.props>0&&Object.keys(e.changedProps).length>0).sort((e,t)=>t.selfMs-e.selfMs).slice(0,8),n={};for(let e of t)for(let t of e.recentIds)n[String(t)]=Object.keys(e.changedProps);return n}function oe(e){let t=e.commits[0]?.timestamp??0;return e.commits.map((n,r)=>{let i=new Map,a=0,o=0;for(let t of w(e,n)){a+=1,t.causes.includes(`mount`)&&(o+=1);let e=g(t),n=i.get(e)??{name:t.name,kind:t.kind,instances:0,selfMs:0,actualMs:0,causes:[]};n.instances+=1,n.selfMs+=t.selfMs,n.actualMs+=t.actualMs;for(let e of t.causes)n.causes.includes(e)||n.causes.push(e);i.set(e,n)}return{index:r,atMs:Math.round(n.timestamp-t),durationMs:n.duration,rendered:a,mounts:o,updaters:b(e,n.updaters),components:[...i.values()].sort((e,t)=>t.selfMs-e.selfMs)}})}const E=e=>`${e.toFixed(e>=10?0:1)}ms`;function D(e){return{...e,commits:[...e.commits].sort((e,t)=>e.timestamp-t.timestamp)}}function se(e,t){let n={},r=new Set;for(let i of e)for(let[e,a]of Object.entries(t[String(i)]??{}))n[e]!==void 0&&n[e]!==a?r.add(e):n[e]=a;for(let e of r)delete n[e];return n}function ce(e,t={}){let n=T(e);for(let e of n.values())e.propKinds=se(e.ids,t);return{components:[...n.values()].map(({ids:e,recentIds:t,commitCosts:n,...r})=>r).sort((e,t)=>t.selfMs-e.selfMs),commits:oe(e)}}function O(e,t){return Object.entries(e).filter(([,e])=>e>=t).sort((e,t)=>t[1]-e[1]).map(([e])=>e)}function k(e){return O(e.owners,1)[0]}function A(e,t){return e.renders===0?0:e.selfMs*t/e.renders}const j=E;function M(e){return{component:e.name,componentKind:e.kind}}function N(e,t){return e.componentKind!==void 0&&_({name:e.component,kind:e.componentKind},t)}function P(e,t){return`${e} ${t}${e===1?``:`s`}`}function F(e){return e.instances>1?` across ${e.instances} instances`:``}function le(e){let t=e.selfMs/e.renders;return e.selfMs<32||t<4&&e.maxSelfMs<16||e.instances>20&&t<4?null:{kind:`slow-render`,...M(e),costMs:e.selfMs,evidence:`${j(t)} per render (max ${j(e.maxSelfMs)}), ${P(e.renders,`render`)}${F(e)}`,fix:`memoize or move the expensive work out of render`}}const ue=new Set([`boolean`,`number`,`string`,`null`,`undefined`,`bigint`,`symbol`]);function de(e){let t=e.renders-e.causes.mount;if(e.kind!==`memo`||t<10||e.causes.props<t*.5)return null;let n=O(e.changedProps,Math.ceil(e.causes.props*.8)),r=(n.length>0?n:O(e.changedProps,1).slice(0,3)).filter(t=>!ue.has(e.propKinds[t]??``));if(r.length===0)return null;let i=k(e),a=i?` from ${i}`:``,o=i?` in ${i}`:``,s=r.filter(t=>e.propKinds[t]!==void 0),c=t=>`${e.changedProps[t]}x`;return s.length===0?{kind:`memo-defeated`,...M(e),costMs:A(e,e.causes.props),evidence:`memo bypassed on ${e.causes.props}/${t} updates; changed ${r.map(e=>`${e} ${c(e)}`).join(`, `)}${a} (value kinds not inspected)`,fix:`check whether those props are recreated on each render${o}; stabilize them with useCallback/useMemo`}:{kind:`memo-defeated`,...M(e),costMs:A(e,e.causes.props),evidence:`memo bypassed on ${e.causes.props}/${t} updates; new ${s.map(t=>`${t} (${e.propKinds[t]}) ${c(t)}`).join(`, `)}${a}`,fix:`wrap those props in useCallback/useMemo${o}`}}function fe(e,t){let n=e.renders-e.causes.mount;return n<10||e.causes.context<n*.5?null:{kind:`context-cascade`,...M(e),costMs:A(e,e.causes.context),evidence:`${e.causes.context} context-driven renders${F(e)}${t.length?` after updates in ${t.join(`, `)}`:``}`,fix:`split the context so consumers subscribe only to what they read, or memoize the provider value`}}function pe(e){let t=e.renders-e.causes.mount;if(e.kind===`memo`||t<10||e.causes.parent<t*.5)return null;let n=k(e);return{kind:`parent-cascade`,...M(e),costMs:A(e,e.causes.parent),evidence:`${e.causes.parent}/${t} re-renders with unchanged props, state, and context${n?` when ${n} rendered`:``}${F(e)}`,fix:`wrap ${e.name} in React.memo or move state below ${n??`its parent`}`}}function me(e,t){let n=new Map;return e.commits.forEach((r,i)=>{let a=new Map,o=0;for(let t of w(e,r)){if(!t.causes.includes(`mount`)||(o+=1,h(t.name)))continue;let e=g(t),n=a.get(e)??{component:t,count:0,actualMs:0};n.count+=1,n.actualMs+=t.actualMs,a.set(e,n)}let s=t[i].durationMs;for(let[e,t]of a){if(t.count<200)continue;let r=Math.min(t.actualMs,s),a=n.get(e)??{component:t.component,mounts:[]};a.mounts.push({index:i,count:t.count,costMs:r,durationMs:s,mounted:o}),n.set(e,a)}}),[...n.values()].map(({component:e,mounts:t})=>{let n=t.reduce((e,t)=>t.costMs>e.costMs?t:e),r=t.reduce((e,t)=>e+t.costMs,0),i=t.length>1?`; ${t.length} such commits, ${j(r)} in all`:``;return{kind:`eager-mount`,...M(e),costMs:r,evidence:`${n.count} instances mounted at once in commit #${n.index}, ${j(n.costMs)} of its ${j(n.durationMs)} (${n.mounted} components mounted)${i}`,fix:`virtualize the list (FlatList/FlashList)`}})}function he(e,t,n){let r=new Set(t.fibers.filter((e,t)=>t%3==0)),i=new Set(t.updaters);return b(e,n.updaters.filter(e=>r.has(e)&&!i.has(e))).filter(e=>!h(e.name))}function I(e){let t=new Map;for(let n=1;n<e.commits.length;n+=1){let r=e.commits[n-1],i=e.commits[n];if(!(i.timestamp-i.duration-r.timestamp>16))for(let n of he(e,r,i)){let e=g(n),r=t.get(e)??{component:n,count:0,costMs:0};r.count+=1,r.costMs+=i.duration,t.set(e,r)}}return[...t.values()].filter(e=>e.count>=3).map(e=>({kind:`effect-chain`,...M(e.component),costMs:e.costMs,evidence:`${P(e.count,`follow-up commit`)} it triggered right after rendering, likely state set in an effect (${j(e.costMs)})`,fix:`if an effect copies derived state, compute it during render (useMemo) instead`}))}function L(e){let t=new Map;e.commits.forEach((n,r)=>{for(let i of b(e,n.updaters)){let e=g(i),n=t.get(e)??{component:i,indexes:[]};n.indexes.push(r),t.set(e,n)}});let n=[];for(let{component:r,indexes:i}of t.values()){if(i.length<20||h(r.name))continue;let t=e.commits[i[0]].timestamp,a=e.commits[i.at(-1)].timestamp,o=Math.max((a-t)/1e3,.001),s=(i.length-1)/o;if(s<20)continue;let c=i.reduce((t,n)=>t+e.commits[n].duration,0);n.push({kind:`render-storm`,...M(r),costMs:c,evidence:`${i.length} commits in ${o.toFixed(1)}s (${Math.round(s)}/s, ${j(c)} rendering)`,fix:`throttle the updates or animate outside React state (Animated/Reanimated)`})}return n}const R=new Set([`slow-render`,`effect-chain`,`render-storm`]);function ge(e){let t=new Map;for(let n of e){if(n.componentKind===void 0)continue;let e=g({name:n.component,kind:n.componentKind});R.has(n.kind)?t.has(e)||t.set(e,`self`):t.set(e,`subtree`)}return t}function _e(e,t,n){let r=[...w(e,t)],i=new Set(r.filter(e=>n.get(g(e))===`subtree`).map(e=>e.id)),a=t=>{let n=new Set;for(let r=x(e,t);r&&!n.has(r);r=x(e,r)){if(i.has(r))return!0;n.add(r)}return!1},o=0;for(let e of r){let t=n.get(g(e));!t||a(e.id)||(o+=t===`subtree`?e.actualMs:e.selfMs)}return o}function ve(e){let t=e.components.filter(t=>!h(t.name)&&t.actualMs>=e.durationMs*.8);return t.find(t=>e.updaters.some(e=>_(e,t)))??t.sort((e,t)=>e.actualMs-t.actualMs)[0]}function ye(e){let t=ve(e),n=e.components.slice(0,3).map(e=>`${e.name}${e.instances>1?` x${e.instances}`:``} ${j(e.selfMs)}`),r=e.mounts>0?` (${e.mounts} mounted)`:``,i=t&&!e.updaters.some(e=>_(e,t))?` inside ${t.name}`:``,a=e.updaters.length>0?` after ${e.updaters.map(e=>e.name).join(`, `)} updated`:``,o=t??e.updaters[0];return{kind:`slow-commit`,...o?M(o):{component:`#${e.index}`},costMs:e.durationMs,evidence:`commit #${e.index} took ${j(e.durationMs)} rendering ${e.rendered} components${r}${i}${a}; most time in ${n.join(`, `)}`,fix:`render less ${t?`under ${t.name} `:``}per update (memoize, virtualize, or defer)`}}function be(e,t,n){let r=ge(n);return t.filter(e=>e.durationMs>=48).filter(t=>_e(e,e.commits[t.index],r)<t.durationMs*.5).sort((e,t)=>t.durationMs-e.durationMs).slice(0,2).map(ye)}function xe(e,t){let n={};for(let r of e.commits){let i=!1;for(let n of w(e,r))if(_(n,t)&&n.causes.includes(`context`)){i=!0;break}if(i)for(let t of b(e,r.updaters))C(n,t.name)}return O(n,1).slice(0,2)}function z(e,t={},n=[]){let r=D(e),{components:i,commits:a}=ce(r,t),o=a.filter(e=>e.durationMs>16),s=a.reduce((e,t)=>e&&e.durationMs>=t.durationMs?e:t,null),c=[];for(let e of i){if(h(e.name))continue;let t=[de(e),fe(e,e.causes.context>0?xe(r,e):[]),pe(e)].filter(e=>e!==null),n=t.length===0||e.maxSelfMs>=16?le(e):null,i=n?[n,...t]:t;c.push(...i)}c.push(...me(r,a)),c.push(...I(r)),c.push(...L(r)),c.push(...be(r,a,c));let l=a.reduce((e,t)=>e+t.durationMs,0),u=Math.max(2,l*.03),d=c.filter(e=>e.costMs>=u).sort((e,t)=>t.costMs-e.costMs);return{wallMs:r.stoppedAt-r.startedAt,commitCount:a.length,renderMs:l,slowCommitCount:o.length,worstCommit:s?{index:s.index,durationMs:s.durationMs}:null,naming:r.naming,notes:n,components:i,commits:a,findings:d}}const B=E,V=e=>`${(e/1e3).toFixed(1)}s`,H=V;function Se(e){let t=[`React profile ${H(e.wallMs)}: ${e.commitCount} commits, ${B(e.renderMs)} rendering`];return e.worstCommit&&e.slowCommitCount>0&&t.push(`${e.slowCommitCount} over 16ms (worst #${e.worstCommit.index} ${B(e.worstCommit.durationMs)})`),t.join(`, `)}function Ce(e,t=5){let n=e.notes.map(e=>`Note: ${e}`);if(e.commitCount===0)return u([`React profile: no commits recorded. Start profiling, then perform the interaction before stopping.`,...n]);let r=[Se(e)],i=e.findings.slice(0,t);if(i.length===0)r.push(`No render problems above thresholds.`);else{i.forEach((e,t)=>{r.push(`${t+1}. ${e.kind} ${e.component}: ${e.evidence} -> ${e.fix}`)});let t=e.findings.length-i.length;t>0&&r.push(`+${t} smaller findings (--limit ${e.findings.length})`)}return r.push(...n),e.naming===`lookup`&&r.push(`Note: component names came from mounted elements; components unmounted during the profile are left out.`),r.push(`More: profile report [Component] | profile commit [N]`),u(r)}function U(e){return Object.entries(e).filter(([,e])=>e>0).sort((e,t)=>t[1]-e[1]).map(([e,t])=>`${e} ${t}`).join(`, `)||`unrecorded`}function W(e,t){return e<t?[` +${t-e} more (--limit ${t})`]:[]}function G(e,t=4){return Object.entries(e).sort((e,t)=>t[1]-e[1]).slice(0,t).map(([e,t])=>`${e} ${t}`).join(`, `)}function K(e){let t=e.renders>0?e.selfMs/e.renders:0,n=e.instances>1?` ${e.instances} inst`:``;return`${e.name} [${e.kind}] self ${B(e.selfMs)} avg ${B(t)} max ${B(e.maxSelfMs)} renders ${e.renders}${n}`}function we(e,t){if(e.components.length===0)return`No component renders recorded.`;let n=e.components.slice(0,t);return u([`Components by self time:`,...n.map(e=>{let t=G(e.changedProps);return` ${K(e)}: ${U(e.causes)}${t?`; changed props ${t}`:``}`}),...W(n.length,e.components.length)])}function Te(e,t){let n=e.components.filter(e=>e.name===t);return n.length>0?n:e.components.filter(e=>e.name.toLowerCase()===t.toLowerCase())}function Ee(e,t){let n=[K(t),`causes: ${U(t.causes)}`],r=Object.entries(t.changedProps).sort((e,t)=>t[1]-e[1]).map(([e,n])=>`${e} ${n}${t.propKinds[e]?` (${t.propKinds[e]})`:``}`);r.length>0&&n.push(`changed props: ${r.join(`, `)}`);let i=G(t.changedState,8);i&&n.push(`changed state: ${i}`);let a=G(t.changedHooks,8);a&&n.push(`changed hooks (by index): ${a}`);let o=G(t.owners,3);if(o&&n.push(`rendered by: ${o}`),t.costliestCommits.length>0){let r=t.costliestCommits.map(({index:t,selfMs:n})=>{let r=e.commits[t];return`#${t} ${B(n)}${r?` of ${B(r.durationMs)}`:``}`});n.push(`its costliest commits (self time of commit duration): ${r.join(`, `)}`)}return n}function De(e,t){return u(t.flatMap(t=>[...Ee(e,t),...e.findings.filter(e=>N(e,t)).map(e=>`finding ${e.kind}: ${e.evidence} -> ${e.fix}`)]))}function q(e){let t=e.updaters.length>0?` <- ${e.updaters.map(e=>e.name).join(`, `)}`:``,n=e.mounts>0?` (${e.mounts} mounted)`:``;return`#${e.index} +${H(e.atMs)} ${B(e.durationMs)} ${e.rendered} rendered${n}${t}`}function J(e,t){return e.commits.length<=t?e.commits:[...e.commits].sort((e,t)=>t.durationMs-e.durationMs).slice(0,t).sort((e,t)=>e.index-t.index)}function Oe(e,t){if(e.commits.length===0)return`No commits recorded.`;let n=J(e,t),r=n.length<e.commits.length?`Commits (${n.length} slowest of ${e.commits.length}, --limit ${e.commits.length} for all):`:`Commits:`;return u([r,...n.map(e=>` ${q(e)}`)])}function ke(e,t){let n=[q(e)],r=e.components.slice(0,t);for(let e of r){let t=e.instances>1?` x${e.instances}`:``;n.push(` ${e.name} [${e.kind}]${t} self ${B(e.selfMs)} ${e.causes.join(`+`)||`unrecorded`}`)}return n.push(...W(r.length,e.components.length)),u(n)}const Y=[`start`,`stop`,`report`,`commit`];function Ae(e){return Y.includes(e)}function X(e,t){switch(e){case`start`:return{usage:`profile start`,positionals:0,options:d};case`stop`:return{usage:`profile stop`,positionals:0,options:[...d,`limit`]};case`report`:return t===void 0?{usage:`profile report`,positionals:1,options:[`limit`]}:{usage:`profile report <Component>`,positionals:1,options:[]};case`commit`:return{usage:`profile commit`,positionals:1,options:[`limit`]}}}function je(t){let[n,...r]=t;if(!Ae(n))throw new e(`INVALID_ARGS`,`Unknown react-devtools profile command: ${n??`(none)`}.`,{hint:`Use one of: ${Y.join(`, `)}.`});let i=l(r,e=>X(n,e[0]));return{...i,subcommand:n,target:i.positionals[0]}}function Z(e){return m.join(e.stateDir,`react-profiles`,`${n(e.session)}.json`)}function Q(e,n){let r=Z(e);return p.mkdirSync(m.dirname(r),{recursive:!0}),t({destination:r,contents:`${JSON.stringify(n)}\n`}),r}function Me(e){return e?.version===2&&Array.isArray(e.profile?.commits)&&typeof e.profile.elements==`object`&&Array.isArray(e.notes)}function $(t){let n;try{n=p.readFileSync(Z(t),`utf8`)}catch{throw new e(`COMMAND_FAILED`,`No React profile saved for session ${t.session}.`,{hint:`Run react-devtools profile start, perform the interaction, then react-devtools profile stop.`})}let r;try{r=JSON.parse(n)}catch{r=void 0}if(!Me(r))throw new e(`COMMAND_FAILED`,`The saved React profile has an unsupported format.`,{hint:`Record a new profile with react-devtools profile start and stop.`});return z(r.profile,r.propKinds,r.notes)}const Ne=e=>V(Math.max(0,e));async function Pe(e,t){return await r(e,t,async(e,t)=>{let n=await c(e,`start`),r=i(t);if(!n.ok&&n.reason===`already-profiling`)return{app:r,alreadyProfiling:!0,message:`Already profiling ${r} for ${Ne(n.elapsedMs??0)}; run react-devtools profile stop to read it.`};if(!n.ok)throw a(n);return{app:r,attach:n.attach,message:`Profiling React renders in ${r}. Perform the interaction, then run react-devtools profile stop.`}})}async function Fe(e,t){let n=ae(t);if(Object.keys(n).length===0)return{propKinds:{},notes:[]};try{return{propKinds:await c(e,`describeProps`,n),notes:[]}}catch(e){return{propKinds:{},notes:[`Changed prop values could not be inspected: ${e instanceof Error?e.message:String(e)}`]}}}async function Ie(e,t){return await r(e,t,async(e,n)=>{let r=await c(e,`stop`);if(!r.ok)throw a(r);let{ok:o,failures:s,...l}=r,u=i(n),d={version:2,savedAt:new Date().toISOString(),appId:u,deviceName:n.deviceName,profile:l,propKinds:{},notes:s.map(e=>`A React renderer's profile could not be read: ${e}`)};Q(t,{...d,notes:[...d.notes,`Changed prop values have not been inspected; collection may have been interrupted.`]});let f=await Fe(e,l);return d.propKinds=f.propKinds,d.notes.push(...f.notes),Q(t,d),{appId:u,analysis:z(l,d.propKinds,d.notes)}})}function Le(t,n){let r=Te(t,n);if(r.length===0)throw new e(`COMMAND_FAILED`,`No renders of ${n} in the saved profile.`,{hint:`Use a name that react-devtools profile report lists.`});return r}function Re(t,n){let r=n.replace(/^#/,``),i=/^\d+$/.test(r)?t.commits[Number(r)]:void 0;if(!i)throw new e(`INVALID_ARGS`,`No commit ${n} in the saved profile.`,{hint:`Use a commit index from 0 to ${Math.max(t.commits.length-1,0)}.`});return i}const ze={start:async(e,t)=>{let n=await Pe(e,t);return{text:n.message,data:n}},stop:async(e,t)=>{let{appId:n,analysis:r}=await Ie(e,t);return{text:Ce(r,e.limit??5),data:{appId:n,wallMs:r.wallMs,commitCount:r.commitCount,renderMs:r.renderMs,slowCommitCount:r.slowCommitCount,worstCommit:r.worstCommit,findings:r.findings.slice(0,e.limit??r.findings.length),notes:r.notes,savedTo:Z(t)}}},report:async(e,t)=>{let n=$(t);if(e.target===void 0){let t=e.limit??10;return{text:we(n,t),data:{components:n.components.slice(0,t)}}}let r=Le(n,e.target);return{text:De(n,r),data:{components:r,findings:n.findings.filter(e=>r.some(t=>N(e,t)))}}},commit:async(e,t)=>{let n=$(t);if(e.target===void 0){let t=e.limit??20;return{text:Oe(n,t),data:{commits:J(n,t)}}}let r=Re(n,e.target),i=e.limit??10;return{text:ke(r,i),data:{...r,components:r.components.slice(0,i)}}}};async function Be(e,t){let n=je(e);return await ze[n.subcommand](n,t)}export{Be as runReactProfileCommand};