UNPKG

react-palm

Version:

Elm-like architecture for React apps

550 lines (477 loc) 15 kB
/** @license React v16.8.4+patch * react-dom-unstable-native-dependencies.production.min.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. */ 'use strict'; function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } var k = require("react-dom"), l = require("object-assign"); function aa(a, b, c, f, e, d, g, h) { if (!a) { a = void 0; if (void 0 === b) a = Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else { var u = [c, f, e, d, g, h], ba = 0; a = Error(b.replace(/%s/g, function () { return u[ba++]; })); a.name = "Invariant Violation"; } a.framesToPop = 1; throw a; } } function m(a) { for (var b = arguments.length - 1, c = "https://reactjs.org/docs/error-decoder.html?invariant=" + a, f = 0; f < b; f++) { c += "&args[]=" + encodeURIComponent(arguments[f + 1]); } aa(!1, "Minified React error #" + a + "; visit %s for the full message or use the non-minified dev environment for full errors and additional helpful warnings. ", c); } var n = null, p = null, q = null; function r(a) { var b = a._dispatchListeners, c = a._dispatchInstances; Array.isArray(b) ? m("103") : void 0; a.currentTarget = b ? q(c) : null; b = b ? b(a) : null; a.currentTarget = null; a._dispatchListeners = null; a._dispatchInstances = null; return b; } function t(a) { do { a = a.return; } while (a && 5 !== a.tag); return a ? a : null; } function v(a, b, c) { for (var f = []; a;) { f.push(a), a = t(a); } for (a = f.length; 0 < a--;) { b(f[a], "captured", c); } for (a = 0; a < f.length; a++) { b(f[a], "bubbled", c); } } function w(a, b) { null == b ? m("30") : void 0; if (null == a) return b; if (Array.isArray(a)) { if (Array.isArray(b)) return a.push.apply(a, b), a; a.push(b); return a; } return Array.isArray(b) ? [a].concat(b) : [a, b]; } function x(a, b, c) { Array.isArray(a) ? a.forEach(b, c) : a && b.call(c, a); } function y(a, b) { var c = a.stateNode; if (!c) return null; var f = n(c); if (!f) return null; c = f[b]; a: switch (b) { case "onClick": case "onClickCapture": case "onDoubleClick": case "onDoubleClickCapture": case "onMouseDown": case "onMouseDownCapture": case "onMouseMove": case "onMouseMoveCapture": case "onMouseUp": case "onMouseUpCapture": (f = !f.disabled) || (a = a.type, f = !("button" === a || "input" === a || "select" === a || "textarea" === a)); a = !f; break a; default: a = !1; } if (a) return null; c && "function" !== typeof c ? m("231", b, _typeof(c)) : void 0; return c; } function z(a, b, c) { if (b = y(a, c.dispatchConfig.phasedRegistrationNames[b])) c._dispatchListeners = w(c._dispatchListeners, b), c._dispatchInstances = w(c._dispatchInstances, a); } function ca(a) { a && a.dispatchConfig.phasedRegistrationNames && v(a._targetInst, z, a); } function da(a) { if (a && a.dispatchConfig.phasedRegistrationNames) { var b = a._targetInst; b = b ? t(b) : null; v(b, z, a); } } function A(a) { if (a && a.dispatchConfig.registrationName) { var b = a._targetInst; if (b && a && a.dispatchConfig.registrationName) { var c = y(b, a.dispatchConfig.registrationName); c && (a._dispatchListeners = w(a._dispatchListeners, c), a._dispatchInstances = w(a._dispatchInstances, b)); } } } function B() { return !0; } function C() { return !1; } function D(a, b, c, f) { this.dispatchConfig = a; this._targetInst = b; this.nativeEvent = c; a = this.constructor.Interface; for (var e in a) { a.hasOwnProperty(e) && ((b = a[e]) ? this[e] = b(c) : "target" === e ? this.target = f : this[e] = c[e]); } this.isDefaultPrevented = (null != c.defaultPrevented ? c.defaultPrevented : !1 === c.returnValue) ? B : C; this.isPropagationStopped = C; return this; } l(D.prototype, { preventDefault: function preventDefault() { this.defaultPrevented = !0; var a = this.nativeEvent; a && (a.preventDefault ? a.preventDefault() : "unknown" !== typeof a.returnValue && (a.returnValue = !1), this.isDefaultPrevented = B); }, stopPropagation: function stopPropagation() { var a = this.nativeEvent; a && (a.stopPropagation ? a.stopPropagation() : "unknown" !== typeof a.cancelBubble && (a.cancelBubble = !0), this.isPropagationStopped = B); }, persist: function persist() { this.isPersistent = B; }, isPersistent: C, destructor: function destructor() { var a = this.constructor.Interface, b; for (b in a) { this[b] = null; } this.nativeEvent = this._targetInst = this.dispatchConfig = null; this.isPropagationStopped = this.isDefaultPrevented = C; this._dispatchInstances = this._dispatchListeners = null; } }); D.Interface = { type: null, target: null, currentTarget: function currentTarget() { return null; }, eventPhase: null, bubbles: null, cancelable: null, timeStamp: function timeStamp(a) { return a.timeStamp || Date.now(); }, defaultPrevented: null, isTrusted: null }; D.extend = function (a) { function b() {} function c() { return f.apply(this, arguments); } var f = this; b.prototype = f.prototype; var e = new b(); l(e, c.prototype); c.prototype = e; c.prototype.constructor = c; c.Interface = l({}, f.Interface, a); c.extend = f.extend; E(c); return c; }; E(D); function ea(a, b, c, f) { if (this.eventPool.length) { var e = this.eventPool.pop(); this.call(e, a, b, c, f); return e; } return new this(a, b, c, f); } function fa(a) { a instanceof this ? void 0 : m("279"); a.destructor(); 10 > this.eventPool.length && this.eventPool.push(a); } function E(a) { a.eventPool = []; a.getPooled = ea; a.release = fa; } var F = D.extend({ touchHistory: function touchHistory() { return null; } }); function G(a) { return "touchstart" === a || "mousedown" === a; } function H(a) { return "touchmove" === a || "mousemove" === a; } function I(a) { return "touchend" === a || "touchcancel" === a || "mouseup" === a; } var J = ["touchstart", "mousedown"], K = ["touchmove", "mousemove"], L = ["touchcancel", "touchend", "mouseup"], M = [], N = { touchBank: M, numberActiveTouches: 0, indexOfSingleActiveTouch: -1, mostRecentTimeStamp: 0 }; function O(a) { return a.timeStamp || a.timestamp; } function P(a) { a = a.identifier; null == a ? m("138") : void 0; return a; } function ha(a) { var b = P(a), c = M[b]; c ? (c.touchActive = !0, c.startPageX = a.pageX, c.startPageY = a.pageY, c.startTimeStamp = O(a), c.currentPageX = a.pageX, c.currentPageY = a.pageY, c.currentTimeStamp = O(a), c.previousPageX = a.pageX, c.previousPageY = a.pageY, c.previousTimeStamp = O(a)) : (c = { touchActive: !0, startPageX: a.pageX, startPageY: a.pageY, startTimeStamp: O(a), currentPageX: a.pageX, currentPageY: a.pageY, currentTimeStamp: O(a), previousPageX: a.pageX, previousPageY: a.pageY, previousTimeStamp: O(a) }, M[b] = c); N.mostRecentTimeStamp = O(a); } function ia(a) { var b = M[P(a)]; b ? (b.touchActive = !0, b.previousPageX = b.currentPageX, b.previousPageY = b.currentPageY, b.previousTimeStamp = b.currentTimeStamp, b.currentPageX = a.pageX, b.currentPageY = a.pageY, b.currentTimeStamp = O(a), N.mostRecentTimeStamp = O(a)) : console.error("Cannot record touch move without a touch start.\nTouch Move: %s\n", "Touch Bank: %s", Q(a), R()); } function ja(a) { var b = M[P(a)]; b ? (b.touchActive = !1, b.previousPageX = b.currentPageX, b.previousPageY = b.currentPageY, b.previousTimeStamp = b.currentTimeStamp, b.currentPageX = a.pageX, b.currentPageY = a.pageY, b.currentTimeStamp = O(a), N.mostRecentTimeStamp = O(a)) : console.error("Cannot record touch end without a touch start.\nTouch End: %s\n", "Touch Bank: %s", Q(a), R()); } function Q(a) { return JSON.stringify({ identifier: a.identifier, pageX: a.pageX, pageY: a.pageY, timestamp: O(a) }); } function R() { var a = JSON.stringify(M.slice(0, 20)); 20 < M.length && (a += " (original size: " + M.length + ")"); return a; } var S = { recordTouchTrack: function recordTouchTrack(a, b) { if (H(a)) b.changedTouches.forEach(ia);else if (G(a)) b.changedTouches.forEach(ha), N.numberActiveTouches = b.touches.length, 1 === N.numberActiveTouches && (N.indexOfSingleActiveTouch = b.touches[0].identifier);else if (I(a) && (b.changedTouches.forEach(ja), N.numberActiveTouches = b.touches.length, 1 === N.numberActiveTouches)) for (a = 0; a < M.length; a++) { if (b = M[a], null != b && b.touchActive) { N.indexOfSingleActiveTouch = a; break; } } }, touchHistory: N }; function T(a, b) { null == b ? m("29") : void 0; return null == a ? b : Array.isArray(a) ? a.concat(b) : Array.isArray(b) ? [a].concat(b) : [a, b]; } var U = null, V = 0; function W(a, b) { var c = U; U = a; if (null !== X.GlobalResponderHandler) X.GlobalResponderHandler.onChange(c, a, b); } var Y = { startShouldSetResponder: { phasedRegistrationNames: { bubbled: "onStartShouldSetResponder", captured: "onStartShouldSetResponderCapture" }, dependencies: J }, scrollShouldSetResponder: { phasedRegistrationNames: { bubbled: "onScrollShouldSetResponder", captured: "onScrollShouldSetResponderCapture" }, dependencies: ["scroll"] }, selectionChangeShouldSetResponder: { phasedRegistrationNames: { bubbled: "onSelectionChangeShouldSetResponder", captured: "onSelectionChangeShouldSetResponderCapture" }, dependencies: ["selectionchange"] }, moveShouldSetResponder: { phasedRegistrationNames: { bubbled: "onMoveShouldSetResponder", captured: "onMoveShouldSetResponderCapture" }, dependencies: K }, responderStart: { registrationName: "onResponderStart", dependencies: J }, responderMove: { registrationName: "onResponderMove", dependencies: K }, responderEnd: { registrationName: "onResponderEnd", dependencies: L }, responderRelease: { registrationName: "onResponderRelease", dependencies: L }, responderTerminationRequest: { registrationName: "onResponderTerminationRequest", dependencies: [] }, responderGrant: { registrationName: "onResponderGrant", dependencies: [] }, responderReject: { registrationName: "onResponderReject", dependencies: [] }, responderTerminate: { registrationName: "onResponderTerminate", dependencies: [] } }, X = { _getResponder: function _getResponder() { return U; }, eventTypes: Y, extractEvents: function extractEvents(a, b, c, f) { if (G(a)) V += 1;else if (I(a)) if (0 <= V) --V;else return console.error("Ended a touch event which was not counted in `trackedTouchCount`."), null; S.recordTouchTrack(a, c); if (b && ("scroll" === a && !c.responderIgnoreScroll || 0 < V && "selectionchange" === a || G(a) || H(a))) { var e = G(a) ? Y.startShouldSetResponder : H(a) ? Y.moveShouldSetResponder : "selectionchange" === a ? Y.selectionChangeShouldSetResponder : Y.scrollShouldSetResponder; if (U) b: { var d = U; for (var g = 0, h = d; h; h = t(h)) { g++; } h = 0; for (var u = b; u; u = t(u)) { h++; } for (; 0 < g - h;) { d = t(d), g--; } for (; 0 < h - g;) { b = t(b), h--; } for (; g--;) { if (d === b || d === b.alternate) break b; d = t(d); b = t(b); } d = null; } else d = b; b = d === U; d = F.getPooled(e, d, c, f); d.touchHistory = S.touchHistory; b ? x(d, da) : x(d, ca); b: { e = d._dispatchListeners; b = d._dispatchInstances; if (Array.isArray(e)) for (g = 0; g < e.length && !d.isPropagationStopped(); g++) { if (e[g](d, b[g])) { e = b[g]; break b; } } else if (e && e(d, b)) { e = b; break b; } e = null; } d._dispatchInstances = null; d._dispatchListeners = null; d.isPersistent() || d.constructor.release(d); e && e !== U ? (d = void 0, b = F.getPooled(Y.responderGrant, e, c, f), b.touchHistory = S.touchHistory, x(b, A), g = !0 === r(b), U ? (h = F.getPooled(Y.responderTerminationRequest, U, c, f), h.touchHistory = S.touchHistory, x(h, A), u = !h._dispatchListeners || r(h), h.isPersistent() || h.constructor.release(h), u ? (h = F.getPooled(Y.responderTerminate, U, c, f), h.touchHistory = S.touchHistory, x(h, A), d = T(d, [b, h]), W(e, g)) : (e = F.getPooled(Y.responderReject, e, c, f), e.touchHistory = S.touchHistory, x(e, A), d = T(d, e))) : (d = T(d, b), W(e, g)), e = d) : e = null; } else e = null; d = U && G(a); b = U && H(a); g = U && I(a); if (d = d ? Y.responderStart : b ? Y.responderMove : g ? Y.responderEnd : null) d = F.getPooled(d, U, c, f), d.touchHistory = S.touchHistory, x(d, A), e = T(e, d); d = U && "touchcancel" === a; if (a = U && !d && I(a)) a: { if ((a = c.touches) && 0 !== a.length) for (b = 0; b < a.length; b++) { if (g = a[b].target, null !== g && void 0 !== g && 0 !== g) { h = p(g); b: { for (g = U; h;) { if (g === h || g === h.alternate) { g = !0; break b; } h = t(h); } g = !1; } if (g) { a = !1; break a; } } } a = !0; } if (a = d ? Y.responderTerminate : a ? Y.responderRelease : null) c = F.getPooled(a, U, c, f), c.touchHistory = S.touchHistory, x(c, A), e = T(e, c), W(null); return e; }, GlobalResponderHandler: null, injection: { injectGlobalResponderHandler: function injectGlobalResponderHandler(a) { X.GlobalResponderHandler = a; } } }, Z = k.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events, ka = Z[3], la = Z[0], ma = Z[1]; n = Z[2]; p = la; q = ma; module.exports = { ResponderEventPlugin: X, ResponderTouchHistoryStore: S, injectEventPluginsByName: ka };