@sentry-internal/browser-utils
Advanced tools
Comparing version 8.0.0-beta.1 to 8.0.0-beta.2
@@ -5,5 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
const WINDOW = utils.GLOBAL_OBJ ; | ||
const WINDOW = utils.GLOBAL_OBJ | ||
; | ||
exports.WINDOW = WINDOW; | ||
//# sourceMappingURL=types.js.map |
Object.defineProperty(exports, '__esModule', { value: true }); | ||
const types = require('../types.js'); | ||
const bindReporter = require('./lib/bindReporter.js'); | ||
@@ -87,6 +88,8 @@ const getActivationStart = require('./lib/getActivationStart.js'); | ||
['keydown', 'click'].forEach(type => { | ||
// Wrap in a setTimeout so the callback is run in a separate task | ||
// to avoid extending the keyboard/click handler to reduce INP impact | ||
// https://github.com/GoogleChrome/web-vitals/issues/383 | ||
addEventListener(type, () => setTimeout(stopListening, 0), true); | ||
if (types.WINDOW.document) { | ||
// Wrap in a setTimeout so the callback is run in a separate task | ||
// to avoid extending the keyboard/click handler to reduce INP impact | ||
// https://github.com/GoogleChrome/web-vitals/issues/383 | ||
addEventListener(type, () => setTimeout(stopListening, 0), true); | ||
} | ||
}); | ||
@@ -93,0 +96,0 @@ |
@@ -30,3 +30,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
// event logic below). | ||
return types.WINDOW.document.visibilityState === 'hidden' && !types.WINDOW.document.prerendering ? 0 : Infinity; | ||
firstHiddenTime = types.WINDOW.document.visibilityState === 'hidden' && !types.WINDOW.document.prerendering ? 0 : Infinity; | ||
}; | ||
@@ -48,3 +48,4 @@ | ||
// Remove all listeners now that a `firstHiddenTime` value has been set. | ||
removeChangeListeners(); | ||
removeEventListener('visibilitychange', onVisibilityUpdate, true); | ||
removeEventListener('prerenderingchange', onVisibilityUpdate, true); | ||
} | ||
@@ -62,9 +63,4 @@ }; | ||
const removeChangeListeners = () => { | ||
removeEventListener('visibilitychange', onVisibilityUpdate, true); | ||
removeEventListener('prerenderingchange', onVisibilityUpdate, true); | ||
}; | ||
const getVisibilityWatcher = () => { | ||
if (firstHiddenTime < 0) { | ||
if (types.WINDOW.document && firstHiddenTime < 0) { | ||
// If the document is hidden when this code runs, assume it was hidden | ||
@@ -74,3 +70,3 @@ // since navigation start. This isn't a perfect heuristic, but it's the | ||
// visibilityState. | ||
firstHiddenTime = initHiddenTime(); | ||
initHiddenTime(); | ||
addChangeListeners(); | ||
@@ -77,0 +73,0 @@ } |
@@ -30,5 +30,5 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
if (navEntry) { | ||
if (types.WINDOW.document.prerendering || getActivationStart.getActivationStart() > 0) { | ||
if ((types.WINDOW.document && types.WINDOW.document.prerendering) || getActivationStart.getActivationStart() > 0) { | ||
navigationType = 'prerender'; | ||
} else if (types.WINDOW.document.wasDiscarded) { | ||
} else if (types.WINDOW.document && types.WINDOW.document.wasDiscarded) { | ||
navigationType = 'restore'; | ||
@@ -35,0 +35,0 @@ } else if (navEntry.type) { |
@@ -24,10 +24,13 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
const onHiddenOrPageHide = (event) => { | ||
if (event.type === 'pagehide' || types.WINDOW.document.visibilityState === 'hidden') { | ||
if (event.type === 'pagehide' || (types.WINDOW.document && types.WINDOW.document.visibilityState === 'hidden')) { | ||
cb(event); | ||
} | ||
}; | ||
addEventListener('visibilitychange', onHiddenOrPageHide, true); | ||
// Some browsers have buggy implementations of visibilitychange, | ||
// so we use pagehide in addition, just to be safe. | ||
addEventListener('pagehide', onHiddenOrPageHide, true); | ||
if (types.WINDOW.document) { | ||
addEventListener('visibilitychange', onHiddenOrPageHide, true); | ||
// Some browsers have buggy implementations of visibilitychange, | ||
// so we use pagehide in addition, just to be safe. | ||
addEventListener('pagehide', onHiddenOrPageHide, true); | ||
} | ||
}; | ||
@@ -34,0 +37,0 @@ |
@@ -23,3 +23,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
const whenActivated = (callback) => { | ||
if (types.WINDOW.document.prerendering) { | ||
if (types.WINDOW.document && types.WINDOW.document.prerendering) { | ||
addEventListener('prerenderingchange', () => callback(), true); | ||
@@ -26,0 +26,0 @@ } else { |
@@ -35,5 +35,5 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
const whenReady = (callback) => { | ||
if (types.WINDOW.document.prerendering) { | ||
if (types.WINDOW.document && types.WINDOW.document.prerendering) { | ||
whenActivated.whenActivated(() => whenReady(callback)); | ||
} else if (types.WINDOW.document.readyState !== 'complete') { | ||
} else if (types.WINDOW.document && types.WINDOW.document.readyState !== 'complete') { | ||
addEventListener('load', () => whenReady(callback), true); | ||
@@ -40,0 +40,0 @@ } else { |
import { GLOBAL_OBJ } from '@sentry/utils'; | ||
const WINDOW = GLOBAL_OBJ ; | ||
const WINDOW = GLOBAL_OBJ | ||
; | ||
export { WINDOW }; | ||
//# sourceMappingURL=types.js.map |
@@ -0,1 +1,2 @@ | ||
import { WINDOW } from '../types.js'; | ||
import { bindReporter } from './lib/bindReporter.js'; | ||
@@ -85,6 +86,8 @@ import { getActivationStart } from './lib/getActivationStart.js'; | ||
['keydown', 'click'].forEach(type => { | ||
// Wrap in a setTimeout so the callback is run in a separate task | ||
// to avoid extending the keyboard/click handler to reduce INP impact | ||
// https://github.com/GoogleChrome/web-vitals/issues/383 | ||
addEventListener(type, () => setTimeout(stopListening, 0), true); | ||
if (WINDOW.document) { | ||
// Wrap in a setTimeout so the callback is run in a separate task | ||
// to avoid extending the keyboard/click handler to reduce INP impact | ||
// https://github.com/GoogleChrome/web-vitals/issues/383 | ||
addEventListener(type, () => setTimeout(stopListening, 0), true); | ||
} | ||
}); | ||
@@ -91,0 +94,0 @@ |
@@ -28,3 +28,3 @@ import { WINDOW } from '../../types.js'; | ||
// event logic below). | ||
return WINDOW.document.visibilityState === 'hidden' && !WINDOW.document.prerendering ? 0 : Infinity; | ||
firstHiddenTime = WINDOW.document.visibilityState === 'hidden' && !WINDOW.document.prerendering ? 0 : Infinity; | ||
}; | ||
@@ -46,3 +46,4 @@ | ||
// Remove all listeners now that a `firstHiddenTime` value has been set. | ||
removeChangeListeners(); | ||
removeEventListener('visibilitychange', onVisibilityUpdate, true); | ||
removeEventListener('prerenderingchange', onVisibilityUpdate, true); | ||
} | ||
@@ -60,9 +61,4 @@ }; | ||
const removeChangeListeners = () => { | ||
removeEventListener('visibilitychange', onVisibilityUpdate, true); | ||
removeEventListener('prerenderingchange', onVisibilityUpdate, true); | ||
}; | ||
const getVisibilityWatcher = () => { | ||
if (firstHiddenTime < 0) { | ||
if (WINDOW.document && firstHiddenTime < 0) { | ||
// If the document is hidden when this code runs, assume it was hidden | ||
@@ -72,3 +68,3 @@ // since navigation start. This isn't a perfect heuristic, but it's the | ||
// visibilityState. | ||
firstHiddenTime = initHiddenTime(); | ||
initHiddenTime(); | ||
addChangeListeners(); | ||
@@ -75,0 +71,0 @@ } |
@@ -28,5 +28,5 @@ import { WINDOW } from '../../types.js'; | ||
if (navEntry) { | ||
if (WINDOW.document.prerendering || getActivationStart() > 0) { | ||
if ((WINDOW.document && WINDOW.document.prerendering) || getActivationStart() > 0) { | ||
navigationType = 'prerender'; | ||
} else if (WINDOW.document.wasDiscarded) { | ||
} else if (WINDOW.document && WINDOW.document.wasDiscarded) { | ||
navigationType = 'restore'; | ||
@@ -33,0 +33,0 @@ } else if (navEntry.type) { |
@@ -22,10 +22,13 @@ import { WINDOW } from '../../types.js'; | ||
const onHiddenOrPageHide = (event) => { | ||
if (event.type === 'pagehide' || WINDOW.document.visibilityState === 'hidden') { | ||
if (event.type === 'pagehide' || (WINDOW.document && WINDOW.document.visibilityState === 'hidden')) { | ||
cb(event); | ||
} | ||
}; | ||
addEventListener('visibilitychange', onHiddenOrPageHide, true); | ||
// Some browsers have buggy implementations of visibilitychange, | ||
// so we use pagehide in addition, just to be safe. | ||
addEventListener('pagehide', onHiddenOrPageHide, true); | ||
if (WINDOW.document) { | ||
addEventListener('visibilitychange', onHiddenOrPageHide, true); | ||
// Some browsers have buggy implementations of visibilitychange, | ||
// so we use pagehide in addition, just to be safe. | ||
addEventListener('pagehide', onHiddenOrPageHide, true); | ||
} | ||
}; | ||
@@ -32,0 +35,0 @@ |
@@ -21,3 +21,3 @@ import { WINDOW } from '../../types.js'; | ||
const whenActivated = (callback) => { | ||
if (WINDOW.document.prerendering) { | ||
if (WINDOW.document && WINDOW.document.prerendering) { | ||
addEventListener('prerenderingchange', () => callback(), true); | ||
@@ -24,0 +24,0 @@ } else { |
@@ -33,5 +33,5 @@ import { WINDOW } from '../types.js'; | ||
const whenReady = (callback) => { | ||
if (WINDOW.document.prerendering) { | ||
if (WINDOW.document && WINDOW.document.prerendering) { | ||
whenActivated(() => whenReady(callback)); | ||
} else if (WINDOW.document.readyState !== 'complete') { | ||
} else if (WINDOW.document && WINDOW.document.readyState !== 'complete') { | ||
addEventListener('load', () => whenReady(callback), true); | ||
@@ -38,0 +38,0 @@ } else { |
{ | ||
"name": "@sentry-internal/browser-utils", | ||
"version": "8.0.0-beta.1", | ||
"version": "8.0.0-beta.2", | ||
"description": "Browser Utilities for all Sentry JavaScript SDKs", | ||
@@ -45,7 +45,7 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
"dependencies": { | ||
"@sentry/core": "8.0.0-beta.1", | ||
"@sentry/types": "8.0.0-beta.1", | ||
"@sentry/utils": "8.0.0-beta.1" | ||
"@sentry/core": "8.0.0-beta.2", | ||
"@sentry/types": "8.0.0-beta.2", | ||
"@sentry/utils": "8.0.0-beta.2" | ||
}, | ||
"sideEffects": false | ||
} |
@@ -1,2 +0,2 @@ | ||
export declare const WINDOW: import("@sentry/utils").InternalGlobal & Window; | ||
export declare const WINDOW: import("@sentry/utils").InternalGlobal & Pick<Window, Exclude<keyof Window, "document">> & Partial<Pick<Window, "document">>; | ||
//# sourceMappingURL=types.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export declare const WINDOW: import("@sentry/utils").InternalGlobal & Window; | ||
export declare const WINDOW: import("@sentry/utils").InternalGlobal & Omit<Window, "document"> & Partial<Pick<Window, "document">>; | ||
//# sourceMappingURL=types.d.ts.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
509931
5639
0
+ Added@sentry/core@8.0.0-beta.2(transitive)
+ Added@sentry/types@8.0.0-beta.2(transitive)
+ Added@sentry/utils@8.0.0-beta.2(transitive)
- Removed@sentry/core@8.0.0-beta.1(transitive)
- Removed@sentry/types@8.0.0-beta.1(transitive)
- Removed@sentry/utils@8.0.0-beta.1(transitive)
Updated@sentry/core@8.0.0-beta.2
Updated@sentry/types@8.0.0-beta.2
Updated@sentry/utils@8.0.0-beta.2