ea5ab8bc8dc91f071c051133193b6d8f.json
14.3 KB
{"ast":null,"code":"var _interopRequireDefault=require(\"@babel/runtime/helpers/interopRequireDefault\");Object.defineProperty(exports,\"__esModule\",{value:true});exports.default=void 0;var _defineProperty2=_interopRequireDefault(require(\"@babel/runtime/helpers/defineProperty\"));var _classCallCheck2=_interopRequireDefault(require(\"@babel/runtime/helpers/classCallCheck\"));var _createClass2=_interopRequireDefault(require(\"@babel/runtime/helpers/createClass\"));var _ReanimatedModule=_interopRequireDefault(require(\"../ReanimatedModule\"));function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(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=arguments[i]!=null?arguments[i]:{};if(i%2){ownKeys(source,true).forEach(function(key){(0,_defineProperty2.default)(target,key,source[key]);});}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source));}else{ownKeys(source).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}}return target;}var UPDATED_NODES=[];var loopID=1;var propUpdatesEnqueued=null;function sanitizeConfig(config){for(var key in config){var value=config[key];if(value instanceof AnimatedNode){config[key]=value.__nodeID;}}return config;}function runPropUpdates(){var visitedNodes=new Set();var findAndUpdateNodes=function findAndUpdateNodes(node){if(!node){console.warn('findAndUpdateNodes was passed a nullish node');return;}if(visitedNodes.has(node)){return;}else{visitedNodes.add(node);}if(typeof node.update==='function'){node.update();}else{var nodes=node.__getChildren();if(nodes){for(var i=0,l=nodes.length;i<l;i++){findAndUpdateNodes(nodes[i]);}}}};for(var i=0;i<UPDATED_NODES.length;i++){var node=UPDATED_NODES[i];findAndUpdateNodes(node);}UPDATED_NODES.length=0;propUpdatesEnqueued=null;loopID+=1;}var nodeCount=0;var AnimatedNode=function(){function AnimatedNode(nodeConfig,inputNodes){(0,_classCallCheck2.default)(this,AnimatedNode);this.__lastLoopID=0;this.__memoizedValue=null;this.__children=[];this.__nodeID=++nodeCount;this.__nodeConfig=sanitizeConfig(nodeConfig);this.__initialized=false;this.__inputNodes=inputNodes&&inputNodes.filter(function(node){return node instanceof AnimatedNode;});}(0,_createClass2.default)(AnimatedNode,[{key:\"__attach\",value:function __attach(){this.__nativeInitialize();var nodes=this.__inputNodes;if(nodes){for(var i=0,l=nodes.length;i<l;i++){nodes[i].__addChild(this);}}}},{key:\"__detach\",value:function __detach(){var nodes=this.__inputNodes;if(nodes){for(var i=0,l=nodes.length;i<l;i++){nodes[i].__removeChild(this);}}this.__nativeTearDown();}},{key:\"__getValue\",value:function __getValue(){if(this.__lastLoopID<loopID){this.__lastLoopID=loopID;return this.__memoizedValue=this.__onEvaluate();}return this.__memoizedValue;}},{key:\"__forceUpdateCache\",value:function __forceUpdateCache(newValue){this.__memoizedValue=newValue;this.__markUpdated();}},{key:\"__dangerouslyRescheduleEvaluate\",value:function __dangerouslyRescheduleEvaluate(){this.__lastLoopID=0;this.__markUpdated();}},{key:\"__markUpdated\",value:function __markUpdated(){UPDATED_NODES.push(this);if(!propUpdatesEnqueued){propUpdatesEnqueued=setImmediate(runPropUpdates);}}},{key:\"__nativeInitialize\",value:function __nativeInitialize(){if(!this.__initialized){_ReanimatedModule.default.createNode(this.__nodeID,_objectSpread({},this.__nodeConfig));this.__initialized=true;}}},{key:\"__nativeTearDown\",value:function __nativeTearDown(){if(this.__initialized){_ReanimatedModule.default.dropNode(this.__nodeID);this.__initialized=false;}}},{key:\"isNativelyInitialized\",value:function isNativelyInitialized(){return this.__initialized;}},{key:\"__onEvaluate\",value:function __onEvaluate(){throw new Error('Missing implementation of onEvaluate');}},{key:\"__getProps\",value:function __getProps(){return this.__getValue();}},{key:\"__getChildren\",value:function __getChildren(){return this.__children;}},{key:\"__addChild\",value:function __addChild(child){if(this.__children.length===0){this.__attach();}this.__children.push(child);child.__nativeInitialize();if(_ReanimatedModule.default.connectNodes){_ReanimatedModule.default.connectNodes(this.__nodeID,child.__nodeID);}else{this.__dangerouslyRescheduleEvaluate();}}},{key:\"__removeChild\",value:function __removeChild(child){var index=this.__children.indexOf(child);if(index===-1){console.warn(\"Trying to remove a child that doesn't exist\");return;}_ReanimatedModule.default.disconnectNodes(this.__nodeID,child.__nodeID);this.__children.splice(index,1);if(this.__children.length===0){this.__detach();}}},{key:\"_connectAnimatedView\",value:function _connectAnimatedView(nativeViewTag){if(_ReanimatedModule.default.connectNodeToView){_ReanimatedModule.default.connectNodeToView(this.__nodeID,nativeViewTag);}else{this.__dangerouslyRescheduleEvaluate();}}},{key:\"_disconnectAnimatedView\",value:function _disconnectAnimatedView(nativeViewTag){_ReanimatedModule.default.disconnectNodeFromView(this.__nodeID,nativeViewTag);}}]);return AnimatedNode;}();exports.default=AnimatedNode;","map":{"version":3,"sources":["C:/Users/bluej/Desktop/2_2/searchGuide/searchGuide/node_modules/react-native-reanimated/src/core/AnimatedNode.js"],"names":["UPDATED_NODES","loopID","propUpdatesEnqueued","sanitizeConfig","config","key","value","AnimatedNode","__nodeID","runPropUpdates","visitedNodes","Set","findAndUpdateNodes","node","console","warn","has","add","update","nodes","__getChildren","i","l","length","nodeCount","nodeConfig","inputNodes","__lastLoopID","__memoizedValue","__children","__nodeConfig","__initialized","__inputNodes","filter","__nativeInitialize","__addChild","__removeChild","__nativeTearDown","__onEvaluate","newValue","__markUpdated","push","setImmediate","ReanimatedModule","createNode","dropNode","Error","__getValue","child","__attach","connectNodes","__dangerouslyRescheduleEvaluate","index","indexOf","disconnectNodes","splice","__detach","nativeViewTag","connectNodeToView","disconnectNodeFromView"],"mappings":"ubAAA,6E,yxBAEA,GAAMA,CAAAA,aAAa,CAAG,EAAtB,CAEA,GAAIC,CAAAA,MAAM,CAAG,CAAb,CACA,GAAIC,CAAAA,mBAAmB,CAAG,IAA1B,CAEA,QAASC,CAAAA,cAAT,CAA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AA8B,KAAK1C,QAAnC,CAA6CwC,KAAK,CAACxC,QAAnD,EACD,CAFD,IAEO,CACL,KAAK2C,+BAAL,GACD,CACF,C,oDAEaH,K,CAAO,CACnB,GAAMI,CAAAA,KAAK,CAAG,KAAKvB,UAAL,CAAgBwB,OAAhB,CAAwBL,KAAxB,CAAd,CACA,GAAII,KAAK,GAAK,CAAC,CAAf,CAAkB,CAChBtC,OAAO,CAACC,IAAR,CAAa,6CAAb,EACA,OACD,CACD4B,0BAAiBW,eAAjB,CAAiC,KAAK9C,QAAtC,CAAgDwC,KAAK,CAACxC,QAAtD,EAEA,KAAKqB,UAAL,CAAgB0B,MAAhB,CAAuBH,KAAvB,CAA8B,CAA9B,EACA,GAAI,KAAKvB,UAAL,CAAgBN,MAAhB,GAA2B,CAA/B,CAAkC,CAChC,KAAKiC,QAAL,GACD,CACF,C,kEAEoBC,a,CAAe,CAClC,GAAId,0BAAiBe,iBAArB,CAAwC,CACtCf,0BAAiBe,iBAAjB,CAAmC,KAAKlD,QAAxC,CAAkDiD,aAAlD,EACD,CAFD,IAEO,CACL,KAAKN,+BAAL,GACD,CACF,C,wEAEuBM,a,CAAe,CACrCd,0BAAiBgB,sBAAjB,CAAwC,KAAKnD,QAA7C,CAAuDiD,aAAvD,EACD,C","sourcesContent":["import ReanimatedModule from '../ReanimatedModule';\n\nconst UPDATED_NODES = [];\n\nlet loopID = 1;\nlet propUpdatesEnqueued = null;\n\nfunction sanitizeConfig(config) {\n for (const key in config) {\n const value = config[key];\n if (value instanceof AnimatedNode) {\n config[key] = value.__nodeID;\n }\n }\n return config;\n}\n\nfunction runPropUpdates() {\n const visitedNodes = new Set();\n const findAndUpdateNodes = node => {\n if (!node) {\n console.warn('findAndUpdateNodes was passed a nullish node');\n return;\n }\n\n if (visitedNodes.has(node)) {\n return;\n } else {\n visitedNodes.add(node);\n }\n if (typeof node.update === 'function') {\n node.update();\n } else {\n const nodes = node.__getChildren();\n if (nodes) {\n for (let i = 0, l = nodes.length; i < l; i++) {\n findAndUpdateNodes(nodes[i]);\n }\n }\n }\n };\n for (let i = 0; i < UPDATED_NODES.length; i++) {\n const node = UPDATED_NODES[i];\n findAndUpdateNodes(node);\n }\n UPDATED_NODES.length = 0; // clear array\n propUpdatesEnqueued = null;\n loopID += 1;\n}\n\nlet nodeCount = 0;\n\nexport default class AnimatedNode {\n constructor(nodeConfig, inputNodes) {\n this.__nodeID = ++nodeCount;\n this.__nodeConfig = sanitizeConfig(nodeConfig);\n this.__initialized = false;\n this.__inputNodes =\n inputNodes && inputNodes.filter(node => node instanceof AnimatedNode);\n }\n\n __attach() {\n this.__nativeInitialize();\n\n const nodes = this.__inputNodes;\n\n if (nodes) {\n for (let i = 0, l = nodes.length; i < l; i++) {\n nodes[i].__addChild(this);\n }\n }\n }\n\n __detach() {\n const nodes = this.__inputNodes;\n\n if (nodes) {\n for (let i = 0, l = nodes.length; i < l; i++) {\n nodes[i].__removeChild(this);\n }\n }\n\n this.__nativeTearDown();\n }\n\n __lastLoopID = 0;\n __memoizedValue = null;\n\n __children = [];\n\n __getValue() {\n if (this.__lastLoopID < loopID) {\n this.__lastLoopID = loopID;\n return (this.__memoizedValue = this.__onEvaluate());\n }\n return this.__memoizedValue;\n }\n\n __forceUpdateCache(newValue) {\n this.__memoizedValue = newValue;\n this.__markUpdated();\n }\n\n __dangerouslyRescheduleEvaluate() {\n this.__lastLoopID = 0;\n this.__markUpdated();\n }\n\n __markUpdated() {\n UPDATED_NODES.push(this);\n if (!propUpdatesEnqueued) {\n propUpdatesEnqueued = setImmediate(runPropUpdates);\n }\n }\n\n __nativeInitialize() {\n if (!this.__initialized) {\n ReanimatedModule.createNode(this.__nodeID, { ...this.__nodeConfig });\n this.__initialized = true;\n }\n }\n\n __nativeTearDown() {\n if (this.__initialized) {\n ReanimatedModule.dropNode(this.__nodeID);\n this.__initialized = false;\n }\n }\n\n isNativelyInitialized() {\n return this.__initialized;\n }\n\n __onEvaluate() {\n throw new Error('Missing implementation of onEvaluate');\n }\n\n __getProps() {\n return this.__getValue();\n }\n\n __getChildren() {\n return this.__children;\n }\n\n __addChild(child) {\n if (this.__children.length === 0) {\n this.__attach();\n }\n this.__children.push(child);\n child.__nativeInitialize();\n\n if (ReanimatedModule.connectNodes) {\n ReanimatedModule.connectNodes(this.__nodeID, child.__nodeID);\n } else {\n this.__dangerouslyRescheduleEvaluate();\n }\n }\n\n __removeChild(child) {\n const index = this.__children.indexOf(child);\n if (index === -1) {\n console.warn(\"Trying to remove a child that doesn't exist\");\n return;\n }\n ReanimatedModule.disconnectNodes(this.__nodeID, child.__nodeID);\n\n this.__children.splice(index, 1);\n if (this.__children.length === 0) {\n this.__detach();\n }\n }\n\n _connectAnimatedView(nativeViewTag) {\n if (ReanimatedModule.connectNodeToView) {\n ReanimatedModule.connectNodeToView(this.__nodeID, nativeViewTag);\n } else {\n this.__dangerouslyRescheduleEvaluate();\n }\n }\n\n _disconnectAnimatedView(nativeViewTag) {\n ReanimatedModule.disconnectNodeFromView(this.__nodeID, nativeViewTag);\n }\n}\n"]},"metadata":{},"sourceType":"script"}