reactant-last-action
Version:
A Reactant plugin for staging last action
2 lines (1 loc) • 3.51 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("reactant-module")):"function"==typeof define&&define.amd?define(["exports","reactant-module"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).reactantLastAction={},e.reactantModule)}(this,(function(e,t){"use strict";var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)};var o=function(){return o=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},o.apply(this,arguments)};function r(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}"function"==typeof SuppressedError&&SuppressedError;var i=Symbol("LastActionOptions"),c=function(e){function c(t){var n,o,r=e.call(this)||this;return r.options=t,r.stateKey=null!==(o=null===(n=r.options)||void 0===n?void 0:n.stateKey)&&void 0!==o?o:"lastAction",r}var a,l;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}(c,e),c.prototype.beforeCombineRootReducers=function(e){var n,r=this;if(Object.prototype.hasOwnProperty.call(e,this.stateKey))throw new Error("The identifier '".concat(this.stateKey,"' has a duplicate name, please reset the option 'stateKey' of 'LastAction' module."));return Object.assign(e,((n={})[this.stateKey]=function(e,n){var i,c,a;void 0===e&&(e=null);var l=n._inversePatches,s=n.state,u=n.rehydrate,f=n.register,p=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(n,["_inversePatches","state","rehydrate","register"]),y="function"==typeof u||null==u?{}:{rehydrate:u},d="function"==typeof f||null==f?{}:{register:f},v=p._reactant===t.actionIdentifier?{}:{state:s,_inversePatches:l},h=null!==(i=null==e?void 0:e._sequence)&&void 0!==i?i:0,b=null===(a=null===(c=r.options)||void 0===c?void 0:c.ignoreAction)||void 0===a?void 0:a.call(c,p);return o(o(o(o(o({},p),y),d),v),{_sequence:b?h:h+1})},n))},Object.defineProperty(c.prototype,"sequence",{get:function(){var e,t,n;return null!==(n=null!==(e=this._sequence)&&void 0!==e?e:null===(t=this.action)||void 0===t?void 0:t._sequence)&&void 0!==n?n:0},set:function(e){this._sequence=e},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"action",{get:function(){var e,n;return null!==(n=null===(e=this[t.storeKey])||void 0===e?void 0:e.getState()[this.stateKey])&&void 0!==n?n:null},enumerable:!1,configurable:!0}),c=function(e,t,n,o){var r,i=arguments.length,c=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(c=(i<3?r(c):i>3?r(t,n,c):r(t,n))||c);return i>3&&c&&Object.defineProperty(t,n,c),c}([t.injectable(),(a=0,l=t.optional(i),function(e,t){l(e,t,a)}),r("design:paramtypes",[Object])],c),c}(t.PluginModule);e.LastAction=c,e.LastActionOptions=i}));