Comparing version 0.1.1 to 0.1.2
@@ -89,2 +89,5 @@ 'use strict'; | ||
} | ||
function createState(state) { | ||
return state; | ||
} | ||
@@ -329,2 +332,3 @@ var defaultMapState = function defaultMapState(state) { | ||
exports.StoreProvider = StoreProvider; | ||
exports.createState = createState; | ||
exports.createStore = createStore; | ||
@@ -331,0 +335,0 @@ exports.useAction = useAction; |
@@ -1,2 +0,2 @@ | ||
"use strict";var t=require("react");function e(){return(e=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}var r=t.createContext(void 0);function n(){var e=t.useContext(r);if(!e)throw new Error("Not inside provider");return e}var o=function(t){return t};function u(t,e){return!function t(e,r){if(typeof e!=typeof r)return!1;if(Array.isArray(e)&&Array.isArray(r))return e.length===r.length&&e.every(function(e,n){return t(e,r[n])});if("object"==typeof e&&"object"==typeof r){var n=Object.keys(e);return t(n,Object.keys(r))&&n.every(function(n){return t(e[n],r[n])})}return e===r}(t,e)}function i(t,e,r){var n=t.subscriptions.get(e);return n||(n=new Set,t.subscriptions.set(e,n)),n.add(r),function(){n.delete(r)}}function a(t,e){if(!t.states.has(e)){var r=e.initialState;return t.states.set(e,r),r}return t.states.get(e)}function c(t,e){return Object.keys(e).reduce(function(r,n){return r[n]=a(t,e[n]._storeData),r},{})}function s(){var e=n();return t.useMemo(function(){return function t(e,r){return function(n){var o,u=!r,i=r?r.changesSet:new Set,c=r?r.changesMap:new WeakMap,s=r?r.commit:function(){var t=new Set;i.forEach(function(r){e.states.set(r,c.get(r));var n=e.subscriptions.get(r);n&&n.forEach(function(e){return t.add(e)})}),t.forEach(function(t){try{t()}catch(t){console.error("Error when calling subscription",t)}}),i.clear(),c=new WeakMap},f=function(){return c.get(n.store)||a(e,n.store)},v=n({state:f(),getState:f,setState:function(t,e){void 0===e&&(e=!1);var r=function(t){return"function"==typeof t}(t)?t(f()):t;i.add(n.store),c.set(n.store,r),e&&s()},commit:s,disableAutoCommit:function(){u=!1},getStore:function(t){return c.get(t._storeData)||a(e,t._storeData)},dispatch:t(e,{changesMap:c,commit:s,changesSet:i})});return u&&(v&&"then"in(o=v)&&"function"==typeof o.then?v.then(function(){return s()}):s()),v}}(e)},[e])}exports.StoreProvider=function(e){var n=e.initialStates,o=function(t,e){if(null==t)return{};var r,n,o={},u=Object.keys(t);for(n=0;n<u.length;n++)e.indexOf(r=u[n])>=0||(o[r]=t[r]);return o}(e,["initialStates"]),u={states:n||new WeakMap,subscriptions:new WeakMap};return t.createElement(r.Provider,Object.assign({},o,{value:u}))},exports.createStore=function(t){var r=t.actions,n={initialState:t.initialState};return e({},Object.keys(r).reduce(function(t,e){return t[e]=function(){for(var t=arguments.length,o=new Array(t),u=0;u<t;u++)o[u]=arguments[u];var i=function(t){return r[e].apply(r,[t].concat(o))};return i.store=n,i},t},{}),{_storeData:n})},exports.useAction=function(e){var r=s();return t.useMemo(function(){return"store"in e?function(){return r(e)}:function(){return r(e.apply(void 0,arguments))}},[r])},exports.useDispatcher=s,exports.useStore=function(e,r,c){void 0===r&&(r=o),void 0===c&&(c=u);var s=n(),f=t.useState(function(){return r(a(s,e._storeData))}),v=f[0],p=f[1];return t.useEffect(function(){return i(s,e._storeData,function(){var t=a(s,e._storeData),n=r(t);(r===o&&c===u?v!==n:c(v,n))&&p(n)})},[s,v]),v},exports.useStores=function(e,r,a){void 0===r&&(r=o),void 0===a&&(a=u);var s=n(),f=t.useState(function(){return r(c(s,e))}),v=f[0],p=f[1];return t.useEffect(function(){var t=function(){var t=c(s,e),n=r(t);a(v,n)&&p(n)},n=Object.values(e).map(function(e){return i(s,e._storeData,t)});return function(){n.map(function(t){return t()})}},[s,v]),v}; | ||
"use strict";var t=require("react");function e(){return(e=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}var r=t.createContext(void 0);function n(){var e=t.useContext(r);if(!e)throw new Error("Not inside provider");return e}var o=function(t){return t};function u(t,e){return!function t(e,r){if(typeof e!=typeof r)return!1;if(Array.isArray(e)&&Array.isArray(r))return e.length===r.length&&e.every(function(e,n){return t(e,r[n])});if("object"==typeof e&&"object"==typeof r){var n=Object.keys(e);return t(n,Object.keys(r))&&n.every(function(n){return t(e[n],r[n])})}return e===r}(t,e)}function i(t,e,r){var n=t.subscriptions.get(e);return n||(n=new Set,t.subscriptions.set(e,n)),n.add(r),function(){n.delete(r)}}function a(t,e){if(!t.states.has(e)){var r=e.initialState;return t.states.set(e,r),r}return t.states.get(e)}function c(t,e){return Object.keys(e).reduce(function(r,n){return r[n]=a(t,e[n]._storeData),r},{})}function s(){var e=n();return t.useMemo(function(){return function t(e,r){return function(n){var o,u=!r,i=r?r.changesSet:new Set,c=r?r.changesMap:new WeakMap,s=r?r.commit:function(){var t=new Set;i.forEach(function(r){e.states.set(r,c.get(r));var n=e.subscriptions.get(r);n&&n.forEach(function(e){return t.add(e)})}),t.forEach(function(t){try{t()}catch(t){console.error("Error when calling subscription",t)}}),i.clear(),c=new WeakMap},f=function(){return c.get(n.store)||a(e,n.store)},v=n({state:f(),getState:f,setState:function(t,e){void 0===e&&(e=!1);var r=function(t){return"function"==typeof t}(t)?t(f()):t;i.add(n.store),c.set(n.store,r),e&&s()},commit:s,disableAutoCommit:function(){u=!1},getStore:function(t){return c.get(t._storeData)||a(e,t._storeData)},dispatch:t(e,{changesMap:c,commit:s,changesSet:i})});return u&&(v&&"then"in(o=v)&&"function"==typeof o.then?v.then(function(){return s()}):s()),v}}(e)},[e])}exports.StoreProvider=function(e){var n=e.initialStates,o=function(t,e){if(null==t)return{};var r,n,o={},u=Object.keys(t);for(n=0;n<u.length;n++)e.indexOf(r=u[n])>=0||(o[r]=t[r]);return o}(e,["initialStates"]),u={states:n||new WeakMap,subscriptions:new WeakMap};return t.createElement(r.Provider,Object.assign({},o,{value:u}))},exports.createState=function(t){return t},exports.createStore=function(t){var r=t.actions,n={initialState:t.initialState};return e({},Object.keys(r).reduce(function(t,e){return t[e]=function(){for(var t=arguments.length,o=new Array(t),u=0;u<t;u++)o[u]=arguments[u];var i=function(t){return r[e].apply(r,[t].concat(o))};return i.store=n,i},t},{}),{_storeData:n})},exports.useAction=function(e){var r=s();return t.useMemo(function(){return"store"in e?function(){return r(e)}:function(){return r(e.apply(void 0,arguments))}},[r])},exports.useDispatcher=s,exports.useStore=function(e,r,c){void 0===r&&(r=o),void 0===c&&(c=u);var s=n(),f=t.useState(function(){return r(a(s,e._storeData))}),v=f[0],p=f[1];return t.useEffect(function(){return i(s,e._storeData,function(){var t=a(s,e._storeData),n=r(t);(r===o&&c===u?v!==n:c(v,n))&&p(n)})},[s,v]),v},exports.useStores=function(e,r,a){void 0===r&&(r=o),void 0===a&&(a=u);var s=n(),f=t.useState(function(){return r(c(s,e))}),v=f[0],p=f[1];return t.useEffect(function(){var t=function(){var t=c(s,e),n=r(t);a(v,n)&&p(n)},n=Object.values(e).map(function(e){return i(s,e._storeData,t)});return function(){n.map(function(t){return t()})}},[s,v]),v}; | ||
//# sourceMappingURL=el-state.cjs.production.min.js.map |
@@ -87,2 +87,5 @@ import { createElement, createContext, useContext, useState, useEffect, useMemo } from 'react'; | ||
} | ||
function createState(state) { | ||
return state; | ||
} | ||
@@ -326,3 +329,3 @@ var defaultMapState = function defaultMapState(state) { | ||
export { StoreProvider, createStore, useAction, useDispatcher, useStore, useStores }; | ||
export { StoreProvider, createState, createStore, useAction, useDispatcher, useStore, useStores }; | ||
//# sourceMappingURL=el-state.esm.js.map |
export { StoreProvider } from './provider'; | ||
export { createStore } from './createStore'; | ||
export { createStore, createState } from './createStore'; | ||
export { useStore } from './useStore'; | ||
export { useStores } from './useStores'; | ||
export { useDispatcher, useAction } from './dispatcher'; |
{ | ||
"name": "el-state", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"license": "MIT", | ||
"homepage": "https://github.com/abihf/el-state#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/abihf/el-state.git" | ||
}, | ||
"main": "dist/index.js", | ||
@@ -5,0 +11,0 @@ "module": "dist/el-state.esm.js", |
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
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 License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
76623
0
669
2
1
0