feat(core): new worker workspace engine (#9257)

This commit is contained in:
EYHN
2025-01-17 00:22:18 +08:00
committed by GitHub
parent 7dc470e7ea
commit a2ffdb4047
219 changed files with 4267 additions and 7194 deletions

View File

@@ -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();

View File

@@ -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';

View File

@@ -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';

View File

@@ -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';

View File

@@ -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);
};

View File

@@ -1,5 +1,7 @@
import { ResizeObserver } from '@juggle/resize-observer';
export function polyfillResizeObserver() {
window.ResizeObserver = ResizeObserver;
if (typeof window !== 'undefined') {
window.ResizeObserver = ResizeObserver;
}
}