Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rematch/loading

Package Overview
Dependencies
Maintainers
3
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rematch/loading - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

2

dist/loading.cjs.development.js

@@ -222,3 +222,3 @@ 'use strict';

exports.default = index;
exports["default"] = index;
//# sourceMappingURL=loading.cjs.development.js.map

@@ -1,2 +0,2 @@

"use strict";function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e}).apply(this,arguments)}Object.defineProperty(exports,"__esModule",{value:!0});var t=function(t,a,n){return function(o,i){var c,l,s,d=i||{name:"",action:""},r=d.name,f=d.action,u=d.detailedPayload;return n.global+=a,n.models[r]+=a,n.effects[r][f]+=a,e({},o,{global:t(n.global,u),models:e({},o.models,(c={},c[r]=t(n.models[r],u),c)),effects:e({},o.effects,(s={},s[r]=e({},o.effects[r],(l={},l[f]=t(n.effects[r][f],u),l)),s))})}};function a(e,t,a){return e?{error:t,success:a}:null}exports.default=function(n){void 0===n&&(n={});var o=n.name||"loading";n.asNumber&&(n.type="number");var i="number"===n.type,c="full"===n.type,l=function(t,a){return i?t:c&&a?e({},a,{loading:t>0}):c?{loading:t>0,success:!1,error:!1}:t>0},s={global:l(0),models:{},effects:{}},d={global:0,models:{},effects:{}},r={name:o,reducers:{hide:t(l,-1,d),show:t(l,1,d)},state:s},f=l(0);return{config:{models:{loading:r}},onModel:function(e,t){var i=e.name;i!==o&&(d.models[i]=0,d.effects[i]={},s.models[i]=f,s.effects[i]={},Object.keys(t.dispatch[i]).forEach((function(e){if(!1!==t.dispatch[i][e].isEffect){d.effects[i][e]=0,s.effects[i][e]=f;var l=i+"/"+e;if((!n.whitelist||n.whitelist.includes(l))&&(!n.blacklist||!n.blacklist.includes(l))){var r=t.dispatch[i][e],u=function(){try{t.dispatch[o].show({name:i,action:e,detailedPayload:a(c,!1,!1)});var n=r.apply(void 0,arguments);return null!=n&&n.then?n.then((function(n){return t.dispatch[o].hide({name:i,action:e,detailedPayload:a(c,!1,!0)}),n})).catch((function(n){throw t.dispatch[o].hide({name:i,action:e,detailedPayload:a(c,n,!1)}),n})):(t.dispatch[o].hide({name:i,action:e,detailedPayload:a(c,!1,!0)}),n)}catch(n){throw t.dispatch[o].hide({name:i,action:e,detailedPayload:a(c,n,!1)}),n}};u.isEffect=!0,t.dispatch[i][e]=u}}})))}}};
"use strict";function e(){return e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},e.apply(this,arguments)}Object.defineProperty(exports,"__esModule",{value:!0});var t=function(t,a,n){return function(o,i){var c,l,s,d=i||{name:"",action:""},r=d.name,f=d.action,u=d.detailedPayload;return n.global+=a,n.models[r]+=a,n.effects[r][f]+=a,e({},o,{global:t(n.global,u),models:e({},o.models,(c={},c[r]=t(n.models[r],u),c)),effects:e({},o.effects,(s={},s[r]=e({},o.effects[r],(l={},l[f]=t(n.effects[r][f],u),l)),s))})}};function a(e,t,a){return e?{error:t,success:a}:null}exports.default=function(n){void 0===n&&(n={});var o=n.name||"loading";n.asNumber&&(n.type="number");var i="number"===n.type,c="full"===n.type,l=function(t,a){return i?t:c&&a?e({},a,{loading:t>0}):c?{loading:t>0,success:!1,error:!1}:t>0},s={global:l(0),models:{},effects:{}},d={global:0,models:{},effects:{}},r={name:o,reducers:{hide:t(l,-1,d),show:t(l,1,d)},state:s},f=l(0);return{config:{models:{loading:r}},onModel:function(e,t){var i=e.name;i!==o&&(d.models[i]=0,d.effects[i]={},s.models[i]=f,s.effects[i]={},Object.keys(t.dispatch[i]).forEach((function(e){if(!1!==t.dispatch[i][e].isEffect){d.effects[i][e]=0,s.effects[i][e]=f;var l=i+"/"+e;if((!n.whitelist||n.whitelist.includes(l))&&(!n.blacklist||!n.blacklist.includes(l))){var r=t.dispatch[i][e],u=function(){try{t.dispatch[o].show({name:i,action:e,detailedPayload:a(c,!1,!1)});var n=r.apply(void 0,arguments);return null!=n&&n.then?n.then((function(n){return t.dispatch[o].hide({name:i,action:e,detailedPayload:a(c,!1,!0)}),n})).catch((function(n){throw t.dispatch[o].hide({name:i,action:e,detailedPayload:a(c,n,!1)}),n})):(t.dispatch[o].hide({name:i,action:e,detailedPayload:a(c,!1,!0)}),n)}catch(n){throw t.dispatch[o].hide({name:i,action:e,detailedPayload:a(c,n,!1)}),n}};u.isEffect=!0,t.dispatch[i][e]=u}}})))}}};
//# sourceMappingURL=loading.cjs.production.min.js.map

