Created
December 29, 2025 03:40
-
-
Save ribeiroeder/5a17e244076bd854c758d6a2e1cdeae6 to your computer and use it in GitHub Desktop.
header-project-to-slim
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /******/ (function() { // webpackBootstrap | |
| /******/ var __webpack_modules__ = ({ | |
| /***/ "./src/components/common/error-boundary/index.js": | |
| /*!*******************************************************!*\ | |
| !*** ./src/components/common/error-boundary/index.js ***! | |
| \*******************************************************/ | |
| /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| "use strict"; | |
| __webpack_require__.r(__webpack_exports__); | |
| /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); | |
| /* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "./node_modules/prop-types/index.js"); | |
| /* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); | |
| /** | |
| * Error Boundary component (React 16) | |
| */ | |
| class ErrorBoundary extends react__WEBPACK_IMPORTED_MODULE_0__.Component { | |
| /** | |
| * Constructor | |
| * | |
| * @param {Object} props | |
| */ | |
| constructor(props) { | |
| super(props); | |
| this.state = { | |
| hasError: false | |
| }; | |
| } | |
| /** | |
| * To catch errors | |
| * | |
| * @param {Object} error | |
| * @param {Object} info | |
| */ | |
| componentDidCatch(error, info) { | |
| // Display fallback UI | |
| this.setState({ | |
| hasError: true, | |
| error, | |
| info | |
| }); | |
| // You can also log the error to an error reporting service | |
| // console.log( error, info ); | |
| } | |
| /** | |
| * Render child error message or components | |
| */ | |
| render() { | |
| if (this.state.hasError) { | |
| // You can render any custom fallback UI | |
| return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { | |
| className: this.props.className | |
| }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h2", null, this.props.message)); | |
| } | |
| return this.props.children; | |
| } | |
| } | |
| /** | |
| * Valid props | |
| */ | |
| ErrorBoundary.propTypes = { | |
| children: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().node.isRequired), | |
| message: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string.isRequired), | |
| className: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string) | |
| }; | |
| /** | |
| * When a prop is not passed down by the parent component. | |
| */ | |
| ErrorBoundary.defaultProps = { | |
| message: `${LearnDashData.i18n.error}`, | |
| className: '' | |
| }; | |
| /* harmony default export */ __webpack_exports__["default"] = (ErrorBoundary); | |
| /***/ }), | |
| /***/ "./src/components/common/icon/index.js": | |
| /*!*********************************************!*\ | |
| !*** ./src/components/common/icon/index.js ***! | |
| \*********************************************/ | |
| /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| "use strict"; | |
| __webpack_require__.r(__webpack_exports__); | |
| /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); | |
| /* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "./node_modules/prop-types/index.js"); | |
| /* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); | |
| /** | |
| * Displays SVG Icon | |
| * | |
| * @param {Object} props | |
| * @param {string} props.icon | |
| * @param {string} props.stroke | |
| */ | |
| const Icon = _ref => { | |
| let { | |
| icon, | |
| stroke | |
| } = _ref; | |
| if ('plus' === icon) { | |
| return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", { | |
| width: "256", | |
| height: "256", | |
| viewBox: "0 0 256 256", | |
| xmlns: "http://www.w3.org/2000/svg" | |
| }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { | |
| d: "M185.066 128c0 3.534-2.866 6-6.4 6H134v44.666c0 3.534-2.467 6.399-6 6.399-3.534 0-6-2.865-6-6.399V134H77.332c-3.535 0-6.4-2.466-6.4-6s2.866-6 6.4-6H122V77.331c0-3.534 2.466-6.4 6-6.4 3.533 0 6 2.866 6 6.4V122h44.666c3.534 0 6.4 2.466 6.4 6zM256 128C256 57.42 198.58 0 128 0S0 57.42 0 128s57.42 128 128 128 128-57.42 128-128zm-12.8 0c0 63.521-51.679 115.2-115.2 115.2-63.522 0-115.2-51.679-115.2-115.2C12.8 64.478 64.478 12.8 128 12.8c63.521 0 115.2 51.678 115.2 115.2z", | |
| fillRule: "nonzero" | |
| })); | |
| } else if ('drag' === icon) { | |
| return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", { | |
| width: "10", | |
| height: "6", | |
| xmlns: "http://www.w3.org/2000/svg", | |
| viewBox: "4 6 10 6", | |
| role: "img", | |
| "aria-hidden": "true", | |
| focusable: "false" | |
| }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { | |
| d: "M13,8c0.6,0,1-0.4,1-1s-0.4-1-1-1s-1,0.4-1,1S12.4,8,13,8z M5,6C4.4,6,4,6.4,4,7s0.4,1,1,1s1-0.4,1-1S5.6,6,5,6z M5,10 c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S5.6,10,5,10z M13,10c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S13.6,10,13,10z M9,6 C8.4,6,8,6.4,8,7s0.4,1,1,1s1-0.4,1-1S9.6,6,9,6z M9,10c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S9.6,10,9,10z" | |
| })); | |
| } else if ('chevron-up' === icon) { | |
| return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", { | |
| width: "12", | |
| height: "7", | |
| xmlns: "http://www.w3.org/2000/svg", | |
| viewBox: "3.3 4.5 11.4 7", | |
| role: "img", | |
| "aria-hidden": "true", | |
| focusable: "false" | |
| }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("polygon", { | |
| points: "9,4.5 3.3,10.1 4.8,11.5 9,7.3 13.2,11.5 14.7,10.1 " | |
| })); | |
| } else if ('chevron-down' === icon) { | |
| return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", { | |
| width: "12", | |
| height: "7", | |
| xmlns: "http://www.w3.org/2000/svg", | |
| viewBox: "3.3 6.5 11.4 7", | |
| role: "img", | |
| "aria-hidden": "true", | |
| focusable: "false" | |
| }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("polygon", { | |
| points: "9,13.5 14.7,7.9 13.2,6.5 9,10.7 4.8,6.5 3.3,7.9 " | |
| })); | |
| } else if ('chevron-right' === icon) { | |
| return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", { | |
| focusable: "false", | |
| xmlns: "http://www.w3.org/2000/svg", | |
| width: "7", | |
| height: "11.4", | |
| viewBox: "5.8 2.3 7 11.4" | |
| }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("polygon", { | |
| points: "12.8,8 7.2,2.3 5.8,3.8 10,8 5.8,12.2 7.2,13.7 " | |
| })); | |
| } else if ('pencil' === icon) { | |
| return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", { | |
| xmlns: "http://www.w3.org/2000/svg", | |
| viewBox: "0 0 20 20", | |
| width: "16", | |
| height: "16", | |
| className: "edit-svg" | |
| }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("rect", { | |
| x: "0", | |
| fill: "none", | |
| width: "20", | |
| height: "20" | |
| }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("g", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { | |
| d: "M13.89 3.39l2.71 2.72c.46.46.42 1.24.03 1.64l-8.01 8.02-5.56 1.16 1.16-5.58s7.6-7.63 7.99-8.03c.39-.39 1.22-.39 1.68.07zm-2.73 2.79l-5.59 5.61 1.11 1.11 5.54-5.65zm-2.97 8.23l5.58-5.6-1.07-1.08-5.59 5.6z" | |
| }))); | |
| } else if ('undo' === icon) { | |
| return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", { | |
| xmlns: "http://www.w3.org/2000/svg", | |
| width: "24", | |
| height: "24", | |
| viewBox: "0 0 24 24" | |
| }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { | |
| d: "M0 0h24v24H0z", | |
| fill: "none" | |
| }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { | |
| d: "M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z" | |
| })); | |
| } else if ('dropdown' === icon) { | |
| return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", { | |
| width: "11", | |
| height: "8", | |
| viewBox: "0 0 14 8", | |
| xmlns: "http://www.w3.org/2000/svg" | |
| }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { | |
| d: "M1 1l6 6 6-6", | |
| stroke: stroke ? stroke : '#006799', | |
| strokeWidth: "2", | |
| fill: "none", | |
| fillRule: "evenodd", | |
| strokeLinecap: "round", | |
| strokeLinejoin: "round" | |
| })); | |
| } else if ('warning' === icon) { | |
| return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", { | |
| xmlns: "http://www.w3.org/2000/svg", | |
| x: "0", | |
| y: "0", | |
| width: "554.2", | |
| height: "554.199", | |
| viewBox: "0 0 554.2 554.199" | |
| }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("title", null, `${LearnDashData.i18n.question_data_invalid}`), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { | |
| d: "M538.5,386.199L356.5,70.8c-16.4-28.4-46.7-45.9-79.501-45.9c-32.8,0-63.1,17.5-79.5,45.9L12.3,391.6 c-16.4,28.4-16.4,63.4,0,91.8C28.7,511.8,59,529.3,91.8,529.3H462.2c0.101,0,0.2,0,0.2,0c50.7,0,91.8-41.101,91.8-91.8 C554.2,418.5,548.4,400.8,538.5,386.199z M316.3,416.899c0,21.7-16.7,38.3-39.2,38.3s-39.2-16.6-39.2-38.3V416 c0-21.601,16.7-38.301,39.2-38.301S316.3,394.3,316.3,416V416.899z M317.2,158.7L297.8,328.1c-1.3,12.2-9.4,19.8-20.7,19.8 s-19.4-7.7-20.7-19.8L237,158.6c-1.3-13.1,5.801-23,18-23H299.1C311.3,135.7,318.5,145.6,317.2,158.7z" | |
| })); | |
| } | |
| return null; | |
| }; | |
| /** | |
| * Valid props | |
| */ | |
| Icon.propTypes = { | |
| icon: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), | |
| stroke: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string) | |
| }; | |
| /* harmony default export */ __webpack_exports__["default"] = (Icon); | |
| /***/ }), | |
| /***/ "./src/components/header/global-header/index.js": | |
| /*!******************************************************!*\ | |
| !*** ./src/components/header/global-header/index.js ***! | |
| \******************************************************/ | |
| /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| "use strict"; | |
| __webpack_require__.r(__webpack_exports__); | |
| /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); | |
| /* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "./node_modules/react-dom/index.js"); | |
| /* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! prop-types */ "./node_modules/prop-types/index.js"); | |
| /* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_4__); | |
| /* harmony import */ var _tabs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../tabs */ "./src/components/header/tabs/index.js"); | |
| /* harmony import */ var _post_title__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../post-title */ "./src/components/header/post-title/index.js"); | |
| // If in post editor screen | |
| if (document.location.href.includes('post.php') || document.location.href.includes('post-new.php')) { | |
| // Hook into Gutenberg Middleware | |
| if (wp.apiFetch) { | |
| wp.apiFetch.use((options, next) => { | |
| // Getting the course_id value from query params using regular expressions | |
| const re = new RegExp('([?&])course_id=.*?(&|$)', 'i'); | |
| const uri = window.location.href; | |
| const match = uri.match(re); | |
| const course_id = match && match[0] && match[0].substring(11); | |
| if (course_id && options && options.data) { | |
| // Pass course_id to POST data | |
| options.data.course_id = course_id; | |
| } | |
| const result = next(options); | |
| return result; | |
| }); | |
| } | |
| } | |
| /** | |
| * Display top level header on the page. | |
| * | |
| * @param {Object} props | |
| * @param {string} props.el | |
| */ | |
| const GlobalHeader = _ref => { | |
| let { | |
| el | |
| } = _ref; | |
| if (document.getElementById(el)) { | |
| let post_type = null; | |
| if (LearnDashData.post_data) { | |
| post_type = LearnDashData.post_data.builder_post_type; | |
| } | |
| let url = `${LearnDashData.adminurl}?post_type=${post_type}`; | |
| let title = `${LearnDashData.i18n.back_to} ${LearnDashData.labels[post_type]}`; | |
| if (LearnDashData.back_to_title) { | |
| title = LearnDashData.back_to_title; | |
| } | |
| if (LearnDashData.back_to_url) { | |
| url = LearnDashData.back_to_url; | |
| } | |
| return /*#__PURE__*/react_dom__WEBPACK_IMPORTED_MODULE_1__.createPortal( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { | |
| className: "ld-global-header edit-post-header" | |
| }, LearnDashData.post_data && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { | |
| className: "ld-global-header-title-area" | |
| }, LearnDashData.back_to_title && LearnDashData.back_to_url && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("a", { | |
| href: url, | |
| className: "ld-back-link" | |
| }, "\u2190 ", title), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_post_title__WEBPACK_IMPORTED_MODULE_3__["default"], null)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_tabs__WEBPACK_IMPORTED_MODULE_2__["default"], null)), document.getElementById(el)); | |
| } | |
| return null; | |
| }; | |
| /** | |
| * Valid props | |
| */ | |
| GlobalHeader.propTypes = { | |
| el: (prop_types__WEBPACK_IMPORTED_MODULE_4___default().string) | |
| }; | |
| /* harmony default export */ __webpack_exports__["default"] = (GlobalHeader); | |
| /***/ }), | |
| /***/ "./src/components/header/post-title/index.js": | |
| /*!***************************************************!*\ | |
| !*** ./src/components/header/post-title/index.js ***! | |
| \***************************************************/ | |
| /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| "use strict"; | |
| __webpack_require__.r(__webpack_exports__); | |
| /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); | |
| /** | |
| * Render post title in the Entity Header | |
| */ | |
| class PostTitle extends react__WEBPACK_IMPORTED_MODULE_0__.PureComponent { | |
| /** | |
| * Constructor | |
| * | |
| * @param {Object} props | |
| */ | |
| constructor(props) { | |
| super(props); | |
| /** | |
| * Post title data | |
| */ | |
| this.state = { | |
| original_post_title: LearnDashData.post_data ? LearnDashData.post_data.builder_post_title : '', | |
| post_title: LearnDashData.post_data ? LearnDashData.post_data.builder_post_title : '' | |
| }; | |
| } | |
| /** | |
| * Update header title when updating title in Gutenberg or classic editor | |
| */ | |
| componentDidMount() { | |
| const self = this; | |
| // Look for changes in #editor in Gutenberg | |
| const editorContainer = document.getElementById('editor'); | |
| if (editorContainer) { | |
| const observer = new MutationObserver(() => { | |
| const titleField = editorContainer.querySelector('.editor-post-title__input'); | |
| if (titleField) { | |
| titleField.addEventListener('input', function (e) { | |
| const { | |
| target | |
| } = e; | |
| const newValue = target.value ?? target.textContent; | |
| self.setState({ | |
| post_title: newValue | |
| }); | |
| }); | |
| observer.disconnect(); | |
| } | |
| }); | |
| const observerConfig = { | |
| attributes: true, | |
| childList: true, | |
| characterData: false | |
| }; | |
| observer.observe(editorContainer, observerConfig); | |
| } else { | |
| const titleFieldClassic = document.getElementById('title'); | |
| if (titleFieldClassic) { | |
| titleFieldClassic.addEventListener('input', function (e) { | |
| self.setState({ | |
| post_title: e.target.value | |
| }); | |
| }); | |
| } | |
| } | |
| } | |
| /** | |
| * Render the post title component | |
| */ | |
| render() { | |
| const { | |
| original_post_title, | |
| post_title | |
| } = this.state; | |
| return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h1", { | |
| dangerouslySetInnerHTML: { | |
| __html: '' !== post_title ? post_title : original_post_title | |
| } | |
| }); | |
| } | |
| } | |
| /* harmony default export */ __webpack_exports__["default"] = (PostTitle); | |
| /***/ }), | |
| /***/ "./src/components/header/tabs/index.js": | |
| /*!*********************************************!*\ | |
| !*** ./src/components/header/tabs/index.js ***! | |
| \*********************************************/ | |
| /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| "use strict"; | |
| __webpack_require__.r(__webpack_exports__); | |
| /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); | |
| /* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! prop-types */ "./node_modules/prop-types/index.js"); | |
| /* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_3__); | |
| /* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); | |
| /* harmony import */ var _common_icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../common/icon */ "./src/components/common/icon/index.js"); | |
| function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | |
| function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | |
| function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | |
| function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | |
| function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | |
| /* eslint-disable @wordpress/no-global-event-listener */ | |
| /** | |
| * Render tabs in the Entity Header | |
| */ | |
| class Tabs extends react__WEBPACK_IMPORTED_MODULE_0__.PureComponent { | |
| /** | |
| * Constructor | |
| * | |
| * @param {Object} props | |
| */ | |
| constructor(props) { | |
| super(props); | |
| // If there is a currentTab defined, use the currentTab ID, if not, use the first tab. | |
| let activeTab; | |
| if ('' === this.props.data.currentTab) { | |
| if (0 < this.props.data.tabs.length) { | |
| activeTab = this.props.data.tabs[0].id; | |
| } else { | |
| activeTab = ''; | |
| } | |
| } else { | |
| activeTab = this.props.data.currentTab; | |
| } | |
| /** | |
| * Tabs data | |
| */ | |
| this.state = { | |
| currentTab: activeTab, | |
| tabs: this.props.data.tabs || [], | |
| popover: false, | |
| addNewEntityButton: null | |
| }; | |
| this.dropdownRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createRef(); | |
| this.handleTabClick = this.handleTabClick.bind(this); | |
| this.handleActions = this.handleActions.bind(this); | |
| this.handleClickOutside = this.handleClickOutside.bind(this); | |
| this.showMetaboxesDocumentSidebar = this.showMetaboxesDocumentSidebar.bind(this); | |
| } | |
| /** | |
| * Hide all tabs except the first | |
| * Add mousedown event | |
| */ | |
| componentDidMount() { | |
| const { | |
| tabs, | |
| currentTab, | |
| addNewEntityButton | |
| } = this.state; | |
| if (addNewEntityButton === null) { | |
| this.setState({ | |
| addNewEntityButton: document.querySelector('.page-title-actionn') | |
| }); | |
| } | |
| // The page has tabs, add a class to body to push down Gutenberg if needed | |
| if (0 !== tabs.length) { | |
| document.body.classList.add('ld-header-has-tabs'); | |
| } | |
| // Look for changes in #editor in Gutenberg | |
| const editorContainer = document.getElementById('editor'); | |
| if (editorContainer) { | |
| const observer = new MutationObserver(() => { | |
| const editor = document.querySelector('.edit-post-visual-editor'); | |
| if (editor) { | |
| editor.id = 'post-body-content'; | |
| editor.classList.add('tab-content'); | |
| observer.disconnect(); | |
| } | |
| }); | |
| const observerConfig = { | |
| attributes: false, | |
| childList: true, | |
| characterData: false | |
| }; | |
| observer.observe(editorContainer, observerConfig); | |
| } | |
| // Add necessary class to Gutenberg editor | |
| window.addEventListener('load', () => { | |
| tabs.forEach(tab => { | |
| const tabEl = document.querySelector('#' + tab.id); | |
| if (tabEl) { | |
| tabEl.classList.add('tab-content'); | |
| // Hide all tabs except the current tab | |
| if (tab.id !== currentTab) { | |
| tabEl.setAttribute('aria-hidden', true); | |
| } | |
| } | |
| }); | |
| document.body.classList.add('ld-tabs-ready'); | |
| // Initialize Metaboxes | |
| this.showMetaboxesDocumentSidebar(currentTab); | |
| }); | |
| // Set active tab data | |
| if ('' !== currentTab) { | |
| document.body.setAttribute('data-active-tab', currentTab); | |
| } | |
| document.addEventListener('mousedown', this.handleClickOutside); | |
| } | |
| /** | |
| * Remove mousedown event | |
| */ | |
| componentWillUnmount() { | |
| document.removeEventListener('mousedown', this.handleClickOutside); | |
| } | |
| /** | |
| * Handle Actions click | |
| */ | |
| handleActions() { | |
| this.setState(_ref => { | |
| let { | |
| popover | |
| } = _ref; | |
| return { | |
| popover: !popover | |
| }; | |
| }); | |
| } | |
| /** | |
| * Handle clicking on DOM | |
| * | |
| * @param {handleClickOutside} e | |
| */ | |
| handleClickOutside(e) { | |
| if (this.dropdownRef.current && !this.dropdownRef.current.contains(e.target)) { | |
| this.setState(() => ({ | |
| popover: false | |
| })); | |
| } | |
| } | |
| /** | |
| * Switch tab on button click | |
| * | |
| * @param {handleTabClick} e | |
| */ | |
| handleTabClick(e) { | |
| e.preventDefault(); | |
| const { | |
| tabs | |
| } = this.state; | |
| const { | |
| target | |
| } = e; | |
| const controlledTab = target.getAttribute('aria-controls'); | |
| if (controlledTab) { | |
| document.body.setAttribute('data-active-tab', controlledTab); | |
| if (document.querySelector('button[data-label="Document"]')) { | |
| document.querySelector('button[data-label="Document"]').click(); | |
| } | |
| this.showMetaboxesDocumentSidebar(controlledTab); | |
| } else { | |
| document.body.removeAttribute('data-active-tab'); | |
| } | |
| this.setState({ | |
| currentTab: controlledTab | |
| }); | |
| tabs.forEach(tab => { | |
| const tabEl = document.querySelector('#' + tab.id); | |
| if (tabEl) { | |
| if (tab.id !== controlledTab) { | |
| tabEl.setAttribute('aria-hidden', true); | |
| } else { | |
| tabEl.setAttribute('aria-hidden', false); | |
| } | |
| } | |
| }); | |
| // Get last bit of URL including query strings. | |
| const lastPartOfUrl = window.location.href.substr(window.location.href.lastIndexOf('/') + 1); | |
| // Get the currentTab. | |
| let selectedTab = this.state.tabs && this.state.tabs.filter(tab => controlledTab === tab.id); | |
| selectedTab = selectedTab[0] ? selectedTab[0].id : null; | |
| // Set the URL with currentTab. Refreshing will preserve the current tab. | |
| // replaceState() modifies the current history entry instead of creating a new one. | |
| window.history.replaceState({}, '', this.updateQueryStringParameter(lastPartOfUrl, 'currentTab', selectedTab)); | |
| // Set the selectedTab value to ld_post_edit_current_tab input field | |
| const ld_post_edit_current_tab = document.getElementById('ld_post_edit_current_tab'); | |
| if (ld_post_edit_current_tab) { | |
| ld_post_edit_current_tab.value = selectedTab; | |
| } | |
| try { | |
| window.scrollTo(0, 0); | |
| } catch (e) { | |
| // unsupported browser | |
| } | |
| } | |
| /** | |
| * Update or Add a Query String Param | |
| * | |
| * @param {string} uri | |
| * @param {string} key | |
| * @param {string} value | |
| */ | |
| updateQueryStringParameter(uri, key, value) { | |
| const re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i'); | |
| const separator = -1 !== uri.indexOf('?') ? '&' : '?'; | |
| if (uri.match(re)) { | |
| if (value) { | |
| return uri.replace(re, '$1' + key + '=' + value + '$2'); | |
| } | |
| return uri.replace(re, ''); | |
| } | |
| return uri + separator + key + '=' + value; | |
| } | |
| /** | |
| * Hide all existing Metaboxes and only show the ones that are needed on a particular tab | |
| * Show the Document Sidebar only when needed | |
| * | |
| * @param {number} controlledTab | |
| */ | |
| showMetaboxesDocumentSidebar(controlledTab) { | |
| // Only run code on post edit screens - because these pages don't reload when changing tabs | |
| if (document.location.href.includes('post.php') || document.location.href.includes('post-new.php')) { | |
| // Get all known metaboxes via the LearnDashData var onto an array | |
| let allKnownMetaboxes = []; | |
| if (LearnDashData.tabs) { | |
| LearnDashData.tabs.forEach(tab => { | |
| if (tab.metaboxes) { | |
| allKnownMetaboxes = [...allKnownMetaboxes, ...tab.metaboxes]; | |
| } | |
| }); | |
| } | |
| // Get Metabox containers in WordPress | |
| const metaboxesParents = document.querySelectorAll('#normal-sortables,#advanced-sortables'); | |
| // Loop through the two Metabox containers | |
| for (const parent of metaboxesParents) { | |
| // Hide all existing Metaboxes in the screen | |
| let currentMetaboxes = parent.querySelectorAll('.postbox:not(.tab-content)'); | |
| // Converting NodeList to Array to make it work on IE | |
| currentMetaboxes = currentMetaboxes && Array.from(currentMetaboxes); | |
| if (currentMetaboxes) { | |
| currentMetaboxes.forEach(metabox => { | |
| metabox.style.display = 'none'; | |
| }); | |
| } | |
| let firstTab = this.state.tabs && this.state.tabs.filter((tab, index) => 0 === index); | |
| firstTab = firstTab[0] ? firstTab[0].id : null; | |
| // If selected tab is the 'Courses page' tab | |
| if (firstTab === controlledTab) { | |
| if (currentMetaboxes) { | |
| currentMetaboxes.forEach(metabox => { | |
| // Show metaboxes that are not known | |
| if (!allKnownMetaboxes.includes(metabox.id)) metabox.style.display = 'block'; | |
| }); | |
| } | |
| } | |
| } | |
| } | |
| // Show only relevant Metaboxes and hide Document Sidebar when not needed | |
| this.state.tabs.forEach(tab => { | |
| if (controlledTab === tab.id) { | |
| if (tab.metaboxes) { | |
| tab.metaboxes.forEach(metabox => { | |
| const selectedMetabox = document.getElementById(metabox); | |
| if (selectedMetabox) { | |
| selectedMetabox.style.display = 'block'; | |
| } | |
| }); | |
| } | |
| // Get reference to .edit-post-sidebar and .edit-post-layout__content elements | |
| const documentSidebar = document.querySelector('.interface-interface-skeleton__sidebar'); | |
| const gearIcon = document.querySelector('.components-button.components-icon-button[aria-label="Settings"]'); | |
| const noticeList = document.querySelector('.edit-post-layout.is-sidebar-opened .components-notice-list'); | |
| // If elements exist and if sidebar is to be hidden | |
| if (documentSidebar && tab.showDocumentSidebar && 'false' === tab.showDocumentSidebar) { | |
| documentSidebar.style.display = 'none'; | |
| if (gearIcon) { | |
| gearIcon.style.display = 'none'; | |
| } | |
| if (noticeList) { | |
| noticeList.style.right = 0; | |
| } | |
| } else if (documentSidebar) { | |
| documentSidebar.style.display = 'block'; | |
| if (gearIcon) { | |
| gearIcon.style.display = null; | |
| } | |
| if (noticeList) { | |
| noticeList.style.right = null; | |
| } | |
| } | |
| } | |
| }); | |
| } | |
| /** | |
| * Render the tabs component | |
| * | |
| * @event handleClickOutside | |
| * @event handleTabClick | |
| */ | |
| render() { | |
| const { | |
| tabs, | |
| currentTab, | |
| popover, | |
| addNewEntityButton | |
| } = this.state; | |
| const currentTabObject = tabs.filter(tab => currentTab === tab.id)[0] || tabs[0]; | |
| const hasActions = currentTabObject && 'actions' in currentTabObject && 0 !== currentTabObject.actions.length; | |
| if (0 !== tabs.length) { | |
| if (addNewEntityButton) { | |
| addNewEntityButton.remove(); | |
| } | |
| return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { | |
| className: "ld-global-header-new-settings" | |
| }, addNewEntityButton && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("a", { | |
| href: addNewEntityButton.href, | |
| className: `global-new-entity-button ${hasActions ? '' : '-right'}` | |
| }, addNewEntityButton.innerText), hasActions && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { | |
| className: "edit-post-header__settings", | |
| ref: this.dropdownRef | |
| }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("button", { | |
| className: "is-button components-button ld-actions button", | |
| onClick: this.handleActions, | |
| "aria-haspopup": "true", | |
| "aria-expanded": popover | |
| }, LearnDashData.i18n.actions, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_common_icon__WEBPACK_IMPORTED_MODULE_2__["default"], { | |
| icon: "dropdown" | |
| })), popover && currentTabObject.actions && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { | |
| className: "components-popover edit-post-more-menu__content is-bottom is-left ld-popover" | |
| }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { | |
| className: "components-popover__content" | |
| }, currentTabObject.actions.map((action, index) => { | |
| // Checking if current URL is equal to link | |
| // Also checking if the URL (converted to &) contains the link | |
| const isActive = document.URL === action.link || 0 < document.URL.replace('&', '&').indexOf(action.link); | |
| const activeClassName = isActive ? ' active' : ''; | |
| return 'true' === action.isCallback ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("button", { | |
| key: `action-${index}`, | |
| id: action.id ? `action-${action.id}` : false, | |
| className: `${action.classNames && action.classNames.length ? action.classNames.join(' ') : ''} components-menu-item__button components-button${activeClassName}`, | |
| onClick: Function(action.callback) | |
| }, action.title) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("a", { | |
| key: `action-${index}`, | |
| id: action.id ? `action-${action.id}` : undefined, | |
| href: action.link.replace(/&/g, '&'), | |
| target: 'true' === action.isExternal ? '_blank' : '', | |
| rel: `noreferrer noopener`, | |
| className: `${action.classNames && action.classNames.length ? action.classNames.join(' ') : ''} components-menu-item__button components-button${activeClassName}` | |
| }, action.title); | |
| }))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { | |
| className: "ld-tab-buttons" | |
| }, tabs.map((tab, index) => 'true' === tab.isExternal ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("a", { | |
| key: `tab-button-${index}`, | |
| id: tab.id ? `tab-${tab.id}` : false, | |
| href: tab.link.replace(/&/g, '&'), | |
| className: `is-button button components-button ${tab.id === currentTab ? 'is-primary' : ''}`, | |
| dangerouslySetInnerHTML: { | |
| __html: tab.name | |
| } | |
| }) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("button", { | |
| key: `tab-button-${index}`, | |
| id: tab.id ? `tab-${tab.id}` : false, | |
| onClick: this.handleTabClick, | |
| "aria-controls": tab.id, | |
| "data-index": index, | |
| className: `is-button button components-button ${tab.id === currentTab ? 'is-primary' : ''}`, | |
| dangerouslySetInnerHTML: { | |
| __html: tab.name | |
| } | |
| })))); | |
| } | |
| return null; | |
| } | |
| } | |
| /** | |
| * Valid props | |
| */ | |
| Tabs.propTypes = { | |
| data: (prop_types__WEBPACK_IMPORTED_MODULE_3___default().object) | |
| }; | |
| /** | |
| * | |
| * @param {*} state | |
| */ | |
| const mapStateToProps = state => _objectSpread({}, state); | |
| /** | |
| * | |
| */ | |
| const mapDispatchToProps = () => ({}); | |
| /* harmony default export */ __webpack_exports__["default"] = ((0,react_redux__WEBPACK_IMPORTED_MODULE_1__.connect)(mapStateToProps, mapDispatchToProps)(Tabs)); | |
| /***/ }), | |
| /***/ "./src/constants/index.js": | |
| /*!********************************!*\ | |
| !*** ./src/constants/index.js ***! | |
| \********************************/ | |
| /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| "use strict"; | |
| __webpack_require__.r(__webpack_exports__); | |
| /* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| /* harmony export */ "ADD_ANSWER_ENTITY": function() { return /* binding */ ADD_ANSWER_ENTITY; }, | |
| /* harmony export */ "ADD_FINAL_QUIZ_ENTITY": function() { return /* binding */ ADD_FINAL_QUIZ_ENTITY; }, | |
| /* harmony export */ "ADD_LESSON": function() { return /* binding */ ADD_LESSON; }, | |
| /* harmony export */ "ADD_LESSON_ENTITY": function() { return /* binding */ ADD_LESSON_ENTITY; }, | |
| /* harmony export */ "ADD_QUESTION": function() { return /* binding */ ADD_QUESTION; }, | |
| /* harmony export */ "ADD_QUESTION_ENTITY": function() { return /* binding */ ADD_QUESTION_ENTITY; }, | |
| /* harmony export */ "ADD_QUIZ": function() { return /* binding */ ADD_QUIZ; }, | |
| /* harmony export */ "ADD_QUIZ_ENTITY": function() { return /* binding */ ADD_QUIZ_ENTITY; }, | |
| /* harmony export */ "ADD_SECTION_HEADING_ENTITY": function() { return /* binding */ ADD_SECTION_HEADING_ENTITY; }, | |
| /* harmony export */ "ADD_TOPIC": function() { return /* binding */ ADD_TOPIC; }, | |
| /* harmony export */ "ADD_TOPIC_ENTITY": function() { return /* binding */ ADD_TOPIC_ENTITY; }, | |
| /* harmony export */ "INIT_DATA": function() { return /* binding */ INIT_DATA; }, | |
| /* harmony export */ "MOVE_ENTITY": function() { return /* binding */ MOVE_ENTITY; }, | |
| /* harmony export */ "REMOVE_ANSWER_ENTITY": function() { return /* binding */ REMOVE_ANSWER_ENTITY; }, | |
| /* harmony export */ "REMOVE_ENTITY": function() { return /* binding */ REMOVE_ENTITY; }, | |
| /* harmony export */ "REMOVE_EXISTING_ENTITY": function() { return /* binding */ REMOVE_EXISTING_ENTITY; }, | |
| /* harmony export */ "REMOVE_SECTION_HEADING_ENTITY": function() { return /* binding */ REMOVE_SECTION_HEADING_ENTITY; }, | |
| /* harmony export */ "SET_ACTIVE_LESSON": function() { return /* binding */ SET_ACTIVE_LESSON; }, | |
| /* harmony export */ "SET_DRAGGABLE_ENTITY": function() { return /* binding */ SET_DRAGGABLE_ENTITY; }, | |
| /* harmony export */ "SET_IS_DROP_DISABLED_LESSON": function() { return /* binding */ SET_IS_DROP_DISABLED_LESSON; }, | |
| /* harmony export */ "SORT_FINAL_QUIZZES_OUTLINE": function() { return /* binding */ SORT_FINAL_QUIZZES_OUTLINE; }, | |
| /* harmony export */ "TOGGLE_EXPAND_ALL": function() { return /* binding */ TOGGLE_EXPAND_ALL; }, | |
| /* harmony export */ "TOGGLE_EXPAND_ENTITY": function() { return /* binding */ TOGGLE_EXPAND_ENTITY; }, | |
| /* harmony export */ "UPDATE_COURSE_OUTLINE": function() { return /* binding */ UPDATE_COURSE_OUTLINE; }, | |
| /* harmony export */ "UPDATE_LESSONS": function() { return /* binding */ UPDATE_LESSONS; }, | |
| /* harmony export */ "UPDATE_NODE_TITLE": function() { return /* binding */ UPDATE_NODE_TITLE; }, | |
| /* harmony export */ "UPDATE_QUESTIONS": function() { return /* binding */ UPDATE_QUESTIONS; }, | |
| /* harmony export */ "UPDATE_QUESTION_ANSWERS": function() { return /* binding */ UPDATE_QUESTION_ANSWERS; }, | |
| /* harmony export */ "UPDATE_QUESTION_TYPE": function() { return /* binding */ UPDATE_QUESTION_TYPE; }, | |
| /* harmony export */ "UPDATE_SECTION_HEADINGS": function() { return /* binding */ UPDATE_SECTION_HEADINGS; }, | |
| /* harmony export */ "UPDATE_WORKSPACE_NODE_TITLE": function() { return /* binding */ UPDATE_WORKSPACE_NODE_TITLE; } | |
| /* harmony export */ }); | |
| const INIT_DATA = 'INIT_DATA'; | |
| const UPDATE_COURSE_OUTLINE = 'UPDATE_COURSE_OUTLINE'; | |
| const ADD_LESSON_ENTITY = 'ADD_LESSON_ENTITY'; | |
| const ADD_SECTION_HEADING_ENTITY = 'ADD_SECTION_HEADING_ENTITY'; | |
| const UPDATE_LESSONS = 'UPDATE_LESSONS'; | |
| const UPDATE_SECTION_HEADINGS = 'UPDATE_SECTION_HEADINGS'; | |
| const SET_ACTIVE_LESSON = 'SET_ACTIVE_LESSON'; | |
| const ADD_TOPIC_ENTITY = 'ADD_TOPIC_ENTITY'; | |
| const SET_DRAGGABLE_ENTITY = 'SET_DRAGGABLE_ENTITY'; | |
| const SET_IS_DROP_DISABLED_LESSON = 'SET_IS_DROP_DISABLED_LESSON'; | |
| const ADD_QUIZ_ENTITY = 'ADD_QUIZ_ENTITY'; | |
| const UPDATE_QUESTIONS = 'UPDATE_QUESTIONS'; | |
| const ADD_QUESTION_ENTITY = 'ADD_QUESTION_ENTITY'; | |
| const ADD_ANSWER_ENTITY = 'ADD_ANSWER_ENTITY'; | |
| const REMOVE_ANSWER_ENTITY = 'REMOVE_ANSWER_ENTITY'; | |
| const ADD_LESSON = 'ADD_LESSON'; | |
| const ADD_TOPIC = 'ADD_TOPIC'; | |
| const ADD_QUIZ = 'ADD_QUIZ'; | |
| const ADD_QUESTION = 'ADD_QUESTION'; | |
| const UPDATE_WORKSPACE_NODE_TITLE = 'UPDATE_WORKSPACE_NODE_TITLE'; | |
| const UPDATE_NODE_TITLE = 'UPDATE_NODE_TITLE'; | |
| const TOGGLE_EXPAND_ALL = 'TOGGLE_EXPAND_ALL'; | |
| const TOGGLE_EXPAND_ENTITY = 'TOGGLE_EXPAND_ENTITY'; | |
| const ADD_FINAL_QUIZ_ENTITY = 'ADD_FINAL_QUIZ_ENTITY'; | |
| const SORT_FINAL_QUIZZES_OUTLINE = 'SORT_FINAL_QUIZZES_OUTLINE'; | |
| const REMOVE_ENTITY = 'REMOVE_ENTITY'; | |
| const REMOVE_SECTION_HEADING_ENTITY = 'REMOVE_SECTION_HEADING_ENTITY'; | |
| const MOVE_ENTITY = 'MOVE_ENTITY'; | |
| const REMOVE_EXISTING_ENTITY = 'REMOVE_EXISTING_ENTITY'; | |
| const UPDATE_QUESTION_TYPE = 'UPDATE_QUESTION_TYPE'; | |
| const UPDATE_QUESTION_ANSWERS = 'UPDATE_QUESTION_ANSWERS'; | |
| /***/ }), | |
| /***/ "./src/redux/configureStore.js": | |
| /*!*************************************!*\ | |
| !*** ./src/redux/configureStore.js ***! | |
| \*************************************/ | |
| /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| "use strict"; | |
| __webpack_require__.r(__webpack_exports__); | |
| /* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| /* harmony export */ "store": function() { return /* binding */ store; } | |
| /* harmony export */ }); | |
| /* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); | |
| /* harmony import */ var _reducers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reducers */ "./src/redux/reducers/index.js"); | |
| const store = (0,redux__WEBPACK_IMPORTED_MODULE_1__.createStore)(_reducers__WEBPACK_IMPORTED_MODULE_0__["default"]); | |
| /***/ }), | |
| /***/ "./src/redux/reducers/data.js": | |
| /*!************************************!*\ | |
| !*** ./src/redux/reducers/data.js ***! | |
| \************************************/ | |
| /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| "use strict"; | |
| __webpack_require__.r(__webpack_exports__); | |
| /* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| /* harmony export */ "data": function() { return /* binding */ data; } | |
| /* harmony export */ }); | |
| /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../util */ "./src/util/index.js"); | |
| /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../constants */ "./src/constants/index.js"); | |
| function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | |
| function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | |
| function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | |
| function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | |
| function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | |
| // Default state for the data | |
| const defaultState = { | |
| currentTab: LearnDashData.currentTab && LearnDashData.currentTab, | |
| tabs: LearnDashData.tabs && LearnDashData.tabs || '', | |
| editing: LearnDashData.editing && LearnDashData.editing, | |
| courses: LearnDashData.courses && LearnDashData.courses, | |
| lessons: LearnDashData.lessons && LearnDashData.lessons, | |
| topics: LearnDashData.topics && LearnDashData.topics, | |
| quizzes: LearnDashData.quizzes && LearnDashData.quizzes, | |
| labels: LearnDashData.labels && LearnDashData.labels, | |
| questions: LearnDashData.questions && LearnDashData.questions || '' | |
| }; | |
| /** | |
| * Initial raw data | |
| * | |
| * @param {*} state | |
| * @param {*} action | |
| */ | |
| const data = function () { | |
| let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState; | |
| let action = arguments.length > 1 ? arguments[1] : undefined; | |
| switch (action.type) { | |
| // Sets the data for each entity. | |
| case _constants__WEBPACK_IMPORTED_MODULE_1__.INIT_DATA: | |
| { | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| [action.payload.field]: action.payload.data | |
| }); | |
| } | |
| // Adds a new lesson entity in the raw data | |
| case _constants__WEBPACK_IMPORTED_MODULE_1__.ADD_LESSON: | |
| { | |
| const lessons = Object.values(state.lessons); | |
| lessons.unshift(action.payload); | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| lessons | |
| }); | |
| } | |
| // Adds a new topic entity in the raw data | |
| case _constants__WEBPACK_IMPORTED_MODULE_1__.ADD_TOPIC: | |
| { | |
| const topics = Object.values(state.topics); | |
| topics.unshift(action.payload); | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| topics | |
| }); | |
| } | |
| // Adds a new quiz entity in the raw data | |
| case _constants__WEBPACK_IMPORTED_MODULE_1__.ADD_QUIZ: | |
| { | |
| const quizzes = Object.values(state.quizzes); | |
| quizzes.unshift(action.payload); | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| quizzes | |
| }); | |
| } | |
| // Adds a new question entity in the raw data | |
| case _constants__WEBPACK_IMPORTED_MODULE_1__.ADD_QUESTION: | |
| case _constants__WEBPACK_IMPORTED_MODULE_1__.ADD_QUESTION_ENTITY: | |
| { | |
| const questions = Object.values(state.questions); | |
| questions.unshift(action.payload); | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| questions | |
| }); | |
| } | |
| // Updates the title for a node | |
| case _constants__WEBPACK_IMPORTED_MODULE_1__.UPDATE_NODE_TITLE: | |
| { | |
| if (action.payload.ID && action.payload.post_title) { | |
| const nodeMap = { | |
| lesson: 'lessons', | |
| 'sfwd-lessons': 'lessons', | |
| topic: 'topics', | |
| 'sfwd-topic': 'topics', | |
| quiz: 'quizzes', | |
| 'sfwd-quiz': 'quizzes', | |
| question: 'questions', | |
| 'sfwd-question': 'questions' | |
| }; | |
| const stateObject = Object.values(state[nodeMap[action.payload.type]]); | |
| const node = _util__WEBPACK_IMPORTED_MODULE_0__.treeNodeUtils.getNodeByKey(stateObject, action.payload.ID); | |
| if (node) { | |
| node.post_title = action.payload.post_title; | |
| } | |
| if ('lesson' === action.payload.type) { | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| lessons: stateObject | |
| }); | |
| } else if ('topic' === action.payload.type) { | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| topics: stateObject | |
| }); | |
| } else if ('quiz' === action.payload.type) { | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| quizzes: stateObject | |
| }); | |
| } else if ('question' === action.payload.type) { | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| questions: stateObject | |
| }); | |
| } | |
| } | |
| return state; | |
| } | |
| default: | |
| return state; | |
| } | |
| }; | |
| /***/ }), | |
| /***/ "./src/redux/reducers/index.js": | |
| /*!*************************************!*\ | |
| !*** ./src/redux/reducers/index.js ***! | |
| \*************************************/ | |
| /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| "use strict"; | |
| __webpack_require__.r(__webpack_exports__); | |
| /* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); | |
| /* harmony import */ var _workspace__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./workspace */ "./src/redux/reducers/workspace.js"); | |
| /* harmony import */ var _data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./data */ "./src/redux/reducers/data.js"); | |
| /* harmony default export */ __webpack_exports__["default"] = ((0,redux__WEBPACK_IMPORTED_MODULE_2__.combineReducers)({ | |
| data: _data__WEBPACK_IMPORTED_MODULE_1__.data, | |
| workspace: _workspace__WEBPACK_IMPORTED_MODULE_0__.workspace | |
| })); | |
| /***/ }), | |
| /***/ "./src/redux/reducers/workspace.js": | |
| /*!*****************************************!*\ | |
| !*** ./src/redux/reducers/workspace.js ***! | |
| \*****************************************/ | |
| /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| "use strict"; | |
| __webpack_require__.r(__webpack_exports__); | |
| /* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| /* harmony export */ "workspace": function() { return /* binding */ workspace; } | |
| /* harmony export */ }); | |
| /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../util */ "./src/util/index.js"); | |
| /* harmony import */ var immutable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! immutable */ "./node_modules/immutable/dist/immutable.es.js"); | |
| /* harmony import */ var redux_undo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! redux-undo */ "./node_modules/redux-undo/lib/index.js"); | |
| /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../constants */ "./src/constants/index.js"); | |
| function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | |
| function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | |
| function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | |
| function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | |
| function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | |
| /* eslint-disable @wordpress/no-unused-vars-before-return */ | |
| /** | |
| * Initial state of the app | |
| */ | |
| const initialState = { | |
| disabledDrop: false, | |
| currentDraggableEntity: null, | |
| currentDroppableEntity: null, | |
| activeLesson: null, | |
| isDropDisabledLesson: null, | |
| lessons: undefined !== LearnDashData.outline && undefined !== LearnDashData.outline.lessons ? LearnDashData.outline.lessons : [], | |
| quizzes: undefined !== LearnDashData.outline && undefined !== LearnDashData.outline.quizzes ? LearnDashData.outline.quizzes : [], | |
| // holding our final quizzes | |
| questions: undefined !== LearnDashData.outline && undefined !== LearnDashData.outline.questions ? LearnDashData.outline.questions : [], | |
| sections: undefined !== LearnDashData.outline && undefined !== LearnDashData.outline.sections ? LearnDashData.outline.sections : [], | |
| expandAll: false, | |
| expandedItems: [], | |
| refresh: null // which data we need to refresh | |
| }; | |
| // Check if we have existing lessons/questions, set the first entity as the active one. | |
| if (LearnDashData.post_data && 'sfwd-quiz' !== LearnDashData.post_data.builder_post_type) { | |
| if (LearnDashData.outline && LearnDashData.outline.lessons && LearnDashData.outline.lessons.length) { | |
| // get index of first lesson (skip section heading) | |
| const firstLesson = LearnDashData.outline.lessons.findIndex(node => 'sfwd-lessons' === node.type); | |
| if (LearnDashData.outline.lessons[firstLesson]) { | |
| initialState.activeLesson = LearnDashData.outline.lessons[firstLesson].ID; | |
| } | |
| } | |
| } else if (LearnDashData.outline && LearnDashData.outline.questions && LearnDashData.outline.questions.length) { | |
| initialState.activeLesson = LearnDashData.outline.questions[0].ID; | |
| LearnDashData.outline.questions[0].expanded = true; | |
| } | |
| /** | |
| * Workspace related actions here. | |
| * | |
| * @param {*} state | |
| * @param {*} action | |
| */ | |
| const workspaceReducer = function () { | |
| let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState; | |
| let action = arguments.length > 1 ? arguments[1] : undefined; | |
| const immutableLessons = (0,immutable__WEBPACK_IMPORTED_MODULE_3__.fromJS)(state.lessons); | |
| // Final quizzes, which are separate from lessons (which can contain topics and quizzes) | |
| const immutableQuizzes = (0,immutable__WEBPACK_IMPORTED_MODULE_3__.fromJS)(state.quizzes); | |
| // Questions | |
| const immutableQuestions = (0,immutable__WEBPACK_IMPORTED_MODULE_3__.fromJS)(state.questions); | |
| // Sections | |
| const immutableSections = state.sections ? (0,immutable__WEBPACK_IMPORTED_MODULE_3__.fromJS)(state.sections) : (0,immutable__WEBPACK_IMPORTED_MODULE_3__.fromJS)([]); | |
| switch (action.type) { | |
| /** | |
| * Update the lessons field in the store. | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.UPDATE_LESSONS: | |
| { | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| lessons: action.payload | |
| }); | |
| } | |
| /** | |
| * Update the sections field in the store. | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.UPDATE_SECTION_HEADINGS: | |
| { | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| sections: action.payload | |
| }); | |
| } | |
| /** | |
| * Adds a new lesson within the workspace at a specific position | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.ADD_LESSON_ENTITY: | |
| { | |
| let index = action.payload.index; | |
| // Check if we have a valid index. | |
| if (undefined === index || isNaN(index)) { | |
| index = state.lessons.length; | |
| } | |
| // Use the insert method to add the new object. | |
| const lessons = immutableLessons.insert(index, { | |
| ID: action.payload.ID, | |
| post_title: action.payload.post_title, | |
| url: action.payload.url, | |
| edit_link: action.payload.edit_link, | |
| tree: [], | |
| expanded: false, | |
| type: 'sfwd-lessons', | |
| post_status: action.payload.post_status | |
| }).toJS(); | |
| // Set the active lesson which is the newly added one. | |
| const activeLesson = action.payload.ID; | |
| // which data we need to refresh | |
| const refresh = 'lesson'; | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| lessons, | |
| activeLesson, | |
| refresh | |
| }); | |
| } | |
| /** | |
| * Adds a new section heading within the workspace at a specific position | |
| * Adds to workspace lesson but also to workspace sections | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.ADD_SECTION_HEADING_ENTITY: | |
| { | |
| let index = action.payload.index; | |
| let lessonIndex = 0; | |
| // Check if we have a valid index. | |
| if (undefined === index || isNaN(index)) { | |
| index = state.lessons.length; | |
| } | |
| if (state.activeLesson) { | |
| lessonIndex = immutableLessons.findIndex(node => node.get('ID') === state.activeLesson); | |
| } else { | |
| lessonIndex = index; | |
| } | |
| // Use the insert method to add the new object. | |
| const lessons = immutableLessons.insert(parseInt(lessonIndex + 1, 10), { | |
| order: action.payload.order, | |
| ID: action.payload.ID, | |
| post_title: action.payload.post_title, | |
| url: action.payload.url, | |
| edit_link: action.payload.edit_link, | |
| tree: [], | |
| expanded: false, | |
| type: 'section-heading' | |
| }).toJS(); | |
| const sections = immutableSections.insert(index, { | |
| order: action.payload.order, | |
| ID: action.payload.ID, | |
| post_title: action.payload.post_title, | |
| url: action.payload.url, | |
| edit_link: action.payload.edit_link, | |
| tree: [], | |
| expanded: false, | |
| type: 'section-heading' | |
| }).toJS(); | |
| // which data we need to refresh | |
| const refresh = 'lesson'; | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| lessons, | |
| sections, | |
| refresh | |
| }); | |
| } | |
| /** | |
| * Sets the active lesson in the workspace. | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.SET_ACTIVE_LESSON: | |
| { | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| activeLesson: parseInt(action.payload.activeLesson) | |
| }); | |
| } | |
| /** | |
| * Adds a new topic to a lesson | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.ADD_TOPIC_ENTITY: | |
| { | |
| let topicDestinationIndex = 0; | |
| let lessonIndex = null; | |
| let activeLesson = state.activeLesson; | |
| // We are passing a parent to which the topic will be added to. | |
| if (action.parent) { | |
| // get parent node | |
| lessonIndex = immutableLessons.findIndex(node => node.get('ID') === action.parent); | |
| // If we found the parent node. | |
| if (-1 !== lessonIndex) { | |
| // Get the tree | |
| const parentNode = immutableLessons.get(lessonIndex); | |
| const parentNodeTree = parentNode.get('tree'); | |
| topicDestinationIndex = action.destinationIndex; | |
| activeLesson = action.parent; | |
| if (0 < topicDestinationIndex || null === topicDestinationIndex) { | |
| // if we are trying to drop before a quiz, find the first quiz index and insert topic at that index | |
| const firstQuizIndex = parentNodeTree.findIndex(el => { | |
| return 'quiz' === el.get('type') || 'sfwd-quiz' === el.get('type'); | |
| }); | |
| if (-1 !== firstQuizIndex) { | |
| topicDestinationIndex = firstQuizIndex; | |
| } else { | |
| topicDestinationIndex = parentNodeTree.size; | |
| } | |
| } | |
| } | |
| } else if (state.activeLesson) { | |
| // Get the active lesson | |
| lessonIndex = immutableLessons.findIndex(node => node.get('ID') === state.activeLesson); | |
| if (-1 !== lessonIndex) { | |
| const activeLessonNode = immutableLessons.get(lessonIndex); | |
| const activeLessonTree = activeLessonNode.get('tree'); | |
| topicDestinationIndex = activeLessonTree.size; | |
| if (undefined === action.payload.destinationIndex) { | |
| // if we are trying to drop before a quiz, find the first quiz index and insert topic at that index | |
| const firstQuizIndex = activeLessonTree.findIndex(el => { | |
| return 'quiz' === el.get('type') || 'sfwd-quiz' === el.get('type'); | |
| }); | |
| if (-1 !== firstQuizIndex) { | |
| topicDestinationIndex = firstQuizIndex; | |
| } | |
| } | |
| } | |
| } | |
| // Add extra information. | |
| action.payload.type = 'sfwd-topic'; | |
| action.payload.tree = []; | |
| action.payload.expanded = false; | |
| // Make the update | |
| const lessons = immutableLessons.updateIn([lessonIndex, 'tree'], tree => { | |
| return tree.insert(topicDestinationIndex, action.payload); | |
| }).toJS(); | |
| // which data we need to refresh | |
| const refresh = 'topic'; | |
| // Return with updated values if any. | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| lessons, | |
| activeLesson, | |
| refresh | |
| }); | |
| } | |
| /** | |
| * Adds a new quiz entity to the workspace | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.ADD_QUIZ_ENTITY: | |
| { | |
| // Default values | |
| let nodePath = -1; | |
| let activeLesson = state.activeLesson; | |
| // add some extra data. | |
| action.payload.type = 'sfwd-quiz'; | |
| action.payload.expanded = false; | |
| if (action.parent) { | |
| nodePath = (0,_util__WEBPACK_IMPORTED_MODULE_0__.getNodePath)(state.lessons, action.parent, true); | |
| activeLesson = action.parent; | |
| } else if (state.activeLesson) { | |
| // Adds quiz to the current active lesson. Get the active lesson first. | |
| nodePath = (0,_util__WEBPACK_IMPORTED_MODULE_0__.getNodePath)(state.lessons, state.activeLesson, true); | |
| } | |
| // If we have a path | |
| if (-1 !== nodePath) { | |
| // Make the update. | |
| const lessons = immutableLessons.updateIn(nodePath, tree => { | |
| return tree.push(action.payload); | |
| }).toJS(); | |
| // which data we need to refresh | |
| const refresh = 'quiz'; | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| lessons, | |
| activeLesson, | |
| refresh | |
| }); | |
| } | |
| // there is no active lesson, add to final quizzes | |
| const index = state.quizzes.length; | |
| // Use the insert method to add the new object. | |
| const quizzes = immutableQuizzes.insert(index, { | |
| ID: action.payload.ID, | |
| post_title: action.payload.post_title, | |
| edit_link: action.payload.edit_link, | |
| url: action.payload.url, | |
| tree: [], | |
| expanded: true, | |
| type: 'sfwd-quiz' | |
| }).toJS(); | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| quizzes | |
| }); | |
| } | |
| /** | |
| * Update the questions field in the store. | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.UPDATE_QUESTIONS: | |
| { | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| questions: action.payload | |
| }); | |
| } | |
| /** | |
| * Adds a new question within the workspace at a specific position | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.ADD_QUESTION_ENTITY: | |
| { | |
| let index = action.payload.index; | |
| // Check if we have a valid index. | |
| if (undefined === index || isNaN(index)) { | |
| index = state.questions.length; | |
| } | |
| // answers objects when none are provided. | |
| // this need to match backend defaults | |
| const newAnswerObject = { | |
| answer: '', | |
| correct: false, | |
| graded: '1', | |
| gradedType: 'text', | |
| gradingProgression: '', | |
| html: false, | |
| points: 1, | |
| sortString: '', | |
| sortStringHtml: false, | |
| type: 'answer' | |
| }; | |
| const newAnswersObject = { | |
| assessment_answer: [newAnswerObject], | |
| classic_answer: [newAnswerObject], | |
| cloze_answer: [newAnswerObject], | |
| essay: [newAnswerObject], | |
| free_answer: [newAnswerObject], | |
| matrix_sort_answer: [newAnswerObject], | |
| sort_answer: [newAnswerObject] | |
| }; | |
| // Use the insert method to add the new object. | |
| const questions = immutableQuestions.insert(index, { | |
| ID: action.payload.ID, | |
| post_title: action.payload.post_title, | |
| url: action.payload.url, | |
| edit_link: action.payload.edit_link, | |
| answers: action.payload.answers ? action.payload.answers : newAnswersObject, | |
| question_type: action.payload.question_type ? action.payload.question_type : 'single', | |
| post_content: action.payload.post_content ? action.payload.post_content : '', | |
| points: action.payload.points ? action.payload.points : 1, | |
| expanded: false, | |
| type: 'sfwd-question', | |
| post_status: action.payload.post_status, | |
| correctMsg: action.payload.correctMsg ?? '', | |
| incorrectMsg: action.payload.incorrectMsg ?? '', | |
| correctSameText: action.payload.correctSameText ?? false, | |
| tipEnabled: action.payload.tipEnabled ?? false, | |
| tipMsg: action.payload.tipMsg ?? '', | |
| answerPointsActivated: action.payload.answerPointsActivated ?? false | |
| }).toJS(); | |
| // Set the active lesson which is the newly added one. | |
| const activeLesson = action.payload.ID; | |
| // which data we need to refresh | |
| const refresh = 'question'; | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| questions, | |
| activeLesson, | |
| refresh | |
| }); | |
| } | |
| /** | |
| * Adds a new answer within the workspace | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.ADD_ANSWER_ENTITY: | |
| { | |
| let questions = state.questions; | |
| const answerType = LearnDashData.questions_types_map[action.parent.question_type]; | |
| const parentIndex = immutableQuestions.findIndex(node => node.get('ID') === action.parent.ID); | |
| const index = state.questions[parentIndex].answers[answerType].length + 1; | |
| const nodePath = [parentIndex, 'answers', answerType, action.payload.index]; | |
| if (nodePath.length) { | |
| // we need to update a tree | |
| const treePath = nodePath.slice(0, nodePath.length - 1); | |
| questions = immutableQuestions.updateIn(treePath, tree => { | |
| return tree.insert(index, action.payload); | |
| }).toJS(); | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| questions | |
| }); | |
| } | |
| return state; | |
| } | |
| /** | |
| * Removes an answer within the workspace | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.REMOVE_ANSWER_ENTITY: | |
| { | |
| let questions = state.questions; | |
| const answerType = LearnDashData.questions_types_map[action.parent.question_type]; | |
| const parentIndex = immutableQuestions.findIndex(node => node.get('ID') === action.parent.ID); | |
| const nodePath = [parentIndex, 'answers', answerType, action.payload]; | |
| if (nodePath.length) { | |
| // we need to update a tree | |
| const treePath = nodePath.slice(0, nodePath.length - 1); | |
| questions = immutableQuestions.updateIn(treePath, tree => { | |
| return tree.delete(action.payload).toJS(); | |
| }).toJS(); | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| questions | |
| }); | |
| } | |
| return state; | |
| } | |
| /** | |
| * Updates a node title. | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.UPDATE_WORKSPACE_NODE_TITLE: | |
| { | |
| if (action.payload.ID && action.payload.post_title) { | |
| let type = ''; | |
| const entities = { | |
| lessons: state.lessons, | |
| questions: state.questions | |
| }; | |
| if ('sfwd-quiz' === LearnDashData.post_data.builder_post_type) { | |
| type = 'questions'; | |
| } else { | |
| type = 'lessons'; | |
| } | |
| const entityObject = Object.values(entities[type]); | |
| const node = _util__WEBPACK_IMPORTED_MODULE_0__.treeNodeUtils.getNodeByKey(entityObject, action.payload.ID); | |
| if (node) { | |
| node.post_title = action.payload.post_title; | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| [type]: entities[type] | |
| }); | |
| } | |
| // try to look into the quizzes | |
| const quizzes = Object.values(state.quizzes); | |
| const quizNode = _util__WEBPACK_IMPORTED_MODULE_0__.treeNodeUtils.getNodeByKey(quizzes, action.payload.ID); | |
| if (quizNode) { | |
| quizNode.post_title = action.payload.post_title; | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| quizzes | |
| }); | |
| } | |
| return state; | |
| } | |
| return state; | |
| } | |
| /** | |
| * Adds a quiz to the final quizzes section. | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.ADD_FINAL_QUIZ_ENTITY: | |
| { | |
| let index = action.index; | |
| // Check if we have a valid index. | |
| if (undefined === index || isNaN(index)) { | |
| index = state.quizzes.length; | |
| } | |
| // Use the insert method to add the new object. | |
| const quizzes = immutableQuizzes.insert(index, { | |
| ID: action.payload.ID, | |
| post_title: action.payload.post_title, | |
| edit_link: action.payload.edit_link, | |
| url: action.payload.url, | |
| tree: [], | |
| expanded: true, | |
| type: 'sfwd-quiz' | |
| }).toJS(); | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| quizzes | |
| }); | |
| } | |
| /** | |
| * Used when sorting quizzes. | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.SORT_FINAL_QUIZZES_OUTLINE: | |
| { | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| quizzes: action.payload | |
| }); | |
| } | |
| /** | |
| * Remove any entity from the workspace based on the entity ID | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.REMOVE_EXISTING_ENTITY: | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.REMOVE_SECTION_HEADING_ENTITY: | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.REMOVE_ENTITY: | |
| { | |
| if (action.payload.ID) { | |
| // Default value for our lessons and quizzes, which is the same state | |
| let quizzes = state.quizzes; | |
| let type = ''; | |
| const entities = { | |
| lessons: state.lessons, | |
| questions: state.questions | |
| }; | |
| let immutableEntities = null; | |
| if ('sfwd-quiz' === LearnDashData.post_data.builder_post_type) { | |
| type = 'questions'; | |
| immutableEntities = immutableQuestions; | |
| } else { | |
| type = 'lessons'; | |
| immutableEntities = immutableLessons; | |
| } | |
| // Whether we found the node. | |
| let found = false; | |
| // Look if we need to remove a lesson. | |
| const nodePath = (0,_util__WEBPACK_IMPORTED_MODULE_0__.getNodePath)(entities[type], action.payload.ID); | |
| if (-1 !== nodePath) { | |
| entities[type] = immutableEntities.deleteIn(nodePath).toJS(); | |
| found = true; | |
| const activeLesson = 0 < entities[type].length ? entities[type][0].ID : null; | |
| // Found, return updated entities. | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| [type]: entities[type], | |
| activeLesson | |
| }); | |
| } | |
| if ('sfwd-quiz' !== LearnDashData.post_data.builder_post_type) { | |
| // if node has not been found in lessons, look into final quizzes | |
| if (!found) { | |
| const quizNodePath = (0,_util__WEBPACK_IMPORTED_MODULE_0__.getNodePath)(state.quizzes, action.payload.ID); | |
| if (-1 !== quizNodePath) { | |
| quizzes = immutableQuizzes.deleteIn(quizNodePath).toJS(); | |
| } | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| quizzes | |
| }); | |
| } | |
| } | |
| // Return everything now. | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| [type]: entities[type], | |
| quizzes | |
| }); | |
| } | |
| return state; | |
| } | |
| /** | |
| * Moves an entity up or down | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.MOVE_ENTITY: | |
| { | |
| if (!action.payload) { | |
| return state; | |
| } | |
| let type = ''; | |
| let nodePath = []; | |
| const entities = { | |
| questions: state.questions, | |
| lessons: state.lessons | |
| }; | |
| let immutableEntities = null; | |
| if ('sfwd-quiz' === LearnDashData.post_data.builder_post_type) { | |
| type = 'questions'; | |
| immutableEntities = immutableQuestions; | |
| } else { | |
| type = 'lessons'; | |
| immutableEntities = immutableLessons; | |
| } | |
| if ('answer' === action.payload.type) { | |
| const parentIndex = immutableEntities.findIndex(node => node.get('ID') === action.payload.parentID); | |
| nodePath = [parentIndex, 'answers', action.payload.answerType, action.payload.index]; | |
| } else { | |
| nodePath = (0,_util__WEBPACK_IMPORTED_MODULE_0__.getNodePath)(entities[type], action.payload.ID, false); | |
| } | |
| if (nodePath.length) { | |
| // Get the index of the node which is the last element in the array. | |
| const currentIndex = nodePath[nodePath.length - 1]; | |
| const currentNode = immutableEntities.getIn(nodePath); | |
| // set the new index depending on the direction. | |
| let newIndex = currentIndex + 1; | |
| if ('up' === action.direction) { | |
| newIndex = currentIndex - 1; | |
| } | |
| // We are at the top level | |
| if (1 === nodePath.length) { | |
| entities[type] = immutableEntities.deleteIn(nodePath).insert(newIndex, currentNode).toJS(); | |
| } else { | |
| // we need to update a tree | |
| const treePath = nodePath.slice(0, nodePath.length - 1); | |
| entities[type] = immutableEntities.updateIn(treePath, tree => { | |
| return tree.delete(currentIndex).insert(newIndex, currentNode); | |
| }).toJS(); | |
| } | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| [type]: entities[type] | |
| }); | |
| } | |
| return state; | |
| } | |
| /** | |
| * Sets the draggable and droppable entities. | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.SET_DRAGGABLE_ENTITY: | |
| { | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| currentDraggableEntity: action.payload.currentDraggableEntity, | |
| currentDroppableEntity: action.payload.currentDroppableEntity | |
| }); | |
| } | |
| /** | |
| * Sets the is drop disabled value | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.SET_IS_DROP_DISABLED_LESSON: | |
| { | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| isDropDisabledLesson: action.payload.isDropDisabledLesson | |
| }); | |
| } | |
| /** | |
| * Used for the global expand/collapse all | |
| * Only affects top level items (lessons in course builder or questions in quiz builder) | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.TOGGLE_EXPAND_ALL: | |
| { | |
| let type = ''; | |
| const entities = { | |
| questions: state.questions, | |
| lessons: state.lessons | |
| }; | |
| if ('sfwd-quiz' === LearnDashData.post_data.builder_post_type) { | |
| type = 'questions'; | |
| } else { | |
| type = 'lessons'; | |
| } | |
| // Get all the top level items (ignore section headings) | |
| const realBuilderItems = entities[type].filter(node => 'sfwd-lessons' === node.type || 'sfwd-question' === node.type); | |
| // Everything was already expanded, so collapse all | |
| if (state.expandAll) { | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| expandedItems: [], | |
| expandAll: false | |
| }); | |
| } | |
| // Everything was collapsed, so expand all | |
| // Add all top level items IDs in expandedItems | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| expandedItems: realBuilderItems.map(item => item.ID), | |
| expandAll: true | |
| }); | |
| } | |
| /** | |
| * Used for the entity expand/collapse | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.TOGGLE_EXPAND_ENTITY: | |
| { | |
| if (action.payload.ID) { | |
| let type = ''; | |
| let entityObject = null; | |
| const entities = { | |
| questions: state.questions, | |
| lessons: state.lessons | |
| }; | |
| if ('sfwd-quiz' === LearnDashData.post_data.builder_post_type) { | |
| type = 'questions'; | |
| } else { | |
| type = 'lessons'; | |
| } | |
| // Get all the top level items (ignore section headings) | |
| const realBuilderItems = entities[type].filter(node => 'sfwd-lessons' === node.type || 'sfwd-question' === node.type); | |
| // Expand/Collapse lessons or questions | |
| if ('sfwd-lessons' === action.payload.type || 'sfwd-question' === action.payload.type) { | |
| const isExpanded = -1 !== state.expandedItems.indexOf(action.payload.ID); | |
| // If the item is not expanded, add it to expandedItems | |
| // If the item is already expanded, remove it | |
| const newExpandedItems = !isExpanded ? [...state.expandedItems, action.payload.ID] : state.expandedItems.filter(item => item !== action.payload.ID); | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| expandedItems: newExpandedItems, | |
| expandAll: realBuilderItems.length === newExpandedItems.length | |
| }); | |
| } else if ('sfwd-topic' === action.payload.type) { | |
| // Expand/Collapse topics | |
| entityObject = Object.values(entities[type][action.parent].tree); | |
| const node = _util__WEBPACK_IMPORTED_MODULE_0__.treeNodeUtils.getNodeByKey(entityObject, action.payload.ID); | |
| if (node) { | |
| node.expanded = !action.payload.expanded; | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| [type]: entities[type] | |
| }); | |
| } | |
| } | |
| return state; | |
| } | |
| return state; | |
| } | |
| /** | |
| * Updates a question type. | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.UPDATE_QUESTION_TYPE: | |
| { | |
| if (action.payload.ID) { | |
| const nodeIndex = immutableQuestions.findIndex(node => node.get('ID') === action.payload.ID); | |
| if (-1 !== nodeIndex) { | |
| const questions = immutableQuestions.update(nodeIndex, node => node.set('question_type', action.payload.question_type).set('points', action.payload.points).set('post_content', action.payload.post_content)).toJS(); | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| questions | |
| }); | |
| } | |
| return state; | |
| } | |
| return state; | |
| } | |
| /** | |
| * Updates the answers for a question. Used mainly when selecting the correct answer to refresh everything. | |
| */ | |
| case _constants__WEBPACK_IMPORTED_MODULE_2__.UPDATE_QUESTION_ANSWERS: | |
| { | |
| if (action.question.ID) { | |
| const nodeIndex = immutableQuestions.findIndex(node => node.get('ID') === action.question.ID); | |
| if (-1 !== nodeIndex) { | |
| const questions = immutableQuestions.update(nodeIndex, node => node.setIn(['answers', LearnDashData.questions_types_map[action.question.question_type]], action.answers)).toJS(); | |
| return _objectSpread(_objectSpread({}, state), {}, { | |
| questions | |
| }); | |
| } | |
| } | |
| return state; | |
| } | |
| default: | |
| { | |
| return state; | |
| } | |
| } | |
| }; | |
| const workspace = (0,redux_undo__WEBPACK_IMPORTED_MODULE_1__["default"])(workspaceReducer, { | |
| filter: (0,redux_undo__WEBPACK_IMPORTED_MODULE_1__.excludeAction)([_constants__WEBPACK_IMPORTED_MODULE_2__.INIT_DATA, _constants__WEBPACK_IMPORTED_MODULE_2__.SET_DRAGGABLE_ENTITY, _constants__WEBPACK_IMPORTED_MODULE_2__.SET_ACTIVE_LESSON, _constants__WEBPACK_IMPORTED_MODULE_2__.SET_IS_DROP_DISABLED_LESSON, _constants__WEBPACK_IMPORTED_MODULE_2__.ADD_LESSON, _constants__WEBPACK_IMPORTED_MODULE_2__.TOGGLE_EXPAND_ALL, _constants__WEBPACK_IMPORTED_MODULE_2__.TOGGLE_EXPAND_ENTITY, _constants__WEBPACK_IMPORTED_MODULE_2__.REMOVE_EXISTING_ENTITY, | |
| // used when moving things. | |
| _constants__WEBPACK_IMPORTED_MODULE_2__.UPDATE_QUESTION_TYPE, _constants__WEBPACK_IMPORTED_MODULE_2__.ADD_SECTION_HEADING_ENTITY, _constants__WEBPACK_IMPORTED_MODULE_2__.REMOVE_SECTION_HEADING_ENTITY, _constants__WEBPACK_IMPORTED_MODULE_2__.UPDATE_SECTION_HEADINGS]) | |
| }); | |
| /***/ }), | |
| /***/ "./src/util/index.js": | |
| /*!***************************!*\ | |
| !*** ./src/util/index.js ***! | |
| \***************************/ | |
| /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| "use strict"; | |
| __webpack_require__.r(__webpack_exports__); | |
| /* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| /* harmony export */ "calculatePoints": function() { return /* binding */ calculatePoints; }, | |
| /* harmony export */ "debounce": function() { return /* binding */ debounce; }, | |
| /* harmony export */ "formattedAnswersForAPI": function() { return /* binding */ formattedAnswersForAPI; }, | |
| /* harmony export */ "getNodePath": function() { return /* binding */ getNodePath; }, | |
| /* harmony export */ "mergeUniqueItems": function() { return /* binding */ mergeUniqueItems; }, | |
| /* harmony export */ "treeConfig": function() { return /* binding */ treeConfig; }, | |
| /* harmony export */ "treeNodeUtils": function() { return /* binding */ treeNodeUtils; } | |
| /* harmony export */ }); | |
| /* harmony import */ var lodash_mapKeys__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lodash/mapKeys */ "./node_modules/lodash/mapKeys.js"); | |
| /* harmony import */ var lodash_mapKeys__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_mapKeys__WEBPACK_IMPORTED_MODULE_0__); | |
| /* harmony import */ var tree_node_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tree-node-utils */ "./node_modules/tree-node-utils/lib/tree-node-utils.js"); | |
| /* harmony import */ var tree_node_utils__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(tree_node_utils__WEBPACK_IMPORTED_MODULE_1__); | |
| /* harmony import */ var immutable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! immutable */ "./node_modules/immutable/dist/immutable.es.js"); | |
| /** | |
| * Format the answer data to use in the API | |
| * Adds _ before key name | |
| * | |
| * @param {Object} answers | |
| */ | |
| const formattedAnswersForAPI = answers => { | |
| const formatted = answers.map(answer => { | |
| return lodash_mapKeys__WEBPACK_IMPORTED_MODULE_0___default()(answer, (value, key) => { | |
| return '_' + key; | |
| }); | |
| }); | |
| return formatted; | |
| }; | |
| /** | |
| * Calculates the points for answers. | |
| * | |
| * @deprecated 4.14.0 All the points should be calculated in the backend. | |
| * | |
| * @param {Object} answers | |
| */ | |
| const calculatePoints = answers => { | |
| console.warn('calculatePoints() is deprecated'); | |
| const answerObject = answers[0]; | |
| let points = 1, | |
| maxPoints = 0; | |
| if (answerObject) { | |
| if ('assessment_answer' === answerObject.answerType) { | |
| const items = answerObject.answer.match(/{(.*?)}/im); | |
| if (items && 0 !== items.length && items[1]) { | |
| points = items[1].match(/\[([^|\]]+)(?:\|(\d+))?\]/gim).length; | |
| maxPoints = Math.max(maxPoints, points); | |
| } | |
| } else { | |
| points = answerObject.points; | |
| } | |
| } | |
| return { | |
| points, | |
| maxPoints | |
| }; | |
| }; | |
| // Tree utils | |
| const treeConfig = { | |
| childrenField: 'tree', | |
| keyField: 'ID' | |
| }; | |
| const treeNodeUtils = new (tree_node_utils__WEBPACK_IMPORTED_MODULE_1___default())(treeConfig); | |
| /** | |
| * Concatenates 2 arrays without any duplicates, based on the ID attribute. | |
| * | |
| * @param {Array} nodes | |
| * @param {Array} newNodes | |
| */ | |
| const mergeUniqueItems = (nodes, newNodes) => { | |
| newNodes.forEach(data => { | |
| const existingElement = nodes.findIndex(node => node.ID === data.ID); | |
| if (-1 === existingElement) { | |
| nodes = [...nodes, data]; | |
| } | |
| }); | |
| return nodes; | |
| }; | |
| /** | |
| * Get the parent path for a node, provide the ID. | |
| * | |
| * @param {Array} data Array | |
| * @param {number} ID Number The id we are looking for | |
| * @param {boolean} appendTree Whether to add the tree path to the first path. | |
| * | |
| * @return {Array} to be used with immutable JS | |
| */ | |
| const getNodePath = function (data, ID) { | |
| let appendTree = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | |
| const immutableData = (0,immutable__WEBPACK_IMPORTED_MODULE_2__.fromJS)(data); | |
| const parentIndex = immutableData.findIndex(node => node.get('ID') === ID); | |
| let path = -1; | |
| if (-1 === parentIndex) { | |
| // look into child now | |
| immutableData.forEach((parent, index) => { | |
| const parentTree = parent.get('tree'); | |
| if (parentTree.size) { | |
| const childIndex = parentTree.findIndex(node => node.get('ID') === ID); | |
| if (-1 !== childIndex) { | |
| path = [index, 'tree', childIndex]; | |
| } else { | |
| parent.get('tree').forEach((child, childIndex) => { | |
| const childTree = child.get('tree'); | |
| if (childTree && childTree.size) { | |
| const grandChildIndex = childTree.findIndex(node => node.get('ID') === ID); | |
| if (-1 !== grandChildIndex) { | |
| path = [index, 'tree', childIndex, 'tree', grandChildIndex]; | |
| } | |
| } | |
| }); | |
| } | |
| } | |
| }); | |
| } else { | |
| path = [parentIndex]; | |
| } | |
| if (-1 !== path && appendTree) { | |
| path.push('tree'); | |
| } | |
| return path; | |
| }; | |
| /** | |
| * Debounce callback | |
| * Replaces lodash.debounce | |
| * | |
| * @callback callback | |
| * @param {callback} callback Callback to be debounced | |
| * @param {number} wait Time to wait before execution | |
| */ | |
| const debounce = (callback, wait) => { | |
| let timeout; | |
| return function () { | |
| for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | |
| args[_key] = arguments[_key]; | |
| } | |
| clearTimeout(timeout); | |
| timeout = setTimeout(() => { | |
| callback.apply(this, args); | |
| }, wait); | |
| }; | |
| }; | |
| /***/ }), | |
| /***/ "./node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js": | |
| /*!**********************************************************************************!*\ | |
| !*** ./node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js ***! | |
| \**********************************************************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| "use strict"; | |
| var reactIs = __webpack_require__(/*! react-is */ "./node_modules/react-is/index.js"); | |
| /** | |
| * Copyright 2015, Yahoo! Inc. | |
| * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. | |
| */ | |
| var REACT_STATICS = { | |
| childContextTypes: true, | |
| contextType: true, | |
| contextTypes: true, | |
| defaultProps: true, | |
| displayName: true, | |
| getDefaultProps: true, | |
| getDerivedStateFromError: true, | |
| getDerivedStateFromProps: true, | |
| mixins: true, | |
| propTypes: true, | |
| type: true | |
| }; | |
| var KNOWN_STATICS = { | |
| name: true, | |
| length: true, | |
| prototype: true, | |
| caller: true, | |
| callee: true, | |
| arguments: true, | |
| arity: true | |
| }; | |
| var FORWARD_REF_STATICS = { | |
| '$$typeof': true, | |
| render: true, | |
| defaultProps: true, | |
| displayName: true, | |
| propTypes: true | |
| }; | |
| var MEMO_STATICS = { | |
| '$$typeof': true, | |
| compare: true, | |
| defaultProps: true, | |
| displayName: true, | |
| propTypes: true, | |
| type: true | |
| }; | |
| var TYPE_STATICS = {}; | |
| TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS; | |
| TYPE_STATICS[reactIs.Memo] = MEMO_STATICS; | |
| function getStatics(component) { | |
| // React v16.11 and below | |
| if (reactIs.isMemo(component)) { | |
| return MEMO_STATICS; | |
| } // React v16.12 and above | |
| return TYPE_STATICS[component['$$typeof']] || REACT_STATICS; | |
| } | |
| var defineProperty = Object.defineProperty; | |
| var getOwnPropertyNames = Object.getOwnPropertyNames; | |
| var getOwnPropertySymbols = Object.getOwnPropertySymbols; | |
| var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; | |
| var getPrototypeOf = Object.getPrototypeOf; | |
| var objectPrototype = Object.prototype; | |
| function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) { | |
| if (typeof sourceComponent !== 'string') { | |
| // don't hoist over string (html) components | |
| if (objectPrototype) { | |
| var inheritedComponent = getPrototypeOf(sourceComponent); | |
| if (inheritedComponent && inheritedComponent !== objectPrototype) { | |
| hoistNonReactStatics(targetComponent, inheritedComponent, blacklist); | |
| } | |
| } | |
| var keys = getOwnPropertyNames(sourceComponent); | |
| if (getOwnPropertySymbols) { | |
| keys = keys.concat(getOwnPropertySymbols(sourceComponent)); | |
| } | |
| var targetStatics = getStatics(targetComponent); | |
| var sourceStatics = getStatics(sourceComponent); | |
| for (var i = 0; i < keys.length; ++i) { | |
| var key = keys[i]; | |
| if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) { | |
| var descriptor = getOwnPropertyDescriptor(sourceComponent, key); | |
| try { | |
| // Avoid failures from read-only properties | |
| defineProperty(targetComponent, key, descriptor); | |
| } catch (e) {} | |
| } | |
| } | |
| } | |
| return targetComponent; | |
| } | |
| module.exports = hoistNonReactStatics; | |
| /***/ }), | |
| /***/ "./node_modules/immutable/dist/immutable.es.js": | |
| /*!*****************************************************!*\ | |
| !*** ./node_modules/immutable/dist/immutable.es.js ***! | |
| \*****************************************************/ | |
| /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| "use strict"; | |
| __webpack_require__.r(__webpack_exports__); | |
| /* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| /* harmony export */ "Collection": function() { return /* binding */ Collection; }, | |
| /* harmony export */ "Iterable": function() { return /* binding */ Iterable; }, | |
| /* harmony export */ "List": function() { return /* binding */ List; }, | |
| /* harmony export */ "Map": function() { return /* binding */ Map; }, | |
| /* harmony export */ "OrderedMap": function() { return /* binding */ OrderedMap; }, | |
| /* harmony export */ "OrderedSet": function() { return /* binding */ OrderedSet; }, | |
| /* harmony export */ "PairSorting": function() { return /* binding */ PairSorting; }, | |
| /* harmony export */ "Range": function() { return /* binding */ Range; }, | |
| /* harmony export */ "Record": function() { return /* binding */ Record; }, | |
| /* harmony export */ "Repeat": function() { return /* binding */ Repeat; }, | |
| /* harmony export */ "Seq": function() { return /* binding */ Seq; }, | |
| /* harmony export */ "Set": function() { return /* binding */ Set; }, | |
| /* harmony export */ "Stack": function() { return /* binding */ Stack; }, | |
| /* harmony export */ "fromJS": function() { return /* binding */ fromJS; }, | |
| /* harmony export */ "get": function() { return /* binding */ get; }, | |
| /* harmony export */ "getIn": function() { return /* binding */ getIn$1; }, | |
| /* harmony export */ "has": function() { return /* binding */ has; }, | |
| /* harmony export */ "hasIn": function() { return /* binding */ hasIn$1; }, | |
| /* harmony export */ "hash": function() { return /* binding */ hash; }, | |
| /* harmony export */ "is": function() { return /* binding */ is; }, | |
| /* harmony export */ "isAssociative": function() { return /* binding */ isAssociative; }, | |
| /* harmony export */ "isCollection": function() { return /* binding */ isCollection; }, | |
| /* harmony export */ "isImmutable": function() { return /* binding */ isImmutable; }, | |
| /* harmony export */ "isIndexed": function() { return /* binding */ isIndexed; }, | |
| /* harmony export */ "isKeyed": function() { return /* binding */ isKeyed; }, | |
| /* harmony export */ "isList": function() { return /* binding */ isList; }, | |
| /* harmony export */ "isMap": function() { return /* binding */ isMap; }, | |
| /* harmony export */ "isOrdered": function() { return /* binding */ isOrdered; }, | |
| /* harmony export */ "isOrderedMap": function() { return /* binding */ isOrderedMap; }, | |
| /* harmony export */ "isOrderedSet": function() { return /* binding */ isOrderedSet; }, | |
| /* harmony export */ "isPlainObject": function() { return /* binding */ isPlainObject; }, | |
| /* harmony export */ "isRecord": function() { return /* binding */ isRecord; }, | |
| /* harmony export */ "isSeq": function() { return /* binding */ isSeq; }, | |
| /* harmony export */ "isSet": function() { return /* binding */ isSet; }, | |
| /* harmony export */ "isStack": function() { return /* binding */ isStack; }, | |
| /* harmony export */ "isValueObject": function() { return /* binding */ isValueObject; }, | |
| /* harmony export */ "merge": function() { return /* binding */ merge; }, | |
| /* harmony export */ "mergeDeep": function() { return /* binding */ mergeDeep$1; }, | |
| /* harmony export */ "mergeDeepWith": function() { return /* binding */ mergeDeepWith$1; }, | |
| /* harmony export */ "mergeWith": function() { return /* binding */ mergeWith; }, | |
| /* harmony export */ "remove": function() { return /* binding */ remove; }, | |
| /* harmony export */ "removeIn": function() { return /* binding */ removeIn; }, | |
| /* harmony export */ "set": function() { return /* binding */ set; }, | |
| /* harmony export */ "setIn": function() { return /* binding */ setIn$1; }, | |
| /* harmony export */ "update": function() { return /* binding */ update$1; }, | |
| /* harmony export */ "updateIn": function() { return /* binding */ updateIn$1; }, | |
| /* harmony export */ "version": function() { return /* binding */ version; } | |
| /* harmony export */ }); | |
| /** | |
| * MIT License | |
| * | |
| * Copyright (c) 2014-present, Lee Byron and other contributors. | |
| * | |
| * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| * of this software and associated documentation files (the "Software"), to deal | |
| * in the Software without restriction, including without limitation the rights | |
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| * copies of the Software, and to permit persons to whom the Software is | |
| * furnished to do so, subject to the following conditions: | |
| * | |
| * The above copyright notice and this permission notice shall be included in all | |
| * copies or substantial portions of the Software. | |
| * | |
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
| * SOFTWARE. | |
| */ | |
| var DELETE = 'delete'; | |
| // Constants describing the size of trie nodes. | |
| var SHIFT = 5; // Resulted in best performance after ______? | |
| var SIZE = 1 << SHIFT; | |
| var MASK = SIZE - 1; | |
| // A consistent shared value representing "not set" which equals nothing other | |
| // than itself, and nothing that could be provided externally. | |
| var NOT_SET = {}; | |
| // Boolean references, Rough equivalent of `bool &`. | |
| function MakeRef() { | |
| return { value: false }; | |
| } | |
| function SetRef(ref) { | |
| if (ref) { | |
| ref.value = true; | |
| } | |
| } | |
| // A function which returns a value representing an "owner" for transient writes | |
| // to tries. The return value will only ever equal itself, and will not equal | |
| // the return of any subsequent call of this function. | |
| function OwnerID() {} | |
| function ensureSize(iter) { | |
| if (iter.size === undefined) { | |
| iter.size = iter.__iterate(returnTrue); | |
| } | |
| return iter.size; | |
| } | |
| function wrapIndex(iter, index) { | |
| // This implements "is array index" which the ECMAString spec defines as: | |
| // | |
| // A String property name P is an array index if and only if | |
| // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal | |
| // to 2^32−1. | |
| // | |
| // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects | |
| if (typeof index !== 'number') { | |
| var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32 | |
| if ('' + uint32Index !== index || uint32Index === 4294967295) { | |
| return NaN; | |
| } | |
| index = uint32Index; | |
| } | |
| return index < 0 ? ensureSize(iter) + index : index; | |
| } | |
| function returnTrue() { | |
| return true; | |
| } | |
| function wholeSlice(begin, end, size) { | |
| return ( | |
| ((begin === 0 && !isNeg(begin)) || | |
| (size !== undefined && begin <= -size)) && | |
| (end === undefined || (size !== undefined && end >= size)) | |
| ); | |
| } | |
| function resolveBegin(begin, size) { | |
| return resolveIndex(begin, size, 0); | |
| } | |
| function resolveEnd(end, size) { | |
| return resolveIndex(end, size, size); | |
| } | |
| function resolveIndex(index, size, defaultIndex) { | |
| // Sanitize indices using this shorthand for ToInt32(argument) | |
| // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 | |
| return index === undefined | |
| ? defaultIndex | |
| : isNeg(index) | |
| ? size === Infinity | |
| ? size | |
| : Math.max(0, size + index) | 0 | |
| : size === undefined || size === index | |
| ? index | |
| : Math.min(size, index) | 0; | |
| } | |
| function isNeg(value) { | |
| // Account for -0 which is negative, but not less than 0. | |
| return value < 0 || (value === 0 && 1 / value === -Infinity); | |
| } | |
| var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@'; | |
| function isCollection(maybeCollection) { | |
| return Boolean(maybeCollection && maybeCollection[IS_COLLECTION_SYMBOL]); | |
| } | |
| var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@'; | |
| function isKeyed(maybeKeyed) { | |
| return Boolean(maybeKeyed && maybeKeyed[IS_KEYED_SYMBOL]); | |
| } | |
| var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@'; | |
| function isIndexed(maybeIndexed) { | |
| return Boolean(maybeIndexed && maybeIndexed[IS_INDEXED_SYMBOL]); | |
| } | |
| function isAssociative(maybeAssociative) { | |
| return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); | |
| } | |
| var Collection = function Collection(value) { | |
| return isCollection(value) ? value : Seq(value); | |
| }; | |
| var KeyedCollection = /*@__PURE__*/(function (Collection) { | |
| function KeyedCollection(value) { | |
| return isKeyed(value) ? value : KeyedSeq(value); | |
| } | |
| if ( Collection ) KeyedCollection.__proto__ = Collection; | |
| KeyedCollection.prototype = Object.create( Collection && Collection.prototype ); | |
| KeyedCollection.prototype.constructor = KeyedCollection; | |
| return KeyedCollection; | |
| }(Collection)); | |
| var IndexedCollection = /*@__PURE__*/(function (Collection) { | |
| function IndexedCollection(value) { | |
| return isIndexed(value) ? value : IndexedSeq(value); | |
| } | |
| if ( Collection ) IndexedCollection.__proto__ = Collection; | |
| IndexedCollection.prototype = Object.create( Collection && Collection.prototype ); | |
| IndexedCollection.prototype.constructor = IndexedCollection; | |
| return IndexedCollection; | |
| }(Collection)); | |
| var SetCollection = /*@__PURE__*/(function (Collection) { | |
| function SetCollection(value) { | |
| return isCollection(value) && !isAssociative(value) ? value : SetSeq(value); | |
| } | |
| if ( Collection ) SetCollection.__proto__ = Collection; | |
| SetCollection.prototype = Object.create( Collection && Collection.prototype ); | |
| SetCollection.prototype.constructor = SetCollection; | |
| return SetCollection; | |
| }(Collection)); | |
| Collection.Keyed = KeyedCollection; | |
| Collection.Indexed = IndexedCollection; | |
| Collection.Set = SetCollection; | |
| var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@'; | |
| function isSeq(maybeSeq) { | |
| return Boolean(maybeSeq && maybeSeq[IS_SEQ_SYMBOL]); | |
| } | |
| var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@'; | |
| function isRecord(maybeRecord) { | |
| return Boolean(maybeRecord && maybeRecord[IS_RECORD_SYMBOL]); | |
| } | |
| function isImmutable(maybeImmutable) { | |
| return isCollection(maybeImmutable) || isRecord(maybeImmutable); | |
| } | |
| var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@'; | |
| function isOrdered(maybeOrdered) { | |
| return Boolean(maybeOrdered && maybeOrdered[IS_ORDERED_SYMBOL]); | |
| } | |
| var ITERATE_KEYS = 0; | |
| var ITERATE_VALUES = 1; | |
| var ITERATE_ENTRIES = 2; | |
| var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; | |
| var FAUX_ITERATOR_SYMBOL = '@@iterator'; | |
| var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL; | |
| var Iterator = function Iterator(next) { | |
| this.next = next; | |
| }; | |
| Iterator.prototype.toString = function toString () { | |
| return '[Iterator]'; | |
| }; | |
| Iterator.KEYS = ITERATE_KEYS; | |
| Iterator.VALUES = ITERATE_VALUES; | |
| Iterator.ENTRIES = ITERATE_ENTRIES; | |
| Iterator.prototype.inspect = Iterator.prototype.toSource = function () { | |
| return this.toString(); | |
| }; | |
| Iterator.prototype[ITERATOR_SYMBOL] = function () { | |
| return this; | |
| }; | |
| function iteratorValue(type, k, v, iteratorResult) { | |
| var value = type === 0 ? k : type === 1 ? v : [k, v]; | |
| iteratorResult | |
| ? (iteratorResult.value = value) | |
| : (iteratorResult = { | |
| value: value, | |
| done: false, | |
| }); | |
| return iteratorResult; | |
| } | |
| function iteratorDone() { | |
| return { value: undefined, done: true }; | |
| } | |
| function hasIterator(maybeIterable) { | |
| if (Array.isArray(maybeIterable)) { | |
| // IE11 trick as it does not support `Symbol.iterator` | |
| return true; | |
| } | |
| return !!getIteratorFn(maybeIterable); | |
| } | |
| function isIterator(maybeIterator) { | |
| return maybeIterator && typeof maybeIterator.next === 'function'; | |
| } | |
| function getIterator(iterable) { | |
| var iteratorFn = getIteratorFn(iterable); | |
| return iteratorFn && iteratorFn.call(iterable); | |
| } | |
| function getIteratorFn(iterable) { | |
| var iteratorFn = | |
| iterable && | |
| ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) || | |
| iterable[FAUX_ITERATOR_SYMBOL]); | |
| if (typeof iteratorFn === 'function') { | |
| return iteratorFn; | |
| } | |
| } | |
| function isEntriesIterable(maybeIterable) { | |
| var iteratorFn = getIteratorFn(maybeIterable); | |
| return iteratorFn && iteratorFn === maybeIterable.entries; | |
| } | |
| function isKeysIterable(maybeIterable) { | |
| var iteratorFn = getIteratorFn(maybeIterable); | |
| return iteratorFn && iteratorFn === maybeIterable.keys; | |
| } | |
| var hasOwnProperty = Object.prototype.hasOwnProperty; | |
| function isArrayLike(value) { | |
| if (Array.isArray(value) || typeof value === 'string') { | |
| return true; | |
| } | |
| return ( | |
| value && | |
| typeof value === 'object' && | |
| Number.isInteger(value.length) && | |
| value.length >= 0 && | |
| (value.length === 0 | |
| ? // Only {length: 0} is considered Array-like. | |
| Object.keys(value).length === 1 | |
| : // An object is only Array-like if it has a property where the last value | |
| // in the array-like may be found (which could be undefined). | |
| value.hasOwnProperty(value.length - 1)) | |
| ); | |
| } | |
| var Seq = /*@__PURE__*/(function (Collection) { | |
| function Seq(value) { | |
| return value === undefined || value === null | |
| ? emptySequence() | |
| : isImmutable(value) | |
| ? value.toSeq() | |
| : seqFromValue(value); | |
| } | |
| if ( Collection ) Seq.__proto__ = Collection; | |
| Seq.prototype = Object.create( Collection && Collection.prototype ); | |
| Seq.prototype.constructor = Seq; | |
| Seq.prototype.toSeq = function toSeq () { | |
| return this; | |
| }; | |
| Seq.prototype.toString = function toString () { | |
| return this.__toString('Seq {', '}'); | |
| }; | |
| Seq.prototype.cacheResult = function cacheResult () { | |
| if (!this._cache && this.__iterateUncached) { | |
| this._cache = this.entrySeq().toArray(); | |
| this.size = this._cache.length; | |
| } | |
| return this; | |
| }; | |
| // abstract __iterateUncached(fn, reverse) | |
| Seq.prototype.__iterate = function __iterate (fn, reverse) { | |
| var cache = this._cache; | |
| if (cache) { | |
| var size = cache.length; | |
| var i = 0; | |
| while (i !== size) { | |
| var entry = cache[reverse ? size - ++i : i++]; | |
| if (fn(entry[1], entry[0], this) === false) { | |
| break; | |
| } | |
| } | |
| return i; | |
| } | |
| return this.__iterateUncached(fn, reverse); | |
| }; | |
| // abstract __iteratorUncached(type, reverse) | |
| Seq.prototype.__iterator = function __iterator (type, reverse) { | |
| var cache = this._cache; | |
| if (cache) { | |
| var size = cache.length; | |
| var i = 0; | |
| return new Iterator(function () { | |
| if (i === size) { | |
| return iteratorDone(); | |
| } | |
| var entry = cache[reverse ? size - ++i : i++]; | |
| return iteratorValue(type, entry[0], entry[1]); | |
| }); | |
| } | |
| return this.__iteratorUncached(type, reverse); | |
| }; | |
| return Seq; | |
| }(Collection)); | |
| var KeyedSeq = /*@__PURE__*/(function (Seq) { | |
| function KeyedSeq(value) { | |
| return value === undefined || value === null | |
| ? emptySequence().toKeyedSeq() | |
| : isCollection(value) | |
| ? isKeyed(value) | |
| ? value.toSeq() | |
| : value.fromEntrySeq() | |
| : isRecord(value) | |
| ? value.toSeq() | |
| : keyedSeqFromValue(value); | |
| } | |
| if ( Seq ) KeyedSeq.__proto__ = Seq; | |
| KeyedSeq.prototype = Object.create( Seq && Seq.prototype ); | |
| KeyedSeq.prototype.constructor = KeyedSeq; | |
| KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () { | |
| return this; | |
| }; | |
| return KeyedSeq; | |
| }(Seq)); | |
| var IndexedSeq = /*@__PURE__*/(function (Seq) { | |
| function IndexedSeq(value) { | |
| return value === undefined || value === null | |
| ? emptySequence() | |
| : isCollection(value) | |
| ? isKeyed(value) | |
| ? value.entrySeq() | |
| : value.toIndexedSeq() | |
| : isRecord(value) | |
| ? value.toSeq().entrySeq() | |
| : indexedSeqFromValue(value); | |
| } | |
| if ( Seq ) IndexedSeq.__proto__ = Seq; | |
| IndexedSeq.prototype = Object.create( Seq && Seq.prototype ); | |
| IndexedSeq.prototype.constructor = IndexedSeq; | |
| IndexedSeq.of = function of (/*...values*/) { | |
| return IndexedSeq(arguments); | |
| }; | |
| IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () { | |
| return this; | |
| }; | |
| IndexedSeq.prototype.toString = function toString () { | |
| return this.__toString('Seq [', ']'); | |
| }; | |
| return IndexedSeq; | |
| }(Seq)); | |
| var SetSeq = /*@__PURE__*/(function (Seq) { | |
| function SetSeq(value) { | |
| return ( | |
| isCollection(value) && !isAssociative(value) ? value : IndexedSeq(value) | |
| ).toSetSeq(); | |
| } | |
| if ( Seq ) SetSeq.__proto__ = Seq; | |
| SetSeq.prototype = Object.create( Seq && Seq.prototype ); | |
| SetSeq.prototype.constructor = SetSeq; | |
| SetSeq.of = function of (/*...values*/) { | |
| return SetSeq(arguments); | |
| }; | |
| SetSeq.prototype.toSetSeq = function toSetSeq () { | |
| return this; | |
| }; | |
| return SetSeq; | |
| }(Seq)); | |
| Seq.isSeq = isSeq; | |
| Seq.Keyed = KeyedSeq; | |
| Seq.Set = SetSeq; | |
| Seq.Indexed = IndexedSeq; | |
| Seq.prototype[IS_SEQ_SYMBOL] = true; | |
| // #pragma Root Sequences | |
| var ArraySeq = /*@__PURE__*/(function (IndexedSeq) { | |
| function ArraySeq(array) { | |
| this._array = array; | |
| this.size = array.length; | |
| } | |
| if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq; | |
| ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); | |
| ArraySeq.prototype.constructor = ArraySeq; | |
| ArraySeq.prototype.get = function get (index, notSetValue) { | |
| return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue; | |
| }; | |
| ArraySeq.prototype.__iterate = function __iterate (fn, reverse) { | |
| var array = this._array; | |
| var size = array.length; | |
| var i = 0; | |
| while (i !== size) { | |
| var ii = reverse ? size - ++i : i++; | |
| if (fn(array[ii], ii, this) === false) { | |
| break; | |
| } | |
| } | |
| return i; | |
| }; | |
| ArraySeq.prototype.__iterator = function __iterator (type, reverse) { | |
| var array = this._array; | |
| var size = array.length; | |
| var i = 0; | |
| return new Iterator(function () { | |
| if (i === size) { | |
| return iteratorDone(); | |
| } | |
| var ii = reverse ? size - ++i : i++; | |
| return iteratorValue(type, ii, array[ii]); | |
| }); | |
| }; | |
| return ArraySeq; | |
| }(IndexedSeq)); | |
| var ObjectSeq = /*@__PURE__*/(function (KeyedSeq) { | |
| function ObjectSeq(object) { | |
| var keys = Object.keys(object).concat( | |
| Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [] | |
| ); | |
| this._object = object; | |
| this._keys = keys; | |
| this.size = keys.length; | |
| } | |
| if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq; | |
| ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); | |
| ObjectSeq.prototype.constructor = ObjectSeq; | |
| ObjectSeq.prototype.get = function get (key, notSetValue) { | |
| if (notSetValue !== undefined && !this.has(key)) { | |
| return notSetValue; | |
| } | |
| return this._object[key]; | |
| }; | |
| ObjectSeq.prototype.has = function has (key) { | |
| return hasOwnProperty.call(this._object, key); | |
| }; | |
| ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) { | |
| var object = this._object; | |
| var keys = this._keys; | |
| var size = keys.length; | |
| var i = 0; | |
| while (i !== size) { | |
| var key = keys[reverse ? size - ++i : i++]; | |
| if (fn(object[key], key, this) === false) { | |
| break; | |
| } | |
| } | |
| return i; | |
| }; | |
| ObjectSeq.prototype.__iterator = function __iterator (type, reverse) { | |
| var object = this._object; | |
| var keys = this._keys; | |
| var size = keys.length; | |
| var i = 0; | |
| return new Iterator(function () { | |
| if (i === size) { | |
| return iteratorDone(); | |
| } | |
| var key = keys[reverse ? size - ++i : i++]; | |
| return iteratorValue(type, key, object[key]); | |
| }); | |
| }; | |
| return ObjectSeq; | |
| }(KeyedSeq)); | |
| ObjectSeq.prototype[IS_ORDERED_SYMBOL] = true; | |
| var CollectionSeq = /*@__PURE__*/(function (IndexedSeq) { | |
| function CollectionSeq(collection) { | |
| this._collection = collection; | |
| this.size = collection.length || collection.size; | |
| } | |
| if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq; | |
| CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); | |
| CollectionSeq.prototype.constructor = CollectionSeq; | |
| CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { | |
| if (reverse) { | |
| return this.cacheResult().__iterate(fn, reverse); | |
| } | |
| var collection = this._collection; | |
| var iterator = getIterator(collection); | |
| var iterations = 0; | |
| if (isIterator(iterator)) { | |
| var step; | |
| while (!(step = iterator.next()).done) { | |
| if (fn(step.value, iterations++, this) === false) { | |
| break; | |
| } | |
| } | |
| } | |
| return iterations; | |
| }; | |
| CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { | |
| if (reverse) { | |
| return this.cacheResult().__iterator(type, reverse); | |
| } | |
| var collection = this._collection; | |
| var iterator = getIterator(collection); | |
| if (!isIterator(iterator)) { | |
| return new Iterator(iteratorDone); | |
| } | |
| var iterations = 0; | |
| return new Iterator(function () { | |
| var step = iterator.next(); | |
| return step.done ? step : iteratorValue(type, iterations++, step.value); | |
| }); | |
| }; | |
| return CollectionSeq; | |
| }(IndexedSeq)); | |
| // # pragma Helper functions | |
| var EMPTY_SEQ; | |
| function emptySequence() { | |
| return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([])); | |
| } | |
| function keyedSeqFromValue(value) { | |
| var seq = maybeIndexedSeqFromValue(value); | |
| if (seq) { | |
| return seq.fromEntrySeq(); | |
| } | |
| if (typeof value === 'object') { | |
| return new ObjectSeq(value); | |
| } | |
| throw new TypeError( | |
| 'Expected Array or collection object of [k, v] entries, or keyed object: ' + | |
| value | |
| ); | |
| } | |
| function indexedSeqFromValue(value) { | |
| var seq = maybeIndexedSeqFromValue(value); | |
| if (seq) { | |
| return seq; | |
| } | |
| throw new TypeError( | |
| 'Expected Array or collection object of values: ' + value | |
| ); | |
| } | |
| function seqFromValue(value) { | |
| var seq = maybeIndexedSeqFromValue(value); | |
| if (seq) { | |
| return isEntriesIterable(value) | |
| ? seq.fromEntrySeq() | |
| : isKeysIterable(value) | |
| ? seq.toSetSeq() | |
| : seq; | |
| } | |
| if (typeof value === 'object') { | |
| return new ObjectSeq(value); | |
| } | |
| throw new TypeError( | |
| 'Expected Array or collection object of values, or keyed object: ' + value | |
| ); | |
| } | |
| function maybeIndexedSeqFromValue(value) { | |
| return isArrayLike(value) | |
| ? new ArraySeq(value) | |
| : hasIterator(value) | |
| ? new CollectionSeq(value) | |
| : undefined; | |
| } | |
| var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@'; | |
| function isMap(maybeMap) { | |
| return Boolean(maybeMap && maybeMap[IS_MAP_SYMBOL]); | |
| } | |
| function isOrderedMap(maybeOrderedMap) { | |
| return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap); | |
| } | |
| function isValueObject(maybeValue) { | |
| return Boolean( | |
| maybeValue && | |
| typeof maybeValue.equals === 'function' && | |
| typeof maybeValue.hashCode === 'function' | |
| ); | |
| } | |
| /** | |
| * An extension of the "same-value" algorithm as [described for use by ES6 Map | |
| * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality) | |
| * | |
| * NaN is considered the same as NaN, however -0 and 0 are considered the same | |
| * value, which is different from the algorithm described by | |
| * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). | |
| * | |
| * This is extended further to allow Objects to describe the values they | |
| * represent, by way of `valueOf` or `equals` (and `hashCode`). | |
| * | |
| * Note: because of this extension, the key equality of Immutable.Map and the | |
| * value equality of Immutable.Set will differ from ES6 Map and Set. | |
| * | |
| * ### Defining custom values | |
| * | |
| * The easiest way to describe the value an object represents is by implementing | |
| * `valueOf`. For example, `Date` represents a value by returning a unix | |
| * timestamp for `valueOf`: | |
| * | |
| * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ... | |
| * var date2 = new Date(1234567890000); | |
| * date1.valueOf(); // 1234567890000 | |
| * assert( date1 !== date2 ); | |
| * assert( Immutable.is( date1, date2 ) ); | |
| * | |
| * Note: overriding `valueOf` may have other implications if you use this object | |
| * where JavaScript expects a primitive, such as implicit string coercion. | |
| * | |
| * For more complex types, especially collections, implementing `valueOf` may | |
| * not be performant. An alternative is to implement `equals` and `hashCode`. | |
| * | |
| * `equals` takes another object, presumably of similar type, and returns true | |
| * if it is equal. Equality is symmetrical, so the same result should be | |
| * returned if this and the argument are flipped. | |
| * | |
| * assert( a.equals(b) === b.equals(a) ); | |
| * | |
| * `hashCode` returns a 32bit integer number representing the object which will | |
| * be used to determine how to store the value object in a Map or Set. You must | |
| * provide both or neither methods, one must not exist without the other. | |
| * | |
| * Also, an important relationship between these methods must be upheld: if two | |
| * values are equal, they *must* return the same hashCode. If the values are not | |
| * equal, they might have the same hashCode; this is called a hash collision, | |
| * and while undesirable for performance reasons, it is acceptable. | |
| * | |
| * if (a.equals(b)) { | |
| * assert( a.hashCode() === b.hashCode() ); | |
| * } | |
| * | |
| * All Immutable collections are Value Objects: they implement `equals()` | |
| * and `hashCode()`. | |
| */ | |
| function is(valueA, valueB) { | |
| if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { | |
| return true; | |
| } | |
| if (!valueA || !valueB) { | |
| return false; | |
| } | |
| if ( | |
| typeof valueA.valueOf === 'function' && | |
| typeof valueB.valueOf === 'function' | |
| ) { | |
| valueA = valueA.valueOf(); | |
| valueB = valueB.valueOf(); | |
| if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { | |
| return true; | |
| } | |
| if (!valueA || !valueB) { | |
| return false; | |
| } | |
| } | |
| return !!( | |
| isValueObject(valueA) && | |
| isValueObject(valueB) && | |
| valueA.equals(valueB) | |
| ); | |
| } | |
| var imul = | |
| typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 | |
| ? Math.imul | |
| : function imul(a, b) { | |
| a |= 0; // int | |
| b |= 0; // int | |
| var c = a & 0xffff; | |
| var d = b & 0xffff; | |
| // Shift by 0 fixes the sign on the high part. | |
| return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int | |
| }; | |
| // v8 has an optimization for storing 31-bit signed numbers. | |
| // Values which have either 00 or 11 as the high order bits qualify. | |
| // This function drops the highest order bit in a signed number, maintaining | |
| // the sign bit. | |
| function smi(i32) { | |
| return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff); | |
| } | |
| var defaultValueOf = Object.prototype.valueOf; | |
| function hash(o) { | |
| if (o == null) { | |
| return hashNullish(o); | |
| } | |
| if (typeof o.hashCode === 'function') { | |
| // Drop any high bits from accidentally long hash codes. | |
| return smi(o.hashCode(o)); | |
| } | |
| var v = valueOf(o); | |
| if (v == null) { | |
| return hashNullish(v); | |
| } | |
| switch (typeof v) { | |
| case 'boolean': | |
| // The hash values for built-in constants are a 1 value for each 5-byte | |
| // shift region expect for the first, which encodes the value. This | |
| // reduces the odds of a hash collision for these common values. | |
| return v ? 0x42108421 : 0x42108420; | |
| case 'number': | |
| return hashNumber(v); | |
| case 'string': | |
| return v.length > STRING_HASH_CACHE_MIN_STRLEN | |
| ? cachedHashString(v) | |
| : hashString(v); | |
| case 'object': | |
| case 'function': | |
| return hashJSObj(v); | |
| case 'symbol': | |
| return hashSymbol(v); | |
| default: | |
| if (typeof v.toString === 'function') { | |
| return hashString(v.toString()); | |
| } | |
| throw new Error('Value type ' + typeof v + ' cannot be hashed.'); | |
| } | |
| } | |
| function hashNullish(nullish) { | |
| return nullish === null ? 0x42108422 : /* undefined */ 0x42108423; | |
| } | |
| // Compress arbitrarily large numbers into smi hashes. | |
| function hashNumber(n) { | |
| if (n !== n || n === Infinity) { | |
| return 0; | |
| } | |
| var hash = n | 0; | |
| if (hash !== n) { | |
| hash ^= n * 0xffffffff; | |
| } | |
| while (n > 0xffffffff) { | |
| n /= 0xffffffff; | |
| hash ^= n; | |
| } | |
| return smi(hash); | |
| } | |
| function cachedHashString(string) { | |
| var hashed = stringHashCache[string]; | |
| if (hashed === undefined) { | |
| hashed = hashString(string); | |
| if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { | |
| STRING_HASH_CACHE_SIZE = 0; | |
| stringHashCache = {}; | |
| } | |
| STRING_HASH_CACHE_SIZE++; | |
| stringHashCache[string] = hashed; | |
| } | |
| return hashed; | |
| } | |
| // http://jsperf.com/hashing-strings | |
| function hashString(string) { | |
| // This is the hash from JVM | |
| // The hash code for a string is computed as | |
| // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], | |
| // where s[i] is the ith character of the string and n is the length of | |
| // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 | |
| // (exclusive) by dropping high bits. | |
| var hashed = 0; | |
| for (var ii = 0; ii < string.length; ii++) { | |
| hashed = (31 * hashed + string.charCodeAt(ii)) | 0; | |
| } | |
| return smi(hashed); | |
| } | |
| function hashSymbol(sym) { | |
| var hashed = symbolMap[sym]; | |
| if (hashed !== undefined) { | |
| return hashed; | |
| } | |
| hashed = nextHash(); | |
| symbolMap[sym] = hashed; | |
| return hashed; | |
| } | |
| function hashJSObj(obj) { | |
| var hashed; | |
| if (usingWeakMap) { | |
| hashed = weakMap.get(obj); | |
| if (hashed !== undefined) { | |
| return hashed; | |
| } | |
| } | |
| hashed = obj[UID_HASH_KEY]; | |
| if (hashed !== undefined) { | |
| return hashed; | |
| } | |
| if (!canDefineProperty) { | |
| hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; | |
| if (hashed !== undefined) { | |
| return hashed; | |
| } | |
| hashed = getIENodeHash(obj); | |
| if (hashed !== undefined) { | |
| return hashed; | |
| } | |
| } | |
| hashed = nextHash(); | |
| if (usingWeakMap) { | |
| weakMap.set(obj, hashed); | |
| } else if (isExtensible !== undefined && isExtensible(obj) === false) { | |
| throw new Error('Non-extensible objects are not allowed as keys.'); | |
| } else if (canDefineProperty) { | |
| Object.defineProperty(obj, UID_HASH_KEY, { | |
| enumerable: false, | |
| configurable: false, | |
| writable: false, | |
| value: hashed, | |
| }); | |
| } else if ( | |
| obj.propertyIsEnumerable !== undefined && | |
| obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable | |
| ) { | |
| // Since we can't define a non-enumerable property on the object | |
| // we'll hijack one of the less-used non-enumerable properties to | |
| // save our hash on it. Since this is a function it will not show up in | |
| // `JSON.stringify` which is what we want. | |
| obj.propertyIsEnumerable = function () { | |
| return this.constructor.prototype.propertyIsEnumerable.apply( | |
| this, | |
| arguments | |
| ); | |
| }; | |
| obj.propertyIsEnumerable[UID_HASH_KEY] = hashed; | |
| } else if (obj.nodeType !== undefined) { | |
| // At this point we couldn't get the IE `uniqueID` to use as a hash | |
| // and we couldn't use a non-enumerable property to exploit the | |
| // dontEnum bug so we simply add the `UID_HASH_KEY` on the node | |
| // itself. | |
| obj[UID_HASH_KEY] = hashed; | |
| } else { | |
| throw new Error('Unable to set a non-enumerable property on object.'); | |
| } | |
| return hashed; | |
| } | |
| // Get references to ES5 object methods. | |
| var isExtensible = Object.isExtensible; | |
| // True if Object.defineProperty works as expected. IE8 fails this test. | |
| var canDefineProperty = (function () { | |
| try { | |
| Object.defineProperty({}, '@', {}); | |
| return true; | |
| } catch (e) { | |
| return false; | |
| } | |
| })(); | |
| // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it | |
| // and avoid memory leaks from the IE cloneNode bug. | |
| function getIENodeHash(node) { | |
| if (node && node.nodeType > 0) { | |
| switch (node.nodeType) { | |
| case 1: // Element | |
| return node.uniqueID; | |
| case 9: // Document | |
| return node.documentElement && node.documentElement.uniqueID; | |
| } | |
| } | |
| } | |
| function valueOf(obj) { | |
| return obj.valueOf !== defaultValueOf && typeof obj.valueOf === 'function' | |
| ? obj.valueOf(obj) | |
| : obj; | |
| } | |
| function nextHash() { | |
| var nextHash = ++_objHashUID; | |
| if (_objHashUID & 0x40000000) { | |
| _objHashUID = 0; | |
| } | |
| return nextHash; | |
| } | |
| // If possible, use a WeakMap. | |
| var usingWeakMap = typeof WeakMap === 'function'; | |
| var weakMap; | |
| if (usingWeakMap) { | |
| weakMap = new WeakMap(); | |
| } | |
| var symbolMap = Object.create(null); | |
| var _objHashUID = 0; | |
| var UID_HASH_KEY = '__immutablehash__'; | |
| if (typeof Symbol === 'function') { | |
| UID_HASH_KEY = Symbol(UID_HASH_KEY); | |
| } | |
| var STRING_HASH_CACHE_MIN_STRLEN = 16; | |
| var STRING_HASH_CACHE_MAX_SIZE = 255; | |
| var STRING_HASH_CACHE_SIZE = 0; | |
| var stringHashCache = {}; | |
| var ToKeyedSequence = /*@__PURE__*/(function (KeyedSeq) { | |
| function ToKeyedSequence(indexed, useKeys) { | |
| this._iter = indexed; | |
| this._useKeys = useKeys; | |
| this.size = indexed.size; | |
| } | |
| if ( KeyedSeq ) ToKeyedSequence.__proto__ = KeyedSeq; | |
| ToKeyedSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); | |
| ToKeyedSequence.prototype.constructor = ToKeyedSequence; | |
| ToKeyedSequence.prototype.get = function get (key, notSetValue) { | |
| return this._iter.get(key, notSetValue); | |
| }; | |
| ToKeyedSequence.prototype.has = function has (key) { | |
| return this._iter.has(key); | |
| }; | |
| ToKeyedSequence.prototype.valueSeq = function valueSeq () { | |
| return this._iter.valueSeq(); | |
| }; | |
| ToKeyedSequence.prototype.reverse = function reverse () { | |
| var this$1$1 = this; | |
| var reversedSequence = reverseFactory(this, true); | |
| if (!this._useKeys) { | |
| reversedSequence.valueSeq = function () { return this$1$1._iter.toSeq().reverse(); }; | |
| } | |
| return reversedSequence; | |
| }; | |
| ToKeyedSequence.prototype.map = function map (mapper, context) { | |
| var this$1$1 = this; | |
| var mappedSequence = mapFactory(this, mapper, context); | |
| if (!this._useKeys) { | |
| mappedSequence.valueSeq = function () { return this$1$1._iter.toSeq().map(mapper, context); }; | |
| } | |
| return mappedSequence; | |
| }; | |
| ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) { | |
| var this$1$1 = this; | |
| return this._iter.__iterate(function (v, k) { return fn(v, k, this$1$1); }, reverse); | |
| }; | |
| ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) { | |
| return this._iter.__iterator(type, reverse); | |
| }; | |
| return ToKeyedSequence; | |
| }(KeyedSeq)); | |
| ToKeyedSequence.prototype[IS_ORDERED_SYMBOL] = true; | |
| var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq) { | |
| function ToIndexedSequence(iter) { | |
| this._iter = iter; | |
| this.size = iter.size; | |
| } | |
| if ( IndexedSeq ) ToIndexedSequence.__proto__ = IndexedSeq; | |
| ToIndexedSequence.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); | |
| ToIndexedSequence.prototype.constructor = ToIndexedSequence; | |
| ToIndexedSequence.prototype.includes = function includes (value) { | |
| return this._iter.includes(value); | |
| }; | |
| ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) { | |
| var this$1$1 = this; | |
| var i = 0; | |
| reverse && ensureSize(this); | |
| return this._iter.__iterate( | |
| function (v) { return fn(v, reverse ? this$1$1.size - ++i : i++, this$1$1); }, | |
| reverse | |
| ); | |
| }; | |
| ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) { | |
| var this$1$1 = this; | |
| var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); | |
| var i = 0; | |
| reverse && ensureSize(this); | |
| return new Iterator(function () { | |
| var step = iterator.next(); | |
| return step.done | |
| ? step | |
| : iteratorValue( | |
| type, | |
| reverse ? this$1$1.size - ++i : i++, | |
| step.value, | |
| step | |
| ); | |
| }); | |
| }; | |
| return ToIndexedSequence; | |
| }(IndexedSeq)); | |
| var ToSetSequence = /*@__PURE__*/(function (SetSeq) { | |
| function ToSetSequence(iter) { | |
| this._iter = iter; | |
| this.size = iter.size; | |
| } | |
| if ( SetSeq ) ToSetSequence.__proto__ = SetSeq; | |
| ToSetSequence.prototype = Object.create( SetSeq && SetSeq.prototype ); | |
| ToSetSequence.prototype.constructor = ToSetSequence; | |
| ToSetSequence.prototype.has = function has (key) { | |
| return this._iter.includes(key); | |
| }; | |
| ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) { | |
| var this$1$1 = this; | |
| return this._iter.__iterate(function (v) { return fn(v, v, this$1$1); }, reverse); | |
| }; | |
| ToSetSequence.prototype.__iterator = function __iterator (type, reverse) { | |
| var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); | |
| return new Iterator(function () { | |
| var step = iterator.next(); | |
| return step.done | |
| ? step | |
| : iteratorValue(type, step.value, step.value, step); | |
| }); | |
| }; | |
| return ToSetSequence; | |
| }(SetSeq)); | |
| var FromEntriesSequence = /*@__PURE__*/(function (KeyedSeq) { | |
| function FromEntriesSequence(entries) { | |
| this._iter = entries; | |
| this.size = entries.size; | |
| } | |
| if ( KeyedSeq ) FromEntriesSequence.__proto__ = KeyedSeq; | |
| FromEntriesSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); | |
| FromEntriesSequence.prototype.constructor = FromEntriesSequence; | |
| FromEntriesSequence.prototype.entrySeq = function entrySeq () { | |
| return this._iter.toSeq(); | |
| }; | |
| FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) { | |
| var this$1$1 = this; | |
| return this._iter.__iterate(function (entry) { | |
| // Check if entry exists first so array access doesn't throw for holes | |
| // in the parent iteration. | |
| if (entry) { | |
| validateEntry(entry); | |
| var indexedCollection = isCollection(entry); | |
| return fn( | |
| indexedCollection ? entry.get(1) : entry[1], | |
| indexedCollection ? entry.get(0) : entry[0], | |
| this$1$1 | |
| ); | |
| } | |
| }, reverse); | |
| }; | |
| FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) { | |
| var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); | |
| return new Iterator(function () { | |
| while (true) { | |
| var step = iterator.next(); | |
| if (step.done) { | |
| return step; | |
| } | |
| var entry = step.value; | |
| // Check if entry exists first so array access doesn't throw for holes | |
| // in the parent iteration. | |
| if (entry) { | |
| validateEntry(entry); | |
| var indexedCollection = isCollection(entry); | |
| return iteratorValue( | |
| type, | |
| indexedCollection ? entry.get(0) : entry[0], | |
| indexedCollection ? entry.get(1) : entry[1], | |
| step | |
| ); | |
| } | |
| } | |
| }); | |
| }; | |
| return FromEntriesSequence; | |
| }(KeyedSeq)); | |
| ToIndexedSequence.prototype.cacheResult = | |
| ToKeyedSequence.prototype.cacheResult = | |
| ToSetSequence.prototype.cacheResult = | |
| FromEntriesSequence.prototype.cacheResult = | |
| cacheResultThrough; | |
| function flipFactory(collection) { | |
| var flipSequence = makeSequence(collection); | |
| flipSequence._iter = collection; | |
| flipSequence.size = collection.size; | |
| flipSequence.flip = function () { return collection; }; | |
| flipSequence.reverse = function () { | |
| var reversedSequence = collection.reverse.apply(this); // super.reverse() | |
| reversedSequence.flip = function () { return collection.reverse(); }; | |
| return reversedSequence; | |
| }; | |
| flipSequence.has = function (key) { return collection.includes(key); }; | |
| flipSequence.includes = function (key) { return collection.has(key); }; | |
| flipSequence.cacheResult = cacheResultThrough; | |
| flipSequence.__iterateUncached = function (fn, reverse) { | |
| var this$1$1 = this; | |
| return collection.__iterate(function (v, k) { return fn(k, v, this$1$1) !== false; }, reverse); | |
| }; | |
| flipSequence.__iteratorUncached = function (type, reverse) { | |
| if (type === ITERATE_ENTRIES) { | |
| var iterator = collection.__iterator(type, reverse); | |
| return new Iterator(function () { | |
| var step = iterator.next(); | |
| if (!step.done) { | |
| var k = step.value[0]; | |
| step.value[0] = step.value[1]; | |
| step.value[1] = k; | |
| } | |
| return step; | |
| }); | |
| } | |
| return collection.__iterator( | |
| type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES, | |
| reverse | |
| ); | |
| }; | |
| return flipSequence; | |
| } | |
| function mapFactory(collection, mapper, context) { | |
| var mappedSequence = makeSequence(collection); | |
| mappedSequence.size = collection.size; | |
| mappedSequence.has = function (key) { return collection.has(key); }; | |
| mappedSequence.get = function (key, notSetValue) { | |
| var v = collection.get(key, NOT_SET); | |
| return v === NOT_SET | |
| ? notSetValue | |
| : mapper.call(context, v, key, collection); | |
| }; | |
| mappedSequence.__iterateUncached = function (fn, reverse) { | |
| var this$1$1 = this; | |
| return collection.__iterate( | |
| function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1$1) !== false; }, | |
| reverse | |
| ); | |
| }; | |
| mappedSequence.__iteratorUncached = function (type, reverse) { | |
| var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); | |
| return new Iterator(function () { | |
| var step = iterator.next(); | |
| if (step.done) { | |
| return step; | |
| } | |
| var entry = step.value; | |
| var key = entry[0]; | |
| return iteratorValue( | |
| type, | |
| key, | |
| mapper.call(context, entry[1], key, collection), | |
| step | |
| ); | |
| }); | |
| }; | |
| return mappedSequence; | |
| } | |
| function reverseFactory(collection, useKeys) { | |
| var this$1$1 = this; | |
| var reversedSequence = makeSequence(collection); | |
| reversedSequence._iter = collection; | |
| reversedSequence.size = collection.size; | |
| reversedSequence.reverse = function () { return collection; }; | |
| if (collection.flip) { | |
| reversedSequence.flip = function () { | |
| var flipSequence = flipFactory(collection); | |
| flipSequence.reverse = function () { return collection.flip(); }; | |
| return flipSequence; | |
| }; | |
| } | |
| reversedSequence.get = function (key, notSetValue) { return collection.get(useKeys ? key : -1 - key, notSetValue); }; | |
| reversedSequence.has = function (key) { return collection.has(useKeys ? key : -1 - key); }; | |
| reversedSequence.includes = function (value) { return collection.includes(value); }; | |
| reversedSequence.cacheResult = cacheResultThrough; | |
| reversedSequence.__iterate = function (fn, reverse) { | |
| var this$1$1 = this; | |
| var i = 0; | |
| reverse && ensureSize(collection); | |
| return collection.__iterate( | |
| function (v, k) { return fn(v, useKeys ? k : reverse ? this$1$1.size - ++i : i++, this$1$1); }, | |
| !reverse | |
| ); | |
| }; | |
| reversedSequence.__iterator = function (type, reverse) { | |
| var i = 0; | |
| reverse && ensureSize(collection); | |
| var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse); | |
| return new Iterator(function () { | |
| var step = iterator.next(); | |
| if (step.done) { | |
| return step; | |
| } | |
| var entry = step.value; | |
| return iteratorValue( | |
| type, | |
| useKeys ? entry[0] : reverse ? this$1$1.size - ++i : i++, | |
| entry[1], | |
| step | |
| ); | |
| }); | |
| }; | |
| return reversedSequence; | |
| } | |
| function filterFactory(collection, predicate, context, useKeys) { | |
| var filterSequence = makeSequence(collection); | |
| if (useKeys) { | |
| filterSequence.has = function (key) { | |
| var v = collection.get(key, NOT_SET); | |
| return v !== NOT_SET && !!predicate.call(context, v, key, collection); | |
| }; | |
| filterSequence.get = function (key, notSetValue) { | |
| var v = collection.get(key, NOT_SET); | |
| return v !== NOT_SET && predicate.call(context, v, key, collection) | |
| ? v | |
| : notSetValue; | |
| }; | |
| } | |
| filterSequence.__iterateUncached = function (fn, reverse) { | |
| var this$1$1 = this; | |
| var iterations = 0; | |
| collection.__iterate(function (v, k, c) { | |
| if (predicate.call(context, v, k, c)) { | |
| iterations++; | |
| return fn(v, useKeys ? k : iterations - 1, this$1$1); | |
| } | |
| }, reverse); | |
| return iterations; | |
| }; | |
| filterSequence.__iteratorUncached = function (type, reverse) { | |
| var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); | |
| var iterations = 0; | |
| return new Iterator(function () { | |
| while (true) { | |
| var step = iterator.next(); | |
| if (step.done) { | |
| return step; | |
| } | |
| var entry = step.value; | |
| var key = entry[0]; | |
| var value = entry[1]; | |
| if (predicate.call(context, value, key, collection)) { | |
| return iteratorValue(type, useKeys ? key : iterations++, value, step); | |
| } | |
| } | |
| }); | |
| }; | |
| return filterSequence; | |
| } | |
| function countByFactory(collection, grouper, context) { | |
| var groups = Map().asMutable(); | |
| collection.__iterate(function (v, k) { | |
| groups.update(grouper.call(context, v, k, collection), 0, function (a) { return a + 1; }); | |
| }); | |
| return groups.asImmutable(); | |
| } | |
| function groupByFactory(collection, grouper, context) { | |
| var isKeyedIter = isKeyed(collection); | |
| var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable(); | |
| collection.__iterate(function (v, k) { | |
| groups.update( | |
| grouper.call(context, v, k, collection), | |
| function (a) { return ((a = a || []), a.push(isKeyedIter ? [k, v] : v), a); } | |
| ); | |
| }); | |
| var coerce = collectionClass(collection); | |
| return groups.map(function (arr) { return reify(collection, coerce(arr)); }).asImmutable(); | |
| } | |
| function partitionFactory(collection, predicate, context) { | |
| var isKeyedIter = isKeyed(collection); | |
| var groups = [[], []]; | |
| collection.__iterate(function (v, k) { | |
| groups[predicate.call(context, v, k, collection) ? 1 : 0].push( | |
| isKeyedIter ? [k, v] : v | |
| ); | |
| }); | |
| var coerce = collectionClass(collection); | |
| return groups.map(function (arr) { return reify(collection, coerce(arr)); }); | |
| } | |
| function sliceFactory(collection, begin, end, useKeys) { | |
| var originalSize = collection.size; | |
| if (wholeSlice(begin, end, originalSize)) { | |
| return collection; | |
| } | |
| var resolvedBegin = resolveBegin(begin, originalSize); | |
| var resolvedEnd = resolveEnd(end, originalSize); | |
| // begin or end will be NaN if they were provided as negative numbers and | |
| // this collection's size is unknown. In that case, cache first so there is | |
| // a known size and these do not resolve to NaN. | |
| if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) { | |
| return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys); | |
| } | |
| // Note: resolvedEnd is undefined when the original sequence's length is | |
| // unknown and this slice did not supply an end and should contain all | |
| // elements after resolvedBegin. | |
| // In that case, resolvedSize will be NaN and sliceSize will remain undefined. | |
| var resolvedSize = resolvedEnd - resolvedBegin; | |
| var sliceSize; | |
| if (resolvedSize === resolvedSize) { | |
| sliceSize = resolvedSize < 0 ? 0 : resolvedSize; | |
| } | |
| var sliceSeq = makeSequence(collection); | |
| // If collection.size is undefined, the size of the realized sliceSeq is | |
| // unknown at this point unless the number of items to slice is 0 | |
| sliceSeq.size = | |
| sliceSize === 0 ? sliceSize : (collection.size && sliceSize) || undefined; | |
| if (!useKeys && isSeq(collection) && sliceSize >= 0) { | |
| sliceSeq.get = function (index, notSetValue) { | |
| index = wrapIndex(this, index); | |
| return index >= 0 && index < sliceSize | |
| ? collection.get(index + resolvedBegin, notSetValue) | |
| : notSetValue; | |
| }; | |
| } | |
| sliceSeq.__iterateUncached = function (fn, reverse) { | |
| var this$1$1 = this; | |
| if (sliceSize === 0) { | |
| return 0; | |
| } | |
| if (reverse) { | |
| return this.cacheResult().__iterate(fn, reverse); | |
| } | |
| var skipped = 0; | |
| var isSkipping = true; | |
| var iterations = 0; | |
| collection.__iterate(function (v, k) { | |
| if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { | |
| iterations++; | |
| return ( | |
| fn(v, useKeys ? k : iterations - 1, this$1$1) !== false && | |
| iterations !== sliceSize | |
| ); | |
| } | |
| }); | |
| return iterations; | |
| }; | |
| sliceSeq.__iteratorUncached = function (type, reverse) { | |
| if (sliceSize !== 0 && reverse) { | |
| return this.cacheResult().__iterator(type, reverse); | |
| } | |
| // Don't bother instantiating parent iterator if taking 0. | |
| if (sliceSize === 0) { | |
| return new Iterator(iteratorDone); | |
| } | |
| var iterator = collection.__iterator(type, reverse); | |
| var skipped = 0; | |
| var iterations = 0; | |
| return new Iterator(function () { | |
| while (skipped++ < resolvedBegin) { | |
| iterator.next(); | |
| } | |
| if (++iterations > sliceSize) { | |
| return iteratorDone(); | |
| } | |
| var step = iterator.next(); | |
| if (useKeys || type === ITERATE_VALUES || step.done) { | |
| return step; | |
| } | |
| if (type === ITERATE_KEYS) { | |
| return iteratorValue(type, iterations - 1, undefined, step); | |
| } | |
| return iteratorValue(type, iterations - 1, step.value[1], step); | |
| }); | |
| }; | |
| return sliceSeq; | |
| } | |
| function takeWhileFactory(collection, predicate, context) { | |
| var takeSequence = makeSequence(collection); | |
| takeSequence.__iterateUncached = function (fn, reverse) { | |
| var this$1$1 = this; | |
| if (reverse) { | |
| return this.cacheResult().__iterate(fn, reverse); | |
| } | |
| var iterations = 0; | |
| collection.__iterate( | |
| function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1$1); } | |
| ); | |
| return iterations; | |
| }; | |
| takeSequence.__iteratorUncached = function (type, reverse) { | |
| var this$1$1 = this; | |
| if (reverse) { | |
| return this.cacheResult().__iterator(type, reverse); | |
| } | |
| var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); | |
| var iterating = true; | |
| return new Iterator(function () { | |
| if (!iterating) { | |
| return iteratorDone(); | |
| } | |
| var step = iterator.next(); | |
| if (step.done) { | |
| return step; | |
| } | |
| var entry = step.value; | |
| var k = entry[0]; | |
| var v = entry[1]; | |
| if (!predicate.call(context, v, k, this$1$1)) { | |
| iterating = false; | |
| return iteratorDone(); | |
| } | |
| return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); | |
| }); | |
| }; | |
| return takeSequence; | |
| } | |
| function skipWhileFactory(collection, predicate, context, useKeys) { | |
| var skipSequence = makeSequence(collection); | |
| skipSequence.__iterateUncached = function (fn, reverse) { | |
| var this$1$1 = this; | |
| if (reverse) { | |
| return this.cacheResult().__iterate(fn, reverse); | |
| } | |
| var isSkipping = true; | |
| var iterations = 0; | |
| collection.__iterate(function (v, k, c) { | |
| if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) { | |
| iterations++; | |
| return fn(v, useKeys ? k : iterations - 1, this$1$1); | |
| } | |
| }); | |
| return iterations; | |
| }; | |
| skipSequence.__iteratorUncached = function (type, reverse) { | |
| var this$1$1 = this; | |
| if (reverse) { | |
| return this.cacheResult().__iterator(type, reverse); | |
| } | |
| var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); | |
| var skipping = true; | |
| var iterations = 0; | |
| return new Iterator(function () { | |
| var step; | |
| var k; | |
| var v; | |
| do { | |
| step = iterator.next(); | |
| if (step.done) { | |
| if (useKeys || type === ITERATE_VALUES) { | |
| return step; | |
| } | |
| if (type === ITERATE_KEYS) { | |
| return iteratorValue(type, iterations++, undefined, step); | |
| } | |
| return iteratorValue(type, iterations++, step.value[1], step); | |
| } | |
| var entry = step.value; | |
| k = entry[0]; | |
| v = entry[1]; | |
| skipping && (skipping = predicate.call(context, v, k, this$1$1)); | |
| } while (skipping); | |
| return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); | |
| }); | |
| }; | |
| return skipSequence; | |
| } | |
| function concatFactory(collection, values) { | |
| var isKeyedCollection = isKeyed(collection); | |
| var iters = [collection] | |
| .concat(values) | |
| .map(function (v) { | |
| if (!isCollection(v)) { | |
| v = isKeyedCollection | |
| ? keyedSeqFromValue(v) | |
| : indexedSeqFromValue(Array.isArray(v) ? v : [v]); | |
| } else if (isKeyedCollection) { | |
| v = KeyedCollection(v); | |
| } | |
| return v; | |
| }) | |
| .filter(function (v) { return v.size !== 0; }); | |
| if (iters.length === 0) { | |
| return collection; | |
| } | |
| if (iters.length === 1) { | |
| var singleton = iters[0]; | |
| if ( | |
| singleton === collection || | |
| (isKeyedCollection && isKeyed(singleton)) || | |
| (isIndexed(collection) && isIndexed(singleton)) | |
| ) { | |
| return singleton; | |
| } | |
| } | |
| var concatSeq = new ArraySeq(iters); | |
| if (isKeyedCollection) { | |
| concatSeq = concatSeq.toKeyedSeq(); | |
| } else if (!isIndexed(collection)) { | |
| concatSeq = concatSeq.toSetSeq(); | |
| } | |
| concatSeq = concatSeq.flatten(true); | |
| concatSeq.size = iters.reduce(function (sum, seq) { | |
| if (sum !== undefined) { | |
| var size = seq.size; | |
| if (size !== undefined) { | |
| return sum + size; | |
| } | |
| } | |
| }, 0); | |
| return concatSeq; | |
| } | |
| function flattenFactory(collection, depth, useKeys) { | |
| var flatSequence = makeSequence(collection); | |
| flatSequence.__iterateUncached = function (fn, reverse) { | |
| if (reverse) { | |
| return this.cacheResult().__iterate(fn, reverse); | |
| } | |
| var iterations = 0; | |
| var stopped = false; | |
| function flatDeep(iter, currentDepth) { | |
| iter.__iterate(function (v, k) { | |
| if ((!depth || currentDepth < depth) && isCollection(v)) { | |
| flatDeep(v, currentDepth + 1); | |
| } else { | |
| iterations++; | |
| if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) { | |
| stopped = true; | |
| } | |
| } | |
| return !stopped; | |
| }, reverse); | |
| } | |
| flatDeep(collection, 0); | |
| return iterations; | |
| }; | |
| flatSequence.__iteratorUncached = function (type, reverse) { | |
| if (reverse) { | |
| return this.cacheResult().__iterator(type, reverse); | |
| } | |
| var iterator = collection.__iterator(type, reverse); | |
| var stack = []; | |
| var iterations = 0; | |
| return new Iterator(function () { | |
| while (iterator) { | |
| var step = iterator.next(); | |
| if (step.done !== false) { | |
| iterator = stack.pop(); | |
| continue; | |
| } | |
| var v = step.value; | |
| if (type === ITERATE_ENTRIES) { | |
| v = v[1]; | |
| } | |
| if ((!depth || stack.length < depth) && isCollection(v)) { | |
| stack.push(iterator); | |
| iterator = v.__iterator(type, reverse); | |
| } else { | |
| return useKeys ? step : iteratorValue(type, iterations++, v, step); | |
| } | |
| } | |
| return iteratorDone(); | |
| }); | |
| }; | |
| return flatSequence; | |
| } | |
| function flatMapFactory(collection, mapper, context) { | |
| var coerce = collectionClass(collection); | |
| return collection | |
| .toSeq() | |
| .map(function (v, k) { return coerce(mapper.call(context, v, k, collection)); }) | |
| .flatten(true); | |
| } | |
| function interposeFactory(collection, separator) { | |
| var interposedSequence = makeSequence(collection); | |
| interposedSequence.size = collection.size && collection.size * 2 - 1; | |
| interposedSequence.__iterateUncached = function (fn, reverse) { | |
| var this$1$1 = this; | |
| var iterations = 0; | |
| collection.__iterate( | |
| function (v) { return (!iterations || fn(separator, iterations++, this$1$1) !== false) && | |
| fn(v, iterations++, this$1$1) !== false; }, | |
| reverse | |
| ); | |
| return iterations; | |
| }; | |
| interposedSequence.__iteratorUncached = function (type, reverse) { | |
| var iterator = collection.__iterator(ITERATE_VALUES, reverse); | |
| var iterations = 0; | |
| var step; | |
| return new Iterator(function () { | |
| if (!step || iterations % 2) { | |
| step = iterator.next(); | |
| if (step.done) { | |
| return step; | |
| } | |
| } | |
| return iterations % 2 | |
| ? iteratorValue(type, iterations++, separator) | |
| : iteratorValue(type, iterations++, step.value, step); | |
| }); | |
| }; | |
| return interposedSequence; | |
| } | |
| function sortFactory(collection, comparator, mapper) { | |
| if (!comparator) { | |
| comparator = defaultComparator; | |
| } | |
| var isKeyedCollection = isKeyed(collection); | |
| var index = 0; | |
| var entries = collection | |
| .toSeq() | |
| .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; }) | |
| .valueSeq() | |
| .toArray(); | |
| entries | |
| .sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; }) | |
| .forEach( | |
| isKeyedCollection | |
| ? function (v, i) { | |
| entries[i].length = 2; | |
| } | |
| : function (v, i) { | |
| entries[i] = v[1]; | |
| } | |
| ); | |
| return isKeyedCollection | |
| ? KeyedSeq(entries) | |
| : isIndexed(collection) | |
| ? IndexedSeq(entries) | |
| : SetSeq(entries); | |
| } | |
| function maxFactory(collection, comparator, mapper) { | |
| if (!comparator) { | |
| comparator = defaultComparator; | |
| } | |
| if (mapper) { | |
| var entry = collection | |
| .toSeq() | |
| .map(function (v, k) { return [v, mapper(v, k, collection)]; }) | |
| .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); }); | |
| return entry && entry[0]; | |
| } | |
| return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); }); | |
| } | |
| function maxCompare(comparator, a, b) { | |
| var comp = comparator(b, a); | |
| // b is considered the new max if the comparator declares them equal, but | |
| // they are not equal and b is in fact a nullish value. | |
| return ( | |
| (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || | |
| comp > 0 | |
| ); | |
| } | |
| function zipWithFactory(keyIter, zipper, iters, zipAll) { | |
| var zipSequence = makeSequence(keyIter); | |
| var sizes = new ArraySeq(iters).map(function (i) { return i.size; }); | |
| zipSequence.size = zipAll ? sizes.max() : sizes.min(); | |
| // Note: this a generic base implementation of __iterate in terms of | |
| // __iterator which may be more generically useful in the future. | |
| zipSequence.__iterate = function (fn, reverse) { | |
| /* generic: | |
| var iterator = this.__iterator(ITERATE_ENTRIES, reverse); | |
| var step; | |
| var iterations = 0; | |
| while (!(step = iterator.next()).done) { | |
| iterations++; | |
| if (fn(step.value[1], step.value[0], this) === false) { | |
| break; | |
| } | |
| } | |
| return iterations; | |
| */ | |
| // indexed: | |
| var iterator = this.__iterator(ITERATE_VALUES, reverse); | |
| var step; | |
| var iterations = 0; | |
| while (!(step = iterator.next()).done) { | |
| if (fn(step.value, iterations++, this) === false) { | |
| break; | |
| } | |
| } | |
| return iterations; | |
| }; | |
| zipSequence.__iteratorUncached = function (type, reverse) { | |
| var iterators = iters.map( | |
| function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); } | |
| ); | |
| var iterations = 0; | |
| var isDone = false; | |
| return new Iterator(function () { | |
| var steps; | |
| if (!isDone) { | |
| steps = iterators.map(function (i) { return i.next(); }); | |
| isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; }); | |
| } | |
| if (isDone) { | |
| return iteratorDone(); | |
| } | |
| return iteratorValue( | |
| type, | |
| iterations++, | |
| zipper.apply( | |
| null, | |
| steps.map(function (s) { return s.value; }) | |
| ) | |
| ); | |
| }); | |
| }; | |
| return zipSequence; | |
| } | |
| // #pragma Helper Functions | |
| function reify(iter, seq) { | |
| return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq); | |
| } | |
| function validateEntry(entry) { | |
| if (entry !== Object(entry)) { | |
| throw new TypeError('Expected [K, V] tuple: ' + entry); | |
| } | |
| } | |
| function collectionClass(collection) { | |
| return isKeyed(collection) | |
| ? KeyedCollection | |
| : isIndexed(collection) | |
| ? IndexedCollection | |
| : SetCollection; | |
| } | |
| function makeSequence(collection) { | |
| return Object.create( | |
| (isKeyed(collection) | |
| ? KeyedSeq | |
| : isIndexed(collection) | |
| ? IndexedSeq | |
| : SetSeq | |
| ).prototype | |
| ); | |
| } | |
| function cacheResultThrough() { | |
| if (this._iter.cacheResult) { | |
| this._iter.cacheResult(); | |
| this.size = this._iter.size; | |
| return this; | |
| } | |
| return Seq.prototype.cacheResult.call(this); | |
| } | |
| function defaultComparator(a, b) { | |
| if (a === undefined && b === undefined) { | |
| return 0; | |
| } | |
| if (a === undefined) { | |
| return 1; | |
| } | |
| if (b === undefined) { | |
| return -1; | |
| } | |
| return a > b ? 1 : a < b ? -1 : 0; | |
| } | |
| function arrCopy(arr, offset) { | |
| offset = offset || 0; | |
| var len = Math.max(0, arr.length - offset); | |
| var newArr = new Array(len); | |
| for (var ii = 0; ii < len; ii++) { | |
| newArr[ii] = arr[ii + offset]; | |
| } | |
| return newArr; | |
| } | |
| function invariant(condition, error) { | |
| if (!condition) { throw new Error(error); } | |
| } | |
| function assertNotInfinite(size) { | |
| invariant( | |
| size !== Infinity, | |
| 'Cannot perform this action with an infinite size.' | |
| ); | |
| } | |
| function coerceKeyPath(keyPath) { | |
| if (isArrayLike(keyPath) && typeof keyPath !== 'string') { | |
| return keyPath; | |
| } | |
| if (isOrdered(keyPath)) { | |
| return keyPath.toArray(); | |
| } | |
| throw new TypeError( | |
| 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath | |
| ); | |
| } | |
| var toString = Object.prototype.toString; | |
| function isPlainObject(value) { | |
| // The base prototype's toString deals with Argument objects and native namespaces like Math | |
| if ( | |
| !value || | |
| typeof value !== 'object' || | |
| toString.call(value) !== '[object Object]' | |
| ) { | |
| return false; | |
| } | |
| var proto = Object.getPrototypeOf(value); | |
| if (proto === null) { | |
| return true; | |
| } | |
| // Iteratively going up the prototype chain is needed for cross-realm environments (differing contexts, iframes, etc) | |
| var parentProto = proto; | |
| var nextProto = Object.getPrototypeOf(proto); | |
| while (nextProto !== null) { | |
| parentProto = nextProto; | |
| nextProto = Object.getPrototypeOf(parentProto); | |
| } | |
| return parentProto === proto; | |
| } | |
| /** | |
| * Returns true if the value is a potentially-persistent data structure, either | |
| * provided by Immutable.js or a plain Array or Object. | |
| */ | |
| function isDataStructure(value) { | |
| return ( | |
| typeof value === 'object' && | |
| (isImmutable(value) || Array.isArray(value) || isPlainObject(value)) | |
| ); | |
| } | |
| function quoteString(value) { | |
| try { | |
| return typeof value === 'string' ? JSON.stringify(value) : String(value); | |
| } catch (_ignoreError) { | |
| return JSON.stringify(value); | |
| } | |
| } | |
| function has(collection, key) { | |
| return isImmutable(collection) | |
| ? collection.has(key) | |
| : isDataStructure(collection) && hasOwnProperty.call(collection, key); | |
| } | |
| function get(collection, key, notSetValue) { | |
| return isImmutable(collection) | |
| ? collection.get(key, notSetValue) | |
| : !has(collection, key) | |
| ? notSetValue | |
| : typeof collection.get === 'function' | |
| ? collection.get(key) | |
| : collection[key]; | |
| } | |
| function shallowCopy(from) { | |
| if (Array.isArray(from)) { | |
| return arrCopy(from); | |
| } | |
| var to = {}; | |
| for (var key in from) { | |
| if (hasOwnProperty.call(from, key)) { | |
| to[key] = from[key]; | |
| } | |
| } | |
| return to; | |
| } | |
| function remove(collection, key) { | |
| if (!isDataStructure(collection)) { | |
| throw new TypeError( | |
| 'Cannot update non-data-structure value: ' + collection | |
| ); | |
| } | |
| if (isImmutable(collection)) { | |
| if (!collection.remove) { | |
| throw new TypeError( | |
| 'Cannot update immutable value without .remove() method: ' + collection | |
| ); | |
| } | |
| return collection.remove(key); | |
| } | |
| if (!hasOwnProperty.call(collection, key)) { | |
| return collection; | |
| } | |
| var collectionCopy = shallowCopy(collection); | |
| if (Array.isArray(collectionCopy)) { | |
| collectionCopy.splice(key, 1); | |
| } else { | |
| delete collectionCopy[key]; | |
| } | |
| return collectionCopy; | |
| } | |
| function set(collection, key, value) { | |
| if (!isDataStructure(collection)) { | |
| throw new TypeError( | |
| 'Cannot update non-data-structure value: ' + collection | |
| ); | |
| } | |
| if (isImmutable(collection)) { | |
| if (!collection.set) { | |
| throw new TypeError( | |
| 'Cannot update immutable value without .set() method: ' + collection | |
| ); | |
| } | |
| return collection.set(key, value); | |
| } | |
| if (hasOwnProperty.call(collection, key) && value === collection[key]) { | |
| return collection; | |
| } | |
| var collectionCopy = shallowCopy(collection); | |
| collectionCopy[key] = value; | |
| return collectionCopy; | |
| } | |
| function updateIn$1(collection, keyPath, notSetValue, updater) { | |
| if (!updater) { | |
| updater = notSetValue; | |
| notSetValue = undefined; | |
| } | |
| var updatedValue = updateInDeeply( | |
| isImmutable(collection), | |
| collection, | |
| coerceKeyPath(keyPath), | |
| 0, | |
| notSetValue, | |
| updater | |
| ); | |
| return updatedValue === NOT_SET ? notSetValue : updatedValue; | |
| } | |
| function updateInDeeply( | |
| inImmutable, | |
| existing, | |
| keyPath, | |
| i, | |
| notSetValue, | |
| updater | |
| ) { | |
| var wasNotSet = existing === NOT_SET; | |
| if (i === keyPath.length) { | |
| var existingValue = wasNotSet ? notSetValue : existing; | |
| var newValue = updater(existingValue); | |
| return newValue === existingValue ? existing : newValue; | |
| } | |
| if (!wasNotSet && !isDataStructure(existing)) { | |
| throw new TypeError( | |
| 'Cannot update within non-data-structure value in path [' + | |
| keyPath.slice(0, i).map(quoteString) + | |
| ']: ' + | |
| existing | |
| ); | |
| } | |
| var key = keyPath[i]; | |
| var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); | |
| var nextUpdated = updateInDeeply( | |
| nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), | |
| nextExisting, | |
| keyPath, | |
| i + 1, | |
| notSetValue, | |
| updater | |
| ); | |
| return nextUpdated === nextExisting | |
| ? existing | |
| : nextUpdated === NOT_SET | |
| ? remove(existing, key) | |
| : set( | |
| wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, | |
| key, | |
| nextUpdated | |
| ); | |
| } | |
| function setIn$1(collection, keyPath, value) { | |
| return updateIn$1(collection, keyPath, NOT_SET, function () { return value; }); | |
| } | |
| function setIn(keyPath, v) { | |
| return setIn$1(this, keyPath, v); | |
| } | |
| function removeIn(collection, keyPath) { | |
| return updateIn$1(collection, keyPath, function () { return NOT_SET; }); | |
| } | |
| function deleteIn(keyPath) { | |
| return removeIn(this, keyPath); | |
| } | |
| function update$1(collection, key, notSetValue, updater) { | |
| return updateIn$1(collection, [key], notSetValue, updater); | |
| } | |
| function update(key, notSetValue, updater) { | |
| return arguments.length === 1 | |
| ? key(this) | |
| : update$1(this, key, notSetValue, updater); | |
| } | |
| function updateIn(keyPath, notSetValue, updater) { | |
| return updateIn$1(this, keyPath, notSetValue, updater); | |
| } | |
| function merge$1() { | |
| var iters = [], len = arguments.length; | |
| while ( len-- ) iters[ len ] = arguments[ len ]; | |
| return mergeIntoKeyedWith(this, iters); | |
| } | |
| function mergeWith$1(merger) { | |
| var iters = [], len = arguments.length - 1; | |
| while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; | |
| if (typeof merger !== 'function') { | |
| throw new TypeError('Invalid merger function: ' + merger); | |
| } | |
| return mergeIntoKeyedWith(this, iters, merger); | |
| } | |
| function mergeIntoKeyedWith(collection, collections, merger) { | |
| var iters = []; | |
| for (var ii = 0; ii < collections.length; ii++) { | |
| var collection$1 = KeyedCollection(collections[ii]); | |
| if (collection$1.size !== 0) { | |
| iters.push(collection$1); | |
| } | |
| } | |
| if (iters.length === 0) { | |
| return collection; | |
| } | |
| if ( | |
| collection.toSeq().size === 0 && | |
| !collection.__ownerID && | |
| iters.length === 1 | |
| ) { | |
| return collection.constructor(iters[0]); | |
| } | |
| return collection.withMutations(function (collection) { | |
| var mergeIntoCollection = merger | |
| ? function (value, key) { | |
| update$1(collection, key, NOT_SET, function (oldVal) { return oldVal === NOT_SET ? value : merger(oldVal, value, key); } | |
| ); | |
| } | |
| : function (value, key) { | |
| collection.set(key, value); | |
| }; | |
| for (var ii = 0; ii < iters.length; ii++) { | |
| iters[ii].forEach(mergeIntoCollection); | |
| } | |
| }); | |
| } | |
| function merge(collection) { | |
| var sources = [], len = arguments.length - 1; | |
| while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; | |
| return mergeWithSources(collection, sources); | |
| } | |
| function mergeWith(merger, collection) { | |
| var sources = [], len = arguments.length - 2; | |
| while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; | |
| return mergeWithSources(collection, sources, merger); | |
| } | |
| function mergeDeep$1(collection) { | |
| var sources = [], len = arguments.length - 1; | |
| while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; | |
| return mergeDeepWithSources(collection, sources); | |
| } | |
| function mergeDeepWith$1(merger, collection) { | |
| var sources = [], len = arguments.length - 2; | |
| while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; | |
| return mergeDeepWithSources(collection, sources, merger); | |
| } | |
| function mergeDeepWithSources(collection, sources, merger) { | |
| return mergeWithSources(collection, sources, deepMergerWith(merger)); | |
| } | |
| function mergeWithSources(collection, sources, merger) { | |
| if (!isDataStructure(collection)) { | |
| throw new TypeError( | |
| 'Cannot merge into non-data-structure value: ' + collection | |
| ); | |
| } | |
| if (isImmutable(collection)) { | |
| return typeof merger === 'function' && collection.mergeWith | |
| ? collection.mergeWith.apply(collection, [ merger ].concat( sources )) | |
| : collection.merge | |
| ? collection.merge.apply(collection, sources) | |
| : collection.concat.apply(collection, sources); | |
| } | |
| var isArray = Array.isArray(collection); | |
| var merged = collection; | |
| var Collection = isArray ? IndexedCollection : KeyedCollection; | |
| var mergeItem = isArray | |
| ? function (value) { | |
| // Copy on write | |
| if (merged === collection) { | |
| merged = shallowCopy(merged); | |
| } | |
| merged.push(value); | |
| } | |
| : function (value, key) { | |
| var hasVal = hasOwnProperty.call(merged, key); | |
| var nextVal = | |
| hasVal && merger ? merger(merged[key], value, key) : value; | |
| if (!hasVal || nextVal !== merged[key]) { | |
| // Copy on write | |
| if (merged === collection) { | |
| merged = shallowCopy(merged); | |
| } | |
| merged[key] = nextVal; | |
| } | |
| }; | |
| for (var i = 0; i < sources.length; i++) { | |
| Collection(sources[i]).forEach(mergeItem); | |
| } | |
| return merged; | |
| } | |
| function deepMergerWith(merger) { | |
| function deepMerger(oldValue, newValue, key) { | |
| return isDataStructure(oldValue) && | |
| isDataStructure(newValue) && | |
| areMergeable(oldValue, newValue) | |
| ? mergeWithSources(oldValue, [newValue], deepMerger) | |
| : merger | |
| ? merger(oldValue, newValue, key) | |
| : newValue; | |
| } | |
| return deepMerger; | |
| } | |
| /** | |
| * It's unclear what the desired behavior is for merging two collections that | |
| * fall into separate categories between keyed, indexed, or set-like, so we only | |
| * consider them mergeable if they fall into the same category. | |
| */ | |
| function areMergeable(oldDataStructure, newDataStructure) { | |
| var oldSeq = Seq(oldDataStructure); | |
| var newSeq = Seq(newDataStructure); | |
| // This logic assumes that a sequence can only fall into one of the three | |
| // categories mentioned above (since there's no `isSetLike()` method). | |
| return ( | |
| isIndexed(oldSeq) === isIndexed(newSeq) && | |
| isKeyed(oldSeq) === isKeyed(newSeq) | |
| ); | |
| } | |
| function mergeDeep() { | |
| var iters = [], len = arguments.length; | |
| while ( len-- ) iters[ len ] = arguments[ len ]; | |
| return mergeDeepWithSources(this, iters); | |
| } | |
| function mergeDeepWith(merger) { | |
| var iters = [], len = arguments.length - 1; | |
| while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; | |
| return mergeDeepWithSources(this, iters, merger); | |
| } | |
| function mergeIn(keyPath) { | |
| var iters = [], len = arguments.length - 1; | |
| while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; | |
| return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); }); | |
| } | |
| function mergeDeepIn(keyPath) { | |
| var iters = [], len = arguments.length - 1; | |
| while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; | |
| return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); } | |
| ); | |
| } | |
| function withMutations(fn) { | |
| var mutable = this.asMutable(); | |
| fn(mutable); | |
| return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; | |
| } | |
| function asMutable() { | |
| return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); | |
| } | |
| function asImmutable() { | |
| return this.__ensureOwner(); | |
| } | |
| function wasAltered() { | |
| return this.__altered; | |
| } | |
| var Map = /*@__PURE__*/(function (KeyedCollection) { | |
| function Map(value) { | |
| return value === undefined || value === null | |
| ? emptyMap() | |
| : isMap(value) && !isOrdered(value) | |
| ? value | |
| : emptyMap().withMutations(function (map) { | |
| var iter = KeyedCollection(value); | |
| assertNotInfinite(iter.size); | |
| iter.forEach(function (v, k) { return map.set(k, v); }); | |
| }); | |
| } | |
| if ( KeyedCollection ) Map.__proto__ = KeyedCollection; | |
| Map.prototype = Object.create( KeyedCollection && KeyedCollection.prototype ); | |
| Map.prototype.constructor = Map; | |
| Map.of = function of () { | |
| var keyValues = [], len = arguments.length; | |
| while ( len-- ) keyValues[ len ] = arguments[ len ]; | |
| return emptyMap().withMutations(function (map) { | |
| for (var i = 0; i < keyValues.length; i += 2) { | |
| if (i + 1 >= keyValues.length) { | |
| throw new Error('Missing value for key: ' + keyValues[i]); | |
| } | |
| map.set(keyValues[i], keyValues[i + 1]); | |
| } | |
| }); | |
| }; | |
| Map.prototype.toString = function toString () { | |
| return this.__toString('Map {', '}'); | |
| }; | |
| // @pragma Access | |
| Map.prototype.get = function get (k, notSetValue) { | |
| return this._root | |
| ? this._root.get(0, undefined, k, notSetValue) | |
| : notSetValue; | |
| }; | |
| // @pragma Modification | |
| Map.prototype.set = function set (k, v) { | |
| return updateMap(this, k, v); | |
| }; | |
| Map.prototype.remove = function remove (k) { | |
| return updateMap(this, k, NOT_SET); | |
| }; | |
| Map.prototype.deleteAll = function deleteAll (keys) { | |
| var collection = Collection(keys); | |
| if (collection.size === 0) { | |
| return this; | |
| } | |
| return this.withMutations(function (map) { | |
| collection.forEach(function (key) { return map.remove(key); }); | |
| }); | |
| }; | |
| Map.prototype.clear = function clear () { | |
| if (this.size === 0) { | |
| return this; | |
| } | |
| if (this.__ownerID) { | |
| this.size = 0; | |
| this._root = null; | |
| this.__hash = undefined; | |
| this.__altered = true; | |
| return this; | |
| } | |
| return emptyMap(); | |
| }; | |
| // @pragma Composition | |
| Map.prototype.sort = function sort (comparator) { | |
| // Late binding | |
| return OrderedMap(sortFactory(this, comparator)); | |
| }; | |
| Map.prototype.sortBy = function sortBy (mapper, comparator) { | |
| // Late binding | |
| return OrderedMap(sortFactory(this, comparator, mapper)); | |
| }; | |
| Map.prototype.map = function map (mapper, context) { | |
| var this$1$1 = this; | |
| return this.withMutations(function (map) { | |
| map.forEach(function (value, key) { | |
| map.set(key, mapper.call(context, value, key, this$1$1)); | |
| }); | |
| }); | |
| }; | |
| // @pragma Mutability | |
| Map.prototype.__iterator = function __iterator (type, reverse) { | |
| return new MapIterator(this, type, reverse); | |
| }; | |
| Map.prototype.__iterate = function __iterate (fn, reverse) { | |
| var this$1$1 = this; | |
| var iterations = 0; | |
| this._root && | |
| this._root.iterate(function (entry) { | |
| iterations++; | |
| return fn(entry[1], entry[0], this$1$1); | |
| }, reverse); | |
| return iterations; | |
| }; | |
| Map.prototype.__ensureOwner = function __ensureOwner (ownerID) { | |
| if (ownerID === this.__ownerID) { | |
| return this; | |
| } | |
| if (!ownerID) { | |
| if (this.size === 0) { | |
| return emptyMap(); | |
| } | |
| this.__ownerID = ownerID; | |
| this.__altered = false; | |
| return this; | |
| } | |
| return makeMap(this.size, this._root, ownerID, this.__hash); | |
| }; | |
| return Map; | |
| }(KeyedCollection)); | |
| Map.isMap = isMap; | |
| var MapPrototype = Map.prototype; | |
| MapPrototype[IS_MAP_SYMBOL] = true; | |
| MapPrototype[DELETE] = MapPrototype.remove; | |
| MapPrototype.removeAll = MapPrototype.deleteAll; | |
| MapPrototype.setIn = setIn; | |
| MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn; | |
| MapPrototype.update = update; | |
| MapPrototype.updateIn = updateIn; | |
| MapPrototype.merge = MapPrototype.concat = merge$1; | |
| MapPrototype.mergeWith = mergeWith$1; | |
| MapPrototype.mergeDeep = mergeDeep; | |
| MapPrototype.mergeDeepWith = mergeDeepWith; | |
| MapPrototype.mergeIn = mergeIn; | |
| MapPrototype.mergeDeepIn = mergeDeepIn; | |
| MapPrototype.withMutations = withMutations; | |
| MapPrototype.wasAltered = wasAltered; | |
| MapPrototype.asImmutable = asImmutable; | |
| MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable; | |
| MapPrototype['@@transducer/step'] = function (result, arr) { | |
| return result.set(arr[0], arr[1]); | |
| }; | |
| MapPrototype['@@transducer/result'] = function (obj) { | |
| return obj.asImmutable(); | |
| }; | |
| // #pragma Trie Nodes | |
| var ArrayMapNode = function ArrayMapNode(ownerID, entries) { | |
| this.ownerID = ownerID; | |
| this.entries = entries; | |
| }; | |
| ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { | |
| var entries = this.entries; | |
| for (var ii = 0, len = entries.length; ii < len; ii++) { | |
| if (is(key, entries[ii][0])) { | |
| return entries[ii][1]; | |
| } | |
| } | |
| return notSetValue; | |
| }; | |
| ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { | |
| var removed = value === NOT_SET; | |
| var entries = this.entries; | |
| var idx = 0; | |
| var len = entries.length; | |
| for (; idx < len; idx++) { | |
| if (is(key, entries[idx][0])) { | |
| break; | |
| } | |
| } | |
| var exists = idx < len; | |
| if (exists ? entries[idx][1] === value : removed) { | |
| return this; | |
| } | |
| SetRef(didAlter); | |
| (removed || !exists) && SetRef(didChangeSize); | |
| if (removed && entries.length === 1) { | |
| return; // undefined | |
| } | |
| if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) { | |
| return createNodes(ownerID, entries, key, value); | |
| } | |
| var isEditable = ownerID && ownerID === this.ownerID; | |
| var newEntries = isEditable ? entries : arrCopy(entries); | |
| if (exists) { | |
| if (removed) { | |
| idx === len - 1 | |
| ? newEntries.pop() | |
| : (newEntries[idx] = newEntries.pop()); | |
| } else { | |
| newEntries[idx] = [key, value]; | |
| } | |
| } else { | |
| newEntries.push([key, value]); | |
| } | |
| if (isEditable) { | |
| this.entries = newEntries; | |
| return this; | |
| } | |
| return new ArrayMapNode(ownerID, newEntries); | |
| }; | |
| var BitmapIndexedNode = function BitmapIndexedNode(ownerID, bitmap, nodes) { | |
| this.ownerID = ownerID; | |
| this.bitmap = bitmap; | |
| this.nodes = nodes; | |
| }; | |
| BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue) { | |
| if (keyHash === undefined) { | |
| keyHash = hash(key); | |
| } | |
| var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK); | |
| var bitmap = this.bitmap; | |
| return (bitmap & bit) === 0 | |
| ? notSetValue | |
| : this.nodes[popCount(bitmap & (bit - 1))].get( | |
| shift + SHIFT, | |
| keyHash, | |
| key, | |
| notSetValue | |
| ); | |
| }; | |
| BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { | |
| if (keyHash === undefined) { | |
| keyHash = hash(key); | |
| } | |
| var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; | |
| var bit = 1 << keyHashFrag; | |
| var bitmap = this.bitmap; | |
| var exists = (bitmap & bit) !== 0; | |
| if (!exists && value === NOT_SET) { | |
| return this; | |
| } | |
| var idx = popCount(bitmap & (bit - 1)); | |
| var nodes = this.nodes; | |
| var node = exists ? nodes[idx] : undefined; | |
| var newNode = updateNode( | |
| node, | |
| ownerID, | |
| shift + SHIFT, | |
| keyHash, | |
| key, | |
| value, | |
| didChangeSize, | |
| didAlter | |
| ); | |
| if (newNode === node) { | |
| return this; | |
| } | |
| if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) { | |
| return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode); | |
| } | |
| if ( | |
| exists && | |
| !newNode && | |
| nodes.length === 2 && | |
| isLeafNode(nodes[idx ^ 1]) | |
| ) { | |
| return nodes[idx ^ 1]; | |
| } | |
| if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) { | |
| return newNode; | |
| } | |
| var isEditable = ownerID && ownerID === this.ownerID; | |
| var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit; | |
| var newNodes = exists | |
| ? newNode | |
| ? setAt(nodes, idx, newNode, isEditable) | |
| : spliceOut(nodes, idx, isEditable) | |
| : spliceIn(nodes, idx, newNode, isEditable); | |
| if (isEditable) { | |
| this.bitmap = newBitmap; | |
| this.nodes = newNodes; | |
| return this; | |
| } | |
| return new BitmapIndexedNode(ownerID, newBitmap, newNodes); | |
| }; | |
| var HashArrayMapNode = function HashArrayMapNode(ownerID, count, nodes) { | |
| this.ownerID = ownerID; | |
| this.count = count; | |
| this.nodes = nodes; | |
| }; | |
| HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { | |
| if (keyHash === undefined) { | |
| keyHash = hash(key); | |
| } | |
| var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; | |
| var node = this.nodes[idx]; | |
| return node | |
| ? node.get(shift + SHIFT, keyHash, key, notSetValue) | |
| : notSetValue; | |
| }; | |
| HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { | |
| if (keyHash === undefined) { | |
| keyHash = hash(key); | |
| } | |
| var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; | |
| var removed = value === NOT_SET; | |
| var nodes = this.nodes; | |
| var node = nodes[idx]; | |
| if (removed && !node) { | |
| return this; | |
| } | |
| var newNode = updateNode( | |
| node, | |
| ownerID, | |
| shift + SHIFT, | |
| keyHash, | |
| key, | |
| value, | |
| didChangeSize, | |
| didAlter | |
| ); | |
| if (newNode === node) { | |
| return this; | |
| } | |
| var newCount = this.count; | |
| if (!node) { | |
| newCount++; | |
| } else if (!newNode) { | |
| newCount--; | |
| if (newCount < MIN_HASH_ARRAY_MAP_SIZE) { | |
| return packNodes(ownerID, nodes, newCount, idx); | |
| } | |
| } | |
| var isEditable = ownerID && ownerID === this.ownerID; | |
| var newNodes = setAt(nodes, idx, newNode, isEditable); | |
| if (isEditable) { | |
| this.count = newCount; | |
| this.nodes = newNodes; | |
| return this; | |
| } | |
| return new HashArrayMapNode(ownerID, newCount, newNodes); | |
| }; | |
| var HashCollisionNode = function HashCollisionNode(ownerID, keyHash, entries) { | |
| this.ownerID = ownerID; | |
| this.keyHash = keyHash; | |
| this.entries = entries; | |
| }; | |
| HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue) { | |
| var entries = this.entries; | |
| for (var ii = 0, len = entries.length; ii < len; ii++) { | |
| if (is(key, entries[ii][0])) { | |
| return entries[ii][1]; | |
| } | |
| } | |
| return notSetValue; | |
| }; | |
| HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { | |
| if (keyHash === undefined) { | |
| keyHash = hash(key); | |
| } | |
| var removed = value === NOT_SET; | |
| if (keyHash !== this.keyHash) { | |
| if (removed) { | |
| return this; | |
| } | |
| SetRef(didAlter); | |
| SetRef(didChangeSize); | |
| return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]); | |
| } | |
| var entries = this.entries; | |
| var idx = 0; | |
| var len = entries.length; | |
| for (; idx < len; idx++) { | |
| if (is(key, entries[idx][0])) { | |
| break; | |
| } | |
| } | |
| var exists = idx < len; | |
| if (exists ? entries[idx][1] === value : removed) { | |
| return this; | |
| } | |
| SetRef(didAlter); | |
| (removed || !exists) && SetRef(didChangeSize); | |
| if (removed && len === 2) { | |
| return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]); | |
| } | |
| var isEditable = ownerID && ownerID === this.ownerID; | |
| var newEntries = isEditable ? entries : arrCopy(entries); | |
| if (exists) { | |
| if (removed) { | |
| idx === len - 1 | |
| ? newEntries.pop() | |
| : (newEntries[idx] = newEntries.pop()); | |
| } else { | |
| newEntries[idx] = [key, value]; | |
| } | |
| } else { | |
| newEntries.push([key, value]); | |
| } | |
| if (isEditable) { | |
| this.entries = newEntries; | |
| return this; | |
| } | |
| return new HashCollisionNode(ownerID, this.keyHash, newEntries); | |
| }; | |
| var ValueNode = function ValueNode(ownerID, keyHash, entry) { | |
| this.ownerID = ownerID; | |
| this.keyHash = keyHash; | |
| this.entry = entry; | |
| }; | |
| ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) { | |
| return is(key, this.entry[0]) ? this.entry[1] : notSetValue; | |
| }; | |
| ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { | |
| var removed = value === NOT_SET; | |
| var keyMatch = is(key, this.entry[0]); | |
| if (keyMatch ? value === this.entry[1] : removed) { | |
| return this; | |
| } | |
| SetRef(didAlter); | |
| if (removed) { | |
| SetRef(didChangeSize); | |
| return; // undefined | |
| } | |
| if (keyMatch) { | |
| if (ownerID && ownerID === this.ownerID) { | |
| this.entry[1] = value; | |
| return this; | |
| } | |
| return new ValueNode(ownerID, this.keyHash, [key, value]); | |
| } | |
| SetRef(didChangeSize); | |
| return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]); | |
| }; | |
| // #pragma Iterators | |
| ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = | |
| function (fn, reverse) { | |
| var entries = this.entries; | |
| for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) { | |
| if (fn(entries[reverse ? maxIndex - ii : ii]) === false) { | |
| return false; | |
| } | |
| } | |
| }; | |
| BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = | |
| function (fn, reverse) { | |
| var nodes = this.nodes; | |
| for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) { | |
| var node = nodes[reverse ? maxIndex - ii : ii]; | |
| if (node && node.iterate(fn, reverse) === false) { | |
| return false; | |
| } | |
| } | |
| }; | |
| // eslint-disable-next-line no-unused-vars | |
| ValueNode.prototype.iterate = function (fn, reverse) { | |
| return fn(this.entry); | |
| }; | |
| var MapIterator = /*@__PURE__*/(function (Iterator) { | |
| function MapIterator(map, type, reverse) { | |
| this._type = type; | |
| this._reverse = reverse; | |
| this._stack = map._root && mapIteratorFrame(map._root); | |
| } | |
| if ( Iterator ) MapIterator.__proto__ = Iterator; | |
| MapIterator.prototype = Object.create( Iterator && Iterator.prototype ); | |
| MapIterator.prototype.constructor = MapIterator; | |
| MapIterator.prototype.next = function next () { | |
| var type = this._type; | |
| var stack = this._stack; | |
| while (stack) { | |
| var node = stack.node; | |
| var index = stack.index++; | |
| var maxIndex = (void 0); | |
| if (node.entry) { | |
| if (index === 0) { | |
| return mapIteratorValue(type, node.entry); | |
| } | |
| } else if (node.entries) { | |
| maxIndex = node.entries.length - 1; | |
| if (index <= maxIndex) { | |
| return mapIteratorValue( | |
| type, | |
| node.entries[this._reverse ? maxIndex - index : index] | |
| ); | |
| } | |
| } else { | |
| maxIndex = node.nodes.length - 1; | |
| if (index <= maxIndex) { | |
| var subNode = node.nodes[this._reverse ? maxIndex - index : index]; | |
| if (subNode) { | |
| if (subNode.entry) { | |
| return mapIteratorValue(type, subNode.entry); | |
| } | |
| stack = this._stack = mapIteratorFrame(subNode, stack); | |
| } | |
| continue; | |
| } | |
| } | |
| stack = this._stack = this._stack.__prev; | |
| } | |
| return iteratorDone(); | |
| }; | |
| return MapIterator; | |
| }(Iterator)); | |
| function mapIteratorValue(type, entry) { | |
| return iteratorValue(type, entry[0], entry[1]); | |
| } | |
| function mapIteratorFrame(node, prev) { | |
| return { | |
| node: node, | |
| index: 0, | |
| __prev: prev, | |
| }; | |
| } | |
| function makeMap(size, root, ownerID, hash) { | |
| var map = Object.create(MapPrototype); | |
| map.size = size; | |
| map._root = root; | |
| map.__ownerID = ownerID; | |
| map.__hash = hash; | |
| map.__altered = false; | |
| return map; | |
| } | |
| var EMPTY_MAP; | |
| function emptyMap() { | |
| return EMPTY_MAP || (EMPTY_MAP = makeMap(0)); | |
| } | |
| function updateMap(map, k, v) { | |
| var newRoot; | |
| var newSize; | |
| if (!map._root) { | |
| if (v === NOT_SET) { | |
| return map; | |
| } | |
| newSize = 1; | |
| newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]); | |
| } else { | |
| var didChangeSize = MakeRef(); | |
| var didAlter = MakeRef(); | |
| newRoot = updateNode( | |
| map._root, | |
| map.__ownerID, | |
| 0, | |
| undefined, | |
| k, | |
| v, | |
| didChangeSize, | |
| didAlter | |
| ); | |
| if (!didAlter.value) { | |
| return map; | |
| } | |
| newSize = map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0); | |
| } | |
| if (map.__ownerID) { | |
| map.size = newSize; | |
| map._root = newRoot; | |
| map.__hash = undefined; | |
| map.__altered = true; | |
| return map; | |
| } | |
| return newRoot ? makeMap(newSize, newRoot) : emptyMap(); | |
| } | |
| function updateNode( | |
| node, | |
| ownerID, | |
| shift, | |
| keyHash, | |
| key, | |
| value, | |
| didChangeSize, | |
| didAlter | |
| ) { | |
| if (!node) { | |
| if (value === NOT_SET) { | |
| return node; | |
| } | |
| SetRef(didAlter); | |
| SetRef(didChangeSize); | |
| return new ValueNode(ownerID, keyHash, [key, value]); | |
| } | |
| return node.update( | |
| ownerID, | |
| shift, | |
| keyHash, | |
| key, | |
| value, | |
| didChangeSize, | |
| didAlter | |
| ); | |
| } | |
| function isLeafNode(node) { | |
| return ( | |
| node.constructor === ValueNode || node.constructor === HashCollisionNode | |
| ); | |
| } | |
| function mergeIntoNode(node, ownerID, shift, keyHash, entry) { | |
| if (node.keyHash === keyHash) { | |
| return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]); | |
| } | |
| var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK; | |
| var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; | |
| var newNode; | |
| var nodes = | |
| idx1 === idx2 | |
| ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] | |
| : ((newNode = new ValueNode(ownerID, keyHash, entry)), | |
| idx1 < idx2 ? [node, newNode] : [newNode, node]); | |
| return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes); | |
| } | |
| function createNodes(ownerID, entries, key, value) { | |
| if (!ownerID) { | |
| ownerID = new OwnerID(); | |
| } | |
| var node = new ValueNode(ownerID, hash(key), [key, value]); | |
| for (var ii = 0; ii < entries.length; ii++) { | |
| var entry = entries[ii]; | |
| node = node.update(ownerID, 0, undefined, entry[0], entry[1]); | |
| } | |
| return node; | |
| } | |
| function packNodes(ownerID, nodes, count, excluding) { | |
| var bitmap = 0; | |
| var packedII = 0; | |
| var packedNodes = new Array(count); | |
| for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) { | |
| var node = nodes[ii]; | |
| if (node !== undefined && ii !== excluding) { | |
| bitmap |= bit; | |
| packedNodes[packedII++] = node; | |
| } | |
| } | |
| return new BitmapIndexedNode(ownerID, bitmap, packedNodes); | |
| } | |
| function expandNodes(ownerID, nodes, bitmap, including, node) { | |
| var count = 0; | |
| var expandedNodes = new Array(SIZE); | |
| for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) { | |
| expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined; | |
| } | |
| expandedNodes[including] = node; | |
| return new HashArrayMapNode(ownerID, count + 1, expandedNodes); | |
| } | |
| function popCount(x) { | |
| x -= (x >> 1) & 0x55555555; | |
| x = (x & 0x33333333) + ((x >> 2) & 0x33333333); | |
| x = (x + (x >> 4)) & 0x0f0f0f0f; | |
| x += x >> 8; | |
| x += x >> 16; | |
| return x & 0x7f; | |
| } | |
| function setAt(array, idx, val, canEdit) { | |
| var newArray = canEdit ? array : arrCopy(array); | |
| newArray[idx] = val; | |
| return newArray; | |
| } | |
| function spliceIn(array, idx, val, canEdit) { | |
| var newLen = array.length + 1; | |
| if (canEdit && idx + 1 === newLen) { | |
| array[idx] = val; | |
| return array; | |
| } | |
| var newArray = new Array(newLen); | |
| var after = 0; | |
| for (var ii = 0; ii < newLen; ii++) { | |
| if (ii === idx) { | |
| newArray[ii] = val; | |
| after = -1; | |
| } else { | |
| newArray[ii] = array[ii + after]; | |
| } | |
| } | |
| return newArray; | |
| } | |
| function spliceOut(array, idx, canEdit) { | |
| var newLen = array.length - 1; | |
| if (canEdit && idx === newLen) { | |
| array.pop(); | |
| return array; | |
| } | |
| var newArray = new Array(newLen); | |
| var after = 0; | |
| for (var ii = 0; ii < newLen; ii++) { | |
| if (ii === idx) { | |
| after = 1; | |
| } | |
| newArray[ii] = array[ii + after]; | |
| } | |
| return newArray; | |
| } | |
| var MAX_ARRAY_MAP_SIZE = SIZE / 4; | |
| var MAX_BITMAP_INDEXED_SIZE = SIZE / 2; | |
| var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4; | |
| var IS_LIST_SYMBOL = '@@__IMMUTABLE_LIST__@@'; | |
| function isList(maybeList) { | |
| return Boolean(maybeList && maybeList[IS_LIST_SYMBOL]); | |
| } | |
| var List = /*@__PURE__*/(function (IndexedCollection) { | |
| function List(value) { | |
| var empty = emptyList(); | |
| if (value === undefined || value === null) { | |
| return empty; | |
| } | |
| if (isList(value)) { | |
| return value; | |
| } | |
| var iter = IndexedCollection(value); | |
| var size = iter.size; | |
| if (size === 0) { | |
| return empty; | |
| } | |
| assertNotInfinite(size); | |
| if (size > 0 && size < SIZE) { | |
| return makeList(0, size, SHIFT, null, new VNode(iter.toArray())); | |
| } | |
| return empty.withMutations(function (list) { | |
| list.setSize(size); | |
| iter.forEach(function (v, i) { return list.set(i, v); }); | |
| }); | |
| } | |
| if ( IndexedCollection ) List.__proto__ = IndexedCollection; | |
| List.prototype = Object.create( IndexedCollection && IndexedCollection.prototype ); | |
| List.prototype.constructor = List; | |
| List.of = function of (/*...values*/) { | |
| return this(arguments); | |
| }; | |
| List.prototype.toString = function toString () { | |
| return this.__toString('List [', ']'); | |
| }; | |
| // @pragma Access | |
| List.prototype.get = function get (index, notSetValue) { | |
| index = wrapIndex(this, index); | |
| if (index >= 0 && index < this.size) { | |
| index += this._origin; | |
| var node = listNodeFor(this, index); | |
| return node && node.array[index & MASK]; | |
| } | |
| return notSetValue; | |
| }; | |
| // @pragma Modification | |
| List.prototype.set = function set (index, value) { | |
| return updateList(this, index, value); | |
| }; | |
| List.prototype.remove = function remove (index) { | |
| return !this.has(index) | |
| ? this | |
| : index === 0 | |
| ? this.shift() | |
| : index === this.size - 1 | |
| ? this.pop() | |
| : this.splice(index, 1); | |
| }; | |
| List.prototype.insert = function insert (index, value) { | |
| return this.splice(index, 0, value); | |
| }; | |
| List.prototype.clear = function clear () { | |
| if (this.size === 0) { | |
| return this; | |
| } | |
| if (this.__ownerID) { | |
| this.size = this._origin = this._capacity = 0; | |
| this._level = SHIFT; | |
| this._root = this._tail = this.__hash = undefined; | |
| this.__altered = true; | |
| return this; | |
| } | |
| return emptyList(); | |
| }; | |
| List.prototype.push = function push (/*...values*/) { | |
| var values = arguments; | |
| var oldSize = this.size; | |
| return this.withMutations(function (list) { | |
| setListBounds(list, 0, oldSize + values.length); | |
| for (var ii = 0; ii < values.length; ii++) { | |
| list.set(oldSize + ii, values[ii]); | |
| } | |
| }); | |
| }; | |
| List.prototype.pop = function pop () { | |
| return setListBounds(this, 0, -1); | |
| }; | |
| List.prototype.unshift = function unshift (/*...values*/) { | |
| var values = arguments; | |
| return this.withMutations(function (list) { | |
| setListBounds(list, -values.length); | |
| for (var ii = 0; ii < values.length; ii++) { | |
| list.set(ii, values[ii]); | |
| } | |
| }); | |
| }; | |
| List.prototype.shift = function shift () { | |
| return setListBounds(this, 1); | |
| }; | |
| // @pragma Composition | |
| List.prototype.concat = function concat (/*...collections*/) { | |
| var arguments$1 = arguments; | |
| var seqs = []; | |
| for (var i = 0; i < arguments.length; i++) { | |
| var argument = arguments$1[i]; | |
| var seq = IndexedCollection( | |
| typeof argument !== 'string' && hasIterator(argument) | |
| ? argument | |
| : [argument] | |
| ); | |
| if (seq.size !== 0) { | |
| seqs.push(seq); | |
| } | |
| } | |
| if (seqs.length === 0) { | |
| return this; | |
| } | |
| if (this.size === 0 && !this.__ownerID && seqs.length === 1) { | |
| return this.constructor(seqs[0]); | |
| } | |
| return this.withMutations(function (list) { | |
| seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); }); | |
| }); | |
| }; | |
| List.prototype.setSize = function setSize (size) { | |
| return setListBounds(this, 0, size); | |
| }; | |
| List.prototype.map = function map (mapper, context) { | |
| var this$1$1 = this; | |
| return this.withMutations(function (list) { | |
| for (var i = 0; i < this$1$1.size; i++) { | |
| list.set(i, mapper.call(context, list.get(i), i, this$1$1)); | |
| } | |
| }); | |
| }; | |
| // @pragma Iteration | |
| List.prototype.slice = function slice (begin, end) { | |
| var size = this.size; | |
| if (wholeSlice(begin, end, size)) { | |
| return this; | |
| } | |
| return setListBounds( | |
| this, | |
| resolveBegin(begin, size), | |
| resolveEnd(end, size) | |
| ); | |
| }; | |
| List.prototype.__iterator = function __iterator (type, reverse) { | |
| var index = reverse ? this.size : 0; | |
| var values = iterateList(this, reverse); | |
| return new Iterator(function () { | |
| var value = values(); | |
| return value === DONE | |
| ? iteratorDone() | |
| : iteratorValue(type, reverse ? --index : index++, value); | |
| }); | |
| }; | |
| List.prototype.__iterate = function __iterate (fn, reverse) { | |
| var index = reverse ? this.size : 0; | |
| var values = iterateList(this, reverse); | |
| var value; | |
| while ((value = values()) !== DONE) { | |
| if (fn(value, reverse ? --index : index++, this) === false) { | |
| break; | |
| } | |
| } | |
| return index; | |
| }; | |
| List.prototype.__ensureOwner = function __ensureOwner (ownerID) { | |
| if (ownerID === this.__ownerID) { | |
| return this; | |
| } | |
| if (!ownerID) { | |
| if (this.size === 0) { | |
| return emptyList(); | |
| } | |
| this.__ownerID = ownerID; | |
| this.__altered = false; | |
| return this; | |
| } | |
| return makeList( | |
| this._origin, | |
| this._capacity, | |
| this._level, | |
| this._root, | |
| this._tail, | |
| ownerID, | |
| this.__hash | |
| ); | |
| }; | |
| return List; | |
| }(IndexedCollection)); | |
| List.isList = isList; | |
| var ListPrototype = List.prototype; | |
| ListPrototype[IS_LIST_SYMBOL] = true; | |
| ListPrototype[DELETE] = ListPrototype.remove; | |
| ListPrototype.merge = ListPrototype.concat; | |
| ListPrototype.setIn = setIn; | |
| ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn; | |
| ListPrototype.update = update; | |
| ListPrototype.updateIn = updateIn; | |
| ListPrototype.mergeIn = mergeIn; | |
| ListPrototype.mergeDeepIn = mergeDeepIn; | |
| ListPrototype.withMutations = withMutations; | |
| ListPrototype.wasAltered = wasAltered; | |
| ListPrototype.asImmutable = asImmutable; | |
| ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable; | |
| ListPrototype['@@transducer/step'] = function (result, arr) { | |
| return result.push(arr); | |
| }; | |
| ListPrototype['@@transducer/result'] = function (obj) { | |
| return obj.asImmutable(); | |
| }; | |
| var VNode = function VNode(array, ownerID) { | |
| this.array = array; | |
| this.ownerID = ownerID; | |
| }; | |
| // TODO: seems like these methods are very similar | |
| VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { | |
| if (index === level ? 1 << level : this.array.length === 0) { | |
| return this; | |
| } | |
| var originIndex = (index >>> level) & MASK; | |
| if (originIndex >= this.array.length) { | |
| return new VNode([], ownerID); | |
| } | |
| var removingFirst = originIndex === 0; | |
| var newChild; | |
| if (level > 0) { | |
| var oldChild = this.array[originIndex]; | |
| newChild = | |
| oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index); | |
| if (newChild === oldChild && removingFirst) { | |
| return this; | |
| } | |
| } | |
| if (removingFirst && !newChild) { | |
| return this; | |
| } | |
| var editable = editableVNode(this, ownerID); | |
| if (!removingFirst) { | |
| for (var ii = 0; ii < originIndex; ii++) { | |
| editable.array[ii] = undefined; | |
| } | |
| } | |
| if (newChild) { | |
| editable.array[originIndex] = newChild; | |
| } | |
| return editable; | |
| }; | |
| VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) { | |
| if (index === (level ? 1 << level : 0) || this.array.length === 0) { | |
| return this; | |
| } | |
| var sizeIndex = ((index - 1) >>> level) & MASK; | |
| if (sizeIndex >= this.array.length) { | |
| return this; | |
| } | |
| var newChild; | |
| if (level > 0) { | |
| var oldChild = this.array[sizeIndex]; | |
| newChild = | |
| oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index); | |
| if (newChild === oldChild && sizeIndex === this.array.length - 1) { | |
| return this; | |
| } | |
| } | |
| var editable = editableVNode(this, ownerID); | |
| editable.array.splice(sizeIndex + 1); | |
| if (newChild) { | |
| editable.array[sizeIndex] = newChild; | |
| } | |
| return editable; | |
| }; | |
| var DONE = {}; | |
| function iterateList(list, reverse) { | |
| var left = list._origin; | |
| var right = list._capacity; | |
| var tailPos = getTailOffset(right); | |
| var tail = list._tail; | |
| return iterateNodeOrLeaf(list._root, list._level, 0); | |
| function iterateNodeOrLeaf(node, level, offset) { | |
| return level === 0 | |
| ? iterateLeaf(node, offset) | |
| : iterateNode(node, level, offset); | |
| } | |
| function iterateLeaf(node, offset) { | |
| var array = offset === tailPos ? tail && tail.array : node && node.array; | |
| var from = offset > left ? 0 : left - offset; | |
| var to = right - offset; | |
| if (to > SIZE) { | |
| to = SIZE; | |
| } | |
| return function () { | |
| if (from === to) { | |
| return DONE; | |
| } | |
| var idx = reverse ? --to : from++; | |
| return array && array[idx]; | |
| }; | |
| } | |
| function iterateNode(node, level, offset) { | |
| var values; | |
| var array = node && node.array; | |
| var from = offset > left ? 0 : (left - offset) >> level; | |
| var to = ((right - offset) >> level) + 1; | |
| if (to > SIZE) { | |
| to = SIZE; | |
| } | |
| return function () { | |
| while (true) { | |
| if (values) { | |
| var value = values(); | |
| if (value !== DONE) { | |
| return value; | |
| } | |
| values = null; | |
| } | |
| if (from === to) { | |
| return DONE; | |
| } | |
| var idx = reverse ? --to : from++; | |
| values = iterateNodeOrLeaf( | |
| array && array[idx], | |
| level - SHIFT, | |
| offset + (idx << level) | |
| ); | |
| } | |
| }; | |
| } | |
| } | |
| function makeList(origin, capacity, level, root, tail, ownerID, hash) { | |
| var list = Object.create(ListPrototype); | |
| list.size = capacity - origin; | |
| list._origin = origin; | |
| list._capacity = capacity; | |
| list._level = level; | |
| list._root = root; | |
| list._tail = tail; | |
| list.__ownerID = ownerID; | |
| list.__hash = hash; | |
| list.__altered = false; | |
| return list; | |
| } | |
| var EMPTY_LIST; | |
| function emptyList() { | |
| return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT)); | |
| } | |
| function updateList(list, index, value) { | |
| index = wrapIndex(list, index); | |
| if (index !== index) { | |
| return list; | |
| } | |
| if (index >= list.size || index < 0) { | |
| return list.withMutations(function (list) { | |
| index < 0 | |
| ? setListBounds(list, index).set(0, value) | |
| : setListBounds(list, 0, index + 1).set(index, value); | |
| }); | |
| } | |
| index += list._origin; | |
| var newTail = list._tail; | |
| var newRoot = list._root; | |
| var didAlter = MakeRef(); | |
| if (index >= getTailOffset(list._capacity)) { | |
| newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter); | |
| } else { | |
| newRoot = updateVNode( | |
| newRoot, | |
| list.__ownerID, | |
| list._level, | |
| index, | |
| value, | |
| didAlter | |
| ); | |
| } | |
| if (!didAlter.value) { | |
| return list; | |
| } | |
| if (list.__ownerID) { | |
| list._root = newRoot; | |
| list._tail = newTail; | |
| list.__hash = undefined; | |
| list.__altered = true; | |
| return list; | |
| } | |
| return makeList(list._origin, list._capacity, list._level, newRoot, newTail); | |
| } | |
| function updateVNode(node, ownerID, level, index, value, didAlter) { | |
| var idx = (index >>> level) & MASK; | |
| var nodeHas = node && idx < node.array.length; | |
| if (!nodeHas && value === undefined) { | |
| return node; | |
| } | |
| var newNode; | |
| if (level > 0) { | |
| var lowerNode = node && node.array[idx]; | |
| var newLowerNode = updateVNode( | |
| lowerNode, | |
| ownerID, | |
| level - SHIFT, | |
| index, | |
| value, | |
| didAlter | |
| ); | |
| if (newLowerNode === lowerNode) { | |
| return node; | |
| } | |
| newNode = editableVNode(node, ownerID); | |
| newNode.array[idx] = newLowerNode; | |
| return newNode; | |
| } | |
| if (nodeHas && node.array[idx] === value) { | |
| return node; | |
| } | |
| if (didAlter) { | |
| SetRef(didAlter); | |
| } | |
| newNode = editableVNode(node, ownerID); | |
| if (value === undefined && idx === newNode.array.length - 1) { | |
| newNode.array.pop(); | |
| } else { | |
| newNode.array[idx] = value; | |
| } | |
| return newNode; | |
| } | |
| function editableVNode(node, ownerID) { | |
| if (ownerID && node && ownerID === node.ownerID) { | |
| return node; | |
| } | |
| return new VNode(node ? node.array.slice() : [], ownerID); | |
| } | |
| function listNodeFor(list, rawIndex) { | |
| if (rawIndex >= getTailOffset(list._capacity)) { | |
| return list._tail; | |
| } | |
| if (rawIndex < 1 << (list._level + SHIFT)) { | |
| var node = list._root; | |
| var level = list._level; | |
| while (node && level > 0) { | |
| node = node.array[(rawIndex >>> level) & MASK]; | |
| level -= SHIFT; | |
| } | |
| return node; | |
| } | |
| } | |
| function setListBounds(list, begin, end) { | |
| // Sanitize begin & end using this shorthand for ToInt32(argument) | |
| // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 | |
| if (begin !== undefined) { | |
| begin |= 0; | |
| } | |
| if (end !== undefined) { | |
| end |= 0; | |
| } | |
| var owner = list.__ownerID || new OwnerID(); | |
| var oldOrigin = list._origin; | |
| var oldCapacity = list._capacity; | |
| var newOrigin = oldOrigin + begin; | |
| var newCapacity = | |
| end === undefined | |
| ? oldCapacity | |
| : end < 0 | |
| ? oldCapacity + end | |
| : oldOrigin + end; | |
| if (newOrigin === oldOrigin && newCapacity === oldCapacity) { | |
| return list; | |
| } | |
| // If it's going to end after it starts, it's empty. | |
| if (newOrigin >= newCapacity) { | |
| return list.clear(); | |
| } | |
| var newLevel = list._level; | |
| var newRoot = list._root; | |
| // New origin might need creating a higher root. | |
| var offsetShift = 0; | |
| while (newOrigin + offsetShift < 0) { | |
| newRoot = new VNode( | |
| newRoot && newRoot.array.length ? [undefined, newRoot] : [], | |
| owner | |
| ); | |
| newLevel += SHIFT; | |
| offsetShift += 1 << newLevel; | |
| } | |
| if (offsetShift) { | |
| newOrigin += offsetShift; | |
| oldOrigin += offsetShift; | |
| newCapacity += offsetShift; | |
| oldCapacity += offsetShift; | |
| } | |
| var oldTailOffset = getTailOffset(oldCapacity); | |
| var newTailOffset = getTailOffset(newCapacity); | |
| // New size might need creating a higher root. | |
| while (newTailOffset >= 1 << (newLevel + SHIFT)) { | |
| newRoot = new VNode( | |
| newRoot && newRoot.array.length ? [newRoot] : [], | |
| owner | |
| ); | |
| newLevel += SHIFT; | |
| } | |
| // Locate or create the new tail. | |
| var oldTail = list._tail; | |
| var newTail = | |
| newTailOffset < oldTailOffset | |
| ? listNodeFor(list, newCapacity - 1) | |
| : newTailOffset > oldTailOffset | |
| ? new VNode([], owner) | |
| : oldTail; | |
| // Merge Tail into tree. | |
| if ( | |
| oldTail && | |
| newTailOffset > oldTailOffset && | |
| newOrigin < oldCapacity && | |
| oldTail.array.length | |
| ) { | |
| newRoot = editableVNode(newRoot, owner); | |
| var node = newRoot; | |
| for (var level = newLevel; level > SHIFT; level -= SHIFT) { | |
| var idx = (oldTailOffset >>> level) & MASK; | |
| node = node.array[idx] = editableVNode(node.array[idx], owner); | |
| } | |
| node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail; | |
| } | |
| // If the size has been reduced, there's a chance the tail needs to be trimmed. | |
| if (newCapacity < oldCapacity) { | |
| newTail = newTail && newTail.removeAfter(owner, 0, newCapacity); | |
| } | |
| // If the new origin is within the tail, then we do not need a root. | |
| if (newOrigin >= newTailOffset) { | |
| newOrigin -= newTailOffset; | |
| newCapacity -= newTailOffset; | |
| newLevel = SHIFT; | |
| newRoot = null; | |
| newTail = newTail && newTail.removeBefore(owner, 0, newOrigin); | |
| // Otherwise, if the root has been trimmed, garbage collect. | |
| } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) { | |
| offsetShift = 0; | |
| // Identify the new top root node of the subtree of the old root. | |
| while (newRoot) { | |
| var beginIndex = (newOrigin >>> newLevel) & MASK; | |
| if ((beginIndex !== newTailOffset >>> newLevel) & MASK) { | |
| break; | |
| } | |
| if (beginIndex) { | |
| offsetShift += (1 << newLevel) * beginIndex; | |
| } | |
| newLevel -= SHIFT; | |
| newRoot = newRoot.array[beginIndex]; | |
| } | |
| // Trim the new sides of the new root. | |
| if (newRoot && newOrigin > oldOrigin) { | |
| newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift); | |
| } | |
| if (newRoot && newTailOffset < oldTailOffset) { | |
| newRoot = newRoot.removeAfter( | |
| owner, | |
| newLevel, | |
| newTailOffset - offsetShift | |
| ); | |
| } | |
| if (offsetShift) { | |
| newOrigin -= offsetShift; | |
| newCapacity -= offsetShift; | |
| } | |
| } | |
| if (list.__ownerID) { | |
| list.size = newCapacity - newOrigin; | |
| list._origin = newOrigin; | |
| list._capacity = newCapacity; | |
| list._level = newLevel; | |
| list._root = newRoot; | |
| list._tail = newTail; | |
| list.__hash = undefined; | |
| list.__altered = true; | |
| return list; | |
| } | |
| return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail); | |
| } | |
| function getTailOffset(size) { | |
| return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT; | |
| } | |
| var OrderedMap = /*@__PURE__*/(function (Map) { | |
| function OrderedMap(value) { | |
| return value === undefined || value === null | |
| ? emptyOrderedMap() | |
| : isOrderedMap(value) | |
| ? value | |
| : emptyOrderedMap().withMutations(function (map) { | |
| var iter = KeyedCollection(value); | |
| assertNotInfinite(iter.size); | |
| iter.forEach(function (v, k) { return map.set(k, v); }); | |
| }); | |
| } | |
| if ( Map ) OrderedMap.__proto__ = Map; | |
| OrderedMap.prototype = Object.create( Map && Map.prototype ); | |
| OrderedMap.prototype.constructor = OrderedMap; | |
| OrderedMap.of = function of (/*...values*/) { | |
| return this(arguments); | |
| }; | |
| OrderedMap.prototype.toString = function toString () { | |
| return this.__toString('OrderedMap {', '}'); | |
| }; | |
| // @pragma Access | |
| OrderedMap.prototype.get = function get (k, notSetValue) { | |
| var index = this._map.get(k); | |
| return index !== undefined ? this._list.get(index)[1] : notSetValue; | |
| }; | |
| // @pragma Modification | |
| OrderedMap.prototype.clear = function clear () { | |
| if (this.size === 0) { | |
| return this; | |
| } | |
| if (this.__ownerID) { | |
| this.size = 0; | |
| this._map.clear(); | |
| this._list.clear(); | |
| this.__altered = true; | |
| return this; | |
| } | |
| return emptyOrderedMap(); | |
| }; | |
| OrderedMap.prototype.set = function set (k, v) { | |
| return updateOrderedMap(this, k, v); | |
| }; | |
| OrderedMap.prototype.remove = function remove (k) { | |
| return updateOrderedMap(this, k, NOT_SET); | |
| }; | |
| OrderedMap.prototype.__iterate = function __iterate (fn, reverse) { | |
| var this$1$1 = this; | |
| return this._list.__iterate( | |
| function (entry) { return entry && fn(entry[1], entry[0], this$1$1); }, | |
| reverse | |
| ); | |
| }; | |
| OrderedMap.prototype.__iterator = function __iterator (type, reverse) { | |
| return this._list.fromEntrySeq().__iterator(type, reverse); | |
| }; | |
| OrderedMap.prototype.__ensureOwner = function __ensureOwner (ownerID) { | |
| if (ownerID === this.__ownerID) { | |
| return this; | |
| } | |
| var newMap = this._map.__ensureOwner(ownerID); | |
| var newList = this._list.__ensureOwner(ownerID); | |
| if (!ownerID) { | |
| if (this.size === 0) { | |
| return emptyOrderedMap(); | |
| } | |
| this.__ownerID = ownerID; | |
| this.__altered = false; | |
| this._map = newMap; | |
| this._list = newList; | |
| return this; | |
| } | |
| return makeOrderedMap(newMap, newList, ownerID, this.__hash); | |
| }; | |
| return OrderedMap; | |
| }(Map)); | |
| OrderedMap.isOrderedMap = isOrderedMap; | |
| OrderedMap.prototype[IS_ORDERED_SYMBOL] = true; | |
| OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove; | |
| function makeOrderedMap(map, list, ownerID, hash) { | |
| var omap = Object.create(OrderedMap.prototype); | |
| omap.size = map ? map.size : 0; | |
| omap._map = map; | |
| omap._list = list; | |
| omap.__ownerID = ownerID; | |
| omap.__hash = hash; | |
| omap.__altered = false; | |
| return omap; | |
| } | |
| var EMPTY_ORDERED_MAP; | |
| function emptyOrderedMap() { | |
| return ( | |
| EMPTY_ORDERED_MAP || | |
| (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList())) | |
| ); | |
| } | |
| function updateOrderedMap(omap, k, v) { | |
| var map = omap._map; | |
| var list = omap._list; | |
| var i = map.get(k); | |
| var has = i !== undefined; | |
| var newMap; | |
| var newList; | |
| if (v === NOT_SET) { | |
| // removed | |
| if (!has) { | |
| return omap; | |
| } | |
| if (list.size >= SIZE && list.size >= map.size * 2) { | |
| newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; }); | |
| newMap = newList | |
| .toKeyedSeq() | |
| .map(function (entry) { return entry[0]; }) | |
| .flip() | |
| .toMap(); | |
| if (omap.__ownerID) { | |
| newMap.__ownerID = newList.__ownerID = omap.__ownerID; | |
| } | |
| } else { | |
| newMap = map.remove(k); | |
| newList = i === list.size - 1 ? list.pop() : list.set(i, undefined); | |
| } | |
| } else if (has) { | |
| if (v === list.get(i)[1]) { | |
| return omap; | |
| } | |
| newMap = map; | |
| newList = list.set(i, [k, v]); | |
| } else { | |
| newMap = map.set(k, list.size); | |
| newList = list.set(list.size, [k, v]); | |
| } | |
| if (omap.__ownerID) { | |
| omap.size = newMap.size; | |
| omap._map = newMap; | |
| omap._list = newList; | |
| omap.__hash = undefined; | |
| omap.__altered = true; | |
| return omap; | |
| } | |
| return makeOrderedMap(newMap, newList); | |
| } | |
| var IS_STACK_SYMBOL = '@@__IMMUTABLE_STACK__@@'; | |
| function isStack(maybeStack) { | |
| return Boolean(maybeStack && maybeStack[IS_STACK_SYMBOL]); | |
| } | |
| var Stack = /*@__PURE__*/(function (IndexedCollection) { | |
| function Stack(value) { | |
| return value === undefined || value === null | |
| ? emptyStack() | |
| : isStack(value) | |
| ? value | |
| : emptyStack().pushAll(value); | |
| } | |
| if ( IndexedCollection ) Stack.__proto__ = IndexedCollection; | |
| Stack.prototype = Object.create( IndexedCollection && IndexedCollection.prototype ); | |
| Stack.prototype.constructor = Stack; | |
| Stack.of = function of (/*...values*/) { | |
| return this(arguments); | |
| }; | |
| Stack.prototype.toString = function toString () { | |
| return this.__toString('Stack [', ']'); | |
| }; | |
| // @pragma Access | |
| Stack.prototype.get = function get (index, notSetValue) { | |
| var head = this._head; | |
| index = wrapIndex(this, index); | |
| while (head && index--) { | |
| head = head.next; | |
| } | |
| return head ? head.value : notSetValue; | |
| }; | |
| Stack.prototype.peek = function peek () { | |
| return this._head && this._head.value; | |
| }; | |
| // @pragma Modification | |
| Stack.prototype.push = function push (/*...values*/) { | |
| var arguments$1 = arguments; | |
| if (arguments.length === 0) { | |
| return this; | |
| } | |
| var newSize = this.size + arguments.length; | |
| var head = this._head; | |
| for (var ii = arguments.length - 1; ii >= 0; ii--) { | |
| head = { | |
| value: arguments$1[ii], | |
| next: head, | |
| }; | |
| } | |
| if (this.__ownerID) { | |
| this.size = newSize; | |
| this._head = head; | |
| this.__hash = undefined; | |
| this.__altered = true; | |
| return this; | |
| } | |
| return makeStack(newSize, head); | |
| }; | |
| Stack.prototype.pushAll = function pushAll (iter) { | |
| iter = IndexedCollection(iter); | |
| if (iter.size === 0) { | |
| return this; | |
| } | |
| if (this.size === 0 && isStack(iter)) { | |
| return iter; | |
| } | |
| assertNotInfinite(iter.size); | |
| var newSize = this.size; | |
| var head = this._head; | |
| iter.__iterate(function (value) { | |
| newSize++; | |
| head = { | |
| value: value, | |
| next: head, | |
| }; | |
| }, /* reverse */ true); | |
| if (this.__ownerID) { | |
| this.size = newSize; | |
| this._head = head; | |
| this.__hash = undefined; | |
| this.__altered = true; | |
| return this; | |
| } | |
| return makeStack(newSize, head); | |
| }; | |
| Stack.prototype.pop = function pop () { | |
| return this.slice(1); | |
| }; | |
| Stack.prototype.clear = function clear () { | |
| if (this.size === 0) { | |
| return this; | |
| } | |
| if (this.__ownerID) { | |
| this.size = 0; | |
| this._head = undefined; | |
| this.__hash = undefined; | |
| this.__altered = true; | |
| return this; | |
| } | |
| return emptyStack(); | |
| }; | |
| Stack.prototype.slice = function slice (begin, end) { | |
| if (wholeSlice(begin, end, this.size)) { | |
| return this; | |
| } | |
| var resolvedBegin = resolveBegin(begin, this.size); | |
| var resolvedEnd = resolveEnd(end, this.size); | |
| if (resolvedEnd !== this.size) { | |
| // super.slice(begin, end); | |
| return IndexedCollection.prototype.slice.call(this, begin, end); | |
| } | |
| var newSize = this.size - resolvedBegin; | |
| var head = this._head; | |
| while (resolvedBegin--) { | |
| head = head.next; | |
| } | |
| if (this.__ownerID) { | |
| this.size = newSize; | |
| this._head = head; | |
| this.__hash = undefined; | |
| this.__altered = true; | |
| return this; | |
| } | |
| return makeStack(newSize, head); | |
| }; | |
| // @pragma Mutability | |
| Stack.prototype.__ensureOwner = function __ensureOwner (ownerID) { | |
| if (ownerID === this.__ownerID) { | |
| return this; | |
| } | |
| if (!ownerID) { | |
| if (this.size === 0) { | |
| return emptyStack(); | |
| } | |
| this.__ownerID = ownerID; | |
| this.__altered = false; | |
| return this; | |
| } | |
| return makeStack(this.size, this._head, ownerID, this.__hash); | |
| }; | |
| // @pragma Iteration | |
| Stack.prototype.__iterate = function __iterate (fn, reverse) { | |
| var this$1$1 = this; | |
| if (reverse) { | |
| return new ArraySeq(this.toArray()).__iterate( | |
| function (v, k) { return fn(v, k, this$1$1); }, | |
| reverse | |
| ); | |
| } | |
| var iterations = 0; | |
| var node = this._head; | |
| while (node) { | |
| if (fn(node.value, iterations++, this) === false) { | |
| break; | |
| } | |
| node = node.next; | |
| } | |
| return iterations; | |
| }; | |
| Stack.prototype.__iterator = function __iterator (type, reverse) { | |
| if (reverse) { | |
| return new ArraySeq(this.toArray()).__iterator(type, reverse); | |
| } | |
| var iterations = 0; | |
| var node = this._head; | |
| return new Iterator(function () { | |
| if (node) { | |
| var value = node.value; | |
| node = node.next; | |
| return iteratorValue(type, iterations++, value); | |
| } | |
| return iteratorDone(); | |
| }); | |
| }; | |
| return Stack; | |
| }(IndexedCollection)); | |
| Stack.isStack = isStack; | |
| var StackPrototype = Stack.prototype; | |
| StackPrototype[IS_STACK_SYMBOL] = true; | |
| StackPrototype.shift = StackPrototype.pop; | |
| StackPrototype.unshift = StackPrototype.push; | |
| StackPrototype.unshiftAll = StackPrototype.pushAll; | |
| StackPrototype.withMutations = withMutations; | |
| StackPrototype.wasAltered = wasAltered; | |
| StackPrototype.asImmutable = asImmutable; | |
| StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable; | |
| StackPrototype['@@transducer/step'] = function (result, arr) { | |
| return result.unshift(arr); | |
| }; | |
| StackPrototype['@@transducer/result'] = function (obj) { | |
| return obj.asImmutable(); | |
| }; | |
| function makeStack(size, head, ownerID, hash) { | |
| var map = Object.create(StackPrototype); | |
| map.size = size; | |
| map._head = head; | |
| map.__ownerID = ownerID; | |
| map.__hash = hash; | |
| map.__altered = false; | |
| return map; | |
| } | |
| var EMPTY_STACK; | |
| function emptyStack() { | |
| return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); | |
| } | |
| var IS_SET_SYMBOL = '@@__IMMUTABLE_SET__@@'; | |
| function isSet(maybeSet) { | |
| return Boolean(maybeSet && maybeSet[IS_SET_SYMBOL]); | |
| } | |
| function isOrderedSet(maybeOrderedSet) { | |
| return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); | |
| } | |
| function deepEqual(a, b) { | |
| if (a === b) { | |
| return true; | |
| } | |
| if ( | |
| !isCollection(b) || | |
| (a.size !== undefined && b.size !== undefined && a.size !== b.size) || | |
| (a.__hash !== undefined && | |
| b.__hash !== undefined && | |
| a.__hash !== b.__hash) || | |
| isKeyed(a) !== isKeyed(b) || | |
| isIndexed(a) !== isIndexed(b) || | |
| isOrdered(a) !== isOrdered(b) | |
| ) { | |
| return false; | |
| } | |
| if (a.size === 0 && b.size === 0) { | |
| return true; | |
| } | |
| var notAssociative = !isAssociative(a); | |
| if (isOrdered(a)) { | |
| var entries = a.entries(); | |
| return ( | |
| b.every(function (v, k) { | |
| var entry = entries.next().value; | |
| return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); | |
| }) && entries.next().done | |
| ); | |
| } | |
| var flipped = false; | |
| if (a.size === undefined) { | |
| if (b.size === undefined) { | |
| if (typeof a.cacheResult === 'function') { | |
| a.cacheResult(); | |
| } | |
| } else { | |
| flipped = true; | |
| var _ = a; | |
| a = b; | |
| b = _; | |
| } | |
| } | |
| var allEqual = true; | |
| var bSize = b.__iterate(function (v, k) { | |
| if ( | |
| notAssociative | |
| ? !a.has(v) | |
| : flipped | |
| ? !is(v, a.get(k, NOT_SET)) | |
| : !is(a.get(k, NOT_SET), v) | |
| ) { | |
| allEqual = false; | |
| return false; | |
| } | |
| }); | |
| return allEqual && a.size === bSize; | |
| } | |
| function mixin(ctor, methods) { | |
| var keyCopier = function (key) { | |
| ctor.prototype[key] = methods[key]; | |
| }; | |
| Object.keys(methods).forEach(keyCopier); | |
| Object.getOwnPropertySymbols && | |
| Object.getOwnPropertySymbols(methods).forEach(keyCopier); | |
| return ctor; | |
| } | |
| function toJS(value) { | |
| if (!value || typeof value !== 'object') { | |
| return value; | |
| } | |
| if (!isCollection(value)) { | |
| if (!isDataStructure(value)) { | |
| return value; | |
| } | |
| value = Seq(value); | |
| } | |
| if (isKeyed(value)) { | |
| var result$1 = {}; | |
| value.__iterate(function (v, k) { | |
| result$1[k] = toJS(v); | |
| }); | |
| return result$1; | |
| } | |
| var result = []; | |
| value.__iterate(function (v) { | |
| result.push(toJS(v)); | |
| }); | |
| return result; | |
| } | |
| var Set = /*@__PURE__*/(function (SetCollection) { | |
| function Set(value) { | |
| return value === undefined || value === null | |
| ? emptySet() | |
| : isSet(value) && !isOrdered(value) | |
| ? value | |
| : emptySet().withMutations(function (set) { | |
| var iter = SetCollection(value); | |
| assertNotInfinite(iter.size); | |
| iter.forEach(function (v) { return set.add(v); }); | |
| }); | |
| } | |
| if ( SetCollection ) Set.__proto__ = SetCollection; | |
| Set.prototype = Object.create( SetCollection && SetCollection.prototype ); | |
| Set.prototype.constructor = Set; | |
| Set.of = function of (/*...values*/) { | |
| return this(arguments); | |
| }; | |
| Set.fromKeys = function fromKeys (value) { | |
| return this(KeyedCollection(value).keySeq()); | |
| }; | |
| Set.intersect = function intersect (sets) { | |
| sets = Collection(sets).toArray(); | |
| return sets.length | |
| ? SetPrototype.intersect.apply(Set(sets.pop()), sets) | |
| : emptySet(); | |
| }; | |
| Set.union = function union (sets) { | |
| sets = Collection(sets).toArray(); | |
| return sets.length | |
| ? SetPrototype.union.apply(Set(sets.pop()), sets) | |
| : emptySet(); | |
| }; | |
| Set.prototype.toString = function toString () { | |
| return this.__toString('Set {', '}'); | |
| }; | |
| // @pragma Access | |
| Set.prototype.has = function has (value) { | |
| return this._map.has(value); | |
| }; | |
| // @pragma Modification | |
| Set.prototype.add = function add (value) { | |
| return updateSet(this, this._map.set(value, value)); | |
| }; | |
| Set.prototype.remove = function remove (value) { | |
| return updateSet(this, this._map.remove(value)); | |
| }; | |
| Set.prototype.clear = function clear () { | |
| return updateSet(this, this._map.clear()); | |
| }; | |
| // @pragma Composition | |
| Set.prototype.map = function map (mapper, context) { | |
| var this$1$1 = this; | |
| // keep track if the set is altered by the map function | |
| var didChanges = false; | |
| var newMap = updateSet( | |
| this, | |
| this._map.mapEntries(function (ref) { | |
| var v = ref[1]; | |
| var mapped = mapper.call(context, v, v, this$1$1); | |
| if (mapped !== v) { | |
| didChanges = true; | |
| } | |
| return [mapped, mapped]; | |
| }, context) | |
| ); | |
| return didChanges ? newMap : this; | |
| }; | |
| Set.prototype.union = function union () { | |
| var iters = [], len = arguments.length; | |
| while ( len-- ) iters[ len ] = arguments[ len ]; | |
| iters = iters.filter(function (x) { return x.size !== 0; }); | |
| if (iters.length === 0) { | |
| return this; | |
| } | |
| if (this.size === 0 && !this.__ownerID && iters.length === 1) { | |
| return this.constructor(iters[0]); | |
| } | |
| return this.withMutations(function (set) { | |
| for (var ii = 0; ii < iters.length; ii++) { | |
| if (typeof iters[ii] === 'string') { | |
| set.add(iters[ii]); | |
| } else { | |
| SetCollection(iters[ii]).forEach(function (value) { return set.add(value); }); | |
| } | |
| } | |
| }); | |
| }; | |
| Set.prototype.intersect = function intersect () { | |
| var iters = [], len = arguments.length; | |
| while ( len-- ) iters[ len ] = arguments[ len ]; | |
| if (iters.length === 0) { | |
| return this; | |
| } | |
| iters = iters.map(function (iter) { return SetCollection(iter); }); | |
| var toRemove = []; | |
| this.forEach(function (value) { | |
| if (!iters.every(function (iter) { return iter.includes(value); })) { | |
| toRemove.push(value); | |
| } | |
| }); | |
| return this.withMutations(function (set) { | |
| toRemove.forEach(function (value) { | |
| set.remove(value); | |
| }); | |
| }); | |
| }; | |
| Set.prototype.subtract = function subtract () { | |
| var iters = [], len = arguments.length; | |
| while ( len-- ) iters[ len ] = arguments[ len ]; | |
| if (iters.length === 0) { | |
| return this; | |
| } | |
| iters = iters.map(function (iter) { return SetCollection(iter); }); | |
| var toRemove = []; | |
| this.forEach(function (value) { | |
| if (iters.some(function (iter) { return iter.includes(value); })) { | |
| toRemove.push(value); | |
| } | |
| }); | |
| return this.withMutations(function (set) { | |
| toRemove.forEach(function (value) { | |
| set.remove(value); | |
| }); | |
| }); | |
| }; | |
| Set.prototype.sort = function sort (comparator) { | |
| // Late binding | |
| return OrderedSet(sortFactory(this, comparator)); | |
| }; | |
| Set.prototype.sortBy = function sortBy (mapper, comparator) { | |
| // Late binding | |
| return OrderedSet(sortFactory(this, comparator, mapper)); | |
| }; | |
| Set.prototype.wasAltered = function wasAltered () { | |
| return this._map.wasAltered(); | |
| }; | |
| Set.prototype.__iterate = function __iterate (fn, reverse) { | |
| var this$1$1 = this; | |
| return this._map.__iterate(function (k) { return fn(k, k, this$1$1); }, reverse); | |
| }; | |
| Set.prototype.__iterator = function __iterator (type, reverse) { | |
| return this._map.__iterator(type, reverse); | |
| }; | |
| Set.prototype.__ensureOwner = function __ensureOwner (ownerID) { | |
| if (ownerID === this.__ownerID) { | |
| return this; | |
| } | |
| var newMap = this._map.__ensureOwner(ownerID); | |
| if (!ownerID) { | |
| if (this.size === 0) { | |
| return this.__empty(); | |
| } | |
| this.__ownerID = ownerID; | |
| this._map = newMap; | |
| return this; | |
| } | |
| return this.__make(newMap, ownerID); | |
| }; | |
| return Set; | |
| }(SetCollection)); | |
| Set.isSet = isSet; | |
| var SetPrototype = Set.prototype; | |
| SetPrototype[IS_SET_SYMBOL] = true; | |
| SetPrototype[DELETE] = SetPrototype.remove; | |
| SetPrototype.merge = SetPrototype.concat = SetPrototype.union; | |
| SetPrototype.withMutations = withMutations; | |
| SetPrototype.asImmutable = asImmutable; | |
| SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable; | |
| SetPrototype['@@transducer/step'] = function (result, arr) { | |
| return result.add(arr); | |
| }; | |
| SetPrototype['@@transducer/result'] = function (obj) { | |
| return obj.asImmutable(); | |
| }; | |
| SetPrototype.__empty = emptySet; | |
| SetPrototype.__make = makeSet; | |
| function updateSet(set, newMap) { | |
| if (set.__ownerID) { | |
| set.size = newMap.size; | |
| set._map = newMap; | |
| return set; | |
| } | |
| return newMap === set._map | |
| ? set | |
| : newMap.size === 0 | |
| ? set.__empty() | |
| : set.__make(newMap); | |
| } | |
| function makeSet(map, ownerID) { | |
| var set = Object.create(SetPrototype); | |
| set.size = map ? map.size : 0; | |
| set._map = map; | |
| set.__ownerID = ownerID; | |
| return set; | |
| } | |
| var EMPTY_SET; | |
| function emptySet() { | |
| return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap())); | |
| } | |
| /** | |
| * Returns a lazy seq of nums from start (inclusive) to end | |
| * (exclusive), by step, where start defaults to 0, step to 1, and end to | |
| * infinity. When start is equal to end, returns empty list. | |
| */ | |
| var Range = /*@__PURE__*/(function (IndexedSeq) { | |
| function Range(start, end, step) { | |
| if (!(this instanceof Range)) { | |
| return new Range(start, end, step); | |
| } | |
| invariant(step !== 0, 'Cannot step a Range by 0'); | |
| start = start || 0; | |
| if (end === undefined) { | |
| end = Infinity; | |
| } | |
| step = step === undefined ? 1 : Math.abs(step); | |
| if (end < start) { | |
| step = -step; | |
| } | |
| this._start = start; | |
| this._end = end; | |
| this._step = step; | |
| this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1); | |
| if (this.size === 0) { | |
| if (EMPTY_RANGE) { | |
| return EMPTY_RANGE; | |
| } | |
| EMPTY_RANGE = this; | |
| } | |
| } | |
| if ( IndexedSeq ) Range.__proto__ = IndexedSeq; | |
| Range.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); | |
| Range.prototype.constructor = Range; | |
| Range.prototype.toString = function toString () { | |
| if (this.size === 0) { | |
| return 'Range []'; | |
| } | |
| return ( | |
| 'Range [ ' + | |
| this._start + | |
| '...' + | |
| this._end + | |
| (this._step !== 1 ? ' by ' + this._step : '') + | |
| ' ]' | |
| ); | |
| }; | |
| Range.prototype.get = function get (index, notSetValue) { | |
| return this.has(index) | |
| ? this._start + wrapIndex(this, index) * this._step | |
| : notSetValue; | |
| }; | |
| Range.prototype.includes = function includes (searchValue) { | |
| var possibleIndex = (searchValue - this._start) / this._step; | |
| return ( | |
| possibleIndex >= 0 && | |
| possibleIndex < this.size && | |
| possibleIndex === Math.floor(possibleIndex) | |
| ); | |
| }; | |
| Range.prototype.slice = function slice (begin, end) { | |
| if (wholeSlice(begin, end, this.size)) { | |
| return this; | |
| } | |
| begin = resolveBegin(begin, this.size); | |
| end = resolveEnd(end, this.size); | |
| if (end <= begin) { | |
| return new Range(0, 0); | |
| } | |
| return new Range( | |
| this.get(begin, this._end), | |
| this.get(end, this._end), | |
| this._step | |
| ); | |
| }; | |
| Range.prototype.indexOf = function indexOf (searchValue) { | |
| var offsetValue = searchValue - this._start; | |
| if (offsetValue % this._step === 0) { | |
| var index = offsetValue / this._step; | |
| if (index >= 0 && index < this.size) { | |
| return index; | |
| } | |
| } | |
| return -1; | |
| }; | |
| Range.prototype.lastIndexOf = function lastIndexOf (searchValue) { | |
| return this.indexOf(searchValue); | |
| }; | |
| Range.prototype.__iterate = function __iterate (fn, reverse) { | |
| var size = this.size; | |
| var step = this._step; | |
| var value = reverse ? this._start + (size - 1) * step : this._start; | |
| var i = 0; | |
| while (i !== size) { | |
| if (fn(value, reverse ? size - ++i : i++, this) === false) { | |
| break; | |
| } | |
| value += reverse ? -step : step; | |
| } | |
| return i; | |
| }; | |
| Range.prototype.__iterator = function __iterator (type, reverse) { | |
| var size = this.size; | |
| var step = this._step; | |
| var value = reverse ? this._start + (size - 1) * step : this._start; | |
| var i = 0; | |
| return new Iterator(function () { | |
| if (i === size) { | |
| return iteratorDone(); | |
| } | |
| var v = value; | |
| value += reverse ? -step : step; | |
| return iteratorValue(type, reverse ? size - ++i : i++, v); | |
| }); | |
| }; | |
| Range.prototype.equals = function equals (other) { | |
| return other instanceof Range | |
| ? this._start === other._start && | |
| this._end === other._end && | |
| this._step === other._step | |
| : deepEqual(this, other); | |
| }; | |
| return Range; | |
| }(IndexedSeq)); | |
| var EMPTY_RANGE; | |
| function getIn$1(collection, searchKeyPath, notSetValue) { | |
| var keyPath = coerceKeyPath(searchKeyPath); | |
| var i = 0; | |
| while (i !== keyPath.length) { | |
| collection = get(collection, keyPath[i++], NOT_SET); | |
| if (collection === NOT_SET) { | |
| return notSetValue; | |
| } | |
| } | |
| return collection; | |
| } | |
| function getIn(searchKeyPath, notSetValue) { | |
| return getIn$1(this, searchKeyPath, notSetValue); | |
| } | |
| function hasIn$1(collection, keyPath) { | |
| return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET; | |
| } | |
| function hasIn(searchKeyPath) { | |
| return hasIn$1(this, searchKeyPath); | |
| } | |
| function toObject() { | |
| assertNotInfinite(this.size); | |
| var object = {}; | |
| this.__iterate(function (v, k) { | |
| object[k] = v; | |
| }); | |
| return object; | |
| } | |
| // Note: all of these methods are deprecated. | |
| Collection.isIterable = isCollection; | |
| Collection.isKeyed = isKeyed; | |
| Collection.isIndexed = isIndexed; | |
| Collection.isAssociative = isAssociative; | |
| Collection.isOrdered = isOrdered; | |
| Collection.Iterator = Iterator; | |
| mixin(Collection, { | |
| // ### Conversion to other types | |
| toArray: function toArray() { | |
| assertNotInfinite(this.size); | |
| var array = new Array(this.size || 0); | |
| var useTuples = isKeyed(this); | |
| var i = 0; | |
| this.__iterate(function (v, k) { | |
| // Keyed collections produce an array of tuples. | |
| array[i++] = useTuples ? [k, v] : v; | |
| }); | |
| return array; | |
| }, | |
| toIndexedSeq: function toIndexedSeq() { | |
| return new ToIndexedSequence(this); | |
| }, | |
| toJS: function toJS$1() { | |
| return toJS(this); | |
| }, | |
| toKeyedSeq: function toKeyedSeq() { | |
| return new ToKeyedSequence(this, true); | |
| }, | |
| toMap: function toMap() { | |
| // Use Late Binding here to solve the circular dependency. | |
| return Map(this.toKeyedSeq()); | |
| }, | |
| toObject: toObject, | |
| toOrderedMap: function toOrderedMap() { | |
| // Use Late Binding here to solve the circular dependency. | |
| return OrderedMap(this.toKeyedSeq()); | |
| }, | |
| toOrderedSet: function toOrderedSet() { | |
| // Use Late Binding here to solve the circular dependency. | |
| return OrderedSet(isKeyed(this) ? this.valueSeq() : this); | |
| }, | |
| toSet: function toSet() { | |
| // Use Late Binding here to solve the circular dependency. | |
| return Set(isKeyed(this) ? this.valueSeq() : this); | |
| }, | |
| toSetSeq: function toSetSeq() { | |
| return new ToSetSequence(this); | |
| }, | |
| toSeq: function toSeq() { | |
| return isIndexed(this) | |
| ? this.toIndexedSeq() | |
| : isKeyed(this) | |
| ? this.toKeyedSeq() | |
| : this.toSetSeq(); | |
| }, | |
| toStack: function toStack() { | |
| // Use Late Binding here to solve the circular dependency. | |
| return Stack(isKeyed(this) ? this.valueSeq() : this); | |
| }, | |
| toList: function toList() { | |
| // Use Late Binding here to solve the circular dependency. | |
| return List(isKeyed(this) ? this.valueSeq() : this); | |
| }, | |
| // ### Common JavaScript methods and properties | |
| toString: function toString() { | |
| return '[Collection]'; | |
| }, | |
| __toString: function __toString(head, tail) { | |
| if (this.size === 0) { | |
| return head + tail; | |
| } | |
| return ( | |
| head + | |
| ' ' + | |
| this.toSeq().map(this.__toStringMapper).join(', ') + | |
| ' ' + | |
| tail | |
| ); | |
| }, | |
| // ### ES6 Collection methods (ES6 Array and Map) | |
| concat: function concat() { | |
| var values = [], len = arguments.length; | |
| while ( len-- ) values[ len ] = arguments[ len ]; | |
| return reify(this, concatFactory(this, values)); | |
| }, | |
| includes: function includes(searchValue) { | |
| return this.some(function (value) { return is(value, searchValue); }); | |
| }, | |
| entries: function entries() { | |
| return this.__iterator(ITERATE_ENTRIES); | |
| }, | |
| every: function every(predicate, context) { | |
| assertNotInfinite(this.size); | |
| var returnValue = true; | |
| this.__iterate(function (v, k, c) { | |
| if (!predicate.call(context, v, k, c)) { | |
| returnValue = false; | |
| return false; | |
| } | |
| }); | |
| return returnValue; | |
| }, | |
| filter: function filter(predicate, context) { | |
| return reify(this, filterFactory(this, predicate, context, true)); | |
| }, | |
| partition: function partition(predicate, context) { | |
| return partitionFactory(this, predicate, context); | |
| }, | |
| find: function find(predicate, context, notSetValue) { | |
| var entry = this.findEntry(predicate, context); | |
| return entry ? entry[1] : notSetValue; | |
| }, | |
| forEach: function forEach(sideEffect, context) { | |
| assertNotInfinite(this.size); | |
| return this.__iterate(context ? sideEffect.bind(context) : sideEffect); | |
| }, | |
| join: function join(separator) { | |
| assertNotInfinite(this.size); | |
| separator = separator !== undefined ? '' + separator : ','; | |
| var joined = ''; | |
| var isFirst = true; | |
| this.__iterate(function (v) { | |
| isFirst ? (isFirst = false) : (joined += separator); | |
| joined += v !== null && v !== undefined ? v.toString() : ''; | |
| }); | |
| return joined; | |
| }, | |
| keys: function keys() { | |
| return this.__iterator(ITERATE_KEYS); | |
| }, | |
| map: function map(mapper, context) { | |
| return reify(this, mapFactory(this, mapper, context)); | |
| }, | |
| reduce: function reduce$1(reducer, initialReduction, context) { | |
| return reduce( | |
| this, | |
| reducer, | |
| initialReduction, | |
| context, | |
| arguments.length < 2, | |
| false | |
| ); | |
| }, | |
| reduceRight: function reduceRight(reducer, initialReduction, context) { | |
| return reduce( | |
| this, | |
| reducer, | |
| initialReduction, | |
| context, | |
| arguments.length < 2, | |
| true | |
| ); | |
| }, | |
| reverse: function reverse() { | |
| return reify(this, reverseFactory(this, true)); | |
| }, | |
| slice: function slice(begin, end) { | |
| return reify(this, sliceFactory(this, begin, end, true)); | |
| }, | |
| some: function some(predicate, context) { | |
| return !this.every(not(predicate), context); | |
| }, | |
| sort: function sort(comparator) { | |
| return reify(this, sortFactory(this, comparator)); | |
| }, | |
| values: function values() { | |
| return this.__iterator(ITERATE_VALUES); | |
| }, | |
| // ### More sequential methods | |
| butLast: function butLast() { | |
| return this.slice(0, -1); | |
| }, | |
| isEmpty: function isEmpty() { | |
| return this.size !== undefined ? this.size === 0 : !this.some(function () { return true; }); | |
| }, | |
| count: function count(predicate, context) { | |
| return ensureSize( | |
| predicate ? this.toSeq().filter(predicate, context) : this | |
| ); | |
| }, | |
| countBy: function countBy(grouper, context) { | |
| return countByFactory(this, grouper, context); | |
| }, | |
| equals: function equals(other) { | |
| return deepEqual(this, other); | |
| }, | |
| entrySeq: function entrySeq() { | |
| var collection = this; | |
| if (collection._cache) { | |
| // We cache as an entries array, so we can just return the cache! | |
| return new ArraySeq(collection._cache); | |
| } | |
| var entriesSequence = collection.toSeq().map(entryMapper).toIndexedSeq(); | |
| entriesSequence.fromEntrySeq = function () { return collection.toSeq(); }; | |
| return entriesSequence; | |
| }, | |
| filterNot: function filterNot(predicate, context) { | |
| return this.filter(not(predicate), context); | |
| }, | |
| findEntry: function findEntry(predicate, context, notSetValue) { | |
| var found = notSetValue; | |
| this.__iterate(function (v, k, c) { | |
| if (predicate.call(context, v, k, c)) { | |
| found = [k, v]; | |
| return false; | |
| } | |
| }); | |
| return found; | |
| }, | |
| findKey: function findKey(predicate, context) { | |
| var entry = this.findEntry(predicate, context); | |
| return entry && entry[0]; | |
| }, | |
| findLast: function findLast(predicate, context, notSetValue) { | |
| return this.toKeyedSeq().reverse().find(predicate, context, notSetValue); | |
| }, | |
| findLastEntry: function findLastEntry(predicate, context, notSetValue) { | |
| return this.toKeyedSeq() | |
| .reverse() | |
| .findEntry(predicate, context, notSetValue); | |
| }, | |
| findLastKey: function findLastKey(predicate, context) { | |
| return this.toKeyedSeq().reverse().findKey(predicate, context); | |
| }, | |
| first: function first(notSetValue) { | |
| return this.find(returnTrue, null, notSetValue); | |
| }, | |
| flatMap: function flatMap(mapper, context) { | |
| return reify(this, flatMapFactory(this, mapper, context)); | |
| }, | |
| flatten: function flatten(depth) { | |
| return reify(this, flattenFactory(this, depth, true)); | |
| }, | |
| fromEntrySeq: function fromEntrySeq() { | |
| return new FromEntriesSequence(this); | |
| }, | |
| get: function get(searchKey, notSetValue) { | |
| return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue); | |
| }, | |
| getIn: getIn, | |
| groupBy: function groupBy(grouper, context) { | |
| return groupByFactory(this, grouper, context); | |
| }, | |
| has: function has(searchKey) { | |
| return this.get(searchKey, NOT_SET) !== NOT_SET; | |
| }, | |
| hasIn: hasIn, | |
| isSubset: function isSubset(iter) { | |
| iter = typeof iter.includes === 'function' ? iter : Collection(iter); | |
| return this.every(function (value) { return iter.includes(value); }); | |
| }, | |
| isSuperset: function isSuperset(iter) { | |
| iter = typeof iter.isSubset === 'function' ? iter : Collection(iter); | |
| return iter.isSubset(this); | |
| }, | |
| keyOf: function keyOf(searchValue) { | |
| return this.findKey(function (value) { return is(value, searchValue); }); | |
| }, | |
| keySeq: function keySeq() { | |
| return this.toSeq().map(keyMapper).toIndexedSeq(); | |
| }, | |
| last: function last(notSetValue) { | |
| return this.toSeq().reverse().first(notSetValue); | |
| }, | |
| lastKeyOf: function lastKeyOf(searchValue) { | |
| return this.toKeyedSeq().reverse().keyOf(searchValue); | |
| }, | |
| max: function max(comparator) { | |
| return maxFactory(this, comparator); | |
| }, | |
| maxBy: function maxBy(mapper, comparator) { | |
| return maxFactory(this, comparator, mapper); | |
| }, | |
| min: function min(comparator) { | |
| return maxFactory( | |
| this, | |
| comparator ? neg(comparator) : defaultNegComparator | |
| ); | |
| }, | |
| minBy: function minBy(mapper, comparator) { | |
| return maxFactory( | |
| this, | |
| comparator ? neg(comparator) : defaultNegComparator, | |
| mapper | |
| ); | |
| }, | |
| rest: function rest() { | |
| return this.slice(1); | |
| }, | |
| skip: function skip(amount) { | |
| return amount === 0 ? this : this.slice(Math.max(0, amount)); | |
| }, | |
| skipLast: function skipLast(amount) { | |
| return amount === 0 ? this : this.slice(0, -Math.max(0, amount)); | |
| }, | |
| skipWhile: function skipWhile(predicate, context) { | |
| return reify(this, skipWhileFactory(this, predicate, context, true)); | |
| }, | |
| skipUntil: function skipUntil(predicate, context) { | |
| return this.skipWhile(not(predicate), context); | |
| }, | |
| sortBy: function sortBy(mapper, comparator) { | |
| return reify(this, sortFactory(this, comparator, mapper)); | |
| }, | |
| take: function take(amount) { | |
| return this.slice(0, Math.max(0, amount)); | |
| }, | |
| takeLast: function takeLast(amount) { | |
| return this.slice(-Math.max(0, amount)); | |
| }, | |
| takeWhile: function takeWhile(predicate, context) { | |
| return reify(this, takeWhileFactory(this, predicate, context)); | |
| }, | |
| takeUntil: function takeUntil(predicate, context) { | |
| return this.takeWhile(not(predicate), context); | |
| }, | |
| update: function update(fn) { | |
| return fn(this); | |
| }, | |
| valueSeq: function valueSeq() { | |
| return this.toIndexedSeq(); | |
| }, | |
| // ### Hashable Object | |
| hashCode: function hashCode() { | |
| return this.__hash || (this.__hash = hashCollection(this)); | |
| }, | |
| // ### Internal | |
| // abstract __iterate(fn, reverse) | |
| // abstract __iterator(type, reverse) | |
| }); | |
| var CollectionPrototype = Collection.prototype; | |
| CollectionPrototype[IS_COLLECTION_SYMBOL] = true; | |
| CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values; | |
| CollectionPrototype.toJSON = CollectionPrototype.toArray; | |
| CollectionPrototype.__toStringMapper = quoteString; | |
| CollectionPrototype.inspect = CollectionPrototype.toSource = function () { | |
| return this.toString(); | |
| }; | |
| CollectionPrototype.chain = CollectionPrototype.flatMap; | |
| CollectionPrototype.contains = CollectionPrototype.includes; | |
| mixin(KeyedCollection, { | |
| // ### More sequential methods | |
| flip: function flip() { | |
| return reify(this, flipFactory(this)); | |
| }, | |
| mapEntries: function mapEntries(mapper, context) { | |
| var this$1$1 = this; | |
| var iterations = 0; | |
| return reify( | |
| this, | |
| this.toSeq() | |
| .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1$1); }) | |
| .fromEntrySeq() | |
| ); | |
| }, | |
| mapKeys: function mapKeys(mapper, context) { | |
| var this$1$1 = this; | |
| return reify( | |
| this, | |
| this.toSeq() | |
| .flip() | |
| .map(function (k, v) { return mapper.call(context, k, v, this$1$1); }) | |
| .flip() | |
| ); | |
| }, | |
| }); | |
| var KeyedCollectionPrototype = KeyedCollection.prototype; | |
| KeyedCollectionPrototype[IS_KEYED_SYMBOL] = true; | |
| KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries; | |
| KeyedCollectionPrototype.toJSON = toObject; | |
| KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); }; | |
| mixin(IndexedCollection, { | |
| // ### Conversion to other types | |
| toKeyedSeq: function toKeyedSeq() { | |
| return new ToKeyedSequence(this, false); | |
| }, | |
| // ### ES6 Collection methods (ES6 Array and Map) | |
| filter: function filter(predicate, context) { | |
| return reify(this, filterFactory(this, predicate, context, false)); | |
| }, | |
| findIndex: function findIndex(predicate, context) { | |
| var entry = this.findEntry(predicate, context); | |
| return entry ? entry[0] : -1; | |
| }, | |
| indexOf: function indexOf(searchValue) { | |
| var key = this.keyOf(searchValue); | |
| return key === undefined ? -1 : key; | |
| }, | |
| lastIndexOf: function lastIndexOf(searchValue) { | |
| var key = this.lastKeyOf(searchValue); | |
| return key === undefined ? -1 : key; | |
| }, | |
| reverse: function reverse() { | |
| return reify(this, reverseFactory(this, false)); | |
| }, | |
| slice: function slice(begin, end) { | |
| return reify(this, sliceFactory(this, begin, end, false)); | |
| }, | |
| splice: function splice(index, removeNum /*, ...values*/) { | |
| var numArgs = arguments.length; | |
| removeNum = Math.max(removeNum || 0, 0); | |
| if (numArgs === 0 || (numArgs === 2 && !removeNum)) { | |
| return this; | |
| } | |
| // If index is negative, it should resolve relative to the size of the | |
| // collection. However size may be expensive to compute if not cached, so | |
| // only call count() if the number is in fact negative. | |
| index = resolveBegin(index, index < 0 ? this.count() : this.size); | |
| var spliced = this.slice(0, index); | |
| return reify( | |
| this, | |
| numArgs === 1 | |
| ? spliced | |
| : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum)) | |
| ); | |
| }, | |
| // ### More collection methods | |
| findLastIndex: function findLastIndex(predicate, context) { | |
| var entry = this.findLastEntry(predicate, context); | |
| return entry ? entry[0] : -1; | |
| }, | |
| first: function first(notSetValue) { | |
| return this.get(0, notSetValue); | |
| }, | |
| flatten: function flatten(depth) { | |
| return reify(this, flattenFactory(this, depth, false)); | |
| }, | |
| get: function get(index, notSetValue) { | |
| index = wrapIndex(this, index); | |
| return index < 0 || | |
| this.size === Infinity || | |
| (this.size !== undefined && index > this.size) | |
| ? notSetValue | |
| : this.find(function (_, key) { return key === index; }, undefined, notSetValue); | |
| }, | |
| has: function has(index) { | |
| index = wrapIndex(this, index); | |
| return ( | |
| index >= 0 && | |
| (this.size !== undefined | |
| ? this.size === Infinity || index < this.size | |
| : this.indexOf(index) !== -1) | |
| ); | |
| }, | |
| interpose: function interpose(separator) { | |
| return reify(this, interposeFactory(this, separator)); | |
| }, | |
| interleave: function interleave(/*...collections*/) { | |
| var collections = [this].concat(arrCopy(arguments)); | |
| var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections); | |
| var interleaved = zipped.flatten(true); | |
| if (zipped.size) { | |
| interleaved.size = zipped.size * collections.length; | |
| } | |
| return reify(this, interleaved); | |
| }, | |
| keySeq: function keySeq() { | |
| return Range(0, this.size); | |
| }, | |
| last: function last(notSetValue) { | |
| return this.get(-1, notSetValue); | |
| }, | |
| skipWhile: function skipWhile(predicate, context) { | |
| return reify(this, skipWhileFactory(this, predicate, context, false)); | |
| }, | |
| zip: function zip(/*, ...collections */) { | |
| var collections = [this].concat(arrCopy(arguments)); | |
| return reify(this, zipWithFactory(this, defaultZipper, collections)); | |
| }, | |
| zipAll: function zipAll(/*, ...collections */) { | |
| var collections = [this].concat(arrCopy(arguments)); | |
| return reify(this, zipWithFactory(this, defaultZipper, collections, true)); | |
| }, | |
| zipWith: function zipWith(zipper /*, ...collections */) { | |
| var collections = arrCopy(arguments); | |
| collections[0] = this; | |
| return reify(this, zipWithFactory(this, zipper, collections)); | |
| }, | |
| }); | |
| var IndexedCollectionPrototype = IndexedCollection.prototype; | |
| IndexedCollectionPrototype[IS_INDEXED_SYMBOL] = true; | |
| IndexedCollectionPrototype[IS_ORDERED_SYMBOL] = true; | |
| mixin(SetCollection, { | |
| // ### ES6 Collection methods (ES6 Array and Map) | |
| get: function get(value, notSetValue) { | |
| return this.has(value) ? value : notSetValue; | |
| }, | |
| includes: function includes(value) { | |
| return this.has(value); | |
| }, | |
| // ### More sequential methods | |
| keySeq: function keySeq() { | |
| return this.valueSeq(); | |
| }, | |
| }); | |
| var SetCollectionPrototype = SetCollection.prototype; | |
| SetCollectionPrototype.has = CollectionPrototype.includes; | |
| SetCollectionPrototype.contains = SetCollectionPrototype.includes; | |
| SetCollectionPrototype.keys = SetCollectionPrototype.values; | |
| // Mixin subclasses | |
| mixin(KeyedSeq, KeyedCollectionPrototype); | |
| mixin(IndexedSeq, IndexedCollectionPrototype); | |
| mixin(SetSeq, SetCollectionPrototype); | |
| // #pragma Helper functions | |
| function reduce(collection, reducer, reduction, context, useFirst, reverse) { | |
| assertNotInfinite(collection.size); | |
| collection.__iterate(function (v, k, c) { | |
| if (useFirst) { | |
| useFirst = false; | |
| reduction = v; | |
| } else { | |
| reduction = reducer.call(context, reduction, v, k, c); | |
| } | |
| }, reverse); | |
| return reduction; | |
| } | |
| function keyMapper(v, k) { | |
| return k; | |
| } | |
| function entryMapper(v, k) { | |
| return [k, v]; | |
| } | |
| function not(predicate) { | |
| return function () { | |
| return !predicate.apply(this, arguments); | |
| }; | |
| } | |
| function neg(predicate) { | |
| return function () { | |
| return -predicate.apply(this, arguments); | |
| }; | |
| } | |
| function defaultZipper() { | |
| return arrCopy(arguments); | |
| } | |
| function defaultNegComparator(a, b) { | |
| return a < b ? 1 : a > b ? -1 : 0; | |
| } | |
| function hashCollection(collection) { | |
| if (collection.size === Infinity) { | |
| return 0; | |
| } | |
| var ordered = isOrdered(collection); | |
| var keyed = isKeyed(collection); | |
| var h = ordered ? 1 : 0; | |
| var size = collection.__iterate( | |
| keyed | |
| ? ordered | |
| ? function (v, k) { | |
| h = (31 * h + hashMerge(hash(v), hash(k))) | 0; | |
| } | |
| : function (v, k) { | |
| h = (h + hashMerge(hash(v), hash(k))) | 0; | |
| } | |
| : ordered | |
| ? function (v) { | |
| h = (31 * h + hash(v)) | 0; | |
| } | |
| : function (v) { | |
| h = (h + hash(v)) | 0; | |
| } | |
| ); | |
| return murmurHashOfSize(size, h); | |
| } | |
| function murmurHashOfSize(size, h) { | |
| h = imul(h, 0xcc9e2d51); | |
| h = imul((h << 15) | (h >>> -15), 0x1b873593); | |
| h = imul((h << 13) | (h >>> -13), 5); | |
| h = ((h + 0xe6546b64) | 0) ^ size; | |
| h = imul(h ^ (h >>> 16), 0x85ebca6b); | |
| h = imul(h ^ (h >>> 13), 0xc2b2ae35); | |
| h = smi(h ^ (h >>> 16)); | |
| return h; | |
| } | |
| function hashMerge(a, b) { | |
| return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int | |
| } | |
| var OrderedSet = /*@__PURE__*/(function (Set) { | |
| function OrderedSet(value) { | |
| return value === undefined || value === null | |
| ? emptyOrderedSet() | |
| : isOrderedSet(value) | |
| ? value | |
| : emptyOrderedSet().withMutations(function (set) { | |
| var iter = SetCollection(value); | |
| assertNotInfinite(iter.size); | |
| iter.forEach(function (v) { return set.add(v); }); | |
| }); | |
| } | |
| if ( Set ) OrderedSet.__proto__ = Set; | |
| OrderedSet.prototype = Object.create( Set && Set.prototype ); | |
| OrderedSet.prototype.constructor = OrderedSet; | |
| OrderedSet.of = function of (/*...values*/) { | |
| return this(arguments); | |
| }; | |
| OrderedSet.fromKeys = function fromKeys (value) { | |
| return this(KeyedCollection(value).keySeq()); | |
| }; | |
| OrderedSet.prototype.toString = function toString () { | |
| return this.__toString('OrderedSet {', '}'); | |
| }; | |
| return OrderedSet; | |
| }(Set)); | |
| OrderedSet.isOrderedSet = isOrderedSet; | |
| var OrderedSetPrototype = OrderedSet.prototype; | |
| OrderedSetPrototype[IS_ORDERED_SYMBOL] = true; | |
| OrderedSetPrototype.zip = IndexedCollectionPrototype.zip; | |
| OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith; | |
| OrderedSetPrototype.zipAll = IndexedCollectionPrototype.zipAll; | |
| OrderedSetPrototype.__empty = emptyOrderedSet; | |
| OrderedSetPrototype.__make = makeOrderedSet; | |
| function makeOrderedSet(map, ownerID) { | |
| var set = Object.create(OrderedSetPrototype); | |
| set.size = map ? map.size : 0; | |
| set._map = map; | |
| set.__ownerID = ownerID; | |
| return set; | |
| } | |
| var EMPTY_ORDERED_SET; | |
| function emptyOrderedSet() { | |
| return ( | |
| EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())) | |
| ); | |
| } | |
| var PairSorting = { | |
| LeftThenRight: -1, | |
| RightThenLeft: +1, | |
| }; | |
| function throwOnInvalidDefaultValues(defaultValues) { | |
| if (isRecord(defaultValues)) { | |
| throw new Error( | |
| 'Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.' | |
| ); | |
| } | |
| if (isImmutable(defaultValues)) { | |
| throw new Error( | |
| 'Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.' | |
| ); | |
| } | |
| if (defaultValues === null || typeof defaultValues !== 'object') { | |
| throw new Error( | |
| 'Can not call `Record` with a non-object as default values. Use a plain javascript object instead.' | |
| ); | |
| } | |
| } | |
| var Record = function Record(defaultValues, name) { | |
| var hasInitialized; | |
| throwOnInvalidDefaultValues(defaultValues); | |
| var RecordType = function Record(values) { | |
| var this$1$1 = this; | |
| if (values instanceof RecordType) { | |
| return values; | |
| } | |
| if (!(this instanceof RecordType)) { | |
| return new RecordType(values); | |
| } | |
| if (!hasInitialized) { | |
| hasInitialized = true; | |
| var keys = Object.keys(defaultValues); | |
| var indices = (RecordTypePrototype._indices = {}); | |
| // Deprecated: left to attempt not to break any external code which | |
| // relies on a ._name property existing on record instances. | |
| // Use Record.getDescriptiveName() instead | |
| RecordTypePrototype._name = name; | |
| RecordTypePrototype._keys = keys; | |
| RecordTypePrototype._defaultValues = defaultValues; | |
| for (var i = 0; i < keys.length; i++) { | |
| var propName = keys[i]; | |
| indices[propName] = i; | |
| if (RecordTypePrototype[propName]) { | |
| /* eslint-disable no-console */ | |
| typeof console === 'object' && | |
| console.warn && | |
| console.warn( | |
| 'Cannot define ' + | |
| recordName(this) + | |
| ' with property "' + | |
| propName + | |
| '" since that property name is part of the Record API.' | |
| ); | |
| /* eslint-enable no-console */ | |
| } else { | |
| setProp(RecordTypePrototype, propName); | |
| } | |
| } | |
| } | |
| this.__ownerID = undefined; | |
| this._values = List().withMutations(function (l) { | |
| l.setSize(this$1$1._keys.length); | |
| KeyedCollection(values).forEach(function (v, k) { | |
| l.set(this$1$1._indices[k], v === this$1$1._defaultValues[k] ? undefined : v); | |
| }); | |
| }); | |
| return this; | |
| }; | |
| var RecordTypePrototype = (RecordType.prototype = | |
| Object.create(RecordPrototype)); | |
| RecordTypePrototype.constructor = RecordType; | |
| if (name) { | |
| RecordType.displayName = name; | |
| } | |
| return RecordType; | |
| }; | |
| Record.prototype.toString = function toString () { | |
| var str = recordName(this) + ' { '; | |
| var keys = this._keys; | |
| var k; | |
| for (var i = 0, l = keys.length; i !== l; i++) { | |
| k = keys[i]; | |
| str += (i ? ', ' : '') + k + ': ' + quoteString(this.get(k)); | |
| } | |
| return str + ' }'; | |
| }; | |
| Record.prototype.equals = function equals (other) { | |
| return ( | |
| this === other || | |
| (isRecord(other) && recordSeq(this).equals(recordSeq(other))) | |
| ); | |
| }; | |
| Record.prototype.hashCode = function hashCode () { | |
| return recordSeq(this).hashCode(); | |
| }; | |
| // @pragma Access | |
| Record.prototype.has = function has (k) { | |
| return this._indices.hasOwnProperty(k); | |
| }; | |
| Record.prototype.get = function get (k, notSetValue) { | |
| if (!this.has(k)) { | |
| return notSetValue; | |
| } | |
| var index = this._indices[k]; | |
| var value = this._values.get(index); | |
| return value === undefined ? this._defaultValues[k] : value; | |
| }; | |
| // @pragma Modification | |
| Record.prototype.set = function set (k, v) { | |
| if (this.has(k)) { | |
| var newValues = this._values.set( | |
| this._indices[k], | |
| v === this._defaultValues[k] ? undefined : v | |
| ); | |
| if (newValues !== this._values && !this.__ownerID) { | |
| return makeRecord(this, newValues); | |
| } | |
| } | |
| return this; | |
| }; | |
| Record.prototype.remove = function remove (k) { | |
| return this.set(k); | |
| }; | |
| Record.prototype.clear = function clear () { | |
| var newValues = this._values.clear().setSize(this._keys.length); | |
| return this.__ownerID ? this : makeRecord(this, newValues); | |
| }; | |
| Record.prototype.wasAltered = function wasAltered () { | |
| return this._values.wasAltered(); | |
| }; | |
| Record.prototype.toSeq = function toSeq () { | |
| return recordSeq(this); | |
| }; | |
| Record.prototype.toJS = function toJS$1 () { | |
| return toJS(this); | |
| }; | |
| Record.prototype.entries = function entries () { | |
| return this.__iterator(ITERATE_ENTRIES); | |
| }; | |
| Record.prototype.__iterator = function __iterator (type, reverse) { | |
| return recordSeq(this).__iterator(type, reverse); | |
| }; | |
| Record.prototype.__iterate = function __iterate (fn, reverse) { | |
| return recordSeq(this).__iterate(fn, reverse); | |
| }; | |
| Record.prototype.__ensureOwner = function __ensureOwner (ownerID) { | |
| if (ownerID === this.__ownerID) { | |
| return this; | |
| } | |
| var newValues = this._values.__ensureOwner(ownerID); | |
| if (!ownerID) { | |
| this.__ownerID = ownerID; | |
| this._values = newValues; | |
| return this; | |
| } | |
| return makeRecord(this, newValues, ownerID); | |
| }; | |
| Record.isRecord = isRecord; | |
| Record.getDescriptiveName = recordName; | |
| var RecordPrototype = Record.prototype; | |
| RecordPrototype[IS_RECORD_SYMBOL] = true; | |
| RecordPrototype[DELETE] = RecordPrototype.remove; | |
| RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn; | |
| RecordPrototype.getIn = getIn; | |
| RecordPrototype.hasIn = CollectionPrototype.hasIn; | |
| RecordPrototype.merge = merge$1; | |
| RecordPrototype.mergeWith = mergeWith$1; | |
| RecordPrototype.mergeIn = mergeIn; | |
| RecordPrototype.mergeDeep = mergeDeep; | |
| RecordPrototype.mergeDeepWith = mergeDeepWith; | |
| RecordPrototype.mergeDeepIn = mergeDeepIn; | |
| RecordPrototype.setIn = setIn; | |
| RecordPrototype.update = update; | |
| RecordPrototype.updateIn = updateIn; | |
| RecordPrototype.withMutations = withMutations; | |
| RecordPrototype.asMutable = asMutable; | |
| RecordPrototype.asImmutable = asImmutable; | |
| RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries; | |
| RecordPrototype.toJSON = RecordPrototype.toObject = | |
| CollectionPrototype.toObject; | |
| RecordPrototype.inspect = RecordPrototype.toSource = function () { | |
| return this.toString(); | |
| }; | |
| function makeRecord(likeRecord, values, ownerID) { | |
| var record = Object.create(Object.getPrototypeOf(likeRecord)); | |
| record._values = values; | |
| record.__ownerID = ownerID; | |
| return record; | |
| } | |
| function recordName(record) { | |
| return record.constructor.displayName || record.constructor.name || 'Record'; | |
| } | |
| function recordSeq(record) { | |
| return keyedSeqFromValue(record._keys.map(function (k) { return [k, record.get(k)]; })); | |
| } | |
| function setProp(prototype, name) { | |
| try { | |
| Object.defineProperty(prototype, name, { | |
| get: function () { | |
| return this.get(name); | |
| }, | |
| set: function (value) { | |
| invariant(this.__ownerID, 'Cannot set on an immutable record.'); | |
| this.set(name, value); | |
| }, | |
| }); | |
| } catch (error) { | |
| // Object.defineProperty failed. Probably IE8. | |
| } | |
| } | |
| /** | |
| * Returns a lazy Seq of `value` repeated `times` times. When `times` is | |
| * undefined, returns an infinite sequence of `value`. | |
| */ | |
| var Repeat = /*@__PURE__*/(function (IndexedSeq) { | |
| function Repeat(value, times) { | |
| if (!(this instanceof Repeat)) { | |
| return new Repeat(value, times); | |
| } | |
| this._value = value; | |
| this.size = times === undefined ? Infinity : Math.max(0, times); | |
| if (this.size === 0) { | |
| if (EMPTY_REPEAT) { | |
| return EMPTY_REPEAT; | |
| } | |
| EMPTY_REPEAT = this; | |
| } | |
| } | |
| if ( IndexedSeq ) Repeat.__proto__ = IndexedSeq; | |
| Repeat.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); | |
| Repeat.prototype.constructor = Repeat; | |
| Repeat.prototype.toString = function toString () { | |
| if (this.size === 0) { | |
| return 'Repeat []'; | |
| } | |
| return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]'; | |
| }; | |
| Repeat.prototype.get = function get (index, notSetValue) { | |
| return this.has(index) ? this._value : notSetValue; | |
| }; | |
| Repeat.prototype.includes = function includes (searchValue) { | |
| return is(this._value, searchValue); | |
| }; | |
| Repeat.prototype.slice = function slice (begin, end) { | |
| var size = this.size; | |
| return wholeSlice(begin, end, size) | |
| ? this | |
| : new Repeat( | |
| this._value, | |
| resolveEnd(end, size) - resolveBegin(begin, size) | |
| ); | |
| }; | |
| Repeat.prototype.reverse = function reverse () { | |
| return this; | |
| }; | |
| Repeat.prototype.indexOf = function indexOf (searchValue) { | |
| if (is(this._value, searchValue)) { | |
| return 0; | |
| } | |
| return -1; | |
| }; | |
| Repeat.prototype.lastIndexOf = function lastIndexOf (searchValue) { | |
| if (is(this._value, searchValue)) { | |
| return this.size; | |
| } | |
| return -1; | |
| }; | |
| Repeat.prototype.__iterate = function __iterate (fn, reverse) { | |
| var size = this.size; | |
| var i = 0; | |
| while (i !== size) { | |
| if (fn(this._value, reverse ? size - ++i : i++, this) === false) { | |
| break; | |
| } | |
| } | |
| return i; | |
| }; | |
| Repeat.prototype.__iterator = function __iterator (type, reverse) { | |
| var this$1$1 = this; | |
| var size = this.size; | |
| var i = 0; | |
| return new Iterator(function () { return i === size | |
| ? iteratorDone() | |
| : iteratorValue(type, reverse ? size - ++i : i++, this$1$1._value); } | |
| ); | |
| }; | |
| Repeat.prototype.equals = function equals (other) { | |
| return other instanceof Repeat | |
| ? is(this._value, other._value) | |
| : deepEqual(other); | |
| }; | |
| return Repeat; | |
| }(IndexedSeq)); | |
| var EMPTY_REPEAT; | |
| function fromJS(value, converter) { | |
| return fromJSWith( | |
| [], | |
| converter || defaultConverter, | |
| value, | |
| '', | |
| converter && converter.length > 2 ? [] : undefined, | |
| { '': value } | |
| ); | |
| } | |
| function fromJSWith(stack, converter, value, key, keyPath, parentValue) { | |
| if ( | |
| typeof value !== 'string' && | |
| !isImmutable(value) && | |
| (isArrayLike(value) || hasIterator(value) || isPlainObject(value)) | |
| ) { | |
| if (~stack.indexOf(value)) { | |
| throw new TypeError('Cannot convert circular structure to Immutable'); | |
| } | |
| stack.push(value); | |
| keyPath && key !== '' && keyPath.push(key); | |
| var converted = converter.call( | |
| parentValue, | |
| key, | |
| Seq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); } | |
| ), | |
| keyPath && keyPath.slice() | |
| ); | |
| stack.pop(); | |
| keyPath && keyPath.pop(); | |
| return converted; | |
| } | |
| return value; | |
| } | |
| function defaultConverter(k, v) { | |
| // Effectively the opposite of "Collection.toSeq()" | |
| return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); | |
| } | |
| var version = "4.3.0"; | |
| var Immutable = { | |
| version: version, | |
| Collection: Collection, | |
| // Note: Iterable is deprecated | |
| Iterable: Collection, | |
| Seq: Seq, | |
| Map: Map, | |
| OrderedMap: OrderedMap, | |
| List: List, | |
| Stack: Stack, | |
| Set: Set, | |
| OrderedSet: OrderedSet, | |
| PairSorting: PairSorting, | |
| Record: Record, | |
| Range: Range, | |
| Repeat: Repeat, | |
| is: is, | |
| fromJS: fromJS, | |
| hash: hash, | |
| isImmutable: isImmutable, | |
| isCollection: isCollection, | |
| isKeyed: isKeyed, | |
| isIndexed: isIndexed, | |
| isAssociative: isAssociative, | |
| isOrdered: isOrdered, | |
| isValueObject: isValueObject, | |
| isPlainObject: isPlainObject, | |
| isSeq: isSeq, | |
| isList: isList, | |
| isMap: isMap, | |
| isOrderedMap: isOrderedMap, | |
| isStack: isStack, | |
| isSet: isSet, | |
| isOrderedSet: isOrderedSet, | |
| isRecord: isRecord, | |
| get: get, | |
| getIn: getIn$1, | |
| has: has, | |
| hasIn: hasIn$1, | |
| merge: merge, | |
| mergeDeep: mergeDeep$1, | |
| mergeWith: mergeWith, | |
| mergeDeepWith: mergeDeepWith$1, | |
| remove: remove, | |
| removeIn: removeIn, | |
| set: set, | |
| setIn: setIn$1, | |
| update: update$1, | |
| updateIn: updateIn$1, | |
| }; | |
| // Note: Iterable is deprecated | |
| var Iterable = Collection; | |
| /* harmony default export */ __webpack_exports__["default"] = (Immutable); | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_DataView.js": | |
| /*!******************************************!*\ | |
| !*** ./node_modules/lodash/_DataView.js ***! | |
| \******************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var getNative = __webpack_require__(/*! ./_getNative */ "./node_modules/lodash/_getNative.js"), | |
| root = __webpack_require__(/*! ./_root */ "./node_modules/lodash/_root.js"); | |
| /* Built-in method references that are verified to be native. */ | |
| var DataView = getNative(root, 'DataView'); | |
| module.exports = DataView; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_Hash.js": | |
| /*!**************************************!*\ | |
| !*** ./node_modules/lodash/_Hash.js ***! | |
| \**************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var hashClear = __webpack_require__(/*! ./_hashClear */ "./node_modules/lodash/_hashClear.js"), | |
| hashDelete = __webpack_require__(/*! ./_hashDelete */ "./node_modules/lodash/_hashDelete.js"), | |
| hashGet = __webpack_require__(/*! ./_hashGet */ "./node_modules/lodash/_hashGet.js"), | |
| hashHas = __webpack_require__(/*! ./_hashHas */ "./node_modules/lodash/_hashHas.js"), | |
| hashSet = __webpack_require__(/*! ./_hashSet */ "./node_modules/lodash/_hashSet.js"); | |
| /** | |
| * Creates a hash object. | |
| * | |
| * @private | |
| * @constructor | |
| * @param {Array} [entries] The key-value pairs to cache. | |
| */ | |
| function Hash(entries) { | |
| var index = -1, | |
| length = entries == null ? 0 : entries.length; | |
| this.clear(); | |
| while (++index < length) { | |
| var entry = entries[index]; | |
| this.set(entry[0], entry[1]); | |
| } | |
| } | |
| // Add methods to `Hash`. | |
| Hash.prototype.clear = hashClear; | |
| Hash.prototype['delete'] = hashDelete; | |
| Hash.prototype.get = hashGet; | |
| Hash.prototype.has = hashHas; | |
| Hash.prototype.set = hashSet; | |
| module.exports = Hash; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_ListCache.js": | |
| /*!*******************************************!*\ | |
| !*** ./node_modules/lodash/_ListCache.js ***! | |
| \*******************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var listCacheClear = __webpack_require__(/*! ./_listCacheClear */ "./node_modules/lodash/_listCacheClear.js"), | |
| listCacheDelete = __webpack_require__(/*! ./_listCacheDelete */ "./node_modules/lodash/_listCacheDelete.js"), | |
| listCacheGet = __webpack_require__(/*! ./_listCacheGet */ "./node_modules/lodash/_listCacheGet.js"), | |
| listCacheHas = __webpack_require__(/*! ./_listCacheHas */ "./node_modules/lodash/_listCacheHas.js"), | |
| listCacheSet = __webpack_require__(/*! ./_listCacheSet */ "./node_modules/lodash/_listCacheSet.js"); | |
| /** | |
| * Creates an list cache object. | |
| * | |
| * @private | |
| * @constructor | |
| * @param {Array} [entries] The key-value pairs to cache. | |
| */ | |
| function ListCache(entries) { | |
| var index = -1, | |
| length = entries == null ? 0 : entries.length; | |
| this.clear(); | |
| while (++index < length) { | |
| var entry = entries[index]; | |
| this.set(entry[0], entry[1]); | |
| } | |
| } | |
| // Add methods to `ListCache`. | |
| ListCache.prototype.clear = listCacheClear; | |
| ListCache.prototype['delete'] = listCacheDelete; | |
| ListCache.prototype.get = listCacheGet; | |
| ListCache.prototype.has = listCacheHas; | |
| ListCache.prototype.set = listCacheSet; | |
| module.exports = ListCache; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_Map.js": | |
| /*!*************************************!*\ | |
| !*** ./node_modules/lodash/_Map.js ***! | |
| \*************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var getNative = __webpack_require__(/*! ./_getNative */ "./node_modules/lodash/_getNative.js"), | |
| root = __webpack_require__(/*! ./_root */ "./node_modules/lodash/_root.js"); | |
| /* Built-in method references that are verified to be native. */ | |
| var Map = getNative(root, 'Map'); | |
| module.exports = Map; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_MapCache.js": | |
| /*!******************************************!*\ | |
| !*** ./node_modules/lodash/_MapCache.js ***! | |
| \******************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var mapCacheClear = __webpack_require__(/*! ./_mapCacheClear */ "./node_modules/lodash/_mapCacheClear.js"), | |
| mapCacheDelete = __webpack_require__(/*! ./_mapCacheDelete */ "./node_modules/lodash/_mapCacheDelete.js"), | |
| mapCacheGet = __webpack_require__(/*! ./_mapCacheGet */ "./node_modules/lodash/_mapCacheGet.js"), | |
| mapCacheHas = __webpack_require__(/*! ./_mapCacheHas */ "./node_modules/lodash/_mapCacheHas.js"), | |
| mapCacheSet = __webpack_require__(/*! ./_mapCacheSet */ "./node_modules/lodash/_mapCacheSet.js"); | |
| /** | |
| * Creates a map cache object to store key-value pairs. | |
| * | |
| * @private | |
| * @constructor | |
| * @param {Array} [entries] The key-value pairs to cache. | |
| */ | |
| function MapCache(entries) { | |
| var index = -1, | |
| length = entries == null ? 0 : entries.length; | |
| this.clear(); | |
| while (++index < length) { | |
| var entry = entries[index]; | |
| this.set(entry[0], entry[1]); | |
| } | |
| } | |
| // Add methods to `MapCache`. | |
| MapCache.prototype.clear = mapCacheClear; | |
| MapCache.prototype['delete'] = mapCacheDelete; | |
| MapCache.prototype.get = mapCacheGet; | |
| MapCache.prototype.has = mapCacheHas; | |
| MapCache.prototype.set = mapCacheSet; | |
| module.exports = MapCache; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_Promise.js": | |
| /*!*****************************************!*\ | |
| !*** ./node_modules/lodash/_Promise.js ***! | |
| \*****************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var getNative = __webpack_require__(/*! ./_getNative */ "./node_modules/lodash/_getNative.js"), | |
| root = __webpack_require__(/*! ./_root */ "./node_modules/lodash/_root.js"); | |
| /* Built-in method references that are verified to be native. */ | |
| var Promise = getNative(root, 'Promise'); | |
| module.exports = Promise; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_Set.js": | |
| /*!*************************************!*\ | |
| !*** ./node_modules/lodash/_Set.js ***! | |
| \*************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var getNative = __webpack_require__(/*! ./_getNative */ "./node_modules/lodash/_getNative.js"), | |
| root = __webpack_require__(/*! ./_root */ "./node_modules/lodash/_root.js"); | |
| /* Built-in method references that are verified to be native. */ | |
| var Set = getNative(root, 'Set'); | |
| module.exports = Set; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_SetCache.js": | |
| /*!******************************************!*\ | |
| !*** ./node_modules/lodash/_SetCache.js ***! | |
| \******************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var MapCache = __webpack_require__(/*! ./_MapCache */ "./node_modules/lodash/_MapCache.js"), | |
| setCacheAdd = __webpack_require__(/*! ./_setCacheAdd */ "./node_modules/lodash/_setCacheAdd.js"), | |
| setCacheHas = __webpack_require__(/*! ./_setCacheHas */ "./node_modules/lodash/_setCacheHas.js"); | |
| /** | |
| * | |
| * Creates an array cache object to store unique values. | |
| * | |
| * @private | |
| * @constructor | |
| * @param {Array} [values] The values to cache. | |
| */ | |
| function SetCache(values) { | |
| var index = -1, | |
| length = values == null ? 0 : values.length; | |
| this.__data__ = new MapCache; | |
| while (++index < length) { | |
| this.add(values[index]); | |
| } | |
| } | |
| // Add methods to `SetCache`. | |
| SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; | |
| SetCache.prototype.has = setCacheHas; | |
| module.exports = SetCache; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_Stack.js": | |
| /*!***************************************!*\ | |
| !*** ./node_modules/lodash/_Stack.js ***! | |
| \***************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var ListCache = __webpack_require__(/*! ./_ListCache */ "./node_modules/lodash/_ListCache.js"), | |
| stackClear = __webpack_require__(/*! ./_stackClear */ "./node_modules/lodash/_stackClear.js"), | |
| stackDelete = __webpack_require__(/*! ./_stackDelete */ "./node_modules/lodash/_stackDelete.js"), | |
| stackGet = __webpack_require__(/*! ./_stackGet */ "./node_modules/lodash/_stackGet.js"), | |
| stackHas = __webpack_require__(/*! ./_stackHas */ "./node_modules/lodash/_stackHas.js"), | |
| stackSet = __webpack_require__(/*! ./_stackSet */ "./node_modules/lodash/_stackSet.js"); | |
| /** | |
| * Creates a stack cache object to store key-value pairs. | |
| * | |
| * @private | |
| * @constructor | |
| * @param {Array} [entries] The key-value pairs to cache. | |
| */ | |
| function Stack(entries) { | |
| var data = this.__data__ = new ListCache(entries); | |
| this.size = data.size; | |
| } | |
| // Add methods to `Stack`. | |
| Stack.prototype.clear = stackClear; | |
| Stack.prototype['delete'] = stackDelete; | |
| Stack.prototype.get = stackGet; | |
| Stack.prototype.has = stackHas; | |
| Stack.prototype.set = stackSet; | |
| module.exports = Stack; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_Symbol.js": | |
| /*!****************************************!*\ | |
| !*** ./node_modules/lodash/_Symbol.js ***! | |
| \****************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var root = __webpack_require__(/*! ./_root */ "./node_modules/lodash/_root.js"); | |
| /** Built-in value references. */ | |
| var Symbol = root.Symbol; | |
| module.exports = Symbol; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_Uint8Array.js": | |
| /*!********************************************!*\ | |
| !*** ./node_modules/lodash/_Uint8Array.js ***! | |
| \********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var root = __webpack_require__(/*! ./_root */ "./node_modules/lodash/_root.js"); | |
| /** Built-in value references. */ | |
| var Uint8Array = root.Uint8Array; | |
| module.exports = Uint8Array; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_WeakMap.js": | |
| /*!*****************************************!*\ | |
| !*** ./node_modules/lodash/_WeakMap.js ***! | |
| \*****************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var getNative = __webpack_require__(/*! ./_getNative */ "./node_modules/lodash/_getNative.js"), | |
| root = __webpack_require__(/*! ./_root */ "./node_modules/lodash/_root.js"); | |
| /* Built-in method references that are verified to be native. */ | |
| var WeakMap = getNative(root, 'WeakMap'); | |
| module.exports = WeakMap; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_arrayFilter.js": | |
| /*!*********************************************!*\ | |
| !*** ./node_modules/lodash/_arrayFilter.js ***! | |
| \*********************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * A specialized version of `_.filter` for arrays without support for | |
| * iteratee shorthands. | |
| * | |
| * @private | |
| * @param {Array} [array] The array to iterate over. | |
| * @param {Function} predicate The function invoked per iteration. | |
| * @returns {Array} Returns the new filtered array. | |
| */ | |
| function arrayFilter(array, predicate) { | |
| var index = -1, | |
| length = array == null ? 0 : array.length, | |
| resIndex = 0, | |
| result = []; | |
| while (++index < length) { | |
| var value = array[index]; | |
| if (predicate(value, index, array)) { | |
| result[resIndex++] = value; | |
| } | |
| } | |
| return result; | |
| } | |
| module.exports = arrayFilter; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_arrayLikeKeys.js": | |
| /*!***********************************************!*\ | |
| !*** ./node_modules/lodash/_arrayLikeKeys.js ***! | |
| \***********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseTimes = __webpack_require__(/*! ./_baseTimes */ "./node_modules/lodash/_baseTimes.js"), | |
| isArguments = __webpack_require__(/*! ./isArguments */ "./node_modules/lodash/isArguments.js"), | |
| isArray = __webpack_require__(/*! ./isArray */ "./node_modules/lodash/isArray.js"), | |
| isBuffer = __webpack_require__(/*! ./isBuffer */ "./node_modules/lodash/isBuffer.js"), | |
| isIndex = __webpack_require__(/*! ./_isIndex */ "./node_modules/lodash/_isIndex.js"), | |
| isTypedArray = __webpack_require__(/*! ./isTypedArray */ "./node_modules/lodash/isTypedArray.js"); | |
| /** Used for built-in method references. */ | |
| var objectProto = Object.prototype; | |
| /** Used to check objects for own properties. */ | |
| var hasOwnProperty = objectProto.hasOwnProperty; | |
| /** | |
| * Creates an array of the enumerable property names of the array-like `value`. | |
| * | |
| * @private | |
| * @param {*} value The value to query. | |
| * @param {boolean} inherited Specify returning inherited property names. | |
| * @returns {Array} Returns the array of property names. | |
| */ | |
| function arrayLikeKeys(value, inherited) { | |
| var isArr = isArray(value), | |
| isArg = !isArr && isArguments(value), | |
| isBuff = !isArr && !isArg && isBuffer(value), | |
| isType = !isArr && !isArg && !isBuff && isTypedArray(value), | |
| skipIndexes = isArr || isArg || isBuff || isType, | |
| result = skipIndexes ? baseTimes(value.length, String) : [], | |
| length = result.length; | |
| for (var key in value) { | |
| if ((inherited || hasOwnProperty.call(value, key)) && | |
| !(skipIndexes && ( | |
| // Safari 9 has enumerable `arguments.length` in strict mode. | |
| key == 'length' || | |
| // Node.js 0.10 has enumerable non-index properties on buffers. | |
| (isBuff && (key == 'offset' || key == 'parent')) || | |
| // PhantomJS 2 has enumerable non-index properties on typed arrays. | |
| (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || | |
| // Skip index properties. | |
| isIndex(key, length) | |
| ))) { | |
| result.push(key); | |
| } | |
| } | |
| return result; | |
| } | |
| module.exports = arrayLikeKeys; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_arrayMap.js": | |
| /*!******************************************!*\ | |
| !*** ./node_modules/lodash/_arrayMap.js ***! | |
| \******************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * A specialized version of `_.map` for arrays without support for iteratee | |
| * shorthands. | |
| * | |
| * @private | |
| * @param {Array} [array] The array to iterate over. | |
| * @param {Function} iteratee The function invoked per iteration. | |
| * @returns {Array} Returns the new mapped array. | |
| */ | |
| function arrayMap(array, iteratee) { | |
| var index = -1, | |
| length = array == null ? 0 : array.length, | |
| result = Array(length); | |
| while (++index < length) { | |
| result[index] = iteratee(array[index], index, array); | |
| } | |
| return result; | |
| } | |
| module.exports = arrayMap; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_arrayPush.js": | |
| /*!*******************************************!*\ | |
| !*** ./node_modules/lodash/_arrayPush.js ***! | |
| \*******************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * Appends the elements of `values` to `array`. | |
| * | |
| * @private | |
| * @param {Array} array The array to modify. | |
| * @param {Array} values The values to append. | |
| * @returns {Array} Returns `array`. | |
| */ | |
| function arrayPush(array, values) { | |
| var index = -1, | |
| length = values.length, | |
| offset = array.length; | |
| while (++index < length) { | |
| array[offset + index] = values[index]; | |
| } | |
| return array; | |
| } | |
| module.exports = arrayPush; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_arraySome.js": | |
| /*!*******************************************!*\ | |
| !*** ./node_modules/lodash/_arraySome.js ***! | |
| \*******************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * A specialized version of `_.some` for arrays without support for iteratee | |
| * shorthands. | |
| * | |
| * @private | |
| * @param {Array} [array] The array to iterate over. | |
| * @param {Function} predicate The function invoked per iteration. | |
| * @returns {boolean} Returns `true` if any element passes the predicate check, | |
| * else `false`. | |
| */ | |
| function arraySome(array, predicate) { | |
| var index = -1, | |
| length = array == null ? 0 : array.length; | |
| while (++index < length) { | |
| if (predicate(array[index], index, array)) { | |
| return true; | |
| } | |
| } | |
| return false; | |
| } | |
| module.exports = arraySome; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_assocIndexOf.js": | |
| /*!**********************************************!*\ | |
| !*** ./node_modules/lodash/_assocIndexOf.js ***! | |
| \**********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var eq = __webpack_require__(/*! ./eq */ "./node_modules/lodash/eq.js"); | |
| /** | |
| * Gets the index at which the `key` is found in `array` of key-value pairs. | |
| * | |
| * @private | |
| * @param {Array} array The array to inspect. | |
| * @param {*} key The key to search for. | |
| * @returns {number} Returns the index of the matched value, else `-1`. | |
| */ | |
| function assocIndexOf(array, key) { | |
| var length = array.length; | |
| while (length--) { | |
| if (eq(array[length][0], key)) { | |
| return length; | |
| } | |
| } | |
| return -1; | |
| } | |
| module.exports = assocIndexOf; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseAssignValue.js": | |
| /*!*************************************************!*\ | |
| !*** ./node_modules/lodash/_baseAssignValue.js ***! | |
| \*************************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var defineProperty = __webpack_require__(/*! ./_defineProperty */ "./node_modules/lodash/_defineProperty.js"); | |
| /** | |
| * The base implementation of `assignValue` and `assignMergeValue` without | |
| * value checks. | |
| * | |
| * @private | |
| * @param {Object} object The object to modify. | |
| * @param {string} key The key of the property to assign. | |
| * @param {*} value The value to assign. | |
| */ | |
| function baseAssignValue(object, key, value) { | |
| if (key == '__proto__' && defineProperty) { | |
| defineProperty(object, key, { | |
| 'configurable': true, | |
| 'enumerable': true, | |
| 'value': value, | |
| 'writable': true | |
| }); | |
| } else { | |
| object[key] = value; | |
| } | |
| } | |
| module.exports = baseAssignValue; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseFor.js": | |
| /*!*****************************************!*\ | |
| !*** ./node_modules/lodash/_baseFor.js ***! | |
| \*****************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var createBaseFor = __webpack_require__(/*! ./_createBaseFor */ "./node_modules/lodash/_createBaseFor.js"); | |
| /** | |
| * The base implementation of `baseForOwn` which iterates over `object` | |
| * properties returned by `keysFunc` and invokes `iteratee` for each property. | |
| * Iteratee functions may exit iteration early by explicitly returning `false`. | |
| * | |
| * @private | |
| * @param {Object} object The object to iterate over. | |
| * @param {Function} iteratee The function invoked per iteration. | |
| * @param {Function} keysFunc The function to get the keys of `object`. | |
| * @returns {Object} Returns `object`. | |
| */ | |
| var baseFor = createBaseFor(); | |
| module.exports = baseFor; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseForOwn.js": | |
| /*!********************************************!*\ | |
| !*** ./node_modules/lodash/_baseForOwn.js ***! | |
| \********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseFor = __webpack_require__(/*! ./_baseFor */ "./node_modules/lodash/_baseFor.js"), | |
| keys = __webpack_require__(/*! ./keys */ "./node_modules/lodash/keys.js"); | |
| /** | |
| * The base implementation of `_.forOwn` without support for iteratee shorthands. | |
| * | |
| * @private | |
| * @param {Object} object The object to iterate over. | |
| * @param {Function} iteratee The function invoked per iteration. | |
| * @returns {Object} Returns `object`. | |
| */ | |
| function baseForOwn(object, iteratee) { | |
| return object && baseFor(object, iteratee, keys); | |
| } | |
| module.exports = baseForOwn; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseGet.js": | |
| /*!*****************************************!*\ | |
| !*** ./node_modules/lodash/_baseGet.js ***! | |
| \*****************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var castPath = __webpack_require__(/*! ./_castPath */ "./node_modules/lodash/_castPath.js"), | |
| toKey = __webpack_require__(/*! ./_toKey */ "./node_modules/lodash/_toKey.js"); | |
| /** | |
| * The base implementation of `_.get` without support for default values. | |
| * | |
| * @private | |
| * @param {Object} object The object to query. | |
| * @param {Array|string} path The path of the property to get. | |
| * @returns {*} Returns the resolved value. | |
| */ | |
| function baseGet(object, path) { | |
| path = castPath(path, object); | |
| var index = 0, | |
| length = path.length; | |
| while (object != null && index < length) { | |
| object = object[toKey(path[index++])]; | |
| } | |
| return (index && index == length) ? object : undefined; | |
| } | |
| module.exports = baseGet; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseGetAllKeys.js": | |
| /*!************************************************!*\ | |
| !*** ./node_modules/lodash/_baseGetAllKeys.js ***! | |
| \************************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var arrayPush = __webpack_require__(/*! ./_arrayPush */ "./node_modules/lodash/_arrayPush.js"), | |
| isArray = __webpack_require__(/*! ./isArray */ "./node_modules/lodash/isArray.js"); | |
| /** | |
| * The base implementation of `getAllKeys` and `getAllKeysIn` which uses | |
| * `keysFunc` and `symbolsFunc` to get the enumerable property names and | |
| * symbols of `object`. | |
| * | |
| * @private | |
| * @param {Object} object The object to query. | |
| * @param {Function} keysFunc The function to get the keys of `object`. | |
| * @param {Function} symbolsFunc The function to get the symbols of `object`. | |
| * @returns {Array} Returns the array of property names and symbols. | |
| */ | |
| function baseGetAllKeys(object, keysFunc, symbolsFunc) { | |
| var result = keysFunc(object); | |
| return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); | |
| } | |
| module.exports = baseGetAllKeys; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseGetTag.js": | |
| /*!********************************************!*\ | |
| !*** ./node_modules/lodash/_baseGetTag.js ***! | |
| \********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var Symbol = __webpack_require__(/*! ./_Symbol */ "./node_modules/lodash/_Symbol.js"), | |
| getRawTag = __webpack_require__(/*! ./_getRawTag */ "./node_modules/lodash/_getRawTag.js"), | |
| objectToString = __webpack_require__(/*! ./_objectToString */ "./node_modules/lodash/_objectToString.js"); | |
| /** `Object#toString` result references. */ | |
| var nullTag = '[object Null]', | |
| undefinedTag = '[object Undefined]'; | |
| /** Built-in value references. */ | |
| var symToStringTag = Symbol ? Symbol.toStringTag : undefined; | |
| /** | |
| * The base implementation of `getTag` without fallbacks for buggy environments. | |
| * | |
| * @private | |
| * @param {*} value The value to query. | |
| * @returns {string} Returns the `toStringTag`. | |
| */ | |
| function baseGetTag(value) { | |
| if (value == null) { | |
| return value === undefined ? undefinedTag : nullTag; | |
| } | |
| return (symToStringTag && symToStringTag in Object(value)) | |
| ? getRawTag(value) | |
| : objectToString(value); | |
| } | |
| module.exports = baseGetTag; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseHasIn.js": | |
| /*!*******************************************!*\ | |
| !*** ./node_modules/lodash/_baseHasIn.js ***! | |
| \*******************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * The base implementation of `_.hasIn` without support for deep paths. | |
| * | |
| * @private | |
| * @param {Object} [object] The object to query. | |
| * @param {Array|string} key The key to check. | |
| * @returns {boolean} Returns `true` if `key` exists, else `false`. | |
| */ | |
| function baseHasIn(object, key) { | |
| return object != null && key in Object(object); | |
| } | |
| module.exports = baseHasIn; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseIsArguments.js": | |
| /*!*************************************************!*\ | |
| !*** ./node_modules/lodash/_baseIsArguments.js ***! | |
| \*************************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseGetTag = __webpack_require__(/*! ./_baseGetTag */ "./node_modules/lodash/_baseGetTag.js"), | |
| isObjectLike = __webpack_require__(/*! ./isObjectLike */ "./node_modules/lodash/isObjectLike.js"); | |
| /** `Object#toString` result references. */ | |
| var argsTag = '[object Arguments]'; | |
| /** | |
| * The base implementation of `_.isArguments`. | |
| * | |
| * @private | |
| * @param {*} value The value to check. | |
| * @returns {boolean} Returns `true` if `value` is an `arguments` object, | |
| */ | |
| function baseIsArguments(value) { | |
| return isObjectLike(value) && baseGetTag(value) == argsTag; | |
| } | |
| module.exports = baseIsArguments; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseIsEqual.js": | |
| /*!*********************************************!*\ | |
| !*** ./node_modules/lodash/_baseIsEqual.js ***! | |
| \*********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseIsEqualDeep = __webpack_require__(/*! ./_baseIsEqualDeep */ "./node_modules/lodash/_baseIsEqualDeep.js"), | |
| isObjectLike = __webpack_require__(/*! ./isObjectLike */ "./node_modules/lodash/isObjectLike.js"); | |
| /** | |
| * The base implementation of `_.isEqual` which supports partial comparisons | |
| * and tracks traversed objects. | |
| * | |
| * @private | |
| * @param {*} value The value to compare. | |
| * @param {*} other The other value to compare. | |
| * @param {boolean} bitmask The bitmask flags. | |
| * 1 - Unordered comparison | |
| * 2 - Partial comparison | |
| * @param {Function} [customizer] The function to customize comparisons. | |
| * @param {Object} [stack] Tracks traversed `value` and `other` objects. | |
| * @returns {boolean} Returns `true` if the values are equivalent, else `false`. | |
| */ | |
| function baseIsEqual(value, other, bitmask, customizer, stack) { | |
| if (value === other) { | |
| return true; | |
| } | |
| if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { | |
| return value !== value && other !== other; | |
| } | |
| return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); | |
| } | |
| module.exports = baseIsEqual; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseIsEqualDeep.js": | |
| /*!*************************************************!*\ | |
| !*** ./node_modules/lodash/_baseIsEqualDeep.js ***! | |
| \*************************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var Stack = __webpack_require__(/*! ./_Stack */ "./node_modules/lodash/_Stack.js"), | |
| equalArrays = __webpack_require__(/*! ./_equalArrays */ "./node_modules/lodash/_equalArrays.js"), | |
| equalByTag = __webpack_require__(/*! ./_equalByTag */ "./node_modules/lodash/_equalByTag.js"), | |
| equalObjects = __webpack_require__(/*! ./_equalObjects */ "./node_modules/lodash/_equalObjects.js"), | |
| getTag = __webpack_require__(/*! ./_getTag */ "./node_modules/lodash/_getTag.js"), | |
| isArray = __webpack_require__(/*! ./isArray */ "./node_modules/lodash/isArray.js"), | |
| isBuffer = __webpack_require__(/*! ./isBuffer */ "./node_modules/lodash/isBuffer.js"), | |
| isTypedArray = __webpack_require__(/*! ./isTypedArray */ "./node_modules/lodash/isTypedArray.js"); | |
| /** Used to compose bitmasks for value comparisons. */ | |
| var COMPARE_PARTIAL_FLAG = 1; | |
| /** `Object#toString` result references. */ | |
| var argsTag = '[object Arguments]', | |
| arrayTag = '[object Array]', | |
| objectTag = '[object Object]'; | |
| /** Used for built-in method references. */ | |
| var objectProto = Object.prototype; | |
| /** Used to check objects for own properties. */ | |
| var hasOwnProperty = objectProto.hasOwnProperty; | |
| /** | |
| * A specialized version of `baseIsEqual` for arrays and objects which performs | |
| * deep comparisons and tracks traversed objects enabling objects with circular | |
| * references to be compared. | |
| * | |
| * @private | |
| * @param {Object} object The object to compare. | |
| * @param {Object} other The other object to compare. | |
| * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. | |
| * @param {Function} customizer The function to customize comparisons. | |
| * @param {Function} equalFunc The function to determine equivalents of values. | |
| * @param {Object} [stack] Tracks traversed `object` and `other` objects. | |
| * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. | |
| */ | |
| function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { | |
| var objIsArr = isArray(object), | |
| othIsArr = isArray(other), | |
| objTag = objIsArr ? arrayTag : getTag(object), | |
| othTag = othIsArr ? arrayTag : getTag(other); | |
| objTag = objTag == argsTag ? objectTag : objTag; | |
| othTag = othTag == argsTag ? objectTag : othTag; | |
| var objIsObj = objTag == objectTag, | |
| othIsObj = othTag == objectTag, | |
| isSameTag = objTag == othTag; | |
| if (isSameTag && isBuffer(object)) { | |
| if (!isBuffer(other)) { | |
| return false; | |
| } | |
| objIsArr = true; | |
| objIsObj = false; | |
| } | |
| if (isSameTag && !objIsObj) { | |
| stack || (stack = new Stack); | |
| return (objIsArr || isTypedArray(object)) | |
| ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) | |
| : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); | |
| } | |
| if (!(bitmask & COMPARE_PARTIAL_FLAG)) { | |
| var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), | |
| othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); | |
| if (objIsWrapped || othIsWrapped) { | |
| var objUnwrapped = objIsWrapped ? object.value() : object, | |
| othUnwrapped = othIsWrapped ? other.value() : other; | |
| stack || (stack = new Stack); | |
| return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); | |
| } | |
| } | |
| if (!isSameTag) { | |
| return false; | |
| } | |
| stack || (stack = new Stack); | |
| return equalObjects(object, other, bitmask, customizer, equalFunc, stack); | |
| } | |
| module.exports = baseIsEqualDeep; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseIsMatch.js": | |
| /*!*********************************************!*\ | |
| !*** ./node_modules/lodash/_baseIsMatch.js ***! | |
| \*********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var Stack = __webpack_require__(/*! ./_Stack */ "./node_modules/lodash/_Stack.js"), | |
| baseIsEqual = __webpack_require__(/*! ./_baseIsEqual */ "./node_modules/lodash/_baseIsEqual.js"); | |
| /** Used to compose bitmasks for value comparisons. */ | |
| var COMPARE_PARTIAL_FLAG = 1, | |
| COMPARE_UNORDERED_FLAG = 2; | |
| /** | |
| * The base implementation of `_.isMatch` without support for iteratee shorthands. | |
| * | |
| * @private | |
| * @param {Object} object The object to inspect. | |
| * @param {Object} source The object of property values to match. | |
| * @param {Array} matchData The property names, values, and compare flags to match. | |
| * @param {Function} [customizer] The function to customize comparisons. | |
| * @returns {boolean} Returns `true` if `object` is a match, else `false`. | |
| */ | |
| function baseIsMatch(object, source, matchData, customizer) { | |
| var index = matchData.length, | |
| length = index, | |
| noCustomizer = !customizer; | |
| if (object == null) { | |
| return !length; | |
| } | |
| object = Object(object); | |
| while (index--) { | |
| var data = matchData[index]; | |
| if ((noCustomizer && data[2]) | |
| ? data[1] !== object[data[0]] | |
| : !(data[0] in object) | |
| ) { | |
| return false; | |
| } | |
| } | |
| while (++index < length) { | |
| data = matchData[index]; | |
| var key = data[0], | |
| objValue = object[key], | |
| srcValue = data[1]; | |
| if (noCustomizer && data[2]) { | |
| if (objValue === undefined && !(key in object)) { | |
| return false; | |
| } | |
| } else { | |
| var stack = new Stack; | |
| if (customizer) { | |
| var result = customizer(objValue, srcValue, key, object, source, stack); | |
| } | |
| if (!(result === undefined | |
| ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) | |
| : result | |
| )) { | |
| return false; | |
| } | |
| } | |
| } | |
| return true; | |
| } | |
| module.exports = baseIsMatch; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseIsNative.js": | |
| /*!**********************************************!*\ | |
| !*** ./node_modules/lodash/_baseIsNative.js ***! | |
| \**********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var isFunction = __webpack_require__(/*! ./isFunction */ "./node_modules/lodash/isFunction.js"), | |
| isMasked = __webpack_require__(/*! ./_isMasked */ "./node_modules/lodash/_isMasked.js"), | |
| isObject = __webpack_require__(/*! ./isObject */ "./node_modules/lodash/isObject.js"), | |
| toSource = __webpack_require__(/*! ./_toSource */ "./node_modules/lodash/_toSource.js"); | |
| /** | |
| * Used to match `RegExp` | |
| * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). | |
| */ | |
| var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; | |
| /** Used to detect host constructors (Safari). */ | |
| var reIsHostCtor = /^\[object .+?Constructor\]$/; | |
| /** Used for built-in method references. */ | |
| var funcProto = Function.prototype, | |
| objectProto = Object.prototype; | |
| /** Used to resolve the decompiled source of functions. */ | |
| var funcToString = funcProto.toString; | |
| /** Used to check objects for own properties. */ | |
| var hasOwnProperty = objectProto.hasOwnProperty; | |
| /** Used to detect if a method is native. */ | |
| var reIsNative = RegExp('^' + | |
| funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') | |
| .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' | |
| ); | |
| /** | |
| * The base implementation of `_.isNative` without bad shim checks. | |
| * | |
| * @private | |
| * @param {*} value The value to check. | |
| * @returns {boolean} Returns `true` if `value` is a native function, | |
| * else `false`. | |
| */ | |
| function baseIsNative(value) { | |
| if (!isObject(value) || isMasked(value)) { | |
| return false; | |
| } | |
| var pattern = isFunction(value) ? reIsNative : reIsHostCtor; | |
| return pattern.test(toSource(value)); | |
| } | |
| module.exports = baseIsNative; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseIsTypedArray.js": | |
| /*!**************************************************!*\ | |
| !*** ./node_modules/lodash/_baseIsTypedArray.js ***! | |
| \**************************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseGetTag = __webpack_require__(/*! ./_baseGetTag */ "./node_modules/lodash/_baseGetTag.js"), | |
| isLength = __webpack_require__(/*! ./isLength */ "./node_modules/lodash/isLength.js"), | |
| isObjectLike = __webpack_require__(/*! ./isObjectLike */ "./node_modules/lodash/isObjectLike.js"); | |
| /** `Object#toString` result references. */ | |
| var argsTag = '[object Arguments]', | |
| arrayTag = '[object Array]', | |
| boolTag = '[object Boolean]', | |
| dateTag = '[object Date]', | |
| errorTag = '[object Error]', | |
| funcTag = '[object Function]', | |
| mapTag = '[object Map]', | |
| numberTag = '[object Number]', | |
| objectTag = '[object Object]', | |
| regexpTag = '[object RegExp]', | |
| setTag = '[object Set]', | |
| stringTag = '[object String]', | |
| weakMapTag = '[object WeakMap]'; | |
| var arrayBufferTag = '[object ArrayBuffer]', | |
| dataViewTag = '[object DataView]', | |
| float32Tag = '[object Float32Array]', | |
| float64Tag = '[object Float64Array]', | |
| int8Tag = '[object Int8Array]', | |
| int16Tag = '[object Int16Array]', | |
| int32Tag = '[object Int32Array]', | |
| uint8Tag = '[object Uint8Array]', | |
| uint8ClampedTag = '[object Uint8ClampedArray]', | |
| uint16Tag = '[object Uint16Array]', | |
| uint32Tag = '[object Uint32Array]'; | |
| /** Used to identify `toStringTag` values of typed arrays. */ | |
| var typedArrayTags = {}; | |
| typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = | |
| typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = | |
| typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = | |
| typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = | |
| typedArrayTags[uint32Tag] = true; | |
| typedArrayTags[argsTag] = typedArrayTags[arrayTag] = | |
| typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = | |
| typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = | |
| typedArrayTags[errorTag] = typedArrayTags[funcTag] = | |
| typedArrayTags[mapTag] = typedArrayTags[numberTag] = | |
| typedArrayTags[objectTag] = typedArrayTags[regexpTag] = | |
| typedArrayTags[setTag] = typedArrayTags[stringTag] = | |
| typedArrayTags[weakMapTag] = false; | |
| /** | |
| * The base implementation of `_.isTypedArray` without Node.js optimizations. | |
| * | |
| * @private | |
| * @param {*} value The value to check. | |
| * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. | |
| */ | |
| function baseIsTypedArray(value) { | |
| return isObjectLike(value) && | |
| isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; | |
| } | |
| module.exports = baseIsTypedArray; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseIteratee.js": | |
| /*!**********************************************!*\ | |
| !*** ./node_modules/lodash/_baseIteratee.js ***! | |
| \**********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseMatches = __webpack_require__(/*! ./_baseMatches */ "./node_modules/lodash/_baseMatches.js"), | |
| baseMatchesProperty = __webpack_require__(/*! ./_baseMatchesProperty */ "./node_modules/lodash/_baseMatchesProperty.js"), | |
| identity = __webpack_require__(/*! ./identity */ "./node_modules/lodash/identity.js"), | |
| isArray = __webpack_require__(/*! ./isArray */ "./node_modules/lodash/isArray.js"), | |
| property = __webpack_require__(/*! ./property */ "./node_modules/lodash/property.js"); | |
| /** | |
| * The base implementation of `_.iteratee`. | |
| * | |
| * @private | |
| * @param {*} [value=_.identity] The value to convert to an iteratee. | |
| * @returns {Function} Returns the iteratee. | |
| */ | |
| function baseIteratee(value) { | |
| // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. | |
| // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. | |
| if (typeof value == 'function') { | |
| return value; | |
| } | |
| if (value == null) { | |
| return identity; | |
| } | |
| if (typeof value == 'object') { | |
| return isArray(value) | |
| ? baseMatchesProperty(value[0], value[1]) | |
| : baseMatches(value); | |
| } | |
| return property(value); | |
| } | |
| module.exports = baseIteratee; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseKeys.js": | |
| /*!******************************************!*\ | |
| !*** ./node_modules/lodash/_baseKeys.js ***! | |
| \******************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var isPrototype = __webpack_require__(/*! ./_isPrototype */ "./node_modules/lodash/_isPrototype.js"), | |
| nativeKeys = __webpack_require__(/*! ./_nativeKeys */ "./node_modules/lodash/_nativeKeys.js"); | |
| /** Used for built-in method references. */ | |
| var objectProto = Object.prototype; | |
| /** Used to check objects for own properties. */ | |
| var hasOwnProperty = objectProto.hasOwnProperty; | |
| /** | |
| * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. | |
| * | |
| * @private | |
| * @param {Object} object The object to query. | |
| * @returns {Array} Returns the array of property names. | |
| */ | |
| function baseKeys(object) { | |
| if (!isPrototype(object)) { | |
| return nativeKeys(object); | |
| } | |
| var result = []; | |
| for (var key in Object(object)) { | |
| if (hasOwnProperty.call(object, key) && key != 'constructor') { | |
| result.push(key); | |
| } | |
| } | |
| return result; | |
| } | |
| module.exports = baseKeys; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseMatches.js": | |
| /*!*********************************************!*\ | |
| !*** ./node_modules/lodash/_baseMatches.js ***! | |
| \*********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseIsMatch = __webpack_require__(/*! ./_baseIsMatch */ "./node_modules/lodash/_baseIsMatch.js"), | |
| getMatchData = __webpack_require__(/*! ./_getMatchData */ "./node_modules/lodash/_getMatchData.js"), | |
| matchesStrictComparable = __webpack_require__(/*! ./_matchesStrictComparable */ "./node_modules/lodash/_matchesStrictComparable.js"); | |
| /** | |
| * The base implementation of `_.matches` which doesn't clone `source`. | |
| * | |
| * @private | |
| * @param {Object} source The object of property values to match. | |
| * @returns {Function} Returns the new spec function. | |
| */ | |
| function baseMatches(source) { | |
| var matchData = getMatchData(source); | |
| if (matchData.length == 1 && matchData[0][2]) { | |
| return matchesStrictComparable(matchData[0][0], matchData[0][1]); | |
| } | |
| return function(object) { | |
| return object === source || baseIsMatch(object, source, matchData); | |
| }; | |
| } | |
| module.exports = baseMatches; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseMatchesProperty.js": | |
| /*!*****************************************************!*\ | |
| !*** ./node_modules/lodash/_baseMatchesProperty.js ***! | |
| \*****************************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseIsEqual = __webpack_require__(/*! ./_baseIsEqual */ "./node_modules/lodash/_baseIsEqual.js"), | |
| get = __webpack_require__(/*! ./get */ "./node_modules/lodash/get.js"), | |
| hasIn = __webpack_require__(/*! ./hasIn */ "./node_modules/lodash/hasIn.js"), | |
| isKey = __webpack_require__(/*! ./_isKey */ "./node_modules/lodash/_isKey.js"), | |
| isStrictComparable = __webpack_require__(/*! ./_isStrictComparable */ "./node_modules/lodash/_isStrictComparable.js"), | |
| matchesStrictComparable = __webpack_require__(/*! ./_matchesStrictComparable */ "./node_modules/lodash/_matchesStrictComparable.js"), | |
| toKey = __webpack_require__(/*! ./_toKey */ "./node_modules/lodash/_toKey.js"); | |
| /** Used to compose bitmasks for value comparisons. */ | |
| var COMPARE_PARTIAL_FLAG = 1, | |
| COMPARE_UNORDERED_FLAG = 2; | |
| /** | |
| * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. | |
| * | |
| * @private | |
| * @param {string} path The path of the property to get. | |
| * @param {*} srcValue The value to match. | |
| * @returns {Function} Returns the new spec function. | |
| */ | |
| function baseMatchesProperty(path, srcValue) { | |
| if (isKey(path) && isStrictComparable(srcValue)) { | |
| return matchesStrictComparable(toKey(path), srcValue); | |
| } | |
| return function(object) { | |
| var objValue = get(object, path); | |
| return (objValue === undefined && objValue === srcValue) | |
| ? hasIn(object, path) | |
| : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); | |
| }; | |
| } | |
| module.exports = baseMatchesProperty; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseProperty.js": | |
| /*!**********************************************!*\ | |
| !*** ./node_modules/lodash/_baseProperty.js ***! | |
| \**********************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * The base implementation of `_.property` without support for deep paths. | |
| * | |
| * @private | |
| * @param {string} key The key of the property to get. | |
| * @returns {Function} Returns the new accessor function. | |
| */ | |
| function baseProperty(key) { | |
| return function(object) { | |
| return object == null ? undefined : object[key]; | |
| }; | |
| } | |
| module.exports = baseProperty; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_basePropertyDeep.js": | |
| /*!**************************************************!*\ | |
| !*** ./node_modules/lodash/_basePropertyDeep.js ***! | |
| \**************************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseGet = __webpack_require__(/*! ./_baseGet */ "./node_modules/lodash/_baseGet.js"); | |
| /** | |
| * A specialized version of `baseProperty` which supports deep paths. | |
| * | |
| * @private | |
| * @param {Array|string} path The path of the property to get. | |
| * @returns {Function} Returns the new accessor function. | |
| */ | |
| function basePropertyDeep(path) { | |
| return function(object) { | |
| return baseGet(object, path); | |
| }; | |
| } | |
| module.exports = basePropertyDeep; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseTimes.js": | |
| /*!*******************************************!*\ | |
| !*** ./node_modules/lodash/_baseTimes.js ***! | |
| \*******************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * The base implementation of `_.times` without support for iteratee shorthands | |
| * or max array length checks. | |
| * | |
| * @private | |
| * @param {number} n The number of times to invoke `iteratee`. | |
| * @param {Function} iteratee The function invoked per iteration. | |
| * @returns {Array} Returns the array of results. | |
| */ | |
| function baseTimes(n, iteratee) { | |
| var index = -1, | |
| result = Array(n); | |
| while (++index < n) { | |
| result[index] = iteratee(index); | |
| } | |
| return result; | |
| } | |
| module.exports = baseTimes; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseToString.js": | |
| /*!**********************************************!*\ | |
| !*** ./node_modules/lodash/_baseToString.js ***! | |
| \**********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var Symbol = __webpack_require__(/*! ./_Symbol */ "./node_modules/lodash/_Symbol.js"), | |
| arrayMap = __webpack_require__(/*! ./_arrayMap */ "./node_modules/lodash/_arrayMap.js"), | |
| isArray = __webpack_require__(/*! ./isArray */ "./node_modules/lodash/isArray.js"), | |
| isSymbol = __webpack_require__(/*! ./isSymbol */ "./node_modules/lodash/isSymbol.js"); | |
| /** Used as references for various `Number` constants. */ | |
| var INFINITY = 1 / 0; | |
| /** Used to convert symbols to primitives and strings. */ | |
| var symbolProto = Symbol ? Symbol.prototype : undefined, | |
| symbolToString = symbolProto ? symbolProto.toString : undefined; | |
| /** | |
| * The base implementation of `_.toString` which doesn't convert nullish | |
| * values to empty strings. | |
| * | |
| * @private | |
| * @param {*} value The value to process. | |
| * @returns {string} Returns the string. | |
| */ | |
| function baseToString(value) { | |
| // Exit early for strings to avoid a performance hit in some environments. | |
| if (typeof value == 'string') { | |
| return value; | |
| } | |
| if (isArray(value)) { | |
| // Recursively convert values (susceptible to call stack limits). | |
| return arrayMap(value, baseToString) + ''; | |
| } | |
| if (isSymbol(value)) { | |
| return symbolToString ? symbolToString.call(value) : ''; | |
| } | |
| var result = (value + ''); | |
| return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; | |
| } | |
| module.exports = baseToString; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_baseUnary.js": | |
| /*!*******************************************!*\ | |
| !*** ./node_modules/lodash/_baseUnary.js ***! | |
| \*******************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * The base implementation of `_.unary` without support for storing metadata. | |
| * | |
| * @private | |
| * @param {Function} func The function to cap arguments for. | |
| * @returns {Function} Returns the new capped function. | |
| */ | |
| function baseUnary(func) { | |
| return function(value) { | |
| return func(value); | |
| }; | |
| } | |
| module.exports = baseUnary; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_cacheHas.js": | |
| /*!******************************************!*\ | |
| !*** ./node_modules/lodash/_cacheHas.js ***! | |
| \******************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * Checks if a `cache` value for `key` exists. | |
| * | |
| * @private | |
| * @param {Object} cache The cache to query. | |
| * @param {string} key The key of the entry to check. | |
| * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. | |
| */ | |
| function cacheHas(cache, key) { | |
| return cache.has(key); | |
| } | |
| module.exports = cacheHas; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_castPath.js": | |
| /*!******************************************!*\ | |
| !*** ./node_modules/lodash/_castPath.js ***! | |
| \******************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var isArray = __webpack_require__(/*! ./isArray */ "./node_modules/lodash/isArray.js"), | |
| isKey = __webpack_require__(/*! ./_isKey */ "./node_modules/lodash/_isKey.js"), | |
| stringToPath = __webpack_require__(/*! ./_stringToPath */ "./node_modules/lodash/_stringToPath.js"), | |
| toString = __webpack_require__(/*! ./toString */ "./node_modules/lodash/toString.js"); | |
| /** | |
| * Casts `value` to a path array if it's not one. | |
| * | |
| * @private | |
| * @param {*} value The value to inspect. | |
| * @param {Object} [object] The object to query keys on. | |
| * @returns {Array} Returns the cast property path array. | |
| */ | |
| function castPath(value, object) { | |
| if (isArray(value)) { | |
| return value; | |
| } | |
| return isKey(value, object) ? [value] : stringToPath(toString(value)); | |
| } | |
| module.exports = castPath; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_coreJsData.js": | |
| /*!********************************************!*\ | |
| !*** ./node_modules/lodash/_coreJsData.js ***! | |
| \********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var root = __webpack_require__(/*! ./_root */ "./node_modules/lodash/_root.js"); | |
| /** Used to detect overreaching core-js shims. */ | |
| var coreJsData = root['__core-js_shared__']; | |
| module.exports = coreJsData; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_createBaseFor.js": | |
| /*!***********************************************!*\ | |
| !*** ./node_modules/lodash/_createBaseFor.js ***! | |
| \***********************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * Creates a base function for methods like `_.forIn` and `_.forOwn`. | |
| * | |
| * @private | |
| * @param {boolean} [fromRight] Specify iterating from right to left. | |
| * @returns {Function} Returns the new base function. | |
| */ | |
| function createBaseFor(fromRight) { | |
| return function(object, iteratee, keysFunc) { | |
| var index = -1, | |
| iterable = Object(object), | |
| props = keysFunc(object), | |
| length = props.length; | |
| while (length--) { | |
| var key = props[fromRight ? length : ++index]; | |
| if (iteratee(iterable[key], key, iterable) === false) { | |
| break; | |
| } | |
| } | |
| return object; | |
| }; | |
| } | |
| module.exports = createBaseFor; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_defineProperty.js": | |
| /*!************************************************!*\ | |
| !*** ./node_modules/lodash/_defineProperty.js ***! | |
| \************************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var getNative = __webpack_require__(/*! ./_getNative */ "./node_modules/lodash/_getNative.js"); | |
| var defineProperty = (function() { | |
| try { | |
| var func = getNative(Object, 'defineProperty'); | |
| func({}, '', {}); | |
| return func; | |
| } catch (e) {} | |
| }()); | |
| module.exports = defineProperty; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_equalArrays.js": | |
| /*!*********************************************!*\ | |
| !*** ./node_modules/lodash/_equalArrays.js ***! | |
| \*********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var SetCache = __webpack_require__(/*! ./_SetCache */ "./node_modules/lodash/_SetCache.js"), | |
| arraySome = __webpack_require__(/*! ./_arraySome */ "./node_modules/lodash/_arraySome.js"), | |
| cacheHas = __webpack_require__(/*! ./_cacheHas */ "./node_modules/lodash/_cacheHas.js"); | |
| /** Used to compose bitmasks for value comparisons. */ | |
| var COMPARE_PARTIAL_FLAG = 1, | |
| COMPARE_UNORDERED_FLAG = 2; | |
| /** | |
| * A specialized version of `baseIsEqualDeep` for arrays with support for | |
| * partial deep comparisons. | |
| * | |
| * @private | |
| * @param {Array} array The array to compare. | |
| * @param {Array} other The other array to compare. | |
| * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. | |
| * @param {Function} customizer The function to customize comparisons. | |
| * @param {Function} equalFunc The function to determine equivalents of values. | |
| * @param {Object} stack Tracks traversed `array` and `other` objects. | |
| * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. | |
| */ | |
| function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { | |
| var isPartial = bitmask & COMPARE_PARTIAL_FLAG, | |
| arrLength = array.length, | |
| othLength = other.length; | |
| if (arrLength != othLength && !(isPartial && othLength > arrLength)) { | |
| return false; | |
| } | |
| // Check that cyclic values are equal. | |
| var arrStacked = stack.get(array); | |
| var othStacked = stack.get(other); | |
| if (arrStacked && othStacked) { | |
| return arrStacked == other && othStacked == array; | |
| } | |
| var index = -1, | |
| result = true, | |
| seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; | |
| stack.set(array, other); | |
| stack.set(other, array); | |
| // Ignore non-index properties. | |
| while (++index < arrLength) { | |
| var arrValue = array[index], | |
| othValue = other[index]; | |
| if (customizer) { | |
| var compared = isPartial | |
| ? customizer(othValue, arrValue, index, other, array, stack) | |
| : customizer(arrValue, othValue, index, array, other, stack); | |
| } | |
| if (compared !== undefined) { | |
| if (compared) { | |
| continue; | |
| } | |
| result = false; | |
| break; | |
| } | |
| // Recursively compare arrays (susceptible to call stack limits). | |
| if (seen) { | |
| if (!arraySome(other, function(othValue, othIndex) { | |
| if (!cacheHas(seen, othIndex) && | |
| (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { | |
| return seen.push(othIndex); | |
| } | |
| })) { | |
| result = false; | |
| break; | |
| } | |
| } else if (!( | |
| arrValue === othValue || | |
| equalFunc(arrValue, othValue, bitmask, customizer, stack) | |
| )) { | |
| result = false; | |
| break; | |
| } | |
| } | |
| stack['delete'](array); | |
| stack['delete'](other); | |
| return result; | |
| } | |
| module.exports = equalArrays; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_equalByTag.js": | |
| /*!********************************************!*\ | |
| !*** ./node_modules/lodash/_equalByTag.js ***! | |
| \********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var Symbol = __webpack_require__(/*! ./_Symbol */ "./node_modules/lodash/_Symbol.js"), | |
| Uint8Array = __webpack_require__(/*! ./_Uint8Array */ "./node_modules/lodash/_Uint8Array.js"), | |
| eq = __webpack_require__(/*! ./eq */ "./node_modules/lodash/eq.js"), | |
| equalArrays = __webpack_require__(/*! ./_equalArrays */ "./node_modules/lodash/_equalArrays.js"), | |
| mapToArray = __webpack_require__(/*! ./_mapToArray */ "./node_modules/lodash/_mapToArray.js"), | |
| setToArray = __webpack_require__(/*! ./_setToArray */ "./node_modules/lodash/_setToArray.js"); | |
| /** Used to compose bitmasks for value comparisons. */ | |
| var COMPARE_PARTIAL_FLAG = 1, | |
| COMPARE_UNORDERED_FLAG = 2; | |
| /** `Object#toString` result references. */ | |
| var boolTag = '[object Boolean]', | |
| dateTag = '[object Date]', | |
| errorTag = '[object Error]', | |
| mapTag = '[object Map]', | |
| numberTag = '[object Number]', | |
| regexpTag = '[object RegExp]', | |
| setTag = '[object Set]', | |
| stringTag = '[object String]', | |
| symbolTag = '[object Symbol]'; | |
| var arrayBufferTag = '[object ArrayBuffer]', | |
| dataViewTag = '[object DataView]'; | |
| /** Used to convert symbols to primitives and strings. */ | |
| var symbolProto = Symbol ? Symbol.prototype : undefined, | |
| symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; | |
| /** | |
| * A specialized version of `baseIsEqualDeep` for comparing objects of | |
| * the same `toStringTag`. | |
| * | |
| * **Note:** This function only supports comparing values with tags of | |
| * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. | |
| * | |
| * @private | |
| * @param {Object} object The object to compare. | |
| * @param {Object} other The other object to compare. | |
| * @param {string} tag The `toStringTag` of the objects to compare. | |
| * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. | |
| * @param {Function} customizer The function to customize comparisons. | |
| * @param {Function} equalFunc The function to determine equivalents of values. | |
| * @param {Object} stack Tracks traversed `object` and `other` objects. | |
| * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. | |
| */ | |
| function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { | |
| switch (tag) { | |
| case dataViewTag: | |
| if ((object.byteLength != other.byteLength) || | |
| (object.byteOffset != other.byteOffset)) { | |
| return false; | |
| } | |
| object = object.buffer; | |
| other = other.buffer; | |
| case arrayBufferTag: | |
| if ((object.byteLength != other.byteLength) || | |
| !equalFunc(new Uint8Array(object), new Uint8Array(other))) { | |
| return false; | |
| } | |
| return true; | |
| case boolTag: | |
| case dateTag: | |
| case numberTag: | |
| // Coerce booleans to `1` or `0` and dates to milliseconds. | |
| // Invalid dates are coerced to `NaN`. | |
| return eq(+object, +other); | |
| case errorTag: | |
| return object.name == other.name && object.message == other.message; | |
| case regexpTag: | |
| case stringTag: | |
| // Coerce regexes to strings and treat strings, primitives and objects, | |
| // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring | |
| // for more details. | |
| return object == (other + ''); | |
| case mapTag: | |
| var convert = mapToArray; | |
| case setTag: | |
| var isPartial = bitmask & COMPARE_PARTIAL_FLAG; | |
| convert || (convert = setToArray); | |
| if (object.size != other.size && !isPartial) { | |
| return false; | |
| } | |
| // Assume cyclic values are equal. | |
| var stacked = stack.get(object); | |
| if (stacked) { | |
| return stacked == other; | |
| } | |
| bitmask |= COMPARE_UNORDERED_FLAG; | |
| // Recursively compare objects (susceptible to call stack limits). | |
| stack.set(object, other); | |
| var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); | |
| stack['delete'](object); | |
| return result; | |
| case symbolTag: | |
| if (symbolValueOf) { | |
| return symbolValueOf.call(object) == symbolValueOf.call(other); | |
| } | |
| } | |
| return false; | |
| } | |
| module.exports = equalByTag; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_equalObjects.js": | |
| /*!**********************************************!*\ | |
| !*** ./node_modules/lodash/_equalObjects.js ***! | |
| \**********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var getAllKeys = __webpack_require__(/*! ./_getAllKeys */ "./node_modules/lodash/_getAllKeys.js"); | |
| /** Used to compose bitmasks for value comparisons. */ | |
| var COMPARE_PARTIAL_FLAG = 1; | |
| /** Used for built-in method references. */ | |
| var objectProto = Object.prototype; | |
| /** Used to check objects for own properties. */ | |
| var hasOwnProperty = objectProto.hasOwnProperty; | |
| /** | |
| * A specialized version of `baseIsEqualDeep` for objects with support for | |
| * partial deep comparisons. | |
| * | |
| * @private | |
| * @param {Object} object The object to compare. | |
| * @param {Object} other The other object to compare. | |
| * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. | |
| * @param {Function} customizer The function to customize comparisons. | |
| * @param {Function} equalFunc The function to determine equivalents of values. | |
| * @param {Object} stack Tracks traversed `object` and `other` objects. | |
| * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. | |
| */ | |
| function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { | |
| var isPartial = bitmask & COMPARE_PARTIAL_FLAG, | |
| objProps = getAllKeys(object), | |
| objLength = objProps.length, | |
| othProps = getAllKeys(other), | |
| othLength = othProps.length; | |
| if (objLength != othLength && !isPartial) { | |
| return false; | |
| } | |
| var index = objLength; | |
| while (index--) { | |
| var key = objProps[index]; | |
| if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { | |
| return false; | |
| } | |
| } | |
| // Check that cyclic values are equal. | |
| var objStacked = stack.get(object); | |
| var othStacked = stack.get(other); | |
| if (objStacked && othStacked) { | |
| return objStacked == other && othStacked == object; | |
| } | |
| var result = true; | |
| stack.set(object, other); | |
| stack.set(other, object); | |
| var skipCtor = isPartial; | |
| while (++index < objLength) { | |
| key = objProps[index]; | |
| var objValue = object[key], | |
| othValue = other[key]; | |
| if (customizer) { | |
| var compared = isPartial | |
| ? customizer(othValue, objValue, key, other, object, stack) | |
| : customizer(objValue, othValue, key, object, other, stack); | |
| } | |
| // Recursively compare objects (susceptible to call stack limits). | |
| if (!(compared === undefined | |
| ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) | |
| : compared | |
| )) { | |
| result = false; | |
| break; | |
| } | |
| skipCtor || (skipCtor = key == 'constructor'); | |
| } | |
| if (result && !skipCtor) { | |
| var objCtor = object.constructor, | |
| othCtor = other.constructor; | |
| // Non `Object` object instances with different constructors are not equal. | |
| if (objCtor != othCtor && | |
| ('constructor' in object && 'constructor' in other) && | |
| !(typeof objCtor == 'function' && objCtor instanceof objCtor && | |
| typeof othCtor == 'function' && othCtor instanceof othCtor)) { | |
| result = false; | |
| } | |
| } | |
| stack['delete'](object); | |
| stack['delete'](other); | |
| return result; | |
| } | |
| module.exports = equalObjects; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_freeGlobal.js": | |
| /*!********************************************!*\ | |
| !*** ./node_modules/lodash/_freeGlobal.js ***! | |
| \********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| /** Detect free variable `global` from Node.js. */ | |
| var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g; | |
| module.exports = freeGlobal; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_getAllKeys.js": | |
| /*!********************************************!*\ | |
| !*** ./node_modules/lodash/_getAllKeys.js ***! | |
| \********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseGetAllKeys = __webpack_require__(/*! ./_baseGetAllKeys */ "./node_modules/lodash/_baseGetAllKeys.js"), | |
| getSymbols = __webpack_require__(/*! ./_getSymbols */ "./node_modules/lodash/_getSymbols.js"), | |
| keys = __webpack_require__(/*! ./keys */ "./node_modules/lodash/keys.js"); | |
| /** | |
| * Creates an array of own enumerable property names and symbols of `object`. | |
| * | |
| * @private | |
| * @param {Object} object The object to query. | |
| * @returns {Array} Returns the array of property names and symbols. | |
| */ | |
| function getAllKeys(object) { | |
| return baseGetAllKeys(object, keys, getSymbols); | |
| } | |
| module.exports = getAllKeys; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_getMapData.js": | |
| /*!********************************************!*\ | |
| !*** ./node_modules/lodash/_getMapData.js ***! | |
| \********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var isKeyable = __webpack_require__(/*! ./_isKeyable */ "./node_modules/lodash/_isKeyable.js"); | |
| /** | |
| * Gets the data for `map`. | |
| * | |
| * @private | |
| * @param {Object} map The map to query. | |
| * @param {string} key The reference key. | |
| * @returns {*} Returns the map data. | |
| */ | |
| function getMapData(map, key) { | |
| var data = map.__data__; | |
| return isKeyable(key) | |
| ? data[typeof key == 'string' ? 'string' : 'hash'] | |
| : data.map; | |
| } | |
| module.exports = getMapData; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_getMatchData.js": | |
| /*!**********************************************!*\ | |
| !*** ./node_modules/lodash/_getMatchData.js ***! | |
| \**********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var isStrictComparable = __webpack_require__(/*! ./_isStrictComparable */ "./node_modules/lodash/_isStrictComparable.js"), | |
| keys = __webpack_require__(/*! ./keys */ "./node_modules/lodash/keys.js"); | |
| /** | |
| * Gets the property names, values, and compare flags of `object`. | |
| * | |
| * @private | |
| * @param {Object} object The object to query. | |
| * @returns {Array} Returns the match data of `object`. | |
| */ | |
| function getMatchData(object) { | |
| var result = keys(object), | |
| length = result.length; | |
| while (length--) { | |
| var key = result[length], | |
| value = object[key]; | |
| result[length] = [key, value, isStrictComparable(value)]; | |
| } | |
| return result; | |
| } | |
| module.exports = getMatchData; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_getNative.js": | |
| /*!*******************************************!*\ | |
| !*** ./node_modules/lodash/_getNative.js ***! | |
| \*******************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseIsNative = __webpack_require__(/*! ./_baseIsNative */ "./node_modules/lodash/_baseIsNative.js"), | |
| getValue = __webpack_require__(/*! ./_getValue */ "./node_modules/lodash/_getValue.js"); | |
| /** | |
| * Gets the native function at `key` of `object`. | |
| * | |
| * @private | |
| * @param {Object} object The object to query. | |
| * @param {string} key The key of the method to get. | |
| * @returns {*} Returns the function if it's native, else `undefined`. | |
| */ | |
| function getNative(object, key) { | |
| var value = getValue(object, key); | |
| return baseIsNative(value) ? value : undefined; | |
| } | |
| module.exports = getNative; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_getRawTag.js": | |
| /*!*******************************************!*\ | |
| !*** ./node_modules/lodash/_getRawTag.js ***! | |
| \*******************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var Symbol = __webpack_require__(/*! ./_Symbol */ "./node_modules/lodash/_Symbol.js"); | |
| /** Used for built-in method references. */ | |
| var objectProto = Object.prototype; | |
| /** Used to check objects for own properties. */ | |
| var hasOwnProperty = objectProto.hasOwnProperty; | |
| /** | |
| * Used to resolve the | |
| * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) | |
| * of values. | |
| */ | |
| var nativeObjectToString = objectProto.toString; | |
| /** Built-in value references. */ | |
| var symToStringTag = Symbol ? Symbol.toStringTag : undefined; | |
| /** | |
| * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. | |
| * | |
| * @private | |
| * @param {*} value The value to query. | |
| * @returns {string} Returns the raw `toStringTag`. | |
| */ | |
| function getRawTag(value) { | |
| var isOwn = hasOwnProperty.call(value, symToStringTag), | |
| tag = value[symToStringTag]; | |
| try { | |
| value[symToStringTag] = undefined; | |
| var unmasked = true; | |
| } catch (e) {} | |
| var result = nativeObjectToString.call(value); | |
| if (unmasked) { | |
| if (isOwn) { | |
| value[symToStringTag] = tag; | |
| } else { | |
| delete value[symToStringTag]; | |
| } | |
| } | |
| return result; | |
| } | |
| module.exports = getRawTag; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_getSymbols.js": | |
| /*!********************************************!*\ | |
| !*** ./node_modules/lodash/_getSymbols.js ***! | |
| \********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var arrayFilter = __webpack_require__(/*! ./_arrayFilter */ "./node_modules/lodash/_arrayFilter.js"), | |
| stubArray = __webpack_require__(/*! ./stubArray */ "./node_modules/lodash/stubArray.js"); | |
| /** Used for built-in method references. */ | |
| var objectProto = Object.prototype; | |
| /** Built-in value references. */ | |
| var propertyIsEnumerable = objectProto.propertyIsEnumerable; | |
| /* Built-in method references for those with the same name as other `lodash` methods. */ | |
| var nativeGetSymbols = Object.getOwnPropertySymbols; | |
| /** | |
| * Creates an array of the own enumerable symbols of `object`. | |
| * | |
| * @private | |
| * @param {Object} object The object to query. | |
| * @returns {Array} Returns the array of symbols. | |
| */ | |
| var getSymbols = !nativeGetSymbols ? stubArray : function(object) { | |
| if (object == null) { | |
| return []; | |
| } | |
| object = Object(object); | |
| return arrayFilter(nativeGetSymbols(object), function(symbol) { | |
| return propertyIsEnumerable.call(object, symbol); | |
| }); | |
| }; | |
| module.exports = getSymbols; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_getTag.js": | |
| /*!****************************************!*\ | |
| !*** ./node_modules/lodash/_getTag.js ***! | |
| \****************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var DataView = __webpack_require__(/*! ./_DataView */ "./node_modules/lodash/_DataView.js"), | |
| Map = __webpack_require__(/*! ./_Map */ "./node_modules/lodash/_Map.js"), | |
| Promise = __webpack_require__(/*! ./_Promise */ "./node_modules/lodash/_Promise.js"), | |
| Set = __webpack_require__(/*! ./_Set */ "./node_modules/lodash/_Set.js"), | |
| WeakMap = __webpack_require__(/*! ./_WeakMap */ "./node_modules/lodash/_WeakMap.js"), | |
| baseGetTag = __webpack_require__(/*! ./_baseGetTag */ "./node_modules/lodash/_baseGetTag.js"), | |
| toSource = __webpack_require__(/*! ./_toSource */ "./node_modules/lodash/_toSource.js"); | |
| /** `Object#toString` result references. */ | |
| var mapTag = '[object Map]', | |
| objectTag = '[object Object]', | |
| promiseTag = '[object Promise]', | |
| setTag = '[object Set]', | |
| weakMapTag = '[object WeakMap]'; | |
| var dataViewTag = '[object DataView]'; | |
| /** Used to detect maps, sets, and weakmaps. */ | |
| var dataViewCtorString = toSource(DataView), | |
| mapCtorString = toSource(Map), | |
| promiseCtorString = toSource(Promise), | |
| setCtorString = toSource(Set), | |
| weakMapCtorString = toSource(WeakMap); | |
| /** | |
| * Gets the `toStringTag` of `value`. | |
| * | |
| * @private | |
| * @param {*} value The value to query. | |
| * @returns {string} Returns the `toStringTag`. | |
| */ | |
| var getTag = baseGetTag; | |
| // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. | |
| if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || | |
| (Map && getTag(new Map) != mapTag) || | |
| (Promise && getTag(Promise.resolve()) != promiseTag) || | |
| (Set && getTag(new Set) != setTag) || | |
| (WeakMap && getTag(new WeakMap) != weakMapTag)) { | |
| getTag = function(value) { | |
| var result = baseGetTag(value), | |
| Ctor = result == objectTag ? value.constructor : undefined, | |
| ctorString = Ctor ? toSource(Ctor) : ''; | |
| if (ctorString) { | |
| switch (ctorString) { | |
| case dataViewCtorString: return dataViewTag; | |
| case mapCtorString: return mapTag; | |
| case promiseCtorString: return promiseTag; | |
| case setCtorString: return setTag; | |
| case weakMapCtorString: return weakMapTag; | |
| } | |
| } | |
| return result; | |
| }; | |
| } | |
| module.exports = getTag; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_getValue.js": | |
| /*!******************************************!*\ | |
| !*** ./node_modules/lodash/_getValue.js ***! | |
| \******************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * Gets the value at `key` of `object`. | |
| * | |
| * @private | |
| * @param {Object} [object] The object to query. | |
| * @param {string} key The key of the property to get. | |
| * @returns {*} Returns the property value. | |
| */ | |
| function getValue(object, key) { | |
| return object == null ? undefined : object[key]; | |
| } | |
| module.exports = getValue; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_hasPath.js": | |
| /*!*****************************************!*\ | |
| !*** ./node_modules/lodash/_hasPath.js ***! | |
| \*****************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var castPath = __webpack_require__(/*! ./_castPath */ "./node_modules/lodash/_castPath.js"), | |
| isArguments = __webpack_require__(/*! ./isArguments */ "./node_modules/lodash/isArguments.js"), | |
| isArray = __webpack_require__(/*! ./isArray */ "./node_modules/lodash/isArray.js"), | |
| isIndex = __webpack_require__(/*! ./_isIndex */ "./node_modules/lodash/_isIndex.js"), | |
| isLength = __webpack_require__(/*! ./isLength */ "./node_modules/lodash/isLength.js"), | |
| toKey = __webpack_require__(/*! ./_toKey */ "./node_modules/lodash/_toKey.js"); | |
| /** | |
| * Checks if `path` exists on `object`. | |
| * | |
| * @private | |
| * @param {Object} object The object to query. | |
| * @param {Array|string} path The path to check. | |
| * @param {Function} hasFunc The function to check properties. | |
| * @returns {boolean} Returns `true` if `path` exists, else `false`. | |
| */ | |
| function hasPath(object, path, hasFunc) { | |
| path = castPath(path, object); | |
| var index = -1, | |
| length = path.length, | |
| result = false; | |
| while (++index < length) { | |
| var key = toKey(path[index]); | |
| if (!(result = object != null && hasFunc(object, key))) { | |
| break; | |
| } | |
| object = object[key]; | |
| } | |
| if (result || ++index != length) { | |
| return result; | |
| } | |
| length = object == null ? 0 : object.length; | |
| return !!length && isLength(length) && isIndex(key, length) && | |
| (isArray(object) || isArguments(object)); | |
| } | |
| module.exports = hasPath; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_hashClear.js": | |
| /*!*******************************************!*\ | |
| !*** ./node_modules/lodash/_hashClear.js ***! | |
| \*******************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var nativeCreate = __webpack_require__(/*! ./_nativeCreate */ "./node_modules/lodash/_nativeCreate.js"); | |
| /** | |
| * Removes all key-value entries from the hash. | |
| * | |
| * @private | |
| * @name clear | |
| * @memberOf Hash | |
| */ | |
| function hashClear() { | |
| this.__data__ = nativeCreate ? nativeCreate(null) : {}; | |
| this.size = 0; | |
| } | |
| module.exports = hashClear; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_hashDelete.js": | |
| /*!********************************************!*\ | |
| !*** ./node_modules/lodash/_hashDelete.js ***! | |
| \********************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * Removes `key` and its value from the hash. | |
| * | |
| * @private | |
| * @name delete | |
| * @memberOf Hash | |
| * @param {Object} hash The hash to modify. | |
| * @param {string} key The key of the value to remove. | |
| * @returns {boolean} Returns `true` if the entry was removed, else `false`. | |
| */ | |
| function hashDelete(key) { | |
| var result = this.has(key) && delete this.__data__[key]; | |
| this.size -= result ? 1 : 0; | |
| return result; | |
| } | |
| module.exports = hashDelete; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_hashGet.js": | |
| /*!*****************************************!*\ | |
| !*** ./node_modules/lodash/_hashGet.js ***! | |
| \*****************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var nativeCreate = __webpack_require__(/*! ./_nativeCreate */ "./node_modules/lodash/_nativeCreate.js"); | |
| /** Used to stand-in for `undefined` hash values. */ | |
| var HASH_UNDEFINED = '__lodash_hash_undefined__'; | |
| /** Used for built-in method references. */ | |
| var objectProto = Object.prototype; | |
| /** Used to check objects for own properties. */ | |
| var hasOwnProperty = objectProto.hasOwnProperty; | |
| /** | |
| * Gets the hash value for `key`. | |
| * | |
| * @private | |
| * @name get | |
| * @memberOf Hash | |
| * @param {string} key The key of the value to get. | |
| * @returns {*} Returns the entry value. | |
| */ | |
| function hashGet(key) { | |
| var data = this.__data__; | |
| if (nativeCreate) { | |
| var result = data[key]; | |
| return result === HASH_UNDEFINED ? undefined : result; | |
| } | |
| return hasOwnProperty.call(data, key) ? data[key] : undefined; | |
| } | |
| module.exports = hashGet; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_hashHas.js": | |
| /*!*****************************************!*\ | |
| !*** ./node_modules/lodash/_hashHas.js ***! | |
| \*****************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var nativeCreate = __webpack_require__(/*! ./_nativeCreate */ "./node_modules/lodash/_nativeCreate.js"); | |
| /** Used for built-in method references. */ | |
| var objectProto = Object.prototype; | |
| /** Used to check objects for own properties. */ | |
| var hasOwnProperty = objectProto.hasOwnProperty; | |
| /** | |
| * Checks if a hash value for `key` exists. | |
| * | |
| * @private | |
| * @name has | |
| * @memberOf Hash | |
| * @param {string} key The key of the entry to check. | |
| * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. | |
| */ | |
| function hashHas(key) { | |
| var data = this.__data__; | |
| return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); | |
| } | |
| module.exports = hashHas; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_hashSet.js": | |
| /*!*****************************************!*\ | |
| !*** ./node_modules/lodash/_hashSet.js ***! | |
| \*****************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var nativeCreate = __webpack_require__(/*! ./_nativeCreate */ "./node_modules/lodash/_nativeCreate.js"); | |
| /** Used to stand-in for `undefined` hash values. */ | |
| var HASH_UNDEFINED = '__lodash_hash_undefined__'; | |
| /** | |
| * Sets the hash `key` to `value`. | |
| * | |
| * @private | |
| * @name set | |
| * @memberOf Hash | |
| * @param {string} key The key of the value to set. | |
| * @param {*} value The value to set. | |
| * @returns {Object} Returns the hash instance. | |
| */ | |
| function hashSet(key, value) { | |
| var data = this.__data__; | |
| this.size += this.has(key) ? 0 : 1; | |
| data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; | |
| return this; | |
| } | |
| module.exports = hashSet; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_isIndex.js": | |
| /*!*****************************************!*\ | |
| !*** ./node_modules/lodash/_isIndex.js ***! | |
| \*****************************************/ | |
| /***/ (function(module) { | |
| /** Used as references for various `Number` constants. */ | |
| var MAX_SAFE_INTEGER = 9007199254740991; | |
| /** Used to detect unsigned integer values. */ | |
| var reIsUint = /^(?:0|[1-9]\d*)$/; | |
| /** | |
| * Checks if `value` is a valid array-like index. | |
| * | |
| * @private | |
| * @param {*} value The value to check. | |
| * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. | |
| * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. | |
| */ | |
| function isIndex(value, length) { | |
| var type = typeof value; | |
| length = length == null ? MAX_SAFE_INTEGER : length; | |
| return !!length && | |
| (type == 'number' || | |
| (type != 'symbol' && reIsUint.test(value))) && | |
| (value > -1 && value % 1 == 0 && value < length); | |
| } | |
| module.exports = isIndex; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_isKey.js": | |
| /*!***************************************!*\ | |
| !*** ./node_modules/lodash/_isKey.js ***! | |
| \***************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var isArray = __webpack_require__(/*! ./isArray */ "./node_modules/lodash/isArray.js"), | |
| isSymbol = __webpack_require__(/*! ./isSymbol */ "./node_modules/lodash/isSymbol.js"); | |
| /** Used to match property names within property paths. */ | |
| var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, | |
| reIsPlainProp = /^\w*$/; | |
| /** | |
| * Checks if `value` is a property name and not a property path. | |
| * | |
| * @private | |
| * @param {*} value The value to check. | |
| * @param {Object} [object] The object to query keys on. | |
| * @returns {boolean} Returns `true` if `value` is a property name, else `false`. | |
| */ | |
| function isKey(value, object) { | |
| if (isArray(value)) { | |
| return false; | |
| } | |
| var type = typeof value; | |
| if (type == 'number' || type == 'symbol' || type == 'boolean' || | |
| value == null || isSymbol(value)) { | |
| return true; | |
| } | |
| return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || | |
| (object != null && value in Object(object)); | |
| } | |
| module.exports = isKey; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_isKeyable.js": | |
| /*!*******************************************!*\ | |
| !*** ./node_modules/lodash/_isKeyable.js ***! | |
| \*******************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * Checks if `value` is suitable for use as unique object key. | |
| * | |
| * @private | |
| * @param {*} value The value to check. | |
| * @returns {boolean} Returns `true` if `value` is suitable, else `false`. | |
| */ | |
| function isKeyable(value) { | |
| var type = typeof value; | |
| return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') | |
| ? (value !== '__proto__') | |
| : (value === null); | |
| } | |
| module.exports = isKeyable; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_isMasked.js": | |
| /*!******************************************!*\ | |
| !*** ./node_modules/lodash/_isMasked.js ***! | |
| \******************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var coreJsData = __webpack_require__(/*! ./_coreJsData */ "./node_modules/lodash/_coreJsData.js"); | |
| /** Used to detect methods masquerading as native. */ | |
| var maskSrcKey = (function() { | |
| var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); | |
| return uid ? ('Symbol(src)_1.' + uid) : ''; | |
| }()); | |
| /** | |
| * Checks if `func` has its source masked. | |
| * | |
| * @private | |
| * @param {Function} func The function to check. | |
| * @returns {boolean} Returns `true` if `func` is masked, else `false`. | |
| */ | |
| function isMasked(func) { | |
| return !!maskSrcKey && (maskSrcKey in func); | |
| } | |
| module.exports = isMasked; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_isPrototype.js": | |
| /*!*********************************************!*\ | |
| !*** ./node_modules/lodash/_isPrototype.js ***! | |
| \*********************************************/ | |
| /***/ (function(module) { | |
| /** Used for built-in method references. */ | |
| var objectProto = Object.prototype; | |
| /** | |
| * Checks if `value` is likely a prototype object. | |
| * | |
| * @private | |
| * @param {*} value The value to check. | |
| * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. | |
| */ | |
| function isPrototype(value) { | |
| var Ctor = value && value.constructor, | |
| proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; | |
| return value === proto; | |
| } | |
| module.exports = isPrototype; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_isStrictComparable.js": | |
| /*!****************************************************!*\ | |
| !*** ./node_modules/lodash/_isStrictComparable.js ***! | |
| \****************************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var isObject = __webpack_require__(/*! ./isObject */ "./node_modules/lodash/isObject.js"); | |
| /** | |
| * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. | |
| * | |
| * @private | |
| * @param {*} value The value to check. | |
| * @returns {boolean} Returns `true` if `value` if suitable for strict | |
| * equality comparisons, else `false`. | |
| */ | |
| function isStrictComparable(value) { | |
| return value === value && !isObject(value); | |
| } | |
| module.exports = isStrictComparable; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_listCacheClear.js": | |
| /*!************************************************!*\ | |
| !*** ./node_modules/lodash/_listCacheClear.js ***! | |
| \************************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * Removes all key-value entries from the list cache. | |
| * | |
| * @private | |
| * @name clear | |
| * @memberOf ListCache | |
| */ | |
| function listCacheClear() { | |
| this.__data__ = []; | |
| this.size = 0; | |
| } | |
| module.exports = listCacheClear; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_listCacheDelete.js": | |
| /*!*************************************************!*\ | |
| !*** ./node_modules/lodash/_listCacheDelete.js ***! | |
| \*************************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var assocIndexOf = __webpack_require__(/*! ./_assocIndexOf */ "./node_modules/lodash/_assocIndexOf.js"); | |
| /** Used for built-in method references. */ | |
| var arrayProto = Array.prototype; | |
| /** Built-in value references. */ | |
| var splice = arrayProto.splice; | |
| /** | |
| * Removes `key` and its value from the list cache. | |
| * | |
| * @private | |
| * @name delete | |
| * @memberOf ListCache | |
| * @param {string} key The key of the value to remove. | |
| * @returns {boolean} Returns `true` if the entry was removed, else `false`. | |
| */ | |
| function listCacheDelete(key) { | |
| var data = this.__data__, | |
| index = assocIndexOf(data, key); | |
| if (index < 0) { | |
| return false; | |
| } | |
| var lastIndex = data.length - 1; | |
| if (index == lastIndex) { | |
| data.pop(); | |
| } else { | |
| splice.call(data, index, 1); | |
| } | |
| --this.size; | |
| return true; | |
| } | |
| module.exports = listCacheDelete; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_listCacheGet.js": | |
| /*!**********************************************!*\ | |
| !*** ./node_modules/lodash/_listCacheGet.js ***! | |
| \**********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var assocIndexOf = __webpack_require__(/*! ./_assocIndexOf */ "./node_modules/lodash/_assocIndexOf.js"); | |
| /** | |
| * Gets the list cache value for `key`. | |
| * | |
| * @private | |
| * @name get | |
| * @memberOf ListCache | |
| * @param {string} key The key of the value to get. | |
| * @returns {*} Returns the entry value. | |
| */ | |
| function listCacheGet(key) { | |
| var data = this.__data__, | |
| index = assocIndexOf(data, key); | |
| return index < 0 ? undefined : data[index][1]; | |
| } | |
| module.exports = listCacheGet; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_listCacheHas.js": | |
| /*!**********************************************!*\ | |
| !*** ./node_modules/lodash/_listCacheHas.js ***! | |
| \**********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var assocIndexOf = __webpack_require__(/*! ./_assocIndexOf */ "./node_modules/lodash/_assocIndexOf.js"); | |
| /** | |
| * Checks if a list cache value for `key` exists. | |
| * | |
| * @private | |
| * @name has | |
| * @memberOf ListCache | |
| * @param {string} key The key of the entry to check. | |
| * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. | |
| */ | |
| function listCacheHas(key) { | |
| return assocIndexOf(this.__data__, key) > -1; | |
| } | |
| module.exports = listCacheHas; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_listCacheSet.js": | |
| /*!**********************************************!*\ | |
| !*** ./node_modules/lodash/_listCacheSet.js ***! | |
| \**********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var assocIndexOf = __webpack_require__(/*! ./_assocIndexOf */ "./node_modules/lodash/_assocIndexOf.js"); | |
| /** | |
| * Sets the list cache `key` to `value`. | |
| * | |
| * @private | |
| * @name set | |
| * @memberOf ListCache | |
| * @param {string} key The key of the value to set. | |
| * @param {*} value The value to set. | |
| * @returns {Object} Returns the list cache instance. | |
| */ | |
| function listCacheSet(key, value) { | |
| var data = this.__data__, | |
| index = assocIndexOf(data, key); | |
| if (index < 0) { | |
| ++this.size; | |
| data.push([key, value]); | |
| } else { | |
| data[index][1] = value; | |
| } | |
| return this; | |
| } | |
| module.exports = listCacheSet; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_mapCacheClear.js": | |
| /*!***********************************************!*\ | |
| !*** ./node_modules/lodash/_mapCacheClear.js ***! | |
| \***********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var Hash = __webpack_require__(/*! ./_Hash */ "./node_modules/lodash/_Hash.js"), | |
| ListCache = __webpack_require__(/*! ./_ListCache */ "./node_modules/lodash/_ListCache.js"), | |
| Map = __webpack_require__(/*! ./_Map */ "./node_modules/lodash/_Map.js"); | |
| /** | |
| * Removes all key-value entries from the map. | |
| * | |
| * @private | |
| * @name clear | |
| * @memberOf MapCache | |
| */ | |
| function mapCacheClear() { | |
| this.size = 0; | |
| this.__data__ = { | |
| 'hash': new Hash, | |
| 'map': new (Map || ListCache), | |
| 'string': new Hash | |
| }; | |
| } | |
| module.exports = mapCacheClear; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_mapCacheDelete.js": | |
| /*!************************************************!*\ | |
| !*** ./node_modules/lodash/_mapCacheDelete.js ***! | |
| \************************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var getMapData = __webpack_require__(/*! ./_getMapData */ "./node_modules/lodash/_getMapData.js"); | |
| /** | |
| * Removes `key` and its value from the map. | |
| * | |
| * @private | |
| * @name delete | |
| * @memberOf MapCache | |
| * @param {string} key The key of the value to remove. | |
| * @returns {boolean} Returns `true` if the entry was removed, else `false`. | |
| */ | |
| function mapCacheDelete(key) { | |
| var result = getMapData(this, key)['delete'](key); | |
| this.size -= result ? 1 : 0; | |
| return result; | |
| } | |
| module.exports = mapCacheDelete; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_mapCacheGet.js": | |
| /*!*********************************************!*\ | |
| !*** ./node_modules/lodash/_mapCacheGet.js ***! | |
| \*********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var getMapData = __webpack_require__(/*! ./_getMapData */ "./node_modules/lodash/_getMapData.js"); | |
| /** | |
| * Gets the map value for `key`. | |
| * | |
| * @private | |
| * @name get | |
| * @memberOf MapCache | |
| * @param {string} key The key of the value to get. | |
| * @returns {*} Returns the entry value. | |
| */ | |
| function mapCacheGet(key) { | |
| return getMapData(this, key).get(key); | |
| } | |
| module.exports = mapCacheGet; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_mapCacheHas.js": | |
| /*!*********************************************!*\ | |
| !*** ./node_modules/lodash/_mapCacheHas.js ***! | |
| \*********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var getMapData = __webpack_require__(/*! ./_getMapData */ "./node_modules/lodash/_getMapData.js"); | |
| /** | |
| * Checks if a map value for `key` exists. | |
| * | |
| * @private | |
| * @name has | |
| * @memberOf MapCache | |
| * @param {string} key The key of the entry to check. | |
| * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. | |
| */ | |
| function mapCacheHas(key) { | |
| return getMapData(this, key).has(key); | |
| } | |
| module.exports = mapCacheHas; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_mapCacheSet.js": | |
| /*!*********************************************!*\ | |
| !*** ./node_modules/lodash/_mapCacheSet.js ***! | |
| \*********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var getMapData = __webpack_require__(/*! ./_getMapData */ "./node_modules/lodash/_getMapData.js"); | |
| /** | |
| * Sets the map `key` to `value`. | |
| * | |
| * @private | |
| * @name set | |
| * @memberOf MapCache | |
| * @param {string} key The key of the value to set. | |
| * @param {*} value The value to set. | |
| * @returns {Object} Returns the map cache instance. | |
| */ | |
| function mapCacheSet(key, value) { | |
| var data = getMapData(this, key), | |
| size = data.size; | |
| data.set(key, value); | |
| this.size += data.size == size ? 0 : 1; | |
| return this; | |
| } | |
| module.exports = mapCacheSet; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_mapToArray.js": | |
| /*!********************************************!*\ | |
| !*** ./node_modules/lodash/_mapToArray.js ***! | |
| \********************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * Converts `map` to its key-value pairs. | |
| * | |
| * @private | |
| * @param {Object} map The map to convert. | |
| * @returns {Array} Returns the key-value pairs. | |
| */ | |
| function mapToArray(map) { | |
| var index = -1, | |
| result = Array(map.size); | |
| map.forEach(function(value, key) { | |
| result[++index] = [key, value]; | |
| }); | |
| return result; | |
| } | |
| module.exports = mapToArray; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_matchesStrictComparable.js": | |
| /*!*********************************************************!*\ | |
| !*** ./node_modules/lodash/_matchesStrictComparable.js ***! | |
| \*********************************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * A specialized version of `matchesProperty` for source values suitable | |
| * for strict equality comparisons, i.e. `===`. | |
| * | |
| * @private | |
| * @param {string} key The key of the property to get. | |
| * @param {*} srcValue The value to match. | |
| * @returns {Function} Returns the new spec function. | |
| */ | |
| function matchesStrictComparable(key, srcValue) { | |
| return function(object) { | |
| if (object == null) { | |
| return false; | |
| } | |
| return object[key] === srcValue && | |
| (srcValue !== undefined || (key in Object(object))); | |
| }; | |
| } | |
| module.exports = matchesStrictComparable; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_memoizeCapped.js": | |
| /*!***********************************************!*\ | |
| !*** ./node_modules/lodash/_memoizeCapped.js ***! | |
| \***********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var memoize = __webpack_require__(/*! ./memoize */ "./node_modules/lodash/memoize.js"); | |
| /** Used as the maximum memoize cache size. */ | |
| var MAX_MEMOIZE_SIZE = 500; | |
| /** | |
| * A specialized version of `_.memoize` which clears the memoized function's | |
| * cache when it exceeds `MAX_MEMOIZE_SIZE`. | |
| * | |
| * @private | |
| * @param {Function} func The function to have its output memoized. | |
| * @returns {Function} Returns the new memoized function. | |
| */ | |
| function memoizeCapped(func) { | |
| var result = memoize(func, function(key) { | |
| if (cache.size === MAX_MEMOIZE_SIZE) { | |
| cache.clear(); | |
| } | |
| return key; | |
| }); | |
| var cache = result.cache; | |
| return result; | |
| } | |
| module.exports = memoizeCapped; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_nativeCreate.js": | |
| /*!**********************************************!*\ | |
| !*** ./node_modules/lodash/_nativeCreate.js ***! | |
| \**********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var getNative = __webpack_require__(/*! ./_getNative */ "./node_modules/lodash/_getNative.js"); | |
| /* Built-in method references that are verified to be native. */ | |
| var nativeCreate = getNative(Object, 'create'); | |
| module.exports = nativeCreate; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_nativeKeys.js": | |
| /*!********************************************!*\ | |
| !*** ./node_modules/lodash/_nativeKeys.js ***! | |
| \********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var overArg = __webpack_require__(/*! ./_overArg */ "./node_modules/lodash/_overArg.js"); | |
| /* Built-in method references for those with the same name as other `lodash` methods. */ | |
| var nativeKeys = overArg(Object.keys, Object); | |
| module.exports = nativeKeys; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_nodeUtil.js": | |
| /*!******************************************!*\ | |
| !*** ./node_modules/lodash/_nodeUtil.js ***! | |
| \******************************************/ | |
| /***/ (function(module, exports, __webpack_require__) { | |
| /* module decorator */ module = __webpack_require__.nmd(module); | |
| var freeGlobal = __webpack_require__(/*! ./_freeGlobal */ "./node_modules/lodash/_freeGlobal.js"); | |
| /** Detect free variable `exports`. */ | |
| var freeExports = true && exports && !exports.nodeType && exports; | |
| /** Detect free variable `module`. */ | |
| var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module; | |
| /** Detect the popular CommonJS extension `module.exports`. */ | |
| var moduleExports = freeModule && freeModule.exports === freeExports; | |
| /** Detect free variable `process` from Node.js. */ | |
| var freeProcess = moduleExports && freeGlobal.process; | |
| /** Used to access faster Node.js helpers. */ | |
| var nodeUtil = (function() { | |
| try { | |
| // Use `util.types` for Node.js 10+. | |
| var types = freeModule && freeModule.require && freeModule.require('util').types; | |
| if (types) { | |
| return types; | |
| } | |
| // Legacy `process.binding('util')` for Node.js < 10. | |
| return freeProcess && freeProcess.binding && freeProcess.binding('util'); | |
| } catch (e) {} | |
| }()); | |
| module.exports = nodeUtil; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_objectToString.js": | |
| /*!************************************************!*\ | |
| !*** ./node_modules/lodash/_objectToString.js ***! | |
| \************************************************/ | |
| /***/ (function(module) { | |
| /** Used for built-in method references. */ | |
| var objectProto = Object.prototype; | |
| /** | |
| * Used to resolve the | |
| * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) | |
| * of values. | |
| */ | |
| var nativeObjectToString = objectProto.toString; | |
| /** | |
| * Converts `value` to a string using `Object.prototype.toString`. | |
| * | |
| * @private | |
| * @param {*} value The value to convert. | |
| * @returns {string} Returns the converted string. | |
| */ | |
| function objectToString(value) { | |
| return nativeObjectToString.call(value); | |
| } | |
| module.exports = objectToString; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_overArg.js": | |
| /*!*****************************************!*\ | |
| !*** ./node_modules/lodash/_overArg.js ***! | |
| \*****************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * Creates a unary function that invokes `func` with its argument transformed. | |
| * | |
| * @private | |
| * @param {Function} func The function to wrap. | |
| * @param {Function} transform The argument transform. | |
| * @returns {Function} Returns the new function. | |
| */ | |
| function overArg(func, transform) { | |
| return function(arg) { | |
| return func(transform(arg)); | |
| }; | |
| } | |
| module.exports = overArg; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_root.js": | |
| /*!**************************************!*\ | |
| !*** ./node_modules/lodash/_root.js ***! | |
| \**************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var freeGlobal = __webpack_require__(/*! ./_freeGlobal */ "./node_modules/lodash/_freeGlobal.js"); | |
| /** Detect free variable `self`. */ | |
| var freeSelf = typeof self == 'object' && self && self.Object === Object && self; | |
| /** Used as a reference to the global object. */ | |
| var root = freeGlobal || freeSelf || Function('return this')(); | |
| module.exports = root; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_setCacheAdd.js": | |
| /*!*********************************************!*\ | |
| !*** ./node_modules/lodash/_setCacheAdd.js ***! | |
| \*********************************************/ | |
| /***/ (function(module) { | |
| /** Used to stand-in for `undefined` hash values. */ | |
| var HASH_UNDEFINED = '__lodash_hash_undefined__'; | |
| /** | |
| * Adds `value` to the array cache. | |
| * | |
| * @private | |
| * @name add | |
| * @memberOf SetCache | |
| * @alias push | |
| * @param {*} value The value to cache. | |
| * @returns {Object} Returns the cache instance. | |
| */ | |
| function setCacheAdd(value) { | |
| this.__data__.set(value, HASH_UNDEFINED); | |
| return this; | |
| } | |
| module.exports = setCacheAdd; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_setCacheHas.js": | |
| /*!*********************************************!*\ | |
| !*** ./node_modules/lodash/_setCacheHas.js ***! | |
| \*********************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * Checks if `value` is in the array cache. | |
| * | |
| * @private | |
| * @name has | |
| * @memberOf SetCache | |
| * @param {*} value The value to search for. | |
| * @returns {number} Returns `true` if `value` is found, else `false`. | |
| */ | |
| function setCacheHas(value) { | |
| return this.__data__.has(value); | |
| } | |
| module.exports = setCacheHas; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_setToArray.js": | |
| /*!********************************************!*\ | |
| !*** ./node_modules/lodash/_setToArray.js ***! | |
| \********************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * Converts `set` to an array of its values. | |
| * | |
| * @private | |
| * @param {Object} set The set to convert. | |
| * @returns {Array} Returns the values. | |
| */ | |
| function setToArray(set) { | |
| var index = -1, | |
| result = Array(set.size); | |
| set.forEach(function(value) { | |
| result[++index] = value; | |
| }); | |
| return result; | |
| } | |
| module.exports = setToArray; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_stackClear.js": | |
| /*!********************************************!*\ | |
| !*** ./node_modules/lodash/_stackClear.js ***! | |
| \********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var ListCache = __webpack_require__(/*! ./_ListCache */ "./node_modules/lodash/_ListCache.js"); | |
| /** | |
| * Removes all key-value entries from the stack. | |
| * | |
| * @private | |
| * @name clear | |
| * @memberOf Stack | |
| */ | |
| function stackClear() { | |
| this.__data__ = new ListCache; | |
| this.size = 0; | |
| } | |
| module.exports = stackClear; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_stackDelete.js": | |
| /*!*********************************************!*\ | |
| !*** ./node_modules/lodash/_stackDelete.js ***! | |
| \*********************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * Removes `key` and its value from the stack. | |
| * | |
| * @private | |
| * @name delete | |
| * @memberOf Stack | |
| * @param {string} key The key of the value to remove. | |
| * @returns {boolean} Returns `true` if the entry was removed, else `false`. | |
| */ | |
| function stackDelete(key) { | |
| var data = this.__data__, | |
| result = data['delete'](key); | |
| this.size = data.size; | |
| return result; | |
| } | |
| module.exports = stackDelete; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_stackGet.js": | |
| /*!******************************************!*\ | |
| !*** ./node_modules/lodash/_stackGet.js ***! | |
| \******************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * Gets the stack value for `key`. | |
| * | |
| * @private | |
| * @name get | |
| * @memberOf Stack | |
| * @param {string} key The key of the value to get. | |
| * @returns {*} Returns the entry value. | |
| */ | |
| function stackGet(key) { | |
| return this.__data__.get(key); | |
| } | |
| module.exports = stackGet; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_stackHas.js": | |
| /*!******************************************!*\ | |
| !*** ./node_modules/lodash/_stackHas.js ***! | |
| \******************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * Checks if a stack value for `key` exists. | |
| * | |
| * @private | |
| * @name has | |
| * @memberOf Stack | |
| * @param {string} key The key of the entry to check. | |
| * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. | |
| */ | |
| function stackHas(key) { | |
| return this.__data__.has(key); | |
| } | |
| module.exports = stackHas; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_stackSet.js": | |
| /*!******************************************!*\ | |
| !*** ./node_modules/lodash/_stackSet.js ***! | |
| \******************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var ListCache = __webpack_require__(/*! ./_ListCache */ "./node_modules/lodash/_ListCache.js"), | |
| Map = __webpack_require__(/*! ./_Map */ "./node_modules/lodash/_Map.js"), | |
| MapCache = __webpack_require__(/*! ./_MapCache */ "./node_modules/lodash/_MapCache.js"); | |
| /** Used as the size to enable large array optimizations. */ | |
| var LARGE_ARRAY_SIZE = 200; | |
| /** | |
| * Sets the stack `key` to `value`. | |
| * | |
| * @private | |
| * @name set | |
| * @memberOf Stack | |
| * @param {string} key The key of the value to set. | |
| * @param {*} value The value to set. | |
| * @returns {Object} Returns the stack cache instance. | |
| */ | |
| function stackSet(key, value) { | |
| var data = this.__data__; | |
| if (data instanceof ListCache) { | |
| var pairs = data.__data__; | |
| if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { | |
| pairs.push([key, value]); | |
| this.size = ++data.size; | |
| return this; | |
| } | |
| data = this.__data__ = new MapCache(pairs); | |
| } | |
| data.set(key, value); | |
| this.size = data.size; | |
| return this; | |
| } | |
| module.exports = stackSet; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_stringToPath.js": | |
| /*!**********************************************!*\ | |
| !*** ./node_modules/lodash/_stringToPath.js ***! | |
| \**********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var memoizeCapped = __webpack_require__(/*! ./_memoizeCapped */ "./node_modules/lodash/_memoizeCapped.js"); | |
| /** Used to match property names within property paths. */ | |
| var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; | |
| /** Used to match backslashes in property paths. */ | |
| var reEscapeChar = /\\(\\)?/g; | |
| /** | |
| * Converts `string` to a property path array. | |
| * | |
| * @private | |
| * @param {string} string The string to convert. | |
| * @returns {Array} Returns the property path array. | |
| */ | |
| var stringToPath = memoizeCapped(function(string) { | |
| var result = []; | |
| if (string.charCodeAt(0) === 46 /* . */) { | |
| result.push(''); | |
| } | |
| string.replace(rePropName, function(match, number, quote, subString) { | |
| result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); | |
| }); | |
| return result; | |
| }); | |
| module.exports = stringToPath; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_toKey.js": | |
| /*!***************************************!*\ | |
| !*** ./node_modules/lodash/_toKey.js ***! | |
| \***************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var isSymbol = __webpack_require__(/*! ./isSymbol */ "./node_modules/lodash/isSymbol.js"); | |
| /** Used as references for various `Number` constants. */ | |
| var INFINITY = 1 / 0; | |
| /** | |
| * Converts `value` to a string key if it's not a string or symbol. | |
| * | |
| * @private | |
| * @param {*} value The value to inspect. | |
| * @returns {string|symbol} Returns the key. | |
| */ | |
| function toKey(value) { | |
| if (typeof value == 'string' || isSymbol(value)) { | |
| return value; | |
| } | |
| var result = (value + ''); | |
| return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; | |
| } | |
| module.exports = toKey; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/_toSource.js": | |
| /*!******************************************!*\ | |
| !*** ./node_modules/lodash/_toSource.js ***! | |
| \******************************************/ | |
| /***/ (function(module) { | |
| /** Used for built-in method references. */ | |
| var funcProto = Function.prototype; | |
| /** Used to resolve the decompiled source of functions. */ | |
| var funcToString = funcProto.toString; | |
| /** | |
| * Converts `func` to its source code. | |
| * | |
| * @private | |
| * @param {Function} func The function to convert. | |
| * @returns {string} Returns the source code. | |
| */ | |
| function toSource(func) { | |
| if (func != null) { | |
| try { | |
| return funcToString.call(func); | |
| } catch (e) {} | |
| try { | |
| return (func + ''); | |
| } catch (e) {} | |
| } | |
| return ''; | |
| } | |
| module.exports = toSource; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/eq.js": | |
| /*!***********************************!*\ | |
| !*** ./node_modules/lodash/eq.js ***! | |
| \***********************************/ | |
| /***/ (function(module) { | |
| /** | |
| * Performs a | |
| * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) | |
| * comparison between two values to determine if they are equivalent. | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @since 4.0.0 | |
| * @category Lang | |
| * @param {*} value The value to compare. | |
| * @param {*} other The other value to compare. | |
| * @returns {boolean} Returns `true` if the values are equivalent, else `false`. | |
| * @example | |
| * | |
| * var object = { 'a': 1 }; | |
| * var other = { 'a': 1 }; | |
| * | |
| * _.eq(object, object); | |
| * // => true | |
| * | |
| * _.eq(object, other); | |
| * // => false | |
| * | |
| * _.eq('a', 'a'); | |
| * // => true | |
| * | |
| * _.eq('a', Object('a')); | |
| * // => false | |
| * | |
| * _.eq(NaN, NaN); | |
| * // => true | |
| */ | |
| function eq(value, other) { | |
| return value === other || (value !== value && other !== other); | |
| } | |
| module.exports = eq; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/get.js": | |
| /*!************************************!*\ | |
| !*** ./node_modules/lodash/get.js ***! | |
| \************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseGet = __webpack_require__(/*! ./_baseGet */ "./node_modules/lodash/_baseGet.js"); | |
| /** | |
| * Gets the value at `path` of `object`. If the resolved value is | |
| * `undefined`, the `defaultValue` is returned in its place. | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @since 3.7.0 | |
| * @category Object | |
| * @param {Object} object The object to query. | |
| * @param {Array|string} path The path of the property to get. | |
| * @param {*} [defaultValue] The value returned for `undefined` resolved values. | |
| * @returns {*} Returns the resolved value. | |
| * @example | |
| * | |
| * var object = { 'a': [{ 'b': { 'c': 3 } }] }; | |
| * | |
| * _.get(object, 'a[0].b.c'); | |
| * // => 3 | |
| * | |
| * _.get(object, ['a', '0', 'b', 'c']); | |
| * // => 3 | |
| * | |
| * _.get(object, 'a.b.c', 'default'); | |
| * // => 'default' | |
| */ | |
| function get(object, path, defaultValue) { | |
| var result = object == null ? undefined : baseGet(object, path); | |
| return result === undefined ? defaultValue : result; | |
| } | |
| module.exports = get; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/hasIn.js": | |
| /*!**************************************!*\ | |
| !*** ./node_modules/lodash/hasIn.js ***! | |
| \**************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseHasIn = __webpack_require__(/*! ./_baseHasIn */ "./node_modules/lodash/_baseHasIn.js"), | |
| hasPath = __webpack_require__(/*! ./_hasPath */ "./node_modules/lodash/_hasPath.js"); | |
| /** | |
| * Checks if `path` is a direct or inherited property of `object`. | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @since 4.0.0 | |
| * @category Object | |
| * @param {Object} object The object to query. | |
| * @param {Array|string} path The path to check. | |
| * @returns {boolean} Returns `true` if `path` exists, else `false`. | |
| * @example | |
| * | |
| * var object = _.create({ 'a': _.create({ 'b': 2 }) }); | |
| * | |
| * _.hasIn(object, 'a'); | |
| * // => true | |
| * | |
| * _.hasIn(object, 'a.b'); | |
| * // => true | |
| * | |
| * _.hasIn(object, ['a', 'b']); | |
| * // => true | |
| * | |
| * _.hasIn(object, 'b'); | |
| * // => false | |
| */ | |
| function hasIn(object, path) { | |
| return object != null && hasPath(object, path, baseHasIn); | |
| } | |
| module.exports = hasIn; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/identity.js": | |
| /*!*****************************************!*\ | |
| !*** ./node_modules/lodash/identity.js ***! | |
| \*****************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * This method returns the first argument it receives. | |
| * | |
| * @static | |
| * @since 0.1.0 | |
| * @memberOf _ | |
| * @category Util | |
| * @param {*} value Any value. | |
| * @returns {*} Returns `value`. | |
| * @example | |
| * | |
| * var object = { 'a': 1 }; | |
| * | |
| * console.log(_.identity(object) === object); | |
| * // => true | |
| */ | |
| function identity(value) { | |
| return value; | |
| } | |
| module.exports = identity; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/isArguments.js": | |
| /*!********************************************!*\ | |
| !*** ./node_modules/lodash/isArguments.js ***! | |
| \********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseIsArguments = __webpack_require__(/*! ./_baseIsArguments */ "./node_modules/lodash/_baseIsArguments.js"), | |
| isObjectLike = __webpack_require__(/*! ./isObjectLike */ "./node_modules/lodash/isObjectLike.js"); | |
| /** Used for built-in method references. */ | |
| var objectProto = Object.prototype; | |
| /** Used to check objects for own properties. */ | |
| var hasOwnProperty = objectProto.hasOwnProperty; | |
| /** Built-in value references. */ | |
| var propertyIsEnumerable = objectProto.propertyIsEnumerable; | |
| /** | |
| * Checks if `value` is likely an `arguments` object. | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @since 0.1.0 | |
| * @category Lang | |
| * @param {*} value The value to check. | |
| * @returns {boolean} Returns `true` if `value` is an `arguments` object, | |
| * else `false`. | |
| * @example | |
| * | |
| * _.isArguments(function() { return arguments; }()); | |
| * // => true | |
| * | |
| * _.isArguments([1, 2, 3]); | |
| * // => false | |
| */ | |
| var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { | |
| return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && | |
| !propertyIsEnumerable.call(value, 'callee'); | |
| }; | |
| module.exports = isArguments; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/isArray.js": | |
| /*!****************************************!*\ | |
| !*** ./node_modules/lodash/isArray.js ***! | |
| \****************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * Checks if `value` is classified as an `Array` object. | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @since 0.1.0 | |
| * @category Lang | |
| * @param {*} value The value to check. | |
| * @returns {boolean} Returns `true` if `value` is an array, else `false`. | |
| * @example | |
| * | |
| * _.isArray([1, 2, 3]); | |
| * // => true | |
| * | |
| * _.isArray(document.body.children); | |
| * // => false | |
| * | |
| * _.isArray('abc'); | |
| * // => false | |
| * | |
| * _.isArray(_.noop); | |
| * // => false | |
| */ | |
| var isArray = Array.isArray; | |
| module.exports = isArray; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/isArrayLike.js": | |
| /*!********************************************!*\ | |
| !*** ./node_modules/lodash/isArrayLike.js ***! | |
| \********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var isFunction = __webpack_require__(/*! ./isFunction */ "./node_modules/lodash/isFunction.js"), | |
| isLength = __webpack_require__(/*! ./isLength */ "./node_modules/lodash/isLength.js"); | |
| /** | |
| * Checks if `value` is array-like. A value is considered array-like if it's | |
| * not a function and has a `value.length` that's an integer greater than or | |
| * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @since 4.0.0 | |
| * @category Lang | |
| * @param {*} value The value to check. | |
| * @returns {boolean} Returns `true` if `value` is array-like, else `false`. | |
| * @example | |
| * | |
| * _.isArrayLike([1, 2, 3]); | |
| * // => true | |
| * | |
| * _.isArrayLike(document.body.children); | |
| * // => true | |
| * | |
| * _.isArrayLike('abc'); | |
| * // => true | |
| * | |
| * _.isArrayLike(_.noop); | |
| * // => false | |
| */ | |
| function isArrayLike(value) { | |
| return value != null && isLength(value.length) && !isFunction(value); | |
| } | |
| module.exports = isArrayLike; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/isBuffer.js": | |
| /*!*****************************************!*\ | |
| !*** ./node_modules/lodash/isBuffer.js ***! | |
| \*****************************************/ | |
| /***/ (function(module, exports, __webpack_require__) { | |
| /* module decorator */ module = __webpack_require__.nmd(module); | |
| var root = __webpack_require__(/*! ./_root */ "./node_modules/lodash/_root.js"), | |
| stubFalse = __webpack_require__(/*! ./stubFalse */ "./node_modules/lodash/stubFalse.js"); | |
| /** Detect free variable `exports`. */ | |
| var freeExports = true && exports && !exports.nodeType && exports; | |
| /** Detect free variable `module`. */ | |
| var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module; | |
| /** Detect the popular CommonJS extension `module.exports`. */ | |
| var moduleExports = freeModule && freeModule.exports === freeExports; | |
| /** Built-in value references. */ | |
| var Buffer = moduleExports ? root.Buffer : undefined; | |
| /* Built-in method references for those with the same name as other `lodash` methods. */ | |
| var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; | |
| /** | |
| * Checks if `value` is a buffer. | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @since 4.3.0 | |
| * @category Lang | |
| * @param {*} value The value to check. | |
| * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. | |
| * @example | |
| * | |
| * _.isBuffer(new Buffer(2)); | |
| * // => true | |
| * | |
| * _.isBuffer(new Uint8Array(2)); | |
| * // => false | |
| */ | |
| var isBuffer = nativeIsBuffer || stubFalse; | |
| module.exports = isBuffer; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/isFunction.js": | |
| /*!*******************************************!*\ | |
| !*** ./node_modules/lodash/isFunction.js ***! | |
| \*******************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseGetTag = __webpack_require__(/*! ./_baseGetTag */ "./node_modules/lodash/_baseGetTag.js"), | |
| isObject = __webpack_require__(/*! ./isObject */ "./node_modules/lodash/isObject.js"); | |
| /** `Object#toString` result references. */ | |
| var asyncTag = '[object AsyncFunction]', | |
| funcTag = '[object Function]', | |
| genTag = '[object GeneratorFunction]', | |
| proxyTag = '[object Proxy]'; | |
| /** | |
| * Checks if `value` is classified as a `Function` object. | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @since 0.1.0 | |
| * @category Lang | |
| * @param {*} value The value to check. | |
| * @returns {boolean} Returns `true` if `value` is a function, else `false`. | |
| * @example | |
| * | |
| * _.isFunction(_); | |
| * // => true | |
| * | |
| * _.isFunction(/abc/); | |
| * // => false | |
| */ | |
| function isFunction(value) { | |
| if (!isObject(value)) { | |
| return false; | |
| } | |
| // The use of `Object#toString` avoids issues with the `typeof` operator | |
| // in Safari 9 which returns 'object' for typed arrays and other constructors. | |
| var tag = baseGetTag(value); | |
| return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; | |
| } | |
| module.exports = isFunction; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/isLength.js": | |
| /*!*****************************************!*\ | |
| !*** ./node_modules/lodash/isLength.js ***! | |
| \*****************************************/ | |
| /***/ (function(module) { | |
| /** Used as references for various `Number` constants. */ | |
| var MAX_SAFE_INTEGER = 9007199254740991; | |
| /** | |
| * Checks if `value` is a valid array-like length. | |
| * | |
| * **Note:** This method is loosely based on | |
| * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @since 4.0.0 | |
| * @category Lang | |
| * @param {*} value The value to check. | |
| * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. | |
| * @example | |
| * | |
| * _.isLength(3); | |
| * // => true | |
| * | |
| * _.isLength(Number.MIN_VALUE); | |
| * // => false | |
| * | |
| * _.isLength(Infinity); | |
| * // => false | |
| * | |
| * _.isLength('3'); | |
| * // => false | |
| */ | |
| function isLength(value) { | |
| return typeof value == 'number' && | |
| value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; | |
| } | |
| module.exports = isLength; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/isObject.js": | |
| /*!*****************************************!*\ | |
| !*** ./node_modules/lodash/isObject.js ***! | |
| \*****************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * Checks if `value` is the | |
| * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) | |
| * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @since 0.1.0 | |
| * @category Lang | |
| * @param {*} value The value to check. | |
| * @returns {boolean} Returns `true` if `value` is an object, else `false`. | |
| * @example | |
| * | |
| * _.isObject({}); | |
| * // => true | |
| * | |
| * _.isObject([1, 2, 3]); | |
| * // => true | |
| * | |
| * _.isObject(_.noop); | |
| * // => true | |
| * | |
| * _.isObject(null); | |
| * // => false | |
| */ | |
| function isObject(value) { | |
| var type = typeof value; | |
| return value != null && (type == 'object' || type == 'function'); | |
| } | |
| module.exports = isObject; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/isObjectLike.js": | |
| /*!*********************************************!*\ | |
| !*** ./node_modules/lodash/isObjectLike.js ***! | |
| \*********************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * Checks if `value` is object-like. A value is object-like if it's not `null` | |
| * and has a `typeof` result of "object". | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @since 4.0.0 | |
| * @category Lang | |
| * @param {*} value The value to check. | |
| * @returns {boolean} Returns `true` if `value` is object-like, else `false`. | |
| * @example | |
| * | |
| * _.isObjectLike({}); | |
| * // => true | |
| * | |
| * _.isObjectLike([1, 2, 3]); | |
| * // => true | |
| * | |
| * _.isObjectLike(_.noop); | |
| * // => false | |
| * | |
| * _.isObjectLike(null); | |
| * // => false | |
| */ | |
| function isObjectLike(value) { | |
| return value != null && typeof value == 'object'; | |
| } | |
| module.exports = isObjectLike; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/isSymbol.js": | |
| /*!*****************************************!*\ | |
| !*** ./node_modules/lodash/isSymbol.js ***! | |
| \*****************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseGetTag = __webpack_require__(/*! ./_baseGetTag */ "./node_modules/lodash/_baseGetTag.js"), | |
| isObjectLike = __webpack_require__(/*! ./isObjectLike */ "./node_modules/lodash/isObjectLike.js"); | |
| /** `Object#toString` result references. */ | |
| var symbolTag = '[object Symbol]'; | |
| /** | |
| * Checks if `value` is classified as a `Symbol` primitive or object. | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @since 4.0.0 | |
| * @category Lang | |
| * @param {*} value The value to check. | |
| * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. | |
| * @example | |
| * | |
| * _.isSymbol(Symbol.iterator); | |
| * // => true | |
| * | |
| * _.isSymbol('abc'); | |
| * // => false | |
| */ | |
| function isSymbol(value) { | |
| return typeof value == 'symbol' || | |
| (isObjectLike(value) && baseGetTag(value) == symbolTag); | |
| } | |
| module.exports = isSymbol; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/isTypedArray.js": | |
| /*!*********************************************!*\ | |
| !*** ./node_modules/lodash/isTypedArray.js ***! | |
| \*********************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseIsTypedArray = __webpack_require__(/*! ./_baseIsTypedArray */ "./node_modules/lodash/_baseIsTypedArray.js"), | |
| baseUnary = __webpack_require__(/*! ./_baseUnary */ "./node_modules/lodash/_baseUnary.js"), | |
| nodeUtil = __webpack_require__(/*! ./_nodeUtil */ "./node_modules/lodash/_nodeUtil.js"); | |
| /* Node.js helper references. */ | |
| var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; | |
| /** | |
| * Checks if `value` is classified as a typed array. | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @since 3.0.0 | |
| * @category Lang | |
| * @param {*} value The value to check. | |
| * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. | |
| * @example | |
| * | |
| * _.isTypedArray(new Uint8Array); | |
| * // => true | |
| * | |
| * _.isTypedArray([]); | |
| * // => false | |
| */ | |
| var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; | |
| module.exports = isTypedArray; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/keys.js": | |
| /*!*************************************!*\ | |
| !*** ./node_modules/lodash/keys.js ***! | |
| \*************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var arrayLikeKeys = __webpack_require__(/*! ./_arrayLikeKeys */ "./node_modules/lodash/_arrayLikeKeys.js"), | |
| baseKeys = __webpack_require__(/*! ./_baseKeys */ "./node_modules/lodash/_baseKeys.js"), | |
| isArrayLike = __webpack_require__(/*! ./isArrayLike */ "./node_modules/lodash/isArrayLike.js"); | |
| /** | |
| * Creates an array of the own enumerable property names of `object`. | |
| * | |
| * **Note:** Non-object values are coerced to objects. See the | |
| * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) | |
| * for more details. | |
| * | |
| * @static | |
| * @since 0.1.0 | |
| * @memberOf _ | |
| * @category Object | |
| * @param {Object} object The object to query. | |
| * @returns {Array} Returns the array of property names. | |
| * @example | |
| * | |
| * function Foo() { | |
| * this.a = 1; | |
| * this.b = 2; | |
| * } | |
| * | |
| * Foo.prototype.c = 3; | |
| * | |
| * _.keys(new Foo); | |
| * // => ['a', 'b'] (iteration order is not guaranteed) | |
| * | |
| * _.keys('hi'); | |
| * // => ['0', '1'] | |
| */ | |
| function keys(object) { | |
| return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); | |
| } | |
| module.exports = keys; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/mapKeys.js": | |
| /*!****************************************!*\ | |
| !*** ./node_modules/lodash/mapKeys.js ***! | |
| \****************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseAssignValue = __webpack_require__(/*! ./_baseAssignValue */ "./node_modules/lodash/_baseAssignValue.js"), | |
| baseForOwn = __webpack_require__(/*! ./_baseForOwn */ "./node_modules/lodash/_baseForOwn.js"), | |
| baseIteratee = __webpack_require__(/*! ./_baseIteratee */ "./node_modules/lodash/_baseIteratee.js"); | |
| /** | |
| * The opposite of `_.mapValues`; this method creates an object with the | |
| * same values as `object` and keys generated by running each own enumerable | |
| * string keyed property of `object` thru `iteratee`. The iteratee is invoked | |
| * with three arguments: (value, key, object). | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @since 3.8.0 | |
| * @category Object | |
| * @param {Object} object The object to iterate over. | |
| * @param {Function} [iteratee=_.identity] The function invoked per iteration. | |
| * @returns {Object} Returns the new mapped object. | |
| * @see _.mapValues | |
| * @example | |
| * | |
| * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { | |
| * return key + value; | |
| * }); | |
| * // => { 'a1': 1, 'b2': 2 } | |
| */ | |
| function mapKeys(object, iteratee) { | |
| var result = {}; | |
| iteratee = baseIteratee(iteratee, 3); | |
| baseForOwn(object, function(value, key, object) { | |
| baseAssignValue(result, iteratee(value, key, object), value); | |
| }); | |
| return result; | |
| } | |
| module.exports = mapKeys; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/memoize.js": | |
| /*!****************************************!*\ | |
| !*** ./node_modules/lodash/memoize.js ***! | |
| \****************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var MapCache = __webpack_require__(/*! ./_MapCache */ "./node_modules/lodash/_MapCache.js"); | |
| /** Error message constants. */ | |
| var FUNC_ERROR_TEXT = 'Expected a function'; | |
| /** | |
| * Creates a function that memoizes the result of `func`. If `resolver` is | |
| * provided, it determines the cache key for storing the result based on the | |
| * arguments provided to the memoized function. By default, the first argument | |
| * provided to the memoized function is used as the map cache key. The `func` | |
| * is invoked with the `this` binding of the memoized function. | |
| * | |
| * **Note:** The cache is exposed as the `cache` property on the memoized | |
| * function. Its creation may be customized by replacing the `_.memoize.Cache` | |
| * constructor with one whose instances implement the | |
| * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) | |
| * method interface of `clear`, `delete`, `get`, `has`, and `set`. | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @since 0.1.0 | |
| * @category Function | |
| * @param {Function} func The function to have its output memoized. | |
| * @param {Function} [resolver] The function to resolve the cache key. | |
| * @returns {Function} Returns the new memoized function. | |
| * @example | |
| * | |
| * var object = { 'a': 1, 'b': 2 }; | |
| * var other = { 'c': 3, 'd': 4 }; | |
| * | |
| * var values = _.memoize(_.values); | |
| * values(object); | |
| * // => [1, 2] | |
| * | |
| * values(other); | |
| * // => [3, 4] | |
| * | |
| * object.a = 2; | |
| * values(object); | |
| * // => [1, 2] | |
| * | |
| * // Modify the result cache. | |
| * values.cache.set(object, ['a', 'b']); | |
| * values(object); | |
| * // => ['a', 'b'] | |
| * | |
| * // Replace `_.memoize.Cache`. | |
| * _.memoize.Cache = WeakMap; | |
| */ | |
| function memoize(func, resolver) { | |
| if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { | |
| throw new TypeError(FUNC_ERROR_TEXT); | |
| } | |
| var memoized = function() { | |
| var args = arguments, | |
| key = resolver ? resolver.apply(this, args) : args[0], | |
| cache = memoized.cache; | |
| if (cache.has(key)) { | |
| return cache.get(key); | |
| } | |
| var result = func.apply(this, args); | |
| memoized.cache = cache.set(key, result) || cache; | |
| return result; | |
| }; | |
| memoized.cache = new (memoize.Cache || MapCache); | |
| return memoized; | |
| } | |
| // Expose `MapCache`. | |
| memoize.Cache = MapCache; | |
| module.exports = memoize; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/property.js": | |
| /*!*****************************************!*\ | |
| !*** ./node_modules/lodash/property.js ***! | |
| \*****************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseProperty = __webpack_require__(/*! ./_baseProperty */ "./node_modules/lodash/_baseProperty.js"), | |
| basePropertyDeep = __webpack_require__(/*! ./_basePropertyDeep */ "./node_modules/lodash/_basePropertyDeep.js"), | |
| isKey = __webpack_require__(/*! ./_isKey */ "./node_modules/lodash/_isKey.js"), | |
| toKey = __webpack_require__(/*! ./_toKey */ "./node_modules/lodash/_toKey.js"); | |
| /** | |
| * Creates a function that returns the value at `path` of a given object. | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @since 2.4.0 | |
| * @category Util | |
| * @param {Array|string} path The path of the property to get. | |
| * @returns {Function} Returns the new accessor function. | |
| * @example | |
| * | |
| * var objects = [ | |
| * { 'a': { 'b': 2 } }, | |
| * { 'a': { 'b': 1 } } | |
| * ]; | |
| * | |
| * _.map(objects, _.property('a.b')); | |
| * // => [2, 1] | |
| * | |
| * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); | |
| * // => [1, 2] | |
| */ | |
| function property(path) { | |
| return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); | |
| } | |
| module.exports = property; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/stubArray.js": | |
| /*!******************************************!*\ | |
| !*** ./node_modules/lodash/stubArray.js ***! | |
| \******************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * This method returns a new empty array. | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @since 4.13.0 | |
| * @category Util | |
| * @returns {Array} Returns the new empty array. | |
| * @example | |
| * | |
| * var arrays = _.times(2, _.stubArray); | |
| * | |
| * console.log(arrays); | |
| * // => [[], []] | |
| * | |
| * console.log(arrays[0] === arrays[1]); | |
| * // => false | |
| */ | |
| function stubArray() { | |
| return []; | |
| } | |
| module.exports = stubArray; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/stubFalse.js": | |
| /*!******************************************!*\ | |
| !*** ./node_modules/lodash/stubFalse.js ***! | |
| \******************************************/ | |
| /***/ (function(module) { | |
| /** | |
| * This method returns `false`. | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @since 4.13.0 | |
| * @category Util | |
| * @returns {boolean} Returns `false`. | |
| * @example | |
| * | |
| * _.times(2, _.stubFalse); | |
| * // => [false, false] | |
| */ | |
| function stubFalse() { | |
| return false; | |
| } | |
| module.exports = stubFalse; | |
| /***/ }), | |
| /***/ "./node_modules/lodash/toString.js": | |
| /*!*****************************************!*\ | |
| !*** ./node_modules/lodash/toString.js ***! | |
| \*****************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| var baseToString = __webpack_require__(/*! ./_baseToString */ "./node_modules/lodash/_baseToString.js"); | |
| /** | |
| * Converts `value` to a string. An empty string is returned for `null` | |
| * and `undefined` values. The sign of `-0` is preserved. | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @since 4.0.0 | |
| * @category Lang | |
| * @param {*} value The value to convert. | |
| * @returns {string} Returns the converted string. | |
| * @example | |
| * | |
| * _.toString(null); | |
| * // => '' | |
| * | |
| * _.toString(-0); | |
| * // => '-0' | |
| * | |
| * _.toString([1, 2, 3]); | |
| * // => '1,2,3' | |
| */ | |
| function toString(value) { | |
| return value == null ? '' : baseToString(value); | |
| } | |
| module.exports = toString; | |
| /***/ }), | |
| /***/ "./src/sass/header.scss": | |
| /*!******************************!*\ | |
| !*** ./src/sass/header.scss ***! | |
| \******************************/ | |
| /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| "use strict"; | |
| __webpack_require__.r(__webpack_exports__); | |
| // extracted by mini-css-extract-plugin | |
| /***/ }), | |
| /***/ "./node_modules/object-assign/index.js": | |
| /*!*********************************************!*\ | |
| !*** ./node_modules/object-assign/index.js ***! | |
| \*********************************************/ | |
| /***/ (function(module) { | |
| "use strict"; | |
| /* | |
| object-assign | |
| (c) Sindre Sorhus | |
| @license MIT | |
| */ | |
| /* eslint-disable no-unused-vars */ | |
| var getOwnPropertySymbols = Object.getOwnPropertySymbols; | |
| var hasOwnProperty = Object.prototype.hasOwnProperty; | |
| var propIsEnumerable = Object.prototype.propertyIsEnumerable; | |
| function toObject(val) { | |
| if (val === null || val === undefined) { | |
| throw new TypeError('Object.assign cannot be called with null or undefined'); | |
| } | |
| return Object(val); | |
| } | |
| function shouldUseNative() { | |
| try { | |
| if (!Object.assign) { | |
| return false; | |
| } | |
| // Detect buggy property enumeration order in older V8 versions. | |
| // https://bugs.chromium.org/p/v8/issues/detail?id=4118 | |
| var test1 = new String('abc'); // eslint-disable-line no-new-wrappers | |
| test1[5] = 'de'; | |
| if (Object.getOwnPropertyNames(test1)[0] === '5') { | |
| return false; | |
| } | |
| // https://bugs.chromium.org/p/v8/issues/detail?id=3056 | |
| var test2 = {}; | |
| for (var i = 0; i < 10; i++) { | |
| test2['_' + String.fromCharCode(i)] = i; | |
| } | |
| var order2 = Object.getOwnPropertyNames(test2).map(function (n) { | |
| return test2[n]; | |
| }); | |
| if (order2.join('') !== '0123456789') { | |
| return false; | |
| } | |
| // https://bugs.chromium.org/p/v8/issues/detail?id=3056 | |
| var test3 = {}; | |
| 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { | |
| test3[letter] = letter; | |
| }); | |
| if (Object.keys(Object.assign({}, test3)).join('') !== | |
| 'abcdefghijklmnopqrst') { | |
| return false; | |
| } | |
| return true; | |
| } catch (err) { | |
| // We don't expect any of the above to throw, but better to be safe. | |
| return false; | |
| } | |
| } | |
| module.exports = shouldUseNative() ? Object.assign : function (target, source) { | |
| var from; | |
| var to = toObject(target); | |
| var symbols; | |
| for (var s = 1; s < arguments.length; s++) { | |
| from = Object(arguments[s]); | |
| for (var key in from) { | |
| if (hasOwnProperty.call(from, key)) { | |
| to[key] = from[key]; | |
| } | |
| } | |
| if (getOwnPropertySymbols) { | |
| symbols = getOwnPropertySymbols(from); | |
| for (var i = 0; i < symbols.length; i++) { | |
| if (propIsEnumerable.call(from, symbols[i])) { | |
| to[symbols[i]] = from[symbols[i]]; | |
| } | |
| } | |
| } | |
| } | |
| return to; | |
| }; | |
| /***/ }), | |
| /***/ "./node_modules/prop-types/checkPropTypes.js": | |
| /*!***************************************************!*\ | |
| !*** ./node_modules/prop-types/checkPropTypes.js ***! | |
| \***************************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| "use strict"; | |
| /** | |
| * Copyright (c) 2013-present, Facebook, Inc. | |
| * | |
| * This source code is licensed under the MIT license found in the | |
| * LICENSE file in the root directory of this source tree. | |
| */ | |
| var printWarning = function() {}; | |
| if (true) { | |
| var ReactPropTypesSecret = __webpack_require__(/*! ./lib/ReactPropTypesSecret */ "./node_modules/prop-types/lib/ReactPropTypesSecret.js"); | |
| var loggedTypeFailures = {}; | |
| var has = __webpack_require__(/*! ./lib/has */ "./node_modules/prop-types/lib/has.js"); | |
| printWarning = function(text) { | |
| var message = 'Warning: ' + text; | |
| if (typeof console !== 'undefined') { | |
| console.error(message); | |
| } | |
| try { | |
| // --- Welcome to debugging React --- | |
| // This error was thrown as a convenience so that you can use this stack | |
| // to find the callsite that caused this warning to fire. | |
| throw new Error(message); | |
| } catch (x) { /**/ } | |
| }; | |
| } | |
| /** | |
| * Assert that the values match with the type specs. | |
| * Error messages are memorized and will only be shown once. | |
| * | |
| * @param {object} typeSpecs Map of name to a ReactPropType | |
| * @param {object} values Runtime values that need to be type-checked | |
| * @param {string} location e.g. "prop", "context", "child context" | |
| * @param {string} componentName Name of the component for error messages. | |
| * @param {?Function} getStack Returns the component stack. | |
| * @private | |
| */ | |
| function checkPropTypes(typeSpecs, values, location, componentName, getStack) { | |
| if (true) { | |
| for (var typeSpecName in typeSpecs) { | |
| if (has(typeSpecs, typeSpecName)) { | |
| var error; | |
| // Prop type validation may throw. In case they do, we don't want to | |
| // fail the render phase where it didn't fail before. So we log it. | |
| // After these have been cleaned up, we'll let them throw. | |
| try { | |
| // This is intentionally an invariant that gets caught. It's the same | |
| // behavior as without this statement except with a better message. | |
| if (typeof typeSpecs[typeSpecName] !== 'function') { | |
| var err = Error( | |
| (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + | |
| 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + | |
| 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.' | |
| ); | |
| err.name = 'Invariant Violation'; | |
| throw err; | |
| } | |
| error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); | |
| } catch (ex) { | |
| error = ex; | |
| } | |
| if (error && !(error instanceof Error)) { | |
| printWarning( | |
| (componentName || 'React class') + ': type specification of ' + | |
| location + ' `' + typeSpecName + '` is invalid; the type checker ' + | |
| 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + | |
| 'You may have forgotten to pass an argument to the type checker ' + | |
| 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + | |
| 'shape all require an argument).' | |
| ); | |
| } | |
| if (error instanceof Error && !(error.message in loggedTypeFailures)) { | |
| // Only monitor this failure once because there tends to be a lot of the | |
| // same error. | |
| loggedTypeFailures[error.message] = true; | |
| var stack = getStack ? getStack() : ''; | |
| printWarning( | |
| 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') | |
| ); | |
| } | |
| } | |
| } | |
| } | |
| } | |
| /** | |
| * Resets warning cache when testing. | |
| * | |
| * @private | |
| */ | |
| checkPropTypes.resetWarningCache = function() { | |
| if (true) { | |
| loggedTypeFailures = {}; | |
| } | |
| } | |
| module.exports = checkPropTypes; | |
| /***/ }), | |
| /***/ "./node_modules/prop-types/factoryWithTypeCheckers.js": | |
| /*!************************************************************!*\ | |
| !*** ./node_modules/prop-types/factoryWithTypeCheckers.js ***! | |
| \************************************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| "use strict"; | |
| /** | |
| * Copyright (c) 2013-present, Facebook, Inc. | |
| * | |
| * This source code is licensed under the MIT license found in the | |
| * LICENSE file in the root directory of this source tree. | |
| */ | |
| var ReactIs = __webpack_require__(/*! react-is */ "./node_modules/react-is/index.js"); | |
| var assign = __webpack_require__(/*! object-assign */ "./node_modules/object-assign/index.js"); | |
| var ReactPropTypesSecret = __webpack_require__(/*! ./lib/ReactPropTypesSecret */ "./node_modules/prop-types/lib/ReactPropTypesSecret.js"); | |
| var has = __webpack_require__(/*! ./lib/has */ "./node_modules/prop-types/lib/has.js"); | |
| var checkPropTypes = __webpack_require__(/*! ./checkPropTypes */ "./node_modules/prop-types/checkPropTypes.js"); | |
| var printWarning = function() {}; | |
| if (true) { | |
| printWarning = function(text) { | |
| var message = 'Warning: ' + text; | |
| if (typeof console !== 'undefined') { | |
| console.error(message); | |
| } | |
| try { | |
| // --- Welcome to debugging React --- | |
| // This error was thrown as a convenience so that you can use this stack | |
| // to find the callsite that caused this warning to fire. | |
| throw new Error(message); | |
| } catch (x) {} | |
| }; | |
| } | |
| function emptyFunctionThatReturnsNull() { | |
| return null; | |
| } | |
| module.exports = function(isValidElement, throwOnDirectAccess) { | |
| /* global Symbol */ | |
| var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; | |
| var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec. | |
| /** | |
| * Returns the iterator method function contained on the iterable object. | |
| * | |
| * Be sure to invoke the function with the iterable as context: | |
| * | |
| * var iteratorFn = getIteratorFn(myIterable); | |
| * if (iteratorFn) { | |
| * var iterator = iteratorFn.call(myIterable); | |
| * ... | |
| * } | |
| * | |
| * @param {?object} maybeIterable | |
| * @return {?function} | |
| */ | |
| function getIteratorFn(maybeIterable) { | |
| var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); | |
| if (typeof iteratorFn === 'function') { | |
| return iteratorFn; | |
| } | |
| } | |
| /** | |
| * Collection of methods that allow declaration and validation of props that are | |
| * supplied to React components. Example usage: | |
| * | |
| * var Props = require('ReactPropTypes'); | |
| * var MyArticle = React.createClass({ | |
| * propTypes: { | |
| * // An optional string prop named "description". | |
| * description: Props.string, | |
| * | |
| * // A required enum prop named "category". | |
| * category: Props.oneOf(['News','Photos']).isRequired, | |
| * | |
| * // A prop named "dialog" that requires an instance of Dialog. | |
| * dialog: Props.instanceOf(Dialog).isRequired | |
| * }, | |
| * render: function() { ... } | |
| * }); | |
| * | |
| * A more formal specification of how these methods are used: | |
| * | |
| * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...) | |
| * decl := ReactPropTypes.{type}(.isRequired)? | |
| * | |
| * Each and every declaration produces a function with the same signature. This | |
| * allows the creation of custom validation functions. For example: | |
| * | |
| * var MyLink = React.createClass({ | |
| * propTypes: { | |
| * // An optional string or URI prop named "href". | |
| * href: function(props, propName, componentName) { | |
| * var propValue = props[propName]; | |
| * if (propValue != null && typeof propValue !== 'string' && | |
| * !(propValue instanceof URI)) { | |
| * return new Error( | |
| * 'Expected a string or an URI for ' + propName + ' in ' + | |
| * componentName | |
| * ); | |
| * } | |
| * } | |
| * }, | |
| * render: function() {...} | |
| * }); | |
| * | |
| * @internal | |
| */ | |
| var ANONYMOUS = '<<anonymous>>'; | |
| // Important! | |
| // Keep this list in sync with production version in `./factoryWithThrowingShims.js`. | |
| var ReactPropTypes = { | |
| array: createPrimitiveTypeChecker('array'), | |
| bigint: createPrimitiveTypeChecker('bigint'), | |
| bool: createPrimitiveTypeChecker('boolean'), | |
| func: createPrimitiveTypeChecker('function'), | |
| number: createPrimitiveTypeChecker('number'), | |
| object: createPrimitiveTypeChecker('object'), | |
| string: createPrimitiveTypeChecker('string'), | |
| symbol: createPrimitiveTypeChecker('symbol'), | |
| any: createAnyTypeChecker(), | |
| arrayOf: createArrayOfTypeChecker, | |
| element: createElementTypeChecker(), | |
| elementType: createElementTypeTypeChecker(), | |
| instanceOf: createInstanceTypeChecker, | |
| node: createNodeChecker(), | |
| objectOf: createObjectOfTypeChecker, | |
| oneOf: createEnumTypeChecker, | |
| oneOfType: createUnionTypeChecker, | |
| shape: createShapeTypeChecker, | |
| exact: createStrictShapeTypeChecker, | |
| }; | |
| /** | |
| * inlined Object.is polyfill to avoid requiring consumers ship their own | |
| * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is | |
| */ | |
| /*eslint-disable no-self-compare*/ | |
| function is(x, y) { | |
| // SameValue algorithm | |
| if (x === y) { | |
| // Steps 1-5, 7-10 | |
| // Steps 6.b-6.e: +0 != -0 | |
| return x !== 0 || 1 / x === 1 / y; | |
| } else { | |
| // Step 6.a: NaN == NaN | |
| return x !== x && y !== y; | |
| } | |
| } | |
| /*eslint-enable no-self-compare*/ | |
| /** | |
| * We use an Error-like object for backward compatibility as people may call | |
| * PropTypes directly and inspect their output. However, we don't use real | |
| * Errors anymore. We don't inspect their stack anyway, and creating them | |
| * is prohibitively expensive if they are created too often, such as what | |
| * happens in oneOfType() for any type before the one that matched. | |
| */ | |
| function PropTypeError(message, data) { | |
| this.message = message; | |
| this.data = data && typeof data === 'object' ? data: {}; | |
| this.stack = ''; | |
| } | |
| // Make `instanceof Error` still work for returned errors. | |
| PropTypeError.prototype = Error.prototype; | |
| function createChainableTypeChecker(validate) { | |
| if (true) { | |
| var manualPropTypeCallCache = {}; | |
| var manualPropTypeWarningCount = 0; | |
| } | |
| function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { | |
| componentName = componentName || ANONYMOUS; | |
| propFullName = propFullName || propName; | |
| if (secret !== ReactPropTypesSecret) { | |
| if (throwOnDirectAccess) { | |
| // New behavior only for users of `prop-types` package | |
| var err = new Error( | |
| 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + | |
| 'Use `PropTypes.checkPropTypes()` to call them. ' + | |
| 'Read more at http://fb.me/use-check-prop-types' | |
| ); | |
| err.name = 'Invariant Violation'; | |
| throw err; | |
| } else if ( true && typeof console !== 'undefined') { | |
| // Old behavior for people using React.PropTypes | |
| var cacheKey = componentName + ':' + propName; | |
| if ( | |
| !manualPropTypeCallCache[cacheKey] && | |
| // Avoid spamming the console because they are often not actionable except for lib authors | |
| manualPropTypeWarningCount < 3 | |
| ) { | |
| printWarning( | |
| 'You are manually calling a React.PropTypes validation ' + | |
| 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' + | |
| 'and will throw in the standalone `prop-types` package. ' + | |
| 'You may be seeing this warning due to a third-party PropTypes ' + | |
| 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.' | |
| ); | |
| manualPropTypeCallCache[cacheKey] = true; | |
| manualPropTypeWarningCount++; | |
| } | |
| } | |
| } | |
| if (props[propName] == null) { | |
| if (isRequired) { | |
| if (props[propName] === null) { | |
| return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.')); | |
| } | |
| return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.')); | |
| } | |
| return null; | |
| } else { | |
| return validate(props, propName, componentName, location, propFullName); | |
| } | |
| } | |
| var chainedCheckType = checkType.bind(null, false); | |
| chainedCheckType.isRequired = checkType.bind(null, true); | |
| return chainedCheckType; | |
| } | |
| function createPrimitiveTypeChecker(expectedType) { | |
| function validate(props, propName, componentName, location, propFullName, secret) { | |
| var propValue = props[propName]; | |
| var propType = getPropType(propValue); | |
| if (propType !== expectedType) { | |
| // `propValue` being instance of, say, date/regexp, pass the 'object' | |
| // check, but we can offer a more precise error message here rather than | |
| // 'of type `object`'. | |
| var preciseType = getPreciseType(propValue); | |
| return new PropTypeError( | |
| 'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'), | |
| {expectedType: expectedType} | |
| ); | |
| } | |
| return null; | |
| } | |
| return createChainableTypeChecker(validate); | |
| } | |
| function createAnyTypeChecker() { | |
| return createChainableTypeChecker(emptyFunctionThatReturnsNull); | |
| } | |
| function createArrayOfTypeChecker(typeChecker) { | |
| function validate(props, propName, componentName, location, propFullName) { | |
| if (typeof typeChecker !== 'function') { | |
| return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.'); | |
| } | |
| var propValue = props[propName]; | |
| if (!Array.isArray(propValue)) { | |
| var propType = getPropType(propValue); | |
| return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); | |
| } | |
| for (var i = 0; i < propValue.length; i++) { | |
| var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret); | |
| if (error instanceof Error) { | |
| return error; | |
| } | |
| } | |
| return null; | |
| } | |
| return createChainableTypeChecker(validate); | |
| } | |
| function createElementTypeChecker() { | |
| function validate(props, propName, componentName, location, propFullName) { | |
| var propValue = props[propName]; | |
| if (!isValidElement(propValue)) { | |
| var propType = getPropType(propValue); | |
| return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.')); | |
| } | |
| return null; | |
| } | |
| return createChainableTypeChecker(validate); | |
| } | |
| function createElementTypeTypeChecker() { | |
| function validate(props, propName, componentName, location, propFullName) { | |
| var propValue = props[propName]; | |
| if (!ReactIs.isValidElementType(propValue)) { | |
| var propType = getPropType(propValue); | |
| return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.')); | |
| } | |
| return null; | |
| } | |
| return createChainableTypeChecker(validate); | |
| } | |
| function createInstanceTypeChecker(expectedClass) { | |
| function validate(props, propName, componentName, location, propFullName) { | |
| if (!(props[propName] instanceof expectedClass)) { | |
| var expectedClassName = expectedClass.name || ANONYMOUS; | |
| var actualClassName = getClassName(props[propName]); | |
| return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); | |
| } | |
| return null; | |
| } | |
| return createChainableTypeChecker(validate); | |
| } | |
| function createEnumTypeChecker(expectedValues) { | |
| if (!Array.isArray(expectedValues)) { | |
| if (true) { | |
| if (arguments.length > 1) { | |
| printWarning( | |
| 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' + | |
| 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).' | |
| ); | |
| } else { | |
| printWarning('Invalid argument supplied to oneOf, expected an array.'); | |
| } | |
| } | |
| return emptyFunctionThatReturnsNull; | |
| } | |
| function validate(props, propName, componentName, location, propFullName) { | |
| var propValue = props[propName]; | |
| for (var i = 0; i < expectedValues.length; i++) { | |
| if (is(propValue, expectedValues[i])) { | |
| return null; | |
| } | |
| } | |
| var valuesString = JSON.stringify(expectedValues, function replacer(key, value) { | |
| var type = getPreciseType(value); | |
| if (type === 'symbol') { | |
| return String(value); | |
| } | |
| return value; | |
| }); | |
| return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); | |
| } | |
| return createChainableTypeChecker(validate); | |
| } | |
| function createObjectOfTypeChecker(typeChecker) { | |
| function validate(props, propName, componentName, location, propFullName) { | |
| if (typeof typeChecker !== 'function') { | |
| return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.'); | |
| } | |
| var propValue = props[propName]; | |
| var propType = getPropType(propValue); | |
| if (propType !== 'object') { | |
| return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); | |
| } | |
| for (var key in propValue) { | |
| if (has(propValue, key)) { | |
| var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); | |
| if (error instanceof Error) { | |
| return error; | |
| } | |
| } | |
| } | |
| return null; | |
| } | |
| return createChainableTypeChecker(validate); | |
| } | |
| function createUnionTypeChecker(arrayOfTypeCheckers) { | |
| if (!Array.isArray(arrayOfTypeCheckers)) { | |
| true ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : 0; | |
| return emptyFunctionThatReturnsNull; | |
| } | |
| for (var i = 0; i < arrayOfTypeCheckers.length; i++) { | |
| var checker = arrayOfTypeCheckers[i]; | |
| if (typeof checker !== 'function') { | |
| printWarning( | |
| 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + | |
| 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.' | |
| ); | |
| return emptyFunctionThatReturnsNull; | |
| } | |
| } | |
| function validate(props, propName, componentName, location, propFullName) { | |
| var expectedTypes = []; | |
| for (var i = 0; i < arrayOfTypeCheckers.length; i++) { | |
| var checker = arrayOfTypeCheckers[i]; | |
| var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret); | |
| if (checkerResult == null) { | |
| return null; | |
| } | |
| if (checkerResult.data && has(checkerResult.data, 'expectedType')) { | |
| expectedTypes.push(checkerResult.data.expectedType); | |
| } | |
| } | |
| var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': ''; | |
| return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.')); | |
| } | |
| return createChainableTypeChecker(validate); | |
| } | |
| function createNodeChecker() { | |
| function validate(props, propName, componentName, location, propFullName) { | |
| if (!isNode(props[propName])) { | |
| return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); | |
| } | |
| return null; | |
| } | |
| return createChainableTypeChecker(validate); | |
| } | |
| function invalidValidatorError(componentName, location, propFullName, key, type) { | |
| return new PropTypeError( | |
| (componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' + | |
| 'it must be a function, usually from the `prop-types` package, but received `' + type + '`.' | |
| ); | |
| } | |
| function createShapeTypeChecker(shapeTypes) { | |
| function validate(props, propName, componentName, location, propFullName) { | |
| var propValue = props[propName]; | |
| var propType = getPropType(propValue); | |
| if (propType !== 'object') { | |
| return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); | |
| } | |
| for (var key in shapeTypes) { | |
| var checker = shapeTypes[key]; | |
| if (typeof checker !== 'function') { | |
| return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker)); | |
| } | |
| var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); | |
| if (error) { | |
| return error; | |
| } | |
| } | |
| return null; | |
| } | |
| return createChainableTypeChecker(validate); | |
| } | |
| function createStrictShapeTypeChecker(shapeTypes) { | |
| function validate(props, propName, componentName, location, propFullName) { | |
| var propValue = props[propName]; | |
| var propType = getPropType(propValue); | |
| if (propType !== 'object') { | |
| return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); | |
| } | |
| // We need to check all keys in case some are required but missing from props. | |
| var allKeys = assign({}, props[propName], shapeTypes); | |
| for (var key in allKeys) { | |
| var checker = shapeTypes[key]; | |
| if (has(shapeTypes, key) && typeof checker !== 'function') { | |
| return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker)); | |
| } | |
| if (!checker) { | |
| return new PropTypeError( | |
| 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + | |
| '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + | |
| '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ') | |
| ); | |
| } | |
| var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); | |
| if (error) { | |
| return error; | |
| } | |
| } | |
| return null; | |
| } | |
| return createChainableTypeChecker(validate); | |
| } | |
| function isNode(propValue) { | |
| switch (typeof propValue) { | |
| case 'number': | |
| case 'string': | |
| case 'undefined': | |
| return true; | |
| case 'boolean': | |
| return !propValue; | |
| case 'object': | |
| if (Array.isArray(propValue)) { | |
| return propValue.every(isNode); | |
| } | |
| if (propValue === null || isValidElement(propValue)) { | |
| return true; | |
| } | |
| var iteratorFn = getIteratorFn(propValue); | |
| if (iteratorFn) { | |
| var iterator = iteratorFn.call(propValue); | |
| var step; | |
| if (iteratorFn !== propValue.entries) { | |
| while (!(step = iterator.next()).done) { | |
| if (!isNode(step.value)) { | |
| return false; | |
| } | |
| } | |
| } else { | |
| // Iterator will provide entry [k,v] tuples rather than values. | |
| while (!(step = iterator.next()).done) { | |
| var entry = step.value; | |
| if (entry) { | |
| if (!isNode(entry[1])) { | |
| return false; | |
| } | |
| } | |
| } | |
| } | |
| } else { | |
| return false; | |
| } | |
| return true; | |
| default: | |
| return false; | |
| } | |
| } | |
| function isSymbol(propType, propValue) { | |
| // Native Symbol. | |
| if (propType === 'symbol') { | |
| return true; | |
| } | |
| // falsy value can't be a Symbol | |
| if (!propValue) { | |
| return false; | |
| } | |
| // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol' | |
| if (propValue['@@toStringTag'] === 'Symbol') { | |
| return true; | |
| } | |
| // Fallback for non-spec compliant Symbols which are polyfilled. | |
| if (typeof Symbol === 'function' && propValue instanceof Symbol) { | |
| return true; | |
| } | |
| return false; | |
| } | |
| // Equivalent of `typeof` but with special handling for array and regexp. | |
| function getPropType(propValue) { | |
| var propType = typeof propValue; | |
| if (Array.isArray(propValue)) { | |
| return 'array'; | |
| } | |
| if (propValue instanceof RegExp) { | |
| // Old webkits (at least until Android 4.0) return 'function' rather than | |
| // 'object' for typeof a RegExp. We'll normalize this here so that /bla/ | |
| // passes PropTypes.object. | |
| return 'object'; | |
| } | |
| if (isSymbol(propType, propValue)) { | |
| return 'symbol'; | |
| } | |
| return propType; | |
| } | |
| // This handles more types than `getPropType`. Only used for error messages. | |
| // See `createPrimitiveTypeChecker`. | |
| function getPreciseType(propValue) { | |
| if (typeof propValue === 'undefined' || propValue === null) { | |
| return '' + propValue; | |
| } | |
| var propType = getPropType(propValue); | |
| if (propType === 'object') { | |
| if (propValue instanceof Date) { | |
| return 'date'; | |
| } else if (propValue instanceof RegExp) { | |
| return 'regexp'; | |
| } | |
| } | |
| return propType; | |
| } | |
| // Returns a string that is postfixed to a warning about an invalid type. | |
| // For example, "undefined" or "of type array" | |
| function getPostfixForTypeWarning(value) { | |
| var type = getPreciseType(value); | |
| switch (type) { | |
| case 'array': | |
| case 'object': | |
| return 'an ' + type; | |
| case 'boolean': | |
| case 'date': | |
| case 'regexp': | |
| return 'a ' + type; | |
| default: | |
| return type; | |
| } | |
| } | |
| // Returns class name of the object, if any. | |
| function getClassName(propValue) { | |
| if (!propValue.constructor || !propValue.constructor.name) { | |
| return ANONYMOUS; | |
| } | |
| return propValue.constructor.name; | |
| } | |
| ReactPropTypes.checkPropTypes = checkPropTypes; | |
| ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache; | |
| ReactPropTypes.PropTypes = ReactPropTypes; | |
| return ReactPropTypes; | |
| }; | |
| /***/ }), | |
| /***/ "./node_modules/prop-types/index.js": | |
| /*!******************************************!*\ | |
| !*** ./node_modules/prop-types/index.js ***! | |
| \******************************************/ | |
| /***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| /** | |
| * Copyright (c) 2013-present, Facebook, Inc. | |
| * | |
| * This source code is licensed under the MIT license found in the | |
| * LICENSE file in the root directory of this source tree. | |
| */ | |
| if (true) { | |
| var ReactIs = __webpack_require__(/*! react-is */ "./node_modules/react-is/index.js"); | |
| // By explicitly using `prop-types` you are opting into new development behavior. | |
| // http://fb.me/prop-types-in-prod | |
| var throwOnDirectAccess = true; | |
| module.exports = __webpack_require__(/*! ./factoryWithTypeCheckers */ "./node_modules/prop-types/factoryWithTypeCheckers.js")(ReactIs.isElement, throwOnDirectAccess); | |
| } else {} | |
| /***/ }), | |
| /***/ "./node_modules/prop-types/lib/ReactPropTypesSecret.js": | |
| /*!*************************************************************!*\ | |
| !*** ./node_modules/prop-types/lib/ReactPropTypesSecret.js ***! | |
| \*************************************************************/ | |
| /***/ (function(module) { | |
| "use strict"; | |
| /** | |
| * Copyright (c) 2013-present, Facebook, Inc. | |
| * | |
| * This source code is licensed under the MIT license found in the | |
| * LICENSE file in the root directory of this source tree. | |
| */ | |
| var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; | |
| module.exports = ReactPropTypesSecret; | |
| /***/ }), | |
| /***/ "./node_modules/prop-types/lib/has.js": | |
| /*!********************************************!*\ | |
| !*** ./node_modules/prop-types/lib/has.js ***! | |
| \********************************************/ | |
| /***/ (function(module) { | |
| module.exports = Function.call.bind(Object.prototype.hasOwnProperty); | |
| /***/ }), | |
| /***/ "./node_modules/react-dom/cjs/react-dom.development.js": | |
| /*!*************************************************************!*\ | |
| !*** ./node_modules/react-dom/cjs/react-dom.development.js ***! | |
| \*************************************************************/ | |
| /***/ (function(__unused_webpack_module, exports, __webpack_require__) { | |
| "use strict"; | |
| /** @license React v16.14.0 | |
| * react-dom.development.js | |
| * | |
| * Copyright (c) Facebook, Inc. and its affiliates. | |
| * | |
| * This source code is licensed under the MIT license found in the | |
| * LICENSE file in the root directory of this source tree. | |
| */ | |
| if (true) { | |
| (function() { | |
| 'use strict'; | |
| var React = __webpack_require__(/*! react */ "./node_modules/react/index.js"); | |
| var _assign = __webpack_require__(/*! object-assign */ "./node_modules/object-assign/index.js"); | |
| var Scheduler = __webpack_require__(/*! scheduler */ "./node_modules/scheduler/index.js"); | |
| var checkPropTypes = __webpack_require__(/*! prop-types/checkPropTypes */ "./node_modules/prop-types/checkPropTypes.js"); | |
| var tracing = __webpack_require__(/*! scheduler/tracing */ "./node_modules/scheduler/tracing.js"); | |
| var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions. | |
| // Current owner and dispatcher used to share the same ref, | |
| // but PR #14548 split them out to better support the react-debug-tools package. | |
| if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) { | |
| ReactSharedInternals.ReactCurrentDispatcher = { | |
| current: null | |
| }; | |
| } | |
| if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) { | |
| ReactSharedInternals.ReactCurrentBatchConfig = { | |
| suspense: null | |
| }; | |
| } | |
| // by calls to these methods by a Babel plugin. | |
| // | |
| // In PROD (or in packages without access to React internals), | |
| // they are left as they are instead. | |
| function warn(format) { | |
| { | |
| for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | |
| args[_key - 1] = arguments[_key]; | |
| } | |
| printWarning('warn', format, args); | |
| } | |
| } | |
| function error(format) { | |
| { | |
| for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | |
| args[_key2 - 1] = arguments[_key2]; | |
| } | |
| printWarning('error', format, args); | |
| } | |
| } | |
| function printWarning(level, format, args) { | |
| // When changing this logic, you might want to also | |
| // update consoleWithStackDev.www.js as well. | |
| { | |
| var hasExistingStack = args.length > 0 && typeof args[args.length - 1] === 'string' && args[args.length - 1].indexOf('\n in') === 0; | |
| if (!hasExistingStack) { | |
| var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; | |
| var stack = ReactDebugCurrentFrame.getStackAddendum(); | |
| if (stack !== '') { | |
| format += '%s'; | |
| args = args.concat([stack]); | |
| } | |
| } | |
| var argsWithFormat = args.map(function (item) { | |
| return '' + item; | |
| }); // Careful: RN currently depends on this prefix | |
| argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it | |
| // breaks IE9: https://github.com/facebook/react/issues/13610 | |
| // eslint-disable-next-line react-internal/no-production-logging | |
| Function.prototype.apply.call(console[level], console, argsWithFormat); | |
| try { | |
| // --- Welcome to debugging React --- | |
| // This error was thrown as a convenience so that you can use this stack | |
| // to find the callsite that caused this warning to fire. | |
| var argIndex = 0; | |
| var message = 'Warning: ' + format.replace(/%s/g, function () { | |
| return args[argIndex++]; | |
| }); | |
| throw new Error(message); | |
| } catch (x) {} | |
| } | |
| } | |
| if (!React) { | |
| { | |
| throw Error( "ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM." ); | |
| } | |
| } | |
| var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) { | |
| var funcArgs = Array.prototype.slice.call(arguments, 3); | |
| try { | |
| func.apply(context, funcArgs); | |
| } catch (error) { | |
| this.onError(error); | |
| } | |
| }; | |
| { | |
| // In DEV mode, we swap out invokeGuardedCallback for a special version | |
| // that plays more nicely with the browser's DevTools. The idea is to preserve | |
| // "Pause on exceptions" behavior. Because React wraps all user-provided | |
| // functions in invokeGuardedCallback, and the production version of | |
| // invokeGuardedCallback uses a try-catch, all user exceptions are treated | |
| // like caught exceptions, and the DevTools won't pause unless the developer | |
| // takes the extra step of enabling pause on caught exceptions. This is | |
| // unintuitive, though, because even though React has caught the error, from | |
| // the developer's perspective, the error is uncaught. | |
| // | |
| // To preserve the expected "Pause on exceptions" behavior, we don't use a | |
| // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake | |
| // DOM node, and call the user-provided callback from inside an event handler | |
| // for that fake event. If the callback throws, the error is "captured" using | |
| // a global event handler. But because the error happens in a different | |
| // event loop context, it does not interrupt the normal program flow. | |
| // Effectively, this gives us try-catch behavior without actually using | |
| // try-catch. Neat! | |
| // Check that the browser supports the APIs we need to implement our special | |
| // DEV version of invokeGuardedCallback | |
| if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') { | |
| var fakeNode = document.createElement('react'); | |
| var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) { | |
| // If document doesn't exist we know for sure we will crash in this method | |
| // when we call document.createEvent(). However this can cause confusing | |
| // errors: https://github.com/facebookincubator/create-react-app/issues/3482 | |
| // So we preemptively throw with a better message instead. | |
| if (!(typeof document !== 'undefined')) { | |
| { | |
| throw Error( "The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous." ); | |
| } | |
| } | |
| var evt = document.createEvent('Event'); // Keeps track of whether the user-provided callback threw an error. We | |
| // set this to true at the beginning, then set it to false right after | |
| // calling the function. If the function errors, `didError` will never be | |
| // set to false. This strategy works even if the browser is flaky and | |
| // fails to call our global error handler, because it doesn't rely on | |
| // the error event at all. | |
| var didError = true; // Keeps track of the value of window.event so that we can reset it | |
| // during the callback to let user code access window.event in the | |
| // browsers that support it. | |
| var windowEvent = window.event; // Keeps track of the descriptor of window.event to restore it after event | |
| // dispatching: https://github.com/facebook/react/issues/13688 | |
| var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event'); // Create an event handler for our fake event. We will synchronously | |
| // dispatch our fake event using `dispatchEvent`. Inside the handler, we | |
| // call the user-provided callback. | |
| var funcArgs = Array.prototype.slice.call(arguments, 3); | |
| function callCallback() { | |
| // We immediately remove the callback from event listeners so that | |
| // nested `invokeGuardedCallback` calls do not clash. Otherwise, a | |
| // nested call would trigger the fake event handlers of any call higher | |
| // in the stack. | |
| fakeNode.removeEventListener(evtType, callCallback, false); // We check for window.hasOwnProperty('event') to prevent the | |
| // window.event assignment in both IE <= 10 as they throw an error | |
| // "Member not found" in strict mode, and in Firefox which does not | |
| // support window.event. | |
| if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) { | |
| window.event = windowEvent; | |
| } | |
| func.apply(context, funcArgs); | |
| didError = false; | |
| } // Create a global error event handler. We use this to capture the value | |
| // that was thrown. It's possible that this error handler will fire more | |
| // than once; for example, if non-React code also calls `dispatchEvent` | |
| // and a handler for that event throws. We should be resilient to most of | |
| // those cases. Even if our error event handler fires more than once, the | |
| // last error event is always used. If the callback actually does error, | |
| // we know that the last error event is the correct one, because it's not | |
| // possible for anything else to have happened in between our callback | |
| // erroring and the code that follows the `dispatchEvent` call below. If | |
| // the callback doesn't error, but the error event was fired, we know to | |
| // ignore it because `didError` will be false, as described above. | |
| var error; // Use this to track whether the error event is ever called. | |
| var didSetError = false; | |
| var isCrossOriginError = false; | |
| function handleWindowError(event) { | |
| error = event.error; | |
| didSetError = true; | |
| if (error === null && event.colno === 0 && event.lineno === 0) { | |
| isCrossOriginError = true; | |
| } | |
| if (event.defaultPrevented) { | |
| // Some other error handler has prevented default. | |
| // Browsers silence the error report if this happens. | |
| // We'll remember this to later decide whether to log it or not. | |
| if (error != null && typeof error === 'object') { | |
| try { | |
| error._suppressLogging = true; | |
| } catch (inner) {// Ignore. | |
| } | |
| } | |
| } | |
| } // Create a fake event type. | |
| var evtType = "react-" + (name ? name : 'invokeguardedcallback'); // Attach our event handlers | |
| window.addEventListener('error', handleWindowError); | |
| fakeNode.addEventListener(evtType, callCallback, false); // Synchronously dispatch our fake event. If the user-provided function | |
| // errors, it will trigger our global error handler. | |
| evt.initEvent(evtType, false, false); | |
| fakeNode.dispatchEvent(evt); | |
| if (windowEventDescriptor) { | |
| Object.defineProperty(window, 'event', windowEventDescriptor); | |
| } | |
| if (didError) { | |
| if (!didSetError) { | |
| // The callback errored, but the error event never fired. | |
| error = new Error('An error was thrown inside one of your components, but React ' + "doesn't know what it was. This is likely due to browser " + 'flakiness. React does its best to preserve the "Pause on ' + 'exceptions" behavior of the DevTools, which requires some ' + "DEV-mode only tricks. It's possible that these don't work in " + 'your browser. Try triggering the error in production mode, ' + 'or switching to a modern browser. If you suspect that this is ' + 'actually an issue with React, please file an issue.'); | |
| } else if (isCrossOriginError) { | |
| error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://fb.me/react-crossorigin-error for more information.'); | |
| } | |
| this.onError(error); | |
| } // Remove our event listeners | |
| window.removeEventListener('error', handleWindowError); | |
| }; | |
| invokeGuardedCallbackImpl = invokeGuardedCallbackDev; | |
| } | |
| } | |
| var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl; | |
| var hasError = false; | |
| var caughtError = null; // Used by event system to capture/rethrow the first error. | |
| var hasRethrowError = false; | |
| var rethrowError = null; | |
| var reporter = { | |
| onError: function (error) { | |
| hasError = true; | |
| caughtError = error; | |
| } | |
| }; | |
| /** | |
| * Call a function while guarding against errors that happens within it. | |
| * Returns an error if it throws, otherwise null. | |
| * | |
| * In production, this is implemented using a try-catch. The reason we don't | |
| * use a try-catch directly is so that we can swap out a different | |
| * implementation in DEV mode. | |
| * | |
| * @param {String} name of the guard to use for logging or debugging | |
| * @param {Function} func The function to invoke | |
| * @param {*} context The context to use when calling the function | |
| * @param {...*} args Arguments for function | |
| */ | |
| function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { | |
| hasError = false; | |
| caughtError = null; | |
| invokeGuardedCallbackImpl$1.apply(reporter, arguments); | |
| } | |
| /** | |
| * Same as invokeGuardedCallback, but instead of returning an error, it stores | |
| * it in a global so it can be rethrown by `rethrowCaughtError` later. | |
| * TODO: See if caughtError and rethrowError can be unified. | |
| * | |
| * @param {String} name of the guard to use for logging or debugging | |
| * @param {Function} func The function to invoke | |
| * @param {*} context The context to use when calling the function | |
| * @param {...*} args Arguments for function | |
| */ | |
| function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) { | |
| invokeGuardedCallback.apply(this, arguments); | |
| if (hasError) { | |
| var error = clearCaughtError(); | |
| if (!hasRethrowError) { | |
| hasRethrowError = true; | |
| rethrowError = error; | |
| } | |
| } | |
| } | |
| /** | |
| * During execution of guarded functions we will capture the first error which | |
| * we will rethrow to be handled by the top level error handler. | |
| */ | |
| function rethrowCaughtError() { | |
| if (hasRethrowError) { | |
| var error = rethrowError; | |
| hasRethrowError = false; | |
| rethrowError = null; | |
| throw error; | |
| } | |
| } | |
| function hasCaughtError() { | |
| return hasError; | |
| } | |
| function clearCaughtError() { | |
| if (hasError) { | |
| var error = caughtError; | |
| hasError = false; | |
| caughtError = null; | |
| return error; | |
| } else { | |
| { | |
| { | |
| throw Error( "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." ); | |
| } | |
| } | |
| } | |
| } | |
| var getFiberCurrentPropsFromNode = null; | |
| var getInstanceFromNode = null; | |
| var getNodeFromInstance = null; | |
| function setComponentTree(getFiberCurrentPropsFromNodeImpl, getInstanceFromNodeImpl, getNodeFromInstanceImpl) { | |
| getFiberCurrentPropsFromNode = getFiberCurrentPropsFromNodeImpl; | |
| getInstanceFromNode = getInstanceFromNodeImpl; | |
| getNodeFromInstance = getNodeFromInstanceImpl; | |
| { | |
| if (!getNodeFromInstance || !getInstanceFromNode) { | |
| error('EventPluginUtils.setComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.'); | |
| } | |
| } | |
| } | |
| var validateEventDispatches; | |
| { | |
| validateEventDispatches = function (event) { | |
| var dispatchListeners = event._dispatchListeners; | |
| var dispatchInstances = event._dispatchInstances; | |
| var listenersIsArr = Array.isArray(dispatchListeners); | |
| var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0; | |
| var instancesIsArr = Array.isArray(dispatchInstances); | |
| var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0; | |
| if (instancesIsArr !== listenersIsArr || instancesLen !== listenersLen) { | |
| error('EventPluginUtils: Invalid `event`.'); | |
| } | |
| }; | |
| } | |
| /** | |
| * Dispatch the event to the listener. | |
| * @param {SyntheticEvent} event SyntheticEvent to handle | |
| * @param {function} listener Application-level callback | |
| * @param {*} inst Internal component instance | |
| */ | |
| function executeDispatch(event, listener, inst) { | |
| var type = event.type || 'unknown-event'; | |
| event.currentTarget = getNodeFromInstance(inst); | |
| invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event); | |
| event.currentTarget = null; | |
| } | |
| /** | |
| * Standard/simple iteration through an event's collected dispatches. | |
| */ | |
| function executeDispatchesInOrder(event) { | |
| var dispatchListeners = event._dispatchListeners; | |
| var dispatchInstances = event._dispatchInstances; | |
| { | |
| validateEventDispatches(event); | |
| } | |
| if (Array.isArray(dispatchListeners)) { | |
| for (var i = 0; i < dispatchListeners.length; i++) { | |
| if (event.isPropagationStopped()) { | |
| break; | |
| } // Listeners and Instances are two parallel arrays that are always in sync. | |
| executeDispatch(event, dispatchListeners[i], dispatchInstances[i]); | |
| } | |
| } else if (dispatchListeners) { | |
| executeDispatch(event, dispatchListeners, dispatchInstances); | |
| } | |
| event._dispatchListeners = null; | |
| event._dispatchInstances = null; | |
| } | |
| var FunctionComponent = 0; | |
| var ClassComponent = 1; | |
| var IndeterminateComponent = 2; // Before we know whether it is function or class | |
| var HostRoot = 3; // Root of a host tree. Could be nested inside another node. | |
| var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. | |
| var HostComponent = 5; | |
| var HostText = 6; | |
| var Fragment = 7; | |
| var Mode = 8; | |
| var ContextConsumer = 9; | |
| var ContextProvider = 10; | |
| var ForwardRef = 11; | |
| var Profiler = 12; | |
| var SuspenseComponent = 13; | |
| var MemoComponent = 14; | |
| var SimpleMemoComponent = 15; | |
| var LazyComponent = 16; | |
| var IncompleteClassComponent = 17; | |
| var DehydratedFragment = 18; | |
| var SuspenseListComponent = 19; | |
| var FundamentalComponent = 20; | |
| var ScopeComponent = 21; | |
| var Block = 22; | |
| /** | |
| * Injectable ordering of event plugins. | |
| */ | |
| var eventPluginOrder = null; | |
| /** | |
| * Injectable mapping from names to event plugin modules. | |
| */ | |
| var namesToPlugins = {}; | |
| /** | |
| * Recomputes the plugin list using the injected plugins and plugin ordering. | |
| * | |
| * @private | |
| */ | |
| function recomputePluginOrdering() { | |
| if (!eventPluginOrder) { | |
| // Wait until an `eventPluginOrder` is injected. | |
| return; | |
| } | |
| for (var pluginName in namesToPlugins) { | |
| var pluginModule = namesToPlugins[pluginName]; | |
| var pluginIndex = eventPluginOrder.indexOf(pluginName); | |
| if (!(pluginIndex > -1)) { | |
| { | |
| throw Error( "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + pluginName + "`." ); | |
| } | |
| } | |
| if (plugins[pluginIndex]) { | |
| continue; | |
| } | |
| if (!pluginModule.extractEvents) { | |
| { | |
| throw Error( "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + pluginName + "` does not." ); | |
| } | |
| } | |
| plugins[pluginIndex] = pluginModule; | |
| var publishedEvents = pluginModule.eventTypes; | |
| for (var eventName in publishedEvents) { | |
| if (!publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName)) { | |
| { | |
| throw Error( "EventPluginRegistry: Failed to publish event `" + eventName + "` for plugin `" + pluginName + "`." ); | |
| } | |
| } | |
| } | |
| } | |
| } | |
| /** | |
| * Publishes an event so that it can be dispatched by the supplied plugin. | |
| * | |
| * @param {object} dispatchConfig Dispatch configuration for the event. | |
| * @param {object} PluginModule Plugin publishing the event. | |
| * @return {boolean} True if the event was successfully published. | |
| * @private | |
| */ | |
| function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { | |
| if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) { | |
| { | |
| throw Error( "EventPluginRegistry: More than one plugin attempted to publish the same event name, `" + eventName + "`." ); | |
| } | |
| } | |
| eventNameDispatchConfigs[eventName] = dispatchConfig; | |
| var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; | |
| if (phasedRegistrationNames) { | |
| for (var phaseName in phasedRegistrationNames) { | |
| if (phasedRegistrationNames.hasOwnProperty(phaseName)) { | |
| var phasedRegistrationName = phasedRegistrationNames[phaseName]; | |
| publishRegistrationName(phasedRegistrationName, pluginModule, eventName); | |
| } | |
| } | |
| return true; | |
| } else if (dispatchConfig.registrationName) { | |
| publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName); | |
| return true; | |
| } | |
| return false; | |
| } | |
| /** | |
| * Publishes a registration name that is used to identify dispatched events. | |
| * | |
| * @param {string} registrationName Registration name to add. | |
| * @param {object} PluginModule Plugin publishing the event. | |
| * @private | |
| */ | |
| function publishRegistrationName(registrationName, pluginModule, eventName) { | |
| if (!!registrationNameModules[registrationName]) { | |
| { | |
| throw Error( "EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" + registrationName + "`." ); | |
| } | |
| } | |
| registrationNameModules[registrationName] = pluginModule; | |
| registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies; | |
| { | |
| var lowerCasedName = registrationName.toLowerCase(); | |
| possibleRegistrationNames[lowerCasedName] = registrationName; | |
| if (registrationName === 'onDoubleClick') { | |
| possibleRegistrationNames.ondblclick = registrationName; | |
| } | |
| } | |
| } | |
| /** | |
| * Registers plugins so that they can extract and dispatch events. | |
| */ | |
| /** | |
| * Ordered list of injected plugins. | |
| */ | |
| var plugins = []; | |
| /** | |
| * Mapping from event name to dispatch config | |
| */ | |
| var eventNameDispatchConfigs = {}; | |
| /** | |
| * Mapping from registration name to plugin module | |
| */ | |
| var registrationNameModules = {}; | |
| /** | |
| * Mapping from registration name to event name | |
| */ | |
| var registrationNameDependencies = {}; | |
| /** | |
| * Mapping from lowercase registration names to the properly cased version, | |
| * used to warn in the case of missing event handlers. Available | |
| * only in true. | |
| * @type {Object} | |
| */ | |
| var possibleRegistrationNames = {} ; // Trust the developer to only use possibleRegistrationNames in true | |
| /** | |
| * Injects an ordering of plugins (by plugin name). This allows the ordering | |
| * to be decoupled from injection of the actual plugins so that ordering is | |
| * always deterministic regardless of packaging, on-the-fly injection, etc. | |
| * | |
| * @param {array} InjectedEventPluginOrder | |
| * @internal | |
| */ | |
| function injectEventPluginOrder(injectedEventPluginOrder) { | |
| if (!!eventPluginOrder) { | |
| { | |
| throw Error( "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." ); | |
| } | |
| } // Clone the ordering so it cannot be dynamically mutated. | |
| eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); | |
| recomputePluginOrdering(); | |
| } | |
| /** | |
| * Injects plugins to be used by plugin event system. The plugin names must be | |
| * in the ordering injected by `injectEventPluginOrder`. | |
| * | |
| * Plugins can be injected as part of page initialization or on-the-fly. | |
| * | |
| * @param {object} injectedNamesToPlugins Map from names to plugin modules. | |
| * @internal | |
| */ | |
| function injectEventPluginsByName(injectedNamesToPlugins) { | |
| var isOrderingDirty = false; | |
| for (var pluginName in injectedNamesToPlugins) { | |
| if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) { | |
| continue; | |
| } | |
| var pluginModule = injectedNamesToPlugins[pluginName]; | |
| if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) { | |
| if (!!namesToPlugins[pluginName]) { | |
| { | |
| throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + pluginName + "`." ); | |
| } | |
| } | |
| namesToPlugins[pluginName] = pluginModule; | |
| isOrderingDirty = true; | |
| } | |
| } | |
| if (isOrderingDirty) { | |
| recomputePluginOrdering(); | |
| } | |
| } | |
| var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined'); | |
| var PLUGIN_EVENT_SYSTEM = 1; | |
| var IS_REPLAYED = 1 << 5; | |
| var IS_FIRST_ANCESTOR = 1 << 6; | |
| var restoreImpl = null; | |
| var restoreTarget = null; | |
| var restoreQueue = null; | |
| function restoreStateOfTarget(target) { | |
| // We perform this translation at the end of the event loop so that we | |
| // always receive the correct fiber here | |
| var internalInstance = getInstanceFromNode(target); | |
| if (!internalInstance) { | |
| // Unmounted | |
| return; | |
| } | |
| if (!(typeof restoreImpl === 'function')) { | |
| { | |
| throw Error( "setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue." ); | |
| } | |
| } | |
| var stateNode = internalInstance.stateNode; // Guard against Fiber being unmounted. | |
| if (stateNode) { | |
| var _props = getFiberCurrentPropsFromNode(stateNode); | |
| restoreImpl(internalInstance.stateNode, internalInstance.type, _props); | |
| } | |
| } | |
| function setRestoreImplementation(impl) { | |
| restoreImpl = impl; | |
| } | |
| function enqueueStateRestore(target) { | |
| if (restoreTarget) { | |
| if (restoreQueue) { | |
| restoreQueue.push(target); | |
| } else { | |
| restoreQueue = [target]; | |
| } | |
| } else { | |
| restoreTarget = target; | |
| } | |
| } | |
| function needsStateRestore() { | |
| return restoreTarget !== null || restoreQueue !== null; | |
| } | |
| function restoreStateIfNeeded() { | |
| if (!restoreTarget) { | |
| return; | |
| } | |
| var target = restoreTarget; | |
| var queuedTargets = restoreQueue; | |
| restoreTarget = null; | |
| restoreQueue = null; | |
| restoreStateOfTarget(target); | |
| if (queuedTargets) { | |
| for (var i = 0; i < queuedTargets.length; i++) { | |
| restoreStateOfTarget(queuedTargets[i]); | |
| } | |
| } | |
| } | |
| var enableProfilerTimer = true; // Trace which interactions trigger each commit. | |
| var enableDeprecatedFlareAPI = false; // Experimental Host Component support. | |
| var enableFundamentalAPI = false; // Experimental Scope support. | |
| var warnAboutStringRefs = false; | |
| // the renderer. Such as when we're dispatching events or if third party | |
| // libraries need to call batchedUpdates. Eventually, this API will go away when | |
| // everything is batched by default. We'll then have a similar API to opt-out of | |
| // scheduled work and instead do synchronous work. | |
| // Defaults | |
| var batchedUpdatesImpl = function (fn, bookkeeping) { | |
| return fn(bookkeeping); | |
| }; | |
| var discreteUpdatesImpl = function (fn, a, b, c, d) { | |
| return fn(a, b, c, d); | |
| }; | |
| var flushDiscreteUpdatesImpl = function () {}; | |
| var batchedEventUpdatesImpl = batchedUpdatesImpl; | |
| var isInsideEventHandler = false; | |
| var isBatchingEventUpdates = false; | |
| function finishEventHandler() { | |
| // Here we wait until all updates have propagated, which is important | |
| // when using controlled components within layers: | |
| // https://github.com/facebook/react/issues/1698 | |
| // Then we restore state of any controlled component. | |
| var controlledComponentsHavePendingUpdates = needsStateRestore(); | |
| if (controlledComponentsHavePendingUpdates) { | |
| // If a controlled event was fired, we may need to restore the state of | |
| // the DOM node back to the controlled value. This is necessary when React | |
| // bails out of the update without touching the DOM. | |
| flushDiscreteUpdatesImpl(); | |
| restoreStateIfNeeded(); | |
| } | |
| } | |
| function batchedUpdates(fn, bookkeeping) { | |
| if (isInsideEventHandler) { | |
| // If we are currently inside another batch, we need to wait until it | |
| // fully completes before restoring state. | |
| return fn(bookkeeping); | |
| } | |
| isInsideEventHandler = true; | |
| try { | |
| return batchedUpdatesImpl(fn, bookkeeping); | |
| } finally { | |
| isInsideEventHandler = false; | |
| finishEventHandler(); | |
| } | |
| } | |
| function batchedEventUpdates(fn, a, b) { | |
| if (isBatchingEventUpdates) { | |
| // If we are currently inside another batch, we need to wait until it | |
| // fully completes before restoring state. | |
| return fn(a, b); | |
| } | |
| isBatchingEventUpdates = true; | |
| try { | |
| return batchedEventUpdatesImpl(fn, a, b); | |
| } finally { | |
| isBatchingEventUpdates = false; | |
| finishEventHandler(); | |
| } | |
| } // This is for the React Flare event system | |
| function discreteUpdates(fn, a, b, c, d) { | |
| var prevIsInsideEventHandler = isInsideEventHandler; | |
| isInsideEventHandler = true; | |
| try { | |
| return discreteUpdatesImpl(fn, a, b, c, d); | |
| } finally { | |
| isInsideEventHandler = prevIsInsideEventHandler; | |
| if (!isInsideEventHandler) { | |
| finishEventHandler(); | |
| } | |
| } | |
| } | |
| function flushDiscreteUpdatesIfNeeded(timeStamp) { | |
| // event.timeStamp isn't overly reliable due to inconsistencies in | |
| // how different browsers have historically provided the time stamp. | |
| // Some browsers provide high-resolution time stamps for all events, | |
| // some provide low-resolution time stamps for all events. FF < 52 | |
| // even mixes both time stamps together. Some browsers even report | |
| // negative time stamps or time stamps that are 0 (iOS9) in some cases. | |
| // Given we are only comparing two time stamps with equality (!==), | |
| // we are safe from the resolution differences. If the time stamp is 0 | |
| // we bail-out of preventing the flush, which can affect semantics, | |
| // such as if an earlier flush removes or adds event listeners that | |
| // are fired in the subsequent flush. However, this is the same | |
| // behaviour as we had before this change, so the risks are low. | |
| if (!isInsideEventHandler && (!enableDeprecatedFlareAPI )) { | |
| flushDiscreteUpdatesImpl(); | |
| } | |
| } | |
| function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl, _flushDiscreteUpdatesImpl, _batchedEventUpdatesImpl) { | |
| batchedUpdatesImpl = _batchedUpdatesImpl; | |
| discreteUpdatesImpl = _discreteUpdatesImpl; | |
| flushDiscreteUpdatesImpl = _flushDiscreteUpdatesImpl; | |
| batchedEventUpdatesImpl = _batchedEventUpdatesImpl; | |
| } | |
| var DiscreteEvent = 0; | |
| var UserBlockingEvent = 1; | |
| var ContinuousEvent = 2; | |
| // A reserved attribute. | |
| // It is handled by React separately and shouldn't be written to the DOM. | |
| var RESERVED = 0; // A simple string attribute. | |
| // Attributes that aren't in the whitelist are presumed to have this type. | |
| var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called | |
| // "enumerated" attributes with "true" and "false" as possible values. | |
| // When true, it should be set to a "true" string. | |
| // When false, it should be set to a "false" string. | |
| var BOOLEANISH_STRING = 2; // A real boolean attribute. | |
| // When true, it should be present (set either to an empty string or its name). | |
| // When false, it should be omitted. | |
| var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value. | |
| // When true, it should be present (set either to an empty string or its name). | |
| // When false, it should be omitted. | |
| // For any other value, should be present with that value. | |
| var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric. | |
| // When falsy, it should be removed. | |
| var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric. | |
| // When falsy, it should be removed. | |
| var POSITIVE_NUMERIC = 6; | |
| /* eslint-disable max-len */ | |
| var ATTRIBUTE_NAME_START_CHAR = ":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD"; | |
| /* eslint-enable max-len */ | |
| var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040"; | |
| var ROOT_ATTRIBUTE_NAME = 'data-reactroot'; | |
| var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$'); | |
| var hasOwnProperty = Object.prototype.hasOwnProperty; | |
| var illegalAttributeNameCache = {}; | |
| var validatedAttributeNameCache = {}; | |
| function isAttributeNameSafe(attributeName) { | |
| if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) { | |
| return true; | |
| } | |
| if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) { | |
| return false; | |
| } | |
| if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) { | |
| validatedAttributeNameCache[attributeName] = true; | |
| return true; | |
| } | |
| illegalAttributeNameCache[attributeName] = true; | |
| { | |
| error('Invalid attribute name: `%s`', attributeName); | |
| } | |
| return false; | |
| } | |
| function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) { | |
| if (propertyInfo !== null) { | |
| return propertyInfo.type === RESERVED; | |
| } | |
| if (isCustomComponentTag) { | |
| return false; | |
| } | |
| if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) { | |
| return true; | |
| } | |
| return false; | |
| } | |
| function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) { | |
| if (propertyInfo !== null && propertyInfo.type === RESERVED) { | |
| return false; | |
| } | |
| switch (typeof value) { | |
| case 'function': // $FlowIssue symbol is perfectly valid here | |
| case 'symbol': | |
| // eslint-disable-line | |
| return true; | |
| case 'boolean': | |
| { | |
| if (isCustomComponentTag) { | |
| return false; | |
| } | |
| if (propertyInfo !== null) { | |
| return !propertyInfo.acceptsBooleans; | |
| } else { | |
| var prefix = name.toLowerCase().slice(0, 5); | |
| return prefix !== 'data-' && prefix !== 'aria-'; | |
| } | |
| } | |
| default: | |
| return false; | |
| } | |
| } | |
| function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) { | |
| if (value === null || typeof value === 'undefined') { | |
| return true; | |
| } | |
| if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) { | |
| return true; | |
| } | |
| if (isCustomComponentTag) { | |
| return false; | |
| } | |
| if (propertyInfo !== null) { | |
| switch (propertyInfo.type) { | |
| case BOOLEAN: | |
| return !value; | |
| case OVERLOADED_BOOLEAN: | |
| return value === false; | |
| case NUMERIC: | |
| return isNaN(value); | |
| case POSITIVE_NUMERIC: | |
| return isNaN(value) || value < 1; | |
| } | |
| } | |
| return false; | |
| } | |
| function getPropertyInfo(name) { | |
| return properties.hasOwnProperty(name) ? properties[name] : null; | |
| } | |
| function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL) { | |
| this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN; | |
| this.attributeName = attributeName; | |
| this.attributeNamespace = attributeNamespace; | |
| this.mustUseProperty = mustUseProperty; | |
| this.propertyName = name; | |
| this.type = type; | |
| this.sanitizeURL = sanitizeURL; | |
| } // When adding attributes to this list, be sure to also add them to | |
| // the `possibleStandardNames` module to ensure casing and incorrect | |
| // name warnings. | |
| var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM. | |
| var reservedProps = ['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular | |
| // elements (not just inputs). Now that ReactDOMInput assigns to the | |
| // defaultValue property -- do we need this? | |
| 'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style']; | |
| reservedProps.forEach(function (name) { | |
| properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty | |
| name, // attributeName | |
| null, // attributeNamespace | |
| false); | |
| }); // A few React string attributes have a different name. | |
| // This is a mapping from React prop names to the attribute names. | |
| [['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) { | |
| var name = _ref[0], | |
| attributeName = _ref[1]; | |
| properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty | |
| attributeName, // attributeName | |
| null, // attributeNamespace | |
| false); | |
| }); // These are "enumerated" HTML attributes that accept "true" and "false". | |
| // In React, we let users pass `true` and `false` even though technically | |
| // these aren't boolean attributes (they are coerced to strings). | |
| ['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) { | |
| properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty | |
| name.toLowerCase(), // attributeName | |
| null, // attributeNamespace | |
| false); | |
| }); // These are "enumerated" SVG attributes that accept "true" and "false". | |
| // In React, we let users pass `true` and `false` even though technically | |
| // these aren't boolean attributes (they are coerced to strings). | |
| // Since these are SVG attributes, their attribute names are case-sensitive. | |
| ['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) { | |
| properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty | |
| name, // attributeName | |
| null, // attributeNamespace | |
| false); | |
| }); // These are HTML boolean attributes. | |
| ['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM | |
| // on the client side because the browsers are inconsistent. Instead we call focus(). | |
| 'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata | |
| 'itemScope'].forEach(function (name) { | |
| properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty | |
| name.toLowerCase(), // attributeName | |
| null, // attributeNamespace | |
| false); | |
| }); // These are the few React props that we set as DOM properties | |
| // rather than attributes. These are all booleans. | |
| ['checked', // Note: `option.selected` is not updated if `select.multiple` is | |
| // disabled with `removeAttribute`. We have special logic for handling this. | |
| 'multiple', 'muted', 'selected' // NOTE: if you add a camelCased prop to this list, | |
| // you'll need to set attributeName to name.toLowerCase() | |
| // instead in the assignment below. | |
| ].forEach(function (name) { | |
| properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty | |
| name, // attributeName | |
| null, // attributeNamespace | |
| false); | |
| }); // These are HTML attributes that are "overloaded booleans": they behave like | |
| // booleans, but can also accept a string value. | |
| ['capture', 'download' // NOTE: if you add a camelCased prop to this list, | |
| // you'll need to set attributeName to name.toLowerCase() | |
| // instead in the assignment below. | |
| ].forEach(function (name) { | |
| properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty | |
| name, // attributeName | |
| null, // attributeNamespace | |
| false); | |
| }); // These are HTML attributes that must be positive numbers. | |
| ['cols', 'rows', 'size', 'span' // NOTE: if you add a camelCased prop to this list, | |
| // you'll need to set attributeName to name.toLowerCase() | |
| // instead in the assignment below. | |
| ].forEach(function (name) { | |
| properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty | |
| name, // attributeName | |
| null, // attributeNamespace | |
| false); | |
| }); // These are HTML attributes that must be numbers. | |
| ['rowSpan', 'start'].forEach(function (name) { | |
| properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty | |
| name.toLowerCase(), // attributeName | |
| null, // attributeNamespace | |
| false); | |
| }); | |
| var CAMELIZE = /[\-\:]([a-z])/g; | |
| var capitalize = function (token) { | |
| return token[1].toUpperCase(); | |
| }; // This is a list of all SVG attributes that need special casing, namespacing, | |
| // or boolean value assignment. Regular attributes that just accept strings | |
| // and have the same names are omitted, just like in the HTML whitelist. | |
| // Some of these attributes can be hard to find. This list was created by | |
| // scraping the MDN documentation. | |
| ['accent-height', 'alignment-baseline', 'arabic-form', 'baseline-shift', 'cap-height', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'dominant-baseline', 'enable-background', 'fill-opacity', 'fill-rule', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-name', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'horiz-adv-x', 'horiz-origin-x', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'overline-position', 'overline-thickness', 'paint-order', 'panose-1', 'pointer-events', 'rendering-intent', 'shape-rendering', 'stop-color', 'stop-opacity', 'strikethrough-position', 'strikethrough-thickness', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'underline-position', 'underline-thickness', 'unicode-bidi', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'vector-effect', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'word-spacing', 'writing-mode', 'xmlns:xlink', 'x-height' // NOTE: if you add a camelCased prop to this list, | |
| // you'll need to set attributeName to name.toLowerCase() | |
| // instead in the assignment below. | |
| ].forEach(function (attributeName) { | |
| var name = attributeName.replace(CAMELIZE, capitalize); | |
| properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty | |
| attributeName, null, // attributeNamespace | |
| false); | |
| }); // String SVG attributes with the xlink namespace. | |
| ['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type' // NOTE: if you add a camelCased prop to this list, | |
| // you'll need to set attributeName to name.toLowerCase() | |
| // instead in the assignment below. | |
| ].forEach(function (attributeName) { | |
| var name = attributeName.replace(CAMELIZE, capitalize); | |
| properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty | |
| attributeName, 'http://www.w3.org/1999/xlink', false); | |
| }); // String SVG attributes with the xml namespace. | |
| ['xml:base', 'xml:lang', 'xml:space' // NOTE: if you add a camelCased prop to this list, | |
| // you'll need to set attributeName to name.toLowerCase() | |
| // instead in the assignment below. | |
| ].forEach(function (attributeName) { | |
| var name = attributeName.replace(CAMELIZE, capitalize); | |
| properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty | |
| attributeName, 'http://www.w3.org/XML/1998/namespace', false); | |
| }); // These attribute exists both in HTML and SVG. | |
| // The attribute name is case-sensitive in SVG so we can't just use | |
| // the React name like we do for attributes that exist only in HTML. | |
| ['tabIndex', 'crossOrigin'].forEach(function (attributeName) { | |
| properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty | |
| attributeName.toLowerCase(), // attributeName | |
| null, // attributeNamespace | |
| false); | |
| }); // These attributes accept URLs. These must not allow javascript: URLS. | |
| // These will also need to accept Trusted Types object in the future. | |
| var xlinkHref = 'xlinkHref'; | |
| properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty | |
| 'xlink:href', 'http://www.w3.org/1999/xlink', true); | |
| ['src', 'href', 'action', 'formAction'].forEach(function (attributeName) { | |
| properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty | |
| attributeName.toLowerCase(), // attributeName | |
| null, // attributeNamespace | |
| true); | |
| }); | |
| var ReactDebugCurrentFrame = null; | |
| { | |
| ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; | |
| } // A javascript: URL can contain leading C0 control or \u0020 SPACE, | |
| // and any newline or tab are filtered out as if they're not part of the URL. | |
| // https://url.spec.whatwg.org/#url-parsing | |
| // Tab or newline are defined as \r\n\t: | |
| // https://infra.spec.whatwg.org/#ascii-tab-or-newline | |
| // A C0 control is a code point in the range \u0000 NULL to \u001F | |
| // INFORMATION SEPARATOR ONE, inclusive: | |
| // https://infra.spec.whatwg.org/#c0-control-or-space | |
| /* eslint-disable max-len */ | |
| var isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i; | |
| var didWarn = false; | |
| function sanitizeURL(url) { | |
| { | |
| if (!didWarn && isJavaScriptProtocol.test(url)) { | |
| didWarn = true; | |
| error('A future version of React will block javascript: URLs as a security precaution. ' + 'Use event handlers instead if you can. If you need to generate unsafe HTML try ' + 'using dangerouslySetInnerHTML instead. React was passed %s.', JSON.stringify(url)); | |
| } | |
| } | |
| } | |
| /** | |
| * Get the value for a property on a node. Only used in DEV for SSR validation. | |
| * The "expected" argument is used as a hint of what the expected value is. | |
| * Some properties have multiple equivalent values. | |
| */ | |
| function getValueForProperty(node, name, expected, propertyInfo) { | |
| { | |
| if (propertyInfo.mustUseProperty) { | |
| var propertyName = propertyInfo.propertyName; | |
| return node[propertyName]; | |
| } else { | |
| if ( propertyInfo.sanitizeURL) { | |
| // If we haven't fully disabled javascript: URLs, and if | |
| // the hydration is successful of a javascript: URL, we | |
| // still want to warn on the client. | |
| sanitizeURL('' + expected); | |
| } | |
| var attributeName = propertyInfo.attributeName; | |
| var stringValue = null; | |
| if (propertyInfo.type === OVERLOADED_BOOLEAN) { | |
| if (node.hasAttribute(attributeName)) { | |
| var value = node.getAttribute(attributeName); | |
| if (value === '') { | |
| return true; | |
| } | |
| if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { | |
| return value; | |
| } | |
| if (value === '' + expected) { | |
| return expected; | |
| } | |
| return value; | |
| } | |
| } else if (node.hasAttribute(attributeName)) { | |
| if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { | |
| // We had an attribute but shouldn't have had one, so read it | |
| // for the error message. | |
| return node.getAttribute(attributeName); | |
| } | |
| if (propertyInfo.type === BOOLEAN) { | |
| // If this was a boolean, it doesn't matter what the value is | |
| // the fact that we have it is the same as the expected. | |
| return expected; | |
| } // Even if this property uses a namespace we use getAttribute | |
| // because we assume its namespaced name is the same as our config. | |
| // To use getAttributeNS we need the local name which we don't have | |
| // in our config atm. | |
| stringValue = node.getAttribute(attributeName); | |
| } | |
| if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { | |
| return stringValue === null ? expected : stringValue; | |
| } else if (stringValue === '' + expected) { | |
| return expected; | |
| } else { | |
| return stringValue; | |
| } | |
| } | |
| } | |
| } | |
| /** | |
| * Get the value for a attribute on a node. Only used in DEV for SSR validation. | |
| * The third argument is used as a hint of what the expected value is. Some | |
| * attributes have multiple equivalent values. | |
| */ | |
| function getValueForAttribute(node, name, expected) { | |
| { | |
| if (!isAttributeNameSafe(name)) { | |
| return; | |
| } | |
| if (!node.hasAttribute(name)) { | |
| return expected === undefined ? undefined : null; | |
| } | |
| var value = node.getAttribute(name); | |
| if (value === '' + expected) { | |
| return expected; | |
| } | |
| return value; | |
| } | |
| } | |
| /** | |
| * Sets the value for a property on a node. | |
| * | |
| * @param {DOMElement} node | |
| * @param {string} name | |
| * @param {*} value | |
| */ | |
| function setValueForProperty(node, name, value, isCustomComponentTag) { | |
| var propertyInfo = getPropertyInfo(name); | |
| if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) { | |
| return; | |
| } | |
| if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) { | |
| value = null; | |
| } // If the prop isn't in the special list, treat it as a simple attribute. | |
| if (isCustomComponentTag || propertyInfo === null) { | |
| if (isAttributeNameSafe(name)) { | |
| var _attributeName = name; | |
| if (value === null) { | |
| node.removeAttribute(_attributeName); | |
| } else { | |
| node.setAttribute(_attributeName, '' + value); | |
| } | |
| } | |
| return; | |
| } | |
| var mustUseProperty = propertyInfo.mustUseProperty; | |
| if (mustUseProperty) { | |
| var propertyName = propertyInfo.propertyName; | |
| if (value === null) { | |
| var type = propertyInfo.type; | |
| node[propertyName] = type === BOOLEAN ? false : ''; | |
| } else { | |
| // Contrary to `setAttribute`, object properties are properly | |
| // `toString`ed by IE8/9. | |
| node[propertyName] = value; | |
| } | |
| return; | |
| } // The rest are treated as attributes with special cases. | |
| var attributeName = propertyInfo.attributeName, | |
| attributeNamespace = propertyInfo.attributeNamespace; | |
| if (value === null) { | |
| node.removeAttribute(attributeName); | |
| } else { | |
| var _type = propertyInfo.type; | |
| var attributeValue; | |
| if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) { | |
| // If attribute type is boolean, we know for sure it won't be an execution sink | |
| // and we won't require Trusted Type here. | |
| attributeValue = ''; | |
| } else { | |
| // `setAttribute` with objects becomes only `[object]` in IE8/9, | |
| // ('' + value) makes it output the correct toString()-value. | |
| { | |
| attributeValue = '' + value; | |
| } | |
| if (propertyInfo.sanitizeURL) { | |
| sanitizeURL(attributeValue.toString()); | |
| } | |
| } | |
| if (attributeNamespace) { | |
| node.setAttributeNS(attributeNamespace, attributeName, attributeValue); | |
| } else { | |
| node.setAttribute(attributeName, attributeValue); | |
| } | |
| } | |
| } | |
| var BEFORE_SLASH_RE = /^(.*)[\\\/]/; | |
| function describeComponentFrame (name, source, ownerName) { | |
| var sourceInfo = ''; | |
| if (source) { | |
| var path = source.fileName; | |
| var fileName = path.replace(BEFORE_SLASH_RE, ''); | |
| { | |
| // In DEV, include code for a common special case: | |
| // prefer "folder/index.js" instead of just "index.js". | |
| if (/^index\./.test(fileName)) { | |
| var match = path.match(BEFORE_SLASH_RE); | |
| if (match) { | |
| var pathBeforeSlash = match[1]; | |
| if (pathBeforeSlash) { | |
| var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ''); | |
| fileName = folderName + '/' + fileName; | |
| } | |
| } | |
| } | |
| } | |
| sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')'; | |
| } else if (ownerName) { | |
| sourceInfo = ' (created by ' + ownerName + ')'; | |
| } | |
| return '\n in ' + (name || 'Unknown') + sourceInfo; | |
| } | |
| // The Symbol used to tag the ReactElement-like types. If there is no native Symbol | |
| // nor polyfill, then a plain number is used for performance. | |
| var hasSymbol = typeof Symbol === 'function' && Symbol.for; | |
| var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; | |
| var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; | |
| var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; | |
| var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; | |
| var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; | |
| var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; | |
| var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary | |
| var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; | |
| var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; | |
| var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; | |
| var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; | |
| var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; | |
| var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; | |
| var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9; | |
| var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; | |
| var FAUX_ITERATOR_SYMBOL = '@@iterator'; | |
| function getIteratorFn(maybeIterable) { | |
| if (maybeIterable === null || typeof maybeIterable !== 'object') { | |
| return null; | |
| } | |
| var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; | |
| if (typeof maybeIterator === 'function') { | |
| return maybeIterator; | |
| } | |
| return null; | |
| } | |
| var Uninitialized = -1; | |
| var Pending = 0; | |
| var Resolved = 1; | |
| var Rejected = 2; | |
| function refineResolvedLazyComponent(lazyComponent) { | |
| return lazyComponent._status === Resolved ? lazyComponent._result : null; | |
| } | |
| function initializeLazyComponentType(lazyComponent) { | |
| if (lazyComponent._status === Uninitialized) { | |
| lazyComponent._status = Pending; | |
| var ctor = lazyComponent._ctor; | |
| var thenable = ctor(); | |
| lazyComponent._result = thenable; | |
| thenable.then(function (moduleObject) { | |
| if (lazyComponent._status === Pending) { | |
| var defaultExport = moduleObject.default; | |
| { | |
| if (defaultExport === undefined) { | |
| error('lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + "const MyComponent = lazy(() => import('./MyComponent'))", moduleObject); | |
| } | |
| } | |
| lazyComponent._status = Resolved; | |
| lazyComponent._result = defaultExport; | |
| } | |
| }, function (error) { | |
| if (lazyComponent._status === Pending) { | |
| lazyComponent._status = Rejected; | |
| lazyComponent._result = error; | |
| } | |
| }); | |
| } | |
| } | |
| function getWrappedName(outerType, innerType, wrapperName) { | |
| var functionName = innerType.displayName || innerType.name || ''; | |
| return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); | |
| } | |
| function getComponentName(type) { | |
| if (type == null) { | |
| // Host root, text node or just invalid type. | |
| return null; | |
| } | |
| { | |
| if (typeof type.tag === 'number') { | |
| error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); | |
| } | |
| } | |
| if (typeof type === 'function') { | |
| return type.displayName || type.name || null; | |
| } | |
| if (typeof type === 'string') { | |
| return type; | |
| } | |
| switch (type) { | |
| case REACT_FRAGMENT_TYPE: | |
| return 'Fragment'; | |
| case REACT_PORTAL_TYPE: | |
| return 'Portal'; | |
| case REACT_PROFILER_TYPE: | |
| return "Profiler"; | |
| case REACT_STRICT_MODE_TYPE: | |
| return 'StrictMode'; | |
| case REACT_SUSPENSE_TYPE: | |
| return 'Suspense'; | |
| case REACT_SUSPENSE_LIST_TYPE: | |
| return 'SuspenseList'; | |
| } | |
| if (typeof type === 'object') { | |
| switch (type.$$typeof) { | |
| case REACT_CONTEXT_TYPE: | |
| return 'Context.Consumer'; | |
| case REACT_PROVIDER_TYPE: | |
| return 'Context.Provider'; | |
| case REACT_FORWARD_REF_TYPE: | |
| return getWrappedName(type, type.render, 'ForwardRef'); | |
| case REACT_MEMO_TYPE: | |
| return getComponentName(type.type); | |
| case REACT_BLOCK_TYPE: | |
| return getComponentName(type.render); | |
| case REACT_LAZY_TYPE: | |
| { | |
| var thenable = type; | |
| var resolvedThenable = refineResolvedLazyComponent(thenable); | |
| if (resolvedThenable) { | |
| return getComponentName(resolvedThenable); | |
| } | |
| break; | |
| } | |
| } | |
| } | |
| return null; | |
| } | |
| var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; | |
| function describeFiber(fiber) { | |
| switch (fiber.tag) { | |
| case HostRoot: | |
| case HostPortal: | |
| case HostText: | |
| case Fragment: | |
| case ContextProvider: | |
| case ContextConsumer: | |
| return ''; | |
| default: | |
| var owner = fiber._debugOwner; | |
| var source = fiber._debugSource; | |
| var name = getComponentName(fiber.type); | |
| var ownerName = null; | |
| if (owner) { | |
| ownerName = getComponentName(owner.type); | |
| } | |
| return describeComponentFrame(name, source, ownerName); | |
| } | |
| } | |
| function getStackByFiberInDevAndProd(workInProgress) { | |
| var info = ''; | |
| var node = workInProgress; | |
| do { | |
| info += describeFiber(node); | |
| node = node.return; | |
| } while (node); | |
| return info; | |
| } | |
| var current = null; | |
| var isRendering = false; | |
| function getCurrentFiberOwnerNameInDevOrNull() { | |
| { | |
| if (current === null) { | |
| return null; | |
| } | |
| var owner = current._debugOwner; | |
| if (owner !== null && typeof owner !== 'undefined') { | |
| return getComponentName(owner.type); | |
| } | |
| } | |
| return null; | |
| } | |
| function getCurrentFiberStackInDev() { | |
| { | |
| if (current === null) { | |
| return ''; | |
| } // Safe because if current fiber exists, we are reconciling, | |
| // and it is guaranteed to be the work-in-progress version. | |
| return getStackByFiberInDevAndProd(current); | |
| } | |
| } | |
| function resetCurrentFiber() { | |
| { | |
| ReactDebugCurrentFrame$1.getCurrentStack = null; | |
| current = null; | |
| isRendering = false; | |
| } | |
| } | |
| function setCurrentFiber(fiber) { | |
| { | |
| ReactDebugCurrentFrame$1.getCurrentStack = getCurrentFiberStackInDev; | |
| current = fiber; | |
| isRendering = false; | |
| } | |
| } | |
| function setIsRendering(rendering) { | |
| { | |
| isRendering = rendering; | |
| } | |
| } | |
| // Flow does not allow string concatenation of most non-string types. To work | |
| // around this limitation, we use an opaque type that can only be obtained by | |
| // passing the value through getToStringValue first. | |
| function toString(value) { | |
| return '' + value; | |
| } | |
| function getToStringValue(value) { | |
| switch (typeof value) { | |
| case 'boolean': | |
| case 'number': | |
| case 'object': | |
| case 'string': | |
| case 'undefined': | |
| return value; | |
| default: | |
| // function, symbol are assigned as empty strings | |
| return ''; | |
| } | |
| } | |
| var ReactDebugCurrentFrame$2 = null; | |
| var ReactControlledValuePropTypes = { | |
| checkPropTypes: null | |
| }; | |
| { | |
| ReactDebugCurrentFrame$2 = ReactSharedInternals.ReactDebugCurrentFrame; | |
| var hasReadOnlyValue = { | |
| button: true, | |
| checkbox: true, | |
| image: true, | |
| hidden: true, | |
| radio: true, | |
| reset: true, | |
| submit: true | |
| }; | |
| var propTypes = { | |
| value: function (props, propName, componentName) { | |
| if (hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled || props[propName] == null || enableDeprecatedFlareAPI ) { | |
| return null; | |
| } | |
| return new Error('You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.'); | |
| }, | |
| checked: function (props, propName, componentName) { | |
| if (props.onChange || props.readOnly || props.disabled || props[propName] == null || enableDeprecatedFlareAPI ) { | |
| return null; | |
| } | |
| return new Error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.'); | |
| } | |
| }; | |
| /** | |
| * Provide a linked `value` attribute for controlled forms. You should not use | |
| * this outside of the ReactDOM controlled form components. | |
| */ | |
| ReactControlledValuePropTypes.checkPropTypes = function (tagName, props) { | |
| checkPropTypes(propTypes, props, 'prop', tagName, ReactDebugCurrentFrame$2.getStackAddendum); | |
| }; | |
| } | |
| function isCheckable(elem) { | |
| var type = elem.type; | |
| var nodeName = elem.nodeName; | |
| return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio'); | |
| } | |
| function getTracker(node) { | |
| return node._valueTracker; | |
| } | |
| function detachTracker(node) { | |
| node._valueTracker = null; | |
| } | |
| function getValueFromNode(node) { | |
| var value = ''; | |
| if (!node) { | |
| return value; | |
| } | |
| if (isCheckable(node)) { | |
| value = node.checked ? 'true' : 'false'; | |
| } else { | |
| value = node.value; | |
| } | |
| return value; | |
| } | |
| function trackValueOnNode(node) { | |
| var valueField = isCheckable(node) ? 'checked' : 'value'; | |
| var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField); | |
| var currentValue = '' + node[valueField]; // if someone has already defined a value or Safari, then bail | |
| // and don't track value will cause over reporting of changes, | |
| // but it's better then a hard failure | |
| // (needed for certain tests that spyOn input values and Safari) | |
| if (node.hasOwnProperty(valueField) || typeof descriptor === 'undefined' || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') { | |
| return; | |
| } | |
| var get = descriptor.get, | |
| set = descriptor.set; | |
| Object.defineProperty(node, valueField, { | |
| configurable: true, | |
| get: function () { | |
| return get.call(this); | |
| }, | |
| set: function (value) { | |
| currentValue = '' + value; | |
| set.call(this, value); | |
| } | |
| }); // We could've passed this the first time | |
| // but it triggers a bug in IE11 and Edge 14/15. | |
| // Calling defineProperty() again should be equivalent. | |
| // https://github.com/facebook/react/issues/11768 | |
| Object.defineProperty(node, valueField, { | |
| enumerable: descriptor.enumerable | |
| }); | |
| var tracker = { | |
| getValue: function () { | |
| return currentValue; | |
| }, | |
| setValue: function (value) { | |
| currentValue = '' + value; | |
| }, | |
| stopTracking: function () { | |
| detachTracker(node); | |
| delete node[valueField]; | |
| } | |
| }; | |
| return tracker; | |
| } | |
| function track(node) { | |
| if (getTracker(node)) { | |
| return; | |
| } // TODO: Once it's just Fiber we can move this to node._wrapperState | |
| node._valueTracker = trackValueOnNode(node); | |
| } | |
| function updateValueIfChanged(node) { | |
| if (!node) { | |
| return false; | |
| } | |
| var tracker = getTracker(node); // if there is no tracker at this point it's unlikely | |
| // that trying again will succeed | |
| if (!tracker) { | |
| return true; | |
| } | |
| var lastValue = tracker.getValue(); | |
| var nextValue = getValueFromNode(node); | |
| if (nextValue !== lastValue) { | |
| tracker.setValue(nextValue); | |
| return true; | |
| } | |
| return false; | |
| } | |
| var didWarnValueDefaultValue = false; | |
| var didWarnCheckedDefaultChecked = false; | |
| var didWarnControlledToUncontrolled = false; | |
| var didWarnUncontrolledToControlled = false; | |
| function isControlled(props) { | |
| var usesChecked = props.type === 'checkbox' || props.type === 'radio'; | |
| return usesChecked ? props.checked != null : props.value != null; | |
| } | |
| /** | |
| * Implements an <input> host component that allows setting these optional | |
| * props: `checked`, `value`, `defaultChecked`, and `defaultValue`. | |
| * | |
| * If `checked` or `value` are not supplied (or null/undefined), user actions | |
| * that affect the checked state or value will trigger updates to the element. | |
| * | |
| * If they are supplied (and not null/undefined), the rendered element will not | |
| * trigger updates to the element. Instead, the props must change in order for | |
| * the rendered element to be updated. | |
| * | |
| * The rendered element will be initialized as unchecked (or `defaultChecked`) | |
| * with an empty value (or `defaultValue`). | |
| * | |
| * See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html | |
| */ | |
| function getHostProps(element, props) { | |
| var node = element; | |
| var checked = props.checked; | |
| var hostProps = _assign({}, props, { | |
| defaultChecked: undefined, | |
| defaultValue: undefined, | |
| value: undefined, | |
| checked: checked != null ? checked : node._wrapperState.initialChecked | |
| }); | |
| return hostProps; | |
| } | |
| function initWrapperState(element, props) { | |
| { | |
| ReactControlledValuePropTypes.checkPropTypes('input', props); | |
| if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) { | |
| error('%s contains an input of type %s with both checked and defaultChecked props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type); | |
| didWarnCheckedDefaultChecked = true; | |
| } | |
| if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) { | |
| error('%s contains an input of type %s with both value and defaultValue props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type); | |
| didWarnValueDefaultValue = true; | |
| } | |
| } | |
| var node = element; | |
| var defaultValue = props.defaultValue == null ? '' : props.defaultValue; | |
| node._wrapperState = { | |
| initialChecked: props.checked != null ? props.checked : props.defaultChecked, | |
| initialValue: getToStringValue(props.value != null ? props.value : defaultValue), | |
| controlled: isControlled(props) | |
| }; | |
| } | |
| function updateChecked(element, props) { | |
| var node = element; | |
| var checked = props.checked; | |
| if (checked != null) { | |
| setValueForProperty(node, 'checked', checked, false); | |
| } | |
| } | |
| function updateWrapper(element, props) { | |
| var node = element; | |
| { | |
| var controlled = isControlled(props); | |
| if (!node._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) { | |
| error('A component is changing an uncontrolled input of type %s to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', props.type); | |
| didWarnUncontrolledToControlled = true; | |
| } | |
| if (node._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) { | |
| error('A component is changing a controlled input of type %s to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', props.type); | |
| didWarnControlledToUncontrolled = true; | |
| } | |
| } | |
| updateChecked(element, props); | |
| var value = getToStringValue(props.value); | |
| var type = props.type; | |
| if (value != null) { | |
| if (type === 'number') { | |
| if (value === 0 && node.value === '' || // We explicitly want to coerce to number here if possible. | |
| // eslint-disable-next-line | |
| node.value != value) { | |
| node.value = toString(value); | |
| } | |
| } else if (node.value !== toString(value)) { | |
| node.value = toString(value); | |
| } | |
| } else if (type === 'submit' || type === 'reset') { | |
| // Submit/reset inputs need the attribute removed completely to avoid | |
| // blank-text buttons. | |
| node.removeAttribute('value'); | |
| return; | |
| } | |
| { | |
| // When syncing the value attribute, the value comes from a cascade of | |
| // properties: | |
| // 1. The value React property | |
| // 2. The defaultValue React property | |
| // 3. Otherwise there should be no change | |
| if (props.hasOwnProperty('value')) { | |
| setDefaultValue(node, props.type, value); | |
| } else if (props.hasOwnProperty('defaultValue')) { | |
| setDefaultValue(node, props.type, getToStringValue(props.defaultValue)); | |
| } | |
| } | |
| { | |
| // When syncing the checked attribute, it only changes when it needs | |
| // to be removed, such as transitioning from a checkbox into a text input | |
| if (props.checked == null && props.defaultChecked != null) { | |
| node.defaultChecked = !!props.defaultChecked; | |
| } | |
| } | |
| } | |
| function postMountWrapper(element, props, isHydrating) { | |
| var node = element; // Do not assign value if it is already set. This prevents user text input | |
| // from being lost during SSR hydration. | |
| if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) { | |
| var type = props.type; | |
| var isButton = type === 'submit' || type === 'reset'; // Avoid setting value attribute on submit/reset inputs as it overrides the | |
| // default value provided by the browser. See: #12872 | |
| if (isButton && (props.value === undefined || props.value === null)) { | |
| return; | |
| } | |
| var initialValue = toString(node._wrapperState.initialValue); // Do not assign value if it is already set. This prevents user text input | |
| // from being lost during SSR hydration. | |
| if (!isHydrating) { | |
| { | |
| // When syncing the value attribute, the value property should use | |
| // the wrapperState._initialValue property. This uses: | |
| // | |
| // 1. The value React property when present | |
| // 2. The defaultValue React property when present | |
| // 3. An empty string | |
| if (initialValue !== node.value) { | |
| node.value = initialValue; | |
| } | |
| } | |
| } | |
| { | |
| // Otherwise, the value attribute is synchronized to the property, | |
| // so we assign defaultValue to the same thing as the value property | |
| // assignment step above. | |
| node.defaultValue = initialValue; | |
| } | |
| } // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug | |
| // this is needed to work around a chrome bug where setting defaultChecked | |
| // will sometimes influence the value of checked (even after detachment). | |
| // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416 | |
| // We need to temporarily unset name to avoid disrupting radio button groups. | |
| var name = node.name; | |
| if (name !== '') { | |
| node.name = ''; | |
| } | |
| { | |
| // When syncing the checked attribute, both the checked property and | |
| // attribute are assigned at the same time using defaultChecked. This uses: | |
| // | |
| // 1. The checked React property when present | |
| // 2. The defaultChecked React property when present | |
| // 3. Otherwise, false | |
| node.defaultChecked = !node.defaultChecked; | |
| node.defaultChecked = !!node._wrapperState.initialChecked; | |
| } | |
| if (name !== '') { | |
| node.name = name; | |
| } | |
| } | |
| function restoreControlledState(element, props) { | |
| var node = element; | |
| updateWrapper(node, props); | |
| updateNamedCousins(node, props); | |
| } | |
| function updateNamedCousins(rootNode, props) { | |
| var name = props.name; | |
| if (props.type === 'radio' && name != null) { | |
| var queryRoot = rootNode; | |
| while (queryRoot.parentNode) { | |
| queryRoot = queryRoot.parentNode; | |
| } // If `rootNode.form` was non-null, then we could try `form.elements`, | |
| // but that sometimes behaves strangely in IE8. We could also try using | |
| // `form.getElementsByName`, but that will only return direct children | |
| // and won't include inputs that use the HTML5 `form=` attribute. Since | |
| // the input might not even be in a form. It might not even be in the | |
| // document. Let's just use the local `querySelectorAll` to ensure we don't | |
| // miss anything. | |
| var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]'); | |
| for (var i = 0; i < group.length; i++) { | |
| var otherNode = group[i]; | |
| if (otherNode === rootNode || otherNode.form !== rootNode.form) { | |
| continue; | |
| } // This will throw if radio buttons rendered by different copies of React | |
| // and the same name are rendered into the same form (same as #1939). | |
| // That's probably okay; we don't support it just as we don't support | |
| // mixing React radio buttons with non-React ones. | |
| var otherProps = getFiberCurrentPropsFromNode$1(otherNode); | |
| if (!otherProps) { | |
| { | |
| throw Error( "ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported." ); | |
| } | |
| } // We need update the tracked value on the named cousin since the value | |
| // was changed but the input saw no event or value set | |
| updateValueIfChanged(otherNode); // If this is a controlled radio button group, forcing the input that | |
| // was previously checked to update will cause it to be come re-checked | |
| // as appropriate. | |
| updateWrapper(otherNode, otherProps); | |
| } | |
| } | |
| } // In Chrome, assigning defaultValue to certain input types triggers input validation. | |
| // For number inputs, the display value loses trailing decimal points. For email inputs, | |
| // Chrome raises "The specified value <x> is not a valid email address". | |
| // | |
| // Here we check to see if the defaultValue has actually changed, avoiding these problems | |
| // when the user is inputting text | |
| // | |
| // https://github.com/facebook/react/issues/7253 | |
| function setDefaultValue(node, type, value) { | |
| if ( // Focused number inputs synchronize on blur. See ChangeEventPlugin.js | |
| type !== 'number' || node.ownerDocument.activeElement !== node) { | |
| if (value == null) { | |
| node.defaultValue = toString(node._wrapperState.initialValue); | |
| } else if (node.defaultValue !== toString(value)) { | |
| node.defaultValue = toString(value); | |
| } | |
| } | |
| } | |
| var didWarnSelectedSetOnOption = false; | |
| var didWarnInvalidChild = false; | |
| function flattenChildren(children) { | |
| var content = ''; // Flatten children. We'll warn if they are invalid | |
| // during validateProps() which runs for hydration too. | |
| // Note that this would throw on non-element objects. | |
| // Elements are stringified (which is normally irrelevant | |
| // but matters for <fbt>). | |
| React.Children.forEach(children, function (child) { | |
| if (child == null) { | |
| return; | |
| } | |
| content += child; // Note: we don't warn about invalid children here. | |
| // Instead, this is done separately below so that | |
| // it happens during the hydration codepath too. | |
| }); | |
| return content; | |
| } | |
| /** | |
| * Implements an <option> host component that warns when `selected` is set. | |
| */ | |
| function validateProps(element, props) { | |
| { | |
| // This mirrors the codepath above, but runs for hydration too. | |
| // Warn about invalid children here so that client and hydration are consistent. | |
| // TODO: this seems like it could cause a DEV-only throw for hydration | |
| // if children contains a non-element object. We should try to avoid that. | |
| if (typeof props.children === 'object' && props.children !== null) { | |
| React.Children.forEach(props.children, function (child) { | |
| if (child == null) { | |
| return; | |
| } | |
| if (typeof child === 'string' || typeof child === 'number') { | |
| return; | |
| } | |
| if (typeof child.type !== 'string') { | |
| return; | |
| } | |
| if (!didWarnInvalidChild) { | |
| didWarnInvalidChild = true; | |
| error('Only strings and numbers are supported as <option> children.'); | |
| } | |
| }); | |
| } // TODO: Remove support for `selected` in <option>. | |
| if (props.selected != null && !didWarnSelectedSetOnOption) { | |
| error('Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.'); | |
| didWarnSelectedSetOnOption = true; | |
| } | |
| } | |
| } | |
| function postMountWrapper$1(element, props) { | |
| // value="" should make a value attribute (#6219) | |
| if (props.value != null) { | |
| element.setAttribute('value', toString(getToStringValue(props.value))); | |
| } | |
| } | |
| function getHostProps$1(element, props) { | |
| var hostProps = _assign({ | |
| children: undefined | |
| }, props); | |
| var content = flattenChildren(props.children); | |
| if (content) { | |
| hostProps.children = content; | |
| } | |
| return hostProps; | |
| } | |
| var didWarnValueDefaultValue$1; | |
| { | |
| didWarnValueDefaultValue$1 = false; | |
| } | |
| function getDeclarationErrorAddendum() { | |
| var ownerName = getCurrentFiberOwnerNameInDevOrNull(); | |
| if (ownerName) { | |
| return '\n\nCheck the render method of `' + ownerName + '`.'; | |
| } | |
| return ''; | |
| } | |
| var valuePropNames = ['value', 'defaultValue']; | |
| /** | |
| * Validation function for `value` and `defaultValue`. | |
| */ | |
| function checkSelectPropTypes(props) { | |
| { | |
| ReactControlledValuePropTypes.checkPropTypes('select', props); | |
| for (var i = 0; i < valuePropNames.length; i++) { | |
| var propName = valuePropNames[i]; | |
| if (props[propName] == null) { | |
| continue; | |
| } | |
| var isArray = Array.isArray(props[propName]); | |
| if (props.multiple && !isArray) { | |
| error('The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum()); | |
| } else if (!props.multiple && isArray) { | |
| error('The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum()); | |
| } | |
| } | |
| } | |
| } | |
| function updateOptions(node, multiple, propValue, setDefaultSelected) { | |
| var options = node.options; | |
| if (multiple) { | |
| var selectedValues = propValue; | |
| var selectedValue = {}; | |
| for (var i = 0; i < selectedValues.length; i++) { | |
| // Prefix to avoid chaos with special keys. | |
| selectedValue['$' + selectedValues[i]] = true; | |
| } | |
| for (var _i = 0; _i < options.length; _i++) { | |
| var selected = selectedValue.hasOwnProperty('$' + options[_i].value); | |
| if (options[_i].selected !== selected) { | |
| options[_i].selected = selected; | |
| } | |
| if (selected && setDefaultSelected) { | |
| options[_i].defaultSelected = true; | |
| } | |
| } | |
| } else { | |
| // Do not set `select.value` as exact behavior isn't consistent across all | |
| // browsers for all cases. | |
| var _selectedValue = toString(getToStringValue(propValue)); | |
| var defaultSelected = null; | |
| for (var _i2 = 0; _i2 < options.length; _i2++) { | |
| if (options[_i2].value === _selectedValue) { | |
| options[_i2].selected = true; | |
| if (setDefaultSelected) { | |
| options[_i2].defaultSelected = true; | |
| } | |
| return; | |
| } | |
| if (defaultSelected === null && !options[_i2].disabled) { | |
| defaultSelected = options[_i2]; | |
| } | |
| } | |
| if (defaultSelected !== null) { | |
| defaultSelected.selected = true; | |
| } | |
| } | |
| } | |
| /** | |
| * Implements a <select> host component that allows optionally setting the | |
| * props `value` and `defaultValue`. If `multiple` is false, the prop must be a | |
| * stringable. If `multiple` is true, the prop must be an array of stringables. | |
| * | |
| * If `value` is not supplied (or null/undefined), user actions that change the | |
| * selected option will trigger updates to the rendered options. | |
| * | |
| * If it is supplied (and not null/undefined), the rendered options will not | |
| * update in response to user actions. Instead, the `value` prop must change in | |
| * order for the rendered options to update. | |
| * | |
| * If `defaultValue` is provided, any options with the supplied values will be | |
| * selected. | |
| */ | |
| function getHostProps$2(element, props) { | |
| return _assign({}, props, { | |
| value: undefined | |
| }); | |
| } | |
| function initWrapperState$1(element, props) { | |
| var node = element; | |
| { | |
| checkSelectPropTypes(props); | |
| } | |
| node._wrapperState = { | |
| wasMultiple: !!props.multiple | |
| }; | |
| { | |
| if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue$1) { | |
| error('Select elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled select ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components'); | |
| didWarnValueDefaultValue$1 = true; | |
| } | |
| } | |
| } | |
| function postMountWrapper$2(element, props) { | |
| var node = element; | |
| node.multiple = !!props.multiple; | |
| var value = props.value; | |
| if (value != null) { | |
| updateOptions(node, !!props.multiple, value, false); | |
| } else if (props.defaultValue != null) { | |
| updateOptions(node, !!props.multiple, props.defaultValue, true); | |
| } | |
| } | |
| function postUpdateWrapper(element, props) { | |
| var node = element; | |
| var wasMultiple = node._wrapperState.wasMultiple; | |
| node._wrapperState.wasMultiple = !!props.multiple; | |
| var value = props.value; | |
| if (value != null) { | |
| updateOptions(node, !!props.multiple, value, false); | |
| } else if (wasMultiple !== !!props.multiple) { | |
| // For simplicity, reapply `defaultValue` if `multiple` is toggled. | |
| if (props.defaultValue != null) { | |
| updateOptions(node, !!props.multiple, props.defaultValue, true); | |
| } else { | |
| // Revert the select back to its default unselected state. | |
| updateOptions(node, !!props.multiple, props.multiple ? [] : '', false); | |
| } | |
| } | |
| } | |
| function restoreControlledState$1(element, props) { | |
| var node = element; | |
| var value = props.value; | |
| if (value != null) { | |
| updateOptions(node, !!props.multiple, value, false); | |
| } | |
| } | |
| var didWarnValDefaultVal = false; | |
| /** | |
| * Implements a <textarea> host component that allows setting `value`, and | |
| * `defaultValue`. This differs from the traditional DOM API because value is | |
| * usually set as PCDATA children. | |
| * | |
| * If `value` is not supplied (or null/undefined), user actions that affect the | |
| * value will trigger updates to the element. | |
| * | |
| * If `value` is supplied (and not null/undefined), the rendered element will | |
| * not trigger updates to the element. Instead, the `value` prop must change in | |
| * order for the rendered element to be updated. | |
| * | |
| * The rendered element will be initialized with an empty value, the prop | |
| * `defaultValue` if specified, or the children content (deprecated). | |
| */ | |
| function getHostProps$3(element, props) { | |
| var node = element; | |
| if (!(props.dangerouslySetInnerHTML == null)) { | |
| { | |
| throw Error( "`dangerouslySetInnerHTML` does not make sense on <textarea>." ); | |
| } | |
| } // Always set children to the same thing. In IE9, the selection range will | |
| // get reset if `textContent` is mutated. We could add a check in setTextContent | |
| // to only set the value if/when the value differs from the node value (which would | |
| // completely solve this IE9 bug), but Sebastian+Sophie seemed to like this | |
| // solution. The value can be a boolean or object so that's why it's forced | |
| // to be a string. | |
| var hostProps = _assign({}, props, { | |
| value: undefined, | |
| defaultValue: undefined, | |
| children: toString(node._wrapperState.initialValue) | |
| }); | |
| return hostProps; | |
| } | |
| function initWrapperState$2(element, props) { | |
| var node = element; | |
| { | |
| ReactControlledValuePropTypes.checkPropTypes('textarea', props); | |
| if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) { | |
| error('%s contains a textarea with both value and defaultValue props. ' + 'Textarea elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled textarea ' + 'and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component'); | |
| didWarnValDefaultVal = true; | |
| } | |
| } | |
| var initialValue = props.value; // Only bother fetching default value if we're going to use it | |
| if (initialValue == null) { | |
| var children = props.children, | |
| defaultValue = props.defaultValue; | |
| if (children != null) { | |
| { | |
| error('Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.'); | |
| } | |
| { | |
| if (!(defaultValue == null)) { | |
| { | |
| throw Error( "If you supply `defaultValue` on a <textarea>, do not pass children." ); | |
| } | |
| } | |
| if (Array.isArray(children)) { | |
| if (!(children.length <= 1)) { | |
| { | |
| throw Error( "<textarea> can only have at most one child." ); | |
| } | |
| } | |
| children = children[0]; | |
| } | |
| defaultValue = children; | |
| } | |
| } | |
| if (defaultValue == null) { | |
| defaultValue = ''; | |
| } | |
| initialValue = defaultValue; | |
| } | |
| node._wrapperState = { | |
| initialValue: getToStringValue(initialValue) | |
| }; | |
| } | |
| function updateWrapper$1(element, props) { | |
| var node = element; | |
| var value = getToStringValue(props.value); | |
| var defaultValue = getToStringValue(props.defaultValue); | |
| if (value != null) { | |
| // Cast `value` to a string to ensure the value is set correctly. While | |
| // browsers typically do this as necessary, jsdom doesn't. | |
| var newValue = toString(value); // To avoid side effects (such as losing text selection), only set value if changed | |
| if (newValue !== node.value) { | |
| node.value = newValue; | |
| } | |
| if (props.defaultValue == null && node.defaultValue !== newValue) { | |
| node.defaultValue = newValue; | |
| } | |
| } | |
| if (defaultValue != null) { | |
| node.defaultValue = toString(defaultValue); | |
| } | |
| } | |
| function postMountWrapper$3(element, props) { | |
| var node = element; // This is in postMount because we need access to the DOM node, which is not | |
| // available until after the component has mounted. | |
| var textContent = node.textContent; // Only set node.value if textContent is equal to the expected | |
| // initial value. In IE10/IE11 there is a bug where the placeholder attribute | |
| // will populate textContent as well. | |
| // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/ | |
| if (textContent === node._wrapperState.initialValue) { | |
| if (textContent !== '' && textContent !== null) { | |
| node.value = textContent; | |
| } | |
| } | |
| } | |
| function restoreControlledState$2(element, props) { | |
| // DOM component is still mounted; update | |
| updateWrapper$1(element, props); | |
| } | |
| var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; | |
| var MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; | |
| var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; | |
| var Namespaces = { | |
| html: HTML_NAMESPACE, | |
| mathml: MATH_NAMESPACE, | |
| svg: SVG_NAMESPACE | |
| }; // Assumes there is no parent namespace. | |
| function getIntrinsicNamespace(type) { | |
| switch (type) { | |
| case 'svg': | |
| return SVG_NAMESPACE; | |
| case 'math': | |
| return MATH_NAMESPACE; | |
| default: | |
| return HTML_NAMESPACE; | |
| } | |
| } | |
| function getChildNamespace(parentNamespace, type) { | |
| if (parentNamespace == null || parentNamespace === HTML_NAMESPACE) { | |
| // No (or default) parent namespace: potential entry point. | |
| return getIntrinsicNamespace(type); | |
| } | |
| if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') { | |
| // We're leaving SVG. | |
| return HTML_NAMESPACE; | |
| } // By default, pass namespace below. | |
| return parentNamespace; | |
| } | |
| /* globals MSApp */ | |
| /** | |
| * Create a function which has 'unsafe' privileges (required by windows8 apps) | |
| */ | |
| var createMicrosoftUnsafeLocalFunction = function (func) { | |
| if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) { | |
| return function (arg0, arg1, arg2, arg3) { | |
| MSApp.execUnsafeLocalFunction(function () { | |
| return func(arg0, arg1, arg2, arg3); | |
| }); | |
| }; | |
| } else { | |
| return func; | |
| } | |
| }; | |
| var reusableSVGContainer; | |
| /** | |
| * Set the innerHTML property of a node | |
| * | |
| * @param {DOMElement} node | |
| * @param {string} html | |
| * @internal | |
| */ | |
| var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) { | |
| if (node.namespaceURI === Namespaces.svg) { | |
| if (!('innerHTML' in node)) { | |
| // IE does not have innerHTML for SVG nodes, so instead we inject the | |
| // new markup in a temp node and then move the child nodes across into | |
| // the target node | |
| reusableSVGContainer = reusableSVGContainer || document.createElement('div'); | |
| reusableSVGContainer.innerHTML = '<svg>' + html.valueOf().toString() + '</svg>'; | |
| var svgNode = reusableSVGContainer.firstChild; | |
| while (node.firstChild) { | |
| node.removeChild(node.firstChild); | |
| } | |
| while (svgNode.firstChild) { | |
| node.appendChild(svgNode.firstChild); | |
| } | |
| return; | |
| } | |
| } | |
| node.innerHTML = html; | |
| }); | |
| /** | |
| * HTML nodeType values that represent the type of the node | |
| */ | |
| var ELEMENT_NODE = 1; | |
| var TEXT_NODE = 3; | |
| var COMMENT_NODE = 8; | |
| var DOCUMENT_NODE = 9; | |
| var DOCUMENT_FRAGMENT_NODE = 11; | |
| /** | |
| * Set the textContent property of a node. For text updates, it's faster | |
| * to set the `nodeValue` of the Text node directly instead of using | |
| * `.textContent` which will remove the existing node and create a new one. | |
| * | |
| * @param {DOMElement} node | |
| * @param {string} text | |
| * @internal | |
| */ | |
| var setTextContent = function (node, text) { | |
| if (text) { | |
| var firstChild = node.firstChild; | |
| if (firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE) { | |
| firstChild.nodeValue = text; | |
| return; | |
| } | |
| } | |
| node.textContent = text; | |
| }; | |
| // Do not use the below two methods directly! | |
| // Instead use constants exported from DOMTopLevelEventTypes in ReactDOM. | |
| // (It is the only module that is allowed to access these methods.) | |
| function unsafeCastStringToDOMTopLevelType(topLevelType) { | |
| return topLevelType; | |
| } | |
| function unsafeCastDOMTopLevelTypeToString(topLevelType) { | |
| return topLevelType; | |
| } | |
| /** | |
| * Generate a mapping of standard vendor prefixes using the defined style property and event name. | |
| * | |
| * @param {string} styleProp | |
| * @param {string} eventName | |
| * @returns {object} | |
| */ | |
| function makePrefixMap(styleProp, eventName) { | |
| var prefixes = {}; | |
| prefixes[styleProp.toLowerCase()] = eventName.toLowerCase(); | |
| prefixes['Webkit' + styleProp] = 'webkit' + eventName; | |
| prefixes['Moz' + styleProp] = 'moz' + eventName; | |
| return prefixes; | |
| } | |
| /** | |
| * A list of event names to a configurable list of vendor prefixes. | |
| */ | |
| var vendorPrefixes = { | |
| animationend: makePrefixMap('Animation', 'AnimationEnd'), | |
| animationiteration: makePrefixMap('Animation', 'AnimationIteration'), | |
| animationstart: makePrefixMap('Animation', 'AnimationStart'), | |
| transitionend: makePrefixMap('Transition', 'TransitionEnd') | |
| }; | |
| /** | |
| * Event names that have already been detected and prefixed (if applicable). | |
| */ | |
| var prefixedEventNames = {}; | |
| /** | |
| * Element to check for prefixes on. | |
| */ | |
| var style = {}; | |
| /** | |
| * Bootstrap if a DOM exists. | |
| */ | |
| if (canUseDOM) { | |
| style = document.createElement('div').style; // On some platforms, in particular some releases of Android 4.x, | |
| // the un-prefixed "animation" and "transition" properties are defined on the | |
| // style object but the events that fire will still be prefixed, so we need | |
| // to check if the un-prefixed events are usable, and if not remove them from the map. | |
| if (!('AnimationEvent' in window)) { | |
| delete vendorPrefixes.animationend.animation; | |
| delete vendorPrefixes.animationiteration.animation; | |
| delete vendorPrefixes.animationstart.animation; | |
| } // Same as above | |
| if (!('TransitionEvent' in window)) { | |
| delete vendorPrefixes.transitionend.transition; | |
| } | |
| } | |
| /** | |
| * Attempts to determine the correct vendor prefixed event name. | |
| * | |
| * @param {string} eventName | |
| * @returns {string} | |
| */ | |
| function getVendorPrefixedEventName(eventName) { | |
| if (prefixedEventNames[eventName]) { | |
| return prefixedEventNames[eventName]; | |
| } else if (!vendorPrefixes[eventName]) { | |
| return eventName; | |
| } | |
| var prefixMap = vendorPrefixes[eventName]; | |
| for (var styleProp in prefixMap) { | |
| if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) { | |
| return prefixedEventNames[eventName] = prefixMap[styleProp]; | |
| } | |
| } | |
| return eventName; | |
| } | |
| /** | |
| * To identify top level events in ReactDOM, we use constants defined by this | |
| * module. This is the only module that uses the unsafe* methods to express | |
| * that the constants actually correspond to the browser event names. This lets | |
| * us save some bundle size by avoiding a top level type -> event name map. | |
| * The rest of ReactDOM code should import top level types from this file. | |
| */ | |
| var TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort'); | |
| var TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationend')); | |
| var TOP_ANIMATION_ITERATION = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationiteration')); | |
| var TOP_ANIMATION_START = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationstart')); | |
| var TOP_BLUR = unsafeCastStringToDOMTopLevelType('blur'); | |
| var TOP_CAN_PLAY = unsafeCastStringToDOMTopLevelType('canplay'); | |
| var TOP_CAN_PLAY_THROUGH = unsafeCastStringToDOMTopLevelType('canplaythrough'); | |
| var TOP_CANCEL = unsafeCastStringToDOMTopLevelType('cancel'); | |
| var TOP_CHANGE = unsafeCastStringToDOMTopLevelType('change'); | |
| var TOP_CLICK = unsafeCastStringToDOMTopLevelType('click'); | |
| var TOP_CLOSE = unsafeCastStringToDOMTopLevelType('close'); | |
| var TOP_COMPOSITION_END = unsafeCastStringToDOMTopLevelType('compositionend'); | |
| var TOP_COMPOSITION_START = unsafeCastStringToDOMTopLevelType('compositionstart'); | |
| var TOP_COMPOSITION_UPDATE = unsafeCastStringToDOMTopLevelType('compositionupdate'); | |
| var TOP_CONTEXT_MENU = unsafeCastStringToDOMTopLevelType('contextmenu'); | |
| var TOP_COPY = unsafeCastStringToDOMTopLevelType('copy'); | |
| var TOP_CUT = unsafeCastStringToDOMTopLevelType('cut'); | |
| var TOP_DOUBLE_CLICK = unsafeCastStringToDOMTopLevelType('dblclick'); | |
| var TOP_AUX_CLICK = unsafeCastStringToDOMTopLevelType('auxclick'); | |
| var TOP_DRAG = unsafeCastStringToDOMTopLevelType('drag'); | |
| var TOP_DRAG_END = unsafeCastStringToDOMTopLevelType('dragend'); | |
| var TOP_DRAG_ENTER = unsafeCastStringToDOMTopLevelType('dragenter'); | |
| var TOP_DRAG_EXIT = unsafeCastStringToDOMTopLevelType('dragexit'); | |
| var TOP_DRAG_LEAVE = unsafeCastStringToDOMTopLevelType('dragleave'); | |
| var TOP_DRAG_OVER = unsafeCastStringToDOMTopLevelType('dragover'); | |
| var TOP_DRAG_START = unsafeCastStringToDOMTopLevelType('dragstart'); | |
| var TOP_DROP = unsafeCastStringToDOMTopLevelType('drop'); | |
| var TOP_DURATION_CHANGE = unsafeCastStringToDOMTopLevelType('durationchange'); | |
| var TOP_EMPTIED = unsafeCastStringToDOMTopLevelType('emptied'); | |
| var TOP_ENCRYPTED = unsafeCastStringToDOMTopLevelType('encrypted'); | |
| var TOP_ENDED = unsafeCastStringToDOMTopLevelType('ended'); | |
| var TOP_ERROR = unsafeCastStringToDOMTopLevelType('error'); | |
| var TOP_FOCUS = unsafeCastStringToDOMTopLevelType('focus'); | |
| var TOP_GOT_POINTER_CAPTURE = unsafeCastStringToDOMTopLevelType('gotpointercapture'); | |
| var TOP_INPUT = unsafeCastStringToDOMTopLevelType('input'); | |
| var TOP_INVALID = unsafeCastStringToDOMTopLevelType('invalid'); | |
| var TOP_KEY_DOWN = unsafeCastStringToDOMTopLevelType('keydown'); | |
| var TOP_KEY_PRESS = unsafeCastStringToDOMTopLevelType('keypress'); | |
| var TOP_KEY_UP = unsafeCastStringToDOMTopLevelType('keyup'); | |
| var TOP_LOAD = unsafeCastStringToDOMTopLevelType('load'); | |
| var TOP_LOAD_START = unsafeCastStringToDOMTopLevelType('loadstart'); | |
| var TOP_LOADED_DATA = unsafeCastStringToDOMTopLevelType('loadeddata'); | |
| var TOP_LOADED_METADATA = unsafeCastStringToDOMTopLevelType('loadedmetadata'); | |
| var TOP_LOST_POINTER_CAPTURE = unsafeCastStringToDOMTopLevelType('lostpointercapture'); | |
| var TOP_MOUSE_DOWN = unsafeCastStringToDOMTopLevelType('mousedown'); | |
| var TOP_MOUSE_MOVE = unsafeCastStringToDOMTopLevelType('mousemove'); | |
| var TOP_MOUSE_OUT = unsafeCastStringToDOMTopLevelType('mouseout'); | |
| var TOP_MOUSE_OVER = unsafeCastStringToDOMTopLevelType('mouseover'); | |
| var TOP_MOUSE_UP = unsafeCastStringToDOMTopLevelType('mouseup'); | |
| var TOP_PASTE = unsafeCastStringToDOMTopLevelType('paste'); | |
| var TOP_PAUSE = unsafeCastStringToDOMTopLevelType('pause'); | |
| var TOP_PLAY = unsafeCastStringToDOMTopLevelType('play'); | |
| var TOP_PLAYING = unsafeCastStringToDOMTopLevelType('playing'); | |
| var TOP_POINTER_CANCEL = unsafeCastStringToDOMTopLevelType('pointercancel'); | |
| var TOP_POINTER_DOWN = unsafeCastStringToDOMTopLevelType('pointerdown'); | |
| var TOP_POINTER_MOVE = unsafeCastStringToDOMTopLevelType('pointermove'); | |
| var TOP_POINTER_OUT = unsafeCastStringToDOMTopLevelType('pointerout'); | |
| var TOP_POINTER_OVER = unsafeCastStringToDOMTopLevelType('pointerover'); | |
| var TOP_POINTER_UP = unsafeCastStringToDOMTopLevelType('pointerup'); | |
| var TOP_PROGRESS = unsafeCastStringToDOMTopLevelType('progress'); | |
| var TOP_RATE_CHANGE = unsafeCastStringToDOMTopLevelType('ratechange'); | |
| var TOP_RESET = unsafeCastStringToDOMTopLevelType('reset'); | |
| var TOP_SCROLL = unsafeCastStringToDOMTopLevelType('scroll'); | |
| var TOP_SEEKED = unsafeCastStringToDOMTopLevelType('seeked'); | |
| var TOP_SEEKING = unsafeCastStringToDOMTopLevelType('seeking'); | |
| var TOP_SELECTION_CHANGE = unsafeCastStringToDOMTopLevelType('selectionchange'); | |
| var TOP_STALLED = unsafeCastStringToDOMTopLevelType('stalled'); | |
| var TOP_SUBMIT = unsafeCastStringToDOMTopLevelType('submit'); | |
| var TOP_SUSPEND = unsafeCastStringToDOMTopLevelType('suspend'); | |
| var TOP_TEXT_INPUT = unsafeCastStringToDOMTopLevelType('textInput'); | |
| var TOP_TIME_UPDATE = unsafeCastStringToDOMTopLevelType('timeupdate'); | |
| var TOP_TOGGLE = unsafeCastStringToDOMTopLevelType('toggle'); | |
| var TOP_TOUCH_CANCEL = unsafeCastStringToDOMTopLevelType('touchcancel'); | |
| var TOP_TOUCH_END = unsafeCastStringToDOMTopLevelType('touchend'); | |
| var TOP_TOUCH_MOVE = unsafeCastStringToDOMTopLevelType('touchmove'); | |
| var TOP_TOUCH_START = unsafeCastStringToDOMTopLevelType('touchstart'); | |
| var TOP_TRANSITION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('transitionend')); | |
| var TOP_VOLUME_CHANGE = unsafeCastStringToDOMTopLevelType('volumechange'); | |
| var TOP_WAITING = unsafeCastStringToDOMTopLevelType('waiting'); | |
| var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel'); // List of events that need to be individually attached to media elements. | |
| // Note that events in this list will *not* be listened to at the top level | |
| // unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`. | |
| var mediaEventTypes = [TOP_ABORT, TOP_CAN_PLAY, TOP_CAN_PLAY_THROUGH, TOP_DURATION_CHANGE, TOP_EMPTIED, TOP_ENCRYPTED, TOP_ENDED, TOP_ERROR, TOP_LOADED_DATA, TOP_LOADED_METADATA, TOP_LOAD_START, TOP_PAUSE, TOP_PLAY, TOP_PLAYING, TOP_PROGRESS, TOP_RATE_CHANGE, TOP_SEEKED, TOP_SEEKING, TOP_STALLED, TOP_SUSPEND, TOP_TIME_UPDATE, TOP_VOLUME_CHANGE, TOP_WAITING]; | |
| function getRawEventName(topLevelType) { | |
| return unsafeCastDOMTopLevelTypeToString(topLevelType); | |
| } | |
| var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; // prettier-ignore | |
| var elementListenerMap = new PossiblyWeakMap(); | |
| function getListenerMapForElement(element) { | |
| var listenerMap = elementListenerMap.get(element); | |
| if (listenerMap === undefined) { | |
| listenerMap = new Map(); | |
| elementListenerMap.set(element, listenerMap); | |
| } | |
| return listenerMap; | |
| } | |
| /** | |
| * `ReactInstanceMap` maintains a mapping from a public facing stateful | |
| * instance (key) and the internal representation (value). This allows public | |
| * methods to accept the user facing instance as an argument and map them back | |
| * to internal methods. | |
| * | |
| * Note that this module is currently shared and assumed to be stateless. | |
| * If this becomes an actual Map, that will break. | |
| */ | |
| function get(key) { | |
| return key._reactInternalFiber; | |
| } | |
| function has(key) { | |
| return key._reactInternalFiber !== undefined; | |
| } | |
| function set(key, value) { | |
| key._reactInternalFiber = value; | |
| } | |
| // Don't change these two values. They're used by React Dev Tools. | |
| var NoEffect = | |
| /* */ | |
| 0; | |
| var PerformedWork = | |
| /* */ | |
| 1; // You can change the rest (and add more). | |
| var Placement = | |
| /* */ | |
| 2; | |
| var Update = | |
| /* */ | |
| 4; | |
| var PlacementAndUpdate = | |
| /* */ | |
| 6; | |
| var Deletion = | |
| /* */ | |
| 8; | |
| var ContentReset = | |
| /* */ | |
| 16; | |
| var Callback = | |
| /* */ | |
| 32; | |
| var DidCapture = | |
| /* */ | |
| 64; | |
| var Ref = | |
| /* */ | |
| 128; | |
| var Snapshot = | |
| /* */ | |
| 256; | |
| var Passive = | |
| /* */ | |
| 512; | |
| var Hydrating = | |
| /* */ | |
| 1024; | |
| var HydratingAndUpdate = | |
| /* */ | |
| 1028; // Passive & Update & Callback & Ref & Snapshot | |
| var LifecycleEffectMask = | |
| /* */ | |
| 932; // Union of all host effects | |
| var HostEffectMask = | |
| /* */ | |
| 2047; | |
| var Incomplete = | |
| /* */ | |
| 2048; | |
| var ShouldCapture = | |
| /* */ | |
| 4096; | |
| var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; | |
| function getNearestMountedFiber(fiber) { | |
| var node = fiber; | |
| var nearestMounted = fiber; | |
| if (!fiber.alternate) { | |
| // If there is no alternate, this might be a new tree that isn't inserted | |
| // yet. If it is, then it will have a pending insertion effect on it. | |
| var nextNode = node; | |
| do { | |
| node = nextNode; | |
| if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) { | |
| // This is an insertion or in-progress hydration. The nearest possible | |
| // mounted fiber is the parent but we need to continue to figure out | |
| // if that one is still mounted. | |
| nearestMounted = node.return; | |
| } | |
| nextNode = node.return; | |
| } while (nextNode); | |
| } else { | |
| while (node.return) { | |
| node = node.return; | |
| } | |
| } | |
| if (node.tag === HostRoot) { | |
| // TODO: Check if this was a nested HostRoot when used with | |
| // renderContainerIntoSubtree. | |
| return nearestMounted; | |
| } // If we didn't hit the root, that means that we're in an disconnected tree | |
| // that has been unmounted. | |
| return null; | |
| } | |
| function getSuspenseInstanceFromFiber(fiber) { | |
| if (fiber.tag === SuspenseComponent) { | |
| var suspenseState = fiber.memoizedState; | |
| if (suspenseState === null) { | |
| var current = fiber.alternate; | |
| if (current !== null) { | |
| suspenseState = current.memoizedState; | |
| } | |
| } | |
| if (suspenseState !== null) { | |
| return suspenseState.dehydrated; | |
| } | |
| } | |
| return null; | |
| } | |
| function getContainerFromFiber(fiber) { | |
| return fiber.tag === HostRoot ? fiber.stateNode.containerInfo : null; | |
| } | |
| function isFiberMounted(fiber) { | |
| return getNearestMountedFiber(fiber) === fiber; | |
| } | |
| function isMounted(component) { | |
| { | |
| var owner = ReactCurrentOwner.current; | |
| if (owner !== null && owner.tag === ClassComponent) { | |
| var ownerFiber = owner; | |
| var instance = ownerFiber.stateNode; | |
| if (!instance._warnedAboutRefsInRender) { | |
| error('%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(ownerFiber.type) || 'A component'); | |
| } | |
| instance._warnedAboutRefsInRender = true; | |
| } | |
| } | |
| var fiber = get(component); | |
| if (!fiber) { | |
| return false; | |
| } | |
| return getNearestMountedFiber(fiber) === fiber; | |
| } | |
| function assertIsMounted(fiber) { | |
| if (!(getNearestMountedFiber(fiber) === fiber)) { | |
| { | |
| throw Error( "Unable to find node on an unmounted component." ); | |
| } | |
| } | |
| } | |
| function findCurrentFiberUsingSlowPath(fiber) { | |
| var alternate = fiber.alternate; | |
| if (!alternate) { | |
| // If there is no alternate, then we only need to check if it is mounted. | |
| var nearestMounted = getNearestMountedFiber(fiber); | |
| if (!(nearestMounted !== null)) { | |
| { | |
| throw Error( "Unable to find node on an unmounted component." ); | |
| } | |
| } | |
| if (nearestMounted !== fiber) { | |
| return null; | |
| } | |
| return fiber; | |
| } // If we have two possible branches, we'll walk backwards up to the root | |
| // to see what path the root points to. On the way we may hit one of the | |
| // special cases and we'll deal with them. | |
| var a = fiber; | |
| var b = alternate; | |
| while (true) { | |
| var parentA = a.return; | |
| if (parentA === null) { | |
| // We're at the root. | |
| break; | |
| } | |
| var parentB = parentA.alternate; | |
| if (parentB === null) { | |
| // There is no alternate. This is an unusual case. Currently, it only | |
| // happens when a Suspense component is hidden. An extra fragment fiber | |
| // is inserted in between the Suspense fiber and its children. Skip | |
| // over this extra fragment fiber and proceed to the next parent. | |
| var nextParent = parentA.return; | |
| if (nextParent !== null) { | |
| a = b = nextParent; | |
| continue; | |
| } // If there's no parent, we're at the root. | |
| break; | |
| } // If both copies of the parent fiber point to the same child, we can | |
| // assume that the child is current. This happens when we bailout on low | |
| // priority: the bailed out fiber's child reuses the current child. | |
| if (parentA.child === parentB.child) { | |
| var child = parentA.child; | |
| while (child) { | |
| if (child === a) { | |
| // We've determined that A is the current branch. | |
| assertIsMounted(parentA); | |
| return fiber; | |
| } | |
| if (child === b) { | |
| // We've determined that B is the current branch. | |
| assertIsMounted(parentA); | |
| return alternate; | |
| } | |
| child = child.sibling; | |
| } // We should never have an alternate for any mounting node. So the only | |
| // way this could possibly happen is if this was unmounted, if at all. | |
| { | |
| { | |
| throw Error( "Unable to find node on an unmounted component." ); | |
| } | |
| } | |
| } | |
| if (a.return !== b.return) { | |
| // The return pointer of A and the return pointer of B point to different | |
| // fibers. We assume that return pointers never criss-cross, so A must | |
| // belong to the child set of A.return, and B must belong to the child | |
| // set of B.return. | |
| a = parentA; | |
| b = parentB; | |
| } else { | |
| // The return pointers point to the same fiber. We'll have to use the | |
| // default, slow path: scan the child sets of each parent alternate to see | |
| // which child belongs to which set. | |
| // | |
| // Search parent A's child set | |
| var didFindChild = false; | |
| var _child = parentA.child; | |
| while (_child) { | |
| if (_child === a) { | |
| didFindChild = true; | |
| a = parentA; | |
| b = parentB; | |
| break; | |
| } | |
| if (_child === b) { | |
| didFindChild = true; | |
| b = parentA; | |
| a = parentB; | |
| break; | |
| } | |
| _child = _child.sibling; | |
| } | |
| if (!didFindChild) { | |
| // Search parent B's child set | |
| _child = parentB.child; | |
| while (_child) { | |
| if (_child === a) { | |
| didFindChild = true; | |
| a = parentB; | |
| b = parentA; | |
| break; | |
| } | |
| if (_child === b) { | |
| didFindChild = true; | |
| b = parentB; | |
| a = parentA; | |
| break; | |
| } | |
| _child = _child.sibling; | |
| } | |
| if (!didFindChild) { | |
| { | |
| throw Error( "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." ); | |
| } | |
| } | |
| } | |
| } | |
| if (!(a.alternate === b)) { | |
| { | |
| throw Error( "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." ); | |
| } | |
| } | |
| } // If the root is not a host container, we're in a disconnected tree. I.e. | |
| // unmounted. | |
| if (!(a.tag === HostRoot)) { | |
| { | |
| throw Error( "Unable to find node on an unmounted component." ); | |
| } | |
| } | |
| if (a.stateNode.current === a) { | |
| // We've determined that A is the current branch. | |
| return fiber; | |
| } // Otherwise B has to be current branch. | |
| return alternate; | |
| } | |
| function findCurrentHostFiber(parent) { | |
| var currentParent = findCurrentFiberUsingSlowPath(parent); | |
| if (!currentParent) { | |
| return null; | |
| } // Next we'll drill down this component to find the first HostComponent/Text. | |
| var node = currentParent; | |
| while (true) { | |
| if (node.tag === HostComponent || node.tag === HostText) { | |
| return node; | |
| } else if (node.child) { | |
| node.child.return = node; | |
| node = node.child; | |
| continue; | |
| } | |
| if (node === currentParent) { | |
| return null; | |
| } | |
| while (!node.sibling) { | |
| if (!node.return || node.return === currentParent) { | |
| return null; | |
| } | |
| node = node.return; | |
| } | |
| node.sibling.return = node.return; | |
| node = node.sibling; | |
| } // Flow needs the return null here, but ESLint complains about it. | |
| // eslint-disable-next-line no-unreachable | |
| return null; | |
| } | |
| function findCurrentHostFiberWithNoPortals(parent) { | |
| var currentParent = findCurrentFiberUsingSlowPath(parent); | |
| if (!currentParent) { | |
| return null; | |
| } // Next we'll drill down this component to find the first HostComponent/Text. | |
| var node = currentParent; | |
| while (true) { | |
| if (node.tag === HostComponent || node.tag === HostText || enableFundamentalAPI ) { | |
| return node; | |
| } else if (node.child && node.tag !== HostPortal) { | |
| node.child.return = node; | |
| node = node.child; | |
| continue; | |
| } | |
| if (node === currentParent) { | |
| return null; | |
| } | |
| while (!node.sibling) { | |
| if (!node.return || node.return === currentParent) { | |
| return null; | |
| } | |
| node = node.return; | |
| } | |
| node.sibling.return = node.return; | |
| node = node.sibling; | |
| } // Flow needs the return null here, but ESLint complains about it. | |
| // eslint-disable-next-line no-unreachable | |
| return null; | |
| } | |
| /** | |
| * Accumulates items that must not be null or undefined into the first one. This | |
| * is used to conserve memory by avoiding array allocations, and thus sacrifices | |
| * API cleanness. Since `current` can be null before being passed in and not | |
| * null after this function, make sure to assign it back to `current`: | |
| * | |
| * `a = accumulateInto(a, b);` | |
| * | |
| * This API should be sparingly used. Try `accumulate` for something cleaner. | |
| * | |
| * @return {*|array<*>} An accumulation of items. | |
| */ | |
| function accumulateInto(current, next) { | |
| if (!(next != null)) { | |
| { | |
| throw Error( "accumulateInto(...): Accumulated items must not be null or undefined." ); | |
| } | |
| } | |
| if (current == null) { | |
| return next; | |
| } // Both are not empty. Warning: Never call x.concat(y) when you are not | |
| // certain that x is an Array (x could be a string with concat method). | |
| if (Array.isArray(current)) { | |
| if (Array.isArray(next)) { | |
| current.push.apply(current, next); | |
| return current; | |
| } | |
| current.push(next); | |
| return current; | |
| } | |
| if (Array.isArray(next)) { | |
| // A bit too dangerous to mutate `next`. | |
| return [current].concat(next); | |
| } | |
| return [current, next]; | |
| } | |
| /** | |
| * @param {array} arr an "accumulation" of items which is either an Array or | |
| * a single item. Useful when paired with the `accumulate` module. This is a | |
| * simple utility that allows us to reason about a collection of items, but | |
| * handling the case when there is exactly one item (and we do not need to | |
| * allocate an array). | |
| * @param {function} cb Callback invoked with each element or a collection. | |
| * @param {?} [scope] Scope used as `this` in a callback. | |
| */ | |
| function forEachAccumulated(arr, cb, scope) { | |
| if (Array.isArray(arr)) { | |
| arr.forEach(cb, scope); | |
| } else if (arr) { | |
| cb.call(scope, arr); | |
| } | |
| } | |
| /** | |
| * Internal queue of events that have accumulated their dispatches and are | |
| * waiting to have their dispatches executed. | |
| */ | |
| var eventQueue = null; | |
| /** | |
| * Dispatches an event and releases it back into the pool, unless persistent. | |
| * | |
| * @param {?object} event Synthetic event to be dispatched. | |
| * @private | |
| */ | |
| var executeDispatchesAndRelease = function (event) { | |
| if (event) { | |
| executeDispatchesInOrder(event); | |
| if (!event.isPersistent()) { | |
| event.constructor.release(event); | |
| } | |
| } | |
| }; | |
| var executeDispatchesAndReleaseTopLevel = function (e) { | |
| return executeDispatchesAndRelease(e); | |
| }; | |
| function runEventsInBatch(events) { | |
| if (events !== null) { | |
| eventQueue = accumulateInto(eventQueue, events); | |
| } // Set `eventQueue` to null before processing it so that we can tell if more | |
| // events get enqueued while processing. | |
| var processingEventQueue = eventQueue; | |
| eventQueue = null; | |
| if (!processingEventQueue) { | |
| return; | |
| } | |
| forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); | |
| if (!!eventQueue) { | |
| { | |
| throw Error( "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." ); | |
| } | |
| } // This would be a good time to rethrow if any of the event handlers threw. | |
| rethrowCaughtError(); | |
| } | |
| /** | |
| * Gets the target node from a native browser event by accounting for | |
| * inconsistencies in browser DOM APIs. | |
| * | |
| * @param {object} nativeEvent Native browser event. | |
| * @return {DOMEventTarget} Target node. | |
| */ | |
| function getEventTarget(nativeEvent) { | |
| // Fallback to nativeEvent.srcElement for IE9 | |
| // https://github.com/facebook/react/issues/12506 | |
| var target = nativeEvent.target || nativeEvent.srcElement || window; // Normalize SVG <use> element events #4963 | |
| if (target.correspondingUseElement) { | |
| target = target.correspondingUseElement; | |
| } // Safari may fire events on text nodes (Node.TEXT_NODE is 3). | |
| // @see http://www.quirksmode.org/js/events_properties.html | |
| return target.nodeType === TEXT_NODE ? target.parentNode : target; | |
| } | |
| /** | |
| * Checks if an event is supported in the current execution environment. | |
| * | |
| * NOTE: This will not work correctly for non-generic events such as `change`, | |
| * `reset`, `load`, `error`, and `select`. | |
| * | |
| * Borrows from Modernizr. | |
| * | |
| * @param {string} eventNameSuffix Event name, e.g. "click". | |
| * @return {boolean} True if the event is supported. | |
| * @internal | |
| * @license Modernizr 3.0.0pre (Custom Build) | MIT | |
| */ | |
| function isEventSupported(eventNameSuffix) { | |
| if (!canUseDOM) { | |
| return false; | |
| } | |
| var eventName = 'on' + eventNameSuffix; | |
| var isSupported = eventName in document; | |
| if (!isSupported) { | |
| var element = document.createElement('div'); | |
| element.setAttribute(eventName, 'return;'); | |
| isSupported = typeof element[eventName] === 'function'; | |
| } | |
| return isSupported; | |
| } | |
| /** | |
| * Summary of `DOMEventPluginSystem` event handling: | |
| * | |
| * - Top-level delegation is used to trap most native browser events. This | |
| * may only occur in the main thread and is the responsibility of | |
| * ReactDOMEventListener, which is injected and can therefore support | |
| * pluggable event sources. This is the only work that occurs in the main | |
| * thread. | |
| * | |
| * - We normalize and de-duplicate events to account for browser quirks. This | |
| * may be done in the worker thread. | |
| * | |
| * - Forward these native events (with the associated top-level type used to | |
| * trap it) to `EventPluginRegistry`, which in turn will ask plugins if they want | |
| * to extract any synthetic events. | |
| * | |
| * - The `EventPluginRegistry` will then process each event by annotating them with | |
| * "dispatches", a sequence of listeners and IDs that care about that event. | |
| * | |
| * - The `EventPluginRegistry` then dispatches the events. | |
| * | |
| * Overview of React and the event system: | |
| * | |
| * +------------+ . | |
| * | DOM | . | |
| * +------------+ . | |
| * | . | |
| * v . | |
| * +------------+ . | |
| * | ReactEvent | . | |
| * | Listener | . | |
| * +------------+ . +-----------+ | |
| * | . +--------+|SimpleEvent| | |
| * | . | |Plugin | | |
| * +-----|------+ . v +-----------+ | |
| * | | | . +--------------+ +------------+ | |
| * | +-----------.--->|PluginRegistry| | Event | | |
| * | | . | | +-----------+ | Propagators| | |
| * | ReactEvent | . | | |TapEvent | |------------| | |
| * | Emitter | . | |<---+|Plugin | |other plugin| | |
| * | | . | | +-----------+ | utilities | | |
| * | +-----------.--->| | +------------+ | |
| * | | | . +--------------+ | |
| * +-----|------+ . ^ +-----------+ | |
| * | . | |Enter/Leave| | |
| * + . +-------+|Plugin | | |
| * +-------------+ . +-----------+ | |
| * | application | . | |
| * |-------------| . | |
| * | | . | |
| * | | . | |
| * +-------------+ . | |
| * . | |
| * React Core . General Purpose Event Plugin System | |
| */ | |
| var CALLBACK_BOOKKEEPING_POOL_SIZE = 10; | |
| var callbackBookkeepingPool = []; | |
| function releaseTopLevelCallbackBookKeeping(instance) { | |
| instance.topLevelType = null; | |
| instance.nativeEvent = null; | |
| instance.targetInst = null; | |
| instance.ancestors.length = 0; | |
| if (callbackBookkeepingPool.length < CALLBACK_BOOKKEEPING_POOL_SIZE) { | |
| callbackBookkeepingPool.push(instance); | |
| } | |
| } // Used to store ancestor hierarchy in top level callback | |
| function getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst, eventSystemFlags) { | |
| if (callbackBookkeepingPool.length) { | |
| var instance = callbackBookkeepingPool.pop(); | |
| instance.topLevelType = topLevelType; | |
| instance.eventSystemFlags = eventSystemFlags; | |
| instance.nativeEvent = nativeEvent; | |
| instance.targetInst = targetInst; | |
| return instance; | |
| } | |
| return { | |
| topLevelType: topLevelType, | |
| eventSystemFlags: eventSystemFlags, | |
| nativeEvent: nativeEvent, | |
| targetInst: targetInst, | |
| ancestors: [] | |
| }; | |
| } | |
| /** | |
| * Find the deepest React component completely containing the root of the | |
| * passed-in instance (for use when entire React trees are nested within each | |
| * other). If React trees are not nested, returns null. | |
| */ | |
| function findRootContainerNode(inst) { | |
| if (inst.tag === HostRoot) { | |
| return inst.stateNode.containerInfo; | |
| } // TODO: It may be a good idea to cache this to prevent unnecessary DOM | |
| // traversal, but caching is difficult to do correctly without using a | |
| // mutation observer to listen for all DOM changes. | |
| while (inst.return) { | |
| inst = inst.return; | |
| } | |
| if (inst.tag !== HostRoot) { | |
| // This can happen if we're in a detached tree. | |
| return null; | |
| } | |
| return inst.stateNode.containerInfo; | |
| } | |
| /** | |
| * Allows registered plugins an opportunity to extract events from top-level | |
| * native browser events. | |
| * | |
| * @return {*} An accumulation of synthetic events. | |
| * @internal | |
| */ | |
| function extractPluginEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { | |
| var events = null; | |
| for (var i = 0; i < plugins.length; i++) { | |
| // Not every plugin in the ordering may be loaded at runtime. | |
| var possiblePlugin = plugins[i]; | |
| if (possiblePlugin) { | |
| var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); | |
| if (extractedEvents) { | |
| events = accumulateInto(events, extractedEvents); | |
| } | |
| } | |
| } | |
| return events; | |
| } | |
| function runExtractedPluginEventsInBatch(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { | |
| var events = extractPluginEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); | |
| runEventsInBatch(events); | |
| } | |
| function handleTopLevel(bookKeeping) { | |
| var targetInst = bookKeeping.targetInst; // Loop through the hierarchy, in case there's any nested components. | |
| // It's important that we build the array of ancestors before calling any | |
| // event handlers, because event handlers can modify the DOM, leading to | |
| // inconsistencies with ReactMount's node cache. See #1105. | |
| var ancestor = targetInst; | |
| do { | |
| if (!ancestor) { | |
| var ancestors = bookKeeping.ancestors; | |
| ancestors.push(ancestor); | |
| break; | |
| } | |
| var root = findRootContainerNode(ancestor); | |
| if (!root) { | |
| break; | |
| } | |
| var tag = ancestor.tag; | |
| if (tag === HostComponent || tag === HostText) { | |
| bookKeeping.ancestors.push(ancestor); | |
| } | |
| ancestor = getClosestInstanceFromNode(root); | |
| } while (ancestor); | |
| for (var i = 0; i < bookKeeping.ancestors.length; i++) { | |
| targetInst = bookKeeping.ancestors[i]; | |
| var eventTarget = getEventTarget(bookKeeping.nativeEvent); | |
| var topLevelType = bookKeeping.topLevelType; | |
| var nativeEvent = bookKeeping.nativeEvent; | |
| var eventSystemFlags = bookKeeping.eventSystemFlags; // If this is the first ancestor, we mark it on the system flags | |
| if (i === 0) { | |
| eventSystemFlags |= IS_FIRST_ANCESTOR; | |
| } | |
| runExtractedPluginEventsInBatch(topLevelType, targetInst, nativeEvent, eventTarget, eventSystemFlags); | |
| } | |
| } | |
| function dispatchEventForLegacyPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst) { | |
| var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst, eventSystemFlags); | |
| try { | |
| // Event queue being processed in the same cycle allows | |
| // `preventDefault`. | |
| batchedEventUpdates(handleTopLevel, bookKeeping); | |
| } finally { | |
| releaseTopLevelCallbackBookKeeping(bookKeeping); | |
| } | |
| } | |
| /** | |
| * We listen for bubbled touch events on the document object. | |
| * | |
| * Firefox v8.01 (and possibly others) exhibited strange behavior when | |
| * mounting `onmousemove` events at some node that was not the document | |
| * element. The symptoms were that if your mouse is not moving over something | |
| * contained within that mount point (for example on the background) the | |
| * top-level listeners for `onmousemove` won't be called. However, if you | |
| * register the `mousemove` on the document object, then it will of course | |
| * catch all `mousemove`s. This along with iOS quirks, justifies restricting | |
| * top-level listeners to the document object only, at least for these | |
| * movement types of events and possibly all events. | |
| * | |
| * @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html | |
| * | |
| * Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but | |
| * they bubble to document. | |
| * | |
| * @param {string} registrationName Name of listener (e.g. `onClick`). | |
| * @param {object} mountAt Container where to mount the listener | |
| */ | |
| function legacyListenToEvent(registrationName, mountAt) { | |
| var listenerMap = getListenerMapForElement(mountAt); | |
| var dependencies = registrationNameDependencies[registrationName]; | |
| for (var i = 0; i < dependencies.length; i++) { | |
| var dependency = dependencies[i]; | |
| legacyListenToTopLevelEvent(dependency, mountAt, listenerMap); | |
| } | |
| } | |
| function legacyListenToTopLevelEvent(topLevelType, mountAt, listenerMap) { | |
| if (!listenerMap.has(topLevelType)) { | |
| switch (topLevelType) { | |
| case TOP_SCROLL: | |
| trapCapturedEvent(TOP_SCROLL, mountAt); | |
| break; | |
| case TOP_FOCUS: | |
| case TOP_BLUR: | |
| trapCapturedEvent(TOP_FOCUS, mountAt); | |
| trapCapturedEvent(TOP_BLUR, mountAt); // We set the flag for a single dependency later in this function, | |
| // but this ensures we mark both as attached rather than just one. | |
| listenerMap.set(TOP_BLUR, null); | |
| listenerMap.set(TOP_FOCUS, null); | |
| break; | |
| case TOP_CANCEL: | |
| case TOP_CLOSE: | |
| if (isEventSupported(getRawEventName(topLevelType))) { | |
| trapCapturedEvent(topLevelType, mountAt); | |
| } | |
| break; | |
| case TOP_INVALID: | |
| case TOP_SUBMIT: | |
| case TOP_RESET: | |
| // We listen to them on the target DOM elements. | |
| // Some of them bubble so we don't want them to fire twice. | |
| break; | |
| default: | |
| // By default, listen on the top level to all non-media events. | |
| // Media events don't bubble so adding the listener wouldn't do anything. | |
| var isMediaEvent = mediaEventTypes.indexOf(topLevelType) !== -1; | |
| if (!isMediaEvent) { | |
| trapBubbledEvent(topLevelType, mountAt); | |
| } | |
| break; | |
| } | |
| listenerMap.set(topLevelType, null); | |
| } | |
| } | |
| function isListeningToAllDependencies(registrationName, mountAt) { | |
| var listenerMap = getListenerMapForElement(mountAt); | |
| var dependencies = registrationNameDependencies[registrationName]; | |
| for (var i = 0; i < dependencies.length; i++) { | |
| var dependency = dependencies[i]; | |
| if (!listenerMap.has(dependency)) { | |
| return false; | |
| } | |
| } | |
| return true; | |
| } | |
| var attemptUserBlockingHydration; | |
| function setAttemptUserBlockingHydration(fn) { | |
| attemptUserBlockingHydration = fn; | |
| } | |
| var attemptContinuousHydration; | |
| function setAttemptContinuousHydration(fn) { | |
| attemptContinuousHydration = fn; | |
| } | |
| var attemptHydrationAtCurrentPriority; | |
| function setAttemptHydrationAtCurrentPriority(fn) { | |
| attemptHydrationAtCurrentPriority = fn; | |
| } // TODO: Upgrade this definition once we're on a newer version of Flow that | |
| var hasScheduledReplayAttempt = false; // The queue of discrete events to be replayed. | |
| var queuedDiscreteEvents = []; // Indicates if any continuous event targets are non-null for early bailout. | |
| // if the last target was dehydrated. | |
| var queuedFocus = null; | |
| var queuedDrag = null; | |
| var queuedMouse = null; // For pointer events there can be one latest event per pointerId. | |
| var queuedPointers = new Map(); | |
| var queuedPointerCaptures = new Map(); // We could consider replaying selectionchange and touchmoves too. | |
| var queuedExplicitHydrationTargets = []; | |
| function hasQueuedDiscreteEvents() { | |
| return queuedDiscreteEvents.length > 0; | |
| } | |
| var discreteReplayableEvents = [TOP_MOUSE_DOWN, TOP_MOUSE_UP, TOP_TOUCH_CANCEL, TOP_TOUCH_END, TOP_TOUCH_START, TOP_AUX_CLICK, TOP_DOUBLE_CLICK, TOP_POINTER_CANCEL, TOP_POINTER_DOWN, TOP_POINTER_UP, TOP_DRAG_END, TOP_DRAG_START, TOP_DROP, TOP_COMPOSITION_END, TOP_COMPOSITION_START, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_INPUT, TOP_TEXT_INPUT, TOP_CLOSE, TOP_CANCEL, TOP_COPY, TOP_CUT, TOP_PASTE, TOP_CLICK, TOP_CHANGE, TOP_CONTEXT_MENU, TOP_RESET, TOP_SUBMIT]; | |
| var continuousReplayableEvents = [TOP_FOCUS, TOP_BLUR, TOP_DRAG_ENTER, TOP_DRAG_LEAVE, TOP_MOUSE_OVER, TOP_MOUSE_OUT, TOP_POINTER_OVER, TOP_POINTER_OUT, TOP_GOT_POINTER_CAPTURE, TOP_LOST_POINTER_CAPTURE]; | |
| function isReplayableDiscreteEvent(eventType) { | |
| return discreteReplayableEvents.indexOf(eventType) > -1; | |
| } | |
| function trapReplayableEventForDocument(topLevelType, document, listenerMap) { | |
| legacyListenToTopLevelEvent(topLevelType, document, listenerMap); | |
| } | |
| function eagerlyTrapReplayableEvents(container, document) { | |
| var listenerMapForDoc = getListenerMapForElement(document); // Discrete | |
| discreteReplayableEvents.forEach(function (topLevelType) { | |
| trapReplayableEventForDocument(topLevelType, document, listenerMapForDoc); | |
| }); // Continuous | |
| continuousReplayableEvents.forEach(function (topLevelType) { | |
| trapReplayableEventForDocument(topLevelType, document, listenerMapForDoc); | |
| }); | |
| } | |
| function createQueuedReplayableEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent) { | |
| return { | |
| blockedOn: blockedOn, | |
| topLevelType: topLevelType, | |
| eventSystemFlags: eventSystemFlags | IS_REPLAYED, | |
| nativeEvent: nativeEvent, | |
| container: container | |
| }; | |
| } | |
| function queueDiscreteEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent) { | |
| var queuedEvent = createQueuedReplayableEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent); | |
| queuedDiscreteEvents.push(queuedEvent); | |
| } // Resets the replaying for this type of continuous event to no event. | |
| function clearIfContinuousEvent(topLevelType, nativeEvent) { | |
| switch (topLevelType) { | |
| case TOP_FOCUS: | |
| case TOP_BLUR: | |
| queuedFocus = null; | |
| break; | |
| case TOP_DRAG_ENTER: | |
| case TOP_DRAG_LEAVE: | |
| queuedDrag = null; | |
| break; | |
| case TOP_MOUSE_OVER: | |
| case TOP_MOUSE_OUT: | |
| queuedMouse = null; | |
| break; | |
| case TOP_POINTER_OVER: | |
| case TOP_POINTER_OUT: | |
| { | |
| var pointerId = nativeEvent.pointerId; | |
| queuedPointers.delete(pointerId); | |
| break; | |
| } | |
| case TOP_GOT_POINTER_CAPTURE: | |
| case TOP_LOST_POINTER_CAPTURE: | |
| { | |
| var _pointerId = nativeEvent.pointerId; | |
| queuedPointerCaptures.delete(_pointerId); | |
| break; | |
| } | |
| } | |
| } | |
| function accumulateOrCreateContinuousQueuedReplayableEvent(existingQueuedEvent, blockedOn, topLevelType, eventSystemFlags, container, nativeEvent) { | |
| if (existingQueuedEvent === null || existingQueuedEvent.nativeEvent !== nativeEvent) { | |
| var queuedEvent = createQueuedReplayableEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent); | |
| if (blockedOn !== null) { | |
| var _fiber2 = getInstanceFromNode$1(blockedOn); | |
| if (_fiber2 !== null) { | |
| // Attempt to increase the priority of this target. | |
| attemptContinuousHydration(_fiber2); | |
| } | |
| } | |
| return queuedEvent; | |
| } // If we have already queued this exact event, then it's because | |
| // the different event systems have different DOM event listeners. | |
| // We can accumulate the flags and store a single event to be | |
| // replayed. | |
| existingQueuedEvent.eventSystemFlags |= eventSystemFlags; | |
| return existingQueuedEvent; | |
| } | |
| function queueIfContinuousEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent) { | |
| // These set relatedTarget to null because the replayed event will be treated as if we | |
| // moved from outside the window (no target) onto the target once it hydrates. | |
| // Instead of mutating we could clone the event. | |
| switch (topLevelType) { | |
| case TOP_FOCUS: | |
| { | |
| var focusEvent = nativeEvent; | |
| queuedFocus = accumulateOrCreateContinuousQueuedReplayableEvent(queuedFocus, blockedOn, topLevelType, eventSystemFlags, container, focusEvent); | |
| return true; | |
| } | |
| case TOP_DRAG_ENTER: | |
| { | |
| var dragEvent = nativeEvent; | |
| queuedDrag = accumulateOrCreateContinuousQueuedReplayableEvent(queuedDrag, blockedOn, topLevelType, eventSystemFlags, container, dragEvent); | |
| return true; | |
| } | |
| case TOP_MOUSE_OVER: | |
| { | |
| var mouseEvent = nativeEvent; | |
| queuedMouse = accumulateOrCreateContinuousQueuedReplayableEvent(queuedMouse, blockedOn, topLevelType, eventSystemFlags, container, mouseEvent); | |
| return true; | |
| } | |
| case TOP_POINTER_OVER: | |
| { | |
| var pointerEvent = nativeEvent; | |
| var pointerId = pointerEvent.pointerId; | |
| queuedPointers.set(pointerId, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointers.get(pointerId) || null, blockedOn, topLevelType, eventSystemFlags, container, pointerEvent)); | |
| return true; | |
| } | |
| case TOP_GOT_POINTER_CAPTURE: | |
| { | |
| var _pointerEvent = nativeEvent; | |
| var _pointerId2 = _pointerEvent.pointerId; | |
| queuedPointerCaptures.set(_pointerId2, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointerCaptures.get(_pointerId2) || null, blockedOn, topLevelType, eventSystemFlags, container, _pointerEvent)); | |
| return true; | |
| } | |
| } | |
| return false; | |
| } // Check if this target is unblocked. Returns true if it's unblocked. | |
| function attemptExplicitHydrationTarget(queuedTarget) { | |
| // TODO: This function shares a lot of logic with attemptToDispatchEvent. | |
| // Try to unify them. It's a bit tricky since it would require two return | |
| // values. | |
| var targetInst = getClosestInstanceFromNode(queuedTarget.target); | |
| if (targetInst !== null) { | |
| var nearestMounted = getNearestMountedFiber(targetInst); | |
| if (nearestMounted !== null) { | |
| var tag = nearestMounted.tag; | |
| if (tag === SuspenseComponent) { | |
| var instance = getSuspenseInstanceFromFiber(nearestMounted); | |
| if (instance !== null) { | |
| // We're blocked on hydrating this boundary. | |
| // Increase its priority. | |
| queuedTarget.blockedOn = instance; | |
| Scheduler.unstable_runWithPriority(queuedTarget.priority, function () { | |
| attemptHydrationAtCurrentPriority(nearestMounted); | |
| }); | |
| return; | |
| } | |
| } else if (tag === HostRoot) { | |
| var root = nearestMounted.stateNode; | |
| if (root.hydrate) { | |
| queuedTarget.blockedOn = getContainerFromFiber(nearestMounted); // We don't currently have a way to increase the priority of | |
| // a root other than sync. | |
| return; | |
| } | |
| } | |
| } | |
| } | |
| queuedTarget.blockedOn = null; | |
| } | |
| function attemptReplayContinuousQueuedEvent(queuedEvent) { | |
| if (queuedEvent.blockedOn !== null) { | |
| return false; | |
| } | |
| var nextBlockedOn = attemptToDispatchEvent(queuedEvent.topLevelType, queuedEvent.eventSystemFlags, queuedEvent.container, queuedEvent.nativeEvent); | |
| if (nextBlockedOn !== null) { | |
| // We're still blocked. Try again later. | |
| var _fiber3 = getInstanceFromNode$1(nextBlockedOn); | |
| if (_fiber3 !== null) { | |
| attemptContinuousHydration(_fiber3); | |
| } | |
| queuedEvent.blockedOn = nextBlockedOn; | |
| return false; | |
| } | |
| return true; | |
| } | |
| function attemptReplayContinuousQueuedEventInMap(queuedEvent, key, map) { | |
| if (attemptReplayContinuousQueuedEvent(queuedEvent)) { | |
| map.delete(key); | |
| } | |
| } | |
| function replayUnblockedEvents() { | |
| hasScheduledReplayAttempt = false; // First replay discrete events. | |
| while (queuedDiscreteEvents.length > 0) { | |
| var nextDiscreteEvent = queuedDiscreteEvents[0]; | |
| if (nextDiscreteEvent.blockedOn !== null) { | |
| // We're still blocked. | |
| // Increase the priority of this boundary to unblock | |
| // the next discrete event. | |
| var _fiber4 = getInstanceFromNode$1(nextDiscreteEvent.blockedOn); | |
| if (_fiber4 !== null) { | |
| attemptUserBlockingHydration(_fiber4); | |
| } | |
| break; | |
| } | |
| var nextBlockedOn = attemptToDispatchEvent(nextDiscreteEvent.topLevelType, nextDiscreteEvent.eventSystemFlags, nextDiscreteEvent.container, nextDiscreteEvent.nativeEvent); | |
| if (nextBlockedOn !== null) { | |
| // We're still blocked. Try again later. | |
| nextDiscreteEvent.blockedOn = nextBlockedOn; | |
| } else { | |
| // We've successfully replayed the first event. Let's try the next one. | |
| queuedDiscreteEvents.shift(); | |
| } | |
| } // Next replay any continuous events. | |
| if (queuedFocus !== null && attemptReplayContinuousQueuedEvent(queuedFocus)) { | |
| queuedFocus = null; | |
| } | |
| if (queuedDrag !== null && attemptReplayContinuousQueuedEvent(queuedDrag)) { | |
| queuedDrag = null; | |
| } | |
| if (queuedMouse !== null && attemptReplayContinuousQueuedEvent(queuedMouse)) { | |
| queuedMouse = null; | |
| } | |
| queuedPointers.forEach(attemptReplayContinuousQueuedEventInMap); | |
| queuedPointerCaptures.forEach(attemptReplayContinuousQueuedEventInMap); | |
| } | |
| function scheduleCallbackIfUnblocked(queuedEvent, unblocked) { | |
| if (queuedEvent.blockedOn === unblocked) { | |
| queuedEvent.blockedOn = null; | |
| if (!hasScheduledReplayAttempt) { | |
| hasScheduledReplayAttempt = true; // Schedule a callback to attempt replaying as many events as are | |
| // now unblocked. This first might not actually be unblocked yet. | |
| // We could check it early to avoid scheduling an unnecessary callback. | |
| Scheduler.unstable_scheduleCallback(Scheduler.unstable_NormalPriority, replayUnblockedEvents); | |
| } | |
| } | |
| } | |
| function retryIfBlockedOn(unblocked) { | |
| // Mark anything that was blocked on this as no longer blocked | |
| // and eligible for a replay. | |
| if (queuedDiscreteEvents.length > 0) { | |
| scheduleCallbackIfUnblocked(queuedDiscreteEvents[0], unblocked); // This is a exponential search for each boundary that commits. I think it's | |
| // worth it because we expect very few discrete events to queue up and once | |
| // we are actually fully unblocked it will be fast to replay them. | |
| for (var i = 1; i < queuedDiscreteEvents.length; i++) { | |
| var queuedEvent = queuedDiscreteEvents[i]; | |
| if (queuedEvent.blockedOn === unblocked) { | |
| queuedEvent.blockedOn = null; | |
| } | |
| } | |
| } | |
| if (queuedFocus !== null) { | |
| scheduleCallbackIfUnblocked(queuedFocus, unblocked); | |
| } | |
| if (queuedDrag !== null) { | |
| scheduleCallbackIfUnblocked(queuedDrag, unblocked); | |
| } | |
| if (queuedMouse !== null) { | |
| scheduleCallbackIfUnblocked(queuedMouse, unblocked); | |
| } | |
| var unblock = function (queuedEvent) { | |
| return scheduleCallbackIfUnblocked(queuedEvent, unblocked); | |
| }; | |
| queuedPointers.forEach(unblock); | |
| queuedPointerCaptures.forEach(unblock); | |
| for (var _i = 0; _i < queuedExplicitHydrationTargets.length; _i++) { | |
| var queuedTarget = queuedExplicitHydrationTargets[_i]; | |
| if (queuedTarget.blockedOn === unblocked) { | |
| queuedTarget.blockedOn = null; | |
| } | |
| } | |
| while (queuedExplicitHydrationTargets.length > 0) { | |
| var nextExplicitTarget = queuedExplicitHydrationTargets[0]; | |
| if (nextExplicitTarget.blockedOn !== null) { | |
| // We're still blocked. | |
| break; | |
| } else { | |
| attemptExplicitHydrationTarget(nextExplicitTarget); | |
| if (nextExplicitTarget.blockedOn === null) { | |
| // We're unblocked. | |
| queuedExplicitHydrationTargets.shift(); | |
| } | |
| } | |
| } | |
| } | |
| function addEventBubbleListener(element, eventType, listener) { | |
| element.addEventListener(eventType, listener, false); | |
| } | |
| function addEventCaptureListener(element, eventType, listener) { | |
| element.addEventListener(eventType, listener, true); | |
| } | |
| // do it in two places, which duplicates logic | |
| // and increases the bundle size, we do it all | |
| // here once. If we remove or refactor the | |
| // SimpleEventPlugin, we should also remove or | |
| // update the below line. | |
| var simpleEventPluginEventTypes = {}; | |
| var topLevelEventsToDispatchConfig = new Map(); | |
| var eventPriorities = new Map(); // We store most of the events in this module in pairs of two strings so we can re-use | |
| // the code required to apply the same logic for event prioritization and that of the | |
| // SimpleEventPlugin. This complicates things slightly, but the aim is to reduce code | |
| // duplication (for which there would be quite a bit). For the events that are not needed | |
| // for the SimpleEventPlugin (otherDiscreteEvents) we process them separately as an | |
| // array of top level events. | |
| // Lastly, we ignore prettier so we can keep the formatting sane. | |
| // prettier-ignore | |
| var discreteEventPairsForSimpleEventPlugin = [TOP_BLUR, 'blur', TOP_CANCEL, 'cancel', TOP_CLICK, 'click', TOP_CLOSE, 'close', TOP_CONTEXT_MENU, 'contextMenu', TOP_COPY, 'copy', TOP_CUT, 'cut', TOP_AUX_CLICK, 'auxClick', TOP_DOUBLE_CLICK, 'doubleClick', TOP_DRAG_END, 'dragEnd', TOP_DRAG_START, 'dragStart', TOP_DROP, 'drop', TOP_FOCUS, 'focus', TOP_INPUT, 'input', TOP_INVALID, 'invalid', TOP_KEY_DOWN, 'keyDown', TOP_KEY_PRESS, 'keyPress', TOP_KEY_UP, 'keyUp', TOP_MOUSE_DOWN, 'mouseDown', TOP_MOUSE_UP, 'mouseUp', TOP_PASTE, 'paste', TOP_PAUSE, 'pause', TOP_PLAY, 'play', TOP_POINTER_CANCEL, 'pointerCancel', TOP_POINTER_DOWN, 'pointerDown', TOP_POINTER_UP, 'pointerUp', TOP_RATE_CHANGE, 'rateChange', TOP_RESET, 'reset', TOP_SEEKED, 'seeked', TOP_SUBMIT, 'submit', TOP_TOUCH_CANCEL, 'touchCancel', TOP_TOUCH_END, 'touchEnd', TOP_TOUCH_START, 'touchStart', TOP_VOLUME_CHANGE, 'volumeChange']; | |
| var otherDiscreteEvents = [TOP_CHANGE, TOP_SELECTION_CHANGE, TOP_TEXT_INPUT, TOP_COMPOSITION_START, TOP_COMPOSITION_END, TOP_COMPOSITION_UPDATE]; // prettier-ignore | |
| var userBlockingPairsForSimpleEventPlugin = [TOP_DRAG, 'drag', TOP_DRAG_ENTER, 'dragEnter', TOP_DRAG_EXIT, 'dragExit', TOP_DRAG_LEAVE, 'dragLeave', TOP_DRAG_OVER, 'dragOver', TOP_MOUSE_MOVE, 'mouseMove', TOP_MOUSE_OUT, 'mouseOut', TOP_MOUSE_OVER, 'mouseOver', TOP_POINTER_MOVE, 'pointerMove', TOP_POINTER_OUT, 'pointerOut', TOP_POINTER_OVER, 'pointerOver', TOP_SCROLL, 'scroll', TOP_TOGGLE, 'toggle', TOP_TOUCH_MOVE, 'touchMove', TOP_WHEEL, 'wheel']; // prettier-ignore | |
| var continuousPairsForSimpleEventPlugin = [TOP_ABORT, 'abort', TOP_ANIMATION_END, 'animationEnd', TOP_ANIMATION_ITERATION, 'animationIteration', TOP_ANIMATION_START, 'animationStart', TOP_CAN_PLAY, 'canPlay', TOP_CAN_PLAY_THROUGH, 'canPlayThrough', TOP_DURATION_CHANGE, 'durationChange', TOP_EMPTIED, 'emptied', TOP_ENCRYPTED, 'encrypted', TOP_ENDED, 'ended', TOP_ERROR, 'error', TOP_GOT_POINTER_CAPTURE, 'gotPointerCapture', TOP_LOAD, 'load', TOP_LOADED_DATA, 'loadedData', TOP_LOADED_METADATA, 'loadedMetadata', TOP_LOAD_START, 'loadStart', TOP_LOST_POINTER_CAPTURE, 'lostPointerCapture', TOP_PLAYING, 'playing', TOP_PROGRESS, 'progress', TOP_SEEKING, 'seeking', TOP_STALLED, 'stalled', TOP_SUSPEND, 'suspend', TOP_TIME_UPDATE, 'timeUpdate', TOP_TRANSITION_END, 'transitionEnd', TOP_WAITING, 'waiting']; | |
| /** | |
| * Turns | |
| * ['abort', ...] | |
| * into | |
| * eventTypes = { | |
| * 'abort': { | |
| * phasedRegistrationNames: { | |
| * bubbled: 'onAbort', | |
| * captured: 'onAbortCapture', | |
| * }, | |
| * dependencies: [TOP_ABORT], | |
| * }, | |
| * ... | |
| * }; | |
| * topLevelEventsToDispatchConfig = new Map([ | |
| * [TOP_ABORT, { sameConfig }], | |
| * ]); | |
| */ | |
| function processSimpleEventPluginPairsByPriority(eventTypes, priority) { | |
| // As the event types are in pairs of two, we need to iterate | |
| // through in twos. The events are in pairs of two to save code | |
| // and improve init perf of processing this array, as it will | |
| // result in far fewer object allocations and property accesses | |
| // if we only use three arrays to process all the categories of | |
| // instead of tuples. | |
| for (var i = 0; i < eventTypes.length; i += 2) { | |
| var topEvent = eventTypes[i]; | |
| var event = eventTypes[i + 1]; | |
| var capitalizedEvent = event[0].toUpperCase() + event.slice(1); | |
| var onEvent = 'on' + capitalizedEvent; | |
| var config = { | |
| phasedRegistrationNames: { | |
| bubbled: onEvent, | |
| captured: onEvent + 'Capture' | |
| }, | |
| dependencies: [topEvent], | |
| eventPriority: priority | |
| }; | |
| eventPriorities.set(topEvent, priority); | |
| topLevelEventsToDispatchConfig.set(topEvent, config); | |
| simpleEventPluginEventTypes[event] = config; | |
| } | |
| } | |
| function processTopEventPairsByPriority(eventTypes, priority) { | |
| for (var i = 0; i < eventTypes.length; i++) { | |
| eventPriorities.set(eventTypes[i], priority); | |
| } | |
| } // SimpleEventPlugin | |
| processSimpleEventPluginPairsByPriority(discreteEventPairsForSimpleEventPlugin, DiscreteEvent); | |
| processSimpleEventPluginPairsByPriority(userBlockingPairsForSimpleEventPlugin, UserBlockingEvent); | |
| processSimpleEventPluginPairsByPriority(continuousPairsForSimpleEventPlugin, ContinuousEvent); // Not used by SimpleEventPlugin | |
| processTopEventPairsByPriority(otherDiscreteEvents, DiscreteEvent); | |
| function getEventPriorityForPluginSystem(topLevelType) { | |
| var priority = eventPriorities.get(topLevelType); // Default to a ContinuousEvent. Note: we might | |
| // want to warn if we can't detect the priority | |
| // for the event. | |
| return priority === undefined ? ContinuousEvent : priority; | |
| } | |
| // Intentionally not named imports because Rollup would use dynamic dispatch for | |
| var UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, | |
| runWithPriority = Scheduler.unstable_runWithPriority; // TODO: can we stop exporting these? | |
| var _enabled = true; | |
| function setEnabled(enabled) { | |
| _enabled = !!enabled; | |
| } | |
| function isEnabled() { | |
| return _enabled; | |
| } | |
| function trapBubbledEvent(topLevelType, element) { | |
| trapEventForPluginEventSystem(element, topLevelType, false); | |
| } | |
| function trapCapturedEvent(topLevelType, element) { | |
| trapEventForPluginEventSystem(element, topLevelType, true); | |
| } | |
| function trapEventForPluginEventSystem(container, topLevelType, capture) { | |
| var listener; | |
| switch (getEventPriorityForPluginSystem(topLevelType)) { | |
| case DiscreteEvent: | |
| listener = dispatchDiscreteEvent.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM, container); | |
| break; | |
| case UserBlockingEvent: | |
| listener = dispatchUserBlockingUpdate.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM, container); | |
| break; | |
| case ContinuousEvent: | |
| default: | |
| listener = dispatchEvent.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM, container); | |
| break; | |
| } | |
| var rawEventName = getRawEventName(topLevelType); | |
| if (capture) { | |
| addEventCaptureListener(container, rawEventName, listener); | |
| } else { | |
| addEventBubbleListener(container, rawEventName, listener); | |
| } | |
| } | |
| function dispatchDiscreteEvent(topLevelType, eventSystemFlags, container, nativeEvent) { | |
| flushDiscreteUpdatesIfNeeded(nativeEvent.timeStamp); | |
| discreteUpdates(dispatchEvent, topLevelType, eventSystemFlags, container, nativeEvent); | |
| } | |
| function dispatchUserBlockingUpdate(topLevelType, eventSystemFlags, container, nativeEvent) { | |
| runWithPriority(UserBlockingPriority, dispatchEvent.bind(null, topLevelType, eventSystemFlags, container, nativeEvent)); | |
| } | |
| function dispatchEvent(topLevelType, eventSystemFlags, container, nativeEvent) { | |
| if (!_enabled) { | |
| return; | |
| } | |
| if (hasQueuedDiscreteEvents() && isReplayableDiscreteEvent(topLevelType)) { | |
| // If we already have a queue of discrete events, and this is another discrete | |
| // event, then we can't dispatch it regardless of its target, since they | |
| // need to dispatch in order. | |
| queueDiscreteEvent(null, // Flags that we're not actually blocked on anything as far as we know. | |
| topLevelType, eventSystemFlags, container, nativeEvent); | |
| return; | |
| } | |
| var blockedOn = attemptToDispatchEvent(topLevelType, eventSystemFlags, container, nativeEvent); | |
| if (blockedOn === null) { | |
| // We successfully dispatched this event. | |
| clearIfContinuousEvent(topLevelType, nativeEvent); | |
| return; | |
| } | |
| if (isReplayableDiscreteEvent(topLevelType)) { | |
| // This this to be replayed later once the target is available. | |
| queueDiscreteEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent); | |
| return; | |
| } | |
| if (queueIfContinuousEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent)) { | |
| return; | |
| } // We need to clear only if we didn't queue because | |
| // queueing is accummulative. | |
| clearIfContinuousEvent(topLevelType, nativeEvent); // This is not replayable so we'll invoke it but without a target, | |
| // in case the event system needs to trace it. | |
| { | |
| dispatchEventForLegacyPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, null); | |
| } | |
| } // Attempt dispatching an event. Returns a SuspenseInstance or Container if it's blocked. | |
| function attemptToDispatchEvent(topLevelType, eventSystemFlags, container, nativeEvent) { | |
| // TODO: Warn if _enabled is false. | |
| var nativeEventTarget = getEventTarget(nativeEvent); | |
| var targetInst = getClosestInstanceFromNode(nativeEventTarget); | |
| if (targetInst !== null) { | |
| var nearestMounted = getNearestMountedFiber(targetInst); | |
| if (nearestMounted === null) { | |
| // This tree has been unmounted already. Dispatch without a target. | |
| targetInst = null; | |
| } else { | |
| var tag = nearestMounted.tag; | |
| if (tag === SuspenseComponent) { | |
| var instance = getSuspenseInstanceFromFiber(nearestMounted); | |
| if (instance !== null) { | |
| // Queue the event to be replayed later. Abort dispatching since we | |
| // don't want this event dispatched twice through the event system. | |
| // TODO: If this is the first discrete event in the queue. Schedule an increased | |
| // priority for this boundary. | |
| return instance; | |
| } // This shouldn't happen, something went wrong but to avoid blocking | |
| // the whole system, dispatch the event without a target. | |
| // TODO: Warn. | |
| targetInst = null; | |
| } else if (tag === HostRoot) { | |
| var root = nearestMounted.stateNode; | |
| if (root.hydrate) { | |
| // If this happens during a replay something went wrong and it might block | |
| // the whole system. | |
| return getContainerFromFiber(nearestMounted); | |
| } | |
| targetInst = null; | |
| } else if (nearestMounted !== targetInst) { | |
| // If we get an event (ex: img onload) before committing that | |
| // component's mount, ignore it for now (that is, treat it as if it was an | |
| // event on a non-React tree). We might also consider queueing events and | |
| // dispatching them after the mount. | |
| targetInst = null; | |
| } | |
| } | |
| } | |
| { | |
| dispatchEventForLegacyPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst); | |
| } // We're not blocked on anything. | |
| return null; | |
| } | |
| // List derived from Gecko source code: | |
| // https://github.com/mozilla/gecko-dev/blob/4e638efc71/layout/style/test/property_database.js | |
| var shorthandToLonghand = { | |
| animation: ['animationDelay', 'animationDirection', 'animationDuration', 'animationFillMode', 'animationIterationCount', 'animationName', 'animationPlayState', 'animationTimingFunction'], | |
| background: ['backgroundAttachment', 'backgroundClip', 'backgroundColor', 'backgroundImage', 'backgroundOrigin', 'backgroundPositionX', 'backgroundPositionY', 'backgroundRepeat', 'backgroundSize'], | |
| backgroundPosition: ['backgroundPositionX', 'backgroundPositionY'], | |
| border: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth', 'borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth', 'borderRightColor', 'borderRightStyle', 'borderRightWidth', 'borderTopColor', 'borderTopStyle', 'borderTopWidth'], | |
| borderBlockEnd: ['borderBlockEndColor', 'borderBlockEndStyle', 'borderBlockEndWidth'], | |
| borderBlockStart: ['borderBlockStartColor', 'borderBlockStartStyle', 'borderBlockStartWidth'], | |
| borderBottom: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth'], | |
| borderColor: ['borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor'], | |
| borderImage: ['borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth'], | |
| borderInlineEnd: ['borderInlineEndColor', 'borderInlineEndStyle', 'borderInlineEndWidth'], | |
| borderInlineStart: ['borderInlineStartColor', 'borderInlineStartStyle', 'borderInlineStartWidth'], | |
| borderLeft: ['borderLeftColor', 'borderLeftStyle', 'borderLeftWidth'], | |
| borderRadius: ['borderBottomLeftRadius', 'borderBottomRightRadius', 'borderTopLeftRadius', 'borderTopRightRadius'], | |
| borderRight: ['borderRightColor', 'borderRightStyle', 'borderRightWidth'], | |
| borderStyle: ['borderBottomStyle', 'borderLeftStyle', 'borderRightStyle', 'borderTopStyle'], | |
| borderTop: ['borderTopColor', 'borderTopStyle', 'borderTopWidth'], | |
| borderWidth: ['borderBottomWidth', 'borderLeftWidth', 'borderRightWidth', 'borderTopWidth'], | |
| columnRule: ['columnRuleColor', 'columnRuleStyle', 'columnRuleWidth'], | |
| columns: ['columnCount', 'columnWidth'], | |
| flex: ['flexBasis', 'flexGrow', 'flexShrink'], | |
| flexFlow: ['flexDirection', 'flexWrap'], | |
| font: ['fontFamily', 'fontFeatureSettings', 'fontKerning', 'fontLanguageOverride', 'fontSize', 'fontSizeAdjust', 'fontStretch', 'fontStyle', 'fontVariant', 'fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition', 'fontWeight', 'lineHeight'], | |
| fontVariant: ['fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition'], | |
| gap: ['columnGap', 'rowGap'], | |
| grid: ['gridAutoColumns', 'gridAutoFlow', 'gridAutoRows', 'gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'], | |
| gridArea: ['gridColumnEnd', 'gridColumnStart', 'gridRowEnd', 'gridRowStart'], | |
| gridColumn: ['gridColumnEnd', 'gridColumnStart'], | |
| gridColumnGap: ['columnGap'], | |
| gridGap: ['columnGap', 'rowGap'], | |
| gridRow: ['gridRowEnd', 'gridRowStart'], | |
| gridRowGap: ['rowGap'], | |
| gridTemplate: ['gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'], | |
| listStyle: ['listStyleImage', 'listStylePosition', 'listStyleType'], | |
| margin: ['marginBottom', 'marginLeft', 'marginRight', 'marginTop'], | |
| marker: ['markerEnd', 'markerMid', 'markerStart'], | |
| mask: ['maskClip', 'maskComposite', 'maskImage', 'maskMode', 'maskOrigin', 'maskPositionX', 'maskPositionY', 'maskRepeat', 'maskSize'], | |
| maskPosition: ['maskPositionX', 'maskPositionY'], | |
| outline: ['outlineColor', 'outlineStyle', 'outlineWidth'], | |
| overflow: ['overflowX', 'overflowY'], | |
| padding: ['paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop'], | |
| placeContent: ['alignContent', 'justifyContent'], | |
| placeItems: ['alignItems', 'justifyItems'], | |
| placeSelf: ['alignSelf', 'justifySelf'], | |
| textDecoration: ['textDecorationColor', 'textDecorationLine', 'textDecorationStyle'], | |
| textEmphasis: ['textEmphasisColor', 'textEmphasisStyle'], | |
| transition: ['transitionDelay', 'transitionDuration', 'transitionProperty', 'transitionTimingFunction'], | |
| wordWrap: ['overflowWrap'] | |
| }; | |
| /** | |
| * CSS properties which accept numbers but are not in units of "px". | |
| */ | |
| var isUnitlessNumber = { | |
| animationIterationCount: true, | |
| borderImageOutset: true, | |
| borderImageSlice: true, | |
| borderImageWidth: true, | |
| boxFlex: true, | |
| boxFlexGroup: true, | |
| boxOrdinalGroup: true, | |
| columnCount: true, | |
| columns: true, | |
| flex: true, | |
| flexGrow: true, | |
| flexPositive: true, | |
| flexShrink: true, | |
| flexNegative: true, | |
| flexOrder: true, | |
| gridArea: true, | |
| gridRow: true, | |
| gridRowEnd: true, | |
| gridRowSpan: true, | |
| gridRowStart: true, | |
| gridColumn: true, | |
| gridColumnEnd: true, | |
| gridColumnSpan: true, | |
| gridColumnStart: true, | |
| fontWeight: true, | |
| lineClamp: true, | |
| lineHeight: true, | |
| opacity: true, | |
| order: true, | |
| orphans: true, | |
| tabSize: true, | |
| widows: true, | |
| zIndex: true, | |
| zoom: true, | |
| // SVG-related properties | |
| fillOpacity: true, | |
| floodOpacity: true, | |
| stopOpacity: true, | |
| strokeDasharray: true, | |
| strokeDashoffset: true, | |
| strokeMiterlimit: true, | |
| strokeOpacity: true, | |
| strokeWidth: true | |
| }; | |
| /** | |
| * @param {string} prefix vendor-specific prefix, eg: Webkit | |
| * @param {string} key style name, eg: transitionDuration | |
| * @return {string} style name prefixed with `prefix`, properly camelCased, eg: | |
| * WebkitTransitionDuration | |
| */ | |
| function prefixKey(prefix, key) { | |
| return prefix + key.charAt(0).toUpperCase() + key.substring(1); | |
| } | |
| /** | |
| * Support style names that may come passed in prefixed by adding permutations | |
| * of vendor prefixes. | |
| */ | |
| var prefixes = ['Webkit', 'ms', 'Moz', 'O']; // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an | |
| // infinite loop, because it iterates over the newly added props too. | |
| Object.keys(isUnitlessNumber).forEach(function (prop) { | |
| prefixes.forEach(function (prefix) { | |
| isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop]; | |
| }); | |
| }); | |
| /** | |
| * Convert a value into the proper css writable value. The style name `name` | |
| * should be logical (no hyphens), as specified | |
| * in `CSSProperty.isUnitlessNumber`. | |
| * | |
| * @param {string} name CSS property name such as `topMargin`. | |
| * @param {*} value CSS property value such as `10px`. | |
| * @return {string} Normalized style value with dimensions applied. | |
| */ | |
| function dangerousStyleValue(name, value, isCustomProperty) { | |
| // Note that we've removed escapeTextForBrowser() calls here since the | |
| // whole string will be escaped when the attribute is injected into | |
| // the markup. If you provide unsafe user data here they can inject | |
| // arbitrary CSS which may be problematic (I couldn't repro this): | |
| // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet | |
| // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/ | |
| // This is not an XSS hole but instead a potential CSS injection issue | |
| // which has lead to a greater discussion about how we're going to | |
| // trust URLs moving forward. See #2115901 | |
| var isEmpty = value == null || typeof value === 'boolean' || value === ''; | |
| if (isEmpty) { | |
| return ''; | |
| } | |
| if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) { | |
| return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers | |
| } | |
| return ('' + value).trim(); | |
| } | |
| var uppercasePattern = /([A-Z])/g; | |
| var msPattern = /^ms-/; | |
| /** | |
| * Hyphenates a camelcased CSS property name, for example: | |
| * | |
| * > hyphenateStyleName('backgroundColor') | |
| * < "background-color" | |
| * > hyphenateStyleName('MozTransition') | |
| * < "-moz-transition" | |
| * > hyphenateStyleName('msTransition') | |
| * < "-ms-transition" | |
| * | |
| * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix | |
| * is converted to `-ms-`. | |
| */ | |
| function hyphenateStyleName(name) { | |
| return name.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern, '-ms-'); | |
| } | |
| var warnValidStyle = function () {}; | |
| { | |
| // 'msTransform' is correct, but the other prefixes should be capitalized | |
| var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/; | |
| var msPattern$1 = /^-ms-/; | |
| var hyphenPattern = /-(.)/g; // style values shouldn't contain a semicolon | |
| var badStyleValueWithSemicolonPattern = /;\s*$/; | |
| var warnedStyleNames = {}; | |
| var warnedStyleValues = {}; | |
| var warnedForNaNValue = false; | |
| var warnedForInfinityValue = false; | |
| var camelize = function (string) { | |
| return string.replace(hyphenPattern, function (_, character) { | |
| return character.toUpperCase(); | |
| }); | |
| }; | |
| var warnHyphenatedStyleName = function (name) { | |
| if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { | |
| return; | |
| } | |
| warnedStyleNames[name] = true; | |
| error('Unsupported style property %s. Did you mean %s?', name, // As Andi Smith suggests | |
| // (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix | |
| // is converted to lowercase `ms`. | |
| camelize(name.replace(msPattern$1, 'ms-'))); | |
| }; | |
| var warnBadVendoredStyleName = function (name) { | |
| if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { | |
| return; | |
| } | |
| warnedStyleNames[name] = true; | |
| error('Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1)); | |
| }; | |
| var warnStyleValueWithSemicolon = function (name, value) { | |
| if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) { | |
| return; | |
| } | |
| warnedStyleValues[value] = true; | |
| error("Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, '')); | |
| }; | |
| var warnStyleValueIsNaN = function (name, value) { | |
| if (warnedForNaNValue) { | |
| return; | |
| } | |
| warnedForNaNValue = true; | |
| error('`NaN` is an invalid value for the `%s` css style property.', name); | |
| }; | |
| var warnStyleValueIsInfinity = function (name, value) { | |
| if (warnedForInfinityValue) { | |
| return; | |
| } | |
| warnedForInfinityValue = true; | |
| error('`Infinity` is an invalid value for the `%s` css style property.', name); | |
| }; | |
| warnValidStyle = function (name, value) { | |
| if (name.indexOf('-') > -1) { | |
| warnHyphenatedStyleName(name); | |
| } else if (badVendoredStyleNamePattern.test(name)) { | |
| warnBadVendoredStyleName(name); | |
| } else if (badStyleValueWithSemicolonPattern.test(value)) { | |
| warnStyleValueWithSemicolon(name, value); | |
| } | |
| if (typeof value === 'number') { | |
| if (isNaN(value)) { | |
| warnStyleValueIsNaN(name, value); | |
| } else if (!isFinite(value)) { | |
| warnStyleValueIsInfinity(name, value); | |
| } | |
| } | |
| }; | |
| } | |
| var warnValidStyle$1 = warnValidStyle; | |
| /** | |
| * Operations for dealing with CSS properties. | |
| */ | |
| /** | |
| * This creates a string that is expected to be equivalent to the style | |
| * attribute generated by server-side rendering. It by-passes warnings and | |
| * security checks so it's not safe to use this value for anything other than | |
| * comparison. It is only used in DEV for SSR validation. | |
| */ | |
| function createDangerousStringForStyles(styles) { | |
| { | |
| var serialized = ''; | |
| var delimiter = ''; | |
| for (var styleName in styles) { | |
| if (!styles.hasOwnProperty(styleName)) { | |
| continue; | |
| } | |
| var styleValue = styles[styleName]; | |
| if (styleValue != null) { | |
| var isCustomProperty = styleName.indexOf('--') === 0; | |
| serialized += delimiter + (isCustomProperty ? styleName : hyphenateStyleName(styleName)) + ':'; | |
| serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty); | |
| delimiter = ';'; | |
| } | |
| } | |
| return serialized || null; | |
| } | |
| } | |
| /** | |
| * Sets the value for multiple styles on a node. If a value is specified as | |
| * '' (empty string), the corresponding style property will be unset. | |
| * | |
| * @param {DOMElement} node | |
| * @param {object} styles | |
| */ | |
| function setValueForStyles(node, styles) { | |
| var style = node.style; | |
| for (var styleName in styles) { | |
| if (!styles.hasOwnProperty(styleName)) { | |
| continue; | |
| } | |
| var isCustomProperty = styleName.indexOf('--') === 0; | |
| { | |
| if (!isCustomProperty) { | |
| warnValidStyle$1(styleName, styles[styleName]); | |
| } | |
| } | |
| var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty); | |
| if (styleName === 'float') { | |
| styleName = 'cssFloat'; | |
| } | |
| if (isCustomProperty) { | |
| style.setProperty(styleName, styleValue); | |
| } else { | |
| style[styleName] = styleValue; | |
| } | |
| } | |
| } | |
| function isValueEmpty(value) { | |
| return value == null || typeof value === 'boolean' || value === ''; | |
| } | |
| /** | |
| * Given {color: 'red', overflow: 'hidden'} returns { | |
| * color: 'color', | |
| * overflowX: 'overflow', | |
| * overflowY: 'overflow', | |
| * }. This can be read as "the overflowY property was set by the overflow | |
| * shorthand". That is, the values are the property that each was derived from. | |
| */ | |
| function expandShorthandMap(styles) { | |
| var expanded = {}; | |
| for (var key in styles) { | |
| var longhands = shorthandToLonghand[key] || [key]; | |
| for (var i = 0; i < longhands.length; i++) { | |
| expanded[longhands[i]] = key; | |
| } | |
| } | |
| return expanded; | |
| } | |
| /** | |
| * When mixing shorthand and longhand property names, we warn during updates if | |
| * we expect an incorrect result to occur. In particular, we warn for: | |
| * | |
| * Updating a shorthand property (longhand gets overwritten): | |
| * {font: 'foo', fontVariant: 'bar'} -> {font: 'baz', fontVariant: 'bar'} | |
| * becomes .style.font = 'baz' | |
| * Removing a shorthand property (longhand gets lost too): | |
| * {font: 'foo', fontVariant: 'bar'} -> {fontVariant: 'bar'} | |
| * becomes .style.font = '' | |
| * Removing a longhand property (should revert to shorthand; doesn't): | |
| * {font: 'foo', fontVariant: 'bar'} -> {font: 'foo'} | |
| * becomes .style.fontVariant = '' | |
| */ | |
| function validateShorthandPropertyCollisionInDev(styleUpdates, nextStyles) { | |
| { | |
| if (!nextStyles) { | |
| return; | |
| } | |
| var expandedUpdates = expandShorthandMap(styleUpdates); | |
| var expandedStyles = expandShorthandMap(nextStyles); | |
| var warnedAbout = {}; | |
| for (var key in expandedUpdates) { | |
| var originalKey = expandedUpdates[key]; | |
| var correctOriginalKey = expandedStyles[key]; | |
| if (correctOriginalKey && originalKey !== correctOriginalKey) { | |
| var warningKey = originalKey + ',' + correctOriginalKey; | |
| if (warnedAbout[warningKey]) { | |
| continue; | |
| } | |
| warnedAbout[warningKey] = true; | |
| error('%s a style property during rerender (%s) when a ' + 'conflicting property is set (%s) can lead to styling bugs. To ' + "avoid this, don't mix shorthand and non-shorthand properties " + 'for the same value; instead, replace the shorthand with ' + 'separate values.', isValueEmpty(styleUpdates[originalKey]) ? 'Removing' : 'Updating', originalKey, correctOriginalKey); | |
| } | |
| } | |
| } | |
| } | |
| // For HTML, certain tags should omit their close tag. We keep a whitelist for | |
| // those special-case tags. | |
| var omittedCloseTags = { | |
| area: true, | |
| base: true, | |
| br: true, | |
| col: true, | |
| embed: true, | |
| hr: true, | |
| img: true, | |
| input: true, | |
| keygen: true, | |
| link: true, | |
| meta: true, | |
| param: true, | |
| source: true, | |
| track: true, | |
| wbr: true // NOTE: menuitem's close tag should be omitted, but that causes problems. | |
| }; | |
| // `omittedCloseTags` except that `menuitem` should still have its closing tag. | |
| var voidElementTags = _assign({ | |
| menuitem: true | |
| }, omittedCloseTags); | |
| var HTML = '__html'; | |
| var ReactDebugCurrentFrame$3 = null; | |
| { | |
| ReactDebugCurrentFrame$3 = ReactSharedInternals.ReactDebugCurrentFrame; | |
| } | |
| function assertValidProps(tag, props) { | |
| if (!props) { | |
| return; | |
| } // Note the use of `==` which checks for null or undefined. | |
| if (voidElementTags[tag]) { | |
| if (!(props.children == null && props.dangerouslySetInnerHTML == null)) { | |
| { | |
| throw Error( tag + " is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`." + ( ReactDebugCurrentFrame$3.getStackAddendum() ) ); | |
| } | |
| } | |
| } | |
| if (props.dangerouslySetInnerHTML != null) { | |
| if (!(props.children == null)) { | |
| { | |
| throw Error( "Can only set one of `children` or `props.dangerouslySetInnerHTML`." ); | |
| } | |
| } | |
| if (!(typeof props.dangerouslySetInnerHTML === 'object' && HTML in props.dangerouslySetInnerHTML)) { | |
| { | |
| throw Error( "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information." ); | |
| } | |
| } | |
| } | |
| { | |
| if (!props.suppressContentEditableWarning && props.contentEditable && props.children != null) { | |
| error('A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.'); | |
| } | |
| } | |
| if (!(props.style == null || typeof props.style === 'object')) { | |
| { | |
| throw Error( "The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX." + ( ReactDebugCurrentFrame$3.getStackAddendum() ) ); | |
| } | |
| } | |
| } | |
| function isCustomComponent(tagName, props) { | |
| if (tagName.indexOf('-') === -1) { | |
| return typeof props.is === 'string'; | |
| } | |
| switch (tagName) { | |
| // These are reserved SVG and MathML elements. | |
| // We don't mind this whitelist too much because we expect it to never grow. | |
| // The alternative is to track the namespace in a few places which is convoluted. | |
| // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts | |
| case 'annotation-xml': | |
| case 'color-profile': | |
| case 'font-face': | |
| case 'font-face-src': | |
| case 'font-face-uri': | |
| case 'font-face-format': | |
| case 'font-face-name': | |
| case 'missing-glyph': | |
| return false; | |
| default: | |
| return true; | |
| } | |
| } | |
| // When adding attributes to the HTML or SVG whitelist, be sure to | |
| // also add them to this module to ensure casing and incorrect name | |
| // warnings. | |
| var possibleStandardNames = { | |
| // HTML | |
| accept: 'accept', | |
| acceptcharset: 'acceptCharset', | |
| 'accept-charset': 'acceptCharset', | |
| accesskey: 'accessKey', | |
| action: 'action', | |
| allowfullscreen: 'allowFullScreen', | |
| alt: 'alt', | |
| as: 'as', | |
| async: 'async', | |
| autocapitalize: 'autoCapitalize', | |
| autocomplete: 'autoComplete', | |
| autocorrect: 'autoCorrect', | |
| autofocus: 'autoFocus', | |
| autoplay: 'autoPlay', | |
| autosave: 'autoSave', | |
| capture: 'capture', | |
| cellpadding: 'cellPadding', | |
| cellspacing: 'cellSpacing', | |
| challenge: 'challenge', | |
| charset: 'charSet', | |
| checked: 'checked', | |
| children: 'children', | |
| cite: 'cite', | |
| class: 'className', | |
| classid: 'classID', | |
| classname: 'className', | |
| cols: 'cols', | |
| colspan: 'colSpan', | |
| content: 'content', | |
| contenteditable: 'contentEditable', | |
| contextmenu: 'contextMenu', | |
| controls: 'controls', | |
| controlslist: 'controlsList', | |
| coords: 'coords', | |
| crossorigin: 'crossOrigin', | |
| dangerouslysetinnerhtml: 'dangerouslySetInnerHTML', | |
| data: 'data', | |
| datetime: 'dateTime', | |
| default: 'default', | |
| defaultchecked: 'defaultChecked', | |
| defaultvalue: 'defaultValue', | |
| defer: 'defer', | |
| dir: 'dir', | |
| disabled: 'disabled', | |
| disablepictureinpicture: 'disablePictureInPicture', | |
| download: 'download', | |
| draggable: 'draggable', | |
| enctype: 'encType', | |
| for: 'htmlFor', | |
| form: 'form', | |
| formmethod: 'formMethod', | |
| formaction: 'formAction', | |
| formenctype: 'formEncType', | |
| formnovalidate: 'formNoValidate', | |
| formtarget: 'formTarget', | |
| frameborder: 'frameBorder', | |
| headers: 'headers', | |
| height: 'height', | |
| hidden: 'hidden', | |
| high: 'high', | |
| href: 'href', | |
| hreflang: 'hrefLang', | |
| htmlfor: 'htmlFor', | |
| httpequiv: 'httpEquiv', | |
| 'http-equiv': 'httpEquiv', | |
| icon: 'icon', | |
| id: 'id', | |
| innerhtml: 'innerHTML', | |
| inputmode: 'inputMode', | |
| integrity: 'integrity', | |
| is: 'is', | |
| itemid: 'itemID', | |
| itemprop: 'itemProp', | |
| itemref: 'itemRef', | |
| itemscope: 'itemScope', | |
| itemtype: 'itemType', | |
| keyparams: 'keyParams', | |
| keytype: 'keyType', | |
| kind: 'kind', | |
| label: 'label', | |
| lang: 'lang', | |
| list: 'list', | |
| loop: 'loop', | |
| low: 'low', | |
| manifest: 'manifest', | |
| marginwidth: 'marginWidth', | |
| marginheight: 'marginHeight', | |
| max: 'max', | |
| maxlength: 'maxLength', | |
| media: 'media', | |
| mediagroup: 'mediaGroup', | |
| method: 'method', | |
| min: 'min', | |
| minlength: 'minLength', | |
| multiple: 'multiple', | |
| muted: 'muted', | |
| name: 'name', | |
| nomodule: 'noModule', | |
| nonce: 'nonce', | |
| novalidate: 'noValidate', | |
| open: 'open', | |
| optimum: 'optimum', | |
| pattern: 'pattern', | |
| placeholder: 'placeholder', | |
| playsinline: 'playsInline', | |
| poster: 'poster', | |
| preload: 'preload', | |
| profile: 'profile', | |
| radiogroup: 'radioGroup', | |
| readonly: 'readOnly', | |
| referrerpolicy: 'referrerPolicy', | |
| rel: 'rel', | |
| required: 'required', | |
| reversed: 'reversed', | |
| role: 'role', | |
| rows: 'rows', | |
| rowspan: 'rowSpan', | |
| sandbox: 'sandbox', | |
| scope: 'scope', | |
| scoped: 'scoped', | |
| scrolling: 'scrolling', | |
| seamless: 'seamless', | |
| selected: 'selected', | |
| shape: 'shape', | |
| size: 'size', | |
| sizes: 'sizes', | |
| span: 'span', | |
| spellcheck: 'spellCheck', | |
| src: 'src', | |
| srcdoc: 'srcDoc', | |
| srclang: 'srcLang', | |
| srcset: 'srcSet', | |
| start: 'start', | |
| step: 'step', | |
| style: 'style', | |
| summary: 'summary', | |
| tabindex: 'tabIndex', | |
| target: 'target', | |
| title: 'title', | |
| type: 'type', | |
| usemap: 'useMap', | |
| value: 'value', | |
| width: 'width', | |
| wmode: 'wmode', | |
| wrap: 'wrap', | |
| // SVG | |
| about: 'about', | |
| accentheight: 'accentHeight', | |
| 'accent-height': 'accentHeight', | |
| accumulate: 'accumulate', | |
| additive: 'additive', | |
| alignmentbaseline: 'alignmentBaseline', | |
| 'alignment-baseline': 'alignmentBaseline', | |
| allowreorder: 'allowReorder', | |
| alphabetic: 'alphabetic', | |
| amplitude: 'amplitude', | |
| arabicform: 'arabicForm', | |
| 'arabic-form': 'arabicForm', | |
| ascent: 'ascent', | |
| attributename: 'attributeName', | |
| attributetype: 'attributeType', | |
| autoreverse: 'autoReverse', | |
| azimuth: 'azimuth', | |
| basefrequency: 'baseFrequency', | |
| baselineshift: 'baselineShift', | |
| 'baseline-shift': 'baselineShift', | |
| baseprofile: 'baseProfile', | |
| bbox: 'bbox', | |
| begin: 'begin', | |
| bias: 'bias', | |
| by: 'by', | |
| calcmode: 'calcMode', | |
| capheight: 'capHeight', | |
| 'cap-height': 'capHeight', | |
| clip: 'clip', | |
| clippath: 'clipPath', | |
| 'clip-path': 'clipPath', | |
| clippathunits: 'clipPathUnits', | |
| cliprule: 'clipRule', | |
| 'clip-rule': 'clipRule', | |
| color: 'color', | |
| colorinterpolation: 'colorInterpolation', | |
| 'color-interpolation': 'colorInterpolation', | |
| colorinterpolationfilters: 'colorInterpolationFilters', | |
| 'color-interpolation-filters': 'colorInterpolationFilters', | |
| colorprofile: 'colorProfile', | |
| 'color-profile': 'colorProfile', | |
| colorrendering: 'colorRendering', | |
| 'color-rendering': 'colorRendering', | |
| contentscripttype: 'contentScriptType', | |
| contentstyletype: 'contentStyleType', | |
| cursor: 'cursor', | |
| cx: 'cx', | |
| cy: 'cy', | |
| d: 'd', | |
| datatype: 'datatype', | |
| decelerate: 'decelerate', | |
| descent: 'descent', | |
| diffuseconstant: 'diffuseConstant', | |
| direction: 'direction', | |
| display: 'display', | |
| divisor: 'divisor', | |
| dominantbaseline: 'dominantBaseline', | |
| 'dominant-baseline': 'dominantBaseline', | |
| dur: 'dur', | |
| dx: 'dx', | |
| dy: 'dy', | |
| edgemode: 'edgeMode', | |
| elevation: 'elevation', | |
| enablebackground: 'enableBackground', | |
| 'enable-background': 'enableBackground', | |
| end: 'end', | |
| exponent: 'exponent', | |
| externalresourcesrequired: 'externalResourcesRequired', | |
| fill: 'fill', | |
| fillopacity: 'fillOpacity', | |
| 'fill-opacity': 'fillOpacity', | |
| fillrule: 'fillRule', | |
| 'fill-rule': 'fillRule', | |
| filter: 'filter', | |
| filterres: 'filterRes', | |
| filterunits: 'filterUnits', | |
| floodopacity: 'floodOpacity', | |
| 'flood-opacity': 'floodOpacity', | |
| floodcolor: 'floodColor', | |
| 'flood-color': 'floodColor', | |
| focusable: 'focusable', | |
| fontfamily: 'fontFamily', | |
| 'font-family': 'fontFamily', | |
| fontsize: 'fontSize', | |
| 'font-size': 'fontSize', | |
| fontsizeadjust: 'fontSizeAdjust', | |
| 'font-size-adjust': 'fontSizeAdjust', | |
| fontstretch: 'fontStretch', | |
| 'font-stretch': 'fontStretch', | |
| fontstyle: 'fontStyle', | |
| 'font-style': 'fontStyle', | |
| fontvariant: 'fontVariant', | |
| 'font-variant': 'fontVariant', | |
| fontweight: 'fontWeight', | |
| 'font-weight': 'fontWeight', | |
| format: 'format', | |
| from: 'from', | |
| fx: 'fx', | |
| fy: 'fy', | |
| g1: 'g1', | |
| g2: 'g2', | |
| glyphname: 'glyphName', | |
| 'glyph-name': 'glyphName', | |
| glyphorientationhorizontal: 'glyphOrientationHorizontal', | |
| 'glyph-orientation-horizontal': 'glyphOrientationHorizontal', | |
| glyphorientationvertical: 'glyphOrientationVertical', | |
| 'glyph-orientation-vertical': 'glyphOrientationVertical', | |
| glyphref: 'glyphRef', | |
| gradienttransform: 'gradientTransform', | |
| gradientunits: 'gradientUnits', | |
| hanging: 'hanging', | |
| horizadvx: 'horizAdvX', | |
| 'horiz-adv-x': 'horizAdvX', | |
| horizoriginx: 'horizOriginX', | |
| 'horiz-origin-x': 'horizOriginX', | |
| ideographic: 'ideographic', | |
| imagerendering: 'imageRendering', | |
| 'image-rendering': 'imageRendering', | |
| in2: 'in2', | |
| in: 'in', | |
| inlist: 'inlist', | |
| intercept: 'intercept', | |
| k1: 'k1', | |
| k2: 'k2', | |
| k3: 'k3', | |
| k4: 'k4', | |
| k: 'k', | |
| kernelmatrix: 'kernelMatrix', | |
| kernelunitlength: 'kernelUnitLength', | |
| kerning: 'kerning', | |
| keypoints: 'keyPoints', | |
| keysplines: 'keySplines', | |
| keytimes: 'keyTimes', | |
| lengthadjust: 'lengthAdjust', | |
| letterspacing: 'letterSpacing', | |
| 'letter-spacing': 'letterSpacing', | |
| lightingcolor: 'lightingColor', | |
| 'lighting-color': 'lightingColor', | |
| limitingconeangle: 'limitingConeAngle', | |
| local: 'local', | |
| markerend: 'markerEnd', | |
| 'marker-end': 'markerEnd', | |
| markerheight: 'markerHeight', | |
| markermid: 'markerMid', | |
| 'marker-mid': 'markerMid', | |
| markerstart: 'markerStart', | |
| 'marker-start': 'markerStart', | |
| markerunits: 'markerUnits', | |
| markerwidth: 'markerWidth', | |
| mask: 'mask', | |
| maskcontentunits: 'maskContentUnits', | |
| maskunits: 'maskUnits', | |
| mathematical: 'mathematical', | |
| mode: 'mode', | |
| numoctaves: 'numOctaves', | |
| offset: 'offset', | |
| opacity: 'opacity', | |
| operator: 'operator', | |
| order: 'order', | |
| orient: 'orient', | |
| orientation: 'orientation', | |
| origin: 'origin', | |
| overflow: 'overflow', | |
| overlineposition: 'overlinePosition', | |
| 'overline-position': 'overlinePosition', | |
| overlinethickness: 'overlineThickness', | |
| 'overline-thickness': 'overlineThickness', | |
| paintorder: 'paintOrder', | |
| 'paint-order': 'paintOrder', | |
| panose1: 'panose1', | |
| 'panose-1': 'panose1', | |
| pathlength: 'pathLength', | |
| patterncontentunits: 'patternContentUnits', | |
| patterntransform: 'patternTransform', | |
| patternunits: 'patternUnits', | |
| pointerevents: 'pointerEvents', | |
| 'pointer-events': 'pointerEvents', | |
| points: 'points', | |
| pointsatx: 'pointsAtX', | |
| pointsaty: 'pointsAtY', | |
| pointsatz: 'pointsAtZ', | |
| prefix: 'prefix', | |
| preservealpha: 'preserveAlpha', | |
| preserveaspectratio: 'preserveAspectRatio', | |
| primitiveunits: 'primitiveUnits', | |
| property: 'property', | |
| r: 'r', | |
| radius: 'radius', | |
| refx: 'refX', | |
| refy: 'refY', | |
| renderingintent: 'renderingIntent', | |
| 'rendering-intent': 'renderingIntent', | |
| repeatcount: 'repeatCount', | |
| repeatdur: 'repeatDur', | |
| requiredextensions: 'requiredExtensions', | |
| requiredfeatures: 'requiredFeatures', | |
| resource: 'resource', | |
| restart: 'restart', | |
| result: 'result', | |
| results: 'results', | |
| rotate: 'rotate', | |
| rx: 'rx', | |
| ry: 'ry', | |
| scale: 'scale', | |
| security: 'security', | |
| seed: 'seed', | |
| shaperendering: 'shapeRendering', | |
| 'shape-rendering': 'shapeRendering', | |
| slope: 'slope', | |
| spacing: 'spacing', | |
| specularconstant: 'specularConstant', | |
| specularexponent: 'specularExponent', | |
| speed: 'speed', | |
| spreadmethod: 'spreadMethod', | |
| startoffset: 'startOffset', | |
| stddeviation: 'stdDeviation', | |
| stemh: 'stemh', | |
| stemv: 'stemv', | |
| stitchtiles: 'stitchTiles', | |
| stopcolor: 'stopColor', | |
| 'stop-color': 'stopColor', | |
| stopopacity: 'stopOpacity', | |
| 'stop-opacity': 'stopOpacity', | |
| strikethroughposition: 'strikethroughPosition', | |
| 'strikethrough-position': 'strikethroughPosition', | |
| strikethroughthickness: 'strikethroughThickness', | |
| 'strikethrough-thickness': 'strikethroughThickness', | |
| string: 'string', | |
| stroke: 'stroke', | |
| strokedasharray: 'strokeDasharray', | |
| 'stroke-dasharray': 'strokeDasharray', | |
| strokedashoffset: 'strokeDashoffset', | |
| 'stroke-dashoffset': 'strokeDashoffset', | |
| strokelinecap: 'strokeLinecap', | |
| 'stroke-linecap': 'strokeLinecap', | |
| strokelinejoin: 'strokeLinejoin', | |
| 'stroke-linejoin': 'strokeLinejoin', | |
| strokemiterlimit: 'strokeMiterlimit', | |
| 'stroke-miterlimit': 'strokeMiterlimit', | |
| strokewidth: 'strokeWidth', | |
| 'stroke-width': 'strokeWidth', | |
| strokeopacity: 'strokeOpacity', | |
| 'stroke-opacity': 'strokeOpacity', | |
| suppresscontenteditablewarning: 'suppressContentEditableWarning', | |
| suppresshydrationwarning: 'suppressHydrationWarning', | |
| surfacescale: 'surfaceScale', | |
| systemlanguage: 'systemLanguage', | |
| tablevalues: 'tableValues', | |
| targetx: 'targetX', | |
| targety: 'targetY', | |
| textanchor: 'textAnchor', | |
| 'text-anchor': 'textAnchor', | |
| textdecoration: 'textDecoration', | |
| 'text-decoration': 'textDecoration', | |
| textlength: 'textLength', | |
| textrendering: 'textRendering', | |
| 'text-rendering': 'textRendering', | |
| to: 'to', | |
| transform: 'transform', | |
| typeof: 'typeof', | |
| u1: 'u1', | |
| u2: 'u2', | |
| underlineposition: 'underlinePosition', | |
| 'underline-position': 'underlinePosition', | |
| underlinethickness: 'underlineThickness', | |
| 'underline-thickness': 'underlineThickness', | |
| unicode: 'unicode', | |
| unicodebidi: 'unicodeBidi', | |
| 'unicode-bidi': 'unicodeBidi', | |
| unicoderange: 'unicodeRange', | |
| 'unicode-range': 'unicodeRange', | |
| unitsperem: 'unitsPerEm', | |
| 'units-per-em': 'unitsPerEm', | |
| unselectable: 'unselectable', | |
| valphabetic: 'vAlphabetic', | |
| 'v-alphabetic': 'vAlphabetic', | |
| values: 'values', | |
| vectoreffect: 'vectorEffect', | |
| 'vector-effect': 'vectorEffect', | |
| version: 'version', | |
| vertadvy: 'vertAdvY', | |
| 'vert-adv-y': 'vertAdvY', | |
| vertoriginx: 'vertOriginX', | |
| 'vert-origin-x': 'vertOriginX', | |
| vertoriginy: 'vertOriginY', | |
| 'vert-origin-y': 'vertOriginY', | |
| vhanging: 'vHanging', | |
| 'v-hanging': 'vHanging', | |
| videographic: 'vIdeographic', | |
| 'v-ideographic': 'vIdeographic', | |
| viewbox: 'viewBox', | |
| viewtarget: 'viewTarget', | |
| visibility: 'visibility', | |
| vmathematical: 'vMathematical', | |
| 'v-mathematical': 'vMathematical', | |
| vocab: 'vocab', | |
| widths: 'widths', | |
| wordspacing: 'wordSpacing', | |
| 'word-spacing': 'wordSpacing', | |
| writingmode: 'writingMode', | |
| 'writing-mode': 'writingMode', | |
| x1: 'x1', | |
| x2: 'x2', | |
| x: 'x', | |
| xchannelselector: 'xChannelSelector', | |
| xheight: 'xHeight', | |
| 'x-height': 'xHeight', | |
| xlinkactuate: 'xlinkActuate', | |
| 'xlink:actuate': 'xlinkActuate', | |
| xlinkarcrole: 'xlinkArcrole', | |
| 'xlink:arcrole': 'xlinkArcrole', | |
| xlinkhref: 'xlinkHref', | |
| 'xlink:href': 'xlinkHref', | |
| xlinkrole: 'xlinkRole', | |
| 'xlink:role': 'xlinkRole', | |
| xlinkshow: 'xlinkShow', | |
| 'xlink:show': 'xlinkShow', | |
| xlinktitle: 'xlinkTitle', | |
| 'xlink:title': 'xlinkTitle', | |
| xlinktype: 'xlinkType', | |
| 'xlink:type': 'xlinkType', | |
| xmlbase: 'xmlBase', | |
| 'xml:base': 'xmlBase', | |
| xmllang: 'xmlLang', | |
| 'xml:lang': 'xmlLang', | |
| xmlns: 'xmlns', | |
| 'xml:space': 'xmlSpace', | |
| xmlnsxlink: 'xmlnsXlink', | |
| 'xmlns:xlink': 'xmlnsXlink', | |
| xmlspace: 'xmlSpace', | |
| y1: 'y1', | |
| y2: 'y2', | |
| y: 'y', | |
| ychannelselector: 'yChannelSelector', | |
| z: 'z', | |
| zoomandpan: 'zoomAndPan' | |
| }; | |
| var ariaProperties = { | |
| 'aria-current': 0, | |
| // state | |
| 'aria-details': 0, | |
| 'aria-disabled': 0, | |
| // state | |
| 'aria-hidden': 0, | |
| // state | |
| 'aria-invalid': 0, | |
| // state | |
| 'aria-keyshortcuts': 0, | |
| 'aria-label': 0, | |
| 'aria-roledescription': 0, | |
| // Widget Attributes | |
| 'aria-autocomplete': 0, | |
| 'aria-checked': 0, | |
| 'aria-expanded': 0, | |
| 'aria-haspopup': 0, | |
| 'aria-level': 0, | |
| 'aria-modal': 0, | |
| 'aria-multiline': 0, | |
| 'aria-multiselectable': 0, | |
| 'aria-orientation': 0, | |
| 'aria-placeholder': 0, | |
| 'aria-pressed': 0, | |
| 'aria-readonly': 0, | |
| 'aria-required': 0, | |
| 'aria-selected': 0, | |
| 'aria-sort': 0, | |
| 'aria-valuemax': 0, | |
| 'aria-valuemin': 0, | |
| 'aria-valuenow': 0, | |
| 'aria-valuetext': 0, | |
| // Live Region Attributes | |
| 'aria-atomic': 0, | |
| 'aria-busy': 0, | |
| 'aria-live': 0, | |
| 'aria-relevant': 0, | |
| // Drag-and-Drop Attributes | |
| 'aria-dropeffect': 0, | |
| 'aria-grabbed': 0, | |
| // Relationship Attributes | |
| 'aria-activedescendant': 0, | |
| 'aria-colcount': 0, | |
| 'aria-colindex': 0, | |
| 'aria-colspan': 0, | |
| 'aria-controls': 0, | |
| 'aria-describedby': 0, | |
| 'aria-errormessage': 0, | |
| 'aria-flowto': 0, | |
| 'aria-labelledby': 0, | |
| 'aria-owns': 0, | |
| 'aria-posinset': 0, | |
| 'aria-rowcount': 0, | |
| 'aria-rowindex': 0, | |
| 'aria-rowspan': 0, | |
| 'aria-setsize': 0 | |
| }; | |
| var warnedProperties = {}; | |
| var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'); | |
| var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$'); | |
| var hasOwnProperty$1 = Object.prototype.hasOwnProperty; | |
| function validateProperty(tagName, name) { | |
| { | |
| if (hasOwnProperty$1.call(warnedProperties, name) && warnedProperties[name]) { | |
| return true; | |
| } | |
| if (rARIACamel.test(name)) { | |
| var ariaName = 'aria-' + name.slice(4).toLowerCase(); | |
| var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null; // If this is an aria-* attribute, but is not listed in the known DOM | |
| // DOM properties, then it is an invalid aria-* attribute. | |
| if (correctName == null) { | |
| error('Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.', name); | |
| warnedProperties[name] = true; | |
| return true; | |
| } // aria-* attributes should be lowercase; suggest the lowercase version. | |
| if (name !== correctName) { | |
| error('Invalid ARIA attribute `%s`. Did you mean `%s`?', name, correctName); | |
| warnedProperties[name] = true; | |
| return true; | |
| } | |
| } | |
| if (rARIA.test(name)) { | |
| var lowerCasedName = name.toLowerCase(); | |
| var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null; // If this is an aria-* attribute, but is not listed in the known DOM | |
| // DOM properties, then it is an invalid aria-* attribute. | |
| if (standardName == null) { | |
| warnedProperties[name] = true; | |
| return false; | |
| } // aria-* attributes should be lowercase; suggest the lowercase version. | |
| if (name !== standardName) { | |
| error('Unknown ARIA attribute `%s`. Did you mean `%s`?', name, standardName); | |
| warnedProperties[name] = true; | |
| return true; | |
| } | |
| } | |
| } | |
| return true; | |
| } | |
| function warnInvalidARIAProps(type, props) { | |
| { | |
| var invalidProps = []; | |
| for (var key in props) { | |
| var isValid = validateProperty(type, key); | |
| if (!isValid) { | |
| invalidProps.push(key); | |
| } | |
| } | |
| var unknownPropString = invalidProps.map(function (prop) { | |
| return '`' + prop + '`'; | |
| }).join(', '); | |
| if (invalidProps.length === 1) { | |
| error('Invalid aria prop %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type); | |
| } else if (invalidProps.length > 1) { | |
| error('Invalid aria props %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type); | |
| } | |
| } | |
| } | |
| function validateProperties(type, props) { | |
| if (isCustomComponent(type, props)) { | |
| return; | |
| } | |
| warnInvalidARIAProps(type, props); | |
| } | |
| var didWarnValueNull = false; | |
| function validateProperties$1(type, props) { | |
| { | |
| if (type !== 'input' && type !== 'textarea' && type !== 'select') { | |
| return; | |
| } | |
| if (props != null && props.value === null && !didWarnValueNull) { | |
| didWarnValueNull = true; | |
| if (type === 'select' && props.multiple) { | |
| error('`value` prop on `%s` should not be null. ' + 'Consider using an empty array when `multiple` is set to `true` ' + 'to clear the component or `undefined` for uncontrolled components.', type); | |
| } else { | |
| error('`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.', type); | |
| } | |
| } | |
| } | |
| } | |
| var validateProperty$1 = function () {}; | |
| { | |
| var warnedProperties$1 = {}; | |
| var _hasOwnProperty = Object.prototype.hasOwnProperty; | |
| var EVENT_NAME_REGEX = /^on./; | |
| var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/; | |
| var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'); | |
| var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$'); | |
| validateProperty$1 = function (tagName, name, value, canUseEventSystem) { | |
| if (_hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) { | |
| return true; | |
| } | |
| var lowerCasedName = name.toLowerCase(); | |
| if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') { | |
| error('React uses onFocus and onBlur instead of onFocusIn and onFocusOut. ' + 'All React events are normalized to bubble, so onFocusIn and onFocusOut ' + 'are not needed/supported by React.'); | |
| warnedProperties$1[name] = true; | |
| return true; | |
| } // We can't rely on the event system being injected on the server. | |
| if (canUseEventSystem) { | |
| if (registrationNameModules.hasOwnProperty(name)) { | |
| return true; | |
| } | |
| var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null; | |
| if (registrationName != null) { | |
| error('Invalid event handler property `%s`. Did you mean `%s`?', name, registrationName); | |
| warnedProperties$1[name] = true; | |
| return true; | |
| } | |
| if (EVENT_NAME_REGEX.test(name)) { | |
| error('Unknown event handler property `%s`. It will be ignored.', name); | |
| warnedProperties$1[name] = true; | |
| return true; | |
| } | |
| } else if (EVENT_NAME_REGEX.test(name)) { | |
| // If no event plugins have been injected, we are in a server environment. | |
| // So we can't tell if the event name is correct for sure, but we can filter | |
| // out known bad ones like `onclick`. We can't suggest a specific replacement though. | |
| if (INVALID_EVENT_NAME_REGEX.test(name)) { | |
| error('Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.', name); | |
| } | |
| warnedProperties$1[name] = true; | |
| return true; | |
| } // Let the ARIA attribute hook validate ARIA attributes | |
| if (rARIA$1.test(name) || rARIACamel$1.test(name)) { | |
| return true; | |
| } | |
| if (lowerCasedName === 'innerhtml') { | |
| error('Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.'); | |
| warnedProperties$1[name] = true; | |
| return true; | |
| } | |
| if (lowerCasedName === 'aria') { | |
| error('The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.'); | |
| warnedProperties$1[name] = true; | |
| return true; | |
| } | |
| if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') { | |
| error('Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.', typeof value); | |
| warnedProperties$1[name] = true; | |
| return true; | |
| } | |
| if (typeof value === 'number' && isNaN(value)) { | |
| error('Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.', name); | |
| warnedProperties$1[name] = true; | |
| return true; | |
| } | |
| var propertyInfo = getPropertyInfo(name); | |
| var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED; // Known attributes should match the casing specified in the property config. | |
| if (possibleStandardNames.hasOwnProperty(lowerCasedName)) { | |
| var standardName = possibleStandardNames[lowerCasedName]; | |
| if (standardName !== name) { | |
| error('Invalid DOM property `%s`. Did you mean `%s`?', name, standardName); | |
| warnedProperties$1[name] = true; | |
| return true; | |
| } | |
| } else if (!isReserved && name !== lowerCasedName) { | |
| // Unknown attributes should have lowercase casing since that's how they | |
| // will be cased anyway with server rendering. | |
| error('React does not recognize the `%s` prop on a DOM element. If you ' + 'intentionally want it to appear in the DOM as a custom ' + 'attribute, spell it as lowercase `%s` instead. ' + 'If you accidentally passed it from a parent component, remove ' + 'it from the DOM element.', name, lowerCasedName); | |
| warnedProperties$1[name] = true; | |
| return true; | |
| } | |
| if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) { | |
| if (value) { | |
| error('Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.', value, name, name, value, name); | |
| } else { | |
| error('Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.', value, name, name, value, name, name, name); | |
| } | |
| warnedProperties$1[name] = true; | |
| return true; | |
| } // Now that we've validated casing, do not validate | |
| // data types for reserved props | |
| if (isReserved) { | |
| return true; | |
| } // Warn when a known attribute is a bad type | |
| if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) { | |
| warnedProperties$1[name] = true; | |
| return false; | |
| } // Warn when passing the strings 'false' or 'true' into a boolean prop | |
| if ((value === 'false' || value === 'true') && propertyInfo !== null && propertyInfo.type === BOOLEAN) { | |
| error('Received the string `%s` for the boolean attribute `%s`. ' + '%s ' + 'Did you mean %s={%s}?', value, name, value === 'false' ? 'The browser will interpret it as a truthy value.' : 'Although this works, it will not work as expected if you pass the string "false".', name, value); | |
| warnedProperties$1[name] = true; | |
| return true; | |
| } | |
| return true; | |
| }; | |
| } | |
| var warnUnknownProperties = function (type, props, canUseEventSystem) { | |
| { | |
| var unknownProps = []; | |
| for (var key in props) { | |
| var isValid = validateProperty$1(type, key, props[key], canUseEventSystem); | |
| if (!isValid) { | |
| unknownProps.push(key); | |
| } | |
| } | |
| var unknownPropString = unknownProps.map(function (prop) { | |
| return '`' + prop + '`'; | |
| }).join(', '); | |
| if (unknownProps.length === 1) { | |
| error('Invalid value for prop %s on <%s> tag. Either remove it from the element, ' + 'or pass a string or number value to keep it in the DOM. ' + 'For details, see https://fb.me/react-attribute-behavior', unknownPropString, type); | |
| } else if (unknownProps.length > 1) { | |
| error('Invalid values for props %s on <%s> tag. Either remove them from the element, ' + 'or pass a string or number value to keep them in the DOM. ' + 'For details, see https://fb.me/react-attribute-behavior', unknownPropString, type); | |
| } | |
| } | |
| }; | |
| function validateProperties$2(type, props, canUseEventSystem) { | |
| if (isCustomComponent(type, props)) { | |
| return; | |
| } | |
| warnUnknownProperties(type, props, canUseEventSystem); | |
| } | |
| var didWarnInvalidHydration = false; | |
| var DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML'; | |
| var SUPPRESS_CONTENT_EDITABLE_WARNING = 'suppressContentEditableWarning'; | |
| var SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning'; | |
| var AUTOFOCUS = 'autoFocus'; | |
| var CHILDREN = 'children'; | |
| var STYLE = 'style'; | |
| var HTML$1 = '__html'; | |
| var HTML_NAMESPACE$1 = Namespaces.html; | |
| var warnedUnknownTags; | |
| var suppressHydrationWarning; | |
| var validatePropertiesInDevelopment; | |
| var warnForTextDifference; | |
| var warnForPropDifference; | |
| var warnForExtraAttributes; | |
| var warnForInvalidEventListener; | |
| var canDiffStyleForHydrationWarning; | |
| var normalizeMarkupForTextOrAttribute; | |
| var normalizeHTML; | |
| { | |
| warnedUnknownTags = { | |
| // Chrome is the only major browser not shipping <time>. But as of July | |
| // 2017 it intends to ship it due to widespread usage. We intentionally | |
| // *don't* warn for <time> even if it's unrecognized by Chrome because | |
| // it soon will be, and many apps have been using it anyway. | |
| time: true, | |
| // There are working polyfills for <dialog>. Let people use it. | |
| dialog: true, | |
| // Electron ships a custom <webview> tag to display external web content in | |
| // an isolated frame and process. | |
| // This tag is not present in non Electron environments such as JSDom which | |
| // is often used for testing purposes. | |
| // @see https://electronjs.org/docs/api/webview-tag | |
| webview: true | |
| }; | |
| validatePropertiesInDevelopment = function (type, props) { | |
| validateProperties(type, props); | |
| validateProperties$1(type, props); | |
| validateProperties$2(type, props, | |
| /* canUseEventSystem */ | |
| true); | |
| }; // IE 11 parses & normalizes the style attribute as opposed to other | |
| // browsers. It adds spaces and sorts the properties in some | |
| // non-alphabetical order. Handling that would require sorting CSS | |
| // properties in the client & server versions or applying | |
| // `expectedStyle` to a temporary DOM node to read its `style` attribute | |
| // normalized. Since it only affects IE, we're skipping style warnings | |
| // in that browser completely in favor of doing all that work. | |
| // See https://github.com/facebook/react/issues/11807 | |
| canDiffStyleForHydrationWarning = canUseDOM && !document.documentMode; // HTML parsing normalizes CR and CRLF to LF. | |
| // It also can turn \u0000 into \uFFFD inside attributes. | |
| // https://www.w3.org/TR/html5/single-page.html#preprocessing-the-input-stream | |
| // If we have a mismatch, it might be caused by that. | |
| // We will still patch up in this case but not fire the warning. | |
| var NORMALIZE_NEWLINES_REGEX = /\r\n?/g; | |
| var NORMALIZE_NULL_AND_REPLACEMENT_REGEX = /\u0000|\uFFFD/g; | |
| normalizeMarkupForTextOrAttribute = function (markup) { | |
| var markupString = typeof markup === 'string' ? markup : '' + markup; | |
| return markupString.replace(NORMALIZE_NEWLINES_REGEX, '\n').replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, ''); | |
| }; | |
| warnForTextDifference = function (serverText, clientText) { | |
| if (didWarnInvalidHydration) { | |
| return; | |
| } | |
| var normalizedClientText = normalizeMarkupForTextOrAttribute(clientText); | |
| var normalizedServerText = normalizeMarkupForTextOrAttribute(serverText); | |
| if (normalizedServerText === normalizedClientText) { | |
| return; | |
| } | |
| didWarnInvalidHydration = true; | |
| error('Text content did not match. Server: "%s" Client: "%s"', normalizedServerText, normalizedClientText); | |
| }; | |
| warnForPropDifference = function (propName, serverValue, clientValue) { | |
| if (didWarnInvalidHydration) { | |
| return; | |
| } | |
| var normalizedClientValue = normalizeMarkupForTextOrAttribute(clientValue); | |
| var normalizedServerValue = normalizeMarkupForTextOrAttribute(serverValue); | |
| if (normalizedServerValue === normalizedClientValue) { | |
| return; | |
| } | |
| didWarnInvalidHydration = true; | |
| error('Prop `%s` did not match. Server: %s Client: %s', propName, JSON.stringify(normalizedServerValue), JSON.stringify(normalizedClientValue)); | |
| }; | |
| warnForExtraAttributes = function (attributeNames) { | |
| if (didWarnInvalidHydration) { | |
| return; | |
| } | |
| didWarnInvalidHydration = true; | |
| var names = []; | |
| attributeNames.forEach(function (name) { | |
| names.push(name); | |
| }); | |
| error('Extra attributes from the server: %s', names); | |
| }; | |
| warnForInvalidEventListener = function (registrationName, listener) { | |
| if (listener === false) { | |
| error('Expected `%s` listener to be a function, instead got `false`.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.', registrationName, registrationName, registrationName); | |
| } else { | |
| error('Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener); | |
| } | |
| }; // Parse the HTML and read it back to normalize the HTML string so that it | |
| // can be used for comparison. | |
| normalizeHTML = function (parent, html) { | |
| // We could have created a separate document here to avoid | |
| // re-initializing custom elements if they exist. But this breaks | |
| // how <noscript> is being handled. So we use the same document. | |
| // See the discussion in https://github.com/facebook/react/pull/11157. | |
| var testElement = parent.namespaceURI === HTML_NAMESPACE$1 ? parent.ownerDocument.createElement(parent.tagName) : parent.ownerDocument.createElementNS(parent.namespaceURI, parent.tagName); | |
| testElement.innerHTML = html; | |
| return testElement.innerHTML; | |
| }; | |
| } | |
| function ensureListeningTo(rootContainerElement, registrationName) { | |
| var isDocumentOrFragment = rootContainerElement.nodeType === DOCUMENT_NODE || rootContainerElement.nodeType === DOCUMENT_FRAGMENT_NODE; | |
| var doc = isDocumentOrFragment ? rootContainerElement : rootContainerElement.ownerDocument; | |
| legacyListenToEvent(registrationName, doc); | |
| } | |
| function getOwnerDocumentFromRootContainer(rootContainerElement) { | |
| return rootContainerElement.nodeType === DOCUMENT_NODE ? rootContainerElement : rootContainerElement.ownerDocument; | |
| } | |
| function noop() {} | |
| function trapClickOnNonInteractiveElement(node) { | |
| // Mobile Safari does not fire properly bubble click events on | |
| // non-interactive elements, which means delegated click listeners do not | |
| // fire. The workaround for this bug involves attaching an empty click | |
| // listener on the target node. | |
| // http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html | |
| // Just set it using the onclick property so that we don't have to manage any | |
| // bookkeeping for it. Not sure if we need to clear it when the listener is | |
| // removed. | |
| // TODO: Only do this for the relevant Safaris maybe? | |
| node.onclick = noop; | |
| } | |
| function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) { | |
| for (var propKey in nextProps) { | |
| if (!nextProps.hasOwnProperty(propKey)) { | |
| continue; | |
| } | |
| var nextProp = nextProps[propKey]; | |
| if (propKey === STYLE) { | |
| { | |
| if (nextProp) { | |
| // Freeze the next style object so that we can assume it won't be | |
| // mutated. We have already warned for this in the past. | |
| Object.freeze(nextProp); | |
| } | |
| } // Relies on `updateStylesByID` not mutating `styleUpdates`. | |
| setValueForStyles(domElement, nextProp); | |
| } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { | |
| var nextHtml = nextProp ? nextProp[HTML$1] : undefined; | |
| if (nextHtml != null) { | |
| setInnerHTML(domElement, nextHtml); | |
| } | |
| } else if (propKey === CHILDREN) { | |
| if (typeof nextProp === 'string') { | |
| // Avoid setting initial textContent when the text is empty. In IE11 setting | |
| // textContent on a <textarea> will cause the placeholder to not | |
| // show within the <textarea> until it has been focused and blurred again. | |
| // https://github.com/facebook/react/issues/6731#issuecomment-254874553 | |
| var canSetTextContent = tag !== 'textarea' || nextProp !== ''; | |
| if (canSetTextContent) { | |
| setTextContent(domElement, nextProp); | |
| } | |
| } else if (typeof nextProp === 'number') { | |
| setTextContent(domElement, '' + nextProp); | |
| } | |
| } else if ( propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (propKey === AUTOFOCUS) ; else if (registrationNameModules.hasOwnProperty(propKey)) { | |
| if (nextProp != null) { | |
| if ( typeof nextProp !== 'function') { | |
| warnForInvalidEventListener(propKey, nextProp); | |
| } | |
| ensureListeningTo(rootContainerElement, propKey); | |
| } | |
| } else if (nextProp != null) { | |
| setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag); | |
| } | |
| } | |
| } | |
| function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) { | |
| // TODO: Handle wasCustomComponentTag | |
| for (var i = 0; i < updatePayload.length; i += 2) { | |
| var propKey = updatePayload[i]; | |
| var propValue = updatePayload[i + 1]; | |
| if (propKey === STYLE) { | |
| setValueForStyles(domElement, propValue); | |
| } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { | |
| setInnerHTML(domElement, propValue); | |
| } else if (propKey === CHILDREN) { | |
| setTextContent(domElement, propValue); | |
| } else { | |
| setValueForProperty(domElement, propKey, propValue, isCustomComponentTag); | |
| } | |
| } | |
| } | |
| function createElement(type, props, rootContainerElement, parentNamespace) { | |
| var isCustomComponentTag; // We create tags in the namespace of their parent container, except HTML | |
| // tags get no namespace. | |
| var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement); | |
| var domElement; | |
| var namespaceURI = parentNamespace; | |
| if (namespaceURI === HTML_NAMESPACE$1) { | |
| namespaceURI = getIntrinsicNamespace(type); | |
| } | |
| if (namespaceURI === HTML_NAMESPACE$1) { | |
| { | |
| isCustomComponentTag = isCustomComponent(type, props); // Should this check be gated by parent namespace? Not sure we want to | |
| // allow <SVG> or <mATH>. | |
| if (!isCustomComponentTag && type !== type.toLowerCase()) { | |
| error('<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', type); | |
| } | |
| } | |
| if (type === 'script') { | |
| // Create the script via .innerHTML so its "parser-inserted" flag is | |
| // set to true and it does not execute | |
| var div = ownerDocument.createElement('div'); | |
| div.innerHTML = '<script><' + '/script>'; // eslint-disable-line | |
| // This is guaranteed to yield a script element. | |
| var firstChild = div.firstChild; | |
| domElement = div.removeChild(firstChild); | |
| } else if (typeof props.is === 'string') { | |
| // $FlowIssue `createElement` should be updated for Web Components | |
| domElement = ownerDocument.createElement(type, { | |
| is: props.is | |
| }); | |
| } else { | |
| // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug. | |
| // See discussion in https://github.com/facebook/react/pull/6896 | |
| // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240 | |
| domElement = ownerDocument.createElement(type); // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple` and `size` | |
| // attributes on `select`s needs to be added before `option`s are inserted. | |
| // This prevents: | |
| // - a bug where the `select` does not scroll to the correct option because singular | |
| // `select` elements automatically pick the first item #13222 | |
| // - a bug where the `select` set the first item as selected despite the `size` attribute #14239 | |
| // See https://github.com/facebook/react/issues/13222 | |
| // and https://github.com/facebook/react/issues/14239 | |
| if (type === 'select') { | |
| var node = domElement; | |
| if (props.multiple) { | |
| node.multiple = true; | |
| } else if (props.size) { | |
| // Setting a size greater than 1 causes a select to behave like `multiple=true`, where | |
| // it is possible that no option is selected. | |
| // | |
| // This is only necessary when a select in "single selection mode". | |
| node.size = props.size; | |
| } | |
| } | |
| } | |
| } else { | |
| domElement = ownerDocument.createElementNS(namespaceURI, type); | |
| } | |
| { | |
| if (namespaceURI === HTML_NAMESPACE$1) { | |
| if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) { | |
| warnedUnknownTags[type] = true; | |
| error('The tag <%s> is unrecognized in this browser. ' + 'If you meant to render a React component, start its name with ' + 'an uppercase letter.', type); | |
| } | |
| } | |
| } | |
| return domElement; | |
| } | |
| function createTextNode(text, rootContainerElement) { | |
| return getOwnerDocumentFromRootContainer(rootContainerElement).createTextNode(text); | |
| } | |
| function setInitialProperties(domElement, tag, rawProps, rootContainerElement) { | |
| var isCustomComponentTag = isCustomComponent(tag, rawProps); | |
| { | |
| validatePropertiesInDevelopment(tag, rawProps); | |
| } // TODO: Make sure that we check isMounted before firing any of these events. | |
| var props; | |
| switch (tag) { | |
| case 'iframe': | |
| case 'object': | |
| case 'embed': | |
| trapBubbledEvent(TOP_LOAD, domElement); | |
| props = rawProps; | |
| break; | |
| case 'video': | |
| case 'audio': | |
| // Create listener for each media event | |
| for (var i = 0; i < mediaEventTypes.length; i++) { | |
| trapBubbledEvent(mediaEventTypes[i], domElement); | |
| } | |
| props = rawProps; | |
| break; | |
| case 'source': | |
| trapBubbledEvent(TOP_ERROR, domElement); | |
| props = rawProps; | |
| break; | |
| case 'img': | |
| case 'image': | |
| case 'link': | |
| trapBubbledEvent(TOP_ERROR, domElement); | |
| trapBubbledEvent(TOP_LOAD, domElement); | |
| props = rawProps; | |
| break; | |
| case 'form': | |
| trapBubbledEvent(TOP_RESET, domElement); | |
| trapBubbledEvent(TOP_SUBMIT, domElement); | |
| props = rawProps; | |
| break; | |
| case 'details': | |
| trapBubbledEvent(TOP_TOGGLE, domElement); | |
| props = rawProps; | |
| break; | |
| case 'input': | |
| initWrapperState(domElement, rawProps); | |
| props = getHostProps(domElement, rawProps); | |
| trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening | |
| // to onChange. Even if there is no listener. | |
| ensureListeningTo(rootContainerElement, 'onChange'); | |
| break; | |
| case 'option': | |
| validateProps(domElement, rawProps); | |
| props = getHostProps$1(domElement, rawProps); | |
| break; | |
| case 'select': | |
| initWrapperState$1(domElement, rawProps); | |
| props = getHostProps$2(domElement, rawProps); | |
| trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening | |
| // to onChange. Even if there is no listener. | |
| ensureListeningTo(rootContainerElement, 'onChange'); | |
| break; | |
| case 'textarea': | |
| initWrapperState$2(domElement, rawProps); | |
| props = getHostProps$3(domElement, rawProps); | |
| trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening | |
| // to onChange. Even if there is no listener. | |
| ensureListeningTo(rootContainerElement, 'onChange'); | |
| break; | |
| default: | |
| props = rawProps; | |
| } | |
| assertValidProps(tag, props); | |
| setInitialDOMProperties(tag, domElement, rootContainerElement, props, isCustomComponentTag); | |
| switch (tag) { | |
| case 'input': | |
| // TODO: Make sure we check if this is still unmounted or do any clean | |
| // up necessary since we never stop tracking anymore. | |
| track(domElement); | |
| postMountWrapper(domElement, rawProps, false); | |
| break; | |
| case 'textarea': | |
| // TODO: Make sure we check if this is still unmounted or do any clean | |
| // up necessary since we never stop tracking anymore. | |
| track(domElement); | |
| postMountWrapper$3(domElement); | |
| break; | |
| case 'option': | |
| postMountWrapper$1(domElement, rawProps); | |
| break; | |
| case 'select': | |
| postMountWrapper$2(domElement, rawProps); | |
| break; | |
| default: | |
| if (typeof props.onClick === 'function') { | |
| // TODO: This cast may not be sound for SVG, MathML or custom elements. | |
| trapClickOnNonInteractiveElement(domElement); | |
| } | |
| break; | |
| } | |
| } // Calculate the diff between the two objects. | |
| function diffProperties(domElement, tag, lastRawProps, nextRawProps, rootContainerElement) { | |
| { | |
| validatePropertiesInDevelopment(tag, nextRawProps); | |
| } | |
| var updatePayload = null; | |
| var lastProps; | |
| var nextProps; | |
| switch (tag) { | |
| case 'input': | |
| lastProps = getHostProps(domElement, lastRawProps); | |
| nextProps = getHostProps(domElement, nextRawProps); | |
| updatePayload = []; | |
| break; | |
| case 'option': | |
| lastProps = getHostProps$1(domElement, lastRawProps); | |
| nextProps = getHostProps$1(domElement, nextRawProps); | |
| updatePayload = []; | |
| break; | |
| case 'select': | |
| lastProps = getHostProps$2(domElement, lastRawProps); | |
| nextProps = getHostProps$2(domElement, nextRawProps); | |
| updatePayload = []; | |
| break; | |
| case 'textarea': | |
| lastProps = getHostProps$3(domElement, lastRawProps); | |
| nextProps = getHostProps$3(domElement, nextRawProps); | |
| updatePayload = []; | |
| break; | |
| default: | |
| lastProps = lastRawProps; | |
| nextProps = nextRawProps; | |
| if (typeof lastProps.onClick !== 'function' && typeof nextProps.onClick === 'function') { | |
| // TODO: This cast may not be sound for SVG, MathML or custom elements. | |
| trapClickOnNonInteractiveElement(domElement); | |
| } | |
| break; | |
| } | |
| assertValidProps(tag, nextProps); | |
| var propKey; | |
| var styleName; | |
| var styleUpdates = null; | |
| for (propKey in lastProps) { | |
| if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) { | |
| continue; | |
| } | |
| if (propKey === STYLE) { | |
| var lastStyle = lastProps[propKey]; | |
| for (styleName in lastStyle) { | |
| if (lastStyle.hasOwnProperty(styleName)) { | |
| if (!styleUpdates) { | |
| styleUpdates = {}; | |
| } | |
| styleUpdates[styleName] = ''; | |
| } | |
| } | |
| } else if (propKey === DANGEROUSLY_SET_INNER_HTML || propKey === CHILDREN) ; else if ( propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (propKey === AUTOFOCUS) ; else if (registrationNameModules.hasOwnProperty(propKey)) { | |
| // This is a special case. If any listener updates we need to ensure | |
| // that the "current" fiber pointer gets updated so we need a commit | |
| // to update this element. | |
| if (!updatePayload) { | |
| updatePayload = []; | |
| } | |
| } else { | |
| // For all other deleted properties we add it to the queue. We use | |
| // the whitelist in the commit phase instead. | |
| (updatePayload = updatePayload || []).push(propKey, null); | |
| } | |
| } | |
| for (propKey in nextProps) { | |
| var nextProp = nextProps[propKey]; | |
| var lastProp = lastProps != null ? lastProps[propKey] : undefined; | |
| if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) { | |
| continue; | |
| } | |
| if (propKey === STYLE) { | |
| { | |
| if (nextProp) { | |
| // Freeze the next style object so that we can assume it won't be | |
| // mutated. We have already warned for this in the past. | |
| Object.freeze(nextProp); | |
| } | |
| } | |
| if (lastProp) { | |
| // Unset styles on `lastProp` but not on `nextProp`. | |
| for (styleName in lastProp) { | |
| if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) { | |
| if (!styleUpdates) { | |
| styleUpdates = {}; | |
| } | |
| styleUpdates[styleName] = ''; | |
| } | |
| } // Update styles that changed since `lastProp`. | |
| for (styleName in nextProp) { | |
| if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) { | |
| if (!styleUpdates) { | |
| styleUpdates = {}; | |
| } | |
| styleUpdates[styleName] = nextProp[styleName]; | |
| } | |
| } | |
| } else { | |
| // Relies on `updateStylesByID` not mutating `styleUpdates`. | |
| if (!styleUpdates) { | |
| if (!updatePayload) { | |
| updatePayload = []; | |
| } | |
| updatePayload.push(propKey, styleUpdates); | |
| } | |
| styleUpdates = nextProp; | |
| } | |
| } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { | |
| var nextHtml = nextProp ? nextProp[HTML$1] : undefined; | |
| var lastHtml = lastProp ? lastProp[HTML$1] : undefined; | |
| if (nextHtml != null) { | |
| if (lastHtml !== nextHtml) { | |
| (updatePayload = updatePayload || []).push(propKey, nextHtml); | |
| } | |
| } | |
| } else if (propKey === CHILDREN) { | |
| if (lastProp !== nextProp && (typeof nextProp === 'string' || typeof nextProp === 'number')) { | |
| (updatePayload = updatePayload || []).push(propKey, '' + nextProp); | |
| } | |
| } else if ( propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (registrationNameModules.hasOwnProperty(propKey)) { | |
| if (nextProp != null) { | |
| // We eagerly listen to this even though we haven't committed yet. | |
| if ( typeof nextProp !== 'function') { | |
| warnForInvalidEventListener(propKey, nextProp); | |
| } | |
| ensureListeningTo(rootContainerElement, propKey); | |
| } | |
| if (!updatePayload && lastProp !== nextProp) { | |
| // This is a special case. If any listener updates we need to ensure | |
| // that the "current" props pointer gets updated so we need a commit | |
| // to update this element. | |
| updatePayload = []; | |
| } | |
| } else { | |
| // For any other property we always add it to the queue and then we | |
| // filter it out using the whitelist during the commit. | |
| (updatePayload = updatePayload || []).push(propKey, nextProp); | |
| } | |
| } | |
| if (styleUpdates) { | |
| { | |
| validateShorthandPropertyCollisionInDev(styleUpdates, nextProps[STYLE]); | |
| } | |
| (updatePayload = updatePayload || []).push(STYLE, styleUpdates); | |
| } | |
| return updatePayload; | |
| } // Apply the diff. | |
| function updateProperties(domElement, updatePayload, tag, lastRawProps, nextRawProps) { | |
| // Update checked *before* name. | |
| // In the middle of an update, it is possible to have multiple checked. | |
| // When a checked radio tries to change name, browser makes another radio's checked false. | |
| if (tag === 'input' && nextRawProps.type === 'radio' && nextRawProps.name != null) { | |
| updateChecked(domElement, nextRawProps); | |
| } | |
| var wasCustomComponentTag = isCustomComponent(tag, lastRawProps); | |
| var isCustomComponentTag = isCustomComponent(tag, nextRawProps); // Apply the diff. | |
| updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag); // TODO: Ensure that an update gets scheduled if any of the special props | |
| // changed. | |
| switch (tag) { | |
| case 'input': | |
| // Update the wrapper around inputs *after* updating props. This has to | |
| // happen after `updateDOMProperties`. Otherwise HTML5 input validations | |
| // raise warnings and prevent the new value from being assigned. | |
| updateWrapper(domElement, nextRawProps); | |
| break; | |
| case 'textarea': | |
| updateWrapper$1(domElement, nextRawProps); | |
| break; | |
| case 'select': | |
| // <select> value update needs to occur after <option> children | |
| // reconciliation | |
| postUpdateWrapper(domElement, nextRawProps); | |
| break; | |
| } | |
| } | |
| function getPossibleStandardName(propName) { | |
| { | |
| var lowerCasedName = propName.toLowerCase(); | |
| if (!possibleStandardNames.hasOwnProperty(lowerCasedName)) { | |
| return null; | |
| } | |
| return possibleStandardNames[lowerCasedName] || null; | |
| } | |
| } | |
| function diffHydratedProperties(domElement, tag, rawProps, parentNamespace, rootContainerElement) { | |
| var isCustomComponentTag; | |
| var extraAttributeNames; | |
| { | |
| suppressHydrationWarning = rawProps[SUPPRESS_HYDRATION_WARNING] === true; | |
| isCustomComponentTag = isCustomComponent(tag, rawProps); | |
| validatePropertiesInDevelopment(tag, rawProps); | |
| } // TODO: Make sure that we check isMounted before firing any of these events. | |
| switch (tag) { | |
| case 'iframe': | |
| case 'object': | |
| case 'embed': | |
| trapBubbledEvent(TOP_LOAD, domElement); | |
| break; | |
| case 'video': | |
| case 'audio': | |
| // Create listener for each media event | |
| for (var i = 0; i < mediaEventTypes.length; i++) { | |
| trapBubbledEvent(mediaEventTypes[i], domElement); | |
| } | |
| break; | |
| case 'source': | |
| trapBubbledEvent(TOP_ERROR, domElement); | |
| break; | |
| case 'img': | |
| case 'image': | |
| case 'link': | |
| trapBubbledEvent(TOP_ERROR, domElement); | |
| trapBubbledEvent(TOP_LOAD, domElement); | |
| break; | |
| case 'form': | |
| trapBubbledEvent(TOP_RESET, domElement); | |
| trapBubbledEvent(TOP_SUBMIT, domElement); | |
| break; | |
| case 'details': | |
| trapBubbledEvent(TOP_TOGGLE, domElement); | |
| break; | |
| case 'input': | |
| initWrapperState(domElement, rawProps); | |
| trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening | |
| // to onChange. Even if there is no listener. | |
| ensureListeningTo(rootContainerElement, 'onChange'); | |
| break; | |
| case 'option': | |
| validateProps(domElement, rawProps); | |
| break; | |
| case 'select': | |
| initWrapperState$1(domElement, rawProps); | |
| trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening | |
| // to onChange. Even if there is no listener. | |
| ensureListeningTo(rootContainerElement, 'onChange'); | |
| break; | |
| case 'textarea': | |
| initWrapperState$2(domElement, rawProps); | |
| trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening | |
| // to onChange. Even if there is no listener. | |
| ensureListeningTo(rootContainerElement, 'onChange'); | |
| break; | |
| } | |
| assertValidProps(tag, rawProps); | |
| { | |
| extraAttributeNames = new Set(); | |
| var attributes = domElement.attributes; | |
| for (var _i = 0; _i < attributes.length; _i++) { | |
| var name = attributes[_i].name.toLowerCase(); | |
| switch (name) { | |
| // Built-in SSR attribute is whitelisted | |
| case 'data-reactroot': | |
| break; | |
| // Controlled attributes are not validated | |
| // TODO: Only ignore them on controlled tags. | |
| case 'value': | |
| break; | |
| case 'checked': | |
| break; | |
| case 'selected': | |
| break; | |
| default: | |
| // Intentionally use the original name. | |
| // See discussion in https://github.com/facebook/react/pull/10676. | |
| extraAttributeNames.add(attributes[_i].name); | |
| } | |
| } | |
| } | |
| var updatePayload = null; | |
| for (var propKey in rawProps) { | |
| if (!rawProps.hasOwnProperty(propKey)) { | |
| continue; | |
| } | |
| var nextProp = rawProps[propKey]; | |
| if (propKey === CHILDREN) { | |
| // For text content children we compare against textContent. This | |
| // might match additional HTML that is hidden when we read it using | |
| // textContent. E.g. "foo" will match "f<span>oo</span>" but that still | |
| // satisfies our requirement. Our requirement is not to produce perfect | |
| // HTML and attributes. Ideally we should preserve structure but it's | |
| // ok not to if the visible content is still enough to indicate what | |
| // even listeners these nodes might be wired up to. | |
| // TODO: Warn if there is more than a single textNode as a child. | |
| // TODO: Should we use domElement.firstChild.nodeValue to compare? | |
| if (typeof nextProp === 'string') { | |
| if (domElement.textContent !== nextProp) { | |
| if ( !suppressHydrationWarning) { | |
| warnForTextDifference(domElement.textContent, nextProp); | |
| } | |
| updatePayload = [CHILDREN, nextProp]; | |
| } | |
| } else if (typeof nextProp === 'number') { | |
| if (domElement.textContent !== '' + nextProp) { | |
| if ( !suppressHydrationWarning) { | |
| warnForTextDifference(domElement.textContent, nextProp); | |
| } | |
| updatePayload = [CHILDREN, '' + nextProp]; | |
| } | |
| } | |
| } else if (registrationNameModules.hasOwnProperty(propKey)) { | |
| if (nextProp != null) { | |
| if ( typeof nextProp !== 'function') { | |
| warnForInvalidEventListener(propKey, nextProp); | |
| } | |
| ensureListeningTo(rootContainerElement, propKey); | |
| } | |
| } else if ( // Convince Flow we've calculated it (it's DEV-only in this method.) | |
| typeof isCustomComponentTag === 'boolean') { | |
| // Validate that the properties correspond to their expected values. | |
| var serverValue = void 0; | |
| var propertyInfo = getPropertyInfo(propKey); | |
| if (suppressHydrationWarning) ; else if ( propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING || // Controlled attributes are not validated | |
| // TODO: Only ignore them on controlled tags. | |
| propKey === 'value' || propKey === 'checked' || propKey === 'selected') ; else if (propKey === DANGEROUSLY_SET_INNER_HTML) { | |
| var serverHTML = domElement.innerHTML; | |
| var nextHtml = nextProp ? nextProp[HTML$1] : undefined; | |
| var expectedHTML = normalizeHTML(domElement, nextHtml != null ? nextHtml : ''); | |
| if (expectedHTML !== serverHTML) { | |
| warnForPropDifference(propKey, serverHTML, expectedHTML); | |
| } | |
| } else if (propKey === STYLE) { | |
| // $FlowFixMe - Should be inferred as not undefined. | |
| extraAttributeNames.delete(propKey); | |
| if (canDiffStyleForHydrationWarning) { | |
| var expectedStyle = createDangerousStringForStyles(nextProp); | |
| serverValue = domElement.getAttribute('style'); | |
| if (expectedStyle !== serverValue) { | |
| warnForPropDifference(propKey, serverValue, expectedStyle); | |
| } | |
| } | |
| } else if (isCustomComponentTag) { | |
| // $FlowFixMe - Should be inferred as not undefined. | |
| extraAttributeNames.delete(propKey.toLowerCase()); | |
| serverValue = getValueForAttribute(domElement, propKey, nextProp); | |
| if (nextProp !== serverValue) { | |
| warnForPropDifference(propKey, serverValue, nextProp); | |
| } | |
| } else if (!shouldIgnoreAttribute(propKey, propertyInfo, isCustomComponentTag) && !shouldRemoveAttribute(propKey, nextProp, propertyInfo, isCustomComponentTag)) { | |
| var isMismatchDueToBadCasing = false; | |
| if (propertyInfo !== null) { | |
| // $FlowFixMe - Should be inferred as not undefined. | |
| extraAttributeNames.delete(propertyInfo.attributeName); | |
| serverValue = getValueForProperty(domElement, propKey, nextProp, propertyInfo); | |
| } else { | |
| var ownNamespace = parentNamespace; | |
| if (ownNamespace === HTML_NAMESPACE$1) { | |
| ownNamespace = getIntrinsicNamespace(tag); | |
| } | |
| if (ownNamespace === HTML_NAMESPACE$1) { | |
| // $FlowFixMe - Should be inferred as not undefined. | |
| extraAttributeNames.delete(propKey.toLowerCase()); | |
| } else { | |
| var standardName = getPossibleStandardName(propKey); | |
| if (standardName !== null && standardName !== propKey) { | |
| // If an SVG prop is supplied with bad casing, it will | |
| // be successfully parsed from HTML, but will produce a mismatch | |
| // (and would be incorrectly rendered on the client). | |
| // However, we already warn about bad casing elsewhere. | |
| // So we'll skip the misleading extra mismatch warning in this case. | |
| isMismatchDueToBadCasing = true; // $FlowFixMe - Should be inferred as not undefined. | |
| extraAttributeNames.delete(standardName); | |
| } // $FlowFixMe - Should be inferred as not undefined. | |
| extraAttributeNames.delete(propKey); | |
| } | |
| serverValue = getValueForAttribute(domElement, propKey, nextProp); | |
| } | |
| if (nextProp !== serverValue && !isMismatchDueToBadCasing) { | |
| warnForPropDifference(propKey, serverValue, nextProp); | |
| } | |
| } | |
| } | |
| } | |
| { | |
| // $FlowFixMe - Should be inferred as not undefined. | |
| if (extraAttributeNames.size > 0 && !suppressHydrationWarning) { | |
| // $FlowFixMe - Should be inferred as not undefined. | |
| warnForExtraAttributes(extraAttributeNames); | |
| } | |
| } | |
| switch (tag) { | |
| case 'input': | |
| // TODO: Make sure we check if this is still unmounted or do any clean | |
| // up necessary since we never stop tracking anymore. | |
| track(domElement); | |
| postMountWrapper(domElement, rawProps, true); | |
| break; | |
| case 'textarea': | |
| // TODO: Make sure we check if this is still unmounted or do any clean | |
| // up necessary since we never stop tracking anymore. | |
| track(domElement); | |
| postMountWrapper$3(domElement); | |
| break; | |
| case 'select': | |
| case 'option': | |
| // For input and textarea we current always set the value property at | |
| // post mount to force it to diverge from attributes. However, for | |
| // option and select we don't quite do the same thing and select | |
| // is not resilient to the DOM state changing so we don't do that here. | |
| // TODO: Consider not doing this for input and textarea. | |
| break; | |
| default: | |
| if (typeof rawProps.onClick === 'function') { | |
| // TODO: This cast may not be sound for SVG, MathML or custom elements. | |
| trapClickOnNonInteractiveElement(domElement); | |
| } | |
| break; | |
| } | |
| return updatePayload; | |
| } | |
| function diffHydratedText(textNode, text) { | |
| var isDifferent = textNode.nodeValue !== text; | |
| return isDifferent; | |
| } | |
| function warnForUnmatchedText(textNode, text) { | |
| { | |
| warnForTextDifference(textNode.nodeValue, text); | |
| } | |
| } | |
| function warnForDeletedHydratableElement(parentNode, child) { | |
| { | |
| if (didWarnInvalidHydration) { | |
| return; | |
| } | |
| didWarnInvalidHydration = true; | |
| error('Did not expect server HTML to contain a <%s> in <%s>.', child.nodeName.toLowerCase(), parentNode.nodeName.toLowerCase()); | |
| } | |
| } | |
| function warnForDeletedHydratableText(parentNode, child) { | |
| { | |
| if (didWarnInvalidHydration) { | |
| return; | |
| } | |
| didWarnInvalidHydration = true; | |
| error('Did not expect server HTML to contain the text node "%s" in <%s>.', child.nodeValue, parentNode.nodeName.toLowerCase()); | |
| } | |
| } | |
| function warnForInsertedHydratedElement(parentNode, tag, props) { | |
| { | |
| if (didWarnInvalidHydration) { | |
| return; | |
| } | |
| didWarnInvalidHydration = true; | |
| error('Expected server HTML to contain a matching <%s> in <%s>.', tag, parentNode.nodeName.toLowerCase()); | |
| } | |
| } | |
| function warnForInsertedHydratedText(parentNode, text) { | |
| { | |
| if (text === '') { | |
| // We expect to insert empty text nodes since they're not represented in | |
| // the HTML. | |
| // TODO: Remove this special case if we can just avoid inserting empty | |
| // text nodes. | |
| return; | |
| } | |
| if (didWarnInvalidHydration) { | |
| return; | |
| } | |
| didWarnInvalidHydration = true; | |
| error('Expected server HTML to contain a matching text node for "%s" in <%s>.', text, parentNode.nodeName.toLowerCase()); | |
| } | |
| } | |
| function restoreControlledState$3(domElement, tag, props) { | |
| switch (tag) { | |
| case 'input': | |
| restoreControlledState(domElement, props); | |
| return; | |
| case 'textarea': | |
| restoreControlledState$2(domElement, props); | |
| return; | |
| case 'select': | |
| restoreControlledState$1(domElement, props); | |
| return; | |
| } | |
| } | |
| function getActiveElement(doc) { | |
| doc = doc || (typeof document !== 'undefined' ? document : undefined); | |
| if (typeof doc === 'undefined') { | |
| return null; | |
| } | |
| try { | |
| return doc.activeElement || doc.body; | |
| } catch (e) { | |
| return doc.body; | |
| } | |
| } | |
| /** | |
| * Given any node return the first leaf node without children. | |
| * | |
| * @param {DOMElement|DOMTextNode} node | |
| * @return {DOMElement|DOMTextNode} | |
| */ | |
| function getLeafNode(node) { | |
| while (node && node.firstChild) { | |
| node = node.firstChild; | |
| } | |
| return node; | |
| } | |
| /** | |
| * Get the next sibling within a container. This will walk up the | |
| * DOM if a node's siblings have been exhausted. | |
| * | |
| * @param {DOMElement|DOMTextNode} node | |
| * @return {?DOMElement|DOMTextNode} | |
| */ | |
| function getSiblingNode(node) { | |
| while (node) { | |
| if (node.nextSibling) { | |
| return node.nextSibling; | |
| } | |
| node = node.parentNode; | |
| } | |
| } | |
| /** | |
| * Get object describing the nodes which contain characters at offset. | |
| * | |
| * @param {DOMElement|DOMTextNode} root | |
| * @param {number} offset | |
| * @return {?object} | |
| */ | |
| function getNodeForCharacterOffset(root, offset) { | |
| var node = getLeafNode(root); | |
| var nodeStart = 0; | |
| var nodeEnd = 0; | |
| while (node) { | |
| if (node.nodeType === TEXT_NODE) { | |
| nodeEnd = nodeStart + node.textContent.length; | |
| if (nodeStart <= offset && nodeEnd >= offset) { | |
| return { | |
| node: node, | |
| offset: offset - nodeStart | |
| }; | |
| } | |
| nodeStart = nodeEnd; | |
| } | |
| node = getLeafNode(getSiblingNode(node)); | |
| } | |
| } | |
| /** | |
| * @param {DOMElement} outerNode | |
| * @return {?object} | |
| */ | |
| function getOffsets(outerNode) { | |
| var ownerDocument = outerNode.ownerDocument; | |
| var win = ownerDocument && ownerDocument.defaultView || window; | |
| var selection = win.getSelection && win.getSelection(); | |
| if (!selection || selection.rangeCount === 0) { | |
| return null; | |
| } | |
| var anchorNode = selection.anchorNode, | |
| anchorOffset = selection.anchorOffset, | |
| focusNode = selection.focusNode, | |
| focusOffset = selection.focusOffset; // In Firefox, anchorNode and focusNode can be "anonymous divs", e.g. the | |
| // up/down buttons on an <input type="number">. Anonymous divs do not seem to | |
| // expose properties, triggering a "Permission denied error" if any of its | |
| // properties are accessed. The only seemingly possible way to avoid erroring | |
| // is to access a property that typically works for non-anonymous divs and | |
| // catch any error that may otherwise arise. See | |
| // https://bugzilla.mozilla.org/show_bug.cgi?id=208427 | |
| try { | |
| /* eslint-disable no-unused-expressions */ | |
| anchorNode.nodeType; | |
| focusNode.nodeType; | |
| /* eslint-enable no-unused-expressions */ | |
| } catch (e) { | |
| return null; | |
| } | |
| return getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset); | |
| } | |
| /** | |
| * Returns {start, end} where `start` is the character/codepoint index of | |
| * (anchorNode, anchorOffset) within the textContent of `outerNode`, and | |
| * `end` is the index of (focusNode, focusOffset). | |
| * | |
| * Returns null if you pass in garbage input but we should probably just crash. | |
| * | |
| * Exported only for testing. | |
| */ | |
| function getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset) { | |
| var length = 0; | |
| var start = -1; | |
| var end = -1; | |
| var indexWithinAnchor = 0; | |
| var indexWithinFocus = 0; | |
| var node = outerNode; | |
| var parentNode = null; | |
| outer: while (true) { | |
| var next = null; | |
| while (true) { | |
| if (node === anchorNode && (anchorOffset === 0 || node.nodeType === TEXT_NODE)) { | |
| start = length + anchorOffset; | |
| } | |
| if (node === focusNode && (focusOffset === 0 || node.nodeType === TEXT_NODE)) { | |
| end = length + focusOffset; | |
| } | |
| if (node.nodeType === TEXT_NODE) { | |
| length += node.nodeValue.length; | |
| } | |
| if ((next = node.firstChild) === null) { | |
| break; | |
| } // Moving from `node` to its first child `next`. | |
| parentNode = node; | |
| node = next; | |
| } | |
| while (true) { | |
| if (node === outerNode) { | |
| // If `outerNode` has children, this is always the second time visiting | |
| // it. If it has no children, this is still the first loop, and the only | |
| // valid selection is anchorNode and focusNode both equal to this node | |
| // and both offsets 0, in which case we will have handled above. | |
| break outer; | |
| } | |
| if (parentNode === anchorNode && ++indexWithinAnchor === anchorOffset) { | |
| start = length; | |
| } | |
| if (parentNode === focusNode && ++indexWithinFocus === focusOffset) { | |
| end = length; | |
| } | |
| if ((next = node.nextSibling) !== null) { | |
| break; | |
| } | |
| node = parentNode; | |
| parentNode = node.parentNode; | |
| } // Moving from `node` to its next sibling `next`. | |
| node = next; | |
| } | |
| if (start === -1 || end === -1) { | |
| // This should never happen. (Would happen if the anchor/focus nodes aren't | |
| // actually inside the passed-in node.) | |
| return null; | |
| } | |
| return { | |
| start: start, | |
| end: end | |
| }; | |
| } | |
| /** | |
| * In modern non-IE browsers, we can support both forward and backward | |
| * selections. | |
| * | |
| * Note: IE10+ supports the Selection object, but it does not support | |
| * the `extend` method, which means that even in modern IE, it's not possible | |
| * to programmatically create a backward selection. Thus, for all IE | |
| * versions, we use the old IE API to create our selections. | |
| * | |
| * @param {DOMElement|DOMTextNode} node | |
| * @param {object} offsets | |
| */ | |
| function setOffsets(node, offsets) { | |
| var doc = node.ownerDocument || document; | |
| var win = doc && doc.defaultView || window; // Edge fails with "Object expected" in some scenarios. | |
| // (For instance: TinyMCE editor used in a list component that supports pasting to add more, | |
| // fails when pasting 100+ items) | |
| if (!win.getSelection) { | |
| return; | |
| } | |
| var selection = win.getSelection(); | |
| var length = node.textContent.length; | |
| var start = Math.min(offsets.start, length); | |
| var end = offsets.end === undefined ? start : Math.min(offsets.end, length); // IE 11 uses modern selection, but doesn't support the extend method. | |
| // Flip backward selections, so we can set with a single range. | |
| if (!selection.extend && start > end) { | |
| var temp = end; | |
| end = start; | |
| start = temp; | |
| } | |
| var startMarker = getNodeForCharacterOffset(node, start); | |
| var endMarker = getNodeForCharacterOffset(node, end); | |
| if (startMarker && endMarker) { | |
| if (selection.rangeCount === 1 && selection.anchorNode === startMarker.node && selection.anchorOffset === startMarker.offset && selection.focusNode === endMarker.node && selection.focusOffset === endMarker.offset) { | |
| return; | |
| } | |
| var range = doc.createRange(); | |
| range.setStart(startMarker.node, startMarker.offset); | |
| selection.removeAllRanges(); | |
| if (start > end) { | |
| selection.addRange(range); | |
| selection.extend(endMarker.node, endMarker.offset); | |
| } else { | |
| range.setEnd(endMarker.node, endMarker.offset); | |
| selection.addRange(range); | |
| } | |
| } | |
| } | |
| function isTextNode(node) { | |
| return node && node.nodeType === TEXT_NODE; | |
| } | |
| function containsNode(outerNode, innerNode) { | |
| if (!outerNode || !innerNode) { | |
| return false; | |
| } else if (outerNode === innerNode) { | |
| return true; | |
| } else if (isTextNode(outerNode)) { | |
| return false; | |
| } else if (isTextNode(innerNode)) { | |
| return containsNode(outerNode, innerNode.parentNode); | |
| } else if ('contains' in outerNode) { | |
| return outerNode.contains(innerNode); | |
| } else if (outerNode.compareDocumentPosition) { | |
| return !!(outerNode.compareDocumentPosition(innerNode) & 16); | |
| } else { | |
| return false; | |
| } | |
| } | |
| function isInDocument(node) { | |
| return node && node.ownerDocument && containsNode(node.ownerDocument.documentElement, node); | |
| } | |
| function isSameOriginFrame(iframe) { | |
| try { | |
| // Accessing the contentDocument of a HTMLIframeElement can cause the browser | |
| // to throw, e.g. if it has a cross-origin src attribute. | |
| // Safari will show an error in the console when the access results in "Blocked a frame with origin". e.g: | |
| // iframe.contentDocument.defaultView; | |
| // A safety way is to access one of the cross origin properties: Window or Location | |
| // Which might result in "SecurityError" DOM Exception and it is compatible to Safari. | |
| // https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl | |
| return typeof iframe.contentWindow.location.href === 'string'; | |
| } catch (err) { | |
| return false; | |
| } | |
| } | |
| function getActiveElementDeep() { | |
| var win = window; | |
| var element = getActiveElement(); | |
| while (element instanceof win.HTMLIFrameElement) { | |
| if (isSameOriginFrame(element)) { | |
| win = element.contentWindow; | |
| } else { | |
| return element; | |
| } | |
| element = getActiveElement(win.document); | |
| } | |
| return element; | |
| } | |
| /** | |
| * @ReactInputSelection: React input selection module. Based on Selection.js, | |
| * but modified to be suitable for react and has a couple of bug fixes (doesn't | |
| * assume buttons have range selections allowed). | |
| * Input selection module for React. | |
| */ | |
| /** | |
| * @hasSelectionCapabilities: we get the element types that support selection | |
| * from https://html.spec.whatwg.org/#do-not-apply, looking at `selectionStart` | |
| * and `selectionEnd` rows. | |
| */ | |
| function hasSelectionCapabilities(elem) { | |
| var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); | |
| return nodeName && (nodeName === 'input' && (elem.type === 'text' || elem.type === 'search' || elem.type === 'tel' || elem.type === 'url' || elem.type === 'password') || nodeName === 'textarea' || elem.contentEditable === 'true'); | |
| } | |
| function getSelectionInformation() { | |
| var focusedElem = getActiveElementDeep(); | |
| return { | |
| // Used by Flare | |
| activeElementDetached: null, | |
| focusedElem: focusedElem, | |
| selectionRange: hasSelectionCapabilities(focusedElem) ? getSelection(focusedElem) : null | |
| }; | |
| } | |
| /** | |
| * @restoreSelection: If any selection information was potentially lost, | |
| * restore it. This is useful when performing operations that could remove dom | |
| * nodes and place them back in, resulting in focus being lost. | |
| */ | |
| function restoreSelection(priorSelectionInformation) { | |
| var curFocusedElem = getActiveElementDeep(); | |
| var priorFocusedElem = priorSelectionInformation.focusedElem; | |
| var priorSelectionRange = priorSelectionInformation.selectionRange; | |
| if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) { | |
| if (priorSelectionRange !== null && hasSelectionCapabilities(priorFocusedElem)) { | |
| setSelection(priorFocusedElem, priorSelectionRange); | |
| } // Focusing a node can change the scroll position, which is undesirable | |
| var ancestors = []; | |
| var ancestor = priorFocusedElem; | |
| while (ancestor = ancestor.parentNode) { | |
| if (ancestor.nodeType === ELEMENT_NODE) { | |
| ancestors.push({ | |
| element: ancestor, | |
| left: ancestor.scrollLeft, | |
| top: ancestor.scrollTop | |
| }); | |
| } | |
| } | |
| if (typeof priorFocusedElem.focus === 'function') { | |
| priorFocusedElem.focus(); | |
| } | |
| for (var i = 0; i < ancestors.length; i++) { | |
| var info = ancestors[i]; | |
| info.element.scrollLeft = info.left; | |
| info.element.scrollTop = info.top; | |
| } | |
| } | |
| } | |
| /** | |
| * @getSelection: Gets the selection bounds of a focused textarea, input or | |
| * contentEditable node. | |
| * -@input: Look up selection bounds of this input | |
| * -@return {start: selectionStart, end: selectionEnd} | |
| */ | |
| function getSelection(input) { | |
| var selection; | |
| if ('selectionStart' in input) { | |
| // Modern browser with input or textarea. | |
| selection = { | |
| start: input.selectionStart, | |
| end: input.selectionEnd | |
| }; | |
| } else { | |
| // Content editable or old IE textarea. | |
| selection = getOffsets(input); | |
| } | |
| return selection || { | |
| start: 0, | |
| end: 0 | |
| }; | |
| } | |
| /** | |
| * @setSelection: Sets the selection bounds of a textarea or input and focuses | |
| * the input. | |
| * -@input Set selection bounds of this input or textarea | |
| * -@offsets Object of same form that is returned from get* | |
| */ | |
| function setSelection(input, offsets) { | |
| var start = offsets.start, | |
| end = offsets.end; | |
| if (end === undefined) { | |
| end = start; | |
| } | |
| if ('selectionStart' in input) { | |
| input.selectionStart = start; | |
| input.selectionEnd = Math.min(end, input.value.length); | |
| } else { | |
| setOffsets(input, offsets); | |
| } | |
| } | |
| var validateDOMNesting = function () {}; | |
| var updatedAncestorInfo = function () {}; | |
| { | |
| // This validation code was written based on the HTML5 parsing spec: | |
| // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope | |
| // | |
| // Note: this does not catch all invalid nesting, nor does it try to (as it's | |
| // not clear what practical benefit doing so provides); instead, we warn only | |
| // for cases where the parser will give a parse tree differing from what React | |
| // intended. For example, <b><div></div></b> is invalid but we don't warn | |
| // because it still parses correctly; we do warn for other cases like nested | |
| // <p> tags where the beginning of the second element implicitly closes the | |
| // first, causing a confusing mess. | |
| // https://html.spec.whatwg.org/multipage/syntax.html#special | |
| var specialTags = ['address', 'applet', 'area', 'article', 'aside', 'base', 'basefont', 'bgsound', 'blockquote', 'body', 'br', 'button', 'caption', 'center', 'col', 'colgroup', 'dd', 'details', 'dir', 'div', 'dl', 'dt', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'iframe', 'img', 'input', 'isindex', 'li', 'link', 'listing', 'main', 'marquee', 'menu', 'menuitem', 'meta', 'nav', 'noembed', 'noframes', 'noscript', 'object', 'ol', 'p', 'param', 'plaintext', 'pre', 'script', 'section', 'select', 'source', 'style', 'summary', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'track', 'ul', 'wbr', 'xmp']; // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope | |
| var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template', // https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point | |
| // TODO: Distinguish by namespace here -- for <title>, including it here | |
| // errs on the side of fewer warnings | |
| 'foreignObject', 'desc', 'title']; // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope | |
| var buttonScopeTags = inScopeTags.concat(['button']); // https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags | |
| var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt']; | |
| var emptyAncestorInfo = { | |
| current: null, | |
| formTag: null, | |
| aTagInScope: null, | |
| buttonTagInScope: null, | |
| nobrTagInScope: null, | |
| pTagInButtonScope: null, | |
| listItemTagAutoclosing: null, | |
| dlItemTagAutoclosing: null | |
| }; | |
| updatedAncestorInfo = function (oldInfo, tag) { | |
| var ancestorInfo = _assign({}, oldInfo || emptyAncestorInfo); | |
| var info = { | |
| tag: tag | |
| }; | |
| if (inScopeTags.indexOf(tag) !== -1) { | |
| ancestorInfo.aTagInScope = null; | |
| ancestorInfo.buttonTagInScope = null; | |
| ancestorInfo.nobrTagInScope = null; | |
| } | |
| if (buttonScopeTags.indexOf(tag) !== -1) { | |
| ancestorInfo.pTagInButtonScope = null; | |
| } // See rules for 'li', 'dd', 'dt' start tags in | |
| // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody | |
| if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') { | |
| ancestorInfo.listItemTagAutoclosing = null; | |
| ancestorInfo.dlItemTagAutoclosing = null; | |
| } | |
| ancestorInfo.current = info; | |
| if (tag === 'form') { | |
| ancestorInfo.formTag = info; | |
| } | |
| if (tag === 'a') { | |
| ancestorInfo.aTagInScope = info; | |
| } | |
| if (tag === 'button') { | |
| ancestorInfo.buttonTagInScope = info; | |
| } | |
| if (tag === 'nobr') { | |
| ancestorInfo.nobrTagInScope = info; | |
| } | |
| if (tag === 'p') { | |
| ancestorInfo.pTagInButtonScope = info; | |
| } | |
| if (tag === 'li') { | |
| ancestorInfo.listItemTagAutoclosing = info; | |
| } | |
| if (tag === 'dd' || tag === 'dt') { | |
| ancestorInfo.dlItemTagAutoclosing = info; | |
| } | |
| return ancestorInfo; | |
| }; | |
| /** | |
| * Returns whether | |
| */ | |
| var isTagValidWithParent = function (tag, parentTag) { | |
| // First, let's check if we're in an unusual parsing mode... | |
| switch (parentTag) { | |
| // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect | |
| case 'select': | |
| return tag === 'option' || tag === 'optgroup' || tag === '#text'; | |
| case 'optgroup': | |
| return tag === 'option' || tag === '#text'; | |
| // Strictly speaking, seeing an <option> doesn't mean we're in a <select> | |
| // but | |
| case 'option': | |
| return tag === '#text'; | |
| // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd | |
| // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption | |
| // No special behavior since these rules fall back to "in body" mode for | |
| // all except special table nodes which cause bad parsing behavior anyway. | |
| // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr | |
| case 'tr': | |
| return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template'; | |
| // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody | |
| case 'tbody': | |
| case 'thead': | |
| case 'tfoot': | |
| return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template'; | |
| // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup | |
| case 'colgroup': | |
| return tag === 'col' || tag === 'template'; | |
| // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable | |
| case 'table': | |
| return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template'; | |
| // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead | |
| case 'head': | |
| return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template'; | |
| // https://html.spec.whatwg.org/multipage/semantics.html#the-html-element | |
| case 'html': | |
| return tag === 'head' || tag === 'body' || tag === 'frameset'; | |
| case 'frameset': | |
| return tag === 'frame'; | |
| case '#document': | |
| return tag === 'html'; | |
| } // Probably in the "in body" parsing mode, so we outlaw only tag combos | |
| // where the parsing rules cause implicit opens or closes to be added. | |
| // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody | |
| switch (tag) { | |
| case 'h1': | |
| case 'h2': | |
| case 'h3': | |
| case 'h4': | |
| case 'h5': | |
| case 'h6': | |
| return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6'; | |
| case 'rp': | |
| case 'rt': | |
| return impliedEndTags.indexOf(parentTag) === -1; | |
| case 'body': | |
| case 'caption': | |
| case 'col': | |
| case 'colgroup': | |
| case 'frameset': | |
| case 'frame': | |
| case 'head': | |
| case 'html': | |
| case 'tbody': | |
| case 'td': | |
| case 'tfoot': | |
| case 'th': | |
| case 'thead': | |
| case 'tr': | |
| // These tags are only valid with a few parents that have special child | |
| // parsing rules -- if we're down here, then none of those matched and | |
| // so we allow it only if we don't know what the parent is, as all other | |
| // cases are invalid. | |
| return parentTag == null; | |
| } | |
| return true; | |
| }; | |
| /** | |
| * Returns whether | |
| */ | |
| var findInvalidAncestorForTag = function (tag, ancestorInfo) { | |
| switch (tag) { | |
| case 'address': | |
| case 'article': | |
| case 'aside': | |
| case 'blockquote': | |
| case 'center': | |
| case 'details': | |
| case 'dialog': | |
| case 'dir': | |
| case 'div': | |
| case 'dl': | |
| case 'fieldset': | |
| case 'figcaption': | |
| case 'figure': | |
| case 'footer': | |
| case 'header': | |
| case 'hgroup': | |
| case 'main': | |
| case 'menu': | |
| case 'nav': | |
| case 'ol': | |
| case 'p': | |
| case 'section': | |
| case 'summary': | |
| case 'ul': | |
| case 'pre': | |
| case 'listing': | |
| case 'table': | |
| case 'hr': | |
| case 'xmp': | |
| case 'h1': | |
| case 'h2': | |
| case 'h3': | |
| case 'h4': | |
| case 'h5': | |
| case 'h6': | |
| return ancestorInfo.pTagInButtonScope; | |
| case 'form': | |
| return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope; | |
| case 'li': | |
| return ancestorInfo.listItemTagAutoclosing; | |
| case 'dd': | |
| case 'dt': | |
| return ancestorInfo.dlItemTagAutoclosing; | |
| case 'button': | |
| return ancestorInfo.buttonTagInScope; | |
| case 'a': | |
| // Spec says something about storing a list of markers, but it sounds | |
| // equivalent to this check. | |
| return ancestorInfo.aTagInScope; | |
| case 'nobr': | |
| return ancestorInfo.nobrTagInScope; | |
| } | |
| return null; | |
| }; | |
| var didWarn$1 = {}; | |
| validateDOMNesting = function (childTag, childText, ancestorInfo) { | |
| ancestorInfo = ancestorInfo || emptyAncestorInfo; | |
| var parentInfo = ancestorInfo.current; | |
| var parentTag = parentInfo && parentInfo.tag; | |
| if (childText != null) { | |
| if (childTag != null) { | |
| error('validateDOMNesting: when childText is passed, childTag should be null'); | |
| } | |
| childTag = '#text'; | |
| } | |
| var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo; | |
| var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo); | |
| var invalidParentOrAncestor = invalidParent || invalidAncestor; | |
| if (!invalidParentOrAncestor) { | |
| return; | |
| } | |
| var ancestorTag = invalidParentOrAncestor.tag; | |
| var addendum = getCurrentFiberStackInDev(); | |
| var warnKey = !!invalidParent + '|' + childTag + '|' + ancestorTag + '|' + addendum; | |
| if (didWarn$1[warnKey]) { | |
| return; | |
| } | |
| didWarn$1[warnKey] = true; | |
| var tagDisplayName = childTag; | |
| var whitespaceInfo = ''; | |
| if (childTag === '#text') { | |
| if (/\S/.test(childText)) { | |
| tagDisplayName = 'Text nodes'; | |
| } else { | |
| tagDisplayName = 'Whitespace text nodes'; | |
| whitespaceInfo = " Make sure you don't have any extra whitespace between tags on " + 'each line of your source code.'; | |
| } | |
| } else { | |
| tagDisplayName = '<' + childTag + '>'; | |
| } | |
| if (invalidParent) { | |
| var info = ''; | |
| if (ancestorTag === 'table' && childTag === 'tr') { | |
| info += ' Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated by ' + 'the browser.'; | |
| } | |
| error('validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s', tagDisplayName, ancestorTag, whitespaceInfo, info); | |
| } else { | |
| error('validateDOMNesting(...): %s cannot appear as a descendant of ' + '<%s>.', tagDisplayName, ancestorTag); | |
| } | |
| }; | |
| } | |
| var SUPPRESS_HYDRATION_WARNING$1; | |
| { | |
| SUPPRESS_HYDRATION_WARNING$1 = 'suppressHydrationWarning'; | |
| } | |
| var SUSPENSE_START_DATA = '$'; | |
| var SUSPENSE_END_DATA = '/$'; | |
| var SUSPENSE_PENDING_START_DATA = '$?'; | |
| var SUSPENSE_FALLBACK_START_DATA = '$!'; | |
| var STYLE$1 = 'style'; | |
| var eventsEnabled = null; | |
| var selectionInformation = null; | |
| function shouldAutoFocusHostComponent(type, props) { | |
| switch (type) { | |
| case 'button': | |
| case 'input': | |
| case 'select': | |
| case 'textarea': | |
| return !!props.autoFocus; | |
| } | |
| return false; | |
| } | |
| function getRootHostContext(rootContainerInstance) { | |
| var type; | |
| var namespace; | |
| var nodeType = rootContainerInstance.nodeType; | |
| switch (nodeType) { | |
| case DOCUMENT_NODE: | |
| case DOCUMENT_FRAGMENT_NODE: | |
| { | |
| type = nodeType === DOCUMENT_NODE ? '#document' : '#fragment'; | |
| var root = rootContainerInstance.documentElement; | |
| namespace = root ? root.namespaceURI : getChildNamespace(null, ''); | |
| break; | |
| } | |
| default: | |
| { | |
| var container = nodeType === COMMENT_NODE ? rootContainerInstance.parentNode : rootContainerInstance; | |
| var ownNamespace = container.namespaceURI || null; | |
| type = container.tagName; | |
| namespace = getChildNamespace(ownNamespace, type); | |
| break; | |
| } | |
| } | |
| { | |
| var validatedTag = type.toLowerCase(); | |
| var ancestorInfo = updatedAncestorInfo(null, validatedTag); | |
| return { | |
| namespace: namespace, | |
| ancestorInfo: ancestorInfo | |
| }; | |
| } | |
| } | |
| function getChildHostContext(parentHostContext, type, rootContainerInstance) { | |
| { | |
| var parentHostContextDev = parentHostContext; | |
| var namespace = getChildNamespace(parentHostContextDev.namespace, type); | |
| var ancestorInfo = updatedAncestorInfo(parentHostContextDev.ancestorInfo, type); | |
| return { | |
| namespace: namespace, | |
| ancestorInfo: ancestorInfo | |
| }; | |
| } | |
| } | |
| function getPublicInstance(instance) { | |
| return instance; | |
| } | |
| function prepareForCommit(containerInfo) { | |
| eventsEnabled = isEnabled(); | |
| selectionInformation = getSelectionInformation(); | |
| setEnabled(false); | |
| } | |
| function resetAfterCommit(containerInfo) { | |
| restoreSelection(selectionInformation); | |
| setEnabled(eventsEnabled); | |
| eventsEnabled = null; | |
| selectionInformation = null; | |
| } | |
| function createInstance(type, props, rootContainerInstance, hostContext, internalInstanceHandle) { | |
| var parentNamespace; | |
| { | |
| // TODO: take namespace into account when validating. | |
| var hostContextDev = hostContext; | |
| validateDOMNesting(type, null, hostContextDev.ancestorInfo); | |
| if (typeof props.children === 'string' || typeof props.children === 'number') { | |
| var string = '' + props.children; | |
| var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type); | |
| validateDOMNesting(null, string, ownAncestorInfo); | |
| } | |
| parentNamespace = hostContextDev.namespace; | |
| } | |
| var domElement = createElement(type, props, rootContainerInstance, parentNamespace); | |
| precacheFiberNode(internalInstanceHandle, domElement); | |
| updateFiberProps(domElement, props); | |
| return domElement; | |
| } | |
| function appendInitialChild(parentInstance, child) { | |
| parentInstance.appendChild(child); | |
| } | |
| function finalizeInitialChildren(domElement, type, props, rootContainerInstance, hostContext) { | |
| setInitialProperties(domElement, type, props, rootContainerInstance); | |
| return shouldAutoFocusHostComponent(type, props); | |
| } | |
| function prepareUpdate(domElement, type, oldProps, newProps, rootContainerInstance, hostContext) { | |
| { | |
| var hostContextDev = hostContext; | |
| if (typeof newProps.children !== typeof oldProps.children && (typeof newProps.children === 'string' || typeof newProps.children === 'number')) { | |
| var string = '' + newProps.children; | |
| var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type); | |
| validateDOMNesting(null, string, ownAncestorInfo); | |
| } | |
| } | |
| return diffProperties(domElement, type, oldProps, newProps, rootContainerInstance); | |
| } | |
| function shouldSetTextContent(type, props) { | |
| return type === 'textarea' || type === 'option' || type === 'noscript' || typeof props.children === 'string' || typeof props.children === 'number' || typeof props.dangerouslySetInnerHTML === 'object' && props.dangerouslySetInnerHTML !== null && props.dangerouslySetInnerHTML.__html != null; | |
| } | |
| function shouldDeprioritizeSubtree(type, props) { | |
| return !!props.hidden; | |
| } | |
| function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) { | |
| { | |
| var hostContextDev = hostContext; | |
| validateDOMNesting(null, text, hostContextDev.ancestorInfo); | |
| } | |
| var textNode = createTextNode(text, rootContainerInstance); | |
| precacheFiberNode(internalInstanceHandle, textNode); | |
| return textNode; | |
| } | |
| // if a component just imports ReactDOM (e.g. for findDOMNode). | |
| // Some environments might not have setTimeout or clearTimeout. | |
| var scheduleTimeout = typeof setTimeout === 'function' ? setTimeout : undefined; | |
| var cancelTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined; | |
| var noTimeout = -1; // ------------------- | |
| function commitMount(domElement, type, newProps, internalInstanceHandle) { | |
| // Despite the naming that might imply otherwise, this method only | |
| // fires if there is an `Update` effect scheduled during mounting. | |
| // This happens if `finalizeInitialChildren` returns `true` (which it | |
| // does to implement the `autoFocus` attribute on the client). But | |
| // there are also other cases when this might happen (such as patching | |
| // up text content during hydration mismatch). So we'll check this again. | |
| if (shouldAutoFocusHostComponent(type, newProps)) { | |
| domElement.focus(); | |
| } | |
| } | |
| function commitUpdate(domElement, updatePayload, type, oldProps, newProps, internalInstanceHandle) { | |
| // Update the props handle so that we know which props are the ones with | |
| // with current event handlers. | |
| updateFiberProps(domElement, newProps); // Apply the diff to the DOM node. | |
| updateProperties(domElement, updatePayload, type, oldProps, newProps); | |
| } | |
| function resetTextContent(domElement) { | |
| setTextContent(domElement, ''); | |
| } | |
| function commitTextUpdate(textInstance, oldText, newText) { | |
| textInstance.nodeValue = newText; | |
| } | |
| function appendChild(parentInstance, child) { | |
| parentInstance.appendChild(child); | |
| } | |
| function appendChildToContainer(container, child) { | |
| var parentNode; | |
| if (container.nodeType === COMMENT_NODE) { | |
| parentNode = container.parentNode; | |
| parentNode.insertBefore(child, container); | |
| } else { | |
| parentNode = container; | |
| parentNode.appendChild(child); | |
| } // This container might be used for a portal. | |
| // If something inside a portal is clicked, that click should bubble | |
| // through the React tree. However, on Mobile Safari the click would | |
| // never bubble through the *DOM* tree unless an ancestor with onclick | |
| // event exists. So we wouldn't see it and dispatch it. | |
| // This is why we ensure that non React root containers have inline onclick | |
| // defined. | |
| // https://github.com/facebook/react/issues/11918 | |
| var reactRootContainer = container._reactRootContainer; | |
| if ((reactRootContainer === null || reactRootContainer === undefined) && parentNode.onclick === null) { | |
| // TODO: This cast may not be sound for SVG, MathML or custom elements. | |
| trapClickOnNonInteractiveElement(parentNode); | |
| } | |
| } | |
| function insertBefore(parentInstance, child, beforeChild) { | |
| parentInstance.insertBefore(child, beforeChild); | |
| } | |
| function insertInContainerBefore(container, child, beforeChild) { | |
| if (container.nodeType === COMMENT_NODE) { | |
| container.parentNode.insertBefore(child, beforeChild); | |
| } else { | |
| container.insertBefore(child, beforeChild); | |
| } | |
| } | |
| function removeChild(parentInstance, child) { | |
| parentInstance.removeChild(child); | |
| } | |
| function removeChildFromContainer(container, child) { | |
| if (container.nodeType === COMMENT_NODE) { | |
| container.parentNode.removeChild(child); | |
| } else { | |
| container.removeChild(child); | |
| } | |
| } | |
| function hideInstance(instance) { | |
| // pass host context to this method? | |
| instance = instance; | |
| var style = instance.style; | |
| if (typeof style.setProperty === 'function') { | |
| style.setProperty('display', 'none', 'important'); | |
| } else { | |
| style.display = 'none'; | |
| } | |
| } | |
| function hideTextInstance(textInstance) { | |
| textInstance.nodeValue = ''; | |
| } | |
| function unhideInstance(instance, props) { | |
| instance = instance; | |
| var styleProp = props[STYLE$1]; | |
| var display = styleProp !== undefined && styleProp !== null && styleProp.hasOwnProperty('display') ? styleProp.display : null; | |
| instance.style.display = dangerousStyleValue('display', display); | |
| } | |
| function unhideTextInstance(textInstance, text) { | |
| textInstance.nodeValue = text; | |
| } // ------------------- | |
| function canHydrateInstance(instance, type, props) { | |
| if (instance.nodeType !== ELEMENT_NODE || type.toLowerCase() !== instance.nodeName.toLowerCase()) { | |
| return null; | |
| } // This has now been refined to an element node. | |
| return instance; | |
| } | |
| function canHydrateTextInstance(instance, text) { | |
| if (text === '' || instance.nodeType !== TEXT_NODE) { | |
| // Empty strings are not parsed by HTML so there won't be a correct match here. | |
| return null; | |
| } // This has now been refined to a text node. | |
| return instance; | |
| } | |
| function isSuspenseInstancePending(instance) { | |
| return instance.data === SUSPENSE_PENDING_START_DATA; | |
| } | |
| function isSuspenseInstanceFallback(instance) { | |
| return instance.data === SUSPENSE_FALLBACK_START_DATA; | |
| } | |
| function getNextHydratable(node) { | |
| // Skip non-hydratable nodes. | |
| for (; node != null; node = node.nextSibling) { | |
| var nodeType = node.nodeType; | |
| if (nodeType === ELEMENT_NODE || nodeType === TEXT_NODE) { | |
| break; | |
| } | |
| } | |
| return node; | |
| } | |
| function getNextHydratableSibling(instance) { | |
| return getNextHydratable(instance.nextSibling); | |
| } | |
| function getFirstHydratableChild(parentInstance) { | |
| return getNextHydratable(parentInstance.firstChild); | |
| } | |
| function hydrateInstance(instance, type, props, rootContainerInstance, hostContext, internalInstanceHandle) { | |
| precacheFiberNode(internalInstanceHandle, instance); // TODO: Possibly defer this until the commit phase where all the events | |
| // get attached. | |
| updateFiberProps(instance, props); | |
| var parentNamespace; | |
| { | |
| var hostContextDev = hostContext; | |
| parentNamespace = hostContextDev.namespace; | |
| } | |
| return diffHydratedProperties(instance, type, props, parentNamespace, rootContainerInstance); | |
| } | |
| function hydrateTextInstance(textInstance, text, internalInstanceHandle) { | |
| precacheFiberNode(internalInstanceHandle, textInstance); | |
| return diffHydratedText(textInstance, text); | |
| } | |
| function getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance) { | |
| var node = suspenseInstance.nextSibling; // Skip past all nodes within this suspense boundary. | |
| // There might be nested nodes so we need to keep track of how | |
| // deep we are and only break out when we're back on top. | |
| var depth = 0; | |
| while (node) { | |
| if (node.nodeType === COMMENT_NODE) { | |
| var data = node.data; | |
| if (data === SUSPENSE_END_DATA) { | |
| if (depth === 0) { | |
| return getNextHydratableSibling(node); | |
| } else { | |
| depth--; | |
| } | |
| } else if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) { | |
| depth++; | |
| } | |
| } | |
| node = node.nextSibling; | |
| } // TODO: Warn, we didn't find the end comment boundary. | |
| return null; | |
| } // Returns the SuspenseInstance if this node is a direct child of a | |
| // SuspenseInstance. I.e. if its previous sibling is a Comment with | |
| // SUSPENSE_x_START_DATA. Otherwise, null. | |
| function getParentSuspenseInstance(targetInstance) { | |
| var node = targetInstance.previousSibling; // Skip past all nodes within this suspense boundary. | |
| // There might be nested nodes so we need to keep track of how | |
| // deep we are and only break out when we're back on top. | |
| var depth = 0; | |
| while (node) { | |
| if (node.nodeType === COMMENT_NODE) { | |
| var data = node.data; | |
| if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) { | |
| if (depth === 0) { | |
| return node; | |
| } else { | |
| depth--; | |
| } | |
| } else if (data === SUSPENSE_END_DATA) { | |
| depth++; | |
| } | |
| } | |
| node = node.previousSibling; | |
| } | |
| return null; | |
| } | |
| function commitHydratedContainer(container) { | |
| // Retry if any event replaying was blocked on this. | |
| retryIfBlockedOn(container); | |
| } | |
| function commitHydratedSuspenseInstance(suspenseInstance) { | |
| // Retry if any event replaying was blocked on this. | |
| retryIfBlockedOn(suspenseInstance); | |
| } | |
| function didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, text) { | |
| { | |
| warnForUnmatchedText(textInstance, text); | |
| } | |
| } | |
| function didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, text) { | |
| if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { | |
| warnForUnmatchedText(textInstance, text); | |
| } | |
| } | |
| function didNotHydrateContainerInstance(parentContainer, instance) { | |
| { | |
| if (instance.nodeType === ELEMENT_NODE) { | |
| warnForDeletedHydratableElement(parentContainer, instance); | |
| } else if (instance.nodeType === COMMENT_NODE) ; else { | |
| warnForDeletedHydratableText(parentContainer, instance); | |
| } | |
| } | |
| } | |
| function didNotHydrateInstance(parentType, parentProps, parentInstance, instance) { | |
| if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { | |
| if (instance.nodeType === ELEMENT_NODE) { | |
| warnForDeletedHydratableElement(parentInstance, instance); | |
| } else if (instance.nodeType === COMMENT_NODE) ; else { | |
| warnForDeletedHydratableText(parentInstance, instance); | |
| } | |
| } | |
| } | |
| function didNotFindHydratableContainerInstance(parentContainer, type, props) { | |
| { | |
| warnForInsertedHydratedElement(parentContainer, type); | |
| } | |
| } | |
| function didNotFindHydratableContainerTextInstance(parentContainer, text) { | |
| { | |
| warnForInsertedHydratedText(parentContainer, text); | |
| } | |
| } | |
| function didNotFindHydratableInstance(parentType, parentProps, parentInstance, type, props) { | |
| if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { | |
| warnForInsertedHydratedElement(parentInstance, type); | |
| } | |
| } | |
| function didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, text) { | |
| if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { | |
| warnForInsertedHydratedText(parentInstance, text); | |
| } | |
| } | |
| function didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance) { | |
| if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) ; | |
| } | |
| var randomKey = Math.random().toString(36).slice(2); | |
| var internalInstanceKey = '__reactInternalInstance$' + randomKey; | |
| var internalEventHandlersKey = '__reactEventHandlers$' + randomKey; | |
| var internalContainerInstanceKey = '__reactContainere$' + randomKey; | |
| function precacheFiberNode(hostInst, node) { | |
| node[internalInstanceKey] = hostInst; | |
| } | |
| function markContainerAsRoot(hostRoot, node) { | |
| node[internalContainerInstanceKey] = hostRoot; | |
| } | |
| function unmarkContainerAsRoot(node) { | |
| node[internalContainerInstanceKey] = null; | |
| } | |
| function isContainerMarkedAsRoot(node) { | |
| return !!node[internalContainerInstanceKey]; | |
| } // Given a DOM node, return the closest HostComponent or HostText fiber ancestor. | |
| // If the target node is part of a hydrated or not yet rendered subtree, then | |
| // this may also return a SuspenseComponent or HostRoot to indicate that. | |
| // Conceptually the HostRoot fiber is a child of the Container node. So if you | |
| // pass the Container node as the targetNode, you will not actually get the | |
| // HostRoot back. To get to the HostRoot, you need to pass a child of it. | |
| // The same thing applies to Suspense boundaries. | |
| function getClosestInstanceFromNode(targetNode) { | |
| var targetInst = targetNode[internalInstanceKey]; | |
| if (targetInst) { | |
| // Don't return HostRoot or SuspenseComponent here. | |
| return targetInst; | |
| } // If the direct event target isn't a React owned DOM node, we need to look | |
| // to see if one of its parents is a React owned DOM node. | |
| var parentNode = targetNode.parentNode; | |
| while (parentNode) { | |
| // We'll check if this is a container root that could include | |
| // React nodes in the future. We need to check this first because | |
| // if we're a child of a dehydrated container, we need to first | |
| // find that inner container before moving on to finding the parent | |
| // instance. Note that we don't check this field on the targetNode | |
| // itself because the fibers are conceptually between the container | |
| // node and the first child. It isn't surrounding the container node. | |
| // If it's not a container, we check if it's an instance. | |
| targetInst = parentNode[internalContainerInstanceKey] || parentNode[internalInstanceKey]; | |
| if (targetInst) { | |
| // Since this wasn't the direct target of the event, we might have | |
| // stepped past dehydrated DOM nodes to get here. However they could | |
| // also have been non-React nodes. We need to answer which one. | |
| // If we the instance doesn't have any children, then there can't be | |
| // a nested suspense boundary within it. So we can use this as a fast | |
| // bailout. Most of the time, when people add non-React children to | |
| // the tree, it is using a ref to a child-less DOM node. | |
| // Normally we'd only need to check one of the fibers because if it | |
| // has ever gone from having children to deleting them or vice versa | |
| // it would have deleted the dehydrated boundary nested inside already. | |
| // However, since the HostRoot starts out with an alternate it might | |
| // have one on the alternate so we need to check in case this was a | |
| // root. | |
| var alternate = targetInst.alternate; | |
| if (targetInst.child !== null || alternate !== null && alternate.child !== null) { | |
| // Next we need to figure out if the node that skipped past is | |
| // nested within a dehydrated boundary and if so, which one. | |
| var suspenseInstance = getParentSuspenseInstance(targetNode); | |
| while (suspenseInstance !== null) { | |
| // We found a suspense instance. That means that we haven't | |
| // hydrated it yet. Even though we leave the comments in the | |
| // DOM after hydrating, and there are boundaries in the DOM | |
| // that could already be hydrated, we wouldn't have found them | |
| // through this pass since if the target is hydrated it would | |
| // have had an internalInstanceKey on it. | |
| // Let's get the fiber associated with the SuspenseComponent | |
| // as the deepest instance. | |
| var targetSuspenseInst = suspenseInstance[internalInstanceKey]; | |
| if (targetSuspenseInst) { | |
| return targetSuspenseInst; | |
| } // If we don't find a Fiber on the comment, it might be because | |
| // we haven't gotten to hydrate it yet. There might still be a | |
| // parent boundary that hasn't above this one so we need to find | |
| // the outer most that is known. | |
| suspenseInstance = getParentSuspenseInstance(suspenseInstance); // If we don't find one, then that should mean that the parent | |
| // host component also hasn't hydrated yet. We can return it | |
| // below since it will bail out on the isMounted check later. | |
| } | |
| } | |
| return targetInst; | |
| } | |
| targetNode = parentNode; | |
| parentNode = targetNode.parentNode; | |
| } | |
| return null; | |
| } | |
| /** | |
| * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent | |
| * instance, or null if the node was not rendered by this React. | |
| */ | |
| function getInstanceFromNode$1(node) { | |
| var inst = node[internalInstanceKey] || node[internalContainerInstanceKey]; | |
| if (inst) { | |
| if (inst.tag === HostComponent || inst.tag === HostText || inst.tag === SuspenseComponent || inst.tag === HostRoot) { | |
| return inst; | |
| } else { | |
| return null; | |
| } | |
| } | |
| return null; | |
| } | |
| /** | |
| * Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding | |
| * DOM node. | |
| */ | |
| function getNodeFromInstance$1(inst) { | |
| if (inst.tag === HostComponent || inst.tag === HostText) { | |
| // In Fiber this, is just the state node right now. We assume it will be | |
| // a host component or host text. | |
| return inst.stateNode; | |
| } // Without this first invariant, passing a non-DOM-component triggers the next | |
| // invariant for a missing parent, which is super confusing. | |
| { | |
| { | |
| throw Error( "getNodeFromInstance: Invalid argument." ); | |
| } | |
| } | |
| } | |
| function getFiberCurrentPropsFromNode$1(node) { | |
| return node[internalEventHandlersKey] || null; | |
| } | |
| function updateFiberProps(node, props) { | |
| node[internalEventHandlersKey] = props; | |
| } | |
| function getParent(inst) { | |
| do { | |
| inst = inst.return; // TODO: If this is a HostRoot we might want to bail out. | |
| // That is depending on if we want nested subtrees (layers) to bubble | |
| // events to their parent. We could also go through parentNode on the | |
| // host node but that wouldn't work for React Native and doesn't let us | |
| // do the portal feature. | |
| } while (inst && inst.tag !== HostComponent); | |
| if (inst) { | |
| return inst; | |
| } | |
| return null; | |
| } | |
| /** | |
| * Return the lowest common ancestor of A and B, or null if they are in | |
| * different trees. | |
| */ | |
| function getLowestCommonAncestor(instA, instB) { | |
| var depthA = 0; | |
| for (var tempA = instA; tempA; tempA = getParent(tempA)) { | |
| depthA++; | |
| } | |
| var depthB = 0; | |
| for (var tempB = instB; tempB; tempB = getParent(tempB)) { | |
| depthB++; | |
| } // If A is deeper, crawl up. | |
| while (depthA - depthB > 0) { | |
| instA = getParent(instA); | |
| depthA--; | |
| } // If B is deeper, crawl up. | |
| while (depthB - depthA > 0) { | |
| instB = getParent(instB); | |
| depthB--; | |
| } // Walk in lockstep until we find a match. | |
| var depth = depthA; | |
| while (depth--) { | |
| if (instA === instB || instA === instB.alternate) { | |
| return instA; | |
| } | |
| instA = getParent(instA); | |
| instB = getParent(instB); | |
| } | |
| return null; | |
| } | |
| /** | |
| * Simulates the traversal of a two-phase, capture/bubble event dispatch. | |
| */ | |
| function traverseTwoPhase(inst, fn, arg) { | |
| var path = []; | |
| while (inst) { | |
| path.push(inst); | |
| inst = getParent(inst); | |
| } | |
| var i; | |
| for (i = path.length; i-- > 0;) { | |
| fn(path[i], 'captured', arg); | |
| } | |
| for (i = 0; i < path.length; i++) { | |
| fn(path[i], 'bubbled', arg); | |
| } | |
| } | |
| /** | |
| * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that | |
| * should would receive a `mouseEnter` or `mouseLeave` event. | |
| * | |
| * Does not invoke the callback on the nearest common ancestor because nothing | |
| * "entered" or "left" that element. | |
| */ | |
| function traverseEnterLeave(from, to, fn, argFrom, argTo) { | |
| var common = from && to ? getLowestCommonAncestor(from, to) : null; | |
| var pathFrom = []; | |
| while (true) { | |
| if (!from) { | |
| break; | |
| } | |
| if (from === common) { | |
| break; | |
| } | |
| var alternate = from.alternate; | |
| if (alternate !== null && alternate === common) { | |
| break; | |
| } | |
| pathFrom.push(from); | |
| from = getParent(from); | |
| } | |
| var pathTo = []; | |
| while (true) { | |
| if (!to) { | |
| break; | |
| } | |
| if (to === common) { | |
| break; | |
| } | |
| var _alternate = to.alternate; | |
| if (_alternate !== null && _alternate === common) { | |
| break; | |
| } | |
| pathTo.push(to); | |
| to = getParent(to); | |
| } | |
| for (var i = 0; i < pathFrom.length; i++) { | |
| fn(pathFrom[i], 'bubbled', argFrom); | |
| } | |
| for (var _i = pathTo.length; _i-- > 0;) { | |
| fn(pathTo[_i], 'captured', argTo); | |
| } | |
| } | |
| function isInteractive(tag) { | |
| return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea'; | |
| } | |
| function shouldPreventMouseEvent(name, type, props) { | |
| switch (name) { | |
| case 'onClick': | |
| case 'onClickCapture': | |
| case 'onDoubleClick': | |
| case 'onDoubleClickCapture': | |
| case 'onMouseDown': | |
| case 'onMouseDownCapture': | |
| case 'onMouseMove': | |
| case 'onMouseMoveCapture': | |
| case 'onMouseUp': | |
| case 'onMouseUpCapture': | |
| case 'onMouseEnter': | |
| return !!(props.disabled && isInteractive(type)); | |
| default: | |
| return false; | |
| } | |
| } | |
| /** | |
| * @param {object} inst The instance, which is the source of events. | |
| * @param {string} registrationName Name of listener (e.g. `onClick`). | |
| * @return {?function} The stored callback. | |
| */ | |
| function getListener(inst, registrationName) { | |
| var listener; // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not | |
| // live here; needs to be moved to a better place soon | |
| var stateNode = inst.stateNode; | |
| if (!stateNode) { | |
| // Work in progress (ex: onload events in incremental mode). | |
| return null; | |
| } | |
| var props = getFiberCurrentPropsFromNode(stateNode); | |
| if (!props) { | |
| // Work in progress. | |
| return null; | |
| } | |
| listener = props[registrationName]; | |
| if (shouldPreventMouseEvent(registrationName, inst.type, props)) { | |
| return null; | |
| } | |
| if (!(!listener || typeof listener === 'function')) { | |
| { | |
| throw Error( "Expected `" + registrationName + "` listener to be a function, instead got a value of `" + typeof listener + "` type." ); | |
| } | |
| } | |
| return listener; | |
| } | |
| /** | |
| * Some event types have a notion of different registration names for different | |
| * "phases" of propagation. This finds listeners by a given phase. | |
| */ | |
| function listenerAtPhase(inst, event, propagationPhase) { | |
| var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase]; | |
| return getListener(inst, registrationName); | |
| } | |
| /** | |
| * A small set of propagation patterns, each of which will accept a small amount | |
| * of information, and generate a set of "dispatch ready event objects" - which | |
| * are sets of events that have already been annotated with a set of dispatched | |
| * listener functions/ids. The API is designed this way to discourage these | |
| * propagation strategies from actually executing the dispatches, since we | |
| * always want to collect the entire set of dispatches before executing even a | |
| * single one. | |
| */ | |
| /** | |
| * Tags a `SyntheticEvent` with dispatched listeners. Creating this function | |
| * here, allows us to not have to bind or create functions for each event. | |
| * Mutating the event's members allows us to not have to create a wrapping | |
| * "dispatch" object that pairs the event with the listener. | |
| */ | |
| function accumulateDirectionalDispatches(inst, phase, event) { | |
| { | |
| if (!inst) { | |
| error('Dispatching inst must not be null'); | |
| } | |
| } | |
| var listener = listenerAtPhase(inst, event, phase); | |
| if (listener) { | |
| event._dispatchListeners = accumulateInto(event._dispatchListeners, listener); | |
| event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); | |
| } | |
| } | |
| /** | |
| * Collect dispatches (must be entirely collected before dispatching - see unit | |
| * tests). Lazily allocate the array to conserve memory. We must loop through | |
| * each event and perform the traversal for each one. We cannot perform a | |
| * single traversal for the entire collection of events because each event may | |
| * have a different target. | |
| */ | |
| function accumulateTwoPhaseDispatchesSingle(event) { | |
| if (event && event.dispatchConfig.phasedRegistrationNames) { | |
| traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); | |
| } | |
| } | |
| /** | |
| * Accumulates without regard to direction, does not look for phased | |
| * registration names. Same as `accumulateDirectDispatchesSingle` but without | |
| * requiring that the `dispatchMarker` be the same as the dispatched ID. | |
| */ | |
| function accumulateDispatches(inst, ignoredDirection, event) { | |
| if (inst && event && event.dispatchConfig.registrationName) { | |
| var registrationName = event.dispatchConfig.registrationName; | |
| var listener = getListener(inst, registrationName); | |
| if (listener) { | |
| event._dispatchListeners = accumulateInto(event._dispatchListeners, listener); | |
| event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); | |
| } | |
| } | |
| } | |
| /** | |
| * Accumulates dispatches on an `SyntheticEvent`, but only for the | |
| * `dispatchMarker`. | |
| * @param {SyntheticEvent} event | |
| */ | |
| function accumulateDirectDispatchesSingle(event) { | |
| if (event && event.dispatchConfig.registrationName) { | |
| accumulateDispatches(event._targetInst, null, event); | |
| } | |
| } | |
| function accumulateTwoPhaseDispatches(events) { | |
| forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle); | |
| } | |
| function accumulateEnterLeaveDispatches(leave, enter, from, to) { | |
| traverseEnterLeave(from, to, accumulateDispatches, leave, enter); | |
| } | |
| function accumulateDirectDispatches(events) { | |
| forEachAccumulated(events, accumulateDirectDispatchesSingle); | |
| } | |
| /** | |
| * These variables store information about text content of a target node, | |
| * allowing comparison of content before and after a given event. | |
| * | |
| * Identify the node where selection currently begins, then observe | |
| * both its text content and its current position in the DOM. Since the | |
| * browser may natively replace the target node during composition, we can | |
| * use its position to find its replacement. | |
| * | |
| * | |
| */ | |
| var root = null; | |
| var startText = null; | |
| var fallbackText = null; | |
| function initialize(nativeEventTarget) { | |
| root = nativeEventTarget; | |
| startText = getText(); | |
| return true; | |
| } | |
| function reset() { | |
| root = null; | |
| startText = null; | |
| fallbackText = null; | |
| } | |
| function getData() { | |
| if (fallbackText) { | |
| return fallbackText; | |
| } | |
| var start; | |
| var startValue = startText; | |
| var startLength = startValue.length; | |
| var end; | |
| var endValue = getText(); | |
| var endLength = endValue.length; | |
| for (start = 0; start < startLength; start++) { | |
| if (startValue[start] !== endValue[start]) { | |
| break; | |
| } | |
| } | |
| var minEnd = startLength - start; | |
| for (end = 1; end <= minEnd; end++) { | |
| if (startValue[startLength - end] !== endValue[endLength - end]) { | |
| break; | |
| } | |
| } | |
| var sliceTail = end > 1 ? 1 - end : undefined; | |
| fallbackText = endValue.slice(start, sliceTail); | |
| return fallbackText; | |
| } | |
| function getText() { | |
| if ('value' in root) { | |
| return root.value; | |
| } | |
| return root.textContent; | |
| } | |
| var EVENT_POOL_SIZE = 10; | |
| /** | |
| * @interface Event | |
| * @see http://www.w3.org/TR/DOM-Level-3-Events/ | |
| */ | |
| var EventInterface = { | |
| type: null, | |
| target: null, | |
| // currentTarget is set when dispatching; no use in copying it here | |
| currentTarget: function () { | |
| return null; | |
| }, | |
| eventPhase: null, | |
| bubbles: null, | |
| cancelable: null, | |
| timeStamp: function (event) { | |
| return event.timeStamp || Date.now(); | |
| }, | |
| defaultPrevented: null, | |
| isTrusted: null | |
| }; | |
| function functionThatReturnsTrue() { | |
| return true; | |
| } | |
| function functionThatReturnsFalse() { | |
| return false; | |
| } | |
| /** | |
| * Synthetic events are dispatched by event plugins, typically in response to a | |
| * top-level event delegation handler. | |
| * | |
| * These systems should generally use pooling to reduce the frequency of garbage | |
| * collection. The system should check `isPersistent` to determine whether the | |
| * event should be released into the pool after being dispatched. Users that | |
| * need a persisted event should invoke `persist`. | |
| * | |
| * Synthetic events (and subclasses) implement the DOM Level 3 Events API by | |
| * normalizing browser quirks. Subclasses do not necessarily have to implement a | |
| * DOM interface; custom application-specific events can also subclass this. | |
| * | |
| * @param {object} dispatchConfig Configuration used to dispatch this event. | |
| * @param {*} targetInst Marker identifying the event target. | |
| * @param {object} nativeEvent Native browser event. | |
| * @param {DOMEventTarget} nativeEventTarget Target node. | |
| */ | |
| function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) { | |
| { | |
| // these have a getter/setter for warnings | |
| delete this.nativeEvent; | |
| delete this.preventDefault; | |
| delete this.stopPropagation; | |
| delete this.isDefaultPrevented; | |
| delete this.isPropagationStopped; | |
| } | |
| this.dispatchConfig = dispatchConfig; | |
| this._targetInst = targetInst; | |
| this.nativeEvent = nativeEvent; | |
| var Interface = this.constructor.Interface; | |
| for (var propName in Interface) { | |
| if (!Interface.hasOwnProperty(propName)) { | |
| continue; | |
| } | |
| { | |
| delete this[propName]; // this has a getter/setter for warnings | |
| } | |
| var normalize = Interface[propName]; | |
| if (normalize) { | |
| this[propName] = normalize(nativeEvent); | |
| } else { | |
| if (propName === 'target') { | |
| this.target = nativeEventTarget; | |
| } else { | |
| this[propName] = nativeEvent[propName]; | |
| } | |
| } | |
| } | |
| var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false; | |
| if (defaultPrevented) { | |
| this.isDefaultPrevented = functionThatReturnsTrue; | |
| } else { | |
| this.isDefaultPrevented = functionThatReturnsFalse; | |
| } | |
| this.isPropagationStopped = functionThatReturnsFalse; | |
| return this; | |
| } | |
| _assign(SyntheticEvent.prototype, { | |
| preventDefault: function () { | |
| this.defaultPrevented = true; | |
| var event = this.nativeEvent; | |
| if (!event) { | |
| return; | |
| } | |
| if (event.preventDefault) { | |
| event.preventDefault(); | |
| } else if (typeof event.returnValue !== 'unknown') { | |
| event.returnValue = false; | |
| } | |
| this.isDefaultPrevented = functionThatReturnsTrue; | |
| }, | |
| stopPropagation: function () { | |
| var event = this.nativeEvent; | |
| if (!event) { | |
| return; | |
| } | |
| if (event.stopPropagation) { | |
| event.stopPropagation(); | |
| } else if (typeof event.cancelBubble !== 'unknown') { | |
| // The ChangeEventPlugin registers a "propertychange" event for | |
| // IE. This event does not support bubbling or cancelling, and | |
| // any references to cancelBubble throw "Member not found". A | |
| // typeof check of "unknown" circumvents this issue (and is also | |
| // IE specific). | |
| event.cancelBubble = true; | |
| } | |
| this.isPropagationStopped = functionThatReturnsTrue; | |
| }, | |
| /** | |
| * We release all dispatched `SyntheticEvent`s after each event loop, adding | |
| * them back into the pool. This allows a way to hold onto a reference that | |
| * won't be added back into the pool. | |
| */ | |
| persist: function () { | |
| this.isPersistent = functionThatReturnsTrue; | |
| }, | |
| /** | |
| * Checks if this event should be released back into the pool. | |
| * | |
| * @return {boolean} True if this should not be released, false otherwise. | |
| */ | |
| isPersistent: functionThatReturnsFalse, | |
| /** | |
| * `PooledClass` looks for `destructor` on each instance it releases. | |
| */ | |
| destructor: function () { | |
| var Interface = this.constructor.Interface; | |
| for (var propName in Interface) { | |
| { | |
| Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName])); | |
| } | |
| } | |
| this.dispatchConfig = null; | |
| this._targetInst = null; | |
| this.nativeEvent = null; | |
| this.isDefaultPrevented = functionThatReturnsFalse; | |
| this.isPropagationStopped = functionThatReturnsFalse; | |
| this._dispatchListeners = null; | |
| this._dispatchInstances = null; | |
| { | |
| Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null)); | |
| Object.defineProperty(this, 'isDefaultPrevented', getPooledWarningPropertyDefinition('isDefaultPrevented', functionThatReturnsFalse)); | |
| Object.defineProperty(this, 'isPropagationStopped', getPooledWarningPropertyDefinition('isPropagationStopped', functionThatReturnsFalse)); | |
| Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', function () {})); | |
| Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', function () {})); | |
| } | |
| } | |
| }); | |
| SyntheticEvent.Interface = EventInterface; | |
| /** | |
| * Helper to reduce boilerplate when creating subclasses. | |
| */ | |
| SyntheticEvent.extend = function (Interface) { | |
| var Super = this; | |
| var E = function () {}; | |
| E.prototype = Super.prototype; | |
| var prototype = new E(); | |
| function Class() { | |
| return Super.apply(this, arguments); | |
| } | |
| _assign(prototype, Class.prototype); | |
| Class.prototype = prototype; | |
| Class.prototype.constructor = Class; | |
| Class.Interface = _assign({}, Super.Interface, Interface); | |
| Class.extend = Super.extend; | |
| addEventPoolingTo(Class); | |
| return Class; | |
| }; | |
| addEventPoolingTo(SyntheticEvent); | |
| /** | |
| * Helper to nullify syntheticEvent instance properties when destructing | |
| * | |
| * @param {String} propName | |
| * @param {?object} getVal | |
| * @return {object} defineProperty object | |
| */ | |
| function getPooledWarningPropertyDefinition(propName, getVal) { | |
| var isFunction = typeof getVal === 'function'; | |
| return { | |
| configurable: true, | |
| set: set, | |
| get: get | |
| }; | |
| function set(val) { | |
| var action = isFunction ? 'setting the method' : 'setting the property'; | |
| warn(action, 'This is effectively a no-op'); | |
| return val; | |
| } | |
| function get() { | |
| var action = isFunction ? 'accessing the method' : 'accessing the property'; | |
| var result = isFunction ? 'This is a no-op function' : 'This is set to null'; | |
| warn(action, result); | |
| return getVal; | |
| } | |
| function warn(action, result) { | |
| { | |
| error("This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result); | |
| } | |
| } | |
| } | |
| function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { | |
| var EventConstructor = this; | |
| if (EventConstructor.eventPool.length) { | |
| var instance = EventConstructor.eventPool.pop(); | |
| EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst); | |
| return instance; | |
| } | |
| return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst); | |
| } | |
| function releasePooledEvent(event) { | |
| var EventConstructor = this; | |
| if (!(event instanceof EventConstructor)) { | |
| { | |
| throw Error( "Trying to release an event instance into a pool of a different type." ); | |
| } | |
| } | |
| event.destructor(); | |
| if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) { | |
| EventConstructor.eventPool.push(event); | |
| } | |
| } | |
| function addEventPoolingTo(EventConstructor) { | |
| EventConstructor.eventPool = []; | |
| EventConstructor.getPooled = getPooledEvent; | |
| EventConstructor.release = releasePooledEvent; | |
| } | |
| /** | |
| * @interface Event | |
| * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents | |
| */ | |
| var SyntheticCompositionEvent = SyntheticEvent.extend({ | |
| data: null | |
| }); | |
| /** | |
| * @interface Event | |
| * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105 | |
| * /#events-inputevents | |
| */ | |
| var SyntheticInputEvent = SyntheticEvent.extend({ | |
| data: null | |
| }); | |
| var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space | |
| var START_KEYCODE = 229; | |
| var canUseCompositionEvent = canUseDOM && 'CompositionEvent' in window; | |
| var documentMode = null; | |
| if (canUseDOM && 'documentMode' in document) { | |
| documentMode = document.documentMode; | |
| } // Webkit offers a very useful `textInput` event that can be used to | |
| // directly represent `beforeInput`. The IE `textinput` event is not as | |
| // useful, so we don't use it. | |
| var canUseTextInputEvent = canUseDOM && 'TextEvent' in window && !documentMode; // In IE9+, we have access to composition events, but the data supplied | |
| // by the native compositionend event may be incorrect. Japanese ideographic | |
| // spaces, for instance (\u3000) are not recorded correctly. | |
| var useFallbackCompositionData = canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11); | |
| var SPACEBAR_CODE = 32; | |
| var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE); // Events and their corresponding property names. | |
| var eventTypes = { | |
| beforeInput: { | |
| phasedRegistrationNames: { | |
| bubbled: 'onBeforeInput', | |
| captured: 'onBeforeInputCapture' | |
| }, | |
| dependencies: [TOP_COMPOSITION_END, TOP_KEY_PRESS, TOP_TEXT_INPUT, TOP_PASTE] | |
| }, | |
| compositionEnd: { | |
| phasedRegistrationNames: { | |
| bubbled: 'onCompositionEnd', | |
| captured: 'onCompositionEndCapture' | |
| }, | |
| dependencies: [TOP_BLUR, TOP_COMPOSITION_END, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN] | |
| }, | |
| compositionStart: { | |
| phasedRegistrationNames: { | |
| bubbled: 'onCompositionStart', | |
| captured: 'onCompositionStartCapture' | |
| }, | |
| dependencies: [TOP_BLUR, TOP_COMPOSITION_START, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN] | |
| }, | |
| compositionUpdate: { | |
| phasedRegistrationNames: { | |
| bubbled: 'onCompositionUpdate', | |
| captured: 'onCompositionUpdateCapture' | |
| }, | |
| dependencies: [TOP_BLUR, TOP_COMPOSITION_UPDATE, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN] | |
| } | |
| }; // Track whether we've ever handled a keypress on the space key. | |
| var hasSpaceKeypress = false; | |
| /** | |
| * Return whether a native keypress event is assumed to be a command. | |
| * This is required because Firefox fires `keypress` events for key commands | |
| * (cut, copy, select-all, etc.) even though no character is inserted. | |
| */ | |
| function isKeypressCommand(nativeEvent) { | |
| return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && // ctrlKey && altKey is equivalent to AltGr, and is not a command. | |
| !(nativeEvent.ctrlKey && nativeEvent.altKey); | |
| } | |
| /** | |
| * Translate native top level events into event types. | |
| * | |
| * @param {string} topLevelType | |
| * @return {object} | |
| */ | |
| function getCompositionEventType(topLevelType) { | |
| switch (topLevelType) { | |
| case TOP_COMPOSITION_START: | |
| return eventTypes.compositionStart; | |
| case TOP_COMPOSITION_END: | |
| return eventTypes.compositionEnd; | |
| case TOP_COMPOSITION_UPDATE: | |
| return eventTypes.compositionUpdate; | |
| } | |
| } | |
| /** | |
| * Does our fallback best-guess model think this event signifies that | |
| * composition has begun? | |
| * | |
| * @param {string} topLevelType | |
| * @param {object} nativeEvent | |
| * @return {boolean} | |
| */ | |
| function isFallbackCompositionStart(topLevelType, nativeEvent) { | |
| return topLevelType === TOP_KEY_DOWN && nativeEvent.keyCode === START_KEYCODE; | |
| } | |
| /** | |
| * Does our fallback mode think that this event is the end of composition? | |
| * | |
| * @param {string} topLevelType | |
| * @param {object} nativeEvent | |
| * @return {boolean} | |
| */ | |
| function isFallbackCompositionEnd(topLevelType, nativeEvent) { | |
| switch (topLevelType) { | |
| case TOP_KEY_UP: | |
| // Command keys insert or clear IME input. | |
| return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1; | |
| case TOP_KEY_DOWN: | |
| // Expect IME keyCode on each keydown. If we get any other | |
| // code we must have exited earlier. | |
| return nativeEvent.keyCode !== START_KEYCODE; | |
| case TOP_KEY_PRESS: | |
| case TOP_MOUSE_DOWN: | |
| case TOP_BLUR: | |
| // Events are not possible without cancelling IME. | |
| return true; | |
| default: | |
| return false; | |
| } | |
| } | |
| /** | |
| * Google Input Tools provides composition data via a CustomEvent, | |
| * with the `data` property populated in the `detail` object. If this | |
| * is available on the event object, use it. If not, this is a plain | |
| * composition event and we have nothing special to extract. | |
| * | |
| * @param {object} nativeEvent | |
| * @return {?string} | |
| */ | |
| function getDataFromCustomEvent(nativeEvent) { | |
| var detail = nativeEvent.detail; | |
| if (typeof detail === 'object' && 'data' in detail) { | |
| return detail.data; | |
| } | |
| return null; | |
| } | |
| /** | |
| * Check if a composition event was triggered by Korean IME. | |
| * Our fallback mode does not work well with IE's Korean IME, | |
| * so just use native composition events when Korean IME is used. | |
| * Although CompositionEvent.locale property is deprecated, | |
| * it is available in IE, where our fallback mode is enabled. | |
| * | |
| * @param {object} nativeEvent | |
| * @return {boolean} | |
| */ | |
| function isUsingKoreanIME(nativeEvent) { | |
| return nativeEvent.locale === 'ko'; | |
| } // Track the current IME composition status, if any. | |
| var isComposing = false; | |
| /** | |
| * @return {?object} A SyntheticCompositionEvent. | |
| */ | |
| function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) { | |
| var eventType; | |
| var fallbackData; | |
| if (canUseCompositionEvent) { | |
| eventType = getCompositionEventType(topLevelType); | |
| } else if (!isComposing) { | |
| if (isFallbackCompositionStart(topLevelType, nativeEvent)) { | |
| eventType = eventTypes.compositionStart; | |
| } | |
| } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) { | |
| eventType = eventTypes.compositionEnd; | |
| } | |
| if (!eventType) { | |
| return null; | |
| } | |
| if (useFallbackCompositionData && !isUsingKoreanIME(nativeEvent)) { | |
| // The current composition is stored statically and must not be | |
| // overwritten while composition continues. | |
| if (!isComposing && eventType === eventTypes.compositionStart) { | |
| isComposing = initialize(nativeEventTarget); | |
| } else if (eventType === eventTypes.compositionEnd) { | |
| if (isComposing) { | |
| fallbackData = getData(); | |
| } | |
| } | |
| } | |
| var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget); | |
| if (fallbackData) { | |
| // Inject data generated from fallback path into the synthetic event. | |
| // This matches the property of native CompositionEventInterface. | |
| event.data = fallbackData; | |
| } else { | |
| var customData = getDataFromCustomEvent(nativeEvent); | |
| if (customData !== null) { | |
| event.data = customData; | |
| } | |
| } | |
| accumulateTwoPhaseDispatches(event); | |
| return event; | |
| } | |
| /** | |
| * @param {TopLevelType} topLevelType Number from `TopLevelType`. | |
| * @param {object} nativeEvent Native browser event. | |
| * @return {?string} The string corresponding to this `beforeInput` event. | |
| */ | |
| function getNativeBeforeInputChars(topLevelType, nativeEvent) { | |
| switch (topLevelType) { | |
| case TOP_COMPOSITION_END: | |
| return getDataFromCustomEvent(nativeEvent); | |
| case TOP_KEY_PRESS: | |
| /** | |
| * If native `textInput` events are available, our goal is to make | |
| * use of them. However, there is a special case: the spacebar key. | |
| * In Webkit, preventing default on a spacebar `textInput` event | |
| * cancels character insertion, but it *also* causes the browser | |
| * to fall back to its default spacebar behavior of scrolling the | |
| * page. | |
| * | |
| * Tracking at: | |
| * https://code.google.com/p/chromium/issues/detail?id=355103 | |
| * | |
| * To avoid this issue, use the keypress event as if no `textInput` | |
| * event is available. | |
| */ | |
| var which = nativeEvent.which; | |
| if (which !== SPACEBAR_CODE) { | |
| return null; | |
| } | |
| hasSpaceKeypress = true; | |
| return SPACEBAR_CHAR; | |
| case TOP_TEXT_INPUT: | |
| // Record the characters to be added to the DOM. | |
| var chars = nativeEvent.data; // If it's a spacebar character, assume that we have already handled | |
| // it at the keypress level and bail immediately. Android Chrome | |
| // doesn't give us keycodes, so we need to ignore it. | |
| if (chars === SPACEBAR_CHAR && hasSpaceKeypress) { | |
| return null; | |
| } | |
| return chars; | |
| default: | |
| // For other native event types, do nothing. | |
| return null; | |
| } | |
| } | |
| /** | |
| * For browsers that do not provide the `textInput` event, extract the | |
| * appropriate string to use for SyntheticInputEvent. | |
| * | |
| * @param {number} topLevelType Number from `TopLevelEventTypes`. | |
| * @param {object} nativeEvent Native browser event. | |
| * @return {?string} The fallback string for this `beforeInput` event. | |
| */ | |
| function getFallbackBeforeInputChars(topLevelType, nativeEvent) { | |
| // If we are currently composing (IME) and using a fallback to do so, | |
| // try to extract the composed characters from the fallback object. | |
| // If composition event is available, we extract a string only at | |
| // compositionevent, otherwise extract it at fallback events. | |
| if (isComposing) { | |
| if (topLevelType === TOP_COMPOSITION_END || !canUseCompositionEvent && isFallbackCompositionEnd(topLevelType, nativeEvent)) { | |
| var chars = getData(); | |
| reset(); | |
| isComposing = false; | |
| return chars; | |
| } | |
| return null; | |
| } | |
| switch (topLevelType) { | |
| case TOP_PASTE: | |
| // If a paste event occurs after a keypress, throw out the input | |
| // chars. Paste events should not lead to BeforeInput events. | |
| return null; | |
| case TOP_KEY_PRESS: | |
| /** | |
| * As of v27, Firefox may fire keypress events even when no character | |
| * will be inserted. A few possibilities: | |
| * | |
| * - `which` is `0`. Arrow keys, Esc key, etc. | |
| * | |
| * - `which` is the pressed key code, but no char is available. | |
| * Ex: 'AltGr + d` in Polish. There is no modified character for | |
| * this key combination and no character is inserted into the | |
| * document, but FF fires the keypress for char code `100` anyway. | |
| * No `input` event will occur. | |
| * | |
| * - `which` is the pressed key code, but a command combination is | |
| * being used. Ex: `Cmd+C`. No character is inserted, and no | |
| * `input` event will occur. | |
| */ | |
| if (!isKeypressCommand(nativeEvent)) { | |
| // IE fires the `keypress` event when a user types an emoji via | |
| // Touch keyboard of Windows. In such a case, the `char` property | |
| // holds an emoji character like `\uD83D\uDE0A`. Because its length | |
| // is 2, the property `which` does not represent an emoji correctly. | |
| // In such a case, we directly return the `char` property instead of | |
| // using `which`. | |
| if (nativeEvent.char && nativeEvent.char.length > 1) { | |
| return nativeEvent.char; | |
| } else if (nativeEvent.which) { | |
| return String.fromCharCode(nativeEvent.which); | |
| } | |
| } | |
| return null; | |
| case TOP_COMPOSITION_END: | |
| return useFallbackCompositionData && !isUsingKoreanIME(nativeEvent) ? null : nativeEvent.data; | |
| default: | |
| return null; | |
| } | |
| } | |
| /** | |
| * Extract a SyntheticInputEvent for `beforeInput`, based on either native | |
| * `textInput` or fallback behavior. | |
| * | |
| * @return {?object} A SyntheticInputEvent. | |
| */ | |
| function extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) { | |
| var chars; | |
| if (canUseTextInputEvent) { | |
| chars = getNativeBeforeInputChars(topLevelType, nativeEvent); | |
| } else { | |
| chars = getFallbackBeforeInputChars(topLevelType, nativeEvent); | |
| } // If no characters are being inserted, no BeforeInput event should | |
| // be fired. | |
| if (!chars) { | |
| return null; | |
| } | |
| var event = SyntheticInputEvent.getPooled(eventTypes.beforeInput, targetInst, nativeEvent, nativeEventTarget); | |
| event.data = chars; | |
| accumulateTwoPhaseDispatches(event); | |
| return event; | |
| } | |
| /** | |
| * Create an `onBeforeInput` event to match | |
| * http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents. | |
| * | |
| * This event plugin is based on the native `textInput` event | |
| * available in Chrome, Safari, Opera, and IE. This event fires after | |
| * `onKeyPress` and `onCompositionEnd`, but before `onInput`. | |
| * | |
| * `beforeInput` is spec'd but not implemented in any browsers, and | |
| * the `input` event does not provide any useful information about what has | |
| * actually been added, contrary to the spec. Thus, `textInput` is the best | |
| * available event to identify the characters that have actually been inserted | |
| * into the target node. | |
| * | |
| * This plugin is also responsible for emitting `composition` events, thus | |
| * allowing us to share composition fallback code for both `beforeInput` and | |
| * `composition` event types. | |
| */ | |
| var BeforeInputEventPlugin = { | |
| eventTypes: eventTypes, | |
| extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { | |
| var composition = extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget); | |
| var beforeInput = extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget); | |
| if (composition === null) { | |
| return beforeInput; | |
| } | |
| if (beforeInput === null) { | |
| return composition; | |
| } | |
| return [composition, beforeInput]; | |
| } | |
| }; | |
| /** | |
| * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary | |
| */ | |
| var supportedInputTypes = { | |
| color: true, | |
| date: true, | |
| datetime: true, | |
| 'datetime-local': true, | |
| email: true, | |
| month: true, | |
| number: true, | |
| password: true, | |
| range: true, | |
| search: true, | |
| tel: true, | |
| text: true, | |
| time: true, | |
| url: true, | |
| week: true | |
| }; | |
| function isTextInputElement(elem) { | |
| var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); | |
| if (nodeName === 'input') { | |
| return !!supportedInputTypes[elem.type]; | |
| } | |
| if (nodeName === 'textarea') { | |
| return true; | |
| } | |
| return false; | |
| } | |
| var eventTypes$1 = { | |
| change: { | |
| phasedRegistrationNames: { | |
| bubbled: 'onChange', | |
| captured: 'onChangeCapture' | |
| }, | |
| dependencies: [TOP_BLUR, TOP_CHANGE, TOP_CLICK, TOP_FOCUS, TOP_INPUT, TOP_KEY_DOWN, TOP_KEY_UP, TOP_SELECTION_CHANGE] | |
| } | |
| }; | |
| function createAndAccumulateChangeEvent(inst, nativeEvent, target) { | |
| var event = SyntheticEvent.getPooled(eventTypes$1.change, inst, nativeEvent, target); | |
| event.type = 'change'; // Flag this event loop as needing state restore. | |
| enqueueStateRestore(target); | |
| accumulateTwoPhaseDispatches(event); | |
| return event; | |
| } | |
| /** | |
| * For IE shims | |
| */ | |
| var activeElement = null; | |
| var activeElementInst = null; | |
| /** | |
| * SECTION: handle `change` event | |
| */ | |
| function shouldUseChangeEvent(elem) { | |
| var nodeName = elem.nodeName && elem.nodeName.toLowerCase(); | |
| return nodeName === 'select' || nodeName === 'input' && elem.type === 'file'; | |
| } | |
| function manualDispatchChangeEvent(nativeEvent) { | |
| var event = createAndAccumulateChangeEvent(activeElementInst, nativeEvent, getEventTarget(nativeEvent)); // If change and propertychange bubbled, we'd just bind to it like all the | |
| // other events and have it go through ReactBrowserEventEmitter. Since it | |
| // doesn't, we manually listen for the events and so we have to enqueue and | |
| // process the abstract event manually. | |
| // | |
| // Batching is necessary here in order to ensure that all event handlers run | |
| // before the next rerender (including event handlers attached to ancestor | |
| // elements instead of directly on the input). Without this, controlled | |
| // components don't work properly in conjunction with event bubbling because | |
| // the component is rerendered and the value reverted before all the event | |
| // handlers can run. See https://github.com/facebook/react/issues/708. | |
| batchedUpdates(runEventInBatch, event); | |
| } | |
| function runEventInBatch(event) { | |
| runEventsInBatch(event); | |
| } | |
| function getInstIfValueChanged(targetInst) { | |
| var targetNode = getNodeFromInstance$1(targetInst); | |
| if (updateValueIfChanged(targetNode)) { | |
| return targetInst; | |
| } | |
| } | |
| function getTargetInstForChangeEvent(topLevelType, targetInst) { | |
| if (topLevelType === TOP_CHANGE) { | |
| return targetInst; | |
| } | |
| } | |
| /** | |
| * SECTION: handle `input` event | |
| */ | |
| var isInputEventSupported = false; | |
| if (canUseDOM) { | |
| // IE9 claims to support the input event but fails to trigger it when | |
| // deleting text, so we ignore its input events. | |
| isInputEventSupported = isEventSupported('input') && (!document.documentMode || document.documentMode > 9); | |
| } | |
| /** | |
| * (For IE <=9) Starts tracking propertychange events on the passed-in element | |
| * and override the value property so that we can distinguish user events from | |
| * value changes in JS. | |
| */ | |
| function startWatchingForValueChange(target, targetInst) { | |
| activeElement = target; | |
| activeElementInst = targetInst; | |
| activeElement.attachEvent('onpropertychange', handlePropertyChange); | |
| } | |
| /** | |
| * (For IE <=9) Removes the event listeners from the currently-tracked element, | |
| * if any exists. | |
| */ | |
| function stopWatchingForValueChange() { | |
| if (!activeElement) { | |
| return; | |
| } | |
| activeElement.detachEvent('onpropertychange', handlePropertyChange); | |
| activeElement = null; | |
| activeElementInst = null; | |
| } | |
| /** | |
| * (For IE <=9) Handles a propertychange event, sending a `change` event if | |
| * the value of the active element has changed. | |
| */ | |
| function handlePropertyChange(nativeEvent) { | |
| if (nativeEvent.propertyName !== 'value') { | |
| return; | |
| } | |
| if (getInstIfValueChanged(activeElementInst)) { | |
| manualDispatchChangeEvent(nativeEvent); | |
| } | |
| } | |
| function handleEventsForInputEventPolyfill(topLevelType, target, targetInst) { | |
| if (topLevelType === TOP_FOCUS) { | |
| // In IE9, propertychange fires for most input events but is buggy and | |
| // doesn't fire when text is deleted, but conveniently, selectionchange | |
| // appears to fire in all of the remaining cases so we catch those and | |
| // forward the event if the value has changed | |
| // In either case, we don't want to call the event handler if the value | |
| // is changed from JS so we redefine a setter for `.value` that updates | |
| // our activeElementValue variable, allowing us to ignore those changes | |
| // | |
| // stopWatching() should be a noop here but we call it just in case we | |
| // missed a blur event somehow. | |
| stopWatchingForValueChange(); | |
| startWatchingForValueChange(target, targetInst); | |
| } else if (topLevelType === TOP_BLUR) { | |
| stopWatchingForValueChange(); | |
| } | |
| } // For IE8 and IE9. | |
| function getTargetInstForInputEventPolyfill(topLevelType, targetInst) { | |
| if (topLevelType === TOP_SELECTION_CHANGE || topLevelType === TOP_KEY_UP || topLevelType === TOP_KEY_DOWN) { | |
| // On the selectionchange event, the target is just document which isn't | |
| // helpful for us so just check activeElement instead. | |
| // | |
| // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire | |
| // propertychange on the first input event after setting `value` from a | |
| // script and fires only keydown, keypress, keyup. Catching keyup usually | |
| // gets it and catching keydown lets us fire an event for the first | |
| // keystroke if user does a key repeat (it'll be a little delayed: right | |
| // before the second keystroke). Other input methods (e.g., paste) seem to | |
| // fire selectionchange normally. | |
| return getInstIfValueChanged(activeElementInst); | |
| } | |
| } | |
| /** | |
| * SECTION: handle `click` event | |
| */ | |
| function shouldUseClickEvent(elem) { | |
| // Use the `click` event to detect changes to checkbox and radio inputs. | |
| // This approach works across all browsers, whereas `change` does not fire | |
| // until `blur` in IE8. | |
| var nodeName = elem.nodeName; | |
| return nodeName && nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio'); | |
| } | |
| function getTargetInstForClickEvent(topLevelType, targetInst) { | |
| if (topLevelType === TOP_CLICK) { | |
| return getInstIfValueChanged(targetInst); | |
| } | |
| } | |
| function getTargetInstForInputOrChangeEvent(topLevelType, targetInst) { | |
| if (topLevelType === TOP_INPUT || topLevelType === TOP_CHANGE) { | |
| return getInstIfValueChanged(targetInst); | |
| } | |
| } | |
| function handleControlledInputBlur(node) { | |
| var state = node._wrapperState; | |
| if (!state || !state.controlled || node.type !== 'number') { | |
| return; | |
| } | |
| { | |
| // If controlled, assign the value attribute to the current value on blur | |
| setDefaultValue(node, 'number', node.value); | |
| } | |
| } | |
| /** | |
| * This plugin creates an `onChange` event that normalizes change events | |
| * across form elements. This event fires at a time when it's possible to | |
| * change the element's value without seeing a flicker. | |
| * | |
| * Supported elements are: | |
| * - input (see `isTextInputElement`) | |
| * - textarea | |
| * - select | |
| */ | |
| var ChangeEventPlugin = { | |
| eventTypes: eventTypes$1, | |
| _isInputEventSupported: isInputEventSupported, | |
| extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { | |
| var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window; | |
| var getTargetInstFunc, handleEventFunc; | |
| if (shouldUseChangeEvent(targetNode)) { | |
| getTargetInstFunc = getTargetInstForChangeEvent; | |
| } else if (isTextInputElement(targetNode)) { | |
| if (isInputEventSupported) { | |
| getTargetInstFunc = getTargetInstForInputOrChangeEvent; | |
| } else { | |
| getTargetInstFunc = getTargetInstForInputEventPolyfill; | |
| handleEventFunc = handleEventsForInputEventPolyfill; | |
| } | |
| } else if (shouldUseClickEvent(targetNode)) { | |
| getTargetInstFunc = getTargetInstForClickEvent; | |
| } | |
| if (getTargetInstFunc) { | |
| var inst = getTargetInstFunc(topLevelType, targetInst); | |
| if (inst) { | |
| var event = createAndAccumulateChangeEvent(inst, nativeEvent, nativeEventTarget); | |
| return event; | |
| } | |
| } | |
| if (handleEventFunc) { | |
| handleEventFunc(topLevelType, targetNode, targetInst); | |
| } // When blurring, set the value attribute for number inputs | |
| if (topLevelType === TOP_BLUR) { | |
| handleControlledInputBlur(targetNode); | |
| } | |
| } | |
| }; | |
| var SyntheticUIEvent = SyntheticEvent.extend({ | |
| view: null, | |
| detail: null | |
| }); | |
| /** | |
| * Translation from modifier key to the associated property in the event. | |
| * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers | |
| */ | |
| var modifierKeyToProp = { | |
| Alt: 'altKey', | |
| Control: 'ctrlKey', | |
| Meta: 'metaKey', | |
| Shift: 'shiftKey' | |
| }; // Older browsers (Safari <= 10, iOS Safari <= 10.2) do not support | |
| // getModifierState. If getModifierState is not supported, we map it to a set of | |
| // modifier keys exposed by the event. In this case, Lock-keys are not supported. | |
| function modifierStateGetter(keyArg) { | |
| var syntheticEvent = this; | |
| var nativeEvent = syntheticEvent.nativeEvent; | |
| if (nativeEvent.getModifierState) { | |
| return nativeEvent.getModifierState(keyArg); | |
| } | |
| var keyProp = modifierKeyToProp[keyArg]; | |
| return keyProp ? !!nativeEvent[keyProp] : false; | |
| } | |
| function getEventModifierState(nativeEvent) { | |
| return modifierStateGetter; | |
| } | |
| var previousScreenX = 0; | |
| var previousScreenY = 0; // Use flags to signal movementX/Y has already been set | |
| var isMovementXSet = false; | |
| var isMovementYSet = false; | |
| /** | |
| * @interface MouseEvent | |
| * @see http://www.w3.org/TR/DOM-Level-3-Events/ | |
| */ | |
| var SyntheticMouseEvent = SyntheticUIEvent.extend({ | |
| screenX: null, | |
| screenY: null, | |
| clientX: null, | |
| clientY: null, | |
| pageX: null, | |
| pageY: null, | |
| ctrlKey: null, | |
| shiftKey: null, | |
| altKey: null, | |
| metaKey: null, | |
| getModifierState: getEventModifierState, | |
| button: null, | |
| buttons: null, | |
| relatedTarget: function (event) { | |
| return event.relatedTarget || (event.fromElement === event.srcElement ? event.toElement : event.fromElement); | |
| }, | |
| movementX: function (event) { | |
| if ('movementX' in event) { | |
| return event.movementX; | |
| } | |
| var screenX = previousScreenX; | |
| previousScreenX = event.screenX; | |
| if (!isMovementXSet) { | |
| isMovementXSet = true; | |
| return 0; | |
| } | |
| return event.type === 'mousemove' ? event.screenX - screenX : 0; | |
| }, | |
| movementY: function (event) { | |
| if ('movementY' in event) { | |
| return event.movementY; | |
| } | |
| var screenY = previousScreenY; | |
| previousScreenY = event.screenY; | |
| if (!isMovementYSet) { | |
| isMovementYSet = true; | |
| return 0; | |
| } | |
| return event.type === 'mousemove' ? event.screenY - screenY : 0; | |
| } | |
| }); | |
| /** | |
| * @interface PointerEvent | |
| * @see http://www.w3.org/TR/pointerevents/ | |
| */ | |
| var SyntheticPointerEvent = SyntheticMouseEvent.extend({ | |
| pointerId: null, | |
| width: null, | |
| height: null, | |
| pressure: null, | |
| tangentialPressure: null, | |
| tiltX: null, | |
| tiltY: null, | |
| twist: null, | |
| pointerType: null, | |
| isPrimary: null | |
| }); | |
| var eventTypes$2 = { | |
| mouseEnter: { | |
| registrationName: 'onMouseEnter', | |
| dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER] | |
| }, | |
| mouseLeave: { | |
| registrationName: 'onMouseLeave', | |
| dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER] | |
| }, | |
| pointerEnter: { | |
| registrationName: 'onPointerEnter', | |
| dependencies: [TOP_POINTER_OUT, TOP_POINTER_OVER] | |
| }, | |
| pointerLeave: { | |
| registrationName: 'onPointerLeave', | |
| dependencies: [TOP_POINTER_OUT, TOP_POINTER_OVER] | |
| } | |
| }; | |
| var EnterLeaveEventPlugin = { | |
| eventTypes: eventTypes$2, | |
| /** | |
| * For almost every interaction we care about, there will be both a top-level | |
| * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that | |
| * we do not extract duplicate events. However, moving the mouse into the | |
| * browser from outside will not fire a `mouseout` event. In this case, we use | |
| * the `mouseover` top-level event. | |
| */ | |
| extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { | |
| var isOverEvent = topLevelType === TOP_MOUSE_OVER || topLevelType === TOP_POINTER_OVER; | |
| var isOutEvent = topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_POINTER_OUT; | |
| if (isOverEvent && (eventSystemFlags & IS_REPLAYED) === 0 && (nativeEvent.relatedTarget || nativeEvent.fromElement)) { | |
| // If this is an over event with a target, then we've already dispatched | |
| // the event in the out event of the other target. If this is replayed, | |
| // then it's because we couldn't dispatch against this target previously | |
| // so we have to do it now instead. | |
| return null; | |
| } | |
| if (!isOutEvent && !isOverEvent) { | |
| // Must not be a mouse or pointer in or out - ignoring. | |
| return null; | |
| } | |
| var win; | |
| if (nativeEventTarget.window === nativeEventTarget) { | |
| // `nativeEventTarget` is probably a window object. | |
| win = nativeEventTarget; | |
| } else { | |
| // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8. | |
| var doc = nativeEventTarget.ownerDocument; | |
| if (doc) { | |
| win = doc.defaultView || doc.parentWindow; | |
| } else { | |
| win = window; | |
| } | |
| } | |
| var from; | |
| var to; | |
| if (isOutEvent) { | |
| from = targetInst; | |
| var related = nativeEvent.relatedTarget || nativeEvent.toElement; | |
| to = related ? getClosestInstanceFromNode(related) : null; | |
| if (to !== null) { | |
| var nearestMounted = getNearestMountedFiber(to); | |
| if (to !== nearestMounted || to.tag !== HostComponent && to.tag !== HostText) { | |
| to = null; | |
| } | |
| } | |
| } else { | |
| // Moving to a node from outside the window. | |
| from = null; | |
| to = targetInst; | |
| } | |
| if (from === to) { | |
| // Nothing pertains to our managed components. | |
| return null; | |
| } | |
| var eventInterface, leaveEventType, enterEventType, eventTypePrefix; | |
| if (topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_MOUSE_OVER) { | |
| eventInterface = SyntheticMouseEvent; | |
| leaveEventType = eventTypes$2.mouseLeave; | |
| enterEventType = eventTypes$2.mouseEnter; | |
| eventTypePrefix = 'mouse'; | |
| } else if (topLevelType === TOP_POINTER_OUT || topLevelType === TOP_POINTER_OVER) { | |
| eventInterface = SyntheticPointerEvent; | |
| leaveEventType = eventTypes$2.pointerLeave; | |
| enterEventType = eventTypes$2.pointerEnter; | |
| eventTypePrefix = 'pointer'; | |
| } | |
| var fromNode = from == null ? win : getNodeFromInstance$1(from); | |
| var toNode = to == null ? win : getNodeFromInstance$1(to); | |
| var leave = eventInterface.getPooled(leaveEventType, from, nativeEvent, nativeEventTarget); | |
| leave.type = eventTypePrefix + 'leave'; | |
| leave.target = fromNode; | |
| leave.relatedTarget = toNode; | |
| var enter = eventInterface.getPooled(enterEventType, to, nativeEvent, nativeEventTarget); | |
| enter.type = eventTypePrefix + 'enter'; | |
| enter.target = toNode; | |
| enter.relatedTarget = fromNode; | |
| accumulateEnterLeaveDispatches(leave, enter, from, to); // If we are not processing the first ancestor, then we | |
| // should not process the same nativeEvent again, as we | |
| // will have already processed it in the first ancestor. | |
| if ((eventSystemFlags & IS_FIRST_ANCESTOR) === 0) { | |
| return [leave]; | |
| } | |
| return [leave, enter]; | |
| } | |
| }; | |
| /** | |
| * inlined Object.is polyfill to avoid requiring consumers ship their own | |
| * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is | |
| */ | |
| function is(x, y) { | |
| return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare | |
| ; | |
| } | |
| var objectIs = typeof Object.is === 'function' ? Object.is : is; | |
| var hasOwnProperty$2 = Object.prototype.hasOwnProperty; | |
| /** | |
| * Performs equality by iterating through keys on an object and returning false | |
| * when any key has values which are not strictly equal between the arguments. | |
| * Returns true when the values of all keys are strictly equal. | |
| */ | |
| function shallowEqual(objA, objB) { | |
| if (objectIs(objA, objB)) { | |
| return true; | |
| } | |
| if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { | |
| return false; | |
| } | |
| var keysA = Object.keys(objA); | |
| var keysB = Object.keys(objB); | |
| if (keysA.length !== keysB.length) { | |
| return false; | |
| } // Test for A's keys different from B. | |
| for (var i = 0; i < keysA.length; i++) { | |
| if (!hasOwnProperty$2.call(objB, keysA[i]) || !objectIs(objA[keysA[i]], objB[keysA[i]])) { | |
| return false; | |
| } | |
| } | |
| return true; | |
| } | |
| var skipSelectionChangeEvent = canUseDOM && 'documentMode' in document && document.documentMode <= 11; | |
| var eventTypes$3 = { | |
| select: { | |
| phasedRegistrationNames: { | |
| bubbled: 'onSelect', | |
| captured: 'onSelectCapture' | |
| }, | |
| dependencies: [TOP_BLUR, TOP_CONTEXT_MENU, TOP_DRAG_END, TOP_FOCUS, TOP_KEY_DOWN, TOP_KEY_UP, TOP_MOUSE_DOWN, TOP_MOUSE_UP, TOP_SELECTION_CHANGE] | |
| } | |
| }; | |
| var activeElement$1 = null; | |
| var activeElementInst$1 = null; | |
| var lastSelection = null; | |
| var mouseDown = false; | |
| /** | |
| * Get an object which is a unique representation of the current selection. | |
| * | |
| * The return value will not be consistent across nodes or browsers, but | |
| * two identical selections on the same node will return identical objects. | |
| * | |
| * @param {DOMElement} node | |
| * @return {object} | |
| */ | |
| function getSelection$1(node) { | |
| if ('selectionStart' in node && hasSelectionCapabilities(node)) { | |
| return { | |
| start: node.selectionStart, | |
| end: node.selectionEnd | |
| }; | |
| } else { | |
| var win = node.ownerDocument && node.ownerDocument.defaultView || window; | |
| var selection = win.getSelection(); | |
| return { | |
| anchorNode: selection.anchorNode, | |
| anchorOffset: selection.anchorOffset, | |
| focusNode: selection.focusNode, | |
| focusOffset: selection.focusOffset | |
| }; | |
| } | |
| } | |
| /** | |
| * Get document associated with the event target. | |
| * | |
| * @param {object} nativeEventTarget | |
| * @return {Document} | |
| */ | |
| function getEventTargetDocument(eventTarget) { | |
| return eventTarget.window === eventTarget ? eventTarget.document : eventTarget.nodeType === DOCUMENT_NODE ? eventTarget : eventTarget.ownerDocument; | |
| } | |
| /** | |
| * Poll selection to see whether it's changed. | |
| * | |
| * @param {object} nativeEvent | |
| * @param {object} nativeEventTarget | |
| * @return {?SyntheticEvent} | |
| */ | |
| function constructSelectEvent(nativeEvent, nativeEventTarget) { | |
| // Ensure we have the right element, and that the user is not dragging a | |
| // selection (this matches native `select` event behavior). In HTML5, select | |
| // fires only on input and textarea thus if there's no focused element we | |
| // won't dispatch. | |
| var doc = getEventTargetDocument(nativeEventTarget); | |
| if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement(doc)) { | |
| return null; | |
| } // Only fire when selection has actually changed. | |
| var currentSelection = getSelection$1(activeElement$1); | |
| if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) { | |
| lastSelection = currentSelection; | |
| var syntheticEvent = SyntheticEvent.getPooled(eventTypes$3.select, activeElementInst$1, nativeEvent, nativeEventTarget); | |
| syntheticEvent.type = 'select'; | |
| syntheticEvent.target = activeElement$1; | |
| accumulateTwoPhaseDispatches(syntheticEvent); | |
| return syntheticEvent; | |
| } | |
| return null; | |
| } | |
| /** | |
| * This plugin creates an `onSelect` event that normalizes select events | |
| * across form elements. | |
| * | |
| * Supported elements are: | |
| * - input (see `isTextInputElement`) | |
| * - textarea | |
| * - contentEditable | |
| * | |
| * This differs from native browser implementations in the following ways: | |
| * - Fires on contentEditable fields as well as inputs. | |
| * - Fires for collapsed selection. | |
| * - Fires after user input. | |
| */ | |
| var SelectEventPlugin = { | |
| eventTypes: eventTypes$3, | |
| extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, container) { | |
| var containerOrDoc = container || getEventTargetDocument(nativeEventTarget); // Track whether all listeners exists for this plugin. If none exist, we do | |
| // not extract events. See #3639. | |
| if (!containerOrDoc || !isListeningToAllDependencies('onSelect', containerOrDoc)) { | |
| return null; | |
| } | |
| var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window; | |
| switch (topLevelType) { | |
| // Track the input node that has focus. | |
| case TOP_FOCUS: | |
| if (isTextInputElement(targetNode) || targetNode.contentEditable === 'true') { | |
| activeElement$1 = targetNode; | |
| activeElementInst$1 = targetInst; | |
| lastSelection = null; | |
| } | |
| break; | |
| case TOP_BLUR: | |
| activeElement$1 = null; | |
| activeElementInst$1 = null; | |
| lastSelection = null; | |
| break; | |
| // Don't fire the event while the user is dragging. This matches the | |
| // semantics of the native select event. | |
| case TOP_MOUSE_DOWN: | |
| mouseDown = true; | |
| break; | |
| case TOP_CONTEXT_MENU: | |
| case TOP_MOUSE_UP: | |
| case TOP_DRAG_END: | |
| mouseDown = false; | |
| return constructSelectEvent(nativeEvent, nativeEventTarget); | |
| // Chrome and IE fire non-standard event when selection is changed (and | |
| // sometimes when it hasn't). IE's event fires out of order with respect | |
| // to key and input events on deletion, so we discard it. | |
| // | |
| // Firefox doesn't support selectionchange, so check selection status | |
| // after each key entry. The selection changes after keydown and before | |
| // keyup, but we check on keydown as well in the case of holding down a | |
| // key, when multiple keydown events are fired but only one keyup is. | |
| // This is also our approach for IE handling, for the reason above. | |
| case TOP_SELECTION_CHANGE: | |
| if (skipSelectionChangeEvent) { | |
| break; | |
| } | |
| // falls through | |
| case TOP_KEY_DOWN: | |
| case TOP_KEY_UP: | |
| return constructSelectEvent(nativeEvent, nativeEventTarget); | |
| } | |
| return null; | |
| } | |
| }; | |
| /** | |
| * @interface Event | |
| * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface | |
| * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent | |
| */ | |
| var SyntheticAnimationEvent = SyntheticEvent.extend({ | |
| animationName: null, | |
| elapsedTime: null, | |
| pseudoElement: null | |
| }); | |
| /** | |
| * @interface Event | |
| * @see http://www.w3.org/TR/clipboard-apis/ | |
| */ | |
| var SyntheticClipboardEvent = SyntheticEvent.extend({ | |
| clipboardData: function (event) { | |
| return 'clipboardData' in event ? event.clipboardData : window.clipboardData; | |
| } | |
| }); | |
| /** | |
| * @interface FocusEvent | |
| * @see http://www.w3.org/TR/DOM-Level-3-Events/ | |
| */ | |
| var SyntheticFocusEvent = SyntheticUIEvent.extend({ | |
| relatedTarget: null | |
| }); | |
| /** | |
| * `charCode` represents the actual "character code" and is safe to use with | |
| * `String.fromCharCode`. As such, only keys that correspond to printable | |
| * characters produce a valid `charCode`, the only exception to this is Enter. | |
| * The Tab-key is considered non-printable and does not have a `charCode`, | |
| * presumably because it does not produce a tab-character in browsers. | |
| * | |
| * @param {object} nativeEvent Native browser event. | |
| * @return {number} Normalized `charCode` property. | |
| */ | |
| function getEventCharCode(nativeEvent) { | |
| var charCode; | |
| var keyCode = nativeEvent.keyCode; | |
| if ('charCode' in nativeEvent) { | |
| charCode = nativeEvent.charCode; // FF does not set `charCode` for the Enter-key, check against `keyCode`. | |
| if (charCode === 0 && keyCode === 13) { | |
| charCode = 13; | |
| } | |
| } else { | |
| // IE8 does not implement `charCode`, but `keyCode` has the correct value. | |
| charCode = keyCode; | |
| } // IE and Edge (on Windows) and Chrome / Safari (on Windows and Linux) | |
| // report Enter as charCode 10 when ctrl is pressed. | |
| if (charCode === 10) { | |
| charCode = 13; | |
| } // Some non-printable keys are reported in `charCode`/`keyCode`, discard them. | |
| // Must not discard the (non-)printable Enter-key. | |
| if (charCode >= 32 || charCode === 13) { | |
| return charCode; | |
| } | |
| return 0; | |
| } | |
| /** | |
| * Normalization of deprecated HTML5 `key` values | |
| * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names | |
| */ | |
| var normalizeKey = { | |
| Esc: 'Escape', | |
| Spacebar: ' ', | |
| Left: 'ArrowLeft', | |
| Up: 'ArrowUp', | |
| Right: 'ArrowRight', | |
| Down: 'ArrowDown', | |
| Del: 'Delete', | |
| Win: 'OS', | |
| Menu: 'ContextMenu', | |
| Apps: 'ContextMenu', | |
| Scroll: 'ScrollLock', | |
| MozPrintableKey: 'Unidentified' | |
| }; | |
| /** | |
| * Translation from legacy `keyCode` to HTML5 `key` | |
| * Only special keys supported, all others depend on keyboard layout or browser | |
| * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names | |
| */ | |
| var translateToKey = { | |
| '8': 'Backspace', | |
| '9': 'Tab', | |
| '12': 'Clear', | |
| '13': 'Enter', | |
| '16': 'Shift', | |
| '17': 'Control', | |
| '18': 'Alt', | |
| '19': 'Pause', | |
| '20': 'CapsLock', | |
| '27': 'Escape', | |
| '32': ' ', | |
| '33': 'PageUp', | |
| '34': 'PageDown', | |
| '35': 'End', | |
| '36': 'Home', | |
| '37': 'ArrowLeft', | |
| '38': 'ArrowUp', | |
| '39': 'ArrowRight', | |
| '40': 'ArrowDown', | |
| '45': 'Insert', | |
| '46': 'Delete', | |
| '112': 'F1', | |
| '113': 'F2', | |
| '114': 'F3', | |
| '115': 'F4', | |
| '116': 'F5', | |
| '117': 'F6', | |
| '118': 'F7', | |
| '119': 'F8', | |
| '120': 'F9', | |
| '121': 'F10', | |
| '122': 'F11', | |
| '123': 'F12', | |
| '144': 'NumLock', | |
| '145': 'ScrollLock', | |
| '224': 'Meta' | |
| }; | |
| /** | |
| * @param {object} nativeEvent Native browser event. | |
| * @return {string} Normalized `key` property. | |
| */ | |
| function getEventKey(nativeEvent) { | |
| if (nativeEvent.key) { | |
| // Normalize inconsistent values reported by browsers due to | |
| // implementations of a working draft specification. | |
| // FireFox implements `key` but returns `MozPrintableKey` for all | |
| // printable characters (normalized to `Unidentified`), ignore it. | |
| var key = normalizeKey[nativeEvent.key] || nativeEvent.key; | |
| if (key !== 'Unidentified') { | |
| return key; | |
| } | |
| } // Browser does not implement `key`, polyfill as much of it as we can. | |
| if (nativeEvent.type === 'keypress') { | |
| var charCode = getEventCharCode(nativeEvent); // The enter-key is technically both printable and non-printable and can | |
| // thus be captured by `keypress`, no other non-printable key should. | |
| return charCode === 13 ? 'Enter' : String.fromCharCode(charCode); | |
| } | |
| if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') { | |
| // While user keyboard layout determines the actual meaning of each | |
| // `keyCode` value, almost all function keys have a universal value. | |
| return translateToKey[nativeEvent.keyCode] || 'Unidentified'; | |
| } | |
| return ''; | |
| } | |
| /** | |
| * @interface KeyboardEvent | |
| * @see http://www.w3.org/TR/DOM-Level-3-Events/ | |
| */ | |
| var SyntheticKeyboardEvent = SyntheticUIEvent.extend({ | |
| key: getEventKey, | |
| location: null, | |
| ctrlKey: null, | |
| shiftKey: null, | |
| altKey: null, | |
| metaKey: null, | |
| repeat: null, | |
| locale: null, | |
| getModifierState: getEventModifierState, | |
| // Legacy Interface | |
| charCode: function (event) { | |
| // `charCode` is the result of a KeyPress event and represents the value of | |
| // the actual printable character. | |
| // KeyPress is deprecated, but its replacement is not yet final and not | |
| // implemented in any major browser. Only KeyPress has charCode. | |
| if (event.type === 'keypress') { | |
| return getEventCharCode(event); | |
| } | |
| return 0; | |
| }, | |
| keyCode: function (event) { | |
| // `keyCode` is the result of a KeyDown/Up event and represents the value of | |
| // physical keyboard key. | |
| // The actual meaning of the value depends on the users' keyboard layout | |
| // which cannot be detected. Assuming that it is a US keyboard layout | |
| // provides a surprisingly accurate mapping for US and European users. | |
| // Due to this, it is left to the user to implement at this time. | |
| if (event.type === 'keydown' || event.type === 'keyup') { | |
| return event.keyCode; | |
| } | |
| return 0; | |
| }, | |
| which: function (event) { | |
| // `which` is an alias for either `keyCode` or `charCode` depending on the | |
| // type of the event. | |
| if (event.type === 'keypress') { | |
| return getEventCharCode(event); | |
| } | |
| if (event.type === 'keydown' || event.type === 'keyup') { | |
| return event.keyCode; | |
| } | |
| return 0; | |
| } | |
| }); | |
| /** | |
| * @interface DragEvent | |
| * @see http://www.w3.org/TR/DOM-Level-3-Events/ | |
| */ | |
| var SyntheticDragEvent = SyntheticMouseEvent.extend({ | |
| dataTransfer: null | |
| }); | |
| /** | |
| * @interface TouchEvent | |
| * @see http://www.w3.org/TR/touch-events/ | |
| */ | |
| var SyntheticTouchEvent = SyntheticUIEvent.extend({ | |
| touches: null, | |
| targetTouches: null, | |
| changedTouches: null, | |
| altKey: null, | |
| metaKey: null, | |
| ctrlKey: null, | |
| shiftKey: null, | |
| getModifierState: getEventModifierState | |
| }); | |
| /** | |
| * @interface Event | |
| * @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events- | |
| * @see https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent | |
| */ | |
| var SyntheticTransitionEvent = SyntheticEvent.extend({ | |
| propertyName: null, | |
| elapsedTime: null, | |
| pseudoElement: null | |
| }); | |
| /** | |
| * @interface WheelEvent | |
| * @see http://www.w3.org/TR/DOM-Level-3-Events/ | |
| */ | |
| var SyntheticWheelEvent = SyntheticMouseEvent.extend({ | |
| deltaX: function (event) { | |
| return 'deltaX' in event ? event.deltaX : // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive). | |
| 'wheelDeltaX' in event ? -event.wheelDeltaX : 0; | |
| }, | |
| deltaY: function (event) { | |
| return 'deltaY' in event ? event.deltaY : // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive). | |
| 'wheelDeltaY' in event ? -event.wheelDeltaY : // Fallback to `wheelDelta` for IE<9 and normalize (down is positive). | |
| 'wheelDelta' in event ? -event.wheelDelta : 0; | |
| }, | |
| deltaZ: null, | |
| // Browsers without "deltaMode" is reporting in raw wheel delta where one | |
| // notch on the scroll is always +/- 120, roughly equivalent to pixels. | |
| // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or | |
| // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size. | |
| deltaMode: null | |
| }); | |
| var knownHTMLTopLevelTypes = [TOP_ABORT, TOP_CANCEL, TOP_CAN_PLAY, TOP_CAN_PLAY_THROUGH, TOP_CLOSE, TOP_DURATION_CHANGE, TOP_EMPTIED, TOP_ENCRYPTED, TOP_ENDED, TOP_ERROR, TOP_INPUT, TOP_INVALID, TOP_LOAD, TOP_LOADED_DATA, TOP_LOADED_METADATA, TOP_LOAD_START, TOP_PAUSE, TOP_PLAY, TOP_PLAYING, TOP_PROGRESS, TOP_RATE_CHANGE, TOP_RESET, TOP_SEEKED, TOP_SEEKING, TOP_STALLED, TOP_SUBMIT, TOP_SUSPEND, TOP_TIME_UPDATE, TOP_TOGGLE, TOP_VOLUME_CHANGE, TOP_WAITING]; | |
| var SimpleEventPlugin = { | |
| // simpleEventPluginEventTypes gets populated from | |
| // the DOMEventProperties module. | |
| eventTypes: simpleEventPluginEventTypes, | |
| extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { | |
| var dispatchConfig = topLevelEventsToDispatchConfig.get(topLevelType); | |
| if (!dispatchConfig) { | |
| return null; | |
| } | |
| var EventConstructor; | |
| switch (topLevelType) { | |
| case TOP_KEY_PRESS: | |
| // Firefox creates a keypress event for function keys too. This removes | |
| // the unwanted keypress events. Enter is however both printable and | |
| // non-printable. One would expect Tab to be as well (but it isn't). | |
| if (getEventCharCode(nativeEvent) === 0) { | |
| return null; | |
| } | |
| /* falls through */ | |
| case TOP_KEY_DOWN: | |
| case TOP_KEY_UP: | |
| EventConstructor = SyntheticKeyboardEvent; | |
| break; | |
| case TOP_BLUR: | |
| case TOP_FOCUS: | |
| EventConstructor = SyntheticFocusEvent; | |
| break; | |
| case TOP_CLICK: | |
| // Firefox creates a click event on right mouse clicks. This removes the | |
| // unwanted click events. | |
| if (nativeEvent.button === 2) { | |
| return null; | |
| } | |
| /* falls through */ | |
| case TOP_AUX_CLICK: | |
| case TOP_DOUBLE_CLICK: | |
| case TOP_MOUSE_DOWN: | |
| case TOP_MOUSE_MOVE: | |
| case TOP_MOUSE_UP: // TODO: Disabled elements should not respond to mouse events | |
| /* falls through */ | |
| case TOP_MOUSE_OUT: | |
| case TOP_MOUSE_OVER: | |
| case TOP_CONTEXT_MENU: | |
| EventConstructor = SyntheticMouseEvent; | |
| break; | |
| case TOP_DRAG: | |
| case TOP_DRAG_END: | |
| case TOP_DRAG_ENTER: | |
| case TOP_DRAG_EXIT: | |
| case TOP_DRAG_LEAVE: | |
| case TOP_DRAG_OVER: | |
| case TOP_DRAG_START: | |
| case TOP_DROP: | |
| EventConstructor = SyntheticDragEvent; | |
| break; | |
| case TOP_TOUCH_CANCEL: | |
| case TOP_TOUCH_END: | |
| case TOP_TOUCH_MOVE: | |
| case TOP_TOUCH_START: | |
| EventConstructor = SyntheticTouchEvent; | |
| break; | |
| case TOP_ANIMATION_END: | |
| case TOP_ANIMATION_ITERATION: | |
| case TOP_ANIMATION_START: | |
| EventConstructor = SyntheticAnimationEvent; | |
| break; | |
| case TOP_TRANSITION_END: | |
| EventConstructor = SyntheticTransitionEvent; | |
| break; | |
| case TOP_SCROLL: | |
| EventConstructor = SyntheticUIEvent; | |
| break; | |
| case TOP_WHEEL: | |
| EventConstructor = SyntheticWheelEvent; | |
| break; | |
| case TOP_COPY: | |
| case TOP_CUT: | |
| case TOP_PASTE: | |
| EventConstructor = SyntheticClipboardEvent; | |
| break; | |
| case TOP_GOT_POINTER_CAPTURE: | |
| case TOP_LOST_POINTER_CAPTURE: | |
| case TOP_POINTER_CANCEL: | |
| case TOP_POINTER_DOWN: | |
| case TOP_POINTER_MOVE: | |
| case TOP_POINTER_OUT: | |
| case TOP_POINTER_OVER: | |
| case TOP_POINTER_UP: | |
| EventConstructor = SyntheticPointerEvent; | |
| break; | |
| default: | |
| { | |
| if (knownHTMLTopLevelTypes.indexOf(topLevelType) === -1) { | |
| error('SimpleEventPlugin: Unhandled event type, `%s`. This warning ' + 'is likely caused by a bug in React. Please file an issue.', topLevelType); | |
| } | |
| } // HTML Events | |
| // @see http://www.w3.org/TR/html5/index.html#events-0 | |
| EventConstructor = SyntheticEvent; | |
| break; | |
| } | |
| var event = EventConstructor.getPooled(dispatchConfig, targetInst, nativeEvent, nativeEventTarget); | |
| accumulateTwoPhaseDispatches(event); | |
| return event; | |
| } | |
| }; | |
| /** | |
| * Specifies a deterministic ordering of `EventPlugin`s. A convenient way to | |
| * reason about plugins, without having to package every one of them. This | |
| * is better than having plugins be ordered in the same order that they | |
| * are injected because that ordering would be influenced by the packaging order. | |
| * `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that | |
| * preventing default on events is convenient in `SimpleEventPlugin` handlers. | |
| */ | |
| var DOMEventPluginOrder = ['ResponderEventPlugin', 'SimpleEventPlugin', 'EnterLeaveEventPlugin', 'ChangeEventPlugin', 'SelectEventPlugin', 'BeforeInputEventPlugin']; | |
| /** | |
| * Inject modules for resolving DOM hierarchy and plugin ordering. | |
| */ | |
| injectEventPluginOrder(DOMEventPluginOrder); | |
| setComponentTree(getFiberCurrentPropsFromNode$1, getInstanceFromNode$1, getNodeFromInstance$1); | |
| /** | |
| * Some important event plugins included by default (without having to require | |
| * them). | |
| */ | |
| injectEventPluginsByName({ | |
| SimpleEventPlugin: SimpleEventPlugin, | |
| EnterLeaveEventPlugin: EnterLeaveEventPlugin, | |
| ChangeEventPlugin: ChangeEventPlugin, | |
| SelectEventPlugin: SelectEventPlugin, | |
| BeforeInputEventPlugin: BeforeInputEventPlugin | |
| }); | |
| // Prefix measurements so that it's possible to filter them. | |
| // Longer prefixes are hard to read in DevTools. | |
| var reactEmoji = "\u269B"; | |
| var warningEmoji = "\u26D4"; | |
| var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function'; // Keep track of current fiber so that we know the path to unwind on pause. | |
| // TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them? | |
| var currentFiber = null; // If we're in the middle of user code, which fiber and method is it? | |
| // Reusing `currentFiber` would be confusing for this because user code fiber | |
| // can change during commit phase too, but we don't need to unwind it (since | |
| // lifecycles in the commit phase don't resemble a tree). | |
| var currentPhase = null; | |
| var currentPhaseFiber = null; // Did lifecycle hook schedule an update? This is often a performance problem, | |
| // so we will keep track of it, and include it in the report. | |
| // Track commits caused by cascading updates. | |
| var isCommitting = false; | |
| var hasScheduledUpdateInCurrentCommit = false; | |
| var hasScheduledUpdateInCurrentPhase = false; | |
| var commitCountInCurrentWorkLoop = 0; | |
| var effectCountInCurrentCommit = 0; | |
| // to avoid stretch the commit phase with measurement overhead. | |
| var labelsInCurrentCommit = new Set(); | |
| var formatMarkName = function (markName) { | |
| return reactEmoji + " " + markName; | |
| }; | |
| var formatLabel = function (label, warning) { | |
| var prefix = warning ? warningEmoji + " " : reactEmoji + " "; | |
| var suffix = warning ? " Warning: " + warning : ''; | |
| return "" + prefix + label + suffix; | |
| }; | |
| var beginMark = function (markName) { | |
| performance.mark(formatMarkName(markName)); | |
| }; | |
| var clearMark = function (markName) { | |
| performance.clearMarks(formatMarkName(markName)); | |
| }; | |
| var endMark = function (label, markName, warning) { | |
| var formattedMarkName = formatMarkName(markName); | |
| var formattedLabel = formatLabel(label, warning); | |
| try { | |
| performance.measure(formattedLabel, formattedMarkName); | |
| } catch (err) {} // If previous mark was missing for some reason, this will throw. | |
| // This could only happen if React crashed in an unexpected place earlier. | |
| // Don't pile on with more errors. | |
| // Clear marks immediately to avoid growing buffer. | |
| performance.clearMarks(formattedMarkName); | |
| performance.clearMeasures(formattedLabel); | |
| }; | |
| var getFiberMarkName = function (label, debugID) { | |
| return label + " (#" + debugID + ")"; | |
| }; | |
| var getFiberLabel = function (componentName, isMounted, phase) { | |
| if (phase === null) { | |
| // These are composite component total time measurements. | |
| return componentName + " [" + (isMounted ? 'update' : 'mount') + "]"; | |
| } else { | |
| // Composite component methods. | |
| return componentName + "." + phase; | |
| } | |
| }; | |
| var beginFiberMark = function (fiber, phase) { | |
| var componentName = getComponentName(fiber.type) || 'Unknown'; | |
| var debugID = fiber._debugID; | |
| var isMounted = fiber.alternate !== null; | |
| var label = getFiberLabel(componentName, isMounted, phase); | |
| if (isCommitting && labelsInCurrentCommit.has(label)) { | |
| // During the commit phase, we don't show duplicate labels because | |
| // there is a fixed overhead for every measurement, and we don't | |
| // want to stretch the commit phase beyond necessary. | |
| return false; | |
| } | |
| labelsInCurrentCommit.add(label); | |
| var markName = getFiberMarkName(label, debugID); | |
| beginMark(markName); | |
| return true; | |
| }; | |
| var clearFiberMark = function (fiber, phase) { | |
| var componentName = getComponentName(fiber.type) || 'Unknown'; | |
| var debugID = fiber._debugID; | |
| var isMounted = fiber.alternate !== null; | |
| var label = getFiberLabel(componentName, isMounted, phase); | |
| var markName = getFiberMarkName(label, debugID); | |
| clearMark(markName); | |
| }; | |
| var endFiberMark = function (fiber, phase, warning) { | |
| var componentName = getComponentName(fiber.type) || 'Unknown'; | |
| var debugID = fiber._debugID; | |
| var isMounted = fiber.alternate !== null; | |
| var label = getFiberLabel(componentName, isMounted, phase); | |
| var markName = getFiberMarkName(label, debugID); | |
| endMark(label, markName, warning); | |
| }; | |
| var shouldIgnoreFiber = function (fiber) { | |
| // Host components should be skipped in the timeline. | |
| // We could check typeof fiber.type, but does this work with RN? | |
| switch (fiber.tag) { | |
| case HostRoot: | |
| case HostComponent: | |
| case HostText: | |
| case HostPortal: | |
| case Fragment: | |
| case ContextProvider: | |
| case ContextConsumer: | |
| case Mode: | |
| return true; | |
| default: | |
| return false; | |
| } | |
| }; | |
| var clearPendingPhaseMeasurement = function () { | |
| if (currentPhase !== null && currentPhaseFiber !== null) { | |
| clearFiberMark(currentPhaseFiber, currentPhase); | |
| } | |
| currentPhaseFiber = null; | |
| currentPhase = null; | |
| hasScheduledUpdateInCurrentPhase = false; | |
| }; | |
| var pauseTimers = function () { | |
| // Stops all currently active measurements so that they can be resumed | |
| // if we continue in a later deferred loop from the same unit of work. | |
| var fiber = currentFiber; | |
| while (fiber) { | |
| if (fiber._debugIsCurrentlyTiming) { | |
| endFiberMark(fiber, null, null); | |
| } | |
| fiber = fiber.return; | |
| } | |
| }; | |
| var resumeTimersRecursively = function (fiber) { | |
| if (fiber.return !== null) { | |
| resumeTimersRecursively(fiber.return); | |
| } | |
| if (fiber._debugIsCurrentlyTiming) { | |
| beginFiberMark(fiber, null); | |
| } | |
| }; | |
| var resumeTimers = function () { | |
| // Resumes all measurements that were active during the last deferred loop. | |
| if (currentFiber !== null) { | |
| resumeTimersRecursively(currentFiber); | |
| } | |
| }; | |
| function recordEffect() { | |
| { | |
| effectCountInCurrentCommit++; | |
| } | |
| } | |
| function recordScheduleUpdate() { | |
| { | |
| if (isCommitting) { | |
| hasScheduledUpdateInCurrentCommit = true; | |
| } | |
| if (currentPhase !== null && currentPhase !== 'componentWillMount' && currentPhase !== 'componentWillReceiveProps') { | |
| hasScheduledUpdateInCurrentPhase = true; | |
| } | |
| } | |
| } | |
| function startWorkTimer(fiber) { | |
| { | |
| if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { | |
| return; | |
| } // If we pause, this is the fiber to unwind from. | |
| currentFiber = fiber; | |
| if (!beginFiberMark(fiber, null)) { | |
| return; | |
| } | |
| fiber._debugIsCurrentlyTiming = true; | |
| } | |
| } | |
| function cancelWorkTimer(fiber) { | |
| { | |
| if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { | |
| return; | |
| } // Remember we shouldn't complete measurement for this fiber. | |
| // Otherwise flamechart will be deep even for small updates. | |
| fiber._debugIsCurrentlyTiming = false; | |
| clearFiberMark(fiber, null); | |
| } | |
| } | |
| function stopWorkTimer(fiber) { | |
| { | |
| if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { | |
| return; | |
| } // If we pause, its parent is the fiber to unwind from. | |
| currentFiber = fiber.return; | |
| if (!fiber._debugIsCurrentlyTiming) { | |
| return; | |
| } | |
| fiber._debugIsCurrentlyTiming = false; | |
| endFiberMark(fiber, null, null); | |
| } | |
| } | |
| function stopFailedWorkTimer(fiber) { | |
| { | |
| if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { | |
| return; | |
| } // If we pause, its parent is the fiber to unwind from. | |
| currentFiber = fiber.return; | |
| if (!fiber._debugIsCurrentlyTiming) { | |
| return; | |
| } | |
| fiber._debugIsCurrentlyTiming = false; | |
| var warning = fiber.tag === SuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary'; | |
| endFiberMark(fiber, null, warning); | |
| } | |
| } | |
| function startPhaseTimer(fiber, phase) { | |
| { | |
| if (!supportsUserTiming) { | |
| return; | |
| } | |
| clearPendingPhaseMeasurement(); | |
| if (!beginFiberMark(fiber, phase)) { | |
| return; | |
| } | |
| currentPhaseFiber = fiber; | |
| currentPhase = phase; | |
| } | |
| } | |
| function stopPhaseTimer() { | |
| { | |
| if (!supportsUserTiming) { | |
| return; | |
| } | |
| if (currentPhase !== null && currentPhaseFiber !== null) { | |
| var warning = hasScheduledUpdateInCurrentPhase ? 'Scheduled a cascading update' : null; | |
| endFiberMark(currentPhaseFiber, currentPhase, warning); | |
| } | |
| currentPhase = null; | |
| currentPhaseFiber = null; | |
| } | |
| } | |
| function startWorkLoopTimer(nextUnitOfWork) { | |
| { | |
| currentFiber = nextUnitOfWork; | |
| if (!supportsUserTiming) { | |
| return; | |
| } | |
| commitCountInCurrentWorkLoop = 0; // This is top level call. | |
| // Any other measurements are performed within. | |
| beginMark('(React Tree Reconciliation)'); // Resume any measurements that were in progress during the last loop. | |
| resumeTimers(); | |
| } | |
| } | |
| function stopWorkLoopTimer(interruptedBy, didCompleteRoot) { | |
| { | |
| if (!supportsUserTiming) { | |
| return; | |
| } | |
| var warning = null; | |
| if (interruptedBy !== null) { | |
| if (interruptedBy.tag === HostRoot) { | |
| warning = 'A top-level update interrupted the previous render'; | |
| } else { | |
| var componentName = getComponentName(interruptedBy.type) || 'Unknown'; | |
| warning = "An update to " + componentName + " interrupted the previous render"; | |
| } | |
| } else if (commitCountInCurrentWorkLoop > 1) { | |
| warning = 'There were cascading updates'; | |
| } | |
| commitCountInCurrentWorkLoop = 0; | |
| var label = didCompleteRoot ? '(React Tree Reconciliation: Completed Root)' : '(React Tree Reconciliation: Yielded)'; // Pause any measurements until the next loop. | |
| pauseTimers(); | |
| endMark(label, '(React Tree Reconciliation)', warning); | |
| } | |
| } | |
| function startCommitTimer() { | |
| { | |
| if (!supportsUserTiming) { | |
| return; | |
| } | |
| isCommitting = true; | |
| hasScheduledUpdateInCurrentCommit = false; | |
| labelsInCurrentCommit.clear(); | |
| beginMark('(Committing Changes)'); | |
| } | |
| } | |
| function stopCommitTimer() { | |
| { | |
| if (!supportsUserTiming) { | |
| return; | |
| } | |
| var warning = null; | |
| if (hasScheduledUpdateInCurrentCommit) { | |
| warning = 'Lifecycle hook scheduled a cascading update'; | |
| } else if (commitCountInCurrentWorkLoop > 0) { | |
| warning = 'Caused by a cascading update in earlier commit'; | |
| } | |
| hasScheduledUpdateInCurrentCommit = false; | |
| commitCountInCurrentWorkLoop++; | |
| isCommitting = false; | |
| labelsInCurrentCommit.clear(); | |
| endMark('(Committing Changes)', '(Committing Changes)', warning); | |
| } | |
| } | |
| function startCommitSnapshotEffectsTimer() { | |
| { | |
| if (!supportsUserTiming) { | |
| return; | |
| } | |
| effectCountInCurrentCommit = 0; | |
| beginMark('(Committing Snapshot Effects)'); | |
| } | |
| } | |
| function stopCommitSnapshotEffectsTimer() { | |
| { | |
| if (!supportsUserTiming) { | |
| return; | |
| } | |
| var count = effectCountInCurrentCommit; | |
| effectCountInCurrentCommit = 0; | |
| endMark("(Committing Snapshot Effects: " + count + " Total)", '(Committing Snapshot Effects)', null); | |
| } | |
| } | |
| function startCommitHostEffectsTimer() { | |
| { | |
| if (!supportsUserTiming) { | |
| return; | |
| } | |
| effectCountInCurrentCommit = 0; | |
| beginMark('(Committing Host Effects)'); | |
| } | |
| } | |
| function stopCommitHostEffectsTimer() { | |
| { | |
| if (!supportsUserTiming) { | |
| return; | |
| } | |
| var count = effectCountInCurrentCommit; | |
| effectCountInCurrentCommit = 0; | |
| endMark("(Committing Host Effects: " + count + " Total)", '(Committing Host Effects)', null); | |
| } | |
| } | |
| function startCommitLifeCyclesTimer() { | |
| { | |
| if (!supportsUserTiming) { | |
| return; | |
| } | |
| effectCountInCurrentCommit = 0; | |
| beginMark('(Calling Lifecycle Methods)'); | |
| } | |
| } | |
| function stopCommitLifeCyclesTimer() { | |
| { | |
| if (!supportsUserTiming) { | |
| return; | |
| } | |
| var count = effectCountInCurrentCommit; | |
| effectCountInCurrentCommit = 0; | |
| endMark("(Calling Lifecycle Methods: " + count + " Total)", '(Calling Lifecycle Methods)', null); | |
| } | |
| } | |
| var valueStack = []; | |
| var fiberStack; | |
| { | |
| fiberStack = []; | |
| } | |
| var index = -1; | |
| function createCursor(defaultValue) { | |
| return { | |
| current: defaultValue | |
| }; | |
| } | |
| function pop(cursor, fiber) { | |
| if (index < 0) { | |
| { | |
| error('Unexpected pop.'); | |
| } | |
| return; | |
| } | |
| { | |
| if (fiber !== fiberStack[index]) { | |
| error('Unexpected Fiber popped.'); | |
| } | |
| } | |
| cursor.current = valueStack[index]; | |
| valueStack[index] = null; | |
| { | |
| fiberStack[index] = null; | |
| } | |
| index--; | |
| } | |
| function push(cursor, value, fiber) { | |
| index++; | |
| valueStack[index] = cursor.current; | |
| { | |
| fiberStack[index] = fiber; | |
| } | |
| cursor.current = value; | |
| } | |
| var warnedAboutMissingGetChildContext; | |
| { | |
| warnedAboutMissingGetChildContext = {}; | |
| } | |
| var emptyContextObject = {}; | |
| { | |
| Object.freeze(emptyContextObject); | |
| } // A cursor to the current merged context object on the stack. | |
| var contextStackCursor = createCursor(emptyContextObject); // A cursor to a boolean indicating whether the context has changed. | |
| var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack. | |
| // We use this to get access to the parent context after we have already | |
| // pushed the next context provider, and now need to merge their contexts. | |
| var previousContext = emptyContextObject; | |
| function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) { | |
| { | |
| if (didPushOwnContextIfProvider && isContextProvider(Component)) { | |
| // If the fiber is a context provider itself, when we read its context | |
| // we may have already pushed its own child context on the stack. A context | |
| // provider should not "see" its own child context. Therefore we read the | |
| // previous (parent) context instead for a context provider. | |
| return previousContext; | |
| } | |
| return contextStackCursor.current; | |
| } | |
| } | |
| function cacheContext(workInProgress, unmaskedContext, maskedContext) { | |
| { | |
| var instance = workInProgress.stateNode; | |
| instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext; | |
| instance.__reactInternalMemoizedMaskedChildContext = maskedContext; | |
| } | |
| } | |
| function getMaskedContext(workInProgress, unmaskedContext) { | |
| { | |
| var type = workInProgress.type; | |
| var contextTypes = type.contextTypes; | |
| if (!contextTypes) { | |
| return emptyContextObject; | |
| } // Avoid recreating masked context unless unmasked context has changed. | |
| // Failing to do this will result in unnecessary calls to componentWillReceiveProps. | |
| // This may trigger infinite loops if componentWillReceiveProps calls setState. | |
| var instance = workInProgress.stateNode; | |
| if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { | |
| return instance.__reactInternalMemoizedMaskedChildContext; | |
| } | |
| var context = {}; | |
| for (var key in contextTypes) { | |
| context[key] = unmaskedContext[key]; | |
| } | |
| { | |
| var name = getComponentName(type) || 'Unknown'; | |
| checkPropTypes(contextTypes, context, 'context', name, getCurrentFiberStackInDev); | |
| } // Cache unmasked context so we can avoid recreating masked context unless necessary. | |
| // Context is created before the class component is instantiated so check for instance. | |
| if (instance) { | |
| cacheContext(workInProgress, unmaskedContext, context); | |
| } | |
| return context; | |
| } | |
| } | |
| function hasContextChanged() { | |
| { | |
| return didPerformWorkStackCursor.current; | |
| } | |
| } | |
| function isContextProvider(type) { | |
| { | |
| var childContextTypes = type.childContextTypes; | |
| return childContextTypes !== null && childContextTypes !== undefined; | |
| } | |
| } | |
| function popContext(fiber) { | |
| { | |
| pop(didPerformWorkStackCursor, fiber); | |
| pop(contextStackCursor, fiber); | |
| } | |
| } | |
| function popTopLevelContextObject(fiber) { | |
| { | |
| pop(didPerformWorkStackCursor, fiber); | |
| pop(contextStackCursor, fiber); | |
| } | |
| } | |
| function pushTopLevelContextObject(fiber, context, didChange) { | |
| { | |
| if (!(contextStackCursor.current === emptyContextObject)) { | |
| { | |
| throw Error( "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." ); | |
| } | |
| } | |
| push(contextStackCursor, context, fiber); | |
| push(didPerformWorkStackCursor, didChange, fiber); | |
| } | |
| } | |
| function processChildContext(fiber, type, parentContext) { | |
| { | |
| var instance = fiber.stateNode; | |
| var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future. | |
| // It has only been added in Fiber to match the (unintentional) behavior in Stack. | |
| if (typeof instance.getChildContext !== 'function') { | |
| { | |
| var componentName = getComponentName(type) || 'Unknown'; | |
| if (!warnedAboutMissingGetChildContext[componentName]) { | |
| warnedAboutMissingGetChildContext[componentName] = true; | |
| error('%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName); | |
| } | |
| } | |
| return parentContext; | |
| } | |
| var childContext; | |
| startPhaseTimer(fiber, 'getChildContext'); | |
| childContext = instance.getChildContext(); | |
| stopPhaseTimer(); | |
| for (var contextKey in childContext) { | |
| if (!(contextKey in childContextTypes)) { | |
| { | |
| throw Error( (getComponentName(type) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes." ); | |
| } | |
| } | |
| } | |
| { | |
| var name = getComponentName(type) || 'Unknown'; | |
| checkPropTypes(childContextTypes, childContext, 'child context', name, // In practice, there is one case in which we won't get a stack. It's when | |
| // somebody calls unstable_renderSubtreeIntoContainer() and we process | |
| // context from the parent component instance. The stack will be missing | |
| // because it's outside of the reconciliation, and so the pointer has not | |
| // been set. This is rare and doesn't matter. We'll also remove that API. | |
| getCurrentFiberStackInDev); | |
| } | |
| return _assign({}, parentContext, {}, childContext); | |
| } | |
| } | |
| function pushContextProvider(workInProgress) { | |
| { | |
| var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity. | |
| // If the instance does not exist yet, we will push null at first, | |
| // and replace it on the stack later when invalidating the context. | |
| var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject; // Remember the parent context so we can merge with it later. | |
| // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates. | |
| previousContext = contextStackCursor.current; | |
| push(contextStackCursor, memoizedMergedChildContext, workInProgress); | |
| push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress); | |
| return true; | |
| } | |
| } | |
| function invalidateContextProvider(workInProgress, type, didChange) { | |
| { | |
| var instance = workInProgress.stateNode; | |
| if (!instance) { | |
| { | |
| throw Error( "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." ); | |
| } | |
| } | |
| if (didChange) { | |
| // Merge parent and own context. | |
| // Skip this if we're not updating due to sCU. | |
| // This avoids unnecessarily recomputing memoized values. | |
| var mergedContext = processChildContext(workInProgress, type, previousContext); | |
| instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one. | |
| // It is important to unwind the context in the reverse order. | |
| pop(didPerformWorkStackCursor, workInProgress); | |
| pop(contextStackCursor, workInProgress); // Now push the new context and mark that it has changed. | |
| push(contextStackCursor, mergedContext, workInProgress); | |
| push(didPerformWorkStackCursor, didChange, workInProgress); | |
| } else { | |
| pop(didPerformWorkStackCursor, workInProgress); | |
| push(didPerformWorkStackCursor, didChange, workInProgress); | |
| } | |
| } | |
| } | |
| function findCurrentUnmaskedContext(fiber) { | |
| { | |
| // Currently this is only used with renderSubtreeIntoContainer; not sure if it | |
| // makes sense elsewhere | |
| if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) { | |
| { | |
| throw Error( "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." ); | |
| } | |
| } | |
| var node = fiber; | |
| do { | |
| switch (node.tag) { | |
| case HostRoot: | |
| return node.stateNode.context; | |
| case ClassComponent: | |
| { | |
| var Component = node.type; | |
| if (isContextProvider(Component)) { | |
| return node.stateNode.__reactInternalMemoizedMergedChildContext; | |
| } | |
| break; | |
| } | |
| } | |
| node = node.return; | |
| } while (node !== null); | |
| { | |
| { | |
| throw Error( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); | |
| } | |
| } | |
| } | |
| } | |
| var LegacyRoot = 0; | |
| var BlockingRoot = 1; | |
| var ConcurrentRoot = 2; | |
| var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, | |
| Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, | |
| Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, | |
| Scheduler_shouldYield = Scheduler.unstable_shouldYield, | |
| Scheduler_requestPaint = Scheduler.unstable_requestPaint, | |
| Scheduler_now = Scheduler.unstable_now, | |
| Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel, | |
| Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, | |
| Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, | |
| Scheduler_NormalPriority = Scheduler.unstable_NormalPriority, | |
| Scheduler_LowPriority = Scheduler.unstable_LowPriority, | |
| Scheduler_IdlePriority = Scheduler.unstable_IdlePriority; | |
| { | |
| // Provide explicit error message when production+profiling bundle of e.g. | |
| // react-dom is used with production (non-profiling) bundle of | |
| // scheduler/tracing | |
| if (!(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null)) { | |
| { | |
| throw Error( "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" ); | |
| } | |
| } | |
| } | |
| var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use | |
| // ascending numbers so we can compare them like numbers. They start at 90 to | |
| // avoid clashing with Scheduler's priorities. | |
| var ImmediatePriority = 99; | |
| var UserBlockingPriority$1 = 98; | |
| var NormalPriority = 97; | |
| var LowPriority = 96; | |
| var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only. | |
| var NoPriority = 90; | |
| var shouldYield = Scheduler_shouldYield; | |
| var requestPaint = // Fall back gracefully if we're running an older version of Scheduler. | |
| Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function () {}; | |
| var syncQueue = null; | |
| var immediateQueueCallbackNode = null; | |
| var isFlushingSyncQueue = false; | |
| var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. | |
| // This will be the case for modern browsers that support `performance.now`. In | |
| // older browsers, Scheduler falls back to `Date.now`, which returns a Unix | |
| // timestamp. In that case, subtract the module initialization time to simulate | |
| // the behavior of performance.now and keep our times small enough to fit | |
| // within 32 bits. | |
| // TODO: Consider lifting this into Scheduler. | |
| var now = initialTimeMs < 10000 ? Scheduler_now : function () { | |
| return Scheduler_now() - initialTimeMs; | |
| }; | |
| function getCurrentPriorityLevel() { | |
| switch (Scheduler_getCurrentPriorityLevel()) { | |
| case Scheduler_ImmediatePriority: | |
| return ImmediatePriority; | |
| case Scheduler_UserBlockingPriority: | |
| return UserBlockingPriority$1; | |
| case Scheduler_NormalPriority: | |
| return NormalPriority; | |
| case Scheduler_LowPriority: | |
| return LowPriority; | |
| case Scheduler_IdlePriority: | |
| return IdlePriority; | |
| default: | |
| { | |
| { | |
| throw Error( "Unknown priority level." ); | |
| } | |
| } | |
| } | |
| } | |
| function reactPriorityToSchedulerPriority(reactPriorityLevel) { | |
| switch (reactPriorityLevel) { | |
| case ImmediatePriority: | |
| return Scheduler_ImmediatePriority; | |
| case UserBlockingPriority$1: | |
| return Scheduler_UserBlockingPriority; | |
| case NormalPriority: | |
| return Scheduler_NormalPriority; | |
| case LowPriority: | |
| return Scheduler_LowPriority; | |
| case IdlePriority: | |
| return Scheduler_IdlePriority; | |
| default: | |
| { | |
| { | |
| throw Error( "Unknown priority level." ); | |
| } | |
| } | |
| } | |
| } | |
| function runWithPriority$1(reactPriorityLevel, fn) { | |
| var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); | |
| return Scheduler_runWithPriority(priorityLevel, fn); | |
| } | |
| function scheduleCallback(reactPriorityLevel, callback, options) { | |
| var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); | |
| return Scheduler_scheduleCallback(priorityLevel, callback, options); | |
| } | |
| function scheduleSyncCallback(callback) { | |
| // Push this callback into an internal queue. We'll flush these either in | |
| // the next tick, or earlier if something calls `flushSyncCallbackQueue`. | |
| if (syncQueue === null) { | |
| syncQueue = [callback]; // Flush the queue in the next tick, at the earliest. | |
| immediateQueueCallbackNode = Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueueImpl); | |
| } else { | |
| // Push onto existing queue. Don't need to schedule a callback because | |
| // we already scheduled one when we created the queue. | |
| syncQueue.push(callback); | |
| } | |
| return fakeCallbackNode; | |
| } | |
| function cancelCallback(callbackNode) { | |
| if (callbackNode !== fakeCallbackNode) { | |
| Scheduler_cancelCallback(callbackNode); | |
| } | |
| } | |
| function flushSyncCallbackQueue() { | |
| if (immediateQueueCallbackNode !== null) { | |
| var node = immediateQueueCallbackNode; | |
| immediateQueueCallbackNode = null; | |
| Scheduler_cancelCallback(node); | |
| } | |
| flushSyncCallbackQueueImpl(); | |
| } | |
| function flushSyncCallbackQueueImpl() { | |
| if (!isFlushingSyncQueue && syncQueue !== null) { | |
| // Prevent re-entrancy. | |
| isFlushingSyncQueue = true; | |
| var i = 0; | |
| try { | |
| var _isSync = true; | |
| var queue = syncQueue; | |
| runWithPriority$1(ImmediatePriority, function () { | |
| for (; i < queue.length; i++) { | |
| var callback = queue[i]; | |
| do { | |
| callback = callback(_isSync); | |
| } while (callback !== null); | |
| } | |
| }); | |
| syncQueue = null; | |
| } catch (error) { | |
| // If something throws, leave the remaining callbacks on the queue. | |
| if (syncQueue !== null) { | |
| syncQueue = syncQueue.slice(i + 1); | |
| } // Resume flushing in the next tick | |
| Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueue); | |
| throw error; | |
| } finally { | |
| isFlushingSyncQueue = false; | |
| } | |
| } | |
| } | |
| var NoMode = 0; | |
| var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root | |
| // tag instead | |
| var BlockingMode = 2; | |
| var ConcurrentMode = 4; | |
| var ProfileMode = 8; | |
| // Max 31 bit integer. The max integer size in V8 for 32-bit systems. | |
| // Math.pow(2, 30) - 1 | |
| // 0b111111111111111111111111111111 | |
| var MAX_SIGNED_31_BIT_INT = 1073741823; | |
| var NoWork = 0; // TODO: Think of a better name for Never. The key difference with Idle is that | |
| // Never work can be committed in an inconsistent state without tearing the UI. | |
| // The main example is offscreen content, like a hidden subtree. So one possible | |
| // name is Offscreen. However, it also includes dehydrated Suspense boundaries, | |
| // which are inconsistent in the sense that they haven't finished yet, but | |
| // aren't visibly inconsistent because the server rendered HTML matches what the | |
| // hydrated tree would look like. | |
| var Never = 1; // Idle is slightly higher priority than Never. It must completely finish in | |
| // order to be consistent. | |
| var Idle = 2; // Continuous Hydration is slightly higher than Idle and is used to increase | |
| // priority of hover targets. | |
| var ContinuousHydration = 3; | |
| var Sync = MAX_SIGNED_31_BIT_INT; | |
| var Batched = Sync - 1; | |
| var UNIT_SIZE = 10; | |
| var MAGIC_NUMBER_OFFSET = Batched - 1; // 1 unit of expiration time represents 10ms. | |
| function msToExpirationTime(ms) { | |
| // Always subtract from the offset so that we don't clash with the magic number for NoWork. | |
| return MAGIC_NUMBER_OFFSET - (ms / UNIT_SIZE | 0); | |
| } | |
| function expirationTimeToMs(expirationTime) { | |
| return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE; | |
| } | |
| function ceiling(num, precision) { | |
| return ((num / precision | 0) + 1) * precision; | |
| } | |
| function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) { | |
| return MAGIC_NUMBER_OFFSET - ceiling(MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE); | |
| } // TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update | |
| // the names to reflect. | |
| var LOW_PRIORITY_EXPIRATION = 5000; | |
| var LOW_PRIORITY_BATCH_SIZE = 250; | |
| function computeAsyncExpiration(currentTime) { | |
| return computeExpirationBucket(currentTime, LOW_PRIORITY_EXPIRATION, LOW_PRIORITY_BATCH_SIZE); | |
| } | |
| function computeSuspenseExpiration(currentTime, timeoutMs) { | |
| // TODO: Should we warn if timeoutMs is lower than the normal pri expiration time? | |
| return computeExpirationBucket(currentTime, timeoutMs, LOW_PRIORITY_BATCH_SIZE); | |
| } // We intentionally set a higher expiration time for interactive updates in | |
| // dev than in production. | |
| // | |
| // If the main thread is being blocked so long that you hit the expiration, | |
| // it's a problem that could be solved with better scheduling. | |
| // | |
| // People will be more likely to notice this and fix it with the long | |
| // expiration time in development. | |
| // | |
| // In production we opt for better UX at the risk of masking scheduling | |
| // problems, by expiring fast. | |
| var HIGH_PRIORITY_EXPIRATION = 500 ; | |
| var HIGH_PRIORITY_BATCH_SIZE = 100; | |
| function computeInteractiveExpiration(currentTime) { | |
| return computeExpirationBucket(currentTime, HIGH_PRIORITY_EXPIRATION, HIGH_PRIORITY_BATCH_SIZE); | |
| } | |
| function inferPriorityFromExpirationTime(currentTime, expirationTime) { | |
| if (expirationTime === Sync) { | |
| return ImmediatePriority; | |
| } | |
| if (expirationTime === Never || expirationTime === Idle) { | |
| return IdlePriority; | |
| } | |
| var msUntil = expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime); | |
| if (msUntil <= 0) { | |
| return ImmediatePriority; | |
| } | |
| if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) { | |
| return UserBlockingPriority$1; | |
| } | |
| if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) { | |
| return NormalPriority; | |
| } // TODO: Handle LowPriority | |
| // Assume anything lower has idle priority | |
| return IdlePriority; | |
| } | |
| var ReactStrictModeWarnings = { | |
| recordUnsafeLifecycleWarnings: function (fiber, instance) {}, | |
| flushPendingUnsafeLifecycleWarnings: function () {}, | |
| recordLegacyContextWarning: function (fiber, instance) {}, | |
| flushLegacyContextWarning: function () {}, | |
| discardPendingWarnings: function () {} | |
| }; | |
| { | |
| var findStrictRoot = function (fiber) { | |
| var maybeStrictRoot = null; | |
| var node = fiber; | |
| while (node !== null) { | |
| if (node.mode & StrictMode) { | |
| maybeStrictRoot = node; | |
| } | |
| node = node.return; | |
| } | |
| return maybeStrictRoot; | |
| }; | |
| var setToSortedString = function (set) { | |
| var array = []; | |
| set.forEach(function (value) { | |
| array.push(value); | |
| }); | |
| return array.sort().join(', '); | |
| }; | |
| var pendingComponentWillMountWarnings = []; | |
| var pendingUNSAFE_ComponentWillMountWarnings = []; | |
| var pendingComponentWillReceivePropsWarnings = []; | |
| var pendingUNSAFE_ComponentWillReceivePropsWarnings = []; | |
| var pendingComponentWillUpdateWarnings = []; | |
| var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about. | |
| var didWarnAboutUnsafeLifecycles = new Set(); | |
| ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) { | |
| // Dedup strategy: Warn once per component. | |
| if (didWarnAboutUnsafeLifecycles.has(fiber.type)) { | |
| return; | |
| } | |
| if (typeof instance.componentWillMount === 'function' && // Don't warn about react-lifecycles-compat polyfilled components. | |
| instance.componentWillMount.__suppressDeprecationWarning !== true) { | |
| pendingComponentWillMountWarnings.push(fiber); | |
| } | |
| if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillMount === 'function') { | |
| pendingUNSAFE_ComponentWillMountWarnings.push(fiber); | |
| } | |
| if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) { | |
| pendingComponentWillReceivePropsWarnings.push(fiber); | |
| } | |
| if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillReceiveProps === 'function') { | |
| pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber); | |
| } | |
| if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) { | |
| pendingComponentWillUpdateWarnings.push(fiber); | |
| } | |
| if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillUpdate === 'function') { | |
| pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber); | |
| } | |
| }; | |
| ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () { | |
| // We do an initial pass to gather component names | |
| var componentWillMountUniqueNames = new Set(); | |
| if (pendingComponentWillMountWarnings.length > 0) { | |
| pendingComponentWillMountWarnings.forEach(function (fiber) { | |
| componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component'); | |
| didWarnAboutUnsafeLifecycles.add(fiber.type); | |
| }); | |
| pendingComponentWillMountWarnings = []; | |
| } | |
| var UNSAFE_componentWillMountUniqueNames = new Set(); | |
| if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) { | |
| pendingUNSAFE_ComponentWillMountWarnings.forEach(function (fiber) { | |
| UNSAFE_componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component'); | |
| didWarnAboutUnsafeLifecycles.add(fiber.type); | |
| }); | |
| pendingUNSAFE_ComponentWillMountWarnings = []; | |
| } | |
| var componentWillReceivePropsUniqueNames = new Set(); | |
| if (pendingComponentWillReceivePropsWarnings.length > 0) { | |
| pendingComponentWillReceivePropsWarnings.forEach(function (fiber) { | |
| componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component'); | |
| didWarnAboutUnsafeLifecycles.add(fiber.type); | |
| }); | |
| pendingComponentWillReceivePropsWarnings = []; | |
| } | |
| var UNSAFE_componentWillReceivePropsUniqueNames = new Set(); | |
| if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) { | |
| pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function (fiber) { | |
| UNSAFE_componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component'); | |
| didWarnAboutUnsafeLifecycles.add(fiber.type); | |
| }); | |
| pendingUNSAFE_ComponentWillReceivePropsWarnings = []; | |
| } | |
| var componentWillUpdateUniqueNames = new Set(); | |
| if (pendingComponentWillUpdateWarnings.length > 0) { | |
| pendingComponentWillUpdateWarnings.forEach(function (fiber) { | |
| componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component'); | |
| didWarnAboutUnsafeLifecycles.add(fiber.type); | |
| }); | |
| pendingComponentWillUpdateWarnings = []; | |
| } | |
| var UNSAFE_componentWillUpdateUniqueNames = new Set(); | |
| if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) { | |
| pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function (fiber) { | |
| UNSAFE_componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component'); | |
| didWarnAboutUnsafeLifecycles.add(fiber.type); | |
| }); | |
| pendingUNSAFE_ComponentWillUpdateWarnings = []; | |
| } // Finally, we flush all the warnings | |
| // UNSAFE_ ones before the deprecated ones, since they'll be 'louder' | |
| if (UNSAFE_componentWillMountUniqueNames.size > 0) { | |
| var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames); | |
| error('Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '\nPlease update the following components: %s', sortedNames); | |
| } | |
| if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) { | |
| var _sortedNames = setToSortedString(UNSAFE_componentWillReceivePropsUniqueNames); | |
| error('Using UNSAFE_componentWillReceiveProps in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, " + 'refactor your code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n' + '\nPlease update the following components: %s', _sortedNames); | |
| } | |
| if (UNSAFE_componentWillUpdateUniqueNames.size > 0) { | |
| var _sortedNames2 = setToSortedString(UNSAFE_componentWillUpdateUniqueNames); | |
| error('Using UNSAFE_componentWillUpdate in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '\nPlease update the following components: %s', _sortedNames2); | |
| } | |
| if (componentWillMountUniqueNames.size > 0) { | |
| var _sortedNames3 = setToSortedString(componentWillMountUniqueNames); | |
| warn('componentWillMount has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '* Rename componentWillMount to UNSAFE_componentWillMount to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames3); | |
| } | |
| if (componentWillReceivePropsUniqueNames.size > 0) { | |
| var _sortedNames4 = setToSortedString(componentWillReceivePropsUniqueNames); | |
| warn('componentWillReceiveProps has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, refactor your " + 'code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n' + '* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames4); | |
| } | |
| if (componentWillUpdateUniqueNames.size > 0) { | |
| var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames); | |
| warn('componentWillUpdate has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames5); | |
| } | |
| }; | |
| var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about. | |
| var didWarnAboutLegacyContext = new Set(); | |
| ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) { | |
| var strictRoot = findStrictRoot(fiber); | |
| if (strictRoot === null) { | |
| error('Expected to find a StrictMode component in a strict mode tree. ' + 'This error is likely caused by a bug in React. Please file an issue.'); | |
| return; | |
| } // Dedup strategy: Warn once per component. | |
| if (didWarnAboutLegacyContext.has(fiber.type)) { | |
| return; | |
| } | |
| var warningsForRoot = pendingLegacyContextWarning.get(strictRoot); | |
| if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') { | |
| if (warningsForRoot === undefined) { | |
| warningsForRoot = []; | |
| pendingLegacyContextWarning.set(strictRoot, warningsForRoot); | |
| } | |
| warningsForRoot.push(fiber); | |
| } | |
| }; | |
| ReactStrictModeWarnings.flushLegacyContextWarning = function () { | |
| pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) { | |
| if (fiberArray.length === 0) { | |
| return; | |
| } | |
| var firstFiber = fiberArray[0]; | |
| var uniqueNames = new Set(); | |
| fiberArray.forEach(function (fiber) { | |
| uniqueNames.add(getComponentName(fiber.type) || 'Component'); | |
| didWarnAboutLegacyContext.add(fiber.type); | |
| }); | |
| var sortedNames = setToSortedString(uniqueNames); | |
| var firstComponentStack = getStackByFiberInDevAndProd(firstFiber); | |
| error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://fb.me/react-legacy-context' + '%s', sortedNames, firstComponentStack); | |
| }); | |
| }; | |
| ReactStrictModeWarnings.discardPendingWarnings = function () { | |
| pendingComponentWillMountWarnings = []; | |
| pendingUNSAFE_ComponentWillMountWarnings = []; | |
| pendingComponentWillReceivePropsWarnings = []; | |
| pendingUNSAFE_ComponentWillReceivePropsWarnings = []; | |
| pendingComponentWillUpdateWarnings = []; | |
| pendingUNSAFE_ComponentWillUpdateWarnings = []; | |
| pendingLegacyContextWarning = new Map(); | |
| }; | |
| } | |
| var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below. | |
| var failedBoundaries = null; | |
| var setRefreshHandler = function (handler) { | |
| { | |
| resolveFamily = handler; | |
| } | |
| }; | |
| function resolveFunctionForHotReloading(type) { | |
| { | |
| if (resolveFamily === null) { | |
| // Hot reloading is disabled. | |
| return type; | |
| } | |
| var family = resolveFamily(type); | |
| if (family === undefined) { | |
| return type; | |
| } // Use the latest known implementation. | |
| return family.current; | |
| } | |
| } | |
| function resolveClassForHotReloading(type) { | |
| // No implementation differences. | |
| return resolveFunctionForHotReloading(type); | |
| } | |
| function resolveForwardRefForHotReloading(type) { | |
| { | |
| if (resolveFamily === null) { | |
| // Hot reloading is disabled. | |
| return type; | |
| } | |
| var family = resolveFamily(type); | |
| if (family === undefined) { | |
| // Check if we're dealing with a real forwardRef. Don't want to crash early. | |
| if (type !== null && type !== undefined && typeof type.render === 'function') { | |
| // ForwardRef is special because its resolved .type is an object, | |
| // but it's possible that we only have its inner render function in the map. | |
| // If that inner render function is different, we'll build a new forwardRef type. | |
| var currentRender = resolveFunctionForHotReloading(type.render); | |
| if (type.render !== currentRender) { | |
| var syntheticType = { | |
| $$typeof: REACT_FORWARD_REF_TYPE, | |
| render: currentRender | |
| }; | |
| if (type.displayName !== undefined) { | |
| syntheticType.displayName = type.displayName; | |
| } | |
| return syntheticType; | |
| } | |
| } | |
| return type; | |
| } // Use the latest known implementation. | |
| return family.current; | |
| } | |
| } | |
| function isCompatibleFamilyForHotReloading(fiber, element) { | |
| { | |
| if (resolveFamily === null) { | |
| // Hot reloading is disabled. | |
| return false; | |
| } | |
| var prevType = fiber.elementType; | |
| var nextType = element.type; // If we got here, we know types aren't === equal. | |
| var needsCompareFamilies = false; | |
| var $$typeofNextType = typeof nextType === 'object' && nextType !== null ? nextType.$$typeof : null; | |
| switch (fiber.tag) { | |
| case ClassComponent: | |
| { | |
| if (typeof nextType === 'function') { | |
| needsCompareFamilies = true; | |
| } | |
| break; | |
| } | |
| case FunctionComponent: | |
| { | |
| if (typeof nextType === 'function') { | |
| needsCompareFamilies = true; | |
| } else if ($$typeofNextType === REACT_LAZY_TYPE) { | |
| // We don't know the inner type yet. | |
| // We're going to assume that the lazy inner type is stable, | |
| // and so it is sufficient to avoid reconciling it away. | |
| // We're not going to unwrap or actually use the new lazy type. | |
| needsCompareFamilies = true; | |
| } | |
| break; | |
| } | |
| case ForwardRef: | |
| { | |
| if ($$typeofNextType === REACT_FORWARD_REF_TYPE) { | |
| needsCompareFamilies = true; | |
| } else if ($$typeofNextType === REACT_LAZY_TYPE) { | |
| needsCompareFamilies = true; | |
| } | |
| break; | |
| } | |
| case MemoComponent: | |
| case SimpleMemoComponent: | |
| { | |
| if ($$typeofNextType === REACT_MEMO_TYPE) { | |
| // TODO: if it was but can no longer be simple, | |
| // we shouldn't set this. | |
| needsCompareFamilies = true; | |
| } else if ($$typeofNextType === REACT_LAZY_TYPE) { | |
| needsCompareFamilies = true; | |
| } | |
| break; | |
| } | |
| default: | |
| return false; | |
| } // Check if both types have a family and it's the same one. | |
| if (needsCompareFamilies) { | |
| // Note: memo() and forwardRef() we'll compare outer rather than inner type. | |
| // This means both of them need to be registered to preserve state. | |
| // If we unwrapped and compared the inner types for wrappers instead, | |
| // then we would risk falsely saying two separate memo(Foo) | |
| // calls are equivalent because they wrap the same Foo function. | |
| var prevFamily = resolveFamily(prevType); | |
| if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) { | |
| return true; | |
| } | |
| } | |
| return false; | |
| } | |
| } | |
| function markFailedErrorBoundaryForHotReloading(fiber) { | |
| { | |
| if (resolveFamily === null) { | |
| // Hot reloading is disabled. | |
| return; | |
| } | |
| if (typeof WeakSet !== 'function') { | |
| return; | |
| } | |
| if (failedBoundaries === null) { | |
| failedBoundaries = new WeakSet(); | |
| } | |
| failedBoundaries.add(fiber); | |
| } | |
| } | |
| var scheduleRefresh = function (root, update) { | |
| { | |
| if (resolveFamily === null) { | |
| // Hot reloading is disabled. | |
| return; | |
| } | |
| var staleFamilies = update.staleFamilies, | |
| updatedFamilies = update.updatedFamilies; | |
| flushPassiveEffects(); | |
| flushSync(function () { | |
| scheduleFibersWithFamiliesRecursively(root.current, updatedFamilies, staleFamilies); | |
| }); | |
| } | |
| }; | |
| var scheduleRoot = function (root, element) { | |
| { | |
| if (root.context !== emptyContextObject) { | |
| // Super edge case: root has a legacy _renderSubtree context | |
| // but we don't know the parentComponent so we can't pass it. | |
| // Just ignore. We'll delete this with _renderSubtree code path later. | |
| return; | |
| } | |
| flushPassiveEffects(); | |
| syncUpdates(function () { | |
| updateContainer(element, root, null, null); | |
| }); | |
| } | |
| }; | |
| function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) { | |
| { | |
| var alternate = fiber.alternate, | |
| child = fiber.child, | |
| sibling = fiber.sibling, | |
| tag = fiber.tag, | |
| type = fiber.type; | |
| var candidateType = null; | |
| switch (tag) { | |
| case FunctionComponent: | |
| case SimpleMemoComponent: | |
| case ClassComponent: | |
| candidateType = type; | |
| break; | |
| case ForwardRef: | |
| candidateType = type.render; | |
| break; | |
| } | |
| if (resolveFamily === null) { | |
| throw new Error('Expected resolveFamily to be set during hot reload.'); | |
| } | |
| var needsRender = false; | |
| var needsRemount = false; | |
| if (candidateType !== null) { | |
| var family = resolveFamily(candidateType); | |
| if (family !== undefined) { | |
| if (staleFamilies.has(family)) { | |
| needsRemount = true; | |
| } else if (updatedFamilies.has(family)) { | |
| if (tag === ClassComponent) { | |
| needsRemount = true; | |
| } else { | |
| needsRender = true; | |
| } | |
| } | |
| } | |
| } | |
| if (failedBoundaries !== null) { | |
| if (failedBoundaries.has(fiber) || alternate !== null && failedBoundaries.has(alternate)) { | |
| needsRemount = true; | |
| } | |
| } | |
| if (needsRemount) { | |
| fiber._debugNeedsRemount = true; | |
| } | |
| if (needsRemount || needsRender) { | |
| scheduleWork(fiber, Sync); | |
| } | |
| if (child !== null && !needsRemount) { | |
| scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies); | |
| } | |
| if (sibling !== null) { | |
| scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies); | |
| } | |
| } | |
| } | |
| var findHostInstancesForRefresh = function (root, families) { | |
| { | |
| var hostInstances = new Set(); | |
| var types = new Set(families.map(function (family) { | |
| return family.current; | |
| })); | |
| findHostInstancesForMatchingFibersRecursively(root.current, types, hostInstances); | |
| return hostInstances; | |
| } | |
| }; | |
| function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) { | |
| { | |
| var child = fiber.child, | |
| sibling = fiber.sibling, | |
| tag = fiber.tag, | |
| type = fiber.type; | |
| var candidateType = null; | |
| switch (tag) { | |
| case FunctionComponent: | |
| case SimpleMemoComponent: | |
| case ClassComponent: | |
| candidateType = type; | |
| break; | |
| case ForwardRef: | |
| candidateType = type.render; | |
| break; | |
| } | |
| var didMatch = false; | |
| if (candidateType !== null) { | |
| if (types.has(candidateType)) { | |
| didMatch = true; | |
| } | |
| } | |
| if (didMatch) { | |
| // We have a match. This only drills down to the closest host components. | |
| // There's no need to search deeper because for the purpose of giving | |
| // visual feedback, "flashing" outermost parent rectangles is sufficient. | |
| findHostInstancesForFiberShallowly(fiber, hostInstances); | |
| } else { | |
| // If there's no match, maybe there will be one further down in the child tree. | |
| if (child !== null) { | |
| findHostInstancesForMatchingFibersRecursively(child, types, hostInstances); | |
| } | |
| } | |
| if (sibling !== null) { | |
| findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances); | |
| } | |
| } | |
| } | |
| function findHostInstancesForFiberShallowly(fiber, hostInstances) { | |
| { | |
| var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances); | |
| if (foundHostInstances) { | |
| return; | |
| } // If we didn't find any host children, fallback to closest host parent. | |
| var node = fiber; | |
| while (true) { | |
| switch (node.tag) { | |
| case HostComponent: | |
| hostInstances.add(node.stateNode); | |
| return; | |
| case HostPortal: | |
| hostInstances.add(node.stateNode.containerInfo); | |
| return; | |
| case HostRoot: | |
| hostInstances.add(node.stateNode.containerInfo); | |
| return; | |
| } | |
| if (node.return === null) { | |
| throw new Error('Expected to reach root first.'); | |
| } | |
| node = node.return; | |
| } | |
| } | |
| } | |
| function findChildHostInstancesForFiberShallowly(fiber, hostInstances) { | |
| { | |
| var node = fiber; | |
| var foundHostInstances = false; | |
| while (true) { | |
| if (node.tag === HostComponent) { | |
| // We got a match. | |
| foundHostInstances = true; | |
| hostInstances.add(node.stateNode); // There may still be more, so keep searching. | |
| } else if (node.child !== null) { | |
| node.child.return = node; | |
| node = node.child; | |
| continue; | |
| } | |
| if (node === fiber) { | |
| return foundHostInstances; | |
| } | |
| while (node.sibling === null) { | |
| if (node.return === null || node.return === fiber) { | |
| return foundHostInstances; | |
| } | |
| node = node.return; | |
| } | |
| node.sibling.return = node.return; | |
| node = node.sibling; | |
| } | |
| } | |
| return false; | |
| } | |
| function resolveDefaultProps(Component, baseProps) { | |
| if (Component && Component.defaultProps) { | |
| // Resolve default props. Taken from ReactElement | |
| var props = _assign({}, baseProps); | |
| var defaultProps = Component.defaultProps; | |
| for (var propName in defaultProps) { | |
| if (props[propName] === undefined) { | |
| props[propName] = defaultProps[propName]; | |
| } | |
| } | |
| return props; | |
| } | |
| return baseProps; | |
| } | |
| function readLazyComponentType(lazyComponent) { | |
| initializeLazyComponentType(lazyComponent); | |
| if (lazyComponent._status !== Resolved) { | |
| throw lazyComponent._result; | |
| } | |
| return lazyComponent._result; | |
| } | |
| var valueCursor = createCursor(null); | |
| var rendererSigil; | |
| { | |
| // Use this to detect multiple renderers using the same context | |
| rendererSigil = {}; | |
| } | |
| var currentlyRenderingFiber = null; | |
| var lastContextDependency = null; | |
| var lastContextWithAllBitsObserved = null; | |
| var isDisallowedContextReadInDEV = false; | |
| function resetContextDependencies() { | |
| // This is called right before React yields execution, to ensure `readContext` | |
| // cannot be called outside the render phase. | |
| currentlyRenderingFiber = null; | |
| lastContextDependency = null; | |
| lastContextWithAllBitsObserved = null; | |
| { | |
| isDisallowedContextReadInDEV = false; | |
| } | |
| } | |
| function enterDisallowedContextReadInDEV() { | |
| { | |
| isDisallowedContextReadInDEV = true; | |
| } | |
| } | |
| function exitDisallowedContextReadInDEV() { | |
| { | |
| isDisallowedContextReadInDEV = false; | |
| } | |
| } | |
| function pushProvider(providerFiber, nextValue) { | |
| var context = providerFiber.type._context; | |
| { | |
| push(valueCursor, context._currentValue, providerFiber); | |
| context._currentValue = nextValue; | |
| { | |
| if (context._currentRenderer !== undefined && context._currentRenderer !== null && context._currentRenderer !== rendererSigil) { | |
| error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.'); | |
| } | |
| context._currentRenderer = rendererSigil; | |
| } | |
| } | |
| } | |
| function popProvider(providerFiber) { | |
| var currentValue = valueCursor.current; | |
| pop(valueCursor, providerFiber); | |
| var context = providerFiber.type._context; | |
| { | |
| context._currentValue = currentValue; | |
| } | |
| } | |
| function calculateChangedBits(context, newValue, oldValue) { | |
| if (objectIs(oldValue, newValue)) { | |
| // No change | |
| return 0; | |
| } else { | |
| var changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT; | |
| { | |
| if ((changedBits & MAX_SIGNED_31_BIT_INT) !== changedBits) { | |
| error('calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits); | |
| } | |
| } | |
| return changedBits | 0; | |
| } | |
| } | |
| function scheduleWorkOnParentPath(parent, renderExpirationTime) { | |
| // Update the child expiration time of all the ancestors, including | |
| // the alternates. | |
| var node = parent; | |
| while (node !== null) { | |
| var alternate = node.alternate; | |
| if (node.childExpirationTime < renderExpirationTime) { | |
| node.childExpirationTime = renderExpirationTime; | |
| if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) { | |
| alternate.childExpirationTime = renderExpirationTime; | |
| } | |
| } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) { | |
| alternate.childExpirationTime = renderExpirationTime; | |
| } else { | |
| // Neither alternate was updated, which means the rest of the | |
| // ancestor path already has sufficient priority. | |
| break; | |
| } | |
| node = node.return; | |
| } | |
| } | |
| function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) { | |
| var fiber = workInProgress.child; | |
| if (fiber !== null) { | |
| // Set the return pointer of the child to the work-in-progress fiber. | |
| fiber.return = workInProgress; | |
| } | |
| while (fiber !== null) { | |
| var nextFiber = void 0; // Visit this fiber. | |
| var list = fiber.dependencies; | |
| if (list !== null) { | |
| nextFiber = fiber.child; | |
| var dependency = list.firstContext; | |
| while (dependency !== null) { | |
| // Check if the context matches. | |
| if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) { | |
| // Match! Schedule an update on this fiber. | |
| if (fiber.tag === ClassComponent) { | |
| // Schedule a force update on the work-in-progress. | |
| var update = createUpdate(renderExpirationTime, null); | |
| update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the | |
| // update to the current fiber, too, which means it will persist even if | |
| // this render is thrown away. Since it's a race condition, not sure it's | |
| // worth fixing. | |
| enqueueUpdate(fiber, update); | |
| } | |
| if (fiber.expirationTime < renderExpirationTime) { | |
| fiber.expirationTime = renderExpirationTime; | |
| } | |
| var alternate = fiber.alternate; | |
| if (alternate !== null && alternate.expirationTime < renderExpirationTime) { | |
| alternate.expirationTime = renderExpirationTime; | |
| } | |
| scheduleWorkOnParentPath(fiber.return, renderExpirationTime); // Mark the expiration time on the list, too. | |
| if (list.expirationTime < renderExpirationTime) { | |
| list.expirationTime = renderExpirationTime; | |
| } // Since we already found a match, we can stop traversing the | |
| // dependency list. | |
| break; | |
| } | |
| dependency = dependency.next; | |
| } | |
| } else if (fiber.tag === ContextProvider) { | |
| // Don't scan deeper if this is a matching provider | |
| nextFiber = fiber.type === workInProgress.type ? null : fiber.child; | |
| } else { | |
| // Traverse down. | |
| nextFiber = fiber.child; | |
| } | |
| if (nextFiber !== null) { | |
| // Set the return pointer of the child to the work-in-progress fiber. | |
| nextFiber.return = fiber; | |
| } else { | |
| // No child. Traverse to next sibling. | |
| nextFiber = fiber; | |
| while (nextFiber !== null) { | |
| if (nextFiber === workInProgress) { | |
| // We're back to the root of this subtree. Exit. | |
| nextFiber = null; | |
| break; | |
| } | |
| var sibling = nextFiber.sibling; | |
| if (sibling !== null) { | |
| // Set the return pointer of the sibling to the work-in-progress fiber. | |
| sibling.return = nextFiber.return; | |
| nextFiber = sibling; | |
| break; | |
| } // No more siblings. Traverse up. | |
| nextFiber = nextFiber.return; | |
| } | |
| } | |
| fiber = nextFiber; | |
| } | |
| } | |
| function prepareToReadContext(workInProgress, renderExpirationTime) { | |
| currentlyRenderingFiber = workInProgress; | |
| lastContextDependency = null; | |
| lastContextWithAllBitsObserved = null; | |
| var dependencies = workInProgress.dependencies; | |
| if (dependencies !== null) { | |
| var firstContext = dependencies.firstContext; | |
| if (firstContext !== null) { | |
| if (dependencies.expirationTime >= renderExpirationTime) { | |
| // Context list has a pending update. Mark that this fiber performed work. | |
| markWorkInProgressReceivedUpdate(); | |
| } // Reset the work-in-progress list | |
| dependencies.firstContext = null; | |
| } | |
| } | |
| } | |
| function readContext(context, observedBits) { | |
| { | |
| // This warning would fire if you read context inside a Hook like useMemo. | |
| // Unlike the class check below, it's not enforced in production for perf. | |
| if (isDisallowedContextReadInDEV) { | |
| error('Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().'); | |
| } | |
| } | |
| if (lastContextWithAllBitsObserved === context) ; else if (observedBits === false || observedBits === 0) ; else { | |
| var resolvedObservedBits; // Avoid deopting on observable arguments or heterogeneous types. | |
| if (typeof observedBits !== 'number' || observedBits === MAX_SIGNED_31_BIT_INT) { | |
| // Observe all updates. | |
| lastContextWithAllBitsObserved = context; | |
| resolvedObservedBits = MAX_SIGNED_31_BIT_INT; | |
| } else { | |
| resolvedObservedBits = observedBits; | |
| } | |
| var contextItem = { | |
| context: context, | |
| observedBits: resolvedObservedBits, | |
| next: null | |
| }; | |
| if (lastContextDependency === null) { | |
| if (!(currentlyRenderingFiber !== null)) { | |
| { | |
| throw Error( "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()." ); | |
| } | |
| } // This is the first dependency for this component. Create a new list. | |
| lastContextDependency = contextItem; | |
| currentlyRenderingFiber.dependencies = { | |
| expirationTime: NoWork, | |
| firstContext: contextItem, | |
| responders: null | |
| }; | |
| } else { | |
| // Append a new context item. | |
| lastContextDependency = lastContextDependency.next = contextItem; | |
| } | |
| } | |
| return context._currentValue ; | |
| } | |
| var UpdateState = 0; | |
| var ReplaceState = 1; | |
| var ForceUpdate = 2; | |
| var CaptureUpdate = 3; // Global state that is reset at the beginning of calling `processUpdateQueue`. | |
| // It should only be read right after calling `processUpdateQueue`, via | |
| // `checkHasForceUpdateAfterProcessing`. | |
| var hasForceUpdate = false; | |
| var didWarnUpdateInsideUpdate; | |
| var currentlyProcessingQueue; | |
| { | |
| didWarnUpdateInsideUpdate = false; | |
| currentlyProcessingQueue = null; | |
| } | |
| function initializeUpdateQueue(fiber) { | |
| var queue = { | |
| baseState: fiber.memoizedState, | |
| baseQueue: null, | |
| shared: { | |
| pending: null | |
| }, | |
| effects: null | |
| }; | |
| fiber.updateQueue = queue; | |
| } | |
| function cloneUpdateQueue(current, workInProgress) { | |
| // Clone the update queue from current. Unless it's already a clone. | |
| var queue = workInProgress.updateQueue; | |
| var currentQueue = current.updateQueue; | |
| if (queue === currentQueue) { | |
| var clone = { | |
| baseState: currentQueue.baseState, | |
| baseQueue: currentQueue.baseQueue, | |
| shared: currentQueue.shared, | |
| effects: currentQueue.effects | |
| }; | |
| workInProgress.updateQueue = clone; | |
| } | |
| } | |
| function createUpdate(expirationTime, suspenseConfig) { | |
| var update = { | |
| expirationTime: expirationTime, | |
| suspenseConfig: suspenseConfig, | |
| tag: UpdateState, | |
| payload: null, | |
| callback: null, | |
| next: null | |
| }; | |
| update.next = update; | |
| { | |
| update.priority = getCurrentPriorityLevel(); | |
| } | |
| return update; | |
| } | |
| function enqueueUpdate(fiber, update) { | |
| var updateQueue = fiber.updateQueue; | |
| if (updateQueue === null) { | |
| // Only occurs if the fiber has been unmounted. | |
| return; | |
| } | |
| var sharedQueue = updateQueue.shared; | |
| var pending = sharedQueue.pending; | |
| if (pending === null) { | |
| // This is the first update. Create a circular list. | |
| update.next = update; | |
| } else { | |
| update.next = pending.next; | |
| pending.next = update; | |
| } | |
| sharedQueue.pending = update; | |
| { | |
| if (currentlyProcessingQueue === sharedQueue && !didWarnUpdateInsideUpdate) { | |
| error('An update (setState, replaceState, or forceUpdate) was scheduled ' + 'from inside an update function. Update functions should be pure, ' + 'with zero side-effects. Consider using componentDidUpdate or a ' + 'callback.'); | |
| didWarnUpdateInsideUpdate = true; | |
| } | |
| } | |
| } | |
| function enqueueCapturedUpdate(workInProgress, update) { | |
| var current = workInProgress.alternate; | |
| if (current !== null) { | |
| // Ensure the work-in-progress queue is a clone | |
| cloneUpdateQueue(current, workInProgress); | |
| } // Captured updates go only on the work-in-progress queue. | |
| var queue = workInProgress.updateQueue; // Append the update to the end of the list. | |
| var last = queue.baseQueue; | |
| if (last === null) { | |
| queue.baseQueue = update.next = update; | |
| update.next = update; | |
| } else { | |
| update.next = last.next; | |
| last.next = update; | |
| } | |
| } | |
| function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) { | |
| switch (update.tag) { | |
| case ReplaceState: | |
| { | |
| var payload = update.payload; | |
| if (typeof payload === 'function') { | |
| // Updater function | |
| { | |
| enterDisallowedContextReadInDEV(); | |
| if ( workInProgress.mode & StrictMode) { | |
| payload.call(instance, prevState, nextProps); | |
| } | |
| } | |
| var nextState = payload.call(instance, prevState, nextProps); | |
| { | |
| exitDisallowedContextReadInDEV(); | |
| } | |
| return nextState; | |
| } // State object | |
| return payload; | |
| } | |
| case CaptureUpdate: | |
| { | |
| workInProgress.effectTag = workInProgress.effectTag & ~ShouldCapture | DidCapture; | |
| } | |
| // Intentional fallthrough | |
| case UpdateState: | |
| { | |
| var _payload = update.payload; | |
| var partialState; | |
| if (typeof _payload === 'function') { | |
| // Updater function | |
| { | |
| enterDisallowedContextReadInDEV(); | |
| if ( workInProgress.mode & StrictMode) { | |
| _payload.call(instance, prevState, nextProps); | |
| } | |
| } | |
| partialState = _payload.call(instance, prevState, nextProps); | |
| { | |
| exitDisallowedContextReadInDEV(); | |
| } | |
| } else { | |
| // Partial state object | |
| partialState = _payload; | |
| } | |
| if (partialState === null || partialState === undefined) { | |
| // Null and undefined are treated as no-ops. | |
| return prevState; | |
| } // Merge the partial state and the previous state. | |
| return _assign({}, prevState, partialState); | |
| } | |
| case ForceUpdate: | |
| { | |
| hasForceUpdate = true; | |
| return prevState; | |
| } | |
| } | |
| return prevState; | |
| } | |
| function processUpdateQueue(workInProgress, props, instance, renderExpirationTime) { | |
| // This is always non-null on a ClassComponent or HostRoot | |
| var queue = workInProgress.updateQueue; | |
| hasForceUpdate = false; | |
| { | |
| currentlyProcessingQueue = queue.shared; | |
| } // The last rebase update that is NOT part of the base state. | |
| var baseQueue = queue.baseQueue; // The last pending update that hasn't been processed yet. | |
| var pendingQueue = queue.shared.pending; | |
| if (pendingQueue !== null) { | |
| // We have new updates that haven't been processed yet. | |
| // We'll add them to the base queue. | |
| if (baseQueue !== null) { | |
| // Merge the pending queue and the base queue. | |
| var baseFirst = baseQueue.next; | |
| var pendingFirst = pendingQueue.next; | |
| baseQueue.next = pendingFirst; | |
| pendingQueue.next = baseFirst; | |
| } | |
| baseQueue = pendingQueue; | |
| queue.shared.pending = null; // TODO: Pass `current` as argument | |
| var current = workInProgress.alternate; | |
| if (current !== null) { | |
| var currentQueue = current.updateQueue; | |
| if (currentQueue !== null) { | |
| currentQueue.baseQueue = pendingQueue; | |
| } | |
| } | |
| } // These values may change as we process the queue. | |
| if (baseQueue !== null) { | |
| var first = baseQueue.next; // Iterate through the list of updates to compute the result. | |
| var newState = queue.baseState; | |
| var newExpirationTime = NoWork; | |
| var newBaseState = null; | |
| var newBaseQueueFirst = null; | |
| var newBaseQueueLast = null; | |
| if (first !== null) { | |
| var update = first; | |
| do { | |
| var updateExpirationTime = update.expirationTime; | |
| if (updateExpirationTime < renderExpirationTime) { | |
| // Priority is insufficient. Skip this update. If this is the first | |
| // skipped update, the previous update/state is the new base | |
| // update/state. | |
| var clone = { | |
| expirationTime: update.expirationTime, | |
| suspenseConfig: update.suspenseConfig, | |
| tag: update.tag, | |
| payload: update.payload, | |
| callback: update.callback, | |
| next: null | |
| }; | |
| if (newBaseQueueLast === null) { | |
| newBaseQueueFirst = newBaseQueueLast = clone; | |
| newBaseState = newState; | |
| } else { | |
| newBaseQueueLast = newBaseQueueLast.next = clone; | |
| } // Update the remaining priority in the queue. | |
| if (updateExpirationTime > newExpirationTime) { | |
| newExpirationTime = updateExpirationTime; | |
| } | |
| } else { | |
| // This update does have sufficient priority. | |
| if (newBaseQueueLast !== null) { | |
| var _clone = { | |
| expirationTime: Sync, | |
| // This update is going to be committed so we never want uncommit it. | |
| suspenseConfig: update.suspenseConfig, | |
| tag: update.tag, | |
| payload: update.payload, | |
| callback: update.callback, | |
| next: null | |
| }; | |
| newBaseQueueLast = newBaseQueueLast.next = _clone; | |
| } // Mark the event time of this update as relevant to this render pass. | |
| // TODO: This should ideally use the true event time of this update rather than | |
| // its priority which is a derived and not reverseable value. | |
| // TODO: We should skip this update if it was already committed but currently | |
| // we have no way of detecting the difference between a committed and suspended | |
| // update here. | |
| markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig); // Process this update. | |
| newState = getStateFromUpdate(workInProgress, queue, update, newState, props, instance); | |
| var callback = update.callback; | |
| if (callback !== null) { | |
| workInProgress.effectTag |= Callback; | |
| var effects = queue.effects; | |
| if (effects === null) { | |
| queue.effects = [update]; | |
| } else { | |
| effects.push(update); | |
| } | |
| } | |
| } | |
| update = update.next; | |
| if (update === null || update === first) { | |
| pendingQueue = queue.shared.pending; | |
| if (pendingQueue === null) { | |
| break; | |
| } else { | |
| // An update was scheduled from inside a reducer. Add the new | |
| // pending updates to the end of the list and keep processing. | |
| update = baseQueue.next = pendingQueue.next; | |
| pendingQueue.next = first; | |
| queue.baseQueue = baseQueue = pendingQueue; | |
| queue.shared.pending = null; | |
| } | |
| } | |
| } while (true); | |
| } | |
| if (newBaseQueueLast === null) { | |
| newBaseState = newState; | |
| } else { | |
| newBaseQueueLast.next = newBaseQueueFirst; | |
| } | |
| queue.baseState = newBaseState; | |
| queue.baseQueue = newBaseQueueLast; // Set the remaining expiration time to be whatever is remaining in the queue. | |
| // This should be fine because the only two other things that contribute to | |
| // expiration time are props and context. We're already in the middle of the | |
| // begin phase by the time we start processing the queue, so we've already | |
| // dealt with the props. Context in components that specify | |
| // shouldComponentUpdate is tricky; but we'll have to account for | |
| // that regardless. | |
| markUnprocessedUpdateTime(newExpirationTime); | |
| workInProgress.expirationTime = newExpirationTime; | |
| workInProgress.memoizedState = newState; | |
| } | |
| { | |
| currentlyProcessingQueue = null; | |
| } | |
| } | |
| function callCallback(callback, context) { | |
| if (!(typeof callback === 'function')) { | |
| { | |
| throw Error( "Invalid argument passed as callback. Expected a function. Instead received: " + callback ); | |
| } | |
| } | |
| callback.call(context); | |
| } | |
| function resetHasForceUpdateBeforeProcessing() { | |
| hasForceUpdate = false; | |
| } | |
| function checkHasForceUpdateAfterProcessing() { | |
| return hasForceUpdate; | |
| } | |
| function commitUpdateQueue(finishedWork, finishedQueue, instance) { | |
| // Commit the effects | |
| var effects = finishedQueue.effects; | |
| finishedQueue.effects = null; | |
| if (effects !== null) { | |
| for (var i = 0; i < effects.length; i++) { | |
| var effect = effects[i]; | |
| var callback = effect.callback; | |
| if (callback !== null) { | |
| effect.callback = null; | |
| callCallback(callback, instance); | |
| } | |
| } | |
| } | |
| } | |
| var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; | |
| function requestCurrentSuspenseConfig() { | |
| return ReactCurrentBatchConfig.suspense; | |
| } | |
| var fakeInternalInstance = {}; | |
| var isArray = Array.isArray; // React.Component uses a shared frozen object by default. | |
| // We'll use it to determine whether we need to initialize legacy refs. | |
| var emptyRefsObject = new React.Component().refs; | |
| var didWarnAboutStateAssignmentForComponent; | |
| var didWarnAboutUninitializedState; | |
| var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate; | |
| var didWarnAboutLegacyLifecyclesAndDerivedState; | |
| var didWarnAboutUndefinedDerivedState; | |
| var warnOnUndefinedDerivedState; | |
| var warnOnInvalidCallback; | |
| var didWarnAboutDirectlyAssigningPropsToState; | |
| var didWarnAboutContextTypeAndContextTypes; | |
| var didWarnAboutInvalidateContextType; | |
| { | |
| didWarnAboutStateAssignmentForComponent = new Set(); | |
| didWarnAboutUninitializedState = new Set(); | |
| didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set(); | |
| didWarnAboutLegacyLifecyclesAndDerivedState = new Set(); | |
| didWarnAboutDirectlyAssigningPropsToState = new Set(); | |
| didWarnAboutUndefinedDerivedState = new Set(); | |
| didWarnAboutContextTypeAndContextTypes = new Set(); | |
| didWarnAboutInvalidateContextType = new Set(); | |
| var didWarnOnInvalidCallback = new Set(); | |
| warnOnInvalidCallback = function (callback, callerName) { | |
| if (callback === null || typeof callback === 'function') { | |
| return; | |
| } | |
| var key = callerName + "_" + callback; | |
| if (!didWarnOnInvalidCallback.has(key)) { | |
| didWarnOnInvalidCallback.add(key); | |
| error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback); | |
| } | |
| }; | |
| warnOnUndefinedDerivedState = function (type, partialState) { | |
| if (partialState === undefined) { | |
| var componentName = getComponentName(type) || 'Component'; | |
| if (!didWarnAboutUndefinedDerivedState.has(componentName)) { | |
| didWarnAboutUndefinedDerivedState.add(componentName); | |
| error('%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName); | |
| } | |
| } | |
| }; // This is so gross but it's at least non-critical and can be removed if | |
| // it causes problems. This is meant to give a nicer error message for | |
| // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component, | |
| // ...)) which otherwise throws a "_processChildContext is not a function" | |
| // exception. | |
| Object.defineProperty(fakeInternalInstance, '_processChildContext', { | |
| enumerable: false, | |
| value: function () { | |
| { | |
| { | |
| throw Error( "_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal)." ); | |
| } | |
| } | |
| } | |
| }); | |
| Object.freeze(fakeInternalInstance); | |
| } | |
| function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) { | |
| var prevState = workInProgress.memoizedState; | |
| { | |
| if ( workInProgress.mode & StrictMode) { | |
| // Invoke the function an extra time to help detect side-effects. | |
| getDerivedStateFromProps(nextProps, prevState); | |
| } | |
| } | |
| var partialState = getDerivedStateFromProps(nextProps, prevState); | |
| { | |
| warnOnUndefinedDerivedState(ctor, partialState); | |
| } // Merge the partial state and the previous state. | |
| var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState); | |
| workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the | |
| // base state. | |
| if (workInProgress.expirationTime === NoWork) { | |
| // Queue is always non-null for classes | |
| var updateQueue = workInProgress.updateQueue; | |
| updateQueue.baseState = memoizedState; | |
| } | |
| } | |
| var classComponentUpdater = { | |
| isMounted: isMounted, | |
| enqueueSetState: function (inst, payload, callback) { | |
| var fiber = get(inst); | |
| var currentTime = requestCurrentTimeForUpdate(); | |
| var suspenseConfig = requestCurrentSuspenseConfig(); | |
| var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); | |
| var update = createUpdate(expirationTime, suspenseConfig); | |
| update.payload = payload; | |
| if (callback !== undefined && callback !== null) { | |
| { | |
| warnOnInvalidCallback(callback, 'setState'); | |
| } | |
| update.callback = callback; | |
| } | |
| enqueueUpdate(fiber, update); | |
| scheduleWork(fiber, expirationTime); | |
| }, | |
| enqueueReplaceState: function (inst, payload, callback) { | |
| var fiber = get(inst); | |
| var currentTime = requestCurrentTimeForUpdate(); | |
| var suspenseConfig = requestCurrentSuspenseConfig(); | |
| var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); | |
| var update = createUpdate(expirationTime, suspenseConfig); | |
| update.tag = ReplaceState; | |
| update.payload = payload; | |
| if (callback !== undefined && callback !== null) { | |
| { | |
| warnOnInvalidCallback(callback, 'replaceState'); | |
| } | |
| update.callback = callback; | |
| } | |
| enqueueUpdate(fiber, update); | |
| scheduleWork(fiber, expirationTime); | |
| }, | |
| enqueueForceUpdate: function (inst, callback) { | |
| var fiber = get(inst); | |
| var currentTime = requestCurrentTimeForUpdate(); | |
| var suspenseConfig = requestCurrentSuspenseConfig(); | |
| var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); | |
| var update = createUpdate(expirationTime, suspenseConfig); | |
| update.tag = ForceUpdate; | |
| if (callback !== undefined && callback !== null) { | |
| { | |
| warnOnInvalidCallback(callback, 'forceUpdate'); | |
| } | |
| update.callback = callback; | |
| } | |
| enqueueUpdate(fiber, update); | |
| scheduleWork(fiber, expirationTime); | |
| } | |
| }; | |
| function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) { | |
| var instance = workInProgress.stateNode; | |
| if (typeof instance.shouldComponentUpdate === 'function') { | |
| { | |
| if ( workInProgress.mode & StrictMode) { | |
| // Invoke the function an extra time to help detect side-effects. | |
| instance.shouldComponentUpdate(newProps, newState, nextContext); | |
| } | |
| } | |
| startPhaseTimer(workInProgress, 'shouldComponentUpdate'); | |
| var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext); | |
| stopPhaseTimer(); | |
| { | |
| if (shouldUpdate === undefined) { | |
| error('%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(ctor) || 'Component'); | |
| } | |
| } | |
| return shouldUpdate; | |
| } | |
| if (ctor.prototype && ctor.prototype.isPureReactComponent) { | |
| return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState); | |
| } | |
| return true; | |
| } | |
| function checkClassInstance(workInProgress, ctor, newProps) { | |
| var instance = workInProgress.stateNode; | |
| { | |
| var name = getComponentName(ctor) || 'Component'; | |
| var renderPresent = instance.render; | |
| if (!renderPresent) { | |
| if (ctor.prototype && typeof ctor.prototype.render === 'function') { | |
| error('%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name); | |
| } else { | |
| error('%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name); | |
| } | |
| } | |
| if (instance.getInitialState && !instance.getInitialState.isReactClassApproved && !instance.state) { | |
| error('getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name); | |
| } | |
| if (instance.getDefaultProps && !instance.getDefaultProps.isReactClassApproved) { | |
| error('getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name); | |
| } | |
| if (instance.propTypes) { | |
| error('propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name); | |
| } | |
| if (instance.contextType) { | |
| error('contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name); | |
| } | |
| { | |
| if (instance.contextTypes) { | |
| error('contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name); | |
| } | |
| if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) { | |
| didWarnAboutContextTypeAndContextTypes.add(ctor); | |
| error('%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name); | |
| } | |
| } | |
| if (typeof instance.componentShouldUpdate === 'function') { | |
| error('%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name); | |
| } | |
| if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') { | |
| error('%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentName(ctor) || 'A pure component'); | |
| } | |
| if (typeof instance.componentDidUnmount === 'function') { | |
| error('%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name); | |
| } | |
| if (typeof instance.componentDidReceiveProps === 'function') { | |
| error('%s has a method called ' + 'componentDidReceiveProps(). But there is no such lifecycle method. ' + 'If you meant to update the state in response to changing props, ' + 'use componentWillReceiveProps(). If you meant to fetch data or ' + 'run side-effects or mutations after React has updated the UI, use componentDidUpdate().', name); | |
| } | |
| if (typeof instance.componentWillRecieveProps === 'function') { | |
| error('%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name); | |
| } | |
| if (typeof instance.UNSAFE_componentWillRecieveProps === 'function') { | |
| error('%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name); | |
| } | |
| var hasMutatedProps = instance.props !== newProps; | |
| if (instance.props !== undefined && hasMutatedProps) { | |
| error('%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name); | |
| } | |
| if (instance.defaultProps) { | |
| error('Setting defaultProps as an instance property on %s is not supported and will be ignored.' + ' Instead, define defaultProps as a static property on %s.', name, name); | |
| } | |
| if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) { | |
| didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor); | |
| error('%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(ctor)); | |
| } | |
| if (typeof instance.getDerivedStateFromProps === 'function') { | |
| error('%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name); | |
| } | |
| if (typeof instance.getDerivedStateFromError === 'function') { | |
| error('%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name); | |
| } | |
| if (typeof ctor.getSnapshotBeforeUpdate === 'function') { | |
| error('%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name); | |
| } | |
| var _state = instance.state; | |
| if (_state && (typeof _state !== 'object' || isArray(_state))) { | |
| error('%s.state: must be set to an object or null', name); | |
| } | |
| if (typeof instance.getChildContext === 'function' && typeof ctor.childContextTypes !== 'object') { | |
| error('%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name); | |
| } | |
| } | |
| } | |
| function adoptClassInstance(workInProgress, instance) { | |
| instance.updater = classComponentUpdater; | |
| workInProgress.stateNode = instance; // The instance needs access to the fiber so that it can schedule updates | |
| set(instance, workInProgress); | |
| { | |
| instance._reactInternalInstance = fakeInternalInstance; | |
| } | |
| } | |
| function constructClassInstance(workInProgress, ctor, props) { | |
| var isLegacyContextConsumer = false; | |
| var unmaskedContext = emptyContextObject; | |
| var context = emptyContextObject; | |
| var contextType = ctor.contextType; | |
| { | |
| if ('contextType' in ctor) { | |
| var isValid = // Allow null for conditional declaration | |
| contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer> | |
| if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) { | |
| didWarnAboutInvalidateContextType.add(ctor); | |
| var addendum = ''; | |
| if (contextType === undefined) { | |
| addendum = ' However, it is set to undefined. ' + 'This can be caused by a typo or by mixing up named and default imports. ' + 'This can also happen due to a circular dependency, so ' + 'try moving the createContext() call to a separate file.'; | |
| } else if (typeof contextType !== 'object') { | |
| addendum = ' However, it is set to a ' + typeof contextType + '.'; | |
| } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) { | |
| addendum = ' Did you accidentally pass the Context.Provider instead?'; | |
| } else if (contextType._context !== undefined) { | |
| // <Context.Consumer> | |
| addendum = ' Did you accidentally pass the Context.Consumer instead?'; | |
| } else { | |
| addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.'; | |
| } | |
| error('%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum); | |
| } | |
| } | |
| } | |
| if (typeof contextType === 'object' && contextType !== null) { | |
| context = readContext(contextType); | |
| } else { | |
| unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); | |
| var contextTypes = ctor.contextTypes; | |
| isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined; | |
| context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject; | |
| } // Instantiate twice to help detect side-effects. | |
| { | |
| if ( workInProgress.mode & StrictMode) { | |
| new ctor(props, context); // eslint-disable-line no-new | |
| } | |
| } | |
| var instance = new ctor(props, context); | |
| var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null; | |
| adoptClassInstance(workInProgress, instance); | |
| { | |
| if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) { | |
| var componentName = getComponentName(ctor) || 'Component'; | |
| if (!didWarnAboutUninitializedState.has(componentName)) { | |
| didWarnAboutUninitializedState.add(componentName); | |
| error('`%s` uses `getDerivedStateFromProps` but its initial state is ' + '%s. This is not recommended. Instead, define the initial state by ' + 'assigning an object to `this.state` in the constructor of `%s`. ' + 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.', componentName, instance.state === null ? 'null' : 'undefined', componentName); | |
| } | |
| } // If new component APIs are defined, "unsafe" lifecycles won't be called. | |
| // Warn about these lifecycles if they are present. | |
| // Don't warn about react-lifecycles-compat polyfilled methods though. | |
| if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') { | |
| var foundWillMountName = null; | |
| var foundWillReceivePropsName = null; | |
| var foundWillUpdateName = null; | |
| if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) { | |
| foundWillMountName = 'componentWillMount'; | |
| } else if (typeof instance.UNSAFE_componentWillMount === 'function') { | |
| foundWillMountName = 'UNSAFE_componentWillMount'; | |
| } | |
| if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) { | |
| foundWillReceivePropsName = 'componentWillReceiveProps'; | |
| } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') { | |
| foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps'; | |
| } | |
| if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) { | |
| foundWillUpdateName = 'componentWillUpdate'; | |
| } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') { | |
| foundWillUpdateName = 'UNSAFE_componentWillUpdate'; | |
| } | |
| if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) { | |
| var _componentName = getComponentName(ctor) || 'Component'; | |
| var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()'; | |
| if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) { | |
| didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName); | |
| error('Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' + '%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n' + 'The above lifecycles should be removed. Learn more about this warning here:\n' + 'https://fb.me/react-unsafe-component-lifecycles', _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : '', foundWillReceivePropsName !== null ? "\n " + foundWillReceivePropsName : '', foundWillUpdateName !== null ? "\n " + foundWillUpdateName : ''); | |
| } | |
| } | |
| } | |
| } // Cache unmasked context so we can avoid recreating masked context unless necessary. | |
| // ReactFiberContext usually updates this cache but can't for newly-created instances. | |
| if (isLegacyContextConsumer) { | |
| cacheContext(workInProgress, unmaskedContext, context); | |
| } | |
| return instance; | |
| } | |
| function callComponentWillMount(workInProgress, instance) { | |
| startPhaseTimer(workInProgress, 'componentWillMount'); | |
| var oldState = instance.state; | |
| if (typeof instance.componentWillMount === 'function') { | |
| instance.componentWillMount(); | |
| } | |
| if (typeof instance.UNSAFE_componentWillMount === 'function') { | |
| instance.UNSAFE_componentWillMount(); | |
| } | |
| stopPhaseTimer(); | |
| if (oldState !== instance.state) { | |
| { | |
| error('%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress.type) || 'Component'); | |
| } | |
| classComponentUpdater.enqueueReplaceState(instance, instance.state, null); | |
| } | |
| } | |
| function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) { | |
| var oldState = instance.state; | |
| startPhaseTimer(workInProgress, 'componentWillReceiveProps'); | |
| if (typeof instance.componentWillReceiveProps === 'function') { | |
| instance.componentWillReceiveProps(newProps, nextContext); | |
| } | |
| if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') { | |
| instance.UNSAFE_componentWillReceiveProps(newProps, nextContext); | |
| } | |
| stopPhaseTimer(); | |
| if (instance.state !== oldState) { | |
| { | |
| var componentName = getComponentName(workInProgress.type) || 'Component'; | |
| if (!didWarnAboutStateAssignmentForComponent.has(componentName)) { | |
| didWarnAboutStateAssignmentForComponent.add(componentName); | |
| error('%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName); | |
| } | |
| } | |
| classComponentUpdater.enqueueReplaceState(instance, instance.state, null); | |
| } | |
| } // Invokes the mount life-cycles on a previously never rendered instance. | |
| function mountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) { | |
| { | |
| checkClassInstance(workInProgress, ctor, newProps); | |
| } | |
| var instance = workInProgress.stateNode; | |
| instance.props = newProps; | |
| instance.state = workInProgress.memoizedState; | |
| instance.refs = emptyRefsObject; | |
| initializeUpdateQueue(workInProgress); | |
| var contextType = ctor.contextType; | |
| if (typeof contextType === 'object' && contextType !== null) { | |
| instance.context = readContext(contextType); | |
| } else { | |
| var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); | |
| instance.context = getMaskedContext(workInProgress, unmaskedContext); | |
| } | |
| { | |
| if (instance.state === newProps) { | |
| var componentName = getComponentName(ctor) || 'Component'; | |
| if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) { | |
| didWarnAboutDirectlyAssigningPropsToState.add(componentName); | |
| error('%s: It is not recommended to assign props directly to state ' + "because updates to props won't be reflected in state. " + 'In most cases, it is better to use props directly.', componentName); | |
| } | |
| } | |
| if (workInProgress.mode & StrictMode) { | |
| ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance); | |
| } | |
| { | |
| ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance); | |
| } | |
| } | |
| processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); | |
| instance.state = workInProgress.memoizedState; | |
| var getDerivedStateFromProps = ctor.getDerivedStateFromProps; | |
| if (typeof getDerivedStateFromProps === 'function') { | |
| applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); | |
| instance.state = workInProgress.memoizedState; | |
| } // In order to support react-lifecycles-compat polyfilled components, | |
| // Unsafe lifecycles should not be invoked for components using the new APIs. | |
| if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) { | |
| callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's | |
| // process them now. | |
| processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); | |
| instance.state = workInProgress.memoizedState; | |
| } | |
| if (typeof instance.componentDidMount === 'function') { | |
| workInProgress.effectTag |= Update; | |
| } | |
| } | |
| function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) { | |
| var instance = workInProgress.stateNode; | |
| var oldProps = workInProgress.memoizedProps; | |
| instance.props = oldProps; | |
| var oldContext = instance.context; | |
| var contextType = ctor.contextType; | |
| var nextContext = emptyContextObject; | |
| if (typeof contextType === 'object' && contextType !== null) { | |
| nextContext = readContext(contextType); | |
| } else { | |
| var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); | |
| nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext); | |
| } | |
| var getDerivedStateFromProps = ctor.getDerivedStateFromProps; | |
| var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what | |
| // ever the previously attempted to render - not the "current". However, | |
| // during componentDidUpdate we pass the "current" props. | |
| // In order to support react-lifecycles-compat polyfilled components, | |
| // Unsafe lifecycles should not be invoked for components using the new APIs. | |
| if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) { | |
| if (oldProps !== newProps || oldContext !== nextContext) { | |
| callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext); | |
| } | |
| } | |
| resetHasForceUpdateBeforeProcessing(); | |
| var oldState = workInProgress.memoizedState; | |
| var newState = instance.state = oldState; | |
| processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); | |
| newState = workInProgress.memoizedState; | |
| if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) { | |
| // If an update was already in progress, we should schedule an Update | |
| // effect even though we're bailing out, so that cWU/cDU are called. | |
| if (typeof instance.componentDidMount === 'function') { | |
| workInProgress.effectTag |= Update; | |
| } | |
| return false; | |
| } | |
| if (typeof getDerivedStateFromProps === 'function') { | |
| applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); | |
| newState = workInProgress.memoizedState; | |
| } | |
| var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext); | |
| if (shouldUpdate) { | |
| // In order to support react-lifecycles-compat polyfilled components, | |
| // Unsafe lifecycles should not be invoked for components using the new APIs. | |
| if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) { | |
| startPhaseTimer(workInProgress, 'componentWillMount'); | |
| if (typeof instance.componentWillMount === 'function') { | |
| instance.componentWillMount(); | |
| } | |
| if (typeof instance.UNSAFE_componentWillMount === 'function') { | |
| instance.UNSAFE_componentWillMount(); | |
| } | |
| stopPhaseTimer(); | |
| } | |
| if (typeof instance.componentDidMount === 'function') { | |
| workInProgress.effectTag |= Update; | |
| } | |
| } else { | |
| // If an update was already in progress, we should schedule an Update | |
| // effect even though we're bailing out, so that cWU/cDU are called. | |
| if (typeof instance.componentDidMount === 'function') { | |
| workInProgress.effectTag |= Update; | |
| } // If shouldComponentUpdate returned false, we should still update the | |
| // memoized state to indicate that this work can be reused. | |
| workInProgress.memoizedProps = newProps; | |
| workInProgress.memoizedState = newState; | |
| } // Update the existing instance's state, props, and context pointers even | |
| // if shouldComponentUpdate returns false. | |
| instance.props = newProps; | |
| instance.state = newState; | |
| instance.context = nextContext; | |
| return shouldUpdate; | |
| } // Invokes the update life-cycles and returns false if it shouldn't rerender. | |
| function updateClassInstance(current, workInProgress, ctor, newProps, renderExpirationTime) { | |
| var instance = workInProgress.stateNode; | |
| cloneUpdateQueue(current, workInProgress); | |
| var oldProps = workInProgress.memoizedProps; | |
| instance.props = workInProgress.type === workInProgress.elementType ? oldProps : resolveDefaultProps(workInProgress.type, oldProps); | |
| var oldContext = instance.context; | |
| var contextType = ctor.contextType; | |
| var nextContext = emptyContextObject; | |
| if (typeof contextType === 'object' && contextType !== null) { | |
| nextContext = readContext(contextType); | |
| } else { | |
| var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); | |
| nextContext = getMaskedContext(workInProgress, nextUnmaskedContext); | |
| } | |
| var getDerivedStateFromProps = ctor.getDerivedStateFromProps; | |
| var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what | |
| // ever the previously attempted to render - not the "current". However, | |
| // during componentDidUpdate we pass the "current" props. | |
| // In order to support react-lifecycles-compat polyfilled components, | |
| // Unsafe lifecycles should not be invoked for components using the new APIs. | |
| if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) { | |
| if (oldProps !== newProps || oldContext !== nextContext) { | |
| callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext); | |
| } | |
| } | |
| resetHasForceUpdateBeforeProcessing(); | |
| var oldState = workInProgress.memoizedState; | |
| var newState = instance.state = oldState; | |
| processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); | |
| newState = workInProgress.memoizedState; | |
| if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) { | |
| // If an update was already in progress, we should schedule an Update | |
| // effect even though we're bailing out, so that cWU/cDU are called. | |
| if (typeof instance.componentDidUpdate === 'function') { | |
| if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { | |
| workInProgress.effectTag |= Update; | |
| } | |
| } | |
| if (typeof instance.getSnapshotBeforeUpdate === 'function') { | |
| if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { | |
| workInProgress.effectTag |= Snapshot; | |
| } | |
| } | |
| return false; | |
| } | |
| if (typeof getDerivedStateFromProps === 'function') { | |
| applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); | |
| newState = workInProgress.memoizedState; | |
| } | |
| var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext); | |
| if (shouldUpdate) { | |
| // In order to support react-lifecycles-compat polyfilled components, | |
| // Unsafe lifecycles should not be invoked for components using the new APIs. | |
| if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) { | |
| startPhaseTimer(workInProgress, 'componentWillUpdate'); | |
| if (typeof instance.componentWillUpdate === 'function') { | |
| instance.componentWillUpdate(newProps, newState, nextContext); | |
| } | |
| if (typeof instance.UNSAFE_componentWillUpdate === 'function') { | |
| instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext); | |
| } | |
| stopPhaseTimer(); | |
| } | |
| if (typeof instance.componentDidUpdate === 'function') { | |
| workInProgress.effectTag |= Update; | |
| } | |
| if (typeof instance.getSnapshotBeforeUpdate === 'function') { | |
| workInProgress.effectTag |= Snapshot; | |
| } | |
| } else { | |
| // If an update was already in progress, we should schedule an Update | |
| // effect even though we're bailing out, so that cWU/cDU are called. | |
| if (typeof instance.componentDidUpdate === 'function') { | |
| if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { | |
| workInProgress.effectTag |= Update; | |
| } | |
| } | |
| if (typeof instance.getSnapshotBeforeUpdate === 'function') { | |
| if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { | |
| workInProgress.effectTag |= Snapshot; | |
| } | |
| } // If shouldComponentUpdate returned false, we should still update the | |
| // memoized props/state to indicate that this work can be reused. | |
| workInProgress.memoizedProps = newProps; | |
| workInProgress.memoizedState = newState; | |
| } // Update the existing instance's state, props, and context pointers even | |
| // if shouldComponentUpdate returns false. | |
| instance.props = newProps; | |
| instance.state = newState; | |
| instance.context = nextContext; | |
| return shouldUpdate; | |
| } | |
| var didWarnAboutMaps; | |
| var didWarnAboutGenerators; | |
| var didWarnAboutStringRefs; | |
| var ownerHasKeyUseWarning; | |
| var ownerHasFunctionTypeWarning; | |
| var warnForMissingKey = function (child) {}; | |
| { | |
| didWarnAboutMaps = false; | |
| didWarnAboutGenerators = false; | |
| didWarnAboutStringRefs = {}; | |
| /** | |
| * Warn if there's no key explicitly set on dynamic arrays of children or | |
| * object keys are not valid. This allows us to keep track of children between | |
| * updates. | |
| */ | |
| ownerHasKeyUseWarning = {}; | |
| ownerHasFunctionTypeWarning = {}; | |
| warnForMissingKey = function (child) { | |
| if (child === null || typeof child !== 'object') { | |
| return; | |
| } | |
| if (!child._store || child._store.validated || child.key != null) { | |
| return; | |
| } | |
| if (!(typeof child._store === 'object')) { | |
| { | |
| throw Error( "React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue." ); | |
| } | |
| } | |
| child._store.validated = true; | |
| var currentComponentErrorInfo = 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.' + getCurrentFiberStackInDev(); | |
| if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { | |
| return; | |
| } | |
| ownerHasKeyUseWarning[currentComponentErrorInfo] = true; | |
| error('Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.'); | |
| }; | |
| } | |
| var isArray$1 = Array.isArray; | |
| function coerceRef(returnFiber, current, element) { | |
| var mixedRef = element.ref; | |
| if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') { | |
| { | |
| // TODO: Clean this up once we turn on the string ref warning for | |
| // everyone, because the strict mode case will no longer be relevant | |
| if ((returnFiber.mode & StrictMode || warnAboutStringRefs) && // We warn in ReactElement.js if owner and self are equal for string refs | |
| // because these cannot be automatically converted to an arrow function | |
| // using a codemod. Therefore, we don't have to warn about string refs again. | |
| !(element._owner && element._self && element._owner.stateNode !== element._self)) { | |
| var componentName = getComponentName(returnFiber.type) || 'Component'; | |
| if (!didWarnAboutStringRefs[componentName]) { | |
| { | |
| error('A string ref, "%s", has been found within a strict mode tree. ' + 'String refs are a source of potential bugs and should be avoided. ' + 'We recommend using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref%s', mixedRef, getStackByFiberInDevAndProd(returnFiber)); | |
| } | |
| didWarnAboutStringRefs[componentName] = true; | |
| } | |
| } | |
| } | |
| if (element._owner) { | |
| var owner = element._owner; | |
| var inst; | |
| if (owner) { | |
| var ownerFiber = owner; | |
| if (!(ownerFiber.tag === ClassComponent)) { | |
| { | |
| throw Error( "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref" ); | |
| } | |
| } | |
| inst = ownerFiber.stateNode; | |
| } | |
| if (!inst) { | |
| { | |
| throw Error( "Missing owner for string ref " + mixedRef + ". This error is likely caused by a bug in React. Please file an issue." ); | |
| } | |
| } | |
| var stringRef = '' + mixedRef; // Check if previous string ref matches new string ref | |
| if (current !== null && current.ref !== null && typeof current.ref === 'function' && current.ref._stringRef === stringRef) { | |
| return current.ref; | |
| } | |
| var ref = function (value) { | |
| var refs = inst.refs; | |
| if (refs === emptyRefsObject) { | |
| // This is a lazy pooled frozen object, so we need to initialize. | |
| refs = inst.refs = {}; | |
| } | |
| if (value === null) { | |
| delete refs[stringRef]; | |
| } else { | |
| refs[stringRef] = value; | |
| } | |
| }; | |
| ref._stringRef = stringRef; | |
| return ref; | |
| } else { | |
| if (!(typeof mixedRef === 'string')) { | |
| { | |
| throw Error( "Expected ref to be a function, a string, an object returned by React.createRef(), or null." ); | |
| } | |
| } | |
| if (!element._owner) { | |
| { | |
| throw Error( "Element ref was specified as a string (" + mixedRef + ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information." ); | |
| } | |
| } | |
| } | |
| } | |
| return mixedRef; | |
| } | |
| function throwOnInvalidObjectType(returnFiber, newChild) { | |
| if (returnFiber.type !== 'textarea') { | |
| var addendum = ''; | |
| { | |
| addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getCurrentFiberStackInDev(); | |
| } | |
| { | |
| { | |
| throw Error( "Objects are not valid as a React child (found: " + (Object.prototype.toString.call(newChild) === '[object Object]' ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' : newChild) + ")." + addendum ); | |
| } | |
| } | |
| } | |
| } | |
| function warnOnFunctionType() { | |
| { | |
| var currentComponentErrorInfo = 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.' + getCurrentFiberStackInDev(); | |
| if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) { | |
| return; | |
| } | |
| ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true; | |
| error('Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.'); | |
| } | |
| } // This wrapper function exists because I expect to clone the code in each path | |
| // to be able to optimize each path individually by branching early. This needs | |
| // a compiler or we can do it manually. Helpers that don't need this branching | |
| // live outside of this function. | |
| function ChildReconciler(shouldTrackSideEffects) { | |
| function deleteChild(returnFiber, childToDelete) { | |
| if (!shouldTrackSideEffects) { | |
| // Noop. | |
| return; | |
| } // Deletions are added in reversed order so we add it to the front. | |
| // At this point, the return fiber's effect list is empty except for | |
| // deletions, so we can just append the deletion to the list. The remaining | |
| // effects aren't added until the complete phase. Once we implement | |
| // resuming, this may not be true. | |
| var last = returnFiber.lastEffect; | |
| if (last !== null) { | |
| last.nextEffect = childToDelete; | |
| returnFiber.lastEffect = childToDelete; | |
| } else { | |
| returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; | |
| } | |
| childToDelete.nextEffect = null; | |
| childToDelete.effectTag = Deletion; | |
| } | |
| function deleteRemainingChildren(returnFiber, currentFirstChild) { | |
| if (!shouldTrackSideEffects) { | |
| // Noop. | |
| return null; | |
| } // TODO: For the shouldClone case, this could be micro-optimized a bit by | |
| // assuming that after the first child we've already added everything. | |
| var childToDelete = currentFirstChild; | |
| while (childToDelete !== null) { | |
| deleteChild(returnFiber, childToDelete); | |
| childToDelete = childToDelete.sibling; | |
| } | |
| return null; | |
| } | |
| function mapRemainingChildren(returnFiber, currentFirstChild) { | |
| // Add the remaining children to a temporary map so that we can find them by | |
| // keys quickly. Implicit (null) keys get added to this set with their index | |
| // instead. | |
| var existingChildren = new Map(); | |
| var existingChild = currentFirstChild; | |
| while (existingChild !== null) { | |
| if (existingChild.key !== null) { | |
| existingChildren.set(existingChild.key, existingChild); | |
| } else { | |
| existingChildren.set(existingChild.index, existingChild); | |
| } | |
| existingChild = existingChild.sibling; | |
| } | |
| return existingChildren; | |
| } | |
| function useFiber(fiber, pendingProps) { | |
| // We currently set sibling to null and index to 0 here because it is easy | |
| // to forget to do before returning it. E.g. for the single child case. | |
| var clone = createWorkInProgress(fiber, pendingProps); | |
| clone.index = 0; | |
| clone.sibling = null; | |
| return clone; | |
| } | |
| function placeChild(newFiber, lastPlacedIndex, newIndex) { | |
| newFiber.index = newIndex; | |
| if (!shouldTrackSideEffects) { | |
| // Noop. | |
| return lastPlacedIndex; | |
| } | |
| var current = newFiber.alternate; | |
| if (current !== null) { | |
| var oldIndex = current.index; | |
| if (oldIndex < lastPlacedIndex) { | |
| // This is a move. | |
| newFiber.effectTag = Placement; | |
| return lastPlacedIndex; | |
| } else { | |
| // This item can stay in place. | |
| return oldIndex; | |
| } | |
| } else { | |
| // This is an insertion. | |
| newFiber.effectTag = Placement; | |
| return lastPlacedIndex; | |
| } | |
| } | |
| function placeSingleChild(newFiber) { | |
| // This is simpler for the single child case. We only need to do a | |
| // placement for inserting new children. | |
| if (shouldTrackSideEffects && newFiber.alternate === null) { | |
| newFiber.effectTag = Placement; | |
| } | |
| return newFiber; | |
| } | |
| function updateTextNode(returnFiber, current, textContent, expirationTime) { | |
| if (current === null || current.tag !== HostText) { | |
| // Insert | |
| var created = createFiberFromText(textContent, returnFiber.mode, expirationTime); | |
| created.return = returnFiber; | |
| return created; | |
| } else { | |
| // Update | |
| var existing = useFiber(current, textContent); | |
| existing.return = returnFiber; | |
| return existing; | |
| } | |
| } | |
| function updateElement(returnFiber, current, element, expirationTime) { | |
| if (current !== null) { | |
| if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path: | |
| isCompatibleFamilyForHotReloading(current, element) )) { | |
| // Move based on index | |
| var existing = useFiber(current, element.props); | |
| existing.ref = coerceRef(returnFiber, current, element); | |
| existing.return = returnFiber; | |
| { | |
| existing._debugSource = element._source; | |
| existing._debugOwner = element._owner; | |
| } | |
| return existing; | |
| } | |
| } // Insert | |
| var created = createFiberFromElement(element, returnFiber.mode, expirationTime); | |
| created.ref = coerceRef(returnFiber, current, element); | |
| created.return = returnFiber; | |
| return created; | |
| } | |
| function updatePortal(returnFiber, current, portal, expirationTime) { | |
| if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) { | |
| // Insert | |
| var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime); | |
| created.return = returnFiber; | |
| return created; | |
| } else { | |
| // Update | |
| var existing = useFiber(current, portal.children || []); | |
| existing.return = returnFiber; | |
| return existing; | |
| } | |
| } | |
| function updateFragment(returnFiber, current, fragment, expirationTime, key) { | |
| if (current === null || current.tag !== Fragment) { | |
| // Insert | |
| var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key); | |
| created.return = returnFiber; | |
| return created; | |
| } else { | |
| // Update | |
| var existing = useFiber(current, fragment); | |
| existing.return = returnFiber; | |
| return existing; | |
| } | |
| } | |
| function createChild(returnFiber, newChild, expirationTime) { | |
| if (typeof newChild === 'string' || typeof newChild === 'number') { | |
| // Text nodes don't have keys. If the previous node is implicitly keyed | |
| // we can continue to replace it without aborting even if it is not a text | |
| // node. | |
| var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime); | |
| created.return = returnFiber; | |
| return created; | |
| } | |
| if (typeof newChild === 'object' && newChild !== null) { | |
| switch (newChild.$$typeof) { | |
| case REACT_ELEMENT_TYPE: | |
| { | |
| var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime); | |
| _created.ref = coerceRef(returnFiber, null, newChild); | |
| _created.return = returnFiber; | |
| return _created; | |
| } | |
| case REACT_PORTAL_TYPE: | |
| { | |
| var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime); | |
| _created2.return = returnFiber; | |
| return _created2; | |
| } | |
| } | |
| if (isArray$1(newChild) || getIteratorFn(newChild)) { | |
| var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null); | |
| _created3.return = returnFiber; | |
| return _created3; | |
| } | |
| throwOnInvalidObjectType(returnFiber, newChild); | |
| } | |
| { | |
| if (typeof newChild === 'function') { | |
| warnOnFunctionType(); | |
| } | |
| } | |
| return null; | |
| } | |
| function updateSlot(returnFiber, oldFiber, newChild, expirationTime) { | |
| // Update the fiber if the keys match, otherwise return null. | |
| var key = oldFiber !== null ? oldFiber.key : null; | |
| if (typeof newChild === 'string' || typeof newChild === 'number') { | |
| // Text nodes don't have keys. If the previous node is implicitly keyed | |
| // we can continue to replace it without aborting even if it is not a text | |
| // node. | |
| if (key !== null) { | |
| return null; | |
| } | |
| return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime); | |
| } | |
| if (typeof newChild === 'object' && newChild !== null) { | |
| switch (newChild.$$typeof) { | |
| case REACT_ELEMENT_TYPE: | |
| { | |
| if (newChild.key === key) { | |
| if (newChild.type === REACT_FRAGMENT_TYPE) { | |
| return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key); | |
| } | |
| return updateElement(returnFiber, oldFiber, newChild, expirationTime); | |
| } else { | |
| return null; | |
| } | |
| } | |
| case REACT_PORTAL_TYPE: | |
| { | |
| if (newChild.key === key) { | |
| return updatePortal(returnFiber, oldFiber, newChild, expirationTime); | |
| } else { | |
| return null; | |
| } | |
| } | |
| } | |
| if (isArray$1(newChild) || getIteratorFn(newChild)) { | |
| if (key !== null) { | |
| return null; | |
| } | |
| return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null); | |
| } | |
| throwOnInvalidObjectType(returnFiber, newChild); | |
| } | |
| { | |
| if (typeof newChild === 'function') { | |
| warnOnFunctionType(); | |
| } | |
| } | |
| return null; | |
| } | |
| function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) { | |
| if (typeof newChild === 'string' || typeof newChild === 'number') { | |
| // Text nodes don't have keys, so we neither have to check the old nor | |
| // new node for the key. If both are text nodes, they match. | |
| var matchedFiber = existingChildren.get(newIdx) || null; | |
| return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime); | |
| } | |
| if (typeof newChild === 'object' && newChild !== null) { | |
| switch (newChild.$$typeof) { | |
| case REACT_ELEMENT_TYPE: | |
| { | |
| var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null; | |
| if (newChild.type === REACT_FRAGMENT_TYPE) { | |
| return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key); | |
| } | |
| return updateElement(returnFiber, _matchedFiber, newChild, expirationTime); | |
| } | |
| case REACT_PORTAL_TYPE: | |
| { | |
| var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null; | |
| return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime); | |
| } | |
| } | |
| if (isArray$1(newChild) || getIteratorFn(newChild)) { | |
| var _matchedFiber3 = existingChildren.get(newIdx) || null; | |
| return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null); | |
| } | |
| throwOnInvalidObjectType(returnFiber, newChild); | |
| } | |
| { | |
| if (typeof newChild === 'function') { | |
| warnOnFunctionType(); | |
| } | |
| } | |
| return null; | |
| } | |
| /** | |
| * Warns if there is a duplicate or missing key | |
| */ | |
| function warnOnInvalidKey(child, knownKeys) { | |
| { | |
| if (typeof child !== 'object' || child === null) { | |
| return knownKeys; | |
| } | |
| switch (child.$$typeof) { | |
| case REACT_ELEMENT_TYPE: | |
| case REACT_PORTAL_TYPE: | |
| warnForMissingKey(child); | |
| var key = child.key; | |
| if (typeof key !== 'string') { | |
| break; | |
| } | |
| if (knownKeys === null) { | |
| knownKeys = new Set(); | |
| knownKeys.add(key); | |
| break; | |
| } | |
| if (!knownKeys.has(key)) { | |
| knownKeys.add(key); | |
| break; | |
| } | |
| error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key); | |
| break; | |
| } | |
| } | |
| return knownKeys; | |
| } | |
| function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) { | |
| // This algorithm can't optimize by searching from both ends since we | |
| // don't have backpointers on fibers. I'm trying to see how far we can get | |
| // with that model. If it ends up not being worth the tradeoffs, we can | |
| // add it later. | |
| // Even with a two ended optimization, we'd want to optimize for the case | |
| // where there are few changes and brute force the comparison instead of | |
| // going for the Map. It'd like to explore hitting that path first in | |
| // forward-only mode and only go for the Map once we notice that we need | |
| // lots of look ahead. This doesn't handle reversal as well as two ended | |
| // search but that's unusual. Besides, for the two ended optimization to | |
| // work on Iterables, we'd need to copy the whole set. | |
| // In this first iteration, we'll just live with hitting the bad case | |
| // (adding everything to a Map) in for every insert/move. | |
| // If you change this code, also update reconcileChildrenIterator() which | |
| // uses the same algorithm. | |
| { | |
| // First, validate keys. | |
| var knownKeys = null; | |
| for (var i = 0; i < newChildren.length; i++) { | |
| var child = newChildren[i]; | |
| knownKeys = warnOnInvalidKey(child, knownKeys); | |
| } | |
| } | |
| var resultingFirstChild = null; | |
| var previousNewFiber = null; | |
| var oldFiber = currentFirstChild; | |
| var lastPlacedIndex = 0; | |
| var newIdx = 0; | |
| var nextOldFiber = null; | |
| for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) { | |
| if (oldFiber.index > newIdx) { | |
| nextOldFiber = oldFiber; | |
| oldFiber = null; | |
| } else { | |
| nextOldFiber = oldFiber.sibling; | |
| } | |
| var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime); | |
| if (newFiber === null) { | |
| // TODO: This breaks on empty slots like null children. That's | |
| // unfortunate because it triggers the slow path all the time. We need | |
| // a better way to communicate whether this was a miss or null, | |
| // boolean, undefined, etc. | |
| if (oldFiber === null) { | |
| oldFiber = nextOldFiber; | |
| } | |
| break; | |
| } | |
| if (shouldTrackSideEffects) { | |
| if (oldFiber && newFiber.alternate === null) { | |
| // We matched the slot, but we didn't reuse the existing fiber, so we | |
| // need to delete the existing child. | |
| deleteChild(returnFiber, oldFiber); | |
| } | |
| } | |
| lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx); | |
| if (previousNewFiber === null) { | |
| // TODO: Move out of the loop. This only happens for the first run. | |
| resultingFirstChild = newFiber; | |
| } else { | |
| // TODO: Defer siblings if we're not at the right index for this slot. | |
| // I.e. if we had null values before, then we want to defer this | |
| // for each null value. However, we also don't want to call updateSlot | |
| // with the previous one. | |
| previousNewFiber.sibling = newFiber; | |
| } | |
| previousNewFiber = newFiber; | |
| oldFiber = nextOldFiber; | |
| } | |
| if (newIdx === newChildren.length) { | |
| // We've reached the end of the new children. We can delete the rest. | |
| deleteRemainingChildren(returnFiber, oldFiber); | |
| return resultingFirstChild; | |
| } | |
| if (oldFiber === null) { | |
| // If we don't have any more existing children we can choose a fast path | |
| // since the rest will all be insertions. | |
| for (; newIdx < newChildren.length; newIdx++) { | |
| var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime); | |
| if (_newFiber === null) { | |
| continue; | |
| } | |
| lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx); | |
| if (previousNewFiber === null) { | |
| // TODO: Move out of the loop. This only happens for the first run. | |
| resultingFirstChild = _newFiber; | |
| } else { | |
| previousNewFiber.sibling = _newFiber; | |
| } | |
| previousNewFiber = _newFiber; | |
| } | |
| return resultingFirstChild; | |
| } // Add all children to a key map for quick lookups. | |
| var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves. | |
| for (; newIdx < newChildren.length; newIdx++) { | |
| var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime); | |
| if (_newFiber2 !== null) { | |
| if (shouldTrackSideEffects) { | |
| if (_newFiber2.alternate !== null) { | |
| // The new fiber is a work in progress, but if there exists a | |
| // current, that means that we reused the fiber. We need to delete | |
| // it from the child list so that we don't add it to the deletion | |
| // list. | |
| existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key); | |
| } | |
| } | |
| lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx); | |
| if (previousNewFiber === null) { | |
| resultingFirstChild = _newFiber2; | |
| } else { | |
| previousNewFiber.sibling = _newFiber2; | |
| } | |
| previousNewFiber = _newFiber2; | |
| } | |
| } | |
| if (shouldTrackSideEffects) { | |
| // Any existing children that weren't consumed above were deleted. We need | |
| // to add them to the deletion list. | |
| existingChildren.forEach(function (child) { | |
| return deleteChild(returnFiber, child); | |
| }); | |
| } | |
| return resultingFirstChild; | |
| } | |
| function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) { | |
| // This is the same implementation as reconcileChildrenArray(), | |
| // but using the iterator instead. | |
| var iteratorFn = getIteratorFn(newChildrenIterable); | |
| if (!(typeof iteratorFn === 'function')) { | |
| { | |
| throw Error( "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." ); | |
| } | |
| } | |
| { | |
| // We don't support rendering Generators because it's a mutation. | |
| // See https://github.com/facebook/react/issues/12995 | |
| if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag | |
| newChildrenIterable[Symbol.toStringTag] === 'Generator') { | |
| if (!didWarnAboutGenerators) { | |
| error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.'); | |
| } | |
| didWarnAboutGenerators = true; | |
| } // Warn about using Maps as children | |
| if (newChildrenIterable.entries === iteratorFn) { | |
| if (!didWarnAboutMaps) { | |
| error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.'); | |
| } | |
| didWarnAboutMaps = true; | |
| } // First, validate keys. | |
| // We'll get a different iterator later for the main pass. | |
| var _newChildren = iteratorFn.call(newChildrenIterable); | |
| if (_newChildren) { | |
| var knownKeys = null; | |
| var _step = _newChildren.next(); | |
| for (; !_step.done; _step = _newChildren.next()) { | |
| var child = _step.value; | |
| knownKeys = warnOnInvalidKey(child, knownKeys); | |
| } | |
| } | |
| } | |
| var newChildren = iteratorFn.call(newChildrenIterable); | |
| if (!(newChildren != null)) { | |
| { | |
| throw Error( "An iterable object provided no iterator." ); | |
| } | |
| } | |
| var resultingFirstChild = null; | |
| var previousNewFiber = null; | |
| var oldFiber = currentFirstChild; | |
| var lastPlacedIndex = 0; | |
| var newIdx = 0; | |
| var nextOldFiber = null; | |
| var step = newChildren.next(); | |
| for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) { | |
| if (oldFiber.index > newIdx) { | |
| nextOldFiber = oldFiber; | |
| oldFiber = null; | |
| } else { | |
| nextOldFiber = oldFiber.sibling; | |
| } | |
| var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime); | |
| if (newFiber === null) { | |
| // TODO: This breaks on empty slots like null children. That's | |
| // unfortunate because it triggers the slow path all the time. We need | |
| // a better way to communicate whether this was a miss or null, | |
| // boolean, undefined, etc. | |
| if (oldFiber === null) { | |
| oldFiber = nextOldFiber; | |
| } | |
| break; | |
| } | |
| if (shouldTrackSideEffects) { | |
| if (oldFiber && newFiber.alternate === null) { | |
| // We matched the slot, but we didn't reuse the existing fiber, so we | |
| // need to delete the existing child. | |
| deleteChild(returnFiber, oldFiber); | |
| } | |
| } | |
| lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx); | |
| if (previousNewFiber === null) { | |
| // TODO: Move out of the loop. This only happens for the first run. | |
| resultingFirstChild = newFiber; | |
| } else { | |
| // TODO: Defer siblings if we're not at the right index for this slot. | |
| // I.e. if we had null values before, then we want to defer this | |
| // for each null value. However, we also don't want to call updateSlot | |
| // with the previous one. | |
| previousNewFiber.sibling = newFiber; | |
| } | |
| previousNewFiber = newFiber; | |
| oldFiber = nextOldFiber; | |
| } | |
| if (step.done) { | |
| // We've reached the end of the new children. We can delete the rest. | |
| deleteRemainingChildren(returnFiber, oldFiber); | |
| return resultingFirstChild; | |
| } | |
| if (oldFiber === null) { | |
| // If we don't have any more existing children we can choose a fast path | |
| // since the rest will all be insertions. | |
| for (; !step.done; newIdx++, step = newChildren.next()) { | |
| var _newFiber3 = createChild(returnFiber, step.value, expirationTime); | |
| if (_newFiber3 === null) { | |
| continue; | |
| } | |
| lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx); | |
| if (previousNewFiber === null) { | |
| // TODO: Move out of the loop. This only happens for the first run. | |
| resultingFirstChild = _newFiber3; | |
| } else { | |
| previousNewFiber.sibling = _newFiber3; | |
| } | |
| previousNewFiber = _newFiber3; | |
| } | |
| return resultingFirstChild; | |
| } // Add all children to a key map for quick lookups. | |
| var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves. | |
| for (; !step.done; newIdx++, step = newChildren.next()) { | |
| var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime); | |
| if (_newFiber4 !== null) { | |
| if (shouldTrackSideEffects) { | |
| if (_newFiber4.alternate !== null) { | |
| // The new fiber is a work in progress, but if there exists a | |
| // current, that means that we reused the fiber. We need to delete | |
| // it from the child list so that we don't add it to the deletion | |
| // list. | |
| existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key); | |
| } | |
| } | |
| lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx); | |
| if (previousNewFiber === null) { | |
| resultingFirstChild = _newFiber4; | |
| } else { | |
| previousNewFiber.sibling = _newFiber4; | |
| } | |
| previousNewFiber = _newFiber4; | |
| } | |
| } | |
| if (shouldTrackSideEffects) { | |
| // Any existing children that weren't consumed above were deleted. We need | |
| // to add them to the deletion list. | |
| existingChildren.forEach(function (child) { | |
| return deleteChild(returnFiber, child); | |
| }); | |
| } | |
| return resultingFirstChild; | |
| } | |
| function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) { | |
| // There's no need to check for keys on text nodes since we don't have a | |
| // way to define them. | |
| if (currentFirstChild !== null && currentFirstChild.tag === HostText) { | |
| // We already have an existing node so let's just update it and delete | |
| // the rest. | |
| deleteRemainingChildren(returnFiber, currentFirstChild.sibling); | |
| var existing = useFiber(currentFirstChild, textContent); | |
| existing.return = returnFiber; | |
| return existing; | |
| } // The existing first child is not a text node so we need to create one | |
| // and delete the existing ones. | |
| deleteRemainingChildren(returnFiber, currentFirstChild); | |
| var created = createFiberFromText(textContent, returnFiber.mode, expirationTime); | |
| created.return = returnFiber; | |
| return created; | |
| } | |
| function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) { | |
| var key = element.key; | |
| var child = currentFirstChild; | |
| while (child !== null) { | |
| // TODO: If key === null and child.key === null, then this only applies to | |
| // the first item in the list. | |
| if (child.key === key) { | |
| switch (child.tag) { | |
| case Fragment: | |
| { | |
| if (element.type === REACT_FRAGMENT_TYPE) { | |
| deleteRemainingChildren(returnFiber, child.sibling); | |
| var existing = useFiber(child, element.props.children); | |
| existing.return = returnFiber; | |
| { | |
| existing._debugSource = element._source; | |
| existing._debugOwner = element._owner; | |
| } | |
| return existing; | |
| } | |
| break; | |
| } | |
| case Block: | |
| // We intentionally fallthrough here if enableBlocksAPI is not on. | |
| // eslint-disable-next-lined no-fallthrough | |
| default: | |
| { | |
| if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path: | |
| isCompatibleFamilyForHotReloading(child, element) )) { | |
| deleteRemainingChildren(returnFiber, child.sibling); | |
| var _existing3 = useFiber(child, element.props); | |
| _existing3.ref = coerceRef(returnFiber, child, element); | |
| _existing3.return = returnFiber; | |
| { | |
| _existing3._debugSource = element._source; | |
| _existing3._debugOwner = element._owner; | |
| } | |
| return _existing3; | |
| } | |
| break; | |
| } | |
| } // Didn't match. | |
| deleteRemainingChildren(returnFiber, child); | |
| break; | |
| } else { | |
| deleteChild(returnFiber, child); | |
| } | |
| child = child.sibling; | |
| } | |
| if (element.type === REACT_FRAGMENT_TYPE) { | |
| var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key); | |
| created.return = returnFiber; | |
| return created; | |
| } else { | |
| var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime); | |
| _created4.ref = coerceRef(returnFiber, currentFirstChild, element); | |
| _created4.return = returnFiber; | |
| return _created4; | |
| } | |
| } | |
| function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) { | |
| var key = portal.key; | |
| var child = currentFirstChild; | |
| while (child !== null) { | |
| // TODO: If key === null and child.key === null, then this only applies to | |
| // the first item in the list. | |
| if (child.key === key) { | |
| if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) { | |
| deleteRemainingChildren(returnFiber, child.sibling); | |
| var existing = useFiber(child, portal.children || []); | |
| existing.return = returnFiber; | |
| return existing; | |
| } else { | |
| deleteRemainingChildren(returnFiber, child); | |
| break; | |
| } | |
| } else { | |
| deleteChild(returnFiber, child); | |
| } | |
| child = child.sibling; | |
| } | |
| var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime); | |
| created.return = returnFiber; | |
| return created; | |
| } // This API will tag the children with the side-effect of the reconciliation | |
| // itself. They will be added to the side-effect list as we pass through the | |
| // children and the parent. | |
| function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) { | |
| // This function is not recursive. | |
| // If the top level item is an array, we treat it as a set of children, | |
| // not as a fragment. Nested arrays on the other hand will be treated as | |
| // fragment nodes. Recursion happens at the normal flow. | |
| // Handle top level unkeyed fragments as if they were arrays. | |
| // This leads to an ambiguity between <>{[...]}</> and <>...</>. | |
| // We treat the ambiguous cases above the same. | |
| var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null; | |
| if (isUnkeyedTopLevelFragment) { | |
| newChild = newChild.props.children; | |
| } // Handle object types | |
| var isObject = typeof newChild === 'object' && newChild !== null; | |
| if (isObject) { | |
| switch (newChild.$$typeof) { | |
| case REACT_ELEMENT_TYPE: | |
| return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime)); | |
| case REACT_PORTAL_TYPE: | |
| return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime)); | |
| } | |
| } | |
| if (typeof newChild === 'string' || typeof newChild === 'number') { | |
| return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime)); | |
| } | |
| if (isArray$1(newChild)) { | |
| return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime); | |
| } | |
| if (getIteratorFn(newChild)) { | |
| return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime); | |
| } | |
| if (isObject) { | |
| throwOnInvalidObjectType(returnFiber, newChild); | |
| } | |
| { | |
| if (typeof newChild === 'function') { | |
| warnOnFunctionType(); | |
| } | |
| } | |
| if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) { | |
| // If the new child is undefined, and the return fiber is a composite | |
| // component, throw an error. If Fiber return types are disabled, | |
| // we already threw above. | |
| switch (returnFiber.tag) { | |
| case ClassComponent: | |
| { | |
| { | |
| var instance = returnFiber.stateNode; | |
| if (instance.render._isMockFunction) { | |
| // We allow auto-mocks to proceed as if they're returning null. | |
| break; | |
| } | |
| } | |
| } | |
| // Intentionally fall through to the next case, which handles both | |
| // functions and classes | |
| // eslint-disable-next-lined no-fallthrough | |
| case FunctionComponent: | |
| { | |
| var Component = returnFiber.type; | |
| { | |
| { | |
| throw Error( (Component.displayName || Component.name || 'Component') + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." ); | |
| } | |
| } | |
| } | |
| } | |
| } // Remaining cases are all treated as empty. | |
| return deleteRemainingChildren(returnFiber, currentFirstChild); | |
| } | |
| return reconcileChildFibers; | |
| } | |
| var reconcileChildFibers = ChildReconciler(true); | |
| var mountChildFibers = ChildReconciler(false); | |
| function cloneChildFibers(current, workInProgress) { | |
| if (!(current === null || workInProgress.child === current.child)) { | |
| { | |
| throw Error( "Resuming work not yet implemented." ); | |
| } | |
| } | |
| if (workInProgress.child === null) { | |
| return; | |
| } | |
| var currentChild = workInProgress.child; | |
| var newChild = createWorkInProgress(currentChild, currentChild.pendingProps); | |
| workInProgress.child = newChild; | |
| newChild.return = workInProgress; | |
| while (currentChild.sibling !== null) { | |
| currentChild = currentChild.sibling; | |
| newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps); | |
| newChild.return = workInProgress; | |
| } | |
| newChild.sibling = null; | |
| } // Reset a workInProgress child set to prepare it for a second pass. | |
| function resetChildFibers(workInProgress, renderExpirationTime) { | |
| var child = workInProgress.child; | |
| while (child !== null) { | |
| resetWorkInProgress(child, renderExpirationTime); | |
| child = child.sibling; | |
| } | |
| } | |
| var NO_CONTEXT = {}; | |
| var contextStackCursor$1 = createCursor(NO_CONTEXT); | |
| var contextFiberStackCursor = createCursor(NO_CONTEXT); | |
| var rootInstanceStackCursor = createCursor(NO_CONTEXT); | |
| function requiredContext(c) { | |
| if (!(c !== NO_CONTEXT)) { | |
| { | |
| throw Error( "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." ); | |
| } | |
| } | |
| return c; | |
| } | |
| function getRootHostContainer() { | |
| var rootInstance = requiredContext(rootInstanceStackCursor.current); | |
| return rootInstance; | |
| } | |
| function pushHostContainer(fiber, nextRootInstance) { | |
| // Push current root instance onto the stack; | |
| // This allows us to reset root when portals are popped. | |
| push(rootInstanceStackCursor, nextRootInstance, fiber); // Track the context and the Fiber that provided it. | |
| // This enables us to pop only Fibers that provide unique contexts. | |
| push(contextFiberStackCursor, fiber, fiber); // Finally, we need to push the host context to the stack. | |
| // However, we can't just call getRootHostContext() and push it because | |
| // we'd have a different number of entries on the stack depending on | |
| // whether getRootHostContext() throws somewhere in renderer code or not. | |
| // So we push an empty value first. This lets us safely unwind on errors. | |
| push(contextStackCursor$1, NO_CONTEXT, fiber); | |
| var nextRootContext = getRootHostContext(nextRootInstance); // Now that we know this function doesn't throw, replace it. | |
| pop(contextStackCursor$1, fiber); | |
| push(contextStackCursor$1, nextRootContext, fiber); | |
| } | |
| function popHostContainer(fiber) { | |
| pop(contextStackCursor$1, fiber); | |
| pop(contextFiberStackCursor, fiber); | |
| pop(rootInstanceStackCursor, fiber); | |
| } | |
| function getHostContext() { | |
| var context = requiredContext(contextStackCursor$1.current); | |
| return context; | |
| } | |
| function pushHostContext(fiber) { | |
| var rootInstance = requiredContext(rootInstanceStackCursor.current); | |
| var context = requiredContext(contextStackCursor$1.current); | |
| var nextContext = getChildHostContext(context, fiber.type); // Don't push this Fiber's context unless it's unique. | |
| if (context === nextContext) { | |
| return; | |
| } // Track the context and the Fiber that provided it. | |
| // This enables us to pop only Fibers that provide unique contexts. | |
| push(contextFiberStackCursor, fiber, fiber); | |
| push(contextStackCursor$1, nextContext, fiber); | |
| } | |
| function popHostContext(fiber) { | |
| // Do not pop unless this Fiber provided the current context. | |
| // pushHostContext() only pushes Fibers that provide unique contexts. | |
| if (contextFiberStackCursor.current !== fiber) { | |
| return; | |
| } | |
| pop(contextStackCursor$1, fiber); | |
| pop(contextFiberStackCursor, fiber); | |
| } | |
| var DefaultSuspenseContext = 0; // The Suspense Context is split into two parts. The lower bits is | |
| // inherited deeply down the subtree. The upper bits only affect | |
| // this immediate suspense boundary and gets reset each new | |
| // boundary or suspense list. | |
| var SubtreeSuspenseContextMask = 1; // Subtree Flags: | |
| // InvisibleParentSuspenseContext indicates that one of our parent Suspense | |
| // boundaries is not currently showing visible main content. | |
| // Either because it is already showing a fallback or is not mounted at all. | |
| // We can use this to determine if it is desirable to trigger a fallback at | |
| // the parent. If not, then we might need to trigger undesirable boundaries | |
| // and/or suspend the commit to avoid hiding the parent content. | |
| var InvisibleParentSuspenseContext = 1; // Shallow Flags: | |
| // ForceSuspenseFallback can be used by SuspenseList to force newly added | |
| // items into their fallback state during one of the render passes. | |
| var ForceSuspenseFallback = 2; | |
| var suspenseStackCursor = createCursor(DefaultSuspenseContext); | |
| function hasSuspenseContext(parentContext, flag) { | |
| return (parentContext & flag) !== 0; | |
| } | |
| function setDefaultShallowSuspenseContext(parentContext) { | |
| return parentContext & SubtreeSuspenseContextMask; | |
| } | |
| function setShallowSuspenseContext(parentContext, shallowContext) { | |
| return parentContext & SubtreeSuspenseContextMask | shallowContext; | |
| } | |
| function addSubtreeSuspenseContext(parentContext, subtreeContext) { | |
| return parentContext | subtreeContext; | |
| } | |
| function pushSuspenseContext(fiber, newContext) { | |
| push(suspenseStackCursor, newContext, fiber); | |
| } | |
| function popSuspenseContext(fiber) { | |
| pop(suspenseStackCursor, fiber); | |
| } | |
| function shouldCaptureSuspense(workInProgress, hasInvisibleParent) { | |
| // If it was the primary children that just suspended, capture and render the | |
| // fallback. Otherwise, don't capture and bubble to the next boundary. | |
| var nextState = workInProgress.memoizedState; | |
| if (nextState !== null) { | |
| if (nextState.dehydrated !== null) { | |
| // A dehydrated boundary always captures. | |
| return true; | |
| } | |
| return false; | |
| } | |
| var props = workInProgress.memoizedProps; // In order to capture, the Suspense component must have a fallback prop. | |
| if (props.fallback === undefined) { | |
| return false; | |
| } // Regular boundaries always capture. | |
| if (props.unstable_avoidThisFallback !== true) { | |
| return true; | |
| } // If it's a boundary we should avoid, then we prefer to bubble up to the | |
| // parent boundary if it is currently invisible. | |
| if (hasInvisibleParent) { | |
| return false; | |
| } // If the parent is not able to handle it, we must handle it. | |
| return true; | |
| } | |
| function findFirstSuspended(row) { | |
| var node = row; | |
| while (node !== null) { | |
| if (node.tag === SuspenseComponent) { | |
| var state = node.memoizedState; | |
| if (state !== null) { | |
| var dehydrated = state.dehydrated; | |
| if (dehydrated === null || isSuspenseInstancePending(dehydrated) || isSuspenseInstanceFallback(dehydrated)) { | |
| return node; | |
| } | |
| } | |
| } else if (node.tag === SuspenseListComponent && // revealOrder undefined can't be trusted because it don't | |
| // keep track of whether it suspended or not. | |
| node.memoizedProps.revealOrder !== undefined) { | |
| var didSuspend = (node.effectTag & DidCapture) !== NoEffect; | |
| if (didSuspend) { | |
| return node; | |
| } | |
| } else if (node.child !== null) { | |
| node.child.return = node; | |
| node = node.child; | |
| continue; | |
| } | |
| if (node === row) { | |
| return null; | |
| } | |
| while (node.sibling === null) { | |
| if (node.return === null || node.return === row) { | |
| return null; | |
| } | |
| node = node.return; | |
| } | |
| node.sibling.return = node.return; | |
| node = node.sibling; | |
| } | |
| return null; | |
| } | |
| function createDeprecatedResponderListener(responder, props) { | |
| var eventResponderListener = { | |
| responder: responder, | |
| props: props | |
| }; | |
| { | |
| Object.freeze(eventResponderListener); | |
| } | |
| return eventResponderListener; | |
| } | |
| var HasEffect = | |
| /* */ | |
| 1; // Represents the phase in which the effect (not the clean-up) fires. | |
| var Layout = | |
| /* */ | |
| 2; | |
| var Passive$1 = | |
| /* */ | |
| 4; | |
| var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, | |
| ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; | |
| var didWarnAboutMismatchedHooksForComponent; | |
| { | |
| didWarnAboutMismatchedHooksForComponent = new Set(); | |
| } | |
| // These are set right before calling the component. | |
| var renderExpirationTime = NoWork; // The work-in-progress fiber. I've named it differently to distinguish it from | |
| // the work-in-progress hook. | |
| var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on the fiber's memoizedState field. The | |
| // current hook list is the list that belongs to the current fiber. The | |
| // work-in-progress hook list is a new list that will be added to the | |
| // work-in-progress fiber. | |
| var currentHook = null; | |
| var workInProgressHook = null; // Whether an update was scheduled at any point during the render phase. This | |
| // does not get reset if we do another render pass; only when we're completely | |
| // finished evaluating this component. This is an optimization so we know | |
| // whether we need to clear render phase updates after a throw. | |
| var didScheduleRenderPhaseUpdate = false; | |
| var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook | |
| var currentHookNameInDev = null; // In DEV, this list ensures that hooks are called in the same order between renders. | |
| // The list stores the order of hooks used during the initial render (mount). | |
| // Subsequent renders (updates) reference this list. | |
| var hookTypesDev = null; | |
| var hookTypesUpdateIndexDev = -1; // In DEV, this tracks whether currently rendering component needs to ignore | |
| // the dependencies for Hooks that need them (e.g. useEffect or useMemo). | |
| // When true, such Hooks will always be "remounted". Only used during hot reload. | |
| var ignorePreviousDependencies = false; | |
| function mountHookTypesDev() { | |
| { | |
| var hookName = currentHookNameInDev; | |
| if (hookTypesDev === null) { | |
| hookTypesDev = [hookName]; | |
| } else { | |
| hookTypesDev.push(hookName); | |
| } | |
| } | |
| } | |
| function updateHookTypesDev() { | |
| { | |
| var hookName = currentHookNameInDev; | |
| if (hookTypesDev !== null) { | |
| hookTypesUpdateIndexDev++; | |
| if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) { | |
| warnOnHookMismatchInDev(hookName); | |
| } | |
| } | |
| } | |
| } | |
| function checkDepsAreArrayDev(deps) { | |
| { | |
| if (deps !== undefined && deps !== null && !Array.isArray(deps)) { | |
| // Verify deps, but only on mount to avoid extra checks. | |
| // It's unlikely their type would change as usually you define them inline. | |
| error('%s received a final argument that is not an array (instead, received `%s`). When ' + 'specified, the final argument must be an array.', currentHookNameInDev, typeof deps); | |
| } | |
| } | |
| } | |
| function warnOnHookMismatchInDev(currentHookName) { | |
| { | |
| var componentName = getComponentName(currentlyRenderingFiber$1.type); | |
| if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) { | |
| didWarnAboutMismatchedHooksForComponent.add(componentName); | |
| if (hookTypesDev !== null) { | |
| var table = ''; | |
| var secondColumnStart = 30; | |
| for (var i = 0; i <= hookTypesUpdateIndexDev; i++) { | |
| var oldHookName = hookTypesDev[i]; | |
| var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName; | |
| var row = i + 1 + ". " + oldHookName; // Extra space so second column lines up | |
| // lol @ IE not supporting String#repeat | |
| while (row.length < secondColumnStart) { | |
| row += ' '; | |
| } | |
| row += newHookName + '\n'; | |
| table += row; | |
| } | |
| error('React has detected a change in the order of Hooks called by %s. ' + 'This will lead to bugs and errors if not fixed. ' + 'For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' ------------------------------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table); | |
| } | |
| } | |
| } | |
| } | |
| function throwInvalidHookError() { | |
| { | |
| { | |
| throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." ); | |
| } | |
| } | |
| } | |
| function areHookInputsEqual(nextDeps, prevDeps) { | |
| { | |
| if (ignorePreviousDependencies) { | |
| // Only true when this component is being hot reloaded. | |
| return false; | |
| } | |
| } | |
| if (prevDeps === null) { | |
| { | |
| error('%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev); | |
| } | |
| return false; | |
| } | |
| { | |
| // Don't bother comparing lengths in prod because these arrays should be | |
| // passed inline. | |
| if (nextDeps.length !== prevDeps.length) { | |
| error('The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, "[" + prevDeps.join(', ') + "]", "[" + nextDeps.join(', ') + "]"); | |
| } | |
| } | |
| for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) { | |
| if (objectIs(nextDeps[i], prevDeps[i])) { | |
| continue; | |
| } | |
| return false; | |
| } | |
| return true; | |
| } | |
| function renderWithHooks(current, workInProgress, Component, props, secondArg, nextRenderExpirationTime) { | |
| renderExpirationTime = nextRenderExpirationTime; | |
| currentlyRenderingFiber$1 = workInProgress; | |
| { | |
| hookTypesDev = current !== null ? current._debugHookTypes : null; | |
| hookTypesUpdateIndexDev = -1; // Used for hot reloading: | |
| ignorePreviousDependencies = current !== null && current.type !== workInProgress.type; | |
| } | |
| workInProgress.memoizedState = null; | |
| workInProgress.updateQueue = null; | |
| workInProgress.expirationTime = NoWork; // The following should have already been reset | |
| // currentHook = null; | |
| // workInProgressHook = null; | |
| // didScheduleRenderPhaseUpdate = false; | |
| // TODO Warn if no hooks are used at all during mount, then some are used during update. | |
| // Currently we will identify the update render as a mount because memoizedState === null. | |
| // This is tricky because it's valid for certain types of components (e.g. React.lazy) | |
| // Using memoizedState to differentiate between mount/update only works if at least one stateful hook is used. | |
| // Non-stateful hooks (e.g. context) don't get added to memoizedState, | |
| // so memoizedState would be null during updates and mounts. | |
| { | |
| if (current !== null && current.memoizedState !== null) { | |
| ReactCurrentDispatcher.current = HooksDispatcherOnUpdateInDEV; | |
| } else if (hookTypesDev !== null) { | |
| // This dispatcher handles an edge case where a component is updating, | |
| // but no stateful hooks have been used. | |
| // We want to match the production code behavior (which will use HooksDispatcherOnMount), | |
| // but with the extra DEV validation to ensure hooks ordering hasn't changed. | |
| // This dispatcher does that. | |
| ReactCurrentDispatcher.current = HooksDispatcherOnMountWithHookTypesInDEV; | |
| } else { | |
| ReactCurrentDispatcher.current = HooksDispatcherOnMountInDEV; | |
| } | |
| } | |
| var children = Component(props, secondArg); // Check if there was a render phase update | |
| if (workInProgress.expirationTime === renderExpirationTime) { | |
| // Keep rendering in a loop for as long as render phase updates continue to | |
| // be scheduled. Use a counter to prevent infinite loops. | |
| var numberOfReRenders = 0; | |
| do { | |
| workInProgress.expirationTime = NoWork; | |
| if (!(numberOfReRenders < RE_RENDER_LIMIT)) { | |
| { | |
| throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." ); | |
| } | |
| } | |
| numberOfReRenders += 1; | |
| { | |
| // Even when hot reloading, allow dependencies to stabilize | |
| // after first render to prevent infinite render phase updates. | |
| ignorePreviousDependencies = false; | |
| } // Start over from the beginning of the list | |
| currentHook = null; | |
| workInProgressHook = null; | |
| workInProgress.updateQueue = null; | |
| { | |
| // Also validate hook order for cascading updates. | |
| hookTypesUpdateIndexDev = -1; | |
| } | |
| ReactCurrentDispatcher.current = HooksDispatcherOnRerenderInDEV ; | |
| children = Component(props, secondArg); | |
| } while (workInProgress.expirationTime === renderExpirationTime); | |
| } // We can assume the previous dispatcher is always this one, since we set it | |
| // at the beginning of the render phase and there's no re-entrancy. | |
| ReactCurrentDispatcher.current = ContextOnlyDispatcher; | |
| { | |
| workInProgress._debugHookTypes = hookTypesDev; | |
| } // This check uses currentHook so that it works the same in DEV and prod bundles. | |
| // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. | |
| var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null; | |
| renderExpirationTime = NoWork; | |
| currentlyRenderingFiber$1 = null; | |
| currentHook = null; | |
| workInProgressHook = null; | |
| { | |
| currentHookNameInDev = null; | |
| hookTypesDev = null; | |
| hookTypesUpdateIndexDev = -1; | |
| } | |
| didScheduleRenderPhaseUpdate = false; | |
| if (!!didRenderTooFewHooks) { | |
| { | |
| throw Error( "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." ); | |
| } | |
| } | |
| return children; | |
| } | |
| function bailoutHooks(current, workInProgress, expirationTime) { | |
| workInProgress.updateQueue = current.updateQueue; | |
| workInProgress.effectTag &= ~(Passive | Update); | |
| if (current.expirationTime <= expirationTime) { | |
| current.expirationTime = NoWork; | |
| } | |
| } | |
| function resetHooksAfterThrow() { | |
| // We can assume the previous dispatcher is always this one, since we set it | |
| // at the beginning of the render phase and there's no re-entrancy. | |
| ReactCurrentDispatcher.current = ContextOnlyDispatcher; | |
| if (didScheduleRenderPhaseUpdate) { | |
| // There were render phase updates. These are only valid for this render | |
| // phase, which we are now aborting. Remove the updates from the queues so | |
| // they do not persist to the next render. Do not remove updates from hooks | |
| // that weren't processed. | |
| // | |
| // Only reset the updates from the queue if it has a clone. If it does | |
| // not have a clone, that means it wasn't processed, and the updates were | |
| // scheduled before we entered the render phase. | |
| var hook = currentlyRenderingFiber$1.memoizedState; | |
| while (hook !== null) { | |
| var queue = hook.queue; | |
| if (queue !== null) { | |
| queue.pending = null; | |
| } | |
| hook = hook.next; | |
| } | |
| } | |
| renderExpirationTime = NoWork; | |
| currentlyRenderingFiber$1 = null; | |
| currentHook = null; | |
| workInProgressHook = null; | |
| { | |
| hookTypesDev = null; | |
| hookTypesUpdateIndexDev = -1; | |
| currentHookNameInDev = null; | |
| } | |
| didScheduleRenderPhaseUpdate = false; | |
| } | |
| function mountWorkInProgressHook() { | |
| var hook = { | |
| memoizedState: null, | |
| baseState: null, | |
| baseQueue: null, | |
| queue: null, | |
| next: null | |
| }; | |
| if (workInProgressHook === null) { | |
| // This is the first hook in the list | |
| currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook; | |
| } else { | |
| // Append to the end of the list | |
| workInProgressHook = workInProgressHook.next = hook; | |
| } | |
| return workInProgressHook; | |
| } | |
| function updateWorkInProgressHook() { | |
| // This function is used both for updates and for re-renders triggered by a | |
| // render phase update. It assumes there is either a current hook we can | |
| // clone, or a work-in-progress hook from a previous render pass that we can | |
| // use as a base. When we reach the end of the base list, we must switch to | |
| // the dispatcher used for mounts. | |
| var nextCurrentHook; | |
| if (currentHook === null) { | |
| var current = currentlyRenderingFiber$1.alternate; | |
| if (current !== null) { | |
| nextCurrentHook = current.memoizedState; | |
| } else { | |
| nextCurrentHook = null; | |
| } | |
| } else { | |
| nextCurrentHook = currentHook.next; | |
| } | |
| var nextWorkInProgressHook; | |
| if (workInProgressHook === null) { | |
| nextWorkInProgressHook = currentlyRenderingFiber$1.memoizedState; | |
| } else { | |
| nextWorkInProgressHook = workInProgressHook.next; | |
| } | |
| if (nextWorkInProgressHook !== null) { | |
| // There's already a work-in-progress. Reuse it. | |
| workInProgressHook = nextWorkInProgressHook; | |
| nextWorkInProgressHook = workInProgressHook.next; | |
| currentHook = nextCurrentHook; | |
| } else { | |
| // Clone from the current hook. | |
| if (!(nextCurrentHook !== null)) { | |
| { | |
| throw Error( "Rendered more hooks than during the previous render." ); | |
| } | |
| } | |
| currentHook = nextCurrentHook; | |
| var newHook = { | |
| memoizedState: currentHook.memoizedState, | |
| baseState: currentHook.baseState, | |
| baseQueue: currentHook.baseQueue, | |
| queue: currentHook.queue, | |
| next: null | |
| }; | |
| if (workInProgressHook === null) { | |
| // This is the first hook in the list. | |
| currentlyRenderingFiber$1.memoizedState = workInProgressHook = newHook; | |
| } else { | |
| // Append to the end of the list. | |
| workInProgressHook = workInProgressHook.next = newHook; | |
| } | |
| } | |
| return workInProgressHook; | |
| } | |
| function createFunctionComponentUpdateQueue() { | |
| return { | |
| lastEffect: null | |
| }; | |
| } | |
| function basicStateReducer(state, action) { | |
| // $FlowFixMe: Flow doesn't like mixed types | |
| return typeof action === 'function' ? action(state) : action; | |
| } | |
| function mountReducer(reducer, initialArg, init) { | |
| var hook = mountWorkInProgressHook(); | |
| var initialState; | |
| if (init !== undefined) { | |
| initialState = init(initialArg); | |
| } else { | |
| initialState = initialArg; | |
| } | |
| hook.memoizedState = hook.baseState = initialState; | |
| var queue = hook.queue = { | |
| pending: null, | |
| dispatch: null, | |
| lastRenderedReducer: reducer, | |
| lastRenderedState: initialState | |
| }; | |
| var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue); | |
| return [hook.memoizedState, dispatch]; | |
| } | |
| function updateReducer(reducer, initialArg, init) { | |
| var hook = updateWorkInProgressHook(); | |
| var queue = hook.queue; | |
| if (!(queue !== null)) { | |
| { | |
| throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." ); | |
| } | |
| } | |
| queue.lastRenderedReducer = reducer; | |
| var current = currentHook; // The last rebase update that is NOT part of the base state. | |
| var baseQueue = current.baseQueue; // The last pending update that hasn't been processed yet. | |
| var pendingQueue = queue.pending; | |
| if (pendingQueue !== null) { | |
| // We have new updates that haven't been processed yet. | |
| // We'll add them to the base queue. | |
| if (baseQueue !== null) { | |
| // Merge the pending queue and the base queue. | |
| var baseFirst = baseQueue.next; | |
| var pendingFirst = pendingQueue.next; | |
| baseQueue.next = pendingFirst; | |
| pendingQueue.next = baseFirst; | |
| } | |
| current.baseQueue = baseQueue = pendingQueue; | |
| queue.pending = null; | |
| } | |
| if (baseQueue !== null) { | |
| // We have a queue to process. | |
| var first = baseQueue.next; | |
| var newState = current.baseState; | |
| var newBaseState = null; | |
| var newBaseQueueFirst = null; | |
| var newBaseQueueLast = null; | |
| var update = first; | |
| do { | |
| var updateExpirationTime = update.expirationTime; | |
| if (updateExpirationTime < renderExpirationTime) { | |
| // Priority is insufficient. Skip this update. If this is the first | |
| // skipped update, the previous update/state is the new base | |
| // update/state. | |
| var clone = { | |
| expirationTime: update.expirationTime, | |
| suspenseConfig: update.suspenseConfig, | |
| action: update.action, | |
| eagerReducer: update.eagerReducer, | |
| eagerState: update.eagerState, | |
| next: null | |
| }; | |
| if (newBaseQueueLast === null) { | |
| newBaseQueueFirst = newBaseQueueLast = clone; | |
| newBaseState = newState; | |
| } else { | |
| newBaseQueueLast = newBaseQueueLast.next = clone; | |
| } // Update the remaining priority in the queue. | |
| if (updateExpirationTime > currentlyRenderingFiber$1.expirationTime) { | |
| currentlyRenderingFiber$1.expirationTime = updateExpirationTime; | |
| markUnprocessedUpdateTime(updateExpirationTime); | |
| } | |
| } else { | |
| // This update does have sufficient priority. | |
| if (newBaseQueueLast !== null) { | |
| var _clone = { | |
| expirationTime: Sync, | |
| // This update is going to be committed so we never want uncommit it. | |
| suspenseConfig: update.suspenseConfig, | |
| action: update.action, | |
| eagerReducer: update.eagerReducer, | |
| eagerState: update.eagerState, | |
| next: null | |
| }; | |
| newBaseQueueLast = newBaseQueueLast.next = _clone; | |
| } // Mark the event time of this update as relevant to this render pass. | |
| // TODO: This should ideally use the true event time of this update rather than | |
| // its priority which is a derived and not reverseable value. | |
| // TODO: We should skip this update if it was already committed but currently | |
| // we have no way of detecting the difference between a committed and suspended | |
| // update here. | |
| markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig); // Process this update. | |
| if (update.eagerReducer === reducer) { | |
| // If this update was processed eagerly, and its reducer matches the | |
| // current reducer, we can use the eagerly computed state. | |
| newState = update.eagerState; | |
| } else { | |
| var action = update.action; | |
| newState = reducer(newState, action); | |
| } | |
| } | |
| update = update.next; | |
| } while (update !== null && update !== first); | |
| if (newBaseQueueLast === null) { | |
| newBaseState = newState; | |
| } else { | |
| newBaseQueueLast.next = newBaseQueueFirst; | |
| } // Mark that the fiber performed work, but only if the new state is | |
| // different from the current state. | |
| if (!objectIs(newState, hook.memoizedState)) { | |
| markWorkInProgressReceivedUpdate(); | |
| } | |
| hook.memoizedState = newState; | |
| hook.baseState = newBaseState; | |
| hook.baseQueue = newBaseQueueLast; | |
| queue.lastRenderedState = newState; | |
| } | |
| var dispatch = queue.dispatch; | |
| return [hook.memoizedState, dispatch]; | |
| } | |
| function rerenderReducer(reducer, initialArg, init) { | |
| var hook = updateWorkInProgressHook(); | |
| var queue = hook.queue; | |
| if (!(queue !== null)) { | |
| { | |
| throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." ); | |
| } | |
| } | |
| queue.lastRenderedReducer = reducer; // This is a re-render. Apply the new render phase updates to the previous | |
| // work-in-progress hook. | |
| var dispatch = queue.dispatch; | |
| var lastRenderPhaseUpdate = queue.pending; | |
| var newState = hook.memoizedState; | |
| if (lastRenderPhaseUpdate !== null) { | |
| // The queue doesn't persist past this render pass. | |
| queue.pending = null; | |
| var firstRenderPhaseUpdate = lastRenderPhaseUpdate.next; | |
| var update = firstRenderPhaseUpdate; | |
| do { | |
| // Process this render phase update. We don't have to check the | |
| // priority because it will always be the same as the current | |
| // render's. | |
| var action = update.action; | |
| newState = reducer(newState, action); | |
| update = update.next; | |
| } while (update !== firstRenderPhaseUpdate); // Mark that the fiber performed work, but only if the new state is | |
| // different from the current state. | |
| if (!objectIs(newState, hook.memoizedState)) { | |
| markWorkInProgressReceivedUpdate(); | |
| } | |
| hook.memoizedState = newState; // Don't persist the state accumulated from the render phase updates to | |
| // the base state unless the queue is empty. | |
| // TODO: Not sure if this is the desired semantics, but it's what we | |
| // do for gDSFP. I can't remember why. | |
| if (hook.baseQueue === null) { | |
| hook.baseState = newState; | |
| } | |
| queue.lastRenderedState = newState; | |
| } | |
| return [newState, dispatch]; | |
| } | |
| function mountState(initialState) { | |
| var hook = mountWorkInProgressHook(); | |
| if (typeof initialState === 'function') { | |
| // $FlowFixMe: Flow doesn't like mixed types | |
| initialState = initialState(); | |
| } | |
| hook.memoizedState = hook.baseState = initialState; | |
| var queue = hook.queue = { | |
| pending: null, | |
| dispatch: null, | |
| lastRenderedReducer: basicStateReducer, | |
| lastRenderedState: initialState | |
| }; | |
| var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue); | |
| return [hook.memoizedState, dispatch]; | |
| } | |
| function updateState(initialState) { | |
| return updateReducer(basicStateReducer); | |
| } | |
| function rerenderState(initialState) { | |
| return rerenderReducer(basicStateReducer); | |
| } | |
| function pushEffect(tag, create, destroy, deps) { | |
| var effect = { | |
| tag: tag, | |
| create: create, | |
| destroy: destroy, | |
| deps: deps, | |
| // Circular | |
| next: null | |
| }; | |
| var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue; | |
| if (componentUpdateQueue === null) { | |
| componentUpdateQueue = createFunctionComponentUpdateQueue(); | |
| currentlyRenderingFiber$1.updateQueue = componentUpdateQueue; | |
| componentUpdateQueue.lastEffect = effect.next = effect; | |
| } else { | |
| var lastEffect = componentUpdateQueue.lastEffect; | |
| if (lastEffect === null) { | |
| componentUpdateQueue.lastEffect = effect.next = effect; | |
| } else { | |
| var firstEffect = lastEffect.next; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment