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/GlobalStore.cjs
CHANGED
|
@@ -1,525 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __spreadValues = (a, b) => {
|
|
14
|
-
for (var prop in b || (b = {}))
|
|
15
|
-
if (__hasOwnProp.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols)
|
|
18
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
-
if (__propIsEnum.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
-
var __export = (target, all) => {
|
|
26
|
-
for (var name in all)
|
|
27
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
28
|
-
};
|
|
29
|
-
var __copyProps = (to, from, except, desc) => {
|
|
30
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
31
|
-
for (let key of __getOwnPropNames(from))
|
|
32
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
33
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
34
|
-
}
|
|
35
|
-
return to;
|
|
36
|
-
};
|
|
37
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
38
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
39
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
40
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
41
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
42
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
43
|
-
mod
|
|
44
|
-
));
|
|
45
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
46
|
-
|
|
47
|
-
// src/GlobalStore.ts
|
|
48
|
-
var GlobalStore_exports = {};
|
|
49
|
-
__export(GlobalStore_exports, {
|
|
50
|
-
GlobalStore: () => GlobalStore,
|
|
51
|
-
createObservable: () => createObservable,
|
|
52
|
-
createSelectorHook: () => createSelectorHook,
|
|
53
|
-
default: () => GlobalStore_default
|
|
54
|
-
});
|
|
55
|
-
module.exports = __toCommonJS(GlobalStore_exports);
|
|
56
|
-
var import_react = require("react");
|
|
57
|
-
var import_isFunction = __toESM(require("json-storage-formatter/isFunction"));
|
|
58
|
-
var import_isRecord = __toESM(require("./isRecord.cjs"));
|
|
59
|
-
var import_shallowCompare = __toESM(require("./shallowCompare.cjs"));
|
|
60
|
-
var import_throwWrongKeyOnActionCollectionConfig = __toESM(require("./throwWrongKeyOnActionCollectionConfig.cjs"));
|
|
61
|
-
var import_uniqueId = __toESM(require("./uniqueId.cjs"));
|
|
62
|
-
var import_GlobalStore = __toESM(require("./GlobalStore.debugProps.cjs"));
|
|
63
|
-
var GlobalStore = class _GlobalStore {
|
|
64
|
-
constructor(state, args = { metadata: {} }) {
|
|
65
|
-
this.cleanupFunctions = [];
|
|
66
|
-
this.actionsConfig = null;
|
|
67
|
-
this.callbacks = null;
|
|
68
|
-
/**
|
|
69
|
-
* @description If the actionsConfig is defined, this will be a map of actions that can be used to modify or interact with the state
|
|
70
|
-
* */
|
|
71
|
-
this.actions = null;
|
|
72
|
-
/**
|
|
73
|
-
* @deprecated
|
|
74
|
-
* @description Set of subscribers that are listening to state changes
|
|
75
|
-
* Useful for debugging purposes... You'll probably not need to use this in your application
|
|
76
|
-
*/
|
|
77
|
-
this.subscribers = /* @__PURE__ */ new Set();
|
|
78
|
-
this.createSelectorHook = createSelectorHook;
|
|
79
|
-
this.createObservable = createObservable;
|
|
80
|
-
var _a, _b, _c;
|
|
81
|
-
const { metadata, callbacks, actions, name: storeName } = args;
|
|
82
|
-
if ((0, import_isFunction.default)(state)) this.stateCallback = state;
|
|
83
|
-
if ((0, import_isFunction.default)(metadata)) this.metadataCallback = metadata;
|
|
84
|
-
this._name = storeName != null ? storeName : (0, import_uniqueId.default)("gs:");
|
|
85
|
-
this.state = this.stateCallback ? this.stateCallback() : state;
|
|
86
|
-
this.metadata = this.metadataCallback ? this.metadataCallback() : metadata != null ? metadata : {};
|
|
87
|
-
this.callbacks = callbacks != null ? callbacks : null;
|
|
88
|
-
this.actionsConfig = actions != null ? actions : null;
|
|
89
|
-
if (import_GlobalStore.default.isDevToolsPresent) {
|
|
90
|
-
const hookStack = (_a = new Error().stack) != null ? _a : "";
|
|
91
|
-
(_c = (_b = import_GlobalStore.default).REACT_GLOBAL_STATE_HOOK_DEBUG) == null ? void 0 : _c.call(_b, this, args, hookStack);
|
|
92
|
-
}
|
|
93
|
-
const isExtensionClass = this.constructor !== _GlobalStore;
|
|
94
|
-
if (isExtensionClass) return;
|
|
95
|
-
this.initialize();
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* @description
|
|
99
|
-
* Initializes the global store, setting up the main hook and actions map if applicable,
|
|
100
|
-
*/
|
|
101
|
-
async initialize() {
|
|
102
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
103
|
-
const storeAndActions = (_b = (_a = this.__devtools_initialize_getStoreActionsMapWrapped) == null ? void 0 : _a.call(this)) != null ? _b : this.getStoreActionsMap();
|
|
104
|
-
const { actions, storeTools } = storeAndActions;
|
|
105
|
-
this.actions = actions;
|
|
106
|
-
this.storeTools = storeTools;
|
|
107
|
-
this.use = this.getMainHook();
|
|
108
|
-
const extensionCleanup = (_d = (_c = this.onInit) == null ? void 0 : _c.call(this)) != null ? _d : null;
|
|
109
|
-
if ((0, import_isFunction.default)(extensionCleanup)) this.cleanupFunctions.push(extensionCleanup);
|
|
110
|
-
const { onInit: onInitFromConfig } = (_e = this.callbacks) != null ? _e : {};
|
|
111
|
-
if (!onInitFromConfig) return;
|
|
112
|
-
const onInitFromConfigStoreTools = (_g = (_f = this.__devtools_getLifeCycleStoreToolsWrapper) == null ? void 0 : _f.call(this, "config/onInit/")) != null ? _g : storeTools;
|
|
113
|
-
const configCleanup = (_h = onInitFromConfig == null ? void 0 : onInitFromConfig(onInitFromConfigStoreTools)) != null ? _h : null;
|
|
114
|
-
if ((0, import_isFunction.default)(configCleanup)) this.cleanupFunctions.push(configCleanup);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* set the state for a single subscriber
|
|
118
|
-
* validate if the state should be updated by comparing the previous state and the new state
|
|
119
|
-
*/
|
|
120
|
-
executeSetStateForSubscriber(subscription, args) {
|
|
121
|
-
const {
|
|
122
|
-
selector,
|
|
123
|
-
onStoreChange: callback,
|
|
124
|
-
currentState: currentChildState,
|
|
125
|
-
isEqualRoot = (a, b) => a === b,
|
|
126
|
-
isEqual = (a, b) => a === b
|
|
127
|
-
} = subscription;
|
|
128
|
-
if (!args.forceUpdate && isEqualRoot(args.currentState, args.newState)) {
|
|
129
|
-
return { didUpdate: false };
|
|
130
|
-
}
|
|
131
|
-
const newChildState = selector ? selector(args.newState) : args.newState;
|
|
132
|
-
if (!args.forceUpdate && isEqual(currentChildState, newChildState)) {
|
|
133
|
-
return { didUpdate: false };
|
|
134
|
-
}
|
|
135
|
-
this.partialUpdateSubscription(subscription, {
|
|
136
|
-
currentState: newChildState
|
|
137
|
-
});
|
|
138
|
-
callback(
|
|
139
|
-
{
|
|
140
|
-
state: newChildState
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
identifier: args.identifier
|
|
144
|
-
}
|
|
145
|
-
);
|
|
146
|
-
return { didUpdate: true };
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* set the state and update all the subscribers
|
|
150
|
-
* @param {State} newState - The new state to set
|
|
151
|
-
* @param {object} options - The options for setting the state
|
|
152
|
-
* @param {boolean} [options.forceUpdate] - Whether to force the update even if the state is the same
|
|
153
|
-
* @param {string} [options.identifier] - An optional identifier for the state change
|
|
154
|
-
* */
|
|
155
|
-
setActualStateWithoutValidations(newState, { forceUpdate, identifier }) {
|
|
156
|
-
const currentState = this.state;
|
|
157
|
-
const shouldUpdate = forceUpdate || currentState !== newState;
|
|
158
|
-
if (!shouldUpdate) return;
|
|
159
|
-
this.state = newState;
|
|
160
|
-
const subscribers = this.subscribers.values();
|
|
161
|
-
const args = {
|
|
162
|
-
forceUpdate,
|
|
163
|
-
newState,
|
|
164
|
-
currentState,
|
|
165
|
-
identifier
|
|
166
|
-
};
|
|
167
|
-
for (const subscription of subscribers) {
|
|
168
|
-
this.executeSetStateForSubscriber(subscription, args);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Set the value of the metadata property, this is no reactive and will not trigger a re-render
|
|
173
|
-
* @param {MetadataSetter<Metadata>} setter - The setter function or the value to set
|
|
174
|
-
* */
|
|
175
|
-
setMetadata(setter) {
|
|
176
|
-
const metadata = (0, import_isFunction.default)(setter) ? setter(this.metadata) : setter;
|
|
177
|
-
this.metadata = metadata;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Returns the metadata [non-reactive additional information associated with the global state]
|
|
181
|
-
*/
|
|
182
|
-
getMetadata() {
|
|
183
|
-
return this.metadata;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Get the current value of the state
|
|
187
|
-
*/
|
|
188
|
-
getState() {
|
|
189
|
-
return this.state;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Subscribe an individual callback to state changes
|
|
193
|
-
*/
|
|
194
|
-
subscribe(...[param1, param2, param3]) {
|
|
195
|
-
var _a;
|
|
196
|
-
const hasExplicitSelector = (0, import_isFunction.default)(param2);
|
|
197
|
-
const selector = hasExplicitSelector ? param1 : void 0;
|
|
198
|
-
const callback = hasExplicitSelector ? param2 : param1;
|
|
199
|
-
const options = (_a = hasExplicitSelector ? param3 : param2) != null ? _a : void 0;
|
|
200
|
-
const initialState = selector ? selector(this.state) : this.state;
|
|
201
|
-
if (!(options == null ? void 0 : options.skipFirst)) {
|
|
202
|
-
callback(initialState);
|
|
203
|
-
}
|
|
204
|
-
const subscription = __spreadValues({
|
|
205
|
-
selector,
|
|
206
|
-
currentState: initialState,
|
|
207
|
-
onStoreChange: ({ state }) => callback(state)
|
|
208
|
-
}, options);
|
|
209
|
-
this.subscribeCallback(subscription);
|
|
210
|
-
return () => {
|
|
211
|
-
this.subscribers.delete(subscription);
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Adds a subscription object to the subscribers set and returns the unsubscribe function
|
|
216
|
-
*/
|
|
217
|
-
subscribeCallback(subscription) {
|
|
218
|
-
var _a, _b;
|
|
219
|
-
(_b = (_a = this.callbacks) == null ? void 0 : _a.onSubscribed) == null ? void 0 : _b.call(_a, this.storeTools, subscription);
|
|
220
|
-
this.subscribers.add(subscription);
|
|
221
|
-
return () => {
|
|
222
|
-
this.subscribers.delete(subscription);
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
partialUpdateSubscription(subscription, values) {
|
|
226
|
-
Object.assign(subscription, values);
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Returns a custom hook that allows to handle a global state
|
|
230
|
-
* @returns {[State, StateMutator, Metadata]} - The state, the state setter or the actions map, the metadata
|
|
231
|
-
* */
|
|
232
|
-
getMainHook() {
|
|
233
|
-
const identifier = `globalHook:${this._name}`;
|
|
234
|
-
const use = (selector, args = []) => {
|
|
235
|
-
(0, import_react.useDebugValue)(identifier);
|
|
236
|
-
const options = (0, import_shallowCompare.isArray)(args) ? { dependencies: args } : args != null ? args : {};
|
|
237
|
-
const subscriptionRef = (0, import_react.useRef)(null);
|
|
238
|
-
const selectorWrapper = (state) => {
|
|
239
|
-
return (0, import_isFunction.default)(selector) ? selector(state) : state;
|
|
240
|
-
};
|
|
241
|
-
subscriptionRef.current = (() => {
|
|
242
|
-
if (subscriptionRef.current) return subscriptionRef.current;
|
|
243
|
-
return __spreadValues({
|
|
244
|
-
selector: selectorWrapper,
|
|
245
|
-
currentState: selectorWrapper(this.state),
|
|
246
|
-
onStoreChange: () => {
|
|
247
|
-
throw new Error("Callback not set");
|
|
248
|
-
}
|
|
249
|
-
}, options);
|
|
250
|
-
})();
|
|
251
|
-
const currentDependencies = subscriptionRef.current.dependencies;
|
|
252
|
-
const newDependencies = options == null ? void 0 : options.dependencies;
|
|
253
|
-
const extensions = __spreadProps(__spreadValues({}, options), {
|
|
254
|
-
selector: selectorWrapper,
|
|
255
|
-
dependencies: newDependencies
|
|
256
|
-
});
|
|
257
|
-
this.partialUpdateSubscription(subscriptionRef.current, extensions);
|
|
258
|
-
const { subscribe, getSnapshot, getServerSnapshot } = (0, import_react.useMemo)(() => {
|
|
259
|
-
const subscribe2 = (onStoreChange) => {
|
|
260
|
-
subscriptionRef.current.onStoreChange = onStoreChange;
|
|
261
|
-
return this.subscribeCallback(subscriptionRef.current);
|
|
262
|
-
};
|
|
263
|
-
const getSnapshot2 = () => {
|
|
264
|
-
return subscriptionRef.current.currentState;
|
|
265
|
-
};
|
|
266
|
-
const getServerSnapshot2 = getSnapshot2;
|
|
267
|
-
return { subscribe: subscribe2, getSnapshot: getSnapshot2, getServerSnapshot: getServerSnapshot2 };
|
|
268
|
-
}, []);
|
|
269
|
-
this.reselectIfDependenciesChanged({
|
|
270
|
-
subscription: subscriptionRef.current,
|
|
271
|
-
newDependencies,
|
|
272
|
-
currentDependencies
|
|
273
|
-
});
|
|
274
|
-
return [
|
|
275
|
-
(0, import_react.useSyncExternalStore)(subscribe, getSnapshot, getServerSnapshot),
|
|
276
|
-
this.getStateOrchestrator(),
|
|
277
|
-
this.metadata
|
|
278
|
-
];
|
|
279
|
-
};
|
|
280
|
-
const apiAsReadOnly = this;
|
|
281
|
-
const useExtensions = {
|
|
282
|
-
actions: this.actions,
|
|
283
|
-
createObservable: this.createObservable.bind(apiAsReadOnly),
|
|
284
|
-
createSelectorHook: this.createSelectorHook.bind(apiAsReadOnly),
|
|
285
|
-
dispose: this.dispose.bind(this),
|
|
286
|
-
getMetadata: this.getMetadata.bind(this),
|
|
287
|
-
getState: this.getState.bind(this),
|
|
288
|
-
reset: this.reset.bind(this),
|
|
289
|
-
setMetadata: this.setMetadata.bind(this),
|
|
290
|
-
setState: this.setState.bind(this),
|
|
291
|
-
subscribe: this.subscribe.bind(this),
|
|
292
|
-
// useful for debugging purposes
|
|
293
|
-
subscribers: this.subscribers,
|
|
294
|
-
// sugar syntax
|
|
295
|
-
use,
|
|
296
|
-
select: (...args) => use(...args)[0]
|
|
297
|
-
};
|
|
298
|
-
Object.assign(use, useExtensions);
|
|
299
|
-
return use;
|
|
300
|
-
}
|
|
301
|
-
reselectIfDependenciesChanged({
|
|
302
|
-
subscription,
|
|
303
|
-
newDependencies,
|
|
304
|
-
currentDependencies
|
|
305
|
-
}) {
|
|
306
|
-
if (!subscription.selector) return;
|
|
307
|
-
if (currentDependencies === newDependencies) return;
|
|
308
|
-
const isLengthEqual = (currentDependencies == null ? void 0 : currentDependencies.length) === (newDependencies == null ? void 0 : newDependencies.length);
|
|
309
|
-
const isSameValues = isLengthEqual && (0, import_shallowCompare.default)(currentDependencies, newDependencies);
|
|
310
|
-
if (isSameValues) return;
|
|
311
|
-
this.partialUpdateSubscription(subscription, {
|
|
312
|
-
currentState: subscription.selector(this.state)
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Returns the state setter or the actions map
|
|
317
|
-
* @returns {StateMutator} - The state setter or the actions map
|
|
318
|
-
* */
|
|
319
|
-
getStateOrchestrator() {
|
|
320
|
-
return (() => {
|
|
321
|
-
if (this.actions) {
|
|
322
|
-
return this.actions;
|
|
323
|
-
}
|
|
324
|
-
return this.setState.bind(this);
|
|
325
|
-
})();
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* This is the only setState function that should be exposed outside the class
|
|
329
|
-
* This is responsible for defining whenever or not the state change should be allowed or prevented
|
|
330
|
-
* the function also execute the functions:
|
|
331
|
-
* - onStateChanged (if defined) - this function is executed after the state change
|
|
332
|
-
* - computePreventStateChange (if defined) - this function is executed before the state change and it should return a boolean value that will be used to determine if the state change should be prevented or not
|
|
333
|
-
*/
|
|
334
|
-
setState(setter, {
|
|
335
|
-
forceUpdate,
|
|
336
|
-
identifier
|
|
337
|
-
} = {}) {
|
|
338
|
-
var _a, _b, _c, _d, _e, _f;
|
|
339
|
-
const previousState = this.state;
|
|
340
|
-
const newState = (0, import_isFunction.default)(setter) ? setter(previousState) : setter;
|
|
341
|
-
if (!forceUpdate && this.state === newState) return;
|
|
342
|
-
const setState = this.setActualStateWithoutValidations;
|
|
343
|
-
const stateChanges = {
|
|
344
|
-
previousState,
|
|
345
|
-
state: newState,
|
|
346
|
-
identifier
|
|
347
|
-
};
|
|
348
|
-
const storeTools = __spreadProps(__spreadValues(__spreadValues({}, this.storeTools), stateChanges), {
|
|
349
|
-
setState
|
|
350
|
-
});
|
|
351
|
-
if ((_a = this.callbacks) == null ? void 0 : _a.computePreventStateChange) {
|
|
352
|
-
const shouldPreventStateChange = (_c = (_b = this.callbacks) == null ? void 0 : _b.computePreventStateChange) == null ? void 0 : _c.call(_b, storeTools);
|
|
353
|
-
if (shouldPreventStateChange) return;
|
|
354
|
-
}
|
|
355
|
-
this.setActualStateWithoutValidations(newState, { forceUpdate, identifier });
|
|
356
|
-
(_d = this.onStateChanged) == null ? void 0 : _d.call(this, storeTools);
|
|
357
|
-
(_f = (_e = this.callbacks) == null ? void 0 : _e.onStateChanged) == null ? void 0 : _f.call(_e, storeTools);
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* This creates storeTools and actions map if applicable
|
|
361
|
-
* */
|
|
362
|
-
getStoreActionsMap() {
|
|
363
|
-
const storeTools = {
|
|
364
|
-
setMetadata: this.setMetadata.bind(this),
|
|
365
|
-
getMetadata: this.getMetadata.bind(this),
|
|
366
|
-
getState: this.getState.bind(this),
|
|
367
|
-
setState: this.setState.bind(this),
|
|
368
|
-
subscribe: this.subscribe.bind(this),
|
|
369
|
-
actions: null
|
|
370
|
-
};
|
|
371
|
-
if (!(0, import_isRecord.default)(this.actionsConfig)) {
|
|
372
|
-
return {
|
|
373
|
-
actions: null,
|
|
374
|
-
storeTools
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
const actionsConfig = this.actionsConfig;
|
|
378
|
-
const actions = {};
|
|
379
|
-
storeTools.actions = actions;
|
|
380
|
-
const actionsKeys = Object.keys(actionsConfig);
|
|
381
|
-
for (const action_key of actionsKeys) {
|
|
382
|
-
Object.assign(actions, {
|
|
383
|
-
[action_key](...parameters) {
|
|
384
|
-
const actionConfig = actionsConfig[action_key];
|
|
385
|
-
const action = actionConfig.apply(actions, parameters);
|
|
386
|
-
const actionIsNotAFunction = typeof action !== "function";
|
|
387
|
-
if (actionIsNotAFunction) {
|
|
388
|
-
(0, import_throwWrongKeyOnActionCollectionConfig.default)(action_key);
|
|
389
|
-
}
|
|
390
|
-
const result = action.call(actions, storeTools);
|
|
391
|
-
return result;
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
return {
|
|
396
|
-
actions,
|
|
397
|
-
storeTools
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
removeSubscriptions() {
|
|
401
|
-
this.subscribers.clear();
|
|
402
|
-
}
|
|
403
|
-
executeCleanupTasks() {
|
|
404
|
-
this.cleanupFunctions.forEach((cleanup) => {
|
|
405
|
-
cleanup == null ? void 0 : cleanup();
|
|
406
|
-
});
|
|
407
|
-
this.cleanupFunctions.length = 0;
|
|
408
|
-
}
|
|
409
|
-
dispose() {
|
|
410
|
-
this.removeSubscriptions();
|
|
411
|
-
this.executeCleanupTasks();
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* @description Resets the store to a new initial state and re-runs initialization.
|
|
415
|
-
*
|
|
416
|
-
* This method is reserved for advanced use cases and testing scenarios, use with caution.
|
|
417
|
-
*/
|
|
418
|
-
reset(...args) {
|
|
419
|
-
var _a, _b, _c, _d, _e, _f;
|
|
420
|
-
this.executeCleanupTasks();
|
|
421
|
-
const hasArgs = args.length > 0;
|
|
422
|
-
const state = (() => {
|
|
423
|
-
if (hasArgs) return args[0];
|
|
424
|
-
if (this.stateCallback) return this.stateCallback();
|
|
425
|
-
return this.state;
|
|
426
|
-
})();
|
|
427
|
-
const metadata = (() => {
|
|
428
|
-
if (hasArgs) return args[1];
|
|
429
|
-
if (this.metadataCallback) return this.metadataCallback();
|
|
430
|
-
return this.metadata;
|
|
431
|
-
})();
|
|
432
|
-
this.setActualStateWithoutValidations(state, { forceUpdate: true });
|
|
433
|
-
this.setMetadata(metadata);
|
|
434
|
-
const extensionCleanup = (_b = (_a = this.onInit) == null ? void 0 : _a.call(this)) != null ? _b : null;
|
|
435
|
-
if ((0, import_isFunction.default)(extensionCleanup)) this.cleanupFunctions.push(extensionCleanup);
|
|
436
|
-
const { onInit: onInitFromConfig } = (_c = this.callbacks) != null ? _c : {};
|
|
437
|
-
if (!onInitFromConfig) return;
|
|
438
|
-
const onInitFromConfigStoreTools = (_e = (_d = this.__devtools_getLifeCycleStoreToolsWrapper) == null ? void 0 : _d.call(this, "config/onInit/")) != null ? _e : this.storeTools;
|
|
439
|
-
const configCleanup = (_f = onInitFromConfig == null ? void 0 : onInitFromConfig(onInitFromConfigStoreTools)) != null ? _f : null;
|
|
440
|
-
if ((0, import_isFunction.default)(configCleanup)) this.cleanupFunctions.push(configCleanup);
|
|
441
|
-
}
|
|
442
|
-
//#endregion DevTools extensions
|
|
443
|
-
};
|
|
444
|
-
function createObservable(selector, options) {
|
|
445
|
-
const selectorName = options == null ? void 0 : options.name;
|
|
446
|
-
const mainIsEqualRoot = options == null ? void 0 : options.isEqualRoot;
|
|
447
|
-
const mainIsEqual = options == null ? void 0 : options.isEqual;
|
|
448
|
-
let rootState = this.getState();
|
|
449
|
-
let selectedState = (selector != null ? selector : (s) => s)(rootState);
|
|
450
|
-
const childStore = new GlobalStore(selectedState, {
|
|
451
|
-
name: selectorName != null ? selectorName : (0, import_uniqueId.default)("sh:")
|
|
452
|
-
});
|
|
453
|
-
const unsubscribeFromRootState = this.subscribe(
|
|
454
|
-
(newRoot) => {
|
|
455
|
-
const isRootEqual = (mainIsEqualRoot != null ? mainIsEqualRoot : Object.is)(rootState, newRoot);
|
|
456
|
-
if (isRootEqual) return;
|
|
457
|
-
rootState = newRoot;
|
|
458
|
-
const selectedState$ = selector(newRoot);
|
|
459
|
-
const isSelectedValueEqual = (mainIsEqual != null ? mainIsEqual : Object.is)(selectedState, selectedState$);
|
|
460
|
-
if (isSelectedValueEqual) return;
|
|
461
|
-
selectedState = selectedState$;
|
|
462
|
-
childStore.setState(selectedState$);
|
|
463
|
-
},
|
|
464
|
-
{ skipFirst: true }
|
|
465
|
-
);
|
|
466
|
-
const observable = childStore.subscribe.bind(childStore);
|
|
467
|
-
const extensions = {
|
|
468
|
-
getState: childStore.getState.bind(childStore),
|
|
469
|
-
subscribe: childStore.subscribe.bind(childStore),
|
|
470
|
-
createSelectorHook: createSelectorHook.bind(observable),
|
|
471
|
-
createObservable: createObservable.bind(observable),
|
|
472
|
-
dispose: () => {
|
|
473
|
-
unsubscribeFromRootState();
|
|
474
|
-
childStore.dispose();
|
|
475
|
-
},
|
|
476
|
-
subscribers: childStore.subscribers
|
|
477
|
-
};
|
|
478
|
-
Object.assign(observable, extensions);
|
|
479
|
-
return observable;
|
|
480
|
-
}
|
|
481
|
-
function createSelectorHook(selector, options) {
|
|
482
|
-
const selectorName = options == null ? void 0 : options.name;
|
|
483
|
-
const mainIsEqualRoot = options == null ? void 0 : options.isEqualRoot;
|
|
484
|
-
const mainIsEqual = options == null ? void 0 : options.isEqual;
|
|
485
|
-
let rootState = this.getState();
|
|
486
|
-
let selectedState = (selector != null ? selector : (s) => s)(rootState);
|
|
487
|
-
const derivedStore = new GlobalStore(selectedState, {
|
|
488
|
-
name: selectorName != null ? selectorName : (0, import_uniqueId.default)("sh:")
|
|
489
|
-
});
|
|
490
|
-
const unsubscribeFromRootState = this.subscribe(
|
|
491
|
-
(newRoot) => {
|
|
492
|
-
const isRootEqual = (mainIsEqualRoot != null ? mainIsEqualRoot : Object.is)(rootState, newRoot);
|
|
493
|
-
if (isRootEqual) return;
|
|
494
|
-
rootState = newRoot;
|
|
495
|
-
const selectedState$ = selector(newRoot);
|
|
496
|
-
const isSelectedValueEqual = (mainIsEqual != null ? mainIsEqual : Object.is)(selectedState, selectedState$);
|
|
497
|
-
if (isSelectedValueEqual) return;
|
|
498
|
-
selectedState = selectedState$;
|
|
499
|
-
derivedStore.setState(selectedState$);
|
|
500
|
-
},
|
|
501
|
-
{ skipFirst: true }
|
|
502
|
-
);
|
|
503
|
-
const selectorHook = (...args) => {
|
|
504
|
-
const [selection] = derivedStore.use(...args);
|
|
505
|
-
return selection;
|
|
506
|
-
};
|
|
507
|
-
const extensions = {
|
|
508
|
-
getState: () => derivedStore.getState(),
|
|
509
|
-
subscribe: derivedStore.subscribe.bind(derivedStore),
|
|
510
|
-
createSelectorHook: createSelectorHook.bind(
|
|
511
|
-
selectorHook
|
|
512
|
-
),
|
|
513
|
-
createObservable: createObservable.bind(
|
|
514
|
-
selectorHook
|
|
515
|
-
),
|
|
516
|
-
dispose: () => {
|
|
517
|
-
unsubscribeFromRootState();
|
|
518
|
-
derivedStore.dispose();
|
|
519
|
-
},
|
|
520
|
-
subscribers: derivedStore.subscribers
|
|
521
|
-
};
|
|
522
|
-
Object.assign(selectorHook, extensions);
|
|
523
|
-
return selectorHook;
|
|
524
|
-
}
|
|
525
|
-
var GlobalStore_default = GlobalStore;
|
|
1
|
+
"use strict";var V=Object.create;var m=Object.defineProperty,W=Object.defineProperties,B=Object.getOwnPropertyDescriptor,I=Object.getOwnPropertyDescriptors,L=Object.getOwnPropertyNames,w=Object.getOwnPropertySymbols,G=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var F=(i,t,e)=>t in i?m(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,k=(i,t)=>{for(var e in t||(t={}))E.call(t,e)&&F(i,e,t[e]);if(w)for(var e of w(t))z.call(t,e)&&F(i,e,t[e]);return i},x=(i,t)=>W(i,I(t));var D=(i,t)=>{for(var e in t)m(i,e,{get:t[e],enumerable:!0})},H=(i,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of L(t))!E.call(i,s)&&s!==e&&m(i,s,{get:()=>t[s],enumerable:!(a=B(t,s))||a.enumerable});return i};var g=(i,t,e)=>(e=i!=null?V(G(i)):{},H(t||!i||!i.__esModule?m(e,"default",{value:i,enumerable:!0}):e,i)),K=i=>H(m({},"__esModule",{value:!0}),i);var $={};D($,{GlobalStore:()=>M,createObservable:()=>y,createSelectorHook:()=>R,default:()=>N});module.exports=K($);var f=require("react"),p=g(require("json-storage-formatter/isFunction")),_=g(require("./isRecord.cjs")),A=g(require("./shallowCompare.cjs")),U=g(require("./throwWrongKeyOnActionCollectionConfig.cjs")),v=g(require("./uniqueId.cjs")),O=g(require("./GlobalStore.debugProps.cjs"));var M=class i{constructor(t,e={metadata:{}}){this.cleanupFunctions=[];this.actionsConfig=null;this.callbacks=null;this.actions=null;this.subscribers=new Set;this.createSelectorHook=R;this.createObservable=y;var l,o,u;let{metadata:a,callbacks:s,actions:c,name:r}=e;if((0,p.default)(t)&&(this.stateCallback=t),(0,p.default)(a)&&(this.metadataCallback=a),this._name=r!=null?r:(0,v.default)("gs:"),this.state=this.stateCallback?this.stateCallback():t,this.metadata=this.metadataCallback?this.metadataCallback():a!=null?a:{},this.callbacks=s!=null?s:null,this.actionsConfig=c!=null?c:null,O.default.isDevToolsPresent){let b=(l=new Error().stack)!=null?l:"";(u=(o=O.default).REACT_GLOBAL_STATE_HOOK_DEBUG)==null||u.call(o,this,e,b)}this.constructor===i&&this.initialize()}async initialize(){var l,o,u,b,d,S,h,C;let t=(o=(l=this.__devtools_initialize_getStoreActionsMapWrapped)==null?void 0:l.call(this))!=null?o:this.getStoreActionsMap(),{actions:e,storeTools:a}=t;this.actions=e,this.storeTools=a,this.use=this.getMainHook();let s=(b=(u=this.onInit)==null?void 0:u.call(this))!=null?b:null;(0,p.default)(s)&&this.cleanupFunctions.push(s);let{onInit:c}=(d=this.callbacks)!=null?d:{};if(!c)return;let r=(h=(S=this.__devtools_getLifeCycleStoreToolsWrapper)==null?void 0:S.call(this,"config/onInit/"))!=null?h:a,n=(C=c==null?void 0:c(r))!=null?C:null;(0,p.default)(n)&&this.cleanupFunctions.push(n)}executeSetStateForSubscriber(t,e){let{selector:a,onStoreChange:s,currentState:c,isEqualRoot:r=(o,u)=>o===u,isEqual:n=(o,u)=>o===u}=t;if(!e.forceUpdate&&r(e.currentState,e.newState))return{didUpdate:!1};let l=a?a(e.newState):e.newState;return!e.forceUpdate&&n(c,l)?{didUpdate:!1}:(this.partialUpdateSubscription(t,{currentState:l}),s({state:l},{identifier:e.identifier}),{didUpdate:!0})}setActualStateWithoutValidations(t,{forceUpdate:e,identifier:a}){let s=this.state;if(!(e||s!==t))return;this.state=t;let r=this.subscribers.values(),n={forceUpdate:e,newState:t,currentState:s,identifier:a};for(let l of r)this.executeSetStateForSubscriber(l,n)}setMetadata(t){let e=(0,p.default)(t)?t(this.metadata):t;this.metadata=e}getMetadata(){return this.metadata}getState(){return this.state}subscribe(...[t,e,a]){var u;let s=(0,p.default)(e),c=s?t:void 0,r=s?e:t,n=(u=s?a:e)!=null?u:void 0,l=c?c(this.state):this.state;n!=null&&n.skipFirst||r(l);let o=k({selector:c,currentState:l,onStoreChange:({state:b})=>r(b)},n);return this.subscribeCallback(o),()=>{this.subscribers.delete(o)}}subscribeCallback(t){var e,a;return(a=(e=this.callbacks)==null?void 0:e.onSubscribed)==null||a.call(e,this.storeTools,t),this.subscribers.add(t),()=>{this.subscribers.delete(t)}}partialUpdateSubscription(t,e){Object.assign(t,e)}getMainHook(){let t=`globalHook:${this._name}`,e=(r,n=[])=>{(0,f.useDebugValue)(t);let l=(0,A.isArray)(n)?{dependencies:n}:n!=null?n:{},o=(0,f.useRef)(null),u=P=>(0,p.default)(r)?r(P):P;o.current=o.current?o.current:k({selector:u,currentState:u(this.state),onStoreChange:()=>{throw new Error("Callback not set")}},l);let b=o.current.dependencies,d=l==null?void 0:l.dependencies,S=x(k({},l),{selector:u,dependencies:d});this.partialUpdateSubscription(o.current,S);let{subscribe:h,getSnapshot:C,getServerSnapshot:q}=(0,f.useMemo)(()=>{let P=j=>(o.current.onStoreChange=j,this.subscribeCallback(o.current)),T=()=>o.current.currentState;return{subscribe:P,getSnapshot:T,getServerSnapshot:T}},[]);return this.reselectIfDependenciesChanged({subscription:o.current,newDependencies:d,currentDependencies:b}),[(0,f.useSyncExternalStore)(h,C,q),this.getStateOrchestrator(),this.metadata]},a=this,s=this.getMetadata.bind(this),c={actions:this.actions,createObservable:this.createObservable.bind(a),createSelectorHook:this.createSelectorHook.bind(a),dispose:this.dispose.bind(this),metadata:void 0,getMetadata:s,getState:this.getState.bind(this),reset:this.reset.bind(this),setMetadata:this.setMetadata.bind(this),setState:this.setState.bind(this),subscribe:this.subscribe.bind(this),subscribers:this.subscribers,use:e,select:(...r)=>e(...r)[0]};return Object.assign(e,c),Object.defineProperty(e,"metadata",{configurable:!0,enumerable:!0,get:s}),e}reselectIfDependenciesChanged({subscription:t,newDependencies:e,currentDependencies:a}){!t.selector||a===e||(a==null?void 0:a.length)===(e==null?void 0:e.length)&&(0,A.default)(a,e)||this.partialUpdateSubscription(t,{currentState:t.selector(this.state)})}getStateOrchestrator(){return this.actions?this.actions:this.setState.bind(this)}setState(t,{forceUpdate:e,identifier:a}={}){var o,u,b,d,S,h;let s=this.state,c=(0,p.default)(t)?t(s):t;if(!e&&this.state===c)return;let r=this.setActualStateWithoutValidations,n={previousState:s,state:c,identifier:a},l=x(k(k({},this.storeTools),n),{setState:r});Object.defineProperty(l,"metadata",{configurable:!0,enumerable:!0,get:l.getMetadata}),!((o=this.callbacks)!=null&&o.computePreventStateChange&&((b=(u=this.callbacks)==null?void 0:u.computePreventStateChange)!=null&&b.call(u,l)))&&(this.setActualStateWithoutValidations(c,{forceUpdate:e,identifier:a}),(d=this.onStateChanged)==null||d.call(this,l),(h=(S=this.callbacks)==null?void 0:S.onStateChanged)==null||h.call(S,l))}getStoreActionsMap(){let t=this.getMetadata.bind(this),e={setMetadata:this.setMetadata.bind(this),get metadata(){return t()},getMetadata:t,getState:this.getState.bind(this),setState:this.setState.bind(this),subscribe:this.subscribe.bind(this),actions:null};if(!(0,_.default)(this.actionsConfig))return{actions:null,storeTools:e};let a=this.actionsConfig,s={};e.actions=s;let c=Object.keys(a);for(let r of c)Object.assign(s,{[r](...n){let o=a[r].apply(s,n);return typeof o!="function"&&(0,U.default)(r),o.call(s,e)}});return{actions:s,storeTools:e}}removeSubscriptions(){this.subscribers.clear()}executeCleanupTasks(){this.cleanupFunctions.forEach(t=>{t==null||t()}),this.cleanupFunctions.length=0}dispose(){this.removeSubscriptions(),this.executeCleanupTasks()}reset(...t){var o,u,b,d,S,h;this.executeCleanupTasks();let e=t.length>0,a=e?t[0]:this.stateCallback?this.stateCallback():this.state,s=e?t[1]:this.metadataCallback?this.metadataCallback():this.metadata;this.setActualStateWithoutValidations(a,{forceUpdate:!0}),this.setMetadata(s);let c=(u=(o=this.onInit)==null?void 0:o.call(this))!=null?u:null;(0,p.default)(c)&&this.cleanupFunctions.push(c);let{onInit:r}=(b=this.callbacks)!=null?b:{};if(!r)return;let n=(S=(d=this.__devtools_getLifeCycleStoreToolsWrapper)==null?void 0:d.call(this,"config/onInit/"))!=null?S:this.storeTools,l=(h=r==null?void 0:r(n))!=null?h:null;(0,p.default)(l)&&this.cleanupFunctions.push(l)}};function y(i,t){let e=t==null?void 0:t.name,a=t==null?void 0:t.isEqualRoot,s=t==null?void 0:t.isEqual,c=this.getState(),r=(i!=null?i:b=>b)(c),n=new M(r,{name:e!=null?e:(0,v.default)("sh:")}),l=this.subscribe(b=>{if((a!=null?a:Object.is)(c,b))return;c=b;let S=i(b);(s!=null?s:Object.is)(r,S)||(r=S,n.setState(S))},{skipFirst:!0}),o=n.subscribe.bind(n),u={getState:n.getState.bind(n),subscribe:n.subscribe.bind(n),createSelectorHook:R.bind(o),createObservable:y.bind(o),dispose:()=>{l(),n.dispose()},subscribers:n.subscribers};return Object.assign(o,u),o}function R(i,t){let e=t==null?void 0:t.name,a=t==null?void 0:t.isEqualRoot,s=t==null?void 0:t.isEqual,c=this.getState(),r=(i!=null?i:b=>b)(c),n=new M(r,{name:e!=null?e:(0,v.default)("sh:")}),l=this.subscribe(b=>{if((a!=null?a:Object.is)(c,b))return;c=b;let S=i(b);(s!=null?s:Object.is)(r,S)||(r=S,n.setState(S))},{skipFirst:!0}),o=(...b)=>{let[d]=n.use(...b);return d},u={getState:()=>n.getState(),subscribe:n.subscribe.bind(n),createSelectorHook:R.bind(o),createObservable:y.bind(o),dispose:()=>{l(),n.dispose()},subscribers:n.subscribers};return Object.assign(o,u),o}var N=M;
|
|
@@ -1,28 +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/GlobalStore.debugProps.ts
|
|
21
|
-
var GlobalStore_debugProps_exports = {};
|
|
22
|
-
__export(GlobalStore_debugProps_exports, {
|
|
23
|
-
default: () => GlobalStore_debugProps_default
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(GlobalStore_debugProps_exports);
|
|
26
|
-
var debugProps = globalThis;
|
|
27
|
-
debugProps.isDevToolsPresent = Boolean(debugProps.REACT_GLOBAL_STATE_HOOK_DEBUG);
|
|
28
|
-
var GlobalStore_debugProps_default = debugProps;
|
|
1
|
+
"use strict";var T=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var t=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var r=(e,o)=>{for(var n in o)T(e,n,{get:o[n],enumerable:!0})},A=(e,o,n,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of t(o))!_.call(e,s)&&s!==n&&T(e,s,{get:()=>o[s],enumerable:!(i=l(o,s))||i.enumerable});return e};var E=e=>A(T({},"__esModule",{value:!0}),e);var d={};r(d,{default:()=>O});module.exports=E(d);var a=globalThis;a.isDevToolsPresent=!!a.REACT_GLOBAL_STATE_HOOK_DEBUG;var O=a;
|
|
@@ -1,28 +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/GlobalStore.debugProps.ts
|
|
21
|
-
var GlobalStore_debugProps_exports = {};
|
|
22
|
-
__export(GlobalStore_debugProps_exports, {
|
|
23
|
-
default: () => GlobalStore_debugProps_default
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(GlobalStore_debugProps_exports);
|
|
26
|
-
var debugProps = globalThis;
|
|
27
|
-
debugProps.isDevToolsPresent = Boolean(debugProps.REACT_GLOBAL_STATE_HOOK_DEBUG);
|
|
28
|
-
var GlobalStore_debugProps_default = debugProps;
|
|
1
|
+
"use strict";var T=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var t=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var r=(e,o)=>{for(var n in o)T(e,n,{get:o[n],enumerable:!0})},A=(e,o,n,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of t(o))!_.call(e,s)&&s!==n&&T(e,s,{get:()=>o[s],enumerable:!(i=l(o,s))||i.enumerable});return e};var E=e=>A(T({},"__esModule",{value:!0}),e);var d={};r(d,{default:()=>O});module.exports=E(d);var a=globalThis;a.isDevToolsPresent=!!a.REACT_GLOBAL_STATE_HOOK_DEBUG;var O=a;
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var debugProps = globalThis;
|
|
3
|
-
debugProps.isDevToolsPresent = Boolean(debugProps.REACT_GLOBAL_STATE_HOOK_DEBUG);
|
|
4
|
-
var GlobalStore_debugProps_default = debugProps;
|
|
5
|
-
export {
|
|
6
|
-
GlobalStore_debugProps_default as default
|
|
7
|
-
};
|
|
1
|
+
var o=globalThis;o.isDevToolsPresent=!!o.REACT_GLOBAL_STATE_HOOK_DEBUG;var e=o;export{e as default};
|