* ui, tracker, backend: support long animation metrics * ui: fix LAT mapping * ui: change jump button display, longTask time definition * ui: border for rows * ui: refine LAT design * tracker: regenerate messages
72 lines
1.9 KiB
TypeScript
72 lines
1.9 KiB
TypeScript
import React from 'react';
|
|
import { LongAnimationTask } from './type';
|
|
import { Tag } from 'antd';
|
|
import { Code } from 'lucide-react';
|
|
|
|
function getAddress(script: LongAnimationTask['scripts'][number]) {
|
|
return `${script.sourceURL}${script.sourceFunctionName ? ':' + script.sourceFunctionName : ''}${script.sourceCharPosition && script.sourceCharPosition >= 0 ? ':' + script.sourceCharPosition : ''}`;
|
|
}
|
|
function ScriptTitle({
|
|
script,
|
|
}: {
|
|
script: LongAnimationTask['scripts'][number];
|
|
}) {
|
|
return script.invokerType ? (
|
|
<span>{script.invokerType}</span>
|
|
) : (
|
|
<span>{script.name}</span>
|
|
);
|
|
}
|
|
|
|
function ScriptInfo({
|
|
script,
|
|
}: {
|
|
script: LongAnimationTask['scripts'][number];
|
|
}) {
|
|
const hasInvoker = script.invoker !== script.sourceURL;
|
|
return (
|
|
<div className={'border-l border-l-gray-light pl-1'}>
|
|
{hasInvoker ? (
|
|
<InfoEntry title={'invoker:'} value={script.invoker} />
|
|
) : null}
|
|
<InfoEntry title={'address:'} value={getAddress(script)} />
|
|
<InfoEntry
|
|
title={'script execution:'}
|
|
value={`${Math.round(script.duration)} ms`}
|
|
/>
|
|
<InfoEntry
|
|
title={'pause duration:'}
|
|
value={`${Math.round(script.pauseDuration)} ms`}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function InfoEntry({
|
|
title,
|
|
value,
|
|
}: {
|
|
title: string;
|
|
value: string | number;
|
|
}) {
|
|
return (
|
|
<div className={'flex items-center gap-1 text-sm'}>
|
|
<div className={'text-disabled-text'}>{title}</div>
|
|
<div className='font-mono text-neutral-600'>{value}</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function Script({ script }: { script: LongAnimationTask['scripts'][number] }) {
|
|
return (
|
|
<div className="flex flex-col mb-4">
|
|
<Tag className='w-fit font-mono text-sm font-bold flex gap-1 items-center rounded-lg'>
|
|
<Code size={12} />
|
|
<ScriptTitle script={script} />
|
|
</Tag>
|
|
<ScriptInfo script={script} />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default Script;
|