@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.cjs
CHANGED
|
@@ -90,7 +90,7 @@ function mountShadow(vnode, opts = {}) {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
// src/app.tsx
|
|
93
|
-
var
|
|
93
|
+
var import_hooks6 = require("preact/hooks");
|
|
94
94
|
|
|
95
95
|
// src/i18n.ts
|
|
96
96
|
var import_preact2 = require("preact");
|
|
@@ -390,7 +390,7 @@ function Widget(props) {
|
|
|
390
390
|
}
|
|
391
391
|
|
|
392
392
|
// src/panel.tsx
|
|
393
|
-
var
|
|
393
|
+
var import_hooks5 = require("preact/hooks");
|
|
394
394
|
var import_core4 = require("@react-perfscope/core");
|
|
395
395
|
|
|
396
396
|
// src/overlay.ts
|
|
@@ -1936,6 +1936,7 @@ function RenderInsights({ signals, onSelect }) {
|
|
|
1936
1936
|
}
|
|
1937
1937
|
|
|
1938
1938
|
// src/inp-episode.tsx
|
|
1939
|
+
var import_hooks3 = require("preact/hooks");
|
|
1939
1940
|
var import_core2 = require("@react-perfscope/core");
|
|
1940
1941
|
|
|
1941
1942
|
// src/episode-shared.tsx
|
|
@@ -2006,7 +2007,7 @@ function phaseMs(episode, phase) {
|
|
|
2006
2007
|
}
|
|
2007
2008
|
function InpEpisode({ signals }) {
|
|
2008
2009
|
const { t } = useI18n();
|
|
2009
|
-
const episode = worstInteractionEpisode(signals);
|
|
2010
|
+
const episode = (0, import_hooks3.useMemo)(() => worstInteractionEpisode(signals), [signals]);
|
|
2010
2011
|
if (!episode || episode.anchor.kind !== "interaction") return null;
|
|
2011
2012
|
const a = episode.anchor;
|
|
2012
2013
|
const target = a.target ? ` on ${a.target}` : "";
|
|
@@ -2062,6 +2063,7 @@ function InpEpisode({ signals }) {
|
|
|
2062
2063
|
}
|
|
2063
2064
|
|
|
2064
2065
|
// src/long-task-episode.tsx
|
|
2066
|
+
var import_hooks4 = require("preact/hooks");
|
|
2065
2067
|
var import_core3 = require("@react-perfscope/core");
|
|
2066
2068
|
var import_jsx_runtime8 = require("preact/jsx-runtime");
|
|
2067
2069
|
function worstLongTaskEpisode(signals) {
|
|
@@ -2074,7 +2076,7 @@ function worstLongTaskEpisode(signals) {
|
|
|
2074
2076
|
}
|
|
2075
2077
|
function LongTaskEpisode({ signals }) {
|
|
2076
2078
|
const { t } = useI18n();
|
|
2077
|
-
const episode = worstLongTaskEpisode(signals);
|
|
2079
|
+
const episode = (0, import_hooks4.useMemo)(() => worstLongTaskEpisode(signals), [signals]);
|
|
2078
2080
|
if (!episode || episode.anchor.kind !== "long-task") return null;
|
|
2079
2081
|
if (episode.members.length === 0) return null;
|
|
2080
2082
|
const a = episode.anchor;
|
|
@@ -2413,9 +2415,9 @@ function StackFrames({
|
|
|
2413
2415
|
}) {
|
|
2414
2416
|
const { t } = useI18n();
|
|
2415
2417
|
const original = raw.slice(0, limit);
|
|
2416
|
-
const [frames, setFrames] = (0,
|
|
2417
|
-
const [resolving, setResolving] = (0,
|
|
2418
|
-
(0,
|
|
2418
|
+
const [frames, setFrames] = (0, import_hooks5.useState)(original);
|
|
2419
|
+
const [resolving, setResolving] = (0, import_hooks5.useState)(false);
|
|
2420
|
+
(0, import_hooks5.useEffect)(() => {
|
|
2419
2421
|
if (!resolveFrame || original.length === 0) return;
|
|
2420
2422
|
let cancelled = false;
|
|
2421
2423
|
setResolving(true);
|
|
@@ -2454,8 +2456,8 @@ function HotFunctions({
|
|
|
2454
2456
|
resolveFrame
|
|
2455
2457
|
}) {
|
|
2456
2458
|
const { t } = useI18n();
|
|
2457
|
-
const [frames, setFrames] = (0,
|
|
2458
|
-
(0,
|
|
2459
|
+
const [frames, setFrames] = (0, import_hooks5.useState)(attribution.map((a) => a.frame));
|
|
2460
|
+
(0, import_hooks5.useEffect)(() => {
|
|
2459
2461
|
if (!resolveFrame) return;
|
|
2460
2462
|
let cancelled = false;
|
|
2461
2463
|
Promise.all(attribution.map((a) => resolveFrame(a.frame))).then((resolved) => {
|
|
@@ -2899,21 +2901,21 @@ function LanguageToggle() {
|
|
|
2899
2901
|
function Panel(props) {
|
|
2900
2902
|
const { result, onClose, position = "bottom-right", resolveFrame } = props;
|
|
2901
2903
|
const { t } = useI18n();
|
|
2902
|
-
const grouped = (0,
|
|
2904
|
+
const grouped = (0, import_hooks5.useMemo)(() => groupByKind(result.signals), [result.signals]);
|
|
2903
2905
|
const kindsPresent = KIND_ORDER.filter((k) => grouped[k].length > 0);
|
|
2904
|
-
const unsupported = (0,
|
|
2906
|
+
const unsupported = (0, import_hooks5.useMemo)(() => (0, import_core4.unsupportedKinds)(), []);
|
|
2905
2907
|
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;
|
|
2906
|
-
const [activeTab, setActiveTab] = (0,
|
|
2908
|
+
const [activeTab, setActiveTab] = (0, import_hooks5.useState)(
|
|
2907
2909
|
kindsPresent[0] ?? "forced-reflow"
|
|
2908
2910
|
);
|
|
2909
2911
|
const activeKind = activeTab === "timeline" ? null : activeTab;
|
|
2910
2912
|
const setActiveKind = (k) => setActiveTab(k);
|
|
2911
|
-
const [expandedKey, setExpandedKey] = (0,
|
|
2912
|
-
const [groupMode, setGroupMode] = (0,
|
|
2913
|
-
const [sortMode, setSortMode] = (0,
|
|
2914
|
-
const [filterText, setFilterText] = (0,
|
|
2915
|
-
const activeOverlayCount = (0,
|
|
2916
|
-
(0,
|
|
2913
|
+
const [expandedKey, setExpandedKey] = (0, import_hooks5.useState)(null);
|
|
2914
|
+
const [groupMode, setGroupMode] = (0, import_hooks5.useState)({});
|
|
2915
|
+
const [sortMode, setSortMode] = (0, import_hooks5.useState)({});
|
|
2916
|
+
const [filterText, setFilterText] = (0, import_hooks5.useState)({});
|
|
2917
|
+
const activeOverlayCount = (0, import_hooks5.useRef)(0);
|
|
2918
|
+
(0, import_hooks5.useEffect)(() => () => hideAllOverlays(), []);
|
|
2917
2919
|
function handleHover(signal) {
|
|
2918
2920
|
if (!signal) {
|
|
2919
2921
|
for (let i = 0; i < activeOverlayCount.current; i++) {
|
|
@@ -3284,19 +3286,20 @@ function Panel(props) {
|
|
|
3284
3286
|
var import_jsx_runtime10 = require("preact/jsx-runtime");
|
|
3285
3287
|
function App(props) {
|
|
3286
3288
|
const { recorder, position = "bottom-right", resolveFrame, finalize } = props;
|
|
3287
|
-
const [recording, setRecording] = (0,
|
|
3288
|
-
const [result, setResult] = (0,
|
|
3289
|
-
const [elapsedMs, setElapsedMs] = (0,
|
|
3290
|
-
const startedAtRef = (0,
|
|
3291
|
-
const rafRef = (0,
|
|
3292
|
-
const resultTokenRef = (0,
|
|
3293
|
-
(0,
|
|
3289
|
+
const [recording, setRecording] = (0, import_hooks6.useState)(false);
|
|
3290
|
+
const [result, setResult] = (0, import_hooks6.useState)(null);
|
|
3291
|
+
const [elapsedMs, setElapsedMs] = (0, import_hooks6.useState)(0);
|
|
3292
|
+
const startedAtRef = (0, import_hooks6.useRef)(0);
|
|
3293
|
+
const rafRef = (0, import_hooks6.useRef)(null);
|
|
3294
|
+
const resultTokenRef = (0, import_hooks6.useRef)(0);
|
|
3295
|
+
(0, import_hooks6.useEffect)(() => {
|
|
3294
3296
|
if (!recording) {
|
|
3295
3297
|
if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);
|
|
3296
3298
|
return;
|
|
3297
3299
|
}
|
|
3298
3300
|
const tick = () => {
|
|
3299
|
-
|
|
3301
|
+
const elapsed = performance.now() - startedAtRef.current;
|
|
3302
|
+
setElapsedMs(Math.floor(elapsed / 1e3) * 1e3);
|
|
3300
3303
|
rafRef.current = requestAnimationFrame(tick);
|
|
3301
3304
|
};
|
|
3302
3305
|
rafRef.current = requestAnimationFrame(tick);
|
|
@@ -3345,6 +3348,11 @@ function App(props) {
|
|
|
3345
3348
|
var import_jsx_runtime11 = require("preact/jsx-runtime");
|
|
3346
3349
|
function mount(opts) {
|
|
3347
3350
|
const { recorder, position = "bottom-right", host = document.body, resolveFrame, finalize } = opts;
|
|
3351
|
+
if (host.querySelector("[data-perfscope-host]")) {
|
|
3352
|
+
console.warn("[react-perfscope] mount(): a widget is already mounted here \u2014 ignoring this call");
|
|
3353
|
+
return () => {
|
|
3354
|
+
};
|
|
3355
|
+
}
|
|
3348
3356
|
return mountShadow(
|
|
3349
3357
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(App, { recorder, position, resolveFrame, finalize }),
|
|
3350
3358
|
{ parent: host }
|