UNPKG

@revolut/checkout

Version:
38 lines (37 loc) 1.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var constants_1 = require("./constants"); var utils_1 = require("./utils"); var loadedVersion = null; var pendingTimestamp = null; function RevolutPaymentsVersionLoader(mode) { if (mode === void 0) { mode = RevolutPaymentsVersionLoader.mode; } if (typeof loadedVersion === 'string') { return Promise.resolve(loadedVersion); } pendingTimestamp = pendingTimestamp !== null && pendingTimestamp !== void 0 ? pendingTimestamp : Date.now(); return utils_1.loadScript({ src: utils_1.getVersionedUrl(constants_1.URLS[mode].version, "" + pendingTimestamp), id: 'revolut-pay-version', name: 'RevolutPayVersion', }) .then(function () { pendingTimestamp = null; if (typeof loadedVersion !== 'string' || !loadedVersion) { loadedVersion = '__REV_PAY_VERSION__' in window && typeof __REV_PAY_VERSION__ === 'string' ? __REV_PAY_VERSION__ : ''; delete window.__REV_PAY_VERSION__; } return loadedVersion; }) .catch(function () { pendingTimestamp = null; loadedVersion = ''; return loadedVersion; }); } exports.RevolutPaymentsVersionLoader = RevolutPaymentsVersionLoader; RevolutPaymentsVersionLoader.mode = constants_1.MODE.PRODUCTION;