UNPKG

rn-web-cli

Version:

React Native for Web

1 lines 14.9 kB
{"version":3,"sources":["node_modules\\react-dom\\lib\\EventPluginHub.js"],"names":["_prodInvariant","require","EventPluginRegistry","EventPluginUtils","ReactErrorUtils","accumulateInto","forEachAccumulated","invariant","listenerBank","eventQueue","executeDispatchesAndRelease","event","simulated","executeDispatchesInOrder","isPersistent","constructor","release","executeDispatchesAndReleaseSimulated","e","executeDispatchesAndReleaseTopLevel","getDictionaryKey","inst","_rootNodeID","isInteractive","tag","shouldPreventMouseEvent","name","type","props","disabled","EventPluginHub","injection","injectEventPluginOrder","injectEventPluginsByName","putListener","registrationName","listener","process","env","NODE_ENV","key","bankForRegistrationName","PluginModule","registrationNameModules","didPutListener","getListener","_currentElement","deleteListener","willDeleteListener","deleteAllListeners","hasOwnProperty","extractEvents","topLevelType","targetInst","nativeEvent","nativeEventTarget","events","plugins","i","length","possiblePlugin","extractedEvents","enqueueEvents","processEventQueue","processingEventQueue","rethrowCaughtError","__purge","__getListenerBank","module","exports"],"mappings":";;;;;;;;;;AAUA;;AAEA,GAAIA,gBAAiBC,QAAQ,sBAAR,CAArB;;AAEA,GAAIC,qBAAsBD,QAAQ,uBAAR,CAA1B;AACA,GAAIE,kBAAmBF,QAAQ,oBAAR,CAAvB;AACA,GAAIG,iBAAkBH,QAAQ,mBAAR,CAAtB;;AAEA,GAAII,gBAAiBJ,QAAQ,kBAAR,CAArB;AACA,GAAIK,oBAAqBL,QAAQ,sBAAR,CAAzB;AACA,GAAIM,WAAYN,QAAQ,oBAAR,CAAhB;;;;;AAKA,GAAIO,cAAe,EAAnB;;;;;;AAMA,GAAIC,YAAa,IAAjB;;;;;;;;;AASA,GAAIC,6BAA8B,QAA9BA,4BAA8B,CAAUC,KAAV,CAAiBC,SAAjB,CAA4B;AAC5D,GAAID,KAAJ,CAAW;AACTR,iBAAiBU,wBAAjB,CAA0CF,KAA1C,CAAiDC,SAAjD;;AAEA,GAAI,CAACD,MAAMG,YAAN,EAAL,CAA2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CAAY;AACV/C,WAAaJ,eAAeI,UAAf,CAA2B+C,MAA3B,CAAb;AACD;AACF,CApIkB;;;;;;;AA2InBO,kBAAmB,2BAAUnD,SAAV,CAAqB;;;AAGtC,GAAIoD,sBAAuBvD,UAA3B;AACAA,WAAa,IAAb;AACA,GAAIG,SAAJ,CAAe;AACbN,mBAAmB0D,oBAAnB,CAAyC/C,oCAAzC;AACD,CAFD,IAEO;AACLX,mBAAmB0D,oBAAnB,CAAyC7C,mCAAzC;AACD;AACD,CAAC,CAACV,UAAF,CAAe4B,QAAQC,GAAR,CAAYC,QAAZ,GAAyB,YAAzB,CAAwChC,UAAU,KAAV,CAAiB,sIAAjB,CAAxC,CAAmMP,eAAe,IAAf,CAAlN,CAAyO,IAAK,EAA9O;;AAEAI,gBAAgB6D,kBAAhB;AACD,CAxJkB;;;;;AA6JnBC,QAAS,kBAAY;AACnB1D,aAAe,EAAf;AACD,CA/JkB;;AAiKnB2D,kBAAmB,4BAAY;AAC7B,MAAO3D,aAAP;AACD,CAnKkB,CAArB;;;AAsKA4D,OAAOC,OAAP,CAAiBvC,cAAjB","file":"EventPluginHub.js","sourceRoot":"d:/Work/Office/react-native-on-web/cli/tmpl/project","sourcesContent":["/**\n * Copyright 2013-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n *\n */\n\n'use strict';\n\nvar _prodInvariant = require('./reactProdInvariant');\n\nvar EventPluginRegistry = require('./EventPluginRegistry');\nvar EventPluginUtils = require('./EventPluginUtils');\nvar ReactErrorUtils = require('./ReactErrorUtils');\n\nvar accumulateInto = require('./accumulateInto');\nvar forEachAccumulated = require('./forEachAccumulated');\nvar invariant = require('fbjs/lib/invariant');\n\n/**\n * Internal store for event listeners\n */\nvar listenerBank = {};\n\n/**\n * Internal queue of events that have accumulated their dispatches and are\n * waiting to have their dispatches executed.\n */\nvar eventQueue = null;\n\n/**\n * Dispatches an event and releases it back into the pool, unless persistent.\n *\n * @param {?object} event Synthetic event to be dispatched.\n * @param {boolean} simulated If the event is simulated (changes exn behavior)\n * @private\n */\nvar executeDispatchesAndRelease = function (event, simulated) {\n if (event) {\n EventPluginUtils.executeDispatchesInOrder(event, simulated);\n\n if (!event.isPersistent()) {\n event.constructor.release(event);\n }\n }\n};\nvar executeDispatchesAndReleaseSimulated = function (e) {\n return executeDispatchesAndRelease(e, true);\n};\nvar executeDispatchesAndReleaseTopLevel = function (e) {\n return executeDispatchesAndRelease(e, false);\n};\n\nvar getDictionaryKey = function (inst) {\n // Prevents V8 performance issue:\n // https://github.com/facebook/react/pull/7232\n return '.' + inst._rootNodeID;\n};\n\nfunction isInteractive(tag) {\n return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea';\n}\n\nfunction shouldPreventMouseEvent(name, type, props) {\n switch (name) {\n case 'onClick':\n case 'onClickCapture':\n case 'onDoubleClick':\n case 'onDoubleClickCapture':\n case 'onMouseDown':\n case 'onMouseDownCapture':\n case 'onMouseMove':\n case 'onMouseMoveCapture':\n case 'onMouseUp':\n case 'onMouseUpCapture':\n return !!(props.disabled && isInteractive(type));\n default:\n return false;\n }\n}\n\n/**\n * This is a unified interface for event plugins to be installed and configured.\n *\n * Event plugins can implement the following properties:\n *\n * `extractEvents` {function(string, DOMEventTarget, string, object): *}\n * Required. When a top-level event is fired, this method is expected to\n * extract synthetic events that will in turn be queued and dispatched.\n *\n * `eventTypes` {object}\n * Optional, plugins that fire events must publish a mapping of registration\n * names that are used to register listeners. Values of this mapping must\n * be objects that contain `registrationName` or `phasedRegistrationNames`.\n *\n * `executeDispatch` {function(object, function, string)}\n * Optional, allows plugins to override how an event gets dispatched. By\n * default, the listener is simply invoked.\n *\n * Each plugin that is injected into `EventsPluginHub` is immediately operable.\n *\n * @public\n */\nvar EventPluginHub = {\n /**\n * Methods for injecting dependencies.\n */\n injection: {\n /**\n * @param {array} InjectedEventPluginOrder\n * @public\n */\n injectEventPluginOrder: EventPluginRegistry.injectEventPluginOrder,\n\n /**\n * @param {object} injectedNamesToPlugins Map from names to plugin modules.\n */\n injectEventPluginsByName: EventPluginRegistry.injectEventPluginsByName\n },\n\n /**\n * Stores `listener` at `listenerBank[registrationName][key]`. Is idempotent.\n *\n * @param {object} inst The instance, which is the source of events.\n * @param {string} registrationName Name of listener (e.g. `onClick`).\n * @param {function} listener The callback to store.\n */\n putListener: function (inst, registrationName, listener) {\n !(typeof listener === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected %s listener to be a function, instead got type %s', registrationName, typeof listener) : _prodInvariant('94', registrationName, typeof listener) : void 0;\n\n var key = getDictionaryKey(inst);\n var bankForRegistrationName = listenerBank[registrationName] || (listenerBank[registrationName] = {});\n bankForRegistrationName[key] = listener;\n\n var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];\n if (PluginModule && PluginModule.didPutListener) {\n PluginModule.didPutListener(inst, registrationName, listener);\n }\n },\n\n /**\n * @param {object} inst The instance, which is the source of events.\n * @param {string} registrationName Name of listener (e.g. `onClick`).\n * @return {?function} The stored callback.\n */\n getListener: function (inst, registrationName) {\n // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not\n // live here; needs to be moved to a better place soon\n var bankForRegistrationName = listenerBank[registrationName];\n if (shouldPreventMouseEvent(registrationName, inst._currentElement.type, inst._currentElement.props)) {\n return null;\n }\n var key = getDictionaryKey(inst);\n return bankForRegistrationName && bankForRegistrationName[key];\n },\n\n /**\n * Deletes a listener from the registration bank.\n *\n * @param {object} inst The instance, which is the source of events.\n * @param {string} registrationName Name of listener (e.g. `onClick`).\n */\n deleteListener: function (inst, registrationName) {\n var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];\n if (PluginModule && PluginModule.willDeleteListener) {\n PluginModule.willDeleteListener(inst, registrationName);\n }\n\n var bankForRegistrationName = listenerBank[registrationName];\n // TODO: This should never be null -- when is it?\n if (bankForRegistrationName) {\n var key = getDictionaryKey(inst);\n delete bankForRegistrationName[key];\n }\n },\n\n /**\n * Deletes all listeners for the DOM element with the supplied ID.\n *\n * @param {object} inst The instance, which is the source of events.\n */\n deleteAllListeners: function (inst) {\n var key = getDictionaryKey(inst);\n for (var registrationName in listenerBank) {\n if (!listenerBank.hasOwnProperty(registrationName)) {\n continue;\n }\n\n if (!listenerBank[registrationName][key]) {\n continue;\n }\n\n var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];\n if (PluginModule && PluginModule.willDeleteListener) {\n PluginModule.willDeleteListener(inst, registrationName);\n }\n\n delete listenerBank[registrationName][key];\n }\n },\n\n /**\n * Allows registered plugins an opportunity to extract events from top-level\n * native browser events.\n *\n * @return {*} An accumulation of synthetic events.\n * @internal\n */\n extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {\n var events;\n var plugins = EventPluginRegistry.plugins;\n for (var i = 0; i < plugins.length; i++) {\n // Not every plugin in the ordering may be loaded at runtime.\n var possiblePlugin = plugins[i];\n if (possiblePlugin) {\n var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget);\n if (extractedEvents) {\n events = accumulateInto(events, extractedEvents);\n }\n }\n }\n return events;\n },\n\n /**\n * Enqueues a synthetic event that should be dispatched when\n * `processEventQueue` is invoked.\n *\n * @param {*} events An accumulation of synthetic events.\n * @internal\n */\n enqueueEvents: function (events) {\n if (events) {\n eventQueue = accumulateInto(eventQueue, events);\n }\n },\n\n /**\n * Dispatches all synthetic events on the event queue.\n *\n * @internal\n */\n processEventQueue: function (simulated) {\n // Set `eventQueue` to null before processing it so that we can tell if more\n // events get enqueued while processing.\n var processingEventQueue = eventQueue;\n eventQueue = null;\n if (simulated) {\n forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseSimulated);\n } else {\n forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel);\n }\n !!eventQueue ? process.env.NODE_ENV !== 'production' ? invariant(false, 'processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented.') : _prodInvariant('95') : void 0;\n // This would be a good time to rethrow if any of the event handlers threw.\n ReactErrorUtils.rethrowCaughtError();\n },\n\n /**\n * These are needed for tests only. Do not use!\n */\n __purge: function () {\n listenerBank = {};\n },\n\n __getListenerBank: function () {\n return listenerBank;\n }\n};\n\nmodule.exports = EventPluginHub;"]}