@buoy-gg/js-top 7.0.41 → 7.0.42
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/README.md +12 -71
- package/lib/commonjs/index.js +1 -99
- package/lib/commonjs/js-top/components/BusySparkline.js +1 -56
- package/lib/commonjs/js-top/components/JsTopHudOverlay.js +1 -79
- package/lib/commonjs/js-top/components/JsTopModal.js +1 -349
- package/lib/commonjs/js-top/components/TaskDetailView.js +1 -330
- package/lib/commonjs/js-top/components/TaskTable.js +1 -360
- package/lib/commonjs/js-top/engine/JsTopController.js +1 -350
- package/lib/commonjs/js-top/engine/aggregator.js +1 -148
- package/lib/commonjs/js-top/engine/busyProbe.js +1 -101
- package/lib/commonjs/js-top/engine/frameStack.js +1 -133
- package/lib/commonjs/js-top/engine/longtasks.js +1 -141
- package/lib/commonjs/js-top/engine/now.js +1 -38
- package/lib/commonjs/js-top/engine/originRegistry.js +1 -402
- package/lib/commonjs/js-top/engine/patches/bridge.js +1 -60
- package/lib/commonjs/js-top/engine/patches/microtasks.js +1 -27
- package/lib/commonjs/js-top/engine/patches/promises.js +1 -65
- package/lib/commonjs/js-top/engine/patches/timers.js +1 -66
- package/lib/commonjs/js-top/engine/state.js +1 -63
- package/lib/commonjs/js-top/engine/symbolicate.js +1 -95
- package/lib/commonjs/js-top/sync/jsTopSyncAdapter.js +1 -74
- package/lib/commonjs/js-top/types/index.js +1 -46
- package/lib/commonjs/js-top/utils/preferences.js +1 -31
- package/lib/commonjs/preset.js +1 -75
- package/lib/module/index.js +1 -49
- package/lib/module/js-top/components/BusySparkline.js +1 -52
- package/lib/module/js-top/components/JsTopHudOverlay.js +1 -75
- package/lib/module/js-top/components/JsTopModal.js +1 -345
- package/lib/module/js-top/components/TaskDetailView.js +1 -326
- package/lib/module/js-top/components/TaskTable.js +1 -353
- package/lib/module/js-top/engine/JsTopController.js +1 -347
- package/lib/module/js-top/engine/aggregator.js +1 -136
- package/lib/module/js-top/engine/busyProbe.js +1 -94
- package/lib/module/js-top/engine/frameStack.js +1 -126
- package/lib/module/js-top/engine/longtasks.js +1 -133
- package/lib/module/js-top/engine/now.js +1 -33
- package/lib/module/js-top/engine/originRegistry.js +1 -388
- package/lib/module/js-top/engine/patches/bridge.js +1 -56
- package/lib/module/js-top/engine/patches/microtasks.js +1 -23
- package/lib/module/js-top/engine/patches/promises.js +1 -62
- package/lib/module/js-top/engine/patches/timers.js +1 -62
- package/lib/module/js-top/engine/state.js +1 -54
- package/lib/module/js-top/engine/symbolicate.js +1 -91
- package/lib/module/js-top/sync/jsTopSyncAdapter.js +1 -70
- package/lib/module/js-top/types/index.js +1 -42
- package/lib/module/js-top/utils/preferences.js +1 -26
- package/lib/module/preset.js +1 -71
- package/lib/web/index.mjs +2 -3
- package/package.json +2 -2
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/js-top/components/BusySparkline.js.map +0 -1
- package/lib/commonjs/js-top/components/JsTopHudOverlay.js.map +0 -1
- package/lib/commonjs/js-top/components/JsTopModal.js.map +0 -1
- package/lib/commonjs/js-top/components/TaskDetailView.js.map +0 -1
- package/lib/commonjs/js-top/components/TaskTable.js.map +0 -1
- package/lib/commonjs/js-top/engine/JsTopController.js.map +0 -1
- package/lib/commonjs/js-top/engine/aggregator.js.map +0 -1
- package/lib/commonjs/js-top/engine/busyProbe.js.map +0 -1
- package/lib/commonjs/js-top/engine/frameStack.js.map +0 -1
- package/lib/commonjs/js-top/engine/longtasks.js.map +0 -1
- package/lib/commonjs/js-top/engine/now.js.map +0 -1
- package/lib/commonjs/js-top/engine/originRegistry.js.map +0 -1
- package/lib/commonjs/js-top/engine/patches/bridge.js.map +0 -1
- package/lib/commonjs/js-top/engine/patches/microtasks.js.map +0 -1
- package/lib/commonjs/js-top/engine/patches/promises.js.map +0 -1
- package/lib/commonjs/js-top/engine/patches/timers.js.map +0 -1
- package/lib/commonjs/js-top/engine/state.js.map +0 -1
- package/lib/commonjs/js-top/engine/symbolicate.js.map +0 -1
- package/lib/commonjs/js-top/sync/jsTopSyncAdapter.js.map +0 -1
- package/lib/commonjs/js-top/types/index.js.map +0 -1
- package/lib/commonjs/js-top/utils/preferences.js.map +0 -1
- package/lib/commonjs/preset.js.map +0 -1
- package/lib/module/index.js.map +0 -1
- package/lib/module/js-top/components/BusySparkline.js.map +0 -1
- package/lib/module/js-top/components/JsTopHudOverlay.js.map +0 -1
- package/lib/module/js-top/components/JsTopModal.js.map +0 -1
- package/lib/module/js-top/components/TaskDetailView.js.map +0 -1
- package/lib/module/js-top/components/TaskTable.js.map +0 -1
- package/lib/module/js-top/engine/JsTopController.js.map +0 -1
- package/lib/module/js-top/engine/aggregator.js.map +0 -1
- package/lib/module/js-top/engine/busyProbe.js.map +0 -1
- package/lib/module/js-top/engine/frameStack.js.map +0 -1
- package/lib/module/js-top/engine/longtasks.js.map +0 -1
- package/lib/module/js-top/engine/now.js.map +0 -1
- package/lib/module/js-top/engine/originRegistry.js.map +0 -1
- package/lib/module/js-top/engine/patches/bridge.js.map +0 -1
- package/lib/module/js-top/engine/patches/microtasks.js.map +0 -1
- package/lib/module/js-top/engine/patches/promises.js.map +0 -1
- package/lib/module/js-top/engine/patches/timers.js.map +0 -1
- package/lib/module/js-top/engine/state.js.map +0 -1
- package/lib/module/js-top/engine/symbolicate.js.map +0 -1
- package/lib/module/js-top/sync/jsTopSyncAdapter.js.map +0 -1
- package/lib/module/js-top/types/index.js.map +0 -1
- package/lib/module/js-top/utils/preferences.js.map +0 -1
- package/lib/module/preset.js.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/js-top/components/BusySparkline.d.ts.map +0 -1
- package/lib/typescript/js-top/components/JsTopHudOverlay.d.ts.map +0 -1
- package/lib/typescript/js-top/components/JsTopModal.d.ts.map +0 -1
- package/lib/typescript/js-top/components/TaskDetailView.d.ts.map +0 -1
- package/lib/typescript/js-top/components/TaskTable.d.ts.map +0 -1
- package/lib/typescript/js-top/engine/JsTopController.d.ts.map +0 -1
- package/lib/typescript/js-top/engine/aggregator.d.ts.map +0 -1
- package/lib/typescript/js-top/engine/busyProbe.d.ts.map +0 -1
- package/lib/typescript/js-top/engine/frameStack.d.ts.map +0 -1
- package/lib/typescript/js-top/engine/longtasks.d.ts.map +0 -1
- package/lib/typescript/js-top/engine/now.d.ts.map +0 -1
- package/lib/typescript/js-top/engine/originRegistry.d.ts.map +0 -1
- package/lib/typescript/js-top/engine/patches/bridge.d.ts.map +0 -1
- package/lib/typescript/js-top/engine/patches/microtasks.d.ts.map +0 -1
- package/lib/typescript/js-top/engine/patches/promises.d.ts.map +0 -1
- package/lib/typescript/js-top/engine/patches/timers.d.ts.map +0 -1
- package/lib/typescript/js-top/engine/state.d.ts.map +0 -1
- package/lib/typescript/js-top/engine/symbolicate.d.ts.map +0 -1
- package/lib/typescript/js-top/sync/jsTopSyncAdapter.d.ts.map +0 -1
- package/lib/typescript/js-top/types/index.d.ts.map +0 -1
- package/lib/typescript/js-top/utils/preferences.d.ts.map +0 -1
- package/lib/typescript/preset.d.ts.map +0 -1
|
@@ -1,63 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.WRAPPED_TAG = exports.PATCHED_TAG = void 0;
|
|
7
|
-
exports.captureOriginals = captureOriginals;
|
|
8
|
-
exports.g = void 0;
|
|
9
|
-
exports.getOriginals = getOriginals;
|
|
10
|
-
exports.isActive = isActive;
|
|
11
|
-
exports.setActive = setActive;
|
|
12
|
-
/**
|
|
13
|
-
* Shared engine state + pre-patch originals.
|
|
14
|
-
*
|
|
15
|
-
* `active` is the single gate every patched global checks at schedule time:
|
|
16
|
-
* patches install once and are NEVER removed (restoring originals would
|
|
17
|
-
* clobber any wrapper another library — Sentry, Reanimated — layered on top
|
|
18
|
-
* of ours after install; same reasoning as highlight-updates' CommitProfiler
|
|
19
|
-
* hook). When inactive, a patched global forwards the raw callback to the
|
|
20
|
-
* original at the cost of one boolean check.
|
|
21
|
-
*
|
|
22
|
-
* `originals` are captured BEFORE patching so the engine's own probe and
|
|
23
|
-
* notify timers never flow through the wrappers — JS TOP must not list
|
|
24
|
-
* itself as a task.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
-
const g = exports.g =
|
|
29
|
-
// eslint-disable-next-line no-restricted-globals
|
|
30
|
-
typeof globalThis !== "undefined" ? globalThis : {};
|
|
31
|
-
let active = false;
|
|
32
|
-
function isActive() {
|
|
33
|
-
return active;
|
|
34
|
-
}
|
|
35
|
-
function setActive(on) {
|
|
36
|
-
active = on;
|
|
37
|
-
}
|
|
38
|
-
let originals = null;
|
|
39
|
-
|
|
40
|
-
/** Capture pre-patch globals. Idempotent; first call wins. */
|
|
41
|
-
function captureOriginals() {
|
|
42
|
-
if (!originals) {
|
|
43
|
-
originals = {
|
|
44
|
-
setTimeout: g.setTimeout?.bind(g),
|
|
45
|
-
setInterval: g.setInterval?.bind(g),
|
|
46
|
-
clearInterval: g.clearInterval?.bind(g),
|
|
47
|
-
clearTimeout: g.clearTimeout?.bind(g),
|
|
48
|
-
setImmediate: g.setImmediate?.bind(g),
|
|
49
|
-
requestAnimationFrame: g.requestAnimationFrame?.bind(g),
|
|
50
|
-
queueMicrotask: g.queueMicrotask?.bind(g)
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
return originals;
|
|
54
|
-
}
|
|
55
|
-
function getOriginals() {
|
|
56
|
-
return captureOriginals();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** Tag interned on patched globals so duplicate module instances skip re-patching. */
|
|
60
|
-
const PATCHED_TAG = exports.PATCHED_TAG = Symbol.for("buoy.jsTop.patched");
|
|
61
|
-
/** Marker set on wrapper functions so a wrapped fn is never wrapped twice. */
|
|
62
|
-
const WRAPPED_TAG = exports.WRAPPED_TAG = Symbol.for("buoy.jsTop.wrapped");
|
|
63
|
-
//# sourceMappingURL=state.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.WRAPPED_TAG=exports.PATCHED_TAG=void 0;exports.captureOriginals=captureOriginals;exports.g=void 0;exports.getOriginals=getOriginals;exports.isActive=isActive;exports.setActive=setActive;const g=exports.g=typeof globalThis!=="undefined"?globalThis:{};let active=false;function isActive(){return active}function setActive(e){active=e}let originals=null;function captureOriginals(){if(!originals){originals={setTimeout:g.setTimeout?.bind(g),setInterval:g.setInterval?.bind(g),clearInterval:g.clearInterval?.bind(g),clearTimeout:g.clearTimeout?.bind(g),setImmediate:g.setImmediate?.bind(g),requestAnimationFrame:g.requestAnimationFrame?.bind(g),queueMicrotask:g.queueMicrotask?.bind(g)}}return originals}function getOriginals(){return captureOriginals()}const PATCHED_TAG=exports.PATCHED_TAG=Symbol.for("buoy.jsTop.patched");const WRAPPED_TAG=exports.WRAPPED_TAG=Symbol.for("buoy.jsTop.wrapped");
|
|
@@ -1,95 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.buoyJsTopSymbolicateOrigin = buoyJsTopSymbolicateOrigin;
|
|
7
|
-
/**
|
|
8
|
-
* Dev-only origin symbolication via Metro's /symbolicate endpoint (the same
|
|
9
|
-
* one LogBox uses). Hermes stacks give function names + bundle offsets; for
|
|
10
|
-
* anonymous scheduling sites (the typical `useEffect(() => setInterval(…))`)
|
|
11
|
-
* that leaves an unreadable label. Metro maps the offset back to the real
|
|
12
|
-
* source file — so a row can say `setInterval ← ChatScreen.tsx:42`, which is
|
|
13
|
-
* component-level attribution in practice.
|
|
14
|
-
*
|
|
15
|
-
* Fire-and-forget with hard caps: one attempt per origin, few in flight,
|
|
16
|
-
* silent on any failure (release builds, tunnels, Metro gone). The origin's
|
|
17
|
-
* label/file/line are upgraded in place when the answer lands — the table
|
|
18
|
-
* re-renders every tick and picks it up.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
const MAX_IN_FLIGHT = 3;
|
|
22
|
-
let inFlight = 0;
|
|
23
|
-
function isDev() {
|
|
24
|
-
return typeof __DEV__ !== "undefined" && __DEV__;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** Last two path segments of a source path — "screens/ChatScreen.tsx". */
|
|
28
|
-
function tailPath(file) {
|
|
29
|
-
const clean = file.split("?")[0] ?? file;
|
|
30
|
-
const parts = clean.split("/").filter(Boolean);
|
|
31
|
-
return parts.slice(-2).join("/");
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** True for names like ChatScreen / PokemonScreen — reads as a component. */
|
|
35
|
-
function looksLikeComponent(name) {
|
|
36
|
-
return /^[A-Z][A-Za-z0-9]*$/.test(name);
|
|
37
|
-
}
|
|
38
|
-
function buoyJsTopSymbolicateOrigin(o, apiLabelText) {
|
|
39
|
-
if (!isDev()) return;
|
|
40
|
-
if (o.symbolicated || !o.frames || o.frames.length === 0) return;
|
|
41
|
-
if (inFlight >= MAX_IN_FLIGHT) return; // retried implicitly? no — one shot
|
|
42
|
-
o.symbolicated = true;
|
|
43
|
-
const top = o.frames[0];
|
|
44
|
-
if (!top || !/^https?:\/\//.test(top.file)) return;
|
|
45
|
-
let endpoint;
|
|
46
|
-
try {
|
|
47
|
-
endpoint = `${new URL(top.file).origin}/symbolicate`;
|
|
48
|
-
} catch {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
inFlight++;
|
|
52
|
-
const body = JSON.stringify({
|
|
53
|
-
stack: o.frames.map(f => ({
|
|
54
|
-
file: f.file,
|
|
55
|
-
lineNumber: f.line,
|
|
56
|
-
column: f.col,
|
|
57
|
-
methodName: ""
|
|
58
|
-
}))
|
|
59
|
-
});
|
|
60
|
-
fetch(endpoint, {
|
|
61
|
-
method: "POST",
|
|
62
|
-
body
|
|
63
|
-
}).then(res => res.ok ? res.json() : null).then(data => {
|
|
64
|
-
let frame = data?.stack?.find(f => f.file && !f.file.includes("node_modules")) ?? data?.stack?.[0];
|
|
65
|
-
// Some Metro configs (serialized source maps) reject full
|
|
66
|
-
// symbolication but still NAME the module in the error — that file
|
|
67
|
-
// path is exactly the scheduling site, so harvest it.
|
|
68
|
-
if (!frame?.file && data?.error) {
|
|
69
|
-
const m = /found: (\/.+)$/.exec(data.error);
|
|
70
|
-
if (m) frame = {
|
|
71
|
-
file: m[1]
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
if (!frame?.file) return;
|
|
75
|
-
const file = tailPath(frame.file);
|
|
76
|
-
const line = frame.lineNumber;
|
|
77
|
-
const method = frame.methodName && frame.methodName !== "<unknown>" ? frame.methodName : undefined;
|
|
78
|
-
o.file = file;
|
|
79
|
-
o.line = line ?? o.line;
|
|
80
|
-
// The existing label is name-anchored — append the source site
|
|
81
|
-
// once, and promote a component-looking method name.
|
|
82
|
-
const site = `${file.split("/").pop()}${line != null ? `:${line}` : ""}`;
|
|
83
|
-
if (method && looksLikeComponent(method) && !o.caller) {
|
|
84
|
-
o.caller = method;
|
|
85
|
-
o.label = `${o.label} ← <${method}> · ${site}`;
|
|
86
|
-
} else {
|
|
87
|
-
o.label = `${o.label} · ${site}`;
|
|
88
|
-
}
|
|
89
|
-
}).catch(() => {
|
|
90
|
-
// Symbolication is best-effort decoration — never surface failures.
|
|
91
|
-
}).finally(() => {
|
|
92
|
-
inFlight--;
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
//# sourceMappingURL=symbolicate.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.buoyJsTopSymbolicateOrigin=buoyJsTopSymbolicateOrigin;const MAX_IN_FLIGHT=3;let inFlight=0;function isDev(){return typeof __DEV__!=="undefined"&&__DEV__}function tailPath(e){const s=e.split("?")[0]??e;const i=s.split("/").filter(Boolean);return i.slice(-2).join("/")}function looksLikeComponent(e){return/^[A-Z][A-Za-z0-9]*$/.test(e)}function buoyJsTopSymbolicateOrigin(e,s){if(!isDev())return;if(e.symbolicated||!e.frames||e.frames.length===0)return;if(inFlight>=MAX_IN_FLIGHT)return;e.symbolicated=true;const i=e.frames[0];if(!i||!/^https?:\/\//.test(i.file))return;let c;try{c=`${new URL(i.file).origin}/symbolicate`}catch{return}inFlight++;const a=JSON.stringify({stack:e.frames.map(t=>({file:t.file,lineNumber:t.line,column:t.col,methodName:""}))});fetch(c,{method:"POST",body:a}).then(t=>t.ok?t.json():null).then(t=>{let n=t?.stack?.find(l=>l.file&&!l.file.includes("node_modules"))??t?.stack?.[0];if(!n?.file&&t?.error){const l=/found: (\/.+)$/.exec(t.error);if(l)n={file:l[1]}}if(!n?.file)return;const f=tailPath(n.file);const o=n.lineNumber;const r=n.methodName&&n.methodName!=="<unknown>"?n.methodName:void 0;e.file=f;e.line=o??e.line;const u=`${f.split("/").pop()}${o!=null?`:${o}`:""}`;if(r&&looksLikeComponent(r)&&!e.caller){e.caller=r;e.label=`${e.label} \u2190 <${r}> \xB7 ${u}`}else{e.label=`${e.label} \xB7 ${u}`}}).catch(()=>{}).finally(()=>{inFlight--})}
|
|
@@ -1,74 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.jsTopSyncAdapter = void 0;
|
|
7
|
-
var _JsTopController = require("../engine/JsTopController");
|
|
8
|
-
/**
|
|
9
|
-
* Sync adapter for the JS TOP tool, consumed by @buoy-gg/external-sync's
|
|
10
|
-
* `useExternalSync` (structurally matches its ToolSyncAdapter interface so
|
|
11
|
-
* this package doesn't need a dependency on it — same pattern as
|
|
12
|
-
* perf-monitor's adapter).
|
|
13
|
-
*
|
|
14
|
-
* `subscribe` is only called while a dashboard is watching, and subscribing
|
|
15
|
-
* to JsTopController is exactly what starts the engine — so a desktop
|
|
16
|
-
* watcher auto-starts sampling and closing the desktop tool stops it. The
|
|
17
|
-
* snapshot IS the live channel; there is no heavy persisted state.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const jsTopSyncAdapter = exports.jsTopSyncAdapter = {
|
|
21
|
-
version: 1,
|
|
22
|
-
getSnapshot: () => ({
|
|
23
|
-
live: _JsTopController.JsTopController.getSnapshot(),
|
|
24
|
-
// "enabled" mirrors perf-monitor semantics: is the device sampling for
|
|
25
|
-
// any viewer (its own HUD/modal or a desktop's silent remote sampling).
|
|
26
|
-
enabled: _JsTopController.JsTopController.isEnabled() || _JsTopController.JsTopController.isRemoteSampling()
|
|
27
|
-
}),
|
|
28
|
-
subscribe: onChange => {
|
|
29
|
-
const unsubSnapshot = _JsTopController.JsTopController.subscribe(() => onChange());
|
|
30
|
-
const unsubEnabled = _JsTopController.JsTopController.subscribeEnabled(() => onChange());
|
|
31
|
-
return () => {
|
|
32
|
-
unsubSnapshot();
|
|
33
|
-
unsubEnabled();
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
actions: {
|
|
37
|
-
/**
|
|
38
|
-
* Silent sampling for a desktop viewer: streams snapshots without
|
|
39
|
-
* showing the device's own HUD. (Subscribing via `subscribe` already
|
|
40
|
-
* runs the engine while watched; this exists so MCP / scripted callers
|
|
41
|
-
* can force sampling on without a watch.)
|
|
42
|
-
*/
|
|
43
|
-
setEnabled: params => {
|
|
44
|
-
const enabled = params.enabled;
|
|
45
|
-
_JsTopController.JsTopController.setRemoteSampling(enabled);
|
|
46
|
-
},
|
|
47
|
-
pause: () => _JsTopController.JsTopController.pause(),
|
|
48
|
-
resume: () => _JsTopController.JsTopController.resume(),
|
|
49
|
-
clear: () => _JsTopController.JsTopController.clear(),
|
|
50
|
-
/** Full detail for one origin (desktop tap-through parity). */
|
|
51
|
-
getOriginDetail: params => _JsTopController.JsTopController.getOriginDetail(params.key),
|
|
52
|
-
/**
|
|
53
|
-
* One-shot sample for MCP/automation: ensure the engine is running,
|
|
54
|
-
* observe for `durationMs` (default 3s, capped 30s), return the
|
|
55
|
-
* resulting snapshot. `clearFirst` resets all stats before sampling so
|
|
56
|
-
* the result attributes exactly one interaction/window. Leaves sampling
|
|
57
|
-
* in its prior state.
|
|
58
|
-
*/
|
|
59
|
-
sample: async params => {
|
|
60
|
-
const p = params;
|
|
61
|
-
const durationMs = Math.min(Math.max(p?.durationMs ?? 3000, 250), 30_000);
|
|
62
|
-
const wasSampling = _JsTopController.JsTopController.isRemoteSampling() || _JsTopController.JsTopController.isEnabled();
|
|
63
|
-
if (!wasSampling) _JsTopController.JsTopController.setRemoteSampling(true);
|
|
64
|
-
if (p?.clearFirst) _JsTopController.JsTopController.clear();
|
|
65
|
-
try {
|
|
66
|
-
await new Promise(resolve => setTimeout(resolve, durationMs));
|
|
67
|
-
return _JsTopController.JsTopController.getSnapshot();
|
|
68
|
-
} finally {
|
|
69
|
-
if (!wasSampling) _JsTopController.JsTopController.setRemoteSampling(false);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
//# sourceMappingURL=jsTopSyncAdapter.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.jsTopSyncAdapter=void 0;var _JsTopController=require("../engine/JsTopController");const jsTopSyncAdapter=exports.jsTopSyncAdapter={version:1,getSnapshot:()=>({live:_JsTopController.JsTopController.getSnapshot(),enabled:_JsTopController.JsTopController.isEnabled()||_JsTopController.JsTopController.isRemoteSampling()}),subscribe:e=>{const o=_JsTopController.JsTopController.subscribe(()=>e());const r=_JsTopController.JsTopController.subscribeEnabled(()=>e());return()=>{o();r()}},actions:{setEnabled:e=>{const o=e.enabled;_JsTopController.JsTopController.setRemoteSampling(o)},pause:()=>_JsTopController.JsTopController.pause(),resume:()=>_JsTopController.JsTopController.resume(),clear:()=>_JsTopController.JsTopController.clear(),getOriginDetail:e=>_JsTopController.JsTopController.getOriginDetail(e.key),sample:async e=>{const o=e;const r=Math.min(Math.max(o?.durationMs??3e3,250),3e4);const s=_JsTopController.JsTopController.isRemoteSampling()||_JsTopController.JsTopController.isEnabled();if(!s)_JsTopController.JsTopController.setRemoteSampling(true);if(o?.clearFirst)_JsTopController.JsTopController.clear();try{await new Promise(t=>setTimeout(t,r));return _JsTopController.JsTopController.getSnapshot()}finally{if(!s)_JsTopController.JsTopController.setRemoteSampling(false)}}}};
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.WINDOW_BUCKETS = exports.SNAPSHOT_ROWS = exports.PROMOTE_MIN_TOTAL_MS = exports.PROMOTE_MIN_CALLS = exports.MAX_ORIGINS = exports.HISTORY_BUCKETS = exports.BUCKET_MS = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* JS TOP — live Task Manager for the React Native JS thread.
|
|
9
|
-
*
|
|
10
|
-
* Attribution model: the engine wraps every JS-thread entry point it can
|
|
11
|
-
* reach (timers, rAF, microtasks, Promise reactions, legacy-bridge call-ins)
|
|
12
|
-
* and books EXCLUSIVE time per "origin" (the place a callback was scheduled
|
|
13
|
-
* from). A high-frequency probe measures true thread occupancy; the gap
|
|
14
|
-
* between measured busy time and attributed time is surfaced honestly as an
|
|
15
|
-
* "unattributed" row rather than hidden.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/** Which entry-point API a task came through. */
|
|
19
|
-
|
|
20
|
-
/** One captured stack frame from an origin's scheduling site (dev-readable). */
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Which coverage tiers are live on this device. UIs gray out / banner what a
|
|
24
|
-
* runtime can't see (e.g. bridge call-ins don't exist on bridgeless).
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/** One row of the live table — a task origin ("process" in Task Manager terms). */
|
|
28
|
-
|
|
29
|
-
/** A 50ms+ blocking task reported by the runtime, with our best attribution. */
|
|
30
|
-
|
|
31
|
-
/** The JSON-serializable live snapshot (device UI + external-sync payload). */
|
|
32
|
-
|
|
33
|
-
/** Everything the engine knows about one origin — the tap-through detail. */
|
|
34
|
-
|
|
35
|
-
/** Engine tuning constants — exported for tests. */
|
|
36
|
-
const BUCKET_MS = exports.BUCKET_MS = 250;
|
|
37
|
-
/** Rolling "recent" window: 20 buckets = 5s. */
|
|
38
|
-
const WINDOW_BUCKETS = exports.WINDOW_BUCKETS = 20;
|
|
39
|
-
/** Global busy history ring: 120 buckets = 30s. */
|
|
40
|
-
const HISTORY_BUCKETS = exports.HISTORY_BUCKETS = 120;
|
|
41
|
-
const MAX_ORIGINS = exports.MAX_ORIGINS = 500;
|
|
42
|
-
/** Promotion thresholds: capture a scheduling stack once an origin is hot. */
|
|
43
|
-
const PROMOTE_MIN_CALLS = exports.PROMOTE_MIN_CALLS = 25;
|
|
44
|
-
const PROMOTE_MIN_TOTAL_MS = exports.PROMOTE_MIN_TOTAL_MS = 50;
|
|
45
|
-
const SNAPSHOT_ROWS = exports.SNAPSHOT_ROWS = 30;
|
|
46
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.WINDOW_BUCKETS=exports.SNAPSHOT_ROWS=exports.PROMOTE_MIN_TOTAL_MS=exports.PROMOTE_MIN_CALLS=exports.MAX_ORIGINS=exports.HISTORY_BUCKETS=exports.BUCKET_MS=void 0;const BUCKET_MS=exports.BUCKET_MS=250;const WINDOW_BUCKETS=exports.WINDOW_BUCKETS=20;const HISTORY_BUCKETS=exports.HISTORY_BUCKETS=120;const MAX_ORIGINS=exports.MAX_ORIGINS=500;const PROMOTE_MIN_CALLS=exports.PROMOTE_MIN_CALLS=25;const PROMOTE_MIN_TOTAL_MS=exports.PROMOTE_MIN_TOTAL_MS=50;const SNAPSHOT_ROWS=exports.SNAPSHOT_ROWS=30;
|
|
@@ -1,31 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.loadJsTopPrefs = loadJsTopPrefs;
|
|
7
|
-
exports.saveJsTopPrefs = saveJsTopPrefs;
|
|
8
|
-
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
9
|
-
/**
|
|
10
|
-
* Persisted JS TOP preferences. Same load-then-save contract as
|
|
11
|
-
* perf-monitor's hudPreferences: rehydrate async, and only persist
|
|
12
|
-
* user-driven changes after the load resolves so defaults never clobber
|
|
13
|
-
* last session's state.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
const KEY = "@react_buoy/js-top/prefs";
|
|
17
|
-
const DEFAULTS = {
|
|
18
|
-
enabled: false
|
|
19
|
-
};
|
|
20
|
-
const prefs = (0, _sharedUi.definePersistedSetting)(KEY, DEFAULTS, {
|
|
21
|
-
sanitize: merged => ({
|
|
22
|
-
enabled: merged.enabled === true
|
|
23
|
-
})
|
|
24
|
-
});
|
|
25
|
-
async function loadJsTopPrefs() {
|
|
26
|
-
return prefs.load();
|
|
27
|
-
}
|
|
28
|
-
async function saveJsTopPrefs(next) {
|
|
29
|
-
await prefs.save(next);
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=preferences.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.loadJsTopPrefs=loadJsTopPrefs;exports.saveJsTopPrefs=saveJsTopPrefs;var _sharedUi=require("@buoy-gg/shared-ui");const KEY="@react_buoy/js-top/prefs";const DEFAULTS={enabled:false};const prefs=(0,_sharedUi.definePersistedSetting)(KEY,DEFAULTS,{sanitize:e=>({enabled:e.enabled===true})});async function loadJsTopPrefs(){return prefs.load()}async function saveJsTopPrefs(e){await prefs.save(e)}
|
package/lib/commonjs/preset.js
CHANGED
|
@@ -1,75 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.jsTopPreset = exports.jsTopModalPreset = exports.JS_TOP_ENABLED_COLOR = exports.JS_TOP_DISABLED_COLOR = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
9
|
-
var _JsTopController = require("./js-top/engine/JsTopController");
|
|
10
|
-
var _JsTopModal = require("./js-top/components/JsTopModal");
|
|
11
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
/**
|
|
13
|
-
* Pre-configured JS TOP tools for FloatingDevTools.
|
|
14
|
-
*
|
|
15
|
-
* Two presets:
|
|
16
|
-
* - jsTopPreset: toggle-only chip that turns the floating busy% pill on/off.
|
|
17
|
-
* - jsTopModalPreset: opens the Task Manager window (ranked live table).
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```tsx
|
|
21
|
-
* import { jsTopPreset, jsTopModalPreset } from '@buoy-gg/js-top';
|
|
22
|
-
*
|
|
23
|
-
* <FloatingDevTools apps={[jsTopPreset, jsTopModalPreset]} />
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
const JS_TOP_ENABLED_COLOR = exports.JS_TOP_ENABLED_COLOR = "#34D399";
|
|
28
|
-
const JS_TOP_DISABLED_COLOR = exports.JS_TOP_DISABLED_COLOR = "#6B7280";
|
|
29
|
-
function JsTopToggleIcon({
|
|
30
|
-
size
|
|
31
|
-
}) {
|
|
32
|
-
const [enabled, setEnabled] = (0, _react.useState)(() => _JsTopController.JsTopController.isEnabled());
|
|
33
|
-
(0, _react.useEffect)(() => _JsTopController.JsTopController.subscribeEnabled(setEnabled), []);
|
|
34
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.Activity, {
|
|
35
|
-
size: size,
|
|
36
|
-
color: enabled ? JS_TOP_ENABLED_COLOR : JS_TOP_DISABLED_COLOR
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
function EmptyComponent() {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** Toggle-only preset: show/hide the floating busy% pill. */
|
|
44
|
-
const jsTopPreset = exports.jsTopPreset = {
|
|
45
|
-
id: "js-top",
|
|
46
|
-
name: "JS TOP",
|
|
47
|
-
description: "Toggle the floating JS-thread busy pill",
|
|
48
|
-
slot: "row",
|
|
49
|
-
icon: JsTopToggleIcon,
|
|
50
|
-
component: EmptyComponent,
|
|
51
|
-
props: {},
|
|
52
|
-
launchMode: "toggle-only",
|
|
53
|
-
onPress: () => {
|
|
54
|
-
_JsTopController.JsTopController.setEnabled(!_JsTopController.JsTopController.isEnabled());
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
/** Modal preset: the live Task Manager window. */
|
|
59
|
-
const jsTopModalPreset = exports.jsTopModalPreset = {
|
|
60
|
-
id: "js-top-modal",
|
|
61
|
-
name: "TASKS",
|
|
62
|
-
description: "Live Task Manager for the JS thread",
|
|
63
|
-
slot: "both",
|
|
64
|
-
icon: ({
|
|
65
|
-
size
|
|
66
|
-
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.Activity, {
|
|
67
|
-
size: size,
|
|
68
|
-
color: JS_TOP_ENABLED_COLOR
|
|
69
|
-
}),
|
|
70
|
-
component: _JsTopModal.JsTopModal,
|
|
71
|
-
props: {
|
|
72
|
-
enableSharedModalDimensions: false
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
//# sourceMappingURL=preset.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.jsTopPreset=exports.jsTopModalPreset=exports.JS_TOP_ENABLED_COLOR=exports.JS_TOP_DISABLED_COLOR=void 0;var _react=require("react");var _sharedUi=require("@buoy-gg/shared-ui");var _JsTopController=require("./js-top/engine/JsTopController");var _JsTopModal=require("./js-top/components/JsTopModal");var _jsxRuntime=require("react/jsx-runtime");const JS_TOP_ENABLED_COLOR=exports.JS_TOP_ENABLED_COLOR="#34D399";const JS_TOP_DISABLED_COLOR=exports.JS_TOP_DISABLED_COLOR="#6B7280";function JsTopToggleIcon({size:e}){const[o,s]=(0,_react.useState)(()=>_JsTopController.JsTopController.isEnabled());(0,_react.useEffect)(()=>_JsTopController.JsTopController.subscribeEnabled(s),[]);return(0,_jsxRuntime.jsx)(_sharedUi.Activity,{size:e,color:o?JS_TOP_ENABLED_COLOR:JS_TOP_DISABLED_COLOR})}function EmptyComponent(){return null}const jsTopPreset=exports.jsTopPreset={id:"js-top",name:"JS TOP",description:"Toggle the floating JS-thread busy pill",slot:"row",icon:JsTopToggleIcon,component:EmptyComponent,props:{},launchMode:"toggle-only",onPress:()=>{_JsTopController.JsTopController.setEnabled(!_JsTopController.JsTopController.isEnabled())}};const jsTopModalPreset=exports.jsTopModalPreset={id:"js-top-modal",name:"TASKS",description:"Live Task Manager for the JS thread",slot:"both",icon:({size:e})=>(0,_jsxRuntime.jsx)(_sharedUi.Activity,{size:e,color:JS_TOP_ENABLED_COLOR}),component:_JsTopModal.JsTopModal,props:{enableSharedModalDimensions:false}};
|
package/lib/module/index.js
CHANGED
|
@@ -1,49 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @buoy-gg/js-top — live Task Manager for the React Native JS thread.
|
|
5
|
-
*
|
|
6
|
-
* Pure JS (Expo Go + release compatible): wraps timers / rAF / microtasks /
|
|
7
|
-
* Promise reactions / legacy-bridge call-ins and books exclusive time per
|
|
8
|
-
* scheduling origin; a calibrated busy probe measures true thread occupancy
|
|
9
|
-
* so unattributable work is surfaced honestly instead of hidden.
|
|
10
|
-
*
|
|
11
|
-
* Coverage tiers beyond the core (promises, bridge, longtask correlation)
|
|
12
|
-
* are registered here at module scope — the controller installs them lazily
|
|
13
|
-
* on first engine start, so importing this package costs nothing until a
|
|
14
|
-
* viewer opens the tool.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { JsTopController } from "./js-top/engine/JsTopController";
|
|
18
|
-
import { installPromisePatches } from "./js-top/engine/patches/promises";
|
|
19
|
-
import { installBridgePatch } from "./js-top/engine/patches/bridge";
|
|
20
|
-
import { installTimerPatches } from "./js-top/engine/patches/timers";
|
|
21
|
-
import { installMicrotaskPatches } from "./js-top/engine/patches/microtasks";
|
|
22
|
-
import { clearLongtasks, getFreezeStats, getLongtasks, installLongtaskObserver } from "./js-top/engine/longtasks";
|
|
23
|
-
JsTopController.registerTierInstaller(installPromisePatches);
|
|
24
|
-
JsTopController.registerTierInstaller(installBridgePatch);
|
|
25
|
-
JsTopController.registerTierInstaller(installLongtaskObserver);
|
|
26
|
-
JsTopController.registerLongtaskProvider(getLongtasks);
|
|
27
|
-
JsTopController.registerFreezeStatsProvider(getFreezeStats);
|
|
28
|
-
JsTopController.registerClearHook(clearLongtasks);
|
|
29
|
-
|
|
30
|
-
// Timer/microtask patches install at import so callbacks scheduled at APP
|
|
31
|
-
// BOOT — the classic forgotten setInterval, the tool's #1 target — are
|
|
32
|
-
// wrapped and attributable the moment any viewer opens the tool. Wrappers
|
|
33
|
-
// resolve their origin lazily and cost one boolean per fire while the
|
|
34
|
-
// engine is off. (Promise/bridge patches are more invasive and stay lazy —
|
|
35
|
-
// they install on first engine start and cover work scheduled after it.)
|
|
36
|
-
try {
|
|
37
|
-
if (typeof window !== "undefined") {
|
|
38
|
-
installTimerPatches();
|
|
39
|
-
installMicrotaskPatches();
|
|
40
|
-
}
|
|
41
|
-
} catch {
|
|
42
|
-
// Never let instrumentation break an app at import time.
|
|
43
|
-
}
|
|
44
|
-
export { JsTopController } from "./js-top/engine/JsTopController";
|
|
45
|
-
export { jsTopSyncAdapter } from "./js-top/sync/jsTopSyncAdapter";
|
|
46
|
-
export { JsTopModal } from "./js-top/components/JsTopModal";
|
|
47
|
-
export { JsTopHudOverlay } from "./js-top/components/JsTopHudOverlay";
|
|
48
|
-
export { jsTopPreset, jsTopModalPreset, JS_TOP_ENABLED_COLOR, JS_TOP_DISABLED_COLOR } from "./preset";
|
|
49
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";import{JsTopController as r}from"./js-top/engine/JsTopController";import{installPromisePatches as e}from"./js-top/engine/patches/promises";import{installBridgePatch as t}from"./js-top/engine/patches/bridge";import{installTimerPatches as o}from"./js-top/engine/patches/timers";import{installMicrotaskPatches as s}from"./js-top/engine/patches/microtasks";import{clearLongtasks as i,getFreezeStats as a,getLongtasks as l,installLongtaskObserver as p}from"./js-top/engine/longtasks";r.registerTierInstaller(e);r.registerTierInstaller(t);r.registerTierInstaller(p);r.registerLongtaskProvider(l);r.registerFreezeStatsProvider(a);r.registerClearHook(i);try{if(typeof window!=="undefined"){o();s()}}catch{}export{JsTopController}from"./js-top/engine/JsTopController";export{jsTopSyncAdapter}from"./js-top/sync/jsTopSyncAdapter";export{JsTopModal}from"./js-top/components/JsTopModal";export{JsTopHudOverlay}from"./js-top/components/JsTopHudOverlay";export{jsTopPreset,jsTopModalPreset,JS_TOP_ENABLED_COLOR,JS_TOP_DISABLED_COLOR}from"./preset";
|
|
@@ -1,52 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Busy% history sparkline — plain View bars (no SVG dependency), tinted by
|
|
5
|
-
* severity. Renders at most the trailing 60 buckets (15s).
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { memo } from "react";
|
|
9
|
-
import { StyleSheet, View } from "react-native";
|
|
10
|
-
import { macOSColors } from "@buoy-gg/shared-ui";
|
|
11
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
-
const MAX_POINTS = 60;
|
|
13
|
-
function barColor(pct) {
|
|
14
|
-
if (pct >= 80) return macOSColors.semantic.error;
|
|
15
|
-
if (pct >= 40) return macOSColors.semantic.warning;
|
|
16
|
-
return macOSColors.semantic.success;
|
|
17
|
-
}
|
|
18
|
-
export const BusySparkline = /*#__PURE__*/memo(function BusySparkline({
|
|
19
|
-
history
|
|
20
|
-
}) {
|
|
21
|
-
const points = history.slice(-MAX_POINTS);
|
|
22
|
-
return /*#__PURE__*/_jsx(View, {
|
|
23
|
-
style: styles.row,
|
|
24
|
-
pointerEvents: "none",
|
|
25
|
-
children: points.map((pct, i) => /*#__PURE__*/_jsx(View
|
|
26
|
-
// Bars are positional by nature (a scrolling time axis); the array
|
|
27
|
-
// is fixed-length and rewritten wholesale each tick, so positional
|
|
28
|
-
// keys are correct here — this is not a prepend-list.
|
|
29
|
-
, {
|
|
30
|
-
style: [styles.bar, {
|
|
31
|
-
height: Math.max(2, pct / 100 * 28),
|
|
32
|
-
backgroundColor: barColor(pct)
|
|
33
|
-
}]
|
|
34
|
-
}, `b${i}`))
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
const styles = StyleSheet.create({
|
|
38
|
-
row: {
|
|
39
|
-
flexDirection: "row",
|
|
40
|
-
alignItems: "flex-end",
|
|
41
|
-
gap: 1,
|
|
42
|
-
height: 28,
|
|
43
|
-
alignSelf: "stretch"
|
|
44
|
-
},
|
|
45
|
-
bar: {
|
|
46
|
-
flex: 1,
|
|
47
|
-
maxWidth: 6,
|
|
48
|
-
borderRadius: 1,
|
|
49
|
-
opacity: 0.9
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
//# sourceMappingURL=BusySparkline.js.map
|
|
1
|
+
"use strict";import{memo as m}from"react";import{StyleSheet as l,View as o}from"react-native";import{macOSColors as e}from"@buoy-gg/shared-ui";import{jsx as n}from"react/jsx-runtime";const f=60;function u(r){if(r>=80)return e.semantic.error;if(r>=40)return e.semantic.warning;return e.semantic.success}export const BusySparkline=m(function r({history:s}){const a=s.slice(-f);return n(o,{style:i.row,pointerEvents:"none",children:a.map((t,c)=>n(o,{style:[i.bar,{height:Math.max(2,t/100*28),backgroundColor:u(t)}]},`b${c}`))})});const i=l.create({row:{flexDirection:"row",alignItems:"flex-end",gap:1,height:28,alignSelf:"stretch"},bar:{flex:1,maxWidth:6,borderRadius:1,opacity:.9}});
|
|
@@ -1,75 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Minimal floating HUD pill: busy% + the current top offender. Rendered by
|
|
5
|
-
* FloatingDevTools (guarded require) when the JS TOP toggle chip is on —
|
|
6
|
-
* same auto-mount pattern as the perf-monitor overlay. Display-only in v1
|
|
7
|
-
* (no drag; sits under the status bar on the left).
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { useEffect, useState } from "react";
|
|
11
|
-
import { StyleSheet, Text, View } from "react-native";
|
|
12
|
-
import { macOSColors, night } from "@buoy-gg/shared-ui";
|
|
13
|
-
import { JsTopController } from "../engine/JsTopController";
|
|
14
|
-
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
-
function busyColor(pct) {
|
|
16
|
-
if (pct >= 80) return macOSColors.semantic.error;
|
|
17
|
-
if (pct >= 40) return macOSColors.semantic.warning;
|
|
18
|
-
return macOSColors.semantic.success;
|
|
19
|
-
}
|
|
20
|
-
export function JsTopHudOverlay() {
|
|
21
|
-
const [enabled, setEnabled] = useState(() => JsTopController.isEnabled());
|
|
22
|
-
const [snapshot, setSnapshot] = useState(null);
|
|
23
|
-
useEffect(() => JsTopController.subscribeEnabled(setEnabled), []);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (!enabled) {
|
|
26
|
-
setSnapshot(null);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
return JsTopController.subscribe(setSnapshot);
|
|
30
|
-
}, [enabled]);
|
|
31
|
-
if (!enabled || !snapshot) return null;
|
|
32
|
-
const top = snapshot.rows.find(r => r.api !== "unattributed");
|
|
33
|
-
return /*#__PURE__*/_jsxs(View, {
|
|
34
|
-
style: styles.pill,
|
|
35
|
-
pointerEvents: "none",
|
|
36
|
-
children: [/*#__PURE__*/_jsxs(Text, {
|
|
37
|
-
style: [styles.busy, {
|
|
38
|
-
color: busyColor(snapshot.busyPct)
|
|
39
|
-
}],
|
|
40
|
-
children: [snapshot.busyPct.toFixed(0), "%"]
|
|
41
|
-
}), top && /*#__PURE__*/_jsx(Text, {
|
|
42
|
-
style: styles.label,
|
|
43
|
-
numberOfLines: 1,
|
|
44
|
-
children: top.label
|
|
45
|
-
})]
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
const styles = StyleSheet.create({
|
|
49
|
-
pill: {
|
|
50
|
-
position: "absolute",
|
|
51
|
-
top: 60,
|
|
52
|
-
left: 8,
|
|
53
|
-
flexDirection: "row",
|
|
54
|
-
alignItems: "center",
|
|
55
|
-
gap: 6,
|
|
56
|
-
backgroundColor: night.color.buttonSurface,
|
|
57
|
-
borderWidth: 1,
|
|
58
|
-
borderColor: night.color.border,
|
|
59
|
-
borderRadius: 6,
|
|
60
|
-
paddingHorizontal: 8,
|
|
61
|
-
paddingVertical: 4,
|
|
62
|
-
maxWidth: 220
|
|
63
|
-
},
|
|
64
|
-
busy: {
|
|
65
|
-
fontSize: 11,
|
|
66
|
-
fontWeight: "700",
|
|
67
|
-
fontVariant: ["tabular-nums"]
|
|
68
|
-
},
|
|
69
|
-
label: {
|
|
70
|
-
color: night.color.textSecondary,
|
|
71
|
-
fontSize: 10,
|
|
72
|
-
flexShrink: 1
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
//# sourceMappingURL=JsTopHudOverlay.js.map
|
|
1
|
+
"use strict";import{useEffect as a,useState as u}from"react";import{StyleSheet as p,Text as c,View as m}from"react-native";import{macOSColors as t,night as o}from"@buoy-gg/shared-ui";import{JsTopController as n}from"../engine/JsTopController";import{jsxs as b,jsx as y}from"react/jsx-runtime";function h(e){if(e>=80)return t.semantic.error;if(e>=40)return t.semantic.warning;return t.semantic.success}export function JsTopHudOverlay(){const[e,d]=u(()=>n.isEnabled());const[r,i]=u(null);a(()=>n.subscribeEnabled(d),[]);a(()=>{if(!e){i(null);return}return n.subscribe(i)},[e]);if(!e||!r)return null;const l=r.rows.find(f=>f.api!=="unattributed");return b(m,{style:s.pill,pointerEvents:"none",children:[b(c,{style:[s.busy,{color:h(r.busyPct)}],children:[r.busyPct.toFixed(0),"%"]}),l&&y(c,{style:s.label,numberOfLines:1,children:l.label})]})}const s=p.create({pill:{position:"absolute",top:60,left:8,flexDirection:"row",alignItems:"center",gap:6,backgroundColor:o.color.buttonSurface,borderWidth:1,borderColor:o.color.border,borderRadius:6,paddingHorizontal:8,paddingVertical:4,maxWidth:220},busy:{fontSize:11,fontWeight:"700",fontVariant:["tabular-nums"]},label:{color:o.color.textSecondary,fontSize:10,flexShrink:1}});
|