@rematch/loading
Advanced tools
Comparing version 1.1.3 to 1.2.0
@@ -1,183 +0,2 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */ | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
} | ||
function __generator(thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
} | ||
var cntState = { | ||
global: 0, | ||
models: {}, | ||
effects: {}, | ||
}; | ||
var createLoadingAction = function (converter, i) { return function (state, _a) { | ||
var name = _a.name, action = _a.action; | ||
var _b, _c, _d; | ||
cntState.global += i; | ||
cntState.models[name] += i; | ||
cntState.effects[name][action] += i; | ||
return __assign({}, state, { global: converter(cntState.global), models: __assign({}, state.models, (_b = {}, _b[name] = converter(cntState.models[name]), _b)), effects: __assign({}, state.effects, (_c = {}, _c[name] = __assign({}, state.effects[name], (_d = {}, _d[action] = converter(cntState.effects[name][action]), _d)), _c)) }); | ||
}; }; | ||
var validateConfig = function (config) { | ||
if (config.name && typeof config.name !== 'string') { | ||
throw new Error('loading plugin config name must be a string'); | ||
} | ||
if (config.asNumber && typeof config.asNumber !== 'boolean') { | ||
throw new Error('loading plugin config asNumber must be a boolean'); | ||
} | ||
if (config.whitelist && !Array.isArray(config.whitelist)) { | ||
throw new Error('loading plugin config whitelist must be an array of strings'); | ||
} | ||
if (config.blacklist && !Array.isArray(config.blacklist)) { | ||
throw new Error('loading plugin config blacklist must be an array of strings'); | ||
} | ||
if (config.whitelist && config.blacklist) { | ||
throw new Error('loading plugin config cannot have both a whitelist & a blacklist'); | ||
} | ||
}; | ||
var index = (function (config) { | ||
if (config === void 0) { config = {}; } | ||
validateConfig(config); | ||
var loadingModelName = config.name || 'loading'; | ||
var converter = config.asNumber === true ? function (cnt) { return cnt; } : function (cnt) { return cnt > 0; }; | ||
var loading = { | ||
name: loadingModelName, | ||
reducers: { | ||
hide: createLoadingAction(converter, -1), | ||
show: createLoadingAction(converter, 1), | ||
}, | ||
state: __assign({}, cntState), | ||
}; | ||
cntState.global = 0; | ||
loading.state.global = converter(cntState.global); | ||
return { | ||
config: { | ||
models: { | ||
loading: loading, | ||
}, | ||
}, | ||
onModel: function (_a) { | ||
var _this = this; | ||
var name = _a.name; | ||
// do not run dispatch on "loading" model | ||
if (name === loadingModelName) { | ||
return; | ||
} | ||
cntState.models[name] = 0; | ||
loading.state.models[name] = converter(cntState.models[name]); | ||
loading.state.effects[name] = {}; | ||
var modelActions = this.dispatch[name]; | ||
// map over effects within models | ||
Object.keys(modelActions).forEach(function (action) { | ||
if (_this.dispatch[name][action].isEffect !== true) { | ||
return; | ||
} | ||
cntState.effects[name][action] = 0; | ||
loading.state.effects[name][action] = converter(cntState.effects[name][action]); | ||
var actionType = name + "/" + action; | ||
// ignore items not in whitelist | ||
if (config.whitelist && !config.whitelist.includes(actionType)) { | ||
return; | ||
} | ||
// ignore items in blacklist | ||
if (config.blacklist && config.blacklist.includes(actionType)) { | ||
return; | ||
} | ||
// copy orig effect pointer | ||
var origEffect = _this.dispatch[name][action]; | ||
// create function with pre & post loading calls | ||
var effectWrapper = function () { | ||
var props = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
props[_i] = arguments[_i]; | ||
} | ||
return __awaiter(_this, void 0, void 0, function () { | ||
var effectResult, error_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
this.dispatch.loading.show({ name: name, action: action }); | ||
return [4 /*yield*/, origEffect.apply(void 0, props)]; | ||
case 1: | ||
effectResult = _a.sent(); | ||
this.dispatch.loading.hide({ name: name, action: action }); | ||
return [2 /*return*/, effectResult]; | ||
case 2: | ||
error_1 = _a.sent(); | ||
this.dispatch.loading.hide({ name: name, action: action }); | ||
throw error_1; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
// replace existing effect with new wrapper | ||
_this.dispatch[name][action] = effectWrapper; | ||
}); | ||
}, | ||
}; | ||
}); | ||
exports.default = index; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(t){for(var e,n=1,a=arguments.length;n<a;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function __awaiter(r,o,s,c){return new(s=s||Promise)(function(t,e){function n(t){try{i(c.next(t))}catch(t){e(t)}}function a(t){try{i(c.throw(t))}catch(t){e(t)}}function i(e){e.done?t(e.value):new s(function(t){t(e.value)}).then(n,a)}i((c=c.apply(r,o||[])).next())})}function __generator(n,a){var i,r,o,t,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,r&&(o=2&e[0]?r.return:e[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,e[1])).done)return o;switch(r=0,o&&(e=[2&e[0],o.value]),e[0]){case 0:case 1:o=e;break;case 4:return s.label++,{value:e[1],done:!1};case 5:s.label++,r=e[1],e=[0];continue;case 7:e=s.ops.pop(),s.trys.pop();continue;default:if(!(o=0<(o=s.trys).length&&o[o.length-1])&&(6===e[0]||2===e[0])){s=0;continue}if(3===e[0]&&(!o||e[1]>o[0]&&e[1]<o[3])){s.label=e[1];break}if(6===e[0]&&s.label<o[1]){s.label=o[1],o=e;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(e);break}o[2]&&s.ops.pop(),s.trys.pop();continue}e=a.call(n,s)}catch(t){e=[6,t],r=0}finally{i=o=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}var cntState={global:0,models:{},effects:{}},createLoadingAction=function(s,c){return function(t,e){var n,a,i,r=e.name,o=e.action;return cntState.global+=c,cntState.models[r]+=c,cntState.effects[r][o]+=c,__assign(__assign({},t),{global:s(cntState.global),models:__assign(__assign({},t.models),(n={},n[r]=s(cntState.models[r]),n)),effects:__assign(__assign({},t.effects),(a={},a[r]=__assign(__assign({},t.effects[r]),(i={},i[o]=s(cntState.effects[r][o]),i)),a))})}},validateConfig=function(t){if(t.name&&"string"!=typeof t.name)throw new Error("loading plugin config name must be a string");if(t.asNumber&&"boolean"!=typeof t.asNumber)throw new Error("loading plugin config asNumber must be a boolean");if(t.whitelist&&!Array.isArray(t.whitelist))throw new Error("loading plugin config whitelist must be an array of strings");if(t.blacklist&&!Array.isArray(t.blacklist))throw new Error("loading plugin config blacklist must be an array of strings");if(t.whitelist&&t.blacklist)throw new Error("loading plugin config cannot have both a whitelist & a blacklist")},index=function(a){void 0===a&&(a={}),validateConfig(a);var i=a.name||"loading",s=!0===a.asNumber?function(t){return t}:function(t){return 0<t},c={name:i,reducers:{hide:createLoadingAction(s,-1),show:createLoadingAction(s,1)},state:__assign({},cntState)};return cntState.global=0,c.state.global=s(cntState.global),{config:{models:{loading:c}},onModel:function(t){var n=this,o=t.name;if(o!==i){cntState.models[o]=0,c.state.models[o]=s(cntState.models[o]),c.state.effects[o]={};var e=this.dispatch[o];Object.keys(e).forEach(function(i){if(!0===n.dispatch[o][i].isEffect){cntState.effects[o][i]=0,c.state.effects[o][i]=s(cntState.effects[o][i]);var t=o+"/"+i;if((!a.whitelist||a.whitelist.includes(t))&&(!a.blacklist||!a.blacklist.includes(t))){var r=n.dispatch[o][i],e=function(){for(var a=[],t=0;t<arguments.length;t++)a[t]=arguments[t];return __awaiter(n,void 0,void 0,function(){var e,n;return __generator(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.dispatch.loading.show({name:o,action:i}),[4,r.apply(void 0,a)];case 1:return e=t.sent(),this.dispatch.loading.hide({name:o,action:i}),[2,e];case 2:throw n=t.sent(),this.dispatch.loading.hide({name:o,action:i}),n;case 3:return[2]}})})};e.isEffect=!0,n.dispatch[o][i]=e}}})}}}};exports.default=index; | ||
//# sourceMappingURL=rematch-loading.cjs.js.map |
@@ -70,8 +70,8 @@ /*! ***************************************************************************** | ||
var createLoadingAction = function (converter, i) { return function (state, _a) { | ||
var _b, _c, _d; | ||
var name = _a.name, action = _a.action; | ||
var _b, _c, _d; | ||
cntState.global += i; | ||
cntState.models[name] += i; | ||
cntState.effects[name][action] += i; | ||
return __assign({}, state, { global: converter(cntState.global), models: __assign({}, state.models, (_b = {}, _b[name] = converter(cntState.models[name]), _b)), effects: __assign({}, state.effects, (_c = {}, _c[name] = __assign({}, state.effects[name], (_d = {}, _d[action] = converter(cntState.effects[name][action]), _d)), _c)) }); | ||
return __assign(__assign({}, state), { global: converter(cntState.global), models: __assign(__assign({}, state.models), (_b = {}, _b[name] = converter(cntState.models[name]), _b)), effects: __assign(__assign({}, state.effects), (_c = {}, _c[name] = __assign(__assign({}, state.effects[name]), (_d = {}, _d[action] = converter(cntState.effects[name][action]), _d)), _c)) }); | ||
}; }; | ||
@@ -172,2 +172,3 @@ var validateConfig = function (config) { | ||
}; | ||
effectWrapper.isEffect = true; | ||
// replace existing effect with new wrapper | ||
@@ -174,0 +175,0 @@ _this.dispatch[name][action] = effectWrapper; |
@@ -1,189 +0,2 @@ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = global || self, factory(global.RematchLoading = {})); | ||
}(this, function (exports) { 'use strict'; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */ | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
} | ||
function __generator(thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
} | ||
var cntState = { | ||
global: 0, | ||
models: {}, | ||
effects: {}, | ||
}; | ||
var createLoadingAction = function (converter, i) { return function (state, _a) { | ||
var name = _a.name, action = _a.action; | ||
var _b, _c, _d; | ||
cntState.global += i; | ||
cntState.models[name] += i; | ||
cntState.effects[name][action] += i; | ||
return __assign({}, state, { global: converter(cntState.global), models: __assign({}, state.models, (_b = {}, _b[name] = converter(cntState.models[name]), _b)), effects: __assign({}, state.effects, (_c = {}, _c[name] = __assign({}, state.effects[name], (_d = {}, _d[action] = converter(cntState.effects[name][action]), _d)), _c)) }); | ||
}; }; | ||
var validateConfig = function (config) { | ||
if (config.name && typeof config.name !== 'string') { | ||
throw new Error('loading plugin config name must be a string'); | ||
} | ||
if (config.asNumber && typeof config.asNumber !== 'boolean') { | ||
throw new Error('loading plugin config asNumber must be a boolean'); | ||
} | ||
if (config.whitelist && !Array.isArray(config.whitelist)) { | ||
throw new Error('loading plugin config whitelist must be an array of strings'); | ||
} | ||
if (config.blacklist && !Array.isArray(config.blacklist)) { | ||
throw new Error('loading plugin config blacklist must be an array of strings'); | ||
} | ||
if (config.whitelist && config.blacklist) { | ||
throw new Error('loading plugin config cannot have both a whitelist & a blacklist'); | ||
} | ||
}; | ||
var index = (function (config) { | ||
if (config === void 0) { config = {}; } | ||
validateConfig(config); | ||
var loadingModelName = config.name || 'loading'; | ||
var converter = config.asNumber === true ? function (cnt) { return cnt; } : function (cnt) { return cnt > 0; }; | ||
var loading = { | ||
name: loadingModelName, | ||
reducers: { | ||
hide: createLoadingAction(converter, -1), | ||
show: createLoadingAction(converter, 1), | ||
}, | ||
state: __assign({}, cntState), | ||
}; | ||
cntState.global = 0; | ||
loading.state.global = converter(cntState.global); | ||
return { | ||
config: { | ||
models: { | ||
loading: loading, | ||
}, | ||
}, | ||
onModel: function (_a) { | ||
var _this = this; | ||
var name = _a.name; | ||
// do not run dispatch on "loading" model | ||
if (name === loadingModelName) { | ||
return; | ||
} | ||
cntState.models[name] = 0; | ||
loading.state.models[name] = converter(cntState.models[name]); | ||
loading.state.effects[name] = {}; | ||
var modelActions = this.dispatch[name]; | ||
// map over effects within models | ||
Object.keys(modelActions).forEach(function (action) { | ||
if (_this.dispatch[name][action].isEffect !== true) { | ||
return; | ||
} | ||
cntState.effects[name][action] = 0; | ||
loading.state.effects[name][action] = converter(cntState.effects[name][action]); | ||
var actionType = name + "/" + action; | ||
// ignore items not in whitelist | ||
if (config.whitelist && !config.whitelist.includes(actionType)) { | ||
return; | ||
} | ||
// ignore items in blacklist | ||
if (config.blacklist && config.blacklist.includes(actionType)) { | ||
return; | ||
} | ||
// copy orig effect pointer | ||
var origEffect = _this.dispatch[name][action]; | ||
// create function with pre & post loading calls | ||
var effectWrapper = function () { | ||
var props = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
props[_i] = arguments[_i]; | ||
} | ||
return __awaiter(_this, void 0, void 0, function () { | ||
var effectResult, error_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
this.dispatch.loading.show({ name: name, action: action }); | ||
return [4 /*yield*/, origEffect.apply(void 0, props)]; | ||
case 1: | ||
effectResult = _a.sent(); | ||
this.dispatch.loading.hide({ name: name, action: action }); | ||
return [2 /*return*/, effectResult]; | ||
case 2: | ||
error_1 = _a.sent(); | ||
this.dispatch.loading.hide({ name: name, action: action }); | ||
throw error_1; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
// replace existing effect with new wrapper | ||
_this.dispatch[name][action] = effectWrapper; | ||
}); | ||
}, | ||
}; | ||
}); | ||
exports.default = index; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
})); | ||
!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";var e,t;e=window,t=function(e){var c=function(){return(c=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function f(n,i){var o,r,a,e,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,r&&(a=2&t[0]?r.return:t[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,t[1])).done)return a;switch(r=0,a&&(t=[2&t[0],a.value]),t[0]){case 0:case 1:a=t;break;case 4:return s.label++,{value:t[1],done:!1};case 5:s.label++,r=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3])){s.label=t[1];break}if(6===t[0]&&s.label<a[1]){s.label=a[1],a=t;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(t);break}a[2]&&s.ops.pop(),s.trys.pop();continue}t=i.call(n,s)}catch(e){t=[6,e],r=0}finally{o=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}}function t(s,l){return function(e,t){var n,i,o,r=t.name,a=t.action;return u.global+=l,u.models[r]+=l,u.effects[r][a]+=l,c(c({},e),{global:s(u.global),models:c(c({},e.models),(n={},n[r]=s(u.models[r]),n)),effects:c(c({},e.effects),(i={},i[r]=c(c({},e.effects[r]),(o={},o[a]=s(u.effects[r][a]),o)),i))})}}var u={global:0,models:{},effects:{}};e.default=function(i){void 0===i&&(i={}),function(e){if(e.name&&"string"!=typeof e.name)throw new Error("loading plugin config name must be a string");if(e.asNumber&&"boolean"!=typeof e.asNumber)throw new Error("loading plugin config asNumber must be a boolean");if(e.whitelist&&!Array.isArray(e.whitelist))throw new Error("loading plugin config whitelist must be an array of strings");if(e.blacklist&&!Array.isArray(e.blacklist))throw new Error("loading plugin config blacklist must be an array of strings");if(e.whitelist&&e.blacklist)throw new Error("loading plugin config cannot have both a whitelist & a blacklist")}(i);var o=i.name||"loading",s=!0===i.asNumber?function(e){return e}:function(e){return 0<e},l={name:o,reducers:{hide:t(s,-1),show:t(s,1)},state:c({},u)};return u.global=0,l.state.global=s(u.global),{config:{models:{loading:l}},onModel:function(e){var n=this,a=e.name;if(a!==o){u.models[a]=0,l.state.models[a]=s(u.models[a]),l.state.effects[a]={};var t=this.dispatch[a];Object.keys(t).forEach(function(o){if(!0===n.dispatch[a][o].isEffect){u.effects[a][o]=0,l.state.effects[a][o]=s(u.effects[a][o]);var e=a+"/"+o;if((!i.whitelist||i.whitelist.includes(e))&&(!i.blacklist||!i.blacklist.includes(e))){var r=n.dispatch[a][o],t=function(){for(var i=[],e=0;e<arguments.length;e++)i[e]=arguments[e];return function(r,a,s,l){return new(s=s||Promise)(function(e,t){function n(e){try{o(l.next(e))}catch(e){t(e)}}function i(e){try{o(l.throw(e))}catch(e){t(e)}}function o(t){t.done?e(t.value):new s(function(e){e(t.value)}).then(n,i)}o((l=l.apply(r,a||[])).next())})}(n,void 0,void 0,function(){var t,n;return f(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),this.dispatch.loading.show({name:a,action:o}),[4,r.apply(void 0,i)];case 1:return t=e.sent(),this.dispatch.loading.hide({name:a,action:o}),[2,t];case 2:throw n=e.sent(),this.dispatch.loading.hide({name:a,action:o}),n;case 3:return[2]}})})};t.isEffect=!0,n.dispatch[a][o]=t}}})}}}},Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).RematchLoading={})}); | ||
//# sourceMappingURL=rematch-loading.umd.js.map |
{ | ||
"name": "@rematch/loading", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "Loading indicator plugin for Rematch", | ||
@@ -25,3 +25,2 @@ "keywords": [ | ||
"browser": "dist/rematch-loading.umd.js", | ||
"types": "src/typings.d.ts", | ||
"scripts": { | ||
@@ -31,3 +30,4 @@ "clean:dist": "npx rimraf dist", | ||
"clean": "npm run clean:dist & npm run clean:build", | ||
"build": "NODE_ENV=production npm run clean && rollup -c" | ||
"type": "tsc --emitDeclarationOnly", | ||
"build": "npm run clean && NODE_ENV=production rollup -c && npm run type" | ||
}, | ||
@@ -40,9 +40,9 @@ "devDependencies": { | ||
"rimraf": "^2.6.3", | ||
"rollup": "^1.0.2", | ||
"rollup-plugin-commonjs": "^9.2.0", | ||
"rollup-plugin-replace": "^2.1.0", | ||
"rollup-plugin-typescript": "^1.0.0", | ||
"rollup-plugin-uglify": "^6.0.0", | ||
"typescript": "^3.2.2", | ||
"uglify-es": "^3.3.9" | ||
"rollup": "^1.21.4", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-replace": "^2.2.0", | ||
"rollup-plugin-typescript": "^1.0.1", | ||
"rollup-plugin-uglify": "^6.0.3", | ||
"typescript": "^3.2.2" | ||
}, | ||
@@ -49,0 +49,0 @@ "peerDependencies": { |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57164
7
207
1
0
1