You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
918 B
30 lines
918 B
import { g as getWorkerState } from './chunk-mock-date.a1c85759.js';
|
|
import { s as safeSetTimeout } from './chunk-utils-timers.52534f96.js';
|
|
|
|
const safeRandom = Math.random;
|
|
function withSafeTimers(fn) {
|
|
const currentSetTimeout = globalThis.setTimeout;
|
|
const currentRandom = globalThis.Math.random;
|
|
try {
|
|
globalThis.setTimeout = safeSetTimeout;
|
|
globalThis.Math.random = safeRandom;
|
|
const result = fn();
|
|
return result;
|
|
} finally {
|
|
globalThis.setTimeout = currentSetTimeout;
|
|
globalThis.Math.random = currentRandom;
|
|
}
|
|
}
|
|
const rpc = () => {
|
|
const { rpc: rpc2 } = getWorkerState();
|
|
return new Proxy(rpc2, {
|
|
get(target, p, handler) {
|
|
const sendCall = Reflect.get(target, p, handler);
|
|
const safeSendCall = (...args) => withSafeTimers(() => sendCall(...args));
|
|
safeSendCall.asEvent = sendCall.asEvent;
|
|
return safeSendCall;
|
|
}
|
|
});
|
|
};
|
|
|
|
export { rpc as r };
|
|
|