a1c3145cf44d0cc6039a80f89f70dfd3.json 7.8 KB

1
  1. {"ast":null,"code":"import verifyPlainObject from '../utils/verifyPlainObject';\nexport function wrapMapToPropsConstant(getConstant) {\n return function initConstantSelector(dispatch, options) {\n var constant = getConstant(dispatch, options);\n\n function constantSelector() {\n return constant;\n }\n\n constantSelector.dependsOnOwnProps = false;\n return constantSelector;\n };\n} // dependsOnOwnProps is used by createMapToPropsProxy to determine whether to pass props as args\n// to the mapToProps function being wrapped. It is also used by makePurePropsSelector to determine\n// whether mapToProps needs to be invoked when props have changed.\n//\n// A length of one signals that mapToProps does not depend on props from the parent component.\n// A length of zero is assumed to mean mapToProps is getting args via arguments or ...args and\n// therefore not reporting its length accurately..\n\nexport function getDependsOnOwnProps(mapToProps) {\n return mapToProps.dependsOnOwnProps !== null && mapToProps.dependsOnOwnProps !== undefined ? Boolean(mapToProps.dependsOnOwnProps) : mapToProps.length !== 1;\n} // Used by whenMapStateToPropsIsFunction and whenMapDispatchToPropsIsFunction,\n// this function wraps mapToProps in a proxy function which does several things:\n//\n// * Detects whether the mapToProps function being called depends on props, which\n// is used by selectorFactory to decide if it should reinvoke on props changes.\n//\n// * On first call, handles mapToProps if returns another function, and treats that\n// new function as the true mapToProps for subsequent calls.\n//\n// * On first call, verifies the first result is a plain object, in order to warn\n// the developer that their mapToProps function is not returning a valid result.\n//\n\nexport function wrapMapToPropsFunc(mapToProps, methodName) {\n return function initProxySelector(dispatch, _ref) {\n var displayName = _ref.displayName;\n\n var proxy = function mapToPropsProxy(stateOrDispatch, ownProps) {\n return proxy.dependsOnOwnProps ? proxy.mapToProps(stateOrDispatch, ownProps) : proxy.mapToProps(stateOrDispatch);\n }; // allow detectFactoryAndVerify to get ownProps\n\n\n proxy.dependsOnOwnProps = true;\n\n proxy.mapToProps = function detectFactoryAndVerify(stateOrDispatch, ownProps) {\n proxy.mapToProps = mapToProps;\n proxy.dependsOnOwnProps = getDependsOnOwnProps(mapToProps);\n var props = proxy(stateOrDispatch, ownProps);\n\n if (typeof props === 'function') {\n proxy.mapToProps = props;\n proxy.dependsOnOwnProps = getDependsOnOwnProps(props);\n props = proxy(stateOrDispatch, ownProps);\n }\n\n if (process.env.NODE_ENV !== 'production') verifyPlainObject(props, displayName, methodName);\n return props;\n };\n\n return proxy;\n };\n}","map":{"version":3,"sources":["/home/ilya/projects/NIX/homework/react/react-store/node_modules/react-redux/es/connect/wrapMapToProps.js"],"names":["verifyPlainObject","wrapMapToPropsConstant","getConstant","initConstantSelector","dispatch","options","constant","constantSelector","dependsOnOwnProps","getDependsOnOwnProps","mapToProps","undefined","Boolean","length","wrapMapToPropsFunc","methodName","initProxySelector","_ref","displayName","proxy","mapToPropsProxy","stateOrDispatch","ownProps","detectFactoryAndVerify","props","process","env","NODE_ENV"],"mappings":"AAAA,OAAOA,iBAAP,MAA8B,4BAA9B;AACA,OAAO,SAASC,sBAAT,CAAgCC,WAAhC,EAA6C;AAClD,SAAO,SAASC,oBAAT,CAA8BC,QAA9B,EAAwCC,OAAxC,EAAiD;AACtD,QAAIC,QAAQ,GAAGJ,WAAW,CAACE,QAAD,EAAWC,OAAX,CAA1B;;AAEA,aAASE,gBAAT,GAA4B;AAC1B,aAAOD,QAAP;AACD;;AAEDC,IAAAA,gBAAgB,CAACC,iBAAjB,GAAqC,KAArC;AACA,WAAOD,gBAAP;AACD,GATD;AAUD,C,CAAC;AACF;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASE,oBAAT,CAA8BC,UAA9B,EAA0C;AAC/C,SAAOA,UAAU,CAACF,iBAAX,KAAiC,IAAjC,IAAyCE,UAAU,CAACF,iBAAX,KAAiCG,SAA1E,GAAsFC,OAAO,CAACF,UAAU,CAACF,iBAAZ,CAA7F,GAA8HE,UAAU,CAACG,MAAX,KAAsB,CAA3J;AACD,C,CAAC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASC,kBAAT,CAA4BJ,UAA5B,EAAwCK,UAAxC,EAAoD;AACzD,SAAO,SAASC,iBAAT,CAA2BZ,QAA3B,EAAqCa,IAArC,EAA2C;AAChD,QAAIC,WAAW,GAAGD,IAAI,CAACC,WAAvB;;AAEA,QAAIC,KAAK,GAAG,SAASC,eAAT,CAAyBC,eAAzB,EAA0CC,QAA1C,EAAoD;AAC9D,aAAOH,KAAK,CAACX,iBAAN,GAA0BW,KAAK,CAACT,UAAN,CAAiBW,eAAjB,EAAkCC,QAAlC,CAA1B,GAAwEH,KAAK,CAACT,UAAN,CAAiBW,eAAjB,CAA/E;AACD,KAFD,CAHgD,CAK7C;;;AAGHF,IAAAA,KAAK,CAACX,iBAAN,GAA0B,IAA1B;;AAEAW,IAAAA,KAAK,CAACT,UAAN,GAAmB,SAASa,sBAAT,CAAgCF,eAAhC,EAAiDC,QAAjD,EAA2D;AAC5EH,MAAAA,KAAK,CAACT,UAAN,GAAmBA,UAAnB;AACAS,MAAAA,KAAK,CAACX,iBAAN,GAA0BC,oBAAoB,CAACC,UAAD,CAA9C;AACA,UAAIc,KAAK,GAAGL,KAAK,CAACE,eAAD,EAAkBC,QAAlB,CAAjB;;AAEA,UAAI,OAAOE,KAAP,KAAiB,UAArB,EAAiC;AAC/BL,QAAAA,KAAK,CAACT,UAAN,GAAmBc,KAAnB;AACAL,QAAAA,KAAK,CAACX,iBAAN,GAA0BC,oBAAoB,CAACe,KAAD,CAA9C;AACAA,QAAAA,KAAK,GAAGL,KAAK,CAACE,eAAD,EAAkBC,QAAlB,CAAb;AACD;;AAED,UAAIG,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C3B,iBAAiB,CAACwB,KAAD,EAAQN,WAAR,EAAqBH,UAArB,CAAjB;AAC3C,aAAOS,KAAP;AACD,KAbD;;AAeA,WAAOL,KAAP;AACD,GA1BD;AA2BD","sourcesContent":["import verifyPlainObject from '../utils/verifyPlainObject';\nexport function wrapMapToPropsConstant(getConstant) {\n return function initConstantSelector(dispatch, options) {\n var constant = getConstant(dispatch, options);\n\n function constantSelector() {\n return constant;\n }\n\n constantSelector.dependsOnOwnProps = false;\n return constantSelector;\n };\n} // dependsOnOwnProps is used by createMapToPropsProxy to determine whether to pass props as args\n// to the mapToProps function being wrapped. It is also used by makePurePropsSelector to determine\n// whether mapToProps needs to be invoked when props have changed.\n//\n// A length of one signals that mapToProps does not depend on props from the parent component.\n// A length of zero is assumed to mean mapToProps is getting args via arguments or ...args and\n// therefore not reporting its length accurately..\n\nexport function getDependsOnOwnProps(mapToProps) {\n return mapToProps.dependsOnOwnProps !== null && mapToProps.dependsOnOwnProps !== undefined ? Boolean(mapToProps.dependsOnOwnProps) : mapToProps.length !== 1;\n} // Used by whenMapStateToPropsIsFunction and whenMapDispatchToPropsIsFunction,\n// this function wraps mapToProps in a proxy function which does several things:\n//\n// * Detects whether the mapToProps function being called depends on props, which\n// is used by selectorFactory to decide if it should reinvoke on props changes.\n//\n// * On first call, handles mapToProps if returns another function, and treats that\n// new function as the true mapToProps for subsequent calls.\n//\n// * On first call, verifies the first result is a plain object, in order to warn\n// the developer that their mapToProps function is not returning a valid result.\n//\n\nexport function wrapMapToPropsFunc(mapToProps, methodName) {\n return function initProxySelector(dispatch, _ref) {\n var displayName = _ref.displayName;\n\n var proxy = function mapToPropsProxy(stateOrDispatch, ownProps) {\n return proxy.dependsOnOwnProps ? proxy.mapToProps(stateOrDispatch, ownProps) : proxy.mapToProps(stateOrDispatch);\n }; // allow detectFactoryAndVerify to get ownProps\n\n\n proxy.dependsOnOwnProps = true;\n\n proxy.mapToProps = function detectFactoryAndVerify(stateOrDispatch, ownProps) {\n proxy.mapToProps = mapToProps;\n proxy.dependsOnOwnProps = getDependsOnOwnProps(mapToProps);\n var props = proxy(stateOrDispatch, ownProps);\n\n if (typeof props === 'function') {\n proxy.mapToProps = props;\n proxy.dependsOnOwnProps = getDependsOnOwnProps(props);\n props = proxy(stateOrDispatch, ownProps);\n }\n\n if (process.env.NODE_ENV !== 'production') verifyPlainObject(props, displayName, methodName);\n return props;\n };\n\n return proxy;\n };\n}"]},"metadata":{},"sourceType":"module"}