fix(core): add requestidlecallback polyfill for safari (#5231)

This commit is contained in:
EYHN 2023-12-08 05:21:03 +00:00
parent 17d584b336
commit df439877bd
No known key found for this signature in database
GPG Key ID: 46C9E26A75AB276C
2 changed files with 20 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import './polyfill/ses-lockdown';
import './polyfill/intl-segmenter';
import './polyfill/request-idle-callback';
import { WorkspaceFallback } from '@affine/component/workspace';
import { assertExists } from '@blocksuite/global/utils';

View File

@ -0,0 +1,19 @@
window.requestIdleCallback =
window.requestIdleCallback ||
function (cb) {
const 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);
};