@@ -218,3 +218,3 @@ function _extends() {

export default index;
export { index as default };
//# sourceMappingURL=loading.esm.js.map
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global['@rematch/loading'] = {}));
}(this, (function (exports) { 'use strict';
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rematch/loading"] = {}));
})(this, (function (exports) { 'use strict';

@@ -224,7 +224,7 @@ function _extends() {

exports.default = index;
exports["default"] = index;
Object.defineProperty(exports, '__esModule', { value: true });
})));
}));
//# sourceMappingURL=loading.umd.development.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self)["@rematch/loading"]={})}(this,(function(e){"use strict";function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e}).apply(this,arguments)}var a=function(e,a,n){return function(o,i){var c,d,l,s=i||{name:"",action:""},f=s.name,r=s.action,u=s.detailedPayload;return n.global+=a,n.models[f]+=a,n.effects[f][r]+=a,t({},o,{global:e(n.global,u),models:t({},o.models,(c={},c[f]=e(n.models[f],u),c)),effects:t({},o.effects,(l={},l[f]=t({},o.effects[f],(d={},d[r]=e(n.effects[f][r],u),d)),l))})}};function n(e,t,a){return e?{error:t,success:a}:null}e.default=function(e){void 0===e&&(e={});var o=e.name||"loading";e.asNumber&&(e.type="number");var i="number"===e.type,c="full"===e.type,d=function(e,a){return i?e:c&&a?t({},a,{loading:e>0}):c?{loading:e>0,success:!1,error:!1}:e>0},l={global:d(0),models:{},effects:{}},s={global:0,models:{},effects:{}},f={name:o,reducers:{hide:a(d,-1,s),show:a(d,1,s)},state:l},r=d(0);return{config:{models:{loading:f}},onModel:function(t,a){var i=t.name;i!==o&&(s.models[i]=0,s.effects[i]={},l.models[i]=r,l.effects[i]={},Object.keys(a.dispatch[i]).forEach((function(t){if(!1!==a.dispatch[i][t].isEffect){s.effects[i][t]=0,l.effects[i][t]=r;var d=i+"/"+t;if((!e.whitelist||e.whitelist.includes(d))&&(!e.blacklist||!e.blacklist.includes(d))){var f=a.dispatch[i][t],u=function(){try{a.dispatch[o].show({name:i,action:t,detailedPayload:n(c,!1,!1)});var e=f.apply(void 0,arguments);return null!=e&&e.then?e.then((function(e){return a.dispatch[o].hide({name:i,action:t,detailedPayload:n(c,!1,!0)}),e})).catch((function(e){throw a.dispatch[o].hide({name:i,action:t,detailedPayload:n(c,e,!1)}),e})):(a.dispatch[o].hide({name:i,action:t,detailedPayload:n(c,!1,!0)}),e)}catch(e){throw a.dispatch[o].hide({name:i,action:t,detailedPayload:n(c,e,!1)}),e}};u.isEffect=!0,a.dispatch[i][t]=u}}})))}}},Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@rematch/loading"]={})}(this,(function(e){"use strict";function t(){return t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},t.apply(this,arguments)}var a=function(e,a,n){return function(o,i){var c,l,d,s=i||{name:"",action:""},f=s.name,r=s.action,u=s.detailedPayload;return n.global+=a,n.models[f]+=a,n.effects[f][r]+=a,t({},o,{global:e(n.global,u),models:t({},o.models,(c={},c[f]=e(n.models[f],u),c)),effects:t({},o.effects,(d={},d[f]=t({},o.effects[f],(l={},l[r]=e(n.effects[f][r],u),l)),d))})}};function n(e,t,a){return e?{error:t,success:a}:null}e.default=function(e){void 0===e&&(e={});var o=e.name||"loading";e.asNumber&&(e.type="number");var i="number"===e.type,c="full"===e.type,l=function(e,a){return i?e:c&&a?t({},a,{loading:e>0}):c?{loading:e>0,success:!1,error:!1}:e>0},d={global:l(0),models:{},effects:{}},s={global:0,models:{},effects:{}},f={name:o,reducers:{hide:a(l,-1,s),show:a(l,1,s)},state:d},r=l(0);return{config:{models:{loading:f}},onModel:function(t,a){var i=t.name;i!==o&&(s.models[i]=0,s.effects[i]={},d.models[i]=r,d.effects[i]={},Object.keys(a.dispatch[i]).forEach((function(t){if(!1!==a.dispatch[i][t].isEffect){s.effects[i][t]=0,d.effects[i][t]=r;var l=i+"/"+t;if((!e.whitelist||e.whitelist.includes(l))&&(!e.blacklist||!e.blacklist.includes(l))){var f=a.dispatch[i][t],u=function(){try{a.dispatch[o].show({name:i,action:t,detailedPayload:n(c,!1,!1)});var e=f.apply(void 0,arguments);return null!=e&&e.then?e.then((function(e){return a.dispatch[o].hide({name:i,action:t,detailedPayload:n(c,!1,!0)}),e})).catch((function(e){throw a.dispatch[o].hide({name:i,action:t,detailedPayload:n(c,e,!1)}),e})):(a.dispatch[o].hide({name:i,action:t,detailedPayload:n(c,!1,!0)}),e)}catch(e){throw a.dispatch[o].hide({name:i,action:t,detailedPayload:n(c,e,!1)}),e}};u.isEffect=!0,a.dispatch[i][t]=u}}})))}}},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=loading.umd.production.min.js.map
{
"name": "@rematch/loading",
"version": "2.1.0",
"version": "2.1.1",
"sideEffects": false,

@@ -17,6 +17,6 @@ "description": "Loading indicator plugin for Rematch",

"scripts": {
"start": "tsdx watch",
"build": "tsdx build --format cjs,esm,umd --tsconfig ./tsconfig.build.json",
"test": "tsdx test",
"lint": "tsdx lint",
"start": "dts watch",
"build": "dts build --format cjs,esm,umd --tsconfig ./tsconfig.build.json",
"test": "dts test",
"lint": "dts lint",
"clean": "rimraf dist"

@@ -26,6 +26,7 @@ },

"dist",
"src"
"src",
"README.md"
],
"devDependencies": {
"@rematch/core": "^2.1.0"
"@rematch/core": "^2.1.1"
},

