|
|
@ -27,6 +27,43 @@ class Worker { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
window.Worker = Worker; |
|
|
window.Worker = Worker; |
|
|
|
|
|
// Polyfill MessageChannel for environments (like jest/jsdom) that don't provide it |
|
|
|
|
|
if (typeof global.MessageChannel === 'undefined') { |
|
|
|
|
|
class PolyMessageChannel { |
|
|
|
|
|
constructor() { |
|
|
|
|
|
const channel = this; |
|
|
|
|
|
this.port1 = { |
|
|
|
|
|
postMessage(msg) { |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
if ( |
|
|
|
|
|
channel.port2 && |
|
|
|
|
|
typeof channel.port2.onmessage === 'function' |
|
|
|
|
|
) { |
|
|
|
|
|
channel.port2.onmessage({ data: msg }); |
|
|
|
|
|
} |
|
|
|
|
|
}, 0); |
|
|
|
|
|
}, |
|
|
|
|
|
}; |
|
|
|
|
|
this.port2 = { |
|
|
|
|
|
postMessage(msg) { |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
if ( |
|
|
|
|
|
channel.port1 && |
|
|
|
|
|
typeof channel.port1.onmessage === 'function' |
|
|
|
|
|
) { |
|
|
|
|
|
channel.port1.onmessage({ data: msg }); |
|
|
|
|
|
} |
|
|
|
|
|
}, 0); |
|
|
|
|
|
}, |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
global.MessageChannel = PolyMessageChannel; |
|
|
|
|
|
if (typeof window !== 'undefined') { |
|
|
|
|
|
window.MessageChannel = PolyMessageChannel; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (typeof window !== 'undefined') { |
|
|
if (typeof window !== 'undefined') { |
|
|
// ref: https://github.com/ant-design/ant-design/issues/18774 |
|
|
// ref: https://github.com/ant-design/ant-design/issues/18774 |
|
|
|