feeles-ide
Version:
The hackable and serializable IDE to make learning material
78 lines (65 loc) • 2.23 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _ = require("./");
var _default =
/*#__PURE__*/
function () {
var _ref = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee(script) {
var name, type, options, credits, lastModified, composed;
return _regenerator.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return 1;
case 2:
// Be asynchronus.
name = script.getAttribute('name');
type = script.getAttribute('data-type');
options = {
isTrashed: script.hasAttribute('is-trashed')
};
credits = script.hasAttribute('data-credits') ? JSON.parse(script.getAttribute('data-credits')) : [];
lastModified = +script.getAttribute('data-last-modified') || 0;
composed = script.textContent;
if (!(0, _.validateType)('blob', type)) {
_context.next = 12;
break;
}
return _context.abrupt("return", new _.BinaryFile({
type: type,
name: name,
options: options,
credits: credits,
lastModified: lastModified,
composed: composed
}));
case 12:
return _context.abrupt("return", new _.SourceFile({
type: type,
name: name,
options: options,
credits: credits,
lastModified: lastModified,
composed: composed
}));
case 13:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
return function (_x) {
return _ref.apply(this, arguments);
};
}();
exports.default = _default;