123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- Object.defineProperty(exports, '__esModule', { value: true });
- const worldwide = require('./worldwide.js');
- const ONE_SECOND_IN_MS = 1000;
- function dateTimestampInSeconds() {
- return Date.now() / ONE_SECOND_IN_MS;
- }
- function createUnixTimestampInSecondsFunc() {
- const { performance } = worldwide.GLOBAL_OBJ ;
- if (!performance || !performance.now) {
- return dateTimestampInSeconds;
- }
-
-
- const approxStartingTimeOrigin = Date.now() - performance.now();
- const timeOrigin = performance.timeOrigin == undefined ? approxStartingTimeOrigin : performance.timeOrigin;
-
-
-
-
-
-
-
-
-
- return () => {
- return (timeOrigin + performance.now()) / ONE_SECOND_IN_MS;
- };
- }
- const timestampInSeconds = createUnixTimestampInSecondsFunc();
- const timestampWithMs = timestampInSeconds;
- exports._browserPerformanceTimeOriginMode = void 0;
- const browserPerformanceTimeOrigin = (() => {
-
-
-
- const { performance } = worldwide.GLOBAL_OBJ ;
- if (!performance || !performance.now) {
- exports._browserPerformanceTimeOriginMode = 'none';
- return undefined;
- }
- const threshold = 3600 * 1000;
- const performanceNow = performance.now();
- const dateNow = Date.now();
-
- const timeOriginDelta = performance.timeOrigin
- ? Math.abs(performance.timeOrigin + performanceNow - dateNow)
- : threshold;
- const timeOriginIsReliable = timeOriginDelta < threshold;
-
-
-
-
-
-
- const navigationStart = performance.timing && performance.timing.navigationStart;
- const hasNavigationStart = typeof navigationStart === 'number';
-
- const navigationStartDelta = hasNavigationStart ? Math.abs(navigationStart + performanceNow - dateNow) : threshold;
- const navigationStartIsReliable = navigationStartDelta < threshold;
- if (timeOriginIsReliable || navigationStartIsReliable) {
-
- if (timeOriginDelta <= navigationStartDelta) {
- exports._browserPerformanceTimeOriginMode = 'timeOrigin';
- return performance.timeOrigin;
- } else {
- exports._browserPerformanceTimeOriginMode = 'navigationStart';
- return navigationStart;
- }
- }
-
- exports._browserPerformanceTimeOriginMode = 'dateNow';
- return dateNow;
- })();
- exports.browserPerformanceTimeOrigin = browserPerformanceTimeOrigin;
- exports.dateTimestampInSeconds = dateTimestampInSeconds;
- exports.timestampInSeconds = timestampInSeconds;
- exports.timestampWithMs = timestampWithMs;
|