add requestIdleCallback polyfill to fix Safari crash (#5689)

This commit is contained in:
rahulramesha 2024-09-24 19:37:12 +05:30 committed by GitHub
parent 3df230393a
commit 117afdb67f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 0 deletions

View file

@ -12,6 +12,8 @@ import { SWR_CONFIG } from "@/constants/swr-config";
import { resolveGeneralTheme } from "@/helpers/theme.helper";
// nprogress
import { AppProgressBar } from "@/lib/n-progress";
// polyfills
import "@/lib/polyfills";
// mobx store provider
import { StoreProvider } from "@/lib/store-context";
// wrappers

View file

@ -0,0 +1 @@
export * from "./requestIdleCallback";

View file

@ -0,0 +1,24 @@
if (typeof window !== "undefined" && window) {
// Add request callback polyfill to browser incase it does not exist
window.requestIdleCallback =
window.requestIdleCallback ??
function (cb) {
var start = Date.now();
return setTimeout(function () {
cb({
didTimeout: false,
timeRemaining: function () {
return Math.max(0, 50 - (Date.now() - start));
},
});
}, 1);
};
window.cancelIdleCallback =
window.cancelIdleCallback ??
function (id) {
clearTimeout(id);
};
}
export {};