@@ -48,3 +49,3 @@ "peerDependencies": {

},
"gitHead": "0f3d198961271397b86e31b8be94d6e7a9ed95b2"
"gitHead": "1bba6cf12529d18819a03a9ab298412606364fbf"
}

@@ -21,9 +21,8 @@ import {

}
type PickLoadingPluginType<
WhichType extends LoadingPluginType
> = WhichType extends 'number'
? number
: WhichType extends 'full'
? DetailedPayload
: boolean
type PickLoadingPluginType<WhichType extends LoadingPluginType> =
WhichType extends 'number'
? number
: WhichType extends 'full'
? DetailedPayload
: boolean

@@ -93,39 +92,41 @@ interface LoadingState<

const createLoadingAction = <
TModels extends Models<TModels>,
WhichType extends LoadingPluginType
>(
converter: Converter<WhichType>,
i: number,
cntState: InitialState<'number'>
): Reducer<LoadingState<TModels, WhichType>> => (
state,
payload: Action<{
name: string
action: string
detailedPayload: DetailedPayload
}>['payload']
): LoadingState<TModels, WhichType> => {
const { name, action, detailedPayload } = payload || { name: '', action: '' }
const createLoadingAction =
<TModels extends Models<TModels>, WhichType extends LoadingPluginType>(
converter: Converter<WhichType>,
i: number,
cntState: InitialState<'number'>
): Reducer<LoadingState<TModels, WhichType>> =>
(
state,
payload: Action<{
name: string
action: string
detailedPayload: DetailedPayload
}>['payload']
): LoadingState<TModels, WhichType> => {
const { name, action, detailedPayload } = payload || {
name: '',
action: '',
}
cntState.global += i
cntState.models[name] += i
cntState.effects[name][action] += i
cntState.global += i
cntState.models[name] += i
cntState.effects[name][action] += i
return {
...state,
global: converter(cntState.global, detailedPayload),
models: {
...state.models,
[name]: converter(cntState.models[name], detailedPayload),
},
effects: {
...state.effects,
[name]: {
...state.effects[name],
[action]: converter(cntState.effects[name][action], detailedPayload),
return {
...state,
global: converter(cntState.global, detailedPayload),
models: {
...state.models,
[name]: converter(cntState.models[name], detailedPayload),
},
},
effects: {
...state.effects,
[name]: {
...state.effects[name],
[action]: converter(cntState.effects[name][action], detailedPayload),
},
},
}
}
}

@@ -256,5 +257,4 @@ const validateConfig = (config: LoadingConfig): void => {

cntState.effects[name][action] = 0
loadingInitialState.effects[name][
action
] = initialLoadingValue as number
loadingInitialState.effects[name][action] =
initialLoadingValue as number

@@ -261,0 +261,0 @@ const actionType = `${name}/${action}`

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc