@buoy-gg/js-top 7.0.40 → 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.
Files changed (118) hide show
  1. package/README.md +12 -67
  2. package/lib/commonjs/index.js +1 -97
  3. package/lib/commonjs/js-top/components/BusySparkline.js +1 -56
  4. package/lib/commonjs/js-top/components/JsTopHudOverlay.js +1 -79
  5. package/lib/commonjs/js-top/components/JsTopModal.js +1 -349
  6. package/lib/commonjs/js-top/components/TaskDetailView.js +1 -330
  7. package/lib/commonjs/js-top/components/TaskTable.js +1 -360
  8. package/lib/commonjs/js-top/engine/JsTopController.js +1 -350
  9. package/lib/commonjs/js-top/engine/aggregator.js +1 -148
  10. package/lib/commonjs/js-top/engine/busyProbe.js +1 -101
  11. package/lib/commonjs/js-top/engine/frameStack.js +1 -133
  12. package/lib/commonjs/js-top/engine/longtasks.js +1 -141
  13. package/lib/commonjs/js-top/engine/now.js +1 -38
  14. package/lib/commonjs/js-top/engine/originRegistry.js +1 -402
  15. package/lib/commonjs/js-top/engine/patches/bridge.js +1 -60
  16. package/lib/commonjs/js-top/engine/patches/microtasks.js +1 -27
  17. package/lib/commonjs/js-top/engine/patches/promises.js +1 -65
  18. package/lib/commonjs/js-top/engine/patches/timers.js +1 -66
  19. package/lib/commonjs/js-top/engine/state.js +1 -63
  20. package/lib/commonjs/js-top/engine/symbolicate.js +1 -95
  21. package/lib/commonjs/js-top/sync/jsTopSyncAdapter.js +1 -74
  22. package/lib/commonjs/js-top/types/index.js +1 -46
  23. package/lib/commonjs/js-top/utils/preferences.js +1 -31
  24. package/lib/commonjs/preset.js +1 -75
  25. package/lib/module/index.js +1 -47
  26. package/lib/module/js-top/components/BusySparkline.js +1 -52
  27. package/lib/module/js-top/components/JsTopHudOverlay.js +1 -75
  28. package/lib/module/js-top/components/JsTopModal.js +1 -345
  29. package/lib/module/js-top/components/TaskDetailView.js +1 -326
  30. package/lib/module/js-top/components/TaskTable.js +1 -353
  31. package/lib/module/js-top/engine/JsTopController.js +1 -347
  32. package/lib/module/js-top/engine/aggregator.js +1 -136
  33. package/lib/module/js-top/engine/busyProbe.js +1 -94
  34. package/lib/module/js-top/engine/frameStack.js +1 -126
  35. package/lib/module/js-top/engine/longtasks.js +1 -133
  36. package/lib/module/js-top/engine/now.js +1 -33
  37. package/lib/module/js-top/engine/originRegistry.js +1 -388
  38. package/lib/module/js-top/engine/patches/bridge.js +1 -56
  39. package/lib/module/js-top/engine/patches/microtasks.js +1 -23
  40. package/lib/module/js-top/engine/patches/promises.js +1 -62
  41. package/lib/module/js-top/engine/patches/timers.js +1 -62
  42. package/lib/module/js-top/engine/state.js +1 -54
  43. package/lib/module/js-top/engine/symbolicate.js +1 -91
  44. package/lib/module/js-top/sync/jsTopSyncAdapter.js +1 -70
  45. package/lib/module/js-top/types/index.js +1 -42
  46. package/lib/module/js-top/utils/preferences.js +1 -26
  47. package/lib/module/preset.js +1 -71
  48. package/lib/web/index.mjs +2 -0
  49. package/package.json +39 -5
  50. package/lib/commonjs/index.js.map +0 -1
  51. package/lib/commonjs/js-top/components/BusySparkline.js.map +0 -1
  52. package/lib/commonjs/js-top/components/JsTopHudOverlay.js.map +0 -1
  53. package/lib/commonjs/js-top/components/JsTopModal.js.map +0 -1
  54. package/lib/commonjs/js-top/components/TaskDetailView.js.map +0 -1
  55. package/lib/commonjs/js-top/components/TaskTable.js.map +0 -1
  56. package/lib/commonjs/js-top/engine/JsTopController.js.map +0 -1
  57. package/lib/commonjs/js-top/engine/aggregator.js.map +0 -1
  58. package/lib/commonjs/js-top/engine/busyProbe.js.map +0 -1
  59. package/lib/commonjs/js-top/engine/frameStack.js.map +0 -1
  60. package/lib/commonjs/js-top/engine/longtasks.js.map +0 -1
  61. package/lib/commonjs/js-top/engine/now.js.map +0 -1
  62. package/lib/commonjs/js-top/engine/originRegistry.js.map +0 -1
  63. package/lib/commonjs/js-top/engine/patches/bridge.js.map +0 -1
  64. package/lib/commonjs/js-top/engine/patches/microtasks.js.map +0 -1
  65. package/lib/commonjs/js-top/engine/patches/promises.js.map +0 -1
  66. package/lib/commonjs/js-top/engine/patches/timers.js.map +0 -1
  67. package/lib/commonjs/js-top/engine/state.js.map +0 -1
  68. package/lib/commonjs/js-top/engine/symbolicate.js.map +0 -1
  69. package/lib/commonjs/js-top/sync/jsTopSyncAdapter.js.map +0 -1
  70. package/lib/commonjs/js-top/types/index.js.map +0 -1
  71. package/lib/commonjs/js-top/utils/preferences.js.map +0 -1
  72. package/lib/commonjs/preset.js.map +0 -1
  73. package/lib/module/index.js.map +0 -1
  74. package/lib/module/js-top/components/BusySparkline.js.map +0 -1
  75. package/lib/module/js-top/components/JsTopHudOverlay.js.map +0 -1
  76. package/lib/module/js-top/components/JsTopModal.js.map +0 -1
  77. package/lib/module/js-top/components/TaskDetailView.js.map +0 -1
  78. package/lib/module/js-top/components/TaskTable.js.map +0 -1
  79. package/lib/module/js-top/engine/JsTopController.js.map +0 -1
  80. package/lib/module/js-top/engine/aggregator.js.map +0 -1
  81. package/lib/module/js-top/engine/busyProbe.js.map +0 -1
  82. package/lib/module/js-top/engine/frameStack.js.map +0 -1
  83. package/lib/module/js-top/engine/longtasks.js.map +0 -1
  84. package/lib/module/js-top/engine/now.js.map +0 -1
  85. package/lib/module/js-top/engine/originRegistry.js.map +0 -1
  86. package/lib/module/js-top/engine/patches/bridge.js.map +0 -1
  87. package/lib/module/js-top/engine/patches/microtasks.js.map +0 -1
  88. package/lib/module/js-top/engine/patches/promises.js.map +0 -1
  89. package/lib/module/js-top/engine/patches/timers.js.map +0 -1
  90. package/lib/module/js-top/engine/state.js.map +0 -1
  91. package/lib/module/js-top/engine/symbolicate.js.map +0 -1
  92. package/lib/module/js-top/sync/jsTopSyncAdapter.js.map +0 -1
  93. package/lib/module/js-top/types/index.js.map +0 -1
  94. package/lib/module/js-top/utils/preferences.js.map +0 -1
  95. package/lib/module/preset.js.map +0 -1
  96. package/lib/typescript/index.d.ts.map +0 -1
  97. package/lib/typescript/js-top/components/BusySparkline.d.ts.map +0 -1
  98. package/lib/typescript/js-top/components/JsTopHudOverlay.d.ts.map +0 -1
  99. package/lib/typescript/js-top/components/JsTopModal.d.ts.map +0 -1
  100. package/lib/typescript/js-top/components/TaskDetailView.d.ts.map +0 -1
  101. package/lib/typescript/js-top/components/TaskTable.d.ts.map +0 -1
  102. package/lib/typescript/js-top/engine/JsTopController.d.ts.map +0 -1
  103. package/lib/typescript/js-top/engine/aggregator.d.ts.map +0 -1
  104. package/lib/typescript/js-top/engine/busyProbe.d.ts.map +0 -1
  105. package/lib/typescript/js-top/engine/frameStack.d.ts.map +0 -1
  106. package/lib/typescript/js-top/engine/longtasks.d.ts.map +0 -1
  107. package/lib/typescript/js-top/engine/now.d.ts.map +0 -1
  108. package/lib/typescript/js-top/engine/originRegistry.d.ts.map +0 -1
  109. package/lib/typescript/js-top/engine/patches/bridge.d.ts.map +0 -1
  110. package/lib/typescript/js-top/engine/patches/microtasks.d.ts.map +0 -1
  111. package/lib/typescript/js-top/engine/patches/promises.d.ts.map +0 -1
  112. package/lib/typescript/js-top/engine/patches/timers.d.ts.map +0 -1
  113. package/lib/typescript/js-top/engine/state.d.ts.map +0 -1
  114. package/lib/typescript/js-top/engine/symbolicate.d.ts.map +0 -1
  115. package/lib/typescript/js-top/sync/jsTopSyncAdapter.d.ts.map +0 -1
  116. package/lib/typescript/js-top/types/index.d.ts.map +0 -1
  117. package/lib/typescript/js-top/utils/preferences.d.ts.map +0 -1
  118. package/lib/typescript/preset.d.ts.map +0 -1
@@ -1,133 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.buoyJsTopRunAs = buoyJsTopRunAs;
7
- exports.buoyJsTopWrapTask = buoyJsTopWrapTask;
8
- exports.debugDepth = debugDepth;
9
- exports.recentIntervals = recentIntervals;
10
- var _now = require("./now");
11
- var _state = require("./state");
12
- var _originRegistry = require("./originRegistry");
13
- /**
14
- * wrapTask — the single wrapper every patched entry point uses, plus the
15
- * frame stack that makes nested wrapped calls book EXCLUSIVE time.
16
- *
17
- * The no-double-count rule: every wrapper at any depth books
18
- * `(end − start) − childrenMs` to its own origin and adds its TOTAL to its
19
- * parent frame's childrenMs. Thread occupancy is then the sum of exclusive
20
- * time at all depths, which equals the union of wrapped wall intervals —
21
- * nesting (e.g. rAF callbacks fired inside a wrapped bridge call-in) can
22
- * never inflate totals.
23
- *
24
- * Naming: exported/inner functions carry a `buoyJsTop` prefix on purpose —
25
- * Hermes dev stacks only show function names + bundle offsets, and the
26
- * registry's stack parser filters engine frames by that prefix.
27
- */
28
-
29
- const DEPTH_CAP = 32;
30
- const stack = [];
31
-
32
- /** Depth-0 completed intervals ≥ this feed the longtask correlator. */
33
- const NOTABLE_INTERVAL_MS = 20;
34
- const INTERVAL_RING_SIZE = 64;
35
- const intervalRing = new Array(INTERVAL_RING_SIZE).fill(null);
36
- let intervalRingIndex = 0;
37
-
38
- /** Recent depth-0 wrapped intervals, unordered — consumers scan all slots. */
39
- function recentIntervals() {
40
- return intervalRing;
41
- }
42
-
43
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
-
45
- /** Push a frame (unless depth-capped), run `invoke`, book on the way out. */
46
- function buoyJsTopRunFrame(originKey, invoke) {
47
- const start = (0, _now.now)();
48
- const parent = stack.length > 0 ? stack[stack.length - 1] : null;
49
- let frame = null;
50
- if (stack.length < DEPTH_CAP) {
51
- frame = {
52
- originKey,
53
- start,
54
- childrenMs: 0
55
- };
56
- stack.push(frame);
57
- }
58
- try {
59
- // The user code runs OUTSIDE any catch of ours: errors propagate to the
60
- // runtime's normal unhandled-error path untouched.
61
- return invoke();
62
- } finally {
63
- try {
64
- if (frame) {
65
- stack.pop();
66
- const end = (0, _now.now)();
67
- const total = end - start;
68
- const exclusive = Math.max(0, total - frame.childrenMs);
69
- if (parent) parent.childrenMs += total;
70
- (0, _originRegistry.buoyJsTopBookExclusive)(originKey, exclusive, start, end);
71
- if (!parent && total >= NOTABLE_INTERVAL_MS) {
72
- intervalRing[intervalRingIndex] = {
73
- originKey,
74
- start,
75
- end
76
- };
77
- intervalRingIndex = (intervalRingIndex + 1) % INTERVAL_RING_SIZE;
78
- }
79
- }
80
- } catch {
81
- // Bookkeeping must never break the app.
82
- }
83
- }
84
- }
85
-
86
- /**
87
- * Wrap a callback at schedule time. ALWAYS wraps once patches are installed
88
- * (installation itself only happens on first engine start): a long-lived
89
- * callback — the classic forgotten setInterval — must stay attributable
90
- * even when it was scheduled while the engine was off, or after clear()
91
- * deleted its origin record. Identity is therefore resolved eagerly at
92
- * schedule time when possible (best stack context) and re-resolved lazily
93
- * at fire time otherwise. Inactive-engine cost per fire: one boolean.
94
- */
95
- function buoyJsTopWrapTask(fn, api) {
96
- if (typeof fn !== "function") return fn;
97
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
- if (fn[_state.WRAPPED_TAG]) return fn;
99
- let originKey = (0, _state.isActive)() ? (0, _originRegistry.buoyJsTopScheduleOrigin)(api, fn, (0, _now.now)()) : null;
100
-
101
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
102
- const buoyJsTopTaskWrapper = function (...args) {
103
- if (!(0, _state.isActive)()) return fn.apply(this, args);
104
- if (originKey === null || !(0, _originRegistry.buoyJsTopOriginExists)(originKey)) {
105
- // Scheduled while the engine was off, or stats cleared since —
106
- // (re)resolve identity now, without stack capture (see scheduleOrigin).
107
- originKey = (0, _originRegistry.buoyJsTopScheduleOrigin)(api, fn, (0, _now.now)(), false);
108
- }
109
- return buoyJsTopRunFrame(originKey, () => fn.apply(this, args));
110
- };
111
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
112
- buoyJsTopTaskWrapper[_state.WRAPPED_TAG] = true;
113
- return buoyJsTopTaskWrapper;
114
- }
115
-
116
- /**
117
- * Run a thunk as a named task frame — for entry points that aren't
118
- * schedule-a-callback shaped (e.g. bridge call-ins, where the "origin" is
119
- * the module.method being invoked right now).
120
- */
121
- function buoyJsTopRunAs(api, name, thunk) {
122
- if (!(0, _state.isActive)()) return thunk();
123
- const originKey = (0, _originRegistry.buoyJsTopScheduleOrigin)(api, {
124
- name
125
- }, (0, _now.now)());
126
- return buoyJsTopRunFrame(originKey, thunk);
127
- }
128
-
129
- /** Test-only: current nesting depth. */
130
- function debugDepth() {
131
- return stack.length;
132
- }
133
- //# sourceMappingURL=frameStack.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.buoyJsTopRunAs=buoyJsTopRunAs;exports.buoyJsTopWrapTask=buoyJsTopWrapTask;exports.debugDepth=debugDepth;exports.recentIntervals=recentIntervals;var _now=require("./now");var _state=require("./state");var _originRegistry=require("./originRegistry");const DEPTH_CAP=32;const stack=[];const NOTABLE_INTERVAL_MS=20;const INTERVAL_RING_SIZE=64;const intervalRing=new Array(INTERVAL_RING_SIZE).fill(null);let intervalRingIndex=0;function recentIntervals(){return intervalRing}function buoyJsTopRunFrame(e,o){const t=(0,_now.now)();const n=stack.length>0?stack[stack.length-1]:null;let r=null;if(stack.length<DEPTH_CAP){r={originKey:e,start:t,childrenMs:0};stack.push(r)}try{return o()}finally{try{if(r){stack.pop();const s=(0,_now.now)();const i=s-t;const u=Math.max(0,i-r.childrenMs);if(n)n.childrenMs+=i;(0,_originRegistry.buoyJsTopBookExclusive)(e,u,t,s);if(!n&&i>=NOTABLE_INTERVAL_MS){intervalRing[intervalRingIndex]={originKey:e,start:t,end:s};intervalRingIndex=(intervalRingIndex+1)%INTERVAL_RING_SIZE}}}catch{}}}function buoyJsTopWrapTask(e,o){if(typeof e!=="function")return e;if(e[_state.WRAPPED_TAG])return e;let t=(0,_state.isActive)()?(0,_originRegistry.buoyJsTopScheduleOrigin)(o,e,(0,_now.now)()):null;const n=function(...r){if(!(0,_state.isActive)())return e.apply(this,r);if(t===null||!(0,_originRegistry.buoyJsTopOriginExists)(t)){t=(0,_originRegistry.buoyJsTopScheduleOrigin)(o,e,(0,_now.now)(),false)}return buoyJsTopRunFrame(t,()=>e.apply(this,r))};n[_state.WRAPPED_TAG]=true;return n}function buoyJsTopRunAs(e,o,t){if(!(0,_state.isActive)())return t();const n=(0,_originRegistry.buoyJsTopScheduleOrigin)(e,{name:o},(0,_now.now)());return buoyJsTopRunFrame(n,t)}function debugDepth(){return stack.length}
@@ -1,141 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SYSTEM_FREEZE_KEY = void 0;
7
- exports.clearLongtasks = clearLongtasks;
8
- exports.getFreezeStats = getFreezeStats;
9
- exports.getLongtasks = getLongtasks;
10
- exports.installLongtaskObserver = installLongtaskObserver;
11
- var _state = require("./state");
12
- var _frameStack = require("./frameStack");
13
- var _originRegistry = require("./originRegistry");
14
- var _aggregator = require("./aggregator");
15
- /**
16
- * Freeze tracking. RN ships a real `PerformanceObserver('longtask')` (C++
17
- * TurboModule, present in Expo Go and release): entries fire for any task
18
- * that blocks the JS event loop ≥ 50ms — what a user feels as a dropped tap
19
- * or stuttered animation — but carry NO attribution. We supply it: each
20
- * entry is overlap-matched against the ring of recent depth-0 wrapped
21
- * intervals; the biggest overlap names the offender.
22
- *
23
- * Freeze data doesn't get its own UI section — it decorates the places you
24
- * already look: per-row ⚠ badges in the task table and a summary chip in
25
- * the header, both fed by getFreezeStats() (trailing 60s window). The raw
26
- * entry list is still exported for the desktop panel and MCP payloads.
27
- *
28
- * The observer installs once and stays connected (uninstalling/reinstalling
29
- * observers has its own churn); its handler early-outs when the engine is
30
- * inactive — longtasks only fire on 50ms+ blocks, so the idle cost is nil.
31
- */
32
-
33
- const MAX_ENTRIES = 40;
34
- /** Freeze badges/summary only consider the trailing window. */
35
- const FREEZE_WINDOW_MS = 60_000;
36
-
37
- /** Per-origin key for freezes we couldn't attribute to a wrapped callback. */
38
- const SYSTEM_FREEZE_KEY = exports.SYSTEM_FREEZE_KEY = "unattributed";
39
- let installed = false;
40
- let supported = false;
41
- const entries = [];
42
- function correlate(start, duration) {
43
- const end = start + duration;
44
- let bestKey = null;
45
- let bestOverlap = 0;
46
- for (const interval of (0, _frameStack.recentIntervals)()) {
47
- if (!interval) continue;
48
- const overlap = Math.min(end, interval.end) - Math.max(start, interval.start);
49
- if (overlap > bestOverlap) {
50
- bestOverlap = overlap;
51
- bestKey = interval.originKey;
52
- }
53
- }
54
- return bestKey;
55
- }
56
- function installLongtaskObserver() {
57
- if (installed) return {
58
- longtask: supported
59
- };
60
- installed = true;
61
- const PerformanceObserverCtor = _state.g.PerformanceObserver;
62
- if (typeof PerformanceObserverCtor !== "function") {
63
- return {
64
- longtask: false
65
- };
66
- }
67
- try {
68
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
- const observer = new PerformanceObserverCtor(list => {
70
- if (!(0, _state.isActive)()) return;
71
- try {
72
- for (const entry of list.getEntries()) {
73
- if (entry.entryType !== "longtask") continue;
74
- const start = entry.startTime;
75
- const duration = entry.duration;
76
- (0, _aggregator.bookLongtaskRange)(start, start + duration);
77
- entries.push({
78
- start,
79
- duration,
80
- at: Date.now(),
81
- originKey: correlate(start, duration)
82
- });
83
- if (entries.length > MAX_ENTRIES) entries.shift();
84
- }
85
- } catch {
86
- // Never let observation break the app.
87
- }
88
- });
89
- observer.observe({
90
- entryTypes: ["longtask"]
91
- });
92
- supported = true;
93
- } catch {
94
- supported = false;
95
- }
96
- return {
97
- longtask: supported
98
- };
99
- }
100
-
101
- /** Raw recent entries (desktop panel + MCP payload shape). */
102
- function getLongtasks() {
103
- return entries.map(e => ({
104
- start: e.start,
105
- duration: e.duration,
106
- at: e.at,
107
- originLabel: e.originKey ? (0, _originRegistry.labelForOrigin)(e.originKey) : null
108
- }));
109
- }
110
-
111
- /** Windowed per-origin freeze aggregation for badges + header summary. */
112
- function getFreezeStats(now) {
113
- const byOrigin = {};
114
- let count = 0;
115
- let worstMs = 0;
116
- for (const e of entries) {
117
- if (e.at > 0 && now - e.at > FREEZE_WINDOW_MS) continue;
118
- count++;
119
- if (e.duration > worstMs) worstMs = e.duration;
120
- const key = e.originKey ?? SYSTEM_FREEZE_KEY;
121
- const s = byOrigin[key];
122
- if (s) {
123
- s.count++;
124
- if (e.duration > s.maxMs) s.maxMs = e.duration;
125
- } else {
126
- byOrigin[key] = {
127
- count: 1,
128
- maxMs: e.duration
129
- };
130
- }
131
- }
132
- return {
133
- count,
134
- worstMs,
135
- byOrigin
136
- };
137
- }
138
- function clearLongtasks() {
139
- entries.length = 0;
140
- }
141
- //# sourceMappingURL=longtasks.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.SYSTEM_FREEZE_KEY=void 0;exports.clearLongtasks=clearLongtasks;exports.getFreezeStats=getFreezeStats;exports.getLongtasks=getLongtasks;exports.installLongtaskObserver=installLongtaskObserver;var _state=require("./state");var _frameStack=require("./frameStack");var _originRegistry=require("./originRegistry");var _aggregator=require("./aggregator");const MAX_ENTRIES=40;const FREEZE_WINDOW_MS=6e4;const SYSTEM_FREEZE_KEY=exports.SYSTEM_FREEZE_KEY="unattributed";let installed=false;let supported=false;const entries=[];function correlate(e,o){const a=e+o;let n=null;let t=0;for(const r of(0,_frameStack.recentIntervals)()){if(!r)continue;const s=Math.min(a,r.end)-Math.max(e,r.start);if(s>t){t=s;n=r.originKey}}return n}function installLongtaskObserver(){if(installed)return{longtask:supported};installed=true;const e=_state.g.PerformanceObserver;if(typeof e!=="function"){return{longtask:false}}try{const o=new e(a=>{if(!(0,_state.isActive)())return;try{for(const n of a.getEntries()){if(n.entryType!=="longtask")continue;const t=n.startTime;const r=n.duration;(0,_aggregator.bookLongtaskRange)(t,t+r);entries.push({start:t,duration:r,at:Date.now(),originKey:correlate(t,r)});if(entries.length>MAX_ENTRIES)entries.shift()}}catch{}});o.observe({entryTypes:["longtask"]});supported=true}catch{supported=false}return{longtask:supported}}function getLongtasks(){return entries.map(e=>({start:e.start,duration:e.duration,at:e.at,originLabel:e.originKey?(0,_originRegistry.labelForOrigin)(e.originKey):null}))}function getFreezeStats(e){const o={};let a=0;let n=0;for(const t of entries){if(t.at>0&&e-t.at>FREEZE_WINDOW_MS)continue;a++;if(t.duration>n)n=t.duration;const r=t.originKey??SYSTEM_FREEZE_KEY;const s=o[r];if(s){s.count++;if(t.duration>s.maxMs)s.maxMs=t.duration}else{o[r]={count:1,maxMs:t.duration}}}return{count:a,worstMs:n,byOrigin:o}}function clearLongtasks(){entries.length=0}
@@ -1,38 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.now = now;
7
- exports.setNowForTests = setNowForTests;
8
- /**
9
- * High-res monotonic clock for the engine's hot path. Resolved once at module
10
- * load: `nativePerformanceNow` (JSI global, cheapest) → `performance.now` →
11
- * `Date.now`. All engine timestamps share this single time base.
12
- */
13
-
14
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
- const g =
16
- // eslint-disable-next-line no-restricted-globals
17
- typeof globalThis !== "undefined" ? globalThis : undefined;
18
- const resolved = (() => {
19
- if (typeof g?.nativePerformanceNow === "function") {
20
- const native = g.nativePerformanceNow;
21
- return () => native();
22
- }
23
- if (typeof g?.performance?.now === "function") {
24
- const perf = g.performance;
25
- return () => perf.now();
26
- }
27
- return () => Date.now();
28
- })();
29
- let clock = resolved;
30
- function now() {
31
- return clock();
32
- }
33
-
34
- /** Test-only: swap the engine clock for a controllable one. */
35
- function setNowForTests(fn) {
36
- clock = fn ?? resolved;
37
- }
38
- //# sourceMappingURL=now.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.now=now;exports.setNowForTests=setNowForTests;const g=typeof globalThis!=="undefined"?globalThis:void 0;const resolved=(()=>{if(typeof g?.nativePerformanceNow==="function"){const e=g.nativePerformanceNow;return()=>e()}if(typeof g?.performance?.now==="function"){const e=g.performance;return()=>e.now()}return()=>Date.now()})();let clock=resolved;function now(){return clock()}function setNowForTests(e){clock=e??resolved}