react-hooks-global-states 16.0.0 → 16.0.1-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GlobalStore.cjs +1 -525
- package/GlobalStore.debugProps.cjs +1 -28
- package/GlobalStore.debugProps.js +1 -28
- package/GlobalStore.debugProps.mjs +1 -7
- package/GlobalStore.js +1 -525
- package/GlobalStore.mjs +1 -497
- package/actions.cjs +1 -61
- package/actions.d.ts +3 -3
- package/actions.js +1 -61
- package/actions.mjs +1 -30
- package/bundle.cjs +1 -40
- package/bundle.js +1 -40
- package/bundle.mjs +1 -19
- package/createContext.cjs +1 -253
- package/createContext.js +1 -253
- package/createContext.mjs +1 -235
- package/createGlobalState.cjs +1 -29
- package/createGlobalState.js +1 -29
- package/createGlobalState.mjs +1 -8
- package/isRecord.cjs +1 -46
- package/isRecord.js +1 -46
- package/isRecord.mjs +1 -15
- package/package.json +1 -1
- package/shallowCompare.cjs +1 -115
- package/shallowCompare.js +1 -115
- package/shallowCompare.mjs +1 -84
- package/throwWrongKeyOnActionCollectionConfig.cjs +4 -33
- package/throwWrongKeyOnActionCollectionConfig.js +4 -33
- package/throwWrongKeyOnActionCollectionConfig.mjs +4 -12
- package/types.cjs +1 -18
- package/types.d.ts +21 -3
- package/types.js +1 -18
- package/uniqueId.cjs +1 -72
- package/uniqueId.js +1 -72
- package/uniqueId.mjs +1 -51
package/shallowCompare.js
CHANGED
|
@@ -1,115 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/shallowCompare.ts
|
|
31
|
-
var shallowCompare_exports = {};
|
|
32
|
-
__export(shallowCompare_exports, {
|
|
33
|
-
canCheckSimpleEquality: () => canCheckSimpleEquality,
|
|
34
|
-
default: () => shallowCompare_default,
|
|
35
|
-
isArray: () => isArray,
|
|
36
|
-
isEqualArray: () => isEqualArray,
|
|
37
|
-
isEqualMap: () => isEqualMap,
|
|
38
|
-
isEqualObject: () => isEqualObject,
|
|
39
|
-
isEqualSet: () => isEqualSet,
|
|
40
|
-
isMap: () => isMap,
|
|
41
|
-
isSet: () => isSet,
|
|
42
|
-
shallowCompare: () => shallowCompare
|
|
43
|
-
});
|
|
44
|
-
module.exports = __toCommonJS(shallowCompare_exports);
|
|
45
|
-
var import_isPrimitive = __toESM(require("json-storage-formatter/isPrimitive"));
|
|
46
|
-
var import_isDate = __toESM(require("json-storage-formatter/isDate"));
|
|
47
|
-
var import_isNil = __toESM(require("json-storage-formatter/isNil"));
|
|
48
|
-
var import_isRecord = __toESM(require("./isRecord.js"));
|
|
49
|
-
var shallowCompare = (value1, value2) => {
|
|
50
|
-
const isEqual = value1 === value2;
|
|
51
|
-
if (isEqual) return true;
|
|
52
|
-
if (canCheckSimpleEquality(value1, value2)) {
|
|
53
|
-
return value1 === value2;
|
|
54
|
-
}
|
|
55
|
-
if (isArray(value1) && isArray(value2)) {
|
|
56
|
-
return isEqualArray(value1, value2);
|
|
57
|
-
}
|
|
58
|
-
if (isMap(value1) && isMap(value2)) {
|
|
59
|
-
return isEqualMap(value1, value2);
|
|
60
|
-
}
|
|
61
|
-
if (isSet(value1) && isSet(value2)) {
|
|
62
|
-
return isEqualSet(value1, value2);
|
|
63
|
-
}
|
|
64
|
-
if (!(0, import_isRecord.default)(value1) || !(0, import_isRecord.default)(value2)) return value1 === value2;
|
|
65
|
-
return isEqualObject(value1, value2);
|
|
66
|
-
};
|
|
67
|
-
var isArray = (value) => Array.isArray(value);
|
|
68
|
-
var isMap = (value) => {
|
|
69
|
-
return value instanceof Map;
|
|
70
|
-
};
|
|
71
|
-
var isSet = (value) => {
|
|
72
|
-
return value instanceof Set;
|
|
73
|
-
};
|
|
74
|
-
var canCheckSimpleEquality = (value1, value2) => {
|
|
75
|
-
const typeofValue1 = typeof value1;
|
|
76
|
-
const typeofValue2 = typeof value2;
|
|
77
|
-
if (typeofValue1 !== typeofValue2) return true;
|
|
78
|
-
return (0, import_isNil.default)(value1) || (0, import_isNil.default)(value2) || (0, import_isPrimitive.default)(value1) && (0, import_isPrimitive.default)(value2) || (0, import_isDate.default)(value1) && (0, import_isDate.default)(value2) || typeofValue1 === "function" && typeofValue2 === "function";
|
|
79
|
-
};
|
|
80
|
-
var isEqualArray = (array1, array2) => {
|
|
81
|
-
if (array1.length !== array2.length) return false;
|
|
82
|
-
for (let i = 0; i < array1.length; i += 1) {
|
|
83
|
-
const $value1 = array1[i];
|
|
84
|
-
const $value2 = array2[i];
|
|
85
|
-
if ($value1 !== $value2) return false;
|
|
86
|
-
}
|
|
87
|
-
return true;
|
|
88
|
-
};
|
|
89
|
-
var isEqualMap = (map1, map2) => {
|
|
90
|
-
if (map1.size !== map2.size) return false;
|
|
91
|
-
for (const [key, value] of map1) {
|
|
92
|
-
const $value2 = map2.get(key);
|
|
93
|
-
if (value !== $value2) return false;
|
|
94
|
-
}
|
|
95
|
-
return true;
|
|
96
|
-
};
|
|
97
|
-
var isEqualSet = (set1, set2) => {
|
|
98
|
-
if (set1.size !== set2.size) return false;
|
|
99
|
-
for (const value of set1) {
|
|
100
|
-
if (!set2.has(value)) return false;
|
|
101
|
-
}
|
|
102
|
-
return true;
|
|
103
|
-
};
|
|
104
|
-
var isEqualObject = (value1, value2) => {
|
|
105
|
-
const keys1 = Object.keys(value1);
|
|
106
|
-
const keys2 = Object.keys(value2);
|
|
107
|
-
if (keys1.length !== keys2.length) return false;
|
|
108
|
-
for (const key of keys1) {
|
|
109
|
-
const propObject1 = value1[key];
|
|
110
|
-
const propObject2 = value2[key];
|
|
111
|
-
if (propObject1 !== propObject2) return false;
|
|
112
|
-
}
|
|
113
|
-
return true;
|
|
114
|
-
};
|
|
115
|
-
var shallowCompare_default = shallowCompare;
|
|
1
|
+
"use strict";var q=Object.create;var s=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var V=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var O=(t,n)=>{for(var r in n)s(t,r,{get:n[r],enumerable:!0})},a=(t,n,r,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of M(n))!j.call(t,o)&&o!==r&&s(t,o,{get:()=>n[o],enumerable:!(e=E(n,o))||e.enumerable});return t};var i=(t,n,r)=>(r=t!=null?q(V(t)):{},a(n||!t||!t.__esModule?s(r,"default",{value:t,enumerable:!0}):r,t)),d=t=>a(s({},"__esModule",{value:!0}),t);var A={};O(A,{canCheckSimpleEquality:()=>x,default:()=>z,isArray:()=>k,isEqualArray:()=>m,isEqualMap:()=>h,isEqualObject:()=>S,isEqualSet:()=>l,isMap:()=>T,isSet:()=>y,shallowCompare:()=>w});module.exports=d(A);var f=i(require("json-storage-formatter/isPrimitive")),c=i(require("json-storage-formatter/isDate")),p=i(require("json-storage-formatter/isNil")),u=i(require("./isRecord.js")),w=(t,n)=>t===n?!0:x(t,n)?t===n:k(t)&&k(n)?m(t,n):T(t)&&T(n)?h(t,n):y(t)&&y(n)?l(t,n):!(0,u.default)(t)||!(0,u.default)(n)?t===n:S(t,n),k=t=>Array.isArray(t),T=t=>t instanceof Map,y=t=>t instanceof Set,x=(t,n)=>{let r=typeof t,e=typeof n;return r!==e?!0:(0,p.default)(t)||(0,p.default)(n)||(0,f.default)(t)&&(0,f.default)(n)||(0,c.default)(t)&&(0,c.default)(n)||r==="function"&&e==="function"},m=(t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r+=1){let e=t[r],o=n[r];if(e!==o)return!1}return!0},h=(t,n)=>{if(t.size!==n.size)return!1;for(let[r,e]of t){let o=n.get(r);if(e!==o)return!1}return!0},l=(t,n)=>{if(t.size!==n.size)return!1;for(let r of t)if(!n.has(r))return!1;return!0},S=(t,n)=>{let r=Object.keys(t),e=Object.keys(n);if(r.length!==e.length)return!1;for(let o of r){let b=t[o],g=n[o];if(b!==g)return!1}return!0},z=w;
|
package/shallowCompare.mjs
CHANGED
|
@@ -1,84 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import isPrimitive from "json-storage-formatter/isPrimitive";
|
|
3
|
-
import isDate from "json-storage-formatter/isDate";
|
|
4
|
-
import isNil from "json-storage-formatter/isNil";
|
|
5
|
-
import isRecord from "./isRecord.mjs";
|
|
6
|
-
var shallowCompare = (value1, value2) => {
|
|
7
|
-
const isEqual = value1 === value2;
|
|
8
|
-
if (isEqual) return true;
|
|
9
|
-
if (canCheckSimpleEquality(value1, value2)) {
|
|
10
|
-
return value1 === value2;
|
|
11
|
-
}
|
|
12
|
-
if (isArray(value1) && isArray(value2)) {
|
|
13
|
-
return isEqualArray(value1, value2);
|
|
14
|
-
}
|
|
15
|
-
if (isMap(value1) && isMap(value2)) {
|
|
16
|
-
return isEqualMap(value1, value2);
|
|
17
|
-
}
|
|
18
|
-
if (isSet(value1) && isSet(value2)) {
|
|
19
|
-
return isEqualSet(value1, value2);
|
|
20
|
-
}
|
|
21
|
-
if (!isRecord(value1) || !isRecord(value2)) return value1 === value2;
|
|
22
|
-
return isEqualObject(value1, value2);
|
|
23
|
-
};
|
|
24
|
-
var isArray = (value) => Array.isArray(value);
|
|
25
|
-
var isMap = (value) => {
|
|
26
|
-
return value instanceof Map;
|
|
27
|
-
};
|
|
28
|
-
var isSet = (value) => {
|
|
29
|
-
return value instanceof Set;
|
|
30
|
-
};
|
|
31
|
-
var canCheckSimpleEquality = (value1, value2) => {
|
|
32
|
-
const typeofValue1 = typeof value1;
|
|
33
|
-
const typeofValue2 = typeof value2;
|
|
34
|
-
if (typeofValue1 !== typeofValue2) return true;
|
|
35
|
-
return isNil(value1) || isNil(value2) || isPrimitive(value1) && isPrimitive(value2) || isDate(value1) && isDate(value2) || typeofValue1 === "function" && typeofValue2 === "function";
|
|
36
|
-
};
|
|
37
|
-
var isEqualArray = (array1, array2) => {
|
|
38
|
-
if (array1.length !== array2.length) return false;
|
|
39
|
-
for (let i = 0; i < array1.length; i += 1) {
|
|
40
|
-
const $value1 = array1[i];
|
|
41
|
-
const $value2 = array2[i];
|
|
42
|
-
if ($value1 !== $value2) return false;
|
|
43
|
-
}
|
|
44
|
-
return true;
|
|
45
|
-
};
|
|
46
|
-
var isEqualMap = (map1, map2) => {
|
|
47
|
-
if (map1.size !== map2.size) return false;
|
|
48
|
-
for (const [key, value] of map1) {
|
|
49
|
-
const $value2 = map2.get(key);
|
|
50
|
-
if (value !== $value2) return false;
|
|
51
|
-
}
|
|
52
|
-
return true;
|
|
53
|
-
};
|
|
54
|
-
var isEqualSet = (set1, set2) => {
|
|
55
|
-
if (set1.size !== set2.size) return false;
|
|
56
|
-
for (const value of set1) {
|
|
57
|
-
if (!set2.has(value)) return false;
|
|
58
|
-
}
|
|
59
|
-
return true;
|
|
60
|
-
};
|
|
61
|
-
var isEqualObject = (value1, value2) => {
|
|
62
|
-
const keys1 = Object.keys(value1);
|
|
63
|
-
const keys2 = Object.keys(value2);
|
|
64
|
-
if (keys1.length !== keys2.length) return false;
|
|
65
|
-
for (const key of keys1) {
|
|
66
|
-
const propObject1 = value1[key];
|
|
67
|
-
const propObject2 = value2[key];
|
|
68
|
-
if (propObject1 !== propObject2) return false;
|
|
69
|
-
}
|
|
70
|
-
return true;
|
|
71
|
-
};
|
|
72
|
-
var shallowCompare_default = shallowCompare;
|
|
73
|
-
export {
|
|
74
|
-
canCheckSimpleEquality,
|
|
75
|
-
shallowCompare_default as default,
|
|
76
|
-
isArray,
|
|
77
|
-
isEqualArray,
|
|
78
|
-
isEqualMap,
|
|
79
|
-
isEqualObject,
|
|
80
|
-
isEqualSet,
|
|
81
|
-
isMap,
|
|
82
|
-
isSet,
|
|
83
|
-
shallowCompare
|
|
84
|
-
};
|
|
1
|
+
import s from"json-storage-formatter/isPrimitive";import i from"json-storage-formatter/isDate";import f from"json-storage-formatter/isNil";import c from"./isRecord.mjs";var a=(t,n)=>t===n?!0:w(t,n)?t===n:p(t)&&p(n)?x(t,n):u(t)&&u(n)?m(t,n):k(t)&&k(n)?h(t,n):!c(t)||!c(n)?t===n:l(t,n),p=t=>Array.isArray(t),u=t=>t instanceof Map,k=t=>t instanceof Set,w=(t,n)=>{let r=typeof t,o=typeof n;return r!==o?!0:f(t)||f(n)||s(t)&&s(n)||i(t)&&i(n)||r==="function"&&o==="function"},x=(t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r+=1){let o=t[r],e=n[r];if(o!==e)return!1}return!0},m=(t,n)=>{if(t.size!==n.size)return!1;for(let[r,o]of t){let e=n.get(r);if(o!==e)return!1}return!0},h=(t,n)=>{if(t.size!==n.size)return!1;for(let r of t)if(!n.has(r))return!1;return!0},l=(t,n)=>{let r=Object.keys(t),o=Object.keys(n);if(r.length!==o.length)return!1;for(let e of r){let T=t[e],y=n[e];if(T!==y)return!1}return!0},E=a;export{w as canCheckSimpleEquality,E as default,p as isArray,x as isEqualArray,m as isEqualMap,l as isEqualObject,h as isEqualSet,u as isMap,k as isSet,a as shallowCompare};
|
|
@@ -1,41 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/throwWrongKeyOnActionCollectionConfig.ts
|
|
21
|
-
var throwWrongKeyOnActionCollectionConfig_exports = {};
|
|
22
|
-
__export(throwWrongKeyOnActionCollectionConfig_exports, {
|
|
23
|
-
default: () => throwWrongKeyOnActionCollectionConfig_default,
|
|
24
|
-
throwWrongKeyOnActionCollectionConfig: () => throwWrongKeyOnActionCollectionConfig
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(throwWrongKeyOnActionCollectionConfig_exports);
|
|
27
|
-
var throwWrongKeyOnActionCollectionConfig = (action_key) => {
|
|
28
|
-
throw new Error(`[WRONG CONFIGURATION!]: Every key inside the storeActionsConfig must be a higher order function that returns a function
|
|
29
|
-
[${action_key}]: key is not a valid function, try something like this:
|
|
1
|
+
"use strict";var o=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var c=(t,e)=>{for(var a in e)o(t,a,{get:e[a],enumerable:!0})},d=(t,e,a,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of g(e))!h.call(t,n)&&n!==a&&o(t,n,{get:()=>e[n],enumerable:!(r=s(e,n))||r.enumerable});return t};var f=t=>d(o({},"__esModule",{value:!0}),t);var l={};c(l,{default:()=>u,throwWrongKeyOnActionCollectionConfig:()=>i});module.exports=f(l);var i=t=>{throw new Error(`[WRONG CONFIGURATION!]: Every key inside the storeActionsConfig must be a higher order function that returns a function
|
|
2
|
+
[${t}]: key is not a valid function, try something like this:
|
|
30
3
|
{
|
|
31
4
|
|
|
32
|
-
${
|
|
5
|
+
${t}: (param) => ({ setState, getState, setMetadata, getMetadata, actions }) => {
|
|
33
6
|
|
|
34
7
|
setState((state) => ({ ...state, ...param }))
|
|
35
8
|
|
|
36
9
|
}
|
|
37
10
|
|
|
38
11
|
}
|
|
39
|
-
`);
|
|
40
|
-
};
|
|
41
|
-
var throwWrongKeyOnActionCollectionConfig_default = throwWrongKeyOnActionCollectionConfig;
|
|
12
|
+
`)},u=i;
|
|
@@ -1,41 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/throwWrongKeyOnActionCollectionConfig.ts
|
|
21
|
-
var throwWrongKeyOnActionCollectionConfig_exports = {};
|
|
22
|
-
__export(throwWrongKeyOnActionCollectionConfig_exports, {
|
|
23
|
-
default: () => throwWrongKeyOnActionCollectionConfig_default,
|
|
24
|
-
throwWrongKeyOnActionCollectionConfig: () => throwWrongKeyOnActionCollectionConfig
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(throwWrongKeyOnActionCollectionConfig_exports);
|
|
27
|
-
var throwWrongKeyOnActionCollectionConfig = (action_key) => {
|
|
28
|
-
throw new Error(`[WRONG CONFIGURATION!]: Every key inside the storeActionsConfig must be a higher order function that returns a function
|
|
29
|
-
[${action_key}]: key is not a valid function, try something like this:
|
|
1
|
+
"use strict";var o=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var c=(t,e)=>{for(var a in e)o(t,a,{get:e[a],enumerable:!0})},d=(t,e,a,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of g(e))!h.call(t,n)&&n!==a&&o(t,n,{get:()=>e[n],enumerable:!(r=s(e,n))||r.enumerable});return t};var f=t=>d(o({},"__esModule",{value:!0}),t);var l={};c(l,{default:()=>u,throwWrongKeyOnActionCollectionConfig:()=>i});module.exports=f(l);var i=t=>{throw new Error(`[WRONG CONFIGURATION!]: Every key inside the storeActionsConfig must be a higher order function that returns a function
|
|
2
|
+
[${t}]: key is not a valid function, try something like this:
|
|
30
3
|
{
|
|
31
4
|
|
|
32
|
-
${
|
|
5
|
+
${t}: (param) => ({ setState, getState, setMetadata, getMetadata, actions }) => {
|
|
33
6
|
|
|
34
7
|
setState((state) => ({ ...state, ...param }))
|
|
35
8
|
|
|
36
9
|
}
|
|
37
10
|
|
|
38
11
|
}
|
|
39
|
-
`);
|
|
40
|
-
};
|
|
41
|
-
var throwWrongKeyOnActionCollectionConfig_default = throwWrongKeyOnActionCollectionConfig;
|
|
12
|
+
`)},u=i;
|
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
throw new Error(`[WRONG CONFIGURATION!]: Every key inside the storeActionsConfig must be a higher order function that returns a function
|
|
4
|
-
[${action_key}]: key is not a valid function, try something like this:
|
|
1
|
+
var e=t=>{throw new Error(`[WRONG CONFIGURATION!]: Every key inside the storeActionsConfig must be a higher order function that returns a function
|
|
2
|
+
[${t}]: key is not a valid function, try something like this:
|
|
5
3
|
{
|
|
6
4
|
|
|
7
|
-
${
|
|
5
|
+
${t}: (param) => ({ setState, getState, setMetadata, getMetadata, actions }) => {
|
|
8
6
|
|
|
9
7
|
setState((state) => ({ ...state, ...param }))
|
|
10
8
|
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
}
|
|
14
|
-
`);
|
|
15
|
-
};
|
|
16
|
-
var throwWrongKeyOnActionCollectionConfig_default = throwWrongKeyOnActionCollectionConfig;
|
|
17
|
-
export {
|
|
18
|
-
throwWrongKeyOnActionCollectionConfig_default as default,
|
|
19
|
-
throwWrongKeyOnActionCollectionConfig
|
|
20
|
-
};
|
|
12
|
+
`)},n=e;export{n as default,e as throwWrongKeyOnActionCollectionConfig};
|
package/types.cjs
CHANGED
|
@@ -1,18 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
|
|
16
|
-
// src/types.ts
|
|
17
|
-
var types_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(types_exports);
|
|
1
|
+
"use strict";var n=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var d=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of i(t))!S.call(e,a)&&a!==r&&n(e,a,{get:()=>t[a],enumerable:!(o=s(t,a))||o.enumerable});return e};var l=e=>d(n({},"__esModule",{value:!0}),e);var c={};module.exports=l(c);
|
package/types.d.ts
CHANGED
|
@@ -45,6 +45,13 @@ export interface SelectHook<State> {
|
|
|
45
45
|
*/
|
|
46
46
|
export type StateApi<State, StateMutator, Metadata extends BaseMetadata> = {
|
|
47
47
|
/**
|
|
48
|
+
* @description The metadata associated with the global state.
|
|
49
|
+
* Metadata is additional non reactive information associated with the global state, reading it will not trigger re-renders.
|
|
50
|
+
* To change the metadata use `setMetadata`.
|
|
51
|
+
*/
|
|
52
|
+
readonly metadata: Metadata;
|
|
53
|
+
/**
|
|
54
|
+
* @deprecated Use the `metadata` property instead, e.g. `const { metadata } = api;`. Metadata is stable, so it is exposed directly.
|
|
48
55
|
* Returns the metadata
|
|
49
56
|
* Metadata is additional non reactive information associated with the global state
|
|
50
57
|
*/
|
|
@@ -202,6 +209,12 @@ export type StoreTools<State, StateMutator = React.Dispatch<React.SetStateAction
|
|
|
202
209
|
*/
|
|
203
210
|
actions: StateMutator extends AnyFunction ? null : StateMutator;
|
|
204
211
|
/**
|
|
212
|
+
* @description Metadata associated with the global state.
|
|
213
|
+
* Metadata is non-reactive; reading it will not trigger re-renders. To change it use `setMetadata`.
|
|
214
|
+
*/
|
|
215
|
+
readonly metadata: Metadata;
|
|
216
|
+
/**
|
|
217
|
+
* @deprecated Use the `metadata` property instead, e.g. `const { metadata } = storeTools;`. Metadata is stable, so it is exposed directly.
|
|
205
218
|
* @description Metadata associated with the global state
|
|
206
219
|
*/
|
|
207
220
|
getMetadata: () => Metadata;
|
|
@@ -528,7 +541,7 @@ export type ContextProviderExtensions<State, StateMutator, Metadata extends Base
|
|
|
528
541
|
/**
|
|
529
542
|
* @description Underlying store instance
|
|
530
543
|
*/
|
|
531
|
-
instance: GlobalStore<State, Metadata, unknown,
|
|
544
|
+
instance: GlobalStore<State, Metadata, unknown, Any>;
|
|
532
545
|
};
|
|
533
546
|
};
|
|
534
547
|
};
|
|
@@ -1168,12 +1181,17 @@ export interface UniqueId {
|
|
|
1168
1181
|
*
|
|
1169
1182
|
* @example
|
|
1170
1183
|
* uniqueId(); // "k9j3n5x8q2"
|
|
1171
|
-
* type Id1 = `${string}` & { __brand:
|
|
1184
|
+
* type Id1 = `${string}` & { __brand: '' };
|
|
1185
|
+
*/
|
|
1186
|
+
(): BrandedId<''>;
|
|
1187
|
+
/**
|
|
1188
|
+
* Generates a unique identifier string, optionally prefixed.
|
|
1172
1189
|
*
|
|
1190
|
+
* @example
|
|
1173
1191
|
* uniqueId('user:'); // "user:k9j3n5x8q2"
|
|
1174
1192
|
* type Id2 = `user:${string}` & { __brand: 'user:' };
|
|
1175
1193
|
*/
|
|
1176
|
-
<T extends string
|
|
1194
|
+
<T extends string>(prefix: T): BrandedId<T>;
|
|
1177
1195
|
/**
|
|
1178
1196
|
* Creates a reusable unique ID generator for a specific prefix.
|
|
1179
1197
|
*
|
package/types.js
CHANGED
|
@@ -1,18 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
|
|
16
|
-
// src/types.ts
|
|
17
|
-
var types_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(types_exports);
|
|
1
|
+
"use strict";var n=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var d=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of i(t))!S.call(e,a)&&a!==r&&n(e,a,{get:()=>t[a],enumerable:!(o=s(t,a))||o.enumerable});return e};var l=e=>d(n({},"__esModule",{value:!0}),e);var c={};module.exports=l(c);
|
package/uniqueId.cjs
CHANGED
|
@@ -1,72 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/uniqueId.ts
|
|
21
|
-
var uniqueId_exports = {};
|
|
22
|
-
__export(uniqueId_exports, {
|
|
23
|
-
default: () => uniqueId_default,
|
|
24
|
-
uniqueId: () => uniqueId
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(uniqueId_exports);
|
|
27
|
-
var uniqueId = (() => {
|
|
28
|
-
let $counter = 0;
|
|
29
|
-
const counter = () => {
|
|
30
|
-
if ($counter === Number.MAX_SAFE_INTEGER) $counter = 0;
|
|
31
|
-
return $counter++;
|
|
32
|
-
};
|
|
33
|
-
const getBrandedId = (prefix, base) => {
|
|
34
|
-
var _a;
|
|
35
|
-
if ((_a = globalThis.crypto) == null ? void 0 : _a.randomUUID)
|
|
36
|
-
return (prefix != null ? prefix : "") + globalThis.crypto.randomUUID();
|
|
37
|
-
return (prefix != null ? prefix : "") + Date.now().toString(36) + base.toString(36);
|
|
38
|
-
};
|
|
39
|
-
const $uniqueId = (prefix) => {
|
|
40
|
-
return getBrandedId(prefix, counter());
|
|
41
|
-
};
|
|
42
|
-
$uniqueId.for = (prefix) => {
|
|
43
|
-
const generateBrandedId = () => {
|
|
44
|
-
return getBrandedId(prefix, counter());
|
|
45
|
-
};
|
|
46
|
-
generateBrandedId.is = (value) => {
|
|
47
|
-
return typeof value === "string" && value.startsWith(prefix);
|
|
48
|
-
};
|
|
49
|
-
generateBrandedId.assert = function(value) {
|
|
50
|
-
if (!generateBrandedId.is(value)) {
|
|
51
|
-
throw new Error(
|
|
52
|
-
`The value "${String(value)}" does not match the expected prefix "${String(prefix)}"`
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
generateBrandedId.strict = () => {
|
|
57
|
-
const strictBrandGenerator = generateBrandedId;
|
|
58
|
-
return strictBrandGenerator;
|
|
59
|
-
};
|
|
60
|
-
return generateBrandedId;
|
|
61
|
-
};
|
|
62
|
-
$uniqueId.of = () => {
|
|
63
|
-
const generateBrandedId = $uniqueId.for("");
|
|
64
|
-
return generateBrandedId;
|
|
65
|
-
};
|
|
66
|
-
$uniqueId.strict = () => {
|
|
67
|
-
const strictBrandGenerator = $uniqueId;
|
|
68
|
-
return strictBrandGenerator;
|
|
69
|
-
};
|
|
70
|
-
return $uniqueId;
|
|
71
|
-
})();
|
|
72
|
-
var uniqueId_default = uniqueId;
|
|
1
|
+
"use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var c=(d,r)=>{for(var s in r)o(d,s,{get:r[s],enumerable:!0})},g=(d,r,s,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of B(r))!I.call(d,n)&&n!==s&&o(d,n,{get:()=>r[n],enumerable:!(e=i(r,n))||e.enumerable});return d};var T=d=>g(o({},"__esModule",{value:!0}),d);var y={};c(y,{default:()=>l,uniqueId:()=>u});module.exports=T(y);var u=(()=>{let d=0,r=()=>(d===Number.MAX_SAFE_INTEGER&&(d=0),d++),s=(n,a)=>{var t;return(t=globalThis.crypto)!=null&&t.randomUUID?(n!=null?n:"")+globalThis.crypto.randomUUID():(n!=null?n:"")+Date.now().toString(36)+a.toString(36)},e=n=>s(n,r());return e.for=n=>{let a=()=>s(n,r());return a.is=t=>typeof t=="string"&&t.startsWith(n),a.assert=function(t){if(!a.is(t))throw new Error(`The value "${String(t)}" does not match the expected prefix "${String(n)}"`)},a.strict=()=>a,a},e.of=()=>e.for(""),e.strict=()=>e,e})(),l=u;
|
package/uniqueId.js
CHANGED
|
@@ -1,72 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/uniqueId.ts
|
|
21
|
-
var uniqueId_exports = {};
|
|
22
|
-
__export(uniqueId_exports, {
|
|
23
|
-
default: () => uniqueId_default,
|
|
24
|
-
uniqueId: () => uniqueId
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(uniqueId_exports);
|
|
27
|
-
var uniqueId = (() => {
|
|
28
|
-
let $counter = 0;
|
|
29
|
-
const counter = () => {
|
|
30
|
-
if ($counter === Number.MAX_SAFE_INTEGER) $counter = 0;
|
|
31
|
-
return $counter++;
|
|
32
|
-
};
|
|
33
|
-
const getBrandedId = (prefix, base) => {
|
|
34
|
-
var _a;
|
|
35
|
-
if ((_a = globalThis.crypto) == null ? void 0 : _a.randomUUID)
|
|
36
|
-
return (prefix != null ? prefix : "") + globalThis.crypto.randomUUID();
|
|
37
|
-
return (prefix != null ? prefix : "") + Date.now().toString(36) + base.toString(36);
|
|
38
|
-
};
|
|
39
|
-
const $uniqueId = (prefix) => {
|
|
40
|
-
return getBrandedId(prefix, counter());
|
|
41
|
-
};
|
|
42
|
-
$uniqueId.for = (prefix) => {
|
|
43
|
-
const generateBrandedId = () => {
|
|
44
|
-
return getBrandedId(prefix, counter());
|
|
45
|
-
};
|
|
46
|
-
generateBrandedId.is = (value) => {
|
|
47
|
-
return typeof value === "string" && value.startsWith(prefix);
|
|
48
|
-
};
|
|
49
|
-
generateBrandedId.assert = function(value) {
|
|
50
|
-
if (!generateBrandedId.is(value)) {
|
|
51
|
-
throw new Error(
|
|
52
|
-
`The value "${String(value)}" does not match the expected prefix "${String(prefix)}"`
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
generateBrandedId.strict = () => {
|
|
57
|
-
const strictBrandGenerator = generateBrandedId;
|
|
58
|
-
return strictBrandGenerator;
|
|
59
|
-
};
|
|
60
|
-
return generateBrandedId;
|
|
61
|
-
};
|
|
62
|
-
$uniqueId.of = () => {
|
|
63
|
-
const generateBrandedId = $uniqueId.for("");
|
|
64
|
-
return generateBrandedId;
|
|
65
|
-
};
|
|
66
|
-
$uniqueId.strict = () => {
|
|
67
|
-
const strictBrandGenerator = $uniqueId;
|
|
68
|
-
return strictBrandGenerator;
|
|
69
|
-
};
|
|
70
|
-
return $uniqueId;
|
|
71
|
-
})();
|
|
72
|
-
var uniqueId_default = uniqueId;
|
|
1
|
+
"use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var c=(d,r)=>{for(var s in r)o(d,s,{get:r[s],enumerable:!0})},g=(d,r,s,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of B(r))!I.call(d,n)&&n!==s&&o(d,n,{get:()=>r[n],enumerable:!(e=i(r,n))||e.enumerable});return d};var T=d=>g(o({},"__esModule",{value:!0}),d);var y={};c(y,{default:()=>l,uniqueId:()=>u});module.exports=T(y);var u=(()=>{let d=0,r=()=>(d===Number.MAX_SAFE_INTEGER&&(d=0),d++),s=(n,a)=>{var t;return(t=globalThis.crypto)!=null&&t.randomUUID?(n!=null?n:"")+globalThis.crypto.randomUUID():(n!=null?n:"")+Date.now().toString(36)+a.toString(36)},e=n=>s(n,r());return e.for=n=>{let a=()=>s(n,r());return a.is=t=>typeof t=="string"&&t.startsWith(n),a.assert=function(t){if(!a.is(t))throw new Error(`The value "${String(t)}" does not match the expected prefix "${String(n)}"`)},a.strict=()=>a,a},e.of=()=>e.for(""),e.strict=()=>e,e})(),l=u;
|
package/uniqueId.mjs
CHANGED
|
@@ -1,51 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var uniqueId = (() => {
|
|
3
|
-
let $counter = 0;
|
|
4
|
-
const counter = () => {
|
|
5
|
-
if ($counter === Number.MAX_SAFE_INTEGER) $counter = 0;
|
|
6
|
-
return $counter++;
|
|
7
|
-
};
|
|
8
|
-
const getBrandedId = (prefix, base) => {
|
|
9
|
-
var _a;
|
|
10
|
-
if ((_a = globalThis.crypto) == null ? void 0 : _a.randomUUID)
|
|
11
|
-
return (prefix != null ? prefix : "") + globalThis.crypto.randomUUID();
|
|
12
|
-
return (prefix != null ? prefix : "") + Date.now().toString(36) + base.toString(36);
|
|
13
|
-
};
|
|
14
|
-
const $uniqueId = (prefix) => {
|
|
15
|
-
return getBrandedId(prefix, counter());
|
|
16
|
-
};
|
|
17
|
-
$uniqueId.for = (prefix) => {
|
|
18
|
-
const generateBrandedId = () => {
|
|
19
|
-
return getBrandedId(prefix, counter());
|
|
20
|
-
};
|
|
21
|
-
generateBrandedId.is = (value) => {
|
|
22
|
-
return typeof value === "string" && value.startsWith(prefix);
|
|
23
|
-
};
|
|
24
|
-
generateBrandedId.assert = function(value) {
|
|
25
|
-
if (!generateBrandedId.is(value)) {
|
|
26
|
-
throw new Error(
|
|
27
|
-
`The value "${String(value)}" does not match the expected prefix "${String(prefix)}"`
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
generateBrandedId.strict = () => {
|
|
32
|
-
const strictBrandGenerator = generateBrandedId;
|
|
33
|
-
return strictBrandGenerator;
|
|
34
|
-
};
|
|
35
|
-
return generateBrandedId;
|
|
36
|
-
};
|
|
37
|
-
$uniqueId.of = () => {
|
|
38
|
-
const generateBrandedId = $uniqueId.for("");
|
|
39
|
-
return generateBrandedId;
|
|
40
|
-
};
|
|
41
|
-
$uniqueId.strict = () => {
|
|
42
|
-
const strictBrandGenerator = $uniqueId;
|
|
43
|
-
return strictBrandGenerator;
|
|
44
|
-
};
|
|
45
|
-
return $uniqueId;
|
|
46
|
-
})();
|
|
47
|
-
var uniqueId_default = uniqueId;
|
|
48
|
-
export {
|
|
49
|
-
uniqueId_default as default,
|
|
50
|
-
uniqueId
|
|
51
|
-
};
|
|
1
|
+
var o=(()=>{let t=0,a=()=>(t===Number.MAX_SAFE_INTEGER&&(t=0),t++),s=(n,d)=>{var r;return(r=globalThis.crypto)!=null&&r.randomUUID?(n!=null?n:"")+globalThis.crypto.randomUUID():(n!=null?n:"")+Date.now().toString(36)+d.toString(36)},e=n=>s(n,a());return e.for=n=>{let d=()=>s(n,a());return d.is=r=>typeof r=="string"&&r.startsWith(n),d.assert=function(r){if(!d.is(r))throw new Error(`The value "${String(r)}" does not match the expected prefix "${String(n)}"`)},d.strict=()=>d,d},e.of=()=>e.for(""),e.strict=()=>e,e})(),u=o;export{u as default,o as uniqueId};
|