You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4602 lines
135 KiB

3 years ago
3 years ago
3 years ago
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // define getter function for harmony exports
  37. /******/ __webpack_require__.d = function(exports, name, getter) {
  38. /******/ if(!__webpack_require__.o(exports, name)) {
  39. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  40. /******/ }
  41. /******/ };
  42. /******/
  43. /******/ // define __esModule on exports
  44. /******/ __webpack_require__.r = function(exports) {
  45. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  46. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  47. /******/ }
  48. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  49. /******/ };
  50. /******/
  51. /******/ // create a fake namespace object
  52. /******/ // mode & 1: value is a module id, require it
  53. /******/ // mode & 2: merge all properties of value into the ns
  54. /******/ // mode & 4: return value when already ns object
  55. /******/ // mode & 8|1: behave like require
  56. /******/ __webpack_require__.t = function(value, mode) {
  57. /******/ if(mode & 1) value = __webpack_require__(value);
  58. /******/ if(mode & 8) return value;
  59. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  60. /******/ var ns = Object.create(null);
  61. /******/ __webpack_require__.r(ns);
  62. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  63. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  64. /******/ return ns;
  65. /******/ };
  66. /******/
  67. /******/ // getDefaultExport function for compatibility with non-harmony modules
  68. /******/ __webpack_require__.n = function(module) {
  69. /******/ var getter = module && module.__esModule ?
  70. /******/ function getDefault() { return module['default']; } :
  71. /******/ function getModuleExports() { return module; };
  72. /******/ __webpack_require__.d(getter, 'a', getter);
  73. /******/ return getter;
  74. /******/ };
  75. /******/
  76. /******/ // Object.prototype.hasOwnProperty.call
  77. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  78. /******/
  79. /******/ // __webpack_public_path__
  80. /******/ __webpack_require__.p = "/";
  81. /******/
  82. /******/
  83. /******/ // Load entry module and return exports
  84. /******/ return __webpack_require__(__webpack_require__.s = 0);
  85. /******/ })
  86. /************************************************************************/
  87. /******/ ({
  88. /***/ "./node_modules/axios/index.js":
  89. /*!*************************************!*\
  90. !*** ./node_modules/axios/index.js ***!
  91. \*************************************/
  92. /*! no static exports found */
  93. /***/ (function(module, exports, __webpack_require__) {
  94. module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js");
  95. /***/ }),
  96. /***/ "./node_modules/axios/lib/adapters/xhr.js":
  97. /*!************************************************!*\
  98. !*** ./node_modules/axios/lib/adapters/xhr.js ***!
  99. \************************************************/
  100. /*! no static exports found */
  101. /***/ (function(module, exports, __webpack_require__) {
  102. "use strict";
  103. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  104. var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js");
  105. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
  106. var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  107. var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js");
  108. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
  109. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
  110. var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
  111. module.exports = function xhrAdapter(config) {
  112. return new Promise(function dispatchXhrRequest(resolve, reject) {
  113. var requestData = config.data;
  114. var requestHeaders = config.headers;
  115. if (utils.isFormData(requestData)) {
  116. delete requestHeaders['Content-Type']; // Let the browser set it
  117. }
  118. var request = new XMLHttpRequest();
  119. // HTTP basic authentication
  120. if (config.auth) {
  121. var username = config.auth.username || '';
  122. var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
  123. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  124. }
  125. var fullPath = buildFullPath(config.baseURL, config.url);
  126. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  127. // Set the request timeout in MS
  128. request.timeout = config.timeout;
  129. // Listen for ready state
  130. request.onreadystatechange = function handleLoad() {
  131. if (!request || request.readyState !== 4) {
  132. return;
  133. }
  134. // The request errored out and we didn't get a response, this will be
  135. // handled by onerror instead
  136. // With one exception: request that using file: protocol, most browsers
  137. // will return status as 0 even though it's a successful request
  138. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  139. return;
  140. }
  141. // Prepare the response
  142. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  143. var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
  144. var response = {
  145. data: responseData,
  146. status: request.status,
  147. statusText: request.statusText,
  148. headers: responseHeaders,
  149. config: config,
  150. request: request
  151. };
  152. settle(resolve, reject, response);
  153. // Clean up request
  154. request = null;
  155. };
  156. // Handle browser request cancellation (as opposed to a manual cancellation)
  157. request.onabort = function handleAbort() {
  158. if (!request) {
  159. return;
  160. }
  161. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  162. // Clean up request
  163. request = null;
  164. };
  165. // Handle low level network errors
  166. request.onerror = function handleError() {
  167. // Real errors are hidden from us by the browser
  168. // onerror should only fire if it's a network error
  169. reject(createError('Network Error', config, null, request));
  170. // Clean up request
  171. request = null;
  172. };
  173. // Handle timeout
  174. request.ontimeout = function handleTimeout() {
  175. var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
  176. if (config.timeoutErrorMessage) {
  177. timeoutErrorMessage = config.timeoutErrorMessage;
  178. }
  179. reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
  180. request));
  181. // Clean up request
  182. request = null;
  183. };
  184. // Add xsrf header
  185. // This is only done if running in a standard browser environment.
  186. // Specifically not if we're in a web worker, or react-native.
  187. if (utils.isStandardBrowserEnv()) {
  188. // Add xsrf header
  189. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  190. cookies.read(config.xsrfCookieName) :
  191. undefined;
  192. if (xsrfValue) {
  193. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  194. }
  195. }
  196. // Add headers to the request
  197. if ('setRequestHeader' in request) {
  198. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  199. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  200. // Remove Content-Type if data is undefined
  201. delete requestHeaders[key];
  202. } else {
  203. // Otherwise add header to the request
  204. request.setRequestHeader(key, val);
  205. }
  206. });
  207. }
  208. // Add withCredentials to request if needed
  209. if (!utils.isUndefined(config.withCredentials)) {
  210. request.withCredentials = !!config.withCredentials;
  211. }
  212. // Add responseType to request if needed
  213. if (config.responseType) {
  214. try {
  215. request.responseType = config.responseType;
  216. } catch (e) {
  217. // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
  218. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
  219. if (config.responseType !== 'json') {
  220. throw e;
  221. }
  222. }
  223. }
  224. // Handle progress if needed
  225. if (typeof config.onDownloadProgress === 'function') {
  226. request.addEventListener('progress', config.onDownloadProgress);
  227. }
  228. // Not all browsers support upload events
  229. if (typeof config.onUploadProgress === 'function' && request.upload) {
  230. request.upload.addEventListener('progress', config.onUploadProgress);
  231. }
  232. if (config.cancelToken) {
  233. // Handle cancellation
  234. config.cancelToken.promise.then(function onCanceled(cancel) {
  235. if (!request) {
  236. return;
  237. }
  238. request.abort();
  239. reject(cancel);
  240. // Clean up request
  241. request = null;
  242. });
  243. }
  244. if (!requestData) {
  245. requestData = null;
  246. }
  247. // Send the request
  248. request.send(requestData);
  249. });
  250. };
  251. /***/ }),
  252. /***/ "./node_modules/axios/lib/axios.js":
  253. /*!*****************************************!*\
  254. !*** ./node_modules/axios/lib/axios.js ***!
  255. \*****************************************/
  256. /*! no static exports found */
  257. /***/ (function(module, exports, __webpack_require__) {
  258. "use strict";
  259. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  260. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  261. var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
  262. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  263. var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
  264. /**
  265. * Create an instance of Axios
  266. *
  267. * @param {Object} defaultConfig The default config for the instance
  268. * @return {Axios} A new instance of Axios
  269. */
  270. function createInstance(defaultConfig) {
  271. var context = new Axios(defaultConfig);
  272. var instance = bind(Axios.prototype.request, context);
  273. // Copy axios.prototype to instance
  274. utils.extend(instance, Axios.prototype, context);
  275. // Copy context to instance
  276. utils.extend(instance, context);
  277. return instance;
  278. }
  279. // Create the default instance to be exported
  280. var axios = createInstance(defaults);
  281. // Expose Axios class to allow class inheritance
  282. axios.Axios = Axios;
  283. // Factory for creating new instances
  284. axios.create = function create(instanceConfig) {
  285. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  286. };
  287. // Expose Cancel & CancelToken
  288. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  289. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
  290. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  291. // Expose all/spread
  292. axios.all = function all(promises) {
  293. return Promise.all(promises);
  294. };
  295. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
  296. // Expose isAxiosError
  297. axios.isAxiosError = __webpack_require__(/*! ./helpers/isAxiosError */ "./node_modules/axios/lib/helpers/isAxiosError.js");
  298. module.exports = axios;
  299. // Allow use of default import syntax in TypeScript
  300. module.exports.default = axios;
  301. /***/ }),
  302. /***/ "./node_modules/axios/lib/cancel/Cancel.js":
  303. /*!*************************************************!*\
  304. !*** ./node_modules/axios/lib/cancel/Cancel.js ***!
  305. \*************************************************/
  306. /*! no static exports found */
  307. /***/ (function(module, exports, __webpack_require__) {
  308. "use strict";
  309. /**
  310. * A `Cancel` is an object that is thrown when an operation is canceled.
  311. *
  312. * @class
  313. * @param {string=} message The message.
  314. */
  315. function Cancel(message) {
  316. this.message = message;
  317. }
  318. Cancel.prototype.toString = function toString() {
  319. return 'Cancel' + (this.message ? ': ' + this.message : '');
  320. };
  321. Cancel.prototype.__CANCEL__ = true;
  322. module.exports = Cancel;
  323. /***/ }),
  324. /***/ "./node_modules/axios/lib/cancel/CancelToken.js":
  325. /*!******************************************************!*\
  326. !*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
  327. \******************************************************/
  328. /*! no static exports found */
  329. /***/ (function(module, exports, __webpack_require__) {
  330. "use strict";
  331. var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  332. /**
  333. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  334. *
  335. * @class
  336. * @param {Function} executor The executor function.
  337. */
  338. function CancelToken(executor) {
  339. if (typeof executor !== 'function') {
  340. throw new TypeError('executor must be a function.');
  341. }
  342. var resolvePromise;
  343. this.promise = new Promise(function promiseExecutor(resolve) {
  344. resolvePromise = resolve;
  345. });
  346. var token = this;
  347. executor(function cancel(message) {
  348. if (token.reason) {
  349. // Cancellation has already been requested
  350. return;
  351. }
  352. token.reason = new Cancel(message);
  353. resolvePromise(token.reason);
  354. });
  355. }
  356. /**
  357. * Throws a `Cancel` if cancellation has been requested.
  358. */
  359. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  360. if (this.reason) {
  361. throw this.reason;
  362. }
  363. };
  364. /**
  365. * Returns an object that contains a new `CancelToken` and a function that, when called,
  366. * cancels the `CancelToken`.
  367. */
  368. CancelToken.source = function source() {
  369. var cancel;
  370. var token = new CancelToken(function executor(c) {
  371. cancel = c;
  372. });
  373. return {
  374. token: token,
  375. cancel: cancel
  376. };
  377. };
  378. module.exports = CancelToken;
  379. /***/ }),
  380. /***/ "./node_modules/axios/lib/cancel/isCancel.js":
  381. /*!***************************************************!*\
  382. !*** ./node_modules/axios/lib/cancel/isCancel.js ***!
  383. \***************************************************/
  384. /*! no static exports found */
  385. /***/ (function(module, exports, __webpack_require__) {
  386. "use strict";
  387. module.exports = function isCancel(value) {
  388. return !!(value && value.__CANCEL__);
  389. };
  390. /***/ }),
  391. /***/ "./node_modules/axios/lib/core/Axios.js":
  392. /*!**********************************************!*\
  393. !*** ./node_modules/axios/lib/core/Axios.js ***!
  394. \**********************************************/
  395. /*! no static exports found */
  396. /***/ (function(module, exports, __webpack_require__) {
  397. "use strict";
  398. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  399. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  400. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
  401. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
  402. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  403. /**
  404. * Create a new instance of Axios
  405. *
  406. * @param {Object} instanceConfig The default config for the instance
  407. */
  408. function Axios(instanceConfig) {
  409. this.defaults = instanceConfig;
  410. this.interceptors = {
  411. request: new InterceptorManager(),
  412. response: new InterceptorManager()
  413. };
  414. }
  415. /**
  416. * Dispatch a request
  417. *
  418. * @param {Object} config The config specific for this request (merged with this.defaults)
  419. */
  420. Axios.prototype.request = function request(config) {
  421. /*eslint no-param-reassign:0*/
  422. // Allow for axios('example/url'[, config]) a la fetch API
  423. if (typeof config === 'string') {
  424. config = arguments[1] || {};
  425. config.url = arguments[0];
  426. } else {
  427. config = config || {};
  428. }
  429. config = mergeConfig(this.defaults, config);
  430. // Set config.method
  431. if (config.method) {
  432. config.method = config.method.toLowerCase();
  433. } else if (this.defaults.method) {
  434. config.method = this.defaults.method.toLowerCase();
  435. } else {
  436. config.method = 'get';
  437. }
  438. // Hook up interceptors middleware
  439. var chain = [dispatchRequest, undefined];
  440. var promise = Promise.resolve(config);
  441. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  442. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  443. });
  444. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  445. chain.push(interceptor.fulfilled, interceptor.rejected);
  446. });
  447. while (chain.length) {
  448. promise = promise.then(chain.shift(), chain.shift());
  449. }
  450. return promise;
  451. };
  452. Axios.prototype.getUri = function getUri(config) {
  453. config = mergeConfig(this.defaults, config);
  454. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  455. };
  456. // Provide aliases for supported request methods
  457. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  458. /*eslint func-names:0*/
  459. Axios.prototype[method] = function(url, config) {
  460. return this.request(mergeConfig(config || {}, {
  461. method: method,
  462. url: url,
  463. data: (config || {}).data
  464. }));
  465. };
  466. });
  467. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  468. /*eslint func-names:0*/
  469. Axios.prototype[method] = function(url, data, config) {
  470. return this.request(mergeConfig(config || {}, {
  471. method: method,
  472. url: url,
  473. data: data
  474. }));
  475. };
  476. });
  477. module.exports = Axios;
  478. /***/ }),
  479. /***/ "./node_modules/axios/lib/core/InterceptorManager.js":
  480. /*!***********************************************************!*\
  481. !*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
  482. \***********************************************************/
  483. /*! no static exports found */
  484. /***/ (function(module, exports, __webpack_require__) {
  485. "use strict";
  486. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  487. function InterceptorManager() {
  488. this.handlers = [];
  489. }
  490. /**
  491. * Add a new interceptor to the stack
  492. *
  493. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  494. * @param {Function} rejected The function to handle `reject` for a `Promise`
  495. *
  496. * @return {Number} An ID used to remove interceptor later
  497. */
  498. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  499. this.handlers.push({
  500. fulfilled: fulfilled,
  501. rejected: rejected
  502. });
  503. return this.handlers.length - 1;
  504. };
  505. /**
  506. * Remove an interceptor from the stack
  507. *
  508. * @param {Number} id The ID that was returned by `use`
  509. */
  510. InterceptorManager.prototype.eject = function eject(id) {
  511. if (this.handlers[id]) {
  512. this.handlers[id] = null;
  513. }
  514. };
  515. /**
  516. * Iterate over all the registered interceptors
  517. *
  518. * This method is particularly useful for skipping over any
  519. * interceptors that may have become `null` calling `eject`.
  520. *
  521. * @param {Function} fn The function to call for each interceptor
  522. */
  523. InterceptorManager.prototype.forEach = function forEach(fn) {
  524. utils.forEach(this.handlers, function forEachHandler(h) {
  525. if (h !== null) {
  526. fn(h);
  527. }
  528. });
  529. };
  530. module.exports = InterceptorManager;
  531. /***/ }),
  532. /***/ "./node_modules/axios/lib/core/buildFullPath.js":
  533. /*!******************************************************!*\
  534. !*** ./node_modules/axios/lib/core/buildFullPath.js ***!
  535. \******************************************************/
  536. /*! no static exports found */
  537. /***/ (function(module, exports, __webpack_require__) {
  538. "use strict";
  539. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
  540. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
  541. /**
  542. * Creates a new URL by combining the baseURL with the requestedURL,
  543. * only when the requestedURL is not already an absolute URL.
  544. * If the requestURL is absolute, this function returns the requestedURL untouched.
  545. *
  546. * @param {string} baseURL The base URL
  547. * @param {string} requestedURL Absolute or relative URL to combine
  548. * @returns {string} The combined full path
  549. */
  550. module.exports = function buildFullPath(baseURL, requestedURL) {
  551. if (baseURL && !isAbsoluteURL(requestedURL)) {
  552. return combineURLs(baseURL, requestedURL);
  553. }
  554. return requestedURL;
  555. };
  556. /***/ }),
  557. /***/ "./node_modules/axios/lib/core/createError.js":
  558. /*!****************************************************!*\
  559. !*** ./node_modules/axios/lib/core/createError.js ***!
  560. \****************************************************/
  561. /*! no static exports found */
  562. /***/ (function(module, exports, __webpack_require__) {
  563. "use strict";
  564. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  565. /**
  566. * Create an Error with the specified message, config, error code, request and response.
  567. *
  568. * @param {string} message The error message.
  569. * @param {Object} config The config.
  570. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  571. * @param {Object} [request] The request.
  572. * @param {Object} [response] The response.
  573. * @returns {Error} The created error.
  574. */
  575. module.exports = function createError(message, config, code, request, response) {
  576. var error = new Error(message);
  577. return enhanceError(error, config, code, request, response);
  578. };
  579. /***/ }),
  580. /***/ "./node_modules/axios/lib/core/dispatchRequest.js":
  581. /*!********************************************************!*\
  582. !*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
  583. \********************************************************/
  584. /*! no static exports found */
  585. /***/ (function(module, exports, __webpack_require__) {
  586. "use strict";
  587. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  588. var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
  589. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  590. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  591. /**
  592. * Throws a `Cancel` if cancellation has been requested.
  593. */
  594. function throwIfCancellationRequested(config) {
  595. if (config.cancelToken) {
  596. config.cancelToken.throwIfRequested();
  597. }
  598. }
  599. /**
  600. * Dispatch a request to the server using the configured adapter.
  601. *
  602. * @param {object} config The config that is to be used for the request
  603. * @returns {Promise} The Promise to be fulfilled
  604. */
  605. module.exports = function dispatchRequest(config) {
  606. throwIfCancellationRequested(config);
  607. // Ensure headers exist
  608. config.headers = config.headers || {};
  609. // Transform request data
  610. config.data = transformData(
  611. config.data,
  612. config.headers,
  613. config.transformRequest
  614. );
  615. // Flatten headers
  616. config.headers = utils.merge(
  617. config.headers.common || {},
  618. config.headers[config.method] || {},
  619. config.headers
  620. );
  621. utils.forEach(
  622. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  623. function cleanHeaderConfig(method) {
  624. delete config.headers[method];
  625. }
  626. );
  627. var adapter = config.adapter || defaults.adapter;
  628. return adapter(config).then(function onAdapterResolution(response) {
  629. throwIfCancellationRequested(config);
  630. // Transform response data
  631. response.data = transformData(
  632. response.data,
  633. response.headers,
  634. config.transformResponse
  635. );
  636. return response;
  637. }, function onAdapterRejection(reason) {
  638. if (!isCancel(reason)) {
  639. throwIfCancellationRequested(config);
  640. // Transform response data
  641. if (reason && reason.response) {
  642. reason.response.data = transformData(
  643. reason.response.data,
  644. reason.response.headers,
  645. config.transformResponse
  646. );
  647. }
  648. }
  649. return Promise.reject(reason);
  650. });
  651. };
  652. /***/ }),
  653. /***/ "./node_modules/axios/lib/core/enhanceError.js":
  654. /*!*****************************************************!*\
  655. !*** ./node_modules/axios/lib/core/enhanceError.js ***!
  656. \*****************************************************/
  657. /*! no static exports found */
  658. /***/ (function(module, exports, __webpack_require__) {
  659. "use strict";
  660. /**
  661. * Update an Error with the specified config, error code, and response.
  662. *
  663. * @param {Error} error The error to update.
  664. * @param {Object} config The config.
  665. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  666. * @param {Object} [request] The request.
  667. * @param {Object} [response] The response.
  668. * @returns {Error} The error.
  669. */
  670. module.exports = function enhanceError(error, config, code, request, response) {
  671. error.config = config;
  672. if (code) {
  673. error.code = code;
  674. }
  675. error.request = request;
  676. error.response = response;
  677. error.isAxiosError = true;
  678. error.toJSON = function toJSON() {
  679. return {
  680. // Standard
  681. message: this.message,
  682. name: this.name,
  683. // Microsoft
  684. description: this.description,
  685. number: this.number,
  686. // Mozilla
  687. fileName: this.fileName,
  688. lineNumber: this.lineNumber,
  689. columnNumber: this.columnNumber,
  690. stack: this.stack,
  691. // Axios
  692. config: this.config,
  693. code: this.code
  694. };
  695. };
  696. return error;
  697. };
  698. /***/ }),
  699. /***/ "./node_modules/axios/lib/core/mergeConfig.js":
  700. /*!****************************************************!*\
  701. !*** ./node_modules/axios/lib/core/mergeConfig.js ***!
  702. \****************************************************/
  703. /*! no static exports found */
  704. /***/ (function(module, exports, __webpack_require__) {
  705. "use strict";
  706. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  707. /**
  708. * Config-specific merge-function which creates a new config-object
  709. * by merging two configuration objects together.
  710. *
  711. * @param {Object} config1
  712. * @param {Object} config2
  713. * @returns {Object} New object resulting from merging config2 to config1
  714. */
  715. module.exports = function mergeConfig(config1, config2) {
  716. // eslint-disable-next-line no-param-reassign
  717. config2 = config2 || {};
  718. var config = {};
  719. var valueFromConfig2Keys = ['url', 'method', 'data'];
  720. var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
  721. var defaultToConfig2Keys = [
  722. 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
  723. 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  724. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
  725. 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
  726. 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
  727. ];
  728. var directMergeKeys = ['validateStatus'];
  729. function getMergedValue(target, source) {
  730. if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
  731. return utils.merge(target, source);
  732. } else if (utils.isPlainObject(source)) {
  733. return utils.merge({}, source);
  734. } else if (utils.isArray(source)) {
  735. return source.slice();
  736. }
  737. return source;
  738. }
  739. function mergeDeepProperties(prop) {
  740. if (!utils.isUndefined(config2[prop])) {
  741. config[prop] = getMergedValue(config1[prop], config2[prop]);
  742. } else if (!utils.isUndefined(config1[prop])) {
  743. config[prop] = getMergedValue(undefined, config1[prop]);
  744. }
  745. }
  746. utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
  747. if (!utils.isUndefined(config2[prop])) {
  748. config[prop] = getMergedValue(undefined, config2[prop]);
  749. }
  750. });
  751. utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
  752. utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
  753. if (!utils.isUndefined(config2[prop])) {
  754. config[prop] = getMergedValue(undefined, config2[prop]);
  755. } else if (!utils.isUndefined(config1[prop])) {
  756. config[prop] = getMergedValue(undefined, config1[prop]);
  757. }
  758. });
  759. utils.forEach(directMergeKeys, function merge(prop) {
  760. if (prop in config2) {
  761. config[prop] = getMergedValue(config1[prop], config2[prop]);
  762. } else if (prop in config1) {
  763. config[prop] = getMergedValue(undefined, config1[prop]);
  764. }
  765. });
  766. var axiosKeys = valueFromConfig2Keys
  767. .concat(mergeDeepPropertiesKeys)
  768. .concat(defaultToConfig2Keys)
  769. .concat(directMergeKeys);
  770. var otherKeys = Object
  771. .keys(config1)
  772. .concat(Object.keys(config2))
  773. .filter(function filterAxiosKeys(key) {
  774. return axiosKeys.indexOf(key) === -1;
  775. });
  776. utils.forEach(otherKeys, mergeDeepProperties);
  777. return config;
  778. };
  779. /***/ }),
  780. /***/ "./node_modules/axios/lib/core/settle.js":
  781. /*!***********************************************!*\
  782. !*** ./node_modules/axios/lib/core/settle.js ***!
  783. \***********************************************/
  784. /*! no static exports found */
  785. /***/ (function(module, exports, __webpack_require__) {
  786. "use strict";
  787. var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
  788. /**
  789. * Resolve or reject a Promise based on response status.
  790. *
  791. * @param {Function} resolve A function that resolves the promise.
  792. * @param {Function} reject A function that rejects the promise.
  793. * @param {object} response The response.
  794. */
  795. module.exports = function settle(resolve, reject, response) {
  796. var validateStatus = response.config.validateStatus;
  797. if (!response.status || !validateStatus || validateStatus(response.status)) {
  798. resolve(response);
  799. } else {
  800. reject(createError(
  801. 'Request failed with status code ' + response.status,
  802. response.config,
  803. null,
  804. response.request,
  805. response
  806. ));
  807. }
  808. };
  809. /***/ }),
  810. /***/ "./node_modules/axios/lib/core/transformData.js":
  811. /*!******************************************************!*\
  812. !*** ./node_modules/axios/lib/core/transformData.js ***!
  813. \******************************************************/
  814. /*! no static exports found */
  815. /***/ (function(module, exports, __webpack_require__) {
  816. "use strict";
  817. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  818. /**
  819. * Transform the data for a request or a response
  820. *
  821. * @param {Object|String} data The data to be transformed
  822. * @param {Array} headers The headers for the request or response
  823. * @param {Array|Function} fns A single function or Array of functions
  824. * @returns {*} The resulting transformed data
  825. */
  826. module.exports = function transformData(data, headers, fns) {
  827. /*eslint no-param-reassign:0*/
  828. utils.forEach(fns, function transform(fn) {
  829. data = fn(data, headers);
  830. });
  831. return data;
  832. };
  833. /***/ }),
  834. /***/ "./node_modules/axios/lib/defaults.js":
  835. /*!********************************************!*\
  836. !*** ./node_modules/axios/lib/defaults.js ***!
  837. \********************************************/
  838. /*! no static exports found */
  839. /***/ (function(module, exports, __webpack_require__) {
  840. "use strict";
  841. /* WEBPACK VAR INJECTION */(function(process) {
  842. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  843. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
  844. var DEFAULT_CONTENT_TYPE = {
  845. 'Content-Type': 'application/x-www-form-urlencoded'
  846. };
  847. function setContentTypeIfUnset(headers, value) {
  848. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  849. headers['Content-Type'] = value;
  850. }
  851. }
  852. function getDefaultAdapter() {
  853. var adapter;
  854. if (typeof XMLHttpRequest !== 'undefined') {
  855. // For browsers use XHR adapter
  856. adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
  857. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  858. // For node use HTTP adapter
  859. adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js");
  860. }
  861. return adapter;
  862. }
  863. var defaults = {
  864. adapter: getDefaultAdapter(),
  865. transformRequest: [function transformRequest(data, headers) {
  866. normalizeHeaderName(headers, 'Accept');
  867. normalizeHeaderName(headers, 'Content-Type');
  868. if (utils.isFormData(data) ||
  869. utils.isArrayBuffer(data) ||
  870. utils.isBuffer(data) ||
  871. utils.isStream(data) ||
  872. utils.isFile(data) ||
  873. utils.isBlob(data)
  874. ) {
  875. return data;
  876. }
  877. if (utils.isArrayBufferView(data)) {
  878. return data.buffer;
  879. }
  880. if (utils.isURLSearchParams(data)) {
  881. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  882. return data.toString();
  883. }
  884. if (utils.isObject(data)) {
  885. setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
  886. return JSON.stringify(data);
  887. }
  888. return data;
  889. }],
  890. transformResponse: [function transformResponse(data) {
  891. /*eslint no-param-reassign:0*/
  892. if (typeof data === 'string') {
  893. try {
  894. data = JSON.parse(data);
  895. } catch (e) { /* Ignore */ }
  896. }
  897. return data;
  898. }],
  899. /**
  900. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  901. * timeout is not created.
  902. */
  903. timeout: 0,
  904. xsrfCookieName: 'XSRF-TOKEN',
  905. xsrfHeaderName: 'X-XSRF-TOKEN',
  906. maxContentLength: -1,
  907. maxBodyLength: -1,
  908. validateStatus: function validateStatus(status) {
  909. return status >= 200 && status < 300;
  910. }
  911. };
  912. defaults.headers = {
  913. common: {
  914. 'Accept': 'application/json, text/plain, */*'
  915. }
  916. };
  917. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  918. defaults.headers[method] = {};
  919. });
  920. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  921. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  922. });
  923. module.exports = defaults;
  924. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js")))
  925. /***/ }),
  926. /***/ "./node_modules/axios/lib/helpers/bind.js":
  927. /*!************************************************!*\
  928. !*** ./node_modules/axios/lib/helpers/bind.js ***!
  929. \************************************************/
  930. /*! no static exports found */
  931. /***/ (function(module, exports, __webpack_require__) {
  932. "use strict";
  933. module.exports = function bind(fn, thisArg) {
  934. return function wrap() {
  935. var args = new Array(arguments.length);
  936. for (var i = 0; i < args.length; i++) {
  937. args[i] = arguments[i];
  938. }
  939. return fn.apply(thisArg, args);
  940. };
  941. };
  942. /***/ }),
  943. /***/ "./node_modules/axios/lib/helpers/buildURL.js":
  944. /*!****************************************************!*\
  945. !*** ./node_modules/axios/lib/helpers/buildURL.js ***!
  946. \****************************************************/
  947. /*! no static exports found */
  948. /***/ (function(module, exports, __webpack_require__) {
  949. "use strict";
  950. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  951. function encode(val) {
  952. return encodeURIComponent(val).
  953. replace(/%3A/gi, ':').
  954. replace(/%24/g, '$').
  955. replace(/%2C/gi, ',').
  956. replace(/%20/g, '+').
  957. replace(/%5B/gi, '[').
  958. replace(/%5D/gi, ']');
  959. }
  960. /**
  961. * Build a URL by appending params to the end
  962. *
  963. * @param {string} url The base of the url (e.g., http://www.google.com)
  964. * @param {object} [params] The params to be appended
  965. * @returns {string} The formatted url
  966. */
  967. module.exports = function buildURL(url, params, paramsSerializer) {
  968. /*eslint no-param-reassign:0*/
  969. if (!params) {
  970. return url;
  971. }
  972. var serializedParams;
  973. if (paramsSerializer) {
  974. serializedParams = paramsSerializer(params);
  975. } else if (utils.isURLSearchParams(params)) {
  976. serializedParams = params.toString();
  977. } else {
  978. var parts = [];
  979. utils.forEach(params, function serialize(val, key) {
  980. if (val === null || typeof val === 'undefined') {
  981. return;
  982. }
  983. if (utils.isArray(val)) {
  984. key = key + '[]';
  985. } else {
  986. val = [val];
  987. }
  988. utils.forEach(val, function parseValue(v) {
  989. if (utils.isDate(v)) {
  990. v = v.toISOString();
  991. } else if (utils.isObject(v)) {
  992. v = JSON.stringify(v);
  993. }
  994. parts.push(encode(key) + '=' + encode(v));
  995. });
  996. });
  997. serializedParams = parts.join('&');
  998. }
  999. if (serializedParams) {
  1000. var hashmarkIndex = url.indexOf('#');
  1001. if (hashmarkIndex !== -1) {
  1002. url = url.slice(0, hashmarkIndex);
  1003. }
  1004. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  1005. }
  1006. return url;
  1007. };
  1008. /***/ }),
  1009. /***/ "./node_modules/axios/lib/helpers/combineURLs.js":
  1010. /*!*******************************************************!*\
  1011. !*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
  1012. \*******************************************************/
  1013. /*! no static exports found */
  1014. /***/ (function(module, exports, __webpack_require__) {
  1015. "use strict";
  1016. /**
  1017. * Creates a new URL by combining the specified URLs
  1018. *
  1019. * @param {string} baseURL The base URL
  1020. * @param {string} relativeURL The relative URL
  1021. * @returns {string} The combined URL
  1022. */
  1023. module.exports = function combineURLs(baseURL, relativeURL) {
  1024. return relativeURL
  1025. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1026. : baseURL;
  1027. };
  1028. /***/ }),
  1029. /***/ "./node_modules/axios/lib/helpers/cookies.js":
  1030. /*!***************************************************!*\
  1031. !*** ./node_modules/axios/lib/helpers/cookies.js ***!
  1032. \***************************************************/
  1033. /*! no static exports found */
  1034. /***/ (function(module, exports, __webpack_require__) {
  1035. "use strict";
  1036. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1037. module.exports = (
  1038. utils.isStandardBrowserEnv() ?
  1039. // Standard browser envs support document.cookie
  1040. (function standardBrowserEnv() {
  1041. return {
  1042. write: function write(name, value, expires, path, domain, secure) {
  1043. var cookie = [];
  1044. cookie.push(name + '=' + encodeURIComponent(value));
  1045. if (utils.isNumber(expires)) {
  1046. cookie.push('expires=' + new Date(expires).toGMTString());
  1047. }
  1048. if (utils.isString(path)) {
  1049. cookie.push('path=' + path);
  1050. }
  1051. if (utils.isString(domain)) {
  1052. cookie.push('domain=' + domain);
  1053. }
  1054. if (secure === true) {
  1055. cookie.push('secure');
  1056. }
  1057. document.cookie = cookie.join('; ');
  1058. },
  1059. read: function read(name) {
  1060. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1061. return (match ? decodeURIComponent(match[3]) : null);
  1062. },
  1063. remove: function remove(name) {
  1064. this.write(name, '', Date.now() - 86400000);
  1065. }
  1066. };
  1067. })() :
  1068. // Non standard browser env (web workers, react-native) lack needed support.
  1069. (function nonStandardBrowserEnv() {
  1070. return {
  1071. write: function write() {},
  1072. read: function read() { return null; },
  1073. remove: function remove() {}
  1074. };
  1075. })()
  1076. );
  1077. /***/ }),
  1078. /***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
  1079. /*!*********************************************************!*\
  1080. !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
  1081. \*********************************************************/
  1082. /*! no static exports found */
  1083. /***/ (function(module, exports, __webpack_require__) {
  1084. "use strict";
  1085. /**
  1086. * Determines whether the specified URL is absolute
  1087. *
  1088. * @param {string} url The URL to test
  1089. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1090. */
  1091. module.exports = function isAbsoluteURL(url) {
  1092. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1093. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1094. // by any combination of letters, digits, plus, period, or hyphen.
  1095. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  1096. };
  1097. /***/ }),
  1098. /***/ "./node_modules/axios/lib/helpers/isAxiosError.js":
  1099. /*!********************************************************!*\
  1100. !*** ./node_modules/axios/lib/helpers/isAxiosError.js ***!
  1101. \********************************************************/
  1102. /*! no static exports found */
  1103. /***/ (function(module, exports, __webpack_require__) {
  1104. "use strict";
  1105. /**
  1106. * Determines whether the payload is an error thrown by Axios
  1107. *
  1108. * @param {*} payload The value to test
  1109. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  1110. */
  1111. module.exports = function isAxiosError(payload) {
  1112. return (typeof payload === 'object') && (payload.isAxiosError === true);
  1113. };
  1114. /***/ }),
  1115. /***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
  1116. /*!***********************************************************!*\
  1117. !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
  1118. \***********************************************************/
  1119. /*! no static exports found */
  1120. /***/ (function(module, exports, __webpack_require__) {
  1121. "use strict";
  1122. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1123. module.exports = (
  1124. utils.isStandardBrowserEnv() ?
  1125. // Standard browser envs have full support of the APIs needed to test
  1126. // whether the request URL is of the same origin as current location.
  1127. (function standardBrowserEnv() {
  1128. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1129. var urlParsingNode = document.createElement('a');
  1130. var originURL;
  1131. /**
  1132. * Parse a URL to discover it's components
  1133. *
  1134. * @param {String} url The URL to be parsed
  1135. * @returns {Object}
  1136. */
  1137. function resolveURL(url) {
  1138. var href = url;
  1139. if (msie) {
  1140. // IE needs attribute set twice to normalize properties
  1141. urlParsingNode.setAttribute('href', href);
  1142. href = urlParsingNode.href;
  1143. }
  1144. urlParsingNode.setAttribute('href', href);
  1145. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1146. return {
  1147. href: urlParsingNode.href,
  1148. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1149. host: urlParsingNode.host,
  1150. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1151. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1152. hostname: urlParsingNode.hostname,
  1153. port: urlParsingNode.port,
  1154. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1155. urlParsingNode.pathname :
  1156. '/' + urlParsingNode.pathname
  1157. };
  1158. }
  1159. originURL = resolveURL(window.location.href);
  1160. /**
  1161. * Determine if a URL shares the same origin as the current location
  1162. *
  1163. * @param {String} requestURL The URL to test
  1164. * @returns {boolean} True if URL shares the same origin, otherwise false
  1165. */
  1166. return function isURLSameOrigin(requestURL) {
  1167. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1168. return (parsed.protocol === originURL.protocol &&
  1169. parsed.host === originURL.host);
  1170. };
  1171. })() :
  1172. // Non standard browser envs (web workers, react-native) lack needed support.
  1173. (function nonStandardBrowserEnv() {
  1174. return function isURLSameOrigin() {
  1175. return true;
  1176. };
  1177. })()
  1178. );
  1179. /***/ }),
  1180. /***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
  1181. /*!***************************************************************!*\
  1182. !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
  1183. \***************************************************************/
  1184. /*! no static exports found */
  1185. /***/ (function(module, exports, __webpack_require__) {
  1186. "use strict";
  1187. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  1188. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1189. utils.forEach(headers, function processHeader(value, name) {
  1190. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1191. headers[normalizedName] = value;
  1192. delete headers[name];
  1193. }
  1194. });
  1195. };
  1196. /***/ }),
  1197. /***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
  1198. /*!********************************************************!*\
  1199. !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
  1200. \********************************************************/
  1201. /*! no static exports found */
  1202. /***/ (function(module, exports, __webpack_require__) {
  1203. "use strict";
  1204. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1205. // Headers whose duplicates are ignored by node
  1206. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1207. var ignoreDuplicateOf = [
  1208. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1209. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1210. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1211. 'referer', 'retry-after', 'user-agent'
  1212. ];
  1213. /**
  1214. * Parse headers into an object
  1215. *
  1216. * ```
  1217. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1218. * Content-Type: application/json
  1219. * Connection: keep-alive
  1220. * Transfer-Encoding: chunked
  1221. * ```
  1222. *
  1223. * @param {String} headers Headers needing to be parsed
  1224. * @returns {Object} Headers parsed into an object
  1225. */
  1226. module.exports = function parseHeaders(headers) {
  1227. var parsed = {};
  1228. var key;
  1229. var val;
  1230. var i;
  1231. if (!headers) { return parsed; }
  1232. utils.forEach(headers.split('\n'), function parser(line) {
  1233. i = line.indexOf(':');
  1234. key = utils.trim(line.substr(0, i)).toLowerCase();
  1235. val = utils.trim(line.substr(i + 1));
  1236. if (key) {
  1237. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1238. return;
  1239. }
  1240. if (key === 'set-cookie') {
  1241. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1242. } else {
  1243. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1244. }
  1245. }
  1246. });
  1247. return parsed;
  1248. };
  1249. /***/ }),
  1250. /***/ "./node_modules/axios/lib/helpers/spread.js":
  1251. /*!**************************************************!*\
  1252. !*** ./node_modules/axios/lib/helpers/spread.js ***!
  1253. \**************************************************/
  1254. /*! no static exports found */
  1255. /***/ (function(module, exports, __webpack_require__) {
  1256. "use strict";
  1257. /**
  1258. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1259. *
  1260. * Common use case would be to use `Function.prototype.apply`.
  1261. *
  1262. * ```js
  1263. * function f(x, y, z) {}
  1264. * var args = [1, 2, 3];
  1265. * f.apply(null, args);
  1266. * ```
  1267. *
  1268. * With `spread` this example can be re-written.
  1269. *
  1270. * ```js
  1271. * spread(function(x, y, z) {})([1, 2, 3]);
  1272. * ```
  1273. *
  1274. * @param {Function} callback
  1275. * @returns {Function}
  1276. */
  1277. module.exports = function spread(callback) {
  1278. return function wrap(arr) {
  1279. return callback.apply(null, arr);
  1280. };
  1281. };
  1282. /***/ }),
  1283. /***/ "./node_modules/axios/lib/utils.js":
  1284. /*!*****************************************!*\
  1285. !*** ./node_modules/axios/lib/utils.js ***!
  1286. \*****************************************/
  1287. /*! no static exports found */
  1288. /***/ (function(module, exports, __webpack_require__) {
  1289. "use strict";
  1290. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  1291. /*global toString:true*/
  1292. // utils is a library of generic helper functions non-specific to axios
  1293. var toString = Object.prototype.toString;
  1294. /**
  1295. * Determine if a value is an Array
  1296. *
  1297. * @param {Object} val The value to test
  1298. * @returns {boolean} True if value is an Array, otherwise false
  1299. */
  1300. function isArray(val) {
  1301. return toString.call(val) === '[object Array]';
  1302. }
  1303. /**
  1304. * Determine if a value is undefined
  1305. *
  1306. * @param {Object} val The value to test
  1307. * @returns {boolean} True if the value is undefined, otherwise false
  1308. */
  1309. function isUndefined(val) {
  1310. return typeof val === 'undefined';
  1311. }
  1312. /**
  1313. * Determine if a value is a Buffer
  1314. *
  1315. * @param {Object} val The value to test
  1316. * @returns {boolean} True if value is a Buffer, otherwise false
  1317. */
  1318. function isBuffer(val) {
  1319. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  1320. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  1321. }
  1322. /**
  1323. * Determine if a value is an ArrayBuffer
  1324. *
  1325. * @param {Object} val The value to test
  1326. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1327. */
  1328. function isArrayBuffer(val) {
  1329. return toString.call(val) === '[object ArrayBuffer]';
  1330. }
  1331. /**
  1332. * Determine if a value is a FormData
  1333. *
  1334. * @param {Object} val The value to test
  1335. * @returns {boolean} True if value is an FormData, otherwise false
  1336. */
  1337. function isFormData(val) {
  1338. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  1339. }
  1340. /**
  1341. * Determine if a value is a view on an ArrayBuffer
  1342. *
  1343. * @param {Object} val The value to test
  1344. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1345. */
  1346. function isArrayBufferView(val) {
  1347. var result;
  1348. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1349. result = ArrayBuffer.isView(val);
  1350. } else {
  1351. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  1352. }
  1353. return result;
  1354. }
  1355. /**
  1356. * Determine if a value is a String
  1357. *
  1358. * @param {Object} val The value to test
  1359. * @returns {boolean} True if value is a String, otherwise false
  1360. */
  1361. function isString(val) {
  1362. return typeof val === 'string';
  1363. }
  1364. /**
  1365. * Determine if a value is a Number
  1366. *
  1367. * @param {Object} val The value to test
  1368. * @returns {boolean} True if value is a Number, otherwise false
  1369. */
  1370. function isNumber(val) {
  1371. return typeof val === 'number';
  1372. }
  1373. /**
  1374. * Determine if a value is an Object
  1375. *
  1376. * @param {Object} val The value to test
  1377. * @returns {boolean} True if value is an Object, otherwise false
  1378. */
  1379. function isObject(val) {
  1380. return val !== null && typeof val === 'object';
  1381. }
  1382. /**
  1383. * Determine if a value is a plain Object
  1384. *
  1385. * @param {Object} val The value to test
  1386. * @return {boolean} True if value is a plain Object, otherwise false
  1387. */
  1388. function isPlainObject(val) {
  1389. if (toString.call(val) !== '[object Object]') {
  1390. return false;
  1391. }
  1392. var prototype = Object.getPrototypeOf(val);
  1393. return prototype === null || prototype === Object.prototype;
  1394. }
  1395. /**
  1396. * Determine if a value is a Date
  1397. *
  1398. * @param {Object} val The value to test
  1399. * @returns {boolean} True if value is a Date, otherwise false
  1400. */
  1401. function isDate(val) {
  1402. return toString.call(val) === '[object Date]';
  1403. }
  1404. /**
  1405. * Determine if a value is a File
  1406. *
  1407. * @param {Object} val The value to test
  1408. * @returns {boolean} True if value is a File, otherwise false
  1409. */
  1410. function isFile(val) {
  1411. return toString.call(val) === '[object File]';
  1412. }
  1413. /**
  1414. * Determine if a value is a Blob
  1415. *
  1416. * @param {Object} val The value to test
  1417. * @returns {boolean} True if value is a Blob, otherwise false
  1418. */
  1419. function isBlob(val) {
  1420. return toString.call(val) === '[object Blob]';
  1421. }
  1422. /**
  1423. * Determine if a value is a Function
  1424. *
  1425. * @param {Object} val The value to test
  1426. * @returns {boolean} True if value is a Function, otherwise false
  1427. */
  1428. function isFunction(val) {
  1429. return toString.call(val) === '[object Function]';
  1430. }
  1431. /**
  1432. * Determine if a value is a Stream
  1433. *
  1434. * @param {Object} val The value to test
  1435. * @returns {boolean} True if value is a Stream, otherwise false
  1436. */
  1437. function isStream(val) {
  1438. return isObject(val) && isFunction(val.pipe);
  1439. }
  1440. /**
  1441. * Determine if a value is a URLSearchParams object
  1442. *
  1443. * @param {Object} val The value to test
  1444. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1445. */
  1446. function isURLSearchParams(val) {
  1447. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  1448. }
  1449. /**
  1450. * Trim excess whitespace off the beginning and end of a string
  1451. *
  1452. * @param {String} str The String to trim
  1453. * @returns {String} The String freed of excess whitespace
  1454. */
  1455. function trim(str) {
  1456. return str.replace(/^\s*/, '').replace(/\s*$/, '');
  1457. }
  1458. /**
  1459. * Determine if we're running in a standard browser environment
  1460. *
  1461. * This allows axios to run in a web worker, and react-native.
  1462. * Both environments support XMLHttpRequest, but not fully standard globals.
  1463. *
  1464. * web workers:
  1465. * typeof window -> undefined
  1466. * typeof document -> undefined
  1467. *
  1468. * react-native:
  1469. * navigator.product -> 'ReactNative'
  1470. * nativescript
  1471. * navigator.product -> 'NativeScript' or 'NS'
  1472. */
  1473. function isStandardBrowserEnv() {
  1474. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1475. navigator.product === 'NativeScript' ||
  1476. navigator.product === 'NS')) {
  1477. return false;
  1478. }
  1479. return (
  1480. typeof window !== 'undefined' &&
  1481. typeof document !== 'undefined'
  1482. );
  1483. }
  1484. /**
  1485. * Iterate over an Array or an Object invoking a function for each item.
  1486. *
  1487. * If `obj` is an Array callback will be called passing
  1488. * the value, index, and complete array for each item.
  1489. *
  1490. * If 'obj' is an Object callback will be called passing
  1491. * the value, key, and complete object for each property.
  1492. *
  1493. * @param {Object|Array} obj The object to iterate
  1494. * @param {Function} fn The callback to invoke for each item
  1495. */
  1496. function forEach(obj, fn) {
  1497. // Don't bother if no value provided
  1498. if (obj === null || typeof obj === 'undefined') {
  1499. return;
  1500. }
  1501. // Force an array if not already something iterable
  1502. if (typeof obj !== 'object') {
  1503. /*eslint no-param-reassign:0*/
  1504. obj = [obj];
  1505. }
  1506. if (isArray(obj)) {
  1507. // Iterate over array values
  1508. for (var i = 0, l = obj.length; i < l; i++) {
  1509. fn.call(null, obj[i], i, obj);
  1510. }
  1511. } else {
  1512. // Iterate over object keys
  1513. for (var key in obj) {
  1514. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1515. fn.call(null, obj[key], key, obj);
  1516. }
  1517. }
  1518. }
  1519. }
  1520. /**
  1521. * Accepts varargs expecting each argument to be an object, then
  1522. * immutably merges the properties of each object and returns result.
  1523. *
  1524. * When multiple objects contain the same key the later object in
  1525. * the arguments list will take precedence.
  1526. *
  1527. * Example:
  1528. *
  1529. * ```js
  1530. * var result = merge({foo: 123}, {foo: 456});
  1531. * console.log(result.foo); // outputs 456
  1532. * ```
  1533. *
  1534. * @param {Object} obj1 Object to merge
  1535. * @returns {Object} Result of all merge properties
  1536. */
  1537. function merge(/* obj1, obj2, obj3, ... */) {
  1538. var result = {};
  1539. function assignValue(val, key) {
  1540. if (isPlainObject(result[key]) && isPlainObject(val)) {
  1541. result[key] = merge(result[key], val);
  1542. } else if (isPlainObject(val)) {
  1543. result[key] = merge({}, val);
  1544. } else if (isArray(val)) {
  1545. result[key] = val.slice();
  1546. } else {
  1547. result[key] = val;
  1548. }
  1549. }
  1550. for (var i = 0, l = arguments.length; i < l; i++) {
  1551. forEach(arguments[i], assignValue);
  1552. }
  1553. return result;
  1554. }
  1555. /**
  1556. * Extends object a by mutably adding to it the properties of object b.
  1557. *
  1558. * @param {Object} a The object to be extended
  1559. * @param {Object} b The object to copy properties from
  1560. * @param {Object} thisArg The object to bind function to
  1561. * @return {Object} The resulting value of object a
  1562. */
  1563. function extend(a, b, thisArg) {
  1564. forEach(b, function assignValue(val, key) {
  1565. if (thisArg && typeof val === 'function') {
  1566. a[key] = bind(val, thisArg);
  1567. } else {
  1568. a[key] = val;
  1569. }
  1570. });
  1571. return a;
  1572. }
  1573. /**
  1574. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  1575. *
  1576. * @param {string} content with BOM
  1577. * @return {string} content value without BOM
  1578. */
  1579. function stripBOM(content) {
  1580. if (content.charCodeAt(0) === 0xFEFF) {
  1581. content = content.slice(1);
  1582. }
  1583. return content;
  1584. }
  1585. module.exports = {
  1586. isArray: isArray,
  1587. isArrayBuffer: isArrayBuffer,
  1588. isBuffer: isBuffer,
  1589. isFormData: isFormData,
  1590. isArrayBufferView: isArrayBufferView,
  1591. isString: isString,
  1592. isNumber: isNumber,
  1593. isObject: isObject,
  1594. isPlainObject: isPlainObject,
  1595. isUndefined: isUndefined,
  1596. isDate: isDate,
  1597. isFile: isFile,
  1598. isBlob: isBlob,
  1599. isFunction: isFunction,
  1600. isStream: isStream,
  1601. isURLSearchParams: isURLSearchParams,
  1602. isStandardBrowserEnv: isStandardBrowserEnv,
  1603. forEach: forEach,
  1604. merge: merge,
  1605. extend: extend,
  1606. trim: trim,
  1607. stripBOM: stripBOM
  1608. };
  1609. /***/ }),
  1610. /***/ "./node_modules/process/browser.js":
  1611. /*!*****************************************!*\
  1612. !*** ./node_modules/process/browser.js ***!
  1613. \*****************************************/
  1614. /*! no static exports found */
  1615. /***/ (function(module, exports) {
  1616. // shim for using process in browser
  1617. var process = module.exports = {};
  1618. // cached from whatever global is present so that test runners that stub it
  1619. // don't break things. But we need to wrap it in a try catch in case it is
  1620. // wrapped in strict mode code which doesn't define any globals. It's inside a
  1621. // function because try/catches deoptimize in certain engines.
  1622. var cachedSetTimeout;
  1623. var cachedClearTimeout;
  1624. function defaultSetTimout() {
  1625. throw new Error('setTimeout has not been defined');
  1626. }
  1627. function defaultClearTimeout () {
  1628. throw new Error('clearTimeout has not been defined');
  1629. }
  1630. (function () {
  1631. try {
  1632. if (typeof setTimeout === 'function') {
  1633. cachedSetTimeout = setTimeout;
  1634. } else {
  1635. cachedSetTimeout = defaultSetTimout;
  1636. }
  1637. } catch (e) {
  1638. cachedSetTimeout = defaultSetTimout;
  1639. }
  1640. try {
  1641. if (typeof clearTimeout === 'function') {
  1642. cachedClearTimeout = clearTimeout;
  1643. } else {
  1644. cachedClearTimeout = defaultClearTimeout;
  1645. }
  1646. } catch (e) {
  1647. cachedClearTimeout = defaultClearTimeout;
  1648. }
  1649. } ())
  1650. function runTimeout(fun) {
  1651. if (cachedSetTimeout === setTimeout) {
  1652. //normal enviroments in sane situations
  1653. return setTimeout(fun, 0);
  1654. }
  1655. // if setTimeout wasn't available but was latter defined
  1656. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  1657. cachedSetTimeout = setTimeout;
  1658. return setTimeout(fun, 0);
  1659. }
  1660. try {
  1661. // when when somebody has screwed with setTimeout but no I.E. maddness
  1662. return cachedSetTimeout(fun, 0);
  1663. } catch(e){
  1664. try {
  1665. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  1666. return cachedSetTimeout.call(null, fun, 0);
  1667. } catch(e){
  1668. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  1669. return cachedSetTimeout.call(this, fun, 0);
  1670. }
  1671. }
  1672. }
  1673. function runClearTimeout(marker) {
  1674. if (cachedClearTimeout === clearTimeout) {
  1675. //normal enviroments in sane situations
  1676. return clearTimeout(marker);
  1677. }
  1678. // if clearTimeout wasn't available but was latter defined
  1679. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  1680. cachedClearTimeout = clearTimeout;
  1681. return clearTimeout(marker);
  1682. }
  1683. try {
  1684. // when when somebody has screwed with setTimeout but no I.E. maddness
  1685. return cachedClearTimeout(marker);
  1686. } catch (e){
  1687. try {
  1688. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  1689. return cachedClearTimeout.call(null, marker);
  1690. } catch (e){
  1691. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  1692. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  1693. return cachedClearTimeout.call(this, marker);
  1694. }
  1695. }
  1696. }
  1697. var queue = [];
  1698. var draining = false;
  1699. var currentQueue;
  1700. var queueIndex = -1;
  1701. function cleanUpNextTick() {
  1702. if (!draining || !currentQueue) {
  1703. return;
  1704. }
  1705. draining = false;
  1706. if (currentQueue.length) {
  1707. queue = currentQueue.concat(queue);
  1708. } else {
  1709. queueIndex = -1;
  1710. }
  1711. if (queue.length) {
  1712. drainQueue();
  1713. }
  1714. }
  1715. function drainQueue() {
  1716. if (draining) {
  1717. return;
  1718. }
  1719. var timeout = runTimeout(cleanUpNextTick);
  1720. draining = true;
  1721. var len = queue.length;
  1722. while(len) {
  1723. currentQueue = queue;
  1724. queue = [];
  1725. while (++queueIndex < len) {
  1726. if (currentQueue) {
  1727. currentQueue[queueIndex].run();
  1728. }
  1729. }
  1730. queueIndex = -1;
  1731. len = queue.length;
  1732. }
  1733. currentQueue = null;
  1734. draining = false;
  1735. runClearTimeout(timeout);
  1736. }
  1737. process.nextTick = function (fun) {
  1738. var args = new Array(arguments.length - 1);
  1739. if (arguments.length > 1) {
  1740. for (var i = 1; i < arguments.length; i++) {
  1741. args[i - 1] = arguments[i];
  1742. }
  1743. }
  1744. queue.push(new Item(fun, args));
  1745. if (queue.length === 1 && !draining) {
  1746. runTimeout(drainQueue);
  1747. }
  1748. };
  1749. // v8 likes predictible objects
  1750. function Item(fun, array) {
  1751. this.fun = fun;
  1752. this.array = array;
  1753. }
  1754. Item.prototype.run = function () {
  1755. this.fun.apply(null, this.array);
  1756. };
  1757. process.title = 'browser';
  1758. process.browser = true;
  1759. process.env = {};
  1760. process.argv = [];
  1761. process.version = ''; // empty string to avoid regexp issues
  1762. process.versions = {};
  1763. function noop() {}
  1764. process.on = noop;
  1765. process.addListener = noop;
  1766. process.once = noop;
  1767. process.off = noop;
  1768. process.removeListener = noop;
  1769. process.removeAllListeners = noop;
  1770. process.emit = noop;
  1771. process.prependListener = noop;
  1772. process.prependOnceListener = noop;
  1773. process.listeners = function (name) { return [] }
  1774. process.binding = function (name) {
  1775. throw new Error('process.binding is not supported');
  1776. };
  1777. process.cwd = function () { return '/' };
  1778. process.chdir = function (dir) {
  1779. throw new Error('process.chdir is not supported');
  1780. };
  1781. process.umask = function() { return 0; };
  1782. /***/ }),
  1783. /***/ "./node_modules/riot/riot.esm.js":
  1784. /*!***************************************!*\
  1785. !*** ./node_modules/riot/riot.esm.js ***!
  1786. \***************************************/
  1787. /*! exports provided: __, component, install, mount, pure, register, uninstall, unmount, unregister, version */
  1788. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1789. "use strict";
  1790. __webpack_require__.r(__webpack_exports__);
  1791. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__", function() { return __; });
  1792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "component", function() { return component; });
  1793. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "install", function() { return install; });
  1794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mount", function() { return mount; });
  1795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pure", function() { return pure; });
  1796. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "register", function() { return register; });
  1797. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "uninstall", function() { return uninstall; });
  1798. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "unmount", function() { return unmount; });
  1799. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "unregister", function() { return unregister; });
  1800. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "version", function() { return version; });
  1801. /* Riot v5.1.1, @license MIT */
  1802. /**
  1803. * Convert a string from camel case to dash-case
  1804. * @param {string} string - probably a component tag name
  1805. * @returns {string} component name normalized
  1806. */
  1807. function camelToDashCase(string) {
  1808. return string.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
  1809. }
  1810. /**
  1811. * Convert a string containing dashes to camel case
  1812. * @param {string} string - input string
  1813. * @returns {string} my-string -> myString
  1814. */
  1815. function dashToCamelCase(string) {
  1816. return string.replace(/-(\w)/g, (_, c) => c.toUpperCase());
  1817. }
  1818. /**
  1819. * Get all the element attributes as object
  1820. * @param {HTMLElement} element - DOM node we want to parse
  1821. * @returns {Object} all the attributes found as a key value pairs
  1822. */
  1823. function DOMattributesToObject(element) {
  1824. return Array.from(element.attributes).reduce((acc, attribute) => {
  1825. acc[dashToCamelCase(attribute.name)] = attribute.value;
  1826. return acc;
  1827. }, {});
  1828. }
  1829. /**
  1830. * Move all the child nodes from a source tag to another
  1831. * @param {HTMLElement} source - source node
  1832. * @param {HTMLElement} target - target node
  1833. * @returns {undefined} it's a void method ¯\_()_/¯
  1834. */
  1835. // Ignore this helper because it's needed only for svg tags
  1836. function moveChildren(source, target) {
  1837. if (source.firstChild) {
  1838. target.appendChild(source.firstChild);
  1839. moveChildren(source, target);
  1840. }
  1841. }
  1842. /**
  1843. * Remove the child nodes from any DOM node
  1844. * @param {HTMLElement} node - target node
  1845. * @returns {undefined}
  1846. */
  1847. function cleanNode(node) {
  1848. clearChildren(node.childNodes);
  1849. }
  1850. /**
  1851. * Clear multiple children in a node
  1852. * @param {HTMLElement[]} children - direct children nodes
  1853. * @returns {undefined}
  1854. */
  1855. function clearChildren(children) {
  1856. Array.from(children).forEach(removeChild);
  1857. }
  1858. /**
  1859. * Remove a node
  1860. * @param {HTMLElement}node - node to remove
  1861. * @returns {undefined}
  1862. */
  1863. const removeChild = node => node && node.parentNode && node.parentNode.removeChild(node);
  1864. /**
  1865. * Insert before a node
  1866. * @param {HTMLElement} newNode - node to insert
  1867. * @param {HTMLElement} refNode - ref child
  1868. * @returns {undefined}
  1869. */
  1870. const insertBefore = (newNode, refNode) => refNode && refNode.parentNode && refNode.parentNode.insertBefore(newNode, refNode);
  1871. /**
  1872. * Replace a node
  1873. * @param {HTMLElement} newNode - new node to add to the DOM
  1874. * @param {HTMLElement} replaced - node to replace
  1875. * @returns {undefined}
  1876. */
  1877. const replaceChild = (newNode, replaced) => replaced && replaced.parentNode && replaced.parentNode.replaceChild(newNode, replaced);
  1878. const EACH = 0;
  1879. const IF = 1;
  1880. const SIMPLE = 2;
  1881. const TAG = 3;
  1882. const SLOT = 4;
  1883. var bindingTypes = {
  1884. EACH,
  1885. IF,
  1886. SIMPLE,
  1887. TAG,
  1888. SLOT
  1889. };
  1890. const ATTRIBUTE = 0;
  1891. const EVENT = 1;
  1892. const TEXT = 2;
  1893. const VALUE = 3;
  1894. var expressionTypes = {
  1895. ATTRIBUTE,
  1896. EVENT,
  1897. TEXT,
  1898. VALUE
  1899. };
  1900. /**
  1901. * Create the template meta object in case of <template> fragments
  1902. * @param {TemplateChunk} componentTemplate - template chunk object
  1903. * @returns {Object} the meta property that will be passed to the mount function of the TemplateChunk
  1904. */
  1905. function createTemplateMeta(componentTemplate) {
  1906. const fragment = componentTemplate.dom.cloneNode(true);
  1907. return {
  1908. avoidDOMInjection: true,
  1909. fragment,
  1910. children: Array.from(fragment.childNodes)
  1911. };
  1912. }
  1913. /**
  1914. * Quick type checking
  1915. * @param {*} element - anything
  1916. * @param {string} type - type definition
  1917. * @returns {boolean} true if the type corresponds
  1918. */
  1919. function checkType(element, type) {
  1920. return typeof element === type;
  1921. }
  1922. /**
  1923. * Check if an element is part of an svg
  1924. * @param {HTMLElement} el - element to check
  1925. * @returns {boolean} true if we are in an svg context
  1926. */
  1927. function isSvg(el) {
  1928. const owner = el.ownerSVGElement;
  1929. return !!owner || owner === null;
  1930. }
  1931. /**
  1932. * Check if an element is a template tag
  1933. * @param {HTMLElement} el - element to check
  1934. * @returns {boolean} true if it's a <template>
  1935. */
  1936. function isTemplate(el) {
  1937. return !isNil(el.content);
  1938. }
  1939. /**
  1940. * Check that will be passed if its argument is a function
  1941. * @param {*} value - value to check
  1942. * @returns {boolean} - true if the value is a function
  1943. */
  1944. function isFunction(value) {
  1945. return checkType(value, 'function');
  1946. }
  1947. /**
  1948. * Check if a value is a Boolean
  1949. * @param {*} value - anything
  1950. * @returns {boolean} true only for the value is a boolean
  1951. */
  1952. function isBoolean(value) {
  1953. return checkType(value, 'boolean');
  1954. }
  1955. /**
  1956. * Check if a value is an Object
  1957. * @param {*} value - anything
  1958. * @returns {boolean} true only for the value is an object
  1959. */
  1960. function isObject(value) {
  1961. return !isNil(value) && checkType(value, 'object');
  1962. }
  1963. /**
  1964. * Check if a value is null or undefined
  1965. * @param {*} value - anything
  1966. * @returns {boolean} true only for the 'undefined' and 'null' types
  1967. */
  1968. function isNil(value) {
  1969. return value === null || value === undefined;
  1970. }
  1971. /**
  1972. * ISC License
  1973. *
  1974. * Copyright (c) 2020, Andrea Giammarchi, @WebReflection
  1975. *
  1976. * Permission to use, copy, modify, and/or distribute this software for any
  1977. * purpose with or without fee is hereby granted, provided that the above
  1978. * copyright notice and this permission notice appear in all copies.
  1979. *
  1980. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  1981. * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  1982. * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  1983. * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  1984. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  1985. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1986. * PERFORMANCE OF THIS SOFTWARE.
  1987. */
  1988. // fork of https://github.com/WebReflection/udomdiff version 1.1.0
  1989. // due to https://github.com/WebReflection/udomdiff/pull/2
  1990. /* eslint-disable */
  1991. /**
  1992. * @param {Node} parentNode The container where children live
  1993. * @param {Node[]} a The list of current/live children
  1994. * @param {Node[]} b The list of future children
  1995. * @param {(entry: Node, action: number) => Node} get
  1996. * The callback invoked per each entry related DOM operation.
  1997. * @param {Node} [before] The optional node used as anchor to insert before.
  1998. * @returns {Node[]} The same list of future children.
  1999. */
  2000. var udomdiff = ((parentNode, a, b, get, before) => {
  2001. const bLength = b.length;
  2002. let aEnd = a.length;
  2003. let bEnd = bLength;
  2004. let aStart = 0;
  2005. let bStart = 0;
  2006. let map = null;
  2007. while (aStart < aEnd || bStart < bEnd) {
  2008. // append head, tail, or nodes in between: fast path
  2009. if (aEnd === aStart) {
  2010. // we could be in a situation where the rest of nodes that
  2011. // need to be added are not at the end, and in such case
  2012. // the node to `insertBefore`, if the index is more than 0
  2013. // must be retrieved, otherwise it's gonna be the first item.
  2014. const node = bEnd < bLength ? bStart ? get(b[bStart - 1], -0).nextSibling : get(b[bEnd - bStart], 0) : before;
  2015. while (bStart < bEnd) insertBefore(get(b[bStart++], 1), node);
  2016. } // remove head or tail: fast path
  2017. else if (bEnd === bStart) {
  2018. while (aStart < aEnd) {
  2019. // remove the node only if it's unknown or not live
  2020. if (!map || !map.has(a[aStart])) removeChild(get(a[aStart], -1));
  2021. aStart++;
  2022. }
  2023. } // same node: fast path
  2024. else if (a[aStart] === b[bStart]) {
  2025. aStart++;
  2026. bStart++;
  2027. } // same tail: fast path
  2028. else if (a[aEnd - 1] === b[bEnd - 1]) {
  2029. aEnd--;
  2030. bEnd--;
  2031. } // The once here single last swap "fast path" has been removed in v1.1.0
  2032. // https://github.com/WebReflection/udomdiff/blob/single-final-swap/esm/index.js#L69-L85
  2033. // reverse swap: also fast path
  2034. else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
  2035. // this is a "shrink" operation that could happen in these cases:
  2036. // [1, 2, 3, 4, 5]
  2037. // [1, 4, 3, 2, 5]
  2038. // or asymmetric too
  2039. // [1, 2, 3, 4, 5]
  2040. // [1, 2, 3, 5, 6, 4]
  2041. const node = get(a[--aEnd], -1).nextSibling;
  2042. insertBefore(get(b[bStart++], 1), get(a[aStart++], -1).nextSibling);
  2043. insertBefore(get(b[--bEnd], 1), node); // mark the future index as identical (yeah, it's dirty, but cheap 👍)
  2044. // The main reason to do this, is that when a[aEnd] will be reached,
  2045. // the loop will likely be on the fast path, as identical to b[bEnd].
  2046. // In the best case scenario, the next loop will skip the tail,
  2047. // but in the worst one, this node will be considered as already
  2048. // processed, bailing out pretty quickly from the map index check
  2049. a[aEnd] = b[bEnd];
  2050. } // map based fallback, "slow" path
  2051. else {
  2052. // the map requires an O(bEnd - bStart) operation once
  2053. // to store all future nodes indexes for later purposes.
  2054. // In the worst case scenario, this is a full O(N) cost,
  2055. // and such scenario happens at least when all nodes are different,
  2056. // but also if both first and last items of the lists are different
  2057. if (!map) {
  2058. map = new Map();
  2059. let i = bStart;
  2060. while (i < bEnd) map.set(b[i], i++);
  2061. } // if it's a future node, hence it needs some handling
  2062. if (map.has(a[aStart])) {
  2063. // grab the index of such node, 'cause it might have been processed
  2064. const index = map.get(a[aStart]); // if it's not already processed, look on demand for the next LCS
  2065. if (bStart < index && index < bEnd) {
  2066. let i = aStart; // counts the amount of nodes that are the same in the future
  2067. let sequence = 1;
  2068. while (++i < aEnd && i < bEnd && map.get(a[i]) === index + sequence) sequence++; // effort decision here: if the sequence is longer than replaces
  2069. // needed to reach such sequence, which would brings again this loop
  2070. // to the fast path, prepend the difference before a sequence,
  2071. // and move only the future list index forward, so that aStart
  2072. // and bStart will be aligned again, hence on the fast path.
  2073. // An example considering aStart and bStart are both 0:
  2074. // a: [1, 2, 3, 4]
  2075. // b: [7, 1, 2, 3, 6]
  2076. // this would place 7 before 1 and, from that time on, 1, 2, and 3
  2077. // will be processed at zero cost
  2078. if (sequence > index - bStart) {
  2079. const node = get(a[aStart], 0);
  2080. while (bStart < index) insertBefore(get(b[bStart++], 1), node);
  2081. } // if the effort wasn't good enough, fallback to a replace,
  2082. // moving both source and target indexes forward, hoping that some
  2083. // similar node will be found later on, to go back to the fast path
  2084. else {
  2085. replaceChild(get(b[bStart++], 1), get(a[aStart++], -1));
  2086. }
  2087. } // otherwise move the source forward, 'cause there's nothing to do
  2088. else aStart++;
  2089. } // this node has no meaning in the future list, so it's more than safe
  2090. // to remove it, and check the next live node out instead, meaning
  2091. // that only the live list index should be forwarded
  2092. else removeChild(get(a[aStart++], -1));
  2093. }
  2094. }
  2095. return b;
  2096. });
  2097. const UNMOUNT_SCOPE = Symbol('unmount');
  2098. const EachBinding = {
  2099. // dynamic binding properties
  2100. // childrenMap: null,
  2101. // node: null,
  2102. // root: null,
  2103. // condition: null,
  2104. // evaluate: null,
  2105. // template: null,
  2106. // isTemplateTag: false,
  2107. nodes: [],
  2108. // getKey: null,
  2109. // indexName: null,
  2110. // itemName: null,
  2111. // afterPlaceholder: null,
  2112. // placeholder: null,
  2113. // API methods
  2114. mount(scope, parentScope) {
  2115. return this.update(scope, parentScope);
  2116. },
  2117. update(scope, parentScope) {
  2118. const {
  2119. placeholder,
  2120. nodes,
  2121. childrenMap
  2122. } = this;
  2123. const collection = scope === UNMOUNT_SCOPE ? null : this.evaluate(scope);
  2124. const items = collection ? Array.from(collection) : [];
  2125. const parent = placeholder.parentNode; // prepare the diffing
  2126. const {
  2127. newChildrenMap,
  2128. batches,
  2129. futureNodes
  2130. } = createPatch(items, scope, parentScope, this); // patch the DOM only if there are new nodes
  2131. udomdiff(parent, nodes, futureNodes, patch(Array.from(childrenMap.values()), parentScope), placeholder); // trigger the mounts and the updates
  2132. batches.forEach(fn => fn()); // update the children map
  2133. this.childrenMap = newChildrenMap;
  2134. this.nodes = futureNodes;
  2135. return this;
  2136. },
  2137. unmount(scope, parentScope) {
  2138. this.update(UNMOUNT_SCOPE, parentScope);
  2139. return this;
  2140. }
  2141. };
  2142. /**
  2143. * Patch the DOM while diffing
  2144. * @param {TemplateChunk[]} redundant - redundant tepmplate chunks
  2145. * @param {*} parentScope - scope of the parent template
  2146. * @returns {Function} patch function used by domdiff
  2147. */
  2148. function patch(redundant, parentScope) {
  2149. return (item, info) => {
  2150. if (info < 0) {
  2151. const element = redundant.pop();
  2152. if (element) {
  2153. const {
  2154. template,
  2155. context
  2156. } = element; // notice that we pass null as last argument because
  2157. // the root node and its children will be removed by domdiff
  2158. template.unmount(context, parentScope, null);
  2159. }
  2160. }
  2161. return item;
  2162. };
  2163. }
  2164. /**
  2165. * Check whether a template must be filtered from a loop
  2166. * @param {Function} condition - filter function
  2167. * @param {Object} context - argument passed to the filter function
  2168. * @returns {boolean} true if this item should be skipped
  2169. */
  2170. function mustFilterItem(condition, context) {
  2171. return condition ? Boolean(condition(context)) === false : false;
  2172. }
  2173. /**
  2174. * Extend the scope of the looped template
  2175. * @param {Object} scope - current template scope
  2176. * @param {string} options.itemName - key to identify the looped item in the new context
  2177. * @param {string} options.indexName - key to identify the index of the looped item
  2178. * @param {number} options.index - current index
  2179. * @param {*} options.item - collection item looped
  2180. * @returns {Object} enhanced scope object
  2181. */
  2182. function extendScope(scope, _ref) {
  2183. let {
  2184. itemName,
  2185. indexName,
  2186. index,
  2187. item
  2188. } = _ref;
  2189. scope[itemName] = item;
  2190. if (indexName) scope[indexName] = index;
  2191. return scope;
  2192. }
  2193. /**
  2194. * Loop the current template items
  2195. * @param {Array} items - expression collection value
  2196. * @param {*} scope - template scope
  2197. * @param {*} parentScope - scope of the parent template
  2198. * @param {EeachBinding} binding - each binding object instance
  2199. * @returns {Object} data
  2200. * @returns {Map} data.newChildrenMap - a Map containing the new children template structure
  2201. * @returns {Array} data.batches - array containing the template lifecycle functions to trigger
  2202. * @returns {Array} data.futureNodes - array containing the nodes we need to diff
  2203. */
  2204. function createPatch(items, scope, parentScope, binding) {
  2205. const {
  2206. condition,
  2207. template,
  2208. childrenMap,
  2209. itemName,
  2210. getKey,
  2211. indexName,
  2212. root,
  2213. isTemplateTag
  2214. } = binding;
  2215. const newChildrenMap = new Map();
  2216. const batches = [];
  2217. const futureNodes = [];
  2218. items.forEach((item, index) => {
  2219. const context = extendScope(Object.create(scope), {
  2220. itemName,
  2221. indexName,
  2222. index,
  2223. item
  2224. });
  2225. const key = getKey ? getKey(context) : index;
  2226. const oldItem = childrenMap.get(key);
  2227. if (mustFilterItem(condition, context)) {
  2228. return;
  2229. }
  2230. const componentTemplate = oldItem ? oldItem.template : template.clone();
  2231. const el = oldItem ? componentTemplate.el : root.cloneNode();
  2232. const mustMount = !oldItem;
  2233. const meta = isTemplateTag && mustMount ? createTemplateMeta(componentTemplate) : {};
  2234. if (mustMount) {
  2235. batches.push(() => componentTemplate.mount(el, context, parentScope, meta));
  2236. } else {
  2237. batches.push(() => componentTemplate.update(context, parentScope));
  2238. } // create the collection of nodes to update or to add
  2239. // in case of template tags we need to add all its children nodes
  2240. if (isTemplateTag) {
  2241. const children = meta.children || componentTemplate.children;
  2242. futureNodes.push(...children);
  2243. } else {
  2244. futureNodes.push(el);
  2245. } // delete the old item from the children map
  2246. childrenMap.delete(key); // update the children map
  2247. newChildrenMap.set(key, {
  2248. template: componentTemplate,
  2249. context,
  2250. index
  2251. });
  2252. });
  2253. return {
  2254. newChildrenMap,
  2255. batches,
  2256. futureNodes
  2257. };
  2258. }
  2259. function create(node, _ref2) {
  2260. let {
  2261. evaluate,
  2262. condition,
  2263. itemName,
  2264. indexName,
  2265. getKey,
  2266. template
  2267. } = _ref2;
  2268. const placeholder = document.createTextNode('');
  2269. const root = node.cloneNode();
  2270. insertBefore(placeholder, node);
  2271. removeChild(node);
  2272. return Object.assign({}, EachBinding, {
  2273. childrenMap: new Map(),
  2274. node,
  2275. root,
  2276. condition,
  2277. evaluate,
  2278. isTemplateTag: isTemplate(root),
  2279. template: template.createDOM(node),
  2280. getKey,
  2281. indexName,
  2282. itemName,
  2283. placeholder
  2284. });
  2285. }
  2286. /**
  2287. * Binding responsible for the `if` directive
  2288. */
  2289. const IfBinding = {
  2290. // dynamic binding properties
  2291. // node: null,
  2292. // evaluate: null,
  2293. // isTemplateTag: false,
  2294. // placeholder: null,
  2295. // template: null,
  2296. // API methods
  2297. mount(scope, parentScope) {
  2298. return this.update(scope, parentScope);
  2299. },
  2300. update(scope, parentScope) {
  2301. const value = !!this.evaluate(scope);
  2302. const mustMount = !this.value && value;
  2303. const mustUnmount = this.value && !value;
  2304. const mount = () => {
  2305. const pristine = this.node.cloneNode();
  2306. insertBefore(pristine, this.placeholder);
  2307. this.template = this.template.clone();
  2308. this.template.mount(pristine, scope, parentScope);
  2309. };
  2310. switch (true) {
  2311. case mustMount:
  2312. mount();
  2313. break;
  2314. case mustUnmount:
  2315. this.unmount(scope);
  2316. break;
  2317. default:
  2318. if (value) this.template.update(scope, parentScope);
  2319. }
  2320. this.value = value;
  2321. return this;
  2322. },
  2323. unmount(scope, parentScope) {
  2324. this.template.unmount(scope, parentScope, true);
  2325. return this;
  2326. }
  2327. };
  2328. function create$1(node, _ref) {
  2329. let {
  2330. evaluate,
  2331. template
  2332. } = _ref;
  2333. const placeholder = document.createTextNode('');
  2334. insertBefore(placeholder, node);
  2335. removeChild(node);
  2336. return Object.assign({}, IfBinding, {
  2337. node,
  2338. evaluate,
  2339. placeholder,
  2340. template: template.createDOM(node)
  2341. });
  2342. }
  2343. /**
  2344. * Throw an error with a descriptive message
  2345. * @param { string } message - error message
  2346. * @returns { undefined } hoppla.. at this point the program should stop working
  2347. */
  2348. function panic(message) {
  2349. throw new Error(message);
  2350. }
  2351. /**
  2352. * Returns the memoized (cached) function.
  2353. * // borrowed from https://www.30secondsofcode.org/js/s/memoize
  2354. * @param {Function} fn - function to memoize
  2355. * @returns {Function} memoize function
  2356. */
  2357. function memoize(fn) {
  2358. const cache = new Map();
  2359. const cached = val => {
  2360. return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val);
  2361. };
  2362. cached.cache = cache;
  2363. return cached;
  2364. }
  2365. /**
  2366. * Evaluate a list of attribute expressions
  2367. * @param {Array} attributes - attribute expressions generated by the riot compiler
  2368. * @returns {Object} key value pairs with the result of the computation
  2369. */
  2370. function evaluateAttributeExpressions(attributes) {
  2371. return attributes.reduce((acc, attribute) => {
  2372. const {
  2373. value,
  2374. type
  2375. } = attribute;
  2376. switch (true) {
  2377. // spread attribute
  2378. case !attribute.name && type === ATTRIBUTE:
  2379. return Object.assign({}, acc, value);
  2380. // value attribute
  2381. case type === VALUE:
  2382. acc.value = attribute.value;
  2383. break;
  2384. // normal attributes
  2385. default:
  2386. acc[dashToCamelCase(attribute.name)] = attribute.value;
  2387. }
  2388. return acc;
  2389. }, {});
  2390. }
  2391. const REMOVE_ATTRIBUTE = 'removeAttribute';
  2392. const SET_ATTIBUTE = 'setAttribute';
  2393. const ElementProto = typeof Element === 'undefined' ? {} : Element.prototype;
  2394. const isNativeHtmlProperty = memoize(name => ElementProto.hasOwnProperty(name)); // eslint-disable-line
  2395. /**
  2396. * Add all the attributes provided
  2397. * @param {HTMLElement} node - target node
  2398. * @param {Object} attributes - object containing the attributes names and values
  2399. * @returns {undefined} sorry it's a void function :(
  2400. */
  2401. function setAllAttributes(node, attributes) {
  2402. Object.entries(attributes).forEach((_ref) => {
  2403. let [name, value] = _ref;
  2404. return attributeExpression(node, {
  2405. name
  2406. }, value);
  2407. });
  2408. }
  2409. /**
  2410. * Remove all the attributes provided
  2411. * @param {HTMLElement} node - target node
  2412. * @param {Object} newAttributes - object containing all the new attribute names
  2413. * @param {Object} oldAttributes - object containing all the old attribute names
  2414. * @returns {undefined} sorry it's a void function :(
  2415. */
  2416. function removeAllAttributes(node, newAttributes, oldAttributes) {
  2417. const newKeys = newAttributes ? Object.keys(newAttributes) : [];
  2418. Object.keys(oldAttributes).filter(name => !newKeys.includes(name)).forEach(attribute => node.removeAttribute(attribute));
  2419. }
  2420. /**
  2421. * This methods handles the DOM attributes updates
  2422. * @param {HTMLElement} node - target node
  2423. * @param {Object} expression - expression object
  2424. * @param {string} expression.name - attribute name
  2425. * @param {*} value - new expression value
  2426. * @param {*} oldValue - the old expression cached value
  2427. * @returns {undefined}
  2428. */
  2429. function attributeExpression(node, _ref2, value, oldValue) {
  2430. let {
  2431. name
  2432. } = _ref2;
  2433. // is it a spread operator? {...attributes}
  2434. if (!name) {
  2435. if (oldValue) {
  2436. // remove all the old attributes
  2437. removeAllAttributes(node, value, oldValue);
  2438. } // is the value still truthy?
  2439. if (value) {
  2440. setAllAttributes(node, value);
  2441. }
  2442. return;
  2443. } // handle boolean attributes
  2444. if (!isNativeHtmlProperty(name) && (isBoolean(value) || isObject(value) || isFunction(value))) {
  2445. node[name] = value;
  2446. }
  2447. node[getMethod(value)](name, normalizeValue(name, value));
  2448. }
  2449. /**
  2450. * Get the attribute modifier method
  2451. * @param {*} value - if truthy we return `setAttribute` othewise `removeAttribute`
  2452. * @returns {string} the node attribute modifier method name
  2453. */
  2454. function getMethod(value) {
  2455. return isNil(value) || value === false || value === '' || isObject(value) || isFunction(value) ? REMOVE_ATTRIBUTE : SET_ATTIBUTE;
  2456. }
  2457. /**
  2458. * Get the value as string
  2459. * @param {string} name - attribute name
  2460. * @param {*} value - user input value
  2461. * @returns {string} input value as string
  2462. */
  2463. function normalizeValue(name, value) {
  2464. // be sure that expressions like selected={ true } will be always rendered as selected='selected'
  2465. if (value === true) return name;
  2466. return value;
  2467. }
  2468. const RE_EVENTS_PREFIX = /^on/;
  2469. const getCallbackAndOptions = value => Array.isArray(value) ? value : [value, false]; // see also https://medium.com/@WebReflection/dom-handleevent-a-cross-platform-standard-since-year-2000-5bf17287fd38
  2470. const EventListener = {
  2471. handleEvent(event) {
  2472. this[event.type](event);
  2473. }
  2474. };
  2475. const ListenersWeakMap = new WeakMap();
  2476. const createListener = node => {
  2477. const listener = Object.create(EventListener);
  2478. ListenersWeakMap.set(node, listener);
  2479. return listener;
  2480. };
  2481. /**
  2482. * Set a new event listener
  2483. * @param {HTMLElement} node - target node
  2484. * @param {Object} expression - expression object
  2485. * @param {string} expression.name - event name
  2486. * @param {*} value - new expression value
  2487. * @returns {value} the callback just received
  2488. */
  2489. function eventExpression(node, _ref, value) {
  2490. let {
  2491. name
  2492. } = _ref;
  2493. const normalizedEventName = name.replace(RE_EVENTS_PREFIX, '');
  2494. const eventListener = ListenersWeakMap.get(node) || createListener(node);
  2495. const [callback, options] = getCallbackAndOptions(value);
  2496. const handler = eventListener[normalizedEventName];
  2497. const mustRemoveEvent = handler && !callback;
  2498. const mustAddEvent = callback && !handler;
  2499. if (mustRemoveEvent) {
  2500. node.removeEventListener(normalizedEventName, eventListener);
  2501. }
  2502. if (mustAddEvent) {
  2503. node.addEventListener(normalizedEventName, eventListener, options);
  2504. }
  2505. eventListener[normalizedEventName] = callback;
  2506. }
  2507. /**
  2508. * Normalize the user value in order to render a empty string in case of falsy values
  2509. * @param {*} value - user input value
  2510. * @returns {string} hopefully a string
  2511. */
  2512. function normalizeStringValue(value) {
  2513. return isNil(value) ? '' : value;
  2514. }
  2515. /**
  2516. * Get the the target text node to update or create one from of a comment node
  2517. * @param {HTMLElement} node - any html element containing childNodes
  2518. * @param {number} childNodeIndex - index of the text node in the childNodes list
  2519. * @returns {HTMLTextNode} the text node to update
  2520. */
  2521. const getTextNode = (node, childNodeIndex) => {
  2522. const target = node.childNodes[childNodeIndex];
  2523. if (target.nodeType === Node.COMMENT_NODE) {
  2524. const textNode = document.createTextNode('');
  2525. node.replaceChild(textNode, target);
  2526. return textNode;
  2527. }
  2528. return target;
  2529. };
  2530. /**
  2531. * This methods handles a simple text expression update
  2532. * @param {HTMLElement} node - target node
  2533. * @param {Object} data - expression object
  2534. * @param {*} value - new expression value
  2535. * @returns {undefined}
  2536. */
  2537. function textExpression(node, data, value) {
  2538. node.data = normalizeStringValue(value);
  2539. }
  2540. /**
  2541. * This methods handles the input fileds value updates
  2542. * @param {HTMLElement} node - target node
  2543. * @param {Object} expression - expression object
  2544. * @param {*} value - new expression value
  2545. * @returns {undefined}
  2546. */
  2547. function valueExpression(node, expression, value) {
  2548. node.value = normalizeStringValue(value);
  2549. }
  2550. var expressions = {
  2551. [ATTRIBUTE]: attributeExpression,
  2552. [EVENT]: eventExpression,
  2553. [TEXT]: textExpression,
  2554. [VALUE]: valueExpression
  2555. };
  2556. const Expression = {
  2557. // Static props
  2558. // node: null,
  2559. // value: null,
  2560. // API methods
  2561. /**
  2562. * Mount the expression evaluating its initial value
  2563. * @param {*} scope - argument passed to the expression to evaluate its current values
  2564. * @returns {Expression} self
  2565. */
  2566. mount(scope) {
  2567. // hopefully a pure function
  2568. this.value = this.evaluate(scope); // IO() DOM updates
  2569. apply(this, this.value);
  2570. return this;
  2571. },
  2572. /**
  2573. * Update the expression if its value changed
  2574. * @param {*} scope - argument passed to the expression to evaluate its current values
  2575. * @returns {Expression} self
  2576. */
  2577. update(scope) {
  2578. // pure function
  2579. const value = this.evaluate(scope);
  2580. if (this.value !== value) {
  2581. // IO() DOM updates
  2582. apply(this, value);
  2583. this.value = value;
  2584. }
  2585. return this;
  2586. },
  2587. /**
  2588. * Expression teardown method
  2589. * @returns {Expression} self
  2590. */
  2591. unmount() {
  2592. // unmount only the event handling expressions
  2593. if (this.type === EVENT) apply(this, null);
  2594. return this;
  2595. }
  2596. };
  2597. /**
  2598. * IO() function to handle the DOM updates
  2599. * @param {Expression} expression - expression object
  2600. * @param {*} value - current expression value
  2601. * @returns {undefined}
  2602. */
  2603. function apply(expression, value) {
  2604. return expressions[expression.type](expression.node, expression, value, expression.value);
  2605. }
  2606. function create$2(node, data) {
  2607. return Object.assign({}, Expression, data, {
  2608. node: data.type === TEXT ? getTextNode(node, data.childNodeIndex) : node
  2609. });
  2610. }
  2611. /**
  2612. * Create a flat object having as keys a list of methods that if dispatched will propagate
  2613. * on the whole collection
  2614. * @param {Array} collection - collection to iterate
  2615. * @param {Array<string>} methods - methods to execute on each item of the collection
  2616. * @param {*} context - context returned by the new methods created
  2617. * @returns {Object} a new object to simplify the the nested methods dispatching
  2618. */
  2619. function flattenCollectionMethods(collection, methods, context) {
  2620. return methods.reduce((acc, method) => {
  2621. return Object.assign({}, acc, {
  2622. [method]: scope => {
  2623. return collection.map(item => item[method](scope)) && context;
  2624. }
  2625. });
  2626. }, {});
  2627. }
  2628. function create$3(node, _ref) {
  2629. let {
  2630. expressions
  2631. } = _ref;
  2632. return Object.assign({}, flattenCollectionMethods(expressions.map(expression => create$2(node, expression)), ['mount', 'update', 'unmount']));
  2633. }
  2634. // Riot.js constants that can be used accross more modules
  2635. const COMPONENTS_IMPLEMENTATION_MAP = new Map(),
  2636. DOM_COMPONENT_INSTANCE_PROPERTY = Symbol('riot-component'),
  2637. PLUGINS_SET = new Set(),
  2638. IS_DIRECTIVE = 'is',
  2639. VALUE_ATTRIBUTE = 'value',
  2640. MOUNT_METHOD_KEY = 'mount',
  2641. UPDATE_METHOD_KEY = 'update',
  2642. UNMOUNT_METHOD_KEY = 'unmount',
  2643. SHOULD_UPDATE_KEY = 'shouldUpdate',
  2644. ON_BEFORE_MOUNT_KEY = 'onBeforeMount',
  2645. ON_MOUNTED_KEY = 'onMounted',
  2646. ON_BEFORE_UPDATE_KEY = 'onBeforeUpdate',
  2647. ON_UPDATED_KEY = 'onUpdated',
  2648. ON_BEFORE_UNMOUNT_KEY = 'onBeforeUnmount',
  2649. ON_UNMOUNTED_KEY = 'onUnmounted',
  2650. PROPS_KEY = 'props',
  2651. STATE_KEY = 'state',
  2652. SLOTS_KEY = 'slots',
  2653. ROOT_KEY = 'root',
  2654. IS_PURE_SYMBOL = Symbol.for('pure'),
  2655. PARENT_KEY_SYMBOL = Symbol('parent'),
  2656. ATTRIBUTES_KEY_SYMBOL = Symbol('attributes'),
  2657. TEMPLATE_KEY_SYMBOL = Symbol('template');
  2658. var globals = /*#__PURE__*/Object.freeze({
  2659. __proto__: null,
  2660. COMPONENTS_IMPLEMENTATION_MAP: COMPONENTS_IMPLEMENTATION_MAP,
  2661. DOM_COMPONENT_INSTANCE_PROPERTY: DOM_COMPONENT_INSTANCE_PROPERTY,
  2662. PLUGINS_SET: PLUGINS_SET,
  2663. IS_DIRECTIVE: IS_DIRECTIVE,
  2664. VALUE_ATTRIBUTE: VALUE_ATTRIBUTE,
  2665. MOUNT_METHOD_KEY: MOUNT_METHOD_KEY,
  2666. UPDATE_METHOD_KEY: UPDATE_METHOD_KEY,
  2667. UNMOUNT_METHOD_KEY: UNMOUNT_METHOD_KEY,
  2668. SHOULD_UPDATE_KEY: SHOULD_UPDATE_KEY,
  2669. ON_BEFORE_MOUNT_KEY: ON_BEFORE_MOUNT_KEY,
  2670. ON_MOUNTED_KEY: ON_MOUNTED_KEY,
  2671. ON_BEFORE_UPDATE_KEY: ON_BEFORE_UPDATE_KEY,
  2672. ON_UPDATED_KEY: ON_UPDATED_KEY,
  2673. ON_BEFORE_UNMOUNT_KEY: ON_BEFORE_UNMOUNT_KEY,
  2674. ON_UNMOUNTED_KEY: ON_UNMOUNTED_KEY,
  2675. PROPS_KEY: PROPS_KEY,
  2676. STATE_KEY: STATE_KEY,
  2677. SLOTS_KEY: SLOTS_KEY,
  2678. ROOT_KEY: ROOT_KEY,
  2679. IS_PURE_SYMBOL: IS_PURE_SYMBOL,
  2680. PARENT_KEY_SYMBOL: PARENT_KEY_SYMBOL,
  2681. ATTRIBUTES_KEY_SYMBOL: ATTRIBUTES_KEY_SYMBOL,
  2682. TEMPLATE_KEY_SYMBOL: TEMPLATE_KEY_SYMBOL
  2683. });
  2684. function extendParentScope(attributes, scope, parentScope) {
  2685. if (!attributes || !attributes.length) return parentScope;
  2686. const expressions = attributes.map(attr => Object.assign({}, attr, {
  2687. value: attr.evaluate(scope)
  2688. }));
  2689. return Object.assign(Object.create(parentScope || null), evaluateAttributeExpressions(expressions));
  2690. } // this function is only meant to fix an edge case
  2691. // https://github.com/riot/riot/issues/2842
  2692. const getRealParent = (scope, parentScope) => scope[PARENT_KEY_SYMBOL] || parentScope;
  2693. const SlotBinding = {
  2694. // dynamic binding properties
  2695. // node: null,
  2696. // name: null,
  2697. attributes: [],
  2698. // template: null,
  2699. getTemplateScope(scope, parentScope) {
  2700. return extendParentScope(this.attributes, scope, parentScope);
  2701. },
  2702. // API methods
  2703. mount(scope, parentScope) {
  2704. const templateData = scope.slots ? scope.slots.find((_ref) => {
  2705. let {
  2706. id
  2707. } = _ref;
  2708. return id === this.name;
  2709. }) : false;
  2710. const {
  2711. parentNode
  2712. } = this.node;
  2713. const realParent = getRealParent(scope, parentScope);
  2714. this.template = templateData && create$6(templateData.html, templateData.bindings).createDOM(parentNode);
  2715. if (this.template) {
  2716. this.template.mount(this.node, this.getTemplateScope(scope, realParent), realParent);
  2717. this.template.children = Array.from(this.node.childNodes);
  2718. moveSlotInnerContent(this.node);
  2719. }
  2720. removeChild(this.node);
  2721. return this;
  2722. },
  2723. update(scope, parentScope) {
  2724. if (this.template) {
  2725. const realParent = getRealParent(scope, parentScope);
  2726. this.template.update(this.getTemplateScope(scope, realParent), realParent);
  2727. }
  2728. return this;
  2729. },
  2730. unmount(scope, parentScope, mustRemoveRoot) {
  2731. if (this.template) {
  2732. this.template.unmount(this.getTemplateScope(scope, parentScope), null, mustRemoveRoot);
  2733. }
  2734. return this;
  2735. }
  2736. };
  2737. /**
  2738. * Move the inner content of the slots outside of them
  2739. * @param {HTMLElement} slot - slot node
  2740. * @returns {undefined} it's a void method ¯\_()_/¯
  2741. */
  2742. function moveSlotInnerContent(slot) {
  2743. const child = slot && slot.firstChild;
  2744. if (!child) return;
  2745. insertBefore(child, slot);
  2746. moveSlotInnerContent(slot);
  2747. }
  2748. /**
  2749. * Create a single slot binding
  2750. * @param {HTMLElement} node - slot node
  2751. * @param {string} options.name - slot id
  2752. * @returns {Object} Slot binding object
  2753. */
  2754. function createSlot(node, _ref2) {
  2755. let {
  2756. name,
  2757. attributes
  2758. } = _ref2;
  2759. return Object.assign({}, SlotBinding, {
  2760. attributes,
  2761. node,
  2762. name
  2763. });
  2764. }
  2765. /**
  2766. * Create a new tag object if it was registered before, otherwise fallback to the simple
  2767. * template chunk
  2768. * @param {Function} component - component factory function
  2769. * @param {Array<Object>} slots - array containing the slots markup
  2770. * @param {Array} attributes - dynamic attributes that will be received by the tag element
  2771. * @returns {TagImplementation|TemplateChunk} a tag implementation or a template chunk as fallback
  2772. */
  2773. function getTag(component, slots, attributes) {
  2774. if (slots === void 0) {
  2775. slots = [];
  2776. }
  2777. if (attributes === void 0) {
  2778. attributes = [];
  2779. }
  2780. // if this tag was registered before we will return its implementation
  2781. if (component) {
  2782. return component({
  2783. slots,
  2784. attributes
  2785. });
  2786. } // otherwise we return a template chunk
  2787. return create$6(slotsToMarkup(slots), [...slotBindings(slots), {
  2788. // the attributes should be registered as binding
  2789. // if we fallback to a normal template chunk
  2790. expressions: attributes.map(attr => {
  2791. return Object.assign({
  2792. type: ATTRIBUTE
  2793. }, attr);
  2794. })
  2795. }]);
  2796. }
  2797. /**
  2798. * Merge all the slots bindings into a single array
  2799. * @param {Array<Object>} slots - slots collection
  2800. * @returns {Array<Bindings>} flatten bindings array
  2801. */
  2802. function slotBindings(slots) {
  2803. return slots.reduce((acc, _ref) => {
  2804. let {
  2805. bindings
  2806. } = _ref;
  2807. return acc.concat(bindings);
  2808. }, []);
  2809. }
  2810. /**
  2811. * Merge all the slots together in a single markup string
  2812. * @param {Array<Object>} slots - slots collection
  2813. * @returns {string} markup of all the slots in a single string
  2814. */
  2815. function slotsToMarkup(slots) {
  2816. return slots.reduce((acc, slot) => {
  2817. return acc + slot.html;
  2818. }, '');
  2819. }
  2820. const TagBinding = {
  2821. // dynamic binding properties
  2822. // node: null,
  2823. // evaluate: null,
  2824. // name: null,
  2825. // slots: null,
  2826. // tag: null,
  2827. // attributes: null,
  2828. // getComponent: null,
  2829. mount(scope) {
  2830. return this.update(scope);
  2831. },
  2832. update(scope, parentScope) {
  2833. const name = this.evaluate(scope); // simple update
  2834. if (name === this.name) {
  2835. this.tag.update(scope);
  2836. } else {
  2837. // unmount the old tag if it exists
  2838. this.unmount(scope, parentScope, true); // mount the new tag
  2839. this.name = name;
  2840. this.tag = getTag(this.getComponent(name), this.slots, this.attributes);
  2841. this.tag.mount(this.node, scope);
  2842. }
  2843. return this;
  2844. },
  2845. unmount(scope, parentScope, keepRootTag) {
  2846. if (this.tag) {
  2847. // keep the root tag
  2848. this.tag.unmount(keepRootTag);
  2849. }
  2850. return this;
  2851. }
  2852. };
  2853. function create$4(node, _ref2) {
  2854. let {
  2855. evaluate,
  2856. getComponent,
  2857. slots,
  2858. attributes
  2859. } = _ref2;
  2860. return Object.assign({}, TagBinding, {
  2861. node,
  2862. evaluate,
  2863. slots,
  2864. attributes,
  2865. getComponent
  2866. });
  2867. }
  2868. var bindings = {
  2869. [IF]: create$1,
  2870. [SIMPLE]: create$3,
  2871. [EACH]: create,
  2872. [TAG]: create$4,
  2873. [SLOT]: createSlot
  2874. };
  2875. /**
  2876. * Text expressions in a template tag will get childNodeIndex value normalized
  2877. * depending on the position of the <template> tag offset
  2878. * @param {Expression[]} expressions - riot expressions array
  2879. * @param {number} textExpressionsOffset - offset of the <template> tag
  2880. * @returns {Expression[]} expressions containing the text expressions normalized
  2881. */
  2882. function fixTextExpressionsOffset(expressions, textExpressionsOffset) {
  2883. return expressions.map(e => e.type === TEXT ? Object.assign({}, e, {
  2884. childNodeIndex: e.childNodeIndex + textExpressionsOffset
  2885. }) : e);
  2886. }
  2887. /**
  2888. * Bind a new expression object to a DOM node
  2889. * @param {HTMLElement} root - DOM node where to bind the expression
  2890. * @param {Object} binding - binding data
  2891. * @param {number|null} templateTagOffset - if it's defined we need to fix the text expressions childNodeIndex offset
  2892. * @returns {Binding} Binding object
  2893. */
  2894. function create$5(root, binding, templateTagOffset) {
  2895. const {
  2896. selector,
  2897. type,
  2898. redundantAttribute,
  2899. expressions
  2900. } = binding; // find the node to apply the bindings
  2901. const node = selector ? root.querySelector(selector) : root; // remove eventually additional attributes created only to select this node
  2902. if (redundantAttribute) node.removeAttribute(redundantAttribute);
  2903. const bindingExpressions = expressions || []; // init the binding
  2904. return (bindings[type] || bindings[SIMPLE])(node, Object.assign({}, binding, {
  2905. expressions: templateTagOffset && !selector ? fixTextExpressionsOffset(bindingExpressions, templateTagOffset) : bindingExpressions
  2906. }));
  2907. }
  2908. function createHTMLTree(html, root) {
  2909. const template = isTemplate(root) ? root : document.createElement('template');
  2910. template.innerHTML = html;
  2911. return template.content;
  2912. } // for svg nodes we need a bit more work
  2913. function createSVGTree(html, container) {
  2914. // create the SVGNode
  2915. const svgNode = container.ownerDocument.importNode(new window.DOMParser().parseFromString(`<svg xmlns="http://www.w3.org/2000/svg">${html}</svg>`, 'application/xml').documentElement, true);
  2916. return svgNode;
  2917. }
  2918. /**
  2919. * Create the DOM that will be injected
  2920. * @param {Object} root - DOM node to find out the context where the fragment will be created
  2921. * @param {string} html - DOM to create as string
  2922. * @returns {HTMLDocumentFragment|HTMLElement} a new html fragment
  2923. */
  2924. function createDOMTree(root, html) {
  2925. if (isSvg(root)) return createSVGTree(html, root);
  2926. return createHTMLTree(html, root);
  2927. }
  2928. /**
  2929. * Inject the DOM tree into a target node
  2930. * @param {HTMLElement} el - target element
  2931. * @param {HTMLFragment|SVGElement} dom - dom tree to inject
  2932. * @returns {undefined}
  2933. */
  2934. function injectDOM(el, dom) {
  2935. switch (true) {
  2936. case isSvg(el):
  2937. moveChildren(dom, el);
  2938. break;
  2939. case isTemplate(el):
  2940. el.parentNode.replaceChild(dom, el);
  2941. break;
  2942. default:
  2943. el.appendChild(dom);
  2944. }
  2945. }
  2946. /**
  2947. * Create the Template DOM skeleton
  2948. * @param {HTMLElement} el - root node where the DOM will be injected
  2949. * @param {string} html - markup that will be injected into the root node
  2950. * @returns {HTMLFragment} fragment that will be injected into the root node
  2951. */
  2952. function createTemplateDOM(el, html) {
  2953. return html && (typeof html === 'string' ? createDOMTree(el, html) : html);
  2954. }
  2955. /**
  2956. * Template Chunk model
  2957. * @type {Object}
  2958. */
  2959. const TemplateChunk = Object.freeze({
  2960. // Static props
  2961. // bindings: null,
  2962. // bindingsData: null,
  2963. // html: null,
  2964. // isTemplateTag: false,
  2965. // fragment: null,
  2966. // children: null,
  2967. // dom: null,
  2968. // el: null,
  2969. /**
  2970. * Create the template DOM structure that will be cloned on each mount
  2971. * @param {HTMLElement} el - the root node
  2972. * @returns {TemplateChunk} self
  2973. */
  2974. createDOM(el) {
  2975. // make sure that the DOM gets created before cloning the template
  2976. this.dom = this.dom || createTemplateDOM(el, this.html);
  2977. return this;
  2978. },
  2979. // API methods
  2980. /**
  2981. * Attach the template to a DOM node
  2982. * @param {HTMLElement} el - target DOM node
  2983. * @param {*} scope - template data
  2984. * @param {*} parentScope - scope of the parent template tag
  2985. * @param {Object} meta - meta properties needed to handle the <template> tags in loops
  2986. * @returns {TemplateChunk} self
  2987. */
  2988. mount(el, scope, parentScope, meta) {
  2989. if (meta === void 0) {
  2990. meta = {};
  2991. }
  2992. if (!el) throw new Error('Please provide DOM node to mount properly your template');
  2993. if (this.el) this.unmount(scope); // <template> tags require a bit more work
  2994. // the template fragment might be already created via meta outside of this call
  2995. const {
  2996. fragment,
  2997. children,
  2998. avoidDOMInjection
  2999. } = meta; // <template> bindings of course can not have a root element
  3000. // so we check the parent node to set the query selector bindings
  3001. const {
  3002. parentNode
  3003. } = children ? children[0] : el;
  3004. const isTemplateTag = isTemplate(el);
  3005. const templateTagOffset = isTemplateTag ? Math.max(Array.from(parentNode.childNodes).indexOf(el), 0) : null;
  3006. this.isTemplateTag = isTemplateTag; // create the DOM if it wasn't created before
  3007. this.createDOM(el);
  3008. if (this.dom) {
  3009. // create the new template dom fragment if it want already passed in via meta
  3010. this.fragment = fragment || this.dom.cloneNode(true);
  3011. } // store root node
  3012. // notice that for template tags the root note will be the parent tag
  3013. this.el = this.isTemplateTag ? parentNode : el; // create the children array only for the <template> fragments
  3014. this.children = this.isTemplateTag ? children || Array.from(this.fragment.childNodes) : null; // inject the DOM into the el only if a fragment is available
  3015. if (!avoidDOMInjection && this.fragment) injectDOM(el, this.fragment); // create the bindings
  3016. this.bindings = this.bindingsData.map(binding => create$5(this.el, binding, templateTagOffset));
  3017. this.bindings.forEach(b => b.mount(scope, parentScope));
  3018. return this;
  3019. },
  3020. /**
  3021. * Update the template with fresh data
  3022. * @param {*} scope - template data
  3023. * @param {*} parentScope - scope of the parent template tag
  3024. * @returns {TemplateChunk} self
  3025. */
  3026. update(scope, parentScope) {
  3027. this.bindings.forEach(b => b.update(scope, parentScope));
  3028. return this;
  3029. },
  3030. /**
  3031. * Remove the template from the node where it was initially mounted
  3032. * @param {*} scope - template data
  3033. * @param {*} parentScope - scope of the parent template tag
  3034. * @param {boolean|null} mustRemoveRoot - if true remove the root element,
  3035. * if false or undefined clean the root tag content, if null don't touch the DOM
  3036. * @returns {TemplateChunk} self
  3037. */
  3038. unmount(scope, parentScope, mustRemoveRoot) {
  3039. if (this.el) {
  3040. this.bindings.forEach(b => b.unmount(scope, parentScope, mustRemoveRoot));
  3041. switch (true) {
  3042. // <template> tags should be treated a bit differently
  3043. // we need to clear their children only if it's explicitly required by the caller
  3044. // via mustRemoveRoot !== null
  3045. case this.children && mustRemoveRoot !== null:
  3046. clearChildren(this.children);
  3047. break;
  3048. // remove the root node only if the mustRemoveRoot === true
  3049. case mustRemoveRoot === true:
  3050. removeChild(this.el);
  3051. break;
  3052. // otherwise we clean the node children
  3053. case mustRemoveRoot !== null:
  3054. cleanNode(this.el);
  3055. break;
  3056. }
  3057. this.el = null;
  3058. }
  3059. return this;
  3060. },
  3061. /**
  3062. * Clone the template chunk
  3063. * @returns {TemplateChunk} a clone of this object resetting the this.el property
  3064. */
  3065. clone() {
  3066. return Object.assign({}, this, {
  3067. el: null
  3068. });
  3069. }
  3070. });
  3071. /**
  3072. * Create a template chunk wiring also the bindings
  3073. * @param {string|HTMLElement} html - template string
  3074. * @param {Array} bindings - bindings collection
  3075. * @returns {TemplateChunk} a new TemplateChunk copy
  3076. */
  3077. function create$6(html, bindings) {
  3078. if (bindings === void 0) {
  3079. bindings = [];
  3080. }
  3081. return Object.assign({}, TemplateChunk, {
  3082. html,
  3083. bindingsData: bindings
  3084. });
  3085. }
  3086. /**
  3087. * Method used to bind expressions to a DOM node
  3088. * @param {string|HTMLElement} html - your static template html structure
  3089. * @param {Array} bindings - list of the expressions to bind to update the markup
  3090. * @returns {TemplateChunk} a new TemplateChunk object having the `update`,`mount`, `unmount` and `clone` methods
  3091. *
  3092. * @example
  3093. *
  3094. * riotDOMBindings
  3095. * .template(
  3096. * `<div expr0><!----></div><div><p expr1><!----><section expr2></section></p>`,
  3097. * [
  3098. * {
  3099. * selector: '[expr0]',
  3100. * redundantAttribute: 'expr0',
  3101. * expressions: [
  3102. * {
  3103. * type: expressionTypes.TEXT,
  3104. * childNodeIndex: 0,
  3105. * evaluate(scope) {
  3106. * return scope.time;
  3107. * },
  3108. * },
  3109. * ],
  3110. * },
  3111. * {
  3112. * selector: '[expr1]',
  3113. * redundantAttribute: 'expr1',
  3114. * expressions: [
  3115. * {
  3116. * type: expressionTypes.TEXT,
  3117. * childNodeIndex: 0,
  3118. * evaluate(scope) {
  3119. * return scope.name;
  3120. * },
  3121. * },
  3122. * {
  3123. * type: 'attribute',
  3124. * name: 'style',
  3125. * evaluate(scope) {
  3126. * return scope.style;
  3127. * },
  3128. * },
  3129. * ],
  3130. * },
  3131. * {
  3132. * selector: '[expr2]',
  3133. * redundantAttribute: 'expr2',
  3134. * type: bindingTypes.IF,
  3135. * evaluate(scope) {
  3136. * return scope.isVisible;
  3137. * },
  3138. * template: riotDOMBindings.template('hello there'),
  3139. * },
  3140. * ]
  3141. * )
  3142. */
  3143. var DOMBindings = /*#__PURE__*/Object.freeze({
  3144. __proto__: null,
  3145. template: create$6,
  3146. createBinding: create$5,
  3147. createExpression: create$2,
  3148. bindingTypes: bindingTypes,
  3149. expressionTypes: expressionTypes
  3150. });
  3151. function noop() {
  3152. return this;
  3153. }
  3154. /**
  3155. * Autobind the methods of a source object to itself
  3156. * @param {Object} source - probably a riot tag instance
  3157. * @param {Array<string>} methods - list of the methods to autobind
  3158. * @returns {Object} the original object received
  3159. */
  3160. function autobindMethods(source, methods) {
  3161. methods.forEach(method => {
  3162. source[method] = source[method].bind(source);
  3163. });
  3164. return source;
  3165. }
  3166. /**
  3167. * Call the first argument received only if it's a function otherwise return it as it is
  3168. * @param {*} source - anything
  3169. * @returns {*} anything
  3170. */
  3171. function callOrAssign(source) {
  3172. return isFunction(source) ? source.prototype && source.prototype.constructor ? new source() : source() : source;
  3173. }
  3174. /**
  3175. * Helper function to set an immutable property
  3176. * @param {Object} source - object where the new property will be set
  3177. * @param {string} key - object key where the new property will be stored
  3178. * @param {*} value - value of the new property
  3179. * @param {Object} options - set the propery overriding the default options
  3180. * @returns {Object} - the original object modified
  3181. */
  3182. function defineProperty(source, key, value, options) {
  3183. if (options === void 0) {
  3184. options = {};
  3185. }
  3186. /* eslint-disable fp/no-mutating-methods */
  3187. Object.defineProperty(source, key, Object.assign({
  3188. value,
  3189. enumerable: false,
  3190. writable: false,
  3191. configurable: true
  3192. }, options));
  3193. /* eslint-enable fp/no-mutating-methods */
  3194. return source;
  3195. }
  3196. /**
  3197. * Define multiple properties on a target object
  3198. * @param {Object} source - object where the new properties will be set
  3199. * @param {Object} properties - object containing as key pair the key + value properties
  3200. * @param {Object} options - set the propery overriding the default options
  3201. * @returns {Object} the original object modified
  3202. */
  3203. function defineProperties(source, properties, options) {
  3204. Object.entries(properties).forEach((_ref) => {
  3205. let [key, value] = _ref;
  3206. defineProperty(source, key, value, options);
  3207. });
  3208. return source;
  3209. }
  3210. /**
  3211. * Define default properties if they don't exist on the source object
  3212. * @param {Object} source - object that will receive the default properties
  3213. * @param {Object} defaults - object containing additional optional keys
  3214. * @returns {Object} the original object received enhanced
  3215. */
  3216. function defineDefaults(source, defaults) {
  3217. Object.entries(defaults).forEach((_ref2) => {
  3218. let [key, value] = _ref2;
  3219. if (!source[key]) source[key] = value;
  3220. });
  3221. return source;
  3222. }
  3223. /**
  3224. * Converts any DOM node/s to a loopable array
  3225. * @param { HTMLElement|NodeList } els - single html element or a node list
  3226. * @returns { Array } always a loopable object
  3227. */
  3228. function domToArray(els) {
  3229. // can this object be already looped?
  3230. if (!Array.isArray(els)) {
  3231. // is it a node list?
  3232. if (/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(els)) && typeof els.length === 'number') return Array.from(els);else // if it's a single node
  3233. // it will be returned as "array" with one single entry
  3234. return [els];
  3235. } // this object could be looped out of the box
  3236. return els;
  3237. }
  3238. /**
  3239. * Simple helper to find DOM nodes returning them as array like loopable object
  3240. * @param { string|DOMNodeList } selector - either the query or the DOM nodes to arraify
  3241. * @param { HTMLElement } ctx - context defining where the query will search for the DOM nodes
  3242. * @returns { Array } DOM nodes found as array
  3243. */
  3244. function $(selector, ctx) {
  3245. return domToArray(typeof selector === 'string' ? (ctx || document).querySelectorAll(selector) : selector);
  3246. }
  3247. /**
  3248. * Normalize the return values, in case of a single value we avoid to return an array
  3249. * @param { Array } values - list of values we want to return
  3250. * @returns { Array|string|boolean } either the whole list of values or the single one found
  3251. * @private
  3252. */
  3253. const normalize = values => values.length === 1 ? values[0] : values;
  3254. /**
  3255. * Parse all the nodes received to get/remove/check their attributes
  3256. * @param { HTMLElement|NodeList|Array } els - DOM node/s to parse
  3257. * @param { string|Array } name - name or list of attributes
  3258. * @param { string } method - method that will be used to parse the attributes
  3259. * @returns { Array|string } result of the parsing in a list or a single value
  3260. * @private
  3261. */
  3262. function parseNodes(els, name, method) {
  3263. const names = typeof name === 'string' ? [name] : name;
  3264. return normalize(domToArray(els).map(el => {
  3265. return normalize(names.map(n => el[method](n)));
  3266. }));
  3267. }
  3268. /**
  3269. * Set any attribute on a single or a list of DOM nodes
  3270. * @param { HTMLElement|NodeList|Array } els - DOM node/s to parse
  3271. * @param { string|Object } name - either the name of the attribute to set
  3272. * or a list of properties as object key - value
  3273. * @param { string } value - the new value of the attribute (optional)
  3274. * @returns { HTMLElement|NodeList|Array } the original array of elements passed to this function
  3275. *
  3276. * @example
  3277. *
  3278. * import { set } from 'bianco.attr'
  3279. *
  3280. * const img = document.createElement('img')
  3281. *
  3282. * set(img, 'width', 100)
  3283. *
  3284. * // or also
  3285. * set(img, {
  3286. * width: 300,
  3287. * height: 300
  3288. * })
  3289. *
  3290. */
  3291. function set(els, name, value) {
  3292. const attrs = typeof name === 'object' ? name : {
  3293. [name]: value
  3294. };
  3295. const props = Object.keys(attrs);
  3296. domToArray(els).forEach(el => {
  3297. props.forEach(prop => el.setAttribute(prop, attrs[prop]));
  3298. });
  3299. return els;
  3300. }
  3301. /**
  3302. * Get any attribute from a single or a list of DOM nodes
  3303. * @param { HTMLElement|NodeList|Array } els - DOM node/s to parse
  3304. * @param { string|Array } name - name or list of attributes to get
  3305. * @returns { Array|string } list of the attributes found
  3306. *
  3307. * @example
  3308. *
  3309. * import { get } from 'bianco.attr'
  3310. *
  3311. * const img = document.createElement('img')
  3312. *
  3313. * get(img, 'width') // => '200'
  3314. *
  3315. * // or also
  3316. * get(img, ['width', 'height']) // => ['200', '300']
  3317. *
  3318. * // or also
  3319. * get([img1, img2], ['width', 'height']) // => [['200', '300'], ['500', '200']]
  3320. */
  3321. function get(els, name) {
  3322. return parseNodes(els, name, 'getAttribute');
  3323. }
  3324. const CSS_BY_NAME = new Map();
  3325. const STYLE_NODE_SELECTOR = 'style[riot]'; // memoized curried function
  3326. const getStyleNode = (style => {
  3327. return () => {
  3328. // lazy evaluation:
  3329. // if this function was already called before
  3330. // we return its cached result
  3331. if (style) return style; // create a new style element or use an existing one
  3332. // and cache it internally
  3333. style = $(STYLE_NODE_SELECTOR)[0] || document.createElement('style');
  3334. set(style, 'type', 'text/css');
  3335. /* istanbul ignore next */
  3336. if (!style.parentNode) document.head.appendChild(style);
  3337. return style;
  3338. };
  3339. })();
  3340. /**
  3341. * Object that will be used to inject and manage the css of every tag instance
  3342. */
  3343. var cssManager = {
  3344. CSS_BY_NAME,
  3345. /**
  3346. * Save a tag style to be later injected into DOM
  3347. * @param { string } name - if it's passed we will map the css to a tagname
  3348. * @param { string } css - css string
  3349. * @returns {Object} self
  3350. */
  3351. add(name, css) {
  3352. if (!CSS_BY_NAME.has(name)) {
  3353. CSS_BY_NAME.set(name, css);
  3354. this.inject();
  3355. }
  3356. return this;
  3357. },
  3358. /**
  3359. * Inject all previously saved tag styles into DOM
  3360. * innerHTML seems slow: http://jsperf.com/riot-insert-style
  3361. * @returns {Object} self
  3362. */
  3363. inject() {
  3364. getStyleNode().innerHTML = [...CSS_BY_NAME.values()].join('\n');
  3365. return this;
  3366. },
  3367. /**
  3368. * Remove a tag style from the DOM
  3369. * @param {string} name a registered tagname
  3370. * @returns {Object} self
  3371. */
  3372. remove(name) {
  3373. if (CSS_BY_NAME.has(name)) {
  3374. CSS_BY_NAME.delete(name);
  3375. this.inject();
  3376. }
  3377. return this;
  3378. }
  3379. };
  3380. /**
  3381. * Function to curry any javascript method
  3382. * @param {Function} fn - the target function we want to curry
  3383. * @param {...[args]} acc - initial arguments
  3384. * @returns {Function|*} it will return a function until the target function
  3385. * will receive all of its arguments
  3386. */
  3387. function curry(fn) {
  3388. for (var _len = arguments.length, acc = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  3389. acc[_key - 1] = arguments[_key];
  3390. }
  3391. return function () {
  3392. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  3393. args[_key2] = arguments[_key2];
  3394. }
  3395. args = [...acc, ...args];
  3396. return args.length < fn.length ? curry(fn, ...args) : fn(...args);
  3397. };
  3398. }
  3399. /**
  3400. * Get the tag name of any DOM node
  3401. * @param {HTMLElement} element - DOM node we want to inspect
  3402. * @returns {string} name to identify this dom node in riot
  3403. */
  3404. function getName(element) {
  3405. return get(element, IS_DIRECTIVE) || element.tagName.toLowerCase();
  3406. }
  3407. const COMPONENT_CORE_HELPERS = Object.freeze({
  3408. // component helpers
  3409. $(selector) {
  3410. return $(selector, this.root)[0];
  3411. },
  3412. $$(selector) {
  3413. return $(selector, this.root);
  3414. }
  3415. });
  3416. const PURE_COMPONENT_API = Object.freeze({
  3417. [MOUNT_METHOD_KEY]: noop,
  3418. [UPDATE_METHOD_KEY]: noop,
  3419. [UNMOUNT_METHOD_KEY]: noop
  3420. });
  3421. const COMPONENT_LIFECYCLE_METHODS = Object.freeze({
  3422. [SHOULD_UPDATE_KEY]: noop,
  3423. [ON_BEFORE_MOUNT_KEY]: noop,
  3424. [ON_MOUNTED_KEY]: noop,
  3425. [ON_BEFORE_UPDATE_KEY]: noop,
  3426. [ON_UPDATED_KEY]: noop,
  3427. [ON_BEFORE_UNMOUNT_KEY]: noop,
  3428. [ON_UNMOUNTED_KEY]: noop
  3429. });
  3430. const MOCKED_TEMPLATE_INTERFACE = Object.assign({}, PURE_COMPONENT_API, {
  3431. clone: noop,
  3432. createDOM: noop
  3433. });
  3434. /**
  3435. * Evaluate the component properties either from its real attributes or from its initial user properties
  3436. * @param {HTMLElement} element - component root
  3437. * @param {Object} initialProps - initial props
  3438. * @returns {Object} component props key value pairs
  3439. */
  3440. function evaluateInitialProps(element, initialProps) {
  3441. if (initialProps === void 0) {
  3442. initialProps = {};
  3443. }
  3444. return Object.assign({}, DOMattributesToObject(element), callOrAssign(initialProps));
  3445. }
  3446. /**
  3447. * Bind a DOM node to its component object
  3448. * @param {HTMLElement} node - html node mounted
  3449. * @param {Object} component - Riot.js component object
  3450. * @returns {Object} the component object received as second argument
  3451. */
  3452. const bindDOMNodeToComponentObject = (node, component) => node[DOM_COMPONENT_INSTANCE_PROPERTY] = component;
  3453. /**
  3454. * Wrap the Riot.js core API methods using a mapping function
  3455. * @param {Function} mapFunction - lifting function
  3456. * @returns {Object} an object having the { mount, update, unmount } functions
  3457. */
  3458. function createCoreAPIMethods(mapFunction) {
  3459. return [MOUNT_METHOD_KEY, UPDATE_METHOD_KEY, UNMOUNT_METHOD_KEY].reduce((acc, method) => {
  3460. acc[method] = mapFunction(method);
  3461. return acc;
  3462. }, {});
  3463. }
  3464. /**
  3465. * Factory function to create the component templates only once
  3466. * @param {Function} template - component template creation function
  3467. * @param {Object} components - object containing the nested components
  3468. * @returns {TemplateChunk} template chunk object
  3469. */
  3470. function componentTemplateFactory(template, components) {
  3471. return template(create$6, expressionTypes, bindingTypes, name => {
  3472. return components[name] || COMPONENTS_IMPLEMENTATION_MAP.get(name);
  3473. });
  3474. }
  3475. /**
  3476. * Create a pure component
  3477. * @param {Function} pureFactoryFunction - pure component factory function
  3478. * @param {Array} options.slots - component slots
  3479. * @param {Array} options.attributes - component attributes
  3480. * @param {Array} options.template - template factory function
  3481. * @param {Array} options.template - template factory function
  3482. * @param {any} options.props - initial component properties
  3483. * @returns {Object} pure component object
  3484. */
  3485. function createPureComponent(pureFactoryFunction, _ref) {
  3486. let {
  3487. slots,
  3488. attributes,
  3489. props,
  3490. css,
  3491. template
  3492. } = _ref;
  3493. if (template) panic('Pure components can not have html');
  3494. if (css) panic('Pure components do not have css');
  3495. const component = defineDefaults(pureFactoryFunction({
  3496. slots,
  3497. attributes,
  3498. props
  3499. }), PURE_COMPONENT_API);
  3500. return createCoreAPIMethods(method => function () {
  3501. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  3502. args[_key] = arguments[_key];
  3503. }
  3504. // intercept the mount calls to bind the DOM node to the pure object created
  3505. // see also https://github.com/riot/riot/issues/2806
  3506. if (method === MOUNT_METHOD_KEY) {
  3507. const [el] = args;
  3508. bindDOMNodeToComponentObject(el, component);
  3509. }
  3510. component[method](...args);
  3511. return component;
  3512. });
  3513. }
  3514. /**
  3515. * Create the component interface needed for the @riotjs/dom-bindings tag bindings
  3516. * @param {string} options.css - component css
  3517. * @param {Function} options.template - functon that will return the dom-bindings template function
  3518. * @param {Object} options.exports - component interface
  3519. * @param {string} options.name - component name
  3520. * @returns {Object} component like interface
  3521. */
  3522. function createComponent(_ref2) {
  3523. let {
  3524. css,
  3525. template,
  3526. exports,
  3527. name
  3528. } = _ref2;
  3529. const templateFn = template ? componentTemplateFactory(template, exports ? createSubcomponents(exports.components) : {}) : MOCKED_TEMPLATE_INTERFACE;
  3530. return (_ref3) => {
  3531. let {
  3532. slots,
  3533. attributes,
  3534. props
  3535. } = _ref3;
  3536. // pure components rendering will be managed by the end user
  3537. if (exports && exports[IS_PURE_SYMBOL]) return createPureComponent(exports, {
  3538. slots,
  3539. attributes,
  3540. props,
  3541. css,
  3542. template
  3543. });
  3544. const componentAPI = callOrAssign(exports) || {};
  3545. const component = defineComponent({
  3546. css,
  3547. template: templateFn,
  3548. componentAPI,
  3549. name
  3550. })({
  3551. slots,
  3552. attributes,
  3553. props
  3554. }); // notice that for the components create via tag binding
  3555. // we need to invert the mount (state/parentScope) arguments
  3556. // the template bindings will only forward the parentScope updates
  3557. // and never deal with the component state
  3558. return {
  3559. mount(element, parentScope, state) {
  3560. return component.mount(element, state, parentScope);
  3561. },
  3562. update(parentScope, state) {
  3563. return component.update(state, parentScope);
  3564. },
  3565. unmount(preserveRoot) {
  3566. return component.unmount(preserveRoot);
  3567. }
  3568. };
  3569. };
  3570. }
  3571. /**
  3572. * Component definition function
  3573. * @param {Object} implementation - the componen implementation will be generated via compiler
  3574. * @param {Object} component - the component initial properties
  3575. * @returns {Object} a new component implementation object
  3576. */
  3577. function defineComponent(_ref4) {
  3578. let {
  3579. css,
  3580. template,
  3581. componentAPI,
  3582. name
  3583. } = _ref4;
  3584. // add the component css into the DOM
  3585. if (css && name) cssManager.add(name, css);
  3586. return curry(enhanceComponentAPI)(defineProperties( // set the component defaults without overriding the original component API
  3587. defineDefaults(componentAPI, Object.assign({}, COMPONENT_LIFECYCLE_METHODS, {
  3588. [STATE_KEY]: {}
  3589. })), Object.assign({
  3590. // defined during the component creation
  3591. [SLOTS_KEY]: null,
  3592. [ROOT_KEY]: null
  3593. }, COMPONENT_CORE_HELPERS, {
  3594. name,
  3595. css,
  3596. template
  3597. })));
  3598. }
  3599. /**
  3600. * Create the bindings to update the component attributes
  3601. * @param {HTMLElement} node - node where we will bind the expressions
  3602. * @param {Array} attributes - list of attribute bindings
  3603. * @returns {TemplateChunk} - template bindings object
  3604. */
  3605. function createAttributeBindings(node, attributes) {
  3606. if (attributes === void 0) {
  3607. attributes = [];
  3608. }
  3609. const expressions = attributes.map(a => create$2(node, a));
  3610. const binding = {};
  3611. return Object.assign(binding, Object.assign({
  3612. expressions
  3613. }, createCoreAPIMethods(method => scope => {
  3614. expressions.forEach(e => e[method](scope));
  3615. return binding;
  3616. })));
  3617. }
  3618. /**
  3619. * Create the subcomponents that can be included inside a tag in runtime
  3620. * @param {Object} components - components imported in runtime
  3621. * @returns {Object} all the components transformed into Riot.Component factory functions
  3622. */
  3623. function createSubcomponents(components) {
  3624. if (components === void 0) {
  3625. components = {};
  3626. }
  3627. return Object.entries(callOrAssign(components)).reduce((acc, _ref5) => {
  3628. let [key, value] = _ref5;
  3629. acc[camelToDashCase(key)] = createComponent(value);
  3630. return acc;
  3631. }, {});
  3632. }
  3633. /**
  3634. * Run the component instance through all the plugins set by the user
  3635. * @param {Object} component - component instance
  3636. * @returns {Object} the component enhanced by the plugins
  3637. */
  3638. function runPlugins(component) {
  3639. return [...PLUGINS_SET].reduce((c, fn) => fn(c) || c, component);
  3640. }
  3641. /**
  3642. * Compute the component current state merging it with its previous state
  3643. * @param {Object} oldState - previous state object
  3644. * @param {Object} newState - new state givent to the `update` call
  3645. * @returns {Object} new object state
  3646. */
  3647. function computeState(oldState, newState) {
  3648. return Object.assign({}, oldState, callOrAssign(newState));
  3649. }
  3650. /**
  3651. * Add eventually the "is" attribute to link this DOM node to its css
  3652. * @param {HTMLElement} element - target root node
  3653. * @param {string} name - name of the component mounted
  3654. * @returns {undefined} it's a void function
  3655. */
  3656. function addCssHook(element, name) {
  3657. if (getName(element) !== name) {
  3658. set(element, IS_DIRECTIVE, name);
  3659. }
  3660. }
  3661. /**
  3662. * Component creation factory function that will enhance the user provided API
  3663. * @param {Object} component - a component implementation previously defined
  3664. * @param {Array} options.slots - component slots generated via riot compiler
  3665. * @param {Array} options.attributes - attribute expressions generated via riot compiler
  3666. * @returns {Riot.Component} a riot component instance
  3667. */
  3668. function enhanceComponentAPI(component, _ref6) {
  3669. let {
  3670. slots,
  3671. attributes,
  3672. props
  3673. } = _ref6;
  3674. return autobindMethods(runPlugins(defineProperties(Object.create(component), {
  3675. mount(element, state, parentScope) {
  3676. if (state === void 0) {
  3677. state = {};
  3678. }
  3679. this[ATTRIBUTES_KEY_SYMBOL] = createAttributeBindings(element, attributes).mount(parentScope);
  3680. defineProperty(this, PROPS_KEY, Object.freeze(Object.assign({}, evaluateInitialProps(element, props), evaluateAttributeExpressions(this[ATTRIBUTES_KEY_SYMBOL].expressions))));
  3681. this[STATE_KEY] = computeState(this[STATE_KEY], state);
  3682. this[TEMPLATE_KEY_SYMBOL] = this.template.createDOM(element).clone(); // link this object to the DOM node
  3683. bindDOMNodeToComponentObject(element, this); // add eventually the 'is' attribute
  3684. component.name && addCssHook(element, component.name); // define the root element
  3685. defineProperty(this, ROOT_KEY, element); // define the slots array
  3686. defineProperty(this, SLOTS_KEY, slots); // before mount lifecycle event
  3687. this[ON_BEFORE_MOUNT_KEY](this[PROPS_KEY], this[STATE_KEY]);
  3688. this[PARENT_KEY_SYMBOL] = parentScope; // mount the template
  3689. this[TEMPLATE_KEY_SYMBOL].mount(element, this, parentScope);
  3690. this[ON_MOUNTED_KEY](this[PROPS_KEY], this[STATE_KEY]);
  3691. return this;
  3692. },
  3693. update(state, parentScope) {
  3694. if (state === void 0) {
  3695. state = {};
  3696. }
  3697. if (parentScope) {
  3698. this[PARENT_KEY_SYMBOL] = parentScope;
  3699. this[ATTRIBUTES_KEY_SYMBOL].update(parentScope);
  3700. }
  3701. const newProps = evaluateAttributeExpressions(this[ATTRIBUTES_KEY_SYMBOL].expressions);
  3702. if (this[SHOULD_UPDATE_KEY](newProps, this[PROPS_KEY]) === false) return;
  3703. defineProperty(this, PROPS_KEY, Object.freeze(Object.assign({}, this[PROPS_KEY], newProps)));
  3704. this[STATE_KEY] = computeState(this[STATE_KEY], state);
  3705. this[ON_BEFORE_UPDATE_KEY](this[PROPS_KEY], this[STATE_KEY]);
  3706. this[TEMPLATE_KEY_SYMBOL].update(this, this[PARENT_KEY_SYMBOL]);
  3707. this[ON_UPDATED_KEY](this[PROPS_KEY], this[STATE_KEY]);
  3708. return this;
  3709. },
  3710. unmount(preserveRoot) {
  3711. this[ON_BEFORE_UNMOUNT_KEY](this[PROPS_KEY], this[STATE_KEY]);
  3712. this[ATTRIBUTES_KEY_SYMBOL].unmount(); // if the preserveRoot is null the template html will be left untouched
  3713. // in that case the DOM cleanup will happen differently from a parent node
  3714. this[TEMPLATE_KEY_SYMBOL].unmount(this, this[PARENT_KEY_SYMBOL], preserveRoot === null ? null : !preserveRoot);
  3715. this[ON_UNMOUNTED_KEY](this[PROPS_KEY], this[STATE_KEY]);
  3716. return this;
  3717. }
  3718. })), Object.keys(component).filter(prop => isFunction(component[prop])));
  3719. }
  3720. /**
  3721. * Component initialization function starting from a DOM node
  3722. * @param {HTMLElement} element - element to upgrade
  3723. * @param {Object} initialProps - initial component properties
  3724. * @param {string} componentName - component id
  3725. * @returns {Object} a new component instance bound to a DOM node
  3726. */
  3727. function mountComponent(element, initialProps, componentName) {
  3728. const name = componentName || getName(element);
  3729. if (!COMPONENTS_IMPLEMENTATION_MAP.has(name)) panic(`The component named "${name}" was never registered`);
  3730. const component = COMPONENTS_IMPLEMENTATION_MAP.get(name)({
  3731. props: initialProps
  3732. });
  3733. return component.mount(element);
  3734. }
  3735. /**
  3736. * Similar to compose but performs from left-to-right function composition.<br/>
  3737. * {@link https://30secondsofcode.org/function#composeright see also}
  3738. * @param {...[function]} fns) - list of unary function
  3739. * @returns {*} result of the computation
  3740. */
  3741. /**
  3742. * Performs right-to-left function composition.<br/>
  3743. * Use Array.prototype.reduce() to perform right-to-left function composition.<br/>
  3744. * The last (rightmost) function can accept one or more arguments; the remaining functions must be unary.<br/>
  3745. * {@link https://30secondsofcode.org/function#compose original source code}
  3746. * @param {...[function]} fns) - list of unary function
  3747. * @returns {*} result of the computation
  3748. */
  3749. function compose() {
  3750. for (var _len2 = arguments.length, fns = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  3751. fns[_key2] = arguments[_key2];
  3752. }
  3753. return fns.reduce((f, g) => function () {
  3754. return f(g(...arguments));
  3755. });
  3756. }
  3757. const {
  3758. DOM_COMPONENT_INSTANCE_PROPERTY: DOM_COMPONENT_INSTANCE_PROPERTY$1,
  3759. COMPONENTS_IMPLEMENTATION_MAP: COMPONENTS_IMPLEMENTATION_MAP$1,
  3760. PLUGINS_SET: PLUGINS_SET$1
  3761. } = globals;
  3762. /**
  3763. * Riot public api
  3764. */
  3765. /**
  3766. * Register a custom tag by name
  3767. * @param {string} name - component name
  3768. * @param {Object} implementation - tag implementation
  3769. * @returns {Map} map containing all the components implementations
  3770. */
  3771. function register(name, _ref) {
  3772. let {
  3773. css,
  3774. template,
  3775. exports
  3776. } = _ref;
  3777. if (COMPONENTS_IMPLEMENTATION_MAP$1.has(name)) panic(`The component "${name}" was already registered`);
  3778. COMPONENTS_IMPLEMENTATION_MAP$1.set(name, createComponent({
  3779. name,
  3780. css,
  3781. template,
  3782. exports
  3783. }));
  3784. return COMPONENTS_IMPLEMENTATION_MAP$1;
  3785. }
  3786. /**
  3787. * Unregister a riot web component
  3788. * @param {string} name - component name
  3789. * @returns {Map} map containing all the components implementations
  3790. */
  3791. function unregister(name) {
  3792. if (!COMPONENTS_IMPLEMENTATION_MAP$1.has(name)) panic(`The component "${name}" was never registered`);
  3793. COMPONENTS_IMPLEMENTATION_MAP$1.delete(name);
  3794. cssManager.remove(name);
  3795. return COMPONENTS_IMPLEMENTATION_MAP$1;
  3796. }
  3797. /**
  3798. * Mounting function that will work only for the components that were globally registered
  3799. * @param {string|HTMLElement} selector - query for the selection or a DOM element
  3800. * @param {Object} initialProps - the initial component properties
  3801. * @param {string} name - optional component name
  3802. * @returns {Array} list of nodes upgraded
  3803. */
  3804. function mount(selector, initialProps, name) {
  3805. return $(selector).map(element => mountComponent(element, initialProps, name));
  3806. }
  3807. /**
  3808. * Sweet unmounting helper function for the DOM node mounted manually by the user
  3809. * @param {string|HTMLElement} selector - query for the selection or a DOM element
  3810. * @param {boolean|null} keepRootElement - if true keep the root element
  3811. * @returns {Array} list of nodes unmounted
  3812. */
  3813. function unmount(selector, keepRootElement) {
  3814. return $(selector).map(element => {
  3815. if (element[DOM_COMPONENT_INSTANCE_PROPERTY$1]) {
  3816. element[DOM_COMPONENT_INSTANCE_PROPERTY$1].unmount(keepRootElement);
  3817. }
  3818. return element;
  3819. });
  3820. }
  3821. /**
  3822. * Define a riot plugin
  3823. * @param {Function} plugin - function that will receive all the components created
  3824. * @returns {Set} the set containing all the plugins installed
  3825. */
  3826. function install(plugin) {
  3827. if (!isFunction(plugin)) panic('Plugins must be of type function');
  3828. if (PLUGINS_SET$1.has(plugin)) panic('This plugin was already installed');
  3829. PLUGINS_SET$1.add(plugin);
  3830. return PLUGINS_SET$1;
  3831. }
  3832. /**
  3833. * Uninstall a riot plugin
  3834. * @param {Function} plugin - plugin previously installed
  3835. * @returns {Set} the set containing all the plugins installed
  3836. */
  3837. function uninstall(plugin) {
  3838. if (!PLUGINS_SET$1.has(plugin)) panic('This plugin was never installed');
  3839. PLUGINS_SET$1.delete(plugin);
  3840. return PLUGINS_SET$1;
  3841. }
  3842. /**
  3843. * Helper method to create component without relying on the registered ones
  3844. * @param {Object} implementation - component implementation
  3845. * @returns {Function} function that will allow you to mount a riot component on a DOM node
  3846. */
  3847. function component(implementation) {
  3848. return function (el, props, _temp) {
  3849. let {
  3850. slots,
  3851. attributes,
  3852. parentScope
  3853. } = _temp === void 0 ? {} : _temp;
  3854. return compose(c => c.mount(el, parentScope), c => c({
  3855. props,
  3856. slots,
  3857. attributes
  3858. }), createComponent)(implementation);
  3859. };
  3860. }
  3861. /**
  3862. * Lift a riot component Interface into a pure riot object
  3863. * @param {Function} func - RiotPureComponent factory function
  3864. * @returns {Function} the lifted original function received as argument
  3865. */
  3866. function pure(func) {
  3867. if (!isFunction(func)) panic('riot.pure accepts only arguments of type "function"');
  3868. func[IS_PURE_SYMBOL] = true;
  3869. return func;
  3870. }
  3871. /** @type {string} current riot version */
  3872. const version = 'v5.1.1'; // expose some internal stuff that might be used from external tools
  3873. const __ = {
  3874. cssManager,
  3875. DOMBindings,
  3876. createComponent,
  3877. defineComponent,
  3878. globals
  3879. };
  3880. /***/ }),
  3881. /***/ "./resources/js/bootstrap.js":
  3882. /*!***********************************!*\
  3883. !*** ./resources/js/bootstrap.js ***!
  3884. \***********************************/
  3885. /*! no static exports found */
  3886. /***/ (function(module, exports, __webpack_require__) {
  3887. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  3888. window.riot = __webpack_require__(/*! riot */ "./node_modules/riot/riot.esm.js");
  3889. /***/ }),
  3890. /***/ "./resources/scss/bootstrap.scss":
  3891. /*!***************************************!*\
  3892. !*** ./resources/scss/bootstrap.scss ***!
  3893. \***************************************/
  3894. /*! no static exports found */
  3895. /***/ (function(module, exports) {
  3896. // removed by extract-text-webpack-plugin
  3897. /***/ }),
  3898. /***/ 0:
  3899. /*!*************************************************************************!*\
  3900. !*** multi ./resources/js/bootstrap.js ./resources/scss/bootstrap.scss ***!
  3901. \*************************************************************************/
  3902. /*! no static exports found */
  3903. /***/ (function(module, exports, __webpack_require__) {
  3904. __webpack_require__(/*! /home/herrhase/Workspace/herrhase/urban-filehub/resources/js/bootstrap.js */"./resources/js/bootstrap.js");
  3905. module.exports = __webpack_require__(/*! /home/herrhase/Workspace/herrhase/urban-filehub/resources/scss/bootstrap.scss */"./resources/scss/bootstrap.scss");
  3906. /***/ })
  3907. /******/ });