feat: complete Ancestor quote bot with production-ready Docker support
This commit is contained in:
27
node_modules/matrix-js-sdk/lib/realtime-callbacks.js
generated
vendored
27
node_modules/matrix-js-sdk/lib/realtime-callbacks.js
generated
vendored
@@ -1,3 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.clearTimeout = clearTimeout;
|
||||
exports.setTimeout = setTimeout;
|
||||
var _logger = require("./logger");
|
||||
/*
|
||||
Copyright 2016 OpenMarket Ltd
|
||||
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||
@@ -24,8 +32,6 @@ limitations under the License.
|
||||
* it will instead fire as soon as possible after resume.
|
||||
*/
|
||||
|
||||
import { logger } from "./logger.js";
|
||||
|
||||
// we schedule a callback at least this often, to check if we've missed out on
|
||||
// some wall-clock time due to being suspended.
|
||||
const TIMER_CHECK_PERIOD_MS = 1000;
|
||||
@@ -33,7 +39,7 @@ const TIMER_CHECK_PERIOD_MS = 1000;
|
||||
// counter, for making up ids to return from setTimeout
|
||||
let count = 0;
|
||||
|
||||
// the key for our callback with the real globalThis.setTimeout
|
||||
// the key for our callback with the real global.setTimeout
|
||||
let realCallbackKey;
|
||||
// a sorted list of the callbacks to be run.
|
||||
// each is an object with keys [runAt, func, params, key].
|
||||
@@ -53,7 +59,7 @@ const debuglog = function (...params) {};
|
||||
* @returns an identifier for this callback, which may be passed into
|
||||
* clearTimeout later.
|
||||
*/
|
||||
export function setTimeout(func, delayMs, ...params) {
|
||||
function setTimeout(func, delayMs, ...params) {
|
||||
delayMs = delayMs || 0;
|
||||
if (delayMs < 0) {
|
||||
delayMs = 0;
|
||||
@@ -82,7 +88,7 @@ export function setTimeout(func, delayMs, ...params) {
|
||||
*
|
||||
* @param key - result from an earlier setTimeout call
|
||||
*/
|
||||
export function clearTimeout(key) {
|
||||
function clearTimeout(key) {
|
||||
if (callbackList.length === 0) {
|
||||
return;
|
||||
}
|
||||
@@ -103,10 +109,10 @@ export function clearTimeout(key) {
|
||||
}
|
||||
}
|
||||
|
||||
// use the real globalThis.setTimeout to schedule a callback to runCallbacks.
|
||||
// use the real global.setTimeout to schedule a callback to runCallbacks.
|
||||
function scheduleRealCallback() {
|
||||
if (realCallbackKey) {
|
||||
globalThis.clearTimeout(realCallbackKey);
|
||||
global.clearTimeout(realCallbackKey);
|
||||
}
|
||||
const first = callbackList[0];
|
||||
if (!first) {
|
||||
@@ -116,7 +122,7 @@ function scheduleRealCallback() {
|
||||
const timestamp = Date.now();
|
||||
const delayMs = Math.min(first.runAt - timestamp, TIMER_CHECK_PERIOD_MS);
|
||||
debuglog("scheduleRealCallback: now:", timestamp, "delay:", delayMs);
|
||||
realCallbackKey = globalThis.setTimeout(runCallbacks, delayMs);
|
||||
realCallbackKey = global.setTimeout(runCallbacks, delayMs);
|
||||
}
|
||||
function runCallbacks() {
|
||||
const timestamp = Date.now();
|
||||
@@ -124,6 +130,7 @@ function runCallbacks() {
|
||||
|
||||
// get the list of things to call
|
||||
const callbacksToRun = [];
|
||||
// eslint-disable-next-line
|
||||
while (true) {
|
||||
const first = callbackList[0];
|
||||
if (!first || first.runAt > timestamp) {
|
||||
@@ -140,9 +147,9 @@ function runCallbacks() {
|
||||
scheduleRealCallback();
|
||||
for (const cb of callbacksToRun) {
|
||||
try {
|
||||
cb.func.apply(globalThis, cb.params);
|
||||
cb.func.apply(global, cb.params);
|
||||
} catch (e) {
|
||||
logger.error("Uncaught exception in callback function", e);
|
||||
_logger.logger.error("Uncaught exception in callback function", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user