901557dbdb75ee7828dbb2a6ecb24f12.json 14.8 KB
{"ast":null,"code":"var __extends = this && this.__extends || function () {\n  var extendStatics = function (d, b) {\n    extendStatics = Object.setPrototypeOf || {\n      __proto__: []\n    } instanceof Array && function (d, b) {\n      d.__proto__ = b;\n    } || function (d, b) {\n      for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n    };\n\n    return extendStatics(d, b);\n  };\n\n  return function (d, b) {\n    extendStatics(d, b);\n\n    function __() {\n      this.constructor = d;\n    }\n\n    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n  };\n}();\n\nvar __assign = this && this.__assign || function () {\n  __assign = Object.assign || function (t) {\n    for (var s, i = 1, n = arguments.length; i < n; i++) {\n      s = arguments[i];\n\n      for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n    }\n\n    return t;\n  };\n\n  return __assign.apply(this, arguments);\n};\n\nimport * as React from 'react';\nimport shallowEqual from 'shallowequal';\nimport hoistStatics from 'hoist-non-react-statics';\nimport { MiniStoreContext } from './Provider';\n\nfunction getDisplayName(WrappedComponent) {\n  return WrappedComponent.displayName || WrappedComponent.name || 'Component';\n}\n\nvar defaultMapStateToProps = function () {\n  return {};\n};\n\nexport function connect(mapStateToProps, options) {\n  if (options === void 0) {\n    options = {};\n  }\n\n  var shouldSubscribe = !!mapStateToProps;\n  var finalMapStateToProps = mapStateToProps || defaultMapStateToProps;\n  return function wrapWithConnect(WrappedComponent) {\n    var Connect =\n    /** @class */\n    function (_super) {\n      __extends(Connect, _super);\n\n      function Connect(props, context) {\n        var _this = _super.call(this, props, context) || this;\n\n        _this.unsubscribe = null;\n\n        _this.handleChange = function () {\n          if (!_this.unsubscribe) {\n            return;\n          }\n\n          var nextState = finalMapStateToProps(_this.store.getState(), _this.props);\n\n          _this.setState({\n            subscribed: nextState\n          });\n        };\n\n        _this.store = _this.context;\n        _this.state = {\n          subscribed: finalMapStateToProps(_this.store.getState(), props),\n          store: _this.store,\n          props: props\n        };\n        return _this;\n      }\n\n      Connect.getDerivedStateFromProps = function (props, prevState) {\n        // using ownProps\n        if (mapStateToProps && mapStateToProps.length === 2 && props !== prevState.props) {\n          return {\n            subscribed: finalMapStateToProps(prevState.store.getState(), props),\n            props: props\n          };\n        }\n\n        return {\n          props: props\n        };\n      };\n\n      Connect.prototype.componentDidMount = function () {\n        this.trySubscribe();\n      };\n\n      Connect.prototype.componentWillUnmount = function () {\n        this.tryUnsubscribe();\n      };\n\n      Connect.prototype.shouldComponentUpdate = function (nextProps, nextState) {\n        return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state.subscribed, nextState.subscribed);\n      };\n\n      Connect.prototype.trySubscribe = function () {\n        if (shouldSubscribe) {\n          this.unsubscribe = this.store.subscribe(this.handleChange);\n          this.handleChange();\n        }\n      };\n\n      Connect.prototype.tryUnsubscribe = function () {\n        if (this.unsubscribe) {\n          this.unsubscribe();\n          this.unsubscribe = null;\n        }\n      };\n\n      Connect.prototype.render = function () {\n        var props = __assign(__assign(__assign({}, this.props), this.state.subscribed), {\n          store: this.store\n        });\n\n        return React.createElement(WrappedComponent, __assign({}, props, {\n          ref: this.props.miniStoreForwardedRef\n        }));\n      };\n\n      Connect.displayName = \"Connect(\" + getDisplayName(WrappedComponent) + \")\";\n      Connect.contextType = MiniStoreContext;\n      return Connect;\n    }(React.Component);\n\n    if (options.forwardRef) {\n      var forwarded = React.forwardRef(function (props, ref) {\n        return React.createElement(Connect, __assign({}, props, {\n          miniStoreForwardedRef: ref\n        }));\n      });\n      return hoistStatics(forwarded, WrappedComponent);\n    }\n\n    return hoistStatics(Connect, WrappedComponent);\n  };\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/mini-store/esm/connect.js"],"names":["__extends","extendStatics","d","b","Object","setPrototypeOf","__proto__","Array","p","hasOwnProperty","__","constructor","prototype","create","__assign","assign","t","s","i","n","arguments","length","call","apply","React","shallowEqual","hoistStatics","MiniStoreContext","getDisplayName","WrappedComponent","displayName","name","defaultMapStateToProps","connect","mapStateToProps","options","shouldSubscribe","finalMapStateToProps","wrapWithConnect","Connect","_super","props","context","_this","unsubscribe","handleChange","nextState","store","getState","setState","subscribed","state","getDerivedStateFromProps","prevState","componentDidMount","trySubscribe","componentWillUnmount","tryUnsubscribe","shouldComponentUpdate","nextProps","subscribe","render","createElement","ref","miniStoreForwardedRef","contextType","Component","forwardRef","forwarded"],"mappings":"AAAA,IAAIA,SAAS,GAAI,QAAQ,KAAKA,SAAd,IAA6B,YAAY;AACrD,MAAIC,aAAa,GAAG,UAAUC,CAAV,EAAaC,CAAb,EAAgB;AAChCF,IAAAA,aAAa,GAAGG,MAAM,CAACC,cAAP,IACX;AAAEC,MAAAA,SAAS,EAAE;AAAb,iBAA6BC,KAA7B,IAAsC,UAAUL,CAAV,EAAaC,CAAb,EAAgB;AAAED,MAAAA,CAAC,CAACI,SAAF,GAAcH,CAAd;AAAkB,KAD/D,IAEZ,UAAUD,CAAV,EAAaC,CAAb,EAAgB;AAAE,WAAK,IAAIK,CAAT,IAAcL,CAAd,EAAiB,IAAIA,CAAC,CAACM,cAAF,CAAiBD,CAAjB,CAAJ,EAAyBN,CAAC,CAACM,CAAD,CAAD,GAAOL,CAAC,CAACK,CAAD,CAAR;AAAc,KAF9E;;AAGA,WAAOP,aAAa,CAACC,CAAD,EAAIC,CAAJ,CAApB;AACH,GALD;;AAMA,SAAO,UAAUD,CAAV,EAAaC,CAAb,EAAgB;AACnBF,IAAAA,aAAa,CAACC,CAAD,EAAIC,CAAJ,CAAb;;AACA,aAASO,EAAT,GAAc;AAAE,WAAKC,WAAL,GAAmBT,CAAnB;AAAuB;;AACvCA,IAAAA,CAAC,CAACU,SAAF,GAAcT,CAAC,KAAK,IAAN,GAAaC,MAAM,CAACS,MAAP,CAAcV,CAAd,CAAb,IAAiCO,EAAE,CAACE,SAAH,GAAeT,CAAC,CAACS,SAAjB,EAA4B,IAAIF,EAAJ,EAA7D,CAAd;AACH,G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AT,EAA4D;AAAEH,UAAAA,KAAK,EAAE,KAAKA;AAAd,SAA5D,CAApB;;AACA,eAAOvB,KAAK,CAACsC,aAAN,CAAoBjC,gBAApB,EAAsCf,QAAQ,CAAC,EAAD,EAAK2B,KAAL,EAAY;AAAEsB,UAAAA,GAAG,EAAE,KAAKtB,KAAL,CAAWuB;AAAlB,SAAZ,CAA9C,CAAP;AACH,OAHD;;AAIAzB,MAAAA,OAAO,CAACT,WAAR,GAAsB,aAAaF,cAAc,CAACC,gBAAD,CAA3B,GAAgD,GAAtE;AACAU,MAAAA,OAAO,CAAC0B,WAAR,GAAsBtC,gBAAtB;AACA,aAAOY,OAAP;AACH,KA3D4B,CA2D3Bf,KAAK,CAAC0C,SA3DqB,CAA7B;;AA4DA,QAAI/B,OAAO,CAACgC,UAAZ,EAAwB;AACpB,UAAIC,SAAS,GAAG5C,KAAK,CAAC2C,UAAN,CAAiB,UAAU1B,KAAV,EAAiBsB,GAAjB,EAAsB;AACnD,eAAOvC,KAAK,CAACsC,aAAN,CAAoBvB,OAApB,EAA6BzB,QAAQ,CAAC,EAAD,EAAK2B,KAAL,EAAY;AAAEuB,UAAAA,qBAAqB,EAAED;AAAzB,SAAZ,CAArC,CAAP;AACH,OAFe,CAAhB;AAGA,aAAOrC,YAAY,CAAC0C,SAAD,EAAYvC,gBAAZ,CAAnB;AACH;;AACD,WAAOH,YAAY,CAACa,OAAD,EAAUV,gBAAV,CAAnB;AACH,GApED;AAqEH","sourcesContent":["var __extends = (this && this.__extends) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\nvar __assign = (this && this.__assign) || function () {\n    __assign = Object.assign || function(t) {\n        for (var s, i = 1, n = arguments.length; i < n; i++) {\n            s = arguments[i];\n            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n                t[p] = s[p];\n        }\n        return t;\n    };\n    return __assign.apply(this, arguments);\n};\nimport * as React from 'react';\nimport shallowEqual from 'shallowequal';\nimport hoistStatics from 'hoist-non-react-statics';\nimport { MiniStoreContext } from './Provider';\nfunction getDisplayName(WrappedComponent) {\n    return WrappedComponent.displayName || WrappedComponent.name || 'Component';\n}\nvar defaultMapStateToProps = function () { return ({}); };\nexport function connect(mapStateToProps, options) {\n    if (options === void 0) { options = {}; }\n    var shouldSubscribe = !!mapStateToProps;\n    var finalMapStateToProps = mapStateToProps || defaultMapStateToProps;\n    return function wrapWithConnect(WrappedComponent) {\n        var Connect = /** @class */ (function (_super) {\n            __extends(Connect, _super);\n            function Connect(props, context) {\n                var _this = _super.call(this, props, context) || this;\n                _this.unsubscribe = null;\n                _this.handleChange = function () {\n                    if (!_this.unsubscribe) {\n                        return;\n                    }\n                    var nextState = finalMapStateToProps(_this.store.getState(), _this.props);\n                    _this.setState({ subscribed: nextState });\n                };\n                _this.store = _this.context;\n                _this.state = {\n                    subscribed: finalMapStateToProps(_this.store.getState(), props),\n                    store: _this.store,\n                    props: props,\n                };\n                return _this;\n            }\n            Connect.getDerivedStateFromProps = function (props, prevState) {\n                // using ownProps\n                if (mapStateToProps && mapStateToProps.length === 2 && props !== prevState.props) {\n                    return {\n                        subscribed: finalMapStateToProps(prevState.store.getState(), props),\n                        props: props,\n                    };\n                }\n                return { props: props };\n            };\n            Connect.prototype.componentDidMount = function () {\n                this.trySubscribe();\n            };\n            Connect.prototype.componentWillUnmount = function () {\n                this.tryUnsubscribe();\n            };\n            Connect.prototype.shouldComponentUpdate = function (nextProps, nextState) {\n                return (!shallowEqual(this.props, nextProps) ||\n                    !shallowEqual(this.state.subscribed, nextState.subscribed));\n            };\n            Connect.prototype.trySubscribe = function () {\n                if (shouldSubscribe) {\n                    this.unsubscribe = this.store.subscribe(this.handleChange);\n                    this.handleChange();\n                }\n            };\n            Connect.prototype.tryUnsubscribe = function () {\n                if (this.unsubscribe) {\n                    this.unsubscribe();\n                    this.unsubscribe = null;\n                }\n            };\n            Connect.prototype.render = function () {\n                var props = __assign(__assign(__assign({}, this.props), this.state.subscribed), { store: this.store });\n                return React.createElement(WrappedComponent, __assign({}, props, { ref: this.props.miniStoreForwardedRef }));\n            };\n            Connect.displayName = \"Connect(\" + getDisplayName(WrappedComponent) + \")\";\n            Connect.contextType = MiniStoreContext;\n            return Connect;\n        }(React.Component));\n        if (options.forwardRef) {\n            var forwarded = React.forwardRef(function (props, ref) {\n                return React.createElement(Connect, __assign({}, props, { miniStoreForwardedRef: ref }));\n            });\n            return hoistStatics(forwarded, WrappedComponent);\n        }\n        return hoistStatics(Connect, WrappedComponent);\n    };\n}\n"]},"metadata":{},"sourceType":"module"}