react-global-state-hooks 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 +240 -0
- package/GlobalStore.js +240 -1
- package/GlobalStore.mjs +212 -0
- package/actions.cjs +37 -0
- package/actions.js +37 -1
- package/actions.mjs +6 -0
- package/bundle.cjs +40 -0
- package/bundle.js +40 -1
- package/bundle.mjs +19 -0
- package/createContext.cjs +37 -0
- package/createContext.js +37 -1
- package/createContext.mjs +9 -0
- package/createGlobalState.cjs +41 -0
- package/createGlobalState.js +41 -1
- package/createGlobalState.mjs +10 -0
- package/isRecord.cjs +37 -0
- package/isRecord.js +37 -1
- package/isRecord.mjs +6 -0
- package/package.json +40 -92
- package/shallowCompare.cjs +37 -0
- package/shallowCompare.js +37 -1
- package/shallowCompare.mjs +6 -0
- package/throwWrongKeyOnActionCollectionConfig.cjs +37 -0
- package/throwWrongKeyOnActionCollectionConfig.js +37 -1
- package/throwWrongKeyOnActionCollectionConfig.mjs +9 -0
- package/tryCatch.cjs +33 -0
- package/tryCatch.js +33 -0
- package/tryCatch.mjs +12 -0
- package/types.cjs +18 -0
- package/types.js +18 -1
- package/types.mjs +0 -0
- package/uniqueId.cjs +37 -0
- package/uniqueId.js +37 -1
- package/uniqueId.mjs +6 -0
- package/webpack.config.js +0 -112
package/GlobalStore.mjs
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
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
|
+
|
|
21
|
+
// src/GlobalStore.ts
|
|
22
|
+
import GlobalStoreBase from "react-hooks-global-states/GlobalStore";
|
|
23
|
+
import tryCatch from "./tryCatch.mjs";
|
|
24
|
+
import formatFromStore from "json-storage-formatter/formatFromStore";
|
|
25
|
+
import formatToStore from "json-storage-formatter/formatToStore";
|
|
26
|
+
import isNil from "json-storage-formatter/isNil";
|
|
27
|
+
import isPrimitive from "json-storage-formatter/isPrimitive";
|
|
28
|
+
var defaultStorageVersion = -1;
|
|
29
|
+
var GlobalStore = class _GlobalStore extends GlobalStoreBase {
|
|
30
|
+
constructor(state, args = { metadata: {} }) {
|
|
31
|
+
var _a;
|
|
32
|
+
super(state, args);
|
|
33
|
+
this.localStorage = null;
|
|
34
|
+
// we are overriding the onInit to add local storage restoration logic
|
|
35
|
+
this.onInit = () => {
|
|
36
|
+
const storageConfig = this.localStorage;
|
|
37
|
+
if (!storageConfig || !this.isPersistStorageAvailable()) return;
|
|
38
|
+
const versioning = storageConfig.versioning;
|
|
39
|
+
const { result: restoredEnvelope, error: initializationError } = tryCatch(
|
|
40
|
+
() => {
|
|
41
|
+
var _a, _b, _c;
|
|
42
|
+
if ((_a = storageConfig.adapter) == null ? void 0 : _a.getItem) {
|
|
43
|
+
return {
|
|
44
|
+
s: (_b = storageConfig.adapter) == null ? void 0 : _b.getItem(storageConfig.key),
|
|
45
|
+
v: (_c = versioning == null ? void 0 : versioning.version) != null ? _c : defaultStorageVersion
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const envelope = this.getStorageItem();
|
|
49
|
+
const shouldMergeStates = envelope && storageConfig.selector && !isPrimitive(envelope == null ? void 0 : envelope.s);
|
|
50
|
+
if (!shouldMergeStates) return envelope;
|
|
51
|
+
return __spreadProps(__spreadValues({}, envelope), {
|
|
52
|
+
s: __spreadValues(__spreadValues({}, this.getState()), envelope.s)
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
if (initializationError) {
|
|
57
|
+
this.handleStorageError(initializationError);
|
|
58
|
+
this.updateStateWithValidation(this.getState());
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (!restoredEnvelope) {
|
|
62
|
+
this.updateStateWithValidation(this.getState());
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const isSameVersion = restoredEnvelope.v === (versioning == null ? void 0 : versioning.version);
|
|
66
|
+
const migratorFn = versioning == null ? void 0 : versioning.migrator;
|
|
67
|
+
if (isSameVersion || !migratorFn || storageConfig.adapter) {
|
|
68
|
+
this.updateStateWithValidation(restoredEnvelope.s);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const { result: migrated, error: migrateError } = tryCatch(() => {
|
|
72
|
+
return migratorFn(
|
|
73
|
+
{
|
|
74
|
+
legacy: restoredEnvelope.s,
|
|
75
|
+
initial: this.getState()
|
|
76
|
+
},
|
|
77
|
+
this.storeTools
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
if (!migrateError) {
|
|
81
|
+
this.updateStateWithValidation(migrated);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.handleStorageError(migrateError);
|
|
85
|
+
this.updateStateWithValidation(this.getState());
|
|
86
|
+
};
|
|
87
|
+
// we are overriding the onStateChanged to add local storage sync logic
|
|
88
|
+
this.onStateChanged = ({ state }) => {
|
|
89
|
+
const storageConfig = this.localStorage;
|
|
90
|
+
if (!storageConfig || !this.isPersistStorageAvailable()) return;
|
|
91
|
+
const { error } = tryCatch(() => {
|
|
92
|
+
var _a;
|
|
93
|
+
const setFn = (_a = storageConfig.adapter) == null ? void 0 : _a.setItem;
|
|
94
|
+
if (setFn) {
|
|
95
|
+
return setFn(storageConfig.key, state);
|
|
96
|
+
}
|
|
97
|
+
this.setStorageItem(state);
|
|
98
|
+
});
|
|
99
|
+
if (!error) return;
|
|
100
|
+
this.handleStorageError(error);
|
|
101
|
+
};
|
|
102
|
+
this.localStorage = (_a = args.localStorage) != null ? _a : null;
|
|
103
|
+
const isExtensionClass = this.constructor !== _GlobalStore;
|
|
104
|
+
if (isExtensionClass) return;
|
|
105
|
+
this.initialize();
|
|
106
|
+
}
|
|
107
|
+
isPersistStorageAvailable() {
|
|
108
|
+
var _a;
|
|
109
|
+
return Boolean(((_a = this.localStorage) == null ? void 0 : _a.key) && (globalThis == null ? void 0 : globalThis.localStorage));
|
|
110
|
+
}
|
|
111
|
+
trySetStorageItem(state) {
|
|
112
|
+
const storageConfig = this.localStorage;
|
|
113
|
+
if (!storageConfig) return;
|
|
114
|
+
const { error } = tryCatch(() => {
|
|
115
|
+
var _a;
|
|
116
|
+
const setFn = (_a = storageConfig.adapter) == null ? void 0 : _a.setItem;
|
|
117
|
+
if (!setFn) return this.setStorageItem(state);
|
|
118
|
+
setFn(storageConfig.key, state);
|
|
119
|
+
});
|
|
120
|
+
if (!error) return;
|
|
121
|
+
this.handleStorageError(error);
|
|
122
|
+
}
|
|
123
|
+
// helper to validate and update the state
|
|
124
|
+
updateStateWithValidation(state) {
|
|
125
|
+
const storageConfig = this.localStorage;
|
|
126
|
+
if (!storageConfig) return;
|
|
127
|
+
const { result: sanitizedState, error: validationError } = tryCatch(() => {
|
|
128
|
+
var _a;
|
|
129
|
+
return (_a = storageConfig.validator) == null ? void 0 : _a.call(
|
|
130
|
+
storageConfig,
|
|
131
|
+
{
|
|
132
|
+
restored: state,
|
|
133
|
+
initial: this.getState()
|
|
134
|
+
},
|
|
135
|
+
this.storeTools
|
|
136
|
+
);
|
|
137
|
+
});
|
|
138
|
+
if (validationError) {
|
|
139
|
+
this.handleStorageError(validationError);
|
|
140
|
+
this.trySetStorageItem(this.getState());
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (sanitizedState === void 0) {
|
|
144
|
+
if (state === void 0) {
|
|
145
|
+
this.trySetStorageItem(this.getState());
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
this.setState(state);
|
|
149
|
+
this.trySetStorageItem(state);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
this.setState(sanitizedState);
|
|
153
|
+
this.trySetStorageItem(sanitizedState);
|
|
154
|
+
}
|
|
155
|
+
// retrieves a versioned item from the local storage
|
|
156
|
+
getStorageItem() {
|
|
157
|
+
const json = globalThis.localStorage.getItem(this.localStorage.key);
|
|
158
|
+
const restoredEnvelope = isNil(json) ? null : formatFromStore(json);
|
|
159
|
+
assertEnvelopeFormat(this.localStorage.key, restoredEnvelope);
|
|
160
|
+
return restoredEnvelope;
|
|
161
|
+
}
|
|
162
|
+
// add a versioned item to the local storage
|
|
163
|
+
setStorageItem(state) {
|
|
164
|
+
var _a, _b, _c, _d;
|
|
165
|
+
const envelope = {
|
|
166
|
+
s: ((_a = this.localStorage) == null ? void 0 : _a.selector) ? this.localStorage.selector(state) : state,
|
|
167
|
+
v: (_d = (_c = (_b = this.localStorage) == null ? void 0 : _b.versioning) == null ? void 0 : _c.version) != null ? _d : defaultStorageVersion
|
|
168
|
+
};
|
|
169
|
+
const formatted = formatToStore(envelope);
|
|
170
|
+
globalThis.localStorage.setItem(this.localStorage.key, formatted);
|
|
171
|
+
}
|
|
172
|
+
reset(...args) {
|
|
173
|
+
if (this.isPersistStorageAvailable() && args.length === 0) {
|
|
174
|
+
globalThis.localStorage.removeItem(this.localStorage.key);
|
|
175
|
+
}
|
|
176
|
+
super.reset(...args);
|
|
177
|
+
}
|
|
178
|
+
handleStorageError(error) {
|
|
179
|
+
var _a, _b;
|
|
180
|
+
if ((_a = this.localStorage) == null ? void 0 : _a.onError) {
|
|
181
|
+
return this.localStorage.onError(error, this.storeTools);
|
|
182
|
+
}
|
|
183
|
+
globalThis.console.error(
|
|
184
|
+
[
|
|
185
|
+
"[react-global-state-hooks]\n",
|
|
186
|
+
" localStorage sync error:",
|
|
187
|
+
`[hook]:`,
|
|
188
|
+
` ${this._name}`,
|
|
189
|
+
`[Localstorage Key]:`,
|
|
190
|
+
` ${(_b = this.localStorage) == null ? void 0 : _b.key}`,
|
|
191
|
+
`[Error]:`,
|
|
192
|
+
` ${error != null ? error : "undefined"}
|
|
193
|
+
|
|
194
|
+
`,
|
|
195
|
+
"Stacktrace:"
|
|
196
|
+
].join("\n"),
|
|
197
|
+
error.stack
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
function assertEnvelopeFormat(key, value) {
|
|
202
|
+
if (isNil(value)) return;
|
|
203
|
+
if (typeof value === "object" && "s" in value && "v" in value) return;
|
|
204
|
+
throw new Error(
|
|
205
|
+
`[react-native-global-state-hooks] The value of the key "${key}" is not a valid storage envelope.`
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
var GlobalStore_default = GlobalStore;
|
|
209
|
+
export {
|
|
210
|
+
GlobalStore,
|
|
211
|
+
GlobalStore_default as default
|
|
212
|
+
};
|
package/actions.cjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
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/actions.ts
|
|
31
|
+
var actions_exports = {};
|
|
32
|
+
__export(actions_exports, {
|
|
33
|
+
actions: () => import_actions.actions,
|
|
34
|
+
default: () => import_actions.default
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(actions_exports);
|
|
37
|
+
var import_actions = __toESM(require("react-hooks-global-states/actions"));
|
package/actions.js
CHANGED
|
@@ -1 +1,37 @@
|
|
|
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/actions.ts
|
|
31
|
+
var actions_exports = {};
|
|
32
|
+
__export(actions_exports, {
|
|
33
|
+
actions: () => import_actions.actions,
|
|
34
|
+
default: () => import_actions.default
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(actions_exports);
|
|
37
|
+
var import_actions = __toESM(require("react-hooks-global-states/actions"));
|
package/actions.mjs
ADDED
package/bundle.cjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
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/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
GlobalStore: () => import_GlobalStore.GlobalStore,
|
|
24
|
+
actions: () => import_actions.actions,
|
|
25
|
+
createContext: () => import_createContext.createContext,
|
|
26
|
+
createGlobalState: () => import_createGlobalState.createGlobalState,
|
|
27
|
+
isRecord: () => import_isRecord.isRecord,
|
|
28
|
+
shallowCompare: () => import_shallowCompare.shallowCompare,
|
|
29
|
+
throwWrongKeyOnActionCollectionConfig: () => import_throwWrongKeyOnActionCollectionConfig.throwWrongKeyOnActionCollectionConfig,
|
|
30
|
+
uniqueId: () => import_uniqueId.uniqueId
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(src_exports);
|
|
33
|
+
var import_GlobalStore = require("./GlobalStore.cjs");
|
|
34
|
+
var import_createGlobalState = require("./createGlobalState.cjs");
|
|
35
|
+
var import_createContext = require("./createContext.cjs");
|
|
36
|
+
var import_shallowCompare = require("./shallowCompare.cjs");
|
|
37
|
+
var import_uniqueId = require("./uniqueId.cjs");
|
|
38
|
+
var import_throwWrongKeyOnActionCollectionConfig = require("./throwWrongKeyOnActionCollectionConfig.cjs");
|
|
39
|
+
var import_isRecord = require("./isRecord.cjs");
|
|
40
|
+
var import_actions = require("./actions.cjs");
|
package/bundle.js
CHANGED
|
@@ -1 +1,40 @@
|
|
|
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/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
GlobalStore: () => import_GlobalStore.GlobalStore,
|
|
24
|
+
actions: () => import_actions.actions,
|
|
25
|
+
createContext: () => import_createContext.createContext,
|
|
26
|
+
createGlobalState: () => import_createGlobalState.createGlobalState,
|
|
27
|
+
isRecord: () => import_isRecord.isRecord,
|
|
28
|
+
shallowCompare: () => import_shallowCompare.shallowCompare,
|
|
29
|
+
throwWrongKeyOnActionCollectionConfig: () => import_throwWrongKeyOnActionCollectionConfig.throwWrongKeyOnActionCollectionConfig,
|
|
30
|
+
uniqueId: () => import_uniqueId.uniqueId
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(src_exports);
|
|
33
|
+
var import_GlobalStore = require("./GlobalStore.js");
|
|
34
|
+
var import_createGlobalState = require("./createGlobalState.js");
|
|
35
|
+
var import_createContext = require("./createContext.js");
|
|
36
|
+
var import_shallowCompare = require("./shallowCompare.js");
|
|
37
|
+
var import_uniqueId = require("./uniqueId.js");
|
|
38
|
+
var import_throwWrongKeyOnActionCollectionConfig = require("./throwWrongKeyOnActionCollectionConfig.js");
|
|
39
|
+
var import_isRecord = require("./isRecord.js");
|
|
40
|
+
var import_actions = require("./actions.js");
|
package/bundle.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { GlobalStore } from "./GlobalStore.mjs";
|
|
3
|
+
import { createGlobalState } from "./createGlobalState.mjs";
|
|
4
|
+
import { createContext } from "./createContext.mjs";
|
|
5
|
+
import { shallowCompare } from "./shallowCompare.mjs";
|
|
6
|
+
import { uniqueId } from "./uniqueId.mjs";
|
|
7
|
+
import { throwWrongKeyOnActionCollectionConfig } from "./throwWrongKeyOnActionCollectionConfig.mjs";
|
|
8
|
+
import { isRecord } from "./isRecord.mjs";
|
|
9
|
+
import { actions } from "./actions.mjs";
|
|
10
|
+
export {
|
|
11
|
+
GlobalStore,
|
|
12
|
+
actions,
|
|
13
|
+
createContext,
|
|
14
|
+
createGlobalState,
|
|
15
|
+
isRecord,
|
|
16
|
+
shallowCompare,
|
|
17
|
+
throwWrongKeyOnActionCollectionConfig,
|
|
18
|
+
uniqueId
|
|
19
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
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/createContext.ts
|
|
31
|
+
var createContext_exports = {};
|
|
32
|
+
__export(createContext_exports, {
|
|
33
|
+
createContext: () => import_createContext.createContext,
|
|
34
|
+
default: () => import_createContext.default
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(createContext_exports);
|
|
37
|
+
var import_createContext = __toESM(require("react-hooks-global-states/createContext"));
|
package/createContext.js
CHANGED
|
@@ -1 +1,37 @@
|
|
|
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/createContext.ts
|
|
31
|
+
var createContext_exports = {};
|
|
32
|
+
__export(createContext_exports, {
|
|
33
|
+
createContext: () => import_createContext.createContext,
|
|
34
|
+
default: () => import_createContext.default
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(createContext_exports);
|
|
37
|
+
var import_createContext = __toESM(require("react-hooks-global-states/createContext"));
|
|
@@ -0,0 +1,41 @@
|
|
|
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/createGlobalState.ts
|
|
31
|
+
var createGlobalState_exports = {};
|
|
32
|
+
__export(createGlobalState_exports, {
|
|
33
|
+
createGlobalState: () => createGlobalState,
|
|
34
|
+
default: () => createGlobalState_default
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(createGlobalState_exports);
|
|
37
|
+
var import_GlobalStore = __toESM(require("./GlobalStore.cjs"));
|
|
38
|
+
var createGlobalState = (...args) => {
|
|
39
|
+
return new import_GlobalStore.default(...args).use;
|
|
40
|
+
};
|
|
41
|
+
var createGlobalState_default = createGlobalState;
|
package/createGlobalState.js
CHANGED
|
@@ -1 +1,41 @@
|
|
|
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/createGlobalState.ts
|
|
31
|
+
var createGlobalState_exports = {};
|
|
32
|
+
__export(createGlobalState_exports, {
|
|
33
|
+
createGlobalState: () => createGlobalState,
|
|
34
|
+
default: () => createGlobalState_default
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(createGlobalState_exports);
|
|
37
|
+
var import_GlobalStore = __toESM(require("./GlobalStore.js"));
|
|
38
|
+
var createGlobalState = (...args) => {
|
|
39
|
+
return new import_GlobalStore.default(...args).use;
|
|
40
|
+
};
|
|
41
|
+
var createGlobalState_default = createGlobalState;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/createGlobalState.ts
|
|
2
|
+
import GlobalStore from "./GlobalStore.mjs";
|
|
3
|
+
var createGlobalState = (...args) => {
|
|
4
|
+
return new GlobalStore(...args).use;
|
|
5
|
+
};
|
|
6
|
+
var createGlobalState_default = createGlobalState;
|
|
7
|
+
export {
|
|
8
|
+
createGlobalState,
|
|
9
|
+
createGlobalState_default as default
|
|
10
|
+
};
|
package/isRecord.cjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
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: () => import_isRecord.default,
|
|
34
|
+
isRecord: () => import_isRecord.isRecord
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(isRecord_exports);
|
|
37
|
+
var import_isRecord = __toESM(require("react-hooks-global-states/isRecord"));
|