@react-perfscope/ui 0.7.0 → 0.7.1
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/dist/index.cjs +34 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -357,7 +357,7 @@ function Widget(props) {
|
|
|
357
357
|
}
|
|
358
358
|
|
|
359
359
|
// src/panel.tsx
|
|
360
|
-
import { useState as useState3, useMemo as
|
|
360
|
+
import { useState as useState3, useMemo as useMemo5, useEffect, useRef as useRef2 } from "preact/hooks";
|
|
361
361
|
import { unsupportedKinds } from "@react-perfscope/core";
|
|
362
362
|
|
|
363
363
|
// src/overlay.ts
|
|
@@ -1903,6 +1903,7 @@ function RenderInsights({ signals, onSelect }) {
|
|
|
1903
1903
|
}
|
|
1904
1904
|
|
|
1905
1905
|
// src/inp-episode.tsx
|
|
1906
|
+
import { useMemo as useMemo3 } from "preact/hooks";
|
|
1906
1907
|
import { correlate } from "@react-perfscope/core";
|
|
1907
1908
|
|
|
1908
1909
|
// src/episode-shared.tsx
|
|
@@ -1973,7 +1974,7 @@ function phaseMs(episode, phase) {
|
|
|
1973
1974
|
}
|
|
1974
1975
|
function InpEpisode({ signals }) {
|
|
1975
1976
|
const { t } = useI18n();
|
|
1976
|
-
const episode = worstInteractionEpisode(signals);
|
|
1977
|
+
const episode = useMemo3(() => worstInteractionEpisode(signals), [signals]);
|
|
1977
1978
|
if (!episode || episode.anchor.kind !== "interaction") return null;
|
|
1978
1979
|
const a = episode.anchor;
|
|
1979
1980
|
const target = a.target ? ` on ${a.target}` : "";
|
|
@@ -2029,6 +2030,7 @@ function InpEpisode({ signals }) {
|
|
|
2029
2030
|
}
|
|
2030
2031
|
|
|
2031
2032
|
// src/long-task-episode.tsx
|
|
2033
|
+
import { useMemo as useMemo4 } from "preact/hooks";
|
|
2032
2034
|
import { correlate as correlate2 } from "@react-perfscope/core";
|
|
2033
2035
|
import { jsx as jsx8, jsxs as jsxs8 } from "preact/jsx-runtime";
|
|
2034
2036
|
function worstLongTaskEpisode(signals) {
|
|
@@ -2041,7 +2043,7 @@ function worstLongTaskEpisode(signals) {
|
|
|
2041
2043
|
}
|
|
2042
2044
|
function LongTaskEpisode({ signals }) {
|
|
2043
2045
|
const { t } = useI18n();
|
|
2044
|
-
const episode = worstLongTaskEpisode(signals);
|
|
2046
|
+
const episode = useMemo4(() => worstLongTaskEpisode(signals), [signals]);
|
|
2045
2047
|
if (!episode || episode.anchor.kind !== "long-task") return null;
|
|
2046
2048
|
if (episode.members.length === 0) return null;
|
|
2047
2049
|
const a = episode.anchor;
|
|
@@ -2866,9 +2868,9 @@ function LanguageToggle() {
|
|
|
2866
2868
|
function Panel(props) {
|
|
2867
2869
|
const { result, onClose, position = "bottom-right", resolveFrame } = props;
|
|
2868
2870
|
const { t } = useI18n();
|
|
2869
|
-
const grouped =
|
|
2871
|
+
const grouped = useMemo5(() => groupByKind(result.signals), [result.signals]);
|
|
2870
2872
|
const kindsPresent = KIND_ORDER.filter((k) => grouped[k].length > 0);
|
|
2871
|
-
const unsupported =
|
|
2873
|
+
const unsupported = useMemo5(() => unsupportedKinds(), []);
|
|
2872
2874
|
const hasTimelineSignals = result.signals.some((s) => s.kind !== "web-vital") || (result.heapSamples?.length ?? 0) > 0 || (result.frames?.length ?? 0) > 0 || (result.leakSuspects?.length ?? 0) > 0;
|
|
2873
2875
|
const [activeTab, setActiveTab] = useState3(
|
|
2874
2876
|
kindsPresent[0] ?? "forced-reflow"
|
|
@@ -3263,7 +3265,8 @@ function App(props) {
|
|
|
3263
3265
|
return;
|
|
3264
3266
|
}
|
|
3265
3267
|
const tick = () => {
|
|
3266
|
-
|
|
3268
|
+
const elapsed = performance.now() - startedAtRef.current;
|
|
3269
|
+
setElapsedMs(Math.floor(elapsed / 1e3) * 1e3);
|
|
3267
3270
|
rafRef.current = requestAnimationFrame(tick);
|
|
3268
3271
|
};
|
|
3269
3272
|
rafRef.current = requestAnimationFrame(tick);
|
|
@@ -3312,6 +3315,11 @@ function App(props) {
|
|
|
3312
3315
|
import { jsx as jsx11 } from "preact/jsx-runtime";
|
|
3313
3316
|
function mount(opts) {
|
|
3314
3317
|
const { recorder, position = "bottom-right", host = document.body, resolveFrame, finalize } = opts;
|
|
3318
|
+
if (host.querySelector("[data-perfscope-host]")) {
|
|
3319
|
+
console.warn("[react-perfscope] mount(): a widget is already mounted here \u2014 ignoring this call");
|
|
3320
|
+
return () => {
|
|
3321
|
+
};
|
|
3322
|
+
}
|
|
3315
3323
|
return mountShadow(
|
|
3316
3324
|
/* @__PURE__ */ jsx11(App, { recorder, position, resolveFrame, finalize }),
|
|
3317
3325
|
{ parent: host }
|