personal-website/res/dev-fs/wde/dist/desktop.js
2023-07-18 20:15:06 +03:00

126 lines
70 KiB
JavaScript

/*
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
* This devtool is neither made for production nor for readable output files.
* It uses "eval()" calls to create a separate source file in the browser devtools.
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
* or disable the default devtool with "devtool: false".
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
*/
/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./src/decorat/desktop-decorat.js":
/*!****************************************!*\
!*** ./src/decorat/desktop-decorat.js ***!
\****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ DesktopDecorat)\n/* harmony export */ });\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nvar DesktopDecorat = /*#__PURE__*/function () {\n // static windowsLayer\n /** @type {Element} */\n\n function DesktopDecorat() {\n _classCallCheck(this, DesktopDecorat);\n this.windowLayer = document.body.querySelector('#windows-layer');\n DesktopDecorat.windowsLayer = document.body.querySelector('#windows-layer');\n if (!WebDesktopEnvironment.isMobile) {\n var startDrag = function startDrag(event) {\n var window = event.target.closest('.WindowFrame');\n DesktopDecorat.bringWindowToFront(window);\n if (event.target.classList.contains(\"DragArea\")) {\n var xPosInit = event.offsetX;\n var yPosInit = event.offsetY;\n var dragWindow = function dragWindow(event) {\n window.style.left = \"\".concat(event.clientX - xPosInit, \"px\");\n window.style.top = \"\".concat(event.clientY - yPosInit, \"px\");\n };\n var stopDrag = function stopDrag() {\n removeEventListener('mousemove', dragWindow);\n removeEventListener('mouseup', stopDrag);\n };\n addEventListener('mousemove', dragWindow);\n addEventListener('mouseup', stopDrag);\n }\n };\n DesktopDecorat.windowsLayer.addEventListener('mousedown', startDrag);\n }\n }\n\n /**\r\n * @param {HTMLElement} window\r\n */\n _createClass(DesktopDecorat, null, [{\n key: \"bringWindowToFront\",\n value: function bringWindowToFront(window) {\n //FIXME\n var previousWindow = DesktopDecorat.windowsLayer.lastChild;\n if (window == null || window == undefined) {\n return;\n }\n if (window != previousWindow) {\n DesktopDecorat.windowsLayer.insertBefore(window, previousWindow.nextSibling);\n previousWindow.classList.remove(\"Focused\");\n window.classList.add(\"Focused\");\n } else {\n window.classList.add(\"Focused\");\n }\n return;\n }\n }, {\n key: \"ChangeURL\",\n value: function ChangeURL(appWindow) {\n var appId = appWindow.getAttribute('appid');\n window.history.replaceState(null, \"\", \"/\".concat(appId, \"/\"));\n }\n }]);\n return DesktopDecorat;\n}();\n_defineProperty(DesktopDecorat, \"windowLayer\", void 0);\n\n\n//# sourceURL=webpack://my-webpack-project/./src/decorat/desktop-decorat.js?");
/***/ }),
/***/ "./src/desktop.js":
/*!************************!*\
!*** ./src/desktop.js ***!
\************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _wde_wde_desktop__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./wde/wde-desktop */ \"./src/wde/wde-desktop.js\");\n\ndocument.addEventListener('DOMContentLoaded', function () {\n var wde = new _wde_wde_desktop__WEBPACK_IMPORTED_MODULE_0__[\"default\"]();\n}, false);\n\n//# sourceURL=webpack://my-webpack-project/./src/desktop.js?");
/***/ }),
/***/ "./src/wde/scrollbar/scrollbar.js":
/*!****************************************!*\
!*** ./src/wde/scrollbar/scrollbar.js ***!
\****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ WdeScrollBar)\n/* harmony export */ });\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nvar WdeScrollBar = /*#__PURE__*/_createClass(\n/**\r\n* @param {HTMLElement} scrollBarContainer\r\n* @param {HTMLElement} content\r\n*/\nfunction WdeScrollBar(scrollBarContainer, content) {\n var _this = this;\n _classCallCheck(this, WdeScrollBar);\n var nonNativeScroll = false;\n // console.log(scrollBarContainer, content)\n // let handler = scrollBarContainer.children[0]\n //TODO On scroll move focus on window?\n var handler = scrollBarContainer.querySelector(\".ScrollBarScrollElement\"); //TODO Refactor classes\n // console.log(handler)\n\n handler.style.height = content.clientHeight / content.scrollHeight * handler.parentElement.clientHeight + 'px';\n var max = handler.parentElement.clientHeight - handler.clientHeight;\n var yPosInit = 0;\n handler.addEventListener('mousedown', function (event) {\n nonNativeScroll = true;\n yPosInit = event.clientY - Number(handler.style.top.replace('px', ''));\n document.addEventListener('mousemove', drag);\n document.addEventListener('mouseup', stop);\n });\n content.addEventListener('scroll', function (event) {\n if (!_this.nonNativeScroll) {\n var handlerPathLength = handler.parentElement.clientHeight - handler.clientHeight; //TODO recalculate only on resize event\n var coefficient = (content.scrollHeight - content.clientHeight) / handlerPathLength;\n handler.style.top = content.scrollTop / coefficient + 'px';\n }\n });\n function drag() {\n // console.log(event.clientY - yPosInit, Number(handler.style.top.replace('px','' )))\n var pos = event.clientY - yPosInit;\n var clampPos = Math.min(Math.max(pos, 0), max);\n handler.style.top = clampPos + \"px\";\n var handlerPathLength = handler.parentElement.clientHeight - handler.clientHeight; //TODO recalculate only on resize event\n var coefficient = (content.scrollHeight - content.clientHeight) / handlerPathLength;\n // console.log(clampPos, coefficient, content.clientHeight, clampPos* coefficient)\n\n content.scrollTop = clampPos * coefficient;\n }\n function stop() {\n // console.log(\"stop\")\n document.removeEventListener('mousemove', drag);\n document.removeEventListener('mouseup', stop);\n nonNativeScroll = false;\n }\n});\n\n\n//# sourceURL=webpack://my-webpack-project/./src/wde/scrollbar/scrollbar.js?");
/***/ }),
/***/ "./src/wde/wde-desktop.js":
/*!********************************!*\
!*** ./src/wde/wde-desktop.js ***!
\********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ WebDesktopEnvironment)\n/* harmony export */ });\n/* harmony import */ var _decorat_desktop_decorat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../decorat/desktop-decorat */ \"./src/decorat/desktop-decorat.js\");\n/* harmony import */ var _scrollbar_scrollbar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./scrollbar/scrollbar */ \"./src/wde/scrollbar/scrollbar.js\");\n/* harmony import */ var _web_fs_web_fs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../web-fs/web-fs */ \"./src/web-fs/web-fs.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = \"function\" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || \"@@iterator\", asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\", toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, \"\"); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, \"_invoke\", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: \"normal\", arg: fn.call(obj, arg) }; } catch (err) { return { type: \"throw\", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { [\"next\", \"throw\", \"return\"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if (\"throw\" !== record.type) { var result = record.arg, value = result.value; return value && \"object\" == _typeof(value) && hasOwn.call(value, \"__await\") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke(\"next\", value, resolve, reject); }, function (err) { invoke(\"throw\", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke(\"throw\", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, \"_invoke\", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = \"suspendedStart\"; return function (method, arg) { if (\"executing\" === state) throw new Error(\"Generator is already running\"); if (\"completed\" === state) { if (\"throw\" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if (\"next\" === context.method) context.sent = context._sent = context.arg;else if (\"throw\" === context.method) { if (\"suspendedStart\" === state) throw state = \"completed\", context.arg; context.dispatchException(context.arg); } else \"return\" === context.method && context.abrupt(\"return\", context.arg); state = \"executing\"; var record = tryCatch(innerFn, self, context); if (\"normal\" === record.type) { if (state = context.done ? \"completed\" : \"suspendedYield\", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } \"throw\" === record.type && (state = \"completed\", context.method = \"throw\", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, \"throw\" === context.method) { if (delegate.iterator[\"return\"] && (context.method = \"return\", context.arg = undefined, maybeInvokeDelegate(delegate, context), \"throw\" === context.method)) return ContinueSentinel; context.method = \"throw\", context.arg = new TypeError(\"The iterator does not provide a 'throw' method\"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if (\"throw\" === record.type) return context.method = \"throw\", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, \"return\" !== context.method && (context.method = \"next\", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = \"throw\", context.arg = new TypeError(\"iterator result is not an object\"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = \"normal\", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: \"root\" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if (\"function\" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, \"GeneratorFunction\"), exports.isGeneratorFunction = function (genFun) { var ctor = \"function\" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || \"GeneratorFunction\" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, \"GeneratorFunction\")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, \"Generator\"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, \"toString\", function () { return \"[object Generator]\"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { \"t\" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if (\"throw\" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = \"throw\", record.arg = exception, context.next = loc, caught && (context.method = \"next\", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if (\"root\" === entry.tryLoc) return handle(\"end\"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, \"catchLoc\"), hasFinally = hasOwn.call(entry, \"finallyLoc\"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error(\"try statement without catch or finally\"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, \"finallyLoc\") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && (\"break\" === type || \"continue\" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = \"next\", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if (\"throw\" === record.type) throw record.arg; return \"break\" === record.type || \"continue\" === record.type ? this.next = record.arg : \"return\" === record.type ? (this.rval = this.arg = record.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, \"catch\": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if (\"throw\" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, \"next\" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }\nfunction _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError(\"Cannot initialize the same private elements twice on an object\"); } }\nfunction _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, \"set\"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }\nfunction _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError(\"attempted to \" + action + \" private field on non-instance\"); } return privateMap.get(receiver); }\nfunction _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError(\"attempted to set read only private field\"); } descriptor.value = value; } }\n\n\n\nvar _decorat = /*#__PURE__*/new WeakMap();\nvar WebDesktopEnvironment = /*#__PURE__*/function () {\n // static decorat\n\n function WebDesktopEnvironment() {\n _classCallCheck(this, WebDesktopEnvironment);\n _classPrivateFieldInitSpec(this, _decorat, {\n writable: true,\n value: void 0\n });\n document.body.style.setProperty('--zoom', 1);\n _classPrivateFieldSet(this, _decorat, new _decorat_desktop_decorat__WEBPACK_IMPORTED_MODULE_0__[\"default\"]());\n WebDesktopEnvironment.webFs = new _web_fs_web_fs__WEBPACK_IMPORTED_MODULE_2__[\"default\"]();\n // this.loadWDE()\n }\n _createClass(WebDesktopEnvironment, [{\n key: \"loadWDE\",\n value: function () {\n var _loadWDE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var autoStart, _iterator, _step, child, appPath, args, argsRaw, _iterator2, _step2, argRaw, arg;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n autoStart = document.body.querySelector(\"wde-autostart\");\n if (!(autoStart == null)) {\n _context.next = 4;\n break;\n }\n WebDesktopEnvironment.Alert(\"Error in loading DE\");\n return _context.abrupt(\"return\");\n case 4:\n _iterator = _createForOfIteratorHelper(autoStart.children);\n _context.prev = 5;\n _iterator.s();\n case 7:\n if ((_step = _iterator.n()).done) {\n _context.next = 41;\n break;\n }\n child = _step.value;\n if (!(child.nodeName != \"APP\")) {\n _context.next = 11;\n break;\n }\n return _context.abrupt(\"continue\", 39);\n case 11:\n appPath = child.getAttribute(\"app-path\");\n if (!(appPath == null)) {\n _context.next = 14;\n break;\n }\n return _context.abrupt(\"continue\", 39);\n case 14:\n args = [];\n argsRaw = child.querySelector(\"args\");\n if (!(argsRaw == null)) {\n _context.next = 18;\n break;\n }\n return _context.abrupt(\"continue\", 39);\n case 18:\n _iterator2 = _createForOfIteratorHelper(argsRaw.children);\n _context.prev = 19;\n _iterator2.s();\n case 21:\n if ((_step2 = _iterator2.n()).done) {\n _context.next = 29;\n break;\n }\n argRaw = _step2.value;\n arg = argRaw.getAttribute(\"string\");\n if (!(arg == null)) {\n _context.next = 26;\n break;\n }\n return _context.abrupt(\"continue\", 27);\n case 26:\n args.push(arg);\n case 27:\n _context.next = 21;\n break;\n case 29:\n _context.next = 34;\n break;\n case 31:\n _context.prev = 31;\n _context.t0 = _context[\"catch\"](19);\n _iterator2.e(_context.t0);\n case 34:\n _context.prev = 34;\n _iterator2.f();\n return _context.finish(34);\n case 37:\n _context.next = 39;\n return WebDesktopEnvironment.Open(appPath, args);\n case 39:\n _context.next = 7;\n break;\n case 41:\n _context.next = 46;\n break;\n case 43:\n _context.prev = 43;\n _context.t1 = _context[\"catch\"](5);\n _iterator.e(_context.t1);\n case 46:\n _context.prev = 46;\n _iterator.f();\n return _context.finish(46);\n case 49:\n autoStart.remove();\n\n // await WebDesktopEnvironment.load2('/Applications/Finder.app', [ \"desktop\", document.querySelector('#desktop-layer')]) //FIXME\n // await WebDesktopEnvironment.Open('/Applications/Finder.app', [\"/home/user/.desktop\", \"-desktop\", document.querySelector('#desktop-layer')])\n // await WebDesktopEnvironment.Open('/Applications/Finder.app', [\"/home/user/Blogs\",])\n // await WebDesktopEnvironment.Open('/Applications/Finder.app', [\"/home/user\",])\n // await WebDesktopEnvironment.Open('/Applications/Finder.app', [\"/home\",])\n // WebDesktopEnvironment.Open('/Applications/AboutMe.app', [])\n // WebDesktopEnvironment.Open('/Applications/FinderAdmin.app', [\"/home/user\",])\n // await WebDesktopEnvironment.Open('/Applications/BlogViewer.app', [\"/home/user/Blogs/blog1.blog\",])\n case 50:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, null, [[5, 43, 46, 49], [19, 31, 34, 37]]);\n }));\n function loadWDE() {\n return _loadWDE.apply(this, arguments);\n }\n return loadWDE;\n }()\n /**\r\n * @param {string} appPath\r\n * @param {string[]} args\r\n * @param {string} runPath\r\n */\n }], [{\n key: \"Open\",\n value: function () {\n var _Open = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(appPath, args, runPath) {\n var appManifest, runContext;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return WebDesktopEnvironment.fetchApp(appPath);\n case 2:\n appManifest = _context2.sent;\n if (!(appManifest === undefined)) {\n _context2.next = 5;\n break;\n }\n return _context2.abrupt(\"return\");\n case 5:\n //TODO return err\n runContext = {\n isMobile: false,\n bundlePath: appPath,\n runPath: runPath //TODO\n };\n\n if (WebDesktopEnvironment.Applications[appManifest.appId] === undefined) {\n WebDesktopEnvironment.load2(appManifest, function () {\n WebDesktopEnvironment.Applications[appManifest.appId].NewWindow(args, runContext);\n });\n } else {\n WebDesktopEnvironment.Applications[appManifest.appId].NewWindow(args, runContext);\n }\n case 7:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2);\n }));\n function Open(_x, _x2, _x3) {\n return _Open.apply(this, arguments);\n }\n return Open;\n }()\n /**\r\n * @param {string} appManifest\r\n * @param {function} onload callback after script loading\r\n */\n }, {\n key: \"load2\",\n value: function () {\n var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(appManifest, onload) {\n var appElem, script;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n appElem = document.createElement(\"div\");\n appElem.setAttribute(\"appId\", appManifest.appId);\n //TODO Render scripts nodes on server\n //FIXME Not support more than one js now :)\n script = document.createElement(\"script\");\n script.setAttribute(\"src\", appManifest.js[0]); //FIXME path by fs read\n script.setAttribute(\"async\", \"false\"); //TODO Possible may creates a problems??\n appElem.appendChild(script);\n document.getElementById(\"applications\").appendChild(appElem);\n script.addEventListener('load', function (event) {\n var newApp = eval(\"new \".concat(appManifest.appId, \"()\"));\n //TODO Check if newApp undefined\n WebDesktopEnvironment.Applications[appManifest.appId] = newApp;\n onload();\n });\n return _context3.abrupt(\"return\");\n case 9:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3);\n }));\n function load2(_x4, _x5) {\n return _load.apply(this, arguments);\n }\n return load2;\n }()\n /**\r\n * @param {string} path\r\n * @returns {Object | undefined} //FIXME\r\n */\n }, {\n key: \"fetchApp\",\n value: function () {\n var _fetchApp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(path) {\n var params, response, error, appManifest;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) {\n switch (_context4.prev = _context4.next) {\n case 0:\n // console.log(\"path: \" + path )\n params = new URLSearchParams({\n path: path,\n mode: \"json\"\n });\n _context4.next = 3;\n return fetch(\"/system/loadApp?\" + params);\n case 3:\n response = _context4.sent;\n if (!(response.status != 200)) {\n _context4.next = 10;\n break;\n }\n _context4.next = 7;\n return response.json();\n case 7:\n error = _context4.sent;\n WebDesktopEnvironment.Alert(error.message);\n return _context4.abrupt(\"return\", undefined);\n case 10:\n //TODO Validate manifest\n appManifest = response.json();\n return _context4.abrupt(\"return\", appManifest);\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }\n }, _callee4);\n }));\n function fetchApp(_x6) {\n return _fetchApp.apply(this, arguments);\n }\n return fetchApp;\n }()\n /**\r\n * @param {string} appId\r\n * @param {number} width\r\n * @param {number} height\r\n * @returns {HTMLElement}\r\n */\n }, {\n key: \"CreateNewWindow\",\n value: function CreateNewWindow(appId, width, height) {\n var newWindow = document.createElement(\"div\");\n newWindow.setAttribute('appid', appId);\n if (WebDesktopEnvironment.isMobile) {\n newWindow.setAttribute(\"class\", \"MobileApplicationWindow\");\n document.body.querySelector('#windows-layer').appendChild(newWindow);\n return newWindow;\n } else {\n newWindow.setAttribute(\"class\", \"WindowFrame ConvexElement\");\n newWindow.setAttribute(\"windowId\", WebDesktopEnvironment.makeid(4)); //TODO:\n\n newWindow.style.width = width.toString() + \"px\";\n newWindow.style.height = height.toString() + \"px\";\n document.body.querySelector('#windows-layer').appendChild(newWindow);\n return newWindow;\n }\n }\n /**\r\n * @param {HTMLElement} window\r\n */\n }, {\n key: \"CloseWindow\",\n value: function CloseWindow(window) {\n window.remove();\n }\n }, {\n key: \"CloseFocusedWindow\",\n value: function CloseFocusedWindow() {\n if (document.body.querySelector('#windows-layer').childElementCount > 1) {\n document.body.querySelector('#windows-layer').lastElementChild.remove();\n }\n }\n\n /**\r\n * @param {string} html\r\n */\n }, {\n key: \"SetBasicWindow\",\n value: function SetBasicWindow(html) {\n this.basicWindow = html;\n }\n\n /**\r\n * @returns {string}\r\n */\n }, {\n key: \"GetBasicWindow\",\n value: function GetBasicWindow() {\n return this.basicWindow;\n }\n\n /**\r\n * @param {string} alertText\r\n */\n }, {\n key: \"Alert\",\n value: function Alert(alertText) {\n WebDesktopEnvironment.CreateAlertWindow(alertText);\n console.log(alertText);\n }\n\n /**\r\n * @param {string} alertText\r\n */\n }, {\n key: \"CreateAlertWindow\",\n value: function CreateAlertWindow(alertText) {\n var newWindow = document.createElement(\"div\");\n newWindow.setAttribute(\"class\", \"WindowFrameless\");\n newWindow.setAttribute(\"windowId\", \"SuperUniqUUID\"); //TODO:\n newWindow.style.cssText = \"position:absolute;width:450px;height:116px; margin-left: -225px; margin-top:-58px;left: 50%;top: 50%;background-color:#FFFFFF;border: 1px solid #000000;box-shadow: 2px 2px 0px #000000;\";\n var alertImage = document.createElement(\"img\");\n alertImage.setAttribute(\"src\", \"/res/sys/wde/icons/ohno.png\");\n alertImage.style.cssText = \"position:absolute; width:64px;height:64px;top:15px;left:25px\";\n newWindow.appendChild(alertImage);\n var errorText = document.createElement(\"div\");\n errorText.style.cssText = \"position:absolute; width: 300px; left:128px; top:30px;font-family: 'Virtue';\";\n errorText.innerHTML = alertText;\n newWindow.appendChild(errorText);\n var closeButton = document.createElement(\"button\");\n closeButton.style.cssText = \"position:absolute; left: 382px; bottom: 10px; background-color:#FFFFFF; width: 55px; height:18px; font-family: 'Virtue'; border-radius:4px;border: 1px solid #000000;\";\n closeButton.innerHTML = \"Close\";\n closeButton.addEventListener('click', function () {\n newWindow.remove();\n });\n newWindow.appendChild(closeButton);\n document.body.querySelector('#windows-layer').appendChild(newWindow);\n }\n }, {\n key: \"CheckMobile\",\n value: function CheckMobile() {\n var check = false;\n (function (a) {\n if (/(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc\\-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|\\-[a-w])|libw|lynx|m1\\-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m\\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\\-2|po(ck|rt|se)|prox|psio|pt\\-g|qa\\-a|qc(07|12|21|32|60|\\-[2-7]|i\\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\\-|oo|p\\-)|sdk\\/|se(c(\\-|0|1)|47|mc|nd|ri)|sgh\\-|shar|sie(\\-|m)|sk\\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\\-|v\\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\\-|tdg\\-|tel(i|m)|tim\\-|t\\-mo|to(pl|sh)|ts(70|m\\-|m3|m5)|tx\\-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\\-|your|zeto|zte\\-/i.test(a.substr(0, 4))) check = true;\n })(navigator.userAgent || navigator.vendor || window.opera);\n return check;\n }\n\n /**\r\n * @param {num} length\r\n */\n }, {\n key: \"makeid\",\n value: function makeid(length) {\n var result = '';\n var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n var charactersLength = characters.length;\n var counter = 0;\n while (counter < length) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n counter += 1;\n }\n return result;\n }\n }]);\n return WebDesktopEnvironment;\n}();\n_defineProperty(WebDesktopEnvironment, \"Applications\", {});\n_defineProperty(WebDesktopEnvironment, \"isMobile\", false);\n_defineProperty(WebDesktopEnvironment, \"webFs\", void 0);\n\n\n//# sourceURL=webpack://my-webpack-project/./src/wde/wde-desktop.js?");
/***/ }),
/***/ "./src/web-fs/web-fs.js":
/*!******************************!*\
!*** ./src/web-fs/web-fs.js ***!
\******************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ WebFS)\n/* harmony export */ });\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = \"function\" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || \"@@iterator\", asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\", toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, \"\"); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, \"_invoke\", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: \"normal\", arg: fn.call(obj, arg) }; } catch (err) { return { type: \"throw\", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { [\"next\", \"throw\", \"return\"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if (\"throw\" !== record.type) { var result = record.arg, value = result.value; return value && \"object\" == _typeof(value) && hasOwn.call(value, \"__await\") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke(\"next\", value, resolve, reject); }, function (err) { invoke(\"throw\", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke(\"throw\", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, \"_invoke\", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = \"suspendedStart\"; return function (method, arg) { if (\"executing\" === state) throw new Error(\"Generator is already running\"); if (\"completed\" === state) { if (\"throw\" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if (\"next\" === context.method) context.sent = context._sent = context.arg;else if (\"throw\" === context.method) { if (\"suspendedStart\" === state) throw state = \"completed\", context.arg; context.dispatchException(context.arg); } else \"return\" === context.method && context.abrupt(\"return\", context.arg); state = \"executing\"; var record = tryCatch(innerFn, self, context); if (\"normal\" === record.type) { if (state = context.done ? \"completed\" : \"suspendedYield\", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } \"throw\" === record.type && (state = \"completed\", context.method = \"throw\", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, \"throw\" === context.method) { if (delegate.iterator[\"return\"] && (context.method = \"return\", context.arg = undefined, maybeInvokeDelegate(delegate, context), \"throw\" === context.method)) return ContinueSentinel; context.method = \"throw\", context.arg = new TypeError(\"The iterator does not provide a 'throw' method\"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if (\"throw\" === record.type) return context.method = \"throw\", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, \"return\" !== context.method && (context.method = \"next\", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = \"throw\", context.arg = new TypeError(\"iterator result is not an object\"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = \"normal\", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: \"root\" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if (\"function\" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, \"GeneratorFunction\"), exports.isGeneratorFunction = function (genFun) { var ctor = \"function\" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || \"GeneratorFunction\" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, \"GeneratorFunction\")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, \"Generator\"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, \"toString\", function () { return \"[object Generator]\"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { \"t\" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if (\"throw\" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = \"throw\", record.arg = exception, context.next = loc, caught && (context.method = \"next\", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if (\"root\" === entry.tryLoc) return handle(\"end\"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, \"catchLoc\"), hasFinally = hasOwn.call(entry, \"finallyLoc\"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error(\"try statement without catch or finally\"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, \"finallyLoc\") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && (\"break\" === type || \"continue\" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = \"next\", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if (\"throw\" === record.type) throw record.arg; return \"break\" === record.type || \"continue\" === record.type ? this.next = record.arg : \"return\" === record.type ? (this.rval = this.arg = record.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, \"catch\": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if (\"throw\" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, \"next\" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nvar WebFS = /*#__PURE__*/function () {\n function WebFS() {\n _classCallCheck(this, WebFS);\n }\n _createClass(WebFS, null, [{\n key: \"CreateDirectory\",\n value:\n /**\r\n * @param {string} path\r\n * @returns {boolean}\r\n */\n function () {\n var _CreateDirectory = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(path) {\n var params, response;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n if (!(path == undefined)) {\n _context.next = 3;\n break;\n }\n WebDesktopEnvironment.Alert(\"Path is undefined\");\n return _context.abrupt(\"return\", false);\n case 3:\n params = new URLSearchParams({\n path: \"\".concat(path, \"/New Directory\")\n });\n _context.next = 6;\n return fetch(\"/system/fs/createDir?\" + params);\n case 6:\n response = _context.sent;\n if (!(response.status != 200)) {\n _context.next = 10;\n break;\n }\n WebDesktopEnvironment.Alert(\"DIRCTORY CREATION ERROR\"); //TODO\n return _context.abrupt(\"return\", false);\n case 10:\n return _context.abrupt(\"return\", true);\n case 11:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee);\n }));\n function CreateDirectory(_x) {\n return _CreateDirectory.apply(this, arguments);\n }\n return CreateDirectory;\n }()\n /**\r\n * @param {string} path\r\n * @returns {boolean}\r\n */\n }, {\n key: \"DeleteFile\",\n value: function () {\n var _DeleteFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(path) {\n var params, response;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n params = new URLSearchParams({\n path: path\n });\n _context2.next = 3;\n return fetch(\"/system/fs/delete?\" + params);\n case 3:\n response = _context2.sent;\n if (!(response.status != 200)) {\n _context2.next = 7;\n break;\n }\n WebDesktopEnvironment.Alert(\"DELETE ERROR\"); //TODO\n return _context2.abrupt(\"return\", false);\n case 7:\n return _context2.abrupt(\"return\", true);\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2);\n }));\n function DeleteFile(_x2) {\n return _DeleteFile.apply(this, arguments);\n }\n return DeleteFile;\n }()\n /**\r\n * @param {string} path\r\n * @returns {boolean}\r\n */\n }, {\n key: \"MoveFile\",\n value: function () {\n var _MoveFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(sourcePath, targetPath) {\n var params, response;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n params = new URLSearchParams({\n sourcePath: sourcePath,\n targetPath: targetPath\n });\n _context3.next = 3;\n return fetch(\"/system/fs/move?\" + params);\n case 3:\n response = _context3.sent;\n if (!(response.status != 200)) {\n _context3.next = 6;\n break;\n }\n return _context3.abrupt(\"return\", false);\n case 6:\n return _context3.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3);\n }));\n function MoveFile(_x3, _x4) {\n return _MoveFile.apply(this, arguments);\n }\n return MoveFile;\n }()\n /**\r\n * @param {string} linkPath\r\n * @returns {string}\r\n */\n }, {\n key: \"ReadObjectLink\",\n value: function () {\n var _ReadObjectLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(linkPath) {\n var params, response, path;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) {\n switch (_context4.prev = _context4.next) {\n case 0:\n params = new URLSearchParams({\n linkPath: linkPath\n });\n _context4.next = 3;\n return fetch(\"/system/fs/readObjectLink?\" + params);\n case 3:\n response = _context4.sent;\n if (!(response.status != 200)) {\n _context4.next = 7;\n break;\n }\n WebDesktopEnvironment.Alert(\"TODO\"); //TODO\n return _context4.abrupt(\"return\", \"\");\n case 7:\n _context4.next = 9;\n return response.text();\n case 9:\n path = _context4.sent;\n return _context4.abrupt(\"return\", path);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }\n }, _callee4);\n }));\n function ReadObjectLink(_x5) {\n return _ReadObjectLink.apply(this, arguments);\n }\n return ReadObjectLink;\n }()\n /**\r\n * @param {string} sourcePath\r\n * @param {string} linkPath\r\n * @returns {string}\r\n */\n }, {\n key: \"CreatePathLink\",\n value: function () {\n var _CreatePathLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(sourcePath, linkPath) {\n var params, response;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) {\n switch (_context5.prev = _context5.next) {\n case 0:\n params = new URLSearchParams({\n sourcePath: sourcePath,\n linkPath: linkPath\n });\n _context5.next = 3;\n return fetch(\"/system/fs/createPathLink?\" + params);\n case 3:\n response = _context5.sent;\n return _context5.abrupt(\"return\", response.status == 200);\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }\n }, _callee5);\n }));\n function CreatePathLink(_x6, _x7) {\n return _CreatePathLink.apply(this, arguments);\n }\n return CreatePathLink;\n }()\n /**\r\n * @param {string} linkPath\r\n * @returns {string}\r\n */\n }, {\n key: \"ReadPathLink\",\n value: function () {\n var _ReadPathLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(linkPath) {\n var params, response, file;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) {\n switch (_context6.prev = _context6.next) {\n case 0:\n params = new URLSearchParams({\n linkPath: linkPath\n });\n _context6.next = 3;\n return fetch(\"/system/fs/readPathLink?\" + params);\n case 3:\n response = _context6.sent;\n if (!(response.status != 200)) {\n _context6.next = 7;\n break;\n }\n WebDesktopEnvironment.Alert(\"TODO\"); //TODO\n return _context6.abrupt(\"return\", \"\");\n case 7:\n _context6.next = 9;\n return response.json();\n case 9:\n file = _context6.sent;\n return _context6.abrupt(\"return\", file);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }\n }, _callee6);\n }));\n function ReadPathLink(_x8) {\n return _ReadPathLink.apply(this, arguments);\n }\n return ReadPathLink;\n }()\n /**\r\n * @param {File} file\r\n * @param {string} parentPath\r\n * @returns {boolean}\r\n */\n }, {\n key: \"UploadFile\",\n value: function () {\n var _UploadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(file, parentPath) {\n var formData, params, response, error;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) {\n switch (_context7.prev = _context7.next) {\n case 0:\n console.log('here');\n formData = new FormData();\n formData.append(\"file\", file); //FIXME Conn reset\n params = new URLSearchParams({\n parentPath: parentPath\n });\n _context7.next = 6;\n return fetch(\"/system/fs/upload?\" + params, {\n method: \"POST\",\n //TODO Change to PUT?\n body: formData\n });\n case 6:\n response = _context7.sent;\n console.log(response.status);\n if (!(response.status != 201)) {\n _context7.next = 14;\n break;\n }\n _context7.next = 11;\n return response.json();\n case 11:\n error = _context7.sent;\n WebDesktopEnvironment.Alert(error.message);\n return _context7.abrupt(\"return\", false);\n case 14:\n return _context7.abrupt(\"return\", true);\n case 15:\n case \"end\":\n return _context7.stop();\n }\n }\n }, _callee7);\n }));\n function UploadFile(_x9, _x10) {\n return _UploadFile.apply(this, arguments);\n }\n return UploadFile;\n }()\n }]);\n return WebFS;\n}();\n\n\n//# sourceURL=webpack://my-webpack-project/./src/web-fs/web-fs.js?");
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
/******/
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module can't be inlined because the eval devtool is used.
/******/ var __webpack_exports__ = __webpack_require__("./src/desktop.js");
/******/
/******/ })()
;