feat(core): new worker workspace engine (#9257)
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
import { polyfillDispose } from './dispose';
|
||||
import { polyfillIteratorHelpers } from './iterator-helpers';
|
||||
import { polyfillPromise } from './promise-with-resolvers';
|
||||
import './dispose';
|
||||
import './iterator-helpers';
|
||||
import './promise-with-resolvers';
|
||||
|
||||
import { polyfillEventLoop } from './request-idle-callback';
|
||||
import { polyfillResizeObserver } from './resize-observer';
|
||||
|
||||
polyfillResizeObserver();
|
||||
polyfillEventLoop();
|
||||
await polyfillPromise();
|
||||
await polyfillDispose();
|
||||
await polyfillIteratorHelpers();
|
||||
|
||||
@@ -1,8 +1,2 @@
|
||||
export async function polyfillDispose() {
|
||||
if (typeof Symbol.dispose !== 'symbol') {
|
||||
// @ts-expect-error ignore
|
||||
await import('core-js/modules/esnext.symbol.async-dispose');
|
||||
// @ts-expect-error ignore
|
||||
await import('core-js/modules/esnext.symbol.dispose');
|
||||
}
|
||||
}
|
||||
import 'core-js/modules/esnext.symbol.async-dispose';
|
||||
import 'core-js/modules/esnext.symbol.dispose';
|
||||
|
||||
@@ -1,7 +1 @@
|
||||
export async function polyfillIteratorHelpers() {
|
||||
if (typeof globalThis['Iterator'] !== 'function') {
|
||||
// @ts-expect-error ignore
|
||||
// https://github.com/zloirock/core-js/blob/master/packages/core-js/proposals/iterator-helpers-stage-3.js
|
||||
await import('core-js/proposals/iterator-helpers-stage-3');
|
||||
}
|
||||
}
|
||||
import 'core-js/proposals/iterator-helpers-stage-3';
|
||||
|
||||
@@ -1,6 +1 @@
|
||||
export async function polyfillPromise() {
|
||||
if (typeof Promise.withResolvers !== 'function') {
|
||||
// @ts-expect-error ignore
|
||||
await import('core-js/features/promise/with-resolvers');
|
||||
}
|
||||
}
|
||||
import 'core-js/features/promise/with-resolvers';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export function polyfillEventLoop() {
|
||||
window.requestIdleCallback =
|
||||
window.requestIdleCallback ||
|
||||
globalThis.requestIdleCallback =
|
||||
globalThis.requestIdleCallback ||
|
||||
function (cb) {
|
||||
const start = Date.now();
|
||||
return setTimeout(function () {
|
||||
@@ -13,8 +13,8 @@ export function polyfillEventLoop() {
|
||||
}, 1);
|
||||
};
|
||||
|
||||
window.cancelIdleCallback =
|
||||
window.cancelIdleCallback ||
|
||||
globalThis.cancelIdleCallback =
|
||||
globalThis.cancelIdleCallback ||
|
||||
function (id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { ResizeObserver } from '@juggle/resize-observer';
|
||||
|
||||
export function polyfillResizeObserver() {
|
||||
window.ResizeObserver = ResizeObserver;
|
||||
if (typeof window !== 'undefined') {
|
||||
window.ResizeObserver = ResizeObserver;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user