@react-perfscope/ui 0.1.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/LICENSE +21 -0
- package/README.md +111 -0
- package/dist/index.cjs +3025 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +87 -0
- package/dist/index.d.ts +87 -0
- package/dist/index.js +2991 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/// <reference lib="es2015" />
|
|
2
|
+
/// <reference lib="dom" />
|
|
3
|
+
|
|
4
|
+
import { Recorder, StackFrame, RecordingResult } from '@react-perfscope/core';
|
|
5
|
+
import { ComponentChild, h } from 'preact';
|
|
6
|
+
|
|
7
|
+
type WidgetPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
8
|
+
interface MountOptions {
|
|
9
|
+
/** The recorder to control. The UI calls .start()/.stop() on it. */
|
|
10
|
+
recorder: Recorder;
|
|
11
|
+
/** Corner placement of the floating widget. Defaults to 'bottom-right'. */
|
|
12
|
+
position?: WidgetPosition;
|
|
13
|
+
/**
|
|
14
|
+
* The host element under which the Shadow DOM root is created. Defaults
|
|
15
|
+
* to document.body. Useful for testing or custom layouts.
|
|
16
|
+
*/
|
|
17
|
+
host?: HTMLElement;
|
|
18
|
+
/**
|
|
19
|
+
* Optional async resolver that maps a captured StackFrame to its original
|
|
20
|
+
* source position. The Panel uses this when expanding a row with stack data.
|
|
21
|
+
* Defaults to a no-op if not provided.
|
|
22
|
+
*/
|
|
23
|
+
resolveFrame?: (frame: StackFrame) => Promise<StackFrame>;
|
|
24
|
+
/**
|
|
25
|
+
* Optional async post-processor run after `recorder.stop()`. The Panel
|
|
26
|
+
* renders the raw result immediately, then re-renders with the resolved
|
|
27
|
+
* value (e.g. self-profiling long-task attribution, which only becomes
|
|
28
|
+
* available once the Profiler trace settles).
|
|
29
|
+
*/
|
|
30
|
+
finalize?: (result: RecordingResult) => Promise<RecordingResult>;
|
|
31
|
+
}
|
|
32
|
+
type UnmountFn = () => void;
|
|
33
|
+
|
|
34
|
+
interface MountShadowOptions {
|
|
35
|
+
/** Parent element under which the host div is appended. Defaults to document.body. */
|
|
36
|
+
parent?: HTMLElement;
|
|
37
|
+
}
|
|
38
|
+
declare function mountShadow(vnode: ComponentChild, opts?: MountShadowOptions): () => void;
|
|
39
|
+
|
|
40
|
+
declare function mount(opts: MountOptions): UnmountFn;
|
|
41
|
+
|
|
42
|
+
interface WidgetProps {
|
|
43
|
+
recording: boolean;
|
|
44
|
+
elapsedMs?: number;
|
|
45
|
+
onToggle: () => void;
|
|
46
|
+
position?: WidgetPosition;
|
|
47
|
+
}
|
|
48
|
+
declare function Widget(props: WidgetProps): h.JSX.Element;
|
|
49
|
+
|
|
50
|
+
interface PanelProps {
|
|
51
|
+
result: RecordingResult;
|
|
52
|
+
position?: WidgetPosition;
|
|
53
|
+
onClose: () => void;
|
|
54
|
+
resolveFrame?: (frame: StackFrame) => Promise<StackFrame>;
|
|
55
|
+
}
|
|
56
|
+
declare function Panel(props: PanelProps): h.JSX.Element;
|
|
57
|
+
|
|
58
|
+
interface AppProps {
|
|
59
|
+
recorder: Recorder;
|
|
60
|
+
position?: WidgetPosition;
|
|
61
|
+
resolveFrame?: (frame: StackFrame) => Promise<StackFrame>;
|
|
62
|
+
finalize?: (result: RecordingResult) => Promise<RecordingResult>;
|
|
63
|
+
}
|
|
64
|
+
declare function App(props: AppProps): h.JSX.Element;
|
|
65
|
+
|
|
66
|
+
interface OverlayStyle {
|
|
67
|
+
/** Border color (CSS color). Defaults to red. */
|
|
68
|
+
border?: string;
|
|
69
|
+
/** Background fill (CSS color). Defaults to translucent red. */
|
|
70
|
+
fill?: string;
|
|
71
|
+
/** Optional dashed border for "previous position" overlays. */
|
|
72
|
+
dashed?: boolean;
|
|
73
|
+
}
|
|
74
|
+
declare function showOverlay(id: string, rect: DOMRect, style?: OverlayStyle): void;
|
|
75
|
+
/**
|
|
76
|
+
* Trigger the fade-out transition and remove the overlay after it completes.
|
|
77
|
+
* If the overlay is shown again before the fade timer fires, the timer is
|
|
78
|
+
* cancelled and the element is kept.
|
|
79
|
+
*/
|
|
80
|
+
declare function hideOverlay(id: string): void;
|
|
81
|
+
/**
|
|
82
|
+
* Remove every overlay immediately, skipping the fade. Used by Panel
|
|
83
|
+
* unmount cleanup where we don't want lingering overlays.
|
|
84
|
+
*/
|
|
85
|
+
declare function hideAllOverlays(): void;
|
|
86
|
+
|
|
87
|
+
export { App, type MountOptions, Panel, type UnmountFn, Widget, type WidgetPosition, hideAllOverlays, hideOverlay, mount, mountShadow, showOverlay };
|