react-hooks-global-states 15.0.18 → 16.0.0
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 +525 -0
- package/GlobalStore.debugProps.cjs +28 -0
- package/GlobalStore.debugProps.js +28 -0
- package/GlobalStore.debugProps.mjs +7 -0
- package/GlobalStore.js +525 -1
- package/GlobalStore.mjs +497 -0
- package/actions.cjs +61 -0
- package/actions.js +61 -1
- package/actions.mjs +30 -0
- package/bundle.cjs +40 -0
- package/bundle.js +40 -1
- package/bundle.mjs +19 -0
- package/createContext.cjs +253 -0
- package/createContext.js +253 -1
- package/createContext.mjs +235 -0
- package/createGlobalState.cjs +29 -0
- package/createGlobalState.js +29 -1
- package/createGlobalState.mjs +8 -0
- package/isRecord.cjs +46 -0
- package/isRecord.js +46 -1
- package/isRecord.mjs +15 -0
- package/package.json +38 -92
- package/shallowCompare.cjs +115 -0
- package/shallowCompare.js +115 -1
- package/shallowCompare.mjs +84 -0
- package/throwWrongKeyOnActionCollectionConfig.cjs +41 -0
- package/throwWrongKeyOnActionCollectionConfig.js +41 -1
- package/throwWrongKeyOnActionCollectionConfig.mjs +20 -0
- package/types.cjs +18 -0
- package/types.d.ts +6 -1
- package/types.js +18 -1
- package/types.mjs +0 -0
- package/uniqueId.cjs +72 -0
- package/uniqueId.js +72 -1
- package/uniqueId.mjs +51 -0
- package/webpack.config.js +0 -103
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// src/createContext.ts
|
|
34
|
+
import {
|
|
35
|
+
createContext as reactCreateContext,
|
|
36
|
+
useContext,
|
|
37
|
+
createElement as reactCreateElement,
|
|
38
|
+
useMemo,
|
|
39
|
+
useEffect,
|
|
40
|
+
useRef,
|
|
41
|
+
useDebugValue,
|
|
42
|
+
useLayoutEffect,
|
|
43
|
+
useState
|
|
44
|
+
} from "react";
|
|
45
|
+
import { createObservable, createSelectorHook as createSelectorHookBase, GlobalStore } from "./GlobalStore.mjs";
|
|
46
|
+
import isFunction from "json-storage-formatter/isFunction";
|
|
47
|
+
import uniqueId from "./uniqueId.mjs";
|
|
48
|
+
var createContext = (valueArg, contextArgs = {}) => {
|
|
49
|
+
var _a;
|
|
50
|
+
const Context = reactCreateContext(null);
|
|
51
|
+
const contextIdentifier = (_a = contextArgs.name) != null ? _a : uniqueId("ctx:");
|
|
52
|
+
const getInheritedState = () => isFunction(valueArg) ? valueArg() : valueArg;
|
|
53
|
+
const hasValueProp = (props) => {
|
|
54
|
+
return Object.prototype.hasOwnProperty.call(props, "value");
|
|
55
|
+
};
|
|
56
|
+
const useProviderValue = (props) => {
|
|
57
|
+
var _a2;
|
|
58
|
+
useDebugValue(`${contextIdentifier}:Provider`);
|
|
59
|
+
const [store] = useState(() => {
|
|
60
|
+
var _a3, _b, _c, _d;
|
|
61
|
+
const initialValue = (() => {
|
|
62
|
+
if (hasValueProp(props))
|
|
63
|
+
return isFunction(props.value) ? props.value(getInheritedState()) : props.value;
|
|
64
|
+
return getInheritedState();
|
|
65
|
+
})();
|
|
66
|
+
const store2 = new GlobalStore(initialValue, __spreadProps(__spreadValues({}, contextArgs), {
|
|
67
|
+
metadata: (_a3 = isFunction(contextArgs.metadata) ? contextArgs.metadata() : contextArgs.metadata) != null ? _a3 : {}
|
|
68
|
+
}));
|
|
69
|
+
const storeToolsExtensions = {
|
|
70
|
+
use
|
|
71
|
+
};
|
|
72
|
+
Object.assign(store2.storeTools, storeToolsExtensions);
|
|
73
|
+
(_c = (_b = contextArgs.callbacks) == null ? void 0 : _b.onCreated) == null ? void 0 : _c.call(
|
|
74
|
+
_b,
|
|
75
|
+
store2.storeTools,
|
|
76
|
+
store2
|
|
77
|
+
);
|
|
78
|
+
(_d = props.onCreated) == null ? void 0 : _d.call(props, store2.storeTools, store2);
|
|
79
|
+
return store2;
|
|
80
|
+
});
|
|
81
|
+
useLayoutEffect(() => {
|
|
82
|
+
const shouldUpdateState = hasValueProp(props) && !isFunction(props.value);
|
|
83
|
+
if (!shouldUpdateState) return;
|
|
84
|
+
store.setState(props.value);
|
|
85
|
+
}, [store, props.value]);
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
var _a3, _b, _c;
|
|
88
|
+
const unsubscribes = [
|
|
89
|
+
(_b = (_a3 = contextArgs.callbacks) == null ? void 0 : _a3.onMounted) == null ? void 0 : _b.call(
|
|
90
|
+
_a3,
|
|
91
|
+
store.storeTools,
|
|
92
|
+
store
|
|
93
|
+
),
|
|
94
|
+
(_c = props.onMounted) == null ? void 0 : _c.call(props, store.storeTools, store)
|
|
95
|
+
].filter(Boolean);
|
|
96
|
+
return () => {
|
|
97
|
+
var _a4, _b2, _c2;
|
|
98
|
+
(_b2 = (_a4 = store.callbacks) == null ? void 0 : _a4.onUnMount) == null ? void 0 : _b2.call(_a4, store);
|
|
99
|
+
unsubscribes.forEach((unsubscribe) => unsubscribe == null ? void 0 : unsubscribe());
|
|
100
|
+
(_c2 = store.__onUnMountContext) == null ? void 0 : _c2.call(
|
|
101
|
+
store,
|
|
102
|
+
store
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
}, [store]);
|
|
106
|
+
(_a2 = props.onRender) == null ? void 0 : _a2.call(props, store.storeTools, store);
|
|
107
|
+
return store;
|
|
108
|
+
};
|
|
109
|
+
const Provider = (args) => {
|
|
110
|
+
const store = useProviderValue(args);
|
|
111
|
+
return reactCreateElement(Context.Provider, { value: store.use }, args.children);
|
|
112
|
+
};
|
|
113
|
+
Provider.displayName = `${contextIdentifier}:Provider`;
|
|
114
|
+
Context.displayName = `${contextIdentifier}`;
|
|
115
|
+
const providerExtensions = {
|
|
116
|
+
makeProviderWrapper: (parentOptions) => {
|
|
117
|
+
const context = {
|
|
118
|
+
current: void 0,
|
|
119
|
+
instance: void 0
|
|
120
|
+
};
|
|
121
|
+
const wrapper = (_a2) => {
|
|
122
|
+
var _b = _a2, { children } = _b, options = __objRest(_b, ["children"]);
|
|
123
|
+
return reactCreateElement(
|
|
124
|
+
Provider,
|
|
125
|
+
__spreadProps(__spreadValues(__spreadValues({}, parentOptions), options), {
|
|
126
|
+
onCreated: (ctx, store) => {
|
|
127
|
+
var _a3;
|
|
128
|
+
context.current = ctx;
|
|
129
|
+
context.instance = store;
|
|
130
|
+
(_a3 = parentOptions == null ? void 0 : parentOptions.onCreated) == null ? void 0 : _a3.call(parentOptions, ctx, store);
|
|
131
|
+
}
|
|
132
|
+
}),
|
|
133
|
+
children
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
return { wrapper, context };
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
const use = (...args) => {
|
|
140
|
+
useDebugValue(`${contextIdentifier}:use`);
|
|
141
|
+
const hook = useContext(Context);
|
|
142
|
+
if (!hook) throw new Error("use hook must be used within a ContextProvider");
|
|
143
|
+
return hook(...args);
|
|
144
|
+
};
|
|
145
|
+
const api = () => {
|
|
146
|
+
useDebugValue(`${contextIdentifier}:api`);
|
|
147
|
+
const hook = useContext(Context);
|
|
148
|
+
if (!hook) throw new Error("api hook must be used within a ContextProvider");
|
|
149
|
+
return hook;
|
|
150
|
+
};
|
|
151
|
+
const observable = (...args) => {
|
|
152
|
+
useDebugValue(`${contextIdentifier}:observable`);
|
|
153
|
+
const context = api();
|
|
154
|
+
const props = useRef(args);
|
|
155
|
+
props.current = args;
|
|
156
|
+
return useMemo(() => {
|
|
157
|
+
var _a2, _b, _c;
|
|
158
|
+
return context.createObservable(
|
|
159
|
+
(state) => {
|
|
160
|
+
const selector = props.current[0];
|
|
161
|
+
return selector(state);
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
// we call the equality in this way to execute always the latest version of the functions
|
|
165
|
+
// check if the root state changed
|
|
166
|
+
isEqualRoot: !((_a2 = props.current[1]) == null ? void 0 : _a2.isEqualRoot) ? void 0 : (current, next) => {
|
|
167
|
+
const isEqualRoot = props.current[1].isEqualRoot;
|
|
168
|
+
return Boolean(isEqualRoot(current, next));
|
|
169
|
+
},
|
|
170
|
+
// check if the selection changed
|
|
171
|
+
isEqual: !((_b = props.current[1]) == null ? void 0 : _b.isEqual) ? void 0 : (current, next) => {
|
|
172
|
+
const isEqual = props.current[1].isEqual;
|
|
173
|
+
return Boolean(isEqual(current, next));
|
|
174
|
+
},
|
|
175
|
+
name: (_c = props.current[1]) == null ? void 0 : _c.name
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
}, [context]);
|
|
179
|
+
};
|
|
180
|
+
const useExtensions = {
|
|
181
|
+
displayName: Context.displayName,
|
|
182
|
+
createSelectorHook: createSelectorHook.bind(use),
|
|
183
|
+
api,
|
|
184
|
+
select: (...args) => use(...args)[0],
|
|
185
|
+
observable,
|
|
186
|
+
actions: () => {
|
|
187
|
+
return api().actions;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
Object.assign(Provider, providerExtensions);
|
|
191
|
+
Object.assign(use, useExtensions);
|
|
192
|
+
return {
|
|
193
|
+
use,
|
|
194
|
+
Provider,
|
|
195
|
+
Context
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
function createSelectorHook(selector, hookConfig) {
|
|
199
|
+
var _a;
|
|
200
|
+
const selectorIdentifier = (_a = hookConfig == null ? void 0 : hookConfig.name) != null ? _a : uniqueId("sh:");
|
|
201
|
+
const use = (...selectorArgs) => {
|
|
202
|
+
const context = this.api();
|
|
203
|
+
useDebugValue(`${this.displayName}:selector`);
|
|
204
|
+
useDebugValue(`${selectorIdentifier}:use`);
|
|
205
|
+
return useMemo(() => {
|
|
206
|
+
return context.createSelectorHook(selector, hookConfig);
|
|
207
|
+
}, [context])(...selectorArgs);
|
|
208
|
+
};
|
|
209
|
+
const api = () => {
|
|
210
|
+
useDebugValue(`${this.displayName}:selector`);
|
|
211
|
+
useDebugValue(`${selectorIdentifier}:api`);
|
|
212
|
+
const context = this.api();
|
|
213
|
+
return useMemo(() => {
|
|
214
|
+
const observable = context.createObservable(selector, hookConfig);
|
|
215
|
+
return __spreadProps(__spreadValues({}, context), {
|
|
216
|
+
getState: () => observable.getState(),
|
|
217
|
+
subscribe: observable.subscribe.bind(observable),
|
|
218
|
+
createSelectorHook: createSelectorHookBase.bind(observable),
|
|
219
|
+
createObservable: createObservable.bind(observable)
|
|
220
|
+
});
|
|
221
|
+
}, [context]);
|
|
222
|
+
};
|
|
223
|
+
const publicExtensions = {
|
|
224
|
+
displayName: this.displayName,
|
|
225
|
+
createSelectorHook: createSelectorHook.bind(use),
|
|
226
|
+
api
|
|
227
|
+
};
|
|
228
|
+
Object.assign(use, publicExtensions);
|
|
229
|
+
return use;
|
|
230
|
+
}
|
|
231
|
+
var createContext_default = createContext;
|
|
232
|
+
export {
|
|
233
|
+
createContext,
|
|
234
|
+
createContext_default as default
|
|
235
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
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/createGlobalState.ts
|
|
21
|
+
var createGlobalState_exports = {};
|
|
22
|
+
__export(createGlobalState_exports, {
|
|
23
|
+
createGlobalState: () => createGlobalState,
|
|
24
|
+
default: () => createGlobalState_default
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(createGlobalState_exports);
|
|
27
|
+
var import_GlobalStore = require("./GlobalStore.cjs");
|
|
28
|
+
var createGlobalState = (...[state, args]) => new import_GlobalStore.GlobalStore(state, args).use;
|
|
29
|
+
var createGlobalState_default = createGlobalState;
|
package/createGlobalState.js
CHANGED
|
@@ -1 +1,29 @@
|
|
|
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/createGlobalState.ts
|
|
21
|
+
var createGlobalState_exports = {};
|
|
22
|
+
__export(createGlobalState_exports, {
|
|
23
|
+
createGlobalState: () => createGlobalState,
|
|
24
|
+
default: () => createGlobalState_default
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(createGlobalState_exports);
|
|
27
|
+
var import_GlobalStore = require("./GlobalStore.js");
|
|
28
|
+
var createGlobalState = (...[state, args]) => new import_GlobalStore.GlobalStore(state, args).use;
|
|
29
|
+
var createGlobalState_default = createGlobalState;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// src/createGlobalState.ts
|
|
2
|
+
import { GlobalStore } from "./GlobalStore.mjs";
|
|
3
|
+
var createGlobalState = (...[state, args]) => new GlobalStore(state, args).use;
|
|
4
|
+
var createGlobalState_default = createGlobalState;
|
|
5
|
+
export {
|
|
6
|
+
createGlobalState,
|
|
7
|
+
createGlobalState_default as default
|
|
8
|
+
};
|
package/isRecord.cjs
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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/isRecord.ts
|
|
31
|
+
var isRecord_exports = {};
|
|
32
|
+
__export(isRecord_exports, {
|
|
33
|
+
default: () => isRecord_default,
|
|
34
|
+
isRecord: () => isRecord
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(isRecord_exports);
|
|
37
|
+
var import_isNil = __toESM(require("json-storage-formatter/isNil"));
|
|
38
|
+
var isRecord = (value) => {
|
|
39
|
+
if ((0, import_isNil.default)(value) || typeof value !== "object") return false;
|
|
40
|
+
if (Array.isArray(value)) return false;
|
|
41
|
+
if (value instanceof Map) return false;
|
|
42
|
+
if (value instanceof Set) return false;
|
|
43
|
+
if (value instanceof Date) return false;
|
|
44
|
+
return true;
|
|
45
|
+
};
|
|
46
|
+
var isRecord_default = isRecord;
|
package/isRecord.js
CHANGED
|
@@ -1 +1,46 @@
|
|
|
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/isRecord.ts
|
|
31
|
+
var isRecord_exports = {};
|
|
32
|
+
__export(isRecord_exports, {
|
|
33
|
+
default: () => isRecord_default,
|
|
34
|
+
isRecord: () => isRecord
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(isRecord_exports);
|
|
37
|
+
var import_isNil = __toESM(require("json-storage-formatter/isNil"));
|
|
38
|
+
var isRecord = (value) => {
|
|
39
|
+
if ((0, import_isNil.default)(value) || typeof value !== "object") return false;
|
|
40
|
+
if (Array.isArray(value)) return false;
|
|
41
|
+
if (value instanceof Map) return false;
|
|
42
|
+
if (value instanceof Set) return false;
|
|
43
|
+
if (value instanceof Date) return false;
|
|
44
|
+
return true;
|
|
45
|
+
};
|
|
46
|
+
var isRecord_default = isRecord;
|
package/isRecord.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/isRecord.ts
|
|
2
|
+
import isNil from "json-storage-formatter/isNil";
|
|
3
|
+
var isRecord = (value) => {
|
|
4
|
+
if (isNil(value) || typeof value !== "object") return false;
|
|
5
|
+
if (Array.isArray(value)) return false;
|
|
6
|
+
if (value instanceof Map) return false;
|
|
7
|
+
if (value instanceof Set) return false;
|
|
8
|
+
if (value instanceof Date) return false;
|
|
9
|
+
return true;
|
|
10
|
+
};
|
|
11
|
+
var isRecord_default = isRecord;
|
|
12
|
+
export {
|
|
13
|
+
isRecord_default as default,
|
|
14
|
+
isRecord
|
|
15
|
+
};
|
package/package.json
CHANGED
|
@@ -1,89 +1,70 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-hooks-global-states",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.0",
|
|
4
4
|
"description": "A package to easily handle global state across your React components using hooks.",
|
|
5
|
-
"main": "./bundle.
|
|
5
|
+
"main": "./bundle.cjs",
|
|
6
|
+
"module": "./bundle.mjs",
|
|
6
7
|
"types": "./index.d.ts",
|
|
7
8
|
"sideEffects": false,
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"types": "./index.d.ts",
|
|
12
|
+
"import": "./bundle.mjs",
|
|
13
|
+
"require": "./bundle.cjs"
|
|
13
14
|
},
|
|
14
15
|
"./createContext": {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
16
|
+
"types": "./createContext.d.ts",
|
|
17
|
+
"import": "./createContext.mjs",
|
|
18
|
+
"require": "./createContext.cjs"
|
|
18
19
|
},
|
|
19
20
|
"./GlobalStore": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
},
|
|
24
|
-
"./GlobalStoreAbstract": {
|
|
25
|
-
"import": "./GlobalStoreAbstract.js",
|
|
26
|
-
"require": "./GlobalStoreAbstract.js",
|
|
27
|
-
"types": "./GlobalStoreAbstract.d.ts"
|
|
21
|
+
"types": "./GlobalStore.d.ts",
|
|
22
|
+
"import": "./GlobalStore.mjs",
|
|
23
|
+
"require": "./GlobalStore.cjs"
|
|
28
24
|
},
|
|
29
25
|
"./createGlobalState": {
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
26
|
+
"types": "./createGlobalState.d.ts",
|
|
27
|
+
"import": "./createGlobalState.mjs",
|
|
28
|
+
"require": "./createGlobalState.cjs"
|
|
33
29
|
},
|
|
34
30
|
"./types": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
31
|
+
"types": "./types.d.ts",
|
|
32
|
+
"import": "./types.mjs",
|
|
33
|
+
"require": "./types.cjs"
|
|
38
34
|
},
|
|
39
35
|
"./isRecord": {
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
36
|
+
"types": "./isRecord.d.ts",
|
|
37
|
+
"import": "./isRecord.mjs",
|
|
38
|
+
"require": "./isRecord.cjs"
|
|
43
39
|
},
|
|
44
40
|
"./shallowCompare": {
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
41
|
+
"types": "./shallowCompare.d.ts",
|
|
42
|
+
"import": "./shallowCompare.mjs",
|
|
43
|
+
"require": "./shallowCompare.cjs"
|
|
48
44
|
},
|
|
49
45
|
"./throwWrongKeyOnActionCollectionConfig": {
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
46
|
+
"types": "./throwWrongKeyOnActionCollectionConfig.d.ts",
|
|
47
|
+
"import": "./throwWrongKeyOnActionCollectionConfig.mjs",
|
|
48
|
+
"require": "./throwWrongKeyOnActionCollectionConfig.cjs"
|
|
53
49
|
},
|
|
54
50
|
"./uniqueId": {
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
51
|
+
"types": "./uniqueId.d.ts",
|
|
52
|
+
"import": "./uniqueId.mjs",
|
|
53
|
+
"require": "./uniqueId.cjs"
|
|
58
54
|
},
|
|
59
55
|
"./actions": {
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
}
|
|
56
|
+
"types": "./actions.d.ts",
|
|
57
|
+
"import": "./actions.mjs",
|
|
58
|
+
"require": "./actions.cjs"
|
|
59
|
+
},
|
|
60
|
+
"./package.json": "./package.json"
|
|
64
61
|
},
|
|
65
62
|
"files": [
|
|
66
63
|
"*.js",
|
|
64
|
+
"*.cjs",
|
|
65
|
+
"*.mjs",
|
|
67
66
|
"*.d.ts"
|
|
68
67
|
],
|
|
69
|
-
"scripts": {
|
|
70
|
-
"format": "prettier --write . --log-level silent && yarn lint:fix",
|
|
71
|
-
"test": "yarn build && yarn ts-check:tests && yarn jest",
|
|
72
|
-
"test:logs": "sh -c 'yarn build && yarn jest \"$@\" 2>&1 | grep -i \"console\" -A 2' --",
|
|
73
|
-
"test:debug:no-watch": "node --inspect-brk node_modules/.bin/jest --no-watchman --runInBand",
|
|
74
|
-
"test:debug": "node --inspect-brk node_modules/.bin/jest --watch --runInBand",
|
|
75
|
-
"test:quick": "yarn ts-check:tests && yarn test --no-coverage --maxWorkers=4 -c --no-watchman -u",
|
|
76
|
-
"test:coverage": "yarn test --maxWorkers=4 -c --colors --no-watchman --verbose --coverage",
|
|
77
|
-
"build": "yarn ts-check && yarn clean && webpack --config webpack.config.js",
|
|
78
|
-
"prepare": "yarn format && npm run build && yarn test:quick",
|
|
79
|
-
"version": "npm run format && yarn build && yarn jest && git add -A",
|
|
80
|
-
"postversion": "git push && git push --tags",
|
|
81
|
-
"lint": "eslint . --max-warnings=0",
|
|
82
|
-
"lint:fix": "eslint . --fix --max-warnings=0",
|
|
83
|
-
"clean": "find . -maxdepth 1 -type f \\( -name '*.js' -o -name '*.d.ts' \\) ! -name 'webpack.config.js' ! -name 'eslint.config.mts' -exec rm {} + && rm -rf coverage",
|
|
84
|
-
"ts-check": "tsc -p tsconfig.json --noEmit",
|
|
85
|
-
"ts-check:tests": "tsc -p tsconfig.test.json --noEmit"
|
|
86
|
-
},
|
|
87
68
|
"repository": {
|
|
88
69
|
"type": "git",
|
|
89
70
|
"url": "git+https://github.com/johnny-quesada-developer/react-hooks-global-states.git"
|
|
@@ -106,51 +87,16 @@
|
|
|
106
87
|
"url": "https://github.com/johnny-quesada-developer/react-hooks-global-states/issues"
|
|
107
88
|
},
|
|
108
89
|
"homepage": "https://github.com/johnny-quesada-developer/react-hooks-global-states#readme",
|
|
109
|
-
"devDependencies": {
|
|
110
|
-
"@eslint/js": "^9.39.1",
|
|
111
|
-
"@testing-library/dom": "^10.4.0",
|
|
112
|
-
"@testing-library/react": "^16.3.0",
|
|
113
|
-
"@types/jest": "^29.5.11",
|
|
114
|
-
"@types/react": "^18.2.45",
|
|
115
|
-
"@types/react-dom": "^18.2.18",
|
|
116
|
-
"@typescript-eslint/eslint-plugin": "^4.9.1",
|
|
117
|
-
"@typescript-eslint/parser": "^4.9.1",
|
|
118
|
-
"clean-webpack-plugin": "^4.0.0",
|
|
119
|
-
"easy-cancelable-promise": "^1.0.1",
|
|
120
|
-
"eslint": "^9.39.1",
|
|
121
|
-
"eslint-config-airbnb": "^18.2.1",
|
|
122
|
-
"eslint-plugin-import": "^2.22.1",
|
|
123
|
-
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
124
|
-
"eslint-plugin-react": "^7.37.5",
|
|
125
|
-
"eslint-plugin-react-hooks": "^4.2.0",
|
|
126
|
-
"jest": "^29.7.0",
|
|
127
|
-
"jest-environment-jsdom": "^30.0.4",
|
|
128
|
-
"jiti": "^2.6.1",
|
|
129
|
-
"prettier": "^3.6.2",
|
|
130
|
-
"react": "^18.2.0",
|
|
131
|
-
"react-dom": "^18.2.0",
|
|
132
|
-
"ts-jest": "^29.1.1",
|
|
133
|
-
"ts-loader": "^9.5.1",
|
|
134
|
-
"tslib": "^2.6.2",
|
|
135
|
-
"typescript": "^5.8.2",
|
|
136
|
-
"typescript-eslint": "^8.46.3",
|
|
137
|
-
"webpack": "^5.76.3",
|
|
138
|
-
"webpack-cli": "^5.0.1"
|
|
139
|
-
},
|
|
140
90
|
"dependencies": {
|
|
141
|
-
"json-storage-formatter": "
|
|
91
|
+
"json-storage-formatter": "4.0.0"
|
|
142
92
|
},
|
|
143
93
|
"peerDependencies": {
|
|
144
|
-
"json-storage-formatter": "^3.0.2",
|
|
145
94
|
"react": ">=18.0.0",
|
|
146
95
|
"react-dom": ">=18.0.0"
|
|
147
96
|
},
|
|
148
97
|
"peerDependenciesMeta": {
|
|
149
98
|
"react": {
|
|
150
99
|
"optional": false
|
|
151
|
-
},
|
|
152
|
-
"json-storage-formatter": {
|
|
153
|
-
"optional": false
|
|
154
100
|
}
|
|
155
101
|
}
|
|
156
102
|
}
|