cosmic-lib
Version:
A JavaScript implementation of the CosmicLink protocol for Stellar
56 lines (47 loc) • 1.46 kB
JavaScript
;
/**
* Asynchronously load external ressources.
*/
/**/
var _regeneratorRuntime = require("@babel/runtime/regenerator");
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
var load = require("@cosmic-plus/domutils/es5/load");
module.exports = load;
/**
*
* Load cosmic-lib CSS from **href** or from default origin. All subsequent
* calls will refer to the original request.
*
* @example
* /// Preload at the start of your script:
* cosmicLib.load.styles('css/cosmic-lib.css')
*
* /// Then wait for the request to resolve before you display CosmicLink HTML
* /// description:
* await cosmicLib.load.styles()
*
* @alias module:load#styles
* @async
* @param {string} [href='cosmic-lib.css']
*/
load.styles = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
var href,
promise,
_args = arguments;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
href = _args.length > 0 && _args[0] !== undefined ? _args[0] : "https://cdn.cosmic.plus/cosmic-lib@2.x/cosmic-lib.css";
promise = load.css(href);
load.styles = function () {
return promise;
};
return _context.abrupt("return", promise);
case 4:
case "end":
return _context.stop();
}
}
}, _callee);
}));