12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- Object.defineProperty(exports, '__esModule', { value: true });
- const object = require('./object.js');
- const nodeStackTrace = require('./node-stack-trace.js');
- function watchdogTimer(
- createTimer,
- pollInterval,
- anrThreshold,
- callback,
- ) {
- const timer = createTimer();
- let triggered = false;
- let enabled = true;
- setInterval(() => {
- const diffMs = timer.getTimeMs();
- if (triggered === false && diffMs > pollInterval + anrThreshold) {
- triggered = true;
- if (enabled) {
- callback();
- }
- }
- if (diffMs < pollInterval + anrThreshold) {
- triggered = false;
- }
- }, 20);
- return {
- poll: () => {
- timer.reset();
- },
- enabled: (state) => {
- enabled = state;
- },
- };
- }
- function callFrameToStackFrame(
- frame,
- url,
- getModuleFromFilename,
- ) {
- const filename = url ? url.replace(/^file:\/\//, '') : undefined;
-
- const colno = frame.location.columnNumber ? frame.location.columnNumber + 1 : undefined;
- const lineno = frame.location.lineNumber ? frame.location.lineNumber + 1 : undefined;
- return object.dropUndefinedKeys({
- filename,
- module: getModuleFromFilename(filename),
- function: frame.functionName || '?',
- colno,
- lineno,
- in_app: filename ? nodeStackTrace.filenameIsInApp(filename) : undefined,
- });
- }
- exports.callFrameToStackFrame = callFrameToStackFrame;
- exports.watchdogTimer = watchdogTimer;
- //# sourceMappingURL=anr.js.map
|