feeles-ide
Version:
The hackable and serializable IDE to make learning material
46 lines (40 loc) • 1.41 kB
JavaScript
import _regeneratorRuntime from 'babel-runtime/regenerator';
import _asyncToGenerator from 'babel-runtime/helpers/asyncToGenerator';
/**
* Display web page acquired by fetch API in new windowShow website
*/
export default (function () {
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(response) {
var url;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (!(process.env.NODE_ENV !== 'production')) {
_context.next = 7;
break;
}
_context.t0 = URL;
_context.next = 4;
return response.clone().blob();
case 4:
_context.t1 = _context.sent;
url = _context.t0.createObjectURL.call(_context.t0, _context.t1);
if (window.open(url) === undefined && confirm('Display page?')) {
// Try opening the window again
if (window.open(url) === undefined) {
console.info('debugWindow: Failed to open window! See raw response', response);
}
}
case 7:
case 'end':
return _context.stop();
}
}
}, _callee, this);
}));
function debugWindow(_x) {
return _ref.apply(this, arguments);
}
return debugWindow;
})();