UNPKG

@typed-tabletop-simulator/lib

Version:
26 lines (25 loc) 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.waitUntilLoaded = exports.waitCondition = exports.waitTime = exports.waitFrames = void 0; const waitFrames = (frames) => new Promise((resolve) => { Wait.frames(() => resolve(), frames); }); exports.waitFrames = waitFrames; const waitTime = async (time) => new Promise((resolve) => { Wait.time(() => resolve(), time); }); exports.waitTime = waitTime; const waitCondition = async (condition, timeout) => new Promise((resolve, reject) => { Wait.condition(() => resolve(), condition, timeout, () => reject("Timeout reached")); }); exports.waitCondition = waitCondition; const waitUntilLoaded = async (object) => { await (0, exports.waitCondition)(() => { return !object.loading_custom && !object.UI.loading; }).then(() => (0, exports.waitFrames)(30)); if (object.hasTag("Signal Loading")) { await (0, exports.waitCondition)(() => object.call("isOnLoadFinished")); } return object; }; exports.waitUntilLoaded = waitUntilLoaded;