react-hooks-global-states 16.0.0 → 16.0.1
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/jest.config.js +50 -0
- package/package.json +52 -2
- package/GlobalStore.cjs +0 -525
- package/GlobalStore.d.ts +0 -160
- package/GlobalStore.debugProps.cjs +0 -28
- package/GlobalStore.debugProps.d.ts +0 -5
- package/GlobalStore.debugProps.js +0 -28
- package/GlobalStore.debugProps.mjs +0 -7
- package/GlobalStore.js +0 -525
- package/GlobalStore.mjs +0 -497
- package/actions.cjs +0 -61
- package/actions.d.ts +0 -32
- package/actions.js +0 -61
- package/actions.mjs +0 -30
- package/bundle.cjs +0 -40
- package/bundle.js +0 -40
- package/bundle.mjs +0 -19
- package/createContext.cjs +0 -253
- package/createContext.d.ts +0 -15
- package/createContext.js +0 -253
- package/createContext.mjs +0 -235
- package/createGlobalState.cjs +0 -29
- package/createGlobalState.d.ts +0 -7
- package/createGlobalState.js +0 -29
- package/createGlobalState.mjs +0 -8
- package/index.d.ts +0 -9
- package/isRecord.cjs +0 -46
- package/isRecord.d.ts +0 -2
- package/isRecord.js +0 -46
- package/isRecord.mjs +0 -15
- package/shallowCompare.cjs +0 -115
- package/shallowCompare.d.ts +0 -52
- package/shallowCompare.js +0 -115
- package/shallowCompare.mjs +0 -84
- package/throwWrongKeyOnActionCollectionConfig.cjs +0 -41
- package/throwWrongKeyOnActionCollectionConfig.d.ts +0 -2
- package/throwWrongKeyOnActionCollectionConfig.js +0 -41
- package/throwWrongKeyOnActionCollectionConfig.mjs +0 -20
- package/types.cjs +0 -18
- package/types.d.ts +0 -1250
- package/types.js +0 -18
- package/types.mjs +0 -0
- package/uniqueId.cjs +0 -72
- package/uniqueId.d.ts +0 -7
- package/uniqueId.js +0 -72
- package/uniqueId.mjs +0 -51
package/shallowCompare.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
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;
|
package/shallowCompare.mjs
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
// src/shallowCompare.ts
|
|
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,41 +0,0 @@
|
|
|
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/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:
|
|
30
|
-
{
|
|
31
|
-
|
|
32
|
-
${action_key}: (param) => ({ setState, getState, setMetadata, getMetadata, actions }) => {
|
|
33
|
-
|
|
34
|
-
setState((state) => ({ ...state, ...param }))
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
`);
|
|
40
|
-
};
|
|
41
|
-
var throwWrongKeyOnActionCollectionConfig_default = throwWrongKeyOnActionCollectionConfig;
|
|
@@ -1,41 +0,0 @@
|
|
|
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/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:
|
|
30
|
-
{
|
|
31
|
-
|
|
32
|
-
${action_key}: (param) => ({ setState, getState, setMetadata, getMetadata, actions }) => {
|
|
33
|
-
|
|
34
|
-
setState((state) => ({ ...state, ...param }))
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
`);
|
|
40
|
-
};
|
|
41
|
-
var throwWrongKeyOnActionCollectionConfig_default = throwWrongKeyOnActionCollectionConfig;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// src/throwWrongKeyOnActionCollectionConfig.ts
|
|
2
|
-
var throwWrongKeyOnActionCollectionConfig = (action_key) => {
|
|
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:
|
|
5
|
-
{
|
|
6
|
-
|
|
7
|
-
${action_key}: (param) => ({ setState, getState, setMetadata, getMetadata, actions }) => {
|
|
8
|
-
|
|
9
|
-
setState((state) => ({ ...state, ...param }))
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
`);
|
|
15
|
-
};
|
|
16
|
-
var throwWrongKeyOnActionCollectionConfig_default = throwWrongKeyOnActionCollectionConfig;
|
|
17
|
-
export {
|
|
18
|
-
throwWrongKeyOnActionCollectionConfig_default as default,
|
|
19
|
-
throwWrongKeyOnActionCollectionConfig
|
|
20
|
-
};
|
package/types.cjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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);
|