UNPKG

@mopinion/deploy

Version:

Deploy your Mopinion feedback forms with ease

101 lines (100 loc) 3.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.config = void 0; exports.getConfig = getConfig; exports.getDebugDomain = getDebugDomain; exports.getDebugEnabled = getDebugEnabled; exports.getDebugVersion = getDebugVersion; exports.getDeployDomain = getDeployDomain; exports.onConfigChange = onConfigChange; exports.setConfig = setConfig; exports.setDebugEnabled = setDebugEnabled; exports.setDebugVersion = setDebugVersion; var config = exports.config = { debug: { host: 'pastease.mopinion.com' }, host: 'deploy.mopinion.com', deployments: {} }; var listeners = []; function onConfigChange(fn) { listeners.push(fn); return listeners.filter(function (listener) { return listener !== fn; }); } function setConfig() { var fn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {}; var newConfig = fn(config); if (newConfig) { Object.assign(config, newConfig); listeners.forEach(function (f) { return f(config); }); } } function getConfig() { var fn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {}; return fn(config); } function getDeployDomain(id) { return getConfig(function (config) { var _config$debug$id; if (config.proxyDeployDomain) { return config.proxyDeployDomain; } if ((_config$debug$id = config.debug[id]) !== null && _config$debug$id !== void 0 && _config$debug$id.enabled) { return config.debug.host; } return config.host; }); } function getDebugDomain() { return getConfig(function (config) { if (config.proxyDebugDomain) { return config.proxyDebugDomain; } if (config.proxyDeployDomain) { return config.proxyDeployDomain; } return config.debug.host; }); } function getDebugEnabled() { var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; return getConfig(function (config) { var _config$debug$id2; return (_config$debug$id2 = config.debug[id]) === null || _config$debug$id2 === void 0 ? void 0 : _config$debug$id2.enabled; }); } function setDebugEnabled() { var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; var enabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; setConfig(function (config) { if (!config.debug[id]) { config.debug[id] = {}; } config.debug[id].enabled = enabled; }); } function getDebugVersion() { var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; return getConfig(function (config) { var _config$debug$id$revi, _config$debug$id3; return (_config$debug$id$revi = (_config$debug$id3 = config.debug[id]) === null || _config$debug$id3 === void 0 ? void 0 : _config$debug$id3.revision) !== null && _config$debug$id$revi !== void 0 ? _config$debug$id$revi : 'live'; }); } function setDebugVersion() { var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; var revision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'live'; setConfig(function (config) { if (!config.debug[id]) { config.debug[id] = {}; } config.debug[id].revision = revision; }); } //# sourceMappingURL=index.js